comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 426:07f5b0baaa57

Adding temperature & ceiling curves * Pink Temperature curve, using fixed scale minTp .. minTp+10.0?C. * Vertical line fill for ceiling. * Dark red coloring when overflowing ceiling, dark green if ok.
author JeanDo
date Sun, 31 Jul 2011 13:27:23 +0200
parents a76c5a3e9e96
children 04535df08575
comparison
equal deleted inserted replaced
425:a76c5a3e9e96 426:07f5b0baaa57
350 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!) 350 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!)
351 movff xC+1,sim_pressure+1 ; holds HIGH byte of y-scale (mbar/pixel!) 351 movff xC+1,sim_pressure+1 ; holds HIGH byte of y-scale (mbar/pixel!)
352 incf sim_pressure+0,F ; increase one, because there may be a remainder 352 incf sim_pressure+0,F ; increase one, because there may be a remainder
353 movlw d'0' 353 movlw d'0'
354 addwfc sim_pressure+1,F 354 addwfc sim_pressure+1,F
355
355 movlw LOW d'164000' ; 164pixel*1000 height 356 movlw LOW d'164000' ; 164pixel*1000 height
356 movwf xC+0 357 movwf xC+0
357 movlw HIGH (d'164000' & h'FFFF') ; 164pixel*1000 height 358 movlw HIGH (d'164000' & h'FFFF') ; 164pixel*1000 height
358 movwf xC+1 359 movwf xC+1
359 movlw UPPER d'164000' ; 164pixel*1000 height 360 movlw UPPER d'164000' ; 164pixel*1000 height
387 movwf xB+0 388 movwf xB+0
388 clrf xB+1 389 clrf xB+1
389 call mult16x16 ; result is in xC:2 ! 390 call mult16x16 ; result is in xC:2 !
390 391
391 bsf leftbind 392 bsf leftbind
392 PUTC 0x95 ; "duration o dive" icon 393 PUTC 0x95 ; "duration of dive" icon
393 output_16 ; divetime minutes 394 output_16 ; divetime minutes
394 395
395 movlw LOW d'600' 396 movlw LOW d'600'
396 movwf xA+0 397 movwf xA+0
397 movlw HIGH d'600' 398 movlw HIGH d'600'
453 addwfc profile_temp+1,F 454 addwfc profile_temp+1,F
454 455
455 456
456 bsf leftbind 457 bsf leftbind
457 output_99x ; divetime seconds 458 output_99x ; divetime seconds
458 PUTC ' ' 459 STRCAT_PRINT " "
460
461 WIN_LEFT .05 + 7*.15
462 lfsr FSR2,letter
463
459 call I2CREAD2 464 call I2CREAD2
460 movff SSPBUF,lo 465 movff SSPBUF,lo
461 call I2CREAD2 466 call I2CREAD2
462 movff SSPBUF,hi ; Read min. Temperature 467 movff SSPBUF,hi ; Read min. Temperature
468 movff lo,logbook_min_tp+0 ; Backup min Tp° too.
469 movff hi,logbook_min_tp+1
470 movlw color_pink ; Use same color as tp° curve
471 call PLED_set_color
472
463 call PLED_convert_signed_temperature ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 473 call PLED_convert_signed_temperature ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
464 movlw d'3' 474 movlw d'3'
465 movwf ignore_digits 475 movwf ignore_digits
466 bsf leftbind 476 bsf leftbind
467 output_16dp d'2' ; temperature 477 output_16dp d'2' ; temperature
468 STRCAT_PRINT "°C" ; Display 2nd row of details 478 STRCAT_PRINT "°C" ; Display 2nd row of details
469 479 call PLED_standard_color ; Back to normal
480
470 WIN_TOP .50 481 WIN_TOP .50
471 WIN_LEFT .05 482 WIN_LEFT .05
472 lfsr FSR2,letter 483 lfsr FSR2,letter
473 484
474 call I2CREAD2 ; read Air pressure 485 call I2CREAD2 ; read Air pressure
501 movff eeprom_address+0,average_depth_hold+0 512 movff eeprom_address+0,average_depth_hold+0
502 movff eeprom_address+1,average_depth_hold+1 ; Pointer to Gaslist (For Page 2) 513 movff eeprom_address+1,average_depth_hold+1 ; Pointer to Gaslist (For Page 2)
503 514
504 incf_eeprom_address d'12' ; Skip 12 Bytes in EEPROM (faster) (Gaslist) 515 incf_eeprom_address d'12' ; Skip 12 Bytes in EEPROM (faster) (Gaslist)
505 call I2CREAD2 ; Read start gas (1-5) 516 call I2CREAD2 ; Read start gas (1-5)
506 movff SSPBUF,active_gas ; Store 517 movff SSPBUF,average_depth_hold_total+3 ; keep copy to restore color
507 movff active_gas,average_depth_hold_total+3 ; keep copy to restore color 518 rcall profile_display_color ; Back to normal profile color.
508 incf_eeprom_address d'5' ; Skip 5 Bytes in EEPROM (faster) (Battery, firmware) 519 incf_eeprom_address d'5' ; Skip 5 Bytes in EEPROM (faster) (Battery, firmware)
509 520
521 call I2CREAD2 ; Read Tp° divisor
522 movf SSPBUF,W
523 andlw 0x0F ; Clear extra bits.
524 movwf divisor_temperature ; Store divisor
525 movwf logbook_temp1 ; Store to tp° counter too.
526
510 call I2CREAD2 ; Read divisor 527 call I2CREAD2 ; Read divisor
511 movff SSPBUF,divisor_temperature ; Store divisor 528 movf SSPBUF,W
512 bcf divisor_temperature,4 ; Clear information length 529 andlw 0x0F
513 bcf divisor_temperature,5 530 movwf divisor_deco ; Store divisor
514 bcf divisor_temperature,6 531 movwf logbook_temp2 ; Store as temp, too
515 bcf divisor_temperature,7 532
516 incf divisor_temperature,F ; increase divisor
517 movff divisor_temperature,logbook_temp1 ; Store as temp, too
518 call I2CREAD2 ; Read divisor
519 movff SSPBUF,divisor_deco ; Store divisor
520 bcf divisor_deco,4 ; Clear information length
521 bcf divisor_deco,5
522 bcf divisor_deco,6
523 bcf divisor_deco,7
524 movff divisor_deco,logbook_temp2 ; Store as temp, too
525 call I2CREAD2 ; Read divisor 533 call I2CREAD2 ; Read divisor
526 movff SSPBUF,divisor_gf ; Store divisor 534 movff SSPBUF,divisor_gf ; Store divisor
527 call I2CREAD2 ; Read divisor 535 call I2CREAD2 ; Read divisor
528 movff SSPBUF,divisor_ppo2 ; Store divisor 536 movff SSPBUF,divisor_ppo2 ; Store divisor
529 call I2CREAD2 ; Read divisor 537 call I2CREAD2 ; Read divisor
591 bcf second_FD ; clear flag 599 bcf second_FD ; clear flag
592 movlw d'5' 600 movlw d'5'
593 movwf timeout_counter3 ; here: used as colum x2 (Start at Colum 5) 601 movwf timeout_counter3 ; here: used as colum x2 (Start at Colum 5)
594 movlw d'75' ; Zero-m row 602 movlw d'75' ; Zero-m row
595 movwf apnoe_mins ; here: used for fill between rows 603 movwf apnoe_mins ; here: used for fill between rows
604 movwf logbook_last_tp ; Initialise for Tp° curve too.
596 incf timeout_counter3,W ; Init Column 605 incf timeout_counter3,W ; Init Column
597 606
607
598 INIT_PIXEL_WROTE timeout_counter3 ; pixel x2 (Also sets standard Color!) 608 INIT_PIXEL_WROTE timeout_counter3 ; pixel x2 (Also sets standard Color!)
599
600 dcfsnz active_gas,F
601 movlw color_white ; Color for Gas 1
602 dcfsnz active_gas,F
603 movlw color_green ; Color for Gas 2
604 dcfsnz active_gas,F
605 movlw color_red ; Color for Gas 3
606 dcfsnz active_gas,F
607 movlw color_yellow ; Color for Gas 4
608 dcfsnz active_gas,F
609 movlw color_violet ; Color for Gas 5
610 call PLED_set_color ; Set Color...
611
612 609
613 profile_display_loop: 610 profile_display_loop:
614 movff profile_temp+0,profile_temp2+0 611 movff profile_temp+0,profile_temp2+0
615 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler 612 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler
616 incf profile_temp2+1,F 613 incf profile_temp2+1,F
617 tstfsz profile_temp2+0 ; Must not be Zero 614 tstfsz profile_temp2+0 ; Must not be Zero
618 bra profile_display_loop2 ; Not Zero! 615 bra profile_display_loop2 ; Not Zero!
619 incf profile_temp2+0,F ; Zero, Increase! 616 incf profile_temp2+0,F ; Zero, Increase!
620 617
621 profile_display_loop2: 618 profile_display_loop2:
622 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo 619 rcall profile_view_get_depth ; reads depth, temp and profile data
623 620
624 btfsc second_FD ; end-of profile reached? 621 btfsc second_FD ; end-of profile reached?
625 bra profile_display_loop_done ; Yes, skip all remaining pixels 622 bra profile_display_loop_done ; Yes, skip all remaining pixels
626 623
624 ;---- Draw Ceiling curve, if any ---------------------------------------------
625 movf divisor_deco,W
626 bz profile_display_skip_deco
627
628 movf logbook_ceiling,W ; Any deco ceiling ?
629 bz profile_display_skip_deco
630
631 mullw .100 ; Yes: convert to mbar
632 movff PRODL,sub_a+0
633 movff PRODH,sub_a+1
634 movff logbook_cur_depth+0,sub_b+0 ; Compare with UNSIGNED current depth (16bits)
635 movff logbook_cur_depth+1,sub_b+1
636 call subU16 ; set (or not) neg_flag
637
638 movlw color_dark_green ; Dark green if Ok,
639 btfss neg_flag
640 movlw color_dark_red ; Or dark red if ceiling overflown.
641 call PLED_set_color
642
643 movff PRODL,xA+0
644 movff PRODH,xA+1
627 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett 645 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett
628 movff sim_pressure+1,xB+1 646 movff sim_pressure+1,xB+1
629 movff lo,xA+0 647 call div16x16 ; xA/xB=xC
630 movff hi,xA+1 648
649 movlw d'76' ; Starts right after the top blue line.
650 movff WREG,win_top
651 movff timeout_counter3,win_leftx2 ; Left border (0-159)
652 movff xC+0,win_height
653 call half_vertical_line ; Inputs: win_top, win_leftx2, win_height, win_color1, win_color2
654 profile_display_skip_deco:
655
656 ;---- Draw Tp° curve, if any ---------------------------------------------
657 movf divisor_temperature,W
658 bz profile_display_skip_temp
659
660 movlw LOW((.153*.8)/.100) ; fixed tp° scale: (10.0° * scale8 )/153pix
661 movwf xB+0
662 movlw HIGH((.153*.8)/.100)
663 movwf xB+1
664
665 movf logbook_cur_tp+0,W
666 subwf logbook_min_tp+0,W
667 movwf xA+0
668 movf logbook_cur_tp+1,W
669 subwfb logbook_min_tp+1,W
670 movwf xA+1
671 call mult16x16 ; xA*xB=xC
672
673 ; scale: divide by 8. Don't bother about CARRY for the high byte.
674 rrcf xC+1,F
675 rrcf xC+0,F
676 rrcf xC+1,F
677 rrcf xC+0,F
678 rrcf xC+1,F
679 rrcf xC+0,F
680
681 movlw .75
682 subwf xC+0,F ; Upside-down: Y = .75 + (.153 - result)
683
684 movlw color_pink
685 call PLED_set_color
686
687 movff logbook_last_tp,xC+1
688 call profile_display_fill ; In this column between this row (xC+0) and the last row (apnoe_mins)
689 movff xC+0,logbook_last_tp
690 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel.
691 profile_display_skip_temp:
692
693 ;---- Draw depth curve ---------------------------------------------------
694 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett
695 movff sim_pressure+1,xB+1
696 movff logbook_cur_depth+0,xA+0
697 movff logbook_cur_depth+1,xA+1
631 call div16x16 ; xA/xB=xC 698 call div16x16 ; xA/xB=xC
632 movlw d'75' 699 movlw d'75'
633 addwf xC+0,F ; add 75 pixel offset to result 700 addwf xC+0,F ; add 75 pixel offset to result
634 701
635 btfsc STATUS,C ; Ignore potential profile errors 702 btfsc STATUS,C ; Ignore potential profile errors
636 movff apnoe_mins,xC+0 703 movff apnoe_mins,xC+0
637 704
705 rcall profile_display_color ; Back to normal profile color.
706 movff apnoe_mins,xC+1
638 call profile_display_fill ; In this column between this row (xC+0) and the last row (apnoe_mins) 707 call profile_display_fill ; In this column between this row (xC+0) and the last row (apnoe_mins)
639 movff xC+0,apnoe_mins ; Store last row for fill routine 708 movff xC+0,apnoe_mins ; Store last row for fill routine
640 incf timeout_counter3,F 709 incf timeout_counter3,F
641 710
642 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel. 711 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel.
643 712
713 ;---- Draw CNS curve, if any ---------------------------------------------
714 movf divisor_cns,W
715 bz profile_display_skip_cns
716 ;
717 ; TODO HERE
718 ;
719 profile_display_skip_cns:
720
721 ;---- Draw GF curve, if any ----------------------------------------------
722 movf divisor_gf,W
723 bz profile_display_skip_gf
724 ;
725 ; TODO HERE
726 ;
727 profile_display_skip_gf:
728
729 ;---- All curves done.
730
644 profile_display_skip_loop1: ; skips readings! 731 profile_display_skip_loop1: ; skips readings!
645 dcfsnz profile_temp2+0,F 732 dcfsnz profile_temp2+0,F
646 bra profile_display_loop3 ; check 16bit.... 733 bra profile_display_loop3 ; check 16bit....
647 734
648 rcall profile_view_get_depth ; reads depth, ignores temp and profile data 735 rcall profile_view_get_depth ; reads depth, temp and profile data
649 bra profile_display_skip_loop1 736 bra profile_display_skip_loop1
650 737
651 profile_display_loop3: 738 profile_display_loop3:
652 decfsz profile_temp2+1,F ; 16 bit x-scaler test 739 decfsz profile_temp2+1,F ; 16 bit x-scaler test
653 bra profile_display_skip_loop1 ; skips readings! 740 bra profile_display_skip_loop1 ; skips readings!
680 bra exit_profileview ; back to list 767 bra exit_profileview ; back to list
681 btfsc divemode 768 btfsc divemode
682 goto restart ; Enter Divemode if required 769 goto restart ; Enter Divemode if required
683 bra display_profile_loop ; wait for something to do 770 bra display_profile_loop ; wait for something to do
684 771
685 772 ;=============================================================================
773 profile_display_color:
774 movff average_depth_hold_total+3,active_gas ; Restore gas color.
775 dcfsnz active_gas,F
776 movlw color_white ; Color for Gas 1
777 dcfsnz active_gas,F
778 movlw color_green ; Color for Gas 2
779 dcfsnz active_gas,F
780 movlw color_red ; Color for Gas 3
781 dcfsnz active_gas,F
782 movlw color_yellow ; Color for Gas 4
783 dcfsnz active_gas,F
784 movlw color_violet ; Color for Gas 5
785 dcfsnz active_gas,F
786 movlw color_cyan ; Color for Gas 6
787 goto PLED_set_color ; Set Color...
788
789 ;=============================================================================
686 profileview_page2: 790 profileview_page2:
687 WIN_BOX_BLACK .0, .74, .0, .159 ;top, bottom, left, right 791 WIN_BOX_BLACK .0, .74, .0, .159 ;top, bottom, left, right
688 792
689 movff average_depth_hold+0,eeprom_address+0 793 movff average_depth_hold+0,eeprom_address+0
690 movff average_depth_hold+1,eeprom_address+1 ; Pointer to Gaslist 794 movff average_depth_hold+1,eeprom_address+1 ; Pointer to Gaslist
797 cpfslt hi ; <2? 901 cpfslt hi ; <2?
798 bsf show_cns_in_logbook ; No, set flag 902 bsf show_cns_in_logbook ; No, set flag
799 output_8 903 output_8
800 call word_processor ; Display Gas information 904 call word_processor ; Display Gas information
801 bcf leftbind ; Clear flag 905 bcf leftbind ; Clear flag
802
803
804 906
805 WIN_TOP .50 907 WIN_TOP .50
806 lfsr FSR2,letter 908 lfsr FSR2,letter
807 call I2CREAD2 ; Battery lo 909 call I2CREAD2 ; Battery lo
808 movff SSPBUF,lo 910 movff SSPBUF,lo
967 bra exit_profileview ; back to list 1069 bra exit_profileview ; back to list
968 btfsc divemode 1070 btfsc divemode
969 goto restart ; Enter Divemode if required 1071 goto restart ; Enter Divemode if required
970 bra display_profile3_loop ; wait for something to do 1072 bra display_profile3_loop ; wait for something to do
971 1073
972 1074 ;=============================================================================
973 1075 ; Draw a vertical line between xC+1 and xC+0, at current X position.
974 profile_display_fill: ; In this column between this row (xC+0) and the last row (apnoe_mins), keep xC+0!! 1076 ;
975 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins 1077 ; Note: should keep xC+0
1078 ; Note: ascending or descending !
1079 ;
1080 profile_display_fill:
1081 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins
976 movf xC+0,W 1082 movf xC+0,W
977 cpfseq apnoe_mins ; xC+0 = apone_mins? 1083 cpfseq xC+1 ; xC+0 = apone_mins?
978 bra profile_display_fill2 ; No! 1084 bra profile_display_fill2 ; No!
979 return 1085 return
980 1086
981 profile_display_fill2: 1087 profile_display_fill2:
982 movf xC+0,W 1088 cpfsgt xC+1 ; apnoe_mins>xC+0?
983 cpfsgt apnoe_mins ; apnoe_mins>xC+0?
984 bra profile_display_fill_up ; Yes! 1089 bra profile_display_fill_up ; Yes!
985 1090
986 profile_display_fill_down: ; Fill downwards from apone_mins to xC+0!
987 movff apnoe_mins,xC+1 ; Copy
988 profile_display_fill_down2: ; Loop 1091 profile_display_fill_down2: ; Loop
989 decf xC+1,F 1092 decf xC+1,F
990 1093
991 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) 1094 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
992 1095
994 cpfseq xC+1 ; Loop until xC+1=xC+0 1097 cpfseq xC+1 ; Loop until xC+1=xC+0
995 bra profile_display_fill_down2 1098 bra profile_display_fill_down2
996 return ; apnoe_mins and xC+0 are untouched 1099 return ; apnoe_mins and xC+0 are untouched
997 1100
998 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins! 1101 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins!
999 movff xC+0,xC+1 ; Copy 1102 incf xC+1,F
1000 profile_display_fill_up2: ; Loop
1001 decf xC+1,F
1002 1103
1003 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) 1104 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
1004 1105
1005 movf apnoe_mins,W 1106 movf xC+0,W
1006 cpfseq xC+1 ; Loop until xC+1=apnoe_mins 1107 cpfseq xC+1 ; Loop until xC+1=apnoe_mins
1007 bra profile_display_fill_up2 1108 bra profile_display_fill_up
1008 return ; apnoe_mins and xC+0 are untouched 1109 return ; apnoe_mins and xC+0 are untouched
1110
1111 ;=============================================================================
1009 1112
1010 profile_view_get_depth: 1113 profile_view_get_depth:
1011 incf average_divesecs+0,F 1114 incf average_divesecs+0,F
1012 movlw d'0' 1115 movlw d'0'
1013 addwfc average_divesecs+1,F ; Count read pixels 1116 addwfc average_divesecs+1,F ; Count read pixels
1032 movff WREG,win_height 1135 movff WREG,win_height
1033 movlw d'1' 1136 movlw d'1'
1034 movff WREG,win_width ; "Window" Width 1137 movff WREG,win_width ; "Window" Width
1035 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 1138 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
1036 1139
1037 ; Now restore current profile color
1038 movff average_depth_hold_total+3,active_gas ; restore color
1039 dcfsnz active_gas,F
1040 movlw color_white ; Color for Gas 1
1041 dcfsnz active_gas,F
1042 movlw color_green ; Color for Gas 2
1043 dcfsnz active_gas,F
1044 movlw color_red ; Color for Gas 3
1045 dcfsnz active_gas,F
1046 movlw color_yellow ; Color for Gas 4
1047 dcfsnz active_gas,F
1048 movlw color_violet ; Color for Gas 5
1049 call PLED_set_color ; Set Color...
1050
1051 profile_view_get_depth_no_line: 1140 profile_view_get_depth_no_line:
1052 call I2CREAD2 ; read first depth 1141 call I2CREAD2 ; read first depth
1053 movff SSPBUF,lo ; low value 1142 movff SSPBUF,logbook_cur_depth+0 ; low value
1054 call I2CREAD2 ; read first depth 1143 call I2CREAD2 ; read first depth
1055 movff SSPBUF,hi ; high value 1144 movff SSPBUF,logbook_cur_depth+1 ; high value
1056 call I2CREAD2 ; read Profile Flag Byte 1145 call I2CREAD2 ; read Profile Flag Byte
1057 movff SSPBUF,timeout_counter2 ; Read Profile Flag Byte 1146 movff SSPBUF,timeout_counter2 ; Read Profile Flag Byte
1058 1147
1059 bcf event_occured ; clear flag 1148 bcf event_occured ; clear flag
1060 btfsc timeout_counter2,7 1149 btfsc timeout_counter2,7
1061 bsf event_occured ; We also have an Event byte! 1150 bsf event_occured ; We also have an Event byte!
1062 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any) 1151 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any)
1063 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127) 1152 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
1064 movlw 0xFD ; end of profile bytes? 1153 movlw 0xFD ; end of profile bytes?
1065 cpfseq lo 1154 cpfseq logbook_cur_depth+0
1066 bra profile_view_get_depth_new1 ; no 0xFD 1155 bra profile_view_get_depth_new1 ; no 0xFD
1067 movlw 0xFD ; end of profile bytes? 1156 movlw 0xFD ; end of profile bytes?
1068 cpfseq hi 1157 cpfseq logbook_cur_depth+1
1069 bra profile_view_get_depth_new1 ; no 0xFD 1158 bra profile_view_get_depth_new1 ; no 0xFD
1070 bsf second_FD ; End found! Set Flag! Skip remaining pixels! 1159 bsf second_FD ; End found! Set Flag! Skip remaining pixels!
1071 return 1160 return
1072 1161
1073 profile_view_get_depth_new1: 1162 profile_view_get_depth_new1:
1074 btfsc event_occured ; Was there an event attached to this sample? 1163 btfsc event_occured ; Was there an event attached to this sample?
1075 rcall profile_view_get_depth_new2 ; Yes, get information about this event 1164 rcall profile_view_get_depth_new2 ; Yes, get information about this event
1076 1165
1077 tstfsz timeout_counter2 ; Any bytes to ignore 1166 ;---- Read Tp°, if any AND divisor reached AND bytes available -----------
1078 bra profile_view_get_depth_new3 ; Yes (1-127) 1167 movf divisor_temperature,W ; Is Tp° divisor null ?
1079 return ; No (0) 1168 bz profile_view_get_depth_no_tp; Yes: no Tp° curve.
1080 1169 decf logbook_temp1,F ; Decrement tp° counter
1081 profile_view_get_depth_new3: 1170 bnz profile_view_get_depth_no_tp; No temperature this time
1082 ; read optional Tp° here, if any, and decrement timeout_counter2 by two... 1171
1172 call I2CREAD2 ; Tp° low
1173 movff SSPBUF,logbook_cur_tp+0
1174 call I2CREAD2 ; Tp° high
1175 movff SSPBUF,logbook_cur_tp+1
1176 decf timeout_counter2,F
1177 decf timeout_counter2,F
1178 movff divisor_temperature,logbook_temp1 ; Restart counter.
1179
1180 ;---- Read deco, if any AND divisor=0 AND bytes available ----------------
1181 profile_view_get_depth_no_tp:
1182 movf divisor_deco,W
1183 bz profile_view_get_depth_no_deco
1184 decf logbook_temp2,F
1185 bnz profile_view_get_depth_no_deco
1186
1187 call I2CREAD2
1188 movff SSPBUF,logbook_ceiling
1189 decf timeout_counter2,F
1190 movff divisor_deco,logbook_temp2 ; Restart counter.
1191
1192 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------
1193 profile_view_get_depth_no_deco:
1194
1195 movf timeout_counter2,W ; No more extra bytes ?
1196 btfsc STATUS,Z
1197 return ; No: done.
1198
1199 ; Then skip remaining bytes...
1083 movf timeout_counter2,W ; number of additional bytes to ignore (0-127) 1200 movf timeout_counter2,W ; number of additional bytes to ignore (0-127)
1084 call incf_eeprom_address0 ; increases bytes in eeprom_address:2 with 0x8000 bank switching 1201 call incf_eeprom_address0 ; increases bytes in eeprom_address:2 with 0x8000 bank switching
1085 return 1202 return
1086 1203
1087 profile_view_get_depth_new2: 1204 profile_view_get_depth_new2:
1093 bra logbook_event1 ; Yes! 1210 bra logbook_event1 ; Yes!
1094 btfss EventByte,5 ; Stored Gas Changed? 1211 btfss EventByte,5 ; Stored Gas Changed?
1095 return ; No, return 1212 return ; No, return
1096 ; Stored Gas changed! 1213 ; Stored Gas changed!
1097 call I2CREAD2 ; Read Gas# 1214 call I2CREAD2 ; Read Gas#
1098 movff SSPBUF,active_gas ; store gas# 1215 movff SSPBUF,average_depth_hold_total+3
1099 movff active_gas,average_depth_hold_total+3 ; keep copy to restore color after drawing 10min line 1216 rcall profile_display_color ; Back to normal profile color.
1217
1100 decf timeout_counter2,F ; reduce counter 1218 decf timeout_counter2,F ; reduce counter
1101 dcfsnz active_gas,F
1102 movlw color_white ; Color for Gas 1
1103 dcfsnz active_gas,F
1104 movlw color_green ; Color for Gas 2
1105 dcfsnz active_gas,F
1106 movlw color_red ; Color for Gas 3
1107 dcfsnz active_gas,F
1108 movlw color_yellow ; Color for Gas 4
1109 dcfsnz active_gas,F
1110 movlw color_violet ; Color for Gas 5
1111 call PLED_set_color ; Set Color...
1112 return 1219 return
1113 1220
1114 logbook_event1: 1221 logbook_event1:
1115 movlw color_cyan ; Color for Gas 6 1222 movlw 6 ; Just color backup to 6
1116 call PLED_set_color ; Set Color... 1223 movwf average_depth_hold_total+3
1224 rcall profile_display_color ; Back to normal profile color.
1117 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...) 1225 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...)
1118
1119 ;Keep comments for future temperature graph
1120 ; call I2CREAD2 ; ignore byte
1121 ; decfsz timeout_counter2,F ; reduce counter
1122 ; bra profile_view_get_depth_new3 ; Loop
1123 ; return
1124 1226
1125 exit_profileview: 1227 exit_profileview:
1126 bcf sleepmode 1228 bcf sleepmode
1127 clrf timeout_counter2 ; restore all registers to build same page again 1229 clrf timeout_counter2 ; restore all registers to build same page again
1128 movff decodata+0,eeprom_address+0 1230 movff decodata+0,eeprom_address+0