Mercurial > public > hwos_code
comparison src/logbook.asm @ 634:4050675965ea
3.10 stable release
author | heinrichsweikamp |
---|---|
date | Tue, 28 Apr 2020 17:34:31 +0200 |
parents | 185ba2f91f59 |
children | 8c1f1f334275 |
comparison
equal
deleted
inserted
replaced
633:690c48db7b5b | 634:4050675965ea |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File logbook.asm combined next generation V3.08.8 | 3 ; File logbook.asm * combined next generation V3.09.5 |
4 ; | 4 ; |
5 ; Logbook | 5 ; Logbook |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
24 #include "start.inc" | 24 #include "start.inc" |
25 #include "surfmode.inc" | 25 #include "surfmode.inc" |
26 #include "divemode.inc" | 26 #include "divemode.inc" |
27 #include "ghostwriter.inc" | 27 #include "ghostwriter.inc" |
28 #include "rtc.inc" | 28 #include "rtc.inc" |
29 #include "gaslist.inc" | |
30 #include "colorschemes.inc" | |
29 | 31 |
30 #DEFINE inside_loogbook | 32 #DEFINE inside_loogbook |
31 #include "logbook.inc" | 33 #include "logbook.inc" |
32 | 34 |
33 | 35 |
34 extern do_main_menu2 | 36 extern main_menu |
35 extern gaslist_show_mix | 37 |
36 | 38 |
37 | 39 ;---- Private local Variables ------------------------------------------------ |
38 ;---- Private local variables ------------------------------------------------ | |
39 | 40 |
40 CBLOCK local1 ; max size is 16 byte !!! | 41 CBLOCK local1 ; max size is 16 byte !!! |
41 count_temperature ; current sample count for temperature divisor | 42 count_temperature ; current sample count for temperature divisor |
42 count_deco ; current sample count for deco (ceiling) divisor | 43 count_deco ; current sample count for deco (ceiling) divisor |
43 logbook_cur_depth:2 ; current depth, for drawing profile | 44 logbook_cur_depth:2 ; current depth, for drawing profile |
83 divisor_tank ; divisor used while sampling of the dive data | 84 divisor_tank ; divisor used while sampling of the dive data |
84 total_num_dives ; total number of dives (low byte on) | 85 total_num_dives ; total number of dives (low byte on) |
85 ENDC ; used: 16 byte, remaining: 0 byte => full | 86 ENDC ; used: 16 byte, remaining: 0 byte => full |
86 | 87 |
87 | 88 |
88 ; Remarks: The variable gaslist_gas is "misused" here as a local variable, | 89 ; Remark: This code includes decoding and displaying of log data for Trimix |
89 ; because the storage space for local variables is fully used up. | |
90 ; | |
91 ; This code includes decoding and displaying of log data for Trimix | |
92 ; and CCR/pSCR dives to make sure that if such dives are in the | 90 ; and CCR/pSCR dives to make sure that if such dives are in the |
93 ; logbook they will be displayed correctly. | 91 ; logbook they will be displayed correctly. |
94 | 92 |
95 ;---- Defines ---------------------------------------------------------------- | 93 ;---- Defines ---------------------------------------------------------------- |
96 | 94 |
190 ; Air pressure | 188 ; Air pressure |
191 #DEFINE MBAR_row .10*.16+log2_salinity_row | 189 #DEFINE MBAR_row .10*.16+log2_salinity_row |
192 #DEFINE MBAR_column log2_salinity_column | 190 #DEFINE MBAR_column log2_salinity_column |
193 | 191 |
194 | 192 |
193 ;============================================================================= | |
195 logbook CODE | 194 logbook CODE |
196 | |
197 ;============================================================================= | 195 ;============================================================================= |
198 | 196 |
197 ;----------------------------------------------------------------------------- | |
198 ; Helper Function - show the Cursor | |
199 ; | |
199 TFT_logbook_cursor: | 200 TFT_logbook_cursor: |
200 WIN_BOX_BLACK .0, .239, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right | 201 WIN_BOX_BLACK .0, .239, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right |
201 | 202 |
202 WIN_LEFT logbook_list_left-.8 ; set horizontal position | 203 WIN_LEFT logbook_list_left-.8 ; set horizontal position |
203 WIN_FONT FT_SMALL ; select small font | 204 FONT_SIZE FT_SMALL ; set font size |
204 call TFT_standard_color ; print in white color | 205 FONT_COLOR_MEMO ; set font color |
205 decf menu_pos_cur,W ; get row number -1 into WREG | 206 decf menu_pos_cur,W ; get row number -1 into WREG |
206 mullw logbook_row_offset ; multiply with vertical offset between rows | 207 mullw logbook_row_offset ; multiply with vertical offset between rows |
207 movff PRODL,win_top ; set vertical position | 208 movff PRODL,win_top ; set vertical position |
208 STRCPY_PRINT "\xB7" ; print cursor | 209 STRCPY_PRINT "\xB7" ; print cursor |
209 return ; done | 210 return ; done |
210 | 211 |
211 | 212 |
212 global logbook ; entry point coming from menu_tree.asm | 213 ;----------------------------------------------------------------------------- |
214 ; Entry Point coming from Surface Menu | |
215 ; | |
216 global logbook | |
213 logbook: | 217 logbook: |
214 call TFT_boot | 218 call TFT_boot ; initialize display |
215 ; call TFT_standard_color | |
216 | 219 |
217 clrf logbook_flags ; clear all flags | 220 clrf logbook_flags ; clear all flags |
218 clrf menu_pos_max ; clear number of used rows on current page | 221 clrf menu_pos_max ; clear number of used rows on current page |
219 clrf logbook_page_number ; here: # of current displayed page | 222 clrf logbook_page_number ; clear # of current displayed page |
220 clrf logbook_divenumber ; # of dive in list during search | 223 clrf logbook_divenumber ; clear # of dive in list during search |
221 clrf logbook_temp | 224 clrf logbook_temp ; clear temps |
222 clrf logbook_temp_backup | 225 clrf logbook_temp_backup ; ... |
223 | 226 |
224 movlw logbook_row_number ; get number of dive entry rows per list | 227 movlw logbook_row_number ; get number of dive entry rows per list |
225 movwf menu_pos_cur ; initialize cursor position to last entry | 228 movwf menu_pos_cur ; initialize cursor position to last entry |
226 | 229 |
227 call eeprom_total_dives_read ; read total number of dives | 230 call eeprom_total_dives_read ; read total number of dives |
228 movf mpr+0,W ; extract low byte | 231 movf mpr+0,W ; extract low byte |
229 movwf logbook_max_dive_counter ; copy to logbook_max_dive_counter | 232 movwf logbook_max_dive_counter ; copy to logbook_max_dive_counter |
230 movwf total_num_dives ; copy to total_num_dives, too | 233 movwf total_num_dives ; copy to total_num_dives, too |
231 | 234 |
232 | |
233 ;----------------------------------------------------------------------------- | |
234 ; display dive headers backwards from latest dive to first dive, stop when | |
235 ; - no dive is stored (no valid header found) | |
236 ; - current dive has no valid header (past last dive, < 256 dives) | |
237 ; - when 255 dives are reached (logbook display limit) | |
238 | |
239 logbook2: | 235 logbook2: |
236 | |
237 ; display dive headers backwards from latest dive to first dive, | |
238 ; stop when - no dive is stored (no valid header found) | |
239 ; - current dive has no valid header (past last dive, < 256 dives) | |
240 ; - 255 dives are reached (logbook display limit) | |
241 | |
240 incf logbook_temp,F ; increase dive counter | 242 incf logbook_temp,F ; increase dive counter |
241 incf logbook_temp,W ; = 0x..FF ? | 243 incf logbook_temp,W ; = 0x..FF ? |
242 bz logbook_reset ; YES - loop | 244 bz logbook_reset ; YES - loop |
243 | 245 |
244 ; compute index for dive to show / goto previous dive | 246 ; compute index for dive to show / goto previous dive |
245 decf logbook_max_dive_counter,F | 247 decf logbook_max_dive_counter,F |
246 | 248 |
247 ; compute the start address of the header of the dive to show | |
248 movf logbook_max_dive_counter,W ; hand over index in WREG | |
249 call log_header_addr_by_index ; compute address of header start | |
250 | |
251 ; copy the first 22 byte of the header from FLASH to memory | 249 ; copy the first 22 byte of the header from FLASH to memory |
252 FLASH_RR_READ mpr,header_buffer,.22 | 250 movf logbook_max_dive_counter,W ; hand over header index in WREG |
251 call log_header_addr_by_index ; compute start address of the header | |
252 FLASH_RR_READ header_buffer,.22 ; copy first 22 bytes of header from FLASH to memory | |
253 | 253 |
254 ; check if there is a header | 254 ; check if there is a header |
255 MOVCC header_buffer+index_header_start,WREG ; read first byte of header | 255 MOVCC header_buffer+index_header_start,WREG ; read first byte of header |
256 xorlw 0xFA ; header start code found? | 256 xorlw 0xFA ; header start code found? |
257 bnz logbook3b ; NO - abort | 257 bnz logbook3b ; NO - abort |
273 bra logbook_display_loop2 ; check number of dives on page and append navigation | 273 bra logbook_display_loop2 ; check number of dives on page and append navigation |
274 | 274 |
275 logbook4: | 275 logbook4: |
276 btfsc all_dives_shown ; all dives shown? | 276 btfsc all_dives_shown ; all dives shown? |
277 bra logbook_display_loop2 ; YES - page done | 277 bra logbook_display_loop2 ; YES - page done |
278 call display_listdive ; NO - display short header for list on current list position | 278 call display_listdive ; NO - display dive summery on current list position |
279 movlw logbook_row_number ; - load max number of lines | 279 movlw logbook_row_number ; - load max number of lines |
280 cpfseq menu_pos_cur ; - cursor on last line (exit)? | 280 cpfseq menu_pos_cur ; - cursor on last line (exit)? |
281 bra logbook_display_loop1 ; NO - skip saving of address | 281 bra logbook_display_loop1 ; NO - skip saving of address |
282 | 282 |
283 ; store all registers required to rebuilt the current logbook page after the detail/profile view | 283 ; store all registers required to rebuilt the current logbook page after the detail/profile view |
335 ;bra exit_logbook ; YES - exit logbook | 335 ;bra exit_logbook ; YES - exit logbook |
336 | 336 |
337 exit_logbook: | 337 exit_logbook: |
338 bcf switch_right ; clear pending button events | 338 bcf switch_right ; clear pending button events |
339 bcf switch_left ; ... | 339 bcf switch_left ; ... |
340 goto do_main_menu2 ; jump-back to main menu (in menu_tree.asm) | 340 goto main_menu ; jump-back to main menu (in menu_tree.asm) |
341 | 341 |
342 display_profile_or_next: | 342 display_profile_or_next: |
343 movlw logbook_row_number+.1 ; get menu line were the next page item is | 343 movlw logbook_row_number+.1 ; get menu line were the next page item is |
344 cpfseq menu_pos_cur ; cursor on next page line? | 344 cpfseq menu_pos_cur ; cursor on next page line? |
345 bra display_profile ; NO - show profile of selected dive | 345 bra display_profile ; NO - show profile of selected dive |
346 goto next_logbook2 ; YES - show next page | 346 goto next_logbook2 ; YES - show next page |
347 | 347 |
348 ;----------------------------------------------------------------------------- | 348 |
349 ; show graphical dive profile | 349 ;----------------------------------------------------------------------------- |
350 ; show graphical Dive Profile | |
350 ; | 351 ; |
351 display_profile: | 352 display_profile: |
352 bcf bailout_mode ; clear event flag | 353 bcf bailout_mode ; clear event flag |
353 bcf event_gas_change_gas6 ; clear event flag | 354 bcf event_gas_change_gas6 ; clear event flag |
354 movff menu_pos_cur,logbook_menupos_temp ; store current cursor position | 355 movff menu_pos_cur,logbook_menupos_temp ; store current cursor position |
359 mullw logbook_row_number ; multiply with number of dives per page | 360 mullw logbook_row_number ; multiply with number of dives per page |
360 movf PRODL,W ; copy low byte to WREG | 361 movf PRODL,W ; copy low byte to WREG |
361 addwf menu_pos_cur,W ; add number of selected dive on current page page | 362 addwf menu_pos_cur,W ; add number of selected dive on current page page |
362 movwf divenumber ; result is the number of the dive to show | 363 movwf divenumber ; result is the number of the dive to show |
363 | 364 |
364 ; compute the header address by the dive number | 365 ; copy header from FLASH into memory |
365 call log_header_addr_by_divenumber | 366 call log_header_addr_by_divenumber ; compute header start address from the dive number |
366 | 367 FLASH_RR_READ header_buffer,.256 ; copy complete header from FLASH to memory |
367 ; copy the complete header from FLASH to memory | |
368 FLASH_RR_READ mpr,header_buffer,.256 | |
369 | 368 |
370 ; read the sampling rate | 369 ; read the sampling rate |
371 MOVCC header_buffer+index_samplingrate,sampling_rate | 370 MOVCC header_buffer+index_samplingrate,sampling_rate |
372 | 371 |
373 ; --- start drawing the dive profile page --- | 372 ; --- start drawing the dive profile page --- |
374 | 373 |
375 display_profile2: | 374 display_profile2: |
376 call TFT_boot | 375 call TFT_boot ; initialize display |
377 call TFT_standard_color | 376 FONT_COLOR_MEMO ; set font color |
378 | 377 |
379 ; show dive number | 378 ; show dive number |
380 call logbook_show_divenumber ; show the dive number in medium font | 379 call logbook_show_divenumber ; show the dive number in medium font |
381 | 380 |
382 ; show date | 381 ; show date |
383 WIN_SMALL logbook_date_column, logbook_date_row | 382 WIN_SMALL logbook_date_column, logbook_date_row |
384 MOVTT header_buffer+index_date,mpr ; read date | 383 MOVTT header_buffer+index_date,mpr ; read date |
385 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | 384 call output_date ; print date |
386 STRCAT_PRINT "" | 385 PRINT ; dump to screen |
387 | 386 |
388 ; show dive mode | 387 ; show dive mode |
389 WIN_SMALL log_divetime_mins_value_column,logbook_date_row ; align with surrounding data | 388 WIN_SMALL log_divetime_mins_value_column,logbook_date_row ; align with surrounding data |
390 MOVCC header_buffer+index_divemode,lo ; read dive type (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR) | 389 MOVCC header_buffer+index_divemode,lo ; read dive type (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR) |
391 call TFT_decotype_logbook ; "strcat_print"s dive mode (OC, CC, Gauge, Apnea or pSCR) | 390 call TFT_print_decotype ; print deco mode (OC, CC, Gauge, Apnea or pSCR) |
392 ; also sets aux_flag in case the dive was done in a deco mode | 391 ; also sets aux_flag in case the dive was done in a deco mode |
393 | 392 |
394 ; show time | 393 ; show time |
395 WIN_SMALL logbook_time_column, logbook_time_row | 394 WIN_SMALL logbook_time_column, logbook_time_row |
396 MOVII header_buffer+index_time,mpr ; get time | 395 MOVII header_buffer+index_time,mpr ; get time |
397 output_99x ; print hour | 396 output_99x ; print hour |
398 PUTC ':' ; print spacing ":" | 397 PUTC ':' ; print spacing ":" |
399 movff hi,lo ; print minute | 398 movff hi,lo ; print minute |
400 output_99x ; ... | 399 output_99x ; ... |
401 STRCAT_PRINT "" ; display 1st row of details | 400 PRINT ; print buffer as 1st row of details to screen |
402 | 401 |
403 ; get log format version | 402 ; get log format version |
404 MOVCC header_buffer+index_profile_version,lo ; read profile format version | 403 MOVCC header_buffer+index_profile_version,lo ; read profile format version |
405 movlw 0x24 | 404 movlw b'00111111' ; load mask for external part of the profile version |
406 cpfslt lo ; < 0x24 ? | 405 andwf lo,F ; keep only the external part |
406 movlw 0x24 ; recorded external version < 0x24 | |
407 cpfslt lo ; ... ? | |
407 bra log_skip_extra_icon ; YES - skip end of dive icon | 408 bra log_skip_extra_icon ; YES - skip end of dive icon |
408 | 409 |
409 ; print end of dive icon | 410 ; print end of dive icon |
410 WIN_SMALL logbook_time_column-.8, logbook_time_row | 411 WIN_SMALL logbook_time_column-.8, logbook_time_row |
411 STRCPY_PRINT 0x94 | 412 STRCPY_PRINT 0x94 |
468 bra display_profile_offset4_metric ; 0 - do metric | 469 bra display_profile_offset4_metric ; 0 - do metric |
469 ;bra display_profile_offset4_imperial ; 1 - do imperial | 470 ;bra display_profile_offset4_imperial ; 1 - do imperial |
470 | 471 |
471 display_profile_offset4_imperial: | 472 display_profile_offset4_imperial: |
472 call convert_cm_to_feet ; convert value in mpr from [cm] to [feet] | 473 call convert_cm_to_feet ; convert value in mpr from [cm] to [feet] |
473 PUTC ' ' | 474 PUTC ' ' ; append a space |
474 bcf leftbind | 475 output_999 ; print depth (0-999) |
475 output_16_3 ; limit to 999 and display only (0-999) | 476 STRCAT_TEXT_PRINT tFeets ; append unit and dump to screen |
476 STRCAT_TEXT_PRINT tFeets | 477 bra display_profile_offset4_common ; continue |
477 bra display_profile_offset4_common | |
478 | 478 |
479 display_profile_offset4_metric: | 479 display_profile_offset4_metric: |
480 bsf ignore_digit5 ; no cm... | 480 bsf omit_digit_1 ; do not print 1st digit (no cm) |
481 movlw d'1' ; no 1000 m | 481 bsf decimal_digit2 ; place a decimal point in front of digit 2 |
482 movwf ignore_digits ; ... | 482 output_65535 ; print depth (0.0x-655.3x) |
483 output_16dp d'3' ; xxx.y | 483 STRCAT_TEXT_PRINT tMeters ; append unit and dump to screen |
484 STRCAT_TEXT_PRINT tMeters | 484 ;bra display_profile_offset4_common ; continue |
485 ;bra display_profile_offset4_common | |
486 | 485 |
487 display_profile_offset4_common: | 486 display_profile_offset4_common: |
488 WIN_SMALL log_divetime_mins_value_column,log_divetime_mins_value_row | 487 WIN_SMALL log_divetime_mins_value_column,log_divetime_mins_value_row |
489 bsf leftbind | |
490 | 488 |
491 ; show dive time minutes : seconds | 489 ; show dive time minutes : seconds |
492 MOVTT header_buffer+index_divetime,mpr ; get dive time | 490 MOVTT header_buffer+index_divetime,mpr ; get dive time |
493 output_16 ; print dive time minutes | 491 bsf leftbind ; print left-aligned |
492 output_9999 ; print dive time minutes (0-9999) | |
494 PUTC 'm' ; print "m" (minutes) | 493 PUTC 'm' ; print "m" (minutes) |
495 movff up,lo ; print dive time seconds | 494 movff up,lo ; print dive time seconds |
496 output_99x ; dive time seconds | 495 output_99x ; dive time seconds |
497 STRCAT_PRINT "s" ; print "s" (seconds) | 496 PUTC_PRINT "s" ; append unit (seconds) and dump buffer to screen |
498 | 497 |
499 ; get minimum temperature (for later use) | 498 ; get minimum temperature (for later use) |
500 MOVII header_buffer+index_min_temp,logbook_min_tp | 499 MOVII header_buffer+index_min_temp,logbook_min_tp |
501 | 500 |
502 ; print gases | 501 ; print gases |
542 | 541 |
543 logbook_find_first_gas_done: | 542 logbook_find_first_gas_done: |
544 movwf backup_color1 ; keep copy of color for later restore | 543 movwf backup_color1 ; keep copy of color for later restore |
545 call TFT_color_code_gas ; set color | 544 call TFT_color_code_gas ; set color |
546 | 545 |
546 ; initialize flag for signaling when last sample set was read | |
547 bcf end_of_profile | |
548 | |
547 ; set ext_flash_address to the begin of the profile data | 549 ; set ext_flash_address to the begin of the profile data |
548 MOVTT header_buffer+index_profile_start_address,ext_flash_address | 550 MOVTT header_buffer+index_profile_start_address,ext_flash_address |
549 | 551 |
550 ; skip the 0xFA 0xFA header of the profile data | 552 ; header start code sequence present? |
551 ext_flash_inc_address_0x20 d'2' | 553 FLASH_CW_READ_0x20 ; get the 1st byte |
552 | 554 xorlw 0xFA ; 1st byte = header start byte? |
553 ; initialize flag for signaling when last sample set was read | 555 bnz display_profile_no_profile_jump ; NO - no profile data available, abort |
554 bcf end_of_profile | 556 |
557 FLASH_CW_READ_0x20 ; get the 2nd byte | |
558 xorlw 0xFA ; 2nd byte = header start byte? | |
559 bnz display_profile_no_profile_jump ; NO - no profile data available, abort | |
555 | 560 |
556 ; check if the profile actually belongs to this dive (check done with low bytes only) | 561 ; check if the profile actually belongs to this dive (check done with low bytes only) |
557 FLASH_CC_READ_0x20 lo ; read dive number in profile | 562 FLASH_CC_READ_0x20 lo ; read dive number in profile |
558 incf total_num_dives,W ; WREG = total number of dives + 1 | 563 incf total_num_dives,W ; WREG = total number of dives + 1 |
559 bsf STATUS,C ; set borrow | 564 bsf STATUS,C ; set borrow |
560 subfwb divenumber,W ; WREG = total number of dives - number of dive to show - 1 | 565 subfwb divenumber,W ; WREG = total number of dives - number of dive to show - 1 |
561 cpfseq lo ; number of dive in profile = number of dive to show? | 566 cpfseq lo ; number of dive in profile = number of dive to show? |
567 display_profile_no_profile_jump: | |
562 bra display_profile_no_profile ; NO - no profile data for this dive available | 568 bra display_profile_no_profile ; NO - no profile data for this dive available |
563 ;bra display_profile_show_profile ; YES - show profile | 569 ;bra display_profile_show_profile ; YES - show profile |
564 | 570 |
565 display_profile_show_profile: | 571 display_profile_show_profile: |
566 | 572 |
567 ; skip high byte of dive number 1 byte | 573 ; skip high byte of dive number 1 byte |
568 ; skip second header code 2 byte | 574 ; skip second part of header start code 2 byte |
569 ; skip length of profile data 3 byte | 575 ; skip length of profile data 3 byte |
570 ; skip sampling rate in profile section 1 byte | 576 ; skip sampling rate in profile data 1 byte |
571 ; skip number of divisors 1 byte | 577 ; skip number of divisors 1 byte |
572 ; ====== | 578 ; ====== |
573 ; total number of bytes to skip = 8 byte | 579 ; total number of bytes to skip = 8 byte |
574 ext_flash_inc_address_0x20 d'8' | 580 |
581 EXT_FLASH_INC_ADDRESS_0x20 d'8' ; skip next 8 bytes | |
575 | 582 |
576 ; read divisor temp | 583 ; read divisor temp |
577 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 584 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
578 FLASH_CW_READ_0x20 ; read temperature divisor | 585 FLASH_CW_READ_0x20 ; read temperature divisor into WREG |
579 movwf divisor_temperature ; store temperature divisor | 586 movwf divisor_temperature ; store temperature divisor |
580 movwf count_temperature ; store to temperature counter, too | 587 movwf count_temperature ; store to temperature counter, too |
581 | 588 |
582 ; read divisor deco | 589 ; read divisor deco |
583 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 590 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
584 FLASH_CW_READ_0x20 ; read deco divisor | 591 FLASH_CW_READ_0x20 ; read deco divisor into WREG |
585 movwf divisor_deco ; store deco divisor | 592 movwf divisor_deco ; store deco divisor |
586 movwf count_deco ; store to deco status counter, too | 593 movwf count_deco ; store to deco status counter, too |
587 | 594 |
588 ; read divisor GF | 595 ; read divisor GF |
589 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 596 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
590 FLASH_CC_READ_0x20 divisor_gf ; store saturation divisor | 597 FLASH_CC_READ_0x20 divisor_gf ; store saturation divisor |
591 | 598 |
592 ; read divisor ppO2 sensors | 599 ; read divisor ppO2 sensors |
593 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 600 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
594 FLASH_CC_READ_0x20 divisor_ppo2_sensors ; store ppO2 divisor | 601 FLASH_CC_READ_0x20 divisor_ppo2_sensors ; store ppO2 divisor |
595 | 602 |
596 ; read divisor deco plan | 603 ; read divisor deco plan |
597 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 604 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
598 FLASH_CC_READ_0x20 divisor_decoplan ; store deco plan divisor | 605 FLASH_CC_READ_0x20 divisor_decoplan ; store deco plan divisor |
599 | 606 |
600 ; read divisor CNS | 607 ; read divisor CNS |
601 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 608 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
602 FLASH_CC_READ_0x20 divisor_cns ; store CNS divisor | 609 FLASH_CC_READ_0x20 divisor_cns ; store CNS divisor |
603 | 610 |
604 ; read divisor tank data | 611 ; read divisor tank data |
605 ext_flash_inc_address_0x20 d'2' ; skip information type and length | 612 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip information type and length |
606 FLASH_CC_READ_0x20 divisor_tank ; store tank pressure divisor | 613 FLASH_CC_READ_0x20 divisor_tank ; store tank pressure divisor |
607 | 614 |
608 | 615 ;---- start drawing the profile ---------------- |
609 ; start drawing the profile | |
610 | |
611 ; set color | |
612 movlw color_deepblue | |
613 call TFT_set_color | |
614 | 616 |
615 ; draw a frame around profile area | 617 ; draw a frame around profile area |
616 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 | 618 movlw color_deepblue ; select color |
619 WIN_FRAME_COLOR profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 | |
617 | 620 |
618 ; draw depth grid | 621 ; draw depth grid |
619 movlw profile_top ; set top position of plot area | 622 movlw profile_top ; set top position of plot area |
620 movwf win_top ; ... | 623 movwf win_top ; ... |
621 movlw profile_left ; set left position of plot area | 624 movlw profile_left ; set left position of plot area |
625 movlw profile_width_pixels+.1 ; set right position of plot area | 628 movlw profile_width_pixels+.1 ; set right position of plot area |
626 movwf win_width+0 ; ... | 629 movwf win_width+0 ; ... |
627 clrf win_width+1 ; ... | 630 clrf win_width+1 ; ... |
628 bra display_profile2_loline ; do not draw the 0 m line | 631 bra display_profile2_loline ; do not draw the 0 m line |
629 display_profile2_loop: | 632 display_profile2_loop: |
630 call TFT_box ; draw the line | 633 BOX ; draw the line |
631 display_profile2_loline: | 634 display_profile2_loline: |
632 movf win_top,W ; get last row drawn | 635 movf win_top,W ; get last row drawn |
633 addwf x_scale+0,W ; add line interval distance, low byte | 636 addwf x_scale+0,W ; add line interval distance, low byte |
634 tstfsz x_scale+1 ; interval distance > 255 ? | 637 tstfsz x_scale+1 ; interval distance > 255 ? |
635 movlw d'255' ; YES - would make win_top > 239 -> prepare abort | 638 movlw d'255' ; YES - would make win_top > 239 -> prepare abort |
639 movlw profile_top+profile_height_pixels+.1 ; get limit for last line | 642 movlw profile_top+profile_height_pixels+.1 ; get limit for last line |
640 cpfsgt win_top ; line to draw beyond limit? | 643 cpfsgt win_top ; line to draw beyond limit? |
641 bra display_profile2_loop ; NO - draw the line | 644 bra display_profile2_loop ; NO - draw the line |
642 | 645 |
643 ; do various initializations for drawing the curves | 646 ; do various initializations for drawing the curves |
644 clrf gaslist_gas ; here: used as counter for depth readings | 647 clrf ul ; clear counter for depth readings |
645 movlw profile_width_pixels+profile_left-.1 | 648 movlw profile_width_pixels+profile_left-.1 ; load loop counter |
646 movwf ignore_digits ; here: used as counter for x-pixels | 649 movwf ex ; ... |
647 | 650 |
648 movlw profile_left+.1 | 651 movlw profile_left+.1 |
649 movwf logbook_pixel_x_pos ; here: used as column x2 (start at column 5) | 652 movwf logbook_pixel_x_pos ; here: used as column x2 (start at column 5) |
650 | 653 |
651 movlw profile_top+.1 ; zero-m row | 654 movlw profile_top+.1 ; zero-m row |
652 movwf fill_between_rows | 655 movwf fill_between_rows |
653 movwf logbook_last_tp ; initialize for temperature curve, too | 656 movwf logbook_last_tp ; initialize for temperature curve, too |
654 | 657 |
655 movlw LOW(-.100) ; initialize max temperature to -10.0 °C | 658 movlw LOW(-.100) ; initialize max temperature to -10.0 °C |
656 movwf logbook_max_tp+0 | 659 movwf logbook_max_tp+0 ; ... |
657 movlw HIGH 0xFFFF & (-.100) | 660 movlw HIGH 0xFFFF & (-.100) ; ... |
658 movwf logbook_max_tp+1 | 661 movwf logbook_max_tp+1 ; ... |
659 | 662 |
660 setf logbook_cur_tp+0 ; initialize temperature to 0xFFFF = 'no data' | 663 setf logbook_cur_tp+0 ; initialize temperature to 0xFFFF = 'no data' |
661 setf logbook_cur_tp+1 ; ... | 664 setf logbook_cur_tp+1 ; ... |
662 clrf logbook_last_tp ; also reset previous Y for temperature | 665 clrf logbook_last_tp ; also reset previous Y for temperature |
663 clrf logbook_ceiling ; ceiling = 0, correct value for no ceiling | 666 clrf logbook_ceiling ; ceiling = 0, correct value for no ceiling |
678 movwf win_width+1 | 681 movwf win_width+1 |
679 call TFT_box_write ; open box for d1 | 682 call TFT_box_write ; open box for d1 |
680 | 683 |
681 ; INIT_PIXEL_WRITE logbook_pixel_x_pos ; pixel x2 (also sets standard color!) | 684 ; INIT_PIXEL_WRITE logbook_pixel_x_pos ; pixel x2 (also sets standard color!) |
682 | 685 |
683 ; start profile plotting loop | 686 ;---- start profile plotting loop -------------- |
687 | |
684 CLRI logbook_sample_counter ; clear counter for amount of samples read so far | 688 CLRI logbook_sample_counter ; clear counter for amount of samples read so far |
685 | 689 |
686 profile_display_loop: | 690 profile_display_loop: |
687 ; initialize pixel write | 691 ; initialize pixel write |
688 movf logbook_pixel_x_pos,W | 692 movf logbook_pixel_x_pos,W |
699 profile_display_loop2: | 703 profile_display_loop2: |
700 rcall profile_view_get_depth ; read one set of depth, temp and event data | 704 rcall profile_view_get_depth ; read one set of depth, temp and event data |
701 btfsc end_of_profile ; end of profile data reached? | 705 btfsc end_of_profile ; end of profile data reached? |
702 bra profile_display_loop_done ; YES - skip all remaining pixels | 706 bra profile_display_loop_done ; YES - skip all remaining pixels |
703 | 707 |
704 | 708 ;---- draw ceiling curve, if any --------------- |
705 ;---- draw ceiling curve, if any --------------------------------------------- | |
706 | 709 |
707 movf divisor_deco,W ; get divisor, deco data logged? | 710 movf divisor_deco,W ; get divisor, deco data logged? |
708 bz profile_display_skip_deco ; NO - skip | 711 bz profile_display_skip_deco ; NO - skip |
709 | 712 |
710 movf logbook_ceiling,W ; any deco ceiling? | 713 movf logbook_ceiling,W ; any deco ceiling? |
727 movff xC+0,win_height ; - set hight | 730 movff xC+0,win_height ; - set hight |
728 call half_vertical_line ; - color the area | 731 call half_vertical_line ; - color the area |
729 | 732 |
730 profile_display_skip_deco: | 733 profile_display_skip_deco: |
731 | 734 |
732 ;---- draw temperature curve, if any --------------------------------------------- | 735 ;---- draw temperature curve, if any ----------- |
733 | 736 |
734 movf divisor_temperature,W ; get divisor, deco data logged? | 737 movf divisor_temperature,W ; get divisor, deco data logged? |
735 bz profile_display_skip_temp ; NO - skip | 738 bz profile_display_skip_temp ; NO - skip |
736 | 739 |
737 movf logbook_cur_tp+0,W ; did we had a valid temperature record already (0xFF = 'no data')? | 740 movf logbook_cur_tp+0,W ; did we had a valid temperature record already (0xFF = 'no data')? |
764 movwf xC+1 | 767 movwf xC+1 |
765 cpfsgt xC+0 | 768 cpfsgt xC+0 |
766 movff xC+1,xC+0 | 769 movff xC+1,xC+0 |
767 | 770 |
768 movlw color_orange ; select color for temperature curve | 771 movlw color_orange ; select color for temperature curve |
769 call TFT_set_color ; set color | 772 call TFT_set_color ; set color |
770 | 773 |
771 movf logbook_last_tp,W ; do we have a valid previous value? | 774 movf logbook_last_tp,W ; do we have a valid previous value? |
772 bz profile_display_temp_1 ; NO - skip the vertical line | 775 bz profile_display_temp_1 ; NO - skip the vertical line |
773 movwf xC+1 ; YES - set end position | 776 movwf xC+1 ; YES - set end position |
774 call profile_display_fill ; - draw in this column between this row (xC+0) and the last row (xC+1) | 777 call profile_display_fill ; - draw in this column between this row (xC+0) and the last row (xC+1) |
783 movff xC+0,logbook_last_tp ; set col (0..159) x row (0..239) | 786 movff xC+0,logbook_last_tp ; set col (0..159) x row (0..239) |
784 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; draw a pixel | 787 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; draw a pixel |
785 | 788 |
786 profile_display_skip_temp: | 789 profile_display_skip_temp: |
787 | 790 |
788 ;---- draw depth curve --------------------------------------------------- | 791 ;---- draw depth curve ------------------------- |
789 | 792 |
790 MOVII y_scale, xB ; divide pressure in mbar/pixel for row offset | 793 MOVII y_scale, xB ; divide pressure in mbar/pixel for row offset |
791 MOVII logbook_cur_depth,xA ; get current depth | 794 MOVII logbook_cur_depth,xA ; get current depth |
792 call div16x16 ; xC = xA / xB with xA as remainder | 795 call div16x16 ; xC = xA / xB with xA as remainder |
793 movlw profile_top+.1 ; get offset | 796 movlw profile_top+.1 ; get offset |
794 addwf xC+0,F ; add offset | 797 addwf xC+0,F ; add offset |
795 btfsc STATUS,C ; profile error? | 798 btfsc STATUS,C ; profile error? |
796 movff fill_between_rows,xC+0 ; YES - ignore | 799 movff fill_between_rows,xC+0 ; YES - ignore |
797 | 800 |
798 movf backup_color1,W ; copy gas number to WREG for color-coding | 801 movf backup_color1,W ; copy gas number to WREG for color-coding |
799 call TFT_color_code_gas ; set color | 802 call TFT_color_code_gas ; get color for gas |
803 call TFT_set_color ; set drawing color | |
800 | 804 |
801 movff fill_between_rows,xC+1 ; set position | 805 movff fill_between_rows,xC+1 ; set position |
802 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) | 806 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) |
803 movff xC+0,fill_between_rows ; store last row for fill routine | 807 movff xC+0,fill_between_rows ; store last row for fill routine |
804 | 808 |
805 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; draw a pixel | 809 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; draw a pixel |
806 incf logbook_pixel_x_pos,F ; advance to next column | 810 incf logbook_pixel_x_pos,F ; advance to next column |
807 | 811 |
808 ;---- draw marker square, if any ----------------------------------------- | 812 ;---- draw marker square, if any --------------- |
809 | 813 |
810 btfss log_marker_found ; any marker to draw? | 814 btfss log_marker_found ; any marker to draw? |
811 bra profile_display_skip_marker ; NO - skip | 815 bra profile_display_skip_marker ; NO - skip |
812 bcf log_marker_found ; YES - clear flag | 816 bcf log_marker_found ; YES - clear flag |
813 | 817 |
826 movlw .151 | 830 movlw .151 |
827 cpfslt win_leftx2 | 831 cpfslt win_leftx2 |
828 movwf win_leftx2 | 832 movwf win_leftx2 |
829 | 833 |
830 ; print marker | 834 ; print marker |
831 movlw color_orange | 835 FONT_COLOR color_orange ; set font color |
832 call TFT_set_color | 836 FONT_SIZE FT_TINY ; set font size |
833 WIN_FONT FT_TINY | 837 INIT_BUFFER ; initialize output buffer |
834 lfsr FSR2,buffer | 838 STRCPY_PRINT "m" ; print a "m" (marker) |
835 STRCPY_PRINT "m" | |
836 | 839 |
837 movlw profile_left | 840 movlw profile_left |
838 movwf win_leftx2 | 841 movwf win_leftx2 |
839 movlw profile_top | 842 movlw profile_top |
840 movwf win_top | 843 movwf win_top |
846 movwf win_width+1 | 849 movwf win_width+1 |
847 call TFT_box_write ; re-open box for d1 | 850 call TFT_box_write ; re-open box for d1 |
848 | 851 |
849 profile_display_skip_marker: | 852 profile_display_skip_marker: |
850 | 853 |
851 ;---- draw CNS curve, if any --------------------------------------------- | 854 ;---- draw CNS curve, if any ------------------- |
852 | 855 |
853 movf divisor_cns,W ; get divisor, CNS logged? | 856 movf divisor_cns,W ; get divisor, CNS logged? |
854 bz profile_display_skip_cns ; NO - skip | 857 bz profile_display_skip_cns ; NO - skip |
855 ; | 858 ; |
856 ; add further code here... | 859 ; add further code here... |
857 ; | 860 ; |
858 | 861 |
859 profile_display_skip_cns: | 862 profile_display_skip_cns: |
860 | 863 |
861 ;---- draw saturation curve, if any -------------------------------------- | 864 ;---- draw saturation curve, if any ------------ |
862 | 865 |
863 movf divisor_gf,W ; get divisor, saturation logged? | 866 movf divisor_gf,W ; get divisor, saturation logged? |
864 bz profile_display_skip_gf ; NO - skip | 867 bz profile_display_skip_gf ; NO - skip |
865 ; | 868 ; |
866 ; add further code here... | 869 ; add further code here... |
867 ; | 870 ; |
868 | 871 |
869 profile_display_skip_gf: | 872 profile_display_skip_gf: |
870 | 873 |
871 ; all curves done | 874 ;---- all curves done -------------------------- |
872 bra profile_display_skip_loop1 | |
873 | |
874 | 875 |
875 profile_display_skip_loop1: | 876 profile_display_skip_loop1: |
876 dcfsnz profile_temp2+0,F ; decrement low byte of x-scaler, became zero? | 877 dcfsnz profile_temp2+0,F ; decrement low byte of x-scaler, became zero? |
877 bra profile_display_loop3 ; YES - decrement high byte | 878 bra profile_display_loop3 ; YES - decrement high byte |
878 rcall profile_view_get_depth ; NO - read next depth, temp and profile data set | 879 rcall profile_view_get_depth ; NO - read next depth, temp and profile data set |
881 bra profile_display_skip_loop1 ; NO - continue | 882 bra profile_display_skip_loop1 ; NO - continue |
882 | 883 |
883 profile_display_loop3: | 884 profile_display_loop3: |
884 decfsz profile_temp2+1,F ; decrement high byte of x-scaler, became zero? | 885 decfsz profile_temp2+1,F ; decrement high byte of x-scaler, became zero? |
885 bra profile_display_skip_loop1 ; NO - continue | 886 bra profile_display_skip_loop1 ; NO - continue |
886 decfsz ignore_digits,F ; YES - count drown x-pixels to zero, became zero? | 887 decfsz ex,F ; YES - count drown x-pixels to zero, became zero? |
887 bra profile_display_loop ; NO - draw next sample | 888 bra profile_display_loop ; NO - draw next sample |
888 bra profile_display_loop_done ; YES - done | 889 bra profile_display_loop_done ; YES - done |
889 | 890 |
890 profile_display_loop_done: | 891 profile_display_loop_done: |
891 btfss bailout_mode ; bailout during the dive? | 892 btfss bailout_mode ; bailout during the dive? |
892 bra profile_display_gas6 ; NO - skip next | 893 bra profile_display_gas6 ; NO - skip next |
893 movlw color_pink ; YES - show "Bailout" in pink color | 894 FONT_COLOR color_pink ; YES - select pink color |
894 call TFT_set_color ; - ... | 895 WIN_TINY logbook_bailout_column,logbook_bailout_row; - select font and position |
895 WIN_TINY logbook_bailout_column,logbook_bailout_row; - ... | 896 STRCPY_TEXT_PRINT tDiveBailout ; - print "Bailout" and dump to screen |
896 STRCPY_TEXT_PRINT tDiveBailout ; - print text | |
897 | 897 |
898 profile_display_gas6: | 898 profile_display_gas6: |
899 btfss event_gas_change_gas6 ; did a change to gas 6 occurred? | 899 btfss event_gas_change_gas6 ; did a change to gas 6 occurred? |
900 bra profile_display_temperatures ; NO - skip next | 900 bra profile_display_temperatures ; NO - skip next |
901 movlw color_pink ; YES - select color | 901 FONT_COLOR color_pink ; YES - select color |
902 call TFT_set_color ; - set color | |
903 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 | 902 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 |
904 STRCPY_TEXT tGas ; - print "Gas" | 903 STRCPY_TEXT tGas ; - print "Gas" |
905 STRCAT_PRINT " 6!" ; - print " 6!" | 904 STRCAT_PRINT " 6!" ; - append " 6!" and dump to screen |
906 | 905 |
907 profile_display_temperatures: | 906 profile_display_temperatures: |
908 movff logbook_min_temp_pos,win_top ; get Y position at lowest temperature | 907 movff logbook_min_temp_pos,win_top ; get Y position at lowest temperature |
909 movff logbook_pixel_x_pos,win_leftx2 ; get X ... | 908 movff logbook_pixel_x_pos,win_leftx2 ; get X ... |
910 movlw .130 ; left border limit | 909 movlw .130 ; left border limit |
911 cpfslt win_leftx2 ; too far to the left? | 910 cpfslt win_leftx2 ; too far to the left? |
912 movwf win_leftx2 ; YES - set to limit | 911 movwf win_leftx2 ; YES - set to limit |
913 WIN_FONT FT_TINY ; select font | 912 FONT_SIZE FT_TINY ; set font size |
914 movlw color_yellow ; select color | 913 FONT_COLOR color_yellow ; set font color |
915 call TFT_set_color ; set color | |
916 | 914 |
917 MOVII logbook_min_tp,mpr ; get min temperature | 915 MOVII logbook_min_tp,mpr ; get min temperature |
918 lfsr FSR2,buffer ; initialize string buffer | |
919 | 916 |
920 TSTOSS opt_units ; 0=°C, 1=°F | 917 TSTOSS opt_units ; 0=°C, 1=°F |
921 bra logbook_show_temp_metric ; 0 - do Celsius | 918 bra logbook_show_temp_metric ; 0 - do Celsius |
922 ;bra logbook_show_temp_imperial ; 1 - do Fahrenheit | 919 ;bra logbook_show_temp_imperial ; 1 - do Fahrenheit |
923 | 920 |
924 logbook_show_temp_imperial: | 921 logbook_show_temp_imperial: |
925 ; min temperature | 922 ; min temperature |
926 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required | 923 rcall logbook_show_temp_imperial_out ; print temperature |
927 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit | |
928 lfsr FSR2,buffer ; overwrite "-" | |
929 bsf ignore_digit5 ; full degrees only | |
930 output_16 | |
931 STRCAT_TEXT_PRINT tLogTunitF | |
932 ; max temperature | 924 ; max temperature |
933 movlw .15 | 925 movlw .15 ; set position |
934 subwf logbook_max_temp_pos,W | 926 subwf logbook_max_temp_pos,W ; ... |
935 movwf win_top ; Y position at max temperature | 927 movwf win_top ; Y position at max temperature |
936 MOVII logbook_max_tp,mpr | 928 MOVII logbook_max_tp,mpr ; get max temperature |
937 lfsr FSR2,buffer | 929 rcall logbook_show_temp_imperial_out ; print temperature |
938 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 930 bra logbook_show_gases ; continue |
939 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit | |
940 output_16 | |
941 bcf ignore_digit5 | |
942 STRCAT_TEXT_PRINT tLogTunitF | |
943 bra logbook_show_gases | |
944 | 931 |
945 logbook_show_temp_metric: | 932 logbook_show_temp_metric: |
946 ; min temperature | 933 ; min temperature |
947 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required | 934 rcall logbook_show_temp_metric_out ; print temperature |
948 movlw d'3' | |
949 movwf ignore_digits | |
950 bsf leftbind | |
951 output_16dp d'2' ; temperature | |
952 STRCAT_TEXT_PRINT tLogTunitC | |
953 ; max temperature | 935 ; max temperature |
954 movlw .15 | 936 movlw .15 ; set position |
955 subwf logbook_max_temp_pos,W | 937 subwf logbook_max_temp_pos,W ; ... |
956 movwf win_top ; Y position at max temperature | 938 movwf win_top ; Y position at max temperature |
957 MOVII logbook_max_tp,mpr | 939 MOVII logbook_max_tp,mpr ; get max temperature |
958 lfsr FSR2,buffer | 940 rcall logbook_show_temp_metric_out ; print temperature |
959 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 941 bra logbook_show_gases ; continue |
960 movlw d'3' | 942 |
961 movwf ignore_digits | 943 logbook_show_temp_imperial_out: |
962 bsf leftbind | 944 INIT_BUFFER ; initialize output buffer |
963 output_16dp d'2' ; temperature | 945 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit |
964 STRCAT_TEXT_PRINT tLogTunitC | 946 bsf leftbind ; print left-aligned |
965 bra logbook_show_gases | 947 bsf omit_digit_1 ; full degrees only |
948 output_9999 ; print temperature (0x-999x) | |
949 STRCAT_TEXT_PRINT tLogTunitF ; add unit and dump to screen | |
950 return ; done | |
951 | |
952 logbook_show_temp_metric_out: | |
953 INIT_BUFFER ; initialize output buffer | |
954 call convert_signed_16bit ; convert lo:hi into unsigned-short and add '-' to POSTINC2 if required | |
955 bsf leftbind ; print left-aligned | |
956 bsf decimal_digit1 ; place a decimal point in front of the 1st digit | |
957 output_999 ; print temperature (0.0-99.9) | |
958 STRCAT_TEXT_PRINT tLogTunitC ; add unit and dump to screen | |
959 return ; done | |
966 | 960 |
967 | 961 |
968 display_profile_no_profile: | 962 display_profile_no_profile: |
969 ; print message "No Data anymore..." | 963 ; print "no profile anymore..." message |
970 WIN_SMALL .4,.110 ; set text size and position | 964 WIN_SMALL .4,.110 ; set text size and position |
971 call TFT_disabled_color ; use the color for disabled things | 965 FONT_COLOR_DISABLED ; use the color for disabled things |
972 STRCPY_TEXT_PRINT tNoProfileData ; print message | 966 STRCPY_TEXT_PRINT tNoProfileData ; print message |
973 | 967 |
974 | |
975 logbook_show_gases: | 968 logbook_show_gases: |
976 bcf leftbind | 969 FONT_COLOR_MEMO ; back to standard color |
977 call TFT_standard_color | |
978 | |
979 btfss aux_flag ; dive done in a deco mode? | 970 btfss aux_flag ; dive done in a deco mode? |
980 bra logbook_show_gases_done ; NO - don't show gases | 971 bra logbook_show_gases_done ; NO - don't show gases |
981 | 972 |
982 ; show gases | 973 ; show gases |
983 lfsr FSR0,header_buffer+index_gas1 ; load base address of gases | 974 lfsr FSR0,header_buffer+index_gas1 ; load base address of the gases |
984 bsf log_show_gas_short ; do the short version of log_show_gas | 975 bsf log_show_gas_short ; do the short version of log_show_gas |
985 bsf leftbind | |
986 | 976 |
987 WIN_TINY log_gas_column1, log_gas_row | 977 WIN_TINY log_gas_column1, log_gas_row |
988 movlw .1 ; color for gas 1 | 978 movlw .1 ; color for gas 1 |
989 call log_show_gas | 979 call log_show_gas |
990 | 980 |
1002 | 992 |
1003 WIN_TINY log_gas_column5, log_gas_row | 993 WIN_TINY log_gas_column5, log_gas_row |
1004 movlw .5 ; color for gas 5 | 994 movlw .5 ; color for gas 5 |
1005 call log_show_gas | 995 call log_show_gas |
1006 | 996 |
1007 bcf leftbind | |
1008 | |
1009 logbook_show_gases_done: | 997 logbook_show_gases_done: |
1010 | |
1011 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco | 998 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco |
1012 display_profile_loop: | 999 display_profile_loop: |
1013 btfsc switch_right ; right button pressed? | 1000 btfsc switch_right ; right button pressed? |
1014 bra logbook_page1 ; YES - show more information | 1001 bra logbook_page1 ; YES - show more information |
1015 btfsc switch_left ; NO - left button pressed? | 1002 btfsc switch_left ; NO - left button pressed? |
1016 bra exit_profileview ; YES - back to list | 1003 bra exit_profileview ; YES - back to list |
1017 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode | 1004 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode |
1018 bra display_profile_loop ; - loop waiting for something to do | 1005 bra display_profile_loop ; - loop waiting for something to do |
1019 | 1006 |
1020 | 1007 |
1021 ;============================================================================= | 1008 ;----------------------------------------------------------------------------- |
1022 ; Draw a vertical line between xC+1 and xC+0, at current X position | 1009 ; Helper Function - draw a vertical line between xC+1 and xC+0 at current X position |
1023 ; | 1010 ; |
1024 ; Note: should keep xC+0 | 1011 ; Note: should keep xC+0 |
1025 ; Note: ascending or descending ! | 1012 ; Note: ascending or descending ! |
1026 ; | 1013 ; |
1027 profile_display_fill: | 1014 profile_display_fill: |
1062 movf xC+0,W | 1049 movf xC+0,W |
1063 cpfseq xC+1 ; loop until xC+1 = fill_between_rows | 1050 cpfseq xC+1 ; loop until xC+1 = fill_between_rows |
1064 bra profile_display_fill_up | 1051 bra profile_display_fill_up |
1065 return ; fill_between_rows and xC+0 are untouched | 1052 return ; fill_between_rows and xC+0 are untouched |
1066 | 1053 |
1067 ;============================================================================= | 1054 |
1068 | 1055 ;----------------------------------------------------------------------------- |
1069 | 1056 ; read next Profile Data Set and plot Depth and Temperature |
1057 ; | |
1070 profile_view_get_depth: | 1058 profile_view_get_depth: |
1071 INCI logbook_sample_counter ; count read pixels | 1059 INCI logbook_sample_counter ; count read pixels |
1072 | 1060 |
1073 movf logbook_sample_counter+0,W | 1061 movf logbook_sample_counter+0,W |
1074 cpfseq vertical_interval+0 | 1062 cpfseq vertical_interval+0 |
1075 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | 1063 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue |
1076 movf logbook_sample_counter+1,W | 1064 movf logbook_sample_counter+1,W |
1077 cpfseq vertical_interval+1 | 1065 cpfseq vertical_interval+1 |
1078 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | 1066 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue |
1079 ; draw a new 10min line here... | 1067 |
1068 ;---- 10 min vertical line --------------------- | |
1069 | |
1080 CLRI logbook_sample_counter ; clear counting registers for next line | 1070 CLRI logbook_sample_counter ; clear counting registers for next line |
1081 | 1071 movlw color_deepblue ; select color |
1082 ; Vertical lines... | 1072 call TFT_set_color ; set color |
1083 movlw color_deepblue | 1073 movlw profile_top+.1 ; set top position |
1084 call TFT_set_color | 1074 movwf win_top ; ... |
1085 movlw profile_top+.1 | |
1086 movwf win_top | |
1087 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile | 1075 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile |
1088 movwf win_leftx2 ; left border (0-159) | 1076 movwf win_leftx2 ; left border (0-159) |
1089 movlw profile_height_pixels | 1077 movlw profile_height_pixels |
1090 movwf win_height | 1078 movwf win_height |
1091 movlw profile_height_pixels | 1079 movlw profile_height_pixels |
1092 movwf win_width ; "window" height | 1080 movwf win_width ; "window" height |
1093 call half_horizontal_line ; inputs: win_top, win_leftx2, win_width, win_color1, win_color2 | 1081 call half_horizontal_line ; inputs: win_top, win_leftx2, win_width, win_color1, win_color2 |
1094 | 1082 |
1095 profile_view_get_depth_no_line: | 1083 profile_view_get_depth_no_line: |
1096 FLASH_II_READ_0x20 logbook_cur_depth ; read depth (2 bytes) | 1084 FLASH_II_READ_0x20 logbook_cur_depth ; read depth (2 bytes) |
1097 FLASH_CC_READ_0x20 gaslist_gas ; read Profile Flag Byte | 1085 FLASH_CC_READ_0x20 ul ; read Profile Flag Byte |
1098 | 1086 |
1099 bcf event_occured ; clear flag by default | 1087 bcf event_occured ; clear flag by default |
1100 btfsc gaslist_gas,7 ; event recorded? | 1088 btfsc ul,7 ; event recorded? |
1101 bsf event_occured ; YES - we also have an event byte | 1089 bsf event_occured ; YES - we also have an event byte |
1102 bcf gaslist_gas,7 ; clear event byte flag (if any) | 1090 bcf ul,7 ; clear event byte flag (if any) |
1103 | 1091 |
1104 ; gaslist_gas now holds the number of additional bytes to ignore (0-127) | 1092 ; ul now holds the number of additional bytes to ignore (0-127) |
1105 | 1093 |
1106 ; check for end of profile | 1094 ;---- check for end of profile ----------------- |
1107 movlw 0xFD ; load token for end of profile data | 1095 movlw 0xFD ; load token for end of profile data |
1108 cpfseq logbook_cur_depth+0 ; end of profile token in 1st depth byte? | 1096 cpfseq logbook_cur_depth+0 ; end of profile token in 1st depth byte? |
1109 bra profile_view_get_depth_new1 ; NO - profile continues | 1097 bra profile_view_get_depth_new1 ; NO - profile continues |
1110 cpfseq logbook_cur_depth+1 ; YES - end of profile token in 2nd depth byte? | 1098 cpfseq logbook_cur_depth+1 ; YES - end of profile token in 2nd depth byte? |
1111 bra profile_view_get_depth_new1 ; NO - profile continues | 1099 bra profile_view_get_depth_new1 ; NO - profile continues |
1114 | 1102 |
1115 profile_view_get_depth_new1: | 1103 profile_view_get_depth_new1: |
1116 btfsc event_occured ; was there an event attached to this sample? | 1104 btfsc event_occured ; was there an event attached to this sample? |
1117 rcall profile_view_get_depth_events ; YES - get information about this event(s) | 1105 rcall profile_view_get_depth_events ; YES - get information about this event(s) |
1118 | 1106 |
1119 ; read temperature if available AND divisor reached AND bytes available | 1107 ;---- temperature ------------------------------ |
1108 | |
1120 movf divisor_temperature,W ; is temperature divisor null ? | 1109 movf divisor_temperature,W ; is temperature divisor null ? |
1121 bz profile_view_get_depth_no_tp ; YES - no temperature curve | 1110 bz profile_view_get_depth_no_tp ; YES - no temperature curve |
1122 decf count_temperature,F ; NO - decrement temperature counter, counter zero now? | 1111 decf count_temperature,F ; NO - decrement temperature counter, counter zero now? |
1123 bnz profile_view_get_depth_no_tp ; NO - no temperature this time | 1112 bnz profile_view_get_depth_no_tp ; NO - no temperature this time |
1124 FLASH_II_READ_0x20 logbook_cur_tp ; YES - read temperature (2 bytes) | 1113 FLASH_II_READ_0x20 logbook_cur_tp ; YES - read temperature (2 bytes) |
1125 decf gaslist_gas,F ; - reduce counter twice | 1114 decf ul,F ; - reduce counter twice |
1126 decf gaslist_gas,F ; - ... | 1115 decf ul,F ; - ... |
1127 movff divisor_temperature,count_temperature ; - restart counter | 1116 movff divisor_temperature,count_temperature ; - restart counter |
1128 | 1117 |
1129 ; compute max temperature on the fly... | 1118 ; compute max temperature on the fly... |
1130 MOVII logbook_cur_tp,sub_a ; copy current temperature to sub_a | 1119 MOVII logbook_cur_tp,sub_a ; copy current temperature to sub_a |
1131 MOVII logbook_max_tp,sub_b ; copy maximum temperature to sub_b | 1120 MOVII logbook_max_tp,sub_b ; copy maximum temperature to sub_b |
1141 bra profile_view_get_depth_no_tp ; NO - ignore current temperature | 1130 bra profile_view_get_depth_no_tp ; NO - ignore current temperature |
1142 | 1131 |
1143 profile_view_compute_max_temp: | 1132 profile_view_compute_max_temp: |
1144 MOVII logbook_cur_tp,logbook_max_tp ; store new max temperature | 1133 MOVII logbook_cur_tp,logbook_max_tp ; store new max temperature |
1145 | 1134 |
1146 ;---- read deco, if any AND divisor=0 AND bytes available ---------------- | |
1147 profile_view_get_depth_no_tp: | 1135 profile_view_get_depth_no_tp: |
1136 | |
1137 ;---- deco ceiling ----------------------------- | |
1138 | |
1148 movf divisor_deco,W | 1139 movf divisor_deco,W |
1149 bz profile_view_get_depth_no_deco | 1140 bz profile_view_get_depth_no_deco |
1150 decf count_deco,F | 1141 decf count_deco,F |
1151 bnz profile_view_get_depth_no_deco | 1142 bnz profile_view_get_depth_no_deco |
1152 | 1143 |
1153 FLASH_CC_READ_0x20 logbook_ceiling ; read the ceiling | 1144 FLASH_CC_READ_0x20 logbook_ceiling ; read the ceiling |
1154 decf gaslist_gas,F ; reduce the counter | 1145 decf ul,F ; reduce the counter |
1155 movff divisor_deco,count_deco ; restart counter | 1146 movff divisor_deco,count_deco ; restart counter |
1156 ext_flash_inc_address_0x40 d'1' ; skip the stop duration | 1147 EXT_FLASH_INC_ADDRESS_0x20 d'1' ; skip the stop duration |
1157 decf gaslist_gas,F ; reduce the counter | 1148 decf ul,F ; reduce the counter |
1158 | |
1159 ;---- read GF, if any AND divisor=0 AND bytes available ------------------ | |
1160 | 1149 |
1161 profile_view_get_depth_no_deco: | 1150 profile_view_get_depth_no_deco: |
1162 ; then skip remaining bytes... | 1151 ; then skip remaining bytes... |
1163 movf gaslist_gas,W ; get number of additional bytes to ignore (0-127) | 1152 movf ul,W ; get number of additional bytes to ignore (0-127) |
1164 tstfsz WREG ; anything to skip? | 1153 tstfsz WREG ; anything to skip? |
1165 call incf_ext_flash_address0_0x20 ; YES - skip #WREG bytes | 1154 call ext_flash_inc_address_0x20_exec ; YES - skip #WREG bytes |
1166 return | 1155 return ; done |
1167 | 1156 |
1157 | |
1158 ;----------------------------------------------------------------------------- | |
1159 ; get Information about Event(s) | |
1160 ; | |
1168 profile_view_get_depth_events: | 1161 profile_view_get_depth_events: |
1169 clrf event_byte2 ; clear event byte 2 | 1162 clrf event_byte2 ; clear event byte 2 |
1170 FLASH_CC_READ_0x20 event_byte1 ; read event byte 1 | 1163 FLASH_CC_READ_0x20 event_byte1 ; read event byte 1 |
1171 decf gaslist_gas,F ; reduce counter | 1164 decf ul,F ; reduce counter |
1172 | 1165 |
1173 btfss event_byte1,7 ; another event byte? | 1166 btfss event_byte1,7 ; another event byte? |
1174 bra profile_no_second_eventbyte ; NO - skip next | 1167 bra profile_no_second_eventbyte ; NO - skip next |
1175 FLASH_CC_READ_0x20 event_byte2 ; YES - read event byte 2 | 1168 FLASH_CC_READ_0x20 event_byte2 ; YES - read event byte 2 |
1176 decf gaslist_gas,F ; - reduce counter | 1169 decf ul,F ; - reduce counter |
1177 bcf event_byte1,7 ; - clear flag | 1170 bcf event_byte1,7 ; - clear flag |
1178 | 1171 |
1179 profile_no_second_eventbyte: | 1172 profile_no_second_eventbyte: |
1180 ; Check event flags in the EventBytes | 1173 ; Check event flags in the EventBytes |
1181 btfsc event_byte1,4 ; manual gas changed? | 1174 btfsc event_byte1,4 ; manual gas changed? |
1186 rcall logbook_event3 ; YES | 1179 rcall logbook_event3 ; YES |
1187 btfsc event_byte2,0 ; bailout? | 1180 btfsc event_byte2,0 ; bailout? |
1188 rcall logbook_event2 ; YES | 1181 rcall logbook_event2 ; YES |
1189 ; any alarm? | 1182 ; any alarm? |
1190 bcf event_byte1,4 ; clear bits already tested | 1183 bcf event_byte1,4 ; clear bits already tested |
1191 bcf event_byte1,5 | 1184 bcf event_byte1,5 ; ... |
1192 bcf event_byte1,6 | 1185 bcf event_byte1,6 ; ... |
1193 movlw .6 ; coding for manual marker | 1186 movlw .6 ; coding for manual marker |
1194 cpfseq event_byte1 ; manual marker set? | 1187 cpfseq event_byte1 ; manual marker set? |
1195 return ; NO - done | 1188 return ; NO - done |
1196 bsf log_marker_found ; YES - draw small yellow rectangle here | 1189 bsf log_marker_found ; YES - draw small yellow rectangle here |
1197 return ; - done | 1190 return ; - done |
1198 | 1191 |
1199 logbook_event4: ; stored gas changed | 1192 logbook_event4: ; stored gas changed |
1200 FLASH_CC_READ_0x20 backup_color1 ; read gas number, to be used as color index | 1193 FLASH_CC_READ_0x20 backup_color1 ; read gas number, to be used as color index |
1201 decf gaslist_gas,F ; reduce counter | 1194 decf ul,F ; reduce counter |
1202 call TFT_color_code_gas ; change profile color according to gas number (still in WREG) | 1195 call TFT_color_code_gas ; change profile color according to gas number (still in WREG) |
1203 return | 1196 return ; done |
1204 | 1197 |
1205 logbook_event1: ; gas 6 used | 1198 logbook_event1: ; gas 6 used |
1206 bsf event_gas_change_gas6 ; set event flag | 1199 bsf event_gas_change_gas6 ; set event flag |
1207 movlw .6 ; use gas 6 color | 1200 movlw .6 ; use gas 6 color |
1208 movwf backup_color1 ; select color for gas 6 | 1201 movwf backup_color1 ; select color for gas 6 |
1209 call TFT_color_code_gas ; set profile color | 1202 call TFT_color_code_gas ; set profile color |
1210 ext_flash_inc_address_0x20 d'2' ; skip two bytes | 1203 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip two bytes |
1211 decf gaslist_gas,F ; reduce counter | 1204 decf ul,F ; reduce counter |
1212 decf gaslist_gas,F ; reduce counter | 1205 decf ul,F ; reduce counter |
1213 return | 1206 return ; done |
1214 | 1207 |
1215 logbook_event2: ; bailout | 1208 logbook_event2: ; bailout |
1216 bsf bailout_mode ; set flag | 1209 bsf bailout_mode ; set flag |
1217 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR | 1210 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR |
1218 movlw .6 ; use Gas6 color | 1211 movlw .6 ; use Gas6 color |
1219 movwf backup_color1 | 1212 movwf backup_color1 |
1220 call TFT_color_code_gas ; use gas 6 color | 1213 call TFT_color_code_gas ; use gas 6 color |
1221 ext_flash_inc_address_0x20 d'2' ; skip two bytes | 1214 EXT_FLASH_INC_ADDRESS_0x20 d'2' ; skip two bytes |
1222 decf gaslist_gas,F ; reduce counter | 1215 decf ul,F ; reduce counter |
1223 decf gaslist_gas,F ; reduce counter | 1216 decf ul,F ; reduce counter |
1224 return | 1217 return ; done |
1225 | 1218 |
1226 logbook_event3: ; setpoint change | 1219 logbook_event3: ; setpoint change |
1227 ext_flash_inc_address_0x20 d'1' ; skip one byte | 1220 EXT_FLASH_INC_ADDRESS_0x20 d'1' ; skip one byte |
1228 decf gaslist_gas,F ; reduce counter | 1221 decf ul,F ; reduce counter |
1229 btfss bailout_mode ; in bailout? | 1222 btfss bailout_mode ; in bailout? |
1230 return ; NO - done | 1223 return ; NO - done |
1231 movff backup_color2,backup_color1 ; YES - restore color | 1224 movff backup_color2,backup_color1 ; YES - restore color |
1232 movf backup_color2,W ; - copy gas number to WREG for color-coding | 1225 movf backup_color2,W ; - copy gas number to WREG for color-coding |
1233 call TFT_color_code_gas ; - back to normal profile color | 1226 call TFT_color_code_gas ; - back to normal profile color |
1234 return ; - done | 1227 return ; - done |
1235 | 1228 |
1236 ; ------------------------------------------------------------------------ | 1229 |
1237 | 1230 ;----------------------------------------------------------------------------- |
1231 ; Helper Function - return to Dive List | |
1232 ; | |
1238 exit_profileview: | 1233 exit_profileview: |
1239 clrf gaslist_gas ; restore all registers to build same page again | 1234 clrf ul ; restore all registers to build same page again |
1240 movff logbook_divenumber_temp,logbook_divenumber | 1235 movff logbook_divenumber_temp,logbook_divenumber |
1241 movff logbook_max_dive_counter_temp,logbook_max_dive_counter | 1236 movff logbook_max_dive_counter_temp,logbook_max_dive_counter |
1242 movff logbook_temp_backup,logbook_temp | 1237 movff logbook_temp_backup,logbook_temp |
1243 incf logbook_max_dive_counter,F | 1238 incf logbook_max_dive_counter,F |
1244 decf logbook_divenumber,F | 1239 decf logbook_divenumber,F |
1245 bcf all_dives_shown | 1240 bcf all_dives_shown |
1246 clrf menu_pos_max ; number of rows used on current logbook-page | 1241 clrf menu_pos_max ; number of rows used on current logbook-page |
1247 movlw logbook_row_number | 1242 movlw logbook_row_number |
1248 movwf menu_pos_cur ; here: active row on current page | 1243 movwf menu_pos_cur ; here: active row on current page |
1249 call TFT_boot | 1244 call TFT_boot |
1250 goto logbook2 ; start search | 1245 goto logbook2 ; display dive headers |
1251 | 1246 |
1247 | |
1248 ;----------------------------------------------------------------------------- | |
1249 ; Helper Function - show next Page | |
1250 ; | |
1252 next_logbook2: | 1251 next_logbook2: |
1253 btfsc all_dives_shown ; all shown? | 1252 btfsc all_dives_shown ; all shown? |
1254 goto logbook ; YES | 1253 goto logbook ; YES |
1255 clrf menu_pos_max ; number of used rows on current logbook-page | 1254 clrf menu_pos_max ; number of used rows on current logbook-page |
1256 movlw logbook_row_number | 1255 movlw logbook_row_number |
1257 movwf menu_pos_cur | 1256 movwf menu_pos_cur |
1258 incf logbook_page_number,F ; start new screen | 1257 incf logbook_page_number,F ; start new screen |
1259 bsf keep_cursor_new_page ; keep cursor on "next page" | 1258 bsf keep_cursor_new_page ; keep cursor on "next page" |
1260 call TFT_boot | 1259 call TFT_boot |
1261 goto logbook2 ; start search | 1260 goto logbook2 ; display dive headers |
1262 | 1261 |
1262 | |
1263 ;----------------------------------------------------------------------------- | |
1264 ; Helper Function - move Cursor | |
1265 ; | |
1263 next_logbook3: | 1266 next_logbook3: |
1264 incf menu_pos_cur,F ; set cursor to next line | 1267 incf menu_pos_cur,F ; set cursor to next line |
1265 movlw logbook_row_number+.2 ; get maximum number of lines | 1268 movlw logbook_row_number+.2 ; get maximum number of lines |
1266 cpfsgt menu_pos_cur ; cursor position beyond last line? | 1269 cpfsgt menu_pos_cur ; cursor position beyond last line? |
1267 bra next_logbook3a ; NO - ok, done | 1270 bra next_logbook3a ; NO - ok, done |
1268 movlw .1 ; YES - reset to first line | 1271 movlw .1 ; YES - reset to first line |
1269 movwf menu_pos_cur ; - ... | 1272 movwf menu_pos_cur ; - ... |
1270 bra next_logbook3b ; - done | 1273 bra next_logbook3b ; - done |
1271 | 1274 |
1272 next_logbook3a: | 1275 next_logbook3a: |
1279 movlw logbook_row_number | 1282 movlw logbook_row_number |
1280 cpfseq menu_pos_max ; last dive was row logbook_row_number? | 1283 cpfseq menu_pos_max ; last dive was row logbook_row_number? |
1281 bsf all_dives_shown ; NO - set flag to load first page again (full reset) | 1284 bsf all_dives_shown ; NO - set flag to load first page again (full reset) |
1282 | 1285 |
1283 next_logbook3b: | 1286 next_logbook3b: |
1284 call TFT_logbook_cursor | 1287 call TFT_logbook_cursor ; show the cursor |
1285 goto logbook_loop_pre | 1288 goto logbook_loop_pre ; serve HMI |
1286 | 1289 |
1287 ; ------------------------------------------------------------------ | 1290 |
1288 ; list one dive | 1291 ;----------------------------------------------------------------------------- |
1292 ; Helper Function - display Dive Summery | |
1289 ; | 1293 ; |
1290 display_listdive: | 1294 display_listdive: |
1291 bsf logbook_page_not_empty ; flag page will not be empty | 1295 bsf logbook_page_not_empty ; flag page will not be empty |
1292 incf menu_pos_max,F ; increment number of lines shown | 1296 incf menu_pos_max,F ; increment number of lines shown |
1293 | 1297 |
1294 lfsr FSR2,buffer ; initialize output buffer | 1298 FONT_SIZE FT_SMALL ; set font size |
1295 WIN_FONT FT_SMALL ; select font | 1299 FONT_COLOR_MEMO ; set font color |
1296 WIN_LEFT logbook_list_left ; set horizontal output position | 1300 WIN_LEFT logbook_list_left ; set horizontal output position |
1297 decf menu_pos_max,W ; get current line -1 into WREG | 1301 decf menu_pos_max,W ; get current line -1 into WREG |
1298 mullw logbook_row_offset ; multiply with row spacing | 1302 mullw logbook_row_offset ; multiply with row spacing |
1299 movff PRODL,win_top ; set vertical output position | 1303 movff PRODL,win_top ; set vertical output position |
1304 INIT_BUFFER ; initialize output buffer | |
1300 | 1305 |
1301 ; print dive number | 1306 ; print dive number |
1302 movf logbook_divenumber,W ; get running number of the dive | 1307 movf logbook_divenumber,W ; get running number of the dive |
1303 call log_compute_divenumber ; compute dive number to show (incorporate dive number offset) | 1308 call log_compute_divenumber ; compute dive number to show (incorporate dive number offset) |
1304 bsf leftbind ; start left-aligned | 1309 bcf leftbind ; make sure dive number is printed in 5 digit format |
1305 movlw .3 ; start with 3rd digit (i.e. suppress the thousands) | 1310 output_65535 ; print dive number (0-65535) |
1306 movwf ignore_digits ; ... | 1311 movff buffer+2,buffer+0 ; drop first 2 digits |
1307 output_16dp .0 ; print dive number | 1312 movff buffer+3,buffer+1 ; ... |
1308 bcf leftbind ; end left-alignment | 1313 movff buffer+4,buffer+2 ; ... |
1314 movlw .3 ; relocate buffer pointer | |
1315 movwf FSR2L ; ... | |
1309 | 1316 |
1310 PUTC ' ' ; print a space char | 1317 PUTC ' ' ; print a space char |
1311 | 1318 |
1312 ; print dive date | 1319 ; print dive date |
1313 MOVTT header_buffer+index_date,mpr ; get date | 1320 MOVTT header_buffer+index_date,mpr ; get date |
1314 call TFT_convert_date_short ; convert and print date | 1321 call output_date_short ; print date (day and month) |
1315 | |
1316 PUTC ' ' ; print a space char | 1322 PUTC ' ' ; print a space char |
1317 | 1323 |
1318 ; print dive depth | 1324 ; print dive depth |
1319 MOVII header_buffer+index_max_depth,mpr ; get max depth | 1325 MOVII header_buffer+index_max_depth,mpr ; get max depth |
1320 | 1326 |
1323 ;bra display_listdive2_imperial ; 1 - do imperial | 1329 ;bra display_listdive2_imperial ; 1 - do imperial |
1324 | 1330 |
1325 display_listdive2_imperial: | 1331 display_listdive2_imperial: |
1326 call convert_cm_to_feet ; convert value in mpr from [cm] to [feet] | 1332 call convert_cm_to_feet ; convert value in mpr from [cm] to [feet] |
1327 PUTC ' ' ; print one space char | 1333 PUTC ' ' ; print one space char |
1328 output_16_3 ; print depth, limited to 999 | 1334 output_999 ; print depth (0-999) |
1329 STRCAT_TEXT tFeets1 ; print unit label | 1335 STRCAT_TEXT tFeets1 ; print unit label |
1330 bra display_listdive3 ; continue with common part | 1336 bra display_listdive3 ; continue with common part |
1331 | 1337 |
1332 display_listdive2_metric: | 1338 display_listdive2_metric: |
1333 bsf ignore_digit5 ; do not print the cm | 1339 bsf omit_digit_1 ; do not print 1st digit (no cm) |
1334 movlw d'1' ; do not print the first digit (no 1000 m) | 1340 bsf decimal_digit2 ; place a decimal point in front of digit 2 |
1335 movwf ignore_digits ; ... | 1341 output_65535 ; print depth (0.0x-655.3x) |
1336 output_16dp .3 ; print depth in format xxx.y | |
1337 STRCAT_TEXT tMeters ; print unit label | 1342 STRCAT_TEXT tMeters ; print unit label |
1338 PUTC ' ' ; print one space char | 1343 PUTC ' ' ; append one space char |
1339 ;bra display_listdive3 ; continue with common part | 1344 ;bra display_listdive3 ; continue with common part |
1340 | 1345 |
1341 ; print dive time | 1346 ; print dive time |
1342 display_listdive3: | 1347 display_listdive3: |
1343 MOVII header_buffer+index_divetime,mpr ; get dive time (minutes only) | 1348 MOVII header_buffer+index_divetime,mpr ; get dive time (minutes only) |
1344 output_16_3 ; print minutes (0-999 min) | 1349 output_999 ; print minutes (0-999) |
1345 STRCAT_TEXT tMinutes ; print minutes mark ("'") | 1350 STRCAT_TEXT tMinutes ; print minutes mark ("'") |
1346 clrf WREG ; create string terminator | 1351 movlw .21 ; max string length is 21 chars |
1347 movff WREG,buffer+.21 ; hard limit the output to 21 chars | 1352 call TFT_buffer_trim_length ; fill or cut buffer to correct length |
1348 STRCAT_PRINT "" ; finalize output | 1353 PRINT ; dump to screen |
1349 | |
1350 return ; done | 1354 return ; done |
1351 | 1355 |
1352 ; ------------------------------------------------------------------ | 1356 |
1353 | 1357 ;----------------------------------------------------------------------------- |
1358 ; Helper Function - show Dive Number | |
1359 ; | |
1354 logbook_show_divenumber: | 1360 logbook_show_divenumber: |
1355 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row | 1361 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row |
1356 movf divenumber,W ; log_compute_divenumber needs the list number | 1362 movf divenumber,W ; log_compute_divenumber needs the list number |
1357 call log_compute_divenumber ; compute dive number | 1363 call log_compute_divenumber ; compute dive number |
1358 bsf leftbind | 1364 bsf leftbind ; print left-aligned |
1359 output_16 ; show dive number | 1365 output_65535 ; show dive number |
1360 bcf leftbind | 1366 PRINT ; print buffer to screen |
1361 STRCAT_PRINT "" ; finalize output | |
1362 return ; done | 1367 return ; done |
1363 | 1368 |
1364 | 1369 |
1365 ;----------------------------------------------------------------------------- | 1370 ;----------------------------------------------------------------------------- |
1366 ; 1st Details Page after Profile: Dive Statistics | 1371 ; 1st Details Page after Profile: Dive Statistics |
1367 | 1372 ; |
1368 logbook_page1: ; show more info | 1373 logbook_page1: ; show more info |
1369 rcall log_details_header ; shows number, time/date and basic dive info | 1374 rcall log_details_header ; show number, time/date and basic dive data |
1370 | 1375 |
1371 btfss aux_flag ; dive done in a deco mode? | 1376 btfss aux_flag ; dive done in a deco mode? |
1372 bra logbook_page1_1 ; NO | 1377 bra logbook_page1_1 ; NO |
1373 | 1378 |
1374 ; deco model | 1379 ; deco model |
1378 bra logbook_decomodel_1 ; NO - ZH-L16 | 1383 bra logbook_decomodel_1 ; NO - ZH-L16 |
1379 ;bra logbook_decomodel_2 ; YES - ZH-L16+GF | 1384 ;bra logbook_decomodel_2 ; YES - ZH-L16+GF |
1380 | 1385 |
1381 logbook_decomodel_2: | 1386 logbook_decomodel_2: |
1382 ; deco model GF version | 1387 ; deco model GF version |
1383 STRCAT_PRINT "ZHL-16+GF" | 1388 STRCAT_PRINT "ZH-L16+GF" ; print model label |
1384 WIN_SMALL .5,.90 | 1389 WIN_SMALL .5,.90 ; set position |
1385 STRCPY_TEXT tGF2 | 1390 STRCPY_TEXT tSD2 ; print label |
1386 MOVII header_buffer+index_gf_lo_hi,mpr ; get GF factors | 1391 MOVII header_buffer+index_gf_lo_hi,mpr ; get GF factors |
1387 output_8 ; print GF lo | 1392 bra logbook_decomodel_com ; continue with common part |
1388 STRCAT "%/" | |
1389 movff hi,lo ; print GF hi | |
1390 output_8 ; ... | |
1391 STRCAT_PRINT "%" | |
1392 bra logbook_cns | |
1393 | 1393 |
1394 logbook_decomodel_1: | 1394 logbook_decomodel_1: |
1395 ; deco model none-GF version | 1395 ; deco model none-GF version |
1396 STRCAT_PRINT "ZH-L16" | 1396 STRCAT_PRINT "ZH-L16" ; print model label |
1397 WIN_SMALL .5,.90 | 1397 WIN_SMALL .5,.90 ; set position |
1398 STRCPY_TEXT tGF2 ; print label | |
1398 MOVII header_buffer+index_factor_sat_desat,mpr; get both factors | 1399 MOVII header_buffer+index_factor_sat_desat,mpr; get both factors |
1399 output_8 ; print saturation factor | 1400 ;bra logbook_decomodel_com ; continue with common part |
1401 | |
1402 logbook_decomodel_com: | |
1403 output_256 ; print saturation factor | |
1400 STRCAT "%/" | 1404 STRCAT "%/" |
1401 movff hi,lo ; print desaturation factor | 1405 movff hi,lo ; print desaturation factor |
1402 output_8 ; ... | 1406 output_256 ; ... |
1403 STRCAT_PRINT "%" | 1407 PUTC_PRINT "%" ; append unit and dump buffer to screen |
1404 ;bra logbook_cns | |
1405 | 1408 |
1406 logbook_cns: | 1409 logbook_cns: |
1407 WIN_SMALL .5,.115 | 1410 WIN_SMALL .5,.115 |
1408 STRCPY_TEXT tCNS2 | 1411 STRCPY_TEXT tCNS2 |
1409 MOVII header_buffer+index_cns_start,mpr ; get CNS at start of dive | 1412 MOVII header_buffer+index_cns_start,mpr ; get CNS at start of dive |
1410 bcf mpr+1,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) | 1413 bcf mpr+1,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) |
1411 bcf mpr+1,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) | 1414 bcf mpr+1,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) |
1412 output_16 | 1415 output_999 ; print CNS % (0-999) |
1413 STRCAT "->" | 1416 STRCAT "->" ; print an arrow |
1414 MOVII header_buffer+index_cns_end,mpr ; get CNS at end of dive | 1417 MOVII header_buffer+index_cns_end,mpr ; get CNS at end of dive |
1415 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) | 1418 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) |
1416 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) | 1419 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) |
1417 output_16 | 1420 output_999 ; print CNS % (0-999) |
1418 STRCAT_PRINT "%" | 1421 PUTC_PRINT "%" ; append unit and dump buffer to screen |
1419 | 1422 |
1420 logbook_page1_1: | 1423 logbook_page1_1: |
1421 WIN_SMALL .5,.140 | 1424 WIN_SMALL .5,.140 |
1422 STRCPY_TEXT tAVG | 1425 STRCPY_TEXT tAVG |
1423 MOVII header_buffer+index_avr_depth,mpr ; get average depth | 1426 MOVII header_buffer+index_avr_depth,mpr ; get average depth |
1426 bra logbook_page1_1_metric ; do metric | 1429 bra logbook_page1_1_metric ; do metric |
1427 ;bra logbook_page1_1_imperial ; do imperial | 1430 ;bra logbook_page1_1_imperial ; do imperial |
1428 | 1431 |
1429 logbook_page1_1_imperial: | 1432 logbook_page1_1_imperial: |
1430 call convert_cm_to_feet ; convert value in lo:hi from [cm] to [feet] | 1433 call convert_cm_to_feet ; convert value in lo:hi from [cm] to [feet] |
1431 PUTC ' ' | 1434 PUTC ' ' ; addend a space |
1432 output_16_3 ; limit to 999 and display only (0-999) | 1435 output_999 ; print depth (0-999) |
1433 STRCAT_PRINT "ft" | 1436 STRCAT_PRINT "ft" ; append unit and dump to screen |
1434 bra logbook_page1_1_common | 1437 bra logbook_page1_1_common ; continue |
1435 | 1438 |
1436 logbook_page1_1_metric: | 1439 logbook_page1_1_metric: |
1437 bsf ignore_digit5 ; no cm (flag will be cleared by output_16) | 1440 bsf decimal_digit2 ; place a decimal point in front of digit 2 |
1438 movlw .1 ; no 1000 meters | 1441 bsf omit_digit_1 ; do not print 1st digit |
1439 movwf ignore_digits ; ... | 1442 output_65535 ; print depth (0.0x - 999.9x) |
1440 output_16dp .3 ; xxx.y | 1443 PUTC_PRINT "m" ; append unit and dump buffer to screen |
1441 STRCAT_PRINT "m" | 1444 ;bra logbook_page1_1_common ; continue |
1442 ;bra logbook_page1_1_common | |
1443 | 1445 |
1444 logbook_page1_1_common: | 1446 logbook_page1_1_common: |
1445 btfss aux_flag ; dive done in a deco mode? | 1447 btfss aux_flag ; dive done in a deco mode? |
1446 bra logbook_page1_2 ; NO | 1448 bra logbook_page1_2 ; NO |
1447 | 1449 |
1448 ; Salinity | 1450 ; Salinity |
1449 WIN_SMALL .5,.165 ; ex WIN_SMALL .5,.140 | 1451 WIN_SMALL .5,.165 ; set position |
1450 STRCPY_TEXT tDvSalinity2 | 1452 STRCPY_TEXT tDvSalinity2 ; print label |
1451 bsf leftbind | |
1452 MOVCC header_buffer+index_salinity,lo ; read salinity | 1453 MOVCC header_buffer+index_salinity,lo ; read salinity |
1453 output_8 | 1454 output_99 ; print salinity (0-99, effectively 0-4 with leading space) |
1454 STRCAT_PRINT "%" | 1455 PUTC_PRINT "%" ; append unit and dump to screen |
1455 | 1456 |
1456 ; Last deco | 1457 ; Last deco |
1457 WIN_SMALL .5,.190 | 1458 WIN_SMALL .5,.190 ; set position |
1458 STRCPY_TEXT tLastDeco | 1459 STRCPY_TEXT tLastDeco ; print label |
1459 MOVCC header_buffer+index_last_stop,lo ; read last stop depth | 1460 MOVCC header_buffer+index_last_stop,lo ; read last stop depth |
1460 output_8 | 1461 output_99 ; print depth (0-99, effectively 0-6 with leading space) |
1461 STRCAT_PRINT "m" | 1462 PUTC_PRINT "m" ; append unit and dump to screen |
1462 | 1463 |
1463 logbook_page1_2: | 1464 logbook_page1_2: |
1464 movlw color_lightblue | 1465 movlw color_lightblue ; select color |
1465 call TFT_set_color | 1466 WIN_FRAME_COLOR .63,.220,.2,.105 ; top, bottom, left, right |
1466 WIN_FRAME_COLOR16 .63,.220,.2,.105 ; top, bottom, left, right | |
1467 | 1467 |
1468 ; Firmware | 1468 ; Firmware |
1469 call TFT_standard_color | 1469 FONT_COLOR_MEMO ; set font color |
1470 WIN_SMALL .110,.65 | 1470 WIN_SMALL .110,.65 ; set output position |
1471 STRCAT "V:" | 1471 STRCAT "V:" ; print "V:" |
1472 MOVII header_buffer+index_firmware,mpr ; get firmware version | 1472 MOVII header_buffer+index_firmware,mpr ; get firmware version |
1473 movff lo,up ; keep a backup of major in up | 1473 movff lo,up ; keep a backup of major in up |
1474 bsf leftbind ; print left-aligned | 1474 bsf leftbind ; print left-aligned |
1475 output_8 ; print major version (in 1 digit due to leftbind) | 1475 output_99 ; print major version |
1476 PUTC "." ; print "." | 1476 PUTC "." ; print "." |
1477 movff hi,lo ; print minor version... | 1477 movff hi,lo ; print minor version... |
1478 output_99x ; ... in 2 digit format | 1478 output_99x ; ... in 2 digit format |
1479 STRCAT_PRINT "" ; finalize output | 1479 PRINT ; print buffer to screen |
1480 | 1480 |
1481 logbook_battery_hwos_tech: | |
1482 ; all hwos tech >= 2.15 also stored battery % | |
1481 movf up,W ; get major into WREG | 1483 movf up,W ; get major into WREG |
1482 xorlw .3 ; major == 3 ? | 1484 xorlw .3 ; major == 3 ? |
1483 bz logbook_battery_percent ; YES - show battery % | 1485 bz logbook_battery_percent ; YES - show battery % |
1484 movf up,W ; NO - get major into WREG (again) | 1486 movf up,W ; NO - get major into WREG (again) |
1485 xorlw .2 ; major == 2 ? | 1487 xorlw .2 ; major == 2 ? |
1486 bnz logbook_battery_voltage ; NO - skip battery % | 1488 bnz logbook_battery_hwos_sport ; NO - check for hwos sport |
1487 movlw .14 ; YES - check minor version | 1489 movlw .14 ; YES - check minor version |
1488 cpfsgt lo ; - minor > 14 ? | 1490 cpfsgt lo ; - minor > 14 ? |
1489 bra logbook_battery_voltage ; NO - skip battery % | 1491 bra logbook_battery_hwos_sport ; NO - check for hwos sport |
1490 ;bra logbook_battery_percent ; YES - show battery % | 1492 bra logbook_battery_percent ; YES - show battery % |
1493 | |
1494 logbook_battery_hwos_sport: | |
1495 ; all hwos_sport >= 10.34 also stored battery % | |
1496 ; check major again for .10 (for maintainability) | |
1497 movf up,W ; get major into WREG | |
1498 xorlw .10 ; major == 10 ? | |
1499 bnz logbook_battery_voltage ; NO - skip battery % | |
1500 movlw .33 ; YES - check minor version | |
1501 cpfsgt lo ; - minor > 33 ? | |
1502 bra logbook_battery_voltage ; NO - skip battery % | |
1503 ;bra logbook_battery_percent ; YES - show battery % | |
1491 | 1504 |
1492 ; Battery % | 1505 ; Battery % |
1493 logbook_battery_percent: | 1506 logbook_battery_percent: |
1494 WIN_SMALL .110,.140 | 1507 WIN_SMALL .110,.140 |
1495 MOVCC header_buffer+index_batt_percent,lo ; get battery percent | 1508 MOVCC header_buffer+index_batt_percent,lo ; get battery percent |
1496 output_8 ; print battery percent | 1509 output_256 ; print battery percent |
1497 STRCAT_PRINT "%" ; print "%" and finalize output | 1510 PUTC_PRINT "%" ; append "%" and dump buffer to screen |
1498 | 1511 |
1499 ; Battery Voltage | 1512 ; Battery Voltage |
1500 logbook_battery_voltage: | 1513 logbook_battery_voltage: |
1501 WIN_SMALL .110,.90 | 1514 WIN_SMALL .110,.90 ; set position |
1502 STRCAT_PRINT "Batt:" | 1515 STRCAT_PRINT "Batt:" ; print label |
1503 WIN_SMALL .110,.115 | 1516 WIN_SMALL .110,.115 ; set position |
1504 MOVII header_buffer+index_battery_voltage,mpr ; get battery voltage | 1517 MOVII header_buffer+index_battery_voltage,mpr ; get battery voltage |
1505 output_16dp .2 ; print battery voltage | 1518 bsf decimal_digit3 ; place a decimal point in front of digit 3 |
1506 STRCAT_PRINT "V" ; print unit (Volt) | 1519 output_9999 ; print battery voltage (0.000-9.999) |
1520 PUTC_PRINT "V" ; append unit and dump buffer to screen | |
1507 | 1521 |
1508 ; Surface Pressure | 1522 ; Surface Pressure |
1509 MOVII header_buffer+index_surface_press,mpr ; get surface pressure | 1523 MOVII header_buffer+index_surface_press,mpr ; get surface pressure |
1510 WIN_SMALL .110,.165 ; set output position | 1524 WIN_SMALL .110,.165 ; set output position |
1511 bsf leftbind ; print without leading spaces | 1525 output_9999 ; print surface pressure before dive (0-9999) |
1512 output_16 ; print surface pressure before dive | 1526 STRCAT_TEXT_PRINT tMBAR ; append unit and dump to screen |
1513 STRCAT_TEXT tMBAR ; print unit | |
1514 clrf WREG ; string terminator | |
1515 movff WREG,buffer+7 ; limit to 7 chars | |
1516 STRCAT_PRINT "" ; dump buffer to screen | |
1517 | 1527 |
1518 movlw color_greenish ; select color | 1528 movlw color_greenish ; select color |
1519 call TFT_set_color ; ... | 1529 WIN_FRAME_COLOR .63,.220,.107,.159 ; draw a frame with coordinates top, bottom, left, right |
1520 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; draw a frame with coordinates top, bottom, left, right | |
1521 | 1530 |
1522 ; handle HMI | 1531 ; handle HMI |
1523 rcall logbook_preloop_tasks ; clear timeout and remaining button events | 1532 rcall logbook_preloop_tasks ; clear timeout and remaining button events |
1524 display_details1_loop: | 1533 display_details1_loop: |
1525 btfsc switch_right ; right button pressed? | 1534 btfsc switch_right ; right button pressed? |
1535 ;bra logbook_page2 ; YES - show more details | 1544 ;bra logbook_page2 ; YES - show more details |
1536 | 1545 |
1537 | 1546 |
1538 ;----------------------------------------------------------------------------- | 1547 ;----------------------------------------------------------------------------- |
1539 ; 2nd Details Page after Profile: Tissue and Decompression Status | 1548 ; 2nd Details Page after Profile: Tissue and Decompression Status |
1540 | 1549 ; |
1541 logbook_page2: | 1550 logbook_page2: |
1542 | 1551 |
1543 ; ################# to be removed later ################################## | 1552 ; skip this page for dives recorded with internal profile < 0x01 |
1544 ; movlw fw_version_beta ; get beta status | 1553 |
1545 ; tstfsz WREG ; beta? | 1554 MOVCC header_buffer+index_profile_version,WREG; read profile format version |
1546 ; bra display_page2_betajump ; YES - omit firmware version check | 1555 andlw b'11000000' ; keep only the internal part of the profile version |
1547 ; ######################################################################## | 1556 bnz logbook_page2a ; show page 2 if internal version > 0 |
1548 | 1557 bra logbook_page3 ; skip page 2 if internal version is 0 |
1549 ; skip this page for dives recorded with firmwares < 3.09 | 1558 |
1550 MOVII header_buffer+index_firmware,mpr ; get firmware version major and minor | 1559 logbook_page2a: |
1551 | 1560 |
1552 movlw .2 ; minimum required major is 3, -1 for cpfsgt | 1561 rcall log_details_header ; show number, time/date and basic dive data |
1553 cpfsgt lo ; major >= requirement? | |
1554 bra logbook_page3 ; NO - skip this page | |
1555 movlw .8 ; YES - minimum required minor is 9, -1 for cpfsgt | |
1556 cpfsgt hi ; - minor >= requirement? | |
1557 bra logbook_page3 ; NO - skip this page | |
1558 | |
1559 ; ################# to be removed later ################################## | |
1560 display_page2_betajump: | |
1561 ; ######################################################################## | |
1562 | |
1563 rcall log_details_header ; shows number, time/date and basic dive info | |
1564 | 1562 |
1565 ; basic configuration of tissue graphics | 1563 ; basic configuration of tissue graphics |
1566 bsf tissue_graphic_mode ; select logbook mode | 1564 bsf tissue_graphic_mode ; select logbook mode |
1567 bcf tissue_graphic_layout ; select press+sat | 1565 bcf tissue_graphic_layout ; select press+sat |
1568 bcf tissue_graphic_cns ; do not show CNS value | 1566 bcf tissue_graphic_cns ; do not show CNS value |
1572 MOVCC header_buffer+index_decomodel,WREG ; get deco model (0= ZH-L16, 1=ZH-L16+GF) | 1570 MOVCC header_buffer+index_decomodel,WREG ; get deco model (0= ZH-L16, 1=ZH-L16+GF) |
1573 dcfsnz WREG ; GF model? | 1571 dcfsnz WREG ; GF model? |
1574 bsf tissue_graphic_gf ; YES - show GF lines | 1572 bsf tissue_graphic_gf ; YES - show GF lines |
1575 | 1573 |
1576 ; draw the graphics | 1574 ; draw the graphics |
1577 call TFT_surface_tissues | 1575 call TFT_surf_cv_tissues |
1578 | 1576 |
1579 ; calculate time/date of the end of the dive | 1577 ; calculate time/date of the end of the dive |
1580 MOVTT header_buffer+index_date, rtc_latched_year ; get start of the dive - year, month, day | 1578 MOVTT header_buffer+index_date, rtc_latched_year ; get start of the dive - year, month, day |
1581 MOVII header_buffer+index_time, rtc_latched_hour ; get start of the dive - hour, minute | 1579 MOVII header_buffer+index_time, rtc_latched_hour ; get start of the dive - hour, minute |
1582 MOVCC header_buffer+index_divetime+2,rtc_latched_secs ; get duration of the dive - seconds | 1580 MOVCC header_buffer+index_divetime+2,rtc_latched_secs ; get duration of the dive - seconds |
1584 call rtc_add_minutes ; add minutes in mpr to time/date in rtc_latched | 1582 call rtc_add_minutes ; add minutes in mpr to time/date in rtc_latched |
1585 | 1583 |
1586 ; print time/date of the end of the dive | 1584 ; print time/date of the end of the dive |
1587 WIN_SMALL .8,.193 ; select font and output position | 1585 WIN_SMALL .8,.193 ; select font and output position |
1588 MOVTT rtc_latched_year,mpr ; get computed end-of-dive date | 1586 MOVTT rtc_latched_year,mpr ; get computed end-of-dive date |
1589 call TFT_convert_date_short ; convert and print date | 1587 call output_date_short ; print date (day and month) |
1590 STRCAT ".-" ; print spacing ".-" | 1588 STRCAT ".-" ; print spacing ".-" |
1591 MOVII rtc_latched_hour,mpr ; get computed end-of-dive time | 1589 MOVII rtc_latched_hour,mpr ; get computed end-of-dive time |
1592 output_99x ; print hour | 1590 output_99x ; print hour |
1593 PUTC ':' ; print spacing ":" | 1591 PUTC ':' ; print spacing ":" |
1594 movff hi,lo ; print minute | 1592 movff hi,lo ; print minute |
1595 output_99x ; ... | 1593 output_99x ; ... |
1596 STRCAT_PRINT "" ; finalize output | 1594 PRINT ; print buffer to screen |
1597 | 1595 |
1598 | 1596 |
1599 ; draw a white frame around the time/date | 1597 ; draw a white frame around the time/date |
1600 WIN_FRAME_STD surf_tissue_diagram_bottom,.220, surf_tissue_diagram_left, surf_tissue_diagram_right | 1598 WIN_FRAME_STD surf_tissue_diagram_bottom,.220, surf_tissue_diagram_left, surf_tissue_diagram_right |
1601 | 1599 |
1612 STRCAT_TEXT_PRINT tBeginOfDive ; print "Begin" | 1610 STRCAT_TEXT_PRINT tBeginOfDive ; print "Begin" |
1613 | 1611 |
1614 ; 2nd line: | 1612 ; 2nd line: |
1615 WIN_SMALL .100+.28,.93 ; +16 for centered, +28 for right-aligned | 1613 WIN_SMALL .100+.28,.93 ; +16 for centered, +28 for right-aligned |
1616 MOVCC header_buffer+index_supersat_start,lo ; get supersaturation at start of dive | 1614 MOVCC header_buffer+index_supersat_start,lo ; get supersaturation at start of dive |
1617 bcf leftbind | 1615 output_256 ; print percent value |
1618 output_8 ; print percent value | 1616 PUTC_PRINT "%" ; append "%" and dump buffer to screen |
1619 STRCAT_PRINT "%" ; print "%" and finalize output | |
1620 | 1617 |
1621 ; 3rd line: | 1618 ; 3rd line: |
1622 WIN_SMALL .100,.118 | 1619 WIN_SMALL .100,.118 |
1623 STRCAT_TEXT_PRINT tEndOfDive ; print "End" | 1620 STRCAT_TEXT_PRINT tEndOfDive ; print "End" |
1624 | 1621 |
1625 ; 4th line: | 1622 ; 4th line: |
1626 WIN_SMALL .100+.28,.143 ; +16 for centered, +28 for right-aligned | 1623 WIN_SMALL .100+.28,.143 ; +16 for centered, +28 for right-aligned |
1627 MOVCC header_buffer+index_supersat_end,lo ; get supersaturation at end of dive | 1624 MOVCC header_buffer+index_supersat_end,lo ; get supersaturation at end of dive |
1628 bcf leftbind | 1625 output_256 ; print percent value |
1629 output_8 ; print percent value | 1626 PUTC_PRINT "%" ; append "%" and dump buffer to screen |
1630 STRCAT_PRINT "%" ; print "%" and finalize output | |
1631 | 1627 |
1632 ; 5th line: desaturation time label | 1628 ; 5th line: desaturation time label |
1633 WIN_SMALL .100,.168 | 1629 WIN_SMALL .100,.168 |
1634 STRCAT_TEXT_PRINT tDesatTime ; print "Desat" | 1630 STRCAT_TEXT_PRINT tDesatTime ; print "Desat" |
1635 | 1631 |
1642 movwf hi ; ... | 1638 movwf hi ; ... |
1643 output_99 ; print hours in 0-99 | 1639 output_99 ; print hours in 0-99 |
1644 PUTC 'h' ; print hours mark | 1640 PUTC 'h' ; print hours mark |
1645 movff hi,lo ; print minutes... | 1641 movff hi,lo ; print minutes... |
1646 output_99x ; ... in two digits, leading zero | 1642 output_99x ; ... in two digits, leading zero |
1647 STRCAT_PRINT "m" ; print minutes mark and finalize output | 1643 PUTC_PRINT "m" ; append minutes mark and dump buffer to screen |
1648 | 1644 |
1649 ; draw a colored frame around the right side | 1645 ; draw a colored frame around the right side |
1650 movlw color_orange ; select color | 1646 movlw color_orange ; select color |
1651 call TFT_set_color ; ... | 1647 WIN_FRAME_COLOR .65,.220,.97,.159 ; draw a frame with coordinates top, bottom, left, right |
1652 WIN_FRAME_COLOR16 .65,.220,.97,.159 ; draw a frame with coordinates top, bottom, left, right | |
1653 | 1648 |
1654 ; handle HMI | 1649 ; handle HMI |
1655 rcall logbook_preloop_tasks ; clear timeout and remaining button events | 1650 rcall logbook_preloop_tasks ; clear timeout and left-over button events |
1656 display_details1b_loop: | 1651 display_details1b_loop: |
1657 btfsc switch_right ; right button pressed? | 1652 btfsc switch_right ; right button pressed? |
1658 bra logbook_page3 ; YES - show more info | 1653 bra logbook_page3 ; YES - show more info |
1659 btfsc switch_left ; left button pressed? | 1654 btfsc switch_left ; left button pressed? |
1660 bra exit_profileview ; YES - back to list | 1655 bra exit_profileview ; YES - back to list |
1661 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode | 1656 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode |
1662 bra display_details1b_loop ; - loop waiting for something to do | 1657 bra display_details1b_loop ; - loop waiting for something to do |
1663 | 1658 |
1664 | 1659 |
1665 ;----------------------------------------------------------------------------- | 1660 ;----------------------------------------------------------------------------- |
1666 ; helper function | 1661 ; Helper Function - clear Timeout and left-over Button Events |
1662 ; | |
1667 logbook_preloop_tasks: | 1663 logbook_preloop_tasks: |
1668 movlw CCP1CON_VALUE ; see hwos.inc | 1664 movlw CCP1CON_VALUE ; see hwos.inc |
1669 movwf CCP1CON ; power-on backlight | 1665 movwf CCP1CON ; power-on backlight |
1670 call TFT_standard_color ; revert to standard color | 1666 FONT_COLOR_MEMO ; revert font color to standard |
1671 call reset_timeout_surfmode ; reset timeout | 1667 call reset_timeout_surfmode ; reset timeout |
1672 bcf switch_left ; clear left-over left button event | 1668 bcf switch_left ; clear left-over left button event |
1673 bcf switch_right ; clear left-over right button event | 1669 bcf switch_right ; clear left-over right button event |
1674 return ; done | 1670 return ; done |
1675 | 1671 |
1676 ;----------------------------------------------------------------------------- | 1672 ;----------------------------------------------------------------------------- |
1677 ; 3rd Details Page after Profile: Gases / Diluents | 1673 ; 3rd Details Page after Profile: Gases / Diluents |
1678 | 1674 ; |
1679 logbook_page3: | 1675 logbook_page3: |
1680 rcall log_details_header ; shows number, time/date and basic dive info | 1676 rcall log_details_header ; show number, time/date and basic dive data |
1677 | |
1681 lfsr FSR0,header_buffer+index_gas1 ; load base address of the gases | 1678 lfsr FSR0,header_buffer+index_gas1 ; load base address of the gases |
1682 bcf log_show_gas_short ; do the long version of log_show_gas | 1679 bcf log_show_gas_short ; do the long version of log_show_gas |
1683 bcf leftbind | |
1684 | 1680 |
1685 WIN_SMALL .5,.90 | 1681 WIN_SMALL .5,.90 |
1686 movlw .1 ; color for gas 1 | 1682 movlw .1 ; color for gas 1 |
1687 rcall log_show_gas | 1683 rcall log_show_gas |
1688 | 1684 |
1701 WIN_SMALL .5,.190 | 1697 WIN_SMALL .5,.190 |
1702 movlw .5 ; color for gas 5 | 1698 movlw .5 ; color for gas 5 |
1703 rcall log_show_gas | 1699 rcall log_show_gas |
1704 | 1700 |
1705 ; OC/CC gas list | 1701 ; OC/CC gas list |
1706 WIN_SMALL .5,.65 | 1702 WIN_SMALL .5,.65 ; set title position |
1707 WIN_COLOR color_greenish | 1703 FONT_COLOR color_greenish ; set title color |
1708 | 1704 |
1709 MOVCC header_buffer+index_divemode,WREG ; read dive mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4= pSCR) | 1705 MOVCC header_buffer+index_divemode,WREG ; read dive mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4= pSCR) |
1710 decfsz WREG,W ; dive mode = CC ? | 1706 decfsz WREG,W ; dive mode = CC ? |
1711 bra logbook_page3a ; NO - print OC title | 1707 bra logbook_page3a ; NO - print OC title |
1712 STRCPY_TEXT_PRINT tGaslistCC ; YES - print CC title | 1708 STRCPY_TEXT_PRINT tGaslistCC ; YES - print CC title |
1713 bra logbook_page3b ; - continue with common part | 1709 bra logbook_page3b ; - continue with common part |
1714 logbook_page3a: | 1710 logbook_page3a: |
1715 STRCPY_TEXT_PRINT tGaslist ; print OC title | 1711 STRCPY_TEXT_PRINT tGaslist ; print OC title |
1716 logbook_page3b: | 1712 logbook_page3b: |
1717 movlw color_lightblue ; select color | 1713 movlw color_lightblue ; select frame color |
1718 call TFT_set_color ; set color | 1714 WIN_FRAME_COLOR .63,.220,.2,.114 ; draw frame (top, bottom, left, right) |
1719 WIN_FRAME_COLOR16 .63,.220,.2,.114 ; draw a frame with coordinates top, bottom, left, right | |
1720 | 1715 |
1721 ; handle HMI | 1716 ; handle HMI |
1722 rcall logbook_preloop_tasks ; clear timeout, some flags and set to speed_eco | 1717 rcall logbook_preloop_tasks ; clear timeout, some flags and set to speed_eco |
1723 display_details2_loop: | 1718 display_details2_loop: |
1724 btfsc switch_right ; right button pressed? | 1719 btfsc switch_right ; right button pressed? |
1729 bra display_details2_loop ; - loop waiting for something to do | 1724 bra display_details2_loop ; - loop waiting for something to do |
1730 | 1725 |
1731 | 1726 |
1732 ;----------------------------------------------------------------------------- | 1727 ;----------------------------------------------------------------------------- |
1733 ; 4th Details Page after Profile: Setpoints | 1728 ; 4th Details Page after Profile: Setpoints |
1734 | 1729 ; |
1735 logbook_page4: | 1730 logbook_page4: |
1736 MOVCC header_buffer+index_divemode,WREG ; get dive mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4= pSCR) | 1731 MOVCC header_buffer+index_divemode,WREG ; get dive mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4= pSCR) |
1737 decfsz WREG,W ; =1 (CC)? | 1732 decfsz WREG,W ; =1 (CC)? |
1738 goto display_profile2 ; NO - skip setpoints | 1733 goto display_profile2 ; NO - skip setpoints |
1739 | 1734 |
1740 rcall log_details_header ; shows number, time/date and basic dive info | 1735 rcall log_details_header ; show number, time/date and basic dive data |
1741 | 1736 |
1742 ; print setpoint list | 1737 ; print setpoint list |
1743 lfsr FSR0,header_buffer+index_sp1 ; load base address of the setpoints | 1738 lfsr FSR0,header_buffer+index_sp1 ; load base address of the setpoints |
1744 WIN_SMALL .5,.65 | 1739 WIN_SMALL .5,.65 ; set title position |
1745 WIN_COLOR color_greenish | 1740 FONT_COLOR color_greenish ; set title color |
1746 STRCPY_TEXT_PRINT tFixedSetpoints | 1741 STRCPY_TEXT_PRINT tFixedSetpoints ; print title |
1747 call TFT_standard_color | 1742 FONT_COLOR_MEMO ; set font color |
1748 WIN_SMALL .5,.90 | 1743 WIN_SMALL .5,.90 ; set position |
1749 rcall log_show_sp | 1744 rcall log_show_sp ; print setpoint data set |
1750 WIN_SMALL .5,.115 | 1745 WIN_SMALL .5,.115 ; set position |
1751 rcall log_show_sp | 1746 rcall log_show_sp ; print setpoint data set |
1752 WIN_SMALL .5,.140 | 1747 WIN_SMALL .5,.140 ; set position |
1753 rcall log_show_sp | 1748 rcall log_show_sp ; print setpoint data set |
1754 WIN_SMALL .5,.165 | 1749 WIN_SMALL .5,.165 ; set position |
1755 rcall log_show_sp | 1750 rcall log_show_sp ; print setpoint data set |
1756 WIN_SMALL .5,.190 | 1751 WIN_SMALL .5,.190 ; set position |
1757 rcall log_show_sp | 1752 rcall log_show_sp ; print setpoint data set |
1758 | 1753 |
1759 movlw color_greenish | 1754 movlw color_greenish ; select color for the frame |
1760 call TFT_set_color | 1755 WIN_FRAME_COLOR .63,.220,.2,.112 ; draw frame (top, bottom, left, right) |
1761 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; top, bottom, left, right | |
1762 | 1756 |
1763 ; handle HMI | 1757 ; handle HMI |
1764 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco | 1758 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco |
1765 display_details3_loop: | 1759 display_details3_loop: |
1766 btfsc switch_right ; right button pressed? | 1760 btfsc switch_right ; right button pressed? |
1770 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode | 1764 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode |
1771 bra display_details3_loop ; - loop waiting for something to do | 1765 bra display_details3_loop ; - loop waiting for something to do |
1772 | 1766 |
1773 | 1767 |
1774 ;----------------------------------------------------------------------------- | 1768 ;----------------------------------------------------------------------------- |
1775 ; Helper Functions | 1769 ; Helper Function - show Dive Number, Time/Date and basic Dive Data |
1776 | 1770 ; |
1777 log_details_header: | 1771 log_details_header: |
1778 call TFT_boot | 1772 call TFT_boot ; initialize display |
1779 call TFT_standard_color | 1773 FONT_COLOR_MEMO ; set font color |
1780 | 1774 |
1781 rcall logbook_show_divenumber ; show the dive number in medium font | 1775 rcall logbook_show_divenumber ; show the dive number in medium font |
1782 | 1776 |
1783 ; show date and time in first row | 1777 ; show date and time in first row |
1784 WIN_SMALL .59,.10 | 1778 WIN_SMALL .59,.10 |
1785 MOVTT header_buffer+index_date,mpr ; get date | 1779 MOVTT header_buffer+index_date,mpr ; get date |
1786 call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in buffer | 1780 call output_date ; print date |
1787 | 1781 PUTC "-" ; print "-" |
1788 PUTC "-" | |
1789 | |
1790 MOVII header_buffer+index_time,mpr ; get time | 1782 MOVII header_buffer+index_time,mpr ; get time |
1791 output_99x ; print hour | 1783 output_99x ; print hour |
1792 PUTC ':' ; print spacing ":" | 1784 PUTC ':' ; print spacing ":" |
1793 movff hi,lo ; print minute | 1785 movff hi,lo ; print minute |
1794 output_99x ; ... | 1786 output_99x ; ... |
1795 STRCAT_PRINT "" ; display 1st row of details | 1787 PRINT ; dump to screen |
1796 | 1788 |
1797 ; show max depth and dive time | 1789 ; show max depth and dive time |
1798 WIN_SMALL .5,.35 | 1790 WIN_SMALL .5,.35 |
1799 STRCAT "Max:" | 1791 STRCAT "Max:" |
1800 MOVII header_buffer+index_max_depth,mpr ; get max depth | 1792 MOVII header_buffer+index_max_depth,mpr ; get max depth |
1803 bra logbook_page2_depth_metric ; 1 - do metric | 1795 bra logbook_page2_depth_metric ; 1 - do metric |
1804 ;bra logbook_page2_depth_imperial ; 0 - do imperial | 1796 ;bra logbook_page2_depth_imperial ; 0 - do imperial |
1805 | 1797 |
1806 logbook_page2_depth_imperial: | 1798 logbook_page2_depth_imperial: |
1807 call convert_cm_to_feet ; convert value in lo:hi from [cm] to [feet] | 1799 call convert_cm_to_feet ; convert value in lo:hi from [cm] to [feet] |
1808 PUTC ' ' | 1800 PUTC ' ' ; append a space |
1809 bcf leftbind | 1801 output_999 ; print depth |
1810 output_16_3 | 1802 STRCAT_TEXT tFeets ; append unit |
1811 STRCAT_TEXT tFeets | 1803 bra logbook_page2_depth_common ; continue |
1812 bra logbook_page2_depth_common | |
1813 | 1804 |
1814 logbook_page2_depth_metric: | 1805 logbook_page2_depth_metric: |
1815 bsf ignore_digit5 ; no cm... | 1806 bsf omit_digit_1 ; do not print 1st digit |
1816 movlw d'1' ; no 1000 m | 1807 bsf decimal_digit2 ; place a decimal point in front of digit 2 |
1817 movwf ignore_digits ; ... | 1808 output_65535 ; print depth (0.0x-655.3x) |
1818 output_16dp d'3' ; xxy.y | 1809 STRCAT_TEXT tMeters ; append unit |
1819 STRCAT_TEXT tMeters | 1810 ;bra logbook_page2_depth_common ; continue |
1820 ;bra logbook_page2_depth_common | |
1821 | 1811 |
1822 logbook_page2_depth_common: | 1812 logbook_page2_depth_common: |
1823 STRCAT " - " | 1813 STRCAT " - " |
1824 MOVTT header_buffer+index_divetime,mpr ; get dive time | 1814 MOVTT header_buffer+index_divetime,mpr ; get dive time |
1825 bsf leftbind | 1815 bsf leftbind ; print left-aligned |
1826 output_16 ; print minutes | 1816 output_9999 ; print minutes (0-9999) |
1827 PUTC "m" | 1817 PUTC "m" ; append unit |
1828 movff up,lo ; print seconds | 1818 movff up,lo ; print seconds |
1829 output_99x ; ... | 1819 output_99x ; ... |
1830 STRCAT_PRINT "s" | 1820 PUTC_PRINT "s" ; append unit and dump buffer to screen |
1831 return | 1821 return ; done |
1832 | 1822 |
1833 | 1823 |
1824 ;----------------------------------------------------------------------------- | |
1825 ; Helper Function - show Setpoint Data | |
1826 ; | |
1834 log_show_sp: | 1827 log_show_sp: |
1835 ; log point is set by caller | 1828 ; log point is set by caller |
1836 MOVCC POSTINC0,lo ; copy set point into lo | 1829 MOVCC POSTINC0,lo ; copy set point into lo |
1837 MOVCC POSTINC0,hi ; copy change depth into hi | 1830 MOVCC POSTINC0,hi ; copy change depth into hi |
1838 | 1831 |
1839 movff mpr+1,mpr+2 ; save change depth | 1832 movff mpr+1,mpr+2 ; save change depth |
1840 clrf mpr+1 ; set high byte to zero for printing setpoint | 1833 clrf mpr+1 ; set high byte to zero for printing setpoint |
1841 bsf leftbind | 1834 bsf leftbind ; print left-aligned |
1842 output_16dp d'3' ; print setpoint x.xx | 1835 bsf decimal_digit2 ; place a decimal point in front of digit 2 |
1843 bcf leftbind | 1836 output_999 ; print setpoint (0.00-9.99) |
1844 STRCAT_TEXT tbar | 1837 STRCAT_TEXT tbar ; append unit |
1845 PUTC " " | 1838 PUTC " " ; append a space |
1846 movff mpr+2,mpr+0 ; restore change depth to lo | 1839 movff mpr+2,mpr+0 ; restore change depth to lo |
1847 | 1840 |
1848 TSTOSS opt_units ; 0=Meter, 1=Feet | 1841 TSTOSS opt_units ; 0=Meter, 1=Feet |
1849 bra log_show_sp_metric ; 0 - do metric | 1842 bra log_show_sp_metric ; 0 - do metric |
1850 ;bra log_show_sp_imperial ; 1 - do imperial | 1843 ;bra log_show_sp_imperial ; 1 - do imperial |
1851 | 1844 |
1852 log_show_sp_imperial: | 1845 log_show_sp_imperial: |
1853 call convert_meter_to_feet ; convert value in lo from [m] to [feet] | 1846 call convert_meter_to_feet ; convert value in lo from [m] to [feet] |
1854 output_16_3 | 1847 output_999 ; print depth (0-999) |
1855 PUTC " " | 1848 PUTC " " ; append space |
1856 STRCAT_TEXT tFeets ; "ft" | 1849 STRCAT_TEXT_PRINT tFeets ; append unit and dump to screen |
1857 bra log_show_sp_common | 1850 return ; done |
1858 | 1851 |
1859 log_show_sp_metric: | 1852 log_show_sp_metric: |
1860 output_8 | 1853 output_256 ; print depth (0-256) |
1861 PUTC " " | 1854 PUTC " " ; append space |
1862 STRCAT_TEXT tMeters ; "m" | 1855 STRCAT_TEXT_PRINT tMeters ; append unit and dump to screen |
1863 ;bra log_show_sp_common | 1856 return ; done |
1864 | 1857 |
1865 log_show_sp_common: | 1858 |
1866 STRCAT_PRINT "" | 1859 ;----------------------------------------------------------------------------- |
1867 return | 1860 ; Helper Function - show Gas Data |
1868 | 1861 ; |
1869 | |
1870 log_show_gas: ; show gas data | 1862 log_show_gas: ; show gas data |
1871 call TFT_color_code_gas ; color the output (gas number is in WREG) | 1863 call TFT_color_code_gas ; color the output (gas number is in WREG) |
1872 MOVCC POSTINC0,lo ; copy O2 fraction into lo | 1864 MOVCC POSTINC0,lo ; read O2 fraction into lo |
1873 MOVCC POSTINC0,hi ; copy He fraction into hi | 1865 MOVCC POSTINC0,hi ; read He fraction into hi |
1874 call gaslist_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into buffer | 1866 call gaslist_strcat_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into buffer |
1875 | 1867 |
1876 MOVCC POSTINC0,lo ; copy change depth into lo | 1868 MOVCC POSTINC0,lo ; read change depth into lo |
1877 MOVCC POSTINC0,hi ; copy gas type into hi | 1869 MOVCC POSTINC0,hi ; read gas type into hi |
1878 btfsc log_show_gas_short ; shall we do the short version? | 1870 |
1879 bra log_show_gas_common ; YES - do short version | 1871 btfss log_show_gas_short ; shall do the short version? |
1880 ;bra log_show_gas_long ; NO - add gas types | 1872 bra log_show_gas_long ; NO - add gas types |
1873 PRINT ; YES - dump to screen | |
1874 return ; done | |
1881 | 1875 |
1882 log_show_gas_long: | 1876 log_show_gas_long: |
1883 PUTC " " ; put one space between gas composition and gas type marking | 1877 PUTC " " ; put one space between gas composition and gas type marking |
1884 tstfsz hi ; gas disabled? | 1878 tstfsz hi ; gas disabled? |
1885 bra log_show_gas_1 ; NO - next check | 1879 bra log_show_gas_1 ; NO - next check |
1899 log_show_gas_3: | 1893 log_show_gas_3: |
1900 PUTC " " ; print a space in absence of any other marking | 1894 PUTC " " ; print a space in absence of any other marking |
1901 log_show_gas_4: | 1895 log_show_gas_4: |
1902 PUTC " " ; put one space between gas type marking and change depth | 1896 PUTC " " ; put one space between gas type marking and change depth |
1903 | 1897 |
1898 bsf leftbind ; print left-aligned | |
1904 TSTOSS opt_units ; 0=Meter, 1=Feet | 1899 TSTOSS opt_units ; 0=Meter, 1=Feet |
1905 bra log_show_gas_metric ; 0 - do metric | 1900 bra log_show_gas_metric ; 0 - do metric |
1906 ;bra log_show_gas_imperial ; 1 - do imperial | 1901 ;bra log_show_gas_imperial ; 1 - do imperial |
1907 | 1902 |
1908 log_show_gas_imperial: | 1903 log_show_gas_imperial: |
1909 call convert_meter_to_feet ; convert value in lo from [m] to [feet] | 1904 call convert_meter_to_feet ; convert value in lo from [m] to [feet] |
1910 output_16_3 ; limit to 999 and display only 0-999 | 1905 output_999 ; print depth (0-999) |
1911 STRCAT_TEXT tFeets ; "ft" | 1906 STRCAT_TEXT_PRINT tFeets ; append unit and dump to screen |
1912 bra log_show_gas_common | 1907 return ; done |
1913 | 1908 |
1914 log_show_gas_metric: | 1909 log_show_gas_metric: |
1915 output_8 | 1910 output_256 ; print depth (0-255) |
1916 STRCAT_TEXT tMeters ; "m" | 1911 STRCAT_TEXT_PRINT tMeters ; append unit and dump to screen |
1917 ;bra log_show_gas_common | 1912 return ; done |
1918 | 1913 |
1919 log_show_gas_common: | 1914 |
1920 STRCAT_PRINT "" | 1915 ;----------------------------------------------------------------------------- |
1921 return | 1916 ; Helper Function - compute Dive Number |
1922 | 1917 ; |
1923 | |
1924 log_compute_divenumber: | 1918 log_compute_divenumber: |
1925 movwf mpr+2 ; store current dive number in mpr+2 | 1919 movwf mpr+2 ; store current dive number in mpr+2 |
1926 call eeprom_log_offset_read ; read log offset into mpr+0 & +1 | 1920 call eeprom_log_offset_read ; read log offset into mpr+0 & +1 |
1927 ; check if offset = 0 | 1921 ; check if offset = 0 |
1928 tstfsz mpr+0 ; low byte = 0 ? | 1922 tstfsz mpr+0 ; low byte = 0 ? |
1949 clrf sub_b+1 ; - high byte is 0 | 1943 clrf sub_b+1 ; - high byte is 0 |
1950 call subU16 ; - sub_c = offset + 1 - (number from list) | 1944 call subU16 ; - sub_c = offset + 1 - (number from list) |
1951 MOVII sub_c,mpr ; - copy result back to mpr | 1945 MOVII sub_c,mpr ; - copy result back to mpr |
1952 return ; - done | 1946 return ; - done |
1953 | 1947 |
1954 ;---------------------------------------------------------------------------- | 1948 |
1955 ; Compute flash address for header data of a particular dive | 1949 ;----------------------------------------------------------------------------- |
1956 ; | 1950 ; Helper Function - compute Flash Address of Header by Dive Number |
1957 ; Memory map in flash: | 1951 ; |
1952 ; Memory Map in Flash: | |
1958 ; | 1953 ; |
1959 ; low(total number of dives) -> index -> start address end address | 1954 ; low(total number of dives) -> index -> start address end address |
1960 ; -------------------------------------------------------------------- | 1955 ; -------------------------------------------------------------------- |
1961 ; 1 0 0x2|00|000 - 0x2|00|FFF | 1956 ; 1 0 0x2|00|000 - 0x2|00|FFF |
1962 ; 2 1 0x2|01|000 - 0x2|01|FFF | 1957 ; 2 1 0x2|01|000 - 0x2|01|FFF |
1963 ; 3 2 0x2|02|000 - 0x2|02|FFF | 1958 ; 3 2 0x2|02|000 - 0x2|02|FFF |
1964 ; ... | 1959 ; ... |
1965 ; 256 -> 0 255 0x2|FF|000 - 0x2|FF|FFF | 1960 ; 256 -> 0 255 0x2|FF|000 - 0x2|FF|FFF |
1966 | 1961 ; |
1967 log_header_addr_by_divenumber: | 1962 log_header_addr_by_divenumber: |
1968 ; compute index of the dive with number 'divenumber' | 1963 ; compute dive index from of the dive number |
1969 decf divenumber,W ; compute number of dive to show -1... | 1964 decf divenumber,W ; compute number of dive to show -1... |
1970 movwf mpr+3 ; ... and store in mpr+3 | 1965 movwf mpr+3 ; ... and store in mpr+3 |
1971 movf total_num_dives,W ; get number of total dives (low byte) | 1966 movf total_num_dives,W ; get number of total dives (low byte) |
1972 bcf STATUS,C ; clear carry/borrow bit | 1967 bcf STATUS,C ; clear carry/borrow bit |
1973 subfwb mpr+3,W ; index = number of total dives - number of dive to show + 1 | 1968 subfwb mpr+3,W ; index = number of total dives - number of dive to show + 1 |
1974 ;bra log_header_addr_by_index ; get address by index | 1969 ;bra log_header_addr_by_index ; get address by index |
1975 | 1970 |
1971 | |
1972 ;----------------------------------------------------------------------------- | |
1973 ; Helper Function - compute Flash Address of Header by Dive Index | |
1974 ; | |
1976 global log_header_addr_by_index | 1975 global log_header_addr_by_index |
1977 log_header_addr_by_index: | 1976 log_header_addr_by_index: |
1978 ; compute the start address of the header belonging to the dive whose index is in WREG | 1977 ; compute the start address of the header belonging to the dive whose index is in WREG |
1979 movwf mpr+3 ; copy index to mpr+3 | 1978 movwf lo ; copy index to lo |
1980 clrf mpr+0 ; set up base address 0x200000 | 1979 movlw .16 ; prepare a shift left by 4 bit -> multiply with 16 |
1981 clrf mpr+1 ; ... | 1980 mulwf lo ; shift left the index to create the offset |
1982 movlw 0x20 ; ... | 1981 clrf ext_flash_address+0 ; clear low byte of the address |
1983 movwf mpr+2 ; ... | 1982 movf PRODL,W ; get low byte of the offset |
1984 movlw .16 ; prepare a shift left by 4 bit | 1983 movwf ext_flash_address+1 ; store as high byte of the address |
1985 mulwf mpr+3 ; shift left index to create offset | 1984 movf PRODH,W ; get high byte of the offset |
1986 movf PRODL,W ; get low byte of offset | 1985 addlw 0x20 ; add 0x20 |
1987 addwf mpr+1,F ; add to high byte of address | 1986 movwf ext_flash_address+2 ; store as upper byte of the address |
1988 movf PRODH,W ; get high byte of offset | 1987 return ; done |
1989 addwfc mpr+2,F ; add to upper byte of address | |
1990 | |
1991 return | |
1992 | 1988 |
1993 ; ---------------------------------------------------------------- | 1989 ; ---------------------------------------------------------------- |
1994 | 1990 |
1995 END | 1991 END |