comparison src/tft_outputs.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents 1ad0531e9078
children cd58f7fc86db
comparison
equal deleted inserted replaced
622:02d1386429a6 623:c40025d8e750
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File tft_outputs.asm REFACTORED VERSION V2.99f 3 ; File tft_outputs.asm next combined generation V3.03.4
4 ; 4 ;
5 ; Startup subroutines 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 ;=============================================================================
9 ; HISTORY 9 ; HISTORY
10 ; 2011-08-07 : [mH] moving from OSTC code 10 ; 2011-08-07 : [mH] moving from OSTC code
11 11
12 #include "hwos.inc" ; mandatory header 12 #include "hwos.inc" ; mandatory header
13 #include "shared_definitions.h" ; mailbox from/to p2_deco.c 13 #include "shared_definitions.h" ; mailbox from/to p2_deco.c
14 #include "tft.inc" 14 #include "tft.inc"
15 #include "start.inc" 15 #include "start.inc"
16 #include "wait.inc"
17 #include "strings.inc" 16 #include "strings.inc"
18 #include "convert.inc" 17 #include "convert.inc"
19 #include "varargs.inc" 18 #include "varargs.inc"
20 #include "math.inc" 19 #include "math.inc"
21 #include "isr.inc"
22 #include "eeprom_rs232.inc" 20 #include "eeprom_rs232.inc"
23 #include "adc_lightsensor.inc" 21 #include "adc_lightsensor.inc"
24 #include "surfmode.inc" 22 #include "surfmode.inc"
25 #include "divemode.inc" 23 #include "divemode.inc"
26 #include "external_flash.inc" 24 #include "external_flash.inc"
28 #include "customview.inc" 26 #include "customview.inc"
29 #include "i2c.inc" 27 #include "i2c.inc"
30 #include "colorschemes.inc" 28 #include "colorschemes.inc"
31 #include "calibrate.inc" 29 #include "calibrate.inc"
32 #include "gaslist.inc" 30 #include "gaslist.inc"
33
34 IFDEF _rx_functions
35 #include "rx_ops.inc" 31 #include "rx_ops.inc"
36 ENDIF 32
33
34 ;---- external Functions -----------------------------------------------------
37 35
38 extern aa_wordprocessor 36 extern aa_wordprocessor
39 extern get_first_gas_to_WREG 37 extern get_first_gas_to_WREG
40 extern get_first_dil_to_WREG 38
39
40 ;---- external Texts ---------------------------------------------------------
41 41
42 extern tFirmware 42 extern tFirmware
43 extern tSerial 43 extern tSerial
44 extern tTotalDives 44 extern tTotalDives
45 extern tBatteryV 45 extern tBatteryV
46 extern tUptime 46 extern tUptime
47 extern tCalX,tCalY,tCalZ
48 extern tPPO2MIN 47 extern tPPO2MIN
49 extern tPPO2MINCC
50 extern tPPO2Max 48 extern tPPO2Max
51 extern tPPO2DECO 49 extern tPPO2DECO
50 extern tbar
51
52 IFDEF _ccr_pscr
53 extern tPPO2MINCC
54 ENDIF
52 55
53 IFDEF _rx_functions 56 IFDEF _rx_functions
54 extern tFirmware_rx 57 extern tFirmware_rx
55 ENDIF 58 ENDIF
56 59
60 IFDEF _compass
61 extern tCalX,tCalY,tCalZ
62 ENDIF
63
64
65 tft_out CODE
66
57 ;============================================================================= 67 ;=============================================================================
58 68
59 tft_out CODE 69 global TFT_debug_output
70 TFT_debug_output:
71 ifndef _debug_output
72 return
73 else
74 btfsc alt_layout_active ; alternative layout active?
75 return ; YES - abort
76
77 ; WIN_TINY .100,.30 ; surface mode: fits under the textual logo in the upper right corner
78 ; WIN_TINY .35, .0 ; dive mode: fits to the right side of the depth label
79 WIN_TINY .0, .0 ; dive mode: overwrites depth label
80 call TFT_standard_color
81 lfsr FSR2,buffer
82
83 ; deco engine scheduling performance
84 MOVII int_O_profiling_overrun,mpr ; runtime +/- versus target
85 btfss mpr+1,7
86 bra TFT_debug_output_1
87 bcf mpr+1,7
88 PUTC "-"
89 bra TFT_debug_output_2
90 TFT_debug_output_1:
91 PUTC " "
92 TFT_debug_output_2:
93 output_16_3
94 PUTC "."
95 MOVII int_O_profiling_overrun_max,mpr ; max runtime
96 output_16_3
97 PUTC "."
98 movff char_O_profiling_overrun_phase,WREG ; calculation phase causing the max runtime
99 output_hex
100 PUTC "."
101 movff char_O_profiling_runs_norm,mpr ; runs/cycle normal plan
102 output_99
103 PUTC "."
104 movff char_O_profiling_runs_alt,mpr ; runs/cycle alternative plan
105 output_99
106 STRCAT_PRINT ""
107 return
108 endif
109
60 110
61 ;============================================================================= 111 ;=============================================================================
62 112
63 global TFT_divemask_color 113 global TFT_divemask_color
64 TFT_divemask_color: 114 TFT_divemask_color:
65 movlw color_green 115 movlw color_green
66 btfsc divemode ; in divemode? 116 btfsc divemode ; in dive mode?
67 rcall TFT_divemask_color_dive 117 rcall TFT_divemask_color_dive
68 bra TFT_standard_color0 118 bra TFT_standard_color0
69 119
70 TFT_divemask_color_dive: 120 TFT_divemask_color_dive:
71 movff opt_dive_color_scheme,WREG ; 0-3 121 movff opt_dive_color_scheme,WREG ; 0-3
98 movlw color_yellow 148 movlw color_yellow
99 bra TFT_standard_color0 149 bra TFT_standard_color0
100 TFT_attention_color_dive: 150 TFT_attention_color_dive:
101 retlw color_yellow 151 retlw color_yellow
102 152
103 global TFT_warnings_color ; important things with immediate need to react upon 153 global TFT_warning_color ; important things with immediate need to react upon
104 TFT_warnings_color: 154 TFT_warning_color:
105 movlw color_red 155 movlw color_red
106 bra TFT_standard_color0 156 bra TFT_standard_color0
107 TFT_warnings_color_dive: 157 TFT_warnings_color_dive:
108 retlw color_red 158 retlw color_red
109 159
110 160
111 global TFT_disabled_color 161 global TFT_disabled_color
112 TFT_disabled_color: 162 TFT_disabled_color:
113 movlw color_lightblue 163 movlw color_lightblue
114 btfsc divemode ; in divemode? 164 btfsc divemode ; in dive mode?
115 rcall TFT_disabled_color_dive ; YES 165 rcall TFT_disabled_color_dive ; YES
116 bra TFT_standard_color0 166 bra TFT_standard_color0
117 TFT_disabled_color_dive: 167 TFT_disabled_color_dive:
118 movff opt_dive_color_scheme,WREG ; 0-3 168 movff opt_dive_color_scheme,WREG ; 0-3
119 incf WREG 169 incf WREG
127 177
128 178
129 global TFT_standard_color 179 global TFT_standard_color
130 TFT_standard_color: 180 TFT_standard_color:
131 setf WREG ; default white 181 setf WREG ; default white
132 btfsc divemode ; in divemode? 182 btfsc divemode ; in dive mode?
133 rcall TFT_standard_color_dive 183 rcall TFT_standard_color_dive
134 ;bra TFT_standard_color0 184 ;bra TFT_standard_color0
135 TFT_standard_color0: 185 TFT_standard_color0:
136 goto TFT_set_color ; and return... 186 goto TFT_set_color ; and return...
137 187
138 188
139 TFT_standard_color_dive: 189 TFT_standard_color_dive:
140 movff opt_dive_color_scheme,WREG ; 0-3 190 movff opt_dive_color_scheme,WREG ; 0-3
141 incf WREG 191 incf WREG
142 dcfsnz WREG 192 dcfsnz WREG
143 retlw color_scheme_divemode_std1 ;0 193 retlw color_scheme_divemode_std1 ; 0
144 dcfsnz WREG 194 dcfsnz WREG
145 retlw color_scheme_divemode_std2 ;1 195 retlw color_scheme_divemode_std2 ; 1
146 dcfsnz WREG 196 dcfsnz WREG
147 retlw color_scheme_divemode_std3 ;2 197 retlw color_scheme_divemode_std3 ; 2
148 retlw color_scheme_divemode_std4 ;3 198 retlw color_scheme_divemode_std4 ; 3
149 199
150 200
151 global TFT_color_code_tank_pres_sac 201 global TFT_color_code_tank_pres_sac
152 TFT_color_code_tank_pres_sac: ; color-code a tank pressure or SAC rate, data in hi:lo 202 TFT_color_code_tank_pres_sac: ; color-code a tank pressure or SAC rate, data in hi:lo
153 btfss hi,int_not_avail_flag ; is the not-available flag set? 203 btfss hi,int_not_avail_flag ; is the not-available flag set?
164 TFT_color_code_tank_pres_2: 214 TFT_color_code_tank_pres_2:
165 btfss hi,int_warning_flag ; is the warning flag set? 215 btfss hi,int_warning_flag ; is the warning flag set?
166 bra TFT_color_code_tank_pres_3 ; NO 216 bra TFT_color_code_tank_pres_3 ; NO
167 bcf hi,int_warning_flag ; YES - clear warning flag 217 bcf hi,int_warning_flag ; YES - clear warning flag
168 bcf hi,int_attention_flag ; - clear attention flag (it may be set) 218 bcf hi,int_attention_flag ; - clear attention flag (it may be set)
169 bra TFT_warnings_color ; - set to warning color and return 219 bra TFT_warning_color ; - set to warning color and return
170 TFT_color_code_tank_pres_3: 220 TFT_color_code_tank_pres_3:
171 btfss hi,int_attention_flag ; is the attention flag set? 221 btfss hi,int_attention_flag ; is the attention flag set?
172 bra TFT_memo_color ; NO - set to memo color and return 222 bra TFT_memo_color ; NO - set to memo color and return
173 bcf hi,int_attention_flag ; YES - clear attention flag 223 bcf hi,int_attention_flag ; YES - clear attention flag
174 bra TFT_attention_color ; - set to attention color and return 224 bra TFT_attention_color ; - set to attention color and return
175 225
176 226
177 global TFT_color_code_gaslist 227 global TFT_color_code_gaslist
178 TFT_color_code_gaslist: ; color-code current row in gaslist (%O2 in hi) according to current amb_pressure 228 TFT_color_code_gaslist: ; color-code current row in gaslist (%O2 in hi) according to current absolute pressure
179 ; Check very high ppO2 manually 229 ; Check very high ppO2 manually
180 movff amb_press_10+0,xA+0 230 MOVII pressure_abs_10,xA
181 movff amb_press_10+1,xA+1
182 movff hi,xB+0 231 movff hi,xB+0
183 clrf xB+1 232 clrf xB+1
184 call mult16x16 ; hi * p_amb/10 233 call mult16x16 ; hi * absolute pressure / 10
185 ; Check if ppO2 > 6.55 bar 234 ; Check if ppO2 > 6.55 bar
186 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2 > 6.55 bar ? 235 tstfsz xC+2 ; char_I_O2_ratio * absolute pressure / 10 > 65536, i.e. ppO2 > 6.55 bar ?
187 bra TFT_warnings_color ; YES - warn in warning color 236 bra TFT_warning_color ; YES - warn in warning color
188 ; Check if ppO2 > 3.30 bar 237 ; Check if ppO2 > 3.30 bar
189 btfsc xC+1,7 238 btfsc xC+1,7
190 bra TFT_warnings_color ; YES - warn in warning color 239 bra TFT_warning_color ; YES - warn in warning color
191 ; Check for low ppO2 240 ; Check for low ppO2
192 movff xC+0,sub_a+0 241 MOVII xC,sub_a
193 movff xC+1,sub_a+1
194 movff char_I_ppO2_min,WREG 242 movff char_I_ppO2_min,WREG
195 mullw d'100' ; char_I_ppO2_min*100 243 mullw d'100' ; char_I_ppO2_min*100
196 movff PRODL,sub_b+0 244 MOVII PRODL,sub_b
197 movff PRODH,sub_b+1 245 call cmpU16 ; compare (sub_a - sub_b)
198 call subU16
199 btfsc neg_flag ; lower than ppO2 min? 246 btfsc neg_flag ; lower than ppO2 min?
200 bra TFT_warnings_color ; YES - set warning color and return 247 bra TFT_warning_color ; YES - set warning color and return
201 ; Check for high ppO2 248 ; Check for high ppO2
202 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector 249 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector
203 btfsc WREG,deco_flag ; are we in deco? 250 btfsc WREG,deco_flag ; are we in deco?
204 bra TFT_color_code_gaslist_deco ; YES - check against ppO2 max deco only 251 bra TFT_color_code_gaslist_deco ; YES - check against ppO2 max deco only
205 ; NO - check against ppO2 max travel/normal and deco 252 ; NO - check against ppO2 max travel/normal and deco
206 ; Check for ppO2 max travel/normal 253 ; Check for ppO2 max travel/normal
207 movff char_I_ppO2_max,WREG ; ppo2 max for travel/normal 254 movff char_I_ppO2_max_work,WREG ; ppo2 max during working phase
208 mullw d'100' ; char_I_ppO2_max*100 255 mullw d'100' ; char_I_ppO2_max_work*100
209 movff PRODL,sub_b+0 256 MOVII PRODL,sub_b
210 movff PRODH,sub_b+1 257 INCI sub_b ; add 1 mbar to avoid warning on equal
211 infsnz sub_b+0,F ; add 1 mbar to avoid warning on equal 258 call cmpU16 ; compare (sub_a - sub_b)
212 incf sub_b+1,F
213 call subU16 ; sub_c = sub_a - sub_b
214 btfss neg_flag ; higher than ppO2 max travel/deco? 259 btfss neg_flag ; higher than ppO2 max travel/deco?
215 rcall TFT_attention_color ; YES - set attention color 260 rcall TFT_attention_color ; YES - set attention color
216 ; Check for ppO2 max deco 261 ; Check for ppO2 max deco
217 TFT_color_code_gaslist_deco: 262 TFT_color_code_gaslist_deco:
218 movff char_I_ppO2_max_deco,WREG ; ppo2 max for deco 263 movff char_I_ppO2_max_deco,WREG ; ppo2 max for deco
219 mullw d'100' ; char_I_ppO2_max_deco*100 264 mullw d'100' ; char_I_ppO2_max_deco * 100
220 movff PRODL,sub_b+0 265 MOVII PRODL,sub_b ; copy product to sub_b
221 movff PRODH,sub_b+1 266 INCI sub_b ; add 1 mbar to avoid warning on equal
222 infsnz sub_b+0,F ; add 1 mbar to avoid warning on equal 267 call cmpU16 ; compare (sub_a - sub_b)
223 incf sub_b+1,F
224 call subU16 ; sub_c = sub_a - sub_b
225 btfss neg_flag ; higher than ppO2 max deco? 268 btfss neg_flag ; higher than ppO2 max deco?
226 bra TFT_warnings_color ; YES - set warning color and return 269 bra TFT_warning_color ; YES - set warning color and return
227 return ; NO - keep current color 270 return ; NO - keep current color
228 271
229 272
230 TFT_color_code_ceiling: ; color-code the ceiling depth 273 TFT_color_code_ceiling: ; color-code the ceiling depth
231 btfsc hi,char_invalid_flag ; is the invalid flag set? (bit 7 here) 274 btfsc hi,char_invalid_flag ; is the invalid flag set? (bit 7 here)
232 bra TFT_color_code_ceiling_1 ; YES 275 bra TFT_color_code_ceiling_1 ; YES - set disabled color
233 SAFE_2BYTE_COPY rel_pressure,sub_a ; NO 276 MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure to sub_a
234 movff lo,sub_b+0 277 MOVII mpr,sub_b ; - get ceiling to sub_b
235 movff hi,sub_b+1 278 call cmpU16 ; - sub_a - sub_b = relative pressure [mbar] - int_O_ceiling [mbar]
236 call subU16 ; sub_c = sub_a - sub_b : sub_c = rel_pressure [mbar] - int_O_ceiling [mbar] 279 btfss neg_flag ; - is current depth < ceiling (too shallow) ?
237 btfsc neg_flag ; is ceiling > current depth? 280 bra TFT_memo_color ; NO - set to memo color and return
238 bra TFT_warnings_color ; YES - set to warning color and return 281 movff char_O_deco_warnings,WREG ; YES - bank-safe copy of deco warnings
239 bra TFT_memo_color ; NO - set to memo color and return 282 btfsc WREG,outside_warning ; - are we currently outside of the ZH-L16 model?
283 bra TFT_warning_color ; YES - set to warnings color and return
284 bra TFT_attention_color ; NO - set to attention color and return
240 TFT_color_code_ceiling_1: 285 TFT_color_code_ceiling_1:
241 bcf hi,char_invalid_flag ; clear the invalid flag (bit 7 here) 286 bcf hi,char_invalid_flag ; clear the invalid flag (bit 7 here)
242 bra TFT_disabled_color ; set to disabled color and return 287 bra TFT_disabled_color ; set to disabled color and return
243 288
244 289
247 ; warning color if above stop and ceiling 292 ; warning color if above stop and ceiling
248 ; (ceiling depth is calculated using current GF) 293 ; (ceiling depth is calculated using current GF)
249 movff char_O_deco_gas+0,WREG ; get flag for invalid deco data 294 movff char_O_deco_gas+0,WREG ; get flag for invalid deco data
250 btfsc WREG,char_invalid_flag ; is the invalid flag set? 295 btfsc WREG,char_invalid_flag ; is the invalid flag set?
251 bra TFT_disabled_color ; YES - set to disabled color and return 296 bra TFT_disabled_color ; YES - set to disabled color and return
252 movff char_O_first_deco_depth,WREG; NO - get stop depth in m into WREG 297 movff char_O_deco_depth,WREG ; NO - get depth of first stop in meters into WREG
253 subwf curr_depth,W ; - compute current depth - stop depth 298 subwf depth_meter,W ; - compute current depth - stop depth
254 btfsc STATUS,C ; - result negative? 299 btfsc STATUS,C ; - result negative?
255 bra TFT_memo_color ; NO - set to memo color and return 300 bra TFT_color_code_stop_1 ; NO - not shallower than stop depth, check for ascent advice
256 movff int_O_ceiling+0,sub_b+0 ; YES - get ceiling depth in mbar 301 MOVII int_O_ceiling,sub_b ; YES - get ceiling depth in mbar
257 movff int_O_ceiling+1,sub_b+1 ; - ...
258 btfsc sub_b+1,char_invalid_flag ; - is the invalid flag set? (bit 7 here) 302 btfsc sub_b+1,char_invalid_flag ; - is the invalid flag set? (bit 7 here)
259 bra TFT_warnings_color ; YES - set to warning color and return 303 bra TFT_warning_color ; YES - set to warning color and return
260 SAFE_2BYTE_COPY rel_pressure,sub_a ; NO - get current depth in mbar 304 MOVII pressure_rel_cur_cached,sub_a; NO - get current pressure
261 call subU16 ; - sub_c = sub_a - sub_b : sub_c = rel_pressure [cm] - int_O_ceiling [mbar => cm] 305 call cmpU16 ; - sub_a - sub_b = relative pressure - int_O_ceiling
262 btfsc neg_flag ; - is ceiling > current depth? 306 btfsc neg_flag ; - is ceiling > current depth?
263 bra TFT_warnings_color ; YES - set to warning color and return 307 bra TFT_warning_color ; YES - set to warning color and return
264 bra TFT_attention_color ; NO - set to attention color and return 308 bra TFT_attention_color ; NO - set to attention color and return
265 309 TFT_color_code_stop_1:
266 310 movff char_O_deco_info,WREG ; get deco info vector
267 TFT_color_code_depth: ; with actual depth as rel_pressure in [mbar] in hi:lo and threshold depth_warn_mbar [mbar] 311 btfss WREG,deco_flag ; in deco mode?
268 movff lo,sub_a+0 312 bra TFT_memo_color ; NO - set to memo color and return
269 movff hi,sub_a+1 313 movff char_O_deco_depth,WREG ; YES - get depth of first stop in meters into WREG
270 movlw LOW depth_warn_mbar 314 incf WREG,W ; - compute stop depth + 1 meter
271 movwf sub_b+0 315 subwf depth_meter,W ; - compute current depth - (stop depth + 1 meter)
272 movlw HIGH depth_warn_mbar 316 btfss STATUS,C ; - result negative?
273 movwf sub_b+1 317 bra TFT_memo_color ; YES - within 1 meter of stop depth
274 call subU16 ; sub_c = sub_a - sub_b 318 bsf win_invert ; NO - deeper that 1 meter below stop depth, give ascent advice
275 TSTOSS opt_modwarning ; 0=standard, 1=blink 319 bra TFT_advice_color ; - ... and return
276 bra TFT_color_code_depth_std 320
277 btfss neg_flag 321
278 bra TFT_color_code_depth_warn ; set to warning color 322 TFT_color_code_depth:
279 bra TFT_color_code_depth_ppO2 ; check depth against MOD and return... 323 TSTOSS opt_modwarning ; MOD warning switched on?
280 TFT_color_code_depth_std: 324 bra TFT_color_code_depth_no_mod ; NO
281 btfss neg_flag 325 btfsc depth_limit_exceeded ; YES - deeper than depth limit?
282 bra TFT_warnings_color ; set to warning color and return 326 bra TFT_color_code_depth_warn ; YES - set to warning color
283 bra TFT_memo_color ; set to memo color and return... 327 bra TFT_color_code_depth_mod ; NO - check depth against MOD and return...
284 TFT_color_code_depth_ppO2: 328 TFT_color_code_depth_no_mod:
285 movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR 329 btfsc depth_limit_exceeded ; NO - deeper than depth limit?
286 decfsz WREG,F ; are we in CCR mode? 330 bra TFT_warning_color ; YES - set to warning color and return
331 bra TFT_memo_color ; NO - set to memo color and return...
332 TFT_color_code_depth_mod:
333 IFDEF _ccr_pscr
334 movff opt_dive_mode,WREG ; get deco mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
335 decfsz WREG,F ; in CCR mode?
287 bra TFT_color_code_depth_no_ccr ; NO - continue checking for ppO2 336 bra TFT_color_code_depth_no_ccr ; NO - continue checking for ppO2
288 btfss FLAG_bailout_mode ; YES - check if in bailout 337 btfss bailout_mode ; YES - check if in bailout
289 bra TFT_color_code_depth_outside; NO - continue checking for outside ZHL16 model 338 bra TFT_color_code_depth_outside; NO - continue checking for outside ZHL16 model
339 ENDIF
290 TFT_color_code_depth_no_ccr: 340 TFT_color_code_depth_no_ccr:
291 movff int_O_breathed_ppO2+1,WREG ; get upper byte of currently breathed ppO2 341 movff int_O_breathed_ppO2+1,WREG ; get upper byte of currently breathed ppO2
292 btfsc WREG,int_warning_flag ; is the warning flag set? 342 btfsc WREG,int_warning_flag ; is the warning flag set?
293 bra TFT_color_code_depth_warn ; YES - animate in warning design 343 bra TFT_color_code_depth_warn ; YES - animate in warning design
294 TFT_color_code_depth_outside: 344 TFT_color_code_depth_outside:
295 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings 345 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings
296 btfsc WREG,outside_warning ; are we currently outside of the ZH-L16 model? 346 btfsc WREG,outside_warning ; are we currently outside of the ZH-L16 model?
297 bra TFT_color_code_depth_warn ; YES 347 bra TFT_color_code_depth_warn ; YES - activate depth warning
298 btfsc WREG,outside_attention ; are we near to outside of the ZH-L16 model? 348 bcf depth_warning ; NO - terminate depth warning
299 bra TFT_color_code_depth_att ; YES 349 btfsc WREG,outside_attention ; - are we near to outside of the ZH-L16 model?
300 bcf blinking_depth_warning ; NO - terminate warning blinking 350 bra TFT_color_code_depth_att ; YES - activate depth attention
301 bcf blinking_depth_attention ; - terminate attention blinking 351 bcf depth_attention ; NO - terminate depth attention
302 bra TFT_memo_color ; - set memo color and return 352 bra TFT_memo_color ; - select memo color and return
303 TFT_color_code_depth_warn: 353 TFT_color_code_depth_warn:
304 bsf blinking_depth_warning ; activate warning blinking 354 bsf depth_warning ; activate depth warning
305 bra TFT_warnings_color ; set to warning color and return... 355 bra TFT_warning_color ; select warning color and return...
306 TFT_color_code_depth_att: 356 TFT_color_code_depth_att:
307 bsf blinking_depth_attention ; activate attention blinking 357 bsf depth_attention ; activate depth attention
308 bra TFT_attention_color ; set to attention color and return... 358 bra TFT_attention_color ; select attention color and return...
309 359
310 360
311 global TFT_color_code_cns 361 global TFT_color_code_cns
312 TFT_color_code_cns: ; color-code CNS values (CNS in hi:lo [%]) 362 TFT_color_code_cns: ; color-code CNS values (CNS in hi:lo [%])
313 btfss hi,int_invalid_flag ; is the invalid flag set? 363 btfss hi,int_invalid_flag ; is the invalid flag set?
319 TFT_color_code_cns_1 369 TFT_color_code_cns_1
320 btfss hi,int_warning_flag ; is the warning flag set? 370 btfss hi,int_warning_flag ; is the warning flag set?
321 bra TFT_color_code_cns_2 ; NO 371 bra TFT_color_code_cns_2 ; NO
322 bcf hi,int_warning_flag ; YES - clear warning flag 372 bcf hi,int_warning_flag ; YES - clear warning flag
323 bcf hi,int_attention_flag ; - clear attention flag (it may be set) 373 bcf hi,int_attention_flag ; - clear attention flag (it may be set)
324 bra TFT_warnings_color ; - set to warning color and return 374 bra TFT_warning_color ; - set to warning color and return
325 TFT_color_code_cns_2: 375 TFT_color_code_cns_2:
326 btfss hi,int_attention_flag ; is the attention flag set? 376 btfss hi,int_attention_flag ; is the attention flag set?
327 bra TFT_memo_color ; NO - set to memo color and return 377 bra TFT_memo_color ; NO - set to memo color and return
328 bcf hi,int_attention_flag ; YES - clear attention flag 378 bcf hi,int_attention_flag ; YES - clear attention flag
329 bra TFT_attention_color ; - set to attention color and return 379 bra TFT_attention_color ; - set to attention color and return
330 380
331 381
332 TFT_color_code_gf: 382 TFT_color_code_gf:
333 ; with int_O_gradient_factor, the upper byte is solely used for the flags 383 ; with int_O_lead_supersat, the upper byte is solely used for the flags
334 ; and not for the value, thus there is no need to clear the flags 384 ; and not for the value, thus there is no need to clear the flags
335 btfsc hi,int_invalid_flag ; is the invalid flag set? 385 btfsc hi,int_invalid_flag ; is the invalid flag set?
336 bra TFT_disabled_color ; YES - set to disabled color and return 386 bra TFT_disabled_color ; YES - set to disabled color and return
337 btfsc hi,int_warning_flag ; NO - is the warning flag set? 387 btfsc hi,int_warning_flag ; NO - is the warning flag set?
338 bra TFT_warnings_color ; YES - set to warning color and return 388 bra TFT_warning_color ; YES - set to warning color and return
339 btfsc hi,int_attention_flag ; NO - is the attention flag set? 389 btfsc hi,int_attention_flag ; NO - is the attention flag set?
340 bra TFT_attention_color ; YES - set to attention color and return 390 bra TFT_attention_color ; YES - set to attention color and return
341 bra TFT_memo_color ; NO - set to memo color and return 391 bra TFT_memo_color ; NO - set to memo color and return
342 392
343 393
346 bra TFT_color_code_ppo2_1 ; NO 396 bra TFT_color_code_ppo2_1 ; NO
347 bcf hi,int_warning_flag ; YES - clear warning flag 397 bcf hi,int_warning_flag ; YES - clear warning flag
348 bcf hi,int_attention_flag ; clear attention flag (it may be set) 398 bcf hi,int_attention_flag ; clear attention flag (it may be set)
349 bcf hi,int_high_flag ; clear high warning flag (it may be set) 399 bcf hi,int_high_flag ; clear high warning flag (it may be set)
350 bcf hi,int_low_flag ; clear low warning flag (it may be set) 400 bcf hi,int_low_flag ; clear low warning flag (it may be set)
351 bra TFT_warnings_color ; warn in warning color 401 bra TFT_warning_color ; warn in warning color
352 TFT_color_code_ppo2_1: 402 TFT_color_code_ppo2_1:
353 btfss hi,int_attention_flag ; is the attention flag set? 403 btfss hi,int_attention_flag ; is the attention flag set?
354 bra TFT_color_code_ppo2_2 ; NO 404 bra TFT_color_code_ppo2_2 ; NO
355 bcf hi,int_attention_flag ; YES - clear attention flag (it may be set) 405 bcf hi,int_attention_flag ; YES - clear attention flag (it may be set)
356 bcf hi,int_high_flag ; clear high warning flag (it may be set) 406 bcf hi,int_high_flag ; clear high warning flag (it may be set)
359 TFT_color_code_ppo2_2: 409 TFT_color_code_ppo2_2:
360 bcf hi,int_high_flag ; clear high warning flag (it may be set) 410 bcf hi,int_high_flag ; clear high warning flag (it may be set)
361 bcf hi,int_low_flag ; clear low warning flag (it may be set) 411 bcf hi,int_low_flag ; clear low warning flag (it may be set)
362 bra TFT_memo_color ; set to memo color and return 412 bra TFT_memo_color ; set to memo color and return
363 413
414 ;=============================================================================
415
416 IFDEF _ccr_pscr
364 417
365 TFT_color_code_ppo2_hud: ; color-code ppO2 values (ppO2 in --:lo [cbar]) by its value 418 TFT_color_code_ppo2_hud: ; color-code ppO2 values (ppO2 in --:lo [cbar]) by its value
366 movff char_O_deco_info,WREG ; get the deco info vector 419 movff char_O_deco_info,WREG ; get the deco info vector
367 btfss WREG,deco_flag ; are we in deco? 420 btfss WREG,deco_flag ; are we in deco?
368 bra TFT_color_code_ppo2_hud_a ; NO - load normal max value as threshold 421 bra TFT_color_code_ppo2_hud_a ; NO - load normal max value as threshold
369 movff char_I_ppO2_max_deco,WREG ; YES - load deco value as threshold 422 movff char_I_ppO2_max_deco,WREG ; YES - load deco value as threshold
370 bra TFT_color_code_ppo2_hud_b 423 bra TFT_color_code_ppo2_hud_b
371 TFT_color_code_ppo2_hud_a: 424 TFT_color_code_ppo2_hud_a:
372 movff char_I_ppO2_max,WREG ; ppO2 max while not in deco 425 movff char_I_ppO2_max_work,WREG ; ppO2 max while in working phase
373 TFT_color_code_ppo2_hud_b: 426 TFT_color_code_ppo2_hud_b:
374 cpfsgt lo ; lo > threshold? 427 cpfsgt lo ; lo > threshold?
375 bra TFT_color_code_ppo2_hud1 ; NO - continue with checking for ppO2 low 428 bra TFT_color_code_ppo2_hud1 ; NO - continue with checking for ppO2 low
376 bra TFT_warnings_color ; YES - set warning color and return 429 bra TFT_warning_color ; YES - set warning color and return
377 TFT_color_code_ppo2_hud1: 430 TFT_color_code_ppo2_hud1:
378 movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR 431 movff opt_dive_mode,WREG ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
379 decfsz WREG,F ; now: 0=CC, 1=Gauge, 2=Apnea, 3=PSCR 432 decfsz WREG,F ; now: 0=CC, 1=Gauge, 2=Apnea, 3=PSCR
380 bra TFT_color_code_ppo2_hud_nocc; not CCR... 433 bra TFT_color_code_ppo2_hud_nocc; not CCR...
381 btfsc FLAG_bailout_mode 434 btfsc bailout_mode
382 bra TFT_color_code_ppo2_hud_nocc; is bailout, hence not loop mode... 435 bra TFT_color_code_ppo2_hud_nocc; is bailout, hence not loop mode...
383 movff char_I_ppO2_min_loop,WREG ; ppO2 min loop mode color coding 436 movff char_I_ppO2_min_loop,WREG ; ppO2 min loop mode color coding
384 bra TFT_color_code_ppo2_hud_cont 437 bra TFT_color_code_ppo2_hud_cont
385 TFT_color_code_ppo2_hud_nocc: 438 TFT_color_code_ppo2_hud_nocc:
386 movff char_I_ppO2_min,WREG ; PPO2 min for all other modes 439 movff char_I_ppO2_min,WREG ; PPO2 min for all other modes
387 TFT_color_code_ppo2_hud_cont: 440 TFT_color_code_ppo2_hud_cont:
388 cpfslt lo ; lo < char_I_ppO2_min? 441 cpfslt lo ; lo < char_I_ppO2_min?
389 bra TFT_memo_color ; NO - set memo color and return... 442 bra TFT_memo_color ; NO - set memo color and return...
390 bra TFT_warnings_color ; Yes - set warning color and return 443 bra TFT_warning_color ; Yes - set warning color and return
391 444
445 ENDIF ; _ccr_pscr
446
447 ;=============================================================================
392 448
393 TFT_color_code_battery: ; color-code the battery display, with battery percent in lo 449 TFT_color_code_battery: ; color-code the battery display, with battery percent in lo
394 movlw color_code_battery_low ; get warning threshold 450 movlw color_code_battery_low ; get warning threshold
395 cpfsgt lo ; is battery percent < threshold? 451 cpfsgt lo ; is battery percent < threshold?
396 bra TFT_warnings_color ; YES - set to warning color and return 452 bra TFT_warning_color ; YES - set to warning color and return
397 bra TFT_memo_color ; NO - set to memo color and return 453 bra TFT_memo_color ; NO - set to memo color and return
398 454
399 455
400 global TFT_color_code_gas 456 global TFT_color_code_gas
401 TFT_color_code_gas: ; color-code the output according to gas number (1-6) in WREG 457 TFT_color_code_gas: ; color-code the output according to gas number (1-6) in WREG
483 return ; done 539 return ; done
484 540
485 541
486 global TFT_show_color_schemes 542 global TFT_show_color_schemes
487 TFT_show_color_schemes: ; update the color schemes 543 TFT_show_color_schemes: ; update the color schemes
488 bsf divemode ; put in divemode 544 bsf divemode ; switch to dive mode
489 call TFT_divemask_color 545 call TFT_divemask_color
490 WIN_TINY .12,.40 546 WIN_TINY .12,.40
491 STRCAT_TEXT_PRINT tDepth 547 STRCAT_TEXT_PRINT tDepth
492 WIN_TINY .62,.40 548 WIN_TINY .62,.40
493 STRCAT_TEXT_PRINT tMaxDepth 549 STRCAT_TEXT_PRINT tMaxDepth
497 ; Show some demo screen 553 ; Show some demo screen
498 554
499 ; Depth demo 555 ; Depth demo
500 call TFT_memo_color 556 call TFT_memo_color
501 WIN_MEDIUM .3,.54 557 WIN_MEDIUM .3,.54
502 movlw LOW .5172 558 MOVLI .5172,mpr
503 movwf lo
504 movlw HIGH .5172
505 movwf hi
506 bsf leftbind 559 bsf leftbind
507 bsf ignore_digit4 560 bsf ignore_digit4
508 output_16 ; full meters in big font 561 output_16 ; full meters in big font
509 bcf leftbind 562 bcf leftbind
510 STRCAT_PRINT "" ; display full meters 563 STRCAT_PRINT "" ; display full meters
511 WIN_SMALL .25,.66 564 WIN_SMALL .25,.66
512 movlw LOW .5172 565 MOVLI .5172,mpr
513 movwf lo
514 movlw HIGH .5172
515 movwf hi
516 PUTC "." 566 PUTC "."
517 movlw d'4' 567 movlw d'4'
518 movwf ignore_digits 568 movwf ignore_digits
519 bsf ignore_digit5 ; (flag will be cleared by output_16) 569 bsf ignore_digit5 ; (flag will be cleared by output_16)
520 output_16dp d'0' ; .1m in SMALL font 570 output_16dp d'0' ; .1m in SMALL font
521 STRCAT_PRINT "" ; display decimeters 571 STRCAT_PRINT "" ; display decimeters
522 WIN_FONT FT_SMALL
523 572
524 ; Max. Depth demo 573 ; Max. Depth demo
525 WIN_MEDIUM .64,.54 574 WIN_MEDIUM .64,.54
526 bsf ignore_digit4 ; no 0.1m 575 bsf ignore_digit4 ; no 0.1m
527 bsf leftbind 576 bsf leftbind
528 movlw LOW .6349 577 MOVLI .6349,mpr
529 movwf lo
530 movlw HIGH .6349
531 movwf hi
532 output_16 578 output_16
533 STRCAT_PRINT "" ; display full meters 579 STRCAT_PRINT "" ; display full meters
534 bcf leftbind 580 bcf leftbind
535 ; .1m in SMALL font 581 ; .1m in SMALL font
536 WIN_SMALL .87,.66 582 WIN_SMALL .87,.66
537 PUTC "." 583 PUTC "."
538 movlw d'4' 584 movlw d'4'
539 movwf ignore_digits 585 movwf ignore_digits
540 bsf ignore_digit5 ; (flag will be cleared by output_16) 586 bsf ignore_digit5 ; (flag will be cleared by output_16)
541 bsf leftbind 587 bsf leftbind
542 movlw LOW .6349 588 MOVLI .6349,mpr
543 movwf lo
544 movlw HIGH .6349
545 movwf hi
546 output_16dp d'0' 589 output_16dp d'0'
547 STRCAT_PRINT "" ; display decimeters 590 STRCAT_PRINT "" ; display decimeters
548 bcf leftbind 591 bcf leftbind
549 592
550 ; Divetime demo 593 ; Divetime demo
551 movff mins,lo 594 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
595 movff rtc_latched_mins,lo
552 clrf hi 596 clrf hi
553 WIN_MEDIUM .103, .54 597 WIN_MEDIUM .103, .54
554 output_16_3 ; limit to 999 and display only (0-999) 598 output_16_3 ; limit to 999 and display only (0-999)
555 STRCAT_PRINT "" ; show minutes in large font 599 STRCAT_PRINT "" ; show minutes in large font
556 WIN_SMALL .139, .66 ; left position for two sec figures 600 WIN_SMALL .139, .66 ; left position for two sec figures
557 PUTC ':' 601 PUTC ':'
558 bsf leftbind 602 bsf leftbind
559 movff secs,lo 603 movff rtc_latched_secs,lo
560 output_99x 604 output_99x
561 bcf leftbind 605 bcf leftbind
562 STRCAT_PRINT "" ; show seconds in small font 606 STRCAT_PRINT "" ; show seconds in small font
563 607
564 bcf divemode ; don't stay in divemode 608 bcf divemode ; terminate dive mode again
565 return 609 return
566 610
567 611
568 global TFT_divemode_mask 612 global TFT_show_divemode_mask
569 TFT_divemode_mask: ; displays mask in divemode 613 TFT_show_divemode_mask: ; display mask in dive mode
570 bcf FLAG_TFT_divemode_mask 614 call TFT_divemask_color ; set color
571 call TFT_divemask_color 615
572 WIN_TINY dm_mask_depth_column,dm_mask_depth_row 616 ; depth
573 STRCAT_TEXT_PRINT tDepth 617 WIN_TINY dm_mask_depth_column,dm_mask_depth_row ; position for "Depth"
574 WIN_TINY dm_mask_maxdepth_column_nvsi,dm_mask_maxdepth_row 618 btfss alt_layout_active ; alternative layout active?
619 bra TFT_divemode_mask_depth_text ; NO
620 WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; YES - alternative position for "Depth"
621 TFT_divemode_mask_depth_text:
622 STRCAT_TEXT_PRINT tDepth ; print "Depth"
623
624 ; avg or max depth
625 btfsc alt_layout_active ; alternative layout active?
626 bra TFT_divemode_mask_avg_max_alt ; YES
627
628 WIN_TINY dm_mask_maxdepth_col_nvsi,dm_mask_maxdepth_row ; default position for "max.Depth"/"avg.Depth"
629 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
630 bra TFT_divemode_mask_max_avg_pos ; NO - keep position
631 WIN_TINY dm_mask_maxdepth_col,dm_mask_maxdepth_row ; YES - adopt position
632 TFT_divemode_mask_max_avg_pos:
633 btfsc FLAG_apnoe_mode ; in apnea mode?
634 bra TFT_divemode_mask_max_text ; YES - always draw max depth
635 TSTOSS opt_2ndDepthDisp ; NO - shall draw avg depth instead of max depth?
636 bra TFT_divemode_mask_max_text ; NO - print "max.Depth"
637 STRCAT_TEXT_PRINT tAvgDepth ; YES - print "avg.Depth"
638 bra TFT_divemode_mask_time_pos ; - continue with dive time
639 TFT_divemode_mask_max_text:
640 STRCAT_TEXT_PRINT tMaxDepth ; print "max.Depth"
641 bra TFT_divemode_mask_time_pos ; continue with dive time
642 TFT_divemode_mask_avg_max_alt:
643 btfss FLAG_gauge_mode ; in gauge mode?
644 bra TFT_divemode_mask_time_pos ; NO - continue with dive time
645 WIN_TINY dm_gauge_max_depth_text_col,dm_gauge_max_depth_text_row ; YES - set position
646 STRCAT_TEXT_PRINT tMaxDepth ; - print "max.Depth"
647 WIN_TINY dm_gauge_avg_depth_text_col,dm_gauge_avg_depth_text_row ; - set position
648 STRCAT_TEXT_PRINT tDiveTotalAvg ; - print "Total Avg"
649 ;bra TFT_divemode_mask_time_pos ; - continue with dive time
650
651 ; dive time
652 TFT_divemode_mask_time_pos:
653 WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row ; position for "Divetime"
654 TFT_divemode_mask_time_text:
655 STRCAT_TEXT_PRINT tDivetime ; print "Divetime"
656 btfss FLAG_apnoe_mode ; in apnea mode?
657 bra TFT_standard_color ; NO - done
658 WIN_TINY dm_total_apnoe_text_col,dm_total_apnoe_text_row; YES - set position
659 STRCPY_TEXT_PRINT tApnoeTotal ; - print "Total"
660 bra TFT_standard_color ; - done
661
662 ;=========================================================================
663
664 global TFT_velocity_show
665 TFT_velocity_show:
666 rcall TFT_memo_color ; set default color
667 btfsc neg_flag_velocity ; descending?
668 rcall TFT_velocity_set_color ; NO - set color for text dependent on speed and set threshold for VSI graph
669 rcall TFT_velocity_num ; show the numerical VSI
575 TSTOSS opt_vsigraph ; graphical VSI bar enabled? 670 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
576 bra TFT_divemode_mask_1 ; NO 671 bra TFT_standard_color ; NO - done
577 WIN_TINY dm_mask_maxdepth_column,dm_mask_maxdepth_row ; YES - adopt position 672 btfsc neg_flag_velocity ; YES - in ascent?
578 TFT_divemode_mask_1: 673 bra TFT_velocity_graph_show ; YES - show the graph
579 btfsc FLAG_apnoe_mode ; in Apnea mode? 674 bra TFT_velocity_graph_clear_1 ; NO - clear the graph
580 bra TFT_divemode_mask_2 ; YES - draw max depth
581 TSTOSS opt_2ndDepthDisp ; draw avg depth?
582 bra TFT_divemode_mask_2 ; NO - draw max depth
583 STRCAT_TEXT_PRINT tAvgDepth ; YES
584 bra TFT_divemode_mask_3
585 TFT_divemode_mask_2:
586 STRCAT_TEXT_PRINT tMaxDepth
587 TFT_divemode_mask_3:
588 WIN_TINY dm_mask_divetime_column,dm_mask_divetime_row
589 STRCAT_TEXT_PRINT tDivetime
590 bra TFT_standard_color ; and return...
591
592 global TFT_divemode_mask_alternative
593 TFT_divemode_mask_alternative: ; alt. mask for divemode
594 bcf FLAG_TFT_divemode_mask_alt
595 call TFT_divemask_color
596 WIN_TINY dm_mask_depth_column,dm_mask_depth_row
597 STRCAT_TEXT_PRINT tDepth
598 WIN_TINY dm_mask_divetime_column-.30,dm_mask_divetime_row
599 STRCAT_TEXT_PRINT tDivetime
600 bra TFT_standard_color ; and return...
601
602 global TFT_draw_gassep_line
603 TFT_draw_gassep_line:
604 btfsc FLAG_apnoe_mode ; ignore in Apnoe mode
605 return
606 btfsc divemode_menu ; is the dive mode menu shown?
607 return ; YES - return
608 bra TFT_standard_color ; NO - set standard color and return
609
610 ;=========================================================================
611
612 global TFT_display_velocity
613 TFT_display_velocity: ; with divA+0 = m/min, neg_flag_velocity: ascend=1, descend=0
614 bcf STATUS,C
615 movlw velocity_display_threshold_1; lowest threshold for display vertical velocity
616 subwf divA+0,W
617 btfss STATUS,C
618 bra TFT_velocity_clear ; lower then threshold. Clear text and graph (If active)
619
620 ; We have something to display
621 bsf display_velocity ; set flag
622 ; check if descending: no warning color if descending
623 rcall TFT_memo_color
624 btfsc neg_flag_velocity ; ignore for descent
625 rcall TFT_velocity_set_color ; set color for text and set threshold for graph
626
627 rcall TFT_velocity_disp ; show the text
628
629 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
630 bra TFT_display_velocity_done ; NO
631
632 btfsc alternative_divelayout ; alternative layout?
633 bra TFT_display_velocity_done ; YES - no graph! (no room when divetime minutes is three digits)
634
635 btfsc neg_flag_velocity ; ignore for descent
636 rcall TFT_velocity_graph ; show the graph
637 btfss neg_flag_velocity ; ignore for descent
638 rcall TFT_velocity_clear_graph ; clear the graph for descent
639
640 TFT_display_velocity_done:
641 bra TFT_standard_color ; and return!
642 675
643 TFT_speed_table: 676 TFT_speed_table:
644 ; use a depth-dependent ascent rate warning 677 ; use a depth-dependent ascent rate warning
645 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164 678 ; depth(ft): <20 >20 >40 >60 >75 >88 >101 >115 >128 >144 >164
646 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66 679 ; speed(ft/min): 23 26 29 33 36 43 49 56 59 62 66
647 ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50 680 ; depth(m): <=6 >6 >12 >18 >23 >27 >31 >35 >39 >44 >50
648 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning) 681 ; speed(m/min): 7 8 9 10 11 13 15 17 18 19 20 (warning)
649 ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention) 682 ; speed(m/min): 5 6 7 8 8 10 12 13 14 15 15 (attention)
650 683
651 ; <xx m, warning speed, attention speed, unused 684 ; < depth (m), warning speed, attention speed, unused
652 DB .6,.7,.5,.0 685 DB .6,.7,.5,.0
653 DB .12,.8,.6,.0 686 DB .12,.8,.6,.0
654 DB .18,.9,.7,.0 687 DB .18,.9,.7,.0
655 DB .23,.10,.8,.0 688 DB .23,.10,.8,.0
656 DB .27,.11,.8,.0 689 DB .27,.11,.8,.0
659 DB .39,.17,.13,.0 692 DB .39,.17,.13,.0
660 DB .44,.18,.14,.0 693 DB .44,.18,.14,.0
661 DB .50,.19,.15,.0 694 DB .50,.19,.15,.0
662 DB .200,.20,.15,.0 695 DB .200,.20,.15,.0
663 696
664 TFT_velocity_set_color: ; Set color based on speed table or use static thresholds, with divA+0 = m/min 697 TFT_velocity_set_color: ; set color based on speed table or use static thresholds, with divA+0 = m/min
698 bsf aux_flag ; for alternative layout: default is to show numerical VSI
665 ; check if old/new ascend logic is used 699 ; check if old/new ascend logic is used
666 TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic 700 TSTOSS opt_vsitextv2 ; 0=standard, 1=dynamic
667 bra TFT_velocity_set_color_static ; static ascend rate limit 701 bra TFT_velocity_set_color_static ; static ascend rate limit
668 702
669 ; point to speed table 703 ; point to speed table
672 movlw HIGH (TFT_speed_table-.3) 706 movlw HIGH (TFT_speed_table-.3)
673 movwf TBLPTRH 707 movwf TBLPTRH
674 movlw UPPER (TFT_speed_table-.3) 708 movlw UPPER (TFT_speed_table-.3)
675 movwf TBLPTRU 709 movwf TBLPTRU
676 710
677 TFT_velocity_set_color_skip: 711 TFT_velocity_set_color_next:
678 TBLRD*+ ; 3 dummy reads 712 TBLRD*+ ; 3 dummy reads
679 TBLRD*+ 713 TBLRD*+
680 TBLRD*+ 714 TBLRD*+
681 TBLRD*+ ; get speed threshold 715 TBLRD*+ ; get speed threshold
682 movf curr_depth,W ; current depth in m 716 movf depth_meter,W ; current depth in m
683 cpfsgt TABLAT ; threshold > current depth ? 717 cpfsgt TABLAT ; threshold > current depth ?
684 bra TFT_velocity_set_color_skip ; NO - loop 718 bra TFT_velocity_set_color_next ; NO - try next
685 719
686 TBLRD*+ ; get warning speed threshold 720 TBLRD*+ ; get warning speed threshold
687 movf TABLAT,W 721 movf TABLAT,W ; ...
688 movwf divA+1 ; copy for graph routine 722 movwf divA+1 ; copy for graph routine
689 cpfslt divA+0 ; smaller then actual value (in m/min)? 723 cpfslt divA+0 ; actual vertical speed smaller than warning threshold?
690 bra TFT_warnings_color ; set Warning color (And return) 724 bra TFT_warning_color ; NO - set warning color (and return)
691 TBLRD*+ ; get attention speed threshold 725 TBLRD*+ ; get attention speed threshold
692 movf TABLAT,W 726 movf TABLAT,W ; ...
693 cpfslt divA+0 ; smaller then actual value (in m/min)? 727 cpfslt divA+0 ; actual vertical speed smaller than attention threshold?
694 bra TFT_attention_color ; NO - set attention color and return 728 bra TFT_attention_color ; NO - set attention color and return
695 bra TFT_memo_color ; YES - set memo color and return 729 bcf aux_flag ; YES - don't show in alternative layout
730 bra TFT_memo_color ; - set memo color and return
696 731
697 TFT_velocity_set_color_static: 732 TFT_velocity_set_color_static:
698 movlw color_code_velocity_warn_high ; in m/min 733 movlw color_code_velocity_warn_high ; threshold for warning in m/min
699 movwf divA+1 ; copy for graph routine 734 movwf divA+1 ; copy for graph routine
700 cpfslt divA+0 ; smaller then actual value (in m/min)? 735 cpfslt divA+0 ; actual vertical speed smaller than warning threshold?
701 bra TFT_warnings_color ; set Warning color (And return) 736 bra TFT_warning_color ; NO - set warning color (and return)
702 movlw color_code_velocity_attn_high ; in m/min 737 movlw color_code_velocity_attn_high ; threshold for attention in m/min
703 cpfslt divA+0 ; smaller then actual value (in m/min)? 738 cpfslt divA+0 ; actual vertical speed smaller than attention threshold?
704 bra TFT_attention_color ; NO - set attention color and return 739 bra TFT_attention_color ; NO - set attention color and return
705 bra TFT_memo_color ; YES - set memo color and return 740 bcf aux_flag ; YES - don't show in alternative layout
706 741 bra TFT_memo_color ; - set memo color and return
707 TFT_velocity_disp: 742
708 WIN_SMALL dm_velocity_text_column, dm_velocity_text_row 743 TFT_velocity_num:
709 TSTOSS opt_units ; 0=Meters, 1=Feets 744 btfsc alt_layout_active ; in alternative layout?
710 bra TFT_velocity_metric 745 bra TFT_velocity_num_alt ; YES
711 ;TFT_velocity_imperial: 746 ; NO - set position
747 WIN_SMALL dm_velocity_text_col_norm, dm_velocity_text_row_norm
748 TFT_velocity_num_com:
749 bsf velocity_active_num ; set numerical velocity as shown
750 TSTOSS opt_units ; - 0=meter, 1=feet
751 bra TFT_velocity_num_metric ; 0 - meter
752 ;bra TFT_velocity_num_imperial ; 1 - feet
753
754 TFT_velocity_num_imperial:
712 movff divA+0,WREG ; divA+0 = m/min 755 movff divA+0,WREG ; divA+0 = m/min
713 mullw .100 ; PRODL:PRODH = mbar/min 756 mullw .100 ; PROD = mbar/min
714 movff PRODL,lo 757 MOVII PRODL,mpr ; copy to hi:lo
715 movff PRODH,hi
716 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 758 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
717 movlw '-' 759 tstfsz hi ; > 255 ?
718 btfsc neg_flag_velocity 760 setf lo ; YES - set lo to 255
719 movlw '+' 761 movlw '-' ; load coding for minus sign
720 movwf POSTINC2 762 btfsc neg_flag_velocity ; ascending?
721 bsf leftbind 763 movlw '+' ; YES - replace with coding for plus sign
722 output_16 764 movwf POSTINC2 ; put sign into output buffer
723 bcf leftbind 765 output_99 ; print rate
724 STRCAT_TEXT_PRINT tVelImperial ; unit switch 766 STRCAT_TEXT tVelImperial ; print unit
725 return 767 bra TFT_velocity_num_finish ; do finishing tasks
726 768
727 TFT_velocity_metric: 769 TFT_velocity_num_metric:
728 movff divA+0,lo ; divA+0 = m/min 770 movff divA+0,lo ; divA+0 = m/min
729 movlw '-' 771 movlw '-' ; load coding for minus sign
730 btfsc neg_flag_velocity 772 btfsc neg_flag_velocity ; ascending?
731 movlw '+' 773 movlw '+' ; YES - replace with coding for plus sign
732 movwf POSTINC2 774 movwf POSTINC2 ; put sign into output buffer
733 output_99 775 output_99 ; print rate
734 STRCAT_TEXT_PRINT tVelMetric ; unit switch 776 STRCAT_TEXT tVelMetric ; print unit
735 return 777 ;bra TFT_velocity_num_finish ; do finishing tasks
736 778
737 TFT_velocity_graph: ; divA+0 = m/min 779 TFT_velocity_num_finish:
738 ; divA+0 holding the ascend speed in m/min 780 btfss alt_layout_active ; in alternative layout?
739 movff divA+0,hi ; copy 781 bra TFT_velocity_num_finish_1 ; NO
740 WIN_BOX_BLACK dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right -> outer frame 782 movlw "'" ; load encoding of minute sign
741 rcall TFT_divemask_color_dive ; color -> WREG 783 movff WREG,buffer+4 ; put it after m (meter) / f (feet)
742 WIN_FRAME_COLOR dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;inner frame 784 clrf WREG ; load string terminator
743 rcall TFT_divemask_color_dive ; color -> WREG 785 movff WREG,buffer+5 ; terminate string after minute sign
744 WIN_FRAME_COLOR dm_velobar_top+.10, dm_velobar_bot-.10, dm_velobar_lft, dm_velobar_rgt ;inner frame 786 TFT_velocity_num_finish_1:
745 rcall TFT_divemask_color_dive ; color -> WREG 787 STRCAT_PRINT "" ; finalize output
746 WIN_FRAME_COLOR dm_velobar_top+.20, dm_velobar_bot-.20, dm_velobar_lft, dm_velobar_rgt ;inner frame 788 bcf win_invert ; end inverse printing
747 rcall TFT_divemask_color_dive ; color -> WREG 789 return ; done
748 WIN_FRAME_COLOR dm_velobar_top+.30, dm_velobar_bot-.30, dm_velobar_lft, dm_velobar_rgt ;inner frame 790
749 791 TFT_velocity_num_alt:
792 btfsc dive_main_menu ; is the dive mode menu shown?
793 return ; YES - abort
794 btfss neg_flag_velocity ; NO - in ascent?
795 bcf aux_flag ; NO - clear aux flag
796 btfsc aux_flag ; - above attention or warning threshold?
797 bsf win_invert ; YES - print inverse
798 ; - set position
799 WIN_SMALL dm_velocity_text_col_alt, dm_velocity_text_row_alt
800 bra TFT_velocity_num_com ; - continue with common part
801
802
803 TFT_velocity_graph_show: ; with speed in divA+0 (m/min)
804 btfsc alt_layout_active ; in alternative layout?
805 bra TFT_standard_color ; YES - done (not implemented)
806
807 btfsc velocity_active_vsi ; was the graphical VSI shown before?
808 bra TFT_velocity_graph_1 ; YES - no need to redraw the framework box
809 bsf velocity_active_vsi ; NO - remember it is shown as of now
810 ; - draw the framework box
811 rcall TFT_divemask_color_dive ; - color -> WREG
812 WIN_FRAME_COLOR dm_velocity_graph_top+.00, dm_velocity_graph_bot-.00, dm_velocity_graph_lft, dm_velocity_graph_rgt
813 rcall TFT_divemask_color_dive ; - color -> WREG
814 WIN_FRAME_COLOR dm_velocity_graph_top+.10, dm_velocity_graph_bot-.10, dm_velocity_graph_lft, dm_velocity_graph_rgt
815 rcall TFT_divemask_color_dive ; - color -> WREG
816 WIN_FRAME_COLOR dm_velocity_graph_top+.20, dm_velocity_graph_bot-.20, dm_velocity_graph_lft, dm_velocity_graph_rgt
817 rcall TFT_divemask_color_dive ; - color -> WREG
818 WIN_FRAME_COLOR dm_velocity_graph_top+.30, dm_velocity_graph_bot-.30, dm_velocity_graph_lft, dm_velocity_graph_rgt
819
820 TFT_velocity_graph_1:
821 movff divA+0,hi ; copy ascend speed (in m/min) to hi
750 movff divA+1,xA+0 ; m/min for warning level (upper two blocks) 822 movff divA+1,xA+0 ; m/min for warning level (upper two blocks)
751 clrf xA+1 823 clrf xA+1
752 movlw .5 824 MOVLI .5,xB ; threshold for color warning (5 color normal + 2 color warning)
753 movwf xB+0 ; threshold for color warning (5 color normal + 2 color warning)
754 clrf xB+1
755 call div16x16 ; xC = xA / xB with xA as remainder 825 call div16x16 ; xC = xA / xB with xA as remainder
756 ; xC+0 holds step size in m/min (e.g. =3 for 15m/min warning threshold) 826 ; xC+0 holds step size in m/min (e.g. =3 for 15m/min warning threshold)
757 movff hi,xA+0 ; velocity in m/min 827 movff hi,xA+0 ; velocity in m/min
758 clrf xA+1 828 clrf xA+1
759 movff xC+0,xB+0 ; step size 829 movff xC+0,xB+0 ; step size
760 clrf xB+1 830 clrf xB+1
761 call div16x16 ; xC = xA / xB with xA as remainder 831 call div16x16 ; xC = xA / xB with xA as remainder
762 ; xC+0 now holds amount of segments to show 832
763 movff hi,divA+0 ; copy back for numeric output 833 movff xC+0,lo ; copy amount of segments to show to lo
764 movlw d'7' 834 incf lo,F
765 cpfslt xC+0 835 dcfsnz lo,F
766 bra DISP_graph_vel_7 836 bra DISP_graph_vel_0_fill
767 movlw d'6' 837 dcfsnz lo,F
768 cpfslt xC+0 838 bra DISP_graph_vel_1_fill
769 bra DISP_graph_vel_6 839 dcfsnz lo,F
770 movlw d'5' 840 bra DISP_graph_vel_2_fill
771 cpfslt xC+0 841 dcfsnz lo,F
772 bra DISP_graph_vel_5 842 bra DISP_graph_vel_3_fill
773 movlw d'4' 843 dcfsnz lo,F
774 cpfslt xC+0 844 bra DISP_graph_vel_4_fill
775 bra DISP_graph_vel_4 845 dcfsnz lo,F
776 movlw d'3' 846 bra DISP_graph_vel_5_fill
777 cpfslt xC+0 847 dcfsnz lo,F
778 bra DISP_graph_vel_3 848 bra DISP_graph_vel_6_fill
779 movlw d'2' 849 ;bra DISP_graph_vel_7_fill
780 cpfslt xC+0 850
781 bra DISP_graph_vel_2 851 DISP_graph_vel_7_fill:
782 movlw d'1'
783 cpfslt xC+0
784 bra DISP_graph_vel_1
785 bra DISP_graph_vel_0 ; should not happen...
786
787 DISP_graph_vel_7:
788 rcall TFT_warnings_color_dive ; color -> WREG 852 rcall TFT_warnings_color_dive ; color -> WREG
789 WIN_BOX_COLOR dm_velobar_top+.2, dm_velobar_top+.8, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 853 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
790 DISP_graph_vel_6: 854 DISP_graph_vel_6_fill:
791 rcall TFT_warnings_color_dive ; color -> WREG 855 rcall TFT_warnings_color_dive ; color -> WREG
792 WIN_BOX_COLOR dm_velobar_top+.12, dm_velobar_top+.18, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 856 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
793 DISP_graph_vel_5: 857 DISP_graph_vel_5_fill:
794 rcall TFT_attention_color_dive ; color -> WREG 858 rcall TFT_attention_color_dive ; color -> WREG
795 WIN_BOX_COLOR dm_velobar_top+.22, dm_velobar_top+.28, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 859 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
796 DISP_graph_vel_4: 860 DISP_graph_vel_4_fill:
797 rcall TFT_standard_color_dive ; color -> WREG 861 rcall TFT_standard_color_dive ; color -> WREG
798 WIN_BOX_COLOR dm_velobar_top+.32, dm_velobar_top+.38, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 862 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
799 DISP_graph_vel_3: 863 DISP_graph_vel_3_fill:
800 rcall TFT_standard_color_dive ; color -> WREG 864 rcall TFT_standard_color_dive ; color -> WREG
801 WIN_BOX_COLOR dm_velobar_top+.42, dm_velobar_top+.48, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 865 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
802 DISP_graph_vel_2: 866 DISP_graph_vel_2_fill:
803 rcall TFT_standard_color_dive ; color -> WREG 867 rcall TFT_standard_color_dive ; color -> WREG
804 WIN_BOX_COLOR dm_velobar_top+.52, dm_velobar_top+.58, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 868 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
805 DISP_graph_vel_1: 869 DISP_graph_vel_1_fill:
806 rcall TFT_standard_color_dive ; color -> WREG 870 rcall TFT_standard_color_dive ; color -> WREG
807 WIN_BOX_COLOR dm_velobar_top+.62, dm_velobar_top+.68, dm_velobar_lft+.2, dm_velobar_rgt-.2 ;top, bottom, left, right 871 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
808 DISP_graph_vel_0: 872 DISP_graph_vel_0_fill:
809 return ; done 873
874 movff xC+0,lo ; copy amount of segments to show to lo
875 incf lo,F
876 dcfsnz lo,F
877 bra DISP_graph_vel_0_clear
878 dcfsnz lo,F
879 bra DISP_graph_vel_1_clear
880 dcfsnz lo,F
881 bra DISP_graph_vel_2_clear
882 dcfsnz lo,F
883 bra DISP_graph_vel_3_clear
884 dcfsnz lo,F
885 bra DISP_graph_vel_4_clear
886 dcfsnz lo,F
887 bra DISP_graph_vel_5_clear
888 dcfsnz lo,F
889 bra DISP_graph_vel_6_clear
890 bra DISP_graph_vel_7_clear
891
892 DISP_graph_vel_0_clear:
893 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
894 DISP_graph_vel_1_clear:
895 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
896 DISP_graph_vel_2_clear:
897 WIN_BOX_BLACK dm_velocity_graph_top+.42, dm_velocity_graph_top+.48, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right
898 DISP_graph_vel_3_clear:
899 WIN_BOX_BLACK dm_velocity_graph_top+.32, dm_velocity_graph_top+.38, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right
900 DISP_graph_vel_4_clear:
901 WIN_BOX_BLACK dm_velocity_graph_top+.22, dm_velocity_graph_top+.28, dm_velocity_graph_lft+.2, dm_velocity_graph_rgt-.2 ;top, bottom, left, right
902 DISP_graph_vel_5_clear:
903 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
904 DISP_graph_vel_6_clear:
905 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
906 DISP_graph_vel_7_clear:
907 bra TFT_standard_color ; done
810 908
811 909
812 global TFT_velocity_clear 910 global TFT_velocity_clear
813 TFT_velocity_clear: 911 TFT_velocity_clear:
814 btfss display_velocity ; velocity was not displayed, do not delete 912 btfss velocity_active_num ; was the numerical VSI shown in last cycle?
815 return 913 bra TFT_velocity_clear_graph ; NO - no need to clear it, continue with graphical VSI
816 bcf display_velocity ; velocity was displayed, delete velocity now 914 TFT_velocity_clear_num_1:
817 ; Clear Text 915 bcf velocity_active_num ; YES - clear flag
818 WIN_BOX_BLACK dm_velocity_text_row, dm_velocity_text_bot, dm_velocity_text_column, dm_velocity_text_rgt ; top, bottom, left, right 916 btfsc alt_layout_active ; - in alternative layout?
819 917 bra TFT_velocity_clear_num_alt ; YES
820 TSTOSS opt_vsigraph ; graphical VSI bar enabled? 918 ;bra TFT_velocity_clear_num_norm ; NO
821 return ; NO - no graph to clear 919
920 TFT_velocity_clear_num_norm: ; clear normal numerical area
921 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
922 bra TFT_velocity_clear_graph ; continue with graphical VSI
923
924 TFT_velocity_clear_num_alt: ; clear alternative numerical area
925 btfsc dive_main_menu ; is the dive mode menu shown?
926 bra TFT_velocity_clear_graph ; YES - skip
927 ; NO - clear area
928 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
929 ;bra TFT_velocity_clear_graph ; continue with graphical VSI
930
822 TFT_velocity_clear_graph: 931 TFT_velocity_clear_graph:
823 ; Clear Graph 932 btfss velocity_active_vsi ; was the graphical VSI shown in last cycle?
824 WIN_BOX_BLACK dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ; top, bottom, left, right 933 bra TFT_standard_color ; NO - no need to clear it, done
825 return 934 TFT_velocity_graph_clear_1:
935 bcf velocity_active_vsi ; YES - clear flag
936 btfsc alt_layout_active ; - in alternative layout?
937 bra TFT_standard_color ; YES - not implemented
938 ;bra TFT_velocity_clear_graph_alt ; YES - code provision for future implementation
939 ;bra TFT_velocity_clear_graph_norm ; NO
940
941 TFT_velocity_clear_graph_norm ; clear normal graph area
942 WIN_BOX_BLACK dm_velocity_graph_top, dm_velocity_graph_bot, dm_velocity_graph_lft, dm_velocity_graph_rgt ; top, bottom, left, right
943 bra TFT_standard_color ; done
826 944
827 ;========================================================================= 945 ;=========================================================================
828
829 global TFT_clear_decoarea
830 TFT_clear_decoarea:
831 WIN_BOX_BLACK dm_decostop_1st_stop_row, .239, dm_decostop_1st_stop_column, .159 ; top, bottom, left, right
832 return
833
834 946
835 global TFT_clear_divemode_menu 947 global TFT_clear_divemode_menu
836 TFT_clear_divemode_menu: 948 TFT_clear_divemode_menu:
837 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 949 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
838 return 950 return
839 951
840 952
841 global TFT_display_ndl_mask 953 global TFT_clear_deco_data
842 TFT_display_ndl_mask: 954 TFT_clear_deco_data:
843 bcf FLAG_TFT_display_ndl_mask 955 btfsc dive_main_menu ; is the dive mode menu shown?
844 btfsc divemode_menu ; is the dive mode menu shown? 956 return ; YES - abort
845 return ; YES - return 957 ; NO - clear deco data area (alternative stop depth makes upper-left most corner)
846 btfsc FLAG_gauge_mode ; in gauge mode? 958 WIN_BOX_BLACK dm_decostop_row_alt_depth, dm_3rdrow_bot, dm_decostop_col_alt_depth, dm_3rdrow_rgt ; top, bottom, left, right
847 return ; YES - return 959 return ; - done
848 call TFT_clear_decoarea ; NO - clear stop depth and TTS 960
849 call TFT_divemask_color 961
962 global TFT_show_ndl_mask
963 TFT_show_ndl_mask:
964 btfsc dive_main_menu ; is the dive mode menu shown?
965 return ; YES - abort
966 call TFT_divemask_color ; NO - set text color
967 ; - set position
850 WIN_STD dm_ndl_text_column, dm_ndl_text_row 968 WIN_STD dm_ndl_text_column, dm_ndl_text_row
851 STRCPY_TEXT_PRINT tNDL ; NDL 969 STRCPY_TEXT_PRINT tNDL ; - print "NDL"
852 bra TFT_standard_color ; and return... 970 bra TFT_standard_color ; - done
853 971
854 972
855 global TFT_display_tts 973 global TFT_show_tts
856 TFT_display_tts: 974 TFT_show_tts:
857 bcf FLAG_TFT_display_tts 975 btfsc dive_main_menu ; is the dive mode menu shown?
858 btfsc divemode_menu ; is the dive mode menu shown? 976 return ; YES - abort
859 return ; YES - return 977 call TFT_memo_color ; NO - default to memo color
860 call TFT_memo_color ; NO - set memo color 978 MOVII int_O_TTS_norm,mpr ; - get the TTS
861 movff int_O_ascenttime+0,lo ; - TTS 979 btfsc hi,int_invalid_flag ; - is the invalid flag set?
862 movff int_O_ascenttime+1,hi ; - on 16 bits 980 call TFT_disabled_color ; YES - use disabled color
863 btfss hi,int_invalid_flag ; - is the invalid flag set? 981 bcf hi,int_invalid_flag ; - eventually clear the invalid flag
864 bra TFT_display_tts_1 ; - NO 982 btfss alt_layout_active ; - in alternative layout?
865 bcf hi,int_invalid_flag ; - YES - clear flag 983 bra TFT_display_tts_999x ; NO
866 call TFT_disabled_color ; - switch to disabled color 984 MOVII mpr, sub_a ; YES - copy TTS to sub_a
867 TFT_display_tts_1: 985 MOVLI .100,sub_b ; - load 100 into sub_b
868 WIN_MEDIUM dm_tts_value_column, dm_tts_value_row 986 call cmpU16 ; - sub_a - sub_b = TTS - 100
869 output_16_3 ; display only 0...999 987 btfss neg_flag ; - TTS >= 100 ?
870 STRCAT_PRINT "'" 988 bra TFT_display_tts_999 ; YES
871 return 989 ;bra TFT_display_tts_99 ; NO
872 990
873 991 TFT_display_tts_99:
874 global TFT_display_ndl 992 btfsc tts_greater_99 ; was TTS > 99 mins last time?
875 TFT_display_ndl: 993 rcall TFT_display_tts_clear ; YES - clear remains from TTS > 99
876 bcf FLAG_TFT_display_ndl 994 ; set output position
877 btfsc divemode_menu ; is the dive mode menu shown? 995 WIN_MEDIUM dm_tts_value_col_99, dm_tts_value_row
878 return ; YES - return 996 output_99 ; display 0...99
879 WIN_MEDIUM dm_ndl_value_column, dm_ndl_value_row 997 STRCAT_PRINT "'" ; print "'"
880 call TFT_memo_color 998 bcf tts_greater_99 ; last TTS shown was <= 99 mins
881 movff char_O_nullzeit,lo ; get NDL from C-code 999 bra TFT_standard_color ; done
882 output_8 1000
883 STRCAT_PRINT "'" 1001 TFT_display_tts_999: ; set position
884 return 1002 WIN_MEDIUM dm_tts_value_col_999, dm_tts_value_row
885 1003 output_16_3 ; display 0...999
886 1004 STRCAT_PRINT "" ; finalize output (no "'" here - not enough space available)
887 global TFT_big_deco_alt ; the big deco 1005 bsf tts_greater_99 ; last TTS shown was > 99 mins
888 TFT_big_deco_alt: 1006 bra TFT_standard_color ; done
889 bcf FLAG_TFT_big_deco_alt 1007
890 1008 TFT_display_tts_999x: ; set position
891 btfss decostop_active ; deco stop shown? 1009 WIN_MEDIUM dm_tts_value_col_999x, dm_tts_value_row
892 bra TFT_big_deco_ndl_alt ; NO - show NDL 1010 output_16_3 ; display 0...999
893 1011 STRCAT_PRINT "'" ; print "'"
894 ; Deco 1012 bra TFT_standard_color ; done
895 bcf FLAG_TFT_display_deko 1013
896 call TFT_divemask_color 1014 TFT_display_tts_clear: ; clear remains from TTS > 99
897 WIN_STD .70,.165 1015 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
898 STRCPY_TEXT_PRINT tTTS ; TTS 1016 call TFT_memo_color ; restore default memo color
899 rcall TFT_memo_color 1017 movff int_O_TTS_norm+1,WREG ; get the high byte of the TTS
900 1018 btfsc WREG,int_invalid_flag ; is the invalid flag set?
901 ; TTS 1019 call TFT_disabled_color ; YES - restore disabled color
902 WIN_LARGE .97,.170 1020 return ; done
903 movff int_O_ascenttime+0,lo ; get the TTS 1021
904 movff int_O_ascenttime+1,hi ; 1022
905 btfss hi,int_invalid_flag ; is the invalid flag set? 1023 global TFT_show_ndl
906 bra TFT_display_tts_alt_1 ; NO 1024 TFT_show_ndl:
907 bcf hi,int_invalid_flag ; YES - clear flag 1025 btfsc dive_main_menu ; is the dive mode menu shown?
908 call TFT_disabled_color ; - switch to disabled color 1026 return ; YES - abort
909 TFT_display_tts_alt_1: 1027 movff char_O_NDL_norm,lo ; NO - get NDL time in normal plan
910 output_16_3 ; display only 0...999 1028 btfsc alt_layout_active ; - alternative layout active?
911 STRCAT_PRINT "" 1029 bra TFT_show_ndl_alt ; YES - use alternative layout
912 1030 ;bra TFT_show_ndl_norm ; NO - use normal layout
913 ; 1st Stop 1031
914 call TFT_divemask_color 1032 TFT_show_ndl_norm: ; set position
915 WIN_STD .25,dm_customview_row 1033 WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm
916 STRCPY_TEXT_PRINT tDiveSafetyStop ; "Stop" 1034 call TFT_memo_color ; set color
917 1035 output_8 ; display 0...240
918 WIN_LARGE .60,.95 1036 STRCAT_PRINT "'" ; print minutes symbol
919 call TFT_color_code_stop ; color-code output 1037 bra TFT_standard_color ; done
920 movff char_O_first_deco_depth,lo ; stop depth in m 1038
921 rcall TFT_display_deko_output_depth ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft) 1039 TFT_show_ndl_alt:
922 STRCAT_PRINT "" 1040 btfsc safety_stop_active ; is the safety stop active?
923 1041 bra TFT_show_ndl_alt_safety ; YES
924 ; m or ft after the stop depth 1042 ; clear potential remains from NDL normal and set position
925 WIN_MEDIUM .100,.118 1043 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
926 TSTOSS opt_units ; 0=m, 1=ft 1044 WIN_LARGE dm_ndl_value_col_alt, dm_ndl_value_row_alt
927 bra TFT_display_tts_alt_1_metric 1045 call TFT_memo_color ; set color
928 STRCAT_TEXT_PRINT tFeets1 1046 output_99 ; display 0...99
929 bra TFT_display_tts_alt_1_com 1047 STRCAT_PRINT "" ; finalize output
930 TFT_display_tts_alt_1_metric: 1048 bra TFT_standard_color ; done
931 STRCAT_TEXT_PRINT tMeters 1049
932 TFT_display_tts_alt_1_com: 1050 TFT_show_ndl_alt_safety:
933 WIN_LARGE .117,.95 1051 WIN_MEDIUM dm_ndl_value_col_norm,dm_ndl_value_row_norm
934 movff char_O_first_deco_time,lo ; get stop time in minutes 1052 call TFT_memo_color ; set color
1053 PUTC " " ; fill first digit position
1054 output_99 ; display 0...99
1055 STRCAT_PRINT "'" ; print minutes symbol
1056 goto TFT_standard_color ; done
1057
1058
1059 global TFT_divemode_sign_show
1060 TFT_divemode_sign_show:
1061 btfsc alt_layout_active ; alternative layout active?
1062 bra TFT_divemode_sign_show_alt ; YES
1063 ;bra TFT_divemode_sign_show_norm ; NO
1064
1065 TFT_divemode_sign_show_norm:
1066 WIN_TOP dm_sign_row_norm ; set row position
1067 WIN_LEFT dm_sign_col_norm ; set column position
1068 bra TFT_divemode_sign_show_com ; continue with common part
1069
1070 TFT_divemode_sign_show_alt:
1071 btfsc dive_main_menu ; is the dive mode menu shown?
1072 return ; YES - abort
1073 btfsc sign_shown ; NO - sign already shown?
1074 bra TFT_divemode_sign_show_alt_1; YES - no need to clear area again
1075 btfsc bailout_mode ; NO - in bailout?
1076 bra TFT_divemode_sign_show_alt_1; YES - no need to clear the area
1077 ; NO - eventually clear area from "bar" label and loop mode
1078 WIN_BOX_BLACK dm_active_dil_row, dm_3rdrow_bot, dm_active_sp_label_col, dm_sign_rgt_alt ; top, bottom, left, right
1079 TFT_divemode_sign_show_alt_1:
1080 WIN_TOP dm_sign_row_alt ; - set row position
1081 WIN_LEFT dm_sign_col_alt ; - set column position
1082 ;bra TFT_divemode_sign_show_com ; - continue with common part
1083
1084 TFT_divemode_sign_show_com:
1085 bsf sign_shown ; flag that the advice/attention/warning sign is shown
1086 btfsc message_warning ; do we have a warning?
1087 bra TFT_divemode_sign_show_warn ; YES - show warning sign
1088 btfsc message_attention ; NO - do we have an attention?
1089 bra TFT_divemode_sign_show_att ; YES - show attention sign
1090 btfsc message_advice ; NO - do we have an advice message?
1091 bra TFT_divemode_sign_show_adv ; YES - show advice sign
1092 return ; NO - false alarm
1093
1094
1095 TFT_divemode_sign_color_warn: ; custom colors table for dive_warning2 icon - warning
1096 db .4, 0 ; #colors, spare
1097 dw 0x0000 ; color 0x00: outside black
1098 dw 0xff80 ; color 0x01: triangle yellow
1099 dw 0xff80 ; color 0x02: exclamation mark yellow
1100 dw 0xf800 ; color 0x03: inside red
1101
1102 TFT_divemode_sign_color_adv: ; custom colors table for dive_warning2 icon - advice
1103 db .4, 0 ; #colors, spare
1104 dw 0x0000 ; color 0x00: outside black
1105 dw 0xffff ; color 0x01: triangle white
1106 dw 0xffff ; color 0x02: exclamation mark white
1107 dw 0x0780 ; color 0x03: inside green
1108
1109 TFT_divemode_sign_show_warn:
1110 TFT_WRITE_PROM_IMAGE_CUST_COLOR TFT_divemode_sign_color_warn; set custom colors for warning
1111 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign
1112 return ; done
1113
1114 TFT_divemode_sign_show_att:
1115 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign (with default colors)
1116 return ; done
1117
1118 TFT_divemode_sign_show_adv:
1119 TFT_WRITE_PROM_IMAGE_CUST_COLOR TFT_divemode_sign_color_adv ; set custom colors for advice
1120 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show sign
1121 return ; done
1122
1123
1124 global TFT_divemode_sign_clear
1125 TFT_divemode_sign_clear:
1126 btfss sign_shown ; is the advice/attention/warning sign shown?
1127 return ; NO - done
1128 bcf sign_shown ; YES - clear advice/attention/warning sign area and its flag
1129 btfsc alt_layout_active ; - alternative layout active?
1130 bra TFT_divemode_sign_clear_alt ; - YES
1131 ;bra TFT_divemode_sign_clear_norm; - NO
1132
1133 TFT_divemode_sign_clear_norm:
1134 WIN_BOX_BLACK dm_sign_row_norm, dm_sign_bot_norm, dm_sign_col_norm, dm_sign_rgt_norm ; top, bottom, left, right
1135 return ; done
1136
1137 TFT_divemode_sign_clear_alt:
1138 WIN_BOX_BLACK dm_sign_row_alt, dm_sign_bot_alt, dm_sign_col_alt, dm_sign_rgt_alt ; top, bottom, left, right
1139 return ; done
1140
1141
1142 global TFT_show_deco_mask
1143 TFT_show_deco_mask:
1144 bcf safety_stop_active ; flag safety stop is not shown any more TODO: needed?
1145 btfsc dive_main_menu ; is the dive mode menu shown?
1146 return ; YES - abort
1147 btfsc alt_layout_active ; NO - in alternative layout?
1148 bra TFT_show_deco_mask_alt ; YES
1149 ;bra TFT_show_deco_mask_norm ; NO
1150
1151 TFT_show_deco_mask_norm:
1152 WIN_STD dm_tts_text_col_norm, dm_tts_text_row_norm ; set text position
1153 bra TFT_show_deco_mask_common ; continue with common part
1154
1155 TFT_show_deco_mask_alt:
1156 WIN_TINY dm_tts_text_col_alt, dm_tts_text_row_alt ; set text position
1157 STRCPY "Stop/" ; print "Stop/"
1158 ;bra TFT_show_deco_mask_common ; continue with common part
1159
1160 TFT_show_deco_mask_common:
1161 call TFT_divemask_color ; set text color
1162 STRCAT_TEXT_PRINT tTTS ; print "TTS"
1163 bra TFT_display_exit_1 ; done
1164
1165
1166 TFT_display_deco_depth: ; output depth (stored in lo) to POSTINC2 with "m" or "ft"
1167 TSTOSS opt_units ; get unit (0=m, 1=ft)
1168 bra TFT_display_deco_depth_m ; 0 - meter
1169 ;bra TFT_display_deco_depth_ft ; 1 - feet
1170
1171 TFT_display_deco_depth_ft:
1172 call convert_meter_to_feet ; convert value in lo from meters to feet
1173 output_16_3 ; output stop depth (000-999)
1174 return ; done
1175
1176 TFT_display_deco_depth_m:
1177 output_99 ; output stop depth
1178 STRCAT_TEXT tMeters ; print unit
1179 return ; done
1180
1181
1182 global TFT_show_deco
1183 TFT_show_deco:
1184 btfsc dive_main_menu ; is the dive mode menu shown?
1185 return ; YES - abort
1186
1187 call TFT_color_code_stop ; color-code output
1188 movff char_O_deco_depth,lo ; get depth of first stop in meters
1189
1190 TSTOSC opt_units ; get unit (0=m, 1=ft)
1191 bra TFT_show_deco_norm ; 1 - ft can only be displayed in normal layout due to space required for 3 digit depth
1192
1193 btfsc alt_layout_active ; in alternative layout?
1194 bra TFT_show_deco_alt ; YES
1195 ;bra TFT_show_deco_norm ; NO
1196
1197 TFT_show_deco_norm: ; set position for combined depth and time
1198 WIN_MEDIUM dm_decostop_col_norm, dm_decostop_row_norm
1199 rcall TFT_display_deco_depth ; output depth (stored in lo) to POSTINC2 with "m" or "ft"
1200 PUTC ' ' ; put a space char between depth and time
1201 bra TFT_display_deco_common ; continue with common part
1202
1203 TFT_show_deco_alt: ; set position for depth
1204 WIN_LARGE dm_decostop_col_alt_depth, dm_decostop_row_alt_depth
1205 output_99 ; output stop depth (2 digits, usable for meters only)
1206 STRCAT_PRINT "" ; finalize output
1207 ; set position for time
1208 WIN_MEDIUM dm_decostop_col_alt_time, dm_decostop_row_alt_time
1209 call TFT_memo_color ; back to memo color
1210 bcf win_invert ; back to non-inverted output
1211 ;bra TFT_display_deco_common ; continue with common part
1212
1213 TFT_display_deco_common:
1214 movff char_O_deco_time,lo ; get stop time of the first stop in minutes
935 tstfsz lo ; stop time = 0 ? 1215 tstfsz lo ; stop time = 0 ?
936 bra TFT_display_tts_alt_2 ; NO - print time 1216 bra TFT_display_deco_1 ; NO - print minutes
937 STRCAT_PRINT ".." ; YES - special treatment 1217 STRCAT_PRINT " .." ; YES - special treatment
938 bra TFT_display_tts_alt_exit 1218 bra TFT_display_deco_2 ; - continue with common part
939 TFT_display_tts_alt_2: 1219 TFT_display_deco_1:
940 bcf leftbind 1220 output_99 ; print minutes
941 output_99 1221 TFT_display_deco_2:
942 STRCAT_PRINT "" 1222 STRCAT_PRINT "'" ; add minutes sign
943 TFT_display_tts_alt_exit: 1223 bcf win_invert ; back to non-inverted output
1224 TFT_display_exit_1:
944 goto TFT_standard_color ; and return... 1225 goto TFT_standard_color ; and return...
945
946
947 TFT_big_deco_ndl_alt:
948 ; NDL
949 bcf FLAG_TFT_display_ndl
950 bcf decostop_active ; clear flag (again)
951 btfsc FLAG_gauge_mode ; in gauge mode?
952 bra TFT_big_deco_ndl_alt_1 ; YES - skip NDL
953 call TFT_divemask_color
954 WIN_STD .70,.165
955 STRCPY_TEXT_PRINT tNDL ; NDL
956 call TFT_memo_color
957 WIN_LARGE .97,.170
958 movff char_O_nullzeit,lo ; get NDL from C-code
959 output_8
960 STRCAT_PRINT ""
961 TFT_big_deco_ndl_alt_1:
962 btfsc FLAG_TFT_show_safety_stop
963 bra TFT_show_safety_stop_alt ; show safety stop (and return)
964 ; Clear any safety stop or Decostop
965 TFT_no_more_safety_stop_alt:
966 WIN_BOX_BLACK dm_customview_row, .150, .0, .159 ; top, bottom, left, right
967 WIN_BOX_BLACK dm_customview_row, .164, .60, .159 ; top, bottom, left, right
968 return
969
970 TFT_show_safety_stop_alt:
971 bcf FLAG_TFT_show_safety_stop
972 tstfsz safety_stop_countdown ; countdown at zero?
973 bra TFT_show_safety_stop_alt2 ; NO - show stop
974 bcf show_safety_stop ; clear flag
975 btfss safety_stop_active ; displayed?
976 return ; NO
977 bcf safety_stop_active ; YES - clear flag
978 bra TFT_no_more_safety_stop_alt ; - clear stop and return
979
980 TFT_show_safety_stop_alt2:
981 bsf safety_stop_active ; set flag
982 decf safety_stop_countdown,F ; reduce countdown
983
984 call TFT_divemask_color
985 WIN_STD .50,dm_customview_row
986 STRCPY_TEXT_PRINT tDiveSafetyStop
987 call TFT_attention_color ; show in yellow
988 WIN_LARGE .90,.95
989 movff safety_stop_countdown,lo
990 clrf hi
991 call convert_time ; converts hi:lo in seconds to mins (up:hi) and seconds (lo)
992 movf hi,W
993 movff lo,hi
994 movwf lo ; exchange lo and hi
995 bsf leftbind
996 output_8
997 STRCAT_PRINT ""
998 WIN_MEDIUM .112,.120
999 STRCAT_PRINT ":"
1000 WIN_LARGE .117,.95
1001 bcf leftbind
1002 movff hi,lo
1003 output_99x
1004 STRCAT_PRINT ""
1005 WIN_FONT FT_SMALL
1006 bra TFT_display_exit_1
1007
1008
1009 global TFT_divemode_warning
1010 TFT_divemode_warning:
1011 bcf FLAG_TFT_divemode_warning ; clear job flag
1012 bsf dive_warning_displayed ; set advice/attention/warning sign is shown flag
1013 WIN_TOP dm_warning_icon_row
1014 WIN_LEFT dm_warning_icon_column
1015 btfsc message_warning ; do we have a warning?
1016 bra TFT_divemode_warning_1 ; YES - show warning sign
1017 btfsc message_attention ; NO - do we have an attention?
1018 bra TFT_divemode_warning_2 ; YES - show attention sign
1019 bra TFT_divemode_warning_3 ; NO to both - must be an advice then
1020
1021 dive_warning2_warning_colors: ; custom colors table for dive_warning2 icon - warning
1022 db .4, 0 ; #colors, spare
1023 dw 0x0000 ; color 0x00: outside black
1024 dw 0xff80 ; color 0x01: triangle yellow
1025 dw 0xff80 ; color 0x02: excl.mark yellow
1026 dw 0xf800 ; color 0x03: inside red
1027
1028 dive_warning2_advice_colors: ; custom colors table for dive_warning2 icon - advice
1029 db .4, 0 ; #colors, spare
1030 dw 0x0000 ; color 0x00: outside black
1031 dw 0xffff ; color 0x01: triangle white
1032 dw 0xffff ; color 0x02: excl.mark white
1033 dw 0x0780 ; color 0x03: inside green
1034
1035 TFT_divemode_warning_1:
1036 TFT_WRITE_PROM_IMAGE_CUST_COLOR dive_warning2_warning_colors
1037 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; output warning sign (with custom colors)
1038 return
1039 TFT_divemode_warning_2:
1040 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; output attention sign (with default colors)
1041 return
1042 TFT_divemode_warning_3:
1043 TFT_WRITE_PROM_IMAGE_CUST_COLOR dive_warning2_advice_colors
1044 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; output advice sign (with custom colors)
1045 return
1046
1047
1048 global TFT_divemode_warning_clear
1049 TFT_divemode_warning_clear:
1050 bcf FLAG_TFT_divemode_warning_clear ; clear job flag
1051 btfss dive_warning_displayed ; advice/attention/warning sign is shown?
1052 return ; NO
1053 bcf dive_warning_displayed ; YES - clear advice/attention/warning sign and its flag
1054 WIN_BOX_BLACK dm_warning_icon_row, dm_warning_icon_bot, dm_warning_icon_column, dm_warning_icon_rgt ; top, bottom, left, right
1055 return
1056
1057
1058 global TFT_display_deko_mask
1059 TFT_display_deko_mask:
1060 bcf FLAG_TFT_display_deko_mask
1061 btfsc divemode_menu ; is the dive mode menu shown?
1062 return ; YES - return
1063 rcall TFT_clear_decoarea ; clear decostop and decosum (and NDL in this case)
1064 WIN_STD dm_tts_text_column, dm_tts_text_row
1065 call TFT_divemask_color
1066 STRCPY_TEXT_PRINT tTTS ; TTS
1067 bcf show_safety_stop ; clear safety stop flag
1068 bra TFT_display_exit_1
1069
1070
1071 TFT_display_deko_output_depth: ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft)
1072 TSTOSS opt_units ; 0=m, 1=ft
1073 bra TFT_display_deko_output_metric
1074 ;TFT_display_deko_output_imperial:
1075 movf lo,W ; lo = m
1076 mullw .100 ; PRODL:PRODH = mbar
1077 movff PRODL,lo
1078 movff PRODH,hi
1079 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops...
1080 movff lo,xA+0
1081 movff hi,xA+1
1082 movlw LOW d'334' ; 334feet/100m
1083 movwf xB+0
1084 movlw HIGH d'334'
1085 movwf xB+1
1086 call mult16x16 ; xA*xB=xC (lo:hi * 328)
1087 movlw d'50' ; round up
1088 addwf xC+0,F
1089 movlw 0
1090 addwfc xC+1,F
1091 addwfc xC+2,F
1092 addwfc xC+3,F
1093 movlw d'100'
1094 movwf xB+0
1095 clrf xB+1
1096 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
1097 movff xC+0,lo
1098 movff xC+1,hi ; restore lo and hi with updated value
1099 bcf leftbind
1100 btfsc alternative_divelayout
1101 bsf leftbind ; left for alternative layout mode
1102 bsf ignore_digit4 ; only full feet
1103 output_16
1104 btfsc alternative_divelayout
1105 return ; not for alternative layout mode
1106 STRCAT_TEXT tFeets1
1107 return
1108
1109 TFT_display_deko_output_metric:
1110 output_99
1111 btfsc alternative_divelayout
1112 return ; not for alternative layout mode
1113 STRCAT_TEXT tMeters
1114 PUTC ' '
1115 return
1116
1117
1118 global TFT_display_deko
1119 TFT_display_deko:
1120 bcf FLAG_TFT_display_deko
1121 btfsc divemode_menu ; is the dive mode menu shown?
1122 return ; YES - return
1123 WIN_MEDIUM dm_decostop_1st_stop_column, dm_decostop_1st_stop_row
1124 call TFT_color_code_stop ; color-code output
1125 movff char_O_first_deco_depth,lo ; stop depth in m
1126 rcall TFT_display_deko_output_depth ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft)
1127 movff char_O_first_deco_time,lo ; get stop time in minutes
1128 tstfsz lo ; stop time = 0 ?
1129 bra TFT_display_deko_1 ; NO - print minutes
1130 STRCAT_PRINT " ..'" ; YES - special treatment
1131 bra TFT_display_exit_1
1132 TFT_display_deko_1:
1133 output_99 ; output lo
1134 STRCAT_PRINT "'"
1135 TFT_display_exit_1
1136 goto TFT_standard_color ; and return...
1137 1226
1138 1227
1139 global TFT_decoplan_mask ; mask for deco plan 1228 global TFT_decoplan_mask ; mask for deco plan
1140 TFT_decoplan_mask: 1229 TFT_decoplan_mask:
1141 call TFT_divemask_color 1230 call TFT_divemask_color
1142 WIN_TINY dm_custom_decoplan_title_column, dm_custom_decoplan_title_row 1231 WIN_TINY dm_custom_decoplan_title_column, dm_custom_decoplan_title_row
1143 STRCPY_TEXT_PRINT tDiveDecoplan 1232 STRCPY_TEXT_PRINT tDiveDecoplan
1144 return 1233 return
1234
1145 1235
1146 global TFT_decoplan ; data for deco plan - stops 2 - 7 (stop 1 is shown in the main screen) 1236 global TFT_decoplan ; data for deco plan - stops 2 - 7 (stop 1 is shown in the main screen)
1147 TFT_decoplan: 1237 TFT_decoplan:
1148 lfsr FSR0,char_O_deco_depth ; load base address of stops table 1238 lfsr FSR0,char_O_deco_depth ; load base address of stops table
1149 clrf ex ; will be used for auxiliary flags 1239 clrf ex ; will be used for auxiliary flags
1189 return 1279 return
1190 TFT_decoplan_helper_2: ; no more stop table entries, blank potential previous content 1280 TFT_decoplan_helper_2: ; no more stop table entries, blank potential previous content
1191 STRCPY_PRINT " " ; wipe screen position by printing 7 spaces 1281 STRCPY_PRINT " " ; wipe screen position by printing 7 spaces
1192 return 1282 return
1193 TFT_decoplan_helper_3: 1283 TFT_decoplan_helper_3:
1194 rcall TFT_display_deko_output_depth ; output depth (stored in lo) to POSTINC2 with "m" or w/o (for ft) 1284 rcall TFT_display_deco_depth ; output depth (stored in lo) to POSTINC2
1285 PUTC " " ; put a space char between depth and time
1195 movlw NUM_STOPS ; offset between arrays holding depths and durations 1286 movlw NUM_STOPS ; offset between arrays holding depths and durations
1196 movff PLUSW0,lo ; get duration of the current stop 1287 movff PLUSW0,lo ; get duration of the current stop
1197 output_99 ; output duration to POSTINC2 1288 output_99 ; output duration to POSTINC2
1198 STRCAT_PRINT "'" ; append symbol for minutes and print to screen 1289 STRCAT_PRINT "'" ; append symbol for minutes and print to screen
1199 bsf ex,1 ; flag that a stop was shown 1290 bsf ex,1 ; flag that a stop was shown
1200 return 1291 return
1201 1292
1202 1293
1203 global TFT_clear_safety_stop 1294 global TFT_safety_stop_clear
1204 TFT_clear_safety_stop: 1295 TFT_safety_stop_clear:
1205 bcf FLAG_TFT_clear_safety_stop ; clear flag 1296 btfsc dive_main_menu ; is the dive mode menu shown?
1206 WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, .159 ; top, bottom, left, right 1297 return ; YES - abort
1207 return 1298 btfss safety_stop_active ; NO - is the safety stop shown?
1208 1299 return ; NO - done, nothing to do
1209 global TFT_show_safety_stop 1300 ; YES - clear safety stop area
1210 TFT_show_safety_stop: 1301 WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, dm_safetystop_rgt ; top, bottom, left, right
1211 bcf FLAG_TFT_show_safety_stop 1302 bcf safety_stop_active ; - safety stop not shown any more
1212 tstfsz safety_stop_countdown ; countdown at zero? 1303 return ; - done
1213 bra TFT_show_safety_stop2 ; NO - show stop 1304
1214 bcf show_safety_stop ; clear flag 1305
1215 btfss safety_stop_active ; displayed? 1306 global TFT_safety_stop_show
1216 return ; NO 1307 TFT_safety_stop_show:
1217 bcf safety_stop_active ; clear flag 1308 btfsc dive_main_menu ; is the dive mode menu shown?
1218 btfsc divemode_menu ; is the dive mode menu shown? 1309 return ; YES - abort
1219 return ; YES - return 1310 btfsc safety_stop_active ; NO - is the safety stop shown already?
1220 bra TFT_clear_safety_stop ; NO - clear stop and return... 1311 bra TFT_safety_stop_show_time ; YES - just update the time
1221 TFT_show_safety_stop2: 1312 ; NO - clear area that may be polluted by alternative NDL
1222 bsf safety_stop_active ; set flag 1313 WIN_BOX_BLACK dm_safetystop_row, dm_tts_value_row, dm_ndl_value_col_alt, dm_safetystop_rgt ; top, bottom, left, right
1223 decf safety_stop_countdown,F ; reduce countdown 1314 call TFT_divemask_color ; - set color for text
1224 btfsc divemode_menu ; is the dive mode menu shown? 1315 ; - set position for text
1225 return ; YES - return 1316 bsf safety_stop_active ; - flag safety stop is shown now
1226 ;btfsc menuview
1227 ;bra TFT_show_safety_stop3 ; no room when menuview=1...
1228 call TFT_divemask_color
1229 WIN_STD dm_safetystop_text_column, dm_safetystop_text_row 1317 WIN_STD dm_safetystop_text_column, dm_safetystop_text_row
1230 STRCPY_TEXT_PRINT tDiveSafetyStop 1318 STRCPY_TEXT_PRINT tDiveSafetyStop ; - print "Stop"
1231 TFT_show_safety_stop3: 1319 TFT_safety_stop_show_time:
1232 call TFT_attention_color ; show in yellow 1320 call TFT_attention_color ; set color for time
1233 WIN_MEDIUM dm_safetystop_column, dm_safetystop_row 1321 ; set position for time
1234 movff safety_stop_countdown,lo 1322 WIN_MEDIUM dm_safetystop_column, dm_safetystop_row
1235 clrf hi 1323 movff safety_stop_countdown,lo ; get remaining time in seconds, low byte, from safety stop timer
1236 call convert_time ; converts hi:lo in seconds to mins (up:hi) and seconds (lo) 1324 clrf hi ; set remaining time in seconds, high byte, to zero
1237 movf hi,W 1325 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
1238 movff lo,hi 1326 movff lo,up ; save seconds in up
1239 movwf lo ; exchange lo and hi 1327 movff hi,lo ; move minutes to lo
1240 bsf leftbind 1328 bsf leftbind ; activate left-alignment
1241 output_8 1329 output_8 ; print minutes
1242 bcf leftbind 1330 bcf leftbind ; deactivate left-alignment
1243 PUTC ':' 1331 PUTC ':' ; print ":"
1244 movff hi,lo 1332 movff up,lo ; move seconds to lo
1245 output_99x 1333 output_99x ; print seconds (2 digits with leading zero)
1246 STRCAT_PRINT "" 1334 STRCAT_PRINT "" ; finalize output
1247 WIN_FONT FT_SMALL 1335 bra TFT_display_exit_1 ; done
1248 bra TFT_display_exit_1
1249 1336
1250 1337
1251 global TFT_avr_stopwatch_mask ; mask for average depth and stopwatch 1338 global TFT_avr_stopwatch_mask ; mask for average depth and stopwatch
1252 TFT_avr_stopwatch_mask: 1339 TFT_avr_stopwatch_mask:
1253 call TFT_divemask_color 1340 call TFT_divemask_color
1341
1342 IFNDEF _min_depth_option
1343
1254 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row 1344 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row
1255 TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth in main screen? 1345 TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth in main screen?
1256 bra TFT_avr_stopwatch_mask_1 ; NO - draw avg depth in custom view then 1346 bra TFT_avr_stopwatch_mask_1 ; NO - draw avg depth in custom view then
1257 STRCAT_TEXT_PRINT tMaxDepth ; YES - draw max depth in custom view then 1347 STRCPY_TEXT_PRINT tMaxDepth ; YES - draw max depth in custom view then
1258 bra TFT_avr_stopwatch_mask_2 1348 bra TFT_avr_stopwatch_mask_2
1259 TFT_avr_stopwatch_mask_1: 1349 TFT_avr_stopwatch_mask_1:
1260 STRCPY_TEXT_PRINT tDiveTotalAvg 1350 STRCPY_TEXT_PRINT tDiveTotalAvg
1261 TFT_avr_stopwatch_mask_2: 1351 TFT_avr_stopwatch_mask_2:
1262 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row 1352 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row
1263 STRCPY_TEXT_PRINT tDiveStopwatch 1353 STRCPY_TEXT_PRINT tDiveStopwatch
1264 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row 1354 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row
1265 STRCPY_TEXT_PRINT tDiveStopAvg 1355 STRCPY_TEXT_PRINT tDiveStopAvg
1266 bra TFT_display_exit_1 1356 bra TFT_display_exit_1
1267 1357
1358 ELSE
1359
1360 WIN_TINY dm_custom_avr_stop_column1+.2,dm_custom_avr_stop_title_row
1361 STRCPY_PRINT "Max.Depth"
1362 WIN_TINY dm_custom_avr_stop_column2+.3,dm_custom_avr_stop_title_row
1363 STRCPY_PRINT "Avg.Depth"
1364 WIN_TINY dm_custom_avr_stop_column3-.8,dm_custom_avr_stop_title_row
1365 STRCPY_PRINT "Min.Depth"
1366 bra TFT_display_exit_1
1367
1368 ENDIF
1369
1268 1370
1269 global TFT_avr_stopwatch ; data for average depth and stopwatch 1371 global TFT_avr_stopwatch ; data for average depth and stopwatch
1270 TFT_avr_stopwatch: 1372 TFT_avr_stopwatch:
1271 call TFT_memo_color 1373 call TFT_memo_color
1272 bsf leftbind 1374 bsf leftbind
1273 1375
1376 IFNDEF _min_depth_option
1377
1274 ; total average depth or max depth 1378 ; total average depth or max depth
1275 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row 1379 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row
1276 TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth in main screen? 1380 TSTOSS opt_2ndDepthDisp ; draw average depth instead of maximum depth in main screen?
1277 bra TFT_avr_stopwatch_01 ; NO - draw avg depth in custom view then 1381 bra TFT_avr_stopwatch_01 ; NO - draw average depth in custom view then
1278 SAFE_2BYTE_COPY max_pressure,lo ; YES - draw max depth in custom view then 1382 MOVII pressure_rel_max_cached,mpr ; YES - draw maximum depth in custom view then
1279 bra TFT_avr_stopwatch_02 1383 bra TFT_avr_stopwatch_02
1280 TFT_avr_stopwatch_01: 1384 TFT_avr_stopwatch_01:
1281 movff avg_rel_pressure_total+0,lo 1385 MOVII pressure_rel_avg_total,mpr ; get total dive average depth into hi:lo
1282 movff avg_rel_pressure_total+1,hi
1283 TFT_avr_stopwatch_02: 1386 TFT_avr_stopwatch_02:
1284 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] 1387 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
1285 TSTOSS opt_units ; 0=m, 1=ft 1388 TSTOSS opt_units ; 0=m, 1=ft
1286 bra TFT_update_avr_stopwatch1_metric ; 0 - metric 1389 bra TFT_update_avr_stopwatch1_metric ; 0 - metric
1287 ;bra TFT_update_avr_stopwatch1_imp ; 1 - imperial 1390 TFT_update_avr_stopwatch1_imp: ; 1 - imperial
1288 TFT_update_avr_stopwatch1_imp:
1289 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 1391 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
1290 output_16 ; yxz 1392 output_16 ; yxz
1291 STRCAT " " ; wipe out remains from last output 1393 STRCAT " " ; wipe out remains from last output
1292 clrf WREG 1394 clrf WREG
1293 movff WREG,buffer+.3 ; limit string length to 3 digits 1395 movff WREG,buffer+.3 ; limit string length to 3 digits
1301 TFT_update_avr_stopwatch2: 1403 TFT_update_avr_stopwatch2:
1302 STRCAT_PRINT "" 1404 STRCAT_PRINT ""
1303 1405
1304 ; stopped average depth 1406 ; stopped average depth
1305 WIN_MEDIUM dm_custom_avr_stop_column3,dm_custom_avr_stop_row 1407 WIN_MEDIUM dm_custom_avr_stop_column3,dm_custom_avr_stop_row
1306 movff avg_rel_pressure+0,lo 1408 MOVII pressure_rel_avg_trip,mpr ; get the resettable average depth
1307 movff avg_rel_pressure+1,hi 1409 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
1308 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
1309 TSTOSS opt_units ; 0=m, 1=ft 1410 TSTOSS opt_units ; 0=m, 1=ft
1310 bra TFT_update_avr_stopwatch2_metric ; 0 - metric 1411 bra TFT_update_avr_stopwatch2_metric ; 0 - metric
1311 ;bra TFT_update_avr_stopwatch2_imp ; 1 - imperial 1412 TFT_update_avr_stopwatch2_imp: ; 1 - imperial
1312 TFT_update_avr_stopwatch2_imp:
1313 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 1413 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
1314 output_16 ; yxz 1414 output_16 ; yxz
1315 STRCAT " " ; wipe out remains from last output 1415 STRCAT " " ; wipe out remains from last output
1316 clrf WREG 1416 clrf WREG
1317 movff WREG,buffer+.3 ; limit string length to 3 digits/characters 1417 movff WREG,buffer+.3 ; limit string length to 3 digits/characters
1321 output_16dp .3 ; yxz.a 1421 output_16dp .3 ; yxz.a
1322 PUTC " " ; wipe out remains from last output 1422 PUTC " " ; wipe out remains from last output
1323 clrf WREG 1423 clrf WREG
1324 movff WREG,buffer+.4 ; limit string length to 4 = 3 digits + 1 half-size decimal dot 1424 movff WREG,buffer+.4 ; limit string length to 4 = 3 digits + 1 half-size decimal dot
1325 TFT_update_avr_stopwatch3: 1425 TFT_update_avr_stopwatch3:
1326 STRCAT_PRINT "" 1426 STRCAT_PRINT "" ; finalize output
1327 1427
1328 ; stopped dive time 1428 ELSE
1429
1430 ; resettable maximum depth - needs ISR-safe copy!
1431 WIN_MEDIUM dm_custom_avr_stop_column1,dm_custom_avr_stop_row ; column 0
1432 call TFT_memo_color
1433 SMOVII pressure_rel_max_trip,mpr
1434 rcall TFT_avr_stopwatch_helper
1435
1436 ; resettable average depth
1437 WIN_MEDIUM dm_custom_avr_stop_column2-.1,dm_custom_avr_stop_row ; column 54 - 1 = 53
1438 call TFT_attention_color
1439 MOVII pressure_rel_avg_trip,mpr
1440 rcall TFT_avr_stopwatch_helper
1441
1442 ; resettable minimum depth - needs ISR safe copy!
1443 WIN_MEDIUM dm_custom_avr_stop_column3-.12,dm_custom_avr_stop_row ; column 118 - 12 = 106
1444 call TFT_memo_color
1445 SMOVII pressure_rel_min_trip,mpr
1446 rcall TFT_avr_stopwatch_helper
1447
1448 ; done
1449 bra TFT_display_exit_2
1450
1451 TFT_avr_stopwatch_helper:
1452 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
1453 output_16dp .3 ; yxz.ab
1454 PUTC " " ; wipe out remains from last output
1455 clrf WREG
1456 movff WREG,buffer+.5 ; limit string length to 5 = 4 digits + 1 half-size decimal dot
1457 STRCAT_PRINT ""
1458 return
1459
1460 ENDIF
1461
1462 ; stopped dive time (will also be used by compass custom view)
1329 WIN_MEDIUM dm_custom_avr_stop_column2,dm_custom_avr_stop_row 1463 WIN_MEDIUM dm_custom_avr_stop_column2,dm_custom_avr_stop_row
1330 TFT_update_stopwatch: ; jump-in point for stopped dive time in compass custom view 1464 TFT_update_stopwatch: ; jump-in point for stopped dive time in compass custom view
1331 bsf leftbind ; print numbers without leading spaces 1465 bsf leftbind ; print numbers without leading spaces
1332 movff average_divesecs+0,lo ; average_divesecs is incremented outside ISR 1466 MOVII divesecs_avg_trip,mpr ; get the resettable dive time (stopwatch)
1333 movff average_divesecs+1,hi 1467 call convert_time ; convert hi:lo in seconds to minutes (up:hi) and seconds (lo)
1334 call convert_time ; converts hi:lo in seconds to minutes (up:hi) and seconds (lo)
1335 movlw .100 ; display layout will change if minutes become >= 100 1468 movlw .100 ; display layout will change if minutes become >= 100
1336 cpfslt hi ; minutes < 100 ? 1469 cpfslt hi ; minutes < 100 ?
1337 bra TFT_update_stopwatch_2 ; NO - display hours:minutes 1470 bra TFT_update_stopwatch_2 ; NO - display hours:minutes
1338 ;bra TFT_update_stopwatch_1 ; YES - display minutes:seconds 1471 ;bra TFT_update_stopwatch_1 ; YES - display minutes:seconds
1339 TFT_update_stopwatch_1: 1472 TFT_update_stopwatch_1:
1351 STRCAT_PRINT "" 1484 STRCAT_PRINT ""
1352 bra TFT_display_exit_2 1485 bra TFT_display_exit_2
1353 TFT_update_stopwatch_2: 1486 TFT_update_stopwatch_2:
1354 movff hi,lo ; transfer minutes (low byte) to lo 1487 movff hi,lo ; transfer minutes (low byte) to lo
1355 movff up,hi ; transfer minutes (high byte) to hi 1488 movff up,hi ; transfer minutes (high byte) to hi
1356 call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) 1489 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
1357 bra TFT_update_stopwatch_1 1490 bra TFT_update_stopwatch_1
1358 1491
1359 1492
1360 global TFT_CNS_mask 1493 global TFT_CNS_mask
1361 TFT_CNS_mask: 1494 TFT_CNS_mask:
1363 WIN_TINY dm_custom_cns3_column1, dm_custom_cns3_title_row 1496 WIN_TINY dm_custom_cns3_column1, dm_custom_cns3_title_row
1364 STRCPY_TEXT_PRINT tCNSsurf 1497 STRCPY_TEXT_PRINT tCNSsurf
1365 WIN_TINY dm_custom_cns3_column2, dm_custom_cns3_title_row 1498 WIN_TINY dm_custom_cns3_column2, dm_custom_cns3_title_row
1366 btfsc FLAG_oc_mode ; in OC mode? 1499 btfsc FLAG_oc_mode ; in OC mode?
1367 bra TFT_CNS_mask_1 ; YES - print fTTS label 1500 bra TFT_CNS_mask_1 ; YES - print fTTS label
1368 btfsc FLAG_bailout_mode ; in bailout? 1501 btfsc bailout_mode ; in bailout?
1369 bra TFT_CNS_mask_1 ; YES - print fTTS label (label will be printed, but a fTTS will actually not be calculated) 1502 bra TFT_CNS_mask_1 ; YES - print fTTS label (label will be printed, but a fTTS will actually not be calculated)
1370 TSTOSS opt_calc_asc_gasvolume ; bailout volume calculation requested? 1503 TSTOSS opt_calc_asc_gasvolume ; bailout volume calculation requested?
1371 bra TFT_CNS_mask_1 ; NO - print fTTS label 1504 bra TFT_CNS_mask_1 ; NO - print fTTS label
1372 STRCPY_TEXT_PRINT tCNSBO ; YES - print bailout label 1505 STRCPY_TEXT_PRINT tCNSBO ; YES - print bailout label
1373 bra TFT_CNS_mask_2 1506 bra TFT_CNS_mask_2
1382 global TFT_CNS 1515 global TFT_CNS
1383 TFT_CNS: 1516 TFT_CNS:
1384 bsf leftbind 1517 bsf leftbind
1385 ; CNS at end of normal dive 1518 ; CNS at end of normal dive
1386 WIN_STD dm_custom_cns3_column1+.3,dm_custom_cns3_row 1519 WIN_STD dm_custom_cns3_column1+.3,dm_custom_cns3_row
1387 movff int_O_normal_CNS_fraction+0,lo 1520 MOVII int_O_CNS_norm,mpr ; get CNS at end of dive in normal plan
1388 movff int_O_normal_CNS_fraction+1,hi
1389 call TFT_color_code_cns 1521 call TFT_color_code_cns
1390 output_16_3 ; output as xxx 1522 output_16_3 ; output as xxx
1391 STRCAT_PRINT "% " 1523 STRCAT_PRINT "% "
1392 ; fTTS / Bailout CNS, if enabled 1524 ; fTTS / Bailout CNS, if enabled
1393 WIN_STD dm_custom_cns3_column2+.2,dm_custom_cns3_row 1525 WIN_STD dm_custom_cns3_column2+.2,dm_custom_cns3_row
1394 btfsc FLAG_bailout_mode ; in bailout? 1526 btfsc bailout_mode ; in bailout?
1395 bra TFT_CNS_3 ; YES - show "---" 1527 bra TFT_CNS_3 ; YES - show "---"
1396 TSTOSS opt_calc_asc_gasvolume ; NO - bailout volume calculation requested? 1528 TSTOSS opt_calc_asc_gasvolume ; NO - bailout volume calculation requested?
1397 bra TFT_CNS_1 ; NO - continue checking fTTS extra time 1529 bra TFT_CNS_1 ; NO - continue checking fTTS extra time
1398 btfss FLAG_oc_mode ; YES - in OC mode? 1530 btfss FLAG_oc_mode ; YES - in OC mode?
1399 bra TFT_CNS_2 ; NO - show CNS% 1531 bra TFT_CNS_2 ; NO - show CNS%
1400 TFT_CNS_1: ; not in bailout, no volume calculation, and/or in OC mode 1532 TFT_CNS_1: ; not in bailout, no volume calculation, and/or in OC mode
1401 TSTOSS char_I_extra_time ; fTTS extra time configured? 1533 TSTOSS char_I_extra_time ; fTTS extra time configured?
1402 bra TFT_CNS_3 ; NO - show "---" 1534 bra TFT_CNS_3 ; NO - show "---"
1403 TFT_CNS_2: 1535 TFT_CNS_2: ; YES - show CNS%
1404 movff int_O_alternate_CNS_fraction+0,lo ; YES - show CNS% 1536 MOVII int_O_CNS_alt,mpr ; get CNS at end of dive in alternative plan
1405 movff int_O_alternate_CNS_fraction+1,hi 1537 call TFT_color_code_cns ; color-code the CNS value
1406 call TFT_color_code_cns
1407 output_16_3 ; output as xxx 1538 output_16_3 ; output as xxx
1408 STRCAT_PRINT "% " 1539 STRCAT_PRINT "% "
1409 bra TFT_CNS_4 1540 bra TFT_CNS_4
1410 TFT_CNS_3: 1541 TFT_CNS_3:
1411 call TFT_memo_color 1542 call TFT_memo_color
1412 STRCPY_PRINT "--- " 1543 STRCPY_PRINT "--- "
1413 TFT_CNS_4: 1544 TFT_CNS_4:
1414 ; current CNS 1545 ; current CNS
1415 WIN_STD dm_custom_cns3_column3+.3,dm_custom_cns3_row 1546 WIN_STD dm_custom_cns3_column3+.3,dm_custom_cns3_row
1416 movff int_O_CNS_fraction+0,lo 1547 MOVII int_O_CNS_current,mpr ; get current CNS
1417 movff int_O_CNS_fraction+1,hi
1418 call TFT_color_code_cns 1548 call TFT_color_code_cns
1419 output_16_3 ; output as xxx 1549 output_16_3 ; output as xxx
1420 STRCAT_PRINT "%" 1550 STRCAT_PRINT "%"
1421 TFT_display_exit_2: 1551 TFT_display_exit_2:
1422 bcf leftbind 1552 bcf leftbind
1423 goto TFT_standard_color ; and return... 1553 goto TFT_standard_color ; and return...
1424 1554
1555
1556 ;=============================================================================
1557
1558 IFDEF _external_sensor
1425 1559
1426 global TFT_ppo2_sensors_mask ; mask for ppO2 sensors 1560 global TFT_ppo2_sensors_mask ; mask for ppO2 sensors
1427 TFT_ppo2_sensors_mask: 1561 TFT_ppo2_sensors_mask:
1428 call TFT_divemask_color 1562 call TFT_divemask_color
1429 WIN_TINY dm_custom_hud_sensor1_column+.4,dm_custom_hud_title_row 1563 WIN_TINY dm_custom_hud_sensor1_column+.4,dm_custom_hud_title_row
1463 STRCPY_PRINT "---" 1597 STRCPY_PRINT "---"
1464 bra TFT_update_hud2a ; continue with sensor 2 1598 bra TFT_update_hud2a ; continue with sensor 2
1465 TFT_update_hud1b: 1599 TFT_update_hud1b:
1466 ; sensor has a valid calibration 1600 ; sensor has a valid calibration
1467 WIN_MEDIUM dm_custom_hud_sensor1_column,dm_custom_hud_row 1601 WIN_MEDIUM dm_custom_hud_sensor1_column,dm_custom_hud_row
1468 movff o2_ppo2_sensor1,lo ; load ppO2 value into transfer storage for output 1602 movff sensor1_ppO2,lo ; load ppO2 value into transfer storage for output
1469 clrf hi ; 1603 clrf hi ;
1470 btfsc use_O2_sensor1 ; in use? 1604 btfsc use_O2_sensor1 ; in use?
1471 bra TFT_update_hud1d ; YES 1605 bra TFT_update_hud1d ; YES
1472 ; valid calibration, but not in use 1606 ; valid calibration, but not in use
1473 tstfsz o2_ppo2_sensor1 ; sensor value = 0? 1607 tstfsz lo ; sensor value = 0?
1474 bra TFT_update_hud1c ; no 1608 bra TFT_update_hud1c ; no
1475 ; valid calibration, not in use and value = 0 1609 ; valid calibration, not in use and value = 0
1476 call TFT_attention_color ; output in yellow 1610 call TFT_attention_color ; output in yellow
1477 bra TFT_update_hud1e 1611 bra TFT_update_hud1e
1478 TFT_update_hud1c: 1612 TFT_update_hud1c:
1480 call TFT_disabled_color ; output in light blue 1614 call TFT_disabled_color ; output in light blue
1481 bra TFT_update_hud1e 1615 bra TFT_update_hud1e
1482 TFT_update_hud1d: 1616 TFT_update_hud1d:
1483 ; sensor has valid calibration and is in use 1617 ; sensor has valid calibration and is in use
1484 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo 1618 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo
1485 btfsc voting_logic_sensor1 ; sensor value agrees with other sensor's values? 1619 btfsc voting_logic_sensor1 ; sensor value agrees with values of other sensors?
1486 bra TFT_update_hud1e ; YES 1620 bra TFT_update_hud1e ; YES
1487 ; valid calibration, in use, but value does not agree with other sensors 1621 ; valid calibration, in use, but value does not agree with other sensors
1488 bsf win_invert ; invert output 1622 bsf win_invert ; invert output
1489 TFT_update_hud1e: 1623 TFT_update_hud1e:
1490 ; all coloring is set up now, let's write the value to the display! 1624 ; all coloring is set up now, let's write the value to the display!
1503 STRCPY_PRINT "---" 1637 STRCPY_PRINT "---"
1504 bra TFT_update_hud3a ; continue with sensor 3 1638 bra TFT_update_hud3a ; continue with sensor 3
1505 TFT_update_hud2b: 1639 TFT_update_hud2b:
1506 ; sensor has a valid calibration 1640 ; sensor has a valid calibration
1507 WIN_MEDIUM dm_custom_hud_sensor2_column,dm_custom_hud_row 1641 WIN_MEDIUM dm_custom_hud_sensor2_column,dm_custom_hud_row
1508 movff o2_ppo2_sensor2,lo ; load ppO2 value into transfer storage for output 1642 movff sensor2_ppO2,lo ; load ppO2 value into transfer storage for output
1509 clrf hi ; 1643 clrf hi ;
1510 btfsc use_O2_sensor2 ; in use? 1644 btfsc use_O2_sensor2 ; in use?
1511 bra TFT_update_hud2d ; YES 1645 bra TFT_update_hud2d ; YES
1512 ; valid calibration, but not in use 1646 ; valid calibration, but not in use
1513 tstfsz o2_ppo2_sensor2 ; sensor value = 0? 1647 tstfsz lo ; sensor value = 0?
1514 bra TFT_update_hud2c ; NO 1648 bra TFT_update_hud2c ; NO
1515 ; valid calibration, not in use and value = 0 1649 ; valid calibration, not in use and value = 0
1516 call TFT_attention_color ; output in yellow 1650 call TFT_attention_color ; output in yellow
1517 bra TFT_update_hud2e 1651 bra TFT_update_hud2e
1518 TFT_update_hud2c: 1652 TFT_update_hud2c:
1520 call TFT_disabled_color ; output in light blue 1654 call TFT_disabled_color ; output in light blue
1521 bra TFT_update_hud2e 1655 bra TFT_update_hud2e
1522 TFT_update_hud2d: 1656 TFT_update_hud2d:
1523 ; sensor has valid calibration and is in use 1657 ; sensor has valid calibration and is in use
1524 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo 1658 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo
1525 btfsc voting_logic_sensor2 ; sensor value agrees with other sensor's vlaues? 1659 btfsc voting_logic_sensor2 ; sensor value agrees with values of other sensors?
1526 bra TFT_update_hud2e ; YES 1660 bra TFT_update_hud2e ; YES
1527 ; valid calibration, in use, but value does not agree with other sensors 1661 ; valid calibration, in use, but value does not agree with other sensors
1528 bsf win_invert ; invert output 1662 bsf win_invert ; invert output
1529 TFT_update_hud2e: 1663 TFT_update_hud2e:
1530 ; all coloring is set up now, let's write the value to the display! 1664 ; all coloring is set up now, let's write the value to the display!
1543 STRCPY_PRINT "---" 1677 STRCPY_PRINT "---"
1544 bra TFT_update_hud4 ; done 1678 bra TFT_update_hud4 ; done
1545 TFT_update_hud3b: 1679 TFT_update_hud3b:
1546 ; sensor has a valid calibration 1680 ; sensor has a valid calibration
1547 WIN_MEDIUM dm_custom_hud_sensor3_column,dm_custom_hud_row 1681 WIN_MEDIUM dm_custom_hud_sensor3_column,dm_custom_hud_row
1548 movff o2_ppo2_sensor3,lo ; load ppO2 value into transfer storage for output 1682 movff sensor3_ppO2,lo ; load ppO2 value into transfer storage for output
1549 clrf hi ; 1683 clrf hi ;
1550 btfsc use_O2_sensor3 ; in use? 1684 btfsc use_O2_sensor3 ; in use?
1551 bra TFT_update_hud3d ; YES 1685 bra TFT_update_hud3d ; YES
1552 ; valid calibration, but not in use 1686 ; valid calibration, but not in use
1553 tstfsz o2_ppo2_sensor3 ; sensor value = 0? 1687 tstfsz lo ; sensor value = 0?
1554 bra TFT_update_hud3c ; NO 1688 bra TFT_update_hud3c ; NO
1555 ; valid calibration, not in use and value = 0 1689 ; valid calibration, not in use and value = 0
1556 call TFT_attention_color ; output in yellow 1690 call TFT_attention_color ; output in yellow
1557 bra TFT_update_hud3e 1691 bra TFT_update_hud3e
1558 TFT_update_hud3c: 1692 TFT_update_hud3c:
1560 call TFT_disabled_color ; output in light blue 1694 call TFT_disabled_color ; output in light blue
1561 bra TFT_update_hud3e 1695 bra TFT_update_hud3e
1562 TFT_update_hud3d: 1696 TFT_update_hud3d:
1563 ; sensor has valid calibration and is in use 1697 ; sensor has valid calibration and is in use
1564 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo 1698 call TFT_color_code_ppo2_hud ; With ppO2 [cbar] in lo
1565 btfsc voting_logic_sensor3 ; sensor value agrees with other sensor's values? 1699 btfsc voting_logic_sensor3 ; sensor value agrees with values other sensors?
1566 bra TFT_update_hud3e ; YES 1700 bra TFT_update_hud3e ; YES
1567 ; valid calibration, in use, but value does not agree with other sensors 1701 ; valid calibration, in use, but value does not agree with other sensors
1568 bsf win_invert ; invert output 1702 bsf win_invert ; invert output
1569 TFT_update_hud3e: 1703 TFT_update_hud3e:
1570 ; all coloring is set up now, let's write the value to the display! 1704 ; all coloring is set up now, let's write the value to the display!
1574 1708
1575 TFT_update_hud4: ; closure 1709 TFT_update_hud4: ; closure
1576 bra TFT_display_exit_3 1710 bra TFT_display_exit_3
1577 1711
1578 1712
1579 global TFT_surface_sensor ; update sensor data in surface mode 1713 global TFT_surface_sensor ; update O2 sensor data in surface mode
1580 TFT_surface_sensor: 1714 TFT_surface_sensor:
1581 movf hardware_flag1,W
1582 sublw 0x11 ; 2 with BLE
1583 btfsc STATUS,Z
1584 return ; ignore for 0x11
1585 ; show three sensors
1586 bsf leftbind 1715 bsf leftbind
1587 WIN_SMALL surf_hud_sensor1_column,surf_hud_sensor1_row 1716 WIN_SMALL surf_hud_sensor1_column,surf_hud_sensor1_row
1588 btfsc sensor1_calibrated_ok 1717 btfsc sensor1_calibrated_ok
1589 bra TFT_surface_sensor1 ; YES 1718 bra TFT_surface_sensor1 ; YES
1590 btfsc sensor1_active ; valid HUD data for this sensor 1719 btfsc sensor1_active ; valid HUD data for this sensor
1591 bra TFT_surface_sensor1 ; YES 1720 bra TFT_surface_sensor1 ; YES
1592 call TFT_standard_color 1721 call TFT_standard_color
1593 STRCPY_PRINT "--- " 1722 STRCPY_PRINT "--- "
1594 bra TFT_surface_sensor2 ; skip sensor 1 1723 bra TFT_surface_sensor2 ; skip sensor 1
1595 TFT_surface_sensor1: 1724 TFT_surface_sensor1:
1596 movff o2_ppo2_sensor1,lo 1725 movff sensor1_ppO2,lo
1597 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo 1726 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo
1598 clrf hi 1727 clrf hi
1599 bsf leftbind 1728 bsf leftbind
1600 output_16dp .3 ; x.xx bar 1729 output_16dp .3 ; x.xx bar
1601 bcf leftbind 1730 bcf leftbind
1608 bra TFT_surface_sensor3 ; YES 1737 bra TFT_surface_sensor3 ; YES
1609 call TFT_standard_color 1738 call TFT_standard_color
1610 STRCPY_PRINT "--- " 1739 STRCPY_PRINT "--- "
1611 bra TFT_surface_sensor4 ; skip sensor 2 1740 bra TFT_surface_sensor4 ; skip sensor 2
1612 TFT_surface_sensor3: 1741 TFT_surface_sensor3:
1613 movff o2_ppo2_sensor2,lo 1742 movff sensor2_ppO2,lo
1614 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo 1743 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo
1615 clrf hi 1744 clrf hi
1616 bsf leftbind 1745 bsf leftbind
1617 output_16dp .3 ; x.xx bar 1746 output_16dp .3 ; x.xx bar
1618 bcf leftbind 1747 bcf leftbind
1625 bra TFT_surface_sensor5 ; YES 1754 bra TFT_surface_sensor5 ; YES
1626 call TFT_standard_color 1755 call TFT_standard_color
1627 STRCPY_PRINT "--- " 1756 STRCPY_PRINT "--- "
1628 bra TFT_surface_sensor6 ; skip sensor 3 1757 bra TFT_surface_sensor6 ; skip sensor 3
1629 TFT_surface_sensor5: 1758 TFT_surface_sensor5:
1630 movff o2_ppo2_sensor3,lo 1759 movff sensor3_ppO2,lo
1631 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo 1760 call TFT_color_code_ppo2_hud ; with ppO2 [cbar] in lo
1632 clrf hi 1761 clrf hi
1633 bsf leftbind 1762 bsf leftbind
1634 output_16dp .3 ; x.xx bar 1763 output_16dp .3 ; x.xx bar
1635 bcf leftbind 1764 bcf leftbind
1640 goto TFT_standard_color ; and return... 1769 goto TFT_standard_color ; and return...
1641 1770
1642 1771
1643 global TFT_sensor_mV 1772 global TFT_sensor_mV
1644 TFT_sensor_mV: 1773 TFT_sensor_mV:
1645 call TFT_standard_color
1646 bsf leftbind 1774 bsf leftbind
1647 1775
1648 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor1_row 1776 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor1_row
1649 movff o2_mv_sensor1+0,lo ; in 0.1mV steps 1777 SMOVII sensor1_mv,mpr ; in 0.1mV steps
1650 movff o2_mv_sensor1+1,hi ; in 0.1mV steps
1651 STRCAT "1: " 1778 STRCAT "1: "
1652 rcall TFT_sensor_mV_helper 1779 rcall TFT_sensor_mV_helper
1653 1780
1654 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor2_row 1781 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor2_row
1655 movff o2_mv_sensor2+0,lo ; in 0.1mV steps 1782 SMOVII sensor2_mv,mpr ; in 0.1mV steps
1656 movff o2_mv_sensor2+1,hi ; in 0.1mV steps
1657 STRCAT "2: " 1783 STRCAT "2: "
1658 rcall TFT_sensor_mV_helper 1784 rcall TFT_sensor_mV_helper
1659 1785
1660 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row 1786 WIN_SMALL surf_mV_sensor_column,surf_mV_sensor3_row
1661 movff o2_mv_sensor3+0,lo ; in 0.1mV steps 1787 SMOVII sensor3_mv,mpr ; in 0.1mV steps
1662 movff o2_mv_sensor3+1,hi ; in 0.1mV steps
1663 STRCAT "3: " 1788 STRCAT "3: "
1664 rcall TFT_sensor_mV_helper 1789 rcall TFT_sensor_mV_helper
1790
1791 bcf leftbind
1665 bra TFT_display_exit_3 1792 bra TFT_display_exit_3
1666 1793
1667 TFT_sensor_mV_helper: 1794 TFT_sensor_mV_helper:
1668 output_16dp .4 ; xxx.y mV 1795 output_16dp .4 ; xxx.y mV
1669 STRCAT_PRINT "mV " 1796 STRCAT_PRINT "mV "
1670 return 1797 return
1671 1798
1672 1799
1673 global TFT_sensor_surface_warning 1800 global TFT_sensor_surface_warning
1674 TFT_sensor_surface_warning: 1801 TFT_sensor_surface_warning:
1675 call TFT_warnings_color 1802 call TFT_warning_color
1676 btfss sensor1_calibrated_ok ; do not show end of lifetime arrow if sensor failed calibration at all 1803 btfss sensor1_calibrated_ok ; do not show end of lifetime arrow if sensor failed calibration at all
1677 bra TFT_sensor_mV2 1804 bra TFT_sensor_mV2
1678 movff opt_x_s1+1,lo ; into bank1 1805 movff opt_x_s1+1,lo ; into bank1
1679 movf lo,W ; when opt_x_s1 > 255 the sensor will just give 8 mV at a ppO2 of 0.21 any more 1806 movf lo,W ; when opt_x_s1 > 255 the sensor will just give 8 mV at a ppO2 of 0.21 any more
1680 bz TFT_sensor_mV2 ; the sensor is not too bad yet for a warning 1807 bz TFT_sensor_mV2 ; the sensor is not too bad yet for a warning
1700 bra TFT_display_exit_3 1827 bra TFT_display_exit_3
1701 1828
1702 1829
1703 global TFT_menu_calibrate 1830 global TFT_menu_calibrate
1704 TFT_menu_calibrate: ; update mV data in calibration menu 1831 TFT_menu_calibrate: ; update mV data in calibration menu
1705 btfss s8_digital ; =1: Digital I/O 1832 btfss s8_digital_avail ; do we have a digital S8 interface?
1706 bra TFT_menu_calibrate_analog ; use analog 1833 bra TFT_menu_calibrate_analog ; NO - use analog
1707 btfss new_s8_data_available ; new data frame received? 1834 btfss trigger_S8_data_update ; YES - new data frame received?
1708 bra TFT_menu_calibrate_common ; NO - use old values... 1835 bra TFT_menu_calibrate_common ; NO - use old values...
1709 ; YES - update the values 1836 bcf trigger_S8_data_update ; YES - clear update flag
1710 call compute_mvolts_for_all_sensors 1837 call compute_mvolts_for_all_sensors ; - compute mV values from received data frame
1711 bra TFT_menu_calibrate_common 1838 bra TFT_menu_calibrate_common ; - continue with common part
1712 TFT_menu_calibrate_analog: 1839 TFT_menu_calibrate_analog:
1713 call get_analog_inputs 1840 call get_analog_inputs ; read mV values from analog inputs
1714 TFT_menu_calibrate_common: 1841 TFT_menu_calibrate_common:
1715 call TFT_attention_color ; show in yellow 1842 call TFT_attention_color ; show in yellow
1716 bsf leftbind 1843 bsf leftbind ; align to the left
1717 WIN_SMALL surf_menu_sensor1_column,surf_menu2_sensor1_row 1844 WIN_SMALL surf_menu_sensor1_column,surf_menu2_sensor1_row
1718 movff o2_mv_sensor1+0,lo ; in 0.1mV steps 1845 SMOVII sensor1_mv,mpr ; in 0.1mV steps
1719 movff o2_mv_sensor1+1,hi ; in 0.1mV steps
1720 output_16dp .4 ; xxx.y mV 1846 output_16dp .4 ; xxx.y mV
1721 STRCAT_PRINT "mV " 1847 STRCAT_PRINT "mV "
1722 WIN_SMALL surf_menu_sensor2_column,surf_menu2_sensor2_row 1848 WIN_SMALL surf_menu_sensor2_column,surf_menu2_sensor2_row
1723 movff o2_mv_sensor2+0,lo ; in 0.1mV steps 1849 SMOVII sensor2_mv,mpr ; in 0.1mV steps
1724 movff o2_mv_sensor2+1,hi ; in 0.1mV steps
1725 output_16dp .4 ; xxx.y mV 1850 output_16dp .4 ; xxx.y mV
1726 STRCAT_PRINT "mV " 1851 STRCAT_PRINT "mV "
1727 WIN_SMALL surf_menu_sensor3_column,surf_menu2_sensor3_row 1852 WIN_SMALL surf_menu_sensor3_column,surf_menu2_sensor3_row
1728 movff o2_mv_sensor3+0,lo ; in 0.1mV steps 1853 SMOVII sensor3_mv,mpr ; in 0.1mV steps
1729 movff o2_mv_sensor3+1,hi ; in 0.1mV steps
1730 output_16dp .4 ; xxx.y mV 1854 output_16dp .4 ; xxx.y mV
1731 STRCAT_PRINT "mV " 1855 STRCAT_PRINT "mV "
1732 bra TFT_display_exit_3 1856 bra TFT_display_exit_3
1733 1857
1734 1858 ENDIF ; _external_sensor
1735 global TFT_clock 1859
1736 TFT_clock: 1860 ;=============================================================================
1861
1862 global TFT_time_surfmode
1863 TFT_time_surfmode:
1737 IFDEF _ostc_logo 1864 IFDEF _ostc_logo
1738 WIN_SMALL surf_clock_column,surf_clock_row 1865 WIN_SMALL surf_clock_column,surf_clock_row
1739 ELSE 1866 ELSE
1740 WIN_SMALL surf_clock_column+.7,surf_clock_row 1867 WIN_SMALL surf_clock_column+.7,surf_clock_row
1741 ENDIF 1868 ENDIF
1742 TFT_clock2: ; called from divemode clock 1869 TFT_clock2: ; called from divemode clock
1743 call TFT_standard_color 1870 call TFT_standard_color
1744 movff hours,lo 1871 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
1872 movff rtc_latched_hour,lo
1745 output_99 1873 output_99
1746 movlw ':' 1874 movlw ':'
1747 btfss secs,0 ; blinking every second 1875 movff rtc_latched_secs,lo
1876 btfss lo,0 ; blinking every second
1748 movlw ' ' 1877 movlw ' '
1749 movwf POSTINC2 1878 movwf POSTINC2
1750 movff mins,lo 1879 movff rtc_latched_mins,lo
1751 output_99x 1880 output_99x
1752 STRCAT_PRINT "" 1881 STRCAT_PRINT ""
1753 return 1882 return
1754 1883
1884
1755 global TFT_show_time_date_menu 1885 global TFT_show_time_date_menu
1886 global TFT_show_time_date_menu_fast
1756 TFT_show_time_date_menu: 1887 TFT_show_time_date_menu:
1757 call speed_fastest 1888 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of current date & time
1758 WIN_SMALL .15,.30 1889 TFT_show_time_date_menu_fast:
1890 WIN_SMALL .20,.40 ; column, row - keep clear of the cursor area on the left!
1759 call TFT_standard_color 1891 call TFT_standard_color
1760 movff hours,lo 1892 movff rtc_latched_hour,lo
1761 output_99 1893 output_99
1762 PUTC ':' 1894 PUTC ':'
1763 movff mins,lo 1895 movff rtc_latched_mins,lo
1764 output_99x 1896 output_99x
1765 PUTC ':' 1897 PUTC ':'
1766 movff secs,lo 1898 movff rtc_latched_secs,lo
1767 output_99x 1899 output_99x
1768 STRCAT " - " 1900 STRCAT " "
1769 movff day,lo 1901 movff rtc_latched_day,lo
1770 movff month,hi 1902 movff rtc_latched_month,hi
1771 movff year,up 1903 movff rtc_latched_year,up
1772 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 1904 call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
1773 STRCAT_PRINT " " 1905 STRCAT_PRINT " "
1774 return 1906 return
1775 1907
1776 ;============================================================================= 1908 ;=============================================================================
1777 1909
1797 bra TFT_surface_decosettings2 1929 bra TFT_surface_decosettings2
1798 ; Display ZH-L16-GF low/high model 1930 ; Display ZH-L16-GF low/high model
1799 TFT_surface_decosettings1: 1931 TFT_surface_decosettings1:
1800 TEXT_SMALL surf_gaslist_column+.43,surf_gaslist_row,tZHL16GF 1932 TEXT_SMALL surf_gaslist_column+.43,surf_gaslist_row,tZHL16GF
1801 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) 1933 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)
1802 STRCPY_TEXT tGF ; GF: 1934 STRCPY_TEXT tGF ; GF:
1803 movff opt_GF_low,lo 1935 movff opt_GF_low,lo
1804 output_99x 1936 output_99x
1805 STRCAT "/" 1937 STRCAT "/"
1806 movff opt_GF_high,lo 1938 movff opt_GF_high,lo
1807 output_99x 1939 output_99x
1826 output_8 1958 output_8
1827 bcf leftbind 1959 bcf leftbind
1828 STRCAT_TEXT_PRINT tPercent 1960 STRCAT_TEXT_PRINT tPercent
1829 return 1961 return
1830 1962
1831 global TFT_debug_output
1832 TFT_debug_output:
1833 WIN_TINY .80,.0
1834 call TFT_standard_color
1835 lfsr FSR2,buffer
1836 movff analog_sw1,lo
1837 output_8
1838 PUTC ","
1839 movff analog_sw2,lo
1840 output_8
1841 STRCAT_PRINT ""
1842 return
1843 1963
1844 global TFT_divetimeout ; show timeout counter 1964 global TFT_divetimeout ; show timeout counter
1845 TFT_divetimeout: 1965 TFT_divetimeout:
1846 call TFT_warning_set_window ; set the row and column for the current message 1966 call TFT_set_message_window ; set the row and column for the current message
1847 tstfsz WREG ; is there room for the message? 1967 tstfsz WREG ; is there room for the message?
1848 return ; NO 1968 return ; NO
1849 call TFT_memo_color 1969 call TFT_memo_color
1850 STRCPY 0x94 ; "End of dive" symbol 1970 STRCPY 0x94 ; "End of dive" symbol
1851 movff opt_diveTimeout,WREG ; in [min] 1971 movff opt_diveTimeout,WREG ; in [min]
1852 mullw .60 1972 mullw .60
1853 movff PRODL,sub_a+0 1973 MOVII PRODL, sub_a ; in seconds
1854 movff PRODH,sub_a+1 ; in [s] 1974 MOVII dive_timeout_timer,sub_b
1855 movff timeout_counter1+0,sub_b+0
1856 movff timeout_counter1+1,sub_b+1
1857 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) 1975 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values)
1858 movff sub_c+0,lo 1976 MOVII sub_c,mpr
1859 movff sub_c+1,hi 1977 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
1860 call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) 1978 movf hi,W ; swap lo and hi
1861 movf hi,W 1979 movff lo,hi ; ...
1862 movff lo,hi 1980 movwf lo ; ...
1863 movwf lo ; exchange lo and hi
1864 output_99x 1981 output_99x
1865 PUTC ':' 1982 PUTC ':'
1866 movff hi,lo 1983 movff hi,lo ; copy hi to lo
1867 output_99x 1984 output_99x
1868 movlw dm_warning_length ; divemode string length 1985 movlw dm_warning_length ; dive mode string length
1869 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 1986 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
1870 STRCAT_PRINT "" 1987 STRCAT_PRINT ""
1871 bcf win_invert 1988 bcf win_invert
1872 return 1989 return
1873 1990
1874 global TFT_display_ftts 1991
1875 TFT_display_ftts: 1992 global TFT_show_ftts
1876 call TFT_warning_set_window ; sets the row and column for the current warning 1993 TFT_show_ftts:
1994 call TFT_set_message_window ; sets the row and column for the current warning
1877 tstfsz WREG ; is there room for the message? 1995 tstfsz WREG ; is there room for the message?
1878 return ; NO - done 1996 return ; NO - done
1879 btfsc FLAG_oc_mode ; YES - in OC mode? 1997 btfsc FLAG_oc_mode ; YES - in OC mode?
1880 bra TFT_display_ftts_1 ; YES - print fTTS label 1998 bra TFT_display_ftts_1 ; YES - print fTTS label
1881 TSTOSS opt_calc_asc_gasvolume ; NO - bailout volume calculation requested? 1999 TSTOSS opt_calc_asc_gasvolume ; NO - bailout volume calculation requested?
1887 TFT_display_ftts_2: 2005 TFT_display_ftts_2:
1888 movff char_I_extra_time,lo ; get fTTS delay time 2006 movff char_I_extra_time,lo ; get fTTS delay time
1889 bsf leftbind ; print with alignment to the left 2007 bsf leftbind ; print with alignment to the left
1890 output_8 ; print fTTS delay time 2008 output_8 ; print fTTS delay time
1891 PUTC ":" ; ":" 2009 PUTC ":" ; ":"
1892 movff int_O_alternate_ascenttime+0,lo 2010 MOVII int_O_TTS_alt,mpr ; get alternative TTS
1893 movff int_O_alternate_ascenttime+1,hi
1894 call TFT_memo_color ; set memo color 2011 call TFT_memo_color ; set memo color
1895 btfss hi,int_invalid_flag ; is the invalid flag set? 2012 btfss hi,int_invalid_flag ; is the invalid flag set?
1896 bra TFT_display_ftts_3 ; NO - keep memo color 2013 bra TFT_display_ftts_3 ; NO - keep memo color
1897 bcf hi,int_invalid_flag ; YES - clear flag 2014 bcf hi,int_invalid_flag ; YES - clear flag
1898 call TFT_disabled_color ; - switch to disabled color 2015 call TFT_disabled_color ; - switch to disabled color
1901 bra TFT_display_ftts_4 ; YES - show dashes 2018 bra TFT_display_ftts_4 ; YES - show dashes
1902 movf lo,W 2019 movf lo,W
1903 iorwf hi,W ; extra_ascenttime = 0 ? 2020 iorwf hi,W ; extra_ascenttime = 0 ?
1904 bz TFT_display_ftts_5 ; YES - show "NDL" 2021 bz TFT_display_ftts_5 ; YES - show "NDL"
1905 movff char_O_deco_info,up ; get deco info vector 2022 movff char_O_deco_info,up ; get deco info vector
1906 btfsc up,deco_steady ; fTTS = TTS ? 2023 btfsc up,deco_zone ; fTTS <= TTS ?
1907 call TFT_advice_color ; YES - set to advice color (green) 2024 call TFT_advice_color ; YES - set to advice color (green)
1908 btfsc up,deco_decreasing ; fTTS < TTS ? 2025 output_16 ; print ascent time
1909 call TFT_advice_color ; YES - set to advice color (green) 2026 PUTC "'" ; print minutes symbol
1910 output_16 ; NO - show ascent time
1911 PUTC "'" ; - minutes symbol
1912 bra TFT_display_ftts_6 2027 bra TFT_display_ftts_6
1913 TFT_display_ftts_4: 2028 TFT_display_ftts_4:
1914 STRCAT "---" ; "---" for not computed 2029 STRCAT "---" ; "---" for not computed
1915 bra TFT_display_ftts_6 2030 bra TFT_display_ftts_6
1916 TFT_display_ftts_5: 2031 TFT_display_ftts_5:
1940 WIN_SMALL surf_temp_column,surf_temp_row 2055 WIN_SMALL surf_temp_column,surf_temp_row
1941 call TFT_memo_color 2056 call TFT_memo_color
1942 bra TFT_temp_common 2057 bra TFT_temp_common
1943 2058
1944 2059
1945 global TFT_temp_divemode 2060 global TFT_show_temp_divemode
1946 TFT_temp_divemode: 2061 TFT_show_temp_divemode:
1947 bcf FLAG_TFT_temp_divemode 2062 btfsc dive_options_menu ; is the pre-menu shown?
1948 btfsc divemode_menu ; is the dive mode menu shown? 2063 return ; YES - abort
1949 return ; YES - no update of temperature now 2064 btfsc dive_main_menu ; is the dive mode menu shown?
1950 btfsc blinking_better_gas ; blinking better gas? 2065 return ; YES - abort, no update of temperature now
1951 return ; YES - no update of temperature now 2066 btfsc better_gas_blinking ; blinking better gas?
1952 btfsc blinking_better_dil ; blinking better diluent? 2067 return ; YES - abort, no update of temperature now
1953 return ; YES - no update of temperature now 2068 btfsc better_dil_blinking ; blinking better diluent?
1954 WIN_SMALL dm_temp_column,dm_temp_row 2069 return ; YES - abort, no update of temperature now
1955 call TFT_memo_color 2070
1956 btfsc alternative_divelayout ; in alternative layout? 2071 WIN_SMALL dm_temp_column,dm_temp_row ; set position
1957 bra TFT_temp_common ; YES - proceed with temperature 2072 call TFT_memo_color ; set color
1958 movlw index_compass_dm ; NO - index of compass custom view 2073 movlw index_compass_dm ; index of compass custom view
1959 cpfseq menupos3 ; - compass shown in custom view? 2074 cpfseq active_customview ; compass shown in custom view?
1960 bra TFT_temp_common ; NO - proceed with temperature 2075 bra TFT_temp_common ; NO - proceed with temperature
1961 bra TFT_update_stopwatch ; YES - show resettable dive time instead of temperature 2076 bra TFT_update_stopwatch ; YES - show resettable dive time instead of temperature
1962 TFT_temp_common: 2077 TFT_temp_common:
1963 SAFE_2BYTE_COPY temperature,lo ; get current temperature 2078 SMOVII temperature_cur,mpr ; ISR-safe 2 byte copy of current temperature to hi:lo
1964 TSTOSS opt_units ; 0=°C, 1=°F 2079 TSTOSC opt_units ; 0=°C, 1=°F
1965 bra TFT_temp_common_1 2080 call convert_celsius_to_fahrenheit ; 1 - convert value in lo:hi from Celsius to Fahrenheit
1966 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit 2081 rcall TFT_convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required
1967 TFT_temp_common_1:
1968 rcall TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
1969 btfsc neg_flag ; is the temperature negative? 2082 btfsc neg_flag ; is the temperature negative?
1970 bra TFT_temp_common_2 ; YES - the minus sign has already been written 2083 bra TFT_temp_common_2 ; YES - the minus sign has already been written
1971 ; temp is positive, is it less than 10°C ? 2084 ; temp is positive, is it less than 10°C ?
1972 tstfsz hi 2085 tstfsz hi
1973 bra TFT_temp_common_1a ; >25.5°C, skip here 2086 bra TFT_temp_common_1 ; > 25.5°C, skip here
1974 movlw .100 2087 movlw .100
1975 cpfslt lo 2088 cpfslt lo
1976 bra TFT_temp_common_1a ; >10.0°C, skip here 2089 bra TFT_temp_common_1 ; > 10.0°C, skip here
1977 bsf leftbind 2090 bsf leftbind
1978 output_16dp d'4' ; x.y°C 2091 output_16dp d'4' ; x.y°C
1979 bcf leftbind 2092 bcf leftbind
1980 bra TFT_temp_common_3 ; done 2093 bra TFT_temp_common_3 ; done
1981 TFT_temp_common_1a: 2094 TFT_temp_common_1:
1982 PUTC " " ; NO - write a space instead of the minus sign 2095 PUTC " " ; NO - write a space instead of the minus sign
1983 TFT_temp_common_2: 2096 TFT_temp_common_2:
1984 bsf ignore_digit5 ; ignore decimal (flag will be cleared by output_16) 2097 bsf ignore_digit5 ; ignore decimal (flag will be cleared by output_16)
1985 output_16_3 ; output 0-999 without decimal -> writes ' ' - 99 2098 output_16_3 ; output 0-999 without decimal -> writes ' ' - 99
1986 movff buffer+2,lo ; get output from unit position 2099 movff buffer+2,lo ; get output from unit position
1999 bra TFT_temp_common_5 2112 bra TFT_temp_common_5
2000 TFT_temp_common_4: 2113 TFT_temp_common_4:
2001 STRCAT_TEXT tLogTunitC ; append °C 2114 STRCAT_TEXT tLogTunitC ; append °C
2002 TFT_temp_common_5: 2115 TFT_temp_common_5:
2003 STRCAT_PRINT "" ; output to screen 2116 STRCAT_PRINT "" ; output to screen
2004 return 2117 TFT_temp_common_6:
2118 goto TFT_standard_color ; done
2119
2005 2120
2006 ;============================================================================= 2121 ;=============================================================================
2007 2122
2008 global TFT_divemode_menu_cursor 2123 global TFT_show_menu_cursor_divemode
2009 TFT_divemode_menu_cursor: 2124 TFT_show_menu_cursor_divemode:
2010 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1 2125 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1
2011 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1 2126 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1
2012 call TFT_standard_color 2127 call TFT_standard_color
2013 2128
2014 movlw dm_menu_item1_column-.8 2129 movlw dm_menu_item1_column-.8
2015 btfsc menupos1,2 ; > 3 ? 2130 btfsc menu_pos_cur,2 ; > 3 ?
2016 movlw dm_menu_item4_column-.8 ; YES 2131 movlw dm_menu_item4_column-.8 ; YES
2017 movwf win_leftx2 2132 movwf win_leftx2
2018 2133
2019 movff menupos1,lo ; copy menu position 2134 movff menu_pos_cur,lo ; copy menu position
2020 movlw dm_menu_item6_row 2135 movlw dm_menu_item6_row
2021 dcfsnz lo,F 2136 dcfsnz lo,F
2022 movlw dm_menu_item1_row 2137 movlw dm_menu_item1_row
2023 dcfsnz lo,F 2138 dcfsnz lo,F
2024 movlw dm_menu_item2_row 2139 movlw dm_menu_item2_row
2032 movlw FT_SMALL 2147 movlw FT_SMALL
2033 movwf win_font 2148 movwf win_font
2034 STRCPY_PRINT "\xb7" ; print cursor 2149 STRCPY_PRINT "\xb7" ; print cursor
2035 return 2150 return
2036 2151
2037 2152 ;=============================================================================
2038 global TFT_active_gas_divemode 2153
2039 TFT_active_gas_divemode: ; display gas/setpoint 2154 global TFT_show_active_gas_divemode
2040 bcf FLAG_TFT_active_gas_divemode 2155 TFT_show_active_gas_divemode: ; display gas (OC) or setpoint/ppO2 & gas (CCR, pSCR)
2041 btfsc divemode_menu ; is the dive mode menu shown? 2156 btfsc dive_main_menu ; is the dive mode menu shown?
2042 return ; YES - return 2157 return ; YES - abort
2043 btfsc FLAG_apnoe_mode ; in apnoe mode? 2158 btfsc FLAG_apnoe_mode ; in apnoe mode?
2044 return ; YES - return 2159 return ; YES - done
2045 btfsc FLAG_gauge_mode ; in gauge mode? 2160 btfsc FLAG_gauge_mode ; in gauge mode?
2046 return ; YES - return 2161 return ; YES - done
2047 btfss FLAG_oc_mode ; in OC mode? 2162
2048 bra TFT_active_setpoint ; NO - show setpoint and gas mix 2163 IFDEF _ccr_pscr
2049 bra TFT_active_gas_divemode_oc ; YES - show OC gas 2164 btfsc FLAG_oc_mode ; in OC mode?
2050 2165 bra TFT_active_gas ; YES - show OC gas
2051 TFT_active_setpoint_bail: ; bailout case 2166 ;bra TFT_active_sp ; NO - show setpoint and diluent
2052 tstfsz menupos2 ; any option shown? 2167
2053 bra TFT_active_gas_divemode_oc ; YES - do not overwrite with bailout text 2168 TFT_active_sp:
2169 btfss bailout_mode ; in bailout?
2170 bra TFT_active_sp_loop ; NO
2171 ;bra TFT_active_sp_bailout ; YES
2172
2173 TFT_active_sp_bailout:
2054 WIN_SMALL dm_active_dil_column, dm_active_dil_row 2174 WIN_SMALL dm_active_dil_column, dm_active_dil_row
2055 call TFT_attention_color ; print in yellow 2175 call TFT_attention_color ; - set color
2056 STRCPY_TEXT_PRINT tDiveBailout ; "Bailout" 2176 STRCPY_TEXT_PRINT tDiveBailout ; - print "Bailout"
2057 TFT_active_gas_divemode_oc: ; common part for OC and bailout 2177 bra TFT_active_gas ; - continue showing OC bailout gas
2058 movff int_O_breathed_ppO2+0,lo ; color-code the output of the gas by the ppO2 it yields 2178
2059 movff int_O_breathed_ppO2+1,hi ; 2179 TFT_active_sp_loop:
2060 call TFT_color_code_ppo2 ; with ppO2 [cbar] in hi:lo 2180 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] to hi:lo
2061 btfss better_gas_available ; check if a better gas is available and a gas change shall be advised 2181 call TFT_color_code_ppo2 ; color-code the output by the ppO2 of the loop gas mixture
2182 btfss timebase_1sec ; on even second?
2183 bra TFT_active_sp_print ; YES - print ppO2 with normal rendering
2184 btfsc sp_fallback ; NO - check if in fallback condition
2185 bra TFT_active_sp_fallback ; YES - process fallback case
2186 movff int_O_breathed_ppO2+1,WREG ; NO - get flags again (have been cleared in hi:lo by TFT_color_code_ppo2 meanwhile)
2187 btfss WREG,int_warning_flag ; warning flag set?
2188 bra TFT_active_sp_print ; NO - ppO2 is ok, print ppO2 with normal rendering
2189 bra TFT_active_sp_invers ; YES - print with inverse rendering
2190 TFT_active_sp_fallback: ; set up fallback case
2191 call TFT_attention_color ; set color to yellow
2192 TFT_active_sp_invers: ; blinking common part
2193 bsf win_invert ; print in inverse
2194 TFT_active_sp_print: ; set position
2195 WIN_MEDIUM dm_active_gas_sp_value_col, dm_active_gas_sp_value_row
2196 bsf leftbind ; print left-aligned
2197 output_16dp .3 ; print ppO2 as x.xx
2198 bcf leftbind ; back to right alignment
2199 STRCAT_PRINT "" ; finalize output
2200 bcf win_invert ; end inverse printing
2201
2202 btfsc sign_shown ; advice/attention/warning sign shown?
2203 bra TFT_active_diluent ; YES - skip display of "bar" and loop mode
2204
2205 btfsc velocity_active_vsi ; graphical vertical speed indicator shown?
2206 bra TFT_active_diluent ; YES - skip display of "bar" and loop mode
2207
2208 TFT_active_sp_label:
2209 WIN_STD dm_active_sp_label_col, dm_active_sp_label_row
2210 call TFT_memo_color ; select memo color
2211 STRCAT "bar" ; print "bar"
2212 IFDEF _external_sensor
2213 movff opt_ccr_mode,WREG ; get setpoint mode =0: Fixed SP, =1: Sensor, =2: Auto SP
2214 sublw .1 ; opt_ccr_mode = 1 (Sensor) ?
2215 bnz TFT_active_sp_label_1 ; NO - skip
2216 PUTC "*" ; YES - add "*"
2217 TFT_active_sp_label_1:
2218 ENDIF
2219 STRCAT_PRINT "" ; finalize output
2220
2221 TFT_active_loop_mode:
2222 WIN_TINY dm_active_sp_label_col, dm_active_dil_row+.3
2223 call TFT_memo_color ; set memo color
2224 btfsc FLAG_ccr_mode ; in CCR mode?
2225 bra TFT_active_loop_mode_ccr ; YES - print CCR label
2226 btfsc FLAG_pscr_mode ; in pSCR mode?
2227 bra TFT_active_loop_mode_pscr ; YES - print pSCR label
2228 bra TFT_active_diluent ; NO to both - should not happen
2229 TFT_active_loop_mode_ccr:
2230 STRCPY_TEXT_PRINT tDvCCR ; print "CCR"
2231 bra TFT_active_diluent ; continue with diluent
2232 TFT_active_loop_mode_pscr:
2233 STRCPY_TEXT_PRINT tDvPSCR ; print "pSCR"
2234 ;bra TFT_active_diluent ; continue with diluent
2235
2236 TFT_active_diluent:
2237 MOVII int_O_pure_ppO2,mpr ; get ppO2 [cbar] into hi:lo
2238 call TFT_color_code_ppo2 ; color-code the output
2239 btfss better_dil_available ; better diluent available?
2240 bra TFT_active_diluent_show ; NO - print in normal rendering
2241 btg better_dil_blinking ; YES - toggle blink bit...
2242 btfss better_dil_blinking ; blink now?
2243 bra TFT_active_diluent_show ; NO - print in normal rendering
2244 call TFT_attention_color ; YES - print in yellow color
2245 bsf win_invert ; - print in inverse
2246 TFT_active_diluent_show:
2247 WIN_SMALL dm_active_dil_column, dm_active_dil_row
2248 bra TFT_active_dil_gas_common ; continue with common part
2249 ENDIF ; _ccr_pscr
2250
2251 TFT_active_gas:
2252 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 [cbar] into hi:lo
2253 call TFT_color_code_ppo2 ; color-code the output
2254 btfss better_gas_available ; better gas available?
2062 bra TFT_active_gas_print ; NO - print in normal rendering 2255 bra TFT_active_gas_print ; NO - print in normal rendering
2063 btg blinking_better_gas ; YES - toggle blink bit 2256 btg better_gas_blinking ; YES - toggle blink bit
2064 btfss blinking_better_gas ; blink now? 2257 btfss better_gas_blinking ; blink now?
2065 bra TFT_active_gas_print ; NO - print in normal rendering 2258 bra TFT_active_gas_print ; NO - print in normal rendering
2066 call TFT_attention_color ; YES - blink in yellow 2259 call TFT_attention_color ; YES - blink in yellow
2067 bsf win_invert ; set invert flag 2260 bsf win_invert ; print in inverse
2068 TFT_active_gas_print: 2261 TFT_active_gas_print:
2069 WIN_STD dm_active_gas_column, dm_active_gas_row 2262 WIN_STD dm_active_gas_sp_value_col, dm_active_sp_label_row
2263 TFT_active_dil_gas_common:
2070 movff char_I_O2_ratio,lo ; lo now stores O2 in % 2264 movff char_I_O2_ratio,lo ; lo now stores O2 in %
2265 IFDEF _helium
2071 movff char_I_He_ratio,hi ; hi now stores He in % 2266 movff char_I_He_ratio,hi ; hi now stores He in %
2072 call customview_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 2267 ELSE
2073 STRCAT_PRINT "" 2268 clrf hi ; set hi to zero (no He)
2074 bcf win_invert ; reset invert flag 2269 ENDIF
2075 goto TFT_standard_color ; ...and return 2270 call gaslist_show_mix ; print "Nxlo", "Txlo/hi", "Air" or "O2"
2076 2271 STRCAT_PRINT "" ; finalize output
2077 ; in CCR / pSCR mode - and maybe in bailout 2272 bcf win_invert ; end inverse printing
2078 TFT_active_setpoint: ; 2273 goto TFT_standard_color ; done
2079 btfsc FLAG_bailout_mode ; in bailout? 2274
2080 bra TFT_active_setpoint_bail ; YES - show "Bailout" instead of setpoint 2275 ;=============================================================================
2081 2276
2082 ; on the loop 2277 global TFT_decotype_surface
2083 movff int_O_breathed_ppO2+0,lo ; color-code the output by the ppO2 of the loop gas mixture 2278 TFT_decotype_surface:
2084 movff int_O_breathed_ppO2+1,hi
2085 call TFT_color_code_ppo2 ; with ppO2 [cbar] in hi:lo
2086 btfss secs,0 ; timebase for blinking effect: on even second?
2087 bra TFT_active_setpoint_print ; YES - print ppO2 with normal rendering
2088 btfsc setpoint_fallback ; NO - check if we are in fallback condition
2089 bra TFT_active_setpoint_fallb ; YES - process fallback case
2090 movff int_O_breathed_ppO2+1,WREG ; NO - get flags again (have been cleared in hi:lo by TFT_color_code_ppo2 meanwhile)
2091 btfss WREG,int_warning_flag ; warning flag set?
2092 bra TFT_active_setpoint_print ; NO - ppO2 is ok, print ppO2 with normal rendering
2093 bra TFT_active_setpoint_com ; YES - continue with blinking common part
2094 TFT_active_setpoint_fallb: ; set up fallback case
2095 call TFT_attention_color ; text in yellow
2096 TFT_active_setpoint_com: ; blinking common part
2097 bsf win_invert ; set invert flag
2098 TFT_active_setpoint_print:
2099 WIN_STD dm_active_gas_column, dm_active_gas_row
2100 bsf leftbind
2101 output_16dp .3 ; x.xx bar
2102 bcf leftbind
2103 STRCAT_TEXT tbar
2104 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
2105 sublw .1 ; opt_ccr_mode = 1 (Sensor)?
2106 bnz TFT_active_setpoint2_a ; NO - skip
2107 PUTC "*" ; YES - add an astrix
2108 TFT_active_setpoint2_a:
2109 STRCAT_PRINT ""
2110 bcf win_invert ; reset invert flag
2111 call TFT_memo_color ; revert to memo color
2112 TFT_active_setpoint_diluent: ; diluent gas
2113 movff int_O_pure_ppO2+0,lo ; color-code the output
2114 movff int_O_pure_ppO2+1,hi
2115 call TFT_color_code_ppo2 ; with ppO2 [cbar] in hi:lo
2116 btfss better_dil_available ; check if a better diluent is available and a diluent change shall be advised
2117 bra TFT_active_setpoint_diluent_show ; NO - print in normal rendering
2118 btg blinking_better_dil ; YES - toggle blink bit...
2119 btfss blinking_better_dil ; blink now?
2120 bra TFT_active_setpoint_diluent_show ; NO - print in normal rendering
2121 call TFT_attention_color ; YES - print in yellow color
2122 bsf win_invert ; - set invert flag
2123 TFT_active_setpoint_diluent_show:
2124 WIN_SMALL dm_active_dil_column, dm_active_dil_row
2125 movff char_I_O2_ratio,lo ; lo now stores O2 in %
2126 movff char_I_He_ratio,hi ; hi now stores He in %
2127 call customview_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
2128 STRCAT_PRINT ""
2129 bcf win_invert ; reset invert flag
2130 call TFT_memo_color ; set memo color
2131 btfsc menuview ; is the dive options menu shown?
2132 return ; YES - do not overwrite it
2133 WIN_TINY dm_active_dil_column+.45, dm_active_dil_row+.3
2134 btfsc FLAG_ccr_mode ; in CCR mode?
2135 bra TFT_active_setpoint_ccr ; YES - write CCR label
2136 btfsc FLAG_pscr_mode ; in pSCR mode?
2137 bra TFT_active_setpoint_pscr ; YES - write pSCR label
2138 return ; NO to both - should not happen, anyhow: done
2139 TFT_active_setpoint_ccr:
2140 STRCPY_TEXT_PRINT tDvCCR ; print "CCR"
2141 return ; done
2142 TFT_active_setpoint_pscr:
2143 STRCPY_TEXT_PRINT tDvPSCR ; print "PSCR"
2144 return ; done
2145
2146
2147 global TFT_display_decotype_surface
2148 TFT_display_decotype_surface:
2149 WIN_STD surf_decotype_column,surf_decotype_row 2279 WIN_STD surf_decotype_column,surf_decotype_row
2150 WIN_COLOR color_lightblue 2280 WIN_COLOR color_lightblue
2151 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnoe, 4=PSCR 2281 movff opt_dive_mode,lo ; 0=OC, 1=CCR, 2=Gauge, 3=Apnoe, 4=pSCR
2152 tstfsz lo 2282 tstfsz lo ; in OC mode?
2153 bra TFT_display_decotype_surface2 2283 bra TFT_decotype_surface_2 ; NO
2154 TFT_display_decotype_surface0: 2284 TFT_decotype_surface_1:
2155 STRCAT_TEXT_PRINT tDvOC ; OC 2285 STRCAT_TEXT_PRINT tDvOC ; OC
2156 bra TFT_display_decotype_exit 2286 bra TFT_display_decotype_exit
2157 TFT_display_decotype_surface2: 2287 TFT_decotype_surface_2:
2158 decfsz lo,F 2288 decfsz lo,F ; in CCR mode?
2159 bra TFT_display_decotype_surface3 2289 bra TFT_decotype_surface_3 ; NO
2160 STRCAT_TEXT_PRINT tDvCC ; CC 2290 IFDEF _ccr_pscr
2291 STRCAT_TEXT_PRINT tDvCC ; YES
2161 call TFT_standard_color 2292 call TFT_standard_color
2162 WIN_TINY surf_decotype_column+.18,surf_decotype_row+.12 2293 WIN_TINY surf_decotype_column+.18,surf_decotype_row+.12
2163 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor, =2: Auto SP 2294 TSTOSS opt_ccr_mode ; > 0, i.e. not Fixed SP ?
2164 bra TFT_display_decotype_cc_fixed 2295 bra TFT_display_decotype_cc_fixed ; NO - fixed then
2165 ; Sensor mode or Auto 2296 IFDEF _external_sensor
2166 movff opt_ccr_mode,WREG 2297 ; Sensor or Auto SP mode
2167 sublw .2 2298 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
2168 bz TFT_display_decotype_cc_auto 2299 sublw .2 ; mode = Auto SP ?
2169 STRCPY_TEXT tCCRModeSensor ; sensor 2300 bz TFT_display_decotype_cc_auto ; YES
2170 bra TFT_display_decotype_cc_common 2301 STRCPY_TEXT tCCRModeSensor ; NO - Sensor
2302 bra TFT_display_decotype_cc_common ;
2303 ENDIF ; _external_sensor
2171 TFT_display_decotype_cc_auto: 2304 TFT_display_decotype_cc_auto:
2172 STRCPY_TEXT tCCRModeAutoSP ; Auto SP 2305 STRCPY_TEXT tCCRModeAutoSP ; Auto SP
2173 bra TFT_display_decotype_cc_common 2306 bra TFT_display_decotype_cc_common
2174 TFT_display_decotype_cc_fixed: 2307 TFT_display_decotype_cc_fixed:
2175 STRCPY_TEXT tCCRModeFixedSP ; fixed SP 2308 STRCPY_TEXT tCCRModeFixedSP ; fixed SP
2176 TFT_display_decotype_cc_common: 2309 TFT_display_decotype_cc_common:
2177 clrf WREG 2310 clrf WREG
2178 movff WREG,buffer+.8 ; limit string length to 8 2311 movff WREG,buffer+.8 ; limit string length to 8
2179 STRCAT_PRINT "" 2312 STRCAT_PRINT ""
2180 bra TFT_display_decotype_exit 2313 bra TFT_display_decotype_exit
2181 TFT_display_decotype_surface3: 2314 ENDIF ; _ccr_pscr
2182 decfsz lo,F 2315 TFT_decotype_surface_3:
2183 bra TFT_display_decotype_surface4 2316 decfsz lo,F ; in gauge mode?
2184 TFT_display_decotype_surface3_1: 2317 bra TFT_decotype_surface_4 ; NO
2185 STRCAT_TEXT_PRINT tDvGauge ; Gauge 2318 TFT_decotype_surface_3_1: ; YES
2319 STRCAT_TEXT_PRINT tDvGauge
2186 bra TFT_display_decotype_exit 2320 bra TFT_display_decotype_exit
2187 TFT_display_decotype_surface4: 2321 TFT_decotype_surface_4:
2188 decfsz lo,F 2322 decfsz lo,F ; in apnea mode?
2189 bra TFT_display_decotype_surface5 2323 bra TFT_decotype_surface_5 ; NO
2190 TFT_display_decotype_surface4_1: 2324 TFT_decotype_surface_4_1: ; YES
2191 STRCAT_TEXT_PRINT tDvApnea ; Apnea 2325 STRCAT_TEXT_PRINT tDvApnea
2192 bra TFT_display_decotype_exit 2326 bra TFT_display_decotype_exit
2193 TFT_display_decotype_surface5: 2327 TFT_decotype_surface_5:
2194 STRCAT_TEXT_PRINT tDvPSCR ; pSCR 2328 STRCAT_TEXT_PRINT tDvPSCR ; last but not least: must be pSCR then
2195 TFT_display_decotype_exit: 2329 TFT_display_decotype_exit:
2196 goto TFT_standard_color ; and return... 2330 goto TFT_standard_color ; and return...
2197 2331
2198 2332
2199 global TFT_display_decotype_surface1 2333 global TFT_decotype_logbook
2200 TFT_display_decotype_surface1: ; used from logbook and from deco calculator (simulator.asm) 2334 TFT_decotype_logbook: ; used from logbook and from deco calculator (simulator.asm)
2201 tstfsz lo ; lo holds 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR 2335 bsf aux_flag ; default to dive with deco calculation
2202 bra TFT_display_decotype_surface1_2 2336 tstfsz lo ; lo holds 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR, in OC mode?
2203 bra TFT_display_decotype_surface0 ; OC 2337 bra TFT_decotype_logbook_1_2 ; NO
2204 TFT_display_decotype_surface1_2: 2338 bra TFT_decotype_surface_1 ; YES - OC
2205 decfsz lo,F 2339 TFT_decotype_logbook_1_2:
2206 bra TFT_display_decotype_surface1_3 2340 decfsz lo,F ; in CCR mode?
2207 STRCAT_TEXT_PRINT tDvCC ; CC 2341 bra TFT_decotype_logbook_1_3 ; NO
2208 bra TFT_display_decotype_exit 2342 STRCAT_TEXT_PRINT tDvCC ; YES - print "CCR"
2209 TFT_display_decotype_surface1_3: 2343 bra TFT_display_decotype_exit ; - done
2210 decfsz lo,F 2344 TFT_decotype_logbook_1_3:
2211 bra TFT_display_decotype_surface1_4 2345 decfsz lo,F ; in gauge mode?
2212 bra TFT_display_decotype_surface3_1 ; Gauge 2346 bra TFT_decotype_logbook_1_4 ; NO
2213 TFT_display_decotype_surface1_4: 2347 bcf aux_flag ; YES - dive without deco data
2214 decfsz lo,F 2348 bra TFT_decotype_surface_3_1 ; - gauge
2215 bra TFT_display_decotype_surface5 ; pSCR 2349 TFT_decotype_logbook_1_4:
2216 bra TFT_display_decotype_surface4_1 ; Apnea 2350 decfsz lo,F ; in apnea mode?
2351 bra TFT_decotype_logbook_1_5 ; NO
2352 bcf aux_flag ; YES - dive without deco data
2353 bra TFT_decotype_surface_4_1 ; - apnea
2354 TFT_decotype_logbook_1_5:
2355 bra TFT_decotype_surface_5 ; last but not least: must be pSCR then
2217 2356
2218 ;============================================================================= 2357 ;=============================================================================
2358
2359 IFDEF _ccr_pscr
2219 2360
2220 global TFT_splist_surfmode ; show setpoint list 2361 global TFT_splist_surfmode ; show setpoint list
2221 TFT_splist_surfmode: 2362 TFT_splist_surfmode:
2222 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint 2363 bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint
2223 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) 2364 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
2224 ;SP 1 2365 ;SP 1
2225 WIN_SMALL surf_gaslist_column,surf_gaslist_row 2366 WIN_SMALL surf_gaslist_column,surf_gaslist_row
2226 clrf PRODL 2367 clrf PRODL
2227 call gaslist_strcat_setpoint ; show SP#+1 of PRODL# 2368 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2251 call gaslist_strcat_setpoint ; show SP#+1 of PRODL# 2392 call gaslist_strcat_setpoint ; show SP#+1 of PRODL#
2252 STRCAT_PRINT "" 2393 STRCAT_PRINT ""
2253 bcf leftbind 2394 bcf leftbind
2254 return 2395 return
2255 2396
2397 ENDIF
2398
2399 ;=============================================================================
2400
2256 global TFT_gaslist_surfmode 2401 global TFT_gaslist_surfmode
2257 TFT_gaslist_surfmode: ; displays gas list 2402 TFT_gaslist_surfmode: ; displays gas list
2258 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint 2403 bsf short_gas_descriptions ; use short versions of gaslist_strcat_gas_cd and gaslist_strcat_setpoint
2259 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only) 2404 bcf better_gas_hint ; do not mark the best gas/diluent (to be used in dive mode only)
2260 ;Gas 1 2405 ;Gas 1
2261 WIN_SMALL surf_gaslist_column,surf_gaslist_row 2406 WIN_SMALL surf_gaslist_column,surf_gaslist_row
2262 clrf PRODL 2407 clrf PRODL
2263 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string 2408 call gaslist_strcat_gas_cd ; append gas description of gas #PRODL (0-4) to current string
2288 STRCAT_PRINT "" 2433 STRCAT_PRINT ""
2289 bcf leftbind 2434 bcf leftbind
2290 bcf win_invert ; clear flag for inverted output 2435 bcf win_invert ; clear flag for inverted output
2291 return 2436 return
2292 2437
2438 ;=============================================================================
2439
2440 IFDEF _ccr_pscr
2441
2293 global TFT_dillist_surfmode 2442 global TFT_dillist_surfmode
2294 TFT_dillist_surfmode: ; displays diluent list 2443 TFT_dillist_surfmode: ; displays diluent list
2295 bsf FLAG_diluent_setup ; use CCR diluents... 2444 bsf is_diluent_menu ; enable using diluents
2296 rcall TFT_gaslist_surfmode ; use OC/BAIL routine 2445 rcall TFT_gaslist_surfmode ; use OC gas routine
2297 bcf FLAG_diluent_setup ; clear flag 2446 bcf is_diluent_menu ; disable using diluents
2298 return 2447 return
2299 2448
2449 ENDIF
2450
2300 ;================================================================== 2451 ;==================================================================
2301 2452
2302 global TFT_depth 2453 global TFT_show_depth
2303 TFT_depth: 2454 TFT_show_depth:
2304 bcf FLAG_TFT_depth 2455 MOVII pressure_rel_cur_cached,mpr ; copy relative pressure to hi:lo
2305 SAFE_2BYTE_COPY rel_pressure, lo 2456 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
2306 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] 2457 call TFT_color_code_depth ; set warning / attention flags and color-code the output
2307 call TFT_color_code_depth ; color-code the output 2458 rcall TFT_depth_blink ; control animation (blinking)
2308 rcall TFT_depth_blink 2459 rcall TFT_depth_position_m_ft ; set output position
2309 WIN_LARGE dm_depth_column, dm_depth_row 2460
2310 TSTOSS opt_units ; 0=m, 1=ft 2461 TSTOSS opt_units ; 0=m, 1=ft ?
2311 bra TFT_depth_metric 2462 bra TFT_depth_metric ; 0 - metric
2312 ;TFT_depth_imperial 2463 ;bra TFT_depth_imperial ; 1 - imperial
2313 clrf sub_a+1 ; display 0ft if lower then 30cm 2464
2314 movlw d'30' 2465 TFT_depth_imperial:
2315 movwf sub_a+0 2466 MOVLI .30,sub_a ; display 0 ft if shallower than 30 cm
2316 movff hi,sub_b+1 2467 MOVII mpr,sub_b
2317 movff lo,sub_b+0 2468 call cmpU16 ; compare (sub_a - sub_b)
2318 call subU16 ; sub_c = sub_a - sub_b 2469 btfss neg_flag ; depth shallower than 30 cm ?
2319 btfss neg_flag ; depth lower then 0.4m? 2470 bra depth_0_feet ; YES - print a zero directly
2320 bra depth_less_0.3mtr_feet ; YES - show 0ft manually 2471 call convert_mbar_to_feet ; NO - convert value in hi:lo from mbar to feet
2321 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 2472 bsf leftbind ; - print left-aligned
2322 bsf leftbind 2473 output_16 ; - feet in large or huge font
2323 output_16 ; feet in Big font 2474 bcf leftbind ; - reset alignment
2324 bcf leftbind 2475 movlw .3 ; - limit to three chars
2325 movlw .3 ; limit to three chars 2476 call TFT_fillup_with_spaces ; - fill up FSR2 with spaces
2326 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 2477 STRCAT_PRINT "" ; - finalize output
2327 STRCAT_PRINT "" ; display feet 2478 TFT_depth_imperial_1:
2479 bcf win_invert ; - reset invert flag
2480 bra TFT_depth_exit ; - show target depth if in simulator mode and return
2481
2482 depth_0_feet:
2483 STRCAT_PRINT "0 " ; print a zero directly
2484 bra TFT_depth_imperial_1 ; continue with common part
2485
2486 TFT_depth_metric:
2487 ; full meters
2488 MOVLI .9999,sub_a ; 9999 mbar = 99.99 m
2489 MOVII mpr, sub_b ; current depth
2490 call cmpU16 ; compare (sub_a - sub_b)
2491 btfsc neg_flag ; current depth < 100 meter ?
2492 bra TFT_depth_metric_100m ; NO - current depth >= 100 meter
2493
2494 btfsc cur_depth_greater_100m ; was the current depth >= 100 meter during last call?
2495 rcall TFT_depth_box_black ; YES - clear depth area
2496 bcf cur_depth_greater_100m ; current depth is now < 100 meter
2497
2498 MOVLI .999,sub_a ; 999 mbar = 9.99 meter
2499 MOVII mpr, sub_b ; current depth
2500 call cmpU16 ; compare (sub_a - sub_b)
2501 movlw ' ' ; load coding of a space char
2502 btfss neg_flag ; current depth < 10 meter ?
2503 movwf POSTINC2 ; YES - print a leading space char
2504
2505 MOVLI .99,sub_a ; 99 mbar = 99 cm
2506 MOVII mpr,sub_b ; current depth
2507 call cmpU16 ; compare (sub_a - sub_b)
2508 btfss neg_flag ; current depth < 1 meter ?
2509 bra TFT_depth_metric_0m ; YES - (1)
2510 bsf ignore_digit4 ; NO - show depth in full meters, i.e. ignore digits 4 and 5
2511 bsf leftbind ; - print left-aligned
2512 output_16 ; - print depth
2513 bcf leftbind ; - reset alignment
2514 bra TFT_depth_metric_com ; - continue with common part
2515 TFT_depth_metric_0m:
2516 STRCAT "0" ; (1) - print a zero directly
2517 TFT_depth_metric_com:
2518 STRCAT_PRINT "" ; finalize output
2519
2520 ; decimeters
2521 rcall TFT_depth_position_dm ; set output position
2522 PUTC "." ; print a decimal point
2523 MOVLI .30,sub_a ; 30 mbar = 0.3 meter
2524 MOVII mpr,sub_b ; current depth
2525 call cmpU16 ; compare (sub_a - sub_b)
2526 btfss neg_flag ; current depth < 0.3 meter ?
2527 bra depth_0_decimeter ; YES - (2)
2528 movlw d'4' ; NO - omit leading digits holding the meters
2529 movwf ignore_digits ; - ...
2530 bsf ignore_digit5 ; - omit last digit holding the centimeters
2531 output_16dp d'0' ; - print decimeters only
2532 STRCAT_PRINT "" ; - finalize output
2533 bcf win_invert ; - reset invert flag
2534 bra TFT_depth_exit ; - show target depth if in simulator mode and return
2535 depth_0_decimeter:
2536 STRCAT_PRINT "0" ; (2) - print a zero directly and finalize output
2537 bcf win_invert ; - reset invert flag
2538 bra TFT_depth_exit ; - show target depth if in simulator mode and return
2539
2540 TFT_depth_metric_100m: ; show full meters only
2541 btfss cur_depth_greater_100m ; was the current depth >= 100 meter during last call?
2542 rcall TFT_depth_box_black ; NO - clear depth area
2543 bsf cur_depth_greater_100m ; depth is >= 100 meter now
2544 bsf ignore_digit4 ; show depth in full meters, i.e. ignore digits 4 and 5
2545 bsf leftbind ; print left-aligned
2546 output_16 ; print depth
2547 bcf leftbind ; reset alignment
2548 STRCAT_PRINT "" ; finalize output
2328 bcf win_invert ; reset invert flag 2549 bcf win_invert ; reset invert flag
2329 return 2550 bra TFT_depth_exit ; show target depth if in simulator mode and return
2330
2331 depth_less_0.3mtr_feet:
2332 STRCAT_PRINT "0 " ; manual zero
2333 bcf win_invert ; reset invert flag
2334 return
2335
2336 TFT_depth_metric:
2337 movlw .039
2338 cpfslt hi
2339 bra depth_greater_99_84mtr
2340
2341 btfsc depth_greater_100m ; was depth > 100m during last call?
2342 rcall TFT_clear_depth ; YES - clear depth area
2343 bcf depth_greater_100m ; do this once only...
2344
2345 movlw .039
2346 cpfslt hi
2347 bra depth_greater_99_84mtr
2348
2349 movlw HIGH d'1000'
2350 movwf sub_a+1
2351 movlw LOW d'1000'
2352 movwf sub_a+0
2353 movff hi,sub_b+1
2354 movff lo,sub_b+0
2355 incf sub_b+0,F
2356 movlw d'0'
2357 addwfc sub_b+1,F ; add 1mbar offset
2358 call sub16 ; sub_c = sub_a - sub_b
2359 movlw ' '
2360 btfss neg_flag ; depth lower then 10m?
2361 movwf POSTINC2 ; YES - add extra space
2362
2363 clrf sub_a+1
2364 movlw d'99'
2365 movwf sub_a+0
2366 movff hi,sub_b+1
2367 movff lo,sub_b+0
2368 call subU16 ; sub_c = sub_a - sub_b
2369 btfss neg_flag ; depth lower then 1m?
2370 bra tft_depth2 ; YES - display manual Zero
2371
2372 bsf leftbind
2373 bsf ignore_digit4
2374 output_16 ; full meters in big font
2375 bcf leftbind
2376 bra tft_depth3
2377
2378 tft_depth2:
2379 STRCAT "0" ; manual zero
2380
2381 tft_depth3:
2382 STRCAT_PRINT "" ; display full meters
2383
2384 ; .1m in MEDIUM font
2385 WIN_MEDIUM dm_depth_dm_column, dm_depth_dm_row
2386
2387 SAFE_2BYTE_COPY rel_pressure, lo
2388 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
2389 ;call TFT_color_code_depth ; color-code the output - not needed, furthermore: seems to cause problems if not commented out...
2390
2391 PUTC "."
2392 movlw HIGH d'30' ; display 0.0m if lower then 30cm
2393 movwf sub_a+1
2394 movlw LOW d'30'
2395 movwf sub_a+0
2396 movff hi,sub_b+1
2397 movff lo,sub_b+0
2398 call subU16 ; sub_c = sub_a - sub_b
2399 btfss neg_flag ; depth lower then 0.3m?
2400 bra depth_less_0.3mtr ; YES - show ".0" manually
2401
2402 movlw d'4'
2403 movwf ignore_digits
2404 bsf ignore_digit5 ; (flag will be cleared by output_16)
2405 output_16dp d'0'
2406 STRCAT_PRINT "" ; display decimeters
2407 bcf win_invert ; reset invert flag
2408 WIN_FONT FT_SMALL
2409 return
2410
2411 depth_less_0.3mtr:
2412 STRCAT_PRINT "0" ; display 0.0m manually
2413 bcf win_invert ; reset invert flag
2414 WIN_FONT FT_SMALL
2415 return
2416
2417 depth_greater_99_84mtr: ; display only in full meters
2418 btfss depth_greater_100m ; is depth > 100m already?
2419 rcall TFT_clear_depth ; NO - clear depth area and set flag
2420 call TFT_color_code_depth
2421 ; Depth is already in hi:lo
2422 ; Show depth in Full meters
2423 ; That means ignore digit 4 and 5
2424 lfsr FSR2,buffer
2425 bsf ignore_digit4
2426 bsf leftbind
2427 output_16
2428 bcf leftbind
2429 STRCAT_PRINT "" ; display full meters only
2430 bcf win_invert ; reset invert flag
2431 WIN_FONT FT_SMALL
2432 return
2433
2434 TFT_clear_depth: ; NO - clear depth area and set flag
2435 WIN_BOX_BLACK dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt ;top, bottom, left, right
2436 bsf depth_greater_100m ; set flag
2437 return
2438 2551
2439 TFT_depth_blink: 2552 TFT_depth_blink:
2440 TSTOSS opt_modwarning ; 0=standard, 1=blink 2553 TSTOSS opt_modwarning ; 0=standard, 1=blink
2441 return 2554 return ; standard, done
2442 2555 btfsc depth_warn_att_last ; was there a warning or attention on the depth in the previous cycle?
2443 ; check if previous cycle had the blinking warning or not 2556 bra TFT_depth_blink_prev ; YES
2444 btfsc blinking_depth_prev ; did we have warning previously? 2557 btfsc depth_warning ; NO - do we have a depth warning now?
2445 bra TFT_depth_blink_prevwarn; YES 2558 bra TFT_depth_blink_new ; YES - so we have a warning now but not previously
2446 2559 btfsc depth_attention ; NO - do we have a depth attention now?
2447 ; NO - check if it's set now 2560 bra TFT_depth_blink_new ; YES - so we have attention now but not previously
2448 btfsc blinking_depth_warning ; do we have warning set now? 2561 bra TFT_depth_blink_none ; NO - no warning in previous cycle, no warning now, reset all flags
2449 bra TFT_depth_blink_warn ; YES - so we have warning now but not previously 2562
2450 btfsc blinking_depth_attention; do we have attention set now? 2563 TFT_depth_blink_prev:
2451 bra TFT_depth_blink_warn ; YES - so we have attention now but not previously 2564 ; we had a warning or attention in previous cycle, check if we still have a warning or attention
2452 2565 btfsc depth_warning ; do we still have a warning?
2453 ; no warning in previous cycle, no warning now, reset all flags 2566 bra TFT_depth_blink_prev_1 ; YES
2454 bcf blinking_depth_prev ; reset previous flag 2567 btfsc depth_attention ; NO - do we still have an attention?
2455 bcf blinking_depth_toggle ; reset toggle 2568 bra TFT_depth_blink_prev_1 ; YES
2456 bcf win_invert 2569 ; we had a warning or attention before, but not now any more - clear depth area from previous color
2457 return ; all done 2570 rcall TFT_depth_box_black ; NO - clear depth area
2458 2571 ;bra TFT_depth_blink_none ; - reset all flags
2459 TFT_depth_blink_prevwarn: 2572
2460 ; ...we had warning in previous cycle, check if we still have the warning set 2573 TFT_depth_blink_none:
2461 btfsc blinking_depth_warning ; do we still have the warning? 2574 bcf win_invert ; print non-inverted
2462 bra TFT_depth_blink_prevwarn_1 ; YES 2575 bcf depth_inverse_last ; memorize depth was printed in normal
2463 btfss blinking_depth_attention ; do we still have the attention? 2576 bcf depth_warn_att_last ; memorize there was no warning or attention
2464 bra TFT_depth_blink_prevwarn_nowarn ; NO - clear the depth area 2577 goto TFT_memo_color ; select memo color and return
2465 TFT_depth_blink_prevwarn_1: 2578
2466 ; we still have the warning, set previous flag for next cycle... 2579 TFT_depth_blink_prev_1:
2467 bsf blinking_depth_prev ; set prev flag 2580 ; we had a warning or attention in previous cycle, and we still have a warning or attention
2468 ; and set toggle and invert if required 2581 btfss depth_inverse_last ; was the depth printed in inverse last time?
2469 btfss blinking_depth_toggle ; do we have the toggle set? 2582 bra TFT_depth_blink_set ; NO - print in inverse now
2470 bra TFT_depth_blink_set ; NO - set inverse, do color_box, set flag 2583 bra TFT_depth_blink_reset ; YES - print in normal now
2471 bra TFT_depth_blink_reset ; Yes - clear inverse, do black box, reset flag 2584
2472 2585 TFT_depth_blink_new:
2473 TFT_depth_blink_prevwarn_nowarn: 2586 ; we had no warning or attention in previous cycle, but now
2474 ; we had warning, but not now... (e.g. ascended or switched to better gas) 2587 bsf depth_warn_att_last ; memorize that the depth had a warning or attention
2475 ; reset the previous cycle flag for the next cycle... 2588 ;bra TFT_depth_blink_set ; start with inverse display
2476 bcf blinking_depth_prev ; reset prev flag
2477 ; clear it - just in case if we had a blinked before
2478 bra TFT_depth_blink_reset ; clear inverse, do black box, reset flag
2479
2480 TFT_depth_blink_warn:
2481 ; new blinking warning activated (had no warning in previous cycle)
2482 bsf blinking_depth_prev ; set prev flag
2483 ;bra TFT_depth_blink_set ; set toggle and invert
2484 2589
2485 TFT_depth_blink_set: 2590 TFT_depth_blink_set:
2486 ; clear the area with color 2591 ; fill the area with respective color
2487 call TFT_attention_color_dive ; default background to attention color 2592 call TFT_attention_color_dive ; select attention color as default
2488 btfsc blinking_depth_warning ; in warning mode? 2593 btfsc depth_warning ; do we have a warning?
2489 call TFT_warnings_color_dive ; overwrite background color with warning color 2594 call TFT_warnings_color_dive ; YES - replace with warning color
2490 WIN_BOX_COLOR dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt ;top, bottom, left, right 2595 rcall TFT_depth_box_color ; color depth area
2491 bsf win_invert ;set the invert color 2596 bsf win_invert ; print in inverse
2492 bsf blinking_depth_toggle ; set the toggle 2597 bsf depth_inverse_last ; memorize depth was printed in inverse
2493 return ; all done 2598 return ; done
2494 2599
2495 TFT_depth_blink_reset: 2600 TFT_depth_blink_reset:
2496 ; clear the area with black 2601 ; fill the area with black color
2497 WIN_BOX_BLACK dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt ;top, bottom, left, right 2602 rcall TFT_depth_box_black ; clear depth area
2498 bcf win_invert ; reset the invert color 2603 bcf win_invert ; print non-inverted
2499 bcf blinking_depth_toggle ; reset the toggle 2604 bcf depth_inverse_last ; memorize depth was printed in normal
2500 call TFT_attention_color ; default to attention color 2605 return ; done
2501 btfsc blinking_depth_warning ; do we have a warning? 2606
2502 call TFT_warnings_color ; YES - overwrite with warning color 2607
2503 return ; all done 2608 TFT_depth_position_m_ft:
2609 btfsc alt_layout_active ; alternative layout active?
2610 bra TFT_depth_position_m_ft_alt ; YES - (1)
2611 WIN_LARGE dm_depth_col_large,dm_depth_row_large ; NO - normal layout
2612 return ; - done
2613 TFT_depth_position_m_ft_alt:
2614 WIN_HUGE dm_depth_col_huge, dm_depth_row_huge ; (1) - alternative layout
2615 return ; - done
2616
2617 TFT_depth_position_dm:
2618 btfsc alt_layout_active ; alternative layout active?
2619 bra TFT_depth_position_dm_alt ; YES - (1)
2620 WIN_MEDIUM dm_depth_dm_col_medium, dm_depth_dm_row_medium ; NO - normal layout
2621 return ; - done
2622 TFT_depth_position_dm_alt:
2623 WIN_LARGE dm_depth_dm_col_large, dm_depth_dm_row_large ; (1) - alternative layout
2624 return ; - done
2625
2626 TFT_depth_box_black:
2627 clrf WREG ; select black color
2628 TFT_depth_box_color:
2629 movff win_color1,mpr+2 ; backup output color
2630 movff win_color2,mpr+3 ; ...
2631 btfsc alt_layout_active ; alternative layout active?
2632 bra TFT_depth_box_alt ; YES - (1)
2633 WIN_BOX_COLOR dm_depth_row_large,dm_depth_bot_large,dm_depth_col_large,dm_depth_rgt_large ; NO - top, bottom, left, right
2634 bra TFT_depth_box_exit ; - continue with common part
2635 TFT_depth_box_alt:
2636 WIN_BOX_COLOR dm_mask_depth_row, dm_depth_bot_huge, dm_depth_col_huge, dm_depth_rgt_huge ; (1) - full meters area
2637 TFT_depth_box_exit:
2638 movff mpr+2,win_color1 ; restore output color
2639 movff mpr+3,win_color2 ; ...
2640 return ; done
2641
2642 TFT_depth_exit:
2643 btfss alt_layout_active ; alternative layout active?
2644 bra TFT_depth_exit_1 ; NO
2645 btfsc depth_inverse_last ; YES - was last output in inverse mode?
2646 bra TFT_depth_exit_1 ; YES
2647 call TFT_divemask_color ; NO - set color
2648 WIN_TINY dm_mask_depth_column_alt,dm_mask_depth_row ; - set position
2649 STRCAT_TEXT_PRINT tDepth ; - restore "Depth" title
2650 TFT_depth_exit_1:
2651 btfss sensor_override_active ; pressure sensor override active (simulator mode)?
2652 goto TFT_standard_color ; NO - done
2653 ;bra TFT_depth_target ; YES - show target depth
2654
2655 TFT_depth_target: ; show simulated target depth
2656 call TFT_attention_color ; select attention color
2657 TSTOSS opt_units ; check unit selection (0=m or 1=ft)
2658 bra TFT_depth_target_metric ; 0 - metric
2659 ;bra TFT_depth_target_imperial ; 1 - imperial
2660
2661 TFT_depth_target_imperial:
2662 btfsc alt_layout_active ; alternative layout active?
2663 bra TFT_depth_target_imperial_alt ; YES
2664 ;bra TFT_depth_target_imperial_norm ; NO
2665
2666 TFT_depth_target_imperial_norm:
2667 WIN_TINY dm_mask_depth_column+.40,dm_mask_depth_row ; position right of depth label
2668 bra TFT_depth_target_imperial_com ; continue with common part
2669
2670 TFT_depth_target_imperial_alt:
2671 WIN_TINY dm_mask_depth_column+.62,dm_mask_depth_row+.20 ; position within last digit
2672 ;bra TFT_depth_target_imperial_com ; continue with common part
2673
2674 TFT_depth_target_imperial_com:
2675 movff simulatormode_depth,lo ; copy target depth to lo
2676 call convert_meter_to_feet ; convert value in lo from meters to feet
2677 output_16_3 ; display only last three digits from a 16 bit value (0-999)
2678 STRCAT_PRINT "ft" ; finalize output
2679 goto TFT_standard_color ; done
2680
2681 TFT_depth_target_metric:
2682 btfsc alt_layout_active ; alternative layout active?
2683 bra TFT_depth_target_metric_alt ; YES
2684 ;bra TFT_depth_target_metric_norm ; NO
2685
2686 TFT_depth_target_metric_norm:
2687 WIN_TINY dm_mask_depth_column+.38,dm_mask_depth_row+.22 ; position right of full meters, above decimal
2688 bra TFT_depth_target_metric_com ; continue with common part
2689
2690 TFT_depth_target_metric_alt:
2691 WIN_TINY dm_mask_depth_column+.65,dm_mask_depth_row+.20 ; position right of full meters, above decimal
2692 ;bra TFT_depth_target_metric_com ; continue with common part
2693
2694 TFT_depth_target_metric_com:
2695 movff simulatormode_depth,lo ; copy target depth to lo
2696 output_8 ; display number
2697 STRCAT_PRINT "m" ; finalize output
2698 goto TFT_standard_color ; done
2504 2699
2505 ;============================================================================= 2700 ;=============================================================================
2506 2701
2507 global TFT_custom_text 2702 global TFT_custom_text
2508 TFT_custom_text: ; show the custom text 2703 TFT_custom_text: ; show the custom text
2509 call TFT_standard_color
2510 lfsr FSR0, opt_name ; source 2704 lfsr FSR0, opt_name ; source
2511 WIN_SMALL surf_customtext_column,surf_customtext_row1 ; 1st row 2705 WIN_SMALL surf_customtext_column,surf_customtext_row1 ; 1st row
2512 rcall TFT_custom_text_2 ; show up to 12 chars and print 2706 rcall TFT_custom_text_2 ; show up to 12 chars and print
2513 incfsz lo,F ; was lo=255? 2707 incfsz lo,F ; was lo=255?
2514 return ; NO - all done 2708 return ; NO - all done
2527 rcall TFT_custom_text_2 ; show up to 12 chars and print 2721 rcall TFT_custom_text_2 ; show up to 12 chars and print
2528 incfsz lo,F ; was lo=255? 2722 incfsz lo,F ; was lo=255?
2529 return ; NO - all done 2723 return ; NO - all done
2530 lfsr FSR0, opt_name+.48 ; source 2724 lfsr FSR0, opt_name+.48 ; source
2531 WIN_SMALL surf_customtext_column,surf_customtext_row5 ; 5th row 2725 WIN_SMALL surf_customtext_column,surf_customtext_row5 ; 5th row
2532 bra TFT_custom_text_2 ; show up to 12 chars, print and return... 2726 ;bra TFT_custom_text_2 ; show up to 12 chars, print and return...
2533
2534 2727
2535 TFT_custom_text_2: 2728 TFT_custom_text_2:
2536 lfsr FSR2, buffer ; destination 2729 lfsr FSR2, buffer ; destination
2537 movlw .12 2730 movlw .12
2538 movwf lo ; length/line 2731 movwf lo ; length/line
2548 goto aa_wordprocessor ; print and return 2741 goto aa_wordprocessor ; print and return
2549 2742
2550 2743
2551 ;============================================================================= 2744 ;=============================================================================
2552 2745
2553 global TFT_update_surf_press 2746 global TFT_pres_surfmode
2554 TFT_update_surf_press: 2747 TFT_pres_surfmode:
2555 WIN_SMALL surf_press_column+.8,surf_press_row 2748 WIN_SMALL surf_press_column+.8,surf_press_row
2556 call TFT_standard_color 2749 call TFT_standard_color
2557 SAFE_2BYTE_COPY amb_pressure, lo 2750 SMOVII pressure_abs, sub_a ; make ISR-safe 2 byte copy of current absolute pressure to sub_a
2558 movff lo,sub_a+0 2751 MOVII pressure_abs_ref,sub_b ; copy absolute pressure from 30 minutes ago to sub_b
2559 movff hi,sub_a+1 2752 MOVII sub_a,mpr ; store current pressure also in hi:lo for output
2560 movff last_surfpressure_30min+0,sub_b+0
2561 movff last_surfpressure_30min+1,sub_b+1
2562 call subU16 ; sub_c = sub_a - sub_b 2753 call subU16 ; sub_c = sub_a - sub_b
2563 btfsc neg_flag ; pressure lower? 2754 btfsc neg_flag ; pressure lower?
2564 rcall update_surf_press2 ; YES - test threshold 2755 rcall update_surf_press2 ; YES - swap arguments
2565 tstfsz sub_c+1 ; >255 mbar difference? 2756 tstfsz sub_c+1 ; > 255 mbar difference?
2566 bra update_surf_press_common ; YES - display 2757 bra update_surf_press_common ; YES - display
2567 movlw d'11' ; 10mbar noise suppression 2758 movlw .11 ; 10 mbar noise suppression margin
2568 subwf sub_c+0,W 2759 subwf sub_c+0,W
2569 btfsc STATUS,C 2760 btfsc STATUS,C
2570 bra update_surf_press_common ; YES - display 2761 bra update_surf_press_common ; YES - display
2571 SAFE_2BYTE_COPY last_surfpressure_30min, lo ; overwrite with stable value... 2762 MOVII pressure_abs_ref,mpr ; NO - overwrite with stable value
2572 update_surf_press_common: 2763 update_surf_press_common:
2573 movff lo,int_I_pres_surface+0 ; copy displayed value to C code to have pressure displayed
2574 movff hi,int_I_pres_surface+1 ; and pressure used for desaturation & no-fly time in sync
2575 output_16 2764 output_16
2576 ; Show only 4 digits 2765 ; Show only 4 digits
2577 movff buffer+1,buffer+0 2766 movff buffer+1,buffer+0
2578 movff buffer+2,buffer+1 2767 movff buffer+2,buffer+1
2579 movff buffer+3,buffer+2 2768 movff buffer+3,buffer+2
2585 WIN_SMALL surf_press_column+(4+1)*8,surf_press_row 2774 WIN_SMALL surf_press_column+(4+1)*8,surf_press_row
2586 STRCPY_TEXT_PRINT tMBAR ; mbar (hPa) 2775 STRCPY_TEXT_PRINT tMBAR ; mbar (hPa)
2587 return 2776 return
2588 2777
2589 update_surf_press2: 2778 update_surf_press2:
2590 movff lo,sub_b+0 2779 MOVII sub_a,sub_b
2591 movff hi,sub_b+1 2780 MOVII pressure_abs_ref,sub_a
2592 movff last_surfpressure_30min+0,sub_a+0
2593 movff last_surfpressure_30min+1,sub_a+1
2594 goto subU16 ; sub_c = sub_a - sub_b and return... 2781 goto subU16 ; sub_c = sub_a - sub_b and return...
2595 2782
2596 ;============================================================================= 2783 ;=============================================================================
2597 2784
2598 global TFT_update_batt_voltage 2785 global TFT_batt_surfmode
2599 TFT_update_batt_voltage: 2786 TFT_batt_surfmode:
2600 movff batt_percent,lo ; get battery percent 2787 ; color-code according to battery percent
2788 movff batt_percent,lo
2601 clrf hi 2789 clrf hi
2602 call TFT_color_code_battery ; color-code battery percent 2790 call TFT_color_code_battery
2603 ; Setup charge indicator 2791
2604 btfsc cc_active 2792 ; set up charging indicator and temperature warning
2605 bsf win_invert 2793 clrf WREG ; default to no indication/warning
2606 btfsc cc_active 2794 btfsc cc_active ; charging in CC mode?
2607 movlw color_yellow 2795 movlw color_yellow ; YES - set output color to yellow
2608 btfsc cv_active 2796 btfsc cv_active ; charging in CV mode?
2609 movlw color_green 2797 movlw color_green ; YES - set output color to green
2610 btfsc cc_active 2798 btfsc battery_overtemp ; battery over-temperature detector tripped?
2611 call TFT_set_color 2799 movlw color_red ; YES - set output color to red
2612 2800 tstfsz WREG ; any indicator or warning active?
2613 ; Setup Temperature warning 2801 bsf win_invert ; YES - set output to inverse
2614 btfsc battery_overtemp 2802 tstfsz WREG ; any indicator or warning active (asked again)?
2615 bsf win_invert 2803 call TFT_set_color ; YES - set color
2616 btfsc battery_overtemp 2804
2617 movlw color_red
2618 btfsc battery_overtemp
2619 call TFT_set_color
2620
2621 IFDEF _ostc_logo 2805 IFDEF _ostc_logo
2622 WIN_TINY batt_percent_column,batt_percent_row 2806 WIN_TINY batt_percent_column,batt_percent_row
2623 ELSE 2807 ELSE
2624 WIN_SMALL batt_percent_column+.2,batt_percent_row 2808 WIN_SMALL batt_percent_column+.2,batt_percent_row
2625 ENDIF 2809 ENDIF
2638 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 2822 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
2639 PUTC "T" 2823 PUTC "T"
2640 bsf leftbind 2824 bsf leftbind
2641 output_8 2825 output_8
2642 PUTC ":" 2826 PUTC ":"
2643 movff batt_voltage+0,lo 2827 MOVII batt_voltage,mpr
2644 movff batt_voltage+1,hi
2645 output_16dp .2 2828 output_16dp .2
2646 bcf leftbind 2829 bcf leftbind
2647 PUTC 'V' 2830 PUTC 'V'
2648 movff buffer+8,buffer+6 2831 movff buffer+8,buffer+6
2649 movlw 0x00 2832 movlw 0x00
2660 ; movff battery_gauge+2,xC+0 2843 ; movff battery_gauge+2,xC+0
2661 ; ; battery_gauge:6 is nAs 2844 ; ; battery_gauge:6 is nAs
2662 ; ; devide through 65536 2845 ; ; devide through 65536
2663 ; ; devide through 152 2846 ; ; devide through 152
2664 ; ; Result is 0.01Ah in xC+1:xC+0 2847 ; ; Result is 0.01Ah in xC+1:xC+0
2665 ; movlw LOW .152 2848 ; MOVLI .152,xB
2666 ; movwf xB+0 2849 ; call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
2667 ; movlw HIGH .152
2668 ; movwf xB+1
2669 ; call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
2670 ; bsf leftbind 2850 ; bsf leftbind
2671 ; movff xC+0,lo 2851 ; MOVII xC,mpr
2672 ; movff xC+1,hi
2673 ; output_16 2852 ; output_16
2674 ; STRCAT_PRINT "x.01Ah" 2853 ; STRCAT_PRINT "x.01Ah"
2675 ; WIN_FONT FT_SMALL
2676 ; bcf leftbind 2854 ; bcf leftbind
2677 ; return 2855 ; return
2678 2856
2679 ;============================================================================= 2857 ;=============================================================================
2680 2858
2681 global TFT_convert_signed_16bit 2859 global TFT_convert_signed_16bit
2682 TFT_convert_signed_16bit: 2860 TFT_convert_signed_16bit:
2683 bcf neg_flag ; positive temperature 2861 bcf neg_flag ; clear flag for negative number by default
2684 btfss hi,7 ; negative temperature ? 2862 btfss hi,7 ; negative number?
2685 return ; NO - return 2863 return ; NO - done
2686 ; YES - negative temperature 2864 ; YES
2687 bsf neg_flag ; negative temperature 2865 bsf neg_flag ; set flag for negative number
2688 PUTC '-' ; display "-" 2866 PUTC '-' ; display a minus sign ("-")
2689 comf hi ; 16 bit sign change 2867 comf hi ; complement hi:lo
2690 negf lo 2868 negf lo
2691 btfsc STATUS,C 2869 btfsc STATUS,C
2692 incf hi 2870 incf hi
2693 return ; done 2871 return ; done
2694 2872
2695 ;============================================================================= 2873 ;=============================================================================
2696 2874
2697 global TFT_convert_date 2875 global TFT_convert_date
2698 TFT_convert_date: ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 2876 TFT_convert_date: ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
2699 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD 2877 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD
2700 movwf EEDATA ; used as temp here 2878 movwf EEDATA ; used as temp here
2701 tstfsz EEDATA 2879 tstfsz EEDATA
2702 bra TFT_convert_date_1 ; opt_dateformat is 1 or 2 2880 bra TFT_convert_date_1 ; opt_dateformat is 1 or 2
2703 ; opt_dateformat is 0 2881 ; opt_dateformat is 0
2704 ; use MMDDYY 2882 ; use MMDDYY
2705 movff lo,lo_temp ; incoming: lo = day, hi = month 2883 movff lo,hy ; incoming: lo = day, hi = month
2706 movff hi,lo ; swap 2884 movff hi,lo ; swap
2707 movff lo_temp,hi ; now: lo = month, hi = day 2885 movff hy,hi ; now: lo = month, hi = day
2708 bra TFT_convert_date_common 2886 bra TFT_convert_date_common
2709 2887
2710 TFT_convert_date_1: 2888 TFT_convert_date_1:
2711 decfsz EEDATA,F 2889 decfsz EEDATA,F
2712 bra TFT_convert_date_2 ; opt_dateformat is 2 2890 bra TFT_convert_date_2 ; opt_dateformat is 2
2725 return 2903 return
2726 2904
2727 TFT_convert_date_2: 2905 TFT_convert_date_2:
2728 ; opt_dateformat is 2 2906 ; opt_dateformat is 2
2729 ; use YYMMDD 2907 ; use YYMMDD
2730 movff lo,lo_temp ; incoming: lo = day, up = year 2908 movff lo,hy ; incoming: lo = day, up = year
2731 movff up,lo ; swap 2909 movff up,lo ; swap
2732 movff lo_temp,up ; now : lo = year, up = day 2910 movff hy,up ; now : lo = year, up = day
2733 bra TFT_convert_date_common 2911 bra TFT_convert_date_common
2734 2912
2735 ;============================================================================= 2913 ;=============================================================================
2736 2914
2737 global TFT_convert_date_short 2915 global TFT_convert_date_short
2738 TFT_convert_date_short: ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 2916 TFT_convert_date_short: ; convert into "DD/MM" or "MM/DD" or "MM/DD" in postinc2
2739 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD 2917 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD
2740 movwf EEDATA ; used as temp here 2918 movwf EEDATA ; used as temp here
2741 tstfsz EEDATA 2919 tstfsz EEDATA
2742 bra TFT_convert_date_short_1 2920 bra TFT_convert_date_short_1
2743 ; opt_dateformat is 0 2921 ; opt_dateformat is 0
2744 ; use MMDD(YY) 2922 ; use MMDD(YY)
2745 TFT_convert_date_short_0: 2923 TFT_convert_date_short_0:
2746 movff lo,lo_temp ; incoming: lo = day, hi = month 2924 movff lo,hy ; incoming: lo = day, hi = month
2747 movff hi,lo ; swap 2925 movff hi,lo ; swap
2748 movff lo_temp,hi ; now: lo = month, hi = day 2926 movff hy,hi ; now: lo = month, hi = day
2749 bra TFT_convert_date_short_common 2927 bra TFT_convert_date_short_common
2750 2928
2751 TFT_convert_date_short_1: 2929 TFT_convert_date_short_1:
2752 decfsz EEDATA,F 2930 decfsz EEDATA,F
2753 bra TFT_convert_date_short_0 ; opt_dateformat is 2 -> use (YY)MMDD 2931 bra TFT_convert_date_short_0; opt_dateformat is 2 -> use (YY)MMDD
2754 ; opt_dateformat is 1 2932 ; opt_dateformat is 1
2755 ; use DDMM(YY) 2933 ; use DDMM(YY)
2756 TFT_convert_date_short_common: 2934 TFT_convert_date_short_common:
2757 bsf leftbind 2935 bsf leftbind
2758 output_99x ; with lo = month or day 2936 output_99x ; with lo = month or day
2762 bcf leftbind 2940 bcf leftbind
2763 return 2941 return
2764 2942
2765 ;============================================================================= 2943 ;=============================================================================
2766 2944
2767 global TFT_date 2945 global TFT_date_surfmode
2768 TFT_date: 2946 TFT_date_surfmode:
2769 WIN_SMALL surf_date_column,surf_date_row ; init new wordprocessor 2947 WIN_SMALL surf_date_column,surf_date_row
2770 call TFT_standard_color 2948 call TFT_standard_color
2771 movff day,lo 2949 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
2772 movff month,hi 2950 movff rtc_latched_day,lo
2773 movff year,up 2951 movff rtc_latched_month,hi
2774 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 2952 movff rtc_latched_year,up
2953 call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
2775 STRCAT_PRINT "" 2954 STRCAT_PRINT ""
2776 return 2955 return
2777 2956
2778 ;============================================================================= 2957 ;=============================================================================
2779 2958
2780 global TFT_max_depth_alternative 2959 global TFT_show_max_depth
2781 TFT_max_depth_alternative: 2960 TFT_show_max_depth:
2782 bcf FLAG_TFT_max_depth 2961 btfsc alt_layout_active ; alternative layout active?
2783 ; The "mask" 2962 bra TFT_show_max_depth_alt ; YES
2784 call TFT_divemask_color 2963
2785 WIN_TINY dm_mask_depth_column, dm_max_alt_row-.14
2786 btfsc FLAG_apnoe_mode ; in Apnea mode?
2787 bra TFT_max_depth_alternative2 ; YES - always draw max depth
2788 TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth?
2789 bra TFT_max_depth_alternative2 ; NO - draw max depth
2790 STRCAT_TEXT_PRINT tAvgDepth ; YES - print avg depth mask
2791 movff avg_rel_pressure_total+0,lo ; - get avg depth, low byte
2792 movff avg_rel_pressure_total+1,hi ; - high byte
2793 bra TFT_max_depth_alternative3
2794 TFT_max_depth_alternative2:
2795 STRCAT_TEXT_PRINT tMaxDepth ; print max depth mask
2796 SAFE_2BYTE_COPY max_pressure, lo ; get max depth into hi:lo
2797 TFT_max_depth_alternative3:
2798 call adjust_depth_with_salinity ; compute salinity setting into lo:hi [mbar]
2799 call TFT_memo_color
2800 WIN_LARGE dm_max_alt_column,dm_max_alt_row
2801 TSTOSS opt_units ; 0=m or 1=ft?
2802 bra TFT_max_depth_alt_metric ; 0 - use alternative metric version
2803 bra TFT_max_depth_imperial ; 1 - use common imperial version
2804 TFT_max_depth_alt_metric:
2805 movff hi,sub_b+1 ; backup hi in sub_b+1
2806 movff lo,sub_b+0 ; backup lo in sub_b+0
2807 bsf ignore_digit4 ; no 0.1 m
2808 output_16
2809 STRCAT_PRINT ""
2810 WIN_MEDIUM dm_max_dm_alt_column,dm_max_alt_row+.25
2811 bra TFT_max_depth_metric3 ; continue with normal metric version for decimal
2812
2813
2814 global TFT_max_depth
2815 TFT_max_depth:
2816 bcf FLAG_TFT_max_depth
2817 btfsc FLAG_apnoe_mode ; in Apnoe mode?
2818 bra TFT_max_depth1 ; YES - different handling in Apnoe mode
2819 TSTOSS opt_2ndDepthDisp ; draw avg depth instead of max depth?
2820 bra TFT_max_depth2 ; NO - show max depth
2821 movff avg_rel_pressure_total+0,lo ; YES - get avg depth, low byte
2822 movff avg_rel_pressure_total+1,hi ; - high byte
2823 bra TFT_max_depth3
2824 TFT_max_depth1:
2825 btfss FLAG_active_descent ; are we descending?
2826 bra TFT_max_depth2 ; NO - show normal max
2827 SAFE_2BYTE_COPY apnoe_max_pressure,lo ; YES - get apnoe_max_pressure
2828 bra TFT_max_depth3
2829 TFT_max_depth2:
2830 SAFE_2BYTE_COPY max_pressure,lo ; get the "normal" max depth
2831 TFT_max_depth3:
2832 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
2833 movlw .039 ; load encoding for 99.84 m
2834 cpfslt hi ; is depth to show > 99.84 m ?
2835 bra TFT_max_depth3a ; YES
2836 btfss max_depth_greater_100m ; NO - was depth > 100 m during last call?
2837 bra TFT_max_depth3c ; NO
2838 bcf max_depth_greater_100m ; YES - clear flag, last depth shown now not > 100 m anymore
2839 bra TFT_max_depth3b ; - clear depth area
2840 TFT_max_depth3a:
2841 btfsc max_depth_greater_100m ; YES - was depth > 100 m during last call?
2842 bra TFT_max_depth3c ; YES
2843 bsf max_depth_greater_100m ; NO - set flag, last depth shown now > 100 m
2844 ;bra TFT_max_depth3b ; - clear depth area
2845 TFT_max_depth3b:
2846 WIN_BOX_BLACK dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt ; top, bottom, left, right
2847 TFT_max_depth3c:
2848 call TFT_memo_color ; set output color
2849 WIN_MEDIUM dm_max_depth_column_nvsi, dm_max_depth_row 2964 WIN_MEDIUM dm_max_depth_column_nvsi, dm_max_depth_row
2850 TSTOSS opt_vsigraph ; graphical VSI bar enabled? 2965 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
2851 bra TFT_max_depth4 ; NO 2966 bra TFT_show_max_depth_1 ; NO - keep position
2852 WIN_MEDIUM dm_max_depth_column, dm_max_depth_row ; YES - adopt output position 2967 ; YES - adopt output position
2853 TFT_max_depth4: 2968 WIN_MEDIUM dm_max_depth_column, dm_max_depth_row
2969
2970 TFT_show_max_depth_1:
2971 btfsc FLAG_apnoe_mode ; in apnoe mode?
2972 bra TFT_max_depth_apnoe ; YES - different handling in apnoe mode
2973
2974 TSTOSS opt_2ndDepthDisp ; show average depth instead of max depth?
2975 bra TFT_max_depth_current ; NO - show max depth
2976 ;bra TFT_avg_depth_current ; YES - show avg depth
2977
2978 TFT_avg_depth_current:
2979 MOVII pressure_rel_avg_total,mpr ; YES - get total dive average depth
2980 bra TFT_max_depth_common ; - continue with common part
2981
2982 TFT_max_depth_apnoe:
2983 btfss apnoe_at_surface ; apnoe mode, at the surface?
2984 bra TFT_max_depth_current ; NO - show max depth of current dive
2985 MOVII apnoe_max_pressure,mpr ; YES - show max depth of all dives so far
2986 bra TFT_max_depth_common ; - continue with common part
2987
2988 TFT_max_depth_current:
2989 MOVII pressure_rel_max_cached,mpr ; get the "normal" max depth in mbar = cm
2990 ;bra TFT_max_depth_common ; continue with common part
2991
2992 TFT_max_depth_common:
2993 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
2854 TSTOSS opt_units ; 0=m or 1=ft ? 2994 TSTOSS opt_units ; 0=m or 1=ft ?
2855 bra TFT_max_depth_metric ; 0 - use metric version 2995 bra TFT_max_depth_metric ; 0 - use metric version
2856 TFT_max_depth_imperial: ; 1 - use imperial version 2996 ;bra TFT_max_depth_imperial ; 1 - use imperial version
2997
2998 TFT_max_depth_imperial:
2857 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 2999 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
2858 output_16_3 3000 call TFT_memo_color ; set output color
2859 bra TFT_max_depth_exit 3001 output_16_3 ; print depth
3002 bra TFT_max_depth_finish ; finish output
3003
2860 TFT_max_depth_metric: 3004 TFT_max_depth_metric:
2861 btfss max_depth_greater_100m ; depth to show > 100 m ? 3005 MOVLI .9999,sub_a ; 9999 mbar = 99.99 m
2862 bra TFT_max_depth_metric0 ; NO - show meters and decimeters 3006 MOVII mpr, sub_b ; depth, also used to back-up hi:lo
2863 bsf ignore_digit4 ; YES - show full meters only, i.e. ignore digits 4 and 5 3007 call cmpU16 ; sub_a - sub_b = 99.99 - depth
2864 bsf leftbind 3008 btfsc neg_flag ; depth < 100 meter ?
2865 output_16 3009 bra TFT_max_depth_greater_100m ; NO - greater than 100 m
2866 bra TFT_max_depth_exit 3010 ;bra TFT_max_depth_shallower_100m; YES - shallower than 100 m
2867 TFT_max_depth_metric0: 3011
2868 movff hi,sub_b+1 ; copy hi to sub_b+1, will also be used to back-up hi 3012 TFT_max_depth_shallower_100m:
2869 movff lo,sub_b+0 ; copy lo to sub_b+0, will also be used to back-up lo 3013 btfss max_depth_greater_100m ; was depth >= 100 m during last call?
2870 3014 bra TFT_max_depth_metric_show ; NO - show depth
2871 movlw HIGH d'999' 3015 bcf max_depth_greater_100m ; YES - clear flag, last depth shown now not > 99.84 m anymore
2872 movwf sub_a+1 3016 bra TFT_max_depth_clear ; - clear depth area
2873 movlw LOW d'999' 3017
2874 movwf sub_a+0 3018 TFT_max_depth_greater_100m:
2875 call sub16 ; sub_c = sub_a - sub_b 3019 btfsc max_depth_greater_100m ; was depth >= 100 m during last call?
2876 movlw ' ' 3020 bra TFT_max_depth_metric_show ; YES - show depth
2877 btfss neg_flag ; depth lower than 10m ? 3021 bsf max_depth_greater_100m ; NO - set flag, last depth shown now > 99.84 m
2878 movwf POSTINC2 ; YES - add extra space 3022 ;bra TFT_max_depth_clear ; - clear depth area
2879 3023
2880 clrf sub_a+1 3024 TFT_max_depth_clear:
2881 movlw d'99' 3025 WIN_BOX_BLACK dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt ; top, bottom, left, right
2882 movwf sub_a+0 3026 ;bra TFT_max_depth_metric_show
2883 call subU16 ; sub_c = sub_a - sub_b 3027
2884 btfss neg_flag ; depth lower than 1m ? 3028 TFT_max_depth_metric_show:
2885 bra TFT_max_depth_metric1 ; YES - manually display a zero 3029 call TFT_memo_color ; set output color
2886 bsf ignore_digit4 ; NO - no 0.1 m 3030 btfss max_depth_greater_100m ; depth to show >= 100 m ?
3031 bra TFT_max_depth_metric_m_dm ; NO - show meters and decimeters
3032 bsf ignore_digit4 ; YES - crop decimeters and centimeters
3033 bsf leftbind ; - print left-aligned
3034 output_16 ; - print depth
3035 bra TFT_max_depth_finish ; - finish output
3036
3037 TFT_max_depth_metric_m_dm:
3038 MOVLI .999,sub_a ; load 9.99 meter
3039 call cmpU16 ; sub_a - sub_b = 9.99 - depth
3040 movlw ' ' ; load a space character
3041 btfss neg_flag ; depth shallower than 10 meter ?
3042 movwf POSTINC2 ; YES - add the space character
3043 MOVLI .99,sub_a ; load 0.99 m
3044 call cmpU16 ; sub_a - sub_b = 0.99 m - depth
3045 btfss neg_flag ; depth shallower than 1 meter ?
3046 bra TFT_max_depth_metric_zero ; YES - manually display a zero
3047 bsf ignore_digit4 ; NO - crop decimeters and centimeters
2887 bsf leftbind ; - align left 3048 bsf leftbind ; - align left
2888 output_16 ; - display full meters 3049 output_16 ; - display full meters
2889 bra TFT_max_depth_metric2 3050 STRCAT_PRINT "" ; - finalize output
2890 TFT_max_depth_metric1: 3051 bra TFT_max_depth_metric_dm ; - continue with decimeters
2891 STRCAT "0" ; display a zero 3052
2892 TFT_max_depth_metric2: 3053 TFT_max_depth_metric_zero:
2893 STRCAT_PRINT "" 3054 STRCAT_PRINT "0" ; print a zero
2894 ; .1 m in SMALL font 3055 ;bra TFT_max_depth_metric_dm ; continue with decimeters
3056
3057 TFT_max_depth_metric_dm:
2895 WIN_SMALL dm_max_depth_dm_column_nvsi, dm_max_depth_dm_row 3058 WIN_SMALL dm_max_depth_dm_column_nvsi, dm_max_depth_dm_row
2896 TSTOSS opt_vsigraph ; graphical VSI bar enabled? 3059 TSTOSS opt_vsigraph ; graphical VSI bar enabled?
2897 bra TFT_max_depth_metric3 ; NO 3060 bra TFT_max_depth_metric_dm_1 ; NO - keep position
2898 WIN_SMALL dm_max_depth_dm_column, dm_max_depth_dm_row ; YES - adopt position 3061 ; YES - adopt position
2899 TFT_max_depth_metric3: 3062 WIN_SMALL dm_max_depth_dm_column, dm_max_depth_dm_row
2900 movff sub_b+1,hi ; restore hi 3063 TFT_max_depth_metric_dm_1:
2901 movff sub_b+0,lo ; restore lo
2902 PUTC "." ; print decimal point 3064 PUTC "." ; print decimal point
2903 movlw d'4' 3065 MOVII sub_b,mpr ; restore depth in hi:lo
2904 movwf ignore_digits 3066 movlw d'4' ; crop leading 4 digits (don't show the full meters)
2905 bsf ignore_digit5 ; no 0.01 m, flag will be cleared by output_16 3067 movwf ignore_digits ; ...
2906 bsf leftbind 3068 bsf ignore_digit5 ; crop last digit (no centimeters, flag will be cleared by output_16)
2907 output_16dp d'0' 3069 bsf leftbind ; print left-aligned
2908 TFT_max_depth_exit: 3070 output_16dp d'0' ; print decimal
2909 STRCAT_PRINT "" 3071 TFT_max_depth_finish:
2910 bcf leftbind 3072 STRCAT_PRINT "" ; finalize output
2911 goto TFT_standard_color ; and return... 3073 bcf leftbind ; back to default right alignment
3074 goto TFT_standard_color ; done
3075
3076
3077 TFT_show_max_depth_alt:
3078 btfsc FLAG_apnoe_mode ; in apnoe mode?
3079 bra TFT_show_apnoe_max_depth ; YES - use apnoe surface output also in alternative dive mode screen
3080 btfsc FLAG_gauge_mode ; NO - in gauge mode?
3081 bra TFT_show_gauge_max_avg_depth; YES - show both, max and avg depth
3082 return ; NO - nothing to do
3083
3084 TFT_show_gauge_max_avg_depth:
3085 call TFT_memo_color ; set color
3086 WIN_MEDIUM dm_gauge_max_depth_col, dm_gauge_max_depth_row ; set position for max depth
3087 rcall TFT_show_gauge_max_depth ; show max depth
3088 call TFT_memo_color ; set color
3089 WIN_MEDIUM dm_gauge_avg_depth_col, dm_gauge_avg_depth_row ; set position for avg depth
3090 MOVII pressure_rel_avg_total,mpr ; get average depth into hi:lo
3091 bra TFT_show_gauge_depth ; show avg depth and return
3092
3093
3094 global TFT_show_apnoe_max_depth
3095 TFT_show_apnoe_max_depth:
3096 ; title
3097 WIN_TINY dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row
3098 call TFT_divemask_color
3099 btfsc alt_layout_active ; alternative layout active?
3100 bra TFT_show_apnoe_max_depth_alt ; YES
3101 STRCPY_TEXT_PRINT tApnoeMax ; NO - print "Last Descent"
3102 bra TFT_show_apnoe_max_depth_com ; - continue with common part
3103 TFT_show_apnoe_max_depth_alt:
3104 STRCPY_TEXT_PRINT tMaxDepth ; print "Max.Depth"
3105 TFT_show_apnoe_max_depth_com:
3106 ; value
3107 WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
3108 call TFT_memo_color
3109 TFT_show_gauge_max_depth:
3110 MOVII pressure_rel_max_cached,mpr ; get max depth into hi:lo
3111 TFT_show_gauge_depth:
3112 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
3113 TSTOSS opt_units ; 0=m, 1=ft
3114 bra TFT_display_apnoe_last_m_metric ; 0 - metric
3115 TFT_display_apnoe_last_max_imp: ; 1 - imperial
3116 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
3117 output_16
3118 bra TFT_max_depth_finish ; finish output
3119 TFT_display_apnoe_last_m_metric:
3120 bsf ignore_digit5 ; do not display centimeters (flag will be cleared by output_16)
3121 output_16dp d'3'
3122 bra TFT_max_depth_finish ; finish output
2912 3123
2913 ;============================================================================= 3124 ;=============================================================================
2914 3125
2915 global TFT_divemins 3126 global TFT_show_divetime
2916 TFT_divemins: 3127 TFT_show_divetime:
2917 bcf FLAG_TFT_divemins ; clear flag 3128 call TFT_memo_color ; set color
2918 movff divemins+0,lo 3129 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 (mpr+1:mpr+0) and seconds (mpr+2)
2919 movff divemins+1,hi 3130 btfsc show_only_divemins ; shall suppress display of seconds?
2920 3131 bra TFT_show_divetime_min_only ; YES - show minutes only
2921 ; Already showing divemins > 99min 3132 movlw .99 ; NO - load 99
2922 btfsc no_more_divesecs ; ignore seconds? 3133 cpfsgt mpr+0 ; - dive time > 99 minutes ?
2923 bra TFT_divemins2 ; show minutes only 3134 bra TFT_show_divetime_min_sec ; NO - show min:sec
2924 3135 bsf show_only_divemins ; YES - set flag to suppress the display of seconds for the rest of the dive
2925 tstfsz hi ; hi = 0? 3136 btfsc alt_layout_active ; - in alternative layout?
2926 bra TFT_divemins_clr ; NO - show mins only 3137 bra TFT_show_divetime_clear_alt ; YES - clear min:sec area of alternative layout
2927 3138 ;bra TFT_show_divetime_clear_norm ; NO - clear min:sec area of normal layout
2928 movlw .99 3139
2929 cpfsgt lo ; bigger than 99? 3140 TFT_show_divetime_clear_norm:
2930 bra TFT_divemins1 ; NO - show mins:secs 3141 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_medium, dm_divetime_col_medium, dm_divetime_rgt ;top, bottom, left, right
2931 3142 bra TFT_show_divetime_min_only_norm ; show minutes only
2932 TFT_divemins_clr: 3143
2933 ; YES - remove second display for the rest of the dive and clear seconds 3144 TFT_show_divetime_clear_alt:
2934 bsf no_more_divesecs ; - set flag 3145 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot_large, dm_divetime_col_large, dm_divetime_rgt ;top, bottom, left, right
2935 ; - clear rest of seconds 3146 bra TFT_show_divetime_min_only_alt ; show minutes only
2936 WIN_BOX_BLACK dm_divetime_row, dm_divetime_bot, dm_divetime_column, dm_divetime_rgt ;top, bottom, left, right 3147
2937 bra TFT_divemins2 ; - show minutes only 3148 TFT_show_divetime_min_sec:
2938 3149 ; show the minutes
2939 TFT_divemins1: 3150 btfsc alt_layout_active ; in alternative layout?
2940 ; Print out the minutes, up to 99 minutes, only 2 chars! 3151 bra TFT_show_divetime_min_alt ; YES
2941 call TFT_memo_color 3152 ;bra TFT_show_divetime_min_norm ; NO
2942 WIN_MEDIUM dm_divetime_column, dm_divetime_row 3153
2943 output_99 ; displays only last two figures from a 8 bit value (0-99) 3154 TFT_show_divetime_min_norm:
2944 STRCAT_PRINT "" ; show minutes in large font 3155 WIN_MEDIUM dm_divetime_col_medium, dm_divetime_row
2945 3156 bra TFT_show_divetime_min_com ; continue with common part
2946 ; Print out the seconds 3157
2947 WIN_SMALL dm_divetime_secs_column, dm_divetime_secs_row ; left position for two sec figures 3158 TFT_show_divetime_min_alt:
2948 PUTC ':' 3159 WIN_LARGE dm_divetime_col_large, dm_divetime_row
2949 movff divesecs,lo 3160 ;bra TFT_show_divetime_min_com ; continue with common part
2950 bsf leftbind 3161
2951 output_99x ; displays only last two figures from a 8 bit value with leading zero (00-99) 3162 TFT_show_divetime_min_com:
2952 bra TFT_divemins_exit ; and return... 3163 output_99 ; displays only last two digits from a 8 bit value (0-99)
2953 3164 STRCAT_PRINT "" ; finalize output
2954 TFT_divemins2: 3165
2955 ; Full minutes only 3166 ; show the seconds
2956 call TFT_memo_color 3167 btfsc alt_layout_active ; in alternative layout?
2957 WIN_MEDIUM dm_divetime_minsonly_column, dm_divetime_row 3168 bra TFT_show_divetime_sec_alt ; YES
2958 bcf leftbind 3169 ;bra TFT_show_divetime_sec_norm ; NO
2959 output_16_4 3170
2960 bra TFT_divemins_exit ; and return... 3171 TFT_show_divetime_sec_norm:
2961 3172 WIN_SMALL dm_divetime_sec_col_small, dm_divetime_sec_row_small
2962 3173 bra TFT_show_divetime_sec_com ; continue with common part
2963 global TFT_divemins_alternative 3174
2964 TFT_divemins_alternative: 3175 TFT_show_divetime_sec_alt:
2965 bcf FLAG_TFT_divemins ; clear flag 3176 WIN_MEDIUM dm_divetime_sec_col_medium, dm_divetime_sec_row_medium
2966 call TFT_memo_color 3177 ;bra TFT_show_divetime_sec_com ; continue with common part
2967 ; Print out the minutes (0-999) in large 3178
2968 WIN_LARGE dm_divetime_alt_column, dm_divetime_alt_row 3179 TFT_show_divetime_sec_com:
2969 movff divemins+0,lo 3180 PUTC ':' ; print separator char
2970 movff divemins+1,hi 3181 movff mpr+2,lo ; copy seconds to lo
2971 output_16_3 ; limit to 999 and display only (0-999) 3182 bsf leftbind ; activate left-alignment
2972 STRCAT_PRINT "" ; show minutes 3183 output_99x ; displays only last two figures from a 8 bit value with leading zero (00-99)
2973 ; Print out the seconds in medium 3184 bcf leftbind ; deactivate left-alignment
2974 WIN_MEDIUM dm_divetime_alt_column+.60, dm_divetime_alt_row+.25 3185 bra TFT_divemins_exit ; continue with common part
2975 PUTC ":" 3186
2976 movff divesecs,lo 3187 TFT_show_divetime_min_only:
2977 bsf leftbind 3188 btfsc alt_layout_active ; in alternative layout?
2978 output_99x ; displays only last two figures from a 8Bit value with leading zero (00-99) 3189 bra TFT_show_divetime_min_only_alt ; YES
3190 ;bra TFT_show_divetime_min_only_norm ; NO
3191
3192 TFT_show_divetime_min_only_norm:
3193 WIN_MEDIUM dm_divetime_minonly_col_medium, dm_divetime_row
3194 output_16_4 ; print minutes (4 digits)
3195 bra TFT_divemins_exit ; continue with common part
3196
3197 TFT_show_divetime_min_only_alt:
3198 WIN_LARGE dm_divetime_minonly_col_large, dm_divetime_row
3199 output_16_3 ; print minutes (3 digits)
3200 ;bra TFT_divemins_exit ; continue with common part
3201
2979 TFT_divemins_exit: 3202 TFT_divemins_exit:
2980 STRCAT_PRINT "" 3203 STRCAT_PRINT "" ; finalize output
2981 bcf leftbind 3204 goto TFT_standard_color ; and return...
2982 goto TFT_standard_color ; and return...
2983 3205
2984 ;============================================================================= 3206 ;=============================================================================
2985 3207
2986 global TFT_display_apnoe_surface 3208 global TFT_show_apnoe_surface
2987 TFT_display_apnoe_surface: 3209 TFT_show_apnoe_surface:
2988 btfsc menuview ; is the options menu shown?
2989 bra TFT_display_apnoe_surface_1 ; YES - skip title
2990 call TFT_divemask_color 3210 call TFT_divemask_color
2991 WIN_TINY dm_apnoe_surface_time_text_col, dm_apnoe_surface_time_text_row 3211 WIN_TINY dm_apnoe_surface_time_text_col, dm_apnoe_surface_time_text_row
2992 STRCPY_TEXT_PRINT tApnoeSurface 3212 STRCPY_TEXT_PRINT tApnoeSurface
2993 TFT_display_apnoe_surface_1:
2994 call TFT_memo_color 3213 call TFT_memo_color
2995 WIN_MEDIUM dm_apnoe_surface_time_column, dm_apnoe_surface_time_row 3214 WIN_MEDIUM dm_apnoe_surface_time_column, dm_apnoe_surface_time_row
2996 movff apnoe_surface_mins,lo 3215 SMOVII apnoe_surface_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi
2997 output_8 3216 output_8
2998 PUTC ':' 3217 PUTC ':'
2999 movff apnoe_surface_secs,lo 3218 movff hi,lo ; copy seconds to lo
3000 output_99x 3219 output_99x
3001 bra TFT_display_apnoe_exit ; and return... 3220 bra TFT_display_apnoe_exit ; and return...
3002 3221
3003 3222
3004 global TFT_display_apnoe_last_max 3223 global TFT_show_apnoe_times
3005 TFT_display_apnoe_last_max: 3224 TFT_show_apnoe_times: ; descent dive time
3006 call TFT_divemask_color 3225 ; current dive time
3007 WIN_TINY dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row
3008 STRCPY_TEXT_PRINT tApnoeMax
3009 call TFT_memo_color 3226 call TFT_memo_color
3010 SAFE_2BYTE_COPY max_pressure, lo 3227 WIN_MEDIUM dm_divetime_apnoe_col, dm_divetime_apnoe_row
3011 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] 3228 SMOVII apnoe_dive_mins,mpr ; ISR-safe copy of minutes to lo and seconds to hi
3012 TSTOSS opt_units ; 0=m, 1=ft 3229 output_99 ; display 0-99
3013 bra TFT_display_apnoe_last_m_metric 3230 STRCAT_PRINT "" ; show minutes
3014 TFT_display_apnoe_last_max_imp: 3231 WIN_SMALL dm_divetime_apnoe_secs_col, dm_divetime_apnoe_secs_row ; left position for two sec figures
3015 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
3016 WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
3017 output_16
3018 bra TFT_max_depth_exit
3019 TFT_display_apnoe_last_m_metric:
3020 WIN_MEDIUM dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
3021 bsf ignore_digit5 ; do not display 1cm depth (flag will be cleared by output_16)
3022 output_16dp d'3'
3023 bra TFT_max_depth_exit
3024
3025
3026 global TFT_display_apnoe_descent
3027 TFT_display_apnoe_descent: ; descent divetime
3028 movff apnoe_mins,lo
3029 clrf hi
3030 WIN_MEDIUM dm_divetime_apnoe_column, dm_divetime_apnoe_row
3031 output_16_3 ; displays only last three figures from a 16Bit value (0-999)
3032 call TFT_memo_color
3033 STRCAT_PRINT "" ; show minutes in large font
3034 WIN_SMALL dm_divetime_apnoe_secs_column, dm_divetime_apnoe_secs_row ; left position for two sec figures
3035 PUTC ':' 3232 PUTC ':'
3036 bsf leftbind 3233 bsf leftbind
3037 movff apnoe_secs,lo 3234 movff hi,lo ; copy seconds to lo
3038 output_99x 3235 output_99x
3039 STRCAT_PRINT "" ; show seconds in small font 3236 STRCAT_PRINT "" ; show seconds
3040 call TFT_divemask_color 3237 ; overall dive time
3041 WIN_TINY dm_total_apnoe_text_column,dm_total_apnoe_text_row 3238 WIN_MEDIUM dm_apnoe_total_divetime_col, dm_apnoe_total_divetime_row
3042 STRCPY_TEXT_PRINT tApnoeTotal 3239 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 and seconds
3043 call TFT_memo_color
3044 movff divemins,lo
3045 clrf hi 3240 clrf hi
3046 WIN_MEDIUM dm_apnoe_total_divetime_column, dm_apnoe_total_divetime_row
3047 bcf leftbind 3241 bcf leftbind
3048 output_16_3 ; displays only last three figures from a 16Bit value (0-999) 3242 output_16_3 ; displays only last three figures from a 16 bit value (0-999)
3049 call TFT_memo_color 3243 STRCAT_PRINT "" ; show minutes in large font
3050 STRCAT_PRINT "" ; show minutes in large font 3244 WIN_SMALL dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row ; left position for two sec figures
3051 WIN_SMALL dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row ; left position for two sec figures
3052 PUTC ':' 3245 PUTC ':'
3053 bsf leftbind 3246 bsf leftbind
3054 movff divesecs,lo 3247 movff up,lo ; copy minutes from up to lo
3055 output_99x 3248 output_99x
3056 TFT_display_apnoe_exit: 3249 TFT_display_apnoe_exit:
3057 STRCAT_PRINT "" 3250 STRCAT_PRINT ""
3058 bcf leftbind 3251 bcf leftbind
3059 goto TFT_standard_color ; and return... 3252 goto TFT_standard_color ; and return...
3060 3253
3061 3254
3062 global TFT_apnoe_clear_surface 3255 global TFT_clear_apnoe_surface
3063 TFT_apnoe_clear_surface: 3256 TFT_clear_apnoe_surface:
3064 ; clear surface timer (TODO: partly wipes out options menu, too) 3257 ; clear surface data
3065 WIN_BOX_BLACK dm_apnoe_surface_time_text_row, .239, dm_apnoe_surface_time_text_col, .159 ; top, bottom, left, right 3258 WIN_BOX_BLACK dm_apnoe_last_max_depth_text_row, .239, dm_apnoe_last_max_depth_column, .159 ; top, bottom, left, right
3066 return 3259 goto TFT_standard_color ; and return...
3067 3260
3068 3261
3069 ;============================================================================= 3262 ;-----------------------------------------------------------------------------
3070 ; append firmware version to current string, including color-coding
3071
3072 global TFT_cat_firmware
3073 TFT_cat_firmware:
3074 movlw softwareversion_x
3075 movwf lo
3076 bsf leftbind
3077 output_8
3078 PUTC '.'
3079 movlw softwareversion_y
3080 movwf lo
3081 output_99x
3082 bcf leftbind
3083 rcall check_expiry
3084 btfss aux_flag
3085 return
3086 bsf win_invert
3087 goto TFT_attention_color
3088
3089 ;=============================================================================
3090 ; check if firmware is within expiry period, will return aux_flag set if not 3263 ; check if firmware is within expiry period, will return aux_flag set if not
3091 3264
3092 check_expiry: ; check if it is time for a firmware update 3265 check_expiry: ; check if it is time for a firmware update
3266 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
3267 movff rtc_latched_day,lo ; get current day
3268 movff rtc_latched_month,hi ; get current month
3269 movff rtc_latched_year,up ; get current year
3093 bsf aux_flag ; set firmware as expired by default 3270 bsf aux_flag ; set firmware as expired by default
3094 movlw firmware_expire_year ; start with checking year 3271 movlw firmware_expire_year ; start with checking year
3095 cpfsgt year ; current year > expiry year ? 3272 cpfsgt up ; current year > expiry year ?
3096 bra check_expiry_Y ; NO - continue checks 3273 bra check_expiry_Y ; NO - continue checks
3097 return ; YES - expired 3274 return ; YES - expired
3098 check_expiry_Y: 3275 check_expiry_Y:
3099 cpfseq year ; current year = expiry year ? 3276 cpfseq up ; current year = expiry year ?
3100 bra check_expiry_ok ; NO - must be < then, OK whatever month & day 3277 bra check_expiry_ok ; NO - must be < then, OK whatever month & day
3101 movlw firmware_expire_month ; YES - continue checking month 3278 movlw firmware_expire_month ; YES - continue checking month
3102 cpfsgt month ; current month > expiry month ? 3279 cpfsgt hi ; current month > expiry month ?
3103 bra check_expiry_M ; NO - continue checks 3280 bra check_expiry_M ; NO - continue checks
3104 return ; YES - expired 3281 return ; YES - expired
3105 check_expiry_M: 3282 check_expiry_M:
3106 cpfseq month ; current month = expiry month ? 3283 cpfseq hi ; current month = expiry month ?
3107 bra check_expiry_ok ; NO - must be < then, OK whatever day 3284 bra check_expiry_ok ; NO - must be < then, OK whatever day
3108 movlw firmware_expire_day ; YES - continue checking day 3285 movlw firmware_expire_day ; YES - continue checking day
3109 cpfsgt day ; current day > expiry day ? 3286 cpfsgt lo ; current day > expiry day ?
3110 bra check_expiry_ok ; NO - must be <= then, OK 3287 bra check_expiry_ok ; NO - must be <= then, OK
3111 return ; YES - expired 3288 return ; YES - expired
3112 check_expiry_ok: 3289 check_expiry_ok:
3113 bcf aux_flag 3290 bcf aux_flag
3114 return 3291 return
3115 3292
3116 ;============================================================================= 3293 ;-----------------------------------------------------------------------------
3117 ; append firmware BETA status to current string, including color-coding 3294 ; append firmware BETA status to current string, including color-coding
3118 3295
3119 global TFT_cat_beta_rel
3120 global TFT_cat_beta_release 3296 global TFT_cat_beta_release
3121 TFT_cat_beta_release: ; entry point for printing "Release" / "Beta #" 3297 TFT_cat_beta_release: ; entry point for printing "Release" / "Beta #"
3122 bsf aux_flag 3298 bsf aux_flag
3123 bra TFT_cat_beta_common 3299 bra TFT_cat_beta_common
3124 TFT_cat_beta_rel: ; entry point for printing "Rel." / "B. #" 3300 TFT_cat_beta_rel: ; entry point for printing "Rel." / "B. #"
3125 bcf aux_flag 3301 bcf aux_flag
3126 TFT_cat_beta_common: 3302 TFT_cat_beta_common:
3127 IFDEF __DEBUG 3303 IFDEF _DEBUG
3128 STRCAT "DBG " 3304 btfss aux_flag ; shall show long version?
3129 goto TFT_warnings_color 3305 bra TFT_cat_debug_short ; NO - show short version
3306 STRCAT "DEBUG" ; YES - show long version
3307 goto TFT_warning_color ; - set color
3308 TFT_cat_debug_short:
3309 STRCAT "DBG." ; show short version
3310 goto TFT_warning_color ; set color
3130 ELSE 3311 ELSE
3131 movlw softwareversion_beta ; =0: release, =1: beta 1, =2: beta 2, ... 3312 movlw softwareversion_beta ; =0: release, =1: beta 1, =2: beta 2, ...
3132 movwf lo ; copy to lo 3313 movwf lo ; copy to lo
3133 tstfsz lo ; release version? 3314 tstfsz lo ; release version?
3134 bra TFT_cat_beta_1 ; NO - must be beta version then 3315 bra TFT_cat_beta_1 ; NO - must be beta version then
3135 btfss aux_flag ; YES - shall show long version? 3316 btfss aux_flag ; YES - shall show long version?
3136 bra TFT_cat_beta_2 ; NO - show short version 3317 bra TFT_cat_beta_2 ; NO - show short version
3137 rcall check_expiry ; YES - check expiry date 3318 rcall check_expiry ; YES - check expiry date
3138 btfsc aux_flag ; - within expiry date? 3319 btfsc aux_flag ; - within expiry date?
3139 bra TFT_cat_beta_4 ; NO - give update cue 3320 bra TFT_cat_beta_4 ; NO - give update cue
3140 STRCAT "Rel. " ; YES - print "Release" 3321 STRCAT "Release" ; YES - print "Release"
3141 return ; - done 3322 return ; - done
3142 TFT_cat_beta_1: 3323 TFT_cat_beta_1:
3143 btfss aux_flag ; shall show long version? 3324 btfss aux_flag ; shall show long version?
3144 bra TFT_cat_beta_3 ; NO - show short version 3325 bra TFT_cat_beta_3 ; NO - show short version
3145 STRCAT "Beta " ; YES - show long version 3326 STRCAT "Beta " ; YES - show long version
3155 STRCAT "B." ; short version for "Beta" 3336 STRCAT "B." ; short version for "Beta"
3156 bra TFT_cat_beta_1a ; append beta version number 3337 bra TFT_cat_beta_1a ; append beta version number
3157 TFT_cat_beta_4 3338 TFT_cat_beta_4
3158 STRCAT "update!" ; print update cue 3339 STRCAT "update!" ; print update cue
3159 goto TFT_attention_color ; and return 3340 goto TFT_attention_color ; and return
3160 ENDIF 3341 ENDIF ; _DEBUG
3161 3342
3162 ;============================================================================= 3343 ;-----------------------------------------------------------------------------
3344 ; show firmware update message
3345 ;
3346 ; all text outputs are hard-coded since language switching
3347 ; has not yet been initialized when this code is executed
3348
3349 global show_fw_mesg_update
3350 global show_fw_mesg_kept
3351 show_fw_mesg_update:
3352 call TFT_standard_color
3353 ; show update message
3354 WIN_SMALL .20,.100
3355 STRCPY_PRINT "Update successful!"
3356 ; show firmware version
3357 WIN_SMALL .20,.140
3358 STRCPY "New Firmware: "
3359 bra show_fw_mesg_common
3360 show_fw_mesg_kept:
3361 call TFT_standard_color
3362 ; show reboot message
3363 WIN_SMALL .60,.100
3364 STRCPY_PRINT "Reboot"
3365 ; show firmware version
3366 WIN_SMALL .30,.140
3367 STRCPY "Firmware: "
3368 show_fw_mesg_common:
3369 rcall TFT_cat_firmware ; show firmware version x.y and color-code + invert if outdated
3370 STRCAT_PRINT "" ; finalize output
3371 bcf win_invert ; back to normal (non inverted) output
3372 ; show firmware beta status
3373 call TFT_standard_color ; color to use if it is a release version
3374 WIN_SMALL .60,.180
3375 rcall TFT_cat_beta_release ; show "Release" or "BETA" + issue
3376 STRCAT_PRINT "" ; finalize output
3377 goto TFT_standard_color ; reset color and return
3378
3379 ;-----------------------------------------------------------------------------
3380 ; show serial and firmware version for comm mode
3381
3382 global TFT_show_serial_and_firmware
3383 global TFT_show_firmware
3384 TFT_show_serial_and_firmware:
3385 STRCPY "#"
3386 call TFT_cat_serial
3387 STRCAT " "
3388 TFT_show_firmware:
3389 STRCAT "v"
3390 call TFT_cat_firmware ; will set win_invert if outdated
3391 STRCAT " "
3392 call TFT_cat_beta_release
3393 STRCAT_PRINT ""
3394 bcf win_invert ; clear win_invert
3395 goto TFT_standard_color ; ...and return
3396
3397 ;-----------------------------------------------------------------------------
3398 ; append firmware version to current string, including color-coding
3399
3400 global TFT_cat_firmware
3401 TFT_cat_firmware:
3402 movlw softwareversion_x
3403 movwf lo
3404 bsf leftbind
3405 output_8 ; print major in 1 digit format
3406 PUTC '.'
3407 movlw softwareversion_y
3408 movwf lo
3409 output_99x ; print minor in two digit format
3410 bcf leftbind
3411 rcall check_expiry ; sets aux_flag if expired
3412 btfss aux_flag ; expired?
3413 return ; NO
3414 bsf win_invert ; YES - print in inverse
3415 goto TFT_attention_color ; - print in attention color (and return)
3416
3417 ;-----------------------------------------------------------------------------
3163 ; For the Information menu: firmware version 3418 ; For the Information menu: firmware version
3164 3419
3165 global info_menu_firmware 3420 global info_menu_firmware
3166 info_menu_firmware: 3421 info_menu_firmware:
3167 lfsr FSR1,tFirmware 3422 lfsr FSR1,tFirmware
3168 call strcat_text 3423 call strcat_text
3169 rcall TFT_cat_firmware 3424 rcall TFT_cat_firmware
3170 PUTC " " 3425 PUTC " "
3171 rcall TFT_cat_beta_rel 3426 rcall TFT_cat_beta_rel
3172 STRCAT_PRINT "" ; print buffer to screen 3427 STRCAT_PRINT ""
3173 return 3428 return
3174 3429
3175 ;============================================================================= 3430 ;-----------------------------------------------------------------------------
3176 ; For the Information menu: firmware version of the RX processor 3431 ; For the Information menu: firmware version of the RX processor
3177 3432
3178 IFDEF _rx_functions 3433 IFDEF _rx_functions
3434
3179 global info_menu_firmware_rx 3435 global info_menu_firmware_rx
3436 global TFT_print_firmware_rx
3180 info_menu_firmware_rx: 3437 info_menu_firmware_rx:
3181 lfsr FSR1,tFirmware_rx 3438 lfsr FSR1,tFirmware_rx
3182 call strcat_text 3439 call strcat_text
3183 ; bra TFT_cat_firmware_rx ;(and return) 3440 TFT_print_firmware_rx:
3184 ;TFT_cat_firmware_rx: 3441 movff rx_firmware_cur_major,lo
3185 movff rx_firmware+0,lo
3186 bsf leftbind 3442 bsf leftbind
3187 output_8 3443 output_8
3188 PUTC '.' 3444 PUTC '.'
3189 movff rx_firmware+1,lo 3445 movff rx_firmware_cur_minor,lo
3190 output_8 3446 output_8
3191 bcf leftbind 3447 bcf leftbind
3192 return 3448 return
3449
3193 ENDIF 3450 ENDIF
3194 3451
3195 ;----------------------------------------------------------------------------- 3452 ;-----------------------------------------------------------------------------
3196 ; For the Information menu: append serial number 3453 ; For the Information menu: append serial number
3197 3454
3198 global info_menu_serial 3455 global info_menu_serial
3456 global TFT_cat_serial
3199 info_menu_serial: 3457 info_menu_serial:
3200 lfsr FSR1,tSerial 3458 lfsr FSR1,tSerial
3201 call strcat_text 3459 call strcat_text
3202 global TFT_cat_serial
3203 TFT_cat_serial: 3460 TFT_cat_serial:
3204 clrf EEADRH 3461 clrf EEADRH
3205 clrf EEADR ; get serial number LOW 3462 clrf EEADR ; get serial number LOW
3206 call read_eeprom ; read byte 3463 call read_eeprom ; read byte
3207 movff EEDATA,lo 3464 movff EEDATA,lo
3229 bsf leftbind 3486 bsf leftbind
3230 output_16 3487 output_16
3231 bcf leftbind 3488 bcf leftbind
3232 return 3489 return
3233 3490
3491 ;-----------------------------------------------------------------------------
3234 ; For the Information menu: append battery voltage 3492 ; For the Information menu: append battery voltage
3493
3235 global info_menu_battery_volts 3494 global info_menu_battery_volts
3236 info_menu_battery_volts: 3495 info_menu_battery_volts:
3237 lfsr FSR1,tBatteryV 3496 lfsr FSR1,tBatteryV
3238 call strcat_text 3497 call strcat_text
3239 movff batt_voltage+1,hi 3498 MOVII batt_voltage,mpr
3240 movff batt_voltage+0,lo
3241 bsf leftbind 3499 bsf leftbind
3242 output_16dp .2 ; x.xxx 3500 output_16dp .2 ; x.xxx
3243 STRCAT "V(T" 3501 STRCAT "V(T"
3244 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 3502 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
3245 output_8 3503 output_8
3246 bcf leftbind 3504 bcf leftbind
3247 PUTC ")" 3505 PUTC ")"
3248 return 3506 return
3249 3507
3250 ; For the Information menu: append uptime 3508 ;-----------------------------------------------------------------------------
3509 ; For the Information menu: append uptime
3510
3251 global info_menu_uptime 3511 global info_menu_uptime
3252 info_menu_uptime: 3512 info_menu_uptime:
3253 lfsr FSR1,tUptime 3513 lfsr FSR1,tUptime
3254 call strcat_text 3514 call strcat_text
3255 movff uptime+0,xC+0 3515 SMOVFF uptime,xC ; ISR-safe copy of uptime:4 to xC:4
3256 movff uptime+1,xC+1 3516
3257 movff uptime+2,xC+2 3517 info_menu_uptime_com:
3258 movff uptime+3,xC+3 3518 MOVLI .3600,xB ; one hour = 3600s
3259 movlw LOW .3600 3519 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder -> xC+1:xC+0 holds full hours
3260 movwf xB+0 3520 MOVII xC,xA
3261 movlw HIGH .3600 3521 MOVLI .24,xB ; one day = 24 hours
3262 movwf xB+1 ; one day = 3600s 3522 call div16x16 ; xC:2 = xA:2 / xB:2 with xA as remainder -> xC+1:xC+0 holds full days, xA holds full hours
3263 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder 3523 MOVII xC,mpr ; copy full days into hi:lo
3264 ;xC+0:xC+1 -> Full hours
3265 movff xC+1,xA+1
3266 movff xC+0,xA+0
3267 clrf xB+1
3268 movlw .24
3269 movwf xB+0
3270 call div16x16 ; xC = xA / xB with xA as remainder
3271 movff xC+0,lo
3272 movff xC+1,hi ; full days
3273 bsf leftbind 3524 bsf leftbind
3274 output_16 3525 output_16
3275 PUTC "d" 3526 PUTC "d"
3276 movff xA+0,lo ; full hours 3527 movff xA+0,lo ; full hours
3277 output_8 3528 output_8
3278 PUTC "h" 3529 PUTC "h"
3279 bcf leftbind 3530 bcf leftbind
3280 return ; done 3531 return ; done
3281 3532
3282 3533
3534 IFDEF _compass
3535
3283 global menu_cal_x 3536 global menu_cal_x
3284 menu_cal_x: 3537 menu_cal_x:
3285 lfsr FSR0,compass_CX_f 3538 lfsr FSR0,compass_CX_f
3286 lfsr FSR1,tCalX 3539 lfsr FSR1,tCalX
3287 bra menu_cal_common 3540 bra menu_cal_common
3294 3547
3295 global menu_cal_z 3548 global menu_cal_z
3296 menu_cal_z: 3549 menu_cal_z:
3297 lfsr FSR0,compass_CZ_f 3550 lfsr FSR0,compass_CZ_f
3298 lfsr FSR1,tCalZ 3551 lfsr FSR1,tCalZ
3552 ;bra menu_cal_common
3553
3299 menu_cal_common: 3554 menu_cal_common:
3300 call strcat_text 3555 call strcat_text
3301 movff POSTINC0,lo 3556 movff POSTINC0,lo
3302 movff POSTINC0,hi 3557 movff POSTINC0,hi
3303 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 3558 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and adds '-' to POSTINC2 if required
3304 bsf leftbind 3559 bsf leftbind
3305 output_16 3560 output_16
3306 bcf leftbind 3561 bcf leftbind
3307 return 3562 return
3563
3564 ENDIF ; _compass
3308 3565
3309 3566
3310 ;----------------------------------------------------------------------------- 3567 ;-----------------------------------------------------------------------------
3311 ; ppO2 menu 3568 ; ppO2 menu
3312 3569
3316 call strcat_text 3573 call strcat_text
3317 movff char_I_ppO2_min,lo 3574 movff char_I_ppO2_min,lo
3318 movlw ppo2_warning_low_default 3575 movlw ppo2_warning_low_default
3319 bra divesets_ppo2_common 3576 bra divesets_ppo2_common
3320 3577
3578
3579 IFDEF _ccr_pscr
3580
3321 global divesets_ppo2_min_cc 3581 global divesets_ppo2_min_cc
3322 divesets_ppo2_min_cc: 3582 divesets_ppo2_min_cc:
3323 lfsr FSR1,tPPO2MINCC 3583 lfsr FSR1,tPPO2MINCC
3324 call strcat_text 3584 call strcat_text
3325 movff char_I_ppO2_min_loop,lo 3585 movff char_I_ppO2_min_loop,lo
3326 movlw ppo2_warning_loop_default 3586 movlw ppo2_warning_loop_default
3327 bra divesets_ppo2_common 3587 bra divesets_ppo2_common
3328 3588
3589 ENDIF
3590
3329 global divesets_ppo2_max 3591 global divesets_ppo2_max
3330 divesets_ppo2_max: 3592 divesets_ppo2_max:
3331 lfsr FSR1,tPPO2Max 3593 lfsr FSR1,tPPO2Max
3332 call strcat_text 3594 call strcat_text
3333 movff char_I_ppO2_max,lo 3595 movff char_I_ppO2_max_work,lo
3334 movlw ppo2_warning_high_default 3596 movlw ppo2_warning_high_default
3335 bra divesets_ppo2_common 3597 bra divesets_ppo2_common
3336 3598
3337 global divesets_ppo2_max_deco 3599 global divesets_ppo2_max_deco
3338 divesets_ppo2_max_deco: 3600 divesets_ppo2_max_deco:
3358 PUTC "*" 3620 PUTC "*"
3359 return ; done 3621 return ; done
3360 3622
3361 ;============================================================================= 3623 ;=============================================================================
3362 3624
3363 global TFT_clear_warning_text 3625 global TFT_clear_message_window
3364 TFT_clear_warning_text: 3626 TFT_clear_message_window:
3365 btfss divemode ; in divemode? 3627 btfss divemode ; in dive mode?
3366 bra TFT_clear_warning_text2 ; NO - setup for surface mode 3628 bra TFT_clear_message_window_surf ; NO - clear surface mode area
3367 bcf FLAG_TFT_dive_warning_text_clear ; clear flag 3629 ;bra TFT_clear_message_window_dive ; YES - clear dive mode area
3368 btfsc alternative_divelayout 3630
3369 bra TFT_clear_warning_text_2nd_row ; in alt. mode, clear only row 2 3631 TFT_clear_message_window_dive:
3632 btfsc alt_layout_active ; in alternative layout?
3633 bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only
3634 ; NO - clear dive mode area, both rows
3370 WIN_BOX_BLACK dm_warning_row, dm_warning_bot, dm_warning_column, dm_warning_rgt ; top, bottom, left, right 3635 WIN_BOX_BLACK dm_warning_row, dm_warning_bot, dm_warning_column, dm_warning_rgt ; top, bottom, left, right
3371 return 3636 return ; - done
3372 TFT_clear_warning_text2: 3637
3638 TFT_clear_message_window_surf:
3373 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ; top, bottom, left, right 3639 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ; top, bottom, left, right
3374 return 3640 return ; done
3375 3641
3376 global TFT_clear_warning_text_2nd_row 3642
3377 TFT_clear_warning_text_2nd_row: 3643 global TFT_clear_message_window_row2
3378 btfss divemode ; in divemode? 3644 TFT_clear_message_window_row2:
3379 bra TFT_clear_warning_text_2nd_2 ; NO - setup for surface mode 3645 btfss divemode ; in dive mode?
3380 bcf FLAG_TFT_dive_warning_text_clr2 ; clear flag 3646 bra TFT_clear_message_window_surf_2 ; NO - clear surface mode area, 2nd row only
3647 ;bra TFT_clear_message_window_dive_2 ; YES - clear dive mode area, 2nd row only
3648
3649 TFT_clear_message_window_dive_2:
3381 WIN_BOX_BLACK dm_warning2_row, dm_warning2_bot, dm_warning2_column, dm_warning2_rgt ; top, bottom, left, right 3650 WIN_BOX_BLACK dm_warning2_row, dm_warning2_bot, dm_warning2_column, dm_warning2_rgt ; top, bottom, left, right
3382 return 3651 bcf message_2nd_row_used ; - 2nd row is clear now
3383 TFT_clear_warning_text_2nd_2: 3652 return ; - done
3653
3654 TFT_clear_message_window_surf_2:
3384 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ; top, bottom, left, right 3655 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ; top, bottom, left, right
3385 return 3656 bcf message_2nd_row_used ; 2nd row is clear now
3657 return ; done
3658
3386 3659
3387 global TFT_fillup_with_spaces 3660 global TFT_fillup_with_spaces
3388 TFT_fillup_with_spaces: ; fill up FSR2 with spaces (total string length in #WREG) 3661 TFT_fillup_with_spaces: ; fill up FSR2 with spaces (total string length in #WREG)
3389 movwf lo ; save max. string length into lo 3662 movwf lo ; save max. string length into lo
3390 movf FSR2L,W ; get current string length 3663 movf FSR2L,W ; get current string length
3402 3675
3403 ;============================================================================= 3676 ;=============================================================================
3404 3677
3405 global TFT_desaturation_time 3678 global TFT_desaturation_time
3406 TFT_desaturation_time: 3679 TFT_desaturation_time:
3407 rcall TFT_warning_set_window ; set the row and column for the current message 3680 rcall TFT_set_message_window ; set the row and column for the current message
3408 tstfsz WREG ; is there room for the message? 3681 tstfsz WREG ; is there room for the message?
3409 return ; NO 3682 return ; NO
3410 call TFT_memo_color 3683 call TFT_memo_color
3411 STRCPY "Desat:" 3684 STRCPY "Desat:"
3412 movff int_O_desaturation_time+0,lo 3685 MOVII int_O_desaturation_time,mpr
3413 movff int_O_desaturation_time+1,hi 3686 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
3414 call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) 3687 movf lo,W ; swap hi and lo
3415 ; bsf leftbind 3688 movff hi,lo ; ...
3416 movf lo,W 3689 movwf hi ; ...
3417 movff hi,lo
3418 movwf hi ; exchange lo and hi...
3419 output_99x ; hours 3690 output_99x ; hours
3420 PUTC ':' 3691 PUTC ':'
3421 movff hi,lo ; minutes 3692 movff hi,lo ; minutes
3422 output_99x 3693 output_99x
3423 ; bcf leftbind
3424 movlw surf_warning_length ; only use surface string length 3694 movlw surf_warning_length ; only use surface string length
3425 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3695 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3426 ; movlw .0 ; not needed
3427 ; movff WREG,buffer+11 ; not needed
3428 STRCAT_PRINT "" 3696 STRCAT_PRINT ""
3429 return 3697 return
3430 3698
3431 3699
3432 global TFT_nofly_time 3700 global TFT_nofly_time
3433 TFT_nofly_time: 3701 TFT_nofly_time:
3434 rcall TFT_warning_set_window ; set the row and column for the current message 3702 rcall TFT_set_message_window ; set the row and column for the current message
3435 tstfsz WREG ; is there room for the message? 3703 tstfsz WREG ; is there room for the message?
3436 return ; NO 3704 return ; NO
3437 call TFT_memo_color 3705 call TFT_memo_color
3438 movff char_I_altitude_wait,WREG 3706 movff char_I_altitude_wait,WREG
3439 tstfsz WREG 3707 tstfsz WREG
3441 STRCPY "NoFly:" 3709 STRCPY "NoFly:"
3442 bra TFT_nofly_time_2 3710 bra TFT_nofly_time_2
3443 TFT_nofly_time_1: 3711 TFT_nofly_time_1:
3444 STRCPY "NoAlt:" 3712 STRCPY "NoAlt:"
3445 TFT_nofly_time_2: 3713 TFT_nofly_time_2:
3446 movff int_O_nofly_time+0,lo 3714 MOVII int_O_nofly_time,mpr
3447 movff int_O_nofly_time+1,hi 3715 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
3448 call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) 3716 movf lo,W ; swap hi and lo
3449 ; bsf leftbind 3717 movff hi,lo ; ...
3450 movf lo,W 3718 movwf hi ; ...
3451 movff hi,lo
3452 movwf hi ; exchange lo and hi...
3453 output_99x ; hours 3719 output_99x ; hours
3454 PUTC ':' 3720 PUTC ':'
3455 movff hi,lo ; minutes 3721 movff hi,lo ; minutes
3456 output_99x 3722 output_99x
3457 ; bcf leftbind
3458 movlw surf_warning_length ; only use surface string length 3723 movlw surf_warning_length ; only use surface string length
3459 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3724 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3460 ; movlw .0 ; not needed
3461 ; movff WREG,buffer+11 ; not needed
3462 STRCAT_PRINT "" 3725 STRCAT_PRINT ""
3463 return 3726 return
3464 3727
3465 ;============================================================================= 3728 ;=============================================================================
3466 3729
3467 global TFT_warning_agf 3730 global TFT_warning_agf
3468 TFT_warning_agf: 3731 TFT_warning_agf:
3469 rcall TFT_warning_set_window ; set the row and column for the current message 3732 rcall TFT_set_message_window ; set the row and column for the current message
3470 tstfsz WREG ; is there room for the message? 3733 tstfsz WREG ; is there room for the message?
3471 return ; NO 3734 return ; NO
3472 call TFT_attention_color 3735 call TFT_attention_color
3473 STRCPY_TEXT tDiveaGF_active ; "aGF!" 3736 STRCPY_TEXT tDiveaGF_active ; "aGF!"
3474 movlw dm_warning_length ; divemode string length 3737 movlw dm_warning_length ; dive mode string length
3475 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3738 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3476 STRCAT_PRINT "" 3739 STRCAT_PRINT ""
3477 bra TFT_warn_att_info_exit ; and return... 3740 bra TFT_warn_att_info_exit ; and return...
3478 3741
3479 3742
3480 global TFT_warning_fallback 3743 global TFT_warning_fallback
3481 TFT_warning_fallback: ; show fallback warning 3744 TFT_warning_fallback: ; show fallback warning
3482 rcall TFT_warning_set_window ; set the row and column for the current message 3745 rcall TFT_set_message_window ; set the row and column for the current message
3483 tstfsz WREG ; is there room for the message? 3746 tstfsz WREG ; is there room for the message?
3484 return ; NO 3747 return ; NO
3485 call TFT_warnings_color 3748 call TFT_warning_color
3486 STRCPY_TEXT tDiveFallback ; "Fallback!" 3749 STRCPY_TEXT tDiveFallback ; "Fallback!"
3487 movlw dm_warning_length ; divemode string length 3750 movlw dm_warning_length ; dive mode string length
3488 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3751 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3489 STRCAT_PRINT "" 3752 STRCAT_PRINT ""
3490 bra TFT_warn_att_info_exit ; and return... 3753 bra TFT_warn_att_info_exit ; and return...
3491 3754
3755 ;=============================================================================
3492 3756
3493 IFDEF _rx_functions 3757 IFDEF _rx_functions
3494 3758
3495 global TFT_advice_switch 3759 global TFT_advice_switch
3496 TFT_advice_switch: 3760 TFT_advice_switch:
3497 rcall TFT_warning_set_window ; set the row and column for the current message 3761 rcall TFT_set_message_window ; set the row and column for the current message
3498 tstfsz WREG ; is there room for the message? 3762 tstfsz WREG ; is there room for the message?
3499 return ; NO 3763 return ; NO
3500 call TFT_advice_color 3764 call TFT_advice_color
3501 STRCPY_TEXT tswap ; "Swap Tank" 3765 STRCPY_TEXT tswap ; "Swap Tank"
3502 movlw dm_warning_length ; divemode string length 3766 movlw dm_warning_length ; dive mode string length
3503 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3767 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3504 STRCAT_PRINT "" 3768 STRCAT_PRINT ""
3505 bra TFT_warn_att_info_exit ; and return... 3769 bra TFT_warn_att_info_exit ; and return...
3506 3770
3507 global TFT_attention_transmitter 3771 global TFT_attention_transmitter
3508 TFT_attention_transmitter: 3772 TFT_attention_transmitter:
3509 rcall TFT_warning_set_window ; set the row and column for the current message 3773 rcall TFT_set_message_window ; set the row and column for the current message
3510 tstfsz WREG ; is there room for the message? 3774 tstfsz WREG ; is there room for the message?
3511 return ; NO 3775 return ; NO
3512 call TFT_attention_color 3776 call TFT_attention_color
3513 STRCPY_TEXT tTransmitter ; "P.Transm." 3777 STRCPY_TEXT tTransmitter ; "P.Transm."
3514 movlw dm_warning_length ; divemode string length 3778 movlw dm_warning_length ; dive mode string length
3515 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3779 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3516 STRCAT_PRINT "" 3780 STRCAT_PRINT ""
3517 bra TFT_warn_att_info_exit ; and return... 3781 bra TFT_warn_att_info_exit ; and return...
3518 3782
3519 global TFT_attention_pres_reading 3783 global TFT_attention_pres_reading
3520 global TFT_warning_pres_reading 3784 global TFT_warning_pres_reading
3521 TFT_attention_pres_reading: ; entry point for attention 3785 TFT_attention_pres_reading: ; entry point for attention
3522 call TFT_attention_color ; use attention color 3786 call TFT_attention_color ; use attention color
3523 bra TFT_common_pres_reading ; continue with common code 3787 bra TFT_common_pres_reading ; continue with common code
3524 TFT_warning_pres_reading: ; entry point for warning 3788 TFT_warning_pres_reading: ; entry point for warning
3525 call TFT_warnings_color ; use warnings color 3789 call TFT_warning_color ; use warnings color
3526 ;bra TFT_common_pres_reading ; continue with common code 3790 ;bra TFT_common_pres_reading ; continue with common code
3527 TFT_common_pres_reading: 3791 TFT_common_pres_reading:
3528 rcall TFT_warning_set_window ; set the row and column for the current message 3792 rcall TFT_set_message_window ; set the row and column for the current message
3529 tstfsz WREG ; is there room for the message? 3793 tstfsz WREG ; is there room for the message?
3530 return ; NO - done 3794 return ; NO - done
3531 STRCPY_TEXT tPressure ; "Tank Pres" 3795 STRCPY_TEXT tPressure ; "Tank Pres"
3532 movlw dm_warning_length ; divemode string length 3796 movlw dm_warning_length ; dive mode string length
3533 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3797 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3534 STRCAT_PRINT "" 3798 STRCAT_PRINT ""
3535 bra TFT_warn_att_info_exit ; and return... 3799 bra TFT_warn_att_info_exit ; and return...
3536 3800
3537 global TFT_attention_sac 3801 global TFT_attention_sac
3538 TFT_attention_sac: 3802 TFT_attention_sac:
3539 rcall TFT_warning_set_window ; set the row and column for the current message 3803 rcall TFT_set_message_window ; set the row and column for the current message
3540 tstfsz WREG ; is there room for the message? 3804 tstfsz WREG ; is there room for the message?
3541 return ; NO 3805 return ; NO
3542 movff int_O_sac_rate+0,lo ; copy SAC rate to hi:lo 3806 MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo
3543 movff int_O_sac_rate+1,hi ; ...
3544 call TFT_color_code_tank_pres_sac; color-code the output 3807 call TFT_color_code_tank_pres_sac; color-code the output
3545 STRCPY_TEXT tSAC ; "SAC", needs to be exactly 3 chars long 3808 STRCPY_TEXT tSAC ; "SAC", needs to be exactly 3 chars long
3546 STRCAT ": " ; ": " 3809 STRCAT ": " ; ": "
3547 output_16_3 ; print as xxx 3810 output_16_3 ; print as xxx
3548 PUTC " " ; print a dummy char to have string termination at the correct place 3811 PUTC " " ; print a dummy char to have string termination at the correct place
3550 movlw "." ; load coding of a decimal point 3813 movlw "." ; load coding of a decimal point
3551 movff WREG,buffer+.7 ; place it before decimal digit 3814 movff WREG,buffer+.7 ; place it before decimal digit
3552 STRCAT_PRINT "" ; dump buffer to screen 3815 STRCAT_PRINT "" ; dump buffer to screen
3553 bra TFT_warn_att_info_exit ; and return... 3816 bra TFT_warn_att_info_exit ; and return...
3554 3817
3555 ENDIF 3818 ENDIF ; _rx_functions
3556 3819
3820 ;=============================================================================
3557 3821
3558 global TFT_info_deco 3822 global TFT_info_deco
3559 TFT_info_deco ; show info when decompression obligation is decreasing 3823 TFT_info_deco ; show info when decompression obligation is steady or decreasing
3560 rcall TFT_warning_set_window ; sets the row and column for the current message 3824 rcall TFT_set_message_window ; set the row and column for the current message
3561 tstfsz WREG ; is there room for the message? 3825 tstfsz WREG ; is there room for the message?
3562 return ; NO - return 3826 return ; NO - return
3563 call TFT_advice_color ; actually it is a memo, but we break the rules here and display in advice color (green) 3827 call TFT_advice_color ; YES - actually it is a memo, but we break the rules here and display in advice color (green)
3564 STRCPY_TEXT tDecoInfo ; write "Deco Zone" 3828 STRCPY_TEXT tDecoInfo ; - write "Deco Zone"
3565 movlw dm_warning_length ; select divemode string length 3829 movlw dm_warning_length ; - select dive mode string length
3566 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3830 rcall TFT_fillup_with_spaces ; - fill up FSR2 with spaces (total string length in #WREG)
3567 STRCAT_PRINT "" ; print buffer 3831 STRCAT_PRINT "" ; - print buffer
3568 bra TFT_warn_att_info_exit ; and return... 3832 bra TFT_warn_att_info_exit ; - and return...
3569 3833
3834 ;=============================================================================
3570 3835
3571 IFDEF _cave_mode 3836 IFDEF _cave_mode
3572 3837
3573 global TFT_info_cave_mode 3838 global TFT_info_cave_mode
3574 TFT_info_cave_mode: 3839 TFT_info_cave_mode:
3575 rcall TFT_warning_set_window ; sets the row and column for the current warning 3840 rcall TFT_set_message_window ; sets the row and column for the current warning
3576 tstfsz WREG ; is there room for the message? 3841 tstfsz WREG ; is there room for the message?
3577 return ; NO - return 3842 return ; NO - return
3578 call TFT_memo_color ; YES - set memo color 3843 call TFT_memo_color ; YES - set memo color
3579 STRCPY_TEXT tCaveMode ; write "Cave Mode" 3844 STRCPY_TEXT tCaveMode ; write "Cave Mode"
3580 movlw dm_warning_length ; select divemode string length 3845 movlw dm_warning_length ; select dive mode string length
3581 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3846 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3582 STRCAT_PRINT "" ; print buffer 3847 STRCAT_PRINT "" ; print buffer
3583 bra TFT_warn_att_info_exit ; and return... 3848 bra TFT_warn_att_info_exit ; and return...
3584 3849
3585 global TFT_info_dive_turned 3850 global TFT_info_dive_turned
3586 TFT_info_dive_turned: 3851 TFT_info_dive_turned:
3587 rcall TFT_warning_set_window ; sets the row and column for the current warning 3852 rcall TFT_set_message_window ; sets the row and column for the current warning
3588 tstfsz WREG ; is there room for the message? 3853 tstfsz WREG ; is there room for the message?
3589 return ; NO - return 3854 return ; NO - return
3590 call TFT_attention_color ; YES - set attention color 3855 call TFT_attention_color ; YES - set attention color
3591 STRCPY_TEXT tDiveTurned ; write "Dv.turned" 3856 STRCPY_TEXT tDiveTurned ; write "Dv.turned"
3592 movlw dm_warning_length ; select divemode string length 3857 movlw dm_warning_length ; select dive mode string length
3593 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3858 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3594 STRCAT_PRINT "" ; print buffer 3859 STRCAT_PRINT "" ; print buffer
3595 bra TFT_warn_att_info_exit ; and return... 3860 bra TFT_warn_att_info_exit ; and return...
3596 3861
3597 global TFT_warn_cave_shutdown 3862 global TFT_warn_cave_shutdown
3598 TFT_warn_cave_shutdown: 3863 TFT_warn_cave_shutdown:
3599 rcall TFT_warning_set_window ; sets the row and column for the current warning 3864 rcall TFT_set_message_window ; sets the row and column for the current warning
3600 tstfsz WREG ; is there room for the message? 3865 tstfsz WREG ; is there room for the message?
3601 return ; NO - return 3866 return ; NO - return
3602 call TFT_warnings_color ; YES - set warning color 3867 call TFT_warning_color ; YES - set warning color
3603 STRCPY_TEXT tCaveModeShutdown ; write "X-Cave-X" 3868 STRCPY_TEXT tCaveModeShutdown ; write "X-Cave-X"
3604 movlw dm_warning_length ; select divemode string length 3869 movlw dm_warning_length ; select dive mode string length
3605 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3870 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3606 STRCAT_PRINT "" ; print buffer 3871 STRCAT_PRINT "" ; print buffer
3607 bra TFT_warn_att_info_exit ; and return... 3872 bra TFT_warn_att_info_exit ; and return...
3608 3873
3609 ENDIF 3874 ENDIF ; _cave_mode
3610 3875
3611 3876 ;=============================================================================
3612 global TFT_warning_gf 3877
3613 TFT_warning_gf: ; GF 3878 global TFT_warning_sat
3614 rcall TFT_warning_set_window ; set the row and column for the current message 3879 TFT_warning_sat ; Saturation
3880 rcall TFT_set_message_window ; set the row and column for the current message
3615 tstfsz WREG ; is there room for the message? 3881 tstfsz WREG ; is there room for the message?
3616 return ; NO 3882 return ; NO
3617 movff int_O_gradient_factor+0,lo ; bank-safe copy gradient factor 3883 MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation
3618 movff int_O_gradient_factor+1,hi ;
3619 call TFT_color_code_gf ; color-code output 3884 call TFT_color_code_gf ; color-code output
3620 STRCPY "GF: " ; the two spaces are on purpose to align the output with other warnings' outputs 3885 ; STRCPY "GF: " ; the two spaces are on purpose to align the output with other warnings' outputs
3886 STRCPY_TEXT tSAT ; print "Sat:"
3887 PUTC " " ; add a space to align the output with other warnings' outputs
3621 bsf leftbind 3888 bsf leftbind
3622 output_8 ; print value of lo only, int_O_gradient_factor is limited to 255 3889 output_8 ; print value of lo only, int_O_lead_supersat is limited to 255
3623 PUTC "%" 3890 PUTC "%"
3624 movlw dm_warning_length ; divemode string length 3891 movlw dm_warning_length ; dive mode string length
3625 btfss divemode ; in divemode? 3892 btfss divemode ; in dive mode?
3626 movlw surf_warning_length ; NO - use surface string length 3893 movlw surf_warning_length ; NO - use surface string length
3627 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3894 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3628 STRCAT_PRINT "" 3895 STRCAT_PRINT ""
3629 bcf leftbind 3896 bcf leftbind
3630 bcf win_invert 3897 bcf win_invert
3632 goto TFT_standard_color ; and return... 3899 goto TFT_standard_color ; and return...
3633 3900
3634 3901
3635 global TFT_warning_mbubbles 3902 global TFT_warning_mbubbles
3636 TFT_warning_mbubbles: 3903 TFT_warning_mbubbles:
3637 rcall TFT_warning_set_window ; sets the row and column for the current warning 3904 rcall TFT_set_message_window ; sets the row and column for the current warning
3638 tstfsz WREG ; is there room for the message? 3905 tstfsz WREG ; is there room for the message?
3639 return ; NO 3906 return ; NO
3640 call TFT_attention_color ; set attention color as default 3907 call TFT_attention_color ; set attention color as default
3641 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings 3908 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
3642 btfsc WREG,mbubble_warning ; are we in the microbubbles zone right now? 3909 btfsc WREG,mbubble_warning ; are we in the microbubbles zone right now?
3643 call TFT_warnings_color ; YES - reconfigure to warning color 3910 call TFT_warning_color ; YES - reconfigure to warning color
3644 STRCPY_TEXT tMicroBubbles 3911 STRCPY_TEXT tMicroBubbles
3645 movlw dm_warning_length ; divemode string length 3912 movlw dm_warning_length ; dive mode string length
3646 btfss divemode ; in divemode? 3913 btfss divemode ; in dive mode?
3647 movlw surf_warning_length ; NO - use surface string length 3914 movlw surf_warning_length ; NO - use surface string length
3648 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3915 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3649 STRCAT_PRINT "" 3916 STRCAT_PRINT ""
3650 bra TFT_warn_att_info_exit ; and return... 3917 bra TFT_warn_att_info_exit ; and return...
3651 3918
3652 3919
3653 global TFT_warning_outside 3920 global TFT_warning_outside
3654 TFT_warning_outside: 3921 TFT_warning_outside:
3655 rcall TFT_warning_set_window ; sets the row and column for the current warning 3922 rcall TFT_set_message_window ; sets the row and column for the current warning
3656 tstfsz WREG ; is there room for the message? 3923 tstfsz WREG ; is there room for the message?
3657 return ; NO 3924 return ; NO
3658 call TFT_attention_color 3925 call TFT_attention_color
3659 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings 3926 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
3660 btfsc WREG,outside_warning ; are we outside the ZH-L16 model right now? 3927 btfsc WREG,outside_warning ; are we outside the ZH-L16 model right now?
3661 call TFT_warnings_color ; YES - reconfigure to warning color 3928 call TFT_warning_color ; YES - reconfigure to warning color
3662 STRCPY "X-ZHL16-X" 3929 STRCPY "X-ZHL16-X"
3663 movlw dm_warning_length ; divemode string length 3930 movlw dm_warning_length ; dive mode string length
3664 btfss divemode ; in divemode? 3931 btfss divemode ; in dive mode?
3665 movlw surf_warning_length ; NO - use surface string length 3932 movlw surf_warning_length ; NO - use surface string length
3666 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3933 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3667 STRCAT_PRINT "" 3934 STRCAT_PRINT ""
3668 bra TFT_warn_att_info_exit ; and return... 3935 bra TFT_warn_att_info_exit ; and return...
3669 3936
3670 3937
3671 global TFT_warning_gas_needs_warn 3938 global TFT_warning_depth
3672 global TFT_warning_gas_needs_att 3939 TFT_warning_depth:
3673 TFT_warning_gas_needs_warn: 3940 rcall TFT_set_message_window ; sets the row and column for the current warning
3674 rcall TFT_warning_gas_needs_war_helper
3675 rcall TFT_warning_set_window ; set the row and column for the current message
3676 tstfsz WREG ; is there room for the message? 3941 tstfsz WREG ; is there room for the message?
3677 return ; NO 3942 return ; NO
3678 call TFT_warnings_color 3943 call TFT_warning_color
3679 bra TFT_warning_gas_needs_com 3944 STRCPY_TEXT tMaxDepth ; "max.Depth"
3680 TFT_warning_gas_needs_att: 3945 movlw dm_warning_length ; dive mode string length
3681 rcall TFT_warning_gas_needs_att_helper 3946 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
3682 rcall TFT_warning_set_window ; set the row and column for the current message 3947 STRCAT_PRINT ""
3948 bra TFT_warn_att_info_exit ; and return...
3949
3950
3951 global TFT_warning_gas_needs_warn
3952 TFT_warning_gas_needs_warn:
3953 rcall TFT_set_message_window ; set the row and column for the current message
3683 tstfsz WREG ; is there room for the message? 3954 tstfsz WREG ; is there room for the message?
3684 return ; NO 3955 return ; NO
3685 call TFT_attention_color 3956 call TFT_warning_color ; YES - set warning color
3957 bra TFT_warning_gas_needs_com ; - continue with common part
3958
3959 global TFT_warning_gas_needs_att
3960 TFT_warning_gas_needs_att:
3961 rcall TFT_set_message_window ; set the row and column for the current message
3962 tstfsz WREG ; is there room for the message?
3963 return ; NO
3964 call TFT_attention_color ; YES - set attention color
3965 ;bra TFT_warning_gas_needs_com ; - continue with common part
3966
3686 TFT_warning_gas_needs_com: 3967 TFT_warning_gas_needs_com:
3687 STRCPY_TEXT tGasNeedsWarn ; "Gas Needs" 3968 STRCPY_TEXT tGasNeedsWarn ; print "Gas Needs"
3688 movlw dm_warning_length ; divemode string length 3969 movlw dm_warning_length ; dive mode string length
3689 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3970 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
3690 STRCAT_PRINT "" 3971 STRCAT_PRINT "" ; finalize output
3691 bra TFT_warn_att_info_exit ; and return... 3972 bra TFT_warn_att_info_exit ; and return...
3692 3973
3693 TFT_warning_gas_needs_war_helper: 3974 ;=============================================================================
3694 incf message_counter,F ; increase counter 3975
3695 btfsc gas_needs_warning ; is it a new warning? 3976 IFDEF _helium
3696 return ; NO - do not show the gas needs custom view again
3697 bsf gas_needs_warning ; YES - memorize it's an old now
3698 bra TFT_warning_gas_needs_helper_com
3699 TFT_warning_gas_needs_att_helper:
3700 incf message_counter,F ; increase counter
3701 btfsc gas_needs_attention ; is it a new attention?
3702 return ; NO - do not show the gas needs custom view again
3703 bsf gas_needs_attention ; YES - memorize it's an old now
3704 TFT_warning_gas_needs_helper_com:
3705 btfsc alternative_divelayout ; in alternative layout?
3706 call switch_layout_to_normal ; YES - switch to normal layout
3707 movlw index_gas_needs_ascent-1 ; custom view number one below gas needs view
3708 movwf menupos3 ; set custom view number
3709 bsf toggle_customview ; initiate toggle to desired custom view -> gas needs view will be shown
3710 return
3711
3712 3977
3713 global TFT_warning_IBCD 3978 global TFT_warning_IBCD
3714 TFT_warning_IBCD: 3979 TFT_warning_IBCD:
3715 rcall TFT_warning_set_window ; set the row and column for the current message 3980 rcall TFT_set_message_window ; set the row and column for the current message
3716 tstfsz WREG ; is there room for the message? 3981 tstfsz WREG ; is there room for the message?
3717 return ; NO 3982 return ; NO
3718 call TFT_attention_color ; select attention color as default 3983 call TFT_attention_color ; select attention color as default
3719 STRCPY_TEXT tIBCD ; "IBCD N2He" 3984 STRCPY_TEXT tIBCD ; "IBCD N2He"
3720 movlw dm_warning_length ; divemode string length 3985 movlw dm_warning_length ; dive mode string length
3721 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 3986 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
3722 STRCAT_PRINT "" 3987 STRCAT_PRINT ""
3723 bra TFT_warn_att_info_exit ; and return... 3988 bra TFT_warn_att_info_exit ; and return...
3724 3989
3990 ENDIF
3991
3992 ;=============================================================================
3725 3993
3726 global TFT_warning_no_BO_gas 3994 global TFT_warning_no_BO_gas
3727 TFT_warning_no_BO_gas: 3995 TFT_warning_no_BO_gas:
3728 rcall TFT_warning_set_window ; set the row and column for the current message 3996 rcall TFT_set_message_window ; set the row and column for the current message
3729 tstfsz WREG ; is there room for the message? 3997 tstfsz WREG ; is there room for the message?
3730 return ; NO 3998 return ; NO
3731 call TFT_attention_color ; select attention color as default 3999 call TFT_warning_color ; select warning color
3732 STRCPY_TEXT tnoBOgas ; "B/O Gas X" 4000 STRCPY_TEXT tnoBOgas ; print "-B/O-Gas-"
3733 movlw dm_warning_length ; divemode string length 4001 movlw dm_warning_length ; dive mode string length
3734 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4002 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
3735 STRCAT_PRINT "" 4003 STRCAT_PRINT "" ; finalize output
3736 bra TFT_warn_att_info_exit ; and return... 4004 bra TFT_warn_att_info_exit ; and return...
3737 4005
3738 4006
3739 global TFT_advice_gas_change 4007 global TFT_advice_gas_change
3740 TFT_advice_gas_change: 4008 TFT_advice_gas_change:
3741 rcall TFT_warning_set_window ; set the row and column for the current message 4009 rcall TFT_set_message_window ; set the row and column for the current message
3742 tstfsz WREG ; is there room for the message? 4010 tstfsz WREG ; is there room for the message?
3743 return ; NO 4011 return ; NO
3744 call TFT_advice_color ; set advice color 4012 call TFT_advice_color ; set advice color
3745 STRCPY_TEXT tgaschange ; "Change?" 4013 STRCPY_TEXT tgaschange ; "Change?"
3746 movlw dm_warning_length ; divemode string length 4014 movlw dm_warning_length ; dive mode string length
3747 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4015 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
3748 STRCAT_PRINT "" 4016 STRCAT_PRINT ""
3749 bra TFT_warn_att_info_exit ; and return... 4017 bra TFT_warn_att_info_exit ; and return...
3750 4018
4019 ;=============================================================================
4020
4021 IFDEF _external_sensor
3751 4022
3752 global TFT_warning_sensor_disagree 4023 global TFT_warning_sensor_disagree
3753 TFT_warning_sensor_disagree: ; show sensor disagree warning 4024 TFT_warning_sensor_disagree: ; show sensor disagree warning
3754 rcall TFT_warning_sensor_dis_helper 4025 rcall TFT_set_message_window ; set the row and column for the current message
3755 rcall TFT_warning_set_window ; set the row and column for the current message
3756 tstfsz WREG ; is there room for the message? 4026 tstfsz WREG ; is there room for the message?
3757 return ; NO 4027 return ; NO
3758 call TFT_warnings_color 4028 call TFT_warning_color
3759 STRCPY_TEXT tSensorDisagree ; "Sensors<>" 4029 STRCPY_TEXT tSensorDisagree ; "Sensors<>"
3760 movlw dm_warning_length ; divemode string length 4030 movlw dm_warning_length ; dive mode string length
3761 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4031 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
3762 STRCAT_PRINT "" 4032 STRCAT_PRINT ""
3763 bra TFT_warn_att_info_exit ; and return... 4033 bra TFT_warn_att_info_exit ; and return...
3764 4034
3765 TFT_warning_sensor_dis_helper: 4035 ENDIF ; _external_sensor
3766 btfsc sensor_warning ; is it a new warning?
3767 return ; NO - do not show the gas needs custom view again
3768 bsf sensor_warning ; YES - memorize it's an old warning now
3769 btfsc alternative_divelayout ; in alternative layout?
3770 call switch_layout_to_normal ; YES - switch to normal layout
3771 movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors
3772 movwf menupos3 ; set custom view number
3773 bsf toggle_customview ; initiate toggle to desired custom view -> ppO2 sensors
3774 return
3775 4036
3776 ;============================================================================= 4037 ;=============================================================================
3777 4038
3778 TFT_warning_set_window: ; set the row and column for the current message 4039 TFT_set_message_window: ; set the row and column for the current message
3779 ; ignore warning (now)? 4040 ; ignore warning (now)?
3780 decf message_counter,W ; -1 4041 decf message_counter,W ; load (message counter - 1) into WREG
3781 bcf STATUS,C 4042 bcf STATUS,C ; clear carry bit
3782 btfss alternative_divelayout ; in alternative layout, do not divide... 4043 btfss alt_layout_active ; in alternative layout?
3783 rrcf WREG,W ; (message_counter-1)/2 4044 rrcf WREG,W ; NO - divide (message_counter-1) by 2 to get the page of the message
3784 cpfseq message_page 4045 cpfseq message_page ; page of the message = current page ?
3785 retlw .255 ; WREG <> 0 -> Warning window not defined 4046 retlw .255 ; NO - do not show in this cycle (message window is not defined)
3786 btfss divemode ; in divemode? 4047 btfss divemode ; YES - in dive mode?
3787 bra TFT_warning_set_window3 ; NO - setup for surface mode 4048 bra TFT_set_message_window_sf ; NO - setup for surface mode
3788 btfss alternative_divelayout 4049 ;bra TFT_set_message_window_dm ; YES - setup for dive mode
3789 bra TFT_warning_set_window3a ; standard layout 4050
3790 bra TFT_warning_set_window2a ; alternative layout (Only lower row used) 4051 ; Dive Mode
3791 TFT_warning_set_window3a: 4052 TFT_set_message_window_dm:
3792 btfss message_counter,0 ; toggle with each warning 4053 btfsc alt_layout_active ; in alternative layout?
3793 bra TFT_warning_set_window2 4054 bra TFT_set_message_window_dm_row2 ; YES - alternative layout only uses 2nd row
3794 WIN_SMALL dm_warning1_column, dm_warning1_row 4055 btfss message_counter,0 ; NO - is the message number uneven?
3795 bcf second_row_warning ; =1: The second row contains a warning 4056 bra TFT_set_message_window_dm_row2 ; NO - use 2nd row
3796 retlw .0 ; WREG=0 -> Warning window defined 4057 ;bra TFT_set_message_window_dm_row1 ; YES - use 1st row
3797 TFT_warning_set_window2: 4058
3798 bsf second_row_warning ; =1: The second row contains a warning 4059 TFT_set_message_window_dm_row1:
3799 TFT_warning_set_window2a: 4060 WIN_SMALL dm_warning1_column, dm_warning1_row ; set output position
3800 WIN_SMALL dm_warning2_column, dm_warning2_row 4061 bcf message_2nd_row_used ; flag that the 2nd does not contain a message yet
3801 retlw .0 ; WREG=0 -> Warning window defined 4062 retlw .0 ; show in this cycle (message window is defined)
3802 TFT_warning_set_window3: 4063
3803 btfss message_counter,0 ; toggle with each warning 4064 TFT_set_message_window_dm_row2:
3804 bra TFT_warning_set_window4 4065 WIN_SMALL dm_warning2_column, dm_warning2_row ; set output position
3805 WIN_SMALL surf_warning1_column,surf_warning1_row 4066 bsf message_2nd_row_used ; flag that the 2nd row contains a message now
3806 bcf second_row_warning ; =1: The second row contains a warning 4067 retlw .0 ; show in this cycle (message window is defined)
3807 retlw .0 ; WREG=0 -> Warning window defined 4068
3808 TFT_warning_set_window4: 4069 ; Surface Mode
3809 WIN_SMALL surf_warning2_column,surf_warning2_row 4070 TFT_set_message_window_sf:
3810 bsf second_row_warning ; =1: The second row contains a warning 4071 btfss message_counter,0 ; is the message counter uneven?
3811 retlw .0 ; WREG=0 -> Warning window defined 4072 bra TFT_set_message_window_sf_row2 ; NO - use 2nd row
3812 4073 ;bra TFT_set_message_window_sf_row1 ; YES - use 1st row
3813 4074
3814 global TFT_update_batt_percent_divemode 4075 TFT_set_message_window_sf_row1:
3815 TFT_update_batt_percent_divemode: 4076 WIN_SMALL surf_warning1_column,surf_warning1_row ; set output position
3816 rcall TFT_warning_set_window ; set the row and column for the current message 4077 bcf message_2nd_row_used ; flag that the 2nd row does not contain a message yet
4078 retlw .0 ; show in this cycle (message window is defined)
4079
4080 TFT_set_message_window_sf_row2:
4081 WIN_SMALL surf_warning2_column,surf_warning2_row ; set output position
4082 bsf message_2nd_row_used ; flag that the 2nd row contains a message now
4083 retlw .0 ; show in this cycle (message window is defined)
4084
4085
4086 global TFT_msg_batt_percent_divemode
4087 TFT_msg_batt_percent_divemode:
4088 rcall TFT_set_message_window ; set the row and column for the current message
3817 tstfsz WREG ; is there room for the message? 4089 tstfsz WREG ; is there room for the message?
3818 return ; NO 4090 return ; NO
3819 movff batt_percent,lo ; get battery percent 4091 movff batt_percent,lo ; get battery percent
3820 call TFT_color_code_battery ; color-code battery percent 4092 call TFT_color_code_battery ; color-code battery percent
3821 STRCPY "Batt:" 4093 STRCPY "Batt:"
3822 bsf leftbind 4094 bsf leftbind
3823 output_8 4095 output_8
3824 bcf leftbind 4096 bcf leftbind
3825 PUTC "%" 4097 PUTC "%"
3826 movlw dm_warning_length ; divemode string length 4098 movlw dm_warning_length ; dive mode string length
3827 btfss divemode ; in divemode? 4099 btfss divemode ; in dive mode?
3828 movlw surf_warning_length ; NO - use surface string length 4100 movlw surf_warning_length ; NO - use surface string length
3829 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4101 rcall TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
3830 STRCAT_PRINT "" 4102 STRCAT_PRINT ""
3831 bcf win_invert 4103 bcf win_invert
3832 bra TFT_custview_exit1 ; and return... 4104 bra TFT_custview_exit1 ; and return...
3839 STRCPY_TEXT_PRINT tGFactors 4111 STRCPY_TEXT_PRINT tGFactors
3840 WIN_TINY dm_custom_gf_column3,dm_custom_gf_title_row 4112 WIN_TINY dm_custom_gf_column3,dm_custom_gf_title_row
3841 STRCPY_TEXT_PRINT taGFactors 4113 STRCPY_TEXT_PRINT taGFactors
3842 ; Show GF (static) 4114 ; Show GF (static)
3843 call TFT_disabled_color ; default to disabled color 4115 call TFT_disabled_color ; default to disabled color
3844 btfss use_agf ; shall use alternative GF factors? 4116 btfss use_aGF ; shall use alternative GF factors?
3845 call TFT_memo_color ; NO - switch to memo color 4117 call TFT_memo_color ; NO - switch to memo color
3846 WIN_STD dm_custom_gf_column1, dm_custom_gf_row 4118 WIN_STD dm_custom_gf_column1, dm_custom_gf_row
3847 bsf leftbind 4119 bsf leftbind
3848 movff opt_GF_low,lo ; get normal GF low 4120 movff opt_GF_low,lo ; get normal GF low
3849 output_8 ; print normal GF low 4121 output_8 ; print normal GF low
3855 call TFT_memo_color ; default to memo color 4127 call TFT_memo_color ; default to memo color
3856 TSTOSS opt_enable_aGF ; are alternative GF factors enabled? 4128 TSTOSS opt_enable_aGF ; are alternative GF factors enabled?
3857 bra TFT_gf_factors_mask_3 ; NO - show "---" and return 4129 bra TFT_gf_factors_mask_3 ; NO - show "---" and return
3858 ; YES - show aGF and which one is active 4130 ; YES - show aGF and which one is active
3859 WIN_STD dm_custom_gf_column2, dm_custom_gf_row 4131 WIN_STD dm_custom_gf_column2, dm_custom_gf_row
3860 btfss use_agf ; shall use aGF? 4132 btfss use_aGF ; shall use aGF?
3861 bra TFT_gf_factors_mask_1 ; NO - print "<- " 4133 bra TFT_gf_factors_mask_1 ; NO - print "<- "
3862 STRCPY_PRINT " ->" ; YES - print " ->" 4134 STRCPY_PRINT " ->" ; YES - print " ->"
3863 bra TFT_gf_factors_mask_2 ; - continue with common part 4135 bra TFT_gf_factors_mask_2 ; - continue with common part
3864 TFT_gf_factors_mask_1: 4136 TFT_gf_factors_mask_1:
3865 STRCPY_PRINT "<- " ; (NO) - print "<- " 4137 STRCPY_PRINT "<- " ; (NO) - print "<- "
3866 TFT_gf_factors_mask_2: ; common part 4138 TFT_gf_factors_mask_2: ; common part
3867 btfss use_agf ; shall use aGF? 4139 btfss use_aGF ; shall use aGF?
3868 call TFT_disabled_color ; NO - switch to disabled color 4140 call TFT_disabled_color ; NO - switch to disabled color
3869 WIN_STD dm_custom_gf_column3, dm_custom_gf_row 4141 WIN_STD dm_custom_gf_column3, dm_custom_gf_row
3870 movff opt_aGF_low,lo ; get aGF low 4142 movff opt_aGF_low,lo ; get aGF low
3871 output_8 ; print 4143 output_8 ; print
3872 PUTC "/" ; print "/" 4144 PUTC "/" ; print "/"
3885 call TFT_divemask_color 4157 call TFT_divemask_color
3886 WIN_TINY dm_custom_ceiling_column+.2,dm_custom_ceiling_title_row 4158 WIN_TINY dm_custom_ceiling_column+.2,dm_custom_ceiling_title_row
3887 STRCPY_TEXT_PRINT tCeiling 4159 STRCPY_TEXT_PRINT tCeiling
3888 WIN_TINY dm_custom_tissue_title_column, dm_custom_tissue_title_row 4160 WIN_TINY dm_custom_tissue_title_column, dm_custom_tissue_title_row
3889 STRCPY_TEXT_PRINT tDiveTissues 4161 STRCPY_TEXT_PRINT tDiveTissues
3890 ; collides with ceiling output and not really needed, too
3891 ; WIN_TINY dm_custom_tissue_N2_column, dm_custom_tissue_N2_row
3892 ; STRCPY_TEXT_PRINT tN2
3893 ; WIN_TINY dm_custom_tissue_He_column, dm_custom_tissue_He_row
3894 ; STRCPY_TEXT_PRINT tHe
3895 WIN_TINY dm_custom_gf_column1+.5, dm_custom_gf_title_row 4162 WIN_TINY dm_custom_gf_column1+.5, dm_custom_gf_title_row
3896 STRCPY_TEXT_PRINT tGFInfo 4163 STRCPY_TEXT_PRINT tGFInfo
3897 bra TFT_custview_exit1 ; and return... 4164 bra TFT_custview_exit1 ; and return...
3898 4165
3899 4166
3900 global TFT_ceiling_GF_tissue ; data for ceiling, current GF and tissues 4167 global TFT_ceiling_GF_tissue ; data for ceiling, current GF and tissues
3901 TFT_ceiling_GF_tissue: 4168 TFT_ceiling_GF_tissue:
3902 WIN_MEDIUM dm_custom_ceiling_column,dm_custom_ceiling_row 4169 WIN_MEDIUM dm_custom_ceiling_column,dm_custom_ceiling_row
3903 movff int_O_ceiling+0,lo 4170 MOVII int_O_ceiling,mpr
3904 movff int_O_ceiling+1,hi
3905 call TFT_color_code_ceiling ; color-code the output 4171 call TFT_color_code_ceiling ; color-code the output
3906 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] 4172 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
3907 bsf leftbind 4173 bsf leftbind
3908 TSTOSS opt_units ; 0=m, 1=ft 4174 TSTOSS opt_units ; 0=m, 1=ft
3909 bra TFT_ceiling_tissue_cGF_m 4175 bra TFT_ceiling_tissue_cGF_m
3910 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 4176 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
3911 output_16 ; yxz 4177 output_16 ; yxz
3915 output_16dp .3 ; yxz.a 4181 output_16dp .3 ; yxz.a
3916 TFT_ceiling_tissue_cGF0: 4182 TFT_ceiling_tissue_cGF0:
3917 bcf leftbind 4183 bcf leftbind
3918 STRCAT_PRINT " " 4184 STRCAT_PRINT " "
3919 ; Show tissue diagram 4185 ; Show tissue diagram
3920 call DISP_tissue_saturation_graph; show char_O_tissue_N2_saturation and char_O_tissue_He_saturation 4186 call TFT_dive_tissues ; show tissue pressure diagram
3921 ; Show current tissue supersaturation 4187 ; Show current supersaturation
3922 WIN_MEDIUM dm_custom_clock_column+.3, dm_custom_gf_row 4188 WIN_MEDIUM dm_custom_clock_column+.3, dm_custom_gf_row
3923 movff int_O_gradient_factor+0,lo ; gradient factor absolute, 100% = on M-line of straight Buhlmann 4189 MOVII int_O_lead_supersat,mpr ; bank-safe copy of leading tissue's supersaturation
3924 movff int_O_gradient_factor+1,hi ; hi byte holds flags
3925 call TFT_color_code_gf ; color-code output 4190 call TFT_color_code_gf ; color-code output
3926 output_8 ; need to print lo only, int_O_gradient_factor value is limited to 255 4191 output_8 ; need to print lo only, int_O_lead_supersat value is limited to 255
3927 STRCAT_PRINT "" 4192 STRCAT_PRINT ""
3928 WIN_STD dm_custom_clock_column+.40, dm_custom_gf_row+.5 4193 WIN_STD dm_custom_clock_column+.40, dm_custom_gf_row+.5
3929 STRCAT_PRINT "%" ; % is printed in color set by TFT_color_code_gf, too 4194 STRCAT_PRINT "%" ; % is printed in color set by TFT_color_code_gf, too
3930 TFT_custview_exit1: 4195 TFT_custview_exit1:
3931 bcf leftbind 4196 bcf leftbind
3939 STRCPY_TEXT_PRINT tTime ; "Time" 4204 STRCPY_TEXT_PRINT tTime ; "Time"
3940 WIN_TINY dm_custom_battery_column, dm_custom_battery_title_row 4205 WIN_TINY dm_custom_battery_column, dm_custom_battery_title_row
3941 STRCPY_TEXT_PRINT tBattery ; "Battery" 4206 STRCPY_TEXT_PRINT tBattery ; "Battery"
3942 WIN_TINY dm_custom_surfpres_column+.8, dm_custom_surfpres_title_row 4207 WIN_TINY dm_custom_surfpres_column+.8, dm_custom_surfpres_title_row
3943 STRCPY_TEXT_PRINT tSurface ; "Surface" 4208 STRCPY_TEXT_PRINT tSurface ; "Surface"
3944 ; Show Surface Pressure (done in mask, because it's static during the dive) 4209 ; Show configured Surface Pressure (done in mask, because it's static during the dive)
3945 call TFT_standard_color 4210 call TFT_standard_color
3946 WIN_SMALL dm_custom_surfpres_column, dm_custom_surfpres_row 4211 WIN_SMALL dm_custom_surfpres_column, dm_custom_surfpres_row
3947 movff last_surfpressure_30min+0,lo 4212 MOVII pressure_surf,mpr
3948 movff last_surfpressure_30min+1,hi
3949 output_16 4213 output_16
3950 PUTC ' ' 4214 PUTC ' '
3951 STRCAT_TEXT_PRINT tMBAR ; mbar (hPa) 4215 STRCAT_TEXT_PRINT tMBAR ; mbar (hPa)
3952 bra TFT_custview_exit1 ; and return... 4216 bra TFT_custview_exit1 ; and return...
3953 4217
3955 global TFT_clock_batt_surfpress ; data for clock, battery and surface pressure 4219 global TFT_clock_batt_surfpress ; data for clock, battery and surface pressure
3956 TFT_clock_batt_surfpress: 4220 TFT_clock_batt_surfpress:
3957 ; Update Clock 4221 ; Update Clock
3958 WIN_SMALL dm_custom_clock_column, dm_custom_clock_row 4222 WIN_SMALL dm_custom_clock_column, dm_custom_clock_row
3959 call TFT_standard_color 4223 call TFT_standard_color
3960 movff hours,lo 4224 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
4225 movff rtc_latched_hour,lo
3961 output_99 4226 output_99
3962 PUTC ':' 4227 PUTC ':'
3963 movff mins,lo 4228 movff rtc_latched_mins,lo
3964 output_99x 4229 output_99x
3965 PUTC ":" 4230 PUTC ":"
3966 movff secs,lo 4231 movff rtc_latched_secs,lo
3967 output_99x 4232 output_99x
3968 STRCAT_PRINT "" 4233 STRCAT_PRINT ""
3969 ; Show Battery Info 4234 ; Show Battery Volt
3970 WIN_SMALL dm_custom_battery_column, dm_custom_battery_percent_row
3971 movff batt_percent,lo ; get battery percent
3972 call TFT_color_code_battery ; color-code battery percent
3973 ; bsf leftbind
3974 output_8
3975 ; bcf leftbind
3976 STRCAT "% "
3977 movlw 0x00
3978 movff WREG,buffer+4 ; only "xxx%"
3979 STRCAT_PRINT ""
3980 bcf win_invert
3981 call TFT_memo_color 4235 call TFT_memo_color
3982 WIN_SMALL dm_custom_battery_column, dm_custom_battery_volt_row 4236 WIN_SMALL dm_custom_battery_column, dm_custom_battery_volt_row
3983 movff batt_voltage+0,lo 4237 MOVII batt_voltage,mpr
3984 movff batt_voltage+1,hi
3985 bsf leftbind 4238 bsf leftbind
3986 output_16dp .2 4239 output_16dp .2
3987 PUTC 'V' 4240 PUTC 'V'
3988 movff buffer+5,buffer+4 4241 movff buffer+5,buffer+4
3989 movlw 0x00 4242 movlw 0x00
3990 movff WREG,buffer+5 ; only "x.yzV" 4243 movff WREG,buffer+5 ; only "x.yzV"
3991 STRCAT_PRINT "" 4244 STRCAT_PRINT ""
4245 ; Show Battery Percent
4246 WIN_SMALL dm_custom_battery_column+.7, dm_custom_battery_percent_row
4247 movff batt_percent,lo ; get battery percent
4248 call TFT_color_code_battery ; color-code battery percent
4249 output_8
4250 STRCAT "% "
4251 movlw 0x00
4252 movff WREG,buffer+4 ; only "xxx%"
4253 STRCAT_PRINT ""
3992 ; Surface pressure is shown in mask because it is static 4254 ; Surface pressure is shown in mask because it is static
3993 bra TFT_custview_exit1 ; and return... 4255 bra TFT_custview_exit1 ; and return...
3994 4256
4257 ;=============================================================================
4258
4259 IFDEF _ccr_pscr
3995 4260
3996 global TFT_pscr_info_mask ; mask for pSCR info 4261 global TFT_pscr_info_mask ; mask for pSCR info
3997 TFT_pscr_info_mask: 4262 TFT_pscr_info_mask:
3998 rcall TFT_mask_ppo2 4263 rcall TFT_show_ppo2_mask
3999 call TFT_divemask_color 4264 call TFT_divemask_color
4000 WIN_TINY dm_custom_pscr_drop_column, dm_custom_pscr_title_row 4265 WIN_TINY dm_custom_pscr_drop_column, dm_custom_pscr_title_row
4001 STRCPY_TEXT_PRINT tPSCR_O2_drop 4266 STRCPY_TEXT_PRINT tPSCR_O2_drop
4002 WIN_TINY dm_custom_pscr_ratio_column, dm_custom_pscr_title_row 4267 WIN_TINY dm_custom_pscr_ratio_column, dm_custom_pscr_title_row
4003 STRCPY_TEXT_PRINT tPSCR_lungratio 4268 STRCPY_TEXT_PRINT tPSCR_lungratio
4004 bra TFT_custview_exit1 ; and return... 4269 bra TFT_custview_exit1 ; and return...
4005 4270
4271
4006 global TFT_pscr_info ; data for pSCR info 4272 global TFT_pscr_info ; data for pSCR info
4007 TFT_pscr_info: 4273 TFT_pscr_info:
4008 ;show ppO2 4274 ;show ppO2
4009 WIN_MEDIUM dm_custom_ppo2_column,dm_custom_ppo2_row 4275 WIN_MEDIUM dm_custom_ppo2_column,dm_custom_ppo2_row
4010 movff int_O_pSCR_ppO2+0,lo ; copy pSCR ppO2 to hi:lo 4276 MOVII int_O_pSCR_ppO2,mpr ; copy pSCR ppO2 to hi:lo
4011 movff int_O_pSCR_ppO2+1,hi
4012 call TFT_color_code_ppo2 ; color-code output 4277 call TFT_color_code_ppo2 ; color-code output
4013 bsf leftbind 4278 bsf leftbind
4014 output_16dp .3 ; x.xx bar 4279 output_16dp .3 ; x.xx bar
4015 bcf leftbind 4280 bcf leftbind
4016 STRCAT_PRINT "" 4281 STRCAT_PRINT ""
4028 STRCPY "1/" 4293 STRCPY "1/"
4029 output_8 4294 output_8
4030 STRCAT_PRINT "" 4295 STRCAT_PRINT ""
4031 bra TFT_custview_exit1 ; and return... 4296 bra TFT_custview_exit1 ; and return...
4032 4297
4298 ENDIF ; _ccr_psrc
4299
4300 ;=============================================================================
4033 4301
4034 global TFT_gas_needs_ascent_mask ; mask for gas needs ascent 4302 global TFT_gas_needs_ascent_mask ; mask for gas needs ascent
4035 TFT_gas_needs_ascent_mask: 4303 TFT_gas_needs_ascent_mask:
4036 WIN_TINY dm_custom_gas_column_title, dm_custom_gas_mask_row 4304 WIN_TINY dm_custom_gas_column_title, dm_custom_gas_mask_row
4037 call TFT_divemask_color 4305 call TFT_divemask_color
4087 cpfslt up ; check if all gases have been processed 4355 cpfslt up ; check if all gases have been processed
4088 bra TFT_gas_needs_helper_1 ; YES - clear display area 4356 bra TFT_gas_needs_helper_1 ; YES - clear display area
4089 movf up,W ; NO - get gas number and check if need of that gas is > 0 4357 movf up,W ; NO - get gas number and check if need of that gas is > 0
4090 rlncf WREG,W ; multiply by 2 4358 rlncf WREG,W ; multiply by 2
4091 incf WREG,W ; add 1 to address high byte 4359 incf WREG,W ; add 1 to address high byte
4092 lfsr FSR1,int_O_ascent_pres_need ; load base of ascent press needs 4360 lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure
4093 movff PLUSW1,hi ; read HIGH(int_O_ascent_pres_need[up]) 4361 movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up])
4094 btfss hi,int_is_zero ; check flag for pres_need == 0 4362 btfss hi,int_is_zero ; check flag for pres_need == 0
4095 bra TFT_gas_needs_helper_2 ; NO - print gas type and pressure needed 4363 bra TFT_gas_needs_helper_2 ; NO - print gas type and pressure needed
4096 incf up,F ; YES - increment to next gas... 4364 incf up,F ; YES - increment to next gas...
4097 bra TFT_gas_needs_helper ; ...and try the next gas 4365 bra TFT_gas_needs_helper ; ...and try the next gas
4098 TFT_gas_needs_helper_1: ; no gases to show anymore, clear display area from potential remains of last invocation 4366 TFT_gas_needs_helper_1: ; no gases to show anymore, clear display area from potential remains of last invocation
4102 movf up,W ; get gas number (0-4) to WREG 4370 movf up,W ; get gas number (0-4) to WREG
4103 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG] 4371 lfsr FSR1,opt_gas_O2_ratio ; read opt_gas_O2_ratio[WREG]
4104 movff PLUSW1,lo ; copy result to lo 4372 movff PLUSW1,lo ; copy result to lo
4105 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_He_ratio[WREG] 4373 lfsr FSR1,opt_gas_He_ratio ; read opt_gas_He_ratio[WREG]
4106 movff PLUSW1,hi ; copy result to hi 4374 movff PLUSW1,hi ; copy result to hi
4107 call customview_show_mix ; print "Air", "O2", "21/35", etc. 4375 call gaslist_show_mix ; print "Air", "O2", "21/35", etc.
4108 PUTC ':' ; ":" 4376 PUTC ':' ; ":"
4109 movf up,W ; get gas number (0-4) to WREG 4377 movf up,W ; get gas number (0-4) to WREG
4110 rlncf WREG,W ; multiply by 2 4378 rlncf WREG,W ; multiply by 2
4111 lfsr FSR1,int_O_ascent_pres_need ; load base of ascent press needs (default) 4379 lfsr FSR1,int_O_gas_need_pres ; load base of gas needs in pressure
4112 movff PLUSW1,lo ; read LOW(int_O_ascent_pres_need[up]) 4380 movff PLUSW1,lo ; read LOW(int_O_gas_need_pres[up])
4113 incf WREG,W ; add 1 to address high byte 4381 incf WREG,W ; add 1 to address high byte
4114 movff PLUSW1,hi ; read HIGH(int_O_ascent_pres_need[up]) 4382 movff PLUSW1,hi ; read HIGH(int_O_gas_need_pres[up])
4115 btfsc hi,int_attention_flag ; check if attention flag is set (pres_need > pres_fill * threshold) 4383 btfsc hi,int_attention_flag ; check if attention flag is set (pres_need > pres_fill * threshold)
4116 call TFT_attention_color ; YES - print gas need in yellow 4384 call TFT_attention_color ; YES - print gas need in attention color
4117 btfsc hi,int_warning_flag ; check if warning flag is set (pres_need > pres_fill) 4385 btfsc hi,int_warning_flag ; check if warning flag is set (pres_need > pres_fill)
4118 call TFT_warnings_color ; YES - print gas need in red 4386 call TFT_warning_color ; YES - print gas need in warning color
4119 movff int_O_ascent_pres_need+1,WREG ; get HIGH(int_O_ascent_pres_need[0]) which holds flag for invalid data 4387 movff int_O_gas_need_pres+1,WREG ; get HIGH(int_O_gas_need_pres[0]) which holds flag for invalid data
4120 btfsc WREG,int_invalid_flag ; check if invalid data flag is set 4388 btfsc WREG,int_invalid_flag ; check if invalid data flag is set
4121 call TFT_disabled_color ; YES - print gas need in disabled color 4389 call TFT_disabled_color ; YES - print gas need in disabled color
4122 bcf hi,int_attention_flag ; clear attention flag for attention color 4390 bcf hi,int_attention_flag ; clear flag for attention
4123 bcf hi,int_warning_flag ; clear warning flag for warning color 4391 bcf hi,int_warning_flag ; clear flag for warning
4392 bcf hi,int_high_flag ; clear flag for > 999 bar
4124 bcf hi,int_invalid_flag ; clear flag for invalid data (will actually only be set with 1st gas) 4393 bcf hi,int_invalid_flag ; clear flag for invalid data (will actually only be set with 1st gas)
4125 output_16_3 ; limit to 999 and display only (0-999) 4394 output_16_3 ; limit to 999 and display only (0-999)
4126 STRCAT_PRINT " " ; adds a space to overwrite any potential remains of earlier outputs 4395 STRCAT_PRINT " " ; adds a space to overwrite any potential remains of earlier outputs
4127 incf up,F ; increment to next gas 4396 incf up,F ; increment to next gas
4128 bra TFT_custview_exit2 ; and return... 4397 bra TFT_custview_exit2 ; and return...
4129 4398
4130 4399
4131 global TFT_mask_ppo2 ; helper function for several custom views 4400 global TFT_show_ppo2_mask ; helper function for several custom views
4132 TFT_mask_ppo2: 4401 TFT_show_ppo2_mask:
4133 call TFT_divemask_color 4402 call TFT_divemask_color
4403 IFDEF _ccr_pscr
4134 btfss FLAG_ccr_mode ; in CCR mode? 4404 btfss FLAG_ccr_mode ; in CCR mode?
4135 bra TFT_mask_ppo2a ; NO - continue checking for pSCR and OC 4405 bra TFT_mask_ppo2a ; NO - continue checking for pSCR and OC
4136 btfsc FLAG_bailout_mode ; in bailout? 4406 btfsc bailout_mode ; YES - in bailout?
4137 bra TFT_mask_ppo2b ; YES 4407 bra TFT_mask_ppo2b ; YES
4138 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display) 4408 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display)
4139 STRCPY_TEXT_PRINT tppO2Dil ; print "ppO2(Dil)" 4409 STRCPY_TEXT_PRINT tppO2Dil ; NO - print "ppO2(Dil)"
4140 bra TFT_custview_exit2 ; and return... 4410 bra TFT_custview_exit2 ; - and return...
4141 TFT_mask_ppo2a: 4411 TFT_mask_ppo2a:
4142 btfss FLAG_pscr_mode ; in pSCR mode? 4412 btfss FLAG_pscr_mode ; in pSCR mode?
4143 bra TFT_mask_ppo2b ; NO - continue with OC mode (or bailout) 4413 bra TFT_mask_ppo2b ; NO - continue with OC mode (or bailout)
4144 btfsc FLAG_bailout_mode ; in bailout? 4414 btfsc bailout_mode ; YES - in bailout?
4145 bra TFT_mask_ppo2b ; YES 4415 bra TFT_mask_ppo2b ; YES
4146 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display) 4416 WIN_TINY dm_custom_ppo2_column-.2,dm_custom_ppo2_title_row ; tuned position for longer text (-8 = on leftmost edge of display)
4147 STRCPY_TEXT_PRINT tppO2Mix ; print "ppO2(Mix)" 4417 STRCPY_TEXT_PRINT tppO2Mix ; NO - print "ppO2(Mix)"
4148 bra TFT_custview_exit2 ; and return... 4418 bra TFT_custview_exit2 ; - and return...
4419 ENDIF
4149 TFT_mask_ppo2b: ; OC mode or bailout 4420 TFT_mask_ppo2b: ; OC mode or bailout
4150 WIN_TINY dm_custom_ppo2_column-.2, dm_custom_ppo2_title_row ; normal position 4421 WIN_TINY dm_custom_ppo2_column-.2, dm_custom_ppo2_title_row ; normal position
4151 STRCPY_TEXT_PRINT tppO2 ; in all other modes 4422 STRCPY_TEXT_PRINT tppO2 ; in all other modes
4152 bra TFT_custview_exit2 ; and return... 4423 bra TFT_custview_exit2 ; and return...
4153 4424
4154 4425
4155 global TFT_ppo2_ead_end_cns_mask ; mask for ppO2, END/EAD and CNS 4426 global TFT_ppo2_ead_end_cns_mask ; mask for ppO2, END/EAD and CNS
4156 TFT_ppo2_ead_end_cns_mask: 4427 TFT_ppo2_ead_end_cns_mask:
4157 rcall TFT_mask_ppo2 4428 rcall TFT_show_ppo2_mask
4158 call TFT_divemask_color 4429 call TFT_divemask_color
4159 WIN_TINY dm_custom_ead_column, dm_custom_eadend_title_row 4430 WIN_TINY dm_custom_ead_column, dm_custom_eadend_title_row
4160 STRCPY_TEXT_PRINT tDiveEAD_END 4431 STRCPY_TEXT_PRINT tDiveEAD_END
4161 WIN_TINY dm_custom_cns_column, dm_custom_cns_title_row 4432 WIN_TINY dm_custom_cns_column, dm_custom_cns_title_row
4162 STRCPY_TEXT_PRINT tCNS2 4433 STRCPY_TEXT_PRINT tCNS2
4165 4436
4166 global TFT_ppo2_ead_end_cns ; data for ppO2, END/EAD and CNS 4437 global TFT_ppo2_ead_end_cns ; data for ppO2, END/EAD and CNS
4167 TFT_ppo2_ead_end_cns: 4438 TFT_ppo2_ead_end_cns:
4168 ; Show ppO2 4439 ; Show ppO2
4169 WIN_MEDIUM dm_custom_ppo2_column, dm_custom_ppo2_row 4440 WIN_MEDIUM dm_custom_ppo2_column, dm_custom_ppo2_row
4170 movff int_O_breathed_ppO2+0,lo ; copy ppO2 of the currently breathed gas to hi:lo 4441 MOVII int_O_breathed_ppO2,mpr ; copy ppO2 of the currently breathed gas to hi:lo
4171 movff int_O_breathed_ppO2+1,hi
4172 call TFT_color_code_ppo2 ; color-code output 4442 call TFT_color_code_ppo2 ; color-code output
4173 bsf leftbind 4443 bsf leftbind
4174 output_16dp .3 ; x.xx bar 4444 output_16dp .3 ; x.xx bar
4175 bcf leftbind 4445 bcf leftbind
4176 STRCAT_PRINT "" 4446 STRCAT_PRINT ""
4184 STRCPY_TEXT tEND ; END: 4454 STRCPY_TEXT tEND ; END:
4185 movff char_O_END,lo 4455 movff char_O_END,lo
4186 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars 4456 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars
4187 ; Show CNS 4457 ; Show CNS
4188 WIN_STD dm_custom_cns_column+.3, dm_custom_cns_row 4458 WIN_STD dm_custom_cns_column+.3, dm_custom_cns_row
4189 movff int_O_CNS_fraction+0,lo 4459 MOVII int_O_CNS_current,mpr ; get current CNS
4190 movff int_O_CNS_fraction+1,hi
4191 call TFT_color_code_cns ; color-code CNS output 4460 call TFT_color_code_cns ; color-code CNS output
4192 bsf leftbind 4461 bsf leftbind
4193 output_16_3 ; displays only 0...999 4462 output_16_3 ; displays only 0...999
4194 bcf leftbind 4463 bcf leftbind
4195 STRCAT_PRINT "%" 4464 STRCAT_PRINT "%"
4196 TFT_custview_exit2: 4465 TFT_custview_exit2:
4197 goto TFT_standard_color ; and return... 4466 goto TFT_standard_color ; and return...
4467
4198 TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars 4468 TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars
4199 bsf leftbind 4469 bsf leftbind
4200 TSTOSS opt_units ; 0=Meters, 1=Feets 4470 TSTOSS opt_units ; 0=Meter, 1=Feet
4201 bra TFT_end_ead_common_metric 4471 bra TFT_end_ead_common_metric
4202 TFT_end_ead_common_imperial: 4472 TFT_end_ead_common_imperial:
4203 movf lo,W ; with lo in m 4473 movf lo,W ; with lo in m
4204 mullw .100 ; PRODL:PRODH = mbar/min 4474 mullw .100 ; PRODL:PRODH = mbar/min
4205 movff PRODL,lo 4475 MOVII PRODL,mpr
4206 movff PRODH,hi
4207 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 4476 call convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
4208 output_16_3 4477 output_16_3
4209 STRCAT_TEXT tFeets 4478 STRCAT_TEXT tFeets
4210 clrf WREG 4479 clrf WREG
4211 movff WREG,buffer+.8 ; limit string length to 8 4480 movff WREG,buffer+.8 ; limit string length to 8
4218 movlw .8 4487 movlw .8
4219 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4488 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4220 STRCAT_PRINT "" 4489 STRCAT_PRINT ""
4221 return 4490 return
4222 4491
4492 ;=============================================================================
4493
4494 IFDEF _ccr_pscr
4223 4495
4224 global TFT_sensor_check_mask ; mask for sensor check 4496 global TFT_sensor_check_mask ; mask for sensor check
4225 TFT_sensor_check_mask: 4497 TFT_sensor_check_mask:
4226 call TFT_divemask_color 4498 call TFT_divemask_color
4227 WIN_TINY dm_custom_s_check_title_column, dm_custom_s_check_title_row 4499 WIN_TINY dm_custom_s_check_title_column, dm_custom_s_check_title_row
4235 4507
4236 global TFT_sensor_check ; data for sensor check 4508 global TFT_sensor_check ; data for sensor check
4237 TFT_sensor_check: 4509 TFT_sensor_check:
4238 ; Show ppO2 of O2 in this depth 4510 ; Show ppO2 of O2 in this depth
4239 WIN_MEDIUM dm_custom_ppO2_column, dm_custom_s_check_row 4511 WIN_MEDIUM dm_custom_ppO2_column, dm_custom_s_check_row
4240 movff int_O_O2_ppO2+0,lo ; copy ppO2 of pure O2 to hi:lo 4512 MOVII int_O_O2_ppO2,mpr ; copy ppO2 of pure O2 to hi:lo
4241 movff int_O_O2_ppO2+1,hi
4242 call TFT_color_code_ppo2 ; color-code output 4513 call TFT_color_code_ppo2 ; color-code output
4243 bsf leftbind 4514 bsf leftbind
4244 output_16dp .3 ; x.xx bar 4515 output_16dp .3 ; x.xx bar
4245 bcf leftbind 4516 bcf leftbind
4246 STRCAT_PRINT "" 4517 STRCAT_PRINT ""
4247 ; Show ppO2 of the diluent in this depth 4518 ; Show ppO2 of the diluent in this depth
4248 WIN_MEDIUM dm_custom_ppDil_column, dm_custom_s_check_row 4519 WIN_MEDIUM dm_custom_ppDil_column, dm_custom_s_check_row
4249 movff int_O_pure_ppO2+0,lo ; copy ppO2 of pure gas to hi:lo 4520 MOVII int_O_pure_ppO2,mpr ; copy ppO2 of pure gas to hi:lo
4250 movff int_O_pure_ppO2+1,hi
4251 call TFT_color_code_ppo2 ; color-code output 4521 call TFT_color_code_ppo2 ; color-code output
4252 bsf leftbind 4522 bsf leftbind
4253 output_16dp .3 ; x.xx bar 4523 output_16dp .3 ; x.xx bar
4254 bcf leftbind 4524 bcf leftbind
4255 STRCAT_PRINT "" 4525 STRCAT_PRINT ""
4256 TFT_sensor_check_exit: 4526 TFT_sensor_check_exit:
4257 bra TFT_custview_exit2 ; and return... 4527 bra TFT_custview_exit2 ; and return...
4258 4528
4529 ENDIF ; _ccr_pscr
4530
4259 ;============================================================================= 4531 ;=============================================================================
4260 4532
4261 global TFT_surface_lastdive 4533 global TFT_surface_lastdive
4262 TFT_surface_lastdive: 4534 TFT_surface_lastdive:
4263 call TFT_divemask_color
4264 WIN_TINY surf_gaslist_column,surf_gaslist_row+.5 4535 WIN_TINY surf_gaslist_column,surf_gaslist_row+.5
4265 STRCAT_TEXT_PRINT tLastDive ; "Last Dive:" 4536 STRCAT_TEXT_PRINT tLastDive ; "Last Dive:"
4266 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)+.5 4537 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1)+.5
4267 STRCAT_TEXT_PRINT tDivetime ; "Divetime:" 4538 STRCAT_TEXT_PRINT tDivetime ; "Divetime:"
4268 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)+.5 4539 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2)+.5
4269 STRCAT_TEXT_PRINT tMaxDepth ; "Max. Depth" 4540 STRCAT_TEXT_PRINT tMaxDepth ; "Max.Depth"
4270 call TFT_standard_color 4541 WIN_TINY surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3)+.5
4542 STRCAT_TEXT_PRINT tAvgDepth ; "Average"
4543
4271 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row 4544 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row
4272 movff int_O_desaturation_time+0,lo ; bank-safe copies 4545 SMOVII int_O_desaturation_time,mpr ; ISR-safe copy of the desaturation time
4273 movff int_O_desaturation_time+1,WREG 4546 movf mpr+0,W ; get low byte into WREG
4274 iorwf lo,W ; check if desaturation time is zero 4547 iorwf mpr+1,W ; inclusive-or with high byte, check if desaturation time is zero
4275 bz TFT_surface_lastdive_1 ; YES - show last dive time 4548 bz TFT_surface_lastdive_1 ; YES - show last dive time
4276 movff surface_interval+0,lo ; NO - show dive interval 4549 ; NO - show surface interval
4277 movff surface_interval+1,hi 4550 SMOVII surface_interval,mpr ; - ISR-safe copy of surface interval
4278 call convert_time ; converts hi:lo in minutes to hours (up:hi) and minutes (lo) 4551 call convert_time ; - convert hi:lo in minutes to hours (up:hi) and minutes (lo)
4279 movf hi,W 4552 movf hi,W ; - swap hi and lo
4280 movff lo,hi 4553 movff lo,hi ; ...
4281 movwf lo ; exchange lo and hi 4554 movwf lo ; ...
4282 bsf leftbind 4555 bsf leftbind ;
4283 output_99x 4556 output_99x ;
4284 PUTC 'h' 4557 PUTC 'h' ;
4285 movff hi,lo 4558 movff hi,lo ;
4286 output_99x 4559 output_99x ;
4287 STRCAT_PRINT "m " 4560 STRCAT_PRINT "m " ;
4288 bra TFT_surface_lastdive_2 4561 bra TFT_surface_lastdive_2 ;
4289 TFT_surface_lastdive_1: 4562 TFT_surface_lastdive_1:
4290 movff lastdive_time+0,xC+0 4563 SMOVFF lastdive_time,xC ; ISR-safe copy of lastdive_time:4 to xC:4
4291 movff lastdive_time+1,xC+1 4564 call info_menu_uptime_com ; use part of info_menu_uptime to convert and display in days and hours
4292 movff lastdive_time+2,xC+2
4293 movff lastdive_time+3,xC+3
4294 movlw LOW .3600
4295 movwf xB+0
4296 movlw HIGH .3600
4297 movwf xB+1 ; one day = 3600s
4298 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
4299 ;xC+0:xC+1 -> full hours
4300 movff xC+1,xA+1
4301 movff xC+0,xA+0
4302 clrf xB+1
4303 movlw .24
4304 movwf xB+0
4305 call div16x16 ; xC = xA / xB with xA as remainder
4306 movff xC+0,lo
4307 movff xC+1,hi ; full days
4308 bsf leftbind
4309 output_16
4310 PUTC "d"
4311 movff xA+0,lo ; full hours
4312 output_8
4313 STRCAT_PRINT "h "
4314 TFT_surface_lastdive_2: 4565 TFT_surface_lastdive_2:
4315 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.1) 4566 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.1)
4316 movff lastdive_duration+0,lo 4567 MOVII lastdive_duration,mpr ; get duration of last dive, minutes
4317 movff lastdive_duration+1,hi 4568 bsf leftbind ; print without leading spaces
4318 output_16 ; divetime minutes 4569 output_16 ; dive time minutes
4319 PUTC ":" 4570 PUTC ":" ;
4320 movff lastdive_duration+2,lo 4571 movff lastdive_duration+2,lo ; get duration of last dive, seconds
4321 output_99x ; divetime seconds 4572 output_99x ; print seconds
4322 STRCAT_PRINT "" 4573 rcall TFT_surface_common ; finalize output
4574 TFT_surface_lastdive_3:
4323 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.2) 4575 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.2)
4324 movff lastdive_maxdepth+0,lo 4576 MOVII lastdive_maxdepth,mpr
4325 movff lastdive_maxdepth+1,hi 4577 bsf leftbind ; print without leading spaces
4326 TSTOSS opt_units ; 0=Meters, 1=Feets 4578 TSTOSS opt_units ; 0=Meter, 1=Feet
4327 bra TFT_surface_lastdive_metric 4579 bra TFT_surface_lastdive_metric ; 0 - metric
4328 ;imperial 4580 rcall TFT_surface_imperial ; 1 - imperial
4581 bra TFT_surface_lastdive_4 ; - continue
4582 TFT_surface_lastdive_metric:
4583 rcall TFT_surface_metric ; print depth in meters
4584 TFT_surface_lastdive_4:
4585 WIN_SMALL surf_gaslist_column+.48,surf_gaslist_row+(surf_gaslist_spacing*.3)
4586 MOVII lastdive_avgdepth,mpr
4587 bsf leftbind ; print without leading spaces
4588 TSTOSS opt_units ; 0=Meter, 1=Feet
4589 bra TFT_surface_metric ; 0 - metric and return
4590 ;bra TFT_surface_imperial ; 1 - imperial and return
4591
4592 TFT_surface_imperial:
4329 rcall convert_mbar_to_feet ; convert value in hi:lo from mbar to feet 4593 rcall convert_mbar_to_feet ; convert value in hi:lo from mbar to feet
4330 output_16_3 ; limit to 999 and display only (0-999) 4594 output_16_3 ; limit to 999 and display only (0-999)
4331 STRCAT_TEXT tFeets1 4595 STRCAT_TEXT tFeets1 ; "ft"
4332 bra TFT_surface_lastdive2 4596 bra TFT_surface_common ; finalize output
4333 4597 TFT_surface_metric:
4334 TFT_surface_lastdive_metric:
4335 bsf ignore_digit5 ; no cm (flag will be cleared by output_16) 4598 bsf ignore_digit5 ; no cm (flag will be cleared by output_16)
4336 movlw d'1' ; +1 4599 movlw .1 ; no 1000 meters
4337 movff WREG,ignore_digits ; no 1000m 4600 movwf ignore_digits ; ...
4338 output_16dp .3 ; xxx.y 4601 output_16dp .3 ; xxx.y
4339 STRCAT_TEXT tMeters 4602 STRCAT_TEXT tMeters ; "m"
4340 TFT_surface_lastdive2: 4603 TFT_surface_common:
4341 STRCAT_PRINT "" 4604 STRCAT_PRINT "" ; finalize output
4342 bcf leftbind 4605 bcf leftbind ; clear left-alignment
4343 return ; done. 4606 return ; done
4344 4607
4345 ;============================================================================= 4608 ;=============================================================================
4346 4609
4347 global TFT_surface_tissues 4610 global TFT_surface_tissues
4348 TFT_surface_tissues: ; show Tissue diagram in surface mode 4611 TFT_surface_tissues: ; show tissue diagram in surface mode
4612
4613 ; draw outer frame
4614 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right
4615
4616 ;---- draw labels --------------------------------- ;
4617
4618 call TFT_standard_color
4349 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row 4619 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row
4350 STRCPY_TEXT_PRINT tN2 4620 IFDEF _helium
4621 TSTOSS opt_tissue_graphics ; shall show N2+He or pressure and saturation?
4622 bra TFT_surface_tissues_1 ; =0: show pressures and saturations
4623 ; =1: show N2 and He pressures
4624 STRCPY_TEXT_PRINT tN2 ; print "N2"
4351 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row 4625 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row
4352 STRCPY_TEXT_PRINT tHe 4626 STRCPY_TEXT_PRINT tHe ; print "He"
4353 4627 bra TFT_surface_tissues_2 ; continue with common part
4628 ENDIF
4629 TFT_surface_tissues_1:
4630 STRCPY_TEXT_PRINT tDiveTissues ; print "Tissues"
4631 TFT_surface_tissues_2:
4632 ;---- draw scale ---------------------------------- ;
4354 movlw color_deepblue 4633 movlw color_deepblue
4355 call TFT_set_color ; make this configurable? 4634 call TFT_set_color
4356 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.29,.29 4635
4357 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.37,.37 4636 SCALELINE macro x
4358 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.45,.45 4637 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
4359 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.53,.53 4638 endm
4360 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.61,.61 4639
4361 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.69,.69 4640 SCALELINE .0
4362 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.77,.77 4641 SCALELINE .8
4363 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.85,.85 4642 SCALELINE .16
4364 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right ; outer frame 4643 SCALELINE .24
4365 4644 SCALELINE .32
4645 SCALELINE .40
4646 SCALELINE .48
4647 SCALELINE .56
4648 SCALELINE .64
4649 SCALELINE .72
4650 SCALELINE .80
4651
4652 ;---- common initialization for Tissue Pressures and Saturation ----------
4366 movlw .1 4653 movlw .1
4367 movwf win_height ; row bottom (0-239) 4654 movwf win_height ; hight of the bargraph (0-239)
4368 4655 movlw surf_tissue_diagram_left+.4 ; left start position for N2 bars
4369 ;---- Draw N2 Tissues ---------------------------------------------------- 4656 movwf win_leftx2 ; column left (0-159)
4370 4657 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4 ; get max width for N2 bars (78 pixel)
4371 movlw surf_tissue_diagram_left+.4 ; start position for N2 bars 4658 movwf win_width+0 ; set width of the bar box
4372 movwf win_leftx2 ; column left (0-159) 4659 clrf win_width+1 ; ...
4373 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4 ; max width for N2 bars 4660 movlw color_white ; color for tissues not exceeding surface max pressure
4374 movwf win_width 4661 movwf ex ; store in ex
4375 4662 movlw color_red ; color for tissues exceeding surface max pressure
4376 lfsr FSR2, char_O_tissue_N2_saturation 4663 movwf ul ; store in ul
4664 bcf aux_flag ; draw tissue pressures by default
4665
4666 ;---- Draw combined or N2 Tissue Pressures--------- ;
4667 lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default
4668 IFDEF _helium
4669 TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation?
4670 lfsr FSR2,char_O_tissue_pres_N2 ; =1: load base address of N2 pressures
4671 ENDIF
4377 movlw d'16' 4672 movlw d'16'
4378 movwf lo ; 16 tissues 4673 movwf lo ; tissue counter, 16 tissues
4379 clrf hi ; row offset 4674 clrf hi ; row counter
4380 surf_tissue_saturation_graph_N2: 4675 TFT_surf_tissues_N2_loop:
4381 movlw surf_tissue_diagram_top+.23 ; surface mode 4676 movlw surf_tissue_diagram_top+.23 ; surface mode top start position N2
4382 addwf hi,W 4677 rcall TFT_surf_tissues_bargraph ; show one tissue
4383 movwf win_top ; row top (0-239) 4678 movlw .2 ; bargraph spacing
4384 rcall surf_tissue_saturation_loop ; show one tissue 4679 addwf hi,F ; increment row counter
4385 decfsz lo,F 4680 decfsz lo,F ; decrement tissue counter, done?
4386 bra surf_tissue_saturation_graph_N2 4681 bra TFT_surf_tissues_N2_loop ; NO - loop
4387 4682 IFDEF _helium
4388 ;---- Draw He Tissues ---------------------------------------------------- 4683 TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation?
4389 4684 bra TFT_surface_tissues_3 ; =1: show He tissue pressures
4390 movlw surf_tissue_diagram_left+.24 ; start position for He bars (.15 without x2) 4685 ENDIF
4391 movwf win_leftx2 ; column left (0-159) 4686
4392 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.24 ; max width for He bars 4687 ;---- Draw Tissue Saturations --------------------- ;
4393 movwf win_width 4688 lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation
4394
4395 lfsr FSR2, char_O_tissue_He_saturation
4396 movlw d'16' 4689 movlw d'16'
4397 movwf lo ; 16 tissues 4690 movwf lo ; tissue counter, 16 tissues
4398 clrf hi ; row offset 4691 clrf hi ; row counter
4399 surf_tissue_saturation_graph_He: 4692 movlw color_grey ; color for tissue saturation
4400 movlw surf_tissue_diagram_top+.23+.57 ; surface mode 4693 movwf ex ; store in ex
4401 addwf hi,W 4694 ; movlw color_yellow ; 2nd color is not used by tissue saturation
4402 movwf win_top ; row top (0-239) 4695 ; movwf ul ; ...
4403 rcall surf_tissue_saturation_loop ; show one tissue 4696 bsf aux_flag ; draw tissue saturation
4404 decfsz lo,F 4697 TFT_surf_tissues_sat_loop:
4405 bra surf_tissue_saturation_graph_He 4698 movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position saturations
4406 4699 rcall TFT_surf_tissues_bargraph ; draw tissue bargraph
4407 WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row ; position in-between tissue bars 4700 movlw .2 ; bargraph spacing
4408 movff int_O_CNS_fraction+0,lo 4701 addwf hi,F ; increment row counter
4409 movff int_O_CNS_fraction+1,hi 4702 decfsz lo,F ; decrement tissue counter, done?
4410 call TFT_color_code_cns 4703 bra TFT_surf_tissues_sat_loop ; NO - loop
4411 STRCPY_TEXT tCNS2 ; CNS: 4704
4705 ;---- common Part for vertical lines--------------- ;
4706 movlw surf_tissue_diagram_top+.23+.57 ; get top position
4707 movwf win_top ; set top position (0-239)
4708 movlw .30 ; get hight
4709 movwf win_height ; set height
4710 movlw .1 ; get width
4711 movwf win_width+0 ; set width, low byte
4712 clrf win_width+1 ; set width, high byte
4713
4714 ;---- Print 100% Line ----------------------------- ;
4715 movlw surf_tissue_diagram_left+.4+.64 ; get left position
4716 movwf win_leftx2 ; set left position (0-159)
4717 movlw color_red ; color for 100% line
4718 call TFT_set_color ; set color
4719 call TFT_box ; draw line
4720
4721 ; GF factors enabled?
4722 TSTOSS char_I_deco_model ; GF factors enabled?
4723 bra TFT_surface_tissues_4 ; NO - continue with CNS
4724
4725 ;---- Print GF low Line -------------------------- ;
4726 movlw surf_tissue_diagram_left+.4 ; get left base position
4727 movwf win_leftx2 ; set left base position (0-159)
4728 movff opt_GF_low,WREG ; get GF low in 0.01 %
4729 mullw .164 ; multiply with 164
4730 movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625
4731 addwf win_leftx2,F ; add to base position
4732 movlw color_green ; color for 100% line
4733 call TFT_set_color ; set color
4734 call TFT_box ; draw line
4735
4736 ;---- Print GF high Line -------------------------- ;
4737 movlw surf_tissue_diagram_left+.4 ; get left base position
4738 movwf win_leftx2 ; set left base position (0-159)
4739 movff opt_GF_high,WREG ; get GF high in 0.01 %
4740 mullw .164 ; multiply with 164
4741 movf PRODH,W ; divide by 256 -> resulting scale factor is 164/256 = 0.640625
4742 addwf win_leftx2,F ; add to base position
4743 movlw color_yellow ; color for 100% line
4744 call TFT_set_color ; set color
4745 call TFT_box ; draw line
4746 bra TFT_surface_tissues_4 ; continue with CNS
4747
4748 IFDEF _helium
4749 TFT_surface_tissues_3:
4750 ;---- Draw He Tissue Pressures--------------------- ;
4751 movlw surf_tissue_diagram_left+.4+.16 ; start position for He bars
4752 movwf win_leftx2 ; column left (0-159)
4753 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-.4-.16 ; max width for He bars
4754 movwf win_width+0 ; set total width of the bar box
4755 clrf win_width+1 ; ...
4756 lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures
4757 movlw d'16'
4758 movwf lo ; tissue counter, 16 tissues
4759 clrf hi ; row counter
4760 TFT_surf_tissues_He_loop:
4761 movlw surf_tissue_diagram_top+.23+.57 ; surface mode top start position He
4762 rcall TFT_surf_tissues_bargraph ; show one tissue
4763 movlw .2 ; bargraph spacing
4764 addwf hi,F ; increment row counter
4765 decfsz lo,F ; decrement tissue counter, done?
4766 bra TFT_surf_tissues_He_loop ; NO - loop
4767 ENDIF
4768
4769 TFT_surface_tissues_4:
4770 ; ---- Draw CNS% ---------------------------------- ;
4771 WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row ; position in-between tissue bars
4772 MOVII int_O_CNS_current,mpr ; get current CNS
4773 call TFT_color_code_cns ; color-code CNS value
4774 STRCPY_TEXT tCNS2 ; "CNS:"
4412 bsf leftbind 4775 bsf leftbind
4413 output_16_3 ; displays only 0...999 4776 output_16_3 ; display only 0...999
4414 bcf leftbind 4777 bcf leftbind
4415 STRCAT_PRINT "%" 4778 STRCAT_PRINT "%"
4416 goto TFT_standard_color ; and return... 4779 goto TFT_standard_color ; and return...
4417 4780
4418 surf_tissue_saturation_loop: 4781 TFT_surf_tissues_bargraph:
4419 call TFT_standard_color 4782 addwf hi,W ; add row number to start position
4420 movlw .2 ; row spacing 4783 movwf win_top ; set as row top (0-239)
4421 addwf hi,F 4784 movff POSTINC2,up ; get tissue value
4422 movf POSTINC2,W ; get tissue load 4785 movf ex,W ; default color
4423 bcf WREG,7 ; clear flag bit for sat/desat info (not used in surface mode) 4786 btfsc up,7 ; check if flag in bit 7 is set
4424 rlncf WREG,W ; multiply with 2 (previously cleared bit 7 will be rotated to bit 0) 4787 movf ul,W ; YES - switch to 2nd color
4425 incf WREG,W ; add 1 for a minimum visible bar (He-bars could be invisible else-wise) 4788 call TFT_set_color ; set bargraph bar color
4426 movwf up 4789 bcf up,7 ; clear flag bit
4427 movf win_width+0,W ; get max window width (win_width) 4790 btfss aux_flag ; drawing saturations?
4428 cpfslt up ; skip if WREG < win_width 4791 rlncf up,F ; NO - multiply with 2 (previously cleared bit 7 will be rotated to bit 0)
4429 movwf up ; crop length to win_width 4792 incf up,W ; add 1 for a minimum visible bar (He-bars could be invisible else-wise)
4430 ; no need to be able to draw longer bars – 4793 movwf win_bargraph ; set length of the bargraph
4431 ; we are at the surface and if bars would 4794 goto TFT_box ; draw bargraph and return
4432 ; even touch the max length possible here, 4795
4433 ; the diver would be in severe decompression
4434 ; issues if not dead already...
4435 movff up,win_bargraph
4436 clrf win_width+1
4437 goto TFT_box ; and return...
4438 4796
4439 ;============================================================================= 4797 ;=============================================================================
4440 ; Draw saturation graph in dive mode 4798 ; Draw saturation graph in dive mode
4441 4799
4442 DISP_tissue_saturation_graph: 4800 TFT_dive_tissues:
4443 ;---- Draw Frame 4801 ;---- Draw Frame
4444 call TFT_standard_color 4802 call TFT_standard_color
4445 WIN_FRAME_COLOR16 dm_custom_tissue_diagram_top, dm_custom_tissue_diagram_bottom, dm_custom_tissue_diagram_left, .159 ; outer frame 4803 WIN_FRAME_COLOR16 dm_custom_tissue_diagram_top, dm_custom_tissue_diagram_bottom, dm_custom_tissue_diagram_left, .159 ; outer frame
4446 4804
4447 ;---- clear area showing leading tissue number as it may not be printed over 4805 ;---- clear area showing leading tissue number as it may not be printed over
4448 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 4806 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
4449 4807
4808 ;---- common initialization for Tissue Pressures and Saturation ----------
4450 movlw .1 4809 movlw .1
4451 movwf win_height ; row bottom (0-239) 4810 movwf win_height ; hight of the bargraph (0-239)
4452 4811 movlw dm_custom_tissue_diagram_left+.3 ; get dive mode left start position
4453 ;---- Draw N2 Tissues ---------------------------------------------------- 4812 movwf win_leftx2 ; set column left (0-159)
4454 4813 movlw .159-dm_custom_tissue_diagram_left-.4 ; get max width
4455 movlw dm_custom_tissue_diagram_left+.3 ; divemode 4814 movwf win_width+0 ; set width (low byte)
4456 movwf win_leftx2 ; column left (0-159) 4815 clrf win_width+1 ; high byte of with is always zero
4457 movlw .159-dm_custom_tissue_diagram_left-.4 ; width 4816 movlw color_cyan ; color for tissues with decreasing pressure
4458 movwf win_width 4817 movwf ex ; store in ex
4459 4818 movlw color_orange ; color for tissues with increasing pressure
4460 lfsr FSR2, char_O_tissue_N2_saturation 4819 movwf ul ; store in ul
4820
4821 ;---- Draw combined or N2 Tissue Pressures -------- ;
4822 lfsr FSR2,char_O_tissue_pressure ; load base address of combined pressures by default
4823 IFDEF _helium
4824 TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation?
4825 lfsr FSR2,char_O_tissue_pres_N2 ; =1: load base address of N2 pressures
4826 ENDIF
4461 movlw d'16' 4827 movlw d'16'
4462 movwf lo ; 16 tissues 4828 movwf lo ; tissue counter, 16 tissues
4463 clrf hi ; row offset 4829 clrf hi ; row counter
4464 tissue_saturation_graph_N2: 4830 TFT_dive_tissues_N2_loop:
4465 movlw dm_custom_tissue_diagram_top+.3 ; divemode 4831 movlw dm_custom_tissue_diagram_top+.3 ; dive mode top start position N2
4466 rcall tissue_saturation_graph_loop ; show one tissue 4832 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
4467 decfsz lo,F 4833 incf hi,F ; increment row counter
4468 bra tissue_saturation_graph_N2 4834 decfsz lo,F ; decrement tissue counter, done?
4469 4835 bra TFT_dive_tissues_N2_loop ; NO - loop
4470 ;---- Draw He Tissues ---------------------------------------------------- 4836 IFDEF _helium
4471 4837 TSTOSC opt_tissue_graphics ; shall show N2+He or pressure and saturation?
4472 movlw dm_custom_tissue_diagram_left+.8 ; divemode 4838 bra TFT_dive_tissues_3 ; =1: show He tissue pressures
4473 movwf win_leftx2 ; column left (0-159) 4839 ENDIF
4474 movlw .159-dm_custom_tissue_diagram_left-.14 ; width 4840
4475 movwf win_width 4841 ;---- Draw Tissue Saturations --------------------- ;
4476 4842 lfsr FSR2,char_O_tissue_saturation ; load base address of tissue supersaturation
4477 lfsr FSR2, char_O_tissue_He_saturation
4478 movlw d'16' 4843 movlw d'16'
4479 movwf lo ; 16 tissues 4844 movwf lo ; tissue counter, 16 tissues
4480 clrf hi ; row offset 4845 clrf hi ; row counter
4481 tissue_saturation_graph_He: 4846 movlw color_grey ; color for tissue saturation, alternative: color_lightblue
4482 movlw dm_custom_tissue_diagram_top+.3+.22 ; divemode 4847 movwf ex ; store in ex
4483 rcall tissue_saturation_graph_loop ; show one tissue 4848 ; movlw color_yellow ; 2nd color is not used by tissue saturation
4484 decfsz lo,F 4849 ; movwf ul ; ...
4485 bra tissue_saturation_graph_He 4850 TFT_dive_tissues_sat_loop:
4486 4851 movlw dm_custom_tissue_diagram_top+.3+.22 ; dive mode top start position saturations
4487 ;---- Print Number of leading Tissue ------------------------------------- 4852 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
4488 4853 incf hi,F ; increment row counter
4489 ; TODO: some flicker due to overwriting by tissue bars 4854 decfsz lo,F ; decrement tissue counter, done?
4490 4855 bra TFT_dive_tissues_sat_loop ; NO - loop
4491 movff int_O_gradient_factor+0,WREG ; get current gradient factor (only low byte used for value) 4856
4492 tstfsz WREG ; current gradient factor = 0 ? 4857 ;---- common Part for vertical lines--------------- ;
4493 bra tissue_saturation_graph_0 ; NO - print number of leading tissue 4858 movlw dm_custom_tissue_diagram_top+.3+.22 ; get top position
4859 movwf win_top ; set top position (0-239)
4860 movlw .15 ; get hight
4861 movwf win_height ; set height
4862 movlw .1 ; get width
4863 movwf win_width+0 ; set width, low byte
4864 clrf win_width+1 ; set width, high byte
4865
4866 ;---- Print 100% Line ----------------------------- ;
4867 movlw dm_custom_tissue_diagram_left+.3+.33 ; get left position
4868 movwf win_leftx2 ; set left position (0-159)
4869 movlw color_red ; color for 100% line
4870 call TFT_set_color ; set color
4871 call TFT_box ; draw line
4872
4873 ; GF factors enabled?
4874 TSTOSS char_I_deco_model ; GF factors enabled?
4875 bra TFT_dive_tissues_4 ; NO - continue with number of leading tissue
4876
4877 ;---- Print GF low Line -------------------------- ;
4878 movlw dm_custom_tissue_diagram_left+.3 ; get left base position
4879 movwf win_leftx2 ; set left base position (0-159)
4880 movff char_I_GF_Low_percentage,WREG ; get GF low in 0.01 %
4881 mullw .82 ; multiply with 82
4882 movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125
4883 addwf win_leftx2,F ; add to base position
4884 movlw color_green ; color for 100% line
4885 call TFT_set_color ; set color
4886 call TFT_box ; draw line
4887
4888 ;---- Print GF high Line -------------------------- ;
4889 movlw dm_custom_tissue_diagram_left+.3 ; get left base position
4890 movwf win_leftx2 ; set left base position (0-159)
4891 movff char_I_GF_High_percentage,WREG ; get GF high in 0.01 %
4892 mullw .82 ; multiply with 82
4893 movf PRODH,W ; divide by 256 -> resulting scale factor is 82/256 = 0.3203125
4894 addwf win_leftx2,F ; add to base position
4895 movlw color_yellow ; color for 100% line
4896 call TFT_set_color ; set color
4897 call TFT_box ; draw line
4898 bra TFT_dive_tissues_4 ; continue with number of leading tissue
4899
4900 IFDEF _helium
4901 TFT_dive_tissues_3:
4902 ;---- Draw He Tissues Pressures ------------------- ;
4903 movlw dm_custom_tissue_diagram_left+.3+.4 ; get dive mode left start position for He bars
4904 movwf win_leftx2 ; set column left (0-159)
4905 movlw .159-dm_custom_tissue_diagram_left-.4-.4 ; get max width for He bars
4906 movwf win_width+0 ; set width (low byte)
4907 clrf win_width+1 ; ...
4908 lfsr FSR2,char_O_tissue_pres_He ; load base address of He pressures
4909 movlw d'16'
4910 movwf lo ; tissue counter, 16 tissues
4911 clrf hi ; row counter
4912 TFT_dive_tissues_He_loop:
4913 movlw dm_custom_tissue_diagram_top+.3+.22 ; dive mode top start position H2
4914 rcall TFT_dive_tissues_bargraph ; draw tissue bargraph
4915 incf hi,F ; increment row counter
4916 decfsz lo,F ; decrement tissue counter, done?
4917 bra TFT_dive_tissues_He_loop ; NO - loop
4918 ENDIF
4919
4920 TFT_dive_tissues_4:
4921 ;---- Print Number of leading Tissue -------------- ; TODO: some flicker due to overwriting by tissue bars
4922 movff int_O_lead_supersat+0,WREG ; get current leading tissue's supersaturation (only low byte used for value)
4923 tstfsz WREG ; current supersaturation = 0 ?
4924 bra TFT_dive_tissues_5 ; NO - print number of leading tissue
4494 movff char_O_deco_info,WREG ; YES - get deco info vector 4925 movff char_O_deco_info,WREG ; YES - get deco info vector
4495 btfss WREG,deco_ceiling ; - do we have a ceiling obligation? 4926 btfss WREG,deco_ceiling ; - do we have a ceiling obligation?
4496 goto TFT_standard_color ; NO - can ascent directly, don't print number, set standard color and return 4927 goto TFT_standard_color ; NO - can ascent directly, don't print number, set standard color and return
4497 ; YES - print number of leading tissue 4928 ; YES - print number of leading tissue
4498 tissue_saturation_graph_0: 4929 TFT_dive_tissues_5:
4499 movff char_O_lead_number,lo ; get number of leading tissue as 0-15 4930 movff char_O_lead_tissue,lo ; get number of leading tissue as 0-15
4500 incf lo,F ; adjust to 1-16 4931 incf lo,F ; adjust to 1-16
4501 movlw .10 4932 movlw .10
4502 cpfsgt lo ; is it > 10 ? 4933 cpfsgt lo ; is it > 10 ?
4503 bra tissue_saturation_graph_1 ; NO - will output a single digit number 4934 bra TFT_dive_tissues_6 ; NO - will output a single digit number
4504 ; start position for a 2 digit number 4935 ; start position for a 2 digit number
4505 WIN_TINY dm_custom_tissue_diagram_left+.32,dm_custom_tissue_diagram_top+.16 4936 WIN_TINY dm_custom_tissue_diagram_left+.32,dm_custom_tissue_diagram_top+.10
4506 bra tissue_saturation_graph_2 4937 bra TFT_dive_tissues_7
4507 tissue_saturation_graph_1: 4938 TFT_dive_tissues_6:
4508 ; start position for a 1 digit number 4939 ; start position for a 1 digit number
4509 WIN_TINY dm_custom_tissue_diagram_left+.32+.4,dm_custom_tissue_diagram_top+.16 4940 WIN_TINY dm_custom_tissue_diagram_left+.32+.4,dm_custom_tissue_diagram_top+.10
4510 tissue_saturation_graph_2: 4941 TFT_dive_tissues_7:
4511 call TFT_standard_color ; set output color 4942 call TFT_standard_color ; set output color
4512 bsf leftbind 4943 bsf leftbind
4513 output_8 ; print number in leftbind, i.e. without leading zeros or spaces 4944 output_8 ; print number in left aligned, i.e. without leading zeros or spaces
4514 bcf leftbind 4945 bcf leftbind
4515 STRCAT_PRINT "" ; finalize output 4946 STRCAT_PRINT "" ; finalize output
4516 return 4947 return
4517 4948
4518 tissue_saturation_graph_loop: 4949 TFT_dive_tissues_bargraph:
4519 addwf hi,W 4950 addwf hi,W ; add row number to start position
4520 movwf win_top ; row top (0-239) 4951 movwf win_top ; set as row top (0-239)
4521 movlw color_cyan ; preset color for tissues with decreasing pressure 4952 movff POSTINC2,up ; get tissue value
4522 call TFT_set_color 4953 movf ex,W ; default color
4523 incf hi,F 4954 btfsc up,7 ; check if flag in bit 7 is set
4524 movf POSTINC2,W 4955 movf ul,W ; YES - switch to 2nd color
4525 btfss WREG,7 ; check if flag for increasing tissue pressure set 4956 call TFT_set_color ; set bargraph bar color
4526 bra tissue_saturation_graph_loop_1 ; NO - keep color 4957 bcf up,7 ; clear flag bit
4527 movwf up ; YES - buffer WREG 4958 bcf STATUS,C ; clear carry bit
4528 movlw color_orange ; select color for tissues with increasing pressure 4959 rrcf up,F ; divide by 2
4529 call TFT_set_color ; change color 4960 incf up,W ; add a bit for a minimum visible bar
4530 movf up,W ; restore WREG 4961 movwf win_bargraph ; set bargraph bar length
4531 tissue_saturation_graph_loop_1: 4962 goto TFT_box ; draw bargraph and return
4532 bcf WREG,7 ; clear flag bit
4533 bcf STATUS,C
4534 rrcf WREG ; divide by 2
4535 incf WREG,W ; add a bit for a minimum visible bar
4536 movwf up
4537 movf win_width,W ; get max window width (win_width)
4538 cpfslt up ; skip if WREG < win_width
4539 movwf up
4540 movff up,win_bargraph
4541 clrf win_width+1
4542 goto TFT_box ; and return...
4543 4963
4544 ;============================================================================= 4964 ;=============================================================================
4545 4965
4546 global TFT_display_cns 4966 global TFT_show_cns
4547 TFT_display_cns: 4967 TFT_show_cns:
4548 call TFT_warning_set_window ; set the row and column for the current message 4968 call TFT_set_message_window ; set the row and column for the current message
4549 tstfsz WREG ; is there room for the message? 4969 tstfsz WREG ; is there room for the message?
4550 return ; NO 4970 return ; NO
4551 STRCPY_TEXT tCNS ; CNS: 4971 STRCPY_TEXT tCNS ; CNS:
4552 movff int_O_CNS_fraction+0,lo 4972 MOVII int_O_CNS_current,mpr ; get current CNS
4553 movff int_O_CNS_fraction+1,hi
4554 call TFT_color_code_cns ; color-code CNS output 4973 call TFT_color_code_cns ; color-code CNS output
4555 bsf leftbind 4974 bsf leftbind
4556 output_16_3 ; displays only 0...999 4975 output_16_3 ; displays only 0...999
4557 bcf leftbind 4976 bcf leftbind
4558 PUTC "%" 4977 PUTC "%"
4559 movlw dm_warning_length ; divemode string length 4978 movlw dm_warning_length ; dive mode string length
4560 btfss divemode ; In divemode? 4979 btfss divemode ; In dive mode?
4561 movlw surf_warning_length ; NO - use surface string length 4980 movlw surf_warning_length ; NO - use surface string length
4562 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4981 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4563 STRCAT_PRINT "" 4982 STRCAT_PRINT ""
4564 bcf win_invert 4983 bcf win_invert
4565 bra TFT_custview_exit3 ; and return... 4984 bra TFT_custview_exit3 ; and return...
4566 4985
4567 4986
4568 global TFT_display_eod_cns 4987 global TFT_warning_eod_cns
4569 TFT_display_eod_cns: 4988 TFT_warning_eod_cns:
4570 call TFT_warning_set_window ; set the row and column for the current message 4989 call TFT_set_message_window ; set the row and column for the current message
4571 tstfsz WREG ; is there room for the message? 4990 tstfsz WREG ; is there room for the message?
4572 return ; NO 4991 return ; NO
4573 call TFT_warnings_color ; switch to warnings (red) text color 4992 call TFT_warning_color ; switch to warnings (red) text color
4574 STRCPY_TEXT tCNSeod ; end-of-dive CNS warning text 4993 STRCPY_TEXT tCNSeod ; end-of-dive CNS warning text
4575 movlw dm_warning_length ; divemode string length 4994 movlw dm_warning_length ; dive mode string length
4576 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 4995 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in WREG)
4577 STRCAT_PRINT "" 4996 STRCAT_PRINT ""
4578 bra TFT_custview_exit3 ; and return... 4997 bra TFT_custview_exit3 ; and return...
4579 4998
4580 4999
4581 global TFT_display_ppo2_warning 5000 global TFT_show_ppo2_warning
4582 TFT_display_ppo2_warning: ; with ppO2 including attention/warning flags in hi:lo 5001 TFT_show_ppo2_warning: ; with ppO2 including attention/warning flags in hi:lo
4583 call TFT_warning_set_window ; set the row and column for the current message 5002 call TFT_set_message_window ; set the row and column for the current message
4584 tstfsz WREG ; is there room for the message? 5003 tstfsz WREG ; is there room for the message?
4585 return ; NO 5004 return ; NO
4586 call TFT_color_code_ppo2 ; color-code output 5005 call TFT_color_code_ppo2 ; color-code output
4587 btfsc FLAG_bailout_mode ; in bailout? 5006 btfsc bailout_mode ; in bailout?
4588 bra TFT_display_diluent_2 ; YES 5007 bra TFT_display_diluent_2 ; YES
4589 btfss FLAG_ccr_mode ; in CCR mode? 5008 btfss FLAG_ccr_mode ; in CCR mode?
4590 bra TFT_display_diluent_1 ; NO - continue with pSCR or OC 5009 bra TFT_display_diluent_1 ; NO - continue with pSCR or OC
4591 STRCPY_TEXT tdil ; YES - print "Dil:" 5010 STRCPY_TEXT tdil ; YES - print "Dil:"
4592 bra TFT_display_diluent_3 5011 bra TFT_display_diluent_3
4599 STRCPY_TEXT tppO2 ; bailout or OC mode, print "ppO2:" 5018 STRCPY_TEXT tppO2 ; bailout or OC mode, print "ppO2:"
4600 TFT_display_diluent_3: 5019 TFT_display_diluent_3:
4601 bsf leftbind 5020 bsf leftbind
4602 output_16dp .3 ; x.xx bar 5021 output_16dp .3 ; x.xx bar
4603 bcf leftbind 5022 bcf leftbind
4604 movlw dm_warning_length ; divemode string length 5023 movlw dm_warning_length ; dive mode string length
4605 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG) 5024 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
4606 STRCAT_PRINT "" 5025 STRCAT_PRINT ""
4607 TFT_custview_exit3: 5026 TFT_custview_exit3:
4608 goto TFT_standard_color ; and return... 5027 goto TFT_standard_color ; and return...
4609 5028
4610 5029
5030 IFDEF _compass
5031
4611 global TFT_surf_set_bearing 5032 global TFT_surf_set_bearing
4612 TFT_surf_set_bearing: 5033 TFT_surf_set_bearing:
4613 btfsc premenu 5034 btfsc compass_menu ; is the "set bearing" selection shown?
4614 return ; already shown, return 5035 return ; YES - return
4615 bsf premenu ; set flag 5036 bsf compass_menu ; NO - set "set bearing" selection as shown
4616 WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right 5037 WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right
4617 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row 5038 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row
4618 WIN_COLOR color_yellow 5039 WIN_COLOR color_yellow
4619 bsf win_invert 5040 bsf win_invert
4620 STRCPY_TEXT_PRINT tSetHeading ; 7 chars 5041 STRCPY_TEXT_PRINT tSetHeading ; 7 chars
4621 bcf win_invert 5042 bcf win_invert
4622 return 5043 return
4623 5044
5045 ENDIF
5046
4624 ;============================================================================= 5047 ;=============================================================================
4625 5048
4626 global TFT_LogOffset_Logtitle 5049 global TFT_LogOffset
4627 TFT_LogOffset_Logtitle: 5050 TFT_LogOffset:
4628 STRCPY_TEXT tLogOffset 5051 STRCPY_TEXT tLogOffsetValue ; print "Offset" in selected language
4629 PUTC ":" 5052 call do_logoffset_common_read ; read offset into lo:hi
4630 call do_logoffset_common_read ; offset into lo:hi 5053 ; bsf leftbind
4631 bsf leftbind 5054 output_16_4 ; print offset in 4 digits
4632 output_16_4 5055 ; bcf leftbind
4633 bcf leftbind
4634 PUTC " "
4635 return ; no "_PRINT" here... 5056 return ; no "_PRINT" here...
4636 5057
4637 ;============================================================================= 5058 ;=============================================================================
4638 ; RX Functions 5059 ; RX Functions
4639 5060
4667 bra TFT_dive_tankdata_mask_helper_2 ; 1 - print "Need " 5088 bra TFT_dive_tankdata_mask_helper_2 ; 1 - print "Need "
4668 STRCAT_PRINT " ---" ; 0 - print " ---" 5089 STRCAT_PRINT " ---" ; 0 - print " ---"
4669 return ; - done 5090 return ; - done
4670 TFT_dive_tankdata_mask_helper_1: 5091 TFT_dive_tankdata_mask_helper_1:
4671 decf WREG,W ; (1..10) -> (0..9) 5092 decf WREG,W ; (1..10) -> (0..9)
4672 bsf short_gas_decriptions ; just "Air", "O2" or "xx/yy" 5093 bsf short_gas_descriptions ; just "Air", "O2" or "xx/yy"
4673 call gaslist_strcat_gas_WREG ; print composition of gas/dil in WREG (0..9) 5094 call gaslist_strcat_gas_WREG ; print composition of gas/dil in WREG (0..9)
4674 bra TFT_dive_tankdata_mask_helper_3 ; finish with adding "(bar)" 5095 bra TFT_dive_tankdata_mask_helper_3 ; finish with adding "(bar)"
4675 TFT_dive_tankdata_mask_helper_2: 5096 TFT_dive_tankdata_mask_helper_2:
4676 STRCPY_TEXT tNeed ; "Need" 5097 STRCPY_TEXT tNeed ; "Need"
4677 TFT_dive_tankdata_mask_helper_3: 5098 TFT_dive_tankdata_mask_helper_3:
4699 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator 5120 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator
4700 ; get data for reading 2 5121 ; get data for reading 2
4701 btfsc aux_flag ; shall reading 2 show need to reading 1 ? 5122 btfsc aux_flag ; shall reading 2 show need to reading 1 ?
4702 bra TFT_pressures_SAC_1 ; YES 5123 bra TFT_pressures_SAC_1 ; YES
4703 movff int_IO_pressure_value+2,lo ; NO - copy pressure 2 to hi:lo 5124 movff int_IO_pressure_value+2,lo ; NO - copy pressure 2 to hi:lo
4704 movff int_IO_pressure_value+3,hi ; 5125 movff int_IO_pressure_value+3,hi
4705 movff char_I_pressure_stat+1,ex ; - copy status data 5126 movff char_I_pressure_stat+1,ex ; - copy status data
4706 bra TFT_pressures_SAC_2 5127 bra TFT_pressures_SAC_2
4707 TFT_pressures_SAC_1: 5128 TFT_pressures_SAC_1:
4708 movff int_O_pressure_need+0,lo ; YES - copy need to pressure 1 to hi:lo 5129 MOVII int_O_pressure_need,mpr ; YES - copy need to pressure 1 to hi:lo
4709 movff int_O_pressure_need+1,hi ;
4710 clrf ex ; - set status data to 0 5130 clrf ex ; - set status data to 0
4711 TFT_pressures_SAC_2: 5131 TFT_pressures_SAC_2:
4712 ; pressure of reading 2 5132 ; pressure of reading 2
4713 WIN_STD dm_custom_tankdata_pres2_col+.2,dm_custom_tankdata_row 5133 WIN_STD dm_custom_tankdata_pres2_col+.2,dm_custom_tankdata_row
4714 rcall TFT_pressures_SAC_helper_1 ; print pressure if available, else " ---" 5134 rcall TFT_pressures_SAC_helper_1 ; print pressure if available, else " ---"
4715 ; battery status of reading 2 5135 ; battery status of reading 2
4716 WIN_SMALL dm_custom_tankdata_pres2_col+.2+.36,dm_custom_tankdata_row 5136 WIN_SMALL dm_custom_tankdata_pres2_col+.2+.36,dm_custom_tankdata_row
4717 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator 5137 rcall TFT_pressures_SAC_helper_2 ; print or clear down arrow as low bat indicator
4718 ; SAC 5138 ; SAC
4719 WIN_STD dm_custom_tankdata_SAC_col+.6,dm_custom_tankdata_row 5139 WIN_STD dm_custom_tankdata_SAC_col+.6,dm_custom_tankdata_row
4720 movff int_O_sac_rate+0,lo ; copy SAC rate to hi:lo 5140 MOVII int_O_SAC_measured,mpr ; copy measured SAC rate to hi:lo
4721 movff int_O_sac_rate+1,hi
4722 btfsc hi,int_not_avail_flag ; SAC rate available? 5141 btfsc hi,int_not_avail_flag ; SAC rate available?
4723 bra TFT_pressures_SAC_4 ; NO - print " --.-" 5142 bra TFT_pressures_SAC_4 ; NO - print " --.-"
4724 call TFT_color_code_tank_pres_sac ; color-code the output 5143 call TFT_color_code_tank_pres_sac ; color-code the output
4725 output_16_3 ; print as xxx 5144 output_16_3 ; print as xxx
4726 PUTC " " ; print a dummy char to have the string termination at the correct place 5145 PUTC " " ; print a dummy char to have the string termination at the correct place
4807 5226
4808 5227
4809 global TFT_surface_tank_pres 5228 global TFT_surface_tank_pres
4810 TFT_surface_tank_pres: ; show pressure reading above surface pressure 5229 TFT_surface_tank_pres: ; show pressure reading above surface pressure
4811 WIN_SMALL surf_decotype_column+.6,surf_decotype_row+.30+.47 5230 WIN_SMALL surf_decotype_column+.6,surf_decotype_row+.30+.47
4812 movff int_IO_pressure_value+0,lo ; copy pressure from 1st reading, low byte 5231 movff int_IO_pressure_value+0,lo ; copy pressure from 1st reading to hi:lo
4813 movff int_IO_pressure_value+1,hi ; copy pressure from 1st reading, high byte 5232 movff int_IO_pressure_value+1,hi
4814 btfss hi,int_not_avail_flag ; pressure reading 1 available? 5233 btfss hi,int_not_avail_flag ; pressure reading 1 available?
4815 bra TFT_surface_tank_pres_0 ; YES 5234 bra TFT_surface_tank_pres_0 ; YES
4816 movff int_IO_pressure_value+2,lo ; NO - copy pressure from 2nd reading, low byte 5235 movff int_IO_pressure_value+2,lo ; NO - copy pressure from 2nd reading to hi:lo
4817 movff int_IO_pressure_value+3,hi ; - copy pressure from 2nd reading, high byte 5236 movff int_IO_pressure_value+3,hi
4818 btfsc hi,int_not_avail_flag ; - pressure reading 2 available? 5237 btfsc hi,int_not_avail_flag ; - pressure reading 2 available?
4819 bra TFT_surface_tank_pres_1 ; NO - show not avail message 5238 bra TFT_surface_tank_pres_1 ; NO - show not avail message
4820 TFT_surface_tank_pres_0: ; YES - show pressure 5239 TFT_surface_tank_pres_0: ; YES - show pressure
4821 call TFT_color_code_tank_pres_sac ; set output color according to flags 5240 call TFT_color_code_tank_pres_sac ; set output color according to flags
4822 bsf ignore_digit5 ; no 0.1 bar (flag will be cleared by output_16) 5241 bsf ignore_digit5 ; no 0.1 bar (flag will be cleared by output_16)
4848 WIN_SMALL surf_customtext_column,surf_customtext_row5 5267 WIN_SMALL surf_customtext_column,surf_customtext_row5
4849 rcall TFT_surface_tankdata_print 5268 rcall TFT_surface_tankdata_print
4850 return 5269 return
4851 5270
4852 TFT_surface_tankdata_print: ; max 12 char 5271 TFT_surface_tankdata_print: ; max 12 char
4853 call TFT_standard_color 5272 call TFT_standard_color ; set color
4854 movff POSTINC1,hi ; ID high (+0) 5273 movff POSTINC1,hi ; ID high (+0)
4855 movff POSTINC1,lo ; ID low (+1) 5274 movff POSTINC1,lo ; ID low (+1)
4856 tstfsz hi ; ID high = 0 ? 5275 tstfsz hi ; ID high = 0 ?
4857 bra TFT_surface_tankdata_print_1 ; NO - slot in use 5276 bra TFT_surface_tankdata_print_1 ; NO - slot in use
4858 tstfsz lo ; ID low = 0? 5277 tstfsz lo ; ID low = 0?
4874 output_16 ; 4 chars (8 in total) 5293 output_16 ; 4 chars (8 in total)
4875 PUTC " " ; 1 char (9 in total) 5294 PUTC " " ; 1 char (9 in total)
4876 movf POSTINC1,W ; status (+4) 5295 movf POSTINC1,W ; status (+4)
4877 andlw .7 ; mask out battery voltage 5296 andlw .7 ; mask out battery voltage
4878 bnz TFT_surface_tankdata_2 ; branch if battery is not completely drained 5297 bnz TFT_surface_tankdata_2 ; branch if battery is not completely drained
4879 call TFT_warnings_color ; output in red 5298 call TFT_warning_color ; output in red
4880 STRCAT_PRINT "XXX" ; "XXX" for low 5299 STRCAT_PRINT "XXX" ; "XXX" for low
4881 bra TFT_surface_tankdata_print_3 5300 bra TFT_surface_tankdata_print_3
4882 TFT_surface_tankdata_2: 5301 TFT_surface_tankdata_2:
4883 addlw .28 ; add offset of 2.8 Volt 5302 addlw .28 ; add offset of 2.8 Volt
4884 movff WREG,lo ; 5303 movff WREG,lo ;
4891 TFT_surface_tankdata_print_3: 5310 TFT_surface_tankdata_print_3:
4892 movf POSTINC1,W ; dummy read (+5) to advance index 5311 movf POSTINC1,W ; dummy read (+5) to advance index
4893 return 5312 return
4894 5313
4895 5314
4896 TFT_surface_tankdata_debug: ; surface custom view debug output 5315 ; TFT_surface_tankdata_debug: ; surface custom view debug output
4897 call TFT_standard_color 5316 ; call TFT_standard_color
4898 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*0 5317 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*0
4899 rcall TFT_surface_tankdata_debug_print 5318 ; rcall TFT_surface_tankdata_debug_print
4900 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*1 5319 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*1
4901 rcall TFT_surface_tankdata_debug_print 5320 ; rcall TFT_surface_tankdata_debug_print
4902 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*2 5321 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*2
4903 rcall TFT_surface_tankdata_debug_print 5322 ; rcall TFT_surface_tankdata_debug_print
4904 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*3 5323 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*3
4905 rcall TFT_surface_tankdata_debug_print 5324 ; rcall TFT_surface_tankdata_debug_print
4906 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*4 5325 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*4
4907 rcall TFT_surface_tankdata_debug_print 5326 ; rcall TFT_surface_tankdata_debug_print
4908 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*5 5327 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*5
4909 rcall TFT_surface_tankdata_debug_print 5328 ; rcall TFT_surface_tankdata_debug_print
4910 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*6 5329 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*6
4911 rcall TFT_surface_tankdata_debug_print 5330 ; rcall TFT_surface_tankdata_debug_print
4912 WIN_TINY surf_customtext_column,surf_customtext_row1+.14*7 5331 ; WIN_TINY surf_customtext_column,surf_customtext_row1+.14*7
4913 rcall TFT_surface_tankdata_debug_print 5332 ; rcall TFT_surface_tankdata_debug_print
4914 return 5333 ; return
4915 5334
4916 TFT_surface_tankdata_debug_print: 5335 ; TFT_surface_tankdata_debug_print:
4917 movff POSTINC1,hi ; ID high (+0) 5336 ; movff POSTINC1,hi ; ID high (+0)
4918 movff POSTINC1,lo ; ID low (+1) 5337 ; movff POSTINC1,lo ; ID low (+1)
4919 output_16 5338 ; output_16
4920 PUTC "," 5339 ; PUTC ","
4921 movff POSTINC1,hi ; pressure high (+2) 5340 ; movff POSTINC1,hi ; pressure high (+2)
4922 movff POSTINC1,lo ; pressure low (+3) 5341 ; movff POSTINC1,lo ; pressure low (+3)
4923 call TFT_color_code_tank_pres_sac; needed to clear the status flags before output 5342 ; call TFT_color_code_tank_pres_sac; needed to clear the status flags before output
4924 output_16 5343 ; output_16
4925 PUTC "," 5344 ; PUTC ","
4926 movff POSTINC1,lo ; status (+4) 5345 ; movff POSTINC1,lo ; status (+4)
4927 output_8 5346 ; output_8
4928 PUTC "," 5347 ; PUTC ","
4929 movff POSTINC1,lo ; date (+5) 5348 ; movff POSTINC1,lo ; date (+5)
4930 output_8 5349 ; output_8
4931 STRCAT_PRINT "" 5350 ; STRCAT_PRINT ""
4932 return 5351 ; return
4933 ENDIF 5352
5353 ENDIF ; _rx_functions
4934 5354
4935 ;============================================================================= 5355 ;=============================================================================
4936 5356
4937 global adjust_depth_with_salinity 5357 global adjust_depth_with_salinity
4938 global adjust_depth_with_salinity_log 5358 global adjust_depth_with_salinity_log
4939 adjust_depth_with_salinity: ; computes salinity setting into lo:hi [mbar] 5359 adjust_depth_with_salinity: ; computes salinity setting into hi:lo [mbar]
4940 btfsc simulatormode_active ; do not apply salinity in simulator mode 5360 btfsc sensor_override_active ; in pressure sensor override mode?
4941 return 5361 return ; YES - do not apply salinity in override mode
4942 movff opt_salinity,WREG ; 0-5% 5362 movff opt_salinity,WREG ; 0-5%
4943 adjust_depth_with_salinity_log: ; computes salinity setting (FROM WREG!) into lo:hi [mbar] 5363 adjust_depth_with_salinity_log: ; computes salinity setting (FROM WREG!) into hi:lo [mbar]
4944 addlw d'100' ; 1.00kg/l 5364 addlw d'100' ; 1.00kg/l
4945 movwf up 5365 movwf up
4946 5366
4947 movlw d'105' ; 105% ? 5367 movlw d'105' ; 105% ?
4948 cpfslt up ; salinity upper limit 5368 cpfslt up ; salinity upper limit
4949 return ; out of limit, do not adjust lo:hi 5369 return ; out of limit, do not adjust hi:lo
4950 movlw d'99' ; 99% ? 5370 movlw d'99' ; 99% ?
4951 cpfsgt up ; salinity lower limit 5371 cpfsgt up ; salinity lower limit
4952 return ; out of limit, do not adjust lo:hi 5372 return ; out of limit, do not adjust hi:lo
4953 5373
4954 movff lo,xA+0 5374 MOVII mpr, xA ; depth in mbar
4955 movff hi,xA+1 5375 MOVLI .102,xB ; 0.98 bar / 10 meter
4956
4957 movlw d'102' ; 0.98 bar / 10 meter
4958 movwf xB+0
4959 clrf xB+1
4960 call mult16x16 ; xC:4 = xA:2 * xB:2 5376 call mult16x16 ; xC:4 = xA:2 * xB:2
4961 movff up,xB+0 ; salinity 5377 movff up,xB+0 ; salinity
4962 clrf xB+1 5378 clrf xB+1
4963 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder 5379 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
4964 movff xC+0,lo 5380 MOVII xC,mpr ; copy corrected values back to hi:lo
4965 movff xC+1,hi ; copy corrected values back to lo and hi
4966 return 5381 return
4967 5382
4968 ;============================================================================= 5383 ;=============================================================================
4969 5384
4970 global convert_mbar_to_feet 5385 global convert_mbar_to_feet
4971 convert_mbar_to_feet: ; convert value in hi:lo from mbar to feet 5386 convert_mbar_to_feet: ; convert value in hi:lo from mbar to feet
4972 movff lo,xA+0 5387 MOVII mpr, xA ; depth in mbar (multiples of 0.01 meter)
4973 movff hi,xA+1 5388 btfsc sensor_override_active ; in pressure sensor override mode?
4974 5389 bra convert_mbar_to_feet_1 ; YES
4975 movlw LOW d'328' ; 328feet/100m 5390 MOVLI .328,xB ; NO - convert with 328feet/100m
4976 movwf xB+0 5391 bra convert_common_to_feet ; - continue with common part
4977 movlw HIGH d'328' 5392 convert_mbar_to_feet_1:
4978 movwf xB+1 5393 MOVLI .334,xB ; YES - convert with 334feet/100m to be in sync with values shown in menu
4979 5394 bra convert_common_to_feet ; - continue with common part
4980 call mult16x16 ; xA*xB=xC (lo:hi * 328) 5395
4981 5396
5397 global convert_meter_to_feet
5398 convert_meter_to_feet: ; convert value in lo from meters to feet
5399 movf lo,W ; depth in meter
5400 mullw .100 ; convert meter to mbar
5401 MOVII PRODL,xA ; depth in mbar (multiples of 0.01 meter)
5402 MOVLI .334,xB ; convert with 334feet/100m to have 10ft, 20ft, 30ft for stop depths
5403
5404 convert_common_to_feet:
5405 call mult16x16 ; xC = xA * xB = depth in 0.01 meter * xxx feet / 100 meter
4982 movlw d'50' ; round up 5406 movlw d'50' ; round up
4983 addwf xC+0,F 5407 addwf xC+0,F
4984 movlw 0 5408 movlw .0
4985 addwfc xC+1,F 5409 addwfc xC+1,F
4986 addwfc xC+2,F 5410 addwfc xC+2,F
4987 addwfc xC+3,F 5411 addwfc xC+3,F
4988 5412 MOVLI .10000,xB ; 10000 = 100 for depth in 0.01 meter to full meter x 100 for feet factor is per 100 meter
4989 movlw LOW .10000 5413 call div32x16 ; xC = xC / xB with xA as remainder
4990 movwf xB+0 5414 MOVII xC,mpr ; store result
4991 movlw HIGH .10000 5415
4992 movwf xB+1
4993
4994 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
4995
4996 movff xC+0,lo
4997 movff xC+1,hi ; restore lo and hi with updated value
4998 return 5416 return
4999 5417
5000 ;============================================================================= 5418 ;=============================================================================
5001 5419
5002 global convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit 5420 global convert_celsius_to_fahrenheit ; convert value in hi:lo from Celsius to Fahrenheit
5003 convert_celsius_to_fahrenheit: ; convert value in lo:hi from Celsius to Fahrenheit 5421 convert_celsius_to_fahrenheit: ; convert value in lo:hi from Celsius to Fahrenheit
5004 movff lo,xA+0 ; temperature in 1/10 of °C 5422 MOVII mpr,xA ; temperature in 1/10 of °C
5005 movff hi,xA+1 5423 ADDLI .1000,xA ; add offset of 1000 to get out of any negative numbers
5006 5424 ; adjust scaling: 1°C = 1.8°F:
5007 movlw LOW d'1000' ; offset °C value by 1000 to get out of any negative numbers 5425 MOVLI .18,xB ; multiply with 18:
5008 addwf xA+0,F 5426 call mult16x16 ; ...
5009 movlw HIGH d'1000' 5427 MOVLI .10,xB ; divide by 10
5010 addwfc xA+1,F 5428 call div32x16 ; ...
5011 5429 SUBLI .1480,xC ; remove offset: subtract above offset of 1000 * 1.8 = 1800 now and add 320 => subtract 1480
5012 movlw d'18' ; adjust scaling: 1°C = 1.8°F 5430 MOVII xC,mpr ; store result in hi:lo
5013 movwf xB+0
5014 clrf xB+1
5015
5016 call mult16x16 ; xA*xB=xC (lo:hi * 18)
5017
5018 movlw d'10'
5019 movwf xB+0
5020 clrf xB+1
5021
5022 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
5023
5024 movlw LOW d'1480' ; adjust offset: subtract above offset of 1000 * 1.8 = 1800 now and add 320 => subtract 1480
5025 subwf xC+0,F
5026 movlw HIGH d'1480'
5027 subwfb xC+1,F
5028
5029 movff xC+0,lo
5030 movff xC+1,hi ; restore lo and hi with updated value
5031 return 5431 return
5032 5432
5033 ;============================================================================= 5433 ;=============================================================================
5034 5434
5035 END 5435 END