Mercurial > public > hwos_code
annotate src/options.asm @ 142:8531f39eb70a
option_read and option_write eeprom banking
author | mh@mh-THINK |
---|---|
date | Thu, 31 Jul 2014 16:36:15 +0200 |
parents | e0b758865e91 |
children | be997abd1f73 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File options.asm | |
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 ; RATIONALS: | |
13 ; | |
14 ; Provides a centralized file with | |
15 | |
16 #include "ostc3.inc" ; Mandatory header | |
17 #include "strings.inc" | |
18 #include "convert.inc" | |
19 #include "ghostwriter.inc" | |
20 #include "eeprom_rs232.inc" | |
21 #include "external_flash.inc" | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
22 #include "wait.inc" |
0 | 23 |
24 extern write_eeprom | |
25 extern read_eeprom | |
26 extern eeprom_serial_save,eeprom_opt_backup | |
27 | |
28 global option_reset_all ; Reset all options to factory default. | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
29 global option_check_all ; Check all option and reset option if out of min/max boundary |
0 | 30 global option_reset ; Reset FSR0 option to factory default. |
31 global option_save_all ; Save options to EEPROM. | |
32 global option_restore_all ; Restore options from EEPROM. | |
33 global option_inc ; Increment FSR0 option. | |
34 global option_draw ; STRCAT FRS0 option. | |
35 | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
36 |
0 | 37 ;============================================================================= |
38 CBLOCK tmp+0x10 ; Reserve space for wordprocessor & convert | |
39 opt_type | |
40 opt_default | |
41 opt_inc ; Also default+1 (string), and enum low | |
42 opt_min ; also enum high | |
43 opt_max | |
44 opt_unit:2 ; Multi-lingual unit text. | |
45 opt_eeprom | |
46 opt_backup_tbl:3 | |
47 ; Reserved to tmp+0x1F... | |
48 ENDC | |
49 | |
50 gui CODE ; Appends to other GUI segment | |
51 ;============================================================================= | |
52 ; Reset all options to factory defauts. | |
53 ; | |
54 ; INPUT: none | |
55 ; OUTPUT: none | |
56 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | |
57 | |
58 option_reset_all: | |
59 clrf EEADRH | |
60 read_int_eeprom .2 | |
139 | 61 tstfsz EEDATA ; Total dives=0? |
62 bra option_reset_all2 ; No, skip resetting logbook | |
0 | 63 read_int_eeprom .3 |
139 | 64 tstfsz EEDATA ; Total dives=0? |
0 | 65 bra option_reset_all2 ; No, skip resetting logbook |
66 | |
67 clrf EEDATA | |
68 write_int_eeprom .4 | |
69 write_int_eeprom .5 | |
70 write_int_eeprom .6 | |
71 write_int_eeprom .2 ; Also, delete total dive counter | |
72 write_int_eeprom .3 | |
73 call ext_flash_erase_logbook ; And complete logbook (!) | |
74 | |
75 option_reset_all2: | |
76 clrf lo | |
77 clrf hi | |
78 call do_logoffset_common_write ; reset Logbook offset | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
79 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
80 ; Point to option table begin |
0 | 81 movlw LOW(option_table_begin) |
82 movwf FSR0L | |
83 movlw HIGH(option_table_begin) | |
84 movwf FSR0H | |
85 option_reset_all_1: | |
86 movf FSR0L,W ; Reached end of table ? | |
87 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
88 btfsc STATUS,Z ; YES: done. | |
89 return | |
90 | |
91 rcall option_reset ; Reset one option. | |
92 bra option_reset_all_1 ; and loop. | |
93 | |
94 ;============================================================================= | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
95 ; 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
|
96 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
97 ; INPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
98 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
99 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
100 option_check_all: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
101 ; Point to option table begin |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
102 movlw LOW(option_table_begin) |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
103 movwf FSR0L |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
104 movlw HIGH(option_table_begin) |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
105 movwf FSR0H |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
106 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
107 option_check_all_1: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
108 movf FSR0L,W ; Reached end of table ? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
109 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
110 btfsc STATUS,Z ; YES: done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
111 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
112 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
113 rcall option_check ; check one option. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
114 bra option_check_all_1 ; and loop |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
115 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
116 ;============================================================================= |
0 | 117 ; Read option handle |
118 ; INPUT: FSR0 = option handle | |
119 ; OUTPUT: FSR1 = address of variable. | |
120 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
121 option_read: | |
122 movff FSR0L,TBLPTRL | |
123 movlw HIGH(option_table_begin); Get 8 high bits. | |
124 andlw 0xF0 ; Keep only the 4 highest ones. | |
125 iorwf FSR0H,W ; Cat with the known 4 lower ones. | |
126 movwf TBLPTRH ; And we have the high byte. | |
127 movlw UPPER(option_table_begin) | |
128 movwf TBLPTRU | |
129 | |
130 ; Read type, default and register from table | |
131 tblrd*+ | |
132 movff TABLAT,opt_type | |
133 tblrd*+ | |
134 movff TABLAT,opt_default | |
135 tblrd*+ | |
136 movff TABLAT,opt_inc | |
137 tblrd*+ | |
138 movff TABLAT,opt_min | |
139 tblrd*+ | |
140 movff TABLAT,opt_max | |
141 tblrd*+ | |
142 movff TABLAT,opt_eeprom | |
143 tblrd*+ | |
144 movff TABLAT,opt_unit+0 | |
145 tblrd*+ | |
146 movff TABLAT,opt_unit+1 | |
147 tblrd*+ | |
148 movff TABLAT,FSR1L | |
149 tblrd*+ | |
150 movff TABLAT,FSR1H | |
151 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all | |
152 movff TBLPTRH,FSR0H | |
153 return | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
154 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
155 ;============================================================================= |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
156 ; 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
|
157 ; INPUT: FSR0 = option handle |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
158 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
159 ; 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
|
160 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
161 option_check: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
162 ; Read type, default and register from table |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
163 rcall option_read |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
164 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
165 ; Switch on type |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
166 movf opt_type,W ; Type == STRING ? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
167 xorlw 2 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
168 bz option_check_string ; String: Do not reset strings |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
169 |
110 | 170 movf opt_type,W ; Type == ENUM8 ? |
171 xorlw 1 | |
172 bz option_check_enum8 ; ENUM8: Check if lower then max. value only | |
173 | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
174 movf opt_min,W |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
175 cpfsgt INDF1 ; bigger then opt_min? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
176 bra option_check_reset ; No, reset option |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
177 movf INDF1,W |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
178 cpfsgt opt_max ; bigger then INDF1? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
179 bra option_check_reset ; No, reset option |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
180 return ; in range, return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
181 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
182 option_check_reset: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
183 movff opt_default,INDF1 ; reset option to default |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
184 return ; Done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
185 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
186 option_check_string: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
187 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
188 |
110 | 189 option_check_enum8: |
190 movf INDF1,W | |
191 cpfsgt opt_max ; bigger then INDF1? | |
192 bra option_check_reset ; No, reset option | |
193 return ; in range, return | |
194 | |
0 | 195 ;============================================================================= |
196 ; Reset an option to its default value. | |
197 ; INPUT: FSR0 = option handle | |
198 ; OUTPUT: none | |
199 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | |
200 ; | |
201 option_reset: | |
202 ; Read type, default and register from table | |
203 rcall option_read | |
204 | |
205 ; Switch on type | |
206 movf opt_type,W ; Type == STRING ? | |
207 xorlw 2 | |
208 bz opt_reset_string ; YES: special copy | |
209 | |
210 movff opt_default,INDF1 ; NO: just a 8bit indirect copy | |
211 return | |
212 | |
213 opt_reset_string: | |
214 movff FSR1L,FSR2L ; set string destination address. | |
215 movff FSR1H,FSR2H | |
216 | |
217 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1 | |
218 movff opt_default+1,FSR1H | |
219 | |
220 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine... | |
221 movff TBLPTRH,opt_backup_tbl+1 | |
222 movff TBLPTRU,opt_backup_tbl+2 | |
223 | |
224 call strcat_text ; Copy translated text to FSR2 | |
225 | |
226 movff opt_backup_tbl+0,TBLPTRL | |
227 movff opt_backup_tbl+1,TBLPTRH | |
228 movff opt_backup_tbl+2,TBLPTRU | |
229 | |
230 return | |
231 | |
232 ;============================================================================= | |
233 ; Save all options to EEPROM | |
234 option_save_all: | |
235 ;---- Save option serial into EEPROM to detect reset and new version | |
236 movlw LOW(eeprom_serial_save) | |
237 movwf EEADR | |
238 movlw HIGH(eeprom_serial_save) | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
239 movwf EEADRH |
0 | 240 movlw LOW(eeprom_opt_serial) |
241 movwf EEDATA | |
242 call write_eeprom | |
243 incf EEADR,F | |
244 movlw HIGH(eeprom_opt_serial) | |
245 movwf EEDATA | |
246 call write_eeprom | |
247 | |
248 ;---- Save all options | |
249 movlw LOW(option_table_begin) | |
250 movwf FSR0L | |
251 movlw HIGH(option_table_begin) | |
252 movwf FSR0H | |
253 | |
254 option_save_all_1: | |
255 movf FSR0L,W ; Reached end of table ? | |
256 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
257 btfsc STATUS,Z ; YES: done. | |
258 return | |
259 | |
260 rcall option_save ; Save one option. | |
261 bra option_save_all_1 ; and loop. | |
262 | |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
92
diff
changeset
|
263 global option_save |
0 | 264 option_save: |
265 rcall option_read | |
266 incf opt_eeprom,W ; Should we save it ? | |
267 btfsc STATUS,Z ; eeprom address is FFh ? | |
268 return ; YES: nothing to do. | |
269 | |
270 movf opt_eeprom,W ; Compute backup address in EEPROM | |
271 addlw LOW(eeprom_opt_backup) ; Add offset | |
272 movwf EEADR | |
273 movlw HIGH(eeprom_opt_backup) | |
142 | 274 btfsc STATUS,C ; >256 |
275 addlw .1 ; Yes: +1 | |
0 | 276 movwf EEADRH |
277 | |
278 movf opt_type,W ; Option type is string ? | |
279 xorlw 2 | |
280 bz option_save_string | |
281 | |
282 ; One byte to save to eeprom | |
283 movff INDF1,EEDATA | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
284 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
285 call write_eeprom ; Yes, write |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
286 return |
0 | 287 |
288 option_save_string: | |
289 movff POSTINC1,EEDATA ; Write one byte | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
290 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
291 call write_eeprom ; Yes, write |
0 | 292 infsnz EEADR,F |
293 incf EEADRH,F | |
294 | |
295 decfsz opt_max ; Decrement string length | |
296 bra option_save_string ; And loop while not finished | |
297 | |
298 return | |
299 ;============================================================================= | |
300 | |
301 option_restore_all: | |
302 ;---- Read option serial from EEPROM | |
303 movlw LOW(eeprom_serial_save) | |
304 movwf EEADR | |
305 movlw HIGH(eeprom_serial_save) | |
306 movf EEADRH | |
307 call read_eeprom | |
308 movlw LOW(eeprom_opt_serial) | |
309 xorwf EEDATA,W | |
310 bnz option_restore_bad ; Auto reset if changed. | |
311 incf EEADR,F | |
312 call read_eeprom | |
313 movlw HIGH(eeprom_opt_serial) | |
314 xorwf EEDATA,W | |
315 bz option_restore_ok ; Auto reset if changed. | |
316 | |
317 option_restore_bad: | |
318 call option_reset_all ; Reset RAM contains | |
319 goto option_save_all ; Then save to EEPROM | |
320 | |
321 ;---- Proper restore | |
322 option_restore_ok: | |
323 movlw LOW(option_table_begin) | |
324 movwf FSR0L | |
325 movlw HIGH(option_table_begin) | |
326 movwf FSR0H | |
327 | |
328 option_restore_all_1: | |
329 movf FSR0L,W ; Reached end of table ? | |
330 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
331 btfsc STATUS,Z ; YES: done. | |
332 return | |
333 | |
334 rcall option_restore ; Restore one option. | |
335 bra option_restore_all_1 ; and loop. | |
336 return | |
337 | |
338 option_restore: | |
339 rcall option_read | |
340 incf opt_eeprom,W ; Should we save it ? | |
341 btfsc STATUS,Z ; eeprom address is FFh ? | |
342 return ; YES: nothing to do. | |
343 | |
344 movf opt_eeprom,W ; Compute backup address in EEPROM | |
345 addlw LOW(eeprom_opt_backup) ; Add offset | |
346 movwf EEADR | |
347 movlw HIGH(eeprom_opt_backup) | |
142 | 348 btfsc STATUS,C ; >256 |
349 addlw .1 ; Yes: +1 | |
0 | 350 movwf EEADRH |
351 | |
352 movf opt_type,W ; Option type is string ? | |
353 xorlw 2 | |
354 bz option_restore_string | |
355 | |
356 ; Read one byte from eeprom | |
357 call read_eeprom | |
358 movff EEDATA, INDF1 ; And restore option register. | |
359 return | |
360 | |
361 option_restore_string: | |
362 call read_eeprom ; Read one byte, and | |
363 movff EEDATA,POSTINC1 ; restore it | |
364 infsnz EEADR,F | |
365 incf EEADRH,F | |
366 | |
367 decfsz opt_max ; Decrement string length | |
368 bra option_restore_string ; And loop while not finished | |
369 return | |
370 | |
371 ;============================================================================= | |
372 ; Increment an option, based on type, and boundary. | |
373 ; INPUT: FSR0 = option handle | |
374 ; OUTPUT: none | |
375 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
376 option_inc: | |
377 ; Read type, default and register from table | |
378 rcall option_read | |
379 | |
380 ; Switch on type | |
381 movf opt_type,W | |
382 bz option_inc_uint8 | |
383 dcfsnz WREG | |
384 bra option_inc_enum8 | |
385 dcfsnz WREG | |
386 bra option_inc_string | |
387 | |
388 option_inc_uint8: ; Defaults type too... | |
389 movf INDF1,W | |
390 addwf opt_inc,W | |
391 cpfslt opt_max | |
392 bra option_inc_1 | |
393 movf opt_min,W | |
394 option_inc_1: | |
395 movwf INDF1 | |
396 return | |
397 | |
398 option_inc_enum8: ; Always +1 | |
399 incf INDF1,W | |
400 cpfsgt opt_max | |
401 clrf WREG | |
402 movwf INDF1 | |
403 return | |
404 | |
405 option_inc_string: ; No edition yet... | |
406 return | |
407 | |
408 ;============================================================================= | |
409 ; Strcat option into FSR2 buffer. | |
410 option_draw: | |
411 ; Read type, default and register from table | |
412 rcall option_read | |
413 | |
414 ; Switch on type | |
415 movf opt_type,W | |
416 bz option_draw_uint8 | |
417 dcfsnz WREG | |
418 bra option_draw_enum8 | |
419 dcfsnz WREG | |
420 bra option_draw_string | |
421 return ; Unknown: return... | |
422 | |
423 option_draw_uint8: | |
424 movff INDF1,lo ; Draw value. | |
425 output_8 | |
426 clrf INDF2 ; Make sure to close string... | |
427 | |
428 movf opt_unit+0,W ; Is there a unit to append ? | |
429 iorwf opt_unit+1,W | |
430 rcall option_draw_unit | |
431 | |
432 movf opt_default,W ; Default value | |
433 cpfseq lo ; Current value | |
434 bra option_draw_uint8_2 ; Not default, add * | |
435 return ; Default, Done. | |
436 option_draw_uint8_2: | |
437 PUTC "*" | |
438 return ; Done. | |
439 | |
440 option_draw_unit: | |
441 movff opt_unit+0,FSR1L | |
442 movff opt_unit+1,FSR1H | |
443 goto strcat_text | |
444 | |
445 | |
446 | |
447 ;---- Draw an enumerated value (set of translated strings) | |
448 option_draw_enum8: | |
449 movf INDF1,W ; Get current value. | |
450 cpfsgt opt_max ; Bound value | |
451 clrf WREG | |
452 addwf WREG ; *= 2 | |
453 addwf opt_inc,W ; Base text + 2 * value | |
454 movwf FSR1L | |
455 movlw 0 | |
456 addwfc opt_min,W ; Propagate carry | |
457 movwf FSR1H ; Into FSR1 | |
458 | |
459 goto strcat_text | |
460 | |
461 option_draw_string: | |
462 movff POSTINC1,POSTINC2 | |
463 decfsz opt_max | |
464 bra option_draw_string | |
465 return | |
466 | |
467 ;============================================================================= | |
468 ; Options Tables | |
469 | |
470 OPTION_UINT8 MACRO lbl, min, max, default, unit, eeprom, register | |
471 global lbl | |
472 lbl: db 0, default ; Type0 = INT8 | |
473 db 1, min | |
474 db max, eeprom | |
475 dw unit | |
476 dw register | |
477 ENDM | |
478 | |
479 OPTION_UINT8p2 MACRO lbl, min, max, default, unit, eeprom, register | |
480 global lbl | |
481 lbl: db 0, default ; Type0 = INT8 | |
482 db 2, min | |
483 db max, eeprom | |
484 dw unit | |
485 dw register | |
486 ENDM | |
487 | |
488 OPTION_UINT8p3 MACRO lbl, min, max, default, unit, eeprom, register | |
489 global lbl | |
490 lbl: db 0, default ; Type0 = INT8 | |
491 db 3, min | |
492 db max, eeprom | |
493 dw unit | |
494 dw register | |
495 ENDM | |
496 | |
497 OPTION_UINT8p10 MACRO lbl, min, max, default, unit, eeprom, register | |
498 global lbl | |
499 lbl: db 0, default ; Type0 = INT8 | |
500 db .10, min | |
501 db max, eeprom | |
502 dw unit | |
503 dw register | |
504 ENDM | |
505 | |
506 OPTION_ENUM8 MACRO lbl, max, default, tValue, eeprom, register | |
507 global lbl | |
508 extern tValue | |
509 lbl: db 1, default ; Type1 = ENUM | |
510 db LOW(tValue), HIGH(tValue) | |
511 db max, eeprom | |
512 dw 0 ; No unit | |
513 dw register | |
514 ENDM | |
515 | |
516 OPTION_BOOL MACRO lbl, default, eeprom, register | |
517 OPTION_ENUM8 lbl, 2, default, tNo, eeprom, register | |
518 ENDM | |
519 | |
520 | |
521 OPTION_STRING MACRO lbl, length, defText, eeprom, register | |
522 global lbl | |
523 lbl: db 2, LOW(defText) ; Type2 = STRING | |
524 db HIGH(defText), 0 | |
525 db length, eeprom | |
526 dw 0 ; No unit | |
527 dw register | |
528 ENDM | |
529 | |
139 | 530 |
0 | 531 ;============================================================================= |
139 | 532 extern tPercent, tMeters, tMinutes, tGasDisabled, tbar, tcharx |
533 extern char_I_deco_gas_change, char_I_setpoint_change, char_I_setpoint_cbar, char_I_dil_change | |
534 extern char_I_dive_interval, char_I_bottom_time, char_I_bottom_depth | |
535 extern char_I_deco_model, char_I_saturation_multiplier, char_I_desaturation_multiplier | |
536 extern char_I_extra_time | |
537 extern tDefName | |
0 | 538 ; Option table |
539 ; OPTION_UINT8 Label, min, max, default, text-string, EEPROM location (-1 for RAM only), RAM location | |
540 option_table_begin: | |
541 ;============================================================================= | |
542 ; Manage Decoplaner & Dive parameters | |
543 OPTION_UINT8p10 odiveInterval, .0, .240, .0, tMinutes, -1, char_I_dive_interval | |
544 OPTION_UINT8p2 obottomTime, .1, .60, .5, tMinutes, -1, char_I_bottom_time | |
545 OPTION_UINT8p3 obottomDepth, .12,.120, .21, tMeters, -1, char_I_bottom_depth | |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
546 OPTION_ENUM8 oDiveMode, 4, 0, tDvOC, .8, opt_dive_mode ; 0=OC, 1=CC, 2=Gauge, 3=Apnea |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
547 OPTION_ENUM8 oDecoMode, 2, 1, tZHL16, .9, char_I_deco_model ; 0 = ZH-L16, 1 = ZH-L16-GF |
0 | 548 OPTION_UINT8p10 oPPO2Max, .120, ppo2_warning_high, .160, 0, .10, opt_ppO2_max |
549 OPTION_UINT8 oLastDeco, .3, .6, .3, tMeters, .11, opt_last_stop | |
22 | 550 OPTION_UINT8 oGF_low, .10, .100, .30, tPercent, .12, opt_GF_low |
32 | 551 OPTION_UINT8 oGF_high, .60, .110, .85, tPercent, .13, opt_GF_high |
0 | 552 OPTION_UINT8p10 osatmult, .100, .140, .110,tPercent, .14, char_I_saturation_multiplier |
553 OPTION_UINT8p10 odesatmult, .60, .100, .90,tPercent, .15, char_I_desaturation_multiplier | |
554 OPTION_UINT8p10 oPPO2Min, .16, ppo2_warning_low, .19, 0, .16, opt_ppO2_min | |
555 OPTION_UINT8 oaGF_low, .60, .100, .60, tPercent, .17, opt_aGF_low | |
32 | 556 OPTION_UINT8 oaGF_high, .70, .120, .85, tPercent, .18, opt_aGF_high |
69 | 557 OPTION_BOOL oEnable_aGF, 0, .19, opt_enable_aGF ; =1: aGF can be selected underwater |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
558 OPTION_UINT8 oCompassGain, 0, 7, 6, tcharx, .20, opt_compass_gain ; 0-7 (230LSB/Gauss to 1370LSB/Gauss) |
24 | 559 OPTION_ENUM8 oSamplingRate, 2, 0, tSampling2s, .21, opt_sampling_rate ; =1: 10s, =0: 2s |
0 | 560 |
561 ;============================================================================= | |
562 ; Managing Settings | |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
563 OPTION_UINT8 oExtraTime, 0, .9, 0,tMinutes, .22, char_I_extra_time ; Future TTS |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
564 OPTION_ENUM8 oBrightness, 3, 0, tEco, .23, opt_brightness ; =0: Eco, =1:Medium, =2:Full |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
565 OPTION_UINT8 oDiveSalinity, 0, 4, 0, tPercent, .24, opt_salinity ; 0-5% |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
566 OPTION_ENUM8 oCCRMode, 2, 0, tCCRModeFixedSP, .25, opt_ccr_mode ; =0: Fixed SP, =1: Sensor |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
567 OPTION_ENUM8 oLanguage, 4, 0, tEnglish, .26, opt_language ; 0=EN, 1=DE, 2=FR, 3=SP |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
568 OPTION_ENUM8 oDateFormat, 3, 1, tDateformat,.27, opt_dateformat ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
569 OPTION_ENUM8 oUnits, 2, 0, tMetric, .28, opt_units ; 0=Meters, 1=Feets |
0 | 570 |
571 ;============================================================================= | |
572 ; Compass calibration data | |
573 OPTION_UINT8 oCalx0, 0,.255,.0, 0, .29, compass_CX_f+0 | |
574 OPTION_UINT8 oCalx1, 0,.255,.0, 0, .30, compass_CX_f+1 | |
575 OPTION_UINT8 oCaly0, 0,.255,.0, 0, .31, compass_CY_f+0 | |
576 OPTION_UINT8 oCaly1, 0,.255,.0, 0, .32, compass_CY_f+1 | |
577 OPTION_UINT8 oCalz0, 0,.255,.0, 0, .33, compass_CZ_f+0 | |
578 OPTION_UINT8 oCalz1, 0,.255,.0, 0, .34, compass_CZ_f+1 | |
579 | |
139 | 580 ;============================================================================= |
581 ; Gas list | |
0 | 582 OPTION_ENUM8 oGas1, 3, 1, tGasDisabled, .35, opt_gas_type+0; 0=Disabled, 1=First, 2=Travel, 3=Deco |
583 OPTION_ENUM8 oGas2, 3, 0, tGasDisabled, .36, opt_gas_type+1 | |
584 OPTION_ENUM8 oGas3, 3, 0, tGasDisabled, .37, opt_gas_type+2 | |
585 OPTION_ENUM8 oGas4, 3, 0, tGasDisabled, .38, opt_gas_type+3 | |
586 OPTION_ENUM8 oGas5, 3, 0, tGasDisabled, .39, opt_gas_type+4 | |
587 OPTION_UINT8 oGas1O2, .21,.100, .21, tPercent, .40, opt_gas_O2_ratio+0 | |
588 OPTION_UINT8 oGas1He, .1, .100, .0, tPercent, .41, opt_gas_He_ratio+0 | |
589 OPTION_UINT8 oGas2O2, .21,.100, .21, tPercent, .42, opt_gas_O2_ratio+1 | |
590 OPTION_UINT8 oGas2He, .1, .100, .0, tPercent, .43, opt_gas_He_ratio+1 | |
591 OPTION_UINT8 oGas3O2, .21,.100, .21, tPercent, .44, opt_gas_O2_ratio+2 | |
592 OPTION_UINT8 oGas3He, .1, .100, .0, tPercent, .45, opt_gas_He_ratio+2 | |
593 OPTION_UINT8 oGas4O2, .21,.100, .21, tPercent, .46, opt_gas_O2_ratio+3 | |
594 OPTION_UINT8 oGas4He, .1, .100, .0, tPercent, .47, opt_gas_He_ratio+3 | |
595 OPTION_UINT8 oGas5O2, .21,.100, .21, tPercent, .48, opt_gas_O2_ratio+4 | |
596 OPTION_UINT8 oGas5He, .1, .100, .0, tPercent, .49, opt_gas_He_ratio+4 | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
93
diff
changeset
|
597 OPTION_UINT8 oGas1Depth, .0, .100, .0, tMeters, .50, opt_OC_bail_gas_change+0 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
93
diff
changeset
|
598 OPTION_UINT8 oGas2Depth, .0, .100, .0, tMeters, .51, opt_OC_bail_gas_change+1 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
93
diff
changeset
|
599 OPTION_UINT8 oGas3Depth, .0, .100, .0, tMeters, .52, opt_OC_bail_gas_change+2 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
93
diff
changeset
|
600 OPTION_UINT8 oGas4Depth, .0, .100, .0, tMeters, .53, opt_OC_bail_gas_change+3 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
93
diff
changeset
|
601 OPTION_UINT8 oGas5Depth, .0, .100, .0, tMeters, .54, opt_OC_bail_gas_change+4 |
0 | 602 OPTION_UINT8 oDil1O2, .21,.100, .21, tPercent, .55, opt_dil_O2_ratio+0 |
603 OPTION_UINT8 oDil1He, .1, .100, .0, tPercent, .56, opt_dil_He_ratio+0 | |
604 OPTION_UINT8 oDil2O2, .21,.100, .21, tPercent, .57, opt_dil_O2_ratio+1 | |
605 OPTION_UINT8 oDil2He, .1, .100, .0, tPercent, .58, opt_dil_He_ratio+1 | |
606 OPTION_UINT8 oDil3O2, .21,.100, .21, tPercent, .59, opt_dil_O2_ratio+2 | |
607 OPTION_UINT8 oDil3He, .1, .100, .0, tPercent, .60, opt_dil_He_ratio+2 | |
608 OPTION_UINT8 oDil4O2, .21,.100, .21, tPercent, .61, opt_dil_O2_ratio+3 | |
609 OPTION_UINT8 oDil4He, .1, .100, .0, tPercent, .62, opt_dil_He_ratio+3 | |
610 OPTION_UINT8 oDil5O2, .21,.100, .21, tPercent, .63, opt_dil_O2_ratio+4 | |
611 OPTION_UINT8 oDil5He, .1, .100, .0, tPercent, .64, opt_dil_He_ratio+4 | |
612 OPTION_UINT8 oSetPoint1, .20, .160, .70, tbar, .65, char_I_setpoint_cbar+0 | |
613 OPTION_UINT8 oSetPoint2, .20, .160, .90, tbar, .66, char_I_setpoint_cbar+1 | |
614 OPTION_UINT8 oSetPoint3, .20, .160, .100, tbar, .67, char_I_setpoint_cbar+2 | |
615 OPTION_UINT8 oSetPoint4, .20, .160, .120, tbar, .68, char_I_setpoint_cbar+3 | |
616 OPTION_UINT8 oSetPoint5, .20, .160, .140, tbar, .69, char_I_setpoint_cbar+4 | |
617 OPTION_UINT8 oSP1Depth, .0, .100, .0, tMeters, .70, char_I_setpoint_change+0 | |
618 OPTION_UINT8 oSP2Depth, .0, .100, .0, tMeters, .71, char_I_setpoint_change+1 | |
619 OPTION_UINT8 oSP3Depth, .0, .100, .0, tMeters, .72, char_I_setpoint_change+2 | |
620 OPTION_UINT8 oSP4Depth, .0, .100, .0, tMeters, .73, char_I_setpoint_change+3 | |
621 OPTION_UINT8 oSP5Depth, .0, .100, .0, tMeters, .74, char_I_setpoint_change+4 | |
622 OPTION_ENUM8 oDil1, 2, 1, tDilDisabled, .75, opt_dil_type+0 ; 0=Disabled, 1=First, 2=Normal | |
623 OPTION_ENUM8 oDil2, 2, 0, tDilDisabled, .76, opt_dil_type+1 | |
624 OPTION_ENUM8 oDil3, 2, 0, tDilDisabled, .77, opt_dil_type+2 | |
625 OPTION_ENUM8 oDil4, 2, 0, tDilDisabled, .78, opt_dil_type+3 | |
626 OPTION_ENUM8 oDil5, 2, 0, tDilDisabled, .79, opt_dil_type+4 | |
627 OPTION_UINT8 oDil1Depth, .0, .100, .0, tMeters, .80, char_I_dil_change+0 | |
628 OPTION_UINT8 oDil2Depth, .0, .100, .0, tMeters, .81, char_I_dil_change+1 | |
629 OPTION_UINT8 oDil3Depth, .0, .100, .0, tMeters, .82, char_I_dil_change+2 | |
630 OPTION_UINT8 oDil4Depth, .0, .100, .0, tMeters, .83, char_I_dil_change+3 | |
631 OPTION_UINT8 oDil5Depth, .0, .100, .0, tMeters, .84, char_I_dil_change+4 | |
139 | 632 |
633 ;============================================================================= | |
634 ; opt_name from 85 to 145 | |
0 | 635 OPTION_STRING oName, opt_name_length, tDefName, .85, opt_name |
139 | 636 |
637 ;============================================================================= | |
638 ; Misc | |
92
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
79
diff
changeset
|
639 OPTION_ENUM8 oColorSetDive, 4, 0, tColorSetName0, .146, opt_dive_color_scheme ; Color scheme divemode |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
79
diff
changeset
|
640 OPTION_UINT8 oPressureAdjust, .0,.255, .0, -1, .147, opt_pressure_adjust ; SIGNED int (-20/+20mbar max.) |
104
223579e905c3
Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents:
97
diff
changeset
|
641 OPTION_BOOL oSafetyStop, 0, .148, opt_enable_safetystop ; =1: A safety stop is shown |
113 | 642 OPTION_UINT8 oCalGasO2, .21,.100, .21, tPercent, .149, opt_calibration_O2_ratio ; Calibration gas %O2 |
0 | 643 |
139 | 644 ;============================================================================= |
645 ; Set Time/Set Date (RAM only) | |
0 | 646 OPTION_UINT8 oSetHours, .0, .23, .0, 0, -1, hours |
647 OPTION_UINT8 oSetMinutes, .0, .59, .0, 0, -1, mins | |
648 OPTION_UINT8 oSetDay, .1, .31, .0, 0, -1, day | |
649 OPTION_UINT8 oSetMonth, .1, .12, .0, 0, -1, month | |
650 OPTION_UINT8 oSetYear, .13,.20, .0, 0, -1, year | |
651 | |
652 option_table_end: | |
653 END |