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