comparison code_part1/OSTC_code_asm_part1/menu_ppO2.asm @ 642:2cecac640202

Diluent setup menu work
author heinrichsweikamp
date Wed, 03 Oct 2012 11:39:50 +0200
parents 50ba6255f53e
children 3b50c9949b84
comparison
equal deleted inserted replaced
641:9dc52559956e 642:2cecac640202
89 menu_diluentsetup_prelist: 89 menu_diluentsetup_prelist:
90 call PLED_ClearScreen 90 call PLED_ClearScreen
91 call menu_pre_loop_common ; Clear some menu flags, timeout and switches 91 call menu_pre_loop_common ; Clear some menu flags, timeout and switches
92 call PLED_topline_box 92 call PLED_topline_box
93 WIN_INVERT .1 ; Init new Wordprocessor 93 WIN_INVERT .1 ; Init new Wordprocessor
94 DISPLAYTEXT .106 ; Gas List 94 DISPLAYTEXT .231 ; Dil. Setup - Gaslist
95 WIN_INVERT .0 ; Init new Wordprocessor 95 WIN_INVERT .0 ; Init new Wordprocessor
96 clrf decodata+0 ; Here: # of gas 0-4 96 clrf decodata+0 ; Here: # of gas 0-4
97 clrf divemins+0 ; Here: # of Gas * 4 97 clrf divemins+0 ; Here: # of Gas * 4
98 movlw d'5' 98 movlw d'5'
99 movwf waitms_temp ; here: stores row for gas list 99 movwf waitms_temp ; here: stores row for gas list
124 WIN_LEFT .48 124 WIN_LEFT .48
125 movf waitms_temp,W ; Load row into WREG 125 movf waitms_temp,W ; Load row into WREG
126 movff WREG,win_top 126 movff WREG,win_top
127 lfsr FSR2,letter 127 lfsr FSR2,letter
128 128
129 movff wait_temp, EEADR ; Gas %He - Set address in internal EEPROM 129 incf wait_temp, W ; Gas %O2
130 incf EEADR,F ; Gas %He - Set address in internal EEPROM 130 movwf EEADR ; Gas %He - Set address in internal EEPROM
131 movlw .1
132 movwf EEADRH
131 call read_eeprom ; Read He value from EEPROM 133 call read_eeprom ; Read He value from EEPROM
132 movff EEDATA,lo ; Move EEDATA -> lo 134 movff EEDATA,lo ; Move EEDATA -> lo
133 movf lo,f ; Move lo -> f 135 movf lo,f ; Move lo -> f
134 movlw d'0' ; Move 0 -> WREG 136 movlw d'0' ; Move 0 -> WREG
135 cpfsgt lo ; He > 0? 137 cpfsgt lo ; He > 0?
136 bra menu_diluentsetup_Nx ; NO check o2 138 bra menu_diluentsetup_Nx ; NO check o2
137 139
138 ; YES Write TX 15/55 140 ; YES Write TX 15/55
139 call gassetup_write_Tx 141 STRCAT TXT_TX3
140 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM 142 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
143 movlw .1
144 movwf EEADRH
141 call read_eeprom ; O2 value 145 call read_eeprom ; O2 value
142 movff EEDATA,lo 146 movff EEDATA,lo
143 output_8 147 output_8
144 PUTC '/' 148 PUTC '/'
145 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM 149 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM
150 movlw .1
151 movwf EEADRH
146 call read_eeprom ; He value 152 call read_eeprom ; He value
147 movff EEDATA,lo 153 movff EEDATA,lo
148 output_8 154 output_8
149 bra menu_diluentsetup_list0 155 bra menu_diluentsetup_list0
150 156
151 ; New v1.44se 157 ; New v1.44se
152 menu_diluentsetup_Nx: 158 menu_diluentsetup_Nx:
153 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM 159 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
160 movlw .1
161 movwf EEADRH
154 call read_eeprom ; Read O2 value from EEPROM 162 call read_eeprom ; Read O2 value from EEPROM
155 movff EEDATA,lo ; Move EEDATA -> lo 163 movff EEDATA,lo ; Move EEDATA -> lo
156 movf lo,f ; Move lo -> f 164 movf lo,f ; Move lo -> f
157 movlw d'21' ; Move 21 -> WREG 165 movlw d'21' ; Move 21 -> WREG
158 cpfsgt lo ; o2 > 21% 166 cpfsgt lo ; o2 > 21%
160 movlw d'100' ; Move 100 -> WREG 168 movlw d'100' ; Move 100 -> WREG
161 cpfslt lo ; o2 < 100% 169 cpfslt lo ; o2 < 100%
162 bra menu_diluentsetup_O2 ; NO write O2 170 bra menu_diluentsetup_O2 ; NO write O2
163 171
164 ; YES Write NX 32 172 ; YES Write NX 32
165 call gassetup_write_Nx 173 STRCAT TXT_NX3
166 output_8 174 output_8
167 bra menu_diluentsetup_list0 175 bra menu_diluentsetup_list0
168 176
169 menu_diluentsetup_O2: 177 menu_diluentsetup_O2:
170 STRCAT TXT_O2_3 178 STRCAT TXT_O2_3
171 output_8 179 output_8
172 bra menu_diluentsetup_list0 180 bra menu_diluentsetup_list0
173 181
174 menu_diluentsetup_Air: 182 menu_diluentsetup_Air:
175 cpfseq lo ; o2 = 21% 183 cpfseq lo ; o2 = 21%
176 call menu_gassetup_Err 184 bra menu_diluentsetup_Err
177 185
178 STRCAT TXT_AIR4 186 STRCAT TXT_AIR4
179 output_8 187 output_8
180 bra menu_diluentsetup_list0 188 bra menu_diluentsetup_list0
181 189
235 243
236 do_diluentsetup_list: 244 do_diluentsetup_list:
237 dcfsnz menupos,F 245 dcfsnz menupos,F
238 bra diluent_list_edit_gas1 246 bra diluent_list_edit_gas1
239 dcfsnz menupos,F 247 dcfsnz menupos,F
240 bra diluent_list_edit_gas1 248 bra diluent_list_edit_gas2
241 dcfsnz menupos,F 249 dcfsnz menupos,F
242 bra diluent_list_edit_gas1 250 bra diluent_list_edit_gas3
243 dcfsnz menupos,F 251 dcfsnz menupos,F
244 bra diluent_list_edit_gas1 252 bra diluent_list_edit_gas4
245 dcfsnz menupos,F 253 dcfsnz menupos,F
246 bra diluent_list_edit_gas1 254 bra diluent_list_edit_gas5
247 bra menu_const_ppO2 ; Exit List 255 bra menu_const_ppO2 ; Exit List
248 256
249 diluent_list_edit_gas1: 257 diluent_list_edit_gas1:
258 movlw d'0' ; Diluent Number 0-4
259 movwf decodata+0
260 movlw d'96' ; EEPROM address of %O2
261 movwf divemins+0
262 bra menu_diluentgas
250 diluent_list_edit_gas2: 263 diluent_list_edit_gas2:
264 movlw d'1' ; Diluent Number 0-4
265 movwf decodata+0
266 movlw d'98' ; EEPROM address of %O2
267 movwf divemins+0
268 bra menu_diluentgas
251 diluent_list_edit_gas3: 269 diluent_list_edit_gas3:
270 movlw d'2' ; Diluent Number 0-4
271 movwf decodata+0
272 movlw d'100' ; EEPROM address of %O2
273 movwf divemins+0
274 bra menu_diluentgas
252 diluent_list_edit_gas4: 275 diluent_list_edit_gas4:
276 movlw d'3' ; Diluent Number 0-4
277 movwf decodata+0
278 movlw d'102' ; EEPROM address of %O2
279 movwf divemins+0
280 bra menu_diluentgas
253 diluent_list_edit_gas5: 281 diluent_list_edit_gas5:
254 bra menu_const_ppO2 ; Exit List 282 movlw d'4' ; Diluent Number 0-4
283 movwf decodata+0
284 movlw d'104' ; EEPROM address of %O2
285 movwf divemins+0
286 ; bra menu_diluentgas
287 menu_diluentgas:
288 movlw d'1'
289 movwf menupos
290 bcf menubit4
291 bcf first_FA ; Here: =1: -, =0: +
292
293 menu_diluentgas0:
294 call PLED_ClearScreen
295 WIN_LEFT .20
296 WIN_TOP .155
297 lfsr FSR2, letter
298 OUTPUTTEXT .11 ; Exit
299 STRCAT_PRINT ""
300
301 menu_diluentgas1:
302 call menu_pre_loop_common ; Clear some menu flags, timeout and switches
303
304 call diluent_title_bar2 ; Displays the title bar with the current Gas info
305
306 WIN_LEFT .20
307 WIN_TOP .35
308 STRCPY TXT_O2_4
309 movff divemins+0,EEADR
310 movlw .1
311 movwf EEADRH
312 call read_eeprom ; O2 value
313 movff EEDATA,lo
314 output_8
315 STRCAT_PRINT "% "
316
317 ; Show MOD in m
318 WIN_LEFT .90
319 lfsr FSR2, letter
320 OUTPUTTEXTH .297 ; MOD:
321
322 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG
323 mullw d'10'
324 movff PRODL,xA+0
325 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10
326 movff divemins+0,EEADR
327 movlw .1
328 movwf EEADRH
329 call read_eeprom ; O2 value
330 movff EEDATA,xB+0
331 clrf xB+1
332 call div16x16 ; xA/xB=xC with xA as remainder
333 movlw d'10'
334 subwf xC+0,F ; Subtract 10m...
335 movff xC+0,lo
336 movlw d'0'
337 subwfb xC+1,F
338 movff xC+1,hi
339
340 output_16
341 STRCAT_PRINT TXT_METER3
342
343 WIN_LEFT .20
344 WIN_TOP .65
345 STRCPY TXT_HE4
346 incf divemins+0,W
347 movwf EEADR
348 movlw .1
349 movwf EEADRH
350 call read_eeprom ; He value
351 movff EEDATA,lo
352 output_8
353 STRCAT_PRINT "% "
354
355 ; Show END in m
356 lfsr FSR2, letter
357 WIN_LEFT .90
358 OUTPUTTEXTH .298 ; END:
359 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG
360 mullw d'10'
361 movff PRODL,xA+0
362 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10
363 movff divemins+0,EEADR
364 movlw .1
365 movwf EEADRH
366 call read_eeprom ; O2 value
367 movff EEDATA,xB+0
368 clrf xB+1
369 call div16x16 ; xA/xB=xC with xA as remainder
370 movlw d'10'
371 subwf xC+0,F ; Subtract 10m...
372 movff xC+0,lo
373 movlw d'0'
374 subwfb xC+1,F
375 movff xC+1,hi ; lo:hi holding MOD in meters
376 movlw d'10'
377 addwf lo,F
378 movlw d'0'
379 addwfc hi,F ; lo:hi holding MOD+10m
380
381 incf divemins+0,W
382 movwf EEADR
383 movlw .1
384 movwf EEADRH
385 call read_eeprom ; He value in % -> EEDATA
386 movlw d'100'
387 movwf xA+0
388 movf EEDATA,W ; He value in % -> EEDATA
389 subwf xA+0,F ; xA+0 = 100 - He Value in %
390 clrf xA+1
391 movff lo,xB+0
392 movff hi,xB+1 ; Copy MOD+10
393 call mult16x16 ; xA*xB=xC
394 movff xC+0,xA+0
395 movff xC+1,xA+1
396 movlw d'100'
397 movwf xB+0
398 clrf xB+1
399 call div16x16 ; xA/xB=xC with xA as remainder
400 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100
401 movlw d'10'
402 subwf xC+0,F ; Subtract 10m...
403 movff xC+0,lo
404 movlw d'0'
405 subwfb xC+1,F
406 movff xC+1,hi
407 output_16
408 STRCAT_PRINT TXT_METER3
409
410 WIN_LEFT .20
411 WIN_TOP .95
412 STRCPY "+/-: "
413 movlw '+'
414 btfsc first_FA
415 movlw '-'
416 movwf POSTINC2
417 call word_processor
418
419 WIN_TOP .125
420 lfsr FSR2,letter
421 OUTPUTTEXT .89 ; Default:
422 movlw .21
423 movwf lo ; Default always Air
424 output_8
425 PUTC '/'
426 clrf lo ; Default He value
427 output_8
428 STRCAT_PRINT " "
429
430 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
431 call PLED_menu_cursor
432
433 diluentgassetup_loop:
434 call check_switches_logbook
435
436 btfsc menubit3
437 bra diluentgassetup2 ; move cursor
438
439 btfsc menubit2
440 bra do_diluentgassetup ; call submenu
441
442 btfsc onesecupdate
443 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag
444
445 bcf onesecupdate ; 1 sec. functions done
446
447 btfsc sleepmode
448 bra exit_menu_const_ppO2
449
450 bra diluentgassetup_loop
451
452 diluentgassetup2:
453 incf menupos,F
454 movlw d'6'
455 cpfseq menupos ; =6?
456 bra diluentgassetup3 ; No
457 movlw d'1'
458 movwf menupos
459
460 diluentgassetup3:
461 clrf timeout_counter2
462 call PLED_menu_cursor
463
464 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
465
466 bcf menubit3 ; clear flag
467 bra diluentgassetup_loop
468
469 do_diluentgassetup:
470 dcfsnz menupos,F
471 bra adjust_o2_diluent
472 dcfsnz menupos,F
473 bra adjust_he_diluent
474 dcfsnz menupos,F
475 bra toggle_plus_minus_diluentsetup
476 dcfsnz menupos,F
477 bra restore_gas_diluent
478 exit_diluentgassetup: ; exit...
479 movff decodata+0,menupos
480 incf menupos,F
481 bra menu_diluentsetup_prelist
482
483 toggle_plus_minus_diluentsetup:
484 btg first_FA
485 movlw d'3'
486 movwf menupos
487 bra menu_diluentgas1 ; return
488
489 adjust_o2_diluent:
490 movff divemins+0,EEADR ; read current value
491 movlw .1
492 movwf EEADRH
493 call read_eeprom ; Low-value
494 movff EEDATA,lo
495
496 btfsc first_FA ; Minus?
497 bra adjust_o2_1_diluent ; yes, minus!
498
499 incf lo,F ; increase O2
500 movlw d'101'
501 cpfseq lo
502 bra adjust_o2_2_diluent
503 movlw d'4' ; LOWER O2 Limit
504 movwf lo
505 bra adjust_o2_2_diluent
506
507 adjust_o2_1_diluent:
508 decf lo,F ; decrease O2
509 movlw d'3'
510 cpfseq lo
511 bra adjust_o2_2_diluent
512
513 incf divemins+0,W
514 movwf EEADR
515 movlw .1
516 movwf EEADRH
517 call read_eeprom ; read He value
518
519 movlw d'100'
520 movwf lo
521 movf EEDATA,W ; He value
522 subwf lo,F ; lo=100% - He%
523
524 adjust_o2_2_diluent: ; test if O2+He>100...
525 incf divemins+0,W
526 movwf EEADR
527 movlw .1
528 movwf EEADRH
529 call read_eeprom ; read He value
530 movf EEDATA,W ; He value
531 addwf lo,W ; add O2 value
532 movwf hi ; store in temp
533 movlw d'101'
534 cpfseq hi ; O2 and He > 100?
535 bra adjust_o2_3_diluent ; No!
536
537 movlw d'4' ; LOWER O2 Limit
538 movwf lo
539
540 adjust_o2_3_diluent:
541 movff divemins+0,EEADR ; save current value
542 movff lo,EEDATA
543 movlw .1
544 movwf EEADRH
545 call write_eeprom ; Low-value
546
547 movlw d'1'
548 movwf menupos
549 bra menu_diluentgas1 ; return
550
551 adjust_he_diluent:
552 incf divemins+0,W
553 movwf EEADR ; read current value
554 movlw .1
555 movwf EEADRH
556 call read_eeprom ; Low-value
557 movff EEDATA,lo
558
559 btfsc first_FA ; Minus?
560 bra adjust_he_1_diluent ; yes, minus!
561
562 incf lo,F
563 movlw d'92' ; He limited to (useless) 90%
564 cpfseq lo
565 bra adjust_he_2_diluent
566 clrf lo
567 bra adjust_he_2_diluent
568
569 adjust_he_1_diluent:
570 decf lo,F ; decrease He
571 movlw d'255'
572 cpfseq lo
573 bra adjust_he_2_diluent
574 clrf lo
575
576 adjust_he_2_diluent: ; test if O2+He>100...
577 incf divemins+0,W
578 movwf EEADR
579 movlw .1
580 movwf EEADRH
581 call read_eeprom ; read He value
582 movf EEDATA,W ; He value
583 addwf lo,W ; add O2 value
584 movwf hi ; store in temp
585 movlw d'101'
586 cpfseq hi ; O2 and He > 100?
587 bra adjust_he_3_diluent ; No!
588 ; clrf lo ; Yes, clear He to zero
589 decf lo,F ; reduce He again = unchanged after operation
590
591 adjust_he_3_diluent:
592 incf divemins+0,W ; save current value
593 movwf EEADR
594 movff lo,EEDATA
595 movlw .1
596 movwf EEADRH
597 call write_eeprom ; Low-value
598
599 movlw d'2'
600 movwf menupos
601 bra menu_diluentgas1 ;
602
603 restore_gas_diluent:
604 movff divemins+0,EEADR ; save Default value (O2)
605 movlw .1
606 movwf EEADRH
607 movlw .21 ; Always Air
608 movwf EEDATA
609 call write_eeprom
610 incf EEADR,F ; Point to He
611 clrf EEDATA
612 call write_eeprom
613 movlw d'4'
614 movwf menupos
615 bra menu_diluentgas1
616
617
618 diluent_title_bar2:
619 call PLED_topline_box
620 WIN_INVERT .1 ; Init new Wordprocessor
621 WIN_TOP .2
622 WIN_LEFT .30
623 lfsr FSR2,letter
624 STRCAT TXT_DIL5 ; Dil.#
625 movff decodata+0,lo
626 incf lo,F
627 bsf leftbind
628 output_99
629 STRCAT_PRINT ": "
630
631 WIN_TOP .2
632 WIN_LEFT .80
633 lfsr FSR2,letter
634
635 ;He check
636 incf divemins+0,W
637 movwf EEADR
638 movlw .1
639 movwf EEADRH
640 call read_eeprom ; He value
641 movff EEDATA,lo ; Move EEData -> lo
642 movf lo,f ; Move lo -> f
643 movlw d'0' ; Move 0 -> WREG
644 cpfsgt lo ; He > 0?
645 bra diluent_title_bar3 ; NO check o2
646
647 ; YES Write TX 15/55
648 STRCAT TXT_TX3
649 movff divemins+0,EEADR
650 movlw .1
651 movwf EEADRH
652 call read_eeprom ; O2 value
653 movff EEDATA,lo
654 output_8 ; Write O2
655 PUTC '/'
656 incf divemins+0,W
657 movwf EEADR
658 call read_eeprom ; He value
659 movff EEDATA,lo
660 output_8 ; Write He
661 bra diluent_title_bar7
662
663 ; New v1.44se
664 diluent_title_bar3: ; O2 Check
665 movff divemins+0,EEADR
666 call read_eeprom ; O2 value
667 movff EEDATA,lo
668 movf lo,f ; Move lo -> f
669 movlw d'21' ; Move 21 -> WREG
670 cpfseq lo ; o2 = 21
671 cpfsgt lo ; o2 > 21%
672 bra diluent_title_bar5 ; NO AIR
673 movlw d'100' ; Move 100 -> WREG
674 cpfslt lo ; o2 < 100%
675 bra diluent_title_bar4 ; NO write O2
676
677 ; YES Write NX 32
678 STRCAT TXT_NX3
679 output_8
680 bra diluent_title_bar7
681
682 ; New v1.44se
683 diluent_title_bar4:
684 STRCAT TXT_O2_3
685 output_8
686 bra diluent_title_bar7
687
688 ; New v1.44se
689 diluent_title_bar5:
690 cpfseq lo ; o2 = 21%
691 bra diluent_title_bar6
692
693 STRCAT TXT_AIR4
694 output_8
695 bra diluent_title_bar7
696
697 ; New v1.44se
698 diluent_title_bar6: ; ERROR
699 STRCAT TXT_ERR4
700 output_8
701 ;bra diluent_title_bar7
702
703 diluent_title_bar7:
704 STRCAT_PRINT ""
705 WIN_INVERT .0 ; Init new Wordprocessor
706 return
707
255 708
256 ; *** 709 ; ***
257 710
258 711
259 712