comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 207:d2a38470f0b2

faster logbook speed
author heinrichsweikamp
date Sat, 19 Feb 2011 12:53:25 +0100
parents aad4f6e25c2d
children 3b961f17aa3a
comparison
equal deleted inserted replaced
206:3414169a2bde 207:d2a38470f0b2
26 ; searches external EEPROM for dive headers and displays them in a list 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 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 28 ; does not require a FAT, will work with other profile intervals as ten seconds, too
29 29
30 menu_logbook: 30 menu_logbook:
31 bcf return_from_profileview ; clear some flags 31 bcf return_from_profileview ; clear some flags
32 ;call enable_rs232 32 ;call enable_rs232
33 menu_logbook1: 33 menu_logbook1:
34 bcf logbook_header_drawn 34 bcf logbook_header_drawn
35 call PLED_ClearScreen ; Clear screen 35 call PLED_ClearScreen ; Clear screen
36 bcf all_dives_shown ; clear some flags 36 bcf all_dives_shown ; clear some flags
48 clrf divemins+0 ; Here: used as temp variables 48 clrf divemins+0 ; Here: used as temp variables
49 clrf divemins+1 49 clrf divemins+1
50 call I2CReset ; Reset I2C Bus 50 call I2CReset ; Reset I2C Bus
51 call get_free_EEPROM_location ; search from "here" backwards through the external memory 51 call get_free_EEPROM_location ; search from "here" backwards through the external memory
52 52
53 movff eeprom_address+0,logbook_temp5
54 movff eeprom_address+1,logbook_temp6 ; Store Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
55
56 menu_logbook1a_no_get_free: ; Without repeated search for dive
53 movlw d'5' 57 movlw d'5'
54 movwf menupos ; Here: stores current position on display (5-x) 58 movwf menupos ; Here: stores current position on display (5-x)
55 59
56 ;----------------------------------------------------------------------------- 60 ;-----------------------------------------------------------------------------
57 ; search external EEPROM backwards from eeprom_address 61 ; search external EEPROM backwards from eeprom_address
108 movff eeprom_address+1,eeprom_header_address+1 ; we must continue search here later 112 movff eeprom_address+1,eeprom_header_address+1 ; we must continue search here later
109 incf divenumber,F ; new header found, increase divenumber 113 incf divenumber,F ; new header found, increase divenumber
110 bra menu_logbook4 ; Done with searching, display the header! 114 bra menu_logbook4 ; Done with searching, display the header!
111 115
112 menu_logbook3b: 116 menu_logbook3b:
113 btfss logbook_page_not_empty ; Was there at least one dive? 117 btfss logbook_page_not_empty ; Was there at least one dive?
114 goto menu ; Not a single header was found, leave logbook. 118 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) 119 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
116 120
117 menu_logbook_reset: 121 menu_logbook_reset:
118 movf divenumber,W 122 movf divenumber,W
119 btfsc STATUS,Z ; Was there at least one dive? 123 btfsc STATUS,Z ; Was there at least one dive?
120 bra menu_logbook3b ; No, Nothing to do 124 bra menu_logbook3b ; No, Nothing to do
121 125
122 bsf all_dives_shown ; Yes 126 bsf all_dives_shown ; Yes
123 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster) 127 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
124 128
125 129
126 menu_logbook4: 130 menu_logbook4:
127 ; Adjust eeprom_address to set pointer on first headerbyte 131 ; Adjust eeprom_address to set pointer on first headerbyte
128 incf_eeprom_address d'2' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 132 incf_eeprom_address d'2' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
161 subwf max_pressure+0,F 165 subwf max_pressure+0,F
162 movlw d'0' 166 movlw d'0'
163 subwfb max_pressure+1,F 167 subwfb max_pressure+1,F
164 168
165 menu_logbook_display_loop1: 169 menu_logbook_display_loop1:
166 decfsz menupos,F ; List full? 170 decfsz menupos,F ; List full?
167 bra next_logbook ; no, search another dive for our current logbook page 171 bra next_logbook ; no, search another dive for our current logbook page
168 172
169 menu_logbook_display_loop2: 173 menu_logbook_display_loop2:
170 btfss logbook_page_not_empty ; Was there one dive at all? 174 btfss logbook_page_not_empty ; Was there one dive at all?
171 bra menu_logbook ; Yes, so reload the first page 175 bra menu_logbook ; Yes, so reload the first page
172 176
173 call PLED_topline_box ; Draw box 177 call PLED_topline_box ; Draw box
174 WIN_INVERT .1 178 WIN_INVERT .1
175 DISPLAYTEXT .26 ; "Logbook" 179 DISPLAYTEXT .26 ; "Logbook"
176 WIN_INVERT .0 180 WIN_INVERT .0
177 181
178 DISPLAYTEXT .11 ; Displays "Exit" in the last row on the current page 182 DISPLAYTEXT .11 ; Displays "Exit" in the last row on the current page
179 183
180 bcf sleepmode ; clear some flags for user input 184 bcf sleepmode ; clear some flags for user input
181 bcf menubit2 185 bcf menubit2
182 bcf menubit3 186 bcf menubit3
183 bcf cursor 187 bcf cursor
184 bcf switch_right 188 bcf switch_right
185 bcf switch_left 189 bcf switch_left
186 clrf timeout_counter2 190 clrf timeout_counter2
187 191
188 movlw d'1' ; Set cursor to position 1... 192 movlw d'1' ; Set cursor to position 1...
189 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view 193 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view
190 movf mintemp+1,W ; load last cursor position again 194 movf mintemp+1,W ; load last cursor position again
237 movwf divesecs ; # of dive to search 241 movwf divesecs ; # of dive to search
238 242
239 call PLED_ClearScreen ; search for dive 243 call PLED_ClearScreen ; search for dive
240 bsf logbook_profile_view ; set flag for search routine 244 bsf logbook_profile_view ; set flag for search routine
241 245
242 clrf divenumber ; search from scratch 246 clrf divenumber ; search from scratch
243 bra menu_logbook1a ; start search 247
248 movff logbook_temp5,eeprom_address+0
249 movff logbook_temp6,eeprom_address+1 ; Restore Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
250
251 bra menu_logbook1a_no_get_free ; Start Search for Dive (Without get_free_EEPROM_location)
252
244 display_profile2: 253 display_profile2:
245 bcf logbook_profile_view ; clear flag for search routine 254 bcf logbook_profile_view ; clear flag for search routine
246 255
247 call PLED_display_wait_clear 256 call PLED_display_wait_clear
248 call PLED_standard_color 257 call PLED_standard_color
272 bsf leftbind 281 bsf leftbind
273 output_16dp d'10' ; # of dive with offset 282 output_16dp d'10' ; # of dive with offset
274 bra display_profile_offset3 ; Skip normal routine 283 bra display_profile_offset3 ; Skip normal routine
275 284
276 display_profile_offset2: 285 display_profile_offset2:
277 movff divesecs,lo 286 movff divesecs,lo ;
278 output_99x ; # of dive 287 output_99x ; # of dive
279 288
280 display_profile_offset3: 289 display_profile_offset3:
281 PUTC ' ' 290 PUTC ' '
282 call I2CREAD2
283 movff SSPBUF,lo ;
284
285 call I2CREAD2 ; Skip Profile version 291 call I2CREAD2 ; Skip Profile version
286 movff SSPBUF,lo ; read month 292 call I2CREAD2 ; read month
287 293 movff SSPBUF,lo ; store in lo
288 ; movff eeprom_address+0, EventByte ; Store current EEPROM position 294
289 ; movff eeprom_address+1, ProfileFlagByte
290 ; Offset to SamplingRate 295 ; Offset to SamplingRate
291 incf_eeprom_address d'32' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 296 incf_eeprom_address d'32' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
292 call I2CREAD ; Read Sampling rate 297 call I2CREAD ; Read Sampling rate
293 movff SSPBUF,samplesecs_value ; Copy sampling rate 298 movff SSPBUF,samplesecs_value ; Copy sampling rate
294 decf_eeprom_address d'32' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000 299 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
297
298 ;display_profile2a:
299 300
300 movff lo,convert_value_temp+0 ; Month (in lo, see above) 301 movff lo,convert_value_temp+0 ; Month (in lo, see above)
301 call I2CREAD2 ; Day 302 call I2CREAD2 ; Day
302 movff SSPBUF,convert_value_temp+1 303 movff SSPBUF,convert_value_temp+1
303 call I2CREAD2 ; Year 304 call I2CREAD2 ; Year
331 movff xC+1,sim_pressure+1 ; holds HIGH byte of y-scale (mbar/pixel!) 332 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 incf sim_pressure+0,F ; increase one, because there may be a remainder
333 movlw d'0' 334 movlw d'0'
334 addwfc sim_pressure+1,F 335 addwfc sim_pressure+1,F
335 336
336 bsf leftbind 337 bsf leftbind
337 output_16dp d'3' ; max. depth 338 output_16dp d'3' ; max. depth
338 STRCAT "m " 339 STRCAT "m "
339 call I2CREAD2 340 call I2CREAD2
340 movff SSPBUF,lo 341 movff SSPBUF,lo
341 call I2CREAD2 342 call I2CREAD2
346 movlw d'60' ; 60seconds are one minute 347 movlw d'60' ; 60seconds are one minute
347 movwf xB+0 348 movwf xB+0
348 clrf xB+1 349 clrf xB+1
349 call mult16x16 ; result is in xC:2 ! 350 call mult16x16 ; result is in xC:2 !
350 351
351 bsf leftbind 352 bsf leftbind
352 output_16 ; divetime minutes 353 output_16 ; divetime minutes
353 PUTC d'39' 354 PUTC d'39'
354 call I2CREAD2 355 call I2CREAD2
355 movff SSPBUF,lo 356 movff SSPBUF,lo
356 movf lo,W ; add seconds to total seconds 357 movf lo,W ; add seconds to total seconds
373 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers 374 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 incf profile_temp+0,F ; increase one, because there may be a remainder
375 movlw d'0' 376 movlw d'0'
376 addwfc profile_temp+1,F 377 addwfc profile_temp+1,F
377 378
378 bsf leftbind 379 bsf leftbind
379 output_99x ; divetime seconds 380 output_99x ; divetime seconds
380 STRCAT "\" " 381 STRCAT "\" "
381 call I2CREAD2 382 call I2CREAD2
382 movff SSPBUF,lo 383 movff SSPBUF,lo
383 call I2CREAD2 384 call I2CREAD2
384 movff SSPBUF,hi 385 movff SSPBUF,hi
385 movlw d'3' 386 movlw d'3'
386 movwf ignore_digits 387 movwf ignore_digits
387 bsf leftbind 388 bsf leftbind
388 output_16dp d'2' ; temperature 389 output_16dp d'2' ; temperature
389 STRCAT_PRINT "°C" ; Display 2nd row of details 390 STRCAT_PRINT "°C" ; Display 2nd row of details
390 391
391 WIN_TOP .50 392 WIN_TOP .50
392 WIN_LEFT .05 393 WIN_LEFT .05
393 lfsr FSR2,letter 394 lfsr FSR2,letter
394 395
395 call I2CREAD2 396 call I2CREAD2 ; read Air pressure
396 movff SSPBUF,lo 397 movff SSPBUF,lo
397 call I2CREAD2 398 call I2CREAD2 ; read Air pressure
398 movff SSPBUF,hi 399 movff SSPBUF,hi
399 bsf leftbind 400 bsf leftbind
400 output_16 ; Air pressure before dive 401 output_16 ; Air pressure before dive
401 STRCAT "mbar " 402 STRCAT "mbar "
402 OUTPUTTEXT .014 ; Desat 403 OUTPUTTEXT .014 ; Desat
403 PUTC ' ' 404 PUTC ' '
404 405
405 call I2CREAD2 406 call I2CREAD2 ; read Desaturation time
406 movff SSPBUF,lo 407 movff SSPBUF,lo
407 call I2CREAD2 408 call I2CREAD2 ; read Desaturation time
408 movff SSPBUF,hi 409 movff SSPBUF,hi
409 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo) 410 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo)
410 bsf leftbind 411 bsf leftbind
411 movf lo,W 412 movf lo,W
412 movff hi,lo 413 movff hi,lo
413 movwf hi ; exchange lo and hi... 414 movwf hi ; exchange lo and hi...
416 movff hi,lo ; Minutes 417 movff hi,lo ; Minutes
417 output_99x 418 output_99x
418 bcf leftbind 419 bcf leftbind
419 call word_processor ; display 3rd page of details 420 call word_processor ; display 3rd page of details
420 421
421 call I2CREAD2 ; Skip Gas1 current O2 422 incf_eeprom_address d'18' ; Skip 18Bytes in EEPROM (faster)
422 call I2CREAD2 ; Skip Gas1 current HE 423
423 call I2CREAD2 ; Skip Gas2 current O2 424 ; Do not remove comments below!
424 call I2CREAD2 ; Skip Gas2 current HE 425 ; call I2CREAD2 ; Skip Gas1 current O2
425 call I2CREAD2 ; Skip Gas3 current O2 426 ; call I2CREAD2 ; Skip Gas1 current HE
426 call I2CREAD2 ; Skip Gas3 current HE 427 ; call I2CREAD2 ; Skip Gas2 current O2
427 call I2CREAD2 ; Skip Gas4 current O2 428 ; call I2CREAD2 ; Skip Gas2 current HE
428 call I2CREAD2 ; Skip Gas4 current HE 429 ; call I2CREAD2 ; Skip Gas3 current O2
429 call I2CREAD2 ; Skip Gas5 current O2 430 ; call I2CREAD2 ; Skip Gas3 current HE
430 call I2CREAD2 ; Skip Gas5 current HE 431 ; call I2CREAD2 ; Skip Gas4 current O2
431 call I2CREAD2 ; Skip Gas6 current O2 432 ; call I2CREAD2 ; Skip Gas4 current HE
432 call I2CREAD2 ; Skip Gas6 current HE 433 ; call I2CREAD2 ; Skip Gas5 current O2
433 call I2CREAD2 ; Skip Start Gas 434 ; call I2CREAD2 ; Skip Gas5 current HE
434 call I2CREAD2 ; Skip Firmware x 435 ; call I2CREAD2 ; Skip Gas6 current O2
435 call I2CREAD2 ; Skip Firmware y 436 ; call I2CREAD2 ; Skip Gas6 current HE
436 call I2CREAD2 ; Skip battery 437 ; call I2CREAD2 ; Skip Start Gas
437 call I2CREAD2 ; Skip battery 438 ; call I2CREAD2 ; Skip Firmware x
438 call I2CREAD2 ; Skip Sampling rate 439 ; call I2CREAD2 ; Skip Firmware y
440 ; call I2CREAD2 ; Skip battery
441 ; call I2CREAD2 ; Skip battery
442 ; call I2CREAD2 ; Skip Sampling rate
443
439 call I2CREAD2 ; Read divisor 444 call I2CREAD2 ; Read divisor
440 movff SSPBUF,divisor_temperature ; Store divisor 445 movff SSPBUF,divisor_temperature ; Store divisor
441 bcf divisor_temperature,4 ; Clear information length 446 bcf divisor_temperature,4 ; Clear information length
442 bcf divisor_temperature,5 447 bcf divisor_temperature,5
443 bcf divisor_temperature,6 448 bcf divisor_temperature,6
458 call I2CREAD2 ; Read divisor 463 call I2CREAD2 ; Read divisor
459 movff SSPBUF,divisor_deco_debug ; Store divisor 464 movff SSPBUF,divisor_deco_debug ; Store divisor
460 call I2CREAD2 ; Read divisor 465 call I2CREAD2 ; Read divisor
461 movff SSPBUF,divisor_nuy2 ; Store divisor 466 movff SSPBUF,divisor_nuy2 ; Store divisor
462 call I2CREAD2 ; Read Salinity 467 call I2CREAD2 ; Read Salinity
463 call I2CREAD2 ; Skip Dummy byte 468 call I2CREAD2 ; Skip GF_HI (Upper nibble), GF_LO (Lower nibble)
464 469
465 display_profile2d: 470 display_profile2d:
466 ; Start Profile display 471 ; Start Profile display
467
468 movlw color_deepblue 472 movlw color_deepblue
469 WIN_BOX_COLOR .75, .239, .0, .159 473 WIN_BOX_COLOR .75, .239, .0, .159 ; Background "image"
470 474
471 call I2CREAD2 ; skip 0xFB (Header-end) 475 call I2CREAD2 ; skip 0xFB (Header-end)
472 clrf timeout_counter2 ; here: used as counter for depth readings 476 clrf timeout_counter2 ; here: used as counter for depth readings
473 call I2CREAD2 ; skip 0xFB (Header-end) 477 call I2CREAD2 ; skip 0xFB (Header-end)
474 movlw d'158' 478 movlw d'158'
621 profile_view_get_depth_new1: 625 profile_view_get_depth_new1:
622 tstfsz timeout_counter2 ; Any bytes to ignore 626 tstfsz timeout_counter2 ; Any bytes to ignore
623 bra profile_view_get_depth_new3 ; Yes (1-127) 627 bra profile_view_get_depth_new3 ; Yes (1-127)
624 return ; No (0) 628 return ; No (0)
625 629
626 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
627 profile_view_get_depth_new3: 630 profile_view_get_depth_new3:
628 call I2CREAD2 ; ignore byte 631 movf timeout_counter2,W ; number of additional bytes to ignore (0-127)
629 decfsz timeout_counter2,F ; reduce counter 632 call incf_eeprom_address0 ; increases bytes in eeprom_address:2 with 0x8000 bank switching
630 bra profile_view_get_depth_new3 ; Loop
631 return 633 return
634
635 ;Keep comments for future temperature graph
636 ; call I2CREAD2 ; ignore byte
637 ; decfsz timeout_counter2,F ; reduce counter
638 ; bra profile_view_get_depth_new3 ; Loop
639 ; return
632 640
633 exit_profileview: 641 exit_profileview:
634 bcf sleepmode 642 bcf sleepmode
635 clrf timeout_counter2 ; restore all registers to build same page again 643 clrf timeout_counter2 ; restore all registers to build same page again
636 movff decodata+0,eeprom_address+0 644 movff decodata+0,eeprom_address+0