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