Mercurial > public > hwos_code
comparison src/logbook.asm @ 0:11d4fc797f74
init
| author | heinrichsweikamp |
|---|---|
| date | Wed, 24 Apr 2013 19:22:45 +0200 |
| parents | |
| children | f65d070a5b76 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:11d4fc797f74 |
|---|---|
| 1 ;============================================================================= | |
| 2 ; | |
| 3 ; File logbook.asm | |
| 4 ; | |
| 5 ; Logbook | |
| 6 ; | |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
| 8 ;============================================================================= | |
| 9 ; HISTORY | |
| 10 ; 2011-11-12 : [mH] moving from OSTC code | |
| 11 | |
| 12 ;============================================================================= | |
| 13 ; Temp data, local to this module, moved to ACCES0 area. | |
| 14 ; | |
| 15 | |
| 16 #include "ostc3.inc" ; Mandatory header | |
| 17 #include "tft.inc" | |
| 18 #include "external_flash.inc" | |
| 19 #include "math.inc" | |
| 20 #include "strings.inc" | |
| 21 #include "convert.inc" | |
| 22 #include "tft_outputs.inc" | |
| 23 #include "eeprom_rs232.inc" | |
| 24 #include "menu_processor.inc" | |
| 25 #include "wait.inc" | |
| 26 #include "start.inc" | |
| 27 #include "surfmode.inc" | |
| 28 #include "divemode.inc" | |
| 29 #include "ghostwriter.inc" | |
| 30 | |
| 31 extern do_main_menu,comm_mode | |
| 32 | |
| 33 CBLOCK tmp+0x40 ; Keep space for menu processor. | |
| 34 count_temperature ; Current sample count for temperature divisor | |
| 35 count_deco ; Current sample count for deco (ceiling) divisor | |
| 36 logbook_cur_depth:2 ; Current depth, for drawing profile. | |
| 37 logbook_cur_tp:2 ; Current temperature, for drawing profile. | |
| 38 logbook_last_tp ; Y of the last item in Tp° curve. | |
| 39 logbook_min_tp:2 ; Min temperature, for drawing profile. | |
| 40 logbook_max_tp:2 ; Maximum temperature, for drawing profile. | |
| 41 logbook_ceiling ; Current ceiling, for drawing profile. | |
| 42 logbook_flags ; Flags only used in logbook.asm | |
| 43 logbook_page_number ; Page# in logbook | |
| 44 logbook_divenumber ; # of dive in list during search | |
| 45 logbook_divenumber_temp ; # of dive in list during search | |
| 46 logbook_menupos_temp ; Last position of cursor | |
| 47 profile_temp:2 ; Temp for profile display | |
| 48 profile_temp2:2 ; Temp for profile display | |
| 49 logbook_max_dive_counter ; Counts dive# to zero | |
| 50 logbook_max_dive_counter_temp; Counts dive# to zero | |
| 51 logbook_sample_counter:2 ; Amount of read samples | |
| 52 divemins_backup ; Backup of divemins+0 | |
| 53 y_scale:2 ; y-scale (The horizontal lines) | |
| 54 x_scale:2 ; x-scale (The vertical lines) | |
| 55 logbook_pixel_x_pos ; x2 position of current pixel in X-direction | |
| 56 ; Reserved to tmp+0x5F | |
| 57 ENDC | |
| 58 | |
| 59 #DEFINE return_from_profileview logbook_flags,0 | |
| 60 #DEFINE all_dives_shown logbook_flags,1 | |
| 61 #DEFINE logbook_page_not_empty logbook_flags,2 | |
| 62 #DEFINE end_of_profile logbook_flags,3 | |
| 63 | |
| 64 | |
| 65 ; Logbook Coordinates | |
| 66 #DEFINE logbook_list_left .18 ; Column of dive# in list | |
| 67 #DEFINE logbook_row_offset .28 ; Distance between rows of list | |
| 68 #DEFINE logbook_row_number .6 ; Amount of rows in the list | |
| 69 | |
| 70 ; Profile display | |
| 71 #DEFINE profile_height_pixels .157 ; Amount of pixels height for profile display | |
| 72 #DEFINE profile_width_pixels .156 ; Amount of pixels width for profile display | |
| 73 #DEFINE profile_left .1 ; Left border | |
| 74 #DEFINE profile_top .65 ; Top border | |
| 75 | |
| 76 ; Dive number | |
| 77 #DEFINE logbook_divenumer_column .1 | |
| 78 #DEFINE logbook_divenumer_row .1 | |
| 79 ; Date and Time | |
| 80 #DEFINE logbook_date_column .100 | |
| 81 #DEFINE logbook_date_row .7 | |
| 82 #DEFINE logbook_time_column .120 | |
| 83 #DEFINE logbook_time_row .33 | |
| 84 ; Max. Depth | |
| 85 #DEFINE log_max_value_row .38 | |
| 86 #DEFINE log_max_value_column .1 | |
| 87 ; Divetime | |
| 88 #DEFINE log_divetime_value_row .38 | |
| 89 #DEFINE log_divetime_value_column .65 | |
| 90 ; Gaslist below profile | |
| 91 #DEFINE log_gas_row .225 | |
| 92 #DEFINE log_gas_column1 .0 | |
| 93 #DEFINE log_gas_column2 log_gas_column1+(.1*.32) | |
| 94 #DEFINE log_gas_column3 log_gas_column1+(.2*.32) | |
| 95 #DEFINE log_gas_column4 log_gas_column1+(.3*.32) | |
| 96 #DEFINE log_gas_column5 log_gas_column1+(.4*.32) | |
| 97 | |
| 98 ; Logbook Page2 | |
| 99 ; Gaslist | |
| 100 #DEFINE log2_title_row1 .20 | |
| 101 #DEFINE log2_title_column .90 | |
| 102 #DEFINE log2_gas_column log2_title_column | |
| 103 #DEFINE log2_gas_row1 .36 | |
| 104 #DEFINE log2_gas_row2 1*.16+log2_gas_row1 | |
| 105 #DEFINE log2_gas_row3 2*.16+log2_gas_row1 | |
| 106 #DEFINE log2_gas_row4 3*.16+log2_gas_row1 | |
| 107 #DEFINE log2_gas_row5 4*.16+log2_gas_row1 | |
| 108 | |
| 109 ; Setpoint List | |
| 110 #DEFINE log2_title_sp_row .130 | |
| 111 #DEFINE log2_sp_row1 .146 | |
| 112 #DEFINE log2_sp_row2 1*.16+log2_sp_row1 | |
| 113 #DEFINE log2_sp_row3 2*.16+log2_sp_row1 | |
| 114 #DEFINE log2_sp_row4 3*.16+log2_sp_row1 | |
| 115 #DEFINE log2_sp_row5 4*.16+log2_sp_row1 | |
| 116 | |
| 117 ; Details list | |
| 118 #DEFINE log2_salinity_row .55 | |
| 119 #DEFINE log2_salinity_column .2 | |
| 120 #DEFINE log2_cns_row .1*.16+log2_salinity_row | |
| 121 #DEFINE log2_cns_column log2_salinity_column | |
| 122 #DEFINE log2_avr_row .2*.16+log2_salinity_row | |
| 123 #DEFINE log2_avr_column log2_salinity_column | |
| 124 #DEFINE log2_decomodel2_row .3*.16+log2_salinity_row | |
| 125 #DEFINE log2_decomodel2_column log2_salinity_column | |
| 126 #DEFINE log2_decomodel3_row .4*.16+log2_salinity_row | |
| 127 #DEFINE log2_decomodel3_column log2_salinity_column | |
| 128 #DEFINE log2_decomodel_row .5*.16+log2_salinity_row | |
| 129 #DEFINE log2_decomodel_column log2_salinity_column | |
| 130 #DEFINE log2_firmware_row .6*.16+log2_salinity_row | |
| 131 #DEFINE log2_firmware_column log2_salinity_column | |
| 132 #DEFINE log2_battery_row .7*.16+log2_salinity_row | |
| 133 #DEFINE log2_battery_column log2_salinity_column | |
| 134 #DEFINE log2_divemode_row .8*.16+log2_salinity_row | |
| 135 #DEFINE log2_divemode_column log2_salinity_column | |
| 136 #DEFINE log2_lastdeco_row .9*.16+log2_salinity_row | |
| 137 #DEFINE log2_lastdeco_column log2_salinity_column | |
| 138 ; Air pressure | |
| 139 #DEFINE MBAR_row .10*.16+log2_salinity_row | |
| 140 #DEFINE MBAR_column log2_salinity_column | |
| 141 | |
| 142 | |
| 143 ; Header coordinates | |
| 144 #DEFINE log_date .12 | |
| 145 #DEFINE log_time .15 | |
| 146 #DEFINE log_max_depth .17 | |
| 147 #DEFINE log_divetime .19 | |
| 148 #DEFINE log_min_temp .22 | |
| 149 #DEFINE log_surface_press .24 | |
| 150 #DEFINE log_desattime .26 | |
| 151 #DEFINE log_gas1 .28 | |
| 152 #DEFINE log_gas2 .32 | |
| 153 #DEFINE log_gas3 .36 | |
| 154 #DEFINE log_gas4 .40 | |
| 155 #DEFINE log_gas5 .44 | |
| 156 #DEFINE log_firmware .48 | |
| 157 #DEFINE log_battery .50 | |
| 158 #DEFINE log_samplingrate .52 | |
| 159 #DEFINE log_cns_start .53 | |
| 160 #DEFINE log_gf_start .55 | |
| 161 #DEFINE log_gf_end .56 | |
| 162 #DEFINE log_sp1 .60 | |
| 163 #DEFINE log_sp2 .62 | |
| 164 #DEFINE log_sp3 .64 | |
| 165 #DEFINE log_sp4 .66 | |
| 166 #DEFINE log_sp5 .68 | |
| 167 #DEFINE log_salinity .70 | |
| 168 #DEFINE log_cns_end .71 | |
| 169 #DEFINE log_avr_depth .73 | |
| 170 #DEFINE log_total_seconds .75 | |
| 171 #DEFINE log_gf_lo .77 | |
| 172 #DEFINE log_sat_mult .77 | |
| 173 #DEFINE log_gf_hi .78 | |
| 174 #DEFINE log_desat_mult .78 | |
| 175 #DEFINE log_decomodel .79 | |
| 176 #DEFINE log_total_dives .80 | |
| 177 #DEFINE log_divemode .82 | |
| 178 #DEFINE log_last_stop .243 | |
| 179 | |
| 180 LOG_POINT_TO macro address | |
| 181 movlw address | |
| 182 movwf ext_flash_address+0 | |
| 183 endm | |
| 184 | |
| 185 ;============================================================================= | |
| 186 | |
| 187 logbook code | |
| 188 | |
| 189 TFT_logbook_cursor: | |
| 190 call speed_fastest | |
| 191 WIN_BOX_BLACK .0, .239, logbook_list_left-.16, logbook_list_left-.1 ;top, bottom, left, right | |
| 192 | |
| 193 WIN_LEFT logbook_list_left-.16 | |
| 194 WIN_FONT FT_SMALL | |
| 195 WIN_INVERT .0 ; Init new Wordprocessor | |
| 196 call TFT_standard_color | |
| 197 | |
| 198 movff menupos,temp1 | |
| 199 dcfsnz temp1,F | |
| 200 movlw d'0' | |
| 201 dcfsnz temp1,F | |
| 202 movlw logbook_row_offset | |
| 203 dcfsnz temp1,F | |
| 204 movlw .2*logbook_row_offset | |
| 205 dcfsnz temp1,F | |
| 206 movlw .3*logbook_row_offset | |
| 207 dcfsnz temp1,F | |
| 208 movlw .4*logbook_row_offset | |
| 209 dcfsnz temp1,F | |
| 210 movlw .5*logbook_row_offset | |
| 211 dcfsnz temp1,F | |
| 212 movlw .6*logbook_row_offset | |
| 213 dcfsnz temp1,F | |
| 214 movlw .7*logbook_row_offset | |
| 215 dcfsnz temp1,F | |
| 216 movlw .8*logbook_row_offset | |
| 217 | |
| 218 movff WREG,win_top | |
| 219 STRCPY_PRINT "\xB7" | |
| 220 return | |
| 221 | |
| 222 global logbook | |
| 223 logbook: | |
| 224 clrf logbook_flags | |
| 225 clrf CCP1CON ; stop PWM | |
| 226 bcf PORTC,2 ; Pull PWM out to GND | |
| 227 call TFT_ClearScreen ; Clear screen | |
| 228 call TFT_standard_color | |
| 229 clrf menupos3 ; Here: used rows on current logbook-page | |
| 230 clrf logbook_page_number ; Here: # of current displayed page | |
| 231 clrf logbook_divenumber ; # of dive in list during search | |
| 232 clrf divemins+0 ; Here: used as temp variables | |
| 233 clrf divemins+1 | |
| 234 clrf timeout_counter2 ; For timeout | |
| 235 movlw logbook_row_number | |
| 236 movwf menupos ; Here: stores current position on display (logbook_row_number-x) | |
| 237 read_int_eeprom .2 ; Get low-byte of total dives | |
| 238 movff EEDATA,logbook_max_dive_counter | |
| 239 | |
| 240 ;----------------------------------------------------------------------------- | |
| 241 ; display dive headers backwards from read_int_eeprom .2 = lo-1 | |
| 242 ; 1st: 200000h-200FFFh -> lo=0 | |
| 243 ; 2nd: 201000h-201FFFh -> lo=1 | |
| 244 ; 3rd: 202000h-202FFFh -> lo=2 | |
| 245 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
| 246 ; Stop when | |
| 247 ; a) no dive is stored (no valid header found) | |
| 248 ; b) current dive has no valid header (Number of stored dives < 256) | |
| 249 ; c) when 255 dives are reached divemins+0 = 255 | |
| 250 | |
| 251 logbook2: | |
| 252 call speed_fastest | |
| 253 incf divemins+0,F ; increase dive counter | |
| 254 incf divemins+0,W ; = 0x..FF ? | |
| 255 bz logbook_reset ; Yes: FF --> loop. | |
| 256 | |
| 257 ; Set ext_flash_address:3 to TOC entry of this dive | |
| 258 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0 | |
| 259 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1 | |
| 260 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2 | |
| 261 ; 256: 2FF000h-2FFFFFh -> logbook_max_dive_counter=255 (And hi>0...) | |
| 262 | |
| 263 decf logbook_max_dive_counter,F ; -1 | |
| 264 | |
| 265 clrf ext_flash_address+0 | |
| 266 clrf ext_flash_address+1 | |
| 267 movlw 0x20 | |
| 268 movwf ext_flash_address+2 | |
| 269 movlw .16 | |
| 270 mulwf logbook_max_dive_counter; logbook_max_dive_counter*16 = offset to 0x2000 (up:hi) | |
| 271 movf PRODL,W | |
| 272 addwf ext_flash_address+1,F | |
| 273 movf PRODH,W | |
| 274 addwfc ext_flash_address+2,F | |
| 275 ; pointer at the first 0xFA of header | |
| 276 | |
| 277 call ext_flash_byte_read ; Reads one byte@ext_flash_address:3 into WREG and temp1 | |
| 278 movwf temp1 | |
| 279 movlw 0xFA | |
| 280 cpfseq temp1 ; 0xFA found? | |
| 281 bra logbook3b ; No, abort | |
| 282 | |
| 283 incf logbook_divenumber,F ; new header found, increase logbook_divenumber | |
| 284 bra logbook4 ; Done with searching, display the header! | |
| 285 | |
| 286 logbook3b: | |
| 287 btfss logbook_page_not_empty ; Was there at least one dive? | |
| 288 goto do_main_menu ; Not a single header was found, leave logbook. | |
| 289 bra logbook_display_loop2 | |
| 290 | |
| 291 logbook_reset: | |
| 292 tstfsz logbook_divenumber ; Was there at least one dive? | |
| 293 bra logbook_reset2 | |
| 294 bra logbook3b ; No, Nothing to do | |
| 295 | |
| 296 logbook_reset2: | |
| 297 bsf all_dives_shown ; Yes | |
| 298 bra logbook_display_loop2 ; Continue | |
| 299 | |
| 300 logbook4: | |
| 301 btfsc all_dives_shown ; All dives displayed? | |
| 302 bra logbook_display_loop2 ; Yes, but display first page again. | |
| 303 | |
| 304 call display_listdive ; display short header for list on current list position | |
| 305 | |
| 306 movlw logbook_row_number | |
| 307 cpfseq menupos ; first dive on list (top place)? | |
| 308 bra logbook_display_loop1 ; no, so skip saving of address | |
| 309 | |
| 310 ; store all registered required to rebuilt the current logbookpage after the detail/profile view | |
| 311 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page | |
| 312 movff divemins+0,divemins_backup ; amount of dives drawn until now | |
| 313 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup Counter | |
| 314 | |
| 315 logbook_display_loop1: | |
| 316 decfsz menupos,F ; List full? | |
| 317 bra logbook2 ; no, search another dive for our current logbook page | |
| 318 | |
| 319 logbook_display_loop2: | |
| 320 btfss logbook_page_not_empty ; Was there one dive at all? | |
| 321 bra logbook ; Yes, so reload the first page | |
| 322 | |
| 323 ; TFT_mask... | |
| 324 | |
| 325 WIN_LEFT logbook_list_left | |
| 326 WIN_TOP logbook_row_offset*logbook_row_number | |
| 327 STRCPY_TEXT_PRINT tNextLog ; "Next Page" | |
| 328 WIN_LEFT logbook_list_left | |
| 329 WIN_TOP logbook_row_offset*(logbook_row_number+.1) | |
| 330 STRCPY_TEXT_PRINT tExitLog ; "Exit Logbook" | |
| 331 | |
| 332 movlw d'1' ; Set cursor to position 1... | |
| 333 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view | |
| 334 movf logbook_menupos_temp,W ; load last cursor position again | |
| 335 movwf menupos ; and set menupos byte | |
| 336 bcf return_from_profileview ; Do this only once while the page is loaded again! | |
| 337 | |
| 338 bcf logbook_page_not_empty ; Obviously the current page is NOT empty | |
| 339 call TFT_logbook_cursor | |
| 340 | |
| 341 call logbook_preloop_tasks ; Clear some flags and set to Speed_eco | |
| 342 logbook_loop: | |
| 343 btfsc switch_left ; SET/MENU? | |
| 344 goto next_logbook3 ; adjust cursor or create new page | |
| 345 btfsc switch_right ; ENTER? | |
| 346 bra display_profile_or_exit ; view details/profile or exit logbook | |
| 347 | |
| 348 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | |
| 349 btfsc sleepmode ; Timeout? | |
| 350 goto do_main_menu ; Yes | |
| 351 | |
| 352 bra logbook_loop ; Wait for something to do | |
| 353 | |
| 354 display_profile_or_exit: | |
| 355 movlw logbook_row_number+.2 ; exit? | |
| 356 cpfseq menupos | |
| 357 bra display_profile_or_exit2 ; No, check for "Next Page" | |
| 358 goto do_main_menu | |
| 359 | |
| 360 display_profile_or_exit2: | |
| 361 movlw logbook_row_number+.1 ; Next page? | |
| 362 cpfseq menupos | |
| 363 bra display_profile ; No, show details/profile | |
| 364 goto next_logbook2 ; Next page! | |
| 365 | |
| 366 display_profile: | |
| 367 call speed_fastest | |
| 368 movff menupos,logbook_menupos_temp; store current cursor position | |
| 369 bsf return_from_profileview ; tweak search routine to exit after found | |
| 370 | |
| 371 movf logbook_page_number,W ; Number of page | |
| 372 mullw logbook_row_number | |
| 373 movf PRODL,W | |
| 374 addwf menupos,W ; page*logbook_row_number+menupos= | |
| 375 movwf divesecs ; # of dive to show | |
| 376 | |
| 377 display_profile2: | |
| 378 call speed_fastest | |
| 379 clrf CCP1CON ; stop PWM | |
| 380 bcf PORTC,2 ; Pull PWM out to GND | |
| 381 call TFT_ClearScreen ; Clear screen | |
| 382 ; Set ext_flash pointer to "#divesecs-oldest" dive | |
| 383 ; compute read_int_eeprom .2 - divesecs | |
| 384 ; Read required header data for profile display | |
| 385 ; look in header for pointer to begin of diveprofile (Byte 2-4) | |
| 386 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing | |
| 387 | |
| 388 decf divesecs,F ;-1 | |
| 389 read_int_eeprom .2 | |
| 390 movf EEDATA,W | |
| 391 bcf STATUS,C | |
| 392 subfwb divesecs,W ; max. dives (low value) - divesecs | |
| 393 movwf lo ; result | |
| 394 incf divesecs,F ;+1 | |
| 395 ; Set ext_flash_address:3 to TOC entry of this dive | |
| 396 ; 1st: 200000h-200FFFh -> lo=0 | |
| 397 ; 2nd: 201000h-201FFFh -> lo=1 | |
| 398 ; 3rd: 202000h-202FFFh -> lo=2 | |
| 399 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
| 400 clrf ext_flash_address+0 | |
| 401 clrf ext_flash_address+1 | |
| 402 movlw 0x20 | |
| 403 movwf ext_flash_address+2 | |
| 404 movlw .16 | |
| 405 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
| 406 movf PRODL,W | |
| 407 addwf ext_flash_address+1,F | |
| 408 movf PRODH,W | |
| 409 addwfc ext_flash_address+2,F | |
| 410 ; pointer at the first 0xFA of header | |
| 411 | |
| 412 ; Now, show profile | |
| 413 LOG_POINT_TO log_samplingrate | |
| 414 call ext_flash_byte_read ; Read sampling rate | |
| 415 movff temp1,samplesecs_value ; needed later... | |
| 416 | |
| 417 LOG_POINT_TO .2 | |
| 418 call ext_flash_byte_read_plus ; Read start address of profile | |
| 419 movff temp1,ext_flash_log_pointer+0 | |
| 420 call ext_flash_byte_read_plus ; Read start address of profile | |
| 421 movff temp1,ext_flash_log_pointer+1 | |
| 422 call ext_flash_byte_read_plus ; Read start address of profile | |
| 423 movff temp1,ext_flash_log_pointer+2 | |
| 424 | |
| 425 | |
| 426 clrf logbook_sample_counter+0 | |
| 427 clrf logbook_sample_counter+1 ; holds amount of read samples | |
| 428 | |
| 429 call TFT_standard_color | |
| 430 call logbook_show_divenumber ; Show the dive number in medium font | |
| 431 | |
| 432 WIN_SMALL logbook_date_column, logbook_date_row | |
| 433 lfsr FSR2,buffer | |
| 434 LOG_POINT_TO log_date | |
| 435 call ext_flash_byte_read_plus | |
| 436 movff temp1,convert_value_temp+2 ; Year | |
| 437 call ext_flash_byte_read_plus | |
| 438 movff temp1,convert_value_temp+0 ; Month | |
| 439 call ext_flash_byte_read_plus | |
| 440 movff temp1,convert_value_temp+1 ; Day | |
| 441 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
| 442 STRCAT_PRINT "" | |
| 443 | |
| 444 WIN_SMALL logbook_time_column, logbook_time_row | |
| 445 lfsr FSR2,buffer | |
| 446 call ext_flash_byte_read_plus ; hour | |
| 447 movff temp1,lo | |
| 448 call ext_flash_byte_read_plus ; Minutes | |
| 449 movf lo,W | |
| 450 mullw .60 | |
| 451 movff temp1,WREG | |
| 452 addwf PRODL,F | |
| 453 movlw .0 | |
| 454 addwfc PRODH,F ; PRODH:PRODL has end-of-dive time in minutes | |
| 455 | |
| 456 LOG_POINT_TO log_total_seconds | |
| 457 call ext_flash_byte_read_plus ; Total sample time in seconds | |
| 458 movff temp1,lo | |
| 459 call ext_flash_byte_read_plus ; Total sample time in seconds | |
| 460 movff temp1,hi | |
| 461 call convert_time ; converts hi:lo in seconds to mins (hi) and seconds (lo) | |
| 462 clrf sub_b+1 | |
| 463 movff hi,sub_b+0 | |
| 464 movff PRODL,sub_a+0 | |
| 465 movff PRODH,sub_a+1 | |
| 466 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | |
| 467 ; sub_c:2 holds entry time in minutes | |
| 468 movff sub_c+0,lo | |
| 469 movff sub_c+1,hi | |
| 470 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
| 471 movff lo,PRODL ; temp | |
| 472 movff hi,lo | |
| 473 output_99x ; hour | |
| 474 PUTC ':' | |
| 475 movff PRODL,lo | |
| 476 output_99x ; minute | |
| 477 STRCAT_PRINT "" ; Display 1st row of details | |
| 478 | |
| 479 LOG_POINT_TO log_max_depth | |
| 480 call ext_flash_byte_read_plus ; read max depth | |
| 481 movff temp1,lo | |
| 482 call ext_flash_byte_read_plus ; read max depth | |
| 483 movff temp1,hi | |
| 484 movff lo,xA+0 ; calculate y-scale for profile display | |
| 485 movff hi,xA+1 | |
| 486 movlw profile_height_pixels ; pixel height available for profile | |
| 487 movwf xB+0 | |
| 488 clrf xB+1 | |
| 489 call div16x16 ; does xA/xB=xC | |
| 490 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!) | |
| 491 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!) | |
| 492 incf y_scale+0,F ; increase one, because there may be a remainder | |
| 493 movlw d'0' | |
| 494 addwfc y_scale+1,F | |
| 495 | |
| 496 movlw LOW ((profile_height_pixels+1)*.1000) | |
| 497 movwf xC+0 | |
| 498 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF') | |
| 499 movwf xC+1 | |
| 500 movlw UPPER ((profile_height_pixels+1)*.1000) | |
| 501 movwf xC+2 | |
| 502 clrf xC+3 | |
| 503 | |
| 504 movff lo,xB+0 ; Max. Depth in mbar | |
| 505 movff hi,xB+1 ; Max. Depth in mbar | |
| 506 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
| 507 | |
| 508 movff xC+0,x_scale+0 ; | |
| 509 movff xC+1,x_scale+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line) | |
| 510 | |
| 511 movf x_scale+0,W | |
| 512 iorwf x_scale+1,W ; x_scale:2 = Null? | |
| 513 bnz display_profile_offset4 ; No, continue | |
| 514 incf x_scale+1,F ; Yes, make x_scale+1>1 to make "display_profile2e" working | |
| 515 | |
| 516 display_profile_offset4: | |
| 517 WIN_SMALL log_max_value_column,log_max_value_row | |
| 518 lfsr FSR2,buffer | |
| 519 | |
| 520 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 521 bra display_profile_offset4_metric | |
| 522 ;display_profile_offset4_imperial: | |
| 523 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 524 PUTC ' ' | |
| 525 bsf ignore_digit4 | |
| 526 movlw d'1' | |
| 527 movff WREG,ignore_digits | |
| 528 bsf leftbind | |
| 529 output_16 ; full feet | |
| 530 STRCAT_TEXT_PRINT tFeets | |
| 531 bra display_profile_offset4_common | |
| 532 | |
| 533 display_profile_offset4_metric: | |
| 534 bsf leftbind | |
| 535 output_16dp d'3' ; max. depth | |
| 536 STRCAT_TEXT_PRINT tMeters | |
| 537 | |
| 538 display_profile_offset4_common: | |
| 539 call ext_flash_byte_read_plus ; divetime in minutes | |
| 540 movff temp1,lo | |
| 541 call ext_flash_byte_read_plus | |
| 542 movff temp1,hi ; divetime in minutes | |
| 543 | |
| 544 movff lo,xA+0 ; calculate x-scale for profile display | |
| 545 movff hi,xA+1 ; calculate total diveseconds first | |
| 546 movlw d'60' ; 60seconds are one minute... | |
| 547 movwf xB+0 | |
| 548 clrf xB+1 | |
| 549 call mult16x16 ; result is in xC:2 ! | |
| 550 | |
| 551 WIN_SMALL log_divetime_value_column,log_divetime_value_row | |
| 552 lfsr FSR2,buffer | |
| 553 bsf leftbind | |
| 554 output_16 ; divetime minutes | |
| 555 movlw LOW d'600' | |
| 556 movwf xA+0 | |
| 557 movlw HIGH d'600' | |
| 558 movwf xA+1 ; A vertical line every 600 seconds | |
| 559 movff samplesecs_value,xB+0 ; Copy sampling rate | |
| 560 clrf xB+1 | |
| 561 call div16x16 ; xA/xB=xC with xA as remainder | |
| 562 movff xC+0,average_depth_hold_total+0 | |
| 563 movff xC+1,average_depth_hold_total+1 | |
| 564 ;average_depth_hold_total:2 holds interval of samples for vertical 10min line | |
| 565 | |
| 566 ; Restore divetime in minutes: | |
| 567 ; get real sample time | |
| 568 LOG_POINT_TO log_total_seconds | |
| 569 call ext_flash_byte_read_plus ; Total sample time in seconds | |
| 570 movff temp1,xC+0 | |
| 571 call ext_flash_byte_read_plus ; Total sample time in seconds | |
| 572 movff temp1,xC+1 | |
| 573 | |
| 574 PUTC ':' | |
| 575 LOG_POINT_TO log_divetime+.2 | |
| 576 call ext_flash_byte_read_plus ; read divetime seconds | |
| 577 movff temp1,lo | |
| 578 movff xC+0,xA+0 ; now calculate x-scale value | |
| 579 movff xC+1,xA+1 | |
| 580 movlw profile_width_pixels ; pix width available | |
| 581 movwf xB+0 | |
| 582 clrf xB+1 | |
| 583 call div16x16 ; xA/xB=xC | |
| 584 movff xC+0,xA+0 | |
| 585 movff xC+1,xA+1 | |
| 586 movf samplesecs_value,W ; devide through sample interval! | |
| 587 movwf xB+0 | |
| 588 clrf xB+1 | |
| 589 call div16x16 ; xA/xB=xC | |
| 590 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers | |
| 591 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers | |
| 592 incf profile_temp+0,F ; Increase by one, there might be a remainder | |
| 593 movlw d'0' | |
| 594 addwfc profile_temp+1,F | |
| 595 | |
| 596 bsf leftbind | |
| 597 output_99x ; divetime seconds | |
| 598 call TFT_standard_color | |
| 599 STRCAT_PRINT "" | |
| 600 | |
| 601 call ext_flash_byte_read_plus ; Read min. Temperature | |
| 602 movff temp1,logbook_min_tp+0 | |
| 603 call ext_flash_byte_read_plus ; Read min. Temperature | |
| 604 movff temp1,logbook_min_tp+1 | |
| 605 | |
| 606 ; Set pointer to Gas 1 Type. | |
| 607 LOG_POINT_TO log_gas1+.3 | |
| 608 call ext_flash_byte_read_plus ; read Gas Type | |
| 609 decfsz temp1,W ; =1 (="First")? | |
| 610 bra logbook_find_first_gas2 ; No. | |
| 611 movlw .1 | |
| 612 movwf temp1 | |
| 613 bra logbook_find_first_gas_done | |
| 614 logbook_find_first_gas2: | |
| 615 ; Set pointer to Gas 2 Type. | |
| 616 LOG_POINT_TO log_gas2+.3 | |
| 617 call ext_flash_byte_read_plus ; read Gas Type | |
| 618 decfsz temp1,W ; =1 (="First")? | |
| 619 bra logbook_find_first_gas3 ; No. | |
| 620 movlw .2 | |
| 621 movwf temp1 | |
| 622 bra logbook_find_first_gas_done | |
| 623 logbook_find_first_gas3: | |
| 624 ; Set pointer to Gas 3 Type. | |
| 625 LOG_POINT_TO log_gas3+.3 | |
| 626 call ext_flash_byte_read_plus ; read Gas Type | |
| 627 decfsz temp1,W ; =1 (="First")? | |
| 628 bra logbook_find_first_gas4 ; No. | |
| 629 movlw .3 | |
| 630 movwf temp1 | |
| 631 bra logbook_find_first_gas_done | |
| 632 logbook_find_first_gas4: | |
| 633 ; Set pointer to Gas 4 Type. | |
| 634 LOG_POINT_TO log_gas4+.3 | |
| 635 call ext_flash_byte_read_plus ; read Gas Type | |
| 636 decfsz temp1,W ; =1 (="First")? | |
| 637 bra logbook_find_first_gas5 ; No. | |
| 638 movlw .4 | |
| 639 movwf temp1 | |
| 640 bra logbook_find_first_gas_done | |
| 641 logbook_find_first_gas5: | |
| 642 movlw .5 ; Must be Gas5 | |
| 643 movwf temp1 | |
| 644 logbook_find_first_gas_done: | |
| 645 movff temp1,average_depth_hold_total+3; keep copy to restore color | |
| 646 rcall profile_display_color ; Back to normal profile color. | |
| 647 ; Pointer is now trashed! | |
| 648 | |
| 649 ; Point to profile portion of this dive | |
| 650 movff ext_flash_log_pointer+0,ext_flash_address+0 | |
| 651 movff ext_flash_log_pointer+1,ext_flash_address+1 | |
| 652 movff ext_flash_log_pointer+2,ext_flash_address+2 | |
| 653 | |
| 654 incf_ext_flash_address_0x20 d'2' ; Skip 0xFA 0xFA | |
| 655 call ext_flash_byte_read_plus_0x20 ; Read low byte of total dives into temp1 (at the time the dive was made) | |
| 656 | |
| 657 ; Load total number of dives (low byte only) | |
| 658 read_int_eeprom .2 | |
| 659 incf EEDATA,W ; +1 | |
| 660 bsf STATUS,C ; Set borrow | |
| 661 subfwb divesecs,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made) | |
| 662 cpfseq temp1 ; # of dive in logbook (Must be equal with low byte in short header) | |
| 663 bra display_profile_no_profile ; Not equal, no profile for this dive available! | |
| 664 | |
| 665 ; Skip rest of short header: 3 Bytes | |
| 666 ; Skip length of profile data: 3 Bytes | |
| 667 ; Skip sampling rate in profile section: 1Byte | |
| 668 ; Skip number of divisors: 1Byte | |
| 669 incf_ext_flash_address_0x20 d'8' | |
| 670 | |
| 671 ; Divisor temp | |
| 672 incf_ext_flash_address_0x20 d'2' | |
| 673 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 674 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 675 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 676 movf temp1,W | |
| 677 movwf divisor_temperature ; Store divisor | |
| 678 movwf count_temperature ; Store to tp° counter too. | |
| 679 ; Divisor Deco | |
| 680 incf_ext_flash_address_0x20 d'2' | |
| 681 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 682 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 683 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 684 movf temp1,W | |
| 685 movwf divisor_deco ; Store divisor | |
| 686 movwf count_deco ; Store as temp, too | |
| 687 ; Divisor GF | |
| 688 incf_ext_flash_address_0x20 d'2' | |
| 689 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 690 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 691 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 692 movff temp1,divisor_gf ; Store divisor | |
| 693 ; Divisor ppO2 Sensors | |
| 694 incf_ext_flash_address_0x20 d'2' | |
| 695 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 696 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 697 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 698 movff temp1,divisor_ppo2_sensors ; Store divisor | |
| 699 ; Divisor decoplan | |
| 700 incf_ext_flash_address_0x20 d'2' | |
| 701 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 702 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 703 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 704 movff temp1,divisor_decoplan ; Store divisor | |
| 705 ; Divisor CNS | |
| 706 incf_ext_flash_address_0x20 d'2' | |
| 707 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 708 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 709 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 710 movff temp1,divisor_cns ; Store divisor | |
| 711 ; Divisor Tank data | |
| 712 incf_ext_flash_address_0x20 d'2' | |
| 713 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
| 714 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
| 715 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
| 716 movff temp1,divisor_tank ; Store divisor | |
| 717 | |
| 718 ; Start Profile display | |
| 719 movlw color_deepblue | |
| 720 call TFT_set_color ; Make this configurable? | |
| 721 ; Draw a frame around profile area | |
| 722 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 | |
| 723 | |
| 724 movlw profile_top | |
| 725 movff WREG,win_top | |
| 726 movlw profile_left | |
| 727 movff WREG,win_leftx2 ; Left border (0-159) | |
| 728 movlw d'1' | |
| 729 movff WREG,win_height | |
| 730 movlw profile_width_pixels+.1 | |
| 731 movff WREG,win_width ; Right border (0-159) | |
| 732 bra display_profile2f ; No 0m line | |
| 733 display_profile2e: | |
| 734 call TFT_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
| 735 display_profile2f: | |
| 736 movff win_top,WREG ; Get row | |
| 737 addwf x_scale+0,W ; Add line interval distance to win_top | |
| 738 tstfsz x_scale+1 ; >255? | |
| 739 movlw d'255' ; Yes, make win_top>239 -> Abort here | |
| 740 btfsc STATUS,C ; A Cary from the addwf above? | |
| 741 movlw d'255' ; Yes, make win_top>239 -> Abort here | |
| 742 movff WREG,win_top ; Result in win_top again | |
| 743 movff win_top,lo ; Get win_top in Bank1... | |
| 744 movlw profile_top+profile_height_pixels+.1 ; Limit | |
| 745 cpfsgt lo ; >239? | |
| 746 bra display_profile2e ; No, draw another line | |
| 747 | |
| 748 clrf timeout_counter2 ; here: used as counter for depth readings | |
| 749 movlw profile_width_pixels+profile_left-.1 | |
| 750 movwf ignore_digits ; here: used as counter for x-pixels | |
| 751 bcf end_of_profile ; clear flag | |
| 752 movlw profile_left | |
| 753 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5) | |
| 754 movlw profile_top ; Zero-m row | |
| 755 movwf apnoe_mins ; here: used for fill between rows | |
| 756 movwf logbook_last_tp ; Initialise for Tp° curve too. | |
| 757 | |
| 758 movlw LOW(-.100) ; Initialize max tp° to -10.0 °C. | |
| 759 movwf logbook_max_tp+0 | |
| 760 movlw HIGH 0xFFFF & (-.100) | |
| 761 movwf logbook_max_tp+1 | |
| 762 | |
| 763 setf logbook_cur_tp+0 ; Initialize Tp°, before the first recorded point. | |
| 764 setf logbook_cur_tp+1 | |
| 765 clrf logbook_last_tp ; Also reset previous Y for Tp° | |
| 766 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling. | |
| 767 | |
| 768 INIT_PIXEL_WROTE logbook_pixel_x_pos ; pixel x2 (Also sets standard Color!) | |
| 769 | |
| 770 profile_display_loop: | |
| 771 movff profile_temp+0,profile_temp2+0 | |
| 772 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler | |
| 773 incf profile_temp2+1,F | |
| 774 tstfsz profile_temp2+0 ; Must not be Zero | |
| 775 bra profile_display_loop2 ; Not Zero! | |
| 776 incf profile_temp2+0,F ; Zero, Increase! | |
| 777 | |
| 778 profile_display_loop2: | |
| 779 rcall profile_view_get_depth ; reads depth, temp and profile data | |
| 780 | |
| 781 btfsc end_of_profile ; end-of profile reached? | |
| 782 bra profile_display_loop_done ; Yes, skip all remaining pixels | |
| 783 | |
| 784 | |
| 785 ;---- Draw Ceiling curve, if any --------------------------------------------- | |
| 786 movf divisor_deco,W | |
| 787 bz profile_display_skip_deco | |
| 788 | |
| 789 movf logbook_ceiling,W ; Any deco ceiling ? | |
| 790 bz profile_display_skip_deco | |
| 791 | |
| 792 mullw .100 ; Yes: convert to mbar | |
| 793 movff PRODL,sub_a+0 | |
| 794 movff PRODH,sub_a+1 | |
| 795 movff logbook_cur_depth+0,sub_b+0 ; Compare with UNSIGNED current depth (16bits) | |
| 796 movff logbook_cur_depth+1,sub_b+1 | |
| 797 call subU16 ; set (or not) neg_flag | |
| 798 | |
| 799 movlw color_dark_green ; Dark green if Ok, | |
| 800 btfss neg_flag | |
| 801 movlw color_dark_red ; Or dark red if ceiling overflown. | |
| 802 call TFT_set_color | |
| 803 | |
| 804 movff PRODL,xA+0 | |
| 805 movff PRODH,xA+1 | |
| 806 movff y_scale+0,xB+0 ; devide pressure in mbar/quant for row offsett | |
| 807 movff y_scale+1,xB+1 | |
| 808 call div16x16 ; xA/xB=xC | |
| 809 | |
| 810 movlw profile_top+.1 ; Starts right after the top greenish line. | |
| 811 movff WREG,win_top | |
| 812 movff logbook_pixel_x_pos,win_leftx2 ; Left border (0-159) | |
| 813 movff xC+0,win_height | |
| 814 call half_vertical_line ; Inputs: win_top, win_leftx2, win_height, win_color1, win_color2 | |
| 815 | |
| 816 profile_display_skip_deco: | |
| 817 ;---- Draw Tp° curve, if any --------------------------------------------- | |
| 818 movf divisor_temperature,W | |
| 819 bz profile_display_skip_temp | |
| 820 | |
| 821 movf logbook_cur_tp+0,W ; Did we had already a valid Tp°C record ? | |
| 822 andwf logbook_cur_tp+1,W | |
| 823 incf WREG | |
| 824 bz profile_display_skip_temp ; No: just skip drawing. | |
| 825 | |
| 826 movlw LOW(((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix | |
| 827 movwf xB+0 | |
| 828 movlw HIGH(((profile_height_pixels-.10)*.256)/.370) | |
| 829 movwf xB+1 | |
| 830 | |
| 831 movf logbook_cur_tp+0,W ; Current Tp° - (-2.0°C) == Tp° + 20. | |
| 832 addlw LOW(.20) ; Low byte. | |
| 833 movwf xA+0 | |
| 834 movf logbook_cur_tp+1,W | |
| 835 btfsc STATUS,C ; Propagate carry, if any | |
| 836 incf WREG | |
| 837 movwf xA+1 | |
| 838 call mult16x16 ; xA*xB=xC | |
| 839 | |
| 840 ; scale: divide by 256, ie. take just high byte. | |
| 841 movf xC+1,W | |
| 842 sublw profile_top+profile_height_pixels-.10 ; Upside-down: Y = .75 + (.153 - result) | |
| 843 movwf xC+0 | |
| 844 | |
| 845 ; Check limits | |
| 846 movlw profile_top | |
| 847 movwf xC+1 | |
| 848 cpfsgt xC+0 | |
| 849 movff xC+1,xC+0 | |
| 850 | |
| 851 movlw color_orange | |
| 852 call TFT_set_color | |
| 853 | |
| 854 movf logbook_last_tp,W ; do we have a valid previous value ? | |
| 855 bz profile_display_temp_1 ; No: skip the vertical line. | |
| 856 movwf xC+1 | |
| 857 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | |
| 858 profile_display_temp_1: | |
| 859 movff xC+0,logbook_last_tp | |
| 860 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a current color pixel. | |
| 861 | |
| 862 profile_display_skip_temp: | |
| 863 ;---- Draw depth curve --------------------------------------------------- | |
| 864 movff y_scale+0,xB+0 ; devide pressure in mbar/quant for row offsett | |
| 865 movff y_scale+1,xB+1 | |
| 866 movff logbook_cur_depth+0,xA+0 | |
| 867 movff logbook_cur_depth+1,xA+1 | |
| 868 call div16x16 ; xA/xB=xC | |
| 869 movlw profile_top | |
| 870 addwf xC+0,F ; add 75 pixel offset to result | |
| 871 | |
| 872 btfsc STATUS,C ; Ignore potential profile errors | |
| 873 movff apnoe_mins,xC+0 | |
| 874 | |
| 875 rcall profile_display_color ; Back to normal profile color. | |
| 876 | |
| 877 movff apnoe_mins,xC+1 | |
| 878 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | |
| 879 movff xC+0,apnoe_mins ; Store last row for fill routine | |
| 880 | |
| 881 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel. | |
| 882 incf logbook_pixel_x_pos,F ; Next row | |
| 883 | |
| 884 ;---- Draw CNS curve, if any --------------------------------------------- | |
| 885 movf divisor_cns,W | |
| 886 bz profile_display_skip_cns | |
| 887 ; | |
| 888 ; TODO HERE | |
| 889 ; | |
| 890 profile_display_skip_cns: | |
| 891 | |
| 892 ;---- Draw GF curve, if any ---------------------------------------------- | |
| 893 movf divisor_gf,W | |
| 894 bz profile_display_skip_gf | |
| 895 ; | |
| 896 ; TODO HERE | |
| 897 ; | |
| 898 profile_display_skip_gf: | |
| 899 | |
| 900 ;---- All curves done. | |
| 901 | |
| 902 profile_display_skip_loop1: ; skips readings! | |
| 903 dcfsnz profile_temp2+0,F | |
| 904 bra profile_display_loop3 ; check 16bit.... | |
| 905 | |
| 906 rcall profile_view_get_depth ; reads depth, temp and profile data | |
| 907 bra profile_display_skip_loop1 | |
| 908 | |
| 909 profile_display_loop3: | |
| 910 decfsz profile_temp2+1,F ; 16 bit x-scaler test | |
| 911 bra profile_display_skip_loop1 ; skips readings! | |
| 912 | |
| 913 decfsz ignore_digits,F ; counts drawn x-pixels to zero | |
| 914 bra profile_display_loop ; Not ready yet | |
| 915 ; Done. | |
| 916 | |
| 917 display_profile_no_profile: ; No profile available for this dive! | |
| 918 | |
| 919 profile_display_loop_done: | |
| 920 decf divesecs,F ;-1 | |
| 921 read_int_eeprom .2 | |
| 922 movf EEDATA,W | |
| 923 bcf STATUS,C | |
| 924 subfwb divesecs,W ; max. dives (low value) - divesecs | |
| 925 movwf lo ; result | |
| 926 incf divesecs,F ;+1 | |
| 927 ; Set ext_flash_address:3 to TOC entry of this dive | |
| 928 ; 1st: 200000h-200FFFh -> lo=0 | |
| 929 ; 2nd: 201000h-201FFFh -> lo=1 | |
| 930 ; 3rd: 202000h-202FFFh -> lo=2 | |
| 931 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
| 932 clrf ext_flash_address+0 | |
| 933 clrf ext_flash_address+1 | |
| 934 movlw 0x20 | |
| 935 movwf ext_flash_address+2 | |
| 936 movlw .16 | |
| 937 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
| 938 movf PRODL,W | |
| 939 addwf ext_flash_address+1,F | |
| 940 movf PRODH,W | |
| 941 addwfc ext_flash_address+2,F | |
| 942 ; pointer at the first 0xFA of header | |
| 943 | |
| 944 movlw .2 ; negative offset | |
| 945 addwf logbook_last_tp,W | |
| 946 movff WREG,win_top ; Line below temp | |
| 947 movff logbook_pixel_x_pos,lo | |
| 948 movlw .130 | |
| 949 cpfslt lo ; limit left border to 130 | |
| 950 movwf lo | |
| 951 movff lo,win_leftx2 | |
| 952 WIN_FONT FT_TINY | |
| 953 movlw color_orange ; Use same color as tp° curve | |
| 954 call TFT_set_color | |
| 955 | |
| 956 movff logbook_min_tp+0,lo | |
| 957 movff logbook_min_tp+1,hi | |
| 958 lfsr FSR2,buffer | |
| 959 | |
| 960 TSTOSS opt_units ; 0=°C, 1=°F | |
| 961 bra logbook_show_temp_metric | |
| 962 ;logbook_show_temp_imperial: | |
| 963 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
| 964 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
| 965 lfsr FSR2,buffer ; Overwrite "-" | |
| 966 bsf ignore_digit5 ; Full degrees only | |
| 967 output_16 | |
| 968 bcf ignore_digit5 | |
| 969 STRCAT_TEXT_PRINT tLogTunitF | |
| 970 bra logbook_show_temp_common | |
| 971 | |
| 972 logbook_show_temp_metric: | |
| 973 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
| 974 movlw d'3' | |
| 975 movwf ignore_digits | |
| 976 bsf leftbind | |
| 977 output_16dp d'2' ; temperature | |
| 978 STRCAT_TEXT_PRINT tLogTunitC | |
| 979 | |
| 980 logbook_show_temp_common: | |
| 981 bcf leftbind | |
| 982 call TFT_standard_color ; Back to normal | |
| 983 | |
| 984 ; Get pointer to Gaslist | |
| 985 LOG_POINT_TO log_gas1 | |
| 986 | |
| 987 movlw color_white ; Color for Gas 1 | |
| 988 call TFT_set_color ; Set Color... | |
| 989 bsf leftbind | |
| 990 WIN_TINY log_gas_column1, log_gas_row | |
| 991 rcall log_show_gas_common | |
| 992 | |
| 993 movlw color_green ; Color for Gas 2 | |
| 994 call TFT_set_color ; Set Color... | |
| 995 WIN_TINY log_gas_column2, log_gas_row | |
| 996 rcall log_show_gas_common | |
| 997 | |
| 998 movlw color_red ; Color for Gas 3 | |
| 999 call TFT_set_color ; Set Color... | |
| 1000 WIN_TINY log_gas_column3, log_gas_row | |
| 1001 rcall log_show_gas_common | |
| 1002 | |
| 1003 movlw color_yellow ; Color for Gas 4 | |
| 1004 call TFT_set_color ; Set Color... | |
| 1005 WIN_TINY log_gas_column4, log_gas_row | |
| 1006 rcall log_show_gas_common | |
| 1007 | |
| 1008 movlw color_cyan ; Color for Gas 5 | |
| 1009 call TFT_set_color ; Set Color... | |
| 1010 WIN_TINY log_gas_column5, log_gas_row | |
| 1011 rcall log_show_gas_common | |
| 1012 | |
| 1013 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | |
| 1014 display_profile_loop: | |
| 1015 btfsc switch_left ; SET/MENU? | |
| 1016 bra logbook_page2 ; Show more information | |
| 1017 btfsc switch_right ; ENTER? | |
| 1018 bra exit_profileview ; back to list | |
| 1019 | |
| 1020 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | |
| 1021 btfsc sleepmode ; Timeout? | |
| 1022 bra exit_profileview ; back to list | |
| 1023 bra display_profile_loop ; wait for something to do | |
| 1024 | |
| 1025 global log_screendump_and_onesecond | |
| 1026 log_screendump_and_onesecond: ; Check if we need to make a screenshot and check for new second | |
| 1027 btfsc onesecupdate | |
| 1028 call timeout_surfmode ; Timeout | |
| 1029 btfsc onesecupdate | |
| 1030 call set_dive_modes ; Check, if divemode must be entered | |
| 1031 bcf onesecupdate ; one second update | |
| 1032 btfsc divemode | |
| 1033 goto restart ; Enter Divemode if required | |
| 1034 | |
| 1035 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | |
| 1036 bra log_screendump_and_onesecond2 | |
| 1037 btfsc vusb_in ; USB plugged in? | |
| 1038 goto comm_mode ; Start COMM mode | |
| 1039 return | |
| 1040 log_screendump_and_onesecond2: | |
| 1041 btfss vusb_in ; USB (still) plugged in? | |
| 1042 bcf enable_screen_dumps ; No, clear flag | |
| 1043 call rs232_get_byte | |
| 1044 btfsc rs232_recieve_overflow | |
| 1045 return | |
| 1046 movlw "l" | |
| 1047 cpfseq RCREG1 | |
| 1048 return | |
| 1049 call TFT_dump_screen ; Dump the screen contents | |
| 1050 return | |
| 1051 | |
| 1052 log_show_gas_common: | |
| 1053 extern customview_show_mix | |
| 1054 lfsr FSR2,buffer | |
| 1055 call ext_flash_byte_read_plus ; Gas2 current O2 | |
| 1056 movff temp1,lo | |
| 1057 call ext_flash_byte_read_plus ; Gas2 current He | |
| 1058 movff temp1,hi | |
| 1059 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
| 1060 STRCAT_PRINT "" | |
| 1061 call ext_flash_byte_read_plus ; Gas2 change depth | |
| 1062 call ext_flash_byte_read_plus ; Gas2 Type | |
| 1063 return | |
| 1064 | |
| 1065 ;============================================================================= | |
| 1066 profile_display_color: | |
| 1067 movff average_depth_hold_total+3,active_gas ; Restore gas color. | |
| 1068 movlw color_white ; Default color | |
| 1069 dcfsnz active_gas,F | |
| 1070 movlw color_white ; Color for Gas 1 | |
| 1071 dcfsnz active_gas,F | |
| 1072 movlw color_green ; Color for Gas 2 | |
| 1073 dcfsnz active_gas,F | |
| 1074 movlw color_red ; Color for Gas 3 | |
| 1075 dcfsnz active_gas,F | |
| 1076 movlw color_yellow ; Color for Gas 4 | |
| 1077 dcfsnz active_gas,F | |
| 1078 movlw color_cyan ; Color for Gas 5 | |
| 1079 dcfsnz active_gas,F | |
| 1080 movlw color_cyan ; Color for Gas 6 | |
| 1081 goto TFT_set_color ; Set Color... | |
| 1082 | |
| 1083 ;============================================================================= | |
| 1084 ; Draw a vertical line between xC+1 and xC+0, at current X position. | |
| 1085 ; | |
| 1086 ; Note: should keep xC+0 | |
| 1087 ; Note: ascending or descending ! | |
| 1088 ; | |
| 1089 profile_display_fill: | |
| 1090 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins | |
| 1091 movf xC+0,W | |
| 1092 cpfseq xC+1 ; xC+0 = apone_mins? | |
| 1093 bra profile_display_fill2 ; No! | |
| 1094 return | |
| 1095 | |
| 1096 profile_display_fill2: | |
| 1097 ; Make sure to init X position. | |
| 1098 movf logbook_pixel_x_pos,W | |
| 1099 mullw 2 | |
| 1100 decf PRODL,F | |
| 1101 movlw 0 | |
| 1102 subwfb PRODH,F | |
| 1103 call pixel_write_col320 | |
| 1104 | |
| 1105 movf xC+0,W | |
| 1106 cpfsgt xC+1 ; apnoe_mins>xC+0? | |
| 1107 bra profile_display_fill_up ; Yes! | |
| 1108 | |
| 1109 profile_display_fill_down2: ; Loop | |
| 1110 decf xC+1,F | |
| 1111 | |
| 1112 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) | |
| 1113 | |
| 1114 movf xC+0,W | |
| 1115 cpfseq xC+1 ; Loop until xC+1=xC+0 | |
| 1116 bra profile_display_fill_down2 | |
| 1117 return ; apnoe_mins and xC+0 are untouched | |
| 1118 | |
| 1119 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins! | |
| 1120 incf xC+1,F | |
| 1121 | |
| 1122 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) | |
| 1123 | |
| 1124 movf xC+0,W | |
| 1125 cpfseq xC+1 ; Loop until xC+1=apnoe_mins | |
| 1126 bra profile_display_fill_up | |
| 1127 return ; apnoe_mins and xC+0 are untouched | |
| 1128 | |
| 1129 ;============================================================================= | |
| 1130 | |
| 1131 | |
| 1132 profile_view_get_depth: | |
| 1133 incf logbook_sample_counter+0,F | |
| 1134 movlw d'0' | |
| 1135 addwfc logbook_sample_counter+1,F ; Count read pixels | |
| 1136 | |
| 1137 movf logbook_sample_counter+0,W | |
| 1138 cpfseq average_depth_hold_total+0 | |
| 1139 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | |
| 1140 movf logbook_sample_counter+1,W | |
| 1141 cpfseq average_depth_hold_total+1 | |
| 1142 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | |
| 1143 ; draw a new 10min line here... | |
| 1144 clrf logbook_sample_counter+0 | |
| 1145 clrf logbook_sample_counter+1 ; clear counting registers for next line | |
| 1146 | |
| 1147 ; Vertical lines... | |
| 1148 movlw color_deepblue | |
| 1149 call TFT_set_color ; Make this configurable? | |
| 1150 movlw profile_top+.1 | |
| 1151 movff WREG,win_top | |
| 1152 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile | |
| 1153 movff WREG,win_leftx2 ; Left border (0-159) | |
| 1154 movlw profile_height_pixels | |
| 1155 movff WREG,win_height | |
| 1156 movlw profile_height_pixels | |
| 1157 movff WREG,win_width ; "Window" height | |
| 1158 call half_horizontal_line ; Inputs: win_top, win_leftx2, win_width, win_color1, win_color2 | |
| 1159 | |
| 1160 profile_view_get_depth_no_line: | |
| 1161 call ext_flash_byte_read_plus_0x20 ; read depth first | |
| 1162 movff temp1,logbook_cur_depth+0 ; low value | |
| 1163 call ext_flash_byte_read_plus_0x20 ; read depth first | |
| 1164 movff temp1,logbook_cur_depth+1 ; high value | |
| 1165 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte | |
| 1166 movff temp1,timeout_counter2 ; Read Profile Flag Byte | |
| 1167 | |
| 1168 bcf event_occured ; clear flag | |
| 1169 btfsc timeout_counter2,7 | |
| 1170 bsf event_occured ; We also have an Event byte! | |
| 1171 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any) | |
| 1172 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127) | |
| 1173 movlw 0xFD ; end of profile bytes? | |
| 1174 cpfseq logbook_cur_depth+0 | |
| 1175 bra profile_view_get_depth_new1 ; no 1st. 0xFD | |
| 1176 cpfseq logbook_cur_depth+1 | |
| 1177 bra profile_view_get_depth_new1 ; no 2nd. 0xFD | |
| 1178 bsf end_of_profile ; End found! Set Flag! Skip remaining pixels! | |
| 1179 return | |
| 1180 | |
| 1181 profile_view_get_depth_new1: | |
| 1182 btfsc event_occured ; Was there an event attached to this sample? | |
| 1183 rcall profile_view_get_depth_new2 ; Yes, get information about this event | |
| 1184 | |
| 1185 ;---- Read Tp°, if any AND divisor reached AND bytes available ----------- | |
| 1186 movf divisor_temperature,W ; Is Tp° divisor null ? | |
| 1187 bz profile_view_get_depth_no_tp; Yes: no Tp° curve. | |
| 1188 decf count_temperature,F ; Decrement tp° counter | |
| 1189 bnz profile_view_get_depth_no_tp; No temperature this time | |
| 1190 | |
| 1191 call ext_flash_byte_read_plus_0x20 ; Tp° low | |
| 1192 decf timeout_counter2,F | |
| 1193 movff temp1,logbook_cur_tp+0 | |
| 1194 call ext_flash_byte_read_plus_0x20 ; Tp° high | |
| 1195 decf timeout_counter2,F | |
| 1196 movff temp1,logbook_cur_tp+1 | |
| 1197 movff divisor_temperature,count_temperature ; Restart counter. | |
| 1198 | |
| 1199 ; Compute Tp° max on the fly... | |
| 1200 movff logbook_cur_tp+0,sub_a+0 ; Compare cur_tp > max_tp ? | |
| 1201 movff logbook_cur_tp+1,sub_a+1 | |
| 1202 movff logbook_max_tp+0,sub_b+0 | |
| 1203 movff logbook_max_tp+1,sub_b+1 | |
| 1204 call sub16 ; SIGNED sub_a - sub_b | |
| 1205 btfsc neg_flag | |
| 1206 bra profile_view_get_depth_no_tp | |
| 1207 | |
| 1208 movff logbook_cur_tp+0,logbook_max_tp+0 | |
| 1209 movff logbook_cur_tp+1,logbook_max_tp+1 | |
| 1210 | |
| 1211 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- | |
| 1212 profile_view_get_depth_no_tp: | |
| 1213 movf divisor_deco,W | |
| 1214 bz profile_view_get_depth_no_deco | |
| 1215 decf count_deco,F | |
| 1216 bnz profile_view_get_depth_no_deco | |
| 1217 | |
| 1218 call ext_flash_byte_read_plus_0x20 | |
| 1219 decf timeout_counter2,F | |
| 1220 movff temp1,logbook_ceiling | |
| 1221 movff divisor_deco,count_deco ; Restart counter. | |
| 1222 | |
| 1223 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------ | |
| 1224 profile_view_get_depth_no_deco: | |
| 1225 movf timeout_counter2,W ; No more extra bytes ? | |
| 1226 btfsc STATUS,Z | |
| 1227 return ; No: done. | |
| 1228 | |
| 1229 ; Then skip remaining bytes... | |
| 1230 movf timeout_counter2,W ; number of additional bytes to ignore (0-127) | |
| 1231 call incf_ext_flash_address0_0x20; increases bytes in ext_flash_address:3 with 0x200000 bank switching | |
| 1232 return | |
| 1233 | |
| 1234 profile_view_get_depth_new2: | |
| 1235 call ext_flash_byte_read_plus_0x20 ; Read Event byte | |
| 1236 movff temp1,EventByte ; store EventByte | |
| 1237 decf timeout_counter2,F ; reduce counter | |
| 1238 ; Check Event flags in the EventByte | |
| 1239 btfsc EventByte,4 ; Manual Gas Changed? | |
| 1240 bra logbook_event1 ; Yes! | |
| 1241 btfss EventByte,5 ; Stored Gas Changed? | |
| 1242 return ; No, return | |
| 1243 ; Stored Gas changed! | |
| 1244 call ext_flash_byte_read_plus_0x20 ; Read Gas# | |
| 1245 decf timeout_counter2,F ; reduce counter | |
| 1246 movff temp1,average_depth_hold_total+3 | |
| 1247 rcall profile_display_color ; Change profile color according to gas number | |
| 1248 return | |
| 1249 | |
| 1250 logbook_event1: | |
| 1251 movlw 6 ; Just color backup to 6 | |
| 1252 movwf average_depth_hold_total+3 | |
| 1253 rcall profile_display_color ; Back to normal profile color. | |
| 1254 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...) | |
| 1255 | |
| 1256 exit_profileview: | |
| 1257 call speed_fastest | |
| 1258 bcf sleepmode | |
| 1259 clrf timeout_counter2 ; restore all registers to build same page again | |
| 1260 movff divemins_backup,divemins+0 | |
| 1261 movff logbook_divenumber_temp, logbook_divenumber | |
| 1262 movff logbook_max_dive_counter_temp,logbook_max_dive_counter | |
| 1263 incf logbook_max_dive_counter,F | |
| 1264 decf logbook_divenumber,F | |
| 1265 bcf all_dives_shown | |
| 1266 clrf menupos3 ; here: used row on current page | |
| 1267 movlw logbook_row_number | |
| 1268 movwf menupos ; here: active row on current page | |
| 1269 clrf CCP1CON ; stop PWM | |
| 1270 bcf PORTC,2 ; Pull PWM out to GND | |
| 1271 call TFT_ClearScreen ; clear details/profile | |
| 1272 goto logbook2 ; start search | |
| 1273 | |
| 1274 next_logbook2: | |
| 1275 btfsc all_dives_shown ; all shown | |
| 1276 goto logbook ; all reset | |
| 1277 clrf menupos3 | |
| 1278 movlw logbook_row_number | |
| 1279 movwf menupos | |
| 1280 incf logbook_page_number,F ; start new screen | |
| 1281 clrf CCP1CON ; stop PWM | |
| 1282 bcf PORTC,2 ; Pull PWM out to GND | |
| 1283 call TFT_ClearScreen | |
| 1284 goto logbook2 ; start search | |
| 1285 | |
| 1286 next_logbook3: | |
| 1287 incf menupos,F ; +1 | |
| 1288 movlw logbook_row_number+.2 | |
| 1289 cpfsgt menupos ; =logbook_row_number+.3? | |
| 1290 bra next_logbook3a ; No | |
| 1291 movlw .1 | |
| 1292 movwf menupos | |
| 1293 bra next_logbook3b | |
| 1294 | |
| 1295 next_logbook3a: | |
| 1296 incf menupos3,W ; last entry in current page +1 | |
| 1297 cpfseq menupos ; same as cursor pos.? | |
| 1298 bra next_logbook3b ; No | |
| 1299 movlw logbook_row_number+.1 ; Yes, ... | |
| 1300 movwf menupos ; ... jump directly to "next page" if page is not full | |
| 1301 | |
| 1302 movlw logbook_row_number | |
| 1303 cpfseq menupos3 ; Last dive was row logbook_row_number? | |
| 1304 bsf all_dives_shown ; No, set flag to load first page again (full reset) | |
| 1305 | |
| 1306 next_logbook3b: | |
| 1307 clrf timeout_counter2 | |
| 1308 call TFT_logbook_cursor | |
| 1309 | |
| 1310 bcf switch_left | |
| 1311 goto logbook_loop | |
| 1312 | |
| 1313 display_listdive: | |
| 1314 bsf logbook_page_not_empty ; Page not empty | |
| 1315 incf menupos3,F | |
| 1316 | |
| 1317 bsf leftbind | |
| 1318 WIN_FONT FT_SMALL | |
| 1319 WIN_LEFT logbook_list_left | |
| 1320 | |
| 1321 decf menupos3,W ; -1 into wreg | |
| 1322 mullw logbook_row_offset | |
| 1323 movff PRODL,win_top | |
| 1324 | |
| 1325 lfsr FSR2,buffer | |
| 1326 movff logbook_divenumber,lo | |
| 1327 output_8 ; # of dive | |
| 1328 PUTC ' ' | |
| 1329 LOG_POINT_TO log_date+1 ; Point to month | |
| 1330 call ext_flash_byte_read_plus | |
| 1331 movff temp1,lo ; read month | |
| 1332 | |
| 1333 display_listdive2: | |
| 1334 movff lo,convert_value_temp+0 ; Month (in lo, see above) | |
| 1335 call ext_flash_byte_read_plus ; Day | |
| 1336 movff temp1,convert_value_temp+1 | |
| 1337 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer | |
| 1338 PUTC ' ' | |
| 1339 | |
| 1340 LOG_POINT_TO log_max_depth ; Point to max. depth | |
| 1341 call ext_flash_byte_read_plus ; max. Depth | |
| 1342 movff temp1,lo | |
| 1343 call ext_flash_byte_read_plus | |
| 1344 movff temp1,hi | |
| 1345 | |
| 1346 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 1347 bra display_listdive2_metric | |
| 1348 ;display_listdive2_imperial: | |
| 1349 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 1350 PUTC ' ' | |
| 1351 bsf ignore_digit4 | |
| 1352 movlw d'1' | |
| 1353 movff WREG,ignore_digits | |
| 1354 bcf leftbind | |
| 1355 output_16 ; full feet | |
| 1356 STRCAT_TEXT tFeets1 | |
| 1357 bra display_listdive3 | |
| 1358 | |
| 1359 display_listdive2_metric: | |
| 1360 bsf ignore_digit5 ; no cm... | |
| 1361 movlw d'1' ; +1 | |
| 1362 movff WREG,ignore_digits ; no 1000m | |
| 1363 bcf leftbind | |
| 1364 output_16dp .3 ; xxx.y | |
| 1365 STRCAT_TEXT tMeters | |
| 1366 PUTC ' ' | |
| 1367 | |
| 1368 display_listdive3: | |
| 1369 call ext_flash_byte_read_plus | |
| 1370 movff temp1,lo ; read divetime minutes | |
| 1371 call ext_flash_byte_read_plus | |
| 1372 movff temp1,hi | |
| 1373 output_16_3 ; Divetime minutes (0-999min) | |
| 1374 STRCAT_TEXT_PRINT tMinutes ; Display header-row in list | |
| 1375 return | |
| 1376 | |
| 1377 logbook_show_divenumber: | |
| 1378 call do_logoffset_common_read ; Read into lo:hi | |
| 1379 tstfsz lo ; lo=0? | |
| 1380 bra logbook_show_divenumber2 ; No, adjust offset | |
| 1381 tstfsz hi ; hi=0? | |
| 1382 bra logbook_show_divenumber2 ; No, adjust offset | |
| 1383 movff divesecs,lo ; lo=0 and hi=0 -> skip Offset routine | |
| 1384 bra logbook_show_divenumber3 ; Display now | |
| 1385 | |
| 1386 logbook_show_divenumber2: | |
| 1387 movlw d'1' | |
| 1388 addwf lo,F | |
| 1389 movlw d'0' | |
| 1390 addwfc hi,F ; hi:lo = hi:lo + 1 | |
| 1391 movff lo,sub_a+0 | |
| 1392 movff hi,sub_a+1 | |
| 1393 movff divesecs,sub_b+0 | |
| 1394 clrf sub_b+1 | |
| 1395 call subU16 ; sub_c = sub_a - sub_b | |
| 1396 movff sub_c+0,lo | |
| 1397 movff sub_c+1,hi | |
| 1398 | |
| 1399 logbook_show_divenumber3: | |
| 1400 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row | |
| 1401 lfsr FSR2,buffer | |
| 1402 bsf leftbind | |
| 1403 output_16 ; # of dive in logbook | |
| 1404 bcf leftbind | |
| 1405 STRCAT_PRINT "" | |
| 1406 return | |
| 1407 | |
| 1408 | |
| 1409 logbook_page2: ; Show more info | |
| 1410 call speed_fastest | |
| 1411 clrf CCP1CON ; stop PWM | |
| 1412 bcf PORTC,2 ; Pull PWM out to GND | |
| 1413 call TFT_ClearScreen ; Clear screen | |
| 1414 | |
| 1415 ; Set ext_flash pointer to "#divesecs-oldest" dive | |
| 1416 ; compute read_int_eeprom .2 - divesecs | |
| 1417 ; Read required header data for profile display | |
| 1418 ; look in header for pointer to begin of diveprofile (Byte 2-4) | |
| 1419 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing | |
| 1420 | |
| 1421 decf divesecs,F ;-1 | |
| 1422 read_int_eeprom .2 | |
| 1423 movf EEDATA,W | |
| 1424 bcf STATUS,C | |
| 1425 subfwb divesecs,W ; max. dives (low value) - divesecs | |
| 1426 movwf lo ; result | |
| 1427 incf divesecs,F ;+1 | |
| 1428 ; Set ext_flash_address:3 to TOC entry of this dive | |
| 1429 ; 1st: 200000h-200FFFh -> lo=0 | |
| 1430 ; 2nd: 201000h-201FFFh -> lo=1 | |
| 1431 ; 3rd: 202000h-202FFFh -> lo=2 | |
| 1432 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
| 1433 clrf ext_flash_address+0 | |
| 1434 clrf ext_flash_address+1 | |
| 1435 movlw 0x20 | |
| 1436 movwf ext_flash_address+2 | |
| 1437 movlw .16 | |
| 1438 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
| 1439 movf PRODL,W | |
| 1440 addwf ext_flash_address+1,F | |
| 1441 movf PRODH,W | |
| 1442 addwfc ext_flash_address+2,F | |
| 1443 ; pointer at the first 0xFA of header | |
| 1444 call logbook_show_divenumber ; Show the dive number in medium font | |
| 1445 | |
| 1446 | |
| 1447 LOG_POINT_TO log_surface_press | |
| 1448 ; surface pressure in mbar | |
| 1449 call ext_flash_byte_read_plus ; read surface pressure | |
| 1450 movff temp1,lo | |
| 1451 call ext_flash_byte_read_plus ; read surface pressure | |
| 1452 movff temp1,hi | |
| 1453 WIN_TINY MBAR_column,MBAR_row | |
| 1454 lfsr FSR2,buffer | |
| 1455 bsf leftbind | |
| 1456 output_16 ; Air pressure before dive | |
| 1457 STRCAT_TEXT_PRINT tMBAR | |
| 1458 | |
| 1459 ; OC Gas List | |
| 1460 LOG_POINT_TO log_gas1 | |
| 1461 WIN_TINY log2_title_column,log2_title_row1 | |
| 1462 WIN_COLOR color_greenish | |
| 1463 STRCPY_TEXT_PRINT tGaslist | |
| 1464 WIN_FRAME_STD log2_title_row1-2, log2_gas_row5+.15, log2_title_column-2, .159 ; Top, Bottom, Left, Right | |
| 1465 bcf leftbind | |
| 1466 movlw color_white ; Color for Gas 1 | |
| 1467 call TFT_set_color ; Set Color... | |
| 1468 WIN_TINY log2_gas_column, log2_gas_row1 | |
| 1469 rcall log_show_gas_common2 | |
| 1470 movlw color_green ; Color for Gas 2 | |
| 1471 call TFT_set_color ; Set Color... | |
| 1472 WIN_TINY log2_gas_column, log2_gas_row2 | |
| 1473 rcall log_show_gas_common2 | |
| 1474 movlw color_red ; Color for Gas 3 | |
| 1475 call TFT_set_color ; Set Color... | |
| 1476 WIN_TINY log2_gas_column, log2_gas_row3 | |
| 1477 rcall log_show_gas_common2 | |
| 1478 movlw color_yellow ; Color for Gas 4 | |
| 1479 call TFT_set_color ; Set Color... | |
| 1480 WIN_TINY log2_gas_column, log2_gas_row4 | |
| 1481 rcall log_show_gas_common2 | |
| 1482 movlw color_cyan ; Color for Gas 5 | |
| 1483 call TFT_set_color ; Set Color... | |
| 1484 WIN_TINY log2_gas_column, log2_gas_row5 | |
| 1485 rcall log_show_gas_common2 | |
| 1486 | |
| 1487 ; Firmware | |
| 1488 call TFT_standard_color | |
| 1489 WIN_TINY log2_firmware_column,log2_firmware_row | |
| 1490 STRCPY_TEXT tFirmware | |
| 1491 call ext_flash_byte_read_plus ; read firmware xx | |
| 1492 movff temp1,lo | |
| 1493 bsf leftbind | |
| 1494 output_8 | |
| 1495 PUTC "." | |
| 1496 call ext_flash_byte_read_plus ; read firmware yy | |
| 1497 movff temp1,lo | |
| 1498 output_99x | |
| 1499 STRCAT_PRINT "" | |
| 1500 | |
| 1501 ; Battery | |
| 1502 WIN_TINY log2_battery_column,log2_battery_row | |
| 1503 STRCPY "Batt:" | |
| 1504 call ext_flash_byte_read_plus ; read battery low | |
| 1505 movff temp1,lo | |
| 1506 call ext_flash_byte_read_plus ; read battery high | |
| 1507 movff temp1,hi | |
| 1508 output_16dp .2 | |
| 1509 STRCAT_PRINT "V" | |
| 1510 | |
| 1511 ; Setpoint list | |
| 1512 LOG_POINT_TO log_sp1 | |
| 1513 WIN_TINY log2_title_column,log2_title_sp_row | |
| 1514 WIN_COLOR color_greenish | |
| 1515 STRCPY_TEXT_PRINT tFixedSetpoints | |
| 1516 WIN_FRAME_STD log2_title_sp_row-2, log2_sp_row5+.15, log2_title_column-2, .159 ; Top, Bottom, Left, Right | |
| 1517 WIN_TINY log2_gas_column, log2_sp_row1 | |
| 1518 rcall log_show_sp_common | |
| 1519 WIN_TINY log2_gas_column, log2_sp_row2 | |
| 1520 rcall log_show_sp_common | |
| 1521 WIN_TINY log2_gas_column, log2_sp_row3 | |
| 1522 rcall log_show_sp_common | |
| 1523 WIN_TINY log2_gas_column, log2_sp_row4 | |
| 1524 rcall log_show_sp_common | |
| 1525 WIN_TINY log2_gas_column, log2_sp_row5 | |
| 1526 rcall log_show_sp_common | |
| 1527 | |
| 1528 ; Salinity | |
| 1529 WIN_TINY log2_salinity_column,log2_salinity_row | |
| 1530 STRCPY_TEXT tDvSalinity | |
| 1531 bsf leftbind | |
| 1532 call ext_flash_byte_read_plus ; read salinity | |
| 1533 movff temp1,lo | |
| 1534 output_8 | |
| 1535 STRCAT_PRINT "%" | |
| 1536 | |
| 1537 ; CNS | |
| 1538 LOG_POINT_TO log_cns_start | |
| 1539 WIN_TINY log2_cns_column,log2_cns_row | |
| 1540 STRCPY_TEXT tCNS2 | |
| 1541 call ext_flash_byte_read_plus ; read cns low | |
| 1542 movff temp1,lo | |
| 1543 call ext_flash_byte_read_plus ; read cns high | |
| 1544 movff temp1,hi | |
| 1545 output_16 | |
| 1546 LOG_POINT_TO log_cns_end | |
| 1547 STRCAT "->" | |
| 1548 call ext_flash_byte_read_plus ; read CNS low | |
| 1549 movff temp1,lo | |
| 1550 call ext_flash_byte_read_plus ; read CNS high | |
| 1551 movff temp1,hi | |
| 1552 output_16 | |
| 1553 STRCAT_PRINT "%" | |
| 1554 | |
| 1555 ; Average depth | |
| 1556 WIN_TINY log2_avr_column,log2_avr_row | |
| 1557 STRCPY_TEXT tAVR | |
| 1558 call ext_flash_byte_read_plus ; read avr low | |
| 1559 movff temp1,lo | |
| 1560 call ext_flash_byte_read_plus ; read avr high | |
| 1561 movff temp1,hi | |
| 1562 output_16dp .3 | |
| 1563 STRCAT_PRINT "m" | |
| 1564 | |
| 1565 ; Deco model | |
| 1566 LOG_POINT_TO log_decomodel | |
| 1567 WIN_TINY log2_decomodel_column,log2_decomodel_row | |
| 1568 STRCPY_TEXT tDkMode | |
| 1569 call ext_flash_byte_read_plus ; read deco model | |
| 1570 movff temp1,lo | |
| 1571 decfsz temp1,F | |
| 1572 bra logbook_decomodel1 | |
| 1573 ; Deco model GF Version | |
| 1574 STRCAT_TEXT_PRINT tZHL16GF | |
| 1575 LOG_POINT_TO log_gf_lo | |
| 1576 WIN_TINY log2_decomodel2_column,log2_decomodel2_row | |
| 1577 STRCPY_TEXT tGF_low | |
| 1578 call ext_flash_byte_read_plus ; Read GF lo | |
| 1579 movff temp1,lo | |
| 1580 output_8 | |
| 1581 STRCAT_PRINT "%" | |
| 1582 WIN_TINY log2_decomodel3_column,log2_decomodel3_row | |
| 1583 STRCPY_TEXT tGF_high | |
| 1584 call ext_flash_byte_read_plus ; Read GF hi | |
| 1585 movff temp1,lo | |
| 1586 output_8 | |
| 1587 STRCAT_PRINT "%" | |
| 1588 bra logbook_decomodel2 | |
| 1589 logbook_decomodel1: | |
| 1590 ; Deco model NON-GF Version | |
| 1591 STRCAT_TEXT_PRINT tZHL16 | |
| 1592 LOG_POINT_TO log_sat_mult | |
| 1593 WIN_TINY log2_decomodel2_column,log2_decomodel2_row | |
| 1594 STRCPY_TEXT tSaturationMult | |
| 1595 call ext_flash_byte_read_plus ; Read sat_mult | |
| 1596 movff temp1,lo | |
| 1597 output_8 | |
| 1598 STRCAT_PRINT "%" | |
| 1599 WIN_TINY log2_decomodel3_column,log2_decomodel3_row | |
| 1600 STRCPY_TEXT tDesaturationMult | |
| 1601 call ext_flash_byte_read_plus ; Read desat_mult | |
| 1602 movff temp1,lo | |
| 1603 output_8 | |
| 1604 STRCAT_PRINT "%" | |
| 1605 logbook_decomodel2: | |
| 1606 ; Dive mode | |
| 1607 LOG_POINT_TO log_divemode | |
| 1608 WIN_TINY log2_divemode_column,log2_divemode_row | |
| 1609 STRCPY_TEXT tDvMode | |
| 1610 call ext_flash_byte_read_plus ; Read divemode | |
| 1611 movff temp1,lo | |
| 1612 call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) | |
| 1613 | |
| 1614 ; Last deco | |
| 1615 LOG_POINT_TO log_last_stop | |
| 1616 WIN_TINY log2_lastdeco_column,log2_lastdeco_row | |
| 1617 STRCPY_TEXT tLastDecostop | |
| 1618 call ext_flash_byte_read_plus ; Read last stop | |
| 1619 movff temp1,lo | |
| 1620 output_8 | |
| 1621 STRCAT_PRINT "m" | |
| 1622 | |
| 1623 ; A frame around the details | |
| 1624 WIN_TINY log2_lastdeco_column,log2_salinity_row-.16 | |
| 1625 WIN_COLOR color_greenish | |
| 1626 STRCPY_TEXT_PRINT tLogbook | |
| 1627 WIN_FRAME_STD log2_salinity_row-.18, MBAR_row+.15, 0, .85 ; Top, Bottom, Left, Right | |
| 1628 | |
| 1629 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | |
| 1630 display_details_loop: | |
| 1631 btfsc switch_left ; SET/MENU? | |
| 1632 goto display_profile2 ; Show the profile view again | |
| 1633 btfsc switch_right ; ENTER? | |
| 1634 bra exit_profileview ; back to list | |
| 1635 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | |
| 1636 btfsc sleepmode ; Timeout? | |
| 1637 bra exit_profileview ; back to list | |
| 1638 | |
| 1639 bra display_details_loop ; wait for something to do | |
| 1640 | |
| 1641 global logbook_preloop_tasks | |
| 1642 logbook_preloop_tasks: | |
| 1643 movlw CCP1CON_VALUE ; See ostc3.inc | |
| 1644 movwf CCP1CON ; Power-on backlight | |
| 1645 call TFT_standard_color | |
| 1646 bcf sleepmode ; clear some flags | |
| 1647 bcf switch_right | |
| 1648 bcf switch_left | |
| 1649 clrf timeout_counter2 | |
| 1650 call speed_normal | |
| 1651 return | |
| 1652 | |
| 1653 log_show_sp_common: | |
| 1654 lfsr FSR2,buffer | |
| 1655 call ext_flash_byte_read_plus ; Read setpoint | |
| 1656 movff temp1,lo | |
| 1657 clrf hi | |
| 1658 bsf leftbind | |
| 1659 output_16dp d'3' | |
| 1660 bcf leftbind | |
| 1661 STRCAT_TEXT tbar | |
| 1662 PUTC " " | |
| 1663 call ext_flash_byte_read_plus ; change depth | |
| 1664 movff temp1,lo | |
| 1665 | |
| 1666 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 1667 bra log_show_sp_common_metric | |
| 1668 movf lo,W | |
| 1669 mullw .100 ; convert meters to mbar | |
| 1670 movff PRODL,lo | |
| 1671 movff PRODH,hi | |
| 1672 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 1673 output_16 | |
| 1674 STRCAT_TEXT tFeets ; "ft" | |
| 1675 bra log_show_sp_common_common | |
| 1676 log_show_sp_common_metric: | |
| 1677 output_8 | |
| 1678 STRCAT_TEXT tMeters ; "m" | |
| 1679 log_show_sp_common_common: | |
| 1680 STRCAT_PRINT "" | |
| 1681 return | |
| 1682 | |
| 1683 log_show_gas_common2: ; as log_show_gas_common but with change depth | |
| 1684 lfsr FSR2,buffer | |
| 1685 call ext_flash_byte_read_plus ; current O2 | |
| 1686 movff temp1,lo | |
| 1687 call ext_flash_byte_read_plus ; current He | |
| 1688 movff temp1,hi | |
| 1689 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
| 1690 call ext_flash_byte_read_plus ; change depth | |
| 1691 movff temp1,lo | |
| 1692 | |
| 1693 TSTOSS opt_units ; 0=Meters, 1=Feets | |
| 1694 bra log_show_gas_common2_metric | |
| 1695 movf lo,W | |
| 1696 mullw .100 ; convert meters to mbar | |
| 1697 movff PRODL,lo | |
| 1698 movff PRODH,hi | |
| 1699 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
| 1700 output_16 | |
| 1701 STRCAT_TEXT tFeets ; "ft" | |
| 1702 bra log_show_gas_common2_common | |
| 1703 log_show_gas_common2_metric: | |
| 1704 output_8 | |
| 1705 STRCAT_TEXT tMeters ; "m" | |
| 1706 log_show_gas_common2_common: | |
| 1707 bcf leftbind | |
| 1708 call ext_flash_byte_read_plus ; Gas Type | |
| 1709 STRCAT_PRINT "" | |
| 1710 return | |
| 1711 | |
| 1712 END |
