Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_custom.asm @ 161:8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
author | JeanDo |
---|---|
date | Tue, 18 Jan 2011 23:57:33 +0100 |
parents | 6a94f96e9cea |
children | 999abb01c78f |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; Menu "Custom Functions", Custom Functions checker (Displays permanent warning if critical custom functions are altered) | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 05/10/30 | |
97 | 21 ; last updated: 2010/12/11 |
0 | 22 ; known bugs: |
23 ; ToDo: | |
24 | |
25 ;First Bank of Custom Functions: | |
26 ; The custom functions are stored in the internal EEPROM after 0x80 | |
27 ; any custom function occupies 4 byte: | |
28 ; 2 byte (low:high) store the default value, reset from menu "reset" | |
29 ; if bit16=1 then the custrom function is 15bit value, if not it's a 8bit value | |
30 ; 2 byte (low:high) store the actual value | |
31 ; defaults for custom functions are in menu "reset" | |
32 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) | |
33 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) | |
34 | |
35 ;Second Bank of Custom Functions: | |
36 ; The custom functions are stored in the internal EEPROM after 0x180 | |
37 ; any custom function occupies 4 byte: | |
38 ; 2 byte (low:high) store the default value, reset from menu "reset" | |
39 ; if bit16=1 then the custrom function is 15bit value, if not it's a 8bit value | |
40 ; 2 byte (low:high) store the actual value | |
41 ; defaults for custom functions are in menu "reset" | |
42 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) | |
43 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) | |
44 | |
79 | 45 ; [jDG] 2010-11-30 More fancy displsy of the various CF types |
46 ; data types. When we do have a 8bit data (bit16=0), the high byte serves to | |
97 | 47 ; define the display format. Also stores min/max bounds into the PROM table. |
48 ; And provides surfacemode checking of all parameters. | |
79 | 49 |
50 CF_INT8 EQU 0 ; Default display, 8 or 15 bits values. | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
51 CF_PERCENT EQU 1 ; Displays 110% |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
52 CF_DECI EQU 2 ; Displays 1.6 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
53 CF_CENTI EQU 3 ; Displays 1.50 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
54 CF_MILI EQU 4 ; Displays 1.015 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
55 CF_BOOL EQU 5 ; Displays ON/OFF |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
56 CF_SEC EQU 6 ; Displays 4:00 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
57 CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
58 ; |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
59 CF_TYPES EQU 0x1F |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
60 CF_MAX_BIT EQU 6 ; Default is the highest safe value. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
61 CF_MAX EQU (1<<CF_MAX_BIT) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
62 CF_MIN_BIT EQU 5 ; Default is the lowest safe value. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
63 CF_MIN EQU (1<<CF_MIN_BIT) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
64 ; |
79 | 65 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. |
0 | 66 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
67 ; Overlay our tmp data with some unused variables. But use more |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
68 ; meaningfull labels... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
69 cf32_x4 EQU divemins+0 ; CF# modulus 32, time 4. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
70 cf_type EQU divemins+1 ; Type of the edited CF |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
71 cf_value EQU divesecs |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
72 cf_min EQU apnoe_mins |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
73 cf_max EQU apnoe_secs |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
74 |
0 | 75 GETCUSTOM8 macro custom8 |
76 movlw custom8 | |
77 call getcustom8_1 | |
78 endm | |
79 | |
80 getcustom8_1: | |
81 ; # number of requested custom function in wreg | |
82 movwf customfunction_temp2 | |
83 | |
84 movlw d'31' | |
85 cpfsgt customfunction_temp2 | |
86 bra getcustom8_2 ; Lower bank | |
87 | |
88 movlw d'1' ; Upper Bank | |
89 movwf EEADRH | |
90 movlw d'32' | |
91 subwf customfunction_temp2,F | |
92 bra getcustom8_3 | |
93 | |
94 getcustom8_2: | |
95 clrf EEADRH | |
96 getcustom8_3: | |
97 movf customfunction_temp2,W | |
98 mullw d'4' | |
99 movf PRODL,W ; x4 for adress | |
100 addlw d'130' | |
101 movwf EEADR ; +130 for LOW Byte of value | |
102 call read_eeprom ; Lowbyte | |
103 movf EEDATA,W ; copied into wreg | |
104 clrf EEADRH | |
105 return ; return | |
106 | |
107 GETCUSTOM15 macro custom15 | |
108 movlw custom15 | |
109 call getcustom15_1 | |
110 endm | |
111 | |
112 getcustom15_1: | |
113 ; # number of requested custom function in wreg | |
114 movwf customfunction_temp2 | |
115 | |
116 movlw d'31' | |
117 cpfsgt customfunction_temp2 | |
118 bra getcustom15_2 ; Lower bank | |
119 | |
120 movlw d'1' ; Upper Bank | |
121 movwf EEADRH | |
122 movlw d'32' | |
123 subwf customfunction_temp2,F | |
124 bra getcustom15_3 | |
125 getcustom15_2: | |
126 clrf EEADRH | |
127 getcustom15_3: | |
128 movf customfunction_temp2,W | |
129 mullw d'4' | |
130 movf PRODL,W ; x4 for adress | |
131 addlw d'130' | |
132 movwf EEADR ; +130 for LOW Byte of value | |
133 call read_eeprom ; Lowbyte | |
134 movff EEDATA,lo | |
135 incf EEADR,F | |
136 call read_eeprom ; Highbyte | |
137 movff EEDATA,hi | |
138 clrf EEADRH | |
139 return ; return | |
140 | |
141 menu_custom_functions_page2: | |
142 movlw d'154' ; start of custom function descriptors | |
143 movwf customfunction_temp1 | |
7 | 144 bsf customfunction_page ; Use Page II... |
0 | 145 bra menu_custom_functions0 |
146 | |
147 menu_custom_functions: | |
148 movlw d'36' ; start of custom function descriptors | |
149 movwf customfunction_temp1 | |
150 bcf customfunction_page ; Use Page I... | |
151 | |
152 menu_custom_functions0: | |
153 bsf leftbind | |
154 call PLED_ClearScreen | |
155 movlw d'1' | |
156 movwf menupos | |
157 | |
158 bcf menubit4 | |
159 bcf cursor | |
160 bcf sleepmode | |
161 clrf decodata+0 ; here: # of CustomFunction | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
162 clrf cf32_x4 ; here: # of CustomFunction*4 |
0 | 163 bcf first_FA ; here: =1: -, =0: + |
164 bcf second_FA ; here: =1: stepsize 1, =0: stepsize 10 | |
165 | |
166 call PLED_topline_box | |
167 WIN_INVERT .1 ; Init new Wordprocessor | |
168 | |
169 btfss customfunction_page ; | |
170 bra menu_custom_functions10 | |
171 DISPLAYTEXT .186 ; Custom FunctionsII | |
172 bra menu_custom_functions11 | |
173 | |
174 menu_custom_functions10: | |
175 DISPLAYTEXT .27 ; Custom FunctionsI | |
176 | |
177 menu_custom_functions11: | |
178 WIN_INVERT .0 ; Init new Wordprocessor | |
179 | |
180 menu_custom_functions1: | |
123 | 181 call PLED_standard_color ; Trash EEADRH... |
29 | 182 |
123 | 183 movlw d'1' ; So restore it ! |
184 btfss customfunction_page ; Use Page II ? | |
185 movlw d'0' ; NO: this is page 1. | |
7 | 186 movwf EEADRH |
187 | |
0 | 188 clrf timeout_counter2 |
189 bcf menubit2 | |
190 bcf menubit3 | |
191 WIN_LEFT .20 | |
192 WIN_TOP .35 | |
193 lfsr FSR2,letter | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
194 movff decodata+0,lo ; decodata == CF number % 32 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
195 |
0 | 196 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
197 btfsc customfunction_page ; Add offset for display in CF menu II |
0 | 198 movlw d'32' |
199 addwf lo,F | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
200 |
0 | 201 output_99x |
123 | 202 STRCAT_PRINT ": " |
0 | 203 |
204 movf customfunction_temp1,W ; start of custom function descriptors | |
205 addwf decodata+0,W ; add # of current custom function, place result in wreg | |
206 call displaytext1 ; shows descriptor | |
207 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
208 ; Read default, type and min/max from reset table. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
209 rcall cf_read_default |
0 | 210 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
211 movf cf_type,W ; Is it a ON/OFF flag ? |
79 | 212 xorlw CF_BOOL |
213 bnz menu_custom_functions10a ; Not a binary CF selected | |
0 | 214 |
215 menu_custom_functions10c: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
216 ; Erase unused lines when editing boolean... |
79 | 217 WIN_LEFT .20 |
218 WIN_TOP .65 | |
219 lfsr FSR2,letter ; Make a string of 8 spaces | |
84 | 220 call cf_fill_line |
79 | 221 call word_processor ; Clear +/- line |
222 | |
223 WIN_TOP .95 | |
224 call word_processor ; Clear 1/10 line | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
225 |
0 | 226 bra menu_custom_functions10b |
227 | |
228 menu_custom_functions10a: | |
229 WIN_LEFT .20 | |
230 WIN_TOP .65 | |
123 | 231 STRCPY "+/-: " |
0 | 232 movlw '+' |
233 btfsc first_FA | |
234 movlw '-' | |
235 movwf POSTINC2 | |
236 call word_processor | |
237 | |
238 WIN_TOP .95 | |
123 | 239 STRCPY "1/10: 1" |
0 | 240 movlw '0' |
241 btfsc second_FA | |
242 movwf POSTINC2 | |
123 | 243 STRCAT_PRINT " " |
0 | 244 |
79 | 245 menu_custom_functions10b: |
0 | 246 WIN_LEFT .20 |
247 WIN_TOP .125 | |
248 lfsr FSR2,letter | |
249 OUTPUTTEXT d'89' ;"Default:" | |
250 | |
79 | 251 call display_customfunction ; Typed display. |
0 | 252 |
253 WIN_LEFT .20 | |
254 WIN_TOP .155 | |
255 lfsr FSR2,letter | |
256 OUTPUTTEXT d'97' ; "Current:" | |
257 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
258 movf cf32_x4,W |
0 | 259 addlw 0x82 |
260 movwf EEADR | |
261 call read_eeprom ; Lowbyte | |
262 movff EEDATA,lo | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
263 movff EEDATA, cf_value ; Backup low 8bit value. |
79 | 264 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
265 movf cf32_x4,W |
0 | 266 addlw 0x83 |
267 movwf EEADR | |
268 call read_eeprom ; Highbyte | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
269 movff EEDATA,hi |
79 | 270 |
123 | 271 call PLED_standard_color ; Changed by color swatches, but trash EEADRH... |
79 | 272 call display_customfunction |
0 | 273 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
274 ; End of mask: min/max and the exit line... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
275 rcall display_minmax |
0 | 276 DISPLAYTEXT .11 ; Exit |
277 | |
278 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
279 call PLED_menu_cursor | |
280 | |
281 customfunctions_loop: | |
282 call check_switches_logbook | |
283 | |
284 btfsc menubit3 | |
285 bra customfunctions2 ; Move cursor or generate next page | |
286 | |
287 btfsc menubit2 | |
288 bra do_customfunction ; call subfunction | |
289 | |
290 btfsc divemode | |
291 goto restart ; dive started during cf menu | |
292 | |
293 btfsc onesecupdate | |
294 call timeout_surfmode | |
295 | |
296 btfsc onesecupdate | |
297 call set_dive_modes | |
298 | |
299 bcf onesecupdate ; end of 1sek. tasks | |
300 | |
301 btfsc sleepmode | |
302 bra exit_customfunctions | |
303 | |
304 bra customfunctions_loop | |
305 | |
306 customfunctions2: | |
307 incf menupos,F | |
90 | 308 movf cf_type,W ; Are we editing a boolean value ? |
309 xorlw CF_BOOL | |
310 bnz customfunctions2a ; NO : don't skip lines 2/3. | |
84 | 311 |
312 movlw d'4' ; Just after increment, | |
313 cpfsgt menupos ; Is current position < 4 ? | |
314 movwf menupos ; NO: skip set to 4. | |
315 | |
316 customfunctions2a: | |
0 | 317 movlw d'7' |
318 cpfseq menupos ; =7? | |
319 bra customfunctions3 ; No | |
320 movlw d'1' | |
321 movwf menupos | |
322 | |
323 customfunctions3: | |
324 clrf timeout_counter2 | |
325 call PLED_menu_cursor | |
326 | |
327 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
328 | |
329 bcf menubit3 ; clear flag | |
330 bra customfunctions_loop | |
331 | |
79 | 332 ;----------------------------------------------------------------------------- |
94 | 333 ; Read default value, type, and constraints |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
334 ; |
94 | 335 ; Input: customfunction_page, cf32_x4 |
336 ; Output: hi:lo, cf_type, cf_min, cf_max. | |
337 ; Trashes: TBLPTR | |
338 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
339 cf_read_default: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
340 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
341 movwf TBLPTRL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
342 movlw HIGH(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
343 movwf TBLPTRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
344 movlw UPPER(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
345 movwf TBLPTRU |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
346 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
347 movlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
348 btfsc customfunction_page ; Page II CF# ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
349 movlw 0x80 ; YES: add 128 to ptr. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
350 addwf cf32_x4,W ; Add 4 x (CF index modulus 32) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
351 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
352 movlw 0 ; (keep carry) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
353 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
354 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
355 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
356 movff TABLAT,lo ; Low byte --> lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
357 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
358 movff TABLAT,hi ; High byte --> hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
359 btfss hi,7 ; 15bit ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
360 clrf hi ; NO: clear extra type flags |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
361 bcf hi,7 ; clear 15bit flag |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
362 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
363 movff TABLAT,cf_type ; type (high byte) --> cf_type |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
364 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
365 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
366 movff TABLAT,cf_min ; Then get optional min/max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
367 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
368 movff TABLAT,cf_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
369 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
370 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
371 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
372 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
373 ; Display a 8/15bit value, plus optional min and max bound. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
374 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
375 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
376 ; cf_min, cf_max : the optional min/max. |
79 | 377 ; FSR2 = current string pointer. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
378 ; Trash : hi:lo (when displaying min/max) |
79 | 379 |
380 display_customfunction: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
381 movff EEADRH, FSR1H ; Backup... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
382 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
383 rcall display_formated |
123 | 384 incf WREG ; Color swatch drawn ? |
385 bz display_customfunction_1 ; YES: skip line fill... | |
386 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
387 rcall cf_fill_line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
388 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
389 |
123 | 390 display_customfunction_1: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
391 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
392 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
393 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
394 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
395 ; Display optional min/max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
396 ; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max). |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
397 ; Trashed: hi:lo while display min and max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
398 display_minmax: |
99 | 399 ; Min/max unsupported for 15bit values yet... |
79 | 400 movff EEADRH, FSR1H ; Backup... |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
401 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
402 ; Display min line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
403 WIN_TOP .65 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
404 WIN_LEFT .100 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
405 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
406 |
100 | 407 btfsc cf_type,7 ; A 15bit value ? |
408 bra cf_no_min ; Don't display, hence clear line... | |
409 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
410 btfss cf_type, CF_MIN_BIT ; A min value exists ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
411 bra cf_no_min |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
412 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
413 movf cf_min,W ; Retrieve current 8b value |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
414 subwf cf_value,W ; Compute (lo-min) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
415 bc cf_min_passed ; Ok if CARRY, ie. min >= lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
416 call PLED_warnings_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
417 WIN_INVERT 1 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
418 cf_min_passed: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
419 |
123 | 420 STRCAT "> " ; A min value follows |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
421 movff cf_min, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
422 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
423 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
424 cf_no_min: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
425 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
426 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
427 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
428 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
429 ; Display max line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
430 WIN_TOP .95 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
431 call PLED_standard_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
432 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
433 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
434 |
100 | 435 btfsc cf_type,7 ; A 15bit value ? |
436 bra cf_no_max ; Don't display, hence clear line too... | |
437 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
438 btfss cf_type, CF_MAX_BIT ; A max value exists ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
439 bra cf_no_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
440 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
441 movf cf_value,W ; Retrieve current max bound |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
442 subwf cf_max,W ; Compute (max-lo) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
443 bc cf_max_passed ; Ok if no carry, ie. max <= lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
444 call PLED_warnings_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
445 WIN_INVERT 1 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
446 cf_max_passed: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
447 |
123 | 448 STRCAT "< " ; A max value follows |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
449 movff cf_max, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
450 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
451 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
452 cf_no_max: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
453 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
454 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
455 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
456 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
457 cf_minmax_done: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
458 call PLED_standard_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
459 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
460 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
461 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
462 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
463 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
464 ; Display a single 8/15 bit value, according to cf_type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
465 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
466 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
467 ; cf_min, cf_max : the optional min/max. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
468 ; FSR2 = current string pointer. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
469 display_formated: |
79 | 470 |
471 ;---- decode type -------------------------------------------------------- | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
472 movf cf_type,W ; Just set N/Z flags |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
473 bn cf_type_neg ; Keep 15bits value in old format. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
474 andlw CF_TYPES ; Look just at types |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
475 bz cf_type_00 ; 8bit standard mode |
79 | 476 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
477 ; Jump table: ; test the value with cleared flags... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
478 dcfsnz WREG |
79 | 479 bra cf_type_01 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
480 dcfsnz WREG |
79 | 481 bra cf_type_02 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
482 dcfsnz WREG |
79 | 483 bra cf_type_03 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
484 dcfsnz WREG |
79 | 485 bra cf_type_04 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
486 dcfsnz WREG |
79 | 487 bra cf_type_05 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
488 dcfsnz WREG |
79 | 489 bra cf_type_06 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
490 dcfsnz WREG |
79 | 491 bra cf_type_07 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
492 bra cf_type_00 ; Default to 8bit mode... |
79 | 493 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
494 cf_type_01: ; Type == 1 is CF_PERCENT mode |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
495 bcf leftbind |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
496 output_8 |
123 | 497 PUTC '%' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
498 retlw 0 |
79 | 499 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
500 cf_type_02: ; Type == 2 is CF_DECI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
501 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
502 bsf leftbind |
79 | 503 output_16dp 4 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
504 retlw 0 |
79 | 505 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
506 cf_type_03: ; Type == 3 is CF_CENTI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
507 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
508 bsf leftbind |
79 | 509 output_16dp 3 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
510 retlw 0 |
79 | 511 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
512 cf_type_04: ; Type == 4 is CF_MILI mode |
79 | 513 output_16dp 2 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
514 retlw 0 |
79 | 515 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
516 cf_type_05: ; Type == 5 is CF_BOOL mode. |
79 | 517 movf lo,W ; Get flag value... |
518 bz cf_type_off | |
519 OUTPUTTEXT d'130' ; ON | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
520 retlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
521 |
79 | 522 cf_type_off: |
523 OUTPUTTEXT d'131' ; OFF | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
524 retlw 0 |
79 | 525 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
526 cf_type_06: ; Type == 6 is CF_SECS mode (mm:ss or hh:mm) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
527 clrf hi |
79 | 528 call convert_time ; Convert to min:sec into hi:low. |
123 | 529 movff lo,TABLAT ; Save seconds for later. |
79 | 530 movff hi,lo ; Get minutes |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
531 bsf leftbind ; Skip leading space(s). |
79 | 532 output_8 ; Print them |
123 | 533 PUTC ':' ; Separator |
534 movff TABLAT,lo ; Get back seconds | |
79 | 535 output_99x ; lo in 2 digits with trailing zeros. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
536 retlw 0 |
79 | 537 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
538 cf_type_07: ; Type == 7 is CF_COLOR swatch. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
539 bcf leftbind ; Keep leading space (better alignement) |
79 | 540 output_8 |
123 | 541 STRCAT_PRINT " " |
84 | 542 |
79 | 543 movf lo,W ; Get color. |
123 | 544 call PLED_set_color |
545 movlw .23 | |
546 movff WREG,win_height ; row bottom (0-239) | |
79 | 547 movlw .110 |
123 | 548 movff WREG,win_leftx2 ; column left (0-159) |
549 movlw .148-.110+1 | |
550 movff WREG,win_width ; column right (0-159) | |
79 | 551 |
552 call PLED_box | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
553 retlw -1 ; wp already done. Skip it... |
79 | 554 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
555 cf_type_00: ; 8bit mode. Or unrecognized type... |
79 | 556 clrf hi |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
557 bsf leftbind |
79 | 558 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
559 cf_type_neg: ; 15bit mode. |
79 | 560 bcf hi,7 |
561 output_16 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
562 retlw 0 |
84 | 563 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
564 ;----------------------------------------------------------------------------- |
84 | 565 |
566 cf_fill_line: ; Mattias: No flicker if u clear just what you need... | |
567 movf FSR2L,W ; How many chars lefts ? | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
568 sublw (LOW letter) + .18 ; Remaining chars to fill: (letter + 18) - PTR |
84 | 569 btfsc STATUS,N ; Add chars until none left... |
570 return | |
123 | 571 PUTC ' ' |
84 | 572 bra cf_fill_line |
79 | 573 |
574 ;----------------------------------------------------------------------------- | |
0 | 575 |
576 do_customfunction: | |
577 CLRF EEADRH | |
578 movlw d'1' | |
579 btfsc customfunction_page | |
580 movwf EEADRH ; Reset EEADRH correct (Was adjusted in check_timeout...) | |
581 | |
582 dcfsnz menupos,F | |
583 bra next_customfunction | |
584 dcfsnz menupos,F | |
585 bra toggle_plusminus | |
586 dcfsnz menupos,F | |
587 bra toggle_oneorten | |
588 dcfsnz menupos,F | |
589 bra restore_cfn_value | |
590 dcfsnz menupos,F | |
591 bra adjust_cfn_value | |
84 | 592 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
593 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
594 |
0 | 595 exit_customfunctions: |
596 movlw d'2' ; Return to correct list entry | |
597 btfss customfunction_page | |
598 movlw d'1' | |
599 movwf menupos ; | |
600 clrf EEADRH ; Clear EEADRH ! | |
601 goto setup_menu2 ; exit... | |
602 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
603 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
604 |
0 | 605 next_customfunction: |
606 incf decodata+0 | |
607 btfsc decodata+0,5 ;>31? | |
608 clrf decodata+0 ;Yes, so reset to zero | |
609 | |
610 movf decodata+0,W | |
611 mullw d'4' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
612 movff PRODL, cf32_x4 ; 12bit address for correct addressing |
0 | 613 |
614 movlw d'1' | |
615 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
616 bra menu_custom_functions1 ; also debounces switches |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
617 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
618 ;----------------------------------------------------------------------------- |
0 | 619 |
620 toggle_plusminus: | |
621 btg first_FA | |
622 movlw d'2' | |
623 movwf menupos | |
624 bra menu_custom_functions1 ; also debounces switches | |
625 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
626 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
627 |
0 | 628 toggle_oneorten: |
629 btg second_FA | |
630 movlw d'3' | |
631 movwf menupos | |
632 bra menu_custom_functions1 ; also debounces switches | |
633 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
634 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
635 |
0 | 636 restore_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
637 rcall cf_read_default ; hi:lo is trashed by min/max display. |
0 | 638 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
639 movf cf32_x4,W ; store default value |
0 | 640 addlw 0x82 |
641 movwf EEADR | |
642 movff lo,EEDATA | |
643 call write_eeprom ; Lowbyte | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
644 movf cf32_x4,W |
0 | 645 addlw 0x83 |
646 movwf EEADR | |
647 movff hi,EEDATA | |
648 call write_eeprom ; Highbyte | |
649 | |
650 movlw d'4' | |
651 movwf menupos | |
652 bra menu_custom_functions1 ; also debounces switches | |
653 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
654 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
655 ; Adjust current value. |
0 | 656 adjust_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
657 movf cf32_x4,W ; get current value |
0 | 658 addlw 0x82 |
659 movwf EEADR | |
660 call read_eeprom ; Lowbyte | |
661 movff EEDATA,lo | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
662 movf cf32_x4,W |
0 | 663 addlw 0x83 |
664 movwf EEADR | |
665 call read_eeprom ; Highbyte | |
666 movff EEDATA,hi | |
667 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
668 movf cf_type,W |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
669 xorlw CF_BOOL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
670 bnz adjust_cfn_value1 |
0 | 671 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
672 btg lo,0 ; Change lower bit. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
673 bra adjust_cfn_value3 ; Store result |
0 | 674 |
675 adjust_cfn_value1: | |
676 movlw d'1' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
677 btfsc second_FA ; -10? |
0 | 678 movlw d'10' |
679 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
680 btfss first_FA ; Minus? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
681 bra adjust_cfn_value2 ; No, Plus |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
682 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
683 subwf lo,F ; substract value |
0 | 684 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
685 btfsc cf_type,7 ; 8Bit value |
0 | 686 subwfb hi,F |
687 | |
688 movlw b'01111111' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
689 btfsc hi,7 ; >32768? |
0 | 690 movwf hi |
691 | |
692 bra adjust_cfn_value3 | |
693 | |
694 adjust_cfn_value2: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
695 addwf lo,F ; add value |
0 | 696 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
697 btfsc cf_type,7 ; 8Bit value? |
0 | 698 addwfc hi,F |
699 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
700 btfsc hi,7 ; >32768? |
0 | 701 clrf hi |
702 | |
703 adjust_cfn_value3: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
704 movf cf32_x4,W ; Store current value |
0 | 705 addlw 0x82 |
706 movwf EEADR | |
707 movff lo,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
708 call write_eeprom ; Lowbyte |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
709 movf cf32_x4,W |
0 | 710 addlw 0x83 |
711 movwf EEADR | |
712 movff hi,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
713 call write_eeprom ; Highbyte |
0 | 714 movlw d'5' |
715 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
716 bra menu_custom_functions1 ; also debounces switches |
94 | 717 |
718 ;----------------------------------------------------------------------------- | |
719 ; Check all CF values that have max and min constraints. | |
720 ; Input: cf_checker_counter. | |
721 ; Output: Pop warning with the first CF number if bad. | |
722 ; cf_checker_counter incremented. | |
723 ; Trashes: TBLPTR, EEADR, PROD | |
100 | 724 ; |
725 ; Note: the trick here is to do two sweep over the 64 CF values, to make sure | |
726 ; they are all ok. | |
94 | 727 |
728 check_customfunctions: | |
100 | 729 ; Did we finished the two sweeps ? |
730 btfsc cf_checker_counter,7 ; Already at position 128 ? | |
731 return ; YES: just do nothing. | |
94 | 732 |
733 ; Setup cf32_x4 and cf page bit: | |
100 | 734 movf cf_checker_counter,W |
94 | 735 rlcf WREG ; x4 |
736 rlcf WREG | |
737 bcf customfunction_page | |
738 btfsc WREG,7 | |
100 | 739 bsf customfunction_page ; Setup CF page bit. |
94 | 740 andlw 4*.31 |
741 movwf cf32_x4 | |
742 | |
743 ; Do the check | |
744 rcall check_one_cf | |
100 | 745 iorwf WREG ; Test return value. |
746 bz check_failed ; 0 == FAILED. | |
747 | |
748 ; Passed: Simple loop until 128 is reached: | |
749 incf cf_checker_counter ; Next CF to check. | |
750 bra check_customfunctions ; And loop until 128 reached (ie twice) | |
94 | 751 |
100 | 752 check_failed: |
753 movlw .63 ; Make sure number is back to range 0..63 | |
754 andwf cf_checker_counter,F | |
755 | |
756 ; Went wrong: draw the warning line... | |
757 WIN_TOP .200 | |
758 WIN_LEFT .80 - (6*.7)/2 ; Center 8 chars of width 14pix. | |
759 WIN_FONT FT_SMALL | |
760 WIN_INVERT .1 ; Init new Wordprocessor | |
761 call PLED_warnings_color | |
762 | |
123 | 763 STRCPY " CF" |
100 | 764 movff cf_checker_counter,lo |
765 output_99x | |
123 | 766 STRCAT_PRINT " " |
94 | 767 |
100 | 768 ; When failed, increment counter modulo 64, to restart checks. |
769 incf cf_checker_counter,W | |
770 andlw .63 ; Modulo 64 | |
94 | 771 movwf cf_checker_counter |
772 return | |
773 | |
774 ; Check one CF value --------------------------------------------------------- | |
775 check_one_cf: | |
776 rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. | |
777 | |
100 | 778 btfsc cf_type,7 ; A 15bit type ? |
779 bra check_cf_check ; Then we have to check it... | |
780 | |
781 movf cf_type,W ; 8bit MIN or MAX set ? | |
94 | 782 andlw (CF_MIN + CF_MAX) |
783 bnz check_cf_check ; yes: do something. | |
100 | 784 retlw -1 ; no: no problem then. |
94 | 785 |
786 ; It does have bound: | |
787 check_cf_check: | |
100 | 788 movf cf_checker_counter,W ; Get current CF number |
789 andlw .63 ; Keep range 0..63 | |
94 | 790 |
791 btfss cf_type,7 ; 15 or 8 bit value ? | |
792 bra cf_check_8bit | |
793 | |
99 | 794 ; Implement the 15bit check, even if not displayed... |
94 | 795 rcall getcustom15_1 ; Read into hi:lo |
796 | |
797 movf cf_min,W ; Compute (bound-value) -> hi:lo | |
798 subwf lo,F | |
799 movf cf_max,W | |
100 | 800 bcf WREG,7 ; Clear min/max bit |
94 | 801 subwfb hi,F |
802 | |
803 movf lo,W ; Is it a 0 result ? | |
804 iorwf hi,W | |
805 bnz cf_15_not_equal ; NO: check sign. | |
806 retlw -1 ; YES: then it is ok. | |
807 | |
808 cf_15_not_equal: | |
99 | 809 btfss cf_max,7 ; Checking min or max ? |
94 | 810 btg hi,6 ; exchange wanted sign |
811 | |
812 btfss hi,6 ; Is sign correct ? | |
100 | 813 retlw 0 ; NO: return failed. |
814 retlw -1 ; YES: return passed. | |
94 | 815 |
816 ; Do a 8bit check | |
817 cf_check_8bit: | |
818 rcall getcustom8_1 ; Read into WREG | |
819 movwf lo ; Save it. | |
820 | |
821 btfss cf_type,CF_MIN_BIT | |
822 bra check_no_min | |
823 | |
824 cpfsgt cf_min ; Compare to cf_min | |
100 | 825 bra check_no_min ; PASSED: continue. |
826 retlw 0 ; NO: return failed. | |
94 | 827 |
828 check_no_min: | |
100 | 829 btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ? |
830 retlw -1 ; No check: return OK. | |
94 | 831 |
832 movf lo,W ; Compute value-max | |
833 cpfslt cf_max | |
100 | 834 retlw -1 ; Bound met: return OK. |
835 retlw 0 ; NO: return failed. |