comparison src/logbook.asm @ 631:185ba2f91f59

3.09 beta 1 release
author heinrichsweikamp
date Fri, 28 Feb 2020 15:45:07 +0100
parents 237931377539
children 4050675965ea
comparison
equal deleted inserted replaced
630:4cd81bdbf15c 631:185ba2f91f59
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File logbook.asm combined next generation V3.06.1 3 ; File logbook.asm combined next generation V3.08.8
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 ;=============================================================================
23 #include "menu_processor.inc" 23 #include "menu_processor.inc"
24 #include "start.inc" 24 #include "start.inc"
25 #include "surfmode.inc" 25 #include "surfmode.inc"
26 #include "divemode.inc" 26 #include "divemode.inc"
27 #include "ghostwriter.inc" 27 #include "ghostwriter.inc"
28 #include "rtc.inc"
29
30 #DEFINE inside_loogbook
31 #include "logbook.inc"
32
28 33
29 extern do_main_menu2 34 extern do_main_menu2
30 extern gaslist_show_mix 35 extern gaslist_show_mix
31 36
32 37
33 ;---- Private local variables ------------------------------------------------- 38 ;---- Private local variables ------------------------------------------------
34 39
35 CBLOCK local1 ; max size is 16 byte !!! 40 CBLOCK local1 ; max size is 16 byte !!!
36 count_temperature ; current sample count for temperature divisor 41 count_temperature ; current sample count for temperature divisor
37 count_deco ; current sample count for deco (ceiling) divisor 42 count_deco ; current sample count for deco (ceiling) divisor
38 logbook_cur_depth:2 ; current depth, for drawing profile 43 logbook_cur_depth:2 ; current depth, for drawing profile
64 CBLOCK local3 ; max size is 16 byte !!! 69 CBLOCK local3 ; max size is 16 byte !!!
65 divenumber ; used for accessing dives 70 divenumber ; used for accessing dives
66 vertical_interval:2 ; holds interval of samples for vertical 10min line 71 vertical_interval:2 ; holds interval of samples for vertical 10min line
67 backup_color1 ; used for restoring drawing color 72 backup_color1 ; used for restoring drawing color
68 backup_color2 ; used for restoring drawing color 73 backup_color2 ; used for restoring drawing color
69 salinity ; salinity during the dive
70 fill_between_rows ; used for fill between rows 74 fill_between_rows ; used for fill between rows
71 logbook_temp ; used as temp 75 logbook_temp ; used as temp
72 logbook_temp_backup ; used as backup for temp 76 logbook_temp_backup ; used as backup for temp
73 divisor_temperature ; divisor used while sampling of the dive data 77 divisor_temperature ; divisor used while sampling of the dive data
74 divisor_deco ; divisor used while sampling of the dive data 78 divisor_deco ; divisor used while sampling of the dive data
75 divisor_gf ; divisor used while sampling of the dive data 79 divisor_gf ; divisor used while sampling of the dive data
76 divisor_ppo2_sensors ; divisor used while sampling of the dive data 80 divisor_ppo2_sensors ; divisor used while sampling of the dive data
77 divisor_decoplan ; divisor used while sampling of the dive data 81 divisor_decoplan ; divisor used while sampling of the dive data
78 divisor_cns ; divisor used while sampling of the dive data 82 divisor_cns ; divisor used while sampling of the dive data
79 divisor_tank ; divisor used while sampling of the dive data 83 divisor_tank ; divisor used while sampling of the dive data
80 ENDC ; used: 16 byte, remaining: 0 byte => FULL 84 total_num_dives ; total number of dives (low byte on)
85 ENDC ; used: 16 byte, remaining: 0 byte => full
81 86
82 87
83 ; Remarks: The variable gaslist_gas is "misused" here as a local variable, 88 ; Remarks: The variable gaslist_gas is "misused" here as a local variable,
84 ; because the storage space for local variables is fully used up. 89 ; because the storage space for local variables is fully used up.
85 ; 90 ;
97 #DEFINE keep_cursor_new_page logbook_flags,4 102 #DEFINE keep_cursor_new_page logbook_flags,4
98 #DEFINE log_marker_found logbook_flags,5 103 #DEFINE log_marker_found logbook_flags,5
99 #DEFINE log_show_gas_short logbook_flags,6 104 #DEFINE log_show_gas_short logbook_flags,6
100 ; logbook_flags,7 ; unused 105 ; logbook_flags,7 ; unused
101 106
107
102 ; Logbook Coordinates 108 ; Logbook Coordinates
103 #DEFINE logbook_list_left .10 ; column of dive# in list 109 #DEFINE logbook_list_left .10 ; column of dive# in list
104 #DEFINE logbook_row_offset .27 ; distance between rows of list 110 #DEFINE logbook_row_offset .27 ; distance between rows of list
105 #DEFINE logbook_row_number .7 ; amount of rows in the list 111 #DEFINE logbook_row_number .7 ; number of dive entry rows per list
106 112
107 ; Profile display 113 ; Profile display
108 #DEFINE profile_height_pixels .157 ; amount of pixels height for profile display 114 #DEFINE profile_height_pixels .157 ; amount of pixels height for profile display
109 #DEFINE profile_width_pixels .156 ; amount of pixels width for profile display 115 #DEFINE profile_width_pixels .156 ; amount of pixels width for profile display
110 #DEFINE profile_left .1 ; left border 116 #DEFINE profile_left .1 ; left border
127 ; Max. Depth 133 ; Max. Depth
128 #DEFINE log_max_value_row .38 134 #DEFINE log_max_value_row .38
129 #DEFINE log_max_value_column .1 135 #DEFINE log_max_value_column .1
130 136
131 ; Divetime 137 ; Divetime
132 #DEFINE log_divetime_value_row .38 138 #DEFINE log_divetime_mins_value_row .38
133 #DEFINE log_divetime_value_column .60 139 #DEFINE log_divetime_mins_value_column .60
134 140
135 ; Gaslist below profile 141 ; Gaslist below profile
136 #DEFINE log_gas_row .225 142 #DEFINE log_gas_row .225
137 #DEFINE log_gas_column1 .0 143 #DEFINE log_gas_column1 .0
138 #DEFINE log_gas_column2 log_gas_column1+(.1*.32) 144 #DEFINE log_gas_column2 log_gas_column1+(.1*.32)
184 ; Air pressure 190 ; Air pressure
185 #DEFINE MBAR_row .10*.16+log2_salinity_row 191 #DEFINE MBAR_row .10*.16+log2_salinity_row
186 #DEFINE MBAR_column log2_salinity_column 192 #DEFINE MBAR_column log2_salinity_column
187 193
188 194
189 ; Header coordinates
190 #DEFINE log_profile_version .8
191 #DEFINE log_date .12
192 #DEFINE log_time .15
193 #DEFINE log_max_depth .17
194 #DEFINE log_divetime .19
195 #DEFINE log_min_temp .22
196 #DEFINE log_surface_press .24
197 #DEFINE log_desattime .26
198 #DEFINE log_gas1 .28
199 #DEFINE log_gas2 .32
200 #DEFINE log_gas3 .36
201 #DEFINE log_gas4 .40
202 #DEFINE log_gas5 .44
203 #DEFINE log_firmware .48
204 #DEFINE log_battery .50
205 #DEFINE log_samplingrate .52
206 #DEFINE log_cns_start .53
207 #DEFINE log_gf_start .55
208 #DEFINE log_gf_end .56
209 #DEFINE log_batt_info .59
210 #DEFINE log_sp1 .60
211 #DEFINE log_sp2 .62
212 #DEFINE log_sp3 .64
213 #DEFINE log_sp4 .66
214 #DEFINE log_sp5 .68
215 #DEFINE log_salinity .70
216 #DEFINE log_cns_end .71
217 #DEFINE log_avr_depth .73
218 #DEFINE log_total_seconds .75
219 #DEFINE log_gf_lo .77
220 #DEFINE log_sat_mult .77
221 #DEFINE log_gf_hi .78
222 #DEFINE log_desat_mult .78
223 #DEFINE log_decomodel .79
224 #DEFINE log_total_dives .80
225 #DEFINE log_divemode .82
226 #DEFINE log_last_stop .243
227
228
229 LOG_POINT_TO macro address
230 movlw address
231 movwf ext_flash_address+0
232 endm
233
234 logbook CODE 195 logbook CODE
235 196
236 ;============================================================================= 197 ;=============================================================================
237 198
238 TFT_logbook_cursor: 199 TFT_logbook_cursor:
239 WIN_BOX_BLACK .0, .239, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right 200 WIN_BOX_BLACK .0, .239, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right
240 201
241 WIN_LEFT logbook_list_left-.8 ; set horizontal position 202 WIN_LEFT logbook_list_left-.8 ; set horizontal position
242 WIN_FONT FT_SMALL ; select small font 203 WIN_FONT FT_SMALL ; select small font
243 ; bcf win_invert ; reset invert flag
244 call TFT_standard_color ; print in white color 204 call TFT_standard_color ; print in white color
245 decf menu_pos_cur,W ; get row number -1 into WREG 205 decf menu_pos_cur,W ; get row number -1 into WREG
246 mullw logbook_row_offset ; multiply with vertical offset between rows 206 mullw logbook_row_offset ; multiply with vertical offset between rows
247 movff PRODL,win_top ; set vertical position 207 movff PRODL,win_top ; set vertical position
248 STRCPY_PRINT "\xB7" ; print cursor 208 STRCPY_PRINT "\xB7" ; print cursor
249 return ; done 209 return ; done
250 210
251 211
252 global logbook ; entry point coming from menu_tree.asm 212 global logbook ; entry point coming from menu_tree.asm
253 logbook: 213 logbook:
254 clrf logbook_flags
255 call TFT_boot 214 call TFT_boot
256 ; call TFT_standard_color 215 ; call TFT_standard_color
257 clrf menu_pos_max ; number of used rows on current logbook-page 216
217 clrf logbook_flags ; clear all flags
218 clrf menu_pos_max ; clear number of used rows on current page
258 clrf logbook_page_number ; here: # of current displayed page 219 clrf logbook_page_number ; here: # of current displayed page
259 clrf logbook_divenumber ; # of dive in list during search 220 clrf logbook_divenumber ; # of dive in list during search
260 clrf logbook_temp 221 clrf logbook_temp
261 clrf logbook_temp_backup 222 clrf logbook_temp_backup
262 movlw logbook_row_number 223
263 movwf menu_pos_cur ; number of current position on display (logbook_row_number-x) 224 movlw logbook_row_number ; get number of dive entry rows per list
264 read_int_eeprom .2 ; get low-byte of total dives 225 movwf menu_pos_cur ; initialize cursor position to last entry
265 movff EEDATA,logbook_max_dive_counter 226
266 227 call eeprom_total_dives_read ; read total number of dives
267 ;----------------------------------------------------------------------------- 228 movf mpr+0,W ; extract low byte
268 ; display dive headers backwards from read_int_eeprom .2 = lo-1 229 movwf logbook_max_dive_counter ; copy to logbook_max_dive_counter
269 ; 1st: 200000h-200FFFh -> lo=0 230 movwf total_num_dives ; copy to total_num_dives, too
270 ; 2nd: 201000h-201FFFh -> lo=1 231
271 ; 3rd: 202000h-202FFFh -> lo=2 232
272 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) 233 ;-----------------------------------------------------------------------------
273 ; Stop when 234 ; display dive headers backwards from latest dive to first dive, stop when
274 ; a) no dive is stored (no valid header found) 235 ; - no dive is stored (no valid header found)
275 ; b) current dive has no valid header (Number of stored dives < 256) 236 ; - current dive has no valid header (past last dive, < 256 dives)
276 ; c) when 255 dives are reached logbook_temp = 255 237 ; - when 255 dives are reached (logbook display limit)
277 238
278 logbook2: 239 logbook2:
279 incf logbook_temp,F ; increase dive counter 240 incf logbook_temp,F ; increase dive counter
280 incf logbook_temp,W ; = 0x..FF ? 241 incf logbook_temp,W ; = 0x..FF ?
281 bz logbook_reset ; YES - ..FF --> loop 242 bz logbook_reset ; YES - loop
282 243
283 ; Set ext_flash_address:3 to TOC entry of this dive 244 ; compute index for dive to show / goto previous dive
284 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0 245 decf logbook_max_dive_counter,F
285 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1 246
286 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2 247 ; compute the start address of the header of the dive to show
287 ; 256: 2FF000h-2FFFFFh -> logbook_max_dive_counter=255 (and hi>0...) 248 movf logbook_max_dive_counter,W ; hand over index in WREG
288 249 call log_header_addr_by_index ; compute address of header start
289 decf logbook_max_dive_counter,F ; -1 250
290 251 ; copy the first 22 byte of the header from FLASH to memory
291 clrf ext_flash_address+0 252 FLASH_RR_READ mpr,header_buffer,.22
292 clrf ext_flash_address+1 253
293 movlw 0x20 254 ; check if there is a header
294 movwf ext_flash_address+2 255 MOVCC header_buffer+index_header_start,WREG ; read first byte of header
295 movlw .16 256 xorlw 0xFA ; header start code found?
296 mulwf logbook_max_dive_counter ; logbook_max_dive_counter*16 = offset to 0x2000 (up:hi) 257 bnz logbook3b ; NO - abort
297 movf PRODL,W
298 addwf ext_flash_address+1,F
299 movf PRODH,W
300 addwfc ext_flash_address+2,F
301 ; pointer at the first 0xFA of header
302
303 call ext_flash_byte_read ; reads one byte@ext_flash_address:3 into WREG and ext_flash_rw
304 movwf ext_flash_rw
305 movlw 0xFA
306 cpfseq ext_flash_rw ; 0xFA found?
307 bra logbook3b ; NO - abort
308 incf logbook_divenumber,F ; YES - new header found, increase logbook_divenumber 258 incf logbook_divenumber,F ; YES - new header found, increase logbook_divenumber
309 bra logbook4 ; - done with searching, display the header 259 bra logbook4 ; - done with searching, display the header
310 260
311 logbook3b: 261 logbook3b:
312 btfss logbook_page_not_empty ; was there at least one dive? 262 btfss logbook_page_not_empty ; was there at least one dive?
313 bra exit_logbook ; not a single header was found, leave logbook 263 bra exit_logbook ; NO - not a single header was found, leave logbook
314 bra logbook_display_loop2 264 bra logbook_display_loop2 ; YES - can show something
315 265
316 logbook_reset: 266 logbook_reset:
317 tstfsz logbook_divenumber ; was there at least one dive? 267 tstfsz logbook_divenumber ; was there at least one dive?
318 bra logbook_reset2 268 bra logbook_reset2 ; YES - proceed
319 bra logbook3b ; NO - nothing to do 269 bra logbook3b ; NO - nothing to do
320 270
321 logbook_reset2: 271 logbook_reset2:
322 bsf all_dives_shown ; YES 272 bsf all_dives_shown ; flag all dives are shown
323 bra logbook_display_loop2 ; continue 273 bra logbook_display_loop2 ; check number of dives on page and append navigation
324 274
325 logbook4: 275 logbook4:
326 btfsc all_dives_shown ; all dives displayed? 276 btfsc all_dives_shown ; all dives shown?
327 bra logbook_display_loop2 ; YES - display first page again 277 bra logbook_display_loop2 ; YES - page done
328 call display_listdive ; NO - display short header for list on current list position 278 call display_listdive ; NO - display short header for list on current list position
329 movlw logbook_row_number ; - 279 movlw logbook_row_number ; - load max number of lines
330 cpfseq menu_pos_cur ; - first dive on list (top row)? 280 cpfseq menu_pos_cur ; - cursor on last line (exit)?
331 bra logbook_display_loop1 ; NO - skip saving of address 281 bra logbook_display_loop1 ; NO - skip saving of address
332 282
333 ; store all registers required to rebuilt the current logbook page after the detail/profile view 283 ; store all registers required to rebuilt the current logbook page after the detail/profile view
334 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page 284 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page
335 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup counter 285 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup counter
336 movff logbook_temp,logbook_temp_backup ; amount of dives drawn until now 286 movff logbook_temp,logbook_temp_backup ; amount of dives drawn until now
337 287
338 logbook_display_loop1: 288 logbook_display_loop1:
339 decfsz menu_pos_cur,F ; list full? 289 decfsz menu_pos_cur,F ; all lines used up?
340 bra logbook2 ; NO - search another dive for our current logbook page 290 bra logbook2 ; NO - loop to show another dive
341
342 logbook_display_loop2: 291 logbook_display_loop2:
343 btfss logbook_page_not_empty ; was there one dive at all? 292 btfss logbook_page_not_empty ; YES - was there one dive at all?
344 bra logbook ; YES - so reload the first page 293 bra logbook ; NO - restart from the first page
345 294 ;bra logbook_display_loop3 ; YES - complete page and start HMI
346 ; TFT_mask... 295
347 296 logbook_display_loop3:
297
298 ; print navigation lines
348 WIN_LEFT logbook_list_left 299 WIN_LEFT logbook_list_left
349 WIN_TOP logbook_row_offset*(logbook_row_number+.0) 300 WIN_TOP logbook_row_offset*(logbook_row_number+.0)
350 STRCPY_TEXT_PRINT tNextLog ; "Next Page" 301 STRCPY_TEXT_PRINT tNextLog ; "Next Page"
351 302
352 WIN_LEFT logbook_list_left 303 WIN_LEFT logbook_list_left
353 WIN_TOP logbook_row_offset*(logbook_row_number+.1) 304 WIN_TOP logbook_row_offset*(logbook_row_number+.1)
354 STRCPY_TEXT_PRINT tExit ; "Exit" 305 STRCPY_TEXT_PRINT tExit ; "Exit"
355 306
356 movlw d'1' ; set cursor to position 1... 307 movlw d'1' ; default cursor to position 1
357 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view 308 btfsc return_from_profileview ; returning from a detail/profile view?
358 movf logbook_menupos_temp,W ; load last cursor position again 309 movf logbook_menupos_temp,W ; YES - reload last cursor position
359 movwf menu_pos_cur ; and set menu_pos_cur byte 310 movwf menu_pos_cur ; set cursor position
360 bcf return_from_profileview ; do this only once while the page is loaded again 311 movlw logbook_row_number+.1 ; get menu line where the next page item is
361 312 btfsc keep_cursor_new_page ; do we come from the "next page" line?
313 movwf menu_pos_cur ; YES - set cursor to "next line" again
314
315 bcf return_from_profileview ; clear flag for returning from detail/profile view
316 bcf keep_cursor_new_page ; clear flag for coming from "next page"
362 bcf logbook_page_not_empty ; obviously the current page is NOT empty 317 bcf logbook_page_not_empty ; obviously the current page is NOT empty
363
364 movlw d'8' ; set cursor to position 7...
365 btfsc keep_cursor_new_page ; ... if we came from the "new page" line
366 movwf menu_pos_cur ; and set menu_pos_cur byte
367 bcf keep_cursor_new_page
368 318
369 call TFT_logbook_cursor ; show the cursor 319 call TFT_logbook_cursor ; show the cursor
370 320
371 logbook_loop_pre: 321 logbook_loop_pre:
372 call logbook_preloop_tasks ; clear timeout, some flags and switch on backlight 322 call logbook_preloop_tasks ; clear timeout, some flags and switch on backlight
373 logbook_loop: 323 logbook_loop:
374 btfsc switch_left ; left button pressed? 324 btfsc switch_left ; left button pressed?
375 goto next_logbook3 ; YES - adjust cursor or create new page 325 goto next_logbook3 ; YES - move cursor
376 btfsc switch_right ; right button pressed? 326 btfsc switch_right ; NO - right button pressed?
377 bra display_profile_or_exit ; YES - view details/profile or exit logbook 327 bra display_profile_or_exit ; YES - view details/profile
378 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode 328 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode
379 bra logbook_loop ; - loop waiting for something to do 329 bra logbook_loop ; - loop waiting for something to do
380 330
381 display_profile_or_exit: 331 display_profile_or_exit:
382 movlw logbook_row_number+.2 ; exit? 332 movlw logbook_row_number+.2 ; get menu line were the exit item is
383 cpfseq menu_pos_cur ; YES 333 cpfseq menu_pos_cur ; cursor on exit line?
384 bra display_profile_or_exit2 ; NO - check for "Next Page" 334 bra display_profile_or_next ; NO - show profile or next page
335 ;bra exit_logbook ; YES - exit logbook
385 336
386 exit_logbook: 337 exit_logbook:
387 bcf switch_right ; clear pending button events 338 bcf switch_right ; clear pending button events
388 bcf switch_left ; ... 339 bcf switch_left ; ...
389 goto do_main_menu2 ; jump-back to menu_tree.asm 340 goto do_main_menu2 ; jump-back to main menu (in menu_tree.asm)
390 341
391 display_profile_or_exit2: 342 display_profile_or_next:
392 movlw logbook_row_number+.1 ; 343 movlw logbook_row_number+.1 ; get menu line were the next page item is
393 cpfseq menu_pos_cur ; do next page? 344 cpfseq menu_pos_cur ; cursor on next page line?
394 bra display_profile ; NO - show details/profile 345 bra display_profile ; NO - show profile of selected dive
395 goto next_logbook2 ; YES - next page 346 goto next_logbook2 ; YES - show next page
396 347
348 ;-----------------------------------------------------------------------------
349 ; show graphical dive profile
350 ;
397 display_profile: 351 display_profile:
398 bcf bailout_mode ; clear event flag 352 bcf bailout_mode ; clear event flag
399 bcf event_gas_change_gas6 ; clear event flag 353 bcf event_gas_change_gas6 ; clear event flag
400 movff menu_pos_cur,logbook_menupos_temp ; store current cursor position 354 movff menu_pos_cur,logbook_menupos_temp ; store current cursor position
401 bsf return_from_profileview ; tweak search routine to exit after found 355 bsf return_from_profileview ; tweak search routine to exit after found
402 356
403 movf logbook_page_number,W ; number of page 357 ; compute the number of the dive to show
404 mullw logbook_row_number 358 movf logbook_page_number,W ; get page number of page we are on
405 movf PRODL,W 359 mullw logbook_row_number ; multiply with number of dives per page
406 addwf menu_pos_cur,W ; page * logbook_row_number + menu_pos_cur = 360 movf PRODL,W ; copy low byte to WREG
407 movwf divenumber ; # of dive to show 361 addwf menu_pos_cur,W ; add number of selected dive on current page page
362 movwf divenumber ; result is the number of the dive to show
363
364 ; compute the header address by the dive number
365 call log_header_addr_by_divenumber
366
367 ; copy the complete header from FLASH to memory
368 FLASH_RR_READ mpr,header_buffer,.256
369
370 ; read the sampling rate
371 MOVCC header_buffer+index_samplingrate,sampling_rate
372
373 ; --- start drawing the dive profile page ---
408 374
409 display_profile2: 375 display_profile2:
410 call TFT_boot 376 call TFT_boot
411
412 ; set ext_flash pointer to "#divenumber-oldest" dive
413 ; compute read_int_eeprom .2 - divenumber
414 ; read required header data for profile display
415 ; look in header for pointer to begin of dive profile (Byte 2-4)
416 ; set pointer (ext_flash_log_pointer:3) to this address, start drawing
417
418 decf divenumber,F ; -1
419 read_int_eeprom .2
420 movf EEDATA,W
421 bcf STATUS,C
422 subfwb divenumber,W ; max. dives (low value) - dive number
423 movwf lo ; result
424 incf divenumber,F ; +1
425 ; Set ext_flash_address:3 to TOC entry of this dive
426 ; 1st: 200000h-200FFFh -> lo=0
427 ; 2nd: 201000h-201FFFh -> lo=1
428 ; 3rd: 202000h-202FFFh -> lo=2
429 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
430 clrf ext_flash_address+0
431 clrf ext_flash_address+1
432 movlw 0x20
433 movwf ext_flash_address+2
434 movlw .16
435 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
436 movf PRODL,W
437 addwf ext_flash_address+1,F
438 movf PRODH,W
439 addwfc ext_flash_address+2,F
440 ; pointer at the first 0xFA of header
441
442 ; Now, show profile
443 LOG_POINT_TO log_samplingrate
444 call ext_flash_byte_read ; read sampling rate
445 movff ext_flash_rw,sampling_rate ; store for later use
446
447 LOG_POINT_TO .2
448 call ext_flash_byte_read_plus ; read start address of profile
449 movff ext_flash_rw,ext_flash_log_pointer+0
450 call ext_flash_byte_read_plus ; read start address of profile
451 movff ext_flash_rw,ext_flash_log_pointer+1
452 call ext_flash_byte_read_plus ; read start address of profile
453 movff ext_flash_rw,ext_flash_log_pointer+2
454
455 CLRI logbook_sample_counter ; holds amount of read samples
456
457 call TFT_standard_color 377 call TFT_standard_color
378
379 ; show dive number
458 call logbook_show_divenumber ; show the dive number in medium font 380 call logbook_show_divenumber ; show the dive number in medium font
459 381
382 ; show date
460 WIN_SMALL logbook_date_column, logbook_date_row 383 WIN_SMALL logbook_date_column, logbook_date_row
461 LOG_POINT_TO log_date 384 MOVTT header_buffer+index_date,mpr ; read date
462 call ext_flash_byte_read_plus
463 movff ext_flash_rw,up ; year
464 call ext_flash_byte_read_plus
465 movff ext_flash_rw,hi ; month
466 call ext_flash_byte_read_plus
467 movff ext_flash_rw,lo ; day
468 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 385 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
469 STRCAT_PRINT "" 386 STRCAT_PRINT ""
470 387
471 WIN_SMALL log_divetime_value_column,logbook_date_row ; align with surrounding data 388 ; show dive mode
472 LOG_POINT_TO log_divemode 389 WIN_SMALL log_divetime_mins_value_column,logbook_date_row ; align with surrounding data
473 call ext_flash_byte_read_plus ; read dive mode 390 MOVCC header_buffer+index_divemode,lo ; read dive type (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR)
474 movff ext_flash_rw,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR
475 call TFT_decotype_logbook ; "strcat_print"s dive mode (OC, CC, Gauge, Apnea or pSCR) 391 call TFT_decotype_logbook ; "strcat_print"s dive mode (OC, CC, Gauge, Apnea or pSCR)
476 ; also sets aux_flag in case the dive was done in a deco mode 392 ; also sets aux_flag in case the dive was done in a deco mode
477 393
394 ; show time
478 WIN_SMALL logbook_time_column, logbook_time_row 395 WIN_SMALL logbook_time_column, logbook_time_row
479 LOG_POINT_TO log_time 396 MOVII header_buffer+index_time,mpr ; get time
480 call ext_flash_byte_read_plus ; hour 397 output_99x ; print hour
481 movff ext_flash_rw,lo 398 PUTC ':' ; print spacing ":"
482 call ext_flash_byte_read_plus ; minutes 399 movff hi,lo ; print minute
483 movff ext_flash_rw,hi 400 output_99x ; ...
484 output_99x ; hour
485 PUTC ':'
486 movff hi,lo
487 output_99x ; minute
488 STRCAT_PRINT "" ; display 1st row of details 401 STRCAT_PRINT "" ; display 1st row of details
489 402
490 LOG_POINT_TO log_profile_version 403 ; get log format version
491 call ext_flash_byte_read_plus ; profile version 404 MOVCC header_buffer+index_profile_version,lo ; read profile format version
492 movlw 0x24 405 movlw 0x24
493 cpfslt ext_flash_rw ; < 0x24 ? 406 cpfslt lo ; < 0x24 ?
494 bra log_skip_extra_icon ; YES - skip 407 bra log_skip_extra_icon ; YES - skip end of dive icon
495 408
409 ; print end of dive icon
496 WIN_SMALL logbook_time_column-.8, logbook_time_row 410 WIN_SMALL logbook_time_column-.8, logbook_time_row
497 STRCPY_PRINT 0x94 ; "End of dive" icon 411 STRCPY_PRINT 0x94
498 412
499 log_skip_extra_icon: 413 log_skip_extra_icon:
500 LOG_POINT_TO log_max_depth 414 MOVII header_buffer+index_max_depth,mpr ; get max depth in [mbar]
501 call ext_flash_byte_read_plus ; read max depth 415
502 movff ext_flash_rw,lo 416 ; compute vertical scale (y-axis)
503 call ext_flash_byte_read_plus ; read max depth 417 MOVII mpr,xA
504 movff ext_flash_rw,hi 418 MOVLI profile_height_pixels,xB ; number of pixels available for plot
505 MOVII mpr,xA ; calculate y-scale for profile display
506 MOVLI profile_height_pixels,xB ; pixel height available for profile
507 call div16x16 ; xC = xA / xB with xA as remainder 419 call div16x16 ; xC = xA / xB with xA as remainder
508 MOVII xC,y_scale ; y-scale (mbar/pixel) 420 MOVII xC,y_scale ; y-scale (mbar/pixel)
509 INCI y_scale ; increase one, because there may be a remainder 421 INCI y_scale ; increase by one to include potential remainder (round up)
510 422
423 ; compute number of pixels per each 10 m
511 movlw LOW ((profile_height_pixels+1)*.1000) 424 movlw LOW ((profile_height_pixels+1)*.1000)
512 movwf xC+0 425 movwf xC+0
513 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF') 426 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF')
514 movwf xC+1 427 movwf xC+1
515 movlw UPPER ((profile_height_pixels+1)*.1000) 428 movlw UPPER ((profile_height_pixels+1)*.1000)
516 movwf xC+2 429 movwf xC+2
517 clrf xC+3 430 clrf xC+3
518 431 MOVII mpr,xB ; get max. depth in mbar
519 MOVII mpr,xB ; max. Depth in mbar
520 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder 432 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
521 MOVII xC,x_scale ; Pixels/10m (for scale, draw any xx rows a scale-line) 433 MOVII xC,x_scale ; pixels/10m (for scale, draw any xx rows a scale-line)
522 434
523 movf x_scale+0,W 435 ; safeguard scale to become zero
524 iorwf x_scale+1,W ; x_scale:2 = zero ? 436 movf x_scale+0,W ; get low byte
525 bnz display_profile_offset4 ; NO - continue 437 iorwf x_scale+1,W ; ior with high byte
526 incf x_scale+1,F ; YES - make x_scale+1>1 to make "display_profile2e" working 438 btfsc STATUS,Z ; x_scale = zero ?
527 439 incf x_scale+1,F ; YES - set to 256 to make "display_profile2e" working
528 display_profile_offset4: 440
441 ; calculate vertical interval
442 MOVLI .600,xA ; a vertical line every 600 seconds (10 minutes)
443 movff sampling_rate,xB+0 ; copy sampling rate to xB, low byte
444 clrf xB+1 ; clear xB, high byte
445 call div16x16 ; xC=xA/xB with xA as remainder
446 MOVII xC,vertical_interval ; vertical_interval:2 holds number of samples between each vertical 10 min lines
447
448 ; get total sample time in seconds
449 MOVII header_buffer+index_total_seconds,xA
450
451 ; calculate x-scale value
452 MOVLI profile_width_pixels,xB ; horizontal width of plot area in pixels
453 call div16x16 ; xC = xA / xB with xA as remainder: seconds per pixel
454 MOVII xC,xA ; copy seconds/pixel to xA
455 movff sampling_rate,xB+0 ; divide through sampling rate
456 clrf xB+1 ; ...
457 call div16x16 ; xC = xA / xB with xA as remainder: samples per pixel
458 MOVII xC,profile_temp1 ; store samples/pixel
459 INCI profile_temp1 ; increment result by 1 to include potential remainder (round up)
460
529 WIN_SMALL log_max_value_column,log_max_value_row 461 WIN_SMALL log_max_value_column,log_max_value_row
530 462
463 ; get max depth in [mbar]
464 MOVII header_buffer+index_max_depth,mpr
465
466 ; print depth
531 TSTOSS opt_units ; 0=Meters, 1=Feets 467 TSTOSS opt_units ; 0=Meters, 1=Feets
532 bra display_profile_offset4_metric ; 0 - do metric 468 bra display_profile_offset4_metric ; 0 - do metric
533 ; 1 - do imperial 469 ;bra display_profile_offset4_imperial ; 1 - do imperial
534 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 470
471 display_profile_offset4_imperial:
472 call convert_cm_to_feet ; convert value in mpr from [cm] to [feet]
535 PUTC ' ' 473 PUTC ' '
536 bcf leftbind 474 bcf leftbind
537 output_16_3 ; limit to 999 and display only (0-999) 475 output_16_3 ; limit to 999 and display only (0-999)
538 STRCAT_TEXT_PRINT tFeets 476 STRCAT_TEXT_PRINT tFeets
539 bra display_profile_offset4_common 477 bra display_profile_offset4_common
540 478
541 display_profile_offset4_metric: 479 display_profile_offset4_metric:
480 bsf ignore_digit5 ; no cm...
481 movlw d'1' ; no 1000 m
482 movwf ignore_digits ; ...
483 output_16dp d'3' ; xxx.y
484 STRCAT_TEXT_PRINT tMeters
485 ;bra display_profile_offset4_common
486
487 display_profile_offset4_common:
488 WIN_SMALL log_divetime_mins_value_column,log_divetime_mins_value_row
542 bsf leftbind 489 bsf leftbind
543 output_16dp d'3' ; max. depth 490
544 STRCAT_TEXT_PRINT tMeters 491 ; show dive time minutes : seconds
545 492 MOVTT header_buffer+index_divetime,mpr ; get dive time
546 display_profile_offset4_common: 493 output_16 ; print dive time minutes
547 call ext_flash_byte_read_plus ; dive time in minutes 494 PUTC 'm' ; print "m" (minutes)
548 movff ext_flash_rw,lo 495 movff up,lo ; print dive time seconds
549 call ext_flash_byte_read_plus
550 movff ext_flash_rw,hi ; dive time in minutes
551
552 MOVII mpr,xA ; calculate x-scale for profile display, calculate total dive seconds first
553 MOVLI .60,xB ; 60 seconds are one minute
554 call mult16x16 ; result is in xC:2
555
556 WIN_SMALL log_divetime_value_column,log_divetime_value_row
557 bsf leftbind
558 output_16 ; dive time minutes
559 MOVLI .600,xA ; a vertical line every 600 seconds
560 movff sampling_rate,xB+0 ; copy sampling rate to xB, low byte
561 clrf xB+1 ; clear xB, high byte
562 call div16x16 ; xA/xB=xC with xA as remainder
563 MOVII xC,vertical_interval ; vertical_interval:2 holds interval of samples for vertical 10min line
564
565 ; Restore dive time in minutes:
566 ; get real sample time
567 LOG_POINT_TO log_total_seconds
568 call ext_flash_byte_read_plus ; total sample time in seconds
569 movff ext_flash_rw,xC+0
570 call ext_flash_byte_read_plus ; total sample time in seconds
571 movff ext_flash_rw,xC+1
572
573 PUTC ':'
574 LOG_POINT_TO log_divetime+.2
575 call ext_flash_byte_read_plus ; read dive time seconds
576 movff ext_flash_rw,lo
577 MOVII xC,xA ; now calculate x-scale value
578 MOVLI profile_width_pixels,xB ; pix width available
579 call div16x16 ; xC = xA / xB with xA as remainder
580 MOVII xC,xA
581 movff sampling_rate,xB+0 ; divide through sampling rate (time interval)
582 clrf xB+1
583 call div16x16 ; xC = xA / xB with xA as remainder
584 MOVII xC,profile_temp1 ; store value (use any #xC sample, skip xC-1) into temp registers
585 INCI profile_temp1 ; increase by one, there might be a remainder
586
587 bsf leftbind
588 output_99x ; dive time seconds 496 output_99x ; dive time seconds
589 call TFT_standard_color 497 STRCAT_PRINT "s" ; print "s" (seconds)
590 STRCAT_PRINT "" 498
591 499 ; get minimum temperature (for later use)
592 call ext_flash_byte_read_plus ; read min. temperature, low byte 500 MOVII header_buffer+index_min_temp,logbook_min_tp
593 movff ext_flash_rw,logbook_min_tp+0 501
594 call ext_flash_byte_read_plus ; read min. temperature, high byte 502 ; print gases
595 movff ext_flash_rw,logbook_min_tp+1
596
597 btfss aux_flag ; dive done in a deco mode? 503 btfss aux_flag ; dive done in a deco mode?
598 bra logbook_set_gas_color ; NO - always use gas 1 color (white) then 504 bra logbook_set_gas_color ; NO - always use gas 1 color (white) then
599 505
600 ; Set pointer to gas 1 type 506 ; set pointer to gas 1 type
601 LOG_POINT_TO log_gas1+.3 507 MOVCC header_buffer+index_gas1+.3,WREG ; read gas type
602 call ext_flash_byte_read_plus ; read gas type 508 decfsz WREG,W ; = 1 (= "First") ?
603 decfsz ext_flash_rw,W ; = 1 (= "First") ?
604 bra logbook_find_first_gas2 ; NO 509 bra logbook_find_first_gas2 ; NO
605 logbook_set_gas_color: 510 logbook_set_gas_color:
606 movlw .1 ; YES - select white color 511 movlw .1 ; YES - select white color
607 movwf ext_flash_rw
608 bra logbook_find_first_gas_done 512 bra logbook_find_first_gas_done
513
609 logbook_find_first_gas2: 514 logbook_find_first_gas2:
610 ; Set pointer to gas 2 type 515 ; set pointer to gas 2 type
611 LOG_POINT_TO log_gas2+.3 516 MOVCC header_buffer+index_gas2+.3,WREG ; read gas type
612 call ext_flash_byte_read_plus ; read gas type 517 decfsz WREG,W ; = 1 (= "First") ?
613 decfsz ext_flash_rw,W ; = 1 (= "First") ?
614 bra logbook_find_first_gas3 ; NO 518 bra logbook_find_first_gas3 ; NO
615 movlw .2 ; YES - select green color 519 movlw .2 ; YES - select green color
616 movwf ext_flash_rw
617 bra logbook_find_first_gas_done 520 bra logbook_find_first_gas_done
521
618 logbook_find_first_gas3: 522 logbook_find_first_gas3:
619 ; Set pointer to gas 3 type 523 ; set pointer to gas 3 type
620 LOG_POINT_TO log_gas3+.3 524 MOVCC header_buffer+index_gas3+.3,WREG ; read gas type
621 call ext_flash_byte_read_plus ; read gas type 525 decfsz WREG,W ; = 1 (= "First") ?
622 decfsz ext_flash_rw,W ; = 1 (= "First") ?
623 bra logbook_find_first_gas4 ; NO 526 bra logbook_find_first_gas4 ; NO
624 movlw .3 ; YES - select red color 527 movlw .3 ; YES - select red color
625 movwf ext_flash_rw
626 bra logbook_find_first_gas_done 528 bra logbook_find_first_gas_done
529
627 logbook_find_first_gas4: 530 logbook_find_first_gas4:
628 ; Set pointer to gas 4 type 531 ; set pointer to gas 4 type
629 LOG_POINT_TO log_gas4+.3 532 MOVCC header_buffer+index_gas4+.3,WREG ; read gas type
630 call ext_flash_byte_read_plus ; read gas type 533 decfsz WREG,W ; = 1 (= "First") ?
631 decfsz ext_flash_rw,W ; = 1 (= "First") ?
632 bra logbook_find_first_gas5 ; NO 534 bra logbook_find_first_gas5 ; NO
633 movlw .4 ; YES - select yellow color 535 movlw .4 ; YES - select yellow color
634 movwf ext_flash_rw
635 bra logbook_find_first_gas_done 536 bra logbook_find_first_gas_done
537
636 logbook_find_first_gas5: 538 logbook_find_first_gas5:
637 movlw .5 ; must be gas 5, select cyan color 539 ; must be gas 5 then
638 movwf ext_flash_rw 540 movlw .5 ; select cyan color
541 ;bra logbook_find_first_gas_done
542
639 logbook_find_first_gas_done: 543 logbook_find_first_gas_done:
640 movff ext_flash_rw,backup_color1 ; keep copy to restore color 544 movwf backup_color1 ; keep copy of color for later restore
641 movff ext_flash_rw,WREG ; copy gas number to WREG for color coding
642 call TFT_color_code_gas ; set color 545 call TFT_color_code_gas ; set color
643 ; Pointer is now trashed! 546
644 547 ; set ext_flash_address to the begin of the profile data
645 ; Point to profile portion of this dive 548 MOVTT header_buffer+index_profile_start_address,ext_flash_address
646 movff ext_flash_log_pointer+0,ext_flash_address+0 549
647 movff ext_flash_log_pointer+1,ext_flash_address+1 550 ; skip the 0xFA 0xFA header of the profile data
648 movff ext_flash_log_pointer+2,ext_flash_address+2 551 ext_flash_inc_address_0x20 d'2'
649 552
650 incf_ext_flash_address_0x20 d'2' ; skip 0xFA 0xFA 553 ; initialize flag for signaling when last sample set was read
651 call ext_flash_byte_read_plus_0x20 ; read low byte of total dives into ext_flash_rw (at the time the dive was made) 554 bcf end_of_profile
652 555
653 ; Load total number of dives (low byte only) 556 ; check if the profile actually belongs to this dive (check done with low bytes only)
654 read_int_eeprom .2 557 FLASH_CC_READ_0x20 lo ; read dive number in profile
655 incf EEDATA,W ; +1 558 incf total_num_dives,W ; WREG = total number of dives + 1
656 bsf STATUS,C ; set borrow 559 bsf STATUS,C ; set borrow
657 subfwb divenumber,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made) 560 subfwb divenumber,W ; WREG = total number of dives - number of dive to show - 1
658 cpfseq ext_flash_rw ; # of dive in logbook (Must be equal with low byte in short header) 561 cpfseq lo ; number of dive in profile = number of dive to show?
659 bra display_profile_no_profile ; not equal, no profile for this dive available 562 bra display_profile_no_profile ; NO - no profile data for this dive available
660 563 ;bra display_profile_show_profile ; YES - show profile
661 ; Skip rest of short header: 3 Bytes 564
662 ; Skip length of profile data: 3 Bytes 565 display_profile_show_profile:
663 ; Skip sampling rate in profile section: 1Byte 566
664 ; Skip number of divisors: 1Byte 567 ; skip high byte of dive number 1 byte
665 incf_ext_flash_address_0x20 d'8' 568 ; skip second header code 2 byte
666 569 ; skip length of profile data 3 byte
667 ; divisor temp 570 ; skip sampling rate in profile section 1 byte
668 incf_ext_flash_address_0x20 d'2' 571 ; skip number of divisors 1 byte
669 ; call ext_flash_byte_read_plus_0x20 ; read information type 572 ; ======
670 ; call ext_flash_byte_read_plus_0x20 ; read information length 573 ; total number of bytes to skip = 8 byte
671 call ext_flash_byte_read_plus_0x20 ; read information divisor 574 ext_flash_inc_address_0x20 d'8'
672 movf ext_flash_rw,W 575
673 movwf divisor_temperature ; store divisor 576 ; read divisor temp
674 movwf count_temperature ; store to tp° counter, too 577 ext_flash_inc_address_0x20 d'2' ; skip information type and length
675 ; divisor deco 578 FLASH_CW_READ_0x20 ; read temperature divisor
676 incf_ext_flash_address_0x20 d'2' 579 movwf divisor_temperature ; store temperature divisor
677 ; call ext_flash_byte_read_plus_0x20 ; read information type 580 movwf count_temperature ; store to temperature counter, too
678 ; call ext_flash_byte_read_plus_0x20 ; read information length 581
679 call ext_flash_byte_read_plus_0x20 ; read information divisor 582 ; read divisor deco
680 movf ext_flash_rw,W 583 ext_flash_inc_address_0x20 d'2' ; skip information type and length
681 movwf divisor_deco ; store divisor 584 FLASH_CW_READ_0x20 ; read deco divisor
682 movwf count_deco ; store as temp, too 585 movwf divisor_deco ; store deco divisor
683 ; divisor GF 586 movwf count_deco ; store to deco status counter, too
684 incf_ext_flash_address_0x20 d'2' 587
685 ; call ext_flash_byte_read_plus_0x20 ; read information type 588 ; read divisor GF
686 ; call ext_flash_byte_read_plus_0x20 ; read information length 589 ext_flash_inc_address_0x20 d'2' ; skip information type and length
687 call ext_flash_byte_read_plus_0x20 ; read information divisor 590 FLASH_CC_READ_0x20 divisor_gf ; store saturation divisor
688 movff ext_flash_rw,divisor_gf ; store divisor 591
689 ; divisor ppO2 sensors 592 ; read divisor ppO2 sensors
690 incf_ext_flash_address_0x20 d'2' 593 ext_flash_inc_address_0x20 d'2' ; skip information type and length
691 ; call ext_flash_byte_read_plus_0x20 ; read information type 594 FLASH_CC_READ_0x20 divisor_ppo2_sensors ; store ppO2 divisor
692 ; call ext_flash_byte_read_plus_0x20 ; read information length 595
693 call ext_flash_byte_read_plus_0x20 ; read information divisor 596 ; read divisor deco plan
694 movff ext_flash_rw,divisor_ppo2_sensors ; store divisor 597 ext_flash_inc_address_0x20 d'2' ; skip information type and length
695 ; divisor decoplan 598 FLASH_CC_READ_0x20 divisor_decoplan ; store deco plan divisor
696 incf_ext_flash_address_0x20 d'2' 599
697 ; call ext_flash_byte_read_plus_0x20 ; read information type 600 ; read divisor CNS
698 ; call ext_flash_byte_read_plus_0x20 ; read information length 601 ext_flash_inc_address_0x20 d'2' ; skip information type and length
699 call ext_flash_byte_read_plus_0x20 ; read information divisor 602 FLASH_CC_READ_0x20 divisor_cns ; store CNS divisor
700 movff ext_flash_rw,divisor_decoplan ; store divisor 603
701 ; divisor CNS 604 ; read divisor tank data
702 incf_ext_flash_address_0x20 d'2' 605 ext_flash_inc_address_0x20 d'2' ; skip information type and length
703 ; call ext_flash_byte_read_plus_0x20 ; read information type 606 FLASH_CC_READ_0x20 divisor_tank ; store tank pressure divisor
704 ; call ext_flash_byte_read_plus_0x20 ; read information length 607
705 call ext_flash_byte_read_plus_0x20 ; read information divisor 608
706 movff ext_flash_rw,divisor_cns ; store divisor 609 ; start drawing the profile
707 ; divisor tank data 610
708 incf_ext_flash_address_0x20 d'2' 611 ; set color
709 ; call ext_flash_byte_read_plus_0x20 ; read information type
710 ; call ext_flash_byte_read_plus_0x20 ; read information length
711 call ext_flash_byte_read_plus_0x20 ; read information divisor
712 movff ext_flash_rw,divisor_tank ; store divisor
713
714 ; Start profile display
715 movlw color_deepblue 612 movlw color_deepblue
716 call TFT_set_color 613 call TFT_set_color
717 ; Draw a frame around profile area 614
615 ; draw a frame around profile area
718 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 616 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1
719 617
720 movlw profile_top 618 ; draw depth grid
721 movwf win_top 619 movlw profile_top ; set top position of plot area
722 movlw profile_left 620 movwf win_top ; ...
723 movwf win_leftx2 ; left border (0-159) 621 movlw profile_left ; set left position of plot area
724 movlw d'1' 622 movwf win_leftx2 ; ...
725 movwf win_height 623 movlw d'1' ; draw lines of 1 pixel width
726 movlw profile_width_pixels+.1 624 movwf win_height ; ...
727 movwf win_width+0 ; right border (0-159) 625 movlw profile_width_pixels+.1 ; set right position of plot area
728 clrf win_width+1 626 movwf win_width+0 ; ...
729 bra display_profile2f ; no 0m line 627 clrf win_width+1 ; ...
730 display_profile2e: 628 bra display_profile2_loline ; do not draw the 0 m line
731 call TFT_box ; inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 629 display_profile2_loop:
732 display_profile2f: 630 call TFT_box ; draw the line
733 movf win_top,W ; get row 631 display_profile2_loline:
734 addwf x_scale+0,W ; add line interval distance to win_top 632 movf win_top,W ; get last row drawn
735 tstfsz x_scale+1 ; > 255 ? 633 addwf x_scale+0,W ; add line interval distance, low byte
736 movlw d'255' ; YES - make win_top>239 -> abort here 634 tstfsz x_scale+1 ; interval distance > 255 ?
737 btfsc STATUS,C ; a carry from the addwf above? 635 movlw d'255' ; YES - would make win_top > 239 -> prepare abort
738 movlw d'255' ; YES - make win_top>239 -> abort here 636 btfsc STATUS,C ; did the add produce a carry?
739 movwf win_top ; result in win_top again 637 movlw d'255' ; YES - would make win_top > 239 -> prepare abort
740 movlw profile_top+profile_height_pixels+.1 ; limit 638 movwf win_top ; write position of next line back to win_top
741 cpfsgt win_top ; > 239 ? 639 movlw profile_top+profile_height_pixels+.1 ; get limit for last line
742 bra display_profile2e ; NO - draw another line 640 cpfsgt win_top ; line to draw beyond limit?
743 641 bra display_profile2_loop ; NO - draw the line
642
643 ; do various initializations for drawing the curves
744 clrf gaslist_gas ; here: used as counter for depth readings 644 clrf gaslist_gas ; here: used as counter for depth readings
745 movlw profile_width_pixels+profile_left-.1 645 movlw profile_width_pixels+profile_left-.1
746 movwf ignore_digits ; here: used as counter for x-pixels 646 movwf ignore_digits ; here: used as counter for x-pixels
747 bcf end_of_profile ; clear flag
748 647
749 movlw profile_left+.1 648 movlw profile_left+.1
750 movwf logbook_pixel_x_pos ; here: used as column x2 (start at column 5) 649 movwf logbook_pixel_x_pos ; here: used as column x2 (start at column 5)
751 650
752 movlw profile_top+.1 ; zero-m row 651 movlw profile_top+.1 ; zero-m row
753 movwf fill_between_rows 652 movwf fill_between_rows
754 movwf logbook_last_tp ; initialize for Tp° curve, too 653 movwf logbook_last_tp ; initialize for temperature curve, too
755 654
756 movlw LOW(-.100) ; initialize max tp° to -10.0 °C 655 movlw LOW(-.100) ; initialize max temperature to -10.0 °C
757 movwf logbook_max_tp+0 656 movwf logbook_max_tp+0
758 movlw HIGH 0xFFFF & (-.100) 657 movlw HIGH 0xFFFF & (-.100)
759 movwf logbook_max_tp+1 658 movwf logbook_max_tp+1
760 659
761 setf logbook_cur_tp+0 ; initialize Tp°, before the first recorded point 660 setf logbook_cur_tp+0 ; initialize temperature to 0xFFFF = 'no data'
762 setf logbook_cur_tp+1 661 setf logbook_cur_tp+1 ; ...
763 clrf logbook_last_tp ; also reset previous Y for Tp° 662 clrf logbook_last_tp ; also reset previous Y for temperature
764 clrf logbook_ceiling ; ceiling = 0, correct value for no ceiling 663 clrf logbook_ceiling ; ceiling = 0, correct value for no ceiling
765 movlw profile_top+.1 664 movlw profile_top+.1
766 movwf logbook_min_temp_pos ; initialize for displaying the lowest temperature 665 movwf logbook_min_temp_pos ; initialize for displaying the lowest temperature
767 movlw profile_top+profile_height_pixels 666 movlw profile_top+profile_height_pixels
768 movwf logbook_max_temp_pos ; initialize for displaying the highest temperature 667 movwf logbook_max_temp_pos ; initialize for displaying the highest temperature
779 movwf win_width+1 678 movwf win_width+1
780 call TFT_box_write ; open box for d1 679 call TFT_box_write ; open box for d1
781 680
782 ; INIT_PIXEL_WRITE logbook_pixel_x_pos ; pixel x2 (also sets standard color!) 681 ; INIT_PIXEL_WRITE logbook_pixel_x_pos ; pixel x2 (also sets standard color!)
783 682
683 ; start profile plotting loop
684 CLRI logbook_sample_counter ; clear counter for amount of samples read so far
685
784 profile_display_loop: 686 profile_display_loop:
785 ; Init pixel write 687 ; initialize pixel write
786 movf logbook_pixel_x_pos,W 688 movf logbook_pixel_x_pos,W
787 mullw 2 689 mullw 2
788 call pixel_write_col320 690 call pixel_write_col320
789 691
790 MOVII profile_temp1,profile_temp2 ; 16 bit x-scaler 692 MOVII profile_temp1,profile_temp2 ; 16 bit x-scaler
793 tstfsz profile_temp2+0 ; must not be zero, is zero? 695 tstfsz profile_temp2+0 ; must not be zero, is zero?
794 bra profile_display_loop2 ; NO - ok 696 bra profile_display_loop2 ; NO - ok
795 incf profile_temp2+0,F ; YES - increase by 1 697 incf profile_temp2+0,F ; YES - increase by 1
796 698
797 profile_display_loop2: 699 profile_display_loop2:
798 rcall profile_view_get_depth ; reads depth, temp and profile data 700 rcall profile_view_get_depth ; read one set of depth, temp and event data
799 701 btfsc end_of_profile ; end of profile data reached?
800 btfsc end_of_profile ; end-of profile reached?
801 bra profile_display_loop_done ; YES - skip all remaining pixels 702 bra profile_display_loop_done ; YES - skip all remaining pixels
802 703
803 704
804 ;---- Draw Ceiling curve, if any --------------------------------------------- 705 ;---- draw ceiling curve, if any ---------------------------------------------
805 movf divisor_deco,W 706
806 bz profile_display_skip_deco 707 movf divisor_deco,W ; get divisor, deco data logged?
708 bz profile_display_skip_deco ; NO - skip
807 709
808 movf logbook_ceiling,W ; any deco ceiling? 710 movf logbook_ceiling,W ; any deco ceiling?
809 bz profile_display_skip_deco 711 bz profile_display_skip_deco ; NO - skip
810 712
811 mullw .100 ; YES - convert to mbar 713 mullw .100 ; YES - convert to mbar
812 MOVII PROD, sub_a ; ceiling depth 714 MOVII PROD, sub_a ; - ceiling depth
813 MOVII logbook_cur_depth+0,sub_b ; current depth 715 MOVII logbook_cur_depth+0,sub_b ; - current depth
814 call cmpU16 ; ceiling - current depth 716 call cmpU16 ; - compute ceiling - current depth
815 717 movlw color_dark_green ; - dark green if ok
816 movlw color_dark_green ; dark green if ok 718 btfss neg_flag ; - current depth > ceiling ?
817 btfss neg_flag ; current depth > ceiling ? 719 movlw color_dark_red ; NO - dark red because ceiling is violated
818 movlw color_dark_red ; NO - dark red because ceiling is violated 720 call TFT_set_color ; - set color
819 call TFT_set_color 721 MOVII PROD,xA ; - divide pressure in mbar/pixel for row offset
820 722 MOVII y_scale,xB ; - ...
821 MOVII PROD,xA 723 call div16x16 ; - xC = xA / xB with xA as remainder
822 MOVII y_scale,xB ; divide pressure in mbar/quant for row offset 724 movlw profile_top+.1 ; - start right after the top line
823 call div16x16 ; xC = xA / xB with xA as remainder 725 movwf win_top ; - ...
824 726 movff logbook_pixel_x_pos,win_leftx2 ; - set left border (0-159)
825 movlw profile_top+.1 ; starts right after the top line 727 movff xC+0,win_height ; - set hight
826 movwf win_top 728 call half_vertical_line ; - color the area
827 movff logbook_pixel_x_pos,win_leftx2 ; left border (0-159)
828 movff xC+0,win_height
829 call half_vertical_line ; inputs: win_top, win_leftx2, win_height, win_color1, win_color2
830 729
831 profile_display_skip_deco: 730 profile_display_skip_deco:
832 ;---- Draw Tp° curve, if any --------------------------------------------- 731
833 movf divisor_temperature,W 732 ;---- draw temperature curve, if any ---------------------------------------------
834 bz profile_display_skip_temp 733
835 734 movf divisor_temperature,W ; get divisor, deco data logged?
836 movf logbook_cur_tp+0,W ; did we had already a valid Tp°C record? 735 bz profile_display_skip_temp ; NO - skip
837 andwf logbook_cur_tp+1,W 736
838 incf WREG 737 movf logbook_cur_tp+0,W ; did we had a valid temperature record already (0xFF = 'no data')?
839 bz profile_display_skip_temp ; NO - just skip drawing 738 andwf logbook_cur_tp+1,W ; ...
840 739 incf WREG ; ...
841 movlw LOW (((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix 740 bz profile_display_skip_temp ; NO - skip drawing
741
742 ; fixed temperature scale: (-2 .. +35°C * scale256 ) / 153 pixel
743 movlw LOW (((profile_height_pixels-.10)*.256)/.370)
842 movwf xB+0 744 movwf xB+0
843 movlw HIGH (((profile_height_pixels-.10)*.256)/.370) 745 movlw HIGH (((profile_height_pixels-.10)*.256)/.370)
844 movwf xB+1 746 movwf xB+1
845 747
846 movf logbook_cur_tp+0,W ; current Tp° - (-2.0°C) == Tp° + 20 748 movf logbook_cur_tp+0,W ; current temperature - (-2.0°C) == temperature + 20
847 addlw LOW(.20) ; low byte 749 addlw LOW(.20) ; low byte
848 movwf xA+0 750 movwf xA+0
849 movf logbook_cur_tp+1,W 751 movf logbook_cur_tp+1,W
850 btfsc STATUS,C ; propagate carry, if any 752 btfsc STATUS,C ; propagate carry, if any
851 incf WREG 753 incf WREG
852 movwf xA+1 754 movwf xA+1
853 call mult16x16 ; xA*xB=xC 755 call mult16x16 ; xA*xB=xC
854 756
855 ; scale: divide by 256, ie. take just high byte. 757 ; scale: divide by 256 -> just take the high byte
856 movf xC+1,W 758 movf xC+1,W
857 sublw profile_top+profile_height_pixels-.10 ; upside-down: Y = .75 + (.153 - result) 759 sublw profile_top+profile_height_pixels-.10 ; upside-down: Y = .75 + (.153 - result)
858 movwf xC+0 760 movwf xC+0
859 761
860 ; check limits 762 ; check limits
865 767
866 movlw color_orange ; select color for temperature curve 768 movlw color_orange ; select color for temperature curve
867 call TFT_set_color ; set color 769 call TFT_set_color ; set color
868 770
869 movf logbook_last_tp,W ; do we have a valid previous value? 771 movf logbook_last_tp,W ; do we have a valid previous value?
870 bz profile_display_temp_1 ; NO - skip the vertical line 772 bz profile_display_temp_1 ; NO - skip the vertical line
871 movwf xC+1 773 movwf xC+1 ; YES - set end position
872 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) 774 call profile_display_fill ; - draw in this column between this row (xC+0) and the last row (xC+1)
775
873 profile_display_temp_1: 776 profile_display_temp_1:
874 movf xC+0,W ; current row 777 movf xC+0,W ; get position
875 cpfsgt logbook_min_temp_pos ; check limit 778 cpfsgt logbook_min_temp_pos ; > min limit?
876 movwf logbook_min_temp_pos ; lowest row in the temp graph 779 movwf logbook_min_temp_pos ; NO - set to lowest position for the temp graph
877 cpfslt logbook_max_temp_pos ; check limit 780 cpfslt logbook_max_temp_pos ; < max limit?
878 movwf logbook_max_temp_pos ; highest row in the temp graph 781 movwf logbook_max_temp_pos ; NO - set to highest position for the temp graph
879 782
880 movff xC+0,logbook_last_tp 783 movff xC+0,logbook_last_tp ; set col (0..159) x row (0..239)
881 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col (0..159) x row (0..239), put a current color pixel 784 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; draw a pixel
882 785
883 profile_display_skip_temp: 786 profile_display_skip_temp:
884 ;---- Draw depth curve --------------------------------------------------- 787
885 MOVII y_scale, xB ; divide pressure in mbar/quant for row offset 788 ;---- draw depth curve ---------------------------------------------------
886 MOVII logbook_cur_depth,xA 789
790 MOVII y_scale, xB ; divide pressure in mbar/pixel for row offset
791 MOVII logbook_cur_depth,xA ; get current depth
887 call div16x16 ; xC = xA / xB with xA as remainder 792 call div16x16 ; xC = xA / xB with xA as remainder
888 movlw profile_top+.1 793 movlw profile_top+.1 ; get offset
889 addwf xC+0,F ; add 75 pixel offset to result 794 addwf xC+0,F ; add offset
890 795 btfsc STATUS,C ; profile error?
891 btfsc STATUS,C ; ignore potential profile errors 796 movff fill_between_rows,xC+0 ; YES - ignore
892 movff fill_between_rows,xC+0 797
893 798 movf backup_color1,W ; copy gas number to WREG for color-coding
894 movff backup_color1,WREG ; copy gas number to WREG for color-coding 799 call TFT_color_code_gas ; set color
895 call TFT_color_code_gas ; back to normal profile color 800
896 801 movff fill_between_rows,xC+1 ; set position
897 movff fill_between_rows,xC+1
898 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) 802 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1)
899 movff xC+0,fill_between_rows ; store last row for fill routine 803 movff xC+0,fill_between_rows ; store last row for fill routine
900 804
901 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col (0..159) x row (0..239), put a std color pixel 805 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; draw a pixel
902 incf logbook_pixel_x_pos,F ; next column 806 incf logbook_pixel_x_pos,F ; advance to next column
903 807
904 ;---- Draw Marker square, if any ----------------------------------------- 808 ;---- draw marker square, if any -----------------------------------------
809
905 btfss log_marker_found ; any marker to draw? 810 btfss log_marker_found ; any marker to draw?
906 bra profile_display_skip_marker ; NO 811 bra profile_display_skip_marker ; NO - skip
907 812 bcf log_marker_found ; YES - clear flag
908 ; tiny "m" 813
814 ; set position
909 incf fill_between_rows,W ; increase row (Y) 815 incf fill_between_rows,W ; increase row (Y)
910 movwf win_top 816 movwf win_top
817
911 ; limit win_top to 220 818 ; limit win_top to 220
912 movlw .220 819 movlw .220
913 cpfslt win_top 820 cpfslt win_top
914 movwf win_top 821 movwf win_top
915 decf logbook_pixel_x_pos,W ; decrease column (X) 822 decf logbook_pixel_x_pos,W ; decrease column (X)
916 movwf win_leftx2 823 movwf win_leftx2
824
917 ; limit win_leftx2 to 151 825 ; limit win_leftx2 to 151
918 movlw .151 826 movlw .151
919 cpfslt win_leftx2 827 cpfslt win_leftx2
920 movwf win_leftx2 828 movwf win_leftx2
921 829
830 ; print marker
922 movlw color_orange 831 movlw color_orange
923 call TFT_set_color 832 call TFT_set_color
924 WIN_FONT FT_TINY 833 WIN_FONT FT_TINY
925 lfsr FSR2,buffer 834 lfsr FSR2,buffer
926 STRCPY_PRINT "m" 835 STRCPY_PRINT "m"
927 bcf log_marker_found ; clear flag
928 836
929 movlw profile_left 837 movlw profile_left
930 movwf win_leftx2 838 movwf win_leftx2
931 movlw profile_top 839 movlw profile_top
932 movwf win_top 840 movwf win_top
937 movlw HIGH (profile_width_pixels*.2) 845 movlw HIGH (profile_width_pixels*.2)
938 movwf win_width+1 846 movwf win_width+1
939 call TFT_box_write ; re-open box for d1 847 call TFT_box_write ; re-open box for d1
940 848
941 profile_display_skip_marker: 849 profile_display_skip_marker:
942 ;---- Draw CNS curve, if any --------------------------------------------- 850
943 movf divisor_cns,W 851 ;---- draw CNS curve, if any ---------------------------------------------
944 bz profile_display_skip_cns 852
853 movf divisor_cns,W ; get divisor, CNS logged?
854 bz profile_display_skip_cns ; NO - skip
945 ; 855 ;
946 ; add further code here... 856 ; add further code here...
947 ; 857 ;
858
948 profile_display_skip_cns: 859 profile_display_skip_cns:
949 860
950 ;---- Draw GF curve, if any ---------------------------------------------- 861 ;---- draw saturation curve, if any --------------------------------------
951 movf divisor_gf,W 862
952 bz profile_display_skip_gf 863 movf divisor_gf,W ; get divisor, saturation logged?
864 bz profile_display_skip_gf ; NO - skip
953 ; 865 ;
954 ; add further code here... 866 ; add further code here...
955 ; 867 ;
868
956 profile_display_skip_gf: 869 profile_display_skip_gf:
957 870
958 ;---- All curves done 871 ; all curves done
959
960 profile_display_skip_loop1: ; skips readings
961 dcfsnz profile_temp2+0,F
962 bra profile_display_loop3 ; check 16bit
963
964 rcall profile_view_get_depth ; reads depth, temp and profile data
965
966 btfsc end_of_profile ; end-of profile reached?
967 bra profile_display_loop_done ; YES - skip all remaining pixels
968
969 bra profile_display_skip_loop1 872 bra profile_display_skip_loop1
970 873
874
875 profile_display_skip_loop1:
876 dcfsnz profile_temp2+0,F ; decrement low byte of x-scaler, became zero?
877 bra profile_display_loop3 ; YES - decrement high byte
878 rcall profile_view_get_depth ; NO - read next depth, temp and profile data set
879 btfsc end_of_profile ; - end-of profile reached?
880 bra profile_display_loop_done ; YES - skip all remaining pixels
881 bra profile_display_skip_loop1 ; NO - continue
882
971 profile_display_loop3: 883 profile_display_loop3:
972 decfsz profile_temp2+1,F ; 16 bit x-scaler test 884 decfsz profile_temp2+1,F ; decrement high byte of x-scaler, became zero?
973 bra profile_display_skip_loop1 ; skips readings 885 bra profile_display_skip_loop1 ; NO - continue
974 886 decfsz ignore_digits,F ; YES - count drown x-pixels to zero, became zero?
975 decfsz ignore_digits,F ; counts drawn x-pixels to zero 887 bra profile_display_loop ; NO - draw next sample
976 bra profile_display_loop ; not ready yet 888 bra profile_display_loop_done ; YES - done
977 ; done
978
979 display_profile_no_profile: ; no profile available for this dive
980 889
981 profile_display_loop_done: 890 profile_display_loop_done:
982 btfss bailout_mode ; bailout during the dive? 891 btfss bailout_mode ; bailout during the dive?
983 bra profile_display_loop_done_nobail ; NO 892 bra profile_display_gas6 ; NO - skip next
984 ; YES - show "Bailout" 893 movlw color_pink ; YES - show "Bailout" in pink color
985 movlw color_pink 894 call TFT_set_color ; - ...
986 call TFT_set_color 895 WIN_TINY logbook_bailout_column,logbook_bailout_row; - ...
987 WIN_TINY logbook_bailout_column,logbook_bailout_row 896 STRCPY_TEXT_PRINT tDiveBailout ; - print text
988 STRCPY_TEXT_PRINT tDiveBailout ; bailout 897
989 profile_display_loop_done_nobail: 898 profile_display_gas6:
990 btfss event_gas_change_gas6 ; did a change to gas 6 occurred? 899 btfss event_gas_change_gas6 ; did a change to gas 6 occurred?
991 bra profile_display_loop_done_nogas6 ; NO 900 bra profile_display_temperatures ; NO - skip next
992 movlw color_pink ; YES - select color 901 movlw color_pink ; YES - select color
993 call TFT_set_color ; - set color 902 call TFT_set_color ; - set color
994 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 903 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15
995 STRCPY_TEXT tGas ; - print "Gas" 904 STRCPY_TEXT tGas ; - print "Gas"
996 STRCAT_PRINT " 6!" ; - print " 6!" 905 STRCAT_PRINT " 6!" ; - print " 6!"
997 906
998 profile_display_loop_done_nogas6: 907 profile_display_temperatures:
999 decf divenumber,F ; -1 908 movff logbook_min_temp_pos,win_top ; get Y position at lowest temperature
1000 read_int_eeprom .2 909 movff logbook_pixel_x_pos,win_leftx2 ; get X ...
1001 movf EEDATA,W 910 movlw .130 ; left border limit
1002 bcf STATUS,C 911 cpfslt win_leftx2 ; too far to the left?
1003 subfwb divenumber,W ; max. dives (low value) - dive number 912 movwf win_leftx2 ; YES - set to limit
1004 movwf lo ; result 913 WIN_FONT FT_TINY ; select font
1005 incf divenumber,F ; +1 914 movlw color_yellow ; select color
1006 ; set ext_flash_address:3 to TOC entry of this dive 915 call TFT_set_color ; set color
1007 ; 1st: 200000h-200FFFh -> lo=0 916
1008 ; 2nd: 201000h-201FFFh -> lo=1 917 MOVII logbook_min_tp,mpr ; get min temperature
1009 ; 3rd: 202000h-202FFFh -> lo=2 918 lfsr FSR2,buffer ; initialize string buffer
1010 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
1011 clrf ext_flash_address+0
1012 clrf ext_flash_address+1
1013 movlw 0x20
1014 movwf ext_flash_address+2
1015 movlw .16
1016 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
1017 movf PRODL,W
1018 addwf ext_flash_address+1,F
1019 movf PRODH,W
1020 addwfc ext_flash_address+2,F
1021 ; pointer at the first 0xFA of header
1022
1023 movff logbook_min_temp_pos,win_top ; Y position at lowest temperature
1024 movff logbook_pixel_x_pos,win_leftx2
1025 movlw .130
1026 cpfslt win_leftx2 ; limit left border to 130
1027 movwf win_leftx2
1028 WIN_FONT FT_TINY
1029 movlw color_yellow ; changed from color_orange to color_yellow for better readability
1030 call TFT_set_color
1031
1032 MOVII logbook_min_tp,mpr
1033 lfsr FSR2,buffer
1034 919
1035 TSTOSS opt_units ; 0=°C, 1=°F 920 TSTOSS opt_units ; 0=°C, 1=°F
1036 bra logbook_show_temp_metric ; 0 - do Celsius 921 bra logbook_show_temp_metric ; 0 - do Celsius
1037 ; 1 - do Fahrenheit 922 ;bra logbook_show_temp_imperial ; 1 - do Fahrenheit
1038 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 923
924 logbook_show_temp_imperial:
925 ; min temperature
926 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required
1039 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit 927 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit
1040 lfsr FSR2,buffer ; overwrite "-" 928 lfsr FSR2,buffer ; overwrite "-"
1041 bsf ignore_digit5 ; full degrees only 929 bsf ignore_digit5 ; full degrees only
1042 output_16 930 output_16
1043 STRCAT_TEXT_PRINT tLogTunitF 931 STRCAT_TEXT_PRINT tLogTunitF
1044 ; Now, the max. temperature 932 ; max temperature
1045 movlw .15 933 movlw .15
1046 subwf logbook_max_temp_pos,W 934 subwf logbook_max_temp_pos,W
1047 movff WREG,win_top ; Y position at max temperature 935 movwf win_top ; Y position at max temperature
1048 MOVII logbook_max_tp,mpr 936 MOVII logbook_max_tp,mpr
1049 lfsr FSR2,buffer 937 lfsr FSR2,buffer
1050 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 938 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
1051 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit 939 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit
1052 output_16 940 output_16
1053 bcf ignore_digit5 941 bcf ignore_digit5
1054 STRCAT_TEXT_PRINT tLogTunitF 942 STRCAT_TEXT_PRINT tLogTunitF
1055 943 bra logbook_show_gases
1056 bra logbook_show_temp_common
1057 944
1058 logbook_show_temp_metric: 945 logbook_show_temp_metric:
1059 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 946 ; min temperature
947 call TFT_convert_signed_16bit ; convert lo:hi into signed-short and add '-' to POSTINC2 if required
1060 movlw d'3' 948 movlw d'3'
1061 movwf ignore_digits 949 movwf ignore_digits
1062 bsf leftbind 950 bsf leftbind
1063 output_16dp d'2' ; temperature 951 output_16dp d'2' ; temperature
1064 STRCAT_TEXT_PRINT tLogTunitC 952 STRCAT_TEXT_PRINT tLogTunitC
1065 ; Now, the max. temperature 953 ; max temperature
1066 movlw .15 954 movlw .15
1067 subwf logbook_max_temp_pos,W 955 subwf logbook_max_temp_pos,W
1068 movwf win_top ; Y position at max temperature 956 movwf win_top ; Y position at max temperature
1069 MOVII logbook_max_tp,mpr 957 MOVII logbook_max_tp,mpr
1070 lfsr FSR2,buffer 958 lfsr FSR2,buffer
1072 movlw d'3' 960 movlw d'3'
1073 movwf ignore_digits 961 movwf ignore_digits
1074 bsf leftbind 962 bsf leftbind
1075 output_16dp d'2' ; temperature 963 output_16dp d'2' ; temperature
1076 STRCAT_TEXT_PRINT tLogTunitC 964 STRCAT_TEXT_PRINT tLogTunitC
1077 965 bra logbook_show_gases
1078 logbook_show_temp_common: 966
967
968 display_profile_no_profile:
969 ; print message "No Data anymore..."
970 WIN_SMALL .4,.110 ; set text size and position
971 call TFT_disabled_color ; use the color for disabled things
972 STRCPY_TEXT_PRINT tNoProfileData ; print message
973
974
975 logbook_show_gases:
1079 bcf leftbind 976 bcf leftbind
1080 call TFT_standard_color 977 call TFT_standard_color
1081 978
1082 btfss aux_flag ; dive done in a deco mode? 979 btfss aux_flag ; dive done in a deco mode?
1083 bra logbook_show_gases_done ; NO 980 bra logbook_show_gases_done ; NO - don't show gases
1084 981
1085 ; show gases 982 ; show gases
1086 LOG_POINT_TO log_gas1 ; get pointer to gaslist 983 lfsr FSR0,header_buffer+index_gas1 ; load base address of gases
1087 bsf log_show_gas_short ; do the short version of log_show_gas 984 bsf log_show_gas_short ; do the short version of log_show_gas
1088 bsf leftbind 985 bsf leftbind
1089 986
1090 WIN_TINY log_gas_column1, log_gas_row 987 WIN_TINY log_gas_column1, log_gas_row
1091 movlw .1 ; color for gas 1 988 movlw .1 ; color for gas 1
1112 logbook_show_gases_done: 1009 logbook_show_gases_done:
1113 1010
1114 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco 1011 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco
1115 display_profile_loop: 1012 display_profile_loop:
1116 btfsc switch_right ; right button pressed? 1013 btfsc switch_right ; right button pressed?
1117 bra logbook_page2 ; YES - show more information 1014 bra logbook_page1 ; YES - show more information
1118 btfsc switch_left ; left button pressed? 1015 btfsc switch_left ; NO - left button pressed?
1119 bra exit_profileview ; YES - back to list 1016 bra exit_profileview ; YES - back to list
1120 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode 1017 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode
1121 bra display_profile_loop ; - loop waiting for something to do 1018 bra display_profile_loop ; - loop waiting for something to do
1019
1122 1020
1123 ;============================================================================= 1021 ;=============================================================================
1124 ; Draw a vertical line between xC+1 and xC+0, at current X position. 1022 ; Draw a vertical line between xC+1 and xC+0, at current X position
1125 ; 1023 ;
1126 ; Note: should keep xC+0 1024 ; Note: should keep xC+0
1127 ; Note: ascending or descending ! 1025 ; Note: ascending or descending !
1128 ; 1026 ;
1129 profile_display_fill: 1027 profile_display_fill:
1193 movlw profile_height_pixels 1091 movlw profile_height_pixels
1194 movwf win_width ; "window" height 1092 movwf win_width ; "window" height
1195 call half_horizontal_line ; inputs: win_top, win_leftx2, win_width, win_color1, win_color2 1093 call half_horizontal_line ; inputs: win_top, win_leftx2, win_width, win_color1, win_color2
1196 1094
1197 profile_view_get_depth_no_line: 1095 profile_view_get_depth_no_line:
1198 call ext_flash_byte_read_plus_0x20 ; read depth first 1096 FLASH_II_READ_0x20 logbook_cur_depth ; read depth (2 bytes)
1199 movff ext_flash_rw,logbook_cur_depth+0 ; low value 1097 FLASH_CC_READ_0x20 gaslist_gas ; read Profile Flag Byte
1200 call ext_flash_byte_read_plus_0x20 ; read depth first
1201 movff ext_flash_rw,logbook_cur_depth+1 ; high value
1202 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte
1203 movff ext_flash_rw,gaslist_gas ; store Profile Flag Byte
1204 1098
1205 bcf event_occured ; clear flag by default 1099 bcf event_occured ; clear flag by default
1206 btfsc gaslist_gas,7 ; event recorded? 1100 btfsc gaslist_gas,7 ; event recorded?
1207 bsf event_occured ; YES - we also have an event byte 1101 bsf event_occured ; YES - we also have an event byte
1208 bcf gaslist_gas,7 ; clear event byte flag (if any) 1102 bcf gaslist_gas,7 ; clear event byte flag (if any)
1103
1209 ; gaslist_gas now holds the number of additional bytes to ignore (0-127) 1104 ; gaslist_gas now holds the number of additional bytes to ignore (0-127)
1210 movlw 0xFD ; end of profile bytes ? 1105
1211 cpfseq logbook_cur_depth+0 1106 ; check for end of profile
1212 bra profile_view_get_depth_new1 ; no 1st. 0xFD 1107 movlw 0xFD ; load token for end of profile data
1213 cpfseq logbook_cur_depth+1 1108 cpfseq logbook_cur_depth+0 ; end of profile token in 1st depth byte?
1214 bra profile_view_get_depth_new1 ; no 2nd. 0xFD 1109 bra profile_view_get_depth_new1 ; NO - profile continues
1215 bsf end_of_profile ; end found - set flag, skip remaining pixels 1110 cpfseq logbook_cur_depth+1 ; YES - end of profile token in 2nd depth byte?
1216 return 1111 bra profile_view_get_depth_new1 ; NO - profile continues
1112 bsf end_of_profile ; YES - end of profile, set flag to skip remaining pixels
1113 return ; - done
1217 1114
1218 profile_view_get_depth_new1: 1115 profile_view_get_depth_new1:
1219 btfsc event_occured ; was there an event attached to this sample? 1116 btfsc event_occured ; was there an event attached to this sample?
1220 rcall profile_view_get_depth_events ; YES - get information about this event(s) 1117 rcall profile_view_get_depth_events ; YES - get information about this event(s)
1221 1118
1222 ;---- read Tp°, if any AND divisor reached AND bytes available ----------- 1119 ; read temperature if available AND divisor reached AND bytes available
1223 movf divisor_temperature,W ; is Tp° divisor null ? 1120 movf divisor_temperature,W ; is temperature divisor null ?
1224 bz profile_view_get_depth_no_tp ; YES - no Tp° curve 1121 bz profile_view_get_depth_no_tp ; YES - no temperature curve
1225 decf count_temperature,F ; decrement tp° counter 1122 decf count_temperature,F ; NO - decrement temperature counter, counter zero now?
1226 bnz profile_view_get_depth_no_tp ; no temperature this time 1123 bnz profile_view_get_depth_no_tp ; NO - no temperature this time
1227 1124 FLASH_II_READ_0x20 logbook_cur_tp ; YES - read temperature (2 bytes)
1228 call ext_flash_byte_read_plus_0x20 ; Tp° low 1125 decf gaslist_gas,F ; - reduce counter twice
1229 decf gaslist_gas,F 1126 decf gaslist_gas,F ; - ...
1230 movff ext_flash_rw,logbook_cur_tp+0 1127 movff divisor_temperature,count_temperature ; - restart counter
1231 call ext_flash_byte_read_plus_0x20 ; Tp° high 1128
1232 decf gaslist_gas,F 1129 ; compute max temperature on the fly...
1233 movff ext_flash_rw,logbook_cur_tp+1 1130 MOVII logbook_cur_tp,sub_a ; copy current temperature to sub_a
1234 movff divisor_temperature,count_temperature ; restart counter 1131 MOVII logbook_max_tp,sub_b ; copy maximum temperature to sub_b
1235
1236 ; Compute Tp° max on the fly...
1237 MOVII logbook_cur_tp,sub_a ; compare cur_tp > max_tp ?
1238 MOVII logbook_max_tp,sub_b
1239 call sub16 ; SIGNED sub_a - sub_b 1132 call sub16 ; SIGNED sub_a - sub_b
1240 btfsc neg_flag 1133 btfsc neg_flag ; current temperature > maximum temperature ?
1241 bra profile_view_get_depth_no_tp 1134 bra profile_view_get_depth_no_tp ; NO - no new max temperature
1242 1135
1243 ; store max. temp only below dive_threshold_norm_alt_start 1136 ; store new max. temperature, but only if below dive_threshold_norm_alt_start
1244 tstfsz logbook_cur_depth+1 ; > 2.56 m ? 1137 tstfsz logbook_cur_depth+1 ; deeper than 2.55 m ?
1245 bra profile_view_compute_max_temp ; YES - include in max. temp measurement 1138 bra profile_view_compute_max_temp ; YES - include in max. temp measurement
1246 movlw dive_threshold_norm_alt_start+0 ; get start-of-dive depth in mbar / cm, low byte 1139 movlw dive_threshold_norm_alt_start+0 ; get start-of-dive depth in mbar / cm, low byte
1247 cpfsgt logbook_cur_depth+0 ; deeper that start-of-dive threshold? 1140 cpfsgt logbook_cur_depth+0 ; deeper that start-of-dive threshold?
1248 bra profile_view_get_depth_no_tp ; NO - ignore temperature 1141 bra profile_view_get_depth_no_tp ; NO - ignore current temperature
1249 1142
1250 profile_view_compute_max_temp: 1143 profile_view_compute_max_temp:
1251 MOVII logbook_cur_tp,logbook_max_tp 1144 MOVII logbook_cur_tp,logbook_max_tp ; store new max temperature
1252 1145
1253 ;---- read deco, if any AND divisor=0 AND bytes available ---------------- 1146 ;---- read deco, if any AND divisor=0 AND bytes available ----------------
1254 profile_view_get_depth_no_tp: 1147 profile_view_get_depth_no_tp:
1255 movf divisor_deco,W 1148 movf divisor_deco,W
1256 bz profile_view_get_depth_no_deco 1149 bz profile_view_get_depth_no_deco
1257 decf count_deco,F 1150 decf count_deco,F
1258 bnz profile_view_get_depth_no_deco 1151 bnz profile_view_get_depth_no_deco
1259 1152
1260 call ext_flash_byte_read_plus_0x20 1153 FLASH_CC_READ_0x20 logbook_ceiling ; read the ceiling
1261 decf gaslist_gas,F 1154 decf gaslist_gas,F ; reduce the counter
1262 movff ext_flash_rw,logbook_ceiling
1263 movff divisor_deco,count_deco ; restart counter 1155 movff divisor_deco,count_deco ; restart counter
1264 call ext_flash_byte_read_plus_0x20 ; skip stop length 1156 ext_flash_inc_address_0x40 d'1' ; skip the stop duration
1265 decf gaslist_gas,F 1157 decf gaslist_gas,F ; reduce the counter
1266 1158
1267 ;---- read GF, if any AND divisor=0 AND bytes available ------------------ 1159 ;---- read GF, if any AND divisor=0 AND bytes available ------------------
1160
1268 profile_view_get_depth_no_deco: 1161 profile_view_get_depth_no_deco:
1269 ; Then skip remaining bytes... 1162 ; then skip remaining bytes...
1270 movf gaslist_gas,W ; number of additional bytes to ignore (0-127) 1163 movf gaslist_gas,W ; get number of additional bytes to ignore (0-127)
1271 tstfsz gaslist_gas ; anything to skip? 1164 tstfsz WREG ; anything to skip?
1272 call incf_ext_flash_address0_0x20 ; YES - increases bytes in ext_flash_address:3 with 0x200000 bank switching 1165 call incf_ext_flash_address0_0x20 ; YES - skip #WREG bytes
1273 return 1166 return
1274 1167
1275 profile_view_get_depth_events: 1168 profile_view_get_depth_events:
1276 clrf event_byte2 ; clear event byte 2 1169 clrf event_byte2 ; clear event byte 2
1277 call ext_flash_byte_read_plus_0x20 ; read event byte 1170 FLASH_CC_READ_0x20 event_byte1 ; read event byte 1
1278 movff ext_flash_rw,event_byte1 ; store event byte 1
1279 decf gaslist_gas,F ; reduce counter 1171 decf gaslist_gas,F ; reduce counter
1280 1172
1281 btfss event_byte1,7 ; another event byte? 1173 btfss event_byte1,7 ; another event byte?
1282 bra profile_no_second_eventbyte ; NO 1174 bra profile_no_second_eventbyte ; NO - skip next
1283 call ext_flash_byte_read_plus_0x20 ; read event byte 2 1175 FLASH_CC_READ_0x20 event_byte2 ; YES - read event byte 2
1284 movff ext_flash_rw,event_byte2 ; store event byte 2 1176 decf gaslist_gas,F ; - reduce counter
1285 decf gaslist_gas,F ; reduce counter 1177 bcf event_byte1,7 ; - clear flag
1286 bcf event_byte1,7 ; clear flag
1287 1178
1288 profile_no_second_eventbyte: 1179 profile_no_second_eventbyte:
1289 ; Check event flags in the EventBytes 1180 ; Check event flags in the EventBytes
1290 btfsc event_byte1,4 ; manual gas changed? 1181 btfsc event_byte1,4 ; manual gas changed?
1291 rcall logbook_event1 ; YES 1182 rcall logbook_event1 ; YES
1304 return ; NO - done 1195 return ; NO - done
1305 bsf log_marker_found ; YES - draw small yellow rectangle here 1196 bsf log_marker_found ; YES - draw small yellow rectangle here
1306 return ; - done 1197 return ; - done
1307 1198
1308 logbook_event4: ; stored gas changed 1199 logbook_event4: ; stored gas changed
1309 call ext_flash_byte_read_plus_0x20 ; read gas number 1200 FLASH_CC_READ_0x20 backup_color1 ; read gas number, to be used as color index
1310 decf gaslist_gas,F ; reduce counter 1201 decf gaslist_gas,F ; reduce counter
1311 movff ext_flash_rw,backup_color1 1202 call TFT_color_code_gas ; change profile color according to gas number (still in WREG)
1312 movff ext_flash_rw,WREG ; copy gas number to WREG for color-coding
1313 call TFT_color_code_gas ; change profile color according to gas number
1314 return 1203 return
1315 1204
1316 logbook_event1: ; gas 6 used 1205 logbook_event1: ; gas 6 used
1317 bsf event_gas_change_gas6 ; set event flag 1206 bsf event_gas_change_gas6 ; set event flag
1318 movlw .6 ; use gas 6 color 1207 movlw .6 ; use gas 6 color
1319 movwf backup_color1 ; select color for gas 6 1208 movwf backup_color1 ; select color for gas 6
1320 call TFT_color_code_gas ; set profile color 1209 call TFT_color_code_gas ; set profile color
1321 incf_ext_flash_address_0x20 .2 ; skip two bytes 1210 ext_flash_inc_address_0x20 d'2' ; skip two bytes
1322 decf gaslist_gas,F ; reduce counter 1211 decf gaslist_gas,F ; reduce counter
1323 decf gaslist_gas,F ; reduce counter 1212 decf gaslist_gas,F ; reduce counter
1324 return 1213 return
1325 1214
1326 logbook_event2: ; bailout 1215 logbook_event2: ; bailout
1327 bsf bailout_mode ; set flag 1216 bsf bailout_mode ; set flag
1328 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR 1217 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR
1329 movlw .6 ; use Gas6 color 1218 movlw .6 ; use Gas6 color
1330 movwf backup_color1 1219 movwf backup_color1
1331 call TFT_color_code_gas ; use gas 6 color 1220 call TFT_color_code_gas ; use gas 6 color
1332 incf_ext_flash_address_0x20 .2 ; skip two bytes 1221 ext_flash_inc_address_0x20 d'2' ; skip two bytes
1333 decf gaslist_gas,F ; reduce counter 1222 decf gaslist_gas,F ; reduce counter
1334 decf gaslist_gas,F ; reduce counter 1223 decf gaslist_gas,F ; reduce counter
1335 return 1224 return
1336 1225
1337 logbook_event3: ; setpoint change 1226 logbook_event3: ; setpoint change
1338 incf_ext_flash_address_0x20 .1 ; skip one byte 1227 ext_flash_inc_address_0x20 d'1' ; skip one byte
1339 decf gaslist_gas,F ; reduce counter 1228 decf gaslist_gas,F ; reduce counter
1340 btfss bailout_mode ; in bailout? 1229 btfss bailout_mode ; in bailout?
1341 return ; NO - return 1230 return ; NO - done
1342 ; We were in bailout before, restore profile color 1231 movff backup_color2,backup_color1 ; YES - restore color
1343 movff backup_color2,backup_color1 ; restore color 1232 movf backup_color2,W ; - copy gas number to WREG for color-coding
1344 movff backup_color2,WREG ; copy gas number to WREG for color-coding 1233 call TFT_color_code_gas ; - back to normal profile color
1345 call TFT_color_code_gas ; back to normal profile color 1234 return ; - done
1346 return
1347 1235
1348 ; ------------------------------------------------------------------------ 1236 ; ------------------------------------------------------------------------
1349 1237
1350 exit_profileview: 1238 exit_profileview:
1351 clrf gaslist_gas ; restore all registers to build same page again 1239 clrf gaslist_gas ; restore all registers to build same page again
1353 movff logbook_max_dive_counter_temp,logbook_max_dive_counter 1241 movff logbook_max_dive_counter_temp,logbook_max_dive_counter
1354 movff logbook_temp_backup,logbook_temp 1242 movff logbook_temp_backup,logbook_temp
1355 incf logbook_max_dive_counter,F 1243 incf logbook_max_dive_counter,F
1356 decf logbook_divenumber,F 1244 decf logbook_divenumber,F
1357 bcf all_dives_shown 1245 bcf all_dives_shown
1358 clrf menu_pos_max ; number of used rows on current logbook-page 1246 clrf menu_pos_max ; number of rows used on current logbook-page
1359 movlw logbook_row_number 1247 movlw logbook_row_number
1360 movwf menu_pos_cur ; here: active row on current page 1248 movwf menu_pos_cur ; here: active row on current page
1361 call TFT_boot 1249 call TFT_boot
1362 goto logbook2 ; start search 1250 goto logbook2 ; start search
1363 1251
1371 bsf keep_cursor_new_page ; keep cursor on "next page" 1259 bsf keep_cursor_new_page ; keep cursor on "next page"
1372 call TFT_boot 1260 call TFT_boot
1373 goto logbook2 ; start search 1261 goto logbook2 ; start search
1374 1262
1375 next_logbook3: 1263 next_logbook3:
1376 incf menu_pos_cur,F ; +1 1264 incf menu_pos_cur,F ; set cursor to next line
1377 movlw logbook_row_number+.2 1265 movlw logbook_row_number+.2 ; get maximum number of lines
1378 cpfsgt menu_pos_cur ; = logbook_row_number + 3 ? 1266 cpfsgt menu_pos_cur ; cursor position beyond last line?
1379 bra next_logbook3a ; NO 1267 bra next_logbook3a ; NO - ok, done
1380 movlw .1 1268 movlw .1 ; YES - reset to first line
1381 movwf menu_pos_cur 1269 movwf menu_pos_cur ; - ...
1382 bra next_logbook3b 1270 bra next_logbook3b ; - done
1383 1271
1384 next_logbook3a: 1272 next_logbook3a:
1385 incf menu_pos_max,W ; last entry on current page +1 1273 incf menu_pos_max,W ; last entry on current page +1
1386 cpfseq menu_pos_cur ; same as cursor position? 1274 cpfseq menu_pos_cur ; same as cursor position?
1387 bra next_logbook3b ; NO 1275 bra next_logbook3b ; NO
1394 1282
1395 next_logbook3b: 1283 next_logbook3b:
1396 call TFT_logbook_cursor 1284 call TFT_logbook_cursor
1397 goto logbook_loop_pre 1285 goto logbook_loop_pre
1398 1286
1287 ; ------------------------------------------------------------------
1288 ; list one dive
1289 ;
1399 display_listdive: 1290 display_listdive:
1400 bsf logbook_page_not_empty ; page not empty 1291 bsf logbook_page_not_empty ; flag page will not be empty
1401 incf menu_pos_max,F 1292 incf menu_pos_max,F ; increment number of lines shown
1402 1293
1403 WIN_FONT FT_SMALL
1404 WIN_LEFT logbook_list_left
1405
1406 decf menu_pos_max,W ; -1 into WREG
1407 mullw logbook_row_offset
1408 movff PRODL,win_top
1409 lfsr FSR2,buffer ; initialize output buffer 1294 lfsr FSR2,buffer ; initialize output buffer
1410 1295 WIN_FONT FT_SMALL ; select font
1411 movf logbook_divenumber,W ; log_compute_divenumber needs the list number 1296 WIN_LEFT logbook_list_left ; set horizontal output position
1412 call log_compute_divenumber ; compute dive number 1297 decf menu_pos_max,W ; get current line -1 into WREG
1413 bsf leftbind 1298 mullw logbook_row_offset ; multiply with row spacing
1299 movff PRODL,win_top ; set vertical output position
1300
1301 ; print dive number
1302 movf logbook_divenumber,W ; get running number of the dive
1303 call log_compute_divenumber ; compute dive number to show (incorporate dive number offset)
1304 bsf leftbind ; start left-aligned
1414 movlw .3 ; start with 3rd digit (i.e. suppress the thousands) 1305 movlw .3 ; start with 3rd digit (i.e. suppress the thousands)
1415 movwf ignore_digits 1306 movwf ignore_digits ; ...
1416 output_16dp .0 ; show dive number 1307 output_16dp .0 ; print dive number
1417 bcf leftbind 1308 bcf leftbind ; end left-alignment
1418 PUTC ' ' 1309
1419 ; display_listdive2: 1310 PUTC ' ' ; print a space char
1420 LOG_POINT_TO log_date+1 ; point to month 1311
1421 call ext_flash_byte_read_plus ; read month 1312 ; print dive date
1422 movff ext_flash_rw,hi ; month 1313 MOVTT header_buffer+index_date,mpr ; get date
1423 call ext_flash_byte_read_plus ; read day 1314 call TFT_convert_date_short ; convert and print date
1424 movff ext_flash_rw,lo ; day 1315
1425 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer 1316 PUTC ' ' ; print a space char
1426 PUTC ' ' 1317
1427 1318 ; print dive depth
1428 LOG_POINT_TO log_max_depth ; point to max. depth 1319 MOVII header_buffer+index_max_depth,mpr ; get max depth
1429 call ext_flash_byte_read_plus ; max. depth 1320
1430 movff ext_flash_rw,lo 1321 TSTOSS opt_units ; switch by configured units
1431 call ext_flash_byte_read_plus
1432 movff ext_flash_rw,hi
1433
1434 TSTOSS opt_units ; 0=Meters, 1=Feets
1435 bra display_listdive2_metric ; 0 - do metric 1322 bra display_listdive2_metric ; 0 - do metric
1436 ; 1 - do imperial 1323 ;bra display_listdive2_imperial ; 1 - do imperial
1437 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1324
1438 PUTC ' ' 1325 display_listdive2_imperial:
1439 output_16_3 ; limit to 999 and display only (0-999) 1326 call convert_cm_to_feet ; convert value in mpr from [cm] to [feet]
1440 STRCAT_TEXT tFeets1 1327 PUTC ' ' ; print one space char
1441 bra display_listdive3 1328 output_16_3 ; print depth, limited to 999
1329 STRCAT_TEXT tFeets1 ; print unit label
1330 bra display_listdive3 ; continue with common part
1442 1331
1443 display_listdive2_metric: 1332 display_listdive2_metric:
1444 bsf ignore_digit5 ; no cm... 1333 bsf ignore_digit5 ; do not print the cm
1445 movlw d'1' ; +1 1334 movlw d'1' ; do not print the first digit (no 1000 m)
1446 movwf ignore_digits ; no 1000 m 1335 movwf ignore_digits ; ...
1447 output_16dp .3 ; xxx.y 1336 output_16dp .3 ; print depth in format xxx.y
1448 STRCAT_TEXT tMeters 1337 STRCAT_TEXT tMeters ; print unit label
1449 PUTC ' ' 1338 PUTC ' ' ; print one space char
1450 1339 ;bra display_listdive3 ; continue with common part
1340
1341 ; print dive time
1451 display_listdive3: 1342 display_listdive3:
1452 call ext_flash_byte_read_plus 1343 MOVII header_buffer+index_divetime,mpr ; get dive time (minutes only)
1453 movff ext_flash_rw,lo ; read dive time minutes 1344 output_16_3 ; print minutes (0-999 min)
1454 call ext_flash_byte_read_plus 1345 STRCAT_TEXT tMinutes ; print minutes mark ("'")
1455 movff ext_flash_rw,hi 1346 clrf WREG ; create string terminator
1456 output_16_3 ; dive time minutes (0-999min) 1347 movff WREG,buffer+.21 ; hard limit the output to 21 chars
1457 STRCAT_TEXT tMinutes 1348 STRCAT_PRINT "" ; finalize output
1458 clrf WREG 1349
1459 movff WREG,buffer+.21 ; limit to 21 chars 1350 return ; done
1460 STRCAT_PRINT "" ; display header-row in list
1461 return
1462 1351
1463 ; ------------------------------------------------------------------ 1352 ; ------------------------------------------------------------------
1464 1353
1465 logbook_show_divenumber: 1354 logbook_show_divenumber:
1466 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row 1355 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row
1470 output_16 ; show dive number 1359 output_16 ; show dive number
1471 bcf leftbind 1360 bcf leftbind
1472 STRCAT_PRINT "" ; finalize output 1361 STRCAT_PRINT "" ; finalize output
1473 return ; done 1362 return ; done
1474 1363
1475 ; ------------------------------------------------------------------- 1364
1476 1365 ;-----------------------------------------------------------------------------
1477 logbook_page2: ; show more info 1366 ; 1st Details Page after Profile: Dive Statistics
1367
1368 logbook_page1: ; show more info
1478 rcall log_details_header ; shows number, time/date and basic dive info 1369 rcall log_details_header ; shows number, time/date and basic dive info
1479 1370
1480 btfss aux_flag ; dive done in a deco mode? 1371 btfss aux_flag ; dive done in a deco mode?
1481 bra logbook_page2_1 ; NO 1372 bra logbook_page1_1 ; NO
1482 1373
1483 ; Deco model 1374 ; deco model
1484 WIN_SMALL .5,.65 1375 WIN_SMALL .5,.65
1485 LOG_POINT_TO log_decomodel 1376 MOVCC header_buffer+index_decomodel,WREG ; get deco model (0= ZH-L16, 1=ZH-L16+GF)
1486 call ext_flash_byte_read_plus ; read deco model 1377 decfsz WREG,W ; GF model?
1487 movff ext_flash_rw,lo 1378 bra logbook_decomodel_1 ; NO - ZH-L16
1488 decfsz ext_flash_rw,F 1379 ;bra logbook_decomodel_2 ; YES - ZH-L16+GF
1489 bra logbook_decomodel1 1380
1490 ; Deco model GF Version 1381 logbook_decomodel_2:
1382 ; deco model GF version
1491 STRCAT_PRINT "ZHL-16+GF" 1383 STRCAT_PRINT "ZHL-16+GF"
1492 LOG_POINT_TO log_gf_lo
1493 WIN_SMALL .5,.90 1384 WIN_SMALL .5,.90
1494 STRCPY_TEXT tGF 1385 STRCPY_TEXT tGF2
1495 call ext_flash_byte_read_plus ; read GF lo 1386 MOVII header_buffer+index_gf_lo_hi,mpr ; get GF factors
1496 movff ext_flash_rw,lo 1387 output_8 ; print GF lo
1497 output_8
1498 STRCAT "%/" 1388 STRCAT "%/"
1499 bra logbook_decomodel_common 1389 movff hi,lo ; print GF hi
1500 logbook_decomodel1: 1390 output_8 ; ...
1501 ; Deco model NON-GF Version 1391 STRCAT_PRINT "%"
1392 bra logbook_cns
1393
1394 logbook_decomodel_1:
1395 ; deco model none-GF version
1502 STRCAT_PRINT "ZH-L16" 1396 STRCAT_PRINT "ZH-L16"
1503 LOG_POINT_TO log_sat_mult
1504 WIN_SMALL .5,.90 1397 WIN_SMALL .5,.90
1505 call ext_flash_byte_read_plus ; read sat_mult or GF low 1398 MOVII header_buffer+index_factor_sat_desat,mpr; get both factors
1506 movff ext_flash_rw,lo 1399 output_8 ; print saturation factor
1507 output_8
1508 STRCAT "%/" 1400 STRCAT "%/"
1509 logbook_decomodel_common: 1401 movff hi,lo ; print desaturation factor
1510 call ext_flash_byte_read_plus ; read desat_mult or GF high 1402 output_8 ; ...
1511 movff ext_flash_rw,lo
1512 output_8
1513 STRCAT_PRINT "%" 1403 STRCAT_PRINT "%"
1514 1404 ;bra logbook_cns
1515 ; CNS 1405
1516 LOG_POINT_TO log_cns_start 1406 logbook_cns:
1517 WIN_SMALL .5,.115 1407 WIN_SMALL .5,.115
1518 STRCPY_TEXT tCNS2 1408 STRCPY_TEXT tCNS2
1519 call ext_flash_byte_read_plus ; read CNS low 1409 MOVII header_buffer+index_cns_start,mpr ; get CNS at start of dive
1520 movff ext_flash_rw,lo 1410 bcf mpr+1,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM)
1521 call ext_flash_byte_read_plus ; read CNS high 1411 bcf mpr+1,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM)
1522 movff ext_flash_rw,hi
1523 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM)
1524 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM)
1525 output_16 1412 output_16
1526 LOG_POINT_TO log_cns_end
1527 STRCAT "->" 1413 STRCAT "->"
1528 call ext_flash_byte_read_plus ; read CNS low 1414 MOVII header_buffer+index_cns_end,mpr ; get CNS at end of dive
1529 movff ext_flash_rw,lo
1530 call ext_flash_byte_read_plus ; read CNS high
1531 movff ext_flash_rw,hi
1532 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) 1415 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM)
1533 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) 1416 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM)
1534 output_16 1417 output_16
1535 STRCAT_PRINT "%" 1418 STRCAT_PRINT "%"
1536 1419
1537 logbook_page2_1: 1420 logbook_page1_1:
1538 1421 WIN_SMALL .5,.140
1539 ; Salinity
1540 WIN_SMALL .5,.165 ; ex WIN_SMALL .5,.140
1541 LOG_POINT_TO log_salinity
1542 STRCPY_TEXT tDvSalinity
1543 bsf leftbind
1544 call ext_flash_byte_read_plus ; read salinity
1545 movff ext_flash_rw,lo
1546 movff ext_flash_rw,salinity ; store salinity for later use
1547 output_8
1548 STRCAT_PRINT "%"
1549
1550 ; Average depth
1551 WIN_SMALL .5,.140 ; ex WIN_SMALL .5,.165
1552 STRCPY_TEXT tAVG 1422 STRCPY_TEXT tAVG
1553 LOG_POINT_TO log_avr_depth 1423 MOVII header_buffer+index_avr_depth,mpr ; get average depth
1554 call ext_flash_byte_read_plus ; read average low 1424
1555 movff ext_flash_rw,lo 1425 TSTOSS opt_units ; 0=Meters, 1=Feets
1556 call ext_flash_byte_read_plus ; read average high 1426 bra logbook_page1_1_metric ; do metric
1557 movff ext_flash_rw,hi 1427 ;bra logbook_page1_1_imperial ; do imperial
1558 movf salinity,W ; salinity for this dive 1428
1559 call adjust_depth_with_salinity_log ; compute salinity into lo:hi [mbar] 1429 logbook_page1_1_imperial:
1430 call convert_cm_to_feet ; convert value in lo:hi from [cm] to [feet]
1431 PUTC ' '
1432 output_16_3 ; limit to 999 and display only (0-999)
1433 STRCAT_PRINT "ft"
1434 bra logbook_page1_1_common
1435
1436 logbook_page1_1_metric:
1560 bsf ignore_digit5 ; no cm (flag will be cleared by output_16) 1437 bsf ignore_digit5 ; no cm (flag will be cleared by output_16)
1561 movlw .1 ; no 1000 meters 1438 movlw .1 ; no 1000 meters
1562 movwf ignore_digits ; ... 1439 movwf ignore_digits ; ...
1563 output_16dp .3 ; xxx.y 1440 output_16dp .3 ; xxx.y
1564 STRCAT_PRINT "m" 1441 STRCAT_PRINT "m"
1565 1442 ;bra logbook_page1_1_common
1443
1444 logbook_page1_1_common:
1566 btfss aux_flag ; dive done in a deco mode? 1445 btfss aux_flag ; dive done in a deco mode?
1567 bra logbook_page2_2 ; NO 1446 bra logbook_page1_2 ; NO
1447
1448 ; Salinity
1449 WIN_SMALL .5,.165 ; ex WIN_SMALL .5,.140
1450 STRCPY_TEXT tDvSalinity2
1451 bsf leftbind
1452 MOVCC header_buffer+index_salinity,lo ; read salinity
1453 output_8
1454 STRCAT_PRINT "%"
1568 1455
1569 ; Last deco 1456 ; Last deco
1570 LOG_POINT_TO log_last_stop
1571 WIN_SMALL .5,.190 1457 WIN_SMALL .5,.190
1572 STRCPY_TEXT tLastDecostopSurf 1458 STRCPY_TEXT tLastDeco
1573 call ext_flash_byte_read_plus ; read last stop 1459 MOVCC header_buffer+index_last_stop,lo ; read last stop depth
1574 movff ext_flash_rw,lo
1575 output_8 1460 output_8
1576 STRCAT_PRINT "m" 1461 STRCAT_PRINT "m"
1577 1462
1578 logbook_page2_2: 1463 logbook_page1_2:
1579
1580 movlw color_lightblue 1464 movlw color_lightblue
1581 call TFT_set_color 1465 call TFT_set_color
1582 WIN_FRAME_COLOR16 .63,.220,.2,.105 ; top, bottom, left, right 1466 WIN_FRAME_COLOR16 .63,.220,.2,.105 ; top, bottom, left, right
1583 1467
1584 ; Firmware 1468 ; Firmware
1585 call TFT_standard_color 1469 call TFT_standard_color
1586 WIN_SMALL .110,.65 1470 WIN_SMALL .110,.65
1587 STRCAT "V:" 1471 STRCAT "V:"
1588 LOG_POINT_TO log_firmware 1472 MOVII header_buffer+index_firmware,mpr ; get firmware version
1589 call ext_flash_byte_read_plus ; read firmware major number 1473 movff lo,up ; keep a backup of major in up
1590 movf ext_flash_rw,W ; copy to WREG
1591 movwf hi ; copy from WREG to hi
1592 movwf lo ; copy from WREG to lo, too
1593 bsf leftbind ; print left-aligned 1474 bsf leftbind ; print left-aligned
1594 output_8 ; print major number 1475 output_8 ; print major version (in 1 digit due to leftbind)
1595 PUTC "." ; print "." 1476 PUTC "." ; print "."
1596 call ext_flash_byte_read_plus ; read firmware minor number 1477 movff hi,lo ; print minor version...
1597 movff ext_flash_rw,lo ; store in lo 1478 output_99x ; ... in 2 digit format
1598 output_99x ; print minor version in 2 digit format
1599 STRCAT_PRINT "" ; finalize output 1479 STRCAT_PRINT "" ; finalize output
1600 1480
1601 movf hi,W ; get major into WREG 1481 movf up,W ; get major into WREG
1602 xorlw .3 ; major == 3 ? 1482 xorlw .3 ; major == 3 ?
1603 bz logbook_battery_percent ; YES - show battery % 1483 bz logbook_battery_percent ; YES - show battery %
1604 1484 movf up,W ; NO - get major into WREG (again)
1605 movf hi,W ; get major into WREG (again) 1485 xorlw .2 ; major == 2 ?
1606 xorlw .2 ; major == 2 ? 1486 bnz logbook_battery_voltage ; NO - skip battery %
1607 bnz logbook_battery_voltage ; NO - skip battery % 1487 movlw .14 ; YES - check minor version
1608 movlw .14 ; YES - check minor version 1488 cpfsgt lo ; - minor > 14 ?
1609 cpfsgt lo ; - minor > 14 ? 1489 bra logbook_battery_voltage ; NO - skip battery %
1610 bra logbook_battery_voltage ; NO - skip battery % 1490 ;bra logbook_battery_percent ; YES - show battery %
1611 ;bra logbook_battery_percent ; YES - show battery %
1612 1491
1613 ; Battery % 1492 ; Battery %
1614 logbook_battery_percent: 1493 logbook_battery_percent:
1615 WIN_SMALL .110,.140 ; show battery percent 1494 WIN_SMALL .110,.140
1616 LOG_POINT_TO log_batt_info ; address battery percent 1495 MOVCC header_buffer+index_batt_percent,lo ; get battery percent
1617 call ext_flash_byte_read_plus ; read battery percent
1618 movff ext_flash_rw,lo ; copy battery percent to lo
1619 output_8 ; print battery percent 1496 output_8 ; print battery percent
1620 STRCAT_PRINT "%" ; print "%" and finalize output 1497 STRCAT_PRINT "%" ; print "%" and finalize output
1621 1498
1622 ; Battery Voltage 1499 ; Battery Voltage
1623 logbook_battery_voltage: 1500 logbook_battery_voltage:
1624 WIN_SMALL .110,.90 1501 WIN_SMALL .110,.90
1625 STRCAT_PRINT "Batt:" 1502 STRCAT_PRINT "Batt:"
1626 WIN_SMALL .110,.115 1503 WIN_SMALL .110,.115
1627 LOG_POINT_TO log_battery ; address battery voltage 1504 MOVII header_buffer+index_battery_voltage,mpr ; get battery voltage
1628 call ext_flash_byte_read_plus ; read battery voltage, low byte
1629 movff ext_flash_rw,lo ; store in lo
1630 call ext_flash_byte_read_plus ; read battery voltage, high byte
1631 movff ext_flash_rw,hi ; store in hi
1632 output_16dp .2 ; print battery voltage 1505 output_16dp .2 ; print battery voltage
1633 STRCAT_PRINT "V" ; ... 1506 STRCAT_PRINT "V" ; print unit (Volt)
1634 1507
1635 LOG_POINT_TO log_surface_press ; address surface pressure in mbar 1508 ; Surface Pressure
1636 call ext_flash_byte_read_plus ; read surface pressure, low byte 1509 MOVII header_buffer+index_surface_press,mpr ; get surface pressure
1637 movff ext_flash_rw,lo ; store in lo
1638 call ext_flash_byte_read_plus ; read surface pressure, high byte
1639 movff ext_flash_rw,hi ; store in hi
1640 WIN_SMALL .110,.165 ; set output position 1510 WIN_SMALL .110,.165 ; set output position
1641 lfsr FSR2,buffer ; set base address of output buffer
1642 bsf leftbind ; print without leading spaces 1511 bsf leftbind ; print without leading spaces
1643 output_16 ; print air pressure before dive 1512 output_16 ; print surface pressure before dive
1644 STRCAT_TEXT tMBAR ; ... 1513 STRCAT_TEXT tMBAR ; print unit
1645 clrf WREG ; string terminator 1514 clrf WREG ; string terminator
1646 movff WREG,buffer+7 ; limit to 7 chars 1515 movff WREG,buffer+7 ; limit to 7 chars
1647 STRCAT_PRINT "" ; dump buffer to screen 1516 STRCAT_PRINT "" ; dump buffer to screen
1648 1517
1649 movlw color_greenish ; select color 1518 movlw color_greenish ; select color
1650 call TFT_set_color ; ... 1519 call TFT_set_color ; ...
1651 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; draw a frame around coordinates top, bottom, left, right 1520 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; draw a frame with coordinates top, bottom, left, right
1652 1521
1522 ; handle HMI
1653 rcall logbook_preloop_tasks ; clear timeout and remaining button events 1523 rcall logbook_preloop_tasks ; clear timeout and remaining button events
1654 display_details_loop: 1524 display_details1_loop:
1655 btfss switch_right ; right button pressed? 1525 btfsc switch_right ; right button pressed?
1656 bra display_details_loop_1 ; NO 1526 bra display_details1_more ; YES - more info or back to profile
1657 btfsc aux_flag ; YES - dive done in a deco mode?
1658 bra logbook_page3 ; YES - show more details, 2nd page
1659 goto display_profile2 ; NO - show the profile view again
1660 display_details_loop_1:
1661 btfsc switch_left ; left button pressed? 1527 btfsc switch_left ; left button pressed?
1662 bra exit_profileview ; YES - back to list 1528 bra exit_profileview ; YES - back to list
1663 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode 1529 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode
1664 bra display_details_loop ; - loop waiting for something to do 1530 bra display_details1_loop ; - loop waiting for something to do
1665 1531
1666 1532 display_details1_more:
1533 btfss aux_flag ; YES - dive done in a deco mode?
1534 goto display_profile2 ; NO - show the profile view again
1535 ;bra logbook_page2 ; YES - show more details
1536
1537
1538 ;-----------------------------------------------------------------------------
1539 ; 2nd Details Page after Profile: Tissue and Decompression Status
1540
1541 logbook_page2:
1542
1543 ; ################# to be removed later ##################################
1544 ; movlw fw_version_beta ; get beta status
1545 ; tstfsz WREG ; beta?
1546 ; bra display_page2_betajump ; YES - omit firmware version check
1547 ; ########################################################################
1548
1549 ; skip this page for dives recorded with firmwares < 3.09
1550 MOVII header_buffer+index_firmware,mpr ; get firmware version major and minor
1551
1552 movlw .2 ; minimum required major is 3, -1 for cpfsgt
1553 cpfsgt lo ; major >= requirement?
1554 bra logbook_page3 ; NO - skip this page
1555 movlw .8 ; YES - minimum required minor is 9, -1 for cpfsgt
1556 cpfsgt hi ; - minor >= requirement?
1557 bra logbook_page3 ; NO - skip this page
1558
1559 ; ################# to be removed later ##################################
1560 display_page2_betajump:
1561 ; ########################################################################
1562
1563 rcall log_details_header ; shows number, time/date and basic dive info
1564
1565 ; basic configuration of tissue graphics
1566 bsf tissue_graphic_mode ; select logbook mode
1567 bcf tissue_graphic_layout ; select press+sat
1568 bcf tissue_graphic_cns ; do not show CNS value
1569 bcf tissue_graphic_gf ; do not show GF lines by default
1570
1571 ; GF configuration
1572 MOVCC header_buffer+index_decomodel,WREG ; get deco model (0= ZH-L16, 1=ZH-L16+GF)
1573 dcfsnz WREG ; GF model?
1574 bsf tissue_graphic_gf ; YES - show GF lines
1575
1576 ; draw the graphics
1577 call TFT_surface_tissues
1578
1579 ; calculate time/date of the end of the dive
1580 MOVTT header_buffer+index_date, rtc_latched_year ; get start of the dive - year, month, day
1581 MOVII header_buffer+index_time, rtc_latched_hour ; get start of the dive - hour, minute
1582 MOVCC header_buffer+index_divetime+2,rtc_latched_secs ; get duration of the dive - seconds
1583 MOVII header_buffer+index_divetime+0,mpr ; get duration of the dive - minutes
1584 call rtc_add_minutes ; add minutes in mpr to time/date in rtc_latched
1585
1586 ; print time/date of the end of the dive
1587 WIN_SMALL .8,.193 ; select font and output position
1588 MOVTT rtc_latched_year,mpr ; get computed end-of-dive date
1589 call TFT_convert_date_short ; convert and print date
1590 STRCAT ".-" ; print spacing ".-"
1591 MOVII rtc_latched_hour,mpr ; get computed end-of-dive time
1592 output_99x ; print hour
1593 PUTC ':' ; print spacing ":"
1594 movff hi,lo ; print minute
1595 output_99x ; ...
1596 STRCAT_PRINT "" ; finalize output
1597
1598
1599 ; draw a white frame around the time/date
1600 WIN_FRAME_STD surf_tissue_diagram_bottom,.220, surf_tissue_diagram_left, surf_tissue_diagram_right
1601
1602 bra logbook_page2_rightside ; continue with right side
1603
1604 logbook_page2_nograph:
1605 WIN_SMALL .6,.118 ; no tissue graphics because the
1606 STRCAT_PRINT "(< FW 3.08)" ; profile was recorded on a FW < 3.08
1607
1608 logbook_page2_rightside:
1609
1610 ; 1st line: supersaturation at end of dive
1611 WIN_SMALL .100,.68
1612 STRCAT_TEXT_PRINT tBeginOfDive ; print "Begin"
1613
1614 ; 2nd line:
1615 WIN_SMALL .100+.28,.93 ; +16 for centered, +28 for right-aligned
1616 MOVCC header_buffer+index_supersat_start,lo ; get supersaturation at start of dive
1617 bcf leftbind
1618 output_8 ; print percent value
1619 STRCAT_PRINT "%" ; print "%" and finalize output
1620
1621 ; 3rd line:
1622 WIN_SMALL .100,.118
1623 STRCAT_TEXT_PRINT tEndOfDive ; print "End"
1624
1625 ; 4th line:
1626 WIN_SMALL .100+.28,.143 ; +16 for centered, +28 for right-aligned
1627 MOVCC header_buffer+index_supersat_end,lo ; get supersaturation at end of dive
1628 bcf leftbind
1629 output_8 ; print percent value
1630 STRCAT_PRINT "%" ; print "%" and finalize output
1631
1632 ; 5th line: desaturation time label
1633 WIN_SMALL .100,.168
1634 STRCAT_TEXT_PRINT tDesatTime ; print "Desat"
1635
1636 ; 6th line: desaturation time value
1637 WIN_SMALL .100+.14,.193 ; +?? for centered, +14 for right-aligned
1638 MOVII header_buffer+index_desattime,mpr ; get desaturation time
1639 call convert_time ; convert hi:lo in minutes to hours (up:hi) and minutes (lo)
1640 movf lo,W ; swap hi and lo
1641 movff hi,lo ; ...
1642 movwf hi ; ...
1643 output_99 ; print hours in 0-99
1644 PUTC 'h' ; print hours mark
1645 movff hi,lo ; print minutes...
1646 output_99x ; ... in two digits, leading zero
1647 STRCAT_PRINT "m" ; print minutes mark and finalize output
1648
1649 ; draw a colored frame around the right side
1650 movlw color_orange ; select color
1651 call TFT_set_color ; ...
1652 WIN_FRAME_COLOR16 .65,.220,.97,.159 ; draw a frame with coordinates top, bottom, left, right
1653
1654 ; handle HMI
1655 rcall logbook_preloop_tasks ; clear timeout and remaining button events
1656 display_details1b_loop:
1657 btfsc switch_right ; right button pressed?
1658 bra logbook_page3 ; YES - show more info
1659 btfsc switch_left ; left button pressed?
1660 bra exit_profileview ; YES - back to list
1661 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode
1662 bra display_details1b_loop ; - loop waiting for something to do
1663
1664
1665 ;-----------------------------------------------------------------------------
1666 ; helper function
1667 logbook_preloop_tasks: 1667 logbook_preloop_tasks:
1668 movlw CCP1CON_VALUE ; see hwos.inc 1668 movlw CCP1CON_VALUE ; see hwos.inc
1669 movwf CCP1CON ; power-on backlight 1669 movwf CCP1CON ; power-on backlight
1670 call TFT_standard_color ; revert to standard color 1670 call TFT_standard_color ; revert to standard color
1671 call reset_timeout_surfmode ; reset timeout 1671 call reset_timeout_surfmode ; reset timeout
1672 bcf switch_left ; clear left-over left button event 1672 bcf switch_left ; clear left-over left button event
1673 bcf switch_right ; clear left-over right button event 1673 bcf switch_right ; clear left-over right button event
1674 return ; done 1674 return ; done
1675 1675
1676 1676 ;-----------------------------------------------------------------------------
1677 logbook_page3: ; show even more info 1677 ; 3rd Details Page after Profile: Gases / Diluents
1678
1679 logbook_page3:
1678 rcall log_details_header ; shows number, time/date and basic dive info 1680 rcall log_details_header ; shows number, time/date and basic dive info
1679 LOG_POINT_TO log_gas1 1681 lfsr FSR0,header_buffer+index_gas1 ; load base address of the gases
1680 bcf log_show_gas_short ; do the long version of log_show_gas 1682 bcf log_show_gas_short ; do the long version of log_show_gas
1681 bcf leftbind 1683 bcf leftbind
1682 1684
1683 WIN_SMALL .5,.90 1685 WIN_SMALL .5,.90
1684 movlw .1 ; color for gas 1 1686 movlw .1 ; color for gas 1
1698 1700
1699 WIN_SMALL .5,.190 1701 WIN_SMALL .5,.190
1700 movlw .5 ; color for gas 5 1702 movlw .5 ; color for gas 5
1701 rcall log_show_gas 1703 rcall log_show_gas
1702 1704
1703 ; OC/CC Gas List 1705 ; OC/CC gas list
1704 WIN_SMALL .5,.65 1706 WIN_SMALL .5,.65
1705 WIN_COLOR color_greenish 1707 WIN_COLOR color_greenish
1706 LOG_POINT_TO log_divemode 1708
1707 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into ext_flash_rw 1709 MOVCC header_buffer+index_divemode,WREG ; read dive mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4= pSCR)
1708 decfsz ext_flash_rw,w ; =1 (CC)? 1710 decfsz WREG,W ; dive mode = CC ?
1709 bra logbook_page3a 1711 bra logbook_page3a ; NO - print OC title
1710 STRCPY_TEXT_PRINT tGaslistCC 1712 STRCPY_TEXT_PRINT tGaslistCC ; YES - print CC title
1711 bra logbook_page3b 1713 bra logbook_page3b ; - continue with common part
1712 logbook_page3a: 1714 logbook_page3a:
1713 STRCPY_TEXT_PRINT tGaslist 1715 STRCPY_TEXT_PRINT tGaslist ; print OC title
1714 logbook_page3b: 1716 logbook_page3b:
1715 movlw color_lightblue 1717 movlw color_lightblue ; select color
1716 call TFT_set_color 1718 call TFT_set_color ; set color
1717 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) 1719 WIN_FRAME_COLOR16 .63,.220,.2,.114 ; draw a frame with coordinates top, bottom, left, right
1718 1720
1719 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco 1721 ; handle HMI
1722 rcall logbook_preloop_tasks ; clear timeout, some flags and set to speed_eco
1720 display_details2_loop: 1723 display_details2_loop:
1721 btfsc switch_right ; right button pressed? 1724 btfsc switch_right ; right button pressed?
1722 goto logbook_page4 ; YES - show more info 1725 goto logbook_page4 ; YES - show more info
1723 btfsc switch_left ; left button pressed? 1726 btfsc switch_left ; NO - left button pressed?
1724 bra exit_profileview ; YES - back to list 1727 bra exit_profileview ; YES - back to list
1725 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode 1728 call housekeeping ; NO - handle screen dump request, timeout and entering dive mode
1726 bra display_details2_loop ; - loop waiting for something to do 1729 bra display_details2_loop ; - loop waiting for something to do
1727 1730
1728 logbook_page4: ; show even more info in CC mode 1731
1729 LOG_POINT_TO log_divemode 1732 ;-----------------------------------------------------------------------------
1730 call ext_flash_byte_read ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into WREG and ext_flash_rw 1733 ; 4th Details Page after Profile: Setpoints
1731 decfsz ext_flash_rw,w ; =1 (CC)? 1734
1732 goto display_profile2 ; no 1735 logbook_page4:
1736 MOVCC header_buffer+index_divemode,WREG ; get dive mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4= pSCR)
1737 decfsz WREG,W ; =1 (CC)?
1738 goto display_profile2 ; NO - skip setpoints
1733 1739
1734 rcall log_details_header ; shows number, time/date and basic dive info 1740 rcall log_details_header ; shows number, time/date and basic dive info
1735 ; Setpoint list 1741
1736 LOG_POINT_TO log_sp1 1742 ; print setpoint list
1743 lfsr FSR0,header_buffer+index_sp1 ; load base address of the setpoints
1737 WIN_SMALL .5,.65 1744 WIN_SMALL .5,.65
1738 WIN_COLOR color_greenish 1745 WIN_COLOR color_greenish
1739 STRCPY_TEXT_PRINT tFixedSetpoints 1746 STRCPY_TEXT_PRINT tFixedSetpoints
1740 call TFT_standard_color 1747 call TFT_standard_color
1741 WIN_SMALL .5,.90 1748 WIN_SMALL .5,.90
1751 1758
1752 movlw color_greenish 1759 movlw color_greenish
1753 call TFT_set_color 1760 call TFT_set_color
1754 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; top, bottom, left, right 1761 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; top, bottom, left, right
1755 1762
1763 ; handle HMI
1756 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco 1764 rcall logbook_preloop_tasks ; clear timeout, some flags and set to Speed_eco
1757 display_details3_loop: 1765 display_details3_loop:
1758 btfsc switch_right ; right button pressed? 1766 btfsc switch_right ; right button pressed?
1759 goto display_profile2 ; YES - show the profile view again 1767 goto display_profile2 ; YES - show the profile view again
1760 btfsc switch_left ; left button pressed? 1768 btfsc switch_left ; left button pressed?
1761 bra exit_profileview ; YES - back to list 1769 bra exit_profileview ; YES - back to list
1762 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode 1770 call housekeeping ; NO to both - handle screen dump request, timeout and entering dive mode
1763 bra display_details3_loop ; - loop waiting for something to do 1771 bra display_details3_loop ; - loop waiting for something to do
1764 1772
1765 1773
1774 ;-----------------------------------------------------------------------------
1775 ; Helper Functions
1776
1766 log_details_header: 1777 log_details_header:
1767 call TFT_boot 1778 call TFT_boot
1768 1779 call TFT_standard_color
1769 ; Set ext_flash pointer to "#divenumber-oldest" dive 1780
1770 ; compute read_int_eeprom .2 - divenumber
1771 ; read required header data for profile display
1772 ; look in header for pointer to begin of diveprofile (byte 2-4)
1773 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing
1774
1775 decf divenumber,F ; -1
1776 read_int_eeprom .2
1777 movf EEDATA,W
1778 bcf STATUS,C
1779 subfwb divenumber,W ; max. dives (low value) - dive number
1780 movwf lo ; result
1781 incf divenumber,F ; +1
1782 ; Set ext_flash_address:3 to TOC entry of this dive
1783 ; 1st: 200000h-200FFFh -> lo=0
1784 ; 2nd: 201000h-201FFFh -> lo=1
1785 ; 3rd: 202000h-202FFFh -> lo=2
1786 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
1787 clrf ext_flash_address+0
1788 clrf ext_flash_address+1
1789 movlw 0x20
1790 movwf ext_flash_address+2
1791 movlw .16
1792 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
1793 movf PRODL,W
1794 addwf ext_flash_address+1,F
1795 movf PRODH,W
1796 addwfc ext_flash_address+2,F
1797 ; pointer at the first 0xFA of header
1798 rcall logbook_show_divenumber ; show the dive number in medium font 1781 rcall logbook_show_divenumber ; show the dive number in medium font
1799 ; Show date and time in first row 1782
1783 ; show date and time in first row
1800 WIN_SMALL .59,.10 1784 WIN_SMALL .59,.10
1801 LOG_POINT_TO log_date 1785 MOVTT header_buffer+index_date,mpr ; get date
1802 call ext_flash_byte_read_plus 1786 call TFT_convert_date ; convert into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in buffer
1803 movff ext_flash_rw,up ; year 1787
1804 call ext_flash_byte_read_plus
1805 movff ext_flash_rw,hi ; month
1806 call ext_flash_byte_read_plus
1807 movff ext_flash_rw,lo ; day
1808 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
1809 PUTC "-" 1788 PUTC "-"
1810 call ext_flash_byte_read_plus ; hour 1789
1811 movff ext_flash_rw,lo 1790 MOVII header_buffer+index_time,mpr ; get time
1812 call ext_flash_byte_read_plus ; minutes 1791 output_99x ; print hour
1813 movff ext_flash_rw,hi 1792 PUTC ':' ; print spacing ":"
1814 output_99x ; hour 1793 movff hi,lo ; print minute
1815 PUTC ':' 1794 output_99x ; ...
1816 movff hi,lo
1817 output_99x ; minute
1818 STRCAT_PRINT "" ; display 1st row of details 1795 STRCAT_PRINT "" ; display 1st row of details
1819 1796
1820 ; Get salinity for this dive 1797 ; show max depth and dive time
1821 LOG_POINT_TO log_salinity
1822 call ext_flash_byte_read_plus ; read salinity
1823 movff ext_flash_rw,salinity ; store salinity
1824
1825 ; Show max depth and dive time
1826 WIN_SMALL .5,.35 1798 WIN_SMALL .5,.35
1827 STRCAT "Max:" 1799 STRCAT "Max:"
1828 LOG_POINT_TO log_max_depth 1800 MOVII header_buffer+index_max_depth,mpr ; get max depth
1829 call ext_flash_byte_read_plus ; read max depth, low byte 1801
1830 movff ext_flash_rw,lo 1802 TSTOSS opt_units ; 0=Meters, 1=Feet
1831 call ext_flash_byte_read_plus ; read max depth, high byte
1832 movff ext_flash_rw,hi
1833
1834 movf salinity,W ; salinity for this dive
1835 call adjust_depth_with_salinity_log ; compute salinity setting into lo:hi [mbar]
1836
1837 TSTOSS opt_units ; 0=Meters, 1=Feets
1838 bra logbook_page2_depth_metric ; 1 - do metric 1803 bra logbook_page2_depth_metric ; 1 - do metric
1839 ; 0 - do imperial 1804 ;bra logbook_page2_depth_imperial ; 0 - do imperial
1840 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1805
1806 logbook_page2_depth_imperial:
1807 call convert_cm_to_feet ; convert value in lo:hi from [cm] to [feet]
1841 PUTC ' ' 1808 PUTC ' '
1842 bcf leftbind 1809 bcf leftbind
1843 output_16_3 1810 output_16_3
1844 STRCAT_TEXT tFeets 1811 STRCAT_TEXT tFeets
1845 bra logbook_page2_depth_common 1812 bra logbook_page2_depth_common
1846 1813
1847 logbook_page2_depth_metric: 1814 logbook_page2_depth_metric:
1848 bsf leftbind 1815 bsf ignore_digit5 ; no cm...
1849 output_16dp d'3' ; max. depth 1816 movlw d'1' ; no 1000 m
1817 movwf ignore_digits ; ...
1818 output_16dp d'3' ; xxy.y
1850 STRCAT_TEXT tMeters 1819 STRCAT_TEXT tMeters
1820 ;bra logbook_page2_depth_common
1851 1821
1852 logbook_page2_depth_common: 1822 logbook_page2_depth_common:
1853 STRCAT " - " 1823 STRCAT " - "
1854 call ext_flash_byte_read_plus ; dive time in minutes 1824 MOVTT header_buffer+index_divetime,mpr ; get dive time
1855 movff ext_flash_rw,lo
1856 call ext_flash_byte_read_plus
1857 movff ext_flash_rw,hi ; dive time in minutes
1858
1859 bsf leftbind 1825 bsf leftbind
1860 output_16 ; dive time minutes 1826 output_16 ; print minutes
1861 PUTC "m" 1827 PUTC "m"
1862 LOG_POINT_TO log_divetime+.2 1828 movff up,lo ; print seconds
1863 call ext_flash_byte_read_plus ; read dive time seconds 1829 output_99x ; ...
1864 movff ext_flash_rw,lo 1830 STRCAT_PRINT "s"
1831 return
1832
1833
1834 log_show_sp:
1835 ; log point is set by caller
1836 MOVCC POSTINC0,lo ; copy set point into lo
1837 MOVCC POSTINC0,hi ; copy change depth into hi
1838
1839 movff mpr+1,mpr+2 ; save change depth
1840 clrf mpr+1 ; set high byte to zero for printing setpoint
1865 bsf leftbind 1841 bsf leftbind
1866 output_99x ; dive time seconds 1842 output_16dp d'3' ; print setpoint x.xx
1867 call TFT_standard_color
1868 STRCAT_PRINT "s"
1869 ; ; Dive mode
1870 ; LOG_POINT_TO log_divemode
1871 ; call ext_flash_byte_read_plus ; read dive mode
1872 ; movff ext_flash_rw,lo
1873 ; call TFT_decotype_logbook ; "strcat_print"s dive mode (OC, CC, APNEA or GAUGE)
1874 return
1875
1876 ; ----------------------------------------------------------------
1877
1878 log_show_sp:
1879 lfsr FSR2,buffer
1880 call ext_flash_byte_read_plus ; read setpoint
1881 movff ext_flash_rw,lo
1882 clrf hi
1883 bsf leftbind
1884 output_16dp d'3'
1885 bcf leftbind 1843 bcf leftbind
1886 STRCAT_TEXT tbar 1844 STRCAT_TEXT tbar
1887 PUTC " " 1845 PUTC " "
1888 call ext_flash_byte_read_plus ; change depth 1846 movff mpr+2,mpr+0 ; restore change depth to lo
1889 movff ext_flash_rw,lo
1890 1847
1891 TSTOSS opt_units ; 0=Meter, 1=Feet 1848 TSTOSS opt_units ; 0=Meter, 1=Feet
1892 bra log_show_sp_metric ; 0 - do metric 1849 bra log_show_sp_metric ; 0 - do metric
1893 movf lo,W ; 1 - do imperial 1850 ;bra log_show_sp_imperial ; 1 - do imperial
1894 mullw .100 ; convert meters to mbar 1851
1895 MOVII PROD,mpr 1852 log_show_sp_imperial:
1896 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1853 call convert_meter_to_feet ; convert value in lo from [m] to [feet]
1897 output_16_3 1854 output_16_3
1898 PUTC " " 1855 PUTC " "
1899 STRCAT_TEXT tFeets ; "ft" 1856 STRCAT_TEXT tFeets ; "ft"
1900 bra log_show_sp_common 1857 bra log_show_sp_common
1858
1901 log_show_sp_metric: 1859 log_show_sp_metric:
1902 output_8 1860 output_8
1903 PUTC " " 1861 PUTC " "
1904 STRCAT_TEXT tMeters ; "m" 1862 STRCAT_TEXT tMeters ; "m"
1863 ;bra log_show_sp_common
1864
1905 log_show_sp_common: 1865 log_show_sp_common:
1906 STRCAT_PRINT "" 1866 STRCAT_PRINT ""
1907 return 1867 return
1908 1868
1909 1869
1910 log_show_gas: ; show gas data 1870 log_show_gas: ; show gas data
1911 call TFT_color_code_gas ; color the output (gas number is in WREG) 1871 call TFT_color_code_gas ; color the output (gas number is in WREG)
1912 lfsr FSR2,buffer 1872 MOVCC POSTINC0,lo ; copy O2 fraction into lo
1913 call ext_flash_byte_read_plus ; read gas O2 fraction 1873 MOVCC POSTINC0,hi ; copy He fraction into hi
1914 movff ext_flash_rw,lo 1874 call gaslist_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into buffer
1915 call ext_flash_byte_read_plus ; read gas He fraction 1875
1916 movff ext_flash_rw,hi 1876 MOVCC POSTINC0,lo ; copy change depth into lo
1917 call gaslist_show_mix ; put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 1877 MOVCC POSTINC0,hi ; copy gas type into hi
1918 call ext_flash_byte_read_plus ; read change depth
1919 movff ext_flash_rw,up
1920 call ext_flash_byte_read_plus ; read gas type - just to increment the pointer
1921 movff ext_flash_rw,ex
1922
1923 btfsc log_show_gas_short ; shall we do the short version? 1878 btfsc log_show_gas_short ; shall we do the short version?
1924 bra log_show_gas_common ; YES 1879 bra log_show_gas_common ; YES - do short version
1925 ; NO - do the long version 1880 ;bra log_show_gas_long ; NO - add gas types
1881
1882 log_show_gas_long:
1926 PUTC " " ; put one space between gas composition and gas type marking 1883 PUTC " " ; put one space between gas composition and gas type marking
1927 tstfsz ex ; gas disabled? 1884 tstfsz hi ; gas disabled?
1928 bra log_show_gas_1 ; NO - next check 1885 bra log_show_gas_1 ; NO - next check
1929 PUTC "x" ; YES - mark with "x" 1886 PUTC "x" ; YES - mark with "x"
1930 bra log_show_gas_4 ; - continue with change depth 1887 bra log_show_gas_4 ; - continue with change depth
1931 log_show_gas_1: 1888 log_show_gas_1:
1932 decfsz ex,F ; now: -1 disabled, 0 first, 1 travel, 2 deco -> first? 1889 decfsz hi,F ; now: -1 disabled, 0 first, 1 travel, 2 deco -> first?
1933 bra log_show_gas_2 ; NO - next check 1890 bra log_show_gas_2 ; NO - next check
1934 PUTC "*" ; YES - mark with "*" 1891 PUTC "*" ; YES - mark with "*"
1935 bra log_show_gas_4 ; - continue with change depth 1892 bra log_show_gas_4 ; - continue with change depth
1936 log_show_gas_2: 1893 log_show_gas_2:
1937 decf ex,F ; now: -2 disabled, -1 first, 0 travel, 1 deco 1894 decf hi,F ; now: -2 disabled, -1 first, 0 travel, 1 deco
1938 decfsz ex,F ; now: -3 disabled, -2 first, -1 travel, 0 deco -> deco? 1895 decfsz hi,F ; now: -3 disabled, -2 first, -1 travel, 0 deco -> deco?
1939 bra log_show_gas_3 ; NO - nothing to mark 1896 bra log_show_gas_3 ; NO - nothing to mark
1940 PUTC "=" ; YES - mark with "=" 1897 PUTC "=" ; YES - mark with "="
1941 bra log_show_gas_4 ; - continue with change depth 1898 bra log_show_gas_4 ; - continue with change depth
1942 log_show_gas_3: 1899 log_show_gas_3:
1943 PUTC " " ; print a space in absence of any other marking 1900 PUTC " " ; print a space in absence of any other marking
1944 log_show_gas_4: 1901 log_show_gas_4:
1945 PUTC " " ; put one space between gas type marking and change depth 1902 PUTC " " ; put one space between gas type marking and change depth
1903
1946 TSTOSS opt_units ; 0=Meter, 1=Feet 1904 TSTOSS opt_units ; 0=Meter, 1=Feet
1947 bra log_show_gas_metric ; 0 - do metric 1905 bra log_show_gas_metric ; 0 - do metric
1948 movf up,W ; 1 - do imperial 1906 ;bra log_show_gas_imperial ; 1 - do imperial
1949 mullw .100 ; convert meters to mbar 1907
1950 MOVII PROD,mpr 1908 log_show_gas_imperial:
1951 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet 1909 call convert_meter_to_feet ; convert value in lo from [m] to [feet]
1952 output_16_3 ; limit to 999 and display only 0-999 1910 output_16_3 ; limit to 999 and display only 0-999
1953 STRCAT_TEXT tFeets ; "ft" 1911 STRCAT_TEXT tFeets ; "ft"
1954 bra log_show_gas_common 1912 bra log_show_gas_common
1913
1955 log_show_gas_metric: 1914 log_show_gas_metric:
1956 movff up,lo
1957 output_8 1915 output_8
1958 STRCAT_TEXT tMeters ; "m" 1916 STRCAT_TEXT tMeters ; "m"
1917 ;bra log_show_gas_common
1918
1959 log_show_gas_common: 1919 log_show_gas_common:
1960 STRCAT_PRINT "" 1920 STRCAT_PRINT ""
1961 return 1921 return
1962 1922
1963 1923
1964 log_compute_divenumber: 1924 log_compute_divenumber:
1965 movwf mpr+2 ; store current dive number to mpr+2 1925 movwf mpr+2 ; store current dive number in mpr+2
1966 call do_logoffset_common_read ; read log offset into mpr 1926 call eeprom_log_offset_read ; read log offset into mpr+0 & +1
1967 ; check if offset = 0 1927 ; check if offset = 0
1968 tstfsz mpr+0 ; mpr+0 (low byte) = 0 ? 1928 tstfsz mpr+0 ; low byte = 0 ?
1969 bra log_compute_divenumber_2 ; NO - apply offset 1929 bra log_compute_divenumber_2 ; NO - apply offset
1970 tstfsz mpr+1 ; mpr+1 (high byte) = 0 ? 1930 tstfsz mpr+1 ; YES - high byte = 0 ?
1971 bra log_compute_divenumber_2 ; NO - apply offset 1931 bra log_compute_divenumber_2 ; NO - apply offset
1972 log_compute_divenumber_1: ; YES to both - no offset 1932 ;bra log_compute_divenumber_1 ; YES - no offset
1933
1934 log_compute_divenumber_1:
1973 movff mpr+2,mpr+0 ; use plain number from dive list 1935 movff mpr+2,mpr+0 ; use plain number from dive list
1974 clrf mpr+1 ; set high byte to 0 1936 clrf mpr+1 ; set high byte to 0
1975 return ; done 1937 return ; done
1938
1976 log_compute_divenumber_2: 1939 log_compute_divenumber_2:
1977 ; check limit (offset must be < 10000) 1940 ; check limit (offset must be < 10000)
1978 MOVLI .9999,sub_a ; sub_a = 9999 1941 MOVLI .9999,sub_a ; sub_a = 9999
1979 MOVII mpr, sub_b ; sub_b = offset 1942 MOVII mpr, sub_b ; sub_b = offset
1980 call cmpU16 ; 9999 - offset 1943 call cmpU16 ; 9999 - offset
1986 clrf sub_b+1 ; - high byte is 0 1949 clrf sub_b+1 ; - high byte is 0
1987 call subU16 ; - sub_c = offset + 1 - (number from list) 1950 call subU16 ; - sub_c = offset + 1 - (number from list)
1988 MOVII sub_c,mpr ; - copy result back to mpr 1951 MOVII sub_c,mpr ; - copy result back to mpr
1989 return ; - done 1952 return ; - done
1990 1953
1954 ;----------------------------------------------------------------------------
1955 ; Compute flash address for header data of a particular dive
1956 ;
1957 ; Memory map in flash:
1958 ;
1959 ; low(total number of dives) -> index -> start address end address
1960 ; --------------------------------------------------------------------
1961 ; 1 0 0x2|00|000 - 0x2|00|FFF
1962 ; 2 1 0x2|01|000 - 0x2|01|FFF
1963 ; 3 2 0x2|02|000 - 0x2|02|FFF
1964 ; ...
1965 ; 256 -> 0 255 0x2|FF|000 - 0x2|FF|FFF
1966
1967 log_header_addr_by_divenumber:
1968 ; compute index of the dive with number 'divenumber'
1969 decf divenumber,W ; compute number of dive to show -1...
1970 movwf mpr+3 ; ... and store in mpr+3
1971 movf total_num_dives,W ; get number of total dives (low byte)
1972 bcf STATUS,C ; clear carry/borrow bit
1973 subfwb mpr+3,W ; index = number of total dives - number of dive to show + 1
1974 ;bra log_header_addr_by_index ; get address by index
1975
1976 global log_header_addr_by_index
1977 log_header_addr_by_index:
1978 ; compute the start address of the header belonging to the dive whose index is in WREG
1979 movwf mpr+3 ; copy index to mpr+3
1980 clrf mpr+0 ; set up base address 0x200000
1981 clrf mpr+1 ; ...
1982 movlw 0x20 ; ...
1983 movwf mpr+2 ; ...
1984 movlw .16 ; prepare a shift left by 4 bit
1985 mulwf mpr+3 ; shift left index to create offset
1986 movf PRODL,W ; get low byte of offset
1987 addwf mpr+1,F ; add to high byte of address
1988 movf PRODH,W ; get high byte of offset
1989 addwfc mpr+2,F ; add to upper byte of address
1990
1991 return
1992
1991 ; ---------------------------------------------------------------- 1993 ; ----------------------------------------------------------------
1992 1994
1993 END 1995 END