Mercurial > public > hwos_code
annotate src/logbook.asm @ 147:fdd4e30846ae
some cleanup
author | heinrichsweikamp |
---|---|
date | Wed, 06 Aug 2014 11:59:04 +0200 |
parents | 40ff64d60054 |
children | 95d05cc14736 |
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 LOG_POINT_TO log_date | |
440 call ext_flash_byte_read_plus | |
441 movff temp1,convert_value_temp+2 ; Year | |
442 call ext_flash_byte_read_plus | |
443 movff temp1,convert_value_temp+0 ; Month | |
444 call ext_flash_byte_read_plus | |
445 movff temp1,convert_value_temp+1 ; Day | |
446 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | |
447 STRCAT_PRINT "" | |
448 | |
449 WIN_SMALL logbook_time_column, logbook_time_row | |
450 call ext_flash_byte_read_plus ; hour | |
451 movff temp1,lo | |
452 call ext_flash_byte_read_plus ; Minutes | |
453 movf lo,W | |
454 mullw .60 | |
455 movff temp1,WREG | |
456 addwf PRODL,F | |
457 movlw .0 | |
458 addwfc PRODH,F ; PRODH:PRODL has end-of-dive time in minutes | |
459 | |
460 LOG_POINT_TO log_total_seconds | |
461 call ext_flash_byte_read_plus ; Total sample time in seconds | |
462 movff temp1,lo | |
463 call ext_flash_byte_read_plus ; Total sample time in seconds | |
464 movff temp1,hi | |
465 call convert_time ; converts hi:lo in seconds to mins (hi) and seconds (lo) | |
466 clrf sub_b+1 | |
467 movff hi,sub_b+0 | |
468 movff PRODL,sub_a+0 | |
469 movff PRODH,sub_a+1 | |
470 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | |
471 ; sub_c:2 holds entry time in minutes | |
472 movff sub_c+0,lo | |
473 movff sub_c+1,hi | |
474 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) | |
475 movff lo,PRODL ; temp | |
476 movff hi,lo | |
477 output_99x ; hour | |
478 PUTC ':' | |
479 movff PRODL,lo | |
480 output_99x ; minute | |
481 STRCAT_PRINT "" ; Display 1st row of details | |
482 | |
483 LOG_POINT_TO log_max_depth | |
484 call ext_flash_byte_read_plus ; read max depth | |
485 movff temp1,lo | |
486 call ext_flash_byte_read_plus ; read max depth | |
487 movff temp1,hi | |
488 movff lo,xA+0 ; calculate y-scale for profile display | |
489 movff hi,xA+1 | |
490 movlw profile_height_pixels ; pixel height available for profile | |
491 movwf xB+0 | |
492 clrf xB+1 | |
493 call div16x16 ; does xA/xB=xC | |
494 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!) | |
495 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!) | |
496 incf y_scale+0,F ; increase one, because there may be a remainder | |
497 movlw d'0' | |
498 addwfc y_scale+1,F | |
499 | |
500 movlw LOW ((profile_height_pixels+1)*.1000) | |
501 movwf xC+0 | |
502 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF') | |
503 movwf xC+1 | |
504 movlw UPPER ((profile_height_pixels+1)*.1000) | |
505 movwf xC+2 | |
506 clrf xC+3 | |
507 | |
508 movff lo,xB+0 ; Max. Depth in mbar | |
509 movff hi,xB+1 ; Max. Depth in mbar | |
510 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
511 | |
512 movff xC+0,x_scale+0 ; | |
513 movff xC+1,x_scale+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line) | |
514 | |
515 movf x_scale+0,W | |
516 iorwf x_scale+1,W ; x_scale:2 = Null? | |
517 bnz display_profile_offset4 ; No, continue | |
518 incf x_scale+1,F ; Yes, make x_scale+1>1 to make "display_profile2e" working | |
519 | |
520 display_profile_offset4: | |
521 WIN_SMALL log_max_value_column,log_max_value_row | |
522 | |
523 TSTOSS opt_units ; 0=Meters, 1=Feets | |
524 bra display_profile_offset4_metric | |
525 ;display_profile_offset4_imperial: | |
526 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
527 PUTC ' ' | |
25 | 528 bcf leftbind |
529 output_16_3 | |
0 | 530 STRCAT_TEXT_PRINT tFeets |
531 bra display_profile_offset4_common | |
532 | |
533 display_profile_offset4_metric: | |
534 bsf leftbind | |
535 output_16dp d'3' ; max. depth | |
536 STRCAT_TEXT_PRINT tMeters | |
537 | |
538 display_profile_offset4_common: | |
539 call ext_flash_byte_read_plus ; divetime in minutes | |
540 movff temp1,lo | |
541 call ext_flash_byte_read_plus | |
542 movff temp1,hi ; divetime in minutes | |
543 | |
544 movff lo,xA+0 ; calculate x-scale for profile display | |
545 movff hi,xA+1 ; calculate total diveseconds first | |
546 movlw d'60' ; 60seconds are one minute... | |
547 movwf xB+0 | |
548 clrf xB+1 | |
549 call mult16x16 ; result is in xC:2 ! | |
550 | |
551 WIN_SMALL log_divetime_value_column,log_divetime_value_row | |
552 bsf leftbind | |
553 output_16 ; divetime minutes | |
554 movlw LOW d'600' | |
555 movwf xA+0 | |
556 movlw HIGH d'600' | |
557 movwf xA+1 ; A vertical line every 600 seconds | |
558 movff samplesecs_value,xB+0 ; Copy sampling rate | |
559 clrf xB+1 | |
560 call div16x16 ; xA/xB=xC with xA as remainder | |
561 movff xC+0,average_depth_hold_total+0 | |
562 movff xC+1,average_depth_hold_total+1 | |
563 ;average_depth_hold_total:2 holds interval of samples for vertical 10min line | |
564 | |
565 ; Restore divetime in minutes: | |
566 ; get real sample time | |
567 LOG_POINT_TO log_total_seconds | |
568 call ext_flash_byte_read_plus ; Total sample time in seconds | |
569 movff temp1,xC+0 | |
570 call ext_flash_byte_read_plus ; Total sample time in seconds | |
571 movff temp1,xC+1 | |
572 | |
573 PUTC ':' | |
574 LOG_POINT_TO log_divetime+.2 | |
575 call ext_flash_byte_read_plus ; read divetime seconds | |
576 movff temp1,lo | |
577 movff xC+0,xA+0 ; now calculate x-scale value | |
578 movff xC+1,xA+1 | |
579 movlw profile_width_pixels ; pix width available | |
580 movwf xB+0 | |
581 clrf xB+1 | |
582 call div16x16 ; xA/xB=xC | |
583 movff xC+0,xA+0 | |
584 movff xC+1,xA+1 | |
585 movf samplesecs_value,W ; devide through sample interval! | |
586 movwf xB+0 | |
587 clrf xB+1 | |
588 call div16x16 ; xA/xB=xC | |
589 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers | |
590 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers | |
591 incf profile_temp+0,F ; Increase by one, there might be a remainder | |
592 movlw d'0' | |
593 addwfc profile_temp+1,F | |
594 | |
595 bsf leftbind | |
596 output_99x ; divetime seconds | |
597 call TFT_standard_color | |
598 STRCAT_PRINT "" | |
599 | |
600 call ext_flash_byte_read_plus ; Read min. Temperature | |
601 movff temp1,logbook_min_tp+0 | |
602 call ext_flash_byte_read_plus ; Read min. Temperature | |
603 movff temp1,logbook_min_tp+1 | |
604 | |
605 ; Set pointer to Gas 1 Type. | |
606 LOG_POINT_TO log_gas1+.3 | |
607 call ext_flash_byte_read_plus ; read Gas Type | |
608 decfsz temp1,W ; =1 (="First")? | |
609 bra logbook_find_first_gas2 ; No. | |
610 movlw .1 | |
611 movwf temp1 | |
612 bra logbook_find_first_gas_done | |
613 logbook_find_first_gas2: | |
614 ; Set pointer to Gas 2 Type. | |
615 LOG_POINT_TO log_gas2+.3 | |
616 call ext_flash_byte_read_plus ; read Gas Type | |
617 decfsz temp1,W ; =1 (="First")? | |
618 bra logbook_find_first_gas3 ; No. | |
619 movlw .2 | |
620 movwf temp1 | |
621 bra logbook_find_first_gas_done | |
622 logbook_find_first_gas3: | |
623 ; Set pointer to Gas 3 Type. | |
624 LOG_POINT_TO log_gas3+.3 | |
625 call ext_flash_byte_read_plus ; read Gas Type | |
626 decfsz temp1,W ; =1 (="First")? | |
627 bra logbook_find_first_gas4 ; No. | |
628 movlw .3 | |
629 movwf temp1 | |
630 bra logbook_find_first_gas_done | |
631 logbook_find_first_gas4: | |
632 ; Set pointer to Gas 4 Type. | |
633 LOG_POINT_TO log_gas4+.3 | |
634 call ext_flash_byte_read_plus ; read Gas Type | |
635 decfsz temp1,W ; =1 (="First")? | |
636 bra logbook_find_first_gas5 ; No. | |
637 movlw .4 | |
638 movwf temp1 | |
639 bra logbook_find_first_gas_done | |
640 logbook_find_first_gas5: | |
641 movlw .5 ; Must be Gas5 | |
642 movwf temp1 | |
643 logbook_find_first_gas_done: | |
644 movff temp1,average_depth_hold_total+3; keep copy to restore color | |
645 rcall profile_display_color ; Back to normal profile color. | |
646 ; Pointer is now trashed! | |
647 | |
648 ; Point to profile portion of this dive | |
649 movff ext_flash_log_pointer+0,ext_flash_address+0 | |
650 movff ext_flash_log_pointer+1,ext_flash_address+1 | |
651 movff ext_flash_log_pointer+2,ext_flash_address+2 | |
652 | |
653 incf_ext_flash_address_0x20 d'2' ; Skip 0xFA 0xFA | |
654 call ext_flash_byte_read_plus_0x20 ; Read low byte of total dives into temp1 (at the time the dive was made) | |
655 | |
656 ; Load total number of dives (low byte only) | |
657 read_int_eeprom .2 | |
658 incf EEDATA,W ; +1 | |
659 bsf STATUS,C ; Set borrow | |
660 subfwb divesecs,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made) | |
661 cpfseq temp1 ; # of dive in logbook (Must be equal with low byte in short header) | |
662 bra display_profile_no_profile ; Not equal, no profile for this dive available! | |
663 | |
664 ; Skip rest of short header: 3 Bytes | |
665 ; Skip length of profile data: 3 Bytes | |
666 ; Skip sampling rate in profile section: 1Byte | |
667 ; Skip number of divisors: 1Byte | |
668 incf_ext_flash_address_0x20 d'8' | |
669 | |
670 ; Divisor temp | |
671 incf_ext_flash_address_0x20 d'2' | |
672 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
673 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
674 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
675 movf temp1,W | |
676 movwf divisor_temperature ; Store divisor | |
677 movwf count_temperature ; Store to tp° counter too. | |
678 ; Divisor Deco | |
679 incf_ext_flash_address_0x20 d'2' | |
680 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
681 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
682 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
683 movf temp1,W | |
684 movwf divisor_deco ; Store divisor | |
685 movwf count_deco ; Store as temp, too | |
686 ; Divisor GF | |
687 incf_ext_flash_address_0x20 d'2' | |
688 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
689 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
690 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
691 movff temp1,divisor_gf ; Store divisor | |
692 ; Divisor ppO2 Sensors | |
693 incf_ext_flash_address_0x20 d'2' | |
694 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
695 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
696 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
697 movff temp1,divisor_ppo2_sensors ; Store divisor | |
698 ; Divisor decoplan | |
699 incf_ext_flash_address_0x20 d'2' | |
700 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
701 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
702 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
703 movff temp1,divisor_decoplan ; Store divisor | |
704 ; Divisor CNS | |
705 incf_ext_flash_address_0x20 d'2' | |
706 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
707 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
708 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
709 movff temp1,divisor_cns ; Store divisor | |
710 ; Divisor Tank data | |
711 incf_ext_flash_address_0x20 d'2' | |
712 ; call ext_flash_byte_read_plus_0x20 ; Read information type | |
713 ; call ext_flash_byte_read_plus_0x20 ; Read information Length | |
714 call ext_flash_byte_read_plus_0x20 ; Read information Divisor | |
715 movff temp1,divisor_tank ; Store divisor | |
716 | |
717 ; Start Profile display | |
718 movlw color_deepblue | |
719 call TFT_set_color ; Make this configurable? | |
720 ; Draw a frame around profile area | |
721 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1 | |
722 | |
723 movlw profile_top | |
724 movff WREG,win_top | |
725 movlw profile_left | |
726 movff WREG,win_leftx2 ; Left border (0-159) | |
727 movlw d'1' | |
728 movff WREG,win_height | |
729 movlw profile_width_pixels+.1 | |
730 movff WREG,win_width ; Right border (0-159) | |
731 bra display_profile2f ; No 0m line | |
732 display_profile2e: | |
733 call TFT_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
734 display_profile2f: | |
735 movff win_top,WREG ; Get row | |
736 addwf x_scale+0,W ; Add line interval distance to win_top | |
737 tstfsz x_scale+1 ; >255? | |
738 movlw d'255' ; Yes, make win_top>239 -> Abort here | |
739 btfsc STATUS,C ; A Cary from the addwf above? | |
740 movlw d'255' ; Yes, make win_top>239 -> Abort here | |
741 movff WREG,win_top ; Result in win_top again | |
742 movff win_top,lo ; Get win_top in Bank1... | |
743 movlw profile_top+profile_height_pixels+.1 ; Limit | |
744 cpfsgt lo ; >239? | |
745 bra display_profile2e ; No, draw another line | |
746 | |
747 clrf timeout_counter2 ; here: used as counter for depth readings | |
748 movlw profile_width_pixels+profile_left-.1 | |
749 movwf ignore_digits ; here: used as counter for x-pixels | |
750 bcf end_of_profile ; clear flag | |
751 movlw profile_left | |
752 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5) | |
753 movlw profile_top ; Zero-m row | |
754 movwf apnoe_mins ; here: used for fill between rows | |
755 movwf logbook_last_tp ; Initialise for Tp° curve too. | |
756 | |
757 movlw LOW(-.100) ; Initialize max tp° to -10.0 °C. | |
758 movwf logbook_max_tp+0 | |
759 movlw HIGH 0xFFFF & (-.100) | |
760 movwf logbook_max_tp+1 | |
761 | |
762 setf logbook_cur_tp+0 ; Initialize Tp°, before the first recorded point. | |
763 setf logbook_cur_tp+1 | |
764 clrf logbook_last_tp ; Also reset previous Y for Tp° | |
765 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling. | |
766 | |
767 INIT_PIXEL_WROTE logbook_pixel_x_pos ; pixel x2 (Also sets standard Color!) | |
768 | |
769 profile_display_loop: | |
770 movff profile_temp+0,profile_temp2+0 | |
771 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler | |
772 incf profile_temp2+1,F | |
773 tstfsz profile_temp2+0 ; Must not be Zero | |
774 bra profile_display_loop2 ; Not Zero! | |
775 incf profile_temp2+0,F ; Zero, Increase! | |
776 | |
777 profile_display_loop2: | |
778 rcall profile_view_get_depth ; reads depth, temp and profile data | |
779 | |
780 btfsc end_of_profile ; end-of profile reached? | |
781 bra profile_display_loop_done ; Yes, skip all remaining pixels | |
782 | |
783 | |
784 ;---- Draw Ceiling curve, if any --------------------------------------------- | |
785 movf divisor_deco,W | |
786 bz profile_display_skip_deco | |
787 | |
788 movf logbook_ceiling,W ; Any deco ceiling ? | |
789 bz profile_display_skip_deco | |
790 | |
791 mullw .100 ; Yes: convert to mbar | |
792 movff PRODL,sub_a+0 | |
793 movff PRODH,sub_a+1 | |
794 movff logbook_cur_depth+0,sub_b+0 ; Compare with UNSIGNED current depth (16bits) | |
795 movff logbook_cur_depth+1,sub_b+1 | |
796 call subU16 ; set (or not) neg_flag | |
797 | |
798 movlw color_dark_green ; Dark green if Ok, | |
799 btfss neg_flag | |
800 movlw color_dark_red ; Or dark red if ceiling overflown. | |
801 call TFT_set_color | |
802 | |
803 movff PRODL,xA+0 | |
804 movff PRODH,xA+1 | |
805 movff y_scale+0,xB+0 ; devide pressure in mbar/quant for row offsett | |
806 movff y_scale+1,xB+1 | |
807 call div16x16 ; xA/xB=xC | |
808 | |
809 movlw profile_top+.1 ; Starts right after the top greenish line. | |
810 movff WREG,win_top | |
811 movff logbook_pixel_x_pos,win_leftx2 ; Left border (0-159) | |
812 movff xC+0,win_height | |
813 call half_vertical_line ; Inputs: win_top, win_leftx2, win_height, win_color1, win_color2 | |
814 | |
815 profile_display_skip_deco: | |
816 ;---- Draw Tp° curve, if any --------------------------------------------- | |
817 movf divisor_temperature,W | |
818 bz profile_display_skip_temp | |
819 | |
820 movf logbook_cur_tp+0,W ; Did we had already a valid Tp°C record ? | |
821 andwf logbook_cur_tp+1,W | |
822 incf WREG | |
823 bz profile_display_skip_temp ; No: just skip drawing. | |
824 | |
825 movlw LOW(((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix | |
826 movwf xB+0 | |
827 movlw HIGH(((profile_height_pixels-.10)*.256)/.370) | |
828 movwf xB+1 | |
829 | |
830 movf logbook_cur_tp+0,W ; Current Tp° - (-2.0°C) == Tp° + 20. | |
831 addlw LOW(.20) ; Low byte. | |
832 movwf xA+0 | |
833 movf logbook_cur_tp+1,W | |
834 btfsc STATUS,C ; Propagate carry, if any | |
835 incf WREG | |
836 movwf xA+1 | |
837 call mult16x16 ; xA*xB=xC | |
838 | |
839 ; scale: divide by 256, ie. take just high byte. | |
840 movf xC+1,W | |
841 sublw profile_top+profile_height_pixels-.10 ; Upside-down: Y = .75 + (.153 - result) | |
842 movwf xC+0 | |
843 | |
844 ; Check limits | |
845 movlw profile_top | |
846 movwf xC+1 | |
847 cpfsgt xC+0 | |
848 movff xC+1,xC+0 | |
849 | |
850 movlw color_orange | |
851 call TFT_set_color | |
852 | |
853 movf logbook_last_tp,W ; do we have a valid previous value ? | |
854 bz profile_display_temp_1 ; No: skip the vertical line. | |
855 movwf xC+1 | |
856 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | |
857 profile_display_temp_1: | |
858 movff xC+0,logbook_last_tp | |
859 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a current color pixel. | |
860 | |
861 profile_display_skip_temp: | |
862 ;---- Draw depth curve --------------------------------------------------- | |
863 movff y_scale+0,xB+0 ; devide pressure in mbar/quant for row offsett | |
864 movff y_scale+1,xB+1 | |
865 movff logbook_cur_depth+0,xA+0 | |
866 movff logbook_cur_depth+1,xA+1 | |
867 call div16x16 ; xA/xB=xC | |
868 movlw profile_top | |
869 addwf xC+0,F ; add 75 pixel offset to result | |
870 | |
871 btfsc STATUS,C ; Ignore potential profile errors | |
872 movff apnoe_mins,xC+0 | |
873 | |
874 rcall profile_display_color ; Back to normal profile color. | |
875 | |
876 movff apnoe_mins,xC+1 | |
877 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1) | |
878 movff xC+0,apnoe_mins ; Store last row for fill routine | |
879 | |
880 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel. | |
881 incf logbook_pixel_x_pos,F ; Next row | |
882 | |
883 ;---- Draw CNS curve, if any --------------------------------------------- | |
884 movf divisor_cns,W | |
885 bz profile_display_skip_cns | |
886 ; | |
887 ; TODO HERE | |
888 ; | |
889 profile_display_skip_cns: | |
890 | |
891 ;---- Draw GF curve, if any ---------------------------------------------- | |
892 movf divisor_gf,W | |
893 bz profile_display_skip_gf | |
894 ; | |
895 ; TODO HERE | |
896 ; | |
897 profile_display_skip_gf: | |
898 | |
899 ;---- All curves done. | |
900 | |
901 profile_display_skip_loop1: ; skips readings! | |
902 dcfsnz profile_temp2+0,F | |
903 bra profile_display_loop3 ; check 16bit.... | |
904 | |
905 rcall profile_view_get_depth ; reads depth, temp and profile data | |
906 bra profile_display_skip_loop1 | |
907 | |
908 profile_display_loop3: | |
909 decfsz profile_temp2+1,F ; 16 bit x-scaler test | |
910 bra profile_display_skip_loop1 ; skips readings! | |
911 | |
912 decfsz ignore_digits,F ; counts drawn x-pixels to zero | |
913 bra profile_display_loop ; Not ready yet | |
914 ; Done. | |
915 | |
916 display_profile_no_profile: ; No profile available for this dive! | |
917 | |
918 profile_display_loop_done: | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
919 btfss is_bailout ; Bailout during the dive? |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
920 bra profile_display_loop_done_nobail ; No |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
921 ; Yes, show "Bailout" |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
922 movlw color_pink |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
923 call TFT_set_color |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
924 WIN_TINY logbook_bailout_column,logbook_bailout_row |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
925 STRCPY_TEXT_PRINT tDiveBailout ; Bailout |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
926 profile_display_loop_done_nobail: |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
927 btfss gas6_changed ; Gas6 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
928 bra profile_display_loop_done_nogas6 ; No |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
929 ; Yes, show "Gas 6!" |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
930 movlw color_pink |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
931 call TFT_set_color |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
932 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
933 STRCPY_TEXT tGas ; Gas |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
934 STRCAT_PRINT " 6!" |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
935 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
936 profile_display_loop_done_nogas6: |
0 | 937 decf divesecs,F ;-1 |
938 read_int_eeprom .2 | |
939 movf EEDATA,W | |
940 bcf STATUS,C | |
941 subfwb divesecs,W ; max. dives (low value) - divesecs | |
942 movwf lo ; result | |
943 incf divesecs,F ;+1 | |
944 ; Set ext_flash_address:3 to TOC entry of this dive | |
945 ; 1st: 200000h-200FFFh -> lo=0 | |
946 ; 2nd: 201000h-201FFFh -> lo=1 | |
947 ; 3rd: 202000h-202FFFh -> lo=2 | |
948 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
949 clrf ext_flash_address+0 | |
950 clrf ext_flash_address+1 | |
951 movlw 0x20 | |
952 movwf ext_flash_address+2 | |
953 movlw .16 | |
954 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
955 movf PRODL,W | |
956 addwf ext_flash_address+1,F | |
957 movf PRODH,W | |
958 addwfc ext_flash_address+2,F | |
959 ; pointer at the first 0xFA of header | |
960 | |
961 movlw .2 ; negative offset | |
962 addwf logbook_last_tp,W | |
963 movff WREG,win_top ; Line below temp | |
964 movff logbook_pixel_x_pos,lo | |
965 movlw .130 | |
966 cpfslt lo ; limit left border to 130 | |
967 movwf lo | |
968 movff lo,win_leftx2 | |
969 WIN_FONT FT_TINY | |
970 movlw color_orange ; Use same color as tp° curve | |
971 call TFT_set_color | |
972 | |
973 movff logbook_min_tp+0,lo | |
974 movff logbook_min_tp+1,hi | |
975 lfsr FSR2,buffer | |
976 | |
977 TSTOSS opt_units ; 0=°C, 1=°F | |
978 bra logbook_show_temp_metric | |
979 ;logbook_show_temp_imperial: | |
980 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
981 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit | |
982 lfsr FSR2,buffer ; Overwrite "-" | |
983 bsf ignore_digit5 ; Full degrees only | |
984 output_16 | |
985 bcf ignore_digit5 | |
986 STRCAT_TEXT_PRINT tLogTunitF | |
987 bra logbook_show_temp_common | |
988 | |
989 logbook_show_temp_metric: | |
990 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
991 movlw d'3' | |
992 movwf ignore_digits | |
993 bsf leftbind | |
994 output_16dp d'2' ; temperature | |
995 STRCAT_TEXT_PRINT tLogTunitC | |
996 | |
997 logbook_show_temp_common: | |
50 | 998 bcf leftbind |
999 call TFT_standard_color | |
0 | 1000 |
1001 ; Get pointer to Gaslist | |
1002 LOG_POINT_TO log_gas1 | |
1003 | |
1004 movlw color_white ; Color for Gas 1 | |
1005 call TFT_set_color ; Set Color... | |
1006 bsf leftbind | |
1007 WIN_TINY log_gas_column1, log_gas_row | |
1008 rcall log_show_gas_common | |
1009 | |
1010 movlw color_green ; Color for Gas 2 | |
1011 call TFT_set_color ; Set Color... | |
1012 WIN_TINY log_gas_column2, log_gas_row | |
1013 rcall log_show_gas_common | |
1014 | |
1015 movlw color_red ; Color for Gas 3 | |
1016 call TFT_set_color ; Set Color... | |
1017 WIN_TINY log_gas_column3, log_gas_row | |
1018 rcall log_show_gas_common | |
1019 | |
1020 movlw color_yellow ; Color for Gas 4 | |
1021 call TFT_set_color ; Set Color... | |
1022 WIN_TINY log_gas_column4, log_gas_row | |
1023 rcall log_show_gas_common | |
1024 | |
1025 movlw color_cyan ; Color for Gas 5 | |
1026 call TFT_set_color ; Set Color... | |
1027 WIN_TINY log_gas_column5, log_gas_row | |
1028 rcall log_show_gas_common | |
1029 | |
1030 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | |
1031 display_profile_loop: | |
1032 btfsc switch_left ; SET/MENU? | |
1033 bra logbook_page2 ; Show more information | |
1034 btfsc switch_right ; ENTER? | |
1035 bra exit_profileview ; back to list | |
1036 | |
1037 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | |
1038 btfsc sleepmode ; Timeout? | |
1039 bra exit_profileview ; back to list | |
1040 bra display_profile_loop ; wait for something to do | |
1041 | |
1042 global log_screendump_and_onesecond | |
1043 log_screendump_and_onesecond: ; Check if we need to make a screenshot and check for new second | |
1044 btfsc onesecupdate | |
1045 call timeout_surfmode ; Timeout | |
1046 btfsc onesecupdate | |
1047 call set_dive_modes ; Check, if divemode must be entered | |
1048 bcf onesecupdate ; one second update | |
1049 btfsc divemode | |
1050 goto restart ; Enter Divemode if required | |
1051 | |
1052 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | |
1053 bra log_screendump_and_onesecond2 | |
1054 btfsc vusb_in ; USB plugged in? | |
113 | 1055 call comm_mode ; Start COMM mode |
0 | 1056 return |
1057 log_screendump_and_onesecond2: | |
1058 btfss vusb_in ; USB (still) plugged in? | |
1059 bcf enable_screen_dumps ; No, clear flag | |
1060 call rs232_get_byte | |
1061 btfsc rs232_recieve_overflow | |
1062 return | |
1063 movlw "l" | |
1064 cpfseq RCREG1 | |
1065 return | |
1066 call TFT_dump_screen ; Dump the screen contents | |
1067 return | |
1068 | |
1069 log_show_gas_common: | |
1070 extern customview_show_mix | |
1071 lfsr FSR2,buffer | |
1072 call ext_flash_byte_read_plus ; Gas2 current O2 | |
1073 movff temp1,lo | |
1074 call ext_flash_byte_read_plus ; Gas2 current He | |
1075 movff temp1,hi | |
1076 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1077 STRCAT_PRINT "" | |
1078 call ext_flash_byte_read_plus ; Gas2 change depth | |
1079 call ext_flash_byte_read_plus ; Gas2 Type | |
1080 return | |
1081 | |
1082 ;============================================================================= | |
1083 profile_display_color: | |
1084 movff average_depth_hold_total+3,active_gas ; Restore gas color. | |
1085 movlw color_white ; Default color | |
1086 dcfsnz active_gas,F | |
1087 movlw color_white ; Color for Gas 1 | |
1088 dcfsnz active_gas,F | |
1089 movlw color_green ; Color for Gas 2 | |
1090 dcfsnz active_gas,F | |
1091 movlw color_red ; Color for Gas 3 | |
1092 dcfsnz active_gas,F | |
1093 movlw color_yellow ; Color for Gas 4 | |
1094 dcfsnz active_gas,F | |
1095 movlw color_cyan ; Color for Gas 5 | |
1096 dcfsnz active_gas,F | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1097 movlw color_pink ; Color for Gas 6 |
0 | 1098 goto TFT_set_color ; Set Color... |
1099 | |
1100 ;============================================================================= | |
1101 ; Draw a vertical line between xC+1 and xC+0, at current X position. | |
1102 ; | |
1103 ; Note: should keep xC+0 | |
1104 ; Note: ascending or descending ! | |
1105 ; | |
1106 profile_display_fill: | |
1107 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins | |
1108 movf xC+0,W | |
1109 cpfseq xC+1 ; xC+0 = apone_mins? | |
1110 bra profile_display_fill2 ; No! | |
1111 return | |
1112 | |
1113 profile_display_fill2: | |
1114 ; Make sure to init X position. | |
1115 movf logbook_pixel_x_pos,W | |
1116 mullw 2 | |
1117 decf PRODL,F | |
1118 movlw 0 | |
1119 subwfb PRODH,F | |
1120 call pixel_write_col320 | |
1121 | |
1122 movf xC+0,W | |
1123 cpfsgt xC+1 ; apnoe_mins>xC+0? | |
1124 bra profile_display_fill_up ; Yes! | |
1125 | |
1126 profile_display_fill_down2: ; Loop | |
1127 decf xC+1,F | |
1128 | |
1129 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) | |
1130 | |
1131 movf xC+0,W | |
1132 cpfseq xC+1 ; Loop until xC+1=xC+0 | |
1133 bra profile_display_fill_down2 | |
1134 return ; apnoe_mins and xC+0 are untouched | |
1135 | |
1136 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins! | |
1137 incf xC+1,F | |
1138 | |
1139 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239) | |
1140 | |
1141 movf xC+0,W | |
1142 cpfseq xC+1 ; Loop until xC+1=apnoe_mins | |
1143 bra profile_display_fill_up | |
1144 return ; apnoe_mins and xC+0 are untouched | |
1145 | |
1146 ;============================================================================= | |
1147 | |
1148 | |
1149 profile_view_get_depth: | |
1150 incf logbook_sample_counter+0,F | |
1151 movlw d'0' | |
1152 addwfc logbook_sample_counter+1,F ; Count read pixels | |
1153 | |
1154 movf logbook_sample_counter+0,W | |
1155 cpfseq average_depth_hold_total+0 | |
1156 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | |
1157 movf logbook_sample_counter+1,W | |
1158 cpfseq average_depth_hold_total+1 | |
1159 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue | |
1160 ; draw a new 10min line here... | |
1161 clrf logbook_sample_counter+0 | |
1162 clrf logbook_sample_counter+1 ; clear counting registers for next line | |
1163 | |
1164 ; Vertical lines... | |
1165 movlw color_deepblue | |
1166 call TFT_set_color ; Make this configurable? | |
1167 movlw profile_top+.1 | |
1168 movff WREG,win_top | |
1169 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile | |
1170 movff WREG,win_leftx2 ; Left border (0-159) | |
1171 movlw profile_height_pixels | |
1172 movff WREG,win_height | |
1173 movlw profile_height_pixels | |
1174 movff WREG,win_width ; "Window" height | |
1175 call half_horizontal_line ; Inputs: win_top, win_leftx2, win_width, win_color1, win_color2 | |
1176 | |
1177 profile_view_get_depth_no_line: | |
1178 call ext_flash_byte_read_plus_0x20 ; read depth first | |
1179 movff temp1,logbook_cur_depth+0 ; low value | |
1180 call ext_flash_byte_read_plus_0x20 ; read depth first | |
1181 movff temp1,logbook_cur_depth+1 ; high value | |
1182 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte | |
1183 movff temp1,timeout_counter2 ; Read Profile Flag Byte | |
1184 | |
1185 bcf event_occured ; clear flag | |
1186 btfsc timeout_counter2,7 | |
1187 bsf event_occured ; We also have an Event byte! | |
1188 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any) | |
1189 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127) | |
1190 movlw 0xFD ; end of profile bytes? | |
1191 cpfseq logbook_cur_depth+0 | |
1192 bra profile_view_get_depth_new1 ; no 1st. 0xFD | |
1193 cpfseq logbook_cur_depth+1 | |
1194 bra profile_view_get_depth_new1 ; no 2nd. 0xFD | |
1195 bsf end_of_profile ; End found! Set Flag! Skip remaining pixels! | |
1196 return | |
1197 | |
1198 profile_view_get_depth_new1: | |
1199 btfsc event_occured ; Was there an event attached to this sample? | |
1200 rcall profile_view_get_depth_new2 ; Yes, get information about this event | |
1201 | |
1202 ;---- Read Tp°, if any AND divisor reached AND bytes available ----------- | |
1203 movf divisor_temperature,W ; Is Tp° divisor null ? | |
1204 bz profile_view_get_depth_no_tp; Yes: no Tp° curve. | |
1205 decf count_temperature,F ; Decrement tp° counter | |
1206 bnz profile_view_get_depth_no_tp; No temperature this time | |
1207 | |
1208 call ext_flash_byte_read_plus_0x20 ; Tp° low | |
1209 decf timeout_counter2,F | |
1210 movff temp1,logbook_cur_tp+0 | |
1211 call ext_flash_byte_read_plus_0x20 ; Tp° high | |
1212 decf timeout_counter2,F | |
1213 movff temp1,logbook_cur_tp+1 | |
1214 movff divisor_temperature,count_temperature ; Restart counter. | |
1215 | |
1216 ; Compute Tp° max on the fly... | |
1217 movff logbook_cur_tp+0,sub_a+0 ; Compare cur_tp > max_tp ? | |
1218 movff logbook_cur_tp+1,sub_a+1 | |
1219 movff logbook_max_tp+0,sub_b+0 | |
1220 movff logbook_max_tp+1,sub_b+1 | |
1221 call sub16 ; SIGNED sub_a - sub_b | |
1222 btfsc neg_flag | |
1223 bra profile_view_get_depth_no_tp | |
1224 | |
1225 movff logbook_cur_tp+0,logbook_max_tp+0 | |
1226 movff logbook_cur_tp+1,logbook_max_tp+1 | |
1227 | |
1228 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- | |
1229 profile_view_get_depth_no_tp: | |
1230 movf divisor_deco,W | |
1231 bz profile_view_get_depth_no_deco | |
1232 decf count_deco,F | |
1233 bnz profile_view_get_depth_no_deco | |
1234 | |
1235 call ext_flash_byte_read_plus_0x20 | |
1236 decf timeout_counter2,F | |
1237 movff temp1,logbook_ceiling | |
1238 movff divisor_deco,count_deco ; Restart counter. | |
1239 | |
1240 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------ | |
1241 profile_view_get_depth_no_deco: | |
1242 movf timeout_counter2,W ; No more extra bytes ? | |
1243 btfsc STATUS,Z | |
1244 return ; No: done. | |
1245 | |
1246 ; Then skip remaining bytes... | |
1247 movf timeout_counter2,W ; number of additional bytes to ignore (0-127) | |
1248 call incf_ext_flash_address0_0x20; increases bytes in ext_flash_address:3 with 0x200000 bank switching | |
1249 return | |
1250 | |
1251 profile_view_get_depth_new2: | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1252 clrf EventByte |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1253 clrf EventByte2 ; Clear EventBytes |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1254 call ext_flash_byte_read_plus_0x20 ; Read Event byte |
0 | 1255 movff temp1,EventByte ; store EventByte |
1256 decf timeout_counter2,F ; reduce counter | |
98 | 1257 |
1258 btfss EventByte,7 ; Another Event byte? | |
1259 bra profile_no_second_eventbyte ; No | |
1260 call ext_flash_byte_read_plus_0x20; Read Event byte2 | |
1261 movff temp1,EventByte2 ; store EventByte2 | |
1262 decf timeout_counter2,F ; reduce counter | |
1263 bcf EventByte,7 ; Clear flag | |
1264 | |
1265 profile_no_second_eventbyte: | |
0 | 1266 ; Check Event flags in the EventByte |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1267 btfsc EventByte2,0 ; Bailout? |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1268 bra logbook_event2 ; Yes! |
0 | 1269 btfsc EventByte,4 ; Manual Gas Changed? |
1270 bra logbook_event1 ; Yes! | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1271 btfsc EventByte,6 ; Setpoint Change? |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1272 bra logbook_event3 ; Yes! |
0 | 1273 btfss EventByte,5 ; Stored Gas Changed? |
1274 return ; No, return | |
1275 ; Stored Gas changed! | |
1276 call ext_flash_byte_read_plus_0x20 ; Read Gas# | |
1277 decf timeout_counter2,F ; reduce counter | |
1278 movff temp1,average_depth_hold_total+3 | |
1279 rcall profile_display_color ; Change profile color according to gas number | |
1280 return | |
1281 | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1282 logbook_event1: ; Gas6 changed |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1283 bsf gas6_changed |
0 | 1284 movlw 6 ; Just color backup to 6 |
1285 movwf average_depth_hold_total+3 | |
1286 rcall profile_display_color ; Back to normal profile color. | |
1287 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...) | |
1288 | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1289 logbook_event2: ; Bailout |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1290 bsf is_bailout ; Set flag |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1291 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
|
1292 movlw 6 ; Use Gas6 color |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1293 movwf average_depth_hold_total+3 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1294 rcall profile_display_color ; Back to normal profile color. |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1295 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
|
1296 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1297 logbook_event3: ; Setpoint change |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1298 btfss is_bailout ; Are we in bailout? |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1299 return ; No, return |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1300 ; We were in bailout before, restore profile color |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1301 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
|
1302 rcall profile_display_color ; Back to normal profile color. |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1303 return |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1304 |
0 | 1305 exit_profileview: |
1306 call speed_fastest | |
1307 bcf sleepmode | |
1308 clrf timeout_counter2 ; restore all registers to build same page again | |
1309 movff divemins_backup,divemins+0 | |
1310 movff logbook_divenumber_temp, logbook_divenumber | |
1311 movff logbook_max_dive_counter_temp,logbook_max_dive_counter | |
1312 incf logbook_max_dive_counter,F | |
1313 decf logbook_divenumber,F | |
1314 bcf all_dives_shown | |
1315 clrf menupos3 ; here: used row on current page | |
1316 movlw logbook_row_number | |
1317 movwf menupos ; here: active row on current page | |
1318 clrf CCP1CON ; stop PWM | |
1319 bcf PORTC,2 ; Pull PWM out to GND | |
1320 call TFT_ClearScreen ; clear details/profile | |
1321 goto logbook2 ; start search | |
1322 | |
1323 next_logbook2: | |
1324 btfsc all_dives_shown ; all shown | |
1325 goto logbook ; all reset | |
1326 clrf menupos3 | |
1327 movlw logbook_row_number | |
1328 movwf menupos | |
1329 incf logbook_page_number,F ; start new screen | |
1330 clrf CCP1CON ; stop PWM | |
1331 bcf PORTC,2 ; Pull PWM out to GND | |
1332 call TFT_ClearScreen | |
1333 goto logbook2 ; start search | |
1334 | |
1335 next_logbook3: | |
1336 incf menupos,F ; +1 | |
1337 movlw logbook_row_number+.2 | |
1338 cpfsgt menupos ; =logbook_row_number+.3? | |
1339 bra next_logbook3a ; No | |
1340 movlw .1 | |
1341 movwf menupos | |
1342 bra next_logbook3b | |
1343 | |
1344 next_logbook3a: | |
1345 incf menupos3,W ; last entry in current page +1 | |
1346 cpfseq menupos ; same as cursor pos.? | |
1347 bra next_logbook3b ; No | |
1348 movlw logbook_row_number+.1 ; Yes, ... | |
1349 movwf menupos ; ... jump directly to "next page" if page is not full | |
1350 | |
1351 movlw logbook_row_number | |
1352 cpfseq menupos3 ; Last dive was row logbook_row_number? | |
1353 bsf all_dives_shown ; No, set flag to load first page again (full reset) | |
1354 | |
1355 next_logbook3b: | |
1356 clrf timeout_counter2 | |
1357 call TFT_logbook_cursor | |
1358 | |
1359 bcf switch_left | |
1360 goto logbook_loop | |
1361 | |
1362 display_listdive: | |
1363 bsf logbook_page_not_empty ; Page not empty | |
1364 incf menupos3,F | |
1365 | |
1366 bsf leftbind | |
1367 WIN_FONT FT_SMALL | |
1368 WIN_LEFT logbook_list_left | |
1369 | |
1370 decf menupos3,W ; -1 into wreg | |
1371 mullw logbook_row_offset | |
1372 movff PRODL,win_top | |
1373 | |
1374 lfsr FSR2,buffer | |
1375 movff logbook_divenumber,lo | |
1376 output_8 ; # of dive | |
1377 PUTC ' ' | |
1378 LOG_POINT_TO log_date+1 ; Point to month | |
1379 call ext_flash_byte_read_plus | |
1380 movff temp1,lo ; read month | |
1381 | |
1382 display_listdive2: | |
1383 movff lo,convert_value_temp+0 ; Month (in lo, see above) | |
1384 call ext_flash_byte_read_plus ; Day | |
1385 movff temp1,convert_value_temp+1 | |
1386 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer | |
1387 PUTC ' ' | |
1388 | |
1389 LOG_POINT_TO log_max_depth ; Point to max. depth | |
1390 call ext_flash_byte_read_plus ; max. Depth | |
1391 movff temp1,lo | |
1392 call ext_flash_byte_read_plus | |
1393 movff temp1,hi | |
1394 | |
1395 TSTOSS opt_units ; 0=Meters, 1=Feets | |
1396 bra display_listdive2_metric | |
1397 ;display_listdive2_imperial: | |
1398 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
1399 PUTC ' ' | |
25 | 1400 bcf leftbind |
1401 output_16_3 | |
0 | 1402 STRCAT_TEXT tFeets1 |
1403 bra display_listdive3 | |
1404 | |
1405 display_listdive2_metric: | |
1406 bsf ignore_digit5 ; no cm... | |
1407 movlw d'1' ; +1 | |
1408 movff WREG,ignore_digits ; no 1000m | |
1409 bcf leftbind | |
1410 output_16dp .3 ; xxx.y | |
1411 STRCAT_TEXT tMeters | |
1412 PUTC ' ' | |
1413 | |
1414 display_listdive3: | |
1415 call ext_flash_byte_read_plus | |
1416 movff temp1,lo ; read divetime minutes | |
1417 call ext_flash_byte_read_plus | |
1418 movff temp1,hi | |
1419 output_16_3 ; Divetime minutes (0-999min) | |
1420 STRCAT_TEXT_PRINT tMinutes ; Display header-row in list | |
1421 return | |
1422 | |
1423 logbook_show_divenumber: | |
1424 call do_logoffset_common_read ; Read into lo:hi | |
1425 tstfsz lo ; lo=0? | |
1426 bra logbook_show_divenumber2 ; No, adjust offset | |
1427 tstfsz hi ; hi=0? | |
1428 bra logbook_show_divenumber2 ; No, adjust offset | |
1429 movff divesecs,lo ; lo=0 and hi=0 -> skip Offset routine | |
1430 bra logbook_show_divenumber3 ; Display now | |
1431 | |
1432 logbook_show_divenumber2: | |
1433 movlw d'1' | |
1434 addwf lo,F | |
1435 movlw d'0' | |
1436 addwfc hi,F ; hi:lo = hi:lo + 1 | |
1437 movff lo,sub_a+0 | |
1438 movff hi,sub_a+1 | |
1439 movff divesecs,sub_b+0 | |
1440 clrf sub_b+1 | |
1441 call subU16 ; sub_c = sub_a - sub_b | |
1442 movff sub_c+0,lo | |
1443 movff sub_c+1,hi | |
1444 | |
1445 logbook_show_divenumber3: | |
1446 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row | |
1447 bsf leftbind | |
1448 output_16 ; # of dive in logbook | |
1449 bcf leftbind | |
1450 STRCAT_PRINT "" | |
1451 return | |
1452 | |
1453 | |
1454 logbook_page2: ; Show more info | |
1455 call speed_fastest | |
1456 clrf CCP1CON ; stop PWM | |
1457 bcf PORTC,2 ; Pull PWM out to GND | |
1458 call TFT_ClearScreen ; Clear screen | |
1459 | |
1460 ; Set ext_flash pointer to "#divesecs-oldest" dive | |
1461 ; compute read_int_eeprom .2 - divesecs | |
1462 ; Read required header data for profile display | |
1463 ; look in header for pointer to begin of diveprofile (Byte 2-4) | |
1464 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing | |
1465 | |
1466 decf divesecs,F ;-1 | |
1467 read_int_eeprom .2 | |
1468 movf EEDATA,W | |
1469 bcf STATUS,C | |
1470 subfwb divesecs,W ; max. dives (low value) - divesecs | |
1471 movwf lo ; result | |
1472 incf divesecs,F ;+1 | |
1473 ; Set ext_flash_address:3 to TOC entry of this dive | |
1474 ; 1st: 200000h-200FFFh -> lo=0 | |
1475 ; 2nd: 201000h-201FFFh -> lo=1 | |
1476 ; 3rd: 202000h-202FFFh -> lo=2 | |
1477 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...) | |
1478 clrf ext_flash_address+0 | |
1479 clrf ext_flash_address+1 | |
1480 movlw 0x20 | |
1481 movwf ext_flash_address+2 | |
1482 movlw .16 | |
1483 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
1484 movf PRODL,W | |
1485 addwf ext_flash_address+1,F | |
1486 movf PRODH,W | |
1487 addwfc ext_flash_address+2,F | |
1488 ; pointer at the first 0xFA of header | |
1489 call logbook_show_divenumber ; Show the dive number in medium font | |
1490 | |
1491 | |
1492 LOG_POINT_TO log_surface_press | |
1493 ; surface pressure in mbar | |
1494 call ext_flash_byte_read_plus ; read surface pressure | |
1495 movff temp1,lo | |
1496 call ext_flash_byte_read_plus ; read surface pressure | |
1497 movff temp1,hi | |
1498 WIN_TINY MBAR_column,MBAR_row | |
1499 bsf leftbind | |
1500 output_16 ; Air pressure before dive | |
1501 STRCAT_TEXT_PRINT tMBAR | |
1502 | |
89
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1503 ; OC/CC Gas List |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1504 LOG_POINT_TO log_divemode |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1505 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into temp1 |
0 | 1506 WIN_TINY log2_title_column,log2_title_row1 |
1507 WIN_COLOR color_greenish | |
89
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1508 movlw .1 |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1509 cpfseq temp1 ;=CC? |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1510 bra logbook_gaslist_oc |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1511 STRCPY_TEXT_PRINT tGaslistCC |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1512 bra logbook_gaslist_common |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1513 logbook_gaslist_oc: |
0 | 1514 STRCPY_TEXT_PRINT tGaslist |
89
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1515 logbook_gaslist_common: |
c34516c99ca8
BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents:
66
diff
changeset
|
1516 LOG_POINT_TO log_gas1 |
0 | 1517 WIN_FRAME_STD log2_title_row1-2, log2_gas_row5+.15, log2_title_column-2, .159 ; Top, Bottom, Left, Right |
1518 bcf leftbind | |
1519 movlw color_white ; Color for Gas 1 | |
1520 call TFT_set_color ; Set Color... | |
1521 WIN_TINY log2_gas_column, log2_gas_row1 | |
1522 rcall log_show_gas_common2 | |
1523 movlw color_green ; Color for Gas 2 | |
1524 call TFT_set_color ; Set Color... | |
1525 WIN_TINY log2_gas_column, log2_gas_row2 | |
1526 rcall log_show_gas_common2 | |
1527 movlw color_red ; Color for Gas 3 | |
1528 call TFT_set_color ; Set Color... | |
1529 WIN_TINY log2_gas_column, log2_gas_row3 | |
1530 rcall log_show_gas_common2 | |
1531 movlw color_yellow ; Color for Gas 4 | |
1532 call TFT_set_color ; Set Color... | |
1533 WIN_TINY log2_gas_column, log2_gas_row4 | |
1534 rcall log_show_gas_common2 | |
1535 movlw color_cyan ; Color for Gas 5 | |
1536 call TFT_set_color ; Set Color... | |
1537 WIN_TINY log2_gas_column, log2_gas_row5 | |
1538 rcall log_show_gas_common2 | |
1539 | |
1540 ; Firmware | |
1541 call TFT_standard_color | |
1542 WIN_TINY log2_firmware_column,log2_firmware_row | |
1543 STRCPY_TEXT tFirmware | |
1544 call ext_flash_byte_read_plus ; read firmware xx | |
1545 movff temp1,lo | |
1546 bsf leftbind | |
1547 output_8 | |
1548 PUTC "." | |
1549 call ext_flash_byte_read_plus ; read firmware yy | |
1550 movff temp1,lo | |
1551 output_99x | |
1552 STRCAT_PRINT "" | |
1553 | |
1554 ; Battery | |
1555 WIN_TINY log2_battery_column,log2_battery_row | |
1556 STRCPY "Batt:" | |
1557 call ext_flash_byte_read_plus ; read battery low | |
1558 movff temp1,lo | |
1559 call ext_flash_byte_read_plus ; read battery high | |
1560 movff temp1,hi | |
1561 output_16dp .2 | |
1562 STRCAT_PRINT "V" | |
1563 | |
1564 ; Setpoint list | |
1565 LOG_POINT_TO log_sp1 | |
1566 WIN_TINY log2_title_column,log2_title_sp_row | |
1567 WIN_COLOR color_greenish | |
1568 STRCPY_TEXT_PRINT tFixedSetpoints | |
1569 WIN_FRAME_STD log2_title_sp_row-2, log2_sp_row5+.15, log2_title_column-2, .159 ; Top, Bottom, Left, Right | |
1570 WIN_TINY log2_gas_column, log2_sp_row1 | |
1571 rcall log_show_sp_common | |
1572 WIN_TINY log2_gas_column, log2_sp_row2 | |
1573 rcall log_show_sp_common | |
1574 WIN_TINY log2_gas_column, log2_sp_row3 | |
1575 rcall log_show_sp_common | |
1576 WIN_TINY log2_gas_column, log2_sp_row4 | |
1577 rcall log_show_sp_common | |
1578 WIN_TINY log2_gas_column, log2_sp_row5 | |
1579 rcall log_show_sp_common | |
1580 | |
1581 ; Salinity | |
1582 WIN_TINY log2_salinity_column,log2_salinity_row | |
1583 STRCPY_TEXT tDvSalinity | |
1584 bsf leftbind | |
1585 call ext_flash_byte_read_plus ; read salinity | |
1586 movff temp1,lo | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1587 movff temp1,total_divetime_seconds+1 ; backup for average depth display |
0 | 1588 output_8 |
1589 STRCAT_PRINT "%" | |
1590 | |
1591 ; CNS | |
1592 LOG_POINT_TO log_cns_start | |
1593 WIN_TINY log2_cns_column,log2_cns_row | |
1594 STRCPY_TEXT tCNS2 | |
1595 call ext_flash_byte_read_plus ; read cns low | |
1596 movff temp1,lo | |
1597 call ext_flash_byte_read_plus ; read cns high | |
1598 movff temp1,hi | |
1599 output_16 | |
1600 LOG_POINT_TO log_cns_end | |
1601 STRCAT "->" | |
1602 call ext_flash_byte_read_plus ; read CNS low | |
1603 movff temp1,lo | |
1604 call ext_flash_byte_read_plus ; read CNS high | |
1605 movff temp1,hi | |
1606 output_16 | |
1607 STRCAT_PRINT "%" | |
1608 | |
1609 ; Average depth | |
1610 WIN_TINY log2_avr_column,log2_avr_row | |
1611 STRCPY_TEXT tAVR | |
1612 call ext_flash_byte_read_plus ; read avr low | |
1613 movff temp1,lo | |
1614 call ext_flash_byte_read_plus ; read avr high | |
1615 movff temp1,hi | |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1616 |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1617 movf total_divetime_seconds+1,W ; salinity for this dive |
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
98
diff
changeset
|
1618 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
|
1619 |
0 | 1620 output_16dp .3 |
1621 STRCAT_PRINT "m" | |
1622 | |
1623 ; Deco model | |
1624 LOG_POINT_TO log_decomodel | |
1625 WIN_TINY log2_decomodel_column,log2_decomodel_row | |
1626 STRCPY_TEXT tDkMode | |
1627 call ext_flash_byte_read_plus ; read deco model | |
1628 movff temp1,lo | |
1629 decfsz temp1,F | |
1630 bra logbook_decomodel1 | |
1631 ; Deco model GF Version | |
1632 STRCAT_TEXT_PRINT tZHL16GF | |
1633 LOG_POINT_TO log_gf_lo | |
1634 WIN_TINY log2_decomodel2_column,log2_decomodel2_row | |
1635 STRCPY_TEXT tGF_low | |
1636 call ext_flash_byte_read_plus ; Read GF lo | |
1637 movff temp1,lo | |
1638 output_8 | |
1639 STRCAT_PRINT "%" | |
1640 WIN_TINY log2_decomodel3_column,log2_decomodel3_row | |
1641 STRCPY_TEXT tGF_high | |
1642 call ext_flash_byte_read_plus ; Read GF hi | |
1643 movff temp1,lo | |
1644 output_8 | |
1645 STRCAT_PRINT "%" | |
1646 bra logbook_decomodel2 | |
1647 logbook_decomodel1: | |
1648 ; Deco model NON-GF Version | |
1649 STRCAT_TEXT_PRINT tZHL16 | |
1650 LOG_POINT_TO log_sat_mult | |
1651 WIN_TINY log2_decomodel2_column,log2_decomodel2_row | |
1652 STRCPY_TEXT tSaturationMult | |
1653 call ext_flash_byte_read_plus ; Read sat_mult | |
1654 movff temp1,lo | |
1655 output_8 | |
1656 STRCAT_PRINT "%" | |
1657 WIN_TINY log2_decomodel3_column,log2_decomodel3_row | |
1658 STRCPY_TEXT tDesaturationMult | |
1659 call ext_flash_byte_read_plus ; Read desat_mult | |
1660 movff temp1,lo | |
1661 output_8 | |
1662 STRCAT_PRINT "%" | |
1663 logbook_decomodel2: | |
1664 ; Dive mode | |
1665 LOG_POINT_TO log_divemode | |
1666 WIN_TINY log2_divemode_column,log2_divemode_row | |
1667 STRCPY_TEXT tDvMode | |
1668 call ext_flash_byte_read_plus ; Read divemode | |
1669 movff temp1,lo | |
1670 call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE) | |
1671 | |
1672 ; Last deco | |
1673 LOG_POINT_TO log_last_stop | |
1674 WIN_TINY log2_lastdeco_column,log2_lastdeco_row | |
1675 STRCPY_TEXT tLastDecostop | |
1676 call ext_flash_byte_read_plus ; Read last stop | |
1677 movff temp1,lo | |
1678 output_8 | |
1679 STRCAT_PRINT "m" | |
1680 | |
1681 ; A frame around the details | |
1682 WIN_TINY log2_lastdeco_column,log2_salinity_row-.16 | |
1683 WIN_COLOR color_greenish | |
1684 STRCPY_TEXT_PRINT tLogbook | |
1685 WIN_FRAME_STD log2_salinity_row-.18, MBAR_row+.15, 0, .85 ; Top, Bottom, Left, Right | |
1686 | |
1687 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco | |
1688 display_details_loop: | |
1689 btfsc switch_left ; SET/MENU? | |
1690 goto display_profile2 ; Show the profile view again | |
1691 btfsc switch_right ; ENTER? | |
1692 bra exit_profileview ; back to list | |
1693 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | |
1694 btfsc sleepmode ; Timeout? | |
1695 bra exit_profileview ; back to list | |
1696 | |
1697 bra display_details_loop ; wait for something to do | |
1698 | |
1699 global logbook_preloop_tasks | |
1700 logbook_preloop_tasks: | |
1701 movlw CCP1CON_VALUE ; See ostc3.inc | |
1702 movwf CCP1CON ; Power-on backlight | |
1703 call TFT_standard_color | |
1704 bcf sleepmode ; clear some flags | |
1705 bcf switch_right | |
1706 bcf switch_left | |
1707 clrf timeout_counter2 | |
1708 call speed_normal | |
1709 return | |
1710 | |
1711 log_show_sp_common: | |
1712 lfsr FSR2,buffer | |
1713 call ext_flash_byte_read_plus ; Read setpoint | |
1714 movff temp1,lo | |
1715 clrf hi | |
1716 bsf leftbind | |
1717 output_16dp d'3' | |
1718 bcf leftbind | |
1719 STRCAT_TEXT tbar | |
1720 PUTC " " | |
1721 call ext_flash_byte_read_plus ; change depth | |
1722 movff temp1,lo | |
1723 | |
1724 TSTOSS opt_units ; 0=Meters, 1=Feets | |
1725 bra log_show_sp_common_metric | |
1726 movf lo,W | |
1727 mullw .100 ; convert meters to mbar | |
1728 movff PRODL,lo | |
1729 movff PRODH,hi | |
1730 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
1731 output_16 | |
1732 STRCAT_TEXT tFeets ; "ft" | |
1733 bra log_show_sp_common_common | |
1734 log_show_sp_common_metric: | |
1735 output_8 | |
1736 STRCAT_TEXT tMeters ; "m" | |
1737 log_show_sp_common_common: | |
1738 STRCAT_PRINT "" | |
1739 return | |
1740 | |
1741 log_show_gas_common2: ; as log_show_gas_common but with change depth | |
1742 lfsr FSR2,buffer | |
1743 call ext_flash_byte_read_plus ; current O2 | |
1744 movff temp1,lo | |
1745 call ext_flash_byte_read_plus ; current He | |
1746 movff temp1,hi | |
1747 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
1748 call ext_flash_byte_read_plus ; change depth | |
1749 movff temp1,lo | |
1750 | |
1751 TSTOSS opt_units ; 0=Meters, 1=Feets | |
1752 bra log_show_gas_common2_metric | |
1753 movf lo,W | |
1754 mullw .100 ; convert meters to mbar | |
1755 movff PRODL,lo | |
1756 movff PRODH,hi | |
1757 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
1758 output_16 | |
1759 STRCAT_TEXT tFeets ; "ft" | |
1760 bra log_show_gas_common2_common | |
1761 log_show_gas_common2_metric: | |
1762 output_8 | |
1763 STRCAT_TEXT tMeters ; "m" | |
1764 log_show_gas_common2_common: | |
1765 bcf leftbind | |
1766 call ext_flash_byte_read_plus ; Gas Type | |
1767 STRCAT_PRINT "" | |
1768 return | |
1769 | |
1770 END |