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