|
@@ -34,7 +34,7 @@ EvtListener *pDelay ;
|
|
|
//delay
|
|
|
int delay_start ;
|
|
|
unsigned long delay_length ;
|
|
|
-bool isDelaying ;
|
|
|
+bool inibSDreading ;
|
|
|
bool delay_flag ; //prevent first event to fire
|
|
|
|
|
|
//Dimmer
|
|
@@ -85,6 +85,19 @@ void setup() {
|
|
|
}
|
|
|
SDfound = 1;
|
|
|
|
|
|
+ // DIMMER
|
|
|
+ Serial.println("Test dimmer");
|
|
|
+ dimmer.setTime(1);
|
|
|
+ dimmer.off();
|
|
|
+ while (!dimmer.done()) {FadeLed::update();}
|
|
|
+ delay(2000);
|
|
|
+ Serial.println("fading up");
|
|
|
+ dimmer.setTime(2000);
|
|
|
+ dimmer.on();
|
|
|
+ while (!dimmer.done()) {FadeLed::update();}
|
|
|
+ Serial.println("fading down");
|
|
|
+ dimmer.off();
|
|
|
+ while (!dimmer.done()) {FadeLed::update();}
|
|
|
|
|
|
// TSUNAMI
|
|
|
// We should wait for the Tsunami to finish reset
|
|
@@ -121,6 +134,9 @@ void setup() {
|
|
|
tsunami.trackPlayPoly(7, 3, true);
|
|
|
delay(500);
|
|
|
tsunami.trackPlayPoly(8, 4, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//Set button pins as input
|
|
|
for (int i ; i < sizeof(BUTTON_PIN)/sizeof(int) ; i++) {
|
|
@@ -168,7 +184,7 @@ String getSubstring(String dataString, char separator, int index)
|
|
|
|
|
|
bool readSDFile() {
|
|
|
|
|
|
- if (!isDelaying) { // if currently delaying, don't read a line
|
|
|
+ if (!inibSDreading) { // if currently delaying, don't read a line
|
|
|
if (btnFile.available()) {
|
|
|
buf = btnFile.readStringUntil('\n');
|
|
|
|
|
@@ -204,7 +220,7 @@ bool readSDFile() {
|
|
|
else if (selector == "delay") {
|
|
|
String wait = getSubstring(buf, ' ', 1);
|
|
|
Serial.println("delai " + wait + " ms");
|
|
|
- isDelaying = true ;
|
|
|
+ inibSDreading = true ;
|
|
|
delay_start = millis();
|
|
|
delay_length = wait.toInt() ;
|
|
|
// delay_flag = 0 ;
|
|
@@ -227,6 +243,7 @@ bool readSDFile() {
|
|
|
Serial.println("EOF");
|
|
|
// mgr.removeListener(pSD);
|
|
|
btnFile.close();
|
|
|
+ inibSDreading = true;
|
|
|
EvtResetButtonContext ();
|
|
|
}
|
|
|
}
|
|
@@ -246,9 +263,9 @@ bool checkDelay() {
|
|
|
//Serial.println("checkDelay");
|
|
|
//if (delay_flag == 0 ) { delay_flag = 1 ;}
|
|
|
if (millis() - delay_start > delay_length ) {
|
|
|
- isDelaying = false ;
|
|
|
+ inibSDreading = false ;
|
|
|
}
|
|
|
- //else {isDelaying = false ;}
|
|
|
+ //else {inibSDreading = false ;}
|
|
|
return false ;
|
|
|
}
|
|
|
|
|
@@ -288,7 +305,7 @@ void buttonFocus(int index) {
|
|
|
if (i == currentButton ) {
|
|
|
ledState[11-i] = 65535 ;
|
|
|
}
|
|
|
- else { ledState[11-i] = 0 ; }
|
|
|
+ else { ledState[11-i] = 50 ; }
|
|
|
tlcWrite();
|
|
|
}
|
|
|
|
|
@@ -304,7 +321,8 @@ void buttonFocus(int index) {
|
|
|
Serial.print("The text file cannot be opened");
|
|
|
// return false;
|
|
|
}
|
|
|
- mgr.addListener(new EvtTimeListener(10, true, (EvtAction)readSDFile));
|
|
|
+ inibSDreading = false ;
|
|
|
+ //mgr.addListener(new EvtTimeListener(10, true, (EvtAction)readSDFile));
|
|
|
//mgr.addListener(new EvtTimeListener(50, true, (EvtAction)fadeDimmer));
|
|
|
//readSDFile();
|
|
|
|
|
@@ -379,4 +397,11 @@ void EvtResetButtonContext () {
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
-USE_EVENTUALLY_LOOP(mgr) // Use this instead of your loop() function.
|
|
|
+//USE_EVENTUALLY_LOOP(mgr) // Use this instead of your loop() function.
|
|
|
+
|
|
|
+void loop() {
|
|
|
+ mgr.loopIteration();
|
|
|
+ readSDFile();
|
|
|
+ FadeLed::update();
|
|
|
+}
|
|
|
+
|