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