0
|
1
|
|
2 ; OSTC - diving computer code
|
|
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
|
|
4
|
|
5 ; This program is free software: you can redistribute it and/or modify
|
|
6 ; it under the terms of the GNU General Public License as published by
|
|
7 ; the Free Software Foundation, either version 3 of the License, or
|
|
8 ; (at your option) any later version.
|
|
9
|
|
10 ; This program is distributed in the hope that it will be useful,
|
|
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 ; GNU General Public License for more details.
|
|
14
|
|
15 ; You should have received a copy of the GNU General Public License
|
|
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
|
18
|
|
19 ; Menu "Logbook"
|
|
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
21 ; written: 060107
|
|
22 ; last updated: 081026
|
|
23 ; known bugs:
|
|
24 ; ToDo:
|
|
25
|
|
26 ; searches external EEPROM for dive headers and displays them in a list
|
|
27 ; a detailed view with all informations and profile can be selected
|
|
28 ; does not require a FAT, will work with other profile intervals as ten seconds, too
|
|
29
|
|
30 menu_logbook:
|
|
31 bcf return_from_profileview ; clear some flags
|
|
32 ;call enable_rs232
|
|
33 menu_logbook1:
|
|
34 bcf logbook_header_drawn
|
|
35 call PLED_ClearScreen ; Clear screen
|
|
36 bcf all_dives_shown ; clear some flags
|
|
37 bcf logbook_profile_view
|
|
38 bcf logbook_page_not_empty
|
|
39 clrf menupos3 ; Here: used rows on current logbook-page
|
|
40 clrf menupos2 ; Here: # of current displayed page
|
|
41 clrf divenumber ; # of dive in list during search
|
|
42
|
|
43
|
|
44 menu_logbook1a:
|
|
45 WIN_INVERT .1
|
|
46 DISPLAYTEXT .12 ;" Wait.."
|
|
47 WIN_INVERT .0
|
|
48 clrf divemins+0 ; Here: used as temp variables
|
|
49 clrf divemins+1
|
|
50 call I2CReset ; Reset I2C Bus
|
|
51 call get_free_EEPROM_location ; search from "here" backwards through the external memory
|
|
52
|
|
53 movlw d'5'
|
|
54 movwf menupos ; Here: stores current position on display (5-x)
|
148
|
55
|
|
56 ;-----------------------------------------------------------------------------
|
|
57 ; search external EEPROM backwards from eeprom_address
|
|
58 ; for 0xFA, 0xFA (store 1st. 0xFA position for next search)
|
|
59 ; read header data and display it
|
|
60 ; wait for user to confirm/exit
|
|
61 ; recopy data to search from here
|
|
62
|
0
|
63 menu_logbook1b:
|
|
64 WIN_INVERT .1
|
|
65 DISPLAYTEXT .12 ;" Wait.."
|
|
66 WIN_INVERT .0
|
|
67
|
148
|
68 ;---- fast loop: check every other byte ----------------------------------
|
0
|
69 menu_logbook2:
|
148
|
70 infsnz divemins+0,F ; increase 16Bit value
|
|
71 incf divemins+1,F
|
|
72 infsnz divemins+0,F ; increase 16Bit value, twice
|
|
73 incf divemins+1,F
|
0
|
74
|
148
|
75 btfsc divemins+1,7 ; At 0x8000?
|
|
76 bra menu_logbook_reset ; yes, restart (if not empty)
|
0
|
77
|
148
|
78 decf_eeprom_address d'2' ; +2 to eeprom address.
|
|
79
|
0
|
80 call I2CREAD ; reads one byte (Slow! Better use Blockread!)
|
|
81
|
148
|
82 movlw 0xFA ; That was a FA ?
|
0
|
83 cpfseq SSPBUF
|
148
|
84 bra menu_logbook2 ; No: continue the fast loop...
|
|
85
|
|
86 ;---- Slow check : was it before or after that one ? ---------------------
|
0
|
87
|
148
|
88 incf_eeprom_address d'1' ; Been one step too far ?
|
|
89 call I2CREAD ; reads one byte (Slow! Better use Blockread!)
|
|
90 movlw 0xFA ; That was a FA ?
|
|
91 xorwf SSPBUF,W
|
151
|
92 bz menu_loop_tooFar ; Got both of them...
|
148
|
93
|
151
|
94 infsnz divemins+0,F ; Advance to the next byte.
|
|
95 incf divemins+1,F
|
|
96 decf_eeprom_address d'2' ; One step back, two steps forward.
|
148
|
97 call I2CREAD ; reads one byte (Slow! Better use Blockread!)
|
|
98 movlw 0xFA ; It was the second FA ?
|
|
99 xorwf SSPBUF,W
|
|
100 bz test_FA_DONE
|
|
101 bra menu_logbook2 ; No: continue the fast loop...
|
|
102
|
|
103 menu_loop_tooFar;
|
151
|
104 decf_eeprom_address d'1' ; So stays pointing at the second one.
|
0
|
105
|
|
106 test_FA_DONE: ; Found 0xFA 0xFA!
|
|
107 movff eeprom_address+0,eeprom_header_address+0 ; store current address into temp register
|
|
108 movff eeprom_address+1,eeprom_header_address+1 ; we must continue search here later
|
148
|
109 incf divenumber,F ; new header found, increase divenumber
|
|
110 bra menu_logbook4 ; Done with searching, display the header!
|
0
|
111
|
|
112 menu_logbook3b:
|
|
113 btfss logbook_page_not_empty ; Was there at least one dive?
|
|
114 goto menu ; Not a single header was found, leave logbook.
|
|
115 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
|
|
116
|
|
117 menu_logbook_reset:
|
|
118 movf divenumber,W
|
|
119 btfsc STATUS,Z ; Was there at least one dive?
|
|
120 bra menu_logbook3b ; No, Nothing to do
|
|
121
|
|
122 bsf all_dives_shown ; Yes
|
|
123 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
|
|
124
|
|
125
|
|
126 menu_logbook4:
|
|
127 ; Adjust eeprom_address to set pointer on first headerbyte
|
148
|
128 incf_eeprom_address d'2' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
|
0
|
129
|
|
130 btfss logbook_profile_view ; Display profile (search routine is used in profileview, too)
|
|
131 bra menu_logbook_display_loop ; No, display overwiev list
|
|
132
|
|
133 movf divesecs,W ; divenumber that is searched
|
|
134 cpfseq divenumber ; current divenumber
|
|
135 bra next_logbook ; No match, continue search
|
|
136 bra display_profile2
|
|
137
|
|
138
|
|
139 menu_logbook_display_loop:
|
|
140 btfsc all_dives_shown ; All dives displayed?
|
|
141 bra menu_logbook_display_loop2 ; Yes, but display first page again.
|
|
142
|
|
143 rcall display_listdive ; display short header for list on current list position
|
|
144
|
|
145 movlw d'5'
|
|
146 cpfseq menupos ; first dive on list (top place)?
|
|
147 bra menu_logbook_display_loop1 ; no, so skip saving of address
|
|
148
|
|
149
|
|
150 movff divenumber,mintemp+0 ; store all registered required to rebuilt the current logbookpage after the detail/profile view
|
|
151 movff eeprom_header_address+0,decodata+0 ; several registers are used as temp registers here
|
|
152 movff eeprom_header_address+1,decodata+1
|
|
153 movff divemins+0,max_pressure+0
|
|
154 movff divemins+1,max_pressure+1
|
|
155
|
|
156 movlw d'3'
|
|
157 addwf decodata+0,F
|
|
158 movlw d'0'
|
|
159 addwfc decodata+1,F ; Re-Adjust pointer again
|
|
160 movlw d'3' ; So first row will be the same again after detail/profile view
|
|
161 subwf max_pressure+0,F
|
|
162 movlw d'0'
|
|
163 subwfb max_pressure+1,F
|
|
164
|
|
165 menu_logbook_display_loop1:
|
|
166 decfsz menupos,F ; List full?
|
|
167 bra next_logbook ; no, search another dive for our current logbook page
|
|
168
|
|
169 menu_logbook_display_loop2:
|
|
170 btfss logbook_page_not_empty ; Was there one dive at all?
|
|
171 bra menu_logbook ; Yes, so reload the first page
|
|
172
|
|
173 call PLED_topline_box ; Draw box
|
|
174 WIN_INVERT .1
|
|
175 DISPLAYTEXT .26 ; "Logbook"
|
|
176 WIN_INVERT .0
|
|
177
|
|
178 DISPLAYTEXT .11 ; Displays "Exit" in the last row on the current page
|
|
179
|
|
180 bcf sleepmode ; clear some flags for user input
|
|
181 bcf menubit2
|
|
182 bcf menubit3
|
|
183 bcf cursor
|
|
184 bcf switch_right
|
|
185 bcf switch_left
|
|
186 clrf timeout_counter2
|
|
187
|
|
188 movlw d'1' ; Set cursor to position 1...
|
|
189 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view
|
|
190 movf mintemp+1,W ; load last cursor position again
|
|
191 movwf menupos ; and set menupos byte
|
|
192 bcf return_from_profileview ; Do this only once while the page is loaded again!
|
|
193
|
|
194 bcf logbook_page_not_empty ; Obviously the current page is NOT empty
|
|
195 call PLED_logbook_cursor
|
|
196
|
|
197 menu_logbook_loop:
|
|
198 call check_switches_logbook
|
|
199
|
|
200 btfsc menubit3 ; SET/MENU?
|
|
201 bra next_logbook3 ; adjust cursor or create new page
|
|
202
|
|
203 btfsc menubit2 ; ENTER?
|
|
204 bra display_profile_or_exit ; view details/profile or exit logbook
|
|
205
|
|
206 btfsc onesecupdate
|
|
207 call timeout_surfmode ; Timeout
|
|
208
|
|
209 btfsc onesecupdate
|
|
210 call set_dive_modes ; Check, if divemode must be entered
|
|
211
|
|
212 bcf onesecupdate ; one second update
|
|
213
|
|
214 btfsc sleepmode ; Timeout?
|
|
215 goto menu ; Yes
|
|
216
|
|
217 btfsc divemode
|
|
218 goto restart ; Enter Divemode if required
|
|
219
|
|
220 bra menu_logbook_loop ; Wait for something to do
|
|
221
|
|
222 display_profile_or_exit:
|
|
223 bcf menubit2 ; debounce
|
|
224 movlw d'6' ; exit?
|
|
225 cpfseq menupos
|
|
226 bra display_profile ; No, show details/profile
|
|
227 goto menu
|
|
228
|
|
229 display_profile:
|
|
230 movff menupos,mintemp+1 ; store current cursor position
|
|
231 bsf return_from_profileview ; tweak search routine to exit after found
|
|
232
|
|
233 movf menupos2,W ; Number of page
|
|
234 mullw d'5'
|
|
235 movf PRODL,W
|
|
236 addwf menupos,W ; page*5+menupos=
|
|
237 movwf divesecs ; # of dive to search
|
|
238
|
|
239 call PLED_ClearScreen ; search for dive
|
|
240 bsf logbook_profile_view ; set flag for search routine
|
|
241
|
|
242 clrf divenumber ; search from scratch
|
|
243 bra menu_logbook1a ; start search
|
|
244 display_profile2:
|
|
245 bcf logbook_profile_view ; clear flag for search routine
|
|
246
|
|
247 call PLED_display_wait_clear
|
204
|
248 call PLED_standard_color
|
0
|
249 WIN_TOP .0
|
|
250 WIN_LEFT .0
|
123
|
251 STRCPY "#"
|
0
|
252
|
|
253 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi
|
|
254 tstfsz lo ; lo=0?
|
|
255 bra display_profile_offset1 ; No, adjust offset
|
|
256 tstfsz hi ; hi=0?
|
|
257 bra display_profile_offset1 ; No, adjust offset
|
|
258 bra display_profile_offset2 ; lo=0 and hi=0 -> skip Offset routine
|
|
259
|
|
260 display_profile_offset1:
|
|
261 movlw d'1'
|
|
262 addwf lo,F
|
|
263 movlw d'0'
|
|
264 addwfc hi,F ; hi:lo = hi:lo + 1
|
|
265 movff lo,sub_a+0
|
|
266 movff hi,sub_a+1
|
|
267 movff divesecs,sub_b+0
|
|
268 clrf sub_b+1
|
|
269 call sub16 ; sub_c = sub_a - sub_b
|
|
270 movff sub_c+0,lo
|
|
271 movff sub_c+1,hi
|
|
272 bsf leftbind
|
|
273 output_16dp d'10' ; # of dive with offset
|
|
274 bra display_profile_offset3 ; Skip normal routine
|
|
275
|
|
276 display_profile_offset2:
|
|
277 movff divesecs,lo
|
|
278 output_99x ; # of dive
|
|
279
|
|
280 display_profile_offset3:
|
123
|
281 PUTC ' '
|
0
|
282 call I2CREAD2
|
|
283 movff SSPBUF,lo ;
|
|
284
|
|
285 call I2CREAD2 ; Skip Profile version
|
|
286 movff SSPBUF,lo ; read month
|
|
287
|
41
|
288 ; movff eeprom_address+0, EventByte ; Store current EEPROM position
|
|
289 ; movff eeprom_address+1, ProfileFlagByte
|
0
|
290 ; Offset to SamplingRate
|
|
291 incf_eeprom_address d'32' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
|
|
292 call I2CREAD ; Read Sampling rate
|
|
293 movff SSPBUF,samplesecs_value ; Copy sampling rate
|
41
|
294 decf_eeprom_address d'32' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000
|
|
295 ; movff EventByte, eeprom_address+0 ; Re-Store current EEPROM position
|
|
296 ; movff ProfileFlagByte, eeprom_address+1 ; Re-Store current EEPROM position
|
0
|
297
|
|
298 ;display_profile2a:
|
|
299
|
|
300 movff lo,convert_value_temp+0 ; Month (in lo, see above)
|
|
301 call I2CREAD2 ; Day
|
|
302 movff SSPBUF,convert_value_temp+1
|
|
303 call I2CREAD2 ; Year
|
|
304 movff SSPBUF,convert_value_temp+2
|
|
305 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
|
|
306
|
123
|
307 PUTC ' '
|
0
|
308 call I2CREAD2 ; hour
|
|
309 movff SSPBUF,lo
|
|
310 output_99x
|
123
|
311 PUTC ':'
|
0
|
312 call I2CREAD2 ; Minute
|
|
313 movff SSPBUF,lo
|
|
314 output_99x
|
|
315 call word_processor ; Display 1st row of details
|
|
316
|
|
317 WIN_TOP .25
|
|
318 WIN_LEFT .05
|
|
319 lfsr FSR2,letter
|
|
320 call I2CREAD2
|
|
321 movff SSPBUF,lo
|
|
322 call I2CREAD2
|
|
323 movff SSPBUF,hi
|
|
324 movff lo,xA+0 ; calculate y-scale for profile display
|
|
325 movff hi,xA+1
|
|
326 movlw d'164' ; 164pixel height available
|
|
327 movwf xB+0
|
|
328 clrf xB+1
|
|
329 call div16x16 ; does xA/xB=xC
|
|
330 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!)
|
|
331 movff xC+1,sim_pressure+1 ; holds HIGH byte of y-scale (mbar/pixel!)
|
|
332 incf sim_pressure+0,F ; increase one, because there may be a remainder
|
|
333 movlw d'0'
|
|
334 addwfc sim_pressure+1,F
|
|
335
|
|
336 bsf leftbind
|
|
337 output_16dp d'3' ; max. depth
|
123
|
338 STRCAT "m "
|
0
|
339 call I2CREAD2
|
|
340 movff SSPBUF,lo
|
|
341 call I2CREAD2
|
|
342 movff SSPBUF,hi
|
|
343
|
|
344 movff lo,xA+0 ; calculate x-scale for profile display
|
|
345 movff hi,xA+1 ; calculate total diveseconds first
|
|
346 movlw d'60' ; 60seconds are one minute
|
|
347 movwf xB+0
|
|
348 clrf xB+1
|
|
349 call mult16x16 ; result is in xC:2 !
|
|
350
|
|
351 bsf leftbind
|
|
352 output_16 ; divetime minutes
|
123
|
353 PUTC d'39'
|
0
|
354 call I2CREAD2
|
|
355 movff SSPBUF,lo
|
|
356 movf lo,W ; add seconds to total seconds
|
|
357 addwf xC+0
|
|
358 movlw d'0'
|
|
359 addwfc xC+1 ; xC:2 now holds total dive seconds!
|
|
360 movff xC+0,xA+0 ; now calculate x-scale value
|
|
361 movff xC+1,xA+1
|
|
362 movlw d'159' ; 159pix width available
|
|
363 movwf xB+0
|
|
364 clrf xB+1
|
|
365 call div16x16 ; xA/xB=xC
|
|
366 movff xC+0,xA+0
|
|
367 movff xC+1,xA+1
|
|
368 movf samplesecs_value,W ; devide through sample interval!
|
|
369 movwf xB+0
|
|
370 clrf xB+1
|
|
371 call div16x16 ; xA/xB=xC
|
|
372 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers
|
|
373 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers
|
|
374 incf profile_temp+0,F ; increase one, because there may be a remainder
|
|
375 movlw d'0'
|
|
376 addwfc profile_temp+1,F
|
|
377
|
|
378 bsf leftbind
|
|
379 output_99x ; divetime seconds
|
123
|
380 STRCAT "\" "
|
0
|
381 call I2CREAD2
|
|
382 movff SSPBUF,lo
|
|
383 call I2CREAD2
|
|
384 movff SSPBUF,hi
|
|
385 movlw d'3'
|
|
386 movwf ignore_digits
|
|
387 bsf leftbind
|
|
388 output_16dp d'2' ; temperature
|
123
|
389 STRCAT_PRINT "°C" ; Display 2nd row of details
|
0
|
390
|
|
391 WIN_TOP .50
|
|
392 WIN_LEFT .05
|
|
393 lfsr FSR2,letter
|
|
394
|
|
395 call I2CREAD2
|
|
396 movff SSPBUF,lo
|
|
397 call I2CREAD2
|
|
398 movff SSPBUF,hi
|
|
399 bsf leftbind
|
|
400 output_16 ; Air pressure before dive
|
199
|
401 STRCAT "mbar "
|
|
402 OUTPUTTEXT .014 ; Desat
|
|
403 PUTC ' '
|
0
|
404
|
|
405 call I2CREAD2
|
|
406 movff SSPBUF,lo
|
|
407 call I2CREAD2
|
|
408 movff SSPBUF,hi
|
|
409 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo)
|
|
410 bsf leftbind
|
|
411 movf lo,W
|
|
412 movff hi,lo
|
|
413 movwf hi ; exchange lo and hi...
|
|
414 output_8 ; Hours
|
123
|
415 PUTC ':'
|
0
|
416 movff hi,lo ; Minutes
|
|
417 output_99x
|
|
418 bcf leftbind
|
|
419 call word_processor ; display 3rd page of details
|
|
420
|
|
421 call I2CREAD2 ; Skip Gas1 current O2
|
|
422 call I2CREAD2 ; Skip Gas1 current HE
|
|
423 call I2CREAD2 ; Skip Gas2 current O2
|
|
424 call I2CREAD2 ; Skip Gas2 current HE
|
|
425 call I2CREAD2 ; Skip Gas3 current O2
|
|
426 call I2CREAD2 ; Skip Gas3 current HE
|
|
427 call I2CREAD2 ; Skip Gas4 current O2
|
|
428 call I2CREAD2 ; Skip Gas4 current HE
|
|
429 call I2CREAD2 ; Skip Gas5 current O2
|
|
430 call I2CREAD2 ; Skip Gas5 current HE
|
|
431 call I2CREAD2 ; Skip Gas6 current O2
|
|
432 call I2CREAD2 ; Skip Gas6 current HE
|
|
433 call I2CREAD2 ; Skip Start Gas
|
|
434 call I2CREAD2 ; Skip Firmware x
|
|
435 call I2CREAD2 ; Skip Firmware y
|
|
436 call I2CREAD2 ; Skip battery
|
|
437 call I2CREAD2 ; Skip battery
|
|
438 call I2CREAD2 ; Skip Sampling rate
|
|
439 call I2CREAD2 ; Read divisor
|
|
440 movff SSPBUF,divisor_temperature ; Store divisor
|
|
441 bcf divisor_temperature,4 ; Clear information length
|
|
442 bcf divisor_temperature,5
|
|
443 bcf divisor_temperature,6
|
|
444 bcf divisor_temperature,7
|
|
445 incf divisor_temperature,F ; increase divisor
|
|
446 movff divisor_temperature,logbook_temp1 ; Store as temp, too
|
|
447 call I2CREAD2 ; Read divisor
|
|
448 movff SSPBUF,divisor_deco ; Store divisor
|
|
449 bcf divisor_deco,4 ; Clear information length
|
|
450 bcf divisor_deco,5
|
|
451 bcf divisor_deco,6
|
|
452 bcf divisor_deco,7
|
|
453 movff divisor_deco,logbook_temp2 ; Store as temp, too
|
|
454 call I2CREAD2 ; Read divisor
|
|
455 movff SSPBUF,divisor_tank ; Store divisor
|
|
456 call I2CREAD2 ; Read divisor
|
|
457 movff SSPBUF,divisor_ppo2 ; Store divisor
|
|
458 call I2CREAD2 ; Read divisor
|
|
459 movff SSPBUF,divisor_deco_debug ; Store divisor
|
|
460 call I2CREAD2 ; Read divisor
|
|
461 movff SSPBUF,divisor_nuy2 ; Store divisor
|
|
462 call I2CREAD2 ; Read Salinity
|
|
463 call I2CREAD2 ; Skip Dummy byte
|
|
464
|
|
465 display_profile2d:
|
|
466 ; Start Profile display
|
|
467
|
|
468 movlw color_deepblue
|
123
|
469 WIN_BOX_COLOR .75, .239, .0, .159
|
0
|
470
|
|
471 call I2CREAD2 ; skip 0xFB (Header-end)
|
|
472 clrf timeout_counter2 ; here: used as counter for depth readings
|
|
473 call I2CREAD2 ; skip 0xFB (Header-end)
|
|
474 movlw d'158'
|
|
475 movwf ignore_digits ; here: used as counter for x-pixels
|
|
476 bcf second_FD ; clear flag
|
|
477 movlw d'5'
|
|
478 movwf timeout_counter3 ; here: used as colum x2 (Start at Colum 5)
|
|
479 movlw d'75' ; Zero-m row
|
|
480 movwf apnoe_mins ; here: used for fill between rows
|
|
481 incf timeout_counter3,W ; Init Column
|
146
|
482
|
|
483 INIT_PIXEL_WROTE timeout_counter3 ; pixel x2
|
0
|
484
|
|
485 profile_display_loop:
|
|
486 movff profile_temp+0,profile_temp2+0
|
|
487 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler
|
|
488 incf profile_temp2+1,F
|
42
|
489 tstfsz profile_temp2+0 ; Must not be Zero
|
|
490 bra profile_display_loop2 ; Not Zero!
|
|
491 incf profile_temp2+0,F ; Zero, Increase!
|
0
|
492
|
|
493 profile_display_loop2:
|
|
494 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo
|
|
495
|
|
496 btfsc second_FD ; end-of profile reached?
|
|
497 bra profile_display_loop_done ; Yes, skip all remaining pixels
|
|
498
|
|
499 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett
|
|
500 movff sim_pressure+1,xB+1
|
|
501 movff lo,xA+0
|
|
502 movff hi,xA+1
|
|
503 call div16x16 ; xA/xB=xC
|
|
504 movlw d'75'
|
|
505 addwf xC+0,F ; add 75 pixel offset to result
|
41
|
506
|
44
|
507 btfsc STATUS,C ; Ignore potential profile errors
|
|
508 movff apnoe_mins,xC+0
|
41
|
509
|
0
|
510 call profile_display_fill ; In this column between this row (xC+0) and the last row (apnoe_mins)
|
|
511 movff xC+0,apnoe_mins ; Store last row for fill routine
|
142
|
512 incf timeout_counter3,F
|
|
513
|
146
|
514 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel.
|
0
|
515
|
|
516 profile_display_skip_loop1: ; skips readings!
|
|
517 dcfsnz profile_temp2+0,F
|
|
518 bra profile_display_loop3 ; check 16bit....
|
|
519
|
|
520 rcall profile_view_get_depth ; reads depth, ignores temp and profile data
|
|
521 bra profile_display_skip_loop1
|
|
522
|
|
523 profile_display_loop3:
|
|
524 decfsz profile_temp2+1,F ; 16 bit x-scaler test
|
|
525 bra profile_display_skip_loop1 ; skips readings!
|
|
526
|
|
527 decfsz ignore_digits,F ; counts x-pixels to zero
|
|
528 bra profile_display_loop ; Not ready yet
|
|
529 ; Done.
|
|
530 profile_display_loop_done:
|
|
531 bcf sleepmode ; clear some flags
|
|
532 bcf menubit2
|
|
533 bcf menubit3
|
|
534 bcf switch_right
|
|
535 bcf switch_left
|
|
536 clrf timeout_counter2
|
|
537
|
|
538 display_profile_loop:
|
|
539 call check_switches_logbook
|
|
540
|
|
541 btfsc menubit2 ; SET/MENU?
|
|
542 bra exit_profileview ; back to list
|
|
543
|
|
544 btfsc menubit3 ; ENTER?
|
33
|
545 bra exit_profileview ; back to list
|
|
546 ; bra profileview_menu ; Switch to the Profileview menu
|
0
|
547
|
|
548 btfsc onesecupdate
|
|
549 call timeout_surfmode ; timeout
|
|
550
|
|
551 btfsc onesecupdate
|
|
552 call set_dive_modes ; check, if divemode must be entered
|
|
553
|
|
554 bcf onesecupdate ; one second update
|
|
555
|
|
556 btfsc sleepmode ; Timeout?
|
|
557 bra exit_profileview ; back to list
|
|
558
|
|
559 btfsc divemode
|
|
560 goto restart ; Enter Divemode if required
|
|
561
|
|
562 bra display_profile_loop ; wait for something to do
|
|
563
|
|
564 profile_display_fill: ; In this column between this row (xC+0) and the last row (apnoe_mins), keep xC+0!!
|
|
565 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins
|
|
566 movf xC+0,W
|
|
567 cpfseq apnoe_mins ; xC+0 = apone_mins?
|
|
568 bra profile_display_fill2 ; No!
|
|
569 return
|
130
|
570
|
0
|
571 profile_display_fill2:
|
|
572 movf xC+0,W
|
|
573 cpfsgt apnoe_mins ; apnoe_mins>xC+0?
|
|
574 bra profile_display_fill_up ; Yes!
|
|
575
|
|
576 profile_display_fill_down: ; Fill downwards from apone_mins to xC+0!
|
|
577 movff apnoe_mins,xC+1 ; Copy
|
|
578 profile_display_fill_down2: ; Loop
|
|
579 decf xC+1,F
|
142
|
580
|
146
|
581 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
|
3
|
582
|
0
|
583 movf xC+0,W
|
|
584 cpfseq xC+1 ; Loop until xC+1=xC+0
|
|
585 bra profile_display_fill_down2
|
|
586 return ; apnoe_mins and xC+0 are untouched
|
|
587
|
|
588 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins!
|
|
589 movff xC+0,xC+1 ; Copy
|
|
590 profile_display_fill_up2: ; Loop
|
|
591 decf xC+1,F
|
142
|
592
|
146
|
593 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
|
3
|
594
|
0
|
595 movf apnoe_mins,W
|
|
596 cpfseq xC+1 ; Loop until xC+1=apnoe_mins
|
|
597 bra profile_display_fill_up2
|
|
598 return ; apnoe_mins and xC+0 are untouched
|
|
599
|
|
600 profile_view_get_depth:
|
|
601 call I2CREAD2 ; read first depth
|
|
602 movff SSPBUF,lo ; low value
|
|
603 call I2CREAD2 ; read first depth
|
|
604 movff SSPBUF,hi ; high value
|
|
605 call I2CREAD2 ; read Profile Flag Byte
|
|
606 movff SSPBUF,timeout_counter2 ; Read Profile Flag Byte
|
|
607 bcf event_occured ; clear flag
|
|
608 btfsc timeout_counter2,7
|
|
609 bsf event_occured ; We also have an Event byte!
|
|
610 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any)
|
|
611 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
|
|
612 movlw 0xFD ; end of profile bytes?
|
|
613 cpfseq lo
|
|
614 bra profile_view_get_depth_new1 ; no 0xFD
|
|
615 movlw 0xFD ; end of profile bytes?
|
|
616 cpfseq hi
|
|
617 bra profile_view_get_depth_new1 ; no 0xFD
|
|
618 bsf second_FD ; End found! Set Flag! Skip remaining pixels!
|
|
619 return
|
|
620
|
|
621 profile_view_get_depth_new1:
|
|
622 tstfsz timeout_counter2 ; Any bytes to ignore
|
|
623 bra profile_view_get_depth_new3 ; Yes (1-127)
|
|
624 return ; No (0)
|
|
625
|
|
626 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
|
|
627 profile_view_get_depth_new3:
|
|
628 call I2CREAD2 ; ignore byte
|
|
629 decfsz timeout_counter2,F ; reduce counter
|
|
630 bra profile_view_get_depth_new3 ; Loop
|
|
631 return
|
|
632
|
|
633 exit_profileview:
|
|
634 bcf sleepmode
|
|
635 clrf timeout_counter2 ; restore all registers to build same page again
|
|
636 movff decodata+0,eeprom_address+0
|
|
637 movff decodata+1,eeprom_address+1
|
|
638 movff max_pressure+0,divemins+0
|
|
639 movff max_pressure+1,divemins+1
|
|
640 movff mintemp+0, divenumber
|
|
641 decf divenumber,F
|
|
642 bcf all_dives_shown
|
|
643
|
|
644 decf menupos2,F
|
|
645
|
|
646 clrf menupos3 ; here: used row on current page
|
|
647 movlw d'5'
|
|
648 movwf menupos ; here: active row on current page
|
|
649 incf menupos2,F ; start new page
|
|
650 call PLED_ClearScreen ; clear details/profile
|
|
651 bra menu_logbook1b ; start search
|
|
652
|
|
653 next_logbook2:
|
|
654 btfsc all_dives_shown ; all shown
|
|
655 goto menu_logbook1 ; all reset
|
|
656
|
|
657 clrf menupos3
|
|
658 movlw d'5'
|
|
659 movwf menupos ;
|
|
660 incf menupos2,F ; start new screen
|
|
661 call PLED_ClearScreen
|
|
662
|
|
663 next_logbook:
|
|
664 movff eeprom_header_address+0,eeprom_address+0
|
|
665 movff eeprom_header_address+1,eeprom_address+1 ; continue search here
|
|
666 goto menu_logbook1b
|
|
667
|
|
668 check_switches_logbook:
|
|
669 btfsc switch_right
|
|
670 bsf menubit3
|
|
671 btfsc switch_left
|
|
672 bsf menubit2 ; Enter
|
|
673 return
|
|
674
|
|
675 next_logbook3:
|
|
676 incf menupos,F
|
|
677 movlw d'7'
|
|
678 cpfseq menupos ; =7?
|
|
679 bra next_logbook3a ; No
|
|
680 bra next_logbook2 ; yes, new page please
|
|
681
|
|
682 next_logbook3a:
|
|
683 incf menupos3,W ;
|
|
684 cpfseq menupos
|
|
685 bra next_logbook3b
|
|
686 movlw d'6'
|
|
687 movwf menupos ; Jump directly to exit if page is not full
|
|
688
|
|
689 next_logbook3b:
|
|
690 clrf timeout_counter2
|
|
691 call PLED_logbook_cursor
|
|
692
|
|
693 bcf switch_right
|
|
694 bcf menubit3 ; clear flag
|
|
695 bra menu_logbook_loop
|
|
696
|
|
697 display_listdive:
|
|
698 bsf logbook_page_not_empty ; Page not empty
|
|
699 incf menupos3,F
|
|
700
|
|
701 btfsc logbook_header_drawn ; "Logbook already displayed?
|
|
702 bra display_listdive1a
|
|
703 call PLED_topline_box ; Draw box
|
|
704 WIN_INVERT .1
|
|
705 DISPLAYTEXT .26 ; "Logbook"
|
|
706 WIN_INVERT .0
|
|
707 bsf logbook_header_drawn
|
|
708
|
|
709 display_listdive1a:
|
|
710 WIN_LEFT .20
|
|
711
|
|
712 movf menupos2,W
|
|
713 mullw d'5'
|
|
714 movf PRODL,W
|
|
715 subwf divenumber,W ; current row on page
|
|
716
|
|
717 mullw d'30' ; x30
|
|
718 movf PRODL,W ; is pixel-row for entry
|
|
719 addlw d'5' ; +5 Pixel, so list entries are at rows 35,65,95,125,155,185
|
|
720 movff WREG,win_top
|
|
721
|
|
722 lfsr FSR2,letter
|
|
723 movff divenumber,lo
|
|
724 output_99x ; # of dive
|
123
|
725 PUTC ' '
|
0
|
726 call I2CREAD2
|
|
727 movff SSPBUF,lo
|
|
728 movlw d'13'
|
|
729 cpfsgt lo ; Skip if lo>13
|
|
730 bra display_listdive2 ; use old format
|
|
731
|
|
732 call I2CREAD2 ; Skip Profile version
|
|
733 movff SSPBUF,lo ; in new format, read month
|
|
734
|
|
735 display_listdive2:
|
|
736 movff lo,convert_value_temp+0 ; Month (in lo, see above)
|
|
737 call I2CREAD2 ; Day
|
|
738 movff SSPBUF,convert_value_temp+1
|
|
739 call I2CREAD2 ; Year
|
|
740 movff SSPBUF,convert_value_temp+2
|
123
|
741 call PLED_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" in s
|
0
|
742
|
|
743
|
|
744 call I2CREAD2 ; hours (Skip)
|
|
745 call I2CREAD2 ; minutes (skip)
|
123
|
746 PUTC ' '
|
0
|
747 call I2CREAD2 ; Depth
|
|
748 movff SSPBUF,lo
|
|
749 call I2CREAD2
|
|
750 movff SSPBUF,hi
|
|
751 bsf leftbind
|
|
752 bsf ignore_digit5 ; Do not display 1cm figure
|
|
753 output_16dp d'3' ; max. depth
|
123
|
754 STRCAT "m "
|
0
|
755 call I2CREAD2
|
|
756 movff SSPBUF,lo
|
|
757 call I2CREAD2
|
|
758 movff SSPBUF,hi
|
|
759 bsf leftbind
|
|
760 output_16 ; Divetime minutes
|
123
|
761 STRCAT_PRINT "'" ; Display header-row in list
|
0
|
762 return
|