Mercurial > public > hwos_code
comparison src/tft_outputs.asm @ 0:11d4fc797f74
init
author | heinrichsweikamp |
---|---|
date | Wed, 24 Apr 2013 19:22:45 +0200 |
parents | |
children | 04794990b619 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:11d4fc797f74 |
---|---|
1 ;============================================================================= | |
2 ; | |
3 ; File tft_outputs.asm | |
4 ; | |
5 ; Startup subroutines | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-07 : [mH] moving from OSTC code | |
11 | |
12 #include "ostc3.inc" ; Mandatory header | |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
14 #include "tft.inc" | |
15 #include "wait.inc" | |
16 #include "strings.inc" | |
17 #include "convert.inc" | |
18 #include "varargs.inc" | |
19 #include "math.inc" | |
20 #include "isr.inc" | |
21 #include "eeprom_rs232.inc" | |
22 #include "adc_lightsensor.inc" | |
23 #include "surfmode.inc" | |
24 #include "divemode.inc" | |
25 #include "external_flash.inc" | |
26 #include "ghostwriter.inc" | |
27 #include "customview.inc" | |
28 #include "i2c.inc" | |
29 | |
30 extern aa_wordprocessor | |
31 | |
32 ;============================================================================= | |
33 | |
34 gui CODE | |
35 ;============================================================================= | |
36 | |
37 global TFT_divemask_color | |
38 TFT_divemask_color: | |
39 movlw color_green ; TODO | |
40 bra TFT_standard_color0 | |
41 | |
42 global TFT_warnings_color | |
43 TFT_warnings_color: | |
44 movlw color_red ; TODO | |
45 bra TFT_standard_color0 | |
46 | |
47 global TFT_disabled_color | |
48 TFT_disabled_color: | |
49 movlw color_grey ; Default to OSTC grey (dark blue) | |
50 bra TFT_standard_color0 | |
51 | |
52 global TFT_standard_color | |
53 TFT_standard_color: | |
54 setf WREG ; TODO... | |
55 TFT_standard_color0: | |
56 call TFT_set_color | |
57 return | |
58 | |
59 TFT_color_code macro color_code_temp | |
60 movlw color_code_temp | |
61 call TFT_color_code1 | |
62 endm | |
63 | |
64 global TFT_color_code1 | |
65 TFT_color_code1: ; Color-codes the output, if required | |
66 dcfsnz WREG | |
67 bra TFT_color_code_depth ; depth_warn_mbar [mbar], 16Bit | |
68 dcfsnz WREG | |
69 bra TFT_color_code_cns ; color_code_cns_high [%] | |
70 dcfsnz WREG | |
71 bra TFT_color_code_gf ; color_code_gf_warn_high [%] | |
72 dcfsnz WREG | |
73 bra TFT_color_code_ppo2 ; Color-code the OC ppO2 results [cbar], opt_ppO2_max as threshold | |
74 dcfsnz WREG | |
75 bra TFT_color_code_velocity ; color_code_velocity_warn_high [m/min] | |
76 dcfsnz WREG | |
77 bra TFT_color_code_ceiling ; Show warning if current depth>shown ceiling | |
78 dcfsnz WREG | |
79 bra TFT_color_code_gaslist ; Color-code current row in Gaslist (%O2 in hi), opt_ppO2_max as threshold | |
80 dcfsnz WREG | |
81 bra TFT_color_code_ppo2_hud ; Color-code the hud ppO2 readings [cbar], opt_ppO2_max as threshold | |
82 dcfsnz WREG | |
83 bra TFT_color_code_battery ; Color-code the battery display | |
84 | |
85 TFT_color_code_gaslist: ; %O2 in hi | |
86 ; Check very high ppO2 manually | |
87 SAFE_2BYTE_COPY amb_pressure,xA | |
88 movlw d'10' | |
89 movwf xB+0 | |
90 clrf xB+1 | |
91 call div16x16 ; xC=p_amb/10 | |
92 movff xC+0,xA+0 | |
93 movff xC+1,xA+1 | |
94 movff hi,xB+0 | |
95 clrf xB+1 | |
96 call mult16x16 ; lo * p_amb/10 | |
97 ; Check if ppO2>6,55bar | |
98 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
99 bra TFT_color_code_warn ; Yes, warn in warning color | |
100 ; Check if ppO2>3,30bar | |
101 btfsc xC+1,7 | |
102 bra TFT_color_code_warn ; Yes, warn in warning color | |
103 | |
104 ; Check for low ppo2 | |
105 movff xC+0,sub_a+0 | |
106 movff xC+1,sub_a+1 | |
107 movff opt_ppO2_min,WREG | |
108 mullw d'100' ; opt_ppO2_min*100 | |
109 movff PRODL,sub_b+0 | |
110 movff PRODH,sub_b+1 | |
111 call subU16 | |
112 btfsc neg_flag | |
113 bra TFT_color_code_warn ; too low -> Warning Color! | |
114 | |
115 ; Check for high ppo2 | |
116 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode | |
117 mullw d'100' ; opt_ppO2_max*100 | |
118 movff PRODL,sub_b+0 | |
119 movff PRODH,sub_b+1 | |
120 call subU16 ; sub_c = sub_a - sub_b | |
121 btfss neg_flag | |
122 bra TFT_color_code_warn ; too high -> Warning Color! | |
123 return | |
124 | |
125 TFT_color_code_warn: | |
126 call TFT_warnings_color | |
127 return | |
128 | |
129 TFT_color_code_ceiling: | |
130 SAFE_2BYTE_COPY rel_pressure, lo | |
131 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
132 movff hi,xA+1 | |
133 movff lo,xA+0 | |
134 movff char_O_first_deco_depth,lo ; Ceiling in m | |
135 decf lo,F ; -1 | |
136 movlw LOW d'100' | |
137 movwf xB+0 | |
138 clrf xB+1 ; Devide/100 -> xC+0 = Depth in m | |
139 call div16x16 ; xA/xB=xC with xA as remainder | |
140 movf xC+0,W ; Depth in m | |
141 subwf lo,W | |
142 btfsc STATUS,C | |
143 bra TFT_color_code_warn ; Set to warning color | |
144 call TFT_standard_color | |
145 return | |
146 | |
147 TFT_color_code_depth: | |
148 movff hi,hi_temp | |
149 movff lo,lo_temp | |
150 SAFE_2BYTE_COPY rel_pressure, lo | |
151 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
152 movff lo,sub_a+0 | |
153 movff hi,sub_a+1 | |
154 movlw LOW depth_warn_mbar | |
155 movwf lo | |
156 movlw HIGH depth_warn_mbar | |
157 movwf hi | |
158 movff lo,sub_b+0 | |
159 movff hi,sub_b+1 | |
160 movff hi_temp,hi | |
161 movff lo_temp,lo ; Restore hi, lo | |
162 call subU16 ; sub_c = sub_a - sub_b | |
163 btfss neg_flag | |
164 bra TFT_color_code_warn ; Set to warning color | |
165 call TFT_standard_color | |
166 return | |
167 | |
168 TFT_color_code_cns: | |
169 movff int_O_CNS_fraction+1,lo ; copy into bank1 | |
170 tstfsz lo ; >255% ? | |
171 bra TFT_color_code_warn ; Yes | |
172 movff int_O_CNS_fraction+0,lo | |
173 movlw color_code_cns_high ; CNS Warn [%] | |
174 subwf lo,W | |
175 btfsc STATUS,C | |
176 bra TFT_color_code_warn ; Set to warning color | |
177 call TFT_standard_color | |
178 return | |
179 | |
180 TFT_color_code_gf: | |
181 movff char_O_gradient_factor,lo ; gradient factor | |
182 movlw color_code_gf_warn_high ; GF Warn [%] | |
183 subwf lo,W | |
184 btfsc STATUS,C | |
185 bra TFT_color_code_warn ; Set to warning color | |
186 call TFT_standard_color | |
187 return | |
188 | |
189 TFT_color_code_ppo2: | |
190 ; Check if ppO2>6,55bar | |
191 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
192 bra TFT_color_code_warn ; Yes, warn in warning color | |
193 ; Check if ppO2>3,30bar | |
194 btfsc xC+1,7 | |
195 bra TFT_color_code_warn ; Yes, warn in warning color | |
196 | |
197 movff xC+0,sub_a+0 | |
198 movff xC+1,sub_a+1 | |
199 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode | |
200 mullw d'100' | |
201 movff PRODL,sub_b+0 | |
202 movff PRODH,sub_b+1 | |
203 call subU16 ; sub_c = sub_a - sub_b | |
204 btfss neg_flag | |
205 bra TFT_color_code_warn ; Set to warning color | |
206 | |
207 movff xC+0,sub_a+0 | |
208 movff xC+1,sub_a+1 | |
209 movff opt_ppO2_min,WREG ; PPO2 min for Sensors and color coding in divemode | |
210 mullw d'100' | |
211 movff PRODL,sub_b+0 | |
212 movff PRODH,sub_b+1 | |
213 call subU16 ; sub_c = sub_a - sub_b | |
214 btfsc neg_flag | |
215 bra TFT_color_code_warn ; Set to warning color | |
216 call TFT_standard_color | |
217 return | |
218 | |
219 TFT_color_code_velocity: | |
220 btfss neg_flag ; Ignore for descend! | |
221 bra TFT_color_code_velocity1 ; Skip check! | |
222 movff divA+0,lo | |
223 movlw color_code_velocity_warn_high ; Velocity warn [m/min] | |
224 subwf lo,W | |
225 btfsc STATUS,C | |
226 bra TFT_color_code_warn ; Set to warning color | |
227 TFT_color_code_velocity1: | |
228 call TFT_standard_color | |
229 return | |
230 | |
231 TFT_color_code_ppo2_hud: ; With ppO2 [cbar] in lo | |
232 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode | |
233 cpfsgt lo ; lo > opt_ppO2_max? | |
234 bra TFT_color_code_ppo2_hud1; No | |
235 bra TFT_color_code_warn ; Yes | |
236 TFT_color_code_ppo2_hud1: | |
237 movff opt_ppO2_min,WREG ; PPO2 min for Sensors and color coding in divemode | |
238 cpfslt lo ; lo < opt_ppO2_min? | |
239 bra TFT_color_code_ppo2_hud2; No | |
240 bra TFT_color_code_warn ; Yes | |
241 TFT_color_code_ppo2_hud2: | |
242 call TFT_standard_color | |
243 return | |
244 | |
245 TFT_color_code_battery: ; With battery percent in lo | |
246 movlw color_code_battery_low | |
247 cpfsgt lo ; lo < color_code_battery_low ? | |
248 bra TFT_color_code_warn ; No | |
249 call TFT_standard_color | |
250 return | |
251 | |
252 ; **************************************************************************** | |
253 | |
254 global TFT_divemode_mask | |
255 TFT_divemode_mask: ; Displays mask in Dive-Mode | |
256 call TFT_divemask_color | |
257 WIN_TINY divemode_mask_depth_column,divemode_mask_depth_row | |
258 lfsr FSR2,buffer | |
259 STRCAT_TEXT_PRINT tDepth | |
260 WIN_TINY divemode_mask_maxdepth_column,divemode_mask_maxdepth_row | |
261 lfsr FSR2,buffer | |
262 STRCAT_TEXT_PRINT tMaxDepth | |
263 WIN_TINY divemode_mask_divetime_column,divemode_mask_divetime_row | |
264 lfsr FSR2,buffer | |
265 STRCAT_TEXT_PRINT tDivetime | |
266 | |
267 call TFT_standard_color | |
268 return | |
269 | |
270 global TFT_clear_customview_divemode | |
271 TFT_clear_customview_divemode: | |
272 WIN_BOX_BLACK divemode_customview_row, .163, .0, .159 ; top, bottom, left, right | |
273 return | |
274 | |
275 global TFT_display_velocity | |
276 TFT_display_velocity: ; With divA+0 = m/min | |
277 TFT_color_code warn_velocity ; Color-code Output (With divA+0 = m/min) | |
278 WIN_SMALL velocity_text_column,velocity_text_row | |
279 | |
280 TSTOSS opt_units ; 0=Meters, 1=Feets | |
281 bra TFT_display_velocity_metric | |
282 ;TFT_display_velocity_imperial: | |
283 lfsr FSR2,buffer | |
284 movff divA+0,WREG ; divA+0 = m/min | |
285 mullw .100 ; PRODL:PRODH = mbar/min | |
286 movff PRODL,lo | |
287 movff PRODH,hi | |
288 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
289 movlw '-' | |
290 btfsc neg_flag | |
291 movlw '+' | |
292 movwf POSTINC2 | |
293 bsf leftbind | |
294 output_16 | |
295 bcf leftbind | |
296 STRCAT_TEXT_PRINT tVelImperial ; Unit switch | |
297 call TFT_standard_color | |
298 return | |
299 | |
300 TFT_display_velocity_metric: | |
301 lfsr FSR2,buffer | |
302 movff divA+0,lo ; divA+0 = m/min | |
303 movlw '-' | |
304 btfsc neg_flag | |
305 movlw '+' | |
306 movwf POSTINC2 | |
307 output_99 | |
308 STRCAT_TEXT_PRINT tVelMetric ; Unit switch | |
309 call TFT_standard_color | |
310 return | |
311 | |
312 global TFT_display_velocity_clear | |
313 TFT_display_velocity_clear: | |
314 ; Clear Text | |
315 WIN_BOX_BLACK velocity_text_row, velocity_text_row+.22, velocity_text_column, (velocity_text_column+.7*.8)-1 ; top, bottom, left, right | |
316 return | |
317 | |
318 TFT_clear_decoarea: | |
319 WIN_BOX_BLACK decostop_1st_stop_row, .239, decostop_1st_stop_column ,.159 ; top, bottom, left, right | |
320 return | |
321 | |
322 global TFT_clear_divemode_menu | |
323 TFT_clear_divemode_menu: | |
324 WIN_BOX_BLACK divemode_menu_row, divemode_menu_lower, divemode_menu_left ,divemode_menu_right ; top, bottom, left, right | |
325 return | |
326 | |
327 global TFT_display_ndl_mask | |
328 TFT_display_ndl_mask: | |
329 btfsc divemode_menu ; Is the dive mode menu shown? | |
330 return ; Yes, return | |
331 rcall TFT_clear_decoarea ; Clear Dekostop and Dekosum | |
332 call TFT_divemask_color | |
333 WIN_STD ndl_text_column,ndl_text_row | |
334 STRCPY_TEXT_PRINT tNDL ; NDL | |
335 call TFT_standard_color | |
336 return | |
337 | |
338 global TFT_show_TTS_divemode | |
339 TFT_show_TTS_divemode: | |
340 btfsc divemode_menu ; Is the dive mode menu shown? | |
341 return ; Yes, return | |
342 call TFT_standard_color | |
343 movff int_O_ascenttime+0,lo ; TTS | |
344 movff int_O_ascenttime+1,hi ; on 16bits | |
345 WIN_MEDIUM tts_value_column,tts_value_row | |
346 lfsr FSR2,buffer | |
347 output_16_3 ;Displays only 0...999 | |
348 STRCAT_PRINT "'" | |
349 return | |
350 | |
351 global TFT_display_ndl | |
352 TFT_display_ndl: | |
353 btfsc divemode_menu ; Is the dive mode menu shown? | |
354 return ; Yes, return | |
355 WIN_MEDIUM ndl_value_column,ndl_value_row | |
356 lfsr FSR2,buffer | |
357 call TFT_standard_color | |
358 movff char_O_nullzeit,lo ; Get NDL from C-code | |
359 output_8 | |
360 STRCAT_PRINT "'" | |
361 return | |
362 | |
363 global TFT_divemode_warning | |
364 TFT_divemode_warning: | |
365 bsf dive_warning_displayed ; =1: The warning sign is shown | |
366 WIN_TOP warning_icon_row | |
367 WIN_LEFT warning_icon_column | |
368 TFT_WRITE_PROM_IMAGE dive_warning_block ; Show Warning icon | |
369 ; movlw .3 | |
370 ; cpfslt warning_counter ; More then two warnings? | |
371 ; rcall TFT_divemode_warning_counter ; Yes, show the number | |
372 return | |
373 | |
374 ;TFT_divemode_warning_counter: | |
375 ; WIN_SMALL warning_icon_column+.8,warning_icon_row+.13 | |
376 ; lfsr FSR2,buffer | |
377 ; call TFT_warnings_color | |
378 ; movff warning_counter,lo | |
379 ; bsf leftbind | |
380 ; output_8 | |
381 ; bcf leftbind | |
382 ; STRCAT_PRINT "" | |
383 ; call TFT_standard_color | |
384 ; return | |
385 | |
386 global TFT_divemode_warning_clear | |
387 TFT_divemode_warning_clear: | |
388 btfss dive_warning_displayed ; =1: The warning sign is shown | |
389 return | |
390 bcf dive_warning_displayed ; clear only once | |
391 WIN_BOX_BLACK warning_icon_row, warning_icon_row+.38, warning_icon_column, warning_icon_column+.21; top, bottom, left, right | |
392 return | |
393 | |
394 global TFT_display_deko_mask | |
395 TFT_display_deko_mask: | |
396 rcall TFT_clear_decoarea | |
397 WIN_STD tts_text_column,tts_text_row | |
398 call TFT_divemask_color | |
399 STRCPY_TEXT_PRINT tTTS ; TTS | |
400 call TFT_standard_color | |
401 return | |
402 | |
403 TFT_display_deko_output_depth: ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
404 TSTOSS opt_units ; 0=m, 1=ft | |
405 bra TFT_display_deko_output_metric | |
406 ;TFT_display_deko_output_imperial: | |
407 movf lo,W ; lo = m | |
408 mullw .100 ; PRODL:PRODH = mbar | |
409 movff PRODL,lo | |
410 movff PRODH,hi | |
411 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops... | |
412 movff lo,xA+0 | |
413 movff hi,xA+1 | |
414 movlw LOW d'334' ; 334feet/100m | |
415 movwf xB+0 | |
416 movlw HIGH d'334' | |
417 movwf xB+1 | |
418 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
419 movlw d'50' ; round up | |
420 addwf xC+0,F | |
421 movlw 0 | |
422 addwfc xC+1,F | |
423 addwfc xC+2,F | |
424 addwfc xC+3,F | |
425 movlw d'100' | |
426 movwf xB+0 | |
427 clrf xB+1 | |
428 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
429 movff xC+0,lo | |
430 movff xC+1,hi ; restore lo and hi with updated value | |
431 bcf leftbind | |
432 bsf ignore_digit4 ; Only full feet | |
433 output_16 | |
434 STRCAT_TEXT tFeets1 | |
435 return | |
436 | |
437 TFT_display_deko_output_metric: | |
438 output_99 | |
439 STRCAT_TEXT tMeters | |
440 PUTC ' ' | |
441 return | |
442 | |
443 global TFT_display_deko | |
444 TFT_display_deko: | |
445 btfsc divemode_menu ; Is the dive mode menu shown? | |
446 return ; Yes, return | |
447 WIN_MEDIUM decostop_1st_stop_column,decostop_1st_stop_row | |
448 TFT_color_code warn_ceiling ; Color-code Output | |
449 lfsr FSR2,buffer | |
450 movff char_O_first_deco_depth,lo ; Ceiling in m | |
451 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
452 movff char_O_first_deco_time,lo ; length of first stop in min | |
453 output_99 | |
454 STRCAT_PRINT "'" | |
455 call TFT_standard_color | |
456 return | |
457 | |
458 global TFT_decoplan | |
459 TFT_decoplan: | |
460 call TFT_divemask_color | |
461 WIN_TINY decoplan_title_column,decoplan_title_row | |
462 STRCPY_TEXT_PRINT tDiveDecoplan | |
463 call TFT_standard_color | |
464 | |
465 movff char_O_deco_depth+1,lo | |
466 tstfsz lo ; Show another stop? | |
467 bra TFT_display_deko2 ; Yes | |
468 ; No, clear output and return | |
469 call TFT_standard_color | |
470 WIN_SMALL decostop_4th_stop_column+.16,decostop_4th_stop_row | |
471 STRCPY_PRINT "---" | |
472 WIN_BOX_BLACK decostop_2nd_stop_row, divemode_simtext_row-1, decostop_2nd_stop_column, decostop_4th_stop_column ; top, bottom, left, right | |
473 WIN_BOX_BLACK decostop_5th_stop_row, divemode_simtext_row-1, decostop_5th_stop_column, decostop_6th_stop_column ; top, bottom, left, right | |
474 WIN_BOX_BLACK decostop_6th_stop_row, divemode_simtext_row-1, decostop_6th_stop_column, .159 ; top, bottom, left, right | |
475 return | |
476 TFT_display_deko2: | |
477 WIN_SMALL decostop_2nd_stop_column,decostop_2nd_stop_row | |
478 lfsr FSR2,buffer | |
479 movff char_O_deco_depth+1,lo ; stop in m | |
480 bcf lo,7 ; Clear GAS_SWITCH bit | |
481 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
482 movff char_O_deco_time+1,lo ; length of stop in min | |
483 output_99 | |
484 STRCAT_PRINT "'" | |
485 movff char_O_deco_depth+2,lo | |
486 tstfsz lo ; Show another stop? | |
487 bra TFT_display_deko3 ; Yes | |
488 ; No, clear output and return | |
489 WIN_BOX_BLACK decostop_3rd_stop_row, divemode_simtext_row-1, decostop_2nd_stop_column, decostop_4th_stop_column ; top, bottom, left, right | |
490 WIN_BOX_BLACK decostop_4th_stop_row, divemode_simtext_row-1, decostop_4th_stop_column, .159 ; top, bottom, left, right | |
491 return | |
492 | |
493 TFT_display_deko3: | |
494 WIN_SMALL decostop_3rd_stop_column,decostop_3rd_stop_row | |
495 lfsr FSR2,buffer | |
496 movff char_O_deco_depth+2,lo ; stop in m | |
497 bcf lo,7 ; Clear GAS_SWITCH bit | |
498 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
499 movff char_O_deco_time+2,lo ; length of stop in min | |
500 output_99 | |
501 STRCAT_PRINT "'" | |
502 | |
503 movff char_O_deco_depth+3,lo | |
504 tstfsz lo ; Show another stop? | |
505 bra TFT_display_deko4 ; Yes | |
506 ; No, clear output and return | |
507 WIN_BOX_BLACK decostop_4th_stop_row, divemode_simtext_row-1, decostop_4th_stop_column, .159 ; top, bottom, left, right | |
508 return ; Done. | |
509 | |
510 TFT_display_deko4: | |
511 WIN_SMALL decostop_4th_stop_column,decostop_4th_stop_row | |
512 lfsr FSR2,buffer | |
513 movff char_O_deco_depth+3,lo ; stop in m | |
514 bcf lo,7 ; Clear GAS_SWITCH bit | |
515 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
516 movff char_O_deco_time+3,lo ; length of stop in min | |
517 output_99 | |
518 STRCAT_PRINT "'" | |
519 | |
520 movff char_O_deco_depth+4,lo | |
521 tstfsz lo ; Show another stop? | |
522 bra TFT_display_deko5 ; Yes | |
523 ; No, clear output and return | |
524 WIN_BOX_BLACK decostop_5th_stop_row, divemode_simtext_row-1, decostop_5th_stop_column, decostop_6th_stop_column ; top, bottom, left, right | |
525 WIN_BOX_BLACK decostop_6th_stop_row, divemode_simtext_row-1, decostop_6th_stop_column, .159 ; top, bottom, left, right | |
526 return ; Done. | |
527 | |
528 TFT_display_deko5: | |
529 WIN_SMALL decostop_5th_stop_column,decostop_5th_stop_row | |
530 lfsr FSR2,buffer | |
531 movff char_O_deco_depth+4,lo ; stop in m | |
532 bcf lo,7 ; Clear GAS_SWITCH bit | |
533 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
534 movff char_O_deco_time+4,lo ; length of stop in min | |
535 output_99 | |
536 STRCAT_PRINT "'" | |
537 movff char_O_deco_depth+5,lo | |
538 tstfsz lo ; Show another stop? | |
539 bra TFT_display_deko6 ; Yes | |
540 ; No, clear output and return | |
541 WIN_BOX_BLACK decostop_6th_stop_row, divemode_simtext_row-1, decostop_6th_stop_column, .159 ; top, bottom, left, right | |
542 return ; Done. | |
543 TFT_display_deko6: | |
544 WIN_SMALL decostop_6th_stop_column,decostop_6th_stop_row | |
545 lfsr FSR2,buffer | |
546 movff char_O_deco_depth+5,lo ; stop in m | |
547 bcf lo,7 ; Clear GAS_SWITCH bit | |
548 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
549 movff char_O_deco_time+5,lo ; length of stop in min | |
550 output_99 | |
551 STRCAT_PRINT "'" | |
552 movff char_O_deco_depth+6,lo | |
553 tstfsz lo ; Show another stop? | |
554 bra TFT_display_deko7 ; Yes | |
555 ; No, clear output and return | |
556 WIN_BOX_BLACK decostop_7th_stop_row, divemode_simtext_row-1, decostop_7th_stop_column, .159 ; top, bottom, left, right | |
557 return ; Done. | |
558 TFT_display_deko7: | |
559 WIN_SMALL decostop_7th_stop_column,decostop_7th_stop_row | |
560 lfsr FSR2,buffer | |
561 movff char_O_deco_depth+6,lo ; stop in m | |
562 bcf lo,7 ; Clear GAS_SWITCH bit | |
563 rcall TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft) | |
564 movff char_O_deco_time+6,lo ; length of stop in min | |
565 output_99 | |
566 STRCAT_PRINT "'" | |
567 return ; Done. | |
568 | |
569 ;TFT_display_deko1: | |
570 ; movff char_O_gradient_factor,lo ; gradient factor | |
571 ; movlw gf_display_threshold ; threshold for display | |
572 ; cpfslt lo ; show value? | |
573 ; bra TFT_display_deko2 ; Yes | |
574 ; ; No | |
575 ; bra TFT_display_ndl_mask2 ; Clear gradient factor | |
576 ; | |
577 | |
578 global TFT_mask_avr_stopwatch ; Show mask for average depth and stopwatch | |
579 TFT_mask_avr_stopwatch: | |
580 ; The mask | |
581 call TFT_divemask_color | |
582 WIN_TINY dive_custom_avr_stop_column1,dive_custom_avr_stop_row | |
583 STRCPY_TEXT_PRINT tDiveTotalAvr | |
584 WIN_TINY dive_custom_avr_stop_column2,dive_custom_avr_stop_row | |
585 STRCPY_TEXT_PRINT tDiveStopwatch | |
586 WIN_TINY dive_custom_avr_stop_column3,dive_custom_avr_stop_row | |
587 STRCPY_TEXT_PRINT tDiveStopAvr | |
588 call TFT_standard_color | |
589 return | |
590 | |
591 global TFT_update_avr_stopwatch ; Update average depth and stopwatch | |
592 TFT_update_avr_stopwatch: | |
593 call TFT_standard_color | |
594 SAFE_2BYTE_COPY average_divesecs,lo | |
595 call convert_time ; lo=secs, hi=mins | |
596 WIN_MEDIUM dive_avr_stop_column2,dive_avr_stop_row | |
597 lfsr FSR2,buffer | |
598 bsf leftbind | |
599 movf hi,W | |
600 movff lo,hi | |
601 movwf lo ; exchange lo and hi | |
602 output_8 | |
603 PUTC ':' | |
604 movff hi,lo | |
605 output_99x | |
606 movlw .5 | |
607 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
608 clrf WREG | |
609 movff WREG,buffer+.5 ; limit to 5 chars | |
610 STRCAT_PRINT "" | |
611 | |
612 TSTOSS opt_units ; 0=m, 1=ft | |
613 bra TFT_update_avr_stopwatch_metric | |
614 ;TFT_update_avr_stopwatch_imperial | |
615 movff avr_rel_pressure_total+0,lo | |
616 movff avr_rel_pressure_total+1,hi | |
617 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
618 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
619 WIN_MEDIUM dive_avr_stop_column1,dive_avr_stop_row | |
620 lfsr FSR2,buffer | |
621 bsf leftbind | |
622 output_16 ; yxz | |
623 STRCAT_PRINT " " | |
624 ; Stopped average depth | |
625 movff avr_rel_pressure+0,lo | |
626 movff avr_rel_pressure+1,hi | |
627 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
628 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
629 WIN_MEDIUM dive_avr_stop_column3,dive_avr_stop_row | |
630 lfsr FSR2,buffer | |
631 output_16 ; yxz | |
632 bcf leftbind | |
633 STRCAT_PRINT " " | |
634 return | |
635 | |
636 TFT_update_avr_stopwatch_metric: | |
637 ; Non-resettable average depth | |
638 movff avr_rel_pressure_total+0,lo | |
639 movff avr_rel_pressure_total+1,hi | |
640 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
641 WIN_MEDIUM dive_avr_stop_column1,dive_avr_stop_row | |
642 lfsr FSR2,buffer | |
643 bsf ignore_digit5 ; no cm | |
644 output_16dp .3 ; yxz.a | |
645 STRCAT_PRINT "" | |
646 ; Stopped average depth | |
647 movff avr_rel_pressure+0,lo | |
648 movff avr_rel_pressure+1,hi | |
649 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
650 WIN_MEDIUM dive_avr_stop_column3,dive_avr_stop_row | |
651 lfsr FSR2,buffer | |
652 bsf ignore_digit5 ; no cm | |
653 output_16dp .3 ; yxz.a | |
654 bcf leftbind | |
655 bcf ignore_digit5 | |
656 STRCAT_PRINT "" | |
657 return | |
658 | |
659 global TFT_hud_mask ; The HUD mask | |
660 TFT_hud_mask: | |
661 ; The mask | |
662 call TFT_divemask_color | |
663 WIN_TINY dive_custom_hud_column1,dive_custom_hud_row | |
664 STRCPY_TEXT_PRINT tDiveHudMask1 | |
665 WIN_TINY dive_custom_hud_column2,dive_custom_hud_row | |
666 STRCPY_TEXT_PRINT tDiveHudMask2 | |
667 WIN_TINY dive_custom_hud_column3,dive_custom_hud_row | |
668 STRCPY_TEXT_PRINT tDiveHudMask3 | |
669 call TFT_standard_color | |
670 return | |
671 | |
672 global TFT_update_hud ; Update HUD data | |
673 TFT_update_hud: | |
674 ; show three sensors | |
675 bsf leftbind | |
676 movff o2_ppo2_sensor1,lo | |
677 tstfsz lo ; ppO2=0 (No data/failure)? | |
678 bra TFT_update_hud1 ; No | |
679 btfss dive_hud1_displayed ; Was the sensor shown? | |
680 bra TFT_update_hud2 ; Yes, skip clear | |
681 bcf dive_hud1_displayed ; No, clear display flag | |
682 WIN_BOX_BLACK dive_hud_data_row, dive_hud_data_row+.30, dive_hud_sensor1_column, dive_hud_sensor2_column ; top, bottom, left, right | |
683 WIN_STD dive_hud_sensor1_column+.7,dive_hud_data_row+.5 | |
684 call TFT_standard_color | |
685 STRCPY_PRINT "---" | |
686 bra TFT_update_hud2 ; Skip Sensor 1 | |
687 TFT_update_hud1: | |
688 WIN_MEDIUM dive_hud_sensor1_column,dive_hud_data_row | |
689 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
690 lfsr FSR2,buffer | |
691 clrf hi | |
692 output_16dp .3 ; x.xx bar | |
693 STRCAT_PRINT "" | |
694 bsf dive_hud1_displayed ; Set display flag | |
695 TFT_update_hud2: | |
696 movff o2_ppo2_sensor2,lo | |
697 tstfsz lo ; ppO2=0 (No data/failure)? | |
698 bra TFT_update_hud3 ; No | |
699 btfss dive_hud2_displayed ; Was the sensor shown? | |
700 bra TFT_update_hud4 ; Yes, skip clear | |
701 bcf dive_hud2_displayed ; No, clear display flag | |
702 WIN_BOX_BLACK dive_hud_data_row, dive_hud_data_row+.30, dive_hud_sensor2_column, dive_hud_sensor3_column ; top, bottom, left, right | |
703 WIN_STD dive_hud_sensor2_column+.7,dive_hud_data_row+.5 | |
704 call TFT_standard_color | |
705 STRCPY_PRINT "---" | |
706 bra TFT_update_hud4 ; Skip Sensor 2 | |
707 TFT_update_hud3: | |
708 WIN_MEDIUM dive_hud_sensor2_column,dive_hud_data_row | |
709 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
710 lfsr FSR2,buffer | |
711 clrf hi | |
712 output_16dp .3 ; x.xx bar | |
713 STRCAT_PRINT "" | |
714 bsf dive_hud2_displayed ; Set display flag | |
715 TFT_update_hud4: | |
716 movff o2_ppo2_sensor3,lo | |
717 tstfsz lo ; ppO2=0 (No data/failure)? | |
718 bra TFT_update_hud5 ; No | |
719 btfss dive_hud3_displayed ; Was the sensor shown? | |
720 bra TFT_update_hud6 ; Yes, skip clear | |
721 bcf dive_hud3_displayed ; No, clear display flag | |
722 WIN_BOX_BLACK dive_hud_data_row, dive_hud_data_row+.30, dive_hud_sensor3_column, .159 ; top, bottom, left, right | |
723 WIN_STD dive_hud_sensor3_column+.7,dive_hud_data_row+.5 | |
724 call TFT_standard_color | |
725 STRCPY_PRINT "---" | |
726 bra TFT_update_hud6 ; Skip Sensor 3 | |
727 TFT_update_hud5: | |
728 WIN_MEDIUM dive_hud_sensor3_column,dive_hud_data_row | |
729 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
730 lfsr FSR2,buffer | |
731 clrf hi | |
732 output_16dp .3 ; x.xx bar | |
733 STRCAT_PRINT "" | |
734 bsf dive_hud3_displayed ; Set display flag | |
735 TFT_update_hud6: | |
736 bcf leftbind | |
737 call TFT_standard_color | |
738 return | |
739 | |
740 global TFT_surface_hud ; Update HUD data in surface mode | |
741 TFT_surface_hud: | |
742 ; show three sensors | |
743 bsf leftbind | |
744 WIN_SMALL surf_hud_sensor1_column,surf_hud_sensor1_row | |
745 movff o2_ppo2_sensor1,lo | |
746 tstfsz lo ; ppO2=0 (No data/failure)? | |
747 bra TFT_surface_hud1 ; No | |
748 call TFT_standard_color | |
749 STRCPY_PRINT "--- " | |
750 bra TFT_surface_hud2 ; Skip Sensor 1 | |
751 TFT_surface_hud1: | |
752 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
753 lfsr FSR2,buffer | |
754 clrf hi | |
755 output_16dp .3 ; x.xx bar | |
756 STRCAT_PRINT "" | |
757 TFT_surface_hud2: | |
758 WIN_SMALL surf_hud_sensor2_column,surf_hud_sensor2_row | |
759 movff o2_ppo2_sensor2,lo | |
760 tstfsz lo ; ppO2=0 (No data/failure)? | |
761 bra TFT_surface_hud3 ; No | |
762 call TFT_standard_color | |
763 STRCPY_PRINT "--- " | |
764 bra TFT_surface_hud4 ; Skip Sensor 2 | |
765 TFT_surface_hud3: | |
766 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
767 lfsr FSR2,buffer | |
768 clrf hi | |
769 output_16dp .3 ; x.xx bar | |
770 STRCAT_PRINT "" | |
771 TFT_surface_hud4: | |
772 WIN_SMALL surf_hud_sensor3_column,surf_hud_sensor3_row | |
773 movff o2_ppo2_sensor3,lo | |
774 tstfsz lo ; ppO2=0 (No data/failure)? | |
775 bra TFT_surface_hud5 ; No | |
776 call TFT_standard_color | |
777 STRCPY_PRINT "--- " | |
778 bra TFT_surface_hud6 ; Skip Sensor 3 | |
779 TFT_surface_hud5: | |
780 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
781 lfsr FSR2,buffer | |
782 clrf hi | |
783 output_16dp .3 ; x.xx bar | |
784 STRCAT_PRINT "" | |
785 TFT_surface_hud6: | |
786 bcf leftbind | |
787 call TFT_standard_color | |
788 return | |
789 | |
790 global TFT_menu_hud | |
791 TFT_menu_hud: ; Yes, update HUD data | |
792 movlw color_yellow | |
793 call TFT_set_color | |
794 bsf leftbind | |
795 WIN_SMALL surf_menu_sensor1_column,surf_menu_sensor1_row | |
796 lfsr FSR2,buffer | |
797 movff o2_ppo2_sensor1,lo | |
798 clrf hi | |
799 output_16dp .3 ; x.xx bar | |
800 PUTC "," | |
801 movff o2_mv_sensor1+0,lo ; in 0.1mV steps | |
802 movff o2_mv_sensor1+1,hi ; in 0.1mV steps | |
803 output_16dp .4 ; xxx.y mV | |
804 STRCAT_PRINT "mV " | |
805 WIN_SMALL surf_menu_sensor2_column,surf_menu_sensor2_row | |
806 lfsr FSR2,buffer | |
807 movff o2_ppo2_sensor2,lo | |
808 clrf hi | |
809 output_16dp .3 ; x.xx bar | |
810 PUTC "," | |
811 movff o2_mv_sensor2+0,lo ; in 0.1mV steps | |
812 movff o2_mv_sensor2+1,hi ; in 0.1mV steps | |
813 output_16dp .4 ; xxx.y mV | |
814 STRCAT_PRINT "mV " | |
815 WIN_SMALL surf_menu_sensor3_column,surf_menu_sensor3_row | |
816 lfsr FSR2,buffer | |
817 movff o2_ppo2_sensor3,lo | |
818 clrf hi | |
819 output_16dp .3 ; x.xx bar | |
820 PUTC "," | |
821 movff o2_mv_sensor3+0,lo ; in 0.1mV steps | |
822 movff o2_mv_sensor3+1,hi ; in 0.1mV steps | |
823 output_16dp .4 ; xxx.y mV | |
824 STRCAT_PRINT "mV " | |
825 WIN_SMALL surf_menu_sensor4_column,surf_menu_sensor4_row | |
826 lfsr FSR2,buffer | |
827 STRCPY "Batt:" | |
828 movff hud_battery_mv+0,lo ; in mV | |
829 movff hud_battery_mv+1,hi ; in mV | |
830 output_16dp .2 ; x.yyy V | |
831 STRCAT_PRINT "V" | |
832 call TFT_standard_color | |
833 bcf leftbind | |
834 return | |
835 | |
836 global TFT_clock | |
837 TFT_clock: | |
838 WIN_TINY surf_clock_column,surf_clock_row | |
839 TFT_clock2: ; called from divemode clock | |
840 call TFT_standard_color | |
841 lfsr FSR2,buffer | |
842 movff hours,lo | |
843 output_99 | |
844 movlw ':' | |
845 btfss secs,0 ; blinking every second | |
846 movlw ' ' | |
847 movwf POSTINC2 | |
848 movff mins,lo | |
849 output_99x | |
850 STRCAT_PRINT "" | |
851 return | |
852 | |
853 global TFT_show_time_date_menu | |
854 TFT_show_time_date_menu: | |
855 call speed_fastest | |
856 WIN_SMALL .15,.30 | |
857 call TFT_standard_color | |
858 lfsr FSR2,buffer | |
859 movff hours,lo | |
860 output_99 | |
861 PUTC ':' | |
862 movff mins,lo | |
863 output_99x | |
864 PUTC ':' | |
865 movff secs,lo | |
866 output_99x | |
867 STRCAT " - " | |
868 movff month,convert_value_temp+0 | |
869 movff day,convert_value_temp+1 | |
870 movff year,convert_value_temp+2 | |
871 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
872 STRCAT_PRINT " " | |
873 return | |
874 ;============================================================================= | |
875 | |
876 global TFT_interval | |
877 TFT_interval: | |
878 call TFT_warning_set_window ; Sets the row and column for the current warning | |
879 tstfsz WREG ; Is there room for the warning? | |
880 return ; No | |
881 STRCPY "Int:" | |
882 movff surface_interval+0,lo | |
883 movff surface_interval+1,hi | |
884 call convert_time ; lo=mins, hi=hours | |
885 movf hi,W | |
886 movff lo,hi | |
887 movwf lo ; exchange lo and hi | |
888 output_99x | |
889 PUTC ':' | |
890 movff hi,lo | |
891 output_99x | |
892 movlw surf_warning_length ; No, use surface string length | |
893 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
894 STRCAT_PRINT "" | |
895 return | |
896 | |
897 global TFT_compass_fast | |
898 TFT_compass_fast: | |
899 WIN_TINY .20,.50 | |
900 STRCPY "X:" | |
901 movff compass_DX+0,lo | |
902 movff compass_DX+1,hi | |
903 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
904 output_16 | |
905 STRCAT " Y:" | |
906 movff compass_DY+0,lo | |
907 movff compass_DY+1,hi | |
908 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
909 output_16 | |
910 STRCAT " Z:" | |
911 movff compass_DZ+0,lo | |
912 movff compass_DZ+1,hi | |
913 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
914 output_16 | |
915 STRCAT_PRINT " " | |
916 return | |
917 | |
918 global TFT_update_raw_data | |
919 TFT_update_raw_data: | |
920 WIN_TINY .0,.0 | |
921 STRCPY "pres:" | |
922 SAFE_2BYTE_COPY amb_pressure, lo | |
923 bsf leftbind | |
924 output_16 | |
925 STRCAT_PRINT "mbar " | |
926 WIN_TINY .80,.0 | |
927 STRCPY "temp:" | |
928 SAFE_2BYTE_COPY temperature, lo | |
929 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
930 movlw d'3' | |
931 movwf ignore_digits | |
932 output_16dp d'2' ; temperature | |
933 STRCAT_PRINT "°C " | |
934 | |
935 call get_battery_voltage ; get battery voltage | |
936 WIN_TINY .0,.18 | |
937 STRCPY "AN06:" | |
938 movff ADRESL,lo | |
939 movff ADRESH,hi | |
940 output_16 | |
941 STRCAT_PRINT "" | |
942 WIN_TINY .80,.18 | |
943 STRCPY "BATT:" | |
944 movff batt_voltage+0,lo | |
945 movff batt_voltage+1,hi | |
946 output_16 | |
947 STRCAT_PRINT "mV " | |
948 | |
949 call get_ambient_level ; get ambient light level | |
950 WIN_TINY .0,.36 | |
951 STRCPY "AN07:" | |
952 movff ADRESL,lo | |
953 movff ADRESH,hi | |
954 output_16 | |
955 STRCAT_PRINT " " | |
956 WIN_TINY .80,.36 | |
957 STRCPY "Amb.:" | |
958 movff ambient_light+0,lo | |
959 movff ambient_light+1,hi | |
960 output_16 | |
961 STRCAT_PRINT " " | |
962 | |
963 call get_rssi_level ; get rssi level | |
964 WIN_TINY .0,.54 | |
965 STRCPY "AN17:" | |
966 movff ADRESL,lo | |
967 movff ADRESH,hi | |
968 output_16 | |
969 STRCAT_PRINT " " | |
970 WIN_TINY .80,.54 | |
971 STRCPY "RSSI:" | |
972 movff rssi_value,lo | |
973 output_8 | |
974 STRCAT_PRINT " " | |
975 | |
976 WIN_TINY .0,.72 | |
977 STRCPY "HUD_Status:" | |
978 movff hud_status_byte,lo | |
979 output_8 | |
980 STRCAT_PRINT " " | |
981 WIN_TINY .80,.72 | |
982 STRCPY "HUD_BATT:" | |
983 movff hud_battery_mv+0,lo | |
984 movff hud_battery_mv+1,hi | |
985 output_16 | |
986 STRCAT_PRINT "mV " | |
987 | |
988 WIN_TINY .0,.90 | |
989 STRCPY "Sens1.:" | |
990 movff o2_mv_sensor1+0,lo | |
991 movff o2_mv_sensor1+1,hi | |
992 output_16dp d'4' | |
993 STRCAT_PRINT "mV " | |
994 WIN_TINY .80,.90 | |
995 STRCPY "Sens2:" | |
996 movff o2_mv_sensor2+0,lo | |
997 movff o2_mv_sensor2+1,hi | |
998 output_16dp d'4' | |
999 STRCAT_PRINT "mV " | |
1000 | |
1001 WIN_TINY .0,.108 | |
1002 STRCPY "Sens3.:" | |
1003 movff o2_mv_sensor3+0,lo | |
1004 movff o2_mv_sensor3+1,hi | |
1005 output_16dp d'4' | |
1006 STRCAT_PRINT "mV " | |
1007 WIN_TINY .80,.108 ; Space | |
1008 | |
1009 WIN_TINY .0,.128 | |
1010 STRCPY "ccDX:" | |
1011 movff compass_DX_f+0,lo ; Display calibrated data | |
1012 movff compass_CX_f+0,WREG ; by substracting compass_CX_f | |
1013 subwf lo,F ; lo := lo - W | |
1014 movff compass_DX_f+1,hi | |
1015 movff compass_CX_f+1,WREG | |
1016 subwfb hi,F | |
1017 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1018 output_16 | |
1019 STRCAT_PRINT " " | |
1020 WIN_TINY .80,.128 | |
1021 STRCPY "ccDY:" | |
1022 movff compass_DY_f+0,lo | |
1023 movff compass_CY_f+0,WREG | |
1024 subwf lo,F | |
1025 movff compass_DY_f+1,hi | |
1026 movff compass_CY_f+1,WREG | |
1027 subwfb hi,F | |
1028 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1029 output_16 | |
1030 STRCAT_PRINT " " | |
1031 WIN_TINY .0,.146 | |
1032 STRCPY "ccDZ:" | |
1033 movff compass_DZ_f+0,lo | |
1034 movff compass_CZ_f+0,WREG | |
1035 subwf lo,F | |
1036 movff compass_DZ_f+1,hi | |
1037 movff compass_CZ_f+1,WREG | |
1038 subwfb hi,F | |
1039 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1040 output_16 | |
1041 STRCAT_PRINT " " | |
1042 WIN_TINY .80,.146 ; Space | |
1043 | |
1044 WIN_TINY .0,.164 | |
1045 STRCPY "AcDX:" | |
1046 movff accel_DX_f+0,lo | |
1047 movff accel_DX_f+1,hi | |
1048 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1049 output_16 | |
1050 STRCAT_PRINT "mg " | |
1051 WIN_TINY .80,.164 | |
1052 STRCPY "AcDY:" | |
1053 movff accel_DY_f+0,lo | |
1054 movff accel_DY_f+1,hi | |
1055 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1056 output_16 | |
1057 STRCAT_PRINT "mg " | |
1058 WIN_TINY .0,.182 | |
1059 STRCPY "AcDZ:" | |
1060 movff accel_DZ_f+0,lo | |
1061 movff accel_DZ_f+1,hi | |
1062 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1063 output_16 | |
1064 STRCAT_PRINT "mg " | |
1065 | |
1066 WIN_TINY .80,.182 | |
1067 STRCPY "Head:" | |
1068 movff compass_heading+0,lo | |
1069 movff compass_heading+1,hi | |
1070 | |
1071 btfsc hi,7 ; Uncalibrated compass ? | |
1072 bra TFT_update_compass_1 | |
1073 | |
1074 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1075 output_16 | |
1076 STRCAT_PRINT " " | |
1077 bra TFT_update_compass_2 | |
1078 | |
1079 TFT_update_compass_1: | |
1080 STRCAT_PRINT "---" | |
1081 | |
1082 TFT_update_compass_2: | |
1083 WIN_TINY .0,.200 | |
1084 STRCPY "calX:" | |
1085 movff compass_CX_f+0,lo | |
1086 movff compass_CX_f+1,hi | |
1087 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1088 output_16 | |
1089 STRCAT ", " | |
1090 movff compass_CY_f+0,lo | |
1091 movff compass_CY_f+1,hi | |
1092 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1093 output_16 | |
1094 STRCAT ", " | |
1095 movff compass_CZ_f+0,lo | |
1096 movff compass_CZ_f+1,hi | |
1097 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1098 output_16 | |
1099 STRCAT_PRINT " " | |
1100 | |
1101 WIN_TINY .0,.218 | |
1102 STRCPY "Roll:" | |
1103 movff compass_roll+0,lo | |
1104 movff compass_roll+1,hi | |
1105 call TFT_convert_signed_16bit | |
1106 output_16 | |
1107 STRCAT_PRINT " " | |
1108 | |
1109 WIN_TINY .80, .218 | |
1110 STRCPY "Pitch:" | |
1111 movff compass_pitch+0,lo | |
1112 movff compass_pitch+1,hi | |
1113 call TFT_convert_signed_16bit | |
1114 output_16 | |
1115 STRCAT_PRINT " " | |
1116 | |
1117 ; call TFT_serial | |
1118 bcf leftbind | |
1119 return | |
1120 | |
1121 | |
1122 global TFT_surface_compass_mask | |
1123 TFT_surface_compass_mask: | |
1124 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row | |
1125 call TFT_standard_color | |
1126 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1127 return | |
1128 | |
1129 global TFT_dive_compass_mask | |
1130 TFT_dive_compass_mask: | |
1131 WIN_TINY dive_compass_mask_column,dive_compass_mask_row | |
1132 call TFT_divemask_color | |
1133 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1134 return | |
1135 | |
1136 | |
1137 global TFT_surface_compass_heading | |
1138 TFT_surface_compass_heading: | |
1139 rcall compass_heading_common | |
1140 WIN_STD surf_compass_head_column,surf_compass_head_row | |
1141 call TFT_standard_color | |
1142 lfsr FSR2,buffer | |
1143 movff compass_heading+0,lo | |
1144 movff compass_heading+1,hi | |
1145 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1146 bsf leftbind | |
1147 output_16 | |
1148 bcf leftbind | |
1149 STRCAT_PRINT "° " | |
1150 return | |
1151 | |
1152 global TFT_dive_compass_heading | |
1153 TFT_dive_compass_heading: | |
1154 rcall compass_heading_common | |
1155 WIN_STD dive_compass_head_column,dive_compass_head_row | |
1156 call TFT_standard_color | |
1157 lfsr FSR2,buffer | |
1158 movff compass_heading+0,lo | |
1159 movff compass_heading+1,hi | |
1160 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1161 bsf leftbind | |
1162 output_16 | |
1163 bcf leftbind | |
1164 STRCAT_PRINT "° " | |
1165 return | |
1166 | |
1167 | |
1168 compass_heading_common: | |
1169 extern compass | |
1170 extern compass_filter | |
1171 rcall TFT_get_compass | |
1172 rcall TFT_get_compass | |
1173 rcall TFT_get_compass | |
1174 rcall TFT_get_compass | |
1175 rcall TFT_get_compass | |
1176 rcall TFT_get_compass | |
1177 call compass ; Do compass corrections. | |
1178 banksel common | |
1179 return | |
1180 | |
1181 TFT_get_compass: | |
1182 call speed_normal | |
1183 call I2C_RX_compass ; Test Compass | |
1184 call I2C_RX_accelerometer ; Test Accelerometer | |
1185 call compass_filter ; Filter Raw compass + accel readings. | |
1186 banksel common | |
1187 return | |
1188 | |
1189 global TFT_debug_output | |
1190 TFT_debug_output: | |
1191 return | |
1192 WIN_TINY .107,.0 | |
1193 call TFT_standard_color | |
1194 lfsr FSR2,buffer | |
1195 movff CCPR1L,lo | |
1196 output_8 | |
1197 STRCAT_PRINT "" | |
1198 return | |
1199 | |
1200 global TFT_ftts | |
1201 TFT_ftts: | |
1202 movff char_I_extra_time,lo | |
1203 tstfsz lo | |
1204 bra $+4 | |
1205 return ; char_I_extra_time=0, return. | |
1206 incf warning_counter,F ; increase counter | |
1207 call TFT_warning_set_window ; Sets the row and column for the current warning | |
1208 tstfsz WREG ; Is there room for the warning? | |
1209 return ; No | |
1210 movff char_I_extra_time,lo | |
1211 STRCPY "@+" | |
1212 bsf leftbind | |
1213 output_8 | |
1214 PUTC ":" | |
1215 movff int_O_extra_ascenttime+0,lo | |
1216 movff int_O_extra_ascenttime+1,hi | |
1217 movf lo,W | |
1218 iorwf hi,W ; extra_ascenttime == 0 ? | |
1219 bz TFT_ftts2 ; No deco | |
1220 movf lo,W ; extra_ascenttime == 0xFFFF ? | |
1221 andwf hi,W | |
1222 incf WREG,w | |
1223 bz TFT_ftts2 ; Wait... | |
1224 output_16 | |
1225 bcf leftbind | |
1226 PUTC "'" | |
1227 movlw warning_length ; Divemode string length | |
1228 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1229 STRCAT_PRINT "" | |
1230 return | |
1231 | |
1232 TFT_ftts2: | |
1233 STRCAT "---" | |
1234 bcf leftbind | |
1235 movlw warning_length ; Divemode string length | |
1236 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1237 STRCAT_PRINT "" | |
1238 return | |
1239 | |
1240 | |
1241 ;============================================================================= | |
1242 | |
1243 global TFT_temp_surfmode | |
1244 TFT_temp_surfmode: | |
1245 WIN_SMALL surf_temp_column,surf_temp_row | |
1246 call TFT_standard_color | |
1247 | |
1248 SAFE_2BYTE_COPY temperature, lo | |
1249 | |
1250 TSTOSS opt_units ; 0=°C, 1=°F | |
1251 bra TFT_temp_surfmode_metric | |
1252 | |
1253 ;TFT_temp_surfmode_imperial: | |
1254 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1255 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
1256 lfsr FSR2,buffer ; Overwrite "-" | |
1257 bsf ignore_digit5 ; Full degrees only | |
1258 output_16 | |
1259 STRCAT_PRINT "" | |
1260 call TFT_divemask_color | |
1261 WIN_SMALL surf_temp_column+4*8,surf_temp_row | |
1262 STRCPY_PRINT "°F" | |
1263 return | |
1264 | |
1265 TFT_temp_surfmode_metric: | |
1266 lfsr FSR2,buffer | |
1267 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1268 movlw d'3' | |
1269 movwf ignore_digits | |
1270 bsf ignore_digit5 ; Full degrees only | |
1271 output_16 | |
1272 | |
1273 ; read-back the buffer+3 | |
1274 movff buffer+3,lo | |
1275 movlw " " ; Space | |
1276 cpfseq lo ; Was it a space (between +1°C and -1°C)? | |
1277 bra TFT_temp_surfmode1 ; No. | |
1278 movlw "0" ; Yes, print manual zero | |
1279 movff WREG,buffer+3 | |
1280 bra TFT_temp_surfmode2 | |
1281 TFT_temp_surfmode1: | |
1282 ; Test if output was negative (Flag set in TFT_convert_signed_16bit) | |
1283 btfss neg_flag ; Negative temperature? | |
1284 bra TFT_temp_surfmode3 ; No, continue | |
1285 ; Yes, negative temperature! | |
1286 movff buffer+3,buffer+2 ; remove two spaces manually | |
1287 movff buffer+4,buffer+3 | |
1288 TFT_temp_surfmode2: | |
1289 movlw 0x00 | |
1290 movff WREG,buffer+4 | |
1291 TFT_temp_surfmode3: | |
1292 STRCAT_PRINT "" | |
1293 call TFT_divemask_color | |
1294 WIN_SMALL surf_temp_column+4*8,surf_temp_row | |
1295 STRCPY_PRINT "°C" | |
1296 return | |
1297 | |
1298 ;============================================================================= | |
1299 global TFT_divemode_menu_cursor | |
1300 TFT_divemode_menu_cursor: | |
1301 WIN_BOX_BLACK divemode_menu_item1_row,divemode_menu_item3_row+.24,divemode_menu_item1_column-.8,divemode_menu_item1_column-.1 | |
1302 WIN_BOX_BLACK divemode_menu_item4_row,divemode_menu_item6_row+.24,divemode_menu_item4_column-.8,divemode_menu_item4_column-.1 | |
1303 call TFT_standard_color | |
1304 | |
1305 movlw divemode_menu_item1_column-.8 | |
1306 btfsc menupos,2 ; >3? | |
1307 movlw divemode_menu_item4_column-.8 ; Yes | |
1308 movff WREG,win_leftx2 | |
1309 | |
1310 movff menupos,lo ; Copy menu pos | |
1311 movlw divemode_menu_item6_row | |
1312 dcfsnz lo,F | |
1313 movlw divemode_menu_item1_row | |
1314 dcfsnz lo,F | |
1315 movlw divemode_menu_item2_row | |
1316 dcfsnz lo,F | |
1317 movlw divemode_menu_item3_row | |
1318 dcfsnz lo,F | |
1319 movlw divemode_menu_item4_row | |
1320 dcfsnz lo,F | |
1321 movlw divemode_menu_item5_row | |
1322 movff WREG,win_top | |
1323 movlw FT_SMALL | |
1324 movff WREG,win_font | |
1325 STRCPY_PRINT "\xb7" ; print cursor | |
1326 return | |
1327 | |
1328 global TFT_temp_divemode | |
1329 TFT_temp_divemode: | |
1330 btfsc divemode_menu ; Is the dive mode menu shown? | |
1331 return ; Yes, return | |
1332 btfsc blinking_better_gas ; blinking better Gas? | |
1333 return ; Yes, no update of temperature now | |
1334 ; temperature | |
1335 WIN_SMALL dive_temp_column,dive_temp_row | |
1336 call TFT_standard_color | |
1337 bsf leftbind | |
1338 | |
1339 SAFE_2BYTE_COPY temperature, lo | |
1340 TSTOSS opt_units ; 0=°C, 1=°F | |
1341 bra TFT_temp_divemode_metric | |
1342 | |
1343 ;TFT_temp_divemode_imperial: | |
1344 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1345 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
1346 lfsr FSR2,buffer ; Overwrite "-" (There won't be less then -18°C underwater...) | |
1347 bsf ignore_digit5 ; Full degrees only | |
1348 output_16 | |
1349 STRCAT_TEXT tLogTunitF | |
1350 TFT_temp_divemode_common: | |
1351 bcf leftbind | |
1352 movlw .4 ; limit to three chars | |
1353 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1354 STRCAT_PRINT "" | |
1355 return ; Done. | |
1356 | |
1357 TFT_temp_divemode_metric: | |
1358 lfsr FSR2,buffer | |
1359 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1360 movlw d'3' | |
1361 movwf ignore_digits | |
1362 bsf ignore_digit5 ; Full degrees only | |
1363 output_16 | |
1364 STRCAT_TEXT tLogTunitC | |
1365 bra TFT_temp_divemode_common ; Done. | |
1366 | |
1367 TFT_active_setpoint: ; Show setpoint | |
1368 WIN_STD active_gas_column,active_gas_row | |
1369 call TFT_standard_color | |
1370 btfsc is_bailout ; =1: Bailout | |
1371 bra TFT_active_setpoint_bail ; Show "Bailout" instead of Setpoint | |
1372 | |
1373 lfsr FSR2,buffer | |
1374 movff char_I_const_ppO2,lo | |
1375 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
1376 clrf hi | |
1377 bsf leftbind | |
1378 output_16dp d'3' | |
1379 bcf leftbind | |
1380 STRCAT_TEXT tbar | |
1381 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor | |
1382 bra $+4 | |
1383 PUTC "*" | |
1384 STRCAT_PRINT "" | |
1385 | |
1386 TFT_active_setpoint_diluent: | |
1387 call TFT_standard_color | |
1388 WIN_SMALL active_dil_column,active_dil_row | |
1389 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1390 movff char_I_He_ratio,hi ; hi now stores He in % | |
1391 rcall TFT_show_dil_divemode2 ; Show diluent (Non-Inverted in all cases) | |
1392 | |
1393 btfss better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
1394 return ; Done. | |
1395 btg blinking_better_gas ; Toggle blink bit... | |
1396 btfss blinking_better_gas ; blink now? | |
1397 return ; No, Done. | |
1398 | |
1399 movlw color_yellow ; Blink in yellow | |
1400 call TFT_set_color | |
1401 WIN_SMALL_INVERT active_dil_column,active_dil_row | |
1402 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1403 movff char_I_He_ratio,hi ; hi now stores He in % | |
1404 rcall TFT_show_dil_divemode2 ; Show gas | |
1405 WIN_INVERT .0 ; Init new Wordprocessor | |
1406 call TFT_standard_color | |
1407 return ; Done. | |
1408 | |
1409 TFT_show_dil_divemode2: | |
1410 lfsr FSR2,buffer | |
1411 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1412 STRCAT_PRINT "" | |
1413 return | |
1414 | |
1415 TFT_active_setpoint_bail: | |
1416 STRCPY_TEXT_PRINT tDiveBailout ; Bailout | |
1417 bra TFT_active_setpoint_diluent | |
1418 | |
1419 global TFT_active_gas_divemode | |
1420 TFT_active_gas_divemode: ; Display gas/Setpoint | |
1421 btfsc divemode_menu ; Is the dive mode menu shown? | |
1422 return ; Yes, return | |
1423 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
1424 return | |
1425 btfsc FLAG_ccr_mode ; in CCR mode | |
1426 bra TFT_active_setpoint ; Yes, show setpoint | |
1427 | |
1428 call TFT_standard_color | |
1429 WIN_STD active_gas_column,active_gas_row | |
1430 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1431 movff char_I_He_ratio,hi ; hi now stores He in % | |
1432 rcall TFT_active_gas_divemode2 ; Show gas (Non-Inverted in all cases) | |
1433 btfss better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
1434 return ; Done. | |
1435 | |
1436 btg blinking_better_gas ; Toggle blink bit... | |
1437 btfss blinking_better_gas ; blink now? | |
1438 return ; No, Done. | |
1439 movlw color_yellow ; Blink in yellow | |
1440 call TFT_set_color | |
1441 WIN_STD_INVERT active_gas_column,active_gas_row | |
1442 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1443 movff char_I_He_ratio,hi ; hi now stores He in % | |
1444 rcall TFT_active_gas_divemode2 ; Show gas (Non-Inverted in all cases) | |
1445 WIN_INVERT .0 ; Init new Wordprocessor | |
1446 call TFT_standard_color | |
1447 return ; Done. | |
1448 | |
1449 TFT_active_gas_divemode2: | |
1450 lfsr FSR2,buffer | |
1451 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1452 STRCAT_PRINT "" | |
1453 return | |
1454 | |
1455 global TFT_display_decotype_surface | |
1456 global TFT_display_decotype_surface1 ; Used from logbook! | |
1457 TFT_display_decotype_surface: | |
1458 WIN_STD surf_decotype_column,surf_decotype_row | |
1459 WIN_COLOR color_lightblue | |
1460 lfsr FSR2,buffer | |
1461 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea | |
1462 TFT_display_decotype_surface1: ; Used from logbook! | |
1463 tstfsz lo | |
1464 bra TFT_display_decotype_surface2 | |
1465 STRCAT_TEXT_PRINT tDvOC ; OC | |
1466 bra TFT_display_decotype_exit | |
1467 TFT_display_decotype_surface2: | |
1468 decfsz lo,F | |
1469 bra TFT_display_decotype_surface3 | |
1470 STRCAT_TEXT_PRINT tDvCC ; CC | |
1471 bra TFT_display_decotype_exit | |
1472 TFT_display_decotype_surface3: | |
1473 decfsz lo,F | |
1474 bra TFT_display_decotype_surface4 | |
1475 STRCAT_TEXT_PRINT tDvGauge ; Gauge | |
1476 bra TFT_display_decotype_exit | |
1477 TFT_display_decotype_surface4: | |
1478 STRCAT_TEXT_PRINT tDvApnea ; Apnea | |
1479 TFT_display_decotype_exit: | |
1480 call TFT_standard_color | |
1481 return | |
1482 ;============================================================================= | |
1483 | |
1484 global TFT_splist_surfmode ; Show Setpoint list | |
1485 extern gaslist_strcat_setpoint | |
1486 TFT_splist_surfmode: | |
1487 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1488 ;SP 1 | |
1489 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1490 lfsr FSR2,buffer | |
1491 clrf PRODL | |
1492 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1493 STRCAT_PRINT "" | |
1494 ;SP 2 | |
1495 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1496 lfsr FSR2,buffer | |
1497 movlw .1 | |
1498 movwf PRODL | |
1499 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1500 STRCAT_PRINT "" | |
1501 ;SP 3 | |
1502 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1503 lfsr FSR2,buffer | |
1504 movlw .2 | |
1505 movwf PRODL | |
1506 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1507 STRCAT_PRINT "" | |
1508 ;SP 4 | |
1509 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1510 lfsr FSR2,buffer | |
1511 movlw .3 | |
1512 movwf PRODL | |
1513 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1514 STRCAT_PRINT "" | |
1515 ;SP 5 | |
1516 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1517 lfsr FSR2,buffer | |
1518 movlw .4 | |
1519 movwf PRODL | |
1520 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1521 STRCAT_PRINT "" | |
1522 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1523 bcf leftbind | |
1524 return | |
1525 | |
1526 global TFT_gaslist_surfmode | |
1527 TFT_gaslist_surfmode: ; Displays Gas List | |
1528 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1529 extern gaslist_strcat_gas_mod | |
1530 ;Gas 1 | |
1531 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1532 lfsr FSR2,buffer | |
1533 movlw .0 | |
1534 movwf PRODL | |
1535 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1536 STRCAT_PRINT "" | |
1537 ;Gas 2 | |
1538 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1539 lfsr FSR2,buffer | |
1540 movlw .1 | |
1541 movwf PRODL | |
1542 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1543 STRCAT_PRINT "" | |
1544 ;Gas 3 | |
1545 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1546 lfsr FSR2,buffer | |
1547 movlw .2 | |
1548 movwf PRODL | |
1549 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1550 STRCAT_PRINT "" | |
1551 ;Gas 4 | |
1552 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1553 lfsr FSR2,buffer | |
1554 movlw .3 | |
1555 movwf PRODL | |
1556 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1557 STRCAT_PRINT "" | |
1558 ;Gas 5 | |
1559 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1560 lfsr FSR2,buffer | |
1561 movlw .4 | |
1562 movwf PRODL | |
1563 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1564 STRCAT_PRINT "" | |
1565 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1566 bcf leftbind | |
1567 return | |
1568 | |
1569 global TFT_dillist_surfmode | |
1570 TFT_dillist_surfmode: ; Displays Diluent List | |
1571 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1572 ;Dil 1 | |
1573 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1574 lfsr FSR2,buffer | |
1575 movlw .5 | |
1576 movwf PRODL | |
1577 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1578 STRCAT_PRINT "" | |
1579 ;Dil 2 | |
1580 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1581 lfsr FSR2,buffer | |
1582 movlw .6 | |
1583 movwf PRODL | |
1584 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1585 STRCAT_PRINT "" | |
1586 ;Dil 3 | |
1587 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1588 lfsr FSR2,buffer | |
1589 movlw .7 | |
1590 movwf PRODL | |
1591 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1592 STRCAT_PRINT "" | |
1593 ;Dil 4 | |
1594 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1595 lfsr FSR2,buffer | |
1596 movlw .8 | |
1597 movwf PRODL | |
1598 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1599 STRCAT_PRINT "" | |
1600 ;Dil 5 | |
1601 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1602 lfsr FSR2,buffer | |
1603 movlw .9 | |
1604 movwf PRODL | |
1605 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1606 STRCAT_PRINT "" | |
1607 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1608 bcf leftbind | |
1609 return | |
1610 | |
1611 global TFT_depth | |
1612 TFT_depth: | |
1613 SAFE_2BYTE_COPY rel_pressure, lo | |
1614 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
1615 | |
1616 TSTOSS opt_units ; 0=m, 1=ft | |
1617 bra TFT_depth_metric | |
1618 ;TFT_depth_imperial | |
1619 WIN_LARGE depth_feet_column,depth_feet_row | |
1620 lfsr FSR2,buffer | |
1621 TFT_color_code warn_depth ; Color-code the output | |
1622 | |
1623 clrf sub_a+1 ; Display 0ft if lower then 30cm | |
1624 movlw d'30' | |
1625 movwf sub_a+0 | |
1626 movff hi,sub_b+1 | |
1627 movff lo,sub_b+0 | |
1628 call subU16 ; sub_c = sub_a - sub_b | |
1629 btfss neg_flag ; Depth lower then 0.4m? | |
1630 bra depth_less_0.3mtr_feet ; Yes, Show 0ft manually | |
1631 | |
1632 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
1633 bsf leftbind | |
1634 output_16 ; feet in Big font | |
1635 bcf leftbind | |
1636 movlw .3 ; limit to three chars | |
1637 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1638 STRCAT_PRINT "" ; Display feet | |
1639 return | |
1640 | |
1641 depth_less_0.3mtr_feet: | |
1642 STRCAT_PRINT "0 " ; manual zero | |
1643 return | |
1644 | |
1645 TFT_depth_metric: | |
1646 WIN_LARGE depth_column,depth_row | |
1647 TFT_color_code warn_depth ; Color-code the output | |
1648 | |
1649 movlw .039 | |
1650 cpfslt hi | |
1651 bra depth_greater_99_84mtr | |
1652 | |
1653 btfsc depth_greater_100m ; Was depth>100m during last call | |
1654 call TFT_clear_depth ; Yes, clear depth area | |
1655 bcf depth_greater_100m ; Do this once only... | |
1656 | |
1657 lfsr FSR2,buffer | |
1658 movlw HIGH d'1000' | |
1659 movwf sub_a+1 | |
1660 movlw LOW d'1000' | |
1661 movwf sub_a+0 | |
1662 movff hi,sub_b+1 | |
1663 movff lo,sub_b+0 | |
1664 incf sub_b+0,F | |
1665 movlw d'0' | |
1666 addwfc sub_b+1,F ; Add 1mbar offset | |
1667 call sub16 ; sub_c = sub_a - sub_b | |
1668 movlw ' ' | |
1669 btfss neg_flag ; Depth lower then 10m? | |
1670 movwf POSTINC2 ; Yes, add extra space | |
1671 | |
1672 clrf sub_a+1 | |
1673 movlw d'99' | |
1674 movwf sub_a+0 | |
1675 movff hi,sub_b+1 | |
1676 movff lo,sub_b+0 | |
1677 call subU16 ; sub_c = sub_a - sub_b | |
1678 btfss neg_flag ; Depth lower then 1m? | |
1679 bra tft_depth2 ; Yes, display manual Zero | |
1680 | |
1681 bsf leftbind | |
1682 bsf ignore_digit4 | |
1683 output_16 ; Full meters in Big font | |
1684 bcf leftbind | |
1685 bra tft_depth3 | |
1686 | |
1687 tft_depth2: | |
1688 WIN_LARGE depth_column,depth_row | |
1689 STRCAT "0" | |
1690 | |
1691 tft_depth3: | |
1692 STRCAT_PRINT "" ; Display full meters | |
1693 | |
1694 ; .1m in MEDIUM font | |
1695 WIN_MEDIUM depth_dm_column,depth_dm_row | |
1696 TFT_color_code warn_depth ; Color-code the output | |
1697 | |
1698 SAFE_2BYTE_COPY rel_pressure, lo | |
1699 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
1700 | |
1701 lfsr FSR2,buffer | |
1702 PUTC "." | |
1703 movlw HIGH d'30' ; Display 0.0m if lower then 30cm | |
1704 movwf sub_a+1 | |
1705 movlw LOW d'30' | |
1706 movwf sub_a+0 | |
1707 movff hi,sub_b+1 | |
1708 movff lo,sub_b+0 | |
1709 call subU16 ; sub_c = sub_a - sub_b | |
1710 btfss neg_flag ; Depth lower then 0.3m? | |
1711 bra depth_less_0.3mtr ; Yes, Show ".0" manually | |
1712 | |
1713 movlw d'4' | |
1714 movwf ignore_digits | |
1715 bsf ignore_digit5 | |
1716 output_16dp d'0' | |
1717 STRCAT_PRINT "" ; Display decimeters | |
1718 WIN_FONT FT_SMALL | |
1719 return | |
1720 | |
1721 depth_less_0.3mtr: | |
1722 STRCAT_PRINT "0" ; Display 0.0m manually | |
1723 WIN_FONT FT_SMALL | |
1724 return | |
1725 | |
1726 depth_greater_99_84mtr: ; Display only in full meters | |
1727 btfss depth_greater_100m ; Is depth>100m already? | |
1728 rcall TFT_clear_depth ; No, clear depth area and set flag | |
1729 ; Depth is already in hi:lo | |
1730 ; Show depth in Full meters | |
1731 ; That means ignore figure 4 and 5 | |
1732 lfsr FSR2,buffer | |
1733 bsf ignore_digit4 | |
1734 bsf leftbind | |
1735 output_16 | |
1736 bcf leftbind | |
1737 STRCAT_PRINT "" ; Display full meters only | |
1738 WIN_FONT FT_SMALL | |
1739 return | |
1740 | |
1741 TFT_clear_depth: ; No, clear depth area and set flag | |
1742 WIN_BOX_BLACK depth_row, .77,.0, max_depth_column-.1 ;top, bottom, left, right | |
1743 bsf depth_greater_100m ; Set Flag | |
1744 return | |
1745 | |
1746 ;============================================================================= | |
1747 | |
1748 ; global TFT_user_image | |
1749 ;TFT_user_image: | |
1750 ; ;---- Display user image ------------------------------------------------- | |
1751 ; ; Compute address in external EEPROM | |
1752 ; movff opt_skin,WREG | |
1753 ; mullw 0x50 | |
1754 ; movff PRODL,ext_flash_address+1 | |
1755 ; movf PRODH,W | |
1756 ; iorlw 0x30 | |
1757 ; movwf ext_flash_address+2 | |
1758 ; | |
1759 ; ; First pixel at @+4: | |
1760 ; movlw 4 | |
1761 ; movwf ext_flash_address+0 | |
1762 ; | |
1763 ; ; Read first pixel | |
1764 ; call ext_flash_read_block_start | |
1765 ;; movff SSP2BUF,skin_color+1 ; TFT format: HIGH is first... | |
1766 ; movwf SSP2BUF ; Write to buffer to initiate new read | |
1767 ; btfss SSP2STAT, BF ; Next byte ready ? | |
1768 ; bra $-2 ; NO: wait... | |
1769 ;; movff SSP2BUF,skin_color+0 | |
1770 ; call ext_flash_read_block_stop | |
1771 ; | |
1772 ; ; Make a frame of the retrieved skin color. | |
1773 ; setf win_color1 | |
1774 ; setf win_color2 | |
1775 ; WIN_FRAME_COLOR16 user_image_upper-.1, user_image_upper+.100,user_image_left-.1, user_image_left+.50 | |
1776 ; | |
1777 ; WIN_LEFT user_image_left+.25 | |
1778 ; WIN_TOP user_image_upper+.50 | |
1779 ; | |
1780 ; ; Display skin icon | |
1781 ; clrf ext_flash_address+0 | |
1782 ; call TFT_write_flash_image_addr | |
1783 ; | |
1784 ; ;---- Print custom text string | |
1785 ; WIN_LEFT user_image_left+.50+.5 | |
1786 ; WIN_TOP user_image_upper+.0 | |
1787 ; | |
1788 ; ; ---- STRNCPY : String copy from RAM | |
1789 ; ; lfsr FSR0, opt_name ; Source | |
1790 ; lfsr FSR1, .13 ; Len max | |
1791 ; lfsr FSR2, buffer ; destination | |
1792 ;TFT_user_image_1: | |
1793 ; movf POSTINC0,W ; Get byte | |
1794 ; bz TFT_user_image_2 ; End if NULL | |
1795 ; movwf POSTINC2 ; NO: copy | |
1796 ; decfsz FSR1L ; Max len reached ? | |
1797 ; bra TFT_user_image_1 ; NO: loop | |
1798 ;TFT_user_image_2: | |
1799 ; clrf POSTINC2 ; Mark end of string | |
1800 ; | |
1801 ; goto aa_wordprocessor ; and print | |
1802 | |
1803 | |
1804 global TFT_custom_text | |
1805 TFT_custom_text: ; Show the custom text | |
1806 lfsr FSR0, opt_name ; Source | |
1807 WIN_SMALL surf_customtext_column,surf_customtext_row1 ; First row | |
1808 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1809 incfsz lo,F ; Was lo=255? | |
1810 return ; No, all done. | |
1811 lfsr FSR0, opt_name+.12 ; Source | |
1812 WIN_SMALL surf_customtext_column,surf_customtext_row2 ; Second row | |
1813 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1814 incfsz lo,F ; Was lo=255? | |
1815 return ; No, all done. | |
1816 lfsr FSR0, opt_name+.24 ; Source | |
1817 WIN_SMALL surf_customtext_column,surf_customtext_row3 ; Third row | |
1818 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1819 incfsz lo,F ; Was lo=255? | |
1820 return ; No, all done. | |
1821 lfsr FSR0, opt_name+.36 ; Source | |
1822 WIN_SMALL surf_customtext_column,surf_customtext_row4 ; Forth row | |
1823 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1824 incfsz lo,F ; Was lo=255? | |
1825 return ; No, all done. | |
1826 lfsr FSR0, opt_name+.48 ; Source | |
1827 WIN_SMALL surf_customtext_column,surf_customtext_row5 ; Fifth row | |
1828 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1829 return ; Done. | |
1830 | |
1831 TFT_custom_text_2: | |
1832 lfsr FSR2, buffer ; destination | |
1833 movlw .12 | |
1834 movwf lo ; length/line | |
1835 TFT_custom_text_3: | |
1836 movf POSTINC0,W ; Get byte | |
1837 bz TFT_custom_text_4 ; End if NULL | |
1838 movwf POSTINC2 ; NO: copy | |
1839 decfsz lo,F ; Max len reached ? | |
1840 bra TFT_custom_text_3 ; NO: loop | |
1841 setf lo ; lo=255 -> more to come | |
1842 TFT_custom_text_4: | |
1843 clrf POSTINC2 ; Mark end of string | |
1844 goto aa_wordprocessor ; print and return | |
1845 | |
1846 | |
1847 ;============================================================================= | |
1848 global TFT_update_surf_press | |
1849 TFT_update_surf_press: | |
1850 WIN_SMALL surf_press_column,surf_press_row | |
1851 call TFT_standard_color | |
1852 SAFE_2BYTE_COPY amb_pressure, lo | |
1853 lfsr FSR2,buffer | |
1854 movff lo,sub_a+0 | |
1855 movff hi,sub_a+1 | |
1856 movff last_surfpressure_30min+0,sub_b+0 | |
1857 movff last_surfpressure_30min+1,sub_b+1 | |
1858 call subU16 ; sub_c = sub_a - sub_b | |
1859 btfsc neg_flag ; Pressure lower? | |
1860 rcall update_surf_press2 ; Yes, test threshold | |
1861 | |
1862 tstfsz sub_c+1 ; >255mbar difference? | |
1863 bra update_surf_press_common; Yes, display! | |
1864 movlw d'10' ; 10mbar noise suppression | |
1865 subwf sub_c+0,W | |
1866 btfsc STATUS,C | |
1867 bra update_surf_press_common; Yes, display! | |
1868 SAFE_2BYTE_COPY last_surfpressure_30min, lo ; Overwrite with stable value... | |
1869 | |
1870 update_surf_press_common: | |
1871 output_16 | |
1872 ; Show only 4 figures | |
1873 movff buffer+1,buffer+0 | |
1874 movff buffer+2,buffer+1 | |
1875 movff buffer+3,buffer+2 | |
1876 movff buffer+4,buffer+3 | |
1877 movlw 0x00 | |
1878 movff WREG,buffer+4 | |
1879 STRCAT_PRINT "" | |
1880 call TFT_divemask_color | |
1881 WIN_SMALL surf_press_column+4*8,surf_press_row | |
1882 STRCPY_PRINT "mbar" | |
1883 return | |
1884 | |
1885 update_surf_press2: | |
1886 movff lo,sub_b+0 | |
1887 movff hi,sub_b+1 | |
1888 movff last_surfpressure_30min+0,sub_a+0 | |
1889 movff last_surfpressure_30min+1,sub_a+1 | |
1890 call subU16 ; sub_c = sub_a - sub_b | |
1891 return | |
1892 | |
1893 ;============================================================================= | |
1894 | |
1895 global TFT_update_batt_voltage | |
1896 TFT_update_batt_voltage: | |
1897 movff batt_percent,lo ; Get battery percent | |
1898 TFT_color_code warn_battery; Color-code battery percent | |
1899 WIN_TINY batt_percent_column,batt_percent_row | |
1900 lfsr FSR2,buffer | |
1901 bsf leftbind | |
1902 output_8 | |
1903 bcf leftbind | |
1904 STRCAT_PRINT "%" | |
1905 call TFT_standard_color | |
1906 WIN_TINY batt_voltage_column,batt_voltage_row | |
1907 lfsr FSR2,buffer | |
1908 movff batt_voltage+0,lo | |
1909 movff batt_voltage+1,hi | |
1910 bsf leftbind | |
1911 output_16dp .2 | |
1912 bcf leftbind | |
1913 PUTC 'V' | |
1914 movff buffer+5,buffer+3 | |
1915 movlw 0x00 | |
1916 movff WREG,buffer+4 ; Only "x.yV" | |
1917 STRCAT_PRINT "" | |
1918 return | |
1919 | |
1920 ;update_battery_debug: | |
1921 ; call TFT_standard_color | |
1922 ; WIN_TINY .70,.0 | |
1923 ; lfsr FSR2,buffer | |
1924 ; movff battery_gauge+5,xC+3 | |
1925 ; movff battery_gauge+4,xC+2 | |
1926 ; movff battery_gauge+3,xC+1 | |
1927 ; movff battery_gauge+2,xC+0 | |
1928 ; ; battery_gauge:6 is nAs | |
1929 ; ; devide through 65536 | |
1930 ; ; devide through 152 | |
1931 ; ; Result is 0.01Ah in xC+1:xC+0 | |
1932 ; movlw LOW .152 | |
1933 ; movwf xB+0 | |
1934 ; movlw HIGH .152 | |
1935 ; movwf xB+1 | |
1936 ; call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
1937 ; bsf leftbind | |
1938 ; movff xC+0,lo | |
1939 ; movff xC+1,hi | |
1940 ; output_16 | |
1941 ; STRCAT_PRINT "x.01Ah" | |
1942 ; WIN_FONT FT_SMALL | |
1943 ; bcf leftbind | |
1944 ; return | |
1945 | |
1946 ;============================================================================= | |
1947 | |
1948 global TFT_convert_signed_16bit | |
1949 TFT_convert_signed_16bit: | |
1950 bcf neg_flag ; Positive temperature | |
1951 btfss hi,7 ; Negative temperature ? | |
1952 return ; No, return | |
1953 ; Yes, negative temperature! | |
1954 bsf neg_flag ; Negative temperature | |
1955 PUTC '-' ; Display "-" | |
1956 comf hi ; Then, 16bit sign changes. | |
1957 negf lo | |
1958 btfsc STATUS,C | |
1959 incf hi | |
1960 return ; and return | |
1961 | |
1962 ;============================================================================= | |
1963 | |
1964 global TFT_convert_date | |
1965 TFT_convert_date: ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
1966 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD | |
1967 movwf EEDATA ; used as temp here | |
1968 tstfsz EEDATA | |
1969 bra TFT_convert_date1 | |
1970 ; EEDATA was 0 | |
1971 ; Use MMDDYY | |
1972 movff convert_value_temp+0,lo ;month | |
1973 bsf leftbind | |
1974 output_99x | |
1975 PUTC '.' | |
1976 movff convert_value_temp+1,lo ;day | |
1977 bra TFT_convert_date1_common ;year | |
1978 | |
1979 TFT_convert_date1: ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD) | |
1980 decfsz EEDATA,F | |
1981 bra TFT_convert_date2 ; EEDATA was 2 | |
1982 ; EEDATA was 1 | |
1983 ; Use DDMMYY | |
1984 movff convert_value_temp+1,lo ;day | |
1985 bsf leftbind | |
1986 output_99x | |
1987 PUTC '.' | |
1988 movff convert_value_temp+0,lo ;month | |
1989 | |
1990 TFT_convert_date1_common: | |
1991 bsf leftbind | |
1992 output_99x | |
1993 PUTC '.' | |
1994 movff convert_value_temp+2,lo ;year | |
1995 output_99x | |
1996 bcf leftbind | |
1997 return | |
1998 | |
1999 TFT_convert_date2: | |
2000 ; Use YYMMDD | |
2001 movff convert_value_temp+2,lo ;year | |
2002 bsf leftbind | |
2003 output_99x | |
2004 PUTC '.' | |
2005 movff convert_value_temp+0,lo ;month | |
2006 output_99x | |
2007 PUTC '.' | |
2008 movff convert_value_temp+1,lo ;day | |
2009 output_99x | |
2010 bcf leftbind | |
2011 return | |
2012 | |
2013 ;============================================================================= | |
2014 | |
2015 global TFT_convert_date_short | |
2016 TFT_convert_date_short: ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
2017 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD | |
2018 movwf EEDATA ; used as temp here | |
2019 tstfsz EEDATA | |
2020 bra TFT_convert_date_short1 | |
2021 ; EEDATA was 0 | |
2022 ; Use MMDDYY | |
2023 TFT_convert_date_short_common: | |
2024 movff convert_value_temp+0,lo ;month | |
2025 bsf leftbind | |
2026 output_99x | |
2027 PUTC '.' | |
2028 movff convert_value_temp+1,lo ;day | |
2029 output_99x | |
2030 bcf leftbind | |
2031 return | |
2032 | |
2033 TFT_convert_date_short1: | |
2034 decfsz EEDATA,F | |
2035 bra TFT_convert_date_short_common ; EEDATA was 2 -> Use YYMMDD | |
2036 ; EEDATA was 1 | |
2037 ; Use DDMMYY | |
2038 movff convert_value_temp+1,lo ;day | |
2039 bsf leftbind | |
2040 output_99x | |
2041 PUTC '.' | |
2042 movff convert_value_temp+0,lo ;month | |
2043 output_99x | |
2044 bcf leftbind | |
2045 return | |
2046 | |
2047 ;============================================================================= | |
2048 | |
2049 global TFT_date | |
2050 TFT_date: | |
2051 WIN_TINY surf_date_column,surf_date_row ; Init new Wordprocessor | |
2052 call TFT_standard_color | |
2053 lfsr FSR2,buffer | |
2054 movff month,convert_value_temp+0 | |
2055 movff day,convert_value_temp+1 | |
2056 movff year,convert_value_temp+2 | |
2057 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
2058 STRCAT_PRINT "" | |
2059 return | |
2060 | |
2061 ;============================================================================= | |
2062 | |
2063 global TFT_max_pressure | |
2064 TFT_max_pressure: | |
2065 btfsc FLAG_apnoe_mode ; different display in apnoe mode | |
2066 bra TFT_max_pressure_apnoe | |
2067 TFT_max_pressure2: | |
2068 SAFE_2BYTE_COPY max_pressure, lo | |
2069 TFT_max_pressure3: | |
2070 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2071 TSTOSS opt_units ; 0=m, 1=ft | |
2072 bra TFT_max_pressure2_metric | |
2073 ;TFT_max_pressure2_imperial | |
2074 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2075 WIN_MEDIUM max_depth_feet_column,max_depth_feet_row | |
2076 lfsr FSR2,buffer | |
2077 call TFT_standard_color | |
2078 output_16_3 | |
2079 STRCAT_PRINT "" | |
2080 return | |
2081 | |
2082 TFT_max_pressure2_metric: | |
2083 WIN_MEDIUM max_depth_column,max_depth_row | |
2084 lfsr FSR2,buffer | |
2085 call TFT_standard_color | |
2086 bsf ignore_digit4 ; no 0.1m | |
2087 output_16 | |
2088 STRCAT_PRINT "" | |
2089 return | |
2090 | |
2091 TFT_max_pressure_apnoe: | |
2092 btfss FLAG_active_descent ; Are we descending? | |
2093 bra TFT_max_pressure2 ; Yes, show normal max. | |
2094 SAFE_2BYTE_COPY apnoe_max_pressure, lo | |
2095 bra TFT_max_pressure3 ; Show apnoe_max_pressure as max. depth | |
2096 | |
2097 global TFT_display_apnoe_last_max | |
2098 TFT_display_apnoe_last_max: | |
2099 call TFT_divemask_color | |
2100 WIN_TINY last_max_apnoe_text_column,last_max_apnoe_text_row | |
2101 STRCPY_TEXT_PRINT tApnoeMax | |
2102 | |
2103 call TFT_standard_color | |
2104 SAFE_2BYTE_COPY max_pressure, lo | |
2105 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2106 TSTOSS opt_units ; 0=m, 1=ft | |
2107 bra TFT_display_apnoe_last_m_metric | |
2108 ;TFT_display_apnoe_last_max_imperial | |
2109 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2110 WIN_MEDIUM apnoe_last_max_depth_column,apnoe_last_max_depth_row | |
2111 lfsr FSR2,buffer | |
2112 output_16 | |
2113 STRCAT_PRINT "" | |
2114 return | |
2115 | |
2116 TFT_display_apnoe_last_m_metric: | |
2117 WIN_MEDIUM apnoe_last_max_depth_column,apnoe_last_max_depth_row | |
2118 lfsr FSR2,buffer | |
2119 bsf ignore_digit5 ; do not display 1cm depth | |
2120 output_16dp d'3' | |
2121 STRCAT_PRINT "" | |
2122 return | |
2123 | |
2124 ;============================================================================= | |
2125 global TFT_divemins | |
2126 TFT_divemins: | |
2127 movff divemins+0,lo | |
2128 movff divemins+1,hi | |
2129 | |
2130 btfsc no_more_divesecs ; Ignore seconds? | |
2131 bra TFT_divemins2 ; Show minutes only | |
2132 | |
2133 movlw .99 | |
2134 cpfsgt lo ; bigger then 99? | |
2135 bra TFT_divemins1 ; No show mins:secs | |
2136 ; Yes, remove second display for the rest of the dive and clear seconds | |
2137 bsf no_more_divesecs ; Set flag | |
2138 ; Clear rest of seconds | |
2139 WIN_BOX_BLACK divetime_row, warning1_row,divetime_column,.159 ;top, bottom, left, right | |
2140 bra TFT_divemins2 ; Show minutes only | |
2141 | |
2142 TFT_divemins1: | |
2143 WIN_MEDIUM divetime_column, divetime_row | |
2144 lfsr FSR2,buffer | |
2145 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2146 call TFT_standard_color | |
2147 STRCAT_PRINT "" ; Show minutes in large font | |
2148 | |
2149 WIN_SMALL divetime_secs_column, divetime_secs_row ; left position for two sec figures | |
2150 lfsr FSR2,buffer | |
2151 PUTC ':' | |
2152 bsf leftbind | |
2153 movff divesecs,lo | |
2154 output_99x | |
2155 bcf leftbind | |
2156 STRCAT_PRINT "" ; Show seconds in small font | |
2157 return | |
2158 | |
2159 TFT_divemins2: | |
2160 WIN_MEDIUM divetime_minsonly_column, divetime_row | |
2161 lfsr FSR2,buffer | |
2162 output_16 | |
2163 call TFT_standard_color | |
2164 STRCAT_PRINT "" ; Show minutes in large font | |
2165 return | |
2166 | |
2167 ;============================================================================= | |
2168 global TFT_display_apnoe_surface | |
2169 TFT_display_apnoe_surface: | |
2170 call TFT_divemask_color | |
2171 WIN_TINY surface_apnoe_text_column,surface_apnoe_text_row | |
2172 STRCPY_TEXT_PRINT tApnoeSurface | |
2173 | |
2174 call TFT_standard_color | |
2175 WIN_MEDIUM surface_time_apnoe_column, surface_time_apnoe_row | |
2176 movff apnoe_surface_mins,lo | |
2177 lfsr FSR2,buffer | |
2178 output_8 | |
2179 PUTC ':' | |
2180 movff apnoe_surface_secs,lo | |
2181 output_99x | |
2182 STRCAT_PRINT "" | |
2183 return | |
2184 | |
2185 global TFT_apnoe_clear_surface | |
2186 TFT_apnoe_clear_surface: | |
2187 ; Clear Surface timer.... | |
2188 WIN_BOX_BLACK surface_apnoe_text_row, .239, surface_apnoe_text_column, .159 ;top, bottom, left, right | |
2189 return | |
2190 | |
2191 global TFT_display_apnoe_descent | |
2192 TFT_display_apnoe_descent: ; Descent divetime | |
2193 movff apnoe_mins,lo | |
2194 clrf hi | |
2195 WIN_MEDIUM divetime_column, divetime_row | |
2196 lfsr FSR2,buffer | |
2197 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2198 call TFT_standard_color | |
2199 STRCAT_PRINT "" ; Show minutes in large font | |
2200 | |
2201 WIN_SMALL divetime_secs_column, divetime_secs_row ; left position for two sec figures | |
2202 lfsr FSR2,buffer | |
2203 PUTC ':' | |
2204 bsf leftbind | |
2205 movff apnoe_secs,lo | |
2206 output_99x | |
2207 bcf leftbind | |
2208 STRCAT_PRINT "" ; Show seconds in small font | |
2209 return | |
2210 | |
2211 ;============================================================================= | |
2212 ; Writes ostc3 #Serial and Firmware version in splash screen | |
2213 ; | |
2214 global TFT_serial | |
2215 TFT_serial: | |
2216 WIN_TINY .0,.239-.14 | |
2217 | |
2218 STRCPY "OSTC3 #" ; Won't translate that... | |
2219 rcall TFT_cat_serial | |
2220 | |
2221 STRCAT " v" | |
2222 rcall TFT_cat_firmware | |
2223 | |
2224 ifdef __DEBUG | |
2225 movlw color_grey ; Write header in blue when | |
2226 call TFT_set_color ; compiled in DEBUG mode... | |
2227 STRCAT_PRINT "DEBUG" | |
2228 call TFT_standard_color | |
2229 else | |
2230 call TFT_standard_color | |
2231 STRCAT_PRINT "" | |
2232 | |
2233 movlw softwareversion_beta ; =1: Beta, =0: Release | |
2234 decfsz WREG,F | |
2235 return ; Release version -> Return | |
2236 | |
2237 call TFT_warnings_color | |
2238 WIN_LEFT .160-4*9/2 ; Right pad. | |
2239 STRCPY_TEXT_PRINT tBeta | |
2240 call TFT_standard_color | |
2241 endif | |
2242 | |
2243 return | |
2244 | |
2245 | |
2246 | |
2247 ;============================================================================= | |
2248 ; For the Information menu: append firmware x.yy version. | |
2249 global info_menu_firmware | |
2250 extern tFirmware | |
2251 info_menu_firmware: | |
2252 lfsr FSR1,tFirmware | |
2253 call strcat_text | |
2254 TFT_cat_firmware: | |
2255 movlw softwareversion_x | |
2256 movwf lo | |
2257 bsf leftbind | |
2258 output_8 | |
2259 PUTC '.' | |
2260 movlw softwareversion_y | |
2261 movwf lo | |
2262 output_99x | |
2263 bcf leftbind | |
2264 return | |
2265 | |
2266 ;----------------------------------------------------------------------------- | |
2267 ; For the Information menu: append serial number ostc3#42. | |
2268 global info_menu_serial | |
2269 extern tSerial | |
2270 info_menu_serial: | |
2271 lfsr FSR1,tSerial | |
2272 call strcat_text | |
2273 TFT_cat_serial: | |
2274 clrf EEADRH | |
2275 clrf EEADR ; Get Serial number LOW | |
2276 call read_eeprom ; read byte | |
2277 movff EEDATA,lo | |
2278 incf EEADR,F ; Get Serial number HIGH | |
2279 call read_eeprom ; read byte | |
2280 movff EEDATA,hi | |
2281 | |
2282 bsf leftbind | |
2283 output_16 | |
2284 bcf leftbind | |
2285 return | |
2286 | |
2287 ;----------------------------------------------------------------------------- | |
2288 ; For the Information menu: Append total dives | |
2289 global info_menu_total_dives | |
2290 extern tTotalDives | |
2291 info_menu_total_dives: | |
2292 lfsr FSR1,tTotalDives | |
2293 call strcat_text | |
2294 TFT_cat_total_dives: | |
2295 read_int_eeprom .2 | |
2296 movff EEDATA,lo | |
2297 read_int_eeprom .3 | |
2298 movff EEDATA,hi | |
2299 bsf leftbind | |
2300 output_16 | |
2301 bcf leftbind | |
2302 return | |
2303 | |
2304 ;----------------------------------------------------------------------------- | |
2305 ; ppO2 menu | |
2306 global divesets_ppo2_max | |
2307 extern tPPO2Max | |
2308 extern tbar | |
2309 divesets_ppo2_max: | |
2310 lfsr FSR1,tPPO2Max | |
2311 call strcat_text | |
2312 movff opt_ppO2_max,lo | |
2313 movlw ppo2_warning_high | |
2314 divesets_ppo2_common: | |
2315 movwf up ; Save default value | |
2316 clrf hi | |
2317 bsf leftbind | |
2318 output_16dp d'3' | |
2319 bcf leftbind | |
2320 lfsr FSR1,tbar | |
2321 call strcat_text | |
2322 | |
2323 movf up,W ; Default value | |
2324 cpfseq lo ; Current value | |
2325 bra divesets_ppo2_common2 ; Not default, add * | |
2326 return ; Default, Done. | |
2327 divesets_ppo2_common2: | |
2328 PUTC "*" | |
2329 return ; Done. | |
2330 | |
2331 global divesets_ppo2_min | |
2332 extern tPPO2Min | |
2333 divesets_ppo2_min: | |
2334 lfsr FSR1,tPPO2Min | |
2335 call strcat_text | |
2336 movff opt_ppO2_min,lo | |
2337 movlw ppo2_warning_low | |
2338 bra divesets_ppo2_common | |
2339 | |
2340 ;============================================================================= | |
2341 | |
2342 global TFT_clear_warning_text | |
2343 TFT_clear_warning_text: | |
2344 btfss divemode ; in divemode? | |
2345 bra TFT_clear_warning_text2 ; No, setup for surface mode | |
2346 WIN_BOX_BLACK warning1_row, divemode_customview_row-3, warning1_column, warning_icon_column-3 ;top, bottom, left, right | |
2347 return | |
2348 TFT_clear_warning_text2: | |
2349 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ;top, bottom, left, right | |
2350 return | |
2351 | |
2352 global TFT_clear_warning_text_2nd_row | |
2353 TFT_clear_warning_text_2nd_row: | |
2354 btfss divemode ; in divemode? | |
2355 bra TFT_clear_warning_text_2nd_2 ; No, setup for surface mode | |
2356 WIN_BOX_BLACK warning2_row, divemode_customview_row-3, warning2_column, warning_icon_column-3 ;top, bottom, left, right | |
2357 return | |
2358 TFT_clear_warning_text_2nd_2: | |
2359 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ;top, bottom, left, right | |
2360 return | |
2361 | |
2362 global TFT_fillup_with_spaces | |
2363 TFT_fillup_with_spaces: ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2364 movwf lo ; save max. string length into lo | |
2365 movf FSR2L,W ; Get current string length | |
2366 subwf lo,F ; lo-WREG | |
2367 btfsc STATUS,N ; longer then #lo already? | |
2368 return ; Yes, done. | |
2369 tstfsz lo ; Zero? | |
2370 bra TFT_fillup_with_spaces2 ; No. | |
2371 return ; Yes, done. | |
2372 TFT_fillup_with_spaces2: | |
2373 PUTC " " ; Add one space | |
2374 decfsz lo,F ; All done? | |
2375 bra TFT_fillup_with_spaces2 ; No, loop | |
2376 return ; Done. | |
2377 | |
2378 global TFT_desaturation_time | |
2379 TFT_desaturation_time: | |
2380 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2381 tstfsz WREG ; Is there room for the warning? | |
2382 return ; No | |
2383 STRCPY "Desat:" | |
2384 movff desaturation_time+0,lo ; divide by 60... | |
2385 movff desaturation_time+1,hi | |
2386 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
2387 bsf leftbind | |
2388 movf lo,W | |
2389 movff hi,lo | |
2390 movwf hi ; exchange lo and hi... | |
2391 output_8 ; Hours | |
2392 PUTC ':' | |
2393 movff hi,lo ; Minutes | |
2394 output_99x | |
2395 bcf leftbind | |
2396 movlw surf_warning_length ; Only use surface string length | |
2397 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2398 STRCAT_PRINT "" | |
2399 return | |
2400 | |
2401 global TFT_nofly_time | |
2402 TFT_nofly_time: | |
2403 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2404 tstfsz WREG ; Is there room for the warning? | |
2405 return ; No | |
2406 STRCPY "NoFly:" | |
2407 movff nofly_time+0,lo ; divide by 60... | |
2408 movff nofly_time+1,hi | |
2409 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
2410 bsf leftbind | |
2411 movf lo,W | |
2412 movff hi,lo | |
2413 movwf hi ; exchange lo and hi... | |
2414 output_8 ; Hours | |
2415 PUTC ':' | |
2416 movff hi,lo ; Minutes | |
2417 output_99x | |
2418 bcf leftbind | |
2419 movlw surf_warning_length ; Only use surface string length | |
2420 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2421 STRCAT_PRINT "" | |
2422 return | |
2423 | |
2424 global TFT_warning_agf | |
2425 TFT_warning_agf: | |
2426 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2427 tstfsz WREG ; Is there room for the warning? | |
2428 return ; No | |
2429 call TFT_warnings_color | |
2430 STRCPY_TEXT tDiveaGF_active ; "aGF!" | |
2431 movlw warning_length ; Divemode string length | |
2432 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2433 STRCAT_PRINT "" | |
2434 call TFT_standard_color | |
2435 return | |
2436 | |
2437 global TFT_warning_gf | |
2438 TFT_warning_gf: ;GF | |
2439 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2440 tstfsz WREG ; Is there room for the warning? | |
2441 return ; No | |
2442 TFT_color_code warn_gf ; Color-code Output | |
2443 STRCPY "GF:" | |
2444 movff char_O_gradient_factor,lo ; gradient factor | |
2445 bsf leftbind | |
2446 output_8 | |
2447 PUTC "%" | |
2448 movlw warning_length ; Divemode string length | |
2449 btfss divemode ; In Divemode? | |
2450 movlw surf_warning_length ; No, use surface string length | |
2451 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2452 STRCAT_PRINT "" | |
2453 bcf leftbind | |
2454 call TFT_standard_color | |
2455 return | |
2456 | |
2457 TFT_warning_set_window: ; Sets the row and column for the current warning | |
2458 ; ignore warning (now)? | |
2459 decf warning_counter,W ; -1 | |
2460 bcf STATUS,C | |
2461 rrcf WREG,W ; (warning_counter-1)/2 | |
2462 cpfseq warning_page | |
2463 retlw .255 ; WREG <> 0 -> Warning window not defined | |
2464 | |
2465 call TFT_standard_color | |
2466 | |
2467 btfss divemode ; in divemode? | |
2468 bra TFT_warning_set_window3 ; No, setup for surface mode | |
2469 | |
2470 btfss warning_counter,0 ; Toggle with each warning | |
2471 bra TFT_warning_set_window2 | |
2472 WIN_SMALL warning1_column,warning1_row | |
2473 bcf second_row_warning ; =1: The second row contains a warning | |
2474 retlw .0 ; WREG=0 -> Warning window defined | |
2475 TFT_warning_set_window2: | |
2476 WIN_SMALL warning2_column,warning2_row | |
2477 bsf second_row_warning ; =1: The second row contains a warning | |
2478 retlw .0 ; WREG=0 -> Warning window defined | |
2479 | |
2480 TFT_warning_set_window3: | |
2481 btfss warning_counter,0 ; Toggle with each warning | |
2482 bra TFT_warning_set_window4 | |
2483 WIN_SMALL surf_warning1_column,surf_warning1_row | |
2484 bcf second_row_warning ; =1: The second row contains a warning | |
2485 retlw .0 ; WREG=0 -> Warning window defined | |
2486 TFT_warning_set_window4: | |
2487 WIN_SMALL surf_warning2_column,surf_warning2_row | |
2488 bsf second_row_warning ; =1: The second row contains a warning | |
2489 retlw .0 ; WREG=0 -> Warning window defined | |
2490 | |
2491 | |
2492 global TFT_update_batt_percent_divemode | |
2493 TFT_update_batt_percent_divemode: | |
2494 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2495 tstfsz WREG ; Is there room for the warning? | |
2496 return ; No | |
2497 movff batt_percent,lo ; Get battery percent | |
2498 TFT_color_code warn_battery; Color-code battery percent | |
2499 STRCPY "Batt:" | |
2500 bsf leftbind | |
2501 output_8 | |
2502 bcf leftbind | |
2503 PUTC "%" | |
2504 movlw warning_length ; Divemode string length | |
2505 btfss divemode ; In Divemode? | |
2506 movlw surf_warning_length ; No, use surface string length | |
2507 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2508 STRCAT_PRINT "" | |
2509 call TFT_standard_color | |
2510 return | |
2511 | |
2512 | |
2513 global TFT_gf_mask ; Setup Mask | |
2514 TFT_gf_mask: | |
2515 ; The mask | |
2516 call TFT_divemask_color | |
2517 WIN_TINY dive_gf_column1,dive_gf_text_row | |
2518 STRCPY_TEXT_PRINT tGFactors | |
2519 WIN_TINY dive_gf_column2,dive_gf_text_row | |
2520 STRCPY_TEXT_PRINT taGFactors | |
2521 WIN_TINY dive_gf_column3,dive_gf_text_row | |
2522 STRCPY_TEXT_PRINT tGFInfo | |
2523 | |
2524 ; Show GF (Static) | |
2525 call TFT_disabled_color | |
2526 btfss use_agf | |
2527 call TFT_standard_color | |
2528 | |
2529 WIN_STD dive_gf_column,dive_gf_row | |
2530 lfsr FSR2,buffer | |
2531 bsf leftbind | |
2532 movff opt_GF_low,lo | |
2533 output_8 | |
2534 PUTC "/" | |
2535 movff opt_GF_high,lo | |
2536 output_8 | |
2537 STRCAT_PRINT "" | |
2538 ; Show aGF (Static) | |
2539 call TFT_standard_color | |
2540 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | |
2541 bra TFT_gf_mask2 ; Show "---" instead | |
2542 | |
2543 btfss use_agf | |
2544 call TFT_disabled_color | |
2545 | |
2546 WIN_STD dive_agf_column,dive_agf_row | |
2547 lfsr FSR2,buffer | |
2548 movff opt_aGF_low,lo | |
2549 output_8 | |
2550 PUTC "/" | |
2551 movff opt_aGF_high,lo | |
2552 output_8 | |
2553 STRCAT_PRINT "" | |
2554 bcf leftbind | |
2555 call TFT_standard_color | |
2556 return | |
2557 | |
2558 TFT_gf_mask2: | |
2559 WIN_STD dive_agf_column+.10,dive_agf_row | |
2560 STRCPY_PRINT "---" | |
2561 bcf leftbind | |
2562 return | |
2563 | |
2564 global TFT_gf_info ; Show GF informations | |
2565 TFT_gf_info: | |
2566 ; Show current GF | |
2567 movff char_O_gradient_factor,lo ; gradient factor absolute (Non-GF model) | |
2568 movff char_I_deco_model,hi | |
2569 decfsz hi,F ; jump over next line if char_I_deco_model == 1 | |
2570 movff char_O_relative_gradient_GF,lo ; gradient factor relative (GF model) | |
2571 WIN_STD dive_currentgf_column,dive_currentgf_row | |
2572 lfsr FSR2,buffer | |
2573 output_8 | |
2574 STRCAT_PRINT "%" | |
2575 return | |
2576 | |
2577 global TFT_ead_end_tissues_clock_mask ; Setup Mask | |
2578 TFT_ead_end_tissues_clock_mask: | |
2579 ; The mask | |
2580 call TFT_divemask_color | |
2581 ; Put three columns at HUD positions | |
2582 WIN_TINY dive_custom_hud_column1,dive_custom_hud_row | |
2583 STRCPY_TEXT_PRINT tDiveClock | |
2584 WIN_TINY dive_custom_hud_column2,dive_custom_hud_row | |
2585 STRCPY_TEXT_PRINT tDiveEAD_END | |
2586 WIN_TINY dive_custom_hud_column3,dive_custom_hud_row | |
2587 STRCPY_TEXT_PRINT tDiveTissues | |
2588 call TFT_standard_color | |
2589 return | |
2590 | |
2591 global TFT_ead_end_tissues_clock ; Show EAD/END, Tissues and clock | |
2592 TFT_ead_end_tissues_clock: | |
2593 ; Update clock and date | |
2594 WIN_SMALL dive_clock_column,dive_clock_row | |
2595 call TFT_clock2 ; print clock | |
2596 ; WIN_SMALL dive_date_column,dive_date_row | |
2597 ; lfsr FSR2,buffer | |
2598 ; movff month,convert_value_temp+0 | |
2599 ; movff day,convert_value_temp+1 | |
2600 ; movff year,convert_value_temp+2 | |
2601 ; rcall TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
2602 ; STRCAT_PRINT "." | |
2603 | |
2604 ; Show END/EAD | |
2605 WIN_SMALL dive_ead_column,dive_ead_row | |
2606 STRCPY_TEXT tEAD ; EAD: | |
2607 movff char_O_EAD,lo | |
2608 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
2609 WIN_SMALL dive_end_column,dive_end_row | |
2610 STRCPY_TEXT tEND ; END: | |
2611 movff char_O_END,lo | |
2612 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
2613 | |
2614 ; Show tissue diagram | |
2615 call TFT_divemask_color | |
2616 WIN_TINY dive_tissue_N2_column,dive_tissue_N2_row | |
2617 STRCPY_TEXT_PRINT tN2 | |
2618 WIN_TINY dive_tissue_He_column,dive_tissue_He_row | |
2619 STRCPY_TEXT_PRINT tHe | |
2620 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
2621 movlb b'00000001' ; select ram bank 1 | |
2622 rcall DISP_tissue_saturation_graph ; Show char_O_tissue_N2_saturation and char_O_tissue_He_saturation | |
2623 return | |
2624 | |
2625 TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars | |
2626 bsf leftbind | |
2627 TSTOSS opt_units ; 0=Meters, 1=Feets | |
2628 bra TFT_end_ead_common_metric | |
2629 ;TFT_end_ead_common_imperial: | |
2630 ; With lo in m | |
2631 movf lo,W | |
2632 mullw .100 ; PRODL:PRODH = mbar/min | |
2633 movff PRODL,lo | |
2634 movff PRODH,hi | |
2635 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2636 output_16_3 | |
2637 STRCAT_TEXT tFeets | |
2638 clrf WREG | |
2639 movff WREG,buffer+.8 ; limit string length to 8 | |
2640 bra TFT_end_ead_common_exit | |
2641 TFT_end_ead_common_metric: | |
2642 output_8 | |
2643 STRCAT_TEXT tMeters | |
2644 TFT_end_ead_common_exit: | |
2645 bcf leftbind | |
2646 movlw .8 | |
2647 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2648 STRCAT_PRINT "" | |
2649 return | |
2650 | |
2651 global TFT_surface_tissues | |
2652 TFT_surface_tissues: ; Show Tissue diagram in surface mode | |
2653 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row | |
2654 STRCPY_TEXT_PRINT tN2 | |
2655 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row | |
2656 STRCPY_TEXT_PRINT tHe | |
2657 | |
2658 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
2659 movlb b'00000001' ; select ram bank 1 | |
2660 | |
2661 movlw color_deepblue | |
2662 call TFT_set_color ; Make this configurable? | |
2663 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.29,.29 | |
2664 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.37,.37 | |
2665 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.45,.45 | |
2666 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.53,.53 | |
2667 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.61,.61 | |
2668 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.69,.69 | |
2669 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.77,.77 | |
2670 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.85,.85 | |
2671 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right ; outer frame | |
2672 | |
2673 movlw .1 | |
2674 movff WREG,win_height ; row bottom (0-239) | |
2675 movlw surf_tissue_diagram_left+.4 ; Surface mode | |
2676 movff WREG,win_leftx2 ; column left (0-159) | |
2677 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-4 ; Width | |
2678 movff WREG,win_width | |
2679 | |
2680 ;---- Draw N2 Tissues | |
2681 lfsr FSR2, char_O_tissue_N2_saturation | |
2682 movlw d'16' | |
2683 movwf wait_temp ; 16 tissues | |
2684 clrf waitms_temp ; Row offset | |
2685 surf_tissue_saturation_graph_N2: | |
2686 movlw surf_tissue_diagram_top+.23 ; surface mode | |
2687 addwf waitms_temp,W | |
2688 movff WREG,win_top ; row top (0-239) | |
2689 rcall surf_tissue_saturation_loop ; Show one tissue | |
2690 decfsz wait_temp,F | |
2691 bra surf_tissue_saturation_graph_N2 | |
2692 | |
2693 ;---- Draw He Tissues ---------------------------------------------------- | |
2694 lfsr FSR2, char_O_tissue_He_saturation | |
2695 movlw d'16' | |
2696 movwf wait_temp ; 16 tissues | |
2697 clrf waitms_temp ; Row offset | |
2698 surf_tissue_saturation_graph_He: | |
2699 movlw surf_tissue_diagram_top+.23+.56 ; surface mode | |
2700 addwf waitms_temp,W | |
2701 movff WREG,win_top ; row top (0-239) | |
2702 rcall surf_tissue_saturation_loop ; Show one tissue | |
2703 decfsz wait_temp,F | |
2704 bra surf_tissue_saturation_graph_He | |
2705 return | |
2706 | |
2707 surf_tissue_saturation_loop: | |
2708 call TFT_standard_color | |
2709 movlw .2 ; row spacing | |
2710 addwf waitms_temp,F | |
2711 movf POSTINC2,W ; Get tissue load | |
2712 bcf STATUS,C | |
2713 rrcf WREG ; And divide by 2 | |
2714 movwf temp1 | |
2715 movlw .20 | |
2716 subwf temp1,F ; Subtract some offset | |
2717 movff win_width,WREG ; Max width. | |
2718 cpfslt temp1 ; skip if WREG < win_width | |
2719 movwf temp1 | |
2720 movff temp1,win_bargraph | |
2721 call TFT_box | |
2722 return | |
2723 | |
2724 ;============================================================================= | |
2725 ; Draw saturation graph, is surface mode or in dive mode. | |
2726 DISP_tissue_saturation_graph: | |
2727 ;---- Draw Frame | |
2728 WIN_FRAME_STD tissue_diagram_top, tissue_diagram_bottom, tissue_diagram_left, .159 ; outer frame | |
2729 | |
2730 movlw .1 | |
2731 movff WREG,win_height ; row bottom (0-239) | |
2732 movlw tissue_diagram_left+.3 ; divemode | |
2733 movff WREG,win_leftx2 ; column left (0-159) | |
2734 movlw .159-tissue_diagram_left-4 ; Width | |
2735 movff WREG,win_width | |
2736 | |
2737 ;---- Draw N2 Tissues | |
2738 lfsr FSR2, char_O_tissue_N2_saturation | |
2739 movlw d'16' | |
2740 movwf wait_temp ; 16 tissues | |
2741 clrf waitms_temp ; Row offset | |
2742 tissue_saturation_graph_N2: | |
2743 movlw tissue_diagram_top+3 ; divemode | |
2744 addwf waitms_temp,W | |
2745 movff WREG,win_top ; row top (0-239) | |
2746 rcall tissue_saturation_graph_loop ; Show one tissue | |
2747 decfsz wait_temp,F | |
2748 bra tissue_saturation_graph_N2 | |
2749 | |
2750 ;---- Draw He Tissues ---------------------------------------------------- | |
2751 lfsr FSR2, char_O_tissue_He_saturation | |
2752 movlw d'16' | |
2753 movwf wait_temp ; 16 tissues | |
2754 clrf waitms_temp ; Row offset | |
2755 tissue_saturation_graph_He: | |
2756 movlw tissue_diagram_top+3+.22 ; divemode | |
2757 addwf waitms_temp,W | |
2758 movff WREG,win_top ; row top (0-239) | |
2759 | |
2760 rcall tissue_saturation_graph_loop ; Show one tissue | |
2761 | |
2762 decfsz wait_temp,F | |
2763 bra tissue_saturation_graph_He | |
2764 return | |
2765 | |
2766 tissue_saturation_graph_loop: | |
2767 call TFT_standard_color | |
2768 incf waitms_temp,F | |
2769 movf POSTINC2,W | |
2770 bcf STATUS,C | |
2771 rrcf WREG | |
2772 bcf STATUS,C | |
2773 rrcf WREG ; And divide by 4 | |
2774 movwf temp1 | |
2775 movlw .12 | |
2776 subwf temp1,F ; Subtract some offset | |
2777 movff win_width,WREG ; Max width. | |
2778 cpfslt temp1 ; skip if WREG < win_width | |
2779 movwf temp1 | |
2780 movff temp1,win_bargraph | |
2781 call TFT_box | |
2782 return | |
2783 | |
2784 global TFT_display_cns | |
2785 TFT_display_cns: | |
2786 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2787 tstfsz WREG ; Is there room for the warning? | |
2788 return ; No | |
2789 TFT_color_code warn_cns ; Color-code CNS output | |
2790 STRCPY_TEXT tCNS2 ; CNS: | |
2791 movff int_O_CNS_fraction+0,lo | |
2792 movff int_O_CNS_fraction+1,hi | |
2793 bsf leftbind | |
2794 output_16_3 ;Displays only 0...999 | |
2795 bcf leftbind | |
2796 PUTC "%" | |
2797 movlw warning_length ; Divemode string length | |
2798 btfss divemode ; In Divemode? | |
2799 movlw surf_warning_length ; No, use surface string length | |
2800 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2801 STRCAT_PRINT "" | |
2802 call TFT_standard_color | |
2803 return | |
2804 | |
2805 global TFT_display_ppo2 | |
2806 TFT_display_ppo2: ; Show ppO2 (ppO2 stored in xC, in mbar!) | |
2807 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2808 tstfsz WREG ; Is there room for the warning? | |
2809 return ; No | |
2810 TFT_color_code warn_ppo2 ; Color-code output (ppO2 stored in xC) | |
2811 STRCPY "O2:" | |
2812 ; Check very high ppO2 manually | |
2813 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
2814 bra TFT_show_ppO2_3 ; Yes, display fixed Value! | |
2815 movff xC+0,lo | |
2816 movff xC+1,hi | |
2817 bsf ignore_digit4 | |
2818 output_16dp d'1' | |
2819 TFT_show_ppO2_2: | |
2820 movlw warning_length ; Divemode string length | |
2821 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2822 STRCAT_PRINT "" | |
2823 call TFT_standard_color | |
2824 return | |
2825 | |
2826 TFT_show_ppO2_3: | |
2827 STRCAT ">6.6" | |
2828 bra TFT_show_ppO2_2 | |
2829 | |
2830 | |
2831 global TFT_LogOffset_Logtitle | |
2832 TFT_LogOffset_Logtitle: | |
2833 STRCPY_TEXT tLogOffset | |
2834 PUTC ":" | |
2835 call do_logoffset_common_read ; Offset into lo:hi | |
2836 bsf leftbind | |
2837 output_16 | |
2838 bcf leftbind | |
2839 PUTC " " | |
2840 return ; No "_PRINT" here... | |
2841 | |
2842 | |
2843 global adjust_depth_with_salinity | |
2844 adjust_depth_with_salinity: ; computes salinity setting into lo:hi [mbar] | |
2845 btfsc simulatormode_active ; Do apply salinity in Simulatormode | |
2846 return | |
2847 | |
2848 movff opt_salinity,WREG ; 0-5% | |
2849 addlw d'100' ; 1.00kg/l | |
2850 movwf wait_temp | |
2851 | |
2852 movlw d'105' ; 105% ? | |
2853 cpfslt wait_temp ; Salinity higher limit | |
2854 return ; Out of limit, do not adjust lo:hi | |
2855 movlw d'99' ; 99% ? | |
2856 cpfsgt wait_temp ; Salinity lower limit | |
2857 return ; Out of limit, do not adjust lo:hi | |
2858 | |
2859 movff lo,xA+0 | |
2860 movff hi,xA+1 | |
2861 | |
2862 movlw d'102' ; 0,98bar/10m | |
2863 movwf xB+0 | |
2864 clrf xB+1 | |
2865 call mult16x16 ;xA*xB=xC (lo:hi * 100) | |
2866 movff wait_temp,xB+0 ; Salinity | |
2867 clrf xB+1 | |
2868 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
2869 movff xC+0,lo | |
2870 movff xC+1,hi ; restore lo and hi with updated value | |
2871 return | |
2872 | |
2873 global convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2874 convert_mbar_to_feet: ; convert value in lo:hi from mbar to feet | |
2875 movff lo,xA+0 | |
2876 movff hi,xA+1 | |
2877 | |
2878 movlw LOW d'328' ; 328feet/100m | |
2879 movwf xB+0 | |
2880 movlw HIGH d'328' | |
2881 movwf xB+1 | |
2882 | |
2883 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
2884 | |
2885 movlw d'50' ; round up | |
2886 addwf xC+0,F | |
2887 movlw 0 | |
2888 addwfc xC+1,F | |
2889 addwfc xC+2,F | |
2890 addwfc xC+3,F | |
2891 | |
2892 movlw LOW .10000 | |
2893 movwf xB+0 | |
2894 movlw HIGH .10000 | |
2895 movwf xB+1 | |
2896 | |
2897 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
2898 | |
2899 movff xC+0,lo | |
2900 movff xC+1,hi ; restore lo and hi with updated value | |
2901 return | |
2902 | |
2903 global convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
2904 convert_celsius_to_fahrenheit: ; convert value in lo:hi from celsius to fahrenheit | |
2905 ; Does it work with signed temperature? mH | |
2906 movff lo,xA+0 | |
2907 movff hi,xA+1 | |
2908 | |
2909 movlw d'18' ; 1C = 1.8F | |
2910 movwf xB+0 | |
2911 clrf xB+1 | |
2912 | |
2913 call mult16x16 ;xA*xB=xC (lo:hi * 18) | |
2914 | |
2915 movlw d'10' | |
2916 movwf xB+0 | |
2917 clrf xB+1 | |
2918 | |
2919 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
2920 | |
2921 movlw LOW d'320' ; 0C = 32F | |
2922 addwf xC+0,F | |
2923 movlw HIGH d'320' | |
2924 addwfc xC+1,F | |
2925 | |
2926 movff xC+0,lo | |
2927 movff xC+1,hi ; restore lo and hi with updated value | |
2928 return | |
2929 | |
2930 END |