|
@@ -4,7 +4,6 @@
|
|
|
#include <SD.h>
|
|
|
#include <SerialFlash.h>
|
|
|
|
|
|
-#include <DmxSimple.h>
|
|
|
|
|
|
/* SdWav1 : sample voix |
|
|
|
* SdWav2 : sample attente |-> mix1 -> Lout & RMS1
|
|
@@ -30,30 +29,41 @@ AudioConnection patchCord7(mixer2, rms2);
|
|
|
AudioControlSGTL5000 sgtl5000_1; //xy=573,537
|
|
|
// GUItool: end automatically generated code
|
|
|
|
|
|
+#define LOOP_WAV "SDTEST1.WAV"
|
|
|
+#define PRESENCE_WAV "SDTEST2.WAV"
|
|
|
+#define WAIT_WAV "SDTEST3.WAV"
|
|
|
|
|
|
+bool presence ;
|
|
|
+
|
|
|
// Use these with the Teensy Audio Shield
|
|
|
#define SDCARD_CS_PIN 10
|
|
|
#define SDCARD_MOSI_PIN 7
|
|
|
#define SDCARD_SCK_PIN 14
|
|
|
|
|
|
-// Use these with the Teensy 3.5 & 3.6 SD card
|
|
|
-//#define SDCARD_CS_PIN BUILTIN_SDCARD
|
|
|
-//#define SDCARD_MOSI_PIN 11 // not actually used
|
|
|
-//#define SDCARD_SCK_PIN 13 // not actually used
|
|
|
+void ESPSerial(){
|
|
|
+ // Send bytes from ESP8266 -> Teensy to Computer
|
|
|
+ bool printLine ;
|
|
|
+ while ( Serial1.available() ) {
|
|
|
+ Serial.write( Serial1.read() );
|
|
|
+ printLine = 1 ;
|
|
|
+ }
|
|
|
+// if (printLine) {Serial.println("");}
|
|
|
+ printLine = 0;
|
|
|
+ // Send bytes from Computer -> Teensy back to ESP8266
|
|
|
+ while ( Serial.available() ) {
|
|
|
+ Serial1.write( Serial.read() );
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
void setup() {
|
|
|
- Serial.begin(9600);
|
|
|
-// DmxSimple.maxChannel(4);
|
|
|
-// DmxSimple.write(4, 250);
|
|
|
+
|
|
|
+ Serial.begin(115200);
|
|
|
+ Serial1.begin(115200);
|
|
|
+ //LDR digital inputs
|
|
|
pinMode(16, INPUT);
|
|
|
pinMode(20,INPUT);
|
|
|
- // Audio connections require memory to work. For more
|
|
|
- // detailed information, see the MemoryAndCpuUsage example
|
|
|
+
|
|
|
AudioMemory(16);
|
|
|
-
|
|
|
- // Comment these out if not using the audio adaptor board.
|
|
|
- // This may wait forever if the SDA & SCL pins lack
|
|
|
- // pullup resistors
|
|
|
sgtl5000_1.enable();
|
|
|
sgtl5000_1.lineOutLevel(13); // set output to 3.16 Vpp
|
|
|
sgtl5000_1.volume(1); //set volume to maximum
|
|
@@ -67,33 +77,30 @@ void setup() {
|
|
|
delay(500);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ Serial1.println("AT+GMR");
|
|
|
delay(2000);
|
|
|
+ //while (!Serial1.available()) {};
|
|
|
+ ESPSerial();
|
|
|
+ Serial.println("");
|
|
|
+ Serial.println("");
|
|
|
+ delay(00);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
//
|
|
|
void playFile(const char *filename)
|
|
|
{
|
|
|
Serial.print("Playing file: ");
|
|
|
Serial.println(filename);
|
|
|
-
|
|
|
- // Start playing the file. This sketch continues to
|
|
|
- // run while the file plays.
|
|
|
playSdWav1.play(filename);
|
|
|
-
|
|
|
// A brief delay for the library read WAV info
|
|
|
delay(5);
|
|
|
|
|
|
- // Simply wait for the file to finish playing.
|
|
|
- while (playSdWav1.isPlaying()) {
|
|
|
- printLDR();
|
|
|
- // uncomment these lines if you audio shield
|
|
|
- // has the optional volume pot soldered
|
|
|
- //float vol = analogRead(15);
|
|
|
- //vol = vol / 1024;
|
|
|
- // sgtl5000_1.volume(vol);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void printLDR(){
|
|
|
+
|
|
|
Serial.print(analogRead(A3));
|
|
|
Serial.print(" ");
|
|
|
Serial.print(digitalRead(16));
|
|
@@ -104,17 +111,24 @@ void printLDR(){
|
|
|
Serial.println();
|
|
|
}
|
|
|
|
|
|
+bool checkPresence(int Pin1, int Pin2) {
|
|
|
+ bool isPresent = digitalRead(Pin2); //|| digitalRead(Pin2);
|
|
|
+ return isPresent ;
|
|
|
+}
|
|
|
void loop() {
|
|
|
-
|
|
|
|
|
|
- delay(100);
|
|
|
- playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format
|
|
|
- delay(500);
|
|
|
- playFile("SDTEST2.WAV");
|
|
|
- delay(500);
|
|
|
- playFile("SDTEST3.WAV");
|
|
|
- delay(500);
|
|
|
- playFile("SDTEST4.WAV");
|
|
|
- delay(1500);
|
|
|
+ // filenames are always uppercase 8.3 format
|
|
|
+ if (!playSdWav1.isPlaying()) {
|
|
|
+ playFile(LOOP_WAV);
|
|
|
+ }
|
|
|
+ presence = checkPresence(16, 20);
|
|
|
+ //Serial.println(presence);
|
|
|
+ if (presence && !playSdWav2.isPlaying() ) {
|
|
|
+ Serial.println("Playing presence file");
|
|
|
+ playSdWav2.play(PRESENCE_WAV);
|
|
|
+ delay(5);
|
|
|
+ }
|
|
|
+ ESPSerial();
|
|
|
+// delay(100);
|
|
|
}
|
|
|
|