Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_custom.asm @ 542:ca0e0efb1573
p2_deco.o
author | JeanDo |
---|---|
date | Tue, 10 Jan 2012 00:04:33 +0100 |
parents | fd8266b511cc |
children | 77c8ff191cd7 |
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 |
478
fd8266b511cc
New SAC (CF56/CF57) in 5..50 l/min range (no more decimal).
JeanDo
parents:
445
diff
changeset
|
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 ; |
355 | 59 CF_TYPES EQU 0x0F |
86
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) |
355 | 64 CF_NEG_BIT EQU 4 ; Allow negativ values. |
65 CF_NEG EQU (1<<CF_NEG_BIT) | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
66 ; |
79 | 67 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. |
0 | 68 |
360 | 69 ;============================================================================= |
70 ; Overlay our tmp data in ACCESS0 bank | |
71 CBLOCK 0x010 ; Keep space for aa_wordprocessor module. | |
72 cf32_x4 ; CF# modulus 32, time 4. | |
73 cf_type ; Type of the edited CF | |
74 cf_default:2 | |
75 cf_value:2 | |
76 cf_min | |
77 cf_max | |
78 cf_step ; Value ad add/substract: 1, 10, 100 | |
79 ENDC | |
80 | |
81 ;============================================================================= | |
82 | |
0 | 83 GETCUSTOM8 macro custom8 |
84 movlw custom8 | |
85 call getcustom8_1 | |
86 endm | |
87 | |
88 getcustom8_1: | |
89 ; # number of requested custom function in wreg | |
90 movwf customfunction_temp2 | |
91 | |
92 movlw d'31' | |
93 cpfsgt customfunction_temp2 | |
94 bra getcustom8_2 ; Lower bank | |
95 | |
96 movlw d'1' ; Upper Bank | |
97 movwf EEADRH | |
98 movlw d'32' | |
99 subwf customfunction_temp2,F | |
100 bra getcustom8_3 | |
101 | |
102 getcustom8_2: | |
103 clrf EEADRH | |
104 getcustom8_3: | |
105 movf customfunction_temp2,W | |
106 mullw d'4' | |
107 movf PRODL,W ; x4 for adress | |
108 addlw d'130' | |
109 movwf EEADR ; +130 for LOW Byte of value | |
110 call read_eeprom ; Lowbyte | |
111 movf EEDATA,W ; copied into wreg | |
112 clrf EEADRH | |
113 return ; return | |
114 | |
167 | 115 GETCUSTOM15 macro number |
116 movlw number | |
117 call getcustom15 | |
0 | 118 endm |
119 | |
167 | 120 global getcustom15 |
121 getcustom15: | |
0 | 122 ; # number of requested custom function in wreg |
123 movwf customfunction_temp2 | |
124 | |
125 movlw d'31' | |
126 cpfsgt customfunction_temp2 | |
127 bra getcustom15_2 ; Lower bank | |
128 | |
129 movlw d'1' ; Upper Bank | |
130 movwf EEADRH | |
131 movlw d'32' | |
132 subwf customfunction_temp2,F | |
133 bra getcustom15_3 | |
134 getcustom15_2: | |
135 clrf EEADRH | |
136 getcustom15_3: | |
137 movf customfunction_temp2,W | |
138 mullw d'4' | |
139 movf PRODL,W ; x4 for adress | |
140 addlw d'130' | |
141 movwf EEADR ; +130 for LOW Byte of value | |
142 call read_eeprom ; Lowbyte | |
143 movff EEDATA,lo | |
144 incf EEADR,F | |
145 call read_eeprom ; Highbyte | |
146 movff EEDATA,hi | |
147 clrf EEADRH | |
148 return ; return | |
149 | |
150 menu_custom_functions_page2: | |
151 movlw d'154' ; start of custom function descriptors | |
152 movwf customfunction_temp1 | |
7 | 153 bsf customfunction_page ; Use Page II... |
0 | 154 bra menu_custom_functions0 |
155 | |
156 menu_custom_functions: | |
157 movlw d'36' ; start of custom function descriptors | |
158 movwf customfunction_temp1 | |
159 bcf customfunction_page ; Use Page I... | |
160 | |
161 menu_custom_functions0: | |
162 bsf leftbind | |
163 call PLED_ClearScreen | |
164 movlw d'1' | |
165 movwf menupos | |
166 | |
167 bcf menubit4 | |
168 bcf cursor | |
169 bcf sleepmode | |
170 clrf decodata+0 ; here: # of CustomFunction | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
171 clrf cf32_x4 ; here: # of CustomFunction*4 |
0 | 172 bcf first_FA ; here: =1: -, =0: + |
360 | 173 movlw 1 ; Stepsize: 1, 10, or 100. |
174 movwf cf_step | |
0 | 175 |
176 call PLED_topline_box | |
177 WIN_INVERT .1 ; Init new Wordprocessor | |
178 | |
179 btfss customfunction_page ; | |
180 bra menu_custom_functions10 | |
181 DISPLAYTEXT .186 ; Custom FunctionsII | |
182 bra menu_custom_functions11 | |
183 | |
184 menu_custom_functions10: | |
185 DISPLAYTEXT .27 ; Custom FunctionsI | |
186 | |
187 menu_custom_functions11: | |
188 WIN_INVERT .0 ; Init new Wordprocessor | |
189 | |
190 menu_custom_functions1: | |
123 | 191 call PLED_standard_color ; Trash EEADRH... |
29 | 192 |
123 | 193 movlw d'1' ; So restore it ! |
194 btfss customfunction_page ; Use Page II ? | |
195 movlw d'0' ; NO: this is page 1. | |
7 | 196 movwf EEADRH |
197 | |
0 | 198 clrf timeout_counter2 |
199 bcf menubit2 | |
200 bcf menubit3 | |
201 WIN_LEFT .20 | |
202 WIN_TOP .35 | |
203 lfsr FSR2,letter | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
204 movff decodata+0,lo ; decodata == CF number % 32 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
205 |
0 | 206 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
207 btfsc customfunction_page ; Add offset for display in CF menu II |
0 | 208 movlw d'32' |
209 addwf lo,F | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
210 |
0 | 211 output_99x |
123 | 212 STRCAT_PRINT ": " |
0 | 213 |
214 movf customfunction_temp1,W ; start of custom function descriptors | |
215 addwf decodata+0,W ; add # of current custom function, place result in wreg | |
174 | 216 call displaytext_1_low ; shows descriptor |
0 | 217 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
218 ; Read default, type and min/max from reset table. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
219 rcall cf_read_default |
0 | 220 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
221 movf cf_type,W ; Is it a ON/OFF flag ? |
79 | 222 xorlw CF_BOOL |
223 bnz menu_custom_functions10a ; Not a binary CF selected | |
0 | 224 |
225 menu_custom_functions10c: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
226 ; Erase unused lines when editing boolean... |
79 | 227 WIN_LEFT .20 |
228 WIN_TOP .65 | |
229 lfsr FSR2,letter ; Make a string of 8 spaces | |
84 | 230 call cf_fill_line |
79 | 231 call word_processor ; Clear +/- line |
232 | |
233 WIN_TOP .95 | |
234 call word_processor ; Clear 1/10 line | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
235 |
0 | 236 bra menu_custom_functions10b |
237 | |
238 menu_custom_functions10a: | |
239 WIN_LEFT .20 | |
240 WIN_TOP .65 | |
123 | 241 STRCPY "+/-: " |
0 | 242 movlw '+' |
243 btfsc first_FA | |
244 movlw '-' | |
245 movwf POSTINC2 | |
246 call word_processor | |
247 | |
248 WIN_TOP .95 | |
445 | 249 STRCPY TXT_STEP5 |
360 | 250 clrf hi |
251 movff cf_step,lo | |
252 call display_formated ; Typed display, w/o fill line. | |
253 STRCAT_PRINT " " ; 2 spaces for "0.01"->"1" | |
0 | 254 |
79 | 255 menu_custom_functions10b: |
0 | 256 WIN_LEFT .20 |
257 WIN_TOP .125 | |
258 lfsr FSR2,letter | |
360 | 259 OUTPUTTEXT d'89' ; "Default:" |
0 | 260 |
360 | 261 movff cf_default+0,lo |
262 movff cf_default+1,hi | |
263 call display_customfunction ; Typed display. | |
0 | 264 |
265 WIN_LEFT .20 | |
266 WIN_TOP .155 | |
267 lfsr FSR2,letter | |
360 | 268 OUTPUTTEXT d'97' ; "Current:" |
0 | 269 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
270 movf cf32_x4,W |
0 | 271 addlw 0x82 |
272 movwf EEADR | |
273 call read_eeprom ; Lowbyte | |
360 | 274 movff EEDATA,cf_value+0 |
79 | 275 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
276 movf cf32_x4,W |
0 | 277 addlw 0x83 |
278 movwf EEADR | |
279 call read_eeprom ; Highbyte | |
360 | 280 movff EEDATA,cf_value+1 |
79 | 281 |
123 | 282 call PLED_standard_color ; Changed by color swatches, but trash EEADRH... |
360 | 283 movff cf_value+0,lo |
284 movff cf_value+1,hi | |
79 | 285 call display_customfunction |
0 | 286 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
287 ; End of mask: min/max and the exit line... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
288 rcall display_minmax |
0 | 289 DISPLAYTEXT .11 ; Exit |
290 | |
291 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
292 call PLED_menu_cursor | |
293 | |
294 customfunctions_loop: | |
337 | 295 call check_switches_logbook |
0 | 296 |
337 | 297 btfsc menubit3 |
298 bra customfunctions2 ; Move cursor or generate next page | |
0 | 299 |
337 | 300 btfsc menubit2 |
301 bra do_customfunction ; call subfunction | |
0 | 302 |
303 btfsc divemode | |
337 | 304 goto restart ; dive started during cf menu |
0 | 305 |
306 btfsc onesecupdate | |
307 call timeout_surfmode | |
308 | |
309 btfsc onesecupdate | |
310 call set_dive_modes | |
311 | |
337 | 312 bcf onesecupdate ; end of 1sek. tasks |
335 | 313 |
0 | 314 btfsc sleepmode |
337 | 315 bra exit_customfunctions |
0 | 316 |
337 | 317 bra customfunctions_loop |
0 | 318 |
319 customfunctions2: | |
320 incf menupos,F | |
90 | 321 movf cf_type,W ; Are we editing a boolean value ? |
322 xorlw CF_BOOL | |
323 bnz customfunctions2a ; NO : don't skip lines 2/3. | |
84 | 324 |
325 movlw d'4' ; Just after increment, | |
326 cpfsgt menupos ; Is current position < 4 ? | |
327 movwf menupos ; NO: skip set to 4. | |
328 | |
329 customfunctions2a: | |
0 | 330 movlw d'7' |
331 cpfseq menupos ; =7? | |
332 bra customfunctions3 ; No | |
333 movlw d'1' | |
334 movwf menupos | |
335 | |
336 customfunctions3: | |
337 clrf timeout_counter2 | |
338 call PLED_menu_cursor | |
339 | |
340 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
341 | |
342 bcf menubit3 ; clear flag | |
343 bra customfunctions_loop | |
344 | |
79 | 345 ;----------------------------------------------------------------------------- |
94 | 346 ; Read default value, type, and constraints |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
347 ; |
94 | 348 ; Input: customfunction_page, cf32_x4 |
360 | 349 ; Output: cf_default, cf_type, cf_min, cf_max. |
94 | 350 ; Trashes: TBLPTR |
351 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
352 cf_read_default: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
353 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
354 movwf TBLPTRL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
355 movlw HIGH(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
356 movwf TBLPTRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
357 movlw UPPER(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
358 movwf TBLPTRU |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
359 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
360 movlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
361 btfsc customfunction_page ; Page II CF# ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
362 movlw 0x80 ; YES: add 128 to ptr. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
363 addwf cf32_x4,W ; Add 4 x (CF index modulus 32) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
364 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
365 movlw 0 ; (keep carry) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
366 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
367 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
368 tblrd*+ |
360 | 369 movff TABLAT,cf_default+0 ; Low byte |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
370 tblrd*+ |
360 | 371 movff TABLAT,cf_default+1 ; High byte |
372 btfss cf_default+1,7 ; 15bit ? | |
373 clrf cf_default+1 ; NO: clear extra type flags | |
374 bcf cf_default+1,7 ; clear 15bit flag | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
375 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
376 movff TABLAT,cf_type ; type (high byte) --> cf_type |
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 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
379 movff TABLAT,cf_min ; Then get optional min/max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
380 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
381 movff TABLAT,cf_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
382 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
383 return |
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 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
386 ; Display a 8/15bit value, plus optional min and max bound. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
387 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
388 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
389 ; cf_min, cf_max : the optional min/max. |
79 | 390 ; FSR2 = current string pointer. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
391 ; Trash : hi:lo (when displaying min/max) |
79 | 392 |
393 display_customfunction: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
394 movff EEADRH, FSR1H ; Backup... |
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 rcall display_formated |
123 | 397 incf WREG ; Color swatch drawn ? |
398 bz display_customfunction_1 ; YES: skip line fill... | |
399 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
400 rcall cf_fill_line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
401 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
402 |
123 | 403 display_customfunction_1: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
404 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
405 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
406 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
407 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
408 ; Display optional min/max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
409 ; 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
|
410 ; Trashed: hi:lo while display min and max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
411 display_minmax: |
99 | 412 ; Min/max unsupported for 15bit values yet... |
79 | 413 movff EEADRH, FSR1H ; Backup... |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
414 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
415 ; Display min line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
416 WIN_TOP .65 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
417 WIN_LEFT .100 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
418 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
419 |
100 | 420 btfsc cf_type,7 ; A 15bit value ? |
421 bra cf_no_min ; Don't display, hence clear line... | |
422 | |
355 | 423 btfss cf_type,CF_MIN_BIT ; A min value exists ? |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
424 bra cf_no_min |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
425 |
355 | 426 btfss cf_type,CF_NEG_BIT |
427 bra cf_min_unsigned | |
428 | |
429 ; Uses 16bit sub for checking signed min value. | |
430 movff cf_value,sub_a+0 ; A <- value | |
431 clrf sub_a+1 | |
432 btfsc cf_value,7 ; extend sign if value < 0 | |
433 setf sub_a+1 | |
434 | |
435 movff cf_min,sub_b+0 ; B <- min (with signed extend) | |
436 setf sub_b+1 ; min have to be negativ. | |
437 call sub16 ; Compute (A-B) | |
438 | |
439 btfss neg_flag ; Result < 0 ? | |
440 bra cf_min_passed ; NO | |
441 bra cf_min_failed ; YES | |
442 | |
443 cf_min_unsigned: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
444 movf cf_min,W ; Retrieve current 8b value |
355 | 445 subwf cf_value,W ; Compute (value-min) |
446 bc cf_min_passed ; Ok if CARRY, ie. min >= lo | |
447 | |
448 cf_min_failed: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
449 call PLED_warnings_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
450 WIN_INVERT 1 |
355 | 451 |
452 cf_min_passed: | |
123 | 453 STRCAT "> " ; A min value follows |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
454 movff cf_min, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
455 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
456 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
457 cf_no_min: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
458 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
459 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
460 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
461 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
462 ; Display max line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
463 WIN_TOP .95 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
464 call PLED_standard_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
465 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
466 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
467 |
100 | 468 btfsc cf_type,7 ; A 15bit value ? |
469 bra cf_no_max ; Don't display, hence clear line too... | |
470 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
471 btfss cf_type, CF_MAX_BIT ; A max value exists ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
472 bra cf_no_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
473 |
355 | 474 btfss cf_type,CF_NEG_BIT |
475 bra cf_max_unsigned | |
476 | |
477 ; Uses 16bit sub for checking signed min value. | |
478 movff cf_max,sub_a+0 ; A <- max (with signed extend) | |
479 clrf sub_a+1 ; max have to be positiv. | |
480 | |
481 movff cf_value,sub_b+0 ; B <- value | |
482 clrf sub_b+1 | |
483 btfsc cf_value,7 ; extend sign if value < 0 | |
484 setf sub_b+1 | |
485 call sub16 ; Compute (A-B) | |
486 | |
487 btfss neg_flag ; Result < 0 ? | |
488 bra cf_max_passed ; NO | |
489 bra cf_max_failed ; YES | |
490 | |
491 cf_max_unsigned: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
492 movf cf_value,W ; Retrieve current max bound |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
493 subwf cf_max,W ; Compute (max-lo) |
360 | 494 bc cf_max_passed ; Ok if no carry, ie. max <= lo |
355 | 495 |
496 cf_max_failed: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
497 call PLED_warnings_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
498 WIN_INVERT 1 |
355 | 499 |
500 cf_max_passed: | |
123 | 501 STRCAT "< " ; A max value follows |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
502 movff cf_max, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
503 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
504 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
505 cf_no_max: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
506 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
507 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
508 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
509 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
510 cf_minmax_done: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
511 call PLED_standard_color |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
512 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
513 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
514 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
515 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
516 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
517 ; Display a single 8/15 bit value, according to cf_type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
518 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
519 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
520 ; cf_min, cf_max : the optional min/max. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
521 ; FSR2 = current string pointer. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
522 display_formated: |
355 | 523 movf cf_type,W ; Just set N flags |
524 bn cf_type_80 ; Keep 15bits value in old format. | |
525 | |
526 ;---- handle signed values ----------------------------------------------- | |
527 ; NOTE: only 8bit values can have a negativ flag right now. | |
528 btfss cf_type,CF_NEG_BIT ; Signed value ? | |
529 bra cf_type_unsigned ; NO: display unsigned as-is | |
530 | |
531 btfss lo,7 ; Negativ value ? | |
532 bra cf_type_pos ; NO: display positives with a + sign. | |
533 | |
534 PUTC '-' ; YES: display with a - sign. | |
535 negf lo ; and correct the said value. | |
536 bra cf_type_unsigned | |
537 | |
538 cf_type_pos: | |
539 PUTC '+' | |
79 | 540 |
541 ;---- decode type -------------------------------------------------------- | |
355 | 542 cf_type_unsigned: |
543 ; Jump table: ; test the value with cleared flags... | |
544 movf cf_type,W | |
545 andlw CF_TYPES ; Look just at types | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
546 bz cf_type_00 ; 8bit standard mode |
79 | 547 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
548 dcfsnz WREG |
79 | 549 bra cf_type_01 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
550 dcfsnz WREG |
79 | 551 bra cf_type_02 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
552 dcfsnz WREG |
79 | 553 bra cf_type_03 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
554 dcfsnz WREG |
79 | 555 bra cf_type_04 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
556 dcfsnz WREG |
79 | 557 bra cf_type_05 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
558 dcfsnz WREG |
79 | 559 bra cf_type_06 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
560 dcfsnz WREG |
79 | 561 bra cf_type_07 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
562 bra cf_type_00 ; Default to 8bit mode... |
79 | 563 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
564 cf_type_01: ; Type == 1 is CF_PERCENT mode |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
565 bcf leftbind |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
566 output_8 |
123 | 567 PUTC '%' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
568 retlw 0 |
79 | 569 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
570 cf_type_02: ; Type == 2 is CF_DECI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
571 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
572 bsf leftbind |
79 | 573 output_16dp 4 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
574 retlw 0 |
79 | 575 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
576 cf_type_03: ; Type == 3 is CF_CENTI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
577 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
578 bsf leftbind |
79 | 579 output_16dp 3 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
580 retlw 0 |
79 | 581 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
582 cf_type_04: ; Type == 4 is CF_MILI mode |
79 | 583 output_16dp 2 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
584 retlw 0 |
79 | 585 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
586 cf_type_05: ; Type == 5 is CF_BOOL mode. |
79 | 587 movf lo,W ; Get flag value... |
588 bz cf_type_off | |
589 OUTPUTTEXT d'130' ; ON | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
590 retlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
591 |
79 | 592 cf_type_off: |
593 OUTPUTTEXT d'131' ; OFF | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
594 retlw 0 |
79 | 595 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
596 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
|
597 clrf hi |
79 | 598 call convert_time ; Convert to min:sec into hi:low. |
123 | 599 movff lo,TABLAT ; Save seconds for later. |
79 | 600 movff hi,lo ; Get minutes |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
601 bsf leftbind ; Skip leading space(s). |
79 | 602 output_8 ; Print them |
123 | 603 PUTC ':' ; Separator |
604 movff TABLAT,lo ; Get back seconds | |
79 | 605 output_99x ; lo in 2 digits with trailing zeros. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
606 retlw 0 |
79 | 607 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
608 cf_type_07: ; Type == 7 is CF_COLOR swatch. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
609 bcf leftbind ; Keep leading space (better alignement) |
79 | 610 output_8 |
360 | 611 |
612 movff win_top,WREG ; Is it the step value ? | |
613 xorlw .95 ; Line for "Step:" | |
614 btfsc STATUS,Z | |
615 retlw -1 ; YES : return | |
616 | |
123 | 617 STRCAT_PRINT " " |
79 | 618 movf lo,W ; Get color. |
123 | 619 call PLED_set_color |
620 movlw .23 | |
621 movff WREG,win_height ; row bottom (0-239) | |
79 | 622 movlw .110 |
123 | 623 movff WREG,win_leftx2 ; column left (0-159) |
624 movlw .148-.110+1 | |
625 movff WREG,win_width ; column right (0-159) | |
79 | 626 |
627 call PLED_box | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
628 retlw -1 ; wp already done. Skip it... |
79 | 629 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
630 cf_type_00: ; 8bit mode. Or unrecognized type... |
79 | 631 clrf hi |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
632 bsf leftbind |
79 | 633 |
355 | 634 cf_type_80: ; 15bit mode. |
79 | 635 bcf hi,7 |
636 output_16 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
637 retlw 0 |
84 | 638 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
639 ;----------------------------------------------------------------------------- |
84 | 640 |
641 cf_fill_line: ; Mattias: No flicker if u clear just what you need... | |
642 movf FSR2L,W ; How many chars lefts ? | |
164 | 643 sublw letter + .18 ; Remaining chars to fill: (letter + 18) - PTR |
84 | 644 btfsc STATUS,N ; Add chars until none left... |
645 return | |
123 | 646 PUTC ' ' |
84 | 647 bra cf_fill_line |
79 | 648 |
649 ;----------------------------------------------------------------------------- | |
0 | 650 |
651 do_customfunction: | |
652 CLRF EEADRH | |
653 movlw d'1' | |
654 btfsc customfunction_page | |
655 movwf EEADRH ; Reset EEADRH correct (Was adjusted in check_timeout...) | |
656 | |
657 dcfsnz menupos,F | |
658 bra next_customfunction | |
659 dcfsnz menupos,F | |
660 bra toggle_plusminus | |
661 dcfsnz menupos,F | |
662 bra toggle_oneorten | |
663 dcfsnz menupos,F | |
664 bra restore_cfn_value | |
665 dcfsnz menupos,F | |
666 bra adjust_cfn_value | |
84 | 667 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
668 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
669 |
0 | 670 exit_customfunctions: |
671 movlw d'2' ; Return to correct list entry | |
672 btfss customfunction_page | |
673 movlw d'1' | |
674 movwf menupos ; | |
675 clrf EEADRH ; Clear EEADRH ! | |
676 goto setup_menu2 ; exit... | |
677 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
678 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
679 |
0 | 680 next_customfunction: |
681 incf decodata+0 | |
682 btfsc decodata+0,5 ;>31? | |
683 clrf decodata+0 ;Yes, so reset to zero | |
684 | |
685 movf decodata+0,W | |
686 mullw d'4' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
687 movff PRODL, cf32_x4 ; 12bit address for correct addressing |
0 | 688 |
689 movlw d'1' | |
690 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
691 bra menu_custom_functions1 ; also debounces switches |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
692 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
693 ;----------------------------------------------------------------------------- |
0 | 694 |
695 toggle_plusminus: | |
696 btg first_FA | |
697 movlw d'2' | |
698 movwf menupos | |
699 bra menu_custom_functions1 ; also debounces switches | |
700 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
701 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
702 |
0 | 703 toggle_oneorten: |
360 | 704 movlw .10 ; Multiply step by 10, |
705 mulwf cf_step ; Result in PROD low. | |
706 | |
707 movf PRODH,W ; Check 1000 | |
708 bz toggle_oneorten_1 ; HIGH(new step) null == no overflow | |
709 movlw .1 ; Cycle to 1. | |
710 movwf cf_step | |
711 bra toggle_oneorten_3 | |
712 | |
713 toggle_oneorten_1: ; Special case for mm:ss | |
714 movf cf_type,W ; Get type | |
715 andlw CF_TYPES ; w/o min/max/neg flags. | |
716 xorlw CF_SEC ; Check for mm:ss ? | |
717 bnz toggle_oneorten_2 ; no: continue | |
718 movlw .100 ; Step = 100 ? | |
719 xorwf PRODL,W | |
720 bnz toggle_oneorten_2 ; no: continue | |
721 movlw .60 ; yes: replace by 1:00 | |
722 movff WREG,cf_step | |
723 bra toggle_oneorten_3 ; Done. | |
724 | |
725 toggle_oneorten_2: | |
726 movff PRODL,cf_step ; Just keep result. | |
727 toggle_oneorten_3: | |
0 | 728 movlw d'3' |
729 movwf menupos | |
730 bra menu_custom_functions1 ; also debounces switches | |
731 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
732 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
733 |
0 | 734 restore_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
735 movf cf32_x4,W ; store default value |
0 | 736 addlw 0x82 |
737 movwf EEADR | |
360 | 738 movff cf_default+0,EEDATA |
739 movff cf_default+0,cf_value+0 | |
0 | 740 call write_eeprom ; Lowbyte |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
741 movf cf32_x4,W |
0 | 742 addlw 0x83 |
743 movwf EEADR | |
360 | 744 movff cf_default+1,EEDATA |
745 movff cf_default+1,cf_value+1 | |
0 | 746 call write_eeprom ; Highbyte |
747 | |
748 movlw d'4' | |
749 movwf menupos | |
750 bra menu_custom_functions1 ; also debounces switches | |
751 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
752 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
753 ; Adjust current value. |
0 | 754 adjust_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
755 movf cf32_x4,W ; get current value |
0 | 756 addlw 0x82 |
757 movwf EEADR | |
758 call read_eeprom ; Lowbyte | |
759 movff EEDATA,lo | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
760 movf cf32_x4,W |
0 | 761 addlw 0x83 |
762 movwf EEADR | |
763 call read_eeprom ; Highbyte | |
764 movff EEDATA,hi | |
765 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
766 movf cf_type,W |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
767 xorlw CF_BOOL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
768 bnz adjust_cfn_value1 |
0 | 769 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
770 btg lo,0 ; Change lower bit. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
771 bra adjust_cfn_value3 ; Store result |
0 | 772 |
773 adjust_cfn_value1: | |
360 | 774 movf cf_step,W ; 1, 10, 100 ? |
0 | 775 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
776 btfss first_FA ; Minus? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
777 bra adjust_cfn_value2 ; No, Plus |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
778 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
779 subwf lo,F ; substract value |
0 | 780 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
781 btfsc cf_type,7 ; 8Bit value |
0 | 782 subwfb hi,F |
783 | |
784 movlw b'01111111' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
785 btfsc hi,7 ; >32768? |
0 | 786 movwf hi |
787 | |
788 bra adjust_cfn_value3 | |
789 | |
790 adjust_cfn_value2: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
791 addwf lo,F ; add value |
0 | 792 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
793 btfsc cf_type,7 ; 8Bit value? |
0 | 794 addwfc hi,F |
795 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
796 btfsc hi,7 ; >32768? |
0 | 797 clrf hi |
798 | |
799 adjust_cfn_value3: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
800 movf cf32_x4,W ; Store current value |
0 | 801 addlw 0x82 |
802 movwf EEADR | |
803 movff lo,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
804 call write_eeprom ; Lowbyte |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
805 movf cf32_x4,W |
0 | 806 addlw 0x83 |
807 movwf EEADR | |
808 movff hi,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
809 call write_eeprom ; Highbyte |
0 | 810 movlw d'5' |
811 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
812 bra menu_custom_functions1 ; also debounces switches |
94 | 813 |
814 ;----------------------------------------------------------------------------- | |
815 ; Check all CF values that have max and min constraints. | |
816 ; Input: cf_checker_counter. | |
817 ; Output: Pop warning with the first CF number if bad. | |
818 ; cf_checker_counter incremented. | |
819 ; Trashes: TBLPTR, EEADR, PROD | |
100 | 820 ; |
821 ; Note: the trick here is to do two sweep over the 64 CF values, to make sure | |
822 ; they are all ok. | |
94 | 823 |
824 check_customfunctions: | |
100 | 825 ; Did we finished the two sweeps ? |
826 btfsc cf_checker_counter,7 ; Already at position 128 ? | |
827 return ; YES: just do nothing. | |
94 | 828 |
829 ; Setup cf32_x4 and cf page bit: | |
100 | 830 movf cf_checker_counter,W |
94 | 831 rlcf WREG ; x4 |
832 rlcf WREG | |
833 bcf customfunction_page | |
834 btfsc WREG,7 | |
100 | 835 bsf customfunction_page ; Setup CF page bit. |
94 | 836 andlw 4*.31 |
837 movwf cf32_x4 | |
838 | |
839 ; Do the check | |
840 rcall check_one_cf | |
100 | 841 iorwf WREG ; Test return value. |
842 bz check_failed ; 0 == FAILED. | |
843 | |
844 ; Passed: Simple loop until 128 is reached: | |
845 incf cf_checker_counter ; Next CF to check. | |
846 bra check_customfunctions ; And loop until 128 reached (ie twice) | |
94 | 847 |
100 | 848 check_failed: |
849 movlw .63 ; Make sure number is back to range 0..63 | |
850 andwf cf_checker_counter,F | |
851 | |
852 ; Went wrong: draw the warning line... | |
309 | 853 WIN_TOP .0 |
854 WIN_LEFT .125 | |
100 | 855 WIN_FONT FT_SMALL |
856 WIN_INVERT .1 ; Init new Wordprocessor | |
857 call PLED_warnings_color | |
858 | |
445 | 859 STRCPY TXT_CF2 |
100 | 860 movff cf_checker_counter,lo |
861 output_99x | |
309 | 862 STRCAT_PRINT "!" |
94 | 863 |
100 | 864 ; When failed, increment counter modulo 64, to restart checks. |
865 incf cf_checker_counter,W | |
866 andlw .63 ; Modulo 64 | |
94 | 867 movwf cf_checker_counter |
868 return | |
869 | |
870 ; Check one CF value --------------------------------------------------------- | |
871 check_one_cf: | |
360 | 872 rcall cf_read_default ; Sets cf_value, cf_type, cf_min, cf_max. |
94 | 873 |
100 | 874 btfsc cf_type,7 ; A 15bit type ? |
875 bra check_cf_check ; Then we have to check it... | |
876 | |
877 movf cf_type,W ; 8bit MIN or MAX set ? | |
94 | 878 andlw (CF_MIN + CF_MAX) |
879 bnz check_cf_check ; yes: do something. | |
100 | 880 retlw -1 ; no: no problem then. |
94 | 881 |
882 ; It does have bound: | |
883 check_cf_check: | |
100 | 884 movf cf_checker_counter,W ; Get current CF number |
885 andlw .63 ; Keep range 0..63 | |
94 | 886 |
887 btfss cf_type,7 ; 15 or 8 bit value ? | |
888 bra cf_check_8bit | |
889 | |
99 | 890 ; Implement the 15bit check, even if not displayed... |
167 | 891 rcall getcustom15 ; Read into hi:lo |
94 | 892 |
893 movf cf_min,W ; Compute (bound-value) -> hi:lo | |
894 subwf lo,F | |
895 movf cf_max,W | |
100 | 896 bcf WREG,7 ; Clear min/max bit |
94 | 897 subwfb hi,F |
898 | |
899 movf lo,W ; Is it a 0 result ? | |
900 iorwf hi,W | |
901 bnz cf_15_not_equal ; NO: check sign. | |
902 retlw -1 ; YES: then it is ok. | |
903 | |
904 cf_15_not_equal: | |
99 | 905 btfss cf_max,7 ; Checking min or max ? |
94 | 906 btg hi,6 ; exchange wanted sign |
907 | |
908 btfss hi,6 ; Is sign correct ? | |
100 | 909 retlw 0 ; NO: return failed. |
910 retlw -1 ; YES: return passed. | |
94 | 911 |
912 ; Do a 8bit check | |
913 cf_check_8bit: | |
914 rcall getcustom8_1 ; Read into WREG | |
915 movwf lo ; Save it. | |
916 | |
917 btfss cf_type,CF_MIN_BIT | |
918 bra check_no_min | |
355 | 919 |
920 btfss cf_type,CF_NEG_BIT | |
921 bra check_min_unsigned | |
922 | |
923 ; Uses 16bit sub for checking signed min value. | |
924 movff lo,sub_a+0 ; A <- value | |
925 clrf sub_a+1 | |
360 | 926 btfsc lo,7 ; extend sign if value < 0 |
355 | 927 setf sub_a+1 |
928 | |
929 movff cf_min,sub_b+0 ; B <- min (with signed extend) | |
930 setf sub_b+1 ; min have to be negativ. | |
931 call sub16 ; Compute (A-B) | |
932 | |
933 btfss neg_flag ; Result < 0 ? | |
934 bra check_no_min ; NO | |
935 retlw 0 ; YES = FAILED | |
936 | |
937 check_min_unsigned: | |
94 | 938 cpfsgt cf_min ; Compare to cf_min |
100 | 939 bra check_no_min ; PASSED: continue. |
940 retlw 0 ; NO: return failed. | |
94 | 941 |
942 check_no_min: | |
100 | 943 btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ? |
944 retlw -1 ; No check: return OK. | |
355 | 945 |
946 btfss cf_type,CF_NEG_BIT | |
947 bra check_max_unsigned | |
948 | |
949 ; Uses 16bit sub for checking signed min value. | |
950 movff cf_max,sub_a+0 ; A <- max (with signed extend) | |
951 clrf sub_a+1 ; max have to be positiv. | |
952 | |
953 movff lo,sub_b+0 ; B <- value | |
954 clrf sub_b+1 | |
360 | 955 btfsc lo,7 ; extend sign if value < 0 |
355 | 956 setf sub_b+1 |
957 call sub16 ; Compute (A-B) | |
958 | |
959 btfss neg_flag ; Result < 0 ? | |
960 retlw -1 ; NO | |
961 retlw 0 ; YES | |
962 | |
963 check_max_unsigned: | |
94 | 964 movf lo,W ; Compute value-max |
965 cpfslt cf_max | |
100 | 966 retlw -1 ; Bound met: return OK. |
967 retlw 0 ; NO: return failed. |