annotate src/options.asm @ 580:1ab93aca7fa9

2.97 work...
author heinrichsweikamp
date Wed, 21 Feb 2018 19:30:28 +0100
parents 8b7ea27ea1fa
children b455b31ce022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
3 ; File options.asm REFACTORED VERSION V2.91
0
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:
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
heinrichsweikamp
parents:
diff changeset
95 rcall option_reset ; Reset one option.
heinrichsweikamp
parents:
diff changeset
96 bra option_reset_all_1 ; and loop.
heinrichsweikamp
parents:
diff changeset
97
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
124 ; Read option handle
heinrichsweikamp
parents:
diff changeset
125 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
126 ; OUTPUT: FSR1 = address of variable.
heinrichsweikamp
parents:
diff changeset
127 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
heinrichsweikamp
parents:
diff changeset
128 option_read:
heinrichsweikamp
parents:
diff changeset
129 movff FSR0L,TBLPTRL
heinrichsweikamp
parents:
diff changeset
130 movlw HIGH(option_table_begin); Get 8 high bits.
heinrichsweikamp
parents:
diff changeset
131 andlw 0xF0 ; Keep only the 4 highest ones.
heinrichsweikamp
parents:
diff changeset
132 iorwf FSR0H,W ; Cat with the known 4 lower ones.
heinrichsweikamp
parents:
diff changeset
133 movwf TBLPTRH ; And we have the high byte.
heinrichsweikamp
parents:
diff changeset
134 movlw UPPER(option_table_begin)
heinrichsweikamp
parents:
diff changeset
135 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
136
heinrichsweikamp
parents:
diff changeset
137 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
138 tblrd*+
heinrichsweikamp
parents:
diff changeset
139 movff TABLAT,opt_type
heinrichsweikamp
parents:
diff changeset
140 tblrd*+
heinrichsweikamp
parents:
diff changeset
141 movff TABLAT,opt_default
heinrichsweikamp
parents:
diff changeset
142 tblrd*+
heinrichsweikamp
parents:
diff changeset
143 movff TABLAT,opt_inc
heinrichsweikamp
parents:
diff changeset
144 tblrd*+
heinrichsweikamp
parents:
diff changeset
145 movff TABLAT,opt_min
heinrichsweikamp
parents:
diff changeset
146 tblrd*+
heinrichsweikamp
parents:
diff changeset
147 movff TABLAT,opt_max
heinrichsweikamp
parents:
diff changeset
148 tblrd*+
heinrichsweikamp
parents:
diff changeset
149 movff TABLAT,opt_eeprom
heinrichsweikamp
parents:
diff changeset
150 tblrd*+
heinrichsweikamp
parents:
diff changeset
151 movff TABLAT,opt_unit+0
heinrichsweikamp
parents:
diff changeset
152 tblrd*+
heinrichsweikamp
parents:
diff changeset
153 movff TABLAT,opt_unit+1
heinrichsweikamp
parents:
diff changeset
154 tblrd*+
heinrichsweikamp
parents:
diff changeset
155 movff TABLAT,FSR1L
heinrichsweikamp
parents:
diff changeset
156 tblrd*+
heinrichsweikamp
parents:
diff changeset
157 movff TABLAT,FSR1H
heinrichsweikamp
parents:
diff changeset
158 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all
heinrichsweikamp
parents:
diff changeset
159 movff TBLPTRH,FSR0H
heinrichsweikamp
parents:
diff changeset
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
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
177 movf opt_type,W ; Type == ENUM8 ?
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
178 xorlw 1
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
179 bz option_check_enum8 ; ENUM8: Check if lower then max. value only
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 104
diff changeset
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
ecadc17a028f check opt_max correctly
heinrichsweikamp
parents: 220
diff changeset
190 infsnz opt_max,W ; Max = 255?
ecadc17a028f check opt_max correctly
heinrichsweikamp
parents: 220
diff changeset
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
heinrichsweikamp
parents:
diff changeset
203 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
204 ; Reset an option to its default value.
heinrichsweikamp
parents:
diff changeset
205 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
206 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
207 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2
heinrichsweikamp
parents:
diff changeset
208 ;
heinrichsweikamp
parents:
diff changeset
209 option_reset:
heinrichsweikamp
parents:
diff changeset
210 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
211 rcall option_read
heinrichsweikamp
parents:
diff changeset
212
heinrichsweikamp
parents:
diff changeset
213 ; Switch on type
heinrichsweikamp
parents:
diff changeset
214 movf opt_type,W ; Type == STRING ?
heinrichsweikamp
parents:
diff changeset
215 xorlw 2
heinrichsweikamp
parents:
diff changeset
216 bz opt_reset_string ; YES: special copy
heinrichsweikamp
parents:
diff changeset
217
heinrichsweikamp
parents:
diff changeset
218 movff opt_default,INDF1 ; NO: just a 8bit indirect copy
heinrichsweikamp
parents:
diff changeset
219 return
heinrichsweikamp
parents:
diff changeset
220
heinrichsweikamp
parents:
diff changeset
221 opt_reset_string:
heinrichsweikamp
parents:
diff changeset
222 movff FSR1L,FSR2L ; set string destination address.
heinrichsweikamp
parents:
diff changeset
223 movff FSR1H,FSR2H
heinrichsweikamp
parents:
diff changeset
224
heinrichsweikamp
parents:
diff changeset
225 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1
heinrichsweikamp
parents:
diff changeset
226 movff opt_default+1,FSR1H
heinrichsweikamp
parents:
diff changeset
227
heinrichsweikamp
parents:
diff changeset
228 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine...
heinrichsweikamp
parents:
diff changeset
229 movff TBLPTRH,opt_backup_tbl+1
heinrichsweikamp
parents:
diff changeset
230 movff TBLPTRU,opt_backup_tbl+2
heinrichsweikamp
parents:
diff changeset
231
heinrichsweikamp
parents:
diff changeset
232 call strcat_text ; Copy translated text to FSR2
heinrichsweikamp
parents:
diff changeset
233
heinrichsweikamp
parents:
diff changeset
234 movff opt_backup_tbl+0,TBLPTRL
heinrichsweikamp
parents:
diff changeset
235 movff opt_backup_tbl+1,TBLPTRH
heinrichsweikamp
parents:
diff changeset
236 movff opt_backup_tbl+2,TBLPTRU
heinrichsweikamp
parents:
diff changeset
237
heinrichsweikamp
parents:
diff changeset
238 return
heinrichsweikamp
parents:
diff changeset
239
heinrichsweikamp
parents:
diff changeset
240 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
241 ; Save all options to EEPROM
heinrichsweikamp
parents:
diff changeset
242 option_save_all:
heinrichsweikamp
parents:
diff changeset
243 ;---- Save option serial into EEPROM to detect reset and new version
heinrichsweikamp
parents:
diff changeset
244 movlw LOW(eeprom_serial_save)
heinrichsweikamp
parents:
diff changeset
245 movwf EEADR
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
248 movlw LOW(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
249 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
250 call write_eeprom
heinrichsweikamp
parents:
diff changeset
251 incf EEADR,F
heinrichsweikamp
parents:
diff changeset
252 movlw HIGH(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
253 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
254 call write_eeprom
heinrichsweikamp
parents:
diff changeset
255
heinrichsweikamp
parents:
diff changeset
256 ;---- Save all options
heinrichsweikamp
parents:
diff changeset
257 movlw LOW(option_table_begin)
heinrichsweikamp
parents:
diff changeset
258 movwf FSR0L
heinrichsweikamp
parents:
diff changeset
259 movlw HIGH(option_table_begin)
heinrichsweikamp
parents:
diff changeset
260 movwf FSR0H
heinrichsweikamp
parents:
diff changeset
261
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
271 rcall option_save ; Save one option.
heinrichsweikamp
parents:
diff changeset
272 bra option_save_all_1 ; and loop.
heinrichsweikamp
parents:
diff changeset
273
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 92
diff changeset
274 global option_save
0
heinrichsweikamp
parents:
diff changeset
275 option_save:
heinrichsweikamp
parents:
diff changeset
276 rcall option_read
heinrichsweikamp
parents:
diff changeset
277 incf opt_eeprom,W ; Should we save it ?
heinrichsweikamp
parents:
diff changeset
278 btfsc STATUS,Z ; eeprom address is FFh ?
heinrichsweikamp
parents:
diff changeset
279 return ; YES: nothing to do.
heinrichsweikamp
parents:
diff changeset
280
heinrichsweikamp
parents:
diff changeset
281 movf opt_eeprom,W ; Compute backup address in EEPROM
heinrichsweikamp
parents:
diff changeset
282 addlw LOW(eeprom_opt_backup) ; Add offset
heinrichsweikamp
parents:
diff changeset
283 movwf EEADR
heinrichsweikamp
parents:
diff changeset
284 movlw HIGH(eeprom_opt_backup)
142
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
285 btfsc STATUS,C ; >256
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
286 addlw .1 ; Yes: +1
0
heinrichsweikamp
parents:
diff changeset
287 movwf EEADRH
heinrichsweikamp
parents:
diff changeset
288
heinrichsweikamp
parents:
diff changeset
289 movf opt_type,W ; Option type is string ?
heinrichsweikamp
parents:
diff changeset
290 xorlw 2
heinrichsweikamp
parents:
diff changeset
291 bz option_save_string
heinrichsweikamp
parents:
diff changeset
292
heinrichsweikamp
parents:
diff changeset
293 ; One byte to save to eeprom
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
298
heinrichsweikamp
parents:
diff changeset
299 option_save_string:
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
303 infsnz EEADR,F
heinrichsweikamp
parents:
diff changeset
304 incf EEADRH,F
heinrichsweikamp
parents:
diff changeset
305
heinrichsweikamp
parents:
diff changeset
306 decfsz opt_max ; Decrement string length
heinrichsweikamp
parents:
diff changeset
307 bra option_save_string ; And loop while not finished
heinrichsweikamp
parents:
diff changeset
308
heinrichsweikamp
parents:
diff changeset
309 return
heinrichsweikamp
parents:
diff changeset
310 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
311
heinrichsweikamp
parents:
diff changeset
312 option_restore_all:
heinrichsweikamp
parents:
diff changeset
313 ;---- Read option serial from EEPROM
heinrichsweikamp
parents:
diff changeset
314 movlw LOW(eeprom_serial_save)
heinrichsweikamp
parents:
diff changeset
315 movwf EEADR
heinrichsweikamp
parents:
diff changeset
316 movlw HIGH(eeprom_serial_save)
heinrichsweikamp
parents:
diff changeset
317 movf EEADRH
heinrichsweikamp
parents:
diff changeset
318 call read_eeprom
heinrichsweikamp
parents:
diff changeset
319 movlw LOW(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
320 xorwf EEDATA,W
heinrichsweikamp
parents:
diff changeset
321 bnz option_restore_bad ; Auto reset if changed.
heinrichsweikamp
parents:
diff changeset
322 incf EEADR,F
heinrichsweikamp
parents:
diff changeset
323 call read_eeprom
heinrichsweikamp
parents:
diff changeset
324 movlw HIGH(eeprom_opt_serial)
heinrichsweikamp
parents:
diff changeset
325 xorwf EEDATA,W
heinrichsweikamp
parents:
diff changeset
326 bz option_restore_ok ; Auto reset if changed.
heinrichsweikamp
parents:
diff changeset
327
heinrichsweikamp
parents:
diff changeset
328 option_restore_bad:
heinrichsweikamp
parents:
diff changeset
329 call option_reset_all ; Reset RAM contains
heinrichsweikamp
parents:
diff changeset
330 goto option_save_all ; Then save to EEPROM
heinrichsweikamp
parents:
diff changeset
331
heinrichsweikamp
parents:
diff changeset
332 ;---- Proper restore
heinrichsweikamp
parents:
diff changeset
333 option_restore_ok:
heinrichsweikamp
parents:
diff changeset
334 movlw LOW(option_table_begin)
heinrichsweikamp
parents:
diff changeset
335 movwf FSR0L
heinrichsweikamp
parents:
diff changeset
336 movlw HIGH(option_table_begin)
heinrichsweikamp
parents:
diff changeset
337 movwf FSR0H
heinrichsweikamp
parents:
diff changeset
338
heinrichsweikamp
parents:
diff changeset
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
heinrichsweikamp
parents:
diff changeset
348 rcall option_restore ; Restore one option.
heinrichsweikamp
parents:
diff changeset
349 bra option_restore_all_1 ; and loop.
heinrichsweikamp
parents:
diff changeset
350
heinrichsweikamp
parents:
diff changeset
351 option_restore:
heinrichsweikamp
parents:
diff changeset
352 rcall option_read
heinrichsweikamp
parents:
diff changeset
353 incf opt_eeprom,W ; Should we save it ?
heinrichsweikamp
parents:
diff changeset
354 btfsc STATUS,Z ; eeprom address is FFh ?
heinrichsweikamp
parents:
diff changeset
355 return ; YES: nothing to do.
heinrichsweikamp
parents:
diff changeset
356
heinrichsweikamp
parents:
diff changeset
357 movf opt_eeprom,W ; Compute backup address in EEPROM
heinrichsweikamp
parents:
diff changeset
358 addlw LOW(eeprom_opt_backup) ; Add offset
heinrichsweikamp
parents:
diff changeset
359 movwf EEADR
heinrichsweikamp
parents:
diff changeset
360 movlw HIGH(eeprom_opt_backup)
142
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
361 btfsc STATUS,C ; >256
8531f39eb70a option_read and option_write eeprom banking
mh@mh-THINK
parents: 139
diff changeset
362 addlw .1 ; Yes: +1
0
heinrichsweikamp
parents:
diff changeset
363 movwf EEADRH
heinrichsweikamp
parents:
diff changeset
364
heinrichsweikamp
parents:
diff changeset
365 movf opt_type,W ; Option type is string ?
heinrichsweikamp
parents:
diff changeset
366 xorlw 2
heinrichsweikamp
parents:
diff changeset
367 bz option_restore_string
heinrichsweikamp
parents:
diff changeset
368
heinrichsweikamp
parents:
diff changeset
369 ; Read one byte from eeprom
heinrichsweikamp
parents:
diff changeset
370 call read_eeprom
heinrichsweikamp
parents:
diff changeset
371 movff EEDATA, INDF1 ; And restore option register.
heinrichsweikamp
parents:
diff changeset
372 return
heinrichsweikamp
parents:
diff changeset
373
heinrichsweikamp
parents:
diff changeset
374 option_restore_string:
heinrichsweikamp
parents:
diff changeset
375 call read_eeprom ; Read one byte, and
heinrichsweikamp
parents:
diff changeset
376 movff EEDATA,POSTINC1 ; restore it
heinrichsweikamp
parents:
diff changeset
377 infsnz EEADR,F
heinrichsweikamp
parents:
diff changeset
378 incf EEADRH,F
heinrichsweikamp
parents:
diff changeset
379
heinrichsweikamp
parents:
diff changeset
380 decfsz opt_max ; Decrement string length
heinrichsweikamp
parents:
diff changeset
381 bra option_restore_string ; And loop while not finished
heinrichsweikamp
parents:
diff changeset
382 return
heinrichsweikamp
parents:
diff changeset
383
heinrichsweikamp
parents:
diff changeset
384 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
385 ; Increment an option, based on type, and boundary.
heinrichsweikamp
parents:
diff changeset
386 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
387 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
388 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
heinrichsweikamp
parents:
diff changeset
389 option_inc:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
390 ; Read type, default and register from table
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
391 rcall option_read
0
heinrichsweikamp
parents:
diff changeset
392
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
393 ; Switch on type
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
394 movf opt_type,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
395 bz option_inc_uint8
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
396 dcfsnz WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
397 bra option_inc_enum8
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
398 dcfsnz WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
399 bra option_inc_string
0
heinrichsweikamp
parents:
diff changeset
400
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
401
0
heinrichsweikamp
parents:
diff changeset
402 option_inc_uint8: ; Defaults type too...
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
403 movf INDF1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
404 addwf opt_inc,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
405 cpfslt opt_max
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
406 bra option_inc_1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
407 movf opt_min,W
0
heinrichsweikamp
parents:
diff changeset
408 option_inc_1:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
409 movwf INDF1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
410
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
411 ; NEW FROM HERE... ## voting logic (allow sensors for pSCR)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
412 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
413 movlw .25 ; eeprom address of option oCCRMode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
414 cpfseq opt_eeprom ; skip next line if we deal with this option right now
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
415 bra option_inc_2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
416 btfsc FLAG_pscr_mode ; skip next line if we are not in PSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
417 bcf opt_ccr_mode,1 ; in pSCR mode, opt_ccr_mode may only be 0 or 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
418
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
419 option_inc_2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
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
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 533
diff changeset
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
heinrichsweikamp
parents:
diff changeset
434
heinrichsweikamp
parents:
diff changeset
435 option_inc_enum8: ; Always +1
heinrichsweikamp
parents:
diff changeset
436 incf INDF1,W
heinrichsweikamp
parents:
diff changeset
437 cpfsgt opt_max
heinrichsweikamp
parents:
diff changeset
438 clrf WREG
heinrichsweikamp
parents:
diff changeset
439 movwf INDF1
heinrichsweikamp
parents:
diff changeset
440 return
heinrichsweikamp
parents:
diff changeset
441
heinrichsweikamp
parents:
diff changeset
442 option_inc_string: ; No edition yet...
heinrichsweikamp
parents:
diff changeset
443 return
heinrichsweikamp
parents:
diff changeset
444
heinrichsweikamp
parents:
diff changeset
445 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
446 ; Strcat option into FSR2 buffer.
heinrichsweikamp
parents:
diff changeset
447 option_draw:
heinrichsweikamp
parents:
diff changeset
448 ; Read type, default and register from table
heinrichsweikamp
parents:
diff changeset
449 rcall option_read
heinrichsweikamp
parents:
diff changeset
450
heinrichsweikamp
parents:
diff changeset
451 ; Switch on type
heinrichsweikamp
parents:
diff changeset
452 movf opt_type,W
heinrichsweikamp
parents:
diff changeset
453 bz option_draw_uint8
heinrichsweikamp
parents:
diff changeset
454 dcfsnz WREG
heinrichsweikamp
parents:
diff changeset
455 bra option_draw_enum8
heinrichsweikamp
parents:
diff changeset
456 dcfsnz WREG
heinrichsweikamp
parents:
diff changeset
457 bra option_draw_string
heinrichsweikamp
parents:
diff changeset
458 return ; Unknown: return...
heinrichsweikamp
parents:
diff changeset
459
heinrichsweikamp
parents:
diff changeset
460 option_draw_uint8:
heinrichsweikamp
parents:
diff changeset
461 movff INDF1,lo ; Draw value.
263
5a30b5b9ee4a show unit8 options in menu left-aligned
heinrichsweikamp
parents: 222
diff changeset
462 bsf leftbind
0
heinrichsweikamp
parents:
diff changeset
463 output_8
263
5a30b5b9ee4a show unit8 options in menu left-aligned
heinrichsweikamp
parents: 222
diff changeset
464 bcf leftbind
0
heinrichsweikamp
parents:
diff changeset
465 clrf INDF2 ; Make sure to close string...
heinrichsweikamp
parents:
diff changeset
466
heinrichsweikamp
parents:
diff changeset
467 movf opt_unit+0,W ; Is there a unit to append ?
heinrichsweikamp
parents:
diff changeset
468 iorwf opt_unit+1,W
heinrichsweikamp
parents:
diff changeset
469 rcall option_draw_unit
heinrichsweikamp
parents:
diff changeset
470
heinrichsweikamp
parents:
diff changeset
471 movf opt_default,W ; Default value
heinrichsweikamp
parents:
diff changeset
472 cpfseq lo ; Current value
heinrichsweikamp
parents:
diff changeset
473 bra option_draw_uint8_2 ; Not default, add *
heinrichsweikamp
parents:
diff changeset
474 return ; Default, Done.
heinrichsweikamp
parents:
diff changeset
475 option_draw_uint8_2:
heinrichsweikamp
parents:
diff changeset
476 PUTC "*"
heinrichsweikamp
parents:
diff changeset
477 return ; Done.
heinrichsweikamp
parents:
diff changeset
478
heinrichsweikamp
parents:
diff changeset
479 option_draw_unit:
heinrichsweikamp
parents:
diff changeset
480 movff opt_unit+0,FSR1L
heinrichsweikamp
parents:
diff changeset
481 movff opt_unit+1,FSR1H
heinrichsweikamp
parents:
diff changeset
482 goto strcat_text
heinrichsweikamp
parents:
diff changeset
483
heinrichsweikamp
parents:
diff changeset
484
heinrichsweikamp
parents:
diff changeset
485
heinrichsweikamp
parents:
diff changeset
486 ;---- Draw an enumerated value (set of translated strings)
heinrichsweikamp
parents:
diff changeset
487 option_draw_enum8:
heinrichsweikamp
parents:
diff changeset
488 movf INDF1,W ; Get current value.
heinrichsweikamp
parents:
diff changeset
489 cpfsgt opt_max ; Bound value
heinrichsweikamp
parents:
diff changeset
490 clrf WREG
heinrichsweikamp
parents:
diff changeset
491 addwf WREG ; *= 2
heinrichsweikamp
parents:
diff changeset
492 addwf opt_inc,W ; Base text + 2 * value
heinrichsweikamp
parents:
diff changeset
493 movwf FSR1L
heinrichsweikamp
parents:
diff changeset
494 movlw 0
heinrichsweikamp
parents:
diff changeset
495 addwfc opt_min,W ; Propagate carry
heinrichsweikamp
parents:
diff changeset
496 movwf FSR1H ; Into FSR1
heinrichsweikamp
parents:
diff changeset
497
heinrichsweikamp
parents:
diff changeset
498 goto strcat_text
heinrichsweikamp
parents:
diff changeset
499
heinrichsweikamp
parents:
diff changeset
500 option_draw_string:
heinrichsweikamp
parents:
diff changeset
501 movff POSTINC1,POSTINC2
heinrichsweikamp
parents:
diff changeset
502 decfsz opt_max
heinrichsweikamp
parents:
diff changeset
503 bra option_draw_string
heinrichsweikamp
parents:
diff changeset
504 return
heinrichsweikamp
parents:
diff changeset
505
heinrichsweikamp
parents:
diff changeset
506 END