comparison src/tft_outputs.asm @ 634:4050675965ea

3.10 stable release
author heinrichsweikamp
date Tue, 28 Apr 2020 17:34:31 +0200
parents 690c48db7b5b
children 9a64914a8fca
comparison
equal deleted inserted replaced
633:690c48db7b5b 634:4050675965ea
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File tft_outputs.asm next combined generation V3.09.1 fix 3 ; File tft_outputs.asm * combined next generation V3.09.5
4 ; 4 ;
5 ; high-level Display Outputs 5 ; high-level Display Outputs
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
19 #include "math.inc" 19 #include "math.inc"
20 #include "eeprom_rs232.inc" 20 #include "eeprom_rs232.inc"
21 #include "adc_lightsensor.inc" 21 #include "adc_lightsensor.inc"
22 #include "surfmode.inc" 22 #include "surfmode.inc"
23 #include "divemode.inc" 23 #include "divemode.inc"
24 #include "external_flash.inc"
25 #include "ghostwriter.inc" 24 #include "ghostwriter.inc"
26 #include "customview.inc" 25 #include "customview.inc"
27 #include "i2c.inc" 26 #include "i2c.inc"
28 #include "colorschemes.inc"
29 #include "calibrate.inc" 27 #include "calibrate.inc"
30 #include "gaslist.inc" 28 #include "gaslist.inc"
31 #include "rx_ops.inc" 29 #include "rx_ops.inc"
32 #include "logbook.inc" 30 #include "logbook.inc"
31 #include "external_flash.inc"
32 #include "colorschemes.inc"
33 33
34 34
35 ;---- external Functions ----------------------------------------------------- 35 ;---- external Functions -----------------------------------------------------
36 36
37 extern aa_wordprocessor
38 extern get_first_gas_to_WREG 37 extern get_first_gas_to_WREG
39
40 38
41 ;---- external Texts --------------------------------------------------------- 39 ;---- external Texts ---------------------------------------------------------
42 40
43 extern tFirmware 41 extern tFirmware
44 extern tFirmwareDate 42 extern tFirmwareDate
65 IFDEF _compass 63 IFDEF _compass
66 extern tCalX,tCalY,tCalZ 64 extern tCalX,tCalY,tCalZ
67 ENDIF 65 ENDIF
68 66
69 67
70 tft_out CODE
71
72 ;============================================================================= 68 ;=============================================================================
73 69 pallet_table CODE_PACK 0x09800 ; must be at 0x***00
74 global TFT_debug_output
75 TFT_debug_output:
76 ifndef _debug_output
77 return
78 else
79 btfsc alt_layout_active ; alternative layout active?
80 return ; YES - abort
81
82 ; WIN_TINY .100,.30 ; surface mode: fits under the textual logo in the upper right corner
83 ; WIN_TINY .35, .0 ; dive mode: fits to the right side of the depth label
84 WIN_TINY .0, .0 ; dive mode: overwrites depth label
85 call TFT_standard_color
86 lfsr FSR2,buffer
87
88 ; print an 16 bit integer as x.yy
89 ;MOVII int_O_profiling_overrun,mpr
90 ;output_16dp .3
91 ;STRCAT_PRINT ""
92 ;return
93
94 ; deco engine scheduling performance
95 MOVII int_O_profiling_overrun,mpr ; runtime +/- versus target
96 btfss mpr+1,7
97 bra TFT_debug_output_1
98 bcf mpr+1,7
99 PUTC "-"
100 bra TFT_debug_output_2
101 TFT_debug_output_1:
102 PUTC " "
103 TFT_debug_output_2:
104 output_16_3
105 PUTC "."
106 MOVII int_O_profiling_overrun_max,mpr ; max runtime
107 output_16_3
108 PUTC "."
109 movff char_O_profiling_overrun_phase,WREG ; calculation phase causing the max runtime
110 output_hex
111 PUTC "."
112 movff char_O_profiling_runs_norm,mpr ; runs/cycle normal plan
113 output_99
114 PUTC "."
115 movff char_O_profiling_runs_alt,mpr ; runs/cycle alternative plan
116 output_99
117 STRCAT_PRINT ""
118 return
119 endif
120
121
122 ;============================================================================= 70 ;=============================================================================
123 71
124 global TFT_divemask_color 72
125 TFT_divemask_color: 73 pallet_table:
126 movlw color_green 74 ; mask disabled memo advice attention warning ; pallet
127 btfsc divemode ; in dive mode? 75 ; --------------- ------------------- --------------- --------------- --------------- --------------- --------
128 rcall TFT_divemask_color_dive 76 DB color_green, color_lightblue, color_white, color_green, color_yellow, color_red ; standard
129 bra TFT_standard_color0 77 DB color_red, color_dark_red, color_orange, color_green, color_yellow, color_red ; redish
130 78 DB color_cyan, color_dark_green, color_green, color_green, color_yellow, color_red ; greenish
131 TFT_divemask_color_dive: 79 DB color_blue, color_deepblue, color_lightblue,color_green, color_yellow, color_red ; blueish
132 movff opt_dive_color_scheme,WREG ; 0-3 80
133 incf WREG 81
134 dcfsnz WREG 82 ;=============================================================================
135 retlw color_scheme_divemode_mask1 ;0 83 tft_out1 CODE
136 dcfsnz WREG 84 ;=============================================================================
137 retlw color_scheme_divemode_mask2 ;1 85
138 dcfsnz WREG 86
139 retlw color_scheme_divemode_mask3 ;2 87 ;-----------------------------------------------------------------------------
140 retlw color_scheme_divemode_mask4 ;3 88 ; load standard Color Pallet
141 89 ;
142 90 global TFT_load_std_color_pallet
143 global TFT_memo_color 91 TFT_load_std_color_pallet:
144 TFT_memo_color: ; information, values within normal range, things without a need to react upon 92 clrf WREG ; select standard pallet
145 movlw color_white 93 bra TFT_load_color_pallet ; load color pallet
146 bra TFT_standard_color0 94
147 TFT_memo_color_dive: 95
148 retlw color_white 96 ;-----------------------------------------------------------------------------
149 97 ; load Dive Mode Color Pallet
150 global TFT_advice_color 98 ;
151 TFT_advice_color: ; advices to do something, but without essential need to actually do it 99 global TFT_load_dive_color_pallet
152 movlw color_green 100 TFT_load_dive_color_pallet:
153 bra TFT_standard_color0 101 movff opt_dive_color_scheme,WREG ; get color scheme selection
154 TFT_advice_color_dive: 102 ;bra TFT_load_color_pallet ; load color pallet
155 retlw color_green 103
156 104
157 global TFT_attention_color ; important things to be aware of and things that are developing towards a warning 105 ; Helper Function - load color pallet
158 TFT_attention_color: 106 TFT_load_color_pallet:
159 movlw color_yellow 107 mullw .6 ; 6 bytes per pallet, compute pallet offset
160 bra TFT_standard_color0 108
161 TFT_attention_color_dive: 109 movf PRODL,W ; get pallet offset, low
162 retlw color_yellow 110 movwf TBLPTRL ; set table pointer, low
163 111
164 global TFT_warning_color ; important things with immediate need to react upon 112 movlw HIGH (pallet_table) ; get start of table, high
165 TFT_warning_color: 113 movwf TBLPTRH ; set table pointer, high
166 movlw color_red 114
167 bra TFT_standard_color0 115 movlw UPPER (pallet_table) ; get start of table, upper
168 TFT_warnings_color_dive: 116 movwf TBLPTRU ; set table pointer, upper
169 retlw color_red 117
170 118 lfsr FSR2,pallet_color_mask ; point to first color in pallet
171 119 movlw .6 ; initialize loop counter
172 global TFT_disabled_color 120 TFT_load_color_pallet_loop:
173 TFT_disabled_color: 121 TBLRD*+ ; read color
174 movlw color_lightblue 122 movff TABLAT,POSTINC2 ; copy color to pallet
175 btfsc divemode ; in dive mode? 123 decfsz WREG ; decrement loop counter, reached zero?
176 rcall TFT_disabled_color_dive ; YES 124 bra TFT_load_color_pallet_loop ; NO - loop
177 bra TFT_standard_color0 125 return ; YES - done
178 TFT_disabled_color_dive: 126
179 movff opt_dive_color_scheme,WREG ; 0-3 127
180 incf WREG 128 ;=============================================================================
181 dcfsnz WREG 129 tft_out2 CODE
182 retlw color_scheme_divemode_dis1 ; 0 130 ;=============================================================================
183 dcfsnz WREG 131
184 retlw color_scheme_divemode_dis2 ; 1 132
185 dcfsnz WREG 133 ;-----------------------------------------------------------------------------
186 retlw color_scheme_divemode_dis3 ; 2 134 ; Color-Code a Tank Pressure or SAC Rate
187 retlw color_scheme_divemode_dis4 ; 3 135 ;
188 136 ; Input hi:lo pressure / SAC rate
189 137 ;
190 global TFT_standard_color 138 TFT_color_code_pres_sac:
191 TFT_standard_color:
192 setf WREG ; default white
193 btfsc divemode ; in dive mode?
194 rcall TFT_standard_color_dive
195 ;bra TFT_standard_color0
196 TFT_standard_color0:
197 goto TFT_set_color ; and return...
198
199
200 TFT_standard_color_dive:
201 movff opt_dive_color_scheme,WREG ; 0-3
202 incf WREG
203 dcfsnz WREG
204 retlw color_scheme_divemode_std1 ; 0
205 dcfsnz WREG
206 retlw color_scheme_divemode_std2 ; 1
207 dcfsnz WREG
208 retlw color_scheme_divemode_std3 ; 2
209 retlw color_scheme_divemode_std4 ; 3
210
211
212 global TFT_color_code_tank_pres_sac
213 TFT_color_code_tank_pres_sac: ; color-code a tank pressure or SAC rate, data in hi:lo
214 btfss hi,int_not_avail_flag ; is the not-available flag set? 139 btfss hi,int_not_avail_flag ; is the not-available flag set?
215 bra TFT_color_code_tank_pres_1 ; NO 140 bra TFT_color_code_tank_pres_1 ; NO
216 bcf hi,int_not_avail_flag ; YES - clear not-available flag 141 bcf hi,int_not_avail_flag ; YES - clear not-available flag
217 TFT_color_code_tank_pres_0: ; entry point for outdated flag 142 TFT_color_code_tank_pres_0: ; - entry point for outdated flag
218 bcf hi,int_outdated_flag ; clear outdated flag (it may be set) 143 bcf hi,int_outdated_flag ; - clear outdated flag (it may be set)
219 bcf hi,int_warning_flag ; clear warning flag (it may be set) 144 bcf hi,int_warning_flag ; - clear warning flag (it may be set)
220 bcf hi,int_attention_flag ; clear attention flag (it may be set) 145 bcf hi,int_attention_flag ; - clear attention flag (it may be set)
221 bra TFT_disabled_color ; set to disabled color and return 146 FONT_COLOR_DISABLED ; - set to disabled color and return
147 return ; - done
148
222 TFT_color_code_tank_pres_1: 149 TFT_color_code_tank_pres_1:
223 btfsc hi,int_outdated_flag ; is the outdated flag set? 150 btfsc hi,int_outdated_flag ; is the outdated flag set?
224 bra TFT_color_code_tank_pres_0 ; YES - handle alike with not-available flag 151 bra TFT_color_code_tank_pres_0 ; YES - handle alike with not-available flag
152 btfss hi,int_warning_flag ; NO - is the warning flag set?
153 bra TFT_color_code_tank_pres_2 ; NO
154 bcf hi,int_attention_flag ; YES - clear attention flag (it may be set)
155 bcf hi,int_warning_flag ; - clear warning flag
156 FONT_COLOR_WARNING ; - select warning color
157 return ; - done
158
225 TFT_color_code_tank_pres_2: 159 TFT_color_code_tank_pres_2:
226 btfss hi,int_warning_flag ; is the warning flag set? 160 btfss hi,int_attention_flag ; is the attention flag set?
227 bra TFT_color_code_tank_pres_3 ; NO 161 bra TFT_color_code_tank_pres_3 ; NO - set memo color and return
228 bcf hi,int_warning_flag ; YES - clear warning flag 162 bcf hi,int_attention_flag ; YES - clear attention flag
229 bcf hi,int_attention_flag ; - clear attention flag (it may be set) 163 FONT_COLOR_ATTENTION ; - set to attention color
230 bra TFT_warning_color ; - set to warning color and return 164 return ; - done
165
231 TFT_color_code_tank_pres_3: 166 TFT_color_code_tank_pres_3:
232 btfss hi,int_attention_flag ; is the attention flag set? 167 FONT_COLOR_MEMO ; set to memo color
233 bra TFT_memo_color ; NO - set to memo color and return 168 return ; done
234 bcf hi,int_attention_flag ; YES - clear attention flag 169
235 bra TFT_attention_color ; - set to attention color and return 170
236 171 ;-----------------------------------------------------------------------------
237 172 ; Color-Code a Gas by its ppO2
173 ;
174 ; Input hi O2% of the gas
175 ; pressure_abs_10 current absolute pressure / 10
176 ;
238 global TFT_color_code_gaslist 177 global TFT_color_code_gaslist
239 TFT_color_code_gaslist: ; color-code a gas (%O2 in hi) according to current absolute pressure 178 TFT_color_code_gaslist:
240 ; Check very high ppO2 manually 179 ; check for very high ppO2
241 MOVII pressure_abs_10,xA 180 MOVII pressure_abs_10,xA ; get absolute pressure / 10
242 movff hi,xB+0 181 movff hi,xB+0 ; get O2%
243 clrf xB+1 182 clrf xB+1 ; ...
244 call mult16x16 ; hi * absolute pressure / 10 183 call mult16x16 ; hi * absolute pressure / 10
245 ; Check if ppO2 > 6.55 bar 184 ; check if ppO2 > 6.55 bar
246 tstfsz xC+2 ; char_I_O2_ratio * absolute pressure / 10 > 65536, i.e. ppO2 > 6.55 bar ? 185 tstfsz xC+2 ; char_I_O2_ratio * absolute pressure / 10 > 65536, i.e. ppO2 > 6.55 bar ?
247 bra TFT_warning_color ; YES - warn in warning color 186 bra TFT_color_code_gaslist_warn ; YES - set warning color and return
248 ; Check if ppO2 > 3.30 bar 187
249 btfsc xC+1,7 188 ; check if ppO2 > 3.30 bar
250 bra TFT_warning_color ; YES - warn in warning color 189 btfsc xC+1,7 ; ppO2 > 3.30 bar ?
251 ; Check for low ppO2 190 bra TFT_color_code_gaslist_warn ; YES - set warning color and return
252 MOVII xC,sub_a 191
253 movff char_I_ppO2_min,WREG 192 ; check for low ppO2
254 mullw d'100' ; char_I_ppO2_min*100 193 MOVII xC,sub_a ; get ppO2 of the gas
255 MOVII PRODL,sub_b 194 movff char_I_ppO2_min,WREG ; get minimum ppO2
195 mullw d'100' ; compute (minimum ppO2) * 100
196 MOVII PRODL,sub_b ; copy result to sub_b
256 call cmpU16 ; compare (sub_a - sub_b) 197 call cmpU16 ; compare (sub_a - sub_b)
257 btfsc neg_flag ; lower than ppO2 min? 198 btfsc neg_flag ; lower than ppO2 min?
258 bra TFT_warning_color ; YES - set warning color and return 199 bra TFT_color_code_gaslist_warn ; YES - set warning color and return
259 ; Check for high ppO2 200
201 ; check for high ppO2
260 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector 202 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector
261 btfsc WREG,deco_mode ; are we in deco? 203 btfsc WREG,deco_mode ; are we in deco?
262 bra TFT_color_code_gaslist_deco ; YES - check against ppO2 max deco only 204 bra TFT_color_code_gaslist_deco ; YES - check against ppO2 max deco only
263 ; NO - check against ppO2 max travel/normal and deco 205
264 ; Check for ppO2 max travel/normal 206 ; check for ppO2 max travel/normal
265 movff char_I_ppO2_max_work,WREG ; ppo2 max during working phase 207 movff char_I_ppO2_max_work,WREG ; ppo2 max during working phase
266 mullw d'100' ; char_I_ppO2_max_work*100 208 mullw d'100' ; char_I_ppO2_max_work*100
267 ADDLI ppO2_margin_on_max,PROD ; add ppO2 margin on max value to compensate for surface pressures > 1000 hPa 209 ADDLI ppO2_margin_on_max,PROD ; add ppO2 margin on max value to compensate for surface pressures > 1000 hPa
268 MOVII PRODL,sub_b ; copy result to sub_b 210 MOVII PRODL,sub_b ; copy result to sub_b
269 call cmpU16 ; compare (sub_a - sub_b) 211 call cmpU16 ; compare (sub_a - sub_b)
270 btfss neg_flag ; higher than ppO2 max travel/deco? 212 btfss neg_flag ; higher than ppO2 max travel/deco?
271 rcall TFT_attention_color ; YES - set attention color 213 FONT_COLOR_ATTENTION ; YES - set attention color
272 ; Check for ppO2 max deco 214 ;bra TFT_color_code_gaslist_deco ; continue checking against max deco
215
216 ; check for ppO2 max deco
273 TFT_color_code_gaslist_deco: 217 TFT_color_code_gaslist_deco:
274 movff char_I_ppO2_max_deco,WREG ; ppo2 max for deco 218 movff char_I_ppO2_max_deco,WREG ; ppo2 max for deco
275 mullw d'100' ; char_I_ppO2_max_deco * 100 219 mullw d'100' ; char_I_ppO2_max_deco * 100
276 ADDLI ppO2_margin_on_max,PROD ; add ppO2 margin on max value to compensate for surface pressures > 1000 hPa 220 ADDLI ppO2_margin_on_max,PROD ; add ppO2 margin on max value to compensate for surface pressures > 1000 hPa
277 MOVII PRODL,sub_b ; copy result to sub_b 221 MOVII PRODL,sub_b ; copy result to sub_b
278 call cmpU16 ; compare (sub_a - sub_b) 222 call cmpU16 ; compare (sub_a - sub_b)
279 btfss neg_flag ; higher than ppO2 max deco? 223 btfsc neg_flag ; higher than ppO2 max deco?
280 bra TFT_warning_color ; YES - set warning color and return 224 return ; NO - done
281 return ; NO - keep current color 225 ;bra TFT_color_code_gaslist_warn ; YES - set warning color and return
282 226
283 227
284 TFT_color_code_ceiling: ; color-code the ceiling depth 228 ; Helper Function - set waring color and return
229 TFT_color_code_gaslist_warn:
230 FONT_COLOR_WARNING ; select warning color
231 return ; done
232
233
234 ;-----------------------------------------------------------------------------
235 ; Color-Code the Ceiling Depth
236 ;
237 ; Input mpr ceiling depth [mbar]
238 ; pressure_rel_cur_cached current relative pressure [mbar]
239 ;
240 TFT_color_code_ceiling:
241 ; check for invalid
285 btfsc hi,char_invalid_flag ; is the invalid flag set? (bit 7 here) 242 btfsc hi,char_invalid_flag ; is the invalid flag set? (bit 7 here)
286 bra TFT_color_code_ceiling_1 ; YES - set disabled color 243 bra TFT_color_code_ceiling_dis ; YES - set to disabled color and return
287 MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure to sub_a 244
288 MOVII mpr,sub_b ; - get ceiling to sub_b 245 ; check for ceiling
289 call cmpU16 ; - sub_a - sub_b = relative pressure [mbar] - int_O_ceiling [mbar] 246 MOVII pressure_rel_cur_cached,sub_a;get current pressure to sub_a
290 btfss neg_flag ; - is current depth < ceiling (too shallow) ? 247 MOVII mpr,sub_b ; get ceiling to sub_b
291 bra TFT_memo_color ; NO - set to memo color and return 248 call cmpU16 ; sub_a - sub_b = relative pressure [mbar] - int_O_ceiling [mbar]
292 movff char_O_deco_warnings,WREG ; YES - bank-safe copy of deco warnings 249 btfss neg_flag ; is current depth < ceiling (too shallow) ?
293 btfsc WREG,outside_warning ; - are we currently outside of the ZH-L16 model? 250 bra TFT_color_code_ceiling_memo ; NO - set to memo color and return
294 bra TFT_warning_color ; YES - set to warnings color and return 251
295 bra TFT_attention_color ; NO - set to attention color and return 252 ; check for outside
296 TFT_color_code_ceiling_1: 253 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings
254 btfss WREG,outside_warning ; are we currently outside of the ZH-L16 model?
255 bra TFT_color_code_ceiling_attn ; NO - set to attention color and return
256 ;bra TFT_color_code_ceiling_warn ; YES - set to warnings color and return
257
258
259 ; Helper Functions - select color and return
260 TFT_color_code_ceiling_warn:
261 FONT_COLOR_WARNING ; select color
262 return ; done
263
264 TFT_color_code_ceiling_attn:
265 FONT_COLOR_ATTENTION ; select color
266 return ; done
267
268 TFT_color_code_ceiling_memo:
269 FONT_COLOR_MEMO ; select color
270 return ; done
271
272 TFT_color_code_ceiling_dis:
297 bcf hi,char_invalid_flag ; clear the invalid flag (bit 7 here) 273 bcf hi,char_invalid_flag ; clear the invalid flag (bit 7 here)
298 bra TFT_disabled_color ; set to disabled color and return 274 FONT_COLOR_DISABLED ; select disabled color
299 275 return ; done
300 276
301 TFT_color_code_stop: ; color-code the stop depth: memo color if below stop depth, 277
302 ; attention color if above stop but below ceiling, 278 ;-----------------------------------------------------------------------------
303 ; warning color if above stop and ceiling 279 ; Color-Code the Stop Depth
304 ; (ceiling depth is calculated using current GF) 280 ;
281 ; memo color if below stop depth,
282 ; attention color if above stop but below ceiling*,
283 ; warning color if above stop and ceiling*
284 ;
285 ; Input: depth_meter current depth
286 ; lo stop depth
287 ; char_O_deco_gas deco data valid flag
288 ;
289 ; * the ceiling depth is calculated using current (interpolated) GF
290 ;
291 TFT_color_code_stop:
292 ; check for invalid
305 movff char_O_deco_gas+0,WREG ; get flag for invalid deco data 293 movff char_O_deco_gas+0,WREG ; get flag for invalid deco data
306 btfsc WREG,char_invalid_flag ; is the invalid flag set? 294 btfsc WREG,char_invalid_flag ; is the invalid flag set?
307 bra TFT_disabled_color ; YES - set to disabled color and return 295 bra TFT_color_code_stop_dis ; YES - set to disabled color and return
308 movff char_O_deco_depth+0,WREG ; NO - get depth of first stop in meters into WREG 296
309 subwf depth_meter,W ; - compute current depth - stop depth 297 ; check for shallower than stop depth
310 btfsc STATUS,C ; - result negative? 298 movf lo,W ; get depth of first stop in meters into WREG
311 bra TFT_color_code_stop_1 ; NO - not shallower than stop depth, check for ascent advice 299 subwf depth_meter,W ; compute current depth - stop depth
312 MOVII int_O_ceiling,sub_b ; YES - get ceiling depth in mbar 300 btfsc STATUS,C ; result negative?
313 btfsc sub_b+1,char_invalid_flag ; - is the invalid flag set? (bit 7 here) 301 bra TFT_color_code_stop_1 ; NO - not shallower than stop depth, check for ascent advice
314 bra TFT_warning_color ; YES - set to warning color and return 302 MOVII int_O_ceiling,sub_b ; YES - get ceiling depth in mbar
315 MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure 303 btfsc sub_b+1,char_invalid_flag ; - is the invalid flag set? (bit 7 here)
316 call cmpU16 ; - sub_a - sub_b = relative pressure - int_O_ceiling 304 bra TFT_color_code_stop_warn ; YES - select warning color and return
317 btfsc neg_flag ; - is ceiling > current depth? 305 MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure
318 bra TFT_warning_color ; YES - set to warning color and return 306 call cmpU16 ; - sub_a - sub_b = relative pressure - int_O_ceiling
319 bra TFT_attention_color ; NO - set to attention color and return 307 btfsc neg_flag ; - is ceiling > current depth?
308 bra TFT_color_code_stop_warn ; YES - set to warning color and return
309 bra TFT_color_code_stop_attn ; NO - set to attention color and return
310
311 ; check for ascent advice
320 TFT_color_code_stop_1: 312 TFT_color_code_stop_1:
321 movff char_O_deco_depth+0,WREG ; get depth of first stop in meters into WREG 313 movf lo,W ; get depth of first stop in meters into WREG
322 incf WREG,W ; compute stop depth + 1 meter 314 incf WREG,W ; compute stop depth + 1 meter
323 subwf depth_meter,W ; compute current depth - (first stop depth + 1 meter) 315 subwf depth_meter,W ; compute current depth - (first stop depth + 1 meter)
324 btfss STATUS,C ; result negative? 316 btfss STATUS,C ; result negative?
325 bra TFT_memo_color ; YES - within 1 meter of stop depth, use memo color 317 bra TFT_color_code_stop_memo ; YES - within 1 meter of stop depth, use memo color
326 btfss deco_region ; NO - within deco stops region? 318 btfsc deco_region ; NO - within deco stops region?
327 bra TFT_memo_color ; NO - use memo color 319 bra TFT_color_code_stop_advc ; YES - use advice color and return
328 bsf win_invert ; YES - give ascent advice, ... 320 ;bra TFT_color_code_stop_memo ; NO - use memo color and return
329 bra TFT_advice_color ; - ... and return 321
330 322
331 323 ; Helper Functions - select color and return
324 TFT_color_code_stop_memo:
325 FONT_COLOR_MEMO ; select color
326 return ; done
327
328 TFT_color_code_stop_advc:
329 FONT_COLOR_ADVICE ; select color
330 bsf win_invert ; print in inverse
331 return ; done
332
333 TFT_color_code_stop_attn:
334 FONT_COLOR_ATTENTION ; select color
335 return ; done
336
337 TFT_color_code_stop_warn:
338 FONT_COLOR_WARNING ; select color
339 return ; done
340
341 TFT_color_code_stop_dis:
342 FONT_COLOR_DISABLED ; select color
343 return ; done
344
345
346 ;-----------------------------------------------------------------------------
347 ; Color-Code the current Depth
348 ;
332 TFT_color_code_depth: 349 TFT_color_code_depth:
333 TSTOSS opt_depth_warn ; depth warning switched on? 350 TSTOSS opt_depth_warn ; depth warning switched on?
334 bra TFT_color_code_depth_no_mod ; NO 351 bra TFT_color_code_depth_no_mod ; NO
335 btfsc depth_limit_exceeded ; YES - deeper than depth limit? 352 btfsc warn_det_depth_limit ; YES - depth limit warning active?
336 bra TFT_color_code_depth_warn ; YES - set to warning color 353 bra TFT_color_code_depth_warn ; YES - set to warning color
337 bra TFT_color_code_depth_mod ; NO - check depth against MOD and return... 354 bra TFT_color_code_depth_mod ; NO - check depth against MOD
355
338 TFT_color_code_depth_no_mod: 356 TFT_color_code_depth_no_mod:
339 btfsc depth_limit_exceeded ; NO - deeper than depth limit? 357 btfsc warn_det_depth_limit ; depth limit warning active?
340 bra TFT_warning_color ; YES - set to warning color and return 358 bra TFT_color_code_depth_warn ; YES - set to warning color and return
341 bra TFT_memo_color ; NO - set to memo color and return... 359 bra TFT_color_code_depth_memo ; NO - set to memo color and return...
360
342 TFT_color_code_depth_mod: 361 TFT_color_code_depth_mod:
343 IFDEF _ccr_pscr 362 IFDEF _ccr_pscr
344 movff opt_dive_mode,WREG ; get deco mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR 363 movff opt_dive_mode,WREG ; get deco mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
345 decfsz WREG,F ; in CCR mode? 364 decfsz WREG,F ; in CCR mode?
346 bra TFT_color_code_depth_no_ccr ; NO - continue checking for ppO2 365 bra TFT_color_code_depth_no_ccr ; NO - continue checking for ppO2
347 btfss bailout_mode ; YES - check if in bailout 366 btfss bailout_mode ; YES - check if in bailout
348 bra TFT_color_code_depth_outside; NO - continue checking for outside ZHL16 model 367 bra TFT_color_code_depth_outside; NO - continue checking for outside ZHL16 model
368 ;bra TFT_color_code_depth_no_ccr ; YES - continue checking for ppO2
349 ENDIF 369 ENDIF
370
350 TFT_color_code_depth_no_ccr: 371 TFT_color_code_depth_no_ccr:
351 movff int_O_breathed_ppO2+1,WREG ; get upper byte of currently breathed ppO2 372 movff int_O_breathed_ppO2+1,WREG ; get upper byte of currently breathed ppO2
352 btfsc WREG,int_warning_flag ; is the warning flag set? 373 btfsc WREG,int_warning_flag ; is the warning flag set?
353 bra TFT_color_code_depth_warn ; YES - animate in warning design 374 bra TFT_color_code_depth_warn ; YES - animate in warning design
375 ;bra TFT_color_code_depth_outside; NO - continue checking for outside ZHL16 model
376
354 TFT_color_code_depth_outside: 377 TFT_color_code_depth_outside:
355 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings 378 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings
356 btfsc WREG,outside_warning ; are we currently outside of the ZH-L16 model? 379 btfsc WREG,outside_warning ; are we currently outside of the ZH-L16 model?
357 bra TFT_color_code_depth_warn ; YES - activate depth warning 380 bra TFT_color_code_depth_warn ; YES - activate depth warning
358 bcf depth_warning ; NO - terminate depth warning 381 btfsc WREG,outside_attention ; NO - are we near to outside of the ZH-L16 model?
359 btfsc WREG,outside_attention ; - are we near to outside of the ZH-L16 model?
360 bra TFT_color_code_depth_att ; YES - activate depth attention 382 bra TFT_color_code_depth_att ; YES - activate depth attention
361 bcf depth_attention ; NO - terminate depth attention 383 ;bra TFT_color_code_depth_memo ; NO - select memo color and return
362 bra TFT_memo_color ; - select memo color and return 384
385
386 ; Helper Functions - set colors and attention/warning flags
387 TFT_color_code_depth_memo:
388 bcf depth_color_warning ; terminate depth warning
389 bcf depth_color_attention ; terminate depth attention
390 FONT_COLOR_MEMO ; select color
391 return ; done
392
363 TFT_color_code_depth_warn: 393 TFT_color_code_depth_warn:
364 bsf depth_warning ; activate depth warning 394 bsf depth_color_warning ; activate depth warning
365 bra TFT_warning_color ; select warning color and return... 395 bcf depth_color_attention ; terminate depth attention
396 FONT_COLOR_WARNING ; select warning color
397 return ; done
398
366 TFT_color_code_depth_att: 399 TFT_color_code_depth_att:
367 bsf depth_attention ; activate depth attention 400 bcf depth_color_warning ; terminate depth warning
368 bra TFT_attention_color ; select attention color and return... 401 bsf depth_color_attention ; activate depth attention
369 402 FONT_COLOR_ATTENTION ; select attention
370 403 return ; done
404
405
406 ;-----------------------------------------------------------------------------
407 ; Color-Code a CNS Value
408 ;
409 ; Input hi:lo CNS value [%]
410 ;
371 global TFT_color_code_cns 411 global TFT_color_code_cns
372 TFT_color_code_cns: ; color-code CNS values (CNS in hi:lo [%]) 412 TFT_color_code_cns:
373 btfss hi,int_invalid_flag ; is the invalid flag set? 413 btfss hi,int_invalid_flag ; is the invalid flag set?
374 bra TFT_color_code_cns_1 ; NO 414 bra TFT_color_code_cns_1 ; NO
375 bcf hi,int_invalid_flag ; YES - clear invalid flag 415 bcf hi,int_invalid_flag ; YES - clear invalid flag
376 bcf hi,int_warning_flag ; clear warning flag (it may be set) 416 bcf hi,int_warning_flag ; - clear warning flag (it may be set)
377 bcf hi,int_attention_flag ; clear attention flag (it may be set) 417 bcf hi,int_attention_flag ; - clear attention flag (it may be set)
378 bra TFT_disabled_color ; set to disabled color and return 418 FONT_COLOR_DISABLED ; - select disabled color
419 return ; - done
420
379 TFT_color_code_cns_1: 421 TFT_color_code_cns_1:
380 btfss hi,int_warning_flag ; is the warning flag set? 422 btfss hi,int_warning_flag ; is the warning flag set?
381 bra TFT_color_code_cns_2 ; NO 423 bra TFT_color_code_cns_2 ; NO
382 bcf hi,int_warning_flag ; YES - clear warning flag 424 bcf hi,int_warning_flag ; YES - clear warning flag
383 bcf hi,int_attention_flag ; - clear attention flag (it may be set) 425 bcf hi,int_attention_flag ; - clear attention flag (it may be set)
384 bra TFT_warning_color ; - set to warning color and return 426 FONT_COLOR_WARNING ; - select warning color
427 return ; - done
428
385 TFT_color_code_cns_2: 429 TFT_color_code_cns_2:
386 btfss hi,int_attention_flag ; is the attention flag set? 430 btfss hi,int_attention_flag ; is the attention flag set?
387 bra TFT_memo_color ; NO - set to memo color and return 431 bra TFT_color_code_cns_3 ; NO - select memo color
388 bcf hi,int_attention_flag ; YES - clear attention flag 432 bcf hi,int_attention_flag ; YES - clear attention flag
389 bra TFT_attention_color ; - set to attention color and return 433 FONT_COLOR_ATTENTION ; - select attention color
390 434 return ; - done
391 435
392 TFT_color_code_gf: 436 TFT_color_code_cns_3:
393 ; with int_O_lead_supersat, the upper byte is solely used for the flags 437 FONT_COLOR_MEMO ; select memo color
394 ; and not for the value, thus there is no need to clear the flags 438 return ; done
439
440
441 ;-----------------------------------------------------------------------------
442 ; Color-Code a Supersaturation Value
443 ;
444 ; Input hi:lo CNS value [%]
445 ;
446 ; with int_O_lead_supersat, the upper byte is solely used for the flags
447 ; and not for the value, thus there is no need to clear the flags
448 ;
449 TFT_color_code_supersat:
450 movf pallet_color_memo,W ; load memo color by default
451 btfsc hi,int_attention_flag ; is the attention flag set?
452 movf pallet_color_attention,W ; YES - replace by attention color
453 btfsc hi,int_warning_flag ; is the warning flag set?
454 movf pallet_color_warning,W ; YES - replace by warning color
395 btfsc hi,int_invalid_flag ; is the invalid flag set? 455 btfsc hi,int_invalid_flag ; is the invalid flag set?
396 bra TFT_disabled_color ; YES - set to disabled color and return 456 movf pallet_color_disabled,W ; YES - replace by disabled color
397 btfsc hi,int_warning_flag ; NO - is the warning flag set? 457 movwf font_color ; set font color
398 bra TFT_warning_color ; YES - set to warning color and return 458 return ; done
399 btfsc hi,int_attention_flag ; NO - is the attention flag set? 459
400 bra TFT_attention_color ; YES - set to attention color and return 460
401 bra TFT_memo_color ; NO - set to memo color and return 461 ;-----------------------------------------------------------------------------
402 462 ; Color-Code a ppO2 Value by its warning flags (16 bit)
403 463 ;
404 TFT_color_code_ppo2: ; color-code ppO2 values (ppO2 in hi:lo [cbar]) by its warning flags 464 ; Input hi:lo ppO2 value [cbar]
465 ;
466 TFT_color_code_ppo2:
405 btfss hi,int_warning_flag ; is the warning flag set? 467 btfss hi,int_warning_flag ; is the warning flag set?
406 bra TFT_color_code_ppo2_1 ; NO 468 bra TFT_color_code_ppo2_1 ; NO
407 bcf hi,int_warning_flag ; YES - clear warning flag 469 bcf hi,int_warning_flag ; YES - clear warning flag
408 bcf hi,int_attention_flag ; clear attention flag (it may be set) 470 bcf hi,int_attention_flag ; - clear attention flag (it may be set)
409 bcf hi,int_high_flag ; clear high warning flag (it may be set) 471 bcf hi,int_high_flag ; - clear high warning flag (it may be set)
410 bcf hi,int_low_flag ; clear low warning flag (it may be set) 472 bcf hi,int_low_flag ; - clear low warning flag (it may be set)
411 bra TFT_warning_color ; warn in warning color 473 FONT_COLOR_WARNING ; - select warning color
474 return ; - done
475
412 TFT_color_code_ppo2_1: 476 TFT_color_code_ppo2_1:
413 btfss hi,int_attention_flag ; is the attention flag set? 477 btfss hi,int_attention_flag ; is the attention flag set?
414 bra TFT_color_code_ppo2_2 ; NO 478 bra TFT_color_code_ppo2_2 ; NO
415 bcf hi,int_attention_flag ; YES - clear attention flag (it may be set) 479 bcf hi,int_attention_flag ; YES - clear attention flag (it may be set)
416 bcf hi,int_high_flag ; clear high warning flag (it may be set) 480 bcf hi,int_high_flag ; - clear high warning flag (it may be set)
417 bcf hi,int_low_flag ; clear low warning flag (it may be set) 481 bcf hi,int_low_flag ; - clear low warning flag (it may be set)
418 bra TFT_attention_color ; set to attention color and return 482 FONT_COLOR_ATTENTION ; - select to attention color
483 return ; - done
484
419 TFT_color_code_ppo2_2: 485 TFT_color_code_ppo2_2:
420 bcf hi,int_high_flag ; clear high warning flag (it may be set) 486 bcf hi,int_high_flag ; clear high warning flag (it may be set)
421 bcf hi,int_low_flag ; clear low warning flag (it may be set) 487 bcf hi,int_low_flag ; clear low warning flag (it may be set)
422 bra TFT_memo_color ; set to memo color and return 488 FONT_COLOR_MEMO ; select memo color
423 489 return ; done
424 ;============================================================================= 490
425 491
426 IFDEF _ccr_pscr 492 IFDEF _ccr_pscr
427 493
428 TFT_color_code_ppo2_hud: ; color-code ppO2 values (ppO2 in --:lo [cbar]) by its value 494 ;-----------------------------------------------------------------------------
495 ; Color-Code a ppO2 Value by its warning flags (8 bit)
496 ;
497 ; Input lo ppO2 value [cbar]
498 ;
499 TFT_color_code_ppo2_hud:
429 movff char_O_deco_info,WREG ; get the deco info vector 500 movff char_O_deco_info,WREG ; get the deco info vector
430 btfss WREG,deco_mode ; are we in deco? 501 btfss WREG,deco_mode ; in deco?
431 bra TFT_color_code_ppo2_hud_a ; NO - load normal max value as threshold 502 bra TFT_color_code_ppo2_hud_a ; NO - load normal max value as threshold
432 movff char_I_ppO2_max_deco,WREG ; YES - load deco value as threshold 503 movff char_I_ppO2_max_deco,WREG ; YES - load deco max value as threshold
433 bra TFT_color_code_ppo2_hud_b 504 bra TFT_color_code_ppo2_hud_b ; continue
505
434 TFT_color_code_ppo2_hud_a: 506 TFT_color_code_ppo2_hud_a:
435 movff char_I_ppO2_max_work,WREG ; ppO2 max while in working phase 507 movff char_I_ppO2_max_work,WREG ; ppO2 max while in working phase
508 ;bra TFT_color_code_ppo2_hud_b ; continue
509
436 TFT_color_code_ppo2_hud_b: 510 TFT_color_code_ppo2_hud_b:
437 cpfsgt lo ; lo > threshold? 511 cpfsgt lo ; lo > threshold?
438 bra TFT_color_code_ppo2_hud1 ; NO - continue with checking for ppO2 low 512 bra TFT_color_code_ppo2_hud1 ; NO - continue with checking for ppO2 low
439 bra TFT_warning_color ; YES - set warning color and return 513 FONT_COLOR_WARNING ; YES - set warning color
514 return ; - done
515
440 TFT_color_code_ppo2_hud1: 516 TFT_color_code_ppo2_hud1:
441 movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR 517 movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
442 decfsz WREG,F ; now: 0=CC, 1=Gauge, 2=Apnea, 3=PSCR 518 decfsz WREG,F ; in CCR mode?
443 bra TFT_color_code_ppo2_hud_nocc; not CCR... 519 bra TFT_color_code_ppo2_hud_nocc; NO - check with ppO2 min for OC mode
444 btfsc bailout_mode 520 btfsc bailout_mode ; YES - in bailout mode?
445 bra TFT_color_code_ppo2_hud_nocc; is bailout, hence not loop mode... 521 bra TFT_color_code_ppo2_hud_nocc; YES - check with ppO2 min for OC mode
446 movff char_I_ppO2_min_loop,WREG ; ppO2 min loop mode color coding 522 movff char_I_ppO2_min_loop,WREG ; NO - check with ppO2 min for loop mode
447 bra TFT_color_code_ppo2_hud_cont 523 bra TFT_color_code_ppo2_hud_com ; - continue with common part
524
448 TFT_color_code_ppo2_hud_nocc: 525 TFT_color_code_ppo2_hud_nocc:
449 movff char_I_ppO2_min,WREG ; PPO2 min for all other modes 526 movff char_I_ppO2_min,WREG ; get ppO2 min for all other modes
450 TFT_color_code_ppo2_hud_cont: 527 ;bra TFT_color_code_ppo2_hud_com ; continue with common part
528
529 TFT_color_code_ppo2_hud_com:
451 cpfslt lo ; lo < char_I_ppO2_min? 530 cpfslt lo ; lo < char_I_ppO2_min?
452 bra TFT_memo_color ; NO - set memo color and return... 531 bra TFT_color_code_ppo2_hud_com1; NO - set memo color
453 bra TFT_warning_color ; Yes - set warning color and return 532 FONT_COLOR_WARNING ; YES - set warning color
533 return ; - done
534
535 TFT_color_code_ppo2_hud_com1:
536 FONT_COLOR_MEMO ; select memo color
537 return ; done
454 538
455 ENDIF ; _ccr_pscr 539 ENDIF ; _ccr_pscr
456 540
541
542 ;-----------------------------------------------------------------------------
543 ; Color-Code the Battery Level
544 ;
545 ; Input battery_low_condition battery status flag
546 ;
547 TFT_color_code_battery:
548 movf pallet_color_memo,W ; get memo color by default
549 btfsc battery_low_condition ; battery low condition detected?
550 movf pallet_color_warning,W ; YES - switch to warning color
551 movwf font_color ; set font color
552 return ; done
553
554
555 ;-----------------------------------------------------------------------------
556 ; Color-Code according to Gas Number
557 ;
558 ; Input WREG gas number
559 ;
560 global TFT_color_code_gas
561 TFT_color_code_gas:
562 movwf up ; copy gas number (1-6) to up
563 movlw color_white ; default color
564 dcfsnz up,F ; gas 1 ?
565 movlw color_white ; YES - color for gas 1
566 dcfsnz up,F ; gas 2 ?
567 movlw color_green ; YES - color for gas 2
568 dcfsnz up,F ; gas 3 ?
569 movlw color_red ; YSE - color for gas 3
570 dcfsnz up,F ; gas 4 ?
571 movlw color_yellow ; YES - color for gas 4
572 dcfsnz up,F ; gas 5 ?
573 movlw color_cyan ; YES - color for gas 5
574 dcfsnz up,F ; gas 6 ?
575 movlw color_pink ; YES - color for gas 6
576 movwf font_color ; set color
577 return ; done
578
579
457 ;============================================================================= 580 ;=============================================================================
458 581 tft_out3 CODE
459 TFT_color_code_battery: ; color-code the battery display, with battery percent in lo 582 ;=============================================================================
583
584
585 ;-----------------------------------------------------------------------------
586 ; Surface Mode Screen - current Time
587 ;
588 global TFT_surfmode_time
589 TFT_surfmode_time:
590 WIN_SMALL surf_clock_column+.7,surf_clock_row
591 FONT_COLOR_MEMO ; set color
592 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
593 movff rtc_latched_hour,lo ; get hours
594 output_99 ; print hours (0-99)
595 movlw ':' ; load a ":"
596 movff rtc_latched_secs,lo ; get seconds
597 btfss lo,0 ; on even second?
598 movlw ' ' ; NO - load a space char
599 movwf POSTINC2 ; print ":" or space char
600 movff rtc_latched_mins,lo ; get minutes
601 output_99x ; print minutes (00-99)
602 PRINT ; dump to screen
603 return ; done
604
605
606 ;-----------------------------------------------------------------------------
607 ; Surface Mode Screen - current Date
608 ;
609 global TFT_surfmode_date
610 TFT_surfmode_date:
611 WIN_SMALL surf_date_column,surf_date_row
612 FONT_COLOR_MEMO ; set color
613 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
614 movff rtc_latched_year, lo ; copy year to lo
615 movff rtc_latched_month,hi ; copy month to hi
616 movff rtc_latched_day, up ; copy day to up
617 call output_date ; print date
618 PRINT ; dump to screen
619 return ; done
620
621
622 ;-----------------------------------------------------------------------------
623 ; Surface Mode Screen - show Pressure, on condition deltaP > threshold
624 ;
625 global TFT_surfmode_pres_fast
626 TFT_surfmode_pres_fast:
627 SMOVII pressure_abs, sub_a ; ISR-safe 2 byte copy of current absolute pressure to sub_a
628 MOVII pressure_abs_ref,sub_b ; standard 2 byte copy 10 min ago absolute pressure to sub_b
629 call subU16 ; sub_c = | sub_a - sub_b | = deltaP
630 tstfsz sub_c+1 ; deltaP > 255 mbar ?
631 bra TFT_pres_surfmode_fast_1 ; YES - show current pressure
632 movlw pressure_noise_threshold+.1 ; NO - load noise suppression threshold
633 subwf sub_c+0,W ; - subtract threshold from deltaP
634 bc TFT_pres_surfmode_fast_1 ; - result negative -> show current pressure
635 tstfsz pressure_update_lag_counter ; - still in lag time?
636 bra TFT_pres_surfmode_fast_0 ; YES - continue updating the display
637 return ; NO - no display updates any more, done
638
639 TFT_pres_surfmode_fast_0:
640 decf pressure_update_lag_counter,F ; clock down lag time counter
641 bra TFT_surfmode_pres ; update display
642
643 TFT_pres_surfmode_fast_1:
644 movlw pressure_noise_lag_time ; get lag time
645 movwf pressure_update_lag_counter ; re-set lag time counter
646 ;bra TFT_surfmode_pres ; update display
647
648
649 ;-----------------------------------------------------------------------------
650 ; Surface Mode Screen - show Pressure (unconditional)
651 ;
652 global TFT_surfmode_pres
653 TFT_surfmode_pres:
654 ; value
655 WIN_SMALL surf_press_column+.8,surf_press_row
656 FONT_COLOR_MEMO ; set color
657 SMOVII pressure_abs,mpr ; get current pressure
658 FONT_COLOR_MEMO ; print in standard color
659 output_9999 ; print (0-9999)
660 PRINT ; dump buffer to screen
661 ; unit
662 WIN_SMALL surf_press_column+(4+1)*8,surf_press_row
663 FONT_COLOR_MASK ; switch to mask color
664 STRCPY_TEXT_PRINT tMBAR ; print unit (hPa)
665 return ; done
666
667
668 ;-----------------------------------------------------------------------------
669 ; Surface Mode Screen - Temperature
670 ;
671 global TFT_surfmode_temp
672 TFT_surfmode_temp:
673 ; unit
674 WIN_SMALL surf_temp_column+3*8,surf_temp_row
675 FONT_COLOR_MASK ; select mask color
676 TSTOSS opt_units ; 0=°C, 1=°F
677 bra TFT_temp_surfmode_metric ; 0: metric
678 ;bra TFT_temp_surfmode_imperial ; 1: imperial
679
680 TFT_temp_surfmode_imperial:
681 STRCAT_TEXT tLogTunitF ; print "°F"
682 bra TFT_temp_surfmode_common ; continue with common part
683
684 TFT_temp_surfmode_metric:
685 STRCAT_TEXT tLogTunitC ; print "°C"
686 ;bra TFT_temp_surfmode_common ; continue with common part
687
688 TFT_temp_surfmode_common:
689 PRINT ; dump the unit to screen
690
691 ; value
692 WIN_SMALL surf_temp_column,surf_temp_row
693 bra TFT_temp_common ; continue with common part
694
695
696 ; Helper Function - common output for surface and dive mode temperature
697 TFT_temp_common:
698 FONT_COLOR_MEMO ; set color
699 SMOVII temperature_cur,mpr ; ISR-safe 2 byte copy of current temperature to hi:lo
700
701 ; DEBUG CODE - manual override temp
702 ; -----------------------------------
703 ; MOVLI 0xFFF6,mpr ; - 1.0 °C
704 ; MOVLI 0xFF9C,mpr ; -10.0 °C
705
706 TSTOSC opt_units ; 0=°C, 1=°F
707 call convert_celsius_to_fahrenheit;1 - convert value in lo:hi from Celsius to Fahrenheit
708 call convert_signed_16bit ; convert lo:hi into signed-short and print '-' if negative
709 btfsc neg_flag ; is the temperature negative?
710 bsf hide_digit4 ; YES - do not print digit 4
711 bsf omit_digit_1 ; do not print digit 1 (0.1°)
712 output_9999 ; print temperature (0x-999x / 0x-99x if negative)
713
714 btfss divemode ; in dive mode?
715 bra TFT_temp_common_no_unit ; NO - no unit to append
716 TSTOSS opt_units ; YES - check unit type: 0=°C, 1=°F
717 bra TFT_temp_common_metric ; 0 - metric
718 ;bra TFT_temp_common_imperial ; 1 - imperial
719
720 TFT_temp_common_imperial:
721 STRCAT_TEXT_PRINT tLogTunitF ; append "°F" and dump to screen
722 return ; done
723
724 TFT_temp_common_metric:
725 STRCAT_TEXT_PRINT tLogTunitC ; append "°C" and dump to screen
726 return ; done
727
728 TFT_temp_common_no_unit:
729 PRINT ; dump to screen
730 return ; done
731
732
733 ;-----------------------------------------------------------------------------
734 ; Surface Mode Screen - Battery Status
735 ;
736 global TFT_surfmode_batt
737 TFT_surfmode_batt:
738 FONT_COLOR_MEMO ; set default color
739
740 ; apply charging indicator and warnings
741 clrf WREG ; default to no indication/warning
742 btfsc cc_active ; charging in CC mode?
743 movlw color_yellow ; YES - set output color to yellow
744 btfsc cv_active ; charging in CV mode?
745 movlw color_green ; YES - set output color to green
460 btfsc battery_low_condition ; battery low condition detected? 746 btfsc battery_low_condition ; battery low condition detected?
461 bra TFT_warning_color ; YES - set to warning color and return 747 movf pallet_color_warning,W ; YES - set output to warning color
462 bra TFT_memo_color ; NO - set to memo color and return 748 btfsc battery_overtemp ; battery over-temperature detector tripped?
463 749 movf pallet_color_warning,W ; YES - set output to warning color
464 750 tstfsz WREG ; any indicator or warning active?
465 global TFT_color_code_gas 751 bsf win_invert ; YES - set output to inverse
466 TFT_color_code_gas: ; color-code the output according to gas number (1-6) in WREG 752 tstfsz WREG ; any indicator or warning active (asked again)?
467 movwf up ; copy gas number (1-6) to up 753 movwf font_color ; YES - change color
468 movlw color_white ; Default color 754
469 dcfsnz up,F 755 WIN_SMALL batt_percent_column+.2,batt_percent_row
470 movlw color_white ; color for gas 1 756 movff batt_percent,lo ; get battery %
471 dcfsnz up,F 757 output_256 ; print battery % (0-255)
472 movlw color_green ; color for gas 2 758 STRCAT_PRINT "% " ; append unit with trailing space and dump to screen
473 dcfsnz up,F 759
474 movlw color_red ; color for gas 3 760 WIN_TINY batt_voltage_column+.15,batt_voltage_row
475 dcfsnz up,F 761 FONT_COLOR_MEMO ; set color
476 movlw color_yellow ; color for gas 4 762 movff battery_type,lo ; get battery type
477 dcfsnz up,F 763 PUTC "T" ; print "T"
478 movlw color_cyan ; color for gas 5 764 output_9 ; print battery type code (0-9)
479 dcfsnz up,F 765 PUTC ":" ; print ":"
480 movlw color_pink ; color for gas 6 766 MOVII batt_voltage,mpr ; get battery voltage
481 goto TFT_set_color ; set color... 767 bsf omit_digit_2 ; do not print 2nd and 1st digit
482 768 bsf decimal_digit3 ; place a decimal point in front of digit 3
483 769 output_9999 ; print x.x--
484 ; **************************************************************************** 770 PUTC_PRINT 'V' ; append unit and dump to screen
485 771 return ; done
486 global TFT_show_OC_startgas_surface 772
487 TFT_show_OC_startgas_surface: ; show first gas and "OSTC2-like" active gases 773 ;update_battery_debug:
488 ; Show first gas 774 ; FONT_COLOR_MEMO
775 ; WIN_TINY .70,.0
776 ; movff battery_gauge+5,xC+3
777 ; movff battery_gauge+4,xC+2
778 ; movff battery_gauge+3,xC+1
779 ; movff battery_gauge+2,xC+0
780 ; ; battery_gauge:6 is nAs
781 ; ; devide through 65536
782 ; ; devide through 152
783 ; ; Result is 0.01Ah in xC+1:xC+0
784 ; MOVLI .152,xB
785 ; call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
786 ; MOVII xC,mpr
787 ; bsf leftbind
788 ; output_65535
789 ; STRCAT_PRINT "x.01Ah"
790 ; return
791
792
793 ;-----------------------------------------------------------------------------
794 ; Surface Mode Screen - Deco Mode (0=OC, 1=CCR, 2=Gauge, 3=Apnoe, 4=pSCR)
795 ;
796 global TFT_surfmode_decotype
797 TFT_surfmode_decotype:
798 WIN_STD surf_decotype_column,surf_decotype_row
799 FONT_COLOR color_lightblue ; set font color
800 movff opt_dive_mode,lo ; get deco mode
801 tstfsz lo ; in OC mode?
802 bra TFT_decotype_surface_2 ; NO
803 STRCAT_TEXT_PRINT tDvOC ; YES - print OC
804 return ; - done
805
806 TFT_decotype_surface_2:
807 decfsz lo,F ; in CCR mode?
808 bra TFT_decotype_surface_3 ; NO
809 IFDEF _ccr_pscr
810 STRCAT_TEXT_PRINT tDvCC ; YES - print CCR
811
812 WIN_TINY surf_decotype_column+.18,surf_decotype_row+.12
813 FONT_COLOR_MEMO ; - set color
814 movff opt_ccr_mode,WREG ; - ccr mode
815 tstfsz WREG ; - ccr_mode = 0 (FixedSP) ?
816 bra TFT_surfmode_decotype_cc_var; NO - not fixed
817 ;bra TFT_surfmode_decotype_cc_fix; YES - fixed
818
819 TFT_surfmode_decotype_cc_fix:
820 STRCPY_TEXT tCCRModeFixedSP ; print "fixed SP"
821 bra TFT_decotype_surface_cc_com ; continue
822
823 TFT_surfmode_decotype_cc_var:
824 ; Sensor or Auto SP mode
825 sublw .2 ; ccr_mode = 2 (Auto SP) ?
826 bz TFT_decotype_surface_cc_auto; YES - AutoSP
827 IFDEF _external_sensor
828 STRCPY_TEXT tCCRModeSensor ; NO - print "Sensor"
829 bra TFT_decotype_surface_cc_com ; - continue
830 ENDIF ; _external_sensor
831
832 TFT_decotype_surface_cc_auto:
833 STRCPY_TEXT tCCRModeAutoSP ; print "Auto SP"
834 ;bra TFT_decotype_surface_cc_com ; continue
835
836 TFT_decotype_surface_cc_com:
837 clrf WREG ; load string terminator
838 movff WREG,buffer+.8 ; limit string length to 8
839 PRINT ; dump to screen
840 return ; done
841 ENDIF ; _ccr_pscr
842
843 TFT_decotype_surface_3:
844 decfsz lo,F ; in gauge mode?
845 bra TFT_decotype_surface_4 ; NO
846 STRCAT_TEXT_PRINT tDvGauge ; YES - print "Gauge"
847 return ; - done
848
849 TFT_decotype_surface_4:
850 decfsz lo,F ; in apnea mode?
851 bra TFT_decotype_surface_5 ; NO
852 STRCAT_TEXT_PRINT tDvApnea ; YES - print "Apnoe"
853 return ; - done
854
855 TFT_decotype_surface_5:
856 STRCAT_TEXT_PRINT tDvPSCR ; print "pSCR"
857 return ; done
858
859
860 ;-----------------------------------------------------------------------------
861 ; Surface Mode Screen - small Gas List
862 ;
863 global TFT_surfmode_startgas
864 TFT_surfmode_startgas:
865 ; FIRST gas
489 WIN_SMALL surf_decotype_column+.1,surf_decotype_row+.30 866 WIN_SMALL surf_decotype_column+.1,surf_decotype_row+.30
867 FONT_COLOR_MEMO ; set font color
490 call get_first_gas_to_WREG ; get first gas (1-5) into WREG 868 call get_first_gas_to_WREG ; get first gas (1-5) into WREG
491 decf WREG,W ; 1-5 -> 0-4 869 decf WREG,W ; 1-5 -> 0-4
492 movwf PRODL 870 movwf PRODL ; copy to PRODL
493 call gaslist_strcat_gas ; input: PRODL : gas number (0..4), Output: Text appended into buffer pointed by FSR2. 871 call gaslist_strcat_mix_PRODL ; print gas description
494 STRCAT_PRINT "" 872 PRINT ; dump to screen
495 ; Show boxes 873
496 WIN_TOP surf_decotype_row+.30+.25 874 ; show gases
875 WIN_TOP surf_decotype_row+.30+.25 ; set row position
876
877 ; 1st gas
497 WIN_LEFT surf_decotype_boxes_left1+.1 878 WIN_LEFT surf_decotype_boxes_left1+.1
498 rcall TFT_disabled_color
499 movff opt_gas_type+0,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco 879 movff opt_gas_type+0,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco
500 tstfsz hi 880 rcall TFT_surfmode_startgas_helper; set font color
501 rcall TFT_standard_color 881 STRCPY_PRINT "1" ; print "1"
502 STRCPY_PRINT "1"
503 decfsz hi,F ; Type = 1 (First)? 882 decfsz hi,F ; Type = 1 (First)?
504 bra DISP_active_gas_surfmode3 ; NO - skip box 883 bra TFT_surfmode_startgas_2 ; NO - skip box
505 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left1, surf_decotype_boxes_left1+.8 ;top, bottom, left, right 884 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left1, surf_decotype_boxes_left1+.8
506 DISP_active_gas_surfmode3: 885
507 rcall TFT_disabled_color 886 ; 2nd gas
887 TFT_surfmode_startgas_2:
888 WIN_LEFT surf_decotype_boxes_left2+.1
508 movff opt_gas_type+1,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco 889 movff opt_gas_type+1,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco
509 tstfsz hi 890 rcall TFT_surfmode_startgas_helper; set font color
510 rcall TFT_standard_color 891 STRCPY_PRINT "2" ; print "2"
511 WIN_LEFT surf_decotype_boxes_left2+.1
512 STRCPY_PRINT "2"
513 decfsz hi,F ; Type = 1 (First)? 892 decfsz hi,F ; Type = 1 (First)?
514 bra DISP_active_gas_surfmode4 ; NO - skip box 893 bra TFT_surfmode_startgas_3 ; NO - skip box
515 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left2, surf_decotype_boxes_left2+.8 ;top, bottom, left, right 894 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left2, surf_decotype_boxes_left2+.8
516 DISP_active_gas_surfmode4: 895
517 rcall TFT_disabled_color 896 ; 3rd gas
897 TFT_surfmode_startgas_3:
898 WIN_LEFT surf_decotype_boxes_left3+.1
518 movff opt_gas_type+2,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco 899 movff opt_gas_type+2,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco
519 tstfsz hi 900 rcall TFT_surfmode_startgas_helper; set font color
520 rcall TFT_standard_color 901 STRCPY_PRINT "3" ; print "3"
521 WIN_LEFT surf_decotype_boxes_left3+.1
522 STRCPY_PRINT "3"
523 decfsz hi,F ; Type = 1 (First)? 902 decfsz hi,F ; Type = 1 (First)?
524 bra DISP_active_gas_surfmode5 ; NO - skip box 903 bra TFT_surfmode_startgas_4 ; NO - skip box
525 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left3, surf_decotype_boxes_left3+.8 ;top, bottom, left, right 904 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left3, surf_decotype_boxes_left3+.8
526 DISP_active_gas_surfmode5: 905
527 rcall TFT_disabled_color 906 ; 4th gas
907 TFT_surfmode_startgas_4:
908 WIN_LEFT surf_decotype_boxes_left4+.1
528 movff opt_gas_type+3,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco 909 movff opt_gas_type+3,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco
529 tstfsz hi 910 rcall TFT_surfmode_startgas_helper; set font color
530 rcall TFT_standard_color 911 STRCPY_PRINT "4" ; print "4"
531 WIN_LEFT surf_decotype_boxes_left4+.1
532 STRCPY_PRINT "4"
533 decfsz hi,F ; Type = 1 (First)? 912 decfsz hi,F ; Type = 1 (First)?
534 bra DISP_active_gas_surfmode6 ; NO - skip box 913 bra TFT_surfmode_startgas_5 ; NO - skip box
535 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left4, surf_decotype_boxes_left4+.8 ;top, bottom, left, right 914 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left4, surf_decotype_boxes_left4+.8
536 DISP_active_gas_surfmode6: 915
537 rcall TFT_disabled_color 916 ; 5th gas
917 TFT_surfmode_startgas_5:
918 WIN_LEFT surf_decotype_boxes_left5+.1
538 movff opt_gas_type+4,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco 919 movff opt_gas_type+4,hi ; 0=Disabled, 1=First, 2=Travel, 3=Deco
539 tstfsz hi 920 rcall TFT_surfmode_startgas_helper; set font color
540 rcall TFT_standard_color 921 STRCPY_PRINT "5" ; print "5"
541 WIN_LEFT surf_decotype_boxes_left5+.1
542 STRCPY_PRINT "5"
543 rcall TFT_standard_color ; reset color
544 decfsz hi,F ; type = 1 (First)? 922 decfsz hi,F ; type = 1 (First)?
545 bra DISP_active_gas_surfmode7 ; NO - done 923 return ; NO - done
546 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left5, surf_decotype_boxes_left5+.8 ;top, bottom, left, right 924 WIN_FRAME_STD surf_decotype_boxes_top, surf_decotype_boxes_bottom, surf_decotype_boxes_left5, surf_decotype_boxes_left5+.8
547 DISP_active_gas_surfmode7: 925 return ; done
548 return ; done 926
549 927
550 928 ; Helper Function - set font color
551 global TFT_show_color_schemes 929 TFT_surfmode_startgas_helper:
552 TFT_show_color_schemes: ; update the color schemes 930 movf pallet_color_disabled,W
553 bsf divemode ; switch to dive mode 931 tstfsz hi ; gas not disabled?
554 call TFT_divemask_color 932 movf pallet_color_memo,W ; YES - change to memo color
555 WIN_TINY .12,.40 933 movwf font_color ; set font color
556 STRCAT_TEXT_PRINT tDepth 934 return
557 WIN_TINY .62,.40 935
558 STRCAT_TEXT_PRINT tMaxDepth 936 IFDEF _rx_functions
559 WIN_TINY .122,.40 937
560 STRCAT_TEXT_PRINT tDivetime 938 ;-----------------------------------------------------------------------------
561 939 ; Surface Mode Screen - Tank Pressure Reading above Surface Pressure
562 ; Show some demo screen 940 ;
563 941 global TFT_surfmode_tankpres
564 ; Depth demo 942 TFT_surfmode_tankpres:
565 call TFT_memo_color 943 WIN_SMALL surf_decotype_column+.6,surf_decotype_row+.30+.47
566 WIN_MEDIUM .3,.54 944 movff int_IO_pressure_value+0,lo ; copy pressure from 1st reading to hi:lo
567 MOVLI .5172,mpr 945 movff int_IO_pressure_value+1,hi ; ...
568 bsf leftbind 946 btfss hi,int_not_avail_flag ; pressure reading 1 available?
569 bsf ignore_digit4 947 bra TFT_surface_tank_pres_0 ; YES
570 output_16 ; full meters in big font 948 movff int_IO_pressure_value+2,lo ; NO - copy pressure from 2nd reading to hi:lo
571 bcf leftbind 949 movff int_IO_pressure_value+3,hi ; - ...
572 STRCAT_PRINT "" ; display full meters 950 btfsc hi,int_not_avail_flag ; - pressure reading 2 available?
573 WIN_SMALL .25,.66 951 bra TFT_surface_tank_pres_1 ; NO - show not avail message
574 MOVLI .5172,mpr 952
575 PUTC "." 953 TFT_surface_tank_pres_0:
576 movlw d'4' 954 call TFT_color_code_pres_sac ; set output color according to flags
577 movwf ignore_digits 955 bsf omit_digit_1 ; do not print 1st digit (0.1 bar)
578 bsf ignore_digit5 ; (flag will be cleared by output_16) 956 output_9999 ; print (0x-999x)
579 output_16dp d'0' ; .1m in SMALL font 957 PRINT ; dump to screen
580 STRCAT_PRINT "" ; display decimeters 958 bra TFT_surface_tank_pres_2 ; print unit
581 959
582 ; Max. Depth demo 960 TFT_surface_tank_pres_1:
583 WIN_MEDIUM .64,.54 961 FONT_COLOR_DISABLED ; select disabled color
584 bsf ignore_digit4 ; no 0.1 m 962 STRCAT_PRINT " ---" ; output for no pressure data available
585 bsf leftbind 963
586 MOVLI .6349,mpr 964 TFT_surface_tank_pres_2:
587 output_16 965 WIN_SMALL surf_decotype_column+.38,surf_decotype_row+.30+.47
588 STRCAT_PRINT "" ; display full meters 966 FONT_COLOR_MASK ; select mask color
589 bcf leftbind 967 STRCAT_PRINT "bar" ; can not use tbar because it has a leading space
590 ; .1m in SMALL font 968 return ; done
591 WIN_SMALL .87,.66 969
592 PUTC "." 970 ENDIF ; _rx_functions
593 movlw d'4' 971
594 movwf ignore_digits 972
595 bsf ignore_digit5 ; (flag will be cleared by output_16) 973 ;=============================================================================
596 bsf leftbind 974 tft_out4 CODE
597 MOVLI .6349,mpr 975 ;=============================================================================
598 output_16dp d'0' 976
599 STRCAT_PRINT "" ; display decimeters 977
600 bcf leftbind 978 ;-----------------------------------------------------------------------------
601 979 ; Imprint the Color Schemes
602 ; Divetime demo 980 ;
981 global TFT_imprint_color_schemes
982 TFT_imprint_color_schemes:
983 call TFT_load_dive_color_pallet ; load dive mode color pallet
984
985 FONT_COLOR_MASK ; select mask color
986 WIN_TINY .12,.40 ; print labels
987 STRCAT_TEXT_PRINT tDepth ; ...
988 WIN_TINY .62,.40 ; ...
989 STRCAT_TEXT_PRINT tMaxDepth ; ...
990 WIN_TINY .122,.40 ; ...
991 STRCAT_TEXT_PRINT tDivetime ; ...
992
993 FONT_COLOR_DISABLED ; select disabled color
994
995 ; max. depth demo
996 WIN_MEDIUM .64,.54 ; set font and position
997 movlw .63 ; load demo depth
998 movwf lo ; ...
999 output_99 ; print full meters (0-99)
1000 PRINT ; dump to screen
1001
1002 WIN_SMALL .87,.66 ; set font and position
1003 PUTC "." ; print ":"
1004 movlw .4 ; load demo depth
1005 movwf lo ; ...
1006 output_9 ; print decimeters (0-9)
1007 PRINT ; dump to screen
1008
1009 FONT_COLOR_MEMO ; select memo color
1010
1011 ; depth demo
1012 WIN_MEDIUM .3,.54 ; set font and position
1013 movlw .17 ; load a demo depth
1014 movwf lo ; ...
1015 output_99 ; print full meters (0-99)
1016 PRINT ; dump to screen
1017
1018 WIN_SMALL .25,.66 ; set font and position
1019 PUTC "." ; print ":"
1020 movlw .5 ; load demo depth
1021 movwf lo ; ...
1022 output_9 ; print decimeters (0-9)
1023 PRINT ; dump to screen
1024
1025 ; dive time demo
1026 WIN_MEDIUM .103, .54 ; set font and position
603 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time 1027 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
604 movff rtc_latched_mins,lo 1028 movff rtc_latched_mins,lo ; get minutes
605 clrf hi 1029 output_256 ; print minutes (in 3 digits, 1st digit used as spacer)
606 WIN_MEDIUM .103, .54 1030 PRINT ; dump to screen
607 output_16_3 ; limit to 999 and display only (0-999) 1031
608 STRCAT_PRINT "" ; show minutes in large font 1032 WIN_SMALL .139, .66 ; set font and position
609 WIN_SMALL .139, .66 ; left position for two sec figures 1033 PUTC ':' ; print ":"
610 PUTC ':' 1034 movff rtc_latched_secs,lo ; get seconds
611 bsf leftbind 1035 output_99x ; print seconds (00-99)
612 movff rtc_latched_secs,lo 1036 PRINT ; dump to screen
613 output_99x 1037
614 bcf leftbind 1038 ; messages demo
615 STRCAT_PRINT "" ; show seconds in small font 1039 WIN_SMALL dm_warning1_column-.78, dm_warning1_row+.39+.12
616 1040 FONT_COLOR_ADVICE ; select advice color
617 bcf divemode ; terminate dive mode again 1041 STRCPY_TEXT_PRINT tgaschange ; sample text "Change?"
618 return 1042
619 1043 WIN_SMALL dm_warning1_column, dm_warning1_row+.39
620 1044 FONT_COLOR_ATTENTION ; select attention color
1045 STRCPY_TEXT_PRINT tCNSeod ; sample text "CNS final"
1046
1047 WIN_SMALL dm_warning2_column, dm_warning2_row+.38
1048 FONT_COLOR_WARNING ; select warning color
1049 STRCPY_TEXT_PRINT tGasNeedsWarn ; sample text "Gas Needs"
1050
1051 call TFT_load_std_color_pallet ; re-load standard color pallet
1052
1053 return ; done
1054
1055
1056 ;-----------------------------------------------------------------------------
1057 ; Surface Menu - Imprint Time & Date
1058 ;
1059 global TFT_imprint_time_date
1060 TFT_imprint_time_date:
1061 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of current date & time
1062 ;bra TFT_imprint_time_date_fast ; continue
1063
1064
1065 ;-----------------------------------------------------------------------------
1066 ; Surface Menu - Imprint Time & Date - fast Updating
1067 ;
1068 global TFT_imprint_time_date_fast
1069 TFT_imprint_time_date_fast:
1070 WIN_SMALL .20,.40 ; column, row - keep clear of the cursor area on the left!
1071 FONT_COLOR_MEMO ; select color
1072 movff rtc_latched_hour,lo ; get hours
1073 output_99 ; print hours (0-99)
1074 PUTC ':' ; print ":"
1075 movff rtc_latched_mins,lo ; get minutes
1076 output_99x ; print minutes (00-99)
1077 PUTC ':' ; print ":"
1078 movff rtc_latched_secs,lo ; get seconds
1079 output_99x ; print seconds (00-99)
1080 STRCAT " " ; append two spaces
1081 movff rtc_latched_year, lo ; get date
1082 movff rtc_latched_month,hi ; ...
1083 movff rtc_latched_day, up ; ...
1084 call output_date ; print date
1085 PUTC_PRINT " " ; append a space and dump to screen
1086 return ; done
1087
1088
1089 IFDEF _external_sensor
1090
1091 ;-----------------------------------------------------------------------------
1092 ; Surface Mode - Imprint ppO2 from Sensors
1093 ;
1094 global TFT_imprint_surf_ppO2
1095 TFT_imprint_surf_ppO2:
1096
1097 TFT_imprint_surf_ppO2_1:
1098 WIN_SMALL surf_hud_sensor1_column,surf_hud_sensor1_row
1099 btfsc sensor1_calibrated_ok ; sensor calibrated?
1100 bra TFT_imprint_surf_ppO2_1a ; YES
1101 btfsc sensor1_active ; NO - valid HUD data for this sensor?
1102 bra TFT_imprint_surf_ppO2_1a ; YES
1103 rcall TFT_imprint_surf_ppO2_h2 ; NO - print dashes
1104 bra TFT_imprint_surf_ppO2_2 ; - continue with sensor 2
1105 TFT_imprint_surf_ppO2_1a:
1106 movff sensor1_ppO2,lo ; get ppO2
1107 rcall TFT_imprint_surf_ppO2_h1 ; print ppO2
1108
1109 TFT_imprint_surf_ppO2_2:
1110 WIN_SMALL surf_hud_sensor2_column,surf_hud_sensor2_row
1111 btfsc sensor2_calibrated_ok ; sensor calibrated?
1112 bra TFT_imprint_surf_ppO2_2a ; YES
1113 btfsc sensor2_active ; NO - valid HUD data for this sensor
1114 bra TFT_imprint_surf_ppO2_2a ; YES
1115 rcall TFT_imprint_surf_ppO2_h2 ; NO - print dashes
1116 bra TFT_imprint_surf_ppO2_3 ; - continue with sensor 3
1117 TFT_imprint_surf_ppO2_2a:
1118 movff sensor2_ppO2,lo ; get ppO2
1119 rcall TFT_imprint_surf_ppO2_h1 ; print ppO2
1120
1121 TFT_imprint_surf_ppO2_3:
1122 WIN_SMALL surf_hud_sensor3_column,surf_hud_sensor3_row
1123 btfsc sensor3_calibrated_ok ; sensor calibrated?
1124 bra TFT_imprint_surf_ppO2_3a ; YES
1125 btfsc sensor3_active ; NO - valid HUD data for this sensor
1126 bra TFT_imprint_surf_ppO2_3a ; YES
1127 bra TFT_imprint_surf_ppO2_h2 ; NO - print dashes and return
1128 return ; - done
1129 TFT_imprint_surf_ppO2_3a:
1130 movff sensor3_ppO2,lo ; get ppO2
1131 ;bra TFT_imprint_surf_ppO2_h1 ; print ppO2 and return
1132
1133 TFT_imprint_surf_ppO2_h1:
1134 call TFT_color_code_ppo2_hud ; color-code with ppO2 [cbar] in lo
1135 bsf decimal_digit2 ; place a decimal point in front of digit 2
1136 output_256 ; print (0.00-2.55)
1137 PRINT ; dump to screen
1138 return ; done
1139
1140 TFT_imprint_surf_ppO2_h2:
1141 FONT_COLOR_MEMO ; select standard color
1142 STRCPY_PRINT "--- " ; print dashes
1143 return ; done
1144
1145
1146 ;-----------------------------------------------------------------------------
1147 ; Surface Mode - Imprint mV from Sensors
1148 ;
1149 global TFT_imprint_surf_mV
1150 TFT_imprint_surf_mV:
1151 FONT_COLOR_MEMO ; set font color
1152
1153 ; sensor 1
1154 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor1_row
1155 SMOVII sensor1_mv,mpr ; in 0.1mV steps
1156 STRCAT "1: " ; print number
1157 rcall TFT_sensor_mV_helper ; print mV
1158
1159 ; sensor 2
1160 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor2_row
1161 SMOVII sensor2_mv,mpr ; in 0.1mV steps
1162 STRCAT "2: " ; print number
1163 rcall TFT_sensor_mV_helper
1164
1165 ; sensor 3
1166 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row
1167 SMOVII sensor3_mv,mpr ; in 0.1mV steps
1168 STRCAT "3: " ; print number
1169 rcall TFT_sensor_mV_helper ; print mV
1170
1171 ; print sensor connection type
1172 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row+.24
1173 btfsc ext_input_optical ; optical input?
1174 bra TFT_sensor_mV_optical ; YES
1175 TSTOSS opt_s8_mode ; NO - S8 input selected?
1176 bra TFT_sensor_mV_analog ; NO - analog input
1177 ;bra TFT_sensor_mV_s8 ; YES - S8
1178
1179 TFT_sensor_mV_s8:
1180 STRCAT_PRINT "Digital" ; print "Digital"
1181 return ; done
1182
1183 TFT_sensor_mV_optical:
1184 STRCAT_PRINT "Optical" ; print "Optical"
1185 return ; done
1186
1187 TFT_sensor_mV_analog:
1188 STRCAT_PRINT "Analog" ; print "analog"
1189 return ; done
1190
1191
1192 ; Helper Function - print mV value
1193 TFT_sensor_mV_helper:
1194 bsf decimal_digit1 ; place a decimal point in front of digit 1
1195 output_9999 ; print (0.0-999.9)
1196 STRCAT_PRINT "mV " ; append unit and dump buffer to screen
1197 return ; done
1198
1199
1200 ;-----------------------------------------------------------------------------
1201 ; Surface Mode - Imprint End-of-Life from Sensors
1202 ;
1203 ; when opt_x_sx > 255 the sensor will just give 8 mV at a ppO2 of 0.21
1204 ;
1205 global TFT_imprint_surf_sensor_eol
1206 TFT_imprint_surf_sensor_eol:
1207 FONT_COLOR_WARNING ; set color
1208
1209 TFT_imprint_surf_eol_1:
1210 ; sensor 1
1211 btfss sensor1_calibrated_ok ; valid calibration?
1212 bra TFT_imprint_surf_eol_2 ; NO - skip
1213 movff opt_x_s1+1,WREG ; YES - get high(opt_x_s1)
1214 movf WREG,W ; - excite flags
1215 bz TFT_imprint_surf_eol_2 ; - opt_x_s1 > 255 -> the sensor is not too bad yet for a warning
1216 WIN_SMALL surf_mV_sensor_status_column,surf_mV_sensor1_row-.5
1217 STRCPY_PRINT "\xb8" ; mark sensor as being at end of lifetime
1218
1219 TFT_imprint_surf_eol_2:
1220 ; sensor 2
1221 btfss sensor2_calibrated_ok ; valid calibration?
1222 bra TFT_imprint_surf_eol_3 ; NO - skip
1223 movff opt_x_s2+1,WREG ; YES - get high(opt_x_s2)
1224 movf WREG,W ; - excite flags
1225 bz TFT_imprint_surf_eol_3 ; - opt_x_s2 > 255 -> the sensor is not too bad yet for a warning
1226 WIN_SMALL surf_mV_sensor_status_column,surf_mV_sensor2_row-.5
1227 STRCPY_PRINT "\xb8" ; mark sensor as being at end of lifetime
1228
1229 TFT_imprint_surf_eol_3:
1230 ; sensor 3
1231 btfss sensor3_calibrated_ok ; valid calibration?
1232 bra TFT_imprint_surf_eol_4 ; NO - skip
1233 movff opt_x_s3+1,WREG ; YES - get high(opt_x_s3)
1234 movf WREG,W ; - excite flags
1235 bz TFT_imprint_surf_eol_4 ; - opt_x_s3 > 255 -> the sensor is not too bad yet for a warning
1236 WIN_SMALL surf_mV_sensor_status_column,surf_mV_sensor3_row-.5
1237 STRCPY_PRINT "\xb8" ; mark sensor as being at end of lifetime
1238
1239 TFT_imprint_surf_eol_4:
1240 return ; done
1241
1242
1243 ;-----------------------------------------------------------------------------
1244 ; Imprint Function for the Calibration Menu
1245 ;
1246 global TFT_imprint_menu_mV
1247 TFT_imprint_menu_mV:
1248 FONT_COLOR color_yellow ; show in yellow
1249 rcall TFT_sensor_mv_get ; get sensor mV values
1250
1251 ; sensor 1
1252 WIN_SMALL surf_menu_sensor1_column,surf_menu2_sensor1_row
1253 SMOVII sensor1_mv,mpr ; in 0.1mV steps
1254 rcall TFT_imprint_menu_mV_helper ; print mV value
1255
1256 ; sensor 2
1257 WIN_SMALL surf_menu_sensor2_column,surf_menu2_sensor2_row
1258 SMOVII sensor2_mv,mpr ; in 0.1mV steps
1259 rcall TFT_imprint_menu_mV_helper ; print mV value
1260
1261 ; sensor 3
1262 WIN_SMALL surf_menu_sensor3_column,surf_menu2_sensor3_row
1263 SMOVII sensor3_mv,mpr ; in 0.1mV steps
1264 rcall TFT_imprint_menu_mV_helper ; print mV value
1265
1266 TSTOSS opt_s8_mode ; =0: analog, =1: digital
1267 return ; analog - done
1268
1269 ; imprint HUD battery voltage
1270 WIN_TINY .20,.209 ; set position
1271 STRCPY "HUD Batt: " ; print label
1272 SMOVII hud_battery_mv,mpr ; get HUD battery voltage
1273 bsf decimal_digit3 ; place a decimal point in front of digit 3
1274 output_9999 ; print (0.000-9.999)
1275 PUTC_PRINT "V" ; append unit and dump buffer to screen
1276 return ; done
1277
1278 ; Helper Function - get sensor mV values
1279 TFT_sensor_mv_get:
1280 ; btfsc ext_input_optical ; do we have an optical interface?
1281 ; return ; YES - optical interface delivers ready-to-use mV data, done
1282 TSTOSS opt_s8_mode ; NO - S8 input selected?
1283 bra TFT_sensor_mv_get_ana ; NO - read analog inputs
1284 ;bra TFT_sensor_mv_get_dig ; YES - convert digitally received ppO2 into mV
1285
1286 TFT_sensor_mv_get_dig:
1287 btfss trigger_S8_data_update ; new data frame received?
1288 return ; NO - use old values
1289 bcf trigger_S8_data_update ; YES - clear update flag
1290 call compute_mvolts_from_rawdata ; - compute mV values from received raw data
1291 return ; - done
1292
1293 TFT_sensor_mv_get_ana:
1294 call get_analog_inputs ; read mV values from analog inputs
1295 return ; done
1296
1297
1298 ; Helper Function - print mV value
1299 TFT_imprint_menu_mV_helper:
1300 bsf decimal_digit1 ; place a decimal point in front of digit 1 (no 0.1 mV)
1301 output_9999 ; print (0.0-999.9)
1302 STRCAT_PRINT "mV" ; append unit and dump buffer to screen
1303 return ; done
1304
1305 ENDIF ; _external_sensor
1306
1307
1308 IFDEF _rx_functions
1309 ;-----------------------------------------------------------------------------
1310 ; Imprint Function for the Tank Setup Menu
1311 ;
1312 global TFT_imprint_tank_pres
1313 TFT_imprint_tank_pres:
1314 FONT_COLOR_MEMO ; set color
1315 ; get ID
1316 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id
1317 movf gaslist_gas,W ; get current gas
1318 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size
1319 movff PLUSW1,lo ; copy opt_transmitter_id+0[gaslist_gas] to lo
1320 incf WREG,W ; increment index
1321 movff PLUSW1,hi ; copy opt_transmitter_id+1[gaslist_gas] to hi
1322 ; show pressure
1323 WIN_SMALL .90, .61 ; column, row (+/- 27 per row)
1324 call get_pres_by_transmitter_id ; get pressure into hi:lo
1325 tstfsz WREG ; do we have valid tank data (WREG=0) ?
1326 bra TFT_menu_tank_pres_1 ; NO - transmitter not found
1327 call TFT_color_code_pres_sac ; set output color according to flags
1328 bsf omit_digit_1 ; do not print 1st digit (0.1 bar)
1329 output_9999 ; print (0x-999x)
1330 bra TFT_menu_tank_pres_2
1331 TFT_menu_tank_pres_1:
1332 FONT_COLOR_DISABLED ; select color
1333 STRCAT " ---" ; print dashes for no pressure data available
1334 TFT_menu_tank_pres_2:
1335 STRCAT_TEXT_PRINT tbar ; print " bar"
1336 return ; done
1337
1338 ENDIF ; _rx_functions
1339
1340
1341 ;=============================================================================
1342 tft_out5 CODE
1343 ;=============================================================================
1344
1345
1346 ;-----------------------------------------------------------------------------
1347 ; Dive Mode - static Layout
1348 ;
621 global TFT_show_divemode_mask 1349 global TFT_show_divemode_mask
622 TFT_show_divemode_mask: ; display mask in dive mode 1350 TFT_show_divemode_mask: ; display mask in dive mode
623 call TFT_divemask_color ; set color 1351 FONT_COLOR_MASK ; select color
624 1352
625 ; depth 1353 ; current depth
626 WIN_TINY dm_mask_depth_column,dm_mask_depth_row ; position for "Depth" 1354 WIN_TINY dm_mask_depth_column,dm_mask_depth_row ; position for "Depth"
627 btfss alt_layout_active ; alternative layout active? 1355 btfss alt_layout_active ; alternative layout active?
628 bra TFT_divemode_mask_depth_text ; NO 1356 bra TFT_divemode_mask_depth_text ; NO
629 WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; YES - alternative position for "Depth" 1357 btfsc cur_depth_greater_100m ; YES - current depth >= 100 m?
1358 bra TFT_divemode_mask_max_avg ; YES - skip depth label as it collides with depth number
1359 WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; NO - set alternative position for "Depth"
630 TFT_divemode_mask_depth_text: 1360 TFT_divemode_mask_depth_text:
631 STRCAT_TEXT_PRINT tDepth ; print "Depth" 1361 STRCAT_TEXT_PRINT tDepth ; print "Depth"
632 1362
1363 TFT_divemode_mask_max_avg:
633 ; avg or max depth 1364 ; avg or max depth
634 btfsc alt_layout_active ; alternative layout active? 1365 btfsc alt_layout_active ; alternative layout active?
635 bra TFT_divemode_mask_avg_max_alt ; YES 1366 bra TFT_divemode_mask_avg_max_alt ; YES
636 1367
637 WIN_TINY dm_mask_maxdepth_col_nvsi,dm_mask_maxdepth_row ; default position for "max.Depth"/"avg.Depth" 1368 WIN_TINY dm_mask_maxdepth_col_nvsi,dm_mask_maxdepth_row ; default position for "max.Depth"/"avg.Depth"
661 TFT_divemode_mask_time_pos: 1392 TFT_divemode_mask_time_pos:
662 WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row ; position for "Divetime" 1393 WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row ; position for "Divetime"
663 TFT_divemode_mask_time_text: 1394 TFT_divemode_mask_time_text:
664 STRCAT_TEXT_PRINT tDivetime ; print "Divetime" 1395 STRCAT_TEXT_PRINT tDivetime ; print "Divetime"
665 btfss FLAG_apnoe_mode ; in apnea mode? 1396 btfss FLAG_apnoe_mode ; in apnea mode?
666 bra TFT_standard_color ; NO - done 1397 return ; NO - done
667 WIN_TINY dm_total_apnoe_text_col,dm_total_apnoe_text_row; YES - set position 1398 WIN_TINY dm_total_apnoe_text_col,dm_total_apnoe_text_row; YES - set position
668 STRCPY_TEXT_PRINT tApnoeTotal ; - print "Total" 1399 STRCPY_TEXT_PRINT tApnoeTotal ; - print "Total"
669 bra TFT_standard_color ; - done 1400 return ; - done
670 1401
671 ;========================================================================= 1402
672 1403 ;-----------------------------------------------------------------------------
673 global TFT_velocity_show 1404 ; Dive Mode - NDL Layout Add-on
674 TFT_velocity_show: 1405 ;
675 rcall TFT_memo_color ; set default color 1406 global TFT_show_ndl_mask
676 btfsc neg_flag_velocity ; descending? 1407 TFT_show_ndl_mask:
677 rcall TFT_velocity_set_color ; NO - set color for text dependent on speed and set threshold for VSI graph 1408 btfsc dive_main_menu ; is the dive mode menu shown?
678 rcall TFT_velocity_num ; show the numerical VSI 1409 return ; YES - abort
679 TSTOSS opt_vsigraph ; graphical VSI bar enabled? 1410 FONT_COLOR_MASK ; NO - set color
680 bra TFT_standard_color ; NO - done 1411 ; - set position
681 btfsc neg_flag_velocity ; YES - in ascent? 1412 WIN_STD dm_ndl_text_column, dm_ndl_text_row
682 bra TFT_velocity_graph_show ; YES - show the graph 1413 STRCPY_TEXT_PRINT tNDL ; - print "NDL"
683 bra TFT_velocity_graph_clear_1 ; NO - clear the graph 1414 btfss deco_region ; - was the dive within deco stops region?
684 1415 return ; NO - done
685 TFT_speed_table: 1416 btfsc safety_stop_active ; YES - safety stop shown?
1417 return ; YES - done
1418 goto TFT_show_slow_reminder ; NO - show "slow" reminder
1419
1420
1421 ;-----------------------------------------------------------------------------
1422 ; Dive Mode - Deco Layout Add-on
1423 ;
1424 global TFT_show_deco_mask
1425 TFT_show_deco_mask:
1426 bcf safety_stop_active ; flag safety stop is not shown any more TODO: needed?
1427 btfsc dive_main_menu ; is the dive mode menu shown?
1428 return ; YES - abort
1429 btfsc alt_layout_active ; NO - in alternative layout?
1430 bra TFT_show_deco_mask_alt ; YES
1431 ;bra TFT_show_deco_mask_norm ; NO
1432
1433 TFT_show_deco_mask_norm:
1434 WIN_STD dm_tts_text_col_norm, dm_tts_text_row_norm
1435 bra TFT_show_deco_mask_common ; continue with common part
1436
1437 TFT_show_deco_mask_alt:
1438 WIN_TINY dm_tts_text_col_alt, dm_tts_text_row_alt
1439 STRCPY "Stop/" ; print "Stop/"
1440 ;bra TFT_show_deco_mask_common ; continue with common part
1441
1442 TFT_show_deco_mask_common:
1443 FONT_COLOR_MASK ; set color
1444 STRCAT_TEXT_PRINT tTTS ; print "TTS"
1445 return ; done
1446
1447
1448 ;=============================================================================
1449 tft_out6 CODE
1450 ;=============================================================================
1451
1452
1453 ;-----------------------------------------------------------------------------
1454 ; Dive Mode - show Dive Time
1455 ;
1456 global TFT_show_divetime
1457 TFT_show_divetime:
1458 FONT_COLOR_MEMO ; set color
1459 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 (mpr+1:mpr+0) and seconds (mpr+2)
1460 btfsc show_only_divemins ; shall suppress display of seconds?
1461 bra TFT_show_divetime_min_only ; YES - show minutes only
1462 movlw .99 ; NO - load 99
1463 cpfsgt mpr+0 ; - dive time > 99 minutes ?
1464 bra TFT_show_divetime_min_sec ; NO - show min:sec
1465 bsf show_only_divemins ; YES - set flag to suppress the display of seconds for the rest of the dive
1466 btfsc alt_layout_active ; - in alternative layout?
1467 bra TFT_show_divetime_clear_alt ; YES - clear min:sec area of alternative layout
1468 ;bra TFT_show_divetime_clear_norm ; NO - clear min:sec area of normal layout
1469
1470 TFT_show_divetime_clear_norm:
1471 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_medium, dm_divetime_col_medium, dm_divetime_rgt ;top, bottom, left, right
1472 bra TFT_show_divetime_min_only_norm ; show minutes only
1473
1474 TFT_show_divetime_clear_alt:
1475 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_large, dm_divetime_col_large, dm_divetime_rgt ;top, bottom, left, right
1476 bra TFT_show_divetime_min_only_alt ; show minutes only
1477
1478 TFT_show_divetime_min_sec:
1479 ; show the minutes
1480 btfsc alt_layout_active ; in alternative layout?
1481 bra TFT_show_divetime_min_alt ; YES
1482 ;bra TFT_show_divetime_min_norm ; NO
1483
1484 TFT_show_divetime_min_norm:
1485 WIN_MEDIUM dm_divetime_col_medium, dm_divetime_row
1486 bra TFT_show_divetime_min_com ; continue with common part
1487
1488 TFT_show_divetime_min_alt:
1489 WIN_LARGE dm_divetime_col_large, dm_divetime_row
1490 ;bra TFT_show_divetime_min_com ; continue with common part
1491
1492 TFT_show_divetime_min_com:
1493 output_99 ; print minutes (0-99)
1494 PRINT ; dump buffer to screen
1495
1496 ; show the seconds
1497 btfsc alt_layout_active ; in alternative layout?
1498 bra TFT_show_divetime_sec_alt ; YES
1499 ;bra TFT_show_divetime_sec_norm ; NO
1500
1501 TFT_show_divetime_sec_norm:
1502 WIN_SMALL dm_divetime_sec_col_small, dm_divetime_sec_row_small
1503 bra TFT_show_divetime_sec_com ; continue with common part
1504
1505 TFT_show_divetime_sec_alt:
1506 WIN_MEDIUM dm_divetime_sec_col_medium, dm_divetime_sec_row_medium
1507 ;bra TFT_show_divetime_sec_com ; continue with common part
1508
1509 TFT_show_divetime_sec_com:
1510 PUTC ':' ; print separator char
1511 movff mpr+2,lo ; copy seconds to lo
1512 output_99x ; print seconds (00-99)
1513 bra TFT_divemins_exit ; continue with common part
1514
1515 TFT_show_divetime_min_only:
1516 btfsc alt_layout_active ; in alternative layout?
1517 bra TFT_show_divetime_min_only_alt ; YES
1518 ;bra TFT_show_divetime_min_only_norm ; NO
1519
1520 TFT_show_divetime_min_only_norm:
1521 WIN_MEDIUM dm_divetime_minonly_col_medium, dm_divetime_row
1522 output_9999 ; print minutes (0-9999)
1523 bra TFT_divemins_exit ; continue with common part
1524
1525 TFT_show_divetime_min_only_alt:
1526 WIN_LARGE dm_divetime_minonly_col_large, dm_divetime_row
1527 output_999 ; print minutes (0-999)
1528 ;bra TFT_divemins_exit ; continue with common part
1529
1530 TFT_divemins_exit:
1531 PRINT ; dump buffer to screen
1532 return ; done
1533
1534
1535 ;-----------------------------------------------------------------------------
1536 ; Dive Mode - show current Depth
1537 ;
1538 global TFT_show_depth
1539 TFT_show_depth:
1540 MOVII pressure_rel_cur_cached,mpr ; copy relative pressure to MPR
1541 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
1542 call TFT_color_code_depth ; set warning / attention flags and color-code the output
1543 rcall TFT_depth_blink ; control animation (blinking)
1544
1545 rcall TFT_depth_position_m_ft ; set output position for full meters/feet
1546 TSTOSS opt_units ; 0=m, 1=ft ?
1547 bra TFT_depth_metric ; 0 - metric
1548 ;bra TFT_depth_imperial ; 1 - imperial
1549
1550 TFT_depth_imperial:
1551 MOVLI .30,sub_a ; load depth threshold of 30 cm (for showing 0 if shallower)
1552 MOVII mpr,sub_b ; get current depth
1553 call cmpU16 ; compute sub_a - sub_b = threshold - current depth
1554 btfss neg_flag ; shallower than 30 cm ?
1555 bra depth_0_feet ; YES - print a zero directly
1556 call convert_cm_to_feet ; NO - convert value in hi:lo from [cm] to [feet]
1557 output_999 ; - feet in large or huge font
1558 PRINT ; - dump to screen
1559 bra TFT_depth_exit ; - do some cleanup and show target depth if in simulator mode
1560
1561 depth_0_feet:
1562 STRCAT_PRINT " 0" ; print a zero directly
1563 bra TFT_depth_exit ; do some cleanup and show target depth if in simulator mode
1564
1565 TFT_depth_metric:
1566 bsf omit_digit_2 ; print depth in full meters, i.e. do not print 2nd and 1st digit
1567 output_9999 ; test-print depth for range up to 99.9 meter (0xx-99xx)
1568 btfsc output_overflow ; did the printing clip, i.e. deeper than 99.9 meter?
1569 bra TFT_depth_metric_100m ; YES - print depth in full meters only
1570
1571 ; depth in meters and decimeters
1572 btfsc cur_depth_greater_100m ; was the depth >= 100 meter during last call?
1573 rcall TFT_depth_box_black ; YES - clear depth area
1574 bcf cur_depth_greater_100m ; current depth is now < 100 meter
1575 PRINT ; dump full meters to screen
1576
1577 btfsc depth_inverse_last ; in inverse printing cycle?
1578 bsf win_invert ; YES - print inverse
1579 rcall TFT_depth_position_dm ; set output position for decimeters
1580 MOVLI .30,sub_a ; 30 mbar = 0.3 meter
1581 MOVII mpr,sub_b ; current depth
1582 call cmpU16 ; compare (sub_a - sub_b)
1583 btfss neg_flag ; current depth < 0.3 meter ?
1584 bra depth_0_decimeter ; YES - print a zero
1585 output_65535 ; NO - print full depth to buffer
1586 REINIT_BUFFER ; - re-initialize the output buffer
1587 PUTC "." ; - print a decimal point
1588 movff buffer+3,POSTINC2 ; - get and print the decimeters
1589 PRINT ; - dump to screen
1590 bra TFT_depth_exit ; - do some cleanup and show target depth if in simulator mode
1591 depth_0_decimeter:
1592 STRCAT_PRINT ".0" ; print a zero directly and dump buffer to screen
1593 bra TFT_depth_exit ; do some cleanup and show target depth if in simulator mode
1594
1595 TFT_depth_metric_100m:
1596 ; full meters only
1597 btfss cur_depth_greater_100m ; was the depth >= 100 meter during last call?
1598 rcall TFT_depth_box_black ; NO - clear depth area
1599 bsf cur_depth_greater_100m ; depth is >= 100 meter now
1600 REINIT_BUFFER ; re-initialize the output buffer
1601 bsf omit_digit_2 ; print depth in full meters, i.e. do not print 1st and 2nd digit
1602 output_65535 ; print depth for range >= 100 meter (0xx-655xx)
1603 PRINT ; dump to screen
1604 ;bra TFT_depth_exit ; do some cleanup and show target depth if in simulator mode
1605
1606 TFT_depth_exit:
1607 btfss alt_layout_active ; alternative layout active?
1608 bra TFT_depth_exit_2 ; NO
1609 btfsc depth_inverse_last ; YES - was last output in inverse mode?
1610 bra TFT_depth_exit_2 ; YES - do not restore "Depth" as it collides with depth number
1611 btfsc cur_depth_greater_100m ; NO - current depth >= 100 m?
1612 bra TFT_depth_exit_2 ; YES
1613 ;bra TFT_depth_exit_1 ; NO
1614
1615 TFT_depth_exit_1
1616 WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row
1617 FONT_COLOR_MASK ; set color
1618 STRCAT_TEXT_PRINT tDepth ; restore "Depth" title
1619
1620 TFT_depth_exit_2:
1621 btfss sensor_override_active ; pressure sensor override active (simulator mode)?
1622 return ; NO - done
1623 bra TFT_depth_target ; YES - show simulator target depth
1624
1625
1626 ; Helper Function - control animation (blinking)
1627 TFT_depth_blink:
1628 TSTOSS opt_depth_warn ; 0=standard, 1=blink
1629 return ; standard, done
1630 btfsc depth_color_last ; was there a warning or attention on the depth in the previous cycle?
1631 bra TFT_depth_blink_prev ; YES
1632 btfsc depth_color_warning ; NO - do we have a depth warning now?
1633 bra TFT_depth_blink_new ; YES - so we have a warning now but not previously
1634 btfsc depth_color_attention ; NO - do we have a depth attention now?
1635 bra TFT_depth_blink_new ; YES - so we have attention now but not previously
1636 bra TFT_depth_blink_none ; NO - no warning in previous cycle, no warning now, reset all flags
1637
1638 TFT_depth_blink_prev:
1639 ; we had a warning or attention in previous cycle, check if we still have a warning or attention
1640 btfsc depth_color_warning ; do we still have a warning?
1641 bra TFT_depth_blink_prev_1 ; YES
1642 btfsc depth_color_attention ; NO - do we still have an attention?
1643 bra TFT_depth_blink_prev_1 ; YES
1644 ; we had a warning or attention before, but not now any more - clear depth area from previous color
1645 rcall TFT_depth_box_black ; NO - clear depth area
1646 ;bra TFT_depth_blink_none ; - reset all flags
1647
1648 TFT_depth_blink_none:
1649 bcf depth_inverse_last ; memorize depth was printed in normal
1650 bcf depth_color_last ; memorize there was no warning or attention
1651 FONT_COLOR_MEMO ; select memo color
1652 return ; done
1653
1654 TFT_depth_blink_prev_1:
1655 ; we had a warning or attention in previous cycle, and we still have a warning or attention
1656 btfss depth_inverse_last ; was the depth printed in inverse last time?
1657 bra TFT_depth_blink_set ; NO - print in inverse now
1658 bra TFT_depth_blink_reset ; YES - print in normal now
1659
1660 TFT_depth_blink_new:
1661 ; we had no warning or attention in previous cycle, but now
1662 bsf depth_color_last ; memorize that the depth had a warning or attention
1663 ;bra TFT_depth_blink_set ; start with inverse display
1664
1665 TFT_depth_blink_set:
1666 ; fill the area with respective color
1667 movf pallet_color_attention,W ; select attention color as default
1668 btfsc depth_color_warning ; do we have a warning?
1669 movf pallet_color_warning,W ; YES - replace with warning color
1670 rcall TFT_depth_box_color ; color depth area with color in WREG
1671 bsf win_invert ; print in inverse
1672 bsf depth_inverse_last ; memorize depth was printed in inverse
1673 return ; done
1674
1675 TFT_depth_blink_reset:
1676 ; fill the area with black color
1677 rcall TFT_depth_box_black ; clear depth area
1678 bcf depth_inverse_last ; memorize depth was printed in normal
1679 return ; done
1680
1681
1682 ; Helper Function - set output position for full meters/feet
1683 TFT_depth_position_m_ft: ; output position meters / feet
1684 btfsc alt_layout_active ; alternative layout active?
1685 bra TFT_depth_position_m_ft_alt ; YES
1686 ;bra TFT_depth_position_m_ft_norm; NO
1687
1688 TFT_depth_position_m_ft_norm:
1689 WIN_LARGE dm_depth_col_large,dm_depth_row_large
1690 return ; done
1691
1692 TFT_depth_position_m_ft_alt:
1693 WIN_HUGE dm_depth_col_huge, dm_depth_row_huge
1694 return ; done
1695
1696
1697 ; Helper Function - set output position for decimeters
1698 TFT_depth_position_dm: ; output position decimeters
1699 btfsc alt_layout_active ; alternative layout active?
1700 bra TFT_depth_position_dm_alt ; YES
1701 bra TFT_depth_position_dm_norm ; NO
1702
1703 TFT_depth_position_dm_norm:
1704 WIN_MEDIUM dm_depth_dm_col_medium, dm_depth_dm_row_medium
1705 return ; done
1706 TFT_depth_position_dm_alt:
1707 WIN_LARGE dm_depth_dm_col_large, dm_depth_dm_row_large
1708 return ; done
1709
1710
1711 ; Helper Function - clear depth area
1712 TFT_depth_box_black:
1713 clrf WREG ; select black color
1714 ;bra TFT_depth_box_color ; continue with colored box
1715
1716
1717 ; Helper Function - color depth area with color in WREG
1718 TFT_depth_box_color:
1719 btfsc alt_layout_active ; alternative layout active?
1720 bra TFT_depth_box_alt ; YES
1721 ;bra TFT_depth_box_norm ; NO
1722
1723 TFT_depth_box_norm:
1724 WIN_BOX_COLOR dm_depth_row_large,dm_depth_bot_large,dm_depth_col_large,dm_depth_rgt_large
1725 return ; done
1726
1727 TFT_depth_box_alt:
1728 WIN_BOX_COLOR dm_mask_depth_row, dm_depth_bot_huge, dm_depth_col_huge, dm_depth_rgt_huge
1729 TFT_depth_box_exit:
1730 return ; done
1731
1732
1733 ; Helper Function - show simulated target depth
1734 TFT_depth_target:
1735 FONT_COLOR_ATTENTION ; select attention color
1736 movff simulatormode_depth,lo ; copy target depth to lo
1737 TSTOSS opt_units ; check unit selection (0=m or 1=ft)
1738 bra TFT_depth_target_metric ; 0 - metric
1739 ;bra TFT_depth_target_imperial ; 1 - imperial
1740
1741 TFT_depth_target_imperial:
1742 btfsc alt_layout_active ; alternative layout active?
1743 bra TFT_depth_target_imperial_alt ; YES
1744 ;bra TFT_depth_target_imperial_norm ; NO
1745
1746 TFT_depth_target_imperial_norm:
1747 WIN_TINY dm_mask_depth_column+.40,dm_mask_depth_row ; position right of depth label
1748 bra TFT_depth_target_imperial_com ; continue with common part
1749
1750 TFT_depth_target_imperial_alt:
1751 WIN_TINY dm_mask_depth_column+.62,dm_mask_depth_row+.20 ; position within last digit
1752 ;bra TFT_depth_target_imperial_com ; continue with common part
1753
1754 TFT_depth_target_imperial_com:
1755 call convert_meter_to_feet ; convert value in lo from meters to feet
1756 output_999 ; display only last three digits from a 16 bit value (0-999)
1757 STRCAT_PRINT "ft" ; append unit and dump buffer to screen
1758 return ; done
1759
1760 TFT_depth_target_metric:
1761 btfsc alt_layout_active ; alternative layout active?
1762 bra TFT_depth_target_metric_alt ; YES
1763 ;bra TFT_depth_target_metric_norm ; NO
1764
1765 TFT_depth_target_metric_norm:
1766 WIN_TINY dm_mask_depth_column+.38,dm_mask_depth_row+.22 ; position right of full meters, above decimal
1767 bra TFT_depth_target_metric_com ; continue with common part
1768
1769 TFT_depth_target_metric_alt:
1770 WIN_TINY dm_mask_depth_column+.65,dm_mask_depth_row+.20 ; position right of full meters, above decimal
1771 ;bra TFT_depth_target_metric_com ; continue with common part
1772
1773 TFT_depth_target_metric_com:
1774 output_256 ; display target depth (0-255)
1775 PUTC_PRINT "m" ; append unit and dump to screen
1776 return ; done
1777
1778
1779 ;-----------------------------------------------------------------------------
1780 ; Dive Mode - show maximum Depth
1781 ;
1782 global TFT_show_max_depth
1783 TFT_show_max_depth:
1784 FONT_COLOR_MEMO ; select color
1785 btfsc alt_layout_active ; alternative layout active?
1786 bra TFT_show_max_depth_alt ; YES
1787 ;bra TFT_show_max_depth_norm ; NO
1788
1789 TFT_show_max_depth_norm:
1790 WIN_MEDIUM dm_max_depth_column_nvsi, dm_max_depth_row
1791 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
1792 bra TFT_show_max_depth_norm_1 ; NO - keep position
1793 WIN_MEDIUM dm_max_depth_column, dm_max_depth_row ; YES - adopt output position
1794
1795 TFT_show_max_depth_norm_1:
1796 btfsc FLAG_apnoe_mode ; in apnoe mode?
1797 bra TFT_max_depth_apnoe ; YES - different handling in apnoe mode
1798 TSTOSS opt_2ndDepthDisp ; NO - show average depth instead of max depth?
1799 bra TFT_max_depth_current ; NO - show max depth
1800 bra TFT_avg_depth_current ; YES - show avg depth
1801
1802 TFT_max_depth_apnoe:
1803 btfss apnoe_at_surface ; apnoe mode, at the surface?
1804 bra TFT_max_depth_current ; NO - show max depth of current dive
1805 MOVII apnoe_max_pressure,mpr ; YES - get max pressure of all dives so far
1806 bra TFT_max_depth_common ; - continue with common part
1807
1808 TFT_max_depth_current:
1809 MOVII pressure_rel_max_cached,mpr ; get the "normal" max pressure
1810 bra TFT_max_depth_common ; continue with common part
1811
1812 TFT_avg_depth_current:
1813 MOVII pressure_rel_avg_total,mpr ; get total dive average pressure
1814 ;bra TFT_max_depth_common ; continue with common part
1815
1816 TFT_max_depth_common:
1817 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
1818 TSTOSS opt_units ; 0=m or 1=ft ?
1819 bra TFT_max_depth_metric ; 0 - use metric version
1820 ;bra TFT_max_depth_imperial ; 1 - use imperial version
1821
1822 TFT_max_depth_imperial:
1823 bra TFT_show_depth_helper_imperial
1824
1825 TFT_max_depth_metric:
1826 bsf omit_digit_2 ; print depth in full meters, i.e. do not print 2nd and 1st digit
1827 output_9999 ; test-print depth for range up to 99.9 meter (0xx-99xx)
1828 btfsc output_overflow ; did the printing clip, i.e. deeper than 99.9 meter?
1829 bra TFT_max_depth_metric_100m ; YES - print depth in full meters only
1830 ;bra TFT_max_depth_metric_99m ; NO - print depth in meters and decimeters
1831
1832 TFT_max_depth_metric_99m:
1833 ; full meters
1834 btfsc max_depth_greater_100m ; was the depth >= 100 meter during last call?
1835 rcall TFT_max_depth_box_black ; NO - clear max depth area
1836 bcf max_depth_greater_100m ; current depth is now < 100 meter
1837 PRINT ; dump full meters to screen
1838 ; decimeters
1839 rcall TFT_max_depth_metric_dm ; set output position for decimeters
1840 output_65535 ; print full depth to buffer
1841 REINIT_BUFFER ; re-initialize the output buffer
1842 PUTC "." ; print a decimal point
1843 movff buffer+3,POSTINC2 ; get and print the decimeters
1844 PRINT ; dump to screen
1845 return ; done
1846
1847 TFT_max_depth_metric_100m:
1848 ; full meters only
1849 btfss max_depth_greater_100m ; was the depth >= 100 meter during last call?
1850 rcall TFT_max_depth_box_black ; NO - clear max depth area
1851 bsf max_depth_greater_100m ; depth is >= 100 meter now
1852 REINIT_BUFFER ; re-initialize the output buffer
1853 bsf omit_digit_2 ; print depth in full meters, i.e. do not print 1st and 2nd digit
1854 output_65535 ; print depth for range >= 100 meter (0xx-655xx)
1855 PRINT ; dump to screen
1856 return ; done
1857
1858 TFT_show_max_depth_alt:
1859 btfsc FLAG_apnoe_mode ; in apnoe mode?
1860 bra TFT_show_apnoe_max_depth ; YES - use apnoe surface output also in alternative dive mode screen
1861 btfss FLAG_gauge_mode ; NO - in gauge mode?
1862 return ; NO - done
1863 ;bra TFT_show_gauge_max_avg_depth; YES
1864
1865 TFT_show_gauge_max_avg_depth:
1866 WIN_MEDIUM dm_gauge_max_depth_col, dm_gauge_max_depth_row ; set position for max depth
1867 MOVII pressure_rel_max_cached,mpr ; get max pressure into hi:lo
1868 rcall TFT_show_depth_helper ; print max depth
1869 WIN_MEDIUM dm_gauge_avg_depth_col, dm_gauge_avg_depth_row ; set position for avg depth
1870 MOVII pressure_rel_avg_total,mpr ; get average pressure into hi:lo
1871 bra TFT_show_depth_helper ; print avg depth and return
1872
1873
1874 ; Helper Function - clear max depth area
1875 TFT_max_depth_box_black:
1876 WIN_BOX_BLACK dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt
1877 return ; done
1878
1879
1880 ; Helper Function - set output position for decimeters
1881 TFT_max_depth_metric_dm:
1882 WIN_SMALL dm_max_depth_dm_column_nvsi, dm_max_depth_dm_row ; default position
1883 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
1884 return ; NO - keep position
1885 WIN_SMALL dm_max_depth_dm_column, dm_max_depth_dm_row ; YES - adopt position
1886 return ; done
1887
1888
1889 ; Helper Function - print depth in mpr
1890 TFT_show_depth_helper:
1891 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
1892 TSTOSS opt_units ; 0=m, 1=ft
1893 bra TFT_show_depth_helper_metric ; 0 - metric
1894 ;bra TFT_show_depth_helper_imperial ; 1 - imperial
1895
1896 TFT_show_depth_helper_imperial:
1897 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
1898 output_999 ; print depth (0-999)
1899 PRINT ; dump to screen
1900 return ; done
1901
1902 TFT_show_depth_helper_metric:
1903 bsf omit_digit_1 ; do not print 1st digit
1904 bsf decimal_digit2 ; place a decimal point in front of digit 2
1905 output_65535 ; print depth (0.0x-655.3x)
1906 PRINT ; dump to screen
1907 return ; done
1908
1909
1910 ;-----------------------------------------------------------------------------
1911 ; Dive Mode - show maximum Depth - Apnoe Mode
1912 ;
1913 global TFT_show_apnoe_max_depth
1914 TFT_show_apnoe_max_depth:
1915 ; title
1916 WIN_TINY dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row
1917 FONT_COLOR_MASK ; set color
1918 btfsc alt_layout_active ; alternative layout active?
1919 bra TFT_show_apnoe_max_depth_alt ; YES
1920 ;bra TFT_show_apnoe_max_depth_norm ; NO
1921
1922 TFT_show_apnoe_max_depth_norm:
1923 STRCPY_TEXT_PRINT tApnoeMax ; print "Last Descent"
1924 bra TFT_show_apnoe_max_depth_com ; continue with common part
1925
1926 TFT_show_apnoe_max_depth_alt:
1927 STRCPY_TEXT_PRINT tMaxDepth ; print "Max.Depth"
1928 ;bra TFT_show_apnoe_max_depth_com ; continue with common part
1929
1930 TFT_show_apnoe_max_depth_com:
1931 ; value
1932 WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
1933 FONT_COLOR_MEMO ; select color
1934 MOVII pressure_rel_max_cached,mpr ; get max pressure into hi:lo
1935 bra TFT_show_depth_helper ; print max depth and return
1936
1937
1938 ;-----------------------------------------------------------------------------
1939 ; Dive Mode - show Temperature
1940 ;
1941 global TFT_show_temp_divemode
1942 TFT_show_temp_divemode:
1943 btfsc dive_pre_menu ; is the pre-menu shown?
1944 return ; YES - abort
1945 btfsc dive_main_menu ; is the dive mode menu shown?
1946 return ; YES - abort, no update of temperature now
1947 btfsc better_gas_blinking ; blinking better gas?
1948 return ; YES - abort, no update of temperature now
1949 btfsc better_dil_blinking ; blinking better diluent?
1950 return ; YES - abort, no update of temperature now
1951
1952 WIN_SMALL dm_temp_column,dm_temp_row; set position
1953 FONT_COLOR_MEMO ; set color
1954 movlw index_compass_dm ; index of compass custom view
1955 cpfseq active_customview ; compass shown in custom view?
1956 goto TFT_temp_common ; NO - continue with common part for temperature
1957 goto TFT_update_stopwatch ; YES - show resettable dive time instead of temperature
1958
1959
1960 ;-----------------------------------------------------------------------------
1961 ; Dive Mode - active Gas and Setpoint
1962 ;
1963 global TFT_show_active_gas_divemode
1964 TFT_show_active_gas_divemode:
1965 btfsc dive_main_menu ; is the dive mode menu shown?
1966 return ; YES - abort
1967 btfsc FLAG_apnoe_mode ; in apnoe mode?
1968 return ; YES - done
1969 btfsc FLAG_gauge_mode ; in gauge mode?
1970 return ; YES - done
1971
1972 IFDEF _ccr_pscr
1973
1974 btfsc FLAG_oc_mode ; in OC mode?
1975 bra TFT_active_gas ; YES - show OC gas
1976 btfss bailout_mode ; NO - in bailout?
1977 bra TFT_active_sp_loop ; NO
1978 ;bra TFT_active_sp_bailout ; YES
1979
1980 TFT_active_sp_bailout:
1981 WIN_SMALL dm_active_dil_column, dm_active_dil_row
1982 FONT_COLOR_ATTENTION ; set color
1983 STRCPY_TEXT_PRINT tDiveBailout ; print "Bailout"
1984 bra TFT_active_gas ; continue showing OC bailout gas
1985
1986 TFT_active_sp_loop:
1987 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] to hi:lo
1988 call TFT_color_code_ppo2 ; color-code the output by the ppO2 of the loop gas mixture
1989 btfss timebase_1sec ; on even second?
1990 bra TFT_active_sp_print ; YES - print ppO2 with normal rendering
1991 btfsc warn_det_sensors_lost ; NO - all sensors lost?
1992 bra TFT_active_sp_fallback ; YES - process fallback case
1993 movff int_O_breathed_ppO2+1,WREG ; NO - get flags again (have been cleared in hi:lo by TFT_color_code_ppo2 meanwhile)
1994 btfss WREG,int_warning_flag ; warning flag set?
1995 bra TFT_active_sp_print ; NO - ppO2 is ok, print ppO2 with normal rendering
1996 bra TFT_active_sp_invers ; YES - print with inverse rendering
1997 TFT_active_sp_fallback: ; set up fallback case
1998 FONT_COLOR_ATTENTION ; set color to attention
1999 TFT_active_sp_invers:
2000 bsf win_invert ; print in inverse
2001 TFT_active_sp_print:
2002 WIN_MEDIUM dm_active_gas_sp_value_col, dm_active_gas_sp_value_row
2003 bsf decimal_digit2 ; place a decimal point in front of digit 2
2004 output_999 ; print ppO2 (0.00-9.99)
2005 PRINT ; dump to screen
2006
2007 btfsc sign_shown ; advice/attention/warning sign shown?
2008 bra TFT_active_diluent ; YES - do not overwrite in case of alternative layout
2009
2010 btfsc velocity_active_vsi ; graphical vertical speed indicator shown?
2011 bra TFT_active_diluent ; YES - do not overwrite in case of alternative layout
2012
2013 TFT_active_sp_label_1:
2014 WIN_STD dm_active_sp_label_col, dm_active_sp_label_row
2015 FONT_COLOR_MEMO ; select memo color
2016 STRCAT "bar" ; print "bar"
2017
2018 IFDEF _external_sensor
2019
2020 movff opt_ccr_mode,WREG ; get setpoint mode =0: Fixed SP, =1: Sensor, =2: Auto SP
2021 sublw .1 ; opt_ccr_mode = 1 (Sensor) ?
2022 bnz TFT_active_sp_label_2 ; NO - skip
2023 btfsc alt_layout_active ; YES - in alternative layout?
2024 bra TFT_active_sp_label_2 ; YES - no space available for the "*"
2025 PUTC "*" ; NO - append "*"
2026
2027 ENDIF
2028
2029 TFT_active_sp_label_2:
2030 PRINT ; dump buffer to screen
2031
2032 TFT_active_loop_mode:
2033 WIN_TINY dm_active_sp_label_col, dm_active_dil_row+.3
2034 FONT_COLOR_MEMO ; set memo color
2035 btfsc FLAG_ccr_mode ; in CCR mode?
2036 bra TFT_active_loop_mode_ccr ; YES - print CCR label
2037 btfsc FLAG_pscr_mode ; in pSCR mode?
2038 bra TFT_active_loop_mode_pscr ; YES - print pSCR label
2039 bra TFT_active_diluent ; NO to both - should not happen
2040
2041 TFT_active_loop_mode_ccr:
2042 STRCPY_TEXT_PRINT tDvCCR ; print "CCR"
2043 bra TFT_active_diluent ; continue with diluent
2044
2045 TFT_active_loop_mode_pscr:
2046 STRCPY_TEXT_PRINT tDvPSCR ; print "pSCR"
2047 ;bra TFT_active_diluent ; continue with diluent
2048
2049 TFT_active_diluent:
2050 MOVII int_O_pure_ppO2,mpr ; get ppO2 [cbar] into hi:lo
2051 call TFT_color_code_ppo2 ; color-code the output
2052 btfss better_dil_available ; better diluent available?
2053 bra TFT_active_diluent_show ; NO - print in normal rendering
2054 btg better_dil_blinking ; YES - toggle blink bit...
2055 btfss better_dil_blinking ; - blink now?
2056 bra TFT_active_diluent_show ; NO - print in normal rendering
2057 FONT_COLOR_ATTENTION ; YES - print in attention color
2058 bsf win_invert ; - print in inverse
2059
2060 TFT_active_diluent_show:
2061 WIN_SMALL dm_active_dil_column, dm_active_dil_row
2062 bra TFT_active_dil_gas_common ; continue with common part
2063
2064 ENDIF ; _ccr_pscr
2065
2066 TFT_active_gas:
2067 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] into hi:lo
2068 call TFT_color_code_ppo2 ; color-code the output
2069 btfss better_gas_available ; better gas available?
2070 bra TFT_active_gas_print ; NO - print in normal rendering
2071 btg better_gas_blinking ; YES - toggle blink bit
2072 btfss better_gas_blinking ; blink now?
2073 bra TFT_active_gas_print ; NO - print in normal rendering
2074 FONT_COLOR_ATTENTION ; YES - blink in attention color
2075 bsf win_invert ; print in inverse
2076
2077 TFT_active_gas_print:
2078 WIN_STD dm_active_gas_sp_value_col, dm_active_sp_label_row
2079
2080 TFT_active_dil_gas_common:
2081 movff char_I_O2_ratio,lo ; lo now stores O2 in %
2082 IFDEF _helium
2083 movff char_I_He_ratio,hi ; hi now stores He in %
2084 ELSE
2085 clrf hi ; set hi to zero (no He)
2086 ENDIF
2087 call gaslist_strcat_mix ; print "Nxlo", "Txlo/hi", "Air" or "O2"
2088 PRINT ; dump to screen
2089 return ; done
2090
2091
2092 ;-----------------------------------------------------------------------------
2093 ; Dive Mode - NDL Time
2094 ;
2095 global TFT_show_ndl
2096 TFT_show_ndl:
2097 btfsc dive_main_menu ; is the dive mode menu shown?
2098 return ; YES - abort
2099 MOVII int_O_NDL_norm,mpr ; NO - get NDL time in normal plan
2100 rcall TFT_show_ndl_tts_set_color ; - set color
2101 btfsc deco_locked ; - was the dive in deco?
2102 bra TFT_show_ndl_norm ; YES - use normal layout
2103 btfsc alt_layout_active ; NO - alternative layout active?
2104 bra TFT_show_ndl_alt ; YES - use alternative layout
2105 ;bra TFT_show_ndl_norm ; NO - use normal layout
2106
2107 TFT_show_ndl_norm:
2108 WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm
2109 output_256 ; print NDL (0-255)
2110 PUTC_PRINT "'" ; append unit and dump buffer to screen
2111 return ; done
2112
2113 TFT_show_ndl_alt:
2114 btfsc safety_stop_active ; is the safety stop active?
2115 bra TFT_show_ndl_alt_safety ; YES
2116 ;bra TFT_show_ndl_alt_no_safety ; NO
2117
2118 TFT_show_ndl_alt_no_safety: ; clear potential remains from NDL normal
2119 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
2120 WIN_LARGE dm_ndl_value_col_alt, dm_ndl_value_row_alt
2121 output_99 ; print NDL (0-99)
2122 PRINT ; dump buffer to screen
2123 return ; done
2124
2125 TFT_show_ndl_alt_safety:
2126 WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm
2127 output_256 ; print NDL (0-255)
2128 PUTC_PRINT "'" ; append unit and dump buffer to screen
2129 return ; done
2130
2131
2132 ; Helper Function - set color
2133 TFT_show_ndl_tts_set_color:
2134 movf pallet_color_memo,W ; load memo color as default
2135 btfsc mpr+1,int_invalid_flag ; is the invalid flag set?
2136 movf pallet_color_disabled,W ; YES - replace by disabled color
2137 movwf font_color ; set font color
2138 return ; done
2139
2140
2141 ;-----------------------------------------------------------------------------
2142 ; Dive Mode - TTS Time
2143 ;
2144 global TFT_show_tts
2145 TFT_show_tts:
2146 btfsc dive_main_menu ; is the dive mode menu shown?
2147 return ; YES - abort
2148 MOVII int_O_TTS_norm,mpr ; NO - get the TTS
2149 rcall TFT_show_ndl_tts_set_color ; - color-code
2150 bcf hi,int_invalid_flag ; - clear the invalid flag if applicable
2151 btfsc alt_layout_active ; - in alternative layout?
2152 bra TFT_display_tts_alt ; YES
2153 ;bra TFT_display_tts_norm ; NO
2154
2155 TFT_display_tts_norm:
2156 WIN_MEDIUM dm_tts_value_col_999x, dm_tts_value_row
2157 output_999 ; print (0...999)
2158 PUTC_PRINT "'" ; append unit and dump buffer to screen
2159 return ; done
2160
2161 TFT_display_tts_alt:
2162 output_99 ; print TTS for range 0-99
2163 btfsc output_overflow ; does TTS fit into 0-99 ?
2164 bra TFT_display_tts_alt_999 ; NO - print in 999 format
2165 ;bra TFT_display_tts_alt_99 ; YES - print in 99 format
2166
2167 TFT_display_tts_alt_99:
2168 btfsc tts_over_99_last ; was TTS > 99 last time?
2169 rcall TFT_display_tts_clear ; YES - clear remains from TTS > 99
2170 WIN_MEDIUM dm_tts_value_col_99, dm_tts_value_row
2171 output_99 ; print TTS (0...99)
2172 PUTC_PRINT "'" ; append unit and dump buffer to screen
2173 return ; done
2174
2175 TFT_display_tts_alt_999:
2176 WIN_MEDIUM dm_tts_value_col_999, dm_tts_value_row
2177 REINIT_BUFFER ; clear the buffer
2178 output_999 ; print (0...999), no space for unit
2179 PRINT ; dump to screen
2180 bsf tts_over_99_last ; remember last TTS was > 99 mins
2181 return ; done
2182
2183
2184 ; Helper Function - clear remains from TTS > 99
2185 TFT_display_tts_clear: ; clear remains from TTS > 99
2186 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
2187 bcf tts_over_99_last ; remember last TTS was NOT > 99 mins
2188 return ; done
2189
2190
2191 ;-----------------------------------------------------------------------------
2192 ; Dive Mode - Deco Stop Time & Depth
2193 ;
2194 global TFT_show_deco
2195 TFT_show_deco:
2196 btfsc dive_main_menu ; is the dive mode menu shown?
2197 return ; YES - abort
2198
2199 movff char_O_deco_depth,lo ; get depth of first stop in meters
2200 call TFT_color_code_stop ; color-code output
2201 TSTOSC opt_units ; get unit (0=m, 1=ft)
2202 bra TFT_show_deco_norm ; 1 - ft can only be displayed in normal layout due to space required for 3 digit depth
2203 btfsc alt_layout_active ; 0 - in alternative layout?
2204 bra TFT_show_deco_alt ; YES
2205 ;bra TFT_show_deco_norm ; NO - combined depth and time
2206
2207 TFT_show_deco_norm:
2208 WIN_MEDIUM dm_decostop_col_norm, dm_decostop_row_norm
2209 call TFT_display_stop_depth ; print stop (depth in lo)
2210 PUTC ' ' ; put a space char between depth and time
2211 bra TFT_display_deco_common ; continue with common part
2212
2213 TFT_show_deco_alt:
2214 WIN_LARGE dm_decostop_col_alt_depth, dm_decostop_row_alt_depth
2215 output_99 ; print stop depth (0-99)
2216 PRINT ; dump buffer to screen
2217 WIN_MEDIUM dm_decostop_col_alt_time, dm_decostop_row_alt_time
2218 FONT_COLOR_MEMO ; select memo color
2219 ;bra TFT_display_deco_common ; continue with common part
2220
2221 TFT_display_deco_common:
2222 movff char_O_deco_time,lo ; get stop time of the first stop in minutes
2223 output_99DD ; print minutes or double dots if null
2224 PUTC_PRINT "'" ; append unit and dump buffer to screen
2225 return ; done
2226
2227
2228 ;=============================================================================
2229 tft_out7 CODE
2230 ;=============================================================================
2231
2232 ;-----------------------------------------------------------------------------
2233 ; Dive Mode - Apnoe current and overall Dive Time
2234 ;
2235 global TFT_show_apnoe_times
2236 TFT_show_apnoe_times:
2237 ; current dive time
2238 FONT_COLOR_MEMO ; select color
2239 WIN_MEDIUM dm_divetime_apnoe_col, dm_divetime_apnoe_row
2240 SMOVII apnoe_dive_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi
2241 output_99 ; print minutes (0-99)
2242 PRINT ; dump to screen
2243 WIN_SMALL dm_divetime_apnoe_secs_col, dm_divetime_apnoe_secs_row
2244 PUTC ':' ; print ":"
2245 movff hi,lo ; copy seconds to lo
2246 output_99x ; print seconds (00-99)
2247 PRINT ; dump to screen
2248 ; overall dive time
2249 WIN_MEDIUM dm_apnoe_total_divetime_col, dm_apnoe_total_divetime_row
2250 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 and seconds
2251 output_256 ; minutes (0-256)
2252 PRINT ; show minutes in large font
2253 WIN_SMALL dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row ; left position for two sec figures
2254 PUTC ':' ; print ":"
2255 movff up,lo ; copy seconds from up to lo
2256 output_99x ; print seconds (00-99)
2257 PRINT ; dump to screen
2258 return ; done
2259
2260
2261 ;-----------------------------------------------------------------------------
2262 ; Dive Mode - show Apnoe Surface Time
2263 ;
2264 global TFT_show_apnoe_surface
2265 TFT_show_apnoe_surface:
2266 FONT_COLOR_MASK ; select mask color
2267 WIN_TINY dm_apnoe_surface_time_text_col, dm_apnoe_surface_time_text_row
2268 STRCPY_TEXT_PRINT tApnoeSurface ; print label
2269 FONT_COLOR_MEMO ; select memo color
2270 WIN_MEDIUM dm_apnoe_surface_time_column, dm_apnoe_surface_time_row
2271 SMOVII apnoe_surface_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi
2272 output_256 ; print minutes (0-255)
2273 PUTC ':' ; print ":"
2274 movff hi,lo ; copy seconds to lo
2275 output_99x ; print seconds (00-99)
2276 PRINT ; dump to screen
2277 return ; done
2278
2279
2280 ;-----------------------------------------------------------------------------
2281 ; Dive Mode - clear Apnoe Surface Time
2282 ;
2283 global TFT_clear_apnoe_surface
2284 TFT_clear_apnoe_surface:
2285 WIN_BOX_BLACK dm_apnoe_last_max_depth_text_row, .239, dm_apnoe_last_max_depth_column, .159
2286 return ; done
2287
2288
2289 ;=============================================================================
2290 tft_out8 CODE
2291 ;=============================================================================
2292
2293
2294 ;-----------------------------------------------------------------------------
2295 ; Dive Mode - clear Deco Data (NDL / Stop & TTS )
2296 ;
2297 global TFT_clear_deco_data
2298 TFT_clear_deco_data:
2299 btfsc dive_main_menu ; is the dive mode menu shown?
2300 return ; YES
2301
2302 WIN_BOX_BLACK dm_decostop_row_alt_depth, dm_3rdrow_bot, dm_decostop_col_alt_depth, dm_3rdrow_rgt ; top, bottom, left, right
2303 return
2304
2305
2306 ;-----------------------------------------------------------------------------
2307 ; Dive Mode - clear Dive Mode Menu
2308 ;
2309 ; starts 2 pixel higher to completely wipe away the temperature display
2310 ;
2311 global TFT_clear_divemode_menu
2312 TFT_clear_divemode_menu:
2313 WIN_BOX_BLACK dm_menu_row-.2, dm_menu_lower, dm_menu_left, dm_menu_right
2314 return
2315
2316
2317 ;=============================================================================
2318 VSI_table CODE_PACK
2319 ;=============================================================================
2320
2321 VSI_table:
2322
686 ; use a depth-dependent ascent rate warning 2323 ; use a depth-dependent ascent rate warning
687 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164 2324 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164
688 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66 2325 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66
689 ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50 2326 ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50
690 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning) 2327 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning)
691 ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention) 2328 ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention)
692 2329
693 ; < depth (m), warning speed, attention speed, unused 2330 ; < depth (m), warning speed, attention speed
694 DB .6,.7,.5,.0 2331 DB .6, .7, .5
695 DB .12,.8,.6,.0 2332 DB .12, .8, .6
696 DB .18,.9,.7,.0 2333 DB .18, .9, .7
697 DB .23,.10,.8,.0 2334 DB .23,.10, .8
698 DB .27,.11,.8,.0 2335 DB .27,.11, .8
699 DB .31,.13,.10,.0 2336 DB .31,.13,.10
700 DB .35,.15,.12,.0 2337 DB .35,.15,.12
701 DB .39,.17,.13,.0 2338 DB .39,.17,.13
702 DB .44,.18,.14,.0 2339 DB .44,.18,.14
703 DB .50,.19,.15,.0 2340 DB .50,.19,.15
704 DB .200,.20,.15,.0 2341 DB .255,.20,.15
705 2342
706 TFT_velocity_set_color: ; set color based on speed table or use static thresholds, with divA+0 = m/min 2343
707 bsf aux_flag ; for alternative layout: default is to show numerical VSI 2344 ;=============================================================================
708 ; check if old/new ascend logic is used 2345 tft_out9 CODE
709 TSTOSS opt_vsitext ; 0=standard, 1=dynamic 2346 ;=============================================================================
710 bra TFT_velocity_set_color_static ; static ascend rate limit 2347
711 2348
712 ; point to speed table 2349 ;-----------------------------------------------------------------------------
713 movlw LOW (TFT_speed_table-.3) 2350 ; Dive Mode - show vertical Velocity
714 movwf TBLPTRL 2351 ;
715 movlw HIGH (TFT_speed_table-.3) 2352 global TFT_velocity_show
716 movwf TBLPTRH 2353 TFT_velocity_show:
717 movlw UPPER (TFT_speed_table-.3) 2354 FONT_COLOR_MEMO ; set default color
718 movwf TBLPTRU 2355 btfsc neg_flag_velocity ; descending?
719 2356 rcall TFT_velocity_set_color ; NO - set color for text dependent on speed and set threshold for VSI graph
720 TFT_velocity_set_color_next: 2357 rcall TFT_velocity_num ; show the numerical VSI
721 TBLRD*+ ; 3 dummy reads 2358 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
722 TBLRD*+ 2359 return ; NO - done
723 TBLRD*+ 2360 btfss neg_flag_velocity ; YES - in ascent?
724 TBLRD*+ ; get speed threshold 2361 bra TFT_velocity_clear_graph ; NO - clear the graph
725 movf depth_meter,W ; current depth in m 2362 ;bra TFT_velocity_graph_show ; YES - show the graph
726 cpfsgt TABLAT ; threshold > current depth ? 2363
727 bra TFT_velocity_set_color_next ; NO - try next 2364 TFT_velocity_graph_show:
728 2365 btfsc alt_layout_active ; in alternative layout?
729 TBLRD*+ ; get warning speed threshold 2366 return ; YES - done (not implemented)
730 movf TABLAT,W ; ... 2367
731 movwf divA+1 ; copy for graph routine 2368 btfsc velocity_active_vsi ; was the graphical VSI shown before?
732 cpfslt divA+0 ; actual vertical speed smaller than warning threshold? 2369 bra TFT_velocity_graph_1 ; YES - no need to redraw the framework box
733 bra TFT_warning_color ; NO - set warning color (and return) 2370 bsf velocity_active_vsi ; NO - remember it is shown as of now
734 TBLRD*+ ; get attention speed threshold 2371 ; - draw the framework box
735 movf TABLAT,W ; ... 2372 movf pallet_color_mask,W ; - color -> WREG
736 cpfslt divA+0 ; actual vertical speed smaller than attention threshold?
737 bra TFT_attention_color ; NO - set attention color and return
738 bcf aux_flag ; YES - don't show in alternative layout
739 bra TFT_memo_color ; - set memo color and return
740
741 TFT_velocity_set_color_static:
742 movlw color_code_velocity_warn_high ; threshold for warning in m/min
743 movwf divA+1 ; copy for graph routine
744 cpfslt divA+0 ; actual vertical speed smaller than warning threshold?
745 bra TFT_warning_color ; NO - set warning color (and return)
746 movlw color_code_velocity_attn_high ; threshold for attention in m/min
747 cpfslt divA+0 ; actual vertical speed smaller than attention threshold?
748 bra TFT_attention_color ; NO - set attention color and return
749 bcf aux_flag ; YES - don't show in alternative layout
750 bra TFT_memo_color ; - set memo color and return
751
752 TFT_velocity_num:
753 btfsc alt_layout_active ; in alternative layout?
754 bra TFT_velocity_num_alt ; YES
755 ; NO - set position
756 WIN_SMALL dm_velocity_text_col_norm, dm_velocity_text_row_norm
757 TFT_velocity_num_com:
758 bsf velocity_active_num ; set numerical velocity as shown
759 TSTOSS opt_units ; - 0=meter, 1=feet
760 bra TFT_velocity_num_metric ; 0 - meter
761 ;bra TFT_velocity_num_imperial ; 1 - feet
762
763 TFT_velocity_num_imperial:
764 movff divA+0,WREG ; divA+0 = m/min
765 mullw .100 ; PROD = mbar/min
766 MOVII PRODL,mpr ; copy to hi:lo
767 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
768 tstfsz hi ; > 255 ?
769 setf lo ; YES - set lo to 255
770 movlw '-' ; load coding for minus sign
771 btfsc neg_flag_velocity ; ascending?
772 movlw '+' ; YES - replace with coding for plus sign
773 movwf POSTINC2 ; put sign into output buffer
774 output_99 ; print rate
775 STRCAT_TEXT tVelImperial ; print unit
776 bra TFT_velocity_num_finish ; do finishing tasks
777
778 TFT_velocity_num_metric:
779 movff divA+0,lo ; divA+0 = m/min
780 movlw '-' ; load coding for minus sign
781 btfsc neg_flag_velocity ; ascending?
782 movlw '+' ; YES - replace with coding for plus sign
783 movwf POSTINC2 ; put sign into output buffer
784 output_99 ; print rate
785 STRCAT_TEXT tVelMetric ; print unit
786 ;bra TFT_velocity_num_finish ; do finishing tasks
787
788 TFT_velocity_num_finish:
789 btfss alt_layout_active ; in alternative layout?
790 bra TFT_velocity_num_finish_1 ; NO
791 movlw "'" ; load encoding of minute sign
792 movff WREG,buffer+4 ; put it after m (meter) / f (feet)
793 clrf WREG ; load string terminator
794 movff WREG,buffer+5 ; terminate string after minute sign
795 TFT_velocity_num_finish_1:
796 STRCAT_PRINT "" ; finalize output
797 bcf win_invert ; end inverse printing
798 return ; done
799
800 TFT_velocity_num_alt:
801 btfsc dive_main_menu ; is the dive mode menu shown?
802 return ; YES - abort
803 btfss neg_flag_velocity ; NO - in ascent?
804 bcf aux_flag ; NO - clear aux flag
805 btfsc aux_flag ; - above attention or warning threshold?
806 bsf win_invert ; YES - print inverse
807 ; - set position
808 WIN_SMALL dm_velocity_text_col_alt, dm_velocity_text_row_alt
809 bra TFT_velocity_num_com ; - continue with common part
810
811
812 TFT_velocity_graph_show: ; with speed in divA+0 (m/min)
813 btfsc alt_layout_active ; in alternative layout?
814 bra TFT_standard_color ; YES - done (not implemented)
815
816 btfsc velocity_active_vsi ; was the graphical VSI shown before?
817 bra TFT_velocity_graph_1 ; YES - no need to redraw the framework box
818 bsf velocity_active_vsi ; NO - remember it is shown as of now
819 ; - draw the framework box
820 rcall TFT_divemask_color_dive ; - color -> WREG
821 WIN_FRAME_COLOR dm_velocity_graph_top+.00, dm_velocity_graph_bot-.00, dm_velocity_graph_lft, dm_velocity_graph_rgt 2373 WIN_FRAME_COLOR dm_velocity_graph_top+.00, dm_velocity_graph_bot-.00, dm_velocity_graph_lft, dm_velocity_graph_rgt
822 rcall TFT_divemask_color_dive ; - color -> WREG 2374 movf pallet_color_mask,W ; - color -> WREG
823 WIN_FRAME_COLOR dm_velocity_graph_top+.10, dm_velocity_graph_bot-.10, dm_velocity_graph_lft, dm_velocity_graph_rgt 2375 WIN_FRAME_COLOR dm_velocity_graph_top+.10, dm_velocity_graph_bot-.10, dm_velocity_graph_lft, dm_velocity_graph_rgt
824 rcall TFT_divemask_color_dive ; - color -> WREG 2376 movf pallet_color_mask,W ; - color -> WREG
825 WIN_FRAME_COLOR dm_velocity_graph_top+.20, dm_velocity_graph_bot-.20, dm_velocity_graph_lft, dm_velocity_graph_rgt 2377 WIN_FRAME_COLOR dm_velocity_graph_top+.20, dm_velocity_graph_bot-.20, dm_velocity_graph_lft, dm_velocity_graph_rgt
826 rcall TFT_divemask_color_dive ; - color -> WREG 2378 movf pallet_color_mask,W ; - color -> WREG
827 WIN_FRAME_COLOR dm_velocity_graph_top+.30, dm_velocity_graph_bot-.30, dm_velocity_graph_lft, dm_velocity_graph_rgt 2379 WIN_FRAME_COLOR dm_velocity_graph_top+.30, dm_velocity_graph_bot-.30, dm_velocity_graph_lft, dm_velocity_graph_rgt
828 2380
829 TFT_velocity_graph_1: 2381 TFT_velocity_graph_1:
830 movff divA+0,hi ; copy ascend speed (in m/min) to hi 2382 movff divA+0,hi ; copy ascend speed (in m/min) to hi
831 movff divA+1,xA+0 ; m/min for warning level (upper two blocks) 2383 movff divA+1,xA+0 ; m/min for warning level (upper two blocks)
832 clrf xA+1 2384 clrf xA+1
833 MOVLI .5,xB ; threshold for color warning (5 color normal + 2 color warning) 2385 MOVLI .5,xB ; threshold for color warning (5 color normal + 2 color warning)
834 call div16x16 ; xC = xA / xB with xA as remainder 2386 call div16x16 ; xC = xA / xB with xA as remainder
835 ; xC+0 holds step size in m/min (e.g. =3 for 15m/min warning threshold) 2387 ; xC+0 holds step size in m/min (e.g. =3 for 15m/min warning threshold)
836 movff hi,xA+0 ; velocity in m/min 2388 movff hi,xA+0 ; velocity in m/min
837 clrf xA+1 2389 clrf xA+1 ; ...
838 movff xC+0,xB+0 ; step size 2390 movff xC+0,xB+0 ; step size
839 clrf xB+1 2391 clrf xB+1 ; ...
840 call div16x16 ; xC = xA / xB with xA as remainder 2392 call div16x16 ; xC = xA / xB with xA as remainder
841 2393 movff xC+0,lo ; copy amount of segments to show to lo
842 movff xC+0,lo ; copy amount of segments to show to lo 2394 incf lo,F ; lo +=1
843 incf lo,F 2395 dcfsnz lo,F ; lo = 1 ?
844 dcfsnz lo,F 2396 bra DISP_graph_vel_0_fill ; YES - fill lowest segment
845 bra DISP_graph_vel_0_fill 2397 dcfsnz lo,F ; lo = 2 ?
846 dcfsnz lo,F 2398 bra DISP_graph_vel_1_fill ; YES - fill lower 2 segments
847 bra DISP_graph_vel_1_fill 2399 dcfsnz lo,F ; lo = 3 ?
848 dcfsnz lo,F 2400 bra DISP_graph_vel_2_fill ; YES - fill lower 3 segments
849 bra DISP_graph_vel_2_fill 2401 dcfsnz lo,F ; lo = 4 ?
850 dcfsnz lo,F 2402 bra DISP_graph_vel_3_fill ; YES - fill lower 4 segments
851 bra DISP_graph_vel_3_fill 2403 dcfsnz lo,F ; lo = 5 ?
852 dcfsnz lo,F 2404 bra DISP_graph_vel_4_fill ; YES - fill lower 5 segments
853 bra DISP_graph_vel_4_fill 2405 dcfsnz lo,F ; lo = 6 ?
854 dcfsnz lo,F 2406 bra DISP_graph_vel_5_fill ; YES - fill lower 6 segments
855 bra DISP_graph_vel_5_fill 2407 dcfsnz lo,F ; lo = 7 ?
856 dcfsnz lo,F 2408 bra DISP_graph_vel_6_fill ; YES - fill lower 7 segments
857 bra DISP_graph_vel_6_fill 2409 ;bra DISP_graph_vel_7_fill ; YES - fill all segments
858 ;bra DISP_graph_vel_7_fill
859 2410
860 DISP_graph_vel_7_fill: 2411 DISP_graph_vel_7_fill:
861 rcall TFT_warnings_color_dive ; color -> WREG 2412 movf pallet_color_warning,W
862 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 2413 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
863 DISP_graph_vel_6_fill: 2414 DISP_graph_vel_6_fill:
864 rcall TFT_warnings_color_dive ; color -> WREG 2415 movf pallet_color_warning,W
865 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 2416 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
866 DISP_graph_vel_5_fill: 2417 DISP_graph_vel_5_fill:
867 rcall TFT_attention_color_dive ; color -> WREG 2418 movf pallet_color_attention,W
868 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 2419 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
869 DISP_graph_vel_4_fill: 2420 DISP_graph_vel_4_fill:
870 rcall TFT_standard_color_dive ; color -> WREG 2421 movf pallet_color_memo,W
871 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 2422 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
872 DISP_graph_vel_3_fill: 2423 DISP_graph_vel_3_fill:
873 rcall TFT_standard_color_dive ; color -> WREG 2424 movf pallet_color_memo,W
874 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 2425 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
875 DISP_graph_vel_2_fill: 2426 DISP_graph_vel_2_fill:
876 rcall TFT_standard_color_dive ; color -> WREG 2427 movf pallet_color_memo,W
877 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 2428 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
878 DISP_graph_vel_1_fill: 2429 DISP_graph_vel_1_fill:
879 rcall TFT_standard_color_dive ; color -> WREG 2430 movf pallet_color_memo,W
880 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 2431 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
881 DISP_graph_vel_0_fill: 2432 DISP_graph_vel_0_fill:
882 2433
883 movff xC+0,lo ; copy amount of segments to show to lo 2434 movff xC+0,lo ; copy amount of segments to show to lo
884 incf lo,F 2435 incf lo,F ; lo += 1
885 dcfsnz lo,F 2436 dcfsnz lo,F ; lo = 1 ?
886 bra DISP_graph_vel_0_clear 2437 bra DISP_graph_vel_0_clear ; YES - clear upper 7 segments
887 dcfsnz lo,F 2438 dcfsnz lo,F ; lo = 2 ?
888 bra DISP_graph_vel_1_clear 2439 bra DISP_graph_vel_1_clear ; YES - clear upper 6 segments
889 dcfsnz lo,F 2440 dcfsnz lo,F ; lo = 3 ?
890 bra DISP_graph_vel_2_clear 2441 bra DISP_graph_vel_2_clear ; YES - clear upper 5 segments
891 dcfsnz lo,F 2442 dcfsnz lo,F ; lo = 4 ?
892 bra DISP_graph_vel_3_clear 2443 bra DISP_graph_vel_3_clear ; YES - clear upper 4 segments
893 dcfsnz lo,F 2444 dcfsnz lo,F ; lo = 5 ?
894 bra DISP_graph_vel_4_clear 2445 bra DISP_graph_vel_4_clear ; YES - clear upper 3 segments
895 dcfsnz lo,F 2446 dcfsnz lo,F ; lo = 6 ?
896 bra DISP_graph_vel_5_clear 2447 bra DISP_graph_vel_5_clear ; YES - clear upper 2 segments
897 dcfsnz lo,F 2448 dcfsnz lo,F ; lo = 7 ?
898 bra DISP_graph_vel_6_clear 2449 bra DISP_graph_vel_6_clear ; YES - clear upper 1 segments
899 bra DISP_graph_vel_7_clear 2450 bra DISP_graph_vel_7_clear ; YES - clear no segments
900 2451
901 DISP_graph_vel_0_clear: 2452 DISP_graph_vel_0_clear:
902 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 2453 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
903 DISP_graph_vel_1_clear: 2454 DISP_graph_vel_1_clear:
904 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 2455 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
911 DISP_graph_vel_5_clear: 2462 DISP_graph_vel_5_clear:
912 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 2463 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
913 DISP_graph_vel_6_clear: 2464 DISP_graph_vel_6_clear:
914 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 2465 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
915 DISP_graph_vel_7_clear: 2466 DISP_graph_vel_7_clear:
916 bra TFT_standard_color ; done 2467 return ; done
917 2468
918 2469
2470 ; Helper Function - set color based on speed table or use static thresholds, with divA+0 = m/min
2471 TFT_velocity_set_color:
2472 bsf aux_flag ; for alternative layout: default is to show numerical VSI
2473 ; check if old/new ascend logic is used
2474 TSTOSS opt_vsitext ; 0=standard, 1=dynamic
2475 bra TFT_velocity_set_color_static ; 0 - static ascend rate limit
2476 ;bra TFT_velocity_set_color_dynamic ; 1 - dynamic ascend rate limit
2477
2478 TFT_velocity_set_color_dynamic:
2479 movlw LOW (VSI_table-.2) ; point to 2 entries ahead of the speed table
2480 movwf TBLPTRL ; ...
2481 movlw HIGH (VSI_table-.2) ; ...
2482 movwf TBLPTRH ; ...
2483 movlw UPPER (VSI_table-.2) ; ...
2484 movwf TBLPTRU ; ...
2485 TFT_velocity_set_color_loop:
2486 TBLRD*+ ; consume waring speed form last round
2487 TBLRD*+ ; consume attention speed form last round
2488 TBLRD*+ ; get table depth
2489 movf depth_meter,W ; get current depth
2490 cpfsgt TABLAT ; table depth > current depth ?
2491 bra TFT_velocity_set_color_loop ; NO - try next
2492 TBLRD*+ ; YES - read warning speed threshold
2493 movf TABLAT,W ; - ...
2494 movwf divA+1 ; - copy to graph routine
2495 cpfslt divA+0 ; - actual vertical speed smaller than warning threshold?
2496 bra TFT_velocity_set_color_warn ; NO - set warning color and return
2497 TBLRD*+ ; YES - read attention speed threshold
2498 movf TABLAT,W ; - ...
2499 cpfslt divA+0 ; - actual vertical speed smaller than attention threshold?
2500 bra TFT_velocity_set_color_attn ; NO - set attention color and return
2501 bcf aux_flag ; YES - don't show in alternative layout
2502 bra TFT_velocity_set_color_memo ; - set memo color and return
2503
2504 TFT_velocity_set_color_static:
2505 movlw color_code_velocity_warn_high ; get static threshold for warning in m/min
2506 movwf divA+1 ; copy for graph routine
2507 cpfslt divA+0 ; actual vertical speed smaller than warning threshold?
2508 bra TFT_velocity_set_color_warn ; NO - set warning color and return
2509 movlw color_code_velocity_attn_high ; YES - get static threshold for attention in m/min
2510 cpfslt divA+0 ; - actual vertical speed smaller than attention threshold?
2511 bra TFT_velocity_set_color_attn ; NO - set attention color and return
2512 bcf aux_flag ; YES - don't show in alternative layout
2513 ;bra TFT_velocity_set_color_memo ; - set memo color and return
2514
2515
2516 ; Helper Function - select color
2517 TFT_velocity_set_color_memo:
2518 FONT_COLOR_MEMO ; select memo color
2519 return ; done
2520
2521 TFT_velocity_set_color_attn:
2522 FONT_COLOR_ATTENTION ; select attention color
2523 return ; done
2524
2525 TFT_velocity_set_color_warn:
2526 FONT_COLOR_WARNING ; select warning color
2527 return ; done
2528
2529
2530 ; Helper Function - show the numerical VSI
2531 TFT_velocity_num:
2532 btfsc alt_layout_active ; in alternative layout?
2533 bra TFT_velocity_num_alt ; YES
2534 ;bra TFT_velocity_num_norm ; NO
2535
2536 TFT_velocity_num_norm:
2537 WIN_SMALL dm_velocity_text_col_norm, dm_velocity_text_row_norm
2538 bra TFT_velocity_num_com ; continue with common part
2539
2540 TFT_velocity_num_alt:
2541 btfsc dive_main_menu ; is the dive mode menu shown?
2542 return ; YES - abort
2543 btfss neg_flag_velocity ; NO - in ascent?
2544 bcf aux_flag ; NO - clear aux flag
2545 btfsc aux_flag ; - above attention or warning threshold?
2546 bsf win_invert ; YES - print inverse
2547 WIN_SMALL dm_velocity_text_col_alt, dm_velocity_text_row_alt
2548 ;bra TFT_velocity_num_com ; - continue with common part
2549
2550 TFT_velocity_num_com:
2551 bsf velocity_active_num ; set numerical velocity as shown
2552 TSTOSS opt_units ; 0=meter, 1=feet
2553 bra TFT_velocity_num_metric ; 0 - meter
2554 ;bra TFT_velocity_num_imperial ; 1 - feet
2555
2556 TFT_velocity_num_imperial:
2557 movff divA+0,WREG ; divA+0 = m/min
2558 mullw .100 ; PROD = mbar/min
2559 MOVII PRODL,mpr ; copy to hi:lo
2560 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
2561 tstfsz hi ; > 255 ?
2562 setf lo ; YES - set lo to 255
2563 rcall TFT_velocity_num_helper ; print vertical speed
2564 STRCAT_TEXT tVelImperial ; print unit
2565 bra TFT_velocity_num_finish ; do finishing tasks
2566
2567 TFT_velocity_num_metric:
2568 movff divA+0,lo ; divA+0 = m/min
2569 rcall TFT_velocity_num_helper ; print vertical speed
2570 STRCAT_TEXT tVelMetric ; print unit
2571 ;bra TFT_velocity_num_finish ; do finishing tasks
2572
2573 TFT_velocity_num_finish:
2574 btfss alt_layout_active ; in alternative layout?
2575 bra TFT_velocity_num_finish_1 ; NO
2576 movlw "'" ; load encoding of minute sign
2577 movff WREG,buffer+4 ; put it after m (meter) / f (feet)
2578 clrf WREG ; load string terminator
2579 movff WREG,buffer+5 ; terminate string after minute sign
2580 TFT_velocity_num_finish_1:
2581 PRINT ; dump to screen
2582 return ; done
2583
2584
2585 ; Helper Function - print vertical speed
2586 TFT_velocity_num_helper:
2587 movlw '-' ; load coding for minus sign
2588 btfsc neg_flag_velocity ; ascending?
2589 movlw '+' ; YES - replace with coding for plus sign
2590 movwf POSTINC2 ; put sign into output buffer
2591 output_99 ; print rate (0-99)
2592 return ; done
2593
2594
2595 ;-----------------------------------------------------------------------------
2596 ; Dive Mode - clear vertical Velocity
2597 ;
919 global TFT_velocity_clear 2598 global TFT_velocity_clear
920 TFT_velocity_clear: 2599 TFT_velocity_clear:
921 btfss velocity_active_num ; was the numerical VSI shown in last cycle? 2600 btfss velocity_active_num ; was the numerical VSI shown in last cycle?
922 bra TFT_velocity_clear_graph ; NO - no need to clear it, continue with graphical VSI 2601 bra TFT_velocity_check_graph ; NO - no need to clear it, continue with graphical VSI
923 TFT_velocity_clear_num_1: 2602 ;bra TFT_velocity_clear_num ; YES
924 bcf velocity_active_num ; YES - clear flag 2603
925 btfsc alt_layout_active ; - in alternative layout? 2604 TFT_velocity_clear_num:
926 bra TFT_velocity_clear_num_alt ; YES 2605 bcf velocity_active_num ; clear flag
927 ;bra TFT_velocity_clear_num_norm ; NO 2606 btfsc alt_layout_active ; in alternative layout?
2607 bra TFT_velocity_clear_num_alt ; YES
2608 ;bra TFT_velocity_clear_num_norm ; NO
928 2609
929 TFT_velocity_clear_num_norm: ; clear normal numerical area 2610 TFT_velocity_clear_num_norm: ; clear normal numerical area
930 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 2611 WIN_BOX_BLACK dm_velocity_text_row_norm, dm_velocity_text_bot_norm, dm_velocity_text_col_norm, dm_velocity_text_rgt_norm
931 bra TFT_velocity_clear_graph ; continue with graphical VSI 2612 bra TFT_velocity_check_graph ; continue with graphical VSI
932 2613
933 TFT_velocity_clear_num_alt: ; clear alternative numerical area 2614 TFT_velocity_clear_num_alt: ; clear alternative numerical area
934 btfsc dive_main_menu ; is the dive mode menu shown? 2615 btfsc dive_main_menu ; is the dive mode menu shown?
935 bra TFT_velocity_clear_graph ; YES - skip 2616 bra TFT_velocity_check_graph ; YES - skip
936 ; NO - clear area 2617 WIN_BOX_BLACK dm_velocity_text_row_alt, dm_velocity_text_bot_alt, dm_velocity_text_col_alt, dm_velocity_text_rgt_alt
937 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 2618 ;bra TFT_velocity_check_graph ; continue with graphical VSI
938 ;bra TFT_velocity_clear_graph ; continue with graphical VSI 2619
2620 TFT_velocity_check_graph:
2621 btfss velocity_active_vsi ; was the graphical VSI shown in last cycle?
2622 return ; NO - no need to clear it, done
2623 ;bra TFT_velocity_clear_graph ; YES - clear it
939 2624
940 TFT_velocity_clear_graph: 2625 TFT_velocity_clear_graph:
941 btfss velocity_active_vsi ; was the graphical VSI shown in last cycle? 2626 bcf velocity_active_vsi ; clear flag
942 bra TFT_standard_color ; NO - no need to clear it, done 2627 btfsc alt_layout_active ; in alternative layout?
943 TFT_velocity_graph_clear_1: 2628 return ; YES - done (not implemented)
944 bcf velocity_active_vsi ; YES - clear flag 2629 WIN_BOX_BLACK dm_velocity_graph_top, dm_velocity_graph_bot, dm_velocity_graph_lft, dm_velocity_graph_rgt
945 btfsc alt_layout_active ; - in alternative layout? 2630 return ; done
946 bra TFT_standard_color ; YES - not implemented 2631
947 ;bra TFT_velocity_clear_graph_alt ; YES - code provision for future implementation 2632
948 ;bra TFT_velocity_clear_graph_norm ; NO 2633 ;=============================================================================
949 2634 tft_out10 CODE
950 TFT_velocity_clear_graph_norm ; clear normal graph area 2635 ;=============================================================================
951 WIN_BOX_BLACK dm_velocity_graph_top, dm_velocity_graph_bot, dm_velocity_graph_lft, dm_velocity_graph_rgt ; top, bottom, left, right 2636
952 bra TFT_standard_color ; done 2637
953 2638 ;-----------------------------------------------------------------------------
954 ;========================================================================= 2639 ; Dive Mode - show Sign
955 2640 ;
956 global TFT_clear_divemode_menu
957 TFT_clear_divemode_menu:
958 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
959 return
960
961
962 global TFT_clear_deco_data
963 TFT_clear_deco_data:
964 btfsc dive_main_menu ; is the dive mode menu shown?
965 return ; YES - abort
966 ; NO - clear deco data area (alternative stop depth makes upper-left most corner)
967 WIN_BOX_BLACK dm_decostop_row_alt_depth, dm_3rdrow_bot, dm_decostop_col_alt_depth, dm_3rdrow_rgt ; top, bottom, left, right
968 return ; - done
969
970
971 global TFT_show_ndl_mask
972 TFT_show_ndl_mask:
973 btfsc dive_main_menu ; is the dive mode menu shown?
974 return ; YES - abort
975 call TFT_divemask_color ; NO - set text color
976 ; - set position
977 WIN_STD dm_ndl_text_column, dm_ndl_text_row
978 STRCPY_TEXT_PRINT tNDL ; - print "NDL"
979 btfss deco_region ; - was the dive within deco stops region?
980 bra TFT_standard_color ; NO - done
981 btfsc safety_stop_active ; YES - safety stop shown?
982 bra TFT_standard_color ; YES - done
983 TFT_show_slow_reminder:
984 call TFT_attention_color ; NO - set color
985 ; - set position
986 WIN_STD dm_safetystop_text_column+.5,dm_safetystop_text_row+.5
987 STRCPY_TEXT tSlow ; - print "SLOW" reminder
988 STRCAT_PRINT 0x94 ; - append an up-arrow
989 bra TFT_standard_color ; - done
990
991
992 global TFT_show_tts
993 TFT_show_tts:
994 btfsc dive_main_menu ; is the dive mode menu shown?
995 return ; YES - abort
996 call TFT_memo_color ; NO - default to memo color
997 MOVII int_O_TTS_norm,mpr ; - get the TTS
998 btfsc hi,int_invalid_flag ; - is the invalid flag set?
999 call TFT_disabled_color ; YES - use disabled color
1000 bcf hi,int_invalid_flag ; - clear the invalid flag if applicable
1001 btfss alt_layout_active ; - in alternative layout?
1002 bra TFT_display_tts_999x ; NO
1003 MOVII mpr, sub_a ; YES - copy TTS to sub_a
1004 MOVLI .100,sub_b ; - load 100 into sub_b
1005 call cmpU16 ; - sub_a - sub_b = TTS - 100
1006 btfss neg_flag ; - TTS >= 100 ?
1007 bra TFT_display_tts_999 ; YES
1008 ;bra TFT_display_tts_99 ; NO
1009
1010 TFT_display_tts_99:
1011 btfsc tts_greater_99 ; was TTS > 99 mins last time?
1012 rcall TFT_display_tts_clear ; YES - clear remains from TTS > 99
1013 ; set output position
1014 WIN_MEDIUM dm_tts_value_col_99, dm_tts_value_row
1015 output_99 ; display 0...99
1016 STRCAT_PRINT "'" ; print "'"
1017 bcf tts_greater_99 ; last TTS shown was <= 99 mins
1018 bra TFT_standard_color ; done
1019
1020 TFT_display_tts_999: ; set position
1021 WIN_MEDIUM dm_tts_value_col_999, dm_tts_value_row
1022 output_16_3 ; display 0...999
1023 STRCAT_PRINT "" ; finalize output (no "'" here - not enough space available)
1024 bsf tts_greater_99 ; last TTS shown was > 99 mins
1025 bra TFT_standard_color ; done
1026
1027 TFT_display_tts_999x: ; set position
1028 WIN_MEDIUM dm_tts_value_col_999x, dm_tts_value_row
1029 output_16_3 ; display 0...999
1030 STRCAT_PRINT "'" ; print "'"
1031 bra TFT_standard_color ; done
1032
1033 TFT_display_tts_clear: ; clear remains from TTS > 99
1034 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
1035 call TFT_memo_color ; restore default memo color
1036 movff int_O_TTS_norm+1,WREG ; get the high byte of the TTS
1037 btfsc WREG,int_invalid_flag ; is the invalid flag set?
1038 call TFT_disabled_color ; YES - restore disabled color
1039 return ; done
1040
1041
1042 global TFT_show_ndl
1043 TFT_show_ndl:
1044 btfsc dive_main_menu ; is the dive mode menu shown?
1045 return ; YES - abort
1046 movff int_O_NDL_norm+0,lo ; NO - get low byte of NDL time in normal plan
1047 btfsc deco_locked ; - was the dive in deco?
1048 bra TFT_show_ndl_norm ; YES - use normal layout
1049 btfsc alt_layout_active ; NO - alternative layout active?
1050 bra TFT_show_ndl_alt ; YES - use alternative layout
1051 ;bra TFT_show_ndl_norm ; NO - use normal layout
1052
1053 TFT_show_ndl_norm: ; set position
1054 WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm
1055 rcall TFT_show_ndl_set_color ; set color
1056 output_8 ; display 0...240
1057 TFT_show_ndl_exit_1:
1058 STRCAT_PRINT "'" ; print minutes symbol
1059 TFT_show_ndl_exit_2:
1060 goto TFT_standard_color ; done
1061
1062 TFT_show_ndl_alt:
1063 btfsc safety_stop_active ; is the safety stop active?
1064 bra TFT_show_ndl_alt_safety ; YES
1065 ; clear potential remains from NDL normal and set position
1066 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
1067 WIN_LARGE dm_ndl_value_col_alt, dm_ndl_value_row_alt
1068 rcall TFT_show_ndl_set_color ; set color
1069 output_99 ; display 0...99
1070 STRCAT_PRINT "" ; finalize output
1071 bra TFT_show_ndl_exit_2 ; done
1072
1073 TFT_show_ndl_alt_safety:
1074 WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm
1075 rcall TFT_show_ndl_set_color ; set color
1076 PUTC " " ; fill first digit position
1077 output_99 ; display 0...99
1078 bra TFT_show_ndl_exit_1 ; print minutes symbol and done
1079
1080 TFT_show_ndl_set_color:
1081 movff int_O_NDL_norm+1,lo ; get high byte of NDL time in normal plan
1082 btfss lo,int_invalid_flag ; is the invalid flag set?
1083 goto TFT_memo_color ; NO - select memo color and return
1084 goto TFT_disabled_color ; YES - select disabled color and return
1085
1086
1087 global TFT_divemode_sign_show 2641 global TFT_divemode_sign_show
1088 TFT_divemode_sign_show: 2642 TFT_divemode_sign_show:
1089 btfsc alt_layout_active ; alternative layout active? 2643 btfsc alt_layout_active ; alternative layout active?
1090 bra TFT_divemode_sign_show_alt ; YES 2644 bra TFT_divemode_sign_show_alt ; YES
1091 ;bra TFT_divemode_sign_show_norm ; NO 2645 ;bra TFT_divemode_sign_show_norm ; NO
1102 bra TFT_divemode_sign_show_alt_1; YES - no need to clear area again 2656 bra TFT_divemode_sign_show_alt_1; YES - no need to clear area again
1103 btfsc bailout_mode ; NO - in bailout? 2657 btfsc bailout_mode ; NO - in bailout?
1104 bra TFT_divemode_sign_show_alt_1; YES - no need to clear the area 2658 bra TFT_divemode_sign_show_alt_1; YES - no need to clear the area
1105 ; NO - clear area from "bar" label and loop mode if applicable 2659 ; NO - clear area from "bar" label and loop mode if applicable
1106 WIN_BOX_BLACK dm_active_dil_row, dm_3rdrow_bot, dm_active_sp_label_col, dm_sign_rgt_alt ; top, bottom, left, right 2660 WIN_BOX_BLACK dm_active_dil_row, dm_3rdrow_bot, dm_active_sp_label_col, dm_sign_rgt_alt ; top, bottom, left, right
2661
1107 TFT_divemode_sign_show_alt_1: 2662 TFT_divemode_sign_show_alt_1:
1108 WIN_TOP dm_sign_row_alt ; - set row position 2663 WIN_TOP dm_sign_row_alt ; - set row position
1109 WIN_LEFT dm_sign_col_alt ; - set column position 2664 WIN_LEFT dm_sign_col_alt ; - set column position
1110 ;bra TFT_divemode_sign_show_com ; - continue with common part 2665 ;bra TFT_divemode_sign_show_com ; - continue with common part
1111 2666
1112 TFT_divemode_sign_show_com: 2667 TFT_divemode_sign_show_com:
1113 bsf sign_shown ; flag that the advice/attention/warning sign is shown 2668 bsf sign_shown ; flag sign is shown
1114 btfsc message_warning ; do we have a warning? 2669 btfsc sign_warning ; shall show warning sign?
1115 bra TFT_divemode_sign_show_warn ; YES - show warning sign 2670 bra TFT_divemode_sign_show_warn ; YES - show warning sign
1116 btfsc message_attention ; NO - do we have an attention? 2671 btfsc sign_attention ; NO - shall show attention sign?
1117 bra TFT_divemode_sign_show_att ; YES - show attention sign 2672 bra TFT_divemode_sign_show_att ; YES - show attention sign
1118 btfsc message_advice ; NO - do we have an advice message? 2673 btfsc sign_advice ; NO - shall show advice sign?
1119 bra TFT_divemode_sign_show_adv ; YES - show advice sign 2674 bra TFT_divemode_sign_show_adv ; YES - show advice sign
1120 return ; NO - false alarm 2675 return ; NO - false alarm
1121
1122 2676
1123 TFT_divemode_sign_color_warn: ; custom colors table for dive_warning2 icon - warning 2677 TFT_divemode_sign_color_warn: ; custom colors table for dive_warning2 icon - warning
1124 db .4, 0 ; #colors, spare 2678 db .4, 0 ; #colors, spare
1125 dw 0x0000 ; color 0x00: outside black 2679 dw 0x0000 ; color 0x00: outside black
1126 dw 0xff80 ; color 0x01: triangle yellow 2680 dw 0xff80 ; color 0x01: triangle yellow
1147 TFT_WRITE_PROM_IMAGE_CUST_COLOR TFT_divemode_sign_color_adv ; set custom colors for advice 2701 TFT_WRITE_PROM_IMAGE_CUST_COLOR TFT_divemode_sign_color_adv ; set custom colors for advice
1148 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign 2702 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign
1149 return ; done 2703 return ; done
1150 2704
1151 2705
2706 ;-----------------------------------------------------------------------------
2707 ; Dive Mode - show Sign
2708 ;
1152 global TFT_divemode_sign_clear 2709 global TFT_divemode_sign_clear
1153 TFT_divemode_sign_clear: 2710 TFT_divemode_sign_clear:
1154 btfss sign_shown ; is the advice/attention/warning sign shown? 2711 btfss sign_shown ; is the advice/attention/warning sign shown?
1155 return ; NO - done 2712 return ; NO - done
1156 bcf sign_shown ; YES - clear advice/attention/warning sign area and its flag 2713 bcf sign_shown ; YES - clear flag
1157 btfsc alt_layout_active ; - alternative layout active? 2714 btfsc alt_layout_active ; - alternative layout active?
1158 bra TFT_divemode_sign_clear_alt ; - YES 2715 bra TFT_divemode_sign_clear_alt ; - YES
1159 ;bra TFT_divemode_sign_clear_norm; - NO 2716 ;bra TFT_divemode_sign_clear_norm; - NO
1160 2717
1161 TFT_divemode_sign_clear_norm: 2718 TFT_divemode_sign_clear_norm:
1162 WIN_BOX_BLACK dm_sign_row_norm, dm_sign_bot_norm, dm_sign_col_norm, dm_sign_rgt_norm ; top, bottom, left, right 2719 WIN_BOX_BLACK dm_sign_row_norm, dm_sign_bot_norm, dm_sign_col_norm, dm_sign_rgt_norm
1163 return ; done 2720 return ; done
1164 2721
1165 TFT_divemode_sign_clear_alt: 2722 TFT_divemode_sign_clear_alt:
1166 WIN_BOX_BLACK dm_sign_row_alt, dm_sign_bot_alt, dm_sign_col_alt, dm_sign_rgt_alt ; top, bottom, left, right 2723 WIN_BOX_BLACK dm_sign_row_alt, dm_sign_bot_alt, dm_sign_col_alt, dm_sign_rgt_alt
1167 return ; done 2724 return ; done
1168 2725
1169 2726
1170 global TFT_show_deco_mask 2727 ;=============================================================================
1171 TFT_show_deco_mask: 2728 tft_out11 CODE
1172 bcf safety_stop_active ; flag safety stop is not shown any more TODO: needed? 2729 ;=============================================================================
2730
2731
2732 ;-----------------------------------------------------------------------------
2733 ; Dive Mode - show Safety Stop
2734 ;
2735 global TFT_safety_stop_show
2736 TFT_safety_stop_show:
1173 btfsc dive_main_menu ; is the dive mode menu shown? 2737 btfsc dive_main_menu ; is the dive mode menu shown?
1174 return ; YES - abort 2738 return ; YES - abort
1175 btfsc alt_layout_active ; NO - in alternative layout? 2739 btfsc safety_stop_active ; NO - is the safety stop shown already?
1176 bra TFT_show_deco_mask_alt ; YES 2740 bra TFT_safety_stop_show_time ; YES - just update the time
1177 ;bra TFT_show_deco_mask_norm ; NO 2741 ; NO - clear area that may be polluted by alternative NDL
1178 2742 WIN_BOX_BLACK dm_safetystop_row, dm_tts_value_row, dm_ndl_value_col_alt, dm_safetystop_rgt ; top, bottom, left, right
1179 TFT_show_deco_mask_norm: 2743 bsf safety_stop_active ; - flag safety stop is shown now
1180 WIN_STD dm_tts_text_col_norm, dm_tts_text_row_norm ; set text position 2744 WIN_STD dm_safetystop_text_column, dm_safetystop_text_row
1181 bra TFT_show_deco_mask_common ; continue with common part 2745 FONT_COLOR_MASK ; - set color
1182 2746 STRCPY_PRINT "Stop " ; - print "Stop" with a trailing space to wipe away potential other remains
1183 TFT_show_deco_mask_alt: 2747
1184 WIN_TINY dm_tts_text_col_alt, dm_tts_text_row_alt ; set text position 2748 TFT_safety_stop_show_time:
1185 STRCPY "Stop/" ; print "Stop/" 2749 WIN_MEDIUM dm_safetystop_column, dm_safetystop_row
1186 ;bra TFT_show_deco_mask_common ; continue with common part 2750 FONT_COLOR_ATTENTION ; set color
1187 2751 movff safety_stop_countdown,lo ; get remaining time in seconds, low byte, from safety stop timer
1188 TFT_show_deco_mask_common: 2752 clrf hi ; set remaining time in seconds, high byte, to zero
1189 call TFT_divemask_color ; set text color 2753 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
1190 STRCAT_TEXT_PRINT tTTS ; print "TTS" 2754 movff lo,up ; save seconds in up
1191 bra TFT_display_exit_1 ; done 2755 movff hi,lo ; move minutes to lo
1192 2756 output_9 ; print minutes (0-9)
1193 2757 PUTC ':' ; print ":"
1194 TFT_display_deco_depth: ; output depth (stored in lo) to POSTINC2 with "m" or "ft" 2758 movff up,lo ; move seconds to lo
1195 TSTOSS opt_units ; get unit (0=m, 1=ft) 2759 output_99x ; print seconds (00-99)
1196 bra TFT_display_deco_depth_m ; 0 - meter 2760 PRINT ; dump buffer to screen
1197 ;bra TFT_display_deco_depth_ft ; 1 - feet 2761 return ; done
1198 2762
1199 TFT_display_deco_depth_ft: 2763
1200 call convert_meter_to_feet ; convert value in lo from meters to feet 2764 ;-----------------------------------------------------------------------------
1201 output_16_3 ; output stop depth (000-999) 2765 ; Dive Mode - clear Safety Stop
1202 return ; done 2766 ;
1203
1204 TFT_display_deco_depth_m:
1205 output_99 ; output stop depth
1206 STRCAT_TEXT tMeters ; print unit
1207 return ; done
1208
1209
1210 global TFT_show_deco
1211 TFT_show_deco:
1212 btfsc dive_main_menu ; is the dive mode menu shown?
1213 return ; YES - abort
1214
1215 call TFT_color_code_stop ; color-code output
1216 movff char_O_deco_depth,lo ; get depth of first stop in meters
1217
1218 TSTOSC opt_units ; get unit (0=m, 1=ft)
1219 bra TFT_show_deco_norm ; 1 - ft can only be displayed in normal layout due to space required for 3 digit depth
1220
1221 btfsc alt_layout_active ; in alternative layout?
1222 bra TFT_show_deco_alt ; YES
1223 ;bra TFT_show_deco_norm ; NO
1224
1225 TFT_show_deco_norm: ; set position for combined depth and time
1226 WIN_MEDIUM dm_decostop_col_norm, dm_decostop_row_norm
1227 rcall TFT_display_deco_depth ; output depth (stored in lo) to POSTINC2 with "m" or "ft"
1228 PUTC ' ' ; put a space char between depth and time
1229 bra TFT_display_deco_common ; continue with common part
1230
1231 TFT_show_deco_alt: ; set position for depth
1232 WIN_LARGE dm_decostop_col_alt_depth, dm_decostop_row_alt_depth
1233 output_99 ; output stop depth (2 digits, usable for meters only)
1234 STRCAT_PRINT "" ; finalize output
1235 ; set position for time
1236 WIN_MEDIUM dm_decostop_col_alt_time, dm_decostop_row_alt_time
1237 call TFT_memo_color ; back to memo color
1238 bcf win_invert ; back to non-inverted output
1239 ;bra TFT_display_deco_common ; continue with common part
1240
1241 TFT_display_deco_common:
1242 movff char_O_deco_time,lo ; get stop time of the first stop in minutes
1243 output_99DD ; print minutes or double dots if null
1244 STRCAT_PRINT "'" ; add minutes sign
1245 bcf win_invert ; back to non-inverted output
1246 TFT_display_exit_1:
1247 goto TFT_standard_color ; and return...
1248
1249
1250 global TFT_decoplan_mask ; mask for deco plan
1251 TFT_decoplan_mask:
1252 call TFT_divemask_color
1253 WIN_TINY dm_custom_decoplan_title_column, dm_custom_decoplan_title_row
1254 STRCPY_TEXT_PRINT tDiveDecoplan
1255 return
1256
1257
1258 global TFT_decoplan ; data for deco plan - stops 2 - 7 (stop 1 is shown in the main screen)
1259 TFT_decoplan:
1260 lfsr FSR0,char_O_deco_depth ; load base address of stops table
1261 clrf ex ; will be used for auxiliary flags
1262 call TFT_memo_color ; set default output color
1263 movff char_O_deco_gas+0,lo ; get flag for invalid deco data
1264 btfsc lo,char_invalid_flag ; is the invalid flag set?
1265 call TFT_disabled_color ; YES - set to disabled color
1266 ; 2nd stop
1267 WIN_SMALL dm_cust_dstop_2nd_stop_column, dm_cust_dstop_2nd_stop_row
1268 rcall TFT_decoplan_helper
1269 ; 3rd stop
1270 WIN_SMALL dm_cust_dstop_3rd_stop_column, dm_cust_dstop_3rd_stop_row
1271 rcall TFT_decoplan_helper
1272 ; 4th stop
1273 bsf ex,4 ; flag we are on 4th screen position
1274 WIN_SMALL dm_cust_dstop_4th_stop_column, dm_cust_dstop_4th_stop_row
1275 rcall TFT_decoplan_helper
1276 bcf ex,4 ; clear 4th position flag again
1277 ; 5th stop
1278 WIN_SMALL dm_cust_dstop_5th_stop_column, dm_cust_dstop_5th_stop_row
1279 rcall TFT_decoplan_helper
1280 ; 6th stop
1281 WIN_SMALL dm_cust_dstop_6th_stop_column, dm_cust_dstop_6th_stop_row
1282 rcall TFT_decoplan_helper
1283 ; 7th stop
1284 WIN_SMALL dm_cust_dstop_7th_stop_column, dm_cust_dstop_7th_stop_row
1285 rcall TFT_decoplan_helper
1286 bra TFT_display_exit_1 ; set standard color and return...
1287
1288 TFT_decoplan_helper:
1289 btfsc ex,0 ; no more stops to show?
1290 bra TFT_decoplan_helper_1 ; YES - skip checking next entry - it will be empty, too
1291 movff PREINC0,lo ; NO - advance pointer to get the depth of the 2nd, 3rd, 4th, ... stop
1292 tstfsz lo ; is the stop depth = 0, i.e. no stop entry?
1293 bra TFT_decoplan_helper_3 ; NO - show stop data
1294 TFT_decoplan_helper_1: ; no more stop table entries
1295 bsf ex,0 ; flag that there are no more stop table entries
1296 btfss ex,4 ; are we on the 4th screen position?
1297 bra TFT_decoplan_helper_2 ; NO - normal handling on this position
1298 btfsc ex,1 ; YES - special handling, has any stop been shown?
1299 bra TFT_decoplan_helper_2 ; YES - print normal blanking
1300 STRCPY_PRINT " ---- " ; NO - print a "no stops" indication (blanking potential previous content, too)
1301 return
1302 TFT_decoplan_helper_2: ; no more stop table entries, blank potential previous content
1303 STRCPY_PRINT " " ; wipe screen position by printing 7 spaces
1304 return
1305 TFT_decoplan_helper_3:
1306 rcall TFT_display_deco_depth ; output depth (stored in lo) to POSTINC2
1307 PUTC " " ; put a space char between depth and time
1308 movlw NUM_STOPS ; offset between arrays holding depths and durations
1309 movff PLUSW0,lo ; get duration of the current stop
1310 output_99dd ; print duration, prints double dots if duration is zero
1311 STRCAT_PRINT "'" ; append symbol for minutes and print to screen
1312 bsf ex,1 ; flag that a stop was shown
1313 return
1314
1315
1316 global TFT_safety_stop_clear 2767 global TFT_safety_stop_clear
1317 TFT_safety_stop_clear: 2768 TFT_safety_stop_clear:
1318 btfsc dive_main_menu ; is the dive mode menu shown? 2769 btfsc dive_main_menu ; is the dive mode menu shown?
1319 return ; YES - abort 2770 return ; YES - abort
1320 btfss safety_stop_active ; NO - is the safety stop shown? 2771 btfss safety_stop_active ; NO - is the safety stop shown?
1321 return ; NO - done, nothing to do 2772 return ; NO - done, nothing to do
1322 ; YES - clear safety stop area 2773 ; YES - clear safety stop area
1323 WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, dm_safetystop_rgt ; top, bottom, left, right 2774 WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, dm_safetystop_rgt ; top, bottom, left, right
1324 bcf safety_stop_active ; - safety stop not shown any more 2775 bcf safety_stop_active ; - safety stop not shown any more
1325 btfsc deco_region ; - was the dive within deco stops region? 2776 btfss deco_region ; - was the dive within deco stops region?
1326 bra TFT_show_slow_reminder ; YES - show "SLOW" reminder
1327 return ; NO - done 2777 return ; NO - done
1328 2778 ;bra TFT_show_slow_reminder ; YES - show "SLOW" reminder
1329 2779
1330 global TFT_safety_stop_show 2780
1331 TFT_safety_stop_show: 2781 ;-----------------------------------------------------------------------------
1332 btfsc dive_main_menu ; is the dive mode menu shown? 2782 ; Dive Mode - show "slow" Reminder
1333 return ; YES - abort 2783 ;
1334 btfsc safety_stop_active ; NO - is the safety stop shown already? 2784 TFT_show_slow_reminder:
1335 bra TFT_safety_stop_show_time ; YES - just update the time 2785 WIN_STD dm_safetystop_text_column+.5,dm_safetystop_text_row+.5
1336 ; NO - clear area that may be polluted by alternative NDL 2786 FONT_COLOR_ATTENTION ; set color
1337 WIN_BOX_BLACK dm_safetystop_row, dm_tts_value_row, dm_ndl_value_col_alt, dm_safetystop_rgt ; top, bottom, left, right 2787 STRCPY_TEXT tSlow ; print "SLOW" reminder
1338 call TFT_divemask_color ; - set color for text 2788 STRCAT_PRINT 0x94 ; append an up-arrow
1339 bsf safety_stop_active ; - flag safety stop is shown now 2789 return ; done
1340 ; - set position for text 2790
1341 WIN_STD dm_safetystop_text_column, dm_safetystop_text_row
1342 STRCPY_PRINT "Stop " ; - print "Stop" with a trailing space to wipe away potential other remains
1343 TFT_safety_stop_show_time:
1344 call TFT_attention_color ; set color for time
1345 ; set position for time
1346 WIN_MEDIUM dm_safetystop_column, dm_safetystop_row
1347 movff safety_stop_countdown,lo ; get remaining time in seconds, low byte, from safety stop timer
1348 clrf hi ; set remaining time in seconds, high byte, to zero
1349 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
1350 movff lo,up ; save seconds in up
1351 movff hi,lo ; move minutes to lo
1352 bsf leftbind ; activate left-alignment
1353 output_8 ; print minutes
1354 bcf leftbind ; deactivate left-alignment
1355 PUTC ':' ; print ":"
1356 movff up,lo ; move seconds to lo
1357 output_99x ; print seconds (2 digits with leading zero)
1358 STRCAT_PRINT "" ; finalize output
1359 bra TFT_display_exit_1 ; done
1360
1361
1362 global TFT_avr_stopwatch_mask ; mask for average depth and stopwatch
1363 TFT_avr_stopwatch_mask:
1364 call TFT_divemask_color
1365
1366 IFNDEF _min_depth_option
1367
1368 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row
1369 TSTOSS opt_2ndDepthDisp ; show avg depth instead of max depth in main screen?
1370 bra TFT_avr_stopwatch_mask_1 ; NO - draw avg depth in custom view then
1371 btfss alt_layout_active ; YES - in alternative layout?
1372 bra TFT_avr_stopwatch_mask_max ; NO - show max depth
1373 ;bra TFT_avr_stopwatch_mask_avg ; YES - show avg depth
1374 TFT_avr_stopwatch_mask_avg:
1375 STRCPY_TEXT_PRINT tDiveTotalAvg ; mask for average depth
1376 bra TFT_avr_stopwatch_mask_2 ; continue
1377 TFT_avr_stopwatch_mask_1:
1378 btfss alt_layout_active ; YES - in alternative layout?
1379 bra TFT_avr_stopwatch_mask_avg ; NO - show avg depth
1380 ;bra TFT_avr_stopwatch_mask_max ; YES - show max depth
1381 TFT_avr_stopwatch_mask_max:
1382 STRCPY_TEXT_PRINT tMaxDepth ; mask for maximum depth
1383 ;bra TFT_avr_stopwatch_mask_2 ; continue
1384 TFT_avr_stopwatch_mask_2:
1385 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row
1386 STRCPY_TEXT_PRINT tDiveStopwatch
1387 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row
1388 STRCPY_TEXT_PRINT tDiveStopAvg
1389 bra TFT_display_exit_1
1390
1391 ELSE
1392
1393 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row
1394 STRCPY_PRINT "Max.Depth"
1395 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row
1396 STRCPY_PRINT "Avg.Depth"
1397 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row
1398 STRCPY_PRINT "Min.Depth"
1399 bra TFT_display_exit_1
1400
1401 ENDIF
1402
1403
1404 global TFT_avr_stopwatch ; dive mode custom view: average depth and stopwatch
1405 TFT_avr_stopwatch:
1406 call TFT_memo_color
1407
1408 IFNDEF _min_depth_option
1409
1410 ; total average depth or max depth
1411 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row
1412 TSTOSS opt_2ndDepthDisp ; show average depth instead of maximum depth in main screen?
1413
1414 bra TFT_avr_stopwatch_1 ; NO - draw avg depth in custom view then
1415 btfss alt_layout_active ; YES - in alternative layout?
1416 bra TFT_avr_stopwatch_max ; NO - show max depth
1417 ;bra TFT_avr_stopwatch_avg ; YES - show avg depth
1418 TFT_avr_stopwatch_avg:
1419 MOVII pressure_rel_avg_total,mpr ; get total dive average pressure into hi:lo
1420 bra TFT_avr_stopwatch_2 ; continue
1421 TFT_avr_stopwatch_1:
1422 btfss alt_layout_active ; YES - in alternative layout?
1423 bra TFT_avr_stopwatch_avg ; NO - show avg depth
1424 ;bra TFT_avr_stopwatch_max ; YES - show max depth
1425 TFT_avr_stopwatch_max:
1426 MOVII pressure_rel_max_cached,mpr ; get maximum pressure into hi:lo
1427 ;bra TFT_avr_stopwatch_2 ; continue
1428 TFT_avr_stopwatch_2:
1429 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
1430 TSTOSS opt_units ; 0=m, 1=ft
1431 bra TFT_update_avr_stopwatch1_metric ; 0 - metric
1432 TFT_update_avr_stopwatch1_imp: ; 1 - imperial
1433 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
1434 output_16_3 ; yxz
1435 bra TFT_update_avr_stopwatch2
1436 TFT_update_avr_stopwatch1_metric:
1437 bsf leftbind
1438 bsf ignore_digit5 ; no cm (flag will be cleared by output_16)
1439 output_16dp .3 ; yxz.a
1440 PUTC " " ; wipe out remains from last output
1441 clrf WREG
1442 movff WREG,buffer+.4 ; limit string length to 4 = 3 digits + 1 half-size decimal dot
1443 TFT_update_avr_stopwatch2:
1444 STRCAT_PRINT ""
1445
1446 ; stopped average depth
1447 WIN_MEDIUM dm_custom_avr_stop_column3,dm_custom_avr_stop_row
1448 MOVII pressure_rel_avg_trip,mpr ; get the resettable average pressure
1449 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
1450 TSTOSS opt_units ; 0=m, 1=ft
1451 bra TFT_update_avr_stopwatch2_metric ; 0 - metric
1452 TFT_update_avr_stopwatch2_imp: ; 1 - imperial
1453 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
1454 output_16_3 ; yxz
1455 bra TFT_update_avr_stopwatch3
1456 TFT_update_avr_stopwatch2_metric:
1457 bsf leftbind
1458 bsf ignore_digit5 ; no cm (flag will be cleared by output_16)
1459 output_16dp .3 ; yxz.a
1460 PUTC " " ; wipe out remains from last output
1461 clrf WREG
1462 movff WREG,buffer+.4 ; limit string length to 4 = 3 digits + 1 half-size decimal dot
1463 TFT_update_avr_stopwatch3:
1464 STRCAT_PRINT "" ; finalize output
1465
1466 ELSE
1467
1468 ; resettable maximum depth - needs ISR-safe copy!
1469 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row ; column 0
1470 call TFT_memo_color
1471 SMOVII pressure_rel_max_trip,mpr ; get resettable maximum pressure
1472 rcall TFT_avr_stopwatch_helper
1473
1474 ; resettable average depth
1475 WIN_MEDIUM dm_custom_avr_stop_column2-.1,dm_custom_avr_stop_row ; column 54 - 1 = 53
1476 call TFT_attention_color
1477 MOVII pressure_rel_avg_trip,mpr ; get resettable average pressure
1478 rcall TFT_avr_stopwatch_helper
1479
1480 ; resettable minimum depth - needs ISR safe copy!
1481 WIN_MEDIUM dm_custom_avr_stop_column3-.12,dm_custom_avr_stop_row ; column 118 - 12 = 106
1482 call TFT_memo_color
1483 SMOVII pressure_rel_min_trip,mpr ; get resettable minimum pressure
1484 rcall TFT_avr_stopwatch_helper
1485
1486 ; done
1487 bra TFT_display_exit_2
1488
1489 TFT_avr_stopwatch_helper:
1490 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
1491 output_16dp .3 ; yxz.ab
1492 PUTC " " ; wipe out remains from last output
1493 clrf WREG
1494 movff WREG,buffer+.5 ; limit string length to 5 = 4 digits + 1 half-size decimal dot
1495 STRCAT_PRINT ""
1496 return
1497
1498 ENDIF
1499
1500 ; stopped dive time (will also be used by compass custom view)
1501 WIN_MEDIUM dm_custom_avr_stop_column2,dm_custom_avr_stop_row
1502 TFT_update_stopwatch: ; jump-in point for stopped dive time in compass custom view
1503 MOVII divesecs_avg_trip,mpr ; get the resettable dive time (stopwatch)
1504 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
1505 movlw .100 ; display layout will change if minutes become >= 100
1506 cpfslt hi ; minutes < 100 ?
1507 bra TFT_update_stopwatch_2 ; NO - display hours:minutes
1508 bcf aux_flag ; will print minutes : seconds
1509 TFT_update_stopwatch_1:
1510 movf hi,W ; exchange lo and hi
1511 movff lo,hi ; ...
1512 movwf lo ; ...
1513 bcf leftbind ; include leading spaces
1514 output_99 ; output minutes or hours ( 0 - 99)
1515 movlw ":" ; load standard separator
1516 btfsc aux_flag ; will print hours : minutes ?
1517 movlw "'" ; YES - swap to alternative separator
1518 movwf POSTINC2 ; print separator
1519 movff hi,lo ; restore lo
1520 output_99x ; output seconds or minutes
1521 movlw .5
1522 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
1523 clrf WREG
1524 movff WREG,buffer+.5 ; limit to 5 chars
1525 STRCAT_PRINT ""
1526 bra TFT_display_exit_2 ; clear leftbind and return
1527 TFT_update_stopwatch_2:
1528 movff hi,lo ; transfer minutes (low byte) to lo
1529 movff up,hi ; transfer minutes (high byte) to hi
1530 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
1531 bsf aux_flag ; will print hours : minutes
1532 bra TFT_update_stopwatch_1
1533
1534
1535 global TFT_CNS_mask
1536 TFT_CNS_mask:
1537 call TFT_divemask_color
1538 WIN_TINY dm_custom_cns3_column1, dm_custom_cns3_title_row
1539 STRCPY_TEXT_PRINT tCNSsurf
1540 WIN_TINY dm_custom_cns3_column2, dm_custom_cns3_title_row
1541
1542 IFDEF _cave_mode
1543 btfss cave_mode ; cave mode switched on?
1544 bra TFT_CNS_mask_1 ; NO
1545 STRCPY_TEXT_PRINT tCNScave ; YES - print cave TTS label
1546 bra TFT_CNS_mask_3 ; - continue with 3rd column
1547 ENDIF
1548
1549 TFT_CNS_mask_1:
1550 btfsc FLAG_oc_mode ; in OC mode?
1551 bra TFT_CNS_mask_2 ; YES - print fTTS label
1552 btfsc bailout_mode ; in bailout?
1553 bra TFT_CNS_mask_2 ; YES - print fTTS label (label will be printed, but a fTTS will actually not be calculated)
1554 TSTOSS opt_calc_gasvolume ; bailout volume calculation requested?
1555 bra TFT_CNS_mask_2 ; NO - print fTTS label
1556 STRCPY_TEXT_PRINT tCNSBO ; YES - print bailout label
1557 bra TFT_CNS_mask_3 ; - continue with 3rd column
1558 TFT_CNS_mask_2: ; OC or bailout
1559 STRCPY_TEXT_PRINT tCNSfTTS ; print fTTS label
1560 TFT_CNS_mask_3:
1561 WIN_TINY dm_custom_cns3_column3, dm_custom_cns3_title_row
1562 STRCPY_TEXT_PRINT tCNSnow ; print CNS now label
1563 bra TFT_display_exit_2
1564
1565
1566 global TFT_CNS
1567 TFT_CNS:
1568 bsf leftbind
1569 ; CNS at end of normal dive
1570 WIN_STD dm_custom_cns3_column1+.3,dm_custom_cns3_row
1571 MOVII int_O_CNS_norm,mpr ; get CNS at end of dive in normal plan
1572 call TFT_color_code_cns
1573 output_16_3 ; output as xxx
1574 STRCAT_PRINT "% "
1575 ; fTTS / Bailout CNS, if enabled
1576 WIN_STD dm_custom_cns3_column2+.2,dm_custom_cns3_row
1577 btfsc bailout_mode ; in bailout?
1578 bra TFT_CNS_3 ; YES - show "---"
1579 TSTOSS opt_calc_gasvolume ; NO - bailout volume calculation requested?
1580 bra TFT_CNS_1 ; NO - continue checking fTTS extra time
1581 btfss FLAG_oc_mode ; YES - in OC mode?
1582 bra TFT_CNS_2 ; NO - show CNS%
1583 TFT_CNS_1: ; not in bailout, no volume calculation, and/or in OC mode
1584 TSTOSS char_I_extra_time ; fTTS extra time configured?
1585 bra TFT_CNS_3 ; NO - show "---"
1586 TFT_CNS_2: ; YES - show CNS%
1587 MOVII int_O_CNS_alt,mpr ; get CNS at end of dive in alternative plan
1588 call TFT_color_code_cns ; color-code the CNS value
1589 output_16_3 ; output as xxx
1590 STRCAT_PRINT "% "
1591 bra TFT_CNS_4
1592 TFT_CNS_3:
1593 IFDEF _cave_mode
1594 btfss cave_mode ; cave mode switched on?
1595 bra TFT_CNS_3a ; NO - show dashes
1596 btfsc backtrack_entire_full ; YES - cave mode shut down due to storage fully used up?
1597 bra TFT_CNS_3a ; YES - show dashes
1598 btfss dive_turned ; NO - dive turned?
1599 bra TFT_CNS_2 ; NO - show cave CNS
1600 ;bra TFT_CNS_3a ; YES - show dashes
1601 ENDIF
1602 TFT_CNS_3a:
1603 call TFT_memo_color
1604 STRCPY_PRINT "--- "
1605 TFT_CNS_4:
1606 ; current CNS
1607 WIN_STD dm_custom_cns3_column3+.3,dm_custom_cns3_row
1608 MOVII int_O_CNS_current,mpr ; get current CNS
1609 call TFT_color_code_cns
1610 output_16_3 ; output as xxx
1611 STRCAT_PRINT "%"
1612 TFT_display_exit_2:
1613 bcf leftbind
1614 goto TFT_standard_color ; and return...
1615 2791
1616 ;============================================================================= 2792 ;=============================================================================
1617 2793 tft_out12 CODE
1618 IFDEF _cave_mode
1619
1620 global TFT_cave_tts_mask ; mask for cave mode data
1621 TFT_cave_tts_mask:
1622 call TFT_divemask_color
1623 WIN_TINY dm_custom_cave_title_column1,dm_custom_cave_title_row
1624 STRCPY_TEXT_PRINT tCaveStops
1625 WIN_TINY dm_custom_cave_title_column2,dm_custom_cave_title_row
1626 STRCPY_TEXT_PRINT tCaveTTS
1627 WIN_TINY dm_custom_cave_title_column3,dm_custom_cave_title_row
1628 STRCPY_TEXT_PRINT tCaveRuntime
1629 bra TFT_display_exit_2
1630
1631
1632 global TFT_cave_tts ; dive mode custom view: cave TTS
1633 TFT_cave_tts:
1634 ; total time of all stops
1635 WIN_MEDIUM dm_custom_cave_data_column1,dm_custom_cave_data_row ; column 8
1636 call TFT_memo_color ; set default color
1637 btfss cave_mode ; cave mode switched on?
1638 bra TFT_cave_1b ; NO - print dashes
1639 MOVII int_O_TST_norm,mpr ; YES - get normal plan total stops time
1640 btfss mpr+1,int_not_yet_computed ; - not yet computed?
1641 bra TFT_cave_1a ; NO - continue
1642 call TFT_disabled_color ; YES - switch to disabled color
1643 bra TFT_cave_1b ; - print dashes
1644 TFT_cave_1a:
1645 btfsc mpr+1,int_invalid_flag ; stops time invalid?
1646 call TFT_disabled_color ; YES - switch to disabled color
1647 bcf mpr+1,int_invalid_flag ; clear invalid flag if applicable
1648 movf mpr+0,W ; copy low byte of stops time to WREG
1649 iorwf mpr+1,W ; ior with high byte of stops time
1650 bz TFT_cave_1b ; print dashes if stops time is zero
1651 output_16_3 ; output as xxx
1652 STRCAT_PRINT "'" ; print minutes symbol
1653 bra TFT_cave_2 ; continue
1654 TFT_cave_1b:
1655 STRCAT_PRINT ",-,-,-," ; print 3 dashes (',' produces a half-width space)
1656 TFT_cave_2:
1657 ; cave TTS
1658 WIN_MEDIUM dm_custom_cave_data_column2,dm_custom_cave_data_row ; column 60
1659 call TFT_memo_color ; set default color
1660 btfsS cave_mode ; cave mode switched on?
1661 bra TFT_cave_2b ; NO - print dashes
1662 MOVII int_O_TTS_norm,mpr ; YES - get normal plan total time to surface
1663 btfss mpr+1,int_not_yet_computed ; - not yet computed?
1664 bra TFT_cave_2a ; NO - continue
1665 call TFT_disabled_color ; YES - switch to disabled color
1666 bra TFT_cave_2b ; - print dashes
1667 TFT_cave_2a:
1668 btfsc mpr+1,int_invalid_flag ; TTS invalid?
1669 call TFT_disabled_color ; YES - switch to disabled color
1670 bcf mpr+1,int_invalid_flag ; clear invalid flag if applicable
1671 output_16_3 ; output as xxx
1672 STRCAT_PRINT "'" ; print minutes symbol
1673 bra TFT_cave_3 ; continue
1674 TFT_cave_2b:
1675 STRCAT_PRINT ",-,-,-," ; print 3 dashes (',' produces a half-width space)
1676 TFT_cave_3:
1677 ; estimated total runtime
1678 WIN_MEDIUM dm_custom_cave_data_column3,dm_custom_cave_data_row ; column 114
1679 ; ; keep color from cave TTS
1680 btfss cave_mode ; cave mode switched on?
1681 bra TFT_cave_3b ; NO - print dashes
1682 SMOVII counted_divetime_mins,mpr ; YES - ISR safe copy of counted dive time to MPR
1683 movff int_O_TTS_norm+0,WREG ; - get TTS, low byte, into WREG
1684 addwf mpr+0,F ; - add TTS, low byte, to dive time in MPR
1685 movff int_O_TTS_norm+1,WREG ; - get TTS, high byte, into WREG
1686 btfsc WREG,int_not_yet_computed ; - not yet computed?
1687 bra TFT_cave_3b ; YES - print dashes
1688 bcf WREG,int_invalid_flag ; NO - clear invalid flag if applicable
1689 addwfc mpr+1,F ; - add TTS, high byte, to dive time in MPR
1690 output_16_3 ; - output as xxx
1691 STRCAT_PRINT "'" ; - print minutes symbol
1692 bra TFT_display_exit_2 ; - done
1693 TFT_cave_3b:
1694 STRCAT_PRINT ",-,-,-," ; print 3 dashes (',' produces a half-width space)
1695 bra TFT_display_exit_2 ; done
1696
1697
1698 global TFT_cave_waypoints
1699 TFT_cave_waypoints:
1700 ; title row
1701 WIN_TINY .70,dm_custom_cave_title_row;adjust column to display position of current waypoint
1702 call TFT_divemask_color ; select color
1703 btfss cave_mode ; cave mode switched on?
1704 bra TFT_cave_waypoints_3 ; NO - do not show any marker (any more)
1705 btfss dive_turned ; YES - dive turned?
1706 bra TFT_cave_waypoints_1 ; NO - print marker on right side
1707 bra TFT_cave_waypoints_2 ; YES - print marker in the middle
1708 TFT_cave_waypoints_1:
1709 movlw .12 ; start with 12 space chars
1710 call TFT_fillup_with_spaces ; fill buffer with space chars
1711 TFT_cave_waypoints_2:
1712 STRCAT "<=====" ; print marker symbol
1713 TFT_cave_waypoints_3:
1714 movlw .18 ; set overall number of chars
1715 call TFT_fillup_with_spaces ; fill buffer with space chars
1716 STRCAT_PRINT "" ; finalize output
1717 ; data row
1718 btfsc cave_mode ; cave mode switched on?
1719 bra TFT_cave_waypoints_4 ; YES - show graphics
1720 WIN_STD .0,dm_custom_cave_data_row ; NO - show "Cave Mode off" text
1721 call TFT_attention_color ; - select attention color
1722 STRCPY " " ; - print 2 space chars
1723 STRCAT_TEXT tCaveMode ; - print "Cave Mode"
1724 PUTC " " ; - print a space char
1725 STRCAT_TEXT tOff ; - print "off"
1726 movlw .17 ; - set max number of chars
1727 call TFT_fillup_with_spaces ; - fill up FSR2 with spaces (total string length in #WREG)
1728 STRCAT_PRINT "" ; - finalize output
1729 return ; - done
1730 TFT_cave_waypoints_4:
1731 WIN_MEDIUM .0,dm_custom_cave_data_row; start in column 0
1732 call TFT_memo_color ; select default color
1733 tstfsz DM_flags_cavereq ; any pending cave mode requests?
1734 call TFT_disabled_color ; YES - switch to disabled color
1735 ; 1st section: previous waypoint number or beginning line
1736 movlw .1 ; load a one into WREG
1737 cpfsgt backtrack_waypoint_num ; current waypoint number > 1 ?
1738 bra TFT_cave_waypoints_5 ; NO - print line segment only
1739 STRCAT ",-," ; YES - print one dash
1740 movff backtrack_waypoint_num,lo ; - copy current waypoint number to lo
1741 decf lo,F ; - create previous waypoint number
1742 output_99 ; - print previous waypoint number in two digit format
1743 STRCAT "," ; - print a half-space
1744 bra TFT_cave_waypoints_6 ; - continue with next section
1745 TFT_cave_waypoints_5:
1746 STRCAT ",-,-----" ; print line segment
1747 TFT_cave_waypoints_6:
1748 ; 2nd section: solid line
1749 STRCAT "---" ; print a solid line
1750 ; 3rd section: current waypoint number, turn point symbol or line segment
1751 tstfsz backtrack_waypoint_num ; does a current waypoint exist?
1752 bra TFT_cave_waypoints_8 ; YES - print its number or the turn point symbol
1753 btfss dive_turned ; NO - dive turned?
1754 bra TFT_cave_waypoints_7 ; NO - print a separated line segment
1755 STRCAT "------" ; YES - print a continuous line
1756 bra TFT_cave_waypoints_10 ; - continue with next section
1757 TFT_cave_waypoints_7:
1758 STRCAT ",----," ; print a separated line segment
1759 bra TFT_cave_waypoints_10 ; continue with next section
1760 TFT_cave_waypoints_8:
1761 STRCAT "," ; print a half-width space
1762 movff backtrack_waypoint_num,lo ; copy current waypoint number to lo
1763 movf backtrack_waypoint_turn,W ; copy turn point number to WREG
1764 cpfseq lo ; current waypoint = turn point ?
1765 bra TFT_cave_waypoints_9 ; NO - show waypoint number
1766 STRCAT_PRINT "--|, " ; YES - print end-of-line symbol, clear remaining output and finalize output
1767 return ; - done
1768 TFT_cave_waypoints_9:
1769 movff backtrack_waypoint_num,lo ; copy current waypoint number to lo
1770 output_99 ; print current waypoint number in two digit format
1771 STRCAT "," ; print a half-space
1772 TFT_cave_waypoints_10:
1773 ; 4th section: solid line
1774 STRCAT "---" ; print a solid line
1775 ; 5th section: next waypoint number or end of line symbol
1776 incf backtrack_waypoint_num,W ; load WREG with next waypoint number
1777 cpfseq backtrack_waypoint_turn ; next waypoint number = turn point number ?
1778 btfsc waypoint_reached_last ; NO - is the current waypoint the last waypoint?
1779 bra TFT_cave_waypoints_11 ; YES / YES - print end-of-line symbol
1780 STRCAT "," ; NO - print a half-space
1781 incf backtrack_waypoint_num,W ; - (re)load WREG with next waypoint number
1782 movwf lo ; NO - copy next waypoint number to lo
1783 output_99 ; - print next waypoint number in two digit format
1784 STRCAT_PRINT "" ; - finalize output
1785 return ; - done
1786 TFT_cave_waypoints_11:
1787 STRCAT_PRINT "---|," ; print end-of-line symbol and finalize output
1788 return ; done
1789
1790 ENDIF
1791
1792 ;============================================================================= 2794 ;=============================================================================
1793 2795
1794 IFDEF _external_sensor 2796
1795 2797 ;-----------------------------------------------------------------------------
1796 global TFT_ppo2_sensors_mask ; mask for ppO2 sensors 2798 ; clear complete Message Window
1797 TFT_ppo2_sensors_mask: 2799 ;
1798 call TFT_divemask_color 2800 global TFT_clear_message_window
1799 WIN_TINY dm_custom_hud_sensor1_column+.4,dm_custom_hud_title_row 2801 TFT_clear_message_window:
1800 STRCPY_TEXT_PRINT tDiveHudMask1 2802 btfss divemode ; in dive mode?
1801 WIN_TINY dm_custom_hud_sensor2_column+.3,dm_custom_hud_title_row 2803 bra TFT_clear_message_window_surf ; NO - clear surface mode area
1802 STRCPY_TEXT_PRINT tDiveHudMask2 2804 ;bra TFT_clear_message_window_dive ; YES - clear dive mode area
1803 WIN_TINY dm_custom_hud_sensor3_column+.2,dm_custom_hud_title_row 2805
1804 STRCPY_TEXT_PRINT tDiveHudMask3 2806 TFT_clear_message_window_dive:
1805 bra TFT_display_exit_2 2807 btfsc alt_layout_active ; in alternative layout?
1806 2808 bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only
1807 2809
1808 global TFT_ppo2_sensors ; data for ppO2 sensors 2810 WIN_BOX_BLACK dm_warning_row, dm_warning_bot, dm_warning_column, dm_warning_rgt
1809 TFT_ppo2_sensors: 2811 return ; done
1810 ; 2812
1811 ; Definition of the output: 2813 TFT_clear_message_window_surf:
1812 ; 2814 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ; top, bottom, left, right
1813 ; sensorX use voting o2 2815 return ; done
1814 ; _calibrated _O2 _logic _ppo2 Output Color 2816
1815 ; _ok _sensorX _sensorX _sensorX 2817
1816 ;----------------------------------------------------------------------------------------------- 2818 ;-----------------------------------------------------------------------------
1817 ; 0 -/- -/- -/- "----" TFT_memo_color 2819 ; clear 2nd Line of Message Window
1818 ; 1 0 -/- = 0 o2_ppo2_sensorX TFT_attention_color 2820 ;
1819 ; 1 0 -/- > 0 o2_ppo2_sensorX TFT_disabled_color 2821 global TFT_clear_message_window_row2
1820 ; 1 1 0 -/- o2_ppo2_sensorX TFT_color_code_ppo2_hud + win_invert 2822 TFT_clear_message_window_row2:
1821 ; 1 1 1 -/- o2_ppo2_sensorX TFT_color_code_ppo2_hud 2823 bcf message_2nd_row_used ; 2nd row is cleared
1822 ; 2824 btfss divemode ; in dive mode?
1823 bsf leftbind 2825 bra TFT_clear_message_window_surf_2 ; NO - clear surface mode area, 2nd row only
1824 ; sensor 1 2826 ;bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only
1825 btfsc sensor1_calibrated_ok ; valid calibration? 2827
1826 bra TFT_update_hud1b ; YES 2828 TFT_clear_message_window_dive_2:
1827 btfsc sensor1_active ; valid HUD data for this sensor 2829 WIN_BOX_BLACK dm_warning2_row, dm_warning2_bot, dm_warning2_column, dm_warning2_rgt
1828 bra TFT_update_hud1b ; YES 2830 return ; done
1829 2831
1830 ; no valid calibration 2832 TFT_clear_message_window_surf_2:
1831 WIN_STD dm_custom_hud_sensor1_column+.7, dm_custom_hud_row+.5 2833 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ; top, bottom, left, right
1832 call TFT_memo_color 2834 return ; done
1833 STRCPY_PRINT "---" 2835
1834 bra TFT_update_hud2a ; continue with sensor 2 2836
1835 TFT_update_hud1b: 2837 ;-----------------------------------------------------------------------------
1836 ; sensor has a valid calibration 2838 ; Surface Mode - Message - Desaturation
1837 WIN_MEDIUM dm_custom_hud_sensor1_column,dm_custom_hud_row 2839 ;
1838 movff sensor1_ppO2,lo ; load ppO2 value into transfer storage for output 2840 global TFT_surf_mesg_desat
1839 clrf hi ; 2841 TFT_surf_mesg_desat:
1840 btfsc use_O2_sensor1 ; in use? 2842 rcall TFT_message_open ; set row and column for the message
1841 bra TFT_update_hud1d ; YES
1842 ; valid calibration, but not in use
1843 tstfsz lo ; sensor value = 0?
1844 bra TFT_update_hud1c ; no
1845 ; valid calibration, not in use and value = 0
1846 call TFT_attention_color ; output in yellow
1847 bra TFT_update_hud1e
1848 TFT_update_hud1c:
1849 ; sensor has valid calibration, is not in use and has a value > 0
1850 call TFT_disabled_color ; output in light blue
1851 bra TFT_update_hud1e
1852 TFT_update_hud1d:
1853 ; sensor has valid calibration and is in use
1854 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo
1855 btfsc voting_logic_sensor1 ; sensor value agrees with values of other sensors?
1856 bra TFT_update_hud1e ; YES
1857 ; valid calibration, in use, but value does not agree with other sensors
1858 bsf win_invert ; invert output
1859 TFT_update_hud1e:
1860 ; all coloring is set up now, let's write the value to the display!
1861 output_16dp .3 ; x.xx bar
1862 STRCAT_PRINT ""
1863 bcf win_invert
1864
1865 TFT_update_hud2a: ; sensor 2
1866 btfsc sensor2_calibrated_ok ; valid calibration?
1867 bra TFT_update_hud2b ; YES
1868 btfsc sensor2_active ; valid HUD data for this sensor
1869 bra TFT_update_hud2b ; YES
1870 ; no valid calibration
1871 WIN_STD dm_custom_hud_sensor2_column+.7, dm_custom_hud_row+.5
1872 call TFT_memo_color
1873 STRCPY_PRINT "---"
1874 bra TFT_update_hud3a ; continue with sensor 3
1875 TFT_update_hud2b:
1876 ; sensor has a valid calibration
1877 WIN_MEDIUM dm_custom_hud_sensor2_column,dm_custom_hud_row
1878 movff sensor2_ppO2,lo ; load ppO2 value into transfer storage for output
1879 clrf hi ;
1880 btfsc use_O2_sensor2 ; in use?
1881 bra TFT_update_hud2d ; YES
1882 ; valid calibration, but not in use
1883 tstfsz lo ; sensor value = 0?
1884 bra TFT_update_hud2c ; NO
1885 ; valid calibration, not in use and value = 0
1886 call TFT_attention_color ; output in yellow
1887 bra TFT_update_hud2e
1888 TFT_update_hud2c:
1889 ; sensor has valid calibration, is not in use and has a value > 0
1890 call TFT_disabled_color ; output in light blue
1891 bra TFT_update_hud2e
1892 TFT_update_hud2d:
1893 ; sensor has valid calibration and is in use
1894 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo
1895 btfsc voting_logic_sensor2 ; sensor value agrees with values of other sensors?
1896 bra TFT_update_hud2e ; YES
1897 ; valid calibration, in use, but value does not agree with other sensors
1898 bsf win_invert ; invert output
1899 TFT_update_hud2e:
1900 ; all coloring is set up now, let's write the value to the display!
1901 output_16dp .3 ; x.xx bar
1902 STRCAT_PRINT ""
1903 bcf win_invert
1904
1905 TFT_update_hud3a: ; sensor 3
1906 btfsc sensor3_calibrated_ok ; valid calibration?
1907 bra TFT_update_hud3b ; YES
1908 btfsc sensor3_active ; valid HUD data for this sensor
1909 bra TFT_update_hud3b ; YES
1910 ; no valid calibration
1911 WIN_STD dm_custom_hud_sensor3_column+.7, dm_custom_hud_row+.5
1912 call TFT_memo_color
1913 STRCPY_PRINT "---"
1914 bra TFT_update_hud4 ; done
1915 TFT_update_hud3b:
1916 ; sensor has a valid calibration
1917 WIN_MEDIUM dm_custom_hud_sensor3_column,dm_custom_hud_row
1918 movff sensor3_ppO2,lo ; load ppO2 value into transfer storage for output
1919 clrf hi ;
1920 btfsc use_O2_sensor3 ; in use?
1921 bra TFT_update_hud3d ; YES
1922 ; valid calibration, but not in use
1923 tstfsz lo ; sensor value = 0?
1924 bra TFT_update_hud3c ; NO
1925 ; valid calibration, not in use and value = 0
1926 call TFT_attention_color ; output in yellow
1927 bra TFT_update_hud3e
1928 TFT_update_hud3c:
1929 ; sensor has valid calibration, is not in use and has a value > 0
1930 call TFT_disabled_color ; output in light blue
1931 bra TFT_update_hud3e
1932 TFT_update_hud3d:
1933 ; sensor has valid calibration and is in use
1934 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo
1935 btfsc voting_logic_sensor3 ; sensor value agrees with values other sensors?
1936 bra TFT_update_hud3e ; YES
1937 ; valid calibration, in use, but value does not agree with other sensors
1938 bsf win_invert ; invert output
1939 TFT_update_hud3e:
1940 ; all coloring is set up now, let's write the value to the display!
1941 output_16dp .3 ; x.xx bar
1942 STRCAT_PRINT ""
1943 bcf win_invert
1944
1945 TFT_update_hud4: ; closure
1946 bra TFT_display_exit_3
1947
1948
1949 global TFT_surface_sensor ; update O2 sensor data in surface mode
1950 TFT_surface_sensor:
1951 bsf leftbind
1952 WIN_SMALL surf_hud_sensor1_column,surf_hud_sensor1_row
1953 btfsc sensor1_calibrated_ok
1954 bra TFT_surface_sensor1 ; YES
1955 btfsc sensor1_active ; valid HUD data for this sensor
1956 bra TFT_surface_sensor1 ; YES
1957 call TFT_standard_color
1958 STRCPY_PRINT "--- "
1959 bra TFT_surface_sensor2 ; skip sensor 1
1960 TFT_surface_sensor1:
1961 movff sensor1_ppO2,lo
1962 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo
1963 clrf hi
1964 bsf leftbind
1965 output_16dp .3 ; x.xx bar
1966 bcf leftbind
1967 STRCAT_PRINT ""
1968 TFT_surface_sensor2:
1969 WIN_SMALL surf_hud_sensor2_column,surf_hud_sensor2_row
1970 btfsc sensor2_calibrated_ok
1971 bra TFT_surface_sensor3 ; YES
1972 btfsc sensor2_active ; valid HUD data for this sensor
1973 bra TFT_surface_sensor3 ; YES
1974 call TFT_standard_color
1975 STRCPY_PRINT "--- "
1976 bra TFT_surface_sensor4 ; skip sensor 2
1977 TFT_surface_sensor3:
1978 movff sensor2_ppO2,lo
1979 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo
1980 clrf hi
1981 bsf leftbind
1982 output_16dp .3 ; x.xx bar
1983 bcf leftbind
1984 STRCAT_PRINT ""
1985 TFT_surface_sensor4:
1986 WIN_SMALL surf_hud_sensor3_column,surf_hud_sensor3_row
1987 btfsc sensor3_calibrated_ok
1988 bra TFT_surface_sensor5 ; YES
1989 btfsc sensor3_active ; valid HUD data for this sensor
1990 bra TFT_surface_sensor5 ; YES
1991 call TFT_standard_color
1992 STRCPY_PRINT "--- "
1993 bra TFT_surface_sensor6 ; skip sensor 3
1994 TFT_surface_sensor5:
1995 movff sensor3_ppO2,lo
1996 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo
1997 clrf hi
1998 bsf leftbind
1999 output_16dp .3 ; x.xx bar
2000 bcf leftbind
2001 STRCAT_PRINT ""
2002 TFT_surface_sensor6:
2003 TFT_display_exit_3:
2004 bcf leftbind
2005 goto TFT_standard_color ; and return...
2006
2007
2008 global TFT_sensor_mV
2009 TFT_sensor_mV:
2010 bsf leftbind
2011
2012 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor1_row
2013 SMOVII sensor1_mv,mpr ; in 0.1mV steps
2014 STRCAT "1: "
2015 rcall TFT_sensor_mV_helper
2016
2017 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor2_row
2018 SMOVII sensor2_mv,mpr ; in 0.1mV steps
2019 STRCAT "2: "
2020 rcall TFT_sensor_mV_helper
2021
2022 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row
2023 SMOVII sensor3_mv,mpr ; in 0.1mV steps
2024 STRCAT "3: "
2025 rcall TFT_sensor_mV_helper
2026 bcf leftbind
2027
2028 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row+.24 ; 4th row
2029 btfss s8_digital_avail ; do we have a digital S8 interface?
2030 bra TFT_sensor_mV_optical_analog
2031 STRCAT_PRINT "Digital"
2032 bra TFT_display_exit_3
2033 TFT_sensor_mV_optical_analog:
2034 btfss ir_power ; do we have a optical digital interface?
2035 bra TFT_sensor_mV_analog
2036 STRCAT_PRINT "Optical"
2037 bra TFT_display_exit_3
2038 TFT_sensor_mV_analog: ; -> optical
2039 STRCAT_PRINT "Analog"
2040 bra TFT_display_exit_3
2041
2042 TFT_sensor_mV_helper:
2043 output_16dp .4 ; xxx.y mV
2044 STRCAT_PRINT "mV "
2045 return
2046
2047
2048 global TFT_sensor_surface_warning
2049 TFT_sensor_surface_warning:
2050 call TFT_warning_color
2051 btfss sensor1_calibrated_ok ; do not show end of lifetime arrow if sensor failed calibration at all
2052 bra TFT_sensor_mV2
2053 movff opt_x_s1+1,lo ; into bank1
2054 movf lo,W ; when opt_x_s1 > 255 the sensor will just give 8 mV at a ppO2 of 0.21 any more
2055 bz TFT_sensor_mV2 ; the sensor is not too bad yet for a warning
2056 WIN_SMALL surf_mV_sensor_status_column,surf_mV_sensor1_row-.5
2057 STRCPY_PRINT "\xb8" ; mark sensor as being at end of lifetime
2058 TFT_sensor_mV2:
2059 btfss sensor2_calibrated_ok ; do not show end of lifetime arrow if sensor failed calibration at all
2060 bra TFT_sensor_mV3
2061 movff opt_x_s2+1,lo ; into bank1
2062 movf lo,W ; when opt_x_s2 > 255 the sensor will just give 8 mV at a ppO2 of 0.21 any more
2063 bz TFT_sensor_mV3 ; the sensor is not too bad yet for a warning
2064 WIN_SMALL surf_mV_sensor_status_column,surf_mV_sensor2_row-.5
2065 STRCPY_PRINT "\xb8" ; mark sensor as being at end of lifetime
2066 TFT_sensor_mV3:
2067 btfss sensor3_calibrated_ok ; do not show end of lifetime arrow if sensor failed calibration at all
2068 bra TFT_sensor_mV4
2069 movff opt_x_s3+1,lo ; into bank1
2070 movf lo,W ; when opt_x_s3 > 255 the sensor will just give 8 mV at a ppO2 of 0.21 any more
2071 bz TFT_sensor_mV4 ; the sensor is not too bad yet for a warning
2072 WIN_SMALL surf_mV_sensor_status_column,surf_mV_sensor3_row-.5
2073 STRCPY_PRINT "\xb8" ; mark sensor as being at end of lifetime
2074 TFT_sensor_mV4:
2075 bra TFT_display_exit_3
2076
2077
2078 global TFT_menu_calibrate
2079 TFT_menu_calibrate: ; update mV data in calibration menu
2080 btfss s8_digital_avail ; do we have a digital S8 interface?
2081 bra TFT_menu_calibrate_analog ; NO - use analog
2082 btfss trigger_S8_data_update ; YES - new data frame received?
2083 bra TFT_menu_calibrate_common ; NO - use old values...
2084 bcf trigger_S8_data_update ; YES - clear update flag
2085 call compute_mvolts_for_all_sensors ; - compute mV values from received data frame
2086 bra TFT_menu_calibrate_common ; - continue with common part
2087 TFT_menu_calibrate_analog:
2088 call get_analog_inputs ; read mV values from analog inputs
2089 TFT_menu_calibrate_common:
2090 call TFT_attention_color ; show in yellow
2091 bsf leftbind ; align to the left
2092 WIN_SMALL surf_menu_sensor1_column,surf_menu2_sensor1_row
2093 SMOVII sensor1_mv,mpr ; in 0.1mV steps
2094 output_16dp .4 ; xxx.y mV
2095 STRCAT_PRINT "mV "
2096 WIN_SMALL surf_menu_sensor2_column,surf_menu2_sensor2_row
2097 SMOVII sensor2_mv,mpr ; in 0.1mV steps
2098 output_16dp .4 ; xxx.y mV
2099 STRCAT_PRINT "mV "
2100 WIN_SMALL surf_menu_sensor3_column,surf_menu2_sensor3_row
2101 SMOVII sensor3_mv,mpr ; in 0.1mV steps
2102 output_16dp .4 ; xxx.y mV
2103 STRCAT_PRINT "mV "
2104 TSTOSS opt_s8_mode ; =0: analog, =1: digital RS232
2105 bra TFT_display_exit_3 ; analog - done
2106 ; also imprint HUD battery voltage
2107 WIN_TINY .20,.209 ; digital
2108 STRCPY "HUD Batt: " ; print label
2109 SMOVII hud_battery_mv,mpr ; get HUD battery voltage
2110 output_16dp .2 ; print as -x.yyy
2111 STRCAT_PRINT "V " ; finalize output
2112 bra TFT_display_exit_3 ; done
2113
2114 ENDIF ; _external_sensor
2115
2116 ;=============================================================================
2117
2118 global TFT_time_surfmode
2119 TFT_time_surfmode:
2120 WIN_SMALL surf_clock_column+.7,surf_clock_row
2121 TFT_clock2: ; called from dive mode clock
2122 call TFT_standard_color
2123 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
2124 movff rtc_latched_hour,lo
2125 output_99
2126 movlw ':'
2127 movff rtc_latched_secs,lo
2128 btfss lo,0 ; blinking every second
2129 movlw ' '
2130 movwf POSTINC2
2131 movff rtc_latched_mins,lo
2132 output_99x
2133 STRCAT_PRINT ""
2134 return
2135
2136
2137 global TFT_show_time_date_menu
2138 global TFT_show_time_date_menu_fast
2139 TFT_show_time_date_menu:
2140 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of current date & time
2141 TFT_show_time_date_menu_fast:
2142 WIN_SMALL .20,.40 ; column, row - keep clear of the cursor area on the left!
2143 call TFT_standard_color
2144 movff rtc_latched_hour,lo
2145 output_99
2146 PUTC ':'
2147 movff rtc_latched_mins,lo
2148 output_99x
2149 PUTC ':'
2150 movff rtc_latched_secs,lo
2151 output_99x
2152 STRCAT " "
2153 movff rtc_latched_year, lo
2154 movff rtc_latched_month,hi
2155 movff rtc_latched_day, up
2156 call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
2157 STRCAT_PRINT " "
2158 return
2159
2160 ;=============================================================================
2161
2162 global TFT_surface_decosettings ; show all deco settings
2163 TFT_surface_decosettings:
2164 ; Deco Mode
2165 call TFT_standard_color
2166 WIN_SMALL surf_gaslist_column,surf_gaslist_row
2167 STRCAT_PRINT "ZH-L16"
2168 movff char_I_model,WREG
2169 iorwf WREG
2170 bnz TFT_surface_decosettings1
2171 ; Display ZH-L16 sat/desat model
2172 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
2173 lfsr FSR2,buffer
2174 movff char_I_desaturation_multiplier,lo
2175 bsf leftbind
2176 output_8
2177 STRCAT "%/"
2178 movff char_I_saturation_multiplier,lo
2179 output_8
2180 STRCAT_PRINT "%"
2181 bra TFT_surface_decosettings2
2182 ; Display ZH-L16-GF low/high model
2183 TFT_surface_decosettings1:
2184 TEXT_SMALL surf_gaslist_column+.43,surf_gaslist_row,tZHL16GF
2185 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
2186 STRCPY_TEXT tGF ; GF:
2187 movff opt_GF_low,lo
2188 output_99x
2189 STRCAT "/"
2190 movff opt_GF_high,lo
2191 output_99x
2192 STRCAT_PRINT ""
2193 TFT_surface_decosettings2: ; fTTS
2194 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)
2195 STRCPY_TEXT tFTTSSurf
2196 movff char_I_extra_time,lo
2197 bsf leftbind
2198 output_8
2199 STRCAT_TEXT_PRINT tMinutes
2200 ; Last Stop
2201 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)
2202 STRCPY_TEXT tLastDecostopSurf
2203 movff opt_last_stop,lo
2204 output_8
2205 STRCAT_TEXT_PRINT tMeters
2206 ; Salinity
2207 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4)
2208 STRCPY_TEXT tDvSalinitySurf
2209 movff opt_salinity,lo
2210 output_8
2211 bcf leftbind
2212 STRCAT_TEXT_PRINT tPercent
2213 return
2214
2215
2216 global TFT_divetimeout
2217 TFT_divetimeout:
2218 call TFT_set_message_window ; set row and column for the message
2219 tstfsz WREG ; is there room for the message? 2843 tstfsz WREG ; is there room for the message?
2220 return ; NO - skip message in this cycle 2844 return ; NO - skip message in this cycle
2221 call TFT_memo_color 2845
2222 STRCPY 0x94 ; "End of dive" symbol 2846 FONT_COLOR_MEMO ; select color
2223 movff opt_diveTimeout,WREG ; in [min] 2847 STRCPY "Desat:" ; print label
2224 mullw .60 2848 MOVII int_O_desaturation_time,mpr ; get desaturation time in minutes
2225 MOVII PRODL, sub_a ; in seconds 2849 bra TFT_dsat_nofly_common ; continue with common part
2226 MOVII dive_timeout_timer,sub_b 2850
2227 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) 2851
2228 MOVII sub_c,mpr 2852 ;-----------------------------------------------------------------------------
2853 ; Surface Mode - Message - No-Fly / NO-Altitude
2854 ;
2855 global TFT_surf_mesg_nofly
2856 TFT_surf_mesg_nofly:
2857 rcall TFT_message_open ; set row and column for the message
2858 tstfsz WREG ; is there room for the message?
2859 return ; NO - skip message in this cycle
2860
2861 FONT_COLOR_MEMO ; select color
2862 movff char_I_altitude_wait,WREG ; get mode
2863 tstfsz WREG ; mode = altitude?
2864 bra TFT_nofly_time_alt ; YES
2865 ;bra TFT_nofly_time_fly ; NO
2866
2867 TFT_nofly_time_fly:
2868 STRCPY "NoFly:" ; print no-fly label
2869 bra TFT_nofly_time_com ; continue
2870
2871 TFT_nofly_time_alt:
2872 STRCPY "NoAlt:" ; print no-altitude label
2873 ;bra TFT_nofly_time_com ; continue
2874
2875 TFT_nofly_time_com:
2876 MOVII int_O_nofly_time,mpr ; get no-fly time in minutes
2877 ;bra TFT_dsat_nofly_common ; continue with common part
2878
2879
2880 ; Helper Function - common part for TFT_surf_mesg_desat and TFT_surf_mesg_nofly
2881 TFT_dsat_nofly_common:
2229 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) 2882 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
2230 movf hi,W ; swap lo and hi 2883 movff lo,up ; backup lo
2231 movff lo,hi ; ... 2884 movff hi,lo ; get hours into lo
2232 movwf lo ; ... 2885 output_99 ; print hours (0-99)
2233 output_99x 2886 PUTC ':' ; print ":"
2234 PUTC ':' 2887 movff up,lo ; get minutes into lo
2235 movff hi,lo ; copy hi to lo 2888 output_99x ; print minutes (00-99)
2236 output_99x 2889 bra TFT_message_close ; finalize message output
2237 movlw dm_warning_length ; dive mode string length 2890
2238 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 2891
2239 STRCAT_PRINT "" 2892 ;-----------------------------------------------------------------------------
2240 bcf win_invert 2893 ; Dive Mode - Message - fTTS
2241 return 2894 ;
2242 2895 global TFT_message_ftts
2243 2896 TFT_message_ftts:
2244 global TFT_show_ftts 2897 call TFT_message_open ; set row and column for the message
2245 TFT_show_ftts:
2246 call TFT_set_message_window ; set row and column for the message
2247 tstfsz WREG ; is there room for the message? 2898 tstfsz WREG ; is there room for the message?
2248 return ; NO - skip message in this cycle 2899 return ; NO - skip message in this cycle
2249 bsf leftbind ; print with alignment to the left 2900
2250 IFDEF _cave_mode 2901 IFDEF _cave_mode
2251 btfss cave_mode ; cave mode switched on? 2902 btfss cave_mode ; cave mode switched on?
2252 bra TFT_display_ftts_2 ; NO - classic open water TTS 2903 bra TFT_display_ftts_2 ; NO - classic open water TTS
2253 btfss dive_turned ; YES - dive turned? 2904 btfss dive_turned ; YES - dive turned?
2254 bra TFT_display_ftts_1 ; NO - cTTS from current position 2905 bra TFT_display_ftts_1 ; NO - cTTS from current position
2258 bra TFT_display_ftts_0 ; NO - print waypoint number 2909 bra TFT_display_ftts_0 ; NO - print waypoint number
2259 STRCAT "-| " ; YES - print turn point symbol 2910 STRCAT "-| " ; YES - print turn point symbol
2260 bra TFT_display_ftts_5 ; - continue with TTS 2911 bra TFT_display_ftts_5 ; - continue with TTS
2261 TFT_display_ftts_0: 2912 TFT_display_ftts_0:
2262 movwf lo ; copy current waypoint number to lo 2913 movwf lo ; copy current waypoint number to lo
2263 output_99 ; print waypoint number 2914 bsf leftbind ; print left-aligned
2915 output_99 ; print waypoint number (0-99)
2264 PUTC " " ; append a space char 2916 PUTC " " ; append a space char
2265 bra TFT_display_ftts_5 ; continue with TTS 2917 bra TFT_display_ftts_5 ; continue with TTS
2266 TFT_display_ftts_1: 2918 TFT_display_ftts_1:
2267 STRCPY "cTTS " ; print cave TTS label followed by a space 2919 STRCPY "cTTS " ; print cave TTS label followed by a space
2268 bra TFT_display_ftts_5 ; continue with TTS 2920 bra TFT_display_ftts_5 ; continue with TTS
2276 bra TFT_display_ftts_4 ; - continue 2928 bra TFT_display_ftts_4 ; - continue
2277 TFT_display_ftts_3: ; OC or CCR/pSCR but no bailout volume calculation 2929 TFT_display_ftts_3: ; OC or CCR/pSCR but no bailout volume calculation
2278 STRCPY "@+" ; print fTTS label 2930 STRCPY "@+" ; print fTTS label
2279 TFT_display_ftts_4: 2931 TFT_display_ftts_4:
2280 movff char_I_extra_time,lo ; get fTTS delay time 2932 movff char_I_extra_time,lo ; get fTTS delay time
2281 output_8 ; print fTTS delay time 2933 output_9 ; print fTTS delay time (0-9)
2282 PUTC ":" ; ":" 2934 PUTC ":" ; print ":"
2283 TFT_display_ftts_5: 2935 TFT_display_ftts_5:
2284 MOVII int_O_TTS_alt,mpr ; get alternative TTS 2936 MOVII int_O_TTS_alt,mpr ; get alternative TTS
2285 call TFT_memo_color ; set memo color 2937 FONT_COLOR_MEMO ; set memo color
2286 btfss hi,int_invalid_flag ; is the invalid flag set? 2938 btfss hi,int_invalid_flag ; is the invalid flag set?
2287 bra TFT_display_ftts_6 ; NO - keep memo color 2939 bra TFT_display_ftts_6 ; NO - keep memo color
2288 bcf hi,int_invalid_flag ; YES - clear flag 2940 bcf hi,int_invalid_flag ; YES - clear flag
2289 call TFT_disabled_color ; - switch to disabled color 2941 FONT_COLOR_DISABLED ; - switch to disabled color
2290 TFT_display_ftts_6: 2942 TFT_display_ftts_6:
2291 btfsc hi,int_not_yet_computed ; is the not-yet-computed flag set? 2943 btfsc hi,int_not_yet_computed ; is the not-yet-computed flag set?
2292 bra TFT_display_ftts_8 ; YES - show dashes 2944 bra TFT_display_ftts_8 ; YES - show dashes
2293 IFDEF _cave_mode 2945 IFDEF _cave_mode
2294 btfsc cave_mode ; cave mode switched on? 2946 btfsc cave_mode ; cave mode switched on?
2296 ENDIF 2948 ENDIF
2297 movff int_O_TST_alt+1,WREG ; get high byte of the alternative total stops time 2949 movff int_O_TST_alt+1,WREG ; get high byte of the alternative total stops time
2298 btfsc WREG,int_is_zero ; total stops time = zero ? 2950 btfsc WREG,int_is_zero ; total stops time = zero ?
2299 bra TFT_display_ftts_9 ; YES - show "NDL" 2951 bra TFT_display_ftts_9 ; YES - show "NDL"
2300 btfsc WREG,deco_zone ; NO - fTTS <= TTS ? 2952 btfsc WREG,deco_zone ; NO - fTTS <= TTS ?
2301 call TFT_advice_color ; YES - set to advice color (green) 2953 FONT_COLOR_ADVICE ; YES - set to advice color (green)
2302 TFT_display_ftts_7: 2954 TFT_display_ftts_7:
2303 output_16 ; print ascent time 2955 bsf leftbind ; print left-aligned
2956 output_999 ; print ascent time (0-999)
2304 PUTC "'" ; print minutes symbol 2957 PUTC "'" ; print minutes symbol
2305 bra TFT_display_ftts_10 ; continue 2958 bra TFT_message_close ; finalize message output
2306 TFT_display_ftts_8: 2959 TFT_display_ftts_8:
2307 STRCAT "---" ; print "---" for not computed 2960 STRCAT "---" ; print "---" for not computed
2308 bra TFT_display_ftts_10 ; continue 2961 bra TFT_message_close ; finalize message output
2309 TFT_display_ftts_9: 2962 TFT_display_ftts_9:
2310 STRCAT_TEXT tNDL ; print "NDL" 2963 STRCAT_TEXT tNDL ; print "NDL"
2311 TFT_display_ftts_10: 2964 bra TFT_message_close ; finalize message output
2312 movlw dm_warning_length ; dive mode string length 2965
2313 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 2966
2314 STRCAT_PRINT "" ; finalize output 2967 ;-----------------------------------------------------------------------------
2315 bcf leftbind ; clear left alignment 2968 ; Dive Mode - Message - ppO2
2316 goto TFT_standard_color ; ...and return 2969 ;
2317 2970 global TFT_message_ppo2
2318 2971 TFT_message_ppo2:
2319 ;============================================================================= 2972 call TFT_message_open ; set row and column for the message
2320
2321 global TFT_temp_surfmode
2322 TFT_temp_surfmode:
2323 call TFT_divemask_color
2324 WIN_SMALL surf_temp_column+3*8,surf_temp_row
2325 TSTOSS opt_units ; 0=°C, 1=°F
2326 bra TFT_temp_surfmode_metric
2327 STRCAT_TEXT tLogTunitF ; °F
2328 bra TFT_temp_surfmode_common
2329 TFT_temp_surfmode_metric:
2330 STRCAT_TEXT tLogTunitC ; °C
2331 TFT_temp_surfmode_common:
2332 STRCAT_PRINT ""
2333 WIN_SMALL surf_temp_column,surf_temp_row
2334 call TFT_memo_color
2335 bra TFT_temp_common
2336
2337
2338 global TFT_show_temp_divemode
2339 TFT_show_temp_divemode:
2340 btfsc dive_options_menu ; is the pre-menu shown?
2341 return ; YES - abort
2342 btfsc dive_main_menu ; is the dive mode menu shown?
2343 return ; YES - abort, no update of temperature now
2344 btfsc better_gas_blinking ; blinking better gas?
2345 return ; YES - abort, no update of temperature now
2346 btfsc better_dil_blinking ; blinking better diluent?
2347 return ; YES - abort, no update of temperature now
2348
2349 WIN_SMALL dm_temp_column,dm_temp_row ; set position
2350 call TFT_memo_color ; set color
2351 movlw index_compass_dm ; index of compass custom view
2352 cpfseq active_customview ; compass shown in custom view?
2353 bra TFT_temp_common ; NO - proceed with temperature
2354 goto TFT_update_stopwatch ; YES - show resettable dive time instead of temperature
2355 TFT_temp_common:
2356 SMOVII temperature_cur,mpr ; ISR-safe 2 byte copy of current temperature to hi:lo
2357 TSTOSC opt_units ; 0=°C, 1=°F
2358 call convert_celsius_to_fahrenheit ; 1 - convert value in lo:hi from Celsius to Fahrenheit
2359 rcall TFT_convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required
2360 btfsc neg_flag ; is the temperature negative?
2361 bra TFT_temp_common_2 ; YES - the minus sign has already been written
2362 ; temp is positive, is it less than 10°C ?
2363 tstfsz hi
2364 bra TFT_temp_common_1 ; > 25.5°C, skip here
2365 movlw .100
2366 cpfslt lo
2367 bra TFT_temp_common_1 ; > 10.0°C, skip here
2368 bsf leftbind
2369 output_16dp d'4' ; x.y°C
2370 bcf leftbind
2371 bra TFT_temp_common_3 ; done
2372 TFT_temp_common_1:
2373 PUTC " " ; NO - write a space instead of the minus sign
2374 TFT_temp_common_2:
2375 bsf ignore_digit5 ; ignore decimal (flag will be cleared by output_16)
2376 output_16_3 ; output 0-999 without decimal -> writes ' ' - 99
2377 movff buffer+2,lo ; get output from unit position
2378 movlw " " ; load code of the space character
2379 cpfseq lo ; is there a space sign on the unit position? (happens between +1 and -1)
2380 bra TFT_temp_common_3 ; NO
2381 movff WREG,buffer+0 ; YES - replace potential minus sign with a space (temps from -0.9° to -0.1° else would appear as '- 0')
2382 movlw "0" ; load code of the zero character
2383 movff WREG,buffer+2 ; replace space with a zero
2384 TFT_temp_common_3:
2385 btfss divemode ; are we in dive mode?
2386 bra TFT_temp_common_5 ; NO - no unit to append
2387 TSTOSS opt_units ; YES - check unit type: 0=°C, 1=°F
2388 bra TFT_temp_common_4 ; go metric
2389 STRCAT_TEXT tLogTunitF ; append °F
2390 bra TFT_temp_common_5
2391 TFT_temp_common_4:
2392 STRCAT_TEXT tLogTunitC ; append °C
2393 TFT_temp_common_5:
2394 STRCAT_PRINT "" ; output to screen
2395 TFT_temp_common_6:
2396 goto TFT_standard_color ; done
2397
2398
2399 ;=============================================================================
2400
2401 global TFT_show_menu_cursor_divemode
2402 TFT_show_menu_cursor_divemode:
2403 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1
2404 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1
2405 call TFT_standard_color
2406
2407 movlw dm_menu_item1_column-.8
2408 btfsc menu_pos_cur,2 ; > 3 ?
2409 movlw dm_menu_item4_column-.8 ; YES
2410 movwf win_leftx2
2411
2412 movff menu_pos_cur,lo ; copy menu position
2413 movlw dm_menu_item6_row
2414 dcfsnz lo,F
2415 movlw dm_menu_item1_row
2416 dcfsnz lo,F
2417 movlw dm_menu_item2_row
2418 dcfsnz lo,F
2419 movlw dm_menu_item3_row
2420 dcfsnz lo,F
2421 movlw dm_menu_item4_row
2422 dcfsnz lo,F
2423 movlw dm_menu_item5_row
2424 movwf win_top
2425 movlw FT_SMALL
2426 movwf win_font
2427 STRCPY_PRINT "\xb7" ; print cursor
2428 return
2429
2430 ;=============================================================================
2431
2432 global TFT_show_active_gas_divemode
2433 TFT_show_active_gas_divemode: ; display gas (OC) or setpoint/ppO2 & gas (CCR, pSCR)
2434 btfsc dive_main_menu ; is the dive mode menu shown?
2435 return ; YES - abort
2436 btfsc FLAG_apnoe_mode ; in apnoe mode?
2437 return ; YES - done
2438 btfsc FLAG_gauge_mode ; in gauge mode?
2439 return ; YES - done
2440
2441 IFDEF _ccr_pscr
2442 btfsc FLAG_oc_mode ; in OC mode?
2443 bra TFT_active_gas ; YES - show OC gas
2444 ;bra TFT_active_sp ; NO - show setpoint and diluent
2445
2446 TFT_active_sp:
2447 btfss bailout_mode ; in bailout?
2448 bra TFT_active_sp_loop ; NO
2449 ;bra TFT_active_sp_bailout ; YES
2450
2451 TFT_active_sp_bailout:
2452 WIN_SMALL dm_active_dil_column, dm_active_dil_row
2453 call TFT_attention_color ; - set color
2454 STRCPY_TEXT_PRINT tDiveBailout ; - print "Bailout"
2455 bra TFT_active_gas ; - continue showing OC bailout gas
2456
2457 TFT_active_sp_loop:
2458 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] to hi:lo
2459 call TFT_color_code_ppo2 ; color-code the output by the ppO2 of the loop gas mixture
2460 btfss timebase_1sec ; on even second?
2461 bra TFT_active_sp_print ; YES - print ppO2 with normal rendering
2462 btfsc sp_fallback ; NO - check if in fallback condition
2463 bra TFT_active_sp_fallback ; YES - process fallback case
2464 movff int_O_breathed_ppO2+1,WREG ; NO - get flags again (have been cleared in hi:lo by TFT_color_code_ppo2 meanwhile)
2465 btfss WREG,int_warning_flag ; warning flag set?
2466 bra TFT_active_sp_print ; NO - ppO2 is ok, print ppO2 with normal rendering
2467 bra TFT_active_sp_invers ; YES - print with inverse rendering
2468 TFT_active_sp_fallback: ; set up fallback case
2469 call TFT_attention_color ; set color to yellow
2470 TFT_active_sp_invers: ; blinking common part
2471 bsf win_invert ; print in inverse
2472 TFT_active_sp_print: ; set position
2473 WIN_MEDIUM dm_active_gas_sp_value_col, dm_active_gas_sp_value_row
2474 bsf leftbind ; print left-aligned
2475 output_16dp .3 ; print ppO2 as x.xx
2476 bcf leftbind ; back to right alignment
2477 STRCAT_PRINT "" ; finalize output
2478 bcf win_invert ; end inverse printing
2479
2480 btfsc sign_shown ; advice/attention/warning sign shown?
2481 bra TFT_active_diluent ; YES - skip display of "bar" and loop mode
2482
2483 btfsc velocity_active_vsi ; graphical vertical speed indicator shown?
2484 bra TFT_active_diluent ; YES - skip display of "bar" and loop mode
2485
2486 TFT_active_sp_label:
2487 WIN_STD dm_active_sp_label_col, dm_active_sp_label_row
2488 call TFT_memo_color ; select memo color
2489 STRCAT "bar" ; print "bar"
2490 IFDEF _external_sensor
2491 movff opt_ccr_mode,WREG ; get setpoint mode =0: Fixed SP, =1: Sensor, =2: Auto SP
2492 sublw .1 ; opt_ccr_mode = 1 (Sensor) ?
2493 bnz TFT_active_sp_label_1 ; NO - skip
2494 btfsc alt_layout_active ; YES - in alternative layout?
2495 bra TFT_active_sp_label_1 ; YES - no space available for the "*"
2496 PUTC "*" ; NO - add "*"
2497 TFT_active_sp_label_1:
2498 ENDIF
2499 STRCAT_PRINT "" ; finalize output
2500
2501 TFT_active_loop_mode:
2502 WIN_TINY dm_active_sp_label_col, dm_active_dil_row+.3
2503 call TFT_memo_color ; set memo color
2504 btfsc FLAG_ccr_mode ; in CCR mode?
2505 bra TFT_active_loop_mode_ccr ; YES - print CCR label
2506 btfsc FLAG_pscr_mode ; in pSCR mode?
2507 bra TFT_active_loop_mode_pscr ; YES - print pSCR label
2508 bra TFT_active_diluent ; NO to both - should not happen
2509 TFT_active_loop_mode_ccr:
2510 STRCPY_TEXT_PRINT tDvCCR ; print "CCR"
2511 bra TFT_active_diluent ; continue with diluent
2512 TFT_active_loop_mode_pscr:
2513 STRCPY_TEXT_PRINT tDvPSCR ; print "pSCR"
2514 ;bra TFT_active_diluent ; continue with diluent
2515
2516 TFT_active_diluent:
2517 MOVII int_O_pure_ppO2,mpr ; get ppO2 [cbar] into hi:lo
2518 call TFT_color_code_ppo2 ; color-code the output
2519 btfss better_dil_available ; better diluent available?
2520 bra TFT_active_diluent_show ; NO - print in normal rendering
2521 btg better_dil_blinking ; YES - toggle blink bit...
2522 btfss better_dil_blinking ; blink now?
2523 bra TFT_active_diluent_show ; NO - print in normal rendering
2524 call TFT_attention_color ; YES - print in yellow color
2525 bsf win_invert ; - print in inverse
2526 TFT_active_diluent_show:
2527 WIN_SMALL dm_active_dil_column, dm_active_dil_row
2528 bra TFT_active_dil_gas_common ; continue with common part
2529 ENDIF ; _ccr_pscr
2530
2531 TFT_active_gas:
2532 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] into hi:lo
2533 call TFT_color_code_ppo2 ; color-code the output
2534 btfss better_gas_available ; better gas available?
2535 bra TFT_active_gas_print ; NO - print in normal rendering
2536 btg better_gas_blinking ; YES - toggle blink bit
2537 btfss better_gas_blinking ; blink now?
2538 bra TFT_active_gas_print ; NO - print in normal rendering
2539 call TFT_attention_color ; YES - blink in yellow
2540 bsf win_invert ; print in inverse
2541 TFT_active_gas_print:
2542 WIN_STD dm_active_gas_sp_value_col, dm_active_sp_label_row
2543 TFT_active_dil_gas_common:
2544 movff char_I_O2_ratio,lo ; lo now stores O2 in %
2545 IFDEF _helium
2546 movff char_I_He_ratio,hi ; hi now stores He in %
2547 ELSE
2548 clrf hi ; set hi to zero (no He)
2549 ENDIF
2550 call gaslist_show_mix ; print "Nxlo", "Txlo/hi", "Air" or "O2"
2551 STRCAT_PRINT "" ; finalize output
2552 bcf win_invert ; end inverse printing
2553 goto TFT_standard_color ; done
2554
2555 ;=============================================================================
2556
2557 global TFT_decotype_surface
2558 TFT_decotype_surface:
2559 WIN_STD surf_decotype_column,surf_decotype_row
2560 WIN_COLOR color_lightblue
2561 movff opt_dive_mode,lo ; 0=OC, 1=CCR, 2=Gauge, 3=Apnoe, 4=pSCR
2562 tstfsz lo ; in OC mode?
2563 bra TFT_decotype_surface_2 ; NO
2564 TFT_decotype_surface_1:
2565 STRCAT_TEXT_PRINT tDvOC ; OC
2566 bra TFT_display_decotype_exit
2567 TFT_decotype_surface_2:
2568 decfsz lo,F ; in CCR mode?
2569 bra TFT_decotype_surface_3 ; NO
2570 IFDEF _ccr_pscr
2571 STRCAT_TEXT_PRINT tDvCC ; YES
2572 call TFT_standard_color
2573 WIN_TINY surf_decotype_column+.18,surf_decotype_row+.12
2574 TSTOSS opt_ccr_mode ; > 0, i.e. not Fixed SP ?
2575 bra TFT_display_decotype_cc_fixed ; NO - fixed then
2576 IFDEF _external_sensor
2577 ; Sensor or Auto SP mode
2578 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
2579 sublw .2 ; mode = Auto SP ?
2580 bz TFT_display_decotype_cc_auto ; YES
2581 STRCPY_TEXT tCCRModeSensor ; NO - Sensor
2582 bra TFT_display_decotype_cc_common ;
2583 ENDIF ; _external_sensor
2584 TFT_display_decotype_cc_auto:
2585 STRCPY_TEXT tCCRModeAutoSP ; Auto SP
2586 bra TFT_display_decotype_cc_common
2587 TFT_display_decotype_cc_fixed:
2588 STRCPY_TEXT tCCRModeFixedSP ; fixed SP
2589 TFT_display_decotype_cc_common:
2590 clrf WREG
2591 movff WREG,buffer+.8 ; limit string length to 8
2592 STRCAT_PRINT ""
2593 bra TFT_display_decotype_exit
2594 ENDIF ; _ccr_pscr
2595 TFT_decotype_surface_3:
2596 decfsz lo,F ; in gauge mode?
2597 bra TFT_decotype_surface_4 ; NO
2598 TFT_decotype_surface_3_1: ; YES
2599 STRCAT_TEXT_PRINT tDvGauge
2600 bra TFT_display_decotype_exit
2601 TFT_decotype_surface_4:
2602 decfsz lo,F ; in apnea mode?
2603 bra TFT_decotype_surface_5 ; NO
2604 TFT_decotype_surface_4_1: ; YES
2605 STRCAT_TEXT_PRINT tDvApnea
2606 bra TFT_display_decotype_exit
2607 TFT_decotype_surface_5:
2608 STRCAT_TEXT_PRINT tDvPSCR ; last but not least: must be pSCR then
2609 TFT_display_decotype_exit:
2610 goto TFT_standard_color ; and return...
2611
2612
2613 global TFT_decotype_logbook
2614 TFT_decotype_logbook: ; used from logbook and from deco calculator (simulator.asm)
2615 bsf aux_flag ; default to dive with deco calculation
2616 tstfsz lo ; lo holds 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR, in OC mode?
2617 bra TFT_decotype_logbook_1_2 ; NO
2618 bra TFT_decotype_surface_1 ; YES - OC
2619 TFT_decotype_logbook_1_2:
2620 decfsz lo,F ; in CCR mode?
2621 bra TFT_decotype_logbook_1_3 ; NO
2622 STRCAT_TEXT_PRINT tDvCC ; YES - print "CCR"
2623 bra TFT_display_decotype_exit ; - done
2624 TFT_decotype_logbook_1_3:
2625 decfsz lo,F ; in gauge mode?
2626 bra TFT_decotype_logbook_1_4 ; NO
2627 bcf aux_flag ; YES - dive without deco data
2628 bra TFT_decotype_surface_3_1 ; - gauge
2629 TFT_decotype_logbook_1_4:
2630 decfsz lo,F ; in apnea mode?
2631 bra TFT_decotype_logbook_1_5 ; NO
2632 bcf aux_flag ; YES - dive without deco data
2633 bra TFT_decotype_surface_4_1 ; - apnea
2634 TFT_decotype_logbook_1_5:
2635 bra TFT_decotype_surface_5 ; last but not least: must be pSCR then
2636
2637 ;=============================================================================
2638
2639 IFDEF _ccr_pscr
2640
2641 global TFT_splist_surfmode ; show setpoint list
2642 TFT_splist_surfmode:
2643 bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint
2644 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
2645 ;SP 1
2646 WIN_SMALL surf_gaslist_column,surf_gaslist_row
2647 clrf PRODL
2648 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2649 STRCAT_PRINT ""
2650 ;SP 2
2651 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
2652 movlw .1
2653 movwf PRODL
2654 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2655 STRCAT_PRINT ""
2656 ;SP 3
2657 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)
2658 movlw .2
2659 movwf PRODL
2660 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2661 STRCAT_PRINT ""
2662 ;SP 4
2663 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)
2664 movlw .3
2665 movwf PRODL
2666 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2667 STRCAT_PRINT ""
2668 ;SP 5
2669 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4)
2670 movlw .4
2671 movwf PRODL
2672 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2673 STRCAT_PRINT ""
2674 bcf leftbind
2675 return
2676
2677 ENDIF
2678
2679 ;=============================================================================
2680
2681 global TFT_gaslist_surfmode
2682 TFT_gaslist_surfmode: ; displays gas list
2683 bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint
2684 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
2685 ;Gas 1
2686 WIN_SMALL surf_gaslist_column,surf_gaslist_row
2687 clrf PRODL
2688 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string
2689 STRCAT_PRINT ""
2690 ;Gas 2
2691 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
2692 movlw .1
2693 movwf PRODL
2694 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string
2695 STRCAT_PRINT ""
2696 ;Gas 3
2697 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)
2698 movlw .2
2699 movwf PRODL
2700 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string
2701 STRCAT_PRINT ""
2702 ;Gas 4
2703 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)
2704 movlw .3
2705 movwf PRODL
2706 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string
2707 STRCAT_PRINT ""
2708 ;Gas 5
2709 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4)
2710 movlw .4
2711 movwf PRODL
2712 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string
2713 STRCAT_PRINT ""
2714 bcf leftbind
2715 bcf win_invert ; clear flag for inverted output
2716 return
2717
2718 ;=============================================================================
2719
2720 IFDEF _ccr_pscr
2721
2722 global TFT_dillist_surfmode
2723 TFT_dillist_surfmode: ; displays diluent list
2724 bsf is_diluent_menu ; enable using diluents
2725 rcall TFT_gaslist_surfmode ; use OC gas routine
2726 bcf is_diluent_menu ; disable using diluents
2727 return
2728
2729 ENDIF
2730
2731 ;==================================================================
2732
2733 global TFT_show_depth
2734 TFT_show_depth:
2735 MOVII pressure_rel_cur_cached,mpr ; copy relative pressure to MPR
2736 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
2737 call TFT_color_code_depth ; set warning / attention flags and color-code the output
2738 rcall TFT_depth_blink ; control animation (blinking)
2739 rcall TFT_depth_position_m_ft ; set output position
2740
2741 TSTOSS opt_units ; 0=m, 1=ft ?
2742 bra TFT_depth_metric ; 0 - metric
2743 ;bra TFT_depth_imperial ; 1 - imperial
2744
2745 TFT_depth_imperial:
2746 MOVLI .30,sub_a ; display 0 ft if shallower than 30 cm
2747 MOVII mpr,sub_b
2748 call cmpU16 ; compare (sub_a - sub_b)
2749 btfss neg_flag ; depth shallower than 30 cm ?
2750 bra depth_0_feet ; YES - print a zero directly
2751 call convert_cm_to_feet ; NO - convert value in hi:lo from [cm] to [feet]
2752 output_16_3 ; - feet in large or huge font
2753 STRCAT_PRINT "" ; - finalize output
2754 TFT_depth_imperial_1:
2755 bcf win_invert ; - reset invert flag
2756 bra TFT_depth_exit ; - show target depth if in simulator mode and return
2757
2758 depth_0_feet:
2759 STRCAT_PRINT " 0" ; print a zero directly
2760 bra TFT_depth_imperial_1 ; continue with common part
2761
2762 TFT_depth_metric:
2763 ; full meters
2764 MOVLI .9999,sub_a ; 9999 mbar = 99.99 m
2765 MOVII mpr, sub_b ; current depth
2766 call cmpU16 ; compare (sub_a - sub_b)
2767 btfsc neg_flag ; current depth < 100 meter ?
2768 bra TFT_depth_metric_100m ; NO - current depth >= 100 meter
2769
2770 btfsc cur_depth_greater_100m ; was the current depth >= 100 meter during last call?
2771 rcall TFT_depth_box_black ; YES - clear depth area
2772 bcf cur_depth_greater_100m ; current depth is now < 100 meter
2773
2774 MOVLI .999,sub_a ; 999 mbar = 9.99 meter
2775 MOVII mpr, sub_b ; current depth
2776 call cmpU16 ; compare (sub_a - sub_b)
2777 movlw ' ' ; load coding of a space char
2778 btfss neg_flag ; current depth < 10 meter ?
2779 movwf POSTINC2 ; YES - print a leading space char
2780
2781 MOVLI .99,sub_a ; 99 mbar = 99 cm
2782 MOVII mpr,sub_b ; current depth
2783 call cmpU16 ; compare (sub_a - sub_b)
2784 btfss neg_flag ; current depth < 1 meter ?
2785 bra TFT_depth_metric_0m ; YES - (1)
2786 bsf ignore_digit4 ; NO - show depth in full meters, i.e. ignore digits 4 and 5
2787 bsf leftbind ; - print left-aligned
2788 output_16 ; - print depth
2789 bcf leftbind ; - reset alignment
2790 bra TFT_depth_metric_com ; - continue with common part
2791 TFT_depth_metric_0m:
2792 STRCAT "0" ; (1) - print a zero directly
2793 TFT_depth_metric_com:
2794 STRCAT_PRINT "" ; finalize output
2795
2796 ; decimeters
2797 rcall TFT_depth_position_dm ; set output position
2798 PUTC "." ; print a decimal point
2799 MOVLI .30,sub_a ; 30 mbar = 0.3 meter
2800 MOVII mpr,sub_b ; current depth
2801 call cmpU16 ; compare (sub_a - sub_b)
2802 btfss neg_flag ; current depth < 0.3 meter ?
2803 bra depth_0_decimeter ; YES - (2)
2804 movlw d'4' ; NO - omit leading digits holding the meters
2805 movwf ignore_digits ; - ...
2806 bsf ignore_digit5 ; - omit last digit holding the centimeters
2807 output_16dp d'0' ; - print decimeters only
2808 STRCAT_PRINT "" ; - finalize output
2809 bcf win_invert ; - reset invert flag
2810 bra TFT_depth_exit ; - show target depth if in simulator mode and return
2811 depth_0_decimeter:
2812 STRCAT_PRINT "0" ; (2) - print a zero directly and finalize output
2813 bcf win_invert ; - reset invert flag
2814 bra TFT_depth_exit ; - show target depth if in simulator mode and return
2815
2816 TFT_depth_metric_100m: ; show full meters only
2817 btfss cur_depth_greater_100m ; was the current depth >= 100 meter during last call?
2818 rcall TFT_depth_box_black ; NO - clear depth area
2819 bsf cur_depth_greater_100m ; depth is >= 100 meter now
2820 bsf ignore_digit4 ; show depth in full meters, i.e. ignore digits 4 and 5
2821 bsf leftbind ; print left-aligned
2822 output_16 ; print depth
2823 bcf leftbind ; reset alignment
2824 STRCAT_PRINT "" ; finalize output
2825 bcf win_invert ; reset invert flag
2826 bra TFT_depth_exit ; show target depth if in simulator mode and return
2827
2828 TFT_depth_blink:
2829 TSTOSS opt_depth_warn ; 0=standard, 1=blink
2830 return ; standard, done
2831 btfsc depth_warn_att_last ; was there a warning or attention on the depth in the previous cycle?
2832 bra TFT_depth_blink_prev ; YES
2833 btfsc depth_warning ; NO - do we have a depth warning now?
2834 bra TFT_depth_blink_new ; YES - so we have a warning now but not previously
2835 btfsc depth_attention ; NO - do we have a depth attention now?
2836 bra TFT_depth_blink_new ; YES - so we have attention now but not previously
2837 bra TFT_depth_blink_none ; NO - no warning in previous cycle, no warning now, reset all flags
2838
2839 TFT_depth_blink_prev:
2840 ; we had a warning or attention in previous cycle, check if we still have a warning or attention
2841 btfsc depth_warning ; do we still have a warning?
2842 bra TFT_depth_blink_prev_1 ; YES
2843 btfsc depth_attention ; NO - do we still have an attention?
2844 bra TFT_depth_blink_prev_1 ; YES
2845 ; we had a warning or attention before, but not now any more - clear depth area from previous color
2846 rcall TFT_depth_box_black ; NO - clear depth area
2847 ;bra TFT_depth_blink_none ; - reset all flags
2848
2849 TFT_depth_blink_none:
2850 bcf win_invert ; print non-inverted
2851 bcf depth_inverse_last ; memorize depth was printed in normal
2852 bcf depth_warn_att_last ; memorize there was no warning or attention
2853 goto TFT_memo_color ; select memo color and return
2854
2855 TFT_depth_blink_prev_1:
2856 ; we had a warning or attention in previous cycle, and we still have a warning or attention
2857 btfss depth_inverse_last ; was the depth printed in inverse last time?
2858 bra TFT_depth_blink_set ; NO - print in inverse now
2859 bra TFT_depth_blink_reset ; YES - print in normal now
2860
2861 TFT_depth_blink_new:
2862 ; we had no warning or attention in previous cycle, but now
2863 bsf depth_warn_att_last ; memorize that the depth had a warning or attention
2864 ;bra TFT_depth_blink_set ; start with inverse display
2865
2866 TFT_depth_blink_set:
2867 ; fill the area with respective color
2868 call TFT_attention_color_dive ; select attention color as default
2869 btfsc depth_warning ; do we have a warning?
2870 call TFT_warnings_color_dive ; YES - replace with warning color
2871 rcall TFT_depth_box_color ; color depth area
2872 bsf win_invert ; print in inverse
2873 bsf depth_inverse_last ; memorize depth was printed in inverse
2874 return ; done
2875
2876 TFT_depth_blink_reset:
2877 ; fill the area with black color
2878 rcall TFT_depth_box_black ; clear depth area
2879 bcf win_invert ; print non-inverted
2880 bcf depth_inverse_last ; memorize depth was printed in normal
2881 return ; done
2882
2883
2884 TFT_depth_position_m_ft:
2885 btfsc alt_layout_active ; alternative layout active?
2886 bra TFT_depth_position_m_ft_alt ; YES - (1)
2887 WIN_LARGE dm_depth_col_large,dm_depth_row_large ; NO - normal layout
2888 return ; - done
2889 TFT_depth_position_m_ft_alt:
2890 WIN_HUGE dm_depth_col_huge, dm_depth_row_huge ; (1) - alternative layout
2891 return ; - done
2892
2893 TFT_depth_position_dm:
2894 btfsc alt_layout_active ; alternative layout active?
2895 bra TFT_depth_position_dm_alt ; YES - (1)
2896 WIN_MEDIUM dm_depth_dm_col_medium, dm_depth_dm_row_medium ; NO - normal layout
2897 return ; - done
2898 TFT_depth_position_dm_alt:
2899 WIN_LARGE dm_depth_dm_col_large, dm_depth_dm_row_large ; (1) - alternative layout
2900 return ; - done
2901
2902 TFT_depth_box_black:
2903 clrf WREG ; select black color
2904 TFT_depth_box_color:
2905 movff win_color1,mpr+2 ; backup output color
2906 movff win_color2,mpr+3 ; ...
2907 btfsc alt_layout_active ; alternative layout active?
2908 bra TFT_depth_box_alt ; YES - (1)
2909 WIN_BOX_COLOR dm_depth_row_large,dm_depth_bot_large,dm_depth_col_large,dm_depth_rgt_large ; NO - top, bottom, left, right
2910 bra TFT_depth_box_exit ; - continue with common part
2911 TFT_depth_box_alt:
2912 WIN_BOX_COLOR dm_mask_depth_row, dm_depth_bot_huge, dm_depth_col_huge, dm_depth_rgt_huge ; (1) - full meters area
2913 TFT_depth_box_exit:
2914 movff mpr+2,win_color1 ; restore output color
2915 movff mpr+3,win_color2 ; ...
2916 return ; done
2917
2918 TFT_depth_exit:
2919 btfss alt_layout_active ; alternative layout active?
2920 bra TFT_depth_exit_1 ; NO
2921 btfsc depth_inverse_last ; YES - was last output in inverse mode?
2922 bra TFT_depth_exit_1 ; YES
2923 call TFT_divemask_color ; NO - set color
2924 WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; - set position
2925 STRCAT_TEXT_PRINT tDepth ; - restore "Depth" title
2926 TFT_depth_exit_1:
2927 btfss sensor_override_active ; pressure sensor override active (simulator mode)?
2928 goto TFT_standard_color ; NO - done
2929 ;bra TFT_depth_target ; YES - show target depth
2930
2931 TFT_depth_target: ; show simulated target depth
2932 call TFT_attention_color ; select attention color
2933 TSTOSS opt_units ; check unit selection (0=m or 1=ft)
2934 bra TFT_depth_target_metric ; 0 - metric
2935 ;bra TFT_depth_target_imperial ; 1 - imperial
2936
2937 TFT_depth_target_imperial:
2938 btfsc alt_layout_active ; alternative layout active?
2939 bra TFT_depth_target_imperial_alt ; YES
2940 ;bra TFT_depth_target_imperial_norm ; NO
2941
2942 TFT_depth_target_imperial_norm:
2943 WIN_TINY dm_mask_depth_column+.40,dm_mask_depth_row ; position right of depth label
2944 bra TFT_depth_target_imperial_com ; continue with common part
2945
2946 TFT_depth_target_imperial_alt:
2947 WIN_TINY dm_mask_depth_column+.62,dm_mask_depth_row+.20 ; position within last digit
2948 ;bra TFT_depth_target_imperial_com ; continue with common part
2949
2950 TFT_depth_target_imperial_com:
2951 movff simulatormode_depth,lo ; copy target depth to lo
2952 call convert_meter_to_feet ; convert value in lo from meters to feet
2953 output_16_3 ; display only last three digits from a 16 bit value (0-999)
2954 STRCAT_PRINT "ft" ; finalize output
2955 goto TFT_standard_color ; done
2956
2957 TFT_depth_target_metric:
2958 btfsc alt_layout_active ; alternative layout active?
2959 bra TFT_depth_target_metric_alt ; YES
2960 ;bra TFT_depth_target_metric_norm ; NO
2961
2962 TFT_depth_target_metric_norm:
2963 WIN_TINY dm_mask_depth_column+.38,dm_mask_depth_row+.22 ; position right of full meters, above decimal
2964 bra TFT_depth_target_metric_com ; continue with common part
2965
2966 TFT_depth_target_metric_alt:
2967 WIN_TINY dm_mask_depth_column+.65,dm_mask_depth_row+.20 ; position right of full meters, above decimal
2968 ;bra TFT_depth_target_metric_com ; continue with common part
2969
2970 TFT_depth_target_metric_com:
2971 movff simulatormode_depth,lo ; copy target depth to lo
2972 output_8 ; display number
2973 STRCAT_PRINT "m" ; finalize output
2974 goto TFT_standard_color ; done
2975
2976 ;=============================================================================
2977
2978 global TFT_custom_text
2979 TFT_custom_text: ; show the custom text
2980 lfsr FSR0, opt_name ; source
2981 WIN_SMALL surf_customtext_column,surf_customtext_row1 ; 1st row
2982 rcall TFT_custom_text_2 ; show up to 12 chars and print
2983 incfsz lo,F ; was lo=255?
2984 return ; NO - all done
2985 lfsr FSR0, opt_name+.12 ; source
2986 WIN_SMALL surf_customtext_column,surf_customtext_row2 ; 2nd row
2987 rcall TFT_custom_text_2 ; show up to 12 chars and print
2988 incfsz lo,F ; was lo=255?
2989 return ; NO - all done
2990 lfsr FSR0, opt_name+.24 ; source
2991 WIN_SMALL surf_customtext_column,surf_customtext_row3 ; 3rd row
2992 rcall TFT_custom_text_2 ; show up to 12 chars and print
2993 incfsz lo,F ; was lo=255?
2994 return ; NO - all done
2995 lfsr FSR0, opt_name+.36 ; source
2996 WIN_SMALL surf_customtext_column,surf_customtext_row4 ; 4th row
2997 rcall TFT_custom_text_2 ; show up to 12 chars and print
2998 incfsz lo,F ; was lo=255?
2999 return ; NO - all done
3000 lfsr FSR0, opt_name+.48 ; source
3001 WIN_SMALL surf_customtext_column,surf_customtext_row5 ; 5th row
3002 ;bra TFT_custom_text_2 ; show up to 12 chars, print and return...
3003
3004 TFT_custom_text_2:
3005 lfsr FSR2, buffer ; destination
3006 movlw .12
3007 movwf lo ; length/line
3008 TFT_custom_text_3:
3009 movf POSTINC0,W ; get byte
3010 bz TFT_custom_text_4 ; end if NULL
3011 movwf POSTINC2 ; NO - copy
3012 decfsz lo,F ; max length reached ?
3013 bra TFT_custom_text_3 ; NO - loop
3014 setf lo ; lo=255 -> more to come
3015 TFT_custom_text_4:
3016 clrf POSTINC2 ; mark end of string
3017 goto aa_wordprocessor ; print and return
3018
3019
3020 ;=============================================================================
3021
3022 global TFT_pres_surfmode
3023 TFT_pres_surfmode:
3024 WIN_SMALL surf_press_column+.8,surf_press_row
3025 call TFT_standard_color
3026 SMOVII pressure_abs, sub_a ; make ISR-safe 2 byte copy of current absolute pressure to sub_a
3027 MOVII pressure_abs_ref,sub_b ; copy absolute pressure from 30 minutes ago to sub_b
3028 MOVII sub_a,mpr ; store current pressure also in hi:lo for output
3029 call subU16 ; sub_c = sub_a - sub_b
3030 btfsc neg_flag ; pressure lower?
3031 rcall update_surf_press2 ; YES - swap arguments
3032 tstfsz sub_c+1 ; > 255 mbar difference?
3033 bra update_surf_press_common ; YES - display
3034 movlw .11 ; 10 mbar noise suppression margin
3035 subwf sub_c+0,W
3036 btfsc STATUS,C
3037 bra update_surf_press_common ; YES - display
3038 MOVII pressure_abs_ref,mpr ; NO - overwrite with stable value
3039 update_surf_press_common:
3040 output_16
3041 ; Show only 4 digits
3042 movff buffer+1,buffer+0
3043 movff buffer+2,buffer+1
3044 movff buffer+3,buffer+2
3045 movff buffer+4,buffer+3
3046 movlw 0x00
3047 movff WREG,buffer+4
3048 STRCAT_PRINT ""
3049 call TFT_divemask_color
3050 WIN_SMALL surf_press_column+(4+1)*8,surf_press_row
3051 STRCPY_TEXT_PRINT tMBAR ; mbar (hPa)
3052 return
3053
3054 update_surf_press2:
3055 MOVII sub_a,sub_b
3056 MOVII pressure_abs_ref,sub_a
3057 goto subU16 ; sub_c = sub_a - sub_b and return...
3058
3059 ;=============================================================================
3060
3061 global TFT_batt_surfmode
3062 TFT_batt_surfmode:
3063 ; color-code according to battery percent
3064 movff batt_percent,lo
3065 clrf hi
3066 call TFT_color_code_battery
3067
3068 ; set up charging indicator and temperature warning
3069 clrf WREG ; default to no indication/warning
3070 btfsc cc_active ; charging in CC mode?
3071 movlw color_yellow ; YES - set output color to yellow
3072 btfsc cv_active ; charging in CV mode?
3073 movlw color_green ; YES - set output color to green
3074 btfsc battery_overtemp ; battery over-temperature detector tripped?
3075 movlw color_red ; YES - set output color to red
3076 tstfsz WREG ; any indicator or warning active?
3077 bsf win_invert ; YES - set output to inverse
3078 tstfsz WREG ; any indicator or warning active (asked again)?
3079 call TFT_set_color ; YES - set color
3080
3081 WIN_SMALL batt_percent_column+.2,batt_percent_row
3082 output_16_3 ; display only last three digits from a 16 bit value (0-999)
3083 STRCAT_PRINT "% "
3084 bcf win_invert
3085 call TFT_standard_color
3086 WIN_TINY batt_voltage_column+.15,batt_voltage_row
3087 movff battery_type,lo ; =0: 1.5V, =1: 3.6V Saft, =2: LiIon 3.7V/0.8Ah, =3: LiIon 3.7V/3.1Ah, =4: LiIon 3.7V/2.3Ah
3088 PUTC "T"
3089 bsf leftbind
3090 output_8
3091 PUTC ":"
3092 MOVII batt_voltage,mpr
3093 output_16dp .2 ; print as -x.yyy
3094 bcf leftbind
3095 PUTC 'V'
3096 movff buffer+8,buffer+6
3097 movlw 0x00
3098 movff WREG,buffer+7 ; only "x.yV"
3099 STRCAT_PRINT ""
3100 return
3101
3102 ;update_battery_debug:
3103 ; call TFT_standard_color
3104 ; WIN_TINY .70,.0
3105 ; movff battery_gauge+5,xC+3
3106 ; movff battery_gauge+4,xC+2
3107 ; movff battery_gauge+3,xC+1
3108 ; movff battery_gauge+2,xC+0
3109 ; ; battery_gauge:6 is nAs
3110 ; ; devide through 65536
3111 ; ; devide through 152
3112 ; ; Result is 0.01Ah in xC+1:xC+0
3113 ; MOVLI .152,xB
3114 ; call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
3115 ; bsf leftbind
3116 ; MOVII xC,mpr
3117 ; output_16
3118 ; STRCAT_PRINT "x.01Ah"
3119 ; bcf leftbind
3120 ; return
3121
3122 ;=============================================================================
3123
3124 global TFT_convert_signed_16bit
3125 TFT_convert_signed_16bit:
3126 bcf neg_flag ; clear flag for negative number by default
3127 btfss hi,7 ; negative number?
3128 return ; NO - done
3129 ; YES
3130 bsf neg_flag ; set flag for negative number
3131 PUTC '-' ; display a minus sign ("-")
3132 comf hi ; complement hi:lo
3133 negf lo
3134 btfsc STATUS,C
3135 incf hi
3136 return ; done
3137
3138 ;=============================================================================
3139 ; input: lo year
3140 ; hi month
3141 ; up day
3142 ;
3143 ; output format by option opt_dateformat:
3144 ; 0: MMDDYY
3145 ; 1: DDMMYY
3146 ; 2: YYMMDD
3147 ;
3148 global TFT_convert_date
3149 TFT_convert_date: ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in output buffer
3150 movff opt_dateformat,EEDATA ; get format (EEDATA used as temp here)
3151 tstfsz EEDATA ; shall use format 0 ?
3152 bra TFT_convert_date_1 ; NO - check for format 1 or 2
3153 ; YES - use format 0: MMDDYY
3154 movff lo,hy ; - backup year to hy
3155 movff hi,lo ; - copy month to lo
3156 movff up,hi ; - copy day to hi
3157 movff hy,up ; - copy year to up
3158 bra TFT_convert_date_common ; - start output
3159 TFT_convert_date_1:
3160 decfsz EEDATA,F ; shall use format 1 ?
3161 bra TFT_convert_date_common ; NO - use format 2: YYMMDD - can print directly
3162 ; YES - use format 1: DDMMYY
3163 movff lo,hy ; - backup year to hy
3164 movff up,lo ; - copy day to lo
3165 movff hy,up ; - copy year to up
3166
3167 TFT_convert_date_common:
3168 bsf leftbind ; start left-alignment
3169 output_99x ; print lo
3170 PUTC '.' ; print spacing dot
3171 movff hi,lo ; print hi
3172 output_99x ; ...
3173 PUTC '.' ; print spacing dot
3174 movff up,lo ; print up
3175 output_99x ; ...
3176 bcf leftbind ; end left-alignment
3177 return ; done
3178
3179
3180 ;=============================================================================
3181 ; show date by month & day
3182 ;
3183 ; input: lo year (not used here)
3184 ; hi month
3185 ; up day
3186 ;
3187 ; output format by option opt_dateformat:
3188 ; 0: MMDD(YY)
3189 ; 1: DDMM(YY)
3190 ; 2: (YY)MMDD
3191 ;
3192 global TFT_convert_date_short
3193 TFT_convert_date_short: ; convert into "DD/MM" or "MM/DD" or "MM/DD" into output buffer
3194 movff opt_dateformat,EEDATA ; get format (EEDATA used as temp here)
3195 tstfsz EEDATA ; shall use format 0 ?
3196 bra TFT_convert_date_short2 ; NO - check for format 1 or 2
3197 TFT_convert_date_short1: ; YES - use format 0: MMDD
3198 movff hi,lo ; - copy month to lo
3199 movff up,hi ; - copy day to hi
3200 bra TFT_convert_date_short3 ; - start output
3201 TFT_convert_date_short2:
3202 decfsz EEDATA,F ; format 1 ?
3203 bra TFT_convert_date_short1 ; NO - use format 2: MMDD (here its like format 0)
3204 ; YES - use format 1: DDMM
3205 movff up,lo ; - copy day to lo,
3206 ; - month is already in hi
3207 TFT_convert_date_short3:
3208 bsf leftbind ; start left-alignment
3209 output_99x ; print lo
3210 PUTC '.' ; print spacing dot
3211 movff hi,lo ; print hi
3212 output_99x ; ...
3213 bcf leftbind ; end left-alignment
3214 return ; done
3215
3216 ;=============================================================================
3217
3218 global TFT_date_surfmode
3219 TFT_date_surfmode:
3220 WIN_SMALL surf_date_column,surf_date_row
3221 call TFT_standard_color
3222 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
3223 movff rtc_latched_year, lo
3224 movff rtc_latched_month,hi
3225 movff rtc_latched_day, up
3226 call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
3227 STRCAT_PRINT ""
3228 return
3229
3230 ;=============================================================================
3231
3232 global TFT_show_max_depth
3233 TFT_show_max_depth:
3234 btfsc alt_layout_active ; alternative layout active?
3235 bra TFT_show_max_depth_alt ; YES
3236
3237 WIN_MEDIUM dm_max_depth_column_nvsi, dm_max_depth_row
3238 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
3239 bra TFT_show_max_depth_1 ; NO - keep position
3240 ; YES - adopt output position
3241 WIN_MEDIUM dm_max_depth_column, dm_max_depth_row
3242
3243 TFT_show_max_depth_1:
3244 btfsc FLAG_apnoe_mode ; in apnoe mode?
3245 bra TFT_max_depth_apnoe ; YES - different handling in apnoe mode
3246
3247 TSTOSS opt_2ndDepthDisp ; show average depth instead of max depth?
3248 bra TFT_max_depth_current ; NO - show max depth
3249 ;bra TFT_avg_depth_current ; YES - show avg depth
3250
3251 TFT_avg_depth_current:
3252 MOVII pressure_rel_avg_total,mpr ; YES - get total dive average pressure
3253 bra TFT_max_depth_common ; - continue with common part
3254
3255 TFT_max_depth_apnoe:
3256 btfss apnoe_at_surface ; apnoe mode, at the surface?
3257 bra TFT_max_depth_current ; NO - show max depth of current dive
3258 MOVII apnoe_max_pressure,mpr ; YES - get max pressure of all dives so far
3259 bra TFT_max_depth_common ; - continue with common part
3260
3261 TFT_max_depth_current:
3262 MOVII pressure_rel_max_cached,mpr ; get the "normal" max pressure
3263 ;bra TFT_max_depth_common ; continue with common part
3264
3265 TFT_max_depth_common:
3266 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
3267 TSTOSS opt_units ; 0=m or 1=ft ?
3268 bra TFT_max_depth_metric ; 0 - use metric version
3269 ;bra TFT_max_depth_imperial ; 1 - use imperial version
3270
3271 TFT_max_depth_imperial:
3272 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
3273 call TFT_memo_color ; set output color
3274 output_16_3 ; print depth
3275 bra TFT_max_depth_finish ; finish output
3276
3277 TFT_max_depth_metric:
3278 MOVLI .9999,sub_a ; 9999 mbar = 99.99 m
3279 MOVII mpr, sub_b ; depth, also used to back-up hi:lo
3280 call cmpU16 ; sub_a - sub_b = 99.99 - depth
3281 btfsc neg_flag ; depth < 100 meter ?
3282 bra TFT_max_depth_greater_100m ; NO - greater than 100 m
3283 ;bra TFT_max_depth_shallower_100m; YES - shallower than 100 m
3284
3285 TFT_max_depth_shallower_100m:
3286 btfss max_depth_greater_100m ; was depth >= 100 m during last call?
3287 bra TFT_max_depth_metric_show ; NO - show depth
3288 bcf max_depth_greater_100m ; YES - clear flag, last depth shown now not > 99.84 m anymore
3289 bra TFT_max_depth_clear ; - clear depth area
3290
3291 TFT_max_depth_greater_100m:
3292 btfsc max_depth_greater_100m ; was depth >= 100 m during last call?
3293 bra TFT_max_depth_metric_show ; YES - show depth
3294 bsf max_depth_greater_100m ; NO - set flag, last depth shown now > 99.84 m
3295 ;bra TFT_max_depth_clear ; - clear depth area
3296
3297 TFT_max_depth_clear:
3298 WIN_BOX_BLACK dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt ; top, bottom, left, right
3299 ;bra TFT_max_depth_metric_show
3300
3301 TFT_max_depth_metric_show:
3302 call TFT_memo_color ; set output color
3303 btfss max_depth_greater_100m ; depth to show >= 100 m ?
3304 bra TFT_max_depth_metric_m_dm ; NO - show meters and decimeters
3305 bsf ignore_digit4 ; YES - crop decimeters and centimeters
3306 bsf leftbind ; - print left-aligned
3307 output_16 ; - print depth
3308 bra TFT_max_depth_finish ; - finish output
3309
3310 TFT_max_depth_metric_m_dm:
3311 MOVLI .999,sub_a ; load 9.99 meter
3312 call cmpU16 ; sub_a - sub_b = 9.99 - depth
3313 movlw ' ' ; load a space character
3314 btfss neg_flag ; depth shallower than 10 meter ?
3315 movwf POSTINC2 ; YES - add the space character
3316 MOVLI .99,sub_a ; load 0.99 m
3317 call cmpU16 ; sub_a - sub_b = 0.99 m - depth
3318 btfss neg_flag ; depth shallower than 1 meter ?
3319 bra TFT_max_depth_metric_zero ; YES - manually display a zero
3320 bsf ignore_digit4 ; NO - crop decimeters and centimeters
3321 bsf leftbind ; - align left
3322 output_16 ; - display full meters
3323 STRCAT_PRINT "" ; - finalize output
3324 bra TFT_max_depth_metric_dm ; - continue with decimeters
3325
3326 TFT_max_depth_metric_zero:
3327 STRCAT_PRINT "0" ; print a zero
3328 ;bra TFT_max_depth_metric_dm ; continue with decimeters
3329
3330 TFT_max_depth_metric_dm:
3331 WIN_SMALL dm_max_depth_dm_column_nvsi, dm_max_depth_dm_row
3332 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
3333 bra TFT_max_depth_metric_dm_1 ; NO - keep position
3334 ; YES - adopt position
3335 WIN_SMALL dm_max_depth_dm_column, dm_max_depth_dm_row
3336 TFT_max_depth_metric_dm_1:
3337 PUTC "." ; print decimal point
3338 MOVII sub_b,mpr ; restore depth in hi:lo
3339 movlw d'4' ; crop leading 4 digits (don't show the full meters)
3340 movwf ignore_digits ; ...
3341 bsf ignore_digit5 ; crop last digit (no centimeters, flag will be cleared by output_16)
3342 bsf leftbind ; print left-aligned
3343 output_16dp d'0' ; print decimal
3344 TFT_max_depth_finish:
3345 STRCAT_PRINT "" ; finalize output
3346 bcf leftbind ; back to default right alignment
3347 goto TFT_standard_color ; done
3348
3349
3350 TFT_show_max_depth_alt:
3351 btfsc FLAG_apnoe_mode ; in apnoe mode?
3352 bra TFT_show_apnoe_max_depth ; YES - use apnoe surface output also in alternative dive mode screen
3353 btfsc FLAG_gauge_mode ; NO - in gauge mode?
3354 bra TFT_show_gauge_max_avg_depth; YES - show both, max and avg depth
3355 return ; NO - nothing to do
3356
3357 TFT_show_gauge_max_avg_depth:
3358 call TFT_memo_color ; set color
3359 WIN_MEDIUM dm_gauge_max_depth_col, dm_gauge_max_depth_row ; set position for max depth
3360 rcall TFT_show_gauge_max_depth ; show max depth
3361 call TFT_memo_color ; set color
3362 WIN_MEDIUM dm_gauge_avg_depth_col, dm_gauge_avg_depth_row ; set position for avg depth
3363 MOVII pressure_rel_avg_total,mpr ; get average pressure into hi:lo
3364 bra TFT_show_gauge_depth ; show avg depth and return
3365
3366
3367 global TFT_show_apnoe_max_depth
3368 TFT_show_apnoe_max_depth:
3369 ; title
3370 WIN_TINY dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row
3371 call TFT_divemask_color
3372 btfsc alt_layout_active ; alternative layout active?
3373 bra TFT_show_apnoe_max_depth_alt ; YES
3374 STRCPY_TEXT_PRINT tApnoeMax ; NO - print "Last Descent"
3375 bra TFT_show_apnoe_max_depth_com ; - continue with common part
3376 TFT_show_apnoe_max_depth_alt:
3377 STRCPY_TEXT_PRINT tMaxDepth ; print "Max.Depth"
3378 TFT_show_apnoe_max_depth_com:
3379 ; value
3380 WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
3381 call TFT_memo_color
3382 TFT_show_gauge_max_depth:
3383 MOVII pressure_rel_max_cached,mpr ; get max pressure into hi:lo
3384 ;bra TFT_show_gauge_depth ; show max depth and return
3385
3386 TFT_show_gauge_depth:
3387 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
3388 TSTOSS opt_units ; 0=m, 1=ft
3389 bra TFT_display_apnoe_last_m_metric ; 0 - metric
3390 TFT_display_apnoe_last_max_imp: ; 1 - imperial
3391 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
3392 output_16
3393 bra TFT_max_depth_finish ; finish output
3394 TFT_display_apnoe_last_m_metric:
3395 bsf ignore_digit5 ; do not display centimeters (flag will be cleared by output_16)
3396 output_16dp d'3'
3397 bra TFT_max_depth_finish ; finish output
3398
3399 ;=============================================================================
3400
3401 global TFT_show_divetime
3402 TFT_show_divetime:
3403 call TFT_memo_color ; set color
3404 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 (mpr+1:mpr+0) and seconds (mpr+2)
3405 btfsc show_only_divemins ; shall suppress display of seconds?
3406 bra TFT_show_divetime_min_only ; YES - show minutes only
3407 movlw .99 ; NO - load 99
3408 cpfsgt mpr+0 ; - dive time > 99 minutes ?
3409 bra TFT_show_divetime_min_sec ; NO - show min:sec
3410 bsf show_only_divemins ; YES - set flag to suppress the display of seconds for the rest of the dive
3411 btfsc alt_layout_active ; - in alternative layout?
3412 bra TFT_show_divetime_clear_alt ; YES - clear min:sec area of alternative layout
3413 ;bra TFT_show_divetime_clear_norm ; NO - clear min:sec area of normal layout
3414
3415 TFT_show_divetime_clear_norm:
3416 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_medium, dm_divetime_col_medium, dm_divetime_rgt ;top, bottom, left, right
3417 bra TFT_show_divetime_min_only_norm ; show minutes only
3418
3419 TFT_show_divetime_clear_alt:
3420 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_large, dm_divetime_col_large, dm_divetime_rgt ;top, bottom, left, right
3421 bra TFT_show_divetime_min_only_alt ; show minutes only
3422
3423 TFT_show_divetime_min_sec:
3424 ; show the minutes
3425 btfsc alt_layout_active ; in alternative layout?
3426 bra TFT_show_divetime_min_alt ; YES
3427 ;bra TFT_show_divetime_min_norm ; NO
3428
3429 TFT_show_divetime_min_norm:
3430 WIN_MEDIUM dm_divetime_col_medium, dm_divetime_row
3431 bra TFT_show_divetime_min_com ; continue with common part
3432
3433 TFT_show_divetime_min_alt:
3434 WIN_LARGE dm_divetime_col_large, dm_divetime_row
3435 ;bra TFT_show_divetime_min_com ; continue with common part
3436
3437 TFT_show_divetime_min_com:
3438 output_99 ; displays only last two digits from a 8 bit value (0-99)
3439 STRCAT_PRINT "" ; finalize output
3440
3441 ; show the seconds
3442 btfsc alt_layout_active ; in alternative layout?
3443 bra TFT_show_divetime_sec_alt ; YES
3444 ;bra TFT_show_divetime_sec_norm ; NO
3445
3446 TFT_show_divetime_sec_norm:
3447 WIN_SMALL dm_divetime_sec_col_small, dm_divetime_sec_row_small
3448 bra TFT_show_divetime_sec_com ; continue with common part
3449
3450 TFT_show_divetime_sec_alt:
3451 WIN_MEDIUM dm_divetime_sec_col_medium, dm_divetime_sec_row_medium
3452 ;bra TFT_show_divetime_sec_com ; continue with common part
3453
3454 TFT_show_divetime_sec_com:
3455 PUTC ':' ; print separator char
3456 movff mpr+2,lo ; copy seconds to lo
3457 bsf leftbind ; activate left-alignment
3458 output_99x ; displays only last two figures from a 8 bit value with leading zero (00-99)
3459 bcf leftbind ; deactivate left-alignment
3460 bra TFT_divemins_exit ; continue with common part
3461
3462 TFT_show_divetime_min_only:
3463 btfsc alt_layout_active ; in alternative layout?
3464 bra TFT_show_divetime_min_only_alt ; YES
3465 ;bra TFT_show_divetime_min_only_norm ; NO
3466
3467 TFT_show_divetime_min_only_norm:
3468 WIN_MEDIUM dm_divetime_minonly_col_medium, dm_divetime_row
3469 output_16_4 ; print minutes (4 digits)
3470 bra TFT_divemins_exit ; continue with common part
3471
3472 TFT_show_divetime_min_only_alt:
3473 WIN_LARGE dm_divetime_minonly_col_large, dm_divetime_row
3474 output_16_3 ; print minutes (3 digits)
3475 ;bra TFT_divemins_exit ; continue with common part
3476
3477 TFT_divemins_exit:
3478 STRCAT_PRINT "" ; finalize output
3479 goto TFT_standard_color ; and return...
3480
3481 ;=============================================================================
3482
3483 global TFT_show_apnoe_surface
3484 TFT_show_apnoe_surface:
3485 call TFT_divemask_color
3486 WIN_TINY dm_apnoe_surface_time_text_col, dm_apnoe_surface_time_text_row
3487 STRCPY_TEXT_PRINT tApnoeSurface
3488 call TFT_memo_color
3489 WIN_MEDIUM dm_apnoe_surface_time_column, dm_apnoe_surface_time_row
3490 SMOVII apnoe_surface_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi
3491 output_8
3492 PUTC ':'
3493 movff hi,lo ; copy seconds to lo
3494 output_99x
3495 bra TFT_display_apnoe_exit ; and return...
3496
3497
3498 global TFT_show_apnoe_times
3499 TFT_show_apnoe_times: ; descent dive time
3500 ; current dive time
3501 call TFT_memo_color
3502 WIN_MEDIUM dm_divetime_apnoe_col, dm_divetime_apnoe_row
3503 SMOVII apnoe_dive_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi
3504 output_99 ; display 0-99
3505 STRCAT_PRINT "" ; show minutes
3506 WIN_SMALL dm_divetime_apnoe_secs_col, dm_divetime_apnoe_secs_row ; left position for two sec figures
3507 PUTC ':'
3508 bsf leftbind
3509 movff hi,lo ; copy seconds to lo
3510 output_99x
3511 STRCAT_PRINT "" ; show seconds
3512 ; overall dive time
3513 WIN_MEDIUM dm_apnoe_total_divetime_col, dm_apnoe_total_divetime_row
3514 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 and seconds
3515 clrf hi
3516 bcf leftbind
3517 output_16_3 ; displays only last three figures from a 16 bit value (0-999)
3518 STRCAT_PRINT "" ; show minutes in large font
3519 WIN_SMALL dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row ; left position for two sec figures
3520 PUTC ':'
3521 bsf leftbind
3522 movff up,lo ; copy minutes from up to lo
3523 output_99x
3524 TFT_display_apnoe_exit:
3525 STRCAT_PRINT ""
3526 bcf leftbind
3527 goto TFT_standard_color ; and return...
3528
3529
3530 global TFT_clear_apnoe_surface
3531 TFT_clear_apnoe_surface:
3532 ; clear surface data
3533 WIN_BOX_BLACK dm_apnoe_last_max_depth_text_row, .239, dm_apnoe_last_max_depth_column, .159 ; top, bottom, left, right
3534 goto TFT_standard_color ; and return...
3535
3536
3537 ;-----------------------------------------------------------------------------
3538 ; check if firmware is within expiry period, will return aux_flag set if not
3539
3540 check_expiry: ; check if it is time for a firmware update
3541 SMOVSS rtc_year,rtc_latched_year; ISR-safe 6 byte copy of date and time
3542 movff rtc_latched_day,lo ; get current day
3543 movff rtc_latched_month,hi ; get current month
3544 movff rtc_latched_year,up ; get current year
3545 bsf aux_flag ; set firmware as expired by default
3546 movlw firmware_expire_year ; start with checking year
3547 cpfsgt up ; current year > expiry year ?
3548 bra check_expiry_Y ; NO - continue checks
3549 return ; YES - expired
3550 check_expiry_Y:
3551 cpfseq up ; current year = expiry year ?
3552 bra check_expiry_ok ; NO - must be < then, OK whatever month & day
3553 movlw firmware_expire_month ; YES - continue checking month
3554 cpfsgt hi ; current month > expiry month ?
3555 bra check_expiry_M ; NO - continue checks
3556 return ; YES - expired
3557 check_expiry_M:
3558 cpfseq hi ; current month = expiry month ?
3559 bra check_expiry_ok ; NO - must be < then, OK whatever day
3560 movlw firmware_expire_day ; YES - continue checking day
3561 cpfsgt lo ; current day > expiry day ?
3562 bra check_expiry_ok ; NO - must be <= then, OK
3563 return ; YES - expired
3564 check_expiry_ok:
3565 bcf aux_flag
3566 return
3567
3568 ;-----------------------------------------------------------------------------
3569 ; append firmware BETA status to current string, including color-coding
3570
3571 global TFT_cat_beta_release
3572 TFT_cat_beta_release: ; entry point for printing "Release" / "Beta #"
3573 bsf aux_flag
3574 bra TFT_cat_beta_common
3575 TFT_cat_beta_rel: ; entry point for printing "Rel." / "B. #"
3576 bcf aux_flag
3577 TFT_cat_beta_common:
3578 IFDEF _DEBUG
3579 btfss aux_flag ; shall show long version?
3580 bra TFT_cat_debug_short ; NO - show short version
3581 STRCAT "DEBUG" ; YES - show long version
3582 goto TFT_warning_color ; - set color
3583 TFT_cat_debug_short:
3584 STRCAT "DBG." ; show short version
3585 goto TFT_warning_color ; set color
3586 ELSE
3587 movlw fw_version_beta ; =0: release, =1: beta 1, =2: beta 2, ...
3588 movwf lo ; copy to lo
3589 tstfsz lo ; release version?
3590 bra TFT_cat_beta_1 ; NO - must be beta version then
3591 btfss aux_flag ; YES - shall show long version?
3592 bra TFT_cat_beta_2 ; NO - show short version
3593 rcall check_expiry ; YES - check expiry date
3594 btfsc aux_flag ; - within expiry date?
3595 bra TFT_cat_beta_4 ; NO - give update cue
3596 STRCAT "Release" ; YES - print "Release"
3597 return ; - done
3598 TFT_cat_beta_1:
3599 btfss aux_flag ; shall show long version?
3600 bra TFT_cat_beta_3 ; NO - show short version
3601 STRCAT "Beta " ; YES - show long version
3602 TFT_cat_beta_1a:
3603 bsf leftbind
3604 output_8 ; print beta version number
3605 bcf leftbind
3606 goto TFT_attention_color ; and return
3607 TFT_cat_beta_2
3608 STRCAT "Rel." ; short version for "Release"
3609 return
3610 TFT_cat_beta_3
3611 STRCAT "B." ; short version for "Beta"
3612 bra TFT_cat_beta_1a ; append beta version number
3613 TFT_cat_beta_4
3614 STRCAT "update!" ; print update cue
3615 goto TFT_attention_color ; and return
3616 ENDIF ; ELSE / _DEBUG
3617
3618 ;-----------------------------------------------------------------------------
3619 ; show firmware update message
3620 ;
3621 ; all text outputs are hard-coded since language switching
3622 ; has not yet been initialized when this code is executed
3623
3624 global show_fw_mesg_update
3625 global show_fw_mesg_kept
3626 show_fw_mesg_update:
3627 call TFT_standard_color
3628 ; show update message
3629 WIN_SMALL .20,.100
3630 STRCPY_PRINT "Update successful!"
3631 ; show firmware version
3632 WIN_SMALL .20,.140
3633 STRCPY "New Firmware: "
3634 bra show_fw_mesg_common
3635 show_fw_mesg_kept:
3636 call TFT_standard_color
3637 ; show reboot message
3638 WIN_SMALL .60,.100
3639 STRCPY_PRINT "Reboot"
3640 ; show firmware version
3641 WIN_SMALL .30,.140
3642 STRCPY "Firmware: "
3643 show_fw_mesg_common:
3644 rcall TFT_cat_firmware ; show firmware version x.y and color-code + invert if outdated
3645 STRCAT_PRINT "" ; finalize output
3646 bcf win_invert ; back to normal (non inverted) output
3647 ; show firmware beta status
3648 call TFT_standard_color ; color to use if it is a release version
3649 WIN_SMALL .60,.180
3650 rcall TFT_cat_beta_release ; show "Release" or "BETA" + issue
3651 STRCAT_PRINT "" ; finalize output
3652 goto TFT_standard_color ; reset color and return
3653
3654 ;-----------------------------------------------------------------------------
3655 ; show serial and firmware version for comm mode
3656
3657 global TFT_show_serial_and_firmware
3658 global TFT_show_firmware
3659 TFT_show_serial_and_firmware:
3660 STRCPY "#"
3661 call TFT_cat_serial
3662 STRCAT " "
3663 STRCAT "v"
3664 TFT_show_firmware:
3665 call TFT_cat_firmware ; will set win_invert if outdated
3666 STRCAT " "
3667 call TFT_cat_beta_release
3668 STRCAT_PRINT ""
3669 bcf win_invert ; clear win_invert
3670 goto TFT_standard_color ; ...and return
3671
3672 ;-----------------------------------------------------------------------------
3673 ; For the Information menu: append total dives
3674
3675 global info_menu_total_dives
3676 info_menu_total_dives:
3677 lfsr FSR1,tTotalDives ; locate text
3678 call strcat_text ; print text
3679 TFT_cat_total_dives:
3680 call eeprom_total_dives_read ; read total number of dives
3681 bsf leftbind ; print left-aligned
3682 output_16 ; print number of total dives
3683 bcf leftbind ; quit left-aligned
3684 return ; done
3685
3686 ;-----------------------------------------------------------------------------
3687 ; append firmware version to current string, including color-coding
3688
3689 global TFT_cat_firmware
3690 TFT_cat_firmware:
3691 movlw fw_version_major
3692 movwf lo
3693 bsf leftbind
3694 output_8 ; print major in 1 or 2 digit format
3695 PUTC '.'
3696 movlw fw_version_minor
3697 movwf lo
3698 output_99x ; print minor in two digit format
3699 bcf leftbind
3700 rcall check_expiry ; sets aux_flag if expired
3701 btfss aux_flag ; expired?
3702 return ; NO
3703 bsf win_invert ; YES - print in inverse
3704 goto TFT_attention_color ; - print in attention color (and return)
3705
3706 ;-----------------------------------------------------------------------------
3707 ; For the Information menu: firmware version and creation date
3708
3709 global info_menu_firmware
3710 info_menu_firmware:
3711 lfsr FSR1,tFirmware ; select label text
3712 call strcat_text ; print label
3713 rcall TFT_cat_firmware ; print firmware version
3714 PUTC " " ; print a dot
3715 rcall TFT_cat_beta_rel ; print beta/release
3716 STRCAT_PRINT "" ; finalize output
3717 return ; done
3718
3719 global info_menu_fw_cration_date
3720 info_menu_fw_cration_date:
3721 lfsr FSR1,tFirmwareDate ; select label text
3722 call strcat_text ; print label
3723 movlw firmware_creation_year ; get firmware creation year
3724 movwf lo ; copy to lo
3725 movlw firmware_creation_month ; get firmware creation month
3726 movwf hi ; copy to hi
3727 movlw firmware_creation_day ; get firmware creation day
3728 movwf up ; copy to up
3729 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
3730 return ; done
3731
3732 ;-----------------------------------------------------------------------------
3733 ; For the Information menu: firmware version of the RX processor
3734
3735 IFDEF _rx_functions
3736
3737 global info_menu_firmware_rx
3738 global TFT_print_firmware_rx
3739 info_menu_firmware_rx:
3740 lfsr FSR1,tFirmware_rx
3741 call strcat_text
3742 TFT_print_firmware_rx:
3743 movff rx_firmware_cur_major,lo
3744 bsf leftbind
3745 output_8
3746 PUTC '.'
3747 movff rx_firmware_cur_minor,lo
3748 output_8
3749 bcf leftbind
3750 return
3751
3752 ENDIF
3753
3754 ;-----------------------------------------------------------------------------
3755 ; For the Information menu: serial number
3756
3757 global info_menu_serial
3758 global TFT_cat_serial
3759 info_menu_serial:
3760 lfsr FSR1,tSerial ; locate text
3761 call strcat_text ; print text
3762 TFT_cat_serial:
3763 call eeprom_serial_number_read ; read OSTC serial number
3764 bsf leftbind ; start left-alignment
3765 output_16 ; print serial number
3766 bcf leftbind ; end left-alignment
3767 return ; done
3768
3769 ;-----------------------------------------------------------------------------
3770 ; For the Information menu: hardware / software configuration
3771
3772 global info_menu_config
3773 info_menu_config:
3774 lfsr FSR1,tHardware ; locate text
3775 call strcat_text ; print text
3776 call I2C_init_compass ; start compass
3777 movf HW_descriptor,W ; copy hardware descriptor to WREG
3778 output_hex ; print as hex
3779 PUTC "-" ; print a separator
3780 movf HW_variants,W ; copy hardware variants to WREG
3781 output_hex ; print as hex
3782 PUTC "-" ; print a separator
3783 movlw SW_CONF ; get software configuration
3784 output_hex ; print as hex
3785 return
3786
3787
3788 ;-----------------------------------------------------------------------------
3789 ; For the Information menu: battery voltage
3790
3791 global info_menu_battery_volts
3792 info_menu_battery_volts:
3793 lfsr FSR1,tBatteryV
3794 call strcat_text
3795 MOVII batt_voltage,mpr
3796 bsf leftbind
3797 output_16dp .2 ; print as -x.yyy
3798 STRCAT "V(T"
3799 movff battery_type,lo ; =0:1.5V, =1:3.6V Saft, =2:LiIon 3.7V/0.8Ah, =3:LiIon 3.7V/3.1Ah, =4: LiIon 3.7V/2.3Ah
3800 output_8
3801 bcf leftbind
3802 PUTC ")"
3803 return
3804
3805
3806 ;-----------------------------------------------------------------------------
3807 ; For the Information menu: sensor C1 and C5 values
3808
3809 global info_menu_sensor_calib
3810 info_menu_sensor_calib:
3811 lfsr FSR1,tSensorC ; locate label
3812 call strcat_text ; print label
3813 movff C1+1,WREG ; get C1, high byte
3814 output_hex ; print C1, high byte
3815 movff C1+0,WREG ; get C1, low byte
3816 output_hex ; print C1, low byte
3817 PUTC "-" ; print a separator
3818 movff C5+1,WREG ; get C5, high byte
3819 output_hex ; print C5, high byte
3820 movff C5+0,WREG ; get C5, low byte
3821 output_hex ; print C5, low byte
3822 return ; done
3823
3824
3825 ;-----------------------------------------------------------------------------
3826 ; For the Information menu: sensor depth correction
3827
3828 global info_menu_sensor_offset
3829 info_menu_sensor_offset:
3830 lfsr FSR1,tSensorD ; locate label
3831 call strcat_text ; print label
3832 movff opt_pressure_adjust,WREG ; get pressure sensor offset
3833 btfsc WREG,7 ; value negative?
3834 bra info_menu_sensor_offset_1 ; YES
3835 PUTC "+" ; NO - print plus sign
3836 bra info_menu_sensor_offset_2 ; - continue with common part
3837 info_menu_sensor_offset_1:
3838 PUTC "-" ; print a minus sign
3839 negf WREG ; negate WREG
3840 info_menu_sensor_offset_2:
3841 PUTC " " ; print a space
3842 bsf leftbind ; start left-bind printing
3843 output_8 ; print value
3844 bcf leftbind ; end left-bind printing
3845 PUTC " " ; print a space
3846 lfsr FSR1,tMBAR ; locate unit
3847 call strcat_text ; print unit
3848 return ; done
3849
3850
3851 ;-----------------------------------------------------------------------------
3852 ; For the Information menu: uptime
3853
3854 global info_menu_uptime
3855 info_menu_uptime:
3856 lfsr FSR1,tUptime
3857 call strcat_text
3858 SMOVQQ uptime,xC ; ISR-safe copy of uptime:4 to xC:4
3859
3860 info_menu_uptime_com:
3861 MOVLI .3600,xB ; one hour = 3600s
3862 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder -> xC+1:xC+0 holds full hours
3863 MOVII xC,xA
3864 MOVLI .24,xB ; one day = 24 hours
3865 call div16x16 ; xC:2 = xA:2 / xB:2 with xA as remainder -> xC+1:xC+0 holds full days, xA holds full hours
3866 MOVII xC,mpr ; copy full days into hi:lo
3867 bsf leftbind
3868 output_16
3869 PUTC "d"
3870 movff xA+0,lo ; full hours
3871 output_8
3872 PUTC "h"
3873 bcf leftbind
3874 return ; done
3875
3876 ;-----------------------------------------------------------------------------
3877
3878 IFDEF _compass
3879
3880 global menu_cal_x
3881 menu_cal_x:
3882 lfsr FSR0,compass_CX_f
3883 lfsr FSR1,tCalX
3884 bra menu_cal_common
3885
3886 global menu_cal_y
3887 menu_cal_y:
3888 lfsr FSR0,compass_CY_f
3889 lfsr FSR1,tCalY
3890 bra menu_cal_common
3891
3892 global menu_cal_z
3893 menu_cal_z:
3894 lfsr FSR0,compass_CZ_f
3895 lfsr FSR1,tCalZ
3896 ;bra menu_cal_common
3897
3898 menu_cal_common:
3899 call strcat_text
3900 movff POSTINC0,lo
3901 movff POSTINC0,hi
3902 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required
3903 bsf leftbind
3904 output_16
3905 bcf leftbind
3906 return
3907
3908 ENDIF ; _compass
3909
3910
3911 ;-----------------------------------------------------------------------------
3912 ; ppO2 menu
3913
3914 global divesets_ppo2_min
3915 divesets_ppo2_min:
3916 lfsr FSR1,tPPO2MIN
3917 call strcat_text
3918 movff char_I_ppO2_min,lo
3919 movlw ppo2_warning_low_default
3920 bra divesets_ppo2_common
3921
3922
3923 IFDEF _ccr_pscr
3924
3925 global divesets_ppo2_min_cc
3926 divesets_ppo2_min_cc:
3927 lfsr FSR1,tPPO2MINCC
3928 call strcat_text
3929 movff char_I_ppO2_min_loop,lo
3930 movlw ppo2_warning_loop_default
3931 bra divesets_ppo2_common
3932
3933 ENDIF
3934
3935 global divesets_ppo2_max
3936 divesets_ppo2_max:
3937 lfsr FSR1,tPPO2Max
3938 call strcat_text
3939 movff char_I_ppO2_max_work,lo
3940 movlw ppo2_warning_high_default
3941 bra divesets_ppo2_common
3942
3943 global divesets_ppo2_max_deco
3944 divesets_ppo2_max_deco:
3945 lfsr FSR1,tPPO2DECO
3946 call strcat_text
3947 movff char_I_ppO2_max_deco,lo
3948 movlw ppo2_warning_deco_default
3949 ;bra divesets_ppo2_common
3950
3951 divesets_ppo2_common:
3952 movwf up ; save default value
3953 clrf hi
3954 bsf leftbind
3955 output_16dp d'3'
3956 bcf leftbind
3957 lfsr FSR1,tbar
3958 call strcat_text
3959 movf up,W ; default value
3960 cpfseq lo ; current value
3961 bra divesets_ppo2_common2 ; not default, add *
3962 return ; default, done
3963 divesets_ppo2_common2:
3964 PUTC "*"
3965 return ; done
3966
3967 ;=============================================================================
3968
3969 global TFT_clear_message_window
3970 TFT_clear_message_window:
3971 btfss divemode ; in dive mode?
3972 bra TFT_clear_message_window_surf ; NO - clear surface mode area
3973 ;bra TFT_clear_message_window_dive ; YES - clear dive mode area
3974
3975 TFT_clear_message_window_dive:
3976 btfsc alt_layout_active ; in alternative layout?
3977 bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only
3978 ; NO - clear dive mode area, both rows
3979 WIN_BOX_BLACK dm_warning_row, dm_warning_bot, dm_warning_column, dm_warning_rgt ; top, bottom, left, right
3980 return ; - done
3981
3982 TFT_clear_message_window_surf:
3983 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ; top, bottom, left, right
3984 return ; done
3985
3986
3987 global TFT_clear_message_window_row2
3988 TFT_clear_message_window_row2:
3989 btfss divemode ; in dive mode?
3990 bra TFT_clear_message_window_surf_2 ; NO - clear surface mode area, 2nd row only
3991 ;bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only
3992
3993 TFT_clear_message_window_dive_2:
3994 WIN_BOX_BLACK dm_warning2_row, dm_warning2_bot, dm_warning2_column, dm_warning2_rgt ; top, bottom, left, right
3995 bcf message_2nd_row_used ; - 2nd row is clear now
3996 return ; - done
3997
3998 TFT_clear_message_window_surf_2:
3999 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ; top, bottom, left, right
4000 bcf message_2nd_row_used ; 2nd row is clear now
4001 return ; done
4002
4003
4004 global TFT_fillup_with_spaces
4005 TFT_fillup_with_spaces: ; fill up FSR2 with spaces (total string length in #WREG)
4006 movwf lo ; save max. string length into lo
4007 movf FSR2L,W ; get current string length
4008 subwf lo,F ; lo-WREG
4009 btfsc STATUS,N ; longer then #lo already?
4010 return ; YES - done
4011 tstfsz lo ; zero?
4012 bra TFT_fillup_with_spaces2 ; NO
4013 return ; YES - done
4014 TFT_fillup_with_spaces2:
4015 PUTC " " ; add one space
4016 decfsz lo,F ; all done?
4017 bra TFT_fillup_with_spaces2 ; NO - loop
4018 return ; YES - done
4019
4020 ;=============================================================================
4021
4022 global TFT_desaturation_time
4023 TFT_desaturation_time:
4024 rcall TFT_set_message_window ; set row and column for the message
4025 tstfsz WREG ; is there room for the message? 2973 tstfsz WREG ; is there room for the message?
4026 return ; NO - skip message in this cycle 2974 return ; NO - skip message in this cycle
4027 call TFT_memo_color 2975
4028 STRCPY "Desat:" 2976 call TFT_color_code_ppo2 ; color-code output
4029 MOVII int_O_desaturation_time,mpr 2977
4030 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) 2978 btfsc bailout_mode ; in bailout?
4031 movf lo,W ; swap hi and lo 2979 bra TFT_display_diluent_oc ; YES - bailout (OC)
4032 movff hi,lo ; ... 2980 btfsc FLAG_ccr_mode ; NO - in CCR mode?
4033 movwf hi ; ... 2981 bra TFT_display_diluent_ccr ; YES - CCR
4034 output_99x ; print hours 2982 btfsc FLAG_pscr_mode ; NO - in pSCR mode?
4035 PUTC ':' ; print ":" 2983 bra TFT_display_diluent_pscr ; YES - pSCR
4036 movff hi,lo ; print minutes... 2984 ;bra TFT_display_diluent_oc ; NO - OC
4037 output_99x ; ... in two digits, leading zero 2985
4038 movlw surf_warning_length ; only use surface string length 2986 TFT_display_diluent_oc:
4039 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 2987 STRCPY_TEXT tppO2 ; bailout or OC mode, print "ppO2:"
4040 STRCAT_PRINT "" 2988 bra TFT_display_diluent_comm ; continue with ppO2 value
4041 return 2989
4042 2990 TFT_display_diluent_ccr:
4043 2991 STRCPY_TEXT tdil ; print "Dil:"
4044 global TFT_nofly_time 2992 bra TFT_display_diluent_comm ; continue with ppO2 value
4045 TFT_nofly_time: 2993
4046 rcall TFT_set_message_window ; set row and column for the message 2994 TFT_display_diluent_pscr:
2995 STRCPY_TEXT tmix ; YES - print "Mix:"
2996 ;bra TFT_display_diluent_comm ; - continue with ppO2 value
2997
2998 TFT_display_diluent_comm:
2999 bsf decimal_digit2 ; place a decimal point in front of digit 2
3000 output_999 ; print ppO2 (0.00-9.99)
3001 bra TFT_message_close ; finalize message output
3002
3003
3004 ;-----------------------------------------------------------------------------
3005 ; Dive Mode - Message - Battery
3006 ;
3007 global TFT_message_battery_percent
3008 TFT_message_battery_percent:
3009 rcall TFT_message_open ; set row and column for the message
4047 tstfsz WREG ; is there room for the message? 3010 tstfsz WREG ; is there room for the message?
4048 return ; NO - skip message in this cycle 3011 return ; NO - skip message in this cycle
4049 call TFT_memo_color 3012
4050 movff char_I_altitude_wait,WREG 3013 call TFT_color_code_battery ; color-code according to battery_low_condition flag
4051 tstfsz WREG 3014 STRCPY "Batt:" ; print "Batt:"
4052 bra TFT_nofly_time_1 3015 bsf leftbind ; print left-aligned
4053 STRCPY "NoFly:" 3016 movff batt_percent,lo ; get battery %
4054 bra TFT_nofly_time_2 3017 output_256 ; print battery % (0-255)
4055 TFT_nofly_time_1: 3018 PUTC "%" ; print "%"
4056 STRCPY "NoAlt:" 3019 bra TFT_message_close ; finalize message output
4057 TFT_nofly_time_2: 3020
4058 MOVII int_O_nofly_time,mpr 3021
4059 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo) 3022 ;-----------------------------------------------------------------------------
4060 movf lo,W ; swap hi and lo 3023 ; Dive Mode - Message - current CNS
4061 movff hi,lo ; ... 3024 ;
4062 movwf hi ; ... 3025 global TFT_message_cns
4063 output_99x ; hours 3026 TFT_message_cns:
4064 PUTC ':' 3027 call TFT_message_open ; set row and column for the message
4065 movff hi,lo ; minutes
4066 output_99x
4067 movlw surf_warning_length ; only use surface string length
4068 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4069 STRCAT_PRINT ""
4070 return
4071
4072 ;=============================================================================
4073
4074 global TFT_warning_agf
4075 TFT_warning_agf:
4076 rcall TFT_set_message_window ; set row and column for the message
4077 tstfsz WREG ; is there room for the message? 3028 tstfsz WREG ; is there room for the message?
4078 return ; NO - skip message in this cycle 3029 return ; NO - skip message in this cycle
4079 call TFT_attention_color 3030
4080 STRCPY_TEXT tDiveaGF_active ; "aGF!" 3031 MOVII int_O_CNS_current,mpr ; get current CNS
4081 movlw dm_warning_length ; dive mode string length 3032 call TFT_color_code_cns ; color-code CNS output
4082 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3033 STRCPY_TEXT tCNS ; CNS:
4083 STRCAT_PRINT "" 3034 bsf leftbind ; print left-aligned
4084 bra TFT_warn_att_info_exit ; and return... 3035 output_999 ; print (0-999)
4085 3036 PUTC "%" ; append unit
4086 3037 bra TFT_message_close ; finalize message output
4087 global TFT_warning_fallback 3038
4088 TFT_warning_fallback: ; show fallback warning 3039
4089 rcall TFT_set_message_window ; set row and column for the message 3040 ;-----------------------------------------------------------------------------
3041 ; Dive Mode - Message - End-of-Dive CNS
3042 ;
3043 global TFT_message_cns_eod
3044 TFT_message_cns_eod:
3045 call TFT_message_open ; set row and column for the message
4090 tstfsz WREG ; is there room for the message? 3046 tstfsz WREG ; is there room for the message?
4091 return ; NO - skip message in this cycle 3047 return ; NO - skip message in this cycle
4092 call TFT_warning_color 3048
4093 STRCPY_TEXT tDiveFallback ; "Fallback!" 3049 FONT_COLOR_WARNING ; switch to warnings (red) text color
4094 movlw dm_warning_length ; dive mode string length 3050 STRCPY_TEXT tCNSeod ; end-of-dive CNS warning text
4095 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3051 bra TFT_message_close ; finalize message output
4096 STRCAT_PRINT "" 3052
4097 bra TFT_warn_att_info_exit ; and return... 3053
4098 3054 ;-----------------------------------------------------------------------------
4099 ;============================================================================= 3055 ; Dive Mode - Message - Saturation
4100 3056 ;
4101 IFDEF _rx_functions 3057 global TFT_message_saturation
4102 3058 TFT_message_saturation
4103 global TFT_advice_switch 3059 rcall TFT_message_open ; set row and column for the message
4104 TFT_advice_switch: 3060 tstfsz WREG ; is there room for the message?
4105 rcall TFT_set_message_window ; set row and column for the message 3061 return ; NO - skip message in this cycle
3062
3063 MOVII int_O_lead_supersat,mpr ; get leading tissue's supersaturation
3064 call TFT_color_code_supersat ; color-code output
3065 STRCPY_TEXT tSAT ; print "Sat:"
3066 PUTC " " ; add a space to align the output with other warnings' outputs
3067 bsf leftbind ; print left-aligned
3068 output_256 ; print value of lo only, int_O_lead_supersat is limited to 255
3069 PUTC "%" ; print "%"
3070 bra TFT_message_close ; finalize message output
3071
3072
3073 ;-----------------------------------------------------------------------------
3074 ; Dive Mode - Message - alternative GF
3075 ;
3076 global TFT_message_agf
3077 TFT_message_agf:
3078 rcall TFT_message_open ; set row and column for the message
3079 tstfsz WREG ; is there room for the message?
3080 return ; NO - skip message in this cycle
3081
3082 FONT_COLOR_ATTENTION ; set attention color
3083 STRCPY_TEXT tDiveaGF_active ; print "aGF!"
3084 bra TFT_message_close ; finalize message output
3085
3086
3087 ;-----------------------------------------------------------------------------
3088 ; Dive Mode - Message - Dive Timeout
3089 ;
3090 global TFT_message_divetimeout
3091 TFT_message_divetimeout:
3092 call TFT_message_open ; set row and column for the message
4106 tstfsz WREG ; is there room for the message? 3093 tstfsz WREG ; is there room for the message?
4107 return ; NO - skip message in this cycle 3094 return ; NO - skip message in this cycle
4108 call TFT_advice_color 3095
4109 STRCPY_TEXT tswap ; "Swap Tank" 3096 FONT_COLOR_MEMO ; select color
4110 movlw dm_warning_length ; dive mode string length 3097 STRCPY 0x94 ; "End of dive" symbol (up-arrow)
4111 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3098 movff opt_diveTimeout,WREG ; get timeout in minutes
4112 STRCAT_PRINT "" 3099 mullw .60 ; get timeout in seconds
4113 bra TFT_warn_att_info_exit ; and return... 3100 MOVII PRODL, sub_a ; calculate timeout - elapsed time = countdown
4114 3101 MOVII dive_timeout_timer,sub_b ; ...
4115 global TFT_attention_transmitter 3102 call subU16 ; ...
4116 TFT_attention_transmitter: 3103 MOVII sub_c,mpr ; transfer to mpr
4117 rcall TFT_set_message_window ; set row and column for the message 3104 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
4118 tstfsz WREG ; is there room for the message? 3105 movff lo,up ; back-up lo
4119 return ; NO - skip message in this cycle 3106 movff hi,lo ; get minutes
4120 call TFT_attention_color 3107 output_99 ; print minutes (0-99)
4121 STRCPY_TEXT tTransmitter ; "P.Transm." 3108 PUTC ':' ; print ":"
4122 movlw dm_warning_length ; dive mode string length 3109 movff up,lo ; get seconds
4123 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3110 output_99x ; print seconds (00-99)
4124 STRCAT_PRINT "" 3111 movlw dm_warning_length ; get dive mode string length
4125 bra TFT_warn_att_info_exit ; and return... 3112 rcall TFT_buffer_trim_length ; fill / cut buffer to target length
4126 3113 PRINT ; dump to screen
4127 global TFT_attention_pres_reading 3114 return ; done
4128 global TFT_warning_pres_reading 3115
4129 TFT_attention_pres_reading: ; entry point for attention 3116
4130 call TFT_attention_color ; use attention color 3117 ;-----------------------------------------------------------------------------
4131 bra TFT_common_pres_reading ; continue with common code 3118 ; Dive Mode - Message - Gas Needs
4132 TFT_warning_pres_reading: ; entry point for warning 3119 ;
4133 call TFT_warning_color ; use warnings color 3120 global TFT_message_gas_needs
4134 ;bra TFT_common_pres_reading ; continue with common code 3121 TFT_message_gas_needs:
4135 TFT_common_pres_reading: 3122 rcall TFT_message_open ; set row and column for the message
4136 rcall TFT_set_message_window ; set row and column for the message
4137 tstfsz WREG ; is there room for the message?
4138 return ; NO - skip message in this cycle
4139 STRCPY_TEXT tPressure ; "Tank Pres"
4140 movlw dm_warning_length ; dive mode string length
4141 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4142 STRCAT_PRINT ""
4143 bra TFT_warn_att_info_exit ; and return...
4144
4145 global TFT_attention_sac
4146 TFT_attention_sac:
4147 rcall TFT_set_message_window ; set row and column for the message
4148 tstfsz WREG ; is there room for the message?
4149 return ; NO - skip message in this cycle
4150 MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo
4151 call TFT_color_code_tank_pres_sac; color-code the output
4152 STRCPY_TEXT tSAC ; "SAC", needs to be exactly 3 chars long
4153 STRCAT ": " ; ": "
4154 output_16_3 ; print as xxx
4155 PUTC " " ; print a dummy char to have string termination at the correct place
4156 movff buffer+.7,buffer+.8 ; move decimal digit one position to the right
4157 movlw "." ; load coding of a decimal point
4158 movff WREG,buffer+.7 ; place it before decimal digit
4159 STRCAT_PRINT "" ; dump buffer to screen
4160 bra TFT_warn_att_info_exit ; and return...
4161
4162 ENDIF ; _rx_functions
4163
4164 ;=============================================================================
4165
4166 global TFT_info_deco
4167 TFT_info_deco ; show info when decompression obligation is steady or decreasing
4168 rcall TFT_set_message_window ; set row and column for the message
4169 tstfsz WREG ; is there room for the message? 3123 tstfsz WREG ; is there room for the message?
4170 return ; NO - skip message in this cycle 3124 return ; NO - skip message in this cycle
4171 call TFT_advice_color ; YES - actually it is a memo, but we break the rules here and display in advice color (green) 3125
4172 STRCPY_TEXT tDecoInfo ; - write "Deco Zone" 3126 btfsc attn_det_gas_needs ; attention?
4173 movlw dm_warning_length ; - select dive mode string length 3127 FONT_COLOR_ATTENTION ; YES - set attention color
4174 rcall TFT_fillup_with_spaces ; - fill up FSR2 with spaces (total string length in #WREG) 3128 btfsc warn_det_gas_needs ; warning?
4175 STRCAT_PRINT "" ; - print buffer 3129 FONT_COLOR_WARNING ; YES - set warning color
4176 bra TFT_warn_att_info_exit ; - and return... 3130 STRCPY_TEXT tGasNeedsWarn ; print "Gas Needs"
4177 3131 bra TFT_message_close ; finalize message output
4178 ;============================================================================= 3132
4179 3133
4180 IFDEF _cave_mode 3134 ;-----------------------------------------------------------------------------
4181 3135 ; Dive Mode - Message - Gas Change
4182 global TFT_info_cave_mode 3136 ;
4183 TFT_info_cave_mode: 3137 global TFT_message_gas_change
4184 rcall TFT_set_message_window ; set row and column for the message 3138 TFT_message_gas_change:
3139 rcall TFT_message_open ; set row and column for the message
4185 tstfsz WREG ; is there room for the message? 3140 tstfsz WREG ; is there room for the message?
4186 return ; NO - skip message in this cycle 3141 return ; NO - skip message in this cycle
4187 call TFT_memo_color ; YES - set memo color 3142
4188 bsf win_invert ; - print in inverse 3143 FONT_COLOR_ADVICE ; set advice color
4189 STRCPY_TEXT tCaveMode ; - write "Cave Mode" 3144 STRCPY_TEXT tgaschange ; print "Change?"
4190 movlw dm_warning_length ; - select dive mode string length 3145 bra TFT_message_close ; finalize message output
4191 rcall TFT_fillup_with_spaces ; - fill up FSR2 with spaces (total string length in #WREG) 3146
4192 STRCAT_PRINT "" ; - print buffer 3147
4193 bcf win_invert ; - end inverse printing 3148 ;-----------------------------------------------------------------------------
4194 bra TFT_warn_att_info_exit ; - and return... 3149 ; Dive Mode - Message - no Bailout Gas
4195 3150 ;
4196 3151 global TFT_message_no_BO_gas
4197 global TFT_cave_shutdown_attention 3152 TFT_message_no_BO_gas:
4198 TFT_cave_shutdown_attention: 3153 rcall TFT_message_open ; set row and column for the message
4199 rcall TFT_set_message_window ; set row and column for the message
4200 tstfsz WREG ; is there room for the message? 3154 tstfsz WREG ; is there room for the message?
4201 return ; NO - skip message in this cycle 3155 return ; NO - skip message in this cycle
4202 call TFT_attention_color ; YES - set warning color 3156
4203 bra TFT_cave_shutdown_common ; - continue with common part 3157 FONT_COLOR_WARNING ; set warning color
4204
4205
4206 global TFT_cave_shutdown_warning
4207 TFT_cave_shutdown_warning:
4208 rcall TFT_set_message_window ; set row and column for the message
4209 tstfsz WREG ; is there room for the message?
4210 return ; NO - skip message in this cycle
4211 call TFT_warning_color ; YES - set warning color
4212 ;bra TFT_cave_shutdown_common ; - continue with common part
4213
4214 TFT_cave_shutdown_common:
4215 STRCPY_TEXT tCaveModeShutdown ; write "X-Cave-X"
4216 movlw dm_warning_length ; select dive mode string length
4217 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4218 STRCAT_PRINT "" ; print buffer
4219 bra TFT_warn_att_info_exit ; and return...
4220
4221 ENDIF ; _cave_mode
4222
4223 ;=============================================================================
4224
4225 global TFT_warning_saturation
4226 TFT_warning_saturation
4227 rcall TFT_set_message_window ; set row and column for the message
4228 tstfsz WREG ; is there room for the message?
4229 return ; NO - skip message in this cycle
4230 MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation
4231 call TFT_color_code_gf ; color-code output
4232 ; STRCPY "GF: " ; the two spaces are on purpose to align the output with other warnings' outputs
4233 STRCPY_TEXT tSAT ; print "Sat:"
4234 PUTC " " ; add a space to align the output with other warnings' outputs
4235 bsf leftbind
4236 output_8 ; print value of lo only, int_O_lead_supersat is limited to 255
4237 PUTC "%"
4238 movlw dm_warning_length ; dive mode string length
4239 btfss divemode ; in dive mode?
4240 movlw surf_warning_length ; NO - use surface string length
4241 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4242 STRCAT_PRINT ""
4243 bcf leftbind
4244 bcf win_invert
4245 TFT_warn_att_info_exit:
4246 goto TFT_standard_color ; and return...
4247
4248
4249 global TFT_warning_mbubbles
4250 TFT_warning_mbubbles:
4251 rcall TFT_set_message_window ; set row and column for the message
4252 tstfsz WREG ; is there room for the message?
4253 return ; NO - skip message in this cycle
4254 call TFT_attention_color ; set attention color as default
4255 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
4256 btfsc WREG,mbubble_warning ; are we in the micro bubbles zone right now?
4257 call TFT_warning_color ; YES - reconfigure to warning color
4258 STRCPY_TEXT tMicroBubbles
4259 movlw dm_warning_length ; dive mode string length
4260 btfss divemode ; in dive mode?
4261 movlw surf_warning_length ; NO - use surface string length
4262 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4263 STRCAT_PRINT ""
4264 bra TFT_warn_att_info_exit ; and return...
4265
4266
4267 global TFT_warning_outside
4268 TFT_warning_outside:
4269 rcall TFT_set_message_window ; set row and column for the message
4270 tstfsz WREG ; is there room for the message?
4271 return ; NO - skip message in this cycle
4272 call TFT_attention_color
4273 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
4274 btfsc WREG,outside_warning ; are we outside the ZH-L16 model right now?
4275 call TFT_warning_color ; YES - reconfigure to warning color
4276 STRCPY "X-ZHL16-X"
4277 movlw dm_warning_length ; dive mode string length
4278 btfss divemode ; in dive mode?
4279 movlw surf_warning_length ; NO - use surface string length
4280 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4281 STRCAT_PRINT ""
4282 bra TFT_warn_att_info_exit ; and return...
4283
4284
4285 global TFT_warning_depth
4286 TFT_warning_depth:
4287 rcall TFT_set_message_window ; set row and column for the message
4288 tstfsz WREG ; is there room for the message?
4289 return ; NO - skip message in this cycle
4290 call TFT_warning_color
4291 STRCPY_TEXT tMaxDepth ; "max.Depth"
4292 movlw dm_warning_length ; dive mode string length
4293 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4294 STRCAT_PRINT ""
4295 bra TFT_warn_att_info_exit ; and return...
4296
4297
4298 global TFT_warning_gas_needs
4299 TFT_warning_gas_needs:
4300 rcall TFT_set_message_window ; set row and column for the message
4301 tstfsz WREG ; is there room for the message?
4302 return ; NO - skip message in this cycle
4303 call TFT_warning_color ; YES - set warning color
4304 bra TFT_warning_gas_needs_com ; - continue with common part
4305
4306 global TFT_attention_gas_needs
4307 TFT_attention_gas_needs:
4308 rcall TFT_set_message_window ; set row and column for the message
4309 tstfsz WREG ; is there room for the message?
4310 return ; NO - skip message in this cycle
4311 call TFT_attention_color ; YES - set attention color
4312 ;bra TFT_warning_gas_needs_com ; - continue with common part
4313
4314 TFT_warning_gas_needs_com:
4315 STRCPY_TEXT tGasNeedsWarn ; print "Gas Needs"
4316 movlw dm_warning_length ; dive mode string length
4317 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4318 STRCAT_PRINT "" ; finalize output
4319 bra TFT_warn_att_info_exit ; and return...
4320
4321 ;=============================================================================
4322
4323 IFDEF _helium
4324
4325 global TFT_warning_IBCD
4326 TFT_warning_IBCD:
4327 rcall TFT_set_message_window ; set row and column for the message
4328 tstfsz WREG ; is there room for the message?
4329 return ; NO - skip message in this cycle
4330 call TFT_attention_color ; select attention color as default
4331 STRCPY_TEXT tIBCD ; "IBCD N2He"
4332 movlw dm_warning_length ; dive mode string length
4333 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4334 STRCAT_PRINT ""
4335 bra TFT_warn_att_info_exit ; and return...
4336
4337 ENDIF
4338
4339 ;=============================================================================
4340
4341 global TFT_warning_no_BO_gas
4342 TFT_warning_no_BO_gas:
4343 rcall TFT_set_message_window ; set row and column for the message
4344 tstfsz WREG ; is there room for the message?
4345 return ; NO - skip message in this cycle
4346 call TFT_warning_color ; select warning color
4347 STRCPY_TEXT tnoBOgas ; print "-B/O-Gas-" 3158 STRCPY_TEXT tnoBOgas ; print "-B/O-Gas-"
4348 movlw dm_warning_length ; dive mode string length 3159 bra TFT_message_close ; finalize message output
4349 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG) 3160
4350 STRCAT_PRINT "" ; finalize output 3161
4351 bra TFT_warn_att_info_exit ; and return... 3162 ;-----------------------------------------------------------------------------
4352 3163 ; Message - open Message
4353 3164 ;
4354 global TFT_advice_gas_change 3165 ; sets the row and column for the current message
4355 TFT_advice_gas_change: 3166 ;
4356 rcall TFT_set_message_window ; set row and column for the message 3167 TFT_message_open:
4357 tstfsz WREG ; is there room for the message?
4358 return ; NO - skip message in this cycle
4359 call TFT_advice_color ; set advice color
4360 STRCPY_TEXT tgaschange ; "Change?"
4361 movlw dm_warning_length ; dive mode string length
4362 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4363 STRCAT_PRINT ""
4364 bra TFT_warn_att_info_exit ; and return...
4365
4366 ;=============================================================================
4367
4368 IFDEF _external_sensor
4369
4370 global TFT_warning_sensor_disagree
4371 TFT_warning_sensor_disagree:
4372 rcall TFT_set_message_window ; set row and column for the message
4373 tstfsz WREG ; is there room for the message?
4374 return ; NO - skip message in this cycle
4375 call TFT_warning_color
4376 STRCPY_TEXT tSensorDisagree ; "Sensors<>"
4377 movlw dm_warning_length ; dive mode string length
4378 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4379 STRCAT_PRINT ""
4380 bra TFT_warn_att_info_exit ; and return...
4381
4382 ENDIF ; _external_sensor
4383
4384 ;=============================================================================
4385
4386 TFT_set_message_window: ; sets the row and column for the current message
4387 ; ignore warning (now)? 3168 ; ignore warning (now)?
4388 decf message_counter,W ; load (message counter - 1) into WREG 3169 decf message_counter,W ; load (message counter - 1) into WREG
4389 bcf STATUS,C ; clear carry bit 3170 bcf STATUS,C ; clear carry bit
4390 btfss alt_layout_active ; in alternative layout? 3171 btfss alt_layout_active ; in alternative layout?
4391 rrcf WREG,W ; NO - divide (message_counter-1) by 2 to get the page of the message 3172 rrcf WREG,W ; NO - divide (message_counter-1) by 2 to get the page of the message
4395 bra TFT_set_message_window_sf ; NO - setup for surface mode 3176 bra TFT_set_message_window_sf ; NO - setup for surface mode
4396 ;bra TFT_set_message_window_dm ; YES - setup for dive mode 3177 ;bra TFT_set_message_window_dm ; YES - setup for dive mode
4397 3178
4398 ; Dive Mode 3179 ; Dive Mode
4399 TFT_set_message_window_dm: 3180 TFT_set_message_window_dm:
4400 btfsc alt_layout_active ; in alternative layout? 3181 btfsc alt_layout_active ; in alternative layout?
4401 bra TFT_set_message_window_dm_row2 ; YES - alternative layout only uses 2nd row 3182 bra TFT_set_message_window_dm_row2 ; YES - alternative layout only uses 2nd row
4402 btfss message_counter,0 ; NO - is the message number uneven? 3183 btfss message_counter,0 ; NO - is the message number uneven?
4403 bra TFT_set_message_window_dm_row2 ; NO - use 2nd row 3184 bra TFT_set_message_window_dm_row2 ; NO - use 2nd row
4404 ;bra TFT_set_message_window_dm_row1 ; YES - use 1st row 3185 ;bra TFT_set_message_window_dm_row1 ; YES - use 1st row
4405 3186
4406 TFT_set_message_window_dm_row1: 3187 TFT_set_message_window_dm_row1:
4407 WIN_SMALL dm_warning1_column, dm_warning1_row ; set output position 3188 WIN_SMALL dm_warning1_column, dm_warning1_row
4408 bcf message_2nd_row_used ; flag that the 2nd does not contain a message yet 3189 bcf message_2nd_row_used ; flag that the 2nd does not contain a message yet
4409 retlw .0 ; show in this cycle (message window is defined) 3190 retlw .0 ; show in this cycle (message window is defined)
4410 3191
4411 TFT_set_message_window_dm_row2: 3192 TFT_set_message_window_dm_row2:
4412 WIN_SMALL dm_warning2_column, dm_warning2_row ; set output position 3193 WIN_SMALL dm_warning2_column, dm_warning2_row
4413 bsf message_2nd_row_used ; flag that the 2nd row contains a message now 3194 bsf message_2nd_row_used ; flag that the 2nd row contains a message now
4414 retlw .0 ; show in this cycle (message window is defined) 3195 retlw .0 ; show in this cycle (message window is defined)
4415 3196
4416 ; Surface Mode 3197 ; Surface Mode
4417 TFT_set_message_window_sf: 3198 TFT_set_message_window_sf:
4418 btfss message_counter,0 ; is the message counter uneven? 3199 btfss message_counter,0 ; is the message counter uneven?
4419 bra TFT_set_message_window_sf_row2 ; NO - use 2nd row 3200 bra TFT_set_message_window_sf_row2 ; NO - use 2nd row
4420 ;bra TFT_set_message_window_sf_row1 ; YES - use 1st row 3201 ;bra TFT_set_message_window_sf_row1 ; YES - use 1st row
4421 3202
4422 TFT_set_message_window_sf_row1: 3203 TFT_set_message_window_sf_row1:
4423 WIN_SMALL surf_warning1_column,surf_warning1_row ; set output position 3204 WIN_SMALL surf_warning1_column,surf_warning1_row
4424 bcf message_2nd_row_used ; flag that the 2nd row does not contain a message yet 3205 bcf message_2nd_row_used ; flag that the 2nd row does not contain a message yet
4425 retlw .0 ; show in this cycle (message window is defined) 3206 retlw .0 ; show in this cycle (message window is defined)
4426 3207
4427 TFT_set_message_window_sf_row2: 3208 TFT_set_message_window_sf_row2:
4428 WIN_SMALL surf_warning2_column,surf_warning2_row ; set output position 3209 WIN_SMALL surf_warning2_column,surf_warning2_row
4429 bsf message_2nd_row_used ; flag that the 2nd row contains a message now 3210 bsf message_2nd_row_used ; flag that the 2nd row contains a message now
4430 retlw .0 ; show in this cycle (message window is defined) 3211 retlw .0 ; show in this cycle (message window is defined)
4431 3212
4432 3213
4433 global TFT_msg_batt_percent_divemode 3214 ;-----------------------------------------------------------------------------
4434 TFT_msg_batt_percent_divemode: 3215 ; Message - fill to a given Length, or cut if too long
4435 rcall TFT_set_message_window ; set row and column for the message 3216 ;
3217 ; Input: buffer message
3218 ; WREG max length
3219 ;
3220 global TFT_buffer_trim_length
3221 TFT_buffer_trim_length:
3222 movwf lo ; copy max. string length to lo
3223 movf FSR2L,W ; get current string length to WREG
3224 subwf lo,F ; lo = max length - current length
3225 bn TFT_fillup_with_spaces_cut ; string too long -> cut string at max length
3226 bnz TFT_fillup_with_spaces_apnd ; string too short -> append spaces and string terminator
3227 bra TFT_fillup_with_spaces_term ; string at exact length -> append string terminator
3228
3229 TFT_fillup_with_spaces_apnd:
3230 PUTC " " ; add one space
3231 decfsz lo,F ; all spaces done?
3232 bra TFT_fillup_with_spaces_apnd ; NO - loop
3233 bra TFT_fillup_with_spaces_term ; YES - append string terminator
3234
3235 TFT_fillup_with_spaces_cut:
3236 movf lo,W ; get over-length (as negative number) into WREG
3237 addwf FSR2L,F ; set back buffer pointer to end of max length
3238 ;bra TFT_fillup_with_spaces_term ; append string terminator
3239
3240 TFT_fillup_with_spaces_term:
3241 clrf INDF2 ; append string terminator
3242 return ; done
3243
3244
3245 ;-----------------------------------------------------------------------------
3246 ; Message - close Message
3247 ;
3248 TFT_message_close:
3249 movlw surf_warning_length ; get surface string length
3250 btfsc divemode ; in dive mode?
3251 movlw dm_warning_length ; YES - replace by dive mode string length
3252 rcall TFT_buffer_trim_length ; fill / cut buffer to target length
3253 PRINT ; dump to screen
3254 return ; done
3255
3256
3257 ;-----------------------------------------------------------------------------
3258 ; Dive Mode - Message - Micro-Bubbles
3259 ;
3260 global TFT_message_mbubbles
3261 TFT_message_mbubbles:
3262 rcall TFT_message_open ; set row and column for the message
4436 tstfsz WREG ; is there room for the message? 3263 tstfsz WREG ; is there room for the message?
4437 return ; NO - skip message in this cycle 3264 return ; NO - skip message in this cycle
4438 movff batt_percent,lo ; get battery percent 3265
4439 call TFT_color_code_battery ; color-code battery percent 3266 FONT_COLOR_ATTENTION ; set attention color as default
4440 STRCPY "Batt:" 3267 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
4441 bsf leftbind 3268 btfsc WREG,mbubble_warning ; currently in the micro bubbles zone?
4442 output_8 3269 FONT_COLOR_WARNING ; YES - reconfigure to warning color
4443 bcf leftbind 3270 STRCPY_TEXT tMicroBubbles ; print message text
4444 PUTC "%" 3271 bra TFT_message_close ; finalize message output
4445 movlw dm_warning_length ; dive mode string length 3272
4446 btfss divemode ; in dive mode? 3273
4447 movlw surf_warning_length ; NO - use surface string length 3274 ;-----------------------------------------------------------------------------
4448 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3275 ; Dive Mode - Message - Outside Buhlmann Model
4449 STRCAT_PRINT "" 3276 ;
4450 bcf win_invert 3277 global TFT_message_outside
4451 bra TFT_custview_exit1 ; and return... 3278 TFT_message_outside:
4452 3279 rcall TFT_message_open ; set row and column for the message
4453 3280 tstfsz WREG ; is there room for the message?
4454 global TFT_gf_factors_mask ; mask for GF factors 3281 return ; NO - skip message in this cycle
4455 TFT_gf_factors_mask: 3282
4456 call TFT_divemask_color 3283 FONT_COLOR_ATTENTION ; set attention color
4457 WIN_TINY dm_custom_gf_column1,dm_custom_gf_title_row 3284 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
4458 STRCPY_TEXT_PRINT tGFactors 3285 btfsc WREG,outside_warning ; currently outside the ZH-L16 model?
4459 WIN_TINY dm_custom_gf_column3,dm_custom_gf_title_row 3286 FONT_COLOR_WARNING ; YES - reconfigure to warning color
4460 STRCPY_TEXT_PRINT taGFactors 3287 STRCPY "X-ZHL16-X" ; print message text
4461 ; Show GF (static) 3288 bra TFT_message_close ; finalize message output
4462 call TFT_disabled_color ; default to disabled color 3289
4463 btfss use_aGF ; shall use alternative GF factors? 3290
4464 call TFT_memo_color ; NO - switch to memo color 3291 ;-----------------------------------------------------------------------------
4465 WIN_STD dm_custom_gf_column1, dm_custom_gf_row 3292 ; Dive Mode - Message - Depth Limit
4466 bsf leftbind 3293 ;
4467 movff opt_GF_low,lo ; get normal GF low 3294 global TFT_message_depth_limit
4468 output_8 ; print normal GF low 3295 TFT_message_depth_limit:
4469 PUTC "/" ; print "/" 3296 rcall TFT_message_open ; set row and column for the message
4470 movff opt_GF_high,lo ; get normal GF high 3297 tstfsz WREG ; is there room for the message?
4471 output_8 ; print normal GF high 3298 return ; NO - skip message in this cycle
4472 STRCAT_PRINT "" ; finish output 3299
4473 ; Show aGF (static) 3300 FONT_COLOR_WARNING ; set warning color
4474 call TFT_memo_color ; default to memo color 3301 STRCPY_TEXT tMaxDepth ; print "max.Depth"
4475 TSTOSS opt_enable_aGF ; are alternative GF factors enabled? 3302 bra TFT_message_close ; finalize message output
4476 bra TFT_gf_factors_mask_3 ; NO - show "---" and return 3303
4477 ; YES - show aGF and which one is active 3304
4478 WIN_STD dm_custom_gf_column2, dm_custom_gf_row 3305 ;-----------------------------------------------------------------------------
4479 btfss use_aGF ; shall use aGF? 3306 ; Dive Mode - Message - Deco Info
4480 bra TFT_gf_factors_mask_1 ; NO - print "<- " 3307 ;
4481 STRCPY_PRINT " ->" ; YES - print " ->" 3308 global TFT_message_deco_info
4482 bra TFT_gf_factors_mask_2 ; - continue with common part 3309 TFT_message_deco_info
4483 TFT_gf_factors_mask_1: 3310 rcall TFT_message_open ; set row and column for the message
4484 STRCPY_PRINT "<- " ; (NO) - print "<- " 3311 tstfsz WREG ; is there room for the message?
4485 TFT_gf_factors_mask_2: ; common part 3312 return ; NO - skip message in this cycle
4486 btfss use_aGF ; shall use aGF? 3313
4487 call TFT_disabled_color ; NO - switch to disabled color 3314 FONT_COLOR_ADVICE ; actually it is a memo, but we break the rules here and display in advice color (green)
4488 WIN_STD dm_custom_gf_column3, dm_custom_gf_row 3315 STRCPY_TEXT tDecoInfo ; write "Deco Zone"
4489 movff opt_aGF_low,lo ; get aGF low 3316 bra TFT_message_close ; finalize message output
4490 output_8 ; print 3317
4491 PUTC "/" ; print "/" 3318
4492 movff opt_aGF_high,lo ; get aGF high 3319 IFDEF _helium
4493 output_8 ; print 3320
4494 STRCAT_PRINT "" ; finish output 3321 ;-----------------------------------------------------------------------------
4495 bra TFT_custview_exit1 ; done 3322 ; Dive Mode - Message - IBCD
4496 TFT_gf_factors_mask_3: 3323 ;
4497 WIN_STD dm_custom_gf_column3+.10, dm_custom_gf_row 3324 global TFT_message_IBCD
4498 STRCPY_PRINT "---" 3325 TFT_message_IBCD:
4499 bra TFT_custview_exit1 ; done 3326 rcall TFT_message_open ; set row and column for the message
4500 3327 tstfsz WREG ; is there room for the message?
4501 3328 return ; NO - skip message in this cycle
4502 global TFT_ceiling_GF_tissue_mask ; mask for ceiling, current GF and tissues 3329
4503 TFT_ceiling_GF_tissue_mask: 3330 FONT_COLOR_ATTENTION ; set attention color
4504 call TFT_divemask_color 3331 STRCPY_TEXT tIBCD ; Print "IBCD N2He"
4505 WIN_TINY dm_custom_ceiling_column+.2,dm_custom_ceiling_title_row 3332 bra TFT_message_close ; finalize message output
4506 STRCPY_TEXT_PRINT tCeiling 3333
4507 WIN_TINY dm_custom_tissue_title_column, dm_custom_tissue_title_row 3334 ENDIF ; _helium
4508 STRCPY_TEXT_PRINT tDiveTissues 3335
4509 WIN_TINY dm_custom_gf_column1+.5, dm_custom_gf_title_row 3336 IFDEF _ccr_pscr
4510 STRCPY_TEXT_PRINT tGFInfo 3337
4511 bra TFT_custview_exit1 ; and return... 3338 ;-----------------------------------------------------------------------------
4512 3339 ; Dive Mode - Message - Gas Density
4513 3340 ;
4514 global TFT_ceiling_GF_tissue ; data for ceiling, current GF and tissues 3341 global TFT_message_gas_density
4515 TFT_ceiling_GF_tissue: 3342 TFT_message_gas_density:
4516 WIN_MEDIUM dm_custom_ceiling_column,dm_custom_ceiling_row 3343 rcall TFT_message_open ; set row and column for the message
4517 MOVII int_O_ceiling,mpr ; get ceiling in [mbar] relative pressure 3344 tstfsz WREG ; is there room for the message?
4518 call TFT_color_code_ceiling ; color-code the output (also strips off flags) 3345 return ; NO - skip message in this cycle
4519 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm] 3346
4520 TSTOSS opt_units ; 0=m, 1=ft 3347 btfsc attn_det_gas_density ; on attention level?
4521 bra TFT_ceiling_tissue_cGF_m 3348 FONT_COLOR_ATTENTION ; YES - set attention color
3349 btfsc warn_det_gas_density ; on warning level?
3350 FONT_COLOR_WARNING ; YES set warning color
3351 STRCPY_TEXT tGasDensity ; print "G.Density"
3352 bra TFT_message_close ; finalize message output
3353
3354 ENDIF ; _ccr_pscr
3355
3356 IFDEF _external_sensor
3357
3358 ;-----------------------------------------------------------------------------
3359 ; Dive Mode - Message - Sensor ppO2 Divergence
3360 ;
3361 global TFT_message_divergence
3362 TFT_message_divergence:
3363 rcall TFT_message_open ; set row and column for the message
3364 tstfsz WREG ; is there room for the message?
3365 return ; NO - skip message in this cycle
3366
3367 FONT_COLOR_WARNING ; set warning color
3368 STRCPY_TEXT tSensorDisagree ; print "Sensors<>"
3369 bra TFT_message_close ; finalize message output
3370
3371
3372 ;-----------------------------------------------------------------------------
3373 ; Dive Mode - Message - Fallback
3374 ;
3375 global TFT_message_fallback
3376 TFT_message_fallback:
3377 rcall TFT_message_open ; set row and column for the message
3378 tstfsz WREG ; is there room for the message?
3379 return ; NO - skip message in this cycle
3380
3381 FONT_COLOR_WARNING ; set warning color
3382 STRCPY_TEXT tDiveFallback ; print "Fallback!"
3383 bra TFT_message_close ; finalize message output
3384
3385 ENDIF ; _external_sensor
3386
3387 IFDEF _rx_functions
3388
3389 ;-----------------------------------------------------------------------------
3390 ; Dive Mode - Message - TR - Transmitter
3391 ;
3392 global TFT_message_transmitter
3393 TFT_message_transmitter:
3394 rcall TFT_message_open ; set row and column for the message
3395 tstfsz WREG ; is there room for the message?
3396 return ; NO - skip message in this cycle
3397
3398 FONT_COLOR_ATTENTION ; set attention color
3399 STRCPY_TEXT tTransmitter ; print "P.Transm."
3400 bra TFT_message_close ; finalize message output
3401
3402
3403 ;-----------------------------------------------------------------------------
3404 ; Dive Mode - Message - TR - Pressure
3405 ;
3406 global TFT_message_pressure
3407 TFT_message_pressure:
3408 rcall TFT_message_open ; set row and column for the message
3409 tstfsz WREG ; is there room for the message?
3410 return ; NO - skip message in this cycle
3411
3412 btfsc attn_det_pressure1 ; on attention level - pressure 1 ?
3413 FONT_COLOR_ATTENTION ; YES - set attention color
3414 btfsc attn_det_pressure2 ; on attention level - pressure 2 ?
3415 FONT_COLOR_ATTENTION ; YES - set attention color
3416 btfsc warn_det_pressure1 ; on warning level - pressure 1 ?
3417 FONT_COLOR_WARNING ; YES - set warning color
3418 btfsc warn_det_pressure2 ; on warning level - pressure 2 ?
3419 FONT_COLOR_WARNING ; YES - set warning color
3420 STRCPY_TEXT tPressure ; print "Tank Pres"
3421 bra TFT_message_close ; finalize message output
3422
3423
3424 ;-----------------------------------------------------------------------------
3425 ; Dive Mode - Message - TR - SAC
3426 ;
3427 global TFT_message_sac
3428 TFT_message_sac:
3429 rcall TFT_message_open ; set row and column for the message
3430 tstfsz WREG ; is there room for the message?
3431 return ; NO - skip message in this cycle
3432
3433 MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo
3434 call TFT_color_code_pres_sac ; color-code the output
3435 STRCPY_TEXT tSAC ; print "SAC" (needs to be exactly 3 chars long)
3436 STRCAT ": " ; print ": "
3437 bsf decimal_digit1 ; place a decimal point in front of digit 1
3438 output_999 ; print (0.0-99.9)
3439 bra TFT_message_close ; finalize message output
3440
3441
3442 ;-----------------------------------------------------------------------------
3443 ; Dive Mode - Message - TR - switch Tank Advice
3444 ;
3445 global TFT_message_switch_tanks
3446 TFT_message_switch_tanks:
3447 rcall TFT_message_open ; set row and column for the message
3448 tstfsz WREG ; is there room for the message?
3449 return ; NO - skip message in this cycle
3450
3451 FONT_COLOR_ADVICE ; set advice color
3452 STRCPY_TEXT tswap ; print "Swap Tank"
3453 bra TFT_message_close ; finalize message output
3454
3455 ENDIF ; _rx_functions
3456
3457 IFDEF _cave_mode
3458
3459 ;-----------------------------------------------------------------------------
3460 ; Dive Mode - Message - Cave Mode
3461 ;
3462 global TFT_message_cave_mode
3463 TFT_message_cave_mode:
3464 rcall TFT_message_open ; set row and column for the message
3465 tstfsz WREG ; is there room for the message?
3466 return ; NO - skip message in this cycle
3467
3468 btfss attn_det_cave_shut_down ; on attention level?
3469 bra TFT_message_cave_mode_1 ; NO
3470 FONT_COLOR_ATTENTION ; YES - select attention color
3471 bra TFT_message_cave_mode_sd ; - print shutdown message
3472
3473 TFT_message_cave_mode_1:
3474 btfss warn_det_cave_shut_down ; on warning level?
3475 bra TFT_message_cave_mode_info ; NO
3476 FONT_COLOR_WARNING ; YES - select warning color
3477 ;bra TFT_message_cave_mode_sd ; - print shutdown message
3478
3479 TFT_message_cave_mode_sd:
3480 STRCPY_TEXT tCaveModeShutdown ; print "X-Cave-X"
3481 bra TFT_message_close ; finalize message output
3482
3483 TFT_message_cave_mode_info:
3484 FONT_COLOR_MEMO ; set memo color
3485 bsf win_invert ; print in inverse
3486 STRCPY_TEXT tCaveMode ; write "Cave Mode"
3487 bra TFT_message_close ; finalize message output
3488
3489 ENDIF ; _cave_mode
3490
3491
3492 ;=============================================================================
3493 tft_out13 CODE
3494 ;=============================================================================
3495
3496
3497 ;-----------------------------------------------------------------------------
3498 ; Surface Custom View - Last Dive Summery
3499 ;
3500 global TFT_surf_cv_lastdive
3501 TFT_surf_cv_lastdive:
3502 FONT_COLOR_MEMO ; set color
3503
3504 WIN_TINY surf_gaslist_column,surf_gaslist_row+.5
3505 STRCAT_TEXT_PRINT tLastDive ; "Last Dive:"
3506
3507 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)+.5
3508 STRCAT_TEXT_PRINT tDivetime ; "Divetime:"
3509
3510 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)+.5
3511 STRCAT_TEXT_PRINT tMaxDepth ; "Max.Depth"
3512
3513 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)+.5
3514 STRCAT_TEXT_PRINT tAvgDepth ; "Average"
3515
3516 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row
3517 SMOVII int_O_desaturation_time,mpr ; ISR-safe copy of the desaturation time
3518 movf mpr+0,W ; get low byte into WREG
3519 iorwf mpr+1,W ; inclusive-or with high byte, check if desaturation time is zero
3520 bz TFT_surface_lastdive_2 ; YES - show last dive time
3521 ;bra TFT_surface_lastdive_1 ; NO - show surface interval
3522
3523 TFT_surface_lastdive_1:
3524 ; surface interval
3525 SMOVII surface_interval_mins,mpr ; ISR-safe copy of surface interval in minutes
3526 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
3527 movff lo,up ; back-up low
3528 movff hi,lo ; get hours
3529 output_99 ; print hours (0-99)
3530 PUTC 'h' ; append hours unit
3531 movff up,lo ; get minutes
3532 output_99x ; print minutes (00-99)
3533 PUTC_PRINT "m" ; append minutes unit and dump to screen
3534 bra TFT_surface_lastdive_com ; continue
3535
3536 TFT_surface_lastdive_2:
3537 ; last dive time
3538 SMOVQQ surface_interval_secs,xC ; ISR-safe copy of surface_interval_secs:4 to xC:4
3539 call output_secs_as_days_hours ; print seconds as days and hours
3540 PRINT ; dump to screen
3541 ;bra TFT_surface_lastdive_com ; continue
3542
3543 TFT_surface_lastdive_com:
3544 ; last dive duration
3545 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.1)
3546 MOVII lastdive_duration,mpr ; get duration of last dive, minutes
3547 output_999 ; print minutes
3548 PUTC ":" ; print ":"
3549 movff lastdive_duration+2,lo ; get duration of last dive, seconds
3550 output_99x ; print seconds
3551 PRINT ; dump to screen
3552
3553 ; last dive max depth
3554 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.2)
3555 MOVII lastdive_maxdepth,mpr ; get max depth of last dive
3556 rcall TFT_surface_lastdive_depth ; print depth
3557
3558 ; average depth
3559 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.3)
3560 MOVII lastdive_avgdepth,mpr ; get avg depth of last dive
3561 ;bra TFT_surface_lastdive_depth ; print depth and return
3562
3563 ; Helper Function - print depth
3564 TFT_surface_lastdive_depth:
3565 TSTOSS opt_units ; 0=Meter, 1=Feet
3566 bra TFT_surface_lastdive_m ; 0 - metric
3567 ;bra TFT_surface_lastdive_ft ; 1 - imperial
3568
3569 TFT_surface_lastdive_ft:
4522 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet] 3570 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
4523 output_16_3 ; yxz 3571 output_999 ; print (0-999)
4524 bra TFT_ceiling_tissue_cGF0 3572 STRCAT_TEXT tFeets1 ; "ft"
4525 TFT_ceiling_tissue_cGF_m: 3573 PRINT ; dump to screen
4526 bsf leftbind 3574 return ; done
4527 bsf ignore_digit5 ; no cm (flag will be cleared by output_16) 3575
4528 output_16dp .3 ; yxz.a 3576 TFT_surface_lastdive_m:
4529 bcf leftbind 3577 bsf omit_digit_1 ; do not print 1st digit
4530 TFT_ceiling_tissue_cGF0: 3578 bsf decimal_digit2 ; place a decimal point in front of digit 2
4531 STRCAT_PRINT " " 3579 output_65535 ; print (0.0x-655.3x)
4532 ; Show tissue diagram 3580 STRCAT_TEXT tMeters ; "m"
4533 call TFT_dive_tissues ; show tissue pressure diagram 3581 PRINT ; dump to screen
4534 ; Show current supersaturation 3582 return ; done
4535 WIN_MEDIUM dm_custom_clock_column+.3, dm_custom_gf_row 3583
4536 MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation 3584
4537 call TFT_color_code_gf ; color-code output 3585 ;-----------------------------------------------------------------------------
4538 output_8 ; need to print lo only, int_O_lead_supersat value is limited to 255 3586 ; Surface Custom View - OC Gas List
4539 STRCAT_PRINT "" 3587 ;
4540 WIN_STD dm_custom_clock_column+.40, dm_custom_gf_row+.5 3588 global TFT_surf_cv_list_gas
4541 STRCAT_PRINT "%" ; % is printed in color set by TFT_color_code_gf, too 3589 TFT_surf_cv_list_gas:
4542 TFT_custview_exit1: 3590 clrf WREG ; do OC gases (0-4)
4543 bcf leftbind 3591 ;bra TFT_surf_cv_list_gas_common ; continue with common part
4544 goto TFT_standard_color ; and return... 3592
4545 3593 ; common list for OC gases and diluents
4546 3594 TFT_surf_cv_list_gas_common:
4547 global TFT_clock_batt_surfpress_mask ; mask for clock, battery and surface pressure 3595 movwf gaslist_gas ; set first gas/dil to show
4548 TFT_clock_batt_surfpress_mask: 3596 FONT_COLOR_MEMO ; set color
4549 call TFT_divemask_color 3597
4550 WIN_TINY dm_custom_clock_column, dm_custom_clock_title_row 3598 bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas and gaslist_strcat_setpoint
4551 STRCPY_TEXT_PRINT tTime ; "Time" 3599 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
4552 WIN_TINY dm_custom_battery_column, dm_custom_battery_title_row 3600
4553 STRCPY_TEXT_PRINT tBattery ; "Battery" 3601 ; Gas 1
4554 WIN_TINY dm_custom_surfpres_column+.8, dm_custom_surfpres_title_row 3602 WIN_SMALL surf_gaslist_column,surf_gaslist_row
4555 STRCPY_TEXT_PRINT tSurface ; "Surface" 3603 call gaslist_strcat_gas ; print gas description
4556 ; Show configured Surface Pressure (done in mask, because it's static during the dive) 3604 PRINT ; dump to screen
4557 call TFT_standard_color 3605
4558 WIN_SMALL dm_custom_surfpres_column, dm_custom_surfpres_row 3606 ; Gas 2
4559 MOVII pressure_surf,mpr 3607 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
4560 output_16 3608 incf gaslist_gas,F ; select next gas/dil
4561 PUTC ' ' 3609 call gaslist_strcat_gas ; print gas description
4562 STRCAT_TEXT_PRINT tMBAR ; mbar (hPa) 3610 PRINT ; dump to screen
4563 bra TFT_custview_exit1 ; and return... 3611
4564 3612 ; Gas 3
4565 3613 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)
4566 global TFT_clock_batt_surfpress ; data for clock, battery and surface pressure 3614 incf gaslist_gas,F ; select next gas/dil
4567 TFT_clock_batt_surfpress: 3615 call gaslist_strcat_gas ; print gas description
4568 ; Update Clock 3616 PRINT ; dump to screen
4569 WIN_SMALL dm_custom_clock_column, dm_custom_clock_row 3617
4570 call TFT_standard_color 3618 ; Gas 4
4571 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time 3619 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)
4572 movff rtc_latched_hour,lo 3620 incf gaslist_gas,F ; select next gas/dil
4573 output_99 3621 call gaslist_strcat_gas ; print gas description
4574 PUTC ':' 3622 PRINT ; dump to screen
4575 movff rtc_latched_mins,lo 3623
4576 output_99x 3624 ; Gas 5
4577 PUTC ":" 3625 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4)
4578 movff rtc_latched_secs,lo 3626 incf gaslist_gas,F ; select next gas/dil
4579 output_99x 3627 call gaslist_strcat_gas ; print gas description
4580 STRCAT_PRINT "" 3628 PRINT ; dump to screen
4581 ; Show Battery Volt 3629
4582 call TFT_memo_color 3630 return ; done
4583 WIN_SMALL dm_custom_battery_column, dm_custom_battery_volt_row 3631
4584 MOVII batt_voltage,mpr 3632
4585 bsf leftbind 3633 ;-----------------------------------------------------------------------------
4586 output_16dp .2 ; print as -x.yyy 3634 ; Surface Custom View - Custom Text
4587 PUTC 'V' 3635 ;
4588 movff buffer+5,buffer+4 3636 global TFT_surf_cv_text
4589 movlw 0x00 3637 TFT_surf_cv_text:
4590 movff WREG,buffer+5 ; only "x.yzV" 3638 FONT_COLOR_MEMO ; set color
4591 STRCAT_PRINT "" 3639
4592 ; Show Battery Percent 3640 ; 1st row
4593 WIN_SMALL dm_custom_battery_column+.7, dm_custom_battery_percent_row 3641 WIN_SMALL surf_customtext_column,surf_customtext_row1
4594 movff batt_percent,lo ; get battery percent 3642 MOVRR opt_name+ .0,buffer,.12 ; copy 1st 12 chars to output buffer
4595 call TFT_color_code_battery ; color-code battery percent 3643 PRINT ; dump to screen
4596 output_8 3644
4597 STRCAT "% " 3645 ; 2nd row
4598 movlw 0x00 3646 WIN_SMALL surf_customtext_column,surf_customtext_row2
4599 movff WREG,buffer+4 ; only "xxx%" 3647 MOVRR opt_name+.12,buffer,.12 ; copy 2nd 12 chars to output buffer
4600 STRCAT_PRINT "" 3648 PRINT ; dump to screen
4601 ; Surface pressure is shown in mask because it is static 3649
4602 bra TFT_custview_exit1 ; and return... 3650 ; 3rd row
4603 3651 WIN_SMALL surf_customtext_column,surf_customtext_row3
4604 ;============================================================================= 3652 MOVRR opt_name+.24,buffer,.12 ; copy 3rd 12 chars to output buffer
4605 3653 PRINT ; dump to screen
4606 IFDEF _ccr_pscr 3654
4607 3655 ; 4th row
4608 global TFT_pscr_info_mask ; mask for pSCR info 3656 WIN_SMALL surf_customtext_column,surf_customtext_row4
4609 TFT_pscr_info_mask: 3657 MOVRR opt_name+.36,buffer,.12 ; copy 4th 12 chars to output buffer
4610 rcall TFT_show_ppo2_mask 3658 PRINT ; dump to screen
4611 call TFT_divemask_color 3659
4612 WIN_TINY dm_custom_pscr_drop_column, dm_custom_pscr_title_row 3660 ; 5th row
4613 STRCPY_TEXT_PRINT tPSCR_O2_drop 3661 WIN_SMALL surf_customtext_column,surf_customtext_row5
4614 WIN_TINY dm_custom_pscr_ratio_column, dm_custom_pscr_title_row 3662 MOVRR opt_name+.48,buffer,.12 ; copy 5th 12 chars to output buffer
4615 STRCPY_TEXT_PRINT tPSCR_lungratio 3663 PRINT ; dump to screen
4616 bra TFT_custview_exit1 ; and return... 3664
4617 3665 return ; done
4618 3666
4619 global TFT_pscr_info ; data for pSCR info 3667
4620 TFT_pscr_info: 3668 ;-----------------------------------------------------------------------------
4621 ;show ppO2 3669 ; Surface Custom View - Tissue Graphics
4622 WIN_MEDIUM dm_custom_ppo2_column,dm_custom_ppo2_row 3670 ;
4623 MOVII int_O_pSCR_ppO2,mpr ; copy pSCR ppO2 to hi:lo 3671 global TFT_surf_cv_tissues
4624 call TFT_color_code_ppo2 ; color-code output 3672 TFT_surf_cv_tissues:
4625 bsf leftbind
4626 output_16dp .3 ; x.xx bar
4627 bcf leftbind
4628 STRCAT_PRINT ""
4629 ; Show drop
4630 WIN_STD dm_custom_pscr_drop_column+.11,dm_custom_pscr_row
4631 call TFT_memo_color
4632 movff char_I_PSCR_drop,lo
4633 bsf leftbind
4634 output_8
4635 STRCAT_PRINT "%"
4636 ; Show lung ratio
4637 WIN_STD dm_custom_pscr_ratio_column+.5,dm_custom_pscr_row
4638 movff char_I_PSCR_lungratio,lo
4639 bsf leftbind
4640 STRCPY "1/"
4641 output_8
4642 STRCAT_PRINT ""
4643 bra TFT_custview_exit1 ; and return...
4644
4645 ENDIF ; _ccr_psrc
4646
4647 ;=============================================================================
4648
4649 global TFT_gas_needs_mask ; mask for gas needs ascent
4650 TFT_gas_needs_mask:
4651 WIN_TINY dm_custom_gas_column_title, dm_custom_gas_mask_row
4652 call TFT_divemask_color
4653 IFDEF _cave_mode
4654 movff char_O_deco_info,WREG ; get the deco info vector
4655 btfss WREG,gas_needs_cave ; are the gas needs calculated for cave mode?
4656 bra TFT_gas_needs_mask_ascent_1 ; NO - show as direct ascent needs
4657 bsf gas_needs_mode_last ; YES - remember last results were for cave mode
4658 STRCPY_TEXT tGasNeedsCaveMode ; - "Gas Needs Cave Mode"
4659 bra TFT_gas_needs_mask_ascent_2
4660 TFT_gas_needs_mask_ascent_1:
4661 bcf gas_needs_mode_last ; remember last results were for direct ascent
4662 STRCPY_TEXT tGasNeedsAscent ; "Gas Needs Ascent"
4663 TFT_gas_needs_mask_ascent_2:
4664 ELSE
4665 STRCPY_TEXT tGasNeedsAscent ; "Gas Needs Ascent"
4666 ENDIF
4667 movff char_O_deco_info,WREG ; get the deco info vector
4668 btfss WREG,gas_needs_fTTS ; are the gas needs calculated for fTTS?
4669 bra TFT_gas_needs_mask_ascent_3 ; NO - continue
4670 STRCAT " fTTS" ; YES - append fTTS marking
4671 TFT_gas_needs_mask_ascent_3:
4672 STRCAT_PRINT " (bar)" ; " (bar)"
4673 bra TFT_custview_exit1 ; and return...
4674
4675
4676 global TFT_gas_needs ; data for gas needs ascent
4677 TFT_gas_needs: ; LIMITATION: there is only space for 4 gases on the screen - if 5 gases have a pres_need > 0, then only the first 4 will be shown!
4678 IFDEF _cave_mode
4679 movff char_O_deco_info,WREG ; get deco info vector
4680 btfss WREG,gas_needs_cave ; are the gas needs calculated for cave mode?
4681 bra TFT_gas_needs_ascent_1 ; NO - continue below...
4682 btfsc gas_needs_mode_last ; YES - were the last results calculated for cave mode?
4683 bra TFT_gas_needs_ascent_3 ; YES - mask still valid
4684 bra TFT_gas_needs_ascent_2 ; NO - redraw mask
4685 TFT_gas_needs_ascent_1:
4686 btfss gas_needs_mode_last ; NO - were the last results calculated for direct ascent?
4687 bra TFT_gas_needs_ascent_3 ; YES - mask still valid
4688 ;bra TFT_gas_needs_ascent_2 ; NO - redraw mask
4689 TFT_gas_needs_ascent_2:
4690 rcall TFT_gas_needs_mask ; redraw mask
4691 TFT_gas_needs_ascent_3:
4692 ENDIF
4693 clrf up ; initialize gas index (0-4)
4694 WIN_SMALL dm_custom_gas_column1+.5,dm_custom_gas_row1
4695 rcall TFT_gas_needs_helper
4696 WIN_SMALL dm_custom_gas_column1+.5,dm_custom_gas_row2
4697 rcall TFT_gas_needs_helper
4698 WIN_SMALL dm_custom_gas_column2+.5,dm_custom_gas_row1
4699 rcall TFT_gas_needs_helper
4700 WIN_SMALL dm_custom_gas_column2+.5,dm_custom_gas_row2
4701 rcall TFT_gas_needs_helper
4702 bra TFT_custview_exit2 ; and return...
4703
4704 TFT_gas_needs_helper:
4705 call TFT_memo_color
4706 movlw .5 ; number of gases
4707 cpfslt up ; check if all gases have been processed
4708 bra TFT_gas_needs_helper_1 ; YES - clear display area
4709 movf up,W ; NO - get gas number and check if need of that gas is > 0
4710 rlncf WREG,W ; multiply by 2
4711 incf WREG,W ; add 1 to address high byte
4712 lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure
4713 movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up])
4714 btfss hi,int_is_zero ; check flag for pres_need == 0
4715 bra TFT_gas_needs_helper_2 ; NO - print gas type and pressure needed
4716 incf up,F ; YES - increment to next gas...
4717 bra TFT_gas_needs_helper ; ...and try the next gas
4718 TFT_gas_needs_helper_1: ; no gases to show anymore, clear display area from potential remains of last invocation
4719 STRCAT_PRINT " ---- " ; overwrite outdated stuff if screen position is not needed
4720 return
4721 TFT_gas_needs_helper_2: ; output gas type and pressure needed
4722 movf up,W ; get gas number (0-4) to WREG
4723 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG]
4724 movff PLUSW1,lo ; copy result to lo
4725 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_He_ratio[WREG]
4726 movff PLUSW1,hi ; copy result to hi
4727 call gaslist_show_mix ; print "Air", "O2", "21/35", etc.
4728 PUTC ':' ; ":"
4729 movf up,W ; get gas number (0-4) to WREG
4730 rlncf WREG,W ; multiply by 2
4731 lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure
4732 movff PLUSW1,lo ; read LOW(int_O_gas_need_pres[up])
4733 incf WREG,W ; add 1 to address high byte
4734 movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up])
4735 btfsc hi,int_attention_flag ; check if attention flag is set (pres_need > pres_fill * threshold)
4736 call TFT_attention_color ; YES - print gas need in attention color
4737 btfsc hi,int_warning_flag ; check if warning flag is set (pres_need > pres_fill)
4738 call TFT_warning_color ; YES - print gas need in warning color
4739 movff int_O_gas_need_pres+1,WREG ; get HIGH(int_O_gas_need_pres[0]) which holds flag for invalid data
4740 btfsc WREG,int_invalid_flag ; check if invalid data flag is set
4741 call TFT_disabled_color ; YES - print gas need in disabled color
4742 bcf hi,int_attention_flag ; clear flag for attention
4743 bcf hi,int_warning_flag ; clear flag for warning
4744 bcf hi,int_high_flag ; clear flag for > 999 bar
4745 bcf hi,int_invalid_flag ; clear flag for invalid data (will actually only be set with 1st gas)
4746 output_16_3 ; limit to 999 and display only (0-999)
4747 STRCAT_PRINT " " ; adds a space to overwrite any potential remains of earlier outputs
4748 incf up,F ; increment to next gas
4749 return ; done
4750
4751
4752 global TFT_show_ppo2_mask ; helper function for several custom views
4753 TFT_show_ppo2_mask:
4754 call TFT_divemask_color
4755 IFDEF _ccr_pscr
4756 btfss FLAG_ccr_mode ; in CCR mode?
4757 bra TFT_mask_ppo2a ; NO - continue checking for pSCR and OC
4758 btfsc bailout_mode ; YES - in bailout?
4759 bra TFT_mask_ppo2b ; YES
4760 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display)
4761 STRCPY_TEXT_PRINT tppO2Dil ; NO - print "ppO2(Dil)"
4762 bra TFT_custview_exit2 ; - and return...
4763 TFT_mask_ppo2a:
4764 btfss FLAG_pscr_mode ; in pSCR mode?
4765 bra TFT_mask_ppo2b ; NO - continue with OC mode (or bailout)
4766 btfsc bailout_mode ; YES - in bailout?
4767 bra TFT_mask_ppo2b ; YES
4768 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display)
4769 STRCPY_TEXT_PRINT tppO2Mix ; NO - print "ppO2(Mix)"
4770 bra TFT_custview_exit2 ; - and return...
4771 ENDIF
4772 TFT_mask_ppo2b: ; OC mode or bailout
4773 WIN_TINY dm_custom_ppo2_column-.2, dm_custom_ppo2_title_row ; normal position
4774 STRCPY_TEXT_PRINT tppO2 ; in all other modes
4775 bra TFT_custview_exit2 ; and return...
4776
4777
4778 global TFT_ppo2_ead_end_cns_mask ; mask for ppO2, END/EAD and CNS / gas density
4779 TFT_ppo2_ead_end_cns_mask:
4780 call TFT_divemask_color
4781 WIN_TINY dm_custom_ppo2_column-.2, dm_custom_ppo2_title_row
4782 STRCPY_TEXT_PRINT tppO2
4783 WIN_TINY dm_custom_ead_column, dm_custom_eadend_title_row
4784 STRCPY_TEXT_PRINT tDiveEAD_END
4785 IFDEF _helium
4786 WIN_TINY dm_custom_cns_column-.5, dm_custom_eadend_title_row
4787 STRCPY_TEXT_PRINT tGasDensity
4788 ELSE
4789 WIN_TINY dm_custom_cns_column, dm_custom_cns_title_row
4790 STRCPY_TEXT_PRINT tCNS2
4791 ENDIF
4792 bra TFT_custview_exit2 ; and return...
4793
4794
4795 global TFT_ppo2_ead_end_cns ; data for ppO2, END/EAD and CNS / gas density
4796 TFT_ppo2_ead_end_cns:
4797 ; Show ppO2
4798 WIN_MEDIUM dm_custom_ppo2_column, dm_custom_ppo2_row
4799 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 of the currently breathed gas to hi:lo
4800 call TFT_color_code_ppo2 ; color-code output
4801 bsf leftbind
4802 output_16dp .3 ; x.xx bar
4803 bcf leftbind
4804 STRCAT_PRINT ""
4805 call TFT_standard_color
4806 ; Show END/EAD
4807 WIN_SMALL dm_custom_ead_column, dm_custom_ead_row
4808 STRCPY_TEXT tEAD ; EAD:
4809 MOVII int_O_EAD_pres,mpr ; copy EAD in [mbar] to MPR
4810 rcall TFT_end_ead_common ; convert to depth, print and limit to 8 chars
4811 WIN_SMALL dm_custom_end_column, dm_custom_end_row
4812 STRCPY_TEXT tEND ; END:
4813 MOVII int_O_END_pres,mpr ; copy END in [mbar] to MPR
4814 rcall TFT_end_ead_common ; convert to depth, print and limit to 8 chars
4815 IFDEF _helium
4816 ; Show Gas Density
4817 WIN_MEDIUM dm_custom_cns_column-.5, dm_custom_cns_row
4818 MOVII int_O_gas_density,mpr ; get current gas density
4819 call TFT_color_code_cns_1 ; color-code output
4820 bsf leftbind ; print left-aligned
4821 movlw .2 ; suppress first and second digit
4822 movwf ignore_digits ; ...
4823 output_16dp .2 ; print as -x.yyy
4824 bcf leftbind ; back to normal alignment
4825 STRCAT_PRINT "" ; finalize output
4826 ELSE
4827 ; Show CNS
4828 WIN_STD dm_custom_cns_column+.3, dm_custom_cns_row
4829 MOVII int_O_CNS_current,mpr ; get current CNS
4830 call TFT_color_code_cns ; color-code CNS output
4831 bsf leftbind
4832 output_16_3 ; displays only 0...999
4833 bcf leftbind
4834 STRCAT_PRINT "%"
4835 ENDIF
4836 TFT_custview_exit2:
4837 goto TFT_standard_color ; and return...
4838
4839 TFT_end_ead_common:
4840 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
4841 TSTOSS opt_units ; 0=Meter, 1=Feet
4842 bra TFT_end_ead_common_metric ; 0: meter
4843 ;bra TFT_end_ead_common_imperial ; 1: feet
4844
4845 TFT_end_ead_common_imperial:
4846 call convert_cm_to_feet ; convert depth in [cm] to depth in [feet]
4847 output_16_3 ; print as xyz
4848 bra TFT_end_ead_common_exit
4849
4850 TFT_end_ead_common_metric:
4851 bsf ignore_digit4 ; no decimals (flag will be cleared by output_16)
4852 output_16dp .3 ; print as yxz.--
4853 movlw 'm' ; hard-coded unit
4854 movff WREG,buffer+.7 ; place the unit onto the decimal point
4855 ;bra TFT_end_ead_common_exit
4856
4857 TFT_end_ead_common_exit:
4858 STRCAT_PRINT "" ; finalize output
4859 return ; done
4860
4861 ;=============================================================================
4862
4863 IFDEF _ccr_pscr
4864
4865 global TFT_sensor_check_mask ; mask for sensor check
4866 TFT_sensor_check_mask:
4867 call TFT_divemask_color
4868 WIN_TINY dm_custom_s_check_title_column, dm_custom_s_check_title_row
4869 STRCPY_TEXT_PRINT tSensorCheck
4870 WIN_TINY dm_custom_ppO2_column, dm_custom_s_check_title_row
4871 STRCPY_TEXT_PRINT tppO2O2
4872 WIN_TINY dm_custom_ppDil_column, dm_custom_s_check_title_row
4873 STRCPY_TEXT_PRINT tppO2Dil
4874 bra TFT_sensor_check_exit ; and return...
4875
4876
4877 global TFT_sensor_check ; data for sensor check
4878 TFT_sensor_check:
4879 ; Show ppO2 of O2 in this depth
4880 WIN_MEDIUM dm_custom_ppO2_column, dm_custom_s_check_row
4881 MOVII int_O_O2_ppO2,mpr ; copy ppO2 of pure O2 to hi:lo
4882 call TFT_color_code_ppo2 ; color-code output
4883 bsf leftbind
4884 output_16dp .3 ; x.xx bar
4885 bcf leftbind
4886 STRCAT_PRINT ""
4887 ; Show ppO2 of the diluent in this depth
4888 WIN_MEDIUM dm_custom_ppDil_column, dm_custom_s_check_row
4889 MOVII int_O_pure_ppO2,mpr ; copy ppO2 of pure gas to hi:lo
4890 call TFT_color_code_ppo2 ; color-code output
4891 bsf leftbind
4892 output_16dp .3 ; x.xx bar
4893 bcf leftbind
4894 STRCAT_PRINT ""
4895 TFT_sensor_check_exit:
4896 bra TFT_custview_exit2 ; and return...
4897
4898 ENDIF ; _ccr_pscr
4899
4900 ;=============================================================================
4901
4902 global TFT_surface_lastdive
4903 TFT_surface_lastdive:
4904 WIN_TINY surf_gaslist_column,surf_gaslist_row+.5
4905 STRCAT_TEXT_PRINT tLastDive ; "Last Dive:"
4906 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)+.5
4907 STRCAT_TEXT_PRINT tDivetime ; "Divetime:"
4908 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)+.5
4909 STRCAT_TEXT_PRINT tMaxDepth ; "Max.Depth"
4910 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)+.5
4911 STRCAT_TEXT_PRINT tAvgDepth ; "Average"
4912
4913 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row
4914 SMOVII int_O_desaturation_time,mpr ; ISR-safe copy of the desaturation time
4915 movf mpr+0,W ; get low byte into WREG
4916 iorwf mpr+1,W ; inclusive-or with high byte, check if desaturation time is zero
4917 bz TFT_surface_lastdive_1 ; YES - show last dive time
4918 ; NO - show surface interval
4919 SMOVII surface_interval_mins,mpr ; - ISR-safe copy of surface interval in minutes
4920 call convert_time ; - convert hi:lo in minutes to hours (up:hi) and minutes (lo)
4921 movf hi,W ; - swap hi and lo
4922 movff lo,hi ; ...
4923 movwf lo ; ...
4924 bsf leftbind ;
4925 output_99x ;
4926 PUTC 'h' ;
4927 movff hi,lo ;
4928 output_99x ;
4929 STRCAT_PRINT "m " ;
4930 bra TFT_surface_lastdive_2 ;
4931 TFT_surface_lastdive_1:
4932 SMOVQQ surface_interval_secs,xC ; ISR-safe copy of surface_interval_secs:4 to xC:4
4933 call info_menu_uptime_com ; use part of info_menu_uptime to convert and display in days and hours
4934 STRCAT_PRINT "" ; finalize output
4935 TFT_surface_lastdive_2:
4936 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.1)
4937 MOVII lastdive_duration,mpr ; get duration of last dive, minutes
4938 bsf leftbind ; print without leading spaces
4939 output_16 ; dive time minutes
4940 PUTC ":" ;
4941 movff lastdive_duration+2,lo ; get duration of last dive, seconds
4942 output_99x ; print seconds
4943 rcall TFT_surface_common ; finalize output
4944 TFT_surface_lastdive_3:
4945 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.2)
4946 MOVII lastdive_maxdepth,mpr ; get max depth of last dive
4947 bsf leftbind ; print without leading spaces
4948 TSTOSS opt_units ; 0=Meter, 1=Feet
4949 bra TFT_surface_lastdive_metric ; 0 - metric
4950 rcall TFT_surface_imperial ; 1 - imperial
4951 bra TFT_surface_lastdive_4 ; - continue
4952 TFT_surface_lastdive_metric:
4953 rcall TFT_surface_metric ; print depth in meters
4954 TFT_surface_lastdive_4:
4955 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.3)
4956 MOVII lastdive_avgdepth,mpr ; get avg depth of last dive
4957 bsf leftbind ; print without leading spaces
4958 TSTOSS opt_units ; 0=Meter, 1=Feet
4959 bra TFT_surface_metric ; 0 - metric and return
4960 ;bra TFT_surface_imperial ; 1 - imperial and return
4961
4962 TFT_surface_imperial:
4963 rcall convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
4964 output_16_3 ; limit to 999 and display only (0-999)
4965 STRCAT_TEXT tFeets1 ; "ft"
4966 bra TFT_surface_common ; finalize output
4967
4968 TFT_surface_metric:
4969 bsf ignore_digit5 ; no cm (flag will be cleared by output_16)
4970 movlw .1 ; no 1000 meters
4971 movwf ignore_digits ; ...
4972 output_16dp .3 ; xxx.y
4973 STRCAT_TEXT tMeters ; "m"
4974 ;bra TFT_surface_common ; finalize output
4975
4976 TFT_surface_common:
4977 STRCAT_PRINT "" ; finalize output
4978 bcf leftbind ; clear left-alignment
4979 return ; done
4980
4981 ;=============================================================================
4982
4983 global TFT_surface_tissues
4984 TFT_surface_tissues: ; show tissue diagram in surface mode
4985 3673
4986 ; draw outer frame 3674 ; draw outer frame
4987 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right 3675 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right
4988 3676
4989 ;---- draw labels --------------------------------- ; 3677 ; draw labels
4990 3678 FONT_COLOR_MEMO ; set color
4991 call TFT_standard_color
4992 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row 3679 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row
4993 IFDEF _helium 3680 IFDEF _helium
4994 btfss tissue_graphic_layout ; shall N2 and He? 3681 btfss tissue_graphic_layout ; shall N2 and He?
4995 bra TFT_surface_tissues_1 ; NO - print "Tissues" 3682 bra TFT_surface_tissues_1 ; NO - print "Tissues"
4996 STRCPY_TEXT_PRINT tN2 ; YES - print "N2" 3683 STRCPY_TEXT_PRINT tN2 ; YES - print "N2"
4997 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row 3684 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row
4998 STRCPY_TEXT_PRINT tHe ; - print "He" 3685 STRCPY_TEXT_PRINT tHe ; - print "He"
4999 bra TFT_surface_tissues_2 ; - continue with common part 3686 bra TFT_surface_tissues_2 ; - continue with common part
5000 ENDIF 3687 ENDIF
5001 3688
5002 TFT_surface_tissues_1: 3689 TFT_surface_tissues_1:
5003 STRCPY_TEXT_PRINT tDiveTissues ; print "Tissues" 3690 STRCPY_TEXT_PRINT tDiveTissues ; print "Tissues"
5004 3691
5005 TFT_surface_tissues_2: 3692 TFT_surface_tissues_2:
5006 ;---- draw scale ---------------------------------- ; 3693 ; draw scale
3694
3695 SCALELINE macro x
5007 movlw color_deepblue 3696 movlw color_deepblue
5008 call TFT_set_color 3697 WIN_FRAME_COLOR surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,surf_tissue_diagram_left+.4+x,surf_tissue_diagram_left+.4+x
5009
5010 SCALELINE macro x
5011 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
5012 endm 3698 endm
5013 3699
5014 SCALELINE .0 3700 SCALELINE .0
5015 SCALELINE .8 3701 SCALELINE .8
5016 SCALELINE .16 3702 SCALELINE .16
5021 SCALELINE .56 3707 SCALELINE .56
5022 SCALELINE .64 3708 SCALELINE .64
5023 SCALELINE .72 3709 SCALELINE .72
5024 SCALELINE .80 3710 SCALELINE .80
5025 3711
5026 ;---- common initialization for Tissue Pressures and Saturation ---------- 3712 ; common initialization for tissue pressures and saturation
5027 movlw .1 3713 movlw .1
5028 movwf win_height ; hight of the bargraph (0-239) 3714 movwf win_height ; hight of the bargraph (0-239)
5029 movlw surf_tissue_diagram_left+.4 ; left start position for N2 bars 3715 movlw surf_tissue_diagram_left+.4 ; left start position for N2 bars
5030 movwf win_leftx2 ; column left (0-159) 3716 movwf win_leftx2 ; column left (0-159)
5031 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4 ; get max width for N2 bars (78 pixel) 3717 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4 ; get max width for N2 bars (78 pixel)
5032 movwf win_width+0 ; set width of the bar box 3718 movwf win_width+0 ; set width of the bar box
5033 clrf win_width+1 ; ... 3719 clrf win_width+1 ; ...
5034 movlw color_white ; color for tissues not exceeding surface max pressure 3720 movlw color_white ; color for tissues not exceeding surface max pressure
5035 movwf ex ; store in ex 3721 movwf ex ; store in ex
5036 movlw color_red ; color for tissues exceeding surface max pressure 3722 movlw color_red ; color for tissues exceeding surface max pressure
5037 movwf ul ; store in ul 3723 movwf ul ; store in ul
5038 bcf aux_flag ; draw tissue pressures by default 3724 bcf aux_flag ; draw tissue pressures by default
5039 3725
5040 ;---- Draw combined or N2 Tissue Pressures--------- ; 3726 ; draw combined or N2 tissue pressures
5041 lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default 3727 lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default
5042 IFDEF _helium 3728 IFDEF _helium
5043 btfsc tissue_graphic_layout ; shall show N2+He ? 3729 btfsc tissue_graphic_layout ; shall show N2+He ?
5044 lfsr FSR2,char_O_tissue_pres_N2 ; YES - replace with base address of N2 pressures 3730 lfsr FSR2,char_O_tissue_pres_N2 ; YES - replace with base address of N2 pressures
5045 ENDIF 3731 ENDIF
5046 btfsc tissue_graphic_mode ; in logbook mode? 3732 btfsc tissue_graphic_mode ; in logbook mode?
5047 lfsr FSR2,header_buffer+index_tissue_pres_total ; YES - replace with base address from logbook 3733 lfsr FSR2,header_buffer+index_tissue_pres_total ; YES - replace with base address from logbook
5048 movlw d'16' 3734 movlw d'16'
5049 movwf lo ; tissue counter, 16 tissues 3735 movwf lo ; tissue counter, 16 tissues
5050 clrf hi ; row counter 3736 clrf hi ; row counter
5051 TFT_surf_tissues_N2_loop: 3737 TFT_surf_tissues_N2_loop:
5052 movlw surf_tissue_diagram_top+.23 ; surface mode top start position N2 3738 movlw surf_tissue_diagram_top+.23 ; surface mode top start position N2
5053 rcall TFT_surf_tissues_bargraph ; show one tissue 3739 rcall TFT_surf_tissues_bargraph ; show one tissue
5054 movlw .2 ; bargraph spacing 3740 movlw .2 ; bargraph spacing
5055 addwf hi,F ; increment row counter 3741 addwf hi,F ; increment row counter
5056 decfsz lo,F ; decrement tissue counter, done? 3742 decfsz lo,F ; decrement tissue counter, done?
5057 bra TFT_surf_tissues_N2_loop ; NO - loop 3743 bra TFT_surf_tissues_N2_loop ; NO - loop
5058 IFDEF _helium 3744 IFDEF _helium
5059 btfsc tissue_graphic_layout ; shall show N2+He ? 3745 btfsc tissue_graphic_layout ; shall show N2+He ?
5060 bra TFT_surface_tissues_3 ; YES - show He tissue pressures 3746 bra TFT_surface_tissues_3 ; YES - show He tissue pressures
5061 ENDIF 3747 ENDIF
5062 3748
5063 ;---- Draw Tissue Saturations --------------------- ; 3749 ; draw tissue saturations
5064 lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation 3750 lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation
5065 btfsc tissue_graphic_mode ; in logbook mode? 3751 btfsc tissue_graphic_mode ; in logbook mode?
5066 lfsr FSR2,header_buffer+index_tissue_supersat ; YES - replace with base address from logbook 3752 lfsr FSR2,header_buffer+index_tissue_supersat ; YES - replace with base address from logbook
5067 movlw d'16' 3753 movlw d'16'
5068 movwf lo ; tissue counter, 16 tissues 3754 movwf lo ; tissue counter, 16 tissues
5069 clrf hi ; row counter 3755 clrf hi ; row counter
5070 movlw color_grey ; color for tissue saturation 3756 movlw color_grey ; color for tissue saturation
5071 movwf ex ; store in ex 3757 movwf ex ; store in ex
5072 ; movlw color_yellow ; 2nd color is not used by tissue saturation 3758 ; movlw color_yellow ; 2nd color is not used by tissue saturation
5073 ; movwf ul ; ... 3759 ; movwf ul ; ...
5074 bsf aux_flag ; draw tissue saturation 3760 bsf aux_flag ; draw tissue saturation
5075 TFT_surf_tissues_sat_loop: 3761 TFT_surf_tissues_sat_loop:
5076 movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position saturations 3762 movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position saturations
5077 rcall TFT_surf_tissues_bargraph ; draw tissue bargraph 3763 rcall TFT_surf_tissues_bargraph ; draw tissue bargraph
5078 movlw .2 ; bargraph spacing 3764 movlw .2 ; bargraph spacing
5079 addwf hi,F ; increment row counter 3765 addwf hi,F ; increment row counter
5080 decfsz lo,F ; decrement tissue counter, done? 3766 decfsz lo,F ; decrement tissue counter, done?
5081 bra TFT_surf_tissues_sat_loop ; NO - loop 3767 bra TFT_surf_tissues_sat_loop ; NO - loop
5082 3768
5083 ;---- common Part for vertical lines--------------- ; 3769 ; common part for vertical lines
5084 movlw surf_tissue_diagram_top+.23+.57 ; get top position 3770 movlw surf_tissue_diagram_top+.23+.57 ; get top position
5085 movwf win_top ; set top position (0-239) 3771 movwf win_top ; set top position (0-239)
5086 movlw .30 ; get hight 3772 movlw .30 ; get hight
5087 movwf win_height ; set height 3773 movwf win_height ; set height
5088 movlw .1 ; get width 3774 movlw .1 ; get width
5089 movwf win_width+0 ; set width, low byte 3775 movwf win_width+0 ; set width, low byte
5090 clrf win_width+1 ; set width, high byte 3776 clrf win_width+1 ; set width, high byte
5091 3777
5092 ;---- Print 100% Line ----------------------------- ; 3778 ; print 100% line
5093 movlw surf_tissue_diagram_left+.4+.64 ; get left position 3779 movlw surf_tissue_diagram_left+.4+.64 ; get left position
5094 movwf win_leftx2 ; set left position (0-159) 3780 movwf win_leftx2 ; set left position (0-159)
5095 movlw color_red ; color for 100% line 3781 movlw color_red ; color for 100% line
5096 call TFT_set_color ; set color 3782 BOX_COLOR ; draw the line
5097 call TFT_box ; draw line
5098 3783
5099 ; GF factors enabled? 3784 ; GF factors enabled?
5100 btfss tissue_graphic_gf ; GF factors enabled? 3785 btfss tissue_graphic_gf ; GF factors enabled?
5101 bra TFT_surface_tissues_4 ; NO - continue with CNS 3786 bra TFT_surface_tissues_4 ; NO - continue with CNS
5102 3787
5103 ;---- Print GF low Line -------------------------- ; 3788 ; print GF low line
5104 movlw surf_tissue_diagram_left+.4 ; get left base position 3789 movlw surf_tissue_diagram_left+.4 ; get left base position
5105 movwf win_leftx2 ; set left base position (0-159) 3790 movwf win_leftx2 ; set left base position (0-159)
5106 movff opt_GF_low,WREG ; get GF low in 0.01 % 3791 movff opt_GF_low,WREG ; get GF low in 0.01 %
5107 btfsc tissue_graphic_mode ; in logbook mode? 3792 btfsc tissue_graphic_mode ; in logbook mode?
5108 movff header_buffer+index_gf_lo_hi+0,WREG ; YES - replace by GF low from logbook 3793 movff header_buffer+index_gf_lo_hi+0,WREG ; YES - replace by GF low from logbook
5109 mullw .164 ; multiply with 164 3794 mullw .164 ; multiply with 164
5110 movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625 3795 movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625
5111 addwf win_leftx2,F ; add to base position 3796 addwf win_leftx2,F ; add to base position
5112 movlw color_green ; color for 100% line 3797 movlw color_green ; color for GF low line
5113 call TFT_set_color ; set color 3798 BOX_COLOR ; draw the line
5114 call TFT_box ; draw line 3799
5115 3800 ; print GF high line
5116 ;---- Print GF high Line -------------------------- ; 3801 movlw surf_tissue_diagram_left+.4 ; get left base position
5117 movlw surf_tissue_diagram_left+.4 ; get left base position 3802 movwf win_leftx2 ; set left base position (0-159)
5118 movwf win_leftx2 ; set left base position (0-159) 3803 movff opt_GF_high,WREG ; get GF high in 0.01 %
5119 movff opt_GF_high,WREG ; get GF high in 0.01 % 3804 btfsc tissue_graphic_mode ; in logbook mode?
5120 btfsc tissue_graphic_mode ; in logbook mode? 3805 movff header_buffer+index_gf_lo_hi+1,WREG ; YES - replace by GF high from logbook
5121 movff header_buffer+index_gf_lo_hi+1,WREG ; YES - replace by GF high from logbook 3806 mullw .164 ; multiply with 164
5122 mullw .164 ; multiply with 164 3807 movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625
5123 movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625 3808 addwf win_leftx2,F ; add to base position
5124 addwf win_leftx2,F ; add to base position 3809 movlw color_yellow ; color for GF high line
5125 movlw color_yellow ; color for 100% line 3810 BOX_COLOR ; draw the line
5126 call TFT_set_color ; set color 3811 bra TFT_surface_tissues_4 ; continue with CNS
5127 call TFT_box ; draw line
5128 bra TFT_surface_tissues_4 ; continue with CNS
5129 3812
5130 IFDEF _helium 3813 IFDEF _helium
5131 TFT_surface_tissues_3: 3814 TFT_surface_tissues_3:
5132 ;---- Draw He Tissue Pressures--------------------- ; 3815 ; draw He tissue pressures
5133 movlw surf_tissue_diagram_left+.4+.16 ; start position for He bars 3816 movlw surf_tissue_diagram_left+.4+.16 ; start position for He bars
5134 movwf win_leftx2 ; column left (0-159) 3817 movwf win_leftx2 ; column left (0-159)
5135 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4-.16 ; max width for He bars 3818 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4-.16 ; max width for He bars
5136 movwf win_width+0 ; set total width of the bar box 3819 movwf win_width+0 ; set total width of the bar box
5137 clrf win_width+1 ; ... 3820 clrf win_width+1 ; ...
5138 lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures 3821 lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures
5139 movlw d'16' 3822 movlw d'16'
5140 movwf lo ; tissue counter, 16 tissues 3823 movwf lo ; tissue counter, 16 tissues
5141 clrf hi ; row counter 3824 clrf hi ; row counter
5142 TFT_surf_tissues_He_loop: 3825 TFT_surf_tissues_He_loop:
5143 movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position He 3826 movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position He
5144 rcall TFT_surf_tissues_bargraph ; show one tissue 3827 rcall TFT_surf_tissues_bargraph ; show one tissue
5145 movlw .2 ; bargraph spacing 3828 movlw .2 ; bargraph spacing
5146 addwf hi,F ; increment row counter 3829 addwf hi,F ; increment row counter
5147 decfsz lo,F ; decrement tissue counter, done? 3830 decfsz lo,F ; decrement tissue counter, done?
5148 bra TFT_surf_tissues_He_loop ; NO - loop 3831 bra TFT_surf_tissues_He_loop ; NO - loop
5149 ENDIF 3832 ENDIF
5150 3833
5151 TFT_surface_tissues_4: 3834 TFT_surface_tissues_4:
5152 btfss tissue_graphic_cns ; shall show CNS value? 3835 btfss tissue_graphic_cns ; shall show CNS value?
5153 goto TFT_standard_color ; NO - done 3836 return ; NO - done
5154 3837
5155 ; ---- Draw CNS% ---------------------------------- ; 3838 ; draw CNS% in-between tissue bars
5156 WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row ; position in-between tissue bars 3839 WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row
5157 MOVII int_O_CNS_current,mpr ; get current CNS 3840 MOVII int_O_CNS_current,mpr ; get current CNS
5158 call TFT_color_code_cns ; color-code CNS value 3841 call TFT_color_code_cns ; color-code CNS value
5159 STRCPY_TEXT tCNS2 ; "CNS:" 3842 STRCPY_TEXT tCNS2 ; "CNS: "
5160 bsf leftbind 3843 bsf leftbind ; print left-aligned
5161 output_16_3 ; display only 0...999 3844 output_999 ; print (0-999)
5162 bcf leftbind 3845 PUTC_PRINT "%" ; append unit and dump to screen
5163 STRCAT_PRINT "%" 3846 return ; done
5164 goto TFT_standard_color ; and return... 3847
5165 3848
3849 ; Helper Function - draw a bargraph
5166 TFT_surf_tissues_bargraph: 3850 TFT_surf_tissues_bargraph:
5167 addwf hi,W ; add row number to start position 3851 addwf hi,W ; add row number to start position
5168 movwf win_top ; set as row top (0-239) 3852 movwf win_top ; set as row top (0-239)
5169 movff POSTINC2,up ; get tissue value 3853 movff POSTINC2,up ; get tissue value
5170 movf ex,W ; default color 3854 movf ex,W ; default color
5171 btfsc up,7 ; check if flag in bit 7 is set 3855 btfsc up,7 ; check if flag in bit 7 is set
5172 movf ul,W ; YES - switch to 2nd color 3856 movf ul,W ; YES - switch to 2nd color
5173 call TFT_set_color ; set bargraph bar color 3857 bcf up,7 ; clear flag bit
5174 bcf up,7 ; clear flag bit 3858 btfss aux_flag ; drawing saturations?
5175 btfss aux_flag ; drawing saturations? 3859 rlncf up,F ; NO - multiply with 2 (previously cleared bit 7 will be rotated to bit 0)
5176 rlncf up,F ; NO - multiply with 2 (previously cleared bit 7 will be rotated to bit 0) 3860 movff up,win_bargraph ; set length of the bargraph
5177 incf up,W ; add 1 for a minimum visible bar (He-bars could be invisible else-wise) 3861 incf win_bargraph,F ; add 1 for a minimum visible bar (He-bars could be invisible else-wise)
5178 movwf win_bargraph ; set length of the bargraph 3862 BOX_COLOR ; draw bargraph with color in WREG
5179 goto TFT_box ; draw bargraph and return 3863 return ; done
5180 3864
5181 3865
5182 ;============================================================================= 3866 ;-----------------------------------------------------------------------------
5183 ; Draw saturation graph in dive mode custom view 3867 ; Surface Custom View - Tissue Graphics
5184 ; 3868 ;
5185 TFT_dive_tissues: 3869 global TFT_surf_cv_settings
5186 3870 TFT_surf_cv_settings:
5187 ;---- draw outer frame 3871 ; Deco Mode
5188 call TFT_standard_color 3872 FONT_COLOR_MEMO ; select color
5189 WIN_FRAME_COLOR16 dm_custom_tissue_diagram_top, dm_custom_tissue_diagram_bottom, dm_custom_tissue_diagram_left, .159 ; outer frame 3873 WIN_SMALL surf_gaslist_column,surf_gaslist_row
5190 3874 STRCAT_PRINT "ZH-L16" ; print fix part of model
5191 ;---- clear area showing leading tissue number as it may not be printed over 3875 movff char_I_model,WREG ; get model
5192 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 3876 iorwf WREG ; GF enabled?
5193 3877 bnz TFT_surface_decosettings1 ; YES
5194 TFT_dive_tissues_1: 3878 ;bra TFT_surface_decosettings0 ; NO
5195 ;---- common initialization for Tissue Pressures and Saturation ---------- 3879
5196 movlw .1 3880 TFT_surface_decosettings0:
5197 movwf win_height ; hight of the bargraph (0-239) 3881 ; Display ZH-L16 sat/desat model
5198 movlw dm_custom_tissue_diagram_left+.3 ; get dive mode left start position 3882 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
5199 movwf win_leftx2 ; set column left (0-159) 3883 STRCPY_TEXT tSD ; print label (S/D)
5200 movlw .159-dm_custom_tissue_diagram_left-.4 ; get max width 3884 movff char_I_saturation_multiplier, lo ; get sat mult.
5201 movwf win_width+0 ; set width (low byte) 3885 movff char_I_desaturation_multiplier,hi ; get desat mult.
5202 clrf win_width+1 ; high byte of with is always zero 3886 bra TFT_surface_decosettings_com ; continue with common part
5203 movlw color_cyan ; color for tissues with decreasing pressure 3887
5204 movwf ex ; store in ex 3888 TFT_surface_decosettings1:
5205 movlw color_orange ; color for tissues with increasing pressure 3889 ; Display ZH-L16-GF low/high model
5206 movwf ul ; store in ul 3890 WIN_SMALL surf_gaslist_column+.43,surf_gaslist_row
5207 3891 STRCPY_TEXT_PRINT tZHL16GF ; print GF label behind deco model label
5208 ;---- Draw combined or N2 Tissue Pressures -------- ; 3892
5209 lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default 3893 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
5210 IFDEF _helium 3894 STRCPY_TEXT tGF ; print label (GF:)
5211 btfsc tissue_graphic_layout ; shall show N2+He ? 3895 PUTC ' ' ; print a space
5212 lfsr FSR2,char_O_tissue_pres_N2 ; YES - load base address of N2 pressures 3896 movff opt_GF_low, lo ; get GF low
5213 ENDIF 3897 movff opt_GF_high,hi ; get GF high
5214 movlw d'16' 3898 ;bra TFT_surface_decosettings_com ; continue with common part
5215 movwf lo ; tissue counter, 16 tissues 3899
5216 clrf hi ; row counter 3900 TFT_surface_decosettings_com:
5217 TFT_dive_tissues_N2_loop: 3901 ; percentage pair
5218 movlw dm_custom_tissue_diagram_top+.3 ; dive mode top start position N2 3902 output_256 ; print (0-255)
5219 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph 3903 STRCAT "%/" ; print "%/"
5220 incf hi,F ; increment row counter 3904 movff hi,lo ; get 2nd value
5221 decfsz lo,F ; decrement tissue counter, done? 3905 output_256 ; print (0-255)
5222 bra TFT_dive_tissues_N2_loop ; NO - loop 3906 PUTC_PRINT "%" ; append unit and dump to screen
5223 IFDEF _helium 3907
5224 btfsc tissue_graphic_layout ; shall show N2+He ? 3908 ; fTTS
5225 bra TFT_dive_tissues_3 ; YES - show He tissue pressures 3909 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)
5226 ENDIF 3910 STRCPY_TEXT tFTTSSurf ; print label
5227 3911 movff char_I_extra_time,lo ; get time
5228 ;---- Draw Tissue Saturations --------------------- ; 3912 output_9 ; print time (0-9)
5229 lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation 3913 STRCAT_TEXT_PRINT tMinutes ; append unit and dump to screen
5230 movlw d'16' 3914
5231 movwf lo ; tissue counter, 16 tissues 3915 ; Last Stop
5232 clrf hi ; row counter 3916 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)
5233 movlw color_grey ; color for tissue saturation, alternative: color_lightblue 3917 STRCPY_TEXT tLastDecostopSurf ; print label
5234 movwf ex ; store in ex 3918 movff opt_last_stop,lo ; get depth
5235 ; movlw color_yellow ; 2nd color is not used by tissue saturation 3919 output_9 ; print depth (0-9)
5236 ; movwf ul ; ... 3920 STRCAT_TEXT_PRINT tMeters ; append unit and dump to screen
5237 TFT_dive_tissues_sat_loop: 3921
5238 movlw dm_custom_tissue_diagram_top+.3+.22 ; dive mode top start position saturations 3922 ; Salinity
5239 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph 3923 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4)
5240 incf hi,F ; increment row counter 3924 STRCPY_TEXT tDvSalinitySurf ; print label
5241 decfsz lo,F ; decrement tissue counter, done? 3925 movff opt_salinity,lo ; get salinity
5242 bra TFT_dive_tissues_sat_loop ; NO - loop 3926 output_9 ; print salinity (0-9)
5243 3927 STRCAT_TEXT_PRINT tPercent ; append unit and dump to screen
5244 ;---- common Part for vertical lines--------------- ; 3928
5245 movlw dm_custom_tissue_diagram_top+.3+.22 ; get top position 3929 return ; done
5246 movwf win_top ; set top position (0-239) 3930
5247 movlw .15 ; get hight
5248 movwf win_height ; set height
5249 movlw .1 ; get width
5250 movwf win_width+0 ; set width, low byte
5251 clrf win_width+1 ; set width, high byte
5252
5253 ;---- Print 100% Line ----------------------------- ;
5254 movlw dm_custom_tissue_diagram_left+.3+.33 ; get left position
5255 movwf win_leftx2 ; set left position (0-159)
5256 movlw color_red ; color for 100% line
5257 call TFT_set_color ; set color
5258 call TFT_box ; draw line
5259
5260 ; GF factors enabled?
5261 btfss tissue_graphic_gf ; shall show GF lines?
5262 bra TFT_dive_tissues_4 ; NO - continue with number of leading tissue
5263
5264 ;---- Print GF low Line -------------------------- ;
5265 movlw dm_custom_tissue_diagram_left+.3 ; get left base position
5266 movwf win_leftx2 ; set left base position (0-159)
5267 movff char_I_GF_Low_percentage,WREG ; get GF low in 0.01 %
5268 mullw .82 ; multiply with 82
5269 movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125
5270 addwf win_leftx2,F ; add to base position
5271 movlw color_green ; color for 100% line
5272 call TFT_set_color ; set color
5273 call TFT_box ; draw line
5274
5275 ;---- Print GF high Line -------------------------- ;
5276 movlw dm_custom_tissue_diagram_left+.3 ; get left base position
5277 movwf win_leftx2 ; set left base position (0-159)
5278 movff char_I_GF_High_percentage,WREG ; get GF high in 0.01 %
5279 mullw .82 ; multiply with 82
5280 movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125
5281 addwf win_leftx2,F ; add to base position
5282 movlw color_yellow ; color for 100% line
5283 call TFT_set_color ; set color
5284 call TFT_box ; draw line
5285 bra TFT_dive_tissues_4 ; continue with number of leading tissue
5286
5287 IFDEF _helium
5288 TFT_dive_tissues_3:
5289 ;---- Draw He Tissues Pressures ------------------- ;
5290 lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures
5291 movlw dm_custom_tissue_diagram_left+.3+.4 ; get dive mode left start position for He bars
5292 movwf win_leftx2 ; set column left (0-159)
5293 movlw .159-dm_custom_tissue_diagram_left-.4-.4 ; get max width for He bars
5294 movwf win_width+0 ; set width (low byte)
5295 clrf win_width+1 ; ...
5296 movlw d'16'
5297 movwf lo ; tissue counter, 16 tissues
5298 clrf hi ; row counter
5299 TFT_dive_tissues_He_loop:
5300 movlw dm_custom_tissue_diagram_top+.3+.22 ; dive mode top start position H2
5301 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
5302 incf hi,F ; increment row counter
5303 decfsz lo,F ; decrement tissue counter, done?
5304 bra TFT_dive_tissues_He_loop ; NO - loop
5305 ENDIF
5306
5307 TFT_dive_tissues_4:
5308 ;---- Print Number of leading Tissue -------------- ; TODO: some flicker due to overwriting by tissue bars
5309 movff int_O_lead_supersat+0,WREG ; get current leading tissue's supersaturation (only low byte used for value)
5310 tstfsz WREG ; current supersaturation = 0 ?
5311 bra TFT_dive_tissues_5 ; NO - print number of leading tissue
5312 movff char_O_deco_info,WREG ; YES - get deco info vector
5313 btfss WREG,deco_ceiling ; - do we have a ceiling obligation?
5314 goto TFT_standard_color ; NO - can ascent directly, don't print number, set standard color and return
5315 ; YES - print number of leading tissue
5316 TFT_dive_tissues_5:
5317 movff char_O_lead_tissue,lo ; get number of leading tissue as 0-15
5318 incf lo,F ; adjust to 1-16
5319 movlw .10
5320 cpfsgt lo ; is it > 10 ?
5321 bra TFT_dive_tissues_6 ; NO - will output a single digit number
5322 ; start position for a 2 digit number
5323 WIN_TINY dm_custom_tissue_diagram_left+.32,dm_custom_tissue_diagram_top+.10
5324 bra TFT_dive_tissues_7
5325 TFT_dive_tissues_6:
5326 ; start position for a 1 digit number
5327 WIN_TINY dm_custom_tissue_diagram_left+.32+.4,dm_custom_tissue_diagram_top+.10
5328 TFT_dive_tissues_7:
5329 call TFT_standard_color ; set output color
5330 bsf leftbind
5331 output_8 ; print number in left aligned, i.e. without leading zeros or spaces
5332 bcf leftbind
5333 STRCAT_PRINT "" ; finalize output
5334 return
5335
5336 TFT_dive_tissues_bargraph:
5337 addwf hi,W ; add row number to start position
5338 movwf win_top ; set as row top (0-239)
5339 movff POSTINC2,up ; get tissue value
5340 movf ex,W ; default color
5341 btfsc up,7 ; check if flag in bit 7 is set
5342 movf ul,W ; YES - switch to 2nd color
5343 call TFT_set_color ; set bargraph bar color
5344 bcf up,7 ; clear flag bit
5345 bcf STATUS,C ; clear carry bit
5346 rrcf up,F ; divide by 2
5347 incf up,W ; add a bit for a minimum visible bar
5348 movwf win_bargraph ; set bargraph bar length
5349 goto TFT_box ; draw bargraph and return
5350
5351 ;=============================================================================
5352
5353 global TFT_show_cns
5354 TFT_show_cns:
5355 call TFT_set_message_window ; set row and column for the message
5356 tstfsz WREG ; is there room for the message?
5357 return ; NO - skip message in this cycle
5358 STRCPY_TEXT tCNS ; CNS:
5359 MOVII int_O_CNS_current,mpr ; get current CNS
5360 call TFT_color_code_cns ; color-code CNS output
5361 bsf leftbind
5362 output_16_3 ; displays only 0...999
5363 bcf leftbind
5364 PUTC "%"
5365 movlw dm_warning_length ; dive mode string length
5366 btfss divemode ; In dive mode?
5367 movlw surf_warning_length ; NO - use surface string length
5368 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
5369 STRCAT_PRINT ""
5370 bcf win_invert
5371 bra TFT_custview_exit3 ; and return...
5372
5373
5374 global TFT_warning_eod_cns
5375 TFT_warning_eod_cns:
5376 call TFT_set_message_window ; set row and column for the message
5377 tstfsz WREG ; is there room for the message?
5378 return ; NO - skip message in this cycle
5379 call TFT_warning_color ; switch to warnings (red) text color
5380 STRCPY_TEXT tCNSeod ; end-of-dive CNS warning text
5381 movlw dm_warning_length ; dive mode string length
5382 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
5383 STRCAT_PRINT ""
5384 bra TFT_custview_exit3 ; and return...
5385
5386
5387 global TFT_show_ppo2_warning
5388 TFT_show_ppo2_warning:
5389 call TFT_set_message_window ; set row and column for the message
5390 tstfsz WREG ; is there room for the message?
5391 return ; NO - skip message in this cycle
5392 call TFT_color_code_ppo2 ; color-code output
5393 btfsc bailout_mode ; in bailout?
5394 bra TFT_display_diluent_2 ; YES
5395 btfss FLAG_ccr_mode ; in CCR mode?
5396 bra TFT_display_diluent_1 ; NO - continue with pSCR or OC
5397 STRCPY_TEXT tdil ; YES - print "Dil:"
5398 bra TFT_display_diluent_3
5399 TFT_display_diluent_1:
5400 btfss FLAG_pscr_mode ; in pSCR mode?
5401 bra TFT_display_diluent_2 ; NO - continue with OC
5402 STRCPY_TEXT tmix ; YES - print "Mix:"
5403 bra TFT_display_diluent_3
5404 TFT_display_diluent_2:
5405 STRCPY_TEXT tppO2 ; bailout or OC mode, print "ppO2:"
5406 TFT_display_diluent_3:
5407 bsf leftbind
5408 output_16dp .3 ; x.xx bar
5409 bcf leftbind
5410 movlw dm_warning_length ; dive mode string length
5411 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
5412 STRCAT_PRINT ""
5413 TFT_custview_exit3:
5414 goto TFT_standard_color ; and return...
5415
5416
5417 IFDEF _compass
5418
5419 global TFT_surf_set_bearing
5420 TFT_surf_set_bearing:
5421 btfsc compass_menu ; is the "set bearing" selection shown?
5422 return ; YES - return
5423 bsf compass_menu ; NO - set "set bearing" selection as shown
5424 WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right
5425 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row
5426 WIN_COLOR color_yellow
5427 bsf win_invert
5428 STRCPY_TEXT_PRINT tSetHeading ; 7 chars
5429 bcf win_invert
5430 return
5431
5432 ENDIF
5433
5434 ;=============================================================================
5435
5436 global TFT_LogOffset
5437 TFT_LogOffset:
5438 STRCPY_TEXT tLogOffsetValue ; print "Offset" in selected language
5439 call eeprom_log_offset_read ; read offset into lo:hi
5440 ; bsf leftbind
5441 output_16_4 ; print offset in 4 digits
5442 ; bcf leftbind
5443 return ; no "_PRINT" here...
5444
5445 ;=============================================================================
5446 ; RX Functions
5447 3931
5448 IFDEF _rx_functions 3932 IFDEF _rx_functions
5449 3933
5450 global TFT_pressures_SAC_mask ; mask for pressures and SAC 3934 ;-----------------------------------------------------------------------------
5451 TFT_pressures_SAC_mask: 3935 ; Surface Custom View - TR - Tank Data
5452 call TFT_divemask_color 3936 ;
5453 ; pressure reading 1 3937 global TFT_surf_cv_tankdata
5454 WIN_TINY dm_custom_tankdata_pres1_col, dm_custom_tankdata_mask_row 3938 TFT_surf_cv_tankdata:
5455 movff char_I_pressure_gas+0,WREG ; =0: disabled, =1..10: gases/dils 3939 lfsr FSR1,rx_buffer ; load base address of RX buffer
5456 bcf aux_flag ; selector for disabled / need set to disabled 3940
5457 call TFT_pressures_SAC_mask_helper ; print gas composition or " ---" if disabled 3941 IFNDEF _rx_functions_debug
5458 ; pressure reading 2 3942
5459 WIN_TINY dm_custom_tankdata_pres2_col, dm_custom_tankdata_mask_row
5460 movff char_I_pressure_gas+1,WREG ; =0: need to reading 1, =1..10: gases/dils
5461 bsf aux_flag ; selector for disabled / need set to need
5462 call TFT_pressures_SAC_mask_helper ; print gas composition or "Need " if 0
5463 ; SAC rate
5464 WIN_TINY dm_custom_tankdata_SAC_col, dm_custom_tankdata_mask_row
5465 STRCPY_TEXT tSAC ; "SAC
5466 STRCAT " (" ; (
5467 STRCAT_TEXT tLitersMinute ; l/min
5468 STRCAT_PRINT ")" ; )"
5469 bra TFT_custview_exit3 ; and return...
5470
5471 TFT_pressures_SAC_mask_helper:
5472 tstfsz WREG ; pressure reading assigned?
5473 bra TFT_dive_tankdata_mask_helper_1 ; YES - print gas composition
5474 btfsc aux_flag ; NO - check auxiliary flag
5475 bra TFT_dive_tankdata_mask_helper_2 ; 1 - print "Need "
5476 STRCAT_PRINT " ---" ; 0 - print " ---"
5477 return ; - done
5478 TFT_dive_tankdata_mask_helper_1:
5479 decf WREG,W ; (1..10) -> (0..9)
5480 bsf short_gas_descriptions ; just "Air", "O2" or "xx/yy"
5481 call gaslist_strcat_gas_WREG ; print composition of gas/dil in WREG (0..9)
5482 bra TFT_dive_tankdata_mask_helper_3 ; finish with adding "(bar)"
5483 TFT_dive_tankdata_mask_helper_2:
5484 STRCPY_TEXT tNeed ; "Need"
5485 TFT_dive_tankdata_mask_helper_3:
5486 STRCAT_PRINT "(bar)"
5487 return
5488
5489
5490 global TFT_pressures_SAC ; data for pressures and SAC
5491 TFT_pressures_SAC:
5492 ; check mode for second reading
5493 bcf aux_flag ; clear auxiliary flag by default (reading 2 is pressure)
5494 movff char_I_pressure_gas+1,WREG ; =0: need to reading 1, =1..10: gases/dils
5495 addlw .0 ; dummy operation to set status register flags
5496 btfsc STATUS,Z ; gas selected = 0 (i.e. no 2nd pressure reading) ?
5497 bsf aux_flag ; YES - set auxiliary flag (display position of reading 2 shall show need to reading 1)
5498 ; get data of reading 1
5499 movff int_IO_pressure_value+0,lo ; copy pressure 1 to hi:lo
5500 movff int_IO_pressure_value+1,hi
5501 movff char_I_pressure_stat+0,ex ; copy status data
5502 ; pressure of reading 1
5503 WIN_STD dm_custom_tankdata_pres1_col+.4,dm_custom_tankdata_row
5504 rcall TFT_pressures_SAC_helper_1 ; print pressure if available, else " ---"
5505 ; battery status of reading 1
5506 WIN_SMALL dm_custom_hud_sensor1_column+.4+.36,dm_custom_tankdata_row
5507 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator
5508 ; get data for reading 2
5509 btfsc aux_flag ; shall reading 2 show need to reading 1 ?
5510 bra TFT_pressures_SAC_1 ; YES
5511 movff int_IO_pressure_value+2,lo ; NO - copy pressure 2 to hi:lo
5512 movff int_IO_pressure_value+3,hi
5513 movff char_I_pressure_stat+1,ex ; - copy status data
5514 bra TFT_pressures_SAC_2
5515 TFT_pressures_SAC_1:
5516 MOVII int_O_pressure_need,mpr ; YES - copy need to pressure 1 to hi:lo
5517 clrf ex ; - set status data to 0
5518 TFT_pressures_SAC_2:
5519 ; pressure of reading 2
5520 WIN_STD dm_custom_tankdata_pres2_col+.2,dm_custom_tankdata_row
5521 rcall TFT_pressures_SAC_helper_1 ; print pressure if available, else " ---"
5522 ; battery status of reading 2
5523 WIN_SMALL dm_custom_tankdata_pres2_col+.2+.36,dm_custom_tankdata_row
5524 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator
5525 ; SAC
5526 WIN_STD dm_custom_tankdata_SAC_col+.6,dm_custom_tankdata_row
5527 MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo
5528 btfsc hi,int_not_avail_flag ; SAC rate available?
5529 bra TFT_pressures_SAC_4 ; NO - print " --.-"
5530 call TFT_color_code_tank_pres_sac ; color-code the output
5531 output_16_3 ; print as xxx
5532 PUTC " " ; print a dummy char to have the string termination at the correct place
5533 movff buffer+.2,buffer+.3 ; move the decimal digit one position to the right
5534 movlw "." ; load coding of a decimal point
5535 movff WREG,buffer+.2 ; place it before decimal digit
5536 movlw " " ; load coding of a space character
5537 movff buffer+.1,up ; get the character in front of the decimal point
5538 cpfseq up ; is it a space?
5539 bra TFT_pressures_SAC_3 ; NO - continue
5540 movlw "0" ; YES - load coding of a zero
5541 movff WREG,buffer+.1 ; - place a zero in front of the decimal point
5542 TFT_pressures_SAC_3:
5543 STRCAT_PRINT "" ; dump buffer to screen
5544 bra TFT_custview_exit3 ; and return...
5545 TFT_pressures_SAC_4:
5546 call TFT_disabled_color
5547 STRCAT_PRINT "--.-" ; output for no SAC data available
5548 bra TFT_custview_exit3 ; and return...
5549
5550 TFT_pressures_SAC_helper_1:
5551 btfss hi,int_not_avail_flag ; pressure available?
5552 bra TFT_pressures_SAC_helper_1a ; YES - print pressure
5553 call TFT_disabled_color ; NO - use disabled color as default
5554 ; btfsc ex,char_transmitter_lost ; - transmitter lost?
5555 ; call TFT_attention_color ; YES - use attention color
5556 STRCAT_PRINT " ---" ; - print " ---"
5557 return
5558 TFT_pressures_SAC_helper_1a:
5559 btfsc hi,int_warning_flag ; out of range (signaled by warning flag)?
5560 bra TFT_pressures_SAC_helper_1c ; YES - special treatment
5561 call TFT_color_code_tank_pres_sac ; NO - color-code the output
5562 bsf ignore_digit5 ; - no 0.1 bar (flag will be cleared by output_16)
5563 movf lo,W ;
5564 iorwf hi,W ; - pressure value = 0 ?
5565 bnz TFT_pressures_SAC_helper_1b ; NO - print value
5566 STRCPY_PRINT " 0" ; YES - print a zero manually
5567 return ; - done
5568 TFT_pressures_SAC_helper_1b:
5569 output_16 ; print hi:lo
5570 STRCAT_PRINT "" ; dump buffer to screen
5571 return ; done
5572 TFT_pressures_SAC_helper_1c:
5573 call TFT_color_code_tank_pres_sac ; color-code the output (clears all flags)
5574 STRCPY_PRINT ">400" ; print ">400"
5575 return ; done
5576
5577 TFT_pressures_SAC_helper_2:
5578 btfss ex,char_transmitter_low_bat ; low battery flag set?
5579 bra TFT_pressures_SAC_helper_2a ; NO - wipe out down arrow (low bat indicator)
5580 call TFT_attention_color ; YES - use attention color
5581 STRCPY_PRINT "\xb8" ; - print down arrow as bat low indication
5582 return
5583 TFT_pressures_SAC_helper_2a:
5584 STRCPY_PRINT " " ; wipe out down arrow (low bat indicator)
5585 return
5586
5587
5588 global TFT_menu_tank_pres
5589 TFT_menu_tank_pres: ; imprinting function for main menu / tank setup
5590 call TFT_standard_color
5591 ; get ID
5592 lfsr FSR1,opt_transmitter_id_1 ; load base address of opt_transmitter_id
5593 movf gaslist_gas,W ; get current gas
5594 rlncf WREG,W ; multiply by 2 because IDs are 2 byte in size
5595 movff PLUSW1,lo ; copy opt_transmitter_id+0[gaslist_gas] to lo
5596 incf WREG,W ; increment index
5597 movff PLUSW1,hi ; copy opt_transmitter_id+1[gaslist_gas] to hi
5598 ; show pressure
5599 WIN_SMALL .90, .61 ; column, row (+/- 27 per row)
5600 call get_pres_by_transmitter_id ; get pressure into hi:lo
5601 tstfsz WREG ; do we have valid tank data (WREG=0) ?
5602 bra TFT_menu_tank_pres_1 ; NO - transmitter not found
5603 call TFT_color_code_tank_pres_sac ; set output color according to flags
5604 bsf ignore_digit5 ; no 0.1 bar (flag will be cleared by output_16)
5605 output_16
5606 bra TFT_menu_tank_pres_2
5607 TFT_menu_tank_pres_1:
5608 call TFT_disabled_color
5609 STRCAT " ---" ; output for no pressure data available
5610 TFT_menu_tank_pres_2:
5611 STRCAT_TEXT_PRINT tbar ; " bar"
5612 bra TFT_custview_exit3 ; and return...
5613
5614
5615 global TFT_surface_tank_pres
5616 TFT_surface_tank_pres: ; show pressure reading above surface pressure
5617 WIN_SMALL surf_decotype_column+.6,surf_decotype_row+.30+.47
5618 movff int_IO_pressure_value+0,lo ; copy pressure from 1st reading to hi:lo
5619 movff int_IO_pressure_value+1,hi
5620 btfss hi,int_not_avail_flag ; pressure reading 1 available?
5621 bra TFT_surface_tank_pres_0 ; YES
5622 movff int_IO_pressure_value+2,lo ; NO - copy pressure from 2nd reading to hi:lo
5623 movff int_IO_pressure_value+3,hi
5624 btfsc hi,int_not_avail_flag ; - pressure reading 2 available?
5625 bra TFT_surface_tank_pres_1 ; NO - show not avail message
5626 TFT_surface_tank_pres_0: ; YES - show pressure
5627 call TFT_color_code_tank_pres_sac ; set output color according to flags
5628 bsf ignore_digit5 ; no 0.1 bar (flag will be cleared by output_16)
5629 output_16
5630 STRCAT_PRINT ""
5631 bra TFT_surface_tank_pres_2
5632 TFT_surface_tank_pres_1:
5633 call TFT_disabled_color
5634 STRCAT_PRINT " ---" ; output for no pressure data available
5635 TFT_surface_tank_pres_2:
5636 WIN_SMALL surf_decotype_column+.38,surf_decotype_row+.30+.47
5637 call TFT_divemask_color
5638 STRCAT_PRINT "bar" ; can not use tbar because it has a leading space
5639 bra TFT_custview_exit3 ; and return...
5640
5641
5642 global TFT_surface_tankdata
5643 TFT_surface_tankdata:
5644 lfsr FSR1,rx_buffer ; load base address of RX buffer
5645 ; bra TFT_surface_tankdata_debug ; comment in for +++ debug version +++
5646 WIN_SMALL surf_customtext_column,surf_customtext_row1 3943 WIN_SMALL surf_customtext_column,surf_customtext_row1
5647 rcall TFT_surface_tankdata_print 3944 rcall TFT_surface_tankdata_print
5648 WIN_SMALL surf_customtext_column,surf_customtext_row2 3945 WIN_SMALL surf_customtext_column,surf_customtext_row2
5649 rcall TFT_surface_tankdata_print 3946 rcall TFT_surface_tankdata_print
5650 WIN_SMALL surf_customtext_column,surf_customtext_row3 3947 WIN_SMALL surf_customtext_column,surf_customtext_row3
5651 rcall TFT_surface_tankdata_print 3948 rcall TFT_surface_tankdata_print
5652 WIN_SMALL surf_customtext_column,surf_customtext_row4 3949 WIN_SMALL surf_customtext_column,surf_customtext_row4
5653 rcall TFT_surface_tankdata_print 3950 rcall TFT_surface_tankdata_print
5654 WIN_SMALL surf_customtext_column,surf_customtext_row5 3951 WIN_SMALL surf_customtext_column,surf_customtext_row5
5655 rcall TFT_surface_tankdata_print 3952 rcall TFT_surface_tankdata_print
3953
3954 return ; done
3955
3956
3957 ; Helper Function - print transmitter data (max 12 char)
3958 TFT_surface_tankdata_print:
3959 FONT_COLOR_MEMO ; set color
3960 movff POSTINC1,hi ; get ID high (+0)
3961 movff POSTINC1,lo ; get ID low (+1)
3962 tstfsz hi ; ID high = 0 ?
3963 bra TFT_surface_tankdata_print_1; NO - slot in use
3964 tstfsz lo ; ID low = 0?
3965 bra TFT_surface_tankdata_print_1; NO - slot in use
3966 STRCAT_PRINT "---- " ; YES - mark as unused and clear rest of line from previous remains
3967 movf POSTINC1,W ; - dummy read (+2) to advance index
3968 movf POSTINC1,W ; - dummy read (+3) to advance index
3969 movf POSTINC1,W ; - dummy read (+4) to advance index
3970 bra TFT_surface_tankdata_print_3; - one more dummy read and return
3971
3972 TFT_surface_tankdata_print_1:
3973 movf hi,W ; copy ID high to WREG
3974 output_hex ; print as hex 2 chars
3975 movf lo,W ; copy ID low to WREG
3976 output_hex ; print as hex 2 chars (4 in total)
3977 movff POSTINC1,hi ; get pressure high (+2)
3978 movff POSTINC1,lo ; get pressure low (+3)
3979 call TFT_color_code_pres_sac ; needed to clear the status flags before output
3980 bsf omit_digit_1 ; do not print 1st digit (0.1 bar)
3981 output_65535 ; print (0x-6553x) 4 chars (8 in total)
3982 PUTC " " ; 1 char (9 in total)
3983 movf POSTINC1,W ; get status (+4)
3984 andlw .7 ; mask out battery voltage
3985 bnz TFT_surface_tankdata_2 ; branch if battery is not completely drained
3986 FONT_COLOR_WARNING ; output in red
3987 STRCAT_PRINT "XXX" ; "XXX" for low
3988 bra TFT_surface_tankdata_print_3; one more dummy read and return
3989
3990 TFT_surface_tankdata_2:
3991 addlw .28 ; add offset of 2.8 Volt
3992 movff WREG,lo ; copy to lo
3993 bsf decimal_digit1 ; put a decimal point in front of digit 1
3994 output_99 ; print voltage 2 chars (11 in total)
3995 PUTC_PRINT " " ; dummy char 1 char (12 in total)
3996
3997 TFT_surface_tankdata_print_3:
3998 movf POSTINC1,W ; dummy read (+5) to advance index
3999 return ; done
4000
4001 ELSE ; _rx_functions_debug
4002
4003 TFT_surface_tankdata_debug: ; surface custom view debug output
4004 FONT_COLOR_MEMO ; set color
4005 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*0
4006 rcall TFT_surface_tankdata_debug_print
4007 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*1
4008 rcall TFT_surface_tankdata_debug_print
4009 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*2
4010 rcall TFT_surface_tankdata_debug_print
4011 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*3
4012 rcall TFT_surface_tankdata_debug_print
4013 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*4
4014 rcall TFT_surface_tankdata_debug_print
4015 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*5
4016 rcall TFT_surface_tankdata_debug_print
4017 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*6
4018 rcall TFT_surface_tankdata_debug_print
4019 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*7
4020 rcall TFT_surface_tankdata_debug_print
4021 return ; done
4022
4023 TFT_surface_tankdata_debug_print:
4024 movff POSTINC1,hi ; read ID high (+0)
4025 output_hex ; print as hex
4026 movff POSTINC1,lo ; read ID low (+1)
4027 output_hex ; print as hex
4028 PUTC "," ; print ","
4029 movff POSTINC1,hi ; read pressure high (+2)
4030 movff POSTINC1,lo ; read pressure low (+3)
4031 call TFT_color_code_pres_sac ; needed to clear the status flags before output
4032 bsf decimal_digit1 ; place a decimal point in front of digit 1
4033 output_9999 ; print pressure (0.0-999.9)
4034 PUTC "," ; print ","
4035 movff POSTINC1,lo ; read status (+4)
4036 output_hex ; print as hex
4037 PUTC "," ; print ","
4038 movff POSTINC1,lo ; read date (+5)
4039 output_256 ; print (0-255)
4040 PRINT ; dump to screen
4041 return ; done
4042
4043 ENDIF ; _rx_functions_debug
4044 ENDIF ; _rx_functions
4045
4046 IFDEF _compass
4047
4048 ;-----------------------------------------------------------------------------
4049 ; Surface Custom View - Compass - "set Bearing Dialog"
4050 ;
4051 global TFT_surf_cv_compass_bearing
4052 TFT_surf_cv_compass_bearing:
4053 btfsc compass_menu ; is the "set bearing" selection shown?
4054 return ; YES - done
4055 bsf compass_menu ; NO - set "set bearing" selection as shown
4056 WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right
4057 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row
4058 FONT_COLOR color_yellow ; set color
4059 bsf win_invert ; print inverse
4060 STRCPY_TEXT_PRINT tSetHeading ; 7 chars
4061 return ; done
4062
4063 ENDIF ; _compass
4064
4065 IFDEF _ccr_pscr
4066
4067 ;-----------------------------------------------------------------------------
4068 ; Surface Custom View - Diluent List
4069 ;
4070 global TFT_surf_cv_list_dil
4071 TFT_surf_cv_list_dil:
4072 movlw .5 ; do diluents (5-9)
4073 bra TFT_surf_cv_list_gas_common ; continue with common part
4074
4075
4076 ;-----------------------------------------------------------------------------
4077 ; Surface Custom View - Setpoint List
4078 ;
4079 global TFT_surf_cv_list_sp ; show setpoint list
4080 TFT_surf_cv_list_sp:
4081 FONT_COLOR_MEMO ; set color
4082 bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_PRODL and gaslist_strcat_setpoint
4083 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
4084
4085 ;SP 1
4086 WIN_SMALL surf_gaslist_column,surf_gaslist_row
4087 clrf gaslist_gas ; select SP 1
4088 call gaslist_strcat_setpoint ; show setpoint data
4089 PRINT ; dump to screen
4090
4091 ;SP 2
4092 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
4093 incf gaslist_gas,F ; select next SP
4094 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
4095 PRINT ; dump to screen
4096
4097 ;SP 3
4098 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)
4099 incf gaslist_gas,F ; select next SP
4100 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
4101 PRINT ; dump to screen
4102
4103 ;SP 4
4104 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)
4105 incf gaslist_gas,F ; select next SP
4106 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
4107 PRINT ; dump to screen
4108
4109 ;SP 5
4110 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4)
4111 incf gaslist_gas,F ; select next SP
4112 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
4113 PRINT ; dump to screen
4114
4115 return ; done
4116
4117 ENDIF ; _ccr_pscr
4118
4119
4120 ;=============================================================================
4121 tft_out14 CODE
4122 ;=============================================================================
4123
4124
4125 ;-----------------------------------------------------------------------------
4126 ; Dive Custom View - AVR / Stopwatch - Mask
4127 ;
4128 global TFT_avr_stopwatch_mask
4129 TFT_avr_stopwatch_mask:
4130 FONT_COLOR_MASK ; select color
4131
4132 IFNDEF _min_depth_option
4133
4134 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row
4135 TSTOSS opt_2ndDepthDisp ; show avg depth instead of max depth in main screen?
4136 bra TFT_avr_stopwatch_mask_1 ; NO - draw avg depth in custom view then
4137 btfss alt_layout_active ; YES - in alternative layout?
4138 bra TFT_avr_stopwatch_mask_max ; NO - show max depth
4139 ;bra TFT_avr_stopwatch_mask_avg ; YES - show avg depth
4140
4141 TFT_avr_stopwatch_mask_avg:
4142 STRCPY_TEXT_PRINT tDiveTotalAvg ; mask for average depth
4143 bra TFT_avr_stopwatch_mask_2 ; continue
4144
4145 TFT_avr_stopwatch_mask_1:
4146 btfss alt_layout_active ; YES - in alternative layout?
4147 bra TFT_avr_stopwatch_mask_avg ; NO - show avg depth
4148 ;bra TFT_avr_stopwatch_mask_max ; YES - show max depth
4149
4150 TFT_avr_stopwatch_mask_max:
4151 STRCPY_TEXT_PRINT tMaxDepth ; mask for maximum depth
4152 ;bra TFT_avr_stopwatch_mask_2 ; continue
4153
4154 TFT_avr_stopwatch_mask_2:
4155 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row
4156 STRCPY_TEXT_PRINT tDiveStopwatch ; print label
4157
4158 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row
4159 STRCPY_TEXT_PRINT tDiveStopAvg ; print label
4160
4161 return ; done
4162
4163 ELSE
4164
4165 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row
4166 STRCPY_PRINT "Max.Depth" ; print label
4167
4168 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row
4169 STRCPY_PRINT "Avg.Depth" ; print label
4170
4171 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row
4172 STRCPY_PRINT "Min.Depth" ; print label
4173
4174 return ; done
4175
4176 ENDIF
4177
4178
4179 ;-----------------------------------------------------------------------------
4180 ; Dive Custom View - AVR / Stopwatch - Data
4181 ;
4182 global TFT_avr_stopwatch
4183 TFT_avr_stopwatch:
4184 FONT_COLOR_MEMO ; select color
4185
4186 IFNDEF _min_depth_option
4187
4188 ; total average depth or max depth
4189 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row
4190 TSTOSS opt_2ndDepthDisp ; show average depth instead of maximum depth in main screen?
4191 bra TFT_avr_stopwatch_1 ; NO - draw avg depth in custom view then
4192 btfsc alt_layout_active ; YES - in alternative layout?
4193 bra TFT_avr_stopwatch_avg ; YES - show avg depth
4194 bra TFT_avr_stopwatch_max ; NO - show max depth
4195
4196 TFT_avr_stopwatch_1:
4197 btfsc alt_layout_active ; YES - in alternative layout?
4198 bra TFT_avr_stopwatch_max ; YES - show max depth
4199 ;bra TFT_avr_stopwatch_avg ; NO - show avg depth
4200
4201 TFT_avr_stopwatch_avg:
4202 MOVII pressure_rel_avg_total,mpr ; get total dive average pressure into hi:lo
4203 bra TFT_avr_stopwatch_2 ; continue
4204
4205 TFT_avr_stopwatch_max:
4206 MOVII pressure_rel_max_cached,mpr ; get maximum pressure into hi:lo
4207 ;bra TFT_avr_stopwatch_2 ; continue
4208
4209 TFT_avr_stopwatch_2:
4210 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
4211 TSTOSS opt_units ; 0=m, 1=ft
4212 bra TFT_update_avr_stopwatch1_metric; 0 - metric
4213 ;bra TFT_update_avr_stopwatch1_imp ; 1 - imperial
4214
4215 TFT_update_avr_stopwatch1_imp:
4216 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
4217 output_999 ; print (0-999)
4218 PRINT ; dump to screen
4219 bra TFT_update_avr_stopwatch2 ; continue
4220
4221 TFT_update_avr_stopwatch1_metric:
4222 rcall TFT_update_avr_stopwatch_metric ; print metric depth
4223 ;bra TFT_update_avr_stopwatch2 ; continue
4224
4225 TFT_update_avr_stopwatch2:
4226 ; stopped average depth
4227 WIN_MEDIUM dm_custom_avr_stop_column3,dm_custom_avr_stop_row
4228 MOVII pressure_rel_avg_trip,mpr ; get the resettable average pressure
4229 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
4230 TSTOSS opt_units ; 0=m, 1=ft
4231 bra TFT_update_avr_stopwatch2_metric; 0 - metric
4232 ;bra TFT_update_avr_stopwatch2_imp ; 1 - imperial
4233
4234 TFT_update_avr_stopwatch2_imp:
4235 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
4236 output_999 ; print (0-999)
4237 PRINT ; dump to screen
4238 bra TFT_update_avr_stopwatch3 ; continue
4239
4240 TFT_update_avr_stopwatch2_metric:
4241 rcall TFT_update_avr_stopwatch_metric ; print metric depth
4242 bra TFT_update_avr_stopwatch3 ; continue
4243
4244
4245 ; Helper Function - print metric depth
4246 TFT_update_avr_stopwatch_metric:
4247 bsf leftbind ; print left-aligned
4248 bsf omit_digit_1 ; do not print 1st digit (no cm)
4249 bsf decimal_digit2 ; place a decimal point in front of digit 2
4250 output_65535 ; print (0.0x-655.3x)
4251 PUTC " " ; wipe out remains from last output
4252 clrf WREG
4253 movff WREG,buffer+.4 ; limit string length to 4 = 3 digits + 1 half-size decimal dot
4254 PRINT ; dump to screen
4255 return ; done
4256
4257 ELSE
4258
4259 ; resettable maximum depth - needs ISR-safe copy!
4260 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row
4261 FONT_COLOR_MEMO ; select color
4262 SMOVII pressure_rel_max_trip,mpr ; get resettable maximum pressure
4263 rcall TFT_avr_stopwatch_helper ; print depth
4264
4265 ; resettable average depth
4266 WIN_MEDIUM dm_custom_avr_stop_column2-.1,dm_custom_avr_stop_row
4267 FONT_COLOR_ATTENTION ; select color
4268 MOVII pressure_rel_avg_trip,mpr ; get resettable average pressure
4269 rcall TFT_avr_stopwatch_helper ; print depth
4270
4271 ; resettable minimum depth - needs ISR safe copy!
4272 WIN_MEDIUM dm_custom_avr_stop_column3-.12,dm_custom_avr_stop_row
4273 FONT_COLOR_MEMO ; select color
4274 SMOVII pressure_rel_min_trip,mpr ; get resettable minimum pressure
4275 rcall TFT_avr_stopwatch_helper ; print depth
4276
4277 return ; done
4278
4279 TFT_avr_stopwatch_helper:
4280 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
4281 bsf leftbind ; print left-aligned
4282 bsf decimal_digit2 ; place a decimal point in front of digit 2
4283 output_65535 ; print (0.00-655.35)
4284 PUTC " " ; wipe out remains from last output
4285 clrf WREG ; load string terminator
4286 movff WREG,buffer+.5 ; limit string length to 5 = 4 digits + 1 half-size decimal dot
4287 PRINT ; dump to screen
4288 return ; done
4289
4290 ENDIF
4291
4292 TFT_update_avr_stopwatch3:
4293 WIN_MEDIUM dm_custom_avr_stop_column2,dm_custom_avr_stop_row
4294 ;bra TFT_update_stopwatch ; continue
4295
4296 TFT_update_stopwatch:
4297 ; jump-in point for stopped dive time in compass custom view
4298 MOVII divesecs_avg_trip,mpr ; get the resettable dive time (stopwatch)
4299 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
4300 movlw .100 ; display layout will change if minutes become >= 100
4301 cpfslt hi ; minutes < 100 ?
4302 bra TFT_update_stopwatch_1 ; NO - display hours:minutes
4303 bcf aux_flag ; YES - will print minutes : seconds
4304 bra TFT_update_stopwatch_2 ; - continue
4305
4306 TFT_update_stopwatch_1:
4307 movff hi,lo ; transfer minutes (low byte) to lo
4308 movff up,hi ; transfer minutes (high byte) to hi
4309 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
4310 bsf aux_flag ; will print hours : minutes
4311
4312 TFT_update_stopwatch_2:
4313 movf hi,W ; exchange lo and hi
4314 movff lo,hi ; ...
4315 movwf lo ; ...
4316 output_99 ; print minutes or hours (0 - 99)
4317 movlw ":" ; load standard separator
4318 btfsc aux_flag ; will print hours : minutes ?
4319 movlw "'" ; YES - swap to alternative separator
4320 movwf POSTINC2 ; print separator
4321 movff hi,lo ; restore lo
4322 output_99x ; print seconds or minutes (00-99)
4323 movlw .5 ; set target length
4324 call TFT_buffer_trim_length ; fill / cut buffer to target length
4325 PRINT ; dump to screen
4326 return ; done
4327
4328
4329 ;-----------------------------------------------------------------------------
4330 ; Dive Custom View - Gas Needs - Mask
4331 ;
4332 global TFT_gas_needs_mask
4333 TFT_gas_needs_mask:
4334 WIN_TINY dm_custom_gas_column_title, dm_custom_gas_mask_row
4335 FONT_COLOR_MASK ; select color
4336
4337 IFDEF _cave_mode
4338
4339 movff char_O_deco_info,WREG ; get the deco info vector
4340 btfss WREG,gas_needs_cave ; are the gas needs calculated for cave mode?
4341 bra TFT_gas_needs_mask_ascent_1 ; NO - show as direct ascent needs
4342 ;bra TFT_gas_needs_mask_ascent_0 ; YES - show as cave return needs
4343
4344 TFT_gas_needs_mask_ascent_0:
4345 bsf gas_needs_mode_last ; remember last results were for cave mode
4346 STRCPY_TEXT tGasNeedsCaveMode ; print "Gas Needs Cave Mode"
4347 bra TFT_gas_needs_mask_ascent_2 ; continue
4348
4349 TFT_gas_needs_mask_ascent_1:
4350 bcf gas_needs_mode_last ; remember last results were for direct ascent
4351 STRCPY_TEXT tGasNeedsAscent ; "Gas Needs Ascent"
4352 ;bra TFT_gas_needs_mask_ascent_2 ; continue
4353
4354 ELSE
4355
4356 STRCPY_TEXT tGasNeedsAscent ; "Gas Needs Ascent"
4357
4358 ENDIF
4359
4360 TFT_gas_needs_mask_ascent_2:
4361 TSTOSS char_I_extra_time ; fTTS enabled?
4362 bra TFT_gas_needs_mask_ascent_3 ; NO - continue
4363 STRCAT " fTTS" ; YES - append fTTS marking
4364 TFT_gas_needs_mask_ascent_3:
4365 STRCAT_PRINT " (bar)" ; append " (bar)" and dump buffer to screen
4366 return ; done
4367
4368
4369 ;-----------------------------------------------------------------------------
4370 ; Dive Custom View - Gas Needs - Data
4371 ;
4372 ; LIMITATION: there is only space for 4 gases on the screen - if 5 gases
4373 ; have a pres_need > 0, then only the first 4 will be shown!
4374 ;
4375 global TFT_gas_needs
4376 TFT_gas_needs:
4377
4378 IFDEF _cave_mode
4379
4380 movff char_O_deco_info,WREG ; get deco info vector
4381 btfss WREG,gas_needs_cave ; are the gas needs calculated for cave mode?
4382 bra TFT_gas_needs_ascent_1 ; NO - continue below...
4383 btfsc gas_needs_mode_last ; YES - were the last results calculated for cave mode?
4384 bra TFT_gas_needs_ascent_3 ; YES - mask still valid
4385 bra TFT_gas_needs_ascent_2 ; NO - redraw mask
4386
4387 TFT_gas_needs_ascent_1:
4388 btfss gas_needs_mode_last ; NO - were the last results calculated for direct ascent?
4389 bra TFT_gas_needs_ascent_3 ; YES - mask still valid
4390 ;bra TFT_gas_needs_ascent_2 ; NO - redraw mask
4391
4392 TFT_gas_needs_ascent_2:
4393 rcall TFT_gas_needs_mask ; redraw mask
4394 ;bra TFT_gas_needs_ascent_3 ; continue
4395
4396 ENDIF
4397
4398 TFT_gas_needs_ascent_3:
4399 clrf up ; initialize gas index (0-4)
4400 WIN_SMALL dm_custom_gas_column1+.5,dm_custom_gas_row1 ; set position
4401 rcall TFT_gas_needs_helper ; print need
4402 WIN_SMALL dm_custom_gas_column1+.5,dm_custom_gas_row2 ; set position
4403 rcall TFT_gas_needs_helper ; print need
4404 WIN_SMALL dm_custom_gas_column2+.5,dm_custom_gas_row1 ; set position
4405 rcall TFT_gas_needs_helper ; print need
4406 WIN_SMALL dm_custom_gas_column2+.5,dm_custom_gas_row2 ; set position
4407 rcall TFT_gas_needs_helper ; print need
4408 return ; done
4409
4410
4411 ; Helper Function - print need for next gas
4412 TFT_gas_needs_helper:
4413 FONT_COLOR_MEMO ; select default color
4414 movlw .5 ; total number of gases
4415 cpfslt up ; check if all gases have been processed
4416 bra TFT_gas_needs_helper_1 ; YES - clear display area
4417 movf up,W ; NO - get gas number and check if need of that gas is > 0
4418 rlncf WREG,W ; - multiply by 2
4419 incf WREG,W ; - add 1 to address high byte
4420 lfsr FSR1,int_O_gas_need_pres ; - load base of gas needs in pressure
4421 movff PLUSW1,hi ; - read HIGH(int_O_gas_need_pres[up])
4422 btfss hi,int_is_zero ; - check flag for pres_need == 0
4423 bra TFT_gas_needs_helper_2 ; NO - print gas type and pressure needed
4424 incf up,F ; YES - increment to next gas
4425 bra TFT_gas_needs_helper ; - loop and try the next gas
4426
4427 TFT_gas_needs_helper_1:
4428 ; no gases to show anymore, clear display area from potential remains of last invocation
4429 STRCAT_PRINT " ---- " ; overwrite outdated stuff if screen position is not needed
4430 return ; done
4431
4432 TFT_gas_needs_helper_2:
4433 ; output gas type and pressure needed
4434 movf up,W ; get gas number (0-4) to WREG
4435 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG]
4436 movff PLUSW1,lo ; copy result to lo
4437 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_He_ratio[WREG]
4438 movff PLUSW1,hi ; copy result to hi
4439 call gaslist_strcat_mix ; print "Air", "O2", "21/35", etc.
4440 PUTC ':' ; print ":"
4441 movf up,W ; get gas number (0-4) to WREG
4442 rlncf WREG,W ; multiply by 2
4443 lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure
4444 movff PLUSW1,lo ; read LOW(int_O_gas_need_pres[up])
4445 incf WREG,W ; add 1 to address high byte
4446 movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up])
4447 btfsc hi,int_attention_flag ; check if attention flag is set (pres_need > pres_fill * threshold)
4448 FONT_COLOR_ATTENTION ; YES - print gas need in attention color
4449 btfsc hi,int_warning_flag ; check if warning flag is set (pres_need > pres_fill)
4450 FONT_COLOR_WARNING ; YES - print gas need in warning color
4451 movff int_O_gas_need_pres+1,WREG ; get HIGH(int_O_gas_need_pres[0]) which holds flag for invalid data
4452 btfsc WREG,int_invalid_flag ; check if invalid data flag is set
4453 FONT_COLOR_DISABLED ; YES - print gas need in disabled color
4454 bcf hi,int_attention_flag ; clear flag for attention
4455 bcf hi,int_warning_flag ; clear flag for warning
4456 bcf hi,int_high_flag ; clear flag for > 999 bar
4457 bcf hi,int_invalid_flag ; clear flag for invalid data (will actually only be set with 1st gas)
4458 output_999 ; print (0-999)
4459 PUTC_PRINT " " ; add a space to overwrite any potential remains of earlier outputs and dump buffer to screen
4460 incf up,F ; increment to next gas
4461 return ; done
4462
4463
4464 ;-----------------------------------------------------------------------------
4465 ; Dive Custom View - Deco Plan - Mask
4466 ;
4467 global TFT_decoplan_mask ; mask for deco plan
4468 TFT_decoplan_mask:
4469 WIN_TINY dm_custom_decoplan_title_column, dm_custom_decoplan_title_row
4470 FONT_COLOR_MASK ; select color
4471 STRCPY_TEXT_PRINT tDiveDecoplan ; print label
4472
4473 return ; done
4474
4475
4476 ;-----------------------------------------------------------------------------
4477 ; Dive Custom View - Deco Plan - Data
4478 ;
4479 global TFT_decoplan
4480 TFT_decoplan:
4481 lfsr FSR0,char_O_deco_depth ; load base address of stops table
4482 clrf ex ; will be used for auxiliary flags
4483 FONT_COLOR_MEMO ; set default output color
4484 movff char_O_deco_gas+0,lo ; get flag for invalid deco data
4485 btfsc lo,char_invalid_flag ; is the invalid flag set?
4486 FONT_COLOR_DISABLED ; YES - set to disabled color
4487 ; 2nd stop
4488 WIN_SMALL dm_cust_dstop_2nd_stop_column, dm_cust_dstop_2nd_stop_row
4489 rcall TFT_decoplan_helper ; show stop data
4490 ; 3rd stop
4491 WIN_SMALL dm_cust_dstop_3rd_stop_column, dm_cust_dstop_3rd_stop_row
4492 rcall TFT_decoplan_helper ; show stop data
4493 ; 4th stop
4494 bsf ex,4 ; flag we are on 4th screen position
4495 WIN_SMALL dm_cust_dstop_4th_stop_column, dm_cust_dstop_4th_stop_row
4496 rcall TFT_decoplan_helper ; show stop data
4497 bcf ex,4 ; clear 4th position flag again
4498 ; 5th stop
4499 WIN_SMALL dm_cust_dstop_5th_stop_column, dm_cust_dstop_5th_stop_row
4500 rcall TFT_decoplan_helper ; show stop data
4501 ; 6th stop
4502 WIN_SMALL dm_cust_dstop_6th_stop_column, dm_cust_dstop_6th_stop_row
4503 rcall TFT_decoplan_helper ; show stop data
4504 ; 7th stop
4505 WIN_SMALL dm_cust_dstop_7th_stop_column, dm_cust_dstop_7th_stop_row
4506 rcall TFT_decoplan_helper ; show stop data
4507 return ; done
4508
4509
4510 ; Helper Function - show stop data
4511 TFT_decoplan_helper:
4512 btfsc ex,0 ; no more stops to show?
4513 bra TFT_decoplan_helper_1 ; YES - skip checking next entry - it will be empty, too
4514 movff PREINC0,lo ; NO - advance pointer to get the depth of the 2nd, 3rd, 4th, ... stop
4515 tstfsz lo ; is the stop depth = 0, i.e. no stop entry?
4516 bra TFT_decoplan_helper_3 ; NO - show stop data
4517
4518 TFT_decoplan_helper_1: ; no more stop table entries
4519 bsf ex,0 ; flag that there are no more stop table entries
4520 btfss ex,4 ; are we on the 4th screen position?
4521 bra TFT_decoplan_helper_2 ; NO - normal handling on this position
4522 btfsc ex,1 ; YES - special handling, has any stop been shown?
4523 bra TFT_decoplan_helper_2 ; YES - print normal blanking
4524 STRCPY_PRINT " ---- " ; NO - print a "no stops" indication (blanking potential previous content, too)
4525 return ; done
4526
4527 TFT_decoplan_helper_2: ; no more stop table entries, blank potential previous content
4528 STRCPY_PRINT " " ; wipe screen position by printing 7 spaces
4529 return ; done
4530
4531 TFT_decoplan_helper_3:
4532 rcall TFT_display_stop_depth ; print stop depth (depth in lo)
4533 PUTC " " ; put a space char between depth and time
4534 movlw NUM_STOPS ; offset between arrays holding depths and durations
4535 movff PLUSW0,lo ; get duration of the current stop
4536 output_99dd ; print duration, prints double dots if duration is zero
4537 PUTC_PRINT "'" ; append unit and dump buffer to screen
4538 bsf ex,1 ; flag that a stop was shown
4539 return ; done
4540
4541
4542 ; Helper Function - print stop depth
4543 TFT_display_stop_depth: ; print depth (stored in lo)
4544 TSTOSS opt_units ; get unit (0=m, 1=ft)
4545 bra TFT_display_stop_depth_m ; 0 - meter
4546 ;bra TFT_display_stop_depth_ft ; 1 - feet
4547
4548 TFT_display_stop_depth_ft:
4549 call convert_meter_to_feet ; convert value in lo from meters to feet
4550 output_999 ; output stop depth (0-999)
4551 return ; done
4552
4553 TFT_display_stop_depth_m:
4554 output_99 ; output stop depth (0-99)
4555 STRCAT_TEXT tMeters ; append unit
4556 return ; done
4557
4558
4559 ;-----------------------------------------------------------------------------
4560 ; Dive Custom View - Ceiling, Supersaturation & Tissues - Mask
4561 ;
4562 global TFT_ceiling_GF_tissue_mask
4563 TFT_ceiling_GF_tissue_mask:
4564 FONT_COLOR_MASK ; select color
4565
4566 WIN_TINY dm_custom_ceiling_column+.2,dm_custom_ceiling_title_row
4567 STRCPY_TEXT_PRINT tCeiling ; print label
4568
4569 WIN_TINY dm_custom_tissue_title_column, dm_custom_tissue_title_row
4570 STRCPY_TEXT_PRINT tDiveTissues ; print label
4571
4572 WIN_TINY dm_custom_gf_column1+.5, dm_custom_gf_title_row
4573 STRCPY_TEXT_PRINT tGFInfo ; print label
4574
4575 return ; done
4576
4577
4578 ;-----------------------------------------------------------------------------
4579 ; Dive Custom View - Ceiling, Supersaturation & Tissues - Data
4580 ;
4581 global TFT_ceiling_GF_tissue
4582 TFT_ceiling_GF_tissue:
4583 WIN_MEDIUM dm_custom_ceiling_column,dm_custom_ceiling_row
4584 MOVII int_O_ceiling,mpr ; get ceiling in [mbar] relative pressure
4585 call TFT_color_code_ceiling ; color-code the output (also strips off flags)
4586 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
4587
4588 TSTOSS opt_units ; 0=m, 1=ft
4589 bra TFT_ceiling_GF_tissue_metric ; 0 - meter
4590 ;bra TFT_ceiling_GF_tissue_imperial ; 1 - feet
4591
4592 TFT_ceiling_GF_tissue_imperial:
4593 call convert_cm_to_feet ; convert value in hi:lo from [cm] to [feet]
4594 output_999 ; print (0-999)
4595 bra TFT_ceiling_GF_tissue0 ; continue
4596
4597 TFT_ceiling_GF_tissue_metric:
4598 bsf omit_digit_1 ; do not print 1st digit
4599 bsf decimal_digit2 ; place a decimal point in front of digit 2
4600 bsf leftbind ; print left-aligned
4601 output_65535 ; print (xxx.x-)
4602 bra TFT_ceiling_GF_tissue0 ; continue
4603
4604 TFT_ceiling_GF_tissue0:
4605 PUTC_PRINT " " ; append a space and dump to screen
4606 ; show tissue diagram
4607 rcall TFT_dive_tissues ; show tissue pressure diagram
4608 ; show current supersaturation
4609 WIN_MEDIUM dm_custom_clock_column+.3, dm_custom_gf_row
4610 MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation
4611 call TFT_color_code_supersat ; color-code output
4612 output_256 ; need to print lo only, int_O_lead_supersat value is limited to 255
4613 PRINT ; dump to screen
4614 WIN_STD dm_custom_clock_column+.40, dm_custom_gf_row+.5
4615 PUTC_PRINT "%" ; print "%" and dump to screen
4616 return ; done
4617
4618
4619 ;-------------------------------------------------------------------------
4620 ; Draw saturation graph in dive mode custom view
4621 ;
4622 TFT_dive_tissues:
4623 ; draw outer frame
4624 movf pallet_color_memo,W ; get color into WREG
4625 WIN_FRAME_COLOR dm_custom_tissue_diagram_top, dm_custom_tissue_diagram_bottom, dm_custom_tissue_diagram_left, .159 ; outer frame
4626
4627 ; clear area showing leading tissue number as it may not be printed over
4628 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
4629
4630 TFT_dive_tissues_1:
4631 ; common initialization for tissue pressures and saturation
4632 movlw .1
4633 movwf win_height ; hight of the bargraph (0-239)
4634 movlw dm_custom_tissue_diagram_left+.3 ; get dive mode left start position
4635 movwf win_leftx2 ; set column left (0-159)
4636 movlw .159-dm_custom_tissue_diagram_left-.4 ; get max width
4637 movwf win_width+0 ; set width (low byte)
4638 clrf win_width+1 ; high byte of with is always zero
4639 movlw color_cyan ; color for tissues with decreasing pressure
4640 movwf ex ; store in ex
4641 movlw color_orange ; color for tissues with increasing pressure
4642 movwf ul ; store in ul
4643
4644 ; draw combined or N2 tissue pressures
4645 lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default
4646 IFDEF _helium
4647 btfsc tissue_graphic_layout ; shall show N2+He ?
4648 lfsr FSR2,char_O_tissue_pres_N2 ; YES - load base address of N2 pressures
4649 ENDIF
4650 movlw d'16'
4651 movwf lo ; tissue counter, 16 tissues
4652 clrf hi ; row counter
4653 TFT_dive_tissues_N2_loop:
4654 movlw dm_custom_tissue_diagram_top+.3 ; dive mode top start position N2
4655 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
4656 incf hi,F ; increment row counter
4657 decfsz lo,F ; decrement tissue counter, done?
4658 bra TFT_dive_tissues_N2_loop ; NO - loop
4659 IFDEF _helium
4660 btfsc tissue_graphic_layout ; shall show N2+He ?
4661 bra TFT_dive_tissues_3 ; YES - show He tissue pressures
4662 ENDIF
4663
4664 ; draw tissue saturations
4665 lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation
4666 movlw d'16'
4667 movwf lo ; tissue counter, 16 tissues
4668 clrf hi ; row counter
4669 movlw color_grey ; color for tissue saturation, alternative: color_lightblue
4670 movwf ex ; store in ex
4671 ; movlw color_yellow ; 2nd color is not used by tissue saturation
4672 ; movwf ul ; ...
4673 TFT_dive_tissues_sat_loop:
4674 movlw dm_custom_tissue_diagram_top+.25 ; dive mode top start position saturations
4675 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
4676 incf hi,F ; increment row counter
4677 decfsz lo,F ; decrement tissue counter, done?
4678 bra TFT_dive_tissues_sat_loop ; NO - loop
4679
4680 ; common part for vertical lines
4681 movlw dm_custom_tissue_diagram_top+.25 ; get top position
4682 movwf win_top ; set top position (0-239)
4683 movlw .15 ; get hight
4684 movwf win_height ; set height
4685 movlw .1 ; get width
4686 movwf win_width+0 ; set width, low byte
4687 clrf win_width+1 ; set width, high byte
4688
4689 ; print 100% line
4690 movlw dm_custom_tissue_diagram_left+.36 ; get left position
4691 movwf win_leftx2 ; set left position (0-159)
4692 movlw color_red ; color for 100% line
4693 BOX_COLOR ; draw line
4694
4695 ; GF factors enabled?
4696 btfss tissue_graphic_gf ; shall show GF lines?
4697 bra TFT_dive_tissues_4 ; NO - continue with number of leading tissue
4698
4699 ; print GF low line
4700 movlw dm_custom_tissue_diagram_left+.3 ; get left base position
4701 movwf win_leftx2 ; set left base position (0-159)
4702 movff char_I_GF_Low_percentage,WREG ; get GF low in 0.01 %
4703 mullw .82 ; multiply with 82
4704 movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125
4705 addwf win_leftx2,F ; add to base position
4706 movlw color_green ; color for GF low line
4707 BOX_COLOR ; draw line
4708
4709 ; print GF high line
4710 movlw dm_custom_tissue_diagram_left+.3 ; get left base position
4711 movwf win_leftx2 ; set left base position (0-159)
4712 movff char_I_GF_High_percentage,WREG ; get GF high in 0.01 %
4713 mullw .82 ; multiply with 82
4714 movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125
4715 addwf win_leftx2,F ; add to base position
4716 movlw color_yellow ; color for GF high line
4717 BOX_COLOR ; draw line
4718
4719 IFDEF _helium
4720 TFT_dive_tissues_3:
4721 ; draw He tissues pressures
4722 lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures
4723 movlw dm_custom_tissue_diagram_left+.7 ; get dive mode left start position for He bars
4724 movwf win_leftx2 ; set column left (0-159)
4725 movlw .159-dm_custom_tissue_diagram_left-.8 ; get max width for He bars
4726 movwf win_width+0 ; set width (low byte)
4727 clrf win_width+1 ; ...
4728 movlw d'16'
4729 movwf lo ; tissue counter, 16 tissues
4730 clrf hi ; row counter
4731 TFT_dive_tissues_He_loop:
4732 movlw dm_custom_tissue_diagram_top+.25 ; dive mode top start position H2
4733 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
4734 incf hi,F ; increment row counter
4735 decfsz lo,F ; decrement tissue counter, done?
4736 bra TFT_dive_tissues_He_loop ; NO - loop
4737 ENDIF
4738
4739 TFT_dive_tissues_4:
4740 ; print number of leading tissue ; TODO: some flicker due to overwriting by tissue bars
4741 movff int_O_lead_supersat+0,WREG ; get current leading tissue's supersaturation (only low byte used for value)
4742 tstfsz WREG ; current supersaturation = 0 ?
4743 bra TFT_dive_tissues_5 ; NO - print number of leading tissue
4744 movff char_O_deco_info,WREG ; YES - get deco info vector
4745 btfss WREG,deco_ceiling ; - do we have a ceiling obligation?
4746 return ; NO - can ascent directly, don't print number, set standard color and return
4747 ; YES - print number of leading tissue
4748 TFT_dive_tissues_5:
4749 movff char_O_lead_tissue,lo ; get number of leading tissue as 0-15
4750 incf lo,F ; adjust to 1-16
4751 movlw .10
4752 cpfsgt lo ; is it > 10 ?
4753 bra TFT_dive_tissues_6 ; NO - will output a single digit number
4754 ; start position for a 2 digit number
4755 WIN_TINY dm_custom_tissue_diagram_left+.32,dm_custom_tissue_diagram_top+.10
4756 bra TFT_dive_tissues_7
4757 TFT_dive_tissues_6:
4758 ; start position for a 1 digit number
4759 WIN_TINY dm_custom_tissue_diagram_left+.32+.4,dm_custom_tissue_diagram_top+.10
4760 TFT_dive_tissues_7:
4761 FONT_COLOR_MEMO ; set output color
4762 bsf leftbind ; print left-aligned
4763 output_99 ; print tissue number (0-99)
4764 PRINT ; dump buffer to screen
4765 return ; done
4766
4767
4768 ; Helper Function - draw a bargraph
4769 TFT_dive_tissues_bargraph:
4770 addwf hi,W ; add row number to start position
4771 movwf win_top ; set as row top (0-239)
4772 movff POSTINC2,up ; get tissue value
4773 movf ex,W ; default color
4774 btfsc up,7 ; check if flag in bit 7 is set
4775 movf ul,W ; YES - switch to 2nd color
4776 bcf up,7 ; clear flag bit
4777 bcf STATUS,C ; clear carry bit
4778 rrcf up,F ; divide by 2
4779 movff up,win_bargraph ; set bargraph length
4780 incf win_bargraph,F ; add a bit for a minimum visible bar
4781 BOX_COLOR ; draw bargraph
4782 return ; done
4783
4784
4785 ;-----------------------------------------------------------------------------
4786 ; Dive Custom View - CNS - Mask
4787 ;
4788 global TFT_CNS_mask
4789 TFT_CNS_mask:
4790 FONT_COLOR_MASK ; select color
4791
4792 WIN_TINY dm_custom_cns3_column1, dm_custom_cns3_title_row
4793 STRCPY_TEXT_PRINT tCNSsurf ; print label
4794
4795 WIN_TINY dm_custom_cns3_column2, dm_custom_cns3_title_row
4796
4797 IFDEF _cave_mode
4798 btfss cave_mode ; cave mode switched on?
4799 bra TFT_CNS_mask_col2 ; NO
4800 STRCPY_TEXT_PRINT tCNScave ; YES - print cave TTS label
4801 bra TFT_CNS_mask_col3 ; - continue with 3rd column
4802 ENDIF
4803
4804 TFT_CNS_mask_col2:
4805 btfsc FLAG_oc_mode ; in OC mode?
4806 bra TFT_CNS_mask_ftts ; YES - print fTTS label
4807 btfsc bailout_mode ; NO - in bailout?
4808 bra TFT_CNS_mask_ftts ; YES - print fTTS label (label will be printed, but a fTTS will actually not be calculated)
4809 TSTOSS opt_calc_gasvolume ; NO - bailout volume calculation requested?
4810 bra TFT_CNS_mask_ftts ; NO - print fTTS label
4811 ;bra TFT_CNS_mask_bo ; YES - print bailout label
4812
4813 TFT_CNS_mask_bo:
4814 STRCPY_TEXT_PRINT tCNSBO ; print bailout label
4815 bra TFT_CNS_mask_col3 ; continue with 3rd column
4816
4817 TFT_CNS_mask_ftts:
4818 STRCPY_TEXT_PRINT tCNSfTTS ; print fTTS label
4819 ;bra TFT_CNS_mask_col3 ; continue with 3rd column
4820
4821 TFT_CNS_mask_col3:
4822 WIN_TINY dm_custom_cns3_column3, dm_custom_cns3_title_row
4823 STRCPY_TEXT_PRINT tCNSnow ; print CNS now label
4824 return ; done
4825
4826
4827 ;-----------------------------------------------------------------------------
4828 ; Dive Custom View - CNS - Data
4829 ;
4830 global TFT_CNS
4831 TFT_CNS:
4832 ; CNS at end of normal dive
4833 WIN_STD dm_custom_cns3_column1+.3,dm_custom_cns3_row
4834 MOVII int_O_CNS_norm,mpr ; get CNS at end of dive in normal plan
4835 call TFT_color_code_cns ; color-code the CNS value
4836 bsf leftbind ; print left-aligned
4837 output_999 ; print (0-999)
4838 STRCAT_PRINT "% " ; append unit and trailing space and dump to screen
4839 ; fTTS / Bailout CNS, if enabled
4840 WIN_STD dm_custom_cns3_column2+.2,dm_custom_cns3_row
4841 btfsc bailout_mode ; in bailout?
4842 bra TFT_CNS_3 ; YES - show "---"
4843 TSTOSS opt_calc_gasvolume ; NO - bailout volume calculation requested?
4844 bra TFT_CNS_1 ; NO - continue checking fTTS extra time
4845 btfss FLAG_oc_mode ; YES - in OC mode?
4846 bra TFT_CNS_2 ; NO - show CNS%
4847 ;bra TFT_CNS_1 ; YES - continue checking fTTS extra time
4848
4849 TFT_CNS_1:
4850 ; not in bailout, no volume calculation, and/or in OC mode
4851 TSTOSS char_I_extra_time ; fTTS extra time configured?
4852 bra TFT_CNS_3 ; NO - show "---"
4853 ;bra TFT_CNS_2 ; YES - show CNS%
4854
4855 TFT_CNS_2:
4856 MOVII int_O_CNS_alt,mpr ; get CNS at end of dive in alternative plan
4857 call TFT_color_code_cns ; color-code the CNS value
4858 bsf leftbind ; print left-aligned
4859 output_999 ; print (0-999)
4860 STRCAT_PRINT "% " ; append unit and trailing space and dump to screen
4861 bra TFT_CNS_4 ; continue
4862
4863 TFT_CNS_3:
4864 IFDEF _cave_mode
4865 btfss cave_mode ; cave mode switched on?
4866 bra TFT_CNS_3a ; NO - show dashes
4867 btfsc backtrack_entire_full ; YES - cave mode shut down due to storage fully used up?
4868 bra TFT_CNS_3a ; YES - show dashes
4869 btfss dive_turned ; NO - dive turned?
4870 bra TFT_CNS_2 ; NO - show cave CNS
4871 ;bra TFT_CNS_3a ; YES - show dashes
4872 ENDIF
4873
4874 TFT_CNS_3a:
4875 FONT_COLOR_MEMO ; select color
4876 STRCPY_PRINT "--- " ; print non-avail symbol
4877 ;bra TFT_CNS_4 ; continue
4878
4879 TFT_CNS_4:
4880 ; current CNS
4881 WIN_STD dm_custom_cns3_column3+.3,dm_custom_cns3_row
4882 MOVII int_O_CNS_current,mpr ; get current CNS
4883 call TFT_color_code_cns ; color-code the CNS value
4884 bsf leftbind ; print left-aligned
4885 output_999 ; print (0-999)
4886 PUTC_PRINT "%" ; append unit and dump to screen
4887 return ; done
4888
4889
4890 ;-----------------------------------------------------------------------------
4891 ; Dive Custom View - ppO2, EAD/END & Gas Density - Mask
4892 ;
4893 global TFT_ppo2_ead_end_cns_mask
4894 TFT_ppo2_ead_end_cns_mask:
4895 FONT_COLOR_MASK ; select color
4896
4897 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row
4898 STRCPY_TEXT_PRINT tppO2 ; print label
4899
4900 WIN_TINY dm_custom_ead_column,dm_custom_eadend_title_row
4901 STRCPY_TEXT_PRINT tDiveEAD_END ; print label
4902
4903 IFDEF _ccr_pscr
4904 WIN_TINY dm_custom_cns_column-.5,dm_custom_eadend_title_row
4905 STRCPY_TEXT_PRINT tGasDensity ; print label
4906 ELSE
4907 WIN_TINY dm_custom_cns_column,dm_custom_cns_title_row
4908 STRCPY_TEXT_PRINT tCNS2 ; print label
4909 ENDIF
4910
4911 return ; done
4912
4913
4914
4915 ;-----------------------------------------------------------------------------
4916 ; Dive Custom View - ppO2, EAD/END & Gas Density - Data
4917 ;
4918 global TFT_ppo2_ead_end_cns
4919 TFT_ppo2_ead_end_cns:
4920 ; show ppO2
4921 WIN_MEDIUM dm_custom_ppo2_column, dm_custom_ppo2_row
4922 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 of the currently breathed gas to hi:lo
4923 call TFT_color_code_ppo2 ; color-code output
4924 bsf decimal_digit2 ; place a decimal point in front of digit 2
4925 output_999 ; print ppO2 (0.00-9.99)
4926 PRINT ; dump to screen
4927 ; show END/EAD
4928 FONT_COLOR_MEMO ; select color
4929 WIN_SMALL dm_custom_ead_column, dm_custom_ead_row
4930 STRCPY_TEXT tEAD ; print "EAD:"
4931 MOVII int_O_EAD_pres,mpr ; copy EAD in [mbar] to MPR
4932 rcall TFT_end_ead_common ; convert to depth, print and limit to 8 chars
4933 WIN_SMALL dm_custom_end_column, dm_custom_end_row
4934 STRCPY_TEXT tEND ; print "END:"
4935 MOVII int_O_END_pres,mpr ; copy END in [mbar] to MPR
4936 rcall TFT_end_ead_common ; convert to depth, print and limit to 8 chars
4937 IFDEF _helium
4938 ; show gas density
4939 WIN_MEDIUM dm_custom_cns_column-.5, dm_custom_cns_row
4940 MOVII int_O_gas_density,mpr ; get current gas density
4941 call TFT_color_code_cns ; color-code output
4942 bsf decimal_digit2 ; place a decimal point in front of digit 2
4943 output_999 ; print (0.00-9.99)
4944 PRINT ; dump to screen
4945 ELSE
4946 ; show CNS
4947 WIN_STD dm_custom_cns_column+.3, dm_custom_cns_row
4948 MOVII int_O_CNS_current,mpr ; get current CNS
4949 call TFT_color_code_cns ; color-code CNS output
4950 bsf leftbind ; print left-aligned
4951 output_999 ; print (0-999)
4952 PUTC_PRINT "%" ; append unit and dump buffer to screen
4953 ENDIF
4954 return ; done
4955
4956
4957 ; Helper Function - convert to depth, print and limit to 8 chars
4958 TFT_end_ead_common:
4959 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
4960 TSTOSS opt_units ; 0=Meter, 1=Feet
4961 bra TFT_end_ead_common_metric ; 0: meter
4962 ;bra TFT_end_ead_common_imperial ; 1: feet
4963
4964 TFT_end_ead_common_imperial:
4965 call convert_cm_to_feet ; convert depth in [cm] to depth in [feet]
4966 output_999 ; print (0-999)
4967 PRINT ; dump buffer to screen
4968 return ; done
4969
4970 TFT_end_ead_common_metric:
4971 bsf omit_digit_2 ; do not print 2nd and 1st digit
4972 output_65535 ; print (0xx-655xx)
4973 PUTC_PRINT 'm' ; append unit and dump to screen
4974 return ; done
4975
4976
4977 ;-----------------------------------------------------------------------------
4978 ; Dive Custom View - GF Factors (Mask only)
4979 ;
4980 global TFT_gf_factors_mask
4981 TFT_gf_factors_mask:
4982 FONT_COLOR_MASK ; select color
4983
4984 ; show labels
4985 WIN_TINY dm_custom_gf_column1,dm_custom_gf_title_row
4986 STRCPY_TEXT_PRINT tGFactors
4987 WIN_TINY dm_custom_gf_column3,dm_custom_gf_title_row
4988 STRCPY_TEXT_PRINT taGFactors
4989
4990 ; show GF (static)
4991 WIN_STD dm_custom_gf_column1, dm_custom_gf_row
4992 FONT_COLOR_DISABLED ; default to disabled color
4993 btfss use_aGF ; shall use alternative GF factors?
4994 FONT_COLOR_MEMO ; NO - switch to memo color
4995 movff opt_GF_low, lo ; get normal GF low
4996 movff opt_GF_high,hi ; get normal GF high
4997 rcall TFT_gf_factors_mask_helper ; print GFs
4998
4999 ; show aGF (static)
5000 FONT_COLOR_MEMO ; select memo color
5001 TSTOSS opt_enable_aGF ; are alternative GF factors enabled?
5002 bra TFT_gf_factors_mask_3 ; NO - show "---" and return
5003 ; bra TFT_gf_factors_mask_0 ; YES - show arrow
5004
5005 TFT_gf_factors_mask_0:
5006 WIN_STD dm_custom_gf_column2, dm_custom_gf_row
5007 btfss use_aGF ; shall use aGF?
5008 bra TFT_gf_factors_mask_1L ; NO - print "<- "
5009 ;bra TFT_gf_factors_mask_1R ; YES - print " ->"
5010
5011 TFT_gf_factors_mask_1R:
5012 STRCPY_PRINT " ->" ; print " ->"
5013 bra TFT_gf_factors_mask_2 ; continue
5014
5015 TFT_gf_factors_mask_1L:
5016 STRCPY_PRINT "<- " ; print "<- "
5017 ;bra TFT_gf_factors_mask_2 ; continue
5018
5019 TFT_gf_factors_mask_2:
5020 WIN_STD dm_custom_gf_column3, dm_custom_gf_row
5021 ;FONT_COLOR_MEMO ; select memo color (still selected)
5022 btfss use_aGF ; shall use aGF?
5023 FONT_COLOR_DISABLED ; NO - switch to disabled color
5024 movff opt_aGF_low, lo ; get aGF low
5025 movff opt_aGF_high,hi ; get aGF high
5026 rcall TFT_gf_factors_mask_helper ; print GFs
5027 return ; done
5028
5029 TFT_gf_factors_mask_3:
5030 WIN_STD dm_custom_gf_column3+.10, dm_custom_gf_row
5031 STRCPY_PRINT "---" ; print not-avail symbol
5032 return ; done
5033
5034 ; Helper Function - print GF pair
5035 TFT_gf_factors_mask_helper:
5036 output_256 ; print GF low (0-255)
5037 PUTC "/" ; print "/"
5038 movff hi,lo ; get GF high
5039 output_256 ; print GF high (0-255)
5040 PRINT ; dump to screen
5041 return ; done
5042
5043
5044 ;-----------------------------------------------------------------------------
5045 ; Dive Custom View - Clock, Battery & Surface Pressure - Mask
5046 ;
5047 global TFT_clock_batt_surfpress_mask
5048 TFT_clock_batt_surfpress_mask:
5049 FONT_COLOR_MASK ; select color
5050
5051 WIN_TINY dm_custom_clock_column, dm_custom_clock_title_row
5052 STRCPY_TEXT_PRINT tTime ; "Time"
5053
5054 WIN_TINY dm_custom_battery_column, dm_custom_battery_title_row
5055 STRCPY_TEXT_PRINT tBattery ; "Battery"
5056
5057 WIN_TINY dm_custom_surfpres_column+.8, dm_custom_surfpres_title_row
5058 STRCPY_TEXT_PRINT tSurface ; "Surface"
5059
5060 ; show configured surface pressure (done in mask, because it's static during the dive)
5061 WIN_SMALL dm_custom_surfpres_column, dm_custom_surfpres_row
5062 FONT_COLOR_MEMO ; select color
5063 MOVII pressure_surf,mpr ; get surface pressure
5064 output_65535 ; print (5 digits, first one used as spacer)
5065 PUTC ' ' ; print a space
5066 STRCAT_TEXT_PRINT tMBAR ; append unit and dump to screen
5067 return ; done
5068
5069
5070 ;-----------------------------------------------------------------------------
5071 ; Dive Custom View - Clock, Battery & Surface Pressure - Data
5072 ;
5073 global TFT_clock_batt_surfpress
5074 TFT_clock_batt_surfpress:
5075 ; update clock
5076 WIN_SMALL dm_custom_clock_column, dm_custom_clock_row
5077 FONT_COLOR_MEMO ; select color
5078 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
5079 movff rtc_latched_hour,lo ; get hours
5080 output_99 ; print hours (0-99)
5081 PUTC ':' ; print ":"
5082 movff rtc_latched_mins,lo ; get minutes
5083 output_99x ; print minutes (00-99)
5084 PUTC ":" ; print ":"
5085 movff rtc_latched_secs,lo ; get seconds
5086 output_99x ; print seconds (00-99)
5087 PRINT ; dump to screen
5088
5089 ; show battery voltage
5090 WIN_SMALL dm_custom_battery_column, dm_custom_battery_volt_row
5091 ;FONT_COLOR_MEMO ; select color
5092 MOVII batt_voltage,mpr ; get voltage
5093 bsf decimal_digit3 ; place a decimal point in front of digit 3
5094 bsf omit_digit_1 ; do not print 1st digit
5095 output_9999 ; print voltage (0.00x-9.99x)
5096 PUTC_PRINT 'V' ; append unit and dump to screen
5097
5098 ; show battery percent
5099 WIN_SMALL dm_custom_battery_column+.7, dm_custom_battery_percent_row
5100 call TFT_color_code_battery ; color-code according to battery_low_condition flag
5101 movff batt_percent,lo ; get battery %
5102 output_256 ; print battery % (0-999)
5103 PUTC_PRINT "%" ; append unit and dump to screen
5104
5105 ; surface pressure is shown via the mask because it is static
5106 return ; done
5107
5108
5109 IFDEF _ccr_pscr
5110
5111 ;-----------------------------------------------------------------------------
5112 ; Dive Custom View - Sensor Check - Mask
5113 ;
5114 global TFT_sensor_check_mask
5115 TFT_sensor_check_mask:
5116 FONT_COLOR_MASK ; select color
5117
5118 WIN_TINY dm_custom_s_check_title_column, dm_custom_s_check_title_row
5119 STRCPY_TEXT_PRINT tSensorCheck ; print label
5120
5121 WIN_TINY dm_custom_ppO2_column, dm_custom_s_check_title_row
5122 STRCPY_TEXT_PRINT tppO2O2 ; print label
5123
5124 WIN_TINY dm_custom_ppDil_column, dm_custom_s_check_title_row
5125 STRCPY_TEXT_PRINT tppO2Dil ; print label
5126
5127 return ; done
5128
5129
5130 ;-----------------------------------------------------------------------------
5131 ; Dive Custom View - Sensor Check - Data
5132 ;
5133 global TFT_sensor_check
5134 TFT_sensor_check:
5135 ; show ppO2 of O2 in this depth
5136 WIN_MEDIUM dm_custom_ppO2_column, dm_custom_s_check_row
5137 MOVII int_O_O2_ppO2,mpr ; copy ppO2 of pure O2 to hi:lo
5138 rcall TFT_sensor_check_helper ; print ppO2
5139 ; show ppO2 of the diluent in this depth
5140 WIN_MEDIUM dm_custom_ppDil_column, dm_custom_s_check_row
5141 MOVII int_O_pure_ppO2,mpr ; copy ppO2 of pure gas to hi:lo
5142 rcall TFT_sensor_check_helper ; print ppO2
5143 return ; done
5144
5145 TFT_sensor_check_helper:
5146 call TFT_color_code_ppo2 ; color-code output
5147 bsf decimal_digit2 ; place a decimal point in front of digit 2
5148 output_999 ; print ppO2 (0.00-9.99)
5149 PRINT ; dump to screen
5150 return ; done
5151
5152
5153 ;-----------------------------------------------------------------------------
5154 ; Dive Custom View - pSCR Info - Mask
5155 ;
5156 global TFT_pscr_info_mask
5157 TFT_pscr_info_mask:
5158 FONT_COLOR_MASK ; select color
5159
5160 WIN_TINY dm_custom_pscr_drop_column, dm_custom_pscr_title_row
5161 STRCPY_TEXT_PRINT tPSCR_O2_drop ; print label
5162
5163 WIN_TINY dm_custom_pscr_ratio_column, dm_custom_pscr_title_row
5164 STRCPY_TEXT_PRINT tPSCR_lungratio ; print label
5165
5166 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row
5167 btfsc bailout_mode ; in bailout?
5168 bra TFT_pscr_info_mask_2 ; YES
5169 ;bra TFT_pscr_info_mask_1 ; NO
5170
5171 TFT_pscr_info_mask_1:
5172 STRCPY_TEXT_PRINT tppO2Mix ; print "ppO2(Mix)"
5173 return ; done
5174
5175 TFT_pscr_info_mask_2:
5176 STRCPY_TEXT_PRINT tppO2 ; print "ppO2"
5177 return ; done
5178
5179
5180 ;-----------------------------------------------------------------------------
5181 ; Dive Custom View - pSCR Info - Data
5182 ;
5183 global TFT_pscr_info
5184 TFT_pscr_info:
5185 ;show ppO2
5186 WIN_MEDIUM dm_custom_ppo2_column,dm_custom_ppo2_row
5187 MOVII int_O_pSCR_ppO2,mpr ; copy pSCR ppO2 to hi:lo
5188 call TFT_color_code_ppo2 ; color-code output
5189 bsf decimal_digit2 ; place a decimal point in front of digit 2
5190 output_999 ; print ppO2 (0.00-9-99)
5191 PRINT ; dump to screen
5192 ; show drop
5193 WIN_STD dm_custom_pscr_drop_column+.11,dm_custom_pscr_row
5194 FONT_COLOR_MEMO ; select color
5195 movff char_I_PSCR_drop,lo ; get drop
5196 output_99 ; print drop (0-99)
5197 PUTC_PRINT "%" ; append unit and dump to screen
5198 ; show lung ratio
5199 WIN_STD dm_custom_pscr_ratio_column+.5,dm_custom_pscr_row
5200 ;FONT_COLOR_MEMO ; select color
5201 movff char_I_PSCR_lungratio,lo ; get ratio
5202 STRCPY "1/" ; print "1/"
5203 bsf leftbind ; print left-aligned
5204 output_256 ; print ratio number (0-256)
5205 PRINT ; dump to screen
5206 return ; done
5207
5208 ENDIF ; _ccr_psrc
5209
5210 IFDEF _external_sensor
5211
5212 ;-----------------------------------------------------------------------------
5213 ; Dive Custom View - Sensor ppO2 - Mask
5214 ;
5215 global TFT_ppo2_sensors_mask
5216 TFT_ppo2_sensors_mask:
5217 FONT_COLOR_MASK ; select color
5218
5219 WIN_TINY dm_custom_hud_sensor1_column+.4,dm_custom_hud_title_row
5220 STRCPY_TEXT_PRINT tDiveHudMask1 ; print label
5221
5222 WIN_TINY dm_custom_hud_sensor2_column+.3,dm_custom_hud_title_row
5223 STRCPY_TEXT_PRINT tDiveHudMask2 ; print label
5224
5225 WIN_TINY dm_custom_hud_sensor3_column+.2,dm_custom_hud_title_row
5226 STRCPY_TEXT_PRINT tDiveHudMask3 ; print label
5227
5228 return ; done
5229
5230
5231 ;-----------------------------------------------------------------------------
5232 ; Dive Custom View - Sensor ppO2 - Data
5233 ;
5234 ; Definition of the output:
5235 ;
5236 ; sensorX use voting o2
5237 ; _calibrated _O2 _logic _ppo2 Output Color
5238 ; _ok _sensorX _sensorX _sensorX
5239 ;-----------------------------------------------------------------------------------------------
5240 ; 0 -/- -/- -/- "----" memo
5241 ; 1 0 -/- = 0 o2_ppo2_sensorX attention
5242 ; 1 0 -/- > 0 o2_ppo2_sensorX disabled
5243 ; 1 1 0 -/- o2_ppo2_sensorX TFT_color_code_ppo2_hud + win_invert
5244 ; 1 1 1 -/- o2_ppo2_sensorX TFT_color_code_ppo2_hud
5245 ;
5246 global TFT_ppo2_sensors
5247 TFT_ppo2_sensors:
5248
5249 ; sensor 1
5250 TFT_ppo2_sensors_1:
5251 btfsc sensor1_calibrated_ok ; valid calibration?
5252 bra TFT_ppo2_sensors_1b ; YES
5253 btfsc sensor1_active ; NO - valid HUD data for this sensor?
5254 bra TFT_ppo2_sensors_1b ; YES
5255 ;bra TFT_ppo2_sensors_1a ; NO
5256
5257 TFT_ppo2_sensors_1a:
5258 ; no valid calibration
5259 WIN_STD dm_custom_hud_sensor1_column+.7, dm_custom_hud_row+.5
5260 FONT_COLOR_MEMO ; set color
5261 STRCPY_PRINT "---" ; print dashes
5262 bra TFT_ppo2_sensors_2 ; continue with sensor 2
5263
5264 TFT_ppo2_sensors_1b:
5265 ; sensor has a valid calibration
5266 WIN_MEDIUM dm_custom_hud_sensor1_column,dm_custom_hud_row
5267 movff sensor1_ppO2,lo ; load ppO2 value into transfer storage for output
5268 btfsc use_O2_sensor1 ; in use?
5269 bra TFT_ppo2_sensors_1d ; YES
5270 tstfsz lo ; NO - sensor value = 0 ?
5271 bra TFT_ppo2_sensors_1c ; NO
5272 FONT_COLOR_ATTENTION ; YES - set attention color
5273 bra TFT_ppo2_sensors_1e ; - print ppO2 value
5274
5275 TFT_ppo2_sensors_1c:
5276 ; sensor has valid calibration, is not in use and has a value > 0
5277 FONT_COLOR_DISABLED ; set disabled color
5278 bra TFT_ppo2_sensors_1e ; print ppO2 value
5279
5280 TFT_ppo2_sensors_1d:
5281 ; sensor has valid calibration and is in use
5282 call TFT_color_code_ppo2_hud ; color-code with ppO2 [cbar] in lo
5283 btfsc voting_logic_sensor1 ; sensor value agrees with values of other sensors?
5284 bra TFT_ppo2_sensors_1e ; YES
5285 bsf win_invert ; NO - invert output
5286 ;bra TFT_ppo2_sensors_1e ; print ppO2 value
5287
5288 TFT_ppo2_sensors_1e:
5289 ; all coloring is set up now, let's write the value to the display!
5290 bsf decimal_digit2 ; place a decimal point in front of digit 2
5291 output_256 ; print (0.00-2.55)
5292 PRINT ; dump to screen
5293
5294 ; sensor 2
5295 TFT_ppo2_sensors_2:
5296 btfsc sensor2_calibrated_ok ; valid calibration?
5297 bra TFT_ppo2_sensors_2b ; YES
5298 btfsc sensor2_active ; NO - valid HUD data for this sensor?
5299 bra TFT_ppo2_sensors_2b ; YES
5300 ;bra TFT_ppo2_sensors_2a ; NO
5301
5302 TFT_ppo2_sensors_2a:
5303 ; no valid calibration
5304 WIN_STD dm_custom_hud_sensor2_column+.7, dm_custom_hud_row+.5
5305 FONT_COLOR_MEMO ; set color
5306 STRCPY_PRINT "---" ; print dashes
5307 bra TFT_ppo2_sensors_3 ; continue with sensor 3
5308
5309 TFT_ppo2_sensors_2b:
5310 ; sensor has a valid calibration
5311 WIN_MEDIUM dm_custom_hud_sensor2_column,dm_custom_hud_row
5312 movff sensor2_ppO2,lo ; load ppO2 value into transfer storage for output
5313 btfsc use_O2_sensor2 ; in use?
5314 bra TFT_ppo2_sensors_2d ; YES
5315 tstfsz lo ; NO - sensor value = 0?
5316 bra TFT_ppo2_sensors_2c ; NO
5317 FONT_COLOR_ATTENTION ; YES - print in attention color
5318 bra TFT_ppo2_sensors_2e ; - print ppO2 value
5319
5320 TFT_ppo2_sensors_2c:
5321 ; sensor has valid calibration, is not in use and has a value > 0
5322 FONT_COLOR_DISABLED ; output in light blue
5323 bra TFT_ppo2_sensors_2e ; print ppO2 value
5324
5325 TFT_ppo2_sensors_2d:
5326 ; sensor has valid calibration and is in use
5327 call TFT_color_code_ppo2_hud ; color-code with ppO2 [cbar] in lo
5328 btfsc voting_logic_sensor2 ; sensor value agrees with values of other sensors?
5329 bra TFT_ppo2_sensors_2e ; YES
5330 bsf win_invert ; NO - invert output
5331 ;bra TFT_ppo2_sensors_2e ; - print ppO2 value
5332
5333 TFT_ppo2_sensors_2e:
5334 ; all coloring is set up now, let's write the value to the display!
5335 bsf decimal_digit2 ; place a decimal point in front of digit 2
5336 output_256 ; print (0.00-2.55)
5337 PRINT ; dump to screen
5338
5339 ; sensor 3
5340 TFT_ppo2_sensors_3:
5341 btfsc sensor3_calibrated_ok ; valid calibration?
5342 bra TFT_ppo2_sensors_3b ; YES
5343 btfsc sensor3_active ; NO - valid HUD data for this sensor?
5344 bra TFT_ppo2_sensors_3b ; YES
5345 ;bra TFT_ppo2_sensors_3a ; NO
5346
5347 TFT_ppo2_sensors_3a:
5348 WIN_STD dm_custom_hud_sensor3_column+.7, dm_custom_hud_row+.5
5349 FONT_COLOR_MEMO ; set color
5350 STRCPY_PRINT "---" ; print dashes
5351 bra TFT_ppo2_sensors_4 ; done
5352
5353 TFT_ppo2_sensors_3b:
5354 ; sensor has a valid calibration
5355 WIN_MEDIUM dm_custom_hud_sensor3_column,dm_custom_hud_row
5356 movff sensor3_ppO2,lo ; load ppO2 value into transfer storage for output
5357 btfsc use_O2_sensor3 ; in use?
5358 bra TFT_ppo2_sensors_3d ; YES
5359 tstfsz lo ; NO - sensor value = 0?
5360 bra TFT_ppo2_sensors_3c ; NO
5361 FONT_COLOR_ATTENTION ; YES - print in attention color
5362 bra TFT_ppo2_sensors_3e ; - print ppO2 value
5363
5364 TFT_ppo2_sensors_3c:
5365 ; sensor has valid calibration, is not in use and has a value > 0
5366 FONT_COLOR_DISABLED ; print in disabled color
5367 bra TFT_ppo2_sensors_3e ; print ppO2 value
5368
5369 TFT_ppo2_sensors_3d:
5370 ; sensor has valid calibration and is in use
5371 call TFT_color_code_ppo2_hud ; color-code with ppO2 [cbar] in lo
5372 btfsc voting_logic_sensor3 ; sensor value agrees with values other sensors?
5373 bra TFT_ppo2_sensors_3e ; YES
5374 bsf win_invert ; NO - invert output
5375 ;bra TFT_ppo2_sensors_3e ; - print ppO2 value
5376
5377 TFT_ppo2_sensors_3e:
5378 ; all coloring is set up now, let's write the value to the display!
5379 bsf decimal_digit2 ; place a decimal point in front of digit 2
5380 output_256 ; print (0.00-2.55)
5381 PRINT ; dump to screen
5382
5383 TFT_ppo2_sensors_4:
5384 return ; done
5385
5386 ENDIF ; _external_sensor
5387
5388 IFDEF _rx_functions
5389
5390 ;-----------------------------------------------------------------------------
5391 ; Dive Custom View - Pressures & SAC - Mask
5392 ;
5393 global TFT_pressures_SAC_mask
5394 TFT_pressures_SAC_mask:
5395 FONT_COLOR_MASK ; select color
5396
5397 ; pressure reading 1
5398 WIN_TINY dm_custom_tankdata_pres1_col, dm_custom_tankdata_mask_row
5399 movff char_I_pressure_gas+0,WREG ; =0: disabled, =1..10: gases/dils
5400 bcf aux_flag ; selector for disabled / need set to disabled
5401 rcall TFT_pressures_SAC_mask_h1 ; print gas composition or " ---" if disabled
5402
5403 ; pressure reading 2
5404 WIN_TINY dm_custom_tankdata_pres2_col, dm_custom_tankdata_mask_row
5405 movff char_I_pressure_gas+1,WREG ; =0: need to reading 1, =1..10: gases/dils
5406 bsf aux_flag ; selector for disabled / need set to need
5407 rcall TFT_pressures_SAC_mask_h1 ; print gas composition or "Need " if 0
5408
5409 ; SAC rate
5410 WIN_TINY dm_custom_tankdata_SAC_col, dm_custom_tankdata_mask_row
5411 STRCPY_TEXT tSAC ; "SAC
5412 STRCAT " (" ; (
5413 STRCAT_TEXT tLitersMinute ; l/min
5414 PUTC_PRINT ")" ; )"
5415 return ; done
5416
5417
5418 ; Helper Function - print gas composition or " ---" if disabled
5419 TFT_pressures_SAC_mask_h1:
5420 tstfsz WREG ; pressure reading assigned?
5421 bra TFT_pressures_SAC_mask_h2 ; YES - print gas composition
5422 btfsc aux_flag ; NO - check auxiliary flag
5423 bra TFT_pressures_SAC_mask_h3 ; 1 - print "Need "
5424 STRCAT_PRINT " ---" ; 0 - print " ---"
5425 return ; - done
5426
5427 TFT_pressures_SAC_mask_h2:
5428 decf WREG,W ; (1..10) -> (0..9)
5429 bsf short_gas_descriptions ; just "Air", "O2" or "xx/yy"
5430 call gaslist_strcat_mix_WREG ; print composition of gas/dil in WREG (0..9)
5431 bra TFT_pressures_SAC_mask_h4 ; finish with adding "(bar)"
5432
5433 TFT_pressures_SAC_mask_h3:
5434 STRCPY_TEXT tNeed ; "Need"
5435 ;bra TFT_pressures_SAC_mask_h4 ; finish with adding "(bar)"
5436
5437 TFT_pressures_SAC_mask_h4:
5438 STRCAT_PRINT "(bar)" ; print "(bar)"
5439 return ; done
5440
5441
5442 ;-----------------------------------------------------------------------------
5443 ; Dive Custom View - Pressures & SAC - Data
5444 ;
5445 global TFT_pressures_SAC
5446 TFT_pressures_SAC:
5447 ; check mode for second reading
5448 bcf aux_flag ; clear auxiliary flag by default (reading 2 is pressure)
5449 movff char_I_pressure_gas+1,WREG ; =0: need to reading 1, =1..10: gases/dils
5450 addlw .0 ; dummy operation to set status register flags
5451 btfsc STATUS,Z ; gas selected = 0 (i.e. no 2nd pressure reading) ?
5452 bsf aux_flag ; YES - set auxiliary flag (display position of reading 2 shall show need to reading 1)
5453 ; get data of reading 1
5454 movff int_IO_pressure_value+0,lo ; copy pressure 1 to hi:lo
5455 movff int_IO_pressure_value+1,hi ; ...
5456 movff char_I_pressure_stat+0,ex ; copy status data
5457 ; pressure of reading 1
5458 WIN_STD dm_custom_tankdata_pres1_col+.4,dm_custom_tankdata_row
5459 rcall TFT_pressures_SAC_helper_1 ; print pressure if available, else " ---"
5460 ; battery status of reading 1
5461 WIN_SMALL dm_custom_hud_sensor1_column+.4+.36,dm_custom_tankdata_row
5462 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator
5463 ; get data for reading 2
5464 btfsc aux_flag ; shall reading 2 show need to reading 1 ?
5465 bra TFT_pressures_SAC_1 ; YES
5466 movff int_IO_pressure_value+2,lo ; NO - copy pressure 2 to hi:lo
5467 movff int_IO_pressure_value+3,hi ; - ...
5468 movff char_I_pressure_stat+1,ex ; - copy status data
5469 bra TFT_pressures_SAC_2 ; - continue
5470
5471 TFT_pressures_SAC_1:
5472 MOVII int_O_pressure_need,mpr ; copy need to pressure 1 to hi:lo
5473 clrf ex ; set status data to 0
5474 bra TFT_pressures_SAC_2 ; continue
5475
5476 TFT_pressures_SAC_2:
5477 ; pressure of reading 2
5478 WIN_STD dm_custom_tankdata_pres2_col+.2,dm_custom_tankdata_row
5479 rcall TFT_pressures_SAC_helper_1 ; print pressure if available, else " ---"
5480 ; battery status of reading 2
5481 WIN_SMALL dm_custom_tankdata_pres2_col+.2+.36,dm_custom_tankdata_row
5482 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator
5483
5484 TFT_pressures_SAC_3:
5485 ; SAC
5486 WIN_STD dm_custom_tankdata_SAC_col+.6,dm_custom_tankdata_row
5487 MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo
5488 btfsc hi,int_not_avail_flag ; SAC rate available?
5489 bra TFT_pressures_SAC_4 ; NO - print " --.-"
5490 call TFT_color_code_pres_sac ; color-code the output
5491 bsf decimal_digit1 ; place a decimal point in front of digit 1
5492 output_999 ; print (0.0-99.9)
5493 PRINT ; dump to screen
5494 return ; done
5495
5496 TFT_pressures_SAC_4:
5497 FONT_COLOR_DISABLED ; set color
5498 STRCAT_PRINT "--.-" ; output for no SAC data available
5499 return ; done
5500
5501
5502 ; Helper Function - print pressure if available, else " ---"
5503 TFT_pressures_SAC_helper_1:
5504 btfss hi,int_not_avail_flag ; pressure available?
5505 bra TFT_pressures_SAC_helper_1a ; YES - print pressure
5506 FONT_COLOR_DISABLED ; NO - use disabled color as default
5507 ; btfsc ex,char_transmitter_lost ; - transmitter lost?
5508 ; FONT_COLOR_ATTENTION ; YES - use attention color
5509 STRCAT_PRINT " ---" ; - print " ---"
5656 return 5510 return
5657 5511
5658 TFT_surface_tankdata_print: ; max 12 char 5512 TFT_pressures_SAC_helper_1a:
5659 call TFT_standard_color ; set color 5513 btfsc hi,int_warning_flag ; out of range (signaled by warning flag)?
5660 movff POSTINC1,hi ; ID high (+0) 5514 bra TFT_pressures_SAC_helper_1c ; YES - special treatment
5661 movff POSTINC1,lo ; ID low (+1) 5515 call TFT_color_code_pres_sac ; NO - color-code the output
5662 tstfsz hi ; ID high = 0 ? 5516 PUTC ' ' ; - add a space
5663 bra TFT_surface_tankdata_print_1 ; NO - slot in use 5517 bsf omit_digit_1 ; - do not print 1st digit (0.1 bar)
5664 tstfsz lo ; ID low = 0? 5518 output_999 ; - print pressure (0x-999x)
5665 bra TFT_surface_tankdata_print_1 ; NO - slot in use 5519 PRINT ; - dump buffer to screen
5666 STRCAT_PRINT "---- " ; YES - mark as unused and clear rest of line from previous remains 5520 return ; - done
5667 movf POSTINC1,W ; - dummy read (+2) to advance index 5521
5668 movf POSTINC1,W ; - dummy read (+3) to advance index 5522 TFT_pressures_SAC_helper_1c:
5669 movf POSTINC1,W ; - dummy read (+4) to advance index 5523 call TFT_color_code_pres_sac ; color-code the output
5670 bra TFT_surface_tankdata_print_3 5524 STRCPY_PRINT ">400" ; print ">400"
5671 TFT_surface_tankdata_print_1: 5525 return ; done
5672 movf hi,W ; copy ID high to WREG 5526
5673 output_hex ; 2 chars 5527
5674 movf lo,W ; copy ID low to WREG 5528 ; Helper Function - print or clear down arrow as low bat indicator
5675 output_hex ; 2 chars (4 in total) 5529 TFT_pressures_SAC_helper_2:
5676 movff POSTINC1,hi ; pressure high (+2) 5530 btfss ex,char_transmitter_low_bat ; low battery flag set?
5677 movff POSTINC1,lo ; pressure low (+3) 5531 bra TFT_pressures_SAC_helper_2b ; NO - clear down arrow (low bat indicator)
5678 call TFT_color_code_tank_pres_sac ; needed to clear the status flags before output 5532 ;bra TFT_pressures_SAC_helper_2a ; YES - show down arrow (low bat indicator)
5679 bsf ignore_digit5 ; no 0.1 bar (flag will be cleared by output_16) 5533
5680 output_16 ; 4 chars (8 in total) 5534 TFT_pressures_SAC_helper_2a:
5681 PUTC " " ; 1 char (9 in total) 5535 FONT_COLOR_ATTENTION ; use attention color
5682 movf POSTINC1,W ; status (+4) 5536 STRCPY_PRINT "\xb8" ; print down arrow as bat low indication
5683 andlw .7 ; mask out battery voltage 5537 return ; done
5684 bnz TFT_surface_tankdata_2 ; branch if battery is not completely drained 5538
5685 call TFT_warning_color ; output in red 5539 TFT_pressures_SAC_helper_2b:
5686 STRCAT_PRINT "XXX" ; "XXX" for low 5540 STRCPY_PRINT " " ; wipe out down arrow (low bat indicator)
5687 bra TFT_surface_tankdata_print_3 5541 return ; done
5688 TFT_surface_tankdata_2: 5542
5689 addlw .28 ; add offset of 2.8 Volt 5543 ENDIF _rx_functions
5690 movff WREG,lo ; 5544
5691 output_99 ; 2 chars (11 in total) 5545 IFDEF _cave_mode
5692 PUTC " " ; dummy char 1 char (12 in total) 5546
5693 movff buffer+.10,buffer+.11 ; move decimal digit of battery voltage one position to the right 5547 ;-----------------------------------------------------------------------------
5694 movlw "." ; decimal point 5548 ; Dive Custom View - Cave Mode TTS, total Stops and Run Time - Mask
5695 movff WREG,buffer+.10 ; place it before decimal digit 5549 ;
5696 STRCAT_PRINT "" ; print buffer to screen 5550
5697 TFT_surface_tankdata_print_3: 5551 global TFT_cave_tts_mask
5698 movf POSTINC1,W ; dummy read (+5) to advance index 5552 TFT_cave_tts_mask:
5699 return 5553 FONT_COLOR_MASK ; select color
5700 5554
5701 5555 WIN_TINY dm_custom_cave_title_column1,dm_custom_cave_title_row
5702 ; TFT_surface_tankdata_debug: ; surface custom view debug output 5556 STRCPY_TEXT_PRINT tCaveStops ; print label
5703 ; call TFT_standard_color 5557
5704 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*0 5558 WIN_TINY dm_custom_cave_title_column2,dm_custom_cave_title_row
5705 ; rcall TFT_surface_tankdata_debug_print 5559 STRCPY_TEXT_PRINT tCaveTTS ; print label
5706 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*1 5560
5707 ; rcall TFT_surface_tankdata_debug_print 5561 WIN_TINY dm_custom_cave_title_column3,dm_custom_cave_title_row
5708 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*2 5562 STRCPY_TEXT_PRINT tCaveRuntime ; print label
5709 ; rcall TFT_surface_tankdata_debug_print 5563
5710 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*3 5564 return ; done
5711 ; rcall TFT_surface_tankdata_debug_print 5565
5712 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*4 5566
5713 ; rcall TFT_surface_tankdata_debug_print 5567 ;-----------------------------------------------------------------------------
5714 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*5 5568 ; Dive Custom View - Cave Mode TTS, total Stops and Run Time - Data
5715 ; rcall TFT_surface_tankdata_debug_print 5569 ;
5716 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*6 5570 global TFT_cave_tts
5717 ; rcall TFT_surface_tankdata_debug_print 5571 TFT_cave_tts:
5718 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*7 5572 ; total time of all stops
5719 ; rcall TFT_surface_tankdata_debug_print 5573 WIN_MEDIUM dm_custom_cave_data_column1,dm_custom_cave_data_row
5720 ; return 5574 FONT_COLOR_MEMO ; set default color
5721 5575 btfss cave_mode ; cave mode switched on?
5722 ; TFT_surface_tankdata_debug_print: 5576 bra TFT_cave_1b ; NO - print dashes
5723 ; movff POSTINC1,hi ; ID high (+0) 5577 MOVII int_O_TST_norm,mpr ; YES - get normal plan total stops time
5724 ; movff POSTINC1,lo ; ID low (+1) 5578 btfss mpr+1,int_not_yet_computed ; - not yet computed?
5725 ; output_16 5579 bra TFT_cave_1a ; NO - continue
5726 ; PUTC "," 5580 FONT_COLOR_DISABLED ; YES - switch to disabled color
5727 ; movff POSTINC1,hi ; pressure high (+2) 5581 bra TFT_cave_1b ; - print dashes
5728 ; movff POSTINC1,lo ; pressure low (+3) 5582
5729 ; call TFT_color_code_tank_pres_sac; needed to clear the status flags before output 5583 TFT_cave_1a:
5730 ; output_16 5584 btfsc mpr+1,int_invalid_flag ; stops time invalid?
5731 ; PUTC "," 5585 FONT_COLOR_DISABLED ; YES - switch to disabled color
5732 ; movff POSTINC1,lo ; status (+4) 5586 bcf mpr+1,int_invalid_flag ; clear invalid flag if applicable
5733 ; output_8 5587 movf mpr+0,W ; copy low byte of stops time to WREG
5734 ; PUTC "," 5588 iorwf mpr+1,W ; ior with high byte of stops time
5735 ; movff POSTINC1,lo ; date (+5) 5589 bz TFT_cave_1b ; print dashes if stops time is zero
5736 ; output_8 5590 output_999 ; print (0-999)
5737 ; STRCAT_PRINT "" 5591 PUTC_PRINT "'" ; append unit and dump to screen
5738 ; return 5592 bra TFT_cave_2 ; continue
5739 5593
5740 ENDIF ; _rx_functions 5594 TFT_cave_1b:
5595 STRCAT_PRINT ",-,-,-," ; print 3 dashes (',' produces a half-width space)
5596 ;bra TFT_cave_2 ; continue
5597
5598 TFT_cave_2:
5599 ; cave TTS
5600 WIN_MEDIUM dm_custom_cave_data_column2,dm_custom_cave_data_row ; column 60
5601 FONT_COLOR_MEMO ; set default color
5602 btfsS cave_mode ; cave mode switched on?
5603 bra TFT_cave_2b ; NO - print dashes
5604 MOVII int_O_TTS_norm,mpr ; YES - get normal plan total time to surface
5605 btfss mpr+1,int_not_yet_computed ; - not yet computed?
5606 bra TFT_cave_2a ; NO - continue
5607 FONT_COLOR_DISABLED ; YES - switch to disabled color
5608 bra TFT_cave_2b ; - print dashes
5609
5610 TFT_cave_2a:
5611 btfsc mpr+1,int_invalid_flag ; TTS invalid?
5612 FONT_COLOR_DISABLED ; YES - switch to disabled color
5613 bcf mpr+1,int_invalid_flag ; clear invalid flag if applicable
5614 output_999 ; print (0-999)
5615 PUTC_PRINT "'" ; append unit and dump to screen
5616 bra TFT_cave_3 ; continue
5617
5618 TFT_cave_2b:
5619 STRCAT_PRINT ",-,-,-," ; print 3 dashes (',' produces a half-width space)
5620 ;bra TFT_cave_3 ; continue
5621
5622 TFT_cave_3:
5623 ; estimated total runtime
5624 WIN_MEDIUM dm_custom_cave_data_column3,dm_custom_cave_data_row
5625 ; ; keep color from cave TTS
5626 btfss cave_mode ; cave mode switched on?
5627 bra TFT_cave_3b ; NO - print dashes
5628 SMOVII counted_divetime_mins,mpr ; YES - ISR safe copy of counted dive time to MPR
5629 movff int_O_TTS_norm+0,WREG ; - get TTS, low byte, into WREG
5630 addwf mpr+0,F ; - add TTS, low byte, to dive time in MPR
5631 movff int_O_TTS_norm+1,WREG ; - get TTS, high byte, into WREG
5632 btfsc WREG,int_not_yet_computed ; - not yet computed?
5633 bra TFT_cave_3b ; YES - print dashes
5634 bcf WREG,int_invalid_flag ; NO - clear invalid flag if applicable
5635 addwfc mpr+1,F ; - add TTS, high byte, to dive time in MPR
5636 output_999 ; - print (0-999)
5637 PUTC_PRINT "'" ; - append unit and dump to screen
5638 return ; - done
5639
5640 TFT_cave_3b:
5641 STRCAT_PRINT ",-,-,-," ; print 3 dashes (',' produces a half-width space)
5642 return ; done
5643
5644
5645 ;-----------------------------------------------------------------------------
5646 ; Dive Custom View - Cave Mode Waypoints
5647 ;
5648 global TFT_cave_waypoints
5649 TFT_cave_waypoints:
5650 ; arrow
5651 WIN_TINY .70,dm_custom_cave_title_row
5652 FONT_COLOR_ATTENTION ; select color
5653 btfss cave_mode ; cave mode switched on?
5654 bra TFT_cave_waypoints_3 ; NO - do not show any marker (any more)
5655 btfsc dive_turned ; YES - dive turned?
5656 bra TFT_cave_waypoints_2 ; YES - print marker in the middle
5657 ;bra TFT_cave_waypoints_1 ; NO - print marker on right side
5658
5659 TFT_cave_waypoints_1:
5660 movlw .12 ; start with 12 space chars
5661 call TFT_buffer_trim_length ; fill / cut buffer to target length
5662 ;bra TFT_cave_waypoints_2 ; continue
5663
5664 TFT_cave_waypoints_2:
5665 STRCAT "<=====" ; print marker symbol
5666 ;bra TFT_cave_waypoints_3 ; continue
5667
5668 TFT_cave_waypoints_3:
5669 movlw .18 ; set overall number of chars
5670 call TFT_buffer_trim_length ; fill / cut buffer to target length
5671 PRINT ; dump buffer to screen
5672 ; waypoint band
5673 btfsc cave_mode ; cave mode switched on?
5674 bra TFT_cave_waypoints_4 ; YES - show graphics
5675 WIN_STD .0,dm_custom_cave_data_row ; NO - show "Cave Mode off" text
5676 FONT_COLOR_ATTENTION ; - select attention color
5677 PUTC " " ; - print 2 space chars
5678 PUTC " " ; - ...
5679 STRCAT_TEXT tCaveMode ; - print "Cave Mode"
5680 PUTC " " ; - print 1 space char
5681 STRCAT_TEXT tOff ; - print "off"
5682 movlw .17 ; - set max number of chars
5683 call TFT_buffer_trim_length ; - fill / cut buffer to target length
5684 PRINT ; - dump buffer to screen
5685 return ; - done
5686
5687 TFT_cave_waypoints_4:
5688 WIN_MEDIUM .0,dm_custom_cave_data_row; start in column 0
5689 FONT_COLOR_MEMO ; select default color
5690 tstfsz DM_flags_cavereq ; any pending cave mode requests?
5691 FONT_COLOR_DISABLED ; YES - switch to disabled color
5692 ; 1st section: previous waypoint number or beginning line
5693 movlw .1 ; load a one into WREG
5694 cpfsgt backtrack_waypoint_num ; current waypoint number > 1 ?
5695 bra TFT_cave_waypoints_5 ; NO - print line segment only
5696 STRCAT ",-," ; YES - print one dash
5697 movff backtrack_waypoint_num,lo ; - copy current waypoint number to lo
5698 decf lo,F ; - create previous waypoint number
5699 output_99 ; - print previous waypoint number in two digit format
5700 STRCAT "," ; - print a half-space
5701 bra TFT_cave_waypoints_6 ; - continue with next section
5702
5703 TFT_cave_waypoints_5:
5704 STRCAT ",-,-----" ; print line segment
5705 ;bra TFT_cave_waypoints_6 ; continue with next section
5706
5707 TFT_cave_waypoints_6:
5708 ; 2nd section: solid line
5709 STRCAT "---" ; print a solid line
5710 ; 3rd section: current waypoint number, turn point symbol or line segment
5711 tstfsz backtrack_waypoint_num ; does a current waypoint exist?
5712 bra TFT_cave_waypoints_8 ; YES - print its number or the turn point symbol
5713 btfss dive_turned ; NO - dive turned?
5714 bra TFT_cave_waypoints_7 ; NO - print a separated line segment
5715 STRCAT "------" ; YES - print a continuous line
5716 bra TFT_cave_waypoints_10 ; - continue with next section
5717
5718 TFT_cave_waypoints_7:
5719 STRCAT ",----," ; print a separated line segment
5720 bra TFT_cave_waypoints_10 ; continue with next section
5721
5722 TFT_cave_waypoints_8:
5723 STRCAT "," ; print a half-width space
5724 movff backtrack_waypoint_num,lo ; copy current waypoint number to lo
5725 movf backtrack_waypoint_turn,W ; copy turn point number to WREG
5726 cpfseq lo ; current waypoint = turn point ?
5727 bra TFT_cave_waypoints_9 ; NO - show waypoint number
5728 STRCAT_PRINT "--|, " ; YES - print end-of-line symbol, clear remaining output and dump buffer to screen
5729 return ; - done
5730
5731 TFT_cave_waypoints_9:
5732 movff backtrack_waypoint_num,lo ; copy current waypoint number to lo
5733 output_99 ; print current waypoint number in two digit format
5734 STRCAT "," ; print a half-space
5735 ;bra TFT_cave_waypoints_10 ; continue with next section
5736
5737 TFT_cave_waypoints_10:
5738 ; 4th section: solid line
5739 STRCAT "---" ; print a solid line
5740 ; 5th section: next waypoint number or end of line symbol
5741 incf backtrack_waypoint_num,W ; load WREG with next waypoint number
5742 cpfseq backtrack_waypoint_turn ; next waypoint number = turn point number ?
5743 btfsc waypoint_reached_last ; NO - is the current waypoint the last waypoint?
5744 bra TFT_cave_waypoints_11 ; YES / YES - print end-of-line symbol
5745 STRCAT "," ; NO - print a half-space
5746 incf backtrack_waypoint_num,W ; - (re)load WREG with next waypoint number
5747 movwf lo ; NO - copy next waypoint number to lo
5748 output_99 ; - print next waypoint number in two digit format
5749 PRINT ; - dump buffer to screen
5750 return ; - done
5751
5752 TFT_cave_waypoints_11:
5753 STRCAT_PRINT "---|," ; print end-of-line symbol and dump buffer to screen
5754 return ; done
5755
5756 ENDIF ; _cave_mode
5757
5741 5758
5742 ;============================================================================= 5759 ;=============================================================================
5743 5760 tft_out15 CODE
5744 global convert_pres_to_depth
5745 convert_pres_to_depth: ; converts pressure in [mbar] to depth in [cm]
5746 btfsc sensor_override_active ; in pressure sensor override (simulator) mode?
5747 return ; YES - convert with factor 1.0, i.e. make [mbar] = [cm]
5748
5749 movff opt_salinity,WREG ; get salinity setting (0 - 4 %, see option_table.asm)
5750 addlw d'100' ; add density of fresh water (1.00 kg/l)
5751 movwf up ; store salinity factor in up
5752
5753 movlw .101+salinity_max ; load (upper limit + 1)
5754 cpfslt up ; current setting > upper limit?
5755 bra convert_fix_salinity ; YES - fix salinity setting
5756
5757 movlw .99+salinity_min ; load (lower limit - 1)
5758 cpfsgt up ; current setting > lower limit?
5759 bra convert_fix_salinity ; YES - fix salinity setting
5760
5761 convert_pres_to_depth_1:
5762 MOVII mpr, xA ; get pressure in [mbar]
5763 MOVLI .102,xB ; conversion factor x 100 for fresh water (1.02 cm per each 1 mbar)
5764 call mult16x16 ; xC:4 = xA:2 * xB:2
5765 movff up,xB+0 ; get salinity in [%]
5766 clrf xB+1 ; ...
5767 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
5768 MOVII xC,mpr ; copy back result as depth in [cm]
5769 return
5770
5771 convert_fix_salinity:
5772 movlw .100 ; reset to 100%, i.e. set salinity to 0%
5773 movwf up ; fix value in up
5774 bra convert_pres_to_depth_1 ; continue
5775
5776 ;============================================================================= 5761 ;=============================================================================
5777 5762
5778 global convert_cm_to_feet 5763
5779 convert_cm_to_feet: ; converts depth in [cm] to depth in [feet] 5764 ;-----------------------------------------------------------------------------
5780 MOVII mpr, xA ; depth in [cm] 5765 ; Helper Function - check if firmware is within expiry period
5781 btfsc sensor_override_active ; in pressure sensor override (simulator) mode? 5766 ;
5782 bra convert_meter_to_feet_1 ; YES - convert with 334feet/100m 5767 ; Output: aux_flag set if not
5783 MOVLI .328,xB ; NO - convert with 328feet/100m 5768 ;
5784 bra convert_common_to_feet ; - continue with common part 5769 check_expiry:
5785 5770 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
5786 5771 movff rtc_latched_day,lo ; get current day
5787 global convert_meter_to_feet 5772 movff rtc_latched_month,hi ; get current month
5788 convert_meter_to_feet: ; converts depth in [m] to depth in [feet] 5773 movff rtc_latched_year,up ; get current year
5789 movf lo,W ; depth in [m] 5774 bsf aux_flag ; set firmware as expired by default
5790 mullw .100 ; factor to convert [m] to [cm] 5775 movlw firmware_expire_year ; start with checking year
5791 MOVII PRODL,xA ; copy depth in [cm] to xA 5776 cpfsgt up ; current year > expiry year ?
5792 convert_meter_to_feet_1: 5777 bra check_expiry_Y ; NO - continue checks
5793 MOVLI .334, xB ; convert with 334feet/100m to have 10ft, 20ft, 30ft, ... for stop depths 5778 return ; YES - expired
5794 ;bra convert_common_to_feet ; continue with common part 5779
5795 5780 check_expiry_Y:
5796 5781 cpfseq up ; current year = expiry year ?
5797 convert_common_to_feet: 5782 bra check_expiry_ok ; NO - must be < then, OK whatever month & day
5798 call mult16x16 ; xC = xA * xB = depth in [cm] * 334 feet/100 m = depth in 0.0001 feet 5783 movlw firmware_expire_month ; YES - continue checking month
5799 MOVLI .10000,xB ; divide by 10000 to turn into full feet 5784 cpfsgt hi ; current month > expiry month ?
5800 call div32x16 ; xC = xC / xB with xA as remainder 5785 bra check_expiry_M ; NO - continue checks
5801 MOVII xC,mpr ; store result 5786 return ; YES - expired
5802 5787
5803 return 5788 check_expiry_M:
5804 5789 cpfseq hi ; current month = expiry month ?
5805 ;============================================================================= 5790 bra check_expiry_ok ; NO - must be < then, OK whatever day
5806 5791 movlw firmware_expire_day ; YES - continue checking day
5807 global convert_celsius_to_fahrenheit ; convert value in hi:lo from Celsius to Fahrenheit 5792 cpfsgt lo ; current day > expiry day ?
5808 convert_celsius_to_fahrenheit: ; convert value in lo:hi from Celsius to Fahrenheit 5793 bra check_expiry_ok ; NO - must be <= then, OK
5809 MOVII mpr,xA ; temperature in 1/10 of °C 5794 return ; YES - expired
5810 ADDLI .1000,xA ; add offset of 1000 to get out of any negative numbers 5795
5811 ; adjust scaling: 1°C = 1.8°F: 5796 check_expiry_ok:
5812 MOVLI .18,xB ; multiply with 18: 5797 bcf aux_flag ; not expired
5813 call mult16x16 ; ... 5798 return ; done
5814 MOVLI .10,xB ; divide by 10 5799
5815 call div32x16 ; ... 5800
5816 SUBLI .1480,xC ; remove offset: subtract above offset of 1000 * 1.8 = 1800 now and add 320 => subtract 1480 5801 ;-----------------------------------------------------------------------------
5817 MOVII xC,mpr ; store result in hi:lo 5802 ; show Firmware updated Message
5818 return 5803 ;
5804 ; Attention:
5805 ; Pallet colors and language switching are not
5806 ; available yet, all text outputs are hard-coded!
5807 ;
5808 global TFT_message_fw_update
5809 TFT_message_fw_update:
5810 FONT_COLOR_STANDARD ; set color
5811
5812 ; show update message
5813 WIN_SMALL .20,.100 ; set position
5814 STRCPY_PRINT "Update successful!" ; print message
5815
5816 ; show firmware version
5817 WIN_SMALL .20,.140 ; set position
5818 STRCPY "New Firmware: " ; print message
5819
5820 bra TFT_message_fw_common ; show firmware version
5821
5822
5823 ;-----------------------------------------------------------------------------
5824 ; show Firmware kept Message
5825 ;
5826 ; Attention:
5827 ; Pallet colors and language switching are not
5828 ; available yet, all text outputs are hard-coded!
5829 ;
5830 global TFT_message_fw_kept
5831 TFT_message_fw_kept:
5832 FONT_COLOR_STANDARD ; set color
5833
5834 ; show reboot message
5835 WIN_SMALL .60,.100 ; set position
5836 STRCPY_PRINT "Reboot" ; print message
5837
5838 ; show firmware version
5839 WIN_SMALL .30,.140 ; set position
5840 STRCPY "Firmware: " ; print message
5841
5842 ;bra TFT_message_fw_common ; show firmware version
5843
5844
5845 ; Helper Function - show firmware version x.y and color-code + invert if outdated
5846 TFT_message_fw_common:
5847 rcall TFT_cat_firmware ; append major/minor and color-code on expiry
5848 PRINT ; dump to screen
5849 ; show firmware beta status
5850 WIN_SMALL .60,.180
5851 FONT_COLOR_STANDARD ; set default color for a release version
5852 rcall TFT_cat_beta_long ; show "Release" or "BETA" + issue
5853 PRINT ; dump to screen
5854 return ; done
5855
5856
5857 ;-----------------------------------------------------------------------------
5858 ; append Firmware Version to current String, including color-coding on expiry
5859 ;
5860 global TFT_cat_firmware
5861 TFT_cat_firmware:
5862 movlw fw_version_major ; get major
5863 movwf lo ; ...
5864 bsf leftbind ; print left-aligned
5865 output_99 ; print major (0-99)
5866 PUTC '.' ; print a dot
5867 movlw fw_version_minor ; get minor
5868 movwf lo ; ...
5869 output_99x ; print minor in two digit format
5870 rcall check_expiry ; check if firmware is expired
5871 btfss aux_flag ; expired?
5872 return ; NO
5873 bsf win_invert ; YES - print in inverse
5874 FONT_COLOR color_yellow ; - print in yellow
5875 return ; - done
5876
5877
5878 ;-----------------------------------------------------------------------------
5879 ; append Firmware BETA Status to current String, including color-coding on BETA
5880 ;
5881 global TFT_cat_beta_long
5882 TFT_cat_beta_long:
5883 bsf aux_flag ; do long version
5884 bra TFT_cat_beta_common ; continue with common part
5885
5886 global TFT_cat_beta_short
5887 TFT_cat_beta_short:
5888 bcf aux_flag ; do short version
5889 ;bra TFT_cat_beta_common ; continue with common part
5890
5891 TFT_cat_beta_common:
5892
5893 IFDEF _DEBUG
5894
5895 FONT_COLOR color_red ; set color
5896 btfss aux_flag ; shall show long version?
5897 bra TFT_cat_debug_short ; NO - show short version
5898 ;bra TFT_cat_debug_long ; YES - show long version
5899
5900 TFT_cat_debug_long:
5901 STRCAT "DEBUG" ; print long debug
5902 return ; done
5903
5904 TFT_cat_debug_short:
5905 STRCAT "DBG." ; print short debug
5906 return ; done
5907
5908 ELSE
5909
5910 movlw fw_version_beta ; =0: release, =1: beta 1, =2: beta 2, ...
5911 movwf lo ; copy to lo
5912 tstfsz lo ; release version?
5913 bra TFT_cat_beta_com ; NO - must be beta version then
5914 btfss aux_flag ; YES - shall show long version?
5915 bra TFT_cat_beta_rel_short ; NO - show short version
5916 rcall check_expiry ; YES - check expiry date
5917 btfsc aux_flag ; - within expiry date?
5918 bra TFT_cat_beta_update ; NO - give update cue
5919 ;bra TFT_cat_beta_rel_long ; YES - "Release"
5920
5921 TFT_cat_beta_rel_long:
5922 STRCAT "Release" ; print long "Release"
5923 return ; done
5924
5925 TFT_cat_beta_rel_short:
5926 STRCAT "Rel." ; print short "Release"
5927 return ; done
5928
5929 TFT_cat_beta_com:
5930 FONT_COLOR color_yellow ; set color
5931 btfss aux_flag ; shall show long version?
5932 bra TFT_cat_beta_short_exec ; NO - show short version
5933 ;bra TFT_cat_beta_long_exec ; YES - show long version
5934
5935 TFT_cat_beta_long_exec:
5936 STRCAT "Beta " ; print long "Beta"
5937 bra TFT_cat_beta_version ; print version
5938
5939 TFT_cat_beta_short_exec:
5940 STRCAT "B." ; print short "Beta"
5941 ;bra TFT_cat_beta_version ; append beta version number
5942
5943 TFT_cat_beta_version:
5944 bsf leftbind ; print left-aligned
5945 output_256 ; print beta version number (0-255)
5946 return ; done
5947
5948 TFT_cat_beta_update:
5949 FONT_COLOR color_yellow
5950 STRCAT "update!" ; print update cue
5951 return ; done
5952
5953 ENDIF
5954
5955
5956 ;-----------------------------------------------------------------------------
5957 ; append Serial Number to to current String
5958 ;
5959 global TFT_cat_serial
5960 TFT_cat_serial:
5961 call eeprom_serial_number_read ; read OSTC serial number
5962 bsf leftbind ; print left-aligned
5963 output_65535 ; print serial number
5964 return ; done
5965
5966
5967 ;-----------------------------------------------------------------------------
5968 ; print Serial Number and Firmware Version (used by comm mode)
5969 ;
5970 global TFT_print_serial_and_firmware
5971 TFT_print_serial_and_firmware:
5972 STRCPY "#" ; print "#"
5973 rcall TFT_cat_serial ; print serial number
5974 STRCAT " " ; print a space
5975 STRCAT "v" ; print a "v" (version)
5976 ;bra TFT_print_firmware ; print firmware version
5977
5978
5979 ;-----------------------------------------------------------------------------
5980 ; print Firmware Version
5981 ;
5982 global TFT_print_firmware
5983 TFT_print_firmware:
5984 rcall TFT_cat_firmware ; print firmware major/minor, will set win_invert if outdated
5985 STRCAT " " ; print a space
5986 rcall TFT_cat_beta_long ; print release/beta and update notification if expired
5987 PRINT ; dump to screen
5988 return ; done
5989
5990
5991 ;-----------------------------------------------------------------------------
5992 ; print Deco Type (OC, CCR, ...)
5993 ;
5994 ; Input: lo deco type number: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
5995 ;
5996 global TFT_print_decotype
5997 TFT_print_decotype:
5998 bsf aux_flag ; default to dive with deco calculation (used by logbook)
5999 incf lo,W ; WREG = lo + 1
6000 TFT_print_decotype_1
6001 decfsz WREG,W ; in OC mode?
6002 bra TFT_print_decotype_2 ; NO - try next
6003 STRCAT_TEXT_PRINT tDvOC ; YES - print "OC"
6004 return ; - done
6005 TFT_print_decotype_2:
6006 decfsz WREG,W ; in CCR mode?
6007 bra TFT_print_decotype_3 ; NO - try next
6008 STRCAT_TEXT_PRINT tDvCC ; YES - print "CCR"
6009 return ; - done
6010 TFT_print_decotype_3:
6011 decfsz WREG,W ; in gauge mode?
6012 bra TFT_print_decotype_4 ; NO - try next
6013 bcf aux_flag ; YES - dive without deco data
6014 STRCAT_TEXT_PRINT tDvGauge ; - Print "Gauge"
6015 return ; - done
6016 TFT_print_decotype_4:
6017 decfsz WREG,W ; in apnea mode?
6018 bra TFT_print_decotype_5 ; NO - try next
6019 bcf aux_flag ; YES - dive without deco data
6020 STRCAT_TEXT_PRINT tDvApnea ; - print "Apnoe"
6021 return ; - done
6022 TFT_print_decotype_5:
6023 STRCAT_TEXT_PRINT tDvPSCR ; print "pSCR"
6024 return ; done
6025
5819 6026
5820 ;============================================================================= 6027 ;=============================================================================
6028 tft_out16 CODE
6029 ;=============================================================================
6030
6031
6032 global TFT_debug_output
6033 TFT_debug_output:
6034
6035 IFNDEF _debug_output
6036
6037 return ; do nothing
6038
6039 ELSE
6040
6041 btfsc alt_layout_active ; alternative layout active?
6042 return ; YES - abort
6043
6044 ; WIN_TINY .100,.30 ; surface mode: fits under the textual logo in the upper right corner
6045 ; WIN_TINY .35, .0 ; dive mode: fits to the right side of the depth label
6046 WIN_TINY .0, . 0 ; dive mode: overwrites depth label
6047 FONT_COLOR_MEMO ; set color
6048
6049 ; deco engine scheduling performance
6050 MOVII int_O_profiling_overrun,mpr ; runtime +/- versus target
6051 btfss mpr+1,7 ; overrun?
6052 bra TFT_debug_output_1 ; YES
6053 bcf mpr+1,7 ; NO - clear flag
6054 PUTC "-" ; - print a minus
6055 bra TFT_debug_output_2 ; - continue
6056 TFT_debug_output_1:
6057 PUTC " " ; print a space instead of the minus
6058 TFT_debug_output_2:
6059 output_999 ; print time (0-999)
6060 PUTC "." ; print a dot as separator
6061 MOVII int_O_profiling_overrun_max,mpr ; get max runtime so far
6062 output_999 ; print (0-999)
6063 PUTC "." ; print a dot as separator
6064 movff char_O_profiling_overrun_phase,WREG ; get calculation phase causing the max runtime
6065 output_hex ; print a hex
6066 PUTC "." ; print a dot as separator
6067 movff char_O_profiling_runs_norm,mpr ; get runs/cycle normal plan
6068 output_99 ; print (0-99)
6069 PUTC "." ; print a dot as separator
6070 movff char_O_profiling_runs_alt,mpr ; get runs/cycle alternative plan
6071 output_99 ; print (0-99)
6072 PRINT ; dump to screen
6073 return ; done
6074
6075 ENDIF ; _debug_output
6076
6077 ;-----------------------------------------------------------------------------
5821 6078
5822 END 6079 END