|
@@ -1,17 +1,23 @@
|
|
|
#include <Eventually.h>
|
|
|
#include "Adafruit_TLC59711.h"
|
|
|
+#include <SD.h>
|
|
|
#include <SPI.h>
|
|
|
|
|
|
const int BUTTON_PIN[10] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39} ;
|
|
|
int currentButton ;
|
|
|
|
|
|
-//TLC59711
|
|
|
+// TLC59711
|
|
|
#define NUM_TLC59711 1
|
|
|
#define data 28
|
|
|
#define clock 27
|
|
|
Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711, clock, data);
|
|
|
uint32_t ledState[12] ;
|
|
|
|
|
|
+// SD card
|
|
|
+File btnFile ;
|
|
|
+String buffer;
|
|
|
+boolean SDfound;
|
|
|
+
|
|
|
//Eventually pointers to manage creation/deletion of listeners
|
|
|
EvtManager mgr;
|
|
|
|
|
@@ -34,40 +40,15 @@ void setup() {
|
|
|
|
|
|
tlc.begin();
|
|
|
tlc.write();
|
|
|
-// tlc.setLED(0, 65535, 65535, 65535);
|
|
|
-// tlc.setLED(1, 65535, 65535, 65535);
|
|
|
-// tlc.setLED(2, 65535, 65535, 65535);
|
|
|
-// tlc.setLED(3, 65535, 65535, 65535);
|
|
|
-// tlc.write();
|
|
|
-// delay(1000);
|
|
|
-// tlc.setLED(0, 0, 0, 0);
|
|
|
-// tlc.setLED(1, 0, 0, 0);
|
|
|
-// tlc.setLED(2, 0, 0, 0);
|
|
|
-// tlc.setLED(3, 0, 0, 0);
|
|
|
-//// tlcSet(0,65535);
|
|
|
-// tlc.write();
|
|
|
-// delay(500);
|
|
|
-// ledState[3] = 65535 ;
|
|
|
-// tlcWrite();
|
|
|
-// delay(10000);
|
|
|
+
|
|
|
for (int i ; i<12; i++) {
|
|
|
Serial.println(i);
|
|
|
ledState[i] = 65535 ;
|
|
|
tlcWrite();
|
|
|
- delay (1000);
|
|
|
+ delay (100);
|
|
|
ledState[i] = 0 ;
|
|
|
tlcWrite();
|
|
|
- }
|
|
|
-// }
|
|
|
-// for (int i ; i<12; i++) {
|
|
|
-// Serial.println(i);
|
|
|
-// tlcSet(i, 65535);
|
|
|
-// tlc.write();
|
|
|
-// delay (1000);
|
|
|
-// tlcSet(i,0);
|
|
|
-// tlc.write();
|
|
|
-// }
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
//Set button pins as input
|
|
|
for (int i ; i < sizeof(BUTTON_PIN)/sizeof(int) ; i++) {
|
|
@@ -81,6 +62,28 @@ void setup() {
|
|
|
// //mgr.addListener( plist2 );
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/////////////////////// SD ////////////////////////////////////////////
|
|
|
+
|
|
|
+void readSDFile() {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ while (btnFile.available()) {
|
|
|
+ buffer = btnFile.readStringUntil('\n');
|
|
|
+ //check selector (1st word of line) and execute corresponding function
|
|
|
+ String selector = buffer.substring(0, buffer.indexOf(" "));
|
|
|
+ Serial.println(selector);
|
|
|
+// switch (selector) {
|
|
|
+// case playWav :
|
|
|
+//
|
|
|
+ delay(500);
|
|
|
+// }
|
|
|
+ Serial.println("EOF");
|
|
|
+ btnFile.close();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
///////////////////////////Events/////////////////////////////////
|
|
|
/*resetButtonContext create a listener for each button
|
|
|
* when triggered, thoses listener execute the same functions with the index of the pressed button :
|
|
@@ -118,41 +121,60 @@ void buttonFocus(int index) {
|
|
|
}
|
|
|
|
|
|
EvtResetButtonContext() ; //clean context before starting reading the file
|
|
|
-
|
|
|
+
|
|
|
//et après ya plein de trucs à faire
|
|
|
-
|
|
|
+ String file = "button";
|
|
|
+ file+=index ;
|
|
|
+ file+=".txt";
|
|
|
+ btnFile = SD.open(file) ;
|
|
|
+ Serial.println(file);
|
|
|
+ if (!file) {
|
|
|
+ Serial.print("The text file cannot be opened");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ readSDFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
bool button0(){
|
|
|
buttonFocus(0) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button1(){
|
|
|
buttonFocus(1) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button2(){
|
|
|
buttonFocus(2) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button3(){
|
|
|
buttonFocus(3) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button4(){
|
|
|
buttonFocus(4) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button5(){
|
|
|
buttonFocus(5) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button6(){
|
|
|
buttonFocus(6) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button7(){
|
|
|
buttonFocus(7) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button8(){
|
|
|
buttonFocus(8) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
bool button9(){
|
|
|
buttonFocus(9) ;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
void EvtResetButtonContext () {
|
|
@@ -172,6 +194,8 @@ void EvtResetButtonContext () {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
USE_EVENTUALLY_LOOP(mgr) // Use this instead of your loop() function.
|