annotate src/options.asm @ 632:0347acdf6d8e

changelog updates
author heinrichsweikamp
date Sat, 29 Feb 2020 16:57:45 +0100
parents 185ba2f91f59
children 4050675965ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
3 ; File options.asm next combined generation V3.08.8
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Manage all options data.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-07-12 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
13 #include "hwos.inc" ; mandatory header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
14 #include "strings.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
15 #include "convert.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
16 #include "ghostwriter.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
17 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
18 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
19 #include "wait.inc"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
20 #include "shared_definitions.h"
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
21 #include "gaslist.inc"
0
heinrichsweikamp
parents:
diff changeset
22
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
23 extern write_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
24 extern read_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
25 extern option_table_begin,option_table_end
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
26 extern convert_meter_to_feet
0
heinrichsweikamp
parents:
diff changeset
27
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
28 options CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
29
0
heinrichsweikamp
parents:
diff changeset
30 ;=============================================================================
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
31 ; Reset all options to factory defaults (in memory only)
0
heinrichsweikamp
parents:
diff changeset
32 ;
heinrichsweikamp
parents:
diff changeset
33 ; INPUT: none
heinrichsweikamp
parents:
diff changeset
34 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
35 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
36 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
37 global option_reset_all ; reset all options to factory default
0
heinrichsweikamp
parents:
diff changeset
38 option_reset_all:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
39 call eeprom_total_dives_read ; read total number of dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
40 tstfsz mpr+0 ; number of total dives, low byte = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
41 bra option_reset_all_1 ; NO - skip resetting logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
42 tstfsz mpr+1 ; number of total dives, high byte = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
43 bra option_reset_all_1 ; NO - skip resetting logbook
0
heinrichsweikamp
parents:
diff changeset
44
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
45 ; reset logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
46 call erase_complete_logbook ; erase complete logbook
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
47
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
48 ; reset logbook offset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
49 CLRI mpr ; set logbook offset to zero
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
50 call eeprom_log_offset_write ; store logbook offset
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
51
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
52 option_reset_all_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
53 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
54 option_reset_all_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
55 rcall option_reset ; reset option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
56 incfsz opt_end_token,F ; was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
57 bra option_reset_all_loop ; NO - do next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
58 return ; YES - done
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
59
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
60
0
heinrichsweikamp
parents:
diff changeset
61 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
62 ; Reset an option to its default value
0
heinrichsweikamp
parents:
diff changeset
63 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
64 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
65 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2
heinrichsweikamp
parents:
diff changeset
66 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
67 global option_reset ; reset option value to default
0
heinrichsweikamp
parents:
diff changeset
68 option_reset:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
69 ; read type, default and register from table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
70 rcall option_read_definition ; read option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
71
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
72 option_reset_loaded: ; entry point with option definition already read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
73 bsf option_repaired ; flag that an option was repaired
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
74 bsf options_changed ; flag that EEPROM needs to be updated
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
75 movf opt_type,W ; get option type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
76 xorlw .2 ; type = STRING ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
77 bz opt_reset_string ; YES - string copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
78 movff opt_default,INDF1 ; NO - 1 byte copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
79 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
80
0
heinrichsweikamp
parents:
diff changeset
81 opt_reset_string:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
82 movff FSR1L,FSR2L ; set string destination address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
83 movff FSR1H,FSR2H ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
84 movff opt_default+0,FSR1L ; get handle to multi-lingual text in FSR1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
85 movff opt_default+1,FSR1H ; ...
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
86 movff TBLPTRL,mpr+0 ; TBLPTR will be trashed by text routine, so make a back-up
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
87 movff TBLPTRH,mpr+1 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
88 movff TBLPTRU,mpr+2 ; ...
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
89 call strcat_text ; copy translated text to FSR2
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
90 movff mpr+0,TBLPTRL ; restore TBLPTR
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
91 movff mpr+1,TBLPTRH ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
92 movff mpr+2,TBLPTRU ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
93 return ; done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
94
0
heinrichsweikamp
parents:
diff changeset
95
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
96 ;=============================================================================
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
97 ; Read option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
98 ; INPUT: FSR0 = option handle
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
99 ; OUTPUT: FSR1 = address of variable.
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
100 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
101 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
102 option_read_definition:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
103 movff FSR0L,TBLPTRL ; low byte : set memory address of option data set
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
104 movlw HIGH(option_table_begin) ; high byte : get table start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
105 andlw 0xF0 ; keep only the upper nibble
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
106 iorwf FSR0H,W ; add the memory address of the option data set
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
107 movwf TBLPTRH ; set the resulting memory address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
108 movlw UPPER(option_table_begin) ; upper byte: get table start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
109 movwf TBLPTRU ; set memory address of option data set
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
110
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
111 lfsr FSR1,opt_type ; load FSR1 with base address of option definition vars
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
112 movlw opt_definiton_bytes ; get number of bytes to copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
113 movwf eeprom_loop ; initialize loop counter (using an EEPROM variable here)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
114 option_read_definition_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
115 tblrd*+ ; read one byte from program memory and increment address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
116 movff TABLAT,POSTINC1 ; transfer byte from program memory to memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
117 decfsz eeprom_loop,F ; all bytes done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
118 bra option_read_definition_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
119 tblrd* ; YES - read one byte ahead without incrementing address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
120 movff TABLAT,POSTINC1 ; - store byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
121 movff opt_memory+0,FSR1L ; - load FSR1 with the address of the option value variable
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
122 movff opt_memory+1,FSR1H ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
123 movff TBLPTRL,FSR0L ; - advance handle to the next option definition data set
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
124 movff TBLPTRH,FSR0H ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
125 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
126
0
heinrichsweikamp
parents:
diff changeset
127
heinrichsweikamp
parents:
diff changeset
128 ;=============================================================================
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
129 ; Check one option and reset its value if it is out of min/max boundary
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
130 ; INPUT: opt_* vars and FSR1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
131 ; OUTPUT: option value set to default if out of min/max
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
132 ; TRASH: WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
133 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
134 option_check_loaded:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
135 ; switch on type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
136 movf opt_type,W ; get type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
137 bz option_check_uint8 ; type 0: INT8
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
138 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
139 bra option_check_enum8 ; type 1: ENUM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
140 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
141 bra option_check_string ; type 2: STRING
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
142 ;bra option_check_uint8 ; type 3: INT8
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
143
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
144 option_check_uint8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
145 tstfsz opt_min ; opt_min = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
146 bra option_check_min ; NO - check it
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
147 bra option_check_enum8 ; YES - continue with check for maximum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
148
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
149 option_check_min:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
150 decf opt_min,W ; get (minimum permissible value - 1) into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
151 cpfsgt INDF1 ; option value > (minimum permissible value - 1) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
152 bra option_reset_loaded ; NO - reset option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
153 ;bra option_check_enum8 ; YES - continue with check for maximum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
154
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
155 option_check_enum8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
156 infsnz opt_max,W ; get (highest permissible value + 1) into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
157 return ; highest permissible value was 255, skip check, done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
158 cpfslt INDF1 ; option value < (highest permissible value + 1) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
159 bra option_reset_loaded ; NO - reset option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
160 return ; YES - within range, done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
161
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
162 option_check_string:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
163 return ; nothing to check with strings
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
164
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
165
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
166 ;=============================================================================
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
167 ; Check and store all option values in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
168 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
169 global option_check_and_store_all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
170 option_check_and_store_all:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
171 bcf PIR3,RC2IE ; disable EUSART interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
172
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
173 ;---- save option version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
174 MOVLI eeprom_opt_version,mpr ; get options version number
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
175 EEPROM_II_WRITE mpr,eeprom_options_version ; store options version number in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
176
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
177 ;---- check and resolve some interdependencies among options
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
178 bsf is_diluent_menu ; setup checking diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
179 call gaslist_cleanup_list ; check and correct multiple or none First diluents
0
heinrichsweikamp
parents:
diff changeset
180
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
181 bcf is_diluent_menu ; setup checking gases
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
182 call gaslist_cleanup_list ; check and correct multiple or none First gases
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
183
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
184 IFNDEF _gauge_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
185 call option_cleanup_gauge ; check and correct gauge mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
186 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
187
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
188 IFDEF _ccr_pscr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
189 call option_cleanup_oCCRMode ; check and correct CCR / pSCR mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
190 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
191
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
192 call option_cleanup_GF ; check and correct GFlow <= GFhigh
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
193
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
194 ;---- check and save all option values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
195 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
196 option_save_all_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
197 rcall option_check_and_store ; check and save option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
198 incfsz opt_end_token,F ; was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
199 bra option_save_all_loop ; NO - do next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
200 return ; YES - done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
201
0
heinrichsweikamp
parents:
diff changeset
202
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
203 ;=============================================================================
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
204 ; Check and store an option value in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
205 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
206 global option_check_and_store
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
207 option_check_and_store:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
208 rcall option_read_definition ; read the option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
209 rcall option_check_loaded ; check if option value is within min/max, set to default if not
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
210
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
211 option_save_loaded_checked:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
212 movf opt_eeprom_bank,W ; get bank
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
213 andlw b'11111110' ; keep only bits 7-1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
214 tstfsz WREG ; bank < 0x02 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
215 return ; NO - volatile option or illegal address, abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
216 tstfsz opt_eeprom_bank ; YES - bank = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
217 bra option_save_execute ; NO - address is valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
218 movlw low(eeprom_options_storage-1) ; YES - get start address of options storage minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
219 cpfsgt opt_eeprom_index ; - index >= start address ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
220 return ; NO - illegal address, abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
221 ;bra option_save_execute ; YES - address is valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
222
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
223 option_save_execute:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
224 movff opt_eeprom_index,EEADR ; set EEPROM index (address low byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
225 movff opt_eeprom_bank, EEADRH ; set EEPROM page (address high byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
226
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
227 movf opt_type,W ; get option type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
228 xorlw .2 ; option type = string ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
229 bz option_save_string ; YES - special handling
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
230 movff INDF1,EEDATA ; NO - copy option value to EEPROM write register
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
231 call write_eeprom ; - execute write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
232 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
233
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
234 option_save_string:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
235 movff POSTINC1,EEDATA ; copy a character from the option value to the EEPROM write register
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
236 btfss EEADRH,1 ; current EEPROM address < 512 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
237 call write_eeprom ; YES - execute write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
238 infsnz EEADR,F ; increment EEPROM address, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
239 incf EEADRH,F ; increment EEPROM address, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
240 decfsz opt_max ; decrement string length, done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
241 bra option_save_string ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
242 return ; YES - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
243
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
244
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
245 ;=============================================================================
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
246 ; Restore and check all option values from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
247 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
248 global option_restore_and_check_all ; restore options from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
249 option_restore_and_check_all:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
250 ;---- Read option version from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
251 EEPROM_II_READ eeprom_options_version,mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
252
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
253 movlw LOW(eeprom_opt_version) ; get options version from current firmware, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
254 xorwf mpr+0,W ; compare with EEPROM version, do they match?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
255 bnz option_restore_reset ; NO - reset to defaults of current firmware
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
256
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
257 movlw HIGH(eeprom_opt_version) ; get options version from current firmware, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
258 xorwf mpr+1,W ; compare with EEPROM version, do they match?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
259 bnz option_restore_reset ; NO - reset to defaults of current firmware
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
260
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
261 ;---- restore all option values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
262 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
263 option_restore_all_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
264 rcall option_restore_and_check ; restore and check the option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
265 incfsz opt_end_token,F ; was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
266 bra option_restore_all_loop ; NO - do next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
267 return ; YES - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
268
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
269 option_restore_reset:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
270 call option_reset_all ; reset all option values to their default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
271 goto option_check_and_store_all ; write back all option values to EEPROM (and return)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
272
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
273
0
heinrichsweikamp
parents:
diff changeset
274 ;=============================================================================
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
275 ; Restore an option value from EEPROM and check it
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
276 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
277 global option_restore_and_check
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
278 option_restore_and_check:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
279 rcall option_read_definition ; read the option definition
0
heinrichsweikamp
parents:
diff changeset
280
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
281 movf opt_eeprom_bank,W ; get bank
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
282 andlw b'11111110' ; keep only bits 7-1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
283 tstfsz WREG ; bank < 0x02 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
284 bra option_reset_loaded ; NO - volatile option or illegal address, restore to default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
285 tstfsz opt_eeprom_bank ; YES - bank = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
286 bra option_restore_execute ; NO - address is valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
287 movlw low(eeprom_options_storage-1) ; YES - get start address of options storage minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
288 cpfsgt opt_eeprom_index ; - index >= start address ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
289 bra option_reset_loaded ; NO - illegal address, restore to default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
290 ;bra option_restore_execute ; YES - address is valid
0
heinrichsweikamp
parents:
diff changeset
291
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
292 option_restore_execute:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
293 movff opt_eeprom_index,EEADR ; set EEPROM index (address low byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
294 movff opt_eeprom_bank, EEADRH ; set EEPROM page (address high byte)
0
heinrichsweikamp
parents:
diff changeset
295
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
296 movf opt_type,W ; get option type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
297 xorlw .2 ; option type = string ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
298 bz option_restore_string ; YES - special handling
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
299 call read_eeprom ; NO - execute read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
300 movff EEDATA,INDF1 ; - read option value from EEPROM read register
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
301 bcf option_repaired ; - clear option repaired flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
302 bra option_check_loaded ; - check if option value is within min/max, reset to default if not
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
303 btfsc option_repaired ; - was the option repaired?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
304 bra option_save_loaded_checked ; YES - save repaired value to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
305 return ; NO - done
0
heinrichsweikamp
parents:
diff changeset
306
heinrichsweikamp
parents:
diff changeset
307 option_restore_string:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
308 call read_eeprom ; read one character from the EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
309 movff EEDATA,POSTINC1 ; copy it to the option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
310 infsnz EEADR,F ; increment EEPROM address, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
311 incf EEADRH,F ; increment EEPROM address, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
312 decfsz opt_max ; decrement string length, done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
313 bra option_restore_string ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
314 return ; YES - done (nothing to check with strings)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
315
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
316
0
heinrichsweikamp
parents:
diff changeset
317
heinrichsweikamp
parents:
diff changeset
318 ;=============================================================================
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
319 ; Read an option value via RS232
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
320 ; INPUT: lo = serial index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
321 ; OUTPUT: hi = option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
322 ; WREG =0: option found and value valid, =1: option not found
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
323 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
324 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
325 global option_read_serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
326 option_read_serial:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
327 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
328 option_read_serial_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
329 rcall option_read_definition ; read option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
330 movf opt_serial,W ; get serial index of the option into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
331 xorwf lo,W ; received index = index of this option ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
332 bz option_read_serial_execute ; YES - read value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
333 incfsz opt_end_token,F ; NO - was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
334 bra option_read_serial_loop ; NO - try next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
335 retlw .1 ; YES - done, option not found
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
336
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
337 option_read_serial_execute:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
338 movff INDF1,hi ; read option value into hi
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
339 retlw .0 ; done, option found
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
340
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
341
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
342 ;=============================================================================
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
343 ; Write an option value via RS232
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
344 ; INPUT: lo = serial index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
345 ; hi = option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
346 ; OUTPUT: WREG =0: option found and value valid, =1: option not found, =2: value not valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
347 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, up
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
348 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
349 global option_write_serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
350 option_write_serial:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
351 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
352 option_write_serial_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
353 rcall option_read_definition ; read option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
354 movf opt_serial,W ; get serial index of the option into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
355 xorwf lo,W ; received index = index of this option ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
356 bz option_write_serial_execute ; YES - check and update value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
357 incfsz opt_end_token,F ; NO - was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
358 bra option_write_serial_loop ; NO - try next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
359 retlw .1 ; YES - done, option not found
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
360
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
361 option_write_serial_execute:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
362 movff INDF1,up ; backup old value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
363 movff hi,INDF1 ; write new value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
364 bcf option_repaired ; clear option repaired flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
365 rcall option_check_loaded ; check the new value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
366 btfsc option_repaired ; was the new value valid?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
367 bra option_write_serial_execute_fail; NO - restore old value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
368 bsf options_changed ; YES - flag that EEPROM needs to be updated
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
369 retlw .0 ; - done, success
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
370 option_write_serial_execute_fail:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
371 movff up,INDF1 ; restore old value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
372 retlw .2 ; done, value not valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
373
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
374
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
375 ;=============================================================================
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
376 ; Increment an option value based on type and min/max boundary
0
heinrichsweikamp
parents:
diff changeset
377 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
378 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
379 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
380 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
381 global option_inc ; increment FSR0 option
0
heinrichsweikamp
parents:
diff changeset
382 option_inc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
383 ; read type, default and register from table
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
384 rcall option_read_definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
385
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
386 bsf options_changed ; flag that EEPROM needs to be updated
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
387
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
388 ; switch on type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
389 movf opt_type,W ; get option type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
390 bz option_inc_uint8 ; type 0: INT8
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
391 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
392 bra option_inc_enum8 ; type 1: ENUM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
393 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
394 bra option_inc_string ; type 2: STRING
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
395 ;bra option_inc_uint8 ; type 3: INT8
0
heinrichsweikamp
parents:
diff changeset
396
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
397 option_inc_uint8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
398 movf INDF1,W ; get option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
399 addwf opt_inc,W ; add increment
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
400 cpfslt opt_max ; max < option value ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
401 bra option_inc_uint8_0 ; NO - new option value ok
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
402 movf opt_min,W ; YES - reset to min value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
403 option_inc_uint8_0:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
404 movwf INDF1 ; store new value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
405 option_inc_uint8_1:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
406 ; now some rather crude hack into this routine to make CCR calibration more convenient:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
407 movlw 0x37 ; serial ID of option CalGasO2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
408 cpfseq opt_serial ; editing CalGasO2 right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
409 bra option_inc_uint8_2 ; NO - check next option
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
410 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
411 decfsz WREG,W ; - in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
412 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
413 movlw .26 ; YES -
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
414 cpfseq INDF1 ; - option value = 26 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
415 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
416 movlw .95 ; YES - advance it to 95
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
417 movwf INDF1 ; - store it
533
dfac393b2199 CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents: 418
diff changeset
418 return
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
419 option_inc_uint8_2:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
420 movlw 0x25 ; serial ID of option opt_GF_low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
421 cpfseq opt_serial ; editing opt_GF_low right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
422 bra option_inc_uint8_3 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
423 movff opt_GF_high,WREG ; get value of associated GF high into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
424 cpfsgt INDF1 ; GF low > GF high?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
425 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
426 movff opt_min,INDF1 ; YES - wrap around to minimum value
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
427 return ; - done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
428 option_inc_uint8_3:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
429 movlw 0x26 ; serial ID of option opt_GF_high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
430 cpfseq opt_serial ; editing opt_GF_high right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
431 bra option_inc_uint8_4 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
432 movff opt_GF_low,WREG ; get value of associated GF low into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
433 cpfslt INDF1 ; GF high < GF low?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
434 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
435 movwf INDF1 ; YES - rise GF high to GF low
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
436 return ; - done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
437 option_inc_uint8_4:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
438 movlw 0x27 ; serial ID of option opt_aGF_low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
439 cpfseq opt_serial ; editing opt_aGF_low right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
440 bra option_inc_uint8_5 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
441 movff opt_aGF_high,WREG ; get value of associated GF high into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
442 cpfsgt INDF1 ; GF low > GF high?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
443 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
444 movff opt_min,INDF1 ; YES - wrap around to minimum value
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
445 return ; - done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
446 option_inc_uint8_5:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
447 movlw 0x28 ; serial ID of option opt_aGF_high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
448 cpfseq opt_serial ; editing opt_aGF_high right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
449 bra option_inc_uint8_6 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
450 movff opt_aGF_low,WREG ; get value of associated GF low into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
451 cpfslt INDF1 ; GF high < GF low?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
452 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
453 movwf INDF1 ; YES - rise GF high to GF low
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
454 return ; - done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
455 option_inc_uint8_6:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
456 return ; all done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
457
0
heinrichsweikamp
parents:
diff changeset
458
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
459 option_inc_enum8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
460 movf opt_max,W ; copy maximum permissible value to WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
461 cpfslt INDF1 ; option value < maximum permissible value ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
462 bra option_inc_enum8_reset ; NO - reset option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
463 incf INDF1,F ; YES - increment option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
464 bra option_inc_enum8_1 ; - continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
465 option_inc_enum8_reset:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
466 clrf INDF1 ; reset option value to zero
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
467
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
468 option_inc_enum8_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
469 IFDEF _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
470 ; now some rather crude hack into this routine to unify CCR & pSCR mode setting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
471 movlw 0x1F ; serial ID of option oCCRMode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
472 cpfseq opt_serial ; editing oCCRMode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
473 bra option_inc_enum8_2 ; NO - check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
474 IFDEF _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
475 btfsc analog_o2_input ; YES - does hosting OSTC have an analog interface?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
476 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
477 btfsc optical_input ; does hosting OSTC have an optical interface?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
478 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
479 ENDIF ; _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
480 movf INDF1,W ; NO to both - get mode (=0: fixed SP, =1: Sensor, =2: AutoSP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
481 xorlw .1 ; - in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
482 bnz option_inc_enum8_1a ; NO - continue with next check
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
483 incf INDF1,F ; YES - advance option value to AutoSP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
484 option_inc_enum8_1a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
485 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
486 xorlw .4 ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
487 bnz option_inc_enum8_1_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
488 bcf INDF1,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
489 option_inc_enum8_1_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
490 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
491 ENDIF ; _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
492
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
493 option_inc_enum8_2:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
494 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
495 ; now some rather crude hack to switch off contingency mode if gas needs calculation is switched off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
496 movlw 0x5A ; serial ID of option opt_calc_gasvolume
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
497 cpfseq opt_serial ; editing opt_calc_gasvolume right now?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
498 bra option_inc_enum8_3 ; NO - check next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
499 movf INDF1,W ; YES - get option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
500 ; xorlw .0 ; - option value = off ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
501 bnz option_inc_enum8_2_exit ; NO - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
502 clrf WREG ; YES - force contingency to be off, too
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
503 movff WREG,opt_gas_contingency_dive ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
504 option_inc_enum8_2_exit:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
505 return
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
506 ENDIF ; _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
507
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
508 option_inc_enum8_3:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
509 ; now some rather crude hack to correct opt_TR_mode in dependency of opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
510 movlw 0x20 ; serial ID of option opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
511 cpfseq opt_serial ; editing opt_dive_mode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
512 bra option_inc_enum8_4 ; NO - check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
513 movf INDF1,W ; YES - get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
514 xorlw .1 ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
515 bnz option_inc_enum8_3a ; NO - in some other mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
516 IFNDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
517 incf INDF1,f ; YES - no CCR mode compiled in, advance to gauge mode
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
518 bra option_inc_enum8_3a ; - check if gauge mode is available
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
519 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
520 IFDEF _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
521 global option_cleanup_oTrMode_CCR ; embedded clean-up entry-point
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
522 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
523 movff opt_TR_mode,WREG ; get TR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
524 xorlw .2 ; mode = 2 (ind.double)?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
525 bnz option_inc_enum8_3_exit ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
526 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
527 ENDIF ; _rx_functions
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
528 option_inc_enum8_3a: ; any mode other than CCR
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
529 IFNDEF _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
530 movf INDF1,W ; get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
531 xorlw .2 ; in Gauge mode?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
532 bnz option_inc_enum8_3b ; NO - in some other mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
533 incf INDF1,f ; YES - no Gauge mode compiled in, advance to Apnea mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
534 bra option_inc_enum8_3_exit ; - done (Apnea mode is always available)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
535 ENDIF ; _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
536 option_inc_enum8_3b:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
537 IFNDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
538 movf INDF1,W ; get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
539 xorlw .4 ; in pSCR mode?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
540 bnz option_inc_enum8_3c ; NO - in some other mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
541 clrf INDF1 ; YES - no pSCR mode compiled in, advance to 0 "OC"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
542 bra option_inc_enum8_3_exit ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
543 ENDIF ; _ccr_pscr
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
544 option_inc_enum8_3c:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
545 global option_cleanup_oTrMode_no_CCR ; embedded clean-up entry-point
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
546 option_cleanup_oTrMode_no_CCR: ; entry point from cleanup during restart
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
547 movff opt_TR_mode,WREG ; get TR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
548 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
549 bnz option_inc_enum8_3_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
550 option_inc_enum8_3_reset: ; YES - revert to mode 1 (on)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
551 movlw .1 ; load coding of mode "on"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
552 movff WREG,opt_TR_mode ; write to option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
553 option_inc_enum8_3_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
554 return ; done
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
555
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
556 option_inc_enum8_4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
557 IFDEF _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
558 ; now some rather crude hack to advance opt_TR_mode in dependency of opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
559 movlw 0x7E ; serial ID of option opt_TR_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
560 cpfseq opt_serial ; editing opt_TR_mode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
561 bra option_inc_enum8_5 ; NO - check next option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
562 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
563 decfsz WREG,W ; dive mode = 1 CCR?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
564 bra option_inc_enum8_4a ; NO - in any other mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
565 movf INDF1,W ; YES - get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
566 xorlw .2 ; - mode = 2 (ind.double)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
567 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
568 incf INDF1,F ; YES - advance option value to 3 (CCR Dil+O2)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
569 bra option_inc_enum8_4_exit ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
570 option_inc_enum8_4a: ; any mode other than CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
571 movf INDF1,W ; get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
572 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
573 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
574 clrf INDF1 ; YES - advance option value to 0 "off"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
575 option_inc_enum8_4_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
576 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
577 ENDIF ; _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
578
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
579 option_inc_enum8_5:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
580 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
581 ; now some rather crude hack to keep contingency mode switched off if gas needs calculation is switched off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
582 movlw 0x91 ; serial ID of option opt_gas_contingency_dive
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
583 cpfseq opt_serial ; editing opt_gas_contingency_dive right now?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
584 bra option_inc_enum8_6 ; NO - check next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
585 movff opt_calc_gasvolume,WREG ; YES - get current setting of gas needs calculation
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
586 tstfsz WREG ; - gas needs calculation switched off?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
587 return ; NO - done, opt_gas_contingency_dive may be switched on
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
588 clrf INDF1 ; YES - force opt_gas_contingency_dive to off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
589 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
590 ENDIF ; _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
591
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
592 option_inc_enum8_6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
593 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
594
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
595
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
596 option_inc_string: ; no editing available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
597 return
0
heinrichsweikamp
parents:
diff changeset
598
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
599
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
600 IFNDEF _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
601 option_cleanup_gauge:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
602 movff opt_dive_mode,WREG ; get dive mode into WREG (0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
603 xorlw .2 ; in Gauge mode?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
604 bnz option_cleanup_gauge_1 ; NO - done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
605 movff WREG,opt_dive_mode ; YES - setting not allowed, WREG is zero -> reset to OC mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
606 bsf options_changed ; - flag that EEPROM needs to be updated
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
607 option_cleanup_gauge_1:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
608 return ; done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
609 ENDIF
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
610
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
611
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
612 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
613 global option_cleanup_oCCRMode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
614 global option_cleanup_oCCRMode_pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
615 global option_cleanup_oCCRMode_CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
616 option_cleanup_oCCRMode: ; in pSCR mode, revert AutoSP (2) to calculated SP (0), in pSCR and CCR revert Sensor to fixed SP if no sensor interface available
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
617 movff opt_dive_mode,WREG ; get dive mode into WREG (0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
618 xorlw .4 ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
619 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
620 option_cleanup_oCCRMode_pSCR: ; jump-in from start.asm if known to be in pSCR mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
621 banksel opt_ccr_mode ; YES - select options bank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
622 bcf opt_ccr_mode,1 ; - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP, keeps sensor)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
623 banksel common ; - back to bank common
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
624 bsf options_changed ; - flag that EEPROM needs to be updated
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
625 option_cleanup_oCCRMode_CCR: ; continue from above & jump-in from start.asm if known to be in CCR mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
626 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
627 btfsc analog_o2_input ; analog interface available?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
628 return ; YES - setting 'sensor' allowed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
629 btfsc optical_input ; does hosting OSTC have an optical interface?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
630 return ; YES - setting 'sensor' allowed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
631 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
632 movff opt_ccr_mode,WREG ; NO to both - get CCR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
633 xorlw .1 ; - coding for sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
634 tstfsz WREG ; - CCR mode = sensor?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
635 return ; NO - setting allowed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
636 banksel opt_ccr_mode ; YES - setting not allowed, select options bank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
637 clrf opt_ccr_mode ; - revert setting to 0 (fixed or calculated SP)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
638 banksel common ; - back to bank common
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
639 bsf options_changed ; - flag that EEPROM needs to be updated
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
640 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
641 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
642
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
643
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
644 option_cleanup_GF:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
645 ; cleanup normal GF
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
646 movff opt_GF_high,WREG ; copy normal GF high to WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
647 movff opt_GF_low,mpr ; copy normal GF low to mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
648 cpfsgt mpr ; GF low > GF high ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
649 bra option_cleanup_GF_2 ; NO - option ok, check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
650 movwf mpr ; YES - copy GF high to mpr
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
651 movlw .100 ; - load GF low limit of 100% into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
652 cpfsgt mpr ; - mpr > 100 ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
653 bra option_cleanup_GF_1 ; NO - correct GF low to GF high
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
654 movwf mpr ; YES - correct GF low to 100%
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
655 option_cleanup_GF_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
656 movff mpr,opt_GF_low ; store corrected GF low
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
657 bsf options_changed ; flag that EEPROM needs to be updated
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
658 option_cleanup_GF_2:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
659 ; cleanup alternative GF
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
660 movff opt_aGF_high,WREG ; copy alternative GF high to WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
661 movff opt_aGF_low,mpr ; copy alternative GF low to mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
662 cpfsgt mpr ; GF low > GF high ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
663 bra option_cleanup_GF_4 ; NO - option ok, check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
664 movwf mpr ; YES - copy GF high to mpr
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
665 movlw .100 ; - load GF low limit of 100% into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
666 cpfsgt mpr ; - mpr > 100 ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
667 bra option_cleanup_GF_3 ; NO - correct GF low to GF high
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
668 movwf mpr ; YES - correct GF low to 100%
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
669 option_cleanup_GF_3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
670 movff mpr,opt_aGF_low ; store corrected GF low
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
671 bsf options_changed ; flag that EEPROM needs to be updated
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
672 option_cleanup_GF_4:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
673 return ; done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
674
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
675
0
heinrichsweikamp
parents:
diff changeset
676 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
677 ; Strcat option into FSR2 buffer
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
678 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
679 global option_draw ; STRCAT FRS0 option
0
heinrichsweikamp
parents:
diff changeset
680 option_draw:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
681 ; read type, default and register from table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
682 rcall option_read_definition
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
683
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
684 ; switch on type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
685 movf opt_type,W ; get option type
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
686 bz option_draw_uint8 ; type0 = INT8
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
687 dcfsnz WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
688 bra option_draw_enum8 ; type1 = ENUM
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
689 dcfsnz WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
690 bra option_draw_string ; type2 = string
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
691 dcfsnz WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
692 bra option_draw_uint8_depth ; type3 = INT8 with automatic display in meters or feet
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
693 return ; unknown, do nothing
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
694
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
695 option_draw_string:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
696 movff POSTINC1,POSTINC2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
697 decfsz opt_max
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
698 bra option_draw_string
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
699 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
700
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
701 option_draw_uint8_depth:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
702 TSTOSS opt_units ; using metric units (0=m, 1=ft)?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
703 bra option_draw_uint8 ; YES - handle with standard output
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
704 movff INDF1,lo ; NO - imperial, get value to lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
705 call convert_meter_to_feet ; - convert value in lo from meter to feet
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
706 bsf leftbind ; - print with left alignment
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
707 output_16_3 ; - display only last three digits from a 16 bit value (0-999)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
708 bcf leftbind ; - back to normal alignment
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
709 STRCAT_TEXT tFeets ; - print unit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
710 bra option_draw_uint8_common ; - continue with common part
0
heinrichsweikamp
parents:
diff changeset
711
heinrichsweikamp
parents:
diff changeset
712 option_draw_uint8:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
713 movff INDF1,lo ; draw value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
714 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
715 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
716 bcf leftbind
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
717 clrf INDF2 ; make sure to close string
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
718 movf opt_unit+0,W ; is there a unit to append?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
719 iorwf opt_unit+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
720 rcall option_draw_unit ; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
721 option_draw_uint8_common:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
722 movf opt_default,W ; get default value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
723 cpfseq lo ; compare with current value, equal?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
724 bra option_draw_uint8_2 ; NO - not default, add *
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
725 return ; YES - default, done
0
heinrichsweikamp
parents:
diff changeset
726 option_draw_uint8_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
727 PUTC "*" ; print "*"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
728 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
729
0
heinrichsweikamp
parents:
diff changeset
730 option_draw_unit:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
731 movff opt_unit+0,FSR1L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
732 movff opt_unit+1,FSR1H
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
733 goto strcat_text
0
heinrichsweikamp
parents:
diff changeset
734
heinrichsweikamp
parents:
diff changeset
735
heinrichsweikamp
parents:
diff changeset
736 ;---- Draw an enumerated value (set of translated strings)
heinrichsweikamp
parents:
diff changeset
737 option_draw_enum8:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
738 movf INDF1,W ; copy option value to WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
739 movwf lo ; memorize option value, too
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
740 cpfslt opt_max ; option value > maximum permissible value ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
741 bra option_draw_enum8_0 ; NO - option value allowed
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
742 clrf WREG ; YES - to avoid printing rubbish, use first ENUM item instead
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
743 option_draw_enum8_0:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
744 addwf WREG ; current value *= 2
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
745 addwf opt_inc,W ; base text + 2 * current value
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
746 movwf FSR1L ; load FSR1
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
747 movlw .0 ; propagate carry...
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
748 addwfc opt_min,W ; ...
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
749 movwf FSR1H ; ...into FSR1
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
750 call strcat_text ; print text
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
751 movf opt_default,W ; get default value
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
752 cpfseq lo ; compare with memorized current value, equal?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
753 bra option_draw_enum8_1 ; NO - not default, add *
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
754 return ; YES - default, done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
755 option_draw_enum8_1:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
756 PUTC "*" ; print "*"
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
757 return ; done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
758
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
759 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
760
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
761 END