Mercurial > public > hwos_code
comparison src/logbook.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
author | heinrichsweikamp |
---|---|
date | Thu, 22 Nov 2018 19:47:26 +0100 |
parents | 08a0162d3ca1 |
children | cd986267a5ca |
comparison
equal
deleted
inserted
replaced
603:00b24fb4324d | 604:ca4556fb60b9 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File logbook.asm REFACTORED VERSION V2.98 | 3 ; File logbook.asm REFACTORED VERSION V2.99e |
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 ;============================================================================= |
10 ; 2011-11-12 : [mH] moving from OSTC code | 10 ; 2011-11-12 : [mH] moving from OSTC code |
11 ; | 11 ; |
12 ;============================================================================= | 12 ;============================================================================= |
13 | 13 |
14 | 14 |
15 #include "hwos.inc" ; Mandatory header | 15 #include "hwos.inc" ; mandatory header |
16 #include "tft.inc" | 16 #include "tft.inc" |
17 #include "external_flash.inc" | 17 #include "external_flash.inc" |
18 #include "math.inc" | 18 #include "math.inc" |
19 #include "strings.inc" | 19 #include "strings.inc" |
20 #include "convert.inc" | 20 #include "convert.inc" |
97 #DEFINE log_marker_found logbook_flags,5 | 97 #DEFINE log_marker_found logbook_flags,5 |
98 #DEFINE log_show_gas_short logbook_flags,6 | 98 #DEFINE log_show_gas_short logbook_flags,6 |
99 ; logbook_flags,7 ; unused | 99 ; logbook_flags,7 ; unused |
100 | 100 |
101 ; Logbook Coordinates | 101 ; Logbook Coordinates |
102 #DEFINE logbook_list_left .10 ; Column of dive# in list | 102 #DEFINE logbook_list_left .10 ; column of dive# in list |
103 #DEFINE logbook_row_offset .28 ; Distance between rows of list | 103 #DEFINE logbook_row_offset .28 ; distance between rows of list |
104 #DEFINE logbook_row_number .6 ; Amount of rows in the list | 104 #DEFINE logbook_row_number .6 ; amount of rows in the list |
105 | 105 |
106 ; Profile display | 106 ; Profile display |
107 #DEFINE profile_height_pixels .157 ; Amount of pixels height for profile display | 107 #DEFINE profile_height_pixels .157 ; amount of pixels height for profile display |
108 #DEFINE profile_width_pixels .156 ; Amount of pixels width for profile display | 108 #DEFINE profile_width_pixels .156 ; amount of pixels width for profile display |
109 #DEFINE profile_left .1 ; Left border | 109 #DEFINE profile_left .1 ; left border |
110 #DEFINE profile_top .65 ; Top border | 110 #DEFINE profile_top .65 ; top border |
111 | 111 |
112 ; "Bailout" | 112 ; "Bailout" |
113 #DEFINE logbook_bailout_column .124 | 113 #DEFINE logbook_bailout_column .124 |
114 #DEFINE logbook_bailout_row .207 | 114 #DEFINE logbook_bailout_row .207 |
115 | 115 |
223 LOG_POINT_TO macro address | 223 LOG_POINT_TO macro address |
224 movlw address | 224 movlw address |
225 movwf ext_flash_address+0 | 225 movwf ext_flash_address+0 |
226 endm | 226 endm |
227 | 227 |
228 logbook code | 228 logbook CODE |
229 | 229 |
230 ;============================================================================= | 230 ;============================================================================= |
231 | 231 |
232 TFT_logbook_cursor: | 232 TFT_logbook_cursor: |
233 ; call speed_fastest | 233 ; call speed_fastest |
234 WIN_BOX_BLACK .0, .240-.16, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right | 234 WIN_BOX_BLACK .0, .240-.16, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right |
235 | 235 |
236 WIN_LEFT logbook_list_left-.8 | 236 WIN_LEFT logbook_list_left-.8 |
237 WIN_FONT FT_SMALL | 237 WIN_FONT FT_SMALL |
238 ; bcf win_invert ; Reset invert flag | 238 ; bcf win_invert ; reset invert flag |
239 call TFT_standard_color | 239 call TFT_standard_color |
240 | 240 |
241 movff menupos1,lo | 241 movff menupos1,lo |
242 dcfsnz lo,F | 242 dcfsnz lo,F |
243 movlw d'0' | 243 movlw d'0' |
264 | 264 |
265 global logbook ; entry point coming from menu_tree.asm | 265 global logbook ; entry point coming from menu_tree.asm |
266 logbook: | 266 logbook: |
267 clrf logbook_flags | 267 clrf logbook_flags |
268 clrf CCP1CON ; stop PWM | 268 clrf CCP1CON ; stop PWM |
269 bcf PORTC,2 ; Pull PWM out to GND | 269 bcf PORTC,2 ; pull PWM out to GND |
270 call TFT_boot | 270 call TFT_boot |
271 ; call TFT_standard_color | 271 ; call TFT_standard_color |
272 clrf menupos3 ; Here: used rows on current logbook-page | 272 clrf menupos3 ; here: used rows on current logbook-page |
273 clrf logbook_page_number ; Here: # of current displayed page | 273 clrf logbook_page_number ; here: # of current displayed page |
274 clrf logbook_divenumber ; # of dive in list during search | 274 clrf logbook_divenumber ; # of dive in list during search |
275 clrf logbook_temp | 275 clrf logbook_temp |
276 clrf logbook_temp_backup | 276 clrf logbook_temp_backup |
277 clrf timeout_counter2 ; For timeout | 277 clrf timeout_counter2 ; for timeout |
278 movlw logbook_row_number | 278 movlw logbook_row_number |
279 movwf menupos1 ; Here: stores current position on display (logbook_row_number-x) | 279 movwf menupos1 ; here: stores current position on display (logbook_row_number-x) |
280 read_int_eeprom .2 ; Get low-byte of total dives | 280 read_int_eeprom .2 ; get low-byte of total dives |
281 movff EEDATA,logbook_max_dive_counter | 281 movff EEDATA,logbook_max_dive_counter |
282 | 282 |
283 ;----------------------------------------------------------------------------- | 283 ;----------------------------------------------------------------------------- |
284 ; display dive headers backwards from read_int_eeprom .2 = lo-1 | 284 ; display dive headers backwards from read_int_eeprom .2 = lo-1 |
285 ; 1st: 200000h-200FFFh -> lo=0 | 285 ; 1st: 200000h-200FFFh -> lo=0 |
293 | 293 |
294 logbook2: | 294 logbook2: |
295 ; call speed_fastest | 295 ; call speed_fastest |
296 incf logbook_temp,F ; increase dive counter | 296 incf logbook_temp,F ; increase dive counter |
297 incf logbook_temp,W ; = 0x..FF ? | 297 incf logbook_temp,W ; = 0x..FF ? |
298 bz logbook_reset ; Yes: FF --> loop. | 298 bz logbook_reset ; YES - FF --> loop |
299 | 299 |
300 ; Set ext_flash_address:3 to TOC entry of this dive | 300 ; Set ext_flash_address:3 to TOC entry of this dive |
301 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0 | 301 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0 |
302 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1 | 302 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1 |
303 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2 | 303 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2 |
304 ; 256: 2FF000h-2FFFFFh -> logbook_max_dive_counter=255 (And hi>0...) | 304 ; 256: 2FF000h-2FFFFFh -> logbook_max_dive_counter=255 (and hi>0...) |
305 | 305 |
306 decf logbook_max_dive_counter,F ; -1 | 306 decf logbook_max_dive_counter,F ; -1 |
307 | 307 |
308 clrf ext_flash_address+0 | 308 clrf ext_flash_address+0 |
309 clrf ext_flash_address+1 | 309 clrf ext_flash_address+1 |
315 addwf ext_flash_address+1,F | 315 addwf ext_flash_address+1,F |
316 movf PRODH,W | 316 movf PRODH,W |
317 addwfc ext_flash_address+2,F | 317 addwfc ext_flash_address+2,F |
318 ; pointer at the first 0xFA of header | 318 ; pointer at the first 0xFA of header |
319 | 319 |
320 call ext_flash_byte_read ; Reads one byte@ext_flash_address:3 into WREG and ext_flash_rw | 320 call ext_flash_byte_read ; reads one byte@ext_flash_address:3 into WREG and ext_flash_rw |
321 movwf ext_flash_rw | 321 movwf ext_flash_rw |
322 movlw 0xFA | 322 movlw 0xFA |
323 cpfseq ext_flash_rw ; 0xFA found? | 323 cpfseq ext_flash_rw ; 0xFA found? |
324 bra logbook3b ; No, abort | 324 bra logbook3b ; NO - abort |
325 | 325 |
326 incf logbook_divenumber,F ; new header found, increase logbook_divenumber | 326 incf logbook_divenumber,F ; new header found, increase logbook_divenumber |
327 bra logbook4 ; Done with searching, display the header! | 327 bra logbook4 ; done with searching, display the header |
328 | 328 |
329 logbook3b: | 329 logbook3b: |
330 btfss logbook_page_not_empty ; Was there at least one dive? | 330 btfss logbook_page_not_empty ; was there at least one dive? |
331 bra exit_logbook ; Not a single header was found, leave logbook. | 331 bra exit_logbook ; not a single header was found, leave logbook |
332 bra logbook_display_loop2 | 332 bra logbook_display_loop2 |
333 | 333 |
334 logbook_reset: | 334 logbook_reset: |
335 tstfsz logbook_divenumber ; Was there at least one dive? | 335 tstfsz logbook_divenumber ; was there at least one dive? |
336 bra logbook_reset2 | 336 bra logbook_reset2 |
337 bra logbook3b ; No, Nothing to do | 337 bra logbook3b ; NO - nothing to do |
338 | 338 |
339 logbook_reset2: | 339 logbook_reset2: |
340 bsf all_dives_shown ; Yes | 340 bsf all_dives_shown ; YES |
341 bra logbook_display_loop2 ; Continue | 341 bra logbook_display_loop2 ; continue |
342 | 342 |
343 logbook4: | 343 logbook4: |
344 btfsc all_dives_shown ; All dives displayed? | 344 btfsc all_dives_shown ; all dives displayed? |
345 bra logbook_display_loop2 ; Yes, but display first page again. | 345 bra logbook_display_loop2 ; YES - display first page again |
346 | 346 |
347 call display_listdive ; display short header for list on current list position | 347 call display_listdive ; display short header for list on current list position |
348 | 348 |
349 movlw logbook_row_number | 349 movlw logbook_row_number |
350 cpfseq menupos1 ; first dive on list (top place)? | 350 cpfseq menupos1 ; first dive on list (top place)? |
351 bra logbook_display_loop1 ; no, so skip saving of address | 351 bra logbook_display_loop1 ; NO - skip saving of address |
352 | 352 |
353 ; store all registers required to rebuilt the current logbook page after the detail/profile view | 353 ; store all registers required to rebuilt the current logbook page after the detail/profile view |
354 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page | 354 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page |
355 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup Counter | 355 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup counter |
356 movff logbook_temp,logbook_temp_backup ; amount of dives drawn until now | 356 movff logbook_temp,logbook_temp_backup ; amount of dives drawn until now |
357 | 357 |
358 | 358 |
359 logbook_display_loop1: | 359 logbook_display_loop1: |
360 decfsz menupos1,F ; List full? | 360 decfsz menupos1,F ; list full? |
361 bra logbook2 ; no, search another dive for our current logbook page | 361 bra logbook2 ; NO - search another dive for our current logbook page |
362 | 362 |
363 logbook_display_loop2: | 363 logbook_display_loop2: |
364 btfss logbook_page_not_empty ; Was there one dive at all? | 364 btfss logbook_page_not_empty ; was there one dive at all? |
365 bra logbook ; Yes, so reload the first page | 365 bra logbook ; YES - so reload the first page |
366 | 366 |
367 ; TFT_mask... | 367 ; TFT_mask... |
368 | 368 |
369 WIN_LEFT logbook_list_left | 369 WIN_LEFT logbook_list_left |
370 WIN_TOP logbook_row_offset*logbook_row_number | 370 WIN_TOP logbook_row_offset*logbook_row_number |
371 STRCPY_TEXT_PRINT tNextLog ; "Next Page" | 371 STRCPY_TEXT_PRINT tNextLog ; "Next Page" |
372 WIN_LEFT logbook_list_left | 372 WIN_LEFT logbook_list_left |
373 WIN_TOP logbook_row_offset*(logbook_row_number+.1) | 373 WIN_TOP logbook_row_offset*(logbook_row_number+.1) |
374 STRCPY_TEXT_PRINT tExit ; "Exit" | 374 STRCPY_TEXT_PRINT tExit ; "Exit" |
375 | 375 |
376 movlw d'1' ; Set cursor to position 1... | 376 movlw d'1' ; set cursor to position 1... |
377 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view | 377 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view |
378 movf logbook_menupos_temp,W ; load last cursor position again | 378 movf logbook_menupos_temp,W ; load last cursor position again |
379 movwf menupos1 ; and set menupos1 byte | 379 movwf menupos1 ; and set menupos1 byte |
380 bcf return_from_profileview ; Do this only once while the page is loaded again! | 380 bcf return_from_profileview ; do this only once while the page is loaded again |
381 | 381 |
382 bcf logbook_page_not_empty ; Obviously the current page is NOT empty | 382 bcf logbook_page_not_empty ; obviously the current page is NOT empty |
383 | 383 |
384 movlw d'7' ; Set cursor to position 7... | 384 movlw d'7' ; set cursor to position 7... |
385 btfsc keep_cursor_new_page ; ... if we came from the "new Page" line | 385 btfsc keep_cursor_new_page ; ... if we came from the "new page" line |
386 movwf menupos1 ; and set menupos1 byte | 386 movwf menupos1 ; and set menupos1 byte |
387 bcf keep_cursor_new_page | 387 bcf keep_cursor_new_page |
388 | 388 |
389 call TFT_logbook_cursor ; Show the cursor | 389 call TFT_logbook_cursor ; show the cursor |
390 | 390 |
391 call logbook_preloop_tasks ; Clear some flags and set to Speed_eco | 391 call logbook_preloop_tasks ; clear some flags and set to Speed_eco |
392 call menu_processor_bottom_line ; Show bottom line | 392 call menu_processor_bottom_line ; show bottom line |
393 | 393 |
394 logbook_loop: | 394 logbook_loop: |
395 btfsc switch_left ; SET/MENU? | 395 btfsc switch_left ; SET/MENU? |
396 goto next_logbook3 ; adjust cursor or create new page | 396 goto next_logbook3 ; adjust cursor or create new page |
397 btfsc switch_right ; ENTER? | 397 btfsc switch_right ; ENTER? |
398 bra display_profile_or_exit ; view details/profile or exit logbook | 398 bra display_profile_or_exit ; view details/profile or exit logbook |
399 | 399 |
400 rcall log_screendump_and_onesecond ; Check if we need to make a screen-shot and check for new second | 400 rcall log_screendump_and_onesecond ; check if we need to make a screen-shot and check for new second |
401 btfsc sleepmode ; Timeout? | 401 btfsc sleepmode ; timeout? |
402 bra exit_logbook ; Yes | 402 bra exit_logbook ; YES |
403 bra logbook_loop ; Wait for something to do | 403 bra logbook_loop ; NO - wait for something to do |
404 | 404 |
405 display_profile_or_exit: | 405 display_profile_or_exit: |
406 movlw logbook_row_number+.2 ; exit? | 406 movlw logbook_row_number+.2 ; exit? |
407 cpfseq menupos1 | 407 cpfseq menupos1 |
408 bra display_profile_or_exit2 ; No, check for "Next Page" | 408 bra display_profile_or_exit2 ; NO - check for "Next Page" |
409 | 409 |
410 exit_logbook: | 410 exit_logbook: |
411 ; call TFT_DisplayOff | 411 ; call TFT_DisplayOff |
412 ; call TFT_boot | 412 ; call TFT_boot |
413 goto do_main_menu2 ; jump-back to menu_tree.asm | 413 goto do_main_menu2 ; jump-back to menu_tree.asm |
414 | 414 |
415 display_profile_or_exit2: | 415 display_profile_or_exit2: |
416 movlw logbook_row_number+.1 ; Next page? | 416 movlw logbook_row_number+.1 ; next page? |
417 cpfseq menupos1 | 417 cpfseq menupos1 |
418 bra display_profile ; No, show details/profile | 418 bra display_profile ; NO - show details/profile |
419 goto next_logbook2 ; Next page! | 419 goto next_logbook2 ; next page |
420 | 420 |
421 display_profile: | 421 display_profile: |
422 bcf is_bailout | 422 bcf FLAG_bailout_mode |
423 bcf gas6_changed ; Clear event flags | 423 bcf gas6_changed ; clear event flags |
424 ; call speed_fastest | 424 ; call speed_fastest |
425 movff menupos1,logbook_menupos_temp ; store current cursor position | 425 movff menupos1,logbook_menupos_temp ; store current cursor position |
426 bsf return_from_profileview ; tweak search routine to exit after found | 426 bsf return_from_profileview ; tweak search routine to exit after found |
427 | 427 |
428 movf logbook_page_number,W ; Number of page | 428 movf logbook_page_number,W ; number of page |
429 mullw logbook_row_number | 429 mullw logbook_row_number |
430 movf PRODL,W | 430 movf PRODL,W |
431 addwf menupos1,W ; page * logbook_row_number + menupos1 = | 431 addwf menupos1,W ; page * logbook_row_number + menupos1 = |
432 movwf divenumber ; # of dive to show | 432 movwf divenumber ; # of dive to show |
433 | 433 |
434 display_profile2: | 434 display_profile2: |
435 ; call speed_fastest | 435 ; call speed_fastest |
436 clrf CCP1CON ; stop PWM | 436 clrf CCP1CON ; stop PWM |
437 bcf PORTC,2 ; Pull PWM out to GND | 437 bcf PORTC,2 ; pull PWM out to GND |
438 call TFT_boot | 438 call TFT_boot |
439 ; call TFT_ClearScreen ; Clear screen | 439 ; call TFT_ClearScreen ; clear screen |
440 ; Set ext_flash pointer to "#divenumber-oldest" dive | 440 ; set ext_flash pointer to "#divenumber-oldest" dive |
441 ; compute read_int_eeprom .2 - divenumber | 441 ; compute read_int_eeprom .2 - divenumber |
442 ; Read required header data for profile display | 442 ; read required header data for profile display |
443 ; look in header for pointer to begin of dive profile (Byte 2-4) | 443 ; look in header for pointer to begin of dive profile (Byte 2-4) |
444 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing | 444 ; set pointer (ext_flash_log_pointer:3) to this address, start drawing |
445 | 445 |
446 decf divenumber,F ;-1 | 446 decf divenumber,F ;-1 |
447 read_int_eeprom .2 | 447 read_int_eeprom .2 |
448 movf EEDATA,W | 448 movf EEDATA,W |
449 bcf STATUS,C | 449 bcf STATUS,C |
467 addwfc ext_flash_address+2,F | 467 addwfc ext_flash_address+2,F |
468 ; pointer at the first 0xFA of header | 468 ; pointer at the first 0xFA of header |
469 | 469 |
470 ; Now, show profile | 470 ; Now, show profile |
471 LOG_POINT_TO log_samplingrate | 471 LOG_POINT_TO log_samplingrate |
472 call ext_flash_byte_read ; Read sampling rate | 472 call ext_flash_byte_read ; read sampling rate |
473 movff ext_flash_rw,samplesecs_value ; needed later... | 473 movff ext_flash_rw,samplesecs_value ; needed later... |
474 | 474 |
475 LOG_POINT_TO .2 | 475 LOG_POINT_TO .2 |
476 call ext_flash_byte_read_plus ; Read start address of profile | 476 call ext_flash_byte_read_plus ; read start address of profile |
477 movff ext_flash_rw,ext_flash_log_pointer+0 | 477 movff ext_flash_rw,ext_flash_log_pointer+0 |
478 call ext_flash_byte_read_plus ; Read start address of profile | 478 call ext_flash_byte_read_plus ; read start address of profile |
479 movff ext_flash_rw,ext_flash_log_pointer+1 | 479 movff ext_flash_rw,ext_flash_log_pointer+1 |
480 call ext_flash_byte_read_plus ; Read start address of profile | 480 call ext_flash_byte_read_plus ; read start address of profile |
481 movff ext_flash_rw,ext_flash_log_pointer+2 | 481 movff ext_flash_rw,ext_flash_log_pointer+2 |
482 | 482 |
483 clrf logbook_sample_counter+0 | 483 clrf logbook_sample_counter+0 |
484 clrf logbook_sample_counter+1 ; holds amount of read samples | 484 clrf logbook_sample_counter+1 ; holds amount of read samples |
485 | 485 |
486 call TFT_standard_color | 486 call TFT_standard_color |
487 call logbook_show_divenumber ; Show the dive number in medium font | 487 call logbook_show_divenumber ; show the dive number in medium font |
488 | 488 |
489 WIN_SMALL logbook_date_column, logbook_date_row | 489 WIN_SMALL logbook_date_column, logbook_date_row |
490 LOG_POINT_TO log_date | 490 LOG_POINT_TO log_date |
491 call ext_flash_byte_read_plus | 491 call ext_flash_byte_read_plus |
492 movff ext_flash_rw,up ; year | 492 movff ext_flash_rw,up ; year |
497 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | 497 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 |
498 STRCAT_PRINT "" | 498 STRCAT_PRINT "" |
499 | 499 |
500 WIN_SMALL log_divetime_value_column,logbook_date_row ; align with surrounding data | 500 WIN_SMALL log_divetime_value_column,logbook_date_row ; align with surrounding data |
501 LOG_POINT_TO log_divemode | 501 LOG_POINT_TO log_divemode |
502 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into ext_flash_rw | 502 call ext_flash_byte_read_plus ; read dive mode |
503 movff ext_flash_rw,lo | 503 movff ext_flash_rw,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR |
504 call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) | 504 call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, Gauge, Apnea or pSCR) |
505 | 505 |
506 WIN_SMALL logbook_time_column, logbook_time_row | 506 WIN_SMALL logbook_time_column, logbook_time_row |
507 LOG_POINT_TO log_time | 507 LOG_POINT_TO log_time |
508 call ext_flash_byte_read_plus ; hour | 508 call ext_flash_byte_read_plus ; hour |
509 movff ext_flash_rw,lo | 509 movff ext_flash_rw,lo |
511 movff ext_flash_rw,hi | 511 movff ext_flash_rw,hi |
512 output_99x ; hour | 512 output_99x ; hour |
513 PUTC ':' | 513 PUTC ':' |
514 movff hi,lo | 514 movff hi,lo |
515 output_99x ; minute | 515 output_99x ; minute |
516 STRCAT_PRINT "" ; Display 1st row of details | 516 STRCAT_PRINT "" ; display 1st row of details |
517 | 517 |
518 LOG_POINT_TO log_profile_version | 518 LOG_POINT_TO log_profile_version |
519 call ext_flash_byte_read_plus ; Profile version | 519 call ext_flash_byte_read_plus ; profile version |
520 movlw 0x24 | 520 movlw 0x24 |
521 cpfslt ext_flash_rw ; <0x24? | 521 cpfslt ext_flash_rw ; < 0x24 ? |
522 bra log_skip_extra_icon ; Yes, skip | 522 bra log_skip_extra_icon ; YES - skip |
523 | 523 |
524 WIN_SMALL logbook_time_column-.8, logbook_time_row | 524 WIN_SMALL logbook_time_column-.8, logbook_time_row |
525 STRCPY_PRINT 0x94 ; "End of dive" icon | 525 STRCPY_PRINT 0x94 ; "End of dive" icon |
526 | 526 |
527 log_skip_extra_icon: | 527 log_skip_extra_icon: |
533 movff lo,xA+0 ; calculate y-scale for profile display | 533 movff lo,xA+0 ; calculate y-scale for profile display |
534 movff hi,xA+1 | 534 movff hi,xA+1 |
535 movlw profile_height_pixels ; pixel height available for profile | 535 movlw profile_height_pixels ; pixel height available for profile |
536 movwf xB+0 | 536 movwf xB+0 |
537 clrf xB+1 | 537 clrf xB+1 |
538 call div16x16 ; does xA/xB=xC | 538 call div16x16 ; xC = xA / xB with xA as remainder |
539 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!) | 539 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!) |
540 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!) | 540 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!) |
541 infsnz y_scale+0,F ; increase one, because there may be a remainder | 541 infsnz y_scale+0,F ; increase one, because there may be a remainder |
542 incf y_scale+1,F | 542 incf y_scale+1,F |
543 | 543 |
547 movwf xC+1 | 547 movwf xC+1 |
548 movlw UPPER ((profile_height_pixels+1)*.1000) | 548 movlw UPPER ((profile_height_pixels+1)*.1000) |
549 movwf xC+2 | 549 movwf xC+2 |
550 clrf xC+3 | 550 clrf xC+3 |
551 | 551 |
552 movff lo,xB+0 ; Max. Depth in mbar | 552 movff lo,xB+0 ; max. Depth in mbar |
553 movff hi,xB+1 ; Max. Depth in mbar | 553 movff hi,xB+1 ; max. Depth in mbar |
554 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | 554 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
555 | 555 |
556 movff xC+0,x_scale+0 | 556 movff xC+0,x_scale+0 |
557 movff xC+1,x_scale+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line) | 557 movff xC+1,x_scale+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line) |
558 | 558 |
559 movf x_scale+0,W | 559 movf x_scale+0,W |
560 iorwf x_scale+1,W ; x_scale:2 = Null? | 560 iorwf x_scale+1,W ; x_scale:2 = Null ? |
561 bnz display_profile_offset4 ; No, continue | 561 bnz display_profile_offset4 ; NO - continue |
562 incf x_scale+1,F ; Yes, make x_scale+1>1 to make "display_profile2e" working | 562 incf x_scale+1,F ; YES - make x_scale+1>1 to make "display_profile2e" working |
563 | 563 |
564 display_profile_offset4: | 564 display_profile_offset4: |
565 WIN_SMALL log_max_value_column,log_max_value_row | 565 WIN_SMALL log_max_value_column,log_max_value_row |
566 | 566 |
567 TSTOSS opt_units ; 0=Meters, 1=Feets | 567 TSTOSS opt_units ; 0=Meters, 1=Feets |
578 bsf leftbind | 578 bsf leftbind |
579 output_16dp d'3' ; max. depth | 579 output_16dp d'3' ; max. depth |
580 STRCAT_TEXT_PRINT tMeters | 580 STRCAT_TEXT_PRINT tMeters |
581 | 581 |
582 display_profile_offset4_common: | 582 display_profile_offset4_common: |
583 call ext_flash_byte_read_plus ; divetime in minutes | 583 call ext_flash_byte_read_plus ; divetime in minutes |
584 movff ext_flash_rw,lo | 584 movff ext_flash_rw,lo |
585 call ext_flash_byte_read_plus | 585 call ext_flash_byte_read_plus |
586 movff ext_flash_rw,hi ; divetime in minutes | 586 movff ext_flash_rw,hi ; divetime in minutes |
587 | 587 |
588 movff lo,xA+0 ; calculate x-scale for profile display | 588 movff lo,xA+0 ; calculate x-scale for profile display |
589 movff hi,xA+1 ; calculate total diveseconds first | 589 movff hi,xA+1 ; calculate total diveseconds first |
590 movlw d'60' ; 60seconds are one minute... | 590 movlw d'60' ; 60 seconds are one minute |
591 movwf xB+0 | 591 movwf xB+0 |
592 clrf xB+1 | 592 clrf xB+1 |
593 call mult16x16 ; result is in xC:2 ! | 593 call mult16x16 ; result is in xC:2 ! |
594 | 594 |
595 WIN_SMALL log_divetime_value_column,log_divetime_value_row | 595 WIN_SMALL log_divetime_value_column,log_divetime_value_row |
597 output_16 ; divetime minutes | 597 output_16 ; divetime minutes |
598 movlw LOW d'600' | 598 movlw LOW d'600' |
599 movwf xA+0 | 599 movwf xA+0 |
600 movlw HIGH d'600' | 600 movlw HIGH d'600' |
601 movwf xA+1 ; a vertical line every 600 seconds | 601 movwf xA+1 ; a vertical line every 600 seconds |
602 movff samplesecs_value,xB+0 ; Copy sampling rate | 602 movff samplesecs_value,xB+0 ; copy sampling rate |
603 clrf xB+1 | 603 clrf xB+1 |
604 call div16x16 ; xA/xB=xC with xA as remainder | 604 call div16x16 ; xA/xB=xC with xA as remainder |
605 movff xC+0,vertical_interval+0 | 605 movff xC+0,vertical_interval+0 |
606 movff xC+1,vertical_interval+1 | 606 movff xC+1,vertical_interval+1 |
607 ; vertical_interval:2 holds interval of samples for vertical 10min line | 607 ; vertical_interval:2 holds interval of samples for vertical 10min line |
608 | 608 |
609 ; Restore divetime in minutes: | 609 ; Restore divetime in minutes: |
610 ; get real sample time | 610 ; get real sample time |
611 LOG_POINT_TO log_total_seconds | 611 LOG_POINT_TO log_total_seconds |
612 call ext_flash_byte_read_plus ; Total sample time in seconds | 612 call ext_flash_byte_read_plus ; total sample time in seconds |
613 movff ext_flash_rw,xC+0 | 613 movff ext_flash_rw,xC+0 |
614 call ext_flash_byte_read_plus ; Total sample time in seconds | 614 call ext_flash_byte_read_plus ; total sample time in seconds |
615 movff ext_flash_rw,xC+1 | 615 movff ext_flash_rw,xC+1 |
616 | 616 |
617 PUTC ':' | 617 PUTC ':' |
618 LOG_POINT_TO log_divetime+.2 | 618 LOG_POINT_TO log_divetime+.2 |
619 call ext_flash_byte_read_plus ; read divetime seconds | 619 call ext_flash_byte_read_plus ; read divetime seconds |
621 movff xC+0,xA+0 ; now calculate x-scale value | 621 movff xC+0,xA+0 ; now calculate x-scale value |
622 movff xC+1,xA+1 | 622 movff xC+1,xA+1 |
623 movlw profile_width_pixels ; pix width available | 623 movlw profile_width_pixels ; pix width available |
624 movwf xB+0 | 624 movwf xB+0 |
625 clrf xB+1 | 625 clrf xB+1 |
626 call div16x16 ; xA/xB=xC | 626 call div16x16 ; xC = xA / xB with xA as remainder |
627 movff xC+0,xA+0 | 627 movff xC+0,xA+0 |
628 movff xC+1,xA+1 | 628 movff xC+1,xA+1 |
629 movf samplesecs_value,W ; divide through sample interval! | 629 movf samplesecs_value,W ; divide through sample interval |
630 movwf xB+0 | 630 movwf xB+0 |
631 clrf xB+1 | 631 clrf xB+1 |
632 call div16x16 ; xA/xB=xC | 632 call div16x16 ; xC = xA / xB with xA as remainder |
633 movff xC+0,profile_temp1+0 ; store value (use any #xC sample, skip xC-1) into temp registers | 633 movff xC+0,profile_temp1+0 ; store value (use any #xC sample, skip xC-1) into temp registers |
634 movff xC+1,profile_temp1+1 ; store value (use any #xC sample, skip xC-1) into temp registers | 634 movff xC+1,profile_temp1+1 ; store value (use any #xC sample, skip xC-1) into temp registers |
635 infsnz profile_temp1+0,F ; Increase by one, there might be a remainder | 635 infsnz profile_temp1+0,F ; increase by one, there might be a remainder |
636 incf profile_temp1+1,F | 636 incf profile_temp1+1,F |
637 | 637 |
638 bsf leftbind | 638 bsf leftbind |
639 output_99x ; divetime seconds | 639 output_99x ; divetime seconds |
640 call TFT_standard_color | 640 call TFT_standard_color |
641 STRCAT_PRINT "" | 641 STRCAT_PRINT "" |
642 | 642 |
643 call ext_flash_byte_read_plus ; Read min. Temperature | 643 call ext_flash_byte_read_plus ; read min. temperature |
644 movff ext_flash_rw,logbook_min_tp+0 | 644 movff ext_flash_rw,logbook_min_tp+0 |
645 call ext_flash_byte_read_plus ; Read min. Temperature | 645 call ext_flash_byte_read_plus ; read min. temperature |
646 movff ext_flash_rw,logbook_min_tp+1 | 646 movff ext_flash_rw,logbook_min_tp+1 |
647 | 647 |
648 ; Set pointer to Gas 1 Type. | 648 ; Set pointer to Gas 1 Type. |
649 LOG_POINT_TO log_gas1+.3 | 649 LOG_POINT_TO log_gas1+.3 |
650 call ext_flash_byte_read_plus ; read Gas Type | 650 call ext_flash_byte_read_plus ; read gas type |
651 decfsz ext_flash_rw,W ; =1 (="First")? | 651 decfsz ext_flash_rw,W ; = 1 (= "First") ? |
652 bra logbook_find_first_gas2 ; No. | 652 bra logbook_find_first_gas2 ; NO |
653 movlw .1 | 653 movlw .1 |
654 movwf ext_flash_rw | 654 movwf ext_flash_rw |
655 bra logbook_find_first_gas_done | 655 bra logbook_find_first_gas_done |
656 logbook_find_first_gas2: | 656 logbook_find_first_gas2: |
657 ; Set pointer to Gas 2 Type. | 657 ; Set pointer to Gas 2 Type. |
658 LOG_POINT_TO log_gas2+.3 | 658 LOG_POINT_TO log_gas2+.3 |
659 call ext_flash_byte_read_plus ; read Gas Type | 659 call ext_flash_byte_read_plus ; read gas type |
660 decfsz ext_flash_rw,W ; =1 (="First")? | 660 decfsz ext_flash_rw,W ; = 1 (= "First") ? |
661 bra logbook_find_first_gas3 ; No. | 661 bra logbook_find_first_gas3 ; NO |
662 movlw .2 | 662 movlw .2 |
663 movwf ext_flash_rw | 663 movwf ext_flash_rw |
664 bra logbook_find_first_gas_done | 664 bra logbook_find_first_gas_done |
665 logbook_find_first_gas3: | 665 logbook_find_first_gas3: |
666 ; Set pointer to Gas 3 Type. | 666 ; Set pointer to Gas 3 Type. |
667 LOG_POINT_TO log_gas3+.3 | 667 LOG_POINT_TO log_gas3+.3 |
668 call ext_flash_byte_read_plus ; read Gas Type | 668 call ext_flash_byte_read_plus ; read gas type |
669 decfsz ext_flash_rw,W ; =1 (="First")? | 669 decfsz ext_flash_rw,W ; = 1 (= "First") ? |
670 bra logbook_find_first_gas4 ; No. | 670 bra logbook_find_first_gas4 ; NO |
671 movlw .3 | 671 movlw .3 |
672 movwf ext_flash_rw | 672 movwf ext_flash_rw |
673 bra logbook_find_first_gas_done | 673 bra logbook_find_first_gas_done |
674 logbook_find_first_gas4: | 674 logbook_find_first_gas4: |
675 ; Set pointer to Gas 4 Type. | 675 ; Set pointer to Gas 4 Type. |
676 LOG_POINT_TO log_gas4+.3 | 676 LOG_POINT_TO log_gas4+.3 |
677 call ext_flash_byte_read_plus ; read Gas Type | 677 call ext_flash_byte_read_plus ; read gas type |
678 decfsz ext_flash_rw,W ; =1 (="First")? | 678 decfsz ext_flash_rw,W ; = 1 (= "First") ? |
679 bra logbook_find_first_gas5 ; No. | 679 bra logbook_find_first_gas5 ; NO |
680 movlw .4 | 680 movlw .4 |
681 movwf ext_flash_rw | 681 movwf ext_flash_rw |
682 bra logbook_find_first_gas_done | 682 bra logbook_find_first_gas_done |
683 logbook_find_first_gas5: | 683 logbook_find_first_gas5: |
684 movlw .5 ; Must be Gas5 | 684 movlw .5 ; must be Gas 5 |
685 movwf ext_flash_rw | 685 movwf ext_flash_rw |
686 logbook_find_first_gas_done: | 686 logbook_find_first_gas_done: |
687 movff ext_flash_rw,backup_color1 ; keep copy to restore color | 687 movff ext_flash_rw,backup_color1 ; keep copy to restore color |
688 movff ext_flash_rw,WREG ; copy gas number to WREG for color coding | 688 movff ext_flash_rw,WREG ; copy gas number to WREG for color coding |
689 call TFT_color_code_gas ; Back to normal profile color. | 689 call TFT_color_code_gas ; back to normal profile color |
690 ; Pointer is now trashed! | 690 ; Pointer is now trashed! |
691 | 691 |
692 ; Point to profile portion of this dive | 692 ; Point to profile portion of this dive |
693 movff ext_flash_log_pointer+0,ext_flash_address+0 | 693 movff ext_flash_log_pointer+0,ext_flash_address+0 |
694 movff ext_flash_log_pointer+1,ext_flash_address+1 | 694 movff ext_flash_log_pointer+1,ext_flash_address+1 |
695 movff ext_flash_log_pointer+2,ext_flash_address+2 | 695 movff ext_flash_log_pointer+2,ext_flash_address+2 |
696 | 696 |
697 incf_ext_flash_address_0x20 d'2' ; Skip 0xFA 0xFA | 697 incf_ext_flash_address_0x20 d'2' ; skip 0xFA 0xFA |
698 call ext_flash_byte_read_plus_0x20 ; Read low byte of total dives into ext_flash_rw (at the time the dive was made) | 698 call ext_flash_byte_read_plus_0x20 ; read low byte of total dives into ext_flash_rw (at the time the dive was made) |
699 | 699 |
700 ; Load total number of dives (low byte only) | 700 ; Load total number of dives (low byte only) |
701 read_int_eeprom .2 | 701 read_int_eeprom .2 |
702 incf EEDATA,W ; +1 | 702 incf EEDATA,W ; +1 |
703 bsf STATUS,C ; Set borrow | 703 bsf STATUS,C ; set borrow |
704 subfwb divenumber,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made) | 704 subfwb divenumber,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made) |
705 cpfseq ext_flash_rw ; # of dive in logbook (Must be equal with low byte in short header) | 705 cpfseq ext_flash_rw ; # of dive in logbook (Must be equal with low byte in short header) |
706 bra display_profile_no_profile ; Not equal, no profile for this dive available! | 706 bra display_profile_no_profile ; not equal, no profile for this dive available |
707 | 707 |
708 ; Skip rest of short header: 3 Bytes | 708 ; Skip rest of short header: 3 Bytes |
709 ; Skip length of profile data: 3 Bytes | 709 ; Skip length of profile data: 3 Bytes |
710 ; Skip sampling rate in profile section: 1Byte | 710 ; Skip sampling rate in profile section: 1Byte |
711 ; Skip number of divisors: 1Byte | 711 ; Skip number of divisors: 1Byte |
712 incf_ext_flash_address_0x20 d'8' | 712 incf_ext_flash_address_0x20 d'8' |
713 | 713 |
714 ; Divisor temp | 714 ; divisor temp |
715 incf_ext_flash_address_0x20 d'2' | 715 incf_ext_flash_address_0x20 d'2' |
716 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 716 ; call ext_flash_byte_read_plus_0x20 ; read information type |
717 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 717 ; call ext_flash_byte_read_plus_0x20 ; read information length |
718 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 718 call ext_flash_byte_read_plus_0x20 ; read information divisor |
719 movf ext_flash_rw,W | 719 movf ext_flash_rw,W |
720 movwf divisor_temperature ; Store divisor | 720 movwf divisor_temperature ; store divisor |
721 movwf count_temperature ; Store to tp° counter too. | 721 movwf count_temperature ; store to tp° counter, too |
722 ; Divisor Deco | 722 ; divisor deco |
723 incf_ext_flash_address_0x20 d'2' | 723 incf_ext_flash_address_0x20 d'2' |
724 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 724 ; call ext_flash_byte_read_plus_0x20 ; read information type |
725 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 725 ; call ext_flash_byte_read_plus_0x20 ; read information length |
726 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 726 call ext_flash_byte_read_plus_0x20 ; read information divisor |
727 movf ext_flash_rw,W | 727 movf ext_flash_rw,W |
728 movwf divisor_deco ; Store divisor | 728 movwf divisor_deco ; store divisor |
729 movwf count_deco ; Store as temp, too | 729 movwf count_deco ; store as temp, too |
730 ; Divisor GF | 730 ; divisor GF |
731 incf_ext_flash_address_0x20 d'2' | 731 incf_ext_flash_address_0x20 d'2' |
732 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 732 ; call ext_flash_byte_read_plus_0x20 ; read information type |
733 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 733 ; call ext_flash_byte_read_plus_0x20 ; read information length |
734 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 734 call ext_flash_byte_read_plus_0x20 ; read information divisor |
735 movff ext_flash_rw,divisor_gf ; Store divisor | 735 movff ext_flash_rw,divisor_gf ; store divisor |
736 ; Divisor ppO2 Sensors | 736 ; divisor ppO2 sensors |
737 incf_ext_flash_address_0x20 d'2' | 737 incf_ext_flash_address_0x20 d'2' |
738 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 738 ; call ext_flash_byte_read_plus_0x20 ; read information type |
739 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 739 ; call ext_flash_byte_read_plus_0x20 ; read information length |
740 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 740 call ext_flash_byte_read_plus_0x20 ; read information divisor |
741 movff ext_flash_rw,divisor_ppo2_sensors ; Store divisor | 741 movff ext_flash_rw,divisor_ppo2_sensors ; store divisor |
742 ; Divisor decoplan | 742 ; divisor decoplan |
743 incf_ext_flash_address_0x20 d'2' | 743 incf_ext_flash_address_0x20 d'2' |
744 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 744 ; call ext_flash_byte_read_plus_0x20 ; read information type |
745 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 745 ; call ext_flash_byte_read_plus_0x20 ; read information length |
746 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 746 call ext_flash_byte_read_plus_0x20 ; read information divisor |
747 movff ext_flash_rw,divisor_decoplan ; Store divisor | 747 movff ext_flash_rw,divisor_decoplan ; store divisor |
748 ; Divisor CNS | 748 ; divisor CNS |
749 incf_ext_flash_address_0x20 d'2' | 749 incf_ext_flash_address_0x20 d'2' |
750 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 750 ; call ext_flash_byte_read_plus_0x20 ; read information type |
751 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 751 ; call ext_flash_byte_read_plus_0x20 ; read information length |
752 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 752 call ext_flash_byte_read_plus_0x20 ; read information divisor |
753 movff ext_flash_rw,divisor_cns ; Store divisor | 753 movff ext_flash_rw,divisor_cns ; store divisor |
754 ; Divisor Tank data | 754 ; divisor tank data |
755 incf_ext_flash_address_0x20 d'2' | 755 incf_ext_flash_address_0x20 d'2' |
756 ; call ext_flash_byte_read_plus_0x20 ; Read information type | 756 ; call ext_flash_byte_read_plus_0x20 ; read information type |
757 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | 757 ; call ext_flash_byte_read_plus_0x20 ; read information length |
758 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | 758 call ext_flash_byte_read_plus_0x20 ; read information divisor |
759 movff ext_flash_rw,divisor_tank ; Store divisor | 759 movff ext_flash_rw,divisor_tank ; store divisor |
760 | 760 |
761 ; Start Profile display | 761 ; Start profile display |
762 movlw color_deepblue | 762 movlw color_deepblue |
763 call TFT_set_color ; Make this configurable? | 763 call TFT_set_color |
764 ; Draw a frame around profile area | 764 ; Draw a frame around profile area |
765 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 | 765 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 |
766 | 766 |
767 movlw profile_top | 767 movlw profile_top |
768 movwf win_top | 768 movwf win_top |
769 movlw profile_left | 769 movlw profile_left |
770 movwf win_leftx2 ; Left border (0-159) | 770 movwf win_leftx2 ; left border (0-159) |
771 movlw d'1' | 771 movlw d'1' |
772 movwf win_height | 772 movwf win_height |
773 movlw profile_width_pixels+.1 | 773 movlw profile_width_pixels+.1 |
774 movwf win_width+0 ; Right border (0-159) | 774 movwf win_width+0 ; right border (0-159) |
775 clrf win_width+1 | 775 clrf win_width+1 |
776 bra display_profile2f ; No 0m line | 776 bra display_profile2f ; no 0m line |
777 display_profile2e: | 777 display_profile2e: |
778 call TFT_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | 778 call TFT_box ; inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
779 display_profile2f: | 779 display_profile2f: |
780 movf win_top,W ; Get row | 780 movf win_top,W ; get row |
781 addwf x_scale+0,W ; Add line interval distance to win_top | 781 addwf x_scale+0,W ; add line interval distance to win_top |
782 tstfsz x_scale+1 ; >255? | 782 tstfsz x_scale+1 ; > 255 ? |
783 movlw d'255' ; Yes, make win_top>239 -> Abort here | 783 movlw d'255' ; YES - make win_top>239 -> abort here |
784 btfsc STATUS,C ; A Cary from the addwf above? | 784 btfsc STATUS,C ; a carry from the addwf above? |
785 movlw d'255' ; Yes, make win_top>239 -> Abort here | 785 movlw d'255' ; YES - make win_top>239 -> abort here |
786 movwf win_top ; Result in win_top again | 786 movwf win_top ; result in win_top again |
787 movlw profile_top+profile_height_pixels+.1 ; Limit | 787 movlw profile_top+profile_height_pixels+.1 ; limit |
788 cpfsgt win_top ; >239? | 788 cpfsgt win_top ; > 239 ? |
789 bra display_profile2e ; No, draw another line | 789 bra display_profile2e ; NO - draw another line |
790 | 790 |
791 clrf gaslist_gas ; here: used as counter for depth readings | 791 clrf gaslist_gas ; here: used as counter for depth readings |
792 movlw profile_width_pixels+profile_left-.1 | 792 movlw profile_width_pixels+profile_left-.1 |
793 movwf ignore_digits ; here: used as counter for x-pixels | 793 movwf ignore_digits ; here: used as counter for x-pixels |
794 bcf end_of_profile ; clear flag | 794 bcf end_of_profile ; clear flag |
795 | 795 |
796 movlw profile_left+.1 | 796 movlw profile_left+.1 |
797 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5) | 797 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5) |
798 | 798 |
799 movlw profile_top+.1 ; Zero-m row | 799 movlw profile_top+.1 ; zero-m row |
800 movwf fill_between_rows | 800 movwf fill_between_rows |
801 movwf logbook_last_tp ; Initialize for Tp° curve too. | 801 movwf logbook_last_tp ; initialize for Tp° curve, too |
802 | 802 |
803 movlw LOW(-.100) ; Initialize max tp° to -10.0 °C. | 803 movlw LOW(-.100) ; initialize max tp° to -10.0 °C |
804 movwf logbook_max_tp+0 | 804 movwf logbook_max_tp+0 |
805 movlw HIGH 0xFFFF & (-.100) | 805 movlw HIGH 0xFFFF & (-.100) |
806 movwf logbook_max_tp+1 | 806 movwf logbook_max_tp+1 |
807 | 807 |
808 setf logbook_cur_tp+0 ; Initialize Tp°, before the first recorded point. | 808 setf logbook_cur_tp+0 ; initialize Tp°, before the first recorded point |
809 setf logbook_cur_tp+1 | 809 setf logbook_cur_tp+1 |
810 clrf logbook_last_tp ; Also reset previous Y for Tp° | 810 clrf logbook_last_tp ; also reset previous Y for Tp° |
811 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling. | 811 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling |
812 movlw profile_top+.1 | 812 movlw profile_top+.1 |
813 movwf logbook_min_temp_pos ; Initialize for displaying the lowest temperature | 813 movwf logbook_min_temp_pos ; initialize for displaying the lowest temperature |
814 movlw profile_top+profile_height_pixels | 814 movlw profile_top+profile_height_pixels |
815 movwf logbook_max_temp_pos ; Initialize for displaying the highest temperature | 815 movwf logbook_max_temp_pos ; initialize for displaying the highest temperature |
816 | 816 |
817 movlw profile_left | 817 movlw profile_left |
818 movwf win_leftx2 | 818 movwf win_leftx2 |
819 movlw profile_top | 819 movlw profile_top |
820 movwf win_top | 820 movwf win_top |
833 movf logbook_pixel_x_pos,W | 833 movf logbook_pixel_x_pos,W |
834 mullw 2 | 834 mullw 2 |
835 call pixel_write_col320 | 835 call pixel_write_col320 |
836 | 836 |
837 movff profile_temp1+0,profile_temp2+0 | 837 movff profile_temp1+0,profile_temp2+0 |
838 movff profile_temp1+1,profile_temp2+1 ; 16Bit x-scaler | 838 movff profile_temp1+1,profile_temp2+1 ; 16bit x-scaler |
839 incf profile_temp2+1,F | 839 incf profile_temp2+1,F |
840 tstfsz profile_temp2+0 ; Must not be Zero | 840 tstfsz profile_temp2+0 ; must not be zero |
841 bra profile_display_loop2 ; Not Zero! | 841 bra profile_display_loop2 ; not Zero |
842 incf profile_temp2+0,F ; Zero, Increase! | 842 incf profile_temp2+0,F ; zero, increase |
843 | 843 |
844 profile_display_loop2: | 844 profile_display_loop2: |
845 rcall profile_view_get_depth ; reads depth, temp and profile data | 845 rcall profile_view_get_depth ; reads depth, temp and profile data |
846 | 846 |
847 btfsc end_of_profile ; end-of profile reached? | 847 btfsc end_of_profile ; end-of profile reached? |
848 bra profile_display_loop_done ; Yes, skip all remaining pixels | 848 bra profile_display_loop_done ; YES - skip all remaining pixels |
849 | 849 |
850 | 850 |
851 ;---- Draw Ceiling curve, if any --------------------------------------------- | 851 ;---- Draw Ceiling curve, if any --------------------------------------------- |
852 movf divisor_deco,W | 852 movf divisor_deco,W |
853 bz profile_display_skip_deco | 853 bz profile_display_skip_deco |
854 | 854 |
855 movf logbook_ceiling,W ; Any deco ceiling ? | 855 movf logbook_ceiling,W ; any deco ceiling? |
856 bz profile_display_skip_deco | 856 bz profile_display_skip_deco |
857 | 857 |
858 mullw .100 ; Yes: convert to mbar | 858 mullw .100 ; YES - convert to mbar |
859 movff PRODL,sub_a+0 | 859 movff PRODL,sub_a+0 |
860 movff PRODH,sub_a+1 | 860 movff PRODH,sub_a+1 |
861 movff logbook_cur_depth+0,sub_b+0 ; Compare with UNSIGNED current depth (16bits) | 861 movff logbook_cur_depth+0,sub_b+0 ; compare with UNSIGNED current depth (16bits) |
862 movff logbook_cur_depth+1,sub_b+1 | 862 movff logbook_cur_depth+1,sub_b+1 |
863 call subU16 ; set (or not) neg_flag | 863 call subU16 ; set (or not) neg_flag |
864 | 864 |
865 movlw color_dark_green ; Dark green if Ok, | 865 movlw color_dark_green ; dark green if ok |
866 btfss neg_flag | 866 btfss neg_flag |
867 movlw color_dark_red ; Or dark red if ceiling overflown. | 867 movlw color_dark_red ; dark red if ceiling is violated |
868 call TFT_set_color | 868 call TFT_set_color |
869 | 869 |
870 movff PRODL,xA+0 | 870 movff PRODL,xA+0 |
871 movff PRODH,xA+1 | 871 movff PRODH,xA+1 |
872 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset | 872 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset |
873 movff y_scale+1,xB+1 | 873 movff y_scale+1,xB+1 |
874 call div16x16 ; xA/xB=xC | 874 call div16x16 ; xC = xA / xB with xA as remainder |
875 | 875 |
876 movlw profile_top+.1 ; Starts right after the top line. | 876 movlw profile_top+.1 ; starts right after the top line |
877 movwf win_top | 877 movwf win_top |
878 movff logbook_pixel_x_pos,win_leftx2 ; Left border (0-159) | 878 movff logbook_pixel_x_pos,win_leftx2 ; left border (0-159) |
879 movff xC+0,win_height | 879 movff xC+0,win_height |
880 call half_vertical_line ; Inputs: win_top, win_leftx2, win_height, win_color1, win_color2 | 880 call half_vertical_line ; inputs: win_top, win_leftx2, win_height, win_color1, win_color2 |
881 | 881 |
882 profile_display_skip_deco: | 882 profile_display_skip_deco: |
883 ;---- Draw Tp° curve, if any --------------------------------------------- | 883 ;---- Draw Tp° curve, if any --------------------------------------------- |
884 movf divisor_temperature,W | 884 movf divisor_temperature,W |
885 bz profile_display_skip_temp | 885 bz profile_display_skip_temp |
886 | 886 |
887 movf logbook_cur_tp+0,W ; Did we had already a valid Tp°C record ? | 887 movf logbook_cur_tp+0,W ; did we had already a valid Tp°C record? |
888 andwf logbook_cur_tp+1,W | 888 andwf logbook_cur_tp+1,W |
889 incf WREG | 889 incf WREG |
890 bz profile_display_skip_temp ; No: just skip drawing. | 890 bz profile_display_skip_temp ; NO - just skip drawing. |
891 | 891 |
892 movlw LOW (((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix | 892 movlw LOW (((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix |
893 movwf xB+0 | 893 movwf xB+0 |
894 movlw HIGH (((profile_height_pixels-.10)*.256)/.370) | 894 movlw HIGH (((profile_height_pixels-.10)*.256)/.370) |
895 movwf xB+1 | 895 movwf xB+1 |
896 | 896 |
897 movf logbook_cur_tp+0,W ; Current Tp° - (-2.0°C) == Tp° + 20. | 897 movf logbook_cur_tp+0,W ; current Tp° - (-2.0°C) == Tp° + 20 |
898 addlw LOW(.20) ; Low byte. | 898 addlw LOW(.20) ; low byte |
899 movwf xA+0 | 899 movwf xA+0 |
900 movf logbook_cur_tp+1,W | 900 movf logbook_cur_tp+1,W |
901 btfsc STATUS,C ; Propagate carry, if any | 901 btfsc STATUS,C ; propagate carry, if any |
902 incf WREG | 902 incf WREG |
903 movwf xA+1 | 903 movwf xA+1 |
904 call mult16x16 ; xA*xB=xC | 904 call mult16x16 ; xA*xB=xC |
905 | 905 |
906 ; scale: divide by 256, ie. take just high byte. | 906 ; scale: divide by 256, ie. take just high byte. |
907 movf xC+1,W | 907 movf xC+1,W |
908 sublw profile_top+profile_height_pixels-.10 ; Upside-down: Y = .75 + (.153 - result) | 908 sublw profile_top+profile_height_pixels-.10 ; upside-down: Y = .75 + (.153 - result) |
909 movwf xC+0 | 909 movwf xC+0 |
910 | 910 |
911 ; Check limits | 911 ; Check limits |
912 movlw profile_top+.1 | 912 movlw profile_top+.1 |
913 movwf xC+1 | 913 movwf xC+1 |
915 movff xC+1,xC+0 | 915 movff xC+1,xC+0 |
916 | 916 |
917 movlw color_orange | 917 movlw color_orange |
918 call TFT_set_color | 918 call TFT_set_color |
919 | 919 |
920 movf logbook_last_tp,W ; do we have a valid previous value ? | 920 movf logbook_last_tp,W ; do we have a valid previous value? |
921 bz profile_display_temp_1 ; No: skip the vertical line. | 921 bz profile_display_temp_1 ; NO - skip the vertical line. |
922 movwf xC+1 | 922 movwf xC+1 |
923 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | 923 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) |
924 profile_display_temp_1: | 924 profile_display_temp_1: |
925 movf xC+0,W ; current row | 925 movf xC+0,W ; current row |
926 cpfsgt logbook_min_temp_pos ; check limit | 926 cpfsgt logbook_min_temp_pos ; check limit |
927 movwf logbook_min_temp_pos ; lowest row in the temp graph | 927 movwf logbook_min_temp_pos ; lowest row in the temp graph |
928 cpfslt logbook_max_temp_pos ; check limit | 928 cpfslt logbook_max_temp_pos ; check limit |
929 movwf logbook_max_temp_pos ; highest row in the temp graph | 929 movwf logbook_max_temp_pos ; highest row in the temp graph |
930 | 930 |
931 movff xC+0,logbook_last_tp | 931 movff xC+0,logbook_last_tp |
932 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a current color pixel. | 932 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col(0..159) x row (0..239), put a current color pixel |
933 | 933 |
934 profile_display_skip_temp: | 934 profile_display_skip_temp: |
935 ;---- Draw depth curve --------------------------------------------------- | 935 ;---- Draw depth curve --------------------------------------------------- |
936 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset | 936 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset |
937 movff y_scale+1,xB+1 | 937 movff y_scale+1,xB+1 |
938 movff logbook_cur_depth+0,xA+0 | 938 movff logbook_cur_depth+0,xA+0 |
939 movff logbook_cur_depth+1,xA+1 | 939 movff logbook_cur_depth+1,xA+1 |
940 call div16x16 ; xA/xB=xC | 940 call div16x16 ; xC = xA / xB with xA as remainder |
941 movlw profile_top+.1 | 941 movlw profile_top+.1 |
942 addwf xC+0,F ; add 75 pixel offset to result | 942 addwf xC+0,F ; add 75 pixel offset to result |
943 | 943 |
944 btfsc STATUS,C ; Ignore potential profile errors | 944 btfsc STATUS,C ; ignore potential profile errors |
945 movff fill_between_rows,xC+0 | 945 movff fill_between_rows,xC+0 |
946 | 946 |
947 movff backup_color1,WREG ; copy gas number to WREG for color-coding | 947 movff backup_color1,WREG ; copy gas number to WREG for color-coding |
948 call TFT_color_code_gas ; Back to normal profile color. | 948 call TFT_color_code_gas ; back to normal profile color. |
949 | 949 |
950 movff fill_between_rows,xC+1 | 950 movff fill_between_rows,xC+1 |
951 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | 951 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) |
952 movff xC+0,fill_between_rows ; Store last row for fill routine | 952 movff xC+0,fill_between_rows ; store last row for fill routine |
953 | 953 |
954 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel. | 954 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col(0..159) x row (0..239), put a std color pixel |
955 incf logbook_pixel_x_pos,F ; Next column | 955 incf logbook_pixel_x_pos,F ; next column |
956 | 956 |
957 ;---- Draw Marker square , if any ---------------------------------------- | 957 ;---- Draw Marker square , if any ---------------------------------------- |
958 btfss log_marker_found ; Any marker to draw? | 958 btfss log_marker_found ; any marker to draw? |
959 bra profile_display_skip_marker ; No | 959 bra profile_display_skip_marker ; NO |
960 | 960 |
961 ; tiny "m" | 961 ; tiny "m" |
962 incf fill_between_rows,W ; increase row (Y) | 962 incf fill_between_rows,W ; increase row (Y) |
963 movwf win_top | 963 movwf win_top |
964 ; limit win_top to 220 | 964 ; limit win_top to 220 |
975 movlw color_orange | 975 movlw color_orange |
976 call TFT_set_color | 976 call TFT_set_color |
977 WIN_FONT FT_TINY | 977 WIN_FONT FT_TINY |
978 lfsr FSR2,buffer | 978 lfsr FSR2,buffer |
979 STRCPY_PRINT "m" | 979 STRCPY_PRINT "m" |
980 bcf log_marker_found ; Clear flag | 980 bcf log_marker_found ; clear flag |
981 | 981 |
982 movlw profile_left | 982 movlw profile_left |
983 movwf win_leftx2 | 983 movwf win_leftx2 |
984 movlw profile_top | 984 movlw profile_top |
985 movwf win_top | 985 movwf win_top |
994 profile_display_skip_marker: | 994 profile_display_skip_marker: |
995 ;---- Draw CNS curve, if any --------------------------------------------- | 995 ;---- Draw CNS curve, if any --------------------------------------------- |
996 movf divisor_cns,W | 996 movf divisor_cns,W |
997 bz profile_display_skip_cns | 997 bz profile_display_skip_cns |
998 ; | 998 ; |
999 ; TODO HERE | 999 ; add further code here... |
1000 ; | 1000 ; |
1001 profile_display_skip_cns: | 1001 profile_display_skip_cns: |
1002 | 1002 |
1003 ;---- Draw GF curve, if any ---------------------------------------------- | 1003 ;---- Draw GF curve, if any ---------------------------------------------- |
1004 movf divisor_gf,W | 1004 movf divisor_gf,W |
1005 bz profile_display_skip_gf | 1005 bz profile_display_skip_gf |
1006 ; | 1006 ; |
1007 ; TODO HERE | 1007 ; add further code here... |
1008 ; | 1008 ; |
1009 profile_display_skip_gf: | 1009 profile_display_skip_gf: |
1010 | 1010 |
1011 ;---- All curves done. | 1011 ;---- All curves done |
1012 | 1012 |
1013 profile_display_skip_loop1: ; skips readings! | 1013 profile_display_skip_loop1: ; skips readings |
1014 dcfsnz profile_temp2+0,F | 1014 dcfsnz profile_temp2+0,F |
1015 bra profile_display_loop3 ; check 16bit.... | 1015 bra profile_display_loop3 ; check 16bit |
1016 | 1016 |
1017 rcall profile_view_get_depth ; reads depth, temp and profile data | 1017 rcall profile_view_get_depth ; reads depth, temp and profile data |
1018 | 1018 |
1019 btfsc end_of_profile ; end-of profile reached? | 1019 btfsc end_of_profile ; end-of profile reached? |
1020 bra profile_display_loop_done ; Yes, skip all remaining pixels | 1020 bra profile_display_loop_done ; YES - skip all remaining pixels |
1021 | 1021 |
1022 bra profile_display_skip_loop1 | 1022 bra profile_display_skip_loop1 |
1023 | 1023 |
1024 profile_display_loop3: | 1024 profile_display_loop3: |
1025 decfsz profile_temp2+1,F ; 16 bit x-scaler test | 1025 decfsz profile_temp2+1,F ; 16 bit x-scaler test |
1026 bra profile_display_skip_loop1 ; skips readings! | 1026 bra profile_display_skip_loop1 ; skips readings |
1027 | 1027 |
1028 decfsz ignore_digits,F ; counts drawn x-pixels to zero | 1028 decfsz ignore_digits,F ; counts drawn x-pixels to zero |
1029 bra profile_display_loop ; Not ready yet | 1029 bra profile_display_loop ; not ready yet |
1030 ; Done. | 1030 ; done |
1031 | 1031 |
1032 display_profile_no_profile: ; No profile available for this dive! | 1032 display_profile_no_profile: ; no profile available for this dive |
1033 | 1033 |
1034 profile_display_loop_done: | 1034 profile_display_loop_done: |
1035 btfss is_bailout ; Bailout during the dive? | 1035 btfss FLAG_bailout_mode ; bailout during the dive? |
1036 bra profile_display_loop_done_nobail ; No | 1036 bra profile_display_loop_done_nobail ; NO |
1037 ; Yes, show "Bailout" | 1037 ; YES - show "Bailout" |
1038 movlw color_pink | 1038 movlw color_pink |
1039 call TFT_set_color | 1039 call TFT_set_color |
1040 WIN_TINY logbook_bailout_column,logbook_bailout_row | 1040 WIN_TINY logbook_bailout_column,logbook_bailout_row |
1041 STRCPY_TEXT_PRINT tDiveBailout ; Bailout | 1041 STRCPY_TEXT_PRINT tDiveBailout ; bailout |
1042 profile_display_loop_done_nobail: | 1042 profile_display_loop_done_nobail: |
1043 btfss gas6_changed ; Gas6 | 1043 btfss gas6_changed ; Gas6 |
1044 bra profile_display_loop_done_nogas6 ; No | 1044 bra profile_display_loop_done_nogas6 ; NO |
1045 ; Yes, show "Gas 6!" | 1045 ; Yes, show "Gas 6!" |
1046 movlw color_pink | 1046 movlw color_pink |
1047 call TFT_set_color | 1047 call TFT_set_color |
1048 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 | 1048 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 |
1049 STRCPY_TEXT tGas ; Gas | 1049 STRCPY_TEXT tGas ; gas |
1050 STRCAT_PRINT " 6!" | 1050 STRCAT_PRINT " 6!" |
1051 | 1051 |
1052 profile_display_loop_done_nogas6: | 1052 profile_display_loop_done_nogas6: |
1053 decf divenumber,F ;-1 | 1053 decf divenumber,F ; -1 |
1054 read_int_eeprom .2 | 1054 read_int_eeprom .2 |
1055 movf EEDATA,W | 1055 movf EEDATA,W |
1056 bcf STATUS,C | 1056 bcf STATUS,C |
1057 subfwb divenumber,W ; max. dives (low value) - divenumber | 1057 subfwb divenumber,W ; max. dives (low value) - dive number |
1058 movwf lo ; result | 1058 movwf lo ; result |
1059 incf divenumber,F ;+1 | 1059 incf divenumber,F ; +1 |
1060 ; Set ext_flash_address:3 to TOC entry of this dive | 1060 ; set ext_flash_address:3 to TOC entry of this dive |
1061 ; 1st: 200000h-200FFFh -> lo=0 | 1061 ; 1st: 200000h-200FFFh -> lo=0 |
1062 ; 2nd: 201000h-201FFFh -> lo=1 | 1062 ; 2nd: 201000h-201FFFh -> lo=1 |
1063 ; 3rd: 202000h-202FFFh -> lo=2 | 1063 ; 3rd: 202000h-202FFFh -> lo=2 |
1064 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | 1064 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) |
1065 clrf ext_flash_address+0 | 1065 clrf ext_flash_address+0 |
1078 movff logbook_pixel_x_pos,win_leftx2 | 1078 movff logbook_pixel_x_pos,win_leftx2 |
1079 movlw .130 | 1079 movlw .130 |
1080 cpfslt win_leftx2 ; limit left border to 130 | 1080 cpfslt win_leftx2 ; limit left border to 130 |
1081 movwf win_leftx2 | 1081 movwf win_leftx2 |
1082 WIN_FONT FT_TINY | 1082 WIN_FONT FT_TINY |
1083 movlw color_orange ; Use same color as tp° curve | 1083 movlw color_orange ; use same color as tp° curve |
1084 call TFT_set_color | 1084 call TFT_set_color |
1085 | 1085 |
1086 movff logbook_min_tp+0,lo | 1086 movff logbook_min_tp+0,lo |
1087 movff logbook_min_tp+1,hi | 1087 movff logbook_min_tp+1,hi |
1088 lfsr FSR2,buffer | 1088 lfsr FSR2,buffer |
1090 TSTOSS opt_units ; 0=°C, 1=°F | 1090 TSTOSS opt_units ; 0=°C, 1=°F |
1091 bra logbook_show_temp_metric | 1091 bra logbook_show_temp_metric |
1092 ;logbook_show_temp_imperial: | 1092 ;logbook_show_temp_imperial: |
1093 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 1093 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
1094 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit | 1094 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit |
1095 lfsr FSR2,buffer ; Overwrite "-" | 1095 lfsr FSR2,buffer ; overwrite "-" |
1096 bsf ignore_digit5 ; Full degrees only | 1096 bsf ignore_digit5 ; full degrees only |
1097 output_16 | 1097 output_16 |
1098 STRCAT_TEXT_PRINT tLogTunitF | 1098 STRCAT_TEXT_PRINT tLogTunitF |
1099 ; Now, the max. temperature | 1099 ; Now, the max. temperature |
1100 movlw .15 | 1100 movlw .15 |
1101 subwf logbook_max_temp_pos,W | 1101 subwf logbook_max_temp_pos,W |
1119 output_16dp d'2' ; temperature | 1119 output_16dp d'2' ; temperature |
1120 STRCAT_TEXT_PRINT tLogTunitC | 1120 STRCAT_TEXT_PRINT tLogTunitC |
1121 ; Now, the max. temperature | 1121 ; Now, the max. temperature |
1122 movlw .15 | 1122 movlw .15 |
1123 subwf logbook_max_temp_pos,W | 1123 subwf logbook_max_temp_pos,W |
1124 movwf win_top ; Y position at max temperature | 1124 movwf win_top ; Y position at max temperature |
1125 movff logbook_max_tp+0,lo | 1125 movff logbook_max_tp+0,lo |
1126 movff logbook_max_tp+1,hi | 1126 movff logbook_max_tp+1,hi |
1127 lfsr FSR2,buffer | 1127 lfsr FSR2,buffer |
1128 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 1128 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
1129 movlw d'3' | 1129 movlw d'3' |
1140 LOG_POINT_TO log_gas1 | 1140 LOG_POINT_TO log_gas1 |
1141 bsf log_show_gas_short ; do the short version of log_show_gas | 1141 bsf log_show_gas_short ; do the short version of log_show_gas |
1142 bsf leftbind | 1142 bsf leftbind |
1143 | 1143 |
1144 WIN_TINY log_gas_column1, log_gas_row | 1144 WIN_TINY log_gas_column1, log_gas_row |
1145 movlw .1 ; Color for Gas 1 | 1145 movlw .1 ; color for gas 1 |
1146 call log_show_gas | 1146 call log_show_gas |
1147 | 1147 |
1148 WIN_TINY log_gas_column2, log_gas_row | 1148 WIN_TINY log_gas_column2, log_gas_row |
1149 movlw .2 ; Color for Gas 2 | 1149 movlw .2 ; color for gas 2 |
1150 call log_show_gas | 1150 call log_show_gas |
1151 | 1151 |
1152 WIN_TINY log_gas_column3, log_gas_row | 1152 WIN_TINY log_gas_column3, log_gas_row |
1153 movlw .3 ; Color for Gas 3 | 1153 movlw .3 ; color for gas 3 |
1154 call log_show_gas | 1154 call log_show_gas |
1155 | 1155 |
1156 WIN_TINY log_gas_column4, log_gas_row | 1156 WIN_TINY log_gas_column4, log_gas_row |
1157 movlw .4 ; Color for Gas 4 | 1157 movlw .4 ; color for gas 4 |
1158 call log_show_gas | 1158 call log_show_gas |
1159 | 1159 |
1160 WIN_TINY log_gas_column5, log_gas_row | 1160 WIN_TINY log_gas_column5, log_gas_row |
1161 movlw .5 ; Color for Gas 5 | 1161 movlw .5 ; color for gas 5 |
1162 call log_show_gas | 1162 call log_show_gas |
1163 | 1163 |
1164 bcf leftbind | 1164 bcf leftbind |
1165 | 1165 |
1166 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | 1166 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
1167 display_profile_loop: | 1167 display_profile_loop: |
1168 btfsc switch_right | 1168 btfsc switch_right |
1169 bra logbook_page2 ; Show more information | 1169 bra logbook_page2 ; show more information |
1170 btfsc switch_left | 1170 btfsc switch_left |
1171 bra exit_profileview ; back to list | 1171 bra exit_profileview ; back to list |
1172 | 1172 |
1173 rcall log_screendump_and_onesecond ; Check if we need to make a screen-shot and check for new second | 1173 rcall log_screendump_and_onesecond ; check if we need to make a screen-shot and check for new second |
1174 btfsc sleepmode ; Timeout? | 1174 btfsc sleepmode ; timeout? |
1175 bra exit_profileview ; back to list | 1175 bra exit_profileview ; back to list |
1176 bra display_profile_loop ; wait for something to do | 1176 bra display_profile_loop ; wait for something to do |
1177 | 1177 |
1178 global log_screendump_and_onesecond | 1178 global log_screendump_and_onesecond |
1179 log_screendump_and_onesecond: ; Check if we need to make a screen-shot and check for new second | 1179 log_screendump_and_onesecond: ; check if we need to make a screen-shot and check for new second |
1180 btfsc onesecupdate | 1180 btfsc onesecupdate |
1181 call timeout_surfmode ; Timeout | 1181 call timeout_surfmode ; timeout |
1182 btfsc onesecupdate | 1182 btfsc onesecupdate |
1183 call set_dive_modes ; Check, if divemode must be entered | 1183 call set_dive_modes ; check if divemode needs to be entered |
1184 bcf onesecupdate ; one second update | 1184 bcf onesecupdate ; one second update |
1185 btfsc divemode | 1185 btfsc divemode |
1186 goto restart ; Enter divemode if required | 1186 goto restart ; enter divemode if required |
1187 | 1187 |
1188 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | 1188 IFDEF _screendump |
1189 bra log_screendump_and_onesecond2 | 1189 btfsc enable_screen_dumps ; screendump enabled? |
1190 call TFT_dump_screen_check ; YES - check if requested and do it | |
1191 ENDIF | |
1192 | |
1190 btfsc vusb_in ; USB plugged in? | 1193 btfsc vusb_in ; USB plugged in? |
1191 call comm_mode ; Start COMM mode | 1194 goto comm_mode ; YES - start COMM mode and return |
1195 | |
1192 return | 1196 return |
1193 log_screendump_and_onesecond2: | 1197 |
1194 btfss vusb_in ; USB (still) plugged in? | |
1195 bcf enable_screen_dumps ; No, clear flag | |
1196 call rs232_get_byte | |
1197 btfsc rs232_receive_overflow | |
1198 return | |
1199 movlw "l" | |
1200 cpfseq RCREG1 | |
1201 return | |
1202 goto TFT_dump_screen ; Dump the screen contents and return | |
1203 | 1198 |
1204 ;============================================================================= | 1199 ;============================================================================= |
1205 ; Draw a vertical line between xC+1 and xC+0, at current X position. | 1200 ; Draw a vertical line between xC+1 and xC+0, at current X position. |
1206 ; | 1201 ; |
1207 ; Note: should keep xC+0 | 1202 ; Note: should keep xC+0 |
1208 ; Note: ascending or descending ! | 1203 ; Note: ascending or descending ! |
1209 ; | 1204 ; |
1210 profile_display_fill: | 1205 profile_display_fill: |
1211 ; First, check if xC+0 > fill_between_rows or xC+0 < aponoe_mins | 1206 ; First, check if xC+0 > fill_between_rows or xC+0 < aponoe_mins |
1212 movf xC+0,W | 1207 movf xC+0,W |
1213 cpfseq xC+1 ; xC+0 = apone_mins? | 1208 cpfseq xC+1 ; xC+0 = apone_mins ? |
1214 bra profile_display_fill2 ; No! | 1209 bra profile_display_fill2 ; NO |
1215 return | 1210 return |
1216 | 1211 |
1217 profile_display_fill2: | 1212 profile_display_fill2: |
1218 ; Make sure to init X position. | 1213 ; Make sure to init X position. |
1219 movf logbook_pixel_x_pos,W | 1214 movf logbook_pixel_x_pos,W |
1220 mullw 2 | 1215 mullw 2 |
1221 decf PRODL,F | 1216 decf PRODL,F |
1222 movlw 0 | 1217 movlw 0 |
1223 subwfb PRODH,F | 1218 subwfb PRODH,F |
1224 call pixel_write_col320 | 1219 call pixel_write_col320 |
1225 | 1220 |
1226 movf xC+0,W | 1221 movf xC+0,W |
1227 cpfsgt xC+1 ; fill_between_rows > xC+0? | 1222 cpfsgt xC+1 ; fill_between_rows > xC+0 ? |
1228 bra profile_display_fill_up ; Yes! | 1223 bra profile_display_fill_up ; YES |
1229 | 1224 |
1230 profile_display_fill_down2: ; Loop | 1225 profile_display_fill_down2: ; loop |
1231 decf xC+1,F | 1226 decf xC+1,F |
1232 | 1227 |
1233 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) | 1228 HALF_PIXEL_WRITE xC+1 ; updates just row (0..239) |
1234 | 1229 |
1235 movf xC+0,W | 1230 movf xC+0,W |
1236 cpfseq xC+1 ; Loop until xC+1 = xC+0 | 1231 cpfseq xC+1 ; loop until xC+1 = xC+0 |
1237 bra profile_display_fill_down2 | 1232 bra profile_display_fill_down2 |
1238 return ; fill_between_rows and xC+0 are untouched | 1233 return ; fill_between_rows and xC+0 are untouched |
1239 | 1234 |
1240 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins! | 1235 profile_display_fill_up: ; fill upwards from xC+0 to apone_mins! |
1241 incf xC+1,F | 1236 incf xC+1,F |
1242 | 1237 |
1243 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) | 1238 HALF_PIXEL_WRITE xC+1 ; updates just row (0..239) |
1244 | 1239 |
1245 movf xC+0,W | 1240 movf xC+0,W |
1246 cpfseq xC+1 ; Loop until xC+1 = fill_between_rows | 1241 cpfseq xC+1 ; loop until xC+1 = fill_between_rows |
1247 bra profile_display_fill_up | 1242 bra profile_display_fill_up |
1248 return ; fill_between_rows and xC+0 are untouched | 1243 return ; fill_between_rows and xC+0 are untouched |
1249 | 1244 |
1250 ;============================================================================= | 1245 ;============================================================================= |
1251 | 1246 |
1252 | 1247 |
1253 profile_view_get_depth: | 1248 profile_view_get_depth: |
1254 infsnz logbook_sample_counter+0,F | 1249 infsnz logbook_sample_counter+0,F |
1255 incf logbook_sample_counter+1,F ; Count read pixels | 1250 incf logbook_sample_counter+1,F ; count read pixels |
1256 | 1251 |
1257 movf logbook_sample_counter+0,W | 1252 movf logbook_sample_counter+0,W |
1258 cpfseq vertical_interval+0 | 1253 cpfseq vertical_interval+0 |
1259 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | 1254 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue |
1260 movf logbook_sample_counter+1,W | 1255 movf logbook_sample_counter+1,W |
1264 clrf logbook_sample_counter+0 | 1259 clrf logbook_sample_counter+0 |
1265 clrf logbook_sample_counter+1 ; clear counting registers for next line | 1260 clrf logbook_sample_counter+1 ; clear counting registers for next line |
1266 | 1261 |
1267 ; Vertical lines... | 1262 ; Vertical lines... |
1268 movlw color_deepblue | 1263 movlw color_deepblue |
1269 call TFT_set_color ; Make this configurable? | 1264 call TFT_set_color |
1270 movlw profile_top+.1 | 1265 movlw profile_top+.1 |
1271 movwf win_top | 1266 movwf win_top |
1272 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile | 1267 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile |
1273 movwf win_leftx2 ; Left border (0-159) | 1268 movwf win_leftx2 ; left border (0-159) |
1274 movlw profile_height_pixels | 1269 movlw profile_height_pixels |
1275 movwf win_height | 1270 movwf win_height |
1276 movlw profile_height_pixels | 1271 movlw profile_height_pixels |
1277 movwf win_width ; "Window" height | 1272 movwf win_width ; "window" height |
1278 call half_horizontal_line ; Inputs: win_top, win_leftx2, win_width, win_color1, win_color2 | 1273 call half_horizontal_line ; inputs: win_top, win_leftx2, win_width, win_color1, win_color2 |
1279 | 1274 |
1280 profile_view_get_depth_no_line: | 1275 profile_view_get_depth_no_line: |
1281 call ext_flash_byte_read_plus_0x20 ; read depth first | 1276 call ext_flash_byte_read_plus_0x20 ; read depth first |
1282 movff ext_flash_rw,logbook_cur_depth+0 ; low value | 1277 movff ext_flash_rw,logbook_cur_depth+0 ; low value |
1283 call ext_flash_byte_read_plus_0x20 ; read depth first | 1278 call ext_flash_byte_read_plus_0x20 ; read depth first |
1284 movff ext_flash_rw,logbook_cur_depth+1 ; high value | 1279 movff ext_flash_rw,logbook_cur_depth+1 ; high value |
1285 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte | 1280 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte |
1286 movff ext_flash_rw,gaslist_gas ; store Profile Flag Byte | 1281 movff ext_flash_rw,gaslist_gas ; store Profile Flag Byte |
1287 | 1282 |
1288 bcf event_occured ; clear flag | 1283 bcf event_occured ; clear flag |
1289 btfsc gaslist_gas,7 | 1284 btfsc gaslist_gas,7 |
1290 bsf event_occured ; We also have an Event byte! | 1285 bsf event_occured ; we also have an event byte |
1291 bcf gaslist_gas,7 ; Clear Event Byte Flag (If any) | 1286 bcf gaslist_gas,7 ; clear event byte flag (if any) |
1292 ; gaslist_gas now holds the number of additional bytes to ignore (0-127) | 1287 ; gaslist_gas now holds the number of additional bytes to ignore (0-127) |
1293 movlw 0xFD ; end of profile bytes? | 1288 movlw 0xFD ; end of profile bytes ? |
1294 cpfseq logbook_cur_depth+0 | 1289 cpfseq logbook_cur_depth+0 |
1295 bra profile_view_get_depth_new1 ; no 1st. 0xFD | 1290 bra profile_view_get_depth_new1 ; no 1st. 0xFD |
1296 cpfseq logbook_cur_depth+1 | 1291 cpfseq logbook_cur_depth+1 |
1297 bra profile_view_get_depth_new1 ; no 2nd. 0xFD | 1292 bra profile_view_get_depth_new1 ; no 2nd. 0xFD |
1298 bsf end_of_profile ; End found! Set Flag! Skip remaining pixels! | 1293 bsf end_of_profile ; end found - set flag, skip remaining pixels |
1299 return | 1294 return |
1300 | 1295 |
1301 profile_view_get_depth_new1: | 1296 profile_view_get_depth_new1: |
1302 btfsc event_occured ; Was there an event attached to this sample? | 1297 btfsc event_occured ; was there an event attached to this sample? |
1303 rcall profile_view_get_depth_events ; Yes, get information about this event(s) | 1298 rcall profile_view_get_depth_events ; YES - get information about this event(s) |
1304 | 1299 |
1305 ;---- Read Tp°, if any AND divisor reached AND bytes available ----------- | 1300 ;---- read Tp°, if any AND divisor reached AND bytes available ----------- |
1306 movf divisor_temperature,W ; Is Tp° divisor null ? | 1301 movf divisor_temperature,W ; is Tp° divisor null ? |
1307 bz profile_view_get_depth_no_tp ; Yes: no Tp° curve. | 1302 bz profile_view_get_depth_no_tp ; YES - no Tp° curve |
1308 decf count_temperature,F ; Decrement tp° counter | 1303 decf count_temperature,F ; decrement tp° counter |
1309 bnz profile_view_get_depth_no_tp ; No temperature this time | 1304 bnz profile_view_get_depth_no_tp ; no temperature this time |
1310 | 1305 |
1311 call ext_flash_byte_read_plus_0x20 ; Tp° low | 1306 call ext_flash_byte_read_plus_0x20 ; Tp° low |
1312 decf gaslist_gas,F | 1307 decf gaslist_gas,F |
1313 movff ext_flash_rw,logbook_cur_tp+0 | 1308 movff ext_flash_rw,logbook_cur_tp+0 |
1314 call ext_flash_byte_read_plus_0x20 ; Tp° high | 1309 call ext_flash_byte_read_plus_0x20 ; Tp° high |
1315 decf gaslist_gas,F | 1310 decf gaslist_gas,F |
1316 movff ext_flash_rw,logbook_cur_tp+1 | 1311 movff ext_flash_rw,logbook_cur_tp+1 |
1317 movff divisor_temperature,count_temperature ; Restart counter. | 1312 movff divisor_temperature,count_temperature ; restart counter |
1318 | 1313 |
1319 ; Compute Tp° max on the fly... | 1314 ; Compute Tp° max on the fly... |
1320 movff logbook_cur_tp+0,sub_a+0 ; Compare cur_tp > max_tp ? | 1315 movff logbook_cur_tp+0,sub_a+0 ; compare cur_tp > max_tp ? |
1321 movff logbook_cur_tp+1,sub_a+1 | 1316 movff logbook_cur_tp+1,sub_a+1 |
1322 movff logbook_max_tp+0,sub_b+0 | 1317 movff logbook_max_tp+0,sub_b+0 |
1323 movff logbook_max_tp+1,sub_b+1 | 1318 movff logbook_max_tp+1,sub_b+1 |
1324 call sub16 ; SIGNED sub_a - sub_b | 1319 call sub16 ; SIGNED sub_a - sub_b |
1325 btfsc neg_flag | 1320 btfsc neg_flag |
1326 bra profile_view_get_depth_no_tp | 1321 bra profile_view_get_depth_no_tp |
1327 | 1322 |
1328 ; store max. temp only below start_dive_threshold (1,0m) | 1323 ; store max. temp only below start_dive_threshold (1,0m) |
1329 tstfsz logbook_cur_depth+1 ; > 2,56m? | 1324 tstfsz logbook_cur_depth+1 ; > 2,56m ? |
1330 bra profile_view_compute_max_temp ; Yes, include in max. temp measurement | 1325 bra profile_view_compute_max_temp ; YES - include in max. temp measurement |
1331 movlw start_dive_threshold ; 1,0m | 1326 movlw start_dive_threshold ; 1,0m |
1332 cpfsgt logbook_cur_depth+0 ; low value | 1327 cpfsgt logbook_cur_depth+0 ; low value |
1333 bra profile_view_get_depth_no_tp ; above 1,0m, ignore temp | 1328 bra profile_view_get_depth_no_tp ; above 1,0m, ignore temp |
1334 | 1329 |
1335 profile_view_compute_max_temp: | 1330 profile_view_compute_max_temp: |
1336 movff logbook_cur_tp+0,logbook_max_tp+0 | 1331 movff logbook_cur_tp+0,logbook_max_tp+0 |
1337 movff logbook_cur_tp+1,logbook_max_tp+1 | 1332 movff logbook_cur_tp+1,logbook_max_tp+1 |
1338 | 1333 |
1339 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- | 1334 ;---- read deco, if any AND divisor=0 AND bytes available ---------------- |
1340 profile_view_get_depth_no_tp: | 1335 profile_view_get_depth_no_tp: |
1341 movf divisor_deco,W | 1336 movf divisor_deco,W |
1342 bz profile_view_get_depth_no_deco | 1337 bz profile_view_get_depth_no_deco |
1343 decf count_deco,F | 1338 decf count_deco,F |
1344 bnz profile_view_get_depth_no_deco | 1339 bnz profile_view_get_depth_no_deco |
1345 | 1340 |
1346 call ext_flash_byte_read_plus_0x20 | 1341 call ext_flash_byte_read_plus_0x20 |
1347 decf gaslist_gas,F | 1342 decf gaslist_gas,F |
1348 movff ext_flash_rw,logbook_ceiling | 1343 movff ext_flash_rw,logbook_ceiling |
1349 movff divisor_deco,count_deco ; Restart counter. | 1344 movff divisor_deco,count_deco ; restart counter |
1350 call ext_flash_byte_read_plus_0x20 ; Skip stop length | 1345 call ext_flash_byte_read_plus_0x20 ; skip stop length |
1351 decf gaslist_gas,F | 1346 decf gaslist_gas,F |
1352 | 1347 |
1353 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------ | 1348 ;---- read GF, if any AND divisor=0 AND bytes available ------------------ |
1354 profile_view_get_depth_no_deco: | 1349 profile_view_get_depth_no_deco: |
1355 ; Then skip remaining bytes... | 1350 ; Then skip remaining bytes... |
1356 movf gaslist_gas,W ; number of additional bytes to ignore (0-127) | 1351 movf gaslist_gas,W ; number of additional bytes to ignore (0-127) |
1357 tstfsz gaslist_gas ; Anything to skip? | 1352 tstfsz gaslist_gas ; anything to skip? |
1358 call incf_ext_flash_address0_0x20 ; Yes, increases bytes in ext_flash_address:3 with 0x200000 bank switching | 1353 call incf_ext_flash_address0_0x20 ; YES - increases bytes in ext_flash_address:3 with 0x200000 bank switching |
1359 return | 1354 return |
1360 | 1355 |
1361 profile_view_get_depth_events: | 1356 profile_view_get_depth_events: |
1362 clrf EventByte2 ; Clear EventByte2 | 1357 clrf EventByte2 ; clear EventByte2 |
1363 call ext_flash_byte_read_plus_0x20 ; Read Event byte | 1358 call ext_flash_byte_read_plus_0x20 ; read event byte |
1364 movff ext_flash_rw,EventByte1 ; store EventByte1 | 1359 movff ext_flash_rw,EventByte1 ; store EventByte1 |
1365 decf gaslist_gas,F ; reduce counter | 1360 decf gaslist_gas,F ; reduce counter |
1366 | 1361 |
1367 btfss EventByte1,7 ; Another Event byte? | 1362 btfss EventByte1,7 ; another event byte? |
1368 bra profile_no_second_eventbyte ; No | 1363 bra profile_no_second_eventbyte ; NO |
1369 call ext_flash_byte_read_plus_0x20 ; Read Event byte2 | 1364 call ext_flash_byte_read_plus_0x20 ; read EventByte2 |
1370 movff ext_flash_rw,EventByte2 ; store EventByte2 | 1365 movff ext_flash_rw,EventByte2 ; store EventByte2 |
1371 decf gaslist_gas,F ; reduce counter | 1366 decf gaslist_gas,F ; reduce counter |
1372 bcf EventByte1,7 ; Clear flag | 1367 bcf EventByte1,7 ; clear flag |
1373 | 1368 |
1374 profile_no_second_eventbyte: | 1369 profile_no_second_eventbyte: |
1375 ; Check event flags in the EventBytes | 1370 ; Check event flags in the EventBytes |
1376 btfsc EventByte1,4 ; Manual Gas Changed? | 1371 btfsc EventByte1,4 ; manual gas changed? |
1377 rcall logbook_event1 ; Yes! | 1372 rcall logbook_event1 ; YES |
1378 btfsc EventByte1,5 ; Stored Gas Changed? | 1373 btfsc EventByte1,5 ; stored gas changed? |
1379 rcall logbook_event4 ; Yes! | 1374 rcall logbook_event4 ; YES |
1380 btfsc EventByte1,6 ; Setpoint Change? | 1375 btfsc EventByte1,6 ; setpoint change? |
1381 rcall logbook_event3 ; Yes! | 1376 rcall logbook_event3 ; YES |
1382 btfsc EventByte2,0 ; Bailout? | 1377 btfsc EventByte2,0 ; bailout? |
1383 rcall logbook_event2 ; Yes! | 1378 rcall logbook_event2 ; YES |
1384 ; Any Alarm? | 1379 ; Any Alarm? |
1385 bcf EventByte1,4 ; Clear bits already tested | 1380 bcf EventByte1,4 ; clear bits already tested |
1386 bcf EventByte1,5 | 1381 bcf EventByte1,5 |
1387 bcf EventByte1,6 | 1382 bcf EventByte1,6 |
1388 movlw .6 ; manual marker? | 1383 movlw .6 ; manual marker? |
1389 cpfseq EventByte1 | 1384 cpfseq EventByte1 |
1390 return ; No, return | 1385 return ; NO - return |
1391 bsf log_marker_found ; Manual marker! Draw small yellow rectangle here | 1386 bsf log_marker_found ; manual marker, draw small yellow rectangle here |
1392 return | 1387 return |
1393 | 1388 |
1394 logbook_event4: ; Stored Gas changed! | 1389 logbook_event4: ; stored gas changed |
1395 call ext_flash_byte_read_plus_0x20 ; Read Gas# | 1390 call ext_flash_byte_read_plus_0x20 ; read Gas# |
1396 decf gaslist_gas,F ; reduce counter | 1391 decf gaslist_gas,F ; reduce counter |
1397 movff ext_flash_rw,backup_color1 | 1392 movff ext_flash_rw,backup_color1 |
1398 movff ext_flash_rw,WREG ; copy gas number to WREG for color-coding | 1393 movff ext_flash_rw,WREG ; copy gas number to WREG for color-coding |
1399 call TFT_color_code_gas ; Change profile color according to gas number | 1394 call TFT_color_code_gas ; change profile color according to gas number |
1400 return | 1395 return |
1401 | 1396 |
1402 logbook_event1: ; Gas 6 used | 1397 logbook_event1: ; gas 6 used |
1403 bsf gas6_changed | 1398 bsf gas6_changed |
1404 movlw .6 ; Use Gas6 color | 1399 movlw .6 ; use Gas6 color |
1405 movwf backup_color1 | 1400 movwf backup_color1 |
1406 call TFT_color_code_gas ; set profile color | 1401 call TFT_color_code_gas ; set profile color |
1407 incf_ext_flash_address_0x20 .2 ; Skip two bytes | 1402 incf_ext_flash_address_0x20 .2 ; skip two bytes |
1408 decf gaslist_gas,F ; reduce counter | 1403 decf gaslist_gas,F ; reduce counter |
1409 decf gaslist_gas,F ; reduce counter | 1404 decf gaslist_gas,F ; reduce counter |
1410 return | 1405 return |
1411 | 1406 |
1412 logbook_event2: ; Bailout | 1407 logbook_event2: ; bailout |
1413 bsf is_bailout ; Set flag | 1408 bsf FLAG_bailout_mode ; set flag |
1414 movff backup_color1,backup_color2 ; Backup last gas color in case we return to CCR | 1409 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR |
1415 movlw .6 ; Use Gas6 color | 1410 movlw .6 ; use Gas6 color |
1416 movwf backup_color1 | 1411 movwf backup_color1 |
1417 call TFT_color_code_gas ; Use Gas6 color | 1412 call TFT_color_code_gas ; use Gas6 color |
1418 incf_ext_flash_address_0x20 .2 ; Skip two bytes | 1413 incf_ext_flash_address_0x20 .2 ; skip two bytes |
1419 decf gaslist_gas,F ; reduce counter | 1414 decf gaslist_gas,F ; reduce counter |
1420 decf gaslist_gas,F ; reduce counter | 1415 decf gaslist_gas,F ; reduce counter |
1421 return | 1416 return |
1422 | 1417 |
1423 logbook_event3: ; Setpoint change | 1418 logbook_event3: ; setpoint change |
1424 incf_ext_flash_address_0x20 .1 ; Skip one byte | 1419 incf_ext_flash_address_0x20 .1 ; skip one byte |
1425 decf gaslist_gas,F ; reduce counter | 1420 decf gaslist_gas,F ; reduce counter |
1426 btfss is_bailout ; Are we in bailout? | 1421 btfss FLAG_bailout_mode ; are we in bailout? |
1427 return ; No, return | 1422 return ; NO - return |
1428 ; We were in bailout before, restore profile color | 1423 ; We were in bailout before, restore profile color |
1429 movff backup_color2,backup_color1 ; Restore color | 1424 movff backup_color2,backup_color1 ; restore color |
1430 movff backup_color2,WREG ; copy gas number to WREG for color-coding | 1425 movff backup_color2,WREG ; copy gas number to WREG for color-coding |
1431 call TFT_color_code_gas ; Back to normal profile color | 1426 call TFT_color_code_gas ; back to normal profile color |
1432 return | 1427 return |
1428 | |
1429 ; ------------------------------------------------------------------------ | |
1433 | 1430 |
1434 exit_profileview: | 1431 exit_profileview: |
1435 ; call speed_fastest | 1432 ; call speed_fastest |
1436 bcf sleepmode | 1433 bcf sleepmode |
1437 clrf gaslist_gas ; restore all registers to build same page again | 1434 clrf gaslist_gas ; restore all registers to build same page again |
1438 movff logbook_divenumber_temp,logbook_divenumber | 1435 movff logbook_divenumber_temp,logbook_divenumber |
1439 movff logbook_max_dive_counter_temp,logbook_max_dive_counter | 1436 movff logbook_max_dive_counter_temp,logbook_max_dive_counter |
1440 movff logbook_temp_backup,logbook_temp | 1437 movff logbook_temp_backup,logbook_temp |
1441 incf logbook_max_dive_counter,F | 1438 incf logbook_max_dive_counter,F |
1442 decf logbook_divenumber,F | 1439 decf logbook_divenumber,F |
1445 movlw logbook_row_number | 1442 movlw logbook_row_number |
1446 movwf menupos1 ; here: active row on current page | 1443 movwf menupos1 ; here: active row on current page |
1447 ; call TFT_DisplayOff | 1444 ; call TFT_DisplayOff |
1448 call TFT_boot | 1445 call TFT_boot |
1449 clrf CCP1CON ; stop PWM | 1446 clrf CCP1CON ; stop PWM |
1450 bcf PORTC,2 ; Pull PWM out to GND | 1447 bcf PORTC,2 ; pull PWM out to GND |
1451 call TFT_boot | 1448 call TFT_boot |
1452 ; call TFT_ClearScreen ; clear details/profile | 1449 ; call TFT_ClearScreen ; clear details/profile |
1453 goto logbook2 ; start search | 1450 goto logbook2 ; start search |
1454 | 1451 |
1455 next_logbook2: | 1452 next_logbook2: |
1457 goto logbook ; all reset | 1454 goto logbook ; all reset |
1458 clrf menupos3 | 1455 clrf menupos3 |
1459 movlw logbook_row_number | 1456 movlw logbook_row_number |
1460 movwf menupos1 | 1457 movwf menupos1 |
1461 incf logbook_page_number,F ; start new screen | 1458 incf logbook_page_number,F ; start new screen |
1462 bsf keep_cursor_new_page ; Keep cursor on "next page" | 1459 bsf keep_cursor_new_page ; keep cursor on "next page" |
1463 clrf CCP1CON ; stop PWM | 1460 clrf CCP1CON ; stop PWM |
1464 bcf PORTC,2 ; Pull PWM out to GND | 1461 bcf PORTC,2 ; pull PWM out to GND |
1465 call TFT_boot | 1462 call TFT_boot |
1466 ; call TFT_ClearScreen | 1463 ; call TFT_ClearScreen |
1467 goto logbook2 ; start search | 1464 goto logbook2 ; start search |
1468 | 1465 |
1469 next_logbook3: | 1466 next_logbook3: |
1470 incf menupos1,F ; +1 | 1467 incf menupos1,F ; +1 |
1471 movlw logbook_row_number+.2 | 1468 movlw logbook_row_number+.2 |
1472 cpfsgt menupos1 ; =logbook_row_number+.3? | 1469 cpfsgt menupos1 ; = logbook_row_number+.3 ? |
1473 bra next_logbook3a ; No | 1470 bra next_logbook3a ; NO |
1474 movlw .1 | 1471 movlw .1 |
1475 movwf menupos1 | 1472 movwf menupos1 |
1476 bra next_logbook3b | 1473 bra next_logbook3b |
1477 | 1474 |
1478 next_logbook3a: | 1475 next_logbook3a: |
1479 incf menupos3,W ; last entry in current page +1 | 1476 incf menupos3,W ; last entry in current page +1 |
1480 cpfseq menupos1 ; same as cursor pos.? | 1477 cpfseq menupos1 ; same as cursor pos.? |
1481 bra next_logbook3b ; No | 1478 bra next_logbook3b ; NO |
1482 movlw logbook_row_number+.1 ; Yes, ... | 1479 movlw logbook_row_number+.1 ; YES - |
1483 movwf menupos1 ; ... jump directly to "next page" if page is not full | 1480 movwf menupos1 ; - jump directly to "next page" if page is not full |
1484 | 1481 |
1485 movlw logbook_row_number | 1482 movlw logbook_row_number |
1486 cpfseq menupos3 ; Last dive was row logbook_row_number? | 1483 cpfseq menupos3 ; last dive was row logbook_row_number? |
1487 bsf all_dives_shown ; No, set flag to load first page again (full reset) | 1484 bsf all_dives_shown ; NO - set flag to load first page again (full reset) |
1488 | 1485 |
1489 next_logbook3b: | 1486 next_logbook3b: |
1490 clrf timeout_counter2 | 1487 clrf timeout_counter2 |
1491 call TFT_logbook_cursor | 1488 call TFT_logbook_cursor |
1492 bcf switch_left | 1489 bcf switch_left |
1493 goto logbook_loop | 1490 goto logbook_loop |
1494 | 1491 |
1495 display_listdive: | 1492 display_listdive: |
1496 bsf logbook_page_not_empty ; Page not empty | 1493 bsf logbook_page_not_empty ; page not empty |
1497 incf menupos3,F | 1494 incf menupos3,F |
1498 | 1495 |
1499 bsf leftbind | 1496 bsf leftbind |
1500 WIN_FONT FT_SMALL | 1497 WIN_FONT FT_SMALL |
1501 WIN_LEFT logbook_list_left | 1498 WIN_LEFT logbook_list_left |
1503 decf menupos3,W ; -1 into wreg | 1500 decf menupos3,W ; -1 into wreg |
1504 mullw logbook_row_offset | 1501 mullw logbook_row_offset |
1505 movff PRODL,win_top | 1502 movff PRODL,win_top |
1506 | 1503 |
1507 lfsr FSR2,buffer | 1504 lfsr FSR2,buffer |
1508 call do_logoffset_common_read ; Read into lo:hi | 1505 call do_logoffset_common_read ; read into lo:hi |
1509 tstfsz lo ; lo=0? | 1506 tstfsz lo ; lo = 0 ? |
1510 bra display_listdive1 ; No, adjust offset | 1507 bra display_listdive1 ; NO - adjust offset |
1511 tstfsz hi ; hi=0? | 1508 tstfsz hi ; hi = 0 ? |
1512 bra display_listdive1 ; No, adjust offset | 1509 bra display_listdive1 ; NO - adjust offset |
1513 bra display_listdive1b ; Display now | 1510 bra display_listdive1b ; display now |
1514 | 1511 |
1515 display_listdive1: | 1512 display_listdive1: |
1516 ; Check limit (lo:hi must be <1000) | 1513 ; Check limit (lo:hi must be <1000) |
1517 movlw LOW d'1000' ; Compare to 1000 | 1514 movlw LOW d'1000' ; compare to 1000 |
1518 subwf lo,W | 1515 subwf lo,W |
1519 movlw HIGH d'1000' | 1516 movlw HIGH d'1000' |
1520 subwfb hi,W | 1517 subwfb hi,W |
1521 bc display_listdive1b ; carry = no-borrow = > 1000, skip! | 1518 bc display_listdive1b ; carry = no-borrow = > 1000, skip! |
1522 | 1519 |
1536 movff logbook_divenumber,lo ; lo=0 and hi=0 -> show without applied offset | 1533 movff logbook_divenumber,lo ; lo=0 and hi=0 -> show without applied offset |
1537 display_listdive1a: | 1534 display_listdive1a: |
1538 output_16_3 ; displays only last three figures from a 16Bit value (0-999), # of dive | 1535 output_16_3 ; displays only last three figures from a 16Bit value (0-999), # of dive |
1539 PUTC ' ' | 1536 PUTC ' ' |
1540 ;display_listdive2: | 1537 ;display_listdive2: |
1541 LOG_POINT_TO log_date+1 ; Point to month | 1538 LOG_POINT_TO log_date+1 ; point to month |
1542 call ext_flash_byte_read_plus ; read month | 1539 call ext_flash_byte_read_plus ; read month |
1543 movff ext_flash_rw,hi ; month | 1540 movff ext_flash_rw,hi ; month |
1544 call ext_flash_byte_read_plus ; read day | 1541 call ext_flash_byte_read_plus ; read day |
1545 movff ext_flash_rw,lo ; day | 1542 movff ext_flash_rw,lo ; day |
1546 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer | 1543 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer |
1547 PUTC ' ' | 1544 PUTC ' ' |
1548 | 1545 |
1549 LOG_POINT_TO log_max_depth ; Point to max. depth | 1546 LOG_POINT_TO log_max_depth ; point to max. depth |
1550 call ext_flash_byte_read_plus ; max. Depth | 1547 call ext_flash_byte_read_plus ; max. depth |
1551 movff ext_flash_rw,lo | 1548 movff ext_flash_rw,lo |
1552 call ext_flash_byte_read_plus | 1549 call ext_flash_byte_read_plus |
1553 movff ext_flash_rw,hi | 1550 movff ext_flash_rw,hi |
1554 | 1551 |
1555 TSTOSS opt_units ; 0=Meters, 1=Feets | 1552 TSTOSS opt_units ; 0=Meters, 1=Feets |
1574 display_listdive3: | 1571 display_listdive3: |
1575 call ext_flash_byte_read_plus | 1572 call ext_flash_byte_read_plus |
1576 movff ext_flash_rw,lo ; read divetime minutes | 1573 movff ext_flash_rw,lo ; read divetime minutes |
1577 call ext_flash_byte_read_plus | 1574 call ext_flash_byte_read_plus |
1578 movff ext_flash_rw,hi | 1575 movff ext_flash_rw,hi |
1579 output_16_3 ; Divetime minutes (0-999min) | 1576 output_16_3 ; divetime minutes (0-999min) |
1580 STRCAT_TEXT tMinutes | 1577 STRCAT_TEXT tMinutes |
1581 clrf WREG | 1578 clrf WREG |
1582 movff WREG,buffer+.21 ; limit to 21 chars | 1579 movff WREG,buffer+.21 ; limit to 21 chars |
1583 STRCAT_PRINT "" ; Display header-row in list | 1580 STRCAT_PRINT "" ; display header-row in list |
1584 return | 1581 return |
1585 | 1582 |
1583 ; ------------------------------------------------------------------ | |
1584 | |
1586 logbook_show_divenumber: | 1585 logbook_show_divenumber: |
1587 call do_logoffset_common_read ; Read into lo:hi | 1586 call do_logoffset_common_read ; read into lo:hi |
1588 tstfsz lo ; lo=0? | 1587 tstfsz lo ; lo = 0 ? |
1589 bra logbook_show_divenumber2 ; No, adjust offset | 1588 bra logbook_show_divenumber2 ; NO - adjust offset |
1590 tstfsz hi ; hi=0? | 1589 tstfsz hi ; hi = 0 ? |
1591 bra logbook_show_divenumber2 ; No, adjust offset | 1590 bra logbook_show_divenumber2 ; NO - adjust offset |
1592 movff divenumber,lo ; lo=0 and hi=0 -> skip Offset routine | 1591 movff divenumber,lo ; lo = 0 and hi = 0 -> skip offset routine |
1593 bra logbook_show_divenumber3 ; Display now | 1592 bra logbook_show_divenumber3 ; display now |
1594 | 1593 |
1595 logbook_show_divenumber2: | 1594 logbook_show_divenumber2: |
1596 infsnz lo,F | 1595 infsnz lo,F |
1597 incf hi,F ; hi:lo = hi:lo + 1 | 1596 incf hi,F ; hi:lo = hi:lo + 1 |
1598 movff lo,sub_a+0 | 1597 movff lo,sub_a+0 |
1609 output_16 ; # of dive in logbook | 1608 output_16 ; # of dive in logbook |
1610 bcf leftbind | 1609 bcf leftbind |
1611 STRCAT_PRINT "" | 1610 STRCAT_PRINT "" |
1612 return | 1611 return |
1613 | 1612 |
1614 | 1613 ; ------------------------------------------------------------------- |
1615 logbook_page2: ; Show more info | 1614 |
1616 rcall log_details_header ; Shows number, time/date and basic dive info | 1615 logbook_page2: ; show more info |
1616 rcall log_details_header ; shows number, time/date and basic dive info | |
1617 | 1617 |
1618 ; Deco model | 1618 ; Deco model |
1619 WIN_SMALL .5,.65 | 1619 WIN_SMALL .5,.65 |
1620 LOG_POINT_TO log_decomodel | 1620 LOG_POINT_TO log_decomodel |
1621 call ext_flash_byte_read_plus ; read deco model | 1621 call ext_flash_byte_read_plus ; read deco model |
1625 ; Deco model GF Version | 1625 ; Deco model GF Version |
1626 STRCAT_PRINT "ZHL-16+GF" | 1626 STRCAT_PRINT "ZHL-16+GF" |
1627 LOG_POINT_TO log_gf_lo | 1627 LOG_POINT_TO log_gf_lo |
1628 WIN_SMALL .5,.90 | 1628 WIN_SMALL .5,.90 |
1629 STRCPY_TEXT tGF | 1629 STRCPY_TEXT tGF |
1630 call ext_flash_byte_read_plus ; Read GF lo | 1630 call ext_flash_byte_read_plus ; read GF lo |
1631 movff ext_flash_rw,lo | 1631 movff ext_flash_rw,lo |
1632 output_8 | 1632 output_8 |
1633 STRCAT "%/" | 1633 STRCAT "%/" |
1634 bra logbook_decomodel_common | 1634 bra logbook_decomodel_common |
1635 logbook_decomodel1: | 1635 logbook_decomodel1: |
1636 ; Deco model NON-GF Version | 1636 ; Deco model NON-GF Version |
1637 STRCAT_PRINT "ZH-L16" | 1637 STRCAT_PRINT "ZH-L16" |
1638 LOG_POINT_TO log_sat_mult | 1638 LOG_POINT_TO log_sat_mult |
1639 WIN_SMALL .5,.90 | 1639 WIN_SMALL .5,.90 |
1640 call ext_flash_byte_read_plus ; Read sat_mult | 1640 call ext_flash_byte_read_plus ; read sat_mult |
1641 movff ext_flash_rw,lo | 1641 movff ext_flash_rw,lo |
1642 output_8 | 1642 output_8 |
1643 STRCAT "%/" | 1643 STRCAT "%/" |
1644 logbook_decomodel_common: | 1644 logbook_decomodel_common: |
1645 call ext_flash_byte_read_plus ; Read desat_mult or GF_hi | 1645 call ext_flash_byte_read_plus ; read desat_mult or GF_hi |
1646 movff ext_flash_rw,lo | 1646 movff ext_flash_rw,lo |
1647 output_8 | 1647 output_8 |
1648 STRCAT_PRINT "%" | 1648 STRCAT_PRINT "%" |
1649 | 1649 |
1650 ; CNS | 1650 ; CNS |
1653 STRCPY_TEXT tCNS2 | 1653 STRCPY_TEXT tCNS2 |
1654 call ext_flash_byte_read_plus ; read cns low | 1654 call ext_flash_byte_read_plus ; read cns low |
1655 movff ext_flash_rw,lo | 1655 movff ext_flash_rw,lo |
1656 call ext_flash_byte_read_plus ; read cns high | 1656 call ext_flash_byte_read_plus ; read cns high |
1657 movff ext_flash_rw,hi | 1657 movff ext_flash_rw,hi |
1658 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to ext. Flash) | 1658 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) |
1659 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to ext. Flash) | 1659 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) |
1660 output_16 | 1660 output_16 |
1661 LOG_POINT_TO log_cns_end | 1661 LOG_POINT_TO log_cns_end |
1662 STRCAT "->" | 1662 STRCAT "->" |
1663 call ext_flash_byte_read_plus ; read CNS low | 1663 call ext_flash_byte_read_plus ; read CNS low |
1664 movff ext_flash_rw,lo | 1664 movff ext_flash_rw,lo |
1665 call ext_flash_byte_read_plus ; read CNS high | 1665 call ext_flash_byte_read_plus ; read CNS high |
1666 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to ext. Flash) | |
1667 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to ext. Flash) | |
1668 movff ext_flash_rw,hi | 1666 movff ext_flash_rw,hi |
1667 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) | |
1668 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) | |
1669 output_16 | 1669 output_16 |
1670 STRCAT_PRINT "%" | 1670 STRCAT_PRINT "%" |
1671 | 1671 |
1672 ; Salinity | 1672 ; Salinity |
1673 WIN_SMALL .5,.140 | 1673 WIN_SMALL .5,.140 |
1694 STRCAT_PRINT "m" | 1694 STRCAT_PRINT "m" |
1695 | 1695 |
1696 ; Last deco | 1696 ; Last deco |
1697 LOG_POINT_TO log_last_stop | 1697 LOG_POINT_TO log_last_stop |
1698 WIN_SMALL .5,.190 | 1698 WIN_SMALL .5,.190 |
1699 STRCPY_TEXT tLastDecostop | 1699 STRCPY_TEXT tLastDecostopSurf |
1700 call ext_flash_byte_read_plus ; Read last stop | 1700 call ext_flash_byte_read_plus ; read last stop |
1701 movff ext_flash_rw,lo | 1701 movff ext_flash_rw,lo |
1702 output_8 | 1702 output_8 |
1703 STRCAT_PRINT "m" | 1703 STRCAT_PRINT "m" |
1704 | 1704 |
1705 movlw color_lightblue | 1705 movlw color_lightblue |
1714 call ext_flash_byte_read_plus ; read firmware xx | 1714 call ext_flash_byte_read_plus ; read firmware xx |
1715 movff ext_flash_rw,lo | 1715 movff ext_flash_rw,lo |
1716 bsf neg_flag ; set flag for 2.15 or newer | 1716 bsf neg_flag ; set flag for 2.15 or newer |
1717 movlw .1 | 1717 movlw .1 |
1718 cpfsgt lo ; >1? | 1718 cpfsgt lo ; >1? |
1719 bcf neg_flag ; No, clear flag | 1719 bcf neg_flag ; NO - clear flag |
1720 movlw .9 | 1720 movlw .9 |
1721 cpfslt lo ; <9 ? | 1721 cpfslt lo ; <9 ? |
1722 bcf neg_flag ; No, clear flag (When unit was upgraded from hwOS Sport (10.xx)) | 1722 bcf neg_flag ; NO - clear flag (When unit was upgraded from hwOS Sport (10.xx)) |
1723 bsf leftbind | 1723 bsf leftbind |
1724 output_8 | 1724 output_8 |
1725 PUTC "." | 1725 PUTC "." |
1726 call ext_flash_byte_read_plus ; read firmware yy | 1726 call ext_flash_byte_read_plus ; read firmware yy |
1727 movff ext_flash_rw,lo | 1727 movff ext_flash_rw,lo |
1728 movlw .14 | 1728 movlw .14 |
1729 cpfsgt lo ; >14 ? | 1729 cpfsgt lo ; >14 ? |
1730 bcf neg_flag ; No, clear flag | 1730 bcf neg_flag ; NO - clear flag |
1731 output_99x | 1731 output_99x |
1732 STRCAT_PRINT "" | 1732 STRCAT_PRINT "" |
1733 | 1733 |
1734 btfss neg_flag ; set flag for 2.15 or newer | 1734 btfss neg_flag ; set flag for 2.15 or newer |
1735 bra logbook_no_batt_info | 1735 bra logbook_no_batt_info |
1736 | 1736 |
1737 ; Battery percent (for dives with 2.15 or newer) | 1737 ; Battery percent (for dives with 2.15 or newer) |
1738 WIN_SMALL .110,.140 | 1738 WIN_SMALL .110,.140 |
1739 LOG_POINT_TO log_batt_info ; Battery percent | 1739 LOG_POINT_TO log_batt_info ; battery percent |
1740 call ext_flash_byte_read_plus ; read battery low | 1740 call ext_flash_byte_read_plus ; read battery low |
1741 movff ext_flash_rw,lo | 1741 movff ext_flash_rw,lo |
1742 output_8 | 1742 output_8 |
1743 STRCAT_PRINT "%" | 1743 STRCAT_PRINT "%" |
1744 | 1744 |
1746 | 1746 |
1747 ; Battery voltage | 1747 ; Battery voltage |
1748 WIN_SMALL .110,.90 | 1748 WIN_SMALL .110,.90 |
1749 STRCAT_PRINT "Batt:" | 1749 STRCAT_PRINT "Batt:" |
1750 WIN_SMALL .110,.115 | 1750 WIN_SMALL .110,.115 |
1751 LOG_POINT_TO log_battery ; Battery voltage... | 1751 LOG_POINT_TO log_battery ; battery voltage |
1752 call ext_flash_byte_read_plus ; read battery low | 1752 call ext_flash_byte_read_plus ; read battery low |
1753 movff ext_flash_rw,lo | 1753 movff ext_flash_rw,lo |
1754 call ext_flash_byte_read_plus ; read battery high | 1754 call ext_flash_byte_read_plus ; read battery high |
1755 movff ext_flash_rw,hi | 1755 movff ext_flash_rw,hi |
1756 output_16dp .2 | 1756 output_16dp .2 |
1763 call ext_flash_byte_read_plus ; read surface pressure | 1763 call ext_flash_byte_read_plus ; read surface pressure |
1764 movff ext_flash_rw,hi | 1764 movff ext_flash_rw,hi |
1765 WIN_SMALL .110,.165 | 1765 WIN_SMALL .110,.165 |
1766 lfsr FSR2,buffer | 1766 lfsr FSR2,buffer |
1767 bsf leftbind | 1767 bsf leftbind |
1768 output_16 ; Air pressure before dive | 1768 output_16 ; air pressure before dive |
1769 STRCAT_TEXT tMBAR | 1769 STRCAT_TEXT tMBAR |
1770 clrf WREG | 1770 clrf WREG |
1771 movff WREG,buffer+7 ; limit to 7 chars | 1771 movff WREG,buffer+7 ; limit to 7 chars |
1772 STRCAT_PRINT "" | 1772 STRCAT_PRINT "" |
1773 | 1773 |
1774 movlw color_greenish | 1774 movlw color_greenish |
1775 call TFT_set_color | 1775 call TFT_set_color |
1776 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; Top, Bottom, Left, Right | 1776 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; Top, Bottom, Left, Right |
1777 | 1777 |
1778 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | 1778 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
1779 display_details_loop: | 1779 display_details_loop: |
1780 btfsc switch_right | 1780 btfsc switch_right |
1781 bra logbook_page3 ; Details, 2nd page | 1781 bra logbook_page3 ; details, 2nd page |
1782 btfsc switch_left | 1782 btfsc switch_left |
1783 bra exit_profileview ; back to list | 1783 bra exit_profileview ; back to list |
1784 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | 1784 rcall log_screendump_and_onesecond ; check if we need to make a screenshot and check for new second |
1785 btfsc sleepmode ; Timeout? | 1785 btfsc sleepmode ; timeout? |
1786 bra exit_profileview ; back to list | 1786 bra exit_profileview ; back to list |
1787 bra display_details_loop ; wait for something to do | 1787 bra display_details_loop ; wait for something to do |
1788 | 1788 |
1789 global logbook_preloop_tasks | 1789 global logbook_preloop_tasks |
1790 logbook_preloop_tasks: | 1790 logbook_preloop_tasks: |
1791 movlw CCP1CON_VALUE ; See hwos.inc | 1791 movlw CCP1CON_VALUE ; see hwos.inc |
1792 movwf CCP1CON ; Power-on backlight | 1792 movwf CCP1CON ; power-on backlight |
1793 call TFT_standard_color | 1793 call TFT_standard_color |
1794 bcf sleepmode ; clear some flags | 1794 bcf sleepmode ; clear some flags |
1795 bcf switch_right | 1795 bcf switch_right |
1796 bcf switch_left | 1796 bcf switch_left |
1797 clrf timeout_counter2 | 1797 clrf timeout_counter2 |
1798 goto speed_normal ; and return | 1798 goto speed_normal ; and return |
1799 | 1799 |
1800 | 1800 |
1801 logbook_page3: ; Show even more info +++ | 1801 logbook_page3: ; show even more info |
1802 rcall log_details_header ; Shows number, time/date and basic dive info | 1802 rcall log_details_header ; shows number, time/date and basic dive info |
1803 LOG_POINT_TO log_gas1 | 1803 LOG_POINT_TO log_gas1 |
1804 bcf log_show_gas_short ; do the long version of log_show_gas | 1804 bcf log_show_gas_short ; do the long version of log_show_gas |
1805 bcf leftbind | 1805 bcf leftbind |
1806 | 1806 |
1807 WIN_SMALL .5,.90 | 1807 WIN_SMALL .5,.90 |
1808 movlw .1 ; Color for Gas 1 | 1808 movlw .1 ; color for gas 1 |
1809 rcall log_show_gas | 1809 rcall log_show_gas |
1810 | 1810 |
1811 WIN_SMALL .5,.115 | 1811 WIN_SMALL .5,.115 |
1812 movlw .2 ; Color for Gas 2 | 1812 movlw .2 ; color for gas 2 |
1813 rcall log_show_gas | 1813 rcall log_show_gas |
1814 | 1814 |
1815 WIN_SMALL .5,.140 | 1815 WIN_SMALL .5,.140 |
1816 movlw .3 ; Color for Gas 3 | 1816 movlw .3 ; color for gas 3 |
1817 rcall log_show_gas | 1817 rcall log_show_gas |
1818 | 1818 |
1819 WIN_SMALL .5,.165 | 1819 WIN_SMALL .5,.165 |
1820 movlw .4 ; Color for Gas 4 | 1820 movlw .4 ; color for gas 4 |
1821 rcall log_show_gas | 1821 rcall log_show_gas |
1822 | 1822 |
1823 WIN_SMALL .5,.190 | 1823 WIN_SMALL .5,.190 |
1824 movlw .5 ; Color for Gas 5 | 1824 movlw .5 ; color for gas 5 |
1825 rcall log_show_gas | 1825 rcall log_show_gas |
1826 | 1826 |
1827 ; OC/CC Gas List | 1827 ; OC/CC Gas List |
1828 WIN_SMALL .5,.65 | 1828 WIN_SMALL .5,.65 |
1829 WIN_COLOR color_greenish | 1829 WIN_COLOR color_greenish |
1836 logbook_page3a: | 1836 logbook_page3a: |
1837 STRCPY_TEXT_PRINT tGaslist | 1837 STRCPY_TEXT_PRINT tGaslist |
1838 logbook_page3b: | 1838 logbook_page3b: |
1839 movlw color_lightblue | 1839 movlw color_lightblue |
1840 call TFT_set_color | 1840 call TFT_set_color |
1841 WIN_FRAME_COLOR16 .63,.220,.2,.90 ; Top, Bottom, Left, Right | 1841 WIN_FRAME_COLOR16 .63,.220,.2,.90+.24 ; Top, Bottom, Left, Right (added .24 to the right as extra space needed for gas typ markings) |
1842 | 1842 |
1843 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | 1843 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
1844 display_details2_loop: | 1844 display_details2_loop: |
1845 btfsc switch_right | 1845 btfsc switch_right |
1846 goto logbook_page4 ; Show more info | 1846 goto logbook_page4 ; show more info |
1847 btfsc switch_left | 1847 btfsc switch_left |
1848 bra exit_profileview ; back to list | 1848 bra exit_profileview ; back to list |
1849 rcall log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second | 1849 rcall log_screendump_and_onesecond ; check if we need to make a screen shot and check for new second |
1850 btfsc sleepmode ; Timeout? | 1850 btfsc sleepmode ; timeout? |
1851 bra exit_profileview ; back to list | 1851 bra exit_profileview ; back to list |
1852 bra display_details2_loop ; wait for something to do | 1852 bra display_details2_loop ; wait for something to do |
1853 | 1853 |
1854 logbook_page4: ; Show even more info in CC mode | 1854 logbook_page4: ; show even more info in CC mode |
1855 LOG_POINT_TO log_divemode | 1855 LOG_POINT_TO log_divemode |
1856 call ext_flash_byte_read ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into WREG and ext_flash_rw | 1856 call ext_flash_byte_read ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into WREG and ext_flash_rw |
1857 decfsz ext_flash_rw,w ; =1 (CC)? | 1857 decfsz ext_flash_rw,w ; =1 (CC)? |
1858 goto display_profile2 ; no | 1858 goto display_profile2 ; no |
1859 | 1859 |
1860 rcall log_details_header ; Shows number, time/date and basic dive info | 1860 rcall log_details_header ; shows number, time/date and basic dive info |
1861 ; Setpoint list | 1861 ; Setpoint list |
1862 LOG_POINT_TO log_sp1 | 1862 LOG_POINT_TO log_sp1 |
1863 WIN_SMALL .5,.65 | 1863 WIN_SMALL .5,.65 |
1864 WIN_COLOR color_greenish | 1864 WIN_COLOR color_greenish |
1865 STRCPY_TEXT_PRINT tFixedSetpoints | 1865 STRCPY_TEXT_PRINT tFixedSetpoints |
1877 | 1877 |
1878 movlw color_greenish | 1878 movlw color_greenish |
1879 call TFT_set_color | 1879 call TFT_set_color |
1880 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; Top, Bottom, Left, Right | 1880 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; Top, Bottom, Left, Right |
1881 | 1881 |
1882 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | 1882 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
1883 display_details3_loop: | 1883 display_details3_loop: |
1884 btfsc switch_right | 1884 btfsc switch_right |
1885 goto display_profile2 ; Show the profile view again | 1885 goto display_profile2 ; show the profile view again |
1886 btfsc switch_left | 1886 btfsc switch_left |
1887 bra exit_profileview ; back to list | 1887 bra exit_profileview ; back to list |
1888 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | 1888 rcall log_screendump_and_onesecond ; check if we need to make a screenshot and check for new second |
1889 btfsc sleepmode ; Timeout? | 1889 btfsc sleepmode ; timeout? |
1890 bra exit_profileview ; back to list | 1890 bra exit_profileview ; back to list |
1891 bra display_details3_loop ; wait for something to do | 1891 bra display_details3_loop ; wait for something to do |
1892 | 1892 |
1893 | 1893 |
1894 log_details_header: | 1894 log_details_header: |
1895 clrf CCP1CON ; stop PWM | 1895 clrf CCP1CON ; stop PWM |
1896 bcf PORTC,2 ; Pull PWM out to GND | 1896 bcf PORTC,2 ; Pull PWM out to GND |
1897 call TFT_boot | 1897 call TFT_boot |
1898 ; call TFT_ClearScreen ; Clear screen | 1898 ; call TFT_ClearScreen ; clear screen |
1899 | 1899 |
1900 ; Set ext_flash pointer to "#divenumber-oldest" dive | 1900 ; Set ext_flash pointer to "#divenumber-oldest" dive |
1901 ; compute read_int_eeprom .2 - divenumber | 1901 ; compute read_int_eeprom .2 - divenumber |
1902 ; Read required header data for profile display | 1902 ; read required header data for profile display |
1903 ; look in header for pointer to begin of diveprofile (Byte 2-4) | 1903 ; look in header for pointer to begin of diveprofile (Byte 2-4) |
1904 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing | 1904 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing |
1905 | 1905 |
1906 decf divenumber,F ;-1 | 1906 decf divenumber,F ;-1 |
1907 read_int_eeprom .2 | 1907 read_int_eeprom .2 |
1908 movf EEDATA,W | 1908 movf EEDATA,W |
1909 bcf STATUS,C | 1909 bcf STATUS,C |
1910 subfwb divenumber,W ; max. dives (low value) - divenumber | 1910 subfwb divenumber,W ; max. dives (low value) - dive number |
1911 movwf lo ; result | 1911 movwf lo ; result |
1912 incf divenumber,F ;+1 | 1912 incf divenumber,F ; +1 |
1913 ; Set ext_flash_address:3 to TOC entry of this dive | 1913 ; Set ext_flash_address:3 to TOC entry of this dive |
1914 ; 1st: 200000h-200FFFh -> lo=0 | 1914 ; 1st: 200000h-200FFFh -> lo=0 |
1915 ; 2nd: 201000h-201FFFh -> lo=1 | 1915 ; 2nd: 201000h-201FFFh -> lo=1 |
1916 ; 3rd: 202000h-202FFFh -> lo=2 | 1916 ; 3rd: 202000h-202FFFh -> lo=2 |
1917 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | 1917 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) |
1989 output_99x ; divetime seconds | 1989 output_99x ; divetime seconds |
1990 call TFT_standard_color | 1990 call TFT_standard_color |
1991 STRCAT_PRINT "s" | 1991 STRCAT_PRINT "s" |
1992 ; ; Dive mode | 1992 ; ; Dive mode |
1993 ; LOG_POINT_TO log_divemode | 1993 ; LOG_POINT_TO log_divemode |
1994 ; call ext_flash_byte_read_plus ; Read divemode | 1994 ; call ext_flash_byte_read_plus ; read divemode |
1995 ; movff ext_flash_rw,lo | 1995 ; movff ext_flash_rw,lo |
1996 ; call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) | 1996 ; call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) |
1997 return | 1997 return |
1998 | 1998 |
1999 ; ---------------------------------------------------------------- | |
1999 | 2000 |
2000 log_show_sp: | 2001 log_show_sp: |
2001 lfsr FSR2,buffer | 2002 lfsr FSR2,buffer |
2002 call ext_flash_byte_read_plus ; Read setpoint | 2003 call ext_flash_byte_read_plus ; read setpoint |
2003 movff ext_flash_rw,lo | 2004 movff ext_flash_rw,lo |
2004 clrf hi | 2005 clrf hi |
2005 bsf leftbind | 2006 bsf leftbind |
2006 output_16dp d'3' | 2007 output_16dp d'3' |
2007 bcf leftbind | 2008 bcf leftbind |
2015 movf lo,W | 2016 movf lo,W |
2016 mullw .100 ; convert meters to mbar | 2017 mullw .100 ; convert meters to mbar |
2017 movff PRODL,lo | 2018 movff PRODL,lo |
2018 movff PRODH,hi | 2019 movff PRODH,hi |
2019 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | 2020 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
2020 output_16 | 2021 output_16_3 |
2022 PUTC " " | |
2021 STRCAT_TEXT tFeets ; "ft" | 2023 STRCAT_TEXT tFeets ; "ft" |
2022 bra log_show_sp_common | 2024 bra log_show_sp_common |
2023 log_show_sp_metric: | 2025 log_show_sp_metric: |
2024 output_8 | 2026 output_8 |
2027 PUTC " " | |
2025 STRCAT_TEXT tMeters ; "m" | 2028 STRCAT_TEXT tMeters ; "m" |
2026 log_show_sp_common: | 2029 log_show_sp_common: |
2027 STRCAT_PRINT "" | 2030 STRCAT_PRINT "" |
2028 return | 2031 return |
2029 | 2032 |
2035 movff ext_flash_rw,lo | 2038 movff ext_flash_rw,lo |
2036 call ext_flash_byte_read_plus ; read gas He fraction | 2039 call ext_flash_byte_read_plus ; read gas He fraction |
2037 movff ext_flash_rw,hi | 2040 movff ext_flash_rw,hi |
2038 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | 2041 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 |
2039 call ext_flash_byte_read_plus ; read change depth | 2042 call ext_flash_byte_read_plus ; read change depth |
2043 movff ext_flash_rw,up | |
2044 call ext_flash_byte_read_plus ; read gas type - just to increment the pointer | |
2045 movff ext_flash_rw,ex | |
2040 | 2046 |
2041 btfsc log_show_gas_short ; shall we do the short version? | 2047 btfsc log_show_gas_short ; shall we do the short version? |
2042 bra log_show_gas_common ; YES | 2048 bra log_show_gas_common ; YES |
2043 ; long version | 2049 ; NO - do the long version |
2044 movff ext_flash_rw,lo ; process change depth | 2050 PUTC " " ; put one space between gas composition and gas type marking |
2051 tstfsz ex ; gas disabled? | |
2052 bra log_show_gas_1 ; NO - next check | |
2053 PUTC "x" ; YES - mark with "x" | |
2054 bra log_show_gas_4 ; - continue with change depth | |
2055 log_show_gas_1: | |
2056 decfsz ex,F ; now: -1 disabled, 0 first, 1 travel, 2 deco -> first? | |
2057 bra log_show_gas_2 ; NO - next check | |
2058 PUTC "*" ; YES - mark with "*" | |
2059 bra log_show_gas_4 ; - continue with change depth | |
2060 log_show_gas_2: | |
2061 decf ex,F ; now: -2 disabled, -1 first, 0 travel, 1 deco | |
2062 decfsz ex,F ; now: -3 disabled, -2 first, -1 travel, 0 deco -> deco? | |
2063 bra log_show_gas_3 ; NO - nothing to mark | |
2064 PUTC "=" ; YES - mark with "=" | |
2065 bra log_show_gas_4 ; - continue with change depth | |
2066 log_show_gas_3: | |
2067 PUTC " " ; print a space in absence of any other marking | |
2068 log_show_gas_4: | |
2069 PUTC " " ; put one space between gas type marking and change depth | |
2045 TSTOSS opt_units ; 0=Meter, 1=Feet | 2070 TSTOSS opt_units ; 0=Meter, 1=Feet |
2046 bra log_show_gas_metric | 2071 bra log_show_gas_metric |
2047 movf lo,W | 2072 movf up,W |
2048 mullw .100 ; convert meters to mbar | 2073 mullw .100 ; convert meters to mbar |
2049 movff PRODL,lo | 2074 movff PRODL,lo |
2050 movff PRODH,hi | 2075 movff PRODH,hi |
2051 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | 2076 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
2052 output_16 | 2077 output_16_3 ; limit to 999 and display only 0-999 |
2053 STRCAT_TEXT tFeets ; "ft" | 2078 STRCAT_TEXT tFeets ; "ft" |
2054 bra log_show_gas_common | 2079 bra log_show_gas_common |
2055 log_show_gas_metric: | 2080 log_show_gas_metric: |
2081 movff up,lo | |
2056 output_8 | 2082 output_8 |
2057 STRCAT_TEXT tMeters ; "m" | 2083 STRCAT_TEXT tMeters ; "m" |
2058 log_show_gas_common: | 2084 log_show_gas_common: |
2059 call ext_flash_byte_read_plus ; read gas type - just to increment the pointer | |
2060 STRCAT_PRINT "" | 2085 STRCAT_PRINT "" |
2061 return | 2086 return |
2062 | 2087 |
2088 ; ---------------------------------------------------------------- | |
2089 | |
2063 END | 2090 END |