Sub Process_Globals
Public Serial1 As Serial
Private sd As SD
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
sd.Initialize(4)
RunNative("begin", Null)
StartPlaying("track002.mp3")
End Sub
Sub StartPlaying(File As String)
RunNative("startPlayingFile", File)
End Sub
#if C
#include "Adafruit_VS1053.h"
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET -1 // VS1053 reset pin (unused!)
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
#define CARDCS 4 // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
Adafruit_VS1053_FilePlayer musicPlayer =
Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
void begin(B4R::Object* o) {
if (! musicPlayer.begin()) { // initialise the music player
Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
while (1);
}
Serial.println(F("VS1053 found"));
musicPlayer.setVolume(20,20);
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);
}
void startPlayingFile (B4R::Object* o) {
musicPlayer.startPlayingFile((const char*)B4R::Object::toPointer(o));
}
#end if