Mercurial > public > hwos_code
diff src/tft_outputs.asm @ 623:c40025d8e750
3.03 beta released
author | heinrichsweikamp |
---|---|
date | Mon, 03 Jun 2019 14:01:48 +0200 |
parents | 1ad0531e9078 |
children | cd58f7fc86db |
line wrap: on
line diff
--- a/src/tft_outputs.asm Wed Apr 10 10:51:07 2019 +0200 +++ b/src/tft_outputs.asm Mon Jun 03 14:01:48 2019 +0200 @@ -1,8 +1,8 @@ ;============================================================================= ; -; File tft_outputs.asm REFACTORED VERSION V2.99f +; File tft_outputs.asm next combined generation V3.03.4 ; -; Startup subroutines +; high-level Display Outputs ; ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. ;============================================================================= @@ -13,12 +13,10 @@ #include "shared_definitions.h" ; mailbox from/to p2_deco.c #include "tft.inc" #include "start.inc" -#include "wait.inc" #include "strings.inc" #include "convert.inc" #include "varargs.inc" #include "math.inc" -#include "isr.inc" #include "eeprom_rs232.inc" #include "adc_lightsensor.inc" #include "surfmode.inc" @@ -30,40 +28,92 @@ #include "colorschemes.inc" #include "calibrate.inc" #include "gaslist.inc" - - IFDEF _rx_functions #include "rx_ops.inc" - ENDIF + + +;---- external Functions ----------------------------------------------------- extern aa_wordprocessor extern get_first_gas_to_WREG - extern get_first_dil_to_WREG + + +;---- external Texts --------------------------------------------------------- extern tFirmware extern tSerial extern tTotalDives extern tBatteryV extern tUptime - extern tCalX,tCalY,tCalZ extern tPPO2MIN - extern tPPO2MINCC extern tPPO2Max extern tPPO2DECO + extern tbar + + IFDEF _ccr_pscr + extern tPPO2MINCC + ENDIF IFDEF _rx_functions extern tFirmware_rx ENDIF + IFDEF _compass + extern tCalX,tCalY,tCalZ + ENDIF + + +tft_out CODE + ;============================================================================= -tft_out CODE + global TFT_debug_output +TFT_debug_output: + ifndef _debug_output + return + else + btfsc alt_layout_active ; alternative layout active? + return ; YES - abort + +; WIN_TINY .100,.30 ; surface mode: fits under the textual logo in the upper right corner +; WIN_TINY .35, .0 ; dive mode: fits to the right side of the depth label + WIN_TINY .0, .0 ; dive mode: overwrites depth label + call TFT_standard_color + lfsr FSR2,buffer + + ; deco engine scheduling performance + MOVII int_O_profiling_overrun,mpr ; runtime +/- versus target + btfss mpr+1,7 + bra TFT_debug_output_1 + bcf mpr+1,7 + PUTC "-" + bra TFT_debug_output_2 +TFT_debug_output_1: + PUTC " " +TFT_debug_output_2: + output_16_3 + PUTC "." + MOVII int_O_profiling_overrun_max,mpr ; max runtime + output_16_3 + PUTC "." + movff char_O_profiling_overrun_phase,WREG ; calculation phase causing the max runtime + output_hex + PUTC "." + movff char_O_profiling_runs_norm,mpr ; runs/cycle normal plan + output_99 + PUTC "." + movff char_O_profiling_runs_alt,mpr ; runs/cycle alternative plan + output_99 + STRCAT_PRINT "" + return + endif + ;============================================================================= global TFT_divemask_color TFT_divemask_color: movlw color_green - btfsc divemode ; in divemode? + btfsc divemode ; in dive mode? rcall TFT_divemask_color_dive bra TFT_standard_color0 @@ -100,8 +150,8 @@ TFT_attention_color_dive: retlw color_yellow - global TFT_warnings_color ; important things with immediate need to react upon -TFT_warnings_color: + global TFT_warning_color ; important things with immediate need to react upon +TFT_warning_color: movlw color_red bra TFT_standard_color0 TFT_warnings_color_dive: @@ -111,7 +161,7 @@ global TFT_disabled_color TFT_disabled_color: movlw color_lightblue - btfsc divemode ; in divemode? + btfsc divemode ; in dive mode? rcall TFT_disabled_color_dive ; YES bra TFT_standard_color0 TFT_disabled_color_dive: @@ -129,7 +179,7 @@ global TFT_standard_color TFT_standard_color: setf WREG ; default white - btfsc divemode ; in divemode? + btfsc divemode ; in dive mode? rcall TFT_standard_color_dive ;bra TFT_standard_color0 TFT_standard_color0: @@ -140,12 +190,12 @@ movff opt_dive_color_scheme,WREG ; 0-3 incf WREG dcfsnz WREG - retlw color_scheme_divemode_std1 ;0 + retlw color_scheme_divemode_std1 ; 0 dcfsnz WREG - retlw color_scheme_divemode_std2 ;1 + retlw color_scheme_divemode_std2 ; 1 dcfsnz WREG - retlw color_scheme_divemode_std3 ;2 - retlw color_scheme_divemode_std4 ;3 + retlw color_scheme_divemode_std3 ; 2 + retlw color_scheme_divemode_std4 ; 3 global TFT_color_code_tank_pres_sac @@ -166,7 +216,7 @@ bra TFT_color_code_tank_pres_3 ; NO bcf hi,int_warning_flag ; YES - clear warning flag bcf hi,int_attention_flag ; - clear attention flag (it may be set) - bra TFT_warnings_color ; - set to warning color and return + bra TFT_warning_color ; - set to warning color and return TFT_color_code_tank_pres_3: btfss hi,int_attention_flag ; is the attention flag set? bra TFT_memo_color ; NO - set to memo color and return @@ -175,68 +225,63 @@ global TFT_color_code_gaslist -TFT_color_code_gaslist: ; color-code current row in gaslist (%O2 in hi) according to current amb_pressure +TFT_color_code_gaslist: ; color-code current row in gaslist (%O2 in hi) according to current absolute pressure ; Check very high ppO2 manually - movff amb_press_10+0,xA+0 - movff amb_press_10+1,xA+1 + MOVII pressure_abs_10,xA movff hi,xB+0 clrf xB+1 - call mult16x16 ; hi * p_amb/10 + call mult16x16 ; hi * absolute pressure / 10 ; Check if ppO2 > 6.55 bar - tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2 > 6.55 bar ? - bra TFT_warnings_color ; YES - warn in warning color + tstfsz xC+2 ; char_I_O2_ratio * absolute pressure / 10 > 65536, i.e. ppO2 > 6.55 bar ? + bra TFT_warning_color ; YES - warn in warning color ; Check if ppO2 > 3.30 bar btfsc xC+1,7 - bra TFT_warnings_color ; YES - warn in warning color + bra TFT_warning_color ; YES - warn in warning color ; Check for low ppO2 - movff xC+0,sub_a+0 - movff xC+1,sub_a+1 + MOVII xC,sub_a movff char_I_ppO2_min,WREG mullw d'100' ; char_I_ppO2_min*100 - movff PRODL,sub_b+0 - movff PRODH,sub_b+1 - call subU16 + MOVII PRODL,sub_b + call cmpU16 ; compare (sub_a - sub_b) btfsc neg_flag ; lower than ppO2 min? - bra TFT_warnings_color ; YES - set warning color and return + bra TFT_warning_color ; YES - set warning color and return ; Check for high ppO2 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector btfsc WREG,deco_flag ; are we in deco? bra TFT_color_code_gaslist_deco ; YES - check against ppO2 max deco only ; NO - check against ppO2 max travel/normal and deco ; Check for ppO2 max travel/normal - movff char_I_ppO2_max,WREG ; ppo2 max for travel/normal - mullw d'100' ; char_I_ppO2_max*100 - movff PRODL,sub_b+0 - movff PRODH,sub_b+1 - infsnz sub_b+0,F ; add 1 mbar to avoid warning on equal - incf sub_b+1,F - call subU16 ; sub_c = sub_a - sub_b + movff char_I_ppO2_max_work,WREG ; ppo2 max during working phase + mullw d'100' ; char_I_ppO2_max_work*100 + MOVII PRODL,sub_b + INCI sub_b ; add 1 mbar to avoid warning on equal + call cmpU16 ; compare (sub_a - sub_b) btfss neg_flag ; higher than ppO2 max travel/deco? rcall TFT_attention_color ; YES - set attention color ; Check for ppO2 max deco TFT_color_code_gaslist_deco: movff char_I_ppO2_max_deco,WREG ; ppo2 max for deco - mullw d'100' ; char_I_ppO2_max_deco*100 - movff PRODL,sub_b+0 - movff PRODH,sub_b+1 - infsnz sub_b+0,F ; add 1 mbar to avoid warning on equal - incf sub_b+1,F - call subU16 ; sub_c = sub_a - sub_b + mullw d'100' ; char_I_ppO2_max_deco * 100 + MOVII PRODL,sub_b ; copy product to sub_b + INCI sub_b ; add 1 mbar to avoid warning on equal + call cmpU16 ; compare (sub_a - sub_b) btfss neg_flag ; higher than ppO2 max deco? - bra TFT_warnings_color ; YES - set warning color and return + bra TFT_warning_color ; YES - set warning color and return return ; NO - keep current color TFT_color_code_ceiling: ; color-code the ceiling depth btfsc hi,char_invalid_flag ; is the invalid flag set? (bit 7 here) - bra TFT_color_code_ceiling_1 ; YES - SAFE_2BYTE_COPY rel_pressure,sub_a ; NO - movff lo,sub_b+0 - movff hi,sub_b+1 - call subU16 ; sub_c = sub_a - sub_b : sub_c = rel_pressure [mbar] - int_O_ceiling [mbar] - btfsc neg_flag ; is ceiling > current depth? - bra TFT_warnings_color ; YES - set to warning color and return - bra TFT_memo_color ; NO - set to memo color and return + bra TFT_color_code_ceiling_1 ; YES - set disabled color + MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure to sub_a + MOVII mpr,sub_b ; - get ceiling to sub_b + call cmpU16 ; - sub_a - sub_b = relative pressure [mbar] - int_O_ceiling [mbar] + btfss neg_flag ; - is current depth < ceiling (too shallow) ? + bra TFT_memo_color ; NO - set to memo color and return + movff char_O_deco_warnings,WREG ; YES - bank-safe copy of deco warnings + btfsc WREG,outside_warning ; - are we currently outside of the ZH-L16 model? + bra TFT_warning_color ; YES - set to warnings color and return + bra TFT_attention_color ; NO - set to attention color and return TFT_color_code_ceiling_1: bcf hi,char_invalid_flag ; clear the invalid flag (bit 7 here) bra TFT_disabled_color ; set to disabled color and return @@ -249,44 +294,49 @@ movff char_O_deco_gas+0,WREG ; get flag for invalid deco data btfsc WREG,char_invalid_flag ; is the invalid flag set? bra TFT_disabled_color ; YES - set to disabled color and return - movff char_O_first_deco_depth,WREG; NO - get stop depth in m into WREG - subwf curr_depth,W ; - compute current depth - stop depth + movff char_O_deco_depth,WREG ; NO - get depth of first stop in meters into WREG + subwf depth_meter,W ; - compute current depth - stop depth btfsc STATUS,C ; - result negative? - bra TFT_memo_color ; NO - set to memo color and return - movff int_O_ceiling+0,sub_b+0 ; YES - get ceiling depth in mbar - movff int_O_ceiling+1,sub_b+1 ; - ... + bra TFT_color_code_stop_1 ; NO - not shallower than stop depth, check for ascent advice + MOVII int_O_ceiling,sub_b ; YES - get ceiling depth in mbar btfsc sub_b+1,char_invalid_flag ; - is the invalid flag set? (bit 7 here) - bra TFT_warnings_color ; YES - set to warning color and return - SAFE_2BYTE_COPY rel_pressure,sub_a ; NO - get current depth in mbar - call subU16 ; - sub_c = sub_a - sub_b : sub_c = rel_pressure [cm] - int_O_ceiling [mbar => cm] + bra TFT_warning_color ; YES - set to warning color and return + MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure + call cmpU16 ; - sub_a - sub_b = relative pressure - int_O_ceiling btfsc neg_flag ; - is ceiling > current depth? - bra TFT_warnings_color ; YES - set to warning color and return + bra TFT_warning_color ; YES - set to warning color and return bra TFT_attention_color ; NO - set to attention color and return - - -TFT_color_code_depth: ; with actual depth as rel_pressure in [mbar] in hi:lo and threshold depth_warn_mbar [mbar] - movff lo,sub_a+0 - movff hi,sub_a+1 - movlw LOW depth_warn_mbar - movwf sub_b+0 - movlw HIGH depth_warn_mbar - movwf sub_b+1 - call subU16 ; sub_c = sub_a - sub_b - TSTOSS opt_modwarning ; 0=standard, 1=blink - bra TFT_color_code_depth_std - btfss neg_flag - bra TFT_color_code_depth_warn ; set to warning color - bra TFT_color_code_depth_ppO2 ; check depth against MOD and return... -TFT_color_code_depth_std: - btfss neg_flag - bra TFT_warnings_color ; set to warning color and return - bra TFT_memo_color ; set to memo color and return... -TFT_color_code_depth_ppO2: - movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR - decfsz WREG,F ; are we in CCR mode? +TFT_color_code_stop_1: + movff char_O_deco_info,WREG ; get deco info vector + btfss WREG,deco_flag ; in deco mode? + bra TFT_memo_color ; NO - set to memo color and return + movff char_O_deco_depth,WREG ; YES - get depth of first stop in meters into WREG + incf WREG,W ; - compute stop depth + 1 meter + subwf depth_meter,W ; - compute current depth - (stop depth + 1 meter) + btfss STATUS,C ; - result negative? + bra TFT_memo_color ; YES - within 1 meter of stop depth + bsf win_invert ; NO - deeper that 1 meter below stop depth, give ascent advice + bra TFT_advice_color ; - ... and return + + +TFT_color_code_depth: + TSTOSS opt_modwarning ; MOD warning switched on? + bra TFT_color_code_depth_no_mod ; NO + btfsc depth_limit_exceeded ; YES - deeper than depth limit? + bra TFT_color_code_depth_warn ; YES - set to warning color + bra TFT_color_code_depth_mod ; NO - check depth against MOD and return... +TFT_color_code_depth_no_mod: + btfsc depth_limit_exceeded ; NO - deeper than depth limit? + bra TFT_warning_color ; YES - set to warning color and return + bra TFT_memo_color ; NO - set to memo color and return... +TFT_color_code_depth_mod: + IFDEF _ccr_pscr + movff opt_dive_mode,WREG ; get deco mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR + decfsz WREG,F ; in CCR mode? bra TFT_color_code_depth_no_ccr ; NO - continue checking for ppO2 - btfss FLAG_bailout_mode ; YES - check if in bailout + btfss bailout_mode ; YES - check if in bailout bra TFT_color_code_depth_outside; NO - continue checking for outside ZHL16 model + ENDIF TFT_color_code_depth_no_ccr: movff int_O_breathed_ppO2+1,WREG ; get upper byte of currently breathed ppO2 btfsc WREG,int_warning_flag ; is the warning flag set? @@ -294,18 +344,18 @@ TFT_color_code_depth_outside: movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings btfsc WREG,outside_warning ; are we currently outside of the ZH-L16 model? - bra TFT_color_code_depth_warn ; YES - btfsc WREG,outside_attention ; are we near to outside of the ZH-L16 model? - bra TFT_color_code_depth_att ; YES - bcf blinking_depth_warning ; NO - terminate warning blinking - bcf blinking_depth_attention ; - terminate attention blinking - bra TFT_memo_color ; - set memo color and return + bra TFT_color_code_depth_warn ; YES - activate depth warning + bcf depth_warning ; NO - terminate depth warning + btfsc WREG,outside_attention ; - are we near to outside of the ZH-L16 model? + bra TFT_color_code_depth_att ; YES - activate depth attention + bcf depth_attention ; NO - terminate depth attention + bra TFT_memo_color ; - select memo color and return TFT_color_code_depth_warn: - bsf blinking_depth_warning ; activate warning blinking - bra TFT_warnings_color ; set to warning color and return... + bsf depth_warning ; activate depth warning + bra TFT_warning_color ; select warning color and return... TFT_color_code_depth_att: - bsf blinking_depth_attention ; activate attention blinking - bra TFT_attention_color ; set to attention color and return... + bsf depth_attention ; activate depth attention + bra TFT_attention_color ; select attention color and return... global TFT_color_code_cns @@ -321,7 +371,7 @@ bra TFT_color_code_cns_2 ; NO bcf hi,int_warning_flag ; YES - clear warning flag bcf hi,int_attention_flag ; - clear attention flag (it may be set) - bra TFT_warnings_color ; - set to warning color and return + bra TFT_warning_color ; - set to warning color and return TFT_color_code_cns_2: btfss hi,int_attention_flag ; is the attention flag set? bra TFT_memo_color ; NO - set to memo color and return @@ -330,12 +380,12 @@ TFT_color_code_gf: - ; with int_O_gradient_factor, the upper byte is solely used for the flags + ; with int_O_lead_supersat, the upper byte is solely used for the flags ; and not for the value, thus there is no need to clear the flags btfsc hi,int_invalid_flag ; is the invalid flag set? bra TFT_disabled_color ; YES - set to disabled color and return btfsc hi,int_warning_flag ; NO - is the warning flag set? - bra TFT_warnings_color ; YES - set to warning color and return + bra TFT_warning_color ; YES - set to warning color and return btfsc hi,int_attention_flag ; NO - is the attention flag set? bra TFT_attention_color ; YES - set to attention color and return bra TFT_memo_color ; NO - set to memo color and return @@ -348,7 +398,7 @@ bcf hi,int_attention_flag ; clear attention flag (it may be set) bcf hi,int_high_flag ; clear high warning flag (it may be set) bcf hi,int_low_flag ; clear low warning flag (it may be set) - bra TFT_warnings_color ; warn in warning color + bra TFT_warning_color ; warn in warning color TFT_color_code_ppo2_1: btfss hi,int_attention_flag ; is the attention flag set? bra TFT_color_code_ppo2_2 ; NO @@ -361,6 +411,9 @@ bcf hi,int_low_flag ; clear low warning flag (it may be set) bra TFT_memo_color ; set to memo color and return +;============================================================================= + + IFDEF _ccr_pscr TFT_color_code_ppo2_hud: ; color-code ppO2 values (ppO2 in --:lo [cbar]) by its value movff char_O_deco_info,WREG ; get the deco info vector @@ -369,16 +422,16 @@ movff char_I_ppO2_max_deco,WREG ; YES - load deco value as threshold bra TFT_color_code_ppo2_hud_b TFT_color_code_ppo2_hud_a: - movff char_I_ppO2_max,WREG ; ppO2 max while not in deco + movff char_I_ppO2_max_work,WREG ; ppO2 max while in working phase TFT_color_code_ppo2_hud_b: cpfsgt lo ; lo > threshold? bra TFT_color_code_ppo2_hud1 ; NO - continue with checking for ppO2 low - bra TFT_warnings_color ; YES - set warning color and return + bra TFT_warning_color ; YES - set warning color and return TFT_color_code_ppo2_hud1: movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR decfsz WREG,F ; now: 0=CC, 1=Gauge, 2=Apnea, 3=PSCR bra TFT_color_code_ppo2_hud_nocc; not CCR... - btfsc FLAG_bailout_mode + btfsc bailout_mode bra TFT_color_code_ppo2_hud_nocc; is bailout, hence not loop mode... movff char_I_ppO2_min_loop,WREG ; ppO2 min loop mode color coding bra TFT_color_code_ppo2_hud_cont @@ -387,13 +440,16 @@ TFT_color_code_ppo2_hud_cont: cpfslt lo ; lo < char_I_ppO2_min? bra TFT_memo_color ; NO - set memo color and return... - bra TFT_warnings_color ; Yes - set warning color and return - + bra TFT_warning_color ; Yes - set warning color and return + + ENDIF ; _ccr_pscr + +;============================================================================= TFT_color_code_battery: ; color-code the battery display, with battery percent in lo movlw color_code_battery_low ; get warning threshold cpfsgt lo ; is battery percent < threshold? - bra TFT_warnings_color ; YES - set to warning color and return + bra TFT_warning_color ; YES - set to warning color and return bra TFT_memo_color ; NO - set to memo color and return @@ -485,7 +541,7 @@ global TFT_show_color_schemes TFT_show_color_schemes: ; update the color schemes - bsf divemode ; put in divemode + bsf divemode ; switch to dive mode call TFT_divemask_color WIN_TINY .12,.40 STRCAT_TEXT_PRINT tDepth @@ -499,36 +555,26 @@ ; Depth demo call TFT_memo_color WIN_MEDIUM .3,.54 - movlw LOW .5172 - movwf lo - movlw HIGH .5172 - movwf hi + MOVLI .5172,mpr bsf leftbind bsf ignore_digit4 output_16 ; full meters in big font bcf leftbind STRCAT_PRINT "" ; display full meters WIN_SMALL .25,.66 - movlw LOW .5172 - movwf lo - movlw HIGH .5172 - movwf hi + MOVLI .5172,mpr PUTC "." movlw d'4' movwf ignore_digits bsf ignore_digit5 ; (flag will be cleared by output_16) output_16dp d'0' ; .1m in SMALL font STRCAT_PRINT "" ; display decimeters - WIN_FONT FT_SMALL ; Max. Depth demo WIN_MEDIUM .64,.54 bsf ignore_digit4 ; no 0.1m bsf leftbind - movlw LOW .6349 - movwf lo - movlw HIGH .6349 - movwf hi + MOVLI .6349,mpr output_16 STRCAT_PRINT "" ; display full meters bcf leftbind @@ -539,16 +585,14 @@ movwf ignore_digits bsf ignore_digit5 ; (flag will be cleared by output_16) bsf leftbind - movlw LOW .6349 - movwf lo - movlw HIGH .6349 - movwf hi + MOVLI .6349,mpr output_16dp d'0' STRCAT_PRINT "" ; display decimeters bcf leftbind ; Divetime demo - movff mins,lo + SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time + movff rtc_latched_mins,lo clrf hi WIN_MEDIUM .103, .54 output_16_3 ; limit to 999 and display only (0-999) @@ -556,89 +600,78 @@ WIN_SMALL .139, .66 ; left position for two sec figures PUTC ':' bsf leftbind - movff secs,lo + movff rtc_latched_secs,lo output_99x bcf leftbind STRCAT_PRINT "" ; show seconds in small font - bcf divemode ; don't stay in divemode + bcf divemode ; terminate dive mode again return - global TFT_divemode_mask -TFT_divemode_mask: ; displays mask in divemode - bcf FLAG_TFT_divemode_mask - call TFT_divemask_color - WIN_TINY dm_mask_depth_column,dm_mask_depth_row - STRCAT_TEXT_PRINT tDepth - WIN_TINY dm_mask_maxdepth_column_nvsi,dm_mask_maxdepth_row - TSTOSS opt_vsigraph ; graphical VSI bar enabled? - bra TFT_divemode_mask_1 ; NO - WIN_TINY dm_mask_maxdepth_column,dm_mask_maxdepth_row ; YES - adopt position -TFT_divemode_mask_1: - btfsc FLAG_apnoe_mode ; in Apnea mode? - bra TFT_divemode_mask_2 ; YES - draw max depth - TSTOSS opt_2ndDepthDisp ; draw avg depth? - bra TFT_divemode_mask_2 ; NO - draw max depth - STRCAT_TEXT_PRINT tAvgDepth ; YES - bra TFT_divemode_mask_3 -TFT_divemode_mask_2: - STRCAT_TEXT_PRINT tMaxDepth -TFT_divemode_mask_3: - WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row - STRCAT_TEXT_PRINT tDivetime - bra TFT_standard_color ; and return... - - global TFT_divemode_mask_alternative -TFT_divemode_mask_alternative: ; alt. mask for divemode - bcf FLAG_TFT_divemode_mask_alt - call TFT_divemask_color - WIN_TINY dm_mask_depth_column,dm_mask_depth_row - STRCAT_TEXT_PRINT tDepth - WIN_TINY dm_mask_divetime_column-.30,dm_mask_divetime_row - STRCAT_TEXT_PRINT tDivetime - bra TFT_standard_color ; and 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 - bra TFT_standard_color ; NO - set standard color and return + global TFT_show_divemode_mask +TFT_show_divemode_mask: ; display mask in dive mode + call TFT_divemask_color ; set color + + ; depth + WIN_TINY dm_mask_depth_column,dm_mask_depth_row ; position for "Depth" + btfss alt_layout_active ; alternative layout active? + bra TFT_divemode_mask_depth_text ; NO + WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; YES - alternative position for "Depth" +TFT_divemode_mask_depth_text: + STRCAT_TEXT_PRINT tDepth ; print "Depth" + + ; avg or max depth + btfsc alt_layout_active ; alternative layout active? + bra TFT_divemode_mask_avg_max_alt ; YES + + WIN_TINY dm_mask_maxdepth_col_nvsi,dm_mask_maxdepth_row ; default position for "max.Depth"/"avg.Depth" + TSTOSS opt_vsigraph ; graphical VSI bar enabled? + bra TFT_divemode_mask_max_avg_pos ; NO - keep position + WIN_TINY dm_mask_maxdepth_col,dm_mask_maxdepth_row ; YES - adopt position +TFT_divemode_mask_max_avg_pos: + btfsc FLAG_apnoe_mode ; in apnea mode? + bra TFT_divemode_mask_max_text ; YES - always draw max depth + TSTOSS opt_2ndDepthDisp ; NO - shall draw avg depth instead of max depth? + bra TFT_divemode_mask_max_text ; NO - print "max.Depth" + STRCAT_TEXT_PRINT tAvgDepth ; YES - print "avg.Depth" + bra TFT_divemode_mask_time_pos ; - continue with dive time +TFT_divemode_mask_max_text: + STRCAT_TEXT_PRINT tMaxDepth ; print "max.Depth" + bra TFT_divemode_mask_time_pos ; continue with dive time +TFT_divemode_mask_avg_max_alt: + btfss FLAG_gauge_mode ; in gauge mode? + bra TFT_divemode_mask_time_pos ; NO - continue with dive time + WIN_TINY dm_gauge_max_depth_text_col,dm_gauge_max_depth_text_row ; YES - set position + STRCAT_TEXT_PRINT tMaxDepth ; - print "max.Depth" + WIN_TINY dm_gauge_avg_depth_text_col,dm_gauge_avg_depth_text_row ; - set position + STRCAT_TEXT_PRINT tDiveTotalAvg ; - print "Total Avg" + ;bra TFT_divemode_mask_time_pos ; - continue with dive time + + ; dive time +TFT_divemode_mask_time_pos: + WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row ; position for "Divetime" +TFT_divemode_mask_time_text: + STRCAT_TEXT_PRINT tDivetime ; print "Divetime" + btfss FLAG_apnoe_mode ; in apnea mode? + bra TFT_standard_color ; NO - done + WIN_TINY dm_total_apnoe_text_col,dm_total_apnoe_text_row; YES - set position + STRCPY_TEXT_PRINT tApnoeTotal ; - print "Total" + bra TFT_standard_color ; - done ;========================================================================= - global TFT_display_velocity -TFT_display_velocity: ; with divA+0 = m/min, neg_flag_velocity: ascend=1, descend=0 - bcf STATUS,C - movlw velocity_display_threshold_1; lowest threshold for display vertical velocity - subwf divA+0,W - btfss STATUS,C - bra TFT_velocity_clear ; lower then threshold. Clear text and graph (If active) - - ; We have something to display - bsf display_velocity ; set flag - ; check if descending: no warning color if descending - rcall TFT_memo_color - btfsc neg_flag_velocity ; ignore for descent - rcall TFT_velocity_set_color ; set color for text and set threshold for graph - - rcall TFT_velocity_disp ; show the text - + global TFT_velocity_show +TFT_velocity_show: + rcall TFT_memo_color ; set default color + btfsc neg_flag_velocity ; descending? + rcall TFT_velocity_set_color ; NO - set color for text dependent on speed and set threshold for VSI graph + rcall TFT_velocity_num ; show the numerical VSI TSTOSS opt_vsigraph ; graphical VSI bar enabled? - bra TFT_display_velocity_done ; NO - - btfsc alternative_divelayout ; alternative layout? - bra TFT_display_velocity_done ; YES - no graph! (no room when divetime minutes is three digits) - - btfsc neg_flag_velocity ; ignore for descent - rcall TFT_velocity_graph ; show the graph - btfss neg_flag_velocity ; ignore for descent - rcall TFT_velocity_clear_graph ; clear the graph for descent - -TFT_display_velocity_done: - bra TFT_standard_color ; and return! + bra TFT_standard_color ; NO - done + btfsc neg_flag_velocity ; YES - in ascent? + bra TFT_velocity_graph_show ; YES - show the graph + bra TFT_velocity_graph_clear_1 ; NO - clear the graph TFT_speed_table: ; use a depth-dependent ascent rate warning @@ -648,7 +681,7 @@ ; 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) - ; <xx m, warning speed, attention speed, unused + ; < depth (m), warning speed, attention speed, unused DB .6,.7,.5,.0 DB .12,.8,.6,.0 DB .18,.9,.7,.0 @@ -661,7 +694,8 @@ DB .50,.19,.15,.0 DB .200,.20,.15,.0 -TFT_velocity_set_color: ; Set color based on speed table or use static thresholds, with divA+0 = m/min +TFT_velocity_set_color: ; set color based on speed table or use static thresholds, with divA+0 = m/min + bsf aux_flag ; for alternative layout: default is to show numerical VSI ; check if old/new ascend logic is used TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic bra TFT_velocity_set_color_static ; static ascend rate limit @@ -674,84 +708,120 @@ movlw UPPER (TFT_speed_table-.3) movwf TBLPTRU -TFT_velocity_set_color_skip: +TFT_velocity_set_color_next: TBLRD*+ ; 3 dummy reads TBLRD*+ TBLRD*+ TBLRD*+ ; get speed threshold - movf curr_depth,W ; current depth in m + movf depth_meter,W ; current depth in m cpfsgt TABLAT ; threshold > current depth ? - bra TFT_velocity_set_color_skip ; NO - loop + bra TFT_velocity_set_color_next ; NO - try next TBLRD*+ ; get warning speed threshold - movf TABLAT,W + movf TABLAT,W ; ... movwf divA+1 ; copy for graph routine - cpfslt divA+0 ; smaller then actual value (in m/min)? - bra TFT_warnings_color ; set Warning color (And return) + cpfslt divA+0 ; actual vertical speed smaller than warning threshold? + bra TFT_warning_color ; NO - set warning color (and return) TBLRD*+ ; get attention speed threshold - movf TABLAT,W - cpfslt divA+0 ; smaller then actual value (in m/min)? + movf TABLAT,W ; ... + cpfslt divA+0 ; actual vertical speed smaller than attention threshold? bra TFT_attention_color ; NO - set attention color and return - bra TFT_memo_color ; YES - set memo color and return + bcf aux_flag ; YES - don't show in alternative layout + bra TFT_memo_color ; - set memo color and return TFT_velocity_set_color_static: - movlw color_code_velocity_warn_high ; in m/min + movlw color_code_velocity_warn_high ; threshold for warning in m/min movwf divA+1 ; copy for graph routine - cpfslt divA+0 ; smaller then actual value (in m/min)? - bra TFT_warnings_color ; set Warning color (And return) - movlw color_code_velocity_attn_high ; in m/min - cpfslt divA+0 ; smaller then actual value (in m/min)? + cpfslt divA+0 ; actual vertical speed smaller than warning threshold? + bra TFT_warning_color ; NO - set warning color (and return) + movlw color_code_velocity_attn_high ; threshold for attention in m/min + cpfslt divA+0 ; actual vertical speed smaller than attention threshold? bra TFT_attention_color ; NO - set attention color and return - bra TFT_memo_color ; YES - set memo color and return - -TFT_velocity_disp: - WIN_SMALL dm_velocity_text_column, dm_velocity_text_row - TSTOSS opt_units ; 0=Meters, 1=Feets - bra TFT_velocity_metric -;TFT_velocity_imperial: + bcf aux_flag ; YES - don't show in alternative layout + bra TFT_memo_color ; - set memo color and return + +TFT_velocity_num: + btfsc alt_layout_active ; in alternative layout? + bra TFT_velocity_num_alt ; YES + ; NO - set position + WIN_SMALL dm_velocity_text_col_norm, dm_velocity_text_row_norm +TFT_velocity_num_com: + bsf velocity_active_num ; set numerical velocity as shown + TSTOSS opt_units ; - 0=meter, 1=feet + bra TFT_velocity_num_metric ; 0 - meter + ;bra TFT_velocity_num_imperial ; 1 - feet + +TFT_velocity_num_imperial: movff divA+0,WREG ; divA+0 = m/min - mullw .100 ; PRODL:PRODH = mbar/min - movff PRODL,lo - movff PRODH,hi + mullw .100 ; PROD = mbar/min + MOVII PRODL,mpr ; copy to hi:lo call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet - movlw '-' - btfsc neg_flag_velocity - movlw '+' - movwf POSTINC2 - bsf leftbind - output_16 - bcf leftbind - STRCAT_TEXT_PRINT tVelImperial ; unit switch - return - -TFT_velocity_metric: + tstfsz hi ; > 255 ? + setf lo ; YES - set lo to 255 + movlw '-' ; load coding for minus sign + btfsc neg_flag_velocity ; ascending? + movlw '+' ; YES - replace with coding for plus sign + movwf POSTINC2 ; put sign into output buffer + output_99 ; print rate + STRCAT_TEXT tVelImperial ; print unit + bra TFT_velocity_num_finish ; do finishing tasks + +TFT_velocity_num_metric: movff divA+0,lo ; divA+0 = m/min - movlw '-' - btfsc neg_flag_velocity - movlw '+' - movwf POSTINC2 - output_99 - STRCAT_TEXT_PRINT tVelMetric ; unit switch - return - -TFT_velocity_graph: ; divA+0 = m/min - ; divA+0 holding the ascend speed in m/min - movff divA+0,hi ; copy - WIN_BOX_BLACK dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right -> outer frame - rcall TFT_divemask_color_dive ; color -> WREG - WIN_FRAME_COLOR dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;inner frame - rcall TFT_divemask_color_dive ; color -> WREG - WIN_FRAME_COLOR dm_velobar_top+.10, dm_velobar_bot-.10, dm_velobar_lft, dm_velobar_rgt ;inner frame - rcall TFT_divemask_color_dive ; color -> WREG - WIN_FRAME_COLOR dm_velobar_top+.20, dm_velobar_bot-.20, dm_velobar_lft, dm_velobar_rgt ;inner frame - rcall TFT_divemask_color_dive ; color -> WREG - WIN_FRAME_COLOR dm_velobar_top+.30, dm_velobar_bot-.30, dm_velobar_lft, dm_velobar_rgt ;inner frame - + movlw '-' ; load coding for minus sign + btfsc neg_flag_velocity ; ascending? + movlw '+' ; YES - replace with coding for plus sign + movwf POSTINC2 ; put sign into output buffer + output_99 ; print rate + STRCAT_TEXT tVelMetric ; print unit + ;bra TFT_velocity_num_finish ; do finishing tasks + +TFT_velocity_num_finish: + btfss alt_layout_active ; in alternative layout? + bra TFT_velocity_num_finish_1 ; NO + movlw "'" ; load encoding of minute sign + movff WREG,buffer+4 ; put it after m (meter) / f (feet) + clrf WREG ; load string terminator + movff WREG,buffer+5 ; terminate string after minute sign +TFT_velocity_num_finish_1: + STRCAT_PRINT "" ; finalize output + bcf win_invert ; end inverse printing + return ; done + +TFT_velocity_num_alt: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + btfss neg_flag_velocity ; NO - in ascent? + bcf aux_flag ; NO - clear aux flag + btfsc aux_flag ; - above attention or warning threshold? + bsf win_invert ; YES - print inverse + ; - set position + WIN_SMALL dm_velocity_text_col_alt, dm_velocity_text_row_alt + bra TFT_velocity_num_com ; - continue with common part + + +TFT_velocity_graph_show: ; with speed in divA+0 (m/min) + btfsc alt_layout_active ; in alternative layout? + bra TFT_standard_color ; YES - done (not implemented) + + btfsc velocity_active_vsi ; was the graphical VSI shown before? + bra TFT_velocity_graph_1 ; YES - no need to redraw the framework box + bsf velocity_active_vsi ; NO - remember it is shown as of now + ; - draw the framework box + rcall TFT_divemask_color_dive ; - color -> WREG + WIN_FRAME_COLOR dm_velocity_graph_top+.00, dm_velocity_graph_bot-.00, dm_velocity_graph_lft, dm_velocity_graph_rgt + rcall TFT_divemask_color_dive ; - color -> WREG + WIN_FRAME_COLOR dm_velocity_graph_top+.10, dm_velocity_graph_bot-.10, dm_velocity_graph_lft, dm_velocity_graph_rgt + rcall TFT_divemask_color_dive ; - color -> WREG + WIN_FRAME_COLOR dm_velocity_graph_top+.20, dm_velocity_graph_bot-.20, dm_velocity_graph_lft, dm_velocity_graph_rgt + rcall TFT_divemask_color_dive ; - color -> WREG + WIN_FRAME_COLOR dm_velocity_graph_top+.30, dm_velocity_graph_bot-.30, dm_velocity_graph_lft, dm_velocity_graph_rgt + +TFT_velocity_graph_1: + movff divA+0,hi ; copy ascend speed (in m/min) to hi movff divA+1,xA+0 ; m/min for warning level (upper two blocks) clrf xA+1 - movlw .5 - movwf xB+0 ; threshold for color warning (5 color normal + 2 color warning) - clrf xB+1 + MOVLI .5,xB ; threshold for color warning (5 color normal + 2 color warning) call div16x16 ; xC = xA / xB with xA as remainder ; xC+0 holds step size in m/min (e.g. =3 for 15m/min warning threshold) movff hi,xA+0 ; velocity in m/min @@ -759,383 +829,402 @@ movff xC+0,xB+0 ; step size clrf xB+1 call div16x16 ; xC = xA / xB with xA as remainder - ; xC+0 now holds amount of segments to show - movff hi,divA+0 ; copy back for numeric output - movlw d'7' - cpfslt xC+0 - bra DISP_graph_vel_7 - movlw d'6' - cpfslt xC+0 - bra DISP_graph_vel_6 - movlw d'5' - cpfslt xC+0 - bra DISP_graph_vel_5 - movlw d'4' - cpfslt xC+0 - bra DISP_graph_vel_4 - movlw d'3' - cpfslt xC+0 - bra DISP_graph_vel_3 - movlw d'2' - cpfslt xC+0 - bra DISP_graph_vel_2 - movlw d'1' - cpfslt xC+0 - bra DISP_graph_vel_1 - bra DISP_graph_vel_0 ; should not happen... - -DISP_graph_vel_7: + + movff xC+0,lo ; copy amount of segments to show to lo + incf lo,F + dcfsnz lo,F + bra DISP_graph_vel_0_fill + dcfsnz lo,F + bra DISP_graph_vel_1_fill + dcfsnz lo,F + bra DISP_graph_vel_2_fill + dcfsnz lo,F + bra DISP_graph_vel_3_fill + dcfsnz lo,F + bra DISP_graph_vel_4_fill + dcfsnz lo,F + bra DISP_graph_vel_5_fill + dcfsnz lo,F + bra DISP_graph_vel_6_fill + ;bra DISP_graph_vel_7_fill + +DISP_graph_vel_7_fill: + rcall TFT_warnings_color_dive ; color -> WREG + WIN_BOX_COLOR dm_velocity_graph_top+.2, dm_velocity_graph_top+.8, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_6_fill: rcall TFT_warnings_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.2, dm_velobar_top+.8, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_6: - rcall TFT_warnings_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.12, dm_velobar_top+.18, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_5: + WIN_BOX_COLOR dm_velocity_graph_top+.12, dm_velocity_graph_top+.18, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_5_fill: rcall TFT_attention_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.22, dm_velobar_top+.28, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_4: + WIN_BOX_COLOR dm_velocity_graph_top+.22, dm_velocity_graph_top+.28, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_4_fill: + rcall TFT_standard_color_dive ; color -> WREG + WIN_BOX_COLOR dm_velocity_graph_top+.32, dm_velocity_graph_top+.38, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_3_fill: + rcall TFT_standard_color_dive ; color -> WREG + WIN_BOX_COLOR dm_velocity_graph_top+.42, dm_velocity_graph_top+.48, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_2_fill: + rcall TFT_standard_color_dive ; color -> WREG + WIN_BOX_COLOR dm_velocity_graph_top+.52, dm_velocity_graph_top+.58, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_1_fill: rcall TFT_standard_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.32, dm_velobar_top+.38, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_3: - rcall TFT_standard_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.42, dm_velobar_top+.48, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_2: - rcall TFT_standard_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.52, dm_velobar_top+.58, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_1: - rcall TFT_standard_color_dive ; color -> WREG - WIN_BOX_COLOR dm_velobar_top+.62, dm_velobar_top+.68, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right -DISP_graph_vel_0: - return ; done + WIN_BOX_COLOR dm_velocity_graph_top+.62, dm_velocity_graph_top+.68, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_0_fill: + + movff xC+0,lo ; copy amount of segments to show to lo + incf lo,F + dcfsnz lo,F + bra DISP_graph_vel_0_clear + dcfsnz lo,F + bra DISP_graph_vel_1_clear + dcfsnz lo,F + bra DISP_graph_vel_2_clear + dcfsnz lo,F + bra DISP_graph_vel_3_clear + dcfsnz lo,F + bra DISP_graph_vel_4_clear + dcfsnz lo,F + bra DISP_graph_vel_5_clear + dcfsnz lo,F + bra DISP_graph_vel_6_clear + bra DISP_graph_vel_7_clear + +DISP_graph_vel_0_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.62, dm_velocity_graph_top+.68, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_1_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.52, dm_velocity_graph_top+.58, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_2_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.42, dm_velocity_graph_top+.48, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_3_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.32, dm_velocity_graph_top+.38, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_4_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.22, dm_velocity_graph_top+.28, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_5_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.12, dm_velocity_graph_top+.18, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_6_clear: + WIN_BOX_BLACK dm_velocity_graph_top+.2, dm_velocity_graph_top+.8, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right +DISP_graph_vel_7_clear: + bra TFT_standard_color ; done 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 - ; Clear Text - WIN_BOX_BLACK dm_velocity_text_row, dm_velocity_text_bot, dm_velocity_text_column, dm_velocity_text_rgt ; top, bottom, left, right - - TSTOSS opt_vsigraph ; graphical VSI bar enabled? - return ; NO - no graph to clear + btfss velocity_active_num ; was the numerical VSI shown in last cycle? + bra TFT_velocity_clear_graph ; NO - no need to clear it, continue with graphical VSI +TFT_velocity_clear_num_1: + bcf velocity_active_num ; YES - clear flag + btfsc alt_layout_active ; - in alternative layout? + bra TFT_velocity_clear_num_alt ; YES + ;bra TFT_velocity_clear_num_norm ; NO + +TFT_velocity_clear_num_norm: ; clear normal numerical area + WIN_BOX_BLACK dm_velocity_text_row_norm, dm_velocity_text_bot_norm, dm_velocity_text_col_norm, dm_velocity_text_rgt_norm ; top, bottom, left, right + bra TFT_velocity_clear_graph ; continue with graphical VSI + +TFT_velocity_clear_num_alt: ; clear alternative numerical area + btfsc dive_main_menu ; is the dive mode menu shown? + bra TFT_velocity_clear_graph ; YES - skip + ; NO - clear area + WIN_BOX_BLACK dm_velocity_text_row_alt, dm_velocity_text_bot_alt, dm_velocity_text_col_alt, dm_velocity_text_rgt_alt ; top, bottom, left, right + ;bra TFT_velocity_clear_graph ; continue with graphical VSI + TFT_velocity_clear_graph: - ; Clear Graph - WIN_BOX_BLACK dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ; top, bottom, left, right - return + btfss velocity_active_vsi ; was the graphical VSI shown in last cycle? + bra TFT_standard_color ; NO - no need to clear it, done +TFT_velocity_graph_clear_1: + bcf velocity_active_vsi ; YES - clear flag + btfsc alt_layout_active ; - in alternative layout? + bra TFT_standard_color ; YES - not implemented + ;bra TFT_velocity_clear_graph_alt ; YES - code provision for future implementation + ;bra TFT_velocity_clear_graph_norm ; NO + +TFT_velocity_clear_graph_norm ; clear normal graph area + WIN_BOX_BLACK dm_velocity_graph_top, dm_velocity_graph_bot, dm_velocity_graph_lft, dm_velocity_graph_rgt ; top, bottom, left, right + bra TFT_standard_color ; done ;========================================================================= - global TFT_clear_decoarea -TFT_clear_decoarea: - WIN_BOX_BLACK dm_decostop_1st_stop_row, .239, dm_decostop_1st_stop_column, .159 ; top, bottom, left, right - return - - global TFT_clear_divemode_menu TFT_clear_divemode_menu: WIN_BOX_BLACK dm_menu_row-.2, dm_menu_lower, dm_menu_left, dm_menu_right ; top, bottom, left, right - starts 2 pixel higher to completely wipe away the temperature display return - global TFT_display_ndl_mask -TFT_display_ndl_mask: - bcf FLAG_TFT_display_ndl_mask - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - btfsc FLAG_gauge_mode ; in gauge mode? - return ; YES - return - call TFT_clear_decoarea ; NO - clear stop depth and TTS - call TFT_divemask_color + global TFT_clear_deco_data +TFT_clear_deco_data: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + ; NO - clear deco data area (alternative stop depth makes upper-left most corner) + WIN_BOX_BLACK dm_decostop_row_alt_depth, dm_3rdrow_bot, dm_decostop_col_alt_depth, dm_3rdrow_rgt ; top, bottom, left, right + return ; - done + + + global TFT_show_ndl_mask +TFT_show_ndl_mask: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + call TFT_divemask_color ; NO - set text color + ; - set position WIN_STD dm_ndl_text_column, dm_ndl_text_row - STRCPY_TEXT_PRINT tNDL ; NDL - bra TFT_standard_color ; and return... - - - global TFT_display_tts -TFT_display_tts: - bcf FLAG_TFT_display_tts - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - call TFT_memo_color ; NO - set memo color - movff int_O_ascenttime+0,lo ; - TTS - movff int_O_ascenttime+1,hi ; - on 16 bits - btfss hi,int_invalid_flag ; - is the invalid flag set? - bra TFT_display_tts_1 ; - NO - bcf hi,int_invalid_flag ; - YES - clear flag - call TFT_disabled_color ; - switch to disabled color -TFT_display_tts_1: - WIN_MEDIUM dm_tts_value_column, dm_tts_value_row - output_16_3 ; display only 0...999 - STRCAT_PRINT "'" - return - - - global TFT_display_ndl -TFT_display_ndl: - bcf FLAG_TFT_display_ndl - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - WIN_MEDIUM dm_ndl_value_column, dm_ndl_value_row - call TFT_memo_color - movff char_O_nullzeit,lo ; get NDL from C-code - output_8 - STRCAT_PRINT "'" - return - - - global TFT_big_deco_alt ; the big deco -TFT_big_deco_alt: - bcf FLAG_TFT_big_deco_alt - - btfss decostop_active ; deco stop shown? - bra TFT_big_deco_ndl_alt ; NO - show NDL - - ; Deco - bcf FLAG_TFT_display_deko - call TFT_divemask_color - WIN_STD .70,.165 - STRCPY_TEXT_PRINT tTTS ; TTS - rcall TFT_memo_color - - ; TTS - WIN_LARGE .97,.170 - movff int_O_ascenttime+0,lo ; get the TTS - movff int_O_ascenttime+1,hi ; - btfss hi,int_invalid_flag ; is the invalid flag set? - bra TFT_display_tts_alt_1 ; NO - bcf hi,int_invalid_flag ; YES - clear flag - call TFT_disabled_color ; - switch to disabled color -TFT_display_tts_alt_1: - output_16_3 ; display only 0...999 - STRCAT_PRINT "" - - ; 1st Stop - call TFT_divemask_color - WIN_STD .25,dm_customview_row - STRCPY_TEXT_PRINT tDiveSafetyStop ; "Stop" - - WIN_LARGE .60,.95 - call TFT_color_code_stop ; color-code output - movff char_O_first_deco_depth,lo ; stop depth in m - rcall TFT_display_deko_output_depth ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft) - STRCAT_PRINT "" - - ; m or ft after the stop depth - WIN_MEDIUM .100,.118 - TSTOSS opt_units ; 0=m, 1=ft - bra TFT_display_tts_alt_1_metric - STRCAT_TEXT_PRINT tFeets1 - bra TFT_display_tts_alt_1_com -TFT_display_tts_alt_1_metric: - STRCAT_TEXT_PRINT tMeters -TFT_display_tts_alt_1_com: - WIN_LARGE .117,.95 - movff char_O_first_deco_time,lo ; get stop time in minutes + STRCPY_TEXT_PRINT tNDL ; - print "NDL" + bra TFT_standard_color ; - done + + + global TFT_show_tts +TFT_show_tts: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + call TFT_memo_color ; NO - default to memo color + MOVII int_O_TTS_norm,mpr ; - get the TTS + btfsc hi,int_invalid_flag ; - is the invalid flag set? + call TFT_disabled_color ; YES - use disabled color + bcf hi,int_invalid_flag ; - eventually clear the invalid flag + btfss alt_layout_active ; - in alternative layout? + bra TFT_display_tts_999x ; NO + MOVII mpr, sub_a ; YES - copy TTS to sub_a + MOVLI .100,sub_b ; - load 100 into sub_b + call cmpU16 ; - sub_a - sub_b = TTS - 100 + btfss neg_flag ; - TTS >= 100 ? + bra TFT_display_tts_999 ; YES + ;bra TFT_display_tts_99 ; NO + +TFT_display_tts_99: + btfsc tts_greater_99 ; was TTS > 99 mins last time? + rcall TFT_display_tts_clear ; YES - clear remains from TTS > 99 + ; set output position + WIN_MEDIUM dm_tts_value_col_99, dm_tts_value_row + output_99 ; display 0...99 + STRCAT_PRINT "'" ; print "'" + bcf tts_greater_99 ; last TTS shown was <= 99 mins + bra TFT_standard_color ; done + +TFT_display_tts_999: ; set position + WIN_MEDIUM dm_tts_value_col_999, dm_tts_value_row + output_16_3 ; display 0...999 + STRCAT_PRINT "" ; finalize output (no "'" here - not enough space available) + bsf tts_greater_99 ; last TTS shown was > 99 mins + bra TFT_standard_color ; done + +TFT_display_tts_999x: ; set position + WIN_MEDIUM dm_tts_value_col_999x, dm_tts_value_row + output_16_3 ; display 0...999 + STRCAT_PRINT "'" ; print "'" + bra TFT_standard_color ; done + +TFT_display_tts_clear: ; clear remains from TTS > 99 + WIN_BOX_BLACK dm_tts_value_row, dm_tts_value_row+.31, dm_tts_value_col_999, dm_tts_value_col_99 ; top, bottom, left, right + call TFT_memo_color ; restore default memo color + movff int_O_TTS_norm+1,WREG ; get the high byte of the TTS + btfsc WREG,int_invalid_flag ; is the invalid flag set? + call TFT_disabled_color ; YES - restore disabled color + return ; done + + + global TFT_show_ndl +TFT_show_ndl: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + movff char_O_NDL_norm,lo ; NO - get NDL time in normal plan + btfsc alt_layout_active ; - alternative layout active? + bra TFT_show_ndl_alt ; YES - use alternative layout + ;bra TFT_show_ndl_norm ; NO - use normal layout + +TFT_show_ndl_norm: ; set position + WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm + call TFT_memo_color ; set color + output_8 ; display 0...240 + STRCAT_PRINT "'" ; print minutes symbol + bra TFT_standard_color ; done + +TFT_show_ndl_alt: + btfsc safety_stop_active ; is the safety stop active? + bra TFT_show_ndl_alt_safety ; YES + ; clear potential remains from NDL normal and set position + WIN_BOX_BLACK dm_ndl_value_row_norm, dm_3rdrow_bot, dm_ndl_value_col_norm, dm_ndl_value_col_alt ; top, bottom, left, right + WIN_LARGE dm_ndl_value_col_alt, dm_ndl_value_row_alt + call TFT_memo_color ; set color + output_99 ; display 0...99 + STRCAT_PRINT "" ; finalize output + bra TFT_standard_color ; done + +TFT_show_ndl_alt_safety: + WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm + call TFT_memo_color ; set color + PUTC " " ; fill first digit position + output_99 ; display 0...99 + STRCAT_PRINT "'" ; print minutes symbol + goto TFT_standard_color ; done + + + global TFT_divemode_sign_show +TFT_divemode_sign_show: + btfsc alt_layout_active ; alternative layout active? + bra TFT_divemode_sign_show_alt ; YES + ;bra TFT_divemode_sign_show_norm ; NO + +TFT_divemode_sign_show_norm: + WIN_TOP dm_sign_row_norm ; set row position + WIN_LEFT dm_sign_col_norm ; set column position + bra TFT_divemode_sign_show_com ; continue with common part + +TFT_divemode_sign_show_alt: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + btfsc sign_shown ; NO - sign already shown? + bra TFT_divemode_sign_show_alt_1; YES - no need to clear area again + btfsc bailout_mode ; NO - in bailout? + bra TFT_divemode_sign_show_alt_1; YES - no need to clear the area + ; NO - eventually clear area from "bar" label and loop mode + WIN_BOX_BLACK dm_active_dil_row, dm_3rdrow_bot, dm_active_sp_label_col, dm_sign_rgt_alt ; top, bottom, left, right +TFT_divemode_sign_show_alt_1: + WIN_TOP dm_sign_row_alt ; - set row position + WIN_LEFT dm_sign_col_alt ; - set column position + ;bra TFT_divemode_sign_show_com ; - continue with common part + +TFT_divemode_sign_show_com: + bsf sign_shown ; flag that the advice/attention/warning sign is shown + btfsc message_warning ; do we have a warning? + bra TFT_divemode_sign_show_warn ; YES - show warning sign + btfsc message_attention ; NO - do we have an attention? + bra TFT_divemode_sign_show_att ; YES - show attention sign + btfsc message_advice ; NO - do we have an advice message? + bra TFT_divemode_sign_show_adv ; YES - show advice sign + return ; NO - false alarm + + +TFT_divemode_sign_color_warn: ; custom colors table for dive_warning2 icon - warning + db .4, 0 ; #colors, spare + dw 0x0000 ; color 0x00: outside black + dw 0xff80 ; color 0x01: triangle yellow + dw 0xff80 ; color 0x02: exclamation mark yellow + dw 0xf800 ; color 0x03: inside red + +TFT_divemode_sign_color_adv: ; custom colors table for dive_warning2 icon - advice + db .4, 0 ; #colors, spare + dw 0x0000 ; color 0x00: outside black + dw 0xffff ; color 0x01: triangle white + dw 0xffff ; color 0x02: exclamation mark white + dw 0x0780 ; color 0x03: inside green + +TFT_divemode_sign_show_warn: + TFT_WRITE_PROM_IMAGE_CUST_COLOR TFT_divemode_sign_color_warn; set custom colors for warning + TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign + return ; done + +TFT_divemode_sign_show_att: + TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign (with default colors) + return ; done + +TFT_divemode_sign_show_adv: + TFT_WRITE_PROM_IMAGE_CUST_COLOR TFT_divemode_sign_color_adv ; set custom colors for advice + TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign + return ; done + + + global TFT_divemode_sign_clear +TFT_divemode_sign_clear: + btfss sign_shown ; is the advice/attention/warning sign shown? + return ; NO - done + bcf sign_shown ; YES - clear advice/attention/warning sign area and its flag + btfsc alt_layout_active ; - alternative layout active? + bra TFT_divemode_sign_clear_alt ; - YES + ;bra TFT_divemode_sign_clear_norm; - NO + +TFT_divemode_sign_clear_norm: + WIN_BOX_BLACK dm_sign_row_norm, dm_sign_bot_norm, dm_sign_col_norm, dm_sign_rgt_norm ; top, bottom, left, right + return ; done + +TFT_divemode_sign_clear_alt: + WIN_BOX_BLACK dm_sign_row_alt, dm_sign_bot_alt, dm_sign_col_alt, dm_sign_rgt_alt ; top, bottom, left, right + return ; done + + + global TFT_show_deco_mask +TFT_show_deco_mask: + bcf safety_stop_active ; flag safety stop is not shown any more TODO: needed? + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + btfsc alt_layout_active ; NO - in alternative layout? + bra TFT_show_deco_mask_alt ; YES + ;bra TFT_show_deco_mask_norm ; NO + +TFT_show_deco_mask_norm: + WIN_STD dm_tts_text_col_norm, dm_tts_text_row_norm ; set text position + bra TFT_show_deco_mask_common ; continue with common part + +TFT_show_deco_mask_alt: + WIN_TINY dm_tts_text_col_alt, dm_tts_text_row_alt ; set text position + STRCPY "Stop/" ; print "Stop/" + ;bra TFT_show_deco_mask_common ; continue with common part + +TFT_show_deco_mask_common: + call TFT_divemask_color ; set text color + STRCAT_TEXT_PRINT tTTS ; print "TTS" + bra TFT_display_exit_1 ; done + + +TFT_display_deco_depth: ; output depth (stored in lo) to POSTINC2 with "m" or "ft" + TSTOSS opt_units ; get unit (0=m, 1=ft) + bra TFT_display_deco_depth_m ; 0 - meter + ;bra TFT_display_deco_depth_ft ; 1 - feet + +TFT_display_deco_depth_ft: + call convert_meter_to_feet ; convert value in lo from meters to feet + output_16_3 ; output stop depth (000-999) + return ; done + +TFT_display_deco_depth_m: + output_99 ; output stop depth + STRCAT_TEXT tMeters ; print unit + return ; done + + + global TFT_show_deco +TFT_show_deco: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + + call TFT_color_code_stop ; color-code output + movff char_O_deco_depth,lo ; get depth of first stop in meters + + TSTOSC opt_units ; get unit (0=m, 1=ft) + bra TFT_show_deco_norm ; 1 - ft can only be displayed in normal layout due to space required for 3 digit depth + + btfsc alt_layout_active ; in alternative layout? + bra TFT_show_deco_alt ; YES + ;bra TFT_show_deco_norm ; NO + +TFT_show_deco_norm: ; set position for combined depth and time + WIN_MEDIUM dm_decostop_col_norm, dm_decostop_row_norm + rcall TFT_display_deco_depth ; output depth (stored in lo) to POSTINC2 with "m" or "ft" + PUTC ' ' ; put a space char between depth and time + bra TFT_display_deco_common ; continue with common part + +TFT_show_deco_alt: ; set position for depth + WIN_LARGE dm_decostop_col_alt_depth, dm_decostop_row_alt_depth + output_99 ; output stop depth (2 digits, usable for meters only) + STRCAT_PRINT "" ; finalize output + ; set position for time + WIN_MEDIUM dm_decostop_col_alt_time, dm_decostop_row_alt_time + call TFT_memo_color ; back to memo color + bcf win_invert ; back to non-inverted output + ;bra TFT_display_deco_common ; continue with common part + +TFT_display_deco_common: + movff char_O_deco_time,lo ; get stop time of the first stop in minutes tstfsz lo ; stop time = 0 ? - bra TFT_display_tts_alt_2 ; NO - print time - STRCAT_PRINT ".." ; YES - special treatment - bra TFT_display_tts_alt_exit -TFT_display_tts_alt_2: - bcf leftbind - output_99 - STRCAT_PRINT "" -TFT_display_tts_alt_exit: + bra TFT_display_deco_1 ; NO - print minutes + STRCAT_PRINT " .." ; YES - special treatment + bra TFT_display_deco_2 ; - continue with common part +TFT_display_deco_1: + output_99 ; print minutes +TFT_display_deco_2: + STRCAT_PRINT "'" ; add minutes sign + bcf win_invert ; back to non-inverted output +TFT_display_exit_1: goto TFT_standard_color ; and return... -TFT_big_deco_ndl_alt: - ; NDL - bcf FLAG_TFT_display_ndl - bcf decostop_active ; clear flag (again) - btfsc FLAG_gauge_mode ; in gauge mode? - bra TFT_big_deco_ndl_alt_1 ; YES - skip NDL - call TFT_divemask_color - WIN_STD .70,.165 - STRCPY_TEXT_PRINT tNDL ; NDL - call TFT_memo_color - WIN_LARGE .97,.170 - movff char_O_nullzeit,lo ; get NDL from C-code - output_8 - STRCAT_PRINT "" -TFT_big_deco_ndl_alt_1: - btfsc FLAG_TFT_show_safety_stop - bra TFT_show_safety_stop_alt ; show safety stop (and return) - ; Clear any safety stop or Decostop -TFT_no_more_safety_stop_alt: - WIN_BOX_BLACK dm_customview_row, .150, .0, .159 ; top, bottom, left, right - WIN_BOX_BLACK dm_customview_row, .164, .60, .159 ; top, bottom, left, right - return - -TFT_show_safety_stop_alt: - bcf FLAG_TFT_show_safety_stop - tstfsz safety_stop_countdown ; countdown at zero? - bra TFT_show_safety_stop_alt2 ; NO - show stop - bcf show_safety_stop ; clear flag - btfss safety_stop_active ; displayed? - return ; NO - bcf safety_stop_active ; YES - clear flag - bra TFT_no_more_safety_stop_alt ; - clear stop and return - -TFT_show_safety_stop_alt2: - bsf safety_stop_active ; set flag - decf safety_stop_countdown,F ; reduce countdown - - call TFT_divemask_color - WIN_STD .50,dm_customview_row - STRCPY_TEXT_PRINT tDiveSafetyStop - call TFT_attention_color ; show in yellow - WIN_LARGE .90,.95 - movff safety_stop_countdown,lo - clrf hi - call convert_time ; converts hi:lo in seconds to mins (up:hi) and seconds (lo) - movf hi,W - movff lo,hi - movwf lo ; exchange lo and hi - bsf leftbind - output_8 - STRCAT_PRINT "" - WIN_MEDIUM .112,.120 - STRCAT_PRINT ":" - WIN_LARGE .117,.95 - bcf leftbind - movff hi,lo - output_99x - STRCAT_PRINT "" - WIN_FONT FT_SMALL - bra TFT_display_exit_1 - - - global TFT_divemode_warning -TFT_divemode_warning: - bcf FLAG_TFT_divemode_warning ; clear job flag - bsf dive_warning_displayed ; set advice/attention/warning sign is shown flag - WIN_TOP dm_warning_icon_row - WIN_LEFT dm_warning_icon_column - btfsc message_warning ; do we have a warning? - bra TFT_divemode_warning_1 ; YES - show warning sign - btfsc message_attention ; NO - do we have an attention? - bra TFT_divemode_warning_2 ; YES - show attention sign - bra TFT_divemode_warning_3 ; NO to both - must be an advice then - -dive_warning2_warning_colors: ; custom colors table for dive_warning2 icon - warning - db .4, 0 ; #colors, spare - dw 0x0000 ; color 0x00: outside black - dw 0xff80 ; color 0x01: triangle yellow - dw 0xff80 ; color 0x02: excl.mark yellow - dw 0xf800 ; color 0x03: inside red - -dive_warning2_advice_colors: ; custom colors table for dive_warning2 icon - advice - db .4, 0 ; #colors, spare - dw 0x0000 ; color 0x00: outside black - dw 0xffff ; color 0x01: triangle white - dw 0xffff ; color 0x02: excl.mark white - dw 0x0780 ; color 0x03: inside green - -TFT_divemode_warning_1: - TFT_WRITE_PROM_IMAGE_CUST_COLOR dive_warning2_warning_colors - TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; output warning sign (with custom colors) - return -TFT_divemode_warning_2: - TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; output attention sign (with default colors) - return -TFT_divemode_warning_3: - TFT_WRITE_PROM_IMAGE_CUST_COLOR dive_warning2_advice_colors - TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; output advice sign (with custom colors) - return - - - global TFT_divemode_warning_clear -TFT_divemode_warning_clear: - bcf FLAG_TFT_divemode_warning_clear ; clear job flag - btfss dive_warning_displayed ; advice/attention/warning sign is shown? - return ; NO - bcf dive_warning_displayed ; YES - clear advice/attention/warning sign and its flag - WIN_BOX_BLACK dm_warning_icon_row, dm_warning_icon_bot, dm_warning_icon_column, dm_warning_icon_rgt ; top, bottom, left, right - return - - - global TFT_display_deko_mask -TFT_display_deko_mask: - bcf FLAG_TFT_display_deko_mask - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - rcall TFT_clear_decoarea ; clear decostop and decosum (and NDL in this case) - WIN_STD dm_tts_text_column, dm_tts_text_row - call TFT_divemask_color - STRCPY_TEXT_PRINT tTTS ; TTS - bcf show_safety_stop ; clear safety stop flag - bra TFT_display_exit_1 - - -TFT_display_deko_output_depth: ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft) - TSTOSS opt_units ; 0=m, 1=ft - bra TFT_display_deko_output_metric -;TFT_display_deko_output_imperial: - movf lo,W ; lo = m - mullw .100 ; PRODL:PRODH = mbar - movff PRODL,lo - movff PRODH,hi - ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops... - movff lo,xA+0 - movff hi,xA+1 - movlw LOW d'334' ; 334feet/100m - movwf xB+0 - movlw HIGH d'334' - movwf xB+1 - call mult16x16 ; xA*xB=xC (lo:hi * 328) - movlw d'50' ; round up - addwf xC+0,F - movlw 0 - addwfc xC+1,F - addwfc xC+2,F - addwfc xC+3,F - movlw d'100' - movwf xB+0 - clrf xB+1 - call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder - movff xC+0,lo - movff xC+1,hi ; restore lo and hi with updated value - bcf leftbind - btfsc alternative_divelayout - bsf leftbind ; left for alternative layout mode - bsf ignore_digit4 ; only full feet - output_16 - btfsc alternative_divelayout - return ; not for alternative layout mode - STRCAT_TEXT tFeets1 - return - -TFT_display_deko_output_metric: - output_99 - btfsc alternative_divelayout - return ; not for alternative layout mode - STRCAT_TEXT tMeters - PUTC ' ' - return - - - global TFT_display_deko -TFT_display_deko: - bcf FLAG_TFT_display_deko - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - WIN_MEDIUM dm_decostop_1st_stop_column, dm_decostop_1st_stop_row - call TFT_color_code_stop ; color-code output - movff char_O_first_deco_depth,lo ; stop depth in m - rcall TFT_display_deko_output_depth ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft) - movff char_O_first_deco_time,lo ; get stop time in minutes - tstfsz lo ; stop time = 0 ? - bra TFT_display_deko_1 ; NO - print minutes - STRCAT_PRINT " ..'" ; YES - special treatment - bra TFT_display_exit_1 -TFT_display_deko_1: - output_99 ; output lo - STRCAT_PRINT "'" -TFT_display_exit_1 - goto TFT_standard_color ; and return... - - global TFT_decoplan_mask ; mask for deco plan TFT_decoplan_mask: call TFT_divemask_color @@ -1143,6 +1232,7 @@ STRCPY_TEXT_PRINT tDiveDecoplan return + global TFT_decoplan ; data for deco plan - stops 2 - 7 (stop 1 is shown in the main screen) TFT_decoplan: lfsr FSR0,char_O_deco_depth ; load base address of stops table @@ -1191,7 +1281,8 @@ STRCPY_PRINT " " ; wipe screen position by printing 7 spaces return TFT_decoplan_helper_3: - rcall TFT_display_deko_output_depth ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft) + rcall TFT_display_deco_depth ; output depth (stored in lo) to POSTINC2 + PUTC " " ; put a space char between depth and time movlw NUM_STOPS ; offset between arrays holding depths and durations movff PLUSW0,lo ; get duration of the current stop output_99 ; output duration to POSTINC2 @@ -1200,61 +1291,60 @@ return - global TFT_clear_safety_stop -TFT_clear_safety_stop: - bcf FLAG_TFT_clear_safety_stop ; clear flag - WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, .159 ; top, bottom, left, right - return - - global TFT_show_safety_stop -TFT_show_safety_stop: - bcf FLAG_TFT_show_safety_stop - tstfsz safety_stop_countdown ; countdown at zero? - bra TFT_show_safety_stop2 ; NO - show stop - bcf show_safety_stop ; clear flag - btfss safety_stop_active ; displayed? - return ; NO - bcf safety_stop_active ; clear flag - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - bra TFT_clear_safety_stop ; NO - clear stop and return... -TFT_show_safety_stop2: - bsf safety_stop_active ; set flag - decf safety_stop_countdown,F ; reduce countdown - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return - ;btfsc menuview - ;bra TFT_show_safety_stop3 ; no room when menuview=1... - call TFT_divemask_color + global TFT_safety_stop_clear +TFT_safety_stop_clear: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + btfss safety_stop_active ; NO - is the safety stop shown? + return ; NO - done, nothing to do + ; YES - clear safety stop area + WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, dm_safetystop_rgt ; top, bottom, left, right + bcf safety_stop_active ; - safety stop not shown any more + return ; - done + + + global TFT_safety_stop_show +TFT_safety_stop_show: + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort + btfsc safety_stop_active ; NO - is the safety stop shown already? + bra TFT_safety_stop_show_time ; YES - just update the time + ; NO - clear area that may be polluted by alternative NDL + WIN_BOX_BLACK dm_safetystop_row, dm_tts_value_row, dm_ndl_value_col_alt, dm_safetystop_rgt ; top, bottom, left, right + call TFT_divemask_color ; - set color for text + ; - set position for text + bsf safety_stop_active ; - flag safety stop is shown now WIN_STD dm_safetystop_text_column, dm_safetystop_text_row - STRCPY_TEXT_PRINT tDiveSafetyStop -TFT_show_safety_stop3: - call TFT_attention_color ; show in yellow - WIN_MEDIUM dm_safetystop_column, dm_safetystop_row - movff safety_stop_countdown,lo - clrf hi - call convert_time ; converts hi:lo in seconds to mins (up:hi) and seconds (lo) - movf hi,W - movff lo,hi - movwf lo ; exchange lo and hi - bsf leftbind - output_8 - bcf leftbind - PUTC ':' - movff hi,lo - output_99x - STRCAT_PRINT "" - WIN_FONT FT_SMALL - bra TFT_display_exit_1 + STRCPY_TEXT_PRINT tDiveSafetyStop ; - print "Stop" +TFT_safety_stop_show_time: + call TFT_attention_color ; set color for time + ; set position for time + WIN_MEDIUM dm_safetystop_column, dm_safetystop_row + movff safety_stop_countdown,lo ; get remaining time in seconds, low byte, from safety stop timer + clrf hi ; set remaining time in seconds, high byte, to zero + call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo) + movff lo,up ; save seconds in up + movff hi,lo ; move minutes to lo + bsf leftbind ; activate left-alignment + output_8 ; print minutes + bcf leftbind ; deactivate left-alignment + PUTC ':' ; print ":" + movff up,lo ; move seconds to lo + output_99x ; print seconds (2 digits with leading zero) + STRCAT_PRINT "" ; finalize output + bra TFT_display_exit_1 ; done global TFT_avr_stopwatch_mask ; mask for average depth and stopwatch TFT_avr_stopwatch_mask: call TFT_divemask_color + + IFNDEF _min_depth_option + WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth in main screen? bra TFT_avr_stopwatch_mask_1 ; NO - draw avg depth in custom view then - STRCAT_TEXT_PRINT tMaxDepth ; YES - draw max depth in custom view then + STRCPY_TEXT_PRINT tMaxDepth ; YES - draw max depth in custom view then bra TFT_avr_stopwatch_mask_2 TFT_avr_stopwatch_mask_1: STRCPY_TEXT_PRINT tDiveTotalAvg @@ -1265,27 +1355,39 @@ STRCPY_TEXT_PRINT tDiveStopAvg bra TFT_display_exit_1 + ELSE + + WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row + STRCPY_PRINT "Max.Depth" + WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row + STRCPY_PRINT "Avg.Depth" + WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row + STRCPY_PRINT "Min.Depth" + bra TFT_display_exit_1 + + ENDIF + global TFT_avr_stopwatch ; data for average depth and stopwatch TFT_avr_stopwatch: call TFT_memo_color bsf leftbind + IFNDEF _min_depth_option + ; total average depth or max depth WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row - TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth in main screen? - bra TFT_avr_stopwatch_01 ; NO - draw avg depth in custom view then - SAFE_2BYTE_COPY max_pressure,lo ; YES - draw max depth in custom view then + TSTOSS opt_2ndDepthDisp ; draw average depth instead of maximum depth in main screen? + bra TFT_avr_stopwatch_01 ; NO - draw average depth in custom view then + MOVII pressure_rel_max_cached,mpr ; YES - draw maximum depth in custom view then bra TFT_avr_stopwatch_02 TFT_avr_stopwatch_01: - movff avg_rel_pressure_total+0,lo - movff avg_rel_pressure_total+1,hi + MOVII pressure_rel_avg_total,mpr ; get total dive average depth into hi:lo TFT_avr_stopwatch_02: - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] TSTOSS opt_units ; 0=m, 1=ft bra TFT_update_avr_stopwatch1_metric ; 0 - metric - ;bra TFT_update_avr_stopwatch1_imp ; 1 - imperial -TFT_update_avr_stopwatch1_imp: +TFT_update_avr_stopwatch1_imp: ; 1 - imperial call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet output_16 ; yxz STRCAT " " ; wipe out remains from last output @@ -1303,13 +1405,11 @@ ; stopped average depth WIN_MEDIUM dm_custom_avr_stop_column3,dm_custom_avr_stop_row - movff avg_rel_pressure+0,lo - movff avg_rel_pressure+1,hi - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] + MOVII pressure_rel_avg_trip,mpr ; get the resettable average depth + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] TSTOSS opt_units ; 0=m, 1=ft bra TFT_update_avr_stopwatch2_metric ; 0 - metric - ;bra TFT_update_avr_stopwatch2_imp ; 1 - imperial -TFT_update_avr_stopwatch2_imp: +TFT_update_avr_stopwatch2_imp: ; 1 - imperial call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet output_16 ; yxz STRCAT " " ; wipe out remains from last output @@ -1323,15 +1423,48 @@ clrf WREG movff WREG,buffer+.4 ; limit string length to 4 = 3 digits + 1 half-size decimal dot TFT_update_avr_stopwatch3: + STRCAT_PRINT "" ; finalize output + + ELSE + + ; resettable maximum depth - needs ISR-safe copy! + WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row ; column 0 + call TFT_memo_color + SMOVII pressure_rel_max_trip,mpr + rcall TFT_avr_stopwatch_helper + + ; resettable average depth + WIN_MEDIUM dm_custom_avr_stop_column2-.1,dm_custom_avr_stop_row ; column 54 - 1 = 53 + call TFT_attention_color + MOVII pressure_rel_avg_trip,mpr + rcall TFT_avr_stopwatch_helper + + ; resettable minimum depth - needs ISR safe copy! + WIN_MEDIUM dm_custom_avr_stop_column3-.12,dm_custom_avr_stop_row ; column 118 - 12 = 106 + call TFT_memo_color + SMOVII pressure_rel_min_trip,mpr + rcall TFT_avr_stopwatch_helper + + ; done + bra TFT_display_exit_2 + +TFT_avr_stopwatch_helper: + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] + output_16dp .3 ; yxz.ab + PUTC " " ; wipe out remains from last output + clrf WREG + movff WREG,buffer+.5 ; limit string length to 5 = 4 digits + 1 half-size decimal dot STRCAT_PRINT "" - - ; stopped dive time + return + + ENDIF + + ; stopped dive time (will also be used by compass custom view) WIN_MEDIUM dm_custom_avr_stop_column2,dm_custom_avr_stop_row TFT_update_stopwatch: ; jump-in point for stopped dive time in compass custom view bsf leftbind ; print numbers without leading spaces - movff average_divesecs+0,lo ; average_divesecs is incremented outside ISR - movff average_divesecs+1,hi - call convert_time ; converts hi:lo in seconds to minutes (up:hi) and seconds (lo) + MOVII divesecs_avg_trip,mpr ; get the resettable dive time (stopwatch) + call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo) movlw .100 ; display layout will change if minutes become >= 100 cpfslt hi ; minutes < 100 ? bra TFT_update_stopwatch_2 ; NO - display hours:minutes @@ -1353,7 +1486,7 @@ TFT_update_stopwatch_2: movff hi,lo ; transfer minutes (low byte) to lo movff up,hi ; transfer minutes (high byte) to hi - call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) + call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) bra TFT_update_stopwatch_1 @@ -1365,7 +1498,7 @@ WIN_TINY dm_custom_cns3_column2, dm_custom_cns3_title_row btfsc FLAG_oc_mode ; in OC mode? bra TFT_CNS_mask_1 ; YES - print fTTS label - btfsc FLAG_bailout_mode ; in bailout? + btfsc bailout_mode ; in bailout? bra TFT_CNS_mask_1 ; YES - print fTTS label (label will be printed, but a fTTS will actually not be calculated) TSTOSS opt_calc_asc_gasvolume ; bailout volume calculation requested? bra TFT_CNS_mask_1 ; NO - print fTTS label @@ -1384,14 +1517,13 @@ bsf leftbind ; CNS at end of normal dive WIN_STD dm_custom_cns3_column1+.3,dm_custom_cns3_row - movff int_O_normal_CNS_fraction+0,lo - movff int_O_normal_CNS_fraction+1,hi + MOVII int_O_CNS_norm,mpr ; get CNS at end of dive in normal plan call TFT_color_code_cns output_16_3 ; output as xxx STRCAT_PRINT "% " ; fTTS / Bailout CNS, if enabled WIN_STD dm_custom_cns3_column2+.2,dm_custom_cns3_row - btfsc FLAG_bailout_mode ; in bailout? + btfsc bailout_mode ; in bailout? bra TFT_CNS_3 ; YES - show "---" TSTOSS opt_calc_asc_gasvolume ; NO - bailout volume calculation requested? bra TFT_CNS_1 ; NO - continue checking fTTS extra time @@ -1400,10 +1532,9 @@ TFT_CNS_1: ; not in bailout, no volume calculation, and/or in OC mode TSTOSS char_I_extra_time ; fTTS extra time configured? bra TFT_CNS_3 ; NO - show "---" -TFT_CNS_2: - movff int_O_alternate_CNS_fraction+0,lo ; YES - show CNS% - movff int_O_alternate_CNS_fraction+1,hi - call TFT_color_code_cns +TFT_CNS_2: ; YES - show CNS% + MOVII int_O_CNS_alt,mpr ; get CNS at end of dive in alternative plan + call TFT_color_code_cns ; color-code the CNS value output_16_3 ; output as xxx STRCAT_PRINT "% " bra TFT_CNS_4 @@ -1413,8 +1544,7 @@ TFT_CNS_4: ; current CNS WIN_STD dm_custom_cns3_column3+.3,dm_custom_cns3_row - movff int_O_CNS_fraction+0,lo - movff int_O_CNS_fraction+1,hi + MOVII int_O_CNS_current,mpr ; get current CNS call TFT_color_code_cns output_16_3 ; output as xxx STRCAT_PRINT "%" @@ -1423,6 +1553,10 @@ goto TFT_standard_color ; and return... +;============================================================================= + + IFDEF _external_sensor + global TFT_ppo2_sensors_mask ; mask for ppO2 sensors TFT_ppo2_sensors_mask: call TFT_divemask_color @@ -1465,12 +1599,12 @@ TFT_update_hud1b: ; sensor has a valid calibration WIN_MEDIUM dm_custom_hud_sensor1_column,dm_custom_hud_row - movff o2_ppo2_sensor1,lo ; load ppO2 value into transfer storage for output + movff sensor1_ppO2,lo ; load ppO2 value into transfer storage for output clrf hi ; btfsc use_O2_sensor1 ; in use? bra TFT_update_hud1d ; YES ; valid calibration, but not in use - tstfsz o2_ppo2_sensor1 ; sensor value = 0? + tstfsz lo ; sensor value = 0? bra TFT_update_hud1c ; no ; valid calibration, not in use and value = 0 call TFT_attention_color ; output in yellow @@ -1482,7 +1616,7 @@ TFT_update_hud1d: ; sensor has valid calibration and is in use call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo - btfsc voting_logic_sensor1 ; sensor value agrees with other sensor's values? + btfsc voting_logic_sensor1 ; sensor value agrees with values of other sensors? bra TFT_update_hud1e ; YES ; valid calibration, in use, but value does not agree with other sensors bsf win_invert ; invert output @@ -1505,12 +1639,12 @@ TFT_update_hud2b: ; sensor has a valid calibration WIN_MEDIUM dm_custom_hud_sensor2_column,dm_custom_hud_row - movff o2_ppo2_sensor2,lo ; load ppO2 value into transfer storage for output + movff sensor2_ppO2,lo ; load ppO2 value into transfer storage for output clrf hi ; btfsc use_O2_sensor2 ; in use? bra TFT_update_hud2d ; YES ; valid calibration, but not in use - tstfsz o2_ppo2_sensor2 ; sensor value = 0? + tstfsz lo ; sensor value = 0? bra TFT_update_hud2c ; NO ; valid calibration, not in use and value = 0 call TFT_attention_color ; output in yellow @@ -1522,7 +1656,7 @@ TFT_update_hud2d: ; sensor has valid calibration and is in use call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo - btfsc voting_logic_sensor2 ; sensor value agrees with other sensor's vlaues? + btfsc voting_logic_sensor2 ; sensor value agrees with values of other sensors? bra TFT_update_hud2e ; YES ; valid calibration, in use, but value does not agree with other sensors bsf win_invert ; invert output @@ -1545,12 +1679,12 @@ TFT_update_hud3b: ; sensor has a valid calibration WIN_MEDIUM dm_custom_hud_sensor3_column,dm_custom_hud_row - movff o2_ppo2_sensor3,lo ; load ppO2 value into transfer storage for output + movff sensor3_ppO2,lo ; load ppO2 value into transfer storage for output clrf hi ; btfsc use_O2_sensor3 ; in use? bra TFT_update_hud3d ; YES ; valid calibration, but not in use - tstfsz o2_ppo2_sensor3 ; sensor value = 0? + tstfsz lo ; sensor value = 0? bra TFT_update_hud3c ; NO ; valid calibration, not in use and value = 0 call TFT_attention_color ; output in yellow @@ -1562,7 +1696,7 @@ TFT_update_hud3d: ; sensor has valid calibration and is in use call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo - btfsc voting_logic_sensor3 ; sensor value agrees with other sensor's values? + btfsc voting_logic_sensor3 ; sensor value agrees with values other sensors? bra TFT_update_hud3e ; YES ; valid calibration, in use, but value does not agree with other sensors bsf win_invert ; invert output @@ -1576,13 +1710,8 @@ bra TFT_display_exit_3 - global TFT_surface_sensor ; update sensor data in surface mode + global TFT_surface_sensor ; update O2 sensor data in surface mode TFT_surface_sensor: - movf hardware_flag1,W - sublw 0x11 ; 2 with BLE - btfsc STATUS,Z - return ; ignore for 0x11 - ; show three sensors bsf leftbind WIN_SMALL surf_hud_sensor1_column,surf_hud_sensor1_row btfsc sensor1_calibrated_ok @@ -1593,7 +1722,7 @@ STRCPY_PRINT "--- " bra TFT_surface_sensor2 ; skip sensor 1 TFT_surface_sensor1: - movff o2_ppo2_sensor1,lo + movff sensor1_ppO2,lo call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo clrf hi bsf leftbind @@ -1610,7 +1739,7 @@ STRCPY_PRINT "--- " bra TFT_surface_sensor4 ; skip sensor 2 TFT_surface_sensor3: - movff o2_ppo2_sensor2,lo + movff sensor2_ppO2,lo call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo clrf hi bsf leftbind @@ -1627,7 +1756,7 @@ STRCPY_PRINT "--- " bra TFT_surface_sensor6 ; skip sensor 3 TFT_surface_sensor5: - movff o2_ppo2_sensor3,lo + movff sensor3_ppO2,lo call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo clrf hi bsf leftbind @@ -1642,26 +1771,24 @@ global TFT_sensor_mV TFT_sensor_mV: - call TFT_standard_color bsf leftbind WIN_SMALL surf_mV_sensor_column,surf_mV_sensor1_row - movff o2_mv_sensor1+0,lo ; in 0.1mV steps - movff o2_mv_sensor1+1,hi ; in 0.1mV steps + SMOVII sensor1_mv,mpr ; in 0.1mV steps STRCAT "1: " rcall TFT_sensor_mV_helper WIN_SMALL surf_mV_sensor_column,surf_mV_sensor2_row - movff o2_mv_sensor2+0,lo ; in 0.1mV steps - movff o2_mv_sensor2+1,hi ; in 0.1mV steps + SMOVII sensor2_mv,mpr ; in 0.1mV steps STRCAT "2: " rcall TFT_sensor_mV_helper WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row - movff o2_mv_sensor3+0,lo ; in 0.1mV steps - movff o2_mv_sensor3+1,hi ; in 0.1mV steps + SMOVII sensor3_mv,mpr ; in 0.1mV steps STRCAT "3: " rcall TFT_sensor_mV_helper + + bcf leftbind bra TFT_display_exit_3 TFT_sensor_mV_helper: @@ -1672,7 +1799,7 @@ global TFT_sensor_surface_warning TFT_sensor_surface_warning: - call TFT_warnings_color + call TFT_warning_color btfss sensor1_calibrated_ok ; do not show end of lifetime arrow if sensor failed calibration at all bra TFT_sensor_mV2 movff opt_x_s1+1,lo ; into bank1 @@ -1702,38 +1829,38 @@ global TFT_menu_calibrate TFT_menu_calibrate: ; update mV data in calibration menu - btfss s8_digital ; =1: Digital I/O - bra TFT_menu_calibrate_analog ; use analog - btfss new_s8_data_available ; new data frame received? - bra TFT_menu_calibrate_common ; NO - use old values... - ; YES - update the values - call compute_mvolts_for_all_sensors - bra TFT_menu_calibrate_common + btfss s8_digital_avail ; do we have a digital S8 interface? + bra TFT_menu_calibrate_analog ; NO - use analog + btfss trigger_S8_data_update ; YES - new data frame received? + bra TFT_menu_calibrate_common ; NO - use old values... + bcf trigger_S8_data_update ; YES - clear update flag + call compute_mvolts_for_all_sensors ; - compute mV values from received data frame + bra TFT_menu_calibrate_common ; - continue with common part TFT_menu_calibrate_analog: - call get_analog_inputs + call get_analog_inputs ; read mV values from analog inputs TFT_menu_calibrate_common: call TFT_attention_color ; show in yellow - bsf leftbind + bsf leftbind ; align to the left WIN_SMALL surf_menu_sensor1_column,surf_menu2_sensor1_row - movff o2_mv_sensor1+0,lo ; in 0.1mV steps - movff o2_mv_sensor1+1,hi ; in 0.1mV steps + SMOVII sensor1_mv,mpr ; in 0.1mV steps output_16dp .4 ; xxx.y mV STRCAT_PRINT "mV " WIN_SMALL surf_menu_sensor2_column,surf_menu2_sensor2_row - movff o2_mv_sensor2+0,lo ; in 0.1mV steps - movff o2_mv_sensor2+1,hi ; in 0.1mV steps + SMOVII sensor2_mv,mpr ; in 0.1mV steps output_16dp .4 ; xxx.y mV STRCAT_PRINT "mV " WIN_SMALL surf_menu_sensor3_column,surf_menu2_sensor3_row - movff o2_mv_sensor3+0,lo ; in 0.1mV steps - movff o2_mv_sensor3+1,hi ; in 0.1mV steps + SMOVII sensor3_mv,mpr ; in 0.1mV steps output_16dp .4 ; xxx.y mV STRCAT_PRINT "mV " bra TFT_display_exit_3 - - global TFT_clock -TFT_clock: + ENDIF ; _external_sensor + +;============================================================================= + + global TFT_time_surfmode +TFT_time_surfmode: IFDEF _ostc_logo WIN_SMALL surf_clock_column,surf_clock_row ELSE @@ -1741,35 +1868,40 @@ ENDIF TFT_clock2: ; called from divemode clock call TFT_standard_color - movff hours,lo + SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time + movff rtc_latched_hour,lo output_99 movlw ':' - btfss secs,0 ; blinking every second + movff rtc_latched_secs,lo + btfss lo,0 ; blinking every second movlw ' ' movwf POSTINC2 - movff mins,lo + movff rtc_latched_mins,lo output_99x STRCAT_PRINT "" return + global TFT_show_time_date_menu + global TFT_show_time_date_menu_fast TFT_show_time_date_menu: - call speed_fastest - WIN_SMALL .15,.30 + SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of current date & time +TFT_show_time_date_menu_fast: + WIN_SMALL .20,.40 ; column, row - keep clear of the cursor area on the left! call TFT_standard_color - movff hours,lo + movff rtc_latched_hour,lo output_99 PUTC ':' - movff mins,lo + movff rtc_latched_mins,lo output_99x PUTC ':' - movff secs,lo + movff rtc_latched_secs,lo output_99x - STRCAT " - " - movff day,lo - movff month,hi - movff year,up - call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 + STRCAT " " + movff rtc_latched_day,lo + movff rtc_latched_month,hi + movff rtc_latched_year,up + call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 STRCAT_PRINT " " return @@ -1799,7 +1931,7 @@ TFT_surface_decosettings1: TEXT_SMALL surf_gaslist_column+.43,surf_gaslist_row,tZHL16GF WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) - STRCPY_TEXT tGF ; GF: + STRCPY_TEXT tGF ; GF: movff opt_GF_low,lo output_99x STRCAT "/" @@ -1828,52 +1960,38 @@ STRCAT_TEXT_PRINT tPercent return - global TFT_debug_output -TFT_debug_output: - WIN_TINY .80,.0 - call TFT_standard_color - lfsr FSR2,buffer - movff analog_sw1,lo - output_8 - PUTC "," - movff analog_sw2,lo - output_8 - STRCAT_PRINT "" - return global TFT_divetimeout ; show timeout counter TFT_divetimeout: - call TFT_warning_set_window ; set the row and column for the current message + call TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_memo_color STRCPY 0x94 ; "End of dive" symbol movff opt_diveTimeout,WREG ; in [min] mullw .60 - movff PRODL,sub_a+0 - movff PRODH,sub_a+1 ; in [s] - movff timeout_counter1+0,sub_b+0 - movff timeout_counter1+1,sub_b+1 + MOVII PRODL, sub_a ; in seconds + MOVII dive_timeout_timer,sub_b call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) - movff sub_c+0,lo - movff sub_c+1,hi - call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) - movf hi,W - movff lo,hi - movwf lo ; exchange lo and hi + MOVII sub_c,mpr + call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) + movf hi,W ; swap lo and hi + movff lo,hi ; ... + movwf lo ; ... output_99x PUTC ':' - movff hi,lo + movff hi,lo ; copy hi to lo output_99x - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bcf win_invert return - global TFT_display_ftts -TFT_display_ftts: - call TFT_warning_set_window ; sets the row and column for the current warning + + global TFT_show_ftts +TFT_show_ftts: + call TFT_set_message_window ; sets the row and column for the current warning tstfsz WREG ; is there room for the message? return ; NO - done btfsc FLAG_oc_mode ; YES - in OC mode? @@ -1889,8 +2007,7 @@ bsf leftbind ; print with alignment to the left output_8 ; print fTTS delay time PUTC ":" ; ":" - movff int_O_alternate_ascenttime+0,lo - movff int_O_alternate_ascenttime+1,hi + MOVII int_O_TTS_alt,mpr ; get alternative TTS call TFT_memo_color ; set memo color btfss hi,int_invalid_flag ; is the invalid flag set? bra TFT_display_ftts_3 ; NO - keep memo color @@ -1903,12 +2020,10 @@ iorwf hi,W ; extra_ascenttime = 0 ? bz TFT_display_ftts_5 ; YES - show "NDL" movff char_O_deco_info,up ; get deco info vector - btfsc up,deco_steady ; fTTS = TTS ? + btfsc up,deco_zone ; fTTS <= TTS ? call TFT_advice_color ; YES - set to advice color (green) - btfsc up,deco_decreasing ; fTTS < TTS ? - call TFT_advice_color ; YES - set to advice color (green) - output_16 ; NO - show ascent time - PUTC "'" ; - minutes symbol + output_16 ; print ascent time + PUTC "'" ; print minutes symbol bra TFT_display_ftts_6 TFT_display_ftts_4: STRCAT "---" ; "---" for not computed @@ -1942,43 +2057,41 @@ bra TFT_temp_common - global TFT_temp_divemode -TFT_temp_divemode: - bcf FLAG_TFT_temp_divemode - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - no update of temperature now - btfsc blinking_better_gas ; blinking better gas? - return ; YES - no update of temperature now - btfsc blinking_better_dil ; blinking better diluent? - return ; YES - no update of temperature now - WIN_SMALL dm_temp_column,dm_temp_row - call TFT_memo_color - btfsc alternative_divelayout ; in alternative layout? - bra TFT_temp_common ; YES - proceed with temperature - movlw index_compass_dm ; NO - index of compass custom view - cpfseq menupos3 ; - compass shown in custom view? - bra TFT_temp_common ; NO - proceed with temperature - bra TFT_update_stopwatch ; YES - show resettable dive time instead of temperature + global TFT_show_temp_divemode +TFT_show_temp_divemode: + btfsc dive_options_menu ; is the pre-menu shown? + return ; YES - abort + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort, no update of temperature now + btfsc better_gas_blinking ; blinking better gas? + return ; YES - abort, no update of temperature now + btfsc better_dil_blinking ; blinking better diluent? + return ; YES - abort, no update of temperature now + + WIN_SMALL dm_temp_column,dm_temp_row ; set position + call TFT_memo_color ; set color + movlw index_compass_dm ; index of compass custom view + cpfseq active_customview ; compass shown in custom view? + bra TFT_temp_common ; NO - proceed with temperature + bra TFT_update_stopwatch ; YES - show resettable dive time instead of temperature TFT_temp_common: - SAFE_2BYTE_COPY temperature,lo ; get current temperature - TSTOSS opt_units ; 0=°C, 1=°F - bra TFT_temp_common_1 - call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit -TFT_temp_common_1: - rcall TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required + SMOVII temperature_cur,mpr ; ISR-safe 2 byte copy of current temperature to hi:lo + TSTOSC opt_units ; 0=°C, 1=°F + call convert_celsius_to_fahrenheit ; 1 - convert value in lo:hi from Celsius to Fahrenheit + rcall TFT_convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required btfsc neg_flag ; is the temperature negative? bra TFT_temp_common_2 ; YES - the minus sign has already been written ; temp is positive, is it less than 10°C ? tstfsz hi - bra TFT_temp_common_1a ; >25.5°C, skip here + bra TFT_temp_common_1 ; > 25.5°C, skip here movlw .100 cpfslt lo - bra TFT_temp_common_1a ; >10.0°C, skip here + bra TFT_temp_common_1 ; > 10.0°C, skip here bsf leftbind output_16dp d'4' ; x.y°C bcf leftbind bra TFT_temp_common_3 ; done -TFT_temp_common_1a: +TFT_temp_common_1: PUTC " " ; NO - write a space instead of the minus sign TFT_temp_common_2: bsf ignore_digit5 ; ignore decimal (flag will be cleared by output_16) @@ -2001,22 +2114,24 @@ STRCAT_TEXT tLogTunitC ; append °C TFT_temp_common_5: STRCAT_PRINT "" ; output to screen - return +TFT_temp_common_6: + goto TFT_standard_color ; done + ;============================================================================= - global TFT_divemode_menu_cursor -TFT_divemode_menu_cursor: + global TFT_show_menu_cursor_divemode +TFT_show_menu_cursor_divemode: WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1 call TFT_standard_color movlw dm_menu_item1_column-.8 - btfsc menupos1,2 ; > 3 ? + btfsc menu_pos_cur,2 ; > 3 ? movlw dm_menu_item4_column-.8 ; YES movwf win_leftx2 - movff menupos1,lo ; copy menu position + movff menu_pos_cur,lo ; copy menu position movlw dm_menu_item6_row dcfsnz lo,F movlw dm_menu_item1_row @@ -2034,140 +2149,158 @@ STRCPY_PRINT "\xb7" ; print cursor return - - global TFT_active_gas_divemode -TFT_active_gas_divemode: ; display gas/setpoint - bcf FLAG_TFT_active_gas_divemode - btfsc divemode_menu ; is the dive mode menu shown? - return ; YES - return +;============================================================================= + + global TFT_show_active_gas_divemode +TFT_show_active_gas_divemode: ; display gas (OC) or setpoint/ppO2 & gas (CCR, pSCR) + btfsc dive_main_menu ; is the dive mode menu shown? + return ; YES - abort btfsc FLAG_apnoe_mode ; in apnoe mode? - return ; YES - return + return ; YES - done btfsc FLAG_gauge_mode ; in gauge mode? - return ; YES - return - btfss FLAG_oc_mode ; in OC mode? - bra TFT_active_setpoint ; NO - show setpoint and gas mix - bra TFT_active_gas_divemode_oc ; YES - show OC gas - -TFT_active_setpoint_bail: ; bailout case - tstfsz menupos2 ; any option shown? - bra TFT_active_gas_divemode_oc ; YES - do not overwrite with bailout text + return ; YES - done + + IFDEF _ccr_pscr + btfsc FLAG_oc_mode ; in OC mode? + bra TFT_active_gas ; YES - show OC gas + ;bra TFT_active_sp ; NO - show setpoint and diluent + +TFT_active_sp: + btfss bailout_mode ; in bailout? + bra TFT_active_sp_loop ; NO + ;bra TFT_active_sp_bailout ; YES + +TFT_active_sp_bailout: WIN_SMALL dm_active_dil_column, dm_active_dil_row - call TFT_attention_color ; print in yellow - STRCPY_TEXT_PRINT tDiveBailout ; "Bailout" -TFT_active_gas_divemode_oc: ; common part for OC and bailout - movff int_O_breathed_ppO2+0,lo ; color-code the output of the gas by the ppO2 it yields - movff int_O_breathed_ppO2+1,hi ; - call TFT_color_code_ppo2 ; with ppO2 [cbar] in hi:lo - btfss better_gas_available ; check if a better gas is available and a gas change shall be advised - bra TFT_active_gas_print ; NO - print in normal rendering - btg blinking_better_gas ; YES - toggle blink bit - btfss blinking_better_gas ; blink now? - bra TFT_active_gas_print ; NO - print in normal rendering - call TFT_attention_color ; YES - blink in yellow - bsf win_invert ; set invert flag -TFT_active_gas_print: - WIN_STD dm_active_gas_column, dm_active_gas_row - movff char_I_O2_ratio,lo ; lo now stores O2 in % - movff char_I_He_ratio,hi ; hi now stores He in % - call customview_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 - STRCAT_PRINT "" - bcf win_invert ; reset invert flag - goto TFT_standard_color ; ...and return - - ; in CCR / pSCR mode - and maybe in bailout -TFT_active_setpoint: ; - btfsc FLAG_bailout_mode ; in bailout? - bra TFT_active_setpoint_bail ; YES - show "Bailout" instead of setpoint - - ; on the loop - movff int_O_breathed_ppO2+0,lo ; color-code the output by the ppO2 of the loop gas mixture - movff int_O_breathed_ppO2+1,hi - call TFT_color_code_ppo2 ; with ppO2 [cbar] in hi:lo - btfss secs,0 ; timebase for blinking effect: on even second? - bra TFT_active_setpoint_print ; YES - print ppO2 with normal rendering - btfsc setpoint_fallback ; NO - check if we are in fallback condition - bra TFT_active_setpoint_fallb ; YES - process fallback case + call TFT_attention_color ; - set color + STRCPY_TEXT_PRINT tDiveBailout ; - print "Bailout" + bra TFT_active_gas ; - continue showing OC bailout gas + +TFT_active_sp_loop: + MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] to hi:lo + call TFT_color_code_ppo2 ; color-code the output by the ppO2 of the loop gas mixture + btfss timebase_1sec ; on even second? + bra TFT_active_sp_print ; YES - print ppO2 with normal rendering + btfsc sp_fallback ; NO - check if in fallback condition + bra TFT_active_sp_fallback ; YES - process fallback case movff int_O_breathed_ppO2+1,WREG ; NO - get flags again (have been cleared in hi:lo by TFT_color_code_ppo2 meanwhile) btfss WREG,int_warning_flag ; warning flag set? - bra TFT_active_setpoint_print ; NO - ppO2 is ok, print ppO2 with normal rendering - bra TFT_active_setpoint_com ; YES - continue with blinking common part -TFT_active_setpoint_fallb: ; set up fallback case - call TFT_attention_color ; text in yellow -TFT_active_setpoint_com: ; blinking common part - bsf win_invert ; set invert flag -TFT_active_setpoint_print: - WIN_STD dm_active_gas_column, dm_active_gas_row - bsf leftbind - output_16dp .3 ; x.xx bar - bcf leftbind - STRCAT_TEXT tbar - movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP - sublw .1 ; opt_ccr_mode = 1 (Sensor)? - bnz TFT_active_setpoint2_a ; NO - skip - PUTC "*" ; YES - add an astrix -TFT_active_setpoint2_a: - STRCAT_PRINT "" - bcf win_invert ; reset invert flag - call TFT_memo_color ; revert to memo color -TFT_active_setpoint_diluent: ; diluent gas - movff int_O_pure_ppO2+0,lo ; color-code the output - movff int_O_pure_ppO2+1,hi - call TFT_color_code_ppo2 ; with ppO2 [cbar] in hi:lo - btfss better_dil_available ; check if a better diluent is available and a diluent change shall be advised - bra TFT_active_setpoint_diluent_show ; NO - print in normal rendering - btg blinking_better_dil ; YES - toggle blink bit... - btfss blinking_better_dil ; blink now? - bra TFT_active_setpoint_diluent_show ; NO - print in normal rendering - call TFT_attention_color ; YES - print in yellow color - bsf win_invert ; - set invert flag -TFT_active_setpoint_diluent_show: + bra TFT_active_sp_print ; NO - ppO2 is ok, print ppO2 with normal rendering + bra TFT_active_sp_invers ; YES - print with inverse rendering +TFT_active_sp_fallback: ; set up fallback case + call TFT_attention_color ; set color to yellow +TFT_active_sp_invers: ; blinking common part + bsf win_invert ; print in inverse +TFT_active_sp_print: ; set position + WIN_MEDIUM dm_active_gas_sp_value_col, dm_active_gas_sp_value_row + bsf leftbind ; print left-aligned + output_16dp .3 ; print ppO2 as x.xx + bcf leftbind ; back to right alignment + STRCAT_PRINT "" ; finalize output + bcf win_invert ; end inverse printing + + btfsc sign_shown ; advice/attention/warning sign shown? + bra TFT_active_diluent ; YES - skip display of "bar" and loop mode + + btfsc velocity_active_vsi ; graphical vertical speed indicator shown? + bra TFT_active_diluent ; YES - skip display of "bar" and loop mode + +TFT_active_sp_label: + WIN_STD dm_active_sp_label_col, dm_active_sp_label_row + call TFT_memo_color ; select memo color + STRCAT "bar" ; print "bar" + IFDEF _external_sensor + movff opt_ccr_mode,WREG ; get setpoint mode =0: Fixed SP, =1: Sensor, =2: Auto SP + sublw .1 ; opt_ccr_mode = 1 (Sensor) ? + bnz TFT_active_sp_label_1 ; NO - skip + PUTC "*" ; YES - add "*" +TFT_active_sp_label_1: + ENDIF + STRCAT_PRINT "" ; finalize output + +TFT_active_loop_mode: + WIN_TINY dm_active_sp_label_col, dm_active_dil_row+.3 + call TFT_memo_color ; set memo color + btfsc FLAG_ccr_mode ; in CCR mode? + bra TFT_active_loop_mode_ccr ; YES - print CCR label + btfsc FLAG_pscr_mode ; in pSCR mode? + bra TFT_active_loop_mode_pscr ; YES - print pSCR label + bra TFT_active_diluent ; NO to both - should not happen +TFT_active_loop_mode_ccr: + STRCPY_TEXT_PRINT tDvCCR ; print "CCR" + bra TFT_active_diluent ; continue with diluent +TFT_active_loop_mode_pscr: + STRCPY_TEXT_PRINT tDvPSCR ; print "pSCR" + ;bra TFT_active_diluent ; continue with diluent + +TFT_active_diluent: + MOVII int_O_pure_ppO2,mpr ; get ppO2 [cbar] into hi:lo + call TFT_color_code_ppo2 ; color-code the output + btfss better_dil_available ; better diluent available? + bra TFT_active_diluent_show ; NO - print in normal rendering + btg better_dil_blinking ; YES - toggle blink bit... + btfss better_dil_blinking ; blink now? + bra TFT_active_diluent_show ; NO - print in normal rendering + call TFT_attention_color ; YES - print in yellow color + bsf win_invert ; - print in inverse +TFT_active_diluent_show: WIN_SMALL dm_active_dil_column, dm_active_dil_row + bra TFT_active_dil_gas_common ; continue with common part + ENDIF ; _ccr_pscr + +TFT_active_gas: + MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] into hi:lo + call TFT_color_code_ppo2 ; color-code the output + btfss better_gas_available ; better gas available? + bra TFT_active_gas_print ; NO - print in normal rendering + btg better_gas_blinking ; YES - toggle blink bit + btfss better_gas_blinking ; blink now? + bra TFT_active_gas_print ; NO - print in normal rendering + call TFT_attention_color ; YES - blink in yellow + bsf win_invert ; print in inverse +TFT_active_gas_print: + WIN_STD dm_active_gas_sp_value_col, dm_active_sp_label_row +TFT_active_dil_gas_common: movff char_I_O2_ratio,lo ; lo now stores O2 in % + IFDEF _helium movff char_I_He_ratio,hi ; hi now stores He in % - call customview_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 - STRCAT_PRINT "" - bcf win_invert ; reset invert flag - call TFT_memo_color ; set memo color - btfsc menuview ; is the dive options menu shown? - return ; YES - do not overwrite it - WIN_TINY dm_active_dil_column+.45, dm_active_dil_row+.3 - btfsc FLAG_ccr_mode ; in CCR mode? - bra TFT_active_setpoint_ccr ; YES - write CCR label - btfsc FLAG_pscr_mode ; in pSCR mode? - bra TFT_active_setpoint_pscr ; YES - write pSCR label - return ; NO to both - should not happen, anyhow: done -TFT_active_setpoint_ccr: - STRCPY_TEXT_PRINT tDvCCR ; print "CCR" - return ; done -TFT_active_setpoint_pscr: - STRCPY_TEXT_PRINT tDvPSCR ; print "PSCR" - return ; done - - - global TFT_display_decotype_surface -TFT_display_decotype_surface: + ELSE + clrf hi ; set hi to zero (no He) + ENDIF + call gaslist_show_mix ; print "Nxlo", "Txlo/hi", "Air" or "O2" + STRCAT_PRINT "" ; finalize output + bcf win_invert ; end inverse printing + goto TFT_standard_color ; done + +;============================================================================= + + global TFT_decotype_surface +TFT_decotype_surface: WIN_STD surf_decotype_column,surf_decotype_row WIN_COLOR color_lightblue - movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnoe, 4=PSCR - tstfsz lo - bra TFT_display_decotype_surface2 -TFT_display_decotype_surface0: + movff opt_dive_mode,lo ; 0=OC, 1=CCR, 2=Gauge, 3=Apnoe, 4=pSCR + tstfsz lo ; in OC mode? + bra TFT_decotype_surface_2 ; NO +TFT_decotype_surface_1: STRCAT_TEXT_PRINT tDvOC ; OC bra TFT_display_decotype_exit -TFT_display_decotype_surface2: - decfsz lo,F - bra TFT_display_decotype_surface3 - STRCAT_TEXT_PRINT tDvCC ; CC +TFT_decotype_surface_2: + decfsz lo,F ; in CCR mode? + bra TFT_decotype_surface_3 ; NO + IFDEF _ccr_pscr + STRCAT_TEXT_PRINT tDvCC ; YES call TFT_standard_color WIN_TINY surf_decotype_column+.18,surf_decotype_row+.12 - TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor, =2: Auto SP - bra TFT_display_decotype_cc_fixed - ; Sensor mode or Auto - movff opt_ccr_mode,WREG - sublw .2 - bz TFT_display_decotype_cc_auto - STRCPY_TEXT tCCRModeSensor ; sensor - bra TFT_display_decotype_cc_common + TSTOSS opt_ccr_mode ; > 0, i.e. not Fixed SP ? + bra TFT_display_decotype_cc_fixed ; NO - fixed then + IFDEF _external_sensor + ; Sensor or Auto SP mode + movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP + sublw .2 ; mode = Auto SP ? + bz TFT_display_decotype_cc_auto ; YES + STRCPY_TEXT tCCRModeSensor ; NO - Sensor + bra TFT_display_decotype_cc_common ; + ENDIF ; _external_sensor TFT_display_decotype_cc_auto: STRCPY_TEXT tCCRModeAutoSP ; Auto SP bra TFT_display_decotype_cc_common @@ -2178,48 +2311,56 @@ movff WREG,buffer+.8 ; limit string length to 8 STRCAT_PRINT "" bra TFT_display_decotype_exit -TFT_display_decotype_surface3: - decfsz lo,F - bra TFT_display_decotype_surface4 -TFT_display_decotype_surface3_1: - STRCAT_TEXT_PRINT tDvGauge ; Gauge + ENDIF ; _ccr_pscr +TFT_decotype_surface_3: + decfsz lo,F ; in gauge mode? + bra TFT_decotype_surface_4 ; NO +TFT_decotype_surface_3_1: ; YES + STRCAT_TEXT_PRINT tDvGauge bra TFT_display_decotype_exit -TFT_display_decotype_surface4: - decfsz lo,F - bra TFT_display_decotype_surface5 -TFT_display_decotype_surface4_1: - STRCAT_TEXT_PRINT tDvApnea ; Apnea +TFT_decotype_surface_4: + decfsz lo,F ; in apnea mode? + bra TFT_decotype_surface_5 ; NO +TFT_decotype_surface_4_1: ; YES + STRCAT_TEXT_PRINT tDvApnea bra TFT_display_decotype_exit -TFT_display_decotype_surface5: - STRCAT_TEXT_PRINT tDvPSCR ; pSCR +TFT_decotype_surface_5: + STRCAT_TEXT_PRINT tDvPSCR ; last but not least: must be pSCR then TFT_display_decotype_exit: goto TFT_standard_color ; and return... - global TFT_display_decotype_surface1 -TFT_display_decotype_surface1: ; used from logbook and from deco calculator (simulator.asm) - tstfsz lo ; lo holds 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR - bra TFT_display_decotype_surface1_2 - bra TFT_display_decotype_surface0 ; OC -TFT_display_decotype_surface1_2: - decfsz lo,F - bra TFT_display_decotype_surface1_3 - STRCAT_TEXT_PRINT tDvCC ; CC - bra TFT_display_decotype_exit -TFT_display_decotype_surface1_3: - decfsz lo,F - bra TFT_display_decotype_surface1_4 - bra TFT_display_decotype_surface3_1 ; Gauge -TFT_display_decotype_surface1_4: - decfsz lo,F - bra TFT_display_decotype_surface5 ; pSCR - bra TFT_display_decotype_surface4_1 ; Apnea + global TFT_decotype_logbook +TFT_decotype_logbook: ; used from logbook and from deco calculator (simulator.asm) + bsf aux_flag ; default to dive with deco calculation + tstfsz lo ; lo holds 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR, in OC mode? + bra TFT_decotype_logbook_1_2 ; NO + bra TFT_decotype_surface_1 ; YES - OC +TFT_decotype_logbook_1_2: + decfsz lo,F ; in CCR mode? + bra TFT_decotype_logbook_1_3 ; NO + STRCAT_TEXT_PRINT tDvCC ; YES - print "CCR" + bra TFT_display_decotype_exit ; - done +TFT_decotype_logbook_1_3: + decfsz lo,F ; in gauge mode? + bra TFT_decotype_logbook_1_4 ; NO + bcf aux_flag ; YES - dive without deco data + bra TFT_decotype_surface_3_1 ; - gauge +TFT_decotype_logbook_1_4: + decfsz lo,F ; in apnea mode? + bra TFT_decotype_logbook_1_5 ; NO + bcf aux_flag ; YES - dive without deco data + bra TFT_decotype_surface_4_1 ; - apnea +TFT_decotype_logbook_1_5: + bra TFT_decotype_surface_5 ; last but not least: must be pSCR then ;============================================================================= + IFDEF _ccr_pscr + global TFT_splist_surfmode ; show setpoint list TFT_splist_surfmode: - bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint + bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) ;SP 1 WIN_SMALL surf_gaslist_column,surf_gaslist_row @@ -2253,9 +2394,13 @@ bcf leftbind return + ENDIF + +;============================================================================= + global TFT_gaslist_surfmode TFT_gaslist_surfmode: ; displays gas list - bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint + bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) ;Gas 1 WIN_SMALL surf_gaslist_column,surf_gaslist_row @@ -2290,223 +2435,272 @@ bcf win_invert ; clear flag for inverted output return +;============================================================================= + + IFDEF _ccr_pscr + global TFT_dillist_surfmode TFT_dillist_surfmode: ; displays diluent list - bsf FLAG_diluent_setup ; use CCR diluents... - rcall TFT_gaslist_surfmode ; use OC/BAIL routine - bcf FLAG_diluent_setup ; clear flag + bsf is_diluent_menu ; enable using diluents + rcall TFT_gaslist_surfmode ; use OC gas routine + bcf is_diluent_menu ; disable using diluents return + ENDIF + ;================================================================== - global TFT_depth -TFT_depth: - bcf FLAG_TFT_depth - SAFE_2BYTE_COPY rel_pressure, lo - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] - call TFT_color_code_depth ; color-code the output - rcall TFT_depth_blink - WIN_LARGE dm_depth_column, dm_depth_row - TSTOSS opt_units ; 0=m, 1=ft - bra TFT_depth_metric -;TFT_depth_imperial - clrf sub_a+1 ; display 0ft if lower then 30cm - movlw d'30' - movwf sub_a+0 - movff hi,sub_b+1 - movff lo,sub_b+0 - call subU16 ; sub_c = sub_a - sub_b - btfss neg_flag ; depth lower then 0.4m? - bra depth_less_0.3mtr_feet ; YES - show 0ft manually - call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet - bsf leftbind - output_16 ; feet in Big font - bcf leftbind - movlw .3 ; limit to three chars - call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) - STRCAT_PRINT "" ; display feet - bcf win_invert ; reset invert flag - return - -depth_less_0.3mtr_feet: - STRCAT_PRINT "0 " ; manual zero - bcf win_invert ; reset invert flag - return + global TFT_show_depth +TFT_show_depth: + MOVII pressure_rel_cur_cached,mpr ; copy relative pressure to hi:lo + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] + call TFT_color_code_depth ; set warning / attention flags and color-code the output + rcall TFT_depth_blink ; control animation (blinking) + rcall TFT_depth_position_m_ft ; set output position + + TSTOSS opt_units ; 0=m, 1=ft ? + bra TFT_depth_metric ; 0 - metric + ;bra TFT_depth_imperial ; 1 - imperial + +TFT_depth_imperial: + MOVLI .30,sub_a ; display 0 ft if shallower than 30 cm + MOVII mpr,sub_b + call cmpU16 ; compare (sub_a - sub_b) + btfss neg_flag ; depth shallower than 30 cm ? + bra depth_0_feet ; YES - print a zero directly + call convert_mbar_to_feet ; NO - convert value in hi:lo from mbar to feet + bsf leftbind ; - print left-aligned + output_16 ; - feet in large or huge font + bcf leftbind ; - reset alignment + movlw .3 ; - limit to three chars + call TFT_fillup_with_spaces ; - fill up FSR2 with spaces + STRCAT_PRINT "" ; - finalize output +TFT_depth_imperial_1: + bcf win_invert ; - reset invert flag + bra TFT_depth_exit ; - show target depth if in simulator mode and return + +depth_0_feet: + STRCAT_PRINT "0 " ; print a zero directly + bra TFT_depth_imperial_1 ; continue with common part TFT_depth_metric: - movlw .039 - cpfslt hi - bra depth_greater_99_84mtr - - btfsc depth_greater_100m ; was depth > 100m during last call? - rcall TFT_clear_depth ; YES - clear depth area - bcf depth_greater_100m ; do this once only... - - movlw .039 - cpfslt hi - bra depth_greater_99_84mtr - - movlw HIGH d'1000' - movwf sub_a+1 - movlw LOW d'1000' - movwf sub_a+0 - movff hi,sub_b+1 - movff lo,sub_b+0 - incf sub_b+0,F - movlw d'0' - addwfc sub_b+1,F ; add 1mbar offset - call sub16 ; sub_c = sub_a - sub_b - movlw ' ' - btfss neg_flag ; depth lower then 10m? - movwf POSTINC2 ; YES - add extra space - - clrf sub_a+1 - movlw d'99' - movwf sub_a+0 - movff hi,sub_b+1 - movff lo,sub_b+0 - call subU16 ; sub_c = sub_a - sub_b - btfss neg_flag ; depth lower then 1m? - bra tft_depth2 ; YES - display manual Zero - - bsf leftbind - bsf ignore_digit4 - output_16 ; full meters in big font - bcf leftbind - bra tft_depth3 - -tft_depth2: - STRCAT "0" ; manual zero - -tft_depth3: - STRCAT_PRINT "" ; display full meters - - ; .1m in MEDIUM font - WIN_MEDIUM dm_depth_dm_column, dm_depth_dm_row - - SAFE_2BYTE_COPY rel_pressure, lo - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] - ;call TFT_color_code_depth ; color-code the output - not needed, furthermore: seems to cause problems if not commented out... - - PUTC "." - movlw HIGH d'30' ; display 0.0m if lower then 30cm - movwf sub_a+1 - movlw LOW d'30' - movwf sub_a+0 - movff hi,sub_b+1 - movff lo,sub_b+0 - call subU16 ; sub_c = sub_a - sub_b - btfss neg_flag ; depth lower then 0.3m? - bra depth_less_0.3mtr ; YES - show ".0" manually - - movlw d'4' - movwf ignore_digits - bsf ignore_digit5 ; (flag will be cleared by output_16) - output_16dp d'0' - STRCAT_PRINT "" ; display decimeters - bcf win_invert ; reset invert flag - WIN_FONT FT_SMALL - return - -depth_less_0.3mtr: - STRCAT_PRINT "0" ; display 0.0m manually - bcf win_invert ; reset invert flag - WIN_FONT FT_SMALL - return - -depth_greater_99_84mtr: ; display only in full meters - btfss depth_greater_100m ; is depth > 100m already? - rcall TFT_clear_depth ; NO - clear depth area and set flag - call TFT_color_code_depth - ; Depth is already in hi:lo - ; Show depth in Full meters - ; That means ignore digit 4 and 5 - lfsr FSR2,buffer - bsf ignore_digit4 - bsf leftbind - output_16 - bcf leftbind - STRCAT_PRINT "" ; display full meters only - bcf win_invert ; reset invert flag - WIN_FONT FT_SMALL - return - -TFT_clear_depth: ; NO - clear depth area and set flag - WIN_BOX_BLACK dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt ;top, bottom, left, right - bsf depth_greater_100m ; set flag - return + ; full meters + MOVLI .9999,sub_a ; 9999 mbar = 99.99 m + MOVII mpr, sub_b ; current depth + call cmpU16 ; compare (sub_a - sub_b) + btfsc neg_flag ; current depth < 100 meter ? + bra TFT_depth_metric_100m ; NO - current depth >= 100 meter + + btfsc cur_depth_greater_100m ; was the current depth >= 100 meter during last call? + rcall TFT_depth_box_black ; YES - clear depth area + bcf cur_depth_greater_100m ; current depth is now < 100 meter + + MOVLI .999,sub_a ; 999 mbar = 9.99 meter + MOVII mpr, sub_b ; current depth + call cmpU16 ; compare (sub_a - sub_b) + movlw ' ' ; load coding of a space char + btfss neg_flag ; current depth < 10 meter ? + movwf POSTINC2 ; YES - print a leading space char + + MOVLI .99,sub_a ; 99 mbar = 99 cm + MOVII mpr,sub_b ; current depth + call cmpU16 ; compare (sub_a - sub_b) + btfss neg_flag ; current depth < 1 meter ? + bra TFT_depth_metric_0m ; YES - (1) + bsf ignore_digit4 ; NO - show depth in full meters, i.e. ignore digits 4 and 5 + bsf leftbind ; - print left-aligned + output_16 ; - print depth + bcf leftbind ; - reset alignment + bra TFT_depth_metric_com ; - continue with common part +TFT_depth_metric_0m: + STRCAT "0" ; (1) - print a zero directly +TFT_depth_metric_com: + STRCAT_PRINT "" ; finalize output + + ; decimeters + rcall TFT_depth_position_dm ; set output position + PUTC "." ; print a decimal point + MOVLI .30,sub_a ; 30 mbar = 0.3 meter + MOVII mpr,sub_b ; current depth + call cmpU16 ; compare (sub_a - sub_b) + btfss neg_flag ; current depth < 0.3 meter ? + bra depth_0_decimeter ; YES - (2) + movlw d'4' ; NO - omit leading digits holding the meters + movwf ignore_digits ; - ... + bsf ignore_digit5 ; - omit last digit holding the centimeters + output_16dp d'0' ; - print decimeters only + STRCAT_PRINT "" ; - finalize output + bcf win_invert ; - reset invert flag + bra TFT_depth_exit ; - show target depth if in simulator mode and return +depth_0_decimeter: + STRCAT_PRINT "0" ; (2) - print a zero directly and finalize output + bcf win_invert ; - reset invert flag + bra TFT_depth_exit ; - show target depth if in simulator mode and return + +TFT_depth_metric_100m: ; show full meters only + btfss cur_depth_greater_100m ; was the current depth >= 100 meter during last call? + rcall TFT_depth_box_black ; NO - clear depth area + bsf cur_depth_greater_100m ; depth is >= 100 meter now + bsf ignore_digit4 ; show depth in full meters, i.e. ignore digits 4 and 5 + bsf leftbind ; print left-aligned + output_16 ; print depth + bcf leftbind ; reset alignment + STRCAT_PRINT "" ; finalize output + bcf win_invert ; reset invert flag + bra TFT_depth_exit ; show target depth if in simulator mode and return TFT_depth_blink: - TSTOSS opt_modwarning ; 0=standard, 1=blink - return - - ; check if previous cycle had the blinking warning or not - btfsc blinking_depth_prev ; did we have warning previously? - bra TFT_depth_blink_prevwarn; YES - - ; NO - check if it's set now - btfsc blinking_depth_warning ; do we have warning set now? - bra TFT_depth_blink_warn ; YES - so we have warning now but not previously - btfsc blinking_depth_attention; do we have attention set now? - bra TFT_depth_blink_warn ; YES - so we have attention now but not previously - - ; no warning in previous cycle, no warning now, reset all flags - bcf blinking_depth_prev ; reset previous flag - bcf blinking_depth_toggle ; reset toggle - bcf win_invert - return ; all done - -TFT_depth_blink_prevwarn: - ; ...we had warning in previous cycle, check if we still have the warning set - btfsc blinking_depth_warning ; do we still have the warning? - bra TFT_depth_blink_prevwarn_1 ; YES - btfss blinking_depth_attention ; do we still have the attention? - bra TFT_depth_blink_prevwarn_nowarn ; NO - clear the depth area -TFT_depth_blink_prevwarn_1: - ; we still have the warning, set previous flag for next cycle... - bsf blinking_depth_prev ; set prev flag - ; and set toggle and invert if required - btfss blinking_depth_toggle ; do we have the toggle set? - bra TFT_depth_blink_set ; NO - set inverse, do color_box, set flag - bra TFT_depth_blink_reset ; Yes - clear inverse, do black box, reset flag - -TFT_depth_blink_prevwarn_nowarn: - ; we had warning, but not now... (e.g. ascended or switched to better gas) - ; reset the previous cycle flag for the next cycle... - bcf blinking_depth_prev ; reset prev flag - ; clear it - just in case if we had a blinked before - bra TFT_depth_blink_reset ; clear inverse, do black box, reset flag - -TFT_depth_blink_warn: - ; new blinking warning activated (had no warning in previous cycle) - bsf blinking_depth_prev ; set prev flag - ;bra TFT_depth_blink_set ; set toggle and invert + TSTOSS opt_modwarning ; 0=standard, 1=blink + return ; standard, done + btfsc depth_warn_att_last ; was there a warning or attention on the depth in the previous cycle? + bra TFT_depth_blink_prev ; YES + btfsc depth_warning ; NO - do we have a depth warning now? + bra TFT_depth_blink_new ; YES - so we have a warning now but not previously + btfsc depth_attention ; NO - do we have a depth attention now? + bra TFT_depth_blink_new ; YES - so we have attention now but not previously + bra TFT_depth_blink_none ; NO - no warning in previous cycle, no warning now, reset all flags + +TFT_depth_blink_prev: + ; we had a warning or attention in previous cycle, check if we still have a warning or attention + btfsc depth_warning ; do we still have a warning? + bra TFT_depth_blink_prev_1 ; YES + btfsc depth_attention ; NO - do we still have an attention? + bra TFT_depth_blink_prev_1 ; YES + ; we had a warning or attention before, but not now any more - clear depth area from previous color + rcall TFT_depth_box_black ; NO - clear depth area + ;bra TFT_depth_blink_none ; - reset all flags + +TFT_depth_blink_none: + bcf win_invert ; print non-inverted + bcf depth_inverse_last ; memorize depth was printed in normal + bcf depth_warn_att_last ; memorize there was no warning or attention + goto TFT_memo_color ; select memo color and return + +TFT_depth_blink_prev_1: + ; we had a warning or attention in previous cycle, and we still have a warning or attention + btfss depth_inverse_last ; was the depth printed in inverse last time? + bra TFT_depth_blink_set ; NO - print in inverse now + bra TFT_depth_blink_reset ; YES - print in normal now + +TFT_depth_blink_new: + ; we had no warning or attention in previous cycle, but now + bsf depth_warn_att_last ; memorize that the depth had a warning or attention + ;bra TFT_depth_blink_set ; start with inverse display TFT_depth_blink_set: - ; clear the area with color - call TFT_attention_color_dive ; default background to attention color - btfsc blinking_depth_warning ; in warning mode? - call TFT_warnings_color_dive ; overwrite background color with warning color - WIN_BOX_COLOR dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt ;top, bottom, left, right - bsf win_invert ;set the invert color - bsf blinking_depth_toggle ; set the toggle - return ; all done + ; fill the area with respective color + call TFT_attention_color_dive ; select attention color as default + btfsc depth_warning ; do we have a warning? + call TFT_warnings_color_dive ; YES - replace with warning color + rcall TFT_depth_box_color ; color depth area + bsf win_invert ; print in inverse + bsf depth_inverse_last ; memorize depth was printed in inverse + return ; done TFT_depth_blink_reset: - ; clear the area with black - WIN_BOX_BLACK dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt ;top, bottom, left, right - bcf win_invert ; reset the invert color - bcf blinking_depth_toggle ; reset the toggle - call TFT_attention_color ; default to attention color - btfsc blinking_depth_warning ; do we have a warning? - call TFT_warnings_color ; YES - overwrite with warning color - return ; all done + ; fill the area with black color + rcall TFT_depth_box_black ; clear depth area + bcf win_invert ; print non-inverted + bcf depth_inverse_last ; memorize depth was printed in normal + return ; done + + +TFT_depth_position_m_ft: + btfsc alt_layout_active ; alternative layout active? + bra TFT_depth_position_m_ft_alt ; YES - (1) + WIN_LARGE dm_depth_col_large,dm_depth_row_large ; NO - normal layout + return ; - done +TFT_depth_position_m_ft_alt: + WIN_HUGE dm_depth_col_huge, dm_depth_row_huge ; (1) - alternative layout + return ; - done + +TFT_depth_position_dm: + btfsc alt_layout_active ; alternative layout active? + bra TFT_depth_position_dm_alt ; YES - (1) + WIN_MEDIUM dm_depth_dm_col_medium, dm_depth_dm_row_medium ; NO - normal layout + return ; - done +TFT_depth_position_dm_alt: + WIN_LARGE dm_depth_dm_col_large, dm_depth_dm_row_large ; (1) - alternative layout + return ; - done + +TFT_depth_box_black: + clrf WREG ; select black color +TFT_depth_box_color: + movff win_color1,mpr+2 ; backup output color + movff win_color2,mpr+3 ; ... + btfsc alt_layout_active ; alternative layout active? + bra TFT_depth_box_alt ; YES - (1) + WIN_BOX_COLOR dm_depth_row_large,dm_depth_bot_large,dm_depth_col_large,dm_depth_rgt_large ; NO - top, bottom, left, right + bra TFT_depth_box_exit ; - continue with common part +TFT_depth_box_alt: + WIN_BOX_COLOR dm_mask_depth_row, dm_depth_bot_huge, dm_depth_col_huge, dm_depth_rgt_huge ; (1) - full meters area +TFT_depth_box_exit: + movff mpr+2,win_color1 ; restore output color + movff mpr+3,win_color2 ; ... + return ; done + +TFT_depth_exit: + btfss alt_layout_active ; alternative layout active? + bra TFT_depth_exit_1 ; NO + btfsc depth_inverse_last ; YES - was last output in inverse mode? + bra TFT_depth_exit_1 ; YES + call TFT_divemask_color ; NO - set color + WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; - set position + STRCAT_TEXT_PRINT tDepth ; - restore "Depth" title +TFT_depth_exit_1: + btfss sensor_override_active ; pressure sensor override active (simulator mode)? + goto TFT_standard_color ; NO - done + ;bra TFT_depth_target ; YES - show target depth + +TFT_depth_target: ; show simulated target depth + call TFT_attention_color ; select attention color + TSTOSS opt_units ; check unit selection (0=m or 1=ft) + bra TFT_depth_target_metric ; 0 - metric + ;bra TFT_depth_target_imperial ; 1 - imperial + +TFT_depth_target_imperial: + btfsc alt_layout_active ; alternative layout active? + bra TFT_depth_target_imperial_alt ; YES + ;bra TFT_depth_target_imperial_norm ; NO + +TFT_depth_target_imperial_norm: + WIN_TINY dm_mask_depth_column+.40,dm_mask_depth_row ; position right of depth label + bra TFT_depth_target_imperial_com ; continue with common part + +TFT_depth_target_imperial_alt: + WIN_TINY dm_mask_depth_column+.62,dm_mask_depth_row+.20 ; position within last digit + ;bra TFT_depth_target_imperial_com ; continue with common part + +TFT_depth_target_imperial_com: + movff simulatormode_depth,lo ; copy target depth to lo + call convert_meter_to_feet ; convert value in lo from meters to feet + output_16_3 ; display only last three digits from a 16 bit value (0-999) + STRCAT_PRINT "ft" ; finalize output + goto TFT_standard_color ; done + +TFT_depth_target_metric: + btfsc alt_layout_active ; alternative layout active? + bra TFT_depth_target_metric_alt ; YES + ;bra TFT_depth_target_metric_norm ; NO + +TFT_depth_target_metric_norm: + WIN_TINY dm_mask_depth_column+.38,dm_mask_depth_row+.22 ; position right of full meters, above decimal + bra TFT_depth_target_metric_com ; continue with common part + +TFT_depth_target_metric_alt: + WIN_TINY dm_mask_depth_column+.65,dm_mask_depth_row+.20 ; position right of full meters, above decimal + ;bra TFT_depth_target_metric_com ; continue with common part + +TFT_depth_target_metric_com: + movff simulatormode_depth,lo ; copy target depth to lo + output_8 ; display number + STRCAT_PRINT "m" ; finalize output + goto TFT_standard_color ; done ;============================================================================= global TFT_custom_text TFT_custom_text: ; show the custom text - call TFT_standard_color lfsr FSR0, opt_name ; source WIN_SMALL surf_customtext_column,surf_customtext_row1 ; 1st row rcall TFT_custom_text_2 ; show up to 12 chars and print @@ -2529,8 +2723,7 @@ return ; NO - all done lfsr FSR0, opt_name+.48 ; source WIN_SMALL surf_customtext_column,surf_customtext_row5 ; 5th row - bra TFT_custom_text_2 ; show up to 12 chars, print and return... - + ;bra TFT_custom_text_2 ; show up to 12 chars, print and return... TFT_custom_text_2: lfsr FSR2, buffer ; destination @@ -2550,28 +2743,24 @@ ;============================================================================= - global TFT_update_surf_press -TFT_update_surf_press: + global TFT_pres_surfmode +TFT_pres_surfmode: WIN_SMALL surf_press_column+.8,surf_press_row call TFT_standard_color - SAFE_2BYTE_COPY amb_pressure, lo - movff lo,sub_a+0 - movff hi,sub_a+1 - movff last_surfpressure_30min+0,sub_b+0 - movff last_surfpressure_30min+1,sub_b+1 + SMOVII pressure_abs, sub_a ; make ISR-safe 2 byte copy of current absolute pressure to sub_a + MOVII pressure_abs_ref,sub_b ; copy absolute pressure from 30 minutes ago to sub_b + MOVII sub_a,mpr ; store current pressure also in hi:lo for output call subU16 ; sub_c = sub_a - sub_b btfsc neg_flag ; pressure lower? - rcall update_surf_press2 ; YES - test threshold - tstfsz sub_c+1 ; >255 mbar difference? + rcall update_surf_press2 ; YES - swap arguments + tstfsz sub_c+1 ; > 255 mbar difference? bra update_surf_press_common ; YES - display - movlw d'11' ; 10mbar noise suppression + movlw .11 ; 10 mbar noise suppression margin subwf sub_c+0,W btfsc STATUS,C bra update_surf_press_common ; YES - display - SAFE_2BYTE_COPY last_surfpressure_30min, lo ; overwrite with stable value... + MOVII pressure_abs_ref,mpr ; NO - overwrite with stable value update_surf_press_common: - movff lo,int_I_pres_surface+0 ; copy displayed value to C code to have pressure displayed - movff hi,int_I_pres_surface+1 ; and pressure used for desaturation & no-fly time in sync output_16 ; Show only 4 digits movff buffer+1,buffer+0 @@ -2587,37 +2776,32 @@ return update_surf_press2: - movff lo,sub_b+0 - movff hi,sub_b+1 - movff last_surfpressure_30min+0,sub_a+0 - movff last_surfpressure_30min+1,sub_a+1 + MOVII sub_a,sub_b + MOVII pressure_abs_ref,sub_a goto subU16 ; sub_c = sub_a - sub_b and return... ;============================================================================= - global TFT_update_batt_voltage -TFT_update_batt_voltage: - movff batt_percent,lo ; get battery percent + global TFT_batt_surfmode +TFT_batt_surfmode: + ; color-code according to battery percent + movff batt_percent,lo clrf hi - call TFT_color_code_battery ; color-code battery percent - ; Setup charge indicator - btfsc cc_active - bsf win_invert - btfsc cc_active - movlw color_yellow - btfsc cv_active - movlw color_green - btfsc cc_active - call TFT_set_color - - ; Setup Temperature warning - btfsc battery_overtemp - bsf win_invert - btfsc battery_overtemp - movlw color_red - btfsc battery_overtemp - call TFT_set_color - + call TFT_color_code_battery + + ; set up charging indicator and temperature warning + clrf WREG ; default to no indication/warning + btfsc cc_active ; charging in CC mode? + movlw color_yellow ; YES - set output color to yellow + btfsc cv_active ; charging in CV mode? + movlw color_green ; YES - set output color to green + btfsc battery_overtemp ; battery over-temperature detector tripped? + movlw color_red ; YES - set output color to red + tstfsz WREG ; any indicator or warning active? + bsf win_invert ; YES - set output to inverse + tstfsz WREG ; any indicator or warning active (asked again)? + call TFT_set_color ; YES - set color + IFDEF _ostc_logo WIN_TINY batt_percent_column,batt_percent_row ELSE @@ -2640,8 +2824,7 @@ bsf leftbind output_8 PUTC ":" - movff batt_voltage+0,lo - movff batt_voltage+1,hi + MOVII batt_voltage,mpr output_16dp .2 bcf leftbind PUTC 'V' @@ -2662,17 +2845,12 @@ ; ; devide through 65536 ; ; devide through 152 ; ; Result is 0.01Ah in xC+1:xC+0 -; movlw LOW .152 -; movwf xB+0 -; movlw HIGH .152 -; movwf xB+1 -; call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder +; MOVLI .152,xB +; call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder ; bsf leftbind -; movff xC+0,lo -; movff xC+1,hi +; MOVII xC,mpr ; output_16 -; STRCAT_PRINT "x.01Ah" -; WIN_FONT FT_SMALL +; STRCAT_PRINT "x.01Ah" ; bcf leftbind ; return @@ -2680,13 +2858,13 @@ global TFT_convert_signed_16bit TFT_convert_signed_16bit: - bcf neg_flag ; positive temperature - btfss hi,7 ; negative temperature ? - return ; NO - return - ; YES - negative temperature - bsf neg_flag ; negative temperature - PUTC '-' ; display "-" - comf hi ; 16 bit sign change + bcf neg_flag ; clear flag for negative number by default + btfss hi,7 ; negative number? + return ; NO - done + ; YES + bsf neg_flag ; set flag for negative number + PUTC '-' ; display a minus sign ("-") + comf hi ; complement hi:lo negf lo btfsc STATUS,C incf hi @@ -2695,16 +2873,16 @@ ;============================================================================= global TFT_convert_date -TFT_convert_date: ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 +TFT_convert_date: ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD movwf EEDATA ; used as temp here tstfsz EEDATA bra TFT_convert_date_1 ; opt_dateformat is 1 or 2 ; opt_dateformat is 0 ; use MMDDYY - movff lo,lo_temp ; incoming: lo = day, hi = month + movff lo,hy ; incoming: lo = day, hi = month movff hi,lo ; swap - movff lo_temp,hi ; now: lo = month, hi = day + movff hy,hi ; now: lo = month, hi = day bra TFT_convert_date_common TFT_convert_date_1: @@ -2727,15 +2905,15 @@ TFT_convert_date_2: ; opt_dateformat is 2 ; use YYMMDD - movff lo,lo_temp ; incoming: lo = day, up = year + movff lo,hy ; incoming: lo = day, up = year movff up,lo ; swap - movff lo_temp,up ; now : lo = year, up = day + movff hy,up ; now : lo = year, up = day bra TFT_convert_date_common ;============================================================================= global TFT_convert_date_short -TFT_convert_date_short: ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 +TFT_convert_date_short: ; convert into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD movwf EEDATA ; used as temp here tstfsz EEDATA @@ -2743,14 +2921,14 @@ ; opt_dateformat is 0 ; use MMDD(YY) TFT_convert_date_short_0: - movff lo,lo_temp ; incoming: lo = day, hi = month + movff lo,hy ; incoming: lo = day, hi = month movff hi,lo ; swap - movff lo_temp,hi ; now: lo = month, hi = day + movff hy,hi ; now: lo = month, hi = day bra TFT_convert_date_short_common TFT_convert_date_short_1: decfsz EEDATA,F - bra TFT_convert_date_short_0 ; opt_dateformat is 2 -> use (YY)MMDD + bra TFT_convert_date_short_0; opt_dateformat is 2 -> use (YY)MMDD ; opt_dateformat is 1 ; use DDMM(YY) TFT_convert_date_short_common: @@ -2764,359 +2942,357 @@ ;============================================================================= - global TFT_date -TFT_date: - WIN_SMALL surf_date_column,surf_date_row ; init new wordprocessor + global TFT_date_surfmode +TFT_date_surfmode: + WIN_SMALL surf_date_column,surf_date_row call TFT_standard_color - movff day,lo - movff month,hi - movff year,up - call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 + SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time + movff rtc_latched_day,lo + movff rtc_latched_month,hi + movff rtc_latched_year,up + call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 STRCAT_PRINT "" return ;============================================================================= - global TFT_max_depth_alternative -TFT_max_depth_alternative: - bcf FLAG_TFT_max_depth - ; The "mask" - call TFT_divemask_color - WIN_TINY dm_mask_depth_column, dm_max_alt_row-.14 - btfsc FLAG_apnoe_mode ; in Apnea mode? - bra TFT_max_depth_alternative2 ; YES - always draw max depth - TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth? - bra TFT_max_depth_alternative2 ; NO - draw max depth - STRCAT_TEXT_PRINT tAvgDepth ; YES - print avg depth mask - movff avg_rel_pressure_total+0,lo ; - get avg depth, low byte - movff avg_rel_pressure_total+1,hi ; - high byte - bra TFT_max_depth_alternative3 -TFT_max_depth_alternative2: - STRCAT_TEXT_PRINT tMaxDepth ; print max depth mask - SAFE_2BYTE_COPY max_pressure, lo ; get max depth into hi:lo -TFT_max_depth_alternative3: - call adjust_depth_with_salinity ; compute salinity setting into lo:hi [mbar] - call TFT_memo_color - WIN_LARGE dm_max_alt_column,dm_max_alt_row - TSTOSS opt_units ; 0=m or 1=ft? - bra TFT_max_depth_alt_metric ; 0 - use alternative metric version - bra TFT_max_depth_imperial ; 1 - use common imperial version -TFT_max_depth_alt_metric: - movff hi,sub_b+1 ; backup hi in sub_b+1 - movff lo,sub_b+0 ; backup lo in sub_b+0 - bsf ignore_digit4 ; no 0.1 m - output_16 - STRCAT_PRINT "" - WIN_MEDIUM dm_max_dm_alt_column,dm_max_alt_row+.25 - bra TFT_max_depth_metric3 ; continue with normal metric version for decimal - - - global TFT_max_depth -TFT_max_depth: - bcf FLAG_TFT_max_depth - btfsc FLAG_apnoe_mode ; in Apnoe mode? - bra TFT_max_depth1 ; YES - different handling in Apnoe mode - TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth? - bra TFT_max_depth2 ; NO - show max depth - movff avg_rel_pressure_total+0,lo ; YES - get avg depth, low byte - movff avg_rel_pressure_total+1,hi ; - high byte - bra TFT_max_depth3 -TFT_max_depth1: - btfss FLAG_active_descent ; are we descending? - bra TFT_max_depth2 ; NO - show normal max - SAFE_2BYTE_COPY apnoe_max_pressure,lo ; YES - get apnoe_max_pressure - bra TFT_max_depth3 -TFT_max_depth2: - SAFE_2BYTE_COPY max_pressure,lo ; get the "normal" max depth -TFT_max_depth3: - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] - movlw .039 ; load encoding for 99.84 m - cpfslt hi ; is depth to show > 99.84 m ? - bra TFT_max_depth3a ; YES - btfss max_depth_greater_100m ; NO - was depth > 100 m during last call? - bra TFT_max_depth3c ; NO - bcf max_depth_greater_100m ; YES - clear flag, last depth shown now not > 100 m anymore - bra TFT_max_depth3b ; - clear depth area -TFT_max_depth3a: - btfsc max_depth_greater_100m ; YES - was depth > 100 m during last call? - bra TFT_max_depth3c ; YES - bsf max_depth_greater_100m ; NO - set flag, last depth shown now > 100 m - ;bra TFT_max_depth3b ; - clear depth area -TFT_max_depth3b: - WIN_BOX_BLACK dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt ; top, bottom, left, right -TFT_max_depth3c: - call TFT_memo_color ; set output color + global TFT_show_max_depth +TFT_show_max_depth: + btfsc alt_layout_active ; alternative layout active? + bra TFT_show_max_depth_alt ; YES + WIN_MEDIUM dm_max_depth_column_nvsi, dm_max_depth_row TSTOSS opt_vsigraph ; graphical VSI bar enabled? - bra TFT_max_depth4 ; NO - WIN_MEDIUM dm_max_depth_column, dm_max_depth_row ; YES - adopt output position -TFT_max_depth4: + bra TFT_show_max_depth_1 ; NO - keep position + ; YES - adopt output position + WIN_MEDIUM dm_max_depth_column, dm_max_depth_row + +TFT_show_max_depth_1: + btfsc FLAG_apnoe_mode ; in apnoe mode? + bra TFT_max_depth_apnoe ; YES - different handling in apnoe mode + + TSTOSS opt_2ndDepthDisp ; show average depth instead of max depth? + bra TFT_max_depth_current ; NO - show max depth + ;bra TFT_avg_depth_current ; YES - show avg depth + +TFT_avg_depth_current: + MOVII pressure_rel_avg_total,mpr ; YES - get total dive average depth + bra TFT_max_depth_common ; - continue with common part + +TFT_max_depth_apnoe: + btfss apnoe_at_surface ; apnoe mode, at the surface? + bra TFT_max_depth_current ; NO - show max depth of current dive + MOVII apnoe_max_pressure,mpr ; YES - show max depth of all dives so far + bra TFT_max_depth_common ; - continue with common part + +TFT_max_depth_current: + MOVII pressure_rel_max_cached,mpr ; get the "normal" max depth in mbar = cm + ;bra TFT_max_depth_common ; continue with common part + +TFT_max_depth_common: + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] TSTOSS opt_units ; 0=m or 1=ft ? bra TFT_max_depth_metric ; 0 - use metric version -TFT_max_depth_imperial: ; 1 - use imperial version + ;bra TFT_max_depth_imperial ; 1 - use imperial version + +TFT_max_depth_imperial: call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet - output_16_3 - bra TFT_max_depth_exit + call TFT_memo_color ; set output color + output_16_3 ; print depth + bra TFT_max_depth_finish ; finish output + TFT_max_depth_metric: - btfss max_depth_greater_100m ; depth to show > 100 m ? - bra TFT_max_depth_metric0 ; NO - show meters and decimeters - bsf ignore_digit4 ; YES - show full meters only, i.e. ignore digits 4 and 5 - bsf leftbind - output_16 - bra TFT_max_depth_exit -TFT_max_depth_metric0: - movff hi,sub_b+1 ; copy hi to sub_b+1, will also be used to back-up hi - movff lo,sub_b+0 ; copy lo to sub_b+0, will also be used to back-up lo - - movlw HIGH d'999' - movwf sub_a+1 - movlw LOW d'999' - movwf sub_a+0 - call sub16 ; sub_c = sub_a - sub_b - movlw ' ' - btfss neg_flag ; depth lower than 10m ? - movwf POSTINC2 ; YES - add extra space - - clrf sub_a+1 - movlw d'99' - movwf sub_a+0 - call subU16 ; sub_c = sub_a - sub_b - btfss neg_flag ; depth lower than 1m ? - bra TFT_max_depth_metric1 ; YES - manually display a zero - bsf ignore_digit4 ; NO - no 0.1 m + MOVLI .9999,sub_a ; 9999 mbar = 99.99 m + MOVII mpr, sub_b ; depth, also used to back-up hi:lo + call cmpU16 ; sub_a - sub_b = 99.99 - depth + btfsc neg_flag ; depth < 100 meter ? + bra TFT_max_depth_greater_100m ; NO - greater than 100 m + ;bra TFT_max_depth_shallower_100m; YES - shallower than 100 m + +TFT_max_depth_shallower_100m: + btfss max_depth_greater_100m ; was depth >= 100 m during last call? + bra TFT_max_depth_metric_show ; NO - show depth + bcf max_depth_greater_100m ; YES - clear flag, last depth shown now not > 99.84 m anymore + bra TFT_max_depth_clear ; - clear depth area + +TFT_max_depth_greater_100m: + btfsc max_depth_greater_100m ; was depth >= 100 m during last call? + bra TFT_max_depth_metric_show ; YES - show depth + bsf max_depth_greater_100m ; NO - set flag, last depth shown now > 99.84 m + ;bra TFT_max_depth_clear ; - clear depth area + +TFT_max_depth_clear: + WIN_BOX_BLACK dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt ; top, bottom, left, right + ;bra TFT_max_depth_metric_show + +TFT_max_depth_metric_show: + call TFT_memo_color ; set output color + btfss max_depth_greater_100m ; depth to show >= 100 m ? + bra TFT_max_depth_metric_m_dm ; NO - show meters and decimeters + bsf ignore_digit4 ; YES - crop decimeters and centimeters + bsf leftbind ; - print left-aligned + output_16 ; - print depth + bra TFT_max_depth_finish ; - finish output + +TFT_max_depth_metric_m_dm: + MOVLI .999,sub_a ; load 9.99 meter + call cmpU16 ; sub_a - sub_b = 9.99 - depth + movlw ' ' ; load a space character + btfss neg_flag ; depth shallower than 10 meter ? + movwf POSTINC2 ; YES - add the space character + MOVLI .99,sub_a ; load 0.99 m + call cmpU16 ; sub_a - sub_b = 0.99 m - depth + btfss neg_flag ; depth shallower than 1 meter ? + bra TFT_max_depth_metric_zero ; YES - manually display a zero + bsf ignore_digit4 ; NO - crop decimeters and centimeters bsf leftbind ; - align left output_16 ; - display full meters - bra TFT_max_depth_metric2 -TFT_max_depth_metric1: - STRCAT "0" ; display a zero -TFT_max_depth_metric2: - STRCAT_PRINT "" - ; .1 m in SMALL font + STRCAT_PRINT "" ; - finalize output + bra TFT_max_depth_metric_dm ; - continue with decimeters + +TFT_max_depth_metric_zero: + STRCAT_PRINT "0" ; print a zero + ;bra TFT_max_depth_metric_dm ; continue with decimeters + +TFT_max_depth_metric_dm: WIN_SMALL dm_max_depth_dm_column_nvsi, dm_max_depth_dm_row TSTOSS opt_vsigraph ; graphical VSI bar enabled? - bra TFT_max_depth_metric3 ; NO - WIN_SMALL dm_max_depth_dm_column, dm_max_depth_dm_row ; YES - adopt position -TFT_max_depth_metric3: - movff sub_b+1,hi ; restore hi - movff sub_b+0,lo ; restore lo + bra TFT_max_depth_metric_dm_1 ; NO - keep position + ; YES - adopt position + WIN_SMALL dm_max_depth_dm_column, dm_max_depth_dm_row +TFT_max_depth_metric_dm_1: PUTC "." ; print decimal point - movlw d'4' - movwf ignore_digits - bsf ignore_digit5 ; no 0.01 m, flag will be cleared by output_16 - bsf leftbind - output_16dp d'0' -TFT_max_depth_exit: - STRCAT_PRINT "" - bcf leftbind - goto TFT_standard_color ; and return... + MOVII sub_b,mpr ; restore depth in hi:lo + movlw d'4' ; crop leading 4 digits (don't show the full meters) + movwf ignore_digits ; ... + bsf ignore_digit5 ; crop last digit (no centimeters, flag will be cleared by output_16) + bsf leftbind ; print left-aligned + output_16dp d'0' ; print decimal +TFT_max_depth_finish: + STRCAT_PRINT "" ; finalize output + bcf leftbind ; back to default right alignment + goto TFT_standard_color ; done + + +TFT_show_max_depth_alt: + btfsc FLAG_apnoe_mode ; in apnoe mode? + bra TFT_show_apnoe_max_depth ; YES - use apnoe surface output also in alternative dive mode screen + btfsc FLAG_gauge_mode ; NO - in gauge mode? + bra TFT_show_gauge_max_avg_depth; YES - show both, max and avg depth + return ; NO - nothing to do + +TFT_show_gauge_max_avg_depth: + call TFT_memo_color ; set color + WIN_MEDIUM dm_gauge_max_depth_col, dm_gauge_max_depth_row ; set position for max depth + rcall TFT_show_gauge_max_depth ; show max depth + call TFT_memo_color ; set color + WIN_MEDIUM dm_gauge_avg_depth_col, dm_gauge_avg_depth_row ; set position for avg depth + MOVII pressure_rel_avg_total,mpr ; get average depth into hi:lo + bra TFT_show_gauge_depth ; show avg depth and return + + + global TFT_show_apnoe_max_depth +TFT_show_apnoe_max_depth: + ; title + WIN_TINY dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row + call TFT_divemask_color + btfsc alt_layout_active ; alternative layout active? + bra TFT_show_apnoe_max_depth_alt ; YES + STRCPY_TEXT_PRINT tApnoeMax ; NO - print "Last Descent" + bra TFT_show_apnoe_max_depth_com ; - continue with common part +TFT_show_apnoe_max_depth_alt: + STRCPY_TEXT_PRINT tMaxDepth ; print "Max.Depth" +TFT_show_apnoe_max_depth_com: + ; value + WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row + call TFT_memo_color +TFT_show_gauge_max_depth: + MOVII pressure_rel_max_cached,mpr ; get max depth into hi:lo +TFT_show_gauge_depth: + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] + TSTOSS opt_units ; 0=m, 1=ft + bra TFT_display_apnoe_last_m_metric ; 0 - metric +TFT_display_apnoe_last_max_imp: ; 1 - imperial + call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet + output_16 + bra TFT_max_depth_finish ; finish output +TFT_display_apnoe_last_m_metric: + bsf ignore_digit5 ; do not display centimeters (flag will be cleared by output_16) + output_16dp d'3' + bra TFT_max_depth_finish ; finish output ;============================================================================= - global TFT_divemins -TFT_divemins: - bcf FLAG_TFT_divemins ; clear flag - movff divemins+0,lo - movff divemins+1,hi - - ; Already showing divemins > 99min - btfsc no_more_divesecs ; ignore seconds? - bra TFT_divemins2 ; show minutes only - - tstfsz hi ; hi = 0? - bra TFT_divemins_clr ; NO - show mins only - - movlw .99 - cpfsgt lo ; bigger than 99? - bra TFT_divemins1 ; NO - show mins:secs - -TFT_divemins_clr: - ; YES - remove second display for the rest of the dive and clear seconds - bsf no_more_divesecs ; - set flag - ; - clear rest of seconds - WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot, dm_divetime_column, dm_divetime_rgt ;top, bottom, left, right - bra TFT_divemins2 ; - show minutes only - -TFT_divemins1: - ; Print out the minutes, up to 99 minutes, only 2 chars! - call TFT_memo_color - WIN_MEDIUM dm_divetime_column, dm_divetime_row - output_99 ; displays only last two figures from a 8 bit value (0-99) - STRCAT_PRINT "" ; show minutes in large font - - ; Print out the seconds - WIN_SMALL dm_divetime_secs_column, dm_divetime_secs_row ; left position for two sec figures - PUTC ':' - movff divesecs,lo - bsf leftbind - output_99x ; displays only last two figures from a 8 bit value with leading zero (00-99) - bra TFT_divemins_exit ; and return... - -TFT_divemins2: - ; Full minutes only - call TFT_memo_color - WIN_MEDIUM dm_divetime_minsonly_column, dm_divetime_row - bcf leftbind - output_16_4 - bra TFT_divemins_exit ; and return... - - - global TFT_divemins_alternative -TFT_divemins_alternative: - bcf FLAG_TFT_divemins ; clear flag - call TFT_memo_color - ; Print out the minutes (0-999) in large - WIN_LARGE dm_divetime_alt_column, dm_divetime_alt_row - movff divemins+0,lo - movff divemins+1,hi - output_16_3 ; limit to 999 and display only (0-999) - STRCAT_PRINT "" ; show minutes - ; Print out the seconds in medium - WIN_MEDIUM dm_divetime_alt_column+.60, dm_divetime_alt_row+.25 - PUTC ":" - movff divesecs,lo - bsf leftbind - output_99x ; displays only last two figures from a 8Bit value with leading zero (00-99) + global TFT_show_divetime +TFT_show_divetime: + call TFT_memo_color ; set color + SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 (mpr+1:mpr+0) and seconds (mpr+2) + btfsc show_only_divemins ; shall suppress display of seconds? + bra TFT_show_divetime_min_only ; YES - show minutes only + movlw .99 ; NO - load 99 + cpfsgt mpr+0 ; - dive time > 99 minutes ? + bra TFT_show_divetime_min_sec ; NO - show min:sec + bsf show_only_divemins ; YES - set flag to suppress the display of seconds for the rest of the dive + btfsc alt_layout_active ; - in alternative layout? + bra TFT_show_divetime_clear_alt ; YES - clear min:sec area of alternative layout + ;bra TFT_show_divetime_clear_norm ; NO - clear min:sec area of normal layout + +TFT_show_divetime_clear_norm: + WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_medium, dm_divetime_col_medium, dm_divetime_rgt ;top, bottom, left, right + bra TFT_show_divetime_min_only_norm ; show minutes only + +TFT_show_divetime_clear_alt: + WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_large, dm_divetime_col_large, dm_divetime_rgt ;top, bottom, left, right + bra TFT_show_divetime_min_only_alt ; show minutes only + +TFT_show_divetime_min_sec: + ; show the minutes + btfsc alt_layout_active ; in alternative layout? + bra TFT_show_divetime_min_alt ; YES + ;bra TFT_show_divetime_min_norm ; NO + +TFT_show_divetime_min_norm: + WIN_MEDIUM dm_divetime_col_medium, dm_divetime_row + bra TFT_show_divetime_min_com ; continue with common part + +TFT_show_divetime_min_alt: + WIN_LARGE dm_divetime_col_large, dm_divetime_row + ;bra TFT_show_divetime_min_com ; continue with common part + +TFT_show_divetime_min_com: + output_99 ; displays only last two digits from a 8 bit value (0-99) + STRCAT_PRINT "" ; finalize output + + ; show the seconds + btfsc alt_layout_active ; in alternative layout? + bra TFT_show_divetime_sec_alt ; YES + ;bra TFT_show_divetime_sec_norm ; NO + +TFT_show_divetime_sec_norm: + WIN_SMALL dm_divetime_sec_col_small, dm_divetime_sec_row_small + bra TFT_show_divetime_sec_com ; continue with common part + +TFT_show_divetime_sec_alt: + WIN_MEDIUM dm_divetime_sec_col_medium, dm_divetime_sec_row_medium + ;bra TFT_show_divetime_sec_com ; continue with common part + +TFT_show_divetime_sec_com: + PUTC ':' ; print separator char + movff mpr+2,lo ; copy seconds to lo + bsf leftbind ; activate left-alignment + output_99x ; displays only last two figures from a 8 bit value with leading zero (00-99) + bcf leftbind ; deactivate left-alignment + bra TFT_divemins_exit ; continue with common part + +TFT_show_divetime_min_only: + btfsc alt_layout_active ; in alternative layout? + bra TFT_show_divetime_min_only_alt ; YES + ;bra TFT_show_divetime_min_only_norm ; NO + +TFT_show_divetime_min_only_norm: + WIN_MEDIUM dm_divetime_minonly_col_medium, dm_divetime_row + output_16_4 ; print minutes (4 digits) + bra TFT_divemins_exit ; continue with common part + +TFT_show_divetime_min_only_alt: + WIN_LARGE dm_divetime_minonly_col_large, dm_divetime_row + output_16_3 ; print minutes (3 digits) + ;bra TFT_divemins_exit ; continue with common part + TFT_divemins_exit: - STRCAT_PRINT "" - bcf leftbind - goto TFT_standard_color ; and return... + STRCAT_PRINT "" ; finalize output + goto TFT_standard_color ; and return... ;============================================================================= - global TFT_display_apnoe_surface -TFT_display_apnoe_surface: - btfsc menuview ; is the options menu shown? - bra TFT_display_apnoe_surface_1 ; YES - skip title + global TFT_show_apnoe_surface +TFT_show_apnoe_surface: call TFT_divemask_color WIN_TINY dm_apnoe_surface_time_text_col, dm_apnoe_surface_time_text_row STRCPY_TEXT_PRINT tApnoeSurface -TFT_display_apnoe_surface_1: call TFT_memo_color WIN_MEDIUM dm_apnoe_surface_time_column, dm_apnoe_surface_time_row - movff apnoe_surface_mins,lo + SMOVII apnoe_surface_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi output_8 PUTC ':' - movff apnoe_surface_secs,lo + movff hi,lo ; copy seconds to lo output_99x - bra TFT_display_apnoe_exit ; and return... - - - global TFT_display_apnoe_last_max -TFT_display_apnoe_last_max: - call TFT_divemask_color - WIN_TINY dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row - STRCPY_TEXT_PRINT tApnoeMax + bra TFT_display_apnoe_exit ; and return... + + + global TFT_show_apnoe_times +TFT_show_apnoe_times: ; descent dive time + ; current dive time call TFT_memo_color - SAFE_2BYTE_COPY max_pressure, lo - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] - TSTOSS opt_units ; 0=m, 1=ft - bra TFT_display_apnoe_last_m_metric -TFT_display_apnoe_last_max_imp: - call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet - WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row - output_16 - bra TFT_max_depth_exit -TFT_display_apnoe_last_m_metric: - WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row - bsf ignore_digit5 ; do not display 1cm depth (flag will be cleared by output_16) - output_16dp d'3' - bra TFT_max_depth_exit - - - global TFT_display_apnoe_descent -TFT_display_apnoe_descent: ; descent divetime - movff apnoe_mins,lo - clrf hi - WIN_MEDIUM dm_divetime_apnoe_column, dm_divetime_apnoe_row - output_16_3 ; displays only last three figures from a 16Bit value (0-999) - call TFT_memo_color - STRCAT_PRINT "" ; show minutes in large font - WIN_SMALL dm_divetime_apnoe_secs_column, dm_divetime_apnoe_secs_row ; left position for two sec figures + WIN_MEDIUM dm_divetime_apnoe_col, dm_divetime_apnoe_row + SMOVII apnoe_dive_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi + output_99 ; display 0-99 + STRCAT_PRINT "" ; show minutes + WIN_SMALL dm_divetime_apnoe_secs_col, dm_divetime_apnoe_secs_row ; left position for two sec figures PUTC ':' bsf leftbind - movff apnoe_secs,lo + movff hi,lo ; copy seconds to lo output_99x - STRCAT_PRINT "" ; show seconds in small font - call TFT_divemask_color - WIN_TINY dm_total_apnoe_text_column,dm_total_apnoe_text_row - STRCPY_TEXT_PRINT tApnoeTotal - call TFT_memo_color - movff divemins,lo + STRCAT_PRINT "" ; show seconds + ; overall dive time + WIN_MEDIUM dm_apnoe_total_divetime_col, dm_apnoe_total_divetime_row + SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 and seconds clrf hi - WIN_MEDIUM dm_apnoe_total_divetime_column, dm_apnoe_total_divetime_row bcf leftbind - output_16_3 ; displays only last three figures from a 16Bit value (0-999) - call TFT_memo_color - STRCAT_PRINT "" ; show minutes in large font - WIN_SMALL dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row ; left position for two sec figures + output_16_3 ; displays only last three figures from a 16 bit value (0-999) + STRCAT_PRINT "" ; show minutes in large font + WIN_SMALL dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row ; left position for two sec figures PUTC ':' bsf leftbind - movff divesecs,lo + movff up,lo ; copy minutes from up to lo output_99x TFT_display_apnoe_exit: STRCAT_PRINT "" bcf leftbind - goto TFT_standard_color ; and return... - - - global TFT_apnoe_clear_surface -TFT_apnoe_clear_surface: - ; clear surface timer (TODO: partly wipes out options menu, too) - WIN_BOX_BLACK dm_apnoe_surface_time_text_row, .239, dm_apnoe_surface_time_text_col, .159 ; top, bottom, left, right - return - - -;============================================================================= -; append firmware version to current string, including color-coding - - global TFT_cat_firmware -TFT_cat_firmware: - movlw softwareversion_x - movwf lo - bsf leftbind - output_8 - PUTC '.' - movlw softwareversion_y - movwf lo - output_99x - bcf leftbind - rcall check_expiry - btfss aux_flag - return - bsf win_invert - goto TFT_attention_color - -;============================================================================= + goto TFT_standard_color ; and return... + + + global TFT_clear_apnoe_surface +TFT_clear_apnoe_surface: + ; clear surface data + WIN_BOX_BLACK dm_apnoe_last_max_depth_text_row, .239, dm_apnoe_last_max_depth_column, .159 ; top, bottom, left, right + goto TFT_standard_color ; and return... + + +;----------------------------------------------------------------------------- ; check if firmware is within expiry period, will return aux_flag set if not check_expiry: ; check if it is time for a firmware update + SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time + movff rtc_latched_day,lo ; get current day + movff rtc_latched_month,hi ; get current month + movff rtc_latched_year,up ; get current year bsf aux_flag ; set firmware as expired by default movlw firmware_expire_year ; start with checking year - cpfsgt year ; current year > expiry year ? + cpfsgt up ; current year > expiry year ? bra check_expiry_Y ; NO - continue checks return ; YES - expired check_expiry_Y: - cpfseq year ; current year = expiry year ? + cpfseq up ; current year = expiry year ? bra check_expiry_ok ; NO - must be < then, OK whatever month & day movlw firmware_expire_month ; YES - continue checking month - cpfsgt month ; current month > expiry month ? + cpfsgt hi ; current month > expiry month ? bra check_expiry_M ; NO - continue checks return ; YES - expired check_expiry_M: - cpfseq month ; current month = expiry month ? + cpfseq hi ; current month = expiry month ? bra check_expiry_ok ; NO - must be < then, OK whatever day movlw firmware_expire_day ; YES - continue checking day - cpfsgt day ; current day > expiry day ? + cpfsgt lo ; current day > expiry day ? bra check_expiry_ok ; NO - must be <= then, OK return ; YES - expired check_expiry_ok: bcf aux_flag return -;============================================================================= +;----------------------------------------------------------------------------- ; append firmware BETA status to current string, including color-coding - global TFT_cat_beta_rel global TFT_cat_beta_release TFT_cat_beta_release: ; entry point for printing "Release" / "Beta #" bsf aux_flag @@ -3124,9 +3300,14 @@ TFT_cat_beta_rel: ; entry point for printing "Rel." / "B. #" bcf aux_flag TFT_cat_beta_common: - IFDEF __DEBUG - STRCAT "DBG " - goto TFT_warnings_color + IFDEF _DEBUG + btfss aux_flag ; shall show long version? + bra TFT_cat_debug_short ; NO - show short version + STRCAT "DEBUG" ; YES - show long version + goto TFT_warning_color ; - set color +TFT_cat_debug_short: + STRCAT "DBG." ; show short version + goto TFT_warning_color ; set color ELSE movlw softwareversion_beta ; =0: release, =1: beta 1, =2: beta 2, ... movwf lo ; copy to lo @@ -3137,7 +3318,7 @@ rcall check_expiry ; YES - check expiry date btfsc aux_flag ; - within expiry date? bra TFT_cat_beta_4 ; NO - give update cue - STRCAT "Rel. " ; YES - print "Release" + STRCAT "Release" ; YES - print "Release" return ; - done TFT_cat_beta_1: btfss aux_flag ; shall show long version? @@ -3157,9 +3338,83 @@ TFT_cat_beta_4 STRCAT "update!" ; print update cue goto TFT_attention_color ; and return - ENDIF - -;============================================================================= + ENDIF ; _DEBUG + +;----------------------------------------------------------------------------- +; show firmware update message +; +; all text outputs are hard-coded since language switching +; has not yet been initialized when this code is executed + + global show_fw_mesg_update + global show_fw_mesg_kept +show_fw_mesg_update: + call TFT_standard_color + ; show update message + WIN_SMALL .20,.100 + STRCPY_PRINT "Update successful!" + ; show firmware version + WIN_SMALL .20,.140 + STRCPY "New Firmware: " + bra show_fw_mesg_common +show_fw_mesg_kept: + call TFT_standard_color + ; show reboot message + WIN_SMALL .60,.100 + STRCPY_PRINT "Reboot" + ; show firmware version + WIN_SMALL .30,.140 + STRCPY "Firmware: " +show_fw_mesg_common: + rcall TFT_cat_firmware ; show firmware version x.y and color-code + invert if outdated + STRCAT_PRINT "" ; finalize output + bcf win_invert ; back to normal (non inverted) output + ; show firmware beta status + call TFT_standard_color ; color to use if it is a release version + WIN_SMALL .60,.180 + rcall TFT_cat_beta_release ; show "Release" or "BETA" + issue + STRCAT_PRINT "" ; finalize output + goto TFT_standard_color ; reset color and return + +;----------------------------------------------------------------------------- +; show serial and firmware version for comm mode + + global TFT_show_serial_and_firmware + global TFT_show_firmware +TFT_show_serial_and_firmware: + STRCPY "#" + call TFT_cat_serial + STRCAT " " +TFT_show_firmware: + STRCAT "v" + call TFT_cat_firmware ; will set win_invert if outdated + STRCAT " " + call TFT_cat_beta_release + STRCAT_PRINT "" + bcf win_invert ; clear win_invert + goto TFT_standard_color ; ...and return + +;----------------------------------------------------------------------------- +; append firmware version to current string, including color-coding + + global TFT_cat_firmware +TFT_cat_firmware: + movlw softwareversion_x + movwf lo + bsf leftbind + output_8 ; print major in 1 digit format + PUTC '.' + movlw softwareversion_y + movwf lo + output_99x ; print minor in two digit format + bcf leftbind + rcall check_expiry ; sets aux_flag if expired + btfss aux_flag ; expired? + return ; NO + bsf win_invert ; YES - print in inverse + goto TFT_attention_color ; - print in attention color (and return) + +;----------------------------------------------------------------------------- ; For the Information menu: firmware version global info_menu_firmware @@ -3169,37 +3424,39 @@ rcall TFT_cat_firmware PUTC " " rcall TFT_cat_beta_rel - STRCAT_PRINT "" ; print buffer to screen + STRCAT_PRINT "" return -;============================================================================= +;----------------------------------------------------------------------------- ; For the Information menu: firmware version of the RX processor IFDEF _rx_functions + global info_menu_firmware_rx + global TFT_print_firmware_rx info_menu_firmware_rx: lfsr FSR1,tFirmware_rx call strcat_text -; bra TFT_cat_firmware_rx ;(and return) -;TFT_cat_firmware_rx: - movff rx_firmware+0,lo +TFT_print_firmware_rx: + movff rx_firmware_cur_major,lo bsf leftbind output_8 PUTC '.' - movff rx_firmware+1,lo + movff rx_firmware_cur_minor,lo output_8 bcf leftbind return + ENDIF ;----------------------------------------------------------------------------- ; For the Information menu: append serial number global info_menu_serial + global TFT_cat_serial info_menu_serial: lfsr FSR1,tSerial call strcat_text - global TFT_cat_serial TFT_cat_serial: clrf EEADRH clrf EEADR ; get serial number LOW @@ -3231,13 +3488,14 @@ bcf leftbind return +;----------------------------------------------------------------------------- ; For the Information menu: append battery voltage + global info_menu_battery_volts info_menu_battery_volts: lfsr FSR1,tBatteryV call strcat_text - movff batt_voltage+1,hi - movff batt_voltage+0,lo + MOVII batt_voltage,mpr bsf leftbind output_16dp .2 ; x.xxx STRCAT "V(T" @@ -3247,29 +3505,22 @@ PUTC ")" return - ; For the Information menu: append uptime +;----------------------------------------------------------------------------- +; For the Information menu: append uptime + global info_menu_uptime info_menu_uptime: lfsr FSR1,tUptime call strcat_text - movff uptime+0,xC+0 - movff uptime+1,xC+1 - movff uptime+2,xC+2 - movff uptime+3,xC+3 - movlw LOW .3600 - movwf xB+0 - movlw HIGH .3600 - movwf xB+1 ; one day = 3600s - call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder - ;xC+0:xC+1 -> Full hours - movff xC+1,xA+1 - movff xC+0,xA+0 - clrf xB+1 - movlw .24 - movwf xB+0 - call div16x16 ; xC = xA / xB with xA as remainder - movff xC+0,lo - movff xC+1,hi ; full days + SMOVFF uptime,xC ; ISR-safe copy of uptime:4 to xC:4 + +info_menu_uptime_com: + MOVLI .3600,xB ; one hour = 3600s + call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder -> xC+1:xC+0 holds full hours + MOVII xC,xA + MOVLI .24,xB ; one day = 24 hours + call div16x16 ; xC:2 = xA:2 / xB:2 with xA as remainder -> xC+1:xC+0 holds full days, xA holds full hours + MOVII xC,mpr ; copy full days into hi:lo bsf leftbind output_16 PUTC "d" @@ -3280,6 +3531,8 @@ return ; done + IFDEF _compass + global menu_cal_x menu_cal_x: lfsr FSR0,compass_CX_f @@ -3296,16 +3549,20 @@ menu_cal_z: lfsr FSR0,compass_CZ_f lfsr FSR1,tCalZ + ;bra menu_cal_common + menu_cal_common: call strcat_text movff POSTINC0,lo movff POSTINC0,hi - call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required + call TFT_convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required bsf leftbind output_16 bcf leftbind return + ENDIF ; _compass + ;----------------------------------------------------------------------------- ; ppO2 menu @@ -3318,6 +3575,9 @@ movlw ppo2_warning_low_default bra divesets_ppo2_common + + IFDEF _ccr_pscr + global divesets_ppo2_min_cc divesets_ppo2_min_cc: lfsr FSR1,tPPO2MINCC @@ -3326,11 +3586,13 @@ movlw ppo2_warning_loop_default bra divesets_ppo2_common + ENDIF + global divesets_ppo2_max divesets_ppo2_max: lfsr FSR1,tPPO2Max call strcat_text - movff char_I_ppO2_max,lo + movff char_I_ppO2_max_work,lo movlw ppo2_warning_high_default bra divesets_ppo2_common @@ -3360,29 +3622,40 @@ ;============================================================================= - global TFT_clear_warning_text -TFT_clear_warning_text: - btfss divemode ; in divemode? - bra TFT_clear_warning_text2 ; NO - setup for surface mode - bcf FLAG_TFT_dive_warning_text_clear ; clear flag - btfsc alternative_divelayout - bra TFT_clear_warning_text_2nd_row ; in alt. mode, clear only row 2 + global TFT_clear_message_window +TFT_clear_message_window: + btfss divemode ; in dive mode? + bra TFT_clear_message_window_surf ; NO - clear surface mode area + ;bra TFT_clear_message_window_dive ; YES - clear dive mode area + +TFT_clear_message_window_dive: + btfsc alt_layout_active ; in alternative layout? + bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only + ; NO - clear dive mode area, both rows WIN_BOX_BLACK dm_warning_row, dm_warning_bot, dm_warning_column, dm_warning_rgt ; top, bottom, left, right - return -TFT_clear_warning_text2: + return ; - done + +TFT_clear_message_window_surf: WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ; top, bottom, left, right - return - - global TFT_clear_warning_text_2nd_row -TFT_clear_warning_text_2nd_row: - btfss divemode ; in divemode? - bra TFT_clear_warning_text_2nd_2 ; NO - setup for surface mode - bcf FLAG_TFT_dive_warning_text_clr2 ; clear flag + return ; done + + + global TFT_clear_message_window_row2 +TFT_clear_message_window_row2: + btfss divemode ; in dive mode? + bra TFT_clear_message_window_surf_2 ; NO - clear surface mode area, 2nd row only + ;bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only + +TFT_clear_message_window_dive_2: WIN_BOX_BLACK dm_warning2_row, dm_warning2_bot, dm_warning2_column, dm_warning2_rgt ; top, bottom, left, right - return -TFT_clear_warning_text_2nd_2: + bcf message_2nd_row_used ; - 2nd row is clear now + return ; - done + +TFT_clear_message_window_surf_2: WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ; top, bottom, left, right - return + bcf message_2nd_row_used ; 2nd row is clear now + return ; done + global TFT_fillup_with_spaces TFT_fillup_with_spaces: ; fill up FSR2 with spaces (total string length in #WREG) @@ -3404,34 +3677,29 @@ global TFT_desaturation_time TFT_desaturation_time: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_memo_color STRCPY "Desat:" - movff int_O_desaturation_time+0,lo - movff int_O_desaturation_time+1,hi - call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) -; bsf leftbind - movf lo,W - movff hi,lo - movwf hi ; exchange lo and hi... + MOVII int_O_desaturation_time,mpr + call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) + movf lo,W ; swap hi and lo + movff hi,lo ; ... + movwf hi ; ... output_99x ; hours PUTC ':' movff hi,lo ; minutes output_99x -; bcf leftbind movlw surf_warning_length ; only use surface string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) -; movlw .0 ; not needed -; movff WREG,buffer+11 ; not needed STRCAT_PRINT "" return global TFT_nofly_time TFT_nofly_time: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_memo_color @@ -3443,22 +3711,17 @@ TFT_nofly_time_1: STRCPY "NoAlt:" TFT_nofly_time_2: - movff int_O_nofly_time+0,lo - movff int_O_nofly_time+1,hi - call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) -; bsf leftbind - movf lo,W - movff hi,lo - movwf hi ; exchange lo and hi... + MOVII int_O_nofly_time,mpr + call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) + movf lo,W ; swap hi and lo + movff hi,lo ; ... + movwf hi ; ... output_99x ; hours PUTC ':' movff hi,lo ; minutes output_99x -; bcf leftbind movlw surf_warning_length ; only use surface string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) -; movlw .0 ; not needed -; movff WREG,buffer+11 ; not needed STRCAT_PRINT "" return @@ -3466,12 +3729,12 @@ global TFT_warning_agf TFT_warning_agf: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_attention_color STRCPY_TEXT tDiveaGF_active ; "aGF!" - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... @@ -3479,39 +3742,40 @@ global TFT_warning_fallback TFT_warning_fallback: ; show fallback warning - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - call TFT_warnings_color + call TFT_warning_color STRCPY_TEXT tDiveFallback ; "Fallback!" - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... +;============================================================================= IFDEF _rx_functions global TFT_advice_switch TFT_advice_switch: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_advice_color STRCPY_TEXT tswap ; "Swap Tank" - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... global TFT_attention_transmitter TFT_attention_transmitter: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_attention_color STRCPY_TEXT tTransmitter ; "P.Transm." - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... @@ -3522,25 +3786,24 @@ call TFT_attention_color ; use attention color bra TFT_common_pres_reading ; continue with common code TFT_warning_pres_reading: ; entry point for warning - call TFT_warnings_color ; use warnings color + call TFT_warning_color ; use warnings color ;bra TFT_common_pres_reading ; continue with common code TFT_common_pres_reading: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - done STRCPY_TEXT tPressure ; "Tank Pres" - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... global TFT_attention_sac TFT_attention_sac: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - movff int_O_sac_rate+0,lo ; copy SAC rate to hi:lo - movff int_O_sac_rate+1,hi ; ... + MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo call TFT_color_code_tank_pres_sac; color-code the output STRCPY_TEXT tSAC ; "SAC", needs to be exactly 3 chars long STRCAT ": " ; ": " @@ -3552,77 +3815,81 @@ STRCAT_PRINT "" ; dump buffer to screen bra TFT_warn_att_info_exit ; and return... - ENDIF - + ENDIF ; _rx_functions + +;============================================================================= global TFT_info_deco -TFT_info_deco ; show info when decompression obligation is decreasing - rcall TFT_warning_set_window ; sets the row and column for the current message +TFT_info_deco ; show info when decompression obligation is steady or decreasing + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - return - call TFT_advice_color ; actually it is a memo, but we break the rules here and display in advice color (green) - STRCPY_TEXT tDecoInfo ; write "Deco Zone" - movlw dm_warning_length ; select divemode string length - rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) - STRCAT_PRINT "" ; print buffer - bra TFT_warn_att_info_exit ; and return... - + call TFT_advice_color ; YES - actually it is a memo, but we break the rules here and display in advice color (green) + STRCPY_TEXT tDecoInfo ; - write "Deco Zone" + movlw dm_warning_length ; - select dive mode string length + rcall TFT_fillup_with_spaces ; - fill up FSR2 with spaces (total string length in #WREG) + STRCAT_PRINT "" ; - print buffer + bra TFT_warn_att_info_exit ; - and return... + +;============================================================================= IFDEF _cave_mode global TFT_info_cave_mode TFT_info_cave_mode: - rcall TFT_warning_set_window ; sets the row and column for the current warning + rcall TFT_set_message_window ; sets the row and column for the current warning tstfsz WREG ; is there room for the message? return ; NO - return call TFT_memo_color ; YES - set memo color STRCPY_TEXT tCaveMode ; write "Cave Mode" - movlw dm_warning_length ; select divemode string length + movlw dm_warning_length ; select dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" ; print buffer bra TFT_warn_att_info_exit ; and return... global TFT_info_dive_turned TFT_info_dive_turned: - rcall TFT_warning_set_window ; sets the row and column for the current warning + rcall TFT_set_message_window ; sets the row and column for the current warning tstfsz WREG ; is there room for the message? return ; NO - return call TFT_attention_color ; YES - set attention color STRCPY_TEXT tDiveTurned ; write "Dv.turned" - movlw dm_warning_length ; select divemode string length + movlw dm_warning_length ; select dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" ; print buffer bra TFT_warn_att_info_exit ; and return... global TFT_warn_cave_shutdown TFT_warn_cave_shutdown: - rcall TFT_warning_set_window ; sets the row and column for the current warning + rcall TFT_set_message_window ; sets the row and column for the current warning tstfsz WREG ; is there room for the message? return ; NO - return - call TFT_warnings_color ; YES - set warning color + call TFT_warning_color ; YES - set warning color STRCPY_TEXT tCaveModeShutdown ; write "X-Cave-X" - movlw dm_warning_length ; select divemode string length + movlw dm_warning_length ; select dive mode string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" ; print buffer bra TFT_warn_att_info_exit ; and return... - ENDIF - - - global TFT_warning_gf -TFT_warning_gf: ; GF - rcall TFT_warning_set_window ; set the row and column for the current message + ENDIF ; _cave_mode + +;============================================================================= + + global TFT_warning_sat +TFT_warning_sat ; Saturation + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - movff int_O_gradient_factor+0,lo ; bank-safe copy gradient factor - movff int_O_gradient_factor+1,hi ; + MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation call TFT_color_code_gf ; color-code output - STRCPY "GF: " ; the two spaces are on purpose to align the output with other warnings' outputs +; STRCPY "GF: " ; the two spaces are on purpose to align the output with other warnings' outputs + STRCPY_TEXT tSAT ; print "Sat:" + PUTC " " ; add a space to align the output with other warnings' outputs bsf leftbind - output_8 ; print value of lo only, int_O_gradient_factor is limited to 255 + output_8 ; print value of lo only, int_O_lead_supersat is limited to 255 PUTC "%" - movlw dm_warning_length ; divemode string length - btfss divemode ; in divemode? + movlw dm_warning_length ; dive mode string length + btfss divemode ; in dive mode? movlw surf_warning_length ; NO - use surface string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" @@ -3634,16 +3901,16 @@ global TFT_warning_mbubbles TFT_warning_mbubbles: - rcall TFT_warning_set_window ; sets the row and column for the current warning + rcall TFT_set_message_window ; sets the row and column for the current warning tstfsz WREG ; is there room for the message? return ; NO call TFT_attention_color ; set attention color as default movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings btfsc WREG,mbubble_warning ; are we in the microbubbles zone right now? - call TFT_warnings_color ; YES - reconfigure to warning color + call TFT_warning_color ; YES - reconfigure to warning color STRCPY_TEXT tMicroBubbles - movlw dm_warning_length ; divemode string length - btfss divemode ; in divemode? + movlw dm_warning_length ; dive mode string length + btfss divemode ; in dive mode? movlw surf_warning_length ; NO - use surface string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" @@ -3652,168 +3919,173 @@ global TFT_warning_outside TFT_warning_outside: - rcall TFT_warning_set_window ; sets the row and column for the current warning + rcall TFT_set_message_window ; sets the row and column for the current warning tstfsz WREG ; is there room for the message? return ; NO call TFT_attention_color movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings btfsc WREG,outside_warning ; are we outside the ZH-L16 model right now? - call TFT_warnings_color ; YES - reconfigure to warning color + call TFT_warning_color ; YES - reconfigure to warning color STRCPY "X-ZHL16-X" - movlw dm_warning_length ; divemode string length - btfss divemode ; in divemode? + movlw dm_warning_length ; dive mode string length + btfss divemode ; in dive mode? movlw surf_warning_length ; NO - use surface string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... + global TFT_warning_depth +TFT_warning_depth: + rcall TFT_set_message_window ; sets the row and column for the current warning + tstfsz WREG ; is there room for the message? + return ; NO + call TFT_warning_color + STRCPY_TEXT tMaxDepth ; "max.Depth" + movlw dm_warning_length ; dive mode string length + rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) + STRCAT_PRINT "" + bra TFT_warn_att_info_exit ; and return... + + global TFT_warning_gas_needs_warn - global TFT_warning_gas_needs_att TFT_warning_gas_needs_warn: - rcall TFT_warning_gas_needs_war_helper - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - call TFT_warnings_color - bra TFT_warning_gas_needs_com + call TFT_warning_color ; YES - set warning color + bra TFT_warning_gas_needs_com ; - continue with common part + + global TFT_warning_gas_needs_att TFT_warning_gas_needs_att: - rcall TFT_warning_gas_needs_att_helper - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - call TFT_attention_color + call TFT_attention_color ; YES - set attention color + ;bra TFT_warning_gas_needs_com ; - continue with common part + TFT_warning_gas_needs_com: - STRCPY_TEXT tGasNeedsWarn ; "Gas Needs" - movlw dm_warning_length ; divemode string length - rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) - STRCAT_PRINT "" + STRCPY_TEXT tGasNeedsWarn ; print "Gas Needs" + movlw dm_warning_length ; dive mode string length + rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) + STRCAT_PRINT "" ; finalize output bra TFT_warn_att_info_exit ; and return... -TFT_warning_gas_needs_war_helper: - incf message_counter,F ; increase counter - btfsc gas_needs_warning ; is it a new warning? - return ; NO - do not show the gas needs custom view again - bsf gas_needs_warning ; YES - memorize it's an old now - bra TFT_warning_gas_needs_helper_com -TFT_warning_gas_needs_att_helper: - incf message_counter,F ; increase counter - btfsc gas_needs_attention ; is it a new attention? - return ; NO - do not show the gas needs custom view again - bsf gas_needs_attention ; YES - memorize it's an old now -TFT_warning_gas_needs_helper_com: - btfsc alternative_divelayout ; in alternative layout? - call switch_layout_to_normal ; YES - switch to normal layout - movlw index_gas_needs_ascent-1 ; custom view number one below gas needs view - movwf menupos3 ; set custom view number - bsf toggle_customview ; initiate toggle to desired custom view -> gas needs view will be shown - return - +;============================================================================= + + IFDEF _helium global TFT_warning_IBCD TFT_warning_IBCD: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_attention_color ; select attention color as default STRCPY_TEXT tIBCD ; "IBCD N2He" - movlw dm_warning_length ; divemode string length - rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) + movlw dm_warning_length ; dive mode string length + rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... + ENDIF + +;============================================================================= global TFT_warning_no_BO_gas TFT_warning_no_BO_gas: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - call TFT_attention_color ; select attention color as default - STRCPY_TEXT tnoBOgas ; "B/O Gas X" - movlw dm_warning_length ; divemode string length - rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) - STRCAT_PRINT "" + call TFT_warning_color ; select warning color + STRCPY_TEXT tnoBOgas ; print "-B/O-Gas-" + movlw dm_warning_length ; dive mode string length + rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) + STRCAT_PRINT "" ; finalize output bra TFT_warn_att_info_exit ; and return... global TFT_advice_gas_change TFT_advice_gas_change: - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_advice_color ; set advice color STRCPY_TEXT tgaschange ; "Change?" - movlw dm_warning_length ; divemode string length - rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) + movlw dm_warning_length ; dive mode string length + rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... +;============================================================================= + + IFDEF _external_sensor global TFT_warning_sensor_disagree TFT_warning_sensor_disagree: ; show sensor disagree warning - rcall TFT_warning_sensor_dis_helper - rcall TFT_warning_set_window ; set the row and column for the current message + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - call TFT_warnings_color + call TFT_warning_color STRCPY_TEXT tSensorDisagree ; "Sensors<>" - movlw dm_warning_length ; divemode string length - rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) + movlw dm_warning_length ; dive mode string length + rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) STRCAT_PRINT "" bra TFT_warn_att_info_exit ; and return... -TFT_warning_sensor_dis_helper: - btfsc sensor_warning ; is it a new warning? - return ; NO - do not show the gas needs custom view again - bsf sensor_warning ; YES - memorize it's an old warning now - btfsc alternative_divelayout ; in alternative layout? - call switch_layout_to_normal ; YES - switch to normal layout - movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors - movwf menupos3 ; set custom view number - bsf toggle_customview ; initiate toggle to desired custom view -> ppO2 sensors - return + ENDIF ; _external_sensor ;============================================================================= -TFT_warning_set_window: ; set the row and column for the current message +TFT_set_message_window: ; set the row and column for the current message ; ignore warning (now)? - decf message_counter,W ; -1 - bcf STATUS,C - btfss alternative_divelayout ; in alternative layout, do not divide... - rrcf WREG,W ; (message_counter-1)/2 - cpfseq message_page - retlw .255 ; WREG <> 0 -> Warning window not defined - btfss divemode ; in divemode? - bra TFT_warning_set_window3 ; NO - setup for surface mode - btfss alternative_divelayout - bra TFT_warning_set_window3a ; standard layout - bra TFT_warning_set_window2a ; alternative layout (Only lower row used) -TFT_warning_set_window3a: - btfss message_counter,0 ; toggle with each warning - bra TFT_warning_set_window2 - WIN_SMALL dm_warning1_column, dm_warning1_row - bcf second_row_warning ; =1: The second row contains a warning - retlw .0 ; WREG=0 -> Warning window defined -TFT_warning_set_window2: - bsf second_row_warning ; =1: The second row contains a warning -TFT_warning_set_window2a: - WIN_SMALL dm_warning2_column, dm_warning2_row - retlw .0 ; WREG=0 -> Warning window defined -TFT_warning_set_window3: - btfss message_counter,0 ; toggle with each warning - bra TFT_warning_set_window4 - WIN_SMALL surf_warning1_column,surf_warning1_row - bcf second_row_warning ; =1: The second row contains a warning - retlw .0 ; WREG=0 -> Warning window defined -TFT_warning_set_window4: - WIN_SMALL surf_warning2_column,surf_warning2_row - bsf second_row_warning ; =1: The second row contains a warning - retlw .0 ; WREG=0 -> Warning window defined - - - global TFT_update_batt_percent_divemode -TFT_update_batt_percent_divemode: - rcall TFT_warning_set_window ; set the row and column for the current message + decf message_counter,W ; load (message counter - 1) into WREG + bcf STATUS,C ; clear carry bit + btfss alt_layout_active ; in alternative layout? + rrcf WREG,W ; NO - divide (message_counter-1) by 2 to get the page of the message + cpfseq message_page ; page of the message = current page ? + retlw .255 ; NO - do not show in this cycle (message window is not defined) + btfss divemode ; YES - in dive mode? + bra TFT_set_message_window_sf ; NO - setup for surface mode + ;bra TFT_set_message_window_dm ; YES - setup for dive mode + +; Dive Mode +TFT_set_message_window_dm: + btfsc alt_layout_active ; in alternative layout? + bra TFT_set_message_window_dm_row2 ; YES - alternative layout only uses 2nd row + btfss message_counter,0 ; NO - is the message number uneven? + bra TFT_set_message_window_dm_row2 ; NO - use 2nd row + ;bra TFT_set_message_window_dm_row1 ; YES - use 1st row + +TFT_set_message_window_dm_row1: + WIN_SMALL dm_warning1_column, dm_warning1_row ; set output position + bcf message_2nd_row_used ; flag that the 2nd does not contain a message yet + retlw .0 ; show in this cycle (message window is defined) + +TFT_set_message_window_dm_row2: + WIN_SMALL dm_warning2_column, dm_warning2_row ; set output position + bsf message_2nd_row_used ; flag that the 2nd row contains a message now + retlw .0 ; show in this cycle (message window is defined) + +; Surface Mode +TFT_set_message_window_sf: + btfss message_counter,0 ; is the message counter uneven? + bra TFT_set_message_window_sf_row2 ; NO - use 2nd row + ;bra TFT_set_message_window_sf_row1 ; YES - use 1st row + +TFT_set_message_window_sf_row1: + WIN_SMALL surf_warning1_column,surf_warning1_row ; set output position + bcf message_2nd_row_used ; flag that the 2nd row does not contain a message yet + retlw .0 ; show in this cycle (message window is defined) + +TFT_set_message_window_sf_row2: + WIN_SMALL surf_warning2_column,surf_warning2_row ; set output position + bsf message_2nd_row_used ; flag that the 2nd row contains a message now + retlw .0 ; show in this cycle (message window is defined) + + + global TFT_msg_batt_percent_divemode +TFT_msg_batt_percent_divemode: + rcall TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO movff batt_percent,lo ; get battery percent @@ -3823,8 +4095,8 @@ output_8 bcf leftbind PUTC "%" - movlw dm_warning_length ; divemode string length - btfss divemode ; in divemode? + movlw dm_warning_length ; dive mode string length + btfss divemode ; in dive mode? movlw surf_warning_length ; NO - use surface string length rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" @@ -3841,7 +4113,7 @@ STRCPY_TEXT_PRINT taGFactors ; Show GF (static) call TFT_disabled_color ; default to disabled color - btfss use_agf ; shall use alternative GF factors? + btfss use_aGF ; shall use alternative GF factors? call TFT_memo_color ; NO - switch to memo color WIN_STD dm_custom_gf_column1, dm_custom_gf_row bsf leftbind @@ -3857,14 +4129,14 @@ bra TFT_gf_factors_mask_3 ; NO - show "---" and return ; YES - show aGF and which one is active WIN_STD dm_custom_gf_column2, dm_custom_gf_row - btfss use_agf ; shall use aGF? + btfss use_aGF ; shall use aGF? bra TFT_gf_factors_mask_1 ; NO - print "<- " STRCPY_PRINT " ->" ; YES - print " ->" bra TFT_gf_factors_mask_2 ; - continue with common part TFT_gf_factors_mask_1: STRCPY_PRINT "<- " ; (NO) - print "<- " TFT_gf_factors_mask_2: ; common part - btfss use_agf ; shall use aGF? + btfss use_aGF ; shall use aGF? call TFT_disabled_color ; NO - switch to disabled color WIN_STD dm_custom_gf_column3, dm_custom_gf_row movff opt_aGF_low,lo ; get aGF low @@ -3887,11 +4159,6 @@ STRCPY_TEXT_PRINT tCeiling WIN_TINY dm_custom_tissue_title_column, dm_custom_tissue_title_row STRCPY_TEXT_PRINT tDiveTissues -; collides with ceiling output and not really needed, too -; WIN_TINY dm_custom_tissue_N2_column, dm_custom_tissue_N2_row -; STRCPY_TEXT_PRINT tN2 -; WIN_TINY dm_custom_tissue_He_column, dm_custom_tissue_He_row -; STRCPY_TEXT_PRINT tHe WIN_TINY dm_custom_gf_column1+.5, dm_custom_gf_title_row STRCPY_TEXT_PRINT tGFInfo bra TFT_custview_exit1 ; and return... @@ -3900,10 +4167,9 @@ global TFT_ceiling_GF_tissue ; data for ceiling, current GF and tissues TFT_ceiling_GF_tissue: WIN_MEDIUM dm_custom_ceiling_column,dm_custom_ceiling_row - movff int_O_ceiling+0,lo - movff int_O_ceiling+1,hi + MOVII int_O_ceiling,mpr call TFT_color_code_ceiling ; color-code the output - call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] + call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] bsf leftbind TSTOSS opt_units ; 0=m, 1=ft bra TFT_ceiling_tissue_cGF_m @@ -3917,13 +4183,12 @@ bcf leftbind STRCAT_PRINT " " ; Show tissue diagram - call DISP_tissue_saturation_graph; show char_O_tissue_N2_saturation and char_O_tissue_He_saturation - ; Show current tissue supersaturation + call TFT_dive_tissues ; show tissue pressure diagram + ; Show current supersaturation WIN_MEDIUM dm_custom_clock_column+.3, dm_custom_gf_row - movff int_O_gradient_factor+0,lo ; gradient factor absolute, 100% = on M-line of straight Buhlmann - movff int_O_gradient_factor+1,hi ; hi byte holds flags + MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation call TFT_color_code_gf ; color-code output - output_8 ; need to print lo only, int_O_gradient_factor value is limited to 255 + output_8 ; need to print lo only, int_O_lead_supersat value is limited to 255 STRCAT_PRINT "" WIN_STD dm_custom_clock_column+.40, dm_custom_gf_row+.5 STRCAT_PRINT "%" ; % is printed in color set by TFT_color_code_gf, too @@ -3941,11 +4206,10 @@ STRCPY_TEXT_PRINT tBattery ; "Battery" WIN_TINY dm_custom_surfpres_column+.8, dm_custom_surfpres_title_row STRCPY_TEXT_PRINT tSurface ; "Surface" - ; Show Surface Pressure (done in mask, because it's static during the dive) + ; Show configured Surface Pressure (done in mask, because it's static during the dive) call TFT_standard_color WIN_SMALL dm_custom_surfpres_column, dm_custom_surfpres_row - movff last_surfpressure_30min+0,lo - movff last_surfpressure_30min+1,hi + MOVII pressure_surf,mpr output_16 PUTC ' ' STRCAT_TEXT_PRINT tMBAR ; mbar (hPa) @@ -3957,45 +4221,46 @@ ; Update Clock WIN_SMALL dm_custom_clock_column, dm_custom_clock_row call TFT_standard_color - movff hours,lo + SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time + movff rtc_latched_hour,lo output_99 PUTC ':' - movff mins,lo + movff rtc_latched_mins,lo output_99x PUTC ":" - movff secs,lo + movff rtc_latched_secs,lo output_99x STRCAT_PRINT "" - ; Show Battery Info - WIN_SMALL dm_custom_battery_column, dm_custom_battery_percent_row - movff batt_percent,lo ; get battery percent - call TFT_color_code_battery ; color-code battery percent -; bsf leftbind - output_8 -; bcf leftbind - STRCAT "% " - movlw 0x00 - movff WREG,buffer+4 ; only "xxx%" - STRCAT_PRINT "" - bcf win_invert + ; Show Battery Volt call TFT_memo_color WIN_SMALL dm_custom_battery_column, dm_custom_battery_volt_row - movff batt_voltage+0,lo - movff batt_voltage+1,hi + MOVII batt_voltage,mpr bsf leftbind - output_16dp .2 + output_16dp .2 PUTC 'V' movff buffer+5,buffer+4 movlw 0x00 movff WREG,buffer+5 ; only "x.yzV" STRCAT_PRINT "" + ; Show Battery Percent + WIN_SMALL dm_custom_battery_column+.7, dm_custom_battery_percent_row + movff batt_percent,lo ; get battery percent + call TFT_color_code_battery ; color-code battery percent + output_8 + STRCAT "% " + movlw 0x00 + movff WREG,buffer+4 ; only "xxx%" + STRCAT_PRINT "" ; Surface pressure is shown in mask because it is static bra TFT_custview_exit1 ; and return... +;============================================================================= + + IFDEF _ccr_pscr global TFT_pscr_info_mask ; mask for pSCR info TFT_pscr_info_mask: - rcall TFT_mask_ppo2 + rcall TFT_show_ppo2_mask call TFT_divemask_color WIN_TINY dm_custom_pscr_drop_column, dm_custom_pscr_title_row STRCPY_TEXT_PRINT tPSCR_O2_drop @@ -4003,12 +4268,12 @@ STRCPY_TEXT_PRINT tPSCR_lungratio bra TFT_custview_exit1 ; and return... + global TFT_pscr_info ; data for pSCR info TFT_pscr_info: ;show ppO2 WIN_MEDIUM dm_custom_ppo2_column,dm_custom_ppo2_row - movff int_O_pSCR_ppO2+0,lo ; copy pSCR ppO2 to hi:lo - movff int_O_pSCR_ppO2+1,hi + MOVII int_O_pSCR_ppO2,mpr ; copy pSCR ppO2 to hi:lo call TFT_color_code_ppo2 ; color-code output bsf leftbind output_16dp .3 ; x.xx bar @@ -4030,6 +4295,9 @@ STRCAT_PRINT "" bra TFT_custview_exit1 ; and return... + ENDIF ; _ccr_psrc + +;============================================================================= global TFT_gas_needs_ascent_mask ; mask for gas needs ascent TFT_gas_needs_ascent_mask: @@ -4089,8 +4357,8 @@ movf up,W ; NO - get gas number and check if need of that gas is > 0 rlncf WREG,W ; multiply by 2 incf WREG,W ; add 1 to address high byte - lfsr FSR1,int_O_ascent_pres_need ; load base of ascent press needs - movff PLUSW1,hi ; read HIGH(int_O_ascent_pres_need[up]) + lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure + movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up]) btfss hi,int_is_zero ; check flag for pres_need == 0 bra TFT_gas_needs_helper_2 ; NO - print gas type and pressure needed incf up,F ; YES - increment to next gas... @@ -4104,23 +4372,24 @@ movff PLUSW1,lo ; copy result to lo lfsr FSR1,opt_gas_He_ratio ; read opt_gas_He_ratio[WREG] movff PLUSW1,hi ; copy result to hi - call customview_show_mix ; print "Air", "O2", "21/35", etc. + call gaslist_show_mix ; print "Air", "O2", "21/35", etc. PUTC ':' ; ":" movf up,W ; get gas number (0-4) to WREG rlncf WREG,W ; multiply by 2 - lfsr FSR1,int_O_ascent_pres_need ; load base of ascent press needs (default) - movff PLUSW1,lo ; read LOW(int_O_ascent_pres_need[up]) + lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure + movff PLUSW1,lo ; read LOW(int_O_gas_need_pres[up]) incf WREG,W ; add 1 to address high byte - movff PLUSW1,hi ; read HIGH(int_O_ascent_pres_need[up]) + movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up]) btfsc hi,int_attention_flag ; check if attention flag is set (pres_need > pres_fill * threshold) - call TFT_attention_color ; YES - print gas need in yellow + call TFT_attention_color ; YES - print gas need in attention color btfsc hi,int_warning_flag ; check if warning flag is set (pres_need > pres_fill) - call TFT_warnings_color ; YES - print gas need in red - movff int_O_ascent_pres_need+1,WREG ; get HIGH(int_O_ascent_pres_need[0]) which holds flag for invalid data + call TFT_warning_color ; YES - print gas need in warning color + movff int_O_gas_need_pres+1,WREG ; get HIGH(int_O_gas_need_pres[0]) which holds flag for invalid data btfsc WREG,int_invalid_flag ; check if invalid data flag is set - call TFT_disabled_color ; YES - print gas need in disabled color - bcf hi,int_attention_flag ; clear attention flag for attention color - bcf hi,int_warning_flag ; clear warning flag for warning color + call TFT_disabled_color ; YES - print gas need in disabled color + bcf hi,int_attention_flag ; clear flag for attention + bcf hi,int_warning_flag ; clear flag for warning + bcf hi,int_high_flag ; clear flag for > 999 bar bcf hi,int_invalid_flag ; clear flag for invalid data (will actually only be set with 1st gas) output_16_3 ; limit to 999 and display only (0-999) STRCAT_PRINT " " ; adds a space to overwrite any potential remains of earlier outputs @@ -4128,24 +4397,26 @@ bra TFT_custview_exit2 ; and return... - global TFT_mask_ppo2 ; helper function for several custom views -TFT_mask_ppo2: + global TFT_show_ppo2_mask ; helper function for several custom views +TFT_show_ppo2_mask: call TFT_divemask_color + IFDEF _ccr_pscr btfss FLAG_ccr_mode ; in CCR mode? bra TFT_mask_ppo2a ; NO - continue checking for pSCR and OC - btfsc FLAG_bailout_mode ; in bailout? - bra TFT_mask_ppo2b ; YES + btfsc bailout_mode ; YES - in bailout? + bra TFT_mask_ppo2b ; YES WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display) - STRCPY_TEXT_PRINT tppO2Dil ; print "ppO2(Dil)" - bra TFT_custview_exit2 ; and return... + STRCPY_TEXT_PRINT tppO2Dil ; NO - print "ppO2(Dil)" + bra TFT_custview_exit2 ; - and return... TFT_mask_ppo2a: btfss FLAG_pscr_mode ; in pSCR mode? bra TFT_mask_ppo2b ; NO - continue with OC mode (or bailout) - btfsc FLAG_bailout_mode ; in bailout? - bra TFT_mask_ppo2b ; YES + btfsc bailout_mode ; YES - in bailout? + bra TFT_mask_ppo2b ; YES WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display) - STRCPY_TEXT_PRINT tppO2Mix ; print "ppO2(Mix)" - bra TFT_custview_exit2 ; and return... + STRCPY_TEXT_PRINT tppO2Mix ; NO - print "ppO2(Mix)" + bra TFT_custview_exit2 ; - and return... + ENDIF TFT_mask_ppo2b: ; OC mode or bailout WIN_TINY dm_custom_ppo2_column-.2, dm_custom_ppo2_title_row ; normal position STRCPY_TEXT_PRINT tppO2 ; in all other modes @@ -4154,7 +4425,7 @@ global TFT_ppo2_ead_end_cns_mask ; mask for ppO2, END/EAD and CNS TFT_ppo2_ead_end_cns_mask: - rcall TFT_mask_ppo2 + rcall TFT_show_ppo2_mask call TFT_divemask_color WIN_TINY dm_custom_ead_column, dm_custom_eadend_title_row STRCPY_TEXT_PRINT tDiveEAD_END @@ -4167,8 +4438,7 @@ TFT_ppo2_ead_end_cns: ; Show ppO2 WIN_MEDIUM dm_custom_ppo2_column, dm_custom_ppo2_row - movff int_O_breathed_ppO2+0,lo ; copy ppO2 of the currently breathed gas to hi:lo - movff int_O_breathed_ppO2+1,hi + MOVII int_O_breathed_ppO2,mpr ; copy ppO2 of the currently breathed gas to hi:lo call TFT_color_code_ppo2 ; color-code output bsf leftbind output_16dp .3 ; x.xx bar @@ -4186,8 +4456,7 @@ rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars ; Show CNS WIN_STD dm_custom_cns_column+.3, dm_custom_cns_row - movff int_O_CNS_fraction+0,lo - movff int_O_CNS_fraction+1,hi + MOVII int_O_CNS_current,mpr ; get current CNS call TFT_color_code_cns ; color-code CNS output bsf leftbind output_16_3 ; displays only 0...999 @@ -4195,15 +4464,15 @@ STRCAT_PRINT "%" TFT_custview_exit2: goto TFT_standard_color ; and return... + TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars bsf leftbind - TSTOSS opt_units ; 0=Meters, 1=Feets + TSTOSS opt_units ; 0=Meter, 1=Feet bra TFT_end_ead_common_metric TFT_end_ead_common_imperial: movf lo,W ; with lo in m mullw .100 ; PRODL:PRODH = mbar/min - movff PRODL,lo - movff PRODH,hi + MOVII PRODL,mpr call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet output_16_3 STRCAT_TEXT tFeets @@ -4220,6 +4489,9 @@ STRCAT_PRINT "" return +;============================================================================= + + IFDEF _ccr_pscr global TFT_sensor_check_mask ; mask for sensor check TFT_sensor_check_mask: @@ -4237,8 +4509,7 @@ TFT_sensor_check: ; Show ppO2 of O2 in this depth WIN_MEDIUM dm_custom_ppO2_column, dm_custom_s_check_row - movff int_O_O2_ppO2+0,lo ; copy ppO2 of pure O2 to hi:lo - movff int_O_O2_ppO2+1,hi + MOVII int_O_O2_ppO2,mpr ; copy ppO2 of pure O2 to hi:lo call TFT_color_code_ppo2 ; color-code output bsf leftbind output_16dp .3 ; x.xx bar @@ -4246,8 +4517,7 @@ STRCAT_PRINT "" ; Show ppO2 of the diluent in this depth WIN_MEDIUM dm_custom_ppDil_column, dm_custom_s_check_row - movff int_O_pure_ppO2+0,lo ; copy ppO2 of pure gas to hi:lo - movff int_O_pure_ppO2+1,hi + MOVII int_O_pure_ppO2,mpr ; copy ppO2 of pure gas to hi:lo call TFT_color_code_ppo2 ; color-code output bsf leftbind output_16dp .3 ; x.xx bar @@ -4256,190 +4526,278 @@ TFT_sensor_check_exit: bra TFT_custview_exit2 ; and return... + ENDIF ; _ccr_pscr + ;============================================================================= global TFT_surface_lastdive TFT_surface_lastdive: - call TFT_divemask_color WIN_TINY surf_gaslist_column,surf_gaslist_row+.5 STRCAT_TEXT_PRINT tLastDive ; "Last Dive:" WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)+.5 STRCAT_TEXT_PRINT tDivetime ; "Divetime:" WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)+.5 - STRCAT_TEXT_PRINT tMaxDepth ; "Max. Depth" - call TFT_standard_color + STRCAT_TEXT_PRINT tMaxDepth ; "Max.Depth" + WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)+.5 + STRCAT_TEXT_PRINT tAvgDepth ; "Average" + WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row - movff int_O_desaturation_time+0,lo ; bank-safe copies - movff int_O_desaturation_time+1,WREG - iorwf lo,W ; check if desaturation time is zero + SMOVII int_O_desaturation_time,mpr ; ISR-safe copy of the desaturation time + movf mpr+0,W ; get low byte into WREG + iorwf mpr+1,W ; inclusive-or with high byte, check if desaturation time is zero bz TFT_surface_lastdive_1 ; YES - show last dive time - movff surface_interval+0,lo ; NO - show dive interval - movff surface_interval+1,hi - call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) - movf hi,W - movff lo,hi - movwf lo ; exchange lo and hi - bsf leftbind - output_99x - PUTC 'h' - movff hi,lo - output_99x - STRCAT_PRINT "m " - bra TFT_surface_lastdive_2 + ; NO - show surface interval + SMOVII surface_interval,mpr ; - ISR-safe copy of surface interval + call convert_time ; - convert hi:lo in minutes to hours (up:hi) and minutes (lo) + movf hi,W ; - swap hi and lo + movff lo,hi ; ... + movwf lo ; ... + bsf leftbind ; + output_99x ; + PUTC 'h' ; + movff hi,lo ; + output_99x ; + STRCAT_PRINT "m " ; + bra TFT_surface_lastdive_2 ; TFT_surface_lastdive_1: - movff lastdive_time+0,xC+0 - movff lastdive_time+1,xC+1 - movff lastdive_time+2,xC+2 - movff lastdive_time+3,xC+3 - movlw LOW .3600 - movwf xB+0 - movlw HIGH .3600 - movwf xB+1 ; one day = 3600s - call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder - ;xC+0:xC+1 -> full hours - movff xC+1,xA+1 - movff xC+0,xA+0 - clrf xB+1 - movlw .24 - movwf xB+0 - call div16x16 ; xC = xA / xB with xA as remainder - movff xC+0,lo - movff xC+1,hi ; full days - bsf leftbind - output_16 - PUTC "d" - movff xA+0,lo ; full hours - output_8 - STRCAT_PRINT "h " + SMOVFF lastdive_time,xC ; ISR-safe copy of lastdive_time:4 to xC:4 + call info_menu_uptime_com ; use part of info_menu_uptime to convert and display in days and hours TFT_surface_lastdive_2: WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.1) - movff lastdive_duration+0,lo - movff lastdive_duration+1,hi - output_16 ; divetime minutes - PUTC ":" - movff lastdive_duration+2,lo - output_99x ; divetime seconds - STRCAT_PRINT "" + MOVII lastdive_duration,mpr ; get duration of last dive, minutes + bsf leftbind ; print without leading spaces + output_16 ; dive time minutes + PUTC ":" ; + movff lastdive_duration+2,lo ; get duration of last dive, seconds + output_99x ; print seconds + rcall TFT_surface_common ; finalize output +TFT_surface_lastdive_3: WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.2) - movff lastdive_maxdepth+0,lo - movff lastdive_maxdepth+1,hi - TSTOSS opt_units ; 0=Meters, 1=Feets - bra TFT_surface_lastdive_metric - ;imperial + MOVII lastdive_maxdepth,mpr + bsf leftbind ; print without leading spaces + TSTOSS opt_units ; 0=Meter, 1=Feet + bra TFT_surface_lastdive_metric ; 0 - metric + rcall TFT_surface_imperial ; 1 - imperial + bra TFT_surface_lastdive_4 ; - continue +TFT_surface_lastdive_metric: + rcall TFT_surface_metric ; print depth in meters +TFT_surface_lastdive_4: + WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.3) + MOVII lastdive_avgdepth,mpr + bsf leftbind ; print without leading spaces + TSTOSS opt_units ; 0=Meter, 1=Feet + bra TFT_surface_metric ; 0 - metric and return + ;bra TFT_surface_imperial ; 1 - imperial and return + +TFT_surface_imperial: rcall convert_mbar_to_feet ; convert value in hi:lo from mbar to feet output_16_3 ; limit to 999 and display only (0-999) - STRCAT_TEXT tFeets1 - bra TFT_surface_lastdive2 - -TFT_surface_lastdive_metric: + STRCAT_TEXT tFeets1 ; "ft" + bra TFT_surface_common ; finalize output +TFT_surface_metric: bsf ignore_digit5 ; no cm (flag will be cleared by output_16) - movlw d'1' ; +1 - movff WREG,ignore_digits ; no 1000m + movlw .1 ; no 1000 meters + movwf ignore_digits ; ... output_16dp .3 ; xxx.y - STRCAT_TEXT tMeters -TFT_surface_lastdive2: - STRCAT_PRINT "" - bcf leftbind - return ; done. + STRCAT_TEXT tMeters ; "m" +TFT_surface_common: + STRCAT_PRINT "" ; finalize output + bcf leftbind ; clear left-alignment + return ; done ;============================================================================= global TFT_surface_tissues -TFT_surface_tissues: ; show Tissue diagram in surface mode +TFT_surface_tissues: ; show tissue diagram in surface mode + + ; draw outer frame + WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right + + ;---- draw labels --------------------------------- ; + + call TFT_standard_color WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row - STRCPY_TEXT_PRINT tN2 + IFDEF _helium + TSTOSS opt_tissue_graphics ; shall show N2+He or pressure and saturation? + bra TFT_surface_tissues_1 ; =0: show pressures and saturations + ; =1: show N2 and He pressures + STRCPY_TEXT_PRINT tN2 ; print "N2" WIN_SMALL surf_tissue_He_column,surf_tissue_He_row - STRCPY_TEXT_PRINT tHe - + STRCPY_TEXT_PRINT tHe ; print "He" + bra TFT_surface_tissues_2 ; continue with common part + ENDIF +TFT_surface_tissues_1: + STRCPY_TEXT_PRINT tDiveTissues ; print "Tissues" +TFT_surface_tissues_2: + ;---- draw scale ---------------------------------- ; movlw color_deepblue - call TFT_set_color ; make this configurable? - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.29,.29 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.37,.37 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.45,.45 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.53,.53 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.61,.61 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.69,.69 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.77,.77 - WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.85,.85 - WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right ; outer frame - + call TFT_set_color + +SCALELINE macro x + WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,surf_tissue_diagram_left+.4+x,surf_tissue_diagram_left+.4+x + endm + + SCALELINE .0 + SCALELINE .8 + SCALELINE .16 + SCALELINE .24 + SCALELINE .32 + SCALELINE .40 + SCALELINE .48 + SCALELINE .56 + SCALELINE .64 + SCALELINE .72 + SCALELINE .80 + + ;---- common initialization for Tissue Pressures and Saturation ---------- movlw .1 - movwf win_height ; row bottom (0-239) - - ;---- Draw N2 Tissues ---------------------------------------------------- - - movlw surf_tissue_diagram_left+.4 ; start position for N2 bars - movwf win_leftx2 ; column left (0-159) - movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4 ; max width for N2 bars - movwf win_width - - lfsr FSR2, char_O_tissue_N2_saturation + movwf win_height ; hight of the bargraph (0-239) + movlw surf_tissue_diagram_left+.4 ; left start position for N2 bars + movwf win_leftx2 ; column left (0-159) + movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4 ; get max width for N2 bars (78 pixel) + movwf win_width+0 ; set width of the bar box + clrf win_width+1 ; ... + movlw color_white ; color for tissues not exceeding surface max pressure + movwf ex ; store in ex + movlw color_red ; color for tissues exceeding surface max pressure + movwf ul ; store in ul + bcf aux_flag ; draw tissue pressures by default + + ;---- Draw combined or N2 Tissue Pressures--------- ; + lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default + IFDEF _helium + TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation? + lfsr FSR2,char_O_tissue_pres_N2 ; =1: load base address of N2 pressures + ENDIF + movlw d'16' + movwf lo ; tissue counter, 16 tissues + clrf hi ; row counter +TFT_surf_tissues_N2_loop: + movlw surf_tissue_diagram_top+.23 ; surface mode top start position N2 + rcall TFT_surf_tissues_bargraph ; show one tissue + movlw .2 ; bargraph spacing + addwf hi,F ; increment row counter + decfsz lo,F ; decrement tissue counter, done? + bra TFT_surf_tissues_N2_loop ; NO - loop + IFDEF _helium + TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation? + bra TFT_surface_tissues_3 ; =1: show He tissue pressures + ENDIF + + ;---- Draw Tissue Saturations --------------------- ; + lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation movlw d'16' - movwf lo ; 16 tissues - clrf hi ; row offset -surf_tissue_saturation_graph_N2: - movlw surf_tissue_diagram_top+.23 ; surface mode - addwf hi,W - movwf win_top ; row top (0-239) - rcall surf_tissue_saturation_loop ; show one tissue - decfsz lo,F - bra surf_tissue_saturation_graph_N2 - - ;---- Draw He Tissues ---------------------------------------------------- - - movlw surf_tissue_diagram_left+.24 ; start position for He bars (.15 without x2) - movwf win_leftx2 ; column left (0-159) - movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.24 ; max width for He bars - movwf win_width - - lfsr FSR2, char_O_tissue_He_saturation + movwf lo ; tissue counter, 16 tissues + clrf hi ; row counter + movlw color_grey ; color for tissue saturation + movwf ex ; store in ex +; movlw color_yellow ; 2nd color is not used by tissue saturation +; movwf ul ; ... + bsf aux_flag ; draw tissue saturation +TFT_surf_tissues_sat_loop: + movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position saturations + rcall TFT_surf_tissues_bargraph ; draw tissue bargraph + movlw .2 ; bargraph spacing + addwf hi,F ; increment row counter + decfsz lo,F ; decrement tissue counter, done? + bra TFT_surf_tissues_sat_loop ; NO - loop + + ;---- common Part for vertical lines--------------- ; + movlw surf_tissue_diagram_top+.23+.57 ; get top position + movwf win_top ; set top position (0-239) + movlw .30 ; get hight + movwf win_height ; set height + movlw .1 ; get width + movwf win_width+0 ; set width, low byte + clrf win_width+1 ; set width, high byte + + ;---- Print 100% Line ----------------------------- ; + movlw surf_tissue_diagram_left+.4+.64 ; get left position + movwf win_leftx2 ; set left position (0-159) + movlw color_red ; color for 100% line + call TFT_set_color ; set color + call TFT_box ; draw line + + ; GF factors enabled? + TSTOSS char_I_deco_model ; GF factors enabled? + bra TFT_surface_tissues_4 ; NO - continue with CNS + + ;---- Print GF low Line -------------------------- ; + movlw surf_tissue_diagram_left+.4 ; get left base position + movwf win_leftx2 ; set left base position (0-159) + movff opt_GF_low,WREG ; get GF low in 0.01 % + mullw .164 ; multiply with 164 + movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625 + addwf win_leftx2,F ; add to base position + movlw color_green ; color for 100% line + call TFT_set_color ; set color + call TFT_box ; draw line + + ;---- Print GF high Line -------------------------- ; + movlw surf_tissue_diagram_left+.4 ; get left base position + movwf win_leftx2 ; set left base position (0-159) + movff opt_GF_high,WREG ; get GF high in 0.01 % + mullw .164 ; multiply with 164 + movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625 + addwf win_leftx2,F ; add to base position + movlw color_yellow ; color for 100% line + call TFT_set_color ; set color + call TFT_box ; draw line + bra TFT_surface_tissues_4 ; continue with CNS + + IFDEF _helium +TFT_surface_tissues_3: + ;---- Draw He Tissue Pressures--------------------- ; + movlw surf_tissue_diagram_left+.4+.16 ; start position for He bars + movwf win_leftx2 ; column left (0-159) + movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4-.16 ; max width for He bars + movwf win_width+0 ; set total width of the bar box + clrf win_width+1 ; ... + lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures movlw d'16' - movwf lo ; 16 tissues - clrf hi ; row offset -surf_tissue_saturation_graph_He: - movlw surf_tissue_diagram_top+.23+.57 ; surface mode - addwf hi,W - movwf win_top ; row top (0-239) - rcall surf_tissue_saturation_loop ; show one tissue - decfsz lo,F - bra surf_tissue_saturation_graph_He - - WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row ; position in-between tissue bars - movff int_O_CNS_fraction+0,lo - movff int_O_CNS_fraction+1,hi - call TFT_color_code_cns - STRCPY_TEXT tCNS2 ; CNS: + movwf lo ; tissue counter, 16 tissues + clrf hi ; row counter +TFT_surf_tissues_He_loop: + movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position He + rcall TFT_surf_tissues_bargraph ; show one tissue + movlw .2 ; bargraph spacing + addwf hi,F ; increment row counter + decfsz lo,F ; decrement tissue counter, done? + bra TFT_surf_tissues_He_loop ; NO - loop + ENDIF + +TFT_surface_tissues_4: + ; ---- Draw CNS% ---------------------------------- ; + WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row ; position in-between tissue bars + MOVII int_O_CNS_current,mpr ; get current CNS + call TFT_color_code_cns ; color-code CNS value + STRCPY_TEXT tCNS2 ; "CNS:" bsf leftbind - output_16_3 ; displays only 0...999 + output_16_3 ; display only 0...999 bcf leftbind STRCAT_PRINT "%" - goto TFT_standard_color ; and return... - -surf_tissue_saturation_loop: - call TFT_standard_color - movlw .2 ; row spacing - addwf hi,F - movf POSTINC2,W ; get tissue load - bcf WREG,7 ; clear flag bit for sat/desat info (not used in surface mode) - rlncf WREG,W ; multiply with 2 (previously cleared bit 7 will be rotated to bit 0) - incf WREG,W ; add 1 for a minimum visible bar (He-bars could be invisible else-wise) - movwf up - movf win_width+0,W ; get max window width (win_width) - cpfslt up ; skip if WREG < win_width - movwf up ; crop length to win_width - ; no need to be able to draw longer bars – - ; we are at the surface and if bars would - ; even touch the max length possible here, - ; the diver would be in severe decompression - ; issues if not dead already... - movff up,win_bargraph - clrf win_width+1 - goto TFT_box ; and return... + goto TFT_standard_color ; and return... + +TFT_surf_tissues_bargraph: + addwf hi,W ; add row number to start position + movwf win_top ; set as row top (0-239) + movff POSTINC2,up ; get tissue value + movf ex,W ; default color + btfsc up,7 ; check if flag in bit 7 is set + movf ul,W ; YES - switch to 2nd color + call TFT_set_color ; set bargraph bar color + bcf up,7 ; clear flag bit + btfss aux_flag ; drawing saturations? + rlncf up,F ; NO - multiply with 2 (previously cleared bit 7 will be rotated to bit 0) + incf up,W ; add 1 for a minimum visible bar (He-bars could be invisible else-wise) + movwf win_bargraph ; set length of the bargraph + goto TFT_box ; draw bargraph and return + ;============================================================================= ; Draw saturation graph in dive mode -DISP_tissue_saturation_graph: +TFT_dive_tissues: ;---- Draw Frame call TFT_standard_color WIN_FRAME_COLOR16 dm_custom_tissue_diagram_top, dm_custom_tissue_diagram_bottom, dm_custom_tissue_diagram_left, .159 ; outer frame @@ -4447,144 +4805,205 @@ ;---- clear area showing leading tissue number as it may not be printed over WIN_BOX_BLACK dm_custom_tissue_diagram_top+.16, dm_custom_tissue_diagram_top+.16+.10, dm_custom_tissue_diagram_left+.32, dm_custom_tissue_diagram_left+.32+.8 ; top, bottom, left, right + ;---- common initialization for Tissue Pressures and Saturation ---------- movlw .1 - movwf win_height ; row bottom (0-239) - - ;---- Draw N2 Tissues ---------------------------------------------------- - - movlw dm_custom_tissue_diagram_left+.3 ; divemode - movwf win_leftx2 ; column left (0-159) - movlw .159-dm_custom_tissue_diagram_left-.4 ; width - movwf win_width - - lfsr FSR2, char_O_tissue_N2_saturation + movwf win_height ; hight of the bargraph (0-239) + movlw dm_custom_tissue_diagram_left+.3 ; get dive mode left start position + movwf win_leftx2 ; set column left (0-159) + movlw .159-dm_custom_tissue_diagram_left-.4 ; get max width + movwf win_width+0 ; set width (low byte) + clrf win_width+1 ; high byte of with is always zero + movlw color_cyan ; color for tissues with decreasing pressure + movwf ex ; store in ex + movlw color_orange ; color for tissues with increasing pressure + movwf ul ; store in ul + + ;---- Draw combined or N2 Tissue Pressures -------- ; + lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default + IFDEF _helium + TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation? + lfsr FSR2,char_O_tissue_pres_N2 ; =1: load base address of N2 pressures + ENDIF + movlw d'16' + movwf lo ; tissue counter, 16 tissues + clrf hi ; row counter +TFT_dive_tissues_N2_loop: + movlw dm_custom_tissue_diagram_top+.3 ; dive mode top start position N2 + rcall TFT_dive_tissues_bargraph ; draw tissue bargraph + incf hi,F ; increment row counter + decfsz lo,F ; decrement tissue counter, done? + bra TFT_dive_tissues_N2_loop ; NO - loop + IFDEF _helium + TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation? + bra TFT_dive_tissues_3 ; =1: show He tissue pressures + ENDIF + + ;---- Draw Tissue Saturations --------------------- ; + lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation movlw d'16' - movwf lo ; 16 tissues - clrf hi ; row offset -tissue_saturation_graph_N2: - movlw dm_custom_tissue_diagram_top+.3 ; divemode - rcall tissue_saturation_graph_loop ; show one tissue - decfsz lo,F - bra tissue_saturation_graph_N2 - - ;---- Draw He Tissues ---------------------------------------------------- - - movlw dm_custom_tissue_diagram_left+.8 ; divemode - movwf win_leftx2 ; column left (0-159) - movlw .159-dm_custom_tissue_diagram_left-.14 ; width - movwf win_width - - lfsr FSR2, char_O_tissue_He_saturation + movwf lo ; tissue counter, 16 tissues + clrf hi ; row counter + movlw color_grey ; color for tissue saturation, alternative: color_lightblue + movwf ex ; store in ex +; movlw color_yellow ; 2nd color is not used by tissue saturation +; movwf ul ; ... +TFT_dive_tissues_sat_loop: + movlw dm_custom_tissue_diagram_top+.3+.22 ; dive mode top start position saturations + rcall TFT_dive_tissues_bargraph ; draw tissue bargraph + incf hi,F ; increment row counter + decfsz lo,F ; decrement tissue counter, done? + bra TFT_dive_tissues_sat_loop ; NO - loop + + ;---- common Part for vertical lines--------------- ; + movlw dm_custom_tissue_diagram_top+.3+.22 ; get top position + movwf win_top ; set top position (0-239) + movlw .15 ; get hight + movwf win_height ; set height + movlw .1 ; get width + movwf win_width+0 ; set width, low byte + clrf win_width+1 ; set width, high byte + + ;---- Print 100% Line ----------------------------- ; + movlw dm_custom_tissue_diagram_left+.3+.33 ; get left position + movwf win_leftx2 ; set left position (0-159) + movlw color_red ; color for 100% line + call TFT_set_color ; set color + call TFT_box ; draw line + + ; GF factors enabled? + TSTOSS char_I_deco_model ; GF factors enabled? + bra TFT_dive_tissues_4 ; NO - continue with number of leading tissue + + ;---- Print GF low Line -------------------------- ; + movlw dm_custom_tissue_diagram_left+.3 ; get left base position + movwf win_leftx2 ; set left base position (0-159) + movff char_I_GF_Low_percentage,WREG ; get GF low in 0.01 % + mullw .82 ; multiply with 82 + movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125 + addwf win_leftx2,F ; add to base position + movlw color_green ; color for 100% line + call TFT_set_color ; set color + call TFT_box ; draw line + + ;---- Print GF high Line -------------------------- ; + movlw dm_custom_tissue_diagram_left+.3 ; get left base position + movwf win_leftx2 ; set left base position (0-159) + movff char_I_GF_High_percentage,WREG ; get GF high in 0.01 % + mullw .82 ; multiply with 82 + movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125 + addwf win_leftx2,F ; add to base position + movlw color_yellow ; color for 100% line + call TFT_set_color ; set color + call TFT_box ; draw line + bra TFT_dive_tissues_4 ; continue with number of leading tissue + + IFDEF _helium +TFT_dive_tissues_3: + ;---- Draw He Tissues Pressures ------------------- ; + movlw dm_custom_tissue_diagram_left+.3+.4 ; get dive mode left start position for He bars + movwf win_leftx2 ; set column left (0-159) + movlw .159-dm_custom_tissue_diagram_left-.4-.4 ; get max width for He bars + movwf win_width+0 ; set width (low byte) + clrf win_width+1 ; ... + lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures movlw d'16' - movwf lo ; 16 tissues - clrf hi ; row offset -tissue_saturation_graph_He: - movlw dm_custom_tissue_diagram_top+.3+.22 ; divemode - rcall tissue_saturation_graph_loop ; show one tissue - decfsz lo,F - bra tissue_saturation_graph_He - - ;---- Print Number of leading Tissue ------------------------------------- - - ; TODO: some flicker due to overwriting by tissue bars - - movff int_O_gradient_factor+0,WREG ; get current gradient factor (only low byte used for value) - tstfsz WREG ; current gradient factor = 0 ? - bra tissue_saturation_graph_0 ; NO - print number of leading tissue + movwf lo ; tissue counter, 16 tissues + clrf hi ; row counter +TFT_dive_tissues_He_loop: + movlw dm_custom_tissue_diagram_top+.3+.22 ; dive mode top start position H2 + rcall TFT_dive_tissues_bargraph ; draw tissue bargraph + incf hi,F ; increment row counter + decfsz lo,F ; decrement tissue counter, done? + bra TFT_dive_tissues_He_loop ; NO - loop + ENDIF + +TFT_dive_tissues_4: + ;---- Print Number of leading Tissue -------------- ; TODO: some flicker due to overwriting by tissue bars + movff int_O_lead_supersat+0,WREG ; get current leading tissue's supersaturation (only low byte used for value) + tstfsz WREG ; current supersaturation = 0 ? + bra TFT_dive_tissues_5 ; NO - print number of leading tissue movff char_O_deco_info,WREG ; YES - get deco info vector btfss WREG,deco_ceiling ; - do we have a ceiling obligation? goto TFT_standard_color ; NO - can ascent directly, don't print number, set standard color and return ; YES - print number of leading tissue -tissue_saturation_graph_0: - movff char_O_lead_number,lo ; get number of leading tissue as 0-15 +TFT_dive_tissues_5: + movff char_O_lead_tissue,lo ; get number of leading tissue as 0-15 incf lo,F ; adjust to 1-16 movlw .10 cpfsgt lo ; is it > 10 ? - bra tissue_saturation_graph_1 ; NO - will output a single digit number + bra TFT_dive_tissues_6 ; NO - will output a single digit number ; start position for a 2 digit number - WIN_TINY dm_custom_tissue_diagram_left+.32,dm_custom_tissue_diagram_top+.16 - bra tissue_saturation_graph_2 -tissue_saturation_graph_1: + WIN_TINY dm_custom_tissue_diagram_left+.32,dm_custom_tissue_diagram_top+.10 + bra TFT_dive_tissues_7 +TFT_dive_tissues_6: ; start position for a 1 digit number - WIN_TINY dm_custom_tissue_diagram_left+.32+.4,dm_custom_tissue_diagram_top+.16 -tissue_saturation_graph_2: + WIN_TINY dm_custom_tissue_diagram_left+.32+.4,dm_custom_tissue_diagram_top+.10 +TFT_dive_tissues_7: call TFT_standard_color ; set output color bsf leftbind - output_8 ; print number in leftbind, i.e. without leading zeros or spaces + output_8 ; print number in left aligned, i.e. without leading zeros or spaces bcf leftbind STRCAT_PRINT "" ; finalize output return -tissue_saturation_graph_loop: - addwf hi,W - movwf win_top ; row top (0-239) - movlw color_cyan ; preset color for tissues with decreasing pressure - call TFT_set_color - incf hi,F - movf POSTINC2,W - btfss WREG,7 ; check if flag for increasing tissue pressure set - bra tissue_saturation_graph_loop_1 ; NO - keep color - movwf up ; YES - buffer WREG - movlw color_orange ; select color for tissues with increasing pressure - call TFT_set_color ; change color - movf up,W ; restore WREG -tissue_saturation_graph_loop_1: - bcf WREG,7 ; clear flag bit - bcf STATUS,C - rrcf WREG ; divide by 2 - incf WREG,W ; add a bit for a minimum visible bar - movwf up - movf win_width,W ; get max window width (win_width) - cpfslt up ; skip if WREG < win_width - movwf up - movff up,win_bargraph - clrf win_width+1 - goto TFT_box ; and return... +TFT_dive_tissues_bargraph: + addwf hi,W ; add row number to start position + movwf win_top ; set as row top (0-239) + movff POSTINC2,up ; get tissue value + movf ex,W ; default color + btfsc up,7 ; check if flag in bit 7 is set + movf ul,W ; YES - switch to 2nd color + call TFT_set_color ; set bargraph bar color + bcf up,7 ; clear flag bit + bcf STATUS,C ; clear carry bit + rrcf up,F ; divide by 2 + incf up,W ; add a bit for a minimum visible bar + movwf win_bargraph ; set bargraph bar length + goto TFT_box ; draw bargraph and return ;============================================================================= - global TFT_display_cns -TFT_display_cns: - call TFT_warning_set_window ; set the row and column for the current message + global TFT_show_cns +TFT_show_cns: + call TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO STRCPY_TEXT tCNS ; CNS: - movff int_O_CNS_fraction+0,lo - movff int_O_CNS_fraction+1,hi + MOVII int_O_CNS_current,mpr ; get current CNS call TFT_color_code_cns ; color-code CNS output bsf leftbind output_16_3 ; displays only 0...999 bcf leftbind PUTC "%" - movlw dm_warning_length ; divemode string length - btfss divemode ; In divemode? + movlw dm_warning_length ; dive mode string length + btfss divemode ; In dive mode? movlw surf_warning_length ; NO - use surface string length - call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) + call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) STRCAT_PRINT "" bcf win_invert bra TFT_custview_exit3 ; and return... - global TFT_display_eod_cns -TFT_display_eod_cns: - call TFT_warning_set_window ; set the row and column for the current message + global TFT_warning_eod_cns +TFT_warning_eod_cns: + call TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO - call TFT_warnings_color ; switch to warnings (red) text color + call TFT_warning_color ; switch to warnings (red) text color STRCPY_TEXT tCNSeod ; end-of-dive CNS warning text - movlw dm_warning_length ; divemode string length - call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) + movlw dm_warning_length ; dive mode string length + call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) STRCAT_PRINT "" bra TFT_custview_exit3 ; and return... - global TFT_display_ppo2_warning -TFT_display_ppo2_warning: ; with ppO2 including attention/warning flags in hi:lo - call TFT_warning_set_window ; set the row and column for the current message + global TFT_show_ppo2_warning +TFT_show_ppo2_warning: ; with ppO2 including attention/warning flags in hi:lo + call TFT_set_message_window ; set the row and column for the current message tstfsz WREG ; is there room for the message? return ; NO call TFT_color_code_ppo2 ; color-code output - btfsc FLAG_bailout_mode ; in bailout? + btfsc bailout_mode ; in bailout? bra TFT_display_diluent_2 ; YES btfss FLAG_ccr_mode ; in CCR mode? bra TFT_display_diluent_1 ; NO - continue with pSCR or OC @@ -4601,18 +5020,20 @@ bsf leftbind output_16dp .3 ; x.xx bar bcf leftbind - movlw dm_warning_length ; divemode string length + movlw dm_warning_length ; dive mode string length call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) STRCAT_PRINT "" TFT_custview_exit3: goto TFT_standard_color ; and return... + IFDEF _compass + global TFT_surf_set_bearing TFT_surf_set_bearing: - btfsc premenu - return ; already shown, return - bsf premenu ; set flag + btfsc compass_menu ; is the "set bearing" selection shown? + return ; YES - return + bsf compass_menu ; NO - set "set bearing" selection as shown WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right WIN_SMALL surf_compass_bear_column,surf_compass_bear_row WIN_COLOR color_yellow @@ -4621,17 +5042,17 @@ bcf win_invert return + ENDIF + ;============================================================================= - global TFT_LogOffset_Logtitle -TFT_LogOffset_Logtitle: - STRCPY_TEXT tLogOffset - PUTC ":" - call do_logoffset_common_read ; offset into lo:hi - bsf leftbind - output_16_4 - bcf leftbind - PUTC " " + global TFT_LogOffset +TFT_LogOffset: + STRCPY_TEXT tLogOffsetValue ; print "Offset" in selected language + call do_logoffset_common_read ; read offset into lo:hi +; bsf leftbind + output_16_4 ; print offset in 4 digits +; bcf leftbind return ; no "_PRINT" here... ;============================================================================= @@ -4669,7 +5090,7 @@ return ; - done TFT_dive_tankdata_mask_helper_1: decf WREG,W ; (1..10) -> (0..9) - bsf short_gas_decriptions ; just "Air", "O2" or "xx/yy" + bsf short_gas_descriptions ; just "Air", "O2" or "xx/yy" call gaslist_strcat_gas_WREG ; print composition of gas/dil in WREG (0..9) bra TFT_dive_tankdata_mask_helper_3 ; finish with adding "(bar)" TFT_dive_tankdata_mask_helper_2: @@ -4701,12 +5122,11 @@ btfsc aux_flag ; shall reading 2 show need to reading 1 ? bra TFT_pressures_SAC_1 ; YES movff int_IO_pressure_value+2,lo ; NO - copy pressure 2 to hi:lo - movff int_IO_pressure_value+3,hi ; + movff int_IO_pressure_value+3,hi movff char_I_pressure_stat+1,ex ; - copy status data bra TFT_pressures_SAC_2 TFT_pressures_SAC_1: - movff int_O_pressure_need+0,lo ; YES - copy need to pressure 1 to hi:lo - movff int_O_pressure_need+1,hi ; + MOVII int_O_pressure_need,mpr ; YES - copy need to pressure 1 to hi:lo clrf ex ; - set status data to 0 TFT_pressures_SAC_2: ; pressure of reading 2 @@ -4717,8 +5137,7 @@ rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator ; SAC WIN_STD dm_custom_tankdata_SAC_col+.6,dm_custom_tankdata_row - movff int_O_sac_rate+0,lo ; copy SAC rate to hi:lo - movff int_O_sac_rate+1,hi + MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo btfsc hi,int_not_avail_flag ; SAC rate available? bra TFT_pressures_SAC_4 ; NO - print " --.-" call TFT_color_code_tank_pres_sac ; color-code the output @@ -4809,12 +5228,12 @@ global TFT_surface_tank_pres TFT_surface_tank_pres: ; show pressure reading above surface pressure WIN_SMALL surf_decotype_column+.6,surf_decotype_row+.30+.47 - movff int_IO_pressure_value+0,lo ; copy pressure from 1st reading, low byte - movff int_IO_pressure_value+1,hi ; copy pressure from 1st reading, high byte + movff int_IO_pressure_value+0,lo ; copy pressure from 1st reading to hi:lo + movff int_IO_pressure_value+1,hi btfss hi,int_not_avail_flag ; pressure reading 1 available? bra TFT_surface_tank_pres_0 ; YES - movff int_IO_pressure_value+2,lo ; NO - copy pressure from 2nd reading, low byte - movff int_IO_pressure_value+3,hi ; - copy pressure from 2nd reading, high byte + movff int_IO_pressure_value+2,lo ; NO - copy pressure from 2nd reading to hi:lo + movff int_IO_pressure_value+3,hi btfsc hi,int_not_avail_flag ; - pressure reading 2 available? bra TFT_surface_tank_pres_1 ; NO - show not avail message TFT_surface_tank_pres_0: ; YES - show pressure @@ -4850,7 +5269,7 @@ return TFT_surface_tankdata_print: ; max 12 char - call TFT_standard_color + call TFT_standard_color ; set color movff POSTINC1,hi ; ID high (+0) movff POSTINC1,lo ; ID low (+1) tstfsz hi ; ID high = 0 ? @@ -4876,7 +5295,7 @@ movf POSTINC1,W ; status (+4) andlw .7 ; mask out battery voltage bnz TFT_surface_tankdata_2 ; branch if battery is not completely drained - call TFT_warnings_color ; output in red + call TFT_warning_color ; output in red STRCAT_PRINT "XXX" ; "XXX" for low bra TFT_surface_tankdata_print_3 TFT_surface_tankdata_2: @@ -4893,141 +5312,122 @@ return -TFT_surface_tankdata_debug: ; surface custom view debug output - call TFT_standard_color - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*0 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*1 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*2 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*3 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*4 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*5 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*6 - rcall TFT_surface_tankdata_debug_print - WIN_TINY surf_customtext_column,surf_customtext_row1+.14*7 - rcall TFT_surface_tankdata_debug_print - return - -TFT_surface_tankdata_debug_print: - movff POSTINC1,hi ; ID high (+0) - movff POSTINC1,lo ; ID low (+1) - output_16 - PUTC "," - movff POSTINC1,hi ; pressure high (+2) - movff POSTINC1,lo ; pressure low (+3) - call TFT_color_code_tank_pres_sac; needed to clear the status flags before output - output_16 - PUTC "," - movff POSTINC1,lo ; status (+4) - output_8 - PUTC "," - movff POSTINC1,lo ; date (+5) - output_8 - STRCAT_PRINT "" - return - ENDIF +; TFT_surface_tankdata_debug: ; surface custom view debug output + ; call TFT_standard_color + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*0 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*1 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*2 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*3 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*4 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*5 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*6 + ; rcall TFT_surface_tankdata_debug_print + ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*7 + ; rcall TFT_surface_tankdata_debug_print + ; return + +; TFT_surface_tankdata_debug_print: + ; movff POSTINC1,hi ; ID high (+0) + ; movff POSTINC1,lo ; ID low (+1) + ; output_16 + ; PUTC "," + ; movff POSTINC1,hi ; pressure high (+2) + ; movff POSTINC1,lo ; pressure low (+3) + ; call TFT_color_code_tank_pres_sac; needed to clear the status flags before output + ; output_16 + ; PUTC "," + ; movff POSTINC1,lo ; status (+4) + ; output_8 + ; PUTC "," + ; movff POSTINC1,lo ; date (+5) + ; output_8 + ; STRCAT_PRINT "" + ; return + + ENDIF ; _rx_functions ;============================================================================= global adjust_depth_with_salinity global adjust_depth_with_salinity_log -adjust_depth_with_salinity: ; computes salinity setting into lo:hi [mbar] - btfsc simulatormode_active ; do not apply salinity in simulator mode - return +adjust_depth_with_salinity: ; computes salinity setting into hi:lo [mbar] + btfsc sensor_override_active ; in pressure sensor override mode? + return ; YES - do not apply salinity in override mode movff opt_salinity,WREG ; 0-5% -adjust_depth_with_salinity_log: ; computes salinity setting (FROM WREG!) into lo:hi [mbar] +adjust_depth_with_salinity_log: ; computes salinity setting (FROM WREG!) into hi:lo [mbar] addlw d'100' ; 1.00kg/l movwf up movlw d'105' ; 105% ? cpfslt up ; salinity upper limit - return ; out of limit, do not adjust lo:hi + return ; out of limit, do not adjust hi:lo movlw d'99' ; 99% ? cpfsgt up ; salinity lower limit - return ; out of limit, do not adjust lo:hi - - movff lo,xA+0 - movff hi,xA+1 - - movlw d'102' ; 0.98 bar / 10 meter - movwf xB+0 - clrf xB+1 + return ; out of limit, do not adjust hi:lo + + MOVII mpr, xA ; depth in mbar + MOVLI .102,xB ; 0.98 bar / 10 meter call mult16x16 ; xC:4 = xA:2 * xB:2 movff up,xB+0 ; salinity clrf xB+1 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder - movff xC+0,lo - movff xC+1,hi ; copy corrected values back to lo and hi + MOVII xC,mpr ; copy corrected values back to hi:lo return ;============================================================================= global convert_mbar_to_feet convert_mbar_to_feet: ; convert value in hi:lo from mbar to feet - movff lo,xA+0 - movff hi,xA+1 - - movlw LOW d'328' ; 328feet/100m - movwf xB+0 - movlw HIGH d'328' - movwf xB+1 - - call mult16x16 ; xA*xB=xC (lo:hi * 328) - + MOVII mpr, xA ; depth in mbar (multiples of 0.01 meter) + btfsc sensor_override_active ; in pressure sensor override mode? + bra convert_mbar_to_feet_1 ; YES + MOVLI .328,xB ; NO - convert with 328feet/100m + bra convert_common_to_feet ; - continue with common part +convert_mbar_to_feet_1: + MOVLI .334,xB ; YES - convert with 334feet/100m to be in sync with values shown in menu + bra convert_common_to_feet ; - continue with common part + + + global convert_meter_to_feet +convert_meter_to_feet: ; convert value in lo from meters to feet + movf lo,W ; depth in meter + mullw .100 ; convert meter to mbar + MOVII PRODL,xA ; depth in mbar (multiples of 0.01 meter) + MOVLI .334,xB ; convert with 334feet/100m to have 10ft, 20ft, 30ft for stop depths + +convert_common_to_feet: + call mult16x16 ; xC = xA * xB = depth in 0.01 meter * xxx feet / 100 meter movlw d'50' ; round up addwf xC+0,F - movlw 0 + movlw .0 addwfc xC+1,F addwfc xC+2,F addwfc xC+3,F - - movlw LOW .10000 - movwf xB+0 - movlw HIGH .10000 - movwf xB+1 - - call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder - - movff xC+0,lo - movff xC+1,hi ; restore lo and hi with updated value + MOVLI .10000,xB ; 10000 = 100 for depth in 0.01 meter to full meter x 100 for feet factor is per 100 meter + call div32x16 ; xC = xC / xB with xA as remainder + MOVII xC,mpr ; store result + return ;============================================================================= - global convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit + global convert_celsius_to_fahrenheit ; convert value in hi:lo from Celsius to Fahrenheit convert_celsius_to_fahrenheit: ; convert value in lo:hi from Celsius to Fahrenheit - movff lo,xA+0 ; temperature in 1/10 of °C - movff hi,xA+1 - - movlw LOW d'1000' ; offset °C value by 1000 to get out of any negative numbers - addwf xA+0,F - movlw HIGH d'1000' - addwfc xA+1,F - - movlw d'18' ; adjust scaling: 1°C = 1.8°F - movwf xB+0 - clrf xB+1 - - call mult16x16 ; xA*xB=xC (lo:hi * 18) - - movlw d'10' - movwf xB+0 - clrf xB+1 - - call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder - - movlw LOW d'1480' ; adjust offset: subtract above offset of 1000 * 1.8 = 1800 now and add 320 => subtract 1480 - subwf xC+0,F - movlw HIGH d'1480' - subwfb xC+1,F - - movff xC+0,lo - movff xC+1,hi ; restore lo and hi with updated value + MOVII mpr,xA ; temperature in 1/10 of °C + ADDLI .1000,xA ; add offset of 1000 to get out of any negative numbers + ; adjust scaling: 1°C = 1.8°F: + MOVLI .18,xB ; multiply with 18: + call mult16x16 ; ... + MOVLI .10,xB ; divide by 10 + call div32x16 ; ... + SUBLI .1480,xC ; remove offset: subtract above offset of 1000 * 1.8 = 1800 now and add 320 => subtract 1480 + MOVII xC,mpr ; store result in hi:lo return ;=============================================================================