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