comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 351:5c186a72cb5d 64kByte Logbook

Debugging the new logbook format, 64kB download routine
author heinrichsweikamp
date Tue, 31 May 2011 22:09:17 +0200
parents 7250ca7c8d24
children 64da813d4726
comparison
equal deleted inserted replaced
350:7250ca7c8d24 351:5c186a72cb5d
69 DISPLAYTEXT .12 ;" Wait.." 69 DISPLAYTEXT .12 ;" Wait.."
70 WIN_INVERT .0 70 WIN_INVERT .0
71 71
72 ;---- fast loop: check every other byte ---------------------------------- 72 ;---- fast loop: check every other byte ----------------------------------
73 menu_logbook2: 73 menu_logbook2:
74 infsnz divemins+0,F ; increase 16Bit value 74 movlw d'2'
75 incf divemins+1,F 75 addwf divemins+0,F
76 infsnz divemins+0,F ; increase 16Bit value, twice 76 movlw d'0'
77 incf divemins+1,F 77 addwfc divemins+1,F ; increase 16Bit value, twice
78 78
79 movlw 0xFF 79 movlw 0xFF
80 cpfseq divemins+1 ; =0xFFFF ?
81 bra menu_logbook2a ; No
80 cpfseq divemins+0 ; =0xFFFF ? 82 cpfseq divemins+0 ; =0xFFFF ?
81 bra menu_logbook2a ; No 83 bra menu_logbook2a ; No
82
83 cpfseq divemins+1 ; =0xFFFF ?
84 bra menu_logbook2a ; No
85
86 bra menu_logbook_reset ; yes, restart (if not empty) 84 bra menu_logbook_reset ; yes, restart (if not empty)
87 85
88 menu_logbook2a: 86 menu_logbook2a:
87 movlw 0x00
88 cpfseq divemins+1 ; =0x0000 ?
89 bra menu_logbook2b ; No
90 cpfseq divemins+0 ; =0x0000 ?
91 bra menu_logbook2b ; No
92 bra menu_logbook_reset ; yes, restart (if not empty)
93
94 menu_logbook2b:
89 decf_eeprom_address d'2' ; -2 to eeprom address. 95 decf_eeprom_address d'2' ; -2 to eeprom address.
90 96
91 call I2CREAD ; reads one byte (Slow! Better use Blockread!) 97 call I2CREAD ; reads one byte (Slow! Better use Blockread!)
92 98
93 movlw 0xFA ; That was a FA ? 99 movlw 0xFA ; That was a FA ?
129 movf divenumber,W 135 movf divenumber,W
130 btfsc STATUS,Z ; Was there at least one dive? 136 btfsc STATUS,Z ; Was there at least one dive?
131 bra menu_logbook3b ; No, Nothing to do 137 bra menu_logbook3b ; No, Nothing to do
132 138
133 bsf all_dives_shown ; Yes 139 bsf all_dives_shown ; Yes
140 bsf logbook_page_not_empty
134 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster) 141 bra menu_logbook_display_loop2 ; rcall of get_free_eeprom_location not required here (faster)
135 142
136 143
137 menu_logbook4: 144 menu_logbook4:
138 ; Adjust eeprom_address to set pointer on first headerbyte 145 ; Adjust eeprom_address to set pointer on first headerbyte
454 call I2CREAD2 ; read Air pressure 461 call I2CREAD2 ; read Air pressure
455 movff SSPBUF,lo 462 movff SSPBUF,lo
456 call I2CREAD2 ; read Air pressure 463 call I2CREAD2 ; read Air pressure
457 movff SSPBUF,hi 464 movff SSPBUF,hi
458 465
459 ; movff lo,average_depth_hold+2
460 ; movff hi,average_depth_hold+3 ; Store here for correct average
461
462 bsf leftbind 466 bsf leftbind
463 output_16 ; Air pressure before dive 467 output_16 ; Air pressure before dive
464 STRCAT "mbar " 468 STRCAT "mbar "
465 OUTPUTTEXT .014 ; Desat 469 OUTPUTTEXT .014 ; Desat
466 PUTC ' ' 470 PUTC ' '
512 movff SSPBUF,divisor_deco_debug ; Store divisor 516 movff SSPBUF,divisor_deco_debug ; Store divisor
513 call I2CREAD2 ; Read divisor 517 call I2CREAD2 ; Read divisor
514 movff SSPBUF,divisor_nuy2 ; Store divisor 518 movff SSPBUF,divisor_nuy2 ; Store divisor
515 incf_eeprom_address d'2' ; Skip 2Bytes in EEPROM (faster) 519 incf_eeprom_address d'2' ; Skip 2Bytes in EEPROM (faster)
516 ; 2 bytes salinity, GF 520 ; 2 bytes salinity, GF
521 btfss logbook_format_0x21 ; 10byte extra?
522 bra display_profile2d ; No
523 incf_eeprom_address d'10' ; Skip another 10 byte from the header for 0x21 format
524 ; Average Depth, spare bytes
517 525
518 display_profile2d: 526 display_profile2d:
519 ; Start Profile display 527 ; Start Profile display
520
521 ; clrf average_divesecs+0
522 ; clrf average_divesecs+1 ; Counts x-pixels for average
523 ; clrf average_depth_hold_total+0
524 ; clrf average_depth_hold_total+1
525 ; clrf average_depth_hold_total+2
526 ; clrf average_depth_hold_total+3 ; Track average depth here...
527 ;
528 ; Write 0m X-Line.. 528 ; Write 0m X-Line..
529 movlw color_grey 529 movlw color_grey
530 call PLED_set_color ; Make this configurable? 530 call PLED_set_color ; Make this configurable?
531 531
532 movlw d'75' 532 movlw d'75'
967 bra profile_view_get_depth_new1 ; no 0xFD 967 bra profile_view_get_depth_new1 ; no 0xFD
968 bsf second_FD ; End found! Set Flag! Skip remaining pixels! 968 bsf second_FD ; End found! Set Flag! Skip remaining pixels!
969 return 969 return
970 970
971 profile_view_get_depth_new1: 971 profile_view_get_depth_new1:
972 ; incf average_divesecs+0,F
973 ; movlw d'0'
974 ; addwfc average_divesecs+1,F ; counter for average depth
975 ; ; add depth to average registers
976 ; movf lo,W
977 ; addwf average_depth_hold_total+0,F
978 ; movf hi,W
979 ; addwfc average_depth_hold_total+1,F
980 ; movlw d'0'
981 ; addwfc average_depth_hold_total+2,F
982 ; addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar
983 ;
984 btfsc event_occured ; Was there an event attached to this sample? 972 btfsc event_occured ; Was there an event attached to this sample?
985 rcall profile_view_get_depth_new2 ; Yes, get information about this event 973 rcall profile_view_get_depth_new2 ; Yes, get information about this event
986 974
987 tstfsz timeout_counter2 ; Any bytes to ignore 975 tstfsz timeout_counter2 ; Any bytes to ignore
988 bra profile_view_get_depth_new3 ; Yes (1-127) 976 bra profile_view_get_depth_new3 ; Yes (1-127)
1023 logbook_event1: 1011 logbook_event1:
1024 movlw color_cyan ; Color for Gas 6 1012 movlw color_cyan ; Color for Gas 6
1025 call PLED_set_color ; Set Color... 1013 call PLED_set_color ; Set Color...
1026 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...) 1014 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...)
1027 1015
1028
1029 ;Keep comments for future temperature graph 1016 ;Keep comments for future temperature graph
1030 ; call I2CREAD2 ; ignore byte 1017 ; call I2CREAD2 ; ignore byte
1031 ; decfsz timeout_counter2,F ; reduce counter 1018 ; decfsz timeout_counter2,F ; reduce counter
1032 ; bra profile_view_get_depth_new3 ; Loop 1019 ; bra profile_view_get_depth_new3 ; Loop
1033 ; return 1020 ; return
1133 movff SSPBUF,lo 1120 movff SSPBUF,lo
1134 movlw d'13' 1121 movlw d'13'
1135 cpfsgt lo ; Skip if lo>13 1122 cpfsgt lo ; Skip if lo>13
1136 bra display_listdive2 ; use old (Pre 0x20) format 1123 bra display_listdive2 ; use old (Pre 0x20) format
1137 1124
1125 bsf logbook_format_0x21 ; Set flag for new 0x21 Format
1126 movlw 0x21
1127 cpfseq lo ; Skip if 0x21
1128 bcf logbook_format_0x21 ; Clear flag for new 0x21 Format
1129
1138 call I2CREAD4 ; Skip Profile version (Block read) 1130 call I2CREAD4 ; Skip Profile version (Block read)
1139 movff SSPBUF,lo ; in new format, read month 1131 movff SSPBUF,lo ; in new format, read month
1140 1132
1141 display_listdive2: 1133 display_listdive2:
1142 movff lo,convert_value_temp+0 ; Month (in lo, see above) 1134 movff lo,convert_value_temp+0 ; Month (in lo, see above)
1166 movff SSPBUF,hi ; read divetime in minutes 1158 movff SSPBUF,hi ; read divetime in minutes
1167 bsf leftbind 1159 bsf leftbind
1168 output_16 ; Divetime minutes 1160 output_16 ; Divetime minutes
1169 STRCAT_PRINT "'" ; Display header-row in list 1161 STRCAT_PRINT "'" ; Display header-row in list
1170 incf_eeprom_address d'37' ; 12 Bytes read from header, skip 37 Bytes in EEPROM (Remaining Header) 1162 incf_eeprom_address d'37' ; 12 Bytes read from header, skip 37 Bytes in EEPROM (Remaining Header)
1163 btfss logbook_format_0x21 ; 10byte extra?
1164 return ; No, Done.
1165 incf_eeprom_address d'10' ; Skip another 10 byte from the header for 0x21 format
1171 return 1166 return