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