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