Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 451:f6f818edf333
BUGFIX bad first Tp? and ceiling in logbook curves.
* Computing Tp? max during logbook profile reading.
author | JeanDo |
---|---|
date | Thu, 18 Aug 2011 23:33:24 +0200 |
parents | 6e57b5bb98ce |
children | 05ec97e106da |
comparison
equal
deleted
inserted
replaced
450:26e5bb28891d | 451:f6f818edf333 |
---|---|
33 logbook1_ptr:2 ; Loogbook pointer inside EEPROM Bank1 | 33 logbook1_ptr:2 ; Loogbook pointer inside EEPROM Bank1 |
34 logbook_cur_depth:2 ; Current depth, for drawing profile. | 34 logbook_cur_depth:2 ; Current depth, for drawing profile. |
35 logbook_cur_tp:2 ; Current temperature, for drawing profile. | 35 logbook_cur_tp:2 ; Current temperature, for drawing profile. |
36 logbook_last_tp ; Y of the last item in Tp° curve. | 36 logbook_last_tp ; Y of the last item in Tp° curve. |
37 logbook_min_tp:2 ; Min temperature, for drawing profile. | 37 logbook_min_tp:2 ; Min temperature, for drawing profile. |
38 logbook_max_tp:2 ; Maximum temperature, for drawing profile. | |
38 logbook_ceiling ; Current ceiling, for drawing profile. | 39 logbook_ceiling ; Current ceiling, for drawing profile. |
39 ENDC | 40 ENDC |
40 | 41 |
41 ;============================================================================= | 42 ;============================================================================= |
42 ; searches external EEPROM for dive headers and displays them in a list | 43 ; searches external EEPROM for dive headers and displays them in a list |
618 movlw d'75' ; Zero-m row | 619 movlw d'75' ; Zero-m row |
619 movwf apnoe_mins ; here: used for fill between rows | 620 movwf apnoe_mins ; here: used for fill between rows |
620 movwf logbook_last_tp ; Initialise for Tp° curve too. | 621 movwf logbook_last_tp ; Initialise for Tp° curve too. |
621 incf timeout_counter3,W ; Init Column | 622 incf timeout_counter3,W ; Init Column |
622 | 623 |
624 movlw LOW(-.100) ; Initialize max tp° to -10.0 °C. | |
625 movwf logbook_max_tp+0 | |
626 movlw HIGH 0xFFFF & (-.100) | |
627 movwf logbook_max_tp+1 | |
623 | 628 |
629 setf logbook_cur_tp+0 ; Initialize Tp°, before the first recorded point. | |
630 setf logbook_cur_tp+1 | |
631 clrf logbook_last_tp ; Also reset previous Y for Tp° | |
632 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling. | |
633 | |
624 INIT_PIXEL_WROTE timeout_counter3 ; pixel x2 (Also sets standard Color!) | 634 INIT_PIXEL_WROTE timeout_counter3 ; pixel x2 (Also sets standard Color!) |
625 | 635 |
626 profile_display_loop: | 636 profile_display_loop: |
627 movff profile_temp+0,profile_temp2+0 | 637 movff profile_temp+0,profile_temp2+0 |
628 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler | 638 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler |
671 | 681 |
672 ;---- Draw Tp° curve, if any --------------------------------------------- | 682 ;---- Draw Tp° curve, if any --------------------------------------------- |
673 movf divisor_temperature,W | 683 movf divisor_temperature,W |
674 bz profile_display_skip_temp | 684 bz profile_display_skip_temp |
675 | 685 |
686 movf logbook_cur_tp+0,W ; Did we had already a valid Tp°C record ? | |
687 andwf logbook_cur_tp+1,W | |
688 incf WREG | |
689 bz profile_display_skip_temp ; No: just skip drawing. | |
690 | |
676 movlw LOW((.153*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scaleé56 )/153pix | 691 movlw LOW((.153*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scaleé56 )/153pix |
677 movwf xB+0 | 692 movwf xB+0 |
678 movlw HIGH((.153*.256)/.370) | 693 movlw HIGH((.153*.256)/.370) |
679 movwf xB+1 | 694 movwf xB+1 |
680 | 695 |
695 ; Check limits | 710 ; Check limits |
696 movlw d'75' | 711 movlw d'75' |
697 movwf xC+1 | 712 movwf xC+1 |
698 cpfsgt xC+0 | 713 cpfsgt xC+0 |
699 movff xC+1,xC+0 | 714 movff xC+1,xC+0 |
700 | |
701 | |
702 | 715 |
703 movlw color_pink | 716 movlw color_pink |
704 call PLED_set_color | 717 call PLED_set_color |
705 | 718 |
706 movff logbook_last_tp,xC+1 | 719 movf logbook_last_tp,W ; do we have a valid previous value ? |
720 bz profile_display_temp_1 ; No: skip the vertical line. | |
721 movwf xC+1 | |
707 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | 722 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) |
723 profile_display_temp_1: | |
708 movff xC+0,logbook_last_tp | 724 movff xC+0,logbook_last_tp |
709 | 725 |
710 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a current color pixel. | 726 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a current color pixel. |
711 | 727 |
712 profile_display_skip_temp: | 728 profile_display_skip_temp: |
1206 call I2CREAD2 ; Tp° high | 1222 call I2CREAD2 ; Tp° high |
1207 movff SSPBUF,logbook_cur_tp+1 | 1223 movff SSPBUF,logbook_cur_tp+1 |
1208 decf timeout_counter2,F | 1224 decf timeout_counter2,F |
1209 decf timeout_counter2,F | 1225 decf timeout_counter2,F |
1210 movff divisor_temperature,count_temperature ; Restart counter. | 1226 movff divisor_temperature,count_temperature ; Restart counter. |
1227 | |
1228 ; Compute Tp° max on the fly... | |
1229 movff logbook_cur_tp+0,sub_a+0 ; Compare cur_tp > max_tp ? | |
1230 movff logbook_cur_tp+1,sub_a+1 | |
1231 movff logbook_max_tp+0,sub_b+0 | |
1232 movff logbook_max_tp+1,sub_b+1 | |
1233 call sub16 ; SIGNED sub_a - sub_b | |
1234 btfsc neg_flag | |
1235 bra profile_view_get_depth_no_tp | |
1236 | |
1237 movff logbook_cur_tp+0,logbook_max_tp+0 | |
1238 movff logbook_cur_tp+1,logbook_max_tp+1 | |
1211 | 1239 |
1212 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- | 1240 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- |
1213 profile_view_get_depth_no_tp: | 1241 profile_view_get_depth_no_tp: |
1214 movf divisor_deco,W | 1242 movf divisor_deco,W |
1215 bz profile_view_get_depth_no_deco | 1243 bz profile_view_get_depth_no_deco |