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