Mercurial > public > hwos_code
annotate src/tft_outputs.asm @ 39:e4e91fe8b09d
remember last customview in dive and surface mode
author | mh@mh-THINK.fritz.box |
---|---|
date | Thu, 15 Aug 2013 13:55:55 +0200 |
parents | 64976f1e0a1c |
children | 1e2d2b0bca5b |
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: | |
31
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
29
diff
changeset
|
920 call TFT_standard_color |
0 | 921 WIN_TINY .0,.0 |
922 STRCPY "pres:" | |
923 SAFE_2BYTE_COPY amb_pressure, lo | |
31
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
29
diff
changeset
|
924 movlw .5 ;>1280mbar |
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
29
diff
changeset
|
925 cpfslt hi |
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
29
diff
changeset
|
926 call TFT_warnings_color |
0 | 927 bsf leftbind |
928 output_16 | |
929 STRCAT_PRINT "mbar " | |
930 WIN_TINY .80,.0 | |
931 STRCPY "temp:" | |
932 SAFE_2BYTE_COPY temperature, lo | |
933 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
934 movlw d'3' | |
935 movwf ignore_digits | |
936 output_16dp d'2' ; temperature | |
937 STRCAT_PRINT "°C " | |
938 | |
31
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
29
diff
changeset
|
939 call TFT_standard_color |
0 | 940 call get_battery_voltage ; get battery voltage |
941 WIN_TINY .0,.18 | |
942 STRCPY "AN06:" | |
943 movff ADRESL,lo | |
944 movff ADRESH,hi | |
945 output_16 | |
946 STRCAT_PRINT "" | |
947 WIN_TINY .80,.18 | |
948 STRCPY "BATT:" | |
949 movff batt_voltage+0,lo | |
950 movff batt_voltage+1,hi | |
951 output_16 | |
952 STRCAT_PRINT "mV " | |
953 | |
954 call get_ambient_level ; get ambient light level | |
955 WIN_TINY .0,.36 | |
956 STRCPY "AN07:" | |
957 movff ADRESL,lo | |
958 movff ADRESH,hi | |
959 output_16 | |
960 STRCAT_PRINT " " | |
961 WIN_TINY .80,.36 | |
962 STRCPY "Amb.:" | |
963 movff ambient_light+0,lo | |
964 movff ambient_light+1,hi | |
965 output_16 | |
966 STRCAT_PRINT " " | |
967 | |
968 call get_rssi_level ; get rssi level | |
969 WIN_TINY .0,.54 | |
970 STRCPY "AN17:" | |
971 movff ADRESL,lo | |
972 movff ADRESH,hi | |
973 output_16 | |
974 STRCAT_PRINT " " | |
975 WIN_TINY .80,.54 | |
976 STRCPY "RSSI:" | |
977 movff rssi_value,lo | |
978 output_8 | |
979 STRCAT_PRINT " " | |
980 | |
981 WIN_TINY .0,.72 | |
982 STRCPY "HUD_Status:" | |
983 movff hud_status_byte,lo | |
984 output_8 | |
985 STRCAT_PRINT " " | |
986 WIN_TINY .80,.72 | |
987 STRCPY "HUD_BATT:" | |
988 movff hud_battery_mv+0,lo | |
989 movff hud_battery_mv+1,hi | |
990 output_16 | |
991 STRCAT_PRINT "mV " | |
992 | |
993 WIN_TINY .0,.90 | |
994 STRCPY "Sens1.:" | |
995 movff o2_mv_sensor1+0,lo | |
996 movff o2_mv_sensor1+1,hi | |
997 output_16dp d'4' | |
998 STRCAT_PRINT "mV " | |
999 WIN_TINY .80,.90 | |
1000 STRCPY "Sens2:" | |
1001 movff o2_mv_sensor2+0,lo | |
1002 movff o2_mv_sensor2+1,hi | |
1003 output_16dp d'4' | |
1004 STRCAT_PRINT "mV " | |
1005 | |
1006 WIN_TINY .0,.108 | |
1007 STRCPY "Sens3.:" | |
1008 movff o2_mv_sensor3+0,lo | |
1009 movff o2_mv_sensor3+1,hi | |
1010 output_16dp d'4' | |
1011 STRCAT_PRINT "mV " | |
1012 WIN_TINY .80,.108 ; Space | |
1013 | |
1014 WIN_TINY .0,.128 | |
1015 STRCPY "ccDX:" | |
1016 movff compass_DX_f+0,lo ; Display calibrated data | |
1017 movff compass_CX_f+0,WREG ; by substracting compass_CX_f | |
1018 subwf lo,F ; lo := lo - W | |
1019 movff compass_DX_f+1,hi | |
1020 movff compass_CX_f+1,WREG | |
1021 subwfb hi,F | |
1022 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1023 output_16 | |
1024 STRCAT_PRINT " " | |
1025 WIN_TINY .80,.128 | |
1026 STRCPY "ccDY:" | |
1027 movff compass_DY_f+0,lo | |
1028 movff compass_CY_f+0,WREG | |
1029 subwf lo,F | |
1030 movff compass_DY_f+1,hi | |
1031 movff compass_CY_f+1,WREG | |
1032 subwfb hi,F | |
1033 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1034 output_16 | |
1035 STRCAT_PRINT " " | |
1036 WIN_TINY .0,.146 | |
1037 STRCPY "ccDZ:" | |
1038 movff compass_DZ_f+0,lo | |
1039 movff compass_CZ_f+0,WREG | |
1040 subwf lo,F | |
1041 movff compass_DZ_f+1,hi | |
1042 movff compass_CZ_f+1,WREG | |
1043 subwfb hi,F | |
1044 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1045 output_16 | |
1046 STRCAT_PRINT " " | |
1047 WIN_TINY .80,.146 ; Space | |
1048 | |
1049 WIN_TINY .0,.164 | |
1050 STRCPY "AcDX:" | |
1051 movff accel_DX_f+0,lo | |
1052 movff accel_DX_f+1,hi | |
1053 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1054 output_16 | |
1055 STRCAT_PRINT "mg " | |
1056 WIN_TINY .80,.164 | |
1057 STRCPY "AcDY:" | |
1058 movff accel_DY_f+0,lo | |
1059 movff accel_DY_f+1,hi | |
1060 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1061 output_16 | |
1062 STRCAT_PRINT "mg " | |
1063 WIN_TINY .0,.182 | |
1064 STRCPY "AcDZ:" | |
1065 movff accel_DZ_f+0,lo | |
1066 movff accel_DZ_f+1,hi | |
1067 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1068 output_16 | |
1069 STRCAT_PRINT "mg " | |
1070 | |
1071 WIN_TINY .80,.182 | |
1072 STRCPY "Head:" | |
1073 movff compass_heading+0,lo | |
1074 movff compass_heading+1,hi | |
1075 | |
1076 btfsc hi,7 ; Uncalibrated compass ? | |
1077 bra TFT_update_compass_1 | |
1078 | |
1079 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1080 output_16 | |
1081 STRCAT_PRINT " " | |
1082 bra TFT_update_compass_2 | |
1083 | |
1084 TFT_update_compass_1: | |
1085 STRCAT_PRINT "---" | |
1086 | |
1087 TFT_update_compass_2: | |
1088 WIN_TINY .0,.200 | |
1089 STRCPY "calX:" | |
1090 movff compass_CX_f+0,lo | |
1091 movff compass_CX_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_CY_f+0,lo | |
1096 movff compass_CY_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 ", " | |
1100 movff compass_CZ_f+0,lo | |
1101 movff compass_CZ_f+1,hi | |
1102 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1103 output_16 | |
1104 STRCAT_PRINT " " | |
1105 | |
1106 WIN_TINY .0,.218 | |
1107 STRCPY "Roll:" | |
1108 movff compass_roll+0,lo | |
1109 movff compass_roll+1,hi | |
1110 call TFT_convert_signed_16bit | |
1111 output_16 | |
1112 STRCAT_PRINT " " | |
1113 | |
1114 WIN_TINY .80, .218 | |
1115 STRCPY "Pitch:" | |
1116 movff compass_pitch+0,lo | |
1117 movff compass_pitch+1,hi | |
1118 call TFT_convert_signed_16bit | |
1119 output_16 | |
1120 STRCAT_PRINT " " | |
1121 | |
1122 ; call TFT_serial | |
1123 bcf leftbind | |
1124 return | |
1125 | |
1126 | |
1127 global TFT_surface_compass_mask | |
1128 TFT_surface_compass_mask: | |
1129 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row | |
1130 call TFT_standard_color | |
1131 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1132 return | |
1133 | |
1134 global TFT_dive_compass_mask | |
1135 TFT_dive_compass_mask: | |
1136 WIN_TINY dive_compass_mask_column,dive_compass_mask_row | |
1137 call TFT_divemask_color | |
1138 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1139 return | |
1140 | |
1141 | |
1142 global TFT_surface_compass_heading | |
1143 TFT_surface_compass_heading: | |
1144 rcall compass_heading_common | |
16
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1145 btfsc compass_fast_mode ; In fast mode? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1146 bra TFT_surface_compass_heading2 ; Yes |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1147 ; No, update 1/second max. |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1148 movff sensor_state_counter,lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1149 movlw .6 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1150 cpfsgt lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1151 return |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1152 TFT_surface_compass_heading2: |
0 | 1153 WIN_STD surf_compass_head_column,surf_compass_head_row |
1154 call TFT_standard_color | |
1155 lfsr FSR2,buffer | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1156 ; movff compass_heading+0,lo |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1157 ; movff compass_heading+1,hi |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1158 ; 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
|
1159 ; output_8 |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1160 ; PUTC " " |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1161 ; movff hi,lo |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1162 ; output_8 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1163 ; PUTC " " |
0 | 1164 movff compass_heading+0,lo |
1165 movff compass_heading+1,hi | |
1166 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1167 bsf leftbind | |
1168 output_16 | |
1169 bcf leftbind | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1170 STRCAT "° " |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1171 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1172 STRCAT_PRINT " " |
0 | 1173 return |
1174 | |
1175 global TFT_dive_compass_heading | |
1176 TFT_dive_compass_heading: | |
1177 rcall compass_heading_common | |
16
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1178 btfsc compass_fast_mode ; In fast mode? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1179 bra TFT_dive_compass_heading2 ; Yes |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1180 ; No, update 1/second max. |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1181 movff sensor_state_counter,lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1182 movlw .6 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1183 cpfsgt lo |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1184 return |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1185 TFT_dive_compass_heading2: |
0 | 1186 WIN_STD dive_compass_head_column,dive_compass_head_row |
1187 call TFT_standard_color | |
1188 lfsr FSR2,buffer | |
1189 movff compass_heading+0,lo | |
1190 movff compass_heading+1,hi | |
1191 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1192 bsf leftbind | |
1193 output_16 | |
1194 bcf leftbind | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1195 STRCAT "° " |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1196 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1197 STRCAT_PRINT " " |
0 | 1198 return |
1199 | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1200 tft_compass_cardinal: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1201 btfsc hi,0 ; Heading >255°? |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1202 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
|
1203 ; 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
|
1204 movlw .23 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1205 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1206 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1207 bra tft_compass_cardinal_N |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1208 movlw .68 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1209 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1210 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1211 bra tft_compass_cardinal_NE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1212 movlw .113 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1213 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1214 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1215 bra tft_compass_cardinal_E |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1216 movlw .158 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1217 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1218 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1219 bra tft_compass_cardinal_SE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1220 movlw .203 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1221 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1222 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1223 bra tft_compass_cardinal_S |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1224 movlw .248 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1225 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1226 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1227 bra tft_compass_cardinal_SW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1228 bra tft_compass_cardinal_W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1229 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1230 tft_compass_cardinal2: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1231 movlw .37 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1232 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1233 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1234 bra tft_compass_cardinal_W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1235 movlw .82 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1236 subwf lo,W |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1237 btfss STATUS,C |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1238 bra tft_compass_cardinal_NW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1239 bra tft_compass_cardinal_N |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1240 |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1241 tft_compass_cardinal_N: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1242 STRCAT_TEXT tN |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1243 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1244 tft_compass_cardinal_NE: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1245 STRCAT_TEXT tNE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1246 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1247 tft_compass_cardinal_E: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1248 STRCAT_TEXT tE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1249 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1250 tft_compass_cardinal_SE: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1251 STRCAT_TEXT tSE |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1252 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1253 tft_compass_cardinal_S: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1254 STRCAT_TEXT tS |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1255 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1256 tft_compass_cardinal_SW: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1257 STRCAT_TEXT tSW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1258 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1259 tft_compass_cardinal_W: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1260 STRCAT_TEXT tW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1261 return |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1262 tft_compass_cardinal_NW: |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1263 STRCAT_TEXT tNW |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
24
diff
changeset
|
1264 return |
0 | 1265 |
1266 compass_heading_common: | |
1267 extern compass | |
1268 extern compass_filter | |
1269 rcall TFT_get_compass | |
1270 rcall TFT_get_compass | |
1271 rcall TFT_get_compass | |
1272 rcall TFT_get_compass | |
1273 rcall TFT_get_compass | |
1274 rcall TFT_get_compass | |
1275 call compass ; Do compass corrections. | |
1276 banksel common | |
16
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1277 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1278 ; More then compass_fast_treshold? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1279 movff compass_heading_old+0,sub_a+0 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1280 movff compass_heading_old+1,sub_a+1 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1281 movff compass_heading+0,sub_b+0 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1282 movff compass_heading+1,sub_b+1 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1283 call sub16 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1284 movff compass_heading+0,compass_heading_old+0 ; copy new "old" |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1285 movff compass_heading+1,compass_heading_old+1 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1286 |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1287 bcf compass_fast_mode |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1288 movlw compass_fast_treshold |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1289 cpfslt sub_c+0 ; > compass_fast_treshold? |
7b06f20881be
calm compass reading for minor heading changes
heinrichsweikamp
parents:
13
diff
changeset
|
1290 bsf compass_fast_mode ; Yes! |
0 | 1291 return |
1292 | |
1293 TFT_get_compass: | |
1294 call speed_normal | |
1295 call I2C_RX_compass ; Test Compass | |
1296 call I2C_RX_accelerometer ; Test Accelerometer | |
1297 call compass_filter ; Filter Raw compass + accel readings. | |
1298 banksel common | |
1299 return | |
1300 | |
1301 global TFT_debug_output | |
1302 TFT_debug_output: | |
1303 return | |
1304 WIN_TINY .107,.0 | |
1305 call TFT_standard_color | |
1306 lfsr FSR2,buffer | |
1307 movff CCPR1L,lo | |
1308 output_8 | |
1309 STRCAT_PRINT "" | |
1310 return | |
1311 | |
1312 global TFT_ftts | |
1313 TFT_ftts: | |
1314 movff char_I_extra_time,lo | |
1315 tstfsz lo | |
1316 bra $+4 | |
1317 return ; char_I_extra_time=0, return. | |
1318 incf warning_counter,F ; increase counter | |
1319 call TFT_warning_set_window ; Sets the row and column for the current warning | |
1320 tstfsz WREG ; Is there room for the warning? | |
1321 return ; No | |
1322 movff char_I_extra_time,lo | |
1323 STRCPY "@+" | |
1324 bsf leftbind | |
1325 output_8 | |
1326 PUTC ":" | |
1327 movff int_O_extra_ascenttime+0,lo | |
1328 movff int_O_extra_ascenttime+1,hi | |
1329 movf lo,W | |
1330 iorwf hi,W ; extra_ascenttime == 0 ? | |
1331 bz TFT_ftts2 ; No deco | |
1332 movf lo,W ; extra_ascenttime == 0xFFFF ? | |
1333 andwf hi,W | |
1334 incf WREG,w | |
1335 bz TFT_ftts2 ; Wait... | |
1336 output_16 | |
1337 bcf leftbind | |
1338 PUTC "'" | |
1339 movlw warning_length ; Divemode string length | |
1340 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1341 STRCAT_PRINT "" | |
1342 return | |
1343 | |
1344 TFT_ftts2: | |
1345 STRCAT "---" | |
1346 bcf leftbind | |
1347 movlw warning_length ; Divemode string length | |
1348 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1349 STRCAT_PRINT "" | |
1350 return | |
1351 | |
1352 | |
1353 ;============================================================================= | |
1354 | |
1355 global TFT_temp_surfmode | |
1356 TFT_temp_surfmode: | |
1357 WIN_SMALL surf_temp_column,surf_temp_row | |
1358 call TFT_standard_color | |
1359 | |
1360 SAFE_2BYTE_COPY temperature, lo | |
1361 | |
1362 TSTOSS opt_units ; 0=°C, 1=°F | |
1363 bra TFT_temp_surfmode_metric | |
1364 | |
1365 ;TFT_temp_surfmode_imperial: | |
1366 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1367 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
1368 lfsr FSR2,buffer ; Overwrite "-" | |
1369 bsf ignore_digit5 ; Full degrees only | |
1370 output_16 | |
1371 STRCAT_PRINT "" | |
1372 call TFT_divemask_color | |
1373 WIN_SMALL surf_temp_column+4*8,surf_temp_row | |
1374 STRCPY_PRINT "°F" | |
1375 return | |
1376 | |
1377 TFT_temp_surfmode_metric: | |
1378 lfsr FSR2,buffer | |
1379 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1380 movlw d'3' | |
1381 movwf ignore_digits | |
1382 bsf ignore_digit5 ; Full degrees only | |
1383 output_16 | |
1384 | |
13
2af021c66b0d
fix negative temperature display in surfacemode
heinrichsweikamp
parents:
11
diff
changeset
|
1385 ; read-back the buffer+4 |
2af021c66b0d
fix negative temperature display in surfacemode
heinrichsweikamp
parents:
11
diff
changeset
|
1386 movff buffer+4,lo |
0 | 1387 movlw " " ; Space |
1388 cpfseq lo ; Was it a space (between +1°C and -1°C)? | |
1389 bra TFT_temp_surfmode1 ; No. | |
1390 movlw "0" ; Yes, print manual zero | |
1391 movff WREG,buffer+3 | |
1392 bra TFT_temp_surfmode2 | |
1393 TFT_temp_surfmode1: | |
1394 ; Test if output was negative (Flag set in TFT_convert_signed_16bit) | |
1395 btfss neg_flag ; Negative temperature? | |
1396 bra TFT_temp_surfmode3 ; No, continue | |
1397 ; Yes, negative temperature! | |
1398 movff buffer+3,buffer+2 ; remove two spaces manually | |
1399 movff buffer+4,buffer+3 | |
1400 TFT_temp_surfmode2: | |
1401 movlw 0x00 | |
1402 movff WREG,buffer+4 | |
1403 TFT_temp_surfmode3: | |
1404 STRCAT_PRINT "" | |
1405 call TFT_divemask_color | |
1406 WIN_SMALL surf_temp_column+4*8,surf_temp_row | |
1407 STRCPY_PRINT "°C" | |
1408 return | |
1409 | |
1410 ;============================================================================= | |
1411 global TFT_divemode_menu_cursor | |
1412 TFT_divemode_menu_cursor: | |
1413 WIN_BOX_BLACK divemode_menu_item1_row,divemode_menu_item3_row+.24,divemode_menu_item1_column-.8,divemode_menu_item1_column-.1 | |
1414 WIN_BOX_BLACK divemode_menu_item4_row,divemode_menu_item6_row+.24,divemode_menu_item4_column-.8,divemode_menu_item4_column-.1 | |
1415 call TFT_standard_color | |
1416 | |
1417 movlw divemode_menu_item1_column-.8 | |
1418 btfsc menupos,2 ; >3? | |
1419 movlw divemode_menu_item4_column-.8 ; Yes | |
1420 movff WREG,win_leftx2 | |
1421 | |
1422 movff menupos,lo ; Copy menu pos | |
1423 movlw divemode_menu_item6_row | |
1424 dcfsnz lo,F | |
1425 movlw divemode_menu_item1_row | |
1426 dcfsnz lo,F | |
1427 movlw divemode_menu_item2_row | |
1428 dcfsnz lo,F | |
1429 movlw divemode_menu_item3_row | |
1430 dcfsnz lo,F | |
1431 movlw divemode_menu_item4_row | |
1432 dcfsnz lo,F | |
1433 movlw divemode_menu_item5_row | |
1434 movff WREG,win_top | |
1435 movlw FT_SMALL | |
1436 movff WREG,win_font | |
1437 STRCPY_PRINT "\xb7" ; print cursor | |
1438 return | |
1439 | |
1440 global TFT_temp_divemode | |
1441 TFT_temp_divemode: | |
1442 btfsc divemode_menu ; Is the dive mode menu shown? | |
1443 return ; Yes, return | |
1444 btfsc blinking_better_gas ; blinking better Gas? | |
1445 return ; Yes, no update of temperature now | |
1446 ; temperature | |
1447 WIN_SMALL dive_temp_column,dive_temp_row | |
1448 call TFT_standard_color | |
1449 bsf leftbind | |
1450 | |
1451 SAFE_2BYTE_COPY temperature, lo | |
1452 TSTOSS opt_units ; 0=°C, 1=°F | |
1453 bra TFT_temp_divemode_metric | |
1454 | |
1455 ;TFT_temp_divemode_imperial: | |
1456 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1457 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
1458 lfsr FSR2,buffer ; Overwrite "-" (There won't be less then -18°C underwater...) | |
1459 bsf ignore_digit5 ; Full degrees only | |
1460 output_16 | |
1461 STRCAT_TEXT tLogTunitF | |
1462 TFT_temp_divemode_common: | |
1463 bcf leftbind | |
1464 movlw .4 ; limit to three chars | |
1465 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1466 STRCAT_PRINT "" | |
1467 return ; Done. | |
1468 | |
1469 TFT_temp_divemode_metric: | |
1470 lfsr FSR2,buffer | |
1471 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1472 movlw d'3' | |
1473 movwf ignore_digits | |
1474 bsf ignore_digit5 ; Full degrees only | |
1475 output_16 | |
1476 STRCAT_TEXT tLogTunitC | |
1477 bra TFT_temp_divemode_common ; Done. | |
1478 | |
1479 TFT_active_setpoint: ; Show setpoint | |
1480 WIN_STD active_gas_column,active_gas_row | |
1481 call TFT_standard_color | |
1482 btfsc is_bailout ; =1: Bailout | |
1483 bra TFT_active_setpoint_bail ; Show "Bailout" instead of Setpoint | |
1484 | |
1485 lfsr FSR2,buffer | |
1486 movff char_I_const_ppO2,lo | |
1487 TFT_color_code warn_ppo2_hud ; With ppO2 [cbar] in lo | |
1488 clrf hi | |
1489 bsf leftbind | |
1490 output_16dp d'3' | |
1491 bcf leftbind | |
1492 STRCAT_TEXT tbar | |
1493 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor | |
1494 bra $+4 | |
1495 PUTC "*" | |
1496 STRCAT_PRINT "" | |
1497 | |
1498 TFT_active_setpoint_diluent: | |
1499 call TFT_standard_color | |
1500 WIN_SMALL active_dil_column,active_dil_row | |
1501 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1502 movff char_I_He_ratio,hi ; hi now stores He in % | |
1503 rcall TFT_show_dil_divemode2 ; Show diluent (Non-Inverted in all cases) | |
1504 | |
1505 btfss better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
1506 return ; Done. | |
1507 btg blinking_better_gas ; Toggle blink bit... | |
1508 btfss blinking_better_gas ; blink now? | |
1509 return ; No, Done. | |
1510 | |
1511 movlw color_yellow ; Blink in yellow | |
1512 call TFT_set_color | |
1513 WIN_SMALL_INVERT active_dil_column,active_dil_row | |
1514 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1515 movff char_I_He_ratio,hi ; hi now stores He in % | |
1516 rcall TFT_show_dil_divemode2 ; Show gas | |
1517 WIN_INVERT .0 ; Init new Wordprocessor | |
1518 call TFT_standard_color | |
1519 return ; Done. | |
1520 | |
1521 TFT_show_dil_divemode2: | |
1522 lfsr FSR2,buffer | |
1523 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1524 STRCAT_PRINT "" | |
1525 return | |
1526 | |
1527 TFT_active_setpoint_bail: | |
1528 STRCPY_TEXT_PRINT tDiveBailout ; Bailout | |
1529 bra TFT_active_setpoint_diluent | |
1530 | |
1531 global TFT_active_gas_divemode | |
1532 TFT_active_gas_divemode: ; Display gas/Setpoint | |
1533 btfsc divemode_menu ; Is the dive mode menu shown? | |
1534 return ; Yes, return | |
1535 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
1536 return | |
1537 btfsc FLAG_ccr_mode ; in CCR mode | |
1538 bra TFT_active_setpoint ; Yes, show setpoint | |
1539 | |
1540 call TFT_standard_color | |
1541 WIN_STD active_gas_column,active_gas_row | |
1542 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1543 movff char_I_He_ratio,hi ; hi now stores He in % | |
1544 rcall TFT_active_gas_divemode2 ; Show gas (Non-Inverted in all cases) | |
1545 btfss better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | |
1546 return ; Done. | |
1547 | |
1548 btg blinking_better_gas ; Toggle blink bit... | |
1549 btfss blinking_better_gas ; blink now? | |
1550 return ; No, Done. | |
1551 movlw color_yellow ; Blink in yellow | |
1552 call TFT_set_color | |
1553 WIN_STD_INVERT active_gas_column,active_gas_row | |
1554 movff char_I_O2_ratio,lo ; lo now stores O2 in % | |
1555 movff char_I_He_ratio,hi ; hi now stores He in % | |
1556 rcall TFT_active_gas_divemode2 ; Show gas (Non-Inverted in all cases) | |
1557 WIN_INVERT .0 ; Init new Wordprocessor | |
1558 call TFT_standard_color | |
1559 return ; Done. | |
1560 | |
1561 TFT_active_gas_divemode2: | |
1562 lfsr FSR2,buffer | |
1563 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1564 STRCAT_PRINT "" | |
1565 return | |
1566 | |
1567 global TFT_display_decotype_surface | |
1568 global TFT_display_decotype_surface1 ; Used from logbook! | |
1569 TFT_display_decotype_surface: | |
1570 WIN_STD surf_decotype_column,surf_decotype_row | |
1571 WIN_COLOR color_lightblue | |
1572 lfsr FSR2,buffer | |
1573 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea | |
1574 TFT_display_decotype_surface1: ; Used from logbook! | |
1575 tstfsz lo | |
1576 bra TFT_display_decotype_surface2 | |
1577 STRCAT_TEXT_PRINT tDvOC ; OC | |
1578 bra TFT_display_decotype_exit | |
1579 TFT_display_decotype_surface2: | |
1580 decfsz lo,F | |
1581 bra TFT_display_decotype_surface3 | |
1582 STRCAT_TEXT_PRINT tDvCC ; CC | |
1583 bra TFT_display_decotype_exit | |
1584 TFT_display_decotype_surface3: | |
1585 decfsz lo,F | |
1586 bra TFT_display_decotype_surface4 | |
1587 STRCAT_TEXT_PRINT tDvGauge ; Gauge | |
1588 bra TFT_display_decotype_exit | |
1589 TFT_display_decotype_surface4: | |
1590 STRCAT_TEXT_PRINT tDvApnea ; Apnea | |
1591 TFT_display_decotype_exit: | |
1592 call TFT_standard_color | |
1593 return | |
1594 ;============================================================================= | |
1595 | |
1596 global TFT_splist_surfmode ; Show Setpoint list | |
1597 extern gaslist_strcat_setpoint | |
1598 TFT_splist_surfmode: | |
1599 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1600 ;SP 1 | |
1601 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1602 lfsr FSR2,buffer | |
1603 clrf PRODL | |
1604 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1605 STRCAT_PRINT "" | |
1606 ;SP 2 | |
1607 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1608 lfsr FSR2,buffer | |
1609 movlw .1 | |
1610 movwf PRODL | |
1611 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1612 STRCAT_PRINT "" | |
1613 ;SP 3 | |
1614 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1615 lfsr FSR2,buffer | |
1616 movlw .2 | |
1617 movwf PRODL | |
1618 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1619 STRCAT_PRINT "" | |
1620 ;SP 4 | |
1621 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1622 lfsr FSR2,buffer | |
1623 movlw .3 | |
1624 movwf PRODL | |
1625 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1626 STRCAT_PRINT "" | |
1627 ;SP 5 | |
1628 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1629 lfsr FSR2,buffer | |
1630 movlw .4 | |
1631 movwf PRODL | |
1632 call gaslist_strcat_setpoint ; Show SP#+1 of PRODL# | |
1633 STRCAT_PRINT "" | |
1634 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1635 bcf leftbind | |
1636 return | |
1637 | |
1638 global TFT_gaslist_surfmode | |
1639 TFT_gaslist_surfmode: ; Displays Gas List | |
1640 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1641 extern gaslist_strcat_gas_mod | |
1642 ;Gas 1 | |
1643 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1644 lfsr FSR2,buffer | |
1645 movlw .0 | |
1646 movwf PRODL | |
1647 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1648 STRCAT_PRINT "" | |
1649 ;Gas 2 | |
1650 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1651 lfsr FSR2,buffer | |
1652 movlw .1 | |
1653 movwf PRODL | |
1654 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1655 STRCAT_PRINT "" | |
1656 ;Gas 3 | |
1657 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1658 lfsr FSR2,buffer | |
1659 movlw .2 | |
1660 movwf PRODL | |
1661 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1662 STRCAT_PRINT "" | |
1663 ;Gas 4 | |
1664 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1665 lfsr FSR2,buffer | |
1666 movlw .3 | |
1667 movwf PRODL | |
1668 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1669 STRCAT_PRINT "" | |
1670 ;Gas 5 | |
1671 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1672 lfsr FSR2,buffer | |
1673 movlw .4 | |
1674 movwf PRODL | |
1675 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1676 STRCAT_PRINT "" | |
1677 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1678 bcf leftbind | |
1679 return | |
1680 | |
1681 global TFT_dillist_surfmode | |
1682 TFT_dillist_surfmode: ; Displays Diluent List | |
1683 bsf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1684 ;Dil 1 | |
1685 WIN_SMALL surf_gaslist_column,surf_gaslist_row | |
1686 lfsr FSR2,buffer | |
1687 movlw .5 | |
1688 movwf PRODL | |
1689 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1690 STRCAT_PRINT "" | |
1691 ;Dil 2 | |
1692 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.1) | |
1693 lfsr FSR2,buffer | |
1694 movlw .6 | |
1695 movwf PRODL | |
1696 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1697 STRCAT_PRINT "" | |
1698 ;Dil 3 | |
1699 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.2) | |
1700 lfsr FSR2,buffer | |
1701 movlw .7 | |
1702 movwf PRODL | |
1703 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1704 STRCAT_PRINT "" | |
1705 ;Dil 4 | |
1706 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.3) | |
1707 lfsr FSR2,buffer | |
1708 movlw .8 | |
1709 movwf PRODL | |
1710 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1711 STRCAT_PRINT "" | |
1712 ;Dil 5 | |
1713 WIN_SMALL surf_gaslist_column,surf_gaslist_row+(surf_gaslist_spacing*.4) | |
1714 lfsr FSR2,buffer | |
1715 movlw .9 | |
1716 movwf PRODL | |
1717 call gaslist_strcat_gas_mod ;Append gas description of gas #PRODL (0-4) to current string | |
1718 STRCAT_PRINT "" | |
1719 bcf short_gas_decriptions ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint | |
1720 bcf leftbind | |
1721 return | |
1722 | |
1723 global TFT_depth | |
1724 TFT_depth: | |
1725 SAFE_2BYTE_COPY rel_pressure, lo | |
1726 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
1727 | |
1728 TSTOSS opt_units ; 0=m, 1=ft | |
1729 bra TFT_depth_metric | |
1730 ;TFT_depth_imperial | |
1731 WIN_LARGE depth_feet_column,depth_feet_row | |
1732 lfsr FSR2,buffer | |
1733 TFT_color_code warn_depth ; Color-code the output | |
1734 | |
1735 clrf sub_a+1 ; Display 0ft if lower then 30cm | |
1736 movlw d'30' | |
1737 movwf sub_a+0 | |
1738 movff hi,sub_b+1 | |
1739 movff lo,sub_b+0 | |
1740 call subU16 ; sub_c = sub_a - sub_b | |
1741 btfss neg_flag ; Depth lower then 0.4m? | |
1742 bra depth_less_0.3mtr_feet ; Yes, Show 0ft manually | |
1743 | |
1744 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
1745 bsf leftbind | |
1746 output_16 ; feet in Big font | |
1747 bcf leftbind | |
1748 movlw .3 ; limit to three chars | |
1749 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
1750 STRCAT_PRINT "" ; Display feet | |
1751 return | |
1752 | |
1753 depth_less_0.3mtr_feet: | |
1754 STRCAT_PRINT "0 " ; manual zero | |
1755 return | |
1756 | |
1757 TFT_depth_metric: | |
1758 WIN_LARGE depth_column,depth_row | |
1759 TFT_color_code warn_depth ; Color-code the output | |
1760 | |
1761 movlw .039 | |
1762 cpfslt hi | |
1763 bra depth_greater_99_84mtr | |
1764 | |
1765 btfsc depth_greater_100m ; Was depth>100m during last call | |
11 | 1766 rcall TFT_clear_depth ; Yes, clear depth area |
0 | 1767 bcf depth_greater_100m ; Do this once only... |
1768 | |
11 | 1769 movlw .039 |
1770 cpfslt hi | |
1771 bra depth_greater_99_84mtr | |
1772 | |
0 | 1773 lfsr FSR2,buffer |
1774 movlw HIGH d'1000' | |
1775 movwf sub_a+1 | |
1776 movlw LOW d'1000' | |
1777 movwf sub_a+0 | |
1778 movff hi,sub_b+1 | |
1779 movff lo,sub_b+0 | |
1780 incf sub_b+0,F | |
1781 movlw d'0' | |
1782 addwfc sub_b+1,F ; Add 1mbar offset | |
1783 call sub16 ; sub_c = sub_a - sub_b | |
1784 movlw ' ' | |
1785 btfss neg_flag ; Depth lower then 10m? | |
1786 movwf POSTINC2 ; Yes, add extra space | |
1787 | |
1788 clrf sub_a+1 | |
1789 movlw d'99' | |
1790 movwf sub_a+0 | |
1791 movff hi,sub_b+1 | |
1792 movff lo,sub_b+0 | |
1793 call subU16 ; sub_c = sub_a - sub_b | |
1794 btfss neg_flag ; Depth lower then 1m? | |
1795 bra tft_depth2 ; Yes, display manual Zero | |
1796 | |
1797 bsf leftbind | |
1798 bsf ignore_digit4 | |
1799 output_16 ; Full meters in Big font | |
1800 bcf leftbind | |
1801 bra tft_depth3 | |
1802 | |
1803 tft_depth2: | |
1804 WIN_LARGE depth_column,depth_row | |
1805 STRCAT "0" | |
1806 | |
1807 tft_depth3: | |
1808 STRCAT_PRINT "" ; Display full meters | |
1809 | |
1810 ; .1m in MEDIUM font | |
1811 WIN_MEDIUM depth_dm_column,depth_dm_row | |
1812 TFT_color_code warn_depth ; Color-code the output | |
1813 | |
1814 SAFE_2BYTE_COPY rel_pressure, lo | |
1815 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
1816 | |
1817 lfsr FSR2,buffer | |
1818 PUTC "." | |
1819 movlw HIGH d'30' ; Display 0.0m if lower then 30cm | |
1820 movwf sub_a+1 | |
1821 movlw LOW d'30' | |
1822 movwf sub_a+0 | |
1823 movff hi,sub_b+1 | |
1824 movff lo,sub_b+0 | |
1825 call subU16 ; sub_c = sub_a - sub_b | |
1826 btfss neg_flag ; Depth lower then 0.3m? | |
1827 bra depth_less_0.3mtr ; Yes, Show ".0" manually | |
1828 | |
1829 movlw d'4' | |
1830 movwf ignore_digits | |
1831 bsf ignore_digit5 | |
1832 output_16dp d'0' | |
1833 STRCAT_PRINT "" ; Display decimeters | |
1834 WIN_FONT FT_SMALL | |
1835 return | |
1836 | |
1837 depth_less_0.3mtr: | |
1838 STRCAT_PRINT "0" ; Display 0.0m manually | |
1839 WIN_FONT FT_SMALL | |
1840 return | |
1841 | |
1842 depth_greater_99_84mtr: ; Display only in full meters | |
1843 btfss depth_greater_100m ; Is depth>100m already? | |
1844 rcall TFT_clear_depth ; No, clear depth area and set flag | |
1845 ; Depth is already in hi:lo | |
1846 ; Show depth in Full meters | |
1847 ; That means ignore figure 4 and 5 | |
1848 lfsr FSR2,buffer | |
1849 bsf ignore_digit4 | |
1850 bsf leftbind | |
1851 output_16 | |
1852 bcf leftbind | |
1853 STRCAT_PRINT "" ; Display full meters only | |
1854 WIN_FONT FT_SMALL | |
1855 return | |
1856 | |
1857 TFT_clear_depth: ; No, clear depth area and set flag | |
1858 WIN_BOX_BLACK depth_row, .77,.0, max_depth_column-.1 ;top, bottom, left, right | |
1859 bsf depth_greater_100m ; Set Flag | |
1860 return | |
1861 | |
1862 ;============================================================================= | |
1863 | |
1864 ; global TFT_user_image | |
1865 ;TFT_user_image: | |
1866 ; ;---- Display user image ------------------------------------------------- | |
1867 ; ; Compute address in external EEPROM | |
1868 ; movff opt_skin,WREG | |
1869 ; mullw 0x50 | |
1870 ; movff PRODL,ext_flash_address+1 | |
1871 ; movf PRODH,W | |
1872 ; iorlw 0x30 | |
1873 ; movwf ext_flash_address+2 | |
1874 ; | |
1875 ; ; First pixel at @+4: | |
1876 ; movlw 4 | |
1877 ; movwf ext_flash_address+0 | |
1878 ; | |
1879 ; ; Read first pixel | |
1880 ; call ext_flash_read_block_start | |
1881 ;; movff SSP2BUF,skin_color+1 ; TFT format: HIGH is first... | |
1882 ; movwf SSP2BUF ; Write to buffer to initiate new read | |
1883 ; btfss SSP2STAT, BF ; Next byte ready ? | |
1884 ; bra $-2 ; NO: wait... | |
1885 ;; movff SSP2BUF,skin_color+0 | |
1886 ; call ext_flash_read_block_stop | |
1887 ; | |
1888 ; ; Make a frame of the retrieved skin color. | |
1889 ; setf win_color1 | |
1890 ; setf win_color2 | |
1891 ; WIN_FRAME_COLOR16 user_image_upper-.1, user_image_upper+.100,user_image_left-.1, user_image_left+.50 | |
1892 ; | |
1893 ; WIN_LEFT user_image_left+.25 | |
1894 ; WIN_TOP user_image_upper+.50 | |
1895 ; | |
1896 ; ; Display skin icon | |
1897 ; clrf ext_flash_address+0 | |
1898 ; call TFT_write_flash_image_addr | |
1899 ; | |
1900 ; ;---- Print custom text string | |
1901 ; WIN_LEFT user_image_left+.50+.5 | |
1902 ; WIN_TOP user_image_upper+.0 | |
1903 ; | |
1904 ; ; ---- STRNCPY : String copy from RAM | |
1905 ; ; lfsr FSR0, opt_name ; Source | |
1906 ; lfsr FSR1, .13 ; Len max | |
1907 ; lfsr FSR2, buffer ; destination | |
1908 ;TFT_user_image_1: | |
1909 ; movf POSTINC0,W ; Get byte | |
1910 ; bz TFT_user_image_2 ; End if NULL | |
1911 ; movwf POSTINC2 ; NO: copy | |
1912 ; decfsz FSR1L ; Max len reached ? | |
1913 ; bra TFT_user_image_1 ; NO: loop | |
1914 ;TFT_user_image_2: | |
1915 ; clrf POSTINC2 ; Mark end of string | |
1916 ; | |
1917 ; goto aa_wordprocessor ; and print | |
1918 | |
1919 | |
1920 global TFT_custom_text | |
1921 TFT_custom_text: ; Show the custom text | |
1922 lfsr FSR0, opt_name ; Source | |
1923 WIN_SMALL surf_customtext_column,surf_customtext_row1 ; First 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+.12 ; Source | |
1928 WIN_SMALL surf_customtext_column,surf_customtext_row2 ; Second 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+.24 ; Source | |
1933 WIN_SMALL surf_customtext_column,surf_customtext_row3 ; Third 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+.36 ; Source | |
1938 WIN_SMALL surf_customtext_column,surf_customtext_row4 ; Forth row | |
1939 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1940 incfsz lo,F ; Was lo=255? | |
1941 return ; No, all done. | |
1942 lfsr FSR0, opt_name+.48 ; Source | |
1943 WIN_SMALL surf_customtext_column,surf_customtext_row5 ; Fifth row | |
1944 rcall TFT_custom_text_2 ; Show up to 12 chars and print | |
1945 return ; Done. | |
1946 | |
1947 TFT_custom_text_2: | |
1948 lfsr FSR2, buffer ; destination | |
1949 movlw .12 | |
1950 movwf lo ; length/line | |
1951 TFT_custom_text_3: | |
1952 movf POSTINC0,W ; Get byte | |
1953 bz TFT_custom_text_4 ; End if NULL | |
1954 movwf POSTINC2 ; NO: copy | |
1955 decfsz lo,F ; Max len reached ? | |
1956 bra TFT_custom_text_3 ; NO: loop | |
1957 setf lo ; lo=255 -> more to come | |
1958 TFT_custom_text_4: | |
1959 clrf POSTINC2 ; Mark end of string | |
1960 goto aa_wordprocessor ; print and return | |
1961 | |
1962 | |
1963 ;============================================================================= | |
1964 global TFT_update_surf_press | |
1965 TFT_update_surf_press: | |
1966 WIN_SMALL surf_press_column,surf_press_row | |
1967 call TFT_standard_color | |
1968 SAFE_2BYTE_COPY amb_pressure, lo | |
1969 lfsr FSR2,buffer | |
1970 movff lo,sub_a+0 | |
1971 movff hi,sub_a+1 | |
1972 movff last_surfpressure_30min+0,sub_b+0 | |
1973 movff last_surfpressure_30min+1,sub_b+1 | |
1974 call subU16 ; sub_c = sub_a - sub_b | |
1975 btfsc neg_flag ; Pressure lower? | |
1976 rcall update_surf_press2 ; Yes, test threshold | |
1977 | |
1978 tstfsz sub_c+1 ; >255mbar difference? | |
1979 bra update_surf_press_common; Yes, display! | |
1980 movlw d'10' ; 10mbar noise suppression | |
1981 subwf sub_c+0,W | |
1982 btfsc STATUS,C | |
1983 bra update_surf_press_common; Yes, display! | |
1984 SAFE_2BYTE_COPY last_surfpressure_30min, lo ; Overwrite with stable value... | |
1985 | |
1986 update_surf_press_common: | |
1987 output_16 | |
1988 ; Show only 4 figures | |
1989 movff buffer+1,buffer+0 | |
1990 movff buffer+2,buffer+1 | |
1991 movff buffer+3,buffer+2 | |
1992 movff buffer+4,buffer+3 | |
1993 movlw 0x00 | |
1994 movff WREG,buffer+4 | |
1995 STRCAT_PRINT "" | |
1996 call TFT_divemask_color | |
1997 WIN_SMALL surf_press_column+4*8,surf_press_row | |
1998 STRCPY_PRINT "mbar" | |
1999 return | |
2000 | |
2001 update_surf_press2: | |
2002 movff lo,sub_b+0 | |
2003 movff hi,sub_b+1 | |
2004 movff last_surfpressure_30min+0,sub_a+0 | |
2005 movff last_surfpressure_30min+1,sub_a+1 | |
2006 call subU16 ; sub_c = sub_a - sub_b | |
2007 return | |
2008 | |
2009 ;============================================================================= | |
2010 | |
2011 global TFT_update_batt_voltage | |
2012 TFT_update_batt_voltage: | |
2013 movff batt_percent,lo ; Get battery percent | |
2014 TFT_color_code warn_battery; Color-code battery percent | |
2015 WIN_TINY batt_percent_column,batt_percent_row | |
2016 lfsr FSR2,buffer | |
2017 bsf leftbind | |
2018 output_8 | |
2019 bcf leftbind | |
2020 STRCAT_PRINT "%" | |
2021 call TFT_standard_color | |
2022 WIN_TINY batt_voltage_column,batt_voltage_row | |
2023 lfsr FSR2,buffer | |
2024 movff batt_voltage+0,lo | |
2025 movff batt_voltage+1,hi | |
2026 bsf leftbind | |
2027 output_16dp .2 | |
2028 bcf leftbind | |
2029 PUTC 'V' | |
2030 movff buffer+5,buffer+3 | |
2031 movlw 0x00 | |
2032 movff WREG,buffer+4 ; Only "x.yV" | |
24 | 2033 STRCAT_PRINT "" |
0 | 2034 return |
2035 | |
2036 ;update_battery_debug: | |
2037 ; call TFT_standard_color | |
2038 ; WIN_TINY .70,.0 | |
2039 ; lfsr FSR2,buffer | |
2040 ; movff battery_gauge+5,xC+3 | |
2041 ; movff battery_gauge+4,xC+2 | |
2042 ; movff battery_gauge+3,xC+1 | |
2043 ; movff battery_gauge+2,xC+0 | |
2044 ; ; battery_gauge:6 is nAs | |
2045 ; ; devide through 65536 | |
2046 ; ; devide through 152 | |
2047 ; ; Result is 0.01Ah in xC+1:xC+0 | |
2048 ; movlw LOW .152 | |
2049 ; movwf xB+0 | |
2050 ; movlw HIGH .152 | |
2051 ; movwf xB+1 | |
2052 ; call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
2053 ; bsf leftbind | |
2054 ; movff xC+0,lo | |
2055 ; movff xC+1,hi | |
2056 ; output_16 | |
2057 ; STRCAT_PRINT "x.01Ah" | |
2058 ; WIN_FONT FT_SMALL | |
2059 ; bcf leftbind | |
2060 ; return | |
2061 | |
2062 ;============================================================================= | |
2063 | |
2064 global TFT_convert_signed_16bit | |
2065 TFT_convert_signed_16bit: | |
2066 bcf neg_flag ; Positive temperature | |
2067 btfss hi,7 ; Negative temperature ? | |
2068 return ; No, return | |
2069 ; Yes, negative temperature! | |
2070 bsf neg_flag ; Negative temperature | |
2071 PUTC '-' ; Display "-" | |
2072 comf hi ; Then, 16bit sign changes. | |
2073 negf lo | |
2074 btfsc STATUS,C | |
2075 incf hi | |
2076 return ; and return | |
2077 | |
2078 ;============================================================================= | |
2079 | |
2080 global TFT_convert_date | |
2081 TFT_convert_date: ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
2082 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD | |
2083 movwf EEDATA ; used as temp here | |
2084 tstfsz EEDATA | |
2085 bra TFT_convert_date1 | |
2086 ; EEDATA was 0 | |
2087 ; Use MMDDYY | |
2088 movff convert_value_temp+0,lo ;month | |
2089 bsf leftbind | |
2090 output_99x | |
2091 PUTC '.' | |
2092 movff convert_value_temp+1,lo ;day | |
2093 bra TFT_convert_date1_common ;year | |
2094 | |
2095 TFT_convert_date1: ; Read date format (0=MMDDYY, 1=DDMMYY, 2=YYMMDD) | |
2096 decfsz EEDATA,F | |
2097 bra TFT_convert_date2 ; EEDATA was 2 | |
2098 ; EEDATA was 1 | |
2099 ; Use DDMMYY | |
2100 movff convert_value_temp+1,lo ;day | |
2101 bsf leftbind | |
2102 output_99x | |
2103 PUTC '.' | |
2104 movff convert_value_temp+0,lo ;month | |
2105 | |
2106 TFT_convert_date1_common: | |
2107 bsf leftbind | |
2108 output_99x | |
2109 PUTC '.' | |
2110 movff convert_value_temp+2,lo ;year | |
2111 output_99x | |
2112 bcf leftbind | |
2113 return | |
2114 | |
2115 TFT_convert_date2: | |
2116 ; Use YYMMDD | |
2117 movff convert_value_temp+2,lo ;year | |
2118 bsf leftbind | |
2119 output_99x | |
2120 PUTC '.' | |
2121 movff convert_value_temp+0,lo ;month | |
2122 output_99x | |
2123 PUTC '.' | |
2124 movff convert_value_temp+1,lo ;day | |
2125 output_99x | |
2126 bcf leftbind | |
2127 return | |
2128 | |
2129 ;============================================================================= | |
2130 | |
2131 global TFT_convert_date_short | |
2132 TFT_convert_date_short: ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
2133 movff opt_dateformat,WREG ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD | |
2134 movwf EEDATA ; used as temp here | |
2135 tstfsz EEDATA | |
2136 bra TFT_convert_date_short1 | |
2137 ; EEDATA was 0 | |
2138 ; Use MMDDYY | |
2139 TFT_convert_date_short_common: | |
2140 movff convert_value_temp+0,lo ;month | |
2141 bsf leftbind | |
2142 output_99x | |
2143 PUTC '.' | |
2144 movff convert_value_temp+1,lo ;day | |
2145 output_99x | |
2146 bcf leftbind | |
2147 return | |
2148 | |
2149 TFT_convert_date_short1: | |
2150 decfsz EEDATA,F | |
2151 bra TFT_convert_date_short_common ; EEDATA was 2 -> Use YYMMDD | |
2152 ; EEDATA was 1 | |
2153 ; Use DDMMYY | |
2154 movff convert_value_temp+1,lo ;day | |
2155 bsf leftbind | |
2156 output_99x | |
2157 PUTC '.' | |
2158 movff convert_value_temp+0,lo ;month | |
2159 output_99x | |
2160 bcf leftbind | |
2161 return | |
2162 | |
2163 ;============================================================================= | |
2164 | |
2165 global TFT_date | |
2166 TFT_date: | |
2167 WIN_TINY surf_date_column,surf_date_row ; Init new Wordprocessor | |
2168 call TFT_standard_color | |
2169 lfsr FSR2,buffer | |
2170 movff month,convert_value_temp+0 | |
2171 movff day,convert_value_temp+1 | |
2172 movff year,convert_value_temp+2 | |
2173 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
2174 STRCAT_PRINT "" | |
2175 return | |
2176 | |
2177 ;============================================================================= | |
2178 | |
2179 global TFT_max_pressure | |
2180 TFT_max_pressure: | |
2181 btfsc FLAG_apnoe_mode ; different display in apnoe mode | |
2182 bra TFT_max_pressure_apnoe | |
2183 TFT_max_pressure2: | |
2184 SAFE_2BYTE_COPY max_pressure, lo | |
2185 TFT_max_pressure3: | |
2186 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2187 TSTOSS opt_units ; 0=m, 1=ft | |
2188 bra TFT_max_pressure2_metric | |
2189 ;TFT_max_pressure2_imperial | |
2190 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2191 WIN_MEDIUM max_depth_feet_column,max_depth_feet_row | |
2192 lfsr FSR2,buffer | |
2193 call TFT_standard_color | |
2194 output_16_3 | |
2195 STRCAT_PRINT "" | |
2196 return | |
2197 | |
2198 TFT_max_pressure2_metric: | |
11 | 2199 WIN_MEDIUM max_depth_column,max_depth_row |
2200 | |
2201 movlw .039 | |
2202 cpfslt hi | |
2203 bra max_depth_greater_99_84mtr | |
2204 | |
2205 btfsc max_depth_greater_100m ; Was depth>100m during last call | |
2206 rcall TFT_clear_max_depth ; Yes, clear depth area | |
2207 bcf max_depth_greater_100m ; Do this once only... | |
2208 | |
2209 movlw .039 | |
2210 cpfslt hi | |
2211 bra max_depth_greater_99_84mtr | |
2212 | |
2213 lfsr FSR2,buffer | |
2214 movlw HIGH d'1000' | |
2215 movwf sub_a+1 | |
2216 movlw LOW d'1000' | |
2217 movwf sub_a+0 | |
2218 movff hi,sub_b+1 | |
2219 movff lo,sub_b+0 | |
2220 incf sub_b+0,F | |
2221 movlw d'0' | |
2222 addwfc sub_b+1,F ; Add 1mbar offset | |
2223 call sub16 ; sub_c = sub_a - sub_b | |
2224 movlw ' ' | |
2225 btfss neg_flag ; Depth lower then 10m? | |
2226 movwf POSTINC2 ; Yes, add extra space | |
2227 | |
2228 clrf sub_a+1 | |
2229 movlw d'99' | |
2230 movwf sub_a+0 | |
2231 movff hi,sub_b+1 | |
2232 movff lo,sub_b+0 | |
2233 call subU16 ; sub_c = sub_a - sub_b | |
2234 btfss neg_flag ; Depth lower then 1m? | |
2235 bra tft_max_depth2 ; Yes, display manual Zero | |
2236 | |
2237 bsf ignore_digit4 ; no 0.1m | |
2238 bsf leftbind | |
2239 output_16 | |
2240 bra tft_max_depth3 | |
2241 | |
2242 tft_max_depth2: | |
0 | 2243 WIN_MEDIUM max_depth_column,max_depth_row |
11 | 2244 STRCAT "0" |
2245 | |
2246 tft_max_depth3: | |
0 | 2247 call TFT_standard_color |
11 | 2248 STRCAT_PRINT "" ; Display full meters |
2249 bcf leftbind | |
2250 | |
2251 ; .1m in SMALL font | |
2252 WIN_SMALL max_depth_dm_column,max_depth_dm_row | |
2253 | |
2254 SAFE_2BYTE_COPY max_pressure, lo | |
2255 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2256 | |
2257 lfsr FSR2,buffer | |
2258 PUTC "." | |
2259 | |
2260 movlw d'4' | |
2261 movwf ignore_digits | |
2262 bsf ignore_digit5 | |
2263 bsf leftbind | |
2264 output_16dp d'0' | |
2265 STRCAT_PRINT "" ; Display decimeters | |
2266 bcf leftbind | |
2267 return | |
2268 | |
2269 max_depth_greater_99_84mtr: ; Display only in full meters | |
2270 btfss max_depth_greater_100m ; Is max depth>100m already? | |
2271 rcall TFT_clear_max_depth ; No, clear max depth area and set flag | |
2272 ; Max. Depth is already in hi:lo | |
2273 ; Show max. depth in Full meters | |
2274 ; That means ignore figure 4 and 5 | |
2275 lfsr FSR2,buffer | |
2276 bsf ignore_digit4 | |
2277 bsf leftbind | |
0 | 2278 output_16 |
11 | 2279 bcf leftbind |
2280 STRCAT_PRINT "" ; Display full meters only | |
2281 WIN_FONT FT_SMALL | |
0 | 2282 return |
2283 | |
11 | 2284 TFT_clear_max_depth: ; No, clear max. depth area and set flag |
2285 WIN_BOX_BLACK max_depth_row,.49,max_depth_column, max_depth_dm_column+.13 ;top, bottom, left, right | |
2286 bsf max_depth_greater_100m ; Set Flag | |
2287 return | |
2288 | |
2289 | |
0 | 2290 TFT_max_pressure_apnoe: |
2291 btfss FLAG_active_descent ; Are we descending? | |
2292 bra TFT_max_pressure2 ; Yes, show normal max. | |
2293 SAFE_2BYTE_COPY apnoe_max_pressure, lo | |
2294 bra TFT_max_pressure3 ; Show apnoe_max_pressure as max. depth | |
2295 | |
2296 global TFT_display_apnoe_last_max | |
2297 TFT_display_apnoe_last_max: | |
2298 call TFT_divemask_color | |
2299 WIN_TINY last_max_apnoe_text_column,last_max_apnoe_text_row | |
2300 STRCPY_TEXT_PRINT tApnoeMax | |
2301 | |
2302 call TFT_standard_color | |
2303 SAFE_2BYTE_COPY max_pressure, lo | |
2304 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
2305 TSTOSS opt_units ; 0=m, 1=ft | |
2306 bra TFT_display_apnoe_last_m_metric | |
2307 ;TFT_display_apnoe_last_max_imperial | |
2308 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2309 WIN_MEDIUM apnoe_last_max_depth_column,apnoe_last_max_depth_row | |
2310 lfsr FSR2,buffer | |
2311 output_16 | |
2312 STRCAT_PRINT "" | |
2313 return | |
2314 | |
2315 TFT_display_apnoe_last_m_metric: | |
2316 WIN_MEDIUM apnoe_last_max_depth_column,apnoe_last_max_depth_row | |
2317 lfsr FSR2,buffer | |
2318 bsf ignore_digit5 ; do not display 1cm depth | |
2319 output_16dp d'3' | |
2320 STRCAT_PRINT "" | |
2321 return | |
2322 | |
2323 ;============================================================================= | |
2324 global TFT_divemins | |
2325 TFT_divemins: | |
2326 movff divemins+0,lo | |
2327 movff divemins+1,hi | |
2328 | |
2329 btfsc no_more_divesecs ; Ignore seconds? | |
2330 bra TFT_divemins2 ; Show minutes only | |
2331 | |
2332 movlw .99 | |
2333 cpfsgt lo ; bigger then 99? | |
2334 bra TFT_divemins1 ; No show mins:secs | |
2335 ; Yes, remove second display for the rest of the dive and clear seconds | |
2336 bsf no_more_divesecs ; Set flag | |
2337 ; Clear rest of seconds | |
2338 WIN_BOX_BLACK divetime_row, warning1_row,divetime_column,.159 ;top, bottom, left, right | |
2339 bra TFT_divemins2 ; Show minutes only | |
2340 | |
2341 TFT_divemins1: | |
2342 WIN_MEDIUM divetime_column, divetime_row | |
2343 lfsr FSR2,buffer | |
2344 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2345 call TFT_standard_color | |
2346 STRCAT_PRINT "" ; Show minutes in large font | |
2347 | |
2348 WIN_SMALL divetime_secs_column, divetime_secs_row ; left position for two sec figures | |
2349 lfsr FSR2,buffer | |
2350 PUTC ':' | |
2351 bsf leftbind | |
2352 movff divesecs,lo | |
2353 output_99x | |
2354 bcf leftbind | |
2355 STRCAT_PRINT "" ; Show seconds in small font | |
2356 return | |
2357 | |
2358 TFT_divemins2: | |
2359 WIN_MEDIUM divetime_minsonly_column, divetime_row | |
2360 lfsr FSR2,buffer | |
2361 output_16 | |
2362 call TFT_standard_color | |
2363 STRCAT_PRINT "" ; Show minutes in large font | |
2364 return | |
2365 | |
2366 ;============================================================================= | |
2367 global TFT_display_apnoe_surface | |
2368 TFT_display_apnoe_surface: | |
2369 call TFT_divemask_color | |
2370 WIN_TINY surface_apnoe_text_column,surface_apnoe_text_row | |
2371 STRCPY_TEXT_PRINT tApnoeSurface | |
2372 | |
2373 call TFT_standard_color | |
2374 WIN_MEDIUM surface_time_apnoe_column, surface_time_apnoe_row | |
2375 movff apnoe_surface_mins,lo | |
2376 lfsr FSR2,buffer | |
2377 output_8 | |
2378 PUTC ':' | |
2379 movff apnoe_surface_secs,lo | |
2380 output_99x | |
2381 STRCAT_PRINT "" | |
2382 return | |
2383 | |
2384 global TFT_apnoe_clear_surface | |
2385 TFT_apnoe_clear_surface: | |
2386 ; Clear Surface timer.... | |
2387 WIN_BOX_BLACK surface_apnoe_text_row, .239, surface_apnoe_text_column, .159 ;top, bottom, left, right | |
2388 return | |
2389 | |
2390 global TFT_display_apnoe_descent | |
2391 TFT_display_apnoe_descent: ; Descent divetime | |
2392 movff apnoe_mins,lo | |
2393 clrf hi | |
2394 WIN_MEDIUM divetime_column, divetime_row | |
2395 lfsr FSR2,buffer | |
2396 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2397 call TFT_standard_color | |
2398 STRCAT_PRINT "" ; Show minutes in large font | |
2399 WIN_SMALL divetime_secs_column, divetime_secs_row ; left position for two sec figures | |
2400 lfsr FSR2,buffer | |
2401 PUTC ':' | |
2402 bsf leftbind | |
2403 movff apnoe_secs,lo | |
2404 output_99x | |
2405 bcf leftbind | |
2406 STRCAT_PRINT "" ; Show seconds in small font | |
38 | 2407 |
2408 | |
2409 call TFT_divemask_color | |
2410 WIN_TINY total_apnoe_text_column,total_apnoe_text_row | |
2411 STRCPY_TEXT_PRINT tApnoeTotal | |
2412 call TFT_standard_color | |
2413 movff divemins,lo | |
2414 clrf hi | |
2415 WIN_MEDIUM apnoe_total_divetime_column, apnoe_total_divetime_row | |
2416 lfsr FSR2,buffer | |
2417 output_16_3 ; displays only last three figures from a 16Bit value (0-999) | |
2418 call TFT_standard_color | |
2419 STRCAT_PRINT "" ; Show minutes in large font | |
2420 WIN_SMALL apnoe_total_divetime_secs_column, apnoe_total_divetime_secs_row ; left position for two sec figures | |
2421 lfsr FSR2,buffer | |
2422 PUTC ':' | |
2423 bsf leftbind | |
2424 movff divesecs,lo | |
2425 output_99x | |
2426 bcf leftbind | |
2427 STRCAT_PRINT "" ; Show seconds in small font | |
2428 | |
0 | 2429 return |
2430 | |
2431 ;============================================================================= | |
2432 ; Writes ostc3 #Serial and Firmware version in splash screen | |
2433 ; | |
2434 global TFT_serial | |
2435 TFT_serial: | |
2436 WIN_TINY .0,.239-.14 | |
2437 | |
2438 STRCPY "OSTC3 #" ; Won't translate that... | |
2439 rcall TFT_cat_serial | |
2440 | |
2441 STRCAT " v" | |
2442 rcall TFT_cat_firmware | |
2443 | |
2444 ifdef __DEBUG | |
2445 movlw color_grey ; Write header in blue when | |
2446 call TFT_set_color ; compiled in DEBUG mode... | |
2447 STRCAT_PRINT "DEBUG" | |
2448 call TFT_standard_color | |
2449 else | |
2450 call TFT_standard_color | |
2451 STRCAT_PRINT "" | |
2452 | |
2453 movlw softwareversion_beta ; =1: Beta, =0: Release | |
2454 decfsz WREG,F | |
2455 return ; Release version -> Return | |
2456 | |
2457 call TFT_warnings_color | |
2458 WIN_LEFT .160-4*9/2 ; Right pad. | |
2459 STRCPY_TEXT_PRINT tBeta | |
2460 call TFT_standard_color | |
2461 endif | |
2462 | |
2463 return | |
2464 | |
2465 | |
2466 | |
2467 ;============================================================================= | |
2468 ; For the Information menu: append firmware x.yy version. | |
2469 global info_menu_firmware | |
2470 extern tFirmware | |
2471 info_menu_firmware: | |
2472 lfsr FSR1,tFirmware | |
2473 call strcat_text | |
2474 TFT_cat_firmware: | |
2475 movlw softwareversion_x | |
2476 movwf lo | |
2477 bsf leftbind | |
2478 output_8 | |
2479 PUTC '.' | |
2480 movlw softwareversion_y | |
2481 movwf lo | |
2482 output_99x | |
2483 bcf leftbind | |
2484 return | |
2485 | |
2486 ;----------------------------------------------------------------------------- | |
2487 ; For the Information menu: append serial number ostc3#42. | |
2488 global info_menu_serial | |
2489 extern tSerial | |
2490 info_menu_serial: | |
2491 lfsr FSR1,tSerial | |
2492 call strcat_text | |
2493 TFT_cat_serial: | |
2494 clrf EEADRH | |
2495 clrf EEADR ; Get Serial number LOW | |
2496 call read_eeprom ; read byte | |
2497 movff EEDATA,lo | |
2498 incf EEADR,F ; Get Serial number HIGH | |
2499 call read_eeprom ; read byte | |
2500 movff EEDATA,hi | |
2501 | |
2502 bsf leftbind | |
2503 output_16 | |
2504 bcf leftbind | |
2505 return | |
2506 | |
2507 ;----------------------------------------------------------------------------- | |
2508 ; For the Information menu: Append total dives | |
2509 global info_menu_total_dives | |
2510 extern tTotalDives | |
2511 info_menu_total_dives: | |
2512 lfsr FSR1,tTotalDives | |
2513 call strcat_text | |
2514 TFT_cat_total_dives: | |
2515 read_int_eeprom .2 | |
2516 movff EEDATA,lo | |
2517 read_int_eeprom .3 | |
2518 movff EEDATA,hi | |
2519 bsf leftbind | |
2520 output_16 | |
2521 bcf leftbind | |
2522 return | |
2523 | |
2524 ;----------------------------------------------------------------------------- | |
2525 ; ppO2 menu | |
2526 global divesets_ppo2_max | |
2527 extern tPPO2Max | |
2528 extern tbar | |
2529 divesets_ppo2_max: | |
2530 lfsr FSR1,tPPO2Max | |
2531 call strcat_text | |
2532 movff opt_ppO2_max,lo | |
2533 movlw ppo2_warning_high | |
2534 divesets_ppo2_common: | |
2535 movwf up ; Save default value | |
2536 clrf hi | |
2537 bsf leftbind | |
2538 output_16dp d'3' | |
2539 bcf leftbind | |
2540 lfsr FSR1,tbar | |
2541 call strcat_text | |
2542 | |
2543 movf up,W ; Default value | |
2544 cpfseq lo ; Current value | |
2545 bra divesets_ppo2_common2 ; Not default, add * | |
2546 return ; Default, Done. | |
2547 divesets_ppo2_common2: | |
2548 PUTC "*" | |
2549 return ; Done. | |
2550 | |
2551 global divesets_ppo2_min | |
2552 extern tPPO2Min | |
2553 divesets_ppo2_min: | |
2554 lfsr FSR1,tPPO2Min | |
2555 call strcat_text | |
2556 movff opt_ppO2_min,lo | |
2557 movlw ppo2_warning_low | |
2558 bra divesets_ppo2_common | |
2559 | |
2560 ;============================================================================= | |
2561 | |
2562 global TFT_clear_warning_text | |
2563 TFT_clear_warning_text: | |
2564 btfss divemode ; in divemode? | |
2565 bra TFT_clear_warning_text2 ; No, setup for surface mode | |
2566 WIN_BOX_BLACK warning1_row, divemode_customview_row-3, warning1_column, warning_icon_column-3 ;top, bottom, left, right | |
2567 return | |
2568 TFT_clear_warning_text2: | |
2569 WIN_BOX_BLACK surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76 ;top, bottom, left, right | |
2570 return | |
2571 | |
2572 global TFT_clear_warning_text_2nd_row | |
2573 TFT_clear_warning_text_2nd_row: | |
2574 btfss divemode ; in divemode? | |
2575 bra TFT_clear_warning_text_2nd_2 ; No, setup for surface mode | |
2576 WIN_BOX_BLACK warning2_row, divemode_customview_row-3, warning2_column, warning_icon_column-3 ;top, bottom, left, right | |
2577 return | |
2578 TFT_clear_warning_text_2nd_2: | |
2579 WIN_BOX_BLACK surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76 ;top, bottom, left, right | |
2580 return | |
2581 | |
2582 global TFT_fillup_with_spaces | |
2583 TFT_fillup_with_spaces: ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2584 movwf lo ; save max. string length into lo | |
2585 movf FSR2L,W ; Get current string length | |
2586 subwf lo,F ; lo-WREG | |
2587 btfsc STATUS,N ; longer then #lo already? | |
2588 return ; Yes, done. | |
2589 tstfsz lo ; Zero? | |
2590 bra TFT_fillup_with_spaces2 ; No. | |
2591 return ; Yes, done. | |
2592 TFT_fillup_with_spaces2: | |
2593 PUTC " " ; Add one space | |
2594 decfsz lo,F ; All done? | |
2595 bra TFT_fillup_with_spaces2 ; No, loop | |
2596 return ; Done. | |
2597 | |
2598 global TFT_desaturation_time | |
2599 TFT_desaturation_time: | |
2600 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2601 tstfsz WREG ; Is there room for the warning? | |
2602 return ; No | |
2603 STRCPY "Desat:" | |
2604 movff desaturation_time+0,lo ; divide by 60... | |
2605 movff desaturation_time+1,hi | |
2606 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
2607 bsf leftbind | |
2608 movf lo,W | |
2609 movff hi,lo | |
2610 movwf hi ; exchange lo and hi... | |
2611 output_8 ; Hours | |
2612 PUTC ':' | |
2613 movff hi,lo ; Minutes | |
2614 output_99x | |
2615 bcf leftbind | |
2616 movlw surf_warning_length ; Only use surface string length | |
2617 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2618 STRCAT_PRINT "" | |
2619 return | |
2620 | |
2621 global TFT_nofly_time | |
2622 TFT_nofly_time: | |
2623 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2624 tstfsz WREG ; Is there room for the warning? | |
2625 return ; No | |
2626 STRCPY "NoFly:" | |
2627 movff nofly_time+0,lo ; divide by 60... | |
2628 movff nofly_time+1,hi | |
2629 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
2630 bsf leftbind | |
2631 movf lo,W | |
2632 movff hi,lo | |
2633 movwf hi ; exchange lo and hi... | |
2634 output_8 ; Hours | |
2635 PUTC ':' | |
2636 movff hi,lo ; Minutes | |
2637 output_99x | |
2638 bcf leftbind | |
2639 movlw surf_warning_length ; Only use surface string length | |
2640 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2641 STRCAT_PRINT "" | |
2642 return | |
2643 | |
2644 global TFT_warning_agf | |
2645 TFT_warning_agf: | |
2646 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2647 tstfsz WREG ; Is there room for the warning? | |
2648 return ; No | |
2649 call TFT_warnings_color | |
2650 STRCPY_TEXT tDiveaGF_active ; "aGF!" | |
2651 movlw warning_length ; Divemode string length | |
2652 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2653 STRCAT_PRINT "" | |
2654 call TFT_standard_color | |
2655 return | |
2656 | |
2657 global TFT_warning_gf | |
2658 TFT_warning_gf: ;GF | |
2659 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2660 tstfsz WREG ; Is there room for the warning? | |
2661 return ; No | |
2662 TFT_color_code warn_gf ; Color-code Output | |
2663 STRCPY "GF:" | |
2664 movff char_O_gradient_factor,lo ; gradient factor | |
2665 bsf leftbind | |
2666 output_8 | |
2667 PUTC "%" | |
2668 movlw warning_length ; Divemode string length | |
2669 btfss divemode ; In Divemode? | |
2670 movlw surf_warning_length ; No, use surface string length | |
2671 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2672 STRCAT_PRINT "" | |
2673 bcf leftbind | |
2674 call TFT_standard_color | |
2675 return | |
2676 | |
2677 TFT_warning_set_window: ; Sets the row and column for the current warning | |
2678 ; ignore warning (now)? | |
2679 decf warning_counter,W ; -1 | |
2680 bcf STATUS,C | |
2681 rrcf WREG,W ; (warning_counter-1)/2 | |
2682 cpfseq warning_page | |
2683 retlw .255 ; WREG <> 0 -> Warning window not defined | |
2684 | |
2685 call TFT_standard_color | |
2686 | |
2687 btfss divemode ; in divemode? | |
2688 bra TFT_warning_set_window3 ; No, setup for surface mode | |
2689 | |
2690 btfss warning_counter,0 ; Toggle with each warning | |
2691 bra TFT_warning_set_window2 | |
2692 WIN_SMALL warning1_column,warning1_row | |
2693 bcf second_row_warning ; =1: The second row contains a warning | |
2694 retlw .0 ; WREG=0 -> Warning window defined | |
2695 TFT_warning_set_window2: | |
2696 WIN_SMALL warning2_column,warning2_row | |
2697 bsf second_row_warning ; =1: The second row contains a warning | |
2698 retlw .0 ; WREG=0 -> Warning window defined | |
2699 | |
2700 TFT_warning_set_window3: | |
2701 btfss warning_counter,0 ; Toggle with each warning | |
2702 bra TFT_warning_set_window4 | |
2703 WIN_SMALL surf_warning1_column,surf_warning1_row | |
2704 bcf second_row_warning ; =1: The second row contains a warning | |
2705 retlw .0 ; WREG=0 -> Warning window defined | |
2706 TFT_warning_set_window4: | |
2707 WIN_SMALL surf_warning2_column,surf_warning2_row | |
2708 bsf second_row_warning ; =1: The second row contains a warning | |
2709 retlw .0 ; WREG=0 -> Warning window defined | |
2710 | |
2711 | |
2712 global TFT_update_batt_percent_divemode | |
2713 TFT_update_batt_percent_divemode: | |
2714 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
2715 tstfsz WREG ; Is there room for the warning? | |
2716 return ; No | |
2717 movff batt_percent,lo ; Get battery percent | |
2718 TFT_color_code warn_battery; Color-code battery percent | |
2719 STRCPY "Batt:" | |
2720 bsf leftbind | |
2721 output_8 | |
2722 bcf leftbind | |
2723 PUTC "%" | |
2724 movlw warning_length ; Divemode string length | |
2725 btfss divemode ; In Divemode? | |
2726 movlw surf_warning_length ; No, use surface string length | |
2727 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2728 STRCAT_PRINT "" | |
2729 call TFT_standard_color | |
2730 return | |
2731 | |
2732 | |
2733 global TFT_gf_mask ; Setup Mask | |
2734 TFT_gf_mask: | |
2735 ; The mask | |
2736 call TFT_divemask_color | |
2737 WIN_TINY dive_gf_column1,dive_gf_text_row | |
2738 STRCPY_TEXT_PRINT tGFactors | |
2739 WIN_TINY dive_gf_column2,dive_gf_text_row | |
2740 STRCPY_TEXT_PRINT taGFactors | |
2741 WIN_TINY dive_gf_column3,dive_gf_text_row | |
2742 STRCPY_TEXT_PRINT tGFInfo | |
2743 | |
2744 ; Show GF (Static) | |
2745 call TFT_disabled_color | |
2746 btfss use_agf | |
2747 call TFT_standard_color | |
2748 | |
2749 WIN_STD dive_gf_column,dive_gf_row | |
2750 lfsr FSR2,buffer | |
2751 bsf leftbind | |
2752 movff opt_GF_low,lo | |
2753 output_8 | |
2754 PUTC "/" | |
2755 movff opt_GF_high,lo | |
2756 output_8 | |
2757 STRCAT_PRINT "" | |
2758 ; Show aGF (Static) | |
2759 call TFT_standard_color | |
2760 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | |
2761 bra TFT_gf_mask2 ; Show "---" instead | |
2762 | |
2763 btfss use_agf | |
2764 call TFT_disabled_color | |
2765 | |
2766 WIN_STD dive_agf_column,dive_agf_row | |
2767 lfsr FSR2,buffer | |
2768 movff opt_aGF_low,lo | |
2769 output_8 | |
2770 PUTC "/" | |
2771 movff opt_aGF_high,lo | |
2772 output_8 | |
2773 STRCAT_PRINT "" | |
2774 bcf leftbind | |
2775 call TFT_standard_color | |
2776 return | |
2777 | |
2778 TFT_gf_mask2: | |
2779 WIN_STD dive_agf_column+.10,dive_agf_row | |
2780 STRCPY_PRINT "---" | |
2781 bcf leftbind | |
2782 return | |
2783 | |
2784 global TFT_gf_info ; Show GF informations | |
2785 TFT_gf_info: | |
2786 ; Show current GF | |
2787 movff char_O_gradient_factor,lo ; gradient factor absolute (Non-GF model) | |
2788 movff char_I_deco_model,hi | |
2789 decfsz hi,F ; jump over next line if char_I_deco_model == 1 | |
2790 movff char_O_relative_gradient_GF,lo ; gradient factor relative (GF model) | |
2791 WIN_STD dive_currentgf_column,dive_currentgf_row | |
2792 lfsr FSR2,buffer | |
2793 output_8 | |
2794 STRCAT_PRINT "%" | |
2795 return | |
2796 | |
2797 global TFT_ead_end_tissues_clock_mask ; Setup Mask | |
2798 TFT_ead_end_tissues_clock_mask: | |
2799 ; The mask | |
2800 call TFT_divemask_color | |
2801 ; Put three columns at HUD positions | |
2802 WIN_TINY dive_custom_hud_column1,dive_custom_hud_row | |
2803 STRCPY_TEXT_PRINT tDiveClock | |
2804 WIN_TINY dive_custom_hud_column2,dive_custom_hud_row | |
2805 STRCPY_TEXT_PRINT tDiveEAD_END | |
2806 WIN_TINY dive_custom_hud_column3,dive_custom_hud_row | |
2807 STRCPY_TEXT_PRINT tDiveTissues | |
2808 call TFT_standard_color | |
2809 return | |
2810 | |
2811 global TFT_ead_end_tissues_clock ; Show EAD/END, Tissues and clock | |
2812 TFT_ead_end_tissues_clock: | |
2813 ; Update clock and date | |
2814 WIN_SMALL dive_clock_column,dive_clock_row | |
2815 call TFT_clock2 ; print clock | |
2816 ; WIN_SMALL dive_date_column,dive_date_row | |
2817 ; lfsr FSR2,buffer | |
2818 ; movff month,convert_value_temp+0 | |
2819 ; movff day,convert_value_temp+1 | |
2820 ; movff year,convert_value_temp+2 | |
2821 ; rcall TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" in postinc2 | |
2822 ; STRCAT_PRINT "." | |
2823 | |
2824 ; Show END/EAD | |
2825 WIN_SMALL dive_ead_column,dive_ead_row | |
2826 STRCPY_TEXT tEAD ; EAD: | |
2827 movff char_O_EAD,lo | |
2828 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
2829 WIN_SMALL dive_end_column,dive_end_row | |
2830 STRCPY_TEXT tEND ; END: | |
2831 movff char_O_END,lo | |
2832 rcall TFT_end_ead_common ; print "lo m" (or ft) and limit to 8 chars | |
2833 | |
2834 ; Show tissue diagram | |
2835 call TFT_divemask_color | |
2836 WIN_TINY dive_tissue_N2_column,dive_tissue_N2_row | |
2837 STRCPY_TEXT_PRINT tN2 | |
2838 WIN_TINY dive_tissue_He_column,dive_tissue_He_row | |
2839 STRCPY_TEXT_PRINT tHe | |
2840 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
2841 movlb b'00000001' ; select ram bank 1 | |
2842 rcall DISP_tissue_saturation_graph ; Show char_O_tissue_N2_saturation and char_O_tissue_He_saturation | |
2843 return | |
2844 | |
2845 TFT_end_ead_common: ; print "lo m" (or ft) and limit to 8 chars | |
2846 bsf leftbind | |
2847 TSTOSS opt_units ; 0=Meters, 1=Feets | |
2848 bra TFT_end_ead_common_metric | |
2849 ;TFT_end_ead_common_imperial: | |
2850 ; With lo in m | |
2851 movf lo,W | |
2852 mullw .100 ; PRODL:PRODH = mbar/min | |
2853 movff PRODL,lo | |
2854 movff PRODH,hi | |
2855 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
2856 output_16_3 | |
2857 STRCAT_TEXT tFeets | |
2858 clrf WREG | |
2859 movff WREG,buffer+.8 ; limit string length to 8 | |
2860 bra TFT_end_ead_common_exit | |
2861 TFT_end_ead_common_metric: | |
2862 output_8 | |
2863 STRCAT_TEXT tMeters | |
2864 TFT_end_ead_common_exit: | |
2865 bcf leftbind | |
2866 movlw .8 | |
2867 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
2868 STRCAT_PRINT "" | |
2869 return | |
2870 | |
2871 global TFT_surface_tissues | |
2872 TFT_surface_tissues: ; Show Tissue diagram in surface mode | |
2873 WIN_SMALL surf_tissue_N2_column,surf_tissue_N2_row | |
2874 STRCPY_TEXT_PRINT tN2 | |
2875 WIN_SMALL surf_tissue_He_column,surf_tissue_He_row | |
2876 STRCPY_TEXT_PRINT tHe | |
2877 | |
2878 call deco_calc_desaturation_time ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation) | |
2879 movlb b'00000001' ; select ram bank 1 | |
2880 | |
2881 movlw color_deepblue | |
2882 call TFT_set_color ; Make this configurable? | |
2883 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.29,.29 | |
2884 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.37,.37 | |
2885 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.45,.45 | |
2886 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.53,.53 | |
2887 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.61,.61 | |
2888 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.69,.69 | |
2889 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.77,.77 | |
2890 WIN_FRAME_COLOR16 surf_tissue_diagram_top+.23,surf_tissue_diagram_bottom-.4,.85,.85 | |
2891 WIN_FRAME_STD surf_tissue_diagram_top, surf_tissue_diagram_bottom, surf_tissue_diagram_left, surf_tissue_diagram_right ; outer frame | |
2892 | |
2893 movlw .1 | |
2894 movff WREG,win_height ; row bottom (0-239) | |
2895 movlw surf_tissue_diagram_left+.4 ; Surface mode | |
2896 movff WREG,win_leftx2 ; column left (0-159) | |
2897 movlw surf_tissue_diagram_right-surf_tissue_diagram_left-4 ; Width | |
2898 movff WREG,win_width | |
2899 | |
2900 ;---- Draw N2 Tissues | |
2901 lfsr FSR2, char_O_tissue_N2_saturation | |
2902 movlw d'16' | |
2903 movwf wait_temp ; 16 tissues | |
2904 clrf waitms_temp ; Row offset | |
2905 surf_tissue_saturation_graph_N2: | |
2906 movlw surf_tissue_diagram_top+.23 ; surface mode | |
2907 addwf waitms_temp,W | |
2908 movff WREG,win_top ; row top (0-239) | |
2909 rcall surf_tissue_saturation_loop ; Show one tissue | |
2910 decfsz wait_temp,F | |
2911 bra surf_tissue_saturation_graph_N2 | |
2912 | |
2913 ;---- Draw He Tissues ---------------------------------------------------- | |
2914 lfsr FSR2, char_O_tissue_He_saturation | |
2915 movlw d'16' | |
2916 movwf wait_temp ; 16 tissues | |
2917 clrf waitms_temp ; Row offset | |
2918 surf_tissue_saturation_graph_He: | |
2919 movlw surf_tissue_diagram_top+.23+.56 ; surface mode | |
2920 addwf waitms_temp,W | |
2921 movff WREG,win_top ; row top (0-239) | |
2922 rcall surf_tissue_saturation_loop ; Show one tissue | |
2923 decfsz wait_temp,F | |
2924 bra surf_tissue_saturation_graph_He | |
2925 return | |
2926 | |
2927 surf_tissue_saturation_loop: | |
2928 call TFT_standard_color | |
2929 movlw .2 ; row spacing | |
2930 addwf waitms_temp,F | |
2931 movf POSTINC2,W ; Get tissue load | |
2932 bcf STATUS,C | |
2933 rrcf WREG ; And divide by 2 | |
2934 movwf temp1 | |
2935 movlw .20 | |
2936 subwf temp1,F ; Subtract some offset | |
2937 movff win_width,WREG ; Max width. | |
2938 cpfslt temp1 ; skip if WREG < win_width | |
2939 movwf temp1 | |
2940 movff temp1,win_bargraph | |
2941 call TFT_box | |
2942 return | |
2943 | |
2944 ;============================================================================= | |
2945 ; Draw saturation graph, is surface mode or in dive mode. | |
2946 DISP_tissue_saturation_graph: | |
2947 ;---- Draw Frame | |
2948 WIN_FRAME_STD tissue_diagram_top, tissue_diagram_bottom, tissue_diagram_left, .159 ; outer frame | |
2949 | |
2950 movlw .1 | |
2951 movff WREG,win_height ; row bottom (0-239) | |
2952 movlw tissue_diagram_left+.3 ; divemode | |
2953 movff WREG,win_leftx2 ; column left (0-159) | |
2954 movlw .159-tissue_diagram_left-4 ; Width | |
2955 movff WREG,win_width | |
2956 | |
2957 ;---- Draw N2 Tissues | |
2958 lfsr FSR2, char_O_tissue_N2_saturation | |
2959 movlw d'16' | |
2960 movwf wait_temp ; 16 tissues | |
2961 clrf waitms_temp ; Row offset | |
2962 tissue_saturation_graph_N2: | |
2963 movlw tissue_diagram_top+3 ; divemode | |
2964 addwf waitms_temp,W | |
2965 movff WREG,win_top ; row top (0-239) | |
2966 rcall tissue_saturation_graph_loop ; Show one tissue | |
2967 decfsz wait_temp,F | |
2968 bra tissue_saturation_graph_N2 | |
2969 | |
2970 ;---- Draw He Tissues ---------------------------------------------------- | |
2971 lfsr FSR2, char_O_tissue_He_saturation | |
2972 movlw d'16' | |
2973 movwf wait_temp ; 16 tissues | |
2974 clrf waitms_temp ; Row offset | |
2975 tissue_saturation_graph_He: | |
2976 movlw tissue_diagram_top+3+.22 ; divemode | |
2977 addwf waitms_temp,W | |
2978 movff WREG,win_top ; row top (0-239) | |
2979 | |
2980 rcall tissue_saturation_graph_loop ; Show one tissue | |
2981 | |
2982 decfsz wait_temp,F | |
2983 bra tissue_saturation_graph_He | |
2984 return | |
2985 | |
2986 tissue_saturation_graph_loop: | |
2987 call TFT_standard_color | |
2988 incf waitms_temp,F | |
2989 movf POSTINC2,W | |
2990 bcf STATUS,C | |
2991 rrcf WREG | |
2992 bcf STATUS,C | |
2993 rrcf WREG ; And divide by 4 | |
2994 movwf temp1 | |
2995 movlw .12 | |
2996 subwf temp1,F ; Subtract some offset | |
2997 movff win_width,WREG ; Max width. | |
2998 cpfslt temp1 ; skip if WREG < win_width | |
2999 movwf temp1 | |
3000 movff temp1,win_bargraph | |
3001 call TFT_box | |
3002 return | |
3003 | |
3004 global TFT_display_cns | |
3005 TFT_display_cns: | |
3006 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3007 tstfsz WREG ; Is there room for the warning? | |
3008 return ; No | |
3009 TFT_color_code warn_cns ; Color-code CNS output | |
3010 STRCPY_TEXT tCNS2 ; CNS: | |
3011 movff int_O_CNS_fraction+0,lo | |
3012 movff int_O_CNS_fraction+1,hi | |
3013 bsf leftbind | |
3014 output_16_3 ;Displays only 0...999 | |
3015 bcf leftbind | |
3016 PUTC "%" | |
3017 movlw warning_length ; Divemode string length | |
3018 btfss divemode ; In Divemode? | |
3019 movlw surf_warning_length ; No, use surface string length | |
3020 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3021 STRCAT_PRINT "" | |
3022 call TFT_standard_color | |
3023 return | |
3024 | |
3025 global TFT_display_ppo2 | |
3026 TFT_display_ppo2: ; Show ppO2 (ppO2 stored in xC, in mbar!) | |
3027 rcall TFT_warning_set_window ; Sets the row and column for the current warning | |
3028 tstfsz WREG ; Is there room for the warning? | |
3029 return ; No | |
3030 TFT_color_code warn_ppo2 ; Color-code output (ppO2 stored in xC) | |
3031 STRCPY "O2:" | |
3032 ; Check very high ppO2 manually | |
3033 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
3034 bra TFT_show_ppO2_3 ; Yes, display fixed Value! | |
3035 movff xC+0,lo | |
3036 movff xC+1,hi | |
3037 bsf ignore_digit4 | |
3038 output_16dp d'1' | |
3039 TFT_show_ppO2_2: | |
3040 movlw warning_length ; Divemode string length | |
3041 rcall TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
3042 STRCAT_PRINT "" | |
3043 call TFT_standard_color | |
3044 return | |
3045 | |
3046 TFT_show_ppO2_3: | |
3047 STRCAT ">6.6" | |
3048 bra TFT_show_ppO2_2 | |
3049 | |
3050 | |
3051 global TFT_LogOffset_Logtitle | |
3052 TFT_LogOffset_Logtitle: | |
3053 STRCPY_TEXT tLogOffset | |
3054 PUTC ":" | |
3055 call do_logoffset_common_read ; Offset into lo:hi | |
3056 bsf leftbind | |
3057 output_16 | |
3058 bcf leftbind | |
3059 PUTC " " | |
3060 return ; No "_PRINT" here... | |
3061 | |
3062 | |
3063 global adjust_depth_with_salinity | |
3064 adjust_depth_with_salinity: ; computes salinity setting into lo:hi [mbar] | |
3065 btfsc simulatormode_active ; Do apply salinity in Simulatormode | |
3066 return | |
3067 | |
3068 movff opt_salinity,WREG ; 0-5% | |
3069 addlw d'100' ; 1.00kg/l | |
3070 movwf wait_temp | |
3071 | |
3072 movlw d'105' ; 105% ? | |
3073 cpfslt wait_temp ; Salinity higher limit | |
3074 return ; Out of limit, do not adjust lo:hi | |
3075 movlw d'99' ; 99% ? | |
3076 cpfsgt wait_temp ; Salinity lower limit | |
3077 return ; Out of limit, do not adjust lo:hi | |
3078 | |
3079 movff lo,xA+0 | |
3080 movff hi,xA+1 | |
3081 | |
3082 movlw d'102' ; 0,98bar/10m | |
3083 movwf xB+0 | |
3084 clrf xB+1 | |
3085 call mult16x16 ;xA*xB=xC (lo:hi * 100) | |
3086 movff wait_temp,xB+0 ; Salinity | |
3087 clrf xB+1 | |
3088 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3089 movff xC+0,lo | |
3090 movff xC+1,hi ; restore lo and hi with updated value | |
3091 return | |
3092 | |
3093 global convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
3094 convert_mbar_to_feet: ; convert value in lo:hi from mbar to feet | |
3095 movff lo,xA+0 | |
3096 movff hi,xA+1 | |
3097 | |
3098 movlw LOW d'328' ; 328feet/100m | |
3099 movwf xB+0 | |
3100 movlw HIGH d'328' | |
3101 movwf xB+1 | |
3102 | |
3103 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
3104 | |
3105 movlw d'50' ; round up | |
3106 addwf xC+0,F | |
3107 movlw 0 | |
3108 addwfc xC+1,F | |
3109 addwfc xC+2,F | |
3110 addwfc xC+3,F | |
3111 | |
3112 movlw LOW .10000 | |
3113 movwf xB+0 | |
3114 movlw HIGH .10000 | |
3115 movwf xB+1 | |
3116 | |
3117 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3118 | |
3119 movff xC+0,lo | |
3120 movff xC+1,hi ; restore lo and hi with updated value | |
3121 return | |
3122 | |
3123 global convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
3124 convert_celsius_to_fahrenheit: ; convert value in lo:hi from celsius to fahrenheit | |
3125 ; Does it work with signed temperature? mH | |
3126 movff lo,xA+0 | |
3127 movff hi,xA+1 | |
3128 | |
3129 movlw d'18' ; 1C = 1.8F | |
3130 movwf xB+0 | |
3131 clrf xB+1 | |
3132 | |
3133 call mult16x16 ;xA*xB=xC (lo:hi * 18) | |
3134 | |
3135 movlw d'10' | |
3136 movwf xB+0 | |
3137 clrf xB+1 | |
3138 | |
3139 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3140 | |
3141 movlw LOW d'320' ; 0C = 32F | |
3142 addwf xC+0,F | |
3143 movlw HIGH d'320' | |
3144 addwfc xC+1,F | |
3145 | |
3146 movff xC+0,lo | |
3147 movff xC+1,hi ; restore lo and hi with updated value | |
3148 return | |
3149 | |
3150 END |