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