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