Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 268:7d24c9d62095
average depth in logbook fixed
author | heinrichsweikamp |
---|---|
date | Tue, 12 Apr 2011 21:02:45 +0200 |
parents | ba109a7948df |
children | ceedf078b2d8 |
comparison
equal
deleted
inserted
replaced
267:814ac3af3052 | 268:7d24c9d62095 |
---|---|
502 ; 2 bytes salinity, GF | 502 ; 2 bytes salinity, GF |
503 | 503 |
504 display_profile2d: | 504 display_profile2d: |
505 ; Start Profile display | 505 ; Start Profile display |
506 | 506 |
507 clrf average_depth_hold_total+0 | 507 clrf average_divesecs+0 |
508 clrf average_depth_hold_total+1 | 508 clrf average_divesecs+1 ; Counts x-pixels for average |
509 clrf average_depth_hold_total+2 | 509 clrf average_depth_hold_total+0 |
510 clrf average_depth_hold_total+3 ; Track average depth here... | 510 clrf average_depth_hold_total+1 |
511 clrf average_depth_hold_total+2 | |
512 clrf average_depth_hold_total+3 ; Track average depth here... | |
511 | 513 |
512 ; Write 0m X-Line.. | 514 ; Write 0m X-Line.. |
513 movlw color_grey | 515 movlw color_grey |
514 call PLED_set_color ; Make this configurable? | 516 call PLED_set_color ; Make this configurable? |
515 | 517 |
600 incf profile_temp2+0,F ; Zero, Increase! | 602 incf profile_temp2+0,F ; Zero, Increase! |
601 | 603 |
602 profile_display_loop2: | 604 profile_display_loop2: |
603 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo | 605 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo |
604 | 606 |
605 ; Subtract Surface pressure | |
606 movff average_depth_hold+2,sub_b+0 | |
607 movff average_depth_hold+3,sub_b+1 ; ambient pressure in mBar | |
608 movff lo,sub_a+0 | |
609 movff hi,sub_a+1 ; depth in mBar | |
610 call sub16 ; sub_c = sub_a - sub_b | |
611 | |
612 ; add depth to average registers | |
613 movf sub_c+0,W | |
614 addwf average_depth_hold_total+0,F | |
615 movf sub_c+1,W | |
616 addwfc average_depth_hold_total+1,F | |
617 movlw d'0' | |
618 addwfc average_depth_hold_total+2,F | |
619 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
620 | |
621 btfsc second_FD ; end-of profile reached? | 607 btfsc second_FD ; end-of profile reached? |
622 bra profile_display_loop_done ; Yes, skip all remaining pixels | 608 bra profile_display_loop_done ; Yes, skip all remaining pixels |
623 | 609 |
624 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett | 610 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett |
625 movff sim_pressure+1,xB+1 | 611 movff sim_pressure+1,xB+1 |
647 | 633 |
648 profile_display_loop3: | 634 profile_display_loop3: |
649 decfsz profile_temp2+1,F ; 16 bit x-scaler test | 635 decfsz profile_temp2+1,F ; 16 bit x-scaler test |
650 bra profile_display_skip_loop1 ; skips readings! | 636 bra profile_display_skip_loop1 ; skips readings! |
651 | 637 |
652 decfsz ignore_digits,F ; counts x-pixels to zero | 638 decfsz ignore_digits,F ; counts drawn x-pixels to zero |
653 bra profile_display_loop ; Not ready yet | 639 bra profile_display_loop ; Not ready yet |
654 ; Done. | 640 ; Done. |
655 profile_display_loop_done: | 641 profile_display_loop_done: |
656 call PLED_standard_color ; Restore color | 642 call PLED_standard_color ; Restore color |
657 movlw d'159' | |
658 ; movlw d'200' | |
659 subfwb ignore_digits,W ; keep number of X-pixels (For average depth display on Page 3) | |
660 movwf average_divesecs+0 ; Store here for compatibility | |
661 | 643 |
662 bcf sleepmode ; clear some flags | 644 bcf sleepmode ; clear some flags |
663 bcf menubit2 | 645 bcf menubit2 |
664 bcf menubit3 | 646 bcf menubit3 |
665 bcf switch_right | 647 bcf switch_right |
874 STRCAT_PRINT "%" ; Display CNS % | 856 STRCAT_PRINT "%" ; Display CNS % |
875 | 857 |
876 logbook_skip_cns: | 858 logbook_skip_cns: |
877 WIN_TOP .50 | 859 WIN_TOP .50 |
878 | 860 |
879 btfsc average_divesecs+0,0 ; Number of drawn pixels even? | 861 movff average_divesecs+0,xB+0 ; Number of samples in dive |
880 incf average_divesecs+0,W ; No, add +1 -> WREG | 862 movff average_divesecs+1,xB+1 ; Copy to xB:2 |
881 movwf xB+0 ; Copy W to xB+0 | 863 |
882 clrf xB+1 ; Number of x-pixels displayed | |
883 movff average_depth_hold_total+0,xC+0 | 864 movff average_depth_hold_total+0,xC+0 |
884 movff average_depth_hold_total+1,xC+1 | 865 movff average_depth_hold_total+1,xC+1 |
885 movff average_depth_hold_total+2,xC+2 | 866 movff average_depth_hold_total+2,xC+2 |
886 movff average_depth_hold_total+3,xC+3 | 867 movff average_depth_hold_total+3,xC+3 |
887 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | 868 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
888 STRCPY "Avr:" | 869 STRCPY "Avr:" |
889 movff xC+0,lo | 870 movff xC+0,lo |
890 movff xC+1,hi | 871 movff xC+1,hi |
891 output_16dp d'3' ; Average depth (Re-calculated from the drawn profile - not 100% exact!) | 872 output_16dp d'3' ; Average depth (Re-calculated from the drawn profile - not 100% exact!) |
892 STRCAT_PRINT "m" | 873 STRCAT_PRINT "m" |
893 | 874 |
894 ; WIN_TOP .0 | 875 ; WIN_TOP .0 |
895 ; WIN_LEFT .65 | 876 ; WIN_LEFT .75 |
896 ; lfsr FSR2,letter | 877 ; lfsr FSR2,letter |
897 ; movff average_divesecs+0,lo | 878 ; movff average_divesecs+0,lo |
898 ; output_8 | 879 ; output_8 |
899 ; call word_processor | 880 ; call word_processor |
881 | |
900 | 882 |
901 bcf menubit2 | 883 bcf menubit2 |
902 bcf menubit3 | 884 bcf menubit3 |
903 bcf switch_right | 885 bcf switch_right |
904 bcf switch_left | 886 bcf switch_left |
963 movff SSPBUF,lo ; low value | 945 movff SSPBUF,lo ; low value |
964 call I2CREAD2 ; read first depth | 946 call I2CREAD2 ; read first depth |
965 movff SSPBUF,hi ; high value | 947 movff SSPBUF,hi ; high value |
966 call I2CREAD2 ; read Profile Flag Byte | 948 call I2CREAD2 ; read Profile Flag Byte |
967 movff SSPBUF,timeout_counter2 ; Read Profile Flag Byte | 949 movff SSPBUF,timeout_counter2 ; Read Profile Flag Byte |
950 | |
968 bcf event_occured ; clear flag | 951 bcf event_occured ; clear flag |
969 btfsc timeout_counter2,7 | 952 btfsc timeout_counter2,7 |
970 bsf event_occured ; We also have an Event byte! | 953 bsf event_occured ; We also have an Event byte! |
971 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any) | 954 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any) |
972 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127) | 955 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127) |
978 bra profile_view_get_depth_new1 ; no 0xFD | 961 bra profile_view_get_depth_new1 ; no 0xFD |
979 bsf second_FD ; End found! Set Flag! Skip remaining pixels! | 962 bsf second_FD ; End found! Set Flag! Skip remaining pixels! |
980 return | 963 return |
981 | 964 |
982 profile_view_get_depth_new1: | 965 profile_view_get_depth_new1: |
966 incf average_divesecs+0,F | |
967 movlw d'0' | |
968 addwfc average_divesecs+1,F ; counter for average depth | |
969 ; add depth to average registers | |
970 movf lo,W | |
971 addwf average_depth_hold_total+0,F | |
972 movf hi,W | |
973 addwfc average_depth_hold_total+1,F | |
974 movlw d'0' | |
975 addwfc average_depth_hold_total+2,F | |
976 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
977 | |
983 btfsc event_occured ; Was there an event attached to this sample? | 978 btfsc event_occured ; Was there an event attached to this sample? |
984 rcall profile_view_get_depth_new2 ; Yes, get information about this event | 979 rcall profile_view_get_depth_new2 ; Yes, get information about this event |
985 | 980 |
986 tstfsz timeout_counter2 ; Any bytes to ignore | 981 tstfsz timeout_counter2 ; Any bytes to ignore |
987 bra profile_view_get_depth_new3 ; Yes (1-127) | 982 bra profile_view_get_depth_new3 ; Yes (1-127) |