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