annotate src/options.asm @ 445:d770f3d204c5

minor: Default timeout is 5min
author heinrichsweikamp
date Thu, 18 Aug 2016 12:41:16 +0200
parents a5fc007634c5
children dfac393b2199
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File options.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Manage all options data.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-07-12 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12 ; RATIONALS:
heinrichsweikamp
parents:
diff changeset
13 ;
heinrichsweikamp
parents:
diff changeset
14 ; Provides a centralized file with
heinrichsweikamp
parents:
diff changeset
15
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 263
diff changeset
16 #include "hwos.inc" ; Mandatory header
0
heinrichsweikamp
parents:
diff changeset
17 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "ghostwriter.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
23
heinrichsweikamp
parents:
diff changeset
24 extern write_eeprom
heinrichsweikamp
parents:
diff changeset
25 extern read_eeprom
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
28
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
31 global option_reset ; Reset FSR0 option to factory default.
heinrichsweikamp
parents:
diff changeset
32 global option_save_all ; Save options to EEPROM.
heinrichsweikamp
parents:
diff changeset
33 global option_restore_all ; Restore options from EEPROM.
heinrichsweikamp
parents:
diff changeset
34 global option_inc ; Increment FSR0 option.
heinrichsweikamp
parents:
diff changeset
35 global option_draw ; STRCAT FRS0 option.
heinrichsweikamp
parents:
diff changeset
36
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
37
0
heinrichsweikamp
parents:
diff changeset
38 ;=============================================================================
418
a5fc007634c5 some cleanup
heinrichsweikamp
parents: 275
diff changeset
39 CBLOCK tmp+0x12 ; Reserve space for wordprocessor & convert
0
heinrichsweikamp
parents:
diff changeset
40 opt_type
heinrichsweikamp
parents:
diff changeset
41 opt_default
heinrichsweikamp
parents:
diff changeset
42 opt_inc ; Also default+1 (string), and enum low
heinrichsweikamp
parents:
diff changeset
43 opt_min ; also enum high
heinrichsweikamp
parents:
diff changeset
44 opt_max
heinrichsweikamp
parents:
diff changeset
45 opt_unit:2 ; Multi-lingual unit text.
heinrichsweikamp
parents:
diff changeset
46 opt_eeprom
heinrichsweikamp
parents:
diff changeset
47 opt_backup_tbl:3
418
a5fc007634c5 some cleanup
heinrichsweikamp
parents: 275
diff changeset
48 ; Reserved to tmp+0x1C...
0
heinrichsweikamp
parents:
diff changeset
49 ENDC
heinrichsweikamp
parents:
diff changeset
50
heinrichsweikamp
parents:
diff changeset
51 gui CODE ; Appends to other GUI segment
heinrichsweikamp
parents:
diff changeset
52 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
53 ; Reset all options to factory defauts.
heinrichsweikamp
parents:
diff changeset
54 ;
heinrichsweikamp
parents:
diff changeset
55 ; INPUT: none
heinrichsweikamp
parents:
diff changeset
56 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
57 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2
heinrichsweikamp
parents:
diff changeset
58
heinrichsweikamp
parents:
diff changeset
59 option_reset_all:
heinrichsweikamp
parents:
diff changeset
60 clrf EEADRH
heinrichsweikamp
parents:
diff changeset
61 read_int_eeprom .2
139
e0b758865e91 some cleanup
heinrichsweikamp
parents: 133
diff changeset
62 tstfsz EEDATA ; Total dives=0?
e0b758865e91 some cleanup
heinrichsweikamp
parents: 133
diff changeset
63 bra option_reset_all2 ; No, skip resetting logbook
0
heinrichsweikamp
parents:
diff changeset
64 read_int_eeprom .3
139
e0b758865e91 some cleanup
heinrichsweikamp
parents: 133
diff changeset
65 tstfsz EEDATA ; Total dives=0?
0
heinrichsweikamp
parents:
diff changeset
66 bra option_reset_all2 ; No, skip resetting logbook
heinrichsweikamp
parents:
diff changeset
67
heinrichsweikamp
parents:
diff changeset
68 clrf EEDATA
heinrichsweikamp
parents:
diff changeset
69 write_int_eeprom .4
heinrichsweikamp
parents:
diff changeset
70 write_int_eeprom .5
heinrichsweikamp
parents:
diff changeset
71 write_int_eeprom .6
heinrichsweikamp
parents:
diff changeset
72 write_int_eeprom .2 ; Also, delete total dive counter
heinrichsweikamp
parents:
diff changeset
73 write_int_eeprom .3
heinrichsweikamp
parents:
diff changeset
74 call ext_flash_erase_logbook ; And complete logbook (!)
heinrichsweikamp
parents:
diff changeset
75
heinrichsweikamp
parents:
diff changeset
76 option_reset_all2:
heinrichsweikamp
parents:
diff changeset
77 clrf lo
heinrichsweikamp
parents:
diff changeset
78 clrf hi
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
82 movlw LOW(option_table_begin)
heinrichsweikamp
parents:
diff changeset
83 movwf FSR0L
heinrichsweikamp
parents:
diff changeset
84 movlw HIGH(option_table_begin)
heinrichsweikamp
parents:
diff changeset
85 movwf FSR0H
heinrichsweikamp
parents:
diff changeset
86 option_reset_all_1:
heinrichsweikamp
parents:
diff changeset
87 movf FSR0L,W ; Reached end of table ?
heinrichsweikamp
parents:
diff changeset
88 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max)
heinrichsweikamp
parents:
diff changeset
89 btfsc STATUS,Z ; YES: done.
heinrichsweikamp
parents:
diff changeset
90 return
heinrichsweikamp
parents:
diff changeset
91
heinrichsweikamp
parents:
diff changeset
92 rcall option_reset ; Reset one option.
heinrichsweikamp
parents:
diff changeset
93 bra option_reset_all_1 ; and loop.
heinrichsweikamp
parents:
diff changeset
94
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
118 ; Read option handle
heinrichsweikamp
parents:
diff changeset
119 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
120 ; OUTPUT: FSR1 = address of variable.
heinrichsweikamp
parents:
diff changeset
121 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
heinrichsweikamp
parents:
diff changeset
122 option_read:
heinrichsweikamp
parents:
diff changeset
123 movff FSR0L,TBLPTRL
heinrichsweikamp
parents:
diff changeset
124 movlw HIGH(option_table_begin); Get 8 high bits.
heinrichsweikamp
parents:
diff changeset
125 andlw 0xF0 ; Keep only the 4 highest ones.
heinrichsweikamp
parents:
diff changeset
126 iorwf FSR0H,W ; Cat with the known 4 lower ones.
heinrichsweikamp
parents:
diff changeset
127 movwf TBLPTRH ; And we have the high byte.
heinrichsweikamp
parents:
diff changeset
128 movlw UPPER(option_table_begin)
heinrichsweikamp
parents:
diff changeset
129 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
130
heinrichsweikamp
parents:
diff changeset
131 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
132 tblrd*+
heinrichsweikamp
parents:
diff changeset
133 movff TABLAT,opt_type
heinrichsweikamp
parents:
diff changeset
134 tblrd*+
heinrichsweikamp
parents:
diff changeset
135 movff TABLAT,opt_default
heinrichsweikamp
parents:
diff changeset
136 tblrd*+
heinrichsweikamp
parents:
diff changeset
137 movff TABLAT,opt_inc
heinrichsweikamp
parents:
diff changeset
138 tblrd*+
heinrichsweikamp
parents:
diff changeset
139 movff TABLAT,opt_min
heinrichsweikamp
parents:
diff changeset
140 tblrd*+
heinrichsweikamp
parents:
diff changeset
141 movff TABLAT,opt_max
heinrichsweikamp
parents:
diff changeset
142 tblrd*+
heinrichsweikamp
parents:
diff changeset
143 movff TABLAT,opt_eeprom
heinrichsweikamp
parents:
diff changeset
144 tblrd*+
heinrichsweikamp
parents:
diff changeset
145 movff TABLAT,opt_unit+0
heinrichsweikamp
parents:
diff changeset
146 tblrd*+
heinrichsweikamp
parents:
diff changeset
147 movff TABLAT,opt_unit+1
heinrichsweikamp
parents:
diff changeset
148 tblrd*+
heinrichsweikamp
parents:
diff changeset
149 movff TABLAT,FSR1L
heinrichsweikamp
parents:
diff changeset
150 tblrd*+
heinrichsweikamp
parents:
diff changeset
151 movff TABLAT,FSR1H
heinrichsweikamp
parents:
diff changeset
152 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all
heinrichsweikamp
parents:
diff changeset
153 movff TBLPTRH,FSR0H
heinrichsweikamp
parents:
diff changeset
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
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
171 movf opt_type,W ; Type == ENUM8 ?
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
172 xorlw 1
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
173 bz option_check_enum8 ; ENUM8: Check if lower then max. value only
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
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
ecadc17a028f check opt_max correctly
heinrichsweikamp
parents: 220
diff changeset
184 infsnz opt_max,W ; Max = 255?
ecadc17a028f check opt_max correctly
heinrichsweikamp
parents: 220
diff changeset
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
heinrichsweikamp
parents:
diff changeset
197 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
198 ; Reset an option to its default value.
heinrichsweikamp
parents:
diff changeset
199 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
200 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
201 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2
heinrichsweikamp
parents:
diff changeset
202 ;
heinrichsweikamp
parents:
diff changeset
203 option_reset:
heinrichsweikamp
parents:
diff changeset
204 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
205 rcall option_read
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 ; Switch on type
heinrichsweikamp
parents:
diff changeset
208 movf opt_type,W ; Type == STRING ?
heinrichsweikamp
parents:
diff changeset
209 xorlw 2
heinrichsweikamp
parents:
diff changeset
210 bz opt_reset_string ; YES: special copy
heinrichsweikamp
parents:
diff changeset
211
heinrichsweikamp
parents:
diff changeset
212 movff opt_default,INDF1 ; NO: just a 8bit indirect copy
heinrichsweikamp
parents:
diff changeset
213 return
heinrichsweikamp
parents:
diff changeset
214
heinrichsweikamp
parents:
diff changeset
215 opt_reset_string:
heinrichsweikamp
parents:
diff changeset
216 movff FSR1L,FSR2L ; set string destination address.
heinrichsweikamp
parents:
diff changeset
217 movff FSR1H,FSR2H
heinrichsweikamp
parents:
diff changeset
218
heinrichsweikamp
parents:
diff changeset
219 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1
heinrichsweikamp
parents:
diff changeset
220 movff opt_default+1,FSR1H
heinrichsweikamp
parents:
diff changeset
221
heinrichsweikamp
parents:
diff changeset
222 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine...
heinrichsweikamp
parents:
diff changeset
223 movff TBLPTRH,opt_backup_tbl+1
heinrichsweikamp
parents:
diff changeset
224 movff TBLPTRU,opt_backup_tbl+2
heinrichsweikamp
parents:
diff changeset
225
heinrichsweikamp
parents:
diff changeset
226 call strcat_text ; Copy translated text to FSR2
heinrichsweikamp
parents:
diff changeset
227
heinrichsweikamp
parents:
diff changeset
228 movff opt_backup_tbl+0,TBLPTRL
heinrichsweikamp
parents:
diff changeset
229 movff opt_backup_tbl+1,TBLPTRH
heinrichsweikamp
parents:
diff changeset
230 movff opt_backup_tbl+2,TBLPTRU
heinrichsweikamp
parents:
diff changeset
231
heinrichsweikamp
parents:
diff changeset
232 return
heinrichsweikamp
parents:
diff changeset
233
heinrichsweikamp
parents:
diff changeset
234 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
235 ; Save all options to EEPROM
heinrichsweikamp
parents:
diff changeset
236 option_save_all:
heinrichsweikamp
parents:
diff changeset
237 ;---- Save option serial into EEPROM to detect reset and new version
heinrichsweikamp
parents:
diff changeset
238 movlw LOW(eeprom_serial_save)
heinrichsweikamp
parents:
diff changeset
239 movwf EEADR
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
242 movlw LOW(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
243 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
244 call write_eeprom
heinrichsweikamp
parents:
diff changeset
245 incf EEADR,F
heinrichsweikamp
parents:
diff changeset
246 movlw HIGH(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
247 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
248 call write_eeprom
heinrichsweikamp
parents:
diff changeset
249
heinrichsweikamp
parents:
diff changeset
250 ;---- Save all options
heinrichsweikamp
parents:
diff changeset
251 movlw LOW(option_table_begin)
heinrichsweikamp
parents:
diff changeset
252 movwf FSR0L
heinrichsweikamp
parents:
diff changeset
253 movlw HIGH(option_table_begin)
heinrichsweikamp
parents:
diff changeset
254 movwf FSR0H
heinrichsweikamp
parents:
diff changeset
255
heinrichsweikamp
parents:
diff changeset
256 option_save_all_1:
heinrichsweikamp
parents:
diff changeset
257 movf FSR0L,W ; Reached end of table ?
heinrichsweikamp
parents:
diff changeset
258 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max)
heinrichsweikamp
parents:
diff changeset
259 btfsc STATUS,Z ; YES: done.
heinrichsweikamp
parents:
diff changeset
260 return
heinrichsweikamp
parents:
diff changeset
261
heinrichsweikamp
parents:
diff changeset
262 rcall option_save ; Save one option.
heinrichsweikamp
parents:
diff changeset
263 bra option_save_all_1 ; and loop.
heinrichsweikamp
parents:
diff changeset
264
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 92
diff changeset
265 global option_save
0
heinrichsweikamp
parents:
diff changeset
266 option_save:
heinrichsweikamp
parents:
diff changeset
267 rcall option_read
heinrichsweikamp
parents:
diff changeset
268 incf opt_eeprom,W ; Should we save it ?
heinrichsweikamp
parents:
diff changeset
269 btfsc STATUS,Z ; eeprom address is FFh ?
heinrichsweikamp
parents:
diff changeset
270 return ; YES: nothing to do.
heinrichsweikamp
parents:
diff changeset
271
heinrichsweikamp
parents:
diff changeset
272 movf opt_eeprom,W ; Compute backup address in EEPROM
heinrichsweikamp
parents:
diff changeset
273 addlw LOW(eeprom_opt_backup) ; Add offset
heinrichsweikamp
parents:
diff changeset
274 movwf EEADR
heinrichsweikamp
parents:
diff changeset
275 movlw HIGH(eeprom_opt_backup)
142
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
276 btfsc STATUS,C ; >256
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
277 addlw .1 ; Yes: +1
0
heinrichsweikamp
parents:
diff changeset
278 movwf EEADRH
heinrichsweikamp
parents:
diff changeset
279
heinrichsweikamp
parents:
diff changeset
280 movf opt_type,W ; Option type is string ?
heinrichsweikamp
parents:
diff changeset
281 xorlw 2
heinrichsweikamp
parents:
diff changeset
282 bz option_save_string
heinrichsweikamp
parents:
diff changeset
283
heinrichsweikamp
parents:
diff changeset
284 ; One byte to save to eeprom
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
289
heinrichsweikamp
parents:
diff changeset
290 option_save_string:
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
294 infsnz EEADR,F
heinrichsweikamp
parents:
diff changeset
295 incf EEADRH,F
heinrichsweikamp
parents:
diff changeset
296
heinrichsweikamp
parents:
diff changeset
297 decfsz opt_max ; Decrement string length
heinrichsweikamp
parents:
diff changeset
298 bra option_save_string ; And loop while not finished
heinrichsweikamp
parents:
diff changeset
299
heinrichsweikamp
parents:
diff changeset
300 return
heinrichsweikamp
parents:
diff changeset
301 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
302
heinrichsweikamp
parents:
diff changeset
303 option_restore_all:
heinrichsweikamp
parents:
diff changeset
304 ;---- Read option serial from EEPROM
heinrichsweikamp
parents:
diff changeset
305 movlw LOW(eeprom_serial_save)
heinrichsweikamp
parents:
diff changeset
306 movwf EEADR
heinrichsweikamp
parents:
diff changeset
307 movlw HIGH(eeprom_serial_save)
heinrichsweikamp
parents:
diff changeset
308 movf EEADRH
heinrichsweikamp
parents:
diff changeset
309 call read_eeprom
heinrichsweikamp
parents:
diff changeset
310 movlw LOW(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
311 xorwf EEDATA,W
heinrichsweikamp
parents:
diff changeset
312 bnz option_restore_bad ; Auto reset if changed.
heinrichsweikamp
parents:
diff changeset
313 incf EEADR,F
heinrichsweikamp
parents:
diff changeset
314 call read_eeprom
heinrichsweikamp
parents:
diff changeset
315 movlw HIGH(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
316 xorwf EEDATA,W
heinrichsweikamp
parents:
diff changeset
317 bz option_restore_ok ; Auto reset if changed.
heinrichsweikamp
parents:
diff changeset
318
heinrichsweikamp
parents:
diff changeset
319 option_restore_bad:
heinrichsweikamp
parents:
diff changeset
320 call option_reset_all ; Reset RAM contains
heinrichsweikamp
parents:
diff changeset
321 goto option_save_all ; Then save to EEPROM
heinrichsweikamp
parents:
diff changeset
322
heinrichsweikamp
parents:
diff changeset
323 ;---- Proper restore
heinrichsweikamp
parents:
diff changeset
324 option_restore_ok:
heinrichsweikamp
parents:
diff changeset
325 movlw LOW(option_table_begin)
heinrichsweikamp
parents:
diff changeset
326 movwf FSR0L
heinrichsweikamp
parents:
diff changeset
327 movlw HIGH(option_table_begin)
heinrichsweikamp
parents:
diff changeset
328 movwf FSR0H
heinrichsweikamp
parents:
diff changeset
329
heinrichsweikamp
parents:
diff changeset
330 option_restore_all_1:
heinrichsweikamp
parents:
diff changeset
331 movf FSR0L,W ; Reached end of table ?
heinrichsweikamp
parents:
diff changeset
332 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max)
heinrichsweikamp
parents:
diff changeset
333 btfsc STATUS,Z ; YES: done.
heinrichsweikamp
parents:
diff changeset
334 return
heinrichsweikamp
parents:
diff changeset
335
heinrichsweikamp
parents:
diff changeset
336 rcall option_restore ; Restore one option.
heinrichsweikamp
parents:
diff changeset
337 bra option_restore_all_1 ; and loop.
heinrichsweikamp
parents:
diff changeset
338 return
heinrichsweikamp
parents:
diff changeset
339
heinrichsweikamp
parents:
diff changeset
340 option_restore:
heinrichsweikamp
parents:
diff changeset
341 rcall option_read
heinrichsweikamp
parents:
diff changeset
342 incf opt_eeprom,W ; Should we save it ?
heinrichsweikamp
parents:
diff changeset
343 btfsc STATUS,Z ; eeprom address is FFh ?
heinrichsweikamp
parents:
diff changeset
344 return ; YES: nothing to do.
heinrichsweikamp
parents:
diff changeset
345
heinrichsweikamp
parents:
diff changeset
346 movf opt_eeprom,W ; Compute backup address in EEPROM
heinrichsweikamp
parents:
diff changeset
347 addlw LOW(eeprom_opt_backup) ; Add offset
heinrichsweikamp
parents:
diff changeset
348 movwf EEADR
heinrichsweikamp
parents:
diff changeset
349 movlw HIGH(eeprom_opt_backup)
142
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
350 btfsc STATUS,C ; >256
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
351 addlw .1 ; Yes: +1
0
heinrichsweikamp
parents:
diff changeset
352 movwf EEADRH
heinrichsweikamp
parents:
diff changeset
353
heinrichsweikamp
parents:
diff changeset
354 movf opt_type,W ; Option type is string ?
heinrichsweikamp
parents:
diff changeset
355 xorlw 2
heinrichsweikamp
parents:
diff changeset
356 bz option_restore_string
heinrichsweikamp
parents:
diff changeset
357
heinrichsweikamp
parents:
diff changeset
358 ; Read one byte from eeprom
heinrichsweikamp
parents:
diff changeset
359 call read_eeprom
heinrichsweikamp
parents:
diff changeset
360 movff EEDATA, INDF1 ; And restore option register.
heinrichsweikamp
parents:
diff changeset
361 return
heinrichsweikamp
parents:
diff changeset
362
heinrichsweikamp
parents:
diff changeset
363 option_restore_string:
heinrichsweikamp
parents:
diff changeset
364 call read_eeprom ; Read one byte, and
heinrichsweikamp
parents:
diff changeset
365 movff EEDATA,POSTINC1 ; restore it
heinrichsweikamp
parents:
diff changeset
366 infsnz EEADR,F
heinrichsweikamp
parents:
diff changeset
367 incf EEADRH,F
heinrichsweikamp
parents:
diff changeset
368
heinrichsweikamp
parents:
diff changeset
369 decfsz opt_max ; Decrement string length
heinrichsweikamp
parents:
diff changeset
370 bra option_restore_string ; And loop while not finished
heinrichsweikamp
parents:
diff changeset
371 return
heinrichsweikamp
parents:
diff changeset
372
heinrichsweikamp
parents:
diff changeset
373 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
374 ; Increment an option, based on type, and boundary.
heinrichsweikamp
parents:
diff changeset
375 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
376 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
377 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
heinrichsweikamp
parents:
diff changeset
378 option_inc:
heinrichsweikamp
parents:
diff changeset
379 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
380 rcall option_read
heinrichsweikamp
parents:
diff changeset
381
heinrichsweikamp
parents:
diff changeset
382 ; Switch on type
heinrichsweikamp
parents:
diff changeset
383 movf opt_type,W
heinrichsweikamp
parents:
diff changeset
384 bz option_inc_uint8
heinrichsweikamp
parents:
diff changeset
385 dcfsnz WREG
heinrichsweikamp
parents:
diff changeset
386 bra option_inc_enum8
heinrichsweikamp
parents:
diff changeset
387 dcfsnz WREG
heinrichsweikamp
parents:
diff changeset
388 bra option_inc_string
heinrichsweikamp
parents:
diff changeset
389
heinrichsweikamp
parents:
diff changeset
390 option_inc_uint8: ; Defaults type too...
heinrichsweikamp
parents:
diff changeset
391 movf INDF1,W
heinrichsweikamp
parents:
diff changeset
392 addwf opt_inc,W
heinrichsweikamp
parents:
diff changeset
393 cpfslt opt_max
heinrichsweikamp
parents:
diff changeset
394 bra option_inc_1
heinrichsweikamp
parents:
diff changeset
395 movf opt_min,W
heinrichsweikamp
parents:
diff changeset
396 option_inc_1:
heinrichsweikamp
parents:
diff changeset
397 movwf INDF1
heinrichsweikamp
parents:
diff changeset
398 return
heinrichsweikamp
parents:
diff changeset
399
heinrichsweikamp
parents:
diff changeset
400 option_inc_enum8: ; Always +1
heinrichsweikamp
parents:
diff changeset
401 incf INDF1,W
heinrichsweikamp
parents:
diff changeset
402 cpfsgt opt_max
heinrichsweikamp
parents:
diff changeset
403 clrf WREG
heinrichsweikamp
parents:
diff changeset
404 movwf INDF1
heinrichsweikamp
parents:
diff changeset
405 return
heinrichsweikamp
parents:
diff changeset
406
heinrichsweikamp
parents:
diff changeset
407 option_inc_string: ; No edition yet...
heinrichsweikamp
parents:
diff changeset
408 return
heinrichsweikamp
parents:
diff changeset
409
heinrichsweikamp
parents:
diff changeset
410 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
411 ; Strcat option into FSR2 buffer.
heinrichsweikamp
parents:
diff changeset
412 option_draw:
heinrichsweikamp
parents:
diff changeset
413 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
414 rcall option_read
heinrichsweikamp
parents:
diff changeset
415
heinrichsweikamp
parents:
diff changeset
416 ; Switch on type
heinrichsweikamp
parents:
diff changeset
417 movf opt_type,W
heinrichsweikamp
parents:
diff changeset
418 bz option_draw_uint8
heinrichsweikamp
parents:
diff changeset
419 dcfsnz WREG
heinrichsweikamp
parents:
diff changeset
420 bra option_draw_enum8
heinrichsweikamp
parents:
diff changeset
421 dcfsnz WREG
heinrichsweikamp
parents:
diff changeset
422 bra option_draw_string
heinrichsweikamp
parents:
diff changeset
423 return ; Unknown: return...
heinrichsweikamp
parents:
diff changeset
424
heinrichsweikamp
parents:
diff changeset
425 option_draw_uint8:
heinrichsweikamp
parents:
diff changeset
426 movff INDF1,lo ; Draw value.
263
5a30b5b9ee4a show unit8 options in menu left-aligned
heinrichsweikamp
parents: 222
diff changeset
427 bsf leftbind
0
heinrichsweikamp
parents:
diff changeset
428 output_8
263
5a30b5b9ee4a show unit8 options in menu left-aligned
heinrichsweikamp
parents: 222
diff changeset
429 bcf leftbind
0
heinrichsweikamp
parents:
diff changeset
430 clrf INDF2 ; Make sure to close string...
heinrichsweikamp
parents:
diff changeset
431
heinrichsweikamp
parents:
diff changeset
432 movf opt_unit+0,W ; Is there a unit to append ?
heinrichsweikamp
parents:
diff changeset
433 iorwf opt_unit+1,W
heinrichsweikamp
parents:
diff changeset
434 rcall option_draw_unit
heinrichsweikamp
parents:
diff changeset
435
heinrichsweikamp
parents:
diff changeset
436 movf opt_default,W ; Default value
heinrichsweikamp
parents:
diff changeset
437 cpfseq lo ; Current value
heinrichsweikamp
parents:
diff changeset
438 bra option_draw_uint8_2 ; Not default, add *
heinrichsweikamp
parents:
diff changeset
439 return ; Default, Done.
heinrichsweikamp
parents:
diff changeset
440 option_draw_uint8_2:
heinrichsweikamp
parents:
diff changeset
441 PUTC "*"
heinrichsweikamp
parents:
diff changeset
442 return ; Done.
heinrichsweikamp
parents:
diff changeset
443
heinrichsweikamp
parents:
diff changeset
444 option_draw_unit:
heinrichsweikamp
parents:
diff changeset
445 movff opt_unit+0,FSR1L
heinrichsweikamp
parents:
diff changeset
446 movff opt_unit+1,FSR1H
heinrichsweikamp
parents:
diff changeset
447 goto strcat_text
heinrichsweikamp
parents:
diff changeset
448
heinrichsweikamp
parents:
diff changeset
449
heinrichsweikamp
parents:
diff changeset
450
heinrichsweikamp
parents:
diff changeset
451 ;---- Draw an enumerated value (set of translated strings)
heinrichsweikamp
parents:
diff changeset
452 option_draw_enum8:
heinrichsweikamp
parents:
diff changeset
453 movf INDF1,W ; Get current value.
heinrichsweikamp
parents:
diff changeset
454 cpfsgt opt_max ; Bound value
heinrichsweikamp
parents:
diff changeset
455 clrf WREG
heinrichsweikamp
parents:
diff changeset
456 addwf WREG ; *= 2
heinrichsweikamp
parents:
diff changeset
457 addwf opt_inc,W ; Base text + 2 * value
heinrichsweikamp
parents:
diff changeset
458 movwf FSR1L
heinrichsweikamp
parents:
diff changeset
459 movlw 0
heinrichsweikamp
parents:
diff changeset
460 addwfc opt_min,W ; Propagate carry
heinrichsweikamp
parents:
diff changeset
461 movwf FSR1H ; Into FSR1
heinrichsweikamp
parents:
diff changeset
462
heinrichsweikamp
parents:
diff changeset
463 goto strcat_text
heinrichsweikamp
parents:
diff changeset
464
heinrichsweikamp
parents:
diff changeset
465 option_draw_string:
heinrichsweikamp
parents:
diff changeset
466 movff POSTINC1,POSTINC2
heinrichsweikamp
parents:
diff changeset
467 decfsz opt_max
heinrichsweikamp
parents:
diff changeset
468 bra option_draw_string
heinrichsweikamp
parents:
diff changeset
469 return
heinrichsweikamp
parents:
diff changeset
470
heinrichsweikamp
parents:
diff changeset
471 END