comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 371:160b3216b335 64kByte Logbook

x-scale in logbook fixed
author Heinrichsweikamp
date Fri, 10 Jun 2011 13:57:28 +0200
parents 584741726190
children 8781d1cf96d8
comparison
equal deleted inserted replaced
367:584741726190 371:160b3216b335
264 264
265 bra menu_logbook1a_no_get_free ; Start Search for Dive (Without get_free_EEPROM_location) 265 bra menu_logbook1a_no_get_free ; Start Search for Dive (Without get_free_EEPROM_location)
266 266
267 display_profile2: 267 display_profile2:
268 bcf logbook_profile_view ; clear flag for search routine 268 bcf logbook_profile_view ; clear flag for search routine
269
270 clrf average_divesecs+0
271 clrf average_divesecs+1 ; holds amount of read samples
269 272
270 call PLED_display_wait_clear 273 call PLED_display_wait_clear
271 call PLED_standard_color 274 call PLED_standard_color
272 WIN_TOP .0 275 WIN_TOP .0
273 WIN_LEFT .0 276 WIN_LEFT .0
387 390
388 bsf leftbind 391 bsf leftbind
389 PUTC 0x95 ; "duration o dive" icon 392 PUTC 0x95 ; "duration o dive" icon
390 output_16 ; divetime minutes 393 output_16 ; divetime minutes
391 394
392 btfss logbook_format_0x21 ; Dive made with new 0x21 format?
393 bra display_profile_old_spacing ; No
394 ; Yes, get real sample time
395 incf_eeprom_address d'35' ; Skip Bytes in EEPROM
396 call I2CREAD2 ; Total sample time in seconds
397 movff SSPBUF,xA+0
398 call I2CREAD2 ; Total sample time in seconds
399 movff SSPBUF,xA+1
400 movlw LOW d'600' 395 movlw LOW d'600'
401 movwf xB+0 396 movwf xA+0
402 movlw HIGH d'600' 397 movlw HIGH d'600'
403 movwf xB+1 ; A vertical line every 600 seconds 398 movwf xA+1 ; A vertical line every 600 seconds
399 movff samplesecs_value,xB+0 ; Copy sampling rate
400 clrf xB+1
404 call div16x16 ; xA/xB=xC with xA as remainder 401 call div16x16 ; xA/xB=xC with xA as remainder
405 decf_eeprom_address d'37' ; Macro, that subtracts 8Bit from eeprom_address:2 402 movff xC+0,average_depth_hold_total+0
406 bra display_profile_spacing ; continue below 403 movff xC+1,average_depth_hold_total+1
407 404 ;average_depth_hold_total:2 holds interval of samples for vertical 10min line
408 display_profile_old_spacing:
409 ; Compute spacing between 10min lines
410 movff lo,xA+0
411 movff hi,xA+1 ; divetime in minutes
412 movlw d'10'
413 movwf xB+0
414 clrf xB+1 ; A vertical line every 10 minutes
415 call div16x16 ; xA/xB=xC with xA as remainder
416 display_profile_spacing:
417 ; xC now holds number of lines
418 movlw d'1'
419 addwf xC+0 ; Add one line...
420 movff xC+0,xB+0
421 clrf xB+1 ; No more then 255 lines...
422 movlw d'159' ; Available width
423 movwf xA+0
424 clrf xA+1
425 call div16x16 ;xA/xB=xC with xA as remainder
426 ; xC now holds spacing between vertical 10min lines
427 movff xC+0,avr_rel_pressure+0
428 movff xC+1,avr_rel_pressure+1 ; spacing between 10min lines (1-159)
429 405
430 ; Restore divetime in minutes: 406 ; Restore divetime in minutes:
431 btfss logbook_format_0x21 ; Dive made with new 0x21 format? 407 btfss logbook_format_0x21 ; Dive made with new 0x21 format?
432 bra display_profile_old_xscale ; No 408 bra display_profile_old_xscale ; No
433 ; Yes, get real sample time 409 ; Yes, get real sample time
597 movff WREG,win_leftx2 ; Left border (0-159) 573 movff WREG,win_leftx2 ; Left border (0-159)
598 movlw d'164' 574 movlw d'164'
599 movff WREG,win_height 575 movff WREG,win_height
600 movlw d'1' 576 movlw d'1'
601 movff WREG,win_width ; "Window" Width 577 movff WREG,win_width ; "Window" Width
602 display_profile2f:
603 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 578 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
604 movff win_leftx2,WREG ; Get column 579
605 addwf avr_rel_pressure+0,W ; Add column interval distance to win_leftx2 580 ; Draw frame around profile
606 tstfsz avr_rel_pressure+1 ; >255?
607 movlw d'255' ; Yes, make win_leftx2>159 -> Abort here
608 btfsc STATUS,C ; A Cary from the addwf above?
609 movlw d'255' ; Yes, make win_leftx2>159 -> Abort here
610 movff WREG,win_leftx2 ; Result in win_leftx2 again
611 movff win_leftx2,lo ; Get win_leftx2 in Bank1...
612 movlw d'159' ; Limit
613 cpfsgt lo ; >159?
614 bra display_profile2f ; No, draw another line
615
616 movlw color_blue 581 movlw color_blue
617 WIN_FRAME_COLOR .75, .239, .4, .159 ;top, bottom, left, right with color in WREG 582 WIN_FRAME_COLOR .75, .239, .4, .159 ;top, bottom, left, right with color in WREG
618 583
619 call I2CREAD2 ; skip 0xFB (Header-end) 584 call I2CREAD2 ; skip 0xFB (Header-end)
620 clrf timeout_counter2 ; here: used as counter for depth readings 585 clrf timeout_counter2 ; here: used as counter for depth readings
980 movf apnoe_mins,W 945 movf apnoe_mins,W
981 cpfseq xC+1 ; Loop until xC+1=apnoe_mins 946 cpfseq xC+1 ; Loop until xC+1=apnoe_mins
982 bra profile_display_fill_up2 947 bra profile_display_fill_up2
983 return ; apnoe_mins and xC+0 are untouched 948 return ; apnoe_mins and xC+0 are untouched
984 949
985 profile_view_get_depth: 950 profile_view_get_depth:
951 incf average_divesecs+0,F
952 movlw d'0'
953 addwfc average_divesecs+1,F ; Count read pixels
954
955 movf average_divesecs+0,W
956 cpfseq average_depth_hold_total+0
957 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue
958 movf average_divesecs+1,W
959 cpfseq average_depth_hold_total+1
960 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue
961 ; draw a new 10min line here...
962 clrf average_divesecs+0
963 clrf average_divesecs+1 ; clear counting registers for next line
964
965 movlw color_grey
966 call PLED_set_color ; Make this configurable?
967 movlw d'75'
968 movff WREG,win_top
969 incf timeout_counter3,W ; draw one line to right to make sure it's the background of the profile
970 movff WREG,win_leftx2 ; Left border (0-159)
971 movlw d'164'
972 movff WREG,win_height
973 movlw d'1'
974 movff WREG,win_width ; "Window" Width
975 call PLED_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
976
977 ; Now restore current profile color
978 movff average_depth_hold_total+3,active_gas ; restore color
979 dcfsnz active_gas,F
980 movlw color_white ; Color for Gas 1
981 dcfsnz active_gas,F
982 movlw color_green ; Color for Gas 2
983 dcfsnz active_gas,F
984 movlw color_red ; Color for Gas 3
985 dcfsnz active_gas,F
986 movlw color_yellow ; Color for Gas 4
987 dcfsnz active_gas,F
988 movlw color_violet ; Color for Gas 5
989 call PLED_set_color ; Set Color...
990
991 profile_view_get_depth_no_line:
986 call I2CREAD2 ; read first depth 992 call I2CREAD2 ; read first depth
987 movff SSPBUF,lo ; low value 993 movff SSPBUF,lo ; low value
988 call I2CREAD2 ; read first depth 994 call I2CREAD2 ; read first depth
989 movff SSPBUF,hi ; high value 995 movff SSPBUF,hi ; high value
990 call I2CREAD2 ; read Profile Flag Byte 996 call I2CREAD2 ; read Profile Flag Byte
1028 btfss EventByte,5 ; Stored Gas Changed? 1034 btfss EventByte,5 ; Stored Gas Changed?
1029 return ; No, return 1035 return ; No, return
1030 ; Stored Gas changed! 1036 ; Stored Gas changed!
1031 call I2CREAD2 ; Read Gas# 1037 call I2CREAD2 ; Read Gas#
1032 movff SSPBUF,active_gas ; store gas# 1038 movff SSPBUF,active_gas ; store gas#
1039 movff active_gas,average_depth_hold_total+3 ; keep copy to restore color after drawing 10min line
1033 decf timeout_counter2,F ; reduce counter 1040 decf timeout_counter2,F ; reduce counter
1034 dcfsnz active_gas,F 1041 dcfsnz active_gas,F
1035 movlw color_white ; Color for Gas 1 1042 movlw color_white ; Color for Gas 1
1036 dcfsnz active_gas,F 1043 dcfsnz active_gas,F
1037 movlw color_green ; Color for Gas 2 1044 movlw color_green ; Color for Gas 2