$regfile=\"m328pdef.dat\"
$crystal=16000000
$baud=9600
$hwstack = 32
$swstack = 32
$framesize = 32
Declare sub dfPlayer(byval command as byte, byval feedback as byte, byval para1 as byte, byval para2 as byte)
\'IO Button Configuration
config pinb.0 =input
playButton alias portb.0
\'Config Software UART for DFPlayer
wait 2
Open \"comd.7:9600,8,n,1\" For Output As #1
\'DFPlayer COMMAND
const NextCommand=&H01
const prevCommand=&H02
const specTracking=&H03
const volUp=&H04
const volDown=&H05
const specVol=&H06
const specEqu=&H07
const playMode=&H08
const specPlayback=&H09
const stbdyMode=&H0A
const Normal=&H0B
const ResetModule=&H0C
const playBack=&H0D
const pause=&H0E
const specFolderPlay=&H0f
const volAdjust=&H10
const repeatPlay=&H11
dfplayer specVol,0,0,30 \'adjust volume
waitms 200
dfplayer specEqu,0,0,0 \'adjust equalizer normal
waitms 200
do
if playButton=0 then
dfplayer specFolderplay , 0,1,1 \'play folder 01 and 001.mp3
end if
loop
sub dfPlayer(byval command as byte, byval feedback as byte, byval para1 as byte, byval para2 as byte)
\'Format command in Hex ($S Ver Len Cmd Feedback para1 para2 Checksum $O)
local _$S as byte, _ver as byte, _len as byte, _$O as byte
local checksum_ as integer , checksum1 as byte, checksum2 as byte
_ver=&HFF
_len=&H06
_$O=&HEF
_$S=&H7E
checksum_=_ver+_len
checksum_=checksum_+command
checksum_=checksum_+feedback
checksum_=checksum_+para1
checksum_=checksum_+para2
checksum_=0-checksum_
checksum1=high(checksum_)
checksum2=low(checksum_)
print #1, chr(_$S);chr(_VER);chr(_LEN);chr(command);chr(feedback);chr(para1);chr(para2);chr(checksum1);chr(checksum2);chr(_$O); \'send command to dfplayer
end sub
|