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