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