annotate src/options.asm @ 595:1719de53e497

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