Mercurial > public > hwos_code
annotate src/tft_outputs.asm @ 59:3e65636a8462
Backlight level in eco mode
author | heinrichsweikamp |
---|---|
date | Sun, 01 Dec 2013 09:08:31 +0100 |
parents | 448ba265fdae |
children | 1464cd73d184 |
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 | |
41 | 1326 global TFT_surface_decosettings ; Show all deco settings |
1327 TFT_surface_decosettings: | |
1328 ; Deco Mode | |
1329 call TFT_standard_color | |
1330 movff char_I_deco_model,WREG | |
1331 iorwf WREG | |
1332 bnz TFT_surface_decosettings1 | |
1333 | |
1334 ; Display ZH-L16 sat/desat model. | |
1335 TEXT_SMALL surf_gaslist_column,surf_gaslist_row, tZHL16 | |
1336 WIN_TOP surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1337 lfsr FSR2,buffer | |
1338 movff char_I_desaturation_multiplier,lo | |
1339 bsf leftbind | |
1340 output_8 | |
1341 STRCAT "%/" | |
1342 movff char_I_saturation_multiplier,lo | |
1343 output_8 | |
1344 STRCAT_PRINT "%" | |
1345 bra TFT_surface_decosettings2 | |
1346 | |
1347 ; Display ZH-L16-GF low/high model. | |
1348 TFT_surface_decosettings1: | |
1349 TEXT_SMALL surf_gaslist_column,surf_gaslist_row, tZHL16GF | |
1350 WIN_TOP surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1351 lfsr FSR2,buffer | |
42 | 1352 STRCPY_TEXT tGF ; GF: |
41 | 1353 movff char_I_GF_Low_percentage,lo |
1354 output_99x | |
42 | 1355 STRCAT "/" |
41 | 1356 movff char_I_GF_High_percentage,lo |
1357 output_99x | |
42 | 1358 STRCAT_PRINT "" |
41 | 1359 ;bra TFT_surface_decosettings2 |
1360 TFT_surface_decosettings2: | |
1361 ; FTTS | |
1362 WIN_TOP surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1363 lfsr FSR2,buffer | |
1364 STRCPY_TEXT tFTTSMenu | |
1365 movff char_I_extra_time,lo | |
1366 bsf leftbind | |
1367 output_8 | |
1368 STRCAT_TEXT_PRINT tMinutes | |
1369 | |
1370 ; Last Stop | |
1371 WIN_TOP surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1372 lfsr FSR2,buffer | |
1373 STRCPY_TEXT tLastDecostop | |
1374 movff char_I_depth_last_deco,lo | |
1375 output_8 | |
1376 STRCAT_TEXT_PRINT tMeters | |
1377 | |
1378 ; Salinity | |
1379 WIN_TOP surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1380 lfsr FSR2,buffer | |
1381 STRCPY_TEXT tDvSalinity | |
1382 movff opt_salinity,lo | |
1383 output_8 | |
1384 bcf leftbind | |
1385 STRCAT_TEXT_PRINT tPercent | |
1386 return ; Done. | |
0 | 1387 |
1388 global TFT_surface_compass_mask | |
1389 TFT_surface_compass_mask: | |
1390 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row | |
1391 call TFT_standard_color | |
1392 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1393 return | |
1394 | |
1395 global TFT_dive_compass_mask | |
1396 TFT_dive_compass_mask: | |
1397 WIN_TINY dive_compass_mask_column,dive_compass_mask_row | |
1398 call TFT_divemask_color | |
1399 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1400 return | |
1401 | |
1402 | |
1403 global TFT_surface_compass_heading | |
1404 TFT_surface_compass_heading: | |
1405 rcall compass_heading_common | |
16
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1406 btfsc compass_fast_mode ; In fast mode? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1407 bra TFT_surface_compass_heading2 ; Yes |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1408 ; No, update 1/second max. |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1409 movff sensor_state_counter,lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1410 movlw .6 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1411 cpfsgt lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1412 return |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1413 TFT_surface_compass_heading2: |
0 | 1414 WIN_STD surf_compass_head_column,surf_compass_head_row |
1415 call TFT_standard_color | |
1416 lfsr FSR2,buffer | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1417 ; movff compass_heading+0,lo |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1418 ; movff compass_heading+1,hi |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1419 ; 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
|
1420 ; output_8 |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1421 ; PUTC " " |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1422 ; movff hi,lo |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1423 ; output_8 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1424 ; PUTC " " |
0 | 1425 movff compass_heading+0,lo |
1426 movff compass_heading+1,hi | |
1427 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1428 bsf leftbind | |
1429 output_16 | |
1430 bcf leftbind | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1431 STRCAT "° " |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1432 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1433 STRCAT_PRINT " " |
0 | 1434 return |
1435 | |
1436 global TFT_dive_compass_heading | |
1437 TFT_dive_compass_heading: | |
1438 rcall compass_heading_common | |
16
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1439 btfsc compass_fast_mode ; In fast mode? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1440 bra TFT_dive_compass_heading2 ; Yes |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1441 ; No, update 1/second max. |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1442 movff sensor_state_counter,lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1443 movlw .6 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1444 cpfsgt lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1445 return |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1446 TFT_dive_compass_heading2: |
0 | 1447 WIN_STD dive_compass_head_column,dive_compass_head_row |
1448 call TFT_standard_color | |
1449 lfsr FSR2,buffer | |
1450 movff compass_heading+0,lo | |
1451 movff compass_heading+1,hi | |
1452 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1453 bsf leftbind | |
1454 output_16 | |
1455 bcf leftbind | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1456 STRCAT "° " |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1457 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1458 STRCAT_PRINT " " |
0 | 1459 return |
1460 | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1461 tft_compass_cardinal: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1462 btfsc hi,0 ; Heading >255°? |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1463 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
|
1464 ; 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
|
1465 movlw .23 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1466 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1467 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1468 bra tft_compass_cardinal_N |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1469 movlw .68 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1470 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1471 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1472 bra tft_compass_cardinal_NE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1473 movlw .113 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1474 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1475 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1476 bra tft_compass_cardinal_E |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1477 movlw .158 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1478 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1479 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1480 bra tft_compass_cardinal_SE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1481 movlw .203 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1482 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1483 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1484 bra tft_compass_cardinal_S |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1485 movlw .248 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1486 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1487 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1488 bra tft_compass_cardinal_SW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1489 bra tft_compass_cardinal_W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1490 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1491 tft_compass_cardinal2: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1492 movlw .37 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1493 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1494 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1495 bra tft_compass_cardinal_W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1496 movlw .82 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1497 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1498 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1499 bra tft_compass_cardinal_NW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1500 bra tft_compass_cardinal_N |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1501 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1502 tft_compass_cardinal_N: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1503 STRCAT_TEXT tN |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1504 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1505 tft_compass_cardinal_NE: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1506 STRCAT_TEXT tNE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1507 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1508 tft_compass_cardinal_E: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1509 STRCAT_TEXT tE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1510 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1511 tft_compass_cardinal_SE: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1512 STRCAT_TEXT tSE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1513 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1514 tft_compass_cardinal_S: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1515 STRCAT_TEXT tS |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1516 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1517 tft_compass_cardinal_SW: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1518 STRCAT_TEXT tSW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1519 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1520 tft_compass_cardinal_W: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1521 STRCAT_TEXT tW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1522 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1523 tft_compass_cardinal_NW: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1524 STRCAT_TEXT tNW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1525 return |
0 | 1526 |
1527 compass_heading_common: | |
1528 extern compass | |
1529 extern compass_filter | |
1530 rcall TFT_get_compass | |
1531 rcall TFT_get_compass | |
1532 rcall TFT_get_compass | |
1533 rcall TFT_get_compass | |
1534 rcall TFT_get_compass | |
1535 rcall TFT_get_compass | |
1536 call compass ; Do compass corrections. | |
1537 banksel common | |
16
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1538 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1539 ; More then compass_fast_treshold? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1540 movff compass_heading_old+0,sub_a+0 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1541 movff compass_heading_old+1,sub_a+1 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1542 movff compass_heading+0,sub_b+0 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1543 movff compass_heading+1,sub_b+1 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1544 call sub16 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1545 movff compass_heading+0,compass_heading_old+0 ; copy new "old" |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1546 movff compass_heading+1,compass_heading_old+1 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1547 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1548 bcf compass_fast_mode |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1549 movlw compass_fast_treshold |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1550 cpfslt sub_c+0 ; > compass_fast_treshold? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1551 bsf compass_fast_mode ; Yes! |
0 | 1552 return |
1553 | |
1554 TFT_get_compass: | |
1555 call speed_normal | |
1556 call I2C_RX_compass ; Test Compass | |
1557 call I2C_RX_accelerometer ; Test Accelerometer | |
1558 call compass_filter ; Filter Raw compass + accel readings. | |
1559 banksel common | |
1560 return | |
1561 | |
1562 global TFT_debug_output | |
1563 TFT_debug_output: | |
1564 return | |
1565 WIN_TINY .107,.0 | |
1566 call TFT_standard_color | |
1567 lfsr FSR2,buffer | |
1568 movff CCPR1L,lo | |
1569 output_8 | |
1570 STRCAT_PRINT "" | |
1571 return | |
1572 | |
55 | 1573 global TFT_divetimeout ; Show timeout counter |
1574 TFT_divetimeout: | |
1575 call TFT_warning_set_window ; Sets the row and column for the current warning | |
1576 tstfsz WREG ; Is there room for the warning? | |
1577 return ; No | |
1578 | |
1579 call TFT_standard_color | |
1580 STRCPY 0x94 ; "End of dive" icon | |
1581 movlw LOW divemode_timeout | |
1582 movwf sub_a+0 | |
1583 movlw HIGH divemode_timeout | |
1584 movwf sub_a+1 | |
1585 movff timeout_counter,sub_b+0 | |
1586 movff timeout_counter2,sub_b+1 | |
1587 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | |
1588 movff sub_c+0, lo | |
1589 movff sub_c+1, hi | |
1590 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
1591 movf hi,W | |
1592 movff lo,hi | |
1593 movwf lo ; exchange lo and hi | |
1594 output_99x | |
1595 PUTC ':' | |
1596 movff hi,lo | |
1597 output_99x | |
1598 movlw warning_length ; Divemode string length | |
1599 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1600 STRCAT_PRINT "" | |
1601 return | |
1602 | |
0 | 1603 global TFT_ftts |
1604 TFT_ftts: | |
1605 movff char_I_extra_time,lo | |
1606 tstfsz lo | |
1607 bra $+4 | |
1608 return ; char_I_extra_time=0, return. | |
1609 incf warning_counter,F ; increase counter | |
1610 call TFT_warning_set_window ; Sets the row and column for the current warning | |
1611 tstfsz WREG ; Is there room for the warning? | |
1612 return ; No | |
1613 movff char_I_extra_time,lo | |
1614 STRCPY "@+" | |
1615 bsf leftbind | |
1616 output_8 | |
1617 PUTC ":" | |
1618 movff int_O_extra_ascenttime+0,lo | |
1619 movff int_O_extra_ascenttime+1,hi | |
1620 movf lo,W | |
1621 iorwf hi,W ; extra_ascenttime == 0 ? | |
1622 bz TFT_ftts2 ; No deco | |
1623 movf lo,W ; extra_ascenttime == 0xFFFF ? | |
1624 andwf hi,W | |
1625 incf WREG,w | |
1626 bz TFT_ftts2 ; Wait... | |
1627 output_16 | |
1628 bcf leftbind | |
1629 PUTC "'" | |
1630 movlw warning_length ; Divemode string length | |
1631 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1632 STRCAT_PRINT "" | |
1633 return | |
1634 | |
1635 TFT_ftts2: | |
1636 STRCAT "---" | |
1637 bcf leftbind | |
1638 movlw warning_length ; Divemode string length | |
1639 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1640 STRCAT_PRINT "" | |
1641 return | |
1642 | |
1643 | |
1644 ;============================================================================= | |
1645 | |
1646 global TFT_temp_surfmode | |
1647 TFT_temp_surfmode: | |
1648 WIN_SMALL surf_temp_column,surf_temp_row | |
1649 call TFT_standard_color | |
1650 | |
1651 SAFE_2BYTE_COPY temperature, lo | |
1652 | |
1653 TSTOSS opt_units ; 0=°C, 1=°F | |
1654 bra TFT_temp_surfmode_metric | |
1655 | |
1656 ;TFT_temp_surfmode_imperial: | |
1657 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1658 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
1659 lfsr FSR2,buffer ; Overwrite "-" | |
1660 bsf ignore_digit5 ; Full degrees only | |
1661 output_16 | |
1662 STRCAT_PRINT "" | |
1663 call TFT_divemask_color | |
1664 WIN_SMALL surf_temp_column+4*8,surf_temp_row | |
1665 STRCPY_PRINT "°F" | |
1666 return | |
1667 | |
1668 TFT_temp_surfmode_metric: | |
1669 lfsr FSR2,buffer | |
1670 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1671 movlw d'3' | |
1672 movwf ignore_digits | |
1673 bsf ignore_digit5 ; Full degrees only | |
1674 output_16 | |
1675 | |
13
2af021c66b0d
fix negative temperature display in surfacemode
heinrichsweikamp
parents:
11
diff
changeset
|
1676 ; read-back the buffer+4 |
2af021c66b0d
fix negative temperature display in surfacemode
heinrichsweikamp
parents:
11
diff
changeset
|
1677 movff buffer+4,lo |
0 | 1678 movlw " " ; Space |
1679 cpfseq lo ; Was it a space (between +1°C and -1°C)? | |
1680 bra TFT_temp_surfmode1 ; No. | |
1681 movlw "0" ; Yes, print manual zero | |
1682 movff WREG,buffer+3 | |
1683 bra TFT_temp_surfmode2 | |
1684 TFT_temp_surfmode1: | |
1685 ; Test if output was negative (Flag set in TFT_convert_signed_16bit) | |
1686 btfss neg_flag ; Negative temperature? | |
1687 bra TFT_temp_surfmode3 ; No, continue | |
1688 ; Yes, negative temperature! | |
1689 movff buffer+3,buffer+2 ; remove two spaces manually | |
1690 movff buffer+4,buffer+3 | |
1691 TFT_temp_surfmode2: | |
1692 movlw 0x00 | |
1693 movff WREG,buffer+4 | |
1694 TFT_temp_surfmode3: | |
1695 STRCAT_PRINT "" | |
1696 call TFT_divemask_color | |
1697 WIN_SMALL surf_temp_column+4*8,surf_temp_row | |
1698 STRCPY_PRINT "°C" | |
1699 return | |
1700 | |
1701 ;============================================================================= | |
1702 global TFT_divemode_menu_cursor | |
1703 TFT_divemode_menu_cursor: | |
1704 WIN_BOX_BLACK divemode_menu_item1_row,divemode_menu_item3_row+.24,divemode_menu_item1_column-.8,divemode_menu_item1_column-.1 | |
1705 WIN_BOX_BLACK divemode_menu_item4_row,divemode_menu_item6_row+.24,divemode_menu_item4_column-.8,divemode_menu_item4_column-.1 | |
1706 call TFT_standard_color | |
1707 | |
1708 movlw divemode_menu_item1_column-.8 | |
1709 btfsc menupos,2 ; >3? | |
1710 movlw divemode_menu_item4_column-.8 ; Yes | |
1711 movff WREG,win_leftx2 | |
1712 | |
1713 movff menupos,lo ; Copy menu pos | |
1714 movlw divemode_menu_item6_row | |
1715 dcfsnz lo,F | |
1716 movlw divemode_menu_item1_row | |
1717 dcfsnz lo,F | |
1718 movlw divemode_menu_item2_row | |
1719 dcfsnz lo,F | |
1720 movlw divemode_menu_item3_row | |
1721 dcfsnz lo,F | |
1722 movlw divemode_menu_item4_row | |
1723 dcfsnz lo,F | |
1724 movlw divemode_menu_item5_row | |
1725 movff WREG,win_top | |
1726 movlw FT_SMALL | |
1727 movff WREG,win_font | |
1728 STRCPY_PRINT "\xb7" ; print cursor | |
1729 return | |
1730 | |
1731 global TFT_temp_divemode | |
1732 TFT_temp_divemode: | |
1733 btfsc divemode_menu ; Is the dive mode menu shown? | |
1734 return ; Yes, return | |
1735 btfsc blinking_better_gas ; blinking better Gas? | |
1736 return ; Yes, no update of temperature now | |
1737 ; temperature | |
1738 WIN_SMALL dive_temp_column,dive_temp_row | |
1739 call TFT_standard_color | |
1740 bsf leftbind | |
1741 | |
1742 SAFE_2BYTE_COPY temperature, lo | |
1743 TSTOSS opt_units ; 0=°C, 1=°F | |
1744 bra TFT_temp_divemode_metric | |
1745 | |
1746 ;TFT_temp_divemode_imperial: | |
1747 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1748 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
1749 lfsr FSR2,buffer ; Overwrite "-" (There won't be less then -18°C underwater...) | |
1750 bsf ignore_digit5 ; Full degrees only | |
1751 output_16 | |
1752 STRCAT_TEXT tLogTunitF | |
1753 TFT_temp_divemode_common: | |
1754 bcf leftbind | |
1755 movlw .4 ; limit to three chars | |
1756 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1757 STRCAT_PRINT "" | |
1758 return ; Done. | |
1759 | |
1760 TFT_temp_divemode_metric: | |
1761 lfsr FSR2,buffer | |
1762 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1763 movlw d'3' | |
1764 movwf ignore_digits | |
1765 bsf ignore_digit5 ; Full degrees only | |
1766 output_16 | |
1767 STRCAT_TEXT tLogTunitC | |
1768 bra TFT_temp_divemode_common ; Done. | |
1769 | |
1770 TFT_active_setpoint: ; Show setpoint | |
1771 WIN_STD active_gas_column,active_gas_row | |
1772 call TFT_standard_color | |
1773 btfsc is_bailout ; =1: Bailout | |
1774 bra TFT_active_setpoint_bail ; Show "Bailout" instead of Setpoint | |
1775 | |
1776 lfsr FSR2,buffer | |
1777 movff char_I_const_ppO2,lo | |
1778 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
1779 clrf hi | |
1780 bsf leftbind | |
1781 output_16dp d'3' | |
1782 bcf leftbind | |
1783 STRCAT_TEXT tbar | |
1784 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor | |
1785 bra $+4 | |
1786 PUTC "*" | |
1787 STRCAT_PRINT "" | |
1788 | |
1789 TFT_active_setpoint_diluent: | |
1790 call TFT_standard_color | |
1791 WIN_SMALL active_dil_column,active_dil_row | |
1792 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1793 movff char_I_He_ratio,hi ; hi now stores He in % | |
1794 rcall TFT_show_dil_divemode2 ; Show diluent (Non-Inverted in all cases) | |
1795 | |
1796 btfss better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
1797 return ; Done. | |
1798 btg blinking_better_gas ; Toggle blink bit... | |
1799 btfss blinking_better_gas ; blink now? | |
1800 return ; No, Done. | |
1801 | |
1802 movlw color_yellow ; Blink in yellow | |
1803 call TFT_set_color | |
1804 WIN_SMALL_INVERT active_dil_column,active_dil_row | |
1805 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1806 movff char_I_He_ratio,hi ; hi now stores He in % | |
1807 rcall TFT_show_dil_divemode2 ; Show gas | |
1808 WIN_INVERT .0 ; Init new Wordprocessor | |
1809 call TFT_standard_color | |
1810 return ; Done. | |
1811 | |
1812 TFT_show_dil_divemode2: | |
1813 lfsr FSR2,buffer | |
1814 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1815 STRCAT_PRINT "" | |
1816 return | |
1817 | |
1818 TFT_active_setpoint_bail: | |
1819 STRCPY_TEXT_PRINT tDiveBailout ; Bailout | |
1820 bra TFT_active_setpoint_diluent | |
1821 | |
1822 global TFT_active_gas_divemode | |
1823 TFT_active_gas_divemode: ; Display gas/Setpoint | |
1824 btfsc divemode_menu ; Is the dive mode menu shown? | |
1825 return ; Yes, return | |
1826 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
1827 return | |
1828 btfsc FLAG_ccr_mode ; in CCR mode | |
1829 bra TFT_active_setpoint ; Yes, show setpoint | |
1830 | |
1831 call TFT_standard_color | |
1832 WIN_STD active_gas_column,active_gas_row | |
1833 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1834 movff char_I_He_ratio,hi ; hi now stores He in % | |
1835 rcall TFT_active_gas_divemode2 ; Show gas (Non-Inverted in all cases) | |
1836 btfss better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
1837 return ; Done. | |
1838 | |
1839 btg blinking_better_gas ; Toggle blink bit... | |
1840 btfss blinking_better_gas ; blink now? | |
1841 return ; No, Done. | |
50 | 1842 call TFT_attention_color ; blink in yellow |
0 | 1843 WIN_STD_INVERT active_gas_column,active_gas_row |
1844 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1845 movff char_I_He_ratio,hi ; hi now stores He in % | |
1846 rcall TFT_active_gas_divemode2 ; Show gas (Non-Inverted in all cases) | |
1847 WIN_INVERT .0 ; Init new Wordprocessor | |
1848 call TFT_standard_color | |
1849 return ; Done. | |
1850 | |
1851 TFT_active_gas_divemode2: | |
1852 lfsr FSR2,buffer | |
1853 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1854 STRCAT_PRINT "" | |
1855 return | |
1856 | |
1857 global TFT_display_decotype_surface | |
1858 global TFT_display_decotype_surface1 ; Used from logbook! | |
1859 TFT_display_decotype_surface: | |
1860 WIN_STD surf_decotype_column,surf_decotype_row | |
1861 WIN_COLOR color_lightblue | |
1862 lfsr FSR2,buffer | |
1863 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea | |
1864 TFT_display_decotype_surface1: ; Used from logbook! | |
1865 tstfsz lo | |
1866 bra TFT_display_decotype_surface2 | |
1867 STRCAT_TEXT_PRINT tDvOC ; OC | |
1868 bra TFT_display_decotype_exit | |
1869 TFT_display_decotype_surface2: | |
1870 decfsz lo,F | |
1871 bra TFT_display_decotype_surface3 | |
1872 STRCAT_TEXT_PRINT tDvCC ; CC | |
1873 bra TFT_display_decotype_exit | |
1874 TFT_display_decotype_surface3: | |
1875 decfsz lo,F | |
1876 bra TFT_display_decotype_surface4 | |
1877 STRCAT_TEXT_PRINT tDvGauge ; Gauge | |
1878 bra TFT_display_decotype_exit | |
1879 TFT_display_decotype_surface4: | |
1880 STRCAT_TEXT_PRINT tDvApnea ; Apnea | |
1881 TFT_display_decotype_exit: | |
1882 call TFT_standard_color | |
1883 return | |
40 | 1884 |
0 | 1885 ;============================================================================= |
1886 | |
1887 global TFT_splist_surfmode ; Show Setpoint list | |
1888 extern gaslist_strcat_setpoint | |
1889 TFT_splist_surfmode: | |
1890 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1891 ;SP 1 | |
1892 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1893 lfsr FSR2,buffer | |
1894 clrf PRODL | |
1895 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1896 STRCAT_PRINT "" | |
1897 ;SP 2 | |
1898 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1899 lfsr FSR2,buffer | |
1900 movlw .1 | |
1901 movwf PRODL | |
1902 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1903 STRCAT_PRINT "" | |
1904 ;SP 3 | |
1905 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1906 lfsr FSR2,buffer | |
1907 movlw .2 | |
1908 movwf PRODL | |
1909 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1910 STRCAT_PRINT "" | |
1911 ;SP 4 | |
1912 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1913 lfsr FSR2,buffer | |
1914 movlw .3 | |
1915 movwf PRODL | |
1916 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1917 STRCAT_PRINT "" | |
1918 ;SP 5 | |
1919 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1920 lfsr FSR2,buffer | |
1921 movlw .4 | |
1922 movwf PRODL | |
1923 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1924 STRCAT_PRINT "" | |
1925 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1926 bcf leftbind | |
1927 return | |
1928 | |
1929 global TFT_gaslist_surfmode | |
1930 TFT_gaslist_surfmode: ; Displays Gas List | |
1931 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1932 extern gaslist_strcat_gas_mod | |
1933 ;Gas 1 | |
1934 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1935 lfsr FSR2,buffer | |
1936 movlw .0 | |
1937 movwf PRODL | |
1938 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1939 STRCAT_PRINT "" | |
1940 ;Gas 2 | |
1941 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1942 lfsr FSR2,buffer | |
1943 movlw .1 | |
1944 movwf PRODL | |
1945 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1946 STRCAT_PRINT "" | |
1947 ;Gas 3 | |
1948 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1949 lfsr FSR2,buffer | |
1950 movlw .2 | |
1951 movwf PRODL | |
1952 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1953 STRCAT_PRINT "" | |
1954 ;Gas 4 | |
1955 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1956 lfsr FSR2,buffer | |
1957 movlw .3 | |
1958 movwf PRODL | |
1959 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1960 STRCAT_PRINT "" | |
1961 ;Gas 5 | |
1962 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1963 lfsr FSR2,buffer | |
1964 movlw .4 | |
1965 movwf PRODL | |
1966 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1967 STRCAT_PRINT "" | |
1968 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1969 bcf leftbind | |
1970 return | |
1971 | |
1972 global TFT_dillist_surfmode | |
1973 TFT_dillist_surfmode: ; Displays Diluent List | |
1974 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1975 ;Dil 1 | |
1976 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1977 lfsr FSR2,buffer | |
1978 movlw .5 | |
1979 movwf PRODL | |
1980 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1981 STRCAT_PRINT "" | |
1982 ;Dil 2 | |
1983 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1984 lfsr FSR2,buffer | |
1985 movlw .6 | |
1986 movwf PRODL | |
1987 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1988 STRCAT_PRINT "" | |
1989 ;Dil 3 | |
1990 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1991 lfsr FSR2,buffer | |
1992 movlw .7 | |
1993 movwf PRODL | |
1994 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1995 STRCAT_PRINT "" | |
1996 ;Dil 4 | |
1997 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1998 lfsr FSR2,buffer | |
1999 movlw .8 | |
2000 movwf PRODL | |
2001 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
2002 STRCAT_PRINT "" | |
2003 ;Dil 5 | |
2004 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
2005 lfsr FSR2,buffer | |
2006 movlw .9 | |
2007 movwf PRODL | |
2008 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
2009 STRCAT_PRINT "" | |
2010 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
2011 bcf leftbind | |
2012 return | |
2013 | |
2014 global TFT_depth | |
2015 TFT_depth: | |
2016 SAFE_2BYTE_COPY rel_pressure, lo | |
2017 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2018 | |
2019 TSTOSS opt_units ; 0=m, 1=ft | |
2020 bra TFT_depth_metric | |
2021 ;TFT_depth_imperial | |
2022 WIN_LARGE depth_feet_column,depth_feet_row | |
2023 lfsr FSR2,buffer | |
2024 TFT_color_code warn_depth ; Color-code the output | |
2025 | |
2026 clrf sub_a+1 ; Display 0ft if lower then 30cm | |
2027 movlw d'30' | |
2028 movwf sub_a+0 | |
2029 movff hi,sub_b+1 | |
2030 movff lo,sub_b+0 | |
2031 call subU16 ; sub_c = sub_a - sub_b | |
2032 btfss neg_flag ; Depth lower then 0.4m? | |
2033 bra depth_less_0.3mtr_feet ; Yes, Show 0ft manually | |
2034 | |
2035 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2036 bsf leftbind | |
2037 output_16 ; feet in Big font | |
2038 bcf leftbind | |
2039 movlw .3 ; limit to three chars | |
2040 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2041 STRCAT_PRINT "" ; Display feet | |
2042 return | |
2043 | |
2044 depth_less_0.3mtr_feet: | |
2045 STRCAT_PRINT "0 " ; manual zero | |
2046 return | |
2047 | |
2048 TFT_depth_metric: | |
2049 WIN_LARGE depth_column,depth_row | |
2050 TFT_color_code warn_depth ; Color-code the output | |
2051 | |
2052 movlw .039 | |
2053 cpfslt hi | |
2054 bra depth_greater_99_84mtr | |
2055 | |
2056 btfsc depth_greater_100m ; Was depth>100m during last call | |
11 | 2057 rcall TFT_clear_depth ; Yes, clear depth area |
0 | 2058 bcf depth_greater_100m ; Do this once only... |
2059 | |
11 | 2060 movlw .039 |
2061 cpfslt hi | |
2062 bra depth_greater_99_84mtr | |
2063 | |
0 | 2064 lfsr FSR2,buffer |
2065 movlw HIGH d'1000' | |
2066 movwf sub_a+1 | |
2067 movlw LOW d'1000' | |
2068 movwf sub_a+0 | |
2069 movff hi,sub_b+1 | |
2070 movff lo,sub_b+0 | |
2071 incf sub_b+0,F | |
2072 movlw d'0' | |
2073 addwfc sub_b+1,F ; Add 1mbar offset | |
2074 call sub16 ; sub_c = sub_a - sub_b | |
2075 movlw ' ' | |
2076 btfss neg_flag ; Depth lower then 10m? | |
2077 movwf POSTINC2 ; Yes, add extra space | |
2078 | |
2079 clrf sub_a+1 | |
2080 movlw d'99' | |
2081 movwf sub_a+0 | |
2082 movff hi,sub_b+1 | |
2083 movff lo,sub_b+0 | |
2084 call subU16 ; sub_c = sub_a - sub_b | |
2085 btfss neg_flag ; Depth lower then 1m? | |
2086 bra tft_depth2 ; Yes, display manual Zero | |
2087 | |
2088 bsf leftbind | |
2089 bsf ignore_digit4 | |
2090 output_16 ; Full meters in Big font | |
2091 bcf leftbind | |
2092 bra tft_depth3 | |
2093 | |
2094 tft_depth2: | |
2095 WIN_LARGE depth_column,depth_row | |
2096 STRCAT "0" | |
2097 | |
2098 tft_depth3: | |
2099 STRCAT_PRINT "" ; Display full meters | |
2100 | |
2101 ; .1m in MEDIUM font | |
2102 WIN_MEDIUM depth_dm_column,depth_dm_row | |
2103 TFT_color_code warn_depth ; Color-code the output | |
2104 | |
2105 SAFE_2BYTE_COPY rel_pressure, lo | |
2106 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2107 | |
2108 lfsr FSR2,buffer | |
2109 PUTC "." | |
2110 movlw HIGH d'30' ; Display 0.0m if lower then 30cm | |
2111 movwf sub_a+1 | |
2112 movlw LOW d'30' | |
2113 movwf sub_a+0 | |
2114 movff hi,sub_b+1 | |
2115 movff lo,sub_b+0 | |
2116 call subU16 ; sub_c = sub_a - sub_b | |
2117 btfss neg_flag ; Depth lower then 0.3m? | |
2118 bra depth_less_0.3mtr ; Yes, Show ".0" manually | |
2119 | |
2120 movlw d'4' | |
2121 movwf ignore_digits | |
2122 bsf ignore_digit5 | |
2123 output_16dp d'0' | |
2124 STRCAT_PRINT "" ; Display decimeters | |
2125 WIN_FONT FT_SMALL | |
2126 return | |
2127 | |
2128 depth_less_0.3mtr: | |
2129 STRCAT_PRINT "0" ; Display 0.0m manually | |
2130 WIN_FONT FT_SMALL | |
2131 return | |
2132 | |
2133 depth_greater_99_84mtr: ; Display only in full meters | |
2134 btfss depth_greater_100m ; Is depth>100m already? | |
2135 rcall TFT_clear_depth ; No, clear depth area and set flag | |
2136 ; Depth is already in hi:lo | |
2137 ; Show depth in Full meters | |
2138 ; That means ignore figure 4 and 5 | |
2139 lfsr FSR2,buffer | |
2140 bsf ignore_digit4 | |
2141 bsf leftbind | |
2142 output_16 | |
2143 bcf leftbind | |
2144 STRCAT_PRINT "" ; Display full meters only | |
2145 WIN_FONT FT_SMALL | |
2146 return | |
2147 | |
2148 TFT_clear_depth: ; No, clear depth area and set flag | |
2149 WIN_BOX_BLACK depth_row, .77,.0, max_depth_column-.1 ;top, bottom, left, right | |
2150 bsf depth_greater_100m ; Set Flag | |
2151 return | |
2152 | |
2153 ;============================================================================= | |
2154 | |
2155 ; global TFT_user_image | |
2156 ;TFT_user_image: | |
2157 ; ;---- Display user image ------------------------------------------------- | |
2158 ; ; Compute address in external EEPROM | |
2159 ; movff opt_skin,WREG | |
2160 ; mullw 0x50 | |
2161 ; movff PRODL,ext_flash_address+1 | |
2162 ; movf PRODH,W | |
2163 ; iorlw 0x30 | |
2164 ; movwf ext_flash_address+2 | |
2165 ; | |
2166 ; ; First pixel at @+4: | |
2167 ; movlw 4 | |
2168 ; movwf ext_flash_address+0 | |
2169 ; | |
2170 ; ; Read first pixel | |
2171 ; call ext_flash_read_block_start | |
2172 ;; movff SSP2BUF,skin_color+1 ; TFT format: HIGH is first... | |
2173 ; movwf SSP2BUF ; Write to buffer to initiate new read | |
2174 ; btfss SSP2STAT, BF ; Next byte ready ? | |
2175 ; bra $-2 ; NO: wait... | |
2176 ;; movff SSP2BUF,skin_color+0 | |
2177 ; call ext_flash_read_block_stop | |
2178 ; | |
2179 ; ; Make a frame of the retrieved skin color. | |
2180 ; setf win_color1 | |
2181 ; setf win_color2 | |
2182 ; WIN_FRAME_COLOR16 user_image_upper-.1, user_image_upper+.100,user_image_left-.1, user_image_left+.50 | |
2183 ; | |
2184 ; WIN_LEFT user_image_left+.25 | |
2185 ; WIN_TOP user_image_upper+.50 | |
2186 ; | |
2187 ; ; Display skin icon | |
2188 ; clrf ext_flash_address+0 | |
2189 ; call TFT_write_flash_image_addr | |
2190 ; | |
2191 ; ;---- Print custom text string | |
2192 ; WIN_LEFT user_image_left+.50+.5 | |
2193 ; WIN_TOP user_image_upper+.0 | |
2194 ; | |
2195 ; ; ---- STRNCPY : String copy from RAM | |
2196 ; ; lfsr FSR0, opt_name ; Source | |
2197 ; lfsr FSR1, .13 ; Len max | |
2198 ; lfsr FSR2, buffer ; destination | |
2199 ;TFT_user_image_1: | |
2200 ; movf POSTINC0,W ; Get byte | |
2201 ; bz TFT_user_image_2 ; End if NULL | |
2202 ; movwf POSTINC2 ; NO: copy | |
2203 ; decfsz FSR1L ; Max len reached ? | |
2204 ; bra TFT_user_image_1 ; NO: loop | |
2205 ;TFT_user_image_2: | |
2206 ; clrf POSTINC2 ; Mark end of string | |
2207 ; | |
2208 ; goto aa_wordprocessor ; and print | |
2209 | |
2210 | |
2211 global TFT_custom_text | |
2212 TFT_custom_text: ; Show the custom text | |
2213 lfsr FSR0, opt_name ; Source | |
2214 WIN_SMALL surf_customtext_column,surf_customtext_row1 ; First row | |
2215 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
2216 incfsz lo,F ; Was lo=255? | |
2217 return ; No, all done. | |
2218 lfsr FSR0, opt_name+.12 ; Source | |
2219 WIN_SMALL surf_customtext_column,surf_customtext_row2 ; Second row | |
2220 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
2221 incfsz lo,F ; Was lo=255? | |
2222 return ; No, all done. | |
2223 lfsr FSR0, opt_name+.24 ; Source | |
2224 WIN_SMALL surf_customtext_column,surf_customtext_row3 ; Third row | |
2225 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
2226 incfsz lo,F ; Was lo=255? | |
2227 return ; No, all done. | |
2228 lfsr FSR0, opt_name+.36 ; Source | |
2229 WIN_SMALL surf_customtext_column,surf_customtext_row4 ; Forth row | |
2230 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
2231 incfsz lo,F ; Was lo=255? | |
2232 return ; No, all done. | |
2233 lfsr FSR0, opt_name+.48 ; Source | |
2234 WIN_SMALL surf_customtext_column,surf_customtext_row5 ; Fifth row | |
2235 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
2236 return ; Done. | |
2237 | |
2238 TFT_custom_text_2: | |
2239 lfsr FSR2, buffer ; destination | |
2240 movlw .12 | |
2241 movwf lo ; length/line | |
2242 TFT_custom_text_3: | |
2243 movf POSTINC0,W ; Get byte | |
2244 bz TFT_custom_text_4 ; End if NULL | |
2245 movwf POSTINC2 ; NO: copy | |
2246 decfsz lo,F ; Max len reached ? | |
2247 bra TFT_custom_text_3 ; NO: loop | |
2248 setf lo ; lo=255 -> more to come | |
2249 TFT_custom_text_4: | |
2250 clrf POSTINC2 ; Mark end of string | |
2251 goto aa_wordprocessor ; print and return | |
2252 | |
2253 | |
2254 ;============================================================================= | |
2255 global TFT_update_surf_press | |
2256 TFT_update_surf_press: | |
2257 WIN_SMALL surf_press_column,surf_press_row | |
2258 call TFT_standard_color | |
2259 SAFE_2BYTE_COPY amb_pressure, lo | |
2260 lfsr FSR2,buffer | |
2261 movff lo,sub_a+0 | |
2262 movff hi,sub_a+1 | |
2263 movff last_surfpressure_30min+0,sub_b+0 | |
2264 movff last_surfpressure_30min+1,sub_b+1 | |
2265 call subU16 ; sub_c = sub_a - sub_b | |
2266 btfsc neg_flag ; Pressure lower? | |
2267 rcall update_surf_press2 ; Yes, test threshold | |
2268 | |
2269 tstfsz sub_c+1 ; >255mbar difference? | |
2270 bra update_surf_press_common; Yes, display! | |
2271 movlw d'10' ; 10mbar noise suppression | |
2272 subwf sub_c+0,W | |
2273 btfsc STATUS,C | |
2274 bra update_surf_press_common; Yes, display! | |
2275 SAFE_2BYTE_COPY last_surfpressure_30min, lo ; Overwrite with stable value... | |
2276 | |
2277 update_surf_press_common: | |
2278 output_16 | |
2279 ; Show only 4 figures | |
2280 movff buffer+1,buffer+0 | |
2281 movff buffer+2,buffer+1 | |
2282 movff buffer+3,buffer+2 | |
2283 movff buffer+4,buffer+3 | |
2284 movlw 0x00 | |
2285 movff WREG,buffer+4 | |
2286 STRCAT_PRINT "" | |
2287 call TFT_divemask_color | |
2288 WIN_SMALL surf_press_column+4*8,surf_press_row | |
2289 STRCPY_PRINT "mbar" | |
2290 return | |
2291 | |
2292 update_surf_press2: | |
2293 movff lo,sub_b+0 | |
2294 movff hi,sub_b+1 | |
2295 movff last_surfpressure_30min+0,sub_a+0 | |
2296 movff last_surfpressure_30min+1,sub_a+1 | |
2297 call subU16 ; sub_c = sub_a - sub_b | |
2298 return | |
2299 | |
2300 ;============================================================================= | |
2301 | |
2302 global TFT_update_batt_voltage | |
2303 TFT_update_batt_voltage: | |
2304 movff batt_percent,lo ; Get battery percent | |
2305 TFT_color_code warn_battery; Color-code battery percent | |
2306 WIN_TINY batt_percent_column,batt_percent_row | |
2307 lfsr FSR2,buffer | |
2308 bsf leftbind | |
2309 output_8 | |
2310 bcf leftbind | |
2311 STRCAT_PRINT "%" | |
2312 call TFT_standard_color | |
2313 WIN_TINY batt_voltage_column,batt_voltage_row | |
2314 lfsr FSR2,buffer | |
2315 movff batt_voltage+0,lo | |
2316 movff batt_voltage+1,hi | |
2317 bsf leftbind | |
2318 output_16dp .2 | |
2319 bcf leftbind | |
2320 PUTC 'V' | |
2321 movff buffer+5,buffer+3 | |
2322 movlw 0x00 | |
2323 movff WREG,buffer+4 ; Only "x.yV" | |
24 | 2324 STRCAT_PRINT "" |
0 | 2325 return |
2326 | |
2327 ;update_battery_debug: | |
2328 ; call TFT_standard_color | |
2329 ; WIN_TINY .70,.0 | |
2330 ; lfsr FSR2,buffer | |
2331 ; movff battery_gauge+5,xC+3 | |
2332 ; movff battery_gauge+4,xC+2 | |
2333 ; movff battery_gauge+3,xC+1 | |
2334 ; movff battery_gauge+2,xC+0 | |
2335 ; ; battery_gauge:6 is nAs | |
2336 ; ; devide through 65536 | |
2337 ; ; devide through 152 | |
2338 ; ; Result is 0.01Ah in xC+1:xC+0 | |
2339 ; movlw LOW .152 | |
2340 ; movwf xB+0 | |
2341 ; movlw HIGH .152 | |
2342 ; movwf xB+1 | |
2343 ; call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
2344 ; bsf leftbind | |
2345 ; movff xC+0,lo | |
2346 ; movff xC+1,hi | |
2347 ; output_16 | |
2348 ; STRCAT_PRINT "x.01Ah" | |
2349 ; WIN_FONT FT_SMALL | |
2350 ; bcf leftbind | |
2351 ; return | |
2352 | |
2353 ;============================================================================= | |
2354 | |
2355 global TFT_convert_signed_16bit | |
2356 TFT_convert_signed_16bit: | |
2357 bcf neg_flag ; Positive temperature | |
2358 btfss hi,7 ; Negative temperature ? | |
2359 return ; No, return | |
2360 ; Yes, negative temperature! | |
2361 bsf neg_flag ; Negative temperature | |
2362 PUTC '-' ; Display "-" | |
2363 comf hi ; Then, 16bit sign changes. | |
2364 negf lo | |
2365 btfsc STATUS,C | |
2366 incf hi | |
2367 return ; and return | |
2368 | |
2369 ;============================================================================= | |
2370 | |
2371 global TFT_convert_date | |
2372 TFT_convert_date: ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
2373 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD | |
2374 movwf EEDATA ; used as temp here | |
2375 tstfsz EEDATA | |
2376 bra TFT_convert_date1 | |
2377 ; EEDATA was 0 | |
2378 ; Use MMDDYY | |
2379 movff convert_value_temp+0,lo ;month | |
2380 bsf leftbind | |
2381 output_99x | |
2382 PUTC '.' | |
2383 movff convert_value_temp+1,lo ;day | |
2384 bra TFT_convert_date1_common ;year | |
2385 | |
2386 TFT_convert_date1: ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD) | |
2387 decfsz EEDATA,F | |
2388 bra TFT_convert_date2 ; EEDATA was 2 | |
2389 ; EEDATA was 1 | |
2390 ; Use DDMMYY | |
2391 movff convert_value_temp+1,lo ;day | |
2392 bsf leftbind | |
2393 output_99x | |
2394 PUTC '.' | |
2395 movff convert_value_temp+0,lo ;month | |
2396 | |
2397 TFT_convert_date1_common: | |
2398 bsf leftbind | |
2399 output_99x | |
2400 PUTC '.' | |
2401 movff convert_value_temp+2,lo ;year | |
2402 output_99x | |
2403 bcf leftbind | |
2404 return | |
2405 | |
2406 TFT_convert_date2: | |
2407 ; Use YYMMDD | |
2408 movff convert_value_temp+2,lo ;year | |
2409 bsf leftbind | |
2410 output_99x | |
2411 PUTC '.' | |
2412 movff convert_value_temp+0,lo ;month | |
2413 output_99x | |
2414 PUTC '.' | |
2415 movff convert_value_temp+1,lo ;day | |
2416 output_99x | |
2417 bcf leftbind | |
2418 return | |
2419 | |
2420 ;============================================================================= | |
2421 | |
2422 global TFT_convert_date_short | |
2423 TFT_convert_date_short: ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
2424 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD | |
2425 movwf EEDATA ; used as temp here | |
2426 tstfsz EEDATA | |
2427 bra TFT_convert_date_short1 | |
2428 ; EEDATA was 0 | |
2429 ; Use MMDDYY | |
2430 TFT_convert_date_short_common: | |
2431 movff convert_value_temp+0,lo ;month | |
2432 bsf leftbind | |
2433 output_99x | |
2434 PUTC '.' | |
2435 movff convert_value_temp+1,lo ;day | |
2436 output_99x | |
2437 bcf leftbind | |
2438 return | |
2439 | |
2440 TFT_convert_date_short1: | |
2441 decfsz EEDATA,F | |
2442 bra TFT_convert_date_short_common ; EEDATA was 2 -> Use YYMMDD | |
2443 ; EEDATA was 1 | |
2444 ; Use DDMMYY | |
2445 movff convert_value_temp+1,lo ;day | |
2446 bsf leftbind | |
2447 output_99x | |
2448 PUTC '.' | |
2449 movff convert_value_temp+0,lo ;month | |
2450 output_99x | |
2451 bcf leftbind | |
2452 return | |
2453 | |
2454 ;============================================================================= | |
2455 | |
2456 global TFT_date | |
2457 TFT_date: | |
48 | 2458 WIN_SMALL surf_date_column,surf_date_row ; Init new Wordprocessor |
0 | 2459 call TFT_standard_color |
2460 lfsr FSR2,buffer | |
2461 movff month,convert_value_temp+0 | |
2462 movff day,convert_value_temp+1 | |
2463 movff year,convert_value_temp+2 | |
2464 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
2465 STRCAT_PRINT "" | |
2466 return | |
2467 | |
2468 ;============================================================================= | |
2469 | |
2470 global TFT_max_pressure | |
2471 TFT_max_pressure: | |
2472 btfsc FLAG_apnoe_mode ; different display in apnoe mode | |
2473 bra TFT_max_pressure_apnoe | |
2474 TFT_max_pressure2: | |
2475 SAFE_2BYTE_COPY max_pressure, lo | |
2476 TFT_max_pressure3: | |
2477 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2478 TSTOSS opt_units ; 0=m, 1=ft | |
2479 bra TFT_max_pressure2_metric | |
2480 ;TFT_max_pressure2_imperial | |
2481 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2482 WIN_MEDIUM max_depth_feet_column,max_depth_feet_row | |
2483 lfsr FSR2,buffer | |
2484 call TFT_standard_color | |
2485 output_16_3 | |
2486 STRCAT_PRINT "" | |
2487 return | |
2488 | |
2489 TFT_max_pressure2_metric: | |
11 | 2490 WIN_MEDIUM max_depth_column,max_depth_row |
2491 | |
2492 movlw .039 | |
2493 cpfslt hi | |
2494 bra max_depth_greater_99_84mtr | |
2495 | |
2496 btfsc max_depth_greater_100m ; Was depth>100m during last call | |
2497 rcall TFT_clear_max_depth ; Yes, clear depth area | |
2498 bcf max_depth_greater_100m ; Do this once only... | |
2499 | |
2500 movlw .039 | |
2501 cpfslt hi | |
2502 bra max_depth_greater_99_84mtr | |
2503 | |
2504 lfsr FSR2,buffer | |
2505 movlw HIGH d'1000' | |
2506 movwf sub_a+1 | |
2507 movlw LOW d'1000' | |
2508 movwf sub_a+0 | |
2509 movff hi,sub_b+1 | |
2510 movff lo,sub_b+0 | |
2511 incf sub_b+0,F | |
2512 movlw d'0' | |
2513 addwfc sub_b+1,F ; Add 1mbar offset | |
2514 call sub16 ; sub_c = sub_a - sub_b | |
2515 movlw ' ' | |
2516 btfss neg_flag ; Depth lower then 10m? | |
2517 movwf POSTINC2 ; Yes, add extra space | |
2518 | |
2519 clrf sub_a+1 | |
2520 movlw d'99' | |
2521 movwf sub_a+0 | |
2522 movff hi,sub_b+1 | |
2523 movff lo,sub_b+0 | |
2524 call subU16 ; sub_c = sub_a - sub_b | |
2525 btfss neg_flag ; Depth lower then 1m? | |
2526 bra tft_max_depth2 ; Yes, display manual Zero | |
2527 | |
2528 bsf ignore_digit4 ; no 0.1m | |
2529 bsf leftbind | |
2530 output_16 | |
2531 bra tft_max_depth3 | |
2532 | |
2533 tft_max_depth2: | |
0 | 2534 WIN_MEDIUM max_depth_column,max_depth_row |
11 | 2535 STRCAT "0" |
2536 | |
2537 tft_max_depth3: | |
0 | 2538 call TFT_standard_color |
11 | 2539 STRCAT_PRINT "" ; Display full meters |
2540 bcf leftbind | |
2541 | |
2542 ; .1m in SMALL font | |
2543 WIN_SMALL max_depth_dm_column,max_depth_dm_row | |
2544 | |
2545 SAFE_2BYTE_COPY max_pressure, lo | |
2546 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2547 | |
2548 lfsr FSR2,buffer | |
2549 PUTC "." | |
2550 | |
2551 movlw d'4' | |
2552 movwf ignore_digits | |
2553 bsf ignore_digit5 | |
2554 bsf leftbind | |
2555 output_16dp d'0' | |
2556 STRCAT_PRINT "" ; Display decimeters | |
2557 bcf leftbind | |
2558 return | |
2559 | |
2560 max_depth_greater_99_84mtr: ; Display only in full meters | |
2561 btfss max_depth_greater_100m ; Is max depth>100m already? | |
2562 rcall TFT_clear_max_depth ; No, clear max depth area and set flag | |
2563 ; Max. Depth is already in hi:lo | |
2564 ; Show max. depth in Full meters | |
2565 ; That means ignore figure 4 and 5 | |
2566 lfsr FSR2,buffer | |
2567 bsf ignore_digit4 | |
2568 bsf leftbind | |
0 | 2569 output_16 |
11 | 2570 bcf leftbind |
2571 STRCAT_PRINT "" ; Display full meters only | |
2572 WIN_FONT FT_SMALL | |
0 | 2573 return |
2574 | |
11 | 2575 TFT_clear_max_depth: ; No, clear max. depth area and set flag |
2576 WIN_BOX_BLACK max_depth_row,.49,max_depth_column, max_depth_dm_column+.13 ;top, bottom, left, right | |
2577 bsf max_depth_greater_100m ; Set Flag | |
2578 return | |
2579 | |
2580 | |
0 | 2581 TFT_max_pressure_apnoe: |
2582 btfss FLAG_active_descent ; Are we descending? | |
2583 bra TFT_max_pressure2 ; Yes, show normal max. | |
2584 SAFE_2BYTE_COPY apnoe_max_pressure, lo | |
2585 bra TFT_max_pressure3 ; Show apnoe_max_pressure as max. depth | |
2586 | |
2587 global TFT_display_apnoe_last_max | |
2588 TFT_display_apnoe_last_max: | |
2589 call TFT_divemask_color | |
2590 WIN_TINY last_max_apnoe_text_column,last_max_apnoe_text_row | |
2591 STRCPY_TEXT_PRINT tApnoeMax | |
2592 | |
2593 call TFT_standard_color | |
2594 SAFE_2BYTE_COPY max_pressure, lo | |
2595 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2596 TSTOSS opt_units ; 0=m, 1=ft | |
2597 bra TFT_display_apnoe_last_m_metric | |
2598 ;TFT_display_apnoe_last_max_imperial | |
2599 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2600 WIN_MEDIUM apnoe_last_max_depth_column,apnoe_last_max_depth_row | |
2601 lfsr FSR2,buffer | |
2602 output_16 | |
2603 STRCAT_PRINT "" | |
2604 return | |
2605 | |
2606 TFT_display_apnoe_last_m_metric: | |
2607 WIN_MEDIUM apnoe_last_max_depth_column,apnoe_last_max_depth_row | |
2608 lfsr FSR2,buffer | |
2609 bsf ignore_digit5 ; do not display 1cm depth | |
2610 output_16dp d'3' | |
2611 STRCAT_PRINT "" | |
2612 return | |
2613 | |
2614 ;============================================================================= | |
2615 global TFT_divemins | |
2616 TFT_divemins: | |
2617 movff divemins+0,lo | |
2618 movff divemins+1,hi | |
2619 | |
2620 btfsc no_more_divesecs ; Ignore seconds? | |
2621 bra TFT_divemins2 ; Show minutes only | |
2622 | |
2623 movlw .99 | |
2624 cpfsgt lo ; bigger then 99? | |
2625 bra TFT_divemins1 ; No show mins:secs | |
2626 ; Yes, remove second display for the rest of the dive and clear seconds | |
2627 bsf no_more_divesecs ; Set flag | |
2628 ; Clear rest of seconds | |
2629 WIN_BOX_BLACK divetime_row, warning1_row,divetime_column,.159 ;top, bottom, left, right | |
2630 bra TFT_divemins2 ; Show minutes only | |
2631 | |
2632 TFT_divemins1: | |
2633 WIN_MEDIUM divetime_column, divetime_row | |
2634 lfsr FSR2,buffer | |
2635 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2636 call TFT_standard_color | |
2637 STRCAT_PRINT "" ; Show minutes in large font | |
2638 | |
2639 WIN_SMALL divetime_secs_column, divetime_secs_row ; left position for two sec figures | |
2640 lfsr FSR2,buffer | |
2641 PUTC ':' | |
2642 bsf leftbind | |
2643 movff divesecs,lo | |
2644 output_99x | |
2645 bcf leftbind | |
2646 STRCAT_PRINT "" ; Show seconds in small font | |
2647 return | |
2648 | |
2649 TFT_divemins2: | |
2650 WIN_MEDIUM divetime_minsonly_column, divetime_row | |
2651 lfsr FSR2,buffer | |
2652 output_16 | |
2653 call TFT_standard_color | |
2654 STRCAT_PRINT "" ; Show minutes in large font | |
2655 return | |
2656 | |
2657 ;============================================================================= | |
2658 global TFT_display_apnoe_surface | |
2659 TFT_display_apnoe_surface: | |
2660 call TFT_divemask_color | |
2661 WIN_TINY surface_apnoe_text_column,surface_apnoe_text_row | |
2662 STRCPY_TEXT_PRINT tApnoeSurface | |
2663 | |
2664 call TFT_standard_color | |
2665 WIN_MEDIUM surface_time_apnoe_column, surface_time_apnoe_row | |
2666 movff apnoe_surface_mins,lo | |
2667 lfsr FSR2,buffer | |
2668 output_8 | |
2669 PUTC ':' | |
2670 movff apnoe_surface_secs,lo | |
2671 output_99x | |
2672 STRCAT_PRINT "" | |
2673 return | |
2674 | |
2675 global TFT_apnoe_clear_surface | |
2676 TFT_apnoe_clear_surface: | |
2677 ; Clear Surface timer.... | |
2678 WIN_BOX_BLACK surface_apnoe_text_row, .239, surface_apnoe_text_column, .159 ;top, bottom, left, right | |
2679 return | |
2680 | |
2681 global TFT_display_apnoe_descent | |
2682 TFT_display_apnoe_descent: ; Descent divetime | |
2683 movff apnoe_mins,lo | |
2684 clrf hi | |
2685 WIN_MEDIUM divetime_column, divetime_row | |
2686 lfsr FSR2,buffer | |
2687 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2688 call TFT_standard_color | |
2689 STRCAT_PRINT "" ; Show minutes in large font | |
2690 WIN_SMALL divetime_secs_column, divetime_secs_row ; left position for two sec figures | |
2691 lfsr FSR2,buffer | |
2692 PUTC ':' | |
2693 bsf leftbind | |
2694 movff apnoe_secs,lo | |
2695 output_99x | |
2696 bcf leftbind | |
2697 STRCAT_PRINT "" ; Show seconds in small font | |
38 | 2698 |
2699 | |
2700 call TFT_divemask_color | |
2701 WIN_TINY total_apnoe_text_column,total_apnoe_text_row | |
2702 STRCPY_TEXT_PRINT tApnoeTotal | |
2703 call TFT_standard_color | |
2704 movff divemins,lo | |
2705 clrf hi | |
2706 WIN_MEDIUM apnoe_total_divetime_column, apnoe_total_divetime_row | |
2707 lfsr FSR2,buffer | |
2708 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2709 call TFT_standard_color | |
2710 STRCAT_PRINT "" ; Show minutes in large font | |
2711 WIN_SMALL apnoe_total_divetime_secs_column, apnoe_total_divetime_secs_row ; left position for two sec figures | |
2712 lfsr FSR2,buffer | |
2713 PUTC ':' | |
2714 bsf leftbind | |
2715 movff divesecs,lo | |
2716 output_99x | |
2717 bcf leftbind | |
2718 STRCAT_PRINT "" ; Show seconds in small font | |
2719 | |
0 | 2720 return |
2721 | |
2722 ;============================================================================= | |
2723 ; Writes ostc3 #Serial and Firmware version in splash screen | |
2724 ; | |
2725 global TFT_serial | |
2726 TFT_serial: | |
2727 WIN_TINY .0,.239-.14 | |
2728 | |
2729 STRCPY "OSTC3 #" ; Won't translate that... | |
2730 rcall TFT_cat_serial | |
2731 | |
2732 STRCAT " v" | |
2733 rcall TFT_cat_firmware | |
2734 | |
2735 ifdef __DEBUG | |
2736 movlw color_grey ; Write header in blue when | |
2737 call TFT_set_color ; compiled in DEBUG mode... | |
2738 STRCAT_PRINT "DEBUG" | |
2739 call TFT_standard_color | |
2740 else | |
2741 call TFT_standard_color | |
2742 STRCAT_PRINT "" | |
2743 | |
2744 movlw softwareversion_beta ; =1: Beta, =0: Release | |
2745 decfsz WREG,F | |
2746 return ; Release version -> Return | |
2747 | |
2748 call TFT_warnings_color | |
2749 WIN_LEFT .160-4*9/2 ; Right pad. | |
2750 STRCPY_TEXT_PRINT tBeta | |
2751 call TFT_standard_color | |
2752 endif | |
2753 | |
2754 return | |
2755 | |
2756 | |
2757 | |
2758 ;============================================================================= | |
2759 ; For the Information menu: append firmware x.yy version. | |
2760 global info_menu_firmware | |
2761 extern tFirmware | |
2762 info_menu_firmware: | |
2763 lfsr FSR1,tFirmware | |
2764 call strcat_text | |
2765 TFT_cat_firmware: | |
2766 movlw softwareversion_x | |
2767 movwf lo | |
2768 bsf leftbind | |
2769 output_8 | |
2770 PUTC '.' | |
2771 movlw softwareversion_y | |
2772 movwf lo | |
2773 output_99x | |
2774 bcf leftbind | |
2775 return | |
2776 | |
2777 ;----------------------------------------------------------------------------- | |
2778 ; For the Information menu: append serial number ostc3#42. | |
2779 global info_menu_serial | |
2780 extern tSerial | |
2781 info_menu_serial: | |
2782 lfsr FSR1,tSerial | |
2783 call strcat_text | |
2784 TFT_cat_serial: | |
2785 clrf EEADRH | |
2786 clrf EEADR ; Get Serial number LOW | |
2787 call read_eeprom ; read byte | |
2788 movff EEDATA,lo | |
2789 incf EEADR,F ; Get Serial number HIGH | |
2790 call read_eeprom ; read byte | |
2791 movff EEDATA,hi | |
2792 | |
2793 bsf leftbind | |
2794 output_16 | |
2795 bcf leftbind | |
2796 return | |
2797 | |
2798 ;----------------------------------------------------------------------------- | |
2799 ; For the Information menu: Append total dives | |
2800 global info_menu_total_dives | |
2801 extern tTotalDives | |
2802 info_menu_total_dives: | |
2803 lfsr FSR1,tTotalDives | |
2804 call strcat_text | |
2805 TFT_cat_total_dives: | |
2806 read_int_eeprom .2 | |
2807 movff EEDATA,lo | |
2808 read_int_eeprom .3 | |
2809 movff EEDATA,hi | |
2810 bsf leftbind | |
2811 output_16 | |
2812 bcf leftbind | |
2813 return | |
2814 | |
2815 ;----------------------------------------------------------------------------- | |
2816 ; ppO2 menu | |
2817 global divesets_ppo2_max | |
2818 extern tPPO2Max | |
2819 extern tbar | |
2820 divesets_ppo2_max: | |
2821 lfsr FSR1,tPPO2Max | |
2822 call strcat_text | |
2823 movff opt_ppO2_max,lo | |
2824 movlw ppo2_warning_high | |
2825 divesets_ppo2_common: | |
2826 movwf up ; Save default value | |
2827 clrf hi | |
2828 bsf leftbind | |
2829 output_16dp d'3' | |
2830 bcf leftbind | |
2831 lfsr FSR1,tbar | |
2832 call strcat_text | |
2833 | |
2834 movf up,W ; Default value | |
2835 cpfseq lo ; Current value | |
2836 bra divesets_ppo2_common2 ; Not default, add * | |
2837 return ; Default, Done. | |
2838 divesets_ppo2_common2: | |
2839 PUTC "*" | |
2840 return ; Done. | |
2841 | |
2842 global divesets_ppo2_min | |
2843 extern tPPO2Min | |
2844 divesets_ppo2_min: | |
2845 lfsr FSR1,tPPO2Min | |
2846 call strcat_text | |
2847 movff opt_ppO2_min,lo | |
2848 movlw ppo2_warning_low | |
2849 bra divesets_ppo2_common | |
2850 | |
2851 ;============================================================================= | |
2852 | |
2853 global TFT_clear_warning_text | |
2854 TFT_clear_warning_text: | |
2855 btfss divemode ; in divemode? | |
2856 bra TFT_clear_warning_text2 ; No, setup for surface mode | |
2857 WIN_BOX_BLACK warning1_row, divemode_customview_row-3, warning1_column, warning_icon_column-3 ;top, bottom, left, right | |
2858 return | |
2859 TFT_clear_warning_text2: | |
2860 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ;top, bottom, left, right | |
2861 return | |
2862 | |
2863 global TFT_clear_warning_text_2nd_row | |
2864 TFT_clear_warning_text_2nd_row: | |
2865 btfss divemode ; in divemode? | |
2866 bra TFT_clear_warning_text_2nd_2 ; No, setup for surface mode | |
2867 WIN_BOX_BLACK warning2_row, divemode_customview_row-3, warning2_column, warning_icon_column-3 ;top, bottom, left, right | |
2868 return | |
2869 TFT_clear_warning_text_2nd_2: | |
2870 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ;top, bottom, left, right | |
2871 return | |
2872 | |
2873 global TFT_fillup_with_spaces | |
2874 TFT_fillup_with_spaces: ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2875 movwf lo ; save max. string length into lo | |
2876 movf FSR2L,W ; Get current string length | |
2877 subwf lo,F ; lo-WREG | |
2878 btfsc STATUS,N ; longer then #lo already? | |
2879 return ; Yes, done. | |
2880 tstfsz lo ; Zero? | |
2881 bra TFT_fillup_with_spaces2 ; No. | |
2882 return ; Yes, done. | |
2883 TFT_fillup_with_spaces2: | |
2884 PUTC " " ; Add one space | |
2885 decfsz lo,F ; All done? | |
2886 bra TFT_fillup_with_spaces2 ; No, loop | |
2887 return ; Done. | |
2888 | |
2889 global TFT_desaturation_time | |
2890 TFT_desaturation_time: | |
2891 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2892 tstfsz WREG ; Is there room for the warning? | |
2893 return ; No | |
2894 STRCPY "Desat:" | |
2895 movff desaturation_time+0,lo ; divide by 60... | |
2896 movff desaturation_time+1,hi | |
2897 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
2898 bsf leftbind | |
2899 movf lo,W | |
2900 movff hi,lo | |
2901 movwf hi ; exchange lo and hi... | |
2902 output_8 ; Hours | |
2903 PUTC ':' | |
2904 movff hi,lo ; Minutes | |
2905 output_99x | |
2906 bcf leftbind | |
2907 movlw surf_warning_length ; Only use surface string length | |
2908 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2909 STRCAT_PRINT "" | |
2910 return | |
2911 | |
2912 global TFT_nofly_time | |
2913 TFT_nofly_time: | |
2914 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2915 tstfsz WREG ; Is there room for the warning? | |
2916 return ; No | |
2917 STRCPY "NoFly:" | |
2918 movff nofly_time+0,lo ; divide by 60... | |
2919 movff nofly_time+1,hi | |
2920 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
2921 bsf leftbind | |
2922 movf lo,W | |
2923 movff hi,lo | |
2924 movwf hi ; exchange lo and hi... | |
2925 output_8 ; Hours | |
2926 PUTC ':' | |
2927 movff hi,lo ; Minutes | |
2928 output_99x | |
2929 bcf leftbind | |
2930 movlw surf_warning_length ; Only use surface string length | |
2931 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2932 STRCAT_PRINT "" | |
2933 return | |
2934 | |
2935 global TFT_warning_agf | |
2936 TFT_warning_agf: | |
2937 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2938 tstfsz WREG ; Is there room for the warning? | |
2939 return ; No | |
2940 call TFT_warnings_color | |
2941 STRCPY_TEXT tDiveaGF_active ; "aGF!" | |
2942 movlw warning_length ; Divemode string length | |
2943 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2944 STRCAT_PRINT "" | |
2945 call TFT_standard_color | |
2946 return | |
2947 | |
2948 global TFT_warning_gf | |
2949 TFT_warning_gf: ;GF | |
2950 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2951 tstfsz WREG ; Is there room for the warning? | |
2952 return ; No | |
2953 TFT_color_code warn_gf ; Color-code Output | |
2954 STRCPY "GF:" | |
2955 movff char_O_gradient_factor,lo ; gradient factor | |
2956 bsf leftbind | |
2957 output_8 | |
2958 PUTC "%" | |
2959 movlw warning_length ; Divemode string length | |
2960 btfss divemode ; In Divemode? | |
2961 movlw surf_warning_length ; No, use surface string length | |
2962 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2963 STRCAT_PRINT "" | |
2964 bcf leftbind | |
2965 call TFT_standard_color | |
2966 return | |
2967 | |
2968 TFT_warning_set_window: ; Sets the row and column for the current warning | |
2969 ; ignore warning (now)? | |
2970 decf warning_counter,W ; -1 | |
2971 bcf STATUS,C | |
2972 rrcf WREG,W ; (warning_counter-1)/2 | |
2973 cpfseq warning_page | |
2974 retlw .255 ; WREG <> 0 -> Warning window not defined | |
2975 | |
2976 call TFT_standard_color | |
2977 | |
2978 btfss divemode ; in divemode? | |
2979 bra TFT_warning_set_window3 ; No, setup for surface mode | |
2980 | |
2981 btfss warning_counter,0 ; Toggle with each warning | |
2982 bra TFT_warning_set_window2 | |
2983 WIN_SMALL warning1_column,warning1_row | |
2984 bcf second_row_warning ; =1: The second row contains a warning | |
2985 retlw .0 ; WREG=0 -> Warning window defined | |
2986 TFT_warning_set_window2: | |
2987 WIN_SMALL warning2_column,warning2_row | |
2988 bsf second_row_warning ; =1: The second row contains a warning | |
2989 retlw .0 ; WREG=0 -> Warning window defined | |
2990 | |
2991 TFT_warning_set_window3: | |
2992 btfss warning_counter,0 ; Toggle with each warning | |
2993 bra TFT_warning_set_window4 | |
2994 WIN_SMALL surf_warning1_column,surf_warning1_row | |
2995 bcf second_row_warning ; =1: The second row contains a warning | |
2996 retlw .0 ; WREG=0 -> Warning window defined | |
2997 TFT_warning_set_window4: | |
2998 WIN_SMALL surf_warning2_column,surf_warning2_row | |
2999 bsf second_row_warning ; =1: The second row contains a warning | |
3000 retlw .0 ; WREG=0 -> Warning window defined | |
3001 | |
3002 | |
3003 global TFT_update_batt_percent_divemode | |
3004 TFT_update_batt_percent_divemode: | |
3005 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3006 tstfsz WREG ; Is there room for the warning? | |
3007 return ; No | |
3008 movff batt_percent,lo ; Get battery percent | |
3009 TFT_color_code warn_battery; Color-code battery percent | |
3010 STRCPY "Batt:" | |
3011 bsf leftbind | |
3012 output_8 | |
3013 bcf leftbind | |
3014 PUTC "%" | |
3015 movlw warning_length ; Divemode string length | |
3016 btfss divemode ; In Divemode? | |
3017 movlw surf_warning_length ; No, use surface string length | |
3018 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3019 STRCAT_PRINT "" | |
3020 call TFT_standard_color | |
3021 return | |
3022 | |
3023 | |
3024 global TFT_gf_mask ; Setup Mask | |
3025 TFT_gf_mask: | |
3026 ; The mask | |
3027 call TFT_divemask_color | |
3028 WIN_TINY dive_gf_column1,dive_gf_text_row | |
3029 STRCPY_TEXT_PRINT tGFactors | |
3030 WIN_TINY dive_gf_column2,dive_gf_text_row | |
3031 STRCPY_TEXT_PRINT taGFactors | |
3032 WIN_TINY dive_gf_column3,dive_gf_text_row | |
3033 STRCPY_TEXT_PRINT tGFInfo | |
3034 | |
3035 ; Show GF (Static) | |
3036 call TFT_disabled_color | |
3037 btfss use_agf | |
3038 call TFT_standard_color | |
3039 | |
3040 WIN_STD dive_gf_column,dive_gf_row | |
3041 lfsr FSR2,buffer | |
3042 bsf leftbind | |
3043 movff opt_GF_low,lo | |
3044 output_8 | |
3045 PUTC "/" | |
3046 movff opt_GF_high,lo | |
3047 output_8 | |
3048 STRCAT_PRINT "" | |
3049 ; Show aGF (Static) | |
3050 call TFT_standard_color | |
3051 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | |
3052 bra TFT_gf_mask2 ; Show "---" instead | |
3053 | |
3054 btfss use_agf | |
3055 call TFT_disabled_color | |
3056 | |
3057 WIN_STD dive_agf_column,dive_agf_row | |
3058 lfsr FSR2,buffer | |
3059 movff opt_aGF_low,lo | |
3060 output_8 | |
3061 PUTC "/" | |
3062 movff opt_aGF_high,lo | |
3063 output_8 | |
3064 STRCAT_PRINT "" | |
3065 bcf leftbind | |
3066 call TFT_standard_color | |
3067 return | |
3068 | |
3069 TFT_gf_mask2: | |
3070 WIN_STD dive_agf_column+.10,dive_agf_row | |
3071 STRCPY_PRINT "---" | |
3072 bcf leftbind | |
3073 return | |
3074 | |
3075 global TFT_gf_info ; Show GF informations | |
3076 TFT_gf_info: | |
3077 ; Show current GF | |
3078 movff char_O_gradient_factor,lo ; gradient factor absolute (Non-GF model) | |
3079 movff char_I_deco_model,hi | |
3080 decfsz hi,F ; jump over next line if char_I_deco_model == 1 | |
3081 movff char_O_relative_gradient_GF,lo ; gradient factor relative (GF model) | |
3082 WIN_STD dive_currentgf_column,dive_currentgf_row | |
3083 lfsr FSR2,buffer | |
3084 output_8 | |
3085 STRCAT_PRINT "%" | |
3086 return | |
3087 | |
3088 global TFT_ead_end_tissues_clock_mask ; Setup Mask | |
3089 TFT_ead_end_tissues_clock_mask: | |
3090 ; The mask | |
3091 call TFT_divemask_color | |
3092 ; Put three columns at HUD positions | |
3093 WIN_TINY dive_custom_hud_column1,dive_custom_hud_row | |
3094 STRCPY_TEXT_PRINT tDiveClock | |
3095 WIN_TINY dive_custom_hud_column2,dive_custom_hud_row | |
3096 STRCPY_TEXT_PRINT tDiveEAD_END | |
3097 WIN_TINY dive_custom_hud_column3,dive_custom_hud_row | |
3098 STRCPY_TEXT_PRINT tDiveTissues | |
3099 call TFT_standard_color | |
3100 return | |
3101 | |
3102 global TFT_ead_end_tissues_clock ; Show EAD/END, Tissues and clock | |
3103 TFT_ead_end_tissues_clock: | |
3104 ; Update clock and date | |
3105 WIN_SMALL dive_clock_column,dive_clock_row | |
3106 call TFT_clock2 ; print clock | |
3107 ; WIN_SMALL dive_date_column,dive_date_row | |
3108 ; lfsr FSR2,buffer | |
3109 ; movff month,convert_value_temp+0 | |
3110 ; movff day,convert_value_temp+1 | |
3111 ; movff year,convert_value_temp+2 | |
3112 ; rcall TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
3113 ; STRCAT_PRINT "." | |
3114 | |
3115 ; Show END/EAD | |
3116 WIN_SMALL dive_ead_column,dive_ead_row | |
3117 STRCPY_TEXT tEAD ; EAD: | |
3118 movff char_O_EAD,lo | |
3119 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
3120 WIN_SMALL dive_end_column,dive_end_row | |
3121 STRCPY_TEXT tEND ; END: | |
3122 movff char_O_END,lo | |
3123 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
3124 | |
3125 ; Show tissue diagram | |
3126 call TFT_divemask_color | |
3127 WIN_TINY dive_tissue_N2_column,dive_tissue_N2_row | |
3128 STRCPY_TEXT_PRINT tN2 | |
3129 WIN_TINY dive_tissue_He_column,dive_tissue_He_row | |
3130 STRCPY_TEXT_PRINT tHe | |
3131 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
3132 movlb b'00000001' ; select ram bank 1 | |
3133 rcall DISP_tissue_saturation_graph ; Show char_O_tissue_N2_saturation and char_O_tissue_He_saturation | |
3134 return | |
3135 | |
3136 TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars | |
3137 bsf leftbind | |
3138 TSTOSS opt_units ; 0=Meters, 1=Feets | |
3139 bra TFT_end_ead_common_metric | |
3140 ;TFT_end_ead_common_imperial: | |
3141 ; With lo in m | |
3142 movf lo,W | |
3143 mullw .100 ; PRODL:PRODH = mbar/min | |
3144 movff PRODL,lo | |
3145 movff PRODH,hi | |
3146 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
3147 output_16_3 | |
3148 STRCAT_TEXT tFeets | |
3149 clrf WREG | |
3150 movff WREG,buffer+.8 ; limit string length to 8 | |
3151 bra TFT_end_ead_common_exit | |
3152 TFT_end_ead_common_metric: | |
3153 output_8 | |
3154 STRCAT_TEXT tMeters | |
3155 TFT_end_ead_common_exit: | |
3156 bcf leftbind | |
3157 movlw .8 | |
3158 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3159 STRCAT_PRINT "" | |
3160 return | |
3161 | |
3162 global TFT_surface_tissues | |
3163 TFT_surface_tissues: ; Show Tissue diagram in surface mode | |
3164 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row | |
3165 STRCPY_TEXT_PRINT tN2 | |
3166 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row | |
3167 STRCPY_TEXT_PRINT tHe | |
3168 | |
3169 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
3170 movlb b'00000001' ; select ram bank 1 | |
3171 | |
3172 movlw color_deepblue | |
3173 call TFT_set_color ; Make this configurable? | |
3174 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.29,.29 | |
3175 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.37,.37 | |
3176 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.45,.45 | |
3177 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.53,.53 | |
3178 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.61,.61 | |
3179 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.69,.69 | |
3180 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.77,.77 | |
3181 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.85,.85 | |
3182 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right ; outer frame | |
3183 | |
3184 movlw .1 | |
3185 movff WREG,win_height ; row bottom (0-239) | |
3186 movlw surf_tissue_diagram_left+.4 ; Surface mode | |
3187 movff WREG,win_leftx2 ; column left (0-159) | |
3188 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-4 ; Width | |
3189 movff WREG,win_width | |
3190 | |
3191 ;---- Draw N2 Tissues | |
3192 lfsr FSR2, char_O_tissue_N2_saturation | |
3193 movlw d'16' | |
3194 movwf wait_temp ; 16 tissues | |
3195 clrf waitms_temp ; Row offset | |
3196 surf_tissue_saturation_graph_N2: | |
3197 movlw surf_tissue_diagram_top+.23 ; surface mode | |
3198 addwf waitms_temp,W | |
3199 movff WREG,win_top ; row top (0-239) | |
3200 rcall surf_tissue_saturation_loop ; Show one tissue | |
3201 decfsz wait_temp,F | |
3202 bra surf_tissue_saturation_graph_N2 | |
3203 | |
3204 ;---- Draw He Tissues ---------------------------------------------------- | |
3205 lfsr FSR2, char_O_tissue_He_saturation | |
3206 movlw d'16' | |
3207 movwf wait_temp ; 16 tissues | |
3208 clrf waitms_temp ; Row offset | |
3209 surf_tissue_saturation_graph_He: | |
3210 movlw surf_tissue_diagram_top+.23+.56 ; surface mode | |
3211 addwf waitms_temp,W | |
3212 movff WREG,win_top ; row top (0-239) | |
3213 rcall surf_tissue_saturation_loop ; Show one tissue | |
3214 decfsz wait_temp,F | |
3215 bra surf_tissue_saturation_graph_He | |
3216 return | |
3217 | |
3218 surf_tissue_saturation_loop: | |
3219 call TFT_standard_color | |
3220 movlw .2 ; row spacing | |
3221 addwf waitms_temp,F | |
3222 movf POSTINC2,W ; Get tissue load | |
3223 bcf STATUS,C | |
3224 rrcf WREG ; And divide by 2 | |
3225 movwf temp1 | |
3226 movlw .20 | |
3227 subwf temp1,F ; Subtract some offset | |
3228 movff win_width,WREG ; Max width. | |
3229 cpfslt temp1 ; skip if WREG < win_width | |
3230 movwf temp1 | |
3231 movff temp1,win_bargraph | |
3232 call TFT_box | |
3233 return | |
3234 | |
3235 ;============================================================================= | |
3236 ; Draw saturation graph, is surface mode or in dive mode. | |
3237 DISP_tissue_saturation_graph: | |
3238 ;---- Draw Frame | |
50 | 3239 call TFT_standard_color |
3240 WIN_FRAME_COLOR16 tissue_diagram_top, tissue_diagram_bottom, tissue_diagram_left, .159 ; outer frame | |
0 | 3241 |
3242 movlw .1 | |
3243 movff WREG,win_height ; row bottom (0-239) | |
3244 movlw tissue_diagram_left+.3 ; divemode | |
3245 movff WREG,win_leftx2 ; column left (0-159) | |
3246 movlw .159-tissue_diagram_left-4 ; Width | |
3247 movff WREG,win_width | |
3248 | |
3249 ;---- Draw N2 Tissues | |
3250 lfsr FSR2, char_O_tissue_N2_saturation | |
3251 movlw d'16' | |
3252 movwf wait_temp ; 16 tissues | |
3253 clrf waitms_temp ; Row offset | |
3254 tissue_saturation_graph_N2: | |
3255 movlw tissue_diagram_top+3 ; divemode | |
3256 addwf waitms_temp,W | |
3257 movff WREG,win_top ; row top (0-239) | |
3258 rcall tissue_saturation_graph_loop ; Show one tissue | |
3259 decfsz wait_temp,F | |
3260 bra tissue_saturation_graph_N2 | |
3261 | |
3262 ;---- Draw He Tissues ---------------------------------------------------- | |
3263 lfsr FSR2, char_O_tissue_He_saturation | |
3264 movlw d'16' | |
3265 movwf wait_temp ; 16 tissues | |
3266 clrf waitms_temp ; Row offset | |
3267 tissue_saturation_graph_He: | |
3268 movlw tissue_diagram_top+3+.22 ; divemode | |
3269 addwf waitms_temp,W | |
3270 movff WREG,win_top ; row top (0-239) | |
3271 | |
3272 rcall tissue_saturation_graph_loop ; Show one tissue | |
3273 | |
3274 decfsz wait_temp,F | |
3275 bra tissue_saturation_graph_He | |
3276 return | |
3277 | |
3278 tissue_saturation_graph_loop: | |
3279 call TFT_standard_color | |
3280 incf waitms_temp,F | |
3281 movf POSTINC2,W | |
3282 bcf STATUS,C | |
3283 rrcf WREG | |
3284 bcf STATUS,C | |
3285 rrcf WREG ; And divide by 4 | |
3286 movwf temp1 | |
3287 movlw .12 | |
3288 subwf temp1,F ; Subtract some offset | |
3289 movff win_width,WREG ; Max width. | |
3290 cpfslt temp1 ; skip if WREG < win_width | |
3291 movwf temp1 | |
3292 movff temp1,win_bargraph | |
3293 call TFT_box | |
3294 return | |
3295 | |
55 | 3296 |
0 | 3297 global TFT_display_cns |
3298 TFT_display_cns: | |
3299 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3300 tstfsz WREG ; Is there room for the warning? | |
3301 return ; No | |
3302 TFT_color_code warn_cns ; Color-code CNS output | |
3303 STRCPY_TEXT tCNS2 ; CNS: | |
3304 movff int_O_CNS_fraction+0,lo | |
3305 movff int_O_CNS_fraction+1,hi | |
3306 bsf leftbind | |
3307 output_16_3 ;Displays only 0...999 | |
3308 bcf leftbind | |
3309 PUTC "%" | |
3310 movlw warning_length ; Divemode string length | |
3311 btfss divemode ; In Divemode? | |
3312 movlw surf_warning_length ; No, use surface string length | |
3313 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3314 STRCAT_PRINT "" | |
3315 call TFT_standard_color | |
3316 return | |
3317 | |
3318 global TFT_display_ppo2 | |
3319 TFT_display_ppo2: ; Show ppO2 (ppO2 stored in xC, in mbar!) | |
3320 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3321 tstfsz WREG ; Is there room for the warning? | |
3322 return ; No | |
3323 TFT_color_code warn_ppo2 ; Color-code output (ppO2 stored in xC) | |
55 | 3324 STRCPY "ppO2:" |
0 | 3325 ; Check very high ppO2 manually |
3326 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
3327 bra TFT_show_ppO2_3 ; Yes, display fixed Value! | |
3328 movff xC+0,lo | |
3329 movff xC+1,hi | |
3330 bsf ignore_digit4 | |
3331 output_16dp d'1' | |
3332 TFT_show_ppO2_2: | |
3333 movlw warning_length ; Divemode string length | |
3334 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3335 STRCAT_PRINT "" | |
3336 call TFT_standard_color | |
3337 return | |
3338 | |
3339 TFT_show_ppO2_3: | |
3340 STRCAT ">6.6" | |
3341 bra TFT_show_ppO2_2 | |
3342 | |
3343 | |
3344 global TFT_LogOffset_Logtitle | |
3345 TFT_LogOffset_Logtitle: | |
3346 STRCPY_TEXT tLogOffset | |
3347 PUTC ":" | |
3348 call do_logoffset_common_read ; Offset into lo:hi | |
3349 bsf leftbind | |
3350 output_16 | |
3351 bcf leftbind | |
3352 PUTC " " | |
3353 return ; No "_PRINT" here... | |
3354 | |
3355 | |
3356 global adjust_depth_with_salinity | |
3357 adjust_depth_with_salinity: ; computes salinity setting into lo:hi [mbar] | |
3358 btfsc simulatormode_active ; Do apply salinity in Simulatormode | |
3359 return | |
3360 | |
3361 movff opt_salinity,WREG ; 0-5% | |
3362 addlw d'100' ; 1.00kg/l | |
3363 movwf wait_temp | |
3364 | |
3365 movlw d'105' ; 105% ? | |
3366 cpfslt wait_temp ; Salinity higher limit | |
3367 return ; Out of limit, do not adjust lo:hi | |
3368 movlw d'99' ; 99% ? | |
3369 cpfsgt wait_temp ; Salinity lower limit | |
3370 return ; Out of limit, do not adjust lo:hi | |
3371 | |
3372 movff lo,xA+0 | |
3373 movff hi,xA+1 | |
3374 | |
3375 movlw d'102' ; 0,98bar/10m | |
3376 movwf xB+0 | |
3377 clrf xB+1 | |
3378 call mult16x16 ;xA*xB=xC (lo:hi * 100) | |
3379 movff wait_temp,xB+0 ; Salinity | |
3380 clrf xB+1 | |
3381 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3382 movff xC+0,lo | |
3383 movff xC+1,hi ; restore lo and hi with updated value | |
3384 return | |
3385 | |
3386 global convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
3387 convert_mbar_to_feet: ; convert value in lo:hi from mbar to feet | |
3388 movff lo,xA+0 | |
3389 movff hi,xA+1 | |
3390 | |
3391 movlw LOW d'328' ; 328feet/100m | |
3392 movwf xB+0 | |
3393 movlw HIGH d'328' | |
3394 movwf xB+1 | |
3395 | |
3396 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
3397 | |
3398 movlw d'50' ; round up | |
3399 addwf xC+0,F | |
3400 movlw 0 | |
3401 addwfc xC+1,F | |
3402 addwfc xC+2,F | |
3403 addwfc xC+3,F | |
3404 | |
3405 movlw LOW .10000 | |
3406 movwf xB+0 | |
3407 movlw HIGH .10000 | |
3408 movwf xB+1 | |
3409 | |
3410 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3411 | |
3412 movff xC+0,lo | |
3413 movff xC+1,hi ; restore lo and hi with updated value | |
3414 return | |
3415 | |
3416 global convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
3417 convert_celsius_to_fahrenheit: ; convert value in lo:hi from celsius to fahrenheit | |
3418 ; Does it work with signed temperature? mH | |
3419 movff lo,xA+0 | |
3420 movff hi,xA+1 | |
3421 | |
3422 movlw d'18' ; 1C = 1.8F | |
3423 movwf xB+0 | |
3424 clrf xB+1 | |
3425 | |
3426 call mult16x16 ;xA*xB=xC (lo:hi * 18) | |
3427 | |
3428 movlw d'10' | |
3429 movwf xB+0 | |
3430 clrf xB+1 | |
3431 | |
3432 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3433 | |
3434 movlw LOW d'320' ; 0C = 32F | |
3435 addwf xC+0,F | |
3436 movlw HIGH d'320' | |
3437 addwfc xC+1,F | |
3438 | |
3439 movff xC+0,lo | |
3440 movff xC+1,hi ; restore lo and hi with updated value | |
3441 return | |
3442 | |
3443 END |