comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 208:3b961f17aa3a

dynamic scale for logbook view
author heinrichsweikamp
date Sat, 19 Feb 2011 18:44:22 +0100
parents d2a38470f0b2
children cdba979821ee
comparison
equal deleted inserted replaced
207:d2a38470f0b2 208:3b961f17aa3a
43 43
44 menu_logbook1a: 44 menu_logbook1a:
45 WIN_INVERT .1 45 WIN_INVERT .1
46 DISPLAYTEXT .12 ;" Wait.." 46 DISPLAYTEXT .12 ;" Wait.."
47 WIN_INVERT .0 47 WIN_INVERT .0
48 call I2CReset ; Reset I2C Bus
49 call get_free_EEPROM_location ; search from "here" backwards through the external memory
50
51 movff eeprom_address+0,logbook_temp5
52 movff eeprom_address+1,logbook_temp6 ; Store Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
53
54 menu_logbook1a_no_get_free: ; Without repeated search for dive
48 clrf divemins+0 ; Here: used as temp variables 55 clrf divemins+0 ; Here: used as temp variables
49 clrf divemins+1 56 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 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
57 movlw d'5' 57 movlw d'5'
58 movwf menupos ; Here: stores current position on display (5-x) 58 movwf menupos ; Here: stores current position on display (5-x)
59 59
60 ;----------------------------------------------------------------------------- 60 ;-----------------------------------------------------------------------------
61 ; search external EEPROM backwards from eeprom_address 61 ; search external EEPROM backwards from eeprom_address
301 movff lo,convert_value_temp+0 ; Month (in lo, see above) 301 movff lo,convert_value_temp+0 ; Month (in lo, see above)
302 call I2CREAD2 ; Day 302 call I2CREAD2 ; Day
303 movff SSPBUF,convert_value_temp+1 303 movff SSPBUF,convert_value_temp+1
304 call I2CREAD2 ; Year 304 call I2CREAD2 ; Year
305 movff SSPBUF,convert_value_temp+2 305 movff SSPBUF,convert_value_temp+2
306 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 306 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
307 307
308 PUTC ' ' 308 PUTC ' '
309 call I2CREAD2 ; hour 309 call I2CREAD2 ; hour
310 movff SSPBUF,lo 310 movff SSPBUF,lo
311 output_99x 311 output_99x
316 call word_processor ; Display 1st row of details 316 call word_processor ; Display 1st row of details
317 317
318 WIN_TOP .25 318 WIN_TOP .25
319 WIN_LEFT .05 319 WIN_LEFT .05
320 lfsr FSR2,letter 320 lfsr FSR2,letter
321 call I2CREAD2 321 call I2CREAD2 ; read max depth
322 movff SSPBUF,lo 322 movff SSPBUF,lo
323 call I2CREAD2 323 call I2CREAD2 ; read max depth
324 movff SSPBUF,hi 324 movff SSPBUF,hi
325 movff lo,xA+0 ; calculate y-scale for profile display 325 movff lo,xA+0 ; calculate y-scale for profile display
326 movff hi,xA+1 326 movff hi,xA+1
327 movlw d'164' ; 164pixel height available 327 movlw d'164' ; 164pixel height available
328 movwf xB+0 328 movwf xB+0
331 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!) 331 movff xC+0,sim_pressure+0 ; holds LOW byte of y-scale (mbar/pixel!)
332 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!)
333 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
334 movlw d'0' 334 movlw d'0'
335 addwfc sim_pressure+1,F 335 addwfc sim_pressure+1,F
336 movlw LOW d'164000' ; 164pixel*1000 height
337 movwf xC+0
338 movlw HIGH d'164000' ; 164pixel*1000 height
339 movwf xC+1
340 movlw UPPER d'164000' ; 164pixel*1000 height
341 movwf xC+2
342 clrf xC+3
343
344 movff lo,xB+0 ; Max. Depth in mBar
345 movff hi,xB+1 ; Max. Depth in mBar
346 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
347
348 movff xC+0,last_temperature+0 ;
349 movff xC+1,last_temperature+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line)
336 350
337 bsf leftbind 351 bsf leftbind
338 output_16dp d'3' ; max. depth 352 output_16dp d'3' ; max. depth
339 STRCAT "m " 353 STRCAT "m "
340 call I2CREAD2 354 call I2CREAD2 ; divetime in minutes
341 movff SSPBUF,lo 355 movff SSPBUF,lo
342 call I2CREAD2 356 call I2CREAD2
343 movff SSPBUF,hi 357 movff SSPBUF,hi ; divetime in minutes
344 358
345 movff lo,xA+0 ; calculate x-scale for profile display 359 movff lo,xA+0 ; calculate x-scale for profile display
346 movff hi,xA+1 ; calculate total diveseconds first 360 movff hi,xA+1 ; calculate total diveseconds first
347 movlw d'60' ; 60seconds are one minute 361 movlw d'60' ; 60seconds are one minute...
348 movwf xB+0 362 movwf xB+0
349 clrf xB+1 363 clrf xB+1
350 call mult16x16 ; result is in xC:2 ! 364 call mult16x16 ; result is in xC:2 !
351 365
352 bsf leftbind 366 bsf leftbind
353 output_16 ; divetime minutes 367 output_16 ; divetime minutes
354 PUTC d'39' 368
355 call I2CREAD2 369 ; Compute spacing between 10min lines
370 movff lo,xA+0
371 movff hi,xA+1 ; divetime in minutes
372 movlw d'10'
373 movwf xB+0
374 clrf xB+1 ; A vertical line every 10 minutes
375 call div16x16 ;xA/xB=xC with xA as remainder
376 ; xC now holds number of lines
377 movlw d'1'
378 addwf xC+0 ; Add one line...
379 movff xC+0,xB+0
380 clrf xB+1 ; No more then 255 lines...
381 movlw d'159' ; Available width
382 movwf xA+0
383 clrf xA+1
384 call div16x16 ;xA/xB=xC with xA as remainder
385 ; xC now holds spacing between vertical 10min lines
386 movff xC+0,avr_rel_pressure+0
387 movff xC+1,avr_rel_pressure+1 ; spacing between 10min lines (1-159)
388
389 ; Restore divetime in minutes:
390 movff lo,xA+0 ; calculate x-scale for profile display
391 movff hi,xA+1 ; calculate total diveseconds first
392 movlw d'60' ; 60seconds are one minute...
393 movwf xB+0
394 clrf xB+1
395 call mult16x16 ; result is in xC:2 !
396
397 PUTC d'39' ;"'"
398 call I2CREAD2 ; read divetime seconds
356 movff SSPBUF,lo 399 movff SSPBUF,lo
357 movf lo,W ; add seconds to total seconds 400 movf lo,W ; add seconds to total seconds
358 addwf xC+0 401 addwf xC+0
359 movlw d'0' 402 movlw d'0'
360 addwfc xC+1 ; xC:2 now holds total dive seconds! 403 addwfc xC+1 ; xC:2 now holds total dive seconds!
373 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers 416 movff xC+0,profile_temp+0 ; 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 417 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers
375 incf profile_temp+0,F ; increase one, because there may be a remainder 418 incf profile_temp+0,F ; increase one, because there may be a remainder
376 movlw d'0' 419 movlw d'0'
377 addwfc profile_temp+1,F 420 addwfc profile_temp+1,F
421
378 422
379 bsf leftbind 423 bsf leftbind
380 output_99x ; divetime seconds 424 output_99x ; divetime seconds
381 STRCAT "\" " 425 STRCAT "\" "
382 call I2CREAD2 426 call I2CREAD2
467 call I2CREAD2 ; Read Salinity 511 call I2CREAD2 ; Read Salinity
468 call I2CREAD2 ; Skip GF_HI (Upper nibble), GF_LO (Lower nibble) 512 call I2CREAD2 ; Skip GF_HI (Upper nibble), GF_LO (Lower nibble)
469 513
470 display_profile2d: 514 display_profile2d:
471 ; Start Profile display 515 ; Start Profile display
472 movlw color_deepblue 516 ; Write 0m X-Line..
473 WIN_BOX_COLOR .75, .239, .0, .159 ; Background "image" 517 movlw color_grey
474 518 call PLED_set_color ; Make this configurable?
519
520 movlw d'75'
521 movff WREG,win_top
522 movlw d'5'
523 movff WREG,win_leftx2 ; Left border (0-159)
524 movlw d'1'
525 movff WREG,win_height
526 movlw d'155'
527 movff WREG,win_width ; Right border (0-159)
528 display_profile2e:
529 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
530 movff win_top,WREG ; Get row
531 addwf last_temperature+0,W ; Add line interval distance to win_top
532 tstfsz last_temperature+1 ; >255?
533 movlw d'255' ; Yes, make win_top>239 -> Abort here
534 btfsc STATUS,C ; A Cary from the addwf above?
535 movlw d'255' ; Yes, make win_top>239 -> Abort here
536 movff WREG,win_top ; Result in win_top again
537 movff win_top,lo ; Get win_top in Bank1...
538 movlw d'239' ; Limit
539 cpfsgt lo ; >239?
540 bra display_profile2e ; No, draw another line
541
542 ; Write 0min Y-Line..
543 movlw color_grey
544 call PLED_set_color ; Make this configurable?
545
546 movlw d'75'
547 movff WREG,win_top
548 movlw d'4'
549 movff WREG,win_leftx2 ; Left border (0-159)
550 movlw d'164'
551 movff WREG,win_height
552 movlw d'1'
553 movff WREG,win_width ; "Window" Width
554 display_profile2f:
555 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
556 movff win_leftx2,WREG ; Get column
557 addwf avr_rel_pressure+0,W ; Add column interval distance to win_leftx2
558 tstfsz avr_rel_pressure+1 ; >255?
559 movlw d'255' ; Yes, make win_leftx2>159 -> Abort here
560 btfsc STATUS,C ; A Cary from the addwf above?
561 movlw d'255' ; Yes, make win_leftx2>159 -> Abort here
562 movff WREG,win_leftx2 ; Result in win_leftx2 again
563 movff win_leftx2,lo ; Get win_leftx2 in Bank1...
564 movlw d'159' ; Limit
565 cpfsgt lo ; >159?
566 bra display_profile2f ; No, draw another line
567
568
475 call I2CREAD2 ; skip 0xFB (Header-end) 569 call I2CREAD2 ; skip 0xFB (Header-end)
476 clrf timeout_counter2 ; here: used as counter for depth readings 570 clrf timeout_counter2 ; here: used as counter for depth readings
477 call I2CREAD2 ; skip 0xFB (Header-end) 571 call I2CREAD2 ; skip 0xFB (Header-end)
478 movlw d'158' 572 movlw d'158'
479 movwf ignore_digits ; here: used as counter for x-pixels 573 movwf ignore_digits ; here: used as counter for x-pixels