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