Mercurial > public > hwos_code
annotate src/options.asm @ 575:bf34a2f784ab
French updates
author | heinrichsweikamp |
---|---|
date | Thu, 15 Feb 2018 10:03:33 +0100 |
parents | 8b7ea27ea1fa |
children | b455b31ce022 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
560 | 3 ; File options.asm REFACTORED VERSION V2.91 |
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 ; 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: | |
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
|
87 movlw LOW(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
|
88 cpfseq FSR0L |
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
|
89 bra option_reset_all_2 ; Not yet done... |
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
|
90 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
|
91 cpfseq FSR0H |
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
|
92 bra option_reset_all_2 ; Not yet done... |
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
|
93 return ; All done. |
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
|
94 option_reset_all_2: |
0 | 95 rcall option_reset ; Reset one option. |
96 bra option_reset_all_1 ; and loop. | |
97 | |
98 ;============================================================================= | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
99 ; 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
|
100 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
101 ; INPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
102 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
103 ; 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
|
104 option_check_all: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
105 ; 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
|
106 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
|
107 movwf FSR0L |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
108 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
|
109 movwf FSR0H |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
110 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
111 option_check_all_1: |
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
|
112 movlw LOW(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
|
113 cpfseq FSR0L |
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
|
114 bra option_check_all_2 ; Not yet done... |
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
|
115 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
|
116 cpfseq FSR0H |
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
|
117 bra option_check_all_2 ; Not yet done... |
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
|
118 return ; All done. |
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
|
119 option_check_all_2: |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
120 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
|
121 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
|
122 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
123 ;============================================================================= |
0 | 124 ; Read option handle |
125 ; INPUT: FSR0 = option handle | |
126 ; OUTPUT: FSR1 = address of variable. | |
127 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
128 option_read: | |
129 movff FSR0L,TBLPTRL | |
130 movlw HIGH(option_table_begin); Get 8 high bits. | |
131 andlw 0xF0 ; Keep only the 4 highest ones. | |
132 iorwf FSR0H,W ; Cat with the known 4 lower ones. | |
133 movwf TBLPTRH ; And we have the high byte. | |
134 movlw UPPER(option_table_begin) | |
135 movwf TBLPTRU | |
136 | |
137 ; Read type, default and register from table | |
138 tblrd*+ | |
139 movff TABLAT,opt_type | |
140 tblrd*+ | |
141 movff TABLAT,opt_default | |
142 tblrd*+ | |
143 movff TABLAT,opt_inc | |
144 tblrd*+ | |
145 movff TABLAT,opt_min | |
146 tblrd*+ | |
147 movff TABLAT,opt_max | |
148 tblrd*+ | |
149 movff TABLAT,opt_eeprom | |
150 tblrd*+ | |
151 movff TABLAT,opt_unit+0 | |
152 tblrd*+ | |
153 movff TABLAT,opt_unit+1 | |
154 tblrd*+ | |
155 movff TABLAT,FSR1L | |
156 tblrd*+ | |
157 movff TABLAT,FSR1H | |
158 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all | |
159 movff TBLPTRH,FSR0H | |
160 return | |
21
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 ;============================================================================= |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
163 ; 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
|
164 ; INPUT: FSR0 = option handle |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
165 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
166 ; 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
|
167 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
168 option_check: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
169 ; 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
|
170 rcall option_read |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
171 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
172 ; Switch on type |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
173 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
|
174 xorlw 2 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
175 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
|
176 |
110 | 177 movf opt_type,W ; Type == ENUM8 ? |
178 xorlw 1 | |
179 bz option_check_enum8 ; ENUM8: Check if lower then max. value only | |
180 | |
220
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
181 tstfsz opt_min ; opt_min=0? |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
182 bra option_check_both ; no |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
183 bra option_check_enum8 ; Check max only |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
184 |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
185 option_check_both: |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
186 decf opt_min,W |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
187 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
|
188 bra option_check_reset ; No, reset option |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
189 option_check_enum8: ; ENUM8: Check max only |
222 | 190 infsnz opt_max,W ; Max = 255? |
191 return ; Yes, igonore max. test | |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
192 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
|
193 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
|
194 return ; in range, return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
195 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
196 option_check_reset: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
197 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
|
198 return ; Done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
199 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
200 option_check_string: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
201 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
202 |
0 | 203 ;============================================================================= |
204 ; Reset an option to its default value. | |
205 ; INPUT: FSR0 = option handle | |
206 ; OUTPUT: none | |
207 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | |
208 ; | |
209 option_reset: | |
210 ; Read type, default and register from table | |
211 rcall option_read | |
212 | |
213 ; Switch on type | |
214 movf opt_type,W ; Type == STRING ? | |
215 xorlw 2 | |
216 bz opt_reset_string ; YES: special copy | |
217 | |
218 movff opt_default,INDF1 ; NO: just a 8bit indirect copy | |
219 return | |
220 | |
221 opt_reset_string: | |
222 movff FSR1L,FSR2L ; set string destination address. | |
223 movff FSR1H,FSR2H | |
224 | |
225 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1 | |
226 movff opt_default+1,FSR1H | |
227 | |
228 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine... | |
229 movff TBLPTRH,opt_backup_tbl+1 | |
230 movff TBLPTRU,opt_backup_tbl+2 | |
231 | |
232 call strcat_text ; Copy translated text to FSR2 | |
233 | |
234 movff opt_backup_tbl+0,TBLPTRL | |
235 movff opt_backup_tbl+1,TBLPTRH | |
236 movff opt_backup_tbl+2,TBLPTRU | |
237 | |
238 return | |
239 | |
240 ;============================================================================= | |
241 ; Save all options to EEPROM | |
242 option_save_all: | |
243 ;---- Save option serial into EEPROM to detect reset and new version | |
244 movlw LOW(eeprom_serial_save) | |
245 movwf EEADR | |
246 movlw HIGH(eeprom_serial_save) | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
247 movwf EEADRH |
0 | 248 movlw LOW(eeprom_opt_serial) |
249 movwf EEDATA | |
250 call write_eeprom | |
251 incf EEADR,F | |
252 movlw HIGH(eeprom_opt_serial) | |
253 movwf EEDATA | |
254 call write_eeprom | |
255 | |
256 ;---- Save all options | |
257 movlw LOW(option_table_begin) | |
258 movwf FSR0L | |
259 movlw HIGH(option_table_begin) | |
260 movwf FSR0H | |
261 | |
262 option_save_all_1: | |
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
|
263 movlw LOW(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
|
264 cpfseq FSR0L |
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
|
265 bra option_save_all_2 ; Not yet done... |
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
|
266 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
|
267 cpfseq FSR0H |
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
|
268 bra option_save_all_2 ; Not yet done... |
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
|
269 return ; All done. |
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
|
270 option_save_all_2: |
0 | 271 rcall option_save ; Save one option. |
272 bra option_save_all_1 ; and loop. | |
273 | |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
92
diff
changeset
|
274 global option_save |
0 | 275 option_save: |
276 rcall option_read | |
277 incf opt_eeprom,W ; Should we save it ? | |
278 btfsc STATUS,Z ; eeprom address is FFh ? | |
279 return ; YES: nothing to do. | |
280 | |
281 movf opt_eeprom,W ; Compute backup address in EEPROM | |
282 addlw LOW(eeprom_opt_backup) ; Add offset | |
283 movwf EEADR | |
284 movlw HIGH(eeprom_opt_backup) | |
142 | 285 btfsc STATUS,C ; >256 |
286 addlw .1 ; Yes: +1 | |
0 | 287 movwf EEADRH |
288 | |
289 movf opt_type,W ; Option type is string ? | |
290 xorlw 2 | |
291 bz option_save_string | |
292 | |
293 ; One byte to save to eeprom | |
294 movff INDF1,EEDATA | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
295 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
296 call write_eeprom ; Yes, write |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
297 return |
0 | 298 |
299 option_save_string: | |
300 movff POSTINC1,EEDATA ; Write one byte | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
301 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
302 call write_eeprom ; Yes, write |
0 | 303 infsnz EEADR,F |
304 incf EEADRH,F | |
305 | |
306 decfsz opt_max ; Decrement string length | |
307 bra option_save_string ; And loop while not finished | |
308 | |
309 return | |
310 ;============================================================================= | |
311 | |
312 option_restore_all: | |
313 ;---- Read option serial from EEPROM | |
314 movlw LOW(eeprom_serial_save) | |
315 movwf EEADR | |
316 movlw HIGH(eeprom_serial_save) | |
317 movf EEADRH | |
318 call read_eeprom | |
319 movlw LOW(eeprom_opt_serial) | |
320 xorwf EEDATA,W | |
321 bnz option_restore_bad ; Auto reset if changed. | |
322 incf EEADR,F | |
323 call read_eeprom | |
324 movlw HIGH(eeprom_opt_serial) | |
325 xorwf EEDATA,W | |
326 bz option_restore_ok ; Auto reset if changed. | |
327 | |
328 option_restore_bad: | |
329 call option_reset_all ; Reset RAM contains | |
330 goto option_save_all ; Then save to EEPROM | |
331 | |
332 ;---- Proper restore | |
333 option_restore_ok: | |
334 movlw LOW(option_table_begin) | |
335 movwf FSR0L | |
336 movlw HIGH(option_table_begin) | |
337 movwf FSR0H | |
338 | |
339 option_restore_all_1: | |
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
|
340 movlw LOW(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
|
341 cpfseq FSR0L |
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
|
342 bra option_restore_all_2 ; Not yet done... |
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
|
343 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
|
344 cpfseq FSR0H |
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
|
345 bra option_restore_all_2 ; Not yet done... |
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
|
346 return ; All done. |
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
|
347 option_restore_all_2: |
0 | 348 rcall option_restore ; Restore one option. |
349 bra option_restore_all_1 ; and loop. | |
350 | |
351 option_restore: | |
352 rcall option_read | |
353 incf opt_eeprom,W ; Should we save it ? | |
354 btfsc STATUS,Z ; eeprom address is FFh ? | |
355 return ; YES: nothing to do. | |
356 | |
357 movf opt_eeprom,W ; Compute backup address in EEPROM | |
358 addlw LOW(eeprom_opt_backup) ; Add offset | |
359 movwf EEADR | |
360 movlw HIGH(eeprom_opt_backup) | |
142 | 361 btfsc STATUS,C ; >256 |
362 addlw .1 ; Yes: +1 | |
0 | 363 movwf EEADRH |
364 | |
365 movf opt_type,W ; Option type is string ? | |
366 xorlw 2 | |
367 bz option_restore_string | |
368 | |
369 ; Read one byte from eeprom | |
370 call read_eeprom | |
371 movff EEDATA, INDF1 ; And restore option register. | |
372 return | |
373 | |
374 option_restore_string: | |
375 call read_eeprom ; Read one byte, and | |
376 movff EEDATA,POSTINC1 ; restore it | |
377 infsnz EEADR,F | |
378 incf EEADRH,F | |
379 | |
380 decfsz opt_max ; Decrement string length | |
381 bra option_restore_string ; And loop while not finished | |
382 return | |
383 | |
384 ;============================================================================= | |
385 ; Increment an option, based on type, and boundary. | |
386 ; INPUT: FSR0 = option handle | |
387 ; OUTPUT: none | |
388 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
389 option_inc: | |
560 | 390 ; Read type, default and register from table |
391 rcall option_read | |
0 | 392 |
560 | 393 ; Switch on type |
394 movf opt_type,W | |
395 bz option_inc_uint8 | |
396 dcfsnz WREG | |
397 bra option_inc_enum8 | |
398 dcfsnz WREG | |
399 bra option_inc_string | |
0 | 400 |
560 | 401 |
0 | 402 option_inc_uint8: ; Defaults type too... |
560 | 403 movf INDF1,W |
404 addwf opt_inc,W | |
405 cpfslt opt_max | |
406 bra option_inc_1 | |
407 movf opt_min,W | |
0 | 408 option_inc_1: |
560 | 409 movwf INDF1 |
410 | |
411 ; NEW FROM HERE... ## voting logic (allow sensors for pSCR) | |
412 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting: | |
413 movlw .25 ; eeprom address of option oCCRMode | |
414 cpfseq opt_eeprom ; skip next line if we deal with this option right now | |
415 bra option_inc_2 | |
416 btfsc FLAG_pscr_mode ; skip next line if we are not in PSCR mode | |
417 bcf opt_ccr_mode,1 ; in pSCR mode, opt_ccr_mode may only be 0 or 1 | |
418 | |
419 option_inc_2: | |
420 ; ...UNTILL HERE | |
533
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
421 ; 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
|
422 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
|
423 cpfseq opt_eeprom ; skip next line if we deal with this option right now |
560 | 424 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
|
425 |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
426 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
|
427 return |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
428 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
|
429 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
|
430 return |
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
431 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
|
432 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
|
433 return |
0 | 434 |
435 option_inc_enum8: ; Always +1 | |
436 incf INDF1,W | |
437 cpfsgt opt_max | |
438 clrf WREG | |
439 movwf INDF1 | |
440 return | |
441 | |
442 option_inc_string: ; No edition yet... | |
443 return | |
444 | |
445 ;============================================================================= | |
446 ; Strcat option into FSR2 buffer. | |
447 option_draw: | |
448 ; Read type, default and register from table | |
449 rcall option_read | |
450 | |
451 ; Switch on type | |
452 movf opt_type,W | |
453 bz option_draw_uint8 | |
454 dcfsnz WREG | |
455 bra option_draw_enum8 | |
456 dcfsnz WREG | |
457 bra option_draw_string | |
458 return ; Unknown: return... | |
459 | |
460 option_draw_uint8: | |
461 movff INDF1,lo ; Draw value. | |
263 | 462 bsf leftbind |
0 | 463 output_8 |
263 | 464 bcf leftbind |
0 | 465 clrf INDF2 ; Make sure to close string... |
466 | |
467 movf opt_unit+0,W ; Is there a unit to append ? | |
468 iorwf opt_unit+1,W | |
469 rcall option_draw_unit | |
470 | |
471 movf opt_default,W ; Default value | |
472 cpfseq lo ; Current value | |
473 bra option_draw_uint8_2 ; Not default, add * | |
474 return ; Default, Done. | |
475 option_draw_uint8_2: | |
476 PUTC "*" | |
477 return ; Done. | |
478 | |
479 option_draw_unit: | |
480 movff opt_unit+0,FSR1L | |
481 movff opt_unit+1,FSR1H | |
482 goto strcat_text | |
483 | |
484 | |
485 | |
486 ;---- Draw an enumerated value (set of translated strings) | |
487 option_draw_enum8: | |
488 movf INDF1,W ; Get current value. | |
489 cpfsgt opt_max ; Bound value | |
490 clrf WREG | |
491 addwf WREG ; *= 2 | |
492 addwf opt_inc,W ; Base text + 2 * value | |
493 movwf FSR1L | |
494 movlw 0 | |
495 addwfc opt_min,W ; Propagate carry | |
496 movwf FSR1H ; Into FSR1 | |
497 | |
498 goto strcat_text | |
499 | |
500 option_draw_string: | |
501 movff POSTINC1,POSTINC2 | |
502 decfsz opt_max | |
503 bra option_draw_string | |
504 return | |
505 | |
506 END |