'TK-68K code for MedeaWiz DV-68 digital video player using 'Parallax Basic Stamp model BS2 'REV 2_2 '2_2 changed both timeloops to only look at 1st 6 bytes for EOF marker '2_1 corrected problem of not allowing the same track to play after it just 'played in the"jump to any other track not playing mode" 'it is a bit slow in the added loop 'added more iterations in time_loop1 looking for buttons between 'the SERIN, which is waiting FOR DATA from the DV-68 '07/31/07 Team Kingsley LLC 'www.teamkingsley.com '{$STAMP BS2} ' {$PBASIC 2.5} '188 on BS2 = 4800 baud rec VAR Byte(18) 'var to hold incomming data from the DV-68 track VAR Byte 'register for user requested video file track_cp VAR Byte 'register for video file currenly playing i VAR Byte 'iteration register track_cp = 255 'set outside of valid button number range 'PAUSE 7000 'allow DV-68 time to boot when powered on 'SEROUT 15, 188, [26] 'play track 1 on master DV-68 and 'SEROUT 13, 188, [26] 'play track 1 on slave DV-68 to sync Top: IF IN11 = 0 THEN 'SW 2 = on, using matrix for buttons mode FOR i = 0 TO 9 'make all inputs high HIGH i NEXT GOTO matrix ELSEIF IN11 = 1 THEN 'SW 2 = off, using up to 9 buttons / 1 common mode LOW 9 'using this pin for common for all buttons GOTO Buttons ENDIF matrix: Col_1: LOW 0 'ground column 1 and scan rows IF IN5 = 0 THEN 'check row 1 track = 1 'to play video file 001.mpg ELSEIF IN6 = 0 THEN 'check row 2 track = 4 'to play video file 004.mpg ELSEIF IN7 = 0 THEN 'check row 3 track = 7 'to play video file 007.mpg ELSEIF IN8 = 0 THEN 'check row 4 track = 11 'to play video file 011.mpg ELSEIF IN9 = 0 THEN 'check row 5 track = 13 'to play video file 013.mpg ELSE HIGH 0 GOTO Col_2 ENDIF GOTO play Col_2: LOW 1 'ground column 2 and scan rows IF IN5 = 0 THEN track = 2 ELSEIF IN6 = 0 THEN track = 5 ELSEIF IN7 = 0 THEN track = 8 ELSEIF IN8 = 0 THEN track = 10 ELSEIF IN9 = 0 THEN track = 14 ELSE HIGH 1 GOTO Col_3 ENDIF GOTO play Col_3: LOW 2 'ground column 3 and scan rows IF IN5 = 0 THEN track = 3 ELSEIF IN6 = 0 THEN track = 6 ELSEIF IN7 = 0 THEN track = 9 ELSEIF IN8 = 0 THEN track = 12 ELSEIF IN9 = 0 THEN track = 15 ELSE HIGH 2 GOTO Col_4 ENDIF GOTO play Col_4: LOW 3 'ground column 4 and scan rows IF IN5 = 0 THEN track = 16 ELSEIF IN6 = 0 THEN track = 17 ELSEIF IN7 = 0 THEN track = 18 ELSEIF IN8 = 0 THEN track = 19 ELSEIF IN9 = 0 THEN track = 20 ELSE HIGH 3 GOTO Col_5 ENDIF GOTO play Col_5: LOW 4 'ground column 5 and scan rows IF IN5 = 0 THEN track = 21 ELSEIF IN6 = 0 THEN track = 22 ELSEIF IN7 = 0 THEN track = 23 ELSEIF IN8 = 0 THEN track = 24 ELSEIF IN9 = 0 THEN track = 25 ELSE HIGH 4 GOTO Col_1 ENDIF GOTO play Buttons: IF IN0 = 0 THEN 'using I/O 0 for button 1, tied high w/ 10K R track = 1 'to play video file 001.mpg ELSEIF IN1 = 0 THEN 'using I/O 1 for button 2, tied high w/ 10K R track = 2 'to play video file 002.mpg ELSEIF IN2 = 0 THEN 'using I/O 2 for button 3, tied high w/ 10K R track = 3 'to play video file 003.mpg ELSEIF IN3 = 0 THEN 'using I/O 3 for button 4, tied high w/ 10K R track = 4 'to play video file 004.mpg ELSEIF IN4 = 0 THEN 'using I/O 1 for button 5, tied high w/ 10K R track = 5 'to play video file 005.mpg ELSEIF IN5 = 0 THEN 'using I/O 2 for button 6, tied high w/ 10K R track = 6 'to play video file 006.mpg ELSEIF IN6 = 0 THEN 'using I/O 3 for button 7, tied high w/ 10K R track = 7 'to play video file 007.mpg ELSEIF IN7 = 0 THEN 'using I/O 1 for button 8, tied high w/ 10K R track = 8 'to play video file 008.mpg ELSEIF IN8 = 0 THEN 'using I/O 2 for button 9, tied high w/ 10K R track = 9 'to play video file 009.mpg ELSE GOTO Buttons 'if button not pressed, go check again ENDIF play: IF IN10 = 0 THEN 'SW 1 = on, jump to any track not playing DEBUG DEC track_cp, CR DEBUG DEC track, CR IF track <> track_cp THEN 'track requested not currently playing SEROUT 15, 188, [track] 'play track [x] SEROUT 13, 188, [track] 'play track [x]on slave player DEBUG "Play ", DEC track, CR track_cp = track DEBUG DEC track_cp, CR PAUSE 1500 'let track begin before checking for EOF ENDIF GOTO timeloop_1 ELSEIF IN10 = 1 THEN 'SW 1 = Off, no jump until current track is finished SEROUT 15, 188, [track] 'play track [x] SEROUT 13, 188, [track] 'play track [x]on slave player PAUSE 1000 'this pause is to insure the file has started playing 'and we don't read the EOF marker from previous file GOTO timeloop ENDIF GOTO top timeloop: 'searching for the EOF (end of file) Marker 'DV-68 sends time (1st 6) and status (2nd 6 bytes) every second DEBUG "waiting", CR SERIN 14, 188, [STR rec\6] DEBUG "input" ,CR FOR i = 0 TO 5 DEBUG HEX rec(i) 'show raw hex data on Debug screen NEXT DEBUG CR 'the 4 bytes below indicate DV-68 is at the end of the video file IF rec(0) = $30 AND rec(1)= $31 AND rec(3) = $30 AND rec(4)= $31 THEN Eof 'these 4 bytes appear after eof marker above IF rec(0) = $30 AND rec(1)= $32 AND rec(3) = $30 AND rec(4)= $34 THEN Eof 'these 4 bytes indicate track 000 is playing IF rec(0) = $30 AND rec(1)= $38 AND rec(3) = $30 AND rec(4)= $31 THEN Eof GOTO timeloop 'keep receiving time code unless end of file was found timeloop_1: 'searching for the EOF (end of file) Marker 'DV-68 sends time (1st 6) and status (2nd 6 bytes) every second 'DEBUG "timeloop 1", CR DEBUG "waiting", CR SERIN 14, 188, [STR rec\6] DEBUG "input" ,CR FOR i = 0 TO 5 DEBUG HEX rec(i) 'show raw hex data on Debug screen NEXT DEBUG CR 'the 4 bytes below indicate DV-68 is at the end of the video file IF rec(0) = $30 AND rec(1)= $31 AND rec(3) = $30 AND rec(4)= $31 THEN Eof 'these 4 bytes appear after eof marker above IF rec(0) = $30 AND rec(1)= $32 AND rec(3) = $30 AND rec(4)= $34 THEN Eof 'these 4 bytes indicate track 000 is playing IF rec(0) = $30 AND rec(1)= $38 AND rec(3) = $30 AND rec(4)= $31 THEN Eof FOR i = 0 TO 40 'scan button inputs while waiting for data from DV-68 'DEBUG DEC? i IF IN0 = 0 THEN 'using I/O 0 for button 1, tied high w/ 10K R track = 1 'to play video file 001.mpg GOTO play ELSEIF IN1 = 0 THEN 'using I/O 1 for button 2, tied high w/ 10K R track = 2 'to play video file 002.mpg GOTO play ELSEIF IN2 = 0 THEN 'using I/O 2 for button 3, tied high w/ 10K R track = 3 'to play video file 003.mpg GOTO play ELSEIF IN3 = 0 THEN 'using I/O 3 for button 4, tied high w/ 10K R track = 4 'to play video file 004.mpg GOTO play ELSEIF IN4 = 0 THEN 'using I/O 1 for button 5, tied high w/ 10K R track = 5 'to play video file 005.mpg GOTO play ELSEIF IN5 = 0 THEN 'using I/O 2 for button 6, tied high w/ 10K R track = 6 'to play video file 006.mpg ELSEIF IN6 = 0 THEN 'using I/O 3 for button 7, tied high w/ 10K R track = 7 'to play video file 007.mpg GOTO play ELSEIF IN7 = 0 THEN 'using I/O 1 for button 8, tied high w/ 10K R track = 8 'to play video file 008.mpg GOTO play ELSEIF IN8 = 0 THEN 'using I/O 2 for button 9, tied high w/ 10K R track = 9 'to play video file 009.mpg GOTO play ENDIF NEXT GOTO timeloop_1 'if button not pressed, go check again Eof: DEBUG "End of file found" ,CR track_cp = 255 'file played to end so reset GOTO top 'go to top and do it all again END 'As in anytime I write code, there is usually a more efficient code to do the 'job. We are always open to suggestions and other points of view. If you have 'any, or have other code you wish to share for the DV-68, please send it to 'bill@teamkingsley.com and we will post it on the website to help others.