Mercurial > public > hwos_code
diff src/tft_outputs.asm @ 315:4f83470dcece new_screen_layout
VSIbar #3: remaining changes for the split style bar
author | Janos Kovacs <kovjanos@gmail.com> |
---|---|
date | Wed, 10 Jun 2015 22:32:38 +0100 |
parents | 453a3d13570f |
children | c6c934f05b42 |
line wrap: on
line diff
--- a/src/tft_outputs.asm Wed Jun 10 22:24:27 2015 +0100 +++ b/src/tft_outputs.asm Wed Jun 10 22:32:38 2015 +0100 @@ -537,13 +537,15 @@ STRCAT_TEXT_PRINT tDivetime endif - ; DEBUG !!! - movlw color_dark_red - call TFT_set_color - WIN_FRAME_COLOR16 dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right - - movlw color_blue - WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right + if dm_offset == 0 + movlw color_dark_red + call TFT_set_color + WIN_FRAME_COLOR16 dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right + WIN_FRAME_COLOR16 dm_sep_1_2_row, dm_sep_1_2_row, .0, .159 ;top, bottom, left, right + WIN_FRAME_COLOR16 dm_sep_2_3_row, dm_sep_2_3_row, .0, .159 ;top, bottom, left, right + WIN_FRAME_COLOR16 dm_warning_row-.1, dm_warning_row-.1, dm_warning_column, .159 ;top, bottom, left, right + call TFT_draw_gassep_line + endif call TFT_standard_color return @@ -553,27 +555,52 @@ WIN_BOX_BLACK dm_customview_row, dm_customview_bot, dm_customview_column, dm_customview_rgt ; top, bottom, left, right return + global TFT_draw_gassep_line +TFT_draw_gassep_line: + btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode + return + btfsc divemode_menu ; Is the dive mode menu shown? + return ; Yes, return + if dm_offset == 0 + movlw color_dark_red + call TFT_set_color + WIN_FRAME_COLOR16 dm_gassep_row, dm_gassep_bot, dm_gassep_column, dm_gassep_column + endif + call TFT_standard_color + return + ;========================================================================= global TFT_display_velocity TFT_display_velocity: ; With divA+0 = m/min + ; Input is: + ; neg_flag: ascend=1, descend=0 + ; divA+0: rate in m/min ; init flags used to store warning/attention bcf velocity_warn bcf velocity_attn - + ; retain the neg_flag (descending information) + bcf neg_flag_velocity + btfsc neg_flag + bsf neg_flag_velocity ; check if old/new ascend logic is used TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic - bra TFT_dispay_velocity_std - - ; Input is: - ; neg_flag: ascend=1, descend=0 - ; divA+0: rate in m/min - + bra TFT_velocity_std ; static ascend rate limit + ; initialize the multiplier/offset values, also required for the + ; below-the-treshold bar + movlw .7 + movwf xC+0 + movlw .6 + movwf xC+1 + movlw .1 + movwf xC+2 + movlw .0 + movwf xC+3 ; check if velocity is below the treshold level movlw velocity_display_threshold_2 subwf divA+0,W btfss STATUS,C - bra TFT_display_velocity_ntr + bra TFT_velocity_ntr ; ascend/descend rare is below limit bsf display_velocity ; use a depth-dependent ascent rate warning @@ -582,33 +609,29 @@ ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning) ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention) - + ; + ; use different multipliers and offsets for the different ascend limits for + ; a smoother bar ; w-multip 7 6 5 5 4 3 3 2 2 2 2 ; a-multip 6 5 4 3 3 3 2 2 2 2 2 ; w-offset 1 2 5 0 6 11 5 16 14 12 10 ; a-offset 0 0 2 6 6 0 6 4 2 0 0 - ; retain the neg_flag (descending information) - bcf neg_flag_save - btfsc neg_flag - bsf neg_flag_save - ; check if descending: no warning color if descending call TFT_standard_color - btfss neg_flag ; Ignore for descent! - bra TFT_display_velocity_out - + btfss neg_flag_velocity ; Ignore for descent! + bra TFT_velocity_disp + ; get the actual depth SAFE_2BYTE_COPY rel_pressure, lo ; get the actual depth call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] call convert_mbar_to_feet ; get depth in feet + ; store current depth (in feet) into sub_a + movff lo,sub_a+0 + movff hi,sub_a+1 ; xA will be used to store the warning/attention limits passed to the verification clrf xA+0 clrf xA+1 - ; store current depth (in feet) into sub_a - movff lo,sub_a+0 - movff hi,sub_a+1 - ;TFT_display_velocity_asc_164: ; store segment limit into sub_b clrf sub_b+1 @@ -878,104 +901,110 @@ TFT_velocity_def: call TFT_standard_color - bra TFT_display_velocity_out + bra TFT_velocity_disp TFT_velocity_warn: call TFT_warnings_color ; Set to warning color bsf win_invert bsf velocity_warn - bra TFT_display_velocity_out + bra TFT_velocity_disp TFT_velocity_attn: call TFT_attention_color ; Set to attention color bsf velocity_attn - ;bra TFT_display_velocity_out - -TFT_display_velocity_out: - ; retain neg_flag value - restore - bcf neg_flag - btfsc neg_flag_save - bsf neg_flag - bra TFT_dispay_velocity_disp - -TFT_dispay_velocity_std: + bra TFT_velocity_disp + +TFT_velocity_std: + ; initialize the multiplier/offset values for the graphical bar + movlw .5 + movwf xC+0 + movlw .3 + movwf xC+1 + movlw .0 + movwf xC+2 + movlw .6 + movwf xC+3 + movlw velocity_display_threshold_1 ; lowest threshold for display vertical velocity subwf divA+0,W btfss STATUS,C - bra TFT_display_velocity_clear + bra TFT_velocity_ntr ; under treshold, clear text and display VSIbar bsf display_velocity call TFT_standard_color - btfss neg_flag ; Ignore for descent! - bra TFT_dispay_velocity_disp ; Skip check! + btfss neg_flag_velocity ; Ignore for descent! + bra TFT_velocity_disp ; Skip check! movff divA+0,lo movlw color_code_velocity_warn_high ; Velocity warn [m/min] subwf lo,W btfsc STATUS,C - call TFT_warnings_color ; Set to warning color - -TFT_dispay_velocity_disp: + bra TFT_velocity_std_warn + bra TFT_velocity_disp + +TFT_velocity_std_warn: + call TFT_warnings_color ; Set to warning color + bsf velocity_warn + ;bsf TFT_velocity_disp + +TFT_velocity_disp: WIN_SMALL dm_velocity_text_column, dm_velocity_text_row TSTOSS opt_units ; 0=Meters, 1=Feets - bra TFT_display_velocity_metric -;TFT_display_velocity_imperial: + bra TFT_velocity_metric +;TFT_velocity_imperial: movff divA+0,WREG ; divA+0 = m/min mullw .100 ; PRODL:PRODH = mbar/min movff PRODL,lo movff PRODH,hi call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet movlw '-' - btfsc neg_flag + btfsc neg_flag_velocity movlw '+' movwf POSTINC2 bsf leftbind output_16 bcf leftbind STRCAT_TEXT_PRINT tVelImperial ; Unit switch + bcf win_invert + bcf neg_flag + call TFT_velocity_VSIbar + bcf neg_flag_velocity call TFT_standard_color - bcf win_invert - call TFT_display_VSIbar return -TFT_display_velocity_metric: +TFT_velocity_metric: movff divA+0,lo ; divA+0 = m/min movlw '-' - btfsc neg_flag + btfsc neg_flag_velocity movlw '+' movwf POSTINC2 output_99 STRCAT_TEXT_PRINT tVelMetric ; Unit switch + bcf win_invert + bcf neg_flag + call TFT_velocity_VSIbar + bcf neg_flag_velocity call TFT_standard_color - bcf win_invert - call TFT_display_VSIbar return -TFT_display_VSIbar: +TFT_velocity_VSIbar: ; use another logic when descending - btfss neg_flag - bra TFT_dispay_VSIbar_desc + btfss neg_flag_velocity + bra TFT_velocity_VSIbar_desc + call TFT_velocity_VSIbar_desc_clr btfsc velocity_warn - bra TFT_display_VSIbar_warn - btfsc velocity_attn - bra TFT_display_VSIbar_attn - ; all ok, use attn's values + bra TFT_velocity_VSIbar_warn + ; if all ok or attention, use attn's values movff xC+1,sub_b+0 ; multiplier movff xC+3,sub_b+1 ; offset - bra TFT_display_VSIbar_com - -TFT_display_VSIbar_warn: + bra TFT_velocity_VSIbar_com + +TFT_velocity_VSIbar_warn: ; save multiplier and offset out from the xC movff xC+0,sub_b+0 ; multiplier movff xC+2,sub_b+1 ; offset - bra TFT_display_VSIbar_com - -TFT_display_VSIbar_attn: - ; save multiplier and offset out from the xC - movff xC+1,sub_b+0 ; multiplier - movff xC+3,sub_b+1 ; offset - ;bra TFT_display_VSIbar_com - -TFT_display_VSIbar_com: + ;bra TFT_velocity_VSIbar_com + +TFT_velocity_VSIbar_com: ; multiply movff divA+0,xA+0 clrf xA+1 @@ -984,44 +1013,47 @@ call mult16x16 ; xA*xB=xC movlw .1 cpfslt xC+3 - bra TFT_display_VSIbar_max + bra TFT_velocity_VSIbar_max cpfslt xC+2 - bra TFT_display_VSIbar_max + bra TFT_velocity_VSIbar_max cpfslt xC+1 - bra TFT_display_VSIbar_max + bra TFT_velocity_VSIbar_max ; add offset movff sub_b+1,WREG addwf xC+0,1 btfsc STATUS,C - bra TFT_display_VSIbar_max + bra TFT_velocity_VSIbar_max ; check if out-of-range movff xC+0,divB movlw .60 cpfsgt divB - bra TFT_display_VSIbar_draw - -TFT_display_VSIbar_max: + bra TFT_velocity_VSIbar_draw + +TFT_velocity_VSIbar_max: movlw .60 movff WREG,divB -TFT_display_VSIbar_draw: +TFT_velocity_VSIbar_draw: ; calculate top&height for the bar and mask ; 1. Bar: top=(bar_top+60-divB); height=divB movlw dm_velobar_top+.1 - movff WREG,sub_a+0 ; !!!!!! bar position must fit into lo !! + movff WREG,sub_a+0 ; !!!!!! bar position must fit into lo !! movlw .60 addwf sub_a+0,1 clrf sub_a+1 movff divB,sub_b+0 clrf sub_b+1 call subU16 + + movlw color_white + WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right movff sub_c+0,win_top movff divB,win_height - movlw dm_velobar_width + movlw dm_velobar_width-.4 movff WREG,win_width movff WREG,win_bargraph - movlw dm_velobar_lft+.1 + movlw dm_velobar_lft+.3 movff WREG,win_leftx2 movlw color_green call TFT_set_color @@ -1057,36 +1089,126 @@ call TFT_box return -TFT_dispay_VSIbar_desc: +TFT_velocity_VSIbar_desc: ; clear the ascend part of the bar - call TFT_display_VSIbar_clr - ; TODO + call TFT_velocity_VSIbar_clr + ; divA+0=0 is descend, clear everything if it's actually zero + movlw .0 + cpfsgt divA+0 + bra TFT_velocity_VSIbar_desc_clr + + ; Desc uses a single multiplier/offset value: *1 / +3 + movlw .1 + movff WREG,sub_b+0 ; multiplier + movlw .3 + movff WREG,sub_b+1 ; offset + ; multiply + movff divA+0,xA+0 + clrf xA+1 + movff sub_b+0,xB+0 + clrf xB+1 + call mult16x16 ; xA*xB=xC + movlw .1 + cpfslt xC+3 + bra TFT_velocity_VSIbar_desc_max + cpfslt xC+2 + bra TFT_velocity_VSIbar_desc_max + cpfslt xC+1 + bra TFT_velocity_VSIbar_desc_max + ; add offset + movff sub_b+1,WREG + addwf xC+0,1 + btfsc STATUS,C + bra TFT_velocity_VSIbar_desc_max + ; check if out-of-range + movff xC+0,divB + movlw .22 + cpfsgt divB + bra TFT_velocity_VSIbar_desc_draw + +TFT_velocity_VSIbar_desc_max: + movlw .22 + movff WREG,divB + +TFT_velocity_VSIbar_desc_draw: + ; calculate top&height for the bar and mask + ; 1. Bar: top=(bar_top+63); height=divB + movlw dm_velobar_top+.1 + movff WREG,sub_a+0 + movlw .62 + addwf sub_a+0,1 + + movlw color_white + WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right + + movff sub_a+0,win_top + movff divB,win_height + movlw dm_velobar_width-.4 + movff WREG,win_width + movff WREG,win_bargraph + movlw dm_velobar_lft+.3 + movff WREG,win_leftx2 + movlw color_green + call TFT_set_color + call TFT_box + + ;clear the rest + movlw .22 + cpfslt divB + return ; divB !< 22 - the graph uses the full bar, no need to clear + + ; 2. Mask: top=(bar_top+63+divB); height=(23-divB) + movlw .24 + movff WREG,sub_a+0 + clrf sub_a+1 + movff divB,sub_b+0 + clrf sub_b+1 + call subU16 ; sub_c = sub_a - sub_b + + movlw dm_velobar_top + movff WREG,sub_a+0 + movlw .61 + addwf sub_a+0,1 + movff divB,WREG + addwf sub_a+0,1 + + movff sub_a+0,win_top + movff sub_c+0,win_height + movlw dm_velobar_width + movff WREG,win_width + movff WREG,win_bargraph + movlw dm_velobar_lft+.1 + movff WREG,win_leftx2 + movlw color_black + call TFT_set_color + call TFT_box return -TFT_display_VSIbar_clr: ; clears the ascend part of hte bar - WIN_BOX_BLACK dm_velobar_top+.1,dm_velobar_top+.59,dm_velobar_lft+.1,dm_velobar_rgt-.1 - movlw color_blue - WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right +TFT_velocity_VSIbar_clr: ; clears the ascend part of the bar + WIN_BOX_BLACK dm_velobar_top+.1,dm_velobar_top+.63,dm_velobar_lft+.1,dm_velobar_rgt-.1 + if dm_offset == 0 + movlw color_dark_red + WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right + endif return -TFT_display_velocity_ntr: ; velocity under treshold - call TFT_display_velocity_clear +TFT_velocity_VSIbar_desc_clr: ; clears the descend part of the bar + WIN_BOX_BLACK dm_velobar_top+.61,dm_velobar_bot-.1,dm_velobar_lft+.1,dm_velobar_rgt-.1 + if dm_offset == 0 + movlw color_dark_red + WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right + endif + return + +TFT_velocity_ntr: ; velocity under treshold + call TFT_velocity_clear ; use another logic when descending - btfss neg_flag - bra TFT_dispay_VSIbar_desc - movlw .7 - movwf xC+0 - movlw .6 - movwf xC+1 - movlw .1 - movwf xC+2 - movlw .0 - movwf xC+3 - call TFT_display_VSIbar - return - - global TFT_display_velocity_clear -TFT_display_velocity_clear: + btfss neg_flag_velocity + bra TFT_velocity_VSIbar_desc + bra TFT_velocity_VSIbar + + global TFT_velocity_clear +TFT_velocity_clear: btfss display_velocity ; Velocity was not displayed, do not delete return bcf display_velocity ; Velocity was displayed, delete velocity now @@ -1115,7 +1237,11 @@ btfsc divemode_menu ; Is the dive mode menu shown? return ; Yes, return rcall TFT_clear_decoarea ; Clear Dekostop and Dekosum - call TFT_divemask_color + if dm_offset != 0 + call TFT_divemask_color + else + call TFT_attention_color + endif WIN_STD dm_ndl_text_column, dm_ndl_text_row STRCPY_TEXT_PRINT tNDL ; NDL call TFT_standard_color @@ -1164,7 +1290,11 @@ TFT_display_deko_mask: rcall TFT_clear_decoarea WIN_STD dm_tts_text_column, dm_tts_text_row - call TFT_divemask_color + if dm_offset != 0 + call TFT_divemask_color + else + call TFT_attention_color + endif STRCPY_TEXT_PRINT tTTS ; TTS call TFT_standard_color bcf show_safety_stop ; Clear safety stop flag @@ -1983,6 +2113,8 @@ return ; No call TFT_warning_set_window_com else + btfsc divemode_menu ; Is the dive mode menu shown? + return ; Yes, return call TFT_standard_color WIN_SMALL dm_ftts_value_column, dm_ftts_value_row endif