display sensor details for OLED completed

--- test/Arduino/MicroView/MicroView_ino/MicroView_ino.ino
+++ test/Arduino/MicroView/MicroView_ino/MicroView_ino.ino
@@ -49,38 +49,43 @@
 {
   sensor_t sensor;
   bno.getSensor(&sensor);
-  char buffer[7];         //the ASCII of the integer will be stored in this char array
-
+
+
+
+  // 10x6 lines availabe
+  //           1234567890
   uView.clear(PAGE);

-  //Serial.print  ("Sensor:       ");
+  // Name
+  //uView.setCursor(0, 0*fontHeight);
+  //uView.print(sensor.name);
+
+  // Driver Version
   uView.setCursor(0, 0*fontHeight);
-  uView.print(sensor.name);
-
-  //Serial.print  ("Driver Ver:   ");
+  uView.print("Version: ");
+  uView.print(sensor.version);
+
+  // Unique ID
   uView.setCursor(0, 1*fontHeight);
-  uView.print("Version: ");
-  itoa(sensor.version, buffer, 10);
-  uView.print(buffer);
-
-  //Serial.print  ("Unique ID:    ");
+  uView.print("ID:  ");
+  uView.print(sensor.sensor_id);
+
+  // Min Value
+  uView.setCursor(0, 3*fontHeight);
+  uView.print("Min: ");
+  uView.print(sensor.min_value);
+
+  // Max Value
   uView.setCursor(0, 2*fontHeight);
-  uView.print("ID: ");
-  itoa(sensor.sensor_id, buffer, 10);
-  uView.print(buffer);
-
-  //Serial.print  ("Max Value:    ");
-  Serial.print(sensor.max_value);
-  //Serial.println(" xxx");
-  Serial.print  ("Min Value:    ");
-  Serial.print(sensor.min_value);
-  //Serial.println(" xxx");
-  Serial.print  ("Resolution:   ");
-  Serial.print(sensor.resolution);
-  //Serial.println(" xxx");
-  //Serial.println("------------------------------------");
-  //Serial.println("");
-
+  uView.print("Max: ");
+  uView.print(sensor.max_value);
+
+  // Resolution
+  uView.setCursor(0, 4*fontHeight);
+  uView.print("Res: ");
+  uView.print(sensor.resolution);
+
+  // show it
   uView.display();

   delay(500);


Some more letters so that Logobot can write his name again

--- software/firmware/LogoBotWifiScribbler/LogoBotWifiScribbler.ino
+++ software/firmware/LogoBotWifiScribbler/LogoBotWifiScribbler.ino
@@ -373,13 +373,25 @@
 void writeChar(char c) {

     switch(c) {
-        case 'L':
-          writeL();
-          break;
+      case 'B':
+        writeB();
+        break;
+      case 'G':
+        writeG();
+        break;
+      case 'L':
+        writeL();
+        break;
+      case 'O':
+        writeO();
+        break;
+      case 'T':
+        writeT();
+        break;

-        default:
-          pushCmd("BZ 500");
-          break;
+      default:
+        pushCmd("BZ 500");
+        break;
     }
 }

@@ -395,7 +407,44 @@

 // Alphabet

-void writeL() {
+#define NEXTLETTER pushTo(x + w + letterSpacing, y);
+
+void writeB()
+{
+  float x = position.x;
+  float y = position.y;
+  float w = fontSize * 0.5;
+
+  pushCmd("PD");
+  pushTo(x + 2 * w / 3, y);
+  pushTo(x + w, y + capHeight / 4);
+  pushTo(x + 2 * w / 3, y + capHeight / 2);
+  pushTo(x + w, y + 3 * capHeight / 4);
+  pushTo(x + 2 * w / 3, y + capHeight);
+  pushTo(x, y + capHeight);
+  pushTo(x, y);
+  pushCmd("PU");
+  NEXTLETTER
+}
+
+void writeG()
+{
+  float x = position.x;
+  float y = position.y;
+  float w = fontSize * 0.5;
+  pushTo(x + w, y + capHeight);
+  pushCmd("PD");
+  pushTo(x, y + capHeight);
+  pushTo(x, y);
+  pushTo(x + w, y);
+  pushTo(x + w, y + capHeight/3);
+  pushTo(x + w/3, y + capHeight/3);
+  pushCmd("PU");
+  NEXTLETTER
+}
+
+void writeL()
+{
   float x = position.x;
   float y = position.y;
   float w = fontSize * 0.5;
@@ -404,7 +453,35 @@
   pushTo(x,y);
   pushTo(x + w, y);
   pushCmd("PU");
-  pushTo(x + w + letterSpacing, y);
+  NEXTLETTER
+}
+
+void writeO()
+{
+  float x = position.x;
+  float y = position.y;
+  float w = fontSize * 0.5;
+  pushCmd("PD");
+  pushTo(x + w, y);
+  pushTo(x + w, y + capHeight);
+  pushTo(x, y + capHeight);
+  pushTo(x, y);
+  pushCmd("PU");
+  NEXTLETTER
+}
+
+void writeT()
+{
+  float x = position.x;
+  float y = position.y;
+  float w = fontSize * 0.5;
+  pushTo(x + w/2, y);
+  pushCmd("PD");
+  pushTo(x + w/2, y + capHeight);
+  pushTo(x, y + capHeight);
+  pushTo(x + w, y + capHeight);
+  pushCmd("PU");
+  NEXTLETTER
 }


fix compile errors

fix compile errors

--- LEDDisplay.ino
+++ LEDDisplay.ino
@@ -785,8 +785,8 @@
   int voltage = dvoltage*100+0.5;

   float fwatt = fvoltage*10;
-  int ufwatt = fwatt
-
+  int ufwatt = fwatt;
+  float dfwatt = fwatt - ufwatt;

   plot_int(ufvoltage,0,0,2,GREEN);
   plot_char(',',10,0,GREEN);
@@ -795,7 +795,7 @@

   plot_int(ufwatt,0,8,3,RED);
   plot_char(',',10,8,RED);
-  plot_int(watt,13,8,1,RED);
+  plot_int(dfwatt,13,8,1,RED);
   plot_char('W',24,8,RED);

   delay(250);
@@ -819,4 +819,4 @@

-}+}


Disable nRF serial in tri-state

Disable nRF serial in tri-state

--- Programmer.ino
+++ Programmer.ino
@@ -276,7 +276,7 @@
   Serial.println("READY READ MAINPAGE");
   Serial.println("SETTING UP");

-  // Put nRF24LE1 into programming mode
+ // Put nRF24LE1 into programming mode
   progStart();

   // Set InfoPage bit so InfoPage flash is read
@@ -364,6 +364,8 @@
 // the nRF
 void disable_nrf_pins() {
   // PROG and RESET are untouched since they need to be maintained to prevent issues and are not used otherwise.
+
+  nRF24LE1Serial.end();

   tri_state_pin(0);
   tri_state_pin(1);


update motion

update motion

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Chain/d_open_manipulator_chain/d_open_manipulator_chain.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Chain/d_open_manipulator_chain/d_open_manipulator_chain.ino
@@ -97,7 +97,7 @@
       {
         goal_position.clear();
         goal_position.push_back(0.0);
-        goal_position.push_back(0.32);
+        goal_position.push_back(0.28);
         goal_position.push_back(0.81);
         goal_position.push_back(-1.20);

@@ -202,7 +202,7 @@
     case 11:
         goal_position.clear();
         goal_position.push_back(0.0);
-        goal_position.push_back(0.32);
+        goal_position.push_back(0.28);
         goal_position.push_back(0.81);
         goal_position.push_back(-1.20);


Removing unused variables and calculate ring time in elapsed time

--- firmware/StandupPotato/StandupPotato.ino
+++ firmware/StandupPotato/StandupPotato.ino
@@ -31,13 +31,13 @@
 volatile bool watchDogBarked = false;
 bool watchDogEnabled = false;
 const WatchDogTimeout gameWdt = WDT_1sec;
-const WatchDogTimeout buzzerWdt = WDT_128ms;
-const WatchDogTimeout motorWdt = WDT_500ms;

 WatchDogTimeout currentWdt = gameWdt;
 unsigned long elapsedTime = 0; // How much time has elapsed in the running turn in milliseconds

 volatile bool buttonPressed = false;
+
+const unsigned long remindBeepDuration = 150; // How long in milliseconds we should beep to "stress" the user

 PowerState currentState = DEEP_SLEEP; // Start with sleep as the initial state

@@ -223,7 +223,8 @@
           halfOfRemainingTime = TURN_DURATION / 2; // reset the remaining time since the turn is over
         } else if (remainingTime <= halfOfRemainingTime) {
           // Ring when we reach half of the remaining time available
-          ringFor(150);
+          ringFor(remindBeepDuration);
+          elapsedTime += remindBeepDuration; // Add the time we spent ringing
           halfOfRemainingTime /= 2;
         }
       }


+ switched to 1uSec delay between steps

+ switched to 1uSec delay between steps

--- longhand_firmware_due/stepper_control.ino
+++ longhand_firmware_due/stepper_control.ino
@@ -370,7 +370,7 @@
 		if( x_needs_to_step) digitalWrite(X_STEP_PIN, HIGH);
 		if( y_needs_to_step) digitalWrite(Y_STEP_PIN, HIGH);
 		if( z_needs_to_step) digitalWrite(Z_STEP_PIN, HIGH);
-		delayMicroseconds(5); // A4988 needs at least 1 microsecond to register a step
+		delayMicroseconds(1); // A4988 needs at least 1 microsecond to register a step
 		if( x_needs_to_step) digitalWrite(X_STEP_PIN, LOW);
 		if( y_needs_to_step) digitalWrite(Y_STEP_PIN, LOW);
 		if( z_needs_to_step) digitalWrite(Z_STEP_PIN, LOW);


Release 3.0.1

Release 3.0.1

--- TinyScreenClockAndDisplay/TinyScreenClockAndDisplay.ino
+++ TinyScreenClockAndDisplay/TinyScreenClockAndDisplay.ino
@@ -27,10 +27,6 @@
 int buttonReleased=0;
 int countdown = 0;

-<<<<<<< HEAD
-=======
-char notificationLine1[20]="Release 3.0.0";
->>>>>>> origin/master

 void setup(void) {
   Wire.begin();


Parsing app messages

Parsing app messages

--- bluetooth/bluetooth_helloWorld/bluetooth_helloWorld.ino
+++ bluetooth/bluetooth_helloWorld/bluetooth_helloWorld.ino
@@ -19,11 +19,6 @@
  * SOFTWARE.
  */

-/**
-Arduino GPS Client to retrieve the Location data from the GPS shield.
-The information are processed through the TinyGPS library and send via the Akeru.
-**/
-
 #include <SPI.h>
 #include <EEPROM.h>
 #include <lib_aci.h>
@@ -147,7 +142,7 @@
   Tell the ACI library, the MCU to nRF8001 pin connections.
   The Active pin is optional and can be marked UNUSED
   */
-  aci_state.aci_pins.board_name = REDBEARLAB_SHIELD_V2; //See board.h for details REDBEARLAB_SHIELD_V1_1 or BOARD_DEFAULT
+  aci_state.aci_pins.board_name = BOARD_DEFAULT; //See board.h for details REDBEARLAB_SHIELD_V1_1 or BOARD_DEFAULT
   aci_state.aci_pins.reqn_pin   = 9; //SS for Nordic board, 9 for REDBEARLAB_SHIELD_V1_1
   aci_state.aci_pins.rdyn_pin   = 8; //3 for Nordic board, 8 for REDBEARLAB_SHIELD_V1_1
   aci_state.aci_pins.mosi_pin   = MOSI;
@@ -157,7 +152,7 @@
   aci_state.aci_pins.spi_clock_divider      = SPI_CLOCK_DIV8;//SPI_CLOCK_DIV8  = 2MHz SPI speed
                                                              //SPI_CLOCK_DIV16 = 1MHz SPI speed

-  aci_state.aci_pins.reset_pin              = UNUSED; //4 for Nordic board, UNUSED for REDBEARLAB_SHIELD_V1_1
+  aci_state.aci_pins.reset_pin              = 4; //4 for Nordic board, UNUSED for REDBEARLAB_SHIELD_V1_1
   aci_state.aci_pins.active_pin             = UNUSED;
   aci_state.aci_pins.optional_chip_sel_pin  = UNUSED;

@@ -382,10 +377,27 @@

         if (PIPE_UART_OVER_BTLE_UART_RX_RX == aci_evt->params.data_received.rx_data.pipe_number)
           {
-
             Serial.print(F(" Data(Hex) : "));
+
+//Switch statement to parse app messages
+              switch(aci_evt->params.data_received.rx_data.aci_data[aci_evt->len - 3]) {
+                case 49:
+                Serial.println(aci_evt->params.data_received.rx_data.aci_data[aci_evt->len - 3]);
+                Serial.println("Theft-Protection is on");
+                break;
+                case 48:
+                Serial.println(aci_evt->params.data_received.rx_data.aci_data[aci_evt->len - 3]);
+                Serial.println("Theft-Protection is off");
+                break;
+                default:
+                Serial.println(aci_evt->params.data_received.rx_data.aci_data[aci_evt->len - 3]);
+                Serial.println("Last char unknown command");
+              }
+
+             //Print message:
             for(int i=0; i<aci_evt->len - 2; i++)
             {
+
               Serial.print((char)aci_evt->params.data_received.rx_data.aci_data[i]);
               uart_buffer[i] = aci_evt->params.data_received.rx_data.aci_data[i];
               Serial.print(F(" "));


Added elapsed time check to debugging

Added elapsed time check to debugging

--- module/module.ino
+++ module/module.ino
@@ -200,7 +200,13 @@
 				Serial.print(" PeriodY: "); Serial.print(periodY);
 				Serial.print(" "); Serial.print(signals[0]); Serial.print(signals[1]); Serial.print(signals[2]); Serial.print(signals[3]); Serial.print(signals[4]);
 				Serial.print(" "); Serial.print(numValid); Serial.print(" "); Serial.print(numInvalid);
-				Serial.print(" Start Time: "); Serial.println(startTime);
+				Serial.print(" Start Time: "); Serial.print(startTime);
+				if (startTime > 0) {
+					Serial.print(" Elapsed Time: "); Serial.println(calcTime(startTime));
+				}
+				else {
+					Serial.println(" Elapsed Time: 0");
+				}
 			}

 			// if periodX and periodY IS a valid pair


Update state_indicator.ino

Update state_indicator.ino

spelling

--- state_indicator.ino
+++ state_indicator.ino
@@ -16,11 +16,11 @@
 signal, or an analog signal.  This example is setup to read a
 logic signal (which will change the display of the first pixel
 only), and also read an analog signal (which will change the
-display of the reminder of the pixels).
+display of the remainder of the pixels).

 The FastLED library is used for ease of programming the addressable
-LEDs.  Here are links to the FastLED wiki, code, and G+ community:
+LEDs.  Here are links to the FastLED wiki, code, and reddit group:
   https://github.com/FastLED/FastLED/wiki/Frequently-Asked-Questions
   https://github.com/FastLED/FastLED
   http://fastled.io/+


Cleaned up Serial output.

Cleaned up Serial output.

--- aquacontrol2.ino
+++ aquacontrol2.ino
@@ -101,7 +101,7 @@
   OLED.display();

   Serial.begin ( 115200 );
-  Serial.print( "\n\n" );
+  Serial.println( "\r\n\r\n" );

   readWifiDataFromEEPROM();

@@ -140,9 +140,9 @@
     while (dir.next()) {
       String 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\r\n", fileName.c_str(), formatBytes(fileSize).c_str() );
     }
-    Serial.printf("\n");
+    Serial.println();
   }
   initNTP();
   setupWebServer();


Correct UUID

Correct UUID

--- libraries/CurieBle/examples/CallbackLED/CallbackLED.ino
+++ libraries/CurieBle/examples/CallbackLED/CallbackLED.ino
@@ -26,7 +26,7 @@
 BleService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // create service

 // create switch characteristic and allow remote device to read and write
-BleCharCharacteristic switchChar("0x2015", BleRead | BleWrite);
+BleCharCharacteristic switchChar("19B10001-E8F2-537E-4F6C-D104768A1214", BleRead | BleWrite);

 void setup() {
   Serial.begin(9600);


only send data if motion detected

only send data if motion detected


Add RPM display and move to ATTiny84

Add RPM display and move to ATTiny84

--- code/MotorController/MotorController.ino
+++ code/MotorController/MotorController.ino
@@ -1,20 +1,15 @@
 #include <Bounce.h>
 #include <UserTimer.h>
+#include <Adafruit_LEDBackpack.h>
+#include <Adafruit_GFX.h>
+#include <TinyWireM.h>
+
+// NOTE: Depending on the version of the Arduino IDE in use, you may
+// need to follow the instructions at https://github.com/TCWORLD/ATTinyCore/tree/master/PCREL%20Patch%20for%20GCC
+// in order to work around a bogus "relocation truncated to fit" linker error.

 const int CLOCKWISE = 1;
 const int COUNTER_CLOCKWISE = 0;
-
-#if defined(__AVR_ATmega328P__)
-
-// Arduino Pins
-const int speedInPin = A0;
-const int rateOfSpeedChangeInPin = A1;
-const int speedOutPin = 9;
-const int onOffSwitchInPin = 7;
-const int directionSwitchInPin = 6;
-const int directionOutPin = 5;
-
-#elif defined( __AVR_ATtinyX4__ )

 // ATMEL ATTINY84 / arduino-tiny mapping
 //
@@ -28,36 +23,17 @@
 //  PWM  (A 6) (D  4)  PA6  7|    |8   PA5  (D  5) (A 5)   PWM
 //                           +----+
 //
+// 8MHz: avrdude -c usbtiny -p attiny84 -U lfuse:w:0xe2:m -U hfuse:w:0xd7:m -U efuse:w:0xff:m
+
 const int speedInPin = A0;
 const int rateOfSpeedChangeInPin = A1;
 const int speedOutPin = 5;
 const int onOffSwitchInPin = 7;
 const int directionSwitchInPin = 8;
-const int directionOutPin = 6;
-
-#elif defined( __AVR_ATtinyX5__ )
-
-// ATMEL ATTINY85 / arduino-tiny mapping
-//                           +-\/-+
-//  Ain0       (D  5)  PB5  1|    |8   VCC
-//  Ain3       (D  3)  PB3  2|    |7   PB2  (D  2)  INT0  Ain1
-//  Ain2       (D  4)  PB4  3|    |6   PB1  (D  1)        pwm1
-//                     GND  4|    |5   PB0  (D  0)        pwm0
-//                           +----+
-//
-// NOTE!!!! This requires use of the RESET pin so either RSTDISBL fuse must be set.
-// 1MHz: avrdude -c usbtiny -p attiny85 -U lfuse:w:0x62:m -U hfuse:w:0x57:m -U efuse:w:0xff:m
-// 8MHz: avrdude -c usbtiny -p attiny85 -U lfuse:w:0xE2:m -U hfuse:w:0x57:m -U efuse:w:0xff:m
-// After this is done the chip cannot be reprogrammed except by the high-voltage method
-
-const int speedInPin = A3;
-const int rateOfSpeedChangeInPin = A0;
-const int speedOutPin = 0;
-const int onOffSwitchInPin = 2;
-const int directionSwitchInPin = 1;
-const int directionOutPin = 4;
-
-#endif
+const int directionOutPin = 3;
+const int rpmInPin = 2;
+// I2C SCL = PA4 (D6)
+// I2C SDA = PA6 (D4)

 // Settings and limits
 const int switchDebounceTime = 30;
@@ -72,6 +48,8 @@
 Bounce onOffSwitch = Bounce(onOffSwitchInPin, switchDebounceTime);
 Bounce directionSwitch = Bounce(directionSwitchInPin, switchDebounceTime);

+Adafruit_7segment rpmDisplay = Adafruit_7segment();
+
 // State variables
 int targetSpeed = 0;
 int currentSpeed = 0;
@@ -79,6 +57,8 @@
 boolean powerEnabled = false;
 int targetDirection = CLOCKWISE;
 int currentDirection = CLOCKWISE;
+int motorTicks = 0;
+unsigned long lastRpmDisplayTime = 0;

 void setup()
 {
@@ -92,9 +72,18 @@
   // 8MHz gives us a smoother filtered single for the analog input to the
   // motor but requires ~4x the current. This may be a heat problem for the
   // regulator since we're dropping from 24V.
+
+  // 7-segment LED display initialization
+  rpmDisplay.begin(0x70);
+  // Be careful with brightness - setting it too high will run the regulator very hot
+  rpmDisplay.setBrightness(3);
+  rpmDisplay.clear();
+  rpmDisplay.writeDisplay();
+

   pinMode(onOffSwitchInPin, INPUT_PULLUP);
   pinMode(directionSwitchInPin, INPUT_PULLUP);
+  pinMode(rpmInPin, INPUT_PULLUP);
   pinMode(directionOutPin, OUTPUT);
   pinMode(speedOutPin, OUTPUT);
   // We don't have to set pin mode for analog inputs
@@ -105,6 +94,8 @@
   targetDirection = directionSwitch.read();
   currentDirection = targetDirection;
   digitalWrite(directionOutPin, targetDirection);
+
+  attachInterrupt(0, OnMotorTick, RISING);
 }

 void loop()
@@ -150,6 +141,8 @@

   currentSpeed += SlewToward(currentSpeed, targetSpeed);
   analogWrite(speedOutPin, abs(currentSpeed));
+
+  UpdateRpmDisplay();

   // Rather than trying to write a fixed-delay loop we're being lazy and using a
   // variable-deplay loop to control the rate at which we change the motor speed.
@@ -190,3 +183,24 @@
   }
 }

+void OnMotorTick()
+{
+  motorTicks++;
+}
+
+void UpdateRpmDisplay()
+{
+  unsigned long now = millis();
+  unsigned int timeSinceLastDisplay = now - lastRpmDisplayTime;
+
+  if (timeSinceLastDisplay > 1000)
+  {
+    int totalMotorTicks = motorTicks;
+    motorTicks = 0;
+    lastRpmDisplayTime = now;
+
+    float rpm = totalMotorTicks * 60 / 5.0 * (1000.0 / timeSinceLastDisplay);
+    rpmDisplay.print((int)rpm);
+    rpmDisplay.writeDisplay();
+  }
+}


fix json string

fix json string

--- plant-monitor/plant-monitor.ino
+++ plant-monitor/plant-monitor.ino
@@ -90,7 +90,7 @@

 int postToParticle(int status) {
   char publishString[128];
-  sprintf(publishString,"{\"status\": %d, \"temp\": %0.2f, \"pressure\": %0.2f, \"humidity\": %0.2f, , \"soil1\": %u}", status, temperature, pressure, humidity, soil1);
+  sprintf(publishString,"{\"status\": %d, \"temp\": %0.2f, \"pressure\": %0.2f, \"humidity\": %0.2f, \"soil1\": %u}", status, temperature, pressure, humidity, soil1);
   Particle.publish("sensor",publishString);
   return 1;
 }


formatting code for readability. Say half way there; much to do still. \n Made temps decimals now for nicer future displays

--- plantstation.ino
+++ plantstation.ino
@@ -1,41 +1,48 @@
+//=====for Keen Integration====================
 #include "ApiClient.h"
+#include "KeenClient.h"
+KeenClient myKeen;
+
+//=====for writting to the console=============
 #include "Bridge.h"
 #include "Console.h"
+
+//=====for Probe Thermometer===================
+#include "OneWire.h"
+const byte probePin = 3;
+OneWire myPT(probePin);
+
+typedef struct my_soilmeasurement {
+  float tempSoilC;
+  float tempSoilF;
+} SoilMeasurement;
+SoilMeasurement sm;
+
+//=====for Digital Thermo, Humidity Sensor=====
 #include "DHT.h"
-#include "KeenClient.h"
-#include "OneWire.h"
-#include "params.h"
-
-// hardware
-int lightPin = 0; // photoresistor
-int hygroPin = 1; // moisture sensor
-int dhtPin = 2;   // dht11
-int probePin = 3; // temp probe
-
-DHT dht(dhtPin, DHT11);
-OneWire ds(probePin);
-KeenClient keen;
-
-// todo make this array (of error codes)
-//boolean error;
+const byte dhtPin = 2;
+DHT myDHT(dhtPin, DHT11);

 typedef struct my_airmeasurement {
-  int humidityAir;
-  int tempAirC;
-  int tempAirF;
-  int heatIndex;
+  float humidityAir;
+  float tempAirC;
+  float tempAirF;
+  float heatIndex;
 } AirMeasurement;
 AirMeasurement am;

-typedef struct my_soilmeasurement {
-  int tempSoilC;
-  int tempSoilF;
-} SoilMeasurement;
-SoilMeasurement sm;
-
+//=====for keys, params========================
+#include "params.h"
+
+//=====for photoresistor=======================
+const byte lightPin = 0;
 int lightResistor;
+
+//=====for hygrometer==========================
+const byte hygroPin = 1;
 int moistureSensor;

+//=====these i am still thinking about=========
 String appId = "Plant01";
 String location = "Dinning Room Window";
 boolean lightStatus = false;
@@ -45,20 +52,18 @@
 void setup() {
   Serial.begin(9600);
   Serial.println("PlantStation is warming up\n");
-  dht.begin();
+  myDHT.begin();

   Bridge.begin();
   Console.begin();

   while (!Console) { ; }
-  Console.print("\nPlantStation is warming up.\nYun Console is warming up.\nNow With Keen.\n\n");
+  Console.print("\nPlantStation is warming up.\nYun Console is warming up.\nKeen is warming up.\n\n");

   while (!Serial);
 }

 void loop() {
-
-  delay(60000);
   am = getAirMeasurements();
   sm = getSoilMeasurements();
   lightResistor = analogRead(lightPin);
@@ -68,14 +73,23 @@

   // send to keen
   sendToKeen(am, lightResistor, sm);
+
+  // We run this once a minute, approximately
+  delay(60000);
+}
+
+void waterPlants() {
+}
+
+void switchLights() {
 }

 struct my_airmeasurement getAirMeasurements() {
   AirMeasurement me;
-  me.humidityAir = dht.readHumidity();
-  me.tempAirC = dht.readTemperature();
-  me.tempAirF = dht.readTemperature(true);
-  me.heatIndex = dht.computeHeatIndex(me.tempAirF, me.humidityAir);
+  me.humidityAir = myDHT.readHumidity();
+  me.tempAirC = myDHT.readTemperature();
+  me.tempAirF = myDHT.readTemperature(true);
+  me.heatIndex = myDHT.computeHeatIndex(me.tempAirF, me.humidityAir);

   if (me.humidityAir == 0  && me.tempAirC == 0) {
     Serial.println("Failed to read from DHT sensor.");
@@ -90,9 +104,9 @@
   byte data[12];
   byte addr[8];

-  if ( !ds.search(addr)) {
+  if ( !myPT.search(addr)) {
       //no more sensors on chain, reset search
-      ds.reset_search();
+      myPT.reset_search();
       Serial.println("No probe sensor detected");
       Console.println("No probe sensor detected");
   }
@@ -107,19 +121,19 @@
       Console.print("Device is not recognized");
   }

-  ds.reset();
-  ds.select(addr);
-  ds.write(0x44,1); // start conversion, with parasite power on at the end
-
-  byte present = ds.reset();
-  ds.select(addr);
-  ds.write(0xBE); // Read Scratchpad
+  myPT.reset();
+  myPT.select(addr);
+  myPT.write(0x44,1); // start conversion, with parasite power on at the end
+
+  byte present = myPT.reset();
+  myPT.select(addr);
+  myPT.write(0xBE); // Read Scratchpad

   for (int i = 0; i < 9; i++) { // we need 9 bytes
-    data[i] = ds.read();
-  }
-
-  ds.reset_search();
+    data[i] = myPT.read();
+  }
+
+  myPT.reset_search();

   byte MSB = data[1];
   byte LSB = data[0];
@@ -161,17 +175,17 @@
   my_output += waterPumpStatus;
   my_output += "}";

-  keen.setApiVersion(F("3.0"));
-  keen.setProjectId(KEEN_PROJECT_ID);
-  keen.setWriteKey(KEEN_WRITE_KEY);
+  myKeen.setApiVersion(F("3.0"));
+  myKeen.setProjectId(KEEN_PROJECT_ID);
+  myKeen.setWriteKey(KEEN_WRITE_KEY);

-  keen.addEvent("arduino_board_test", my_output);
-  keen.printRequest();
+  myKeen.addEvent("arduino_board_test", my_output);
+  myKeen.printRequest();

   Console.println();

-  while (keen.available()) {
-    char c = keen.read();
+  while (myKeen.available()) {
+    char c = myKeen.read();
     Console.print(c);
   }
   Console.println();
@@ -193,7 +207,7 @@
   my_output += am.heatIndex;
   my_output += ";Light:";
   my_output += lightResistor;
-  my_output += ";ProbeTemperatureCelcius";
+  my_output += ";ProbeTemperatureCelcius:";
   my_output += sm.tempSoilC;
   my_output += ";ProbeTemperatureFahrenheit:";
   my_output += sm.tempSoilF;
@@ -212,15 +226,6 @@
   Console.println(my_output);
 }

-// DHT11
-// Connect pin 1 (on the left) of the sensor to +5V
-// Connect pin 2 of the sensor to whatever your DHTPIN is
-// Connect pin 4 (on the right) of the sensor to GROUND
-// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
-// Photoresistor ?
-
 // todo: add led and red led for status of whole thing!

-// http://forum.arduino.cc/index.php?topic=42140.0
-// http://www.arduino.cc/en/Tutorial/ConsoleRead
-
+


Add header to demo class

Add header to demo class

--- examples/AstronomyDemo/AstronomyDemo.ino
+++ examples/AstronomyDemo/AstronomyDemo.ino
@@ -1,3 +1,27 @@
+/**The MIT License (MIT)
+
+Copyright (c) 2018 by ThingPulse
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+See more at https://thingpulse.com
+*/

 #include <ESP8266WiFi.h>
 #include <time.h>


Adding pin configuration for SD on Ethernet Shield (testing ATmega32u4/Leonardo).

--- examples/Sandbox/CosaFAT16/CosaFAT16.ino
+++ examples/Sandbox/CosaFAT16/CosaFAT16.ino
@@ -29,7 +29,12 @@
 #include "Cosa/Watchdog.hh"
 #include "Cosa/Memory.h"

+#define USE_ETHERNET_SHIELD
+#if defined(USE_ETHERNET_SHIELD)
+SD sd(Board::D4);
+#else
 SD sd;
+#endif

 void setup()
 {


Miscounted hidden lights.

Miscounted hidden lights.

--- examples/TiconXmas2012/TiconXmas2012.ino
+++ examples/TiconXmas2012/TiconXmas2012.ino
@@ -18,9 +18,9 @@

 // Arduino with Like A G35 shield (https://github.com/sowbug/like-a-g35).
 // First string on pin 8. Second on 9. My roofline isn't quite long enough
-// for 100 lights, so I have the final 9 hidden.
+// for 100 lights, so I have the final 10 hidden.
 G35String lights_1(8, 50, 50, 0, false);
-G35String lights_2(9, 41);
+G35String lights_2(9, 40);

 const int PROGRAM_COUNT = StockProgramGroup::ProgramCount +
   PlusProgramGroup::ProgramCount;


forgot lst settings

forgot lst settings

--- plantstation.ino
+++ plantstation.ino
@@ -17,7 +17,7 @@

 //===== For probe thermometer ===================
 #include "OneWire.h"
-const byte probePin = 3;
+const byte probePin = 3;
 OneWire myPT(probePin);

 typedef struct my_soilmeasurement {
@@ -63,22 +63,22 @@
 int waterLevelVal;
 String waterLevelStatus = "OK";

+//===== For water pump ===========================
+const byte waterPumpPin = A5;
+// todo - find right value for this
+const int waterLevelThreshold = 245;
+const int waterMaxVal = 386;
+const int waterMinVal = 80;
+boolean waterPumpIsOn = false;
+unsigned long wateringSeconds = 15000;
+unsigned long prevWatering = 0;
+
 //===== For light switch =========================
 const byte lightSwitchPin = 4;
 const byte lightOnThreshold = 30;
 const int lightMaxVal = 250;
 const int lightMinVal = 0;
 boolean lightIsOn = false;
-
-//===== For water pump ===========================
-const byte waterPumpPin = A5;
-// todo - find right value for this
-const int waterLevelThreshold = 5;
-const int waterMaxVal = 280; // was at 271 full when i got here. its at 263 with 2 cups off.
-const int waterMinVal = 10;
-boolean waterPumpIsOn = false;
-unsigned long wateringSeconds = 15000;
-unsigned long prevWatering = 0;

 //===== For timed events =========================
 unsigned long prevMinOneMillis = 0;
@@ -220,7 +220,7 @@
   digitalWrite(waterSensorPower, LOW);
   waterLevelPercent = map(waterLevelVal, waterMinVal, waterMaxVal, 0, 100);

-  if (waterLevelPercent < waterLevelThreshold) {
+  if (waterLevelVal < waterLevelThreshold) {
    waterLevelStatus = "LOW";
   } else {
    waterLevelStatus = "OK";


Some comments

Some comments

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -23,12 +23,19 @@

 int function = 0;

+// Associate the PIN_BUTTON GPIO with the ClickButton library
 ClickButton button1(PIN_BUTTON, LOW, CLICKBTN_PULLUP);

+// Register our two HomieNode instances
 HomieNode relayNode("relay", "relay");
 HomieNode buttonNode("button", "button");

 bool RelayHandler(String value) {
+  /*
+  Here we handle incoming requests to set the state of the relay
+  Set the RELAY_PIN to the appropriate level, and additionally set the
+  state on the relayState topic.
+  */
   if (value == "ON") {
     digitalWrite(PIN_RELAY, HIGH);
     Homie.setNodeProperty(relayNode, "relayState", value);
@@ -52,6 +59,8 @@
   // Save click codes in function, as click codes are reset at next Update()
   if(button1.clicks != 0) function = button1.clicks;

+  // These are single event button presses.
+  // Handle them and reset function back to 0
   if ( function > 0 ) {
     Serial.println("One-shot");
     if ( function == 1 ) {
@@ -72,6 +81,8 @@
     function = 0;
   }

+  // These are repeat events, where the button is being held down.
+  // Handle them, but don't reset function back to 0 unless the button is released.
   if ( function < 0 ) {
     if ( function == -1 ) {
       Homie.setNodeProperty(buttonNode, "event", "SINGLEHELD", 0);


x,y,z, on h,v,s channels, start from center pixel

--- sketch_feb09a/sketch_feb09a.ino
+++ sketch_feb09a/sketch_feb09a.ino
@@ -96,22 +96,29 @@
 #define NUM_PIXELS 8
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
 RGBPixel frame[NUM_PIXELS];
+HSVPixel hsvpix;
+RGBPixel rgbpix;

 void setup() {
-  Serial.begin(115200);
   strip.begin();
+  strip.setBrightness(128);
   strip.show();

   // Init Sensors
   bool successful = accel.begin() && mag.begin() && bmp.begin();

   if (!successful) {
-    Serial.println("Check your wiring!");
-    strip.setPixelColor(4, 128, 0, 0);
-    strip.show();
-    while (1);
-  }
-  Serial.println("Beginning");
+    while (1) {
+      strip.setPixelColor(3, 0, 0 , 0);
+      strip.setPixelColor(4, 128, 0, 0);
+      strip.show();
+      delay(500);
+      strip.setPixelColor(3, 128, 0, 0);
+      strip.setPixelColor(4, 0, 0, 0);
+      strip.show();
+      delay(500);
+    }
+  }
 }

 void pulse(int x, sensors_event_t *event, sensors_event_t *previous_event)
@@ -120,28 +127,17 @@
   int8_t y_delta = abs(event->acceleration.y - previous_event->acceleration.y);
   int8_t z_delta = abs(event->acceleration.z - previous_event->acceleration.z);

-  RGBPixel * p = &frame[x];
+  hsvpix.hue = map(x_delta, 0, maxAcceleration, 0, 255);
+  hsvpix.value = map(y_delta, 0, maxAcceleration, 0, 255);
+  hsvpix.saturation = map(z_delta, 0, maxAcceleration, 0, 255);
+
+  hsvpix.loadTo(&rgbpix);

   avg_color(x,
-            map(x_delta, 0, maxAcceleration, 0, 255),
-            p->green,
-            p->blue
+            rgbpix.red,
+            rgbpix.green,
+            rgbpix.blue
            );
-
-  p = &frame[0];
-  avg_color(0,
-            p->red,
-            map(y_delta, 0, maxAcceleration, 0, 255),
-            p->blue
-           );
-
-  p = &frame[NUM_PIXELS - 1];
-  avg_color(NUM_PIXELS - 1,
-            p->red,
-            p->green,
-            map(z_delta, 0, maxAcceleration, 0, 255)
-           );
-
 }

 void loop() {
@@ -150,9 +146,6 @@
   mag.getEvent(&mag_event);

   if (dof.fusionGetOrientation(event, &mag_event, &orientation)) {
-    Serial.print("X: "); Serial.print(event->acceleration.x); Serial.print(", ");
-    Serial.print("Y: "); Serial.print(event->acceleration.y); Serial.print(", ");
-    Serial.print("Z: "); Serial.println(event->acceleration.z);

     if (which) {
       pulse(3, &accel_event_1, &accel_event_2);


Minor corrections to the comments.

Minor corrections to the comments.

--- examples/hello_menu/hello_menu.ino
+++ examples/hello_menu/hello_menu.ino
@@ -37,12 +37,12 @@
  *
  */

-// The official LCD library
+// The LCD library
 #include <LiquidCrystal.h>
-// This library
+// The menu wrapper library
 #include <LiquidMenu.h>

-// Pin mapping for the display
+// Pin mapping for the display:
 const byte LCD_RS = 12;
 const byte LCD_E = 11;
 const byte LCD_D4 = 5;
@@ -134,8 +134,8 @@
   }

   // Periodic switching to the next screen.
-  if (millis() - lastMs_next > period_next) {
-    lastMs_next = millis();
+  if (millis() - lastMs_nextScreen > period_nextScreen) {
+    lastMs_nextScreen = millis();
     menu.next_screen();
   }
 }


commit

commit

--- watermeter/watermeter.ino
+++ watermeter/watermeter.ino
@@ -21,7 +21,7 @@

 /* Name and Version */
 #define PLATFORM "Wemos D1 mini & Micro SD"
-#define MODULE_VERSION "v1.2"
+#define MODULE_VERSION "v2.0"
 #define MODULE_NAME "WaterMeter " MODULE_VERSION
 #define WEB_WATERMETER_FIRST_NAME "Water"
 #define WEB_WATERMETER_LAST_NAME "Meter"


Minor. Code formatting clean up.

Minor. Code formatting clean up.

--- si5351-beacon.ino
+++ si5351-beacon.ino
@@ -63,7 +63,7 @@
   FILTER_BAND_5
 };

-struct LPF_Band_Matching
+struct LPF_Band_Matching
 {
   unsigned char rfBand;
   unsigned char filterBand;
@@ -88,13 +88,13 @@

 // ----- Configure mapping: RF_Band -> Relay_switch_board_LPF  -----
-LPF_Band_Matching relaySwitchBandMatching [] = {
+LPF_Band_Matching relaySwitchBandMatching [] = {
   {RF_Band_40m, FILTER_BAND_5},
   {RF_Band_30m, FILTER_BAND_3},
   {RF_Band_20m, FILTER_BAND_2},
   {RF_Band_15m, FILTER_BAND_1},
   {RF_Band_15m, FILTER_BAND_1}
-
+
 };

 const FilterBand DefaultFilterBand = FILTER_BAND_0; // default band if none of relaySwitchBandMatching[] matched.
@@ -122,7 +122,7 @@

 //
 // Copy vector-descriptor from web configurator and paste into bandDescrArray.
-// Local configurator:  ./doc/band_configurator.html
+// Local configurator:  ./doc/band_configurator.html
 // Configurator in the Net:  http://ra9yer.blogspot.com/p/si5351-configurator.html
 //

@@ -137,7 +137,7 @@

 // ---------- Time Source Configuration. Either GPS module or DS3231.
-//
+//
 // Here you need to select either DS3231 or GPS module. Please comment one and leave another one uncommented.
 //
 //#define TIME_SLICE_GPS
@@ -158,7 +158,7 @@
 #endif

-// ------ Message initialize functions -----
+// ------ Message initialize functions -----

 //--------------------------------------------------
 void initializeWSPRCoder()
@@ -214,10 +214,10 @@
   pinMode(pinBAND3, OUTPUT);
   pinMode(pinBAND4, OUTPUT);
   pinMode(pinBAND5, OUTPUT);
-
-
+
+
   timeSlice.initialize();
-
+
   si5351.initialize();
   si5351.enableOutput(Si5351::OUT_0, false);

@@ -228,7 +228,7 @@
   initializeJT4Coder();

   currentBandIndex = (currentBandIndex < NumBandsTotal)? currentBandIndex : 0;
-  bandParams.initFromJTBandDescr( bandDescrArray[currentBandIndex] );
+  bandParams.initFromJTBandDescr( bandDescrArray[currentBandIndex] );
   bandParams.setXTALFrequencyInKHz( xtalFrequencyInKHz );
   printBandInfo();

@@ -259,7 +259,7 @@
   if( currentState == stateTransmitting )
   {
     unsigned currentSymbolIndex = symbolRate.currentSymbolIndex();
-
+
     if( currentSymbolIndex != prevSymbolIndex )
     {
       unsigned tmpIndex = prevSymbolIndex;
@@ -327,7 +327,7 @@
     timeValid = true;
     adjustLaunchTimeIfNeed();
   }
-
+
   //
   // actions when next second event is detected
   //
@@ -343,7 +343,7 @@
       currentState = statePTTActive;
       activate_ptt();
     }
-
+
     if( currentState == statePTTActive && currentTime >= symbolsStartTime )
     {
       Serial.print(F("Sending data active\n"));
@@ -353,7 +353,7 @@
     }
   }

-
+

 }

@@ -384,7 +384,7 @@
       }
       params[i] = atoi(ptr);
     }
-
+
     RtcDatetime time;
     time.second = params[5];
     time.minute = params[4];
@@ -410,7 +410,7 @@
       // show time N times with 1sec interval
       numShowTime = atoi(ptr);
     }
-
+
   }
   else if( commandBuffer.startsWith(F("start")) ) // manual start
   {
@@ -423,7 +423,7 @@
     {
       Serial.println(F("unable to start when tx active"));
     }
-
+
   }
   else if( commandBuffer.startsWith(F("stop")) )  // manual stop
   {
@@ -435,7 +435,7 @@
     }
     else
     {
-      currentState = stateIdle;
+      currentState = stateIdle;
     }
   }
   else if( commandBuffer.startsWith(F("activate")) )  // activate auto start mode
@@ -457,14 +457,14 @@
     {
       currentState = stateIdle;
     }
-
+
   }
   else if( commandBuffer.startsWith(F("si")) )  // system info
   {
     printTime(true);
     printBandInfo();
   }
-  else if( commandBuffer.startsWith(F("bhe")) ) // band hopping enable
+  else if( commandBuffer.startsWith(F("bhe")) ) // band hopping enable
   {
     Serial.print(F("Band hopping enabled"));
     BandHoppingEnabled = true;
@@ -481,7 +481,7 @@
     {
       switchToNextBandIfNeed(true);
     }
-
+
   }
   else if( commandBuffer.startsWith(F("temperature")) )
   {
@@ -490,7 +490,7 @@
     Serial.print(temperature);
     Serial.println();
   }
-
+
 }

 //--------------------------------------------------
@@ -558,7 +558,7 @@
       itSymbol = wsprCoder.begin();
       itEnd = wsprCoder.end();
       break;
-
+
     case Mode_JT65_A:
     case Mode_JT65_B:
     case Mode_JT65_C:
@@ -568,7 +568,7 @@
       itSymbol = jt65Coder.begin();
       itEnd = jt65Coder.end();
       break;
-
+
     case Mode_JT9_1:
     case Mode_JT9_2:
     case Mode_JT9_5:
@@ -578,7 +578,7 @@
       itSymbol = jt9Coder.begin();
       itEnd = jt9Coder.end();
       break;
-
+
     case Mode_JT4_A:
     case Mode_JT4_B:
     case Mode_JT4_C:
@@ -614,18 +614,18 @@

   si5351.setupMultisyncParams(Si5351::OUT_0, bandParams.getMsyncDiv(), bandParams.getRDiv() );
-
-  unsigned char currentSymbolValue = *itSymbol;
+
+  unsigned char currentSymbolValue = *itSymbol;
   setSymbol( currentSymbolValue );
-
+
   prevSymbolValue = currentSymbolValue;
   prevSymbolIndex = 0;
-
+
   currentState = stateTransmitting;
-
+
   symbolRate.initFromParams( bandParams.getBaudRateDividend(), bandParams.getBaudRateDivisor() );
   symbolRate.resetToNow();
-
+
   si5351.enableOutput(Si5351::OUT_0, true); //
 }

@@ -643,14 +643,14 @@
 {
   if( !BandHoppingEnabled && !force )
     return;
-
+
   currentBandIndex++;
   if( currentBandIndex >= NumBandsTotal )
   {
     currentBandIndex = 0;
   }

-  bandParams.initFromJTBandDescr( bandDescrArray[currentBandIndex] );
+  bandParams.initFromJTBandDescr( bandDescrArray[currentBandIndex] );
   printBandInfo();
 }

@@ -662,19 +662,19 @@
     currentState = stateIdle;
     return;
   }
-
+
   RtcDatetime currentTime;
   if( !timeSlice.getTime(currentTime) )
   {
     Serial.print(F("\ngetTime error"));
     currentState = stateIdle;
   }
-
+
   unsigned trInterval = bandParams.getTRInterval();
   unsigned long stamp = currentTime.stamp();
   stamp += trInterval * TRIntervalMultiplier; // jump to future
   stamp -= (stamp % trInterval); // round down
-  stamp += 1; // JT65,JT9,JT4,WSPR - all start at 01 second
+  stamp += 1; // JT65,JT9,JT4,WSPR - all start at 01 second

   symbolsStartTime.initFromStamp( stamp );
   pttStartTime.initFromStamp( stamp - PTTWarmupTimeInSeconds );
@@ -682,14 +682,14 @@
   printTime(true);

   currentState = stateWaitStart;
-
+
 }

 //----------------------------------------------------------
 void switchRealyToBand(FilterBand band)
 {
   // Activate specified relay. Debounce-free solution.
-
+
   // --- Turn ALL relays off, but not specified.
   if( band != FILTER_BAND_0 ) { digitalWrite(pinBAND0, HIGH); }
   if( band != FILTER_BAND_1 ) { digitalWrite(pinBAND1, HIGH); }
@@ -697,7 +697,7 @@
   if( band != FILTER_BAND_3 ) { digitalWrite(pinBAND3, HIGH); }
   if( band != FILTER_BAND_4 ) { digitalWrite(pinBAND4, HIGH); }
   if( band != FILTER_BAND_5 ) { digitalWrite(pinBAND5, HIGH); }
-
+
   // --- Activate specified relay.
   if( band == FILTER_BAND_0 ) { digitalWrite(pinBAND0, LOW); }
   if( band == FILTER_BAND_1 ) { digitalWrite(pinBAND1, LOW); }
@@ -705,7 +705,7 @@
   if( band == FILTER_BAND_3 ) { digitalWrite(pinBAND3, LOW); }
   if( band == FILTER_BAND_4 ) { digitalWrite(pinBAND4, LOW); }
   if( band == FILTER_BAND_5 ) { digitalWrite(pinBAND5, LOW); }
-
+
 }

 //----------------------------------------------------------
@@ -722,7 +722,7 @@
     {
       filterBand = static_cast<FilterBand>(item.filterBand);
     }
-
+
   }

   return filterBand;
@@ -734,10 +734,10 @@
 {
   RF_Band rfBand = bandParams.getBand(); // gent band based on pll and multisync params
   FilterBand filterBand = convertRFBandToFilterBand(rfBand);
-  switchRealyToBand( filterBand ); // on/off appropriate relay
+  switchRealyToBand( filterBand ); // on/off appropriate relay

   // turn on ptt key here, if the feature present.
-
+
 }

 //----------------------------------------------------------
@@ -745,8 +745,6 @@
 {
   // TODO: in some cases it is not necessary to switch relay off
   switchRealyToBand( FILTER_BAND_None );
-
+
   // turn off ptt key here
 }
-
-


Remove non-necessary code for the demo

Remove non-necessary code for the demo

--- counter/counter.ino
+++ counter/counter.ino
@@ -1,4 +1,6 @@
 #include <Bridge.h>
+
+#include "logger.h"

 #include "thingspeakReceiver.h"
 ThingspeakReceiver thingspeakReceiver;
@@ -7,55 +9,49 @@
 #include <Adafruit_GFX.h>
 #include <Wire.h>

-#define PIN_LED_KO    12
-#define PIN_LED_OK    13
+#define PIN_LED    13

 Adafruit_7segment matrix = Adafruit_7segment();

 void setup() {
-  pinMode(PIN_LED_KO, OUTPUT);
-  pinMode(PIN_LED_OK, OUTPUT);
-
-  _setKO();
+  pinMode(PIN_LED, OUTPUT);

   Bridge.begin(); //Yun Bridge
-  Serial.begin(9600);
-  while (!Serial);
+  logger->init();

+  // init 7-segments matrix
   matrix.begin(0x70);
   matrix.setBrightness(2);
   displayCounter(0);

+
+  //setup the IoT platforms
+  logger->log("Start setup connection with IoT platforms...\n");
   thingspeakReceiver.init();

-  Serial.println("Counter Up !!!");
+  //Everything seems to be ok, let's start !
+  logger->log("\nBottle Opener up, Let's start to play :) !!!\n");

-  _setOK();
-
+  //highlight blue led just to prevent everything is OK. Useful when logs are disabled
+  digitalWrite(PIN_LED, HIGH);
 }

+/**
+   Arduino Loop
+*/
 void loop() {
   int counter = thingspeakReceiver.receiveCounter();

   displayCounter(counter);

-  delay(100);
+  delay(500);
 }

+/**
+   Display Counter on è
+*/
 void displayCounter(int counter) {
   matrix.print(counter);
   matrix.writeDisplay();
-
-  Serial.println(counter);
 }

-
-void _setOK() {
-  digitalWrite(PIN_LED_KO, LOW);
-  digitalWrite(PIN_LED_OK, HIGH);
-}
-
-void _setKO() {
-  digitalWrite(PIN_LED_OK, LOW);
-  digitalWrite(PIN_LED_KO, HIGH);
-}


Added a function to write board state to the system. We also added code to store the state every 1 sec.

--- BackEnd/BackEnd.ino
+++ BackEnd/BackEnd.ino
@@ -161,7 +161,7 @@

 // Configuration file
 #define CONFIG_FILE_MAX_SIZE WEB_SOCKET_BUFFER_SIZE
-#define CONFIG_FILE_FULL_PATH "/home/root/hardware.conf"
+#define BOARD_CONFIG_FILE_FULL_PATH "/home/root/hardware.conf"
 #define HOSTAPD_CONFIG_FILE_FULL_PATH "/etc/hostapd/hostapd.conf"
 //#define TEMP_CONFIG_FILE_FULL_PATH "/etc/hostapd/hostapd_tmp.conf"
 #define TEMP_CONFIG_FILE_FULL_PATH "/etc/hostapd/hostapdTemp.conf"
@@ -476,9 +476,9 @@

   // Read file
   fp = fopen(_sFullFilePath, "r");
-  Serial.println("File Open");
+//  Serial.println("File Open");
   fgets(sJsonFile, CONFIG_FILE_MAX_SIZE, fp);
-  Serial.println("File Close");
+//  Serial.println("File Close");
   fclose(fp);

   /*
@@ -486,11 +486,11 @@
     trace_info("%s() -> Read file", __func__);
   #endif
   */
-  Serial.println("Read File");
+//  Serial.println("Read File");

   // Parse file
   aJsonObject *poMsg = aJson.parse(sJsonFile);
-  Serial.println("Parse File");
+//  Serial.println("Parse File");

   if( poMsg )
   {
@@ -499,31 +499,31 @@
     if( pJsonPins )  // Check if there is pin info
       procPinsMsg( pJsonPins );

-    Serial.println("Set Pins");
+  //  Serial.println("Set Pins");

     aJsonObject *pJsonConnections = aJson.getObjectItem(poMsg, "connections");
     if( pJsonConnections )  // Check if there is pin info
       procConnMsg( pJsonConnections );

-    Serial.println("Set Connections");
+   // Serial.println("Set Connections");

     aJsonObject *pJsonSsid = aJson.getObjectItem(poMsg, "ssid");
     if( pJsonSsid )  // Check if there is connection info
       procSsidMsg( pJsonSsid );

-    Serial.println("System updated from file.");
+  //  Serial.println("System updated from file.");
   }
   else
   {
-    Serial.println("sJsonFile");
-    Serial.println(sJsonFile);
+   // Serial.println("sJsonFile");
+   // Serial.println(sJsonFile);
     Serial.println("Couln't update system from file.");
   }

   // Set the HW state
   updateBoardState();

-  Serial.print("Done updating system");
+ // Serial.print("Done updating system");

 /*
   #ifdef DEBUG_CAT
@@ -621,7 +621,6 @@
   g_oMessageManager.sent(); // Updating Message Manager

   aJson.deleteItem(msg);
-

   return n;
 }
@@ -1361,31 +1360,56 @@
   }
 }

-/////////////////////////////////////////////////////////////////////////////////
-// Arduino standard funtions
-/////////////////////////////////////////////////////////////////////////////////
-void setup()
-{
-  // put your setup code here, to run once:
-  Serial.begin(9600);
-
-  #ifdef DEBUG_CAT
-    trace_info("-----------------------------------------------------------");
-    trace_info("%s(): Starting Backend", __func__);
-  #endif
-
-  //Serial.println("Starting WebServer");
-//  system("/home/root/startAP");
-  system(START_ACCESS_POINT_SCRIPT_FULL_PATH);
-
-  // Initialize HW and JSON protocol code
-  //Serial.println("Initilize Hardware");
-//  initBoardState();
-  initBoardStateFromFile(CONFIG_FILE_FULL_PATH);
-
-  //Serial.println("Starting WebSocket");
-  initWebsocket();
-
+/*
+  unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + WEB_SOCKET_BUFFER_SIZE + LWS_SEND_BUFFER_POST_PADDING];
+  memset(buf,'\0',LWS_SEND_BUFFER_PRE_PADDING + WEB_SOCKET_BUFFER_SIZE + LWS_SEND_BUFFER_POST_PADDING);
+  unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING];
+
+  updateBoardState();
+
+  aJsonObject *msg = getJsonBoardState();
+
+  aJsonStringStream stringStream(NULL, (char *)p, WEB_SOCKET_BUFFER_SIZE);
+  aJson.print(msg, &stringStream);
+  String sTempString((char *)p);
+*/
+
+void writeBoardStateToFile(char* _sFileFullPath)
+{
+  Serial.println("Write state to file");
+  unsigned char buf[WEB_SOCKET_BUFFER_SIZE];
+
+  // Get the state of the board
+  aJsonObject *msg = getJsonBoardState();
+  aJsonStringStream stringStream(NULL, (char *)buf, WEB_SOCKET_BUFFER_SIZE);
+  aJson.print(msg, &stringStream);
+  String sTempString((char *)buf);
+
+  if( msg )
+  {
+    // Open the system file
+    FILE* Output = fopen(_sFileFullPath, "w"); // Write
+
+    if( Output )
+    {
+      // Write the state
+      Serial.println("Board State:");
+      Serial.println(sTempString);
+      fputs((char *)buf, Output);
+    }
+    else
+    {
+      Serial.println("Nothing found in the board state file.");
+    }
+
+    fclose(Output);
+  }
+  else
+  {
+    Serial.println("Nothing to write to board state file.");
+  }
+
+  aJson.deleteItem(msg);
 }

 int getSsidName(char *_sSsidName)
@@ -1440,8 +1464,8 @@
 //  char      TempBuffer[LOCAL_BUFFER_SIZE];

   // Open the file for reading/write.
-  FILE     *Input = fopen(HOSTAPD_CONFIG_FILE_FULL_PATH, "r"); // Read/write
-  FILE     *Output = fopen(TEMP_CONFIG_FILE_FULL_PATH, "w"); // Read/write
+  FILE     *Input = fopen(HOSTAPD_CONFIG_FILE_FULL_PATH, "r"); // Read
+  FILE     *Output = fopen(TEMP_CONFIG_FILE_FULL_PATH, "w"); // Write

   // Our find and replace arguments
   char     *Find = "ssid=";
@@ -1482,6 +1506,33 @@
   return 0;
 }

+/////////////////////////////////////////////////////////////////////////////////
+// Arduino standard funtions
+/////////////////////////////////////////////////////////////////////////////////
+void setup()
+{
+  // put your setup code here, to run once:
+  Serial.begin(9600);
+
+  #ifdef DEBUG_CAT
+    trace_info("-----------------------------------------------------------");
+    trace_info("%s(): Starting Backend", __func__);
+  #endif
+
+  // Start Web Server
+  //Serial.println("Starting WebServer");
+  system(START_ACCESS_POINT_SCRIPT_FULL_PATH);
+
+  // Initialize HW and JSON protocol code
+  //Serial.println("Initilize Hardware");
+//  initBoardState();
+  initBoardStateFromFile(BOARD_CONFIG_FILE_FULL_PATH);
+
+  //Serial.println("Starting WebSocket");
+  initWebsocket();
+
+}
+
 unsigned long last_print = 0;
 int g_iCatNumber = 0;
 int g_iChangeSsid = 1;
@@ -1489,24 +1540,17 @@
 void loop()
 {

-  if (millis() - last_print > 1000) {
-
-    ///////////////////////////////////////
-    // Test code
-    ///////////////////////////////////////
-
- //   getSerialCommand();
-
-/*
-    g_iCatNumber++;
-    char sSsidName[100];
-    sprintf(sSsidName, "CA3333333333333333333333333333344444444444444444444444444444444444444444444T%i", g_iCatNumber);
-    changeSsidName(sSsidName);
- */
-    //////////////////////////////////////////
-
+// TESTING
+//  getSerialCommand();
+
+  if (millis() - last_print > 1000)
+  {
+    // Save board state every ~1 sec
+    writeBoardStateToFile(BOARD_CONFIG_FILE_FULL_PATH);
+
     last_print = millis();
   }
+
 }

 /////////////////////////////////////////////////////////////////////////////////
@@ -1521,13 +1565,14 @@
     switch (g_iByte)
     {
     case UP:
-      g_iNewCode = 0;
+//      g_iNewCode = 0;
+      initBoardStateFromFile(BOARD_CONFIG_FILE_FULL_PATH);
       break;

     case DOWN:

-        Serial.println("Changing SSID");
-        setSsidName("CAT1");
+        Serial.println("Writing board state to file");
+        writeBoardStateToFile(BOARD_CONFIG_FILE_FULL_PATH);

 //        system("shutdown -r now");


Fixed bug in bot code.

Fixed bug in bot code.

--- BotCode/BotCode.ino
+++ BotCode/BotCode.ino
@@ -317,6 +317,8 @@
   bool success = true;
   do
   {
+    // Ensure connection isn't already open
+    sendCommand(F("AT+CIPCLOSE=1"), F("\nOK"));
     success = true;
     // Connect to server
     String response = sendCommand(connection, F("\nOK"));


Increase servo delay to account for refresh interval (20ms)

--- dee-oh-tee.ino
+++ dee-oh-tee.ino
@@ -30,7 +30,7 @@
 const int CLOCKWISE = 0;
 const int COUNTERCLOCKWISE = 1;

-const int SERVO_DELAY = 15; // millis
+const int SERVO_DELAY = 25; // millis

 typedef Adafruit_SoftServo Servo;
 Servo panServo;


Fix a couple of typos

Fix a couple of typos

--- examples/httpserver/httpserver.ino
+++ examples/httpserver/httpserver.ino
@@ -2,7 +2,7 @@
  * WiFlyHQ Example httpserver.ino
  *
  * This sketch implements a simple Web server that waits for requests
- * and servers up a small form asking for a username, then when the
+ * and serves up a small form asking for a username, then when the
  * client posts that form the server sends a greeting page with the
  * user's name and an analog reading.
  *
@@ -115,7 +115,7 @@
 		/* GET request */
 		Serial.println(F("Got GET request"));
 		while (wifly.gets(buf, sizeof(buf)) > 0) {
-		    /* Skip reset of request */
+		    /* Skip rest of request */
 		}
 		sendIndex();
 		Serial.println(F("Sent index page"));


Update si7051demo.ino

Update si7051demo.ino

--- examples/si7051demo/si7051demo.ino
+++ examples/si7051demo/si7051demo.ino
@@ -24,7 +24,7 @@
 	Serial.begin(9600);
 	Serial.println("ClosedCube Si7051 Arduino Test");

-	si7051.begin(0x40);
+	si7051.begin(0x40); // default I2C address is 0x40
 }

 void loop()


Update motor.ino

Update motor.ino

Debugging flag activated

--- DroidMain/motor.ino
+++ DroidMain/motor.ino
@@ -5,7 +5,7 @@

 void driveMotors()
 {
-  Serial.println(__func__);
+  if (debugging == true) { Serial.println(__func__);}

     /* This function will run the motors across the range of possible speeds.
      * Note that maximum speed is determined by the motor itself and the operating voltage.


Added Canbus filter

Added Canbus filter

--- firmware/arduCanbus/arduCanbus.ino
+++ firmware/arduCanbus/arduCanbus.ino
@@ -126,7 +126,9 @@
     {
         CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
         lb.m_long = CAN.getCanId();
-
+
+        if(lb.m_long == 769)
+        {
         Serial.write(MAVLINK_BEGIN);			//start mark
         Serial.write(13);						//payload len
         Serial.write((uint8_t)CMD_CAN_SEND);	//cmd
@@ -136,7 +138,7 @@
         Serial.write(lb.m_pByte[3]);
         Serial.write(len);						//len
         Serial.write(buf, 8);					//data
-
+        }
     }
 }


Revert "Added 10s delay before birth message response"

This reverts commit 0f5dcd10d4795c8bdd11e9fa51a080ce6a57fba4.

--- GarHAge/GarHAge.ino
+++ GarHAge/GarHAge.ino
@@ -273,8 +273,6 @@
   // Temporary code to listen for and respond to HASS birth message
   else if (requestedDoor == hassBirthTopic && requestedAction == hassBirthPayload) {
     Serial.println("Received HASS birth message... Publishing status update(s)...");
-    Serial.println("Delaying 10s to allow HASS to finish startup...");
-    delay(10000);
     publish_door1_status();
     if (door2_enabled) { publish_door2_status();
     }


Fix multiple hit detection

Fix multiple hit detection

--- Guzheng/Guzheng.ino
+++ Guzheng/Guzheng.ino
@@ -57,8 +57,8 @@
   // Set instrument to trumpet
   // 0xC0 is the change instrument command
   // 0x39 is the instrument ID in hex
-  Serial.write(CHANGEINSTRUMENT);
-  Serial.write(INSTRUMENT);
+  // Serial.write(CHANGEINSTRUMENT);
+  // Serial.write(INSTRUMENT);
 }

 // Function for playing note based on ID
@@ -139,7 +139,7 @@
   for (int i = 0; i <= LASTPORT; i++) {
     if(analogRead(i) > THRESHOLD) {
 #ifndef WIND
-      if (lastNote != i || lastNote != 314) {
+      if (lastNote != i) {
 #endif
         // Beam has been cut
         // i+1 is because i is 0 indexed, but the ID starts with 1
@@ -148,14 +148,18 @@
 #ifndef WIND
           lastNote = i;
 #endif
-        } else {
-          if (noteSet == 1) {
-            noteSet = 2;
-          } else {
-            noteSet = 1;
+        } else if (i == 4) {
+#ifndef WIND
+          if (lastNote != 314) {
+#endif
+            if (noteSet == 1) {
+              noteSet = 2;
+            } else {
+              noteSet = 1;
+            }
+#ifndef WIND
+            lastNote = 314;
           }
-#ifndef WIND
-          lastNote = 314;
 #endif
         }
 #ifndef WIND


Create Sketch.ino

Create Sketch.ino


cleanup

cleanup

--- display/display.ino
+++ display/display.ino
@@ -279,6 +279,9 @@
   		else {
     		display_count += 1;
   		}
+	  if (ts.bufferEmpty()) {
+		continue;
+	  }
       // Retrieve the touch point
       TS_Point p = ts.getPoint();
       // Scale from 0-4000 to tft.width() using calibration numbers
@@ -296,6 +299,9 @@
   if (currentMode == 1){
     SettingsScreenInit();
     while (currentMode == 1){
+	  if (ts.bufferEmpty()) {
+		continue;
+	  }
       TS_Point p = ts.getPoint();
       // Scale from 0-4000 to tft.width() using calibration numbers
       p.x = tft.height() - map(p.x, TS_MINX, TS_MAXX, 0, tft.height());


Abort send on too many tries

Abort send on too many tries

--- core.ino
+++ core.ino
@@ -283,16 +283,18 @@
   return n;
 }

-void netsend_P(int n, PGM_P str) {
+boolean netsend_P(int n, PGM_P str) {
   //DEBUG_SERIAL.println("NSP");
   char buff[BUFFER_SIZE+1];
   strncpy_P(buff, str, BUFFER_SIZE);
   buff[BUFFER_SIZE]=0;
-  netsend(n, buff);
-}
-
-void netsend(int n, char* str) {
+  return netsend(n, buff);
+}
+
+boolean netsend(int n, char* str) {
   //DEBUG_SERIAL.println("NSLL");
+  int tries = 10;
+  int i = 0;
   boolean ok = false;
   while (!ok) {
     while(waitData(50)) {
@@ -322,6 +324,14 @@
         skip();
       }
     }
+    if (i++ > tries) {
+      // ABORT
+      espStream->print("\r\nAT\r\n");
+      while(waitData(100)) {
+        readLine();
+      }
+      return false;
+    }
   }
   espStream->print(str);
   DEBUG_SERIAL.println(str);
@@ -329,6 +339,7 @@
   readLineLowLevel();
   waitData(100);
   readLine();
+  return true;
 }

 boolean sendPrep() {


Added new tests.

Added new tests.

--- examples/TestInPin/TestInPin.ino
+++ examples/TestInPin/TestInPin.ino
@@ -36,26 +36,35 @@
   pinMode(IN_PIN,OUTPUT);
   digitalWrite(IN_PIN,LOW);

+  power_switch.setAllChannelsOn();
+}
+
+void blinkInPin()
+{
+  for (int i=0; i<4; ++i)
+  {
+    digitalWrite(IN_PIN,LOW);
+    Serial << "IN_PIN LOW " << endl;
+    delay(LOOP_DELAY);
+    digitalWrite(IN_PIN,HIGH);
+    Serial << "IN_PIN HIGH " << endl;
+    delay(2*LOOP_DELAY);
+  }
+}
+void loop()
+{
   for (int channel=0; channel<channel_count; ++channel)
   {
-    if ((channel % 1) == 0)
-    {
-      power_switch.setChannelOn(channel);
-    }
     if ((channel % 2) == 0)
     {
       power_switch.setChannelMapFalse(channel);
     }
   }
+  blinkInPin();

+  power_switch.setAllChannelsMapFalse();
+  blinkInPin();
+
+  power_switch.setAllChannelsMapTrue();
+  blinkInPin();
 }
-
-void loop()
-{
-  digitalWrite(IN_PIN,LOW);
-  Serial << "IN_PIN LOW " << endl;
-  delay(LOOP_DELAY);
-  digitalWrite(IN_PIN,HIGH);
-  Serial << "IN_PIN HIGH " << endl;
-  delay(2*LOOP_DELAY);
-}


Fixed bug with USB buffer overflow

Fixed bug with USB buffer overflow

--- Motor_Controler.ino
+++ Motor_Controler.ino
@@ -163,7 +163,7 @@
   if (newMessageReceived)
     handleNewMessage();

-  if(millis() - timeOfLastMessageReceived > 100)
+  if(millis() - timeOfLastMessageReceived > 200)
   {
     for(int i=0; i<6; i++)
       u[i] = 0;
@@ -435,12 +435,12 @@
           u[i] = max(buffer, -mios);
       }

-      for (int i=0; i<6; i++)
-      {
-        Serial.print(u[i]);
-        Serial.print(", ");
-      }
-      Serial.println("");
+//      for (int i=0; i<6; i++)
+//      {
+//        Serial.print(u[i]);
+//        Serial.print(", ");
+//      }
+//      Serial.println("");
     }

     else if (buffer == "SetKp")
@@ -508,6 +508,6 @@
     Serial.println("Message ERROR\n\rInvalid command!\n\r");

   newMessageReceived = false;
-  inputString = "";
+  inputString.remove(0);
 }


Added hack to allow direct arduino firmware upload from the src folder instead of having to upload via browser by simply selecting upload firmware in browser without selecting a file. Increased default video to 1920x1080.

--- OpenROV/OpenROV.ino
+++ OpenROV/OpenROV.ino
@@ -40,7 +40,7 @@

 void setup(){

-  delay(5000); //wait 5 seconds before starting to give time for programming pin sets
+  //delay(10000); //wait 5 seconds before starting to give time for programming pin sets

   Serial.begin(115200);


Adjust example to compile with new implementation

--- examples/ESP_AsyncHTTPd/ESP_AsyncHTTPd.ino
+++ examples/ESP_AsyncHTTPd/ESP_AsyncHTTPd.ino
@@ -68,62 +68,47 @@
   Serial.printf("FATFS: %d total, %d used (%.1f%%), block size %d\n",
                 info.totalBytes, info.usedBytes, info.usedBytes*100.0/info.totalBytes, info.blockSize);

-  wwwSrv.on("/all", HTTP_GET, [](AsyncWebServerRequest *request){
+  wwwSrv.on("/all", HTTP_GET, [](AsyncWebRequest &request){
     String json = "{";
     json += "\"heap\":"+String(ESP.getFreeHeap());
     json += ", \"analog\":"+String(analogRead(A0));
     json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
     json += "}";
-    request->send(200, json, "text/json");
+    request.send(200, json, "text/json");
     json = String();
   });

-  wwwSrv.serveStatic("/", VFATFS.openDir("/"));
+  wwwSrv.serveStatic("/test", VFATFS.openDir("/"));

-  wwwSrv.catchAll([](AsyncWebServerRequest *request){
+  wwwSrv.catchAll([](AsyncWebRequest &request){
     Serial.print("NO_HANDLER: ");
-    if(request->method() == HTTP_GET)
-      Serial.print("GET");
-    else if(request->method() == HTTP_POST)
-      Serial.print("POST");
-    else if(request->method() == HTTP_DELETE)
-      Serial.print("DELETE");
-    else if(request->method() == HTTP_PUT)
-      Serial.print("PUT");
-    else if(request->method() == HTTP_PATCH)
-      Serial.print("PATCH");
-    else if(request->method() == HTTP_HEAD)
-      Serial.print("HEAD");
-    else if(request->method() == HTTP_OPTIONS)
-      Serial.print("OPTIONS");
-    else
-      Serial.print("UNKNOWN");
-    Serial.printf(" http://%s%s\n", request->host().c_str(), request->url().c_str());
+    Serial.print(request.methodToString());
+    Serial.printf(" %s %s\n", request.host().c_str(), request.url().c_str());

-    if(request->contentLength()){
-      Serial.printf("_CONTENT_TYPE: %s\n", request->contentType().c_str());
-      Serial.printf("_CONTENT_LENGTH: %u\n", request->contentLength());
+    if(request.contentLength()){
+      Serial.printf("_CONTENT_TYPE: %s\n", request.contentType().c_str());
+      Serial.printf("_CONTENT_LENGTH: %u\n", request.contentLength());
     }

-    int headers = request->headers();
-    int i;
-    for(i=0;i<headers;i++){
-      AsyncWebHeader* h = request->getHeader(i);
-      Serial.printf("_HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str());
-    }
+    request.enumQueries([&](AsyncWebQuery const& q){
+      Serial.printf("_QUERY[%s]: %s\n", q.name.c_str(), q.value.c_str());
+      return false;
+    });

-    int params = request->params();
-    for(i=0;i<params;i++){
-      AsyncWebParameter* p = request->getParam(i);
-      if(p->isFile()){
-        Serial.printf("_FILE[%s]: %s, size: %u\n", p->name().c_str(), p->value().c_str(), p->size());
-      } else if(p->isPost()){
-        Serial.printf("_POST[%s]: %s\n", p->name().c_str(), p->value().c_str());
-      } else {
-        Serial.printf("_GET[%s]: %s\n", p->name().c_str(), p->value().c_str());
+    request.enumHeaders([&](AsyncWebHeader const& h){
+      Serial.printf("_HEADER[%s]:",h.name.c_str());
+      String values;
+      for (auto v : h.values) {
+        values.concat(' ');
+        values.concat(v);
+        values.concat(',');
       }
-    }
-    request->send(404);
+      values.remove(values.length()-1);
+      Serial.println(values);
+      return false;
+    });
+
+    request.send(404);
   });

   wwwSrv.begin();


added comments in send_Blink_ROS to run the ino file with ROS,Arduino and CAN

--- examples/send_Blink_ROS/send_Blink_ROS.ino
+++ examples/send_Blink_ROS/send_Blink_ROS.ino
@@ -1,4 +1,14 @@
 // demo: CAN-BUS Shield, send data
+//Hardware: TWO ArduinoMega with CAN-SHIELDS
+//Run this send_Blink_ROS.ino file on one of the Arduinos
+//Run receive_Blink on the other
+//***ROS commands to be followe***//
+//roscore
+// rosrun roial_python serial_node.py /dev/ttyACM1 _baud:=57600
+// rostopic pub toggle_led std_msgs/Empty -r 100
+//Jaghvi: jaghvim@andrew.cmu.edu
+
+
 #include <mcp_can.h>
 #include <SPI.h>


SetTime: instead of 9999 show ---- on startup

--- SetTime/SetTime.ino
+++ SetTime/SetTime.ino
@@ -313,7 +313,7 @@
 void loop() {
   static bool flag = true;
   if (flag) {
-    sendHHMM(99, 99);
+    setDigits(10, 10, 10, 10, B8(0000000));
     flag = false;
   }
   checkTime();


added read/write control and 6k ROM size

--- firmware/MultiRomVC4000/MultiRomVC4000.ino
+++ firmware/MultiRomVC4000/MultiRomVC4000.ino
@@ -16,7 +16,7 @@

 #define SD_CS          10
 #define FILENAME_SIZE  12    // 8.3 convention, see SD library doc.
-#define MAX_ROM_SIZE   2048
+#define MAX_ROM_SIZE   6144

 #define LED            13

@@ -122,6 +122,9 @@
   digitalWrite(OEDATA, HIGH);
   digitalWrite(OEADDRESS, HIGH);
   digitalWrite(OEVCBUS, LOW);
+  delay(100);
+  //handover R/W control to VC4000
+  digitalWrite(WR, LOW);
 }

 void write2RAM(unsigned int address, byte data) {


Transport works, punching not...

Transport works, punching not...

--- PaperTapePuncher.ino
+++ PaperTapePuncher.ino
@@ -43,13 +43,17 @@
     delay(18);
   }

-  delay(2000);
+  delay(5000);

   for(int i = 0; i < 8; i++)
   {
     digitalWrite(pins[i], HIGH);
     delay(2);
     digitalWrite(pins[i], LOW);
-    delay(18);
+    delay(8);
+    digitalWrite(PinTransportMotor, HIGH);
+    delay(2);
+    digitalWrite(PinTransportMotor, LOW);
+    delay(8);
   }
 }


shortent boot

shortent boot

--- turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
+++ turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
@@ -55,6 +55,18 @@
 int input;
 unsigned char fuse[1024];

+void longboot(){
+    waitMouth();
+  delay(500);
+  openMouth();
+  delay(1000);
+  waitMouth();
+  delay(500);
+  openMouth();
+  delay(1000);
+  waitMouth();
+  delay(1000);
+}
 void setup(){ //////////////SETUP////////////////////////
     pinMode(12, OUTPUT);
 digitalWrite(12, HIGH);
@@ -69,10 +81,9 @@
   readloop(100);
   LCDA.initDriverPin(2,3,4);
   LCDA.Initialise(); // INIT SCREEN
-  openMouth();
-  delay(500);
-  waitMouth();
-
+
+  //longboot();
+  closeMouth();
   //Serial.println(F("boot completed"));
 }


pre merge

pre merge

--- turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
+++ turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
@@ -227,6 +227,13 @@
 void loop(){

   if(Serial.available()==4){
+      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
+  delay(1000);               // wait for a second
+  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
+  delay(1000);               // wait for a second
+  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
+
+  Serial.println("the cow has landed");
     byte b1,b2,b3,b4;
     b1=Serial.read();
     b2=Serial.read();


remove serial output with #define

remove serial output with #define

--- homemonitor/homemonitor.ino
+++ homemonitor/homemonitor.ino
@@ -12,6 +12,8 @@

 */

+// #define SERIAL_OUTPUT // for debugging
+
 // SD storage stuff
 #include <SD.h> // Modified SD.cpp in SD library to allow for multiple SD.begin() calls
 // Add to Line 343 of SD.cpp: 'if (root.isOpen()) {root.close();}'
@@ -63,6 +65,7 @@
   }
 }

+#ifdef SERIAL_OUTPUT
 void readFileToSerial(char* filename)
 {
   // re-open the file for reading:
@@ -83,6 +86,7 @@
     Serial.println("error opening for reading");
   }
 }
+#endif

 // Append float value to file
 void logToFile(char* filename, float value)
@@ -93,21 +97,27 @@

   // if the file opened okay, write to it:
   if (myFile) {
+    #ifdef SERIAL_OUTPUT
     // Serial info
     Serial.print("Writing ");
     Serial.print(value);
     Serial.print(" to ");
     Serial.print(filename);
     Serial.print("... ");
+    #endif

     // Write value to file and close
     myFile.println(value);
     myFile.close();

+    #ifdef SERIAL_OUTPUT
     Serial.println("done.");
+    #endif
   } else {
     // if the file didn't open, print an error:
+    #ifdef SERIAL_OUTPUT
     Serial.println("error opening for writing.");
+    #endif
   }
 }

@@ -120,6 +130,7 @@

   // if the file opened okay, write to it:
   if (myFile) {
+    #ifdef SERIAL_OUTPUT
     // Serial info
     Serial.print("Writing '");
     Serial.print(month());
@@ -132,6 +143,7 @@
     Serial.print("' to ");
     Serial.print(filename);
     Serial.print("... ");
+    #endif

     // Write value to file and close
     myFile.print(month());
@@ -143,16 +155,22 @@
     myFile.println(minute());
     myFile.close();

+    #ifdef SERIAL_OUTPUT
     Serial.println("done.");
+    #endif
   } else {
     // if the file didn't open, print an error:
+    #ifdef SERIAL_OUTPUT
     Serial.println("error opening for writing.");
+    #endif
   }
 }

 boolean startSD()
 {
+  #ifdef SERIAL_OUTPUT
   Serial.print("Initializing SD card...");
+  #endif
   // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
   // Note that even if it's not used as the CS pin, the hardware SS pin
   // (10 on most Arduino boards, 53 on the Mega) must be left as an output
@@ -160,10 +178,14 @@
   pinMode(10, OUTPUT);

   if (!SD.begin(4)) {
+    #ifdef SERIAL_OUTPUT
     Serial.println("initialization failed!");
+    #endif
     return false;
   }
+  #ifdef SERIAL_OUTPUT
   Serial.println("initialization done.");
+  #endif
   return true;
 }

@@ -185,7 +207,6 @@
 void recordData()
 {
   delay(250);
-  Serial.println("Woo");
   if (startSD())
   {
     SDCardExists = true;
@@ -197,12 +218,14 @@
     logToFile("T_in.txt", tempA);
     logToFile("T_out.txt", tempB);

+    #ifdef SERIAL_OUTPUT
     Serial.println("time.txt: ");
     readFileToSerial("time.txt");
     Serial.println("T_in.txt: ");
     readFileToSerial("T_in.txt");
     Serial.println("T_out.txt: ");
     readFileToSerial("T_out.txt");
+    #endif
   }
   else {
     SDCardExists = false;
@@ -249,7 +272,9 @@

 void setup()
 {
+  #ifdef SERIAL_OUTPUT
   Serial.begin(9600);
+  #endif

   // Initialize the lcd with backlight on
   lcd.init();
@@ -259,10 +284,12 @@

   // Set RTC sync
   setSyncProvider(RTC.get); // get time from Real Time Clock
+  #ifdef SERIAL_OUTPUT
   if(timeStatus()!= timeSet)
     Serial.println("Unable to sync with the RTC");
   else
     Serial.println("RTC has set the system time");
+  #endif

   // Since we're using a filter call update several times to populate
   for (int i = 0; i < 50; ++i)
@@ -314,7 +341,9 @@
   // Called like this to avoid SPI bus collision between SD & LCD
   if (trigger_logging)
   {
+    #ifdef SERIAL_OUTPUT
     Serial.println("Trigger Button");
+    #endif
     recordData();
     delay(250);
     lcd.clear();


added LED management

added LED management

--- examples/androidCar/androidCar.ino
+++ examples/androidCar/androidCar.ino
@@ -18,6 +18,9 @@
 unsigned long overrideRelease = 0;
 boolean overrideTriggered = false;

+unsigned long prevCheck = 0;
+const unsigned short LEDrefreshRate = 200;
+
 void setup() {
   car.begin();
   frontSonar.attach(FRONT_US_TRIG_PIN, FRONT_US_ECHO_PIN);
@@ -32,13 +35,34 @@
   gyro.begin(); //start measuring
   Serial2.begin(9600);
   Serial2.setTimeout(200);
+  Serial3.begin(9600);
 }

 void loop() {
   handleOverride(); //look for an override signal and if it exists disable bluetooth input
   handleInput();
+  updateLEDs();
   gyro.update();
   transmitSensorData();
+}
+
+void updateLEDs() {
+  if (millis() - prevCheck > LEDrefreshRate) {
+    if (overrideTriggered) { //if override is triggered
+      Serial3.print('m');
+    } else {  //if override is NOT triggered
+      if (!car.getSpeed()) { //if car is immobilized
+        Serial3.print('s');
+      } else if (car.getAngle() > 0 && car.getSpeed()) { //if car is running and turns right
+        Serial3.print('r');
+      } else if (car.getAngle() < 0 && car.getSpeed()) { //if car is running and turns left
+        Serial3.print('l');
+      } else if (car.getSpeed() && !car.getAngle()) { //if car is running and goes straight
+        Serial3.print('i');
+      }
+    }
+    prevCheck = millis();
+  }
 }

 void handleOverride() {
@@ -82,7 +106,7 @@

 void handleInput() {
   if (!overrideTriggered || (millis() > overrideRelease)) {
-    overrideTriggered = false;
+    if (overrideTriggered) overrideTriggered = false;
     if (Serial2.available()) {
       String input = decodedNetstring(Serial2.readStringUntil(','));
       Serial.println(input);


added serial listen, commented out physical buttons for now

--- IR_transmit/IR_transmit.ino
+++ IR_transmit/IR_transmit.ino
@@ -15,37 +15,53 @@
 #include <Bounce2.h>

 IRsend irsend; // the IR transmit pin is 11, also requires a 50-150 ohm resistor
-const int button1 = 8; //The power button on this pin and ground
-const int button2 = 9; //The NoShow button on this pin and ground
-const int led2 = 2; //The red status LED
+int serialMessage; // for data we'll receive from the serial port
 // buttons can be connected to 3 through 10, 12 to 15, 18, and 19
 // for a total of 14 (or 13 if we don't use pin 14 which is GREEN_LED)
 // but if we use serial communication, we also can't use pins 3 and 4
+const int button1 = 8; //The power button on this pin and ground
+const int button2 = 9; //The NoShow button on this pin and ground

-// initialize a string variable for the serial data received from the computer
-String controlCode = "";
-boolean stringComplete = false;  // whether the string is complete
-
-Bounce bouncer1 = Bounce(button1, 20); // 20 millisecond debounce
-Bounce bouncer2 = Bounce(button2, 20);
+// debounce values are 20 milliseconds for each button
+//Bounce bouncer1 = Bounce(button1, 20);
+//Bounce bouncer2 = Bounce(button2, 20);

 void setup() {
   pinMode(button1,INPUT_PULLUP);
   pinMode(button2,INPUT_PULLUP);
-  pinMode(led2,OUTPUT);
-  // set up serial listen, so that we can receive OSC commands relayed from the computer
+  pinMode(GREEN_LED,OUTPUT); // pin 14
+  pinMode(RED_LED,OUTPUT); // pin 2
+  // set up serial listen, so that we can receive "OSC" commands relayed from the computer
   Serial.begin(9600);
-  // reserve 200 bytes for the inputString:
-  inputString.reserve(200);
 }

+
+
 void loop() {
+  // read from the serial port to see if the computer is talking
+  while(Serial.available()) {
+    serialMessage = Serial.read();
+  }
+  if (serialMessage == '1')
+  {
+    digitalWrite(GREEN_LED, HIGH); // turn the LED on
+  } else {
+    digitalWrite(GREEN_LED, LOW); // otherwise turn it off
+  }
+  if (serialMessage == '2')
+  {
+    digitalWrite(RED_LED, HIGH);
+  } else {
+    digitalWrite(RED_LED, LOW);
+  }
+
+/* here's a bunch of code for physical buttons that we'll deal with later
   // Update the debouncers
   bouncer1.update ( );
   bouncer2.update ( );

   if (bouncer1.read() == 0) {
-    digitalWrite(led2, HIGH); // turn on the red status LED so we know something is happening
+    digitalWrite(RED_LED, HIGH); // turn on the red status LED so we know something is happening
     irsend.sendNEC(0x5EA1F807, 32); // send power toggle
     delay(100);
     irsend.sendNEC(0x5EA1EA15, 32); // send sleep (120 minutes is the default, send again to decrement)
@@ -53,7 +69,7 @@
     delay(1000); // wait for a second
   }
   else if (bouncer2.read() == 0) {
-    digitalWrite(led2, HIGH); // turn on the red status LED so we know something is happening
+    digitalWrite(RED_LED, HIGH); // turn on the red status LED so we know something is happening
     irsend.sendNEC(0x5EA1837C, 32); // send input DVD
     delay(100);
     irsend.sendNEC(0x5EA1A857, 32); // send input CD
@@ -63,6 +79,7 @@
   }
   else {
   }
+  */
 }

 /*


needed internal ref for temp convert

needed internal ref for temp convert

--- embedded/qubo_arduino/qubo_arduino.ino
+++ embedded/qubo_arduino/qubo_arduino.ino
@@ -44,6 +44,9 @@

   sensor.setFluidDensity(997); // kg/m^3 (997 freshwater, 1029 for seawater)

+  // for lm35 https://playground.arduino.cc/Main/LM35HigherResolution
+  analogReference(INTERNAL);
+
   // Done setup, so send connected command
   //Serial.println(CONNECTED);
   alive = millis();


Improvements for IRMQTTServer example (#466)

- Bump to v0.4
- Set the serial use to be TX-only. Freeing the RX pin for possible use.
- Protect against using debug output and TX pin for IR LED.
- Add comment suggestions for how to use this on an ESP-01 module.
- Display the version.

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -1,9 +1,8 @@
 /*
  * Send arbitrary IR codes via a web server or MQTT.
  * Copyright David Conran 2016, 2017, 2018
- * Version 0.3 Oct, 2017
  *
- * NOTE: An IR LED circuit *MUST* be connected to ESP8266 pin 4 (D2). See IR_LED
+ * NOTE: An IR LED circuit *MUST* be connected to ESP8266 GPIO4 (D2). See IR_LED
  *
  * WARN: This is very advanced & complicated example code. Not for beginners.
  *       You are strongly suggested to try & look at other example code first.
@@ -130,7 +129,9 @@
 #include <string>

 // Configuration parameters
-#define IR_LED 4  // GPIO the IR LED is connected to/controlled by. GPIO 4 = D2.
+// GPIO the IR LED is connected to/controlled by. GPIO 4 = D2.
+#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.

@@ -154,7 +155,18 @@
 #define argData "code"
 #define argBits "bits"
 #define argRepeat "repeats"
-#define DEBUG True
+
+#define _MY_VERSION_ "v0.4"
+
+#if IR_LED != 1  // Disable debug output if the LED is on the TX (D1) pin.
+#undef DEBUG
+#define DEBUG true  // Change to 'false' to disable all serial output.
+#else
+#undef DEBUG
+#define DEBUG false
+#endif
+// NOTE: Make sure you set your Serial Monitor to the same speed.
+#define BAUD_RATE 115200  // Serial port Baud rate.

 // Globals
 ESP8266WebServer server(HTTP_PORT);
@@ -243,6 +255,7 @@
     "
Information
"
     "
IP address: " + WiFi.localIP().toString() + "
"
     "Booted: " + timeSince(1) + "
" +
+    "Version: " _MY_VERSION_ "
"
     "IR Lib Version: " _IRREMOTEESP8266_VERSION_ "
"
     "Total send requests: " + String(sendReqCounter) + "
"
 #ifdef MQTT_ENABLE
@@ -831,7 +844,12 @@
   irsend.begin();

   #ifdef DEBUG
-  Serial.begin(115200);
+  // Use SERIAL_TX_ONLY so that the RX pin can be freed up for GPIO/IR use.
+  Serial.begin(BAUD_RATE, SERIAL_8N1, SERIAL_TX_ONLY);
+  while (!Serial)  // Wait for the serial connection to be establised.
+    delay(50);
+  Serial.println();
+  debug("IRMQTTServer " _MY_VERSION_" has booted.");
   #endif  // DEBUG

   setup_wifi();


added delay for serial port

added delay for serial port

--- SensorShirt/SensorShirt.ino
+++ SensorShirt/SensorShirt.ino
@@ -17,8 +17,8 @@

 void setup() {
   Serial.begin(9600);
-  delay(1000);
-  setVariables();
+  while(!Serial) {} // wait for serial port to connect
+  setVariables();
 }

 void loop() {


Make the config more readable.

Make the config more readable.

--- JnGeneral/JnGeneral.ino
+++ JnGeneral/JnGeneral.ino
@@ -352,7 +352,8 @@
 {
     Serial.print(F("Defined devices:\r\n"));
     for(byte i=0; i<numDevices; i++) {
-        printInt(i);
+        Serial.print("  ");
+        printInt(devices[i].device_id);
         Serial.print(" ");
         Serial.print(devices[i].name);
         Serial.print(", measures: ");
@@ -372,6 +373,7 @@
 {
     Serial.print(F("Current configuration:\r\n"));
     for(byte i=0; i<numPlugs; i++) {
+        Serial.print("  ");
         Serial.print("port ");
         printInt(plugs[i].port);
         Serial.print(" ");
@@ -399,6 +401,7 @@

         Serial.print("\r\n");
     }
+    Serial.print("  RF12: ");
     Serial.println(rf12config.msg);
 }


remove last fastled stuff

remove last fastled stuff


Fix compile issue on ESP32 platform. (#938)

Hat tip to @augustozanellato for finding the issue.
Ref #885 & #936

--- examples/IRsendProntoDemo/IRsendProntoDemo.ino
+++ examples/IRsendProntoDemo/IRsendProntoDemo.ino
@@ -92,7 +92,11 @@

 void setup() {
   irsend.begin();
-  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
+  #if defined(ESP8266)
+    Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
+  #else  // ESP8266
+    Serial.begin(115200, SERIAL_8N1);
+  #endif  // ESP8266
 }

 void loop() {


Fixed dumb typo

Fixed dumb typo

--- Arduino/SNES_4021_Emulation/SNES_4021_Emulation.ino
+++ Arduino/SNES_4021_Emulation/SNES_4021_Emulation.ino
@@ -28,7 +28,7 @@
 /* The following two lines should replace the above two lines if you want to test this on an Uno board. I have no idea if this actually works. If it does, then awesome.
 #define WRITE_DATA_HIGH PORTD |= B00010000
 #define WRITE_DATA_LOW PORTD &= B11101111
-The rest of the code shouldn't doesn't need any changes */
+The rest of the code shouldn't need any changes */

 int saveddata = 0xffff;
 byte serialData1 = 0;


Developed methods for virtual movements of the cube sides


Changed magic numbers for servor neutral to Constants defined in motors.cpp

--- arduino/OpenROV/OpenROV.ino
+++ arduino/OpenROV/OpenROV.ino
@@ -29,14 +29,14 @@
 int index = 0;                  // the index of the current reading
 int total = 0;                  // the running total
 int average = 0;                // the average
-int c_tilt = 90;
-int c_motorp = 90;
-int c_motors = 90;
-int c_motorv = 90;
-int tilt_val = 90;
-int p = 90;
-int v = 90;
-int s = 90;
+int c_tilt = MIDPOINT;
+int c_motorp = MIDPOINT;
+int c_motors = MIDPOINT;
+int c_motorv = MIDPOINT;
+int tilt_val = MIDPOINT;
+int p = MIDPOINT;
+int v = MIDPOINT;
+int s = MIDPOINT;

 void setup(){


captured some tuning of catdoor v1

captured some tuning of catdoor v1

--- arduino/catdoor/catdoor.ino
+++ arduino/catdoor/catdoor.ino
@@ -11,7 +11,7 @@
 Adafruit_VCNL4010 proxim_sensor;

 #define NB_PROXIM_SAMPLES 20
-#define NB_ANOMALY_COUNTS 9
+#define NB_ANOMALY_COUNTS 7

 #define MAX_CLIENT_RETRIES 10


to use SPI change pins

to use SPI change pins

--- _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
+++ _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
@@ -30,14 +30,16 @@
 IPAddress time_server = MQTT_SERVER;

 // pin
-#define pir 13
-#define DHTPIN 14
+//#define pir 13
+//#define DHTPIN 14
+#define pir 16
+#define DHTPIN 2
 #define RELAYPIN 4
 #define TOPBUTTONPIN 5

 // DHT22
 #define DHTTYPE DHT22   // DHT 22  (AM2302)
-DHT dht(DHTPIN, DHTTYPE, 15);
+DHT dht(DHTPIN, DHTTYPE);

 // OTHER
 #define REPORT_INTERVAL 9500 // in msec
@@ -45,7 +47,8 @@
 #define BETWEEN_RELAY_ACTIVE 5000

 // DS18B20
-#define ONE_WIRE_BUS 12
+//#define ONE_WIRE_BUS 12
+#define ONE_WIRE_BUS 0
 #define TEMPERATURE_PRECISION 12

 OneWire oneWire(ONE_WIRE_BUS);
@@ -81,8 +84,9 @@
 float f ;

 //
-volatile int pirValue = LOW;
-volatile int pirSent  = LOW;
+int pirValue ;
+int pirSent  ;
+int oldpirValue ;

 /*
 volatile int relaystatus    = LOW;
@@ -262,8 +266,11 @@
   }

   //
-  attachInterrupt(13, motion_detection, RISING);
+  //attachInterrupt(16, motion_detection, RISING);
   attachInterrupt(5, run_lightcmd, CHANGE);
+
+  pirSent = LOW ;
+  pirValue = oldpirValue = digitalRead(pir);

   sensors.begin();
   if (!sensors.getAddress(outsideThermometer, 0)) {
@@ -363,6 +370,10 @@
   runTimerDoLightOff();

   pirValue = digitalRead(pir);
+  if ( oldpirValue != pirValue ) {
+    pirSent = HIGH;
+    oldpirValue = pirValue;
+  }

   payload = "{\"Humidity\":";
   payload += h;
@@ -380,10 +391,11 @@
   payload += (millis() - timemillis);
   payload += "}";

-  if (( pirSent == HIGH ) && ( pirValue == HIGH ))
+  //if (( pirSent == HIGH ) && ( pirValue == HIGH ))
+  if ( pirSent == HIGH )
   {
     sendmqttMsg(topic, payload);
-    pirSent = LOW ;
+    pirSent = LOW;
     startMills = millis();
   }

@@ -444,7 +456,7 @@

   lastRelayActionmillis = millis();
   oldrelaystatus = relaystatus ;
-  //relayIsReady = LOW;
+  //relayIsReady = LOW;
 }

 void getdht22temp()
@@ -522,10 +534,18 @@
   }
 }

+// pin 16 can't be used for Interrupts
+/*
 void motion_detection()
 {
-  pirValue = pirSent = HIGH ;
-}
+  if (DEBUG_PRINT) {
+    Serial.println("motion_detection called");
+  }
+  //pirValue =
+  pirValue = digitalRead(pir);
+  pirSent = HIGH ;
+}
+*/

 String macToStr(const uint8_t* mac)
 {


Firmware ~ Added BT support

Firmware ~ Added BT support

--- arduino/tLamp/TLamp.ino
+++ arduino/tLamp/TLamp.ino
@@ -1,6 +1,14 @@
+#include <SoftwareSerial.h>
+
 #define PIN_RED 3
 #define PIN_GREEN 4
 #define PIN_BLUE 5
+
+#define PIN_BT_RX 10
+#define PIN_BT_TX 11
+
+#define BAUDRATE_SERIAL 9600
+#define BAUDRATE_BT 9600

 #define PIN_STATUS LED_BUILTIN

@@ -28,6 +36,8 @@

 unsigned long lightModeStart = 0;
 LightMode lightMode = NONE;
+
+SoftwareSerial BT(PIN_BT_RX, PIN_BT_TX);

 void setup() {
   pinMode(PIN_RED, OUTPUT);
@@ -40,27 +50,42 @@
   digitalWrite(PIN_BLUE, LOW);
   digitalWrite(PIN_STATUS, LOW);

-  Serial.begin(9600);
+  Serial.begin(BAUDRATE_SERIAL);
+
+  BT.begin(BAUDRATE_BT);
 }

 void loop() {
   if (Serial.available()) {
     String command = Serial.readStringUntil('\n');
-
-    String output = processCommand(command);
+    handleCommand(command, false);
+  }
+
+  if (BT.available()) {
+    String command = BT.readStringUntil('\n');
+    handleCommand(command, true);
+  }
+
+  processLightMode();
+}
+
+void handleCommand(String command, boolean fromBT) {
+  String output = processCommand(command);
     if (output.length() > 0) {
-      Serial.println("+" + command);
-      if (output != EMPTY_COMMAND_SUCCESS)
-        Serial.println(output);
+      if (fromBT) BT.println("+" + command);
+      else Serial.println("+" + command);
+      if (output != EMPTY_COMMAND_SUCCESS) {
+        if (fromBT) BT.println(output);
+        else Serial.println(output);
+      }
       blink(PIN_STATUS, 2);
     } else {
-      Serial.println("-" + command);
-      Serial.println("UNKNOWN");
+      if (fromBT) BT.println("-" + command);
+      else Serial.println("-" + command);
+      if (fromBT) BT.println("UNKNOWN");
+      else Serial.println("UNKNOWN");
       blink(PIN_STATUS, 1);
     }
-  }
-
-  processLightMode();
 }

 void processLightMode() {


Added SD card logging

Added SD card logging

--- code/arduino/logger/logger_sketch/logger_sketch.ino
+++ code/arduino/logger/logger_sketch/logger_sketch.ino
@@ -15,9 +15,15 @@
 #include <dht11.h>

+#include <SPI.h>
+#include <SD.h>
+
+
 #define DHT11_PIN 3

 dht11 DHT11;
+const int chipSelect = 10;
+File dataFile;

 void setup() {
@@ -39,6 +45,21 @@
         char error[] = "clock error" ;
         Serial.println(error);
         for(;;);
+    }
+
+    // initialize SD card
+    pinMode(SS, OUTPUT);
+        if (!SD.begin(chipSelect)) {
+        Serial.println("Card failed, or not present");
+        // don't do anything more:
+        while (1) ;
+    }
+
+    dataFile = SD.open("yuktix.dat", FILE_WRITE);
+    if (! dataFile) {
+        Serial.println("error opening yuktix.dat");
+        // Wait forever since we cant write data
+        while (1) ;
     }

     Alarm.timerRepeat(10, log_data);
@@ -65,8 +86,12 @@
     }

     buffer[16] = '\0' ;
-    micro_delay(200);
+    // @debug
     Serial.println(buffer);
+    // write to SD card
+    dataFile.println(buffer);
+    dataFile.flush();
+
 }

 // param n is to ensure n*10 ms delay


Fixed MQTT color response

Fixed MQTT color response

Leading zeros are not trimmed on /c topic anymore :)
Before blue: #FF
After blue: #0000FF

--- wled00/wled17_mqtt.ino
+++ wled00/wled17_mqtt.ino
@@ -85,7 +85,7 @@
   strcat(subuf, "/g");
   mqtt->publish(subuf, 0, true, s);

-  sprintf(s, "#%X", col[3]*16777216 + col[0]*65536 + col[1]*256 + col[2]);
+  sprintf(s, "#%06X", col[3]*16777216 + col[0]*65536 + col[1]*256 + col[2]);
   strcpy(subuf, mqttDeviceTopic);
   strcat(subuf, "/c");
   mqtt->publish(subuf, 0, true, s);


Corrected link address in Midi example

Corrected link address in Midi example

--- build/shared/examples/04.Communication/MIDI/Midi.ino
+++ build/shared/examples/04.Communication/MIDI/Midi.ino
@@ -13,12 +13,12 @@
  Attach a MIDI cable to the jack, then to a MIDI synth, and play music.

  created 13 Jun 2006
- modified 30 Aug 2011
+ modified 13 Aug 2012
  by Tom Igoe

  This example code is in the public domain.

- http://www.arduino.cc/en/Tutorial/MIDI
+ http://www.arduino.cc/en/Tutorial/Midi

  */


Logic for increment/decrement spin offset via buttons

--- NeoPixelSwitchBox/NeoPixelSwitchBox.ino
+++ NeoPixelSwitchBox/NeoPixelSwitchBox.ino
@@ -11,8 +11,12 @@
     BUG (believe I fixed it): when calling stopBlinking, if the light is off, won't turn on because it won't be queried during updateBlinkingLights.
     Or, something else may be going on. Seems like it sometimes gets one more update.

-  TODO:
+   Functionality test:
     increment/decrement buttons
+    rainbow
+    random
+
+    Concerned that I may have now run it out of memory again...
   */

   // have to include libraries referenced within libraries in the sketch as well!
@@ -59,6 +63,10 @@
   /* has the random number generator been seeded? Set true the first time random is used */
   bool seededRand = false;

+  /* Increment/decrement spin buttons on pins 0/1 - need to disable if want serial communication */
+  Switch incrementSpinButton(0, DEBOUNCE_TIME);
+  Switch decrementSpinButton(1, DEBOUNCE_TIME);
+
    /* Place light switches on 2 - 9, because pins 0 and 1 are used for serial communication */
   const int FIRST_LIGHT_SWITCH_PIN = 2;

@@ -75,7 +83,7 @@
   //button on pin 11, debounce for DEBOUNCE_TIME
   Switch rainbowButton(11, DEBOUNCE_TIME);

-  /* Buttons */
+  // button on pin 12 - toggle spin on/off
   Switch toggleSpinButton(12, DEBOUNCE_TIME);

   /* Potentiometers on analog inupts*/
@@ -93,7 +101,7 @@

   void setup() {
-     Serial.begin(9600);
+    Serial.begin(9600);
     logger.log("--- Start Serial Monitor ");

     /*
@@ -130,6 +138,9 @@
     // update the spin knob before the spin toggle, just in case they both change on the same update. Want the button to override */
     updateSpinKnob();
     updateToggleSpinButton();
+
+    // update the increment/decrement buttons
+    updateIncrementButtons();

     // update the other pots
     updateBlinkKnob();
@@ -253,6 +264,21 @@
      }
   }

+  void updateIncrementButtons() {
+
+    // spin increment button adjusts the spin 1 clockwise
+    incrementSpinButton.update();
+    if (incrementSpinButton.closedThisUpdate()) {
+      ring.adjustSpinOffset(1);
+    }
+
+    // spin decrement button adjusts the spin 1 counter-clockwise
+    decrementSpinButton.update();
+    if (incrementSpinButton.closedThisUpdate()) {
+      ring.adjustSpinOffset(-1);
+    }
+  }
+
   void updateRainbowButton() {
      rainbowButton.update();
      if (rainbowButton.closedThisUpdate()) {


remove useless file

remove useless file

--- Mark/Arduino/sketch.ino
+++ Mark/Arduino/sketch.ino
@@ -1,42 +0,0 @@
-void setup(){
-  pinMode(2,INPUT);
-  pinMode(3,INPUT);
-  pinMode(4,INPUT);
-  pinMode(5,INPUT);
-  pinMode(6,INPUT);
-  pinMode(7,INPUT);
-  pinMode(8,INPUT);
-  pinMode(9,INPUT);
-  pinMode(10,INPUT);
-  Serial.begin(9600);
-}
-
-void loop(){
-  if(digitalRead(2) == 1){
-	Serial.println("1");
-  }
-  if(digitalRead(3) == 1){
-	Serial.println("2");
-  }
-  if(digitalRead(4) == 1){
-	Serial.println("3");
-  }
-  if(digitalRead(5) == 1){
-	Serial.println("4");
-  }
-  if(digitalRead(6) == 1){
-	Serial.println("5");
-  }
-  if(digitalRead(7) == 1){
-	Serial.println("6");
-  }
-  if(digitalRead(8) == 1){
-	Serial.println("7");
-  }
-  if(digitalRead(9) == 1){
-	Serial.println("8");
-  }
-  if(digitalRead(10) == 1){
-	Serial.println("9");
-  }
-}


PSK mininum length 8 to avoid being locked out

--- ESPloitV2_whid/source/ESP_Code/ESP_Code.ino
+++ ESPloitV2_whid/source/ESP_Code/ESP_Code.ino
@@ -252,7 +252,7 @@
   "Yes <INPUT type=\"radio\" name=\"hidden\" value=\"1\"")+hiddenyes+F(">
"
   "No <INPUT type=\"radio\" name=\"hidden\" value=\"0\"")+hiddenno+F(">

"
   "SSID: <input type=\"text\" name=\"ssid\" value=\"")+ssid+F("\" maxlength=\"31\" size=\"31\">
"
-  "Password: <input type=\"password\" name=\"password\" value=\"")+password+F("\" maxlength=\"64\" size=\"31\">
"
+  "Password: <input type=\"password\" name=\"password\" value=\"")+password+F("\" minlength=\"8\" maxlength=\"64\" size=\"31\">
"
   "Channel: <select name=\"channel\" form=\"configuration\"><option value=\"")+channel+"\" selected>"+channel+F("</option><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option><option value=\"5\">5</option><option value=\"6\">6</option><option value=\"7\">7</option><option value=\"8\">8</option><option value=\"9\">9</option><option value=\"10\">10</option><option value=\"11\">11</option><option value=\"12\">12</option><option value=\"13\">13</option><option value=\"14\">14</option></select>

"
   "IP: <input type=\"text\" name=\"local_IPstr\" value=\"")+local_IPstr+F("\" maxlength=\"16\" size=\"31\">
"
   "Gateway: <input type=\"text\" name=\"gatewaystr\" value=\"")+gatewaystr+F("\" maxlength=\"16\" size=\"31\">
"


отправка A0-A3

отправка A0-A3

--- serialracoon.ino
+++ serialracoon.ino
@@ -139,25 +139,19 @@
 }

 int cnt = 0;
-
 int board = 0;

 const int aInPin = A0;
-
-int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3
-
-                       // outside leads to ground and +5V
-
-int val = 0;           // variable to store the value read
-
-
+int analogPin = 3;
+
+int v0 = 0;
+int v1 = 0;
+int v2 = 0;
+int v3 = 0;

 void loop()
 {
   int btIn = -1;
-
-
-  val = analogRead(A0);    // read the input pin

   if (BTSerial.available() && (btIn = BTSerial.read()) ) {
     Serial.write(btIn);
@@ -185,9 +179,14 @@

   char out[80];

+  v0 = analogRead(A0);
+  v1 = analogRead(A1);
+  v2 = analogRead(A2);
+  v3 = analogRead(A3);
+
   if (board == 0) {
     //sprintf(out, "seqid %d;%d;;;\r\n", cnt++, val);
-    sprintf(out, "%d;%d;%d;%d\r\n", cnt, val+0, val+1, val+2);
+    sprintf(out, "%d;%d;%d;%d;%d\r\n", cnt, v0, v1, v2, v3);
     Serial.println(out);
     BTSerial.write(out);
     delay(100);


Update version to 1.0.0.

Update version to 1.0.0.

Out of beta!


Debugging facilities.

Debugging facilities.

--- maze_robot.ino
+++ maze_robot.ino
@@ -1,12 +1,37 @@
 #include <Servo.h>
+#include <Metro.h>
+#define Serial Serial1

-#define STOP_BUTTON 1
-#define DOWN_BUTTON 0
-#define UP_BUTTON 2
+#include <stdarg.h>
+void p(char *fmt, ... ){
+  char buf[128]; // resulting string limited to 128 chars
+  va_list args;
+  va_start (args, fmt );
+  vsnprintf(buf, 128, fmt, args);
+  va_end (args);
+  Serial.println(buf);
+}

-#define DIST_IN_F 19
+void p(const __FlashStringHelper *fmt, ... ){
+  char buf[128]; // resulting string limited to 128 chars
+  va_list args;
+  va_start (args, fmt);
+#ifdef __AVR__
+  vsnprintf_P(buf, sizeof(buf), (const char *)fmt, args); // progmem for AVR
+#else
+  vsnprintf(buf, sizeof(buf), (const char *)fmt, args); // for the rest of the world
+#endif
+  va_end(args);
+  Serial.println(buf);
+}
+
+// #define STOP_BUTTON 1
+// #define DOWN_BUTTON 0
+// #define UP_BUTTON 2
+
+#define DIST_IN_F 20
 int dist_f = 0;
-#define DIST_IN_L 20
+#define DIST_IN_L 19
 int dist_l = 0;
 #define DIST_IN_R 18
 int dist_r = 0;
@@ -31,6 +56,8 @@
 int speed = 0;
 int dir = 0;

+Metro debug_out = Metro(100);
+
 void setup() {
   pinMode(13, OUTPUT);
   digitalWrite(13, HIGH);
@@ -38,11 +65,11 @@
   wheel_left.attach(MOTOR_OUT_L);
   wheel_right.attach(MOTOR_OUT_R);

-  pinMode(STOP_BUTTON, INPUT_PULLUP);
-  pinMode(DOWN_BUTTON, INPUT_PULLUP);
-  pinMode(UP_BUTTON, INPUT_PULLUP);
+  // pinMode(STOP_BUTTON, INPUT_PULLUP);
+  // pinMode(DOWN_BUTTON, INPUT_PULLUP);
+  // pinMode(UP_BUTTON, INPUT_PULLUP);

-  Serial.begin(9600);
+  Serial.begin(115200);
 }

 void loop() {
@@ -65,10 +92,11 @@
     map(dir, 0, 90, 100, 0),
     right_rw_max, right_zero, right_fwd_max);

-  // Serial.print(" left: ");
-  // Serial.print(left_mapped);
-  // Serial.print(" right: ");
-  // Serial.println(right_mapped);
+  if (debug_out.check() == 1)
+  {
+    p(F("L %03d, F %03d, R %03d, left_mapped %03d, right_mapped %03d"),
+      dist_l, dist_f, dist_r, left_mapped, right_mapped);
+  }

   wheel_right.write(right_mapped);
   wheel_left.write(left_mapped);


Correct verion info

Correct verion info

--- Arduino/McLighting/version_info.ino
+++ Arduino/McLighting/version_info.ino
@@ -95,7 +95,6 @@
  * - #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
  */


[Firmware] OTA in test sketch

[Firmware] OTA in test sketch

--- firmware/lm-wifilamp-test/lm-wifilamp-test.ino
+++ firmware/lm-wifilamp-test/lm-wifilamp-test.ino
@@ -1,5 +1,11 @@
+#include <ESP8266WiFi.h>
+#include <ArduinoOTA.h>
+
+#define WIFI_PASS "put password here"
+
+
 // Enable if you are using touch sensor instead of classic button.
-#define TOUCH_BUTTON 0
+#define TOUCH_BUTTON 1

 #define PIXELS_PIN D1
@@ -23,6 +29,40 @@
   espShow(PIXELS_PIN, pixelsBuffer, PIXELS_BYTE_COUNT);
 }

+void wifiConnect() {
+  Serial.println("Connecting");
+  pixelsSet(0, 0, 255);
+
+  if (WiFi.getMode() != WIFI_STA) WiFi.mode(WIFI_STA);
+  if (WiFi.getAutoConnect()) WiFi.setAutoConnect(false);
+  WiFi.setAutoReconnect(true);
+  WiFi.begin("TheCave", WIFI_PASS);
+
+  int counter = 0;
+  while (WiFi.status() != WL_CONNECTED) {
+    Serial.print('.');
+    pixelsSet(0, 0, 32);
+    delay(250);
+    pixelsSet(0, 0, 128);
+    delay(250);
+    counter++;
+    if (counter > 15) {
+      Serial.println("\nConnect timed out");
+      break;
+    }
+  }
+
+  Serial.print("\nConnect status: ");
+  Serial.println(WiFi.status());
+  if (WiFi.status() == WL_CONNECTED) {
+    Serial.print("Connected successfuly\nIP address: ");
+    Serial.println(WiFi.localIP());
+  } else {
+    pixelsSet(255, 0, 0);
+    while (1) yield();
+  }
+}
+
 void setup() {
 #if TOUCH_BUTTON
   pinMode(BUTTON_PIN, INPUT);
@@ -33,13 +73,23 @@
   pinMode(PIXELS_PIN, OUTPUT);
   digitalWrite(PIXELS_PIN, LOW);

+  String chipId = String(ESP.getChipId(), HEX);

   Serial.begin(9600);
   Serial.println("WiFi lamp tester");
   Serial.print("Chip id: ");
-  Serial.println(String(ESP.getChipId(), HEX));
+  Serial.println(chipId);

-  pixelsSet(0, 0, 0);
+  wifiConnect();
+
+  String ssid = "wifilamp-";
+  ssid += chipId;
+  ArduinoOTA.setHostname(ssid.c_str());
+
+  ArduinoOTA.onStart([]() {
+    pixelsSet(32, 32, 32);
+  });
+  ArduinoOTA.begin();
 }

 uint8_t buttonReadRaw() {
@@ -54,7 +104,7 @@
   if (buttonReadRaw()) {
     pixelsSet(0, 255, 0);
   } else {
-    pixelsSet(255, 0, 0);
+    pixelsSet(255, 255, 0);
   }
-  delay(50);
+  ArduinoOTA.handle();
 }


error handling slightly improved

error handling slightly improved

--- PaperTapePuncher.ino
+++ PaperTapePuncher.ino
@@ -138,6 +138,8 @@
       {
         switch(mode)
         {
+          case error:
+            break;
           case hex:
             if(hexBuffer.add(value))
             {