Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_custom.asm @ 83:3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
author | heinrichsweikamp |
---|---|
date | Tue, 07 Dec 2010 22:36:19 +0100 |
parents | 69c462400279 |
children | 0f4c175ef824 |
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: | |
79 | 166 |
167 #ifndef NO_CF_TYPES | |
168 ;---- Clear color swatches area ------------------------------------------ | |
169 ; BEWARE: PLED_box reset the EEADRH register, so t should be | |
170 ; be done before setting CF page I/II... | |
171 clrf WREG ; Black background | |
172 movff WREG,box_temp+0 ; Set color | |
173 movlw .125 | |
174 movff WREG,box_temp+1 ; row top (0-239) | |
175 movlw .178 | |
176 movff WREG,box_temp+2 ; row bottom (0-239) | |
177 movlw .75 | |
178 movff WREG,box_temp+3 ; column left (0-159) | |
179 movlw .150 | |
180 movff WREG,box_temp+4 ; column right (0-159) | |
181 call PLED_box | |
182 #endif | |
29 | 183 call PLED_standard_color |
184 | |
7 | 185 movlw d'1' |
186 btfss customfunction_page ; Use Page II... | |
187 movlw d'0' | |
188 movwf EEADRH | |
189 | |
0 | 190 clrf timeout_counter2 |
191 bcf menubit2 | |
192 bcf menubit3 | |
193 WIN_LEFT .20 | |
194 WIN_TOP .35 | |
195 lfsr FSR2,letter | |
196 movff decodata+0,lo | |
197 | |
198 movlw d'0' | |
199 btfsc customfunction_page ; Add offset for display | |
200 movlw d'32' | |
201 addwf lo,F | |
79 | 202 movff lo, apnoe_mins ; Copy use when NO_CF_TYPES |
0 | 203 |
204 output_99x | |
205 movlw ':' | |
206 movwf POSTINC2 | |
207 movlw ' ' | |
208 movwf POSTINC2 | |
209 call word_processor | |
210 | |
211 movf customfunction_temp1,W ; start of custom function descriptors | |
212 addwf decodata+0,W ; add # of current custom function, place result in wreg | |
213 call displaytext1 ; shows descriptor | |
214 | |
79 | 215 ; Read defaults into hi:lo |
216 movf divemins+0,W | |
217 addlw 0x80 | |
218 movwf EEADR | |
219 call read_eeprom ; Lowbyte | |
220 movff EEDATA,lo | |
221 movf divemins+0,W | |
222 addlw 0x81 | |
223 movwf EEADR | |
224 call read_eeprom ; Highbyte | |
225 movff EEDATA,hi | |
226 | |
227 #ifdef NO_CF_TYPES | |
0 | 228 movlw binary_cf1 |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
229 subwf apnoe_mins,W ; Binary cf? |
79 | 230 bz menu_custom_functions10c ; Yes |
0 | 231 |
232 movlw binary_cf2 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
233 subwf apnoe_mins,W ; Binary cf? |
79 | 234 bz menu_custom_functions10c ; Yes |
0 | 235 |
236 movlw binary_cf3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
237 subwf apnoe_mins,W ; Binary cf? |
79 | 238 bz menu_custom_functions10c ; Yes |
0 | 239 |
240 movlw binary_cf4 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
241 subwf apnoe_mins,W ; Binary cf? |
79 | 242 bz menu_custom_functions10c ; Yes |
0 | 243 |
244 movlw binary_cf5 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
245 subwf apnoe_mins,W ; Binary cf? |
79 | 246 bz menu_custom_functions10c ; Yes |
0 | 247 |
17 | 248 movlw binary_cf6 |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
249 subwf apnoe_mins,W ; Binary cf? |
79 | 250 bz menu_custom_functions10c ; Yes |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
251 |
79 | 252 bra menu_custom_functions10a ; Not a binary CF... |
253 #else | |
254 movf hi,W ; Is it a ON/OFF flag ? | |
255 xorlw CF_BOOL | |
256 bnz menu_custom_functions10a ; Not a binary CF selected | |
257 #endif | |
0 | 258 |
259 menu_custom_functions10c: | |
79 | 260 setf apnoe_mins ; Yes, set apnoe_mins to 0xFF |
261 | |
262 WIN_LEFT .20 | |
263 WIN_TOP .65 | |
264 lfsr FSR2,letter ; Make a string of 8 spaces | |
265 movlw ' ' | |
266 movwf POSTINC2 | |
267 movwf POSTINC2 | |
268 movwf POSTINC2 | |
269 movwf POSTINC2 | |
270 movwf POSTINC2 | |
271 movwf POSTINC2 | |
272 movwf POSTINC2 | |
273 movwf POSTINC2 | |
274 call word_processor ; Clear +/- line | |
275 | |
276 WIN_TOP .95 | |
277 call word_processor ; Clear 1/10 line | |
0 | 278 bra menu_custom_functions10b |
279 | |
280 menu_custom_functions10a: | |
281 clrf apnoe_mins ; Yes, clear apnoe_mins | |
79 | 282 |
0 | 283 WIN_LEFT .20 |
284 WIN_TOP .65 | |
285 lfsr FSR2,letter | |
286 movlw '+' | |
287 movwf POSTINC2 | |
288 movlw '/' | |
289 movwf POSTINC2 | |
290 movlw '-' | |
291 movwf POSTINC2 | |
292 movlw ':' | |
293 movwf POSTINC2 | |
294 movlw ' ' | |
295 movwf POSTINC2 | |
296 movlw '+' | |
297 btfsc first_FA | |
298 movlw '-' | |
299 movwf POSTINC2 | |
300 call word_processor | |
301 | |
302 WIN_LEFT .20 | |
303 WIN_TOP .95 | |
304 lfsr FSR2,letter | |
305 movlw '1' | |
306 movwf POSTINC2 | |
307 movlw '/' | |
308 movwf POSTINC2 | |
309 movlw '1' | |
310 movwf POSTINC2 | |
311 movlw '0' | |
312 movwf POSTINC2 | |
313 movlw ':' | |
314 movwf POSTINC2 | |
315 movlw ' ' | |
316 movwf POSTINC2 | |
317 movlw '1' | |
318 movwf POSTINC2 | |
319 movlw '0' | |
320 btfsc second_FA | |
321 movwf POSTINC2 | |
322 movlw ' ' | |
323 movwf POSTINC2 | |
324 call word_processor | |
325 | |
79 | 326 menu_custom_functions10b: |
0 | 327 WIN_LEFT .20 |
328 WIN_TOP .125 | |
329 lfsr FSR2,letter | |
330 OUTPUTTEXT d'89' ;"Default:" | |
79 | 331 movlw ' ' |
0 | 332 movwf POSTINC2 |
333 | |
79 | 334 call display_customfunction ; Typed display. |
0 | 335 |
336 WIN_LEFT .20 | |
337 WIN_TOP .155 | |
338 lfsr FSR2,letter | |
339 OUTPUTTEXT d'97' ; "Current:" | |
79 | 340 movlw ' ' |
341 movwf POSTINC2 | |
0 | 342 |
343 movf divemins+0,W | |
344 addlw 0x82 | |
345 movwf EEADR | |
346 call read_eeprom ; Lowbyte | |
347 movff EEDATA,lo | |
79 | 348 |
0 | 349 movf divemins+0,W |
350 addlw 0x83 | |
351 movwf EEADR | |
352 call read_eeprom ; Highbyte | |
79 | 353 |
354 btfss hi,7 ; A 15bit value ? | |
355 bra menu_custom_functions1b ; No : keep types there ! | |
356 | |
0 | 357 movff EEDATA,hi |
79 | 358 bsf hi,7 ; Mark it a 15bit value. |
359 | |
360 menu_custom_functions1b: | |
361 call display_customfunction | |
0 | 362 |
363 menu_custom_functions1a: | |
364 DISPLAYTEXT .11 ; Exit | |
365 | |
366 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
367 call PLED_menu_cursor | |
368 | |
369 customfunctions_loop: | |
370 call check_switches_logbook | |
371 | |
372 btfsc menubit3 | |
373 bra customfunctions2 ; Move cursor or generate next page | |
374 | |
375 btfsc menubit2 | |
376 bra do_customfunction ; call subfunction | |
377 | |
378 btfsc divemode | |
379 goto restart ; dive started during cf menu | |
380 | |
381 btfsc onesecupdate | |
382 call timeout_surfmode | |
383 | |
384 btfsc onesecupdate | |
385 call set_dive_modes | |
386 | |
387 bcf onesecupdate ; end of 1sek. tasks | |
388 | |
389 btfsc sleepmode | |
390 bra exit_customfunctions | |
391 | |
392 bra customfunctions_loop | |
393 | |
394 customfunctions2: | |
395 incf menupos,F | |
396 movlw d'7' | |
397 cpfseq menupos ; =7? | |
398 bra customfunctions3 ; No | |
399 movlw d'1' | |
400 movwf menupos | |
401 | |
402 customfunctions3: | |
403 clrf timeout_counter2 | |
404 call PLED_menu_cursor | |
405 | |
406 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
407 | |
408 bcf menubit3 ; clear flag | |
409 bra customfunctions_loop | |
410 | |
79 | 411 ;----------------------------------------------------------------------------- |
412 ; Input : hi:lo = data to display, with type embebed into hi | |
413 ; FSR2 = current string pointer. | |
414 ; Trash : FSR1 (used to backup EEADRH and hi) | |
415 | |
416 display_customfunction: | |
417 #ifndef NO_CF_TYPES | |
418 movff EEADRH, FSR1H ; Backup... | |
419 movff hi, FSR1L | |
420 | |
421 ;---- decode type -------------------------------------------------------- | |
422 movf hi,W ; Just set N/Z flags | |
423 bn cf_type_0 ; Keep 15bits value in old format. | |
424 bz cf_type_99 ; 8bit standard mode | |
425 | |
426 ; Jump table: | |
427 dcfsnz hi | |
428 bra cf_type_01 | |
429 dcfsnz hi | |
430 bra cf_type_02 | |
431 dcfsnz hi | |
432 bra cf_type_03 | |
433 dcfsnz hi | |
434 bra cf_type_04 | |
435 dcfsnz hi | |
436 bra cf_type_05 | |
437 dcfsnz hi | |
438 bra cf_type_06 | |
439 dcfsnz hi | |
440 bra cf_type_07 | |
441 bra cf_type_99 ; Default to 8bit mode... | |
442 | |
443 cf_type_01: ; Type == 1 is percent mode | |
444 output_16dp 0 ; NOTE : hi is already reseted... | |
445 movlw '%' | |
446 movwf POSTINC2 | |
447 bra cf_done | |
448 | |
449 cf_type_02: ; Type == 2 is deci mode. | |
450 output_16dp 4 | |
451 bra cf_done | |
452 | |
453 cf_type_03: ; Type == 3 is centi mode. | |
454 output_16dp 3 | |
455 bra cf_done | |
456 | |
457 cf_type_04: ; Type == 4 is mili mode | |
458 output_16dp 2 | |
459 bra cf_done | |
460 | |
461 cf_type_05: ; Type == 5 is on/off mode. | |
462 movf lo,W ; Get flag value... | |
463 bz cf_type_off | |
464 OUTPUTTEXT d'130' ; ON | |
465 bra cf_done | |
466 cf_type_off: | |
467 OUTPUTTEXT d'131' ; OFF | |
468 bra cf_done | |
469 | |
470 cf_type_06: ; Type == 6 is mm:ss mode (... or hh:mm) | |
471 call convert_time ; Convert to min:sec into hi:low. | |
472 movff lo,wp_temp ; Save seconds, | |
473 movff hi,lo ; Get minutes | |
474 output_8 ; Print them | |
475 movlw ':' ; Separator | |
476 movwf POSTINC2 | |
477 movff wp_temp,lo ; Get back seconds | |
478 output_99x ; lo in 2 digits with trailing zeros. | |
479 bra cf_done | |
480 | |
481 cf_type_07: ; Type == 7 is Color swatch. | |
482 output_8 | |
483 | |
484 movf lo,W ; Get color. | |
485 movff WREG,box_temp+0 ; Set color | |
486 movff win_top,WREG ; BEWARE : this is a bank0 variable ! | |
487 movff WREG,box_temp+1 ; row top (0-239) | |
488 addlw .23 | |
489 movff WREG,box_temp+2 ; row bottom (0-239) | |
490 movlw .110 | |
491 movff WREG,box_temp+3 ; column left (0-159) | |
492 movlw .140 | |
493 movff WREG,box_temp+4 ; column right (0-159) | |
494 | |
495 call PLED_box | |
496 bra cf_done ; W/o trailling spaces... | |
497 | |
498 cf_type_99: ; 8bit mode. Or unrecognized type... | |
499 clrf hi | |
500 | |
501 cf_type_0: ; 15bit mode. | |
502 bcf hi,7 | |
503 output_16 | |
504 | |
505 cf_done: | |
506 movff FSR1L, hi ; Restore saved registers... | |
507 movff FSR1H, EEADRH | |
508 #else | |
509 bcf hi,7 ; clear Bit 7 of value | |
510 output_16 | |
511 | |
512 movff win_top,WREG ; Get "Default:" line position (BANK0 !) | |
513 xorlw .125 ; This is the default value ? | |
514 bnz cf_no_bits ; NO: skip bits for current value | |
515 | |
516 movlw ',' | |
517 movwf POSTINC2 | |
518 | |
519 movlw '1' | |
520 btfss EEDATA,7 ; 15Bit? | |
521 movlw '8' ; 8Bit! | |
522 tstfsz apnoe_mins ; apnoe_mins=0? | |
523 movlw '1' ; No, 1Bit! | |
524 movwf POSTINC2 | |
525 | |
526 movlw '5' | |
527 btfsc EEDATA,7 ; 15Bit? | |
528 movwf POSTINC2 | |
529 movlw 'B' | |
530 movwf POSTINC2 | |
531 | |
532 cf_no_bits: | |
533 movlw ' ' | |
534 movwf POSTINC2 | |
535 movwf POSTINC2 | |
536 movwf POSTINC2 | |
537 #endif | |
538 goto word_processor | |
539 | |
540 ;----------------------------------------------------------------------------- | |
0 | 541 |
542 do_customfunction: | |
543 CLRF EEADRH | |
544 movlw d'1' | |
545 btfsc customfunction_page | |
546 movwf EEADRH ; Reset EEADRH correct (Was adjusted in check_timeout...) | |
547 | |
548 dcfsnz menupos,F | |
549 bra next_customfunction | |
550 dcfsnz menupos,F | |
551 bra toggle_plusminus | |
552 dcfsnz menupos,F | |
553 bra toggle_oneorten | |
554 dcfsnz menupos,F | |
555 bra restore_cfn_value | |
556 dcfsnz menupos,F | |
557 bra adjust_cfn_value | |
558 exit_customfunctions: | |
559 movlw d'2' ; Return to correct list entry | |
560 btfss customfunction_page | |
561 movlw d'1' | |
562 movwf menupos ; | |
563 clrf EEADRH ; Clear EEADRH ! | |
564 goto setup_menu2 ; exit... | |
565 | |
566 | |
567 next_customfunction: | |
568 incf decodata+0 | |
569 btfsc decodata+0,5 ;>31? | |
570 clrf decodata+0 ;Yes, so reset to zero | |
571 | |
572 movf decodata+0,W | |
573 mullw d'4' | |
574 movff PRODL, divemins+0 ;divemins+0 for correct addressing | |
575 | |
576 movlw d'1' | |
577 movwf menupos | |
578 bra menu_custom_functions1 ; also debounces switches | |
579 | |
580 toggle_plusminus: | |
581 btg first_FA | |
582 movlw d'2' | |
583 movwf menupos | |
584 bra menu_custom_functions1 ; also debounces switches | |
585 | |
586 toggle_oneorten: | |
587 btg second_FA | |
588 movlw d'3' | |
589 movwf menupos | |
590 bra menu_custom_functions1 ; also debounces switches | |
591 | |
592 restore_cfn_value: | |
593 movf divemins+0,W ; read default value | |
594 addlw 0x80 | |
595 movwf EEADR | |
596 call read_eeprom ; Lowbyte | |
597 movff EEDATA,lo | |
598 movf divemins+0,W | |
599 addlw 0x81 | |
600 movwf EEADR | |
601 call read_eeprom ; Highbyte | |
602 movff EEDATA,hi | |
603 bcf hi,7 ; clear bit 7 of value | |
604 | |
605 movf divemins+0,W ; store default value | |
606 addlw 0x82 | |
607 movwf EEADR | |
608 movff lo,EEDATA | |
609 call write_eeprom ; Lowbyte | |
610 movf divemins+0,W | |
611 addlw 0x83 | |
612 movwf EEADR | |
613 movff hi,EEDATA | |
614 call write_eeprom ; Highbyte | |
615 | |
616 movlw d'4' | |
617 movwf menupos | |
618 bra menu_custom_functions1 ; also debounces switches | |
619 | |
620 adjust_cfn_value: | |
621 movf divemins+0,W ; get current value | |
622 addlw 0x82 | |
623 movwf EEADR | |
624 call read_eeprom ; Lowbyte | |
625 movff EEDATA,lo | |
626 movf divemins+0,W | |
627 addlw 0x83 | |
628 movwf EEADR | |
629 call read_eeprom ; Highbyte | |
630 movff EEDATA,hi | |
631 | |
632 movf divemins+0,W | |
633 addlw 0x81 | |
634 movwf EEADR | |
635 call read_eeprom ; Highbyte | |
636 movff EEDATA,divemins+1 ; Highbyte of default value | |
637 | |
79 | 638 btfss apnoe_mins,0 ; If apnoe_mins=1 then CF is binary |
0 | 639 bra adjust_cfn_value1 ; Not Binary |
640 | |
641 tstfsz lo ; =0? | |
642 setf lo ; No, Set to 255 | |
643 incf lo,F ; Increase by one | |
644 clrf hi ; Delete hi byte (Not required but to make sure...) | |
645 bra adjust_cfn_value3 ; Store result | |
646 | |
647 adjust_cfn_value1: | |
648 btfss first_FA ; Minus? | |
649 bra adjust_cfn_value2 ; No, Plus | |
650 | |
651 movlw d'1' | |
652 btfsc second_FA ; -10? | |
653 movlw d'10' | |
654 | |
655 subwf lo,F ; substract value | |
656 movlw d'0' | |
657 btfsc divemins+1,7 ; 8Bit value | |
658 subwfb hi,F | |
659 | |
660 movlw b'01111111' | |
661 btfsc hi,7 ; >32768? | |
662 movwf hi | |
663 | |
664 bra adjust_cfn_value3 | |
665 | |
666 adjust_cfn_value2: | |
667 movlw d'1' | |
668 btfsc second_FA ; +10? | |
669 movlw d'10' | |
670 | |
671 addwf lo,F ; add value | |
672 movlw d'0' | |
673 btfsc divemins+1,7 ; 8Bit value? | |
674 addwfc hi,F | |
675 | |
676 btfsc hi,7 ; >32768? | |
677 clrf hi | |
678 | |
679 adjust_cfn_value3: | |
680 movf divemins+0,W ; Store current value | |
681 addlw 0x82 | |
682 movwf EEADR | |
683 movff lo,EEDATA | |
684 call write_eeprom ; Lowbyte | |
685 movf divemins+0,W | |
686 addlw 0x83 | |
687 movwf EEADR | |
688 movff hi,EEDATA | |
689 call write_eeprom ; Highbyte | |
690 movlw d'5' | |
691 movwf menupos | |
692 bra menu_custom_functions1 ; also debounces switches | |
693 | |
694 getcustom15_default: | |
695 ; # number of requested custom function in wreg | |
696 movwf customfunction_temp2 | |
697 | |
698 movlw d'31' | |
699 cpfsgt customfunction_temp2 | |
700 bra getcustom15_d2 ; Lower bank | |
701 | |
702 movlw d'1' ; Upper Bank | |
703 movwf EEADRH | |
704 movlw d'32' | |
705 subwf customfunction_temp2,F | |
706 bra getcustom15_d3 | |
707 getcustom15_d2: | |
708 clrf EEADRH | |
709 getcustom15_d3: | |
710 movf customfunction_temp2,W | |
711 mullw d'4' | |
712 movf PRODL,W ; x4 for adress | |
713 addlw d'128' | |
714 movwf EEADR ; +130 for LOW Byte of value | |
715 call read_eeprom ; Lowbyte | |
716 movff EEDATA,lo | |
717 incf EEADR,F | |
718 call read_eeprom ; Highbyte | |
719 movff EEDATA,hi | |
720 clrf EEADRH | |
79 | 721 #ifndef NO_CF_TYPES |
722 btfss hi,7 ; Is it a 15bit value ? | |
723 clrf hi ; NO: clear type flags. | |
724 #endif | |
725 bcf hi,7 ; Always clear 15bit flag. | |
0 | 726 return ; return |
727 | |
728 custom_functions_check_divemode: ;displays warning if a critical custom function is not set to default | |
729 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
730 bra check_cf11 | |
731 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
732 bra check_cf12 | |
733 return | |
734 | |
735 custom_functions_check_surfmode: ;displays warning if a critical custom function is not set to default | |
736 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
737 bra check_cf11 | |
738 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
739 bra check_cf12 | |
740 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
741 bra check_cf17 | |
742 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
743 bra check_cf18 | |
744 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
745 bra check_cf19 | |
746 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
747 bra check_cf29 | |
748 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
749 bra check_cf32 | |
750 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
751 bra check_cf33 | |
752 return | |
753 | |
754 check_cf11: | |
755 movlw d'11' ; saturation factor | |
756 rcall custom_function_check_low ; compares current with default value | |
757 call test_and_display_warning ; displays the warning if the custom function is not correct | |
758 movlw d'2' ; next in testing row | |
759 movwf cf_checker_counter ; | |
760 return | |
761 | |
762 check_cf12: | |
763 movlw d'12' ; desaturation factor | |
764 rcall custom_function_check_high ; compares current with default value | |
765 call test_and_display_warning ; displays the warning if the custom function is not correct | |
766 movlw d'3' ; next in testing row | |
767 movwf cf_checker_counter ; | |
768 return | |
769 | |
770 check_cf17: | |
771 movlw d'17' ; lower threshold ppO2 | |
772 rcall custom_function_check_low ; compares current with default value | |
773 call test_and_display_warning ; displays the warning if the custom function is not correct | |
774 movlw d'4' ; next in testing row | |
775 movwf cf_checker_counter ; | |
776 return | |
777 | |
778 check_cf18: | |
779 movlw d'18' ; upper threshold ppO2 | |
780 rcall custom_function_check_high ; compares current with default value | |
781 call test_and_display_warning ; displays the warning if the custom function is not correct | |
782 movlw d'5' ; next in testing row | |
783 movwf cf_checker_counter ; | |
784 return | |
785 | |
786 check_cf19: | |
787 movlw d'19' ; upper threshold ppO2 display | |
788 rcall custom_function_check_high ; compares current with default value | |
789 call test_and_display_warning ; displays the warning if the custom function is not correct | |
790 movlw d'6' ; next in testing row | |
791 movwf cf_checker_counter ; | |
792 return | |
793 | |
794 check_cf29: | |
795 movlw d'6' | |
796 movwf cf_checker_counter ; upper limit for CF29, here: used as a temp variable | |
797 movlw d'29' ; last deco stop in [m] | |
798 rcall custom_function_check_high_limit ; compares current with default value | |
799 call test_and_display_warning ; displays the warning if the custom function is not correct | |
800 movlw d'7' ; next in testing row | |
801 movwf cf_checker_counter ; | |
802 return | |
803 | |
804 check_cf32: | |
805 movlw d'32' ; GF LOW | |
806 rcall custom_function_check_high ; compares current with default value | |
807 call test_and_display_warning ; displays the warning if the custom function is not correct | |
808 movlw d'8' ; next in testing row | |
809 movwf cf_checker_counter ; | |
810 return | |
811 | |
812 check_cf33: | |
813 movlw d'33' ; GF HIGH | |
814 rcall custom_function_check_high ; compares current with default value | |
815 call test_and_display_warning ; displays the warning if the custom function is not correct | |
816 movlw d'1' ; next in testing row | |
817 movwf cf_checker_counter ; | |
818 return | |
819 | |
820 | |
821 test_and_display_warning: | |
822 movwf lo ; copy result | |
823 tstfsz lo | |
824 return ; CF OK | |
825 goto custom_warn_surfmode | |
826 | |
827 custom_function_check_low: ; Checks CF (#WREG) | |
828 ; Returns WREG=0 if CF is lower then default | |
829 movwf temp1 ; save for custom value | |
830 call getcustom15_1 ; Get Current Value stored in hi and lo | |
831 movff lo,sub_a+0 | |
832 movff hi,sub_a+1 ; save value | |
833 | |
834 movf temp1,w | |
835 call getcustom15_default ; Get Default value stored in hi and lo | |
836 movff lo,sub_b+0 | |
837 movff hi,sub_b+1 ; save value | |
838 call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a | |
839 btfss neg_flag ; negative? | |
840 retlw .255 ; no | |
841 retlw .0 ; yes | |
842 | |
843 custom_function_check_high: ; Checks CF (#WREG) | |
844 ; Returns WREG=0 if CF is higher then default | |
845 movwf temp1 ; save for custom value | |
846 call getcustom15_1 ; Get Current Value stored in hi and lo | |
847 movff lo,sub_b+0 | |
848 movff hi,sub_b+1 ; save value | |
849 | |
850 movf temp1,w | |
851 call getcustom15_default ; Get Default value stored in hi and lo | |
852 movff lo,sub_a+0 | |
853 movff hi,sub_a+1 ; save value | |
854 call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a | |
855 btfss neg_flag ; negative? | |
856 retlw .255 ; no | |
857 retlw .0 ; yes | |
858 | |
859 custom_function_check_high_limit: ; Checks if CF (#WREG) is lower then limit (#cf_checker_counter) | |
860 movwf temp1 ; save for custom value | |
861 call getcustom15_1 ; Get Current Value stored in hi and lo | |
862 movff lo,sub_b+0 | |
863 movff hi,sub_b+1 ; save value | |
864 movff cf_checker_counter, sub_a+0 | |
865 clrf sub_a+1 | |
866 call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a | |
867 btfss neg_flag ; negative? | |
868 retlw .255 ; no | |
25 | 869 retlw .0 ; yes |