# HG changeset patch # User JeanDo # Date 1291654813 -3600 # Node ID 69c4624002792d42d9ce841d8d7c4bc7809fc918 # Parent bd16d5830b067676006cf9648cdb958061a5c3ac Making CF edition esier diff -r bd16d5830b06 -r 69c462400279 code_part1/OSTC_code_asm_part1/menu_custom.asm --- a/code_part1/OSTC_code_asm_part1/menu_custom.asm Tue Dec 07 21:06:45 2010 +0100 +++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm Mon Dec 06 18:00:13 2010 +0100 @@ -43,6 +43,19 @@ ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) +; [jDG] 2010-11-30 More fancy displsy of the various CF types +; data types. When we do have a 8bit data (bit16=0), the high byte serves to +; 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_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. GETCUSTOM8 macro custom8 movlw custom8 @@ -150,6 +163,23 @@ WIN_INVERT .0 ; Init new Wordprocessor menu_custom_functions1: + +#ifndef NO_CF_TYPES + ;---- Clear color swatches area ------------------------------------------ + ; BEWARE: PLED_box reset the EEADRH register, so t should be + ; be done before setting CF page I/II... + clrf WREG ; Black background + movff WREG,box_temp+0 ; Set color + movlw .125 + movff WREG,box_temp+1 ; row top (0-239) + movlw .178 + movff WREG,box_temp+2 ; row bottom (0-239) + movlw .75 + movff WREG,box_temp+3 ; column left (0-159) + movlw .150 + movff WREG,box_temp+4 ; column right (0-159) + call PLED_box +#endif call PLED_standard_color movlw d'1' @@ -169,7 +199,7 @@ btfsc customfunction_page ; Add offset for display movlw d'32' addwf lo,F - movff lo,apnoe_mins ; apnoe_mins used as temp for binary CFs + movff lo, apnoe_mins ; Copy use when NO_CF_TYPES output_99x movlw ':' @@ -182,47 +212,74 @@ addwf decodata+0,W ; add # of current custom function, place result in wreg call displaytext1 ; shows descriptor + ; Read defaults into hi:lo + movf divemins+0,W + 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 + +#ifdef NO_CF_TYPES movlw binary_cf1 subwf apnoe_mins,W ; Binary cf? - btfsc STATUS,Z - bra menu_custom_functions10c ; Yes + bz menu_custom_functions10c ; Yes movlw binary_cf2 subwf apnoe_mins,W ; Binary cf? - btfsc STATUS,Z - bra menu_custom_functions10c ; Yes + bz menu_custom_functions10c ; Yes movlw binary_cf3 subwf apnoe_mins,W ; Binary cf? - btfsc STATUS,Z - bra menu_custom_functions10c ; Yes + bz menu_custom_functions10c ; Yes movlw binary_cf4 subwf apnoe_mins,W ; Binary cf? - btfsc STATUS,Z - bra menu_custom_functions10c ; Yes + bz menu_custom_functions10c ; Yes movlw binary_cf5 subwf apnoe_mins,W ; Binary cf? - btfsc STATUS,Z - bra menu_custom_functions10c ; Yes + bz menu_custom_functions10c ; Yes movlw binary_cf6 subwf apnoe_mins,W ; Binary cf? - btfsc STATUS,Z - bra menu_custom_functions10c ; Yes + bz menu_custom_functions10c ; Yes - - bra menu_custom_functions10a ; Not a binary CF selected + bra menu_custom_functions10a ; Not a binary CF... +#else + movf hi,W ; Is it a ON/OFF flag ? + xorlw CF_BOOL + bnz menu_custom_functions10a ; Not a binary CF selected +#endif menu_custom_functions10c: - movlw d'1' - movwf apnoe_mins ; Yes, set apnoe_mins to "1" + setf apnoe_mins ; Yes, set apnoe_mins to 0xFF + + WIN_LEFT .20 + WIN_TOP .65 + lfsr FSR2,letter ; Make a string of 8 spaces + movlw ' ' + movwf POSTINC2 + movwf POSTINC2 + movwf POSTINC2 + movwf POSTINC2 + movwf POSTINC2 + movwf POSTINC2 + movwf POSTINC2 + movwf POSTINC2 + call word_processor ; Clear +/- line + + WIN_TOP .95 + call word_processor ; Clear 1/10 line bra menu_custom_functions10b menu_custom_functions10a: clrf apnoe_mins ; Yes, clear apnoe_mins -menu_custom_functions10b: + WIN_LEFT .20 WIN_TOP .65 lfsr FSR2,letter @@ -266,69 +323,42 @@ movwf POSTINC2 call word_processor +menu_custom_functions10b: WIN_LEFT .20 WIN_TOP .125 lfsr FSR2,letter OUTPUTTEXT d'89' ;"Default:" - - movf divemins+0,W - 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 - output_16 - movlw ',' + 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 - movlw ' ' - movwf POSTINC2 - movlw ' ' - movwf POSTINC2 - movlw ' ' - movwf POSTINC2 - call word_processor + call display_customfunction ; Typed display. WIN_LEFT .20 WIN_TOP .155 lfsr FSR2,letter OUTPUTTEXT d'97' ; "Current:" + movlw ' ' + movwf POSTINC2 movf divemins+0,W addlw 0x82 movwf EEADR call read_eeprom ; Lowbyte movff EEDATA,lo + movf divemins+0,W addlw 0x83 movwf EEADR call read_eeprom ; Highbyte + + btfss hi,7 ; A 15bit value ? + bra menu_custom_functions1b ; No : keep types there ! + movff EEDATA,hi - output_16 - movlw ' ' - movwf POSTINC2 - movlw ' ' - movwf POSTINC2 - movlw ' ' - movwf POSTINC2 - call word_processor + bsf hi,7 ; Mark it a 15bit value. + +menu_custom_functions1b: + call display_customfunction menu_custom_functions1a: DISPLAYTEXT .11 ; Exit @@ -378,6 +408,136 @@ bcf menubit3 ; clear flag bra customfunctions_loop +;----------------------------------------------------------------------------- +; Input : hi:lo = data to display, with type embebed into hi +; FSR2 = current string pointer. +; Trash : FSR1 (used to backup EEADRH and hi) + +display_customfunction: +#ifndef NO_CF_TYPES + movff EEADRH, FSR1H ; Backup... + movff hi, FSR1L + + ;---- 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 + + ; Jump table: + dcfsnz hi + bra cf_type_01 + dcfsnz hi + bra cf_type_02 + dcfsnz hi + bra cf_type_03 + dcfsnz hi + bra cf_type_04 + dcfsnz hi + bra cf_type_05 + dcfsnz hi + bra cf_type_06 + dcfsnz hi + bra cf_type_07 + bra cf_type_99 ; Default to 8bit mode... + +cf_type_01: ; Type == 1 is percent mode + output_16dp 0 ; NOTE : hi is already reseted... + movlw '%' + movwf POSTINC2 + bra cf_done + +cf_type_02: ; Type == 2 is deci mode. + output_16dp 4 + bra cf_done + +cf_type_03: ; Type == 3 is centi mode. + output_16dp 3 + bra cf_done + +cf_type_04: ; Type == 4 is mili mode + output_16dp 2 + bra cf_done + +cf_type_05: ; Type == 5 is on/off mode. + movf lo,W ; Get flag value... + bz cf_type_off + OUTPUTTEXT d'130' ; ON + bra cf_done +cf_type_off: + OUTPUTTEXT d'131' ; OFF + bra cf_done + +cf_type_06: ; Type == 6 is mm:ss mode (... or hh:mm) + call convert_time ; Convert to min:sec into hi:low. + movff lo,wp_temp ; Save seconds, + movff hi,lo ; Get minutes + 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_done + +cf_type_07: ; Type == 7 is Color swatch. + output_8 + + movf lo,W ; Get color. + movff WREG,box_temp+0 ; Set color + movff win_top,WREG ; BEWARE : this is a bank0 variable ! + movff WREG,box_temp+1 ; row top (0-239) + addlw .23 + movff WREG,box_temp+2 ; row bottom (0-239) + movlw .110 + movff WREG,box_temp+3 ; column left (0-159) + movlw .140 + movff WREG,box_temp+4 ; column right (0-159) + + call PLED_box + bra cf_done ; W/o trailling spaces... + +cf_type_99: ; 8bit mode. Or unrecognized type... + clrf hi + +cf_type_0: ; 15bit mode. + bcf hi,7 + output_16 + +cf_done: + movff FSR1L, hi ; Restore saved registers... + movff FSR1H, EEADRH +#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 +#endif + goto word_processor + +;----------------------------------------------------------------------------- do_customfunction: CLRF EEADRH @@ -475,8 +635,7 @@ call read_eeprom ; Highbyte movff EEDATA,divemins+1 ; Highbyte of default value - movlw d'1' - cpfseq apnoe_mins ; If apnoe_mins=1 then CF is binary + btfss apnoe_mins,0 ; If apnoe_mins=1 then CF is binary bra adjust_cfn_value1 ; Not Binary tstfsz lo ; =0? @@ -559,6 +718,11 @@ 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 diff -r bd16d5830b06 -r 69c462400279 code_part1/OSTC_code_asm_part1/menu_reset.asm --- a/code_part1/OSTC_code_asm_part1/menu_reset.asm Tue Dec 07 21:06:45 2010 +0100 +++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm Mon Dec 06 18:00:13 2010 +0100 @@ -27,6 +27,118 @@ ; routines to reset custom function, gases and decompression values ; does not reset clock +;============================================================================= +; CF default values +; + +; 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 + +; resets all customfunctions to the following default values +cf_default_table: + ;---- 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 + + 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_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_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_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'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_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 + + ;---- 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 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_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_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_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 ; 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 ; UNUSED +;============================================================================= + menu_reset: movlw d'1' movwf menupos @@ -166,7 +278,6 @@ rcall reset_customfunction ; saves default and current value for gas #6 reset_all_cf: -; resets all customfunctions to the following default values movlw d'1' movwf EEDATA write_int_eeprom d'33' ; reset start gas @@ -211,270 +322,58 @@ movwf nofly_time+0 ; Clear nofly time clrf nofly_time+1 ; Clear nofly time -#DEFINE dive_threshold d'100' ; 8BIT 100cm -#DEFINE surf_threshold d'30' ; 8BIT 30cm -#DEFINE diveloop_timeout d'240' ; 8BIT 240s -#DEFINE surfloop_timeout d'120' ; 8BIT 120s -#DEFINE premenu_timeout d'5' ; 8BIT 5s - -#DEFINE minimum_velocity d'7' ; 8BIT 7min/min -#DEFINE pressure_offset_divemode d'1160' ; 15BIT 1160mBar -#DEFINE max_surfpressure d'1100' ; 15BIT 1100mBar -#DEFINE min_gradient_factor d'20' ; 8Bit 20% -#DEFINE oxygen_threshold d'20' ; 8Bit 20% - -#DEFINE dive_menu_timeout d'30' ; 8BIT 30s -#DEFINE saturation_multiplier d'110' ; 8BIT x1.1 -#DEFINE desaturation_multiplier d'90' ; 8BIT x0.9 -#DEFINE nofly_time_ratio d'60' ; 8BIT 60% -#DEFINE gradient_factor_alarm1 d'100' ; 8Bit 100% - -#DEFINE cns_display_surface d'10' ; 8Bit 10% -#DEFINE deco_distance_for_sim d'10' ; 8Bit 1m -#DEFINE ppo2_warning_low d'019' ; 8Bit 0.19 Bar -#DEFINE ppo2_warning_high d'160' ; 8Bit 1.60 Bar -#DEFINE ppo2_display_high d'150' ; 8Bit 1.50 Bar - -#DEFINE sampling_rate d'10' ; 8Bit 10s -#DEFINE sampling_divisor_temp d'6' ; 8Bit /6 -#DEFINE sampling_divisor_deco d'6' ; 8Bit /6 -#DEFINE sampling_divisor_tank d'0' ; 8Bit never -#DEFINE sampling_divisor_ppo2 d'0' ; 8Bit never - -#DEFINE sampling_divisor_deco2 d'0' ; 8Bit never -#DEFINE sampling_divisor_nyu2 d'0' ; 8Bit never -#DEFINE cns_display_high d'20' ; 8Bit 20% -#DEFINE logbook_offset d'0' ; 15Bit No Offset, but 15Bit value -#DEFINE last_deco_depth d'3' ; 8Bit 3m -#DEFINE timeout_apnoe_mode d'10' ; 8Bit 10min -#DEFINE show_voltage_value d'0' ; 1Bit =1 Show value instead of symbol, =0 Show Symbol - -#DEFINE GF_low_default d'30' ; 8Bit 30% -#DEFINE GF_high_default d'90' ; 8Bit 90% -#DEFINE color_battery_surface d'199' ; 8Bit Color Battery sign: Deep blue -#DEFINE color_standard1 d'255' ; 8Bit Color Standard: White -#DEFINE color_divemask d'62' ; 8Bit Color Divemask: Light green -#DEFINE color_warnings d'224' ; 8Bit Color Warnings: Red - -#DEFINE show_seconds_divemode d'0' ; 1Bit =1 Show the seconds in Divemode -#DEFINE show_clock_divemode d'0' ; 1Bit =1 Show the clock in Divemode -#DEFINE warn_ceiling_divemode d'1' ; 1Bit =1 Warn ceiling violation in divemode -#DEFINE start_with_stopwatch d'0' ; 1Bit =1 start with stopwatch -#DEFINE blink_gas_divemode d'0' ; 1Bit =1 Show (resetable) average Depth instead of temperature - -#DEFINE color_warn_depth_mBar d'13000' ; 15Bit Warn depths -#DEFINE color_warn_cns_percent d'101' ; 8Bit Warn-% -#DEFINE color_warn_gf_percent d'101' ; 8Bit Warn-% -#DEFINE color_warn_ppo2_cbar d'161' ; 8Bit ppO2 warn -#DEFINE color_warn_celocity_mmin d'15' ; 8Bit warn at xx m/min - -#DEFINE time_correction_value_default d'42' ; 8Bit Adds to Seconds on Midnight - +reset_all_cf_bank0: + clrf EEADRH movlw d'127' ; address of low byte of first custom function movwf EEADR - clrf hi ; only required once - movlw LOW dive_threshold ; 8Bit value - rcall reset_customfunction ; saves default and current value - movlw LOW surf_threshold - rcall reset_customfunction ; saves default and current value - - movlw LOW diveloop_timeout - rcall reset_customfunction ; saves default and current value - - movlw LOW surfloop_timeout - rcall reset_customfunction ; saves default and current value - - movlw LOW premenu_timeout - rcall reset_customfunction ; saves default and current value - - movlw LOW minimum_velocity - rcall reset_customfunction ; saves default and current value - - movlw HIGH pressure_offset_divemode - movwf hi - bsf hi,7 ; 15Bit value - movlw LOW pressure_offset_divemode - rcall reset_customfunction ; saves default and current value - - movlw HIGH max_surfpressure - movwf hi - bsf hi,7 ; 15Bit value - movlw LOW max_surfpressure - rcall reset_customfunction ; saves default and current value - - movlw LOW min_gradient_factor - rcall reset_customfunction ; saves default and current value - - movlw LOW oxygen_threshold - rcall reset_customfunction ; saves default and current value - - movlw LOW dive_menu_timeout - rcall reset_customfunction ; saves default and current value - - movlw LOW saturation_multiplier - rcall reset_customfunction ; saves default and current value - - movlw LOW desaturation_multiplier - rcall reset_customfunction ; saves default and current value - - movlw LOW nofly_time_ratio - rcall reset_customfunction ; saves default and current value - - movlw LOW gradient_factor_alarm1 - rcall reset_customfunction ; saves default and current value + movlw LOW cf_default_table ; Load PROM pointer. + movwf TBLPTRL,A + movlw HIGH cf_default_table + movwf TBLPTRH,A + movlw UPPER cf_default_table + movwf TBLPTRU,A - movlw LOW cns_display_surface - rcall reset_customfunction ; saves default and current value - - movlw LOW deco_distance_for_sim - rcall reset_customfunction ; saves default and current value - - movlw LOW ppo2_warning_low - rcall reset_customfunction ; saves default and current value - - movlw LOW ppo2_warning_high - rcall reset_customfunction ; saves default and current value - - movlw LOW ppo2_display_high - rcall reset_customfunction ; saves default and current value - - movlw LOW sampling_rate - rcall reset_customfunction ; saves default and current value +cf_bank0_loop: + ; Did we already read 32 (decimal) bytes ? + movf TBLPTRL,W + sublw LOW (cf_default_table+.64) + bz reset_all_cf_bank1 - movlw LOW sampling_divisor_temp - rcall reset_customfunction ; saves default and current value - - movlw LOW sampling_divisor_deco - rcall reset_customfunction ; saves default and current value - - movlw LOW sampling_divisor_tank + tblrd*+ + movf TABLAT, W ; Low byte in WREG, + tblrd*+ + movff TABLAT, hi ; High byte in hi rcall reset_customfunction ; saves default and current value - - movlw LOW sampling_divisor_ppo2 - rcall reset_customfunction ; saves default and current value - - movlw LOW sampling_divisor_deco2 - rcall reset_customfunction ; saves default and current value - - movlw LOW sampling_divisor_nyu2 - rcall reset_customfunction ; saves default and current value - - movlw LOW cns_display_high - rcall reset_customfunction ; saves default and current value - - clrf hi - bsf hi,7 ; 15Bit value - movlw LOW logbook_offset - rcall reset_customfunction ; saves default and current value - - movlw LOW last_deco_depth - rcall reset_customfunction ; saves default and current value - - movlw LOW timeout_apnoe_mode - rcall reset_customfunction ; saves default and current value - - movlw LOW show_voltage_value - rcall reset_customfunction ; saves default and current value + bra cf_bank0_loop reset_all_cf_bank1: movlw d'1' movwf EEADRH ; EEPROM BANK 1 !! movlw d'127' ; address of low byte of first custom function movwf EEADR - clrf hi ; only required once/bank - movlw LOW GF_low_default - rcall reset_customfunction ; saves default and current value - - movlw LOW GF_high_default - rcall reset_customfunction ; saves default and current value - - movlw color_battery_surface - rcall reset_customfunction ; saves default and current value - - movlw color_standard1 - rcall reset_customfunction ; saves default and current value - - movlw color_divemask - rcall reset_customfunction ; saves default and current value - - movlw color_warnings - rcall reset_customfunction ; saves default and current value - - movlw show_seconds_divemode - rcall reset_customfunction ; saves default and current value - - movlw show_clock_divemode - rcall reset_customfunction ; saves default and current value - - movlw warn_ceiling_divemode - rcall reset_customfunction ; saves default and current value - - movlw start_with_stopwatch - rcall reset_customfunction ; saves default and current value - - movlw blink_gas_divemode - rcall reset_customfunction ; saves default and current value - - movlw HIGH color_warn_depth_mBar - movwf hi - bsf hi,7 ; 15Bit value - movlw LOW color_warn_depth_mBar - rcall reset_customfunction ; saves default and current value - - movlw color_warn_cns_percent - rcall reset_customfunction ; saves default and current value +cf_bank1_loop: + ; Did we already read another 32 (decimal) bytes ? + movf TBLPTRL,W + sublw LOW (cf_default_table+.128) + bz cf_bank1_end - movlw color_warn_gf_percent - rcall reset_customfunction ; saves default and current value - - movlw color_warn_ppo2_cbar - rcall reset_customfunction ; saves default and current value - - movlw color_warn_celocity_mmin - rcall reset_customfunction ; saves default and current value - - movlw time_correction_value_default - rcall reset_customfunction ; saves default and current value - - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' + tblrd*+ + movf TABLAT, W ; Low byte in WREG, + tblrd*+ + movff TABLAT, hi ; High byte in hi rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value - movlw d'0' - rcall reset_customfunction ; saves default and current value + bra cf_bank1_loop +cf_bank1_end: clrf EEADRH ; EEPROM BANK 0 ! - ;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... reset_customfunction: movwf lo incf EEADR,F @@ -487,10 +386,14 @@ movff lo, EEDATA ; Lowbyte current value call write_eeprom incf EEADR,F - bcf hi,7 ; This bit will only be written for the default value 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 - clrf hi return