comparison src/logbook.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents cd986267a5ca
children cd58f7fc86db
comparison
equal deleted inserted replaced
622:02d1386429a6 623:c40025d8e750
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File logbook.asm REFACTORED VERSION V2.99e 3 ; File logbook.asm combined next generation V3.03.4
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 ;=============================================================================
19 #include "strings.inc" 19 #include "strings.inc"
20 #include "convert.inc" 20 #include "convert.inc"
21 #include "tft_outputs.inc" 21 #include "tft_outputs.inc"
22 #include "eeprom_rs232.inc" 22 #include "eeprom_rs232.inc"
23 #include "menu_processor.inc" 23 #include "menu_processor.inc"
24 #include "wait.inc"
25 #include "start.inc" 24 #include "start.inc"
26 #include "surfmode.inc" 25 #include "surfmode.inc"
27 #include "divemode.inc" 26 #include "divemode.inc"
28 #include "ghostwriter.inc" 27 #include "ghostwriter.inc"
29 28
30 extern do_main_menu2 29 extern do_main_menu2
31 extern comm_mode 30 extern gaslist_show_mix
32 extern customview_show_mix
33 31
34 32
35 ;---- Private local variables ------------------------------------------------- 33 ;---- Private local variables -------------------------------------------------
36 34
37 CBLOCK local1 ; max size is 16 byte !!! 35 CBLOCK local1 ; max size is 16 byte !!!
38 count_temperature ; current sample count for temperature divisor 36 count_temperature ; current sample count for temperature divisor
39 count_deco ; current sample count for deco (ceiling) divisor 37 count_deco ; current sample count for deco (ceiling) divisor
40 logbook_cur_depth:2 ; current depth, for drawing profile. 38 logbook_cur_depth:2 ; current depth, for drawing profile
41 logbook_cur_tp:2 ; current temperature, for drawing profile. 39 logbook_cur_tp:2 ; current temperature, for drawing profile
42 logbook_last_tp ; Y of the last item in Tp° curve. 40 logbook_last_tp ; Y of the last item in Tp° curve
43 logbook_min_tp:2 ; min temperature, for drawing profile. 41 logbook_min_tp:2 ; min temperature, for drawing profile
44 logbook_max_tp:2 ; maximum temperature, for drawing profile. 42 logbook_max_tp:2 ; maximum temperature, for drawing profile
45 logbook_ceiling ; current ceiling, for drawing profile. 43 logbook_ceiling ; current ceiling, for drawing profile
46 logbook_flags ; flags only used in logbook.asm 44 logbook_flags ; flags only used in logbook.asm
47 logbook_page_number ; page# in logbook 45 logbook_page_number ; page# in logbook
48 logbook_divenumber ; # of dive in list during search 46 logbook_divenumber ; # of dive in list during search
49 logbook_max_dive_counter ; counts dive# to zero 47 logbook_max_dive_counter ; counts dive# to zero
50 ENDC ; used: 16 byte, remaining: 0 byte => FULL 48 ENDC ; used: 16 byte, remaining: 0 byte => FULL
80 divisor_cns ; divisor used while sampling of the dive data 78 divisor_cns ; divisor used while sampling of the dive data
81 divisor_tank ; divisor used while sampling of the dive data 79 divisor_tank ; divisor used while sampling of the dive data
82 ENDC ; used: 16 byte, remaining: 0 byte => FULL 80 ENDC ; used: 16 byte, remaining: 0 byte => FULL
83 81
84 82
85 ; Remark: The variable gaslist_gas is "misused" here as a local variable, 83 ; Remarks: The variable gaslist_gas is "misused" here as a local variable,
86 ; because the storage space for local variables is fully used up. 84 ; because the storage space for local variables is fully used up.
87 85 ;
86 ; This code includes decoding and displaying of log data for Trimix
87 ; and CCR/pSCR dives to make sure that if such dives are in the
88 ; logbook they will be displayed correctly.
88 89
89 ;---- Defines ---------------------------------------------------------------- 90 ;---- Defines ----------------------------------------------------------------
90 91
91 ; Flags 92 ; Flags
92 #DEFINE return_from_profileview logbook_flags,0 93 #DEFINE return_from_profileview logbook_flags,0
98 #DEFINE log_show_gas_short logbook_flags,6 99 #DEFINE log_show_gas_short logbook_flags,6
99 ; logbook_flags,7 ; unused 100 ; logbook_flags,7 ; unused
100 101
101 ; Logbook Coordinates 102 ; Logbook Coordinates
102 #DEFINE logbook_list_left .10 ; column of dive# in list 103 #DEFINE logbook_list_left .10 ; column of dive# in list
103 #DEFINE logbook_row_offset .28 ; distance between rows of list 104 #DEFINE logbook_row_offset .28 ; distance between rows of list (needs to be <= 32)
104 #DEFINE logbook_row_number .6 ; amount of rows in the list 105 #DEFINE logbook_row_number .6 ; amount of rows in the list
105 106
106 ; Profile display 107 ; Profile display
107 #DEFINE profile_height_pixels .157 ; amount of pixels height for profile display 108 #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 109 #DEFINE profile_width_pixels .156 ; amount of pixels width for profile display
114 #DEFINE logbook_bailout_row .207 115 #DEFINE logbook_bailout_row .207
115 116
116 ; Dive number 117 ; Dive number
117 #DEFINE logbook_divenumer_column .1 118 #DEFINE logbook_divenumer_column .1
118 #DEFINE logbook_divenumer_row .1 119 #DEFINE logbook_divenumer_row .1
120
119 ; Date and Time 121 ; Date and Time
120 #DEFINE logbook_date_column .100 122 #DEFINE logbook_date_column .100
121 #DEFINE logbook_date_row .7 123 #DEFINE logbook_date_row .7
122 #DEFINE logbook_time_column .120 124 #DEFINE logbook_time_column .120
123 #DEFINE logbook_time_row .38 125 #DEFINE logbook_time_row .38
126
124 ; Max. Depth 127 ; Max. Depth
125 #DEFINE log_max_value_row .38 128 #DEFINE log_max_value_row .38
126 #DEFINE log_max_value_column .1 129 #DEFINE log_max_value_column .1
130
127 ; Divetime 131 ; Divetime
128 #DEFINE log_divetime_value_row .38 132 #DEFINE log_divetime_value_row .38
129 #DEFINE log_divetime_value_column .60 133 #DEFINE log_divetime_value_column .60
134
130 ; Gaslist below profile 135 ; Gaslist below profile
131 #DEFINE log_gas_row .225 136 #DEFINE log_gas_row .225
132 #DEFINE log_gas_column1 .0 137 #DEFINE log_gas_column1 .0
133 #DEFINE log_gas_column2 log_gas_column1+(.1*.32) 138 #DEFINE log_gas_column2 log_gas_column1+(.1*.32)
134 #DEFINE log_gas_column3 log_gas_column1+(.2*.32) 139 #DEFINE log_gas_column3 log_gas_column1+(.2*.32)
173 #DEFINE log2_battery_column log2_salinity_column 178 #DEFINE log2_battery_column log2_salinity_column
174 #DEFINE log2_divemode_row .8*.16+log2_salinity_row 179 #DEFINE log2_divemode_row .8*.16+log2_salinity_row
175 #DEFINE log2_divemode_column log2_salinity_column 180 #DEFINE log2_divemode_column log2_salinity_column
176 #DEFINE log2_lastdeco_row .9*.16+log2_salinity_row 181 #DEFINE log2_lastdeco_row .9*.16+log2_salinity_row
177 #DEFINE log2_lastdeco_column log2_salinity_column 182 #DEFINE log2_lastdeco_column log2_salinity_column
183
178 ; Air pressure 184 ; Air pressure
179 #DEFINE MBAR_row .10*.16+log2_salinity_row 185 #DEFINE MBAR_row .10*.16+log2_salinity_row
180 #DEFINE MBAR_column log2_salinity_column 186 #DEFINE MBAR_column log2_salinity_column
181 187
182 188
228 logbook CODE 234 logbook CODE
229 235
230 ;============================================================================= 236 ;=============================================================================
231 237
232 TFT_logbook_cursor: 238 TFT_logbook_cursor:
233 ; call speed_fastest
234 WIN_BOX_BLACK .0, .240-.16, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right 239 WIN_BOX_BLACK .0, .240-.16, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right
235 240
236 WIN_LEFT logbook_list_left-.8 241 WIN_LEFT logbook_list_left-.8 ; set horizontal position
237 WIN_FONT FT_SMALL 242 WIN_FONT FT_SMALL ; select small font
238 ; bcf win_invert ; reset invert flag 243 ; bcf win_invert ; reset invert flag
239 call TFT_standard_color 244 call TFT_standard_color ; print in white color
240 245 decf menu_pos_cur,W ; get row number -1 into WREG
241 movff menupos1,lo 246 mullw logbook_row_offset ; multiply with vertical offset between rows
242 dcfsnz lo,F 247 movff PRODL,win_top ; set vertical position
243 movlw d'0' 248 STRCPY_PRINT "\xB7" ; print cursor
244 dcfsnz lo,F 249 return ; done
245 movlw logbook_row_offset 250
246 dcfsnz lo,F
247 movlw .2*logbook_row_offset
248 dcfsnz lo,F
249 movlw .3*logbook_row_offset
250 dcfsnz lo,F
251 movlw .4*logbook_row_offset
252 dcfsnz lo,F
253 movlw .5*logbook_row_offset
254 dcfsnz lo,F
255 movlw .6*logbook_row_offset
256 dcfsnz lo,F
257 movlw .7*logbook_row_offset
258 dcfsnz lo,F
259 movlw .8*logbook_row_offset
260
261 movwf win_top
262 STRCPY_PRINT "\xB7"
263 return
264 251
265 global logbook ; entry point coming from menu_tree.asm 252 global logbook ; entry point coming from menu_tree.asm
266 logbook: 253 logbook:
267 clrf logbook_flags 254 clrf logbook_flags
268 clrf CCP1CON ; stop PWM
269 bcf PORTC,2 ; pull PWM out to GND
270 call TFT_boot 255 call TFT_boot
271 ; call TFT_standard_color 256 ; call TFT_standard_color
272 clrf menupos3 ; here: used rows on current logbook-page 257 clrf menu_pos_max ; number of used rows on current logbook-page
273 clrf logbook_page_number ; here: # of current displayed page 258 clrf logbook_page_number ; here: # of current displayed page
274 clrf logbook_divenumber ; # of dive in list during search 259 clrf logbook_divenumber ; # of dive in list during search
275 clrf logbook_temp 260 clrf logbook_temp
276 clrf logbook_temp_backup 261 clrf logbook_temp_backup
277 clrf timeout_counter2 ; for timeout
278 movlw logbook_row_number 262 movlw logbook_row_number
279 movwf menupos1 ; here: stores current position on display (logbook_row_number-x) 263 movwf menu_pos_cur ; number of current position on display (logbook_row_number-x)
280 read_int_eeprom .2 ; get low-byte of total dives 264 read_int_eeprom .2 ; get low-byte of total dives
281 movff EEDATA,logbook_max_dive_counter 265 movff EEDATA,logbook_max_dive_counter
282 266
283 ;----------------------------------------------------------------------------- 267 ;-----------------------------------------------------------------------------
284 ; display dive headers backwards from read_int_eeprom .2 = lo-1 268 ; display dive headers backwards from read_int_eeprom .2 = lo-1
290 ; a) no dive is stored (no valid header found) 274 ; a) no dive is stored (no valid header found)
291 ; b) current dive has no valid header (Number of stored dives < 256) 275 ; b) current dive has no valid header (Number of stored dives < 256)
292 ; c) when 255 dives are reached logbook_temp = 255 276 ; c) when 255 dives are reached logbook_temp = 255
293 277
294 logbook2: 278 logbook2:
295 ; call speed_fastest
296 incf logbook_temp,F ; increase dive counter 279 incf logbook_temp,F ; increase dive counter
297 incf logbook_temp,W ; = 0x..FF ? 280 incf logbook_temp,W ; = 0x..FF ?
298 bz logbook_reset ; YES - FF --> loop 281 bz logbook_reset ; YES - ..FF --> loop
299 282
300 ; Set ext_flash_address:3 to TOC entry of this dive 283 ; Set ext_flash_address:3 to TOC entry of this dive
301 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0 284 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0
302 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1 285 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1
303 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2 286 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2
320 call ext_flash_byte_read ; reads one byte@ext_flash_address:3 into WREG and ext_flash_rw 303 call ext_flash_byte_read ; reads one byte@ext_flash_address:3 into WREG and ext_flash_rw
321 movwf ext_flash_rw 304 movwf ext_flash_rw
322 movlw 0xFA 305 movlw 0xFA
323 cpfseq ext_flash_rw ; 0xFA found? 306 cpfseq ext_flash_rw ; 0xFA found?
324 bra logbook3b ; NO - abort 307 bra logbook3b ; NO - abort
325 308 incf logbook_divenumber,F ; YES - new header found, increase logbook_divenumber
326 incf logbook_divenumber,F ; new header found, increase logbook_divenumber 309 bra logbook4 ; - done with searching, display the header
327 bra logbook4 ; done with searching, display the header
328 310
329 logbook3b: 311 logbook3b:
330 btfss logbook_page_not_empty ; was there at least one dive? 312 btfss logbook_page_not_empty ; was there at least one dive?
331 bra exit_logbook ; not a single header was found, leave logbook 313 bra exit_logbook ; not a single header was found, leave logbook
332 bra logbook_display_loop2 314 bra logbook_display_loop2
341 bra logbook_display_loop2 ; continue 323 bra logbook_display_loop2 ; continue
342 324
343 logbook4: 325 logbook4:
344 btfsc all_dives_shown ; all dives displayed? 326 btfsc all_dives_shown ; all dives displayed?
345 bra logbook_display_loop2 ; YES - display first page again 327 bra logbook_display_loop2 ; YES - display first page again
346 328 call display_listdive ; NO - display short header for list on current list position
347 call display_listdive ; display short header for list on current list position 329 movlw logbook_row_number ; -
348 330 cpfseq menu_pos_cur ; - first dive on list (top row)?
349 movlw logbook_row_number 331 bra logbook_display_loop1 ; NO - skip saving of address
350 cpfseq menupos1 ; first dive on list (top place)?
351 bra logbook_display_loop1 ; NO - skip saving of address
352 332
353 ; store all registers required to rebuilt the current logbook page after the detail/profile view 333 ; 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 334 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 335 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 336 movff logbook_temp,logbook_temp_backup ; amount of dives drawn until now
357
358 337
359 logbook_display_loop1: 338 logbook_display_loop1:
360 decfsz menupos1,F ; list full? 339 decfsz menu_pos_cur,F ; list full?
361 bra logbook2 ; NO - search another dive for our current logbook page 340 bra logbook2 ; NO - search another dive for our current logbook page
362 341
363 logbook_display_loop2: 342 logbook_display_loop2:
364 btfss logbook_page_not_empty ; was there one dive at all? 343 btfss logbook_page_not_empty ; was there one dive at all?
365 bra logbook ; YES - so reload the first page 344 bra logbook ; YES - so reload the first page
374 STRCPY_TEXT_PRINT tExit ; "Exit" 353 STRCPY_TEXT_PRINT tExit ; "Exit"
375 354
376 movlw d'1' ; set cursor to position 1... 355 movlw d'1' ; set cursor to position 1...
377 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view 356 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view
378 movf logbook_menupos_temp,W ; load last cursor position again 357 movf logbook_menupos_temp,W ; load last cursor position again
379 movwf menupos1 ; and set menupos1 byte 358 movwf menu_pos_cur ; and set menu_pos_cur byte
380 bcf return_from_profileview ; do this only once while the page is loaded again 359 bcf return_from_profileview ; do this only once while the page is loaded again
381 360
382 bcf logbook_page_not_empty ; obviously the current page is NOT empty 361 bcf logbook_page_not_empty ; obviously the current page is NOT empty
383 362
384 movlw d'7' ; set cursor to position 7... 363 movlw d'7' ; set cursor to position 7...
385 btfsc keep_cursor_new_page ; ... if we came from the "new page" line 364 btfsc keep_cursor_new_page ; ... if we came from the "new page" line
386 movwf menupos1 ; and set menupos1 byte 365 movwf menu_pos_cur ; and set menu_pos_cur byte
387 bcf keep_cursor_new_page 366 bcf keep_cursor_new_page
388 367
389 call TFT_logbook_cursor ; show the cursor 368 call TFT_logbook_cursor ; show the cursor
390 369
391 call logbook_preloop_tasks ; clear some flags and set to Speed_eco 370 logbook_loop_pre:
392 call menu_processor_bottom_line ; show bottom line 371 call logbook_preloop_tasks ; clear timeout, some flags and switch on backlight
393
394 logbook_loop: 372 logbook_loop:
395 btfsc switch_left ; SET/MENU? 373 btfsc switch_left ; left button pressed?
396 goto next_logbook3 ; adjust cursor or create new page 374 goto next_logbook3 ; YES - adjust cursor or create new page
397 btfsc switch_right ; ENTER? 375 btfsc switch_right ; right button pressed?
398 bra display_profile_or_exit ; view details/profile or exit logbook 376 bra display_profile_or_exit ; YES - view details/profile or exit logbook
399 377 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode
400 rcall log_screendump_and_onesecond ; check if we need to make a screen-shot and check for new second 378 bra logbook_loop ; - loop waiting for something to do
401 btfsc sleepmode ; timeout?
402 bra exit_logbook ; YES
403 bra logbook_loop ; NO - wait for something to do
404 379
405 display_profile_or_exit: 380 display_profile_or_exit:
406 movlw logbook_row_number+.2 ; exit? 381 movlw logbook_row_number+.2 ; exit?
407 cpfseq menupos1 382 cpfseq menu_pos_cur ; YES
408 bra display_profile_or_exit2 ; NO - check for "Next Page" 383 bra display_profile_or_exit2 ; NO - check for "Next Page"
409 384
410 exit_logbook: 385 exit_logbook:
411 ; call TFT_DisplayOff 386 bcf switch_right ; clear pending button events
412 ; call TFT_boot 387 bcf switch_left ; ...
413 goto do_main_menu2 ; jump-back to menu_tree.asm 388 goto do_main_menu2 ; jump-back to menu_tree.asm
414 389
415 display_profile_or_exit2: 390 display_profile_or_exit2:
416 movlw logbook_row_number+.1 ; next page? 391 movlw logbook_row_number+.1 ;
417 cpfseq menupos1 392 cpfseq menu_pos_cur ; do next page?
418 bra display_profile ; NO - show details/profile 393 bra display_profile ; NO - show details/profile
419 goto next_logbook2 ; next page 394 goto next_logbook2 ; YES - next page
420 395
421 display_profile: 396 display_profile:
422 bcf FLAG_bailout_mode 397 bcf bailout_mode ; clear event flag
423 bcf gas6_changed ; clear event flags 398 bcf event_gas_change_gas6 ; clear event flag
424 ; call speed_fastest 399 movff menu_pos_cur,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 400 bsf return_from_profileview ; tweak search routine to exit after found
427 401
428 movf logbook_page_number,W ; number of page 402 movf logbook_page_number,W ; number of page
429 mullw logbook_row_number 403 mullw logbook_row_number
430 movf PRODL,W 404 movf PRODL,W
431 addwf menupos1,W ; page * logbook_row_number + menupos1 = 405 addwf menu_pos_cur,W ; page * logbook_row_number + menu_pos_cur =
432 movwf divenumber ; # of dive to show 406 movwf divenumber ; # of dive to show
433 407
434 display_profile2: 408 display_profile2:
435 ; call speed_fastest
436 clrf CCP1CON ; stop PWM
437 bcf PORTC,2 ; pull PWM out to GND
438 call TFT_boot 409 call TFT_boot
439 ; call TFT_ClearScreen ; clear screen 410
440 ; set ext_flash pointer to "#divenumber-oldest" dive 411 ; set ext_flash pointer to "#divenumber-oldest" dive
441 ; compute read_int_eeprom .2 - divenumber 412 ; compute read_int_eeprom .2 - divenumber
442 ; read required header data for profile display 413 ; read required header data for profile display
443 ; look in header for pointer to begin of dive profile (Byte 2-4) 414 ; 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 415 ; set pointer (ext_flash_log_pointer:3) to this address, start drawing
445 416
446 decf divenumber,F ;-1 417 decf divenumber,F ; -1
447 read_int_eeprom .2 418 read_int_eeprom .2
448 movf EEDATA,W 419 movf EEDATA,W
449 bcf STATUS,C 420 bcf STATUS,C
450 subfwb divenumber,W ; max. dives (low value) - divenumber 421 subfwb divenumber,W ; max. dives (low value) - dive number
451 movwf lo ; result 422 movwf lo ; result
452 incf divenumber,F ;+1 423 incf divenumber,F ; +1
453 ; Set ext_flash_address:3 to TOC entry of this dive 424 ; Set ext_flash_address:3 to TOC entry of this dive
454 ; 1st: 200000h-200FFFh -> lo=0 425 ; 1st: 200000h-200FFFh -> lo=0
455 ; 2nd: 201000h-201FFFh -> lo=1 426 ; 2nd: 201000h-201FFFh -> lo=1
456 ; 3rd: 202000h-202FFFh -> lo=2 427 ; 3rd: 202000h-202FFFh -> lo=2
457 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) 428 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
468 ; pointer at the first 0xFA of header 439 ; pointer at the first 0xFA of header
469 440
470 ; Now, show profile 441 ; Now, show profile
471 LOG_POINT_TO log_samplingrate 442 LOG_POINT_TO log_samplingrate
472 call ext_flash_byte_read ; read sampling rate 443 call ext_flash_byte_read ; read sampling rate
473 movff ext_flash_rw,samplesecs_value ; needed later... 444 movff ext_flash_rw,sampling_rate ; store for later use
474 445
475 LOG_POINT_TO .2 446 LOG_POINT_TO .2
476 call ext_flash_byte_read_plus ; read start address of profile 447 call ext_flash_byte_read_plus ; read start address of profile
477 movff ext_flash_rw,ext_flash_log_pointer+0 448 movff ext_flash_rw,ext_flash_log_pointer+0
478 call ext_flash_byte_read_plus ; read start address of profile 449 call ext_flash_byte_read_plus ; read start address of profile
479 movff ext_flash_rw,ext_flash_log_pointer+1 450 movff ext_flash_rw,ext_flash_log_pointer+1
480 call ext_flash_byte_read_plus ; read start address of profile 451 call ext_flash_byte_read_plus ; read start address of profile
481 movff ext_flash_rw,ext_flash_log_pointer+2 452 movff ext_flash_rw,ext_flash_log_pointer+2
482 453
483 clrf logbook_sample_counter+0 454 CLRI logbook_sample_counter ; holds amount of read samples
484 clrf logbook_sample_counter+1 ; holds amount of read samples
485 455
486 call TFT_standard_color 456 call TFT_standard_color
487 call logbook_show_divenumber ; show the dive number in medium font 457 call logbook_show_divenumber ; show the dive number in medium font
488 458
489 WIN_SMALL logbook_date_column, logbook_date_row 459 WIN_SMALL logbook_date_column, logbook_date_row
499 469
500 WIN_SMALL log_divetime_value_column,logbook_date_row ; align with surrounding data 470 WIN_SMALL log_divetime_value_column,logbook_date_row ; align with surrounding data
501 LOG_POINT_TO log_divemode 471 LOG_POINT_TO log_divemode
502 call ext_flash_byte_read_plus ; read dive mode 472 call ext_flash_byte_read_plus ; read dive mode
503 movff ext_flash_rw,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR 473 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, Gauge, Apnea or pSCR) 474 call TFT_decotype_logbook ; "strcat_print"s dive mode (OC, CC, Gauge, Apnea or pSCR)
475 ; also sets aux_flag in case the dive was done in a deco mode
505 476
506 WIN_SMALL logbook_time_column, logbook_time_row 477 WIN_SMALL logbook_time_column, logbook_time_row
507 LOG_POINT_TO log_time 478 LOG_POINT_TO log_time
508 call ext_flash_byte_read_plus ; hour 479 call ext_flash_byte_read_plus ; hour
509 movff ext_flash_rw,lo 480 movff ext_flash_rw,lo
513 PUTC ':' 484 PUTC ':'
514 movff hi,lo 485 movff hi,lo
515 output_99x ; minute 486 output_99x ; minute
516 STRCAT_PRINT "" ; display 1st row of details 487 STRCAT_PRINT "" ; display 1st row of details
517 488
518 LOG_POINT_TO log_profile_version 489 LOG_POINT_TO log_profile_version
519 call ext_flash_byte_read_plus ; profile version 490 call ext_flash_byte_read_plus ; profile version
520 movlw 0x24 491 movlw 0x24
521 cpfslt ext_flash_rw ; < 0x24 ? 492 cpfslt ext_flash_rw ; < 0x24 ?
522 bra log_skip_extra_icon ; YES - skip 493 bra log_skip_extra_icon ; YES - skip
523 494
528 LOG_POINT_TO log_max_depth 499 LOG_POINT_TO log_max_depth
529 call ext_flash_byte_read_plus ; read max depth 500 call ext_flash_byte_read_plus ; read max depth
530 movff ext_flash_rw,lo 501 movff ext_flash_rw,lo
531 call ext_flash_byte_read_plus ; read max depth 502 call ext_flash_byte_read_plus ; read max depth
532 movff ext_flash_rw,hi 503 movff ext_flash_rw,hi
533 movff lo,xA+0 ; calculate y-scale for profile display 504 MOVII mpr,xA ; calculate y-scale for profile display
534 movff hi,xA+1 505 MOVLI profile_height_pixels,xB ; pixel height available for profile
535 movlw profile_height_pixels ; pixel height available for profile
536 movwf xB+0
537 clrf xB+1
538 call div16x16 ; xC = xA / xB with xA as remainder 506 call div16x16 ; xC = xA / xB with xA as remainder
539 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!) 507 MOVII xC,y_scale ; y-scale (mbar/pixel)
540 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!) 508 INCI y_scale ; 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
543 509
544 movlw LOW ((profile_height_pixels+1)*.1000) 510 movlw LOW ((profile_height_pixels+1)*.1000)
545 movwf xC+0 511 movwf xC+0
546 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF') 512 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF')
547 movwf xC+1 513 movwf xC+1
548 movlw UPPER ((profile_height_pixels+1)*.1000) 514 movlw UPPER ((profile_height_pixels+1)*.1000)
549 movwf xC+2 515 movwf xC+2
550 clrf xC+3 516 clrf xC+3
551 517
552 movff lo,xB+0 ; max. Depth in mbar 518 MOVII mpr,xB ; max. Depth in mbar
553 movff hi,xB+1 ; max. Depth in mbar 519 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
554 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder 520 MOVII xC,x_scale ; Pixels/10m (for scale, draw any xx rows a scale-line)
555
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)
558 521
559 movf x_scale+0,W 522 movf x_scale+0,W
560 iorwf x_scale+1,W ; x_scale:2 = Null ? 523 iorwf x_scale+1,W ; x_scale:2 = zero ?
561 bnz display_profile_offset4 ; NO - continue 524 bnz display_profile_offset4 ; NO - continue
562 incf x_scale+1,F ; YES - make x_scale+1>1 to make "display_profile2e" working 525 incf x_scale+1,F ; YES - make x_scale+1>1 to make "display_profile2e" working
563 526
564 display_profile_offset4: 527 display_profile_offset4:
565 WIN_SMALL log_max_value_column,log_max_value_row 528 WIN_SMALL log_max_value_column,log_max_value_row
566 529
567 TSTOSS opt_units ; 0=Meters, 1=Feets 530 TSTOSS opt_units ; 0=Meters, 1=Feets
568 bra display_profile_offset4_metric 531 bra display_profile_offset4_metric ; 0 - do metric
569 ; display_profile_offset4_imperial: 532 ; 1 - do imperial
570 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 533 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
571 PUTC ' ' 534 PUTC ' '
572 bcf leftbind 535 bcf leftbind
573 output_16_3 ; limit to 999 and display only (0-999) 536 output_16_3 ; limit to 999 and display only (0-999)
574 STRCAT_TEXT_PRINT tFeets 537 STRCAT_TEXT_PRINT tFeets
578 bsf leftbind 541 bsf leftbind
579 output_16dp d'3' ; max. depth 542 output_16dp d'3' ; max. depth
580 STRCAT_TEXT_PRINT tMeters 543 STRCAT_TEXT_PRINT tMeters
581 544
582 display_profile_offset4_common: 545 display_profile_offset4_common:
583 call ext_flash_byte_read_plus ; divetime in minutes 546 call ext_flash_byte_read_plus ; dive time in minutes
584 movff ext_flash_rw,lo 547 movff ext_flash_rw,lo
585 call ext_flash_byte_read_plus 548 call ext_flash_byte_read_plus
586 movff ext_flash_rw,hi ; divetime in minutes 549 movff ext_flash_rw,hi ; dive time in minutes
587 550
588 movff lo,xA+0 ; calculate x-scale for profile display 551 MOVII mpr,xA ; calculate x-scale for profile display, calculate total dive seconds first
589 movff hi,xA+1 ; calculate total diveseconds first 552 MOVLI .60,xB ; 60 seconds are one minute
590 movlw d'60' ; 60 seconds are one minute 553 call mult16x16 ; result is in xC:2
591 movwf xB+0
592 clrf xB+1
593 call mult16x16 ; result is in xC:2 !
594 554
595 WIN_SMALL log_divetime_value_column,log_divetime_value_row 555 WIN_SMALL log_divetime_value_column,log_divetime_value_row
596 bsf leftbind 556 bsf leftbind
597 output_16 ; divetime minutes 557 output_16 ; dive time minutes
598 movlw LOW d'600' 558 MOVLI .600,xA ; a vertical line every 600 seconds
599 movwf xA+0 559 movff sampling_rate,xB+0 ; copy sampling rate to xB, low byte
600 movlw HIGH d'600' 560 clrf xB+1 ; clear xB, high byte
601 movwf xA+1 ; a vertical line every 600 seconds
602 movff samplesecs_value,xB+0 ; copy sampling rate
603 clrf xB+1
604 call div16x16 ; xA/xB=xC with xA as remainder 561 call div16x16 ; xA/xB=xC with xA as remainder
605 movff xC+0,vertical_interval+0 562 MOVII xC,vertical_interval ; vertical_interval:2 holds interval of samples for vertical 10min line
606 movff xC+1,vertical_interval+1 563
607 ; vertical_interval:2 holds interval of samples for vertical 10min line 564 ; Restore dive time in minutes:
608
609 ; Restore divetime in minutes:
610 ; get real sample time 565 ; get real sample time
611 LOG_POINT_TO log_total_seconds 566 LOG_POINT_TO log_total_seconds
612 call ext_flash_byte_read_plus ; total sample time in seconds 567 call ext_flash_byte_read_plus ; total sample time in seconds
613 movff ext_flash_rw,xC+0 568 movff ext_flash_rw,xC+0
614 call ext_flash_byte_read_plus ; total sample time in seconds 569 call ext_flash_byte_read_plus ; total sample time in seconds
615 movff ext_flash_rw,xC+1 570 movff ext_flash_rw,xC+1
616 571
617 PUTC ':' 572 PUTC ':'
618 LOG_POINT_TO log_divetime+.2 573 LOG_POINT_TO log_divetime+.2
619 call ext_flash_byte_read_plus ; read divetime seconds 574 call ext_flash_byte_read_plus ; read dive time seconds
620 movff ext_flash_rw,lo 575 movff ext_flash_rw,lo
621 movff xC+0,xA+0 ; now calculate x-scale value 576 MOVII xC,xA ; now calculate x-scale value
622 movff xC+1,xA+1 577 MOVLI profile_width_pixels,xB ; pix width available
623 movlw profile_width_pixels ; pix width available
624 movwf xB+0
625 clrf xB+1
626 call div16x16 ; xC = xA / xB with xA as remainder 578 call div16x16 ; xC = xA / xB with xA as remainder
627 movff xC+0,xA+0 579 MOVII xC,xA
628 movff xC+1,xA+1 580 movff sampling_rate,xB+0 ; divide through sampling rate (time interval)
629 movf samplesecs_value,W ; divide through sample interval 581 clrf xB+1
630 movwf xB+0
631 clrf xB+1
632 call div16x16 ; xC = xA / xB with xA as remainder 582 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 583 MOVII xC,profile_temp1 ; 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 584 INCI profile_temp1 ; 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
637 585
638 bsf leftbind 586 bsf leftbind
639 output_99x ; divetime seconds 587 output_99x ; dive time seconds
640 call TFT_standard_color 588 call TFT_standard_color
641 STRCAT_PRINT "" 589 STRCAT_PRINT ""
642 590
643 call ext_flash_byte_read_plus ; read min. temperature 591 call ext_flash_byte_read_plus ; read min. temperature, low byte
644 movff ext_flash_rw,logbook_min_tp+0 592 movff ext_flash_rw,logbook_min_tp+0
645 call ext_flash_byte_read_plus ; read min. temperature 593 call ext_flash_byte_read_plus ; read min. temperature, high byte
646 movff ext_flash_rw,logbook_min_tp+1 594 movff ext_flash_rw,logbook_min_tp+1
647 595
648 ; Set pointer to Gas 1 Type. 596 btfss aux_flag ; dive done in a deco mode?
649 LOG_POINT_TO log_gas1+.3 597 bra logbook_set_gas_color ; NO - always use gas 1 color (white) then
598
599 ; Set pointer to gas 1 type
600 LOG_POINT_TO log_gas1+.3
650 call ext_flash_byte_read_plus ; read gas type 601 call ext_flash_byte_read_plus ; read gas type
651 decfsz ext_flash_rw,W ; = 1 (= "First") ? 602 decfsz ext_flash_rw,W ; = 1 (= "First") ?
652 bra logbook_find_first_gas2 ; NO 603 bra logbook_find_first_gas2 ; NO
653 movlw .1 604 logbook_set_gas_color:
605 movlw .1 ; YES - select white color
654 movwf ext_flash_rw 606 movwf ext_flash_rw
655 bra logbook_find_first_gas_done 607 bra logbook_find_first_gas_done
656 logbook_find_first_gas2: 608 logbook_find_first_gas2:
657 ; Set pointer to Gas 2 Type. 609 ; Set pointer to gas 2 type
658 LOG_POINT_TO log_gas2+.3 610 LOG_POINT_TO log_gas2+.3
659 call ext_flash_byte_read_plus ; read gas type 611 call ext_flash_byte_read_plus ; read gas type
660 decfsz ext_flash_rw,W ; = 1 (= "First") ? 612 decfsz ext_flash_rw,W ; = 1 (= "First") ?
661 bra logbook_find_first_gas3 ; NO 613 bra logbook_find_first_gas3 ; NO
662 movlw .2 614 movlw .2 ; YES - select green color
663 movwf ext_flash_rw 615 movwf ext_flash_rw
664 bra logbook_find_first_gas_done 616 bra logbook_find_first_gas_done
665 logbook_find_first_gas3: 617 logbook_find_first_gas3:
666 ; Set pointer to Gas 3 Type. 618 ; Set pointer to gas 3 type
667 LOG_POINT_TO log_gas3+.3 619 LOG_POINT_TO log_gas3+.3
668 call ext_flash_byte_read_plus ; read gas type 620 call ext_flash_byte_read_plus ; read gas type
669 decfsz ext_flash_rw,W ; = 1 (= "First") ? 621 decfsz ext_flash_rw,W ; = 1 (= "First") ?
670 bra logbook_find_first_gas4 ; NO 622 bra logbook_find_first_gas4 ; NO
671 movlw .3 623 movlw .3 ; YES - select red color
672 movwf ext_flash_rw 624 movwf ext_flash_rw
673 bra logbook_find_first_gas_done 625 bra logbook_find_first_gas_done
674 logbook_find_first_gas4: 626 logbook_find_first_gas4:
675 ; Set pointer to Gas 4 Type. 627 ; Set pointer to gas 4 type
676 LOG_POINT_TO log_gas4+.3 628 LOG_POINT_TO log_gas4+.3
677 call ext_flash_byte_read_plus ; read gas type 629 call ext_flash_byte_read_plus ; read gas type
678 decfsz ext_flash_rw,W ; = 1 (= "First") ? 630 decfsz ext_flash_rw,W ; = 1 (= "First") ?
679 bra logbook_find_first_gas5 ; NO 631 bra logbook_find_first_gas5 ; NO
680 movlw .4 632 movlw .4 ; YES - select yellow color
681 movwf ext_flash_rw 633 movwf ext_flash_rw
682 bra logbook_find_first_gas_done 634 bra logbook_find_first_gas_done
683 logbook_find_first_gas5: 635 logbook_find_first_gas5:
684 movlw .5 ; must be Gas 5 636 movlw .5 ; must be gas 5, select cyan color
685 movwf ext_flash_rw 637 movwf ext_flash_rw
686 logbook_find_first_gas_done: 638 logbook_find_first_gas_done:
687 movff ext_flash_rw,backup_color1 ; keep copy to restore color 639 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 640 movff ext_flash_rw,WREG ; copy gas number to WREG for color coding
689 call TFT_color_code_gas ; back to normal profile color 641 call TFT_color_code_gas ; set color
690 ; Pointer is now trashed! 642 ; Pointer is now trashed!
691 643
692 ; Point to profile portion of this dive 644 ; Point to profile portion of this dive
693 movff ext_flash_log_pointer+0,ext_flash_address+0 645 movff ext_flash_log_pointer+0,ext_flash_address+0
694 movff ext_flash_log_pointer+1,ext_flash_address+1 646 movff ext_flash_log_pointer+1,ext_flash_address+1
792 movlw profile_width_pixels+profile_left-.1 744 movlw profile_width_pixels+profile_left-.1
793 movwf ignore_digits ; here: used as counter for x-pixels 745 movwf ignore_digits ; here: used as counter for x-pixels
794 bcf end_of_profile ; clear flag 746 bcf end_of_profile ; clear flag
795 747
796 movlw profile_left+.1 748 movlw profile_left+.1
797 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5) 749 movwf logbook_pixel_x_pos ; here: used as column x2 (start at column 5)
798 750
799 movlw profile_top+.1 ; zero-m row 751 movlw profile_top+.1 ; zero-m row
800 movwf fill_between_rows 752 movwf fill_between_rows
801 movwf logbook_last_tp ; initialize for Tp° curve, too 753 movwf logbook_last_tp ; initialize for Tp° curve, too
802 754
808 setf logbook_cur_tp+0 ; initialize Tp°, before the first recorded point 760 setf logbook_cur_tp+0 ; initialize Tp°, before the first recorded point
809 setf logbook_cur_tp+1 761 setf logbook_cur_tp+1
810 clrf logbook_last_tp ; also reset previous Y for Tp° 762 clrf logbook_last_tp ; also reset previous Y for Tp°
811 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling 763 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling
812 movlw profile_top+.1 764 movlw profile_top+.1
813 movwf logbook_min_temp_pos ; initialize for displaying the lowest temperature 765 movwf logbook_min_temp_pos ; initialize for displaying the lowest temperature
814 movlw profile_top+profile_height_pixels 766 movlw profile_top+profile_height_pixels
815 movwf logbook_max_temp_pos ; initialize for displaying the highest temperature 767 movwf logbook_max_temp_pos ; initialize for displaying the highest temperature
816 768
817 movlw profile_left 769 movlw profile_left
818 movwf win_leftx2 770 movwf win_leftx2
832 ; Init pixel write 784 ; Init pixel write
833 movf logbook_pixel_x_pos,W 785 movf logbook_pixel_x_pos,W
834 mullw 2 786 mullw 2
835 call pixel_write_col320 787 call pixel_write_col320
836 788
837 movff profile_temp1+0,profile_temp2+0 789 MOVII profile_temp1,profile_temp2 ; 16 bit x-scaler
838 movff profile_temp1+1,profile_temp2+1 ; 16bit x-scaler 790
839 incf profile_temp2+1,F 791 incf profile_temp2+1,F
840 tstfsz profile_temp2+0 ; must not be zero 792 tstfsz profile_temp2+0 ; must not be zero, is zero?
841 bra profile_display_loop2 ; not Zero 793 bra profile_display_loop2 ; NO - ok
842 incf profile_temp2+0,F ; zero, increase 794 incf profile_temp2+0,F ; YES - increase by 1
843 795
844 profile_display_loop2: 796 profile_display_loop2:
845 rcall profile_view_get_depth ; reads depth, temp and profile data 797 rcall profile_view_get_depth ; reads depth, temp and profile data
846 798
847 btfsc end_of_profile ; end-of profile reached? 799 btfsc end_of_profile ; end-of profile reached?
854 806
855 movf logbook_ceiling,W ; any deco ceiling? 807 movf logbook_ceiling,W ; any deco ceiling?
856 bz profile_display_skip_deco 808 bz profile_display_skip_deco
857 809
858 mullw .100 ; YES - convert to mbar 810 mullw .100 ; YES - convert to mbar
859 movff PRODL,sub_a+0 811 MOVII PROD, sub_a ; ceiling depth
860 movff PRODH,sub_a+1 812 MOVII logbook_cur_depth+0,sub_b ; current depth
861 movff logbook_cur_depth+0,sub_b+0 ; compare with UNSIGNED current depth (16bits) 813 call cmpU16 ; ceiling - current depth
862 movff logbook_cur_depth+1,sub_b+1
863 call subU16 ; set (or not) neg_flag
864 814
865 movlw color_dark_green ; dark green if ok 815 movlw color_dark_green ; dark green if ok
866 btfss neg_flag 816 btfss neg_flag ; current depth > ceiling ?
867 movlw color_dark_red ; dark red if ceiling is violated 817 movlw color_dark_red ; NO - dark red because ceiling is violated
868 call TFT_set_color 818 call TFT_set_color
869 819
870 movff PRODL,xA+0 820 MOVII PROD,xA
871 movff PRODH,xA+1 821 MOVII y_scale,xB ; 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
874 call div16x16 ; xC = xA / xB with xA as remainder 822 call div16x16 ; xC = xA / xB with xA as remainder
875 823
876 movlw profile_top+.1 ; starts right after the top line 824 movlw profile_top+.1 ; starts right after the top line
877 movwf win_top 825 movwf win_top
878 movff logbook_pixel_x_pos,win_leftx2 ; left border (0-159) 826 movff logbook_pixel_x_pos,win_leftx2 ; left border (0-159)
887 movf logbook_cur_tp+0,W ; did we had already a valid Tp°C record? 835 movf logbook_cur_tp+0,W ; did we had already a valid Tp°C record?
888 andwf logbook_cur_tp+1,W 836 andwf logbook_cur_tp+1,W
889 incf WREG 837 incf WREG
890 bz profile_display_skip_temp ; NO - just skip drawing. 838 bz profile_display_skip_temp ; NO - just skip drawing.
891 839
892 movlw LOW (((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix 840 movlw LOW (((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix
893 movwf xB+0 841 movwf xB+0
894 movlw HIGH (((profile_height_pixels-.10)*.256)/.370) 842 movlw HIGH (((profile_height_pixels-.10)*.256)/.370)
895 movwf xB+1 843 movwf xB+1
896 844
897 movf logbook_cur_tp+0,W ; current Tp° - (-2.0°C) == Tp° + 20 845 movf logbook_cur_tp+0,W ; current Tp° - (-2.0°C) == Tp° + 20
916 864
917 movlw color_orange 865 movlw color_orange
918 call TFT_set_color 866 call TFT_set_color
919 867
920 movf logbook_last_tp,W ; do we have a valid previous value? 868 movf logbook_last_tp,W ; do we have a valid previous value?
921 bz profile_display_temp_1 ; NO - skip the vertical line. 869 bz profile_display_temp_1 ; NO - skip the vertical line
922 movwf xC+1 870 movwf xC+1
923 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) 871 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1)
924 profile_display_temp_1: 872 profile_display_temp_1:
925 movf xC+0,W ; current row 873 movf xC+0,W ; current row
926 cpfsgt logbook_min_temp_pos ; check limit 874 cpfsgt logbook_min_temp_pos ; check limit
927 movwf logbook_min_temp_pos ; lowest row in the temp graph 875 movwf logbook_min_temp_pos ; lowest row in the temp graph
928 cpfslt logbook_max_temp_pos ; check limit 876 cpfslt logbook_max_temp_pos ; check limit
929 movwf logbook_max_temp_pos ; highest row in the temp graph 877 movwf logbook_max_temp_pos ; highest row in the temp graph
930 878
931 movff xC+0,logbook_last_tp 879 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 880 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col (0..159) x row (0..239), put a current color pixel
933 881
934 profile_display_skip_temp: 882 profile_display_skip_temp:
935 ;---- Draw depth curve --------------------------------------------------- 883 ;---- Draw depth curve ---------------------------------------------------
936 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset 884 MOVII y_scale, xB ; divide pressure in mbar/quant for row offset
937 movff y_scale+1,xB+1 885 MOVII logbook_cur_depth,xA
938 movff logbook_cur_depth+0,xA+0
939 movff logbook_cur_depth+1,xA+1
940 call div16x16 ; xC = xA / xB with xA as remainder 886 call div16x16 ; xC = xA / xB with xA as remainder
941 movlw profile_top+.1 887 movlw profile_top+.1
942 addwf xC+0,F ; add 75 pixel offset to result 888 addwf xC+0,F ; add 75 pixel offset to result
943 889
944 btfsc STATUS,C ; ignore potential profile errors 890 btfsc STATUS,C ; ignore potential profile errors
945 movff fill_between_rows,xC+0 891 movff fill_between_rows,xC+0
946 892
947 movff backup_color1,WREG ; copy gas number to WREG for color-coding 893 movff backup_color1,WREG ; copy gas number to WREG for color-coding
948 call TFT_color_code_gas ; back to normal profile color. 894 call TFT_color_code_gas ; back to normal profile color
949 895
950 movff fill_between_rows,xC+1 896 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) 897 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 898 movff xC+0,fill_between_rows ; store last row for fill routine
953 899
954 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col(0..159) x row (0..239), put a std color pixel 900 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 901 incf logbook_pixel_x_pos,F ; next column
956 902
957 ;---- Draw Marker square , if any ---------------------------------------- 903 ;---- Draw Marker square, if any -----------------------------------------
958 btfss log_marker_found ; any marker to draw? 904 btfss log_marker_found ; any marker to draw?
959 bra profile_display_skip_marker ; NO 905 bra profile_display_skip_marker ; NO
960 906
961 ; tiny "m" 907 ; tiny "m"
962 incf fill_between_rows,W ; increase row (Y) 908 incf fill_between_rows,W ; increase row (Y)
1030 ; done 976 ; done
1031 977
1032 display_profile_no_profile: ; no profile available for this dive 978 display_profile_no_profile: ; no profile available for this dive
1033 979
1034 profile_display_loop_done: 980 profile_display_loop_done:
1035 btfss FLAG_bailout_mode ; bailout during the dive? 981 btfss bailout_mode ; bailout during the dive?
1036 bra profile_display_loop_done_nobail ; NO 982 bra profile_display_loop_done_nobail ; NO
1037 ; YES - show "Bailout" 983 ; YES - show "Bailout"
1038 movlw color_pink 984 movlw color_pink
1039 call TFT_set_color 985 call TFT_set_color
1040 WIN_TINY logbook_bailout_column,logbook_bailout_row 986 WIN_TINY logbook_bailout_column,logbook_bailout_row
1041 STRCPY_TEXT_PRINT tDiveBailout ; bailout 987 STRCPY_TEXT_PRINT tDiveBailout ; bailout
1042 profile_display_loop_done_nobail: 988 profile_display_loop_done_nobail:
1043 btfss gas6_changed ; Gas6 989 btfss event_gas_change_gas6 ; did a change to gas 6 occurred?
1044 bra profile_display_loop_done_nogas6 ; NO 990 bra profile_display_loop_done_nogas6 ; NO
1045 ; Yes, show "Gas 6!" 991 movlw color_pink ; YES - select color
1046 movlw color_pink 992 call TFT_set_color ; - set color
1047 call TFT_set_color
1048 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 993 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15
1049 STRCPY_TEXT tGas ; gas 994 STRCPY_TEXT tGas ; - print "Gas"
1050 STRCAT_PRINT " 6!" 995 STRCAT_PRINT " 6!" ; - print " 6!"
1051 996
1052 profile_display_loop_done_nogas6: 997 profile_display_loop_done_nogas6:
1053 decf divenumber,F ; -1 998 decf divenumber,F ; -1
1054 read_int_eeprom .2 999 read_int_eeprom .2
1055 movf EEDATA,W 1000 movf EEDATA,W
1081 movwf win_leftx2 1026 movwf win_leftx2
1082 WIN_FONT FT_TINY 1027 WIN_FONT FT_TINY
1083 movlw color_orange ; use same color as tp° curve 1028 movlw color_orange ; use same color as tp° curve
1084 call TFT_set_color 1029 call TFT_set_color
1085 1030
1086 movff logbook_min_tp+0,lo 1031 MOVII logbook_min_tp,mpr
1087 movff logbook_min_tp+1,hi
1088 lfsr FSR2,buffer 1032 lfsr FSR2,buffer
1089 1033
1090 TSTOSS opt_units ; 0=°C, 1=°F 1034 TSTOSS opt_units ; 0=°C, 1=°F
1091 bra logbook_show_temp_metric 1035 bra logbook_show_temp_metric ; 0 - do Celsius
1092 ;logbook_show_temp_imperial: 1036 ; 1 - do Fahrenheit
1093 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 1037 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 1038 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit
1095 lfsr FSR2,buffer ; overwrite "-" 1039 lfsr FSR2,buffer ; overwrite "-"
1096 bsf ignore_digit5 ; full degrees only 1040 bsf ignore_digit5 ; full degrees only
1097 output_16 1041 output_16
1098 STRCAT_TEXT_PRINT tLogTunitF 1042 STRCAT_TEXT_PRINT tLogTunitF
1099 ; Now, the max. temperature 1043 ; Now, the max. temperature
1100 movlw .15 1044 movlw .15
1101 subwf logbook_max_temp_pos,W 1045 subwf logbook_max_temp_pos,W
1102 movff WREG,win_top ; Y position at max temperature 1046 movff WREG,win_top ; Y position at max temperature
1103 movff logbook_max_tp+0,lo 1047 MOVII logbook_max_tp,mpr
1104 movff logbook_max_tp+1,hi
1105 lfsr FSR2,buffer 1048 lfsr FSR2,buffer
1106 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 1049 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
1107 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit 1050 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit
1108 output_16 1051 output_16
1109 bcf ignore_digit5 1052 bcf ignore_digit5
1120 STRCAT_TEXT_PRINT tLogTunitC 1063 STRCAT_TEXT_PRINT tLogTunitC
1121 ; Now, the max. temperature 1064 ; Now, the max. temperature
1122 movlw .15 1065 movlw .15
1123 subwf logbook_max_temp_pos,W 1066 subwf logbook_max_temp_pos,W
1124 movwf win_top ; Y position at max temperature 1067 movwf win_top ; Y position at max temperature
1125 movff logbook_max_tp+0,lo 1068 MOVII logbook_max_tp,mpr
1126 movff logbook_max_tp+1,hi
1127 lfsr FSR2,buffer 1069 lfsr FSR2,buffer
1128 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 1070 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
1129 movlw d'3' 1071 movlw d'3'
1130 movwf ignore_digits 1072 movwf ignore_digits
1131 bsf leftbind 1073 bsf leftbind
1134 1076
1135 logbook_show_temp_common: 1077 logbook_show_temp_common:
1136 bcf leftbind 1078 bcf leftbind
1137 call TFT_standard_color 1079 call TFT_standard_color
1138 1080
1139 ; Get pointer to Gaslist 1081 btfss aux_flag ; dive done in a deco mode?
1140 LOG_POINT_TO log_gas1 1082 bra logbook_show_gases_done ; NO
1083
1084 ; show gases
1085 LOG_POINT_TO log_gas1 ; get pointer to gaslist
1141 bsf log_show_gas_short ; do the short version of log_show_gas 1086 bsf log_show_gas_short ; do the short version of log_show_gas
1142 bsf leftbind 1087 bsf leftbind
1143 1088
1144 WIN_TINY log_gas_column1, log_gas_row 1089 WIN_TINY log_gas_column1, log_gas_row
1145 movlw .1 ; color for gas 1 1090 movlw .1 ; color for gas 1
1161 movlw .5 ; color for gas 5 1106 movlw .5 ; color for gas 5
1162 call log_show_gas 1107 call log_show_gas
1163 1108
1164 bcf leftbind 1109 bcf leftbind
1165 1110
1166 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco 1111 logbook_show_gases_done:
1112
1113 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco
1167 display_profile_loop: 1114 display_profile_loop:
1168 btfsc switch_right 1115 btfsc switch_right ; right button pressed?
1169 bra logbook_page2 ; show more information 1116 bra logbook_page2 ; YES - show more information
1170 btfsc switch_left 1117 btfsc switch_left ; left button pressed?
1171 bra exit_profileview ; back to list 1118 bra exit_profileview ; YES - back to list
1172 1119 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode
1173 rcall log_screendump_and_onesecond ; check if we need to make a screen-shot and check for new second 1120 bra display_profile_loop ; - loop waiting for something to do
1174 btfsc sleepmode ; timeout?
1175 bra exit_profileview ; back to list
1176 bra display_profile_loop ; wait for something to do
1177
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
1180 btfsc onesecupdate
1181 call timeout_surfmode ; timeout
1182 btfsc onesecupdate
1183 call set_dive_modes ; check if divemode needs to be entered
1184 bcf onesecupdate ; one second update
1185 btfsc divemode
1186 goto restart ; enter divemode if required
1187
1188 IFDEF _screendump
1189 btfsc enable_screen_dumps ; screendump enabled?
1190 call TFT_dump_screen_check ; YES - check if requested and do it
1191 ENDIF
1192
1193 btfsc vusb_in ; USB plugged in?
1194 goto comm_mode ; YES - start COMM mode and return
1195
1196 return
1197
1198 1121
1199 ;============================================================================= 1122 ;=============================================================================
1200 ; Draw a vertical line between xC+1 and xC+0, at current X position. 1123 ; Draw a vertical line between xC+1 and xC+0, at current X position.
1201 ; 1124 ;
1202 ; Note: should keep xC+0 1125 ; Note: should keep xC+0
1203 ; Note: ascending or descending ! 1126 ; Note: ascending or descending !
1204 ; 1127 ;
1205 profile_display_fill: 1128 profile_display_fill:
1206 ; First, check if xC+0 > fill_between_rows or xC+0 < aponoe_mins 1129 ; First, check if xC+0 > fill_between_rows or xC+0 < aponoe_mins
1207 movf xC+0,W 1130 movf xC+0,W
1208 cpfseq xC+1 ; xC+0 = apone_mins ? 1131 cpfseq xC+1 ; xC+0 = apnoe_mins ?
1209 bra profile_display_fill2 ; NO 1132 bra profile_display_fill2 ; NO
1210 return 1133 return
1211 1134
1212 profile_display_fill2: 1135 profile_display_fill2:
1213 ; Make sure to init X position. 1136 ; Make sure to init X position
1214 movf logbook_pixel_x_pos,W 1137 movf logbook_pixel_x_pos,W
1215 mullw 2 1138 mullw 2
1216 decf PRODL,F 1139 decf PRODL,F
1217 movlw 0 1140 movlw 0
1218 subwfb PRODH,F 1141 subwfb PRODH,F
1244 1167
1245 ;============================================================================= 1168 ;=============================================================================
1246 1169
1247 1170
1248 profile_view_get_depth: 1171 profile_view_get_depth:
1249 infsnz logbook_sample_counter+0,F 1172 INCI logbook_sample_counter ; count read pixels
1250 incf logbook_sample_counter+1,F ; count read pixels
1251 1173
1252 movf logbook_sample_counter+0,W 1174 movf logbook_sample_counter+0,W
1253 cpfseq vertical_interval+0 1175 cpfseq vertical_interval+0
1254 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue 1176 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue
1255 movf logbook_sample_counter+1,W 1177 movf logbook_sample_counter+1,W
1256 cpfseq vertical_interval+1 1178 cpfseq vertical_interval+1
1257 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue 1179 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue
1258 ; draw a new 10min line here... 1180 ; draw a new 10min line here...
1259 clrf logbook_sample_counter+0 1181 CLRI logbook_sample_counter ; clear counting registers for next line
1260 clrf logbook_sample_counter+1 ; clear counting registers for next line
1261 1182
1262 ; Vertical lines... 1183 ; Vertical lines...
1263 movlw color_deepblue 1184 movlw color_deepblue
1264 call TFT_set_color 1185 call TFT_set_color
1265 movlw profile_top+.1 1186 movlw profile_top+.1
1275 profile_view_get_depth_no_line: 1196 profile_view_get_depth_no_line:
1276 call ext_flash_byte_read_plus_0x20 ; read depth first 1197 call ext_flash_byte_read_plus_0x20 ; read depth first
1277 movff ext_flash_rw,logbook_cur_depth+0 ; low value 1198 movff ext_flash_rw,logbook_cur_depth+0 ; low value
1278 call ext_flash_byte_read_plus_0x20 ; read depth first 1199 call ext_flash_byte_read_plus_0x20 ; read depth first
1279 movff ext_flash_rw,logbook_cur_depth+1 ; high value 1200 movff ext_flash_rw,logbook_cur_depth+1 ; high value
1280 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte 1201 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte
1281 movff ext_flash_rw,gaslist_gas ; store Profile Flag Byte 1202 movff ext_flash_rw,gaslist_gas ; store Profile Flag Byte
1282 1203
1283 bcf event_occured ; clear flag 1204 bcf event_occured ; clear flag by default
1284 btfsc gaslist_gas,7 1205 btfsc gaslist_gas,7 ; event recorded?
1285 bsf event_occured ; we also have an event byte 1206 bsf event_occured ; YES - we also have an event byte
1286 bcf gaslist_gas,7 ; clear event byte flag (if any) 1207 bcf gaslist_gas,7 ; clear event byte flag (if any)
1287 ; gaslist_gas now holds the number of additional bytes to ignore (0-127) 1208 ; gaslist_gas now holds the number of additional bytes to ignore (0-127)
1288 movlw 0xFD ; end of profile bytes ? 1209 movlw 0xFD ; end of profile bytes ?
1289 cpfseq logbook_cur_depth+0 1210 cpfseq logbook_cur_depth+0
1290 bra profile_view_get_depth_new1 ; no 1st. 0xFD 1211 bra profile_view_get_depth_new1 ; no 1st. 0xFD
1310 decf gaslist_gas,F 1231 decf gaslist_gas,F
1311 movff ext_flash_rw,logbook_cur_tp+1 1232 movff ext_flash_rw,logbook_cur_tp+1
1312 movff divisor_temperature,count_temperature ; restart counter 1233 movff divisor_temperature,count_temperature ; restart counter
1313 1234
1314 ; Compute Tp° max on the fly... 1235 ; Compute Tp° max on the fly...
1315 movff logbook_cur_tp+0,sub_a+0 ; compare cur_tp > max_tp ? 1236 MOVII logbook_cur_tp,sub_a ; compare cur_tp > max_tp ?
1316 movff logbook_cur_tp+1,sub_a+1 1237 MOVII logbook_max_tp,sub_b
1317 movff logbook_max_tp+0,sub_b+0
1318 movff logbook_max_tp+1,sub_b+1
1319 call sub16 ; SIGNED sub_a - sub_b 1238 call sub16 ; SIGNED sub_a - sub_b
1320 btfsc neg_flag 1239 btfsc neg_flag
1321 bra profile_view_get_depth_no_tp 1240 bra profile_view_get_depth_no_tp
1322 1241
1323 ; store max. temp only below start_dive_threshold (1,0m) 1242 ; store max. temp only below dive_threshold_norm_alt_start
1324 tstfsz logbook_cur_depth+1 ; > 2,56m ? 1243 tstfsz logbook_cur_depth+1 ; > 2.56 m ?
1325 bra profile_view_compute_max_temp ; YES - include in max. temp measurement 1244 bra profile_view_compute_max_temp ; YES - include in max. temp measurement
1326 movlw start_dive_threshold ; 1,0m 1245 movlw dive_threshold_norm_alt_start+0 ; get start-of-dive depth in mbar / cm, low byte
1327 cpfsgt logbook_cur_depth+0 ; low value 1246 cpfsgt logbook_cur_depth+0 ; deeper that start-of-dive threshold?
1328 bra profile_view_get_depth_no_tp ; above 1,0m, ignore temp 1247 bra profile_view_get_depth_no_tp ; NO - ignore temperature
1329 1248
1330 profile_view_compute_max_temp: 1249 profile_view_compute_max_temp:
1331 movff logbook_cur_tp+0,logbook_max_tp+0 1250 MOVII logbook_cur_tp,logbook_max_tp
1332 movff logbook_cur_tp+1,logbook_max_tp+1
1333 1251
1334 ;---- read deco, if any AND divisor=0 AND bytes available ---------------- 1252 ;---- read deco, if any AND divisor=0 AND bytes available ----------------
1335 profile_view_get_depth_no_tp: 1253 profile_view_get_depth_no_tp:
1336 movf divisor_deco,W 1254 movf divisor_deco,W
1337 bz profile_view_get_depth_no_deco 1255 bz profile_view_get_depth_no_deco
1352 tstfsz gaslist_gas ; anything to skip? 1270 tstfsz gaslist_gas ; anything to skip?
1353 call incf_ext_flash_address0_0x20 ; YES - increases bytes in ext_flash_address:3 with 0x200000 bank switching 1271 call incf_ext_flash_address0_0x20 ; YES - increases bytes in ext_flash_address:3 with 0x200000 bank switching
1354 return 1272 return
1355 1273
1356 profile_view_get_depth_events: 1274 profile_view_get_depth_events:
1357 clrf EventByte2 ; clear EventByte2 1275 clrf event_byte2 ; clear event byte 2
1358 call ext_flash_byte_read_plus_0x20 ; read event byte 1276 call ext_flash_byte_read_plus_0x20 ; read event byte
1359 movff ext_flash_rw,EventByte1 ; store EventByte1 1277 movff ext_flash_rw,event_byte1 ; store event byte 1
1360 decf gaslist_gas,F ; reduce counter 1278 decf gaslist_gas,F ; reduce counter
1361 1279
1362 btfss EventByte1,7 ; another event byte? 1280 btfss event_byte1,7 ; another event byte?
1363 bra profile_no_second_eventbyte ; NO 1281 bra profile_no_second_eventbyte ; NO
1364 call ext_flash_byte_read_plus_0x20 ; read EventByte2 1282 call ext_flash_byte_read_plus_0x20 ; read event byte 2
1365 movff ext_flash_rw,EventByte2 ; store EventByte2 1283 movff ext_flash_rw,event_byte2 ; store event byte 2
1366 decf gaslist_gas,F ; reduce counter 1284 decf gaslist_gas,F ; reduce counter
1367 bcf EventByte1,7 ; clear flag 1285 bcf event_byte1,7 ; clear flag
1368 1286
1369 profile_no_second_eventbyte: 1287 profile_no_second_eventbyte:
1370 ; Check event flags in the EventBytes 1288 ; Check event flags in the EventBytes
1371 btfsc EventByte1,4 ; manual gas changed? 1289 btfsc event_byte1,4 ; manual gas changed?
1372 rcall logbook_event1 ; YES 1290 rcall logbook_event1 ; YES
1373 btfsc EventByte1,5 ; stored gas changed? 1291 btfsc event_byte1,5 ; stored gas changed?
1374 rcall logbook_event4 ; YES 1292 rcall logbook_event4 ; YES
1375 btfsc EventByte1,6 ; setpoint change? 1293 btfsc event_byte1,6 ; setpoint change?
1376 rcall logbook_event3 ; YES 1294 rcall logbook_event3 ; YES
1377 btfsc EventByte2,0 ; bailout? 1295 btfsc event_byte2,0 ; bailout?
1378 rcall logbook_event2 ; YES 1296 rcall logbook_event2 ; YES
1379 ; Any Alarm? 1297 ; any alarm?
1380 bcf EventByte1,4 ; clear bits already tested 1298 bcf event_byte1,4 ; clear bits already tested
1381 bcf EventByte1,5 1299 bcf event_byte1,5
1382 bcf EventByte1,6 1300 bcf event_byte1,6
1383 movlw .6 ; manual marker? 1301 movlw .6 ; coding for manual marker
1384 cpfseq EventByte1 1302 cpfseq event_byte1 ; manual marker set?
1385 return ; NO - return 1303 return ; NO - done
1386 bsf log_marker_found ; manual marker, draw small yellow rectangle here 1304 bsf log_marker_found ; YES - draw small yellow rectangle here
1387 return 1305 return ; - done
1388 1306
1389 logbook_event4: ; stored gas changed 1307 logbook_event4: ; stored gas changed
1390 call ext_flash_byte_read_plus_0x20 ; read Gas# 1308 call ext_flash_byte_read_plus_0x20 ; read gas number
1391 decf gaslist_gas,F ; reduce counter 1309 decf gaslist_gas,F ; reduce counter
1392 movff ext_flash_rw,backup_color1 1310 movff ext_flash_rw,backup_color1
1393 movff ext_flash_rw,WREG ; copy gas number to WREG for color-coding 1311 movff ext_flash_rw,WREG ; copy gas number to WREG for color-coding
1394 call TFT_color_code_gas ; change profile color according to gas number 1312 call TFT_color_code_gas ; change profile color according to gas number
1395 return 1313 return
1396 1314
1397 logbook_event1: ; gas 6 used 1315 logbook_event1: ; gas 6 used
1398 bsf gas6_changed 1316 bsf event_gas_change_gas6 ; set event flag
1399 movlw .6 ; use Gas6 color 1317 movlw .6 ; use gas 6 color
1400 movwf backup_color1 1318 movwf backup_color1 ; select color for gas 6
1401 call TFT_color_code_gas ; set profile color 1319 call TFT_color_code_gas ; set profile color
1402 incf_ext_flash_address_0x20 .2 ; skip two bytes 1320 incf_ext_flash_address_0x20 .2 ; skip two bytes
1403 decf gaslist_gas,F ; reduce counter 1321 decf gaslist_gas,F ; reduce counter
1404 decf gaslist_gas,F ; reduce counter 1322 decf gaslist_gas,F ; reduce counter
1405 return 1323 return
1406 1324
1407 logbook_event2: ; bailout 1325 logbook_event2: ; bailout
1408 bsf FLAG_bailout_mode ; set flag 1326 bsf bailout_mode ; set flag
1409 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR 1327 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR
1410 movlw .6 ; use Gas6 color 1328 movlw .6 ; use Gas6 color
1411 movwf backup_color1 1329 movwf backup_color1
1412 call TFT_color_code_gas ; use Gas6 color 1330 call TFT_color_code_gas ; use gas 6 color
1413 incf_ext_flash_address_0x20 .2 ; skip two bytes 1331 incf_ext_flash_address_0x20 .2 ; skip two bytes
1414 decf gaslist_gas,F ; reduce counter 1332 decf gaslist_gas,F ; reduce counter
1415 decf gaslist_gas,F ; reduce counter 1333 decf gaslist_gas,F ; reduce counter
1416 return 1334 return
1417 1335
1418 logbook_event3: ; setpoint change 1336 logbook_event3: ; setpoint change
1419 incf_ext_flash_address_0x20 .1 ; skip one byte 1337 incf_ext_flash_address_0x20 .1 ; skip one byte
1420 decf gaslist_gas,F ; reduce counter 1338 decf gaslist_gas,F ; reduce counter
1421 btfss FLAG_bailout_mode ; are we in bailout? 1339 btfss bailout_mode ; in bailout?
1422 return ; NO - return 1340 return ; NO - return
1423 ; We were in bailout before, restore profile color 1341 ; We were in bailout before, restore profile color
1424 movff backup_color2,backup_color1 ; restore color 1342 movff backup_color2,backup_color1 ; restore color
1425 movff backup_color2,WREG ; copy gas number to WREG for color-coding 1343 movff backup_color2,WREG ; copy gas number to WREG for color-coding
1426 call TFT_color_code_gas ; back to normal profile color 1344 call TFT_color_code_gas ; back to normal profile color
1427 return 1345 return
1428 1346
1429 ; ------------------------------------------------------------------------ 1347 ; ------------------------------------------------------------------------
1430 1348
1431 exit_profileview: 1349 exit_profileview:
1432 ; call speed_fastest
1433 bcf sleepmode
1434 clrf gaslist_gas ; restore all registers to build same page again 1350 clrf gaslist_gas ; restore all registers to build same page again
1435 movff logbook_divenumber_temp,logbook_divenumber 1351 movff logbook_divenumber_temp,logbook_divenumber
1436 movff logbook_max_dive_counter_temp,logbook_max_dive_counter 1352 movff logbook_max_dive_counter_temp,logbook_max_dive_counter
1437 movff logbook_temp_backup,logbook_temp 1353 movff logbook_temp_backup,logbook_temp
1438 incf logbook_max_dive_counter,F 1354 incf logbook_max_dive_counter,F
1439 decf logbook_divenumber,F 1355 decf logbook_divenumber,F
1440 bcf all_dives_shown 1356 bcf all_dives_shown
1441 clrf menupos3 ; here: used row on current page 1357 clrf menu_pos_max ; number of used rows on current logbook-page
1442 movlw logbook_row_number 1358 movlw logbook_row_number
1443 movwf menupos1 ; here: active row on current page 1359 movwf menu_pos_cur ; here: active row on current page
1444 ; call TFT_DisplayOff
1445 call TFT_boot 1360 call TFT_boot
1446 clrf CCP1CON ; stop PWM
1447 bcf PORTC,2 ; pull PWM out to GND
1448 call TFT_boot
1449 ; call TFT_ClearScreen ; clear details/profile
1450 goto logbook2 ; start search 1361 goto logbook2 ; start search
1451 1362
1452 next_logbook2: 1363 next_logbook2:
1453 btfsc all_dives_shown ; all shown 1364 btfsc all_dives_shown ; all shown?
1454 goto logbook ; all reset 1365 goto logbook ; YES
1455 clrf menupos3 1366 clrf menu_pos_max ; number of used rows on current logbook-page
1456 movlw logbook_row_number 1367 movlw logbook_row_number
1457 movwf menupos1 1368 movwf menu_pos_cur
1458 incf logbook_page_number,F ; start new screen 1369 incf logbook_page_number,F ; start new screen
1459 bsf keep_cursor_new_page ; keep cursor on "next page" 1370 bsf keep_cursor_new_page ; keep cursor on "next page"
1460 clrf CCP1CON ; stop PWM
1461 bcf PORTC,2 ; pull PWM out to GND
1462 call TFT_boot 1371 call TFT_boot
1463 ; call TFT_ClearScreen
1464 goto logbook2 ; start search 1372 goto logbook2 ; start search
1465 1373
1466 next_logbook3: 1374 next_logbook3:
1467 incf menupos1,F ; +1 1375 incf menu_pos_cur,F ; +1
1468 movlw logbook_row_number+.2 1376 movlw logbook_row_number+.2
1469 cpfsgt menupos1 ; = logbook_row_number+.3 ? 1377 cpfsgt menu_pos_cur ; = logbook_row_number + 3 ?
1470 bra next_logbook3a ; NO 1378 bra next_logbook3a ; NO
1471 movlw .1 1379 movlw .1
1472 movwf menupos1 1380 movwf menu_pos_cur
1473 bra next_logbook3b 1381 bra next_logbook3b
1474 1382
1475 next_logbook3a: 1383 next_logbook3a:
1476 incf menupos3,W ; last entry in current page +1 1384 incf menu_pos_max,W ; last entry on current page +1
1477 cpfseq menupos1 ; same as cursor pos.? 1385 cpfseq menu_pos_cur ; same as cursor position?
1478 bra next_logbook3b ; NO 1386 bra next_logbook3b ; NO
1479 movlw logbook_row_number+.1 ; YES - 1387 movlw logbook_row_number+.1 ; YES - ...
1480 movwf menupos1 ; - jump directly to "next page" if page is not full 1388 movwf menu_pos_cur ; - ... jump directly to "next page" if page is not full
1481 1389
1482 movlw logbook_row_number 1390 movlw logbook_row_number
1483 cpfseq menupos3 ; last dive was row logbook_row_number? 1391 cpfseq menu_pos_max ; last dive was row logbook_row_number?
1484 bsf all_dives_shown ; NO - set flag to load first page again (full reset) 1392 bsf all_dives_shown ; NO - set flag to load first page again (full reset)
1485 1393
1486 next_logbook3b: 1394 next_logbook3b:
1487 clrf timeout_counter2
1488 call TFT_logbook_cursor 1395 call TFT_logbook_cursor
1489 bcf switch_left 1396 goto logbook_loop_pre
1490 goto logbook_loop
1491 1397
1492 display_listdive: 1398 display_listdive:
1493 bsf logbook_page_not_empty ; page not empty 1399 bsf logbook_page_not_empty ; page not empty
1494 incf menupos3,F 1400 incf menu_pos_max,F
1495 1401
1496 bsf leftbind
1497 WIN_FONT FT_SMALL 1402 WIN_FONT FT_SMALL
1498 WIN_LEFT logbook_list_left 1403 WIN_LEFT logbook_list_left
1499 1404
1500 decf menupos3,W ; -1 into wreg 1405 decf menu_pos_max,W ; -1 into WREG
1501 mullw logbook_row_offset 1406 mullw logbook_row_offset
1502 movff PRODL,win_top 1407 movff PRODL,win_top
1503 1408 lfsr FSR2,buffer ; initialize output buffer
1504 lfsr FSR2,buffer 1409
1505 call do_logoffset_common_read ; read into lo:hi 1410 movf logbook_divenumber,W ; log_compute_divenumber needs the list number
1506 tstfsz lo ; lo = 0 ? 1411 call log_compute_divenumber ; compute dive number
1507 bra display_listdive1 ; NO - adjust offset 1412 bsf leftbind
1508 tstfsz hi ; hi = 0 ? 1413 output_16_3 ; show dive number, but only last three digits
1509 bra display_listdive1 ; NO - adjust offset 1414 bcf leftbind
1510 bra display_listdive1b ; display now
1511
1512 display_listdive1:
1513 ; Check limit (lo:hi must be <1000)
1514 movlw LOW d'1000' ; compare to 1000
1515 subwf lo,W
1516 movlw HIGH d'1000'
1517 subwfb hi,W
1518 bc display_listdive1b ; carry = no-borrow = > 1000, skip!
1519
1520 infsnz lo,F
1521 incf hi,F ; hi:lo = hi:lo + 1
1522 movff lo,sub_a+0
1523 movff hi,sub_a+1
1524 movff logbook_divenumber,sub_b+0
1525 clrf sub_b+1
1526 call subU16 ; sub_c = sub_a - sub_b
1527 movff sub_c+0,lo
1528 movff sub_c+1,hi
1529 bra display_listdive1a
1530
1531 display_listdive1b:
1532 clrf hi
1533 movff logbook_divenumber,lo ; lo=0 and hi=0 -> show without applied offset
1534 display_listdive1a:
1535 output_16_3 ; displays only last three figures from a 16Bit value (0-999), # of dive
1536 PUTC ' ' 1415 PUTC ' '
1537 ;display_listdive2: 1416 ; display_listdive2:
1538 LOG_POINT_TO log_date+1 ; point to month 1417 LOG_POINT_TO log_date+1 ; point to month
1539 call ext_flash_byte_read_plus ; read month 1418 call ext_flash_byte_read_plus ; read month
1540 movff ext_flash_rw,hi ; month 1419 movff ext_flash_rw,hi ; month
1541 call ext_flash_byte_read_plus ; read day 1420 call ext_flash_byte_read_plus ; read day
1542 movff ext_flash_rw,lo ; day 1421 movff ext_flash_rw,lo ; day
1548 movff ext_flash_rw,lo 1427 movff ext_flash_rw,lo
1549 call ext_flash_byte_read_plus 1428 call ext_flash_byte_read_plus
1550 movff ext_flash_rw,hi 1429 movff ext_flash_rw,hi
1551 1430
1552 TSTOSS opt_units ; 0=Meters, 1=Feets 1431 TSTOSS opt_units ; 0=Meters, 1=Feets
1553 bra display_listdive2_metric 1432 bra display_listdive2_metric ; 0 - do metric
1554 ;display_listdive2_imperial: 1433 ; 1 - do imperial
1555 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1434 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
1556 PUTC ' ' 1435 PUTC ' '
1557 bcf leftbind
1558 output_16_3 ; limit to 999 and display only (0-999) 1436 output_16_3 ; limit to 999 and display only (0-999)
1559 STRCAT_TEXT tFeets1 1437 STRCAT_TEXT tFeets1
1560 bra display_listdive3 1438 bra display_listdive3
1561 1439
1562 display_listdive2_metric: 1440 display_listdive2_metric:
1563 bsf ignore_digit5 ; no cm... 1441 bsf ignore_digit5 ; no cm...
1564 movlw d'1' ; +1 1442 movlw d'1' ; +1
1565 movff WREG,ignore_digits ; no 1000m 1443 movwf ignore_digits ; no 1000 m
1566 bcf leftbind
1567 output_16dp .3 ; xxx.y 1444 output_16dp .3 ; xxx.y
1568 STRCAT_TEXT tMeters 1445 STRCAT_TEXT tMeters
1569 PUTC ' ' 1446 PUTC ' '
1570 1447
1571 display_listdive3: 1448 display_listdive3:
1572 call ext_flash_byte_read_plus 1449 call ext_flash_byte_read_plus
1573 movff ext_flash_rw,lo ; read divetime minutes 1450 movff ext_flash_rw,lo ; read dive time minutes
1574 call ext_flash_byte_read_plus 1451 call ext_flash_byte_read_plus
1575 movff ext_flash_rw,hi 1452 movff ext_flash_rw,hi
1576 output_16_3 ; divetime minutes (0-999min) 1453 output_16_3 ; dive time minutes (0-999min)
1577 STRCAT_TEXT tMinutes 1454 STRCAT_TEXT tMinutes
1578 clrf WREG 1455 clrf WREG
1579 movff WREG,buffer+.21 ; limit to 21 chars 1456 movff WREG,buffer+.21 ; limit to 21 chars
1580 STRCAT_PRINT "" ; display header-row in list 1457 STRCAT_PRINT "" ; display header-row in list
1581 return 1458 return
1582 1459
1583 ; ------------------------------------------------------------------ 1460 ; ------------------------------------------------------------------
1584 1461
1585 logbook_show_divenumber: 1462 logbook_show_divenumber:
1586 call do_logoffset_common_read ; read into lo:hi
1587 tstfsz lo ; lo = 0 ?
1588 bra logbook_show_divenumber2 ; NO - adjust offset
1589 tstfsz hi ; hi = 0 ?
1590 bra logbook_show_divenumber2 ; NO - adjust offset
1591 movff divenumber,lo ; lo = 0 and hi = 0 -> skip offset routine
1592 bra logbook_show_divenumber3 ; display now
1593
1594 logbook_show_divenumber2:
1595 infsnz lo,F
1596 incf hi,F ; hi:lo = hi:lo + 1
1597 movff lo,sub_a+0
1598 movff hi,sub_a+1
1599 movff divenumber,sub_b+0
1600 clrf sub_b+1
1601 call subU16 ; sub_c = sub_a - sub_b
1602 movff sub_c+0,lo
1603 movff sub_c+1,hi
1604
1605 logbook_show_divenumber3:
1606 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row 1463 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row
1464 movf divenumber,W ; log_compute_divenumber needs the list number
1465 call log_compute_divenumber ; compute dive number
1607 bsf leftbind 1466 bsf leftbind
1608 output_16 ; # of dive in logbook 1467 output_16 ; show dive number
1609 bcf leftbind 1468 bcf leftbind
1610 STRCAT_PRINT "" 1469 STRCAT_PRINT "" ; finalize output
1611 return 1470 return ; done
1612 1471
1613 ; ------------------------------------------------------------------- 1472 ; -------------------------------------------------------------------
1614 1473
1615 logbook_page2: ; show more info 1474 logbook_page2: ; show more info
1616 rcall log_details_header ; shows number, time/date and basic dive info 1475 rcall log_details_header ; shows number, time/date and basic dive info
1476
1477 btfss aux_flag ; dive done in a deco mode?
1478 bra logbook_page2_1 ; NO
1617 1479
1618 ; Deco model 1480 ; Deco model
1619 WIN_SMALL .5,.65 1481 WIN_SMALL .5,.65
1620 LOG_POINT_TO log_decomodel 1482 LOG_POINT_TO log_decomodel
1621 call ext_flash_byte_read_plus ; read deco model 1483 call ext_flash_byte_read_plus ; read deco model
1635 logbook_decomodel1: 1497 logbook_decomodel1:
1636 ; Deco model NON-GF Version 1498 ; Deco model NON-GF Version
1637 STRCAT_PRINT "ZH-L16" 1499 STRCAT_PRINT "ZH-L16"
1638 LOG_POINT_TO log_sat_mult 1500 LOG_POINT_TO log_sat_mult
1639 WIN_SMALL .5,.90 1501 WIN_SMALL .5,.90
1640 call ext_flash_byte_read_plus ; read sat_mult 1502 call ext_flash_byte_read_plus ; read sat_mult or GF low
1641 movff ext_flash_rw,lo 1503 movff ext_flash_rw,lo
1642 output_8 1504 output_8
1643 STRCAT "%/" 1505 STRCAT "%/"
1644 logbook_decomodel_common: 1506 logbook_decomodel_common:
1645 call ext_flash_byte_read_plus ; read desat_mult or GF_hi 1507 call ext_flash_byte_read_plus ; read desat_mult or GF high
1646 movff ext_flash_rw,lo 1508 movff ext_flash_rw,lo
1647 output_8 1509 output_8
1648 STRCAT_PRINT "%" 1510 STRCAT_PRINT "%"
1649 1511
1650 ; CNS 1512 ; CNS
1651 LOG_POINT_TO log_cns_start 1513 LOG_POINT_TO log_cns_start
1652 WIN_SMALL .5,.115 1514 WIN_SMALL .5,.115
1653 STRCPY_TEXT tCNS2 1515 STRCPY_TEXT tCNS2
1654 call ext_flash_byte_read_plus ; read cns low 1516 call ext_flash_byte_read_plus ; read CNS low
1655 movff ext_flash_rw,lo 1517 movff ext_flash_rw,lo
1656 call ext_flash_byte_read_plus ; read cns high 1518 call ext_flash_byte_read_plus ; read CNS high
1657 movff ext_flash_rw,hi 1519 movff ext_flash_rw,hi
1658 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) 1520 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 EEPROM) 1521 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM)
1660 output_16 1522 output_16
1661 LOG_POINT_TO log_cns_end 1523 LOG_POINT_TO log_cns_end
1667 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) 1529 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) 1530 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM)
1669 output_16 1531 output_16
1670 STRCAT_PRINT "%" 1532 STRCAT_PRINT "%"
1671 1533
1534 logbook_page2_1:
1535
1672 ; Salinity 1536 ; Salinity
1673 WIN_SMALL .5,.140 1537 WIN_SMALL .5,.140
1674 LOG_POINT_TO log_salinity 1538 LOG_POINT_TO log_salinity
1675 STRCPY_TEXT tDvSalinity 1539 STRCPY_TEXT tDvSalinity
1676 bsf leftbind 1540 bsf leftbind
1682 1546
1683 ; Average depth 1547 ; Average depth
1684 WIN_SMALL .5,.165 1548 WIN_SMALL .5,.165
1685 STRCPY_TEXT tAVG 1549 STRCPY_TEXT tAVG
1686 LOG_POINT_TO log_avr_depth 1550 LOG_POINT_TO log_avr_depth
1687 call ext_flash_byte_read_plus ; read avr low 1551 call ext_flash_byte_read_plus ; read average low
1688 movff ext_flash_rw,lo 1552 movff ext_flash_rw,lo
1689 call ext_flash_byte_read_plus ; read avr high 1553 call ext_flash_byte_read_plus ; read average high
1690 movff ext_flash_rw,hi 1554 movff ext_flash_rw,hi
1691 movf backup_divedata,W ; salinity for this dive 1555 movf backup_divedata,W ; salinity for this dive
1692 call adjust_depth_with_salinity_log ; computes salinity setting (FROM WREG!) into lo:hi [mbar] 1556 call adjust_depth_with_salinity_log ; compute salinity setting (FROM WREG!) into lo:hi [mbar]
1693 output_16dp .3 1557 output_16dp .3
1694 STRCAT_PRINT "m" 1558 STRCAT_PRINT "m"
1559
1560 btfss aux_flag ; dive done in a deco mode?
1561 bra logbook_page2_2 ; NO
1695 1562
1696 ; Last deco 1563 ; Last deco
1697 LOG_POINT_TO log_last_stop 1564 LOG_POINT_TO log_last_stop
1698 WIN_SMALL .5,.190 1565 WIN_SMALL .5,.190
1699 STRCPY_TEXT tLastDecostopSurf 1566 STRCPY_TEXT tLastDecostopSurf
1700 call ext_flash_byte_read_plus ; read last stop 1567 call ext_flash_byte_read_plus ; read last stop
1701 movff ext_flash_rw,lo 1568 movff ext_flash_rw,lo
1702 output_8 1569 output_8
1703 STRCAT_PRINT "m" 1570 STRCAT_PRINT "m"
1704 1571
1572 logbook_page2_2:
1573
1705 movlw color_lightblue 1574 movlw color_lightblue
1706 call TFT_set_color 1575 call TFT_set_color
1707 WIN_FRAME_COLOR16 .63,.220,.2,.105 ; Top, Bottom, Left, Right 1576 WIN_FRAME_COLOR16 .63,.220,.2,.105 ; top, bottom, left, right
1708 1577
1709 ; Firmware 1578 ; Firmware
1710 call TFT_standard_color 1579 call TFT_standard_color
1711 WIN_SMALL .110,.65 1580 WIN_SMALL .110,.65
1712 STRCAT "V:" 1581 STRCAT "V:"
1713 LOG_POINT_TO log_firmware 1582 LOG_POINT_TO log_firmware
1714 call ext_flash_byte_read_plus ; read firmware major number 1583 call ext_flash_byte_read_plus ; read firmware major number
1715 movf ext_flash_rw,W ; copy to WREG 1584 movf ext_flash_rw,W ; copy to WREG
1716 movwf hi ; copy from WREG to hi 1585 movwf hi ; copy from WREG to hi
1717 movwf lo ; copy from WREG to lo, too 1586 movwf lo ; copy from WREG to lo, too
1718 bsf leftbind ; print left-aligned 1587 bsf leftbind ; print left-aligned
1719 output_8 ; print major number 1588 output_8 ; print major number
1720 PUTC "." ; print "." 1589 PUTC "." ; print "."
1721 call ext_flash_byte_read_plus ; read firmware minor number 1590 call ext_flash_byte_read_plus ; read firmware minor number
1722 movff ext_flash_rw,lo ; store in lo 1591 movff ext_flash_rw,lo ; store in lo
1723 output_99x ; print minor version in 2 digit format 1592 output_99x ; print minor version in 2 digit format
1724 STRCAT_PRINT "" ; finalize output 1593 STRCAT_PRINT "" ; finalize output
1725 1594
1726 movf hi,W ; get major into WREG 1595 movf hi,W ; get major into WREG
1727 xorlw .3 ; major == 3 ? 1596 xorlw .3 ; major == 3 ?
1728 bz logbook_battery_percent ; YES - show battery % 1597 bz logbook_battery_percent ; YES - show battery %
1729 1598
1730 movf hi,W ; get major into WREG (again) 1599 movf hi,W ; get major into WREG (again)
1731 xorlw .2 ; major == 2 ? 1600 xorlw .2 ; major == 2 ?
1732 bnz logbook_battery_voltage ; NO - skip battery % 1601 bnz logbook_battery_voltage ; NO - skip battery %
1733 movlw .14 ; YES - check minor version 1602 movlw .14 ; YES - check minor version
1734 cpfsgt lo ; - minor > 14 ? 1603 cpfsgt lo ; - minor > 14 ?
1735 bra logbook_battery_voltage ; NO - skip battery % 1604 bra logbook_battery_voltage ; NO - skip battery %
1736 ;bra logbook_battery_percent ; YES - show battery % 1605 ;bra logbook_battery_percent ; YES - show battery %
1737 1606
1738 ; Battery % 1607 ; Battery %
1739 logbook_battery_percent: 1608 logbook_battery_percent:
1740 WIN_SMALL .110,.140 ; show battery percent 1609 WIN_SMALL .110,.140 ; show battery percent
1741 LOG_POINT_TO log_batt_info ; address battery percent 1610 LOG_POINT_TO log_batt_info ; address battery percent
1742 call ext_flash_byte_read_plus ; read battery percent 1611 call ext_flash_byte_read_plus ; read battery percent
1743 movff ext_flash_rw,lo ; copy battery percent to lo 1612 movff ext_flash_rw,lo ; copy battery percent to lo
1744 output_8 ; print battery percent 1613 output_8 ; print battery percent
1745 STRCAT_PRINT "%" ; print "%" and finalize output 1614 STRCAT_PRINT "%" ; print "%" and finalize output
1746 1615
1747 ; Battery Voltage 1616 ; Battery Voltage
1748 logbook_battery_voltage: 1617 logbook_battery_voltage:
1749 WIN_SMALL .110,.90 1618 WIN_SMALL .110,.90
1750 STRCAT_PRINT "Batt:" 1619 STRCAT_PRINT "Batt:"
1751 WIN_SMALL .110,.115 1620 WIN_SMALL .110,.115
1752 LOG_POINT_TO log_battery ; battery voltage 1621 LOG_POINT_TO log_battery ; address battery voltage
1753 call ext_flash_byte_read_plus ; read battery low 1622 call ext_flash_byte_read_plus ; read battery voltage, low byte
1754 movff ext_flash_rw,lo 1623 movff ext_flash_rw,lo ; store in lo
1755 call ext_flash_byte_read_plus ; read battery high 1624 call ext_flash_byte_read_plus ; read battery voltage, high byte
1756 movff ext_flash_rw,hi 1625 movff ext_flash_rw,hi ; store in hi
1757 output_16dp .2 1626 output_16dp .2 ; print battery voltage
1758 STRCAT_PRINT "V" 1627 STRCAT_PRINT "V" ; ...
1759 1628
1760 ; surface pressure in mbar 1629 LOG_POINT_TO log_surface_press ; address surface pressure in mbar
1761 LOG_POINT_TO log_surface_press 1630 call ext_flash_byte_read_plus ; read surface pressure, low byte
1762 call ext_flash_byte_read_plus ; read surface pressure 1631 movff ext_flash_rw,lo ; store in lo
1763 movff ext_flash_rw,lo 1632 call ext_flash_byte_read_plus ; read surface pressure, high byte
1764 call ext_flash_byte_read_plus ; read surface pressure 1633 movff ext_flash_rw,hi ; store in hi
1765 movff ext_flash_rw,hi 1634 WIN_SMALL .110,.165 ; set output position
1766 WIN_SMALL .110,.165 1635 lfsr FSR2,buffer ; set base address of output buffer
1767 lfsr FSR2,buffer 1636 bsf leftbind ; print without leading spaces
1768 bsf leftbind 1637 output_16 ; print air pressure before dive
1769 output_16 ; air pressure before dive 1638 STRCAT_TEXT tMBAR ; ...
1770 STRCAT_TEXT tMBAR 1639 clrf WREG ; string terminator
1771 clrf WREG
1772 movff WREG,buffer+7 ; limit to 7 chars 1640 movff WREG,buffer+7 ; limit to 7 chars
1773 STRCAT_PRINT "" 1641 STRCAT_PRINT "" ; dump buffer to screen
1774 1642
1775 movlw color_greenish 1643 movlw color_greenish ; select color
1776 call TFT_set_color 1644 call TFT_set_color ; ...
1777 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; Top, Bottom, Left, Right 1645 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; draw a frame around coordinates top, bottom, left, right
1778 1646
1779 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco 1647 rcall logbook_preloop_tasks ; clear timeout and remaining button events
1780 display_details_loop: 1648 display_details_loop:
1781 btfsc switch_right 1649 btfss switch_right ; right button pressed?
1782 bra logbook_page3 ; details, 2nd page 1650 bra display_details_loop_1 ; NO
1783 btfsc switch_left 1651 btfsc aux_flag ; YES - dive done in a deco mode?
1784 bra exit_profileview ; back to list 1652 bra logbook_page3 ; YES - show more details, 2nd page
1785 rcall log_screendump_and_onesecond ; check if we need to make a screenshot and check for new second 1653 goto display_profile2 ; NO - show the profile view again
1786 btfsc sleepmode ; timeout? 1654 display_details_loop_1:
1787 bra exit_profileview ; back to list 1655 btfsc switch_left ; left button pressed?
1788 bra display_details_loop ; wait for something to do 1656 bra exit_profileview ; YES - back to list
1789 1657 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode
1790 global logbook_preloop_tasks 1658 bra display_details_loop ; - loop waiting for something to do
1659
1660
1791 logbook_preloop_tasks: 1661 logbook_preloop_tasks:
1792 movlw CCP1CON_VALUE ; see hwos.inc 1662 movlw CCP1CON_VALUE ; see hwos.inc
1793 movwf CCP1CON ; power-on backlight 1663 movwf CCP1CON ; power-on backlight
1794 call TFT_standard_color 1664 call TFT_standard_color ; revert to standard color
1795 bcf sleepmode ; clear some flags 1665 call reset_timeout_surfmode ; reset timeout
1796 bcf switch_right 1666 bcf switch_left ; clear left-over left button event
1797 bcf switch_left 1667 bcf switch_right ; clear left-over right button event
1798 clrf timeout_counter2 1668 return ; done
1799 goto speed_normal ; and return
1800 1669
1801 1670
1802 logbook_page3: ; show even more info 1671 logbook_page3: ; show even more info
1803 rcall log_details_header ; shows number, time/date and basic dive info 1672 rcall log_details_header ; shows number, time/date and basic dive info
1804 LOG_POINT_TO log_gas1 1673 LOG_POINT_TO log_gas1
1828 ; OC/CC Gas List 1697 ; OC/CC Gas List
1829 WIN_SMALL .5,.65 1698 WIN_SMALL .5,.65
1830 WIN_COLOR color_greenish 1699 WIN_COLOR color_greenish
1831 LOG_POINT_TO log_divemode 1700 LOG_POINT_TO log_divemode
1832 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into ext_flash_rw 1701 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into ext_flash_rw
1833 decfsz ext_flash_rw,w ; =1 (CC)? 1702 decfsz ext_flash_rw,w ; =1 (CC)?
1834 bra logbook_page3a 1703 bra logbook_page3a
1835 STRCPY_TEXT_PRINT tGaslistCC 1704 STRCPY_TEXT_PRINT tGaslistCC
1836 bra logbook_page3b 1705 bra logbook_page3b
1837 logbook_page3a: 1706 logbook_page3a:
1838 STRCPY_TEXT_PRINT tGaslist 1707 STRCPY_TEXT_PRINT tGaslist
1839 logbook_page3b: 1708 logbook_page3b:
1840 movlw color_lightblue 1709 movlw color_lightblue
1841 call TFT_set_color 1710 call TFT_set_color
1842 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) 1711 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)
1843 1712
1844 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco 1713 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco
1845 display_details2_loop: 1714 display_details2_loop:
1846 btfsc switch_right 1715 btfsc switch_right ; right button pressed?
1847 goto logbook_page4 ; show more info 1716 goto logbook_page4 ; YES - show more info
1848 btfsc switch_left 1717 btfsc switch_left ; left button pressed?
1849 bra exit_profileview ; back to list 1718 bra exit_profileview ; YES - back to list
1850 rcall log_screendump_and_onesecond ; check if we need to make a screen shot and check for new second 1719 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode
1851 btfsc sleepmode ; timeout? 1720 bra display_details2_loop ; - loop waiting for something to do
1852 bra exit_profileview ; back to list
1853 bra display_details2_loop ; wait for something to do
1854 1721
1855 logbook_page4: ; show even more info in CC mode 1722 logbook_page4: ; show even more info in CC mode
1856 LOG_POINT_TO log_divemode 1723 LOG_POINT_TO log_divemode
1857 call ext_flash_byte_read ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into WREG and ext_flash_rw 1724 call ext_flash_byte_read ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into WREG and ext_flash_rw
1858 decfsz ext_flash_rw,w ; =1 (CC)? 1725 decfsz ext_flash_rw,w ; =1 (CC)?
1876 WIN_SMALL .5,.190 1743 WIN_SMALL .5,.190
1877 rcall log_show_sp 1744 rcall log_show_sp
1878 1745
1879 movlw color_greenish 1746 movlw color_greenish
1880 call TFT_set_color 1747 call TFT_set_color
1881 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; Top, Bottom, Left, Right 1748 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; top, bottom, left, right
1882 1749
1883 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco 1750 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco
1884 display_details3_loop: 1751 display_details3_loop:
1885 btfsc switch_right 1752 btfsc switch_right ; right button pressed?
1886 goto display_profile2 ; show the profile view again 1753 goto display_profile2 ; YES - show the profile view again
1887 btfsc switch_left 1754 btfsc switch_left ; left button pressed?
1888 bra exit_profileview ; back to list 1755 bra exit_profileview ; YES - back to list
1889 rcall log_screendump_and_onesecond ; check if we need to make a screenshot and check for new second 1756 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode
1890 btfsc sleepmode ; timeout? 1757 bra display_details3_loop ; - loop waiting for something to do
1891 bra exit_profileview ; back to list
1892 bra display_details3_loop ; wait for something to do
1893 1758
1894 1759
1895 log_details_header: 1760 log_details_header:
1896 clrf CCP1CON ; stop PWM
1897 bcf PORTC,2 ; Pull PWM out to GND
1898 call TFT_boot 1761 call TFT_boot
1899 ; call TFT_ClearScreen ; clear screen
1900 1762
1901 ; Set ext_flash pointer to "#divenumber-oldest" dive 1763 ; Set ext_flash pointer to "#divenumber-oldest" dive
1902 ; compute read_int_eeprom .2 - divenumber 1764 ; compute read_int_eeprom .2 - divenumber
1903 ; read required header data for profile display 1765 ; read required header data for profile display
1904 ; look in header for pointer to begin of diveprofile (Byte 2-4) 1766 ; look in header for pointer to begin of diveprofile (byte 2-4)
1905 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing 1767 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing
1906 1768
1907 decf divenumber,F ;-1 1769 decf divenumber,F ; -1
1908 read_int_eeprom .2 1770 read_int_eeprom .2
1909 movf EEDATA,W 1771 movf EEDATA,W
1910 bcf STATUS,C 1772 bcf STATUS,C
1911 subfwb divenumber,W ; max. dives (low value) - dive number 1773 subfwb divenumber,W ; max. dives (low value) - dive number
1912 movwf lo ; result 1774 movwf lo ; result
1957 movff ext_flash_rw,lo 1819 movff ext_flash_rw,lo
1958 call ext_flash_byte_read_plus ; read max depth 1820 call ext_flash_byte_read_plus ; read max depth
1959 movff ext_flash_rw,hi 1821 movff ext_flash_rw,hi
1960 1822
1961 TSTOSS opt_units ; 0=Meters, 1=Feets 1823 TSTOSS opt_units ; 0=Meters, 1=Feets
1962 bra logbook_page2_depth_metric 1824 bra logbook_page2_depth_metric ; 1 - do metric
1963 ; imperial 1825 ; 0 - do imperial
1964 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1826 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
1965 PUTC ' ' 1827 PUTC ' '
1966 bcf leftbind 1828 bcf leftbind
1967 output_16_3 1829 output_16_3
1968 STRCAT_TEXT tFeets 1830 STRCAT_TEXT tFeets
1973 output_16dp d'3' ; max. depth 1835 output_16dp d'3' ; max. depth
1974 STRCAT_TEXT tMeters 1836 STRCAT_TEXT tMeters
1975 1837
1976 logbook_page2_depth_common: 1838 logbook_page2_depth_common:
1977 STRCAT " - " 1839 STRCAT " - "
1978 call ext_flash_byte_read_plus ; divetime in minutes 1840 call ext_flash_byte_read_plus ; dive time in minutes
1979 movff ext_flash_rw,lo 1841 movff ext_flash_rw,lo
1980 call ext_flash_byte_read_plus 1842 call ext_flash_byte_read_plus
1981 movff ext_flash_rw,hi ; divetime in minutes 1843 movff ext_flash_rw,hi ; dive time in minutes
1982 1844
1983 bsf leftbind 1845 bsf leftbind
1984 output_16 ; divetime minutes 1846 output_16 ; dive time minutes
1985 PUTC "m" 1847 PUTC "m"
1986 LOG_POINT_TO log_divetime+.2 1848 LOG_POINT_TO log_divetime+.2
1987 call ext_flash_byte_read_plus ; read divetime seconds 1849 call ext_flash_byte_read_plus ; read dive time seconds
1988 movff ext_flash_rw,lo 1850 movff ext_flash_rw,lo
1989 bsf leftbind 1851 bsf leftbind
1990 output_99x ; divetime seconds 1852 output_99x ; dive time seconds
1991 call TFT_standard_color 1853 call TFT_standard_color
1992 STRCAT_PRINT "s" 1854 STRCAT_PRINT "s"
1993 ; ; Dive mode 1855 ; ; Dive mode
1994 ; LOG_POINT_TO log_divemode 1856 ; LOG_POINT_TO log_divemode
1995 ; call ext_flash_byte_read_plus ; read divemode 1857 ; call ext_flash_byte_read_plus ; read dive mode
1996 ; movff ext_flash_rw,lo 1858 ; movff ext_flash_rw,lo
1997 ; call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) 1859 ; call TFT_decotype_logbook ; "strcat_print"s dive mode (OC, CC, APNEA or GAUGE)
1998 return 1860 return
1999 1861
2000 ; ---------------------------------------------------------------- 1862 ; ----------------------------------------------------------------
2001 1863
2002 log_show_sp: 1864 log_show_sp:
2011 PUTC " " 1873 PUTC " "
2012 call ext_flash_byte_read_plus ; change depth 1874 call ext_flash_byte_read_plus ; change depth
2013 movff ext_flash_rw,lo 1875 movff ext_flash_rw,lo
2014 1876
2015 TSTOSS opt_units ; 0=Meter, 1=Feet 1877 TSTOSS opt_units ; 0=Meter, 1=Feet
2016 bra log_show_sp_metric 1878 bra log_show_sp_metric ; 0 - do metric
2017 movf lo,W 1879 movf lo,W ; 1 - do imperial
2018 mullw .100 ; convert meters to mbar 1880 mullw .100 ; convert meters to mbar
2019 movff PRODL,lo 1881 MOVII PROD,mpr
2020 movff PRODH,hi
2021 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1882 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
2022 output_16_3 1883 output_16_3
2023 PUTC " " 1884 PUTC " "
2024 STRCAT_TEXT tFeets ; "ft" 1885 STRCAT_TEXT tFeets ; "ft"
2025 bra log_show_sp_common 1886 bra log_show_sp_common
2037 lfsr FSR2,buffer 1898 lfsr FSR2,buffer
2038 call ext_flash_byte_read_plus ; read gas O2 fraction 1899 call ext_flash_byte_read_plus ; read gas O2 fraction
2039 movff ext_flash_rw,lo 1900 movff ext_flash_rw,lo
2040 call ext_flash_byte_read_plus ; read gas He fraction 1901 call ext_flash_byte_read_plus ; read gas He fraction
2041 movff ext_flash_rw,hi 1902 movff ext_flash_rw,hi
2042 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 1903 call gaslist_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
2043 call ext_flash_byte_read_plus ; read change depth 1904 call ext_flash_byte_read_plus ; read change depth
2044 movff ext_flash_rw,up 1905 movff ext_flash_rw,up
2045 call ext_flash_byte_read_plus ; read gas type - just to increment the pointer 1906 call ext_flash_byte_read_plus ; read gas type - just to increment the pointer
2046 movff ext_flash_rw,ex 1907 movff ext_flash_rw,ex
2047 1908
2067 log_show_gas_3: 1928 log_show_gas_3:
2068 PUTC " " ; print a space in absence of any other marking 1929 PUTC " " ; print a space in absence of any other marking
2069 log_show_gas_4: 1930 log_show_gas_4:
2070 PUTC " " ; put one space between gas type marking and change depth 1931 PUTC " " ; put one space between gas type marking and change depth
2071 TSTOSS opt_units ; 0=Meter, 1=Feet 1932 TSTOSS opt_units ; 0=Meter, 1=Feet
2072 bra log_show_gas_metric 1933 bra log_show_gas_metric ; 0 - do metric
2073 movf up,W 1934 movf up,W ; 1 - do imperial
2074 mullw .100 ; convert meters to mbar 1935 mullw .100 ; convert meters to mbar
2075 movff PRODL,lo 1936 MOVII PROD,mpr
2076 movff PRODH,hi
2077 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1937 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
2078 output_16_3 ; limit to 999 and display only 0-999 1938 output_16_3 ; limit to 999 and display only 0-999
2079 STRCAT_TEXT tFeets ; "ft" 1939 STRCAT_TEXT tFeets ; "ft"
2080 bra log_show_gas_common 1940 bra log_show_gas_common
2081 log_show_gas_metric: 1941 log_show_gas_metric:
2084 STRCAT_TEXT tMeters ; "m" 1944 STRCAT_TEXT tMeters ; "m"
2085 log_show_gas_common: 1945 log_show_gas_common:
2086 STRCAT_PRINT "" 1946 STRCAT_PRINT ""
2087 return 1947 return
2088 1948
1949
1950 log_compute_divenumber:
1951 movwf mpr+2 ; store current dive number to mpr+2
1952 call do_logoffset_common_read ; read log offset into mpr
1953 ; check if offset = 0
1954 tstfsz mpr+0 ; mpr+0 (low byte) = 0 ?
1955 bra log_compute_divenumber_2 ; NO - apply offset
1956 tstfsz mpr+1 ; mpr+1 (high byte) = 0 ?
1957 bra log_compute_divenumber_2 ; NO - apply offset
1958 log_compute_divenumber_1: ; YES to both - no offset
1959 movff mpr+2,mpr+0 ; use plain number from dive list
1960 clrf mpr+1 ; set high byte to 0
1961 return ; done
1962 log_compute_divenumber_2:
1963 ; check limit (offset must be < 10000)
1964 MOVLI .9999,sub_a ; sub_a = 9999
1965 MOVII mpr, sub_b ; sub_b = offset
1966 call cmpU16 ; 9999 - offset
1967 btfsc neg_flag ; result negative, i.e. offset > 9999 ?
1968 bc log_compute_divenumber_1 ; YES - ignore offset
1969 INCI mpr ; NO - increment offset by 1
1970 MOVII mpr,sub_a ; - sub_a = offset + 1
1971 movff mpr+2,sub_b+0 ; - sub_b = number from list (low byte)
1972 clrf sub_b+1 ; - high byte is 0
1973 call subU16 ; - sub_c = offset + 1 - (number from list)
1974 MOVII sub_c,mpr ; - copy result back to mpr
1975 return ; - done
1976
2089 ; ---------------------------------------------------------------- 1977 ; ----------------------------------------------------------------
2090 1978
2091 END 1979 END