'TK-68K code for MedeaWiz DV-68 digital video player using 'Parallax Basic Stamp model BS2 'REV 3_0 '3_0 removed Matrix keypad option, added DV-76 player option '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 '03/25/08 Team Kingsley LLC 'www.teamkingsley.com '{$STAMP BS2} ' {$PBASIC 2.5} '188 on BS2 = 4800 baud rec VAR Byte(12) '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 p VAR Bit 'flag for which model player is being used 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 LOW 9 'using this pin for common for all buttons Top: IF IN11 = 0 THEN 'SW 2 = on, using DV-76 mode p = 1 ELSEIF IN11 = 1 THEN 'SW 2 = off, using DV-68 mode p = 0 ENDIF 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] 'make 12 to see timecode in debug DEBUG "input" ,CR FOR i = 0 TO 5 'make 11 to see timecode in debug 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 IF p = 0 THEN 'in DV-68 mode so check bytes below for fail-safe 'these 4 bytes indicate track 000 is playing on DV-68 IF rec(0) = $30 AND rec(1)= $38 AND rec(3) = $30 AND rec(4)= $31 THEN Eof ENDIF 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] 'make 12 to see timecode in debug DEBUG "input" ,CR FOR i = 0 TO 5 'make 11 to see timecode in debug 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 IF p = 0 THEN 'in DV-68 mode so check bytes below for fail-safe 'these 4 bytes indicate track 000 is playing on DV-68 IF rec(0) = $30 AND rec(1)= $38 AND rec(3) = $30 AND rec(4)= $31 THEN Eof ENDIF 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 'We have found some differences in the strings returned from 'the DV-76 to those of the DV-68 'We will be working on a table for the DV-76 but basic control 'is the same as the DV-68 protocol that can be found at ' www.teamkingsley.com/downloads '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 / 76, please send it to 'bill@teamkingsley.com and we will post it on the website to help others.