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