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