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
|
|
92 bz menu_loop_tooFar ; Got it !
|
|
93
|
|
94 decf_eeprom_address d'2' ; Instead, not far enough ?
|
|
95 call I2CREAD ; reads one byte (Slow! Better use Blockread!)
|
|
96 infsnz divemins+0,F ; Keep in sync (-1+2 == +1)
|
|
97 incf divemins+1,F
|
|
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;
|
|
104 movlw -.1 ; Correct counter too,
|
|
105 addwf divemins+0 ; by doing a 16bit decrement.
|
|
106 movlw 0
|
|
107 addwfc divemins+1
|
0
|
108
|
|
109 test_FA_DONE: ; Found 0xFA 0xFA!
|
|
110 movff eeprom_address+0,eeprom_header_address+0 ; store current address into temp register
|
|
111 movff eeprom_address+1,eeprom_header_address+1 ; we must continue search here later
|
148
|
112 incf divenumber,F ; new header found, increase divenumber
|
|
113 bra menu_logbook4 ; Done with searching, display the header!
|
0
|
114
|
|
115 menu_logbook3b:
|
|
116 btfss logbook_page_not_empty ; Was there at least one dive?
|
|
117 goto menu ; Not a single header was found, leave logbook.
|
|
118 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
|
|
119
|
|
120 menu_logbook_reset:
|
|
121 movf divenumber,W
|
|
122 btfsc STATUS,Z ; Was there at least one dive?
|
|
123 bra menu_logbook3b ; No, Nothing to do
|
|
124
|
|
125 bsf all_dives_shown ; Yes
|
|
126 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
|
|
127
|
|
128
|
|
129 menu_logbook4:
|
|
130 ; Adjust eeprom_address to set pointer on first headerbyte
|
148
|
131 incf_eeprom_address d'2' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
|
0
|
132
|
|
133 btfss logbook_profile_view ; Display profile (search routine is used in profileview, too)
|
|
134 bra menu_logbook_display_loop ; No, display overwiev list
|
|
135
|
|
136 movf divesecs,W ; divenumber that is searched
|
|
137 cpfseq divenumber ; current divenumber
|
|
138 bra next_logbook ; No match, continue search
|
|
139 bra display_profile2
|
|
140
|
|
141
|
|
142 menu_logbook_display_loop:
|
|
143 btfsc all_dives_shown ; All dives displayed?
|
|
144 bra menu_logbook_display_loop2 ; Yes, but display first page again.
|
|
145
|
|
146 rcall display_listdive ; display short header for list on current list position
|
|
147
|
|
148 movlw d'5'
|
|
149 cpfseq menupos ; first dive on list (top place)?
|
|
150 bra menu_logbook_display_loop1 ; no, so skip saving of address
|
|
151
|
|
152
|
|
153 movff divenumber,mintemp+0 ; store all registered required to rebuilt the current logbookpage after the detail/profile view
|
|
154 movff eeprom_header_address+0,decodata+0 ; several registers are used as temp registers here
|
|
155 movff eeprom_header_address+1,decodata+1
|
|
156 movff divemins+0,max_pressure+0
|
|
157 movff divemins+1,max_pressure+1
|
|
158
|
|
159 movlw d'3'
|
|
160 addwf decodata+0,F
|
|
161 movlw d'0'
|
|
162 addwfc decodata+1,F ; Re-Adjust pointer again
|
|
163 movlw d'3' ; So first row will be the same again after detail/profile view
|
|
164 subwf max_pressure+0,F
|
|
165 movlw d'0'
|
|
166 subwfb max_pressure+1,F
|
|
167
|
|
168 menu_logbook_display_loop1:
|
|
169 decfsz menupos,F ; List full?
|
|
170 bra next_logbook ; no, search another dive for our current logbook page
|
|
171
|
|
172 menu_logbook_display_loop2:
|
|
173 btfss logbook_page_not_empty ; Was there one dive at all?
|
|
174 bra menu_logbook ; Yes, so reload the first page
|
|
175
|
|
176 call PLED_topline_box ; Draw box
|
|
177 WIN_INVERT .1
|
|
178 DISPLAYTEXT .26 ; "Logbook"
|
|
179 WIN_INVERT .0
|
|
180
|
|
181 DISPLAYTEXT .11 ; Displays "Exit" in the last row on the current page
|
|
182
|
|
183 bcf sleepmode ; clear some flags for user input
|
|
184 bcf menubit2
|
|
185 bcf menubit3
|
|
186 bcf cursor
|
|
187 bcf switch_right
|
|
188 bcf switch_left
|
|
189 clrf timeout_counter2
|
|
190
|
|
191 movlw d'1' ; Set cursor to position 1...
|
|
192 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view
|
|
193 movf mintemp+1,W ; load last cursor position again
|
|
194 movwf menupos ; and set menupos byte
|
|
195 bcf return_from_profileview ; Do this only once while the page is loaded again!
|
|
196
|
|
197 bcf logbook_page_not_empty ; Obviously the current page is NOT empty
|
|
198 call PLED_logbook_cursor
|
|
199
|
|
200 menu_logbook_loop:
|
|
201 call check_switches_logbook
|
|
202
|
|
203 btfsc menubit3 ; SET/MENU?
|
|
204 bra next_logbook3 ; adjust cursor or create new page
|
|
205
|
|
206 btfsc menubit2 ; ENTER?
|
|
207 bra display_profile_or_exit ; view details/profile or exit logbook
|
|
208
|
|
209 btfsc onesecupdate
|
|
210 call timeout_surfmode ; Timeout
|
|
211
|
|
212 btfsc onesecupdate
|
|
213 call set_dive_modes ; Check, if divemode must be entered
|
|
214
|
|
215 bcf onesecupdate ; one second update
|
|
216
|
|
217 btfsc sleepmode ; Timeout?
|
|
218 goto menu ; Yes
|
|
219
|
|
220 btfsc divemode
|
|
221 goto restart ; Enter Divemode if required
|
|
222
|
|
223 bra menu_logbook_loop ; Wait for something to do
|
|
224
|
|
225 display_profile_or_exit:
|
|
226 bcf menubit2 ; debounce
|
|
227 movlw d'6' ; exit?
|
|
228 cpfseq menupos
|
|
229 bra display_profile ; No, show details/profile
|
|
230 goto menu
|
|
231
|
|
232 display_profile:
|
|
233 movff menupos,mintemp+1 ; store current cursor position
|
|
234 bsf return_from_profileview ; tweak search routine to exit after found
|
|
235
|
|
236 movf menupos2,W ; Number of page
|
|
237 mullw d'5'
|
|
238 movf PRODL,W
|
|
239 addwf menupos,W ; page*5+menupos=
|
|
240 movwf divesecs ; # of dive to search
|
|
241
|
|
242 call PLED_ClearScreen ; search for dive
|
|
243 bsf logbook_profile_view ; set flag for search routine
|
|
244
|
|
245 clrf divenumber ; search from scratch
|
|
246 bra menu_logbook1a ; start search
|
|
247 display_profile2:
|
|
248 bcf logbook_profile_view ; clear flag for search routine
|
|
249
|
|
250 call PLED_display_wait_clear
|
|
251 WIN_TOP .0
|
|
252 WIN_LEFT .0
|
123
|
253 STRCPY "#"
|
0
|
254
|
|
255 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi
|
|
256 tstfsz lo ; lo=0?
|
|
257 bra display_profile_offset1 ; No, adjust offset
|
|
258 tstfsz hi ; hi=0?
|
|
259 bra display_profile_offset1 ; No, adjust offset
|
|
260 bra display_profile_offset2 ; lo=0 and hi=0 -> skip Offset routine
|
|
261
|
|
262 display_profile_offset1:
|
|
263 movlw d'1'
|
|
264 addwf lo,F
|
|
265 movlw d'0'
|
|
266 addwfc hi,F ; hi:lo = hi:lo + 1
|
|
267 movff lo,sub_a+0
|
|
268 movff hi,sub_a+1
|
|
269 movff divesecs,sub_b+0
|
|
270 clrf sub_b+1
|
|
271 call sub16 ; sub_c = sub_a - sub_b
|
|
272 movff sub_c+0,lo
|
|
273 movff sub_c+1,hi
|
|
274 bsf leftbind
|
|
275 output_16dp d'10' ; # of dive with offset
|
|
276 bra display_profile_offset3 ; Skip normal routine
|
|
277
|
|
278 display_profile_offset2:
|
|
279 movff divesecs,lo
|
|
280 output_99x ; # of dive
|
|
281
|
|
282 display_profile_offset3:
|
123
|
283 PUTC ' '
|
0
|
284 call I2CREAD2
|
|
285 movff SSPBUF,lo ;
|
|
286
|
|
287 call I2CREAD2 ; Skip Profile version
|
|
288 movff SSPBUF,lo ; read month
|
|
289
|
41
|
290 ; movff eeprom_address+0, EventByte ; Store current EEPROM position
|
|
291 ; movff eeprom_address+1, ProfileFlagByte
|
0
|
292 ; Offset to SamplingRate
|
|
293 incf_eeprom_address d'32' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
|
|
294 call I2CREAD ; Read Sampling rate
|
|
295 movff SSPBUF,samplesecs_value ; Copy sampling rate
|
41
|
296 decf_eeprom_address d'32' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000
|
|
297 ; movff EventByte, eeprom_address+0 ; Re-Store current EEPROM position
|
|
298 ; movff ProfileFlagByte, eeprom_address+1 ; Re-Store current EEPROM position
|
0
|
299
|
|
300 ;display_profile2a:
|
|
301
|
|
302 movff lo,convert_value_temp+0 ; Month (in lo, see above)
|
|
303 call I2CREAD2 ; Day
|
|
304 movff SSPBUF,convert_value_temp+1
|
|
305 call I2CREAD2 ; Year
|
|
306 movff SSPBUF,convert_value_temp+2
|
|
307 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
|
|
308
|
123
|
309 PUTC ' '
|
0
|
310 call I2CREAD2 ; hour
|
|
311 movff SSPBUF,lo
|
|
312 output_99x
|
123
|
313 PUTC ':'
|
0
|
314 call I2CREAD2 ; Minute
|
|
315 movff SSPBUF,lo
|
|
316 output_99x
|
|
317 call word_processor ; Display 1st row of details
|
|
318
|
|
319 WIN_TOP .25
|
|
320 WIN_LEFT .05
|
|
321 lfsr FSR2,letter
|
|
322 call I2CREAD2
|
|
323 movff SSPBUF,lo
|
|
324 call I2CREAD2
|
|
325 movff SSPBUF,hi
|
|
326 movff lo,xA+0 ; calculate y-scale for profile display
|
|
327 movff hi,xA+1
|
|
328 movlw d'164' ; 164pixel height available
|
|
329 movwf xB+0
|
|
330 clrf xB+1
|
|
331 call div16x16 ; does xA/xB=xC
|
|
332 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!)
|
|
333 movff xC+1,sim_pressure+1 ; holds HIGH byte of y-scale (mbar/pixel!)
|
|
334 incf sim_pressure+0,F ; increase one, because there may be a remainder
|
|
335 movlw d'0'
|
|
336 addwfc sim_pressure+1,F
|
|
337
|
|
338 bsf leftbind
|
|
339 output_16dp d'3' ; max. depth
|
123
|
340 STRCAT "m "
|
0
|
341 call I2CREAD2
|
|
342 movff SSPBUF,lo
|
|
343 call I2CREAD2
|
|
344 movff SSPBUF,hi
|
|
345
|
|
346 movff lo,xA+0 ; calculate x-scale for profile display
|
|
347 movff hi,xA+1 ; calculate total diveseconds first
|
|
348 movlw d'60' ; 60seconds are one minute
|
|
349 movwf xB+0
|
|
350 clrf xB+1
|
|
351 call mult16x16 ; result is in xC:2 !
|
|
352
|
|
353 bsf leftbind
|
|
354 output_16 ; divetime minutes
|
123
|
355 PUTC d'39'
|
0
|
356 call I2CREAD2
|
|
357 movff SSPBUF,lo
|
|
358 movf lo,W ; add seconds to total seconds
|
|
359 addwf xC+0
|
|
360 movlw d'0'
|
|
361 addwfc xC+1 ; xC:2 now holds total dive seconds!
|
|
362 movff xC+0,xA+0 ; now calculate x-scale value
|
|
363 movff xC+1,xA+1
|
|
364 movlw d'159' ; 159pix width available
|
|
365 movwf xB+0
|
|
366 clrf xB+1
|
|
367 call div16x16 ; xA/xB=xC
|
|
368 movff xC+0,xA+0
|
|
369 movff xC+1,xA+1
|
|
370 movf samplesecs_value,W ; devide through sample interval!
|
|
371 movwf xB+0
|
|
372 clrf xB+1
|
|
373 call div16x16 ; xA/xB=xC
|
|
374 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers
|
|
375 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers
|
|
376 incf profile_temp+0,F ; increase one, because there may be a remainder
|
|
377 movlw d'0'
|
|
378 addwfc profile_temp+1,F
|
|
379
|
|
380 bsf leftbind
|
|
381 output_99x ; divetime seconds
|
123
|
382 STRCAT "\" "
|
0
|
383 call I2CREAD2
|
|
384 movff SSPBUF,lo
|
|
385 call I2CREAD2
|
|
386 movff SSPBUF,hi
|
|
387 movlw d'3'
|
|
388 movwf ignore_digits
|
|
389 bsf leftbind
|
|
390 output_16dp d'2' ; temperature
|
123
|
391 STRCAT_PRINT "°C" ; Display 2nd row of details
|
0
|
392
|
|
393 WIN_TOP .50
|
|
394 WIN_LEFT .05
|
|
395 lfsr FSR2,letter
|
|
396
|
|
397 call I2CREAD2
|
|
398 movff SSPBUF,lo
|
|
399 call I2CREAD2
|
|
400 movff SSPBUF,hi
|
|
401 bsf leftbind
|
|
402 output_16 ; Air pressure before dive
|
123
|
403 STRCAT "mbar Desat "
|
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
|