remove sensor.ino

remove sensor.ino

--- arduino/sensor.ino
+++ arduino/sensor.ino
@@ -1,66 +0,0 @@
-#include <Wire.h>
-#include <SoftwareSerial.h>
-#include <OneWire.h>
-#include <DallasTemperature.h>
-#include <dht.h>
-#include <Adafruit_Sensor.h>
-#include <Adafruit_BMP085_U.h>
-#include <LowPower.h>
-
-/* Datapins for DS18B20, DHT22 and software serial
-The BMP180 must be connected to the I2C interface */
-#define ONE_WIRE_PIN 9  //DS18B20
-#define DHT22_PIN 6   //DHT22
-#define softSer_RX 10   //SoftwareSerial RX
-#define softSer_TX 11 //SoftwareSerial TX
-
-//Create entitis for the sensors and the software serial interface
-OneWire oneWire(ONE_WIRE_PIN);
-DallasTemperature sensors(&oneWire);
-dht DHT;
-Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
-SoftwareSerial bluetooth(softSer_RX, softSer_TX);
-
-
-void setup(){
-    //Start software serial with 9600 baud
-    bluetooth.begin(9600);
-
-    //Initialize the BMP180
-    bmp.begin();
-    sensor_t sensor;
-    bmp.getSensor(&sensor);
-    sensors.begin();
-}
-
-void loop(){
-  //Read temperature (DS18S20)
-  sensors.requestTemperatures();
-
-  //Read humidity (DHT22)
-  uint32_t start = micros();
-  int chk = DHT.read22(DHT22_PIN);
-  uint32_t stop = micros();
-
-  //Read pressure (BMP180)
-  sensors_event_t event;
-  bmp.getEvent(&event);
-
-  //Write data to the bluetooth module
-  bluetooth.print(sensors.getTempCByIndex(0), 1);
-  bluetooth.print(";");
-  bluetooth.print(DHT.humidity, 1);
-  bluetooth.print(";");
-  bluetooth.print(event.pressure);
-  bluetooth.println();
-
-  //Sleep for 10 minutes
-  sleep();
-}
-
-void sleep() {
-  for (int i = 0; i < 75; i++) {
-    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
-  }
-}
-


TODO-593: unit tests

TODO-593: unit tests

--- test_VALVEMODEL/test_VALVEMODEL.ino
+++ test_VALVEMODEL/test_VALVEMODEL.ino
@@ -222,10 +222,10 @@

 // Test for general sanity of computation of desired valve position.
-static void testComputeRequiredTRVPercentOpen()
-  {
-#ifdef ENABLE_MODELLED_RAD_VALVE
-  DEBUG_SERIAL_PRINTLN_FLASHSTRING("ComputeRequiredTRVPercentOpen");
+// In particular test the logic in ModelledRadValveState for extreme positions.
+static void testMRVSExtremes()
+  {
+  Serial.println("MRVSExtremes");
   // Test that if the real temperature is zero
   // and the initial valve position is anything less than 100%
   // that after one tick (with mainly defaults)
@@ -234,9 +234,9 @@
   // and also test that the fully-open state is reached in a bounded number of ticks ie bounded time.
   static const int maxFullTravelMins = 25;
 //  DEBUG_SERIAL_PRINTLN_FLASHSTRING("open...");
-  ModelledRadValveInputState is0(0);
-  is0.targetTempC = OTV0P2BASE::randRNG8NextBoolean() ? FROST : WARM;
-  ModelledRadValveState rs0;
+  OTRadValve::ModelledRadValveInputState is0(0);
+  is0.targetTempC = OTV0P2BASE::randRNG8NextBoolean() ? 5 : 25;
+  OTRadValve::ModelledRadValveState rs0;
   const uint8_t valvePCOpenInitial0 = OTV0P2BASE::randRNG8() % 100;
   volatile uint8_t valvePCOpen = valvePCOpenInitial0;
   for(int i = maxFullTravelMins; --i >= 0; ) // Must fully open in reasonable time.
@@ -265,9 +265,9 @@
   //   * Check that linger was long enough (if linger threshold is higher enough to allow it).
   // Also check for some correct initialisation and 'velocity'/smoothing behaviour.
 //  DEBUG_SERIAL_PRINTLN_FLASHSTRING("close...");
-  ModelledRadValveInputState is1(100<<4);
-  is1.targetTempC = OTV0P2BASE::randRNG8NextBoolean() ? FROST : WARM;
-  ModelledRadValveState rs1;
+  OTRadValve::ModelledRadValveInputState is1(100<<4);
+  is1.targetTempC = OTV0P2BASE::randRNG8NextBoolean() ? 5 : 25;
+  OTRadValve::ModelledRadValveState rs1;
   AssertIsTrue(!rs1.initialised); // Initialisation not yet complete.
   const uint8_t valvePCOpenInitial1 = 1 + (OTV0P2BASE::randRNG8() % 100);
   valvePCOpen = valvePCOpenInitial1;
@@ -296,9 +296,9 @@
   AssertIsEqual(0, valvePCOpen);
   AssertIsEqual(valvePCOpenInitial1, rs1.cumulativeMovementPC);
   AssertIsTrue(hitLinger == lookForLinger);
-  if(lookForLinger) { AssertIsTrue(lingerMins >= min(is1.minPCOpen, DEFAULT_MAX_RUN_ON_TIME_M)); }
+  if(lookForLinger) { AssertIsTrue(lingerMins >= min(is1.minPCOpen, OTRadValve::DEFAULT_MAX_RUN_ON_TIME_M)); }
   // Filtering should not have been engaged and velocity should be zero (temperature is flat).
-  for(int i = ModelledRadValveState::filterLength; --i >= 0; ) { AssertIsEqual(100<<4, rs1.prevRawTempC16[i]); }
+  for(int i = OTRadValve::ModelledRadValveState::filterLength; --i >= 0; ) { AssertIsEqual(100<<4, rs1.prevRawTempC16[i]); }
   AssertIsEqual(100<<4, rs1.getSmoothedRecent());
 //  AssertIsEqual(0, rs1.getVelocityC16PerTick());
   AssertIsTrue(!rs1.isFiltering);
@@ -320,8 +320,8 @@
 #ifndef OMIT_MODULE_LDROCCUPANCYDETECTION
       //AmbLight._TEST_set_multi_((j != 0) ? 1023 : 0, j != 0);
     // ENERGY SAVING RULE TEST (TODO-442 2a: "Setback in WARM mode must happen in dark (quick response) or long vacant room.")
-    ModelledRadValveInputState is3(100<<4);
-    is3.targetTempC = WARM;
+    OTRadValve::ModelledRadValveInputState is3(100<<4);
+    is3.targetTempC = 25;
     // Try a range of (whole-degree) offsets...
     for(int offset = -2; offset <= +2; ++offset)
       {
@@ -336,7 +336,7 @@
           {
           is3.refTempC16 = (is3.targetTempC + offset) << 4;
           // Where adjusted reference temperature is (well) below target, valve should be driven on.
-          ModelledRadValveState rs3a;
+          OTRadValve::ModelledRadValveState rs3a;
           valvePCOpen = 0;
           rs3a.tick(valvePCOpen, is3);
 //DEBUG_SERIAL_PRINT('@');
@@ -346,7 +346,7 @@
 //DEBUG_SERIAL_PRINTLN();
           AssertIsTrue((offset < 0) ? (valvePCOpen > 0) : (0 == valvePCOpen));
           // Where adjusted reference temperature is (well) above target, valve should be driven off.
-          ModelledRadValveState rs3b;
+          OTRadValve::ModelledRadValveState rs3b;
           valvePCOpen = 100;
           rs3b.tick(valvePCOpen, is3);
           AssertIsTrue((offset < 0) ? (100 == valvePCOpen) : (valvePCOpen < 100));
@@ -355,13 +355,13 @@
           {
           // Below the half way mark the valve should always be opened (from off), soft setback or not.
           is3.refTempC16 = (is3.targetTempC << 4) + 0x4;
-          ModelledRadValveState rs3c;
+          OTRadValve::ModelledRadValveState rs3c;
           valvePCOpen = 0;
           rs3c.tick(valvePCOpen, is3);
           AssertIsTrue(valvePCOpen > 0);
           // Above the half way mark the valve should only be opened without soft setback.
           is3.refTempC16 = (is3.targetTempC << 4) + 0xc;
-          ModelledRadValveState rs3d;
+          OTRadValve::ModelledRadValveState rs3d;
           valvePCOpen = 0;
           rs3d.tick(valvePCOpen, is3);
 #if 1 /* TODO-453: drift down soft by default */
@@ -374,13 +374,7 @@
           }
         }
       }
-
-#if defined(QUICK_DARK_SETBACK_IS_SOFT)
-
-    // TODO
 #endif
-#endif
-#endif // ENABLE_MODELLED_RAD_VALVE
   }

@@ -411,7 +405,7 @@

   testCSVMDC();
   testCurrentSenseValveMotorDirect();
-  testComputeRequiredTRVPercentOpen();
+  testMRVSExtremes();

   // Announce successful loop completion and count.


Added code to get device id and print during setup

--- photo_temp_sensor/photo_temp_sensor.ino
+++ photo_temp_sensor/photo_temp_sensor.ino
@@ -5,6 +5,7 @@
 TCPClient client;
 MCP9808 mcp = MCP9808();
 RgbLed led = RgbLed();
+String myDeviceId;

 double currentTempC = 0;
 double currentTempF = 0;
@@ -20,8 +21,15 @@
 {
     Serial.begin(9600);

+    myDeviceId = Particle.deviceID();
+
+    Serial.print("My device id: ");
+
+    Serial.println(myDeviceId);
+
     led.init();
     led.setColor(YELLOW);
+

     Serial.println("Initializing... ");


help a user enter the command mode

help a user enter the command mode

Note, I added the first question mainly to add a pause so that $$$ was
not sent until the Serial Monitor was up.

--- examples/RoseBot/WiFlySetup/WiFlySetup.ino
+++ examples/RoseBot/WiFlySetup/WiFlySetup.ino
@@ -19,13 +19,31 @@
 #include <SoftwareSerial.h>

 SoftwareSerial WiflySerial(15, 14); // RX, TX
+char response[] = "XXX";
+unsigned long startTimer = 0;

 void setup() {
+  int errorEnterringCommandMode = 0;
   Serial.begin(115200);  // Baudrate used in the Serial Monitor window (can be anything)
-  WiflySerial.begin(57600);  // Baudrate used to talk to WiFly (keep setting that you plan to use with Firmata)
+  errorEnterringCommandMode = enterCommandModeWithWiFly();
+  if (errorEnterringCommandMode) {
+    Serial.println("\n\nAbort");
+    while(1);  // I'm choosing to abort this run by stopping any further execution.  Nothing more will happen.
+  }
 }

 void loop() {
+  // TODO: Make a menu to help guide a user through setting up their WiFly
+  // Select an option below:
+  //   0: Exit this shortcut menu and just let me manually type commands to send to the WiFly.
+  //   1: scan
+  //   2: set wlan ssid RHIT-OPEN
+  //   3: set wlan ssid <enter network name in the next step>
+  //   4: set wlan pass <enter password in next step>
+  //   b: set uart baudrate <select baudrate in next step>
+  //   a: set wlan join 1 (set mode to auto connect in the future, this is the default)
+  //   s: save
+  //   r: reboot
   if (WiflySerial.available()) {
     Serial.write(WiflySerial.read());
   }
@@ -33,3 +51,80 @@
     WiflySerial.write(Serial.read());
   }
 }
+
+
+int enterCommandModeWithWiFly() {
+  Serial.println("Select the WiFly baudrate:");
+  Serial.println("  1 - 9600 (the default when you plug in a new WiFly module)");
+  Serial.println("  2 - 57600 (the standard Firmata baudrate)");
+  Serial.println("  3 - 112500 (the baudrate used by the RoseBotFirmata sketch)");
+  Serial.print("Use the Send box above to send 1, 2, or 3: ");
+
+  while (!Serial.available()); // Wait for the Serial Monitor response.
+
+  switch (Serial.read()) {
+    case '1':
+      Serial.println("1");
+      WiflySerial.begin(9600);
+      break;
+    case '2':
+      Serial.println("2");
+      WiflySerial.begin(57600);
+      break;
+    case '3':
+      Serial.println("3");
+      WiflySerial.begin(115200);
+      break;
+    default:
+      Serial.println("That is not a valid choice. :)");
+      return 1; // Return an error.
+  }
+
+  // Attempt to enter with a nice normal state, flushing buffers, putting things to a normal starting point.
+  WiflySerial.write("exit\r"); // Puts the WiFly back into normal mode if you are accidentally already in command mode.
+  Serial.println("Clearing any pending WiFly messages...");
+  startTimer = millis();
+  while (millis() - startTimer < 1000) {
+    if (WiflySerial.available()) {
+      WiflySerial.read();  // Trash an WiFly messages if any are sent during this time.
+    }
+    if (Serial.available()) {
+      Serial.read();  // Trash an Serial Monitor messages if any are sent during this time.
+    }
+  }
+
+  // Enter into command mode
+  // You should see a slow (0.5 Hz) flashing green LED on the WiFly.
+  Serial.println("Entering WiFly command mode by sending $$$ to the WiFly...");
+  delay(500);
+  WiflySerial.write("$$$"); // Hopefully there is a CMD response
+  delay(1000);
+  if (WiflySerial.available()) {
+    response[0] = WiflySerial.read();
+    response[1] = WiflySerial.read();
+    response[2] = WiflySerial.read();
+  }
+  response[3] = '\0'; // null terminator for the string to print
+
+  Serial.println(response);
+  if (response[0] != 'C' || response[1] != 'M' || response[2] != 'D') {
+    Serial.println("\nSomething went wrong. :(");
+    Serial.println("Turn off your RoseBot, turn it back on, then try again.");
+    Serial.println("Or try pulling the WiFly out and putting it back in, then close and reopen the Serial Monitor");
+    Serial.println("Also check the WiFly Baudrate too!");
+    return 1;  // Return an error.
+  }
+
+  // Hide any extra characters sent from WiFly.
+  startTimer = millis();
+  while (millis() - startTimer < 1000) {
+    if (WiflySerial.available()) {
+      WiflySerial.read();  // Trash an WiFly messages if any are sent during this time.
+    }
+    if (Serial.available()) {
+      Serial.read();  // Trash an Serial Monitor messages if any are sent during this time.
+    }
+  }
+  Serial.println("You are now in command mode with the WiFly!");
+  return 0;  // Return success!
+}


changes in version 0.11:       * added more pushbullet notifications and commented out publish() in other cases

--- minimalistthermostat.ino
+++ minimalistthermostat.ino
@@ -24,7 +24,7 @@
 #include "FiniteStateMachine.h"

 #define APP_NAME "Thermostat"
-String VERSION = "Version 0.10";
+String VERSION = "Version 0.11";
 /*******************************************************************************
  * changes in version 0.09:
        * reorganized code to group functions
@@ -37,6 +37,8 @@
           from the vents
        * added pushbullet notifications for heating on/off
        * added fan on/off setting via a cloud function
+ * changes in version 0.11:
+      * added more pushbullet notifications and commented out publish() in other cases
 *******************************************************************************/

 #define PUSHBULLET_NOTIF "pushbulletGUST"
@@ -82,8 +84,8 @@
 int cold = D2;
 //TESTING_HACK
 int fanOutput;
-int heatTesting;
-int coldTesting;
+int heatOutput;
+int coldOutput;

 /*******************************************************************************
  DHT sensor
@@ -103,7 +105,7 @@
 float targetTemp = 19.0;
 float currentTemp = 20.0;
 float currentHumidity = 0.0;
-float margin = 0.3;
+float margin = 0.25;
 //DHT difference with real temperature (if none set to zero)
 //use this variable to fix DHT measurements with your existing thermostat
 float temperatureDifference = -1.6;
@@ -303,7 +305,7 @@
 ********************************************************************************
 *******************************************************************************/
 void initEnterFunction(){
-  Particle.publish(APP_NAME, "initEnterFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "initEnterFunction", 60, PRIVATE);
   //start the timer of this cycle
   initTimer = 0;
 }
@@ -314,11 +316,11 @@
   }
 }
 void initExitFunction(){
-  Particle.publish(APP_NAME, "initExitFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "initExitFunction", 60, PRIVATE);
 }

 void idleEnterFunction(){
-  Particle.publish(APP_NAME, "idleEnterFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "idleEnterFunction", 60, PRIVATE);
   //turn off the fan only if fan was not set on manually with setFan(on)
   if ( fanStatus == false ) {
     myDigitalWrite(fan, LOW);
@@ -339,16 +341,16 @@
   }

   if ( currentTemp <= (targetTemp - margin) ) {
-    Particle.publish(APP_NAME, "Starting to heat", 60, PRIVATE);
+    //Particle.publish(APP_NAME, "Starting to heat", 60, PRIVATE);
     thermostatStateMachine.transitionTo(heatingState);
   }
 }
 void idleExitFunction(){
-  Particle.publish(APP_NAME, "idleExitFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "idleExitFunction", 60, PRIVATE);
 }

 void heatingEnterFunction(){
-  Particle.publish(APP_NAME, "heatingEnterFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "heatingEnterFunction", 60, PRIVATE);
   Particle.publish(PUSHBULLET_NOTIF, "Heat on", 60, PRIVATE);
   myDigitalWrite(fan, HIGH);
   myDigitalWrite(heat, HIGH);
@@ -365,12 +367,13 @@
   }

   if ( currentTemp >= (targetTemp + margin) ) {
-    Particle.publish(APP_NAME, "Desired temperature reached", 60, PRIVATE);
+    //Particle.publish(APP_NAME, "Desired temperature reached", 60, PRIVATE);
+    Particle.publish(PUSHBULLET_NOTIF, "Desired temperature reached", 60, PRIVATE);
     thermostatStateMachine.transitionTo(endOfCycleState);
   }
 }
 void heatingExitFunction(){
-  Particle.publish(APP_NAME, "heatingExitFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "heatingExitFunction", 60, PRIVATE);
   Particle.publish(PUSHBULLET_NOTIF, "Heat off", 60, PRIVATE);
   myDigitalWrite(fan, HIGH);
   myDigitalWrite(heat, LOW);
@@ -378,7 +381,7 @@
 }

 void endOfCycleEnterFunction(){
-  Particle.publish(APP_NAME, "endOfCycleEnterFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "endOfCycleEnterFunction", 60, PRIVATE);
   myDigitalWrite(fan, HIGH);
   myDigitalWrite(heat, LOW);
   myDigitalWrite(cold, LOW);
@@ -393,7 +396,7 @@
   }
 }
 void endOfCycleExitFunction(){
-  Particle.publish(APP_NAME, "endOfCycleExitFunction", 60, PRIVATE);
+  //Particle.publish(APP_NAME, "endOfCycleExitFunction", 60, PRIVATE);
 }

@@ -429,7 +432,7 @@
   // int fan = D0;
   // int heat = D1;
   // int cold = D2;
-  return coldTesting*4 + heatTesting*2 + fanOutput*1;
+  return coldOutput*4 + heatOutput*2 + fanOutput*1;
 }

 /*******************************************************************************
@@ -449,10 +452,12 @@
   if ( tmpFloat > 0 ) {
     currentTemp = tmpFloat;
     currentTempString = String(currentTemp);
-    Particle.publish(APP_NAME, "New current temp: " + currentTempString, 60, PRIVATE);
+    //Particle.publish(APP_NAME, "New current temp: " + currentTempString, 60, PRIVATE);
+    Particle.publish(PUSHBULLET_NOTIF, "New current temp: " + currentTempString, 60, PRIVATE);
     return 0;
   } else {
-    Particle.publish(APP_NAME, "ERROR: Failed to set new current temp to " + newCurrentTemp, 60, PRIVATE);
+    //Particle.publish(APP_NAME, "ERROR: Failed to set new current temp to " + newCurrentTemp, 60, PRIVATE);
+    Particle.publish(PUSHBULLET_NOTIF, "ERROR: Failed to set new current temp to " + newCurrentTemp, 60, PRIVATE);
     return -1;
   }
 }
@@ -470,10 +475,10 @@
     fanOutput = status;
   }
   if (input == heat){
-    heatTesting = status;
+    heatOutput = status;
   }
   if (input == cold){
-    coldTesting = status;
+    coldOutput = status;
   }
 }


Fix bug in One Tap operation

Fix bug in One Tap operation

--- sequencial_turn_signal_4_8_0zxy/sequencial_turn_signal_4_8_0zxy.ino
+++ sequencial_turn_signal_4_8_0zxy/sequencial_turn_signal_4_8_0zxy.ino
@@ -153,13 +153,13 @@
   else
   {
     // 5. This is if the right turn signal is on, do a cycle through the lights.
-    if( ( (digitalRead(LEFT_SIGNAL_INPUT) == 1) and (digitalRead(BRAKE_INPUT) == 1) ) and ( (digitalRead(RIGHT_SIGNAL_INPUT) == 0) || (!isRightTap) ) )
+    if( ( (digitalRead(LEFT_SIGNAL_INPUT) == 1) and (digitalRead(BRAKE_INPUT) == 1) ) and ( (digitalRead(RIGHT_SIGNAL_INPUT) == 0) || (isRightTap) ) )
     {
       (digitalRead(MODE_INPUT) == 0) ? (rightSequence(QUICK_BLINK, QUICK_BLINK)) : (rightBlink(SLOW_BLINK, MEDIUM_BLINK));
     }

     // 6. Here is if the left turn signal is on. Cycle through the lights.
-    if( ( (digitalRead(RIGHT_SIGNAL_INPUT) == 1) and (digitalRead(BRAKE_INPUT) == 1) ) and ( (digitalRead(LEFT_SIGNAL_INPUT) == 0) || (!isLeftTap) ) )
+    if( ( (digitalRead(RIGHT_SIGNAL_INPUT) == 1) and (digitalRead(BRAKE_INPUT) == 1) ) and ( (digitalRead(LEFT_SIGNAL_INPUT) == 0) || (isLeftTap) ) )
     {
       (digitalRead(MODE_INPUT) == 0) ? (leftSequence(QUICK_BLINK, QUICK_BLINK)) : (leftBlink(SLOW_BLINK, MEDIUM_BLINK));
     }
@@ -171,6 +171,8 @@

 void rightSequence(int durationMillis, int pauseDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(OFF, OFF, OFF, OFF);
   selectRightOn(ON, OFF, OFF, OFF);
   delay(durationMillis);
@@ -178,9 +180,7 @@
   selectLeftOn(OFF, OFF, OFF, OFF);
   selectRightOn(ON, ON, OFF, ON);
   delay(durationMillis);
-
-  checkIsTap();
-
+
   selectLeftOn(OFF, OFF, OFF, OFF);
   selectRightOn(ON, ON, ON, ON);
   delay(durationMillis);
@@ -193,11 +193,11 @@

 void rightBlink(int durationMillis, int offDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(OFF, OFF, OFF, OFF);
   selectRightOn(OFF, ON, ON, ON);
   delay(durationMillis);
-
-  checkIsTap();

   off();
   delay(offDurationMillis);
@@ -207,6 +207,8 @@

 void leftSequence(int durationMillis, int pauseDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(ON, OFF, OFF, OFF);
   selectRightOn(OFF, OFF, OFF, OFF);
   delay(durationMillis);
@@ -214,8 +216,6 @@
   selectLeftOn(ON, ON, OFF, ON);
   selectRightOn(OFF, OFF, OFF, OFF);
   delay(durationMillis);
-
-  checkIsTap();

   selectLeftOn(ON, ON, ON, ON);
   selectRightOn(OFF, OFF, OFF, OFF);
@@ -229,11 +229,11 @@

 void leftBlink(int onDurationMillis, int offDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(OFF, ON, ON, ON);
   selectRightOn(OFF, OFF, OFF, OFF);
   delay(onDurationMillis);
-
-  checkIsTap();

   off();
   delay(offDurationMillis);
@@ -243,6 +243,8 @@

 void rightSequenceBrake(int durationMillis, int pauseDurationMillis)
 {
+  checkIsTap();
+
   selectRightOn(ON, OFF, OFF, OFF);
   selectLeftOn(ON, ON, ON, OFF);
   delay(durationMillis);
@@ -250,8 +252,6 @@
   selectRightOn(ON, ON, OFF, ON);
   selectLeftOn(ON, ON, ON, OFF);
   delay(durationMillis);
-
-  checkIsTap();

   selectRightOn(ON, ON, ON, ON);
   selectLeftOn(ON, ON, ON, OFF);
@@ -266,11 +266,11 @@

 void rightBlinkBrake(int onDurationMillis, int offDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(OFF, ON, ON, OFF);
   selectRightOn(OFF, ON, ON, ON);
   delay(onDurationMillis);
-
-  checkIsTap();

   selectLeftOn(OFF, ON, ON, OFF);
   selectRightOn(OFF, OFF, OFF, OFF);
@@ -281,6 +281,8 @@

 void leftSequenceBrake(int durationMillis, int pauseDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(ON, OFF, OFF, OFF);
   selectRightOn(ON, ON, ON, OFF);
   delay(durationMillis);
@@ -288,8 +290,6 @@
   selectLeftOn(ON, ON, OFF, ON);
   selectRightOn(ON, ON, ON, OFF);
   delay(durationMillis);
-
-  checkIsTap();

   selectLeftOn(ON, ON, ON, ON);
   selectRightOn(ON, ON, ON, OFF);
@@ -304,11 +304,11 @@

 void leftBlinkBrake(int onDurationMillis, int offDurationMillis)
 {
+  checkIsTap();
+
   selectLeftOn(OFF, ON, ON, ON);
   selectRightOn(OFF, ON, ON, OFF);
   delay(onDurationMillis);
-
-  checkIsTap();

   selectLeftOn(OFF, OFF, OFF, OFF);
   selectRightOn(OFF, ON, ON, OFF);
@@ -402,28 +402,42 @@
 // IIIb. Tap Logic Functions

 void checkIsTap()
-{
-  if(flashCount > 0)
-    return;
-
-  if( (digitalRead(RIGHT_SIGNAL_INPUT) == 1) )
-    isRightTap = true;
-  else if( (digitalRead(LEFT_SIGNAL_INPUT) == 1) )
-    isLeftTap = true;
+{
+  if(flashCount > 0)
+  {
+    if( (digitalRead(RIGHT_SIGNAL_INPUT) == 0) )
+    {
+      isRightTap = false;
+      resetFlashCount();
+    }
+    else if( (digitalRead(LEFT_SIGNAL_INPUT) == 0) )
+    {
+      isLeftTap = false;
+      resetFlashCount();
+    }
+  }
+  else
+  {
+    if( (digitalRead(RIGHT_SIGNAL_INPUT) == 0) )
+      isRightTap = true;
+    else if( (digitalRead(LEFT_SIGNAL_INPUT) == 0) )
+      isLeftTap = true;
+  }
 }

 void updateTapControl()
-{
-  flashCount++;
-
-  if( (flashCount > MAX_REPEAT_ON_TAP) and (isRightTap) )
-  {
-    isRightTap = false;
+{
+  flashCount++;
+  if( (flashCount > MAX_REPEAT_ON_TAP) and (isRightTap) )
+  {
+    isRightTap = false;
+    resetFlashCount();
+  }
+  else if( (flashCount > MAX_REPEAT_ON_TAP) and (isLeftTap) )
+  {
+    isLeftTap = false;
+    resetFlashCount();
   }
-  else if( (flashCount > MAX_REPEAT_ON_TAP) and (isLeftTap) )
-  {
-    isLeftTap = false;
-  }
 }

 void resetFlashCount()


More code cleanupery

More code cleanupery

--- examples/RGBCalibrate/RGBCalibrate.ino
+++ examples/RGBCalibrate/RGBCalibrate.ino
@@ -6,18 +6,18 @@
 // RGB Calibration code
 //
 // Use this sketch to determine what the RGB ordering for your chipset should be.  Steps for setting up to use:
-//
+
 // * Uncomment the line in setup that corresponds to the LED chipset that you are using.  (Note that they
 //   all explicitly specify the RGB order as RGB)
 // * Define DATA_PIN to the pin that data is connected to.
 // * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
 // * Compile/upload/run the sketch
-//
+
 // You should see six leds on.  If the RGB ordering is correct, you should see 1 red led, 2 green
 // leds, and 3 blue leds.  If you see different colors, the count of each color tells you what the
 // position for that color in the rgb orering should be.  So, for example, if you see 1 Blue, and 2
 // Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).
-//
+
 // You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
 // and it should come out correctly, 1 red, 2 green, and 3 blue.
 //
@@ -37,21 +37,21 @@
    	delay(2000);

       // Uncomment one of the following lines for your leds arrangement.
-      // LEDS.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);

-      // LEDS.addLeds<WS2801, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<SM16716, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);

-      // LEDS.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
-      // LEDS.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
 }

 void loop() {
@@ -61,6 +61,6 @@
    leds[3] = CRGB::Blue;
    leds[4] = CRGB::Blue;
    leds[5] = CRGB::Blue;
-   LEDS.show();
+   FastLED.show();
    delay(1000);
 }


Update for R sensors

Update for R sensors


Minor bug fixes and code tweeks

Minor bug fixes and code tweeks

--- FH_Tbot.ino
+++ FH_Tbot.ino
@@ -84,7 +84,7 @@
 boolean pingOn = false;
 long nextBoredBotEvent = 0;
 int boredBotTimeout = 60000;//in ms
-#define Diag                             // if not defined disables serial communication after initial feedback
+//#define Diag                             // if not defined disables serial communication after initial feedback

 void Stop(void)
 {


Delete R_PIDITR.ino

Delete R_PIDITR.ino


uint8 instead of int

uint8 instead of int

--- resilient_network/resilient_network.ino
+++ resilient_network/resilient_network.ino
@@ -149,11 +149,11 @@

 void readActiveBus() {
   while(bus[activeBus]->available()) {
-    int message = int(bus[activeBus]->read());
     // if(SERIAL_DEBUG) {
     //   Serial.print("a");
     //   Serial.println(activeBus);
     // }
+    uint8_t message = bus[activeBus]->read();
     if(message != 0) {
       if(SERIAL_DEBUG) {
         Serial.print(activeBus);


removed incorrect file

removed incorrect file

--- hardware/REV14/rn2483test/rn2483test.ino
+++ hardware/REV14/rn2483test/rn2483test.ino
@@ -1,56 +0,0 @@
-uint8_t ch = 0;
-
-void setup() {
-  // put your setup code here, to run once:
-  Serial.begin(19200);
-  Serial.println("start");
-}
-
-void loop() {
-  // put your main code here, to run repeatedly:
-  uint8_t inBuf[64];
-  uint8_t outBuf[128];
-
-  for(uint8_t i = 0; i < sizeof(inBuf); i++) {
-    inBuf[i] = i + (ch * sizeof(inBuf));
-  }
-
-  Serial.print("ReturnVal: ");
-  Serial.println(getHex(inBuf, outBuf, sizeof(outBuf)));
-  for(uint8_t i = 0; i < sizeof(inBuf); i++) {
-    Serial.print(inBuf[i], HEX);
-  }
-  Serial.println();
-  Serial.write(outBuf, sizeof(outBuf));
-  Serial.println();
-  Serial.println();
-  ch++;
-  while (ch == 4) {}
-  delay(500);
-}
-
-bool getHex(const uint8_t *string, uint8_t *output, uint8_t outputLen)
-{
-  if((string || output) == NULL) return false; // check for null pointer
-    uint8_t counter = outputLen;
-    // convert to hex
-  while(counter) {
-    uint8_t highValue = *string >> 4;
-    uint8_t lowValue  = *string & 0x0f;
-    uint8_t temp;
-
-    temp = highValue;
-    if(temp <= 9) temp += '0';
-    else temp += ('A' - 10);
-    *output++ = temp;
-
-    temp = lowValue;
-    if(temp <= 9) temp += '0';
-    else temp += ('A'-10);
-    *output++ = temp;
-
-    string++;
-    counter -= 2;
-  }
-  return true;
-}


Just some comments

Just some comments

--- Code/Arduino/SpaceView/SpaceView.ino
+++ Code/Arduino/SpaceView/SpaceView.ino
@@ -80,14 +80,12 @@
   }

   //Write header to logfile
-  logfile.println("Time,Latitude,Longitude,Altitude,Pressure,Temperature,Acceleration_x,Acceleration_y,Acceleration_z,Gyro_x,Gyro_y,Gyro_z");
+  logfile.println("Time (HH:MM:SS),Latitude (°),Longitude (°),Altitude (m),Pressure (hPa),Temperature (°C),Acceleration_x (gs),Acceleration_y (gs),Acceleration_z (gs),Gyro_x (rad/s),Gyro_y (rad/s),Gyro_z (rad/s)");

   //GPS Setup
-  gps.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
-  // Use a 1 hz, once a second, update rate.
-  gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
-  // Enable the interrupt to parse GPS data.
-  enableGPSInterrupt();
+  gps.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY); //Minimum updates, only updates position and time
+  gps.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // Use a 1 hz, once a second, update rate.
+  enableGPSInterrupt(); // Enable the interrupt to parse GPS data.

   //setup_complete
   setup_complete();


Enabled error reporting

Enabled error reporting

--- Arduino/hardware/V0p2_Main_PCB_REV7_DORM1_and_REV8/REV7RadValve/REV7RadValve.ino
+++ Arduino/hardware/V0p2_Main_PCB_REV7_DORM1_and_REV8/REV7RadValve/REV7RadValve.ino
@@ -296,6 +296,9 @@

 // Managed JSON stats.
 OTV0P2BASE::SimpleStatsRotation<13> ss1; // Configured for maximum different stats.
+
+// Error reporting
+OTV0P2BASE::ErrorReport ErrorReporter;

 /******************************************************************************
@@ -485,11 +488,8 @@

     // Show reset counter. Low priority.
     ss1.put(V0p2_SENSOR_TAG_F("R"), resetCount, true);
-    // Send minimum stack left, saturating at 255 bytes.
-    const size_t curMinSP = OTV0P2BASE::MemoryChecks::getMinSP();
-    const uint8_t txMinSP = (255U >= curMinSP) ? (uint8_t) curMinSP : 255U;
-    ss1.put(V0p2_SENSOR_TAG_F("SP"), txMinSP, true);
-
+    // Send error reports.
+    ss1.put(ErrorReporter, true);

     const uint8_t privacyLevel = OTV0P2BASE::stTXalwaysAll;
     // Redirect JSON output appropriately.
@@ -920,6 +920,8 @@
             // Recompute target, valve position and call for heat, etc.
             // Should be called once per minute to work correctly.
             NominalRadValve.read();
+            // Update/age errors and warnings.
+            ErrorReporter.read();
             break;
         }
         // Stats samples; should never be missed.


Add mode for jumping to particular videos by index

--- Arduino/LightPlayer/LightPlayer.ino
+++ Arduino/LightPlayer/LightPlayer.ino
@@ -43,6 +43,7 @@
   COLOR_CEILING,
   COLOR_FLOOR,
   VIDEO_PLAYBACK,
+  CYCLE_BULBS,
   MACRO,
   MISC,
   ROOT_DIR_ON_RELEASE,
@@ -75,6 +76,8 @@
   uint8_t reset_settings;

   uint8_t toggle_frame_len;
+
+  uint8_t cycle_bulbs;
 };

 volatile PendingOperations GlobalPendingOperations;
@@ -246,6 +249,10 @@
   if (ops.toggle_negative)     Serial.print(F("\ntoggle_negative"));
   if (ops.reset_settings)      Serial.print(F("\nreset_settings"));
   if (ops.toggle_frame_len)    Serial.print(F("\ntoggle_frame_len"));
+  if (ops.cycle_bulbs & 64)    Serial.print(F("\ncycle bulb 4"));
+  if (ops.cycle_bulbs & 16)    Serial.print(F("\ncycle bulb 3"));
+  if (ops.cycle_bulbs & 4)     Serial.print(F("\ncycle bulb 2"));
+  if (ops.cycle_bulbs & 1)     Serial.print(F("\ncycle bulb 1"));
 }

 void printSettings()
@@ -295,6 +302,22 @@
   high.ceil = ColorIntensity::MAX;
 }

+void cycleBulbs(uint8_t which_bulbs)
+{
+  for (int bulb = 64; bulb > 0; bulb /= 4) {
+    if (which_bulbs & bulb) {
+      uint8_t start = curr_index - 1;
+      // Cycle until the first video such that:
+      // 1) its 0-based index is a multiple of this bulb val
+      // 2) its index is not more than this bulb val from the starting index
+      do {
+        nextFile();
+      } while ((curr_index - 1) % bulb != 0
+               || (bulb < 64 && (curr_index-1) / (bulb*4) != start / (bulb*4)));
+    }
+  }
+}
+
 void performPendingOperations(PendingOperations & ops)
 {
 #ifdef DEBUG
@@ -320,6 +343,7 @@
   if (ops.toggle_negative)     negative = !negative;
   if (ops.reset_settings)      resetDefaultSettings();
   if (ops.toggle_frame_len)    frame_len = (frame_len == MAX_FRAME_LEN ? MIN_FRAME_LEN : frame_len+1);
+  if (ops.cycle_bulbs)         cycleBulbs(ops.cycle_bulbs);

 #ifdef DEBUG
   if (    ops.cycle_brightness
@@ -340,7 +364,8 @@
        || ops.skip_forward
        || ops.toggle_negative
        || ops.reset_settings
-       || ops.toggle_frame_len)
+       || ops.toggle_frame_len
+       || ops.cycle_bulbs)
   {
     printSettings();
   }
@@ -378,6 +403,10 @@

         case Pressed::c: {
           CurrentMode = Mode::MACRO;
+        } break;
+
+        case Pressed::ac: {
+          CurrentMode = Mode::CYCLE_BULBS;
         } break;

         case Pressed::bc: {
@@ -554,6 +583,35 @@
       }
     } break;

+    case Mode::CYCLE_BULBS: {
+      switch (button_states) {
+        case Pressed::a: {
+          GlobalPendingOperations.cycle_bulbs |= 64;
+        } break;
+
+        case Pressed::b: {
+          GlobalPendingOperations.cycle_bulbs |= 16;
+        } break;
+
+        case Pressed::c: {
+          GlobalPendingOperations.cycle_bulbs |= 4;
+        } break;
+
+        case Pressed::d: {
+          GlobalPendingOperations.cycle_bulbs |= 1;
+        } break;
+
+        case Pressed::ac:
+        case Pressed::none: {
+          // Do nothing
+        } break;
+
+        default: {
+          CurrentMode = Mode::NORMAL;
+        } break;
+      }
+    } break;
+
     case Mode::ROOT_DIR_ON_RELEASE: {
       if (button_states == Pressed::none) {
         Context = &RootContext;


Update version info

Update version info

--- Arduino/McLighting/version_info.ino
+++ Arduino/McLighting/version_info.ino
@@ -92,5 +92,10 @@
  * 16 Apr 2019
  * - fix all issues with 2.2.3 (REST API)
  * - #368 WDT fix
- # - #371 E1.31 fix
+ * - #371 E1.31 fix
+ *
+ * 05 Jul 2019 v2.2.5 (Hotfix)
+ * - fix all issues with 2.2.3 (REST API)
+ * - #415 wrong WS2812FXStripSettings.stripSize
+ * - #424 PROGMEM edit is broken
  */


cosmetic change in a name of a variable

cosmetic change in a name of a variable

--- minimalistthermostat.ino
+++ minimalistthermostat.ino
@@ -37,7 +37,7 @@
  * changes in version 0.10:
        * added temperatureCalibration to fix DHT measurements with existing thermostat
        * reduced END_OF_CYCLE_TIMEOUT to one sec since my HVAC controller
-          takes care of running the fan for a minute to evacuate the heat/cold
+          takes care of running the fan for a minute to evacuate the heat/cool air
           from the vents
        * added pushbullet notifications for heating on/off
        * added fan on/off setting via a cloud function
@@ -106,17 +106,17 @@
 *******************************************************************************/
 // D0 : relay: fan
 // D1 : relay: heat
-// D2 : relay: cold
+// D2 : relay: cool
 // D4 : DHT22
 // D3, D5~D7 : unused
 // A0~A7 : unused
 int fan = D0;
 int heat = D1;
-int cold = D2;
+int cool = D2;
 //TESTING_HACK
 int fanOutput;
 int heatOutput;
-int coldOutput;
+int coolOutput;

 /*******************************************************************************
  DHT sensor
@@ -203,10 +203,10 @@
   //declare and init pins
   pinMode(fan, OUTPUT);
   pinMode(heat, OUTPUT);
-  pinMode(cold, OUTPUT);
+  pinMode(cool, OUTPUT);
   myDigitalWrite(fan, LOW);
   myDigitalWrite(heat, LOW);
-  myDigitalWrite(cold, LOW);
+  myDigitalWrite(cool, LOW);

   //declare cloud variables
   //https://docs.particle.io/reference/firmware/photon/#particle-variable-
@@ -560,7 +560,7 @@
     myDigitalWrite(fan, LOW);
   }
   myDigitalWrite(heat, LOW);
-  myDigitalWrite(cold, LOW);
+  myDigitalWrite(cool, LOW);

   //start the minimum timer of this cycle
   minimumIdleTimer = 0;
@@ -597,7 +597,7 @@
   Particle.publish(PUSHBULLET_NOTIF, "Heat on" + getTime(), 60, PRIVATE);
   myDigitalWrite(fan, HIGH);
   myDigitalWrite(heat, HIGH);
-  myDigitalWrite(cold, LOW);
+  myDigitalWrite(cool, LOW);

   //start the minimum timer of this cycle
   minimumOnTimer = 0;
@@ -620,7 +620,7 @@
   Particle.publish(PUSHBULLET_NOTIF, "Heat off" + getTime(), 60, PRIVATE);
   myDigitalWrite(fan, LOW);
   myDigitalWrite(heat, LOW);
-  myDigitalWrite(cold, LOW);
+  myDigitalWrite(cool, LOW);
 }

 /*******************************************************************************
@@ -659,8 +659,8 @@
 {
   // int fan = D0;
   // int heat = D1;
-  // int cold = D2;
-  return coldOutput*4 + heatOutput*2 + fanOutput*1;
+  // int cool = D2;
+  return coolOutput*4 + heatOutput*2 + fanOutput*1;
 }

 /*******************************************************************************
@@ -720,8 +720,8 @@
   if (input == heat){
     heatOutput = status;
   }
-  if (input == cold){
-    coldOutput = status;
+  if (input == cool){
+    coolOutput = status;
   }
 }


Removed unused variable

Removed unused variable

--- src/CAN_send_manual/CAN_send_manual.ino
+++ src/CAN_send_manual/CAN_send_manual.ino
@@ -12,8 +12,6 @@
 uint32_t id = 0x100;
 uint8_t dlc = 8;
 unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
-
-String message;

 MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin


don't accept settings buttons when lcd is turned off

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -259,6 +259,10 @@
   timeLastPressedAlarmSetButton = currentMillis;

   Serial.println("Alarm Set Button Pressed");
+
+  if(!showLCD){
+    return;
+  }

   switch(currentState)
   {
@@ -304,6 +308,10 @@
   timeLastPressedTimeSetButton = currentMillis;

   Serial.println("Time Set Button Pressed");
+
+  if(!showLCD){
+    return;
+  }

   switch(currentState)
   {


display compile time on start

display compile time on start

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -18,8 +18,8 @@
 #define RXLED_PIN 17
 #define OLED_RESET_PIN A0

-#define INITIAL_TEXT "Happy 24th birthday\n Jason!\n\n\nBy: Yeo Kheng Meng\n14 May 2014"
-#define INITIAL_TEXT_DELAY 6000
+#define INITIAL_TEXT "Happy 24th birthday\n Jason!\n\nBy: Yeo Kheng Meng\n(14 May 2014)\n\nCompiled on:"
+#define INITIAL_TEXT_DELAY 8000
 #define MIN_TIME_BETWEEN_BUTTON_PRESSES 75  //Debouncing purposes
 #define BLINK_INTERVAL 100

@@ -462,6 +462,28 @@
   digitalWrite(RXLED_PIN, LOW);
   TXLED1;

+  Wire.begin();
+  RTC.begin();
+
+  if (!RTC.isrunning()) {
+    Serial.println("RTC is NOT running");
+  }
+
+  // This section grabs the current datetime and compares it to
+  // the compilation time.  If necessary, the RTC is updated.
+  DateTime now = RTC.now();
+  DateTime compiled = DateTime(__DATE__, __TIME__);
+
+  if (now.unixtime() < compiled.unixtime()) {
+    Serial.println("RTC is older than compile time! Updating");
+    RTC.adjust(DateTime(__DATE__, __TIME__));
+  }
+
+  char compiledDate[30];
+
+  compiled.toString(compiledDate, 30);
+
+

   // initialize with the OLED with I2C addr 0x3D (for the 128x64)
   display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
@@ -471,26 +493,16 @@
   display.setTextSize(1);
   display.setCursor(0,0);
   display.println(INITIAL_TEXT);
+
+  display.println(compiledDate);
+
+
   display.display();

   delay(INITIAL_TEXT_DELAY);

-  Wire.begin();
-  RTC.begin();
-
-  if (!RTC.isrunning()) {
-    Serial.println("RTC is NOT running");
-  }
-
-  // This section grabs the current datetime and compares it to
-  // the compilation time.  If necessary, the RTC is updated.
-  DateTime now = RTC.now();
-  DateTime compiled = DateTime(__DATE__, __TIME__);
-
-  if (now.unixtime() < compiled.unixtime()) {
-    Serial.println("RTC is older than compile time! Updating");
-    RTC.adjust(DateTime(__DATE__, __TIME__));
-  }
+
+

   pinMode(BUTTON_ALARM_SET_PIN, INPUT);
   pinMode(BUTTON_TIME_SET_PIN, INPUT);


increase sleep time to 30

increase sleep time to 30

--- vibrate_alarm_clock.ino
+++ vibrate_alarm_clock.ino
@@ -118,7 +118,7 @@

   //Only power down in normal mode, the rest of the time, at max performance
   if(currentState == NORMAL) {
-      LowPower.powerDown(SLEEP_15Ms, ADC_OFF, BOD_OFF);
+      LowPower.powerDown(SLEEP_30Ms, ADC_OFF, BOD_OFF);

       //This is to give the Arduino sufficient time to wake up. Without this, the alarm may not engage as I suspect the millis() is affected
       delay(15);


Add static IP config option to IRMQTTServer (#480)

* Allow an easy method for users to use a static (non-dhcp) method for IP setup.
* Clarify some of the implications of changing HOSTNAME.

Fixes #478

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -133,7 +133,19 @@
 #define IR_LED 4
 // define IR_LED 3  // For an ESP-01 we suggest you use RX/GPIO3/Pin 7.
 #define HTTP_PORT 80  // The port the HTTP server is listening on.
-#define HOSTNAME "ir_server"  // Name of the device you want in mDNS.
+// Name of the device you want in mDNS.
+// NOTE: Changing this will change the MQTT path too unless you override it
+//       via MQTTprefix below.
+#define HOSTNAME "ir_server"
+
+// We obtain our network config via DHCP by default but allow an easy way to
+// use a static IP config.
+#define USE_STATIC_IP false  // Change to 'true' if you don't want to use DHCP.
+#if USE_STATIC_IP
+const IPAddress kIPAddress = IPAddress(10, 0, 1, 78);
+const IPAddress kGateway = IPAddress(10, 0, 1, 1);
+const IPAddress kSubnetMask = IPAddress(255, 255, 255, 0);
+#endif  // USE_STATIC_IP

 #ifdef MQTT_ENABLE
 // Address of your MQTT server.
@@ -832,6 +844,10 @@
   // We start by connecting to a WiFi network

   wifiManager.setTimeout(300);  // Time out after 5 mins.
+#if USE_STATIC_IP
+  // Use a static IP config rather than the one supplied via DHCP.
+  wifiManager.setSTAStaticIPConfig(kIPAddress, kGateway, kSubnetMask);
+#endif  // USE_STATIC_IP
   if (!wifiManager.autoConnect()) {
     debug("Wifi failed to connect and hit timeout.");
     delay(3000);


Add some code to send the IP the yun gets from DHCP so people can connect to it

--- bsd/bsd.ino
+++ bsd/bsd.ino
@@ -1,16 +1,16 @@
 /**
- * A small project at the request of my friedn and colleague @ffeldmann
- * This is an arduino sketch that runs on the Arduino Yun.
- * This project shows a webpage where people can press the "BullShit" button which in turns will trigger an alarm and light some pixels
- *
- * BSDetector is a microservice accessible as a REST endpoint - seriously :)
- * REST endpoints can be (GET) called over http as follow
- * "http://${ARDUINO_IP}/arduino/bs/0"     -> set BS allarm off
- * "http://${ARDUINO_IP}/arduino/bs/1"     -> set BS allarm on
- * "http://${ARDUINO_IP}/arduino/health"   -> returns info on how many times one calls bullshit, plus other thinks
- *
- * @author Bruno P. Georges
- */
+   A small project at the request of my friedn and colleague @ffeldmann
+   This is an arduino sketch that runs on the Arduino Yun.
+   This project shows a webpage where people can press the "BullShit" button which in turns will trigger an alarm and light some pixels
+
+   BSDetector is a microservice accessible as a REST endpoint - seriously :)
+   REST endpoints can be (GET) called over http as follow
+   "http://${ARDUINO_IP}/arduino/bs/0"     -> set BS allarm off
+   "http://${ARDUINO_IP}/arduino/bs/1"     -> set BS allarm on
+   "http://${ARDUINO_IP}/arduino/health"   -> returns info on how many times one calls bullshit, plus other thinks
+
+   @author Bruno P. Georges
+*/

 #include <Bridge.h>
 #include <BridgeServer.h>
@@ -27,6 +27,7 @@
 uint16_t bshits = 0;  // bs counter, cater for enough
 #define BS_PIN 12     // will lite when BS is called
 #define BOOT_PIN 12   // will flash when arduino init to show all will go well.
+#define ADMIN_EMAIL "bruno.georges@gmail.com"

 // TONES
 #define SPEAKER_PIN  9 // must be a PWM pin (digital 9, 10 or 11)
@@ -39,11 +40,14 @@

 // The YUN IP Address. Value will be set from DHCP leased IP during setup()
 String yunAddr;
-// the url to access the Yun REST enpoints
-String bsURL; //
+// the url to access the Yun REST enpoints
+String bsURL; //

 // no serial, using BOOT_PIN to show things are going as planned.
 void setup() {
+  SerialUSB.begin(9600);
+  delay(1000);
+  SerialUSB.println("Serial USB Open");
   pinMode(SPEAKER_PIN, OUTPUT);
   pinMode(BOOT_PIN, OUTPUT);
   pixels.begin();
@@ -53,12 +57,11 @@
   server.begin();
   yunAddr = getIPaddr();
   bsURL = "http://" + yunAddr + "/arduino/";
-  // set the ipaddr value with the one we got from DHCP
   flashLed(BOOT_PIN, 2, 100);
   makeNoise(2, tones[1], 100);
+  sendIP();
   ledOFF();
 }
-

 void loop() {
   BridgeClient client = server.accept();
@@ -157,8 +160,7 @@
   }
 }

-
-String getIPaddr(){
+String getIPaddr() {
   String ipaddr;
   Process networkCheck;  // initialize a new process
   networkCheck.runShellCommand("ifconfig br-wan | awk '/inet addr/ {gsub(\"addr:\", \"\", $2); print $2}' ");
@@ -168,3 +170,12 @@
   }
   return ipaddr;
 }
+
+void sendIP() {
+  Process p;
+  String link= "http://"+yunAddr+"\/arduino\/bs";
+  p.runShellCommand("cat /mnt/sd/mail_header.txt > /mnt/sd/mail.txt");
+  p.runShellCommand("echo \""+link+"\" >>  /mnt/sd/mail.txt");
+  p.runShellCommand("cat /mnt/sd/mail.txt | ssmtp bruno.georges@gmail.com bruno@redhat.com ffeldman@redhat.com"); //
+}
+


Use assert macro for print out system info

--- tests/TestSystemInfo/TestSystemInfo.ino
+++ tests/TestSystemInfo/TestSystemInfo.ino
@@ -6,19 +6,14 @@
 #include <RabirdToolkit.h>

 #include <RTest.h>
-#include <RRawPointer.h>
-#include <RSharedPointer.h>
-#include <RFormatter.h>

 RTEST(TestSystemInfo)
 {
-  RFormatter formatter(manager()->printer());
-
-  formatter("Size of int : %s").arg(sizeof(int));
-  formatter("Size of uintptr_t : %s").arg(sizeof(uintptr_t));
-  formatter("Size of rsize : %s").arg(sizeof(rsize));
-  formatter("Size of rnumber : %s").arg(sizeof(rnumber));
-  formatter("Size of ruint : %s").arg(sizeof(ruint));
+  RASSERT_MORE(sizeof(int), 0);
+  RASSERT_MORE(sizeof(uintptr_t), 0);
+  RASSERT_MORE(sizeof(rsize), 0);
+  RASSERT_MORE(sizeof(rnumber), 0);
+  RASSERT_MORE(sizeof(ruint), 0);
 };

 void


added cny7' values for painted chips (using acrylic paint)

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -10,10 +10,10 @@
 int color[9];

 //Color limits
-int redLow = 0;
-int redHigh = 0;
-int greenLow = 0;
-int greenHigh = 0;
+int redLow = 45;
+int redHigh = 55;
+int greenLow = 100;
+int greenHigh = 115;

 //Reds, 0 or 1
 int reds[9] = {0,0,0,0,0,0,0,0,};


Moved most strings and literals to flash.

--- webserver.ino
+++ webserver.ino
@@ -3,34 +3,37 @@
 //holds the current upload
 File fsUploadFile;

+const char textplainHEADER[] PROGMEM = "text/plain";
+const char texthtmlHEADER[] PROGMEM = "text/html";
+
 void setupWebServer() {

   ////////////////////////////////////////////////////////////////////////////////////
   //the web interface pages alphabetically

   //handle the index page
-  if ( SPIFFS.exists( "/index.htm" ) ) {
+  if ( SPIFFS.exists( F( "/index.htm" ) ) ) {
     webServer.serveStatic( "/", SPIFFS, "/index.htm" );
     webServer.serveStatic( "/index.htm", SPIFFS, "/index.htm" );
   } else {
     webServer.on( "/", []() {
-      webServer.send( 200, "text/plain", "No index.htm present during boot.\nUpload index.htm and reset controller" );
+      webServer.send( 200, FPSTR( textplainHEADER ), F( "No index.htm present during boot.\nUpload index.htm and reset controller" ) );
     });
   }

   //handle the filemanager
-  if ( SPIFFS.exists( "/filemanager.htm" ) ) {
+  if ( SPIFFS.exists( F( "/filemanager.htm" ) ) ) {
     webServer.serveStatic( "/filemanager", SPIFFS, "/filemanager.htm" );
     webServer.serveStatic( "/filemanager.htm", SPIFFS, "/filemanager.htm" );
   } else {
     webServer.on( "/filemanager", []() {
-      webServer.send( 200, "text/plain", "No filemanager present during boot.\nUpload index.htm and reset controller" );
+      webServer.send( 200, FPSTR( textplainHEADER ), F( "No filemanager present during boot.\nUpload index.htm and reset controller" ) );
     });
   }

   //handle the timer editor
   webServer.on( "/editor", []() {
-    webServer.send( 200, "text/html", "editor" );
+    webServer.send( 200, FPSTR( texthtmlHEADER ), F( "editor" ) );
   });

   //handle the file editor
@@ -40,7 +43,7 @@

   //handle the setup page
   webServer.on( "/setup", []() {
-    webServer.send( 200, "text/html", "setup page" );
+    webServer.send( 200, FPSTR( texthtmlHEADER ), F( "setup page" ) );
   });

   /////////////////////////////////////////////////////////////////////////////////////
@@ -50,25 +53,25 @@

   webServer.on( "/api/cleareeprom", []() {
     clearEEPROM();
-    webServer.send( 200, "text/plain", "EEPROM cleared" );
+    webServer.send( 200, FPSTR( textplainHEADER ), F( "EEPROM cleared" ) );
   });

   webServer.on( "/api/diskspace", []() {
     FSInfo fs_info;
     SPIFFS.info(fs_info);
     size_t diskSpace = fs_info.totalBytes - fs_info.usedBytes;
-    webServer.send( 200, "text/plain", String( diskSpace ) );
+    webServer.send( 200, FPSTR( textplainHEADER ), String( diskSpace ) );
   });

   webServer.on( "/api/formatspiffs", []() {
     OLED.clear();
     OLED.setTextAlignment( TEXT_ALIGN_CENTER );
     OLED.setFont( ArialMT_Plain_16 );
-    OLED.drawString( 64, 10, F("Formatting" ) );
-    OLED.drawString( 64, 30, F("Please wait..." ) );
+    OLED.drawString( 64, 10, F( "Formatting" ) );
+    OLED.drawString( 64, 30, F( "Please wait..." ) );
     OLED.display();
     SPIFFS.format();
-    webServer.send( 200, "text/plain", "SPIFFS disk formatted" );
+    webServer.send( 200, FPSTR( textplainHEADER ), F( "SPIFFS disk formatted" ) );
   });

   webServer.on( "/api/files", []() {
@@ -82,7 +85,7 @@
         HTTPresponse += fileName + "," + formatBytes( fileSize ) + "|";
       }
     }
-    webServer.send( 200, "text/plain", HTTPresponse );
+    webServer.send( 200, FPSTR( textplainHEADER ), HTTPresponse );
   });

   webServer.on( "/api/getpercentage", []() {
@@ -92,7 +95,7 @@
     }
     HTTPresponse += formattedTime( localTime() ) + F( "," );
     HTTPresponse += lightStatus;
-    webServer.send( 200, "text/plain", HTTPresponse );
+    webServer.send( 200, FPSTR( textplainHEADER ), HTTPresponse );
   });

   webServer.on( "/api/hostname", []() {
@@ -102,17 +105,17 @@
       //check for illegal characters --legal chars are alphanumeric
       for ( byte thisChar = 0; thisChar < newHostName.length(); thisChar++ ) {
         if ( !isAlphaNumeric( newHostName[thisChar] ) || isSpace( newHostName[thisChar] ) ) {
-          webServer.send( 200, "text/plain", "ERROR - Invalid character in hostname." );
+          webServer.send( 200, FPSTR( textplainHEADER ), F( "ERROR - Invalid character in hostname." ) );
           return;
         }
       }
       WIFIhostname = newHostName;
       hostNameChanged = true;
       writeWifiDataToEEPROM();
-      webServer.send( 200, "text/plain", "Hostname set to " + WIFIhostname);
+      webServer.send( 200, FPSTR( textplainHEADER ), "Hostname set to " + WIFIhostname);
       return;
     }
-    webServer.send( 200, "text/plain", WiFi.hostname() );
+    webServer.send( 200, FPSTR( textplainHEADER ), WiFi.hostname() );
   });

   webServer.on( "/api/lightsoff", []() {
@@ -122,7 +125,7 @@
       channel[thisChannel].currentPercentage = 0;
     }
     lightStatus = F( "Lights are off." );
-    webServer.send( 200, "text/plain", lightStatus );
+    webServer.send( 200, FPSTR( textplainHEADER ), lightStatus );
   });

   webServer.on( "/api/lightson", []() {
@@ -132,56 +135,56 @@
       channel[thisChannel].currentPercentage = 100;
     }
     lightStatus = F( "Lights are on." );
-    webServer.send( 200, "text/plain", lightStatus );
+    webServer.send( 200, FPSTR( textplainHEADER ), lightStatus );
   });

   webServer.on( "/api/lightsprogram", []() {
     programOverride = false;
     updateChannels();
     lightStatus = F( "Lights controlled by program." );
-    webServer.send( 200, "text/plain", lightStatus );
+    webServer.send( 200, FPSTR( textplainHEADER ), lightStatus );
   });

   webServer.on( "/api/pwmfrequency", []() {
     if ( webServer.arg( "newpwmfrequency" ) != "" ) {
       int tempPWMfrequency = webServer.arg( "newpwmfrequency" ).toInt();
       if ( tempPWMfrequency < 1 || tempPWMfrequency > 1000 ) {
-        webServer.send( 200, "text/plain", "Invalid PWM frequency" );
+        webServer.send( 200, FPSTR( textplainHEADER ), F( "Invalid PWM frequency" ) );
         return;
       }
       PWMfrequency = tempPWMfrequency;
       analogWriteFreq( PWMfrequency );
     }
-    webServer.send( 200, "text/plain", "PWM frequency is " + String( PWMfrequency ) );
+    webServer.send( 200, FPSTR( textplainHEADER ),  "PWM frequency is " + String( PWMfrequency ) );
   });

   webServer.on( "/api/pwmdepth", []() {
     if ( webServer.arg( "newpwmdepth" ) != "" ) {
       unsigned int newPWMdepth = webServer.arg( "newpwmdepth" ).toInt();
       if ( newPWMdepth < 1023 || newPWMdepth > 10230 ) {
-        webServer.send( 200, "text/plain", "ERROR - Invalid PWM depth" );
+        webServer.send( 200, FPSTR( textplainHEADER ), F( "ERROR - Invalid PWM depth" ) );
         return;
       }
       PWMdepth = newPWMdepth;
     }
-    webServer.send( 200, "text/plain", "PWM depth is " + String( PWMdepth ) );
+    webServer.send( 200, FPSTR( textplainHEADER ), "PWM depth is " + String( PWMdepth ) );
   });

   webServer.on( "/api/timezone", []() {
     if ( webServer.arg( "newtimezone" ) != "" ) {
       int newTimeZone = webServer.arg( "newtimezone" ).toInt();
       if ( newTimeZone < -13 || newTimeZone > 13 ) {
-        webServer.send( 200, "text/plain", "ERROR - Invalid timezone" );
+        webServer.send( 200, FPSTR( textplainHEADER ), F( "ERROR - Invalid timezone" ) );
         return;
       }
       timeZone = newTimeZone;
       updateChannels();
     }
-    webServer.send( 200, "text/plain", "Timezone is " + String( timeZone ) );
+    webServer.send( 200, FPSTR( textplainHEADER ), "Timezone is " + String( timeZone ) );
   });

   webServer.on( "/api/upload", HTTP_POST, []() {
-    webServer.send( 200, "text/plain", "" );
+    webServer.send( 200, FPSTR( textplainHEADER ), "" );
   }, []() {
     HTTPUpload& upload = webServer.upload();
     if ( upload.status == UPLOAD_FILE_START ) {
@@ -204,7 +207,7 @@
   //done with setup, start the server
   webServer.begin();

-  Serial.print( "HTTP web server started at IP address: "  );
+  Serial.print( F( "HTTP web server started at IP address: " ) );
   Serial.println( WiFi.localIP() );
 }

@@ -218,21 +221,21 @@
   // try to use the argument as filename and serve from SPIFFS
   // if no matching file is found, throw an error.
   if ( !handleSPIFFSfile( webServer.uri() ) ) {
-    Serial.println( "404 File not found." );
-    webServer.send( 404, "text/plain", "404 - File not found." );
+    Serial.println( F( "404 File not found." ) );
+    webServer.send( 404, FPSTR( textplainHEADER ), F( "404 - File not found." ) );
   }
 }

 bool handleSPIFFSfile( String path ) {
   path = webServer.urlDecode( path );
-  if ( path.endsWith( "/" ) ) path += "index.htm";
+  if ( path.endsWith( "/" ) ) path += F( "index.htm" );

   if ( SPIFFS.exists( path ) ) {
     if ( webServer.arg( "action" ) == "delete" ) {
-      Serial.println( "Delete request. Deleting..." );
+      Serial.println( F( "Delete request. Deleting..." ) );
       SPIFFS.remove( path );
-      Serial.println( path + " deleted" );
-      webServer.send( 200, "text/plain", path + " deleted" );
+      Serial.println( path + F( " deleted" ) );
+      webServer.send( 200, FPSTR( textplainHEADER ), path + " deleted" );
       return true;
     };
     File file = SPIFFS.open( path, "r" );
@@ -266,36 +269,36 @@
   while ( dir.next() ) {
     fileName = dir.fileName();
     size_t fileSize = dir.fileSize();
-    Serial.printf( "FS File: %s, size: %s\n", fileName.c_str(), formatBytes( fileSize ).c_str() );
+    Serial.printf( "FS File: %s, size: %s\n" , fileName.c_str(), formatBytes( fileSize ).c_str() );
     HTTPresponse += "
" +fileName + "" + formatBytes( fileSize ) + "
";
   }
   HTTPresponse += "
";
-  Serial.printf("\n");
-
-  webServer.send( 200, "text/html", uploadHTMLheader + HTTPresponse + uploadForm + uploadHTMLfooter);
+  Serial.println();
+
+  webServer.send( 200, FPSTR( texthtmlHEADER ), uploadHTMLheader + HTTPresponse + uploadForm + uploadHTMLfooter);
 }

 static String getContentType( const String& path) {
   if (path.endsWith(".html")) return "text/html";
-  else if (path.endsWith(".htm")) return "text/html";
-  else if (path.endsWith(".css")) return "text/css";
-  else if (path.endsWith(".txt")) return "text/plain";
-  else if (path.endsWith(".js")) return "application/javascript";
-  else if (path.endsWith(".png")) return "image/png";
-  else if (path.endsWith(".gif")) return "image/gif";
-  else if (path.endsWith(".jpg")) return "image/jpeg";
-  else if (path.endsWith(".ico")) return "image/x-icon";
-  else if (path.endsWith(".svg")) return "image/svg+xml";
-  else if (path.endsWith(".ttf")) return "application/x-font-ttf";
-  else if (path.endsWith(".otf")) return "application/x-font-opentype";
-  else if (path.endsWith(".woff")) return "application/font-woff";
-  else if (path.endsWith(".woff2")) return "application/font-woff2";
-  else if (path.endsWith(".eot")) return "application/vnd.ms-fontobject";
-  else if (path.endsWith(".sfnt")) return "application/font-sfnt";
-  else if (path.endsWith(".xml")) return "text/xml";
-  else if (path.endsWith(".pdf")) return "application/pdf";
-  else if (path.endsWith(".zip")) return "application/zip";
-  else if(path.endsWith(".gz")) return "application/x-gzip";
-  else if (path.endsWith(".appcache")) return "text/cache-manifest";
-  return "application/octet-stream";
-}
+  else if (path.endsWith(".htm")) return F( "text/html" );
+  else if (path.endsWith(".css")) return F( "text/css" );
+  else if (path.endsWith(".txt")) return F( "text/plain" );
+  else if (path.endsWith(".js")) return F( "application/javascript" );
+  else if (path.endsWith(".png")) return F( "image/png" );
+  else if (path.endsWith(".gif")) return F( "image/gif" );
+  else if (path.endsWith(".jpg")) return F( "image/jpeg" );
+  else if (path.endsWith(".ico")) return F( "image/x-icon" );
+  else if (path.endsWith(".svg")) return F( "image/svg+xml" );
+  else if (path.endsWith(".ttf")) return F( "application/x-font-ttf" );
+  else if (path.endsWith(".otf")) return F( "application/x-font-opentype" );
+  else if (path.endsWith(".woff")) return F( "application/font-woff" );
+  else if (path.endsWith(".woff2")) return F( "application/font-woff2" );
+  else if (path.endsWith(".eot")) return F( "application/vnd.ms-fontobject" );
+  else if (path.endsWith(".sfnt")) return F( "application/font-sfnt" );
+  else if (path.endsWith(".xml")) return F( "text/xml" );
+  else if (path.endsWith(".pdf")) return F( "application/pdf" );
+  else if (path.endsWith(".zip")) return F( "application/zip" );
+  else if(path.endsWith(".gz")) return F( "application/x-gzip" );
+  else if (path.endsWith(".appcache")) return F( "text/cache-manifest" );
+  return F( "application/octet-stream" );
+}


volatile

volatile

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -42,13 +42,13 @@
 WiFiUDP udp;

 // volatile
-float H  ;
-float T1 ;
-float T2 ;
-float OT ;
-float PW ;
-float NW ;
-int PIR  ;
+volatile float H  ;
+volatile float T1 ;
+volatile float T2 ;
+volatile float OT ;
+volatile float PW ;
+volatile float NW ;
+volatile int PIR  ;
 float dustDensity ;

 float OLD_H  ;
@@ -202,7 +202,7 @@
   }

   if ( receivedtopic == "esp8266/arduino/s06" ) {
-    NW  = root["NemoWeightAvg"];
+    NW  = root["NemoWeight"];
   }

   if ( receivedtopic == "raspberrypi/doorpir" )


Barometer example includes Altitude filter

--- examples/APM_Barometer/APM_Barometer.ino
+++ examples/APM_Barometer/APM_Barometer.ino
@@ -1,16 +1,12 @@
 #include "Wire.h"
 #include "SPI.h"
 #include "MINDS-i-Drone.h"
-/*
-Altimeter, get a raw value and maybe a converted value to feet?
-(through the Arduino Serial Terminal)
-*/

 MS5611 baro;
+Altitude altitude;
 SRAMstorage<float,2> storage;
 Settings settings(&storage);
 CommManager comms(&Serial, &storage);
-Altitude altitude;

 void setup(){
     Serial.begin(9600);
@@ -19,16 +15,16 @@
     delay(100);
     baro.calibrate();

-    altitude.setup(0.0);
-    settings.attach(0, 0.05, [](float g){ altitude.setBarometerGain(g); });
-    settings.attach(1, 0.02, [](float g){ altitude.setVelocityGain(g); });
+    settings.attach(0, 0.046f, [](float g){ altitude.setBarometerGain(g); });
+    settings.attach(1, 0.020f, [](float g){ altitude.setVelocityGain(g); });
 }
+
 void loop(){
     comms.update();
     baro.update();
     altitude.update(baro.getAltitude());

-    static auto timer = Interval::every(10);
+    static auto timer = Interval::every(250);
     if(timer()){
         float temp = baro.getCelsius();
         float bar  = baro.getMilliBar();
@@ -37,7 +33,7 @@
         comms.sendTelem(GROUNDSPEED, altitude.getVelocity());
         comms.sendTelem(VOLTAGE, temp);
         comms.sendTelem(AMPERAGE, bar);
-        comms.sendTelem(ALTITUDE, alt);
-        comms.sendTelem(ALTITUDE+1, altitude.getAltitude());
+        comms.sendTelem(ALTITUDE, altitude.getAltitude());
+        comms.sendTelem(ALTITUDE+1, alt);
     }
 }


Modify samples to use Arduboy2 library

Modify samples to use Arduboy2 library

--- examples/Sample1-Basic/Sample1-Basic.ino
+++ examples/Sample1-Basic/Sample1-Basic.ino
@@ -1,8 +1,8 @@
-#include <Arduboy.h>
+#include <Arduboy2.h>
 #include <ArdVoice.h>
 #include "voices.h"

-Arduboy arduboy;
+Arduboy2 arduboy;
 ArdVoice ardvoice;

 void setup() {


Fixed symlink to example code

Fixed symlink to example code

Signed-off-by: Roman3349 <6b7cbc66756660b4790b3af1ec1507653acaa035@centrum.cz>


fixed withoutLib_HS

fixed withoutLib_HS

- Now Compatible with ARDUINO MEGA
- Clean and correct ordered response

--- examples/withoutLib_HS/withoutLib_HS.ino
+++ examples/withoutLib_HS/withoutLib_HS.ino
@@ -1,34 +1,47 @@
 /*
-  1 - THIS DOES NOT USES CS5490 LIBRARY, use only if you want to understand
+  1 - THIS EXAMPLE DOES NOT USES CS5490 LIBRARY, use only if you want to understand
 only if you are having some trouble or needs to understante how it works

   2 - THIS EXAMPLES USES SoftwareSerial library, it means that will be useful
 only for ARDUINO MEGA, ESP32 and others with multiple hardware serial components
 */

+byte data[3]; //data buffer
+
 void setup(){
   // Open serial communications and wait for port to open:
   Serial.begin(115200);
-  while (!Serial) {
-    ; // wait for serial port to connect. Needed for Leonardo only
-  }
-  // set the data rate for the SoftwareSerial port
+  // wait for serial port to connect. Needed for Leonardo only
+  while (!Serial);
+  // set the data rate for the HardwareSerial 2 port
   Serial2.begin(600);
-  //Defines the page for the register address
-  Serial2.write(0b10010000); //Select Page 16
 }

 void loop(){
-  Serial2.write(0x31); //Read Address 49
-  while (Serial2.available() > 3){ //Wait for 3 bytes to arrive
-    char inByte = Serial2.read();
-    Serial.print(inByte,HEX);
-    inByte = Serial2.read();
-    Serial.print(inByte,HEX);
-    inByte = Serial2.read();
-    Serial.print(inByte,HEX);
-    //The result must be 9A991
-  }
-  Serial.println("");
+
+  /* The default value is: 01999A */
+  clearSerial2Buffer();
+  Serial2.write(0b10010000); //Select Page 16
+  Serial2.write(0b00110001); //Read Address 49
+	//Wait for 3 bytes to arrive
+	while(Serial2.available() < 3);
+  //Read 3 byte information
+	for(int i=0; i<3; i++){
+		data[i] = Serial2.read();
+	}
+  //Data concatenation
+  uint32_t value = 0;
+  value = value + data[2] << 8;
+  value = value + data[1] << 8;
+  value = value + data[0];
+
+  Serial.println(value,HEX);
   delay(1000);
 }
+
+/* Clearing Serial2 Buffer */
+void clearSerial2Buffer(){
+  while(Serial2.available()){
+    Serial2.read();
+  }
+}


Beginning of variables

Beginning of variables

--- src/BLuB.ino
+++ src/BLuB.ino
@@ -28,8 +28,10 @@
 #define kRamSize (E2END + 1 )
 #define kEESize  (E2END + 1 )

+#define kNVariables (26)
+
 char programRam[ kRamSize ];
-
+int variables[ kNVariables ];

 int ramFree = 0;
 int eeFree = 0;
@@ -74,26 +76,13 @@
 	Serial.println( "" );
 	Serial.println( "Available commands:" );
 	//                   ------- ------- ------- ------- -------
-	Serial.println( "    help    mem     new" );
+	Serial.println( "    help    mem     new     list    run" );
 	Serial.println( "    elist   eload   esave   enew" );
 	//                   ------- ------- ------- ------- -------
 }

 ////////////////////////////////////////////////////////////////////////////////
-void setup()
-{
-	// set up serial port
-	Serial.begin( 9600 );
-	while( !Serial ) {
-		; // wait for Leonardo to catch up
-	}
-
-	Serial.println( "BLuB Interface" );
-	Serial.println( kBLuBVersion );
-	cmd_mem();
-}
-

 // getSerialLine
@@ -127,14 +116,14 @@

 void cmd_enew( void )
 {
-  Serial.print( "Formatting EEPROM " );
-  for( int i=0 ; i<kEESize ; i++ )
-  {
-    EEPROM.write( i, 0x00 );
-//    digitalWrite( kLED, i & 0x020 );
-    if( i%64 == 0 ) Serial.print( "." );
-  }
-  Serial.println( " Done." );
+	Serial.print( "Formatting EEPROM " );
+	for( int i=0 ; i<kEESize ; i++ )
+	{
+		EEPROM.write( i, 0x00 );
+		//    digitalWrite( kLED, i & 0x020 );
+		if( i%64 == 0 ) Serial.print( "." );
+	}
+	Serial.println( " Done." );
 }

 void cmd_elist( void )
@@ -184,18 +173,64 @@
 	Serial.println( " bytes saved." );
 }

+#define VarCharToIndex( A )\
+		( (A) - 'A' )
+
+void init_vars( void )
+{
+	for( int i=0 ; i<kNVariables ; i++ )
+	{
+		variables[i] = 0;
+	}
+
+	// (T)rue
+	variables[ VarCharToIndex( 'T' ) ] = 0xff;
+
+	// (H)alf
+	variables[ VarCharToIndex( 'H' ) ] = 0x80;
+
+	// (F)alse, (Z)ero
+	variables[ VarCharToIndex( 'F' ) ] = 0x00;
+	variables[ VarCharToIndex( 'Z' ) ] = 0x00;
+}
+
 void cmd_new( void )
 {
 	for( int i=0 ; i<kRamSize ; i++ )
 	{
 		programRam[ i ] = '\0';
 	}
+	init_vars();
+
 }

 void cmd_list( void )
 {
 	Serial.println( programRam );
 }
+
+void cmd_run( void )
+{
+	Serial.println( "Not yet." );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void setup()
+{
+	// set up serial port
+	Serial.begin( 9600 );
+	while( !Serial ) {
+		; // wait for Leonardo to catch up
+	}
+
+	Serial.println( "BLuB Interface" );
+	Serial.println( kBLuBVersion );
+	cmd_new();
+	init_vars();
+	cmd_mem();
+}
+

 #define kLineLen (32)
 char linebuf[kLineLen];
@@ -218,6 +253,9 @@
 	else if( !strcmp( linebuf, "elist" )) { cmd_elist(); }
 	else if( !strcmp( linebuf, "eload" )) { cmd_eload(); }
 	else if( !strcmp( linebuf, "esave" )) { cmd_esave(); }
+
+	else if( !strcmp( linebuf, "run" )) { cmd_run(); }
+
 	else if( linebuf[0] >= '0' && linebuf[0] <= '9' ) {
 		Serial.println( "Consume Line To Ram" );
 	}


Delete 4Digit7SegDisplay.ino

Delete 4Digit7SegDisplay.ino

--- DigiDip2/DigiDip2/4Digit7SegDisplay.ino
+++ DigiDip2/DigiDip2/4Digit7SegDisplay.ino
@@ -1,46 +0,0 @@
-/*
-@author Chase St. Laurent
-
-4 Digit 7 Segment display controlled by Potentiometer readings
-(Using Serial)
-
-*/
-#include <SoftwareSerial.h>
-#include <SoftwareSerial\src\SoftwareSerial.h>
-
-SoftwareSerial Serial7Segment(7, 8);
-
-int cycles = 0;
-
-void setup() {
-	Serial.begin(9600); //Start serial communication at 9600 for debug statements
-	Serial7Segment.begin(9600);
-	Serial7Segment.write('v');
-}
-
-void loop() {
-	int sensorValue = analogRead(A0);
-	Serial.println(sensorValue);
-	int correctionFactor = analogRead(A0) * 11;// Increase by a digit and scale
-	if (analogRead(A0) <= 999 && correctionFactor <= 9999) {
-		cycles = correctionFactor;
-	}
-	else {
-		cycles = 9999;
-	}
-
-	Serial.print("Cycle: ");
-	Serial.println(cycles);
-	sendValue(cycles);
-
-	delay(1000);
-}
-
-//Send the four characters to the display
-void sendValue(int tempCycles) {
-	char tempString[10];
-	sprintf(tempString, "%4d", tempCycles);
-	Serial7Segment.print(tempString);
-	delay(10);
-
-}


Delete mtt1.ino

Delete mtt1.ino


added kewly shit like conways do I need to say any more?

--- library/examples/AppManager/AppManager.ino
+++ library/examples/AppManager/AppManager.ino
@@ -25,6 +25,8 @@
 #include "ProfileApp.h"
 #include "StarsApp.h"
 #include "DilbertApp.h"
+#include "Conways.h"
+#include "NeoTestApp.h"

 /* #define USE_BUTTON_INTERRUPTS */

@@ -49,6 +51,8 @@
   appManager.addApp(new ButtonTestApp());
   appManager.addApp(new StarsApp());
   appManager.addApp(new DilbertApp());
+  appManager.addApp(new Conways());
+  appManager.addApp(new NeoTestApp());

   /* Small delay before app manager start (which turns on backlight) */
   delay(100);


doc and --- on display

doc and --- on display

--- firmware/application.ino
+++ firmware/application.ino
@@ -68,24 +68,31 @@

 	if (lcd != NULL) {
-	// Display design: (16x2 char)
+	// Display layout: (16x2 char)
 	// +----------------+
 	// |14:15 15/22`  5m|
 	// |mod rain     12m|
 	// +----------------+
 		lcd->clear();
 		displayCurrentTime(0, 0);
-		transport.displayDepartures(16, 2); // 16x2 Display

-		// print temperature in first row after the time
+		// Transport
+		if(!transport.displayDepartures(16, 2)) { // 16x2 Display
+			lcd->setCursor(16-3,0); //
+			lcd->print("---");
+		}
+
+
+		// Weather
 		weather_response_t resp = weather->cachedUpdate();
 		if ( resp.isSuccess) {
+			// print temperature in first row after the time
 			lcd->setCursor(6, 0);
 			lcd->print(resp.temp_low);
 			lcd->print("/");
 			lcd->print(resp.temp_high);
 			lcd->write(byte(degreeSignKey));
-			// print descr on new line
+			// print descr on second line
 			lcd->setCursor(0, 1);
 			int iconCode = getConditionIcon(resp.conditionCode);
 			if(iconCode >= 0) {
@@ -94,9 +101,10 @@
 				lcd->write(byte(iconCode));
 			}
 			lcd->print(shortDescr(resp.descr).substring(0,12));
+		} else {
+			lcd->setCursor(0, 1);
+			lcd->print("---");
 		}
-
-
 	}


Update web-stepper.ino

Update web-stepper.ino

--- firmware/web-stepper.ino
+++ firmware/web-stepper.ino
@@ -24,7 +24,7 @@
 {
   pinMode(stp, OUTPUT);
   pinMode(dir, OUTPUT);
-  digitalWrite(dir, LOW);
+  digitalWrite(dir, LOW); // to reverse motor direction, write DIR "HIGH"
   digitalWrite(stp, LOW);
   Serial.begin(9600); //Open Serial connection for debugging
   Serial.println("Starting up the Spice Machine web control...");


Fixed bug state was always PING_SCAN after random walk

--- fsm/fsm.ino
+++ fsm/fsm.ino
@@ -50,11 +50,10 @@

   if (currentState == STATE_MOVE_AND_AVOID) {
     // State 0: Move forward a set number of steps and then go to state 1. Avoid any objects.
-
+    currentState = STATE_PING_SCAN;
     randomWalk(0,0,5);  // Go forward dir during 3 sec

-    currentState = STATE_PING_SCAN;
-
+
   } else if (currentState == STATE_PING_SCAN) {
     // State 1: Use the sonar to search and find direction to a cylinder.
     time = millis();
@@ -63,7 +62,7 @@
       if(currentState != STATE_PING_SCAN)
         break;
     }
-
+
   } else if (currentState == STATE_CATCH_CYLINDER) {
     // State 2: Move towards a cylinder using IR to correct the path,
     // stop the robot once the element gets a connection.


Switch tft backlight off after SmartConfig finishes.

--- wifitask.ino
+++ wifitask.ino
@@ -61,6 +61,11 @@
     if ( !WiFi.smartConfigDone() )
     {
       ESP.restart();
+    }
+
+    if ( !xTftTaskHandle )
+    {
+      digitalWrite( TFT_BACKLIGHT_PIN, LOW );
     }
   }

@@ -147,8 +152,8 @@
   }
 }
 /*
-void WiFiEvent( WiFiEvent_t event )
-{
+  void WiFiEvent( WiFiEvent_t event )
+  {
   switch ( event )
   {
     case SYSTEM_EVENT_AP_START:
@@ -183,5 +188,5 @@
     default:
       break;
   }
-}
+  }
 */


Не меняется яркость при первом нажатии на кнопку

--- draft/D20160116_led/dht_restore_LCD_PWM/dht_restore_LCD_PWM.ino
+++ draft/D20160116_led/dht_restore_LCD_PWM/dht_restore_LCD_PWM.ino
@@ -239,11 +239,16 @@

     buttonState =digitalRead(BRIGHT_CONTROL_PIN);
+
     if (buttonState==HIGH){

-
-
-        int brightness =configuration.brightness+pow(-1,brightDirect)* BRIGHT_STEP;
+      int brightness =configuration.brightness;
+
+      //cрабатывание на второй раз
+        if (state ==STATE_BRIGHT_CONTROL){
+          brightness =brightness+pow(-1,brightDirect)* BRIGHT_STEP;
+        }
+

         if (brightness>100){
           brightness=100;
@@ -263,7 +268,9 @@

         analogWrite(BRIGHT_PIN, getBrightLevel(brightness));

-        saveBrighness(brightness);
+        if (state ==STATE_BRIGHT_CONTROL){
+          saveBrighness(brightness);
+        }

         printBrighnessState(brightness);

@@ -272,7 +279,7 @@

         bri_prev_time =micros();
-        delay(250);
+        delay(200);
         return;
       }

@@ -316,10 +323,13 @@
   return  1.0* BRIGHT_0+ 1.0* brightness_percent*BRIGHT_PERCENT;
 }

-  void saveBrighness(int brightness){
-     configuration.brightness =brightness;
-     EEPROM_writeAnything(0, configuration);
-   }
+
+
+/**Сохраняет уровень яркости во внутреннюю память*/
+void saveBrighness(int brightness){
+  configuration.brightness =brightness;
+  EEPROM_writeAnything(0, configuration);
+}

 char* header= " B\1A\2H. TEM\3. ";


Change a line of formatting and a comment

--- Dremelfuge.ino
+++ Dremelfuge.ino
@@ -168,7 +168,7 @@
   {
     case Mode::SETTING_TIME:
     {
-      /* because changedUIString is static, its state will persist even between
+      /* because var is `static`, its state will persist even between
         other calls of loop()
       */
       static bool changedUIString = false;
@@ -225,8 +225,7 @@

     case Mode::SETTING_SPEED:
     {
-      motorSpeed = map(analogRead(POT_PIN),
-                       0, 1024, 0, 255);
+      motorSpeed = map(analogRead(POT_PIN), 0, 1024, 0, 255);

       lcd.setCursor(11, 2);
       lcd.print(F("<"));


Add explanatory information

Add explanatory information

--- examples/HIH61xx_SoftWire_demo/HIH61xx_SoftWire_demo.ino
+++ examples/HIH61xx_SoftWire_demo/HIH61xx_SoftWire_demo.ino
@@ -1,14 +1,25 @@
+// This example demonstrates how to use the HIH61xx class with the SoftWire library. SoftWire is a software I2C
+// implementation which enables any two unused pins to be used as a I2C bus. The HIH61xx state machine
+// enables others tasks to run whilst the HIH61xx is powering up etc.
+
 #include <SoftWire.h>
 #include <HIH61xx.h>
 #include <AsyncDelay.h>

+// Create an instance of the SoftWire class called "sw". In this example it uses the same pins as the hardware I2C
+// bus. Pass the pin numbers to use different pins.
 SoftWire sw(SDA, SCL);
+
+// The "hih" object must be created with a reference to the SoftWire "sw" object which represents the I2C bus it is
+// using. Note that the class for the SoftWire object must be included in the templated class name.
 HIH61xx<SoftWire> hih(sw);
+
 AsyncDelay samplingInterval;

-// Only a very small RX buffer is needed
+// SoftWire requires that the programmer declares the buffers used. This allows the amount of memory used to be set
+// according to need. For the HIH61xx only a very small RX buffer is needed.
 uint8_t i2cRxBuffer[4];
-uint8_t i2cTxBuffer[4];
+uint8_t i2cTxBuffer[32];

 void setup(void)
 {
@@ -22,10 +33,11 @@
 	// sw.setSda(sdaPin);
 	// sw.setScl(sclPin);

+
 	sw.setRxBuffer(i2cRxBuffer, sizeof(i2cRxBuffer));
 	//sw.setTxBuffer(i2cTxBuffer, sizeof(i2cTxBuffer));

-	// HIH61xx doesn't need a TX buffer, but other I2C devices probably will.
+	// HIH61xx doesn't need a TX buffer at all but other I2C devices probably will.
 	//sw.setTxBuffer(i2cTxBuffer, sizeof(i2cTxBuffer));
 	sw.setTxBuffer(NULL, 0);


coded linted

coded linted

--- src-arduino/arduair-mega-wifi-shield-DS1307-allSensors/arduair-mega-wifi-shield-DS1307-allSensors.ino
+++ src-arduino/arduair-mega-wifi-shield-DS1307-allSensors/arduair-mega-wifi-shield-DS1307-allSensors.ino
@@ -8,17 +8,18 @@
 # Wiring Scheme.
 ## Arduino
 Pin   Feature
-2     LED Red
-3     LED Green
-4     WiFiShield Pin
-5     DHT Pin
-7     WifiShield Pin
-8     Shinyei Pin 1
-9     Shinyei Pin 2 //TODO: check what pin is
-10    SD/SS Pin
-S1    Ze-Co  Sensor
-S2    Ze-NO2 Sensor
-S3    Ze-SO2 Sensor
+2       LED Red
+3       LED Green
+4       WiFiShield Reserved Pin
+5       DHT Pin
+7       WifiShield Pin Reserved Pin
+8       Shinyei Pin 1
+9       Shinyei Pin 2 //TODO: check what pin is
+10      SD/SS Pin Reserved Pin
+RX/TX1  Ze-Co  Sensor
+RX/TX2  Ze-NO2 Sensor
+RX/TX3  Ze-SO2 Sensor
+SDA/SCL BMP180, RTC, Light Module

 ## Shinyei PPD42ns
 1     Ground
@@ -34,7 +35,6 @@
 #include <SFE_BMP180.h>//Sparkfun BMP180 pressure Sensor Library
 #include <SparkFunTSL2561.h>//light sensor library SparkFun TSL2561 Breakout
 #include <WiFi.h>      //wifi shield Library
-#include <Event.h>

 //Default configuration
 #define RED_LED_PIN 2
@@ -49,16 +49,12 @@
 #define CO  1 //
 #define NO2 2
 #define SO2 3
-unsigned int zeCo=19;
-unsigned int zeNO2=20;
-unsigned int zeSO2=21;
-bool zeAvailable=true;
-unsigned int zeCounter;    // Ze counter of meausures
+unsigned int zeCounter;    // Ze counter of measures

 //Constructors
 File myFile;              //FIle constructor
 WiFiClient client;        //WiFiClient Constructor
-DHT dht(DHTPIN, DHTTYPE); //DHT constructor
+DHT dht(DHTPIN, DHTTYPE); //DHT constructor , m
 SFE_BMP180 bmp;           //bmp constructor
 SFE_TSL2561 light;        //TSL2561 constructor

@@ -66,8 +62,8 @@
 char ssid[] = "FABIAN"; //  your network SSID (name)
 char pass[] = "63856199";    // your network password (use for WPA, or use as key for WEP)
 char server[] = "arduair.herokuapp.com/test/";
-char device[] = "DeviceName";
-char password[] = "devicePassword";
+char device[] = "device1";
+char password[] = "pass1";
 int status = WL_IDLE_STATUS;

 //Global variables for measuring
@@ -75,12 +71,11 @@
 float p,h,t,l;
 float co,o3,so2,no2;
 unsigned int second, minute,hour,weekDay,monthDay,month,year;
-
-/**
- * Arduair configuration initialitation
+/**
+ * Arduair configuration initialization
  */
 void setup() {
-  digitalWrite(GREEN_LED_PIN,HIGH);
+  digitalWrite(GREEN_LED_PIN,HIGH); // Setup Light On
   Serial.begin(9600);
   Serial1.begin(9600); //ZE CO-sensor
   Serial2.begin(9600); //ZE NO2-sensor
@@ -93,38 +88,36 @@
   digitalWrite(WIFIPIN,HIGH); //active wifishield
   digitalWrite(SDPIN,LOW); //inactive SD
   wifiBegin();
+  winsenBegin();
   arduairSetup();
-  digitalWrite(GREEN_LED_PIN,LOW);
-}
-/**
- * Arduair measuring cycle, it control all measuring cycle and ends writing the
- * results in a SD card and sending a request to the server
- * the measuring order is:
- * 2) 30 s :   measuring PM10 and PM2.5.
- * 3) 30 s :   measuring O3
- * 4) 30 s :   measuring light, humidity, temperature and Pressure
- * 5) 1 s :   detach Winsen sensor interrups (to avoid unnespected results during SD writing and http request)
- * 6) 1 m :   writing in the SD and senging the recuest
- * 7) 1 s :   clear variables
- * Also, asynchronously, Arduair handles the interrupt for the Winsen sensors,
- * thats comes every second per sensor.
+  digitalWrite(GREEN_LED_PIN,LOW); // Setup Light Off
+}
+/**
+* Arduair measuring cycle, it control all measuring cycle and ends writing the
+* results in an SD card and sending a request to the server
+* the measuring order is:
+* 1) 30 s :   measuring PM10 and PM2.5.
+* 2) 30 s :   measuring O3
+* 3) 30 s :   measuring light, humidity, temperature and Pressure
+* 4) 1 s :   Detach Winsen sensor interrupts (to avoid unexpected results during SD writing and HTTP request)
+* 5) 1 m :   writing in the SD and sending the request
+* 6) 1 s :   clear variables
+* Also, asynchronously, Arduair handles the interrupt for the Winsen sensors,
+* that comes every second per sensor.
  *
  */
 void loop() {
-  //2
-  pmRead();
-  //3
-  mq131Read();
-  //4
-  meteorologyRead();
-  //5
-  winsenRead(CO);
+
+  pmRead();          //1
+  mq131Read();       //2
+  meteorologyRead(); //3
+  winsenRead(CO);    //4
   winsenRead(NO2);
   winsenRead(SO2);
-  //6
-  getDate();
+  getDate(DS1307_ADDRESS);         //5
   tableWrite();
   request(h,t,p,l,co,so2,no2);
+  //6
 }
 /**
  * Perform a request to the given server variable. in the form:
@@ -139,8 +132,7 @@
  * @param no2 [description]
  */
 void request(int h,int t,float p,float l,float co,float so2,float no2){
-  // close any connection before send a new request.
-  // This will free the socket on the WiFi shield
+  // close any connection before send a new request.This will free the socket on the WiFi shield
   client.stop();

  // if there's a successful connection:
@@ -209,7 +201,7 @@

 }
 /**
- * read  MQ-131 O3 low concentration sensor
+ * Reads  MQ-131 O3 low concentration sensor
  * @return [description]
  */
 float mq131Read(){
@@ -221,28 +213,7 @@
   return finalValue;
 }
 /**
- * Read ZE03-SO2 winsen sensor
- */
-void zeso2Read(){
-  float c= zeSO2/zeCounter;
-  zeSO2=0;
-}
-/**
- * Read ZE03-no2 winsen sensor
- * @return no2 concentration
- */
-void zeno2Read(){
-  //hey
-}
-/**
- * Read ZE03-co winsen sensor
- * @return co concentration
- */
-void zecoRead(){
-  //hey
-}
-/**
- * Read pm10 and pm2.5 concentration from Shinyei PPD42,, this function is
+ * Reads pm10 and pm2.5 concentration from Shinyei PPD42,, this function is
  * based on the dustduino project
  */
 void pmRead(){
@@ -309,7 +280,7 @@
   Serial.println("Ended  PM read");
 }
 /**
- * Read pressure from BMP pressure Sensor
+ * Reads pressure from BMP pressure Sensor
  * @return pressure
  */
 float pressureRead(){
@@ -386,7 +357,7 @@
     Serial.print(" lux: ");
     Serial.print(lux);

-    if (good) l=lux; else l="undefined";
+    if (good) l=lux; else l=-99;
     return l;
   }
 }
@@ -394,13 +365,13 @@
  * Reads Temperature from DHT
  */
 float temperatureRead(){
-  return dht.readTemperature()
+  return dht.readTemperature();
 }
 /**
  * Reads Temperature from DHT
  */
 float humidityRead(){
-  return dht.readHumidity()
+  return dht.readHumidity();
 }
 /**
  * Convert binary coded decimal to normal decimal numbers
@@ -444,7 +415,7 @@
  * Meteorology read function
  */
 void meteorologyRead(){
-  p = readPressure();
+  p = pressureRead();
   l = lightRead();
   h = humidityRead();  // 1* medir humedad
   t = temperatureRead();// 2* medir temperatura
@@ -456,7 +427,7 @@
  //
 }
 /**
- * This function begin wifi connection
+ * This function begins wifi connection
  */
 void wifiBegin(){
     // check for the presence of the shield:
@@ -478,26 +449,14 @@
   }
   Serial.println("Connected to wifi");
 }
-void serialEvent1(){
-  if (zeAvailable==true){
-    String input;
-    while (Serial1.available()){
-      char inChar = (char)Serial.read();
-      input += inChar;
-      if (input.length()==8){
-        zeSO2=(input[2]*256+input[3])*0.1;
-      }
-    }
-  }
-}
 /**
  * Disables automatic concentration of ZE sensors to prevent unexpectects behaviors from interrupts
  */
 void winsenBegin(){
   byte message[] = {0xFF,0x01, 0x78, 0x04, 0x00, 0x00, 0x00, 0x00, 0x83};//TODO: change bye array to "manual form"
-  Serial1.write(message,siseof(message));
-  Serial2.write(message,siseof(message));
-  Serial3.write(message,siseof(message));
+  Serial1.write(message,sizeof(message));
+  Serial2.write(message,sizeof(message));
+  Serial3.write(message,sizeof(message));
 }
 /**
  * Reads the given contaminant from their respective Winsen Sensor
@@ -507,37 +466,75 @@
   byte message[] = {0xFF,0x01, 0x78, 0x03, 0x00, 0x00, 0x00, 0x00, 0x84};
   unsigned long sampletime_ms = 30000;
   unsigned long starttime=millis();
-  unsigned long starttime=millis();
-  switch (var) {
+  switch (cont) {
     case 1:
-      Serial1.write(message,siseof(message));
+      Serial1.write(message,sizeof(message));
       //for(;sampletime_ms > millis() - starttime;){
       if (Serial1.available() > 0) {
         byte measure[8];
         Serial1.readBytes(measure,9);
-        incomingByte = Serial1.read();
-        int ppm = measure[2]*256+measure[3];
+        float ppm = measure[2]*256+measure[3];
       }
       //}
       break;
     case 2:
-      Serial2.write(message,siseof(message));
+      Serial2.write(message,sizeof(message));
       if (Serial2.available() > 0) {
         byte measure[8];
         Serial2.readBytes(measure,9);
-        incomingByte = Serial2.read();
-        unsigned float ppm = (measure[2]*256+measure[3])*0.1;
+        float ppm = (measure[2]*256+measure[3])*0.1;
       }
       break;
     case 3:
-      Serial1.write(message,siseof(message));
+      Serial1.write(message,sizeof(message));
       if (Serial3.available() > 0) {
         byte measure[8];
         Serial3.readBytes(measure,9);
-        incomingByte = Serial3.read();
-        unsigned float  ppm = (measure[2]*256+measure[3])*0.1;
+        float  ppm = (measure[2]*256+measure[3])*0.1;
       }
     break;
   }
   winsenBegin(); //disable sensors.
 }
+/**
+ * Perform a simple reques
+ * @param h   [description]
+ * @param t   [description]
+ * @param p   [description]
+ * @param l   [description]
+ * @param co  [description]
+ * @param so2 [description]
+ * @param no2 [description]
+ */
+void simple_request(int h,int t,float p,float l,float co,float so2,float no2){
+  // close any connection before send a new request.
+  // This will free the socket on the WiFi shield
+   client.stop();
+   String timezone;
+  // if there's a successful connection:
+  if (client.connect(server, 80)) {
+    Serial.println("connecting...");
+
+    //String getRequest ="GET"+"hola"+" "
+    // send the HTTP GET request:
+    client.print("GET "); client.print("/"); client.print(device); client.print("/"); client.print(password); client.print("/timezone"); client.print(" HTTP/1.1");
+    client.println("");
+    // parameters:
+    client.print("?z="); client.print(timezone); client.print(",");
+    client.print("h="); client.print(h); client.print(",");
+    client.print("t="); client.print(t); client.print(",");
+    client.print("l="); client.print(l); client.print(",");
+    client.print("co="); client.print(pm10); client.print(",");
+    client.print("o3="); client.print(pm10); client.print(",");
+    client.print("pm10="); client.print(pm10); client.print(",");
+    client.print("pm25="); client.print(pm25); client.print(",");
+    client.print("so2="); client.print(so2); client.print(",");
+    client.print("no2="); client.print(no2); client.print(",");
+    client.println("");
+    //server
+    client.print("Host: ");client.print(server);
+    client.println("User-Agent: Arduair");
+    client.println("Connection: close");
+    client.println();
+  }
+ }


Sync version numbers

Sync version numbers

--- OxFloodNet_Sensor/OxFloodNet_Sensor.ino
+++ OxFloodNet_Sensor/OxFloodNet_Sensor.ino
@@ -1,5 +1,5 @@
 /**
- * OxFloodNet_SensorV32 sketch for Ciseco RFu-328 and Maxbotix MB7060 XL-MaxSonar-WR1, Standard edition ultrasonic sensor
+ * OxFloodNet_Sensor sketch for Ciseco RFu-328 and Maxbotix MB7060 XL-MaxSonar-WR1, Standard edition ultrasonic sensor
  *
  * Transmits reading every 1, 5, 10 or 15 minutes depending on jumpers. Default is 15 minutes
  * Data transmitted is of form aXXUnnn-----
@@ -26,8 +26,8 @@
 #include <OneWire.h>
 #include <DallasTemperature.h>

-// Used in START msg to indicate firmware version, 313 = 3.1.3
-#define VERSION_ID 313
+// Used in START msg to indicate firmware version, 314 = 3.1.4
+#define VERSION_ID 314

 // Hardware pin defines
 // Enable SRF


adds updated digital in example

adds updated digital in example

--- arduino-cc3000/digital-in/digital-in.ino
+++ arduino-cc3000/digital-in/digital-in.ino
@@ -1,26 +1,80 @@
+/***************************************************
+  Adafruit MQTT Library CC3000 Example
+
+  Designed specifically to work with the Adafruit WiFi products:
+  ----> https://www.adafruit.com/products/1469
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried/Ladyada for Adafruit Industries.
+  Adafruit IO example additions by Todd Treece.
+  MIT license, all text above must be included in any redistribution
+ ****************************************************/
+#include <Adafruit_SleepyDog.h>
 #include <Adafruit_CC3000.h>
 #include <SPI.h>
+#include "utility/debug.h"
+#include "Adafruit_MQTT.h"
+#include "Adafruit_MQTT_CC3000.h"

-#define ADAFRUIT_CC3000_VBAT  5
+/****************************** Pins ******************************************/
+
+#define BUTTON                2
+#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
+#define ADAFRUIT_CC3000_VBAT  5  // VBAT & CS can be any digital pins.
 #define ADAFRUIT_CC3000_CS    10
-#define BUTTON                2
+// Use hardware SPI for the remaining pins
+// On an UNO, SCK = 13, MISO = 12, and MOSI = 11

-Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,
-                                         ADAFRUIT_CC3000_IRQ,
-                                         ADAFRUIT_CC3000_VBAT,
-                                         SPI_CLOCK_DIVIDER);
+/************************* WiFi Access Point *********************************/

-Adafruit_CC3000_Client cc3000_client = Adafruit_CC3000_Client();
-PubSubClient client("io.adafruit.com", 1883, mqtt_callback, cc3000_client);
+#define WLAN_SSID       "...your SSID..."  // can't be longer than 32 characters!
+#define WLAN_PASS       "...your password..."
+#define WLAN_SECURITY   WLAN_SEC_WPA2  // Can be: WLAN_SEC_UNSEC, WLAN_SEC_WEP,
+                                       //         WLAN_SEC_WPA or WLAN_SEC_WPA2

-// replace with your WiFi connection info
-#define WLAN_SSID "test"
-#define WLAN_PASS "secretpass"
-#define WLAN_SECURITY WLAN_SEC_WPA2
+/************************* Adafruit.io Setup *********************************/

-// replace xxxxxxxxx with your Adafruit IO key
-#define AIO_KEY "xxxxxxxxx"
-#define MQTT_TOPIC "api/feeds/%s/data/send.json"
+#define AIO_SERVER      "io.adafruit.com"
+#define AIO_SERVERPORT  1883
+#define AIO_USERNAME    "...your AIO username (see https://accounts.adafruit.com)..."
+#define AIO_KEY         "...your AIO key..."
+
+/************ Global State (you don't need to change this!) ******************/
+
+// Setup the main CC3000 class, just like a normal CC3000 sketch.
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT);
+
+// Store the MQTT server, client ID, username, and password in flash memory.
+// This is required for using the Adafruit MQTT library.
+const char MQTT_SERVER[] PROGMEM    = AIO_SERVER;
+// Set a unique MQTT client ID using the AIO key + the date and time the sketch
+// was compiled (so this should be unique across multiple devices for a user,
+// alternatively you can manually set this to a GUID or other random value).
+const char MQTT_CLIENTID[] PROGMEM  = AIO_KEY __DATE__ __TIME__;
+const char MQTT_USERNAME[] PROGMEM  = AIO_USERNAME;
+const char MQTT_PASSWORD[] PROGMEM  = AIO_KEY;
+
+// Setup the CC3000 MQTT class by passing in the CC3000 class and MQTT server and login details.
+Adafruit_MQTT_CC3000 mqtt(&cc3000, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);
+
+// You don't need to change anything below this line!
+#define halt(s) { Serial.println(F( s )); while(1);  }
+
+// CC3000connect is a helper function that sets up the CC3000 and connects to
+// the WiFi network. See the cc3000helper.cpp tab above for the source!
+boolean CC3000connect(const char* wlan_ssid, const char* wlan_pass, uint8_t wlan_security);
+
+/****************************** Feeds ***************************************/
+
+// Setup a feed called 'button' for subscribing to changes.
+// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
+const char BUTTON_FEED[] PROGMEM = AIO_USERNAME "/feeds/button";
+Adafruit_MQTT_Publish button = Adafruit_MQTT_Publish(&mqtt, BUTTON_FEED);
+
+/*************************** Sketch Code ************************************/

 // button state
 int current = 0;
@@ -31,17 +85,38 @@
   // set button pin as an input
   pinMode(BUTTON, INPUT_PULLUP);

+  Serial.begin(115200);
+
+  Serial.println(F("Adafruit IO Example:"));
+  Serial.print(F("Free RAM: ")); Serial.println(getFreeRam(), DEC);
+
+  // Initialise the CC3000 module
+  Serial.print(F("\nInit the CC3000..."));
+  if (! cc3000.begin())
+    halt("Failed");
+
+  // attempt wifi connection
+  while (! CC3000connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Retrying WiFi"));
+    while(1);
+  }
+  Serial.println(F("Connected to WiFi!"));
+
+  // connect to adafruit io
+  connect();
+
 }

 void loop() {

-  // required for MQTT connection
-  client.loop();
+  // Make sure to reset watchdog every loop iteration!
+  Watchdog.reset();

-  // reconnect if we lost connection to AIO
-  if(! client.connected()) {
-    Serial.print(F("AIO connection dropped. Attempting reconnect"));
-    mqtt_connect();
+  // ping adafruit io a few times to make sure we remain connected
+  if(! mqtt.ping(3)) {
+    // reconnect to adafruit io
+    if(! mqtt.connected())
+      connect();
   }

   // grab the current state of the button
@@ -51,14 +126,51 @@
   if(current == last)
     return;

-  // send the proper value to AIO depending on button state
-  if(current == LOW)
-    sendData("Button", "1");
+  // Now we can publish stuff!
+  Serial.print(F("\nSending button value: "));
+  Serial.print(current == LOW ? 1 : 0);
+  Serial.print("... ");
+
+  if (! button.publish(current == LOW ? 1 : 0))
+    Serial.println(F("Failed."));
   else
-    sendData("Button", "0");
+    Serial.println(F("Success!"));

   // save the button state
   last = current;

 }

+// connect to adafruit io via MQTT
+void connect() {
+
+  Serial.print(F("Connecting to Adafruit IO... "));
+
+  int8_t ret;
+
+  while ((ret = mqtt.connect()) != 0) {
+
+    switch (ret) {
+      case 1: Serial.println(F("Wrong protocol")); break;
+      case 2: Serial.println(F("ID rejected")); break;
+      case 3: Serial.println(F("Server unavail")); break;
+      case 4: Serial.println(F("Bad user/pass")); break;
+      case 5: Serial.println(F("Not authed")); break;
+      case 6: Serial.println(F("Failed to subscribe")); break;
+      default:
+        Serial.println(F("Connection failed"));
+        CC3000connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
+        break;
+    }
+
+    if(ret >= 0)
+      mqtt.disconnect();
+
+    Serial.println(F("Retrying connection..."));
+    delay(5000);
+
+  }
+
+  Serial.println(F("Adafruit IO Connected!"));
+
+}


adding piano

adding piano

--- arduinoScripts/PruebaRFID/PruebaRFID.ino
+++ arduinoScripts/PruebaRFID/PruebaRFID.ino
@@ -16,6 +16,7 @@
 byte nuidPICC[3];

 byte guitar[4] = {53, 07, 04, 109};
+byte piano[4] = {131, 43, 239, 117};

 void setup() {
   Serial.begin(9600);
@@ -62,6 +63,14 @@
         Serial.println("guitarra!!");

     }
+
+    if(piano[0] == rfid.uid.uidByte[0] &&
+       piano[1] == rfid.uid.uidByte[1] &&
+       piano[2] == rfid.uid.uidByte[2] &&
+       piano[3] == rfid.uid.uidByte[3]){
+
+      Serial.println("piano");
+    }
   // Halt PICC
   rfid.PICC_HaltA();


Bijna alles klaar

Bijna alles klaar

Very confident right now

--- LightTrain.ino
+++ LightTrain.ino
@@ -10,7 +10,10 @@
 #define NUMPIXELS      10
 #define SENSOR_THRESHOLD 400

-#define AFSTAND_TRAJECT 350.0
+#define IDLE_TIME 300*1000
+#define WIT pixels.Color(255,255,255)
+#define UIT pixels.Color(0,0,0)
+#define KLEUR pixels.Color(200, 100, 0)

 // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
 // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
@@ -19,7 +22,8 @@

 const int sensor1;
 int delayval = 200; // delay for half a second
-int ms = 0;         // Aantal milliseconden dat de trein over het traject sensor1 -> sensor2 doet
+int ms = 0;         // Aantal milliseconden dat de trein erover doet om sensor 1 te passeren.
+int laatste_trein   // Aantal milliseconden sinds de laatste keer dat de trein langskwam.
 int aantal_leds;
 boolean trein_langs;

@@ -27,7 +31,7 @@
   pixels.begin(); // This initializes the NeoPixel library.
   for(int i=0;i<NUMPIXELS;i++){
     // Zet de beginkleur op wit
-    pixels.setPixelColor(i, pixels.Color(255, 255, 255));
+    pixels.setPixelColor(i, WIT);
   }
   pixels.show();
 }
@@ -42,14 +46,25 @@
   }
   aantal_leds = ms/delayval;
   if(trein_langs) {
+    laatste_trein = millis();
     for(int i=0;i<NUMPIXELS;i++){
-
-      // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
-      pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
-
-      pixels.show(); // This sends the updated pixel color to the hardware.
-
-      delay(delayval); // Delay for a period of time (in milliseconds).
-
+      int achterste_led = i - aantal_leds;
+      if(achterste_led >= 0) {
+        pixels.setPixelColor(achterste_led, WIT);
+      }
+      pixels.setPixelColor(i, KLEUR);
+      pixels.show();
+      delay(delayval);
+    }
+    trein_langs = false;
+    ms = 0;
+  }
+  if(millis() - laatste_trein > IDLE_TIME) {
+    // De trein is al lang niet langsgeweest, zet de lampjes uit
+    for(int i=0;i<NUMPIXELS;i++){
+      // Zet de lampjes uit
+      pixels.setPixelColor(i, UIT);
+    }
+    pixels.show();
   }
 }


Cleanup

Cleanup

--- Firmware/R2-Quadcopter/R2-Quadcopter.ino
+++ Firmware/R2-Quadcopter/R2-Quadcopter.ino
@@ -39,7 +39,7 @@
 Adafruit_BNO055 bno = Adafruit_BNO055(); // Initialisation de l'objet BNO

 ////////////////////////////////////////////////////////////////////////
-//INTERRUPTS
+//LECTURE RADIO AVEC INTERRUPTS
 ////////////////////////////////////////////////////////////////////////
 void calcSignalARM() {
   if (digitalRead(RX_PIN_ARM) == HIGH) {
@@ -200,7 +200,6 @@
     last_yaw_error = yaw_error;

     dernierTemps = maintenant;
-    //Serial.println(deltaTemps);
   }

 }
@@ -414,7 +413,6 @@
   if (auto_stabilisation_mode == false)pid_compute();
   else pid_LEVEL_compute();

-
   //MOTORS
   throttle = inputTHROTTLE;

@@ -450,11 +448,9 @@
     esc_2.writeMicroseconds(motorFL);
     esc_3.writeMicroseconds(motorBL);
     esc_4.writeMicroseconds(motorBR);
+
     Proportional_roll, Integral_roll, Derivative_roll = 0;
-    Proportional_pitch, Integral_pitch, Derivative_pitch = 0; //reset after disarm
+    Proportional_pitch, Integral_pitch, Derivative_pitch = 0; //reset après disarm
     Proportional_yaw, Integral_yaw, Derivative_yaw = 0;
   }
-
-  //Serial.println(maintenant);
-  //delay(20);
-}
+}