Update 'Feather-M4-Express_NeoTrellis_Music-Maker-FeatherWing-w-Amp.ino'
This commit is contained in:
parent
f63e983a72
commit
880b621c14
@ -5,9 +5,9 @@
|
||||
#include <SD.h>
|
||||
#include <Adafruit_VS1053.h>
|
||||
|
||||
// Set up NeoTrellis
|
||||
// Declare NeoTrellis constants
|
||||
Adafruit_NeoTrellis trellis;
|
||||
#define INT_PIN 11 // Interrupt pin needs to be unused by MusicMaker
|
||||
#define NT_INTERRUPT 11 // Interrupt pin needs to be unused by MusicMaker
|
||||
|
||||
#define MAX_RIPPLES 16
|
||||
#define FALLOFF_TIME 30
|
||||
@ -16,12 +16,48 @@ Adafruit_NeoTrellis trellis;
|
||||
#define RIPPLE_RATE .4
|
||||
#define MATRIX_POINT(x,y) ((y)*4+(x))
|
||||
|
||||
// Set up MusicMaker
|
||||
#define VS1053_RESET -1 // VS1053 reset pin (not used!)
|
||||
#define VS1053_CS 6 // VS1053 chip select pin (output)
|
||||
#define VS1053_DCS 10 // VS1053 Data/command select pin (output)
|
||||
#define CARDCS 5 // Card chip select pin
|
||||
#define VS1053_DREQ 9 // VS1053 Data request, ideally an Interrupt pin
|
||||
// Declare MusicMaker constants
|
||||
#define MM_RESET -1 // VS1053 reset pin (not used!)
|
||||
#define MM_CS 6 // VS1053 chip select pin (output)
|
||||
#define MM_DCS 10 // VS1053 Data/command select pin (output)
|
||||
#define MM_DREQ 9 // VS1053 Data request, ideally an Interrupt pin
|
||||
#define SD_CARDCS 5 // Card chip select pin
|
||||
|
||||
// Declare Sketch-specific global variables
|
||||
const char *ClipNames[4][12] = {
|
||||
{
|
||||
"DOIT.mp3",
|
||||
"MAKEIT.mp3",
|
||||
"WORKIT.mp3",
|
||||
"",
|
||||
"HARDER.mp3",
|
||||
"BETTER.mp3",
|
||||
"FASTER.mp3",
|
||||
"STRONGER.mp3",
|
||||
},
|
||||
{
|
||||
"CRICK.mp3",
|
||||
"FAIL.mp3",
|
||||
"BITEASS.mp3",
|
||||
"MARIO.mp3",
|
||||
"PADUM.mp3",
|
||||
"PHONE.mp3",
|
||||
"WINNER.mp3",
|
||||
"WRONG.mp3"
|
||||
},
|
||||
{
|
||||
"WRONG.mp3"
|
||||
},
|
||||
{
|
||||
"WRONG.mp3"
|
||||
}
|
||||
};
|
||||
const char *TrackNames[4][12] = {
|
||||
{
|
||||
"AA000001.mp3",
|
||||
"AA000002.mp3"
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t colors[] = {
|
||||
0xFF0000, 0x00FF00, 0x0000FF,
|
||||
@ -73,44 +109,40 @@ TrellisCallback blink(keyEvent evt){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create new instance of VS1053_FilePlayer
|
||||
Adafruit_VS1053_FilePlayer musicPlayer =
|
||||
Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);
|
||||
Adafruit_VS1053_FilePlayer(MM_RESET, MM_CS, MM_DCS, MM_DREQ, SD_CARDCS);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Wait for serial port to be opened, remove this line for 'standalone' operation
|
||||
while (!Serial) { delay(1); }
|
||||
delay(500);
|
||||
Serial.println("\n\nAdafruit VS1053 Feather Test");
|
||||
|
||||
/* delay(500);
|
||||
*/
|
||||
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.sineTest(0x44, 500); // Make a tone to indicate VS1053 is working
|
||||
|
||||
/*
|
||||
// Leaving this here for reference purposes
|
||||
musicPlayer.sineTest(0x44, 500);
|
||||
*/
|
||||
|
||||
if (!SD.begin(CARDCS)) {
|
||||
if (!SD.begin(SD_CARDCS)) {
|
||||
Serial.println(F("SD failed, or not present"));
|
||||
while (1); // don't do anything more
|
||||
}
|
||||
Serial.println("SD OK!");
|
||||
|
||||
// Set volume for left, right channels. lower numbers == louder volume!
|
||||
musicPlayer.setVolume(25,25);
|
||||
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int
|
||||
|
||||
// Play a file in the background, REQUIRES interrupts!
|
||||
/* Serial.println(F("Playing full track 001"));
|
||||
musicPlayer.playFullFile("/track001.mp3");
|
||||
*/
|
||||
Serial.println(F("Playing track 002"));
|
||||
musicPlayer.startPlayingFile("/track002.mp3");
|
||||
musicPlayer.startPlayingFile("/TRACKS/AA000002.mp3");
|
||||
|
||||
pinMode(INT_PIN, INPUT);
|
||||
pinMode(NT_INTERRUPT, INPUT);
|
||||
randomSeed(analogRead(0));
|
||||
|
||||
if(!trellis.begin()){
|
||||
@ -146,13 +178,13 @@ void setup() {
|
||||
void loop() {
|
||||
Serial.print(".");
|
||||
// File is playing in the background
|
||||
if (musicPlayer.stopped()) {
|
||||
/* if (musicPlayer.stopped()) {
|
||||
Serial.println("Done playing music");
|
||||
while (1) {
|
||||
delay(10); // we're done! do nothing...
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
*/ if (Serial.available()) {
|
||||
char c = Serial.read();
|
||||
|
||||
// if we get an 's' on the serial console, stop!
|
||||
@ -172,7 +204,7 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
if(!digitalRead(INT_PIN)){
|
||||
if(!digitalRead(NT_INTERRUPT)){
|
||||
trellis.read(false);
|
||||
}
|
||||
processRipples();
|
||||
|
Loading…
Reference in New Issue
Block a user