فهرست منبع

bugfix : random freezes

removed button context resetting at EOF, seems to remove freezes
Etienne Landon 7 سال پیش
والد
کامیت
ec2d54da3e
3فایلهای تغییر یافته به همراه27 افزوده شده و 13 حذف شده
  1. 1 1
      DownTigerDown.ino
  2. 18 6
      SDcard.ino
  3. 8 6
      eventually.ino

+ 1 - 1
DownTigerDown.ino

@@ -49,7 +49,7 @@ unsigned long delay_length ;
 bool inibSDreading = true;
 bool delay_flag ; //prevent first event to fire
 
-byte refreshRate = 25 ;
+byte refreshRate = 23 ;
 
 //Dimmer
 #define DIMMER_PIN 9

+ 18 - 6
SDcard.ino

@@ -65,7 +65,7 @@ bool readSDFile() {
   if (!inibSDreading) { // if currently delaying, don't read a line 
     if (btnFile.available()) {
       buf = btnFile.readStringUntil('\n');
-      
+      Serial.println("readline");
       //check selector (1st word of line) and execute corresponding function
       String selector = getSubstring(buf, ' ', 0);
       //Serial.println(selector);
@@ -107,6 +107,16 @@ bool readSDFile() {
             lustre_stepBrightness = constrain( abs((lustre_targetBrightness - lustre_currentBrightness)) / (float)((fadeTime.toInt()+1)/refreshRate), 0, 255) ;
             if(lustre_currentBrightness > lustre_targetBrightness) { lustre_stepBrightness *= -1 ;}
             }
+          Serial.print ("LEDS : zone ");
+          Serial.print (zone);
+          Serial.print (" - palette ");
+          Serial.print (palette);
+          Serial.print (" - brightness : ");
+          Serial.print (lustre_targetBrightness);
+          Serial.print (" - fade time : ");
+          Serial.print (fadeTime);
+          Serial.print (" - steps : ");
+          Serial.println (lustre_stepBrightness);
           
           
         }
@@ -118,17 +128,18 @@ bool readSDFile() {
           table_targetBrightness = bright.toInt();
           table_stepBrightness = constrain( abs((table_targetBrightness - table_currentBrightness)) / (float)(fadeTime.toInt()/refreshRate), 1, 255) ;
           if(table_currentBrightness > table_targetBrightness) { table_stepBrightness *= -1 ;}
-        }
           Serial.print ("LEDS : zone ");
           Serial.print (zone);
           Serial.print (" - palette ");
           Serial.print (palette);
           Serial.print (" - brightness : ");
-          Serial.print (lustre_targetBrightness);
+          Serial.print (table_targetBrightness);
           Serial.print (" - fade time : ");
           Serial.print (fadeTime);
           Serial.print (" - steps : ");
-          Serial.println (lustre_stepBrightness);
+          Serial.println (table_stepBrightness);
+        }
+
                  
         
         //Serial.println("Led mode " + getSubstring(buf, ' ', 1));
@@ -172,7 +183,7 @@ bool readSDFile() {
         //delay(wait.toInt());
       }
   
-      else if (selector == ""){}
+      //else if (selector == ""){}
      
       else {
         Serial.print(selector);
@@ -185,8 +196,9 @@ bool readSDFile() {
     else {
       Serial.println("EOF");
       inibSDreading = true;
+      Serial.println(inibSDreading);
 //      btnFile.close();
-      EvtResetButtonContext();
+      //EvtResetButtonContext();
       
       
     }

+ 8 - 6
eventually.ino

@@ -19,8 +19,6 @@ bool checkDelay() {
 }
 
 bool updateAll() {
-
-  FadeLed::update();
   //tsunami.update();
   updateLeds() ;
   if (dimmer_random){
@@ -38,7 +36,7 @@ bool updateAll() {
       //Serial.println(dimmer_value - delta );
     }
   }
-
+  FadeLed::update() ;
   
   return false;
   
@@ -90,7 +88,11 @@ void buttonFocus(int index) {
 //   while(
    
    EvtResetButtonContext() ; //clean context before starting reading the file
+   Serial.println("ended buttonReset");
+   delay_length = 0 ;
    inibSDreading = false ;
+   
+   Serial.println("ended focus");
    //mgr.addListener(new EvtTimeListener(10, true, (EvtAction)readSDFile));
    //mgr.addListener(new EvtTimeListener(50, true, (EvtAction)fadeDimmer));
    //readSDFile();
@@ -120,8 +122,8 @@ void stopAll() {
 }
 
 void audioVolume(){
-  int targetVolume = map (analogRead(A21), 0, 1024, 0, -70) ;
-  Serial.println(analogRead(A21));
+  int targetVolume = map (analogRead(audioVolumePin), 0, 1024, 0, -40) ;
+  //Serial.println(analogRead(A21));
   if (targetVolume != audioMasterVolume){
     audioMasterVolume = targetVolume;
     Serial.print("Setting audio volume to : ");
@@ -208,7 +210,7 @@ void EvtResetButtonContext () {
 //  pSD = new EvtTimeListener(5, true, (EvtAction)readSDFile);  
 
   inibSDreading = true ;
-  mgr.addListener(new EvtTimeListener(10, true, (EvtAction)readSDFile));
+  mgr.addListener(new EvtTimeListener(5, true, (EvtAction)readSDFile));
   mgr.addListener(new EvtTimeListener(refreshRate, true, (EvtAction)updateAll));
   //mgr.addListener(new EvtTimeListener(40, true, (EvtAction)fastLeds));
   mgr.addListener(new EvtTimeListener(refreshRate, true, (EvtAction)audioVolume));