comparison src/tft_outputs.asm @ 604:ca4556fb60b9

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