Mercurial > public > hwos_code
annotate src/options.asm @ 605:5ce603c29750
gas color coding fixed
author | heinrichsweikamp |
---|---|
date | Sun, 25 Nov 2018 13:21:52 +0100 |
parents | ca4556fb60b9 |
children | d866684249bd |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
604 | 3 ; File options.asm REFACTORED VERSION V2.99e |
0 | 4 ; |
5 ; Manage all options data. | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-07-12 : [jDG] Creation. | |
11 ; | |
12 | |
604 | 13 #include "hwos.inc" ; mandatory header |
582 | 14 #include "strings.inc" |
15 #include "convert.inc" | |
16 #include "ghostwriter.inc" | |
17 #include "eeprom_rs232.inc" | |
18 #include "external_flash.inc" | |
19 #include "wait.inc" | |
604 | 20 #include "shared_definitions.h" |
0 | 21 |
582 | 22 extern write_eeprom |
23 extern read_eeprom | |
24 extern eeprom_serial_save,eeprom_opt_backup | |
25 extern option_table_begin,option_table_end | |
0 | 26 |
604 | 27 options CODE |
582 | 28 |
0 | 29 ;============================================================================= |
604 | 30 ; Reset all options to factory defaults |
0 | 31 ; |
32 ; INPUT: none | |
33 ; OUTPUT: none | |
34 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | |
604 | 35 ; |
36 global option_reset_all ; reset all options to factory default | |
0 | 37 option_reset_all: |
582 | 38 clrf EEADRH |
39 read_int_eeprom .2 | |
604 | 40 tstfsz EEDATA ; number of total dives = 0 ? |
41 bra option_reset_all2 ; NO - skip resetting logbook | |
582 | 42 read_int_eeprom .3 |
604 | 43 tstfsz EEDATA ; number of total dives = 0 ? |
44 bra option_reset_all2 ; NO - skip resetting logbook | |
0 | 45 |
582 | 46 clrf EEDATA |
47 write_int_eeprom .4 | |
48 write_int_eeprom .5 | |
49 write_int_eeprom .6 | |
604 | 50 write_int_eeprom .2 ; delete total dive counter, too |
582 | 51 write_int_eeprom .3 |
604 | 52 call ext_flash_erase_logbook ; complete logbook |
0 | 53 |
54 option_reset_all2: | |
582 | 55 clrf lo |
56 clrf hi | |
604 | 57 call do_logoffset_common_write ; reset logbook offset |
58 movlw LOW(option_table_begin) ; point to option table begin | |
582 | 59 movwf FSR0L |
60 movlw HIGH(option_table_begin) | |
61 movwf FSR0H | |
0 | 62 option_reset_all_1: |
604 | 63 movlw LOW(option_table_end) ; get low byte of end of table address |
64 cpfseq FSR0L ; does it equal the current pointer position? | |
65 bra option_reset_all_2 ; NO - more options to process | |
66 movlw HIGH(option_table_end) ; get high byte of end of table address | |
67 cpfseq FSR0H ; does it equal the current pointer position? | |
68 bra option_reset_all_2 ; NO - more options to process | |
69 return ; YES to both - end of option table reached, done | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
70 option_reset_all_2: |
604 | 71 rcall option_reset ; reset one option... |
72 bra option_reset_all_1 ; ... and loop | |
0 | 73 |
74 ;============================================================================= | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
75 ; Check all option and reset option if out of min/max boundary |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
76 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
77 ; INPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
78 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
79 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 |
604 | 80 ; |
81 global option_check_all ; check all option and reset option if out of min/max boundary | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
82 option_check_all: |
604 | 83 movlw LOW(option_table_begin) ; point to option table begin |
582 | 84 movwf FSR0L |
85 movlw HIGH(option_table_begin) | |
86 movwf FSR0H | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
87 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
88 option_check_all_1: |
604 | 89 movlw LOW(option_table_end) ; get low byte of end of table address |
90 cpfseq FSR0L ; does it equal the current pointer position? | |
91 bra option_check_all_2 ; NO - more options to process | |
92 movlw HIGH(option_table_end) ; get high byte of end of table address | |
93 cpfseq FSR0H ; does it equal the current pointer position? | |
94 bra option_check_all_2 ; NO - more options to process | |
95 return ; YES to both - end of option table reached, done | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
96 option_check_all_2: |
604 | 97 rcall option_check ; check one option... |
98 bra option_check_all_1 ; ... and loop | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
99 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
100 ;============================================================================= |
0 | 101 ; Read option handle |
102 ; INPUT: FSR0 = option handle | |
103 ; OUTPUT: FSR1 = address of variable. | |
104 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
604 | 105 ; |
0 | 106 option_read: |
582 | 107 movff FSR0L,TBLPTRL |
604 | 108 movlw HIGH(option_table_begin) ; get 8 high bits. |
109 andlw 0xF0 ; keep only the 4 highest ones | |
110 iorwf FSR0H,W ; cat with the known 4 lower ones | |
111 movwf TBLPTRH ; we have the high byte | |
582 | 112 movlw UPPER(option_table_begin) |
113 movwf TBLPTRU | |
0 | 114 |
582 | 115 ; Read type, default and register from table |
116 tblrd*+ | |
117 movff TABLAT,opt_type | |
118 tblrd*+ | |
119 movff TABLAT,opt_default | |
120 tblrd*+ | |
121 movff TABLAT,opt_inc | |
122 tblrd*+ | |
123 movff TABLAT,opt_min | |
124 tblrd*+ | |
125 movff TABLAT,opt_max | |
126 tblrd*+ | |
127 movff TABLAT,opt_eeprom | |
128 tblrd*+ | |
129 movff TABLAT,opt_unit+0 | |
130 tblrd*+ | |
131 movff TABLAT,opt_unit+1 | |
132 tblrd*+ | |
133 movff TABLAT,FSR1L | |
134 tblrd*+ | |
135 movff TABLAT,FSR1H | |
604 | 136 movff TBLPTRL,FSR0L ; advance handle, too, for reset_all |
582 | 137 movff TBLPTRH,FSR0H |
138 return | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
139 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
140 ;============================================================================= |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
141 ; Check one option and reset if it's out of it's min/max boundaries |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
142 ; INPUT: FSR0 = option handle |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
143 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
144 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2, lo |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
145 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
146 option_check: |
582 | 147 ; Read type, default and register from table |
148 rcall option_read | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
149 |
582 | 150 ; Switch on type |
604 | 151 movf opt_type,W ; get option type |
152 xorlw 2 ; type == STRING ? | |
153 bz option_check_string ; YES | |
154 movf opt_type,W ; get option type (again) | |
155 xorlw 1 ; type == ENUM8 ? | |
156 bz option_check_enum8 ; YES - check if lower then max. value only | |
157 ; NO to all - must be integer then | |
158 tstfsz opt_min ; opt_min = 0 ? | |
159 bra option_check_both ; NO - check it | |
160 bra option_check_enum8 ; check max only | |
220
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
161 |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
162 option_check_both: |
604 | 163 decf opt_min,W ; check against minimum value |
164 cpfsgt INDF1 ; bigger then opt_min - 1 ? | |
165 bra option_check_reset ; NO - reset option | |
166 option_check_enum8: ; check against maximum value | |
167 infsnz opt_max,W ; max = 255? | |
168 return ; YES - ignore the max. test | |
169 cpfslt INDF1 ; NO - smaller then opt_max + 1 ? | |
170 bra option_check_reset ; NO - reset option | |
171 return ; YES - in range, return | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
172 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
173 option_check_reset: |
582 | 174 movff opt_default,INDF1 ; reset option to default |
604 | 175 return ; done |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
176 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
177 option_check_string: |
582 | 178 return |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
179 |
0 | 180 ;============================================================================= |
604 | 181 ; Reset an option to its default value |
0 | 182 ; INPUT: FSR0 = option handle |
183 ; OUTPUT: none | |
184 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | |
185 ; | |
604 | 186 global option_reset ; reset FSR0 option to factory default |
0 | 187 option_reset: |
582 | 188 ; Read type, default and register from table |
604 | 189 rcall option_read ; read option data |
190 movf opt_type,W ; get option type | |
191 xorlw 2 ; Type == STRING ? | |
192 bz opt_reset_string ; YES - special copy | |
193 movff opt_default,INDF1 ; NO - just a 8 bit indirect copy | |
582 | 194 return |
0 | 195 opt_reset_string: |
604 | 196 movff FSR1L,FSR2L ; set string destination address |
197 movff FSR1H,FSR2H ; ... | |
198 movff opt_default+0,FSR1L ; get handle to multi-lingual text in FSR1 | |
199 movff opt_default+1,FSR1H ; ... | |
582 | 200 movff TBLPTRL,opt_backup_tbl+0 ; TBLPTR trashed by text routine... |
604 | 201 movff TBLPTRH,opt_backup_tbl+1 ; ... |
202 movff TBLPTRU,opt_backup_tbl+2 ; ... | |
203 call strcat_text ; copy translated text to FSR2 | |
204 movff opt_backup_tbl+0,TBLPTRL ; restore TBLPTR | |
205 movff opt_backup_tbl+1,TBLPTRH ; ... | |
206 movff opt_backup_tbl+2,TBLPTRU ; ... | |
0 | 207 |
582 | 208 return |
0 | 209 |
210 ;============================================================================= | |
211 ; Save all options to EEPROM | |
604 | 212 ; |
213 global option_save_all ; save options to EEPROM | |
0 | 214 option_save_all: |
582 | 215 ;---- Save option serial into EEPROM to detect reset and new version |
216 movlw LOW(eeprom_serial_save) | |
217 movwf EEADR | |
218 movlw HIGH(eeprom_serial_save) | |
219 movwf EEADRH | |
220 movlw LOW(eeprom_opt_serial) | |
221 movwf EEDATA | |
222 call write_eeprom | |
223 incf EEADR,F | |
224 movlw HIGH(eeprom_opt_serial) | |
225 movwf EEDATA | |
226 call write_eeprom | |
227 | |
228 ;---- Save all options | |
229 movlw LOW(option_table_begin) | |
230 movwf FSR0L | |
231 movlw HIGH(option_table_begin) | |
232 movwf FSR0H | |
0 | 233 |
234 option_save_all_1: | |
582 | 235 movlw LOW(option_table_end) |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
236 cpfseq FSR0L |
604 | 237 bra option_save_all_2 ; not yet done... |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
238 movlw HIGH(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
239 cpfseq FSR0H |
604 | 240 bra option_save_all_2 ; not yet done... |
241 return ; all done | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
242 option_save_all_2: |
604 | 243 rcall option_save ; save one option... |
244 bra option_save_all_1 ; ...and loop | |
245 | |
0 | 246 |
582 | 247 global option_save |
0 | 248 option_save: |
582 | 249 rcall option_read |
604 | 250 incf opt_eeprom,W ; should we save it ? |
582 | 251 btfsc STATUS,Z ; EEPROM address is FFh ? |
604 | 252 return ; YES - nothing to do |
253 movf opt_eeprom,W ; compute backup address in EEPROM | |
254 addlw LOW(eeprom_opt_backup) ; add offset | |
582 | 255 movwf EEADR |
256 movlw HIGH(eeprom_opt_backup) | |
604 | 257 btfsc STATUS,C ; > 256 ? |
258 addlw .1 ; YES - +1 | |
582 | 259 movwf EEADRH |
604 | 260 movf opt_type,W ; get option type |
261 xorlw 2 ; option type is string ? | |
262 bz option_save_string ; YES | |
263 movff INDF1,EEDATA ; one byte to be saved to EEPROM | |
264 btfss EEADRH,1 ; EEADR:EEADRH < 512 ? | |
265 call write_eeprom ; YES - write | |
266 return | |
267 option_save_string: | |
268 movff POSTINC1,EEDATA ; write one byte | |
269 btfss EEADRH,1 ; EEADR:EEADRH < 512 ? | |
270 call write_eeprom ; Yes - write | |
271 infsnz EEADR,F | |
272 incf EEADRH,F | |
273 decfsz opt_max ; decrement string length | |
274 bra option_save_string ; loop while not finished | |
582 | 275 return |
276 | |
0 | 277 ;============================================================================= |
278 | |
604 | 279 global option_restore_all ; restore options from EEPROM |
0 | 280 option_restore_all: |
582 | 281 ;---- Read option serial from EEPROM |
282 movlw LOW(eeprom_serial_save) | |
283 movwf EEADR | |
284 movlw HIGH(eeprom_serial_save) | |
285 movf EEADRH | |
286 call read_eeprom | |
287 movlw LOW(eeprom_opt_serial) | |
288 xorwf EEDATA,W | |
604 | 289 bnz option_restore_bad ; auto reset if changed |
582 | 290 incf EEADR,F |
291 call read_eeprom | |
292 movlw HIGH(eeprom_opt_serial) | |
293 xorwf EEDATA,W | |
604 | 294 bz option_restore_ok ; auto reset if changed |
0 | 295 |
296 option_restore_bad: | |
604 | 297 call option_reset_all ; reset RAM contains |
298 goto option_save_all ; then save to EEPROM | |
0 | 299 |
582 | 300 ;---- Proper restore |
0 | 301 option_restore_ok: |
582 | 302 movlw LOW(option_table_begin) |
303 movwf FSR0L | |
304 movlw HIGH(option_table_begin) | |
305 movwf FSR0H | |
0 | 306 |
307 option_restore_all_1: | |
582 | 308 movlw LOW(option_table_end) |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
309 cpfseq FSR0L |
604 | 310 bra option_restore_all_2 ; not yet done... |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
311 movlw HIGH(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
312 cpfseq FSR0H |
604 | 313 bra option_restore_all_2 ; not yet done... |
314 return ; all done | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
315 option_restore_all_2: |
604 | 316 rcall option_restore ; Restore one option |
317 bra option_restore_all_1 ; and loop | |
0 | 318 |
319 option_restore: | |
582 | 320 rcall option_read |
604 | 321 incf opt_eeprom,W ; shall we save it ? |
582 | 322 btfsc STATUS,Z ; EEPROM address is FFh ? |
604 | 323 return ; YES - nothing to do. |
324 movf opt_eeprom,W ; compute backup address in EEPROM | |
325 addlw LOW(eeprom_opt_backup) ; add offset | |
582 | 326 movwf EEADR |
327 movlw HIGH(eeprom_opt_backup) | |
604 | 328 btfsc STATUS,C ; > 256 ? |
329 addlw .1 ; YES - +1 | |
582 | 330 movwf EEADRH |
604 | 331 movf opt_type,W ; get option type |
332 xorlw 2 ; Option type is string? | |
333 bz option_restore_string ; YES | |
334 call read_eeprom ; read one byte from EEPROM | |
335 movff EEDATA, INDF1 ; restore option register | |
582 | 336 return |
0 | 337 option_restore_string: |
604 | 338 call read_eeprom ; read one byte, and... |
339 movff EEDATA,POSTINC1 ; ... restore it | |
582 | 340 infsnz EEADR,F |
341 incf EEADRH,F | |
604 | 342 decfsz opt_max ; decrement string length |
343 bra option_restore_string ; loop while not finished | |
582 | 344 return |
0 | 345 |
346 ;============================================================================= | |
604 | 347 ; Increment an option, based on type, and boundary |
0 | 348 ; INPUT: FSR0 = option handle |
349 ; OUTPUT: none | |
350 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
604 | 351 ; |
352 global option_inc ; increment FSR0 option | |
0 | 353 option_inc: |
604 | 354 ; read type, default and register from table |
582 | 355 rcall option_read |
356 | |
604 | 357 ; switch on type |
582 | 358 movf opt_type,W |
359 bz option_inc_uint8 | |
360 dcfsnz WREG | |
361 bra option_inc_enum8 | |
362 dcfsnz WREG | |
363 bra option_inc_string | |
0 | 364 |
604 | 365 option_inc_uint8: ; default type too... |
582 | 366 movf INDF1,W |
367 addwf opt_inc,W | |
368 cpfslt opt_max | |
604 | 369 bra option_inc_uint8_0 |
582 | 370 movf opt_min,W |
604 | 371 option_inc_uint8_0: |
582 | 372 movwf INDF1 |
604 | 373 option_inc_uint8_1: |
533
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
374 ; Now some rather crude hack into this routine to make CCR Calibration more convenient: |
582 | 375 movlw .149 ; EEPROM address of option CalGasO2 |
604 | 376 cpfseq opt_eeprom ; editing CalGasO2 right now? |
377 return ; NO - done (or bra option_inc_uint8_2) | |
378 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR | |
379 decfsz WREG,W ; - in CCR mode? | |
380 return ; NO - done | |
381 movlw .26 ; YES - | |
382 cpfseq INDF1 ; - option value = 26 ? | |
383 return ; NO - done | |
384 movlw .95 ; YES - advance it to 95 | |
385 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
|
386 return |
0 | 387 |
604 | 388 option_inc_enum8: ; always +1 |
582 | 389 incf INDF1,W |
390 cpfsgt opt_max | |
391 clrf WREG | |
392 movwf INDF1 | |
604 | 393 option_inc_enum8_1: |
394 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting | |
395 movlw .25 ; EEPROM address of option oCCRMode | |
396 cpfseq opt_eeprom ; editing oCCRMode right now? | |
397 bra option_inc_enum8_2 ; NO - check next option | |
398 btfsc analog_o2_input ; YES - does hosting OSTC have an analog interface? | |
399 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed | |
400 btfsc optical_input ; does hosting OSTC have an optical interface? | |
401 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed | |
402 movf INDF1,W ; NO to both - get mode (=0: fixed SP, =1: Sensor, =2: AutoSP) | |
403 xorlw .1 ; - in sensor mode? | |
404 bnz option_inc_enum8_1a ; NO - continue with next check | |
405 incf INDF1,F ; YES - advance option value to AutoSP | |
406 option_inc_enum8_1a: | |
407 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR | |
408 xorlw .4 ; in pSCR mode? | |
409 bnz option_inc_enum8_1_exit ; NO - done | |
410 bcf INDF1,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP) | |
411 option_inc_enum8_1_exit: | |
412 return ; done | |
413 option_inc_enum8_2: | |
414 ; (unused) | |
415 option_inc_enum8_3: | |
416 | |
417 IFDEF _rx_functions | |
418 global option_cleanup_oTrMode_CCR ; embedded clean-up entry-point | |
419 global option_cleanup_oTrMode_no_CCR ; embedded clean-up entry-point | |
420 ; Now some rather crude hack to correct opt_TR_mode in dependency of opt_dive_mode | |
421 movlw .8 ; EEPROM address of option opt_dive_mode | |
422 cpfseq opt_eeprom ; editing opt_dive_mode right now? | |
423 bra option_inc_enum8_4 ; NO - check next option | |
424 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR | |
425 decfsz WREG,W ; dive mode = 1 CCR? | |
426 bra option_inc_enum8_3a ; NO - in any other mode | |
427 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart | |
428 movff opt_TR_mode,WREG ; YES - get TR mode | |
429 xorlw .2 ; - mode = 2 (ind.double)? | |
430 bnz option_inc_enum8_3_exit ; NO - done | |
431 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on) | |
432 option_inc_enum8_3a: ; any mode other than CCR | |
433 option_cleanup_oTrMode_no_CCR: ; entry point from cleanup during restart | |
434 movff opt_TR_mode,WREG ; get TR mode | |
435 xorlw .3 ; mode = 3 (CCR Dil+O2)? | |
436 bnz option_inc_enum8_3_exit ; NO - done | |
437 option_inc_enum8_3_reset: ; YES - revert to mode 1 (on) | |
438 movlw .1 ; load coding of mode "on" | |
439 movff WREG,opt_TR_mode ; write to option | |
440 option_inc_enum8_3_exit: | |
441 return ; done | |
442 option_inc_enum8_4: | |
443 ; Now some rather crude hack to advance opt_TR_mode in dependency of opt_dive_mode | |
444 movlw .222 ; EEPROM address of option opt_TR_mode | |
445 cpfseq opt_eeprom ; editing opt_TR_mode right now? | |
446 bra option_inc_enum8_5 ; NO - check next option | |
447 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR | |
448 decfsz WREG,W ; dive mode = 1 CCR? | |
449 bra option_inc_enum8_4a ; NO - in any other mode | |
450 movf INDF1,W ; YES - get option value (TR mode) | |
451 xorlw .2 ; - mode = 2 (ind.double)? | |
452 bnz option_inc_enum8_4_exit ; NO - done | |
453 incf INDF1,F ; YES - advance option value to 3 (CCR Dil+O2) | |
454 bra option_inc_enum8_4_exit ; - done | |
455 option_inc_enum8_4a: ; any mode other than CCR | |
456 movf INDF1,W ; get option value (TR mode) | |
457 xorlw .3 ; mode = 3 (CCR Dil+O2)? | |
458 bnz option_inc_enum8_4_exit ; NO - done | |
459 clrf INDF1 ; YES - advance option value to 0 "off" | |
460 option_inc_enum8_4_exit: | |
461 return ; done | |
462 ENDIF | |
463 | |
464 option_inc_enum8_5: | |
582 | 465 return |
466 | |
467 | |
604 | 468 option_inc_string: ; no editing available |
582 | 469 return |
0 | 470 |
604 | 471 |
472 global option_cleanup_oCCRMode | |
473 global option_cleanup_oCCRMode_pSCR | |
474 global option_cleanup_oCCRMode_CCR | |
475 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 | |
476 banksel opt_dive_mode ; select options bank | |
477 movf opt_dive_mode,W ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR | |
478 xorlw .4 ; in pSCR mode? | |
479 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC | |
480 option_cleanup_oCCRMode_pSCR: ; jump-in from start.asm if known to be in pSCR mode | |
481 banksel opt_ccr_mode ; select options bank | |
482 bcf opt_ccr_mode,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP) | |
483 option_cleanup_oCCRMode_CCR: ; continue from above & jump-in from start.asm if known to be in CCR mode | |
484 banksel common ; flags are located in bank common | |
485 btfsc analog_o2_input ; does hosting OSTC have an analog interface? | |
486 bra option_cleanup_oCCRMode_exit ; YES - setting 'sensor' allowed | |
487 btfsc optical_input ; does hosting OSTC have an optical interface? | |
488 bra option_cleanup_oCCRMode_exit ; YES - setting 'sensor' allowed | |
489 banksel opt_ccr_mode ; NO to both - select options bank | |
490 movf opt_ccr_mode,W ; - get CCR mode | |
491 xorlw .1 ; - CCR mode = sensor? | |
492 bnz option_cleanup_oCCRMode_exit ; NO - ok | |
493 clrf opt_ccr_mode ; - YES - set CCR mode to fixed SP (0) | |
494 option_cleanup_oCCRMode_exit: | |
495 banksel common ; back to bank common | |
496 return ; done | |
497 | |
498 | |
0 | 499 ;============================================================================= |
604 | 500 ; Strcat option into FSR2 buffer |
501 ; | |
502 global option_draw ; STRCAT FRS0 option | |
0 | 503 option_draw: |
582 | 504 ; Read type, default and register from table |
505 rcall option_read | |
506 | |
507 ; Switch on type | |
508 movf opt_type,W | |
509 bz option_draw_uint8 | |
510 dcfsnz WREG | |
511 bra option_draw_enum8 | |
512 dcfsnz WREG | |
513 bra option_draw_string | |
604 | 514 return ; unknown, return |
515 option_draw_string: | |
516 movff POSTINC1,POSTINC2 | |
517 decfsz opt_max | |
518 bra option_draw_string | |
519 return | |
520 | |
0 | 521 |
522 option_draw_uint8: | |
604 | 523 movff INDF1,lo ; draw value |
582 | 524 bsf leftbind |
525 output_8 | |
526 bcf leftbind | |
604 | 527 clrf INDF2 ; make sure to close string |
528 movf opt_unit+0,W ; is there a unit to append? | |
582 | 529 iorwf opt_unit+1,W |
604 | 530 rcall option_draw_unit ; YES |
531 movf opt_default,W ; get default value | |
532 cpfseq lo ; compare with current value, equal? | |
533 bra option_draw_uint8_2 ; NO - not default, add * | |
534 return ; YES - default, done | |
0 | 535 option_draw_uint8_2: |
604 | 536 PUTC "*" ; print "*" |
537 return ; done | |
0 | 538 option_draw_unit: |
582 | 539 movff opt_unit+0,FSR1L |
540 movff opt_unit+1,FSR1H | |
541 goto strcat_text | |
0 | 542 |
543 | |
544 ;---- Draw an enumerated value (set of translated strings) | |
545 option_draw_enum8: | |
604 | 546 movf INDF1,W ; get current value |
547 cpfsgt opt_max ; bound value | |
582 | 548 clrf WREG |
549 addwf WREG ; *= 2 | |
604 | 550 addwf opt_inc,W ; base text + 2 * value |
582 | 551 movwf FSR1L |
552 movlw .0 | |
604 | 553 addwfc opt_min,W ; propagate carry... |
554 movwf FSR1H ; ...into FSR1 | |
582 | 555 goto strcat_text |
0 | 556 |
557 | |
582 | 558 END |