Mercurial > public > hwos_code
annotate src/logbook.asm @ 622:02d1386429a6
0x60 added for (future) option to change logbook offset via PC/Bluetooth
author | heinrichsweikamp |
---|---|
date | Wed, 10 Apr 2019 10:51:07 +0200 |
parents | cd986267a5ca |
children | c40025d8e750 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
604 | 3 ; File logbook.asm REFACTORED VERSION V2.99e |
0 | 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 | |
582 | 11 ; |
0 | 12 ;============================================================================= |
582 | 13 |
14 | |
604 | 15 #include "hwos.inc" ; mandatory header |
582 | 16 #include "tft.inc" |
17 #include "external_flash.inc" | |
18 #include "math.inc" | |
19 #include "strings.inc" | |
20 #include "convert.inc" | |
21 #include "tft_outputs.inc" | |
22 #include "eeprom_rs232.inc" | |
23 #include "menu_processor.inc" | |
24 #include "wait.inc" | |
25 #include "start.inc" | |
26 #include "surfmode.inc" | |
27 #include "divemode.inc" | |
28 #include "ghostwriter.inc" | |
0 | 29 |
582 | 30 extern do_main_menu2 |
31 extern comm_mode | |
32 extern customview_show_mix | |
33 | |
34 | |
35 ;---- Private local variables ------------------------------------------------- | |
0 | 36 |
582 | 37 CBLOCK local1 ; max size is 16 byte !!! |
38 count_temperature ; current sample count for temperature divisor | |
39 count_deco ; current sample count for deco (ceiling) divisor | |
40 logbook_cur_depth:2 ; current depth, for drawing profile. | |
41 logbook_cur_tp:2 ; current temperature, for drawing profile. | |
42 logbook_last_tp ; Y of the last item in Tp° curve. | |
43 logbook_min_tp:2 ; min temperature, for drawing profile. | |
44 logbook_max_tp:2 ; maximum temperature, for drawing profile. | |
45 logbook_ceiling ; current ceiling, for drawing profile. | |
46 logbook_flags ; flags only used in logbook.asm | |
47 logbook_page_number ; page# in logbook | |
48 logbook_divenumber ; # of dive in list during search | |
49 logbook_max_dive_counter ; counts dive# to zero | |
50 ENDC ; used: 16 byte, remaining: 0 byte => FULL | |
0 | 51 |
582 | 52 CBLOCK local2 ; max size is 16 byte !!! |
53 profile_temp1:2 ; temp for profile display | |
54 profile_temp2:2 ; temp for profile display | |
55 logbook_sample_counter:2 ; amount of read samples | |
56 y_scale:2 ; y-scale (The horizontal lines) | |
57 x_scale:2 ; x-scale (The vertical lines) | |
58 logbook_pixel_x_pos ; x2 position of current pixel in X-direction | |
59 logbook_min_temp_pos ; lowest row in the temp graph | |
60 logbook_max_temp_pos ; lowest row in the temp graph | |
61 logbook_menupos_temp ; last position of cursor | |
62 logbook_divenumber_temp ; used to back-up dive number | |
63 logbook_max_dive_counter_temp ; used to back-up max_dive_counter | |
64 ENDC ; used: 16 byte, remaining: 0 byte => FULL | |
0 | 65 |
582 | 66 CBLOCK local3 ; max size is 16 byte !!! |
67 divenumber ; used for accessing dives | |
68 vertical_interval:2 ; holds interval of samples for vertical 10min line | |
69 backup_color1 ; used for restoring drawing color | |
70 backup_color2 ; used for restoring drawing color | |
71 backup_divedata ; used to backup depth and salinity | |
72 fill_between_rows ; used for fill between rows | |
73 logbook_temp ; used as temp | |
74 logbook_temp_backup ; used as backup for temp | |
75 divisor_temperature ; divisor used while sampling of the dive data | |
76 divisor_deco ; divisor used while sampling of the dive data | |
77 divisor_gf ; divisor used while sampling of the dive data | |
78 divisor_ppo2_sensors ; divisor used while sampling of the dive data | |
79 divisor_decoplan ; divisor used while sampling of the dive data | |
80 divisor_cns ; divisor used while sampling of the dive data | |
81 divisor_tank ; divisor used while sampling of the dive data | |
82 ENDC ; used: 16 byte, remaining: 0 byte => FULL | |
83 | |
0 | 84 |
582 | 85 ; Remark: The variable gaslist_gas is "misused" here as a local variable, |
86 ; because the storage space for local variables is fully used up. | |
87 | |
88 | |
89 ;---- Defines ---------------------------------------------------------------- | |
90 | |
91 ; Flags | |
92 #DEFINE return_from_profileview logbook_flags,0 | |
93 #DEFINE all_dives_shown logbook_flags,1 | |
94 #DEFINE logbook_page_not_empty logbook_flags,2 | |
95 #DEFINE end_of_profile logbook_flags,3 | |
96 #DEFINE keep_cursor_new_page logbook_flags,4 | |
97 #DEFINE log_marker_found logbook_flags,5 | |
98 #DEFINE log_show_gas_short logbook_flags,6 | |
99 ; logbook_flags,7 ; unused | |
100 | |
0 | 101 ; Logbook Coordinates |
604 | 102 #DEFINE logbook_list_left .10 ; column of dive# in list |
103 #DEFINE logbook_row_offset .28 ; distance between rows of list | |
104 #DEFINE logbook_row_number .6 ; amount of rows in the list | |
0 | 105 |
106 ; Profile display | |
604 | 107 #DEFINE profile_height_pixels .157 ; amount of pixels height for profile display |
108 #DEFINE profile_width_pixels .156 ; amount of pixels width for profile display | |
109 #DEFINE profile_left .1 ; left border | |
110 #DEFINE profile_top .65 ; top border | |
0 | 111 |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
112 ; "Bailout" |
582 | 113 #DEFINE logbook_bailout_column .124 |
114 #DEFINE logbook_bailout_row .207 | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
115 |
0 | 116 ; Dive number |
582 | 117 #DEFINE logbook_divenumer_column .1 |
118 #DEFINE logbook_divenumer_row .1 | |
0 | 119 ; Date and Time |
582 | 120 #DEFINE logbook_date_column .100 |
121 #DEFINE logbook_date_row .7 | |
122 #DEFINE logbook_time_column .120 | |
123 #DEFINE logbook_time_row .38 | |
0 | 124 ; Max. Depth |
582 | 125 #DEFINE log_max_value_row .38 |
126 #DEFINE log_max_value_column .1 | |
127 ; Divetime | |
128 #DEFINE log_divetime_value_row .38 | |
129 #DEFINE log_divetime_value_column .60 | |
0 | 130 ; Gaslist below profile |
582 | 131 #DEFINE log_gas_row .225 |
132 #DEFINE log_gas_column1 .0 | |
133 #DEFINE log_gas_column2 log_gas_column1+(.1*.32) | |
134 #DEFINE log_gas_column3 log_gas_column1+(.2*.32) | |
135 #DEFINE log_gas_column4 log_gas_column1+(.3*.32) | |
136 #DEFINE log_gas_column5 log_gas_column1+(.4*.32) | |
0 | 137 |
138 ; Logbook Page2 | |
582 | 139 ; Gaslist |
140 #DEFINE log2_title_row1 .20 | |
141 #DEFINE log2_title_column .90 | |
142 #DEFINE log2_gas_column log2_title_column | |
143 #DEFINE log2_gas_row1 .36 | |
144 #DEFINE log2_gas_row2 1*.16+log2_gas_row1 | |
145 #DEFINE log2_gas_row3 2*.16+log2_gas_row1 | |
146 #DEFINE log2_gas_row4 3*.16+log2_gas_row1 | |
147 #DEFINE log2_gas_row5 4*.16+log2_gas_row1 | |
0 | 148 |
582 | 149 ; Setpoint List |
150 #DEFINE log2_title_sp_row .130 | |
151 #DEFINE log2_sp_row1 .146 | |
152 #DEFINE log2_sp_row2 1*.16+log2_sp_row1 | |
153 #DEFINE log2_sp_row3 2*.16+log2_sp_row1 | |
154 #DEFINE log2_sp_row4 3*.16+log2_sp_row1 | |
155 #DEFINE log2_sp_row5 4*.16+log2_sp_row1 | |
0 | 156 |
582 | 157 ; Details list |
158 #DEFINE log2_salinity_row .55 | |
159 #DEFINE log2_salinity_column .2 | |
160 #DEFINE log2_cns_row .1*.16+log2_salinity_row | |
161 #DEFINE log2_cns_column log2_salinity_column | |
162 #DEFINE log2_avr_row .2*.16+log2_salinity_row | |
163 #DEFINE log2_avr_column log2_salinity_column | |
164 #DEFINE log2_decomodel2_row .3*.16+log2_salinity_row | |
165 #DEFINE log2_decomodel2_column log2_salinity_column | |
166 #DEFINE log2_decomodel3_row .4*.16+log2_salinity_row | |
167 #DEFINE log2_decomodel3_column log2_salinity_column | |
168 #DEFINE log2_decomodel_row .5*.16+log2_salinity_row | |
169 #DEFINE log2_decomodel_column log2_salinity_column | |
170 #DEFINE log2_firmware_row .6*.16+log2_salinity_row | |
171 #DEFINE log2_firmware_column log2_salinity_column | |
172 #DEFINE log2_battery_row .7*.16+log2_salinity_row | |
173 #DEFINE log2_battery_column log2_salinity_column | |
174 #DEFINE log2_divemode_row .8*.16+log2_salinity_row | |
175 #DEFINE log2_divemode_column log2_salinity_column | |
176 #DEFINE log2_lastdeco_row .9*.16+log2_salinity_row | |
177 #DEFINE log2_lastdeco_column log2_salinity_column | |
0 | 178 ; Air pressure |
582 | 179 #DEFINE MBAR_row .10*.16+log2_salinity_row |
180 #DEFINE MBAR_column log2_salinity_column | |
0 | 181 |
182 | |
183 ; Header coordinates | |
582 | 184 #DEFINE log_profile_version .8 |
185 #DEFINE log_date .12 | |
186 #DEFINE log_time .15 | |
187 #DEFINE log_max_depth .17 | |
188 #DEFINE log_divetime .19 | |
189 #DEFINE log_min_temp .22 | |
190 #DEFINE log_surface_press .24 | |
191 #DEFINE log_desattime .26 | |
192 #DEFINE log_gas1 .28 | |
193 #DEFINE log_gas2 .32 | |
194 #DEFINE log_gas3 .36 | |
195 #DEFINE log_gas4 .40 | |
196 #DEFINE log_gas5 .44 | |
197 #DEFINE log_firmware .48 | |
198 #DEFINE log_battery .50 | |
199 #DEFINE log_samplingrate .52 | |
200 #DEFINE log_cns_start .53 | |
201 #DEFINE log_gf_start .55 | |
202 #DEFINE log_gf_end .56 | |
203 #DEFINE log_batt_info .59 | |
204 #DEFINE log_sp1 .60 | |
205 #DEFINE log_sp2 .62 | |
206 #DEFINE log_sp3 .64 | |
207 #DEFINE log_sp4 .66 | |
208 #DEFINE log_sp5 .68 | |
209 #DEFINE log_salinity .70 | |
210 #DEFINE log_cns_end .71 | |
211 #DEFINE log_avr_depth .73 | |
212 #DEFINE log_total_seconds .75 | |
213 #DEFINE log_gf_lo .77 | |
214 #DEFINE log_sat_mult .77 | |
215 #DEFINE log_gf_hi .78 | |
216 #DEFINE log_desat_mult .78 | |
217 #DEFINE log_decomodel .79 | |
218 #DEFINE log_total_dives .80 | |
219 #DEFINE log_divemode .82 | |
220 #DEFINE log_last_stop .243 | |
0 | 221 |
582 | 222 |
223 LOG_POINT_TO macro address | |
224 movlw address | |
225 movwf ext_flash_address+0 | |
226 endm | |
227 | |
604 | 228 logbook CODE |
0 | 229 |
230 ;============================================================================= | |
231 | |
582 | 232 TFT_logbook_cursor: |
233 ; call speed_fastest | |
234 WIN_BOX_BLACK .0, .240-.16, logbook_list_left-.8, logbook_list_left-.1 ; top, bottom, left, right | |
0 | 235 |
582 | 236 WIN_LEFT logbook_list_left-.8 |
237 WIN_FONT FT_SMALL | |
604 | 238 ; bcf win_invert ; reset invert flag |
0 | 239 call TFT_standard_color |
240 | |
582 | 241 movff menupos1,lo |
242 dcfsnz lo,F | |
0 | 243 movlw d'0' |
582 | 244 dcfsnz lo,F |
0 | 245 movlw logbook_row_offset |
582 | 246 dcfsnz lo,F |
0 | 247 movlw .2*logbook_row_offset |
582 | 248 dcfsnz lo,F |
0 | 249 movlw .3*logbook_row_offset |
582 | 250 dcfsnz lo,F |
0 | 251 movlw .4*logbook_row_offset |
582 | 252 dcfsnz lo,F |
0 | 253 movlw .5*logbook_row_offset |
582 | 254 dcfsnz lo,F |
0 | 255 movlw .6*logbook_row_offset |
582 | 256 dcfsnz lo,F |
0 | 257 movlw .7*logbook_row_offset |
582 | 258 dcfsnz lo,F |
0 | 259 movlw .8*logbook_row_offset |
260 | |
433 | 261 movwf win_top |
0 | 262 STRCPY_PRINT "\xB7" |
263 return | |
264 | |
582 | 265 global logbook ; entry point coming from menu_tree.asm |
0 | 266 logbook: |
582 | 267 clrf logbook_flags |
268 clrf CCP1CON ; stop PWM | |
604 | 269 bcf PORTC,2 ; pull PWM out to GND |
582 | 270 call TFT_boot |
271 ; call TFT_standard_color | |
604 | 272 clrf menupos3 ; here: used rows on current logbook-page |
273 clrf logbook_page_number ; here: # of current displayed page | |
582 | 274 clrf logbook_divenumber ; # of dive in list during search |
275 clrf logbook_temp | |
276 clrf logbook_temp_backup | |
604 | 277 clrf timeout_counter2 ; for timeout |
582 | 278 movlw logbook_row_number |
604 | 279 movwf menupos1 ; here: stores current position on display (logbook_row_number-x) |
280 read_int_eeprom .2 ; get low-byte of total dives | |
582 | 281 movff EEDATA,logbook_max_dive_counter |
0 | 282 |
283 ;----------------------------------------------------------------------------- | |
284 ; display dive headers backwards from read_int_eeprom .2 = lo-1 | |
285 ; 1st: 200000h-200FFFh -> lo=0 | |
286 ; 2nd: 201000h-201FFFh -> lo=1 | |
287 ; 3rd: 202000h-202FFFh -> lo=2 | |
288 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
289 ; Stop when | |
290 ; a) no dive is stored (no valid header found) | |
291 ; b) current dive has no valid header (Number of stored dives < 256) | |
582 | 292 ; c) when 255 dives are reached logbook_temp = 255 |
0 | 293 |
294 logbook2: | |
582 | 295 ; call speed_fastest |
296 incf logbook_temp,F ; increase dive counter | |
297 incf logbook_temp,W ; = 0x..FF ? | |
604 | 298 bz logbook_reset ; YES - FF --> loop |
0 | 299 |
300 ; Set ext_flash_address:3 to TOC entry of this dive | |
301 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0 | |
302 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1 | |
303 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2 | |
604 | 304 ; 256: 2FF000h-2FFFFFh -> logbook_max_dive_counter=255 (and hi>0...) |
0 | 305 |
582 | 306 decf logbook_max_dive_counter,F ; -1 |
0 | 307 |
582 | 308 clrf ext_flash_address+0 |
309 clrf ext_flash_address+1 | |
310 movlw 0x20 | |
311 movwf ext_flash_address+2 | |
312 movlw .16 | |
313 mulwf logbook_max_dive_counter ; logbook_max_dive_counter*16 = offset to 0x2000 (up:hi) | |
314 movf PRODL,W | |
315 addwf ext_flash_address+1,F | |
316 movf PRODH,W | |
317 addwfc ext_flash_address+2,F | |
0 | 318 ; pointer at the first 0xFA of header |
319 | |
604 | 320 call ext_flash_byte_read ; reads one byte@ext_flash_address:3 into WREG and ext_flash_rw |
582 | 321 movwf ext_flash_rw |
322 movlw 0xFA | |
323 cpfseq ext_flash_rw ; 0xFA found? | |
604 | 324 bra logbook3b ; NO - abort |
0 | 325 |
582 | 326 incf logbook_divenumber,F ; new header found, increase logbook_divenumber |
604 | 327 bra logbook4 ; done with searching, display the header |
0 | 328 |
329 logbook3b: | |
604 | 330 btfss logbook_page_not_empty ; was there at least one dive? |
331 bra exit_logbook ; not a single header was found, leave logbook | |
582 | 332 bra logbook_display_loop2 |
0 | 333 |
334 logbook_reset: | |
604 | 335 tstfsz logbook_divenumber ; was there at least one dive? |
582 | 336 bra logbook_reset2 |
604 | 337 bra logbook3b ; NO - nothing to do |
0 | 338 |
339 logbook_reset2: | |
604 | 340 bsf all_dives_shown ; YES |
341 bra logbook_display_loop2 ; continue | |
0 | 342 |
343 logbook4: | |
604 | 344 btfsc all_dives_shown ; all dives displayed? |
345 bra logbook_display_loop2 ; YES - display first page again | |
0 | 346 |
582 | 347 call display_listdive ; display short header for list on current list position |
0 | 348 |
582 | 349 movlw logbook_row_number |
350 cpfseq menupos1 ; first dive on list (top place)? | |
604 | 351 bra logbook_display_loop1 ; NO - skip saving of address |
0 | 352 |
582 | 353 ; store all registers required to rebuilt the current logbook page after the detail/profile view |
604 | 354 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page |
355 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup counter | |
582 | 356 movff logbook_temp,logbook_temp_backup ; amount of dives drawn until now |
357 | |
0 | 358 |
359 logbook_display_loop1: | |
604 | 360 decfsz menupos1,F ; list full? |
361 bra logbook2 ; NO - search another dive for our current logbook page | |
0 | 362 |
363 logbook_display_loop2: | |
604 | 364 btfss logbook_page_not_empty ; was there one dive at all? |
365 bra logbook ; YES - so reload the first page | |
0 | 366 |
367 ; TFT_mask... | |
368 | |
369 WIN_LEFT logbook_list_left | |
370 WIN_TOP logbook_row_offset*logbook_row_number | |
582 | 371 STRCPY_TEXT_PRINT tNextLog ; "Next Page" |
0 | 372 WIN_LEFT logbook_list_left |
373 WIN_TOP logbook_row_offset*(logbook_row_number+.1) | |
582 | 374 STRCPY_TEXT_PRINT tExit ; "Exit" |
0 | 375 |
604 | 376 movlw d'1' ; set cursor to position 1... |
582 | 377 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view |
378 movf logbook_menupos_temp,W ; load last cursor position again | |
379 movwf menupos1 ; and set menupos1 byte | |
604 | 380 bcf return_from_profileview ; do this only once while the page is loaded again |
0 | 381 |
604 | 382 bcf logbook_page_not_empty ; obviously the current page is NOT empty |
169
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
168
diff
changeset
|
383 |
604 | 384 movlw d'7' ; set cursor to position 7... |
385 btfsc keep_cursor_new_page ; ... if we came from the "new page" line | |
582 | 386 movwf menupos1 ; and set menupos1 byte |
387 bcf keep_cursor_new_page | |
169
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
168
diff
changeset
|
388 |
604 | 389 call TFT_logbook_cursor ; show the cursor |
0 | 390 |
604 | 391 call logbook_preloop_tasks ; clear some flags and set to Speed_eco |
392 call menu_processor_bottom_line ; show bottom line | |
582 | 393 |
0 | 394 logbook_loop: |
582 | 395 btfsc switch_left ; SET/MENU? |
396 goto next_logbook3 ; adjust cursor or create new page | |
397 btfsc switch_right ; ENTER? | |
398 bra display_profile_or_exit ; view details/profile or exit logbook | |
0 | 399 |
604 | 400 rcall log_screendump_and_onesecond ; check if we need to make a screen-shot and check for new second |
401 btfsc sleepmode ; timeout? | |
402 bra exit_logbook ; YES | |
403 bra logbook_loop ; NO - wait for something to do | |
0 | 404 |
405 display_profile_or_exit: | |
582 | 406 movlw logbook_row_number+.2 ; exit? |
407 cpfseq menupos1 | |
604 | 408 bra display_profile_or_exit2 ; NO - check for "Next Page" |
371 | 409 |
372 | 410 exit_logbook: |
582 | 411 ; call TFT_DisplayOff |
412 ; call TFT_boot | |
413 goto do_main_menu2 ; jump-back to menu_tree.asm | |
0 | 414 |
415 display_profile_or_exit2: | |
604 | 416 movlw logbook_row_number+.1 ; next page? |
582 | 417 cpfseq menupos1 |
604 | 418 bra display_profile ; NO - show details/profile |
419 goto next_logbook2 ; next page | |
0 | 420 |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
421 display_profile: |
604 | 422 bcf FLAG_bailout_mode |
423 bcf gas6_changed ; clear event flags | |
582 | 424 ; call speed_fastest |
425 movff menupos1,logbook_menupos_temp ; store current cursor position | |
426 bsf return_from_profileview ; tweak search routine to exit after found | |
0 | 427 |
604 | 428 movf logbook_page_number,W ; number of page |
582 | 429 mullw logbook_row_number |
430 movf PRODL,W | |
431 addwf menupos1,W ; page * logbook_row_number + menupos1 = | |
432 movwf divenumber ; # of dive to show | |
0 | 433 |
434 display_profile2: | |
582 | 435 ; call speed_fastest |
436 clrf CCP1CON ; stop PWM | |
604 | 437 bcf PORTC,2 ; pull PWM out to GND |
582 | 438 call TFT_boot |
604 | 439 ; call TFT_ClearScreen ; clear screen |
440 ; set ext_flash pointer to "#divenumber-oldest" dive | |
582 | 441 ; compute read_int_eeprom .2 - divenumber |
604 | 442 ; read required header data for profile display |
582 | 443 ; look in header for pointer to begin of dive profile (Byte 2-4) |
604 | 444 ; set pointer (ext_flash_log_pointer:3) to this address, start drawing |
582 | 445 |
446 decf divenumber,F ;-1 | |
0 | 447 read_int_eeprom .2 |
448 movf EEDATA,W | |
449 bcf STATUS,C | |
582 | 450 subfwb divenumber,W ; max. dives (low value) - divenumber |
451 movwf lo ; result | |
452 incf divenumber,F ;+1 | |
0 | 453 ; Set ext_flash_address:3 to TOC entry of this dive |
454 ; 1st: 200000h-200FFFh -> lo=0 | |
455 ; 2nd: 201000h-201FFFh -> lo=1 | |
456 ; 3rd: 202000h-202FFFh -> lo=2 | |
457 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
582 | 458 clrf ext_flash_address+0 |
459 clrf ext_flash_address+1 | |
460 movlw 0x20 | |
461 movwf ext_flash_address+2 | |
462 movlw .16 | |
463 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
464 movf PRODL,W | |
465 addwf ext_flash_address+1,F | |
466 movf PRODH,W | |
467 addwfc ext_flash_address+2,F | |
0 | 468 ; pointer at the first 0xFA of header |
469 | |
470 ; Now, show profile | |
582 | 471 LOG_POINT_TO log_samplingrate |
604 | 472 call ext_flash_byte_read ; read sampling rate |
582 | 473 movff ext_flash_rw,samplesecs_value ; needed later... |
0 | 474 |
582 | 475 LOG_POINT_TO .2 |
604 | 476 call ext_flash_byte_read_plus ; read start address of profile |
582 | 477 movff ext_flash_rw,ext_flash_log_pointer+0 |
604 | 478 call ext_flash_byte_read_plus ; read start address of profile |
582 | 479 movff ext_flash_rw,ext_flash_log_pointer+1 |
604 | 480 call ext_flash_byte_read_plus ; read start address of profile |
582 | 481 movff ext_flash_rw,ext_flash_log_pointer+2 |
0 | 482 |
582 | 483 clrf logbook_sample_counter+0 |
484 clrf logbook_sample_counter+1 ; holds amount of read samples | |
0 | 485 |
582 | 486 call TFT_standard_color |
604 | 487 call logbook_show_divenumber ; show the dive number in medium font |
0 | 488 |
582 | 489 WIN_SMALL logbook_date_column, logbook_date_row |
490 LOG_POINT_TO log_date | |
491 call ext_flash_byte_read_plus | |
492 movff ext_flash_rw,up ; year | |
493 call ext_flash_byte_read_plus | |
494 movff ext_flash_rw,hi ; month | |
495 call ext_flash_byte_read_plus | |
496 movff ext_flash_rw,lo ; day | |
497 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
498 STRCAT_PRINT "" | |
499 | |
500 WIN_SMALL log_divetime_value_column,logbook_date_row ; align with surrounding data | |
501 LOG_POINT_TO log_divemode | |
604 | 502 call ext_flash_byte_read_plus ; read dive mode |
503 movff ext_flash_rw,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR | |
504 call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, Gauge, Apnea or pSCR) | |
0 | 505 |
582 | 506 WIN_SMALL logbook_time_column, logbook_time_row |
507 LOG_POINT_TO log_time | |
508 call ext_flash_byte_read_plus ; hour | |
509 movff ext_flash_rw,lo | |
510 call ext_flash_byte_read_plus ; minutes | |
511 movff ext_flash_rw,hi | |
512 output_99x ; hour | |
513 PUTC ':' | |
514 movff hi,lo | |
515 output_99x ; minute | |
604 | 516 STRCAT_PRINT "" ; display 1st row of details |
0 | 517 |
582 | 518 LOG_POINT_TO log_profile_version |
604 | 519 call ext_flash_byte_read_plus ; profile version |
582 | 520 movlw 0x24 |
604 | 521 cpfslt ext_flash_rw ; < 0x24 ? |
522 bra log_skip_extra_icon ; YES - skip | |
582 | 523 |
524 WIN_SMALL logbook_time_column-.8, logbook_time_row | |
525 STRCPY_PRINT 0x94 ; "End of dive" icon | |
389
9175429bdeba
CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents:
376
diff
changeset
|
526 |
9175429bdeba
CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents:
376
diff
changeset
|
527 log_skip_extra_icon: |
582 | 528 LOG_POINT_TO log_max_depth |
529 call ext_flash_byte_read_plus ; read max depth | |
530 movff ext_flash_rw,lo | |
531 call ext_flash_byte_read_plus ; read max depth | |
532 movff ext_flash_rw,hi | |
533 movff lo,xA+0 ; calculate y-scale for profile display | |
534 movff hi,xA+1 | |
535 movlw profile_height_pixels ; pixel height available for profile | |
536 movwf xB+0 | |
537 clrf xB+1 | |
604 | 538 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 539 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!) |
540 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!) | |
541 infsnz y_scale+0,F ; increase one, because there may be a remainder | |
542 incf y_scale+1,F | |
0 | 543 |
582 | 544 movlw LOW ((profile_height_pixels+1)*.1000) |
545 movwf xC+0 | |
546 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF') | |
547 movwf xC+1 | |
548 movlw UPPER ((profile_height_pixels+1)*.1000) | |
549 movwf xC+2 | |
550 clrf xC+3 | |
0 | 551 |
604 | 552 movff lo,xB+0 ; max. Depth in mbar |
553 movff hi,xB+1 ; max. Depth in mbar | |
582 | 554 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
0 | 555 |
582 | 556 movff xC+0,x_scale+0 |
557 movff xC+1,x_scale+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line) | |
558 | |
559 movf x_scale+0,W | |
604 | 560 iorwf x_scale+1,W ; x_scale:2 = Null ? |
561 bnz display_profile_offset4 ; NO - continue | |
562 incf x_scale+1,F ; YES - make x_scale+1>1 to make "display_profile2e" working | |
0 | 563 |
564 display_profile_offset4: | |
582 | 565 WIN_SMALL log_max_value_column,log_max_value_row |
0 | 566 |
582 | 567 TSTOSS opt_units ; 0=Meters, 1=Feets |
568 bra display_profile_offset4_metric | |
569 ; display_profile_offset4_imperial: | |
570 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
0 | 571 PUTC ' ' |
582 | 572 bcf leftbind |
573 output_16_3 ; limit to 999 and display only (0-999) | |
574 STRCAT_TEXT_PRINT tFeets | |
575 bra display_profile_offset4_common | |
0 | 576 |
577 display_profile_offset4_metric: | |
582 | 578 bsf leftbind |
579 output_16dp d'3' ; max. depth | |
580 STRCAT_TEXT_PRINT tMeters | |
0 | 581 |
582 | 582 display_profile_offset4_common: |
604 | 583 call ext_flash_byte_read_plus ; divetime in minutes |
582 | 584 movff ext_flash_rw,lo |
585 call ext_flash_byte_read_plus | |
586 movff ext_flash_rw,hi ; divetime in minutes | |
0 | 587 |
582 | 588 movff lo,xA+0 ; calculate x-scale for profile display |
589 movff hi,xA+1 ; calculate total diveseconds first | |
604 | 590 movlw d'60' ; 60 seconds are one minute |
582 | 591 movwf xB+0 |
592 clrf xB+1 | |
593 call mult16x16 ; result is in xC:2 ! | |
0 | 594 |
582 | 595 WIN_SMALL log_divetime_value_column,log_divetime_value_row |
596 bsf leftbind | |
597 output_16 ; divetime minutes | |
598 movlw LOW d'600' | |
599 movwf xA+0 | |
600 movlw HIGH d'600' | |
601 movwf xA+1 ; a vertical line every 600 seconds | |
604 | 602 movff samplesecs_value,xB+0 ; copy sampling rate |
582 | 603 clrf xB+1 |
604 call div16x16 ; xA/xB=xC with xA as remainder | |
605 movff xC+0,vertical_interval+0 | |
606 movff xC+1,vertical_interval+1 | |
607 ; vertical_interval:2 holds interval of samples for vertical 10min line | |
0 | 608 |
582 | 609 ; Restore divetime in minutes: |
610 ; get real sample time | |
611 LOG_POINT_TO log_total_seconds | |
604 | 612 call ext_flash_byte_read_plus ; total sample time in seconds |
582 | 613 movff ext_flash_rw,xC+0 |
604 | 614 call ext_flash_byte_read_plus ; total sample time in seconds |
582 | 615 movff ext_flash_rw,xC+1 |
0 | 616 |
582 | 617 PUTC ':' |
618 LOG_POINT_TO log_divetime+.2 | |
619 call ext_flash_byte_read_plus ; read divetime seconds | |
620 movff ext_flash_rw,lo | |
621 movff xC+0,xA+0 ; now calculate x-scale value | |
622 movff xC+1,xA+1 | |
623 movlw profile_width_pixels ; pix width available | |
624 movwf xB+0 | |
625 clrf xB+1 | |
604 | 626 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 627 movff xC+0,xA+0 |
628 movff xC+1,xA+1 | |
604 | 629 movf samplesecs_value,W ; divide through sample interval |
582 | 630 movwf xB+0 |
631 clrf xB+1 | |
604 | 632 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 633 movff xC+0,profile_temp1+0 ; store value (use any #xC sample, skip xC-1) into temp registers |
634 movff xC+1,profile_temp1+1 ; store value (use any #xC sample, skip xC-1) into temp registers | |
604 | 635 infsnz profile_temp1+0,F ; increase by one, there might be a remainder |
582 | 636 incf profile_temp1+1,F |
0 | 637 |
582 | 638 bsf leftbind |
639 output_99x ; divetime seconds | |
0 | 640 call TFT_standard_color |
582 | 641 STRCAT_PRINT "" |
0 | 642 |
604 | 643 call ext_flash_byte_read_plus ; read min. temperature |
582 | 644 movff ext_flash_rw,logbook_min_tp+0 |
604 | 645 call ext_flash_byte_read_plus ; read min. temperature |
582 | 646 movff ext_flash_rw,logbook_min_tp+1 |
0 | 647 |
582 | 648 ; Set pointer to Gas 1 Type. |
649 LOG_POINT_TO log_gas1+.3 | |
604 | 650 call ext_flash_byte_read_plus ; read gas type |
651 decfsz ext_flash_rw,W ; = 1 (= "First") ? | |
652 bra logbook_find_first_gas2 ; NO | |
582 | 653 movlw .1 |
654 movwf ext_flash_rw | |
655 bra logbook_find_first_gas_done | |
0 | 656 logbook_find_first_gas2: |
582 | 657 ; Set pointer to Gas 2 Type. |
658 LOG_POINT_TO log_gas2+.3 | |
604 | 659 call ext_flash_byte_read_plus ; read gas type |
660 decfsz ext_flash_rw,W ; = 1 (= "First") ? | |
661 bra logbook_find_first_gas3 ; NO | |
582 | 662 movlw .2 |
663 movwf ext_flash_rw | |
664 bra logbook_find_first_gas_done | |
0 | 665 logbook_find_first_gas3: |
582 | 666 ; Set pointer to Gas 3 Type. |
667 LOG_POINT_TO log_gas3+.3 | |
604 | 668 call ext_flash_byte_read_plus ; read gas type |
669 decfsz ext_flash_rw,W ; = 1 (= "First") ? | |
670 bra logbook_find_first_gas4 ; NO | |
582 | 671 movlw .3 |
672 movwf ext_flash_rw | |
673 bra logbook_find_first_gas_done | |
0 | 674 logbook_find_first_gas4: |
582 | 675 ; Set pointer to Gas 4 Type. |
676 LOG_POINT_TO log_gas4+.3 | |
604 | 677 call ext_flash_byte_read_plus ; read gas type |
678 decfsz ext_flash_rw,W ; = 1 (= "First") ? | |
679 bra logbook_find_first_gas5 ; NO | |
582 | 680 movlw .4 |
681 movwf ext_flash_rw | |
682 bra logbook_find_first_gas_done | |
0 | 683 logbook_find_first_gas5: |
604 | 684 movlw .5 ; must be Gas 5 |
582 | 685 movwf ext_flash_rw |
0 | 686 logbook_find_first_gas_done: |
582 | 687 movff ext_flash_rw,backup_color1 ; keep copy to restore color |
688 movff ext_flash_rw,WREG ; copy gas number to WREG for color coding | |
604 | 689 call TFT_color_code_gas ; back to normal profile color |
582 | 690 ; Pointer is now trashed! |
0 | 691 |
582 | 692 ; Point to profile portion of this dive |
693 movff ext_flash_log_pointer+0,ext_flash_address+0 | |
694 movff ext_flash_log_pointer+1,ext_flash_address+1 | |
695 movff ext_flash_log_pointer+2,ext_flash_address+2 | |
0 | 696 |
604 | 697 incf_ext_flash_address_0x20 d'2' ; skip 0xFA 0xFA |
698 call ext_flash_byte_read_plus_0x20 ; read low byte of total dives into ext_flash_rw (at the time the dive was made) | |
0 | 699 |
700 ; Load total number of dives (low byte only) | |
701 read_int_eeprom .2 | |
582 | 702 incf EEDATA,W ; +1 |
604 | 703 bsf STATUS,C ; set borrow |
582 | 704 subfwb divenumber,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made) |
705 cpfseq ext_flash_rw ; # of dive in logbook (Must be equal with low byte in short header) | |
604 | 706 bra display_profile_no_profile ; not equal, no profile for this dive available |
0 | 707 |
708 ; Skip rest of short header: 3 Bytes | |
709 ; Skip length of profile data: 3 Bytes | |
582 | 710 ; Skip sampling rate in profile section: 1Byte |
711 ; Skip number of divisors: 1Byte | |
712 incf_ext_flash_address_0x20 d'8' | |
0 | 713 |
604 | 714 ; divisor temp |
582 | 715 incf_ext_flash_address_0x20 d'2' |
604 | 716 ; call ext_flash_byte_read_plus_0x20 ; read information type |
717 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
718 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
582 | 719 movf ext_flash_rw,W |
604 | 720 movwf divisor_temperature ; store divisor |
721 movwf count_temperature ; store to tp° counter, too | |
722 ; divisor deco | |
582 | 723 incf_ext_flash_address_0x20 d'2' |
604 | 724 ; call ext_flash_byte_read_plus_0x20 ; read information type |
725 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
726 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
582 | 727 movf ext_flash_rw,W |
604 | 728 movwf divisor_deco ; store divisor |
729 movwf count_deco ; store as temp, too | |
730 ; divisor GF | |
582 | 731 incf_ext_flash_address_0x20 d'2' |
604 | 732 ; call ext_flash_byte_read_plus_0x20 ; read information type |
733 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
734 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
735 movff ext_flash_rw,divisor_gf ; store divisor | |
736 ; divisor ppO2 sensors | |
582 | 737 incf_ext_flash_address_0x20 d'2' |
604 | 738 ; call ext_flash_byte_read_plus_0x20 ; read information type |
739 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
740 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
741 movff ext_flash_rw,divisor_ppo2_sensors ; store divisor | |
742 ; divisor decoplan | |
582 | 743 incf_ext_flash_address_0x20 d'2' |
604 | 744 ; call ext_flash_byte_read_plus_0x20 ; read information type |
745 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
746 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
747 movff ext_flash_rw,divisor_decoplan ; store divisor | |
748 ; divisor CNS | |
582 | 749 incf_ext_flash_address_0x20 d'2' |
604 | 750 ; call ext_flash_byte_read_plus_0x20 ; read information type |
751 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
752 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
753 movff ext_flash_rw,divisor_cns ; store divisor | |
754 ; divisor tank data | |
582 | 755 incf_ext_flash_address_0x20 d'2' |
604 | 756 ; call ext_flash_byte_read_plus_0x20 ; read information type |
757 ; call ext_flash_byte_read_plus_0x20 ; read information length | |
758 call ext_flash_byte_read_plus_0x20 ; read information divisor | |
759 movff ext_flash_rw,divisor_tank ; store divisor | |
0 | 760 |
604 | 761 ; Start profile display |
582 | 762 movlw color_deepblue |
604 | 763 call TFT_set_color |
582 | 764 ; Draw a frame around profile area |
765 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 | |
0 | 766 |
582 | 767 movlw profile_top |
768 movwf win_top | |
769 movlw profile_left | |
604 | 770 movwf win_leftx2 ; left border (0-159) |
582 | 771 movlw d'1' |
772 movwf win_height | |
773 movlw profile_width_pixels+.1 | |
604 | 774 movwf win_width+0 ; right border (0-159) |
582 | 775 clrf win_width+1 |
604 | 776 bra display_profile2f ; no 0m line |
0 | 777 display_profile2e: |
604 | 778 call TFT_box ; inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
0 | 779 display_profile2f: |
604 | 780 movf win_top,W ; get row |
781 addwf x_scale+0,W ; add line interval distance to win_top | |
782 tstfsz x_scale+1 ; > 255 ? | |
783 movlw d'255' ; YES - make win_top>239 -> abort here | |
784 btfsc STATUS,C ; a carry from the addwf above? | |
785 movlw d'255' ; YES - make win_top>239 -> abort here | |
786 movwf win_top ; result in win_top again | |
787 movlw profile_top+profile_height_pixels+.1 ; limit | |
788 cpfsgt win_top ; > 239 ? | |
789 bra display_profile2e ; NO - draw another line | |
0 | 790 |
604 | 791 clrf gaslist_gas ; here: used as counter for depth readings |
582 | 792 movlw profile_width_pixels+profile_left-.1 |
793 movwf ignore_digits ; here: used as counter for x-pixels | |
794 bcf end_of_profile ; clear flag | |
372 | 795 |
582 | 796 movlw profile_left+.1 |
797 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5) | |
372 | 798 |
604 | 799 movlw profile_top+.1 ; zero-m row |
582 | 800 movwf fill_between_rows |
604 | 801 movwf logbook_last_tp ; initialize for Tp° curve, too |
582 | 802 |
604 | 803 movlw LOW(-.100) ; initialize max tp° to -10.0 °C |
582 | 804 movwf logbook_max_tp+0 |
805 movlw HIGH 0xFFFF & (-.100) | |
806 movwf logbook_max_tp+1 | |
0 | 807 |
604 | 808 setf logbook_cur_tp+0 ; initialize Tp°, before the first recorded point |
582 | 809 setf logbook_cur_tp+1 |
604 | 810 clrf logbook_last_tp ; also reset previous Y for Tp° |
811 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling | |
582 | 812 movlw profile_top+.1 |
604 | 813 movwf logbook_min_temp_pos ; initialize for displaying the lowest temperature |
582 | 814 movlw profile_top+profile_height_pixels |
604 | 815 movwf logbook_max_temp_pos ; initialize for displaying the highest temperature |
0 | 816 |
582 | 817 movlw profile_left |
818 movwf win_leftx2 | |
819 movlw profile_top | |
820 movwf win_top | |
821 movlw profile_height_pixels | |
822 movwf win_height | |
823 movlw LOW (profile_width_pixels*.2) | |
824 movwf win_width+0 | |
825 movlw HIGH (profile_width_pixels*.2) | |
826 movwf win_width+1 | |
827 call TFT_box_write ; open box for d1 | |
371 | 828 |
582 | 829 ; INIT_PIXEL_WRITE logbook_pixel_x_pos ; pixel x2 (also sets standard color!) |
0 | 830 |
831 profile_display_loop: | |
434 | 832 ; Init pixel write |
582 | 833 movf logbook_pixel_x_pos,W |
834 mullw 2 | |
835 call pixel_write_col320 | |
836 | |
837 movff profile_temp1+0,profile_temp2+0 | |
604 | 838 movff profile_temp1+1,profile_temp2+1 ; 16bit x-scaler |
582 | 839 incf profile_temp2+1,F |
604 | 840 tstfsz profile_temp2+0 ; must not be zero |
841 bra profile_display_loop2 ; not Zero | |
842 incf profile_temp2+0,F ; zero, increase | |
0 | 843 |
844 profile_display_loop2: | |
582 | 845 rcall profile_view_get_depth ; reads depth, temp and profile data |
0 | 846 |
582 | 847 btfsc end_of_profile ; end-of profile reached? |
604 | 848 bra profile_display_loop_done ; YES - skip all remaining pixels |
0 | 849 |
850 | |
582 | 851 ;---- Draw Ceiling curve, if any --------------------------------------------- |
852 movf divisor_deco,W | |
853 bz profile_display_skip_deco | |
0 | 854 |
604 | 855 movf logbook_ceiling,W ; any deco ceiling? |
582 | 856 bz profile_display_skip_deco |
0 | 857 |
604 | 858 mullw .100 ; YES - convert to mbar |
582 | 859 movff PRODL,sub_a+0 |
860 movff PRODH,sub_a+1 | |
604 | 861 movff logbook_cur_depth+0,sub_b+0 ; compare with UNSIGNED current depth (16bits) |
582 | 862 movff logbook_cur_depth+1,sub_b+1 |
863 call subU16 ; set (or not) neg_flag | |
0 | 864 |
604 | 865 movlw color_dark_green ; dark green if ok |
582 | 866 btfss neg_flag |
604 | 867 movlw color_dark_red ; dark red if ceiling is violated |
582 | 868 call TFT_set_color |
0 | 869 |
582 | 870 movff PRODL,xA+0 |
871 movff PRODH,xA+1 | |
872 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset | |
873 movff y_scale+1,xB+1 | |
604 | 874 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 875 |
604 | 876 movlw profile_top+.1 ; starts right after the top line |
582 | 877 movwf win_top |
604 | 878 movff logbook_pixel_x_pos,win_leftx2 ; left border (0-159) |
582 | 879 movff xC+0,win_height |
604 | 880 call half_vertical_line ; inputs: win_top, win_leftx2, win_height, win_color1, win_color2 |
0 | 881 |
882 profile_display_skip_deco: | |
582 | 883 ;---- Draw Tp° curve, if any --------------------------------------------- |
884 movf divisor_temperature,W | |
885 bz profile_display_skip_temp | |
0 | 886 |
604 | 887 movf logbook_cur_tp+0,W ; did we had already a valid Tp°C record? |
582 | 888 andwf logbook_cur_tp+1,W |
889 incf WREG | |
604 | 890 bz profile_display_skip_temp ; NO - just skip drawing. |
0 | 891 |
582 | 892 movlw LOW (((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix |
893 movwf xB+0 | |
894 movlw HIGH (((profile_height_pixels-.10)*.256)/.370) | |
895 movwf xB+1 | |
0 | 896 |
604 | 897 movf logbook_cur_tp+0,W ; current Tp° - (-2.0°C) == Tp° + 20 |
898 addlw LOW(.20) ; low byte | |
582 | 899 movwf xA+0 |
900 movf logbook_cur_tp+1,W | |
604 | 901 btfsc STATUS,C ; propagate carry, if any |
582 | 902 incf WREG |
903 movwf xA+1 | |
904 call mult16x16 ; xA*xB=xC | |
0 | 905 |
582 | 906 ; scale: divide by 256, ie. take just high byte. |
907 movf xC+1,W | |
604 | 908 sublw profile_top+profile_height_pixels-.10 ; upside-down: Y = .75 + (.153 - result) |
582 | 909 movwf xC+0 |
0 | 910 |
911 ; Check limits | |
582 | 912 movlw profile_top+.1 |
913 movwf xC+1 | |
914 cpfsgt xC+0 | |
915 movff xC+1,xC+0 | |
0 | 916 |
582 | 917 movlw color_orange |
918 call TFT_set_color | |
0 | 919 |
604 | 920 movf logbook_last_tp,W ; do we have a valid previous value? |
921 bz profile_display_temp_1 ; NO - skip the vertical line. | |
582 | 922 movwf xC+1 |
604 | 923 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
924 profile_display_temp_1: |
582 | 925 movf xC+0,W ; current row |
926 cpfsgt logbook_min_temp_pos ; check limit | |
927 movwf logbook_min_temp_pos ; lowest row in the temp graph | |
928 cpfslt logbook_max_temp_pos ; check limit | |
929 movwf logbook_max_temp_pos ; highest row in the temp graph | |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
930 |
582 | 931 movff xC+0,logbook_last_tp |
604 | 932 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col(0..159) x row (0..239), put a current color pixel |
0 | 933 |
934 profile_display_skip_temp: | |
582 | 935 ;---- Draw depth curve --------------------------------------------------- |
936 movff y_scale+0,xB+0 ; divide pressure in mbar/quant for row offset | |
937 movff y_scale+1,xB+1 | |
938 movff logbook_cur_depth+0,xA+0 | |
939 movff logbook_cur_depth+1,xA+1 | |
604 | 940 call div16x16 ; xC = xA / xB with xA as remainder |
582 | 941 movlw profile_top+.1 |
942 addwf xC+0,F ; add 75 pixel offset to result | |
943 | |
604 | 944 btfsc STATUS,C ; ignore potential profile errors |
582 | 945 movff fill_between_rows,xC+0 |
0 | 946 |
582 | 947 movff backup_color1,WREG ; copy gas number to WREG for color-coding |
604 | 948 call TFT_color_code_gas ; back to normal profile color. |
0 | 949 |
582 | 950 movff fill_between_rows,xC+1 |
604 | 951 call profile_display_fill ; in this column between this row (xC+0) and the last row (xC+1) |
952 movff xC+0,fill_between_rows ; store last row for fill routine | |
0 | 953 |
604 | 954 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; set col(0..159) x row (0..239), put a std color pixel |
955 incf logbook_pixel_x_pos,F ; next column | |
0 | 956 |
582 | 957 ;---- Draw Marker square , if any ---------------------------------------- |
604 | 958 btfss log_marker_found ; any marker to draw? |
959 bra profile_display_skip_marker ; NO | |
402
a3a0f1fd7fc4
NEW: Logbook shows markers with small orange boxes in the profile
heinrichsweikamp
parents:
392
diff
changeset
|
960 |
582 | 961 ; tiny "m" |
962 incf fill_between_rows,W ; increase row (Y) | |
963 movwf win_top | |
964 ; limit win_top to 220 | |
965 movlw .220 | |
966 cpfslt win_top | |
967 movwf win_top | |
968 decf logbook_pixel_x_pos,W ; decrease column (X) | |
969 movwf win_leftx2 | |
970 ; limit win_leftx2 to 151 | |
971 movlw .151 | |
972 cpfslt win_leftx2 | |
973 movwf win_leftx2 | |
402
a3a0f1fd7fc4
NEW: Logbook shows markers with small orange boxes in the profile
heinrichsweikamp
parents:
392
diff
changeset
|
974 |
582 | 975 movlw color_orange |
976 call TFT_set_color | |
977 WIN_FONT FT_TINY | |
978 lfsr FSR2,buffer | |
979 STRCPY_PRINT "m" | |
604 | 980 bcf log_marker_found ; clear flag |
582 | 981 |
982 movlw profile_left | |
983 movwf win_leftx2 | |
984 movlw profile_top | |
985 movwf win_top | |
986 movlw profile_height_pixels | |
987 movwf win_height | |
988 movlw LOW (profile_width_pixels*.2) | |
989 movwf win_width+0 | |
990 movlw HIGH (profile_width_pixels*.2) | |
991 movwf win_width+1 | |
992 call TFT_box_write ; re-open box for d1 | |
402
a3a0f1fd7fc4
NEW: Logbook shows markers with small orange boxes in the profile
heinrichsweikamp
parents:
392
diff
changeset
|
993 |
a3a0f1fd7fc4
NEW: Logbook shows markers with small orange boxes in the profile
heinrichsweikamp
parents:
392
diff
changeset
|
994 profile_display_skip_marker: |
582 | 995 ;---- Draw CNS curve, if any --------------------------------------------- |
996 movf divisor_cns,W | |
997 bz profile_display_skip_cns | |
998 ; | |
604 | 999 ; add further code here... |
582 | 1000 ; |
0 | 1001 profile_display_skip_cns: |
1002 | |
582 | 1003 ;---- Draw GF curve, if any ---------------------------------------------- |
1004 movf divisor_gf,W | |
1005 bz profile_display_skip_gf | |
1006 ; | |
604 | 1007 ; add further code here... |
582 | 1008 ; |
0 | 1009 profile_display_skip_gf: |
1010 | |
604 | 1011 ;---- All curves done |
582 | 1012 |
604 | 1013 profile_display_skip_loop1: ; skips readings |
582 | 1014 dcfsnz profile_temp2+0,F |
604 | 1015 bra profile_display_loop3 ; check 16bit |
0 | 1016 |
582 | 1017 rcall profile_view_get_depth ; reads depth, temp and profile data |
168
1784ab9362ca
BUGFIX: False max. temp in Logbook, false Bailout and Gas 6 flags in logbook
heinrichsweikamp
parents:
167
diff
changeset
|
1018 |
582 | 1019 btfsc end_of_profile ; end-of profile reached? |
604 | 1020 bra profile_display_loop_done ; YES - skip all remaining pixels |
168
1784ab9362ca
BUGFIX: False max. temp in Logbook, false Bailout and Gas 6 flags in logbook
heinrichsweikamp
parents:
167
diff
changeset
|
1021 |
582 | 1022 bra profile_display_skip_loop1 |
0 | 1023 |
1024 profile_display_loop3: | |
582 | 1025 decfsz profile_temp2+1,F ; 16 bit x-scaler test |
604 | 1026 bra profile_display_skip_loop1 ; skips readings |
0 | 1027 |
582 | 1028 decfsz ignore_digits,F ; counts drawn x-pixels to zero |
604 | 1029 bra profile_display_loop ; not ready yet |
1030 ; done | |
0 | 1031 |
604 | 1032 display_profile_no_profile: ; no profile available for this dive |
0 | 1033 |
1034 profile_display_loop_done: | |
604 | 1035 btfss FLAG_bailout_mode ; bailout during the dive? |
1036 bra profile_display_loop_done_nobail ; NO | |
1037 ; YES - show "Bailout" | |
582 | 1038 movlw color_pink |
1039 call TFT_set_color | |
1040 WIN_TINY logbook_bailout_column,logbook_bailout_row | |
604 | 1041 STRCPY_TEXT_PRINT tDiveBailout ; bailout |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1042 profile_display_loop_done_nobail: |
582 | 1043 btfss gas6_changed ; Gas6 |
604 | 1044 bra profile_display_loop_done_nogas6 ; NO |
582 | 1045 ; Yes, show "Gas 6!" |
1046 movlw color_pink | |
1047 call TFT_set_color | |
1048 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 | |
604 | 1049 STRCPY_TEXT tGas ; gas |
582 | 1050 STRCAT_PRINT " 6!" |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1051 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1052 profile_display_loop_done_nogas6: |
604 | 1053 decf divenumber,F ; -1 |
0 | 1054 read_int_eeprom .2 |
582 | 1055 movf EEDATA,W |
1056 bcf STATUS,C | |
604 | 1057 subfwb divenumber,W ; max. dives (low value) - dive number |
582 | 1058 movwf lo ; result |
604 | 1059 incf divenumber,F ; +1 |
1060 ; set ext_flash_address:3 to TOC entry of this dive | |
0 | 1061 ; 1st: 200000h-200FFFh -> lo=0 |
1062 ; 2nd: 201000h-201FFFh -> lo=1 | |
1063 ; 3rd: 202000h-202FFFh -> lo=2 | |
1064 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
582 | 1065 clrf ext_flash_address+0 |
1066 clrf ext_flash_address+1 | |
1067 movlw 0x20 | |
1068 movwf ext_flash_address+2 | |
1069 movlw .16 | |
1070 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
1071 movf PRODL,W | |
1072 addwf ext_flash_address+1,F | |
1073 movf PRODH,W | |
1074 addwfc ext_flash_address+2,F | |
0 | 1075 ; pointer at the first 0xFA of header |
1076 | |
582 | 1077 movff logbook_min_temp_pos,win_top ; Y position at lowest temperature |
1078 movff logbook_pixel_x_pos,win_leftx2 | |
1079 movlw .130 | |
1080 cpfslt win_leftx2 ; limit left border to 130 | |
1081 movwf win_leftx2 | |
1082 WIN_FONT FT_TINY | |
604 | 1083 movlw color_orange ; use same color as tp° curve |
582 | 1084 call TFT_set_color |
0 | 1085 |
582 | 1086 movff logbook_min_tp+0,lo |
1087 movff logbook_min_tp+1,hi | |
1088 lfsr FSR2,buffer | |
0 | 1089 |
582 | 1090 TSTOSS opt_units ; 0=°C, 1=°F |
0 | 1091 bra logbook_show_temp_metric |
1092 ;logbook_show_temp_imperial: | |
582 | 1093 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
1094 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit | |
604 | 1095 lfsr FSR2,buffer ; overwrite "-" |
1096 bsf ignore_digit5 ; full degrees only | |
0 | 1097 output_16 |
582 | 1098 STRCAT_TEXT_PRINT tLogTunitF |
1099 ; Now, the max. temperature | |
1100 movlw .15 | |
1101 subwf logbook_max_temp_pos,W | |
1102 movff WREG,win_top ; Y position at max temperature | |
1103 movff logbook_max_tp+0,lo | |
1104 movff logbook_max_tp+1,hi | |
1105 lfsr FSR2,buffer | |
1106 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1107 call convert_celsius_to_fahrenheit ; convert value in lo:hi from Celsius to Fahrenheit | |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1108 output_16 |
0 | 1109 bcf ignore_digit5 |
582 | 1110 STRCAT_TEXT_PRINT tLogTunitF |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1111 |
0 | 1112 bra logbook_show_temp_common |
1113 | |
1114 logbook_show_temp_metric: | |
582 | 1115 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1116 movlw d'3' |
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1117 movwf ignore_digits |
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1118 bsf leftbind |
582 | 1119 output_16dp d'2' ; temperature |
1120 STRCAT_TEXT_PRINT tLogTunitC | |
1121 ; Now, the max. temperature | |
1122 movlw .15 | |
1123 subwf logbook_max_temp_pos,W | |
604 | 1124 movwf win_top ; Y position at max temperature |
582 | 1125 movff logbook_max_tp+0,lo |
1126 movff logbook_max_tp+1,hi | |
1127 lfsr FSR2,buffer | |
1128 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1129 movlw d'3' |
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1130 movwf ignore_digits |
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1131 bsf leftbind |
582 | 1132 output_16dp d'2' ; temperature |
1133 STRCAT_TEXT_PRINT tLogTunitC | |
0 | 1134 |
1135 logbook_show_temp_common: | |
50 | 1136 bcf leftbind |
582 | 1137 call TFT_standard_color |
0 | 1138 |
1139 ; Get pointer to Gaslist | |
582 | 1140 LOG_POINT_TO log_gas1 |
1141 bsf log_show_gas_short ; do the short version of log_show_gas | |
1142 bsf leftbind | |
0 | 1143 |
582 | 1144 WIN_TINY log_gas_column1, log_gas_row |
604 | 1145 movlw .1 ; color for gas 1 |
582 | 1146 call log_show_gas |
0 | 1147 |
582 | 1148 WIN_TINY log_gas_column2, log_gas_row |
604 | 1149 movlw .2 ; color for gas 2 |
582 | 1150 call log_show_gas |
0 | 1151 |
582 | 1152 WIN_TINY log_gas_column3, log_gas_row |
604 | 1153 movlw .3 ; color for gas 3 |
582 | 1154 call log_show_gas |
0 | 1155 |
582 | 1156 WIN_TINY log_gas_column4, log_gas_row |
604 | 1157 movlw .4 ; color for gas 4 |
582 | 1158 call log_show_gas |
0 | 1159 |
582 | 1160 WIN_TINY log_gas_column5, log_gas_row |
604 | 1161 movlw .5 ; color for gas 5 |
582 | 1162 call log_show_gas |
1163 | |
1164 bcf leftbind | |
0 | 1165 |
604 | 1166 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
582 | 1167 display_profile_loop: |
1168 btfsc switch_right | |
604 | 1169 bra logbook_page2 ; show more information |
582 | 1170 btfsc switch_left |
1171 bra exit_profileview ; back to list | |
0 | 1172 |
604 | 1173 rcall log_screendump_and_onesecond ; check if we need to make a screen-shot and check for new second |
1174 btfsc sleepmode ; timeout? | |
582 | 1175 bra exit_profileview ; back to list |
1176 bra display_profile_loop ; wait for something to do | |
0 | 1177 |
582 | 1178 global log_screendump_and_onesecond |
604 | 1179 log_screendump_and_onesecond: ; check if we need to make a screen-shot and check for new second |
582 | 1180 btfsc onesecupdate |
604 | 1181 call timeout_surfmode ; timeout |
582 | 1182 btfsc onesecupdate |
604 | 1183 call set_dive_modes ; check if divemode needs to be entered |
582 | 1184 bcf onesecupdate ; one second update |
1185 btfsc divemode | |
604 | 1186 goto restart ; enter divemode if required |
0 | 1187 |
604 | 1188 IFDEF _screendump |
1189 btfsc enable_screen_dumps ; screendump enabled? | |
1190 call TFT_dump_screen_check ; YES - check if requested and do it | |
1191 ENDIF | |
1192 | |
582 | 1193 btfsc vusb_in ; USB plugged in? |
604 | 1194 goto comm_mode ; YES - start COMM mode and return |
1195 | |
582 | 1196 return |
604 | 1197 |
0 | 1198 |
1199 ;============================================================================= | |
1200 ; Draw a vertical line between xC+1 and xC+0, at current X position. | |
1201 ; | |
1202 ; Note: should keep xC+0 | |
1203 ; Note: ascending or descending ! | |
1204 ; | |
1205 profile_display_fill: | |
582 | 1206 ; First, check if xC+0 > fill_between_rows or xC+0 < aponoe_mins |
0 | 1207 movf xC+0,W |
604 | 1208 cpfseq xC+1 ; xC+0 = apone_mins ? |
1209 bra profile_display_fill2 ; NO | |
0 | 1210 return |
1211 | |
604 | 1212 profile_display_fill2: |
582 | 1213 ; Make sure to init X position. |
1214 movf logbook_pixel_x_pos,W | |
1215 mullw 2 | |
1216 decf PRODL,F | |
1217 movlw 0 | |
1218 subwfb PRODH,F | |
1219 call pixel_write_col320 | |
0 | 1220 |
1221 movf xC+0,W | |
604 | 1222 cpfsgt xC+1 ; fill_between_rows > xC+0 ? |
1223 bra profile_display_fill_up ; YES | |
0 | 1224 |
604 | 1225 profile_display_fill_down2: ; loop |
560 | 1226 decf xC+1,F |
0 | 1227 |
604 | 1228 HALF_PIXEL_WRITE xC+1 ; updates just row (0..239) |
0 | 1229 |
560 | 1230 movf xC+0,W |
604 | 1231 cpfseq xC+1 ; loop until xC+1 = xC+0 |
560 | 1232 bra profile_display_fill_down2 |
582 | 1233 return ; fill_between_rows and xC+0 are untouched |
0 | 1234 |
604 | 1235 profile_display_fill_up: ; fill upwards from xC+0 to apone_mins! |
560 | 1236 incf xC+1,F |
0 | 1237 |
604 | 1238 HALF_PIXEL_WRITE xC+1 ; updates just row (0..239) |
0 | 1239 |
560 | 1240 movf xC+0,W |
604 | 1241 cpfseq xC+1 ; loop until xC+1 = fill_between_rows |
560 | 1242 bra profile_display_fill_up |
582 | 1243 return ; fill_between_rows and xC+0 are untouched |
0 | 1244 |
1245 ;============================================================================= | |
1246 | |
1247 | |
1248 profile_view_get_depth: | |
582 | 1249 infsnz logbook_sample_counter+0,F |
604 | 1250 incf logbook_sample_counter+1,F ; count read pixels |
0 | 1251 |
582 | 1252 movf logbook_sample_counter+0,W |
1253 cpfseq vertical_interval+0 | |
1254 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | |
1255 movf logbook_sample_counter+1,W | |
1256 cpfseq vertical_interval+1 | |
1257 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | |
560 | 1258 ; draw a new 10min line here... |
582 | 1259 clrf logbook_sample_counter+0 |
1260 clrf logbook_sample_counter+1 ; clear counting registers for next line | |
0 | 1261 |
1262 ; Vertical lines... | |
582 | 1263 movlw color_deepblue |
604 | 1264 call TFT_set_color |
582 | 1265 movlw profile_top+.1 |
1266 movwf win_top | |
1267 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile | |
604 | 1268 movwf win_leftx2 ; left border (0-159) |
582 | 1269 movlw profile_height_pixels |
1270 movwf win_height | |
1271 movlw profile_height_pixels | |
604 | 1272 movwf win_width ; "window" height |
1273 call half_horizontal_line ; inputs: win_top, win_leftx2, win_width, win_color1, win_color2 | |
0 | 1274 |
1275 profile_view_get_depth_no_line: | |
582 | 1276 call ext_flash_byte_read_plus_0x20 ; read depth first |
1277 movff ext_flash_rw,logbook_cur_depth+0 ; low value | |
1278 call ext_flash_byte_read_plus_0x20 ; read depth first | |
1279 movff ext_flash_rw,logbook_cur_depth+1 ; high value | |
1280 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte | |
604 | 1281 movff ext_flash_rw,gaslist_gas ; store Profile Flag Byte |
0 | 1282 |
582 | 1283 bcf event_occured ; clear flag |
1284 btfsc gaslist_gas,7 | |
604 | 1285 bsf event_occured ; we also have an event byte |
1286 bcf gaslist_gas,7 ; clear event byte flag (if any) | |
582 | 1287 ; gaslist_gas now holds the number of additional bytes to ignore (0-127) |
604 | 1288 movlw 0xFD ; end of profile bytes ? |
582 | 1289 cpfseq logbook_cur_depth+0 |
1290 bra profile_view_get_depth_new1 ; no 1st. 0xFD | |
1291 cpfseq logbook_cur_depth+1 | |
1292 bra profile_view_get_depth_new1 ; no 2nd. 0xFD | |
604 | 1293 bsf end_of_profile ; end found - set flag, skip remaining pixels |
0 | 1294 return |
1295 | |
1296 profile_view_get_depth_new1: | |
604 | 1297 btfsc event_occured ; was there an event attached to this sample? |
1298 rcall profile_view_get_depth_events ; YES - get information about this event(s) | |
582 | 1299 |
604 | 1300 ;---- read Tp°, if any AND divisor reached AND bytes available ----------- |
1301 movf divisor_temperature,W ; is Tp° divisor null ? | |
1302 bz profile_view_get_depth_no_tp ; YES - no Tp° curve | |
1303 decf count_temperature,F ; decrement tp° counter | |
1304 bnz profile_view_get_depth_no_tp ; no temperature this time | |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1305 |
582 | 1306 call ext_flash_byte_read_plus_0x20 ; Tp° low |
1307 decf gaslist_gas,F | |
1308 movff ext_flash_rw,logbook_cur_tp+0 | |
1309 call ext_flash_byte_read_plus_0x20 ; Tp° high | |
1310 decf gaslist_gas,F | |
1311 movff ext_flash_rw,logbook_cur_tp+1 | |
604 | 1312 movff divisor_temperature,count_temperature ; restart counter |
582 | 1313 |
1314 ; Compute Tp° max on the fly... | |
604 | 1315 movff logbook_cur_tp+0,sub_a+0 ; compare cur_tp > max_tp ? |
582 | 1316 movff logbook_cur_tp+1,sub_a+1 |
1317 movff logbook_max_tp+0,sub_b+0 | |
1318 movff logbook_max_tp+1,sub_b+1 | |
1319 call sub16 ; SIGNED sub_a - sub_b | |
1320 btfsc neg_flag | |
1321 bra profile_view_get_depth_no_tp | |
1322 | |
1323 ; store max. temp only below start_dive_threshold (1,0m) | |
604 | 1324 tstfsz logbook_cur_depth+1 ; > 2,56m ? |
1325 bra profile_view_compute_max_temp ; YES - include in max. temp measurement | |
582 | 1326 movlw start_dive_threshold ; 1,0m |
1327 cpfsgt logbook_cur_depth+0 ; low value | |
1328 bra profile_view_get_depth_no_tp ; above 1,0m, ignore temp | |
162
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1329 |
95d05cc14736
NEW: Safe tissue data, date and time during firmware update
heinrichsweikamp
parents:
124
diff
changeset
|
1330 profile_view_compute_max_temp: |
582 | 1331 movff logbook_cur_tp+0,logbook_max_tp+0 |
1332 movff logbook_cur_tp+1,logbook_max_tp+1 | |
1333 | |
604 | 1334 ;---- read deco, if any AND divisor=0 AND bytes available ---------------- |
0 | 1335 profile_view_get_depth_no_tp: |
582 | 1336 movf divisor_deco,W |
1337 bz profile_view_get_depth_no_deco | |
1338 decf count_deco,F | |
1339 bnz profile_view_get_depth_no_deco | |
0 | 1340 |
582 | 1341 call ext_flash_byte_read_plus_0x20 |
1342 decf gaslist_gas,F | |
1343 movff ext_flash_rw,logbook_ceiling | |
604 | 1344 movff divisor_deco,count_deco ; restart counter |
1345 call ext_flash_byte_read_plus_0x20 ; skip stop length | |
582 | 1346 decf gaslist_gas,F |
1347 | |
604 | 1348 ;---- read GF, if any AND divisor=0 AND bytes available ------------------ |
0 | 1349 profile_view_get_depth_no_deco: |
582 | 1350 ; Then skip remaining bytes... |
604 | 1351 movf gaslist_gas,W ; number of additional bytes to ignore (0-127) |
1352 tstfsz gaslist_gas ; anything to skip? | |
1353 call incf_ext_flash_address0_0x20 ; YES - increases bytes in ext_flash_address:3 with 0x200000 bank switching | |
0 | 1354 return |
1355 | |
168
1784ab9362ca
BUGFIX: False max. temp in Logbook, false Bailout and Gas 6 flags in logbook
heinrichsweikamp
parents:
167
diff
changeset
|
1356 profile_view_get_depth_events: |
604 | 1357 clrf EventByte2 ; clear EventByte2 |
1358 call ext_flash_byte_read_plus_0x20 ; read event byte | |
582 | 1359 movff ext_flash_rw,EventByte1 ; store EventByte1 |
604 | 1360 decf gaslist_gas,F ; reduce counter |
98 | 1361 |
604 | 1362 btfss EventByte1,7 ; another event byte? |
1363 bra profile_no_second_eventbyte ; NO | |
1364 call ext_flash_byte_read_plus_0x20 ; read EventByte2 | |
1365 movff ext_flash_rw,EventByte2 ; store EventByte2 | |
1366 decf gaslist_gas,F ; reduce counter | |
1367 bcf EventByte1,7 ; clear flag | |
98 | 1368 |
1369 profile_no_second_eventbyte: | |
582 | 1370 ; Check event flags in the EventBytes |
604 | 1371 btfsc EventByte1,4 ; manual gas changed? |
1372 rcall logbook_event1 ; YES | |
1373 btfsc EventByte1,5 ; stored gas changed? | |
1374 rcall logbook_event4 ; YES | |
1375 btfsc EventByte1,6 ; setpoint change? | |
1376 rcall logbook_event3 ; YES | |
1377 btfsc EventByte2,0 ; bailout? | |
1378 rcall logbook_event2 ; YES | |
582 | 1379 ; Any Alarm? |
604 | 1380 bcf EventByte1,4 ; clear bits already tested |
582 | 1381 bcf EventByte1,5 |
1382 bcf EventByte1,6 | |
1383 movlw .6 ; manual marker? | |
1384 cpfseq EventByte1 | |
604 | 1385 return ; NO - return |
1386 bsf log_marker_found ; manual marker, draw small yellow rectangle here | |
582 | 1387 return |
163
4d71549dcf6c
clarify diluent change in the documentation
heinrichsweikamp
parents:
162
diff
changeset
|
1388 |
604 | 1389 logbook_event4: ; stored gas changed |
1390 call ext_flash_byte_read_plus_0x20 ; read Gas# | |
1391 decf gaslist_gas,F ; reduce counter | |
582 | 1392 movff ext_flash_rw,backup_color1 |
604 | 1393 movff ext_flash_rw,WREG ; copy gas number to WREG for color-coding |
1394 call TFT_color_code_gas ; change profile color according to gas number | |
0 | 1395 return |
1396 | |
604 | 1397 logbook_event1: ; gas 6 used |
582 | 1398 bsf gas6_changed |
604 | 1399 movlw .6 ; use Gas6 color |
582 | 1400 movwf backup_color1 |
1401 call TFT_color_code_gas ; set profile color | |
604 | 1402 incf_ext_flash_address_0x20 .2 ; skip two bytes |
1403 decf gaslist_gas,F ; reduce counter | |
1404 decf gaslist_gas,F ; reduce counter | |
167 | 1405 return |
0 | 1406 |
604 | 1407 logbook_event2: ; bailout |
1408 bsf FLAG_bailout_mode ; set flag | |
1409 movff backup_color1,backup_color2 ; backup last gas color in case we return to CCR | |
1410 movlw .6 ; use Gas6 color | |
582 | 1411 movwf backup_color1 |
604 | 1412 call TFT_color_code_gas ; use Gas6 color |
1413 incf_ext_flash_address_0x20 .2 ; skip two bytes | |
1414 decf gaslist_gas,F ; reduce counter | |
1415 decf gaslist_gas,F ; reduce counter | |
167 | 1416 return |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1417 |
604 | 1418 logbook_event3: ; setpoint change |
1419 incf_ext_flash_address_0x20 .1 ; skip one byte | |
1420 decf gaslist_gas,F ; reduce counter | |
1421 btfss FLAG_bailout_mode ; are we in bailout? | |
1422 return ; NO - return | |
582 | 1423 ; We were in bailout before, restore profile color |
604 | 1424 movff backup_color2,backup_color1 ; restore color |
582 | 1425 movff backup_color2,WREG ; copy gas number to WREG for color-coding |
604 | 1426 call TFT_color_code_gas ; back to normal profile color |
582 | 1427 return |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1428 |
604 | 1429 ; ------------------------------------------------------------------------ |
1430 | |
0 | 1431 exit_profileview: |
582 | 1432 ; call speed_fastest |
1433 bcf sleepmode | |
604 | 1434 clrf gaslist_gas ; restore all registers to build same page again |
582 | 1435 movff logbook_divenumber_temp,logbook_divenumber |
1436 movff logbook_max_dive_counter_temp,logbook_max_dive_counter | |
1437 movff logbook_temp_backup,logbook_temp | |
1438 incf logbook_max_dive_counter,F | |
1439 decf logbook_divenumber,F | |
1440 bcf all_dives_shown | |
1441 clrf menupos3 ; here: used row on current page | |
1442 movlw logbook_row_number | |
1443 movwf menupos1 ; here: active row on current page | |
1444 ; call TFT_DisplayOff | |
1445 call TFT_boot | |
1446 clrf CCP1CON ; stop PWM | |
604 | 1447 bcf PORTC,2 ; pull PWM out to GND |
582 | 1448 call TFT_boot |
1449 ; call TFT_ClearScreen ; clear details/profile | |
1450 goto logbook2 ; start search | |
0 | 1451 |
1452 next_logbook2: | |
582 | 1453 btfsc all_dives_shown ; all shown |
1454 goto logbook ; all reset | |
1455 clrf menupos3 | |
1456 movlw logbook_row_number | |
1457 movwf menupos1 | |
1458 incf logbook_page_number,F ; start new screen | |
604 | 1459 bsf keep_cursor_new_page ; keep cursor on "next page" |
582 | 1460 clrf CCP1CON ; stop PWM |
604 | 1461 bcf PORTC,2 ; pull PWM out to GND |
582 | 1462 call TFT_boot |
1463 ; call TFT_ClearScreen | |
1464 goto logbook2 ; start search | |
0 | 1465 |
1466 next_logbook3: | |
582 | 1467 incf menupos1,F ; +1 |
1468 movlw logbook_row_number+.2 | |
604 | 1469 cpfsgt menupos1 ; = logbook_row_number+.3 ? |
1470 bra next_logbook3a ; NO | |
582 | 1471 movlw .1 |
1472 movwf menupos1 | |
1473 bra next_logbook3b | |
0 | 1474 |
1475 next_logbook3a: | |
582 | 1476 incf menupos3,W ; last entry in current page +1 |
1477 cpfseq menupos1 ; same as cursor pos.? | |
604 | 1478 bra next_logbook3b ; NO |
1479 movlw logbook_row_number+.1 ; YES - | |
1480 movwf menupos1 ; - jump directly to "next page" if page is not full | |
0 | 1481 |
582 | 1482 movlw logbook_row_number |
604 | 1483 cpfseq menupos3 ; last dive was row logbook_row_number? |
1484 bsf all_dives_shown ; NO - set flag to load first page again (full reset) | |
0 | 1485 |
1486 next_logbook3b: | |
582 | 1487 clrf timeout_counter2 |
1488 call TFT_logbook_cursor | |
1489 bcf switch_left | |
1490 goto logbook_loop | |
0 | 1491 |
1492 display_listdive: | |
604 | 1493 bsf logbook_page_not_empty ; page not empty |
582 | 1494 incf menupos3,F |
1495 | |
1496 bsf leftbind | |
1497 WIN_FONT FT_SMALL | |
1498 WIN_LEFT logbook_list_left | |
0 | 1499 |
582 | 1500 decf menupos3,W ; -1 into wreg |
1501 mullw logbook_row_offset | |
1502 movff PRODL,win_top | |
0 | 1503 |
582 | 1504 lfsr FSR2,buffer |
604 | 1505 call do_logoffset_common_read ; read into lo:hi |
1506 tstfsz lo ; lo = 0 ? | |
1507 bra display_listdive1 ; NO - adjust offset | |
1508 tstfsz hi ; hi = 0 ? | |
1509 bra display_listdive1 ; NO - adjust offset | |
1510 bra display_listdive1b ; display now | |
392
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1511 |
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1512 display_listdive1: |
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1513 ; Check limit (lo:hi must be <1000) |
604 | 1514 movlw LOW d'1000' ; compare to 1000 |
582 | 1515 subwf lo,W |
1516 movlw HIGH d'1000' | |
1517 subwfb hi,W | |
1518 bc display_listdive1b ; carry = no-borrow = > 1000, skip! | |
392
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1519 |
582 | 1520 infsnz lo,F |
1521 incf hi,F ; hi:lo = hi:lo + 1 | |
1522 movff lo,sub_a+0 | |
1523 movff hi,sub_a+1 | |
1524 movff logbook_divenumber,sub_b+0 | |
1525 clrf sub_b+1 | |
1526 call subU16 ; sub_c = sub_a - sub_b | |
1527 movff sub_c+0,lo | |
1528 movff sub_c+1,hi | |
1529 bra display_listdive1a | |
392
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1530 |
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1531 display_listdive1b: |
582 | 1532 clrf hi |
1533 movff logbook_divenumber,lo ; lo=0 and hi=0 -> show without applied offset | |
392
32780516c8c6
NEW: Show actual dive count in logbook list view (If <1000)
heinrichsweikamp
parents:
389
diff
changeset
|
1534 display_listdive1a: |
582 | 1535 output_16_3 ; displays only last three figures from a 16Bit value (0-999), # of dive |
1536 PUTC ' ' | |
1537 ;display_listdive2: | |
604 | 1538 LOG_POINT_TO log_date+1 ; point to month |
582 | 1539 call ext_flash_byte_read_plus ; read month |
604 | 1540 movff ext_flash_rw,hi ; month |
582 | 1541 call ext_flash_byte_read_plus ; read day |
604 | 1542 movff ext_flash_rw,lo ; day |
582 | 1543 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer |
0 | 1544 PUTC ' ' |
1545 | |
604 | 1546 LOG_POINT_TO log_max_depth ; point to max. depth |
1547 call ext_flash_byte_read_plus ; max. depth | |
582 | 1548 movff ext_flash_rw,lo |
1549 call ext_flash_byte_read_plus | |
1550 movff ext_flash_rw,hi | |
0 | 1551 |
582 | 1552 TSTOSS opt_units ; 0=Meters, 1=Feets |
1553 bra display_listdive2_metric | |
1554 ;display_listdive2_imperial: | |
1555 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
0 | 1556 PUTC ' ' |
582 | 1557 bcf leftbind |
1558 output_16_3 ; limit to 999 and display only (0-999) | |
0 | 1559 STRCAT_TEXT tFeets1 |
582 | 1560 bra display_listdive3 |
0 | 1561 |
1562 display_listdive2_metric: | |
582 | 1563 bsf ignore_digit5 ; no cm... |
1564 movlw d'1' ; +1 | |
1565 movff WREG,ignore_digits ; no 1000m | |
1566 bcf leftbind | |
1567 output_16dp .3 ; xxx.y | |
0 | 1568 STRCAT_TEXT tMeters |
1569 PUTC ' ' | |
1570 | |
1571 display_listdive3: | |
582 | 1572 call ext_flash_byte_read_plus |
1573 movff ext_flash_rw,lo ; read divetime minutes | |
1574 call ext_flash_byte_read_plus | |
1575 movff ext_flash_rw,hi | |
604 | 1576 output_16_3 ; divetime minutes (0-999min) |
582 | 1577 STRCAT_TEXT tMinutes |
1578 clrf WREG | |
1579 movff WREG,buffer+.21 ; limit to 21 chars | |
604 | 1580 STRCAT_PRINT "" ; display header-row in list |
0 | 1581 return |
1582 | |
604 | 1583 ; ------------------------------------------------------------------ |
1584 | |
0 | 1585 logbook_show_divenumber: |
604 | 1586 call do_logoffset_common_read ; read into lo:hi |
1587 tstfsz lo ; lo = 0 ? | |
1588 bra logbook_show_divenumber2 ; NO - adjust offset | |
1589 tstfsz hi ; hi = 0 ? | |
1590 bra logbook_show_divenumber2 ; NO - adjust offset | |
1591 movff divenumber,lo ; lo = 0 and hi = 0 -> skip offset routine | |
1592 bra logbook_show_divenumber3 ; display now | |
0 | 1593 |
1594 logbook_show_divenumber2: | |
582 | 1595 infsnz lo,F |
1596 incf hi,F ; hi:lo = hi:lo + 1 | |
1597 movff lo,sub_a+0 | |
1598 movff hi,sub_a+1 | |
1599 movff divenumber,sub_b+0 | |
1600 clrf sub_b+1 | |
1601 call subU16 ; sub_c = sub_a - sub_b | |
1602 movff sub_c+0,lo | |
1603 movff sub_c+1,hi | |
0 | 1604 |
1605 logbook_show_divenumber3: | |
1606 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row | |
582 | 1607 bsf leftbind |
1608 output_16 ; # of dive in logbook | |
1609 bcf leftbind | |
560 | 1610 STRCAT_PRINT "" |
582 | 1611 return |
0 | 1612 |
604 | 1613 ; ------------------------------------------------------------------- |
0 | 1614 |
604 | 1615 logbook_page2: ; show more info |
1616 rcall log_details_header ; shows number, time/date and basic dive info | |
582 | 1617 |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1618 ; Deco model |
582 | 1619 WIN_SMALL .5,.65 |
1620 LOG_POINT_TO log_decomodel | |
1621 call ext_flash_byte_read_plus ; read deco model | |
1622 movff ext_flash_rw,lo | |
1623 decfsz ext_flash_rw,F | |
1624 bra logbook_decomodel1 | |
1625 ; Deco model GF Version | |
1626 STRCAT_PRINT "ZHL-16+GF" | |
1627 LOG_POINT_TO log_gf_lo | |
1628 WIN_SMALL .5,.90 | |
1629 STRCPY_TEXT tGF | |
604 | 1630 call ext_flash_byte_read_plus ; read GF lo |
582 | 1631 movff ext_flash_rw,lo |
1632 output_8 | |
1633 STRCAT "%/" | |
1634 bra logbook_decomodel_common | |
0 | 1635 logbook_decomodel1: |
582 | 1636 ; Deco model NON-GF Version |
1637 STRCAT_PRINT "ZH-L16" | |
1638 LOG_POINT_TO log_sat_mult | |
1639 WIN_SMALL .5,.90 | |
604 | 1640 call ext_flash_byte_read_plus ; read sat_mult |
582 | 1641 movff ext_flash_rw,lo |
1642 output_8 | |
1643 STRCAT "%/" | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1644 logbook_decomodel_common: |
604 | 1645 call ext_flash_byte_read_plus ; read desat_mult or GF_hi |
582 | 1646 movff ext_flash_rw,lo |
1647 output_8 | |
1648 STRCAT_PRINT "%" | |
0 | 1649 |
582 | 1650 ; CNS |
1651 LOG_POINT_TO log_cns_start | |
1652 WIN_SMALL .5,.115 | |
1653 STRCPY_TEXT tCNS2 | |
1654 call ext_flash_byte_read_plus ; read cns low | |
1655 movff ext_flash_rw,lo | |
1656 call ext_flash_byte_read_plus ; read cns high | |
1657 movff ext_flash_rw,hi | |
604 | 1658 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) |
1659 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) | |
582 | 1660 output_16 |
1661 LOG_POINT_TO log_cns_end | |
1662 STRCAT "->" | |
1663 call ext_flash_byte_read_plus ; read CNS low | |
1664 movff ext_flash_rw,lo | |
1665 call ext_flash_byte_read_plus ; read CNS high | |
1666 movff ext_flash_rw,hi | |
604 | 1667 bcf hi,int_warning_flag ; clear warning flag (fix for cases were the flags already got stored to EEPROM) |
1668 bcf hi,int_attention_flag ; clear attention flag (fix for cases were the flags already got stored to EEPROM) | |
582 | 1669 output_16 |
1670 STRCAT_PRINT "%" | |
1671 | |
1672 ; Salinity | |
1673 WIN_SMALL .5,.140 | |
1674 LOG_POINT_TO log_salinity | |
1675 STRCPY_TEXT tDvSalinity | |
1676 bsf leftbind | |
1677 call ext_flash_byte_read_plus ; read salinity | |
1678 movff ext_flash_rw,lo | |
1679 movff ext_flash_rw,backup_divedata ; backup for average depth display | |
1680 output_8 | |
1681 STRCAT_PRINT "%" | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1682 |
582 | 1683 ; Average depth |
1684 WIN_SMALL .5,.165 | |
1685 STRCPY_TEXT tAVG | |
1686 LOG_POINT_TO log_avr_depth | |
1687 call ext_flash_byte_read_plus ; read avr low | |
1688 movff ext_flash_rw,lo | |
1689 call ext_flash_byte_read_plus ; read avr high | |
1690 movff ext_flash_rw,hi | |
1691 movf backup_divedata,W ; salinity for this dive | |
1692 call adjust_depth_with_salinity_log ; computes salinity setting (FROM WREG!) into lo:hi [mbar] | |
1693 output_16dp .3 | |
1694 STRCAT_PRINT "m" | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1695 |
582 | 1696 ; Last deco |
1697 LOG_POINT_TO log_last_stop | |
1698 WIN_SMALL .5,.190 | |
604 | 1699 STRCPY_TEXT tLastDecostopSurf |
1700 call ext_flash_byte_read_plus ; read last stop | |
582 | 1701 movff ext_flash_rw,lo |
1702 output_8 | |
1703 STRCAT_PRINT "m" | |
1704 | |
1705 movlw color_lightblue | |
1706 call TFT_set_color | |
1707 WIN_FRAME_COLOR16 .63,.220,.2,.105 ; Top, Bottom, Left, Right | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1708 |
582 | 1709 ; Firmware |
620 | 1710 call TFT_standard_color |
1711 WIN_SMALL .110,.65 | |
1712 STRCAT "V:" | |
1713 LOG_POINT_TO log_firmware | |
1714 call ext_flash_byte_read_plus ; read firmware major number | |
1715 movf ext_flash_rw,W ; copy to WREG | |
1716 movwf hi ; copy from WREG to hi | |
1717 movwf lo ; copy from WREG to lo, too | |
1718 bsf leftbind ; print left-aligned | |
1719 output_8 ; print major number | |
1720 PUTC "." ; print "." | |
1721 call ext_flash_byte_read_plus ; read firmware minor number | |
1722 movff ext_flash_rw,lo ; store in lo | |
1723 output_99x ; print minor version in 2 digit format | |
1724 STRCAT_PRINT "" ; finalize output | |
1725 | |
1726 movf hi,W ; get major into WREG | |
1727 xorlw .3 ; major == 3 ? | |
1728 bz logbook_battery_percent ; YES - show battery % | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1729 |
620 | 1730 movf hi,W ; get major into WREG (again) |
1731 xorlw .2 ; major == 2 ? | |
1732 bnz logbook_battery_voltage ; NO - skip battery % | |
1733 movlw .14 ; YES - check minor version | |
1734 cpfsgt lo ; - minor > 14 ? | |
1735 bra logbook_battery_voltage ; NO - skip battery % | |
1736 ;bra logbook_battery_percent ; YES - show battery % | |
582 | 1737 |
620 | 1738 ; Battery % |
1739 logbook_battery_percent: | |
1740 WIN_SMALL .110,.140 ; show battery percent | |
1741 LOG_POINT_TO log_batt_info ; address battery percent | |
1742 call ext_flash_byte_read_plus ; read battery percent | |
1743 movff ext_flash_rw,lo ; copy battery percent to lo | |
1744 output_8 ; print battery percent | |
1745 STRCAT_PRINT "%" ; print "%" and finalize output | |
496
a0247e9f71d0
show battery % in logbook (For dives made with 2.15 or newer)
heinrichsweikamp
parents:
495
diff
changeset
|
1746 |
620 | 1747 ; Battery Voltage |
1748 logbook_battery_voltage: | |
582 | 1749 WIN_SMALL .110,.90 |
1750 STRCAT_PRINT "Batt:" | |
1751 WIN_SMALL .110,.115 | |
604 | 1752 LOG_POINT_TO log_battery ; battery voltage |
582 | 1753 call ext_flash_byte_read_plus ; read battery low |
1754 movff ext_flash_rw,lo | |
1755 call ext_flash_byte_read_plus ; read battery high | |
1756 movff ext_flash_rw,hi | |
1757 output_16dp .2 | |
1758 STRCAT_PRINT "V" | |
496
a0247e9f71d0
show battery % in logbook (For dives made with 2.15 or newer)
heinrichsweikamp
parents:
495
diff
changeset
|
1759 |
582 | 1760 ; surface pressure in mbar |
1761 LOG_POINT_TO log_surface_press | |
1762 call ext_flash_byte_read_plus ; read surface pressure | |
1763 movff ext_flash_rw,lo | |
1764 call ext_flash_byte_read_plus ; read surface pressure | |
1765 movff ext_flash_rw,hi | |
1766 WIN_SMALL .110,.165 | |
1767 lfsr FSR2,buffer | |
1768 bsf leftbind | |
604 | 1769 output_16 ; air pressure before dive |
582 | 1770 STRCAT_TEXT tMBAR |
1771 clrf WREG | |
1772 movff WREG,buffer+7 ; limit to 7 chars | |
1773 STRCAT_PRINT "" | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1774 |
582 | 1775 movlw color_greenish |
1776 call TFT_set_color | |
1777 WIN_FRAME_COLOR16 .63,.220,.107,.159 ; Top, Bottom, Left, Right | |
1778 | |
604 | 1779 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
582 | 1780 display_details_loop: |
1781 btfsc switch_right | |
604 | 1782 bra logbook_page3 ; details, 2nd page |
582 | 1783 btfsc switch_left |
1784 bra exit_profileview ; back to list | |
604 | 1785 rcall log_screendump_and_onesecond ; check if we need to make a screenshot and check for new second |
1786 btfsc sleepmode ; timeout? | |
582 | 1787 bra exit_profileview ; back to list |
1788 bra display_details_loop ; wait for something to do | |
490
8dfb93e80338
NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents:
437
diff
changeset
|
1789 |
582 | 1790 global logbook_preloop_tasks |
1791 logbook_preloop_tasks: | |
604 | 1792 movlw CCP1CON_VALUE ; see hwos.inc |
1793 movwf CCP1CON ; power-on backlight | |
582 | 1794 call TFT_standard_color |
1795 bcf sleepmode ; clear some flags | |
1796 bcf switch_right | |
1797 bcf switch_left | |
1798 clrf timeout_counter2 | |
1799 goto speed_normal ; and return | |
1800 | |
1801 | |
604 | 1802 logbook_page3: ; show even more info |
1803 rcall log_details_header ; shows number, time/date and basic dive info | |
582 | 1804 LOG_POINT_TO log_gas1 |
1805 bcf log_show_gas_short ; do the long version of log_show_gas | |
1806 bcf leftbind | |
0 | 1807 |
582 | 1808 WIN_SMALL .5,.90 |
604 | 1809 movlw .1 ; color for gas 1 |
582 | 1810 rcall log_show_gas |
1811 | |
1812 WIN_SMALL .5,.115 | |
604 | 1813 movlw .2 ; color for gas 2 |
582 | 1814 rcall log_show_gas |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1815 |
582 | 1816 WIN_SMALL .5,.140 |
604 | 1817 movlw .3 ; color for gas 3 |
582 | 1818 rcall log_show_gas |
1819 | |
1820 WIN_SMALL .5,.165 | |
604 | 1821 movlw .4 ; color for gas 4 |
582 | 1822 rcall log_show_gas |
1823 | |
1824 WIN_SMALL .5,.190 | |
604 | 1825 movlw .5 ; color for gas 5 |
582 | 1826 rcall log_show_gas |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1827 |
582 | 1828 ; OC/CC Gas List |
1829 WIN_SMALL .5,.65 | |
1830 WIN_COLOR color_greenish | |
1831 LOG_POINT_TO log_divemode | |
1832 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into ext_flash_rw | |
1833 decfsz ext_flash_rw,w ; =1 (CC)? | |
1834 bra logbook_page3a | |
1835 STRCPY_TEXT_PRINT tGaslistCC | |
1836 bra logbook_page3b | |
560 | 1837 logbook_page3a: |
582 | 1838 STRCPY_TEXT_PRINT tGaslist |
560 | 1839 logbook_page3b: |
582 | 1840 movlw color_lightblue |
1841 call TFT_set_color | |
604 | 1842 WIN_FRAME_COLOR16 .63,.220,.2,.90+.24 ; Top, Bottom, Left, Right (added .24 to the right as extra space needed for gas typ markings) |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1843 |
604 | 1844 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1845 display_details2_loop: |
582 | 1846 btfsc switch_right |
604 | 1847 goto logbook_page4 ; show more info |
582 | 1848 btfsc switch_left |
1849 bra exit_profileview ; back to list | |
604 | 1850 rcall log_screendump_and_onesecond ; check if we need to make a screen shot and check for new second |
1851 btfsc sleepmode ; timeout? | |
582 | 1852 bra exit_profileview ; back to list |
1853 bra display_details2_loop ; wait for something to do | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1854 |
604 | 1855 logbook_page4: ; show even more info in CC mode |
582 | 1856 LOG_POINT_TO log_divemode |
1857 call ext_flash_byte_read ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into WREG and ext_flash_rw | |
1858 decfsz ext_flash_rw,w ; =1 (CC)? | |
1859 goto display_profile2 ; no | |
530 | 1860 |
604 | 1861 rcall log_details_header ; shows number, time/date and basic dive info |
582 | 1862 ; Setpoint list |
1863 LOG_POINT_TO log_sp1 | |
1864 WIN_SMALL .5,.65 | |
1865 WIN_COLOR color_greenish | |
1866 STRCPY_TEXT_PRINT tFixedSetpoints | |
1867 call TFT_standard_color | |
1868 WIN_SMALL .5,.90 | |
1869 rcall log_show_sp | |
1870 WIN_SMALL .5,.115 | |
1871 rcall log_show_sp | |
1872 WIN_SMALL .5,.140 | |
1873 rcall log_show_sp | |
1874 WIN_SMALL .5,.165 | |
1875 rcall log_show_sp | |
1876 WIN_SMALL .5,.190 | |
1877 rcall log_show_sp | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1878 |
582 | 1879 movlw color_greenish |
1880 call TFT_set_color | |
1881 WIN_FRAME_COLOR16 .63,.220,.2,.112 ; Top, Bottom, Left, Right | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1882 |
604 | 1883 rcall logbook_preloop_tasks ; clear some flags and set to Speed_eco |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1884 display_details3_loop: |
582 | 1885 btfsc switch_right |
604 | 1886 goto display_profile2 ; show the profile view again |
582 | 1887 btfsc switch_left |
1888 bra exit_profileview ; back to list | |
604 | 1889 rcall log_screendump_and_onesecond ; check if we need to make a screenshot and check for new second |
1890 btfsc sleepmode ; timeout? | |
582 | 1891 bra exit_profileview ; back to list |
1892 bra display_details3_loop ; wait for something to do | |
0 | 1893 |
582 | 1894 |
1895 log_details_header: | |
1896 clrf CCP1CON ; stop PWM | |
1897 bcf PORTC,2 ; Pull PWM out to GND | |
1898 call TFT_boot | |
604 | 1899 ; call TFT_ClearScreen ; clear screen |
582 | 1900 |
1901 ; Set ext_flash pointer to "#divenumber-oldest" dive | |
1902 ; compute read_int_eeprom .2 - divenumber | |
604 | 1903 ; read required header data for profile display |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1904 ; look in header for pointer to begin of diveprofile (Byte 2-4) |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1905 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1906 |
582 | 1907 decf divenumber,F ;-1 |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1908 read_int_eeprom .2 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1909 movf EEDATA,W |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1910 bcf STATUS,C |
604 | 1911 subfwb divenumber,W ; max. dives (low value) - dive number |
582 | 1912 movwf lo ; result |
604 | 1913 incf divenumber,F ; +1 |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1914 ; Set ext_flash_address:3 to TOC entry of this dive |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1915 ; 1st: 200000h-200FFFh -> lo=0 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1916 ; 2nd: 201000h-201FFFh -> lo=1 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1917 ; 3rd: 202000h-202FFFh -> lo=2 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1918 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) |
582 | 1919 clrf ext_flash_address+0 |
1920 clrf ext_flash_address+1 | |
1921 movlw 0x20 | |
1922 movwf ext_flash_address+2 | |
1923 movlw .16 | |
1924 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
1925 movf PRODL,W | |
1926 addwf ext_flash_address+1,F | |
1927 movf PRODH,W | |
1928 addwfc ext_flash_address+2,F | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1929 ; pointer at the first 0xFA of header |
582 | 1930 rcall logbook_show_divenumber ; show the dive number in medium font |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1931 ; Show date and time in first row |
582 | 1932 WIN_SMALL .59,.10 |
1933 LOG_POINT_TO log_date | |
1934 call ext_flash_byte_read_plus | |
1935 movff ext_flash_rw,up ; year | |
1936 call ext_flash_byte_read_plus | |
1937 movff ext_flash_rw,hi ; month | |
1938 call ext_flash_byte_read_plus | |
1939 movff ext_flash_rw,lo ; day | |
1940 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
1941 PUTC "-" | |
1942 call ext_flash_byte_read_plus ; hour | |
1943 movff ext_flash_rw,lo | |
1944 call ext_flash_byte_read_plus ; minutes | |
1945 movff ext_flash_rw,hi | |
1946 output_99x ; hour | |
1947 PUTC ':' | |
1948 movff hi,lo | |
1949 output_99x ; minute | |
1950 STRCAT_PRINT "" ; display 1st row of details | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1951 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1952 ; Show max depth and dive time |
582 | 1953 WIN_SMALL .5,.35 |
1954 STRCAT "Max:" | |
1955 LOG_POINT_TO log_max_depth | |
1956 call ext_flash_byte_read_plus ; read max depth | |
1957 movff ext_flash_rw,lo | |
1958 call ext_flash_byte_read_plus ; read max depth | |
1959 movff ext_flash_rw,hi | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1960 |
582 | 1961 TSTOSS opt_units ; 0=Meters, 1=Feets |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1962 bra logbook_page2_depth_metric |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1963 ; imperial |
582 | 1964 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1965 PUTC ' ' |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1966 bcf leftbind |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1967 output_16_3 |
582 | 1968 STRCAT_TEXT tFeets |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1969 bra logbook_page2_depth_common |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1970 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1971 logbook_page2_depth_metric: |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1972 bsf leftbind |
582 | 1973 output_16dp d'3' ; max. depth |
1974 STRCAT_TEXT tMeters | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1975 |
582 | 1976 logbook_page2_depth_common: |
1977 STRCAT " - " | |
1978 call ext_flash_byte_read_plus ; divetime in minutes | |
1979 movff ext_flash_rw,lo | |
1980 call ext_flash_byte_read_plus | |
1981 movff ext_flash_rw,hi ; divetime in minutes | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1982 |
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1983 bsf leftbind |
582 | 1984 output_16 ; divetime minutes |
1985 PUTC "m" | |
1986 LOG_POINT_TO log_divetime+.2 | |
1987 call ext_flash_byte_read_plus ; read divetime seconds | |
1988 movff ext_flash_rw,lo | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1989 bsf leftbind |
582 | 1990 output_99x ; divetime seconds |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1991 call TFT_standard_color |
582 | 1992 STRCAT_PRINT "s" |
1993 ; ; Dive mode | |
1994 ; LOG_POINT_TO log_divemode | |
604 | 1995 ; call ext_flash_byte_read_plus ; read divemode |
582 | 1996 ; movff ext_flash_rw,lo |
1997 ; call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) | |
500
989917fe2d9f
Battery % in logbook when updated from Sport to Tech
heinrichsweikamp
parents:
496
diff
changeset
|
1998 return |
582 | 1999 |
604 | 2000 ; ---------------------------------------------------------------- |
582 | 2001 |
2002 log_show_sp: | |
2003 lfsr FSR2,buffer | |
604 | 2004 call ext_flash_byte_read_plus ; read setpoint |
582 | 2005 movff ext_flash_rw,lo |
2006 clrf hi | |
2007 bsf leftbind | |
2008 output_16dp d'3' | |
2009 bcf leftbind | |
2010 STRCAT_TEXT tbar | |
2011 PUTC " " | |
2012 call ext_flash_byte_read_plus ; change depth | |
2013 movff ext_flash_rw,lo | |
0 | 2014 |
582 | 2015 TSTOSS opt_units ; 0=Meter, 1=Feet |
2016 bra log_show_sp_metric | |
2017 movf lo,W | |
2018 mullw .100 ; convert meters to mbar | |
2019 movff PRODL,lo | |
2020 movff PRODH,hi | |
2021 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
604 | 2022 output_16_3 |
2023 PUTC " " | |
582 | 2024 STRCAT_TEXT tFeets ; "ft" |
2025 bra log_show_sp_common | |
2026 log_show_sp_metric: | |
2027 output_8 | |
604 | 2028 PUTC " " |
582 | 2029 STRCAT_TEXT tMeters ; "m" |
2030 log_show_sp_common: | |
2031 STRCAT_PRINT "" | |
2032 return | |
2033 | |
0 | 2034 |
582 | 2035 log_show_gas: ; show gas data |
2036 call TFT_color_code_gas ; color the output (gas number is in WREG) | |
2037 lfsr FSR2,buffer | |
2038 call ext_flash_byte_read_plus ; read gas O2 fraction | |
2039 movff ext_flash_rw,lo | |
2040 call ext_flash_byte_read_plus ; read gas He fraction | |
2041 movff ext_flash_rw,hi | |
2042 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
2043 call ext_flash_byte_read_plus ; read change depth | |
604 | 2044 movff ext_flash_rw,up |
2045 call ext_flash_byte_read_plus ; read gas type - just to increment the pointer | |
2046 movff ext_flash_rw,ex | |
0 | 2047 |
582 | 2048 btfsc log_show_gas_short ; shall we do the short version? |
2049 bra log_show_gas_common ; YES | |
604 | 2050 ; NO - do the long version |
2051 PUTC " " ; put one space between gas composition and gas type marking | |
2052 tstfsz ex ; gas disabled? | |
2053 bra log_show_gas_1 ; NO - next check | |
2054 PUTC "x" ; YES - mark with "x" | |
2055 bra log_show_gas_4 ; - continue with change depth | |
2056 log_show_gas_1: | |
2057 decfsz ex,F ; now: -1 disabled, 0 first, 1 travel, 2 deco -> first? | |
2058 bra log_show_gas_2 ; NO - next check | |
2059 PUTC "*" ; YES - mark with "*" | |
2060 bra log_show_gas_4 ; - continue with change depth | |
2061 log_show_gas_2: | |
2062 decf ex,F ; now: -2 disabled, -1 first, 0 travel, 1 deco | |
2063 decfsz ex,F ; now: -3 disabled, -2 first, -1 travel, 0 deco -> deco? | |
2064 bra log_show_gas_3 ; NO - nothing to mark | |
2065 PUTC "=" ; YES - mark with "=" | |
2066 bra log_show_gas_4 ; - continue with change depth | |
2067 log_show_gas_3: | |
2068 PUTC " " ; print a space in absence of any other marking | |
2069 log_show_gas_4: | |
2070 PUTC " " ; put one space between gas type marking and change depth | |
582 | 2071 TSTOSS opt_units ; 0=Meter, 1=Feet |
2072 bra log_show_gas_metric | |
604 | 2073 movf up,W |
582 | 2074 mullw .100 ; convert meters to mbar |
2075 movff PRODL,lo | |
2076 movff PRODH,hi | |
2077 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
604 | 2078 output_16_3 ; limit to 999 and display only 0-999 |
582 | 2079 STRCAT_TEXT tFeets ; "ft" |
2080 bra log_show_gas_common | |
2081 log_show_gas_metric: | |
604 | 2082 movff up,lo |
582 | 2083 output_8 |
2084 STRCAT_TEXT tMeters ; "m" | |
2085 log_show_gas_common: | |
2086 STRCAT_PRINT "" | |
2087 return | |
0 | 2088 |
604 | 2089 ; ---------------------------------------------------------------- |
2090 | |
0 | 2091 END |