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
|
|
248 WIN_TOP .0
|
|
249 WIN_LEFT .0
|
123
|
250 STRCPY "#"
|
0
|
251
|
|
252 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi
|
|
253 tstfsz lo ; lo=0?
|
|
254 bra display_profile_offset1 ; No, adjust offset
|
|
255 tstfsz hi ; hi=0?
|
|
256 bra display_profile_offset1 ; No, adjust offset
|
|
257 bra display_profile_offset2 ; lo=0 and hi=0 -> skip Offset routine
|
|
258
|
|
259 display_profile_offset1:
|
|
260 movlw d'1'
|
|
261 addwf lo,F
|
|
262 movlw d'0'
|
|
263 addwfc hi,F ; hi:lo = hi:lo + 1
|
|
264 movff lo,sub_a+0
|
|
265 movff hi,sub_a+1
|
|
266 movff divesecs,sub_b+0
|
|
267 clrf sub_b+1
|
|
268 call sub16 ; sub_c = sub_a - sub_b
|
|
269 movff sub_c+0,lo
|
|
270 movff sub_c+1,hi
|
|
271 bsf leftbind
|
|
272 output_16dp d'10' ; # of dive with offset
|
|
273 bra display_profile_offset3 ; Skip normal routine
|
|
274
|
|
275 display_profile_offset2:
|
|
276 movff divesecs,lo
|
|
277 output_99x ; # of dive
|
|
278
|
|
279 display_profile_offset3:
|
123
|
280 PUTC ' '
|
0
|
281 call I2CREAD2
|
|
282 movff SSPBUF,lo ;
|
|
283
|
|
284 call I2CREAD2 ; Skip Profile version
|
|
285 movff SSPBUF,lo ; read month
|
|
286
|
41
|
287 ; movff eeprom_address+0, EventByte ; Store current EEPROM position
|
|
288 ; movff eeprom_address+1, ProfileFlagByte
|
0
|
289 ; Offset to SamplingRate
|
|
290 incf_eeprom_address d'32' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
|
|
291 call I2CREAD ; Read Sampling rate
|
|
292 movff SSPBUF,samplesecs_value ; Copy sampling rate
|
41
|
293 decf_eeprom_address d'32' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000
|
|
294 ; movff EventByte, eeprom_address+0 ; Re-Store current EEPROM position
|
|
295 ; movff ProfileFlagByte, eeprom_address+1 ; Re-Store current EEPROM position
|
0
|
296
|
|
297 ;display_profile2a:
|
|
298
|
|
299 movff lo,convert_value_temp+0 ; Month (in lo, see above)
|
|
300 call I2CREAD2 ; Day
|
|
301 movff SSPBUF,convert_value_temp+1
|
|
302 call I2CREAD2 ; Year
|
|
303 movff SSPBUF,convert_value_temp+2
|
|
304 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
|
|
305
|
123
|
306 PUTC ' '
|
0
|
307 call I2CREAD2 ; hour
|
|
308 movff SSPBUF,lo
|
|
309 output_99x
|
123
|
310 PUTC ':'
|
0
|
311 call I2CREAD2 ; Minute
|
|
312 movff SSPBUF,lo
|
|
313 output_99x
|
|
314 call word_processor ; Display 1st row of details
|
|
315
|
|
316 WIN_TOP .25
|
|
317 WIN_LEFT .05
|
|
318 lfsr FSR2,letter
|
|
319 call I2CREAD2
|
|
320 movff SSPBUF,lo
|
|
321 call I2CREAD2
|
|
322 movff SSPBUF,hi
|
|
323 movff lo,xA+0 ; calculate y-scale for profile display
|
|
324 movff hi,xA+1
|
|
325 movlw d'164' ; 164pixel height available
|
|
326 movwf xB+0
|
|
327 clrf xB+1
|
|
328 call div16x16 ; does xA/xB=xC
|
|
329 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!)
|
|
330 movff xC+1,sim_pressure+1 ; holds HIGH byte of y-scale (mbar/pixel!)
|
|
331 incf sim_pressure+0,F ; increase one, because there may be a remainder
|
|
332 movlw d'0'
|
|
333 addwfc sim_pressure+1,F
|
|
334
|
|
335 bsf leftbind
|
|
336 output_16dp d'3' ; max. depth
|
123
|
337 STRCAT "m "
|
0
|
338 call I2CREAD2
|
|
339 movff SSPBUF,lo
|
|
340 call I2CREAD2
|
|
341 movff SSPBUF,hi
|
|
342
|
|
343 movff lo,xA+0 ; calculate x-scale for profile display
|
|
344 movff hi,xA+1 ; calculate total diveseconds first
|
|
345 movlw d'60' ; 60seconds are one minute
|
|
346 movwf xB+0
|
|
347 clrf xB+1
|
|
348 call mult16x16 ; result is in xC:2 !
|
|
349
|
|
350 bsf leftbind
|
|
351 output_16 ; divetime minutes
|
123
|
352 PUTC d'39'
|
0
|
353 call I2CREAD2
|
|
354 movff SSPBUF,lo
|
|
355 movf lo,W ; add seconds to total seconds
|
|
356 addwf xC+0
|
|
357 movlw d'0'
|
|
358 addwfc xC+1 ; xC:2 now holds total dive seconds!
|
|
359 movff xC+0,xA+0 ; now calculate x-scale value
|
|
360 movff xC+1,xA+1
|
|
361 movlw d'159' ; 159pix width available
|
|
362 movwf xB+0
|
|
363 clrf xB+1
|
|
364 call div16x16 ; xA/xB=xC
|
|
365 movff xC+0,xA+0
|
|
366 movff xC+1,xA+1
|
|
367 movf samplesecs_value,W ; devide through sample interval!
|
|
368 movwf xB+0
|
|
369 clrf xB+1
|
|
370 call div16x16 ; xA/xB=xC
|
|
371 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers
|
|
372 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers
|
|
373 incf profile_temp+0,F ; increase one, because there may be a remainder
|
|
374 movlw d'0'
|
|
375 addwfc profile_temp+1,F
|
|
376
|
|
377 bsf leftbind
|
|
378 output_99x ; divetime seconds
|
123
|
379 STRCAT "\" "
|
0
|
380 call I2CREAD2
|
|
381 movff SSPBUF,lo
|
|
382 call I2CREAD2
|
|
383 movff SSPBUF,hi
|
|
384 movlw d'3'
|
|
385 movwf ignore_digits
|
|
386 bsf leftbind
|
|
387 output_16dp d'2' ; temperature
|
123
|
388 STRCAT_PRINT "°C" ; Display 2nd row of details
|
0
|
389
|
|
390 WIN_TOP .50
|
|
391 WIN_LEFT .05
|
|
392 lfsr FSR2,letter
|
|
393
|
|
394 call I2CREAD2
|
|
395 movff SSPBUF,lo
|
|
396 call I2CREAD2
|
|
397 movff SSPBUF,hi
|
|
398 bsf leftbind
|
|
399 output_16 ; Air pressure before dive
|
199
|
400 STRCAT "mbar "
|
|
401 OUTPUTTEXT .014 ; Desat
|
|
402 PUTC ' '
|
0
|
403
|
|
404 call I2CREAD2
|
|
405 movff SSPBUF,lo
|
|
406 call I2CREAD2
|
|
407 movff SSPBUF,hi
|
|
408 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo)
|
|
409 bsf leftbind
|
|
410 movf lo,W
|
|
411 movff hi,lo
|
|
412 movwf hi ; exchange lo and hi...
|
|
413 output_8 ; Hours
|
123
|
414 PUTC ':'
|
0
|
415 movff hi,lo ; Minutes
|
|
416 output_99x
|
|
417 bcf leftbind
|
|
418 call word_processor ; display 3rd page of details
|
|
419
|
|
420 call I2CREAD2 ; Skip Gas1 current O2
|
|
421 call I2CREAD2 ; Skip Gas1 current HE
|
|
422 call I2CREAD2 ; Skip Gas2 current O2
|
|
423 call I2CREAD2 ; Skip Gas2 current HE
|
|
424 call I2CREAD2 ; Skip Gas3 current O2
|
|
425 call I2CREAD2 ; Skip Gas3 current HE
|
|
426 call I2CREAD2 ; Skip Gas4 current O2
|
|
427 call I2CREAD2 ; Skip Gas4 current HE
|
|
428 call I2CREAD2 ; Skip Gas5 current O2
|
|
429 call I2CREAD2 ; Skip Gas5 current HE
|
|
430 call I2CREAD2 ; Skip Gas6 current O2
|
|
431 call I2CREAD2 ; Skip Gas6 current HE
|
|
432 call I2CREAD2 ; Skip Start Gas
|
|
433 call I2CREAD2 ; Skip Firmware x
|
|
434 call I2CREAD2 ; Skip Firmware y
|
|
435 call I2CREAD2 ; Skip battery
|
|
436 call I2CREAD2 ; Skip battery
|
|
437 call I2CREAD2 ; Skip Sampling rate
|
|
438 call I2CREAD2 ; Read divisor
|
|
439 movff SSPBUF,divisor_temperature ; Store divisor
|
|
440 bcf divisor_temperature,4 ; Clear information length
|
|
441 bcf divisor_temperature,5
|
|
442 bcf divisor_temperature,6
|
|
443 bcf divisor_temperature,7
|
|
444 incf divisor_temperature,F ; increase divisor
|
|
445 movff divisor_temperature,logbook_temp1 ; Store as temp, too
|
|
446 call I2CREAD2 ; Read divisor
|
|
447 movff SSPBUF,divisor_deco ; Store divisor
|
|
448 bcf divisor_deco,4 ; Clear information length
|
|
449 bcf divisor_deco,5
|
|
450 bcf divisor_deco,6
|
|
451 bcf divisor_deco,7
|
|
452 movff divisor_deco,logbook_temp2 ; Store as temp, too
|
|
453 call I2CREAD2 ; Read divisor
|
|
454 movff SSPBUF,divisor_tank ; Store divisor
|
|
455 call I2CREAD2 ; Read divisor
|
|
456 movff SSPBUF,divisor_ppo2 ; Store divisor
|
|
457 call I2CREAD2 ; Read divisor
|
|
458 movff SSPBUF,divisor_deco_debug ; Store divisor
|
|
459 call I2CREAD2 ; Read divisor
|
|
460 movff SSPBUF,divisor_nuy2 ; Store divisor
|
|
461 call I2CREAD2 ; Read Salinity
|
|
462 call I2CREAD2 ; Skip Dummy byte
|
|
463
|
|
464 display_profile2d:
|
|
465 ; Start Profile display
|
|
466
|
|
467 movlw color_deepblue
|
123
|
468 WIN_BOX_COLOR .75, .239, .0, .159
|
0
|
469
|
|
470 call I2CREAD2 ; skip 0xFB (Header-end)
|
|
471 clrf timeout_counter2 ; here: used as counter for depth readings
|
|
472 call I2CREAD2 ; skip 0xFB (Header-end)
|
|
473 movlw d'158'
|
|
474 movwf ignore_digits ; here: used as counter for x-pixels
|
|
475 bcf second_FD ; clear flag
|
|
476 movlw d'5'
|
|
477 movwf timeout_counter3 ; here: used as colum x2 (Start at Colum 5)
|
|
478 movlw d'75' ; Zero-m row
|
|
479 movwf apnoe_mins ; here: used for fill between rows
|
|
480 incf timeout_counter3,W ; Init Column
|
146
|
481
|
|
482 INIT_PIXEL_WROTE timeout_counter3 ; pixel x2
|
0
|
483
|
|
484 profile_display_loop:
|
|
485 movff profile_temp+0,profile_temp2+0
|
|
486 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler
|
|
487 incf profile_temp2+1,F
|
42
|
488 tstfsz profile_temp2+0 ; Must not be Zero
|
|
489 bra profile_display_loop2 ; Not Zero!
|
|
490 incf profile_temp2+0,F ; Zero, Increase!
|
0
|
491
|
|
492 profile_display_loop2:
|
|
493 rcall profile_view_get_depth ; reads depth, ignores temp and profile data -> hi, lo
|
|
494
|
|
495 btfsc second_FD ; end-of profile reached?
|
|
496 bra profile_display_loop_done ; Yes, skip all remaining pixels
|
|
497
|
|
498 movff sim_pressure+0,xB+0 ; devide pressure in mbar/quant for row offsett
|
|
499 movff sim_pressure+1,xB+1
|
|
500 movff lo,xA+0
|
|
501 movff hi,xA+1
|
|
502 call div16x16 ; xA/xB=xC
|
|
503 movlw d'75'
|
|
504 addwf xC+0,F ; add 75 pixel offset to result
|
41
|
505
|
44
|
506 btfsc STATUS,C ; Ignore potential profile errors
|
|
507 movff apnoe_mins,xC+0
|
41
|
508
|
0
|
509 call profile_display_fill ; In this column between this row (xC+0) and the last row (apnoe_mins)
|
|
510 movff xC+0,apnoe_mins ; Store last row for fill routine
|
142
|
511 incf timeout_counter3,F
|
|
512
|
146
|
513 PIXEL_WRITE timeout_counter3,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel.
|
0
|
514
|
|
515 profile_display_skip_loop1: ; skips readings!
|
|
516 dcfsnz profile_temp2+0,F
|
|
517 bra profile_display_loop3 ; check 16bit....
|
|
518
|
|
519 rcall profile_view_get_depth ; reads depth, ignores temp and profile data
|
|
520 bra profile_display_skip_loop1
|
|
521
|
|
522 profile_display_loop3:
|
|
523 decfsz profile_temp2+1,F ; 16 bit x-scaler test
|
|
524 bra profile_display_skip_loop1 ; skips readings!
|
|
525
|
|
526 decfsz ignore_digits,F ; counts x-pixels to zero
|
|
527 bra profile_display_loop ; Not ready yet
|
|
528 ; Done.
|
|
529 profile_display_loop_done:
|
|
530 bcf sleepmode ; clear some flags
|
|
531 bcf menubit2
|
|
532 bcf menubit3
|
|
533 bcf switch_right
|
|
534 bcf switch_left
|
|
535 clrf timeout_counter2
|
|
536
|
|
537 display_profile_loop:
|
|
538 call check_switches_logbook
|
|
539
|
|
540 btfsc menubit2 ; SET/MENU?
|
|
541 bra exit_profileview ; back to list
|
|
542
|
|
543 btfsc menubit3 ; ENTER?
|
33
|
544 bra exit_profileview ; back to list
|
|
545 ; bra profileview_menu ; Switch to the Profileview menu
|
0
|
546
|
|
547 btfsc onesecupdate
|
|
548 call timeout_surfmode ; timeout
|
|
549
|
|
550 btfsc onesecupdate
|
|
551 call set_dive_modes ; check, if divemode must be entered
|
|
552
|
|
553 bcf onesecupdate ; one second update
|
|
554
|
|
555 btfsc sleepmode ; Timeout?
|
|
556 bra exit_profileview ; back to list
|
|
557
|
|
558 btfsc divemode
|
|
559 goto restart ; Enter Divemode if required
|
|
560
|
|
561 bra display_profile_loop ; wait for something to do
|
|
562
|
|
563 profile_display_fill: ; In this column between this row (xC+0) and the last row (apnoe_mins), keep xC+0!!
|
|
564 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins
|
|
565 movf xC+0,W
|
|
566 cpfseq apnoe_mins ; xC+0 = apone_mins?
|
|
567 bra profile_display_fill2 ; No!
|
|
568 return
|
130
|
569
|
0
|
570 profile_display_fill2:
|
|
571 movf xC+0,W
|
|
572 cpfsgt apnoe_mins ; apnoe_mins>xC+0?
|
|
573 bra profile_display_fill_up ; Yes!
|
|
574
|
|
575 profile_display_fill_down: ; Fill downwards from apone_mins to xC+0!
|
|
576 movff apnoe_mins,xC+1 ; Copy
|
|
577 profile_display_fill_down2: ; Loop
|
|
578 decf xC+1,F
|
142
|
579
|
146
|
580 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
|
3
|
581
|
0
|
582 movf xC+0,W
|
|
583 cpfseq xC+1 ; Loop until xC+1=xC+0
|
|
584 bra profile_display_fill_down2
|
|
585 return ; apnoe_mins and xC+0 are untouched
|
|
586
|
|
587 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins!
|
|
588 movff xC+0,xC+1 ; Copy
|
|
589 profile_display_fill_up2: ; Loop
|
|
590 decf xC+1,F
|
142
|
591
|
146
|
592 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
|
3
|
593
|
0
|
594 movf apnoe_mins,W
|
|
595 cpfseq xC+1 ; Loop until xC+1=apnoe_mins
|
|
596 bra profile_display_fill_up2
|
|
597 return ; apnoe_mins and xC+0 are untouched
|
|
598
|
|
599 profile_view_get_depth:
|
|
600 call I2CREAD2 ; read first depth
|
|
601 movff SSPBUF,lo ; low value
|
|
602 call I2CREAD2 ; read first depth
|
|
603 movff SSPBUF,hi ; high value
|
|
604 call I2CREAD2 ; read Profile Flag Byte
|
|
605 movff SSPBUF,timeout_counter2 ; Read Profile Flag Byte
|
|
606 bcf event_occured ; clear flag
|
|
607 btfsc timeout_counter2,7
|
|
608 bsf event_occured ; We also have an Event byte!
|
|
609 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any)
|
|
610 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
|
|
611 movlw 0xFD ; end of profile bytes?
|
|
612 cpfseq lo
|
|
613 bra profile_view_get_depth_new1 ; no 0xFD
|
|
614 movlw 0xFD ; end of profile bytes?
|
|
615 cpfseq hi
|
|
616 bra profile_view_get_depth_new1 ; no 0xFD
|
|
617 bsf second_FD ; End found! Set Flag! Skip remaining pixels!
|
|
618 return
|
|
619
|
|
620 profile_view_get_depth_new1:
|
|
621 tstfsz timeout_counter2 ; Any bytes to ignore
|
|
622 bra profile_view_get_depth_new3 ; Yes (1-127)
|
|
623 return ; No (0)
|
|
624
|
|
625 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
|
|
626 profile_view_get_depth_new3:
|
|
627 call I2CREAD2 ; ignore byte
|
|
628 decfsz timeout_counter2,F ; reduce counter
|
|
629 bra profile_view_get_depth_new3 ; Loop
|
|
630 return
|
|
631
|
|
632 exit_profileview:
|
|
633 bcf sleepmode
|
|
634 clrf timeout_counter2 ; restore all registers to build same page again
|
|
635 movff decodata+0,eeprom_address+0
|
|
636 movff decodata+1,eeprom_address+1
|
|
637 movff max_pressure+0,divemins+0
|
|
638 movff max_pressure+1,divemins+1
|
|
639 movff mintemp+0, divenumber
|
|
640 decf divenumber,F
|
|
641 bcf all_dives_shown
|
|
642
|
|
643 decf menupos2,F
|
|
644
|
|
645 clrf menupos3 ; here: used row on current page
|
|
646 movlw d'5'
|
|
647 movwf menupos ; here: active row on current page
|
|
648 incf menupos2,F ; start new page
|
|
649 call PLED_ClearScreen ; clear details/profile
|
|
650 bra menu_logbook1b ; start search
|
|
651
|
|
652 next_logbook2:
|
|
653 btfsc all_dives_shown ; all shown
|
|
654 goto menu_logbook1 ; all reset
|
|
655
|
|
656 clrf menupos3
|
|
657 movlw d'5'
|
|
658 movwf menupos ;
|
|
659 incf menupos2,F ; start new screen
|
|
660 call PLED_ClearScreen
|
|
661
|
|
662 next_logbook:
|
|
663 movff eeprom_header_address+0,eeprom_address+0
|
|
664 movff eeprom_header_address+1,eeprom_address+1 ; continue search here
|
|
665 goto menu_logbook1b
|
|
666
|
|
667 check_switches_logbook:
|
|
668 btfsc switch_right
|
|
669 bsf menubit3
|
|
670 btfsc switch_left
|
|
671 bsf menubit2 ; Enter
|
|
672 return
|
|
673
|
|
674 next_logbook3:
|
|
675 incf menupos,F
|
|
676 movlw d'7'
|
|
677 cpfseq menupos ; =7?
|
|
678 bra next_logbook3a ; No
|
|
679 bra next_logbook2 ; yes, new page please
|
|
680
|
|
681 next_logbook3a:
|
|
682 incf menupos3,W ;
|
|
683 cpfseq menupos
|
|
684 bra next_logbook3b
|
|
685 movlw d'6'
|
|
686 movwf menupos ; Jump directly to exit if page is not full
|
|
687
|
|
688 next_logbook3b:
|
|
689 clrf timeout_counter2
|
|
690 call PLED_logbook_cursor
|
|
691
|
|
692 bcf switch_right
|
|
693 bcf menubit3 ; clear flag
|
|
694 bra menu_logbook_loop
|
|
695
|
|
696 display_listdive:
|
|
697 bsf logbook_page_not_empty ; Page not empty
|
|
698 incf menupos3,F
|
|
699
|
|
700 btfsc logbook_header_drawn ; "Logbook already displayed?
|
|
701 bra display_listdive1a
|
|
702 call PLED_topline_box ; Draw box
|
|
703 WIN_INVERT .1
|
|
704 DISPLAYTEXT .26 ; "Logbook"
|
|
705 WIN_INVERT .0
|
|
706 bsf logbook_header_drawn
|
|
707
|
|
708 display_listdive1a:
|
|
709 WIN_LEFT .20
|
|
710
|
|
711 movf menupos2,W
|
|
712 mullw d'5'
|
|
713 movf PRODL,W
|
|
714 subwf divenumber,W ; current row on page
|
|
715
|
|
716 mullw d'30' ; x30
|
|
717 movf PRODL,W ; is pixel-row for entry
|
|
718 addlw d'5' ; +5 Pixel, so list entries are at rows 35,65,95,125,155,185
|
|
719 movff WREG,win_top
|
|
720
|
|
721 lfsr FSR2,letter
|
|
722 movff divenumber,lo
|
|
723 output_99x ; # of dive
|
123
|
724 PUTC ' '
|
0
|
725 call I2CREAD2
|
|
726 movff SSPBUF,lo
|
|
727 movlw d'13'
|
|
728 cpfsgt lo ; Skip if lo>13
|
|
729 bra display_listdive2 ; use old format
|
|
730
|
|
731 call I2CREAD2 ; Skip Profile version
|
|
732 movff SSPBUF,lo ; in new format, read month
|
|
733
|
|
734 display_listdive2:
|
|
735 movff lo,convert_value_temp+0 ; Month (in lo, see above)
|
|
736 call I2CREAD2 ; Day
|
|
737 movff SSPBUF,convert_value_temp+1
|
|
738 call I2CREAD2 ; Year
|
|
739 movff SSPBUF,convert_value_temp+2
|
123
|
740 call PLED_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" in s
|
0
|
741
|
|
742
|
|
743 call I2CREAD2 ; hours (Skip)
|
|
744 call I2CREAD2 ; minutes (skip)
|
123
|
745 PUTC ' '
|
0
|
746 call I2CREAD2 ; Depth
|
|
747 movff SSPBUF,lo
|
|
748 call I2CREAD2
|
|
749 movff SSPBUF,hi
|
|
750 bsf leftbind
|
|
751 bsf ignore_digit5 ; Do not display 1cm figure
|
|
752 output_16dp d'3' ; max. depth
|
123
|
753 STRCAT "m "
|
0
|
754 call I2CREAD2
|
|
755 movff SSPBUF,lo
|
|
756 call I2CREAD2
|
|
757 movff SSPBUF,hi
|
|
758 bsf leftbind
|
|
759 output_16 ; Divetime minutes
|
123
|
760 STRCAT_PRINT "'" ; Display header-row in list
|
0
|
761 return
|