Ver código fonte

Panorama bugfix

Reduce hysteresis to 5 to ensure triggering happens
There has been a bug with all three systems not playing sound anymore
after several hours, not reproduced since
Etienne Landon 8 anos atrás
pai
commit
05ca329c97
1 arquivos alterados com 32 adições e 18 exclusões
  1. 32 18
      I_Mihalache_AudioPlayer.ino

+ 32 - 18
I_Mihalache_AudioPlayer.ino

@@ -38,7 +38,7 @@ AudioConnection          patchCord1(LoopPlayer, 0, mixer2, 0);
 AudioConnection          patchCord2(PresencePlayer, 0, mixer1, 0);
 AudioConnection          patchCord3(WaitPlayer, 0, mixer1, 1);
 AudioConnection          patchCord4(mixer1, 0, i2s1, 0);
-AudioConnection          patchCord5(PresencePlayer, rms1);
+AudioConnection          patchCord5(mixer1, rms1);
 AudioConnection          patchCord6(mixer2, 0, i2s1, 1);
 AudioConnection          patchCord7(mixer2, rms2);
 AudioControlSGTL5000     sgtl5000_1;     //xy=573,537
@@ -67,7 +67,7 @@ int sensorPin = A7;
 SetPoint setPoint;
 
 bool presence ;
-uint32_t LastPresence ;
+unsigned long int LastPresence ;
 
  
 // Use these with the Teensy Audio Shield
@@ -214,7 +214,16 @@ bool checkUDPconnected() {
       Serial.println("connected");
       return true ;
     }
-    else return false;
+    else 
+    {
+      int port = 8000 + ID;
+      Serial1.print("AT+CIPSTART=\"UDP\",\"192.168.3.1\",");
+      Serial1.println(port);
+      Serial.println ("Reconnecting UDP");
+      ESPSerial();
+      
+      return false;
+    }
     
   }
 }
@@ -254,7 +263,12 @@ void loop() {
     WaitPlayer.play(WAIT_WAV);
     delay(10);
   }
-
+  if (presence) {
+      LastPresence = millis() ;
+      if (!PresencePlayer.isPlaying()) {
+        PresencePlayer.play(PRESENCE_WAV);
+        delay(10);
+      }
   if ( (millis() - LastPresence > WAIT_TIME) && !WaitPlayer.isPlaying() && !PresencePlayer.isPlaying()) {
       
       mixer1.gain (1, 1.0);
@@ -262,8 +276,7 @@ void loop() {
       delay(10);
     }
 
-  if (presence) {
-      LastPresence = millis() ;
+  
   }
    //WAIT fades up if PresencePlayer stops ( 
   if (millis()-LastPresence > WAIT_TIME && PresencePlayer.isPlaying() && presence == false) {
@@ -287,18 +300,18 @@ void loop() {
     
     
 
-//  if (checkUDP.check() ==1) {
-//    UDPalive = checkUDPconnected();
-//  }
-//  if (checkESPserial.check() == 1) {
-//    
-//  }
-//  ESPSerial();
-//
-// if (sendRMS.check() == 1) {
-//    sendUDP();
-//  }
-//  
+  if (checkUDP.check() ==1) {
+    UDPalive = checkUDPconnected();
+  }
+  if (checkESPserial.check() == 1) {
+    
+  }
+  ESPSerial();
+
+ if (sendRMS.check() == 1) {
+   sendUDP();
+  }
+  
 }
 
 //////////////////////    LDR event handlers    /////////////////////////////
@@ -330,6 +343,7 @@ void Presence() {
     for (float fadeRamp ; fadeRamp < 100 ; fadeRamp++ ) {
           mixer1.gain(0, fadeRamp/100) ;
         }
+        Serial.println("Fading up Presence file");
   }
 
 void Absence() {