Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 84:0f4c175ef824
FIX flickering in new CF menus
author | JeanDo |
---|---|
date | Wed, 08 Dec 2010 02:03:11 +0100 |
parents | c97c5514b165 |
children | 6f8e3a08011e |
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 ; Gas Setup menu | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 10/08/07 | |
22 ; last updated: 080906 | |
23 ; known bugs: | |
24 ; ToDo: | |
25 | |
26 menu_gassetup: | |
27 movlw d'1' | |
28 movwf menupos | |
29 | |
30 menu_gassetup_prelist: | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
31 call PLED_ClearScreen |
47 | 32 call gassetup_sort_gaslist ; Sorts Gaslist according to change depth |
0 | 33 clrf timeout_counter2 |
34 bcf sleepmode | |
35 bcf menubit2 | |
36 bcf menubit3 | |
37 call PLED_topline_box | |
38 WIN_INVERT .1 ; Init new Wordprocessor | |
39 DISPLAYTEXT .106 ; Gas List | |
40 WIN_INVERT .0 ; Init new Wordprocessor | |
41 clrf decodata+0 ; Here: # of gas 0-4 | |
42 clrf divemins+0 ; Here: # of Gas * 4 | |
43 movlw d'5' | |
44 movwf waitms_temp ; here: stores row for gas list | |
45 movlw d'2' | |
46 movwf wait_temp ; here: stores eeprom address for gas list | |
47 | |
48 ; Changed v1.44se | |
49 menu_gassetup_list: | |
50 WIN_LEFT .20 | |
51 movlw d'4' | |
52 addwf wait_temp,F ; Increase eeprom address for gas list | |
53 movlw d'30' | |
54 addwf waitms_temp,F ; Increase row | |
55 movf waitms_temp,W ; Load row into WREG | |
56 movff WREG,win_top | |
57 lfsr FSR2,letter | |
58 movlw 'G' | |
59 movwf POSTINC2 | |
60 movff decodata+0,lo | |
61 incf lo,F | |
62 bsf leftbind | |
63 output_99 | |
64 movlw ':' | |
65 movwf POSTINC2 | |
66 | |
67 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases | |
68 call word_processor | |
69 WIN_LEFT .40 | |
70 movf waitms_temp,W ; Load row into WREG | |
71 movff WREG,win_top | |
72 lfsr FSR2,letter | |
73 | |
74 movlw d'33' | |
75 movwf EEADR | |
76 call read_eeprom ; Get current startgas 1-5 # into EEDATA | |
77 decf EEDATA,W ; 0-4 | |
78 cpfseq decodata+0 ; =current displayed gas #? | |
79 bra menu_gassetup_Tx ; no, do not display * | |
80 movlw '*' ; display * | |
81 movwf POSTINC2 | |
82 | |
83 ; New v1.44se | |
84 menu_gassetup_Tx: | |
85 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases | |
86 call word_processor | |
87 | |
88 WIN_LEFT .48 | |
89 movf waitms_temp,W ; Load row into WREG | |
90 movff WREG,win_top | |
91 lfsr FSR2,letter | |
92 | |
93 movff wait_temp, EEADR ; Gas %He - Set address in internal EEPROM | |
94 incf EEADR,F ; Gas %He - Set address in internal EEPROM | |
95 call read_eeprom ; Read He value from EEPROM | |
96 movff EEDATA,lo ; Move EEDATA -> lo | |
97 movf lo,f ; Move lo -> f | |
98 movlw d'0' ; Move 0 -> WREG | |
99 cpfsgt lo ; He > 0? | |
100 bra menu_gassetup_Nx ; NO check o2 | |
101 | |
102 ; YES Write TX 15/55 | |
103 call gassetup_write_Tx | |
104 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM | |
105 call read_eeprom ; O2 value | |
106 movff EEDATA,lo | |
107 output_8 | |
108 movlw '/' | |
109 movwf POSTINC2 | |
110 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM | |
111 call read_eeprom ; He value | |
112 movff EEDATA,lo | |
113 output_8 | |
114 bra menu_gassetup_list0 | |
115 | |
116 ; New v1.44se | |
117 menu_gassetup_Nx: | |
118 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM | |
119 call read_eeprom ; Read O2 value from EEPROM | |
120 movff EEDATA,lo ; Move EEDATA -> lo | |
121 movf lo,f ; Move lo -> f | |
122 movlw d'21' ; Move 21 -> WREG | |
123 cpfsgt lo ; o2 > 21% | |
124 bra menu_gassetup_Air ; NO AIR | |
125 movlw d'100' ; Move 100 -> WREG | |
126 cpfslt lo ; o2 < 100% | |
127 bra menu_gassetup_O2 ; NO write O2 | |
128 | |
129 ; YES Write NX 32 | |
130 call gassetup_write_Nx | |
131 output_8 | |
132 bra menu_gassetup_list0 | |
133 | |
134 ; New v1.44se | |
135 menu_gassetup_O2: | |
136 movlw 'O' | |
137 movwf POSTINC2 | |
138 movlw '2' | |
139 movwf POSTINC2 | |
140 movlw ' ' | |
141 movwf POSTINC2 | |
142 output_8 | |
143 bra menu_gassetup_list0 | |
144 | |
145 ; New v1.44se | |
146 menu_gassetup_Air: | |
147 cpfseq lo ; o2 = 21% | |
148 call menu_gassetup_Err | |
149 | |
150 movlw 'A' | |
151 movwf POSTINC2 | |
152 movlw 'I' | |
153 movwf POSTINC2 | |
154 movlw 'R' | |
155 movwf POSTINC2 | |
156 movlw ' ' | |
157 movwf POSTINC2 | |
158 output_8 | |
159 bra menu_gassetup_list0 | |
160 | |
161 ; New v1.44se | |
162 menu_gassetup_Err: | |
163 movlw 'E' | |
164 movwf POSTINC2 | |
165 movlw 'R' | |
166 movwf POSTINC2 | |
167 movlw 'R' | |
168 movwf POSTINC2 | |
169 movlw ' ' | |
170 movwf POSTINC2 | |
171 output_8 | |
172 | |
173 ; Changed v1.44se | |
174 menu_gassetup_list0: | |
175 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases | |
176 call word_processor | |
177 | |
178 WIN_LEFT .105 | |
179 movf waitms_temp,W ; Load row into WREG | |
180 movff WREG,win_top | |
181 lfsr FSR2,letter | |
182 | |
183 movlw ' ' | |
184 movwf POSTINC2 | |
185 movlw 'i' | |
186 movwf POSTINC2 | |
187 movlw 'n' | |
188 movwf POSTINC2 | |
189 movlw ' ' | |
190 movwf POSTINC2 | |
191 movf decodata+0,W ; read current value | |
192 addlw d'28' ; offset in memory | |
193 movwf EEADR | |
194 call read_eeprom ; Low-value | |
195 movff EEDATA,lo | |
196 output_8 | |
197 movlw 'm' | |
198 movwf POSTINC2 | |
199 call menu_gassetup_grey_inactive ; Sets Greyvalue for inactive gases | |
200 call word_processor | |
201 | |
3 | 202 call PLED_standard_color |
0 | 203 |
204 incf decodata+0,F | |
205 movlw d'5' | |
206 cpfseq decodata+0 | |
207 goto menu_gassetup_list | |
208 | |
209 DISPLAYTEXT .11 ; Exit | |
210 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
211 call PLED_menu_cursor | |
212 | |
213 gassetup_list_loop: | |
214 call check_switches_logbook | |
215 | |
216 btfsc menubit3 | |
217 bra gassetup_list2 ; move cursor | |
218 | |
219 btfsc menubit2 | |
220 bra do_gassetup_list; call gas-specific submenu | |
221 | |
222 btfsc divemode | |
223 goto restart ; dive started! | |
224 | |
225 btfsc onesecupdate | |
226 call timeout_surfmode | |
227 | |
228 btfsc onesecupdate | |
229 call set_dive_modes | |
230 | |
231 bcf onesecupdate ; 1 sec. functions done | |
232 | |
233 btfsc sleepmode | |
234 bra exit_gassetup_list | |
235 | |
236 bra gassetup_list_loop | |
237 | |
238 gassetup_list2: | |
239 incf menupos,F | |
240 movlw d'7' | |
241 cpfseq menupos ; =7? | |
242 bra gassetup_list3 ; No | |
243 movlw d'1' | |
244 movwf menupos | |
245 | |
246 gassetup_list3: | |
247 clrf timeout_counter2 | |
248 call PLED_menu_cursor | |
249 | |
250 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
251 | |
252 bcf menubit3 ; clear flag | |
253 bra gassetup_list_loop | |
254 | |
255 exit_gassetup_list: ; exit... | |
256 movlw d'2' | |
257 movwf menupos | |
258 goto menu2 | |
259 | |
260 do_gassetup_list: | |
261 dcfsnz menupos,F | |
262 bra gassetup_list_edit_gas1 | |
263 dcfsnz menupos,F | |
264 bra gassetup_list_edit_gas2 | |
265 dcfsnz menupos,F | |
266 bra gassetup_list_edit_gas3 | |
267 dcfsnz menupos,F | |
268 bra gassetup_list_edit_gas4 | |
269 dcfsnz menupos,F | |
270 bra gassetup_list_edit_gas5 | |
271 bra exit_gassetup_list ; Exit List | |
272 | |
273 gassetup_list_edit_gas1: | |
274 movlw d'0' | |
275 movwf decodata+0 | |
276 movlw d'0' | |
277 movwf divemins+0 | |
278 bra menu_gassetup_page1 | |
279 | |
280 gassetup_list_edit_gas2: | |
281 movlw d'1' | |
282 movwf decodata+0 | |
283 movlw d'4' | |
284 movwf divemins+0 | |
285 bra menu_gassetup_page1 | |
286 | |
287 gassetup_list_edit_gas3: | |
288 movlw d'2' | |
289 movwf decodata+0 | |
290 movlw d'8' | |
291 movwf divemins+0 | |
292 bra menu_gassetup_page1 | |
293 | |
294 gassetup_list_edit_gas4: | |
295 movlw d'3' | |
296 movwf decodata+0 | |
297 movlw d'12' | |
298 movwf divemins+0 | |
299 bra menu_gassetup_page1 | |
300 | |
301 gassetup_list_edit_gas5: | |
302 movlw d'4' | |
303 movwf decodata+0 | |
304 movlw d'16' | |
305 movwf divemins+0 | |
306 bra menu_gassetup_page1 | |
307 | |
308 menu_gassetup_page1: | |
309 movlw d'1' | |
310 movwf menupos | |
311 bcf gas_setup_page2 ; Page 1 of gassetup | |
312 bcf menubit4 | |
313 bcf cursor | |
314 bcf sleepmode | |
315 bcf first_FA ; Here: =1: -, =0: + | |
316 | |
317 menu_gassetup0: | |
318 call PLED_ClearScreen | |
319 DISPLAYTEXT .30 ; More... | |
320 DISPLAYTEXT .11 ; Exit | |
321 | |
322 menu_gassetup1: | |
323 clrf timeout_counter2 | |
324 bcf menubit2 | |
325 bcf menubit3 | |
326 | |
327 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info | |
328 | |
329 WIN_TOP .65 | |
330 WIN_LEFT .20 | |
331 lfsr FSR2,letter | |
332 movlw 'O' | |
333 movwf POSTINC2 | |
334 movlw '2' | |
335 movwf POSTINC2 | |
336 movlw ':' | |
337 movwf POSTINC2 | |
338 movlw ' ' | |
339 movwf POSTINC2 | |
340 | |
341 movf divemins+0,W | |
342 addlw 0x06 | |
343 movwf EEADR | |
344 call read_eeprom ; O2 value | |
345 movff EEDATA,lo | |
346 output_8 | |
347 movlw '%' | |
348 movwf POSTINC2 | |
349 movlw ' ' | |
350 movwf POSTINC2 | |
351 movlw '(' | |
352 movwf POSTINC2 | |
353 movlw 'M' | |
354 movwf POSTINC2 | |
355 movlw 'O' | |
356 movwf POSTINC2 | |
357 movlw 'D' | |
358 movwf POSTINC2 | |
359 movlw ':' | |
360 movwf POSTINC2 | |
361 | |
362 ; Show MOD in m | |
363 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
364 mullw d'10' | |
365 movff PRODL,xA+0 | |
366 movff PRODH,xA+1 ; ppO2 in [0.01Bar] * 10 | |
367 | |
368 movf divemins+0,W | |
369 addlw 0x06 | |
370 movwf EEADR | |
371 call read_eeprom ; O2 value | |
372 movff EEDATA,xB+0 | |
373 clrf xB+1 | |
374 call div16x16 ;xA/xB=xC with xA as remainder | |
375 movlw d'10' | |
376 subwf xC+0,F ; Subtract 10m... | |
377 movff xC+0,lo | |
378 movlw d'0' | |
379 subwfb xC+1,F | |
380 movff xC+1,hi | |
381 output_16 | |
382 movlw 'm' | |
383 movwf POSTINC2 | |
384 movlw ')' | |
385 movwf POSTINC2 | |
386 movlw ' ' | |
387 movwf POSTINC2 | |
388 movlw ' ' | |
389 movwf POSTINC2 | |
390 call word_processor | |
391 | |
392 WIN_TOP .95 | |
393 lfsr FSR2,letter | |
394 movlw 'H' | |
395 movwf POSTINC2 | |
396 movlw 'e' | |
397 movwf POSTINC2 | |
398 movlw ':' | |
399 movwf POSTINC2 | |
400 movlw ' ' | |
401 movwf POSTINC2 | |
402 movf divemins+0,W | |
403 addlw 0x07 | |
404 movwf EEADR | |
405 call read_eeprom ; He value | |
406 movff EEDATA,lo | |
407 output_8 | |
408 movlw '%' | |
409 movwf POSTINC2 | |
410 movlw ' ' | |
411 movwf POSTINC2 | |
412 movlw ' ' | |
413 movwf POSTINC2 | |
414 call word_processor | |
415 | |
416 WIN_TOP .125 | |
417 lfsr FSR2,letter | |
418 movlw '+' | |
419 movwf POSTINC2 | |
420 movlw '/' | |
421 movwf POSTINC2 | |
422 movlw '-' | |
423 movwf POSTINC2 | |
424 movlw ':' | |
425 movwf POSTINC2 | |
426 movlw ' ' | |
427 movwf POSTINC2 | |
428 movlw '+' | |
429 btfsc first_FA | |
430 movlw '-' | |
431 movwf POSTINC2 | |
432 call word_processor | |
433 | |
434 WIN_TOP .155 | |
435 lfsr FSR2,letter | |
436 OUTPUTTEXT .89 ; Default: | |
437 movf divemins+0,W | |
438 addlw 0x04 | |
439 movwf EEADR | |
440 call read_eeprom ; Default O2 value | |
441 movff EEDATA,lo | |
442 output_8 | |
443 movlw '/' | |
444 movwf POSTINC2 | |
445 movf divemins+0,W | |
446 addlw 0x05 | |
447 movwf EEADR | |
448 call read_eeprom ; Default He value | |
449 movff EEDATA,lo | |
450 output_8 | |
451 movlw ' ' | |
452 movwf POSTINC2 | |
453 movlw ' ' | |
454 movwf POSTINC2 | |
455 call word_processor | |
456 | |
457 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
458 call PLED_menu_cursor | |
459 | |
460 gassetup_loop: | |
461 call check_switches_logbook | |
462 | |
463 btfsc menubit3 | |
464 bra gassetup2 ; move cursor | |
465 | |
466 btfsc menubit2 | |
467 bra do_gassetup ; call submenu | |
468 | |
469 btfsc divemode | |
470 goto restart ; dive started! | |
471 | |
472 btfsc onesecupdate | |
473 call timeout_surfmode | |
474 | |
475 btfsc onesecupdate | |
476 call set_dive_modes | |
477 | |
478 bcf onesecupdate ; 1 sec. functions done | |
479 | |
480 btfsc sleepmode | |
481 bra exit_gassetup | |
482 | |
483 bra gassetup_loop | |
484 | |
485 gassetup2: | |
486 incf menupos,F | |
487 movlw d'7' | |
488 cpfseq menupos ; =7? | |
489 bra gassetup3 ; No | |
490 movlw d'1' | |
491 movwf menupos | |
492 | |
493 gassetup3: | |
494 | |
495 clrf timeout_counter2 | |
496 call PLED_menu_cursor | |
497 | |
498 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
499 | |
500 bcf menubit3 ; clear flag | |
501 bra gassetup_loop | |
502 | |
503 do_gassetup: | |
504 dcfsnz menupos,F | |
505 bra next_gas_page | |
506 dcfsnz menupos,F | |
507 bra adjust_o2 | |
508 dcfsnz menupos,F | |
509 bra adjust_he | |
510 dcfsnz menupos,F | |
511 bra toggle_plus_minus_gassetup | |
512 dcfsnz menupos,F | |
513 bra restore_gas | |
514 exit_gassetup: ; exit... | |
515 movff decodata+0,menupos | |
516 incf menupos,F | |
517 bra menu_gassetup_prelist | |
518 | |
519 toggle_plus_minus_gassetup: | |
520 btg first_FA | |
521 movlw d'4' | |
522 movwf menupos | |
523 bra menu_gassetup1 ; return | |
524 | |
525 next_gas: | |
526 movlw d'1' | |
527 movwf menupos | |
528 bra menu_gassetup0 ; incl. clear screen | |
529 | |
530 adjust_o2: | |
531 movf divemins+0,W ; read current value | |
532 addlw 0x06 | |
533 movwf EEADR | |
534 call read_eeprom ; Low-value | |
535 movff EEDATA,lo | |
536 | |
537 btfsc first_FA ; Minus? | |
538 bra adjust_o2_1 ; yes, minus! | |
539 | |
540 incf lo,F ; increase O2 | |
541 movlw d'101' | |
542 cpfseq lo | |
543 bra adjust_o2_2 | |
544 movlw d'4' ; LOWER O2 Limit | |
545 movwf lo | |
546 bra adjust_o2_2 | |
547 | |
548 adjust_o2_1: | |
549 decf lo,F ; decrease O2 | |
550 movlw d'3' | |
551 cpfseq lo | |
552 bra adjust_o2_2 | |
553 | |
554 movf divemins+0,W | |
555 addlw 0x07 | |
556 movwf EEADR | |
557 call read_eeprom ; read He value | |
558 | |
559 movlw d'100' | |
560 movwf lo | |
561 movf EEDATA,W ; He value | |
562 subwf lo,F ; lo=100% - He% | |
563 | |
564 adjust_o2_2: ; test if O2+He>100... | |
565 movf divemins+0,W | |
566 addlw 0x07 | |
567 movwf EEADR | |
568 call read_eeprom ; read He value | |
569 movf EEDATA,W ; He value | |
570 addwf lo,W ; add O2 value | |
571 movwf hi ; store in temp | |
572 movlw d'101' | |
573 cpfseq hi ; O2 and He > 100? | |
574 bra adjust_o2_3 ; No! | |
575 | |
576 movlw d'4' ; LOWER O2 Limit | |
577 movwf lo | |
578 | |
579 adjust_o2_3: | |
580 movf divemins+0,W ; save current value | |
581 addlw 0x06 | |
582 movwf EEADR | |
583 movff lo,EEDATA | |
584 call write_eeprom ; Low-value | |
585 | |
586 movlw d'2' | |
587 movwf menupos | |
588 bra menu_gassetup1 | |
589 | |
590 adjust_he: | |
591 movf divemins+0,W ; read current value | |
592 addlw 0x07 | |
593 movwf EEADR | |
594 call read_eeprom ; Low-value | |
595 movff EEDATA,lo | |
596 | |
597 btfsc first_FA ; Minus? | |
598 bra adjust_he_1 ; yes, minus! | |
599 | |
600 incf lo,F | |
601 movlw d'92' ; He limited to (useless) 90% | |
602 cpfseq lo | |
603 bra adjust_he_2 | |
604 clrf lo | |
605 bra adjust_he_2 | |
606 | |
607 adjust_he_1: | |
608 decf lo,F ; decrease He | |
609 movlw d'255' | |
610 cpfseq lo | |
611 bra adjust_he_2 | |
612 clrf lo | |
613 | |
614 adjust_he_2: ; test if O2+He>100... | |
615 movf divemins+0,W | |
616 addlw 0x06 | |
617 movwf EEADR | |
618 call read_eeprom ; read He value | |
619 movf EEDATA,W ; He value | |
620 addwf lo,W ; add O2 value | |
621 movwf hi ; store in temp | |
622 movlw d'101' | |
623 cpfseq hi ; O2 and He > 100? | |
624 bra adjust_he_3 ; No! | |
625 ; clrf lo ; Yes, clear He to zero | |
626 decf lo,F ; reduce He again = unchanged after operation | |
627 | |
628 adjust_he_3: | |
629 movf divemins+0,W ; save current value | |
630 addlw 0x07 | |
631 movwf EEADR | |
632 movff lo,EEDATA | |
633 call write_eeprom ; Low-value | |
634 | |
635 movlw d'3' | |
636 movwf menupos | |
637 bra menu_gassetup1 ; | |
638 | |
639 restore_gas: | |
640 movf divemins+0,W ; read Default value | |
641 addlw 0x04 | |
642 movwf EEADR | |
643 call read_eeprom ; Low-value | |
644 movff EEDATA,lo | |
645 movf divemins+0,W | |
646 addlw 0x05 | |
647 movwf EEADR | |
648 call read_eeprom ; High-value | |
649 movff EEDATA,hi | |
650 | |
651 movf divemins+0,W ; save Default value | |
652 addlw 0x06 | |
653 movwf EEADR | |
654 movff lo,EEDATA | |
655 call write_eeprom ; Low-value | |
656 movf divemins+0,W | |
657 addlw 0x07 | |
658 movwf EEADR | |
659 movff hi,EEDATA | |
660 call write_eeprom ; High-value | |
661 | |
662 movlw d'5' | |
663 movwf menupos | |
664 bra menu_gassetup1 ; | |
665 | |
666 | |
667 next_gas_page: | |
668 call PLED_ClearScreen | |
669 movlw d'1' | |
670 movwf menupos | |
671 DISPLAYTEXT .109 ; Back | |
672 | |
673 DISPLAYTEXT .11 ; Exit | |
674 | |
675 next_gas_page1: | |
676 clrf timeout_counter2 | |
677 bcf menubit2 | |
678 bcf menubit3 | |
679 | |
680 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info | |
681 rcall gassetup_show_ppO2 ; Display the ppO2 of the change depth with the current gas | |
682 | |
683 WIN_TOP .65 | |
684 WIN_LEFT .20 | |
685 lfsr FSR2,letter | |
686 OUTPUTTEXT .105 ; "Active Gas? " | |
687 read_int_eeprom d'27' ; read flag register | |
688 | |
689 ; hi contains active gas flags in BIT0:4 .... | |
690 | |
691 movff decodata+0,lo ; Gas 0-4 | |
692 incf lo,F ; Gas 1-5 | |
693 | |
694 active_gas_display: | |
695 rrcf EEDATA ; roll flags into carry | |
696 decfsz lo,F ; max. 5 times... | |
697 bra active_gas_display | |
698 | |
699 btfss STATUS,C ; test carry | |
700 bra active_gas_display_no | |
701 | |
702 OUTPUTTEXT .96 ; Yes | |
703 bra active_gas_display_end | |
704 | |
705 active_gas_display_no: | |
706 movlw ' ' ; three spaces instead of "Yes" | |
707 movwf POSTINC2 | |
708 movlw ' ' | |
709 movwf POSTINC2 | |
710 movlw ' ' | |
711 movwf POSTINC2 | |
712 | |
713 active_gas_display_end: | |
714 call word_processor | |
715 | |
716 WIN_TOP .95 | |
717 WIN_LEFT .20 | |
718 lfsr FSR2,letter | |
719 OUTPUTTEXT .88 ; First Gas? | |
720 movlw ' ' | |
721 movwf POSTINC2 | |
722 | |
723 movlw d'33' | |
724 movwf EEADR | |
725 call read_eeprom ; Get current startgas 1-5 # into EEDATA | |
726 decf EEDATA,W ; 0-4 | |
727 cpfseq decodata+0 ; =current displayed gas #? | |
728 bra menu_firstgas0 ; no, display three spaces | |
729 | |
730 OUTPUTTEXT .96 ; Yes | |
731 bra menu_firstgas1 | |
732 | |
733 menu_firstgas0: | |
734 movlw ' ' | |
735 movwf POSTINC2 | |
736 movlw ' ' | |
737 movwf POSTINC2 | |
738 movlw ' ' | |
739 movwf POSTINC2 | |
740 | |
741 menu_firstgas1: | |
742 call word_processor | |
743 | |
744 WIN_TOP .125 | |
745 WIN_LEFT .20 | |
746 lfsr FSR2,letter | |
747 OUTPUTTEXT .107 ; Change+ | |
748 call word_processor | |
749 | |
750 WIN_TOP .155 | |
751 WIN_LEFT .20 | |
752 lfsr FSR2,letter | |
753 OUTPUTTEXT .108 ; Change- | |
754 call word_processor | |
755 | |
756 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
757 call PLED_menu_cursor | |
758 | |
759 next_gas_page_loop: | |
760 call check_switches_logbook | |
761 | |
762 btfsc menubit3 | |
763 bra next_gas_page2 ; move cursor | |
764 | |
765 btfsc menubit2 | |
766 bra do_next_gas_page ; call submenu | |
767 | |
768 btfsc divemode | |
769 goto restart ; dive started! | |
770 | |
771 btfsc onesecupdate | |
772 call timeout_surfmode | |
773 | |
774 btfsc onesecupdate | |
775 call set_dive_modes | |
776 | |
777 bcf onesecupdate ; 1 sec. functions done | |
778 | |
779 btfsc sleepmode | |
780 bra exit_gassetup | |
781 | |
782 bra next_gas_page_loop | |
783 | |
784 next_gas_page2: | |
785 incf menupos,F | |
786 | |
787 movlw d'7' | |
788 cpfseq menupos ; =7? | |
789 bra next_gas_page3 ; No | |
790 movlw d'1' | |
791 movwf menupos | |
792 | |
793 next_gas_page3: | |
794 clrf timeout_counter2 | |
795 call PLED_menu_cursor | |
796 | |
797 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
798 | |
799 bcf menubit3 ; clear flag | |
800 bra next_gas_page_loop | |
801 | |
802 do_next_gas_page: | |
803 dcfsnz menupos,F | |
804 bra next_gas | |
805 dcfsnz menupos,F | |
806 bra toggle_active_gas | |
807 dcfsnz menupos,F | |
808 bra make_first_gas | |
809 dcfsnz menupos,F | |
810 bra change_gas_depth_plus | |
811 dcfsnz menupos,F | |
812 bra change_gas_depth_minus | |
813 bra exit_gassetup ; Exit menu | |
814 | |
815 make_first_gas: | |
816 movff decodata+0,EEDATA ; current gas (0-4) into EEDATA | |
817 incf EEDATA,F ; current gas (1-5) into EEDATA | |
818 movlw d'33' | |
819 movwf EEADR | |
820 call write_eeprom ; store in internal EEPROM | |
821 movlw d'3' | |
822 movwf menupos | |
823 bra next_gas_page1 | |
824 | |
825 toggle_active_gas: | |
826 read_int_eeprom d'27' ; read flag register | |
827 movff decodata+0,lo ; selected gas 0-4 | |
828 incf lo,F | |
829 dcfsnz lo,F | |
830 btg EEDATA,0 | |
831 dcfsnz lo,F | |
832 btg EEDATA,1 | |
833 dcfsnz lo,F | |
834 btg EEDATA,2 | |
835 dcfsnz lo,F | |
836 btg EEDATA,3 | |
837 dcfsnz lo,F | |
838 btg EEDATA,4 | |
839 write_int_eeprom d'27' ; write flag register | |
840 movlw d'2' | |
841 movwf menupos | |
842 bra next_gas_page1 | |
843 | |
844 change_gas_depth_plus: | |
845 movf decodata+0,W ; read current value | |
846 addlw d'28' ; offset in memory | |
847 movwf EEADR | |
848 call read_eeprom ; Low-value | |
849 movff EEDATA,lo | |
850 | |
851 incf lo,F ; increase depth | |
852 movlw d'100' ; Change depth limit + 1 | |
853 cpfseq lo | |
854 bra change_gas_depth_plus2 | |
855 movlw d'99' ; Change depth limit | |
856 movwf lo | |
857 change_gas_depth_plus2: | |
858 movff lo,EEDATA ; write result | |
859 call write_eeprom ; save result in EEPROM | |
860 | |
861 movlw d'4' | |
862 movwf menupos | |
863 bra next_gas_page1 | |
864 | |
865 | |
866 change_gas_depth_minus: | |
867 movf decodata+0,W ; read current value | |
868 addlw d'28' ; offset in memory | |
869 movwf EEADR | |
870 call read_eeprom ; Low-value | |
871 movff EEDATA,lo | |
872 | |
873 decf lo,F ; decrease depth | |
874 movlw d'255' | |
875 cpfseq lo | |
876 bra change_gas_depth_minus2 | |
877 movlw d'0' | |
878 movwf lo | |
879 | |
880 change_gas_depth_minus2: | |
881 movff lo,EEDATA ; write result | |
882 call write_eeprom ; save result in EEPROM | |
883 | |
884 movlw d'5' | |
885 movwf menupos | |
886 bra next_gas_page1 | |
887 | |
888 ; Changed v1.44se | |
889 gassetup_title_bar2: | |
890 call PLED_topline_box | |
891 WIN_INVERT .1 ; Init new Wordprocessor | |
892 WIN_TOP .2 | |
893 WIN_LEFT .0 | |
894 lfsr FSR2,letter | |
895 OUTPUTTEXT .95 ; Gas# | |
896 movff decodata+0,lo | |
897 incf lo,F | |
898 bsf leftbind | |
899 output_99 | |
900 movlw ':' | |
901 movwf POSTINC2 | |
902 movlw ' ' | |
903 movwf POSTINC2 | |
904 call word_processor | |
905 | |
906 WIN_TOP .2 | |
907 WIN_LEFT .50 | |
908 lfsr FSR2,letter | |
909 | |
910 ;He check | |
911 movf divemins+0,W | |
912 addlw 0x07 | |
913 movwf EEADR | |
914 call read_eeprom ; He value | |
915 movff EEDATA,lo ; Move EEData -> lo | |
916 movf lo,f ; Move lo -> f | |
917 movlw d'0' ; Move 0 -> WREG | |
918 cpfsgt lo ; He > 0? | |
919 bra gassetup_title_bar3 ; NO check o2 | |
920 | |
921 ; YES Write TX 15/55 | |
922 call gassetup_write_Tx ; Write TX | |
923 movf divemins+0,W | |
924 addlw 0x06 | |
925 movwf EEADR | |
926 call read_eeprom ; O2 value | |
927 movff EEDATA,lo | |
928 output_8 ; Write O2 | |
929 movlw '/' | |
930 movwf POSTINC2 | |
931 movf divemins+0,W | |
932 addlw 0x07 | |
933 movwf EEADR | |
934 call read_eeprom ; He value | |
935 movff EEDATA,lo | |
936 output_8 ; Write He | |
937 bra gassetup_title_bar7 | |
938 | |
939 ; New v1.44se | |
940 gassetup_title_bar3: ; O2 Check | |
941 movf divemins+0,W | |
942 addlw 0x06 | |
943 movwf EEADR | |
944 call read_eeprom ; O2 value | |
945 movff EEDATA,lo | |
946 movf lo,f ; Move lo -> f | |
947 movlw d'21' ; Move 21 -> WREG | |
948 cpfseq lo ; o2 = 21 | |
949 cpfsgt lo ; o2 > 21% | |
950 bra gassetup_title_bar5 ; NO AIR | |
951 movlw d'100' ; Move 100 -> WREG | |
952 cpfslt lo ; o2 < 100% | |
953 bra gassetup_title_bar4 ; NO write O2 | |
954 | |
955 ; YES Write NX 32 | |
956 call gassetup_write_Nx | |
957 output_8 | |
958 bra gassetup_title_bar7 | |
959 | |
960 ; New v1.44se | |
961 gassetup_title_bar4: | |
962 movlw 'O' | |
963 movwf POSTINC2 | |
964 movlw '2' | |
965 movwf POSTINC2 | |
966 movlw ' ' | |
967 movwf POSTINC2 | |
968 output_8 | |
969 bra gassetup_title_bar7 | |
970 | |
971 ; New v1.44se | |
972 gassetup_title_bar5: | |
973 cpfseq lo ; o2 = 21% | |
974 bra gassetup_title_bar6 | |
975 | |
976 movlw 'A' | |
977 movwf POSTINC2 | |
978 movlw 'I' | |
979 movwf POSTINC2 | |
980 movlw 'R' | |
981 movwf POSTINC2 | |
982 movlw ' ' | |
983 movwf POSTINC2 | |
984 output_8 | |
985 bra gassetup_title_bar7 | |
986 | |
987 ; New v1.44se | |
988 gassetup_title_bar6: ; ERROR | |
989 movlw 'E' | |
990 movwf POSTINC2 | |
991 movlw 'R' | |
992 movwf POSTINC2 | |
993 movlw 'R' | |
994 movwf POSTINC2 | |
995 movlw ' ' | |
996 movwf POSTINC2 | |
997 output_8 | |
998 bra gassetup_title_bar7 | |
999 | |
1000 gassetup_title_bar7: | |
1001 movlw ' ' | |
1002 movwf POSTINC2 | |
1003 movlw 'i' | |
1004 movwf POSTINC2 | |
1005 movlw 'n' | |
1006 movwf POSTINC2 | |
1007 movlw ' ' | |
1008 movwf POSTINC2 | |
1009 movf decodata+0,W ; read current value | |
1010 addlw d'28' ; offset in memory | |
1011 movwf EEADR | |
1012 call read_eeprom ; Low-value | |
1013 movff EEDATA,lo | |
1014 output_8 | |
1015 movlw 'm' | |
1016 movwf POSTINC2 | |
1017 movlw ' ' | |
1018 movwf POSTINC2 | |
1019 | |
1020 call word_processor | |
1021 WIN_INVERT .0 ; Init new Wordprocessor | |
1022 return | |
1023 | |
1024 ; New v1.44se | |
1025 gassetup_write_Nx: | |
1026 movlw 'N' | |
1027 movwf POSTINC2 | |
1028 movlw 'X' | |
1029 movwf POSTINC2 | |
1030 movlw ' ' | |
1031 movwf POSTINC2 | |
1032 return | |
1033 | |
1034 ; New v1.44se | |
1035 gassetup_write_Tx: | |
1036 movlw 'T' | |
1037 movwf POSTINC2 | |
1038 movlw 'X' | |
1039 movwf POSTINC2 | |
1040 movlw ' ' | |
1041 movwf POSTINC2 | |
1042 return | |
1043 | |
1044 ; New v1.44se | |
1045 menu_gassetup_grey_inactive: | |
1046 ; Set Greyvalue to lower value when gas is inactive | |
1047 read_int_eeprom d'27' ; read flag register | |
1048 movff decodata+0,lo ; copy gas number 0-4 | |
1049 incf lo,F ; 1-5 | |
1050 menu_gassetup_list1: | |
1051 rrcf EEDATA ; roll flags into carry | |
1052 decfsz lo,F ; max. 5 times... | |
1053 bra menu_gassetup_list1 | |
3 | 1054 |
0 | 1055 btfss STATUS,C ; test carry |
3 | 1056 bra menu_gassetup_list1_grey |
1057 | |
1058 GETCUSTOM8 d'35' ;movlw color_white | |
1059 call PLED_set_color ; grey out inactive gases! | |
1060 return | |
1061 | |
1062 menu_gassetup_list1_grey: | |
0 | 1063 movlw color_grey |
1064 call PLED_set_color ; grey out inactive gases! | |
1065 return | |
1066 | |
1067 gassetup_show_ppO2: | |
1068 movf divemins+0,W | |
1069 addlw 0x06 | |
1070 movwf EEADR | |
1071 call read_eeprom ; O2 value | |
1072 movff EEDATA,hi | |
1073 | |
1074 movf decodata+0,W ; read current value | |
1075 addlw d'28' ; offset in memory | |
1076 movwf EEADR | |
1077 call read_eeprom ; Change depth in m | |
1078 movff EEDATA,lo | |
1079 movlw d'10' | |
1080 addwf lo,F ; Depth+10m=lo | |
1081 movf hi,W | |
1082 mulwf lo ; (Depth+10m)*O2 | |
1083 movff PRODL,xA+0 | |
1084 movff PRODH,xA+1 | |
1085 movlw d'10' | |
1086 movwf xB+0 | |
1087 clrf xB+1 | |
1088 call div16x16 ;xA/xB=xC with xA as remainder | |
1089 movff xC+0,lo ; ((Depth+10m)*O2)/10 = [0.01Bar] ppO2 | |
1090 movff xC+1,hi | |
1091 | |
1092 WIN_LEFT .55 | |
1093 WIN_TOP .35 | |
1094 lfsr FSR2,letter | |
50 | 1095 OUTPUTTEXT d'149' ; (ppO2: |
1096 ; movlw '(' | |
1097 ; movwf POSTINC2 | |
1098 ; movlw 'p' | |
1099 ; movwf POSTINC2 | |
1100 ; movlw 'p' | |
1101 ; movwf POSTINC2 | |
1102 ; movlw 'O' | |
1103 ; movwf POSTINC2 | |
1104 ; movlw '2' | |
1105 ; movwf POSTINC2 | |
1106 ; movlw ':' | |
1107 ; movwf POSTINC2 | |
0 | 1108 output_16dp d'3' |
50 | 1109 OUTPUTTEXT d'150' ; Bar: |
1110 ; movlw 'B' | |
1111 ; movwf POSTINC2 | |
1112 ; movlw 'a' | |
1113 ; movwf POSTINC2 | |
1114 ; movlw 'r' | |
1115 ; movwf POSTINC2 | |
1116 ; movlw ')' | |
1117 ; movwf POSTINC2 | |
1118 ; movlw ' ' | |
1119 ; movwf POSTINC2 | |
0 | 1120 call word_processor |
35 | 1121 return |
1122 | |
1123 | |
1124 gassetup_sort_gaslist: ; Sorts Gaslist according to change depth | |
1125 ; EEPROM Locations of Gaslist | |
1126 ; Gas1: | |
1127 ; O2 Default:4 | |
1128 ; He Default:5 | |
1129 ; O2 Current:6 | |
1130 ; He Current:7 | |
1131 ; Change: 28 | |
1132 ; Active: 27,0 | |
1133 | |
1134 ; Gas2: | |
1135 ; O2 Default:8 | |
1136 ; He Default:9 | |
1137 ; O2 Current:10 | |
1138 ; He Current:11 | |
1139 ; Change: 29 | |
1140 ; Active: 27,1 | |
1141 | |
1142 ; Gas3: | |
1143 ; O2 Default:12 | |
1144 ; He Default:13 | |
1145 ; O2 Current:14 | |
1146 ; He Current:15 | |
1147 ; Change: 30 | |
1148 ; Active: 27,2 | |
1149 | |
1150 ; Gas4: | |
1151 ; O2 Default:16 | |
1152 ; He Default:17 | |
1153 ; O2 Current:18 | |
1154 ; He Current:19 | |
1155 ; Change: 31 | |
1156 ; Active: 27,3 | |
1157 | |
1158 ; Gas5: | |
1159 ; O2 Default:20 | |
1160 ; He Default:21 | |
1161 ; O2 Current:22 | |
1162 ; He Current:23 | |
1163 ; Change: 32 | |
1164 ; Active: 27,4 | |
1165 | |
47 | 1166 ; reset Change depths (Important for all users who upgrade from <1.60!) |
1167 clrf EEADRH | |
1168 clrf EEDATA | |
1169 write_int_eeprom d'118' ; | |
1170 write_int_eeprom d'119' ; | |
1171 write_int_eeprom d'120' ; | |
1172 write_int_eeprom d'121' ; | |
1173 write_int_eeprom d'122' ; | |
1174 movlw d'21' ; O2 Current | |
1175 movwf EEDATA | |
1176 write_int_eeprom d'96' ; | |
1177 write_int_eeprom d'100' ; | |
1178 write_int_eeprom d'104' ; | |
1179 write_int_eeprom d'108' ; | |
1180 write_int_eeprom d'112' ; | |
1181 | |
1182 clrf EEDATA ; He Current | |
1183 write_int_eeprom d'97' ; | |
1184 write_int_eeprom d'101' ; | |
1185 write_int_eeprom d'105' ; | |
1186 write_int_eeprom d'109' ; | |
1187 write_int_eeprom d'113' ; | |
1188 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1189 ; Find deepest Gas |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1190 ; Copy all to RAM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1191 movlw d'3' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1192 movwf EEADR |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1193 clrf EEADRH |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1194 lfsr FSR2,letter ; Store gases in Letter buffer (max. 26Byte!) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1195 gassetup_sort_gaslist1: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1196 incf EEADR,F ; Next Adress |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1197 call read_eeprom ; Read byte |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1198 movff EEDATA,POSTINC2 ; Copy into RAM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1199 movlw d'23' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1200 cpfseq EEADR ; All done? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1201 bra gassetup_sort_gaslist1 ; No, not yet |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1202 ; Letter+0 = EEPROM 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1203 ; ... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1204 ; Letter+20 = EEPROM 23 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1205 read_int_eeprom d'28' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1206 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+21 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1207 read_int_eeprom d'29' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1208 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+22 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1209 read_int_eeprom d'30' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1210 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+23 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1211 read_int_eeprom d'31' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1212 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+24 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1213 read_int_eeprom d'32' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1214 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+25 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1215 read_int_eeprom d'27' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1216 movff EEDATA,POSTINC2 ; Active Byte -> Letter+26 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1217 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1218 ; All change depths = 0? -> Skip sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1219 lfsr FSR2,letter+.20 ; Change depths... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1220 movlw d'5' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1221 movwf logbook_temp3 ; Gas (0-4) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1222 clrf logbook_temp1 ; counter |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1223 gassetup_sort_gaslist1a: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1224 movf POSTINC2,W |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1225 addwf logbook_temp1,F ; sum |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1226 decfsz logbook_temp3,F ; Loop |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1227 bra gassetup_sort_gaslist1a |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1228 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1229 tstfsz logbook_temp1 ; All depths = 0? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1230 bra gassetup_sort_gaslist1b ; No |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1231 return ; Yes, skip all! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1232 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1233 gassetup_sort_gaslist1b: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1234 ; Initialize sorting... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1235 bcf menubit2 ; Change Start gas only 1x |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1236 movlw d'99' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1237 movwf logbook_temp4 ; Last Gas change depth |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1238 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1239 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1240 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1241 movlw d'5' ; Gas 5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1242 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1243 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1244 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1245 write_int_eeprom d'122' ; Write Change Depth Gas 5 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1246 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1247 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1248 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1249 movlw d'4' ; Gas 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1250 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1251 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1252 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1253 write_int_eeprom d'121' ; Write Change Depth Gas 4 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1254 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1255 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1256 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 3 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1257 movlw d'3' ; Gas 3 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1258 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1259 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1260 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1261 write_int_eeprom d'120' ; Write Change Depth Gas 3 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1262 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1263 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1264 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 2 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1265 movlw d'2' ; Gas 2 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1266 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1267 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1268 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1269 write_int_eeprom d'119' ; Write Change Depth Gas 2 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1270 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1271 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1272 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1273 movlw d'1' ; Gas 1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1274 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1275 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1276 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1277 write_int_eeprom d'118' ; Write Change Depth Gas 1 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1278 return |
35 | 1279 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1280 gassetup_sort_sort: |
41 | 1281 clrf logbook_temp2 ; Gas (0-4) |
1282 clrf logbook_temp1 ; Here: Change depth in m | |
1283 clrf logbook_temp3 ; Gas (0-4) | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1284 |
41 | 1285 lfsr FSR2,letter+.20 ; Change depths... |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1286 gassetup_sort_gaslist2: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1287 movf POSTINC2,W ; Get Change depth into WREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1288 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1289 cpfsgt logbook_temp4 ; logbook_temp4 < W? Here: Change depth of last sort run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1290 bra gassetup_sort_gaslist3 ; Skip, tested depth > max. Depth from last run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1291 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1292 cpfslt logbook_temp1 ; logbook_temp1 < W? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1293 bra gassetup_sort_gaslist3 ; Skip, tested depth < max. Depth from this run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1294 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1295 movwf logbook_temp1 ; copy new depth (current run) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1296 movff logbook_temp2,logbook_temp3 ; Holds deepest Gas 0-4 of this run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1297 gassetup_sort_gaslist3: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1298 incf logbook_temp2,F ; Check next Gas |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1299 movlw d'5' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1300 cpfseq logbook_temp2 ; All done? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1301 bra gassetup_sort_gaslist2 ; No |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1302 gassetup_sort_gaslist4: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1303 movff logbook_temp1,logbook_temp4 ; copy new depth (Store for next run) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1304 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1305 ; Debugger |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1306 ;call enable_rs232 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1307 ; movff logbook_temp1,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1308 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1309 ; movff logbook_temp2,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1310 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1311 ; movff logbook_temp3,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1312 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1313 ; movff logbook_temp4,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1314 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1315 ; movff logbook_temp5,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1316 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1317 ; WAITMS d'255' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1318 return |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1319 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1320 gassetup_sort_store: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1321 lfsr FSR2,letter ; Point to Gas0 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1322 movf logbook_temp3,W |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1323 mullw d'4' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1324 movf PRODL,W ; x4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1325 addwf FSR2L,F |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1326 movlw d'0' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1327 addwfc FSR2H,F ; Point to Gas #logbook_temp3 (0-4) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1328 |
50 | 1329 ; btfsc menubit2 ; Change Start gas only 1x |
1330 ; bra gassetup_sort_store2 ; Skip | |
1331 ;; First Gas: 33 (1-5) | |
1332 ;; Was gas #logbook_temp3 first gas? | |
1333 ; read_int_eeprom d'33' ; Get old first gas (1-5) | |
1334 ; incf logbook_temp3,W ; Gas 1-5 -> WREG | |
1335 ; cpfseq EEDATA ; Compare with EEDATA d'33' | |
1336 ; bra gassetup_sort_store2 ; Was not first gas! | |
1337 ; movff logbook_temp5,EEDATA ; Copy new first gas | |
1338 ; write_int_eeprom d'123' ; Store | |
1339 ; bsf menubit2 ; Done. Do not change again. | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1340 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1341 gassetup_sort_store2: |
45 | 1342 ; Was Gas #logbook_temp3 active? |
1343 ; Letter+26 holds active bits 25? | |
1344 movff logbook_temp3,logbook_temp6 ; Counter 0-4 | |
1345 incf logbook_temp6,F ; Counter 1-5 | |
1346 movff letter+.25, logbook_temp2 ; No longer used | |
1347 read_int_eeprom d'27' ; Active flag register | |
1348 gassetup_sort_store3: | |
1349 rrcf logbook_temp2,F ; Shift into Carry | |
1350 decfsz logbook_temp6,F ; 1-5 x | |
1351 bra gassetup_sort_store3 ; Loop | |
1352 ; Carry now holds active bit of gas #logbook_temp3 (0-4) | |
1353 | |
1354 btfss STATUS,C ; Was Gas active? | |
1355 clrf logbook_temp1 ; No!, Clear change Depth to make it inactive for sorted list! | |
1356 | |
49 | 1357 ;call enable_rs232 |
1358 ;movff logbook_temp1,TXREG | |
1359 ;call rs232_wait_tx ; wait for UART | |
1360 | |
1361 movf logbook_temp5,W ; 1-5 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1362 mullw d'4' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1363 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5 |
45 | 1364 movlw d'90' ; +90 Offset to new... |
1365 addwf EEADR,F ; ..sorted list! | |
1366 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1367 movff POSTINC2,EEDATA ; O2 Default |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1368 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1369 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1370 movff POSTINC2,EEDATA ; He Default |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1371 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1372 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1373 movff POSTINC2,EEDATA ; O2 Current |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1374 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1375 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1376 movff POSTINC2,EEDATA ; He Current |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1377 call write_eeprom ; store in internal EEPROM |
0 | 1378 return |