Readings on-demand with "read" input.

Readings on-demand with "read" input.

--- AzElSensor/AzElSensor.ino
+++ AzElSensor/AzElSensor.ino
@@ -29,7 +29,8 @@
 #define    ACC_FULL_SCALE_8_G        0x10
 #define    ACC_FULL_SCALE_16_G       0x18

-
+boolean cmdPending;
+String cmdStr;

 // This function read Nbytes bytes from I2C device at address Address.
 // Put read bytes starting at register Register in the Data array.
@@ -88,16 +89,14 @@
   I2CwriteByte(MAG_ADDRESS,0x0A,0x16);

    pinMode(13, OUTPUT);
-  Timer1.initialize(1000000);         // initialize timer1, and set a 1/2 second period
-  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
-
+  //Timer1.initialize(1000000);         // initialize timer1, and set a 1/2 second period
+  //Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
+
+  cmdPending = false;

   // Store initial time
   ti=millis();
 }
-
-
-

 // Counter
@@ -109,7 +108,6 @@
 int16_t mx, my, mz;
 uint8_t Mag[7];

-
 void callback()
 {
   intFlag=true;
@@ -119,34 +117,28 @@
 // Main loop, read and display data
 void loop()
 {
-  while (!intFlag);
-  intFlag=false;
-
-  // Display time
-  //Serial.print (millis()-ti,DEC);
-
+  //while (!intFlag);
+  //intFlag=false;
+
+  if ( Serial.available() ) getInByte();
+  if ( cmdPending ) processCmd();
+
+}
+
+void processCmd() {
+  if ( cmdStr == "read" ) getReadings();
+  cmdPending = false;
+  cmdStr = "";
+}
+
+void getReadings() {
   accelerometer_subr();
   Serial.print( "," );
   subr_magnetometer();
   Serial.print( "," );
   gyro_subr();
   Serial.println( "" );
-
-  // _______________
-  // ::: Counter :::
-
-  // Display data counter
-//  Serial.print (cpt++,DEC);
-//  Serial.print ("\t");
-
-  // End of line
-  //Serial.println("");
-  //delay(500);
-
-  // ____________________________________
-  // :::  accelerometer and gyroscope :::
-}
-
+}

   void accelerometer_subr()
   {
@@ -218,7 +210,17 @@
     Serial.print (mz,DEC);//(mz-700,DEC);

   }
-
+
+void getInByte() {
+  char inByte = Serial.read();
+  if ( !cmdPending ) {
+    if ( inByte == '\r' || inByte == '\n' ) {
+      cmdPending = true;
+    } else {
+      cmdStr += inByte;
+    }
+  }
+}


remove no-longer-needed includes

remove no-longer-needed includes

--- src/payload/payload.ino
+++ src/payload/payload.ino
@@ -1,19 +1,4 @@
 #include "payload.h" // C++ file which acts as a surrogate this .ino program.
-
-// Must include libraries here for those using the Arduino environment.
-// Sensors:
-#include <Adafruit_Sensor.h>
-#include <Adafruit_BME280.h>
-#include <Adafruit_BNO055.h>
-
-// SD I/O:
-#include <BlockDriver.h>
-#include <MinimumSerial.h>
-#include <SdFat.h>
-#include <SdFatConfig.h>
-#include <SysCall.h>
-//#include <FreeStack.h> // something is wrong with this library.
-

 void setup() {
   rcr::level1payload::setup();


Voordeur; with tussendeur fixes.

Voordeur; with tussendeur fixes.

--- test/PoE-test/voordeur-asis-2017/voordeur-asis-2017.ino
+++ test/PoE-test/voordeur-asis-2017/voordeur-asis-2017.ino
@@ -1,4 +1,4 @@
-/* Schuif/voordeur 2-'as is' configuration which should be near identical
+/* Voordeur hal 'as is' configuration which should be near identical
     to the existing setup late 2017.

 */
@@ -23,14 +23,37 @@
 #define MFRC522_RSTO    (32)
 #define MFRC522_3V3     /* 3v3 */

+#define SOLENOID_GPIO     (4)
+#define SOLENOID_OFF      (LOW)
+#define SOLENOID_ENGAGED  (HIGH)
+
 #define BUZZER_GPIO       (2)
-#define SOLENOID_GPIO     (4)
-#define LED_AART          (16)
-
-#define DOOR_OPEN_DELAY   (10*1000)
-#define REPORTING_PERIOD  (300*1000)
+#define BUZZER_OFF        (HIGH)
+#define BUZZER_ENGAGED    (LOW)
+
+#define AARTLED_GPIO      (16)
+
+#define DOOR_OPEN_DELAY         (10*1000)   //  10 seconds -- how long to hold the relay engaged; in milli seconds.
+#define CACHE_FALLBACK_TIMEOUT  (500)       // 0.5 second  -- how long to wait for a reply before checking the cache.
+#define MAX_RESPONSE_TIMEOUT    (3500)      // 3.5 seconds -- max wait for reply from the server.
+
+// Report regulary - but swithc to a higher frequency if we are in test mode. Also prefix our MQTT topic with 'test'
+// to avoid confusing production.
+//
+#ifdef LOCALMQTT
+#define REPORTING_PERIOD        (300*1000)  //   5 minutes -- how often to report our states; in milli seconds.
+#define PREFIX ""
+#else
+#define REPORTING_PERIOD        (10*1000)   //  10 seconds -- -- how often to report our states; in milli seconds.
+#define PREFIX "test"
+#define MQTT_KEEPALIVE          (10)        // seconds -- keep alive check; default is 2 minutes - but it is
+// easier to keep this short during debugging - i.e. when testing breaking connections. Note that this may not
+// work if the Arduino CPP gets the order wrong.
+#endif

 typedef enum doorstates { CLOSED, CHECKINGCARD, OPEN } doorstate_t;
+const char doorstates_names[OPEN + 1][15] = { "closed", "checking-card", "open" };
+
 doorstate_t doorstate;
 unsigned long long last_doorstatechange = 0;

@@ -44,10 +67,10 @@
 #include <ArduinoOTA.h>
 #include <ESP32Ticker.h>
 #include <PubSubClient.h>
-#include <MFRC522.h>    // Requires modifed MFRC522 (see pull rq) or the -master branch as of late DEC 2017.
+
+// Requires modifed MFRC522 (see pull rq) or the -master branch as of late DEC 2017.
 // https://github.com/miguelbalboa/rfid.git
-
-
+#include <MFRC522.h>

 SPIClass spirfid = SPIClass(VSPI);
 const SPISettings spiSettings = SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0);
@@ -105,7 +128,8 @@
         type = "SPIFFS";
         break;
       default: {
-          const char buff[] = "Unknown type of reprogramming attempt. Rejecting.";
+          char buff[255];
+          snprintf(buff, sizeof(buff), "[%s] Unknown type of reprogramming attempt. Rejecting.", pname);
           Serial.println(buff);
           client.publish(log_topic, buff);
           client.loop();
@@ -150,14 +174,15 @@
     int p = progress / (total / 10);
     if (p != lp) Serial.printf("Progress: %u %%\n", p * 10);
     lp = p;
-    digitalWrite(LED_AART, ((millis() >> 7) & 3) == 0);
+    digitalWrite(AARTLED_GPIO, ((millis() >> 7) & 3) == 0);
   });

   // Unfortunately-deep in OTA it auto defaults to Wifi. So we
   // force it to ETH -- requires pull RQ https://github.com/espressif/arduino-esp32/issues/944
   // and https://github.com/espressif/esp-idf/issues/1431.
   //
-  ArduinoOTA.begin(TCPIP_ADAPTER_IF_ETH);
+  // ArduinoOTA.begin(TCPIP_ADAPTER_IF_ETH);
+  ArduinoOTA.begin();

   Serial.println("OTA enabled.");
   ota = true;
@@ -183,11 +208,11 @@
 {
   switch (event) {
     case SYSTEM_EVENT_ETH_START:
-      Serial.println("ETH Started");
+      Serial.println("ETH Started" + ETH.macAddress());
       ETH.setHostname(pname);
       break;
     case SYSTEM_EVENT_ETH_CONNECTED:
-      Serial.println("ETH Connected");
+      Serial.println("ETH Connected " + ETH.macAddress());
       break;
     case SYSTEM_EVENT_ETH_GOT_IP:
     case SYSTEM_EVENT_STA_GOT_IP:
@@ -259,9 +284,8 @@
   if (p)
     strncpy(pname, p + 1, sizeof(pname));

-  p = index(pname, '.');
-  if (p)
-    *p = 0;
+  if ((p = index(pname, '.')))
+    * p = '\0';

 #ifndef LOCALMQTT
   // Alert us to safe, non production versions.
@@ -273,18 +297,20 @@
   Serial.print(pname);
   Serial.println(" -- buuld: " __DATE__ " " __TIME__ );

-  pinMode(LED_AART, OUTPUT);
-  digitalWrite(LED_AART, 1);
+  pinMode(SOLENOID_GPIO, OUTPUT);
+  digitalWrite(SOLENOID_GPIO, SOLENOID_OFF);
+
+  pinMode(AARTLED_GPIO, OUTPUT);
+  digitalWrite(AARTLED_GPIO, HIGH);

   pinMode(BUZZER_GPIO, OUTPUT);
-  digitalWrite(BUZZER_GPIO, 1);
-
-  pinMode(SOLENOID_GPIO, OUTPUT);
-  digitalWrite(SOLENOID_GPIO, 1);
+  digitalWrite(BUZZER_GPIO, BUZZER_OFF);

   WiFi.onEvent(WiFiEvent);

-  ETH.begin();
+  if (!(ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE))) {
+    Serial.println("Ethernet failed to begin() up\n");
+  }

   Serial.println("SPI init");
   spirfid.begin(MFRC522_SCK, MFRC522_MISO, MFRC522_MOSI, MFRC522_SDA);
@@ -299,7 +325,7 @@
   byte regVal = 0xA0; //rx irq
   mfrc522.PCD_WriteRegister(mfrc522.ComIEnReg, regVal);

-  Serial.println("Setting up MQTT");
+  Serial.println("Setting up MQTT to " + String(mqtt_host)  + ":" + String(mqtt_port, DEC));
   client.setServer(mqtt_host, mqtt_port);
   client.setCallback(callback);

@@ -312,39 +338,44 @@
     wipeCache();
   } else {
     caching = true;
-    listDir(SPIFFS, " / ", "");
+    unsigned long count = listDir(SPIFFS, "/", "");
+    Serial.println("Caching on - Total of " + String(count, DEC) + " files.");
   };

   Serial.println("setup() done.\n\n");
 }

 // This function is taken from the SPIFFS_Test example. Under the expressif ESP32 license.
+// It returns the number of entries found (files only).
 //
-void listDir(fs::FS &fs, const char * dirname, String prefix) {
+unsigned long listDir(fs::FS &fs, const char * dirname, String prefix) {
   Serial.print(prefix);
   Serial.println(dirname);
+  unsigned long count = 0;

   File root = fs.open(dirname);
   if (!root) {
     Serial.println("Failed to open directory");
-    return;
+    return 0;
   }
   if (!root.isDirectory()) {
     Serial.println("Not a directory");
-    return;
+    return 0;
   }

   File file = root.openNextFile();
   while (file) {
     if (file.isDirectory()) {
-      listDir(fs, file.name(), prefix + " ");
+      count += listDir(fs, file.name(), prefix + " ");
     } else {
       Serial.print(prefix + " ");
       Serial.println(file.name());
+      count ++;
     }
     file = root.openNextFile();
   }
   root.close();
+  return count;
 }

 void wipeCache() {
@@ -365,7 +396,7 @@
     SPIFFS.mkdir(String(i));

   Serial.println("Directory structure created.");
-  listDir(SPIFFS, " / ", "");
+  listDir(SPIFFS, "/", "");
   caching = true;
 };

@@ -374,7 +405,7 @@
   for (int i = 0; i < uid.size; i++) {
     path += String(uid.uidByte[i], DEC);
     if (i == 0)
-      path += " / ";
+      path += "/";
     else
       path += ".";
   };
@@ -397,25 +428,29 @@
   }
 }

+void buzz() {
+  static int flip = 0;
+  digitalWrite(BUZZER_GPIO, flip ? BUZZER_ENGAGED : BUZZER_OFF);
+  flip = ! flip;
+}
+
 void closeDoor() {
   doorstate = CLOSED;
-  digitalWrite(SOLENOID_GPIO, HIGH);
+  digitalWrite(SOLENOID_GPIO, SOLENOID_OFF);

   buzzer.detach();
-  digitalWrite(BUZZER_GPIO, HIGH);
-}
-
-void buzz() {
-  static int flip = 0;
-  digitalWrite(BUZZER_GPIO, flip);
-  flip = ! flip;
+  digitalWrite(BUZZER_GPIO, BUZZER_OFF);
 }

 void openDoor() {
+  char msg[255];
+  snprintf(msg, sizeof(msg), "[%s] Engaging solenoid", pname);
   doorstate = OPEN;
+  client.publish(log_topic, msg);
+  Serial.println(msg);

   // Engage solenoid.
-  digitalWrite(SOLENOID_GPIO, LOW);
+  digitalWrite(SOLENOID_GPIO, SOLENOID_ENGAGED);

   // according to Ticker examples - this will reset/overwrite
   // any already running tickers.
@@ -424,13 +459,11 @@

   // Sound buzzer 5 times / second. Use analog PWM if we need faster than 1kHz.
   buzzer.attach_ms(200, &buzz);
-
 };

 bool isOpen() {
-  return digitalRead(SOLENOID_GPIO) == LOW;
-}
-
+  return digitalRead(SOLENOID_GPIO) == SOLENOID_ENGAGED;
+}

 bool isClosed() {
   return !isOpen();
@@ -466,8 +499,9 @@
     if (c >= 32 && c < 128)
       buff[l++] = c;
   };
+
   buff[l] = 0;
-  Serial.println(buff);
+  Serial.println("Handling command: <" + String(buff) + ">");

   if (!strcmp(buff, "reboot")) {
     ESP.restart();
@@ -476,6 +510,16 @@

   if (!strcmp(buff, "report")) {
     reportStats();
+    return;
+  }
+
+  if (!strcmp(buff, "cache")) {
+    char msg[255];
+    unsigned long count = listDir(SPIFFS, "/", "");
+
+    snprintf(msg, sizeof(msg), "[%s] Number of files in the cache: %lu", pname, count);
+    client.publish(log_topic, msg);
+    Serial.println(msg);
     return;
   }

@@ -523,6 +567,12 @@
   if (!strcmp(buff, "open")) {
     Serial.println("Opening door.");
     openDoor();
+    // So we have a lovely security hole here - if someone swipes a card
+    // that has access; and then quickly (before the server respons) swipes
+    // a card that is unknown -- that other card gets caches. And as the system
+    // does not see a 'deny' in the 'as-is' situation - we have a nice window
+    // of naughtyness.
+    //
     if (caching && uid.size)
       setCache(uid, true);
     uid.size = 0;
@@ -547,12 +597,17 @@
 void reportStats() {
   char buff[255];
   snprintf(buff, sizeof(buff),
-           "[%s] alive-uptime %02ld:%02ld :"
-           "swipes %ld, opens %ld, closes %ld, fails %ld, mis-swipes %ld, mqtt reconnects %ld, mqtt fails %ld, door %s",
+           "[%s] alive-uptime %02ld:%02ld, "
+           "mqtt %s (state %d) "
+           "swipes %ld, opens %ld, closes %ld, fails %ld, mis-swipes %ld, mqtt reconnects %ld, mqtt fails %ld, "
+           "door %s, state %s(%d), caching %s",
            pname, cnt_minutes / 60, (cnt_minutes % 60),
+           client.connected() ? "connected" : "not-connected", client.state(),
            cnt_cards,
            cnt_opens, cnt_closes, cnt_fails, cnt_misreads, cnt_reconnects, cnt_mqttfails,
-           isOpen() ? "open" : "closed"
+           isOpen() ? "open" : "closed",
+           doorstates_names[doorstate], doorstate,
+           caching ? "on" : "off"
           );
   client.publish(log_topic, buff);
   Serial.println(buff);
@@ -561,6 +616,10 @@

 void loop()
 {
+#ifdef AARTLED_GPIO
+  // Slow on/off 1 second pattern if we are alive. Very fast flash if we've lost a
+  // network connectionm and a quickish flash while we think the door is open.
+  //
   {
     static unsigned long aart = 0;
     unsigned long del = 1000;
@@ -568,12 +627,13 @@
       del = 100;
     else if (doorstate != CLOSED)
       del = 300;
+
     if (millis() - aart > del) {
-      digitalWrite(LED_AART, !digitalRead(LED_AART));
+      digitalWrite(AARTLED_GPIO, !digitalRead(AARTLED_GPIO));
       aart = millis();
     }
   }
-
+#endif
   if (eth_connected) {
     if (ota)
       ArduinoOTA.handle();
@@ -583,7 +643,7 @@
     client.loop();
     if (!client.connected()) {
       long now = millis();
-      if (now - lastReconnectAttempt > 10*1000) {
+      if (now - lastReconnectAttempt > 10 * 1000) {
         lastReconnectAttempt = now;
         reconnect();
       }
@@ -593,45 +653,70 @@
       client.disconnect();
   }

-  {
-    static doorstate_t lastdoorstate = CLOSED;
-    switch (doorstate) {
-      case CHECKINGCARD:
-        if (millis() - last_doorstatechange > 1500 && caching && checkCache(uid)) {
-          char msg[255];
-          snprintf(msg, sizeof(msg), "[%s] Allowing door to open based on cached information.", pname);
-          Serial.println(msg);
-          client.publish(log_topic, msg);
-          openDoor();
-        }
-        break;
-      case OPEN:
-      case CLOSED:
-      default:
-        break;
-    };
-
-    if (lastdoorstate != doorstate) {
-      lastdoorstate = doorstate;
-      last_doorstatechange = millis();
-    }
-  }
+  static doorstate_t lastdoorstate = CLOSED;
+  if (lastdoorstate != doorstate) {
+    char msg[255];
+    snprintf(msg, sizeof(msg), "[%s] Change from state %s(%d) to %s(%d)",
+             pname,
+             doorstates_names[lastdoorstate], lastdoorstate, doorstates_names[doorstate], doorstate);
+    Serial.println(msg);
+#ifndef LOCALMQTT
+    client.publish(log_topic, msg);
+#endif
+    lastdoorstate = doorstate;
+    last_doorstatechange = millis();
+  }
+
+  switch (doorstate) {
+    case CHECKINGCARD:
+      if (millis() - last_doorstatechange > CACHE_FALLBACK_TIMEOUT && caching && checkCache(uid)) {
+        char msg[255];
+        snprintf(msg, sizeof(msg), "[%s] Allowing door to open based on cached information.", pname);
+        Serial.println(msg);
+        client.publish(log_topic, msg);
+        openDoor();
+      }
+      if (millis() - last_doorstatechange > MAX_RESPONSE_TIMEOUT) {
+        char msg[255];
+        snprintf(msg, sizeof(msg), "[%s] No reply from server. Keeping door closed.", pname);
+        Serial.println(msg);
+        client.publish(log_topic, msg);
+        closeDoor();
+      }
+      break;
+    case OPEN:
+    case CLOSED:
+    default:
+      break;
+  };
+
+
   // catch any logic errors or strange cases where the door is open while we think
   // we are not doing anything.
   //
   if ((millis() - last_doorstatechange > 10 * DOOR_OPEN_DELAY) && ((doorstate != CLOSED) || (!isClosed()))) {
     closeDoor();
-    char msg[256];
-    snprintf(msg, sizeof(msg), "[%s] Door in an odd state-forcing close.", pname);
-    Serial.println(msg);
-    client.publish(log_topic, msg);
+    static unsigned long lastReport = 0;
+    if (millis() - lastReport > 3000 || doorstate != lastdoorstate) {
+      lastReport = millis();
+      char msg[256];
+      snprintf(msg, sizeof(msg), "[%s] Door %sin an odd state-forcing close.", pname, doorstate == lastdoorstate ? "still " : "");
+      Serial.println(msg);
+      client.publish(log_topic, msg);
+    };
     cnt_fails ++;
   }

   {
     static unsigned long tock = 0;
     if (millis() - tock > REPORTING_PERIOD) {
-      cnt_minutes += ((millis() - tock) + 500) / 1000 / 60;
+      static unsigned long last_min = 0;
+      unsigned long delta = millis() - last_min;
+      unsigned int mins = delta / 60 / 1000;
+      if (mins > 0) {
+        cnt_minutes += mins;
+        last_min += mins * 60 * 1000;
+      }
       reportStats();
       tock = millis();
     }
@@ -653,7 +738,11 @@
       client.publish(rfid_topic, pyStr.c_str());

       char msg[256];
+#ifndef LOCALMQTT
       snprintf(msg, sizeof(msg), "[%s] Tag <%s> (len=%d) swiped", pname, uidStr.c_str(), uid.size);
+#else
+      snprintf(msg, sizeof(msg), "[%s] Tag swiped", pname);
+#endif
       client.publish(log_topic, msg);
       Serial.println(msg);


revert

revert

--- d_BacpacCommands.ino
+++ d_BacpacCommands.ino
@@ -204,7 +204,7 @@
     break;
   case SET_CAMERA_3D_SYNCHRONIZE:
     // Master shutter button depressed
-    if (!isMaster) { // send to slaves
+    if (1) { // send to slaves
       Serial.print("SY");
       printHex(RECV(3), true);
       Serial.println("");


Read current seconds from RTC!

Read current seconds from RTC!

--- Lee_Retirement/Lee_Retirement.ino
+++ Lee_Retirement/Lee_Retirement.ino
@@ -19,6 +19,8 @@
 #include <DS1307RTC.h>
 #include <Time.h>
 #include <TimeLib.h>
+
+tmElements_t tm;

 /*
  Set up for the LCD
@@ -138,6 +140,9 @@
   // assemble second LCD line
   line2 = "inc:" + String(brightness_increment);
   secs = String(millis()/1000);
+  if(RTC.read(tm)){
+    secs = "ok!" + String(tm.Second);
+  }
   while( line2.length() < 16 - secs.length() ){
     line2 = line2 + " ";
   }


Added commments for remaining commands

Added commments for remaining commands

--- Microcontroller/teensy/teensy.ino
+++ Microcontroller/teensy/teensy.ino
@@ -51,14 +51,39 @@
 void handleUsbCommand(String value){
   switch(value.charAt(0)){
     //X = [0-9]
-    //M:angle,mag,speed
-    //M:XX.XX,X.XXX,X.XXX
+    /*
+    * Motor Command
+    * M:angle,mag,speed
+    * M:XX.XX,X.XXX,X.XXX
+    */
     case 'M':
       setMotion(value.substring(2,7), value.substring(8,13), value.substring(14));
-      Serial.println("Motor Value: "+value);
+      Serial.println(value);
       break;
+    /*
+    * Decrypt PCB (stage 1)
+    * D:
+    * prints code D:XXXXX
+    */
+    /*
+    * Output Combination (stage 3)
+    * O:code
+    * O:XXXXX
+    * prints completed message O:done
+    */
+    /*
+    * BumpMode (stage 2)
+    * B:
+    * prints completed message B:done
+    */
+    /*
+    * Gun Fire Command (stage 4)
+    * G:angle
+    * G:XXX
+    * prints completed message G:done
+    */
     default:
-      Serial.println("Invalid : "+value);
+      Serial.println("I:"+value);
       break;
   }
 }


Added color picker UI

Added color picker UI

--- HMTL_Module/HMTL_Module.ino
+++ HMTL_Module/HMTL_Module.ino
@@ -247,6 +247,8 @@
     wfb.addRESTEndpoint("/sparkle", sparkleHandler,
                         "\"description\":\"run sparkle pattern\",\"args\":[\"r\",\"g\",\"b\",\"threshold\",\"bg\",\"hum_min\",\"hue_max\",\"sat_min\",\"sat_max\",\"val_min\",\"val_max\"]");

+    wfb.addRESTEndpoint("/RGB", rgbColorPicker, "");
+
     tcpSocket.init(config.address, HMTL_PORT);
     tcpSocket.initBuffer(wifi_data_buffer, WIFI_SEND_BUFFER_SIZE);
     tcpSocket.setup();
@@ -443,6 +445,37 @@

   server->send(200, "application/json", "ok");
 }
+
+void rgbColorPicker() {
+  WebServer *server = wfb.getServer();
+
+  String data =
+          "<!DOCTYPE html>\n"
+          "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n"
+          "<link rel=\"icon\" href=\"data:,\">\n"
+          "<link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css\">\n"
+          "\n"
+          "\n"
+          "

Select color

\n"
+//          "Change Color \n"
+          "<input class=\"jscolor {onFineChange:'update(this)'}\" id=\"rgb\">
\n"
+          "\n"
+          "\n"
+          "\n";
+
+  server->send(200, "text/html", data);
+
+  DEBUG3_PRINTLN("/RGB done");
+}
+
 #endif

 void status_update() {


Added shake to main program

Added shake to main program

--- Pan_Tilt_laser/Pan_Tilt_laser.ino
+++ Pan_Tilt_laser/Pan_Tilt_laser.ino
@@ -86,6 +86,7 @@

   panTilt.updateAngles();
+  shake();

   if(random(1001) < 12){
     delay(markovPause());


Solution for arduino pro micro

Solution for arduino pro micro

--- examples/softwareserial_debug/softwareserial_debug/softwareserial_debug.ino
+++ examples/softwareserial_debug/softwareserial_debug/softwareserial_debug.ino
@@ -31,19 +31,26 @@

     canHacker = new CanHacker(interfaceStream, debugStream, SPI_CS_PIN);
-    canHacker->enableLoopback();
+    canHacker->enableLoopback(); // remove to disable loopback test mode
     lineReader = new CanHackerLineReader(canHacker);

     pinMode(INT_PIN, INPUT);
 }

 void loop() {
+    CanHacker::ERROR error;
+
     if (digitalRead(INT_PIN) == LOW) {
-        CanHacker::ERROR error = canHacker->processInterrupt();
+        error = canHacker->processInterrupt();
         handleError(error);
     }
+
+    // uncomment that lines for Leonardo, Pro Micro or Esplora
+    // error = lineReader->process();
+    // handleError(error);
 }

+// serialEvent handler not supported by Leonardo, Pro Micro and Esplora
 void serialEvent() {
     CanHacker::ERROR error = lineReader->process();
     handleError(error);


Improvements to memory management

Improvements to memory management

--- intel_curie/flash_serial_example/flash_serial_example.ino
+++ intel_curie/flash_serial_example/flash_serial_example.ino
@@ -1,35 +1,39 @@
-// Written by Jose Nunez as didactic example on pulic domain.
-// This example depends on Paul Stoffregen's SerialFlash library
-// Download at https://github.com/PaulStoffregen/SerialFlash
-
+// Escrito por José Núñez como un ejemplo didáctico para el dominio público.
+// Utiliza la librería SerialFlash de Paul Stoffregen.
+// Dicha librería se puede descargar de https://github.com/PaulStoffregen/SerialFlash
+
+//Abstracción de la librería SerialFlash para el controlador Intel Curie
 #include <CurieSerialFlash.h>
 #include <SPI.h>

-#define FSIZE 256
-#define ledPin 13
-#define buttonPin 10
-
-const char *filename = "rfidble.txt";
-#define CONTENT_SIZE 153
+#define FSIZE 256 //Tamaño predefinido del archivo
+#define ledPin 13 //PIN para un LED
+#define buttonPin 10 //PIN para leer un botón. Debe estar "pull-up" y el botón realiza una conexión a tierra.
+
+const char *filename = "rfidble.txt"; //Nombre del archivo
+#define CONTENT_SIZE 153 //Tamaño predefinido del contenido del archivo para este ejemplo.

 void setup() {
   Serial.begin(9600);
-  debugMessage("Setup() BEGIN!");
   pinMode(ledPin, OUTPUT);
   pinMode(buttonPin, INPUT);
-  parpadear (3, 1000);
-  delay(1000);// wait for Arduino Serial Monitor
+
+  parpadear (5, 1000);
+
+  debugMessage("Setup() BEGIN!");
+
   parpadear (3, 500);
-
-  // Init. SPI Flash chip
+
+  // Inicializar operación de la librería SerialFlash
   if (!SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN)) {
-    Serial.println("Unable to access SPI Flash chip");
+    debugMessage("Setup() Unable to access SPI Flash chip");
   }

   debugMessage("Setup() DONE!");
 }
-/*----------------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------------*/
+/*------*/
+/* LOOP */
+/*------*/
 bool executedOnce = false;
 bool addKeyMode = false;
 void loop() {
@@ -55,14 +59,11 @@
       executedOnce = true;
     }
   }
+
   processButtonCase();

 }

-void processDemoCase() {
-  parpadear(2, 200);
-  delay(1000);
-}
 void processButtonCase() {
   heartBeat();

@@ -74,7 +75,7 @@
     addKey("91011");
     addKey("121314");
     addKey("151617");
-    addKeyMode=false;
+    addKeyMode = false;
   }
 }

@@ -90,7 +91,6 @@
 /******************************
    INTERACTION LAYER
  ******************************/
-

 bool didResetMode = false;
 void checkButton() {
@@ -114,7 +114,6 @@

     didResetMode = false;
   }
-  //debugMessage("checkButton() END!");
 }

 /*****************************
@@ -350,7 +349,7 @@
   debugMessageNoLF("|||");
   debugMessageNoLF(result);
   debugMessageNoLF("|||");
-  Serial.println("Size:" + String(result.length()));
+  debugMessage("Size:" + String(result.length()));

   debugMessage("readFile() DONE!");
   return result;
@@ -361,23 +360,28 @@
 */
 void saveFile(String newFileContent) {
   debugMessage("saveFile() BEGIN!");
+
   removeFile();
+
   uint8_t flashBuffer[CONTENT_SIZE + 1];
   newFileContent.getBytes(flashBuffer, CONTENT_SIZE + 1);
   SerialFlashFile file;

+
   debugMessage("saveFile() Creating file if not exist...");
   // Create the file if it doesn't exist
-  if (!create_if_not_exists(filename)) {
-    Serial.println("Not enough space to create file " + String(filename));
-    digitalWrite(ledPin, HIGH);
-    return;
+  while (!create_if_not_exists(filename)) {
+    debugMessage("Memory filled up! Clearing Flash...");
+    SerialFlash.eraseAll();
+
+    while (SerialFlash.ready() == false) {
+      // wait, 30 seconds to 2 minutes for most chips
+    }
   }

   debugMessage("saveFile() Opening file for write!");
   // Open the file and write test data
   file = SerialFlash.open(filename);
-  parpadear (3, 50);

   debugMessage("saveFile() Writing into file...!");
   file.write(flashBuffer, CONTENT_SIZE + 1 );
@@ -410,10 +414,10 @@

 bool create_if_not_exists (const char *filename) {
   if (!SerialFlash.exists(filename)) {
-    Serial.println("Creating file " + String(filename));
+    debugMessage("Creating file " + String(filename));
     return SerialFlash.create(filename, FSIZE);
   }

-  Serial.println("File " + String(filename) + " already exists");
+  debugMessage("File " + String(filename) + " already exists");
   return true;
 }


minor findCylinder cleanup

minor findCylinder cleanup

--- Tests/Ping_findCylinder_factorized/Ping_findCylinder_factorized.ino
+++ Tests/Ping_findCylinder_factorized/Ping_findCylinder_factorized.ino
@@ -14,6 +14,7 @@
 const int discardCylDist = 65;
 const int horizonDist = 300;
 const int extraSwipeSteps = 3;
+const int noCylFound = -1;

 int  measurements[stepsInFullTurn];
 int  currentIndex = 0;
@@ -44,10 +45,10 @@
     noCylinder[currentIndex] = true;
   }

-  int cyl = -1;
+  int cyl = noCylFound;
   if(currentIndex >= extraSwipeSteps)
     cyl = findCylinder(currentIndex-extraSwipeSteps);
-  if(cyl != -1){
+  if(cyl != noCylFound){
     cyl += extraSwipeSteps;
     Serial.println("found cyl "+String(cyl)+" steps away");
     while(cyl--){
@@ -83,12 +84,9 @@
     int nearestIndex = getIndexMin(measurements, noCylinder, maxIndex);

     Serial.println("Nearest index found: "+String(nearestIndex));
-    if(nearestIndex == -1){
-      //return getIndexOfLargestOpenInterval();
-
-      //return -1;
-
-      //If we have checked all indicies
+    if(nearestIndex == noCylFound){
+      // No cylinder found
+      // If we have checked all indicies, move to a new location
       if(currentIndex == stepsInFullTurn-1){
         int iLargest = getIndexOfLargestOpenInterval();
         int nSteps = currentIndex - iLargest;


Update esp8266-anemometer.ino

Update esp8266-anemometer.ino

moving intervall to end

--- esp8266-anemometer.ino
+++ esp8266-anemometer.ino
@@ -54,7 +54,6 @@
   if (millis() > next_timestamp )
   {
     detachInterrupt(input_pin);
-    next_timestamp  = millis()+1000; //intervall is 1s
     float rps = i/number_reed; //computing rounds per second
     if(i == 0)
       wind = 0.0;
@@ -66,6 +65,7 @@
       Serial.println(" km/h");
     }
     i = 0;
+    next_timestamp  = millis()+1000; //intervall is 1s
     attachInterrupt(input_pin,Interrupt,RISING);
   }
 }


Improved cross compatibility

Improved cross compatibility

Finally fixed Issue #3 and improved compatibility by replacing tone(3, with HackBoy.note(


SWR calculation corrected

SWR calculation corrected

--- hal100/hal100.ino
+++ hal100/hal100.ino
@@ -106,11 +106,12 @@

 		float rfl = payload->status.adc.rfl;
 		float fwd = payload->status.adc.fwd;
-		float p = sqrt(rfl / fwd);
+//		float p = sqrt(rfl / fwd);
+    float p = (rfl / fwd);
 		valueSWR = (1 + p) / (1 - p);
 		Serial.print(", Value SWR=");
 		Serial.println(valueSWR);
-    displaySWRvalue();
+   displaySWRvalue();

 		break;
 	}


Move to the new setProperty

Move to the new setProperty

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -43,11 +43,11 @@
   */
   if (value == "ON") {
     digitalWrite(PIN_RELAY, HIGH);
-    // FIXME Homie.setNodeProperty(relayNode, "relayState", value);
+    relayNode.setProperty("relayState").send("ON");
     Serial.println("Relay is on");
   } else if (value == "OFF") {
     digitalWrite(PIN_RELAY, LOW);
-    // FIXME Homie.setNodeProperty(relayNode, "relayState", value);
+    relayNode.setProperty("relayState").send("OFF");
     Serial.println("Relay is off");
   } else {
     Serial.print("Unknown value: ");
@@ -70,16 +70,16 @@
     Serial.println("One-shot");
     if ( function == 1 ) {
       Serial.println("SINGLE click");
-      // FIXME Homie.setNodeProperty(buttonNode, "event", "SINGLE", 0);
+      buttonNode.setProperty("event").send("SINGLE");
     }

     if ( function == 2 ) {
-      // FIXME Homie.setNodeProperty(buttonNode, "event", "DOUBLE", 0);
+      buttonNode.setProperty("event").send("DOUBLE");
       Serial.println("DOUBLE click");
     }

     if ( function == 3 ) {
-      // FIXME Homie.setNodeProperty(buttonNode, "event", "TRIPLE", 0);
+      buttonNode.setProperty("event").send("TRIPLE");
       Serial.println("TRIPLE click");
     }
     // This has been a single event.
@@ -92,17 +92,17 @@
     if ( millis() - previousMillis >= waitInterval ) {
       previousMillis = millis();
       if ( function == -1 ) {
-        // FIXME Homie.setNodeProperty(buttonNode, "event", "SINGLEHELD", 0);
+        buttonNode.setProperty("event").send("SINGLEHELD");
         Serial.println("SINGLE LONG click");
       }

       if ( function == -2 ) {
-        // FIXME Homie.setNodeProperty(buttonNode, "event", "DOUBLEHELD", 0);
+        buttonNode.setProperty("event").send("DOUBLEHELD");
         Serial.println("DOUBLE LONG click");
       }

       if ( function == -3 ) {
-        // FIXME Homie.setNodeProperty(buttonNode, "event", "TRIPLEHELD", 0);
+        buttonNode.setProperty("event").send("TRIPLEHELD");
         Serial.println("TRIPLE LONG click");
       }
     }


buzzer

buzzer

--- short-circuit-limiter/short-circuit-limiter.ino
+++ short-circuit-limiter/short-circuit-limiter.ino
@@ -8,9 +8,14 @@
 #define PIN_CT A0
 #define PIN_BUTTON_ENTER 24
 #define PIN_TEMP A11
+#define PIN_BUZZER 4

 #define PIN_RELAY_MCB 5
 #define PIN_RELAY_LIMITER 7
+
+#define BUZZER_BEEP_ON_TIME 20
+#define BUZZER_BEEP_OFF_TIME 300
+#define BUZZER_LONG_BEEP_TIME 500

 #define CT_CALIBRATION_VALUE 60.6  // (100A / 0.05A) / 33 ohms
 #define INITIAL_SETTLE_TIME 15000 //15 seconds
@@ -47,6 +52,8 @@
 void setup() {

   pinMode(PIN_LED, OUTPUT);
+  pinMode(PIN_BUZZER, OUTPUT);
+
   pinMode(PIN_RELAY_LIMITER, OUTPUT);
   pinMode(PIN_RELAY_MCB, OUTPUT);
   pinMode(PIN_BUTTON_ENTER, INPUT);
@@ -108,7 +115,7 @@
 void loop() {

   double currentValue = getCurrentMeasurement();
-
+
   if(currentValue >= CURRENT_MCB_CUT){
     nextState = enterMCBTrippedMode(currentValue);
   }
@@ -183,6 +190,8 @@
     mcbTrippedCurrent = currentValue;
     Serial.print("MCB tripped at: ");
     Serial.println(mcbTrippedCurrent);
+    longBeep();
+
   }

   int buttonPressed = digitalRead(PIN_BUTTON_ENTER);
@@ -202,6 +211,7 @@

     currentState = STATE_WINDOW_BEFORE;
     Serial.println("Window Before");
+    shortBeepXTimes(2);
   }

@@ -236,6 +246,7 @@
   if(currentState != STATE_WINDOW_EXITED){
     currentState = STATE_WINDOW_EXITED;
     Serial.println("Exited window, bypass resistor");
+    shortBeepXTimes(1);
   }

   passFullCurrentThrough(true);
@@ -298,3 +309,19 @@
   return temperatureC;
 }

+void shortBeepXTimes(int times){
+  for(int i = 0; i < times; i++){
+    digitalWrite(PIN_BUZZER, HIGH);
+    delay(BUZZER_BEEP_ON_TIME);
+    digitalWrite(PIN_BUZZER, LOW);
+    delay(BUZZER_BEEP_OFF_TIME);
+  }
+
+}
+
+void longBeep(){
+  digitalWrite(PIN_BUZZER, HIGH);
+  delay(BUZZER_LONG_BEEP_TIME);
+  digitalWrite(PIN_BUZZER, LOW);
+}
+


Fixed signed return value from VWI::Receiver::recv().

--- examples/VWI/CosaVWIreceiver/CosaVWIreceiver.ino
+++ examples/VWI/CosaVWIreceiver/CosaVWIreceiver.ino
@@ -70,7 +70,7 @@
   static uint32_t cnt = 0;

   char buf[VWI::MESSAGE_MAX];
-  uint8_t buflen = VWI::MESSAGE_MAX;
+  int8_t buflen = VWI::MESSAGE_MAX;

   // Receive message and print contents
   rx.await();


improved MatrixClock3 (better auto-centering, more possibilities to change display parameters, automatic calculation of 'passive segment' effect colours)

--- examples/MatrixClock3/MatrixClock3.ino
+++ examples/MatrixClock3/MatrixClock3.ino
@@ -1,5 +1,5 @@
 /*
- * This clock example uses the RTC from a Teensy3 (Teensy 3.0 or 3.1).
+ * This clock example uses the RTC of a Teensy3 (Teensy 3.0 or 3.1).
  *
  * RTC clock is set in response to serial port time message
  * A Processing example sketch to set the time is included in the download
@@ -21,31 +21,55 @@

 //#define DEBUG_SERIAL

-rgb24 bgCol        = {0x00, 0x00, 0x00};  // background colour
-
-rgb24 timeCol      = {0x2f, 0x2f, 0xff};  // time: segment colour
-rgb24 timeColFx    = {0x00, 0x00, 0x1f};  // time: colour of 'non active segment' effect
-rgb24 dateCol      = {0x00, 0x00, 0x9f};  // date: segment colour
-rgb24 dateColFx    = {0x00, 0x00, 0x15};  // date: colour of 'non active segment' effect
-
-// values for a 96x64 display; need to be adjusted for other resolutions
-int timeSegT       = 4;  // time: thickness of a segment (in pixel)
-int timeSegW       = 17; // time: length of a single segment (in pixel)
-int dateSegT       = 2;  // date: thickness of a segment
-int dateSegW       = 7;  // date: length of a single segment
-
-const int showSecs = 2;  // display seconds: 0: no, 1: yes, 2: no seconds, but blinking dots
-const int showYear = 0;  // show year: 0 no, 1: yes
-
-
-
+rgb24   bgCol       = {0x00, 0x00, 0x00};  // background colour
+
+rgb24   timeCol     = {0x98, 0x40, 0xa4};  // time: segment colour
+rgb24   dateCol     = {0x00, 0x00, 0x9f};  // date: segment colour
+//rgb24   timeCol     = {0x2f, 0x2f, 0xff};  // time: segment colour
+//rgb24   dateCol     = {0x00, 0x00, 0x9f};  // date: segment colour
+
+uint8_t showSecs    = 2;                   // display seconds: 0: no, 1: yes, 2: no seconds, but blinking dots
+uint8_t showYear    = 0;                   // show year: 0 no, 1: yes
+
+
+
+uint8_t timeColPerc = 10;                  // time: brightness of 'passive segment' effect in percent
+uint8_t dateColPerc = 10;                  // date: brightness of 'passive segment' effect in percent
+
+
+uint8_t timeSegT    = 4;                   // time: thickness of a segment (in pixel), reduce for smaller displays
+uint8_t dateSegT    = 3;                   // date: thickness of a segment (in pixel), reduce for smaller displays
+
+uint8_t timeStartX  = 0xFF;                // x start position of time segments, 0xFF: auto center time
+uint8_t timeStartY  = timeSegT;            // y start position of time segments
+uint8_t timeMaxH    = 30;                  // maximal height of time segments, reduce for smaller displays
+
+uint8_t dateStartX  = 0xFF;                // x start position of date segments, 0xFF: auto center date segments horizontally
+uint8_t dateStartY  = 0xFF;                // y start position of date segments, 0xFF: auto center date segments vertically
+uint8_t dateMaxH    = 20;                  // maximal height of date segments, reduce for smaller displays
+
+
+
+// values not to be changed
 SmartMatrix matrix;

-const int timeSegH = timeSegW * 2 - timeSegT;
-const int dateSegH = dateSegW * 2 - dateSegT;
-
-byte currSec = 60;
-
+byte    currSec    = 60;
+
+uint8_t w          = 0;
+uint8_t h          = 0;
+uint8_t timeSegW   = 0;
+uint8_t dateSegW   = 0;
+
+uint8_t timeSegH   = 0;
+uint8_t dateSegH   = 0;
+
+uint8_t timeW      = 0;
+uint8_t dateW      = 0;
+
+uint8_t colonPos   = 0;
+
+rgb24 timeColFx;  // time: calculated colour of 'non active segment' effect
+rgb24 dateColFx;  // date: calculated colour of 'non active segment' effect

 void setup() {
   // set the Time library to use Teensy 3.x's RTC to keep time
@@ -61,6 +85,45 @@

   // setup matrix
   matrix.begin();
+
+  w = matrix.getScreenWidth();
+  h = matrix.getScreenHeight();
+
+  // out-of-bound checks
+  if (timeColPerc > 100) timeColPerc = 100;
+  if (dateColPerc > 100) dateColPerc = 100;
+  if (showSecs > 2) showSecs = 2;
+  if (showYear > 1) showYear = 1;
+
+  // calculate passive segment colours
+  timeColFx.red   = (uint8_t)((uint16_t)timeCol.red   * timeColPerc / 100);
+  timeColFx.green = (uint8_t)((uint16_t)timeCol.green * timeColPerc / 100);
+  timeColFx.blue  = (uint8_t)((uint16_t)timeCol.blue  * timeColPerc / 100);
+  dateColFx.red   = (uint8_t)((uint16_t)dateCol.red   * dateColPerc / 100);
+  dateColFx.green = (uint8_t)((uint16_t)dateCol.green * dateColPerc / 100);
+  dateColFx.blue  = (uint8_t)((uint16_t)dateCol.blue  * dateColPerc / 100);
+
+
+  // calculate width and height of segments
+  if (timeMaxH == 0 && timeStartX == 0xFF) { // auto width and auto center
+    timeSegW = ( w - ((showSecs == 1) ? 9 : 5) * timeSegT ) / ((showSecs == 1) ? 6 : 4);
+  } else {
+    timeSegW = (timeMaxH + timeSegT) / 2;
+  }
+  timeW    = timeSegW * ((showSecs == 1) ? 6 : 4) + timeSegT * ( (showSecs == 1) ? 9 : 5);
+  timeSegH = timeSegW * 2 - timeSegT;
+
+  if (dateMaxH == 0 && dateStartX == 0xFF) { // auto width and auto center
+    dateSegW = ( w - ((showYear == 1) ? 9 : 4) * dateSegT ) / ((showYear == 1) ? 10 : 5);
+  } else {
+    dateSegW = (dateMaxH + dateSegT) / 2;
+  }
+
+  dateW = dateSegW * ((showYear == 1) ? 10 : 5) + dateSegT * ( (showYear == 1) ? 9 : 4);
+  dateSegH = dateSegW * 2 - dateSegT;
+
+  // y-offset of 2 colon points
+  colonPos = (timeSegH - 2* timeSegT ) / 3;
 }

 void loop() {
@@ -70,11 +133,8 @@
     setTime(t);
   }

-  int x;
-  int y;
-
-  int timeW = timeSegW * ((showSecs == 1) ? 6 : 4) + timeSegT * ( (showSecs == 1) ? 9 : 5); // calc. width of time output
-  int dateW = (dateSegW + dateSegT) * ((showYear) ? 10 : 5) + dateSegT; // calc. width of date output
+  uint8_t x;
+  uint8_t y;

   int tSec = second();
   int tMin = minute();
@@ -106,34 +166,47 @@
     Serial.println();
 #endif

-    // center time
-    x = ( matrix.getScreenWidth() - timeW ) / 2;
-    y = timeSegT;
+    // start position of time segments
+    if (timeStartX == 0xFF) { // auto center
+      x = ( w - timeW ) / 2;
+    } else {
+      x = timeStartX;
+    }
+
+    y = timeStartY;

     x += drawNumber(x, y, tHour, timeSegW, timeSegT, 2, timeCol, timeColFx);
     x += timeSegT;
     if (showSecs != 2 || (tSec % 2) ) {
-      drawBar(x, y + (timeSegT * 2) - 1, timeSegT, timeSegT, 0, timeCol);
-      drawBar(x, y + (timeSegH - (timeSegT * 2)) - 1, timeSegT, timeSegT, 0, timeCol);
-    } else {
-      drawBar(x, y + (timeSegT * 2) - 1, timeSegT, timeSegT, 0, timeColFx);
-      drawBar(x, y + (timeSegH - (timeSegT * 2)) - 1, timeSegT, timeSegT, 0, timeColFx);
+      drawBar(x, y + colonPos, timeSegT, timeSegT, 0, timeCol);
+      drawBar(x, y + timeSegH - timeSegT - colonPos, timeSegT, timeSegT, 0, timeCol);
+    } else {
+      drawBar(x, y + colonPos, timeSegT, timeSegT, 0, timeColFx);
+      drawBar(x, y + timeSegH - timeSegT - colonPos, timeSegT, timeSegT, 0, timeColFx);
     }
     x += timeSegT * 2;
     x += drawNumber(x, y, tMin, timeSegW, timeSegT, 2, timeCol, timeColFx);
     if (showSecs == 1) {
       x += timeSegT;
-      drawBar(x, y + (timeSegT * 2) - 1, timeSegT, timeSegT, 0, timeCol);
-      drawBar(x, y + (timeSegH - (timeSegT * 2)) - 1, timeSegT, timeSegT, 0, timeCol);
+      drawBar(x, y + colonPos, timeSegT, timeSegT, 0, timeCol);
+      drawBar(x, y + timeSegH - timeSegT - colonPos, timeSegT, timeSegT, 0, timeCol);
       x += timeSegT * 2;
       x += drawNumber(x, y, tSec, timeSegW, timeSegT, 2, timeCol, timeColFx);
     }
-    y += timeSegH + timeSegT;
-
-
-    // center date
-    x = (matrix.getScreenWidth() - dateW) / 2;
-    y += (matrix.getScreenHeight() - y - dateSegH) / 2;
+    y += timeSegH;
+
+    // start position of time segments
+    if (dateStartX == 0xFF) { // auto center
+      x = ( w - dateW ) / 2;
+    } else {
+      x = dateStartX;
+    }
+
+    if (dateStartY == 0xFF) { // auto place
+      y += (h - y - dateSegH) / 2;
+    } else {
+      y = dateStartY;
+    }

     if (showYear) {
       x += drawNumber(x, y, tYear, dateSegW, dateSegT, 4, dateCol, dateColFx);


add servo_ud

add servo_ud

--- servo/servo.ino
+++ servo/servo.ino
@@ -4,9 +4,31 @@
 Servo servo_under2;
 Servo servo_ud;

+bool servo_ud_flag = 0;
+int servo_ud_max = 90, servo_ud_min = 10;
+
+
+int servo_ud_fun(int servo_ud_now)
+{
+    if(servo_ud_now == servo_ud_max)
+        servo_ud_flag = 1;
+    if(servo_ud_now == servo_ud_min)
+        servo_ud_flag = 0;
+
+    if(servo_ud_flag)
+    {
+        servo_ud_now -= 1;
+    }
+    else
+    {
+        servo_ud_now += 1;
+    }
+    return servo_ud_now;
+}

 void setup()
 {
+    Serial.begin(9600);
     servo_under1.attach(9);
     servo_under2.attach(10);
     servo_ud.attach(11);
@@ -21,8 +43,8 @@

 void loop()
 {
-

+    int servo_ud_now = 90;
     //*以角度控制
     for(int i = 10;i <= 170;i++)
     {
@@ -30,6 +52,8 @@
         delay(20);
         servo_under2.write(i);
         delay(100);
+        servo_ud_now = servo_ud_fun(servo_ud_now);
+        servo_ud.write(servo_ud_now);
     }

     for(int i = 170;i >= 10;i--)
@@ -38,6 +62,8 @@
         delay(20);
         servo_under2.write(i);
         delay(100);
+        servo_ud_now = servo_ud_fun(servo_ud_now);
+        servo_ud.write(servo_ud_now);
     }

     /*


Update revision number

Update revision number

--- tests/LpgSerial/LpgSerial.ino
+++ tests/LpgSerial/LpgSerial.ino
@@ -10,6 +10,12 @@
 unsigned long serial2Timing;
 //char dataBuff[] = {};
 uint32_t dataBuff = 0;
+
+
+ISR(USART2_RX_vect){ // or USART1_RX_vect
+
+}
+

 void captureCommunication() {


Misc sensor changes.

Misc sensor changes.

--- arduino_sensor/arduino_sensor.ino
+++ arduino_sensor/arduino_sensor.ino
@@ -13,26 +13,44 @@
 #include "LowPower.h"
 #include "DallasTemperature.h"

-#define P5
+
+#define PS02

 //************* Node ID Setup ****************/
-#ifdef P5
-char id[] = "P5";
-char location_string[] = "50.93897,-1.39774";
-#define BATTV_FUDGE 0.943
+#ifdef PS00
+char id[] = "PS00";
+char location_string[] = "50.93891,-1.39774";
+#define BATTV_FUDGE 1.109
+#define BEACON_INTERVAL 15
+uint8_t rfm_power = 10; // dBmW
+byte num_repeats = '0'; //The number of hops the message will make before stopping
 #endif
-#define BEACON_INTERVAL 7
-uint8_t rfm_power = 20; // dBmW
+
+#ifdef PS01
+char id[] = "PS01";
+char location_string[] = "50.93898,-1.39762";
+#define BATTV_FUDGE 1.109
+#define BEACON_INTERVAL 15
+uint8_t rfm_power = 10; // dBmW
+byte num_repeats = '0'; //The number of hops the message will make before stopping
+#endif
+
+#ifdef PS02
+char id[] = "PS02";
+char location_string[] = "50.93877,-1.3979";
+#define BATTV_FUDGE 1.109
+#define BEACON_INTERVAL 15
+uint8_t rfm_power = 10; // dBmW
+byte num_repeats = '0'; //The number of hops the message will make before stopping
+#endif

 //************* 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 1.109
-DeviceAddress ds_addr;

 //************* Misc Setup ****************/
-byte num_repeats = '3'; //The number of hops the message will make before stopping
+DeviceAddress ds_addr;
 float battV=0.0;
 uint8_t n;
 uint32_t count = 1, data_interval = 10;


change the baud rate to 38400

change the baud rate to 38400

--- keypad/keypad.ino
+++ keypad/keypad.ino
@@ -210,8 +210,8 @@
   Serial.println("Arduino with HC-06 is ready");

   // HC-06 default baud rate is 9600
-  BTSerial.begin(9600);
-  Serial.println("BTserial started at 9600");
+  BTSerial.begin(38400);
+  Serial.println("BTserial started at 38400");
   ///////////////////////////////////////////////// END BLUETOOTH
 }


Modified MessageDisplay example

Modified MessageDisplay example

--- examples/ESP8266/MessageDisplay/MessageDisplay.ino
+++ examples/ESP8266/MessageDisplay/MessageDisplay.ino
@@ -1,3 +1,19 @@
+/*
+  MessageDisplay by Meeo
+
+  This example will make use of Meeo. If you haven't already,
+  visit Meeo at https://meeo.io and create an account. Then
+  check how to get started with the Meeo library through
+  https://github.com/meeo/meeo-arduino
+
+
+  Send remote message and display it on a small OLED.
+  More details of the project here: https://meeo.io/l/1001
+
+  Copyright: Meeo
+  Author: Terence Anton Dela Fuente
+  License: MIT
+*/
 #include <Meeo.h>
 #include <SH1106.h>

@@ -5,7 +21,7 @@
 String accessKey = "my_access_key";
 String ssid = "MyWiFi";
 String pass = "qwerty123";
-String channel = "my-channel";
+String channel = "message-display";

 SH1106 display(0x3c, 14, 12);

@@ -32,6 +48,7 @@
   Serial.println(payload);

   if (Meeo.isChannelMatched(topic, channel)) {
+    // Show the message on a small OLED
     display.clear();
     display.drawString(64, 24, payload.c_str());
     display.display();
@@ -54,6 +71,8 @@
       break;
     case MQ_CONNECTED:
       Serial.println("Connected to MQTT Server");
+
+      //Once connected, subscribe to the channel
       Meeo.subscribe(channel);
       break;
     case MQ_BAD_CREDENTIALS:


fix typo

fix typo

--- examples/ReadUidMultiReader/ReadUidMultiReader.ino
+++ examples/ReadUidMultiReader/ReadUidMultiReader.ino
@@ -31,8 +31,8 @@
 #include <MFRC522.h>

 #define RST_PIN         9          // Configurable, see typical pin layout above
-#define SS_1_PIN        10         // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
-#define SS_2_PIN        8          // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1
+#define SS_1_PIN        10         // Configurable, take a unused pin, only HIGH/LOW required, must be different to SS 2
+#define SS_2_PIN        8          // Configurable, take a unused pin, only HIGH/LOW required, must be different to SS 1

 #define NR_OF_READERS   2


Custom team mappings in buttons

Custom team mappings in buttons

--- battlestation/arduino/arduino.ino
+++ battlestation/arduino/arduino.ino
@@ -30,6 +30,7 @@
 #define TARGET_DIGIT_LEDS 15
 static byte target_pin = 3;
 static Adafruit_NeoPixel target_strip(TARGET_STRIP_LEDS, target_pin, NEO_GRB + NEO_KHZ800);
+static byte target_teams_start[3] = {30, 15, 0};

 static boolean digit_1[TARGET_DIGIT_LEDS] = {1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
 static boolean digit_2[TARGET_DIGIT_LEDS] = {1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1};
@@ -233,7 +234,7 @@
   }

   // Find the offset for the team's LED matrix
-  byte start_led = team * TARGET_DIGIT_LEDS;
+  byte start_led = target_teams_start[team];
   for (int i = 0; i < TARGET_DIGIT_LEDS; i++) {
     byte * digit;
     switch (territory) {


bug fix in singlecam example

bug fix in singlecam example

the singlecam example would fail is camsetup didn't work the first time.
added checks to have the camera auto initalize

--- UCAM/examples/SingleCamera/SingleCamera.ino
+++ UCAM/examples/SingleCamera/SingleCamera.ino
@@ -8,6 +8,7 @@
 #include <uCam.h>

 uCam cam1;
+boolean camSetUp;

 void setup()
 {
@@ -16,19 +17,32 @@
   pinMode(12, OUTPUT);
   pinMode(13, OUTPUT);
   cam1.begin(&Serial1, &Serial);
+  camSetUp = false;
+}
+
+boolean setUpCam()
+{
+    if (cam1.SYNC() ==0)
+    {
+      digitalWrite(12,HIGH);
+    } else {;
+      cam1.RESET();
+      return false;
+    }
+    cam1.INIT(&UCAM_8BIT_GREY,&UCAM_80X60);
+    return true;
 }

 void loop()
 {
-  delay(5000);
-  if (cam1.SYNC() ==0){
-	digitalWrite(13, HIGH);
+  if (!camSetUp)
+  {
+    delay(1);
+    camSetUp = setUpCam();
   } else {
-	digitalWrite(12, HIGH);
+    cam1.SNAPSHOT();
+    cam1.GET();
+    delay  (100000);
+    return;
   }
-  cam1.INIT(&UCAM_8BIT_GREY,&UCAM_80X60);
-  cam1.SNAPSHOT();
-  cam1.GET();
-  delay  (100000);
-  return;
 }


changes

changes

--- XBee_rob_function_2.0/xBee_2.0/xBee_2.0.ino
+++ XBee_rob_function_2.0/xBee_2.0/xBee_2.0.ino
@@ -131,13 +131,11 @@
     }
 while(joint = 4 && y > 700 && o==0){
     Dynamixel.gripper(OPEN);
-    Dynamixel.setNGoalPositions(-1, -1, k, -1, -1);
     o++;
     break;
 }
 while(joint = 4 && y < 300 && o==0){
     Dynamixel.gripper(CLOSE);
-    Dynamixel.setNGoalPositions(-1, -1, k, -1, -1);
     o++;
     break;
 }


Add interval between sensor data reads

Add interval between sensor data reads

--- arduinoApp/gardenSketch/gardenSketch.ino
+++ arduinoApp/gardenSketch/gardenSketch.ino
@@ -28,6 +28,10 @@
 // activity led setup
 int ledPin = 13; // this is just for checking activity

+// setup sensor reading interval
+unsigned long prevMillis = 0;
+unsigned long interval = 1000;
+
 // Initialize settings
 void setup() {
   // Initialize output pins.
@@ -42,12 +46,19 @@

 // Main loop
 void loop() {
-  // Read sensor values
-  LDRValue = analogRead(lightSensorPin); // read light level from LDR
-  airHumidity = airSensor.readHumidity(); // read humidity from DHT
-  airTemperature = airSensor.readTemperature(); // read temperature from DHT
-  soilHumidity = sht1x.readHumidity(); // read temperature from SHT10
-  soilTemperature = sht1x.readTemperatureC(); // read humidity from SHT10
+  unsigned long curMillis = millis();
+
+  // only read values every 1000 milliseconds
+  if(curMillis - prevMillis > interval) {
+    prevMillis = curMillis;
+
+    // Read sensor values
+    LDRValue = analogRead(lightSensorPin); // read light level from LDR
+    airHumidity = airSensor.readHumidity(); // read humidity from DHT
+    airTemperature = airSensor.readTemperature(); // read temperature from DHT
+    soilHumidity = sht1x.readHumidity(); // read temperature from SHT10
+    soilTemperature = sht1x.readTemperatureC(); // read humidity from SHT10
+  }

 }


Update arduino/OpenROV/OpenROV.ino

Update arduino/OpenROV/OpenROV.ino

add sensor support for cape current - iout

--- arduino/OpenROV/OpenROV.ino
+++ arduino/OpenROV/OpenROV.ino
@@ -8,6 +8,7 @@
 Motors motors(9, 10, 11);
 Command cmd;
 Device vout("vout", 0, vout.analog, vout.in);
+Device iout("iout", 3, iout.analog, iout.in);
 Device light("light", 5, light.analog, light.out);
 Timer time;

@@ -61,9 +62,10 @@
     }
   }

-  // send voltage
+  // send voltage and current
   if (time.elapsed(1000)) {
     vout.send(vout.read());
+    iout.send(iout.read());
     Serial.print("time:");
     Serial.println(millis());
   }


Numbers changed

Numbers changed

--- Kirbi/testing/gucci_motor_testing/gucci_motor_testing.ino
+++ Kirbi/testing/gucci_motor_testing/gucci_motor_testing.ino
@@ -13,18 +13,18 @@

 void setup() {
   // put your setup code here, to run once:
-  ESC_L_SERIAL.begin(115200);
-  ESC_L_SERIAL.setRX(27);
-  ESC_L_SERIAL.setTX(26);
+  ESC_R_SERIAL.begin(115200);
+  ESC_R_SERIAL.setRX(7);
+  ESC_R_SERIAL.setTX(8);
   pinMode(A19, INPUT);
   attachInterrupt(A19, encoderISR, RISING);
 }

 void loop() {
   uint8_t bytes[3];
-  bytes[0] = ESC_L_ADDRESS;
+  bytes[0] = ESC_R_ADDRESS;
   bytes[1] = 0; //0 is drive forward
-  bytes[2] = 20; //drive motor at half speed
+  bytes[2] = 63; //drive motor at half speed
   uint32_t crc = 0;
   for(int i = 0; i < 3; i++) {
     crc = crc ^ (bytes[i] << 8);
@@ -36,11 +36,11 @@
       }
     }
   }
-  ESC_L_SERIAL.write(bytes[0]);
-  ESC_L_SERIAL.write(bytes[1]);
-  ESC_L_SERIAL.write(bytes[2]);
-  ESC_L_SERIAL.write(((crc >> 8) & 0xFF));
-  ESC_L_SERIAL.write((crc & 0xFF));
+  ESC_R_SERIAL.write(bytes[0]);
+  ESC_R_SERIAL.write(bytes[1]);
+  ESC_R_SERIAL.write(bytes[2]);
+  ESC_R_SERIAL.write(((crc >> 8) & 0xFF));
+  ESC_R_SERIAL.write((crc & 0xFF));
   Serial.println(counter);
   delay(100);
 }


license

license

--- dev/test/nullRadioTest/nullRadioTest.ino
+++ dev/test/nullRadioTest/nullRadioTest.ino
@@ -1,3 +1,21 @@
+/*
+The OpenTRV project licenses this file to you
+under the Apache Licence, Version 2.0 (the "Licence");
+you may not use this file except in compliance
+with the Licence. You may obtain a copy of the Licence at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the Licence is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the Licence for the
+specific language governing permissions and limitations
+under the Licence.
+
+Author(s) / Copyright (s): Deniz Erbilgin 2015
+*/
+
 #include <SoftwareSerial.h>
 #include <OTRadioLink.h>
 #include <OTNullRadioLink.h>


Uncoded example, actually not very usefull


update Bluetooth Sensor Combo so that it prints out values over bluetooth again.

--- Arduino/Bluetooth_Sensor_combo/Bluetooth_Sensor_combo.ino
+++ Arduino/Bluetooth_Sensor_combo/Bluetooth_Sensor_combo.ino
@@ -594,7 +594,7 @@
              //float new_y_val = computeComplementaryFilter = (y_val, acc_y_val, GyroPercentage);
              //float new_z_val = computeComplementaryFilter = (z_val, acc_z_val, GyroPercentage);

-            //blueToothSerial.println(String(x_val) + "," + String(y_val) + "," + String(z_val));  //Yaw, Pitch and Roll values
+            blueToothSerial.println(String(x_val) + "," + String(y_val) + "," + String(z_val));  //Yaw, Pitch and Roll values

              //blueToothSerial.println(String(x_val) + "," + String(y_val) + "," + String(z_val) + "," + String (acc_x_val) + "," + String (acc_y_val) +"," + String (acc_z_val));  //Yaw, Pitch and Roll values and acc values


Minor comment block change

Minor comment block change

--- examples/ds1305example/ds1305example.ino
+++ examples/ds1305example/ds1305example.ino
@@ -1,5 +1,5 @@
 /*
- * File                 ds1305test.ino
+ * File                 ds1305example.ino
  *
  * Synopsis             Example Sketch for DS1305 library
  *


typo in getBatteryVoltage

typo in getBatteryVoltage

--- controller/controller.ino
+++ controller/controller.ino
@@ -41,7 +41,7 @@

 float getBatteryVoltage() {
-  return batteryVoltage = 5.0 * analogRead(BATTERY_READ_PIN) / 1024.0;
+  return 5.0 * analogRead(BATTERY_READ_PIN) / 1024.0;
 }

 void cmd_vel_callback( const geometry_msgs::Twist& twist_msg) {


Added a 'ready' cue to the Typeatron

Added a 'ready' cue to the Typeatron

--- typeatron/src/main/arduino/typeatron/typeatron.ino
+++ typeatron/src/main/arduino/typeatron/typeatron.ino
@@ -36,6 +36,7 @@
 const char *EXO_TT_PHOTO_GET     = "/exo/tt/photo/get";
 const char *EXO_TT_PING          = "/exo/tt/ping";
 const char *EXO_TT_PING_REPLY    = "/exo/tt/ping/reply";
+const char *EXO_TT_READY         = "/exo/tt/ready";
 const char *EXO_TT_RGB_SET       = "/exo/tt/rgb/set";
 const char *EXO_TT_VIBRO         = "/exo/tt/vibro";
 const char *EXO_TT_WARNING       = "/exo/tt/warning";
@@ -51,6 +52,7 @@
 const unsigned long errorCueHapticDurationMs = 100;
 const unsigned long errorCueVisualDurationMs = 200;
 const unsigned long okCueVisualDurationMs = 100;
+const unsigned long readyCueVisualDurationMs = 10000;
 const unsigned long warningCueHapticDurationMs = 100;
 const unsigned long warningCueVisualDurationMs = 200;

@@ -124,6 +126,12 @@
     rgbled.replaceColor(RGB_BLUE);
     ledCueLength = infoCueVisualDurationMs;
     ledCueSince = millis();
+}
+
+void readyCue() {
+    rgbled.replaceColor(RGB_WHITE);
+    ledCueLength = readyCueVisualDurationMs;
+    ledCueSince = millis();
 }

 void warningCue() {
@@ -280,6 +288,7 @@
         || bundle.dispatch(EXO_TT_OK, handleOkMessage)
         || bundle.dispatch(EXO_TT_PHOTO_GET, handlePhotoGetMessage)
         || bundle.dispatch(EXO_TT_PING, handlePingMessage)
+        || bundle.dispatch(EXO_TT_READY, handleReadyMessage)
         || bundle.dispatch(EXO_TT_RGB_SET, handleRGBSetMessage)
         || bundle.dispatch(EXO_TT_VIBRO, handleVibroMessage)
         || bundle.dispatch(EXO_TT_WARNING, handleWarningMessage)
@@ -344,6 +353,10 @@

 void handlePingMessage(class OSCMessage &m) {
     sendPingReply();
+}
+
+void handleReadyMessage(class OSCMessage &m) {
+    readyCue();
 }

 void handleRGBSetMessage(class OSCMessage &m) {


Update dragino_lcd20x4.ino

Update dragino_lcd20x4.ino

--- dragino/dragino_lcd20x4.ino
+++ dragino/dragino_lcd20x4.ino
@@ -5,8 +5,9 @@
 #pines LCD RS pin to digital pin 10, LCD Enable pin to digital pin 9, LCD D4 pin to digital pin 6,
 #LCD D5 pin to digital pin 4, LCD D6 pin to digital pin 3, LCD D7 pin to digital pin 2
 #la representacion de temperatura y humedad en el display LCD es en 4 filas, las filas que se muestran en este display
-#son los datos que provienen desde el broker en el topico test/temp que en este caso seria el mismo topico donde
-#se publican.
+#son los datos que provienen desde el broker en el topico test/temp, para efectos de prueba en este sketch se ha
+#utilizado el mismo topico de publicacion y subscripcion, pero puede ser modificado si se requiere representar
+#en el display otros datos, solo hay que filtrar el string mediante el id del sensor.

 #include <Process.h>
 #include "MQTTclient.h"


Added prototypes

Added prototypes

--- libraries/SimplelinkWifi/examples/simpleWebServer/simpleWebServer.ino
+++ libraries/SimplelinkWifi/examples/simpleWebServer/simpleWebServer.ino
@@ -22,6 +22,12 @@

 #include "SPI.h"
 #include "WiFi.h"
+
+// Prototypes
+void printConfig();
+void printWifiData();
+void printIndex();
+void printHelp();

 char ssid[] = WLAN_SSID;     //  your network SSID (name)
 char pass[] = WLAN_PASS;     //  your network SSID (name)


Add functionality for ?

Add functionality for ?

--- Arduino/Arduino.ino
+++ Arduino/Arduino.ino
@@ -30,7 +30,7 @@
 } sensor;

 // DO need to change the next two things:
-#define I2C_ADDRESS 42 // must be between 8-120. Make sure this is different to other devices you connect!
+#define I2C_ADDRESS 42 // must be between 8 and 119. Make sure this is different to other devices you connect!

 /* To add a new sensor:
  * 1. Uncomment a line below, i.e. remove the // before it. Otherwise the line is ignored.
@@ -46,6 +46,7 @@
  */
 sensor sensors[] = {
                       {"SENSOR1", &sensorVal1},
+                      //{"SENSOR2", &sensorVal1},
                       //{"SENSOR2", &sensorVal2},
                       //{"SENSOR3", &sensorVal3},
                       //{"SENSOR4", &sensorVal4},
@@ -89,6 +90,11 @@
 {
   if (!responseStr)
   {
+    /* There will be problems using I2C if we don't respond within a fixed period of time
+     * so send a zero, which we program the master to ignore. This makes sure we have
+     * enough time to do some computation. */
+    Wire.write(0);
+
     float responseNum;

     for (int i = 0; i < LENGTH(sensors); i++)
@@ -104,7 +110,11 @@
       }
     }
     if (!responseStr) { // no match
-      if (strcmp(request, "TEST") == 0) {
+      if (strcmp(request, "?") == 0)
+      {
+        responseStr = sensorList;
+      }
+      else if (strcmp(request, "TEST") == 0) {
         responseStr = "HELLO";
       }
       else
@@ -112,25 +122,19 @@
         responseStr = "ERR";
       }
     }
-
-    if (strcmp(request, "TEST") == 0) {
-      responseStr = "HELLO";
-    } else {
-      responseStr = "ERR";
-    }

-    Serial.print("Received ");
+    Serial.print("Read ");
     Serial.println(request);
     posIn = posOut = 0;
     request[0] = 0;
-
-    Wire.write(0);
   }
   else
   {
-    if (responseStr[posOut] != '\0') {
+    if (responseStr[posOut] != '\0')
+    {
       Wire.write(responseStr[posOut++]);
-    } else
+    }
+    else
     {
       Wire.write("\n");
       Serial.println(responseStr);
@@ -161,7 +165,7 @@
   for (int i = 0; i < LENGTH(sensors); i++)
   {
     strcat(sensorList, sensors[i].name);
-    strcat(sensorList, "\n");
+    strcat(sensorList, "\t");
   }

   // Now call the user's code


Overheat control (screen temperature editor) Save overheat data to EEPROM

--- Led_fixture_sec.ino
+++ Led_fixture_sec.ino
@@ -174,6 +174,9 @@
 int temp_line[]={ 1, 1};
 int temp_pos[]= { 4, 13};

+int overheat_line[]={ 1, 1};
+int overheat_pos[]= { 5, 13};
+

 int cursor_pos=0; // kura pozicija atrodas kursots

@@ -182,8 +185,8 @@
 int fan_on=0; //ReadEEPROM(9);
 int fan_off=0; //ReadEEPROM(9);
 int FAN_status=0; // 0-off, 1-on
-int fan_warning=40; // heatsink temperature warning, -50% light power
-int fan_alert=50; // heatsink temperature alert, power off all LEDs
+int fan_warning=0; // heatsink temperature warning, -50% light power
+int fan_alert=0; // heatsink temperature alert, power off all LEDs

 // koordinates screen saver rezima LED knalu statusiem,
 // kad visi uzreiz uz ekr'na
@@ -251,8 +254,8 @@
   "LED A",        //1
   "LED B", //2
   "LED Moon",        //3
-  "Temperature",         //4
-  "Setup",    //5
+  "Fan Control",         //4
+  "LED Control",     //5
   "Date/Time", //6
   "Manual mode", //7

@@ -384,7 +387,7 @@
     pinMode(DIMM_pin[i], OUTPUT);
   }
   ReadEEPROM(9); // load fan temperature data
-
+  ReadEEPROM(10); // load overheat temperature data
   SetMenu();

 }
@@ -488,6 +491,27 @@
               lcd.print("Current: ");
           }

+          if (menu_mode==5) { // LED overheating  settup
+            lcd.setCursor(0, 0);
+            lcd.print(flash_txt);
+
+            temperature_mode=1;
+            cursor_pos=0;
+              // print mode screen
+              lcd.setCursor(0, 1);
+              lcd.print("50%: ");
+              lcd.print(fan_warning);
+              lcd.print((char)223);
+              lcd.setCursor(9, 1);
+              lcd.print("0%: ");
+              lcd.print(fan_alert);
+              lcd.print((char)223);
+              lcd.setCursor(1, 2);
+              lcd.print("Current: ");
+          }
+
+
+

           if (menu_mode==6) { // date/time
             lcd.setCursor(0, 0);
@@ -511,8 +535,10 @@
     } else if (menu_mode==3) {                // LED Moon settup
         cha=8;
         Dimming_big();
-    } else if (menu_mode==4) {                                 // set temperature mode
-      SetTemp();
+    } else if (menu_mode==4) {                                 // set Fan setting
+      SetTemp();
+    } else if (menu_mode==5) {                                 // set overheat temperatures
+      SetOverheat();
     } else if (menu_mode==6) {                                 // set date/time mode
       SetDateTime();
     } else if (menu_mode>=8 || menu_mode<=15) {                // individual chanel setup
@@ -572,8 +598,6 @@
 // *********************************************************************************************
 //            Manas proceduras
 // *********************************************************************************************
-
-

 // *********************************************************************************************
 //            Ekrana 2 pedeju liniju attirisana
@@ -788,7 +812,11 @@
   if (a==9){// save fan data
     EEPROM.write(81,fan_on);
     EEPROM.write(82,fan_off);
-  }
+  }
+  if (a==10){// save overheat data
+    EEPROM.write(83,fan_warning);
+    EEPROM.write(84,fan_alert);
+  }
 }

 void ReadEEPROM(int a){
@@ -807,12 +835,15 @@
     fan_on = EEPROM.read(81);
     fan_off = EEPROM.read(82);
   }
-
-
-}
-
-// *********************************************************************************************
-//            SetTemperature -  iestadisana
+  if (a==10){// load overheat settings
+    fan_warning = EEPROM.read(83);
+    fan_alert = EEPROM.read(84);
+  }
+
+}
+
+// *********************************************************************************************
+//            Set Temperature / Fan settings
 // *********************************************************************************************

 void SetTemp(){
@@ -867,6 +898,69 @@
     case 1:
       fan_off--;
       if (fan_off<22) fan_off=40;
+      break;
+    }
+  }
+
+}
+
+
+// *********************************************************************************************
+//            Set Overhear Temperature -  iestadisana
+// *********************************************************************************************
+
+void SetOverheat(){
+  flash=1;
+  switch (cursor_pos) {
+  case 0:
+    flash_txt=toDouble(fan_warning);
+    break;
+  case 1:
+    flash_txt=toDouble(fan_alert);
+    break;
+  case 2:
+    // save "Overheat"
+    SaveEEPROM(10);
+    menu_old=-1;
+    menu_mode=0;
+    lcd.clear();
+    temperature_mode=0;
+    SetMenu();
+    ShowMenu();
+    break;
+  }
+  if (cursor_pos<2) {
+    flash_line=overheat_line[cursor_pos];
+    flash_pos=overheat_pos[cursor_pos];
+    if (Button=='a') {
+      cursor_pos++;
+      lcd.setCursor(flash_pos, flash_line);
+      lcd.print(flash_txt);
+    }
+
+  }
+
+  if (qe1Move=='>') {
+    switch (cursor_pos) {
+    case 0:
+      fan_warning++;
+      if (fan_warning>70) fan_warning=22;
+      break;
+    case 1:
+      fan_alert++;
+      if (fan_alert>70) fan_alert=22;
+      break;
+    }
+  }
+  else if (qe1Move=='<') {
+    switch (cursor_pos) {
+    case 0:
+      fan_warning--;
+      if (fan_warning<22) fan_warning=70;
+      break;
+    case 1:
+      fan_alert--;
+      if (fan_alert<22) fan_alert=70;
       break;
     }
   }
@@ -1379,7 +1473,7 @@

 // *********************************************************************************************
-//            LDE kanalu Taimeru darbibas
+//            LED kanalu Taimeru darbibas
 // *********************************************************************************************

 void Watch(){


Check and display RSSI prior to transmit

--- examples/raw-feather/raw-feather.ino
+++ examples/raw-feather/raw-feather.ino
@@ -69,6 +69,7 @@
 // https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc

 #define TX_INTERVAL 2000        // milliseconds
+#define RX_RSSI_INTERVAL 100    // milliseconds

 // Pin mapping for Adafruit Feather M0 LoRa
 const lmic_pinmap lmic_pins = {
@@ -97,8 +98,19 @@

 // Transmit the given string and call the given function afterwards
 void tx(const char *str, osjobcb_t func) {
+  oslmic_radio_rssi_t rssi;
   os_radio(RADIO_RST); // Stop RX first
   delay(1); // Wait a bit, without this os_radio below asserts, apparently because the state hasn't changed yet
+
+  // if requested, scan RSSI (LBT). On a Feather, it's about 42 us/sample.
+  if (RX_RSSI_INTERVAL > 0) {
+    radio_monitor_rssi(ms2osticks(RX_RSSI_INTERVAL), &rssi);
+    Serial.print("RSSI results (dB): min: "); Serial.print(rssi.min_rssi);
+    Serial.print(" max: "); Serial.print(rssi.max_rssi);
+    Serial.print(" mean: "); Serial.print(rssi.mean_rssi);
+    Serial.print(" n: "); Serial.println(rssi.n_rssi);
+  }
+
   LMIC.dataLen = 0;
   while (*str)
     LMIC.frame[LMIC.dataLen++] = *str++;


XKeyPad ex26 cleanup, extend to int32

XKeyPad ex26 cleanup, extend to int32

--- examples/arduino/ex26_ard_calc/ex26_ard_calc.ino
+++ examples/arduino/ex26_ard_calc/ex26_ard_calc.ino
@@ -46,7 +46,7 @@
 enum { E_PG_MAIN, E_POP_KEYPAD };
 enum {
   E_BOX1, E_BTN_ADD, E_BTN_MULT, E_BTN_SUB
-  , E_TXT7, E_TXT_VAL1, E_TXT_VAL2, E_ELEM_KEYPAD
+  , E_TXT_RESULT, E_TXT_VAL1, E_TXT_VAL2, E_ELEM_KEYPAD
 };
 enum { E_FONT_SANS2, E_FONT_TXT1 };
 //<Enum !End!>
@@ -112,7 +112,7 @@
   gslc_tsGui* pGui = (gslc_tsGui*)pvGui;

   char acTxtNum[11];
-  int16_t nVal1, nVal2, nResult;
+  int32_t nVal1, nVal2, nResult;

   if (eTouch == GSLC_TOUCH_UP_IN) {
     // From the element's ID we can determine which button was pressed.
@@ -134,26 +134,26 @@
       break;
     case E_BTN_ADD:
       // Compute the sum and update the result
-      nVal1 = atoi(gslc_ElemGetTxtStr(&m_gui, m_pElemVal1));
-      nVal2 = atoi(gslc_ElemGetTxtStr(&m_gui, m_pElemVal2));
+      nVal1 = atol(gslc_ElemGetTxtStr(&m_gui, m_pElemVal1));
+      nVal2 = atol(gslc_ElemGetTxtStr(&m_gui, m_pElemVal2));
       nResult = nVal1 + nVal2;
-      itoa(nResult, acTxtNum, 10);
+      ltoa(nResult, acTxtNum, 10);
       gslc_ElemSetTxtStr(&m_gui, m_pElemResult, acTxtNum);
       break;
     case E_BTN_SUB:
       // Compute the subtraction and update the result
-      nVal1 = atoi(gslc_ElemGetTxtStr(&m_gui, m_pElemVal1));
-      nVal2 = atoi(gslc_ElemGetTxtStr(&m_gui, m_pElemVal2));
+      nVal1 = atol(gslc_ElemGetTxtStr(&m_gui, m_pElemVal1));
+      nVal2 = atol(gslc_ElemGetTxtStr(&m_gui, m_pElemVal2));
       nResult = nVal1 - nVal2;
-      itoa(nResult, acTxtNum, 10);
+      ltoa(nResult, acTxtNum, 10);
       gslc_ElemSetTxtStr(&m_gui, m_pElemResult, acTxtNum);
       break;
     case E_BTN_MULT:
       // Compute the multiplication and update the result
-      nVal1 = atoi(gslc_ElemGetTxtStr(&m_gui, m_pElemVal1));
-      nVal2 = atoi(gslc_ElemGetTxtStr(&m_gui, m_pElemVal2));
+      nVal1 = atol(gslc_ElemGetTxtStr(&m_gui, m_pElemVal1));
+      nVal2 = atol(gslc_ElemGetTxtStr(&m_gui, m_pElemVal2));
       nResult = nVal1 * nVal2;
-      itoa(nResult, acTxtNum, 10);
+      ltoa(nResult, acTxtNum, 10);
       gslc_ElemSetTxtStr(&m_gui, m_pElemResult, acTxtNum);
       break;
       //<Button Enums !End!>
@@ -261,6 +261,7 @@
   gslc_ElemSetTxtMargin(&m_gui, pElemRef, 5);
   gslc_ElemSetClickEn(&m_gui, pElemRef, true);
   gslc_ElemSetTouchFunc(&m_gui, pElemRef, &CbBtnCommon);
+  m_pElemVal1 = pElemRef; // Save for later

   // Create E_TXT_VAL2 modifiable text label
   static char m_strtxt6[11] = "";
@@ -272,12 +273,14 @@
   gslc_ElemSetTxtMargin(&m_gui, pElemRef, 5);
   gslc_ElemSetClickEn(&m_gui, pElemRef, true);
   gslc_ElemSetTouchFunc(&m_gui, pElemRef, &CbBtnCommon);
-
-  // Create E_TXT7 modifiable text label
-  static char m_strtxt7[11] = "";
-  pElemRef = gslc_ElemCreateTxt(&m_gui, E_TXT7, E_PG_MAIN, (gslc_tsRect) { 150, 200, 62, 12 },
-    (char*)m_strtxt7, 11, E_FONT_TXT1);
+  m_pElemVal2 = pElemRef; // Save for later
+
+  // Create E_TXT_RESULT modifiable text label
+  static char m_strResult[11] = "";
+  pElemRef = gslc_ElemCreateTxt(&m_gui, E_TXT_RESULT, E_PG_MAIN, (gslc_tsRect) { 150, 200, 62, 12 },
+    (char*)m_strResult, 11, E_FONT_TXT1);
   gslc_ElemSetTxtCol(&m_gui, pElemRef, GSLC_COL_GREEN);
+  m_pElemResult = pElemRef; // Save for later

   // create E_BTN_ADD button with text label
   pElemRef = gslc_ElemCreateBtnTxt(&m_gui, E_BTN_ADD, E_PG_MAIN,
@@ -339,9 +342,6 @@
   // Save some element references for quick access
   // ------------------------------------------------
   //<Quick_Access !Start!>
-  m_pElemVal1 = gslc_PageFindElemById(&m_gui, E_PG_MAIN, E_TXT_VAL1);
-  m_pElemVal2 = gslc_PageFindElemById(&m_gui, E_PG_MAIN, E_TXT_VAL2);
-  m_pElemResult = gslc_PageFindElemById(&m_gui, E_PG_MAIN, E_TXT7);
   //<Quick_Access !End!>

   //<Startup !Start!>


Also test button in minimal example

Also test button in minimal example

--- firmware/lm-matrix-minimal/lm-matrix-minimal.ino
+++ firmware/lm-matrix-minimal/lm-matrix-minimal.ino
@@ -14,9 +14,12 @@
 #define PIN_LOAD A1
 #define PIN_BUTTON 2

-uint8_t data[] = {0b00111100, 0b01000010, 0b10101001, 0b10000101, 0b10000101, 0b10101001, 0b01000010, 0b00111100};
+uint8_t smile1[] = {0b00111100, 0b01000010, 0b10101001, 0b10000101, 0b10000101, 0b10101001, 0b01000010, 0b00111100};
+uint8_t smile2[] = {0b00111100, 0b01000010, 0b10100101, 0b10001001, 0b10001001, 0b10100101, 0b01000010, 0b00111100};

 void setup() {
+  pinMode(PIN_BUTTON, INPUT_PULLUP);
+
   pinMode(PIN_DATA, OUTPUT);
   pinMode(PIN_CLK, OUTPUT);
   pinMode(PIN_LOAD, OUTPUT);
@@ -27,13 +30,20 @@
   displaySend(9, 0); // disable BCD decoding (only for 7-seg displays)
   displaySetBrightness(8); // set initial brightness
   displaySend(12, 1); // enable display
+}

+void displaySend(uint8_t *data) {
   for (uint8_t i = 0; i < 8; i++) {
-    displaySend(i+1, data[i]);
+    displaySend(i + 1, data[i]);
   }
 }

 void loop() {
+  if (digitalRead(PIN_BUTTON)) {
+    displaySend(smile1);
+  } else {
+    displaySend(smile2);
+  }
 }

 void displaySetBrightness(int8_t val) {


Update Blink__Multiple_Loops_.ino

Update Blink__Multiple_Loops_.ino

nicht möglich mit Arduino Mega 2560

--- Blink__Multiple_Loops/Blink__Multiple_Loops_.ino
+++ Blink__Multiple_Loops/Blink__Multiple_Loops_.ino
@@ -17,7 +17,7 @@
 }

-void loop() {
+void loop1() {
   digitalWrite(led1, HIGH);

@@ -39,11 +39,11 @@
     char c = Serial.read();
     if (c=='0') {
       digitalWrite(led3, LOW);
-      Serial.println("Led turned off!");
+      Serial.println("Off!");
     }
     if (c=='1') {
       digitalWrite(led3, HIGH);
-      Serial.println("Led turned on!");
+      Serial.println("On!");
     }
   }


Bring back frequency to 20Hz (no tested with radio link)

--- Arduino/MPU9150_MS5611_IMU/MPU9150_MS5611_IMU.ino
+++ Arduino/MPU9150_MS5611_IMU/MPU9150_MS5611_IMU.ino
@@ -93,7 +93,7 @@
 #include "MPU9150.h"
 #include <MS561101BA.h>

-#define OUTPUT_RATE_ms 100 // 20Hz
+#define OUTPUT_RATE_ms 50 // 20Hz

 #define MOVAVG_SIZE 32


Gave ESP8266 a better name

Gave ESP8266 a better name

--- module/module.ino
+++ module/module.ino
@@ -5,7 +5,7 @@
 #define moduleBaud 9600

 SoftwareSerial RFID(RFID_RX, RFID_TX);
-SoftwareSerial ESP(WIFI_RX, WIFI_TX);
+SoftwareSerial WIFI(WIFI_RX, WIFI_TX);
 unsigned char readData[bufferSize];

 const int ledPin = 13;


Cleanup.

Cleanup.

--- examples/LCD/CosaTemperature/CosaTemperature.ino
+++ examples/LCD/CosaTemperature/CosaTemperature.ino
@@ -59,9 +59,8 @@
   // Set up watchdog for low power sleep
   Watchdog::begin();

-  // Initiate the LCD screen and show arduino icon
+  // Initiate the LCD screen and show splash screen with arduino icon
   lcd.begin(CONTRAST);
-  lcd.putchar('\f');
   lcd.set_cursor((lcd.WIDTH - 64)/2, 1);
   lcd.draw_icon(arduino_icon_64x32);
   SLEEP(2);
@@ -78,9 +77,8 @@

 void loop()
 {
-  // Request a new sample from the sensor and read temperature
+  // Request a new sample from the sensor, Read temperature later on
   sensor.convert_request();
-  sensor.read_scratchpad();

   // Create an offscreen bitmap for the presentation
   OffScreen<PCD8544::WIDTH, PCD8544::HEIGHT> offscreen;
@@ -94,10 +92,13 @@
   // Draw the offscreen bitmap with the temperature
   offscreen.begin();
   offscreen.draw_roundrect(8, 8, lcd.WIDTH - 16, lcd.HEIGHT - 16, 8);
+
+  // Read temperature and print to offscreen bitmap
+  sensor.read_scratchpad();
   console << sensor;

   // Draw the bitmap to the LCD screen
-  lcd.putchar('\f');
+  lcd.set_cursor(0, 0);
   lcd.draw_bitmap(offscreen.get_bitmap(), offscreen.WIDTH, offscreen.HEIGHT);

   // Take a nap


updated ethernet example to not have the silly delays that the wifi shield needed.

--- examples/tentacle-ethernet/tentacle-ethernet.ino
+++ examples/tentacle-ethernet/tentacle-ethernet.ino
@@ -28,7 +28,6 @@

   setupEthernet();
   connectToServer();
-  delay(DELAY);
 }

 void loop() {
@@ -38,23 +37,25 @@
   }

   readData();
-  pseudopod.sendConfiguredPins();
+
+  if(pseudopod.shouldBroadcastPins() ) {
+    delay(pseudopod.getBroadcastInterval());
+    Serial.println(F("Sending pins"));
+    pseudopod.sendConfiguredPins();
+  }
 }

 void readData() {
-  delay(DELAY);

   while (conn.available()) {
     Serial.println(F("Received message"));
     Serial.flush();

     if(pseudopod.readMessage() == TentacleMessageTopic_action) {
-      delay(DELAY);
       pseudopod.sendPins();
     }
   }

-  delay(DELAY);
 }

 void connectToServer() {
@@ -72,7 +73,6 @@
     Serial.println(F("Can't connect to the server."));
     Serial.flush();
     conn.stop();
-    delay(DELAY);
     connectionAttempts++;
   }


Update iGPS.ino

Update iGPS.ino

调节读串口速度

--- iGPS.ino
+++ iGPS.ino
@@ -222,9 +222,10 @@
 //0x0D 0x0A CR LF \r \n
 String readLine(){
   String line = "";
+  delay(500);
   while(Serial1.available()) {
-      delay(3);
       char c = char(Serial1.read());
+      delay(50);
       Serial.print(c);
       if(c == '\r'){
         // do nothing


Fix #83: Make ttn-otaa-feather-us915 work with Catena4551

--- examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino
+++ examples/ttn-otaa-feather-us915/ttn-otaa-feather-us915.ino
@@ -65,12 +65,34 @@
 const unsigned TX_INTERVAL = 60;

 // Pin mapping
+#if defined(ARDUINO_SAMD_FEATHER_M0)
+// Pin mapping for Adafruit Feather M0 LoRa, etc.
 const lmic_pinmap lmic_pins = {
     .nss = 8,
     .rxtx = LMIC_UNUSED_PIN,
     .rst = 4,
-    .dio = { 3, 6, LMIC_UNUSED_PIN },
+    .dio = {3, 6, LMIC_UNUSED_PIN},
+    .rxtx_rx_active = 0,
+    .rssi_cal = 8,              // LBT cal for the Adafruit Feather M0 LoRa, in dB
+    .spi_freq = 8000000,
 };
+#elif defined(ARDUINO_CATENA_4551)
+// Pin mapping for Murata module / Catena 4551
+const lmic_pinmap lmic_pins = {
+        .nss = 7,
+        .rxtx = 29,
+        .rst = 8,
+        .dio = { 25,    // DIO0 (IRQ) is D25
+                 26,    // DIO1 is D26
+                 27,    // DIO2 is D27
+               },
+        .rxtx_rx_active = 1,
+        .rssi_cal = 10,
+        .spi_freq = 8000000     // 8MHz
+};
+#else
+# error "Unknown target"
+#endif

 void onEvent (ev_t ev) {
     Serial.print(os_getTime());


Started working on non-arbitrary start

Started working on non-arbitrary start

--- firefighter/firefighter.ino
+++ firefighter/firefighter.ino
@@ -4,6 +4,9 @@
 #include "servo.h"

 #define WALL_DISTANCE 5
+
+#define servo_pin 45
+#define fire_sensor 47

 Motor leftMotor1(2, 3);
 Motor leftMotor2(4, 5);
@@ -12,91 +15,44 @@
 Motor strafeMotor(10, 11);

 ColorSensor colour_sensor(44, 46, 48, 50, 52);
-#define servo_pin 45
-#define fire_sensor 47

 Ultrasonic frontUltrasonic(22, 23, true);
 Ultrasonic leftUltrasonic(24, 25, true);
 Ultrasonic rightUltrasonic(26, 27, true);
 Ultrasonic backUltrasonic(28, 29, true);

+// Drivetrain commands
 void driveToWhite();
 void driveThroughRoom();
+void hDrive(double move, double rotate, double strafe);
+void definedStartSearch();

-void hDrive(double move, double rotate, double strafe) {
-  double leftSpeed, rightSpeed;
-
-  move = constrain(move, -1.0, 1.0);
-  rotate = constrain(rotate, -1.0, 1.0);
-  strafe = constrain(strafe, -1.0, 1.0);
-
-  if (move > 0.0) {
-    if (rotate > 0.0) {
-      leftSpeed =  move - rotate;
-      rightSpeed = max(move, rotate);
-    } else {
-      leftSpeed = max(move, -rotate);
-      rightSpeed = move + rotate;
-    }
-  } else {
-    if (rotate > 0.0) {
-      leftSpeed = -max(-move, rotate);
-      rightSpeed = move + rotate;
-    } else {
-      leftSpeed = move - rotate;
-      rightSpeed = -max(-move, -rotate);
-    }
-  }
-
-  leftMotor1.set(constrain(leftSpeed, -1.0, 1.0));
-  leftMotor2.set(constrain(leftSpeed, -1.0, 1.0));
-  rightMotor1.set(-constrain(rightSpeed, -1.0, 1.0));
-  rightMotor2.set(-constrain(rightSpeed, -1.0, 1.0));
-  strafeMotor.set(strafe);
-}
+// Extinguisher commands
+void scanForFire();

 void setup() {
   Serial.begin(9600);
   pinMode(servo_pin, OUTPUT);
   pinMode(fire_sensor, INPUT);
- }
+}

-void scanForFire(){
-  servo_pin.write(0);
-  for(int i = 0; i <= 180;i += 10){
-    if(digitalRead(fire_sensor)){
-      delay(10);//make sure that the reading isn't a false positive
-      while(digitalRead(fire_sensor))
-      {
-        //Turn on extinguisher
-        delay(50);
-      }
-    }
-    break;
-  }
-}
+int btn = 0;

-int btn = 0;
 void loop() {
-
   // put your main code here, to run repeatedly:
   if(digitalRead(21)){
     delay(100);
-    Serial.println("pressed");

     if(!btn){
-      //hDrive(1.0, 0.0, 0.0);
       delay(100);

       driveToWhite()
-
-      btn = 1;
     }
     else{
       hDrive(0.0, 0.0, 0.0);
-      btn = 0;
     }
-
+
+    btn = !btn;
   }
 }

@@ -135,3 +91,72 @@
   }
 }

+void hDrive(double move, double rotate, double strafe) {
+  double leftSpeed, rightSpeed;
+
+  move = constrain(move, -1.0, 1.0);
+  rotate = constrain(rotate, -1.0, 1.0);
+  strafe = constrain(strafe, -1.0, 1.0);
+
+  if (move > 0.0) {
+    if (rotate > 0.0) {
+      leftSpeed =  move - rotate;
+      rightSpeed = max(move, rotate);
+    } else {
+      leftSpeed = max(move, -rotate);
+      rightSpeed = move + rotate;
+    }
+  } else {
+    if (rotate > 0.0) {
+      leftSpeed = -max(-move, rotate);
+      rightSpeed = move + rotate;
+    } else {
+      leftSpeed = move - rotate;
+      rightSpeed = -max(-move, -rotate);
+    }
+  }
+
+  leftMotor1.set(constrain(leftSpeed, -1.0, 1.0));
+  leftMotor2.set(constrain(leftSpeed, -1.0, 1.0));
+  rightMotor1.set(-constrain(rightSpeed, -1.0, 1.0));
+  rightMotor2.set(-constrain(rightSpeed, -1.0, 1.0));
+  strafeMotor.set(strafe);
+}
+
+void definedStartSearch() {
+  // Start A
+  if (leftUltrasonic.get_distance() < 10) {
+    hDrive(1.0, 0.0, 0.0);
+
+    while (leftUltrasonic.get_distance() < 7) { }
+    hDrive(0.0, 1.0, 0.0);
+
+  // Start B
+  } else {
+    // Strafe to Room4
+    hDrive(0.0, 0.0, -1.0);
+
+    while (frontUltrasonic().get_distance() > 7) { }
+    while (frontUltrasonic().get_distance() < 7) { }
+
+    hDrive(0.0, 0.0, 0.0);
+    delay(100);
+    driveToWhite();
+  }
+}
+
+void scanForFire(){
+  servo_pin.write(0);
+  for(int i = 0; i <= 180;i += 10){
+    if(digitalRead(fire_sensor)){
+      delay(10);//make sure that the reading isn't a false positive
+      while(digitalRead(fire_sensor))
+      {
+        //Turn on extinguisher
+        delay(50);
+      }
+    }
+    break;
+  }
+}
+


moved SD read/write to functions

moved SD read/write to functions

--- homemonitor/homemonitor.ino
+++ homemonitor/homemonitor.ino
@@ -14,13 +14,28 @@
 #include <SD.h> // Modified SD.cpp in SD library to allow for multiple SD.begin() calls
 // Add to Line 343 of SD.cpp: 'if (root.isOpen()) {root.close();}'

+#include <ThermistorSensor.h>
+
+// Thermistor Setup
+// which analog pins to connect
+#define THERMISTOR_PIN_A A0
+#define THERMISTOR_PIN_B A1
+
+// Thermistor objects and temperature variables
+ThermistorSensor thermistorA(THERMISTOR_PIN_A);
+ThermistorSensor thermistorB(THERMISTOR_PIN_B);
+
+#define FILENAME "mtest.txt"
 File myFile;
-void readFileToSerial()
+
+void readFileToSerial(char* filename)
 {
   // re-open the file for reading:
-  myFile = SD.open("mtest.txt");
+  myFile = SD.open(filename);
   if (myFile) {
-    Serial.println("mtest.txt:");
+    Serial.print("Reading ");
+    Serial.print(filename);
+    Serial.println(":");

     // read from the file until there's nothing else in it:
     while (myFile.available()) {
@@ -30,7 +45,7 @@
     myFile.close();
   } else {
   	// if the file didn't open, print an error:
-    Serial.println("error opening mtest.txt");
+    Serial.println("error opening for reading");
   }
 }

@@ -56,9 +71,6 @@
     myFile.println(value);
     myFile.close();

-    // Update counter
-    counter++;
-
     Serial.println("done.");
   } else {
     // if the file didn't open, print an error:
@@ -68,6 +80,13 @@

 boolean startSD()
 {
+  Serial.print("Initializing SD card...");
+  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
+  // Note that even if it's not used as the CS pin, the hardware SS pin
+  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
+  // or the SD library functions will not work.
+  pinMode(10, OUTPUT);
+
   if (!SD.begin(4)) {
     Serial.println("initialization failed!");
     return false;
@@ -77,52 +96,49 @@
 }

 boolean buttonPressed = false;
-void doButtonPressed()
+void buttonInterrupt()
 {
   buttonPressed = true;
 }

+void doButtonCall()
+{
+  delay(250);
+  Serial.println("Woo");
+  if (startSD())
+  {
+    // Read thermistors
+    int tempA = thermistorA.getReading();
+    int tempB = thermistorB.getReading();
+
+    logToFile(FILENAME, tempA);
+    logToFile(FILENAME, tempB);
+    readFileToSerial(FILENAME);
+  }
+  buttonPressed = false;
+
+}
+
 void setup()
 {
- // Open serial communications and wait for port to open:
-  Serial.begin(9600);
-  while (!Serial) {
-    ; // wait for serial port to connect. Needed for Leonardo only
-  }
+  Serial.begin(9600);
+
+  // if (!startSD())
+  // {
+  //   return;
+  // }
+
+  // logToFile(FILENAME, counter);
+  // readFileToSerial(FILENAME);

-
-  Serial.print("Initializing SD card...");
-  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
-  // Note that even if it's not used as the CS pin, the hardware SS pin
-  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
-  // or the SD library functions will not work.
-   pinMode(10, OUTPUT);
-
-  if (!startSD())
-  {
-    return;
-  }
-
-  logToFile("mtest.txt", counter);
-
-  readFileToSerial();
-
-  // Trigger backlight on push button on pin 2 (interrupt 0)
-  attachInterrupt(0, doButtonPressed, RISING);
+  attachInterrupt(0, buttonInterrupt, RISING);
 }

 void loop()
 {
   if (buttonPressed)
   {
-    delay(250);
-    Serial.println("Woo");
-    if (startSD())
-    {
-      logToFile("mtest.txt", counter);
-      readFileToSerial();
-    }
-    buttonPressed = false;
+    doButtonCall();
   }
 }


spinning rainbows are cool

spinning rainbows are cool

--- NeoPixelSwitchBox/NeoPixelSwitchBox.ino
+++ NeoPixelSwitchBox/NeoPixelSwitchBox.ino
@@ -273,6 +273,8 @@
      rainbowButton.update();
      if (rainbowButton.closedThisUpdate()) {
        ring.rainbow();
+       // spin the ring too, because it's cool!
+       ring.spin(50, true);
      }
   }


renaming stuff

renaming stuff

--- Arduino/V0p2_Main/V0p2_Main.ino
+++ Arduino/V0p2_Main/V0p2_Main.ino
@@ -534,7 +534,7 @@
 // relay + bh
 inline bool decodeAndHandleSecureFrame(volatile const uint8_t * const msg)
 {
-  return OTRadioLink::decodeAndHandleOTSecureFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
+  return OTRadioLink::decodeAndHandleOTSecureOFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
                                                    OTV0P2BASE::getPrimaryBuilding16ByteSecretKey,
                                                    OTRadioLink::relayFrameOperation<decltype(SIM900), SIM900>,
                                                    OTRadioLink::boilerFrameOperation<decltype(BoilerHub), BoilerHub, minuteCount>
@@ -544,7 +544,7 @@
 // relay
 inline bool decodeAndHandleSecureFrame(volatile const uint8_t * const msg)
 {
-  return OTRadioLink::decodeAndHandleOTSecureFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
+  return OTRadioLink::decodeAndHandleOTSecureOFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
                                                    OTV0P2BASE::getPrimaryBuilding16ByteSecretKey,
                                                    OTRadioLink::relayFrameOperation<decltype(SIM900), SIM900>
                                                   >(msg);
@@ -553,7 +553,7 @@
 // bh
 inline bool decodeAndHandleSecureFrame(volatile const uint8_t * const msg)
 {
-  return OTRadioLink::decodeAndHandleOTSecureFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
+  return OTRadioLink::decodeAndHandleOTSecureOFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
                                                    OTV0P2BASE::getPrimaryBuilding16ByteSecretKey,
                                                    OTRadioLink::boilerFrameOperation<decltype(BoilerHub), BoilerHub, minuteCount>
                                                   >(msg);
@@ -562,14 +562,15 @@
 // serial
 inline bool decodeAndHandleSecureFrame(volatile const uint8_t * const msg)
 {
-  return OTRadioLink::decodeAndHandleOTSecureFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
+  return OTRadioLink::decodeAndHandleOTSecureOFrame<OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleDec_DEFAULT_STATELESS,
                                                    OTV0P2BASE::getPrimaryBuilding16ByteSecretKey,
                                                    OTRadioLink::serialFrameOperation<decltype(Serial), Serial>
                                                   >(msg);
 }
 #endif // defined(ENABLE_RADIO_SECONDARY_MODULE_AS_RELAY) && (ENABLE_BOILER_HUB)
-OTRadioLink::OTMessageQueueHandler<decodeAndHandleSecureFrame, OTRadioLink::decodeAndHandleDummyFrame,
-                                   pollIO, V0P2_UART_BAUD> actualMessageQueue;  //TODO change baud
+OTRadioLink::OTMessageQueueHandler< pollIO, V0P2_UART_BAUD,
+                                    decodeAndHandleSecureFrame, OTRadioLink::decodeAndHandleDummyFrame
+                                   > actualMessageQueue;  //TODO change baud
 OTRadioLink::OTMessageQueueHandlerBase &messageQueue = actualMessageQueue;
 #else // ENABLE_OTSECUREFRAME_ENCODING_SUPPORT
 // When RX not enabled, switch in dummy version (base class implements stubs)


changed baud to 9600. Had issues with 115200 and XBee

--- Arduino/_firmware/_firmware.ino
+++ Arduino/_firmware/_firmware.ino
@@ -52,7 +52,7 @@

 void setup()
 {
-  Serial.begin(115200);   //Enable serial at high speed
+  Serial.begin(9600);   //Enable serial at high speed

   // Tachometer setup
   digitalWrite (TACH, HIGH);  // internal pull-up resistor built in :-)


Много изменений (версия 0.2 alpha)

Много изменений (версия 0.2 alpha)

--- main.ino
+++ main.ino
@@ -1,6 +1,30 @@
 #include <EEPROM.h>
 #include <Wire.h>
 #include <LiquidCrystal_I2C.h>
+
+#define VERSION "0.2(a)"
+
+static byte	bat_icon[8]	= {
+	B01110,
+	B11111,
+	B11111,
+	B11111,
+	B11111,
+	B11111,
+	B11111,
+	B11111
+};
+
+static byte	bat_in_icon[8]	= {
+	B01110,
+	B11111,
+	B10101,
+	B10101,
+	B10101,
+	B10001,
+	B10101,
+	B11111
+};

 LiquidCrystal_I2C lcd(0x27,16,2);	// Инициализация дисплея (адрес, количество символов, количество строк)

@@ -22,26 +46,178 @@
 #define WHEEL_LENGTH	2.050	// Длина окружности колеса в метрах
 #define BIP_DELAY		4		// Сколько итераций пищать (* 500 / 10000)

+/*Аналоговые выводы*/
+#define ACTION_BUTTON	2
 #define BUTTON_OK		256
 #define BUTTON_LEFT		680
 #define BUTTON_RIGHT	341

 /*Цифровые выводы*/
 #define BIP				4
-
-/*Аналоговые выводы*/
-
-
-bool			alarm_state = false;	// Для сигнализации
+#define BUTTON_CANCEL	341
+#define BUTTON_SIGNAL	341
+
+bool			alarm_state		= false,	// Для сигнализации
+				bat_external	= true;

 unsigned long	lastturn;	// Время последнего обращения

-float			speed_now,	// Скорость
-				distance;	// Расстояние
-
-byte			system_state = 0;
+float			speed_now		= 0.0,	// Скорость
+				distance		= 0.0;	// Расстояние
+
+byte			bat_percent		= 100,
+				system_state	= 0;
+
+#define LOAD_STATE		0
+#define SPEED_STATE		1
+#define MENU_STATE		2
+#define SETTINGS_STATE	3

 sys_conf		btc_config;	// Конфигурация системы
+
+unsigned int key_pressed() {
+	int key;
+
+	while (true) {
+
+		while ((key = analogRead(ACTION_BUTTON)) > 1000);
+
+		#ifdef DEBUG
+		Serial.println(key);
+		#endif
+
+		if ((key >= BUTTON_OK - 10) && (key <= BUTTON_OK + 10)) {
+			key	= BUTTON_OK;
+			break;
+		} else if ((key >= BUTTON_LEFT - 10) && (key <= BUTTON_LEFT + 10)) {
+			key	= BUTTON_LEFT;
+			break;
+		} else if ((key >= BUTTON_RIGHT - 10) && (key <= BUTTON_RIGHT + 10)) {
+			key	= BUTTON_RIGHT;
+			break;
+		}
+	}
+
+	while (analogRead(ACTION_BUTTON) < 1000);
+
+	delay(10);
+
+	return key;
+}
+
+void road_mode() {	// Режим спидометра
+	float	speed_old		= 0.0;
+
+	lcd.clear();
+	lcd.print("km/h: ");
+
+	lcd.setCursor(0, 1);
+	lcd.print("km:");
+
+	lcd.setCursor(15, 1);
+	lcd.write(0);
+
+	while (true) {
+		if (speed_old > speed_now) {
+			lcd.setCursor(5, 0);
+			lcd.print("    ");
+		}
+		lcd.setCursor(5, 0);
+		lcd.print(speed_now);
+		speed_old	= speed_now;
+
+		lcd.setCursor(11, 0);
+		lcd.print("00:00");
+
+		lcd.setCursor(3, 1);
+		lcd.print(distance);
+
+		lcd.setCursor(12, 1);
+		if (bat_percent == 100) {
+			lcd.print("100");
+		} else if ((bat_percent > 100) && (bat_percent <= 10)){
+			lcd.print(" ");
+			lcd.print(bat_percent);
+		} else if (bat_percent > 10){
+			lcd.print("  ");
+			lcd.print(bat_percent);
+		}
+
+		if ((analogRead(ACTION_BUTTON) >= BUTTON_OK - 10) && (analogRead(ACTION_BUTTON) <= BUTTON_OK + 10)) {
+			while (analogRead(ACTION_BUTTON) < 1000);
+			delay(50);
+			lcd.clear();
+			system_state	= MENU_STATE;
+			break;
+		}
+
+		delay(500);
+	}
+}
+
+byte settings(byte all_element, char settings_array[][15]) {
+	lcd.clear();
+
+	byte	selected		= 0,
+			on_display		= 0;
+
+	bool	key_pressed_ok	= true;
+
+	while (true) {
+		if (key_pressed_ok) {
+			if (selected == on_display) {
+				lcd.setCursor(0,0);
+				lcd.print(">");
+				lcd.setCursor(0,1);
+				lcd.print(" ");
+			} else {
+				lcd.setCursor(0,1);
+				lcd.print(">");
+				lcd.setCursor(0,0);
+				lcd.print(" ");
+			}
+
+			lcd.setCursor(1,0);
+			lcd.print(settings_array[on_display]);
+
+			if (on_display + 1 < all_element) {
+				lcd.setCursor(1,1);
+				lcd.print(settings_array[on_display + 1]);
+			}
+		}
+
+		key_pressed_ok	= true;
+
+		switch (key_pressed()) {
+
+			case BUTTON_OK:		return selected;
+								break;
+
+			case BUTTON_LEFT:	if (selected != 0) {
+									if (selected == on_display) {
+										lcd.clear();
+										on_display	-= 2;
+									}
+
+									selected--;
+								}
+								break;
+
+			case BUTTON_RIGHT:	if (selected < all_element - 1) {
+									if (selected == (on_display + 1)) {
+										lcd.clear();
+										on_display	+= 2;
+									}
+
+									selected++;
+								}
+								break;
+
+			default:			key_pressed_ok	= false;
+								break;
+		}
+	}
+}

 void setup() {
 	#ifdef DEBUG
@@ -61,6 +237,8 @@

 	/*Прерывание на 3-ем цифровом канале для подсчёта скорости*/
 	attachInterrupt(1, speed, CHANGE);
+
+	lcd.createChar(0, bat_icon);

 	#ifdef FIRST_ON
 	sys_conf load_to_eeprom;
@@ -106,6 +284,30 @@
 }

 void loop() {
+	if (system_state == LOAD_STATE) {
+		lcd.clear();
+		lcd.print("Loading system..");
+		lcd.setCursor(0, 1);
+		lcd.print("Version: ");
+		lcd.print(VERSION);
+		delay(3000);
+		system_state	= SPEED_STATE;
+	}
+
+	if (system_state == SPEED_STATE) {
+		road_mode();
+	}
+
+	if (system_state == MENU_STATE) {
+		char settings_array[3][15]	= {
+			"Speedometr",
+			"Settings",
+			"About system"
+		};
+
+		settings(3, settings_array);
+		system_state	= SPEED_STATE;
+	}
 }

 void alarm() {	// Сигнализация
@@ -133,7 +335,7 @@

-void input_password() {
+/*void input_password() {
 	lcd.clear();			// Очистка экрана
 	lcd.setCursor(0, 0);	// Установка указателя в левый верхний угол
 	lcd.print("Password:");
@@ -158,4 +360,4 @@
 	lcd.setCursor(0,0);
 	lcd.print("Complete!");
 	delay(2000);
-}+}*/


commented out the watch_dog library stuff

--- SenseBotWifiAgent/SenseBotWifiAgent.ino
+++ SenseBotWifiAgent/SenseBotWifiAgent.ino
@@ -1,7 +1,7 @@
 #include "SenseBotWifiAgent.h"

 #include <Adafruit_CC3000.h>
-#include <avr/wdt.h>
+//#include <avr/wdt.h>
 #include <SPI.h>
 #include "dht.h"
 #include <pt.h>
@@ -33,7 +33,7 @@
     ***********************************************************************************************/

 uint32_t sserver;
-byte server[4] = { XX, XX, XX, XX };
+byte server[4] = { 13, 1, 1, 1 };

 String host, jsonPayLoad;
 dht DHT;
@@ -59,7 +59,7 @@

   connectHttp();
   setupResource();
-  wdt_enable(WDTO_4S);
+//  wdt_enable(WDTO_4S);
 }

@@ -68,15 +68,15 @@

   protothread1(&pushThread, 1000);

-  listen();
+//  listen();
 //  wdt_reset();
                       // Check connection
-  if( !cc3000.checkConnected() ){
-    while(1){
-    }
-  }
-
-  wdt_reset();
+//  if( !cc3000.checkConnected() ){
+//    while(1){
+//    }
+//  }
+//
+//  wdt_reset();
   drive();

 }
@@ -117,7 +117,7 @@
                        // batches all the required pin values together and pushes once
          // Pushes data in 1 second interval
       pushData();
-      wdt_reset();
+//      wdt_reset();
     } else {
       pushClient.close();
       cc3000.disconnect();


remappé les moteurs correctement et les boutons itou

--- DeskChair/desk/desk.ino
+++ DeskChair/desk/desk.ino
@@ -14,17 +14,17 @@

 //-------------------Motors-------------------

-const int DOSSIER_BACK = 24;
-const int DOSSIER_FORWARD = 22;
-
-const int HAUTEUR_BACK = 28;
-const int HAUTEUR_FORWARD = 26;
-
-const int AVANCEMENT_BACK = 32;
-const int AVANCEMENT_FORWARD = 30;
-
-const int ASSISE_BACK = 36;
-const int ASSISE_FORWARD = 34;
+const int DOSSIER_BACK = 34;
+const int DOSSIER_FORWARD = 36;
+
+const int HAUTEUR_BACK = 32;
+const int HAUTEUR_FORWARD = 30;
+
+const int AVANCEMENT_BACK = 26;
+const int AVANCEMENT_FORWARD = 28;
+
+const int ASSISE_BACK = 24;//36;
+const int ASSISE_FORWARD = 22;//34;

 //-------------------Potentiometers-------------------
@@ -49,18 +49,18 @@

-const int BUTTON_HAUTEUR_FORWARD = 33;//23     // the number of the pushbutton pin
-const int BUTTON_HAUTEUR_BACK = 31; //25    // the number of the pushbutton pin
-
-const int BUTTON_ASSISE_FORWARD = 23;//31     // the number of the pushbutton pin
-const int BUTTON_ASSISE_BACK = 25;   //33  // the number of the pushbutton pin
-
-const int BUTTON_DOSSIER_FORWARD = 35;     // the number of the pushbutton pin
-const int BUTTON_DOSSIER_BACK = 37;     // the number of the pushbutton pin
-
-
-const int BUTTON_AVANCEMENT_FORWARD = 27;     // the number of the pushbutton pin
-const int BUTTON_AVANCEMENT_BACK = 29 ;    // the number of the pushbutton pin
+const int BUTTON_HAUTEUR_FORWARD = 27;//23     // the number of the pushbutton pin
+const int BUTTON_HAUTEUR_BACK = 29; //25    // the number of the pushbutton pin
+
+const int BUTTON_ASSISE_FORWARD = 35;//31     // the number of the pushbutton pin
+const int BUTTON_ASSISE_BACK = 37;   //33  // the number of the pushbutton pin
+
+const int BUTTON_DOSSIER_FORWARD = 25;     // the number of the pushbutton pin
+const int BUTTON_DOSSIER_BACK = 23;     // the number of the pushbutton pin
+
+
+const int BUTTON_AVANCEMENT_FORWARD = 31;     // the number of the pushbutton pin
+const int BUTTON_AVANCEMENT_BACK = 33 ;    // the number of the pushbutton pin

 //-------------------Misc-------------------
@@ -195,6 +195,14 @@
   //while ( !Serial.available() );
   while (Serial.available() > 0) {
     int serial_read = Serial.parseInt();
+
+    if(serial_read==42){
+
+        seat.motor_assise.go_forward();
+       delay(3000);
+       seat.motor_assise.go_stop();
+
+    }
     if(serial_read==GET){

     digitalWrite(2, HIGH);
@@ -258,4 +266,4 @@

     }
   }
- }
+ }