plays WAV file when its code is entered

plays WAV file when its code is entered

--- turing-old-rotary.ino
+++ turing-old-rotary.ino
@@ -12,6 +12,7 @@

 enum State {
   nodial,
+  dialing,
   dialed,
   done
 };
@@ -28,17 +29,35 @@
 dir_t dirBuf;     // buffer for directory reads

 const int hangPin = 6; //pin for reciever switch. closed (HIGH) when hung up, open (LOW) when off the hook
-
+const int dialPin = 7; //pin for dialing switch. close (HIGH) when  dialing, open (LOW) when not dialing
+const int countPin = 8; //pin for counting switch.  closed (HIGH) for don't count, open (LOW) for each count
 const int ledPin = 13; //LED pin
+
+int dialCount = 0;
+#define DIAL_ARRAY_LEN 10
+int dialArray[DIAL_ARRAY_LEN];
+int dialIndex = 0;
+
+int p1[] = {1, 2, 3, 4};
+const int p1_len = 4;
+int p2[] = {0, 9, 8, 7};
+const int p2_len = 4;

 int ledState = HIGH;
 int hangState; //current reciever reading
+int dialState; //current dial reading
+int countState;
 int lastHangState = LOW; //previous reciever reading
+int lastDialState = LOW; //previous dial reading
+int lastCountState = LOW;

 long lastHangDebounceTime = 0;  // the last time the reciever pin was toggled
+long lastDialDebounceTime = 0; // last time the dial switch was toggled
+long lastCountDebounceTime = 0;
 const long debounceDelay = 50;    // the debounce time; increase if the output flickers
-
-State dialState = nodial;
+const long countDebounceDelay = 10;
+
+State phoneState = nodial;

 void playfile(char *name) {
   if (wave.isplaying) {
@@ -105,6 +124,8 @@

   pinMode(hangPin, INPUT);
+  pinMode(dialPin, INPUT);
+  pinMode(countPin, INPUT);
   pinMode(ledPin, OUTPUT);

   digitalWrite(ledPin, ledState);
@@ -112,6 +133,8 @@

 void loop() {
   int hangReading = digitalRead(hangPin);
+  int dialReading = digitalRead(dialPin);
+  int countReading = digitalRead(countPin);

   //debounce the reciever switch
   if (hangReading != lastHangState) {
@@ -121,29 +144,18 @@
   if ((millis() - lastHangDebounceTime) > debounceDelay) { //then the bounce settled
     if (hangReading != hangState) {//then reciever state has changed
       hangState = hangReading;
-      ledState = hangState;

       if(hangState == LOW) {//if first time off hook, start dial tone
-        dialState = nodial;
+        phoneState = nodial;
+        putstring_nl("hang low");
       }
-    }
-  }
-
-  //debounce the reciever switch
-  if (hangReading != lastHangState) {
-    lastHangDebounceTime = millis();
-  }
-
-  if ((millis() - lastHangDebounceTime) > debounceDelay) { //then the bounce settled
-    if (hangReading != hangState) {//then reciever state has changed
-      hangState = hangReading;
-      ledState = hangState;
-
-      if(hangState == LOW) {//if first time off hook, start dial tone
-        dialState = nodial;
-      }
-    }
-  }
+      else {
+        putstring_nl("hang high");
+      }
+    }
+  }
+
+

   digitalWrite(ledPin, ledState);

@@ -153,9 +165,110 @@
     //stop any playback
     wave.stop();
     //reset any state
+    dialCount = 0;
+    dialIndex = 0;
+
+    int i = 0;
+    for(i = 0; i < DIAL_ARRAY_LEN; i++) {
+      dialArray[i] = -1;
+    }
   }
   else {//off the hook
-    switch(dialState) {
+    //debounce the dial switch
+    if (dialReading != lastDialState) {
+      lastDialDebounceTime = millis();
+    }
+
+    if ((millis() - lastDialDebounceTime) > debounceDelay) { //then the bounce settled
+      if (dialReading != dialState) {//then reciever state has changed
+        dialState = dialReading;
+        ledState = dialState;
+
+        if(dialState == LOW) {
+          putstring("dial low");
+          if(dialReading == HIGH) {
+            putstring("\tdial reading high");
+          }
+          else {
+            putstring("\tdial reading high\n");
+          }
+        }
+
+        //if just started dialing, reset count
+        if(dialState == HIGH) {
+          dialCount = 0;
+          putstring_nl("dial high");
+
+
+        }
+        //if just ended dialing, save count, set to dialing state if recied a count > 0 (10 is the real zero)
+        //if dialindex bigger than dial array size, then act like wrong number
+        //if dialed number matches anything then play
+        else if(dialCount > 0) {
+          int i;
+          phoneState = dialing;
+          dialArray[dialIndex] = dialCount;
+          if(dialArray[dialIndex] >= 10) {
+            dialArray[dialIndex] = 0;
+          }
+          dialIndex++;
+
+          i = 0;
+          int match = 1;
+          for(i = 0; i < p1_len; i++) {
+            if(p1[i] != dialArray[i]) {
+              match = 0;
+              break;
+            }
+          }
+
+          if(match) {
+            playfile("P1.WAV");
+          }
+
+          i = 0;
+          match = 1;
+          for(i = 0; i < p2_len; i++) {
+            if(p2[i] != dialArray[i]) {
+              match = 0;
+              break;
+            }
+          }
+
+          if(match) {
+            playfile("P2.WAV");
+          }
+
+        }
+      }
+    }
+
+    if(dialState == HIGH) {
+      //debounce the count switch
+      if (countReading != lastCountState) {
+        lastCountDebounceTime = millis();
+      }
+
+      if ((millis() - lastCountDebounceTime) > countDebounceDelay) { //then the bounce settled
+        if (countReading != countState) {//then reciever state has changed
+          countState = countReading;
+
+
+          //if just started dialing, reset count
+          if(countState == LOW) {
+            dialCount++;
+            putstring_nl("count low");
+
+          }
+          else {
+            putstring_nl("count high");
+          }
+
+        }
+      }
+    }
+
+    switch(phoneState) {
       case nodial:
         if(!wave.isplaying) {//if stopped playing, start again
           playfile("DIALTONE.WAV");
@@ -165,5 +278,7 @@
   }

   lastHangState = hangReading;
+  lastDialState = dialReading;
+  lastCountState = countReading;
 }


RFduino/Simblee - native LimiTTer config bug fixes

changes/fixes for LBridge acting as a normal LimiTTer device (no backfilling). Please uncomment USE_XBRIDGE2.
Adjusted Voltage levels for RFduino/Simblee mode.

--- LBridge_RFduino_V09/LBridge_RFduino_V09.ino
+++ LBridge_RFduino_V09/LBridge_RFduino_V09.ino
@@ -72,13 +72,13 @@

 /* ********************* program configuration options **********************/

-//#define RFD                     // uncomment for RFduino platform, otherwise Simblee platform will be used
+#define RFD                     // uncomment for RFduino platform, otherwise Simblee platform will be used
 #define USE_DEAD_SENSOR         // uncomment to work with live sensors
 #define USE_SPIKE_FILTER        // uncomment to use a spike filter on raw data
 #define USE_XBRIDGE2            // uncomment to use two way xbridge2 protocol with backfilling instead of LimiTTER
                                 // ASCII protocol (ine way)
 #define USE_SHADOWFRAM          // uncomment to work with a shadow FRAM copy of the Libre sensor FRAM
-#define SHORTSTARTCYCLE         // uncomment to have 10 inital 1 min cycles to have faster sensor start (@FPV_UAV)
+//#define SHORTSTARTCYCLE         // uncomment to have 10 inital 1 min cycles to have faster sensor start (@FPV_UAV)

 /*
  * debug and other less important options
@@ -87,36 +87,35 @@
 //#define DEBUG                 // uncomment to have verbose debug output
 //#define FRAM_DEBUG                 // uncomment to have verbose debug output for FRAM mechanism
 //#define SIM_MINUTES_UPCOUNT     // for testing backfilling with dead sensor
-#define SHOW_BLESTATECHANGE     // uncomment to have serial BLE connect/disconnect messages
+//#define SHOW_BLESTATECHANGE     // uncomment to have serial BLE connect/disconnect messages

 /* ******************** BLE and central seetings ***************************** */
 #define DXQUEUESIZE (8*12)     // 12 h of queue (remember and send the last x hours when reconnected via BLE)

-#define LB_NAME   "xbridge2"    // dont change "xbridge", space for 1 char left to indicate different versions
+#define LB_NAME   "xbridge1"    // dont change "xbridge", space for 1 char left to indicate different versions
 #define LB_ADVERT "rfduino"     // dont change "rfduino"
                                 // length of device name and advertisement <=15!!!
 #define LB_VERSION "V0.9"       // program version
-#define LB_MINOR_VERSION ".10"  // indicates minor version
-#define LB_DATETIME "180225_1252" // date_time
+#define LB_MINOR_VERSION ".11"  // indicates minor version
+#define LB_DATETIME "180226_2046" // date_time
 #define SPIKE_HEIGHT 40         // minimum delta to be a spike

 #ifdef RFD
 #define MAX_VOLTAGE 3600        // adjust voltage measurement to have a wider rrange
 #define MIN_VOLTAGE 2300        // minimum voltage where BLE will work properly (@bertrooode)
-#else
+#else RFD
 #define MAX_VOLTAGE 3000        // adjust voltage measurement to have a wider rrange
 #define MIN_VOLTAGE 2200        // minimum voltage where BLE will work properly (@FPV-UAV)
-//#define MIN_VOLTAGE 2550        // minimum voltage where BLE will work properly (@FPV-UAV)
-#endif /* RFD */
+#endif RFD

 /* ****************************** includes ********************************** */

 #ifdef RFD
 #include <RFduinoBLE.h>
-#else
+#else RFD
 #include <SimbleeBLE.h>
 #include <ota_bootloader.h>
-#endif
+#endif RFD

 #include <SPI.h>
 #include <Stream.h>
@@ -457,9 +456,10 @@
   // init xbridge queue
   Pkts.read = 0;
   Pkts.write = 0;
+#ifdef USE_XBRIDGE2
   // set timestamps in queue for inital backfilling
   initialFillupBackfillTimestamps();
-
+#endif
   print_statef("NFCReady = %d, BatOK = %d", NFCReady, BatteryOK);
 //  print_state("setup - end - ");
 }
@@ -498,7 +498,9 @@
   if ( BatteryOK ) {
     readAllData();
     if (NFCReady == 2) {
+#ifdef USE_XBRIDGE2
       fillupMissingReadings(0);
+#endif
       dataTransferBLE();
     }
     else {
@@ -549,6 +551,7 @@

 }

+#ifdef USE_XBRIDGE2
 /*
  * search BG queue for missing entries (0), if within the last 8 h fill the values from the Libre sensor FRAM
  */
@@ -562,8 +565,9 @@
   // ??
   minutesSinceProgramStart = (mymillis() / (60000));
   mytime = minutesSinceProgramStart;
+#ifdef DEBUG
   print_statef("fillupMissingReadings() - current time: %d (%d/%d), sensorData.minutesHistoryOffset: %d", mytime, mytime/15, mytime%15, sensorData.minutesHistoryOffset);
-
+#endif DEBUG
   // check complete queue for missing BG readings (0 entries)
   for ( int i = 0 ; i < DXQUEUESIZE ; i++ ) {
     // get time of queue entry
@@ -611,6 +615,7 @@
   if ( nulls > 0 )
     print_statef("backfill %d readings ...", nulls);
 }
+#endif USE_XBRIDGE2

 /* ********************************** dump stuff ************************ */

@@ -699,6 +704,7 @@

 #define FILL8H (8*12)     // fillup 8 h - the length of the 8 hour Libre sensor FRAM history over all

+#ifdef USE_XBRIDGE2
 void initialFillupBackfillTimestamps(void)
 {
   unsigned long sim_time_ms;
@@ -716,6 +722,7 @@
   // set to end of initial queue
   minutesSinceProgramStart = (mymillis() / (60000));
 }
+#endif USE_XBRIDGE2

 /* ************************* NFC/SPI handling **************************** */

@@ -1017,12 +1024,12 @@
     if ((systemInformationData.responseFlags & 0x01) == 0)
     {
       systemInformationData.infoFlags = resultBuffer[3];
-      print_state("UID: ");
+//      print_state("UID: ");
       for (int i = 0; i < 8; i++)
       {
         systemInformationData.uid[i] = resultBuffer[11 - i];
-        Serial.print(systemInformationData.uid[i], HEX);
-        Serial.print(" ");
+//        Serial.print(systemInformationData.uid[i], HEX);
+//        Serial.print(" ");
       }
       systemInformationData.errorCode = resultBuffer[resultBuffer[1] + 2 - 1];
     }
@@ -1049,7 +1056,7 @@
 //  Serial.printf(", Response flags: %x", systemInformationData.responseFlags);
 //  print_state("");
 //  Serial.print(" - Sensor SN:");
-  myprintf(", Sensor SN: %s", systemInformationData.sensorSN.cstr());
+  print_statef("Sensor SN: %s", systemInformationData.sensorSN.cstr());
 //  Serial.printf(", Error code: %x - done", systemInformationData.errorCode);
 }

@@ -1570,7 +1577,10 @@
   analogReference(VBG);
   analogSelection(VDD_1_3_PS);
 #ifdef RFD
+  uint16_t sensorValue1 = readVDD();
+  print_statef("readVDD() = %d", sensorValue1);
   int sensorValue = analogRead(1);
+  print_statef("analogRead(1) = %d", sensorValue);
   SoCData.voltage = sensorValue * (360 / 1023.0) * 10;
   SoCData.temperatureC = RFduino_temperature(CELSIUS);
   SoCData.temperatureF = RFduino_temperature(FAHRENHEIT);
@@ -1832,7 +1842,7 @@
 void decodeSensorBody()
 {
   int j;
-  print_state("decodeSensorBody() - ");
+//  print_state("decodeSensorBody() - ");
   byte pomiar[6];

   // calculate block indices for trend/history
@@ -1861,8 +1871,7 @@
   sensorData.minutesSinceStart += (loop_cnt-1)*runPeriod;
 #endif
   minutesSinceProgramStart = sensorData.minutesSinceStart - startMinutesSinceStart;
-  print_state("runtime minutes since program start: ");
-  Serial.printf("%d (%d - %d)", minutesSinceProgramStart, sensorData.minutesSinceStart, startMinutesSinceStart);
+  print_statef("runtime %d min (%d - %d)", minutesSinceProgramStart, sensorData.minutesSinceStart, startMinutesSinceStart);
   // calculate minute distance to most recent history entry
   sensorData.minutesHistoryOffset = (sensorData.minutesSinceStart - 3) % 15 + 3 ;
 /*
@@ -1909,7 +1918,7 @@
     for (int k = index; k < index + 6; k++) pomiar[k - index] = sensorDataBody[k];
     sensorData.history[i] = ((pomiar[1] << 8) & 0x0F00) + pomiar[0];
   }
-  Serial.print(" - done");
+//  Serial.print(" - done");
 }

 void decodeSensorFooter()
@@ -2036,6 +2045,7 @@
   RFduinoBLE.customUUID = "0000ffe0-0000-1000-8000-00805f9b34fb";
 #else /* USE_XBRIDGE2 */
   Serial.print(" - LimiTTer device");
+  RFduinoBLE.deviceName = "LimiTTer";
   RFduinoBLE.advertisementData = "data";
   RFduinoBLE.customUUID = "c97433f0-be8f-4dc8-b6f0-5343e6100eb4";
 #endif /* USE_XBRIDGE2 */
@@ -2050,6 +2060,7 @@
   SimbleeBLE.customUUID = "0000ffe0-0000-1000-8000-00805f9b34fb";
 #else /* USE_XBRIDGE2 */
   Serial.print(" - setting LimiTTer device");
+  SimbleeBLE.deviceName = "LimiTTer";
   SimbleeBLE.advertisementData = "data";
   SimbleeBLE.customUUID = "c97433f0-be8f-4dc8-b6f0-5343e6100eb4";
 #endif /* USE_XBRIDGE2 */
@@ -2102,10 +2113,8 @@
   TxBuffer1 += " ";
   TxBuffer1 += String((int)(sensorData.minutesSinceStart / 10));
   int  LL = TxBuffer1.length();
-  Serial.print("sendToXdripViaBLE >>");
-  Serial.print(TxBuffer1);
-  Serial.print("<< ");
-  Serial.println(LL);
+  print_statef("sendToXdripViaBLE: %s", TxBuffer1.cstr());
+//  Serial.println(LL);
 #ifdef RFD
   RFduinoBLE.send(TxBuffer1.cstr(), TxBuffer1.length());
 #else
@@ -2310,6 +2319,12 @@
              + sizeof(msg.delay) + sizeof(msg.function);
   msg.cmd_code = 0x00;
   msg.raw = pPkt->raw;
+#ifdef USE_DEAD_SENSOR
+  // xDrip+ filters out identical values too short after each other, simulate small jitter
+  // value range is 100000++
+  if ( runPeriod < 5 )
+    pPkt->raw += loop_cnt % 2;
+#endif USE_DEAD_SENSOR
   msg.filtered = pPkt->raw;
   msg.dex_battery = 214;  // simulate good dexcom transmitter battery
   msg.my_battery = SoCData.voltagePercent;


Telnet detection disable hack for Q-Link

--- MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
+++ MicroView/WiFiModem-Menu/WiFiModem-Menu.ino
@@ -46,7 +46,7 @@

 ;  // Keep this here to pacify the Arduino pre-processor

-#define VERSION "0.12b3"
+#define VERSION "0.13b1"

 unsigned int BAUD_RATE=2400;
 unsigned int WiFly_BAUD_RATE=2400;
@@ -1062,13 +1062,13 @@

 void Connect(String host, int port, boolean raw)
 {
-    if (host == F("5551212")) {
-        host = F("qlink.lyonlabs.org");
-        port = 5190;
-    }
-    else if (host == F("5551213")) {
+    bool isQLink = false;
+
+    if ( (host == F("5551212")) || (host == F("5551213")) || (host == F("QLINK")) )    // Note case!
+    {
         host = F("q-link.net");
         port = 5190;
+        isQLink = true;   // Workaround Telnet detection
     }
 #ifdef HAYES
     else if (host == F("CS38")) {
@@ -1160,6 +1160,11 @@

 #ifdef HAYES
     Modem_Connected(false);
+
+    if (isQLink)
+    {
+        isFirstChar = false;  // force off
+    }
 #else
     /*if (!raw)
     {
@@ -2490,7 +2495,8 @@
                             int data = wifly.read();

                             // If first character back from remote side is NVT_IAC, we have a telnet connection.
-                            if (isFirstChar) {
+                            if (isFirstChar)
+                            {
                                 if (data == NVT_IAC)
                                 {
                                     isTelnet = true;
@@ -2504,10 +2510,10 @@
                             }
                             else
                             {
-                                if (data == NVT_IAC && isTelnet)
-                                {
-                                    if (baudMismatch)
-                                    {
+                                  if (data == NVT_IAC && isTelnet)
+                                  {
+                                      if (baudMismatch)
+                                      {
                                         digitalWriteFast(WIFI_CTS, LOW);        // re-enable data
                                         if (CheckTelnetInline())
                                             buffer[buffer_index++] = NVT_IAC;
@@ -2518,7 +2524,7 @@
                                         if (CheckTelnetInline())
                                             C64Serial.write(NVT_IAC);
                                     }
-
+
                                 }
                                 else
                                 {
@@ -2532,9 +2538,10 @@
                                         DoFlowControlModemToC64();
                                         C64Serial.write(data);
                                     }
-                                }
+                               }
                             }
                         }
+
                         if (baudMismatch)
                         {
                             // Dump the buffer to the C64 before clearing WIFI_CTS


Reset when connection lost

Reset when connection lost

--- arduino/sketch_plug/sketch_plug.ino
+++ arduino/sketch_plug/sketch_plug.ino
@@ -35,6 +35,18 @@
 MQTTClient *g_mqtt_client;

 uint8_t g_plug_status = 0;
+
+void (*reset)(void) = 0;
+
+uint8_t g_retry_cnt = 0;
+
+void retry_or_reset(uint8_t try_cnt) {
+  if (g_retry_cnt >= try_cnt) {
+    reset();
+  } else {
+    ++g_retry_cnt;
+  }
+}

 bool get_ip_port() {
   char *p = strstr(g_url, "tcp://");
@@ -62,9 +74,12 @@
 void simple_send_recv(uint8_t *buf, uint16_t *len, const char *host, uint16_t port) {
   EthernetClient net_client;

-  while (0 == net_client.connect(host, port)) {
-    Serial.println("cs"); // connect server
-    delay(1000);
+  Serial.println("cs"); // connect server
+  g_retry_cnt = 0;
+  while (!net_client.connect(host, port)) {
+    Serial.println("..");
+    delay(100);
+    retry_or_reset(3);
   }
   delay(100);

@@ -74,9 +89,11 @@
   net_client.flush();

   Serial.println("ca"); // check available
+  g_retry_cnt = 0;
   while (!net_client.available()) {
-    Serial.println(".."); // wait data
-    delay(1000);
+    Serial.println("..");
+    delay(100);
+    retry_or_reset(3);
   }

   Serial.println("rd"); // read data
@@ -166,6 +183,7 @@
     }

     if (!st) {
+      reset();
 //      digitalWrite(PIN_NET_STATUS, LOW);
       delete g_mqtt_client;
       delete g_net_client;
@@ -242,12 +260,14 @@
 }

 void init_ethernet() {
-  uint8_t mac[] = {0xb0, 0x5a, 0xda, 0x3a, 0x2e, 0x8f};
+  uint8_t mac[] = {0xb0, 0x5a, 0xda, 0x3a, 0x2e, 0x9f};

   Serial.println("ie.."); // init ethernet
+  g_retry_cnt = 0;
   while (!Ethernet.begin(mac)) {
     Serial.println("..");
-    delay(1000);
+    delay(100);
+    retry_or_reset(0);
   }

   Serial.print("i:");
@@ -275,9 +295,11 @@
 void connect_yunba() {
   Serial.println("cn.."); // connecting

+  g_retry_cnt = 0;
   while (!g_mqtt_client->connect(g_client_id, g_username, g_password)) {
     Serial.println("..");
-    delay(1000);
+    delay(100);
+    retry_or_reset(5);
   }

   g_last_check_ms = millis();


Read TPH sensor and send to serial port

Read TPH sensor and send to serial port

--- Sensors/GpsDataToSerial/GpsDataToSerial.ino
+++ Sensors/GpsDataToSerial/GpsDataToSerial.ino
@@ -1,5 +1,25 @@
+/*--- GROVE GPS ---*/
 #include <SoftwareSerial.h>
+/*-----------------*/
+
+/*--- TPH V2 ---*/
+#include <Wire.h>
+#include <SPI.h>
+#include <Adafruit_Sensor.h>
+#include <Adafruit_BME280.h>
+/*--------------*/
+
+/*--- GROVE BUTTON ---*/
 #define BUTTON_PIN 20
+/*--------------------*/
+
+/*--- TPH V2 ---*/
+#define BME_SCK 13
+#define BME_MISO 12
+#define BME_MOSI 11
+#define BME_CS 10
+#define SEALEVELPRESSURE_HPA (1013.25)
+/*--------------*/

 SoftwareSerial SoftSerial(2, 3);
 char buffer[256];
@@ -7,10 +27,20 @@
 boolean routeStarted = false;

 unsigned long interval = 1000; // the time we need to wait
-unsigned long previousMillis = 0; // millis() returns an unsigned long.
+unsigned long previousMillisTPHv2 = 0;
+unsigned long previousMillisGPS = 0;
+
+boolean previousButtonState = false;
+
+Adafruit_BME280 bme;
+
+float currentTemperature;
+float currentPressure;
+float currentHumidity;

 void setup()
 {
+  bme.begin();
   SoftSerial.begin(9600);
   Serial.begin(9600);
   pinMode(BUTTON_PIN, INPUT);
@@ -23,14 +53,19 @@
   unsigned long currentMillis = millis(); // grab current time

   // check if "interval" time has passed (1000 milliseconds)
-  if ((unsigned long)(currentMillis - previousMillis) >= interval) {
+  if ((unsigned long)(currentMillis - previousMillisTPHv2) >= 200) {
+    checkTPHv2();
+    // save the "current" time
+    previousMillisTPHv2 = millis();
+  }
+
+  // check if "interval" time has passed (1000 milliseconds)
+  if ((unsigned long)(currentMillis - previousMillisGPS) >= interval) {
     checkGPS();
     // save the "current" time
-    previousMillis = millis();
+    previousMillisGPS = millis();
   }
 }
-
-boolean previousButtonState = false;

 void checkButton()
 {
@@ -44,6 +79,13 @@
   }

   previousButtonState = currentButtonState;
+}
+
+void checkTPHv2()
+{
+  currentTemperature = bme.readTemperature();
+  currentPressure = bme.readPressure() / 100.0F;
+  currentHumidity = bme.readHumidity();
 }

 void checkGPS()
@@ -96,7 +138,7 @@
           if(sAlt == "")
             sAlt = "0";

-          String geo = "{\"latitude\":\"" + sLat + "\",\"latd\":\"" + sLatd + "\",\"longitude\":\"" + sLong + "\",\"longd\":\"" + sLongd + "\",\"altitude\":\"" + sAlt + "\"}";
+          String geo = "{\"latitude\":" + sLat + ",\"latd\":" + sLatd + ",\"longitude\":" + sLong + ",\"longd\":" + sLongd + ",\"altitude\":" + sAlt + ",\"T\":" + currentTemperature + ",\"P\":" + currentPressure + ",\"H\":" + currentHumidity + "}";

           Serial.println("#");
           delay(50);


Use double buffering (thanks for Elovalo project)

--- telepulssi_driver.ino
+++ telepulssi_driver.ino
@@ -6,13 +6,24 @@
 #include <SPI.h>
 #include <TimerOne.h>

-static uint8_t koira14[] = {
+static uint8_t buf_a[] = {
 	0x01, 0x00, 0x08, 0x04, 0x10, 0x00, 0x0A, 0x04, 0x01, 0x00, 0x08, 0x04,
 	0x10, 0x00, 0x08, 0x04, 0x07, 0x07, 0x0B, 0x05, 0x17, 0x03, 0x0A, 0x05,
 	0x09, 0x14, 0x18, 0x04, 0x14, 0x04, 0x1A, 0x04, 0x09, 0x17, 0x18, 0x04,
 	0x17, 0x04, 0x1A, 0x04, 0x09, 0x07, 0x0B, 0x0D, 0x17, 0x13, 0x0A, 0x1D,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00
 };
+
+static uint8_t buf_b[sizeof(buf_a)];
+
+uint8_t *buf_front = buf_a;
+uint8_t *buf_back = buf_b;
+
+void buf_swap(void) {
+	uint8_t *tmp = buf_front;
+	buf_front = buf_back;
+	buf_back = tmp;
+}

 void setup() {
 	// Set output pins for LED display
@@ -41,9 +52,10 @@
 			return;
 		}

-		koira14[buf_i++] = data;
-		if (buf_i == sizeof(koira14)) {
+		buf_back[buf_i++] = data;
+		if (buf_i == sizeof(buf_a)) {
 			buf_i = 0;
+			buf_swap();
 			Serial.write('K');
 		}
         }
@@ -83,5 +95,5 @@
 	digitalWrite(5, LOW);

 	// Send new data to SPI. Don't wait it to complete
-	SPDR = koira14[8*row_i+col_i];
+	SPDR = buf_front[8*row_i+col_i];
 }


Removed obsolete mazeNav function

Removed obsolete mazeNav function

--- 2018-Firefighter/2018-Firefighter.ino
+++ 2018-Firefighter/2018-Firefighter.ino
@@ -174,21 +174,6 @@
   }
 }

-void mazeNav() { //MOVE MY MINION
-  if(frontLeftUltrasonic.getDistance() < 2 && leftUltrasonic.getDistance() < 2){ //robot has wall in front and to left
-    moveRight();
-    delay(500);
-  }
-  else if(frontLeftUltrasonic.getDistance() < 2 && leftUltrasonic.getDistance() >= 2){ //robot has wall in front
-    moveLeft();
-    delay(500);
-  }
-  else{ //if(frontLeftUltrasonic.getDistance() >=2 && leftUltrasonic.getDistance() <2), or if (frontLeftUltrasonic.getDistance() >= 2 && leftUltrasonic.getDistance() >= 2): hug the left wall
-    moveForward();
-    delay(500);
-  }
-}
-
 float calcAvg(float x,float y){
   float avg=(x+y)/2;
   return avg;
@@ -266,7 +251,6 @@

   if (robotOn) {
-    mazeNav();

     extinguishFire();


mazeNav v2

mazeNav v2

New and improved mazeNav method, using front and left facing Ultrasonic sensors

--- 2018-Firefighter/2018-Firefighter.ino
+++ 2018-Firefighter/2018-Firefighter.ino
@@ -79,11 +79,25 @@
     }
     delay(100);
   }
-  int detectSound(){return 0;}
+  int detectSound(){return 0;} //these three lines are giving compiler errors
   int detectBaby(){return 0;}
   int usingCamera(){return 0;)
 }

+void mazeNav() { //MOVE MY MINION
+  if(frontUltrasonic < 2 && leftUltrasonic < 2){ //robot has wall in front and to left
+    moveRight();
+    delay(500);
+  }
+  else if(frontUltrasonic < 2 && leftUltrasonic >= 2){ //robot has wall in front
+    moveLeft();
+    delay(500);
+  }
+  else{ //if(frontUltrasonic >=2 && leftUltrasonic <2), or if (frontUltrasonic >= 2 && leftUltrasonic >= 2): hug the left wall
+    moveForward();
+    delay(500);
+  }
+}

 void setup() {
   // put your setup code here, to run once:
@@ -99,7 +113,7 @@
   pinMode(MIC_PIN, INPUT);
   pinMode(MIC_LED, OUTPUT);

-  pinMode(BABY_LED, OUTPT);
+  pinMode(BABY_LED, OUTPUT);

   pinMode(CAMERA_LED, OUTPUT);
 }
@@ -107,8 +121,8 @@
 void loop() {
 // put your main code here, to run repeatedly:

+  mazeNav();
   extinguishFire();
-
   delay(100);

   if (detectfire()){


refactor client code plus misc cosmetic fixes

--- EnerginoEthernet/EnerginoEthernet.ino
+++ EnerginoEthernet/EnerginoEthernet.ino
@@ -33,6 +33,7 @@
  *   switch [read|write]
  *  Examples:
  *   GET http://<ipaddress>/read/datastreams
+ *   GET http://<ipaddress>/read/switch
  *   GET http://<ipaddress>/write/switch/0
  *   GET http://<ipaddress>/write/switch/1
  *
@@ -53,7 +54,7 @@

 #define RELAY_PIN 2

-#define STRING_BUFFER_SIZE 400
+#define STRING_BUFFER_SIZE 300
 #define SAMPLES 100

 #ifdef DEBUG
@@ -122,7 +123,6 @@
 settings;

 // working vars
-EthernetClient client;
 EthernetServer server(SERVER_PORT);

 long lastConnectionTime = 0;
@@ -183,11 +183,9 @@
 void loop() {
   // If we're not connected, and a full period has passed since
   // our connection, then connect again and send data.
-  if(!client.connected() && (millis() - lastConnectionTime > settings.period)) {
+  if(millis() - lastConnectionTime > settings.period) {
     sendData();
-  } else {
-    client.stop();
-  }
+  }
   // Parse incoming commands
   serParseCommand();
   // Listen for incoming requests
@@ -198,7 +196,8 @@
 {
   char cmd = '\0';
   int i, serAva;
-  char inputBytes[60] = { '\0' };
+  char inputBytes[60] = {
+    '\0'   };
   char * inputBytesPtr = &inputBytes[0];
   if (Serial.available() > 0) {
     delay(5);
@@ -215,7 +214,7 @@
       }
       else if (i == 1) {
         cmd = chr;
-      }
+      }
       else{
         inputBytes[i-2] = chr;
       }
@@ -233,27 +232,32 @@
     if (value > 0) {
       settings.period = value;
     }
-  } else if (cmd == 'A') {
+  }
+  else if (cmd == 'A') {
     int value = atoi(inputBytesPtr);
     if (value >= 0) {
       settings.r1 = value;
     }
-  } else if (cmd == 'B') {
+  }
+  else if (cmd == 'B') {
     int value = atoi(inputBytesPtr);
     if (value >= 0) {
       settings.r2 = value;
     }
-  } else if (cmd == 'C') {
+  }
+  else if (cmd == 'C') {
     int value = atoi(inputBytesPtr);
     if (value >= 0) {
       settings.offset = value;
     }
-  } else if (cmd == 'D') {
+  }
+  else if (cmd == 'D') {
     int value = atoi(inputBytesPtr);
     if (value >= 0) {
       settings.sensitivity = value;
     }
-  } else if (cmd == 'K') {
+  }
+  else if (cmd == 'K') {
     strncpy(settings.apikey, inputBytes,49);
     settings.apikey[48] = '\0';
   }
@@ -261,8 +265,8 @@
     byte host[4];
     char *p = strtok(inputBytes, ".");
     for (int i = 0; i < 4; i++) {
-        host[i] = atoi(p);
-        p = strtok(NULL, ".");
+      host[i] = atoi(p);
+      p = strtok(NULL, ".");
     }
     IPAddress hostIP = IPAddress(host);
     DBG Serial.print("New host ip address: ");
@@ -368,9 +372,15 @@
 void sendData() {
   // poll energino
   char *json = getDatastreams();
-  // if there's a successful connection:
+  // check if the feed has been initialized
+  if (settings.feed == 0) {
+    lastConnectionTime = millis();
+    return;
+  }
+  // try to connect
   DBG Serial.println("Connecting.");
-  if ((settings.feed != 0) && client.connect(settings.host, settings.port)) {
+  EthernetClient client;
+  if (client.connect(settings.host, settings.port)) {
     DBG Serial.println("connected.");
     DBG Serial.print("PUT /v2/feeds/");
     DBG Serial.println(settings.feed);
@@ -378,7 +388,6 @@
     client.print("PUT /v2/feeds/");
     client.print(settings.feed);
     client.print(" HTTP/1.1\n");
-    client.println("Host: api.cosm.com");
     client.print("X-PachubeApiKey: ");
     client.println(settings.apikey);
     client.print("User-Agent: ");
@@ -403,7 +412,6 @@
   else {
     // if you couldn't make a connection:
     DBG Serial.println("Unable to connect.");
-    client.stop();
   }
   lastConnectionTime = millis();
 }


Delete C_DISCOR-Industruino.ino

Delete C_DISCOR-Industruino.ino

--- BMS_Francais/Examples/C_DISCOR-Industruino/C_DISCOR-Industruino.ino
+++ BMS_Francais/Examples/C_DISCOR-Industruino/C_DISCOR-Industruino.ino
@@ -1,209 +0,0 @@
-/*-------------------------------------------------------------------------------------------------------------------------------------------*
- * SE2R : C_DISCOR - Fonction de détection temporisée de discordance entre deux valeurs ToR ou analogiques                        29/06/2015 *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- *        C_DISCOR(float IN1, float IN2, float DIF, float CPT[], boolean RES[], int CFG)                                          29/06/2015 *
- *                IN1 : Première valeur à comparer                                                                                *
- *                IN2 : Deuxième valeur à comparer                                                                                *
- *                DIF : Différence maximum tolérée entre IN1 et IN2                                                                          *
- *                TPO : [0] Compteur de temporisation                                                                                *
- *                      [1] Tempo de confirmation de la discordance                                                                          *
- *                      [2] Temps de cycle automate calculé par la fonction                                                                  *
- *                      [3] Mémorisation de la variable système Millis pour le calcul du temps de cycle                                      *
- *                RES : [0] Discordance de l'équipement - forcément un tableau de taille au moins 1                                          *
- *                CFG : Commande de forçage.                                                                                *
- *                      <0 : RES maintenu à false donc en discordance                                                                        *
- *                      0  : RES figée dans son dernier état connu                                                                           *
- *                      1  : RES est true sauf si IN1 et IN2 diffèrent de plus de DIF pendant plus de CPT[1] sans discontinuer               *
- *                      2  : RES maintenu à true en permanence                                                                               *
- *                      3  : RES maintenu à true en permanence                                                                               *
- *                      >3 : RES maintenu à false                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- * Copyright SE2R under the APACHE Licence                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- * Plate-formes testées : Industruino 32U8 et 1286                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- * 29/06/2015 : DD, SE2R : Testée et validée sur banc                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*/
-
-// Déclaration des bibliothèques nécessaires à l'exécution du programme ---------------------------------------------------------------------*
-#include <DIS.h>                        // Biblio   - SE2R - Fonctions de dialogue et d'affichage sur l'écran UC1701 Industruino
-static DIS DIS;                         // Biblio   - Activation du constructeur de la bibliothèque de fonctions d'affichage
-static UC1701 lcd;
-#include <BMS.h>                        // Biblio   - SE2R - Fonctions de contrôle et régulation
-static BMS BMS;                         // Biblio   - Activation du constructeur de la bibliothèque de fonctions d'affichage
-
-// Déclaration des variables nécessaires à l'exécution de la fonction -----------------------------------------------------------------------*
-boolean FCO_REAR[1];                    // C_DISCOR - [00] Commande de réarmement depuis l'extérieur
-boolean EDx_TEL_XXXX[9];                // Système  - [00] Inutilisée
-                                        //            [01] Etat de la lecture de la voie digitale 1 si elle est une entrée
-                                        //            [02] Etat de la lecture de la voie digitale 2 si elle est une entrée
-                                        //            [03] Etat de la lecture de la voie digitale 3 si elle est une entrée
-                                        //            [04] Etat de la lecture de la voie digitale 4 si elle est une entrée
-                                        //            [05] Etat de la lecture de la voie digitale 5 si elle est une entrée
-                                        //            [06] Etat de la lecture de la voie digitale 6 si elle est une entrée
-                                        //            [07] Etat de la lecture de la voie digitale 7 si elle est une entrée
-                                        //            [08] Etat de la lecture de la voie digitale 8 si elle est une entrée
-boolean SDx_TSL_XXXX[9];                // Système  - [00] Mémoire temporaire utilisée pour les calculs
-                                        //            [01] Etat de la commande de la voie digitale 1 si elle est une sortie
-                                        //            [02] Etat de la commande de la voie digitale 1 si elle est une sortie
-                                        //            [04] Etat de la commande de la voie digitale 1 si elle est une sortie
-                                        //            [05] Etat de la commande de la voie digitale 1 si elle est une sortie
-                                        //            [07] Etat de la commande de la voie digitale 1 si elle est une sortie
-                                        //            [08] Etat de la commande de la voie digitale 1 si elle est une sortie
-boolean FDM_XXXX[1];                    // C_DISCOR - [00] Etat de la commande à transmettre à la sortie
-float VTT_XXXX[5];                      // C_DISCOR - [00] Compteur des temporisations
-                                        //            [01] Tempo de confirmation de la discordance
-                                        //            [02] Temps de cycle automate calculé par la fonction
-                                        //            [03] Mémorisation de la variable système Millis pour le calcul du temps de cycle
-int VCO_XXXX[1];                        // C_DISCOR - [00] Commande de forçage par l'extérieur
-
-// Déclaration des variables nécessaires au fonctionnement de l'écran -----------------------------------------------------------------------*
-String TCM_PRES[21] = {                 // EcranLCD - Table de chaînes de caractères de présentation
-  "                     ",  // 00
-  "-  Menu  Principal  -",
-  "Retour Accueil      ",
-  "Rearmer             ",
-  "Chrono              ",
-  "Entree 1            ",
-  "Entree 2            ",
-  "Discorde            ",
-  "- Selection + Enter -",
-  "-    Rearmement     -",
-  "- Tempo discordance -",  // 10
-  " ",
-  " ",
-  " ",
-  " ",
-  " ",
-  " ",
-  " ",
-  " ",
-  " ",
-  " "};                      // 20
-
-
-String TCM_UNIT[21] = {                 // EcranLCD - Table de chaînes de caractères d'unités standard
-  "        ",  // 00
-  "oC      ",
-  "%       ",
-  "s       ",
-  "V       ",
-  "mV      ",  // 05
-  "",
-  "",
-  "",
-  "",
-  "",          // 10
-  "   Arret ",
-  "  Marche ",
-  "Discorde ",
-  "  Normal ",
-  "  Active ", // 15
-  " Rearmer ",
-  " ",
-  " ",
-  " ",
-  "  " };      // 20
-
-boolean FCO_PRUP[5];                    // EcranLCD - Information de touche "Up" appuyée
-boolean FCO_PREN[5];                    // EcranLCD - Information de touche "Enter" appuyée
-boolean FCO_PRDN[5];                    // EcranLCD - Information de touche "Down" appuyée
-int VNT_MENU[2];                        // EcranLCD - Table d'adressage des menus
-int VNC_MENU[10];                       // EcranLCD - Table des numéros de menus
-int VNC_PRUP[11];                       // EcranLCD - Table des numéros de menus de destination par la touche "Up"
-int VNC_PREN[10];                       // EcranLCD - Table des numéros de menus de destination par la touche "Enter"
-int VNC_PRDN[10];                       // EcranLCD - Table des numéros de menus de destination par la touche "Down"
-float VTT_SCRN[10];                     // EcranLCD - Table des temporisations
-int VNX_MN02[12];                       // EcranLCD - Table des menus de destimation et des index du menu 02 - Principal
-boolean FCM_REAR[1];                    // G_MODV1B - Mémoire de la demande de réarmement
-float VTM_TPAM[11];                     // G_MODV1F - Mémoire de calcul de la commande de la fonction pour VTT_XXXX[1] - Tempo à la marche
-float VTM_TPMA[11];                     // G_MODV1F - Mémoire de calcul de la commande de la fonction pour VTT_XXXX[2] - Tempo à l'arrêt
-
-void setup() {                          // Initialisation -----------------------------------------------------------------------------------*
-Indio.digitalMode(1,INPUT);             // Système  - Affectation de la voie Dx1 en tant qu'entrée digitale
-Indio.digitalMode(2,INPUT);             // Système  - Affectation de la voie Dx2 en tant qu'entrée digitale
-VCO_XXXX[0] = 1;                        // C_CDELEM - Passage du forçage en position auto
-
-VTT_SCRN[1] = 180;                      // G_TOUCHx - Temporisation d'inactivité sur le rétroéclairage
-VTT_SCRN[2] = 240;                      // G_TOUCHx - Temporisation d'inactivité de retour à l'écran principal
-VTT_SCRN[3] = 20;                       // G_TOUCHx - Temporisation d'antirebond de la touche "Enter"
-VTT_SCRN[4] = 15;                       // G_TOUCHx - Temporisation d'antiredond des touches "Up" et "Down"
-VNT_MENU[0] = 4;                        // G_NAVIGM - Taille des tables d'index et de destinations
-VNT_MENU[1] = 1;                        // G_NAVIGM - Initialisation du pointeur de destinations
-
-//                                      // G_NAVIGM - Tables d'adressage de l'écran LCD
-VNC_MENU[0] = 1;
-VNC_MENU[1] = 1;
-VNC_MENU[2] = 2;
-VNC_MENU[3] = 3;
-VNC_MENU[4] = 4;
-VNC_PRUP[1] =   1; VNC_PREN[1] =   2; VNC_PRDN[1] =   2;
-VNC_PRUP[2] =   2; VNC_PREN[2] =   2; VNC_PRDN[2] =   2;
-VNC_PRUP[3] =   3; VNC_PREN[3] =   2; VNC_PRDN[3] =   3;
-VNC_PRUP[4] =   4; VNC_PREN[4] =   2; VNC_PRDN[4] =   4;
-VNC_PRUP[5] =   2;
-
-VNX_MN02[0] = 0;						// G_CHOIX8 - Table des menus de destination et des index du menu 11 - Initialisation index
-VNX_MN02[1] = 1;
-VNX_MN02[2] = 3;
-VNX_MN02[3] = 4;
-VNX_MN02[4] = 0;
-VNX_MN02[5] = 0;
-VNX_MN02[6] = 0;
-VNX_MN02[7] = 0;
-VNX_MN02[8] = 1;
-VNX_MN02[9] = 3;
-VNX_MN02[10] = 1;
-
-VTM_XXXX[1] = 0; VTM_XXXX[2] = 600; VTM_XXXX[3] = 1;  VTM_XXXX[4] = VTT_XXXX[1];  VTM_XXXX[8] = 100;
-
-//                                      // EcranLCD - Paramétrage spécifique Industruino 1286
-pinMode(23, INPUT);                     // EcranLCD - Spécifique 1286 - Touche flèche basse
-pinMode(24, INPUT);                     // EcranLCD - Spécifique 1286 - Touche entrée
-pinMode(25, INPUT);                     // EcranLCD - Spécifique 1286 - Touche flèche haute
-pinMode(26, OUTPUT);                    // EcranLCD - Spécifique 1286 - Sortie de commande du rétroéclairage
-
-/*                                      // EcranLCD - Paramétrage spécifique Industruino 32U8
-pinMode(13, OUTPUT);                    // EcranLCD - Spécifique 32U8 - Sortie de commande du rétroéclairage
-*/
-lcd.begin();                            // EcranLCD - Initialisation de l'écran LCD
-lcd.clear();                            // EcranLCD - Effacement de l'écran LCD
-}
-
-void loop() {                            // Exécution ---------------------------------------------------------------------------------------*
-if (Indio.digitalRead(1) == HIGH) { EDx_TEL_XXXX[1] = false; } else { EDx_TEL_XXXX[1] = true; }
-if (Indio.digitalRead(2) == HIGH) { EDx_TEL_XXXX[2] = false; } else { EDx_TEL_XXXX[2] = true; }
-if (FCO_REAR[0]) { FDM_XXXX[0] = true; }
-BMS.C_DISCOR(EDx_TEL_XXXX[1], EDx_TEL_XXXX[2], 0.5, VTT_XXXX, FDM_XXXX, 1 - (2 * (FDM_XXXX[0] == false)));
-
-//                                      // EcranLCD - Gestion des touches spécifique Industruino 1286
-DIS.G_TOUCH2(VNC_MENU, VTT_SCRN, FCO_PRUP, FCO_PREN, FCO_PRDN);
-/*                                      // EcranLCD - Gestion des touches spécifique Industruino 32U8
-DIS.G_TOUCH1(VNC_MENU, VTT_SCRN, FCO_PRUP, FCO_PREN, FCO_PRDN);
-*/
-
-if (VNC_MENU[0] ==  1) { lcd.setCursor(0, 0); lcd.clearLine(); }
-DIS.G_MESS1L(VNC_MENU, 1, 1, 0, "   www.eControls.eu  ");
-DIS.G_MESS1L(VNC_MENU, 1, 2, 0, "    SE2R Softwares   ");
-DIS.G_MESS1L(VNC_MENU, 1, 3, 0, "  Industruino  1286  ");
-// DIS.G_MESS1L(VNC_MENU, 1, 3, 0, "  Industruino  32U8  ");
-if (VNC_MENU[0] ==  1) { lcd.setCursor(0, 4); lcd.clearLine(); }
-DIS.G_MESS1L(VNC_MENU, 1, 5, 0, "Fonction BMS.C_DISCOR");
-DIS.G_MESS1L(VNC_MENU, 1, 6, 0, "A# TESTS     C# 00001");
-DIS.G_MESS1L(VNC_MENU, 1, 7, 0, "V.1.01     29/06/2015");
-
-DIS.G_CHOIX8(VNC_MENU, 2, FCO_PRUP, FCO_PREN, FCO_PRDN, VNX_MN02);
-DIS.G_MESS1L(VNC_MENU, 2, 0, 0, TCM_PRES[1]);
-DIS.G_MESS1L(VNC_MENU, 2, 1, 6, TCM_PRES[2]);
-DIS.G_VISV1B(VNC_MENU, 2, 2, 6, FCO_REAR[0], TCM_PRES[3], TCM_UNIT[15], TCM_UNIT[16]);
-DIS.G_VISV1F(VNC_MENU, 2, 3, 6, VTT_XXXX[0], TCM_PRES[4], TCM_UNIT[3]);
-DIS.G_VISV1B(VNC_MENU, 2, 4, 0, EDx_TEL_XXXX[1], TCM_PRES[6], TCM_UNIT[11], TCM_UNIT[12]);
-DIS.G_VISV1B(VNC_MENU, 2, 5, 0, EDx_TEL_XXXX[2], TCM_PRES[6], TCM_UNIT[11], TCM_UNIT[12]);
-DIS.G_VISV1B(VNC_MENU, 2, 6, 0, FDM_XXXX[0], TCM_PRES[7], TCM_UNIT[13], TCM_UNIT[14]);
-DIS.G_MESS1L(VNC_MENU, 2, 7, 0, TCM_PRES[8]);
-
-DIS.G_MODV1B(VNC_MENU, 3, FCO_PRUP, FCO_PREN, FCO_PRDN, FCO_REAR, 0, FCM_REAR, TCM_PRES[9] , "Rearme discorde a On", TCM_UNIT[13], TCM_UNIT[14], true);
-DIS.G_MODV1F(VNC_MENU, 5, FCO_PRUP, FCO_PREN, FCO_PRDN, VTT_XXXX, 1, VTM_TPAM, TCM_PRES[10], "Avant  passage a Off", TCM_UNIT[3], true, 0);
-
-DIS.G_NAVIGM(VNC_MENU, VNT_MENU, FCO_PRUP, FCO_PREN, FCO_PRDN , VNC_PRUP, VNC_PREN, VNC_PRDN);
-}


New setFirmware

New setFirmware

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -134,7 +134,7 @@
   button1.multiclickTime = 250;  // Time limit for multi clicks
   button1.longClickTime  = 1000; // time until "held-down clicks" register

-  // FIXME Homie.setFirmware(FW_NAME, FW_VERSION);
+  Homie_setFirmware(FW_NAME, FW_VERSION);
   Homie.setLedPin(PIN_LED, HIGH); // Status LED
   // This is a full reset, and will wipe the config
   Homie.setResetTrigger(PIN_BUTTON, LOW, 30000);


in-flight config change doc

in-flight config change doc

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -11,6 +11,11 @@

 /* To use Homie built in OTA updater...
 ./ota_updater.py -l 172.24.32.13 -t devices/ -i 60019485376d /home/kyleg/Projects/homie-sonoff-touch/.pioenvs/esp8285/firmware.bin
+*/
+
+/* To change the config, eg, device name, in flight...
+Use the 'devices/60019485376d/$implementation/config/set topic, such as...
+mosquitto_pub -h homeauto.vpn.glasgownet.com -t 'devices/60019485376d/$implementation/config/set' -m '{"wifi":{"ssid":"Glasgownet"},"mqtt":{"host":"172.24.32.13","port":1883,"base_topic":"devices/","auth":false},"name":"bedroom-wall-switch","ota":{"enabled":true}}'
 */

 // LED_PIN controls the LED under the wifi symbol on the front plate.


Changed adjustment angle to 10 degrees, loop time to 1000ms. Changed printed timestamp so that it zeroes itself on every loop.

--- sonar_error_mapping/sonar_error_mapping.ino
+++ sonar_error_mapping/sonar_error_mapping.ino
@@ -8,7 +8,7 @@
  * @author:    Tyler Lucas
  * Student ID: 3305203
  * Date:       October 6, 2017
- * Version     1.0
+ * Version     1.1
  *
  * References: N/A
  *
@@ -23,9 +23,9 @@

 #define angleMax 110
 #define angleMin 30
-#define angleAdjustmentMagnitude 5
+#define angleAdjustmentMagnitude 10

-#define timeDelayToNextAngle 500
+#define timeDelayToNextAngle 1000

 Servo servo;
 int angle = angleMin;
@@ -43,14 +43,15 @@
   servo.write( angle );

   Serial.println();
-  Serial.println("Printing timestamp, input angle, and sonar measurement (pulse duration).");
+  Serial.println("Printing time, input angle, and sonar measurement (echo pulse delay [us]).");

   delay(1000);
 }

 void loop()
 {
-  unsigned long timestamp = millis();
+  unsigned long timeStart = millis();
+  unsigned long timestamp = timeStart;
   unsigned long timeNextAngle = timestamp + timeDelayToNextAngle;
   long sonarDuration;

@@ -62,7 +63,7 @@
     sonarDuration = getSonarDuration();

     Serial.println();
-    Serial.print( timestamp );
+    Serial.print( timestamp - timeStart );
     Serial.write(',');
     Serial.print( angle );
     Serial.write(',');


Various fixes - tidied config for multiple nodes up.

--- arduino_repeater/arduino_repeater.ino
+++ arduino_repeater/arduino_repeater.ino
@@ -11,16 +11,27 @@
 #include "RFM69.h"
 #include "LowPower.h"

+#define P01
+
 //************* Node ID Setup ****************/
+#ifdef P01
 char id[] = "P01";
-char location_string[] = "50.9375,-1.3982";
+char location_string[] = "50.93753,-1.39797";
+#define BATTV_FUDGE 0.935
+#endif
+#ifdef P02
+char id[] = "P02";
+char location_string[] = "50.93879,-1.3979";
+#define BATTV_FUDGE 0.943
+#endif
+#define BEACON_INTERVAL 30
 uint8_t rfm_power = 20; // dBmW

 //************* Sensors ****************/
 // Battery Voltage Measurement - Also enables zombie mode
 #define ENABLE_BATTV_SENSOR // Comment out to disable, also disables zombie mode
 #define BATTV_PIN 0 //ADC 0 - Battery Voltage, scaled to 1.1V
-#define BATTV_FUDGE 0.935
+#define BATTV_FUDGE 0.943
 // RFM Temperature Sensor - Not very accurate and sometimes glitchy
 #define ENABLE_RFM_TEMPERATURE // Comment out to disable
 #define RX_TEMP_FUDGE 5.0 // Temperature offset when in RX due to self-heating
@@ -41,6 +52,26 @@

 // Singleton instance of the radio
 RFM69 rf69(9.3); // parameter: RFM temperature calibration offset (degrees as float)
+
+#ifdef ENABLE_RFM_TEMPERATURE
+int8_t sampleRfmTemp() {
+    int8_t rfmTemp = rf69.readTemp();
+    while(rfmTemp>100) {
+        rfmTemp = rf69.readTemp();
+    }
+    if(zombie_mode==0) {
+        rfmTemp-=RX_TEMP_FUDGE;
+    }
+    return rfmTemp;
+}
+#endif
+
+#ifdef ENABLE_BATTV_SENSOR
+float sampleBattv() {
+  // External 4:1 Divider
+  return ((float)analogRead(BATTV_PIN)*1.1*4*BATTV_FUDGE)/1023.0;
+}
+#endif

 int gen_Data(){
   if(data_count=='a' or data_count=='z') {
@@ -164,7 +195,7 @@
     int packet_len = gen_Data();
     rf69.send((uint8_t*)data, packet_len, rfm_power);

-    data_interval = random(10, 15) + count;
+    data_interval = random(BEACON_INTERVAL, BEACON_INTERVAL+10) + count;
     #ifdef ENABLE_ZOMBIE_MODE
     if(battV > ZOMBIE_THRESHOLD && zombie_mode==1) {
         rf69.setMode(RFM69_MODE_RX);
@@ -176,23 +207,3 @@
     #endif
   }
 }
-
-#ifdef ENABLE_RFM_TEMPERATURE
-int8_t sampleRfmTemp() {
-    int8_t rfmTemp = rf69.readTemp();
-    while(rfmTemp>100) {
-        rfmTemp = rf69.readTemp();
-    }
-    if(zombie_mode==0) {
-        rfmTemp-=RX_TEMP_FUDGE;
-    }
-    return rfmTemp;
-}
-#endif
-
-#ifdef ENABLE_BATTV_SENSOR
-float sampleBattv() {
-  // External 4:1 Divider
-  return ((float)analogRead(BATTV_PIN)*1.1*4*BATTV_FUDGE)/1023.0;
-}
-#endif


Adds humidity graph

Adds humidity graph

--- njmakerday_20160318/njmakerday_20160318.ino
+++ njmakerday_20160318/njmakerday_20160318.ino
@@ -68,7 +68,7 @@

Temp Graph
\
     \

Humidity Graph
\
-    \
+    \
   \
 ",

@@ -150,6 +150,7 @@
 	server.on ( "/", handleRoot );
 	server.on ( "/uptime.svg", drawUptimeGraph );
   server.on ( "/temp.svg", drawTempGraph );
+  server.on ( "/humidity.svg", drawHumidityGraph );
 	server.on ( "/inline", []() {
 		server.send ( 200, "text/plain", "this works as well" );
 	} );


updates to comments and minor code structure improvements

--- Arduino_codeline/fairytale23/fairytale23.ino
+++ Arduino_codeline/fairytale23/fairytale23.ino
@@ -19,31 +19,35 @@

       taguid:directory:track

-   For example, the audiobook "findet dorie" is in the directory
-
-      findorie
+   For example, the audiobook "Finding Dorie" is stored in the directory
+
+      /findorie

-   it's corresponding TrackDB file
+   on the SD Card. The corresponding TrackDB file is stored at

       /system00/findorie.txt

-   contains a line
+   It contains exactly one line:

       46722634231761290:findorie:1

-   where
+   This line connects the Tag UID with the aformentioned directory plus the number of the track
+   with which to start playback:

       46722634231761290   is the UID of the NFC Tag
       findorie            is the directory from which to play the files
-      1                   is the number of the track with which to start playback
-
+      1                   is the number of the track with which to start playback - here the 1st track
+
+
    The program will take the retrieved information and then start a for-loop beginning with
-   the provided first track until all consecutive numbered tracks are played. After playback of all
-   files is finished, the program will resume it's main loop, delay operation for roughly 15 seconds
-   (to give the user the chance to remove the just used Tag from the reader) and then wait until
-   it detects the next tag.
-
-   While advancing through the files in th diectory, the program will update the TrackDB-File with
+   the provided first track until all consecutive numbered tracks are played - for this it counts the
+   number of files in the given dierctory.
+
+   After playback of all files is finished, the program will resume it's main loop, delay operation
+   for roughly 15 seconds (to give the user the chance to remove the just used Tag from the reader)
+   and then wait until it detects the next tag.
+
+   While advancing through the files in the directory, the program will update the TrackDB-File with
    the number of the currently played track. Doing so allows for interrupted playbacks - tag is
    removed and later put back on when the playback will start with the last track in playback.

@@ -54,6 +58,8 @@
    3. All directory names must be exactly 8 chars long - use any combination of a-z and 0-9 chars for
       the name
    4. if a file is missing in a consecutive order, you may get a glitch in the sound
+   5. As the Adafruit Music Maker Shield library does not support positions within a file we can always
+      only start from the beginning of teh track.

    While the album (or file) is played an operations light is fading up and down in intensity.

@@ -142,9 +148,8 @@
 //
 // turn ON / OFF certain hardware features
 //
-
 // to enable the IR Remote Control option uncomment the following line
-//#define IRREMOTE 1
+#define IRREMOTE 1

 // to enable the 4 control buttons uncomment the following line
 #define BUTTONS 1
@@ -172,16 +177,20 @@
 // this is achieved via a special file on the SD card and works without a tag but uses the pause/resume button instead
 //#define RESUMELAST 1

+
+
 //
 // include SPI and SD libraries
 //
 #include <SPI.h>
 #include <SD.h>
+

 // These are the SPI pins shared among all components
 #define CLK             13    // SPI Clock shared with VS1053, SD card and NFC breakout board
 #define MISO            12    // Input data from VS1053, SD card and NFC breakout board
 #define MOSI            11    // Output data to VS1053, SD card and NFC breakout board
+

 //
 // SETUP MUSIC MAKER SHIELD
@@ -191,6 +200,7 @@
 #define SHIELD_RESET     -1    // VS1053 reset pin (unused!)
 #define SHIELD_CS         7    // VS1053 chip select pin (output)
 #define SHIELD_DCS        6    // VS1053 Data/command select pin (output)
+

 //
 // SETUP SD CARD
@@ -224,6 +234,7 @@
   NfcAdapter nfc = NfcAdapter(pn532spi);
 #endif

+
 // this implementation uses the Adafruit PN532 library alone - it is way smaller and preferrable
 // as it allows for tag removal recognition and does not enforce the user to turn off the box
 // after an album was played, as the above implementation does.
@@ -260,10 +271,12 @@
 byte firstTrackToPlay       = 1;                         // the track number to play (used for the loop)
 char nextTrackToPlay        = 1;                         // the track number to play next (can also be the previos number or a -1 in case of an error)

+
 // file to hold the last played album (aka directory) name - from here we may retrieve other data from the trackDb
 #ifdef RESUMELAST
   const char lastPlayedSessionFile[] = "/trackdb0/LASTPLAY.TDB";
 #endif
+

 // trackDb on the SD card - this is where we store the NFC TAG <-> Directory connection and the track to start playback with
 #ifdef NFCTRACKDB
@@ -278,11 +291,13 @@
   byte uidLength;                          // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
 #endif

+
 // volume control variables for the analog poti
 #ifdef VOLUMEPOT
   const byte volPotPin      = A0;      // the analog input pin that we use for the potentiometer
   word lastVolSensorValue   = 0;       // keeps the last read sensor value
 #endif
+

 // control buttons definition
 #ifdef BUTTONS
@@ -298,6 +313,7 @@
   const word btnPrevValue   = 991;     // 330 Ohm - The value we receive from analog input if the Previos (aka Prev or Rewind) Button is pressed
   const word minBtnValue    = 800;     // we use this value to determine, whether or not to check the buttons. Set to lower val than smallest of buttons
 #endif
+

 // IR remote control
 #ifdef IRREMOTE
@@ -395,6 +411,8 @@
   static void switchLightState(void);   // switch the boolean var lightOn from true to false and vice versa - in case light is lightOn is set to true, lightStartUpTime is set to millis()
 #endif

+
+
 //
 //       SSSSSS  EEEEEE  TTTTTTTT  UU   UU   PPPPP
 //      SS       EE         TT     UU   UU  PP   PP
@@ -403,11 +421,13 @@
 //      SSSSSS   EEEEEE     TT      UUUUU   PP
 //
 void setup() {
+  // SETUP SERIAL CONSOLE
   #ifdef DEBUG
     Serial.begin(38400);
   #endif

-  // set the buttons as input
+
+  // DEFINE INPUT PINs
   #ifdef VOLUMEPOT
     pinMode(volPotPin, INPUT);       // connects to the potentiometer that shall control the volume
   #endif
@@ -421,14 +441,16 @@
     pinMode(iRRemotePin, INPUT);     // connects to the output port of the remote control (decoded values for each button in function playTrack())
   #endif

-  // and the leds as output
+
+  // DEFINE OUPUT PINs
   #ifdef OPRLIGHT
     pinMode(infoLedPin, OUTPUT);     // connect to blue LED
   #endif
   pinMode(warnLedPin, OUTPUT);     // connect to orange LED
   pinMode(errorLedPin, OUTPUT);    // connect to a red LED

-  // initialize the music player
+
+  // INITIALIZE THE MUSIC PLAYER
   if (! musicPlayer.begin()) {
     #ifdef DEBUG
       Serial.println(F("VS1053 Not found"));
@@ -436,16 +458,6 @@
     // flash the red light to indicate we have an error
     for (;;) { digitalWrite(errorLedPin, HIGH); }
   }
-  // initialize the SD card
-  if (!SD.begin(CARDCS)) {
-    #ifdef DEBUG
-      Serial.println(F("SD-Card Not found"));
-    #endif
-    // flash the red light to indicate we have an error
-    for (;;) { digitalWrite(errorLedPin, HIGH); }
-  }
-
-
   // This option uses a pin interrupt. No timers required! But DREQ
   // must be on an interrupt pin. For Uno/Duemilanove/Diecimilla
   // that's Digital #2 or #3
@@ -457,7 +469,18 @@
     for (;;) { digitalWrite(errorLedPin, HIGH); }
   }

-  // WELCOME SOUND
+
+  // INITIALIZE THE SD CARD
+  if (!SD.begin(CARDCS)) {
+    #ifdef DEBUG
+      Serial.println(F("SD-Card Not found"));
+    #endif
+    // flash the red light to indicate we have an error
+    for (;;) { digitalWrite(errorLedPin, HIGH); }
+  }
+
+
+  // PLAY THE WELCOME SOUND
   #ifdef VOLUMEPOT
     plrAdjustVolume();            // initiallly adjust volume
   #endif
@@ -466,7 +489,7 @@
   }

-  // now as the last thing, start the nfc reader
+  // START THE NFC READER
   #ifdef NFCNDEF
     // either use the simple one with NDEF support to get the   tag <-> album directory  connection
     nfc.begin();
@@ -476,6 +499,7 @@
     // or use the Adafruit implementation, which allows for resume and rescan etc.
     //   but needs the trackDB to get the album directory for a tag as no NDEF messages are supported
     nfc.begin();
+    // make sure to comment this out after PN532 is working as it takes approx 290 bytes from progmem
     uint32_t versiondata = nfc.getFirmwareVersion();
     if (! versiondata) {
       #ifdef DEBUG
@@ -487,11 +511,13 @@
       // Got ok data, print it out!
       Serial.print(F("Found chip PN5")); Serial.println((versiondata>>24) & 0xFF, HEX);
       Serial.print(F("Firmware ver. ")); Serial.print((versiondata>>16) & 0xFF, DEC);
-      Serial.print(F('.')); Serial.println((versiondata>>8) & 0xFF, DEC);
+      Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
     #endif
     // configure board to read RFID tags
+
     nfc.SAMConfig();
   #endif
+

   // ALL DONE
   delay(100); // wait some time for everything to settle
@@ -625,7 +651,7 @@
 //
 //  BELOW THIS LINE THE MP3 PLAYER CONTROL IS DEFINED
 //
-// included in while loop during playback to check for volume changes
+// included in while loop of playTrack() for checks for volume changes
 #ifdef VOLUMEPOT
 static void plrAdjustVolume() {
   // volume control functions
@@ -656,6 +682,7 @@
 }
 #endif

+
 //
 //        MM      MM   PPPPPP   33333
 //        MMMM  MMMM  PP    PP      33
@@ -673,6 +700,7 @@
   musicPlayer.stopPlaying();
 }

+
 // toggle pause
 static void plrTogglePause(void) {
   if (!musicPlayer.paused()) {
@@ -688,6 +716,8 @@
   }
 }

+
+// iterates through al files in an album directory and calls playTrack for each track number iteratively
 static char playAlbum(byte numberOfFiles) {
   boolean loopWarningMessageFileNotFound = true;// make sure   file not found               warning message is shown at least once

@@ -702,24 +732,27 @@
     #ifdef DEBUG
       Serial.print(F("Track ")); Serial.print(curTrack); Serial.print(F("/")); Serial.print(numberOfFiles);Serial.println(F(": "));
     #endif
-
+
+    // set the filename we want to play in the global variable so the playTrack() function knows what to play
     if (!setFileNameToPlay(curTrack)) {
-      // created filename does not exit on SD card :-(
+      // set filename does not exit on SD card :-(
       if (loopWarningMessageFileNotFound) {
         loopWarningMessageFileNotFound = false; // set loop warning message so we don't show this warning in the next loop
         issueWarning("file not found", "/system00/filnotfn.mp3", true);
       }
-      break;
+      break;  // try the filename - we break the for loop and skip to next number
     }

     // make sure we remember the just started track to be the new track, in case player is stopped
     if (curTrack != firstTrackToPlay) {
-      // in case we are on the last track, write the first track to the tag, so we start playback all from the beginning.
+      // in case we are on the last track, choose the first track, so we start playback all from the beginning.
       if (curTrack == numberOfFiles) firstTrackToPlay = 1; else firstTrackToPlay = curTrack;

       #ifdef DEBUG
         //Serial.print(F("set ")); Serial.print(firstTrackToPlay); Serial.println(F(" as first track to play"));
       #endif
+
+      // now store this new first track in the TrackDB
       #ifdef NFCTRACKDB
         // first create the new trackDb entry:
         setTrackDbEntry();
@@ -730,7 +763,7 @@
       #endif
     }

-    // play the track on the music maker shield and retrieve a return value
+    // play the track on the music maker shield and retrieve the nextTrackToPlay from global variable (it is set by playTrack())
     //        -1  errors trying to play the file (like file not found)
     //         0  success - the file was played
     //     1-127  any positive number for the next track to play
@@ -749,6 +782,8 @@
   return(0);
 }

+
+// play a single track within an album - is called by playAlbum() or by issueWarning()
 static char playTrack(byte trackNo) {
   #ifdef OPRLIGHTTIME
     const unsigned long maxLightTime = 1800000L;  // how long shall the light stay on while nothing is playing - default 900000 = 15 Minutes
@@ -756,7 +791,7 @@
   const unsigned int checkInterval = 10000L;    // time in milliseconds between checks for battery status, if the tag ist still present and if the max light time is reached
   /*
   #ifdef BUTTONS
-    // the 4 control buttons
+    // the 4 control buttons  - defined in global section
     word btnVal;                        // stores the value we receive on the btnLinePin for comparance with the predefined analog reads for the 4 buttons
     const byte btnValDrift   = 5;       // maximum allowed difference + and - the predefined value for each button we allow
     const word btnPressDelay = 500;     // delay in milliseconds to prevent double press detection
@@ -769,7 +804,7 @@
   #endif

   #ifdef IRREMOTE
-    // IR Remote control
+    // IR Remote control      - defined in global section
     // to reduce PROGMEM size I decided to not use the whole decimal value for each button on the remote control but instead do a calculation
     // which reduces the needed size of the variable to hold the value but still creates different values for each button
     // Function  Original code   Minus         DIV   code I use
@@ -991,6 +1026,7 @@
   return (nextTrackToPlay);
 }

+
 //
 //      TTTTTTTTTT  RRRRRR       AA       CCCCC  KK   KK  DDDDDD    BBBBBB
 //          TT      RR   RR     AAAA     CC      KK KK    DD    DD  BB    BB
@@ -1123,6 +1159,7 @@
 }
 #endif

+
 //
 //      HH    HH  EEEEEE  LL      PPPPPP    EEEEEE  RRRRRR
 //      HH    HH  EE      LL      PP    PP  EE      RR   RR
@@ -1174,6 +1211,17 @@
   strcat(trackDbEntry, "\n");                     // and a newline :-)
 }
 #endif
+
+
+#ifdef DEBUG
+// show the free RAM
+int freeRam () {
+  extern int __heap_start, *__brkval;
+  int v;
+  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+}
+#endif
+

 //
 //        FFFFFF  II  LL      EEEEEE
@@ -1223,6 +1271,7 @@
   digitalWrite(warnLedPin, HIGH);
 }

+
 //
 //  LL      EEEEEE  DDDDDD
 //  LL      EE      DD   DD
@@ -1230,7 +1279,7 @@
 //  LL      EE      DD   DD
 //  LLLLLL  EEEEEE  DDDDDD
 //
-// switches the value of lightOn between true and false
+// switches the value of lightOn between true and false - only needed in case there is a LED attached
 #ifdef OPRLIGHT
 static void switchLightState(void) {
   if (!lightOn) {


fix date in home ethernet ino template

fix date in home ethernet ino template

--- files/template_home/template_home.ino
+++ files/template_home/template_home.ino
@@ -1,7 +1,7 @@
 /*
   senseBox Home - Citizen Sensingplatform
   Version: 2.4
-  Date: 2016-Mar-06
+  Date: 2017-Mar-06
   Homepage: https://www.sensebox.de https://www.opensensemap.org
   Author: Institute for Geoinformatics, University of Muenster
   Note: Sketch for senseBox:home


cleaning up

cleaning up

--- rtty/rtty-gps.ino
+++ rtty/rtty-gps.ino
@@ -1,337 +0,0 @@
-// Arduino RTTY Modulator
-// Uses Fast PWM to produce ~8kHz 8bit audio
-
-#include "baudot.h"
-#include "pwmsine.h"
-
-// Yeah, I really need to get rid of these globals.
-// Thats next on the to-do list
-
-unsigned int sampleRate = 7750;
-unsigned int tableSize = sizeof(sine)/sizeof(char);
-unsigned int pstn = 0;
-int sign = -1;
-unsigned int change = 0;
-unsigned int count = 0;
-
-int fmark = 870;
-int fspac = 700;
-int baud = 45;
-int bits = 8;
-char lsbf = 0;
-
-unsigned char bitPstn = 0;
-int bytePstn = 0;
-unsigned char tx = 1;
-
-unsigned char charbuf = 0;
-unsigned char shiftToNum = 0;
-unsigned char justshifted = 0;
-
-char msg[] = "\n\nCQ CQ CQ DE KG4SGP KG4SGP KG4SGP KN\n\n";
-
-// compute values for tones.
-unsigned int dmark = (unsigned int)((2*(long)tableSize*(long)fmark)/((long)sampleRate));
-unsigned int dspac = (unsigned int)((2*(long)tableSize*(long)fspac)/((long)sampleRate));
-int msgSize = sizeof(msg)/sizeof(char);
-unsigned int sampPerSymb = (unsigned int)(sampleRate/baud);
-
-void setup() {
-
-  // stop interrupts for setup
-  cli();
-
-  // setup pins for output
-  pinMode(3, OUTPUT);
-  pinMode(13, OUTPUT);
-
-  // setup counter 2 for fast PWM output on pin 3 (arduino)
-  TCCR2A = _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
-  TCCR2B = _BV(CS21);
-  TIMSK2 = _BV(TOIE2);
-
-  // begin serial communication
-  Serial.begin(9600);
-  Serial.println("Started");
-
-  // re-enable interrupts
-  sei();
-}
-
-int getgps(){
-
-  // GPS Data
-  char time[16] = {};
-  char longitude[16] = {};
-  char NS[16] = {};
-  char latitude[16] = {};
-  char EW[16] = {};
-  char altitude[16] = {};
-  char aUnits[16] = {};
-
-  // intialize Finite State Machine
-  int go = 0;
-  char buffer[16] = { 0 };
-  int state = 0;
-  int commaCount = 0;
-
-  while(go != 1){
-
-    if (Serial.available()) {
-
-      buffer[15] = Serial.read();
-      Serial.print(buffer[15]);
-
-      if(buffer[15] == ',') commaCount++;
-
-      // reset FSM on new data frame
-      if(buffer[15] == '$') {
-        commaCount = 0;
-        state = 0;
-      }
-
-      // Finite State Machine
-      if (state == 0) {
-        if (buffer[10] == '$'){
-          if (buffer[11] == 'G' && buffer [12] == 'P' &&
-               buffer[13] == 'G' && buffer[14] == 'G' && buffer [15] == 'A'){
-            state = 1;
-          }
-        }
-
-      } else if (state == 1){
-
-        // Grab time info
-        // If this is the second comma in the last element of the buffer array
-        if (buffer[15] == ',' && commaCount == 2){
-          for(int i = 14; i >= 0; i--){
-            // copy the data, counting down until a comma is reached
-            if (buffer[i] == ',' || buffer[i] == ','){
-              time[i] == '\0';
-              break;
-            }
-            time[i] = buffer[i];
-          }
-
-          //next state
-          state = 2;
-        }
-
-      } else if (state == 2) {
-
-        // Grab latitude
-        if (buffer[15] == ',' && commaCount == 3){
-          for(int i = 14; i >= 0; i--){
-            latitude[i] = buffer[i];
-          }
-          state = 3;
-        }
-
-      } else if (state == 3) {
-
-        // Grab N or S reading
-        if (buffer[15] == ',' && commaCount == 4){
-          NS[0] = buffer[14];
-          state = 4;
-        }
-
-      } else if (state == 4) {
-
-        // Grab longitude
-        if (buffer[15] == ',' && commaCount == 5){
-          for(int i = 14; i >= 0; i--){
-
-            longitude[i] = buffer[i];
-          }
-
-          state = 5;
-        }
-
-      } else if (state == 5) {
-
-        // Grab E or W reading
-        if (buffer[15] == ',' && commaCount == 6){
-          EW[0] = buffer[14];
-          state = 6;
-        }
-
-      } else if (state == 6) {
-
-        // Grab altitude
-        if (buffer[15] == ',' && commaCount == 10){
-          for(int i = 14; i >= 0; i--){
-            if (buffer[i] == ',') break;
-            altitude[i-7] = buffer[i];
-          }
-          state = 7;
-        }
-
-      } else if (state == 7) {
-
-        // Grab altitude units
-        if (buffer[15] == ',' && commaCount == 11){
-          aUnits[0] = buffer[14];
-          state = 8;
-        }
-
-      } else if (state == 8) {
-        msg = "W8UPD-1 ";
-        prntchars(&latitude[0]);
-        prntchars(&NS[0]);
-        msg += " ";
-        prntchars(&longitude[0]);
-        prntchars(&EW[0]);
-        msg += " ";
-        prntchars(&altitude[0]);
-        prntchars(&aUnits[0]);
-        //printf(" T");
-        //prntchars(&time[0]);
-        msg += " KN";
-
-        // send the telemetry to the screen
-        Serial.println(" ");
-        Serial.println(" ");
-        Serial.println(msg);
-        Serial.println(" ");
-        return 1;
-      }
-
-      for(int i = 0; i <16; i++){
-        buffer[i] = buffer[i+1];
-      }
-
-    }
-  }
-}
-
-char calcAmp(){
-  pstn += change;
-
-  // if the position rolls off, change sign and start where you left off
-  if(pstn >= tableSize) {
-    pstn = pstn%tableSize;
-    sign *= -1;
-  }
-
-  // return the pwm value
-  return (char)(128+(sign*sine[pstn]));
-}
-
-// sets the character buffer, the current character being sent
-void setCbuff(){
-    int i = 0;
-
-    // Note: the <<2)+3 is how we put the start and stop bits in
-    // the baudot table is MSB on right in the form 000xxxxx
-    // so when we shift two and add three it becomes 0xxxxx11 which is
-    // exactly the form we need for one start bit and two stop bits when read
-    // from left to right
-
-    // try to find a match of the current character in baudot
-    for(i = 0; i < (sizeof(baudot_letters)/sizeof(char)); i++){
-
-      // look in letters
-      if(msg[bytePstn] == baudot_letters[i]) {
-
-        // if coming from numbers, send shift to letters
-        if(shiftToNum == 1){
-          shiftToNum = 0;
-          charbuf = ((baudot[31])<<2)+3;
-          justshifted = 1;
-        } else {
-          charbuf = ((baudot[i])<<2)+3;
-        }
-      }
-
-      //look in numbers
-      if(msg[bytePstn] != ' ' && msg[bytePstn] != 10
-		&& msg[bytePstn] == baudot_figures[i]) {
-        if(shiftToNum == 0){
-          shiftToNum = 1;
-          charbuf = ((baudot[30])<<2)+3;
-          justshifted = 1;
-        } else {
-          charbuf = ((baudot[i])<<2)+3;
-        }
-      }
-
-
-    }
-}
-
-void setSymb(char mve){
-
-    // if its a 1 set change to dmark other wise set change to dspace
-    if((charbuf&(0x01<<mve))>>mve) {
-      change = dmark;
-    } else {
-      change = dspac;
-    }
-}
-
-// int main
-void loop() {
-  while(1){
-    if(tx = 0){
-      getgps();
-      tx = 1;
-    }
-  }
-}
-
-// This interrupt run on every sample (7128.5 times a second)
-// though it should be every 7128.5 the sample rate had to be set differently
-// to produce the correct baud rate and frequencies (that agree with the math)
-// Why?! I'm going to figure that one out
-ISR(TIMER2_OVF_vect) {
-  count++;
-  if (tx == 0) return;
-
-  // if we've played enough samples for the symbol were transmitting, get next symbol
-  if (count >= sampPerSymb){
-    count = 0;
-    bitPstn++;
-
-    // if were at the end of the character return to the begining of a
-    // character and grab the next one
-    if(bitPstn > (bits-1)) {
-      bitPstn = 0;
-
-      // dont increment bytePstn if were transmitting a shift-to character
-      if(justshifted != 1) {
-        bytePstn++;
-      } else {
-        justshifted = 0;
-      }
-
-      setCbuff();
-      // if were at the end of the message, return to the begining
-      if (bytePstn > (msgSize-2)){
-
-        tx = 0;
-
-        // clear variables used here
-        bitPstn = 0;
-        bytePstn = 0;
-        count = 0;
-        return;
-      }
-    }
-
-    unsigned char mve = 0;
-    // endianness thing
-    if (lsbf != 1) {
-      // MSB first
-      mve = (bits-1)-bitPstn;
-    } else {
-      // LSB first
-      mve = bitPstn;
-    }
-
-    // get if 0 or 1 that were transmitting
-    setSymb(mve);
-  }
-
-  // set PWM duty cycle
-  OCR2B = calcAmp();
-}


arm compiler doesnt support binary notation apparently

--- examples/StandardFirmata/StandardFirmata.ino
+++ examples/StandardFirmata/StandardFirmata.ino
@@ -34,12 +34,12 @@
 #include <Firmata.h>

 // move the following defines to Firmata.h?
-#define I2C_WRITE B00000000
-#define I2C_READ B00001000
-#define I2C_READ_CONTINUOUSLY B00010000
-#define I2C_STOP_READING B00011000
-#define I2C_READ_WRITE_MODE_MASK B00011000
-#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
+#define I2C_WRITE 0x00
+#define I2C_READ 0x08
+#define I2C_READ_CONTINUOUSLY 0x10
+#define I2C_STOP_READING 0x18
+#define I2C_READ_WRITE_MODE_MASK 0x18
+#define I2C_10BIT_ADDRESS_MODE_MASK 0x20

 #define MAX_QUERIES 8
 #define MINIMUM_SAMPLING_INTERVAL 10


Arduino: Feature: Added functionality to use telop (linear actuator teleop) to control linear actuator

--- Arduino/soil_sensor_w_linear_actuator/soil_sensor_w_linear_actuator.ino
+++ Arduino/soil_sensor_w_linear_actuator/soil_sensor_w_linear_actuator.ino
@@ -17,6 +17,8 @@
 #include <std_msgs/Float32.h>
 #include <std_msgs/Uint8.h>

+#include <geometry_msgs/Twist.h>
+
 #include <SHT1x.h>

 // Specify data and clock connections and instantiate SHT1x object
@@ -40,14 +42,23 @@
 int incomingByte = 0;   // for incoming serial data

 // Create the callback function for the subscriber
-void actuatorCb(const std_msgs::Float32& cmd_msg)
+//void actuatorCb(const std_msgs::Float32& cmd_msg)
+void actuatorCb(const geometry_msgs::Twist& cmd_msg) // for Twist msg
 {
-  actuator_msg.data = cmd_msg.data;
-  linear_actuator_cmd_echo_msg.data = cmd_msg.data;
+
+  // Pre-Teleop
+  //actuator_msg.data = cmd_msg.data;
+  //linear_actuator_cmd_echo_msg.data = cmd_msg.data;
+
+  // For Teleop Msg Parsing
+  // Access the x variable in the data
+  actuator_msg.data = cmd_msg.linear.x;
+  linear_actuator_cmd_echo_msg.data = cmd_msg.linear.x;
 }

 // Create the subscriber before void setup
-ros::Subscriber<std_msgs::Float32> sub("linear_actuator_cmd", &actuatorCb );
+//ros::Subscriber<std_msgs::Float32> sub("linear_actuator_cmd", &actuatorCb );
+ros::Subscriber<geometry_msgs::Twist> sub("linear_actuator_cmd", &actuatorCb );

 void setup()
 {
@@ -111,7 +122,10 @@
   //Serial.println(linear_actuator_cmd);
   // For ROS
   // 1
-  if (linear_actuator_cmd == 11)// Move down
+  //if (linear_actuator_cmd == 11)// Move down
+
+  // Swap to using teleop
+  if (linear_actuator_cmd < 0)// Move down
   {
     analogWrite(PWMA, 64);
     digitalWrite(AIN1, HIGH);       // sets the digital pin 13 on
@@ -120,7 +134,8 @@
   }// End else if for moving down

   // 2
-  else if (linear_actuator_cmd == 12) // Move up
+  //else if (linear_actuator_cmd == 12) // Move up
+  else if (linear_actuator_cmd > 0) // Move up
   {
     analogWrite(PWMA, 64);
     digitalWrite(AIN1, LOW);       // sets the digital pin 13 on
@@ -138,9 +153,13 @@
   // If it is not set to non-zero in the next time step, the else would trigger and turn off the motor
   linear_actuator_cmd_echo_msg.data = 0;

+  //linear_actuator_cmd_echo_msg.linear.x = 0;
+
   // Reset the variable for the linear actuator cmd to 0, so there needs to be a continuous stream of data for it to actuate the motor
   // linear_actuator_cmd = 0; This does not work, as actuator_msg.data is still the old value, linear_actuator_cmd takes value from actuator_msg.data
   actuator_msg.data = 0;
+
+  //actuator_msg.linear.x = 0; // for teleop

   // Test


Adjusted datalogger to remove indirection reference and changed from Console to Serial

--- hardware/arduino/avr/libraries/Bridge/examples/Datalogger/Datalogger.ino
+++ hardware/arduino/avr/libraries/Bridge/examples/Datalogger/Datalogger.ino
@@ -2,45 +2,46 @@
   SD card datalogger

  This example shows how to log data from three analog sensors
- to an SD card mounted on the Linux using the Bridge library.
+ to an SD card mounted on the Arduino Yun using the Bridge library.

  The circuit:
  * analog sensors on analog ins 0, 1, and 2
  * SD card attached to SD card slot of the Arduino Yun

  You can remove the SD card while the Linux and the
- sketch are running but becareful to don't remove it while
- the system is writing on it.
+ sketch are running but be careful not to remove it while
+ the system is writing to it.

  created  24 Nov 2010
  modified 9 Apr 2012
  by Tom Igoe
  adapted to the Yun Bridge library 20 Jun 2013
  by Federico Vanzati
+ modified  21 Jun 2013
+ by Tom Igoe

  This example code is in the public domain.

  */

 #include <FileIO.h>
-#include <Console.h>
+#include <Serial.h>

 void setup() {
-  // Initialize the Bridge and the Console
+  // Initialize the Bridge and the Serial
   Bridge.begin();
-  Console.begin();
+  Serial.begin(9600);
   FileSystem.begin();

-  while(!Console){
-    ;  // wait for Console port to connect.
-  }
+  while(!Serial);  // wait for Serial port to connect.
+  Serial.println("Filesystem datalogger");
 }

 void loop () {
   // make a string that start with a timestamp for assembling the data to log:
   String dataString = "";
-  addTimeStamp(dataString);
+  dataString += addTimeStamp();
   dataString += " = ";

   // read three sensors and append to the string:
@@ -62,11 +63,11 @@
     dataFile.println(dataString);
     dataFile.close();
     // print to the serial port too:
-    Console.println(dataString);
+    Serial.println(dataString);
   }
   // if the file isn't open, pop up an error:
   else {
-    Console.println("error opening datalog.txt");
+    Serial.println("error opening datalog.txt");
   }

   delay(15000);
@@ -74,7 +75,8 @@
 }

 // This function append a time stamp to the string passed as argument
-void addTimeStamp(String &string) {
+String addTimeStamp() {
+  String result;
   Process time;
   time.begin("date");
   time.addParameter("+%D-%T");
@@ -83,6 +85,6 @@
   while(time.available()>0) {
     char c = time.read();
     if(c != '\n')
-      string += c;
+      result += c;
   }
 }


Wrote handle_joystick() and handle_start_button() as separate functions where start button updates state.

--- src/oven_control_v3/oven_control_v3.ino
+++ src/oven_control_v3/oven_control_v3.ino
@@ -1,5 +1,9 @@
 /********************************************

+ This is oven control shield code v3 written by
+ Thanh Tung Nguyen and Jenner Hanni, 2014.
+ http://github.com/wicker/oven-controller/
+
  This is an oven control sketch for the Adafruit 1.8" TFT
  shield with joystick stacked on a PSAS Airframes Team
  Oven Control Shield v3 stacked on an Arduino Uno.
@@ -12,10 +16,6 @@

  We referenced code written by Limor Fried/Ladyada
  for Adafruit Industries under the MIT license.
-
- This is oven control shield code v3 written by
- Thanh Tung Nguyen and Jenner Hanni, 2014.
- http://github.com/wicker/oven-controller/

  *******************************************/

@@ -27,6 +27,12 @@

 #define OFF 0
 #define ON  1
+
+// assign state values
+#define START   1
+#define RUNNING 2
+#define STOP    3
+#define STOPPED 4

 // assign joystick positions
 #define BUTTON_NONE 0
@@ -97,6 +103,7 @@
 double currTime;

 uint8_t buttonhistory  =  0;
+uint8_t joystickVal = 0;

 // Thermocouples
 Adafruit_MAX31855 thermocouple1(spiCLK, thermoCS1, spiMISO);
@@ -136,31 +143,6 @@
   Serial.println("  1 ON");
 }

-uint8_t readButton(void) {
-  float a = analogRead(3);
-
-  a *= 5.0;
-  a /= 1024.0;
-
-  Serial.print("Button read analog = ");
-  Serial.println(a);
-  if (a < 0.2) return BUTTON_DOWN;
-  if (a < 1.0) return BUTTON_RIGHT;
-  if (a < 1.5) return BUTTON_SELECT;
-  if (a < 2.0) return BUTTON_UP;
-  if (a < 3.2) return BUTTON_LEFT;
-  else return BUTTON_NONE;
-}
-
-int scan_button(int swButton)
-{
-  int ADCreading = analogRead(swButton);
-//  Serial.println(ADCreading);
-  if (ADCreading < ADCThreshold)
-         return (1);
-  else   return (0);
-}
-
 void tempPrint()
 {
   Serial.print("Current temperature F = ");
@@ -178,6 +160,73 @@
   Serial.println(tempAverage);
 }

+// read the joystick and save the value
+void handle_joystick() {
+
+  float a = analogRead(3);
+
+  a *= 5.0;
+  a /= 1024.0;
+
+  Serial.print("Button read analog = ");
+  Serial.println(a);
+  if (a < 0.2) joystickVal = BUTTON_DOWN;
+  if (a < 1.0) joystickVal = BUTTON_RIGHT;
+  if (a < 1.5) joystickVal = BUTTON_SELECT;
+  if (a < 2.0) joystickVal = BUTTON_UP;
+  if (a < 3.2) joystickVal = BUTTON_LEFT;
+  else         joystickVal = BUTTON_NONE;
+}
+
+// Read the start button and update the state machine.
+// Possible states are START, RUNNING, STOP, and STOPPED.
+// The state is updated and the timer is incremented or
+// reset to zero, depending on state.
+void handle_start_button()
+
+  uint8_t ADCReading < ADCThreshold);
+
+  // if the input is HIGH, handle it as a START
+  if (ADCReading > ADCThreshold) {
+    if (status == START) {
+      status = RUNNING;
+      currTime = millis()-startTime;
+    }
+    else if (status == RUNNING) {
+      status = RUNNING;
+      currTime = millis()-startTime;
+    }
+    else if (status == STOP) {
+      status = STOPPED;
+      currTime = 0;
+    }
+    else {
+      status = START;
+      currTime = 0;
+    }
+  }
+
+  // otherwise the input is LOW, handle it as a STOP
+  else {
+    if (status == START) {
+      status = STOP;
+      currTime = millis()-startTime;
+    }
+    else if (status == RUNNING) {
+      status = STOP;
+      currTime = millis()-startTime;
+    }
+    else if (status == STOP) {
+      status = STOPPED;
+      currTime = 0;
+    }
+    else {
+      status = STOPPED;
+      currTime = 0;
+    }
+  }
+}
+
 // Poll each thermocouple value and get an average value.
 // Adjusting by 32 for each tempSensor value
 // eliminates the SPI disconnection.