Mercurial > public > hwos_code
annotate src/options.asm @ 555:98c564a2d6cc
ignore voting logic
author | heinrichsweikamp |
---|---|
date | Thu, 23 Nov 2017 12:52:36 +0100 |
parents | dfac393b2199 |
children | b7eb98dbd800 |
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 | |
275 | 16 #include "hwos.inc" ; Mandatory header |
0 | 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 | |
143
be997abd1f73
seperate option table, place in address <0x10000
heinrichsweikamp
parents:
142
diff
changeset
|
27 extern option_table_begin,option_table_end |
0 | 28 |
29 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
|
30 global option_check_all ; Check all option and reset option if out of min/max boundary |
0 | 31 global option_reset ; Reset FSR0 option to factory default. |
32 global option_save_all ; Save options to EEPROM. | |
33 global option_restore_all ; Restore options from EEPROM. | |
34 global option_inc ; Increment FSR0 option. | |
35 global option_draw ; STRCAT FRS0 option. | |
36 | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
37 |
0 | 38 ;============================================================================= |
418 | 39 CBLOCK tmp+0x12 ; Reserve space for wordprocessor & convert |
0 | 40 opt_type |
41 opt_default | |
42 opt_inc ; Also default+1 (string), and enum low | |
43 opt_min ; also enum high | |
44 opt_max | |
45 opt_unit:2 ; Multi-lingual unit text. | |
46 opt_eeprom | |
47 opt_backup_tbl:3 | |
418 | 48 ; Reserved to tmp+0x1C... |
0 | 49 ENDC |
50 | |
51 gui CODE ; Appends to other GUI segment | |
52 ;============================================================================= | |
53 ; Reset all options to factory defauts. | |
54 ; | |
55 ; INPUT: none | |
56 ; OUTPUT: none | |
57 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | |
58 | |
59 option_reset_all: | |
60 clrf EEADRH | |
61 read_int_eeprom .2 | |
139 | 62 tstfsz EEDATA ; Total dives=0? |
63 bra option_reset_all2 ; No, skip resetting logbook | |
0 | 64 read_int_eeprom .3 |
139 | 65 tstfsz EEDATA ; Total dives=0? |
0 | 66 bra option_reset_all2 ; No, skip resetting logbook |
67 | |
68 clrf EEDATA | |
69 write_int_eeprom .4 | |
70 write_int_eeprom .5 | |
71 write_int_eeprom .6 | |
72 write_int_eeprom .2 ; Also, delete total dive counter | |
73 write_int_eeprom .3 | |
74 call ext_flash_erase_logbook ; And complete logbook (!) | |
75 | |
76 option_reset_all2: | |
77 clrf lo | |
78 clrf hi | |
79 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
|
80 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
81 ; Point to option table begin |
0 | 82 movlw LOW(option_table_begin) |
83 movwf FSR0L | |
84 movlw HIGH(option_table_begin) | |
85 movwf FSR0H | |
86 option_reset_all_1: | |
87 movf FSR0L,W ; Reached end of table ? | |
88 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
89 btfsc STATUS,Z ; YES: done. | |
90 return | |
91 | |
92 rcall option_reset ; Reset one option. | |
93 bra option_reset_all_1 ; and loop. | |
94 | |
95 ;============================================================================= | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
96 ; 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
|
97 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
98 ; INPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
99 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
100 ; 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
|
101 option_check_all: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
102 ; 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
|
103 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
|
104 movwf FSR0L |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
105 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
|
106 movwf FSR0H |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
107 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
108 option_check_all_1: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
113 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
114 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
|
115 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
|
116 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
117 ;============================================================================= |
0 | 118 ; Read option handle |
119 ; INPUT: FSR0 = option handle | |
120 ; OUTPUT: FSR1 = address of variable. | |
121 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
122 option_read: | |
123 movff FSR0L,TBLPTRL | |
124 movlw HIGH(option_table_begin); Get 8 high bits. | |
125 andlw 0xF0 ; Keep only the 4 highest ones. | |
126 iorwf FSR0H,W ; Cat with the known 4 lower ones. | |
127 movwf TBLPTRH ; And we have the high byte. | |
128 movlw UPPER(option_table_begin) | |
129 movwf TBLPTRU | |
130 | |
131 ; Read type, default and register from table | |
132 tblrd*+ | |
133 movff TABLAT,opt_type | |
134 tblrd*+ | |
135 movff TABLAT,opt_default | |
136 tblrd*+ | |
137 movff TABLAT,opt_inc | |
138 tblrd*+ | |
139 movff TABLAT,opt_min | |
140 tblrd*+ | |
141 movff TABLAT,opt_max | |
142 tblrd*+ | |
143 movff TABLAT,opt_eeprom | |
144 tblrd*+ | |
145 movff TABLAT,opt_unit+0 | |
146 tblrd*+ | |
147 movff TABLAT,opt_unit+1 | |
148 tblrd*+ | |
149 movff TABLAT,FSR1L | |
150 tblrd*+ | |
151 movff TABLAT,FSR1H | |
152 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all | |
153 movff TBLPTRH,FSR0H | |
154 return | |
21
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 ;============================================================================= |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
157 ; 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
|
158 ; INPUT: FSR0 = option handle |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
159 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
160 ; 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
|
161 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
162 option_check: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
163 ; 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
|
164 rcall option_read |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
165 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
166 ; Switch on type |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
167 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
|
168 xorlw 2 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
169 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
|
170 |
110 | 171 movf opt_type,W ; Type == ENUM8 ? |
172 xorlw 1 | |
173 bz option_check_enum8 ; ENUM8: Check if lower then max. value only | |
174 | |
220
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
175 tstfsz opt_min ; opt_min=0? |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
176 bra option_check_both ; no |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
177 bra option_check_enum8 ; Check max only |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
178 |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
179 option_check_both: |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
180 decf opt_min,W |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
181 cpfsgt INDF1 ; bigger then opt_min-1? |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
182 bra option_check_reset ; No, reset option |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
183 option_check_enum8: ; ENUM8: Check max only |
222 | 184 infsnz opt_max,W ; Max = 255? |
185 return ; Yes, igonore max. test | |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
186 cpfslt INDF1 ; smaller then opt_max+1? |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
187 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
|
188 return ; in range, return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
189 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
190 option_check_reset: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
191 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
|
192 return ; Done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
193 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
194 option_check_string: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
195 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
196 |
0 | 197 ;============================================================================= |
198 ; Reset an option to its default value. | |
199 ; INPUT: FSR0 = option handle | |
200 ; OUTPUT: none | |
201 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | |
202 ; | |
203 option_reset: | |
204 ; Read type, default and register from table | |
205 rcall option_read | |
206 | |
207 ; Switch on type | |
208 movf opt_type,W ; Type == STRING ? | |
209 xorlw 2 | |
210 bz opt_reset_string ; YES: special copy | |
211 | |
212 movff opt_default,INDF1 ; NO: just a 8bit indirect copy | |
213 return | |
214 | |
215 opt_reset_string: | |
216 movff FSR1L,FSR2L ; set string destination address. | |
217 movff FSR1H,FSR2H | |
218 | |
219 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1 | |
220 movff opt_default+1,FSR1H | |
221 | |
222 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine... | |
223 movff TBLPTRH,opt_backup_tbl+1 | |
224 movff TBLPTRU,opt_backup_tbl+2 | |
225 | |
226 call strcat_text ; Copy translated text to FSR2 | |
227 | |
228 movff opt_backup_tbl+0,TBLPTRL | |
229 movff opt_backup_tbl+1,TBLPTRH | |
230 movff opt_backup_tbl+2,TBLPTRU | |
231 | |
232 return | |
233 | |
234 ;============================================================================= | |
235 ; Save all options to EEPROM | |
236 option_save_all: | |
237 ;---- Save option serial into EEPROM to detect reset and new version | |
238 movlw LOW(eeprom_serial_save) | |
239 movwf EEADR | |
240 movlw HIGH(eeprom_serial_save) | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
241 movwf EEADRH |
0 | 242 movlw LOW(eeprom_opt_serial) |
243 movwf EEDATA | |
244 call write_eeprom | |
245 incf EEADR,F | |
246 movlw HIGH(eeprom_opt_serial) | |
247 movwf EEDATA | |
248 call write_eeprom | |
249 | |
250 ;---- Save all options | |
251 movlw LOW(option_table_begin) | |
252 movwf FSR0L | |
253 movlw HIGH(option_table_begin) | |
254 movwf FSR0H | |
255 | |
256 option_save_all_1: | |
257 movf FSR0L,W ; Reached end of table ? | |
258 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
259 btfsc STATUS,Z ; YES: done. | |
260 return | |
261 | |
262 rcall option_save ; Save one option. | |
263 bra option_save_all_1 ; and loop. | |
264 | |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
92
diff
changeset
|
265 global option_save |
0 | 266 option_save: |
267 rcall option_read | |
268 incf opt_eeprom,W ; Should we save it ? | |
269 btfsc STATUS,Z ; eeprom address is FFh ? | |
270 return ; YES: nothing to do. | |
271 | |
272 movf opt_eeprom,W ; Compute backup address in EEPROM | |
273 addlw LOW(eeprom_opt_backup) ; Add offset | |
274 movwf EEADR | |
275 movlw HIGH(eeprom_opt_backup) | |
142 | 276 btfsc STATUS,C ; >256 |
277 addlw .1 ; Yes: +1 | |
0 | 278 movwf EEADRH |
279 | |
280 movf opt_type,W ; Option type is string ? | |
281 xorlw 2 | |
282 bz option_save_string | |
283 | |
284 ; One byte to save to eeprom | |
285 movff INDF1,EEDATA | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
286 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
287 call write_eeprom ; Yes, write |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
288 return |
0 | 289 |
290 option_save_string: | |
291 movff POSTINC1,EEDATA ; Write one byte | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
292 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
293 call write_eeprom ; Yes, write |
0 | 294 infsnz EEADR,F |
295 incf EEADRH,F | |
296 | |
297 decfsz opt_max ; Decrement string length | |
298 bra option_save_string ; And loop while not finished | |
299 | |
300 return | |
301 ;============================================================================= | |
302 | |
303 option_restore_all: | |
304 ;---- Read option serial from EEPROM | |
305 movlw LOW(eeprom_serial_save) | |
306 movwf EEADR | |
307 movlw HIGH(eeprom_serial_save) | |
308 movf EEADRH | |
309 call read_eeprom | |
310 movlw LOW(eeprom_opt_serial) | |
311 xorwf EEDATA,W | |
312 bnz option_restore_bad ; Auto reset if changed. | |
313 incf EEADR,F | |
314 call read_eeprom | |
315 movlw HIGH(eeprom_opt_serial) | |
316 xorwf EEDATA,W | |
317 bz option_restore_ok ; Auto reset if changed. | |
318 | |
319 option_restore_bad: | |
320 call option_reset_all ; Reset RAM contains | |
321 goto option_save_all ; Then save to EEPROM | |
322 | |
323 ;---- Proper restore | |
324 option_restore_ok: | |
325 movlw LOW(option_table_begin) | |
326 movwf FSR0L | |
327 movlw HIGH(option_table_begin) | |
328 movwf FSR0H | |
329 | |
330 option_restore_all_1: | |
331 movf FSR0L,W ; Reached end of table ? | |
332 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
333 btfsc STATUS,Z ; YES: done. | |
334 return | |
335 | |
336 rcall option_restore ; Restore one option. | |
337 bra option_restore_all_1 ; and loop. | |
338 return | |
339 | |
340 option_restore: | |
341 rcall option_read | |
342 incf opt_eeprom,W ; Should we save it ? | |
343 btfsc STATUS,Z ; eeprom address is FFh ? | |
344 return ; YES: nothing to do. | |
345 | |
346 movf opt_eeprom,W ; Compute backup address in EEPROM | |
347 addlw LOW(eeprom_opt_backup) ; Add offset | |
348 movwf EEADR | |
349 movlw HIGH(eeprom_opt_backup) | |
142 | 350 btfsc STATUS,C ; >256 |
351 addlw .1 ; Yes: +1 | |
0 | 352 movwf EEADRH |
353 | |
354 movf opt_type,W ; Option type is string ? | |
355 xorlw 2 | |
356 bz option_restore_string | |
357 | |
358 ; Read one byte from eeprom | |
359 call read_eeprom | |
360 movff EEDATA, INDF1 ; And restore option register. | |
361 return | |
362 | |
363 option_restore_string: | |
364 call read_eeprom ; Read one byte, and | |
365 movff EEDATA,POSTINC1 ; restore it | |
366 infsnz EEADR,F | |
367 incf EEADRH,F | |
368 | |
369 decfsz opt_max ; Decrement string length | |
370 bra option_restore_string ; And loop while not finished | |
371 return | |
372 | |
373 ;============================================================================= | |
374 ; Increment an option, based on type, and boundary. | |
375 ; INPUT: FSR0 = option handle | |
376 ; OUTPUT: none | |
377 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
378 option_inc: | |
379 ; Read type, default and register from table | |
380 rcall option_read | |
381 | |
382 ; Switch on type | |
383 movf opt_type,W | |
384 bz option_inc_uint8 | |
385 dcfsnz WREG | |
386 bra option_inc_enum8 | |
387 dcfsnz WREG | |
388 bra option_inc_string | |
389 | |
390 option_inc_uint8: ; Defaults type too... | |
391 movf INDF1,W | |
392 addwf opt_inc,W | |
393 cpfslt opt_max | |
394 bra option_inc_1 | |
395 movf opt_min,W | |
396 option_inc_1: | |
397 movwf INDF1 | |
533
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
398 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
399 ; Now some rather crude hack into this routine to make CCR Calibration more convenient: |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
400 movlw .149 ; eeprom address of option CalGasO2 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
401 cpfseq opt_eeprom ; skip next line if we deal with this option right now |
0 | 402 return |
533
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
403 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
404 btfsc FLAG_pscr_mode ; skip next line if we are not in PSCR mode |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
405 return |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
406 movlw .26 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
407 cpfseq INDF1 ; skip next line if current option value is =26 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
408 return |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
409 movlw .95 ; current option value =26, advance it to 95 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
410 movwf INDF1 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
411 return |
0 | 412 |
413 option_inc_enum8: ; Always +1 | |
414 incf INDF1,W | |
415 cpfsgt opt_max | |
416 clrf WREG | |
417 movwf INDF1 | |
418 return | |
419 | |
420 option_inc_string: ; No edition yet... | |
421 return | |
422 | |
423 ;============================================================================= | |
424 ; Strcat option into FSR2 buffer. | |
425 option_draw: | |
426 ; Read type, default and register from table | |
427 rcall option_read | |
428 | |
429 ; Switch on type | |
430 movf opt_type,W | |
431 bz option_draw_uint8 | |
432 dcfsnz WREG | |
433 bra option_draw_enum8 | |
434 dcfsnz WREG | |
435 bra option_draw_string | |
436 return ; Unknown: return... | |
437 | |
438 option_draw_uint8: | |
439 movff INDF1,lo ; Draw value. | |
263 | 440 bsf leftbind |
0 | 441 output_8 |
263 | 442 bcf leftbind |
0 | 443 clrf INDF2 ; Make sure to close string... |
444 | |
445 movf opt_unit+0,W ; Is there a unit to append ? | |
446 iorwf opt_unit+1,W | |
447 rcall option_draw_unit | |
448 | |
449 movf opt_default,W ; Default value | |
450 cpfseq lo ; Current value | |
451 bra option_draw_uint8_2 ; Not default, add * | |
452 return ; Default, Done. | |
453 option_draw_uint8_2: | |
454 PUTC "*" | |
455 return ; Done. | |
456 | |
457 option_draw_unit: | |
458 movff opt_unit+0,FSR1L | |
459 movff opt_unit+1,FSR1H | |
460 goto strcat_text | |
461 | |
462 | |
463 | |
464 ;---- Draw an enumerated value (set of translated strings) | |
465 option_draw_enum8: | |
466 movf INDF1,W ; Get current value. | |
467 cpfsgt opt_max ; Bound value | |
468 clrf WREG | |
469 addwf WREG ; *= 2 | |
470 addwf opt_inc,W ; Base text + 2 * value | |
471 movwf FSR1L | |
472 movlw 0 | |
473 addwfc opt_min,W ; Propagate carry | |
474 movwf FSR1H ; Into FSR1 | |
475 | |
476 goto strcat_text | |
477 | |
478 option_draw_string: | |
479 movff POSTINC1,POSTINC2 | |
480 decfsz opt_max | |
481 bra option_draw_string | |
482 return | |
483 | |
484 END |