Delete ADXL362_SimpleRead.ino

Delete ADXL362_SimpleRead.ino

--- examples/ADXL362_SimpleRead/ADXL362_SimpleRead.ino
+++ examples/ADXL362_SimpleRead/ADXL362_SimpleRead.ino
@@ -1,53 +0,0 @@
-/*
- ADXL362_SimpleRead.ino -  Simple XYZ axis reading example
- for Analog Devices ADXL362 - Micropower 3-axis accelerometer
- go to http://www.analog.com/ADXL362 for datasheet
-
-
- License: CC BY-SA 3.0: Creative Commons Share-alike 3.0. Feel free
- to use and abuse this code however you'd like. If you find it useful
- please attribute, and SHARE-ALIKE!
-
- Created June 2012
- by Anne Mahaffey - hosted on http://annem.github.com/ADXL362
-
- Modified May 2013
- by Jonathan Ruiz de Garibay
-
-Connect SCLK, MISO, MOSI, and CSB of ADXL362 to
-SCLK, MISO, MOSI, and DP 10 of Arduino
-(check http://arduino.cc/en/Reference/SPI for details)
-
-*/
-
-#include <SPI.h>
-#include <ADXL362.h>
-
-ADXL362 xl;
-
-int16_t temp;
-int16_t XValue, YValue, ZValue, Temperature;
-
-void setup(){
-
-  Serial.begin(9600);
-  xl.begin(10);                   // Setup SPI protocol, issue device soft reset
-  xl.beginMeasure();              // Switch ADXL362 to measure mode
-
-  Serial.println("Start Demo: Simple Read");
-}
-
-void loop(){
-
-  // read all three axis in burst to ensure all measurements correspond to same sample time
-  xl.readXYZTData(XValue, YValue, ZValue, Temperature);
-  Serial.print("XVALUE=");
-  Serial.print(XValue);
-  Serial.print("\tYVALUE=");
-  Serial.print(YValue);
-  Serial.print("\tZVALUE=");
-  Serial.print(ZValue);
-  Serial.print("\tTEMPERATURE=");
-  Serial.println(Temperature);
-  delay(100);                // Arbitrary delay to make serial monitor easier to observe
-}


remove debug

remove debug


GPIO input for timelapse start, some HTML modifications

--- ANI_CameraRemote/ANI_CameraRemote.ino
+++ ANI_CameraRemote/ANI_CameraRemote.ino
@@ -8,6 +8,7 @@
   20170720 Bugfix: Restarting timelapse after reconnect removed
   20170720 Information is displayed all the time, refresh button
   20170720 Autorefresh setting added
+  20170722 Input pin as timelapse start
   --------------------------------------------------*/

 #include <ESP8266WiFi.h>
@@ -20,12 +21,13 @@
 const int webServerPort = 80;                      // Port for web server

 const int triggerPin = 2;                          // GPIO2 as trigger output
+const int startPin = 5;                            // GPIO5 as start input for timelapse, -1 = deactivate input pin processing

 // Timelapse Defaults
 const unsigned long default_delayToStart = 0;      // Delay in seconds till start of timelapse
 const unsigned long default_numberOfShots = 10;    // Number of shots in timelapse mode
 const unsigned long default_delayBetweenShots = 5; // Delay between shots in timelapse mode
-const unsigned long default_autorefresh = 60;      // In timelapse mode autorefresh webGUI every 60 seconds, 0 = autorefresh off
+const unsigned long default_autorefresh = 15;      // In timelapse mode autorefresh webGUI every 15 seconds, 0 = autorefresh off

 // End of settings
 //--------------------------------------------------
@@ -60,7 +62,7 @@

 enum triggerModes { ON = 0, OFF = 1 };
 triggerModes currentTriggerMode = OFF;
-enum execModes { NONE, ONESHOT, TIMELAPSESTART, TIMELAPSERUNNING, TIMELAPSESTOP, REFRESH, RESET };
+enum execModes { NONE, ONESHOT, TIMELAPSESTART, TIMELAPSERUNNING, TIMELAPSESTOP, WAITFORGPIO, REFRESH, RESET };
 execModes currentExecMode = NONE;

@@ -71,6 +73,8 @@

 void setup()
 {
+  if (startPin > -1)
+    pinMode(startPin, INPUT_PULLUP); // Setup GPIO input for start signal
   pinMode(triggerPin, OUTPUT); // setup GPIO as camera trigger
   trigger(OFF);
   WiFi.mode(WIFI_AP); // AP mode for connections
@@ -85,34 +89,29 @@
   String sResponse, sHeader, sParam = "";

   process();
+  CheckAndProcessInputPin(startPin);

   client = server.available(); // Check if a client has connected
   String sRequest = getRequest(client);
-
-  if (sRequest == "") // stop client, if request is empty
-  {
-    client.stop();
-    return;
-  }
-
-  bool pathOK = checkPathAndGetParameters(sRequest, sParam); // get parameters from request, check path
-  if (pathOK) // generate the html page
-  {
-    if (sParam != "")
-    {
-      extractParams(sParam);
-      process_mode();
-    }
-
-    sResponse = generateHTMLPage(delayToStart, numberOfShots, delayBetweenShots);
-    generateOKHTML(sResponse, sHeader);
-  }
-  else // 404 if error
-    generateErrorHTML(sResponse, sHeader);
-
-  client.print(sHeader); // Send the response to the client
-  client.print(sResponse);
-  client.stop(); // and stop the client
+  if (sRequest != "") // There is a request
+  {
+    bool pathOK = checkPathAndGetParameters(sRequest, sParam); // get parameters from request, check path
+    if (pathOK) // generate the html page
+    {
+      if (sParam != "")
+      {
+        extractParams(sParam);
+        process_mode();
+      }
+      sResponse = generateHTMLPage(delayToStart, numberOfShots, delayBetweenShots);
+      generateOKHTML(sResponse, sHeader);
+    }
+    else // 404 if error
+      generateErrorHTML(sResponse, sHeader);
+    clientOutAndStop(sHeader, sResponse);
+  }
+  else
+    client.stop(); // stop client, if request is empty
 }

 void process_mode()
@@ -162,55 +161,6 @@
   }
 }

-void extractParams(String params)
-{
-  params[0] = ' ';
-  params.trim();
-  params.toUpperCase();
-  if (params.length() > 0)
-  {
-    params += "&";
-    if ((currentExecMode == TIMELAPSERUNNING) || (currentExecMode == REFRESH)) // Only refresh and stop allowed in timelapse mode
-    {
-      if (params.indexOf("REFRESH") >= 0) // Refresh webGUI
-        currentExecMode = REFRESH;
-      if (params.indexOf("STOP") >= 0) // STOP timelapse
-        currentExecMode = TIMELAPSESTOP;
-    }
-    else // blocked if timelapse running
-    {
-      if (params.indexOf("RESET") >= 0) // RESET form
-        currentExecMode = RESET;
-      else if (params.indexOf("SINGLE_SHOT") >= 0) // single shot
-        currentExecMode = ONESHOT;
-      else if ((params.indexOf("DELAYTOSTART") >= 0) && (currentNShots <= 0)) // Switch to timelapse
-      {
-        currentExecMode = TIMELAPSESTART;
-        String par = params + " ";
-        int idx = par.indexOf("&"); // Find element delimiter
-        while (idx > 2)
-        {
-          String elem = par.substring(0, idx);
-          par = par.substring(idx + 1, par.length());
-          int idx2 = elem.indexOf("=");
-          if (idx2 > 1)
-          {
-            String elemName = elem.substring(0, idx2); // Variable name
-            String elemValue = elem.substring(idx2 + 1, elem.length()); // Variable value
-            if (elemName == "DELAYTOSTART")
-              delayToStart = elemValue.toInt();
-            if (elemName == "NUMBEROFSHOTS")
-              numberOfShots = elemValue.toInt();
-            if (elemName == "DELAYBETWEENSHOTS")
-              delayBetweenShots = elemValue.toInt();
-          }
-          idx = par.indexOf("&");
-        }
-      }
-    }
-  }
-}
-
 void process()
 {
   if ((currentExecMode == NONE) || (currentExecMode == TIMELAPSESTOP) )
@@ -219,7 +169,11 @@
   if ((currentTimeSlotMillis - previousTimeSlotMillis) > timeSlot) // 250 ms time slot
   {
     if (currentTriggerMode == ON)
+    {
       trigger(OFF);
+      if ((currentNShots <= 0) && (currentExecMode == TIMELAPSERUNNING))  // End of Timelapse mode
+        currentExecMode = TIMELAPSESTOP;
+    }

     previousTimeSlotMillis = currentTimeSlotMillis;

@@ -244,27 +198,97 @@
   }
 }

+void extractParams(String params)
+{
+  params[0] = ' ';
+  params.trim();
+  params.toUpperCase();
+  if (params.length() > 0)
+  {
+    params += "&";
+    if ((currentExecMode == TIMELAPSERUNNING) || (currentExecMode == REFRESH)) // Only refresh and stop allowed in timelapse mode
+    {
+      if (params.indexOf("REFRESH") >= 0) // Refresh webGUI
+        currentExecMode = REFRESH;
+      if (params.indexOf("STOP") >= 0) // STOP timelapse
+        currentExecMode = TIMELAPSESTOP;
+    }
+    else // blocked if timelapse running
+    {
+      if (params.indexOf("RESET") >= 0) // RESET form
+        currentExecMode = RESET;
+      else if (params.indexOf("SINGLE_SHOT") >= 0) // single shot
+        currentExecMode = ONESHOT;
+      else if ((params.indexOf("WAITFORGPIO") >= 0) && (startPin > -1)) // Wait for signal on input pin
+      {
+        currentExecMode = WAITFORGPIO;
+        setTimelapseParams(params);
+      }
+      else if ((params.indexOf("DELAYTOSTART") >= 0) && (currentNShots <= 0)) // Switch to timelapse
+      {
+        currentExecMode = TIMELAPSESTART;
+        setTimelapseParams(params);
+      }
+    }
+  }
+}
+
+void setTimelapseParams(String params) // Set timelapse parameters for modes WAITFORGPIO and START
+{
+  String par = params + " ";
+  int idx = par.indexOf("&"); // Find element delimiter
+  while (idx > 2)
+  {
+    String elem = par.substring(0, idx);
+    par = par.substring(idx + 1, par.length());
+    int idx2 = elem.indexOf("=");
+    if (idx2 > 1)
+    {
+      String elemName = elem.substring(0, idx2); // Variable name
+      String elemValue = elem.substring(idx2 + 1, elem.length()); // Variable value
+      if (elemName == "DELAYTOSTART")
+        delayToStart = elemValue.toInt();
+      if (elemName == "NUMBEROFSHOTS")
+        numberOfShots = elemValue.toInt();
+      if (elemName == "DELAYBETWEENSHOTS")
+        delayBetweenShots = elemValue.toInt();
+    }
+    idx = par.indexOf("&");
+  }
+}
+
 String generateHTMLPage(unsigned long sDelay, unsigned long nShots, unsigned long interval)
 {
   String refreshLine = "";
   String stateNotInTimelapse = "enabled";
   String buttonState = "disabled";
+  String waitForGPIOLine = "";
+  String waitForGPIOLineHint = "";
+  // disable webGUI elements while in timelapse
   if (((currentExecMode == TIMELAPSERUNNING) || (currentExecMode == REFRESH)) && (currentNShots > 0))
   {
     buttonState = "enabled";
     stateNotInTimelapse = "disabled";
   }
+  else if (currentExecMode == WAITFORGPIO)
+    currentAutorefresh = autorefresh;
   else
     currentAutorefresh = 0;
   if (currentAutorefresh > 0)
     refreshLine = "<meta http-equiv=\"refresh\" content=\"" + String(currentAutorefresh) + "; URL=http://" + myIPStr + "/\">";
+  if (startPin > -1) // webGUI elements für GPIO if defined
+  {
+    waitForGPIOLine = "<input type=submit value=\"Wait for GPIO" + String(startPin) + "\" " + stateNotInTimelapse + " name=WAITFORGPIO>";
+    waitForGPIOLineHint = "GPIO" + String(startPin) + " input LOW starts timelapse
";
+  }
+  // HTML here
   String retVal = "<title>ANI Camera Remote</title>" + refreshLine + ""
-                  ""
+                  ""
                   ""
                   "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=yes\">"
                   "
" + prgTitle + " V" + prgVersion + "
"
-                  "
"
+                  "
"
                   "
Timelapse	<button " + stateNotInTimelapse + ">Reset</button>
"
                   "<form method=GET>"
                   "
Delay to start:	<input " + stateNotInTimelapse + " id=delayToStart name=delayToStart type=number min=0 step=1 value=" + String(sDelay) + "> sec
"
@@ -272,7 +296,8 @@
                   "
Interval:	<input " + stateNotInTimelapse + " id=delayBetweenShots name=delayBetweenShots type=number min=1 step=1 value=" + String(interval) + "> sec
"
                   "

"
                   "

"
-                  "
<input type=submit value=Start " + stateNotInTimelapse + ">	"
+                  "
" + waitForGPIOLine + ""
+                  "<input type=submit value=Start " + stateNotInTimelapse + " name=START>	"
                   "</form>"
                   "<button " + buttonState + ">Stop</button>
"
                   "

"
@@ -283,8 +308,9 @@
                   "
Remaining delay:	" + String(currentDelayToStart) + " sec
"
                   "
Remaining shots:	" + String(currentNShots) + "
"
                   "

"
-                  "GPIO" + String(triggerPin) + " triggers camera shutter
";
-
+                  "" + waitForGPIOLineHint + ""
+                  "GPIO" + String(triggerPin) + " triggers camera shutter
"
+                  ;
   if (refreshLine != "")
     retVal += "Page will refresh every " + String(currentAutorefresh) +  " seconds
";
   return retVal;
@@ -293,7 +319,6 @@
 void generateErrorHTML(String& sResp, String& sHead)
 {
   sResp = "<title>404 Not Found</title>
Not Found

The requested URL was not found on this server.
";
-
   sHead = "HTTP/1.1 404 Not found\r\n"
           "Content-Length: " + String(sResp.length()) + "\r\n"
           "Content-Type: text/html\r\n"
@@ -304,26 +329,11 @@
 void generateOKHTML(String& sResp, String& sHead)
 {
   sResp += "Andreas Niggemann " + String(versionMonth) + "/" + String(versionYear) + "
";
-
   sHead = "HTTP/1.1 200 OK\r\n"
           "Content-Length: " + String(sResp.length()) + "\r\n"
           "Content-Type: text/html\r\n"
           "Connection: close\r\n"
           "\r\n";
-}
-
-String getRequest(WiFiClient webclient)
-{
-  String retVal = "";
-  if (webclient)
-  {
-    unsigned long timeout = millis() + 250;
-    while (!webclient.available() && (millis() < timeout) )
-      delay(1);
-    retVal = webclient.readStringUntil('\r'); // Read the first line of the request
-    webclient.flush();
-  }
-  return retVal;
 }

 bool checkPathAndGetParameters(String sReq, String& sPar)
@@ -352,10 +362,43 @@
   return sPat == "/";
 }

+String getRequest(WiFiClient webclient)
+{
+  String retVal = "";
+  if (webclient)
+  {
+    unsigned long timeout = millis() + 250;
+    while (!webclient.available() && (millis() < timeout) )
+      delay(1);
+    retVal = webclient.readStringUntil('\r'); // Read the first line of the request
+    webclient.flush();
+  }
+  return retVal;
+}
+
+void clientOutAndStop(String sHdr, String sRespo)
+{
+  client.print(sHdr); // Send the response to the client
+  client.print(sRespo);
+  client.stop(); // and stop the client
+}
+
+void CheckAndProcessInputPin(int inputPin)
+{
+  if (inputPin > -1) // Input pin defined
+    if (currentExecMode == WAITFORGPIO)
+      if (digitalRead(inputPin) == LOW) // start signal
+      {
+        while (digitalRead(inputPin) == LOW) // wait till button not pressed
+          delay(250);
+        currentExecMode = TIMELAPSESTART;
+        process_mode();
+      }
+}
+
 void trigger(triggerModes tMode)
 {
   digitalWrite(triggerPin, tMode);
   currentTriggerMode =  tMode;
 }

-


Fixed EEPROM for new Ticklish name.

Fixed EEPROM for new Ticklish name.

--- ticklish/ticklish.ino
+++ ticklish/ticklish.ino
@@ -662,7 +662,8 @@
   for (; i < WHON-1; i++) {
     byte ei = EEPROM.read(i-1);
     if (!ei) break;
-    whoami[i] = ei;
+    if (ei == '~' || ei == '$' || ei == '\n') whoami[i] = '?';
+    else whoami[i] = ei;
   }
   whoami[i] = '\n';
   whoi = i+1;
@@ -672,8 +673,8 @@
 void tell_who() { Serial.write(whoami, whoi); Serial.send_now(); }

 void init_eeprom() {
-  bool first = eeprom_set((byte*)"stim1.0 ", 0, WHON, false);
-  if (first) eeprom_set((byte*)"", 8, WHON, true);
+  bool first = eeprom_set((byte*)"Ticklish1.0 ", 0, WHON, false);
+  if (first) eeprom_set((byte*)"", 12, WHON, true);
   eeprom_read_who();
 }

@@ -1031,7 +1032,7 @@
         discard_command();
         return;
       }
-      eeprom_set(buf + 9, 8, i - 9, true);
+      eeprom_set(buf + 9, 12, i - 9, true);
       eeprom_read_who();
       discard_buf(i+1);
     }


trying different telegramm bot libs

trying different telegramm bot libs

--- sketches/LaundryMeasure/LaundryMeasure.ino
+++ sketches/LaundryMeasure/LaundryMeasure.ino
@@ -18,10 +18,23 @@
 #include <DNSServer.h>
 #include <ESP8266WebServer.h>
 #include <WiFiManager.h>
+#include <WiFiClientSecure.h>
+#include <UniversalTelegramBot.h>
+
+#define MAX_BUFFER_SIZE 2500

 #ifndef _BOT_ID
 #include "telegram.h"
 #endif
+
+WiFiClientSecure client;
+UniversalTelegramBot bot(_BOT_ID, client);
+
+int Bot_mtbs = 1000; //mean time between scan messages
+long Bot_lasttime;   //last time messages' scan has been done
+
+enum Xpos {links, xmitte, rechts};
+enum Ypos {oben, ymitte, unten};

 //Central European Time (Frankfurt, Paris)
@@ -42,9 +55,6 @@
 unsigned int debounceInterval = 200;
 unsigned int lastJoystick = 0;
 bool triggeredJoystick = false;
-
-enum Xpos {links, xmitte, rechts};
-enum Ypos {oben, ymitte, unten};

 bool WiFiConnected = false;

@@ -129,25 +139,27 @@
   wifiManager.autoConnect("WaschmaschineAP");
   WiFiConnected = true;
   timeClient.begin();
-  String telegram = "https://api.telegram.org/" + String(_BOT_ID) + "/sendMessage?chat_id=" + _CHAT_ID + "&text=" + timeClient.getFormattedTime();
-  Serial.println(telegram);
-  HTTPClient http;
-  http.begin(telegram);
-  int httpCode = http.GET();
-  // httpCode will be negative on error
-  if(httpCode > 0) {
-      // HTTP header has been send and Server response header has been handled
-      Serial.printf("[HTTP] GET... code: %d\n", httpCode);
-
-      // file found at server
-      if(httpCode == HTTP_CODE_OK) {
-          String payload = http.getString();
-          Serial.println(payload);
-      }
-  } else {
-      Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
-  }
-  http.end();
+
+
+  /* String telegram = "https://api.telegram.org/" + String(_BOT_ID) + "/sendMessage?chat_id=" + _CHAT_ID + "&text=" + timeClient.getFormattedTime(); */
+  /* Serial.println(telegram); */
+  /* HTTPClient http; */
+  /* http.begin(telegram); */
+  /* int httpCode = http.GET(); */
+  /* // httpCode will be negative on error */
+  /* if(httpCode > 0) { */
+  /*     // HTTP header has been send and Server response header has been handled */
+  /*     Serial.printf("[HTTP] GET... code: %d\n", httpCode); */
+
+  /*     // file found at server */
+  /*     if(httpCode == HTTP_CODE_OK) { */
+  /*         String payload = http.getString(); */
+  /*         Serial.println(payload); */
+  /*     } */
+  /* } else { */
+  /*     Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); */
+  /* } */
+  /* http.end(); */

   ads.begin();
 }
@@ -168,6 +180,17 @@
         timeClient.setTimeOffset(3600);
     }
   }
+  if (millis() > Bot_lasttime + Bot_mtbs)  {
+      int numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
+      while(numNewMessages) {
+          Serial.println("got response");
+          for(int i=0; i<numNewMessages; i++) {
+              bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, "");
+          }
+          numNewMessages = bot.getUpdates(bot.last_message_recived + 1);
+      }
+      Bot_lasttime = millis();
+  }
   if(triggeredJoystick && ((millis()-lastJoystick)>debounceInterval))
   {
       triggeredJoystick = false;


Delete Simple_Flasher_Example.ino

Delete Simple_Flasher_Example.ino

--- Flasher/examples/Simple_Flasher_Example/Simple_Flasher_Example.ino
+++ Flasher/examples/Simple_Flasher_Example/Simple_Flasher_Example.ino
@@ -1,18 +0,0 @@
-#include <Flasher.h>
-
-const int ledPin = 13;
-const int slowDuration = 300;
-const int fastDuration = 100;
-
-Flasher slowFlasher(ledPin, slowDuration);
-Flasher fastFlasher(ledPin, fastDuration);
-
-void setup(){}
-
-void loop()
-{
-  slowFlasher.flash(5);
-  delay(1000);
-  fastFlasher.flash(10);
-  delay(2000);
-}


Deleted myBytes declaration

Deleted myBytes declaration

--- examples/Button/Button_GUI.ino
+++ examples/Button/Button_GUI.ino
@@ -1,27 +1,27 @@
-#include <AmuletUART.h>
-
-//initialize Virtual Dual Port RAM arrays:
-// these are the memory registers that the UART is going to read and write through the Amulet protocol
-byte myBytes[32] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
-word myWords[32] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
-
-AmuletUART myModule(115200);  // initialize the AmuletUART module as a global
-
-void setup()                    // run once, when the sketch starts
-{
-  Serial.begin(115200);  // setup Serial Connection
-  pinMode(13, OUTPUT);
-  myModule.setBytePointer(myBytes, sizeof(myBytes)); // Load memory address of RAM byte arrays
-  myModule.setWordPointer(myWords, sizeof(myWords)); // Load memory address of RAM word arrays
-}
-
-void loop()
-{
-   if (Serial.available()){
-      myModule.UART_recieve(); // Call the UART_recieve() function to begin slave protocol
-      digitalWrite(13, myWords[13]);
-
-      delay(1000);
-   }
-  }
+#include <AmuletUART.h>

+//initialize Virtual Dual Port RAM arrays:
+// these are the memory registers that the UART is going to read and write through the Amulet protocol
+
+word myWords[32] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+
+AmuletUART myModule(115200);  // initialize the AmuletUART module as a global
+
+void setup()                    // run once, when the sketch starts
+{
+  Serial.begin(115200);  // setup Serial Connection
+  pinMode(13, OUTPUT);
+  myModule.setBytePointer(myBytes, sizeof(myBytes)); // Load memory address of RAM byte arrays
+  myModule.setWordPointer(myWords, sizeof(myWords)); // Load memory address of RAM word arrays
+}
+
+void loop()
+{
+   if (Serial.available()){
+      myModule.UART_recieve(); // Call the UART_recieve() function to begin slave protocol
+      digitalWrite(13, myWords[13]);
+
+      delay(1000);
+   }
+  }
+


Update Complete.ino example

Update Complete.ino example

The function calls on line 48 and 53 were wrong.

--- examples/Complete/Complete.ino
+++ examples/Complete/Complete.ino
@@ -45,12 +45,12 @@
     /****************************************/
     // setWifiMode
     Serial.print("setWifiMode: ");
-    Serial.println(getStatus(wifi.setWifiMode(ESP8266_WIFI_ACCESSPOINT)));
+    Serial.println(getStatus(wifi.setMode(ESP8266_WIFI_ACCESSPOINT)));

     // getWifiMode
     /*ESP8266WifiMode mode;
     Serial.print("getWifiMode: ");
-    Serial.println(getStatus(wifi.getWifiMode(&mode)));*/
+    Serial.println(getStatus(wifi.getMode(&mode)));*/

     // joinAP
     /*Serial.print("joinAP: ");


#21 Removed debug prints

#21 Removed debug prints

--- examples/Sailboat/Sailboat.ino
+++ examples/Sailboat/Sailboat.ino
@@ -112,7 +112,7 @@

 void loop()
 {
-  unsigned long t = millis();
+  //unsigned long t = millis();

   bus.exchange();

@@ -150,11 +150,9 @@
     }
   }

-  //delay(100);
-
-  unsigned long elapsed = millis() - t;
-  if (elapsed > 100) {
-    teleSerial.print("t = ");
-    teleSerial.println(elapsed);
-  }
+//  unsigned long elapsed = millis() - t;
+//  if (elapsed > 100) {
+//    teleSerial.print("t = ");
+//    teleSerial.println(elapsed);
+//  }
 }


getting rid of unused behaviors

getting rid of unused behaviors

--- aquaponicMCP/aquaponicMCP.ino
+++ aquaponicMCP/aquaponicMCP.ino
@@ -3,85 +3,29 @@

 //analog pins
 #define plantLight A0
-#define aquaLight A2
+#define aquaLight A3
 #define waterTurbSensor A1
-#define ovenTempSensor A3
+#define ovenTempSensor A4

 //digital pins
 OneWire  ds(2); //water temp sensor
 #define RELAY1 3
-#define LED1 5
-#define LED2 6
-#define LED3 7
-#define lightButton 6
-
-//sensor constraints
-#define minLightPlant 0
-#define minLightAqua 0
-#define targetTemperature 0
-#define temperatureVarience 0
-#define targetTurbidity 0
-#define turbidityVarience 0
-
-//sensor readings
-float aquaLightReading = 0.0;
-float plantLightReading = 0.0;
-float waterTempReading = 0.0;
-float waterTurbReading = 0.0;
-float ovenTempReading = 0.0;
-
-uint8_t bufferCounter = 1;

 bool powerIsOn = true;

 uint8_t incomingByte;

-uint8_t warningLights[] = {0, 0, 0};
-uint8_t warningIndex = 0;
-
-bool onAuto = true;
-#define autoTime 1 //number of hours until auto mode resumes.
-unsigned long autoTimer = 0;
-
 //run once on start
 void setup() {
   Serial.begin(9600);
-  pinMode(plantLed, OUTPUT);
-  pinMode(aquaLed, OUTPUT);
-  pinMode(turbLed, OUTPUT);
-  pinMode(tempLed, OUTPUT);
-  pinMode(lightButton, INPUT);
-  digitalWrite(lightButton, HIGH);
   pinMode(RELAY1, OUTPUT);
   digitalWrite(RELAY1, HIGH);
-  Serial.print("hi");
 }

 //main program loop.
 void loop() {
   SendData();
-  SendCommands();
-  GetManual();
-  if(onAuto){
-    GetInput();
-  } else {
-    if(millis() > autoTimer + autoTime*3600*1000){
-      onAuto = false;
-    }
-  }
-}
-
-/* Any kind of manual control will go here. Currently a button
- * is hooked up and will turn the lights either on or off.
- * After an hour has passed, auto mode will turn back on.
- */
-void GetManual(){
-  if(digitalRead(lightButton)){
-    digitalWrite(RELAY1, powerIsOn);
-    powerIsOn = !powerIsOn;
-    autoTimer = millis();
-    onAuto = false;
-  }
+  GetInput();
 }

 /*these will be raw readings, converting from voltage to
@@ -104,7 +48,6 @@
   mystr += "},{'sensor':'lightSwitch', 'type': 'lightswitch', 'value':";
   mystr += powerIsOn;

-
   mystr += "}]}]";
   Serial.println(mystr);
 }
@@ -115,6 +58,7 @@
     incomingByte = Serial.read();
     //light schduling
     //turn lights off
+    Serial.println(incomingByte);
     if(incomingByte == 48){     //being sent 1
        digitalWrite(RELAY1,0);
        powerIsOn = false;
@@ -125,41 +69,6 @@
        powerIsOn = true;
     }
   }
-}
-
-uint8_t warnings[] = {0, 0, 0, 0,
-//turns on warning leds, should later control temperature.
-void SendCommands(){
-//  sensor operation
-//  lighting
-  if(powerIsOn && aquaLightReading < minLightAqua){
-    digitalWrite(warningLights[warningIndex, HIGH);
-    warningIndex++;
-  } else if(warnings[0] = 1;
-    digitalWrite(warningLights[warningIndex], LOW);
-    warningIndex++;
-  }
-  if(powerIsOn && plantLightReading < minLightPlant){
-    digitalWrite(warningLights[warningIndex, HIGH);
-    warningIndex++;
-  } else if(warnings[1] = 1;
-    digitalWrite(warningLights[warningIndex], LOW);
-    warningIndex++;
-  }
-
-  //water temperature
-  float tempDifference = targetTemperature > waterTempReading ? targetTemperature - waterTempReading : waterTempReading - targetTemperature;
-  if(tempDifference > temperatureVarience){
-    digitalWrite(tempLed, HIGH);
-  }
-
-  //water turbidity
-  float turbDifference = targetTurbidity > waterTurbReading ? targetTurbidity - waterTurbReading : waterTurbReading - targetTurbidity;
-  if(turbDifference > turbidityVarience){
-    digitalWrite(turbLed, HIGH);
-  }
-
-//  water temp modifications
 }

 //Script I found online and modifed using the OneWire library, returns the temperature in fahrenheit.


Added global flag for switching sound on/off

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -24,6 +24,8 @@
 bool shouldPlayTone1,
      shouldPlayTone2,
      shouldPlayTone3;
+
+bool musicOnOff = true;

 // Bullets array - We may need a playerBullets and enemyBullets at some point and a MAX global int for each
 Bullet playerBullets[MAX_PLAYER_BULLETS];
@@ -190,14 +192,14 @@
 }

 void settingsScreen() {
-  // TODO, this is a placeholder
+
   long lastDebounceTime = 0;  // the last time the button was pressed
   bool exit_settings_menu = false;
   byte selectedItem;

   arduboy.clear();
   printText("SETTINGS", 20, 5, 2);
-  printText("SOUND", 20, 25, 1);
+  printMusicOnOff();
   printText("RESET HIGHSCORE", 20, 37, 1);
   printText("EXIT", 20, 49, 1);
   arduboy.drawRect(17, 22, 35, 13, 1);
@@ -225,6 +227,11 @@
             exit_settings_menu = true;
             break;

+          case SETTINGS_SOUND:
+            musicOnOff = !musicOnOff;
+            printMusicOnOff();
+            break;
+
           case SETTINGS_RESET_HIGH_SCORE:
             highScore = 0;
             exit_settings_menu = true;
@@ -288,6 +295,17 @@

     default: break;
   }
+}
+
+void printMusicOnOff() {
+  if(musicOnOff == true) {
+    printText("SOUND  ON ", 20, 25, 1);
+    arduboy.drawRect(17, 22, 35, 13, 1);
+  } else {
+    printText("SOUND  OFF", 20, 25, 1);
+    arduboy.drawRect(17, 22, 35, 13, 1);
+  }
+  arduboy.display();
 }

 void playGame() {


Actually write brightness to output

Actually write brightness to output

--- arduino/fasnacht/fasnacht.ino
+++ arduino/fasnacht/fasnacht.ino
@@ -69,6 +69,9 @@
     Serial.print("Brightness: ");
     Serial.println(brightness);

+    analogWrite(3, brightness);
+    analogWrite(5, brightness);
+
     digitalWrite(13, 0);
 }


removed dcf77 code

removed dcf77 code

--- arduino/src/myletterclock.ino
+++ arduino/src/myletterclock.ino
@@ -5,11 +5,11 @@
 #include <DS1307RTC.h>
 #include "Adafruit_NeoPixel.h"
 /* #include "TimerOne.h" */
-#include "DCF77.h"
-
-#define DCF_PIN 2                // Connection pin to DCF 77 device
-#define DCF_INTERRUPT 0          // Interrupt number associated with pin
-DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT, true);
+/* #include "DCF77.h" */
+
+/* #define DCF_PIN 2                // Connection pin to DCF 77 device */
+/* #define DCF_INTERRUPT 0          // Interrupt number associated with pin */
+/* DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT, true); */

 //define the data pin
 #define LEDPIN 10
@@ -59,7 +59,7 @@

     msLast = millis();

-    DCF.Start();
+    /* DCF.Start(); */

     setSyncProvider(RTC.get);
     // define global colors
@@ -89,14 +89,14 @@
         utc = now();
         displaytime(CE.toLocal(utc, &tcr));
     }
-    if(i == 300)
-    {
-        time_t DCFtime = DCF.getTime();
-        if((DCFtime != 0) && (DCFtime != now()))
-        {
-            RTC.set(DCFtime);
-        }
-    }
+    /* if(i == 300) */
+    /* { */
+    /*     time_t DCFtime = DCF.getTime(); */
+    /*     if((DCFtime != 0) && (DCFtime != now())) */
+    /*     { */
+    /*         RTC.set(DCFtime); */
+    /*     } */
+    /* } */
 }

 void processSyncMessage() {


Add uptime and whatnot

Add uptime and whatnot

--- spark/main.ino
+++ spark/main.ino
@@ -8,7 +8,10 @@
 #define PIEZO A5

 Servo rightServo, leftServo;
-int temperature = 0, photocell = 0, runs = 0;
+int temperature = 0, photocell = 0;
+unsigned long uptime = 0;
+unsigned long initialBootTime = 0;
+bool leftLightOn = true, rightLightOn = true;

 int move(String command){
     analogWrite(PIEZO, 120);
@@ -48,24 +51,26 @@
     analogWrite(PIEZO, 120);
     switch(command.toInt()){
         case 0:
-            digitalWrite(LEFT_LED, 1);
-            digitalWrite(RIGHT_LED, 1);
+            leftLightOn = true;
+            rightLightOn = true;
             break;
         case 1:
-            digitalWrite(LEFT_LED, 0);
-            digitalWrite(RIGHT_LED, 0);
+            leftLightOn = false;
+            rightLightOn = false;
             break;
         case 11:
-            digitalWrite(LEFT_LED, 1);
-            digitalWrite(RIGHT_LED, 0);
+            leftLightOn = true;
+            rightLightOn = false;
             break;
         case 12:
-            digitalWrite(LEFT_LED, 0);
-            digitalWrite(RIGHT_LED, 1);
+            leftLightOn = false;
+            rightLightOn = true;
             break;
         default:
             return 400;
     }
+    digitalWrite(LEFT_LED, leftLightOn);
+    digitalWrite(RIGHT_LED, rightLightOn);
     return 200;
 }

@@ -78,7 +83,9 @@

   Spark.variable("temperature", &temperature, INT);
   Spark.variable("light", &photocell, INT);
-  Spark.variable("runs", &runs, INT);
+  Spark.variable("uptime", &uptime, INT);
+  Spark.variable("left_light", &leftLightOn, BOOLEAN);
+  Spark.variable("right_light", &rightLightOn, BOOLEAN);

   pinMode(LED_CS, OUTPUT);
   pinMode(THERMISTOR_CS, INPUT);
@@ -92,12 +99,14 @@
     digitalWrite(LEFT_LED, (i % 2 == 0));
     delay(200-(i*10));
   }
+  initialBootTime = millis();
 }

 void loop() {
-  runs++;
-  delay(100);
+  unsigned long currentTime = millis();
+  delay(50);
   temperature = analogRead(THERMISTOR_CS);
   photocell = analogRead(PHOTOCELL);
+  uptime = (currentTime-initialBootTime)/1000;
 }


10Hz update -> 100Hz

10Hz update -> 100Hz

--- src/sketch.ino
+++ src/sketch.ino
@@ -25,6 +25,7 @@
   Wire.onRequest(writeVoltage);
   controller.SetMode(AUTOMATIC);
   controller.SetOutputLimits(-635,635);
+  controller.SetSampleTime(10);
 }

 void loop(){
@@ -69,7 +70,8 @@
     if(controller.GetMode() == MANUAL){
       controller.SetMode(AUTOMATIC);
     }
-    return setParam(incoming, &speed);
+    setParam(incoming, &speed);
+    speed /= 10;
     break;
   case PTERM:
     setParam(incoming, &pterm);


relay test

relay test

--- _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
+++ _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
@@ -113,27 +113,27 @@
   Serial.println("IP address: ");
   Serial.println(WiFi.localIP());

-/*
-  timemillis = millis();
-
-  if (WiFi.status() == WL_CONNECTED) {
-    if (!client.connected()) {
-      if (client.connect((char*) clientName.c_str(), willTopic, 0, true, willMessage)) {
+  /*
+    timemillis = millis();
+
+    if (WiFi.status() == WL_CONNECTED) {
+      if (!client.connected()) {
+        if (client.connect((char*) clientName.c_str(), willTopic, 0, true, willMessage)) {
+          client.publish(willTopic, "1", true);
+          client.publish(hellotopic, "hello again wifi and mqtt from ESP8266 s02");
+          client.subscribe(subtopic);
+
+          Serial.println("reconnecting wifi and mqtt");
+        } else {
+          Serial.println("mqtt publish fail after wifi reconnect");
+        }
+      } else {
         client.publish(willTopic, "1", true);
-        client.publish(hellotopic, "hello again wifi and mqtt from ESP8266 s02");
+        client.publish(hellotopic, "hello again wifi from ESP8266 s02");
         client.subscribe(subtopic);
-
-        Serial.println("reconnecting wifi and mqtt");
-      } else {
-        Serial.println("mqtt publish fail after wifi reconnect");
       }
-    } else {
-      client.publish(willTopic, "1", true);
-      client.publish(hellotopic, "hello again wifi from ESP8266 s02");
-      client.subscribe(subtopic);
-    }
-  }
-*/
+    }
+  */
 }

 boolean reconnect()
@@ -175,7 +175,7 @@
     relaystatus = 0 ;
   }

-  changelight();
+  //changelight();

   if (DEBUG_PRINT) {
     Serial.print("");
@@ -305,7 +305,11 @@
     wifi_connect();
   }

-  changelight();
+  if ( relaystatus != oldrelaystatus ) {
+    changelight();
+    sendlightstatus();
+  }
+
   runTimerDoLightOff();

   pirValue = digitalRead(pir);
@@ -369,23 +373,23 @@

 void changelight()
 {
-  if ( relaystatus != oldrelaystatus )
-  {
-    Serial.print(" => ");
-    Serial.println("checking relay status changelight");
-    delay(10);
-    digitalWrite(RELAYPIN, relaystatus);
-    delay(20);
-    digitalWrite(RELAYPIN, relaystatus);
-    delay(20);
-    digitalWrite(RELAYPIN, relaystatus);
-    delay(20);
-    oldrelaystatus = relaystatus ;
-    Serial.print(" => ");
-    Serial.println("changing relay status");
-
-    sendlightstatus();
-  }
+  //  if ( relaystatus != oldrelaystatus )
+  //  {
+  Serial.print(" => ");
+  Serial.println("checking relay status changelight");
+  delay(10);
+  digitalWrite(RELAYPIN, relaystatus);
+  delay(20);
+  digitalWrite(RELAYPIN, relaystatus);
+  delay(20);
+  digitalWrite(RELAYPIN, relaystatus);
+  delay(20);
+  //oldrelaystatus = relaystatus ;
+  Serial.print(" => ");
+  Serial.println("changing relay status");
+
+  //sendlightstatus();
+  //}
 }

 void getdht22temp()
@@ -419,8 +423,11 @@
   lightpayload += relaystatus;
   lightpayload += "}";

+  /*
   sendmqttMsg(subtopic, lightpayload);
+  */
   sendmqttMsg(rslttopic, lightpayload);
+  oldrelaystatus = relaystatus ;
 }

 void sendmqttMsg(char* topictosend, String payload)


move up radio

move up radio

--- _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
+++ _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
@@ -21,7 +21,7 @@
 #define DEVICE_ID 1
 #define CHANNEL 100 //MAX 127

-#define SYS_CPU_80MHz 80
+#define SYS_CPU_80MHz 80
 #define SYS_CPU_160MHz 160

 extern "C" {
@@ -571,22 +571,6 @@
         //startMills = millis();
       }

-      if ((millis() - startMills) > REPORT_INTERVAL )
-      {
-        sendmqttMsg(topic, payload);
-        //getdalastempstatus = getdht22tempstatus = 0;
-        startMills = millis();
-        sensors.setWaitForConversion(false);
-        sensors.requestTemperatures();
-        sensors.setWaitForConversion(true);
-        bDalasstarted = true;
-
-        if (!bDHTstarted) {
-          DHT.acquire();
-          bDHTstarted = true;
-        }
-      }
-
       // radio
       if (radio.available()) {
         // from attiny 85 data size is 11
@@ -690,6 +674,23 @@
           }
         }
       }
+      if ((millis() - startMills) > REPORT_INTERVAL )
+      {
+        sendmqttMsg(topic, payload);
+        //getdalastempstatus = getdht22tempstatus = 0;
+        startMills = millis();
+        sensors.setWaitForConversion(false);
+        sensors.requestTemperatures();
+        sensors.setWaitForConversion(true);
+        bDalasstarted = true;
+
+        if (!bDHTstarted) {
+          DHT.acquire();
+          bDHTstarted = true;
+        }
+      }
+
+
       client.loop();
     }
     ArduinoOTA.handle();
@@ -846,7 +847,7 @@
     udppayload += "i,";
   }
   udppayload += "F=";
-  udppayload += ESP.getCpuFreqMHz();
+  udppayload += ESP.getCpuFreqMHz();
   udppayload += "i,C=";
   udppayload += _sensor_report_count;
   udppayload += "i,R=";


nrf24 test

nrf24 test

--- _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
+++ _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
@@ -1,3 +1,7 @@
+#include <SPI.h>
+#include <nRF24L01.h>
+#include <RF24.h>
+#include <pgmspace.h>
 #include <OneWire.h>
 #include "DHT.h"
 #include <PubSubClient.h>
@@ -7,10 +11,6 @@
 #include <Time.h>

 // radio
-#include <SPI.h>
-#include <nRF24L01.h>
-#include <RF24.h>
-// radio
 #define DEVICE_ID 2
 #define CHANNEL 1 //MAX 127

@@ -63,18 +63,21 @@
 DallasTemperature sensors(&oneWire);
 DeviceAddress outsideThermometer;

-
 // radio
 RF24 radio(3, 15);

 // Topology
 const uint64_t pipes[2] = { 0xFFFFFFFFFFLL, 0xCCCCCCCCCCLL };

-struct dataStruct{
-  unsigned long _salt;
-  float temp;
-  int volt;
-}sensor_data;
+typedef struct {
+  uint32_t _salt;
+  uint16_t volt;
+  int16_t temp;
+  int16_t humi;
+  uint8_t devid;
+} data;
+
+data sensor_data;

 // mqtt
 char* topic = "esp8266/arduino/s02";
@@ -240,6 +243,7 @@
   if (DEBUG_PRINT) {
     Serial.begin(115200);
   }
+
   delay(20);
   if (DEBUG_PRINT) {
     Serial.println("Sensor and Relay");
@@ -324,19 +328,20 @@
     if (DEBUG_PRINT) {
       Serial.println("Failed to read from DS18B20 sensor!");
     }
-    return;
+    //return;
   }

   // radio
   yield();
   radio.begin(); // Start up the radio
+  radio.setAutoAck(1); // Ensure autoACK is enabled
+  radio.setRetries(15, 15); // Max delay between retries & number of retries
   radio.setPALevel(RF24_PA_HIGH);
-  radio.setDataRate(RF24_250KBPS);
-  radio.openReadingPipe(1,pipes[0]);
-  radio.openWritingPipe(pipes[1]);
-  radio.stopListening();
+  radio.setDataRate(RF24_250KBPS);
+  radio.setPayloadSize(11);
+  radio.openReadingPipe(1, pipes[0]);
+  radio.openWritingPipe(pipes[1]);
   radio.startListening();
-
 }

 void loop()
@@ -413,8 +418,10 @@
   payload += h;
   payload += ",\"Temperature\":";
   payload += t;
-  payload += ",\"DS18B20\":";
-  payload += tempCoutside;
+  if ( (tempCoutside > -100) && (tempCoutside < 100) ) {
+    payload += ",\"DS18B20\":";
+    payload += tempCoutside;
+  }
   payload += ",\"PIRSTATUS\":";
   payload += pirValue;
   payload += ",\"FreeHeap\":";
@@ -452,18 +459,34 @@
     startMills = millis();
   }

-// radio
+  // radio
   if (radio.available()) {
     while (radio.available()) {
-      yield();
       radio.read(&sensor_data, sizeof(sensor_data));
+
+      if (DEBUG_PRINT) {
+        Serial.print(" ****** radio ======> size : ");
+        Serial.print(sizeof(sensor_data));
+        Serial.print(" _salt : ");
+        Serial.print(sensor_data._salt);
+        Serial.print(" volt : ");
+        Serial.print(sensor_data.volt);
+        Serial.print(" temp : ");
+        Serial.print(sensor_data.temp);
+        Serial.print(" humi : ");
+        Serial.println(sensor_data.humi);
+      }

       String radiopayload = "{\"_salt\":";
       radiopayload += sensor_data._salt;
       radiopayload += ",\"volt\":";
       radiopayload += sensor_data.volt;
       radiopayload += ",\"temp\":";
-      radiopayload += sensor_data.temp;
+      radiopayload += ((float)sensor_data.temp / 10);
+      radiopayload += ",\"humi\":";
+      radiopayload += ((float)sensor_data.humi / 10);
+      radiopayload += ",\"devid\":";
+      radiopayload += sensor_data.devid;
       radiopayload += "}";

       sendmqttMsg(radiotopic, radiopayload);
@@ -472,7 +495,6 @@
   }

   client.loop();
-
 }

 void runTimerDoLightOff()
@@ -533,7 +555,7 @@
   sensors.requestTemperatures();
   tempCoutside  = sensors.getTempC(outsideThermometer);

-  if ( isnan(tempCoutside)  ) {
+  if ( isnan(tempCoutside) || tempCoutside < -50  ) {
     if (DEBUG_PRINT) {
       Serial.println("Failed to read from sensor!");
     }


Add testing routines

Add testing routines

--- src/wolves.ino
+++ src/wolves.ino
@@ -9,31 +9,64 @@
 #define N_OF_QUESTIONS 3

 LED leds[N_OF_QUESTIONS] = {
-    LED(0,0),
-    LED(0,0),
-    LED(0,0)
+    LED(23,24),
+    LED(33,34),
+    LED(43,44)
 };

 RFIDSensor sensors[N_OF_QUESTIONS] = {
-    RFIDSensor(0, 0, 0),
-    RFIDSensor(1, 0, 0),
-    RFIDSensor(2, 0, 0)
+    RFIDSensor(0, 22, 53),
+    RFIDSensor(1, 32, 53),
+    RFIDSensor(2, 42, 53)
 };

 Solenoid solenoids[N_OF_QUESTIONS] = {
-    Solenoid(0, sensors[0], leds[0]),
-    Solenoid(0, sensors[1], leds[1]),
-    Solenoid(0, sensors[2], leds[2]),
+    Solenoid(25, sensors[0], leds[0]),
+    Solenoid(35, sensors[1], leds[1]),
+    Solenoid(45, sensors[2], leds[2]),
 };

-void setup() {
-    app.statusLed = new RGBLED(0,0,0);
+void testStatusLed() {
+    app.statusLed.setColor(COLOR_RED);
+    delay(1000);
+    app.statusLed.setColor(COLOR_GREEN);
+    delay(1000);
+    app.statusLed.setColor(COLOR_BLUE);
+    delay(1000);
+    app.statusLed.off();
+}
+
+void testQuestions() {
     for (int i = 0; i < N_OF_QUESTIONS; i++) {
-        leds[i].begin();
-        sensors[i].begin();
-        solenoids[i].begin();
+        leds[i].red();
+        solenoids[i].on();
+        delay(200);
+    }
+    delay(1000);
+    for (int i = 0; i < N_OF_QUESTIONS; i++) {
+        leds[i].green();
+        solenoids[i].off();
+        delay(200);
+    }
+    delay(1000);
+    for (int i = 0; i < N_OF_QUESTIONS; i++) {
+        leds[i].off();
     }
 }

+void setup() {
+    Serial.begin(9600);
+    app.statusLed.begin(2,3,4);
+    for (int i = 0; i < N_OF_QUESTIONS; i++) {
+        leds[i].begin();
+        //sensors[i].begin();
+        solenoids[i].begin();
+    }
+    // Testing
+    testStatusLed();
+    testQuestions();
+}
+
+

 void loop() {}


Added delay to subscription example

Added delay to subscription example

--- examples/rapifire-mqtt-simple-subscribe/rapifire-mqtt-simple-subscribe.ino
+++ examples/rapifire-mqtt-simple-subscribe/rapifire-mqtt-simple-subscribe.ino
@@ -37,5 +37,7 @@
   }

   rapifire.loop();
+
+  delay(500);
 }


Pin Setup

Pin Setup

--- Pickup_sponge/Pickup_sponge.ino
+++ Pickup_sponge/Pickup_sponge.ino
@@ -10,6 +10,12 @@
 #define CCW_LIMIT_ANGLE 0xFFF       // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode
 #define OPEN 'o'
 #define CLOSE 'c'
+
+//                PIN Setup:  Green wire to PIN 10,                                                                           //
+//                            Yellow wire to PIN 11,                                                                          //
+//                            Black wire to ground,                                                                           //
+//                            Red wire to 5v,                                                                                //
+//                            Blue wire to PIN2                                                                               //

 SoftwareSerial mySerial(10, 11);    // RX, TX

@@ -35,11 +41,11 @@
   Dynamixel.setProfileAcceleration(0x05, 300);

   //Set profile velocity
-  Dynamixel.setProfileVelocity(0x01, 100);              //Set profile vel for each servo
+  Dynamixel.setProfileVelocity(0x01, 100);              //Set profile vel for each servo
   Dynamixel.setProfileVelocity(0x02, 100);
   Dynamixel.setProfileVelocity(0x03, 100);
   Dynamixel.setProfileVelocity(0x04, 200);
-  Dynamixel.setProfileVelocity(0x05, 200);
+  Dynamixel.setProfileVelocity(0x05, 200);
  }

 void loop() {
@@ -57,7 +63,7 @@
   delay(2000);

-  Dynamixel.performMovement(1600, 2800, 3200, OPEN);      //Move to sponge.
+  Dynamixel.performMovement(1600, 2800, 3200, OPEN);      //Move to sponge.
   Dynamixel.gripper(CLOSE);                               //Grab
   Dynamixel.performMovement(2148, 1850, 3250, CLOSE);     //Detour
   Dynamixel.performMovement(2650, 2800, 3200, CLOSE);     //Move to destination


simple multi modes working

simple multi modes working

--- moodylite.ino
+++ moodylite.ino
@@ -84,10 +84,14 @@
 	}
 	RGB pattern2[] = {blue, blue, red};
 	Mode mode2(callback2, pattern2);//passing the function instead of a color list as the 1st arg
+
+	//pink color scheme
+	const RGB pink_colors[] = {red, purple, RGB(255, 0, 170), RGB(153, 0, 255)};
+	Mode pink(pink_colors, 5);

 	//add modes to the mode list
-	Mode *modelist[] = {&mode1};
+	Mode *modelist[] = {&mode1, &pink};

 //**OTHER SETTINGS**//
 	void modeSetup() {
@@ -97,6 +101,8 @@

 		mode1.isHSV = false;
 		mode1.random = true;
+		pink.isHSV = false;
+		pink.random = true;
 	}
 	// const unsigned long interval = 5000; //the interval of color change, the time it takes to fade from one color to the next
 	const unsigned long interval = 750;//fast for testing
@@ -112,9 +118,11 @@
 	const RGB *activeColorList = nullptr; //the active color list from the active mode
 	uint8_t currentMode = 0; //the current mode index
 	uint8_t currentColor = 0; //the current colot index (note current here is used for indexes and active is used for pointers)
-
+	bool buttons[2], buttonsOld[2] = {false, false};//the current and prev button states
+
 	//forward declarations
 	RGB getNextColor();//get next color from color list
+	void nextMode();//switch to the next mode
 	void setOutputColor(RGB);//set the argument color as the pwn output to the actual lights
 	void linearFade();
 	void hsvFade();
@@ -220,7 +228,32 @@
 		analogWrite(CFG::GPIN, color.g);
 		analogWrite(CFG::BPIN, color.b);
 	}
-
+	Timer btnTimer;//used for debouncing
+	void btn_tick() {//handles button input
+		if(!btnTimer.Every(20))//only run every 20ms
+			return;
+		//get states from pins
+		buttons[0] = !digitalRead(CFG::BTN1);//invert so that high is false and low is true
+		buttons[1] = !digitalRead(CFG::BTN2);
+		//button logic
+		//TODO add overriding logic here for callbacks
+		if (buttons[0] > buttonsOld[0]) {//if button 1 has gone from up to down
+			nextMode();
+		}
+		if (buttons[1] > buttonsOld[1]) {//if button 2 has gone from up to down
+			//add dimming here
+		}
+		//update old states
+		buttonsOld[0] = buttons[0];
+		buttonsOld[1] = buttons[1];
+	}
+	void nextMode() {
+		uint8_t len = sizeof(CFG::modelist)/sizeof(Mode*);//get length
+		if (++currentMode == len) //check for out of bounds and reset if needed
+			currentMode = 0;
+		activeMode = CFG::modelist[currentMode];//set activeMode to the next mode in the list
+		//animT.Reset();//make the animation start over
+	}
 }

 void setup() {
@@ -247,4 +280,5 @@

 void loop() {
 	Moody::anim_tick();
+	Moody::btn_tick();
 }


Servo_test update

Servo_test update

--- arduino/AP_Utils/examples/servo_test/servo_test.ino
+++ arduino/AP_Utils/examples/servo_test/servo_test.ino
@@ -21,7 +21,7 @@
 //be extremely careful when changing these, only in small incremets (about 10) at a time
 //too big change (100 and more) can cause your servos gears to break!
 #define SERVOMIN 150
-#define SERVOMAX 560
+#define SERVOMAX 530

 //create Adafruit PWM Servo Driver object to directly control the PWM outputs
 Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
@@ -33,29 +33,19 @@
 }

 void loop() {
-  //move first servo from middle to max position
-  for(int pulse=(SERVOMAX-SERVOMIN)/2; pulse<=SERVOMAX; pulse++) {
+  //move from max position to min
+  for(int pulse=SERVOMAX; pulse>=SERVOMIN; pulse--) {
     pwm.setPWM(15, 0, pulse);
     Serial.println(pulse);
     delay(10);
   }
-  //wait 3 seconds to allow power to be unplugged
   delay(3000);

-  //move from min to max and back forever
-  while(true) {
-    for(int pulse=SERVOMAX; pulse>=SERVOMIN; pulse--) {
-      pwm.setPWM(15, 0, pulse);
-      Serial.println(pulse);
-      delay(10);
-    }
-    delay(3000);
-
-    for(int pulse=SERVOMIN; pulse<=SERVOMAX; pulse++) {
-      pwm.setPWM(15, 0, pulse);
-      Serial.println(pulse);
-      delay(10);
-    }
-    delay(3000);
+  //move from min position to max
+  for(int pulse=SERVOMIN; pulse<=SERVOMAX; pulse++) {
+    pwm.setPWM(15, 0, pulse);
+    Serial.println(pulse);
+    delay(10);
   }
+  delay(3000);
 }


dont reset the count on append

dont reset the count on append

--- firmware/sentry.ino
+++ firmware/sentry.ino
@@ -152,9 +152,6 @@

   // Split the data on tabs and new lines, since we know each row has 3 fields.
   const char delim[3] = "\t\n";
-
-  // Reset the card count.
-  numCards = 0;

   // Loop this from 0 to 2 so we know which of the 3 card fields we're processing.
   int fieldIdx = 0;


[WifiDude] Implemented timeout on response read.

Signed-off-by: Juri Berlanda <5bfdca9e82c53adb0603ce7083f4ba4f2da5cacf@hotmail.com>

--- laundry-dude-xbee-bridge/laundry-dude-xbee-bridge.ino
+++ laundry-dude-xbee-bridge/laundry-dude-xbee-bridge.ino
@@ -30,7 +30,11 @@
 	while (xbeeSerial.available()) xbeeSerial.read();
 	// put your main code here, to run repeatedly:
 	xbeeSerial.print(type);
-	while (!xbeeSerial.available());
+	int x = 0;
+	while (!xbeeSerial.available() && x < 10) {
+		x++;
+		delay(100);
+	}
 	recvWithEndMarker();
 	sendData();
 }


temp 2

temp 2

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -18,7 +18,7 @@

 // Change this any time the EEPROM content changes
 const long magic_number = 0x0326;
-
+
 struct __eeprom_data {
   long magic;
   boolean pwrSrc;     // True : connected to TV, False : usb powered
@@ -72,19 +72,22 @@
 long tempMills;
 long o_tempMills;

+// temp
+boolean o_tempminpassed = 0;
+
 // sw status
 int setUpStatus;
 int wrkModeStatus;

 // eeprom status
-boolean o_pwrSrc;
-boolean o_wrkMode;
-boolean o_startMode;
-boolean o_beepMode;
-boolean o_offMode;
-int o_channelGap;
-int o_tvOnTime;
-int o_tvOffTime;
+boolean o_pwrSrc;
+boolean o_wrkMode;
+boolean o_startMode;
+boolean o_beepMode;
+boolean o_offMode;
+int o_channelGap;
+int o_tvOnTime;
+int o_tvOffTime;

 // lcd
 byte termometru[8] =
@@ -106,6 +109,7 @@

   // start serial
   Serial.begin (38400);
+  Serial.println();
   Serial.println("TV controller Starting");
   delay(20);

@@ -139,23 +143,23 @@
   setUpStatus   = digitalRead(SETUP_IN_PIN);
   wrkModeStatus = digitalRead(WRK_MODE_IN_PIN);

-  // initialize eeprom
+  // initialize eeprom
   long magic;
   eeprom_read(magic, magic);
   if ((magic != magic_number) || ( setUpStatus == 0 )) {
-     run_initialise_setup();
-     resetFunc();
+    run_initialise_setup();
+    resetFunc();
   }

   // eeprom read
-  eeprom_read(o_pwrSrc, pwrSrc);
-  eeprom_read(o_wrkMode, wrkMode);
-  eeprom_read(o_startMode, startMode);
-  eeprom_read(o_beepMode, beepMode);
-  eeprom_read(o_offMode, offMode);
-  eeprom_read(o_channelGap, channelGap);
-  eeprom_read(o_tvOnTime, tvOnTime);
-  eeprom_read(o_tvOffTime, tvOffTime);
+  eeprom_read(o_pwrSrc, pwrSrc);
+  eeprom_read(o_wrkMode, wrkMode);
+  eeprom_read(o_startMode, startMode);
+  eeprom_read(o_beepMode, beepMode);
+  eeprom_read(o_offMode, offMode);
+  eeprom_read(o_channelGap, channelGap);
+  eeprom_read(o_tvOnTime, tvOnTime);
+  eeprom_read(o_tvOffTime, tvOffTime);

   // temp sensor
   sensors.begin();
@@ -176,7 +180,7 @@
   lcd.write(1);

   lcd.setCursor(6, 0);
-  lcd.print((char)223);
+  lcd.print((char)223);

 }

@@ -184,17 +188,21 @@
 void loop()
 {

-  if ( millis() - tempMills >= 5000 ) {
-     getdalastemp();
-     displayTemperature();
-     tempMills = millis();
-  }
-
-  if ( millis() - o_tempMills >= 1800000 ) {
+  if ( (millis() - tempMills) >= 2000 ) {
+    getdalastemp();
+    displayTemperature();
+    tempMills = millis();
+
+    if ( (millis() - o_tempMills) >= 60000 ) {
+      Serial.println("o_tempCinside called");
       o_tempCinside = c_tempCinside;
       c_tempCinside = tempCinside;
+      o_tempminpassed = 1;
       o_tempMills = millis();
-  }
+    }
+
+  }
+

   /*
    *
@@ -213,14 +221,14 @@
     delay(1000);
   */

-/*
-  decode_results results;
-
-  if (irrecv.decode(&results)) {
-    dumpInfo(&results);
-
-  }
-*/
+  /*
+    decode_results results;
+
+    if (irrecv.decode(&results)) {
+      dumpInfo(&results);
+
+    }
+  */

 }

@@ -242,13 +250,15 @@
   lcd.setCursor(1, 0);
   displayTemperaturedigit(tempCinside);

-  if ( !isnan(o_tempCinside) ) {
-     float tempdiff = o_tempCinside - tempCinside;
+  if ( o_tempminpassed == 0 ) {
+    return;
+  } else {
+    float tempdiff = o_tempCinside - tempCinside;

     lcd.setCursor(8, 0);
-    if ( tempdiff > 0 ) {
+    if ( tempdiff >= 0 ) {
       lcd.print("+");
-    } else if ( tempdiff < 0 ) {
+    } else {
       lcd.print("-");
     }

@@ -259,7 +269,7 @@
     lcd.print(abs(tempdiff), 1);
     if ( length_tempdiff == 1) {
       lcd.print(" ");
-    }
+    }

   }

@@ -316,18 +326,18 @@
 {
   decode_results results;
   irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
+  while (irrecv.decode(&results) != 1 ) { }

   switch (results.value) {
     case 0xFF02FD:
-        return 1;
-        break;
+      return 1;
+      break;
     case 0xFF9867:
-        return 0;
-        break;
+      return 0;
+      break;
     default:
-        initialise_boolean_select();
-        break;
+      initialise_boolean_select();
+      break;
   }
 }

@@ -336,28 +346,28 @@

   lcd.setCursor(13, 1);
   lcd.print(curno);
-
+
   decode_results results;
   irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
+  while (irrecv.decode(&results) != 1 ) { }

   switch (results.value) {
     case 0xFF02FD:
-        if ( curno >= maxno ) {
-             curno = minno;
-        } else {
-             curno = curno + chstep ;
-        }
-        lcd.setCursor(13, 1);
-        lcd.print(curno);
-        initialise_number_select(minno, maxno, curno, chstep);
-        break;
+      if ( curno >= maxno ) {
+        curno = minno;
+      } else {
+        curno = curno + chstep ;
+      }
+      lcd.setCursor(13, 1);
+      lcd.print(curno);
+      initialise_number_select(minno, maxno, curno, chstep);
+      break;
     case 0xFF9867:
-        return curno;
-        break;
+      return curno;
+      break;
     default:
-        initialise_number_select(minno, maxno, curno, chstep);
-        break;
+      initialise_number_select(minno, maxno, curno, chstep);
+      break;
   }
 }

@@ -374,7 +384,7 @@
   lcd.print("*");

   irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
+  while (irrecv.decode(&results) != 1 ) { }

   lcd.clear();
   lcd.setCursor(0, 0);
@@ -382,183 +392,183 @@
   lcd.setCursor(0, 1);
   lcd.print("power source");
   lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : from TV");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: from other");
+  lcd.print("OFF: from other");

   boolean pwrSrc = initialise_boolean_select();

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("working mode");
   lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : TV + thermo");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: thermo");
+  lcd.print("OFF: thermo");

   boolean wrkMode = initialise_boolean_select();

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("start mode");
   lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : Auto start");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: do nothing");
-
-  boolean startMode = initialise_boolean_select();
+  lcd.print("OFF: do nothing");
+
+  boolean startMode = initialise_boolean_select();

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("beep mode");
-   lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+  lcd.setCursor(15, 1);
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : beep on");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: beep off");
+  lcd.print("OFF: beep off");

   boolean beepMode = initialise_boolean_select();

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("TV off mode");
   lcd.setCursor(15, 1);
   lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : TV on/off");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: IN change");
-
-  boolean offMode = initialise_boolean_select();
+  lcd.print("OFF: IN change");
+
+  boolean offMode = initialise_boolean_select();

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("channel gap");
   lcd.setCursor(15, 1);
   lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : change no");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: done");
-
-  int channelGap = initialise_number_select(1, 5, 1, 1);
+  lcd.print("OFF: done");
+
+  int channelGap = initialise_number_select(1, 5, 1, 1);

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select timer");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("for TV auto off");
-   lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+  lcd.setCursor(15, 1);
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : change no");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: done");
-
-  int tvOnTime = initialise_number_select(30, 90, 50, 5);
+  lcd.print("OFF: done");
+
+  int tvOnTime = initialise_number_select(30, 90, 50, 5);

   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Select timer");
-  lcd.setCursor(0, 1);
+  lcd.setCursor(0, 1);
   lcd.print("for TV auto on");
-   lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+  lcd.setCursor(15, 1);
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("ON : change no");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: done");
-
-  int tvOffTime = initialise_number_select(5, 20, 10, 5);
+  lcd.print("OFF: done");
+
+  int tvOffTime = initialise_number_select(5, 20, 10, 5);

   //
   boolean initialise_eeprom_done =  initialise_eeprom(pwrSrc, wrkMode, startMode, beepMode, offMode, channelGap, tvOnTime, tvOffTime) ;

-  while(initialise_eeprom_done != 1 ) { }
-
-  lcd.clear();
+  while (initialise_eeprom_done != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Setup is done");
   lcd.setCursor(0, 1);
   if ( setUpStatus == 0 ) {
-      lcd.print("change setup sw");
-  }
-  lcd.setCursor(15, 1);
-  lcd.print("*");
-
-  irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-  lcd.clear();
+    lcd.print("change setup sw");
+  }
+  lcd.setCursor(15, 1);
+  lcd.print("*");
+
+  irrecv.resume();
+  while (irrecv.decode(&results) != 1 ) { }
+
+  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Press any button");
   lcd.setCursor(0, 1);
   lcd.print("to reset");

   irrecv.resume();
-  while(irrecv.decode(&results) != 1 ) { }
-
-}
-
-
-boolean initialise_eeprom(boolean i_pwrSrc, boolean i_wrkMode, boolean i_startMode, boolean i_beepMode, boolean i_offMode, int i_channelGap, int i_tvOnTime, int i_tvOffTime)
+  while (irrecv.decode(&results) != 1 ) { }
+
+}
+
+
+boolean initialise_eeprom(boolean i_pwrSrc, boolean i_wrkMode, boolean i_startMode, boolean i_beepMode, boolean i_offMode, int i_channelGap, int i_tvOnTime, int i_tvOffTime)
 {
   eeprom_write(i_pwrSrc, pwrSrc);
   eeprom_write(i_wrkMode, wrkMode);
@@ -573,6 +583,6 @@
   return 1;
 }

-/*
+/*
 *
-*/+*/


low memory, need opti

low memory, need opti

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -387,7 +387,9 @@
         if ( o_wrkMode == 0 ) {
           t.stop(tvIsOffEvent);
           t.stop(tvIsOnEvent);
+          timerStatus = 0;
         } else {
+          timerStatus = 1;
           tvOnTimer();
           temp_Mills = millis();
         }
@@ -410,7 +412,9 @@
         if ( tvPowerStatus == 1 ) {
           t.stop(tvIsOffEvent);
           t.stop(tvIsOnEvent);
+          timerStatus = 0;
         } else {
+          timerStatus = 1;
           tvOnTimer();
           temp_Mills = millis();
         }
@@ -435,14 +439,16 @@

 void tvOnTimer()
 {
+
+  tvIsOnEvent = t.every((o_tvOnTime * 1000 * 60) , doTvOffTimer);
   t.stop(tvIsOffEvent);
-  tvIsOnEvent = t.every(o_tvOnTime * 1000 * 60 , doTvOffTimer);
 }

 void tvOffTimer()
 {
+
+  tvIsOffEvent = t.every((o_tvOffTime * 1000 * 60) , doTvOnTimer);
   t.stop(tvIsOnEvent);
-  tvIsOffEvent = t.every(o_tvOffTime * 1000 * 60 , doTvOnTimer);
 }

 void doTvOffTimer()
@@ -486,7 +492,7 @@
 }

-void irSendTvbytimer()
+void irSendTvbytimer(int onoff)
 {
   switch (onoff) {
     case 1:
@@ -508,7 +514,7 @@
   }
 }

-void irSendTvbypir()
+void irSendTvbypir(int onoff)
 {
   if ( tvPowerStatus == 1 ) {
     switch (onoff) {
@@ -575,7 +581,7 @@
     }
     lcd.print(str_a);
   } else {
-    lcd.print("   ");
+    lcd.print("---");
   }

 }


remove DirectConnect example

remove DirectConnect example

--- examples/BoardsAndShields/ESP8266_DirectConnect/ESP8266_DirectConnect.ino
+++ examples/BoardsAndShields/ESP8266_DirectConnect/ESP8266_DirectConnect.ino
@@ -1,171 +0,0 @@
-/**************************************************************
- * Blynk is a platform with iOS and Android apps to control
- * Arduino, Raspberry Pi and the likes over the Internet.
- * You can easily build graphic interfaces for all your
- * projects by simply dragging and dropping widgets.
- *
- *   Downloads, docs, tutorials: http://www.blynk.cc
- *   Blynk community:            http://community.blynk.cc
- *   Social networks:            http://www.fb.com/blynkapp
- *                               http://twitter.com/blynk_app
- *
- * Blynk library is licensed under MIT license
- * This example code is in public domain.
- *
- **************************************************************
- * This example shows how to connect to ESP8266 directly
- * without using intermediate server.
- *
- * Please note: this example is for experienced users.
- * Use this wiring for improved stability:
- *   https://github.com/esp8266/Arduino/blob/esp8266/docs/ESP_improved_stability.png
- *
- * !!!
- * NOTE: Blynk Apps currently do not support direct TCP connection.
- * Wait for new updates!
- *
- **************************************************************/
-
-#define BLYNK_USE_DIRECT_CONNECT
-//#define BLYNK_DEBUG
-#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
-#include <ESP8266WiFi.h>
-#include <BlynkSimpleUserDefined.h>
-
-// Uncomment this to set WiFi to Access Point mode
-#define WIFI_MODE_AP
-
-// Set these to your credentials.
-const char ssid[]     = "Blynk-AP";    // WiFi name
-const char password[] = "12345678";   // WiFi password
-
-// Set port of the server
-const int port = 8442;
-
-// Auth token doesn't matter with direct-connect
-char auth[] = "";
-
-// Description of the dashboard
-char profile[] = R"json(
-  {
-    "dashBoards": [
-      {
-        "id": 1,
-        "name": "Direct connect",
-        "boardType": "ESP8266",
-        "widgets": [
-          {
-            "id": 2,
-            "type": "DIGIT4_DISPLAY",
-            "pinType": "VIRTUAL",
-            "pin": 9,
-            "x": 5,
-            "y": 1,
-            "frequency": 1000
-          },
-          {
-            "id": 3,
-            "type": "BUTTON",
-            "pinType": "VIRTUAL",
-            "pin": 1,
-            "x": 2,
-            "y": 1
-          }
-        ]
-      }
-    ]
-  }
-)json";
-
-// Virtual handlers for our widgets...
-
-BLYNK_READ(V9) {
-  Blynk.virtualWrite(9, millis() / 1000);
-}
-
-BLYNK_WRITE(V1) {
-  BLYNK_LOG("Button event");
-}
-
-// Next goes the hard stuff: connection management, etc...
-
-WiFiServer server(port);
-WiFiClient client;
-
-// This function is used by Blynk to receive data
-size_t BlynkStreamRead(void* buf, size_t len)
-{
-  return client.readBytes((byte*)buf, len);
-}
-
-// This function is used by Blynk to send data
-size_t BlynkStreamWrite(const void* buf, size_t len)
-{
-  return client.write((byte*)buf, len);
-}
-
-void setup()
-{
-  delay(1000);
-  // Setup your connection here.
-  Serial.begin(9600);
-  Serial.println();
-
-  Blynk.begin(auth);
-  Blynk.setProfile(profile);
-
-#ifdef WIFI_MODE_AP
-  BLYNK_LOG("Configuring WiFi access point: %s", ssid);
-  WiFi.softAP(ssid, password);
-  Serial.print("AP IP address: ");
-  Serial.println(WiFi.softAPIP());
-#else
-  BLYNK_LOG("Connecting to WiFi %s", ssid);
-  WiFi.begin(ssid, password);
-  while (WiFi.status() != WL_CONNECTED) {
-    delay(500);
-    Serial.print(".");
-  }
-  Serial.println();
-  Serial.print("STA IP address: ");
-  Serial.println(WiFi.localIP());
-#endif
-
-  server.begin();
-  BLYNK_LOG("Listening on port: %d", port);
-}
-
-void loop()
-{
-  client = server.available();
-  // Make sure that Blynk.run() is called
-  // only when the connection is established
-  if (client) {
-    Serial.print("Client connected from ");
-    Serial.print(client.remoteIP());
-    Serial.print(":");
-    Serial.println(client.remotePort());
-
-    // Wait for connection
-    unsigned long start = millis();
-    while (!client.connected() && (millis() - start < 1000)) {
-      delay(5);
-    }
-
-    // Go!!!
-    Blynk.startSession();
-    while (client.connected()) {
-      // Okay, handle Blynk protocol
-      bool hasIncomingData = (client.available() > 0);
-      // Tell Blynk if it has incoming data
-      // (this allows to skip unneeded BlynkStreamRead calls)
-      if (!Blynk.run(hasIncomingData)) {
-        Serial.print("Error happened or disconnected.");
-        break;
-      }
-    }
-    client.stop();
-    Serial.println("Client disconnected.");
-  }
-}
-


Add turnUntilNext action

Add turnUntilNext action

Signed-off-by: Mark Knoop <f1b5a91d4d6ad523f2610114591c007e75d15084@markknoop.com>

--- src/sketch.ino
+++ src/sketch.ino
@@ -50,6 +50,7 @@
 #define rReset         13
 #define rDoubleGliss   14
 #define rSetSustain    15
+#define rTurnUntilNext 16
 // array sizes
 #define rDurlength      5
 #define rLength        25
@@ -179,6 +180,28 @@
         if (alarmState) return;
     }
     findSensor(startstoppulse);
+}
+
+void turnUntilNext(float pitch, bool dir) {
+    // leave this without durationTurn adjustments
+    int pulse = pitchToPulse(pitch);
+    int startstoppulse = max(maxPulse, pulse);
+    digitalWrite(dirPin, dir);
+    delayMicroseconds(pulseWidth);
+    for (int i=0; i<accelSteps; i++) {
+        oneStep(map(i, 0, accelSteps, startstoppulse, pulse));
+        if (alarmState) return;
+    }
+    sendReady();
+    while (Serial.available() == 0) {
+        oneStep(pulse);
+        if (alarmState) return;
+    }
+    for (int i=0; i<accelSteps; i++) {
+        oneStep(map(i, 0, accelSteps, pulse, startstoppulse));
+        if (i>(accelSteps - decelLook) && digitalRead(sensorPin)) break;
+        if (alarmState) return;
+    }
 }

 void gliss(int halfturns, float startpitch, float endpitch, bool dir) {
@@ -563,6 +586,8 @@
                 newSustainDuration[d] = serialIncoming[++i];
             }
             sustainDuration = atol(newSustainDuration);
+        } else if (data == rTurnUntilNext) {
+            turnUntilNext(startPitch, Dir);
         } else if (data < 21) {
         } else if (data < 40) {
             halfTurns = data - 20;


シリアル通信で受け取る処理追加

シリアル通信で受け取る処理追加

--- src/sketch.ino
+++ src/sketch.ino
@@ -22,17 +22,26 @@
  1,0,0,0,0,0,0,1,
  1,0,0,0,0,0,0,1,
  0,1,1,1,1,1,1,0};
+
 void setup()
 {
+   Serial.begin(38400);
    ledbegin(0x70, 10);
+   ledmatrixclear();      // clear display
+   setBitmap();
+   writeDisplay();  // write the changes we just made to the display
 }

 void loop()
 {
-    ledmatrixclear();      // clear display
-    setBitmap();
-    writeDisplay();  // write the changes we just made to the display
-    delay(500);
+    if(Serial.available()>=63){
+      for(int i=0;i<64;i++)
+        get_array[i] = Serial.read();
+      setBitmap();
+      writeDisplay();  // write the changes we just made to the display
+      ledmatrixclear();      // clear display
+      Serial.flush();
+    }
 }
 void setBrightness(uint8_t b) {
   if (b > 15) b = 15;
@@ -58,7 +67,9 @@
 }

 void ledmatrixclear(void) {
-  for (uint8_t i=0; i<8; i++) {
+  for (int i=0; i<64; i++) {
+    //get_array[i] = 0;
+    //bitmap[i] = 0;
     displaybuffer[i] = 0;
   }
 }


Rotating camera now publishes its orientation after it finishes a rotation. (Untested).

--- src/RotatingCamera/RotatingCamera.ino
+++ src/RotatingCamera/RotatingCamera.ino
@@ -43,7 +43,10 @@
 void driveUp(void);
 void driveDown(void);

-ros::Subscriber<std_msgs::Int32> cvDegreeReader("camera_angle", &desiredCameraPosChanged);
+ros::Subscriber<std_msgs::Int32> cvDegreeReader("target_camera_angle", &desiredCameraPosChanged);
+
+std_msgs::Int32 currentCameraAngle;
+ros::Publisher cvDegreePublisher("current_camera_angle", &currentCameraAngle);

 void setup(){

@@ -54,6 +57,7 @@
   digitalWrite(ENABLE, HIGH); //the motor should not make loud screeching
   nh.initNode();
   nh.subscribe(cvDegreeReader);
+  nh.advertise(cvDegreePublisher);
   //Serial.begin(9600);
 }

@@ -73,12 +77,6 @@
     desiredDegrees = angle % 360;
     // Step = Degrees / steps per degree * gear ratio
     desiredStep = int(desiredDegrees/stepDegree)*19;
-    Serial.print("Going to degree: ");
-    Serial.print(desiredDegrees);
-    Serial.print(" (Desired step: ");
-    Serial.print(desiredStep);
-    Serial.print("; current step: ");
-    Serial.println(stepCount);
   if(stepCount == desiredStep)
   {
 	  return;
@@ -95,7 +93,9 @@

 void desiredCameraPosChanged( const std_msgs::Int32& newPos){
     desiredDegrees = newPos.data;
-    rotateToFaceAngle(desiredDegrees);
+    currentCameraAngle.data = desiredDegrees;
+	rotateToFaceAngle(desiredDegrees);
+	cvDegreePublisher.publish(&currentCameraAngle);
 }


update example with TaskScheduler

update example with TaskScheduler

--- examples/01_backend/LCDML_011_TaskScheduler/LCDML_display_menuFunction.ino
+++ examples/01_backend/LCDML_011_TaskScheduler/LCDML_display_menuFunction.ino
@@ -51,7 +51,15 @@
   {
     // setup
     // start thread
-    t2.enable();
+    if(t2.isEnabled() == false)
+    {
+      t2.enable();
+    }
+    else
+    {
+      Serial.println("is enabled");
+    }
+

     // end function and go an layer back
     LCDML.FUNC_goBackToMenu(1);      // leave this function
@@ -67,7 +75,14 @@
   {
     // setup
     // stop thread
-    t2.disable();
+    if(t2.isEnabled() == true)
+    {
+      t2.disable();
+    }
+    else
+    {
+      Serial.println("is disabled");
+    }

     // end function and go an layer back
     LCDML.FUNC_goBackToMenu(1);      // leave this function
@@ -328,4 +343,4 @@
   {
     // you can here reset some global vars or do nothing
   }
-}
+}


Add two leds for show robot color

Add two leds for show robot color

--- pug.ino
+++ pug.ino
@@ -12,7 +12,10 @@

 #define colorPin 2
 #define jumperPin 3
-#define enemyLedPin 5
+
+#define enemyLedPin 13
+#define greenLedPin 7
+#define yellowLedPin 6

 #define starterServoPin 19

@@ -152,8 +155,11 @@
   pinMode(colorPin, INPUT);

   // Debug led
-  pinMode(13, OUTPUT);
   pinMode(enemyLedPin, OUTPUT);
+  pinMode(6, OUTPUT);
+  pinMode(7, OUTPUT);
+  digitalWrite(6, HIGH);
+  digitalWrite(7, HIGH);

   // Jumper
   pinMode(jumperPin, INPUT);
@@ -161,11 +167,9 @@
   // Serial
   Serial.begin(9600);

-  if (isGreen()) {
-    digitalWrite(13, LOW);
-  } else {
-    digitalWrite(13, HIGH);
-  }
+  // Highlight leds in function of robot color
+  digitalWrite(greenLedPin, isGreen());
+  digitalWrite(yellowLedPin, !isGreen());
 }

 void loop() {


wiring_analog.c   corrected ROM_SysCtlPeripheralEnable argument for tiva TestAnalogOut.ino changed the of analogoutpins, the tests to match table 13-2 pins_energia.h    corrected 2 pin defs

--- hardware/lm4f/variants/launchpad_129/tests/TestAnalogOut/TestAnalogOut.ino
+++ hardware/lm4f/variants/launchpad_129/tests/TestAnalogOut/TestAnalogOut.ino
@@ -25,6 +25,7 @@

 #define DEBUG 1

+// from Table 13-2. General-Purpose Timers Signals (128TQFP)
 analogoutpin_t analogoutpins[] = {
 // T0CCP0
     {"PD_0","X11_50",PD_0}, // no led


changed output to TEAPOT

changed output to TEAPOT

--- arduino/MPU6050_DMP6/MPU6050_DMP6.ino
+++ arduino/MPU6050_DMP6/MPU6050_DMP6.ino
@@ -97,7 +97,7 @@
 // from the FIFO. Note this also requires gravity vector calculations.
 // Also note that yaw/pitch/roll angles suffer from gimbal lock (for
 // more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
-#define OUTPUT_READABLE_YAWPITCHROLL
+//#define OUTPUT_READABLE_YAWPITCHROLL

 // uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
 // components with gravity removed. This acceleration reference frame is
@@ -114,7 +114,7 @@

 // uncomment "OUTPUT_TEAPOT" if you want output that matches the
 // format used for the InvenSense teapot demo
-//#define OUTPUT_TEAPOT
+#define OUTPUT_TEAPOT


more failed attempts at printer head

more failed attempts at printer head

--- sketchbook/printer/printer.ino
+++ sketchbook/printer/printer.ino
@@ -1,3 +1,4 @@
+#include <Servo.h>
 #include <Motor.h>
 #include <Switch.h>

@@ -10,11 +11,12 @@
 Motor motorX(2, 3, 4, 5);
 Motor motorY(6, 7, 8, 9);
 Motor motorZ(10, 11, 12, 13);
-Switch head(14); // change this
+Servo head;

 void setup() {
     Serial.begin(9600);
     while(!Serial);
+    head.attach(A0);
 }

 void setPos(int & pos, Motor & motor) {
@@ -130,10 +132,12 @@
                 cmdMotor(posZ, motorZ);
                 break;
             case '+': // head on
-                head.on();
+                head.write(180);
+                Serial.write("ok.\n");
                 break;
             case '-': // head off
-                head.off();
+                head.write(0);
+                Serial.write("ok.\n");
                 break;
             case '\r':
             case '\n':


slack ir bot for lgWhisen

slack ir bot for lgWhisen

--- _66-slack-bot/_66-slack-bot.ino
+++ _66-slack-bot/_66-slack-bot.ino
@@ -8,15 +8,21 @@
 */

 /*
- modified by chaeplin @ gmail.com
- */
+  modified by chaeplin @ gmail.com
+*/

 #include <Arduino.h>
 #include <ESP8266WiFi.h>
 #include <WiFiClientSecure.h>
 #include <ESP8266HTTPClient.h>
+// https://github.com/Links2004/arduinoWebSockets
 #include <WebSocketsClient.h>
+// https://github.com/bblanchon/ArduinoJson
 #include <ArduinoJson.h>
+// https://github.com/chaeplin/lgwhisen
+#include <lgWhisen.h>
+// https://github.com/markszabo/IRremoteESP8266
+#include <IRremoteESP8266.h>

 #include "/usr/local/src/ap_setting.h"
 #include "/usr/local/src/slack_setting.h"
@@ -24,6 +30,10 @@
 const char* api_fingerprint = "AB F0 5B A9 1A E0 AE 5F CE 32 2E 7C 66 67 49 EC DD 6D 6A 38";

 //#define SLACK_BOT_TOKEN "put-your-slack-token-here"
+//#define SLACK_CHANNEL "xxxxxx"
+//#define SLACK_USER "xxxxxxx"
+//#define SLACK_TEAM "xxxxxx"
+
 //#define WIFI_SSID       "wifi-name"
 //#define WIFI_PASSWORD   "wifi-password"

@@ -32,12 +42,49 @@

 long nextCmdId = 1;
 bool connected = false;
+
+unsigned long nextTimercheck;
+
+// AC
+#define IR_RX_PIN 14
+#define IR_TX_PIN 2
+#define AC_TYPE 1
+#define AC_HEATING 0
+#define AC_ON_MIN 5
+#define AC_OFF_MIN 3
+
+volatile struct
+{
+  uint8_t ac_mode;
+  uint8_t ac_temp;
+  uint8_t ac_flow;
+  bool haveData;
+  bool timermode;
+  bool timerfirst;
+  unsigned long intervalon;  // ms
+  unsigned long intervaloff; // ms
+  unsigned long timerMillis;
+} ir_data;
+
+IRrecv irrecv(IR_RX_PIN);
+lgWhisen lgWhisen(AC_TYPE, AC_HEATING);
+
+void chane_ac_temp_flow()
+{
+  if (ir_data.ac_mode == 1)
+  {
+    lgWhisen.setTemp(ir_data.ac_temp);
+    lgWhisen.setFlow(ir_data.ac_flow);
+    lgWhisen.activate();
+  }
+}

 /**
   Sends a ping message to Slack. Call this function immediately after establishing
   the WebSocket connection, and then every 5 seconds to keep the connection alive.
 */
-void sendPing() {
+void sendPing()
+{
   DynamicJsonBuffer jsonBuffer;
   JsonObject& root = jsonBuffer.createObject();
   root["type"] = "ping";
@@ -47,15 +94,187 @@
   webSocket.sendTXT(json);
 }

-void processSlackMessage(char *payload) {
-// [WebSocket] Message: {"type":"message","channel":"xxxxx","user":"xxxx","text":"test123","ts":"1466878878.000005","team":"xxxx"}
+void sendHello()
+{
+  DynamicJsonBuffer jsonBuffer;
+  JsonObject& root = jsonBuffer.createObject();
+  root["type"] = "message";
+  root["id"] = nextCmdId++;
+  root["channel"] = SLACK_CHANNEL;
+  //root["text"] = "Hello world";
+  root["text"] = "테스트 시작";
+  String json;
+  root.printTo(json);
+  webSocket.sendTXT(json);
+}
+
+void sendCheck()
+{
+  DynamicJsonBuffer jsonBuffer;
+  JsonObject& root = jsonBuffer.createObject();
+  root["type"] = "message";
+  root["id"] = nextCmdId++;
+  root["channel"] = SLACK_CHANNEL;
+
+  String msg = "ac status: ";
+  if (ir_data.timermode)
+  {
+    int timeremain = ((nextTimercheck - (millis() - ir_data.timerMillis)) / 1000 ) / 60;
+    if (ir_data.ac_mode == 0)
+    {
+      msg += "timer:off, next change in ";
+      msg += timeremain;
+      msg += " min\n";
+    }
+    else
+    {
+      msg += "timer:on, next change in ";
+      msg += timeremain;
+      msg += " min\n";
+    }
+  }
+  else
+  {
+    if (ir_data.ac_mode == 0)
+    {
+      msg += "off\n";
+    }
+    else
+    {
+      msg += "on\n";
+    }
+  }
+  msg += "ac temp set : ";
+  msg += ir_data.ac_temp;
+  msg += "\n";
+  msg += "ac flow set : ";
+  msg += ir_data.ac_flow;
+  msg += " \r\n\r\n";
+
+  root["text"] = msg.c_str();
+  String json;
+  root.printTo(json);
+  webSocket.sendTXT(json);
+}
+
+void sendHelp()
+{
+  DynamicJsonBuffer jsonBuffer;
+  JsonObject& root = jsonBuffer.createObject();
+  root["type"] = "message";
+  root["id"] = nextCmdId++;
+  root["channel"] = SLACK_CHANNEL;
+
+  String msg =  "on -> ac on\n";
+  msg += "off -> ac off\n";
+  msg += "ton -> timer start with ac on\n";
+  msg += "[18 ~ 30] -> temperature set\n";
+  if (AC_TYPE == 0)
+  {
+    msg += "[0 ~ 2] -> flow set(low/mid/high)\n";
+  }
+  else
+  {
+    msg += "[0 ~ 3] -> flow set(low/mid/high/change)\n";
+  }
+  msg += "check -> report ac status\r\n";
+
+  root["text"] = msg.c_str();
+  String json;
+  root.printTo(json);
+  webSocket.sendTXT(json);
+}
+
+void ICACHE_RAM_ATTR processSlackMessage(String receivedpayload)
+{
+  char json[] = "{\"type\":\"message\",\"user\":\"XX0990XX\",\"text\":\"XX0990XX\",\"team\":\"XX0990XX\",\"user_team\":\"XX0990XX\",\"user_profile\":{\"avatar_hash\":\"g9c0531af70a\",\"image_72\":\"https://secure.gravatar.com/avatar/9c0531af70ad0dbed618e9f4c2198145.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0019-72.png\",\"first_name\":null,\"real_name\":\"\",\"name\":\"XX0990XX\"},\"channel\":\"XX0990XX\",\"ts\":\"1466954463.000275\"}";
+  receivedpayload.toCharArray(json, 1024);
+  StaticJsonBuffer<1024> jsonBuffer;
+  JsonObject& root = jsonBuffer.parseObject(json);
+
+  if (!root.success()) {
+    Serial.println("root failed");
+    return;
+  }
+
+  if (root.containsKey("text"))
+  {
+    const char* text = root["text"].asString();
+    Serial.printf("[Processing] text: %s\n", text);
+    if (String(text) == "help")
+    {
+      sendHelp();
+    }
+    else if (String(text) == "check")
+    {
+      Serial.println("->check");
+      sendCheck();
+    }
+    else if (String(text) == "on")
+    {
+      Serial.println("->on");
+      ir_data.ac_mode   = 1;
+      ir_data.timermode = false;
+      ir_data.haveData  = true;
+    }
+    else if (String(text) == "off")
+    {
+      Serial.println("->off");
+      ir_data.ac_mode   = 0;
+      ir_data.timermode = false;
+      ir_data.haveData  = true;
+    }
+    else if (String(text) == "ton")
+    {
+      Serial.println("->ton");
+      ir_data.ac_mode     = 0;
+      ir_data.timermode   = true;
+      ir_data.timerfirst  = false;
+    }
+    else if (String(text) == "0")
+    {
+      Serial.println("->flow 0");
+      ir_data.ac_flow = 0;
+      chane_ac_temp_flow();
+      sendCheck();
+    }
+    else
+    {
+      uint8_t num = atoi(text);
+      if (num >= 18 && num <= 30)
+      {
+        Serial.print("->temp : ");
+        Serial.println(num);
+        ir_data.ac_temp = num;
+        chane_ac_temp_flow();
+        sendCheck();
+      }
+      else if (num >= 1 && num <= 3)
+      {
+        if (AC_TYPE == 0 && num == 3)
+        {
+          return;
+        }
+        else
+        {
+          Serial.print("->flow : ");
+          Serial.println(num);
+          ir_data.ac_flow = num;
+          chane_ac_temp_flow();
+          sendCheck();
+        }
+      }
+    }
+
+  }
 }

 /**
   Called on each web socket event. Handles disconnection, and also
   incoming messages from slack.
 */
-void webSocketEvent(WStype_t type, uint8_t *payload, size_t len) {
+void ICACHE_RAM_ATTR webSocketEvent(WStype_t type, uint8_t *payload, size_t len)
+{
   switch (type) {
     case WStype_DISCONNECTED:
       Serial.printf("[WebSocket] Disconnected :-( \n");
@@ -65,11 +284,29 @@
     case WStype_CONNECTED:
       Serial.printf("[WebSocket] Connected to: %s\n", payload);
       sendPing();
+      webSocket.loop();
+      sendHello();
       break;

     case WStype_TEXT:
       Serial.printf("[WebSocket] Message: %s\n", payload);
-      processSlackMessage((char*)payload);
+
+      String receivedpayload;
+      for (int i = 0; i < len; i++)
+      {
+        receivedpayload += (char)payload[i];
+      }
+      if (receivedpayload.startsWith("{\"type\":\"message"))
+      {
+        if (receivedpayload.indexOf(SLACK_CHANNEL) != -1 &&
+            receivedpayload.indexOf(SLACK_USER) != -1 &&
+            receivedpayload.indexOf(SLACK_TEAM) != -1 )
+        {
+          if (len < 1024) {
+            processSlackMessage(receivedpayload);
+          }
+        }
+      }
       break;
   }
 }
@@ -80,7 +317,8 @@
   2. Conencts the WebSocket
   Returns true if the connection was established successfully.
 */
-bool connectToSlack() {
+bool connectToSlack()
+{
   // Step 1: Find WebSocket address via RTM API (https://api.slack.com/methods/rtm.start)
   HTTPClient http;
   String uri_to_post = "/api/rtm.start?token=";
@@ -88,7 +326,8 @@

   http.begin("slack.com", 443, uri_to_post, api_fingerprint);
   int httpCode = http.GET();
-  if (httpCode != HTTP_CODE_OK) {
+  if (httpCode != HTTP_CODE_OK)
+  {
     Serial.printf("HTTP GET failed with code %d\n", httpCode);
     return false;
   }
@@ -108,15 +347,38 @@

 void setup() {
   Serial.begin(115200);
+  Serial.println();
+  Serial.println("Starting....... ");
   //Serial.setDebugOutput(true);
+
+  // ac
+  ir_data.ac_mode     = 0;
+  ir_data.ac_temp     = 27;
+  ir_data.ac_flow     = 1;
+  ir_data.haveData    = false;
+  ir_data.timermode   = false;
+  ir_data.timerfirst  = false;
+  ir_data.intervalon  = (AC_ON_MIN * 60 * 1000); // ms
+  ir_data.intervaloff = (AC_OFF_MIN * 60 * 1000); // min
+  ir_data.timerMillis = millis();;
+  nextTimercheck = ir_data.intervalon;
+
+  lgWhisen.setTemp(ir_data.ac_temp);    // 18 ~ 30
+  lgWhisen.setFlow(ir_data.ac_flow);    // 0 : low, 1 : mid, 2 : high, if setActype == 1, 3 : change
+  lgWhisen.setIrpin(IR_TX_PIN);         // ir tx pin
+
+  irrecv.enableIRIn();

   WiFi.mode(WIFI_STA);
   WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
-  while (WiFi.status() != WL_CONNECTED) {
+  while (WiFi.status() != WL_CONNECTED)
+  {
+    Serial.print(". ");
     delay(100);
   }
-
-  configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
+  Serial.println();
+
+  configTime(9 * 3600, 0, "pool.ntp.org", "time.nist.gov");
 }

 unsigned long lastPing = 0;
@@ -124,20 +386,100 @@
 /**
   Sends a ping every 5 seconds, and handles reconnections
 */
-void loop() {
+void loop()
+{
+  // ac ir rx
+  decode_results results;
+
+  if (irrecv.decode(&results))
+  {
+    if (lgWhisen.decode(&results))
+    {
+      if (lgWhisen.get_ir_mode() != 0)
+      {
+        ir_data.ac_mode = 1;
+      }
+      else
+      {
+        ir_data.ac_mode = 0;
+      }
+      ir_data.ac_temp = lgWhisen.get_ir_temperature();
+      ir_data.ac_flow = lgWhisen.get_ir_flow();
+    }
+    irrecv.enableIRIn();
+  }
+
+  // slack
   webSocket.loop();

   if (connected) {
     // Send ping every 5 seconds, to keep the connection alive
-    if (millis() - lastPing > 5000) {
+    if (millis() - lastPing > 5000)
+    {
       sendPing();
       lastPing = millis();
     }
-  } else {
+  }
+  else
+  {
     // Try to connect / reconnect to slack
     connected = connectToSlack();
-    if (!connected) {
+    if (!connected)
+    {
       delay(500);
     }
   }
-}
+
+  // ac change, ir tx
+  if (ir_data.haveData)
+  {
+    lgWhisen.setTemp(ir_data.ac_temp);
+    lgWhisen.setFlow(ir_data.ac_flow);
+
+    switch (ir_data.ac_mode)
+    {
+      // ac power down
+      case 0:
+        Serial.println("IR -----> AC Power Down");
+        lgWhisen.power_down();
+        delay(5);
+        break;
+
+      // ac on
+      case 1:
+        Serial.println("IR -----> AC Power On");
+        lgWhisen.activate();
+        delay(5);
+        break;
+
+      default:
+        break;
+    }
+    sendCheck();
+    ir_data.haveData = false;
+  }
+
+  // ac timer
+  if (ir_data.timermode)
+  {
+    if (((millis() - ir_data.timerMillis) > nextTimercheck) || !ir_data.timerfirst)
+    {
+      if (ir_data.ac_mode == 0)
+      {
+        ir_data.ac_mode = 1;
+        nextTimercheck = ir_data.intervalon;
+      }
+      else
+      {
+        ir_data.ac_mode = 0;
+        nextTimercheck = ir_data.intervaloff;
+      }
+      ir_data.haveData = true;
+      ir_data.timerfirst  = true;
+      ir_data.timerMillis = millis();
+    }
+  }
+
+}
+
+// end


Update BinaryEpochClock.ino

Update BinaryEpochClock.ino

fixed time constructs.

--- Firmware/BinaryEpochClock/BinaryEpochClock.ino
+++ Firmware/BinaryEpochClock/BinaryEpochClock.ino
@@ -608,7 +608,7 @@
       timeRef = millis();
       dt_now = RTC->now();

-      int year = dt_now.year - 2000;
+      int year = dt_now.year() - 2000;

 	int valcheck = 32;
 	for (int y=31; y>=26; y--)
@@ -623,7 +623,7 @@
 	valcheck = valcheck / 2;
 	}

-	int month = dt_now.month;
+	int month = dt_now.month();

 	valcheck = 8;
 	for (int m=25; m>=22; m--)
@@ -638,7 +638,7 @@
 	valcheck = valcheck / 2;
 	}

-	int day = dt_now.day;
+	int day = dt_now.day();

 	valcheck = 16;
 	for (int d=21; d>=17; d--)
@@ -654,7 +654,7 @@
 	}

-	int hour = dt_now.hour;
+	int hour = dt_now.hour();

 	valcheck = 16;
 	for (int h=16; h>=12; h--)
@@ -669,7 +669,7 @@
 	valcheck = valcheck / 2;
 	}

-	int minute = dt_now.minute;
+	int minute = dt_now.minute();

 	valcheck = 32;
 	for (int mm=11; mm>=6; mm--)
@@ -684,7 +684,7 @@
 	valcheck = valcheck / 2;
 	}

-	int second = dt_now.second;
+	int second = dt_now.second();

 	valcheck = 32;
 	for (int s=5; s>=0; s--)


v3.4 Add UTC

v3.4 Add UTC

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -183,6 +183,8 @@
   String windDirection = root["list"]["wind"]["deg"];

   int riseI, setI, monthI, dayI, yearI;
+  String timeUTC = timeS;
+  timeUTC = timeUTC.substring(timeUTC.length() - 8, timeUTC.length()); // Strip out the time (XX:XX:XX)
   timeS = convertGMTTimeToLocal(timeS, latitude, longitude,
                                 &riseI, &setI, &monthI, &dayI, &yearI);
   String dateS = String(monthI) + '/' + String(dayI) + '/' + String(yearI);
@@ -226,6 +228,8 @@
   Serial.print(timeS);
   Serial.println(" UTC");
 #endif
+  Serial.print("UTC ");
+  Serial.println(timeUTC);
 #endif // #ifdef DEBUG

   clearScreen();
@@ -241,7 +245,8 @@
                  riseI,
                  setI,
                  idString.toInt(),
-                 dateS);
+                 dateS,
+                 timeUTC);
   }
   else {
     printMainData(humidity,
@@ -262,7 +267,8 @@
                   int rise,
                   int set,
                   int weatherID,
-                  String dateS)
+                  String dateS,
+                  String timeUTC)
 {
   static long lastRandomNumber;
   long randomColor;
@@ -318,6 +324,8 @@
   tft.setTextColor(textColor[newRandomColor]);
   tft.print("Time: ");
   tft.println(time);
+  tft.print("UTC: ");
+  tft.println(timeUTC);
   tft.print("Date: ");
   tft.println(dateS);
   tft.setTextColor(textColor[randomColor]);


timing fixes

timing fixes

--- Gizmo/Gizmo.ino
+++ Gizmo/Gizmo.ino
@@ -152,8 +152,9 @@
     defaultState = STATE_NONE;

     // start clock
-    startClock(true);
-
+    //startClock(true);
+    initializeClock();
+
     // reset ticks and pulses
     uint32_t m = micros();


Switched SPI pin to 12, removed timer and added button on pin 10 for switching the animations

--- WS2812_Test.ino
+++ WS2812_Test.ino
@@ -1,25 +1,32 @@
 #include "FastSPI_LED2.h"
-#include "colorcircle.h"
-#include "rainbow.h"
 #include "animation.h"
+#include "rainbow.h"        //animation 0
+#include "colorcircle.h"    //animation 1

 // define the number of LEDs
-#define NUM_LEDS 100
+#define NUM_LEDS 240

 CRGB leds[NUM_LEDS];
 //ColorCircle Animation(leds, NUM_LEDS);
 //Rainbow Animation(leds, NUM_LEDS);
 Animation *Anim;
-int counter = 0;
+bool buttonPressed = false;
+int ledPin = 13;
+int buttonPin = 10;
+int currentAnimation = 0;

 void setup() {
-    // sanity check delay - allows reprogramming if accidently blowing power w/leds
+    pinMode(ledPin, OUTPUT);
+    pinMode(buttonPin, INPUT_PULLUP);
+    digitalWrite(ledPin, HIGH);
+
+    //sanity check delay - allows reprogramming if accidently blowing power w/leds
     delay(1000);

-    // setting brightness to 12%
-    LEDS.setBrightness(20);
+    //setting maximum brightness
+    LEDS.setBrightness(45);

-    LEDS.addLeds<WS2811, 13, GRB>(leds, NUM_LEDS); //GRB for the WS2812 color order
+    LEDS.addLeds<WS2811, 12, GRB>(leds, NUM_LEDS); //GRB for the WS2812 color order

     //Rainbow *Ani = new Rainbow(leds, NUM_LEDS);
     Anim = new Rainbow(leds, NUM_LEDS);
@@ -27,22 +34,41 @@
     //reset all the LEDs
     memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
     LEDS.show();
+    digitalWrite(ledPin, LOW);
 }

 void loop()
 {
-    counter++;
-    if(counter == 600)
+    int buttonState = digitalRead(buttonPin);
+    if(buttonState == LOW)
     {
-        delete Anim;
-        Anim = new ColorCircle(leds, NUM_LEDS);
+        buttonPressed = true;
+        digitalWrite(ledPin, HIGH);
     }
-    if(counter >= 1200)
+    else if(buttonState == HIGH)
     {
-        delete Anim;
-        Anim = new Rainbow(leds, NUM_LEDS);
-        counter = 0;
+        if(buttonPressed)   //switch animation only if the button was pressed before
+        {
+            buttonPressed = false;
+            delete Anim;
+            currentAnimation++;
+            if(currentAnimation > 1)    //reset
+            {
+                currentAnimation = 0;
+            }
+            switch(currentAnimation)
+            {
+            case 0:
+                Anim = new Rainbow(leds, NUM_LEDS);
+                break;
+            case 1:
+                Anim = new ColorCircle(leds, NUM_LEDS);
+                break;
+            }
+        }
+        digitalWrite(ledPin, LOW);
     }
+
     Anim->doNextStep();
     LEDS.show();
     delay(100);


Add Real Time Clock

Add Real Time Clock

--- software/XTendPayloadTeensy/XTendPayloadTeensy.ino
+++ software/XTendPayloadTeensy/XTendPayloadTeensy.ino
@@ -2,7 +2,7 @@
  * Serial1: GPS and LOGGER
  * Serial2: RF IN/OUT
  */
-#define GPSLEN 100 //max length of GPS output to be sent
+#include <TimeLib.h>
 char pkt_buffer[200];
 boolean sentencePending, sentenceRdy;
 boolean txFlag, help;
@@ -20,6 +20,7 @@
 void setup(){
   Serial1.begin(9600);
   Serial2.begin(9600);
+  setSyncProvider( getTeensy3Time );
   sentencePending = false;
   sentenceRdy = false;
   sentenceBuf[0] = 0;
@@ -125,3 +126,30 @@
   Serial2.print( whatToSend ); // RF module
   Serial1.print( whatToSend ); // Logger
 }
+
+time_t getTeensy3Time() {
+  return Teensy3Clock.get();
+}
+
+void digitalClockDisplay(time_t t) {
+  // digital clock display of the time
+  int hr = hour(t);
+  if ( hr < 10 ) Serial.print( '0' );
+  Serial.print(hr);
+  printDigits(minute(t));
+  printDigits(second(t));
+  Serial.print(" ");
+  Serial.print(day(t));
+  Serial.print(" ");
+  Serial.print(month(t));
+  Serial.print(" ");
+  Serial.print(year(t));
+}
+
+void printDigits(int digits){
+  // utility function for digital clock display: prints preceding colon and leading 0
+  Serial.print(":");
+  if(digits < 10)
+    Serial.print('0');
+  Serial.print(digits);
+}


Bug fix

Bug fix

--- RightpointLabs.Pourcast.Arduino/RightpointLabs.Pourcast.Arduino.ino
+++ RightpointLabs.Pourcast.Arduino/RightpointLabs.Pourcast.Arduino.ino
@@ -281,7 +281,7 @@
   Serial.println("Starting");
   WiFly.begin();
   Serial.println("Joining");
-  if (!WiFly.join("Rightpoint-Guest", "RP@29NWacker")) {
+  if (!WiFly.join("Rightpoint-Guest", "PW")) {
      // Handle the failure
      Serial.println("Failed to connect");
   }


Infrared detection update

Infrared detection update

--- Tests/Infrared_rangeZone_detection/Infrared_rangeZone_detection.ino
+++ Tests/Infrared_rangeZone_detection/Infrared_rangeZone_detection.ino
@@ -1,21 +1,5 @@
-/*
- * Distance range is from 0 to 5.  Only a small range of several centimeters
- * in front of each detector is measureable.  Most of it will be 0 (too
- * close) or 5 (too far).
- */
-
-int irLEDPinLeft = 9;
-int irRecPinLeft = 10;
-int irLEDPinRight = 2;
-int irRecPinRight = 3;
-
-int statusLedPinLeft = 7;
-int statusLedPinRight = 6;
-
-int irMaxFreq = 58000;
-int irOptFreq = 38000;
-int irFreqStep = 5000;
-int nbrIRDistZones = (irMaxFreq-irOptFreq)/irFreqStep+1;
+#include "declarations.h"
+#include "irDistance.h"

 void setup()                                 // Built-in initialization block
 {


[LedDude] Cleanup.

[LedDude] Cleanup.

Signed-off-by: Juri Berlanda <5bfdca9e82c53adb0603ce7083f4ba4f2da5cacf@hotmail.com>

--- laundry-dude-led-sensor/laundry-dude-led-sensor.ino
+++ laundry-dude-led-sensor/laundry-dude-led-sensor.ino
@@ -33,13 +33,16 @@
 uint16_t fifoCount;     // count of all bytes currently in FIFO
 uint8_t fifoBuffer[64];

+// Lock related stuff
 char rfidTag[TAG_LENGTH + 1];
 char lockTag[TAG_LENGTH + 1];
 bool locked = false;
+
+// RFID read stuff
 unsigned long lastRead = 0;
-
 char buffer[TAG_LENGTH];
 int count = 0;
+#define RFID_READ_NO_CARD 1000

 // Software serial for XBee module
 SoftwareSerial xbeeSerial(2, 3); // RX, TX
@@ -113,10 +116,8 @@

 bool checkRfidChecksum(const char* buffer) {
   uint16_t checkSum = 0;
-  char checkSum_L = 0;
-  char checkSum_H = 0;
+  uint16_t tmp = 0;
   String hexstr = "";
-  uint16_t tmp = 0;

   // Calculate
   for (int i = 0; i < (TAG_LENGTH - 2) / 2; i++) {
@@ -132,7 +133,7 @@
   hexstr = "0x";
   hexstr += buffer[TAG_LENGTH - 2];
   hexstr += buffer[TAG_LENGTH - 1];
-  tmp = strtoul(hexstr.c_str(), 0, 16);//hexstr.toInt();
+  tmp = strtoul(hexstr.c_str(), 0, 16);
   return checkSum == tmp;
 }

@@ -152,7 +153,7 @@
     return;

   // FIXME: Runs over after 50 days!
-  if (millis() - lastRead < 2000) {
+  if (millis() - lastRead < RFID_READ_NO_CARD) {
     lastRead = millis();
     return;
   }
@@ -255,7 +256,6 @@
     Serial.print(devStatus);
     Serial.println(F(")"));
   }
-
 }

 bool checkFifoOnMpu() {


Update RF24MeshNode3.ino

Update RF24MeshNode3.ino

--- examples/NanoRFMeshNet/RF24MeshNode3/RF24MeshNode3.ino
+++ examples/NanoRFMeshNet/RF24MeshNode3/RF24MeshNode3.ino
@@ -27,7 +27,7 @@

  **/
 #define nodeID 3
-#define otherNodeID 2
+#define otherNodeID 1

 uint32_t millisTimer = 0;


comments added

comments added

--- examples/bluetooth_transiever/bluetooth_transiever.ino
+++ examples/bluetooth_transiever/bluetooth_transiever.ino
@@ -1,4 +1,6 @@
-/* LucidTronix Wearable Wayfinder Color Clock
+/* LucidTronix Wearable Wayfinder
+ * Blue Tooth Transeiver
+ * written by samwell freeman for LucidTronix
  * For instructions, details and schematic, See:
  * http://www.lucidtronix.com/tutorials/64
  */
@@ -19,7 +21,7 @@
 WearableWayfinder ww = WearableWayfinder(&tft);

 int old_pot = 0;
-const int buffer_size = 128;
+const int buffer_size = 18;
 char buffer_in[buffer_size];
 int char_index = 0;

@@ -27,7 +29,7 @@
   Serial1.begin(115200);    	//initialize Serial1
   Serial.begin(115200);    	//initialize Serial1

-  for(int i = 0; i < buffer_size; i++) buffer_in[i] = '\0';
+  for(int i = 0; i < buffer_size; i++) buffer_in[i] = 0;

   ww.initialize();
   ww.draw_string(5, 6, "BLUE", Color(30, 35, 255).color_16(), 3);
@@ -44,6 +46,7 @@
     char cur_char;
     while((cur_char = Serial1.read()) != -1){
       buffer_in[char_index] = cur_char;
+      char_index = ++char_index % buffer_size;
     }
     Serial1.print("received string:");
     Serial1.println(buffer_in);


Write newline before HELLO to avoid garbage

--- arduino/KnockGame/KnockGame.ino
+++ arduino/KnockGame/KnockGame.ino
@@ -279,6 +279,7 @@
   global_debug = debug;
   global_userid = -1;
   global_state = STATE_IDLE;
+  Serial.println();
   Serial.print("HELLO ");
   Serial.print(HANDSHAKE_STR);
   Serial.print(" ");