Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_custom.asm @ 99:39d325b2a5f9
FIX bad warning for 15bits CF values
author | JeanDo |
---|---|
date | Sun, 12 Dec 2010 16:47:32 +0100 |
parents | dc349e4264bb |
children | db4a20b413df |
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: | |
29 | 181 call PLED_standard_color |
182 | |
7 | 183 movlw d'1' |
184 btfss customfunction_page ; Use Page II... | |
185 movlw d'0' | |
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 |
202 movlw ':' | |
203 movwf POSTINC2 | |
204 movlw ' ' | |
205 movwf POSTINC2 | |
206 call word_processor | |
207 | |
208 movf customfunction_temp1,W ; start of custom function descriptors | |
209 addwf decodata+0,W ; add # of current custom function, place result in wreg | |
210 call displaytext1 ; shows descriptor | |
211 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
212 ; Read default, type and min/max from reset table. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
213 rcall cf_read_default |
0 | 214 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
215 movf cf_type,W ; Is it a ON/OFF flag ? |
79 | 216 xorlw CF_BOOL |
217 bnz menu_custom_functions10a ; Not a binary CF selected | |
0 | 218 |
219 menu_custom_functions10c: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
220 ; Erase unused lines when editing boolean... |
79 | 221 WIN_LEFT .20 |
222 WIN_TOP .65 | |
223 lfsr FSR2,letter ; Make a string of 8 spaces | |
84 | 224 call cf_fill_line |
79 | 225 call word_processor ; Clear +/- line |
226 | |
227 WIN_TOP .95 | |
228 call word_processor ; Clear 1/10 line | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
229 |
0 | 230 bra menu_custom_functions10b |
231 | |
232 menu_custom_functions10a: | |
233 WIN_LEFT .20 | |
234 WIN_TOP .65 | |
235 lfsr FSR2,letter | |
236 movlw '+' | |
237 movwf POSTINC2 | |
238 movlw '/' | |
239 movwf POSTINC2 | |
240 movlw '-' | |
241 movwf POSTINC2 | |
242 movlw ':' | |
243 movwf POSTINC2 | |
244 movlw ' ' | |
245 movwf POSTINC2 | |
246 movlw '+' | |
247 btfsc first_FA | |
248 movlw '-' | |
249 movwf POSTINC2 | |
250 call word_processor | |
251 | |
252 WIN_LEFT .20 | |
253 WIN_TOP .95 | |
254 lfsr FSR2,letter | |
255 movlw '1' | |
256 movwf POSTINC2 | |
257 movlw '/' | |
258 movwf POSTINC2 | |
259 movlw '1' | |
260 movwf POSTINC2 | |
261 movlw '0' | |
262 movwf POSTINC2 | |
263 movlw ':' | |
264 movwf POSTINC2 | |
265 movlw ' ' | |
266 movwf POSTINC2 | |
267 movlw '1' | |
268 movwf POSTINC2 | |
269 movlw '0' | |
270 btfsc second_FA | |
271 movwf POSTINC2 | |
272 movlw ' ' | |
273 movwf POSTINC2 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
274 call word_processor |
0 | 275 |
79 | 276 menu_custom_functions10b: |
0 | 277 WIN_LEFT .20 |
278 WIN_TOP .125 | |
279 lfsr FSR2,letter | |
280 OUTPUTTEXT d'89' ;"Default:" | |
281 | |
79 | 282 call display_customfunction ; Typed display. |
0 | 283 |
284 WIN_LEFT .20 | |
285 WIN_TOP .155 | |
286 lfsr FSR2,letter | |
287 OUTPUTTEXT d'97' ; "Current:" | |
288 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
289 movf cf32_x4,W |
0 | 290 addlw 0x82 |
291 movwf EEADR | |
292 call read_eeprom ; Lowbyte | |
293 movff EEDATA,lo | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
294 movff EEDATA, cf_value ; Backup low 8bit value. |
79 | 295 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
296 movf cf32_x4,W |
0 | 297 addlw 0x83 |
298 movwf EEADR | |
299 call read_eeprom ; Highbyte | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
300 movff EEDATA,hi |
79 | 301 |
302 call display_customfunction | |
0 | 303 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
304 ; End of mask: min/max and the exit line... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
305 rcall display_minmax |
0 | 306 DISPLAYTEXT .11 ; Exit |
307 | |
308 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
309 call PLED_menu_cursor | |
310 | |
311 customfunctions_loop: | |
312 call check_switches_logbook | |
313 | |
314 btfsc menubit3 | |
315 bra customfunctions2 ; Move cursor or generate next page | |
316 | |
317 btfsc menubit2 | |
318 bra do_customfunction ; call subfunction | |
319 | |
320 btfsc divemode | |
321 goto restart ; dive started during cf menu | |
322 | |
323 btfsc onesecupdate | |
324 call timeout_surfmode | |
325 | |
326 btfsc onesecupdate | |
327 call set_dive_modes | |
328 | |
329 bcf onesecupdate ; end of 1sek. tasks | |
330 | |
331 btfsc sleepmode | |
332 bra exit_customfunctions | |
333 | |
334 bra customfunctions_loop | |
335 | |
336 customfunctions2: | |
337 incf menupos,F | |
90 | 338 movf cf_type,W ; Are we editing a boolean value ? |
339 xorlw CF_BOOL | |
340 bnz customfunctions2a ; NO : don't skip lines 2/3. | |
84 | 341 |
342 movlw d'4' ; Just after increment, | |
343 cpfsgt menupos ; Is current position < 4 ? | |
344 movwf menupos ; NO: skip set to 4. | |
345 | |
346 customfunctions2a: | |
0 | 347 movlw d'7' |
348 cpfseq menupos ; =7? | |
349 bra customfunctions3 ; No | |
350 movlw d'1' | |
351 movwf menupos | |
352 | |
353 customfunctions3: | |
354 clrf timeout_counter2 | |
355 call PLED_menu_cursor | |
356 | |
357 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
358 | |
359 bcf menubit3 ; clear flag | |
360 bra customfunctions_loop | |
361 | |
79 | 362 ;----------------------------------------------------------------------------- |
94 | 363 ; Read default value, type, and constraints |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
364 ; |
94 | 365 ; Input: customfunction_page, cf32_x4 |
366 ; Output: hi:lo, cf_type, cf_min, cf_max. | |
367 ; Trashes: TBLPTR | |
368 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
369 cf_read_default: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
370 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
371 movwf TBLPTRL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
372 movlw HIGH(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
373 movwf TBLPTRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
374 movlw UPPER(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
375 movwf TBLPTRU |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
376 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
377 movlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
378 btfsc customfunction_page ; Page II CF# ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
379 movlw 0x80 ; YES: add 128 to ptr. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
380 addwf cf32_x4,W ; Add 4 x (CF index modulus 32) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
381 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
382 movlw 0 ; (keep carry) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
383 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
384 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
385 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
386 movff TABLAT,lo ; Low byte --> lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
387 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
388 movff TABLAT,hi ; High byte --> hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
389 btfss hi,7 ; 15bit ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
390 clrf hi ; NO: clear extra type flags |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
391 bcf hi,7 ; clear 15bit flag |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
392 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
393 movff TABLAT,cf_type ; type (high byte) --> cf_type |
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 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
396 movff TABLAT,cf_min ; Then get optional min/max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
397 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
398 movff TABLAT,cf_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
399 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
400 return |
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 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
403 ; Display a 8/15bit value, plus optional min and max bound. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
404 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
405 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
406 ; cf_min, cf_max : the optional min/max. |
79 | 407 ; FSR2 = current string pointer. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
408 ; Trash : hi:lo (when displaying min/max) |
79 | 409 |
410 display_customfunction: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
411 movff EEADRH, FSR1H ; Backup... |
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 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
414 rcall cf_fill_line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
415 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
416 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
417 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
418 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
419 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
420 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
421 ; Display optional min/max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
422 ; 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
|
423 ; Trashed: hi:lo while display min and max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
424 display_minmax: |
99 | 425 ; Min/max unsupported for 15bit values yet... |
426 btfsc cf_type,7 ; A 15bit value ? | |
427 return | |
428 | |
79 | 429 movff EEADRH, FSR1H ; Backup... |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
430 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
431 ; Display min line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
432 WIN_TOP .65 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
433 WIN_LEFT .100 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
434 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
435 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
436 btfss cf_type, CF_MIN_BIT ; A min value exists ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
437 bra cf_no_min |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
438 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
439 movf cf_min,W ; Retrieve current 8b value |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
440 subwf cf_value,W ; Compute (lo-min) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
441 bc cf_min_passed ; Ok if CARRY, ie. min >= lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
442 call PLED_warnings_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
443 WIN_INVERT 1 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
444 cf_min_passed: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
445 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
446 movlw '>' ; A min value follows |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
447 movwf POSTINC2 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
448 movlw ' ' |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
449 movwf POSTINC2 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
450 movff cf_min, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
451 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
452 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
453 cf_no_min: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
454 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
455 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
456 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
457 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
458 ; Display max line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
459 WIN_TOP .95 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
460 call PLED_standard_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
461 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
462 lfsr FSR2, letter |
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 btfss cf_type, CF_MAX_BIT ; A max value exists ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
465 bra cf_no_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
466 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
467 movf cf_value,W ; Retrieve current max bound |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
468 subwf cf_max,W ; Compute (max-lo) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
469 bc cf_max_passed ; Ok if no carry, ie. max <= lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
470 call PLED_warnings_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
471 WIN_INVERT 1 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
472 cf_max_passed: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
473 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
474 movlw '<' ; A max value follows |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
475 movwf POSTINC2 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
476 movlw ' ' |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
477 movwf POSTINC2 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
478 movff cf_max, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
479 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
480 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
481 cf_no_max: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
482 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
483 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
484 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
485 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
486 cf_minmax_done: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
487 call PLED_standard_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
488 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
489 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
490 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
491 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
492 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
493 ; Display a single 8/15 bit value, according to cf_type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
494 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
495 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
496 ; cf_min, cf_max : the optional min/max. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
497 ; FSR2 = current string pointer. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
498 display_formated: |
79 | 499 |
500 ;---- decode type -------------------------------------------------------- | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
501 movf cf_type,W ; Just set N/Z flags |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
502 bn cf_type_neg ; Keep 15bits value in old format. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
503 andlw CF_TYPES ; Look just at types |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
504 bz cf_type_00 ; 8bit standard mode |
79 | 505 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
506 ; Jump table: ; test the value with cleared flags... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
507 dcfsnz WREG |
79 | 508 bra cf_type_01 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
509 dcfsnz WREG |
79 | 510 bra cf_type_02 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
511 dcfsnz WREG |
79 | 512 bra cf_type_03 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
513 dcfsnz WREG |
79 | 514 bra cf_type_04 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
515 dcfsnz WREG |
79 | 516 bra cf_type_05 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
517 dcfsnz WREG |
79 | 518 bra cf_type_06 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
519 dcfsnz WREG |
79 | 520 bra cf_type_07 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
521 bra cf_type_00 ; Default to 8bit mode... |
79 | 522 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
523 cf_type_01: ; Type == 1 is CF_PERCENT mode |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
524 bcf leftbind |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
525 output_8 |
79 | 526 movlw '%' |
527 movwf POSTINC2 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
528 retlw 0 |
79 | 529 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
530 cf_type_02: ; Type == 2 is CF_DECI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
531 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
532 bsf leftbind |
79 | 533 output_16dp 4 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
534 retlw 0 |
79 | 535 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
536 cf_type_03: ; Type == 3 is CF_CENTI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
537 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
538 bsf leftbind |
79 | 539 output_16dp 3 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
540 retlw 0 |
79 | 541 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
542 cf_type_04: ; Type == 4 is CF_MILI mode |
79 | 543 output_16dp 2 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
544 retlw 0 |
79 | 545 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
546 cf_type_05: ; Type == 5 is CF_BOOL mode. |
79 | 547 movf lo,W ; Get flag value... |
548 bz cf_type_off | |
549 OUTPUTTEXT d'130' ; ON | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
550 retlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
551 |
79 | 552 cf_type_off: |
553 OUTPUTTEXT d'131' ; OFF | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
554 retlw 0 |
79 | 555 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
556 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
|
557 clrf hi |
79 | 558 call convert_time ; Convert to min:sec into hi:low. |
559 movff lo,wp_temp ; Save seconds, | |
560 movff hi,lo ; Get minutes | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
561 bsf leftbind ; Skip leading space(s). |
79 | 562 output_8 ; Print them |
563 movlw ':' ; Separator | |
564 movwf POSTINC2 | |
565 movff wp_temp,lo ; Get back seconds | |
566 output_99x ; lo in 2 digits with trailing zeros. | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
567 retlw 0 |
79 | 568 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
569 cf_type_07: ; Type == 7 is CF_COLOR swatch. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
570 bcf leftbind ; Keep leading space (better alignement) |
79 | 571 output_8 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
572 movlw ' ' |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
573 movwf POSTINC2 |
84 | 574 call word_processor |
575 | |
79 | 576 movf lo,W ; Get color. |
577 movff WREG,box_temp+0 ; Set color | |
578 movff win_top,WREG ; BEWARE : this is a bank0 variable ! | |
579 movff WREG,box_temp+1 ; row top (0-239) | |
580 addlw .23 | |
581 movff WREG,box_temp+2 ; row bottom (0-239) | |
582 movlw .110 | |
583 movff WREG,box_temp+3 ; column left (0-159) | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
584 movlw .148 |
79 | 585 movff WREG,box_temp+4 ; column right (0-159) |
586 | |
587 call PLED_box | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
588 retlw -1 ; wp already done. Skip it... |
79 | 589 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
590 cf_type_00: ; 8bit mode. Or unrecognized type... |
79 | 591 clrf hi |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
592 bsf leftbind |
79 | 593 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
594 cf_type_neg: ; 15bit mode. |
79 | 595 bcf hi,7 |
596 output_16 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
597 retlw 0 |
84 | 598 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
599 ;----------------------------------------------------------------------------- |
84 | 600 |
601 cf_fill_line: ; Mattias: No flicker if u clear just what you need... | |
602 movf FSR2L,W ; How many chars lefts ? | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
603 sublw (LOW letter) + .18 ; Remaining chars to fill: (letter + 18) - PTR |
84 | 604 btfsc STATUS,N ; Add chars until none left... |
605 return | |
606 movlw ' ' | |
607 movwf POSTINC2 | |
608 bra cf_fill_line | |
79 | 609 |
610 ;----------------------------------------------------------------------------- | |
0 | 611 |
612 do_customfunction: | |
613 CLRF EEADRH | |
614 movlw d'1' | |
615 btfsc customfunction_page | |
616 movwf EEADRH ; Reset EEADRH correct (Was adjusted in check_timeout...) | |
617 | |
618 dcfsnz menupos,F | |
619 bra next_customfunction | |
620 dcfsnz menupos,F | |
621 bra toggle_plusminus | |
622 dcfsnz menupos,F | |
623 bra toggle_oneorten | |
624 dcfsnz menupos,F | |
625 bra restore_cfn_value | |
626 dcfsnz menupos,F | |
627 bra adjust_cfn_value | |
84 | 628 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
629 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
630 |
0 | 631 exit_customfunctions: |
632 movlw d'2' ; Return to correct list entry | |
633 btfss customfunction_page | |
634 movlw d'1' | |
635 movwf menupos ; | |
636 clrf EEADRH ; Clear EEADRH ! | |
637 goto setup_menu2 ; exit... | |
638 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
639 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
640 |
0 | 641 next_customfunction: |
642 incf decodata+0 | |
643 btfsc decodata+0,5 ;>31? | |
644 clrf decodata+0 ;Yes, so reset to zero | |
645 | |
646 movf decodata+0,W | |
647 mullw d'4' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
648 movff PRODL, cf32_x4 ; 12bit address for correct addressing |
0 | 649 |
650 movlw d'1' | |
651 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
652 bra menu_custom_functions1 ; also debounces switches |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
653 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
654 ;----------------------------------------------------------------------------- |
0 | 655 |
656 toggle_plusminus: | |
657 btg first_FA | |
658 movlw d'2' | |
659 movwf menupos | |
660 bra menu_custom_functions1 ; also debounces switches | |
661 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
662 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
663 |
0 | 664 toggle_oneorten: |
665 btg second_FA | |
666 movlw d'3' | |
667 movwf menupos | |
668 bra menu_custom_functions1 ; also debounces switches | |
669 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
670 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
671 |
0 | 672 restore_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
673 rcall cf_read_default ; hi:lo is trashed by min/max display. |
0 | 674 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
675 movf cf32_x4,W ; store default value |
0 | 676 addlw 0x82 |
677 movwf EEADR | |
678 movff lo,EEDATA | |
679 call write_eeprom ; Lowbyte | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
680 movf cf32_x4,W |
0 | 681 addlw 0x83 |
682 movwf EEADR | |
683 movff hi,EEDATA | |
684 call write_eeprom ; Highbyte | |
685 | |
686 movlw d'4' | |
687 movwf menupos | |
688 bra menu_custom_functions1 ; also debounces switches | |
689 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
690 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
691 ; Adjust current value. |
0 | 692 adjust_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
693 movf cf32_x4,W ; get current value |
0 | 694 addlw 0x82 |
695 movwf EEADR | |
696 call read_eeprom ; Lowbyte | |
697 movff EEDATA,lo | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
698 movf cf32_x4,W |
0 | 699 addlw 0x83 |
700 movwf EEADR | |
701 call read_eeprom ; Highbyte | |
702 movff EEDATA,hi | |
703 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
704 movf cf_type,W |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
705 xorlw CF_BOOL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
706 bnz adjust_cfn_value1 |
0 | 707 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
708 btg lo,0 ; Change lower bit. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
709 bra adjust_cfn_value3 ; Store result |
0 | 710 |
711 adjust_cfn_value1: | |
712 movlw d'1' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
713 btfsc second_FA ; -10? |
0 | 714 movlw d'10' |
715 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
716 btfss first_FA ; Minus? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
717 bra adjust_cfn_value2 ; No, Plus |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
718 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
719 subwf lo,F ; substract value |
0 | 720 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
721 btfsc cf_type,7 ; 8Bit value |
0 | 722 subwfb hi,F |
723 | |
724 movlw b'01111111' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
725 btfsc hi,7 ; >32768? |
0 | 726 movwf hi |
727 | |
728 bra adjust_cfn_value3 | |
729 | |
730 adjust_cfn_value2: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
731 addwf lo,F ; add value |
0 | 732 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
733 btfsc cf_type,7 ; 8Bit value? |
0 | 734 addwfc hi,F |
735 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
736 btfsc hi,7 ; >32768? |
0 | 737 clrf hi |
738 | |
739 adjust_cfn_value3: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
740 movf cf32_x4,W ; Store current value |
0 | 741 addlw 0x82 |
742 movwf EEADR | |
743 movff lo,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
744 call write_eeprom ; Lowbyte |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
745 movf cf32_x4,W |
0 | 746 addlw 0x83 |
747 movwf EEADR | |
748 movff hi,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
749 call write_eeprom ; Highbyte |
0 | 750 movlw d'5' |
751 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
752 bra menu_custom_functions1 ; also debounces switches |
94 | 753 |
754 ;----------------------------------------------------------------------------- | |
755 ; Check all CF values that have max and min constraints. | |
756 ; Input: cf_checker_counter. | |
757 ; Output: Pop warning with the first CF number if bad. | |
758 ; cf_checker_counter incremented. | |
759 ; Trashes: TBLPTR, EEADR, PROD | |
760 | |
761 check_customfunctions: | |
99 | 762 ; rcall check_next_cf ; Check 5 at a time... |
763 ; rcall check_next_cf | |
764 ; rcall check_next_cf | |
765 ; rcall check_next_cf | |
766 ; | |
767 ;check_next_cf: | |
768 | |
94 | 769 movf cf_checker_counter,W ; Get current CF to ckeck |
770 | |
771 ; Setup cf32_x4 and cf page bit: | |
772 rlcf WREG ; x4 | |
773 rlcf WREG | |
774 bcf customfunction_page | |
775 btfsc WREG,7 | |
776 bsf customfunction_page | |
777 andlw 4*.31 | |
778 movwf cf32_x4 | |
779 | |
780 ; Do the check | |
781 rcall check_one_cf | |
782 btfsc WREG,7 | |
783 bra check_cf_ok | |
784 | |
785 ; Went wrong: pop the warning | |
786 movwf temp1 | |
787 call custom_warn_surfmode | |
788 | |
789 ; Increment counter (modulo 64) | |
790 check_cf_ok: | |
791 movlw 1 | |
792 addwf cf_checker_counter,W | |
793 andlw .63 | |
794 movwf cf_checker_counter | |
795 return | |
796 | |
797 ; Check one CF value --------------------------------------------------------- | |
798 check_one_cf: | |
799 rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. | |
800 | |
801 movf cf_type,W ; MIN or MAX set ? | |
802 andlw (CF_MIN + CF_MAX) | |
803 bnz check_cf_check ; yes: do something. | |
804 retlw -1 ; no: no problem there. | |
805 | |
806 ; It does have bound: | |
807 check_cf_check: | |
808 movf cf32_x4,W ; Compute current CF number | |
809 rrncf WREG ; Div 4 | |
810 rrncf WREG | |
811 btfsc customfunction_page ; Upper page ? | |
812 addlw .32 ; just add 32. | |
813 movwf TABLAT ; saved to return error, if any. | |
814 | |
815 btfss cf_type,7 ; 15 or 8 bit value ? | |
816 bra cf_check_8bit | |
817 | |
99 | 818 ; Implement the 15bit check, even if not displayed... |
94 | 819 rcall getcustom15_1 ; Read into hi:lo |
820 | |
821 movf cf_min,W ; Compute (bound-value) -> hi:lo | |
822 subwf lo,F | |
823 movf cf_max,W | |
99 | 824 bcf WREG,7 ; Clear min or max bit |
94 | 825 subwfb hi,F |
826 | |
827 movf lo,W ; Is it a 0 result ? | |
828 iorwf hi,W | |
829 bnz cf_15_not_equal ; NO: check sign. | |
830 retlw -1 ; YES: then it is ok. | |
831 | |
832 cf_15_not_equal: | |
99 | 833 btfss cf_max,7 ; Checking min or max ? |
94 | 834 btg hi,6 ; exchange wanted sign |
835 | |
836 setf WREG ; -1 for return w/o error | |
837 btfss hi,6 ; Is sign correct ? | |
838 movf TABLAT,W ; NO: get back failed CF number | |
839 return ; and return that. | |
840 | |
841 ; Do a 8bit check | |
842 cf_check_8bit: | |
843 rcall getcustom8_1 ; Read into WREG | |
844 movwf lo ; Save it. | |
845 | |
846 btfss cf_type,CF_MIN_BIT | |
847 bra check_no_min | |
848 | |
849 cpfsgt cf_min ; Compare to cf_min | |
850 bra check_no_min | |
851 | |
852 movf TABLAT,W ; NO: get back failed CF number | |
853 return | |
854 | |
855 check_no_min: | |
856 btfss cf_type,CF_MAX_BIT | |
857 bra check_no_max | |
858 | |
859 movf lo,W ; Compute value-max | |
860 cpfslt cf_max | |
861 bra check_no_max | |
862 | |
863 movf TABLAT,W ; NO: get back failed CF number | |
864 return | |
865 | |
866 check_no_max: ; Then everything was ok... | |
867 retlw -1 |