# HG changeset patch # User heinrichsweikamp # Date 1291923716 -3600 # Node ID b40a0a6284daa2ee6a7891087d9c407d3c385cd0 # Parent 8b813f67220f1ba763d59b0483aba3e3039a1c83 adding custom functions with limits (jeando) diff -r 8b813f67220f -r b40a0a6284da code_part1/OSTC_code_asm_part1/menu_custom.asm --- a/code_part1/OSTC_code_asm_part1/menu_custom.asm Wed Dec 08 08:37:03 2010 +0100 +++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm Thu Dec 09 20:41:56 2010 +0100 @@ -48,15 +48,30 @@ ; define the display format: CF_INT8 EQU 0 ; Default display, 8 or 15 bits values. -CF_PERCENT EQU 1 ; Displays 110% -CF_DECI EQU 2 ; Displays 1.6 -CF_CENTI EQU 3 ; Displays 1.50 -CF_MILI EQU 4 ; Displays 1.015 -CF_BOOL EQU 5 ; Displays ON/OFF -CF_SEC EQU 6 ; Displays 4:00 -CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space) +CF_PERCENT EQU 1 ; Displays 110% +CF_DECI EQU 2 ; Displays 1.6 +CF_CENTI EQU 3 ; Displays 1.50 +CF_MILI EQU 4 ; Displays 1.015 +CF_BOOL EQU 5 ; Displays ON/OFF +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_MAX_BIT EQU 6 ; Default is the highest safe value. +CF_MAX EQU (1< lo + 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_type ; type (high byte) --> cf_type + movlw CF_MILI + btfsc cf_type,7 ; Display all 15bits as 1.234 floats. + movwf cf_type + + tblrd*+ + movff TABLAT,cf_min ; Then get optional min/max + tblrd*+ + movff TABLAT,cf_max + + return + +;----------------------------------------------------------------------------- +; Display a 8/15bit value, plus optional min and max bound. +; Input : hi:lo = data to display. +; cf_type = the type. +; cf_min, cf_max : the optional min/max. ; FSR2 = current string pointer. -; Trash : FSR1 (used to backup EEADRH and hi) +; Trash : hi:lo (when displaying min/max) display_customfunction: -#ifndef NO_CF_TYPES + movff EEADRH, FSR1H ; Backup... + + rcall display_formated + rcall cf_fill_line + call word_processor + + movff FSR1H, EEADRH + return + +;----------------------------------------------------------------------------- +; Display optional min/max values. +; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max). +; Trashed: hi:lo while display min and max values. +display_minmax: movff EEADRH, FSR1H ; Backup... - movff hi, FSR1L + +; Display min line + WIN_TOP .65 + WIN_LEFT .100 + lfsr FSR2, letter + + btfss cf_type, CF_MIN_BIT ; A min value exists ? + bra cf_no_min + + 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 + call PLED_warnings_color + WIN_INVERT 1 +cf_min_passed: + + movlw '>' ; A min value follows + movwf POSTINC2 + movlw ' ' + movwf POSTINC2 + movff cf_min, lo + rcall display_formated + +cf_no_min: + rcall cf_fill_line ; Fill buffer + lfsr FSR2, letter+.7 ; Limit to 8 chars btw. + call word_processor + +; Display max line + WIN_TOP .95 + call PLED_standard_color + WIN_INVERT 0 + lfsr FSR2, letter + + btfss cf_type, CF_MAX_BIT ; A max value exists ? + bra cf_no_max + + 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 + call PLED_warnings_color + WIN_INVERT 1 +cf_max_passed: + + movlw '<' ; A max value follows + movwf POSTINC2 + movlw ' ' + movwf POSTINC2 + movff cf_max, lo + rcall display_formated + +cf_no_max: + rcall cf_fill_line ; Fill buffer + lfsr FSR2, letter+.7 ; Limit to 8 chars btw. + call word_processor + +cf_minmax_done: + call PLED_standard_color + WIN_INVERT 0 + movff FSR1H, EEADRH + return + +;----------------------------------------------------------------------------- +; Display a single 8/15 bit value, according to cf_type. +; Input : hi:lo = data to display. +; cf_type = the type. +; cf_min, cf_max : the optional min/max. +; FSR2 = current string pointer. +display_formated: ;---- decode type -------------------------------------------------------- - movf hi,W ; Just set N/Z flags - bn cf_type_0 ; Keep 15bits value in old format. - bz cf_type_99 ; 8bit standard mode + 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 + bz cf_type_00 ; 8bit standard mode - ; Jump table: - dcfsnz hi + ; Jump table: ; test the value with cleared flags... + dcfsnz WREG bra cf_type_01 - dcfsnz hi + dcfsnz WREG bra cf_type_02 - dcfsnz hi + dcfsnz WREG bra cf_type_03 - dcfsnz hi + dcfsnz WREG bra cf_type_04 - dcfsnz hi + dcfsnz WREG bra cf_type_05 - dcfsnz hi + dcfsnz WREG bra cf_type_06 - dcfsnz hi + dcfsnz WREG bra cf_type_07 - bra cf_type_99 ; Default to 8bit mode... + bra cf_type_00 ; Default to 8bit mode... -cf_type_01: ; Type == 1 is percent mode - output_16dp 0 ; NOTE : hi is already reseted... +cf_type_01: ; Type == 1 is CF_PERCENT mode + bcf leftbind + output_8 movlw '%' movwf POSTINC2 - bra cf_do_wp + retlw 0 -cf_type_02: ; Type == 2 is deci mode. +cf_type_02: ; Type == 2 is CF_DECI mode. + clrf hi + bsf leftbind output_16dp 4 - bra cf_do_wp + retlw 0 -cf_type_03: ; Type == 3 is centi mode. +cf_type_03: ; Type == 3 is CF_CENTI mode. + clrf hi + bsf leftbind output_16dp 3 - bra cf_do_wp + retlw 0 -cf_type_04: ; Type == 4 is mili mode +cf_type_04: ; Type == 4 is CF_MILI mode output_16dp 2 - bra cf_do_wp + retlw 0 -cf_type_05: ; Type == 5 is on/off mode. +cf_type_05: ; Type == 5 is CF_BOOL mode. movf lo,W ; Get flag value... bz cf_type_off OUTPUTTEXT d'130' ; ON - bra cf_do_wp + retlw 0 + cf_type_off: OUTPUTTEXT d'131' ; OFF - bra cf_do_wp + retlw 0 -cf_type_06: ; Type == 6 is mm:ss mode (... or hh:mm) +cf_type_06: ; Type == 6 is CF_SECS mode (mm:ss or hh:mm) + clrf hi call convert_time ; Convert to min:sec into hi:low. movff lo,wp_temp ; Save seconds, movff hi,lo ; Get minutes + bsf leftbind ; Skip leading space(s). output_8 ; Print them movlw ':' ; Separator movwf POSTINC2 movff wp_temp,lo ; Get back seconds output_99x ; lo in 2 digits with trailing zeros. - bra cf_do_wp + retlw 0 -cf_type_07: ; Type == 7 is Color swatch. +cf_type_07: ; Type == 7 is CF_COLOR swatch. + bcf leftbind ; Keep leading space (better alignement) output_8 - - call cf_fill_line ; it does less flickering when editing colors... + movlw ' ' + movwf POSTINC2 call word_processor movf lo,W ; Get color. @@ -476,68 +575,31 @@ movff WREG,box_temp+2 ; row bottom (0-239) movlw .110 movff WREG,box_temp+3 ; column left (0-159) - movlw .140 + movlw .148 movff WREG,box_temp+4 ; column right (0-159) call PLED_box - bra cf_done ; wp already done. Skip it... + retlw -1 ; wp already done. Skip it... -cf_type_99: ; 8bit mode. Or unrecognized type... +cf_type_00: ; 8bit mode. Or unrecognized type... clrf hi + bsf leftbind -cf_type_0: ; 15bit mode. +cf_type_neg: ; 15bit mode. bcf hi,7 output_16 - -cf_do_wp: ; Process by calling wordprocessor - call cf_fill_line - call word_processor + retlw 0 -cf_done: - movff FSR1L, hi ; And restore saved registers before return. - movff FSR1H, EEADRH - return +;----------------------------------------------------------------------------- cf_fill_line: ; Mattias: No flicker if u clear just what you need... movf FSR2L,W ; How many chars lefts ? - sublw (LOW letter) + .17 ; Remaining chars to fill: (letter + 21) - PTR + sublw (LOW letter) + .18 ; Remaining chars to fill: (letter + 18) - PTR btfsc STATUS,N ; Add chars until none left... return movlw ' ' movwf POSTINC2 bra cf_fill_line - -#else - bcf hi,7 ; clear Bit 7 of value - output_16 - - movff win_top,WREG ; Get "Default:" line position (BANK0 !) - xorlw .125 ; This is the default value ? - bnz cf_no_bits ; NO: skip bits for current value - - movlw ',' - movwf POSTINC2 - - movlw '1' - btfss EEDATA,7 ; 15Bit? - movlw '8' ; 8Bit! - tstfsz apnoe_mins ; apnoe_mins=0? - movlw '1' ; No, 1Bit! - movwf POSTINC2 - - movlw '5' - btfsc EEDATA,7 ; 15Bit? - movwf POSTINC2 - movlw 'B' - movwf POSTINC2 - -cf_no_bits: - movlw ' ' - movwf POSTINC2 - movwf POSTINC2 - movwf POSTINC2 - goto word_processor -#endif ;----------------------------------------------------------------------------- @@ -558,6 +620,8 @@ dcfsnz menupos,F bra adjust_cfn_value +;----------------------------------------------------------------------------- + exit_customfunctions: movlw d'2' ; Return to correct list entry btfss customfunction_page @@ -566,6 +630,8 @@ clrf EEADRH ; Clear EEADRH ! goto setup_menu2 ; exit... +;----------------------------------------------------------------------------- + next_customfunction: incf decodata+0 btfsc decodata+0,5 ;>31? @@ -573,11 +639,13 @@ movf decodata+0,W mullw d'4' - movff PRODL, divemins+0 ;divemins+0 for correct addressing + movff PRODL, cf32_x4 ; 12bit address for correct addressing movlw d'1' movwf menupos - bra menu_custom_functions1 ; also debounces switches + bra menu_custom_functions1 ; also debounces switches + +;----------------------------------------------------------------------------- toggle_plusminus: btg first_FA @@ -585,31 +653,25 @@ movwf menupos bra menu_custom_functions1 ; also debounces switches +;----------------------------------------------------------------------------- + toggle_oneorten: btg second_FA movlw d'3' movwf menupos bra menu_custom_functions1 ; also debounces switches +;----------------------------------------------------------------------------- + restore_cfn_value: - movf divemins+0,W ; read default value - addlw 0x80 - movwf EEADR - call read_eeprom ; Lowbyte - movff EEDATA,lo - movf divemins+0,W - addlw 0x81 - movwf EEADR - call read_eeprom ; Highbyte - movff EEDATA,hi - bcf hi,7 ; clear bit 7 of value + rcall cf_read_default ; hi:lo is trashed by min/max display. - movf divemins+0,W ; store default value + movf cf32_x4,W ; store default value addlw 0x82 movwf EEADR movff lo,EEDATA call write_eeprom ; Lowbyte - movf divemins+0,W + movf cf32_x4,W addlw 0x83 movwf EEADR movff hi,EEDATA @@ -619,253 +681,66 @@ movwf menupos bra menu_custom_functions1 ; also debounces switches +;----------------------------------------------------------------------------- +; Adjust current value. adjust_cfn_value: - movf divemins+0,W ; get current value + movf cf32_x4,W ; get current value addlw 0x82 movwf EEADR call read_eeprom ; Lowbyte movff EEDATA,lo - movf divemins+0,W + movf cf32_x4,W addlw 0x83 movwf EEADR call read_eeprom ; Highbyte movff EEDATA,hi - movf divemins+0,W - addlw 0x81 - movwf EEADR - call read_eeprom ; Highbyte - movff EEDATA,divemins+1 ; Highbyte of default value + movf cf_type,W + xorlw CF_BOOL + bnz adjust_cfn_value1 - btfss apnoe_mins,0 ; If apnoe_mins=1 then CF is binary - bra adjust_cfn_value1 ; Not Binary - - tstfsz lo ; =0? - setf lo ; No, Set to 255 - incf lo,F ; Increase by one - clrf hi ; Delete hi byte (Not required but to make sure...) - bra adjust_cfn_value3 ; Store result + btg lo,0 ; Change lower bit. + bra adjust_cfn_value3 ; Store result adjust_cfn_value1: - btfss first_FA ; Minus? - bra adjust_cfn_value2 ; No, Plus - movlw d'1' - btfsc second_FA ; -10? + btfsc second_FA ; -10? movlw d'10' - subwf lo,F ; substract value + btfss first_FA ; Minus? + bra adjust_cfn_value2 ; No, Plus + + subwf lo,F ; substract value movlw d'0' - btfsc divemins+1,7 ; 8Bit value + btfsc cf_type,7 ; 8Bit value subwfb hi,F movlw b'01111111' - btfsc hi,7 ; >32768? + btfsc hi,7 ; >32768? movwf hi bra adjust_cfn_value3 adjust_cfn_value2: - movlw d'1' - btfsc second_FA ; +10? - movlw d'10' - - addwf lo,F ; add value + addwf lo,F ; add value movlw d'0' - btfsc divemins+1,7 ; 8Bit value? + btfsc cf_type,7 ; 8Bit value? addwfc hi,F - btfsc hi,7 ; >32768? + btfsc hi,7 ; >32768? clrf hi adjust_cfn_value3: - movf divemins+0,W ; Store current value + movf cf32_x4,W ; Store current value addlw 0x82 movwf EEADR movff lo,EEDATA - call write_eeprom ; Lowbyte - movf divemins+0,W + call write_eeprom ; Lowbyte + movf cf32_x4,W addlw 0x83 movwf EEADR movff hi,EEDATA - call write_eeprom ; Highbyte + call write_eeprom ; Highbyte movlw d'5' movwf menupos - bra menu_custom_functions1 ; also debounces switches - -getcustom15_default: - ; # number of requested custom function in wreg - movwf customfunction_temp2 - - movlw d'31' - cpfsgt customfunction_temp2 - bra getcustom15_d2 ; Lower bank - - movlw d'1' ; Upper Bank - movwf EEADRH - movlw d'32' - subwf customfunction_temp2,F - bra getcustom15_d3 -getcustom15_d2: - clrf EEADRH -getcustom15_d3: - movf customfunction_temp2,W - mullw d'4' - movf PRODL,W ; x4 for adress - addlw d'128' - movwf EEADR ; +130 for LOW Byte of value - call read_eeprom ; Lowbyte - movff EEDATA,lo - incf EEADR,F - call read_eeprom ; Highbyte - movff EEDATA,hi - clrf EEADRH -#ifndef NO_CF_TYPES - btfss hi,7 ; Is it a 15bit value ? - clrf hi ; NO: clear type flags. -#endif - bcf hi,7 ; Always clear 15bit flag. - return ; return - -custom_functions_check_divemode: ;displays warning if a critical custom function is not set to default - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf11 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf12 - return - -custom_functions_check_surfmode: ;displays warning if a critical custom function is not set to default - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf11 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf12 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf17 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf18 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf19 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf29 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf32 - dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol - bra check_cf33 - return - -check_cf11: - movlw d'11' ; saturation factor - rcall custom_function_check_low ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'2' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf12: - movlw d'12' ; desaturation factor - rcall custom_function_check_high ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'3' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf17: - movlw d'17' ; lower threshold ppO2 - rcall custom_function_check_low ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'4' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf18: - movlw d'18' ; upper threshold ppO2 - rcall custom_function_check_high ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'5' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf19: - movlw d'19' ; upper threshold ppO2 display - rcall custom_function_check_high ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'6' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf29: - movlw d'6' - movwf cf_checker_counter ; upper limit for CF29, here: used as a temp variable - movlw d'29' ; last deco stop in [m] - rcall custom_function_check_high_limit ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'7' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf32: - movlw d'32' ; GF LOW - rcall custom_function_check_high ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'8' ; next in testing row - movwf cf_checker_counter ; - return - -check_cf33: - movlw d'33' ; GF HIGH - rcall custom_function_check_high ; compares current with default value - call test_and_display_warning ; displays the warning if the custom function is not correct - movlw d'1' ; next in testing row - movwf cf_checker_counter ; - return - - -test_and_display_warning: - movwf lo ; copy result - tstfsz lo - return ; CF OK - goto custom_warn_surfmode - -custom_function_check_low: ; Checks CF (#WREG) - ; Returns WREG=0 if CF is lower then default - movwf temp1 ; save for custom value - call getcustom15_1 ; Get Current Value stored in hi and lo - movff lo,sub_a+0 - movff hi,sub_a+1 ; save value - - movf temp1,w - call getcustom15_default ; Get Default value stored in hi and lo - movff lo,sub_b+0 - movff hi,sub_b+1 ; save value - call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a - btfss neg_flag ; negative? - retlw .255 ; no - retlw .0 ; yes - -custom_function_check_high: ; Checks CF (#WREG) - ; Returns WREG=0 if CF is higher then default - movwf temp1 ; save for custom value - call getcustom15_1 ; Get Current Value stored in hi and lo - movff lo,sub_b+0 - movff hi,sub_b+1 ; save value - - movf temp1,w - call getcustom15_default ; Get Default value stored in hi and lo - movff lo,sub_a+0 - movff hi,sub_a+1 ; save value - call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a - btfss neg_flag ; negative? - retlw .255 ; no - retlw .0 ; yes - -custom_function_check_high_limit: ; Checks if CF (#WREG) is lower then limit (#cf_checker_counter) - movwf temp1 ; save for custom value - call getcustom15_1 ; Get Current Value stored in hi and lo - movff lo,sub_b+0 - movff hi,sub_b+1 ; save value - movff cf_checker_counter, sub_a+0 - clrf sub_a+1 - call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a - btfss neg_flag ; negative? - retlw .255 ; no - retlw .0 ; yes \ No newline at end of file + bra menu_custom_functions1 ; also debounces switches diff -r 8b813f67220f -r b40a0a6284da code_part1/OSTC_code_asm_part1/menu_reset.asm --- a/code_part1/OSTC_code_asm_part1/menu_reset.asm Wed Dec 08 08:37:03 2010 +0100 +++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm Thu Dec 09 20:41:56 2010 +0100 @@ -19,7 +19,7 @@ ; Menu "Reset all" ; written by: Matthias Heinrichs, info@heinrichsweikamp.com ; written: 10/30/05 -; last updated: 08/08/31 +; last updated: 10/12/08 by JD Gascuel at free.fr ; known bugs: ; ToDo: @@ -33,110 +33,151 @@ ; Macro to check values, and construct PROM CF default table. ; If in types mode, set flags into hi. If not, clear it. -CF_DEFAULT macro type, value - if ( type == CF_INT15 ) - if (HIGH value) > .127 - error "15bit default too big:", value - endif - DB LOW value, 0x80 + (HIGH value) - else - ; Basic sanity check for 8bit values: - if ( HIGH value ) > 0 - error "8bit default too big:", value - endif - if (type==CF_BOOL) && (value > 1) - error "BOOL default too big:", value - endif - ifdef NO_CF_TYPES - DB LOW value, HIGH value - else - DB LOW value, type - endif - endif - endm +CF_DEFAULT macro type, default, min, max + noexpand + if (type) == CF_INT15 + if (HIGH (default)) > .127 + error "CF# 15bit default too big:", value + endif + if (min)>0 && (max>min) + error "CF# 15bit defaults cannot have both MIN & MAX flags" + endif + + ifdef NO_CF_TYPES + DB LOW (default), HIGH(default) + 0x80 + else + DB LOW (default), HIGH(default) + 0x80 + if (min) > 0 + DB LOW(min), HIGH(min) + else + DB LOW(min), HIGH(min) + 0x80 + endif + endif + else + ; Basic sanity check for 8bit values: + if HIGH(default) > 0 + error "CF# 8bit default too big:", (default) + endif + if HIGH(min) > 0 + error "CF# 8bit min too big:", (min) + endif + if HIGH(max) > 0 + error "CF# 8bit max too big:", (max) + endif + if ((type)==CF_BOOL) && ( (default)>1 ) + error "CF# BOOL default too big:", (default) + endif + if ((type)==CF_BOOL) && ( (min)>0 || (max)>0 ) + error "CF# BOOL cannot have min/max" + endif + + ifdef NO_CF_TYPES + DB LOW(default), 0 + else + local typeFlags +typeFlags set type + if (min)>0 +typeFlags set type + CF_MIN + endif + if (max)>(min) +typeFlags set typeFlags + CF_MAX + endif + DB LOW(default), (typeFlags), LOW(min), LOW(max) + endif + endif + expand + endm + +; Starting at CF0 +CF_NUMBER set -1 ; resets all customfunctions to the following default values -cf_default_table: +cf_default_table0: ;---- BANK0 custom function defaults ------------------------------------- - CF_DEFAULT CF_CENTI, d'100' ; dive_threshold 100cm - CF_DEFAULT CF_CENTI, d'30' ; surf_threshold 30cm - CF_DEFAULT CF_SEC, d'240' ; diveloop_timeout 240s - CF_DEFAULT CF_SEC, d'120' ; surfloop_timeout 120s - CF_DEFAULT CF_SEC, d'5' ; premenu_timeout 5s + ; DEFAULT MIN MAX + CF_DEFAULT CF_CENTI, d'100', d'50', d'250' ; dive_threshold 100cm + CF_DEFAULT CF_CENTI, d'30', d'10', d'100' ; surf_threshold 30cm + CF_DEFAULT CF_SEC, d'240', d'30', d'240' ; diveloop_timeout 240s + CF_DEFAULT CF_SEC, d'120', d'30', d'240' ; surfloop_timeout 120s + CF_DEFAULT CF_SEC, d'5', d'1', d'30' ; premenu_timeout 5s - CF_DEFAULT CF_INT8, d'7' ; minimum_velocity 7min/min - CF_DEFAULT CF_INT15, d'1160' ; pressure_offset_divemode 1160mBar - CF_DEFAULT CF_INT15, d'1100' ; max_surfpressure 1100mBar - CF_DEFAULT CF_PERCENT, d'20' ; min_gradient_factor 20% - CF_DEFAULT CF_PERCENT, d'20' ; oxygen_threshold 20% + CF_DEFAULT CF_INT8, d'7', d'3', d'18' ; minimum_velocity 7min/min + CF_DEFAULT CF_INT15, d'1160',d'950', 0 ; pressure_offset_divemode 1160mBar + CF_DEFAULT CF_INT15, d'1100',d'1100', 0 ; max_surfpressure 1100mBar + CF_DEFAULT CF_PERCENT, d'20', d'1', d'99' ; min_gradient_factor 20% + CF_DEFAULT CF_PERCENT, d'20', d'1', d'20' ; oxygen_threshold 20% - CF_DEFAULT CF_SEC, d'30' ; dive_menu_timeout 30s - CF_DEFAULT CF_PERCENT, d'110' ; saturation_multiplier x1.10 - CF_DEFAULT CF_PERCENT, d'90' ; desaturation_multiplier x0.90 - CF_DEFAULT CF_PERCENT, d'60' ; nofly_time_ratio 60% - CF_DEFAULT CF_PERCENT, d'100' ; gradient_factor_alarm1 100% + CF_DEFAULT CF_SEC, d'30', d'5', d'30' ; dive_menu_timeout 30s + CF_DEFAULT CF_PERCENT, d'110', d'110', d'200' ; saturation_multiplier x1.10 + CF_DEFAULT CF_PERCENT, d'90', d'50', d'90' ; desaturation_multiplier x0.90 + CF_DEFAULT CF_PERCENT, d'60', d'60', d'100' ; nofly_time_ratio 60% + CF_DEFAULT CF_PERCENT, d'100', d'50', d'100' ; gradient_factor_alarm1 100% - CF_DEFAULT CF_PERCENT, d'10' ; cns_display_surface 10% - CF_DEFAULT CF_INT8, d'10' ; deco_distance_for_sim 1m - CF_DEFAULT CF_CENTI, d'019' ; ppo2_warning_low 0.19 Bar - CF_DEFAULT CF_CENTI, d'160' ; ppo2_warning_high 1.60 Bar - CF_DEFAULT CF_CENTI, d'150' ; ppo2_display_high 1.50 Bar + CF_DEFAULT CF_PERCENT, d'10', d'01', d'100' ; cns_display_surface 10% + CF_DEFAULT CF_DECI, d'10', d'10', d'100' ; deco_distance_for_sim 1m + CF_DEFAULT CF_CENTI, d'019', d'019', d'021' ; ppo2_warning_low 0.19 Bar + CF_DEFAULT CF_CENTI, d'160', d'100', d'160' ; ppo2_warning_high 1.60 Bar + CF_DEFAULT CF_CENTI, d'150', d'100', d'150' ; ppo2_display_high 1.50 Bar - CF_DEFAULT CF_INT8, d'10' ; sampling_rate 10s - CF_DEFAULT CF_INT8, d'6' ; sampling_divisor_temp /6 - CF_DEFAULT CF_INT8, d'6' ; sampling_divisor_deco /6 - CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_tank never - CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_ppo2 never + CF_DEFAULT CF_INT8, d'10', d'1', d'120' ; sampling_rate 10s + CF_DEFAULT CF_INT8, d'6', d'0', d'15' ; sampling_divisor_temp /6 + CF_DEFAULT CF_INT8, d'6', d'0', d'15' ; sampling_divisor_deco /6 + CF_DEFAULT CF_INT8, d'0', d'0', d'15' ; sampling_divisor_tank never + CF_DEFAULT CF_INT8, d'0', d'0', d'15' ; sampling_divisor_ppo2 never - CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_deco2 never - CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_nyu2 never - CF_DEFAULT CF_PERCENT, d'20' ; cns_display_high 20% - CF_DEFAULT CF_INT8, d'0' ; logbook_offset No Offset, but 15Bit value - CF_DEFAULT CF_INT8, d'3' ; last_deco_depth 3m + CF_DEFAULT CF_INT8, d'0', d'0', d'15' ; sampling_divisor_deco2 never + CF_DEFAULT CF_INT8, d'0', d'0', d'15' ; sampling_divisor_nyu2 never + CF_DEFAULT CF_PERCENT, d'20', d'5', d'75' ; cns_display_high 20% + CF_DEFAULT CF_INT15, d'0', d'0', 0 ; logbook_offset No Offset, but 15Bit value + CF_DEFAULT CF_INT8, d'3', d'2', d'6' ; last_deco_depth 3m - CF_DEFAULT CF_SEC, d'10' ; timeout_apnoe_mode 10min - CF_DEFAULT CF_BOOL, d'0' ; show_voltage_value =1 Show value instead of symbol, =0 Show Symbol + CF_DEFAULT CF_SEC, d'10', d'1', d'15' ; timeout_apnoe_mode 10min + CF_DEFAULT CF_BOOL, d'0', 0, 0 ; show_voltage_value =1 Show value instead of symbol, =0 Show Symbol ;---- BANK1 custom function defaults ------------------------------------- - CF_DEFAULT CF_PERCENT, d'30' ; GF_low_default 30% - CF_DEFAULT CF_PERCENT, d'90' ; GF_high_default 90% - CF_DEFAULT CF_COLOR, d'199' ; color_battery_surface Color Battery sign: Deep blue - CF_DEFAULT CF_COLOR, d'255' ; color_standard1 Color Standard: White - CF_DEFAULT CF_COLOR, d'62' ; color_divemask Color Divemask: Light green - CF_DEFAULT CF_COLOR, d'224' ; color_warnings Color Warnings: Red +cf_default_table1: + ; DEFAULT MIN MAX + CF_DEFAULT CF_PERCENT, d'30', d'10', d'90' ; GF_low_default 30% + CF_DEFAULT CF_PERCENT, d'90', d'30', d'95' ; GF_high_default 90% + CF_DEFAULT CF_COLOR, d'199', 0, 0 ; color_battery_surface Color Battery sign: Deep blue + CF_DEFAULT CF_COLOR, d'255', 0, 0 ; color_standard1 Color Standard: White + CF_DEFAULT CF_COLOR, d'62', 0, 0 ; color_divemask Color Divemask: Light green + CF_DEFAULT CF_COLOR, d'224', 0, 0 ; color_warnings Color Warnings: Red - CF_DEFAULT CF_BOOL, d'0' ; show_seconds_divemode =1 Show the seconds in Divemode - CF_DEFAULT CF_BOOL, d'0' ; show_clock_divemode =1 Show the clock in Divemode - CF_DEFAULT CF_BOOL, d'1' ; warn_ceiling_divemode =1 Warn ceiling violation in divemode - CF_DEFAULT CF_BOOL, d'0' ; start_with_stopwatch =1 start with stopwatch - CF_DEFAULT CF_BOOL, d'0' ; blink_gas_divemode =1 Show (resetable) average Depth instead of temperature + CF_DEFAULT CF_BOOL, d'0', 0, 0 ; show_seconds_divemode =1 Show the seconds in Divemode + CF_DEFAULT CF_BOOL, d'0', 0, 0 ; show_clock_divemode =1 Show the clock in Divemode + CF_DEFAULT CF_BOOL, d'1', 0, 0 ; warn_ceiling_divemode =1 Warn ceiling violation in divemode + CF_DEFAULT CF_BOOL, d'0', 0, 0 ; start_with_stopwatch =1 start with stopwatch + CF_DEFAULT CF_BOOL, d'0', 0, 0 ; blink_gas_divemode =1 Show (resetable) average Depth instead of temperature - CF_DEFAULT CF_INT15, d'13000' ; color_warn_depth_mBar Warn depths - CF_DEFAULT CF_PERCENT, d'101' ; color_warn_cns_percent Warn-% - CF_DEFAULT CF_PERCENT, d'101' ; color_warn_gf_percent Warn-% - CF_DEFAULT CF_CENTI, d'161' ; color_warn_ppo2_cbar ppO2 warn - CF_DEFAULT CF_INT8, d'15' ; color_warn_celocity_mmin warn at xx m/min + CF_DEFAULT CF_INT15, d'13000', 0, d'13000'; color_warn_depth_mBar Warn depths + CF_DEFAULT CF_PERCENT, d'101', d'50', d'101' ; color_warn_cns_percent Warn-% + CF_DEFAULT CF_PERCENT, d'101', d'50', d'101' ; color_warn_gf_percent Warn-% + 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' ; time_correction_value_default Adds to Seconds on Midnight - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED + CF_DEFAULT CF_SEC, d'42', d'0', d'240' ; time_correction_value_default Adds to Seconds on Midnight + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED - CF_DEFAULT CF_INT15, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED + CF_DEFAULT CF_INT15, 0, 0, 0 ; UNUSED +cf_default_table2: + ;============================================================================= menu_reset: @@ -265,17 +306,17 @@ movwf EEADR clrf hi ; He part (default for all gases: 0%) movlw d'21' ; O2 part (21%) - rcall reset_customfunction ; saves default and current value for gas #1 + rcall reset_gas ; saves default and current value for gas #1 movlw d'21' ; O2 part (21%) - rcall reset_customfunction ; saves default and current value for gas #2 + rcall reset_gas ; saves default and current value for gas #2 movlw d'21' ; O2 part (21%) - rcall reset_customfunction ; saves default and current value for gas #3 + rcall reset_gas ; saves default and current value for gas #3 movlw d'21' ; O2 part (21%) - rcall reset_customfunction ; saves default and current value for gas #4 + rcall reset_gas ; saves default and current value for gas #4 movlw d'21' ; O2 part (21%) - rcall reset_customfunction ; saves default and current value for gas #5 + rcall reset_gas ; saves default and current value for gas #5 movlw d'21' ; O2 part (21%) - rcall reset_customfunction ; saves default and current value for gas #6 + rcall reset_gas ; saves default and current value for gas #6 reset_all_cf: movlw d'1' @@ -327,23 +368,19 @@ movlw d'127' ; address of low byte of first custom function movwf EEADR - movlw LOW cf_default_table ; Load PROM pointer. + movlw LOW cf_default_table0 ; Load PROM pointer. movwf TBLPTRL,A - movlw HIGH cf_default_table + movlw HIGH cf_default_table0 movwf TBLPTRH,A - movlw UPPER cf_default_table + movlw UPPER cf_default_table0 movwf TBLPTRU,A cf_bank0_loop: - ; Did we already read 32 (decimal) bytes ? + ; Did we already read 32 (decimal) words or double-words (with types) ? movf TBLPTRL,W - sublw LOW (cf_default_table+.64) + sublw LOW (cf_default_table1) bz reset_all_cf_bank1 - tblrd*+ - movf TABLAT, W ; Low byte in WREG, - tblrd*+ - movff TABLAT, hi ; High byte in hi rcall reset_customfunction ; saves default and current value bra cf_bank0_loop @@ -352,17 +389,13 @@ movwf EEADRH ; EEPROM BANK 1 !! movlw d'127' ; address of low byte of first custom function movwf EEADR - + cf_bank1_loop: - ; Did we already read another 32 (decimal) bytes ? + ; Did we already read another 32 (decimal) words or double-words ? movf TBLPTRL,W - sublw LOW (cf_default_table+.128) - bz cf_bank1_end + sublw LOW (cf_default_table2) + bz cf_bank1_end - tblrd*+ - movf TABLAT, W ; Low byte in WREG, - tblrd*+ - movff TABLAT, hi ; High byte in hi rcall reset_customfunction ; saves default and current value bra cf_bank1_loop @@ -372,30 +405,40 @@ ;call reset_external_eeprom ; delete profile memory goto restart ; all reset, quit to surfmode -; Write the four bytes lo:hi:lo:(hi w/o type flags) into EEPROM -; Don't change hi:lo values... +; Write WREG:lo twice, w/o any type clearing, pre-incrementing EEADR +reset_gas: + movwf lo + rcall reset_eeprom_value ; First pair + goto reset_eeprom_value ; Second pair. + reset_customfunction: - movwf lo - incf EEADR,F - movff lo, EEDATA ; Lowbyte Defaul value - call write_eeprom - incf EEADR,F - movff hi, EEDATA ; Highbyte default value - call write_eeprom + tblrd*+ + movff TABLAT, lo ; Low byte in lo, + tblrd*+ + movff TABLAT, hi ; High byte in hi + + ifndef NO_CF_TYPES + tblrd*+ ; Skip advanced min/max values. + tblrd*+ + btfss hi,7 ; In EEPROM, just clear all types, + clrf hi ; to keep external program compat (jdivelog etc.) + bcf hi,7 + endif + + ; Manage the default/value tuple + rcall reset_eeprom_value ; First pair, untouched. + bcf hi,7 ; Just clear type bit. + bra reset_eeprom_value ; Second pair, cleared + +; Write the two bytes lo:hi into EEPROM +reset_eeprom_value: incf EEADR,F - movff lo, EEDATA ; Lowbyte current value + movff lo, EEDATA ; Lowbyte Defaul value call write_eeprom + incf EEADR,F - movff hi, EEDATA ; Highbyte current value -#ifdef NO_CF_TYPES - bcf EEDATA,7 ; This bit will only be written for the default value -#else - btfss EEDATA,7 ; A 15bit value ? - clrf EEDATA ; Nope: clear type flag. -#endif - call write_eeprom - return - + movff hi, EEDATA ; Highbyte default value + goto write_eeprom reset_external_eeprom: ; deletes complete external eeprom! clrf eeprom_address+0 diff -r 8b813f67220f -r b40a0a6284da code_part1/OSTC_code_asm_part1/surfmode.asm --- a/code_part1/OSTC_code_asm_part1/surfmode.asm Wed Dec 08 08:37:03 2010 +0100 +++ b/code_part1/OSTC_code_asm_part1/surfmode.asm Thu Dec 09 20:41:56 2010 +0100 @@ -133,10 +133,9 @@ call update_batt_voltage ; display battery voltage call timeout_premenu ; timeout premenu call set_leds_surfmode ; Sets Warning and No-Fly LEDs - call custom_functions_check_surfmode ; Checks CF functions and displays warning symbol if something critical is wrong call PLED_display_decotype_surface ; Show deco mode btfsc enter_error_sleep ; Enter Fatal Error Routine? - call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!) + call fatal_error_sleep ; Yes (In Sleepmode.asm!) bcf onesecupdate ; every second tasks done surfloop_loop2: