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