Mercurial > public > hwos_code
annotate src/tft_outputs.asm @ 75:b808fa26a9a1
change log
author | heinrichsweikamp |
---|---|
date | Tue, 11 Feb 2014 13:02:11 +0100 |
parents | 7815bf21d353 |
children | a5ea132770db |
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 | |
2916 | |
0 | 2917 return |
2918 | |
2919 ;============================================================================= | |
2920 ; Writes ostc3 #Serial and Firmware version in splash screen | |
2921 ; | |
2922 global TFT_serial | |
2923 TFT_serial: | |
2924 WIN_TINY .0,.239-.14 | |
2925 | |
2926 STRCPY "OSTC3 #" ; Won't translate that... | |
2927 rcall TFT_cat_serial | |
2928 | |
2929 STRCAT " v" | |
2930 rcall TFT_cat_firmware | |
2931 | |
2932 ifdef __DEBUG | |
2933 movlw color_grey ; Write header in blue when | |
2934 call TFT_set_color ; compiled in DEBUG mode... | |
2935 STRCAT_PRINT "DEBUG" | |
2936 call TFT_standard_color | |
2937 else | |
2938 call TFT_standard_color | |
2939 STRCAT_PRINT "" | |
2940 | |
2941 movlw softwareversion_beta ; =1: Beta, =0: Release | |
2942 decfsz WREG,F | |
2943 return ; Release version -> Return | |
2944 | |
2945 call TFT_warnings_color | |
2946 WIN_LEFT .160-4*9/2 ; Right pad. | |
2947 STRCPY_TEXT_PRINT tBeta | |
2948 call TFT_standard_color | |
2949 endif | |
2950 | |
2951 return | |
2952 | |
2953 | |
2954 | |
2955 ;============================================================================= | |
2956 ; For the Information menu: append firmware x.yy version. | |
2957 global info_menu_firmware | |
2958 extern tFirmware | |
2959 info_menu_firmware: | |
2960 lfsr FSR1,tFirmware | |
2961 call strcat_text | |
2962 TFT_cat_firmware: | |
2963 movlw softwareversion_x | |
2964 movwf lo | |
2965 bsf leftbind | |
2966 output_8 | |
2967 PUTC '.' | |
2968 movlw softwareversion_y | |
2969 movwf lo | |
2970 output_99x | |
2971 bcf leftbind | |
2972 return | |
2973 | |
2974 ;----------------------------------------------------------------------------- | |
2975 ; For the Information menu: append serial number ostc3#42. | |
2976 global info_menu_serial | |
2977 extern tSerial | |
2978 info_menu_serial: | |
2979 lfsr FSR1,tSerial | |
2980 call strcat_text | |
2981 TFT_cat_serial: | |
2982 clrf EEADRH | |
2983 clrf EEADR ; Get Serial number LOW | |
2984 call read_eeprom ; read byte | |
2985 movff EEDATA,lo | |
2986 incf EEADR,F ; Get Serial number HIGH | |
2987 call read_eeprom ; read byte | |
2988 movff EEDATA,hi | |
2989 | |
2990 bsf leftbind | |
2991 output_16 | |
2992 bcf leftbind | |
2993 return | |
2994 | |
2995 ;----------------------------------------------------------------------------- | |
2996 ; For the Information menu: Append total dives | |
2997 global info_menu_total_dives | |
2998 extern tTotalDives | |
2999 info_menu_total_dives: | |
3000 lfsr FSR1,tTotalDives | |
3001 call strcat_text | |
3002 TFT_cat_total_dives: | |
3003 read_int_eeprom .2 | |
3004 movff EEDATA,lo | |
3005 read_int_eeprom .3 | |
3006 movff EEDATA,hi | |
3007 bsf leftbind | |
3008 output_16 | |
3009 bcf leftbind | |
3010 return | |
3011 | |
62 | 3012 ; For the Information menu: Append battery voltage |
3013 global info_menu_battery_volts | |
3014 extern tBatteryV | |
3015 info_menu_battery_volts: | |
3016 lfsr FSR1,tBatteryV | |
3017 call strcat_text | |
3018 movff batt_voltage+1,hi | |
3019 movff batt_voltage+0,lo | |
3020 bsf leftbind | |
3021 output_16dp .2 ; x.xxx | |
3022 bcf leftbind | |
3023 PUTC "V" | |
3024 return | |
3025 | |
0 | 3026 ;----------------------------------------------------------------------------- |
3027 ; ppO2 menu | |
3028 global divesets_ppo2_max | |
3029 extern tPPO2Max | |
3030 extern tbar | |
3031 divesets_ppo2_max: | |
3032 lfsr FSR1,tPPO2Max | |
3033 call strcat_text | |
3034 movff opt_ppO2_max,lo | |
3035 movlw ppo2_warning_high | |
3036 divesets_ppo2_common: | |
3037 movwf up ; Save default value | |
3038 clrf hi | |
3039 bsf leftbind | |
3040 output_16dp d'3' | |
3041 bcf leftbind | |
3042 lfsr FSR1,tbar | |
3043 call strcat_text | |
3044 | |
3045 movf up,W ; Default value | |
3046 cpfseq lo ; Current value | |
3047 bra divesets_ppo2_common2 ; Not default, add * | |
3048 return ; Default, Done. | |
3049 divesets_ppo2_common2: | |
3050 PUTC "*" | |
3051 return ; Done. | |
3052 | |
3053 global divesets_ppo2_min | |
3054 extern tPPO2Min | |
3055 divesets_ppo2_min: | |
3056 lfsr FSR1,tPPO2Min | |
3057 call strcat_text | |
3058 movff opt_ppO2_min,lo | |
3059 movlw ppo2_warning_low | |
3060 bra divesets_ppo2_common | |
3061 | |
3062 ;============================================================================= | |
3063 | |
3064 global TFT_clear_warning_text | |
3065 TFT_clear_warning_text: | |
3066 btfss divemode ; in divemode? | |
3067 bra TFT_clear_warning_text2 ; No, setup for surface mode | |
3068 WIN_BOX_BLACK warning1_row, divemode_customview_row-3, warning1_column, warning_icon_column-3 ;top, bottom, left, right | |
3069 return | |
3070 TFT_clear_warning_text2: | |
3071 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ;top, bottom, left, right | |
3072 return | |
3073 | |
3074 global TFT_clear_warning_text_2nd_row | |
3075 TFT_clear_warning_text_2nd_row: | |
3076 btfss divemode ; in divemode? | |
3077 bra TFT_clear_warning_text_2nd_2 ; No, setup for surface mode | |
3078 WIN_BOX_BLACK warning2_row, divemode_customview_row-3, warning2_column, warning_icon_column-3 ;top, bottom, left, right | |
3079 return | |
3080 TFT_clear_warning_text_2nd_2: | |
3081 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ;top, bottom, left, right | |
3082 return | |
3083 | |
3084 global TFT_fillup_with_spaces | |
3085 TFT_fillup_with_spaces: ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3086 movwf lo ; save max. string length into lo | |
3087 movf FSR2L,W ; Get current string length | |
3088 subwf lo,F ; lo-WREG | |
3089 btfsc STATUS,N ; longer then #lo already? | |
3090 return ; Yes, done. | |
3091 tstfsz lo ; Zero? | |
3092 bra TFT_fillup_with_spaces2 ; No. | |
3093 return ; Yes, done. | |
3094 TFT_fillup_with_spaces2: | |
3095 PUTC " " ; Add one space | |
3096 decfsz lo,F ; All done? | |
3097 bra TFT_fillup_with_spaces2 ; No, loop | |
3098 return ; Done. | |
3099 | |
3100 global TFT_desaturation_time | |
3101 TFT_desaturation_time: | |
3102 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3103 tstfsz WREG ; Is there room for the warning? | |
3104 return ; No | |
3105 STRCPY "Desat:" | |
3106 movff desaturation_time+0,lo ; divide by 60... | |
3107 movff desaturation_time+1,hi | |
3108 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
3109 bsf leftbind | |
3110 movf lo,W | |
3111 movff hi,lo | |
3112 movwf hi ; exchange lo and hi... | |
3113 output_8 ; Hours | |
3114 PUTC ':' | |
3115 movff hi,lo ; Minutes | |
3116 output_99x | |
3117 bcf leftbind | |
3118 movlw surf_warning_length ; Only use surface string length | |
3119 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
60 | 3120 movlw .0 |
3121 movff WREG,buffer+11 | |
0 | 3122 STRCAT_PRINT "" |
3123 return | |
3124 | |
3125 global TFT_nofly_time | |
3126 TFT_nofly_time: | |
3127 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3128 tstfsz WREG ; Is there room for the warning? | |
3129 return ; No | |
3130 STRCPY "NoFly:" | |
3131 movff nofly_time+0,lo ; divide by 60... | |
3132 movff nofly_time+1,hi | |
3133 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
3134 bsf leftbind | |
3135 movf lo,W | |
3136 movff hi,lo | |
3137 movwf hi ; exchange lo and hi... | |
3138 output_8 ; Hours | |
3139 PUTC ':' | |
3140 movff hi,lo ; Minutes | |
3141 output_99x | |
3142 bcf leftbind | |
3143 movlw surf_warning_length ; Only use surface string length | |
3144 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
60 | 3145 movlw .0 |
3146 movff WREG,buffer+11 | |
0 | 3147 STRCAT_PRINT "" |
3148 return | |
3149 | |
3150 global TFT_warning_agf | |
3151 TFT_warning_agf: | |
3152 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3153 tstfsz WREG ; Is there room for the warning? | |
3154 return ; No | |
3155 call TFT_warnings_color | |
3156 STRCPY_TEXT tDiveaGF_active ; "aGF!" | |
3157 movlw warning_length ; Divemode string length | |
3158 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3159 STRCAT_PRINT "" | |
3160 call TFT_standard_color | |
3161 return | |
3162 | |
3163 global TFT_warning_gf | |
3164 TFT_warning_gf: ;GF | |
3165 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3166 tstfsz WREG ; Is there room for the warning? | |
3167 return ; No | |
3168 TFT_color_code warn_gf ; Color-code Output | |
3169 STRCPY "GF:" | |
3170 movff char_O_gradient_factor,lo ; gradient factor | |
3171 bsf leftbind | |
3172 output_8 | |
3173 PUTC "%" | |
3174 movlw warning_length ; Divemode string length | |
3175 btfss divemode ; In Divemode? | |
3176 movlw surf_warning_length ; No, use surface string length | |
3177 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3178 STRCAT_PRINT "" | |
3179 bcf leftbind | |
3180 call TFT_standard_color | |
3181 return | |
3182 | |
3183 TFT_warning_set_window: ; Sets the row and column for the current warning | |
3184 ; ignore warning (now)? | |
3185 decf warning_counter,W ; -1 | |
3186 bcf STATUS,C | |
3187 rrcf WREG,W ; (warning_counter-1)/2 | |
3188 cpfseq warning_page | |
3189 retlw .255 ; WREG <> 0 -> Warning window not defined | |
3190 | |
3191 call TFT_standard_color | |
3192 | |
3193 btfss divemode ; in divemode? | |
3194 bra TFT_warning_set_window3 ; No, setup for surface mode | |
3195 | |
3196 btfss warning_counter,0 ; Toggle with each warning | |
3197 bra TFT_warning_set_window2 | |
3198 WIN_SMALL warning1_column,warning1_row | |
3199 bcf second_row_warning ; =1: The second row contains a warning | |
3200 retlw .0 ; WREG=0 -> Warning window defined | |
3201 TFT_warning_set_window2: | |
3202 WIN_SMALL warning2_column,warning2_row | |
3203 bsf second_row_warning ; =1: The second row contains a warning | |
3204 retlw .0 ; WREG=0 -> Warning window defined | |
3205 | |
3206 TFT_warning_set_window3: | |
3207 btfss warning_counter,0 ; Toggle with each warning | |
3208 bra TFT_warning_set_window4 | |
3209 WIN_SMALL surf_warning1_column,surf_warning1_row | |
3210 bcf second_row_warning ; =1: The second row contains a warning | |
3211 retlw .0 ; WREG=0 -> Warning window defined | |
3212 TFT_warning_set_window4: | |
3213 WIN_SMALL surf_warning2_column,surf_warning2_row | |
3214 bsf second_row_warning ; =1: The second row contains a warning | |
3215 retlw .0 ; WREG=0 -> Warning window defined | |
3216 | |
3217 | |
3218 global TFT_update_batt_percent_divemode | |
3219 TFT_update_batt_percent_divemode: | |
3220 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3221 tstfsz WREG ; Is there room for the warning? | |
3222 return ; No | |
3223 movff batt_percent,lo ; Get battery percent | |
3224 TFT_color_code warn_battery; Color-code battery percent | |
3225 STRCPY "Batt:" | |
3226 bsf leftbind | |
3227 output_8 | |
3228 bcf leftbind | |
3229 PUTC "%" | |
3230 movlw warning_length ; Divemode string length | |
3231 btfss divemode ; In Divemode? | |
3232 movlw surf_warning_length ; No, use surface string length | |
3233 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3234 STRCAT_PRINT "" | |
3235 call TFT_standard_color | |
3236 return | |
3237 | |
3238 | |
3239 global TFT_gf_mask ; Setup Mask | |
3240 TFT_gf_mask: | |
3241 ; The mask | |
3242 call TFT_divemask_color | |
3243 WIN_TINY dive_gf_column1,dive_gf_text_row | |
3244 STRCPY_TEXT_PRINT tGFactors | |
3245 WIN_TINY dive_gf_column2,dive_gf_text_row | |
3246 STRCPY_TEXT_PRINT taGFactors | |
3247 WIN_TINY dive_gf_column3,dive_gf_text_row | |
3248 STRCPY_TEXT_PRINT tGFInfo | |
3249 | |
3250 ; Show GF (Static) | |
3251 call TFT_disabled_color | |
3252 btfss use_agf | |
3253 call TFT_standard_color | |
3254 | |
3255 WIN_STD dive_gf_column,dive_gf_row | |
3256 lfsr FSR2,buffer | |
3257 bsf leftbind | |
3258 movff opt_GF_low,lo | |
3259 output_8 | |
3260 PUTC "/" | |
3261 movff opt_GF_high,lo | |
3262 output_8 | |
3263 STRCAT_PRINT "" | |
3264 ; Show aGF (Static) | |
3265 call TFT_standard_color | |
3266 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | |
3267 bra TFT_gf_mask2 ; Show "---" instead | |
3268 | |
3269 btfss use_agf | |
3270 call TFT_disabled_color | |
3271 | |
3272 WIN_STD dive_agf_column,dive_agf_row | |
3273 lfsr FSR2,buffer | |
3274 movff opt_aGF_low,lo | |
3275 output_8 | |
3276 PUTC "/" | |
3277 movff opt_aGF_high,lo | |
3278 output_8 | |
3279 STRCAT_PRINT "" | |
3280 bcf leftbind | |
3281 call TFT_standard_color | |
3282 return | |
3283 | |
3284 TFT_gf_mask2: | |
3285 WIN_STD dive_agf_column+.10,dive_agf_row | |
3286 STRCPY_PRINT "---" | |
3287 bcf leftbind | |
3288 return | |
3289 | |
3290 global TFT_gf_info ; Show GF informations | |
3291 TFT_gf_info: | |
3292 ; Show current GF | |
3293 movff char_O_gradient_factor,lo ; gradient factor absolute (Non-GF model) | |
3294 movff char_I_deco_model,hi | |
3295 decfsz hi,F ; jump over next line if char_I_deco_model == 1 | |
3296 movff char_O_relative_gradient_GF,lo ; gradient factor relative (GF model) | |
3297 WIN_STD dive_currentgf_column,dive_currentgf_row | |
3298 lfsr FSR2,buffer | |
3299 output_8 | |
3300 STRCAT_PRINT "%" | |
3301 return | |
3302 | |
3303 global TFT_ead_end_tissues_clock_mask ; Setup Mask | |
3304 TFT_ead_end_tissues_clock_mask: | |
3305 ; The mask | |
3306 call TFT_divemask_color | |
3307 ; Put three columns at HUD positions | |
3308 WIN_TINY dive_custom_hud_column1,dive_custom_hud_row | |
3309 STRCPY_TEXT_PRINT tDiveClock | |
3310 WIN_TINY dive_custom_hud_column2,dive_custom_hud_row | |
3311 STRCPY_TEXT_PRINT tDiveEAD_END | |
3312 WIN_TINY dive_custom_hud_column3,dive_custom_hud_row | |
3313 STRCPY_TEXT_PRINT tDiveTissues | |
3314 call TFT_standard_color | |
3315 return | |
3316 | |
3317 global TFT_ead_end_tissues_clock ; Show EAD/END, Tissues and clock | |
3318 TFT_ead_end_tissues_clock: | |
3319 ; Update clock and date | |
3320 WIN_SMALL dive_clock_column,dive_clock_row | |
3321 call TFT_clock2 ; print clock | |
3322 ; WIN_SMALL dive_date_column,dive_date_row | |
3323 ; lfsr FSR2,buffer | |
3324 ; movff month,convert_value_temp+0 | |
3325 ; movff day,convert_value_temp+1 | |
3326 ; movff year,convert_value_temp+2 | |
3327 ; rcall TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
3328 ; STRCAT_PRINT "." | |
3329 | |
3330 ; Show END/EAD | |
3331 WIN_SMALL dive_ead_column,dive_ead_row | |
3332 STRCPY_TEXT tEAD ; EAD: | |
3333 movff char_O_EAD,lo | |
3334 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
3335 WIN_SMALL dive_end_column,dive_end_row | |
3336 STRCPY_TEXT tEND ; END: | |
3337 movff char_O_END,lo | |
3338 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
3339 | |
3340 ; Show tissue diagram | |
3341 call TFT_divemask_color | |
3342 WIN_TINY dive_tissue_N2_column,dive_tissue_N2_row | |
3343 STRCPY_TEXT_PRINT tN2 | |
3344 WIN_TINY dive_tissue_He_column,dive_tissue_He_row | |
3345 STRCPY_TEXT_PRINT tHe | |
3346 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
3347 movlb b'00000001' ; select ram bank 1 | |
3348 rcall DISP_tissue_saturation_graph ; Show char_O_tissue_N2_saturation and char_O_tissue_He_saturation | |
3349 return | |
3350 | |
3351 TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars | |
3352 bsf leftbind | |
3353 TSTOSS opt_units ; 0=Meters, 1=Feets | |
3354 bra TFT_end_ead_common_metric | |
3355 ;TFT_end_ead_common_imperial: | |
3356 ; With lo in m | |
3357 movf lo,W | |
3358 mullw .100 ; PRODL:PRODH = mbar/min | |
3359 movff PRODL,lo | |
3360 movff PRODH,hi | |
3361 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
3362 output_16_3 | |
3363 STRCAT_TEXT tFeets | |
3364 clrf WREG | |
3365 movff WREG,buffer+.8 ; limit string length to 8 | |
3366 bra TFT_end_ead_common_exit | |
3367 TFT_end_ead_common_metric: | |
3368 output_8 | |
3369 STRCAT_TEXT tMeters | |
3370 TFT_end_ead_common_exit: | |
3371 bcf leftbind | |
3372 movlw .8 | |
3373 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3374 STRCAT_PRINT "" | |
3375 return | |
3376 | |
3377 global TFT_surface_tissues | |
3378 TFT_surface_tissues: ; Show Tissue diagram in surface mode | |
3379 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row | |
3380 STRCPY_TEXT_PRINT tN2 | |
3381 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row | |
3382 STRCPY_TEXT_PRINT tHe | |
3383 | |
3384 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
3385 movlb b'00000001' ; select ram bank 1 | |
3386 | |
3387 movlw color_deepblue | |
3388 call TFT_set_color ; Make this configurable? | |
3389 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.29,.29 | |
3390 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.37,.37 | |
3391 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.45,.45 | |
3392 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.53,.53 | |
3393 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.61,.61 | |
3394 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.69,.69 | |
3395 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.77,.77 | |
3396 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.85,.85 | |
3397 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right ; outer frame | |
3398 | |
3399 movlw .1 | |
3400 movff WREG,win_height ; row bottom (0-239) | |
3401 movlw surf_tissue_diagram_left+.4 ; Surface mode | |
3402 movff WREG,win_leftx2 ; column left (0-159) | |
3403 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-4 ; Width | |
3404 movff WREG,win_width | |
3405 | |
3406 ;---- Draw N2 Tissues | |
3407 lfsr FSR2, char_O_tissue_N2_saturation | |
3408 movlw d'16' | |
3409 movwf wait_temp ; 16 tissues | |
3410 clrf waitms_temp ; Row offset | |
3411 surf_tissue_saturation_graph_N2: | |
3412 movlw surf_tissue_diagram_top+.23 ; surface mode | |
3413 addwf waitms_temp,W | |
3414 movff WREG,win_top ; row top (0-239) | |
3415 rcall surf_tissue_saturation_loop ; Show one tissue | |
3416 decfsz wait_temp,F | |
3417 bra surf_tissue_saturation_graph_N2 | |
3418 | |
3419 ;---- Draw He Tissues ---------------------------------------------------- | |
3420 lfsr FSR2, char_O_tissue_He_saturation | |
3421 movlw d'16' | |
3422 movwf wait_temp ; 16 tissues | |
3423 clrf waitms_temp ; Row offset | |
3424 surf_tissue_saturation_graph_He: | |
3425 movlw surf_tissue_diagram_top+.23+.56 ; surface mode | |
3426 addwf waitms_temp,W | |
3427 movff WREG,win_top ; row top (0-239) | |
3428 rcall surf_tissue_saturation_loop ; Show one tissue | |
3429 decfsz wait_temp,F | |
3430 bra surf_tissue_saturation_graph_He | |
3431 return | |
3432 | |
3433 surf_tissue_saturation_loop: | |
3434 call TFT_standard_color | |
3435 movlw .2 ; row spacing | |
3436 addwf waitms_temp,F | |
3437 movf POSTINC2,W ; Get tissue load | |
3438 bcf STATUS,C | |
3439 rrcf WREG ; And divide by 2 | |
3440 movwf temp1 | |
3441 movlw .20 | |
3442 subwf temp1,F ; Subtract some offset | |
3443 movff win_width,WREG ; Max width. | |
3444 cpfslt temp1 ; skip if WREG < win_width | |
3445 movwf temp1 | |
3446 movff temp1,win_bargraph | |
3447 call TFT_box | |
3448 return | |
3449 | |
3450 ;============================================================================= | |
3451 ; Draw saturation graph, is surface mode or in dive mode. | |
3452 DISP_tissue_saturation_graph: | |
3453 ;---- Draw Frame | |
50 | 3454 call TFT_standard_color |
3455 WIN_FRAME_COLOR16 tissue_diagram_top, tissue_diagram_bottom, tissue_diagram_left, .159 ; outer frame | |
0 | 3456 |
3457 movlw .1 | |
3458 movff WREG,win_height ; row bottom (0-239) | |
3459 movlw tissue_diagram_left+.3 ; divemode | |
3460 movff WREG,win_leftx2 ; column left (0-159) | |
3461 movlw .159-tissue_diagram_left-4 ; Width | |
3462 movff WREG,win_width | |
3463 | |
3464 ;---- Draw N2 Tissues | |
3465 lfsr FSR2, char_O_tissue_N2_saturation | |
3466 movlw d'16' | |
3467 movwf wait_temp ; 16 tissues | |
3468 clrf waitms_temp ; Row offset | |
3469 tissue_saturation_graph_N2: | |
3470 movlw tissue_diagram_top+3 ; divemode | |
3471 addwf waitms_temp,W | |
3472 movff WREG,win_top ; row top (0-239) | |
3473 rcall tissue_saturation_graph_loop ; Show one tissue | |
3474 decfsz wait_temp,F | |
3475 bra tissue_saturation_graph_N2 | |
3476 | |
3477 ;---- Draw He Tissues ---------------------------------------------------- | |
3478 lfsr FSR2, char_O_tissue_He_saturation | |
3479 movlw d'16' | |
3480 movwf wait_temp ; 16 tissues | |
3481 clrf waitms_temp ; Row offset | |
3482 tissue_saturation_graph_He: | |
3483 movlw tissue_diagram_top+3+.22 ; divemode | |
3484 addwf waitms_temp,W | |
3485 movff WREG,win_top ; row top (0-239) | |
3486 | |
3487 rcall tissue_saturation_graph_loop ; Show one tissue | |
3488 | |
3489 decfsz wait_temp,F | |
3490 bra tissue_saturation_graph_He | |
3491 return | |
3492 | |
3493 tissue_saturation_graph_loop: | |
3494 call TFT_standard_color | |
3495 incf waitms_temp,F | |
3496 movf POSTINC2,W | |
3497 bcf STATUS,C | |
3498 rrcf WREG | |
3499 bcf STATUS,C | |
3500 rrcf WREG ; And divide by 4 | |
3501 movwf temp1 | |
3502 movlw .12 | |
3503 subwf temp1,F ; Subtract some offset | |
3504 movff win_width,WREG ; Max width. | |
3505 cpfslt temp1 ; skip if WREG < win_width | |
3506 movwf temp1 | |
3507 movff temp1,win_bargraph | |
3508 call TFT_box | |
3509 return | |
3510 | |
55 | 3511 |
0 | 3512 global TFT_display_cns |
3513 TFT_display_cns: | |
3514 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3515 tstfsz WREG ; Is there room for the warning? | |
3516 return ; No | |
3517 TFT_color_code warn_cns ; Color-code CNS output | |
3518 STRCPY_TEXT tCNS2 ; CNS: | |
3519 movff int_O_CNS_fraction+0,lo | |
3520 movff int_O_CNS_fraction+1,hi | |
3521 bsf leftbind | |
3522 output_16_3 ;Displays only 0...999 | |
3523 bcf leftbind | |
3524 PUTC "%" | |
3525 movlw warning_length ; Divemode string length | |
3526 btfss divemode ; In Divemode? | |
3527 movlw surf_warning_length ; No, use surface string length | |
3528 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3529 STRCAT_PRINT "" | |
3530 call TFT_standard_color | |
3531 return | |
3532 | |
3533 global TFT_display_ppo2 | |
3534 TFT_display_ppo2: ; Show ppO2 (ppO2 stored in xC, in mbar!) | |
3535 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3536 tstfsz WREG ; Is there room for the warning? | |
3537 return ; No | |
3538 TFT_color_code warn_ppo2 ; Color-code output (ppO2 stored in xC) | |
55 | 3539 STRCPY "ppO2:" |
0 | 3540 ; Check very high ppO2 manually |
3541 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
3542 bra TFT_show_ppO2_3 ; Yes, display fixed Value! | |
3543 movff xC+0,lo | |
3544 movff xC+1,hi | |
3545 bsf ignore_digit4 | |
3546 output_16dp d'1' | |
3547 TFT_show_ppO2_2: | |
3548 movlw warning_length ; Divemode string length | |
3549 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3550 STRCAT_PRINT "" | |
3551 call TFT_standard_color | |
3552 return | |
3553 | |
3554 TFT_show_ppO2_3: | |
3555 STRCAT ">6.6" | |
3556 bra TFT_show_ppO2_2 | |
3557 | |
3558 | |
3559 global TFT_LogOffset_Logtitle | |
3560 TFT_LogOffset_Logtitle: | |
3561 STRCPY_TEXT tLogOffset | |
3562 PUTC ":" | |
3563 call do_logoffset_common_read ; Offset into lo:hi | |
3564 bsf leftbind | |
3565 output_16 | |
3566 bcf leftbind | |
3567 PUTC " " | |
3568 return ; No "_PRINT" here... | |
3569 | |
3570 | |
3571 global adjust_depth_with_salinity | |
3572 adjust_depth_with_salinity: ; computes salinity setting into lo:hi [mbar] | |
3573 btfsc simulatormode_active ; Do apply salinity in Simulatormode | |
3574 return | |
3575 | |
3576 movff opt_salinity,WREG ; 0-5% | |
3577 addlw d'100' ; 1.00kg/l | |
3578 movwf wait_temp | |
3579 | |
3580 movlw d'105' ; 105% ? | |
3581 cpfslt wait_temp ; Salinity higher limit | |
3582 return ; Out of limit, do not adjust lo:hi | |
3583 movlw d'99' ; 99% ? | |
3584 cpfsgt wait_temp ; Salinity lower limit | |
3585 return ; Out of limit, do not adjust lo:hi | |
3586 | |
3587 movff lo,xA+0 | |
3588 movff hi,xA+1 | |
3589 | |
3590 movlw d'102' ; 0,98bar/10m | |
3591 movwf xB+0 | |
3592 clrf xB+1 | |
3593 call mult16x16 ;xA*xB=xC (lo:hi * 100) | |
3594 movff wait_temp,xB+0 ; Salinity | |
3595 clrf xB+1 | |
3596 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3597 movff xC+0,lo | |
3598 movff xC+1,hi ; restore lo and hi with updated value | |
3599 return | |
3600 | |
3601 global convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
3602 convert_mbar_to_feet: ; convert value in lo:hi from mbar to feet | |
3603 movff lo,xA+0 | |
3604 movff hi,xA+1 | |
3605 | |
3606 movlw LOW d'328' ; 328feet/100m | |
3607 movwf xB+0 | |
3608 movlw HIGH d'328' | |
3609 movwf xB+1 | |
3610 | |
3611 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
3612 | |
3613 movlw d'50' ; round up | |
3614 addwf xC+0,F | |
3615 movlw 0 | |
3616 addwfc xC+1,F | |
3617 addwfc xC+2,F | |
3618 addwfc xC+3,F | |
3619 | |
3620 movlw LOW .10000 | |
3621 movwf xB+0 | |
3622 movlw HIGH .10000 | |
3623 movwf xB+1 | |
3624 | |
3625 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3626 | |
3627 movff xC+0,lo | |
3628 movff xC+1,hi ; restore lo and hi with updated value | |
3629 return | |
3630 | |
3631 global convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
3632 convert_celsius_to_fahrenheit: ; convert value in lo:hi from celsius to fahrenheit | |
3633 ; Does it work with signed temperature? mH | |
3634 movff lo,xA+0 | |
3635 movff hi,xA+1 | |
3636 | |
3637 movlw d'18' ; 1C = 1.8F | |
3638 movwf xB+0 | |
3639 clrf xB+1 | |
3640 | |
3641 call mult16x16 ;xA*xB=xC (lo:hi * 18) | |
3642 | |
3643 movlw d'10' | |
3644 movwf xB+0 | |
3645 clrf xB+1 | |
3646 | |
3647 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3648 | |
3649 movlw LOW d'320' ; 0C = 32F | |
3650 addwf xC+0,F | |
3651 movlw HIGH d'320' | |
3652 addwfc xC+1,F | |
3653 | |
3654 movff xC+0,lo | |
3655 movff xC+1,hi ; restore lo and hi with updated value | |
3656 return | |
3657 | |
3658 END |