# HG changeset patch # User JeanDo # Date 1307489834 -7200 # Node ID 88660a400338610a3fd83aac54a21903d348a8e8 # Parent 562f1bc79f3c5e71530a77e6d53bdf75ea1f9d17# Parent d4ca9196e8305f45fa33df3c24a63cf01fc9f421 Updated 64K logbook to changeset 360. diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/MAIN.ASM --- a/code_part1/OSTC_code_asm_part1/MAIN.ASM Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/MAIN.ASM Wed Jun 08 01:37:14 2011 +0200 @@ -38,7 +38,7 @@ inter_v code 0x0008 bra HighInt ;High Priority Interrups -inter_asm code 0x0018 ;Low Priority Interrups +inter_asm code 0x0018 ;Low Priority Interrups ; *** low priority interrupts not used bra HighInt ;High Priority Interrups diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/aa_font28.inc --- a/code_part1/OSTC_code_asm_part1/aa_font28.inc Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/aa_font28.inc Wed Jun 08 01:37:14 2011 +0200 @@ -1,5 +1,5 @@ ;========================================================================== -; Font data exported dim. févr. 6 2011 by FontIO.cpp 103 2011-02-04 22:26:15Z gascuel $ +; Font data exported mar. juin 7 2011 by FontIO.cpp 103 2011-02-04 22:26:15Z gascuel $ ;========================================================================== aa_font28_height EQU .24 aa_font28_width EQU .14 @@ -710,7 +710,22 @@ DB 0x04, 0x20, 0x91, 0x20, 0x02, 0x20, 0x93, 0x20 DB 0x00, 0x20, 0x95, 0x20, 0xD3 ; “ 93 - DB 0x89, 0x62, 0x94, 0x62, 0x94, 0x62, 0x8E, 0x6E - DB 0x89, 0x6C, 0x8B, 0x6A, 0x8D, 0x68, 0x8F, 0x66 - DB 0x91, 0x64, 0x93, 0x62, 0x95, 0x60, 0xD3 -; TOTAL COMPRESSED SIZE = 4294 + DB 0xB9, 0x01, 0x85, 0x20, 0x8E, 0x01, 0x85, 0x00 + DB 0x20, 0x8D, 0x01, 0x86, 0x00, 0x8D, 0x01, 0x20 + DB 0x85, 0x00, 0x20, 0x8C, 0x0A, 0x20, 0x8B, 0x20 + DB 0x09, 0x20, 0x94, 0x00, 0x20, 0x95, 0x00, 0x95 + DB 0x00, 0x20, 0x95, 0x20, 0xB4 +; ” 94 + DB 0xB3, 0x20, 0x85, 0x01, 0x8D, 0x20, 0x00, 0x85 + DB 0x01, 0x8D, 0x00, 0x86, 0x01, 0x8C, 0x20, 0x00 + DB 0x85, 0x20, 0x01, 0x8B, 0x20, 0x0A, 0x8B, 0x20 + DB 0x09, 0x20, 0x8C, 0x20, 0x00, 0x96, 0x00, 0x96 + DB 0x20, 0x00, 0x96, 0x20, 0xC2 +; • 95 + DB 0xA2, 0x21, 0x94, 0x20, 0x01, 0x20, 0x91, 0x20 + DB 0x05, 0x20, 0x8E, 0x20, 0x01, 0x80, 0x01, 0x80 + DB 0x01, 0x20, 0x91, 0x01, 0x95, 0x01, 0x95, 0x01 + DB 0x95, 0x01, 0x91, 0x20, 0x01, 0x80, 0x01, 0x80 + DB 0x01, 0x20, 0x8E, 0x20, 0x05, 0x20, 0x91, 0x20 + DB 0x01, 0x20, 0x94, 0x21, 0xA2 +; TOTAL COMPRESSED SIZE = 4390 diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/aa_font28_idx.inc --- a/code_part1/OSTC_code_asm_part1/aa_font28_idx.inc Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/aa_font28_idx.inc Wed Jun 08 01:37:14 2011 +0200 @@ -1,9 +1,9 @@ ;========================================================================== -; Font index exported dim. févr. 6 2011 by FontIO.cpp 103 2011-02-04 22:26:15Z gascuel $ +; Font index exported mar. juin 7 2011 by FontIO.cpp 103 2011-02-04 22:26:15Z gascuel $ ;========================================================================== -aa_font28_chars EQU .116 +aa_font28_chars EQU .118 aa_font28_firstChar EQU ' ' -aa_font28_lastChar EQU '“' +aa_font28_lastChar EQU '•' ; aa_font28_idx: DW aa_font28_bits + 0x0000 ; Space @@ -122,4 +122,6 @@ DW aa_font28_bits + 0x103F ; ‘ 91 DW aa_font28_bits + 0x108A ; ’ 92 DW aa_font28_bits + 0x10AF ; “ 93 - DW aa_font28_bits + 0x10C6 ; END OF INDEX + DW aa_font28_bits + 0x10D4 ; ” 94 + DW aa_font28_bits + 0x10F9 ; • 95 + DW aa_font28_bits + 0x1126 ; END OF INDEX diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/changelog.txt --- a/code_part1/OSTC_code_asm_part1/changelog.txt Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/changelog.txt Wed Jun 08 01:37:14 2011 +0200 @@ -1,11 +1,13 @@ New in 1.91 beta: BETA Version - Do NOT use for diving! BUGFIX: Ignore depths>130m in PC simulation +BUGFIX: Avoid spurious CF55 stops with 3 gas or more +BUGFIX: Average depth in Logbook (For dives made with >=1.91) CHANGE: CF02 now allows delay of more then 240seconds NEW: "Quit Sim" in divemode simulator menu for exiting the simulation +NEW: Allow -2:00 to +2:00 adjustement per day (CF48). +NEW: 1/10/100 steps in CF menu NEW: 64kByte Logbook (Doubled capacity compared to 1.90) -BUGFIX: Average depth in Logbook (For dives made with >=1.91) - New in 1.90 Stable: Stable release diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/divemode.asm --- a/code_part1/OSTC_code_asm_part1/divemode.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/divemode.asm Wed Jun 08 01:37:14 2011 +0200 @@ -1803,6 +1803,7 @@ set_first_gas: read_int_eeprom d'33' ; Read byte (stored in EEDATA) movff EEDATA,active_gas ; Read start gas (1-5) + movff EEDATA,char_I_current_gas decf active_gas,W ; Gas 0-4 mullw d'4' diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/divemode_menu.asm --- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm Wed Jun 08 01:37:14 2011 +0200 @@ -570,7 +570,9 @@ bsf event_occured ; set global event flag bsf is_bailout ;=1: CC mode, but bailout active! clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" - movff lo,char_I_const_ppO2 + movff lo,char_I_const_ppO2 + movlw 6 + movff WREG,char_I_current_gas ; Current gas is Gas6 (manual setting). bra timeout_divemenu2 ; quit underwater menu! divemenu_set_gas: @@ -637,6 +639,7 @@ cpfseq menupos ; At the "Gas 6.." position? bra divemenu_set_gas2b ; No, select Gas1-5 (Stored in Menupos) bra divemode_set_xgas ; Configure the extra gas + divemenu_set_gas2b: bsf is_bailout ;=1: CC mode, but bailout active! clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" @@ -667,6 +670,8 @@ movff EEDATA, char_I_N2_ratio ; = N2! bsf stored_gas_changed ; set event flag bsf event_occured ; set global event flag + + movff menupos,char_I_current_gas ; Inform deco code too. bra timeout_divemenu2 ; quit menu! timeout_divemenu: diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/isr.asm --- a/code_part1/OSTC_code_asm_part1/isr.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/isr.asm Wed Jun 08 01:37:14 2011 +0200 @@ -379,10 +379,10 @@ ; Now, do the RTC routine.... RTCisr2: incf secs,F ; adjusts seconds, minutes, hours, day, month and year. Checks for a leap year and works until 2099! - movlw d'59' - cpfsgt secs - return - clrf secs + movlw d'60' + cpfseq secs ; Secs == 60 ? + return ; NO : done. + clrf secs ; YES: increment minutes instead... bsf oneminupdate incf mins,F movlw d'59' diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/math.asm --- a/code_part1/OSTC_code_asm_part1/math.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/math.asm Wed Jun 08 01:37:14 2011 +0200 @@ -54,10 +54,10 @@ subwfb sub_a+1, W movwf sub_c+1 - btfsc STATUS,C - return ; result positve + btfss STATUS,N ; Negativ result ? + return ; NO: result positive done. - bsf neg_flag ; result negative + bsf neg_flag ; MARK result negative comf sub_c+1 ; 16bit sign change. negf sub_c+0 diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/menu_custom.asm --- a/code_part1/OSTC_code_asm_part1/menu_custom.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm Wed Jun 08 01:37:14 2011 +0200 @@ -56,22 +56,30 @@ CF_SEC EQU 6 ; Displays 4:00 CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space) ; -CF_TYPES EQU 0x1F +CF_TYPES EQU 0x0F CF_MAX_BIT EQU 6 ; Default is the highest safe value. CF_MAX EQU (1<"1" menu_custom_functions10b: WIN_LEFT .20 WIN_TOP .125 lfsr FSR2,letter - OUTPUTTEXT d'89' ;"Default:" + OUTPUTTEXT d'89' ; "Default:" - call display_customfunction ; Typed display. + movff cf_default+0,lo + movff cf_default+1,hi + call display_customfunction ; Typed display. WIN_LEFT .20 WIN_TOP .155 lfsr FSR2,letter - OUTPUTTEXT d'97' ; "Current:" + OUTPUTTEXT d'97' ; "Current:" movf cf32_x4,W addlw 0x82 movwf EEADR call read_eeprom ; Lowbyte - movff EEDATA,lo - movff EEDATA, cf_value ; Backup low 8bit value. + movff EEDATA,cf_value+0 movf cf32_x4,W addlw 0x83 movwf EEADR call read_eeprom ; Highbyte - movff EEDATA,hi + movff EEDATA,cf_value+1 call PLED_standard_color ; Changed by color swatches, but trash EEADRH... + movff cf_value+0,lo + movff cf_value+1,hi call display_customfunction ; End of mask: min/max and the exit line... @@ -334,7 +346,7 @@ ; Read default value, type, and constraints ; ; Input: customfunction_page, cf32_x4 -; Output: hi:lo, cf_type, cf_min, cf_max. +; Output: cf_default, cf_type, cf_min, cf_max. ; Trashes: TBLPTR cf_read_default: @@ -354,12 +366,12 @@ addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). tblrd*+ - movff TABLAT,lo ; Low byte --> lo + movff TABLAT,cf_default+0 ; Low byte tblrd*+ - movff TABLAT,hi ; High byte --> hi - btfss hi,7 ; 15bit ? - clrf hi ; NO: clear extra type flags - bcf hi,7 ; clear 15bit flag + movff TABLAT,cf_default+1 ; High byte + btfss cf_default+1,7 ; 15bit ? + clrf cf_default+1 ; NO: clear extra type flags + bcf cf_default+1,7 ; clear 15bit flag movff TABLAT,cf_type ; type (high byte) --> cf_type @@ -408,16 +420,36 @@ btfsc cf_type,7 ; A 15bit value ? bra cf_no_min ; Don't display, hence clear line... - btfss cf_type, CF_MIN_BIT ; A min value exists ? + btfss cf_type,CF_MIN_BIT ; A min value exists ? bra cf_no_min + btfss cf_type,CF_NEG_BIT + bra cf_min_unsigned + + ; Uses 16bit sub for checking signed min value. + movff cf_value,sub_a+0 ; A <- value + clrf sub_a+1 + btfsc cf_value,7 ; extend sign if value < 0 + setf sub_a+1 + + movff cf_min,sub_b+0 ; B <- min (with signed extend) + setf sub_b+1 ; min have to be negativ. + call sub16 ; Compute (A-B) + + btfss neg_flag ; Result < 0 ? + bra cf_min_passed ; NO + bra cf_min_failed ; YES + +cf_min_unsigned: movf cf_min,W ; Retrieve current 8b value - subwf cf_value,W ; Compute (lo-min) - bc cf_min_passed ; Ok if CARRY, ie. min >= lo + subwf cf_value,W ; Compute (value-min) + bc cf_min_passed ; Ok if CARRY, ie. min >= lo + +cf_min_failed: call PLED_warnings_color WIN_INVERT 1 -cf_min_passed: - + +cf_min_passed: STRCAT "> " ; A min value follows movff cf_min, lo rcall display_formated @@ -439,13 +471,33 @@ btfss cf_type, CF_MAX_BIT ; A max value exists ? bra cf_no_max + btfss cf_type,CF_NEG_BIT + bra cf_max_unsigned + + ; Uses 16bit sub for checking signed min value. + movff cf_max,sub_a+0 ; A <- max (with signed extend) + clrf sub_a+1 ; max have to be positiv. + + movff cf_value,sub_b+0 ; B <- value + clrf sub_b+1 + btfsc cf_value,7 ; extend sign if value < 0 + setf sub_b+1 + call sub16 ; Compute (A-B) + + btfss neg_flag ; Result < 0 ? + bra cf_max_passed ; NO + bra cf_max_failed ; YES + +cf_max_unsigned: movf cf_value,W ; Retrieve current max bound subwf cf_max,W ; Compute (max-lo) - bc cf_max_passed ; Ok if no carry, ie. max <= lo + bc cf_max_passed ; Ok if no carry, ie. max <= lo + +cf_max_failed: call PLED_warnings_color WIN_INVERT 1 -cf_max_passed: - + +cf_max_passed: STRCAT "< " ; A max value follows movff cf_max, lo rcall display_formated @@ -468,14 +520,31 @@ ; cf_min, cf_max : the optional min/max. ; FSR2 = current string pointer. display_formated: + movf cf_type,W ; Just set N flags + bn cf_type_80 ; Keep 15bits value in old format. + + ;---- handle signed values ----------------------------------------------- + ; NOTE: only 8bit values can have a negativ flag right now. + btfss cf_type,CF_NEG_BIT ; Signed value ? + bra cf_type_unsigned ; NO: display unsigned as-is + + btfss lo,7 ; Negativ value ? + bra cf_type_pos ; NO: display positives with a + sign. + + PUTC '-' ; YES: display with a - sign. + negf lo ; and correct the said value. + bra cf_type_unsigned + +cf_type_pos: + PUTC '+' ;---- decode type -------------------------------------------------------- - movf cf_type,W ; Just set N/Z flags - bn cf_type_neg ; Keep 15bits value in old format. - andlw CF_TYPES ; Look just at types +cf_type_unsigned: + ; Jump table: ; test the value with cleared flags... + movf cf_type,W + andlw CF_TYPES ; Look just at types bz cf_type_00 ; 8bit standard mode - ; Jump table: ; test the value with cleared flags... dcfsnz WREG bra cf_type_01 dcfsnz WREG @@ -539,8 +608,13 @@ cf_type_07: ; Type == 7 is CF_COLOR swatch. bcf leftbind ; Keep leading space (better alignement) output_8 + + movff win_top,WREG ; Is it the step value ? + xorlw .95 ; Line for "Step:" + btfsc STATUS,Z + retlw -1 ; YES : return + STRCAT_PRINT " " - movf lo,W ; Get color. call PLED_set_color movlw .23 @@ -557,7 +631,7 @@ clrf hi bsf leftbind -cf_type_neg: ; 15bit mode. +cf_type_80: ; 15bit mode. bcf hi,7 output_16 retlw 0 @@ -627,7 +701,30 @@ ;----------------------------------------------------------------------------- toggle_oneorten: - btg second_FA + movlw .10 ; Multiply step by 10, + mulwf cf_step ; Result in PROD low. + + movf PRODH,W ; Check 1000 + bz toggle_oneorten_1 ; HIGH(new step) null == no overflow + movlw .1 ; Cycle to 1. + movwf cf_step + bra toggle_oneorten_3 + +toggle_oneorten_1: ; Special case for mm:ss + movf cf_type,W ; Get type + andlw CF_TYPES ; w/o min/max/neg flags. + xorlw CF_SEC ; Check for mm:ss ? + bnz toggle_oneorten_2 ; no: continue + movlw .100 ; Step = 100 ? + xorwf PRODL,W + bnz toggle_oneorten_2 ; no: continue + movlw .60 ; yes: replace by 1:00 + movff WREG,cf_step + bra toggle_oneorten_3 ; Done. + +toggle_oneorten_2: + movff PRODL,cf_step ; Just keep result. +toggle_oneorten_3: movlw d'3' movwf menupos bra menu_custom_functions1 ; also debounces switches @@ -635,17 +732,17 @@ ;----------------------------------------------------------------------------- restore_cfn_value: - rcall cf_read_default ; hi:lo is trashed by min/max display. - movf cf32_x4,W ; store default value addlw 0x82 movwf EEADR - movff lo,EEDATA + movff cf_default+0,EEDATA + movff cf_default+0,cf_value+0 call write_eeprom ; Lowbyte movf cf32_x4,W addlw 0x83 movwf EEADR - movff hi,EEDATA + movff cf_default+1,EEDATA + movff cf_default+1,cf_value+1 call write_eeprom ; Highbyte movlw d'4' @@ -674,9 +771,7 @@ bra adjust_cfn_value3 ; Store result adjust_cfn_value1: - movlw d'1' - btfsc second_FA ; -10? - movlw d'10' + movf cf_step,W ; 1, 10, 100 ? btfss first_FA ; Minus? bra adjust_cfn_value2 ; No, Plus @@ -774,7 +869,7 @@ ; Check one CF value --------------------------------------------------------- check_one_cf: - rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. + rcall cf_read_default ; Sets cf_value, cf_type, cf_min, cf_max. btfsc cf_type,7 ; A 15bit type ? bra check_cf_check ; Then we have to check it... @@ -821,7 +916,25 @@ btfss cf_type,CF_MIN_BIT bra check_no_min - + + btfss cf_type,CF_NEG_BIT + bra check_min_unsigned + + ; Uses 16bit sub for checking signed min value. + movff lo,sub_a+0 ; A <- value + clrf sub_a+1 + btfsc lo,7 ; extend sign if value < 0 + setf sub_a+1 + + movff cf_min,sub_b+0 ; B <- min (with signed extend) + setf sub_b+1 ; min have to be negativ. + call sub16 ; Compute (A-B) + + btfss neg_flag ; Result < 0 ? + bra check_no_min ; NO + retlw 0 ; YES = FAILED + +check_min_unsigned: cpfsgt cf_min ; Compare to cf_min bra check_no_min ; PASSED: continue. retlw 0 ; NO: return failed. @@ -829,7 +942,25 @@ check_no_min: btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ? retlw -1 ; No check: return OK. - + + btfss cf_type,CF_NEG_BIT + bra check_max_unsigned + + ; Uses 16bit sub for checking signed min value. + movff cf_max,sub_a+0 ; A <- max (with signed extend) + clrf sub_a+1 ; max have to be positiv. + + movff lo,sub_b+0 ; B <- value + clrf sub_b+1 + btfsc lo,7 ; extend sign if value < 0 + setf sub_b+1 + call sub16 ; Compute (A-B) + + btfss neg_flag ; Result < 0 ? + retlw -1 ; NO + retlw 0 ; YES + +check_max_unsigned: movf lo,W ; Compute value-max cpfslt cf_max retlw -1 ; Bound met: return OK. diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/menu_reset.asm --- a/code_part1/OSTC_code_asm_part1/menu_reset.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm Wed Jun 08 01:37:14 2011 +0200 @@ -65,10 +65,16 @@ if HIGH(default) > 0 error CF#v(CFn) "8bit default too big: ", default endif - if HIGH(min) > 0 - error CF#v(CFn) "8bit min too big: ", min - endif - if HIGH(max) > 0 + if type & CF_NEG + if HIGH(-min) != 0 + error CF#v(CFn) "8bit negativ min too big: ", min + endif + else + if HIGH(min) != 0 + error CF#v(CFn) "8bit min too big: ", min + endif + endif + if HIGH(max) != 0 error CF#v(CFn) "8bit max too big: ", max endif if ((type)==CF_BOOL) && ( (default)>1 ) @@ -83,7 +89,7 @@ else local typeFlags typeFlags set type - if (min)>0 + if (min)!=0 typeFlags set type + CF_MIN endif if (max)>(min) @@ -163,7 +169,7 @@ CF_DEFAULT CF_CENTI, d'161', d'100', d'161' ; color_warn_ppo2_cbar ppO2 warn CF_DEFAULT CF_INT8, d'15', d'7', d'20' ; color_warn_celocity_mmin warn at xx m/min - CF_DEFAULT CF_SEC, d'42', d'0', d'240' ; time_correction_value_default Adds to Seconds on Midnight + CF_DEFAULT CF_SEC+CF_NEG,d'42', -d'120',d'120' ; time_correction_value_default Adds to Seconds on Midnight CF_DEFAULT CF_BOOL, d'0', 0, 0 ; CF#49 Show Altimeter in surface mode CF_DEFAULT CF_BOOL, d'0', 0, 0 ; CF50 Show Log-Marker CF_DEFAULT CF_BOOL, d'1', 0, 0 ; CF51 Show Stopwatch diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/sleepmode.asm --- a/code_part1/OSTC_code_asm_part1/sleepmode.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/sleepmode.asm Wed Jun 08 01:37:14 2011 +0200 @@ -64,11 +64,13 @@ call calc_surface_interval ; Increases Surface-Interval time call nofly_timeout60 ; check for no fly time - ; adjust airpressure compensation any 15 minutes + + ;---- adjust airpressure compensation any 15 minutes incf divemins+1,F ; counts to 14... movlw d'14' cpfsgt divemins+1 bra onemin_sleep2 ; 15 minutes not done! + clrf divemins+1 ; reset counter rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!) @@ -78,27 +80,26 @@ call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only movlb b'00000001' + movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure - clrf divemins+1 ; reset counter GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi movff lo,sub_a+0 ; max. "allowed" airpressure in mBar movff hi,sub_a+1 movff last_surfpressure_15min+0,sub_b+0 movff last_surfpressure_15min+1,sub_b+1 call sub16 ; sub_c = sub_a - sub_b - btfsc neg_flag - bra onemin_sleep1 - bra onemin_sleep2 ; current airpressure is lower then "allowed" airpressure, ok! -onemin_sleep1: ; not ok! Overwrite with max. "allowed" airpressure + btfss neg_flag ; Is 1080mbar < amb_pressure ? + bra onemin_sleep2 ; NO: current airpressure is lower then "allowed" airpressure, ok! + + ; not ok! Overwrite with max. "allowed" airpressure GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar onemin_sleep2: -;calc_deko_sleepmode: SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine GETCUSTOM8 d'11' ; Saturation multiplier % movff WREG,char_I_saturation_multiplier @@ -128,18 +129,20 @@ movlw d'5' cpfsgt divemins+0 ; here: temp variable bra onesec_sleep1 ; #test_pressure_in_sleep not done yet + clrf divemins+0 + rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!) - ; compare current ambient pressure with threshold + ; compare current ambient pressure with threshold CF6==1160mbar. GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi movff lo,sub_a+0 ; power on if ambient pressure is greater threshold movff hi,sub_a+1 - SAFE_2BYTE_COPY amb_pressure_avg, sub_b - call sub16 ; sub_c = sub_a - sub_b + SAFE_2BYTE_COPY amb_pressure_avg, sub_b + call sub16 ; Is (1160mbar - averaged(amb_pressure)) < 0 ? bsf sleepmode btfsc neg_flag ; Wake up from Sleep? bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up! - clrf divemins+0 + onesec_sleep1: bcf onesecupdate ; all done. btfsc switch_left @@ -159,7 +162,7 @@ bcf switch_right bcf switch_left bcf T0CON,TMR0ON ; Stop Timer 0 - bcf sleepmode ; wake up! + bcf sleepmode ; wake up! ; Restart altimeter averaging, so next averaging starts right over... call altimeter_restart diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/start.asm --- a/code_part1/OSTC_code_asm_part1/start.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/start.asm Wed Jun 08 01:37:14 2011 +0200 @@ -39,7 +39,7 @@ call PLED_resetdebugger ; Yes! Something went wrong, show reset informations start3: clrf STKPTR ; Clear Stackpointer - lfsr FSR0, 10Bh ; Clear rambank 1-9, do not delete RTC registers + lfsr FSR0,year+1 ; Clear rambank 1-9, do not delete RTC registers clear_rambank: clrf POSTINC0 movlw 0x0A diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_asm_part1/surfmode.asm --- a/code_part1/OSTC_code_asm_part1/surfmode.asm Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/surfmode.asm Wed Jun 08 01:37:14 2011 +0200 @@ -273,16 +273,17 @@ btg LED_blue return +;============================================================================= + calc_deko_surfmode: ostc_debug 'I' ; Sends debug-information to screen if debugmode active movff last_surfpressure+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine movff last_surfpressure+1,int_I_pres_surface+1 - clrf wait_temp ; Use as buffer - movff wait_temp,char_I_He_ratio ; No He at the Surface - movlw d'79' ; 79% N2 - movwf wait_temp ; Use as buffer - movff wait_temp,char_I_N2_ratio ; No He at the Surface + clrf WREG ; Use as buffer + movff WREG,char_I_He_ratio ; No He at the Surface + movlw d'79' ; 79% N2 + movff WREG,char_I_N2_ratio ; Air at the Surface SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine GETCUSTOM8 d'11' ; Saturation multiplier % @@ -299,6 +300,7 @@ return +;============================================================================= test_charger: bcf TRISC,1 ; CHRG_OUT output diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_c_part2/p2_deco.c --- a/code_part1/OSTC_code_c_part2/p2_deco.c Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/p2_deco.c Wed Jun 08 01:37:14 2011 +0200 @@ -972,63 +972,21 @@ ////////////////////////////////////////////////////////////////////////////// // Find current gas in the list (if any). // -// Input: char_I_deco_N2_ratio[] and He, to detect breathed gas. +// Input: char_I_current_gas. // -// Output: sim_gas_depth_used +// Output: sim_gas_last_depth, temp_depth_limit. // static void gas_switch_find_current(void) { - overlay unsigned char j; - overlay unsigned char N2 = (unsigned char)(N2_ratio * 100 + 0.5); - overlay unsigned char He = (unsigned char)(He_ratio * 100 + 0.5); - - for(j=0; j depth ) - { - for(j=0; j= (char_I_deco_gas_change[j] - 3) - ) - { - // Then start gas-switch timer there, - sim_gas_delay = sim_dive_mins - + read_custom_function(55); - - // And make sure decostop will be recorded at the right depth. - temp_depth_limit = char_I_deco_gas_change[j]; - break; - } - } - } - else - // Make clear there is no deay anymore. - sim_gas_delay = 0; + if( (char_I_current_gas <= NUM_GAS) // Gas6 == manual set. + && char_I_deco_gas_change[char_I_current_gas-1] + ) + { + sim_gas_last_used = char_I_current_gas-1; + sim_gas_last_depth = char_I_deco_gas_change[sim_gas_last_used]; + // temp_depth_limit = ??? } } @@ -1063,7 +1021,7 @@ if( temp_depth_limit > deco_gas_change[j] ) continue; - // Gas deeper than the current/previous one ? Skip ! + // Gas deeper (or equal) than the current one ? Skip ! if( sim_gas_last_depth && deco_gas_change[j] >= sim_gas_last_depth ) continue; diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_c_part2/p2_deco.o Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed diff -r 562f1bc79f3c -r 88660a400338 code_part1/OSTC_code_c_part2/shared_definitions.h --- a/code_part1/OSTC_code_c_part2/shared_definitions.h Tue Jun 07 13:06:14 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/shared_definitions.h Wed Jun 08 01:37:14 2011 +0200 @@ -142,7 +142,8 @@ VAR_UINT (int_I_divemins); // Dive time (minutes) VAR_UCHAR (char_I_temp); // new in v101 VAR_UCHAR (char_I_actual_ppO2); // -VAR_UCHAR (char_I_first_gas); // Gas used at start of dive. +VAR_UCHAR (char_I_first_gas); // Gas used at start of dive (bottom mix) +VAR_UCHAR (char_I_current_gas); // Current gas breathed (1..6). VAR_UCHAR (char_I_N2_ratio); // VAR_UCHAR (char_I_He_ratio); // VAR_UCHAR (char_I_saturation_multiplier); // for conservatism/safety values 1.0 no conservatism to 1.5 50% faster saturation