Report only initialized session vars, like join keys

--- MapTheThings-Arduino/MapTheThings-Arduino.ino
+++ MapTheThings-Arduino/MapTheThings-Arduino.ino
@@ -305,9 +305,27 @@
 }

 void reportSessionVars() {
-  setBluetoothCharData(GattDevAddr.charId, settings.DevAddr, sizeof(settings.DevAddr));
-  setBluetoothCharData(GattNwkSKey.charId, settings.NwkSKey, sizeof(settings.NwkSKey));
-  setBluetoothCharData(GattAppSKey.charId, settings.AppSKey, sizeof(settings.AppSKey));
+  if (settings.flags & FLAG_DEV_ADDR_SET) {
+    setBluetoothCharData(GattDevAddr.charId, settings.DevAddr, sizeof(settings.DevAddr));
+  }
+  if (settings.flags & FLAG_NWK_SKEY_SET) {
+    setBluetoothCharData(GattNwkSKey.charId, settings.NwkSKey, sizeof(settings.NwkSKey));
+  }
+  if (settings.flags & FLAG_APP_SKEY_SET) {
+    setBluetoothCharData(GattAppSKey.charId, settings.AppSKey, sizeof(settings.AppSKey));
+  }
+}
+
+void reportJoinVars() {
+  if (settings.flags & FLAG_APP_KEY_SET) {
+    setBluetoothCharData(GattAppKey.charId, settings.AppKey, sizeof(settings.AppKey));
+  }
+  if (settings.flags & FLAG_APP_EUI_SET) {
+    setBluetoothCharData(GattAppEUI.charId, settings.AppEUI, sizeof(settings.AppEUI));
+  }
+  if (settings.flags & FLAG_DEV_EUI_SET) {
+    setBluetoothCharData(GattDevEUI.charId, settings.DevEUI, sizeof(settings.DevEUI));
+  }
 }

 void onJoin(u1_t *appskey, u1_t *nwkskey, u1_t *devaddr) {
@@ -415,15 +433,8 @@
     debugPrint("Join keys set - initializing lora join");
     loraJoin(settings.seq_no, settings.AppKey, settings.AppEUI, settings.DevEUI, onJoin);
   }
-  if (settings.flags & FLAG_APP_KEY_SET) {
-    setBluetoothCharData(GattAppKey.charId, settings.AppKey, sizeof(settings.AppKey));
-  }
-  if (settings.flags & FLAG_APP_EUI_SET) {
-    setBluetoothCharData(GattAppEUI.charId, settings.AppEUI, sizeof(settings.AppEUI));
-  }
-  if (settings.flags & FLAG_DEV_EUI_SET) {
-    setBluetoothCharData(GattDevEUI.charId, settings.DevEUI, sizeof(settings.DevEUI));
-  }
+  reportSessionVars();
+  reportJoinVars();
 }

 void setup() {


Switch 38400 baud for the serial

Switch 38400 baud for the serial

--- Programmer/Programmer.ino
+++ Programmer/Programmer.ino
@@ -46,7 +46,7 @@
 #else
 #define nRF24LE1Serial Serial1
 #endif
-#define NRF24LE1_BAUD  19200
+#define NRF24LE1_BAUD  38400

 #define FLASH_TRIGGER   0x01    // Magic character to trigger uploading of flash
 #define READ_INFOPAGE_TRIGGER 0x02


Added documentation and LED functionality

--- RFIDreader/RFIDreader.ino
+++ RFIDreader/RFIDreader.ino
@@ -1,4 +1,20 @@
 #include <SoftwareSerial.h>
+
+/* RFID Reader
+   Uses RDM880 breakout board with RX connected to pin 2 and TX connected to pin 3.
+   Another serial interface is added by including the Software Serial library.
+
+   Input:
+      RFID tag
+
+   Output:
+      Serial number of tag scanned
+
+   Operation:
+      Reader waits until a tag is scanned, then prints the serial number of the tag
+      and turns on an LED.
+
+*/

 SoftwareSerial RDM880(2, 3);
 char txrxbuffer[255];
@@ -6,8 +22,7 @@
 // command packet - start, address, data length, command, data[0 to 2], end
 // response packet when idle - 0xAA, 0x00, 0x02, 0x01, 0x83, 0x80, 0xBB
 char get_readID[] = { 0xAA , 0x00, 0x03, 0x25, 0x26, 0x00, 0x00, 0xBB };
-byte response;
-
+byte response[11];
 const int ledPin = 13;

 void setup() {
@@ -17,13 +32,24 @@
 }

 void loop() {
+  // send command packet to RDM880
   RDM880.write(get_readID, 8);
-  delay(500);
-
+  delay(100);
+  digitalWrite(ledPin, LOW);
+  response[7] = 0xFF;
+
+  // read response from RDM880 and print
+  int i = 0;
   while(RDM880.available()) {
-    response = RDM880.read();
-    Serial.print(response, HEX);
+    response[i] = RDM880.read();
+    Serial.print(response[i], HEX);
     Serial.print(" ");
+    i++;
+
+    // LED on if an RFID is detected
+    if(response[7] != 0xFF) {
+      digitalWrite(ledPin, HIGH);
+    }
   }
   Serial.println();
 }


Add code to receive Bluetooth commands via RedBearLabs Bluetooth LE shield.

--- Arduino/Thingamabot/Thingamabot.ino
+++ Arduino/Thingamabot/Thingamabot.ino
@@ -21,6 +21,12 @@
 // ef:             Exit fail safe. Once fail-safe mode is entered, you must
 //                 use this command to exit.

+
+#include <SPI.h>
+#include <boards.h>
+#include <RBL_nRF8001.h>
+#include <services.h>
+
 //////////////////////////////////////////////
 // UTILITY routines.

@@ -316,18 +322,67 @@
 ///////////////////////////////////////////////
 // BLUETOOTH

-// Set up Bluetooth LE hardward.
-void setup_bluetooth()
-{
-    // TODO: Setup Bluetooth hardware.
-}
+const int BLUETOOTH_BUFFER_SIZE = 80;
+char bluetooth_buffer[BLUETOOTH_BUFFER_SIZE];
+char * bluetooth_next;  // Next free character in the buffer.
+
+void clear_bluetooth_buffer()
+{
+    bluetooth_next = bluetooth_buffer;
+}
+

 // Check bluetooth for a command. If a command is
 // found, call dispatch_command.
 void read_bluetooth()
 {
-    // TODO: read characters from Bluetooth.
-}
+    while (ble_available() > 0) {
+        int b = ble_read();
+
+        if (b == -1 || b == 0 || b == '\r') {
+            // Ignore nulls, CR.
+        }
+        else if (b == '\n' || b == '!') {
+            // LF or '!' means end of command. Dispatch the command.
+            *bluetooth_next++ ='\0';  // NUL terminate command.
+
+            // Acknowledge command.
+            ble_write_bytes((unsigned char *)"ACK: ", 5);
+            ble_write_bytes((unsigned char *)bluetooth_buffer, strlen(bluetooth_buffer));
+
+            // Dispatch the command.
+            dispatch_command(bluetooth_buffer);
+            clear_bluetooth_buffer();
+        }
+        else if (bluetooth_next < bluetooth_buffer + BLUETOOTH_BUFFER_SIZE - 1) {
+            // Store character into buffer.
+            *bluetooth_next++ = (char) b;
+        }
+    }
+}
+
+// Set up Bluetooth LE hardware.
+void setup_bluetooth()
+{
+    clear_bluetooth_buffer();
+
+    // Default pins set to 9 and 8 for REQN and RDYN
+    // Set your REQN and RDYN here before ble_begin() if you need
+    ble_set_pins(7, 8);
+
+    // Set your BLE Shield name here, max. length 10
+    ble_set_name("Thingmabot");
+
+    // Init. and start BLE library.
+    ble_begin();
+}
+
+// This must be called from main loop to process bluetooth commands.
+void process_bluetooth()
+{
+    ble_do_events();
+}
+

 ///////////////////////////////////////////////
@@ -402,6 +457,7 @@
     // Check for inputs. These functions will call dispatch_command
     // if an input command is read.
     read_serial();
+    process_bluetooth();
     read_bluetooth();

     // Check if we need to enter fail-safe mode.


missed led and fixed output to make more sense

--- libraries/ESP8266WebServer/examples/HelloServer/HelloServer.ino
+++ libraries/ESP8266WebServer/examples/HelloServer/HelloServer.ino
@@ -14,15 +14,16 @@
 void handleRoot() {
   digitalWrite(led, 1);
   server.send(200, "text/plain", "hello from esp8266!");
+  digitalWrite(led, 0);
 }

 void handleNotFound(){
   digitalWrite(led, 1);
-  String message = "URI: ";
+  String message += "File Not Found\n\n";
+  message += "URI: ";
   message += server.uri();
   message += "\nMethod: ";
   message += (server.method() == HTTP_GET)?"GET":"POST";
-  message += "\nNot Found!\n\n";
   message += "\nArguments: ";
   message += server.args();
   message += "\n";


Toupie mode

Toupie mode

--- pug.ino
+++ pug.ino
@@ -27,6 +27,9 @@
 // Ultrason
 #define MIN_DISTANCE_IN_CM 20
 #define ULTRASOUND true // Disable ultrason if false
+
+// Goodies mode
+#define TOUPIE true

 IntervalTimer ultraTimer;
 IntervalTimer motorTimer;
@@ -185,6 +188,14 @@
 boolean hasCalibrate = false;
 void loop() {
   if (DEBUG) return;
+  if (TOUPIE) {
+    while (!digitalRead(JUMPER_PIN));
+    while (digitalRead(JUMPER_PIN));
+    setLeftSpeed( 100 );
+    setRightSpeed( -100 );
+    delay(5000);
+    stopMotors();
+  }

   if (!hasCalibrate) {
     // Turn for calibrate with potard rotation before the match
@@ -210,16 +221,16 @@
   //  goBackward(20);
   //  delay(3000);
   //  stopMotors();
-
+
   // Tempo before start.
-  delay(START_TIMER);
+  //delay(START_TIMER);

   // Forward
-  goForward(30, 900);
+  goForward(30, 950); // 900 before morning calibration ;)

   // Break!
   goBackward(1);
-  delay(500);
+  delay(100);
   stopMotors();
   delay(1000);


Poll sonar sensors individually

Poll sonar sensors individually

--- arduino/personal_space/personal_space.ino
+++ arduino/personal_space/personal_space.ino
@@ -229,8 +229,10 @@
   //The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial
   lib_aci_init(&aci_state, false);

-  //  Send data every second
+  // Send data every second
   t.every(1000, send_data);
+  // Collect one sonar sensor every 1/4 sec
+  t.every(200, get_data);

   Serial.println(F("Set up done"));
 }
@@ -417,11 +419,6 @@
           lib_aci_change_timing_GAP_PPCP(); // change the timing on the link as specified in the nRFgo studio -> nRF8001 conf. -> GAP.
                                             // Used to increase or decrease bandwidth
           timing_change_done = true;
-
-          char hello[]="Hello World, works";
-          uart_tx((uint8_t *)&hello[0], strlen(hello));
-          Serial.print(F("Sending :"));
-          Serial.println(hello);
         }
         break;

@@ -532,31 +529,32 @@
   }
 }

-void get_data(uint16_t *data){
-  Serial.println(F("data:"));
-  for(int i = 0; i < SONAR_NUM; i++) {
-    data[i] = sonar[i].ping_cm();
-    if(!data[i]) {
-      data[i] = MAX_DISTANCE;
-    }
-    Serial.print(F(" Sonar"));
-    Serial.print(i);
-    Serial.print(F(": "));
-    Serial.println(data[i]);
-  }
+void get_data(){
+  cm[currentSensor] = sonar[currentSensor].ping_cm();
+  if(!cm[currentSensor]) {
+    cm[currentSensor] = MAX_DISTANCE;
+  }
+
+  Serial.print(F(" Sonar"));
+  Serial.print(currentSensor);
+  Serial.print(F(": "));
+  Serial.println(cm[currentSensor]);
+  currentSensor++;
+  currentSensor%=SONAR_NUM;
 }

 void send_data(){
-  uint16_t data16[SONAR_NUM];
   uint8_t data8[2*SONAR_NUM];
-
-  get_data(data16);
-
-  for(int i = 0; i < sizeof(data16); i++){
-    data8[i*2] = data16[i] & 0xFF;
-    data8[i*2 + 1] = (data16[i] & 0xFF00) >> 8;
-  }
-
+  Serial.println(F("Data: "));
+  for(int i = 0; i < SONAR_NUM; i++){
+    Serial.print(F(" ( "));
+    data8[i*2] = cm[i] & 0xFF;
+    Serial.print(data8[i*2]);
+    Serial.print(F(", "));
+    data8[i*2 + 1] = (cm[i] & 0xFF00) >> 8;
+    Serial.print(data8[i*2 + 1]);
+    Serial.println(F(" )"));
+  }
   uart_tx(data8, sizeof(data8));
 }


Update edison2fiware.ino

Update edison2fiware.ino

--- arduino/edison2fiware.ino
+++ arduino/edison2fiware.ino
@@ -5,8 +5,8 @@

   //################# WIFI DETAILS #################
-  char ssid[] = "OWDTEST";     // your network SSID (name)
-  char pass[] = "tidowd22";    // your network password (use for WPA, or use as key for WEP)
+  char ssid[] = "";     // your network SSID (name)
+  char pass[] = "";    // your network password (use for WPA, or use as key for WEP)
   int keyIndex = 0;            // your network key Index number (needed only for WEP)
   int status = WL_IDLE_STATUS;
   WiFiClient client;


Ensure that broadcast arrive

Ensure that broadcast arrive

Stay awake for at least one second to give pending broadcasts a chance
to arrive before re-entering sleep

--- homie-dht.ino
+++ homie-dht.ino
@@ -11,6 +11,8 @@
 static void setupHandler() {
   Homie.getLogger() << "homie-dht - " << __DATE__ << " - " << __TIME__ << endl;
   sensor.setup();
+  awakeTillMillis = millis() + 1000UL; // stay awake for at least one second to give pending broadcasts a
+                                       // chance to arrive before re-entering sleep
 }

 bool broadcastHandler(const String& level, const String& value) {


Disable WebSocket clients upon OTA start.

--- src/_ota.ino
+++ src/_ota.ino
@@ -27,6 +27,9 @@
   ArduinoOTA.onStart([]() {
     DEBUGLOG("[OTA ] Start\n");
     events.send("start", "ota");
+
+    ws.enable(false); // Disable WebSocket client connections
+    ws.closeAll(); // Close WebSocket client connections
   });

   ArduinoOTA.onEnd([]() {


Second Push

Second Push

Added partial Code for the GPS need to finish GPS

--- Test-Station-Firmware.ino
+++ Test-Station-Firmware.ino
@@ -63,6 +63,9 @@
 #include <Progmem.h> // Allows us to sacrifice flash for DRAM
 #include <Wire.h>
 #include <Adafruit_MPL3115A2.h>
+#include <Adafruit_GPS.h>
+#include <SoftwareSerial.h>
+

 /////////////
 //Altimeter//
@@ -72,6 +75,48 @@
 // See the Wire tutorial for pinouts for each Arduino
 // http://arduino.cc/en/reference/wire
 Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
+
+// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
+//
+// This code just echos whatever is coming from the GPS unit to the
+// serial monitor, handy for debugging!
+//
+// Tested and works great with the Adafruit Ultimate GPS module
+// using MTK33x9 chipset
+//    ------> http://www.adafruit.com/products/746
+// Pick one up today at the Adafruit electronics shop
+// and help support open source hardware & software! -ada
+
+
+
+// Connect the GPS Power pin to 5V
+// Connect the GPS Ground pin to ground
+// If using software serial (sketch example default):
+//   Connect the GPS TX (transmit) pin to Digital 3
+//   Connect the GPS RX (receive) pin to Digital 2
+// If using hardware serial (e.g. Arduino Mega):
+//   Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
+//   Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
+
+// If using software serial, keep these lines enabled
+// (you can change the pin numbers to match your wiring):
+
+SoftwareSerial mySerial(3, 2);
+Adafruit_GPS GPS(&mySerial);
+// If using hardware serial (e.g. Arduino Mega), comment
+// out the above six lines and enable this line instead:
+//Adafruit_GPS GPS(&Serial1);
+
+// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
+// Set to 'true' if you want to debug and listen to the raw GPS sentences
+#define GPSECHO  true
+#define GPSSerial true
+
+// this keeps track of whether we're using the interrupt
+// off by default!
+boolean usingInterrupt = false;
+void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
+

 ///////////////////////
 // Ethernet Settings //
@@ -111,11 +156,39 @@
   Serial.begin(115200);
   Serial.println("Adafruit_MPL3115A2 test!");
   fieldData[10] = name;
+  setup_GPS();

   // Set Up Ethernet:
   setupEthernet();

 }
+// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
+SIGNAL(TIMER0_COMPA_vect) {
+  char c = GPS.read();
+  // if you want to debug, this is a good time to do it!
+#ifdef UDR0
+  if (GPSECHO)
+    if (c) UDR0 = c;
+    // writing direct to UDR0 is much much faster than Serial.print
+    // but only one character can be written at a time.
+#endif
+}
+
+void useInterrupt(boolean v) {
+  if (v) {
+    // Timer0 is already used for millis() - we'll just interrupt somewhere
+    // in the middle and call the "Compare A" function above
+    OCR0A = 0xAF;
+    TIMSK0 |= _BV(OCIE0A);
+    usingInterrupt = true;
+  } else {
+    // do not call the interrupt function COMPA anymore
+    TIMSK0 &= ~_BV(OCIE0A);
+    usingInterrupt = false;
+  }
+}
+
+uint32_t timer = millis();

 void loop()
 {
@@ -128,6 +201,9 @@
   }
   altimeter_get_debug();
   altimeter_post_to_table();
+  delay(100);
+  GPSloop();
+  delay(250);
   ///////////////
   //Phant Stuff//
   ///////////////
@@ -138,6 +214,7 @@
   delay(20000);

 }
+
 void altimeter_post_to_table()
 {
   float pascals = baro.getPressure();
@@ -217,5 +294,102 @@
   // give the Ethernet shield a second to initialize:
   delay(1000);
 }
-
-
+void setup_GPS()
+{
+  Serial.println("Adafruit GPS library basic test!");
+
+  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
+  GPS.begin(9600);
+
+  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
+  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
+  // uncomment this line to turn on only the "minimum recommended" data
+  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
+  // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
+  // the parser doesn't care about other sentences at this time
+
+  // Set the update rate
+  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
+  // For the parsing code to work nicely and have time to sort thru the data, and
+  // print it out we don't suggest using anything higher than 1 Hz
+
+  // Request updates on antenna status, comment out to keep quiet
+  GPS.sendCommand(PGCMD_ANTENNA);
+
+  // the nice thing about this code is you can have a timer0 interrupt go off
+  // every 1 millisecond, and read data from the GPS for you. that makes the
+  // loop code a heck of a lot easier!
+  useInterrupt(true);
+
+  delay(1000);
+  // Ask for firmware version
+  mySerial.println(PMTK_Q_RELEASE);
+}
+void GPSloop()
+{
+  // in case you are not using the interrupt above, you'll
+  // need to 'hand query' the GPS, not suggested :(
+  if (! usingInterrupt) {
+    // read data from the GPS in the 'main loop'
+    char c = GPS.read();
+    // if you want to debug, this is a good time to do it!
+    if (GPSECHO)
+      if (c) Serial.print(c);
+  }
+
+  // if a sentence is received, we can check the checksum, parse it...
+  if (GPS.newNMEAreceived()) {
+    // a tricky thing here is if we print the NMEA sentence, or data
+    // we end up not listening and catching other sentences!
+    // so be very wary if using OUTPUT_ALLDATA and trytng to print out data
+    //Serial.println(GPS.lastNMEA());   // this also sets the newNMEAreceived() flag to false
+
+    if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
+      return;  // we can fail to parse a sentence in which case we should just wait for another
+  }
+
+  // if millis() or timer wraps around, we'll just reset it
+  if (timer > millis())  timer = millis();
+
+  // approximately every 2 seconds or so, print out the current stats
+  if (millis() - timer > 2000 && GPSSerial) {
+    timer = millis(); // reset the timer
+
+    Serial.print("\nTime: ");
+    Serial.print(GPS.hour, DEC); Serial.print(':');
+    Serial.print(GPS.minute, DEC); Serial.print(':');
+    Serial.print(GPS.seconds, DEC); Serial.print('.');
+    Serial.println(GPS.milliseconds);
+    Serial.print("Date: ");
+    Serial.print(GPS.day, DEC); Serial.print('/');
+    Serial.print(GPS.month, DEC); Serial.print("/20");
+    Serial.println(GPS.year, DEC);
+    Serial.print("Fix: "); Serial.print((int)GPS.fix);
+    Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
+    if (GPS.fix) {
+      Serial.print("Location: ");
+      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
+      Serial.print(", ");
+      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
+      Serial.print("Location (in degrees, works with Google Maps): ");
+      Serial.print(GPS.latitudeDegrees, 4);
+      Serial.print(", ");
+      Serial.println(GPS.longitudeDegrees, 4);
+
+      Serial.print("Speed (knots): "); Serial.println(GPS.speed);
+      Serial.print("Angle: "); Serial.println(GPS.angle);
+      Serial.print("Altitude: "); Serial.println(GPS.altitude);
+      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
+    }
+  }
+}
+String GPSDatestamp()
+{
+  char datestamp[25] = "0000000000000000000000000";
+  datestamp = GPS.year+"-"+GPS.month+"-"+GPS.day
+}
+void GPSPost()
+{
+
+}
+


fixing

fixing

--- coni/arduino/main/master/multi_master.ino
+++ coni/arduino/main/master/multi_master.ino
@@ -210,6 +210,7 @@
             Serial.println(dataOut[completo]);
             Serial2.print(dataOut[completo]);
           }
+          break;

         default:
           Serial.println("comando inesistente");


Update AM2320lib_test.ino

Update AM2320lib_test.ino

--- AM2320/example/AM2320lib_test.ino
+++ AM2320/example/AM2320lib_test.ino
@@ -1,19 +1,27 @@
 #include <Wire.h>
 #include <AM2320.h>
 AM2320 th;
+
 void setup() {
   Serial.begin(9600);
 }

 void loop() {
-
-  Serial.println("---------------");
-  Serial.print("humidity: ");
-  Serial.print(th.getHumidity());
-  Serial.print("%");
-  Serial.print("|| temperature: ");
-  Serial.print(th.getTemperature());
-  Serial.println("*C");
-  Serial.println("---------------");
-  delay(2000);
+  switch(th.Read()) {
+    case 2:
+      Serial.println("CRC failed");
+      break;
+    case 1:
+      Serial.println("Sensor offline");
+      break;
+    case 0:
+      Serial.print("humidity: ");
+      Serial.print(th.h);
+      Serial.print("%, temperature: ");
+      Serial.print(th.t);
+      Serial.println("*C");
+      break;
+  }
+
+  delay(200);
 }


Advanced algorithm.

Advanced algorithm.

--- mech/mech.ino
+++ mech/mech.ino
@@ -211,13 +211,26 @@

 void fineTune() {
   if (((fwdPwrVal >> 4) == 0) || (isAutoTune)) {
-    return;
-  }
-  isAutoTune = 1;
-  optimize(&stepperC1, 10, 0);
-  optimize(&stepperC2, 10, 0);
-  optimize(&stepperC1, 10, 0);
-  isAutoTune = 0;
+      dprintf("fineTune() - rejected\n");
+      return;
+    }
+    uint32_t startedTime = micros();
+    dprintf("fineTune() - started\n");
+    isAutoTune = 1;
+    stepperL.moveTo(3000);
+    stepperC1.moveTo(800);
+    stepperC2.moveTo(100);
+    optimize(&stepperC1, 20, 0);
+    dprintf("fineTune() - stepperC1 finished in %8d ms\n", (uint32_t) micros() - startedTime);
+    optimize(&stepperC2, 20, 0);
+    dprintf("fineTune() - stepperC2 finished in %8d ms\n", (uint32_t) micros() - startedTime);
+    optimize(&stepperL, 2000, 0);
+    dprintf("fineTune() - stepperL finished in %8d ms\n", (uint32_t) micros() - startedTime);
+    optimize(&stepperC1, 10, 0);
+    dprintf("fineTune() - stepperC1 finished in %8d ms\n", (uint32_t) micros() - startedTime);
+    optimize(&stepperC2, 10, 0);
+    dprintf("fineTune() - stepperC2 finished in %8d ms\n", (uint32_t) micros() - startedTime);
+    isAutoTune = 0;
 }

 void updateStatus() {


fixed logic error

fixed logic error

--- grill.ino
+++ grill.ino
@@ -38,8 +38,10 @@
     if (pid.GetMode() != AUTOMATIC) {
       pid.SetMode(AUTOMATIC);
     }
-    if ((output == 0 || output == 255) && pid.GetKi() != 0) {
-      pid.SetTunings(P, 0, D);
+    if (output == 0 || output == 255) {
+      if (pid.GetKi() != 0) {
+        pid.SetTunings(P, 0, D);
+      }
     } else if (pid.GetKi() != I) {
       pid.SetTunings(P, I, D);
     }


Reduce mission timeout to 5 seconds

Reduce mission timeout to 5 seconds

--- mk_0/mk_0.ino
+++ mk_0/mk_0.ino
@@ -3,7 +3,7 @@
 #include "doom.h"

 #define MAINLOOP_PERIOD_TICKS   6249
-#define MISSION_TIMEOUT         3200
+#define MISSION_TIMEOUT         200

 statevars_t statevars;
 uint32_t iterations;
@@ -57,7 +57,7 @@
   }

   // Draw the PWM signals one by one before continuing the loop
-  mobility_send_steering_pwm(1200);
+  mobility_send_steering_pwm(statevars.control_steering_pwm);
   mobility_send_throttle_pwm(SPEED_FWD_CREEP);

   // Record the data from the previous iteration
@@ -76,9 +76,9 @@
   iterations++;

   // If the button switched to the OFF position, then stop the mission
-  if (!button_is_pressed()) {
+  //if (!button_is_pressed()) {
   // Instead, stop the robot after a certain number of seconds
-  //if (iterations > MISSION_TIMEOUT) {
+  if (iterations > MISSION_TIMEOUT) {
     Serial.println("Finished collecting data!");
     sdcard_finish();


Connect to smart-connected.us

Connect to smart-connected.us

--- microcoap.ino
+++ microcoap.ino
@@ -18,7 +18,8 @@

 static uint8_t mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};

-IPAddress ip(185, 38, 249, 75); // com1.telemetria-online.pl
+// IPAddress ip(185, 38, 249, 75); // com1.telemetria-online.pl
+IPAddress ip(178, 62, 114, 226); // com1.smart-connected.us

 EthernetClient client;
 EthernetUDP udp;
@@ -238,10 +239,10 @@
       coap_handle_req(endpoints, &scratch_buf, &pkt, &rsppkt);

       if (0 != (rc = coap_build(packetbuf, &rsplen, &rsppkt))) {
-	Serial.print(F("coap_build failed rc="));
-	Serial.println(rc, DEC);
+        Serial.print(F("coap_build failed rc="));
+        Serial.println(rc, DEC);
       } else {
-	udp_send(udp.remoteIP(), udp.remotePort(), packetbuf, rsplen);
+        udp_send(udp.remoteIP(), udp.remotePort(), packetbuf, rsplen);
       }
     }
   }


smaller change

smaller change

--- a_star_dual_25D_motor/a_star_dual_25D_motor.ino
+++ a_star_dual_25D_motor/a_star_dual_25D_motor.ino
@@ -38,7 +38,7 @@

 void loop() {
   // Gain Scheduling Test
-  // update gains relative to the velocity
+  // update gains relative to velocity
   float vel_raw = motor1->calculateVelocity();
   vel = vel*alpha + (1-alpha)*vel_raw;
   float p = (50-vel*40/1000.);


Updated to my local altitude

Updated to my local altitude

--- oak/oak_weather.ino
+++ oak/oak_weather.ino
@@ -13,7 +13,7 @@
 HTU21D htu;
 SFE_BMP180 bmp;

-#define ALTITUDE 509 //Altitude in meter
+#define ALTITUDE 210 //Altitude in meter
 #define PCF8591 (0x90 >> 1) //I2C bus address
 #define ADC0 0x00 //ADC0


added TURN_HEAD command

added TURN_HEAD command

--- biber/biber.ino
+++ biber/biber.ino
@@ -1,6 +1,8 @@
 #include <Servo.h>
 #include <NewPing.h>

+#define BAUD_RATE 115200
+#define SERVO_HEAD 10
 #define TRIGGER_PIN  A1  // Arduino pin tied to trigger pin on the ultrasonic sensor.
 #define ECHO_PIN     A0  // Arduino pin tied to echo pin on the ultrasonic sensor.
 #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
@@ -22,8 +24,9 @@
 byte index = 0; // Index into array; where to store the character

 enum COMMAND {
-  NONE = -1,
-  SONAR,        // value = servo microseconds
+  NONE = -1,
+  TURN_HEAD = 0, // value = servo microseconds
+  SONAR = 1,
   COMMAND_MAX
 } currentCommand;

@@ -35,8 +38,8 @@
 void setup() {

   // turn on servo
-  servo.attach(10);
-  Serial.begin(115200);
+  servo.attach(SERVO_HEAD);
+  Serial.begin(BAUD_RATE);
   lastServoTime = millis();
   lastSonarTime = millis();
   sayYes();
@@ -61,25 +64,36 @@

   switch(command) {
     case SONAR: {
-       sonarPing(value);
-	   break;
+      sonarPing();
+      break;
+    }
+
+    case TURN_HEAD: {
+      turnHead(value);
+      break;
     }

-	default: {
-
-	}
+    default: {
+
+    }
   }

   return readSomething;
 }

-void sonarPing(int microseconds) {
+void sonarPing() {
+  unsigned int dist = getDistance();
+  Serial.print(dist);
+  Serial.print("\n");
+  printOK();
+}
+
+void turnHead(int microseconds) {
   microseconds = constrain(microseconds, SERVO_MIN_MS, SERVO_MAX_MS);
   servo.writeMicroseconds(microseconds);
   waitForServo();
   lastServoTime = millis();
-  printDistance();
-  lastServoTime = millis();
+  printOK();
 }

 void waitForServo() {
@@ -87,15 +101,18 @@
   unsigned long diff = now - lastServoTime;
   if( diff < SERVO_WAIT_TIME_MILLIS ) {
     unsigned long delayTime = SERVO_WAIT_TIME_MILLIS - diff;
-    Serial.write("delaying servo movement for ms: ");
-    Serial.print(delayTime, DEC);
     delay(delayTime);
   }
 }

-void printDistance() {
+void printOK() {
+  Serial.println("ok");
+}
+
+unsigned int getDistance() {
   unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
-  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range)
+  unsigned int distance = uS / US_ROUNDTRIP_CM; // Convert ping time to distance in cm and print result (0 = outside set distance range)
+  return distance;
 }

@@ -110,6 +127,8 @@
    delay(ANSWER_SERVO_DELAY);
    servo.writeMicroseconds((SERVO_MAX_MS - SERVO_MIN_MS)/2 + SERVO_MIN_MS);
    delay(ANSWER_SERVO_DELAY);
+
+  lastServoTime = millis();
 }

 void sayYes() {
@@ -123,4 +142,6 @@
    delay(ANSWER_SERVO_DELAY);
    servo.writeMicroseconds((SERVO_MAX_MS - SERVO_MIN_MS)/2 + SERVO_MIN_MS);
    delay(ANSWER_SERVO_DELAY);
+
+  lastServoTime = millis();
 }


Update mech.ino

Update mech.ino

--- mech/mech.ino
+++ mech/mech.ino
@@ -187,17 +187,17 @@
     dprintf("autoTune() - rejected\n");
     return;
   }
-  unsigned long startedTime = micros();
+  uint16_t startedTime = micros();
   dprintf("autoTune() - started\n");
   isAutoTune = 1;
   stepperC1.moveTo(10);
   stepperC2.moveTo(10);
   optimize(&stepperL, 2000, 0);
-  dprintf("autoTune() - stepperL finished in %8d uSec\n", micros() - startedTime);
+  dprintf("autoTune() - stepperL finished in %8d ms\n", (uint16_t) micros() - startedTime);
   optimize(&stepperC1, 20, 0);
-  dprintf("autoTune() - stepperC1 finished in %8d uSec\n", micros() - startedTime);
+  dprintf("autoTune() - stepperC1 finished in %8d ms\n", (uint16_t) micros() - startedTime);
   optimize(&stepperC2, 20, 0);
-  dprintf("autoTune() - stepperC2 finished in %8d uSec\n", micros() - startedTime);
+  dprintf("autoTune() - stepperC2 finished in %8d ms\n", (uint16_t) micros() - startedTime);
   isAutoTune = 0;
 }


V2.7

V2.7

Change /setup page to select the sensors you want to use if any.
Added a backup of last good data to be used when sensors failed.
Optimized /temp page to better use new settings.
Optimized lesliens() function to better use new settings.
code cleanup.

Still need to find a way to test server status because of after wifimanager config it seems to not start properly needs a reboot somehow.

--- esp32LightServerRGB.ino
+++ esp32LightServerRGB.ino
@@ -58,7 +58,11 @@
 int flashoufade = 0;
 int tstrouteur = 0;
 String logs[51];
-int usesenseur = 0;
+float dernh = 0;
+float dernt = 0;
+String dernd = "0";
+int usesenseurdallas = 0;
+int usesenseurdht = 0;
 // end of internally used vars

 // stylesheet for web pages
@@ -108,17 +112,26 @@

 // functions used internally

-//used to set the links at the bottom of the pages (ran at setup and on /setup changes)
+//used to set the links at the bottom of the pages (ran at setup() and on /setup changes)
 void lesliens() {
+  int usesenseur = 0;
+  if (usesenseurdallas == 1) {
+    usesenseur = 1;
+  }
+  if (usesenseurdht == 1) {
+    usesenseur = 1;
+  }
   liens = "Acceuil";
   if (usesenseur == 1) {
     liens += " - Température";
   }
   liens += " - Version - Setup";
   if (usesenseur == 1) {
-    liens += " - Temp stats\n";
+    if (thingchanel != "none") {
+      liens += " - Temp stats\n";
+    }
   }
 }

@@ -502,7 +515,7 @@
   Serial.println(addy);
   Serial.println("!!! PAGE DE RESET !!!");
   String testteu = server.arg("RESET");
-  String passme = server.arg("PASSME");
+  String passme = server.arg("PASSMOI");
   logtourne();
   logs[1] = addy;
   logs[1] += " : Reset : Password=";
@@ -529,14 +542,14 @@
     contenu += "<form action=\"/reset\" method=\"post\">\n"
                "
Tu veux VRAIEMENT resetter TOUT les réglages (incluent les paramètres wifi)
"
                "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
+               "<input type=\"password\" name=\"PASSMOI\" value=\"\">
\n"
                "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
                "</form>\n";
   } else if (ouireset != 1) {
     contenu += "<form action=\"/reset\" method=\"post\">\n"
                "
Tu veux VRAIEMENT resetter TOUT les réglages (incluent les paramètres wifi)
"
                "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
+               "<input type=\"password\" name=\"PASSMOI\" value=\"\">
\n"
                "
!!! MAUVAIS PASSWORD !!!

\n"
                "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
                "</form>\n";
@@ -567,19 +580,6 @@
   Serial.println("");
   Serial.println(addy);
   Serial.println("!!! PAGE DE SETUP !!!");
-  int ouireset = 0;
-  String testteu = server.arg("RESET");
-  //  String passme = server.arg("PASSME");
-  String noupass = server.arg("LAPASSE");
-  String lakey = server.arg("APIKEY");
-  String lechan = server.arg("CHANEL");
-  String theuse = server.arg("LEUSE");
-  int leuse = 0;
-  if (theuse == "usemoi") {
-    leuse = 1;
-  } else {
-    leuse = 0;
-  }
   logtourne();
   logs[1] = addy;
   logs[1] += " : Settings !";
@@ -589,6 +589,21 @@
     logs[1] += " Not logged in !";
     return server.requestAuthentication();
   }
+  int ouireset = 0;
+  String testteu = server.arg("RESET");
+  String noupass = server.arg("LAPASSE");
+  String lakey = server.arg("APIKEY");
+  String lechan = server.arg("CHANEL");
+  String thedallas = server.arg("LEDALLAS");
+  String thedht = server.arg("LEDHT");
+  int leusedallas = 0;
+  int leusedht = 0;
+  if (thedallas == "usedallas") {
+    leusedallas = 1;
+  }
+  if (thedht == "usedht") {
+    leusedht = 1;
+  }
   if (testteu == "OUI") {
     ouireset = 1;
     if (noupass == "") {
@@ -599,6 +614,42 @@
     }
     if (lechan == "") {
       ouireset = 3;
+    }
+  }
+  if (ouireset == 1) {
+    Serial.println("Réglages changé");
+    if (noupass != resetpass) {
+      preferences.putString("resetpass", noupass);
+      resetpass = noupass;
+      Serial.print("NOUVEAU Password : ");
+      Serial.println(resetpass);
+    }
+    if (lakey != thingkey) {
+      preferences.putString("thingkey", lakey);
+      thingkey = lakey;
+      Serial.print("NOUVEL API KEY : ");
+      Serial.println(thingkey);
+    }
+    if (leusedallas != usesenseurdallas) {
+      preferences.putUInt("usesenseurdal", leusedallas);
+      usesenseurdallas = leusedallas;
+      lesliens();
+      Serial.print("NOUVEAU use dallas : ");
+      Serial.println(usesenseurdallas);
+    }
+    if (leusedht != usesenseurdht) {
+      preferences.putUInt("usesenseurdht", leusedht);
+      usesenseurdht = leusedht;
+      lesliens();
+      Serial.print("NOUVEAU use dht : ");
+      Serial.println(usesenseurdht);
+    }
+    if (lechan != thingchanel) {
+      preferences.putString("thingchanel", lechan);
+      thingchanel = lechan;
+      lesliens();
+      Serial.print("NOUVEAU channel : ");
+      Serial.println(thingchanel);
     }
   }
   String contenu = "<!DOCTYPE html>\n\n\n";
@@ -614,11 +665,16 @@
                "Password :
\n<input type=\"password\" name=\"LAPASSE\" value=\"";
     contenu += resetpass;
     contenu += "\">
\n"
-               "
\n<input type=\"checkbox\" name=\"LEUSE\" value=\"usemoi\" ";
-    if (usesenseur == 1) {
+               "
\n<input type=\"checkbox\" name=\"LEDALLAS\" value=\"usedallas\" ";
+    if (usesenseurdallas == 1) {
       contenu += "checked";
     }
-    contenu += ">Utilise des senseurs
\n"
+    contenu += ">Utilise un senseur Dallas (field1 sur Thingspeak)"
+               "
\n<input type=\"checkbox\" name=\"LEDHT\" value=\"usedht\" ";
+    if (usesenseurdht == 1) {
+      contenu += "checked";
+    }
+    contenu += ">Utilise un senseur DHT22 (field2 et 3 sur Thingspeak)
\n"
                "ThingSpeak API Key :
\n<input type=\"text\" name=\"APIKEY\" value=\"";
     contenu += thingkey;
     contenu += "\">
\n"
@@ -637,11 +693,16 @@
     "Password :
\n<input type=\"password\" name=\"LAPASSE\" value=\"";
     contenu += resetpass;
     contenu += "\">
\n"
-               "
\n<input type=\"checkbox\" name=\"LEUSE\" value=\"usemoi\" ";
-    if (usesenseur == 1) {
+               "
\n<input type=\"checkbox\" name=\"LEDALLAS\" value=\"usedallas\" ";
+    if (usesenseurdallas == 1) {
       contenu += "checked";
     }
-    contenu += ">Utilise des senseurs
\n"
+    contenu += ">Utilise un senseur Dallas (field1 sur Thingspeak)"
+               "
\n<input type=\"checkbox\" name=\"LEDHT\" value=\"usedht\" ";
+    if (usesenseurdht == 1) {
+      contenu += "checked";
+    }
+    contenu += ">Utilise un senseur DHT22 (field2 et 3 sur Thingspeak)
\n"
                "ThingSpeak API Key :
\n<input type=\"text\" name=\"APIKEY\" value=\"";
     contenu += thingkey;
     contenu += "\">
\n"
@@ -666,35 +727,6 @@
   contenu += liens;
   contenu += "\n

\n";
   server.send(200, "text/html", contenu);
-  if (ouireset == 1) {
-    Serial.println("Réglages changé");
-    if (noupass != resetpass) {
-      preferences.putString("resetpass", noupass);
-      resetpass = noupass;
-      Serial.print("NOUVEAU Password : ");
-      Serial.println(resetpass);
-    }
-    if (lakey != thingkey) {
-      preferences.putString("thingkey", lakey);
-      thingkey = lakey;
-      Serial.print("NOUVEL API KEY : ");
-      Serial.println(thingkey);
-    }
-    if (leuse != usesenseur) {
-      preferences.putUInt("usesenseur", leuse);
-      usesenseur = leuse;
-      lesliens();
-      Serial.print("NOUVEAU use les senseurs : ");
-      Serial.println(usesenseur);
-    }
-    if (lechan != thingchanel) {
-      preferences.putString("thingchanel", lechan);
-      thingchanel = lechan;
-      lesliens();
-      Serial.print("NOUVEAU channel : ");
-      Serial.println(thingchanel);
-    }
-  }
 }

 // convert string 2 char*
@@ -761,74 +793,145 @@
 // function executed in main loop every minute to update sensors data to thingspeak.com
 void latemp() {
   if (thingkey != "none") {
-    sensors.requestTemperatures();
-    float thetemp = sensors.getTempCByIndex(0);
-    char buffer[10];
-    String tempC = dtostrf(thetemp, 5, 2, buffer);
-    delay(400);
-    float t = 0;
-    float h = 0;
-    int err = SimpleDHTErrSuccess;
-    if ((err = dht22.read2(pinDHT22, &t, &h, NULL)) != SimpleDHTErrSuccess) {
-      Serial.print("Read DHT22 failed, err=");
-      Serial.println(err);
-      h = 0;
-    }
-    if (tempC != "-127.00") {
-      if (tempC != "85.00") {
-        Serial.print("Envoi de température et humidité: ");
-        Serial.print(tempC);
-        Serial.print(" - ");
-        HTTPClient http;
-        String webadd = "http://api.thingspeak.com/update?key=";
-        webadd += thingkey;
-        webadd += "&field1=";
-        webadd += tempC;
-        if (h != 0) {
+    HTTPClient http;
+    String webadd = "http://api.thingspeak.com/update?key=";
+    webadd += thingkey;
+    Serial.println("");
+    Serial.print("Envoi de température et humidité: ");
+    int enweille = 0;
+    if (usesenseurdallas == 1) {
+      //dallas
+      sensors.requestTemperatures();
+      float thetemp = sensors.getTempCByIndex(0);
+      char buffer[10];
+      String tempC = dtostrf(thetemp, 5, 2, buffer);
+      delay(400);
+      if (tempC != "-127.00") {
+        if (tempC != "85.00") {
+          Serial.print(tempC);
+          if (usesenseurdht == 1) {
+            Serial.print(" - ");
+          }
+          webadd += "&field1=";
+          webadd += tempC;
+          enweille = 1;
+          dernd = tempC;
+        }
+      } else {
+        Serial.println("Dallas error !");
+        if (dernd != "0") {
+          tempC = dernd;
+          webadd += "&field1=";
+          webadd += tempC;
+          enweille = 1;
+        } else {
+          enweille = 0;
+        }
+      }
+    }
+    if (usesenseurdht == 1) {
+      //dht
+      float t = 0;
+      float h = 0;
+      int err = SimpleDHTErrSuccess;
+      if ((err = dht22.read2(pinDHT22, &t, &h, NULL)) != SimpleDHTErrSuccess) {
+        Serial.println("");
+        Serial.print("Read DHT22 failed, err=");
+        Serial.println(err);
+        if (dernh != 0) {
+          h = dernh;
+          t = dernt;
           webadd += "&field2=";
           webadd += h;
           Serial.print(h);
           webadd += "&field3=";
           webadd += t;
+          Serial.print(" - ");
+          Serial.print(t);
+          enweille = 1;
+          dernt = t;
+          dernh = h;
         }
-        Serial.println("");
-        http.begin(webadd);
-        int httpCode = http.GET();//Send the request
-        if (httpCode > 0) {
-          Serial.println("Envoit réussit !");
-          tstrouteur = 0;
+      } else {
+        webadd += "&field2=";
+        webadd += h;
+        Serial.print(h);
+        webadd += "&field3=";
+        webadd += t;
+        Serial.print(" - ");
+        Serial.print(t);
+        enweille = 1;
+        dernt = t;
+        dernh = h;
+      }
+    }
+    if (enweille == 1) {
+      Serial.println("");
+      http.begin(webadd);
+      int httpCode = http.GET();//Send the request
+      if (httpCode > 0) {
+        Serial.println("Envoit réussit !");
+        tstrouteur = 0;
+      } else {
+        if (tstrouteur == 10) {
+          Serial.println("10 Erreur envoit ! REBOOT !");
+          ESP.restart();
         } else {
-          if (tstrouteur == 10) {
-            Serial.println("10 Erreur envoit ! REBOOT !");
-            ESP.restart();
-          } else {
-            Serial.println("!!! Erreur envoit !!!");
-            tstrouteur++;
-          }
+          Serial.println("!!! Erreur envoit !!!");
+          tstrouteur++;
         }
-        http.end();   //Close connection
+      }
+      http.end();   //Close connection
+    } else {
+      Serial.println("Envois pas car erreur de senseurs !");
+    }
+  } else {
+    Serial.println("Pas de API KEY donc pas d'envoi");
+  }
+}
+
+// web page for showing sensors data
+void handleTemp() {
+  String addy = server.client().remoteIP().toString();
+  float latemp;
+  float t;
+  float h;
+  String tempC;
+  if (usesenseurdallas == 1) {
+    sensors.requestTemperatures();
+    latemp = sensors.getTempCByIndex(0);
+    char buffer[10];
+    tempC = dtostrf(latemp, 5, 2, buffer);
+    if (tempC != "-127.00") {
+      if (tempC != "85.00") {
+        dernd = tempC;
+      } else {
+        Serial.println("Dallas error !");
+        if (dernd != "0") {
+          tempC = dernd;
+        }
       }
     } else {
       Serial.println("Dallas error !");
-    }
-  } else {
-    Serial.println("Pas de API KEY donc pas d'envoi");
-  }
-}
-
-// web page for showing sensors data
-void handleTemp() {
-  sensors.requestTemperatures();
-  float latemp = sensors.getTempCByIndex(0);
-  delay(250);
-  float t = 0;
-  float h = 0;
-  int err = SimpleDHTErrSuccess;
-  if ((err = dht22.read2(pinDHT22, &t, &h, NULL)) != SimpleDHTErrSuccess) {
-    Serial.print("Read DHT22 failed, err=");
-    Serial.println(err);
-  }
-  String addy = server.client().remoteIP().toString();
+      if (dernd != "0") {
+        tempC = dernd;
+      }
+    }
+    delay(250);
+  }
+  if (usesenseurdht == 1) {
+    t = 0;
+    h = 0;
+    int err = SimpleDHTErrSuccess;
+    if ((err = dht22.read2(pinDHT22, &t, &h, NULL)) != SimpleDHTErrSuccess) {
+      Serial.print("Read DHT22 failed, err=");
+      Serial.println(err);
+      t = dernt;
+      h = dernh;
+    }
+    dernt = t;
+    dernh = h;
+  }
   String contenu = "<!DOCTYPE html>\n\n\n";
   contenu += "<meta charset=\"UTF-8\" />\n<title>Quel chaleur</title>\n"
              "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
@@ -838,20 +941,34 @@
   contenu += "<form action=\"/\" method=\"get\">\n"
              "
Voici la température
"
              "
";
-  contenu += latemp;
-  contenu += "°C Humidité : ";
-  contenu += h;
+  if (usesenseurdallas == 1) {
+    contenu += tempC;
+    contenu += "°C";
+  }
+  if (usesenseurdht == 1) {
+    if (usesenseurdallas == 1) {
+      contenu += " - ";
+    }
+    contenu += t;
+    contenu += "°C - Humidité : ";
+    contenu += h;
+    contenu += "%";
+  }
   contenu += "

\n";
   if (thingchanel != "none") {
-    contenu += ""
-               ""
-               "";
+    if (usesenseurdallas == 1) {
+      contenu += "";
+    }
+    if (usesenseurdht == 1) {
+      contenu += ""
+                 "";
+    }
   } else {
     contenu += "
Vas dans /setup pour les réglages thingspeak !
";
   }
@@ -865,16 +982,28 @@
   server.send(200, "text/html", contenu);
   Serial.println("");
   Serial.println(addy);
-  Serial.print("Température : ");
-  Serial.println(latemp);
-  Serial.print("Humidité : ");
-  Serial.println(h);
+  if (usesenseurdallas == 1) {
+    Serial.print("Température : ");
+    Serial.println(latemp);
+  }
+  if (usesenseurdht == 1) {
+    Serial.print("Temp2 : ");
+    Serial.println(t);
+    Serial.print("Humidité : ");
+    Serial.println(h);
+  }
   logtourne();
   logs[1] = addy;
-  logs[1] += " : Temp : Temp=";
-  logs[1] += latemp;
-  logs[1] += " : Humidite=";
-  logs[1] += h;
+  if (usesenseurdallas == 1) {
+    logs[1] += " : Temp : Temp=";
+    logs[1] += latemp;
+  }
+  if (usesenseurdht == 1) {
+    logs[1] += " : Humidite=";
+    logs[1] += h;
+    logs[1] += " : Temp2=";
+    logs[1] += t;
+  }
 }

 int fadecomment(int claire) {
@@ -919,7 +1048,8 @@
   ledcSetup(2, 12000, 8);
   ledcSetup(3, 12000, 8);
   derncoul = preferences.getString("derncoul", "#000000");
-  usesenseur =  preferences.getUInt("usesenseur", 0);
+  usesenseurdallas = preferences.getUInt("usesenseurdal", 0);
+  usesenseurdht = preferences.getUInt("usesenseurdht", 0);
   r = preferences.getUInt("r", 0);
   g = preferences.getUInt("g", 0);
   b = preferences.getUInt("b", 0);
@@ -934,6 +1064,7 @@
     ESP.restart();
     delay(5000);
   }
+  delay(3000);
   MDNS.begin("lumiere");
   server.on("/", handleRoot);
   server.on("/setup", handleSetup);
@@ -946,7 +1077,7 @@
   server.on("/party", handleClignote);
   server.on("/version", []() {
     String addy = server.client().remoteIP().toString();
-    server.send(200, "text/html", "V2.6, Steve Olmstead sansillusion@gmail.com\n\n

"
+    server.send(200, "text/html", "V2.7, Steve Olmstead sansillusion@gmail.com\n\n

"
                 "Added fader function\nRemoved connection watchdog (better have good signal)\n
"
                 "Removed mDns (did not work anyway)\n\n

"
                 "Added smoother fading\n\n

"
@@ -974,7 +1105,9 @@
                 "Added color persistance trough reboot using esp32 Preferences\n\n

"
                 "Added /setup page to set admin password and thingspeak api key and channel\n\n

"
                 "Added option in /setup tu use or not temperature sensors\n
"
-                "Changed from Adafruit DHT library to simpleDHT for better reliability\n\n

"+ liens);
+                "Changed from Adafruit DHT library to simpleDHT for better reliability\n\n

"
+                "Changed /setup (removed use sensors and added use dht and use dallas checkboxes)\n
"
+                "Revamped /temp and lesliens() to accomodate new changes in setup\n\n

" + liens);
     Serial.println("");
     Serial.println(addy);
     Serial.println("Page de Version");
@@ -993,10 +1126,19 @@
 void loop() {
   server.handleClient();
   unsigned long currentMillis = millis();
-  if (usesenseur == 1) {
-    if (currentMillis - previousMillis >= interval) {
-      previousMillis = currentMillis;
+  if (currentMillis - previousMillis >= interval) {
+    previousMillis = currentMillis;
+    int usesenseur = 0;
+    if (usesenseurdallas == 1) {
+      usesenseur = 1;
+    }
+    if (usesenseurdht == 1) {
+      usesenseur = 1;
+    }
+    if (usesenseur == 1) {
       latemp();
+    } else {
+      Serial.println("");
     }
   }
   if (flashoufade == 1) {


add setup() to the basic-est example

add setup() to the basic-est example

--- examples-ltc/6.LTCVolume1/Test1/Test1.ino
+++ examples-ltc/6.LTCVolume1/Test1/Test1.ino
@@ -3,6 +3,9 @@
 // Volume 1 syntax demo

 // The simplest possible blink example is shown here using the LTC API.
+setup() {
+  outputMode(0);
+}

 loop() {
   on(0);


v 1.0.13 en master

v 1.0.13 en master


tweak

tweak

--- examples/Ports/blink_timers/blink_timers.ino
+++ examples/Ports/blink_timers/blink_timers.ino
@@ -3,7 +3,7 @@

 #include <JeeLib.h>

-BlinkPlug myPlug (1); // needs a Blink Plug attached to port 1
+BlinkPlug myPlug (1); // expects a Blink Plug on port 1
 MilliTimer timer1, timer2;

 void setup () {


Change mater RF Pins

Change mater RF Pins

--- arduino/Master/Master.ino
+++ arduino/Master/Master.ino
@@ -7,7 +7,7 @@
 #include <ArduinoJson.h>
 #include <stdlib.h>

-RF24 radio(7, 8);
+RF24 radio(49, 53);
 RF24Network network(radio);
 RF24Mesh mesh(radio, network);


Tidied up code

Tidied up code

--- wled00/wled17_mqtt.ino
+++ wled00/wled17_mqtt.ino
@@ -227,7 +227,6 @@
   } else {
     mqtt->setServer(mqttServer, WLED_MQTT_PORT);
   }
-  //mqtt->setClientId(escapedMac.c_str());
   mqtt->setClientId(mqttClientID);
   if (mqttUser[0] && mqttPass[0] != 0) mqtt->setCredentials(mqttUser, mqttPass);
   mqtt->onMessage(onMqttMessage);


modifying code from the strandtest example. working on the poweerOn method.

--- Helios.ino
+++ Helios.ino
@@ -1,9 +1,10 @@
 #include <Adafruit_NeoPixel.h>
+#include <avr/power.h>

-      #define PIN 6
+#define PIN 6

 // Parameter 1 = number of pixels in strip
-// Parameter 2 = pin number (most are valid)
+// Parameter 2 = Arduino pin number (most are valid)
 // Parameter 3 = pixel type flags, add together as needed:
 //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
 //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
@@ -11,15 +12,153 @@
 //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(30, PIN, NEO_GRB + NEO_KHZ800);

+// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
+// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
+// and minimize distance between Arduino and first pixel.  Avoid connecting
+// on a live circuit...if you must, connect GND first.
+
 void setup() {
- // strip.begin();
+  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
+#if defined (__AVR_ATtiny85__)
+  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
+#endif
+  // End of trinket special code
+
   strip.begin();
   strip.show(); // Initialize all pixels to 'off'
-  strip.setPixelColor(11, 255, 0, 255);
-  strip.show(); // Initialize all pixels to 'off'
-
+  //powerOn(strip.Color(255, 150, 110), 750);
+  powerOn(255,255,255, 10, 25);
 }

 void loop() {
-  // put your main code here, to run repeatedly:
+  // Some example procedures showing how to display to the pixels:
+ // colorWipe(strip.Color(255, 0, 0), 50); // Red
+ // colorWipe(strip.Color(0, 255, 0), 50); // Green
+ // colorWipe(strip.Color(0, 0, 255), 50); // Blue
+  // Send a theater pixel chase in...
+ // theaterChase(strip.Color(127, 127, 127), 50); // White
+ // theaterChase(strip.Color(127,   0,   0), 50); // Red
+ // theaterChase(strip.Color(  0,   0, 127), 50); // Blue
+ // 255 152 96
+
+ //powerOn(strip.Color(255, 150, 110), 750);
+ /*
+ powerOn(strip.Color(255, 0, 0), 100);
+ powerOn(strip.Color(0, 255, 0), 100);
+ powerOn(strip.Color(0, 0, 255), 100);
+ powerOn(strip.Color(255, 255, 255), 100);
+
+*/
+ // rainbow(20);
+ // rainbowCycle(20);
+ // theaterChaseRainbow(50);
 }
+
+void powerOn(uint16_t r, uint16_t g, uint16_t b, uint16_t wait, uint16_t fadeTime) {
+  uint8_t a = 0;
+  while(a < strip.numPixels()/2) {
+    for(uint32_t i=0; i < 100; i++) {
+      double percent = (double)i/100;
+      strip.setPixelColor(a, strip.Color((uint16_t)percent*r, (uint16_t)percent*g, (uint16_t)percent*b));
+      strip.setPixelColor(((strip.numPixels() - 1) - a), strip.Color((uint16_t)percent*r, (uint16_t)percent*g, (uint16_t)percent*b));
+      strip.show();
+      delay(fadeTime);
+    }
+    //strip.show();
+    a++;
+    delay(wait);
+  }
+}
+
+// Fill the dots one after the other with a color
+void colorWipe(uint32_t c, uint8_t wait) {
+  for(uint16_t i=0; i<strip.numPixels(); i++) {
+      strip.setPixelColor(i, c);
+      strip.show();
+      delay(wait);
+  }
+}
+
+/*
+void rainbow(uint8_t wait) {
+  uint16_t i, j;
+
+  for(j=0; j<256; j++) {
+    for(i=0; i<strip.numPixels(); i++) {
+      strip.setPixelColor(i, Wheel((i+j) & 255));
+    }
+    strip.show();
+    delay(wait);
+  }
+}
+*/
+
+/*
+// Slightly different, this makes the rainbow equally distributed throughout
+void rainbowCycle(uint8_t wait) {
+  uint16_t i, j;
+
+  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
+    for(i=0; i< strip.numPixels(); i++) {
+      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
+    }
+    strip.show();
+    delay(wait);
+  }
+}
+*/
+
+/*
+//Theatre-style crawling lights.
+void theaterChase(uint32_t c, uint8_t wait) {
+  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
+    for (int q=0; q < 3; q++) {
+      for (int i=0; i < strip.numPixels(); i=i+3) {
+        strip.setPixelColor(i+q, c);    //turn every third pixel on
+      }
+      strip.show();
+
+      delay(wait);
+
+      for (int i=0; i < strip.numPixels(); i=i+3) {
+        strip.setPixelColor(i+q, 0);        //turn every third pixel off
+      }
+    }
+  }
+}
+*/
+/*
+//Theatre-style crawling lights with rainbow effect
+void theaterChaseRainbow(uint8_t wait) {
+  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
+    for (int q=0; q < 3; q++) {
+        for (int i=0; i < strip.numPixels(); i=i+3) {
+          strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
+        }
+        strip.show();
+
+        delay(wait);
+
+        for (int i=0; i < strip.numPixels(); i=i+3) {
+          strip.setPixelColor(i+q, 0);        //turn every third pixel off
+        }
+    }
+  }
+}
+*/
+
+// Input a value 0 to 255 to get a color value.
+// The colours are a transition r - g - b - back to r.
+uint32_t Wheel(byte WheelPos) {
+  WheelPos = 255 - WheelPos;
+  if(WheelPos < 85) {
+   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
+  } else if(WheelPos < 170) {
+    WheelPos -= 85;
+   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
+  } else {
+   WheelPos -= 170;
+   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
+  }
+}
+


bugfix

bugfix

--- NeoPixelSwitchBox/NeoPixelSwitchBox.ino
+++ NeoPixelSwitchBox/NeoPixelSwitchBox.ino
@@ -274,7 +274,7 @@

     // spin decrement button adjusts the spin counter-clockwise by NUM_LIGHTS_PER_SWITCH
     decrementSpinButton.update();
-    if (incrementSpinButton.closedThisUpdate()) {
+    if (decrementSpinButton.closedThisUpdate()) {
       ring.adjustSpinOffset(-NUM_LIGHTS_PER_SWITCH);
     }
   }


Convert runSteppersToPos() to work with a variable number of axes. It's vitally important that this function works correctly.

--- OpenStage/openStage_moveToTarget.ino
+++ OpenStage/openStage_moveToTarget.ino
@@ -116,24 +116,33 @@

   int n=0; //counter to monitor if the controller is locked in this loop

-  while (stepperX.distanceToGo() != 0 ||
-         stepperY.distanceToGo() != 0 ||
-         stepperZ.distanceToGo() != 0){
-      stepperX.run();
-      stepperY.run();
-      stepperZ.run();
-
+  long keepMoving=0;
+  while (keepMoving>0){
+
+    for (int ii=0; ii<numAxes; ii++){
+      if (!axisPresent[ii]){
+        continue;
+      }
+      keepMoving += (*mySteppers[ii]).distanceToGo();
+      (*mySteppers[ii]).run();
+    }
+

       //Sometimes the controller locks up following analog stick motions
       //This is due to it getting stuck in this loop with the motors at zero
       //speed. Not yet clear why this happens, but in the mean time we can catch
       //it with the following code and deliver an audible indication that something
       //is wrong. This enables us to keep going and not lock up.
-      if (stepperX.speed()==0 &&
-          stepperY.speed()==0 &&
-          stepperZ.speed()==0)
+      long currentTotalSpeed=0;
+      for (int ii=0; ii<numAxes; ii++){
+        if (!axisPresent[ii]){
+           continue;
+        }
+        currentTotalSpeed+=(*mySteppers[ii]).speed();
+      }
+      if (currentTotalSpeed==0){
             n++;
-
+      }
       if (n>50){ //If we're stuck here not moving for 50 cycles then something's wrong!
         for (int ii=0; ii<5; ii++){
             serialBeep();


Update 01_Particle.ino

Update 01_Particle.ino

--- firmware/examples/01_Particle/01_Particle.ino
+++ firmware/examples/01_Particle/01_Particle.ino
@@ -6,84 +6,61 @@
  *
  *   Downloads, docs, tutorials: http://www.blynk.cc
  *   Blynk community:            http://community.blynk.cc
- *   Social groups:              http://www.fb.com/blynkapp
+ *   Social networks:            http://www.fb.com/blynkapp
  *                               http://twitter.com/blynk_app
  *
  * Blynk library is licensed under MIT license
  * This example code is in public domain.
- *
- * WARNING: It is recommended to use SparkCorePolledTimer library
- *          to make periodic actions (similar to SimpleTimer on Arduino).
+ *
+ **************************************************************
+ *
+ * This example shows how to use RedBear Duo BLE
+ * to connect your project to Blynk.
+ *
+ * NOTE: BLE support is in beta!
  *
  **************************************************************/
-//#define BLYNK_DEBUG // Uncomment this to see debug prints
+
+#if defined(ARDUINO)
+  SYSTEM_MODE(MANUAL);    // If Arduino - do not connect to Particle cloud
+#else
+  SYSTEM_MODE(AUTOMATIC); // Otherwise, connect to Particle cloud
+#endif
+
+//#define BLYNK_DEBUG
 #define BLYNK_PRINT Serial
-#include "blynk/blynk.h"
+
+//#define BLYNK_USE_DIRECT_CONNECT
+
+#include <BlynkSimpleRedBear_Duo_BLE.h>

 // You should get Auth Token in the Blynk App.
 // Go to the Project Settings (nut icon).
 char auth[] = "YourAuthToken";

-// Attach a Button widget (mode: Switch) to the Digital pin 7 - and control the built-in blue led.
-// Attach a Graph widget to Analog pin 1
-// Attach a Gauge widget to Analog pin 2
+void setup() {
+  Serial.begin(9600);
+  delay(5000);

-// No coding required for direct pin operations!
+  Blynk.begin(auth);

-void setup()
-{
-    Serial.begin(9600);
-    delay(5000); // Allow board to settle
-    Blynk.begin(auth);
+  Serial.println("Waiting for connections...");
 }

-// Attach a Button widget (mode: Push) to the Virtual pin 1 - and send sweet tweets!
-BLYNK_WRITE(V1) {
-    if (param.asInt() == 1) { // On button down...
-        // Tweeting!
-        // Note:
-        //   We allow 1 tweet per minute for now.
-        //   Twitter doesn't allow identical subsequent messages.
-        Blynk.tweet("My Particle project is tweeting using @blynk_app and it’s awesome!\n @Particle #IoT #blynk");
-
-        // Pushing notification to the app!
-        // Note:
-        //   We allow 1 notification per minute for now.
-        Blynk.notify("You pressed the button and I know it ;)");
-    }
+void loop() {
+  Blynk.run();
 }

-// Attach a ZeRGBa widget (mode: Merge) to the Virtual pin 2 - and control the built-in RGB led!
-BLYNK_WRITE(V2) {
-    int r = param[0].asInt();
-    int g = param[1].asInt();
-    int b = param[2].asInt();
-    if (r > 0 || g > 0 || b > 0) {
-        RGB.control(true);
-        RGB.color(r, g, b);
-    } else {
-        RGB.control(false);
-    }
+// Next functions are optional.
+// Add ZeRGBa Widget on V0 to control onboard LED.
+BLYNK_CONNECTED() {
+  RGB.control(true);
 }

-void loop()
-{
-    Blynk.run();
-
-    if (ModeBtnPressed()) {
-        Blynk.notify("Mode button was pressed");
-    }
+BLYNK_WRITE(V0) {
+  int r = param[0].asInt();
+  int g = param[1].asInt();
+  int b = param[2].asInt();
+  RGB.color(r, g, b);
 }

-// *** Utility functions
-
-bool ModeBtnPressed() {
-    if(millis() > 5000) {
-        if(BUTTON_GetDebouncedTime(BUTTON1) >= 50) {
-            BUTTON_ResetDebouncedState(BUTTON1);
-            return 1;
-        }
-    }
-    return 0;
-}
-


Remove extra example file

Remove extra example file

--- examples/semaphore/semaphore_ino/semaphore_ino.ino
+++ examples/semaphore/semaphore_ino/semaphore_ino.ino
@@ -1,134 +0,0 @@
-/*
-This example implements a simple consumer node that implements a semaphore.
-It control 3 leds (green,yellow and red).
-The on event makes the transition from red to green and the off event goes from green to red. Both passing throu yellow.
-Usim FLIM mode teach on/off events.
-It implements all automatic configuration, including learning events.
-It does not handle short events. In phase of implementation.
-It does not handle DCC messages, but you can do it on your user function.
-You can change the ports to fit to your arduino.
-This node uses 500 bytes of EPROM to store events and the other information.
-See MemoryManagement.h for memory configuration
-*/
-
-
-
-#include <Arduino.h>
-#include <SPI.h>
-#include <MergCBUS.h>
-#include <Message.h>
-#include <EEPROM.h>
-#include <TimerOne.h>
-
-#define GREEN_LED 5       //merg green led port
-#define YELLOW_LED 4      //merg yellow led port
-#define PUSH_BUTTON 3     //std merg push button
-#define PUSH_BUTTON1 9    //debug push button
-//semaphore leds
-#define GREEN 10        //green led
-#define YELLOW 11        //green led
-#define RED 12        //green led
-#define TRANSITION_TIME  2000 //time in milli to keep the yellow light on
-
-MergCBUS cbus=MergCBUS();
-byte lighton;//control the state
-byte nextlighton;//control the state
-unsigned long starttime;
-
-//timer function to read the can messages
-void readCanMessages(){
-  //read the can message and put then in a circular buffer
-  cbus.cbusRead();
-}
-
-void setup(){
-
-  setLedPorts();     //setup the sensor ports
-  pinMode(PUSH_BUTTON1,INPUT_PULLUP);//debug push button
-  Serial.begin(115200);
-
-  //cbus.setUpNewMemory(); //uncomment this line to setup a new node and then comment it again
-  //Configuration data for the node
-  cbus.getNodeId()->setNodeName("MODTESTE",8);  //node name
-  cbus.getNodeId()->setModuleId(55);            //module number
-  cbus.getNodeId()->setManufacturerId(0xA5);    //merg code
-  cbus.getNodeId()->setMinCodeVersion(1);       //Version 1
-  cbus.getNodeId()->setMaxCodeVersion(0);
-  cbus.getNodeId()->setSuportedEvents(20);      //max supported events. this can be changed in the memory config
-  cbus.getNodeId()->setSuportedEventsVariables(8);
-  cbus.getNodeId()->setSuportedNodeVariables(20);
-  cbus.getNodeId()->setProducerNode(true);
-  cbus.getNodeId()->setConsumerNode(false);
-  cbus.setStdNN(999); //standard node number
-
-  cbus.setLeds(GREEN_LED,YELLOW_LED);//set the led ports
-  cbus.setPushButton(PUSH_BUTTON);//set the push button ports
-  cbus.setDebug(true);//print some messages on the serial port
-  cbus.setUserHandlerFunction(&myUserFunc);//function that implements the node logic
-  cbus.initCanBus(53,CAN_125KBPS,10,200);  //initiate the transport layer
-
-  Timer1.initialize(10000);//microseconds
-  Timer1.attachInterrupt(readCanMessages);
-  Serial.println("Setup finished");
-}
-
-void loop (){
-
-  cbus.run();//do all logic
-  //debug memory
-  if (digitalRead(PUSH_BUTTON1)==LOW){
-    cbus.dumpMemory();
-  }
-}
-
-void myUserFunc(Message *msg,MergCBUS *mcbus){
-
-  //getting standard on/off events
-  if (mcbus->eventMatch()){
-      lighton=YELLOW;
-      turnLightsOn();
-      starttime=millis();
-
-      if (mcbus->isAccOn()){
-        nextlighton=GREEN;
-      }
-      else {
-        nextlighton=RED;
-      }
-  }
-  if (lighton==YELLOW){
-    if ((millis()-starttime)>TRANSITION_TIME){
-      lighton=nextlighton;
-    }
-  }
-  turnLightsOn();
-}
-//config the leds ports and the initial state
-void setLedPorts(){
-
-  pinMode(GREEN,OUTPUT);
-  pinMode(YELLOW,OUTPUT);
-  pinMode(RED,OUTPUT);
-  lighton=GREEN;
-  turnLightsOn();
-}
-
-void turnLightsOn(){
-  switch (lighton){
-    case (GREEN):
-      digitalWrite(GREEN,HIGH);
-      digitalWrite(RED,LOW);
-      digitalWrite(YELLOW,LOW);
-    break;
-    case (RED):
-      digitalWrite(RED,HIGH);
-      digitalWrite(GREEN,LOW);
-      digitalWrite(YELLOW,LOW);
-    break;
-    case (YELLOW):
-      digitalWrite(YELLOW,HIGH);
-      digitalWrite(RED,LOW);
-      digitalWrite(GREEN,LOW);
-    break;
-  }
-}


Fix typo in example

Fix typo in example

--- examples/ColorPalette/ColorPalette.ino
+++ examples/ColorPalette/ColorPalette.ino
@@ -165,7 +165,7 @@

-// Additionl notes on FastLED compact palettes:
+// Additional notes on FastLED compact palettes:
 //
 // Normally, in computer graphics, the palette (or "color lookup table")
 // has 256 entries, each containing a specific 24-bit RGB color.  You can then


Add simple pause in tone play.

Add simple pause in tone play.

--- examples/Sandbox/CosaTone/CosaTone.ino
+++ examples/Sandbox/CosaTone/CosaTone.ino
@@ -36,7 +36,7 @@

   // Classical telephone signal
   for (uint8_t i = 0; i < 10; i++) {
-    Tone::play(Note::A4, 5, 200);
+    Tone::play(Note::A4, i, 200);
     delay(200);
   }
   sleep(3);
@@ -52,15 +52,19 @@
 void play(const uint16_t* freq, uint8_t volume, uint16_t duration)
 {
   uint16_t f;
-  while ((f = *freq++) != Note::END)
-    Tone::play(f, volume, duration);
+  while ((f = *freq++) != Note::END) {
+    if (f == Note::PAUSE) delay(100);
+    else Tone::play(f, volume, duration);
+  }
 }

 void play_P(const uint16_t* freq, uint8_t volume, uint16_t duration)
 {
   uint16_t f;
-  while ((f = pgm_read_word(freq++)) != Note::END)
-    Tone::play(f, volume, duration);
+  while ((f = pgm_read_word(freq++)) != Note::END) {
+    if (f == Note::PAUSE) delay(100);
+    else Tone::play(f, volume, duration);
+  }
 }

 void loop()


better terminal example

better terminal example

--- examples/Widgets/Terminal/Terminal.ino
+++ examples/Widgets/Terminal/Terminal.ino
@@ -54,6 +54,11 @@
   terminal.write(param.getBuffer(), param.getLength());
   terminal.println();

+  // print "received 'repeat' text" string back if we got "repeat" string
+  if (String("repeat") == param.asStr()) {
+      terminal.println("received 'repeat' text") ;
+  }
+
   // Ensure everything is sent
   terminal.flush();
 }


Minor corrections.

Minor corrections.

--- examples/buttons_menu/buttons_menu.ino
+++ examples/buttons_menu/buttons_menu.ino
@@ -1,7 +1,7 @@
 /*
  * LiquidMenu library - buttons_menu.ino
  *
- * This example demonstrates the use of buttons, callback
+ * This example demonstrates how to use buttons, callback
  * functions and changing text variables.
  *
  * It creates three screens. The first one displays static
@@ -128,18 +128,18 @@
  * writes it to the pin.
  */
 void pwm_up() {
-	if (pwmLevel <= 245) {
-		pwmLevel += 10;
+	if (pwmLevel < 225) {
+		pwmLevel += 25;
 	} else {
-		pwmLevel = 0;
+		pwmLevel = 250;
 	}
 	analogWrite(pwmPin, pwmLevel);
 }

 // Function to be attached to the pwm_line object.
 void pwm_down() {
-	if (pwmLevel >= 10) {
-		pwmLevel -= 10;
+	if (pwmLevel > 25) {
+		pwmLevel -= 25;
 	} else {
 		pwmLevel = 0;
 	}


Update Beacon.ino

Update Beacon.ino

--- FastLED/Beacon.ino
+++ FastLED/Beacon.ino
@@ -65,22 +65,25 @@
 	uint8_t satBright = 20;
 	CRGB color = red;

-    while (touchEvent != CapTouch::ReleaseEvent) {
-		satBright += 5;
-		color.saturation = satBright;
-		color.brightness = satBright;
+    	while (touchEvent != CapTouch::ReleaseEvent) {
+
 		if(satBright >= 255){
 			satBright = 20;
 			colorIndex +=1;
 			color = currentPalette[colorIndex % colors];
-		}
-	}
-	uint8_t pixelsLit = map(satBright,0,255,0,STRIP_LEDS+1);
-	for int(i = 0; i <= pixelsLit && i <= STRIP_LEDS;i++){
-		stripLeds[i] = color;
-	}
-	if(pixelsLit > STRIP_LEDS){
-		fill_solid(&ringLeds, RING_LEDS, color); //at max capacity, light up the whole beacon
+			}
+
+		uint8_t pixelsLit = map(satBright,0,255,0,STRIP_LEDS+1);
+
+		for int(i = 0; i <= pixelsLit && i <= STRIP_LEDS;i++){
+			stripLeds[i] = color;
+			}
+		if(pixelsLit > STRIP_LEDS){
+			fill_solid(&ringLeds, RING_LEDS, color); //at max capacity, light up the whole beacon
+			}
+		satBright += 5;
+		color.saturation = satBright;
+		color.brightness = satBright;
 	}
 	fastLED.show();
 	beaconColor = color;


8 dir keys from joystick

8 dir keys from joystick

--- remap.ino
+++ remap.ino
@@ -19,7 +19,7 @@
   curJoystick->sliderRight((1023-t)&1023);
 }

-void buttonizeStick(uint8_t* buttons, uint8_t x, uint8_t y) {
+void buttonizeStick4dir(uint8_t* buttons, uint8_t x, uint8_t y) {
   uint8_t dx = x < 128 ? 128 - x : x - 128;
   uint8_t dy = y < 128 ? 128 - y : y - 128;
   if (dx > dy) {
@@ -39,6 +39,38 @@
     else {
       buttons[virtualUp] = 1;
     }
+  }
+}
+
+const uint32_t tan22_5 = 4142;
+
+void buttonizeStick(uint8_t* buttons, uint8_t x, uint8_t y) {
+  uint32_t dx = x < 128 ? 128 - x : x - 128;
+  uint32_t dy = y < 128 ? 128 - y : y - 128;
+  uint32_t r2 = dx*dx+dy*dy;
+  if (r2 <= directionThreshold*(uint32_t)directionThreshold)
+    return;
+  if (dy * 10000 < tan22_5 * dx) {
+    if (x<128)
+      buttons[virtualLeft]=1;
+    else
+      buttons[virtualRight]=1;
+  }
+  else if (dx * 10000 < dy * tan22_5) {
+    if (y<128)
+      buttons[virtualDown]=1;
+    else
+      buttons[virtualUp]=1;
+  }
+  else {
+    if (x<128)
+      buttons[virtualLeft]=1;
+    else
+      buttons[virtualRight]=1;
+    if (y<128)
+      buttons[virtualDown]=1;
+    else
+      buttons[virtualUp]=1;
   }
 }


A few fixes..

A few fixes..

--- apollo/apolloClient/apolloClient.ino
+++ apollo/apolloClient/apolloClient.ino
@@ -56,11 +56,15 @@
 */
 void(* resetFunc)(void) = 0;

+int twoBytesToInt();
+
 void setup() {
   resetEthernet(A5);
   Serial.begin(9600);
   delay(500);
+
   Serial.println(F("Started"));
+
   setupWDT();
   // put your setup code here, to run once:

@@ -77,6 +81,7 @@
   if (updateNow) {
     resetEthernet(A5);
     delay(2000);
+
     Serial.println(F("Apollo init"));

     // Init SD Card
@@ -88,12 +93,15 @@

     // create a new file
     Fat16 file;
-    const char name[] = "FIRMWARE.BIN";
-    file.open(name, O_CREAT | O_WRITE);
+    const char fileName[] = "FIRMWARE.BIN";
+    file.open(fileName, O_CREAT | O_WRITE);

     Serial.println(F("Getting new Firmware file"));
+
     if (client.connect(updateServer, 80)) {  //starts client connection, checks for connection
+
       Serial.println(F("Connected to Update Server"));
+
       client.println(F("GET /apollo/FIRMWARE.BIN HTTP/1.1")); //download text
       client.println(F("Host: www.debcal.co.za"));
       client.println(F("Connection: close"));  //close 1.1 persistent connection
@@ -108,19 +116,21 @@
         }
       }
 end:
+
       Serial.println();
       Serial.print(F("File size = "));

       // The first two bytes are the size of the file
-      unsigned int prependedSize = twoBytesToInt(byteStream);
+      unsigned int prependedSize = twoBytesToInt();
       // The next two bytes are the checksum
-      unsigned int checksum = twoBytesToInt(byteStream);
+      unsigned int checksum = twoBytesToInt();

       Serial.print(prependedSize);
       Serial.println(F(" bytes"));
       Serial.print(F("File checksum = "));
       Serial.println(checksum);
       Serial.print(F("Receiving Data: "));
+
       int bytesReceived = 0;
       byte sum1 = 0;
       byte sum2 = 0;
@@ -151,18 +161,33 @@

       Serial.println();
       Serial.print(F("File check: "));
+
       if (prependedSize == bytesReceived && checksum == computedChecksum) {
+
         Serial.println(F("OK"));
+
       }
       else if (checksum != computedChecksum) {
+
         Serial.println(F("CHECKSUM ERROR!"));
+
+        Serial.println(F("Removing file"));
+        file.remove();
+
       }
       else if (prependedSize != bytesReceived) {
+
         Serial.println(F("SIZE ERROR!"));
+
+        Serial.println(F("Removing file"));
+        file.remove();
+
       }

       if (!client.connected()) {
+
         Serial.println(F("Disconecting"));
+
         client.stop();
       }

@@ -171,7 +196,9 @@
       //Disable the SD card:
       pinMode(CHIP_SELECT, OUTPUT);
       digitalWrite(CHIP_SELECT, HIGH);
+
       Serial.println(F("Resetting..."));
+
       delay(200);
       resetFunc();

@@ -179,7 +206,12 @@
     else {
       Serial.println(F("Connection failed")); //error message if no client connect
       Serial.println();
+
+      Serial.println(F("Removing file"));
+      file.remove();
+
       Serial.println(F("Resetting..."));
+
       delay(200);
       resetFunc();
     }
@@ -218,9 +250,10 @@
   if (updateCounter * 8 / 15 >= updateInterval)
   {
     updateNow = true;
+    updateCounter = 0;
   }
   // Quick Lock up watch Dawg.
-  else if (updateCounter * 8 / 60 >= updateInterval)
+  else if (updateCounter * 8 / 60 >= updateInterval * 2)
   {
     resetFunc();
   }
@@ -233,9 +266,9 @@
 void resetEthernet(int pin) {
   pinMode(pin, OUTPUT);
   digitalWrite(pin, LOW);
-  delay(500);
+  delay(1000);
   digitalWrite(pin, HIGH);
-  delay(500);  // start the Ethernet connection:
+  delay(1000);  // start the Ethernet connection:
   if (Ethernet.begin(mac) == 0) {
     //Serial.println("Failed to configure Ethernet using DHCP");
     // try to congifure using IP address instead of DHCP:
@@ -243,32 +276,31 @@
   }
 }

-
-
-
-/**
- * A little wrapper function which can be pointed to.
- */
+/**
+   A little wrapper function which can be pointed to.
+*/
 char byteStream() {
-  return client.read();
-}
-
-/**
- * Used to count the amount of mathching bytes found in the stream.
- * It can not be local to checkBytes
- */
+  char a = client.read();
+  Serial.print(a);
+  return a;
+}
+
+/**
+   Used to count the amount of mathching bytes found in the stream.
+   It can not be local to checkBytes
+*/
 int matchingBytes = 0;

 /**
- * Searches a byteStream for a sequence of bytes
- */
+   Searches a byteStream for a sequence of bytes
+*/
 bool checkBytes(char* sequence, int sequenceLength, char (*stream)()) {
   int byteCount = 0;
   while (matchingBytes < sequenceLength) {
     matchingBytes = sequence[matchingBytes] == stream() ? matchingBytes + 1 : 0;
     byteCount++;
     // Allow some sort of default behaviour
-    if (byteCount >= 2048) {
+    if (byteCount >= 4096) {
       return false;
     }
   }
@@ -276,12 +308,14 @@
 }

 /**
- * Reads two consecutive bytes from the byteStream, and returns a little endian int.
- */
-int twoBytesToInt(char (*stream)()) {
+   Reads two consecutive bytes from the byteStream, and returns a little endian int.
+*/
+int twoBytesToInt() {
   int tempVal = 0;
-  tempVal = stream() << 8;
-  tempVal |= stream();
+  byte one = client.read();
+  byte two = client.read();
+  tempVal = one << 8;
+  tempVal |= two;
   return tempVal;
 }


mudado portas dos sensores de segurança

mudado portas dos sensores de segurança

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -10,9 +10,9 @@
     const byte bt_geral = 22; // Entrada do botão de Liga/Desliga Geral
     const byte bt_dosador = 24; // Entrada do botão de Liga/Desliga do Dosador
     const byte bt_datador = 26; // Entrada do botão de Liga/Desliga do Datador
-    const byte sensor_porta = 48; // Sensor de Segurança da Porta Frontal
-    const byte sensor_painel = 50; // Sensor de Segurança da Porta do Painel
-    const byte sensor_maquina = 52; // Sensor de Segurança da Porta da Máquina
+    const byte sensor_porta = 32; // Sensor de Segurança da Porta Frontal
+    const byte sensor_painel = 34; // Sensor de Segurança da Porta do Painel
+    const byte sensor_maquina = 36; // Sensor de Segurança da Porta da Máquina
     const byte pot_solda_vertical = A0; // Potenciômetro da Solda Vertical
     const byte pot_solda_horizontal = A1; // Potenciômetro da Solda Vertical
     const byte pot_solda_datador = A2; // Potenciômetro da Solda Vertical


MQTT433gateway.ino: small typecasting fix

change int to unsigned int to avoid compiler warning.

--- MQTT433gateway.ino
+++ MQTT433gateway.ino
@@ -126,7 +126,7 @@
   Serial.print(F("Message arrived ["));
   Serial.print(topic_);
   Serial.print(F("] "));
-  for (int i = 0; i < length; i++) {
+  for (unsigned int i = 0; i < length; i++) {
     Serial.print((char)payload_[i]);
   }
   Serial.println();


[FretBoard] add support for Unknown activity status

--- FretBoard/FretBoard.ino
+++ FretBoard/FretBoard.ino
@@ -26,7 +26,7 @@
 /*
   build status values are recorded as follows:
   xx00 - undefined/off
-  xx01 - 1 sleeping or checking mods
+  xx01 - 1 sleeping, checking mods or unknown
   xx10 - 2 building
   00xx - undefined/off
   01xx - 4 fail
@@ -187,9 +187,8 @@
                   status = status ^ 2;
                   break;
                 case 'S': // Sleeping
-                  status = status ^ 1;
-                  break;
                 case 'C': // CheckingModifications
+                case 'U': // Unknown
                   status = status ^ 1;
                   break;
               }


typo in StringLength.ino fixes #1028

typo in StringLength.ino fixes #1028

--- build/shared/examples/08.Strings/StringLength/StringLength.ino
+++ build/shared/examples/08.Strings/StringLength/StringLength.ino
@@ -23,7 +23,7 @@

   // send an intro:
   Serial.println("\n\nString  length():");
-  Serial.ptintln();
+  Serial.println();
 }

 void loop() {


COH-71: WIP

COH-71: WIP

--- Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -1280,7 +1280,6 @@
       }
 #endif

-
 #if defined(ENABLE_FHT8VSIMPLE)
   // Try for double TX for more robust conversation with valve?
   const bool doubleTXForFTH8V = false;
@@ -1289,17 +1288,19 @@
   bool useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_First(doubleTXForFTH8V); // Time for extra TX before UI.
   if(useExtraFHT8VTXSlots)
     {
-    // Time for extra TX before other actions, but don't bother if minimising power in frost mode.
+    handleQueuedMessages(&Serial, true, &PrimaryRadio);
     // ---------- HALF SECOND #1 -----------
     useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
     }
   if(useExtraFHT8VTXSlots)
     {
+    handleQueuedMessages(&Serial, true, &PrimaryRadio);
     // ---------- HALF SECOND #2 -----------
     useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
     }
   if(useExtraFHT8VTXSlots)
     {
+    handleQueuedMessages(&Serial, true, &PrimaryRadio);
     // ---------- HALF SECOND #3 -----------
     useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
     }


COH-71: WIP

COH-71: WIP

--- Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -445,9 +445,9 @@
   // Set up async edge interrupts.
   ATOMIC_BLOCK (ATOMIC_RESTORESTATE)
     {
-    //PCMSK0 = PB; PCINT  0--7    (LEARN1 and Radio)
+    //PCMSK0 = PB; PCINT  0--7    (Radio)
     //PCMSK1 = PC; PCINT  8--15
-    //PCMSK2 = PD; PCINT 16--24   (Serial RX and LEARN2 and MODE and Voice)
+    //PCMSK2 = PD; PCINT 16--24   (Serial RX)

     PCICR =
 #if defined(MASK_PB) && (MASK_PB != 0) // If PB interrupts required.
@@ -486,18 +486,40 @@
   TIME_LSD = OTV0P2BASE::getSecondsLT();
   }

-void loop() {
-  // put your main code here, to run repeatedly:
-
-}
-
-
-
-
-
-
-
-
-
-
-
+
+// Main code here, loops every 2s.
+void loop()
+  {
+  OTV0P2BASE::powerDownSerial(); // Ensure that serial I/O is off.
+  // Power down most stuff (except radio for hub RX).
+  OTV0P2BASE::minimisePowerWithoutSleep();
+  uint_fast8_t newTLSD;
+  while(TIME_LSD == (newTLSD = OTV0P2BASE::getSecondsLT()))
+    {
+// FIXME FIXME FIXME
+//    // Poll I/O and process message incrementally (in this otherwise idle time)
+//    // before sleep and on wakeup in case some IO needs further processing now,
+//    // eg work was accrued during the previous major slow/outer loop
+//    // or the in a previous orbit of this loop sleep or nap was terminated by an I/O interrupt.
+//    // Come back and have another go if work was done, until the next tick at most.
+//    if(handleQueuedMessages(&Serial, true, &PrimaryRadio)) { continue; }
+
+    // Normal long minimal-power sleep until wake-up interrupt.
+    // Rely on interrupt to force fall through to I/O poll() below.
+    OTV0P2BASE::sleepUntilInt();
+    }
+  TIME_LSD = newTLSD;
+
+
+  }
+
+
+
+
+
+
+
+
+
+
+


Auto format code.

Auto format code.

--- wifitask.ino
+++ wifitask.ino
@@ -33,7 +33,7 @@
     ESP_LOGI( TAG, "Waiting %i seconds for SmartConfig.", rebootDelayMs / 1000 );

-    while ( !WiFi.smartConfigDone() && ( (unsigned long) millis() - smartConfigStartMs ) < rebootDelayMs )
+    while ( !WiFi.smartConfigDone() && ( (unsigned long)millis() - smartConfigStartMs ) < rebootDelayMs )
     {
       char remainingSCTime[12];
       if ( xOledTaskHandle )
@@ -41,7 +41,7 @@
         OLED.clear();
         OLED.setFont( ArialMT_Plain_10 );
         OLED.drawString( 64, 10, "Waiting for SmartConfig." );
-        snprintf( remainingSCTime, sizeof( remainingSCTime), "%i seconds", ( (unsigned long) ( smartConfigStartMs + rebootDelayMs ) - millis() ) / 1000 );
+        snprintf( remainingSCTime, sizeof( remainingSCTime), "%i seconds", ( (unsigned long)( smartConfigStartMs + rebootDelayMs ) - millis() ) / 1000 );
         OLED.drawString( 64, 30, remainingSCTime );
         OLED.invertDisplay();
         OLED.display();


Set a reconnect handler for when WiFi looses connection.

Better logic in smartConfig code.

Delete wifiTask when done.

--- wifitask.ino
+++ wifitask.ino
@@ -1,12 +1,10 @@
 void wifiTask( void * pvParameters ) {
   /* trying last accesspoint */
-  //WiFi.onEvent( WiFiEvent );
   WiFi.mode( WIFI_STA );
   WiFi.setSleep( false );
+
   if ( wifi_network != "" ) WiFi.begin( wifi_network, wifi_password );
   else WiFi.begin();
-
-  ESP_LOGI( TAG, "Connecting WiFi" );

   if ( xTftTaskHandle ) {
     tft.setTextColor( TFT_TEXT_COLOR , TFT_BACK_COLOR );
@@ -15,7 +13,7 @@

   WiFi.waitForConnectResult();

-  if ( WiFi.status() != WL_CONNECTED ) {
+  if ( WiFi.status() != WL_CONNECTED && ( WiFi.status() != WL_CONNECT_FAILED ) ) {
     if ( xTftTaskHandle ) {
       tft.println( "\nNo WiFi connection.\nWaiting for SmartConfig." );
       tft.invertDisplay( true );
@@ -24,19 +22,18 @@
     WiFi.mode( WIFI_AP_STA );
     WiFi.beginSmartConfig();

-    const unsigned long rebootDelayMs = 60 * 5 * 1000;
+    const time_t DELAY_SECONDS = 60 * 5;
+    const time_t END_TIME = time( NULL ) + DELAY_SECONDS;

-    const unsigned long smartConfigStartMs = millis();
+    ESP_LOGI( TAG, "Waiting %i seconds for SmartConfig.", DELAY_SECONDS );

-    ESP_LOGI( TAG, "Waiting %i seconds for SmartConfig.", rebootDelayMs / 1000 );
-
-    while ( !WiFi.smartConfigDone() && ( (unsigned long)millis() - smartConfigStartMs ) < rebootDelayMs ) {
+    while ( !WiFi.smartConfigDone() && time( NULL ) < END_TIME ) {
       char remainingSCTime[12];
       if ( xOledTaskHandle ) {
         OLED.clear();
         OLED.setFont( ArialMT_Plain_10 );
         OLED.drawString( 64, 10, "Waiting for SmartConfig." );
-        snprintf( remainingSCTime, sizeof( remainingSCTime), "%i seconds", ( (unsigned long)( smartConfigStartMs + rebootDelayMs ) - millis() ) / 1000 );
+        snprintf( remainingSCTime, sizeof( remainingSCTime), "%3.i seconds", END_TIME - time( NULL ) );
         OLED.drawString( 64, 30, remainingSCTime );
         OLED.invertDisplay();
         OLED.display();
@@ -60,7 +57,9 @@

   waitForWifi();

+  WiFi.setAutoReconnect( true );
   /* We have succesfully connected */
+  WiFi.onEvent( WiFiEvent );
   ESP_LOGI( TAG, "WiFi connected to '%s' %s %s",
             WiFi.SSID().c_str(), WiFi.localIP().toString().c_str(), WiFi.macAddress().c_str() );
   if ( xTftTaskHandle ) {
@@ -100,15 +99,17 @@
     webserverTaskPriority,          /* Priority of the task */
     NULL,                           /* Task handle. */
     1);                             /* Core where the task should run */
-
-  while (1) {
-    if ( !WiFi.isConnected() ) {
-      ESP_LOGI( TAG, "No Wifi. Reconnecting.." );
-      WiFi.reconnect();
-      vTaskDelay( 9000 / portTICK_PERIOD_MS );
+  /*
+    while (1) {
+      if ( !WiFi.isConnected() ) {
+        ESP_LOGI( TAG, "No Wifi. Reconnecting.." );
+        WiFi.reconnect();
+        vTaskDelay( 9000 / portTICK_PERIOD_MS );
+      }
+      vTaskDelay( 1000 / portTICK_PERIOD_MS );
     }
-    vTaskDelay( 1000 / portTICK_PERIOD_MS );
-  }
+  */
+  vTaskDelete(NULL);
 }

 /* https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiType.h */
@@ -145,6 +146,7 @@
       break;
     case SYSTEM_EVENT_STA_DISCONNECTED:
       ESP_LOGI( TAG, "STA Disconnected");
+      WiFi.begin();
       break;
     case SYSTEM_EVENT_STA_STOP:
       ESP_LOGI( TAG, "STA Stopped");


Modified serial prints

Modified serial prints

--- sketch_02_dht11_graph/sketch_02_dht11_graph.ino
+++ sketch_02_dht11_graph/sketch_02_dht11_graph.ino
@@ -55,7 +55,8 @@
 /************************ Example Starts Here *******************************/

 // set up the 'graph' feed
-AdafruitIO_Feed * graphFeed = io.feed("graph");
+AdafruitIO_Feed * hiGraphFeed = io.feed("hi");
+AdafruitIO_Feed * kiGraphFeed = io.feed("ki");

 void setup() {
 	// use serial port for printing messages
@@ -95,8 +96,9 @@
 	Serial.print("% ");
 	Serial.print(T, 0);
 	Serial.print((char) 176); // degree symbol
-	Serial.print("C\t");
+	Serial.print("C ");
   Serial.print(V);
+  Serial.print("m/s\t");
      double HI = 0;
      double KI = 0;
   if(T>20){
@@ -114,9 +116,9 @@
   }
 	// save heat index value to the 'graph' feed on Adafruit IO
 	Serial.print("HI = ");
-	Serial.println(HI);
-  Serial.print("KI = ");
+	Serial.print(HI);
+  Serial.print(" KI = ");
   Serial.println(KI);
-	graphFeed->save(HI);
-  graphFeed->save(KI);
+	hiGraphFeed->save(HI);
+  kiGraphFeed->save(KI);
 }


Adjust alarm thresholds to give a more realistic example sketch.

--- examples/OWI/CosaDS18B20alarm/CosaDS18B20alarm.ino
+++ examples/OWI/CosaDS18B20alarm/CosaDS18B20alarm.ino
@@ -98,17 +98,17 @@
   ledPin.toggle();

   indoors.connect(0);
-  indoors.set_trigger(30, 20);
+  indoors.set_trigger(28, 18);
   indoors.write_scratchpad();
   trace << (OWI::Driver&) indoors << endl;

   outdoors.connect(1);
-  outdoors.set_trigger(30, 20);
+  outdoors.set_trigger(35, -10);
   outdoors.write_scratchpad();
   trace << (OWI::Driver&) outdoors << endl;

   basement.connect(2);
-  basement.set_trigger(30, 20);
+  basement.set_trigger(20, 0);
   basement.write_scratchpad();
   trace << (OWI::Driver&) basement << endl;


Fixed prototype signatures

Fixed prototype signatures

--- examples/WeatherStationDemo/WeatherStationDemo.ino
+++ examples/WeatherStationDemo/WeatherStationDemo.ino
@@ -81,13 +81,13 @@
 ThingspeakClient thingspeak;

 // declaring prototypes
-void drawFrame1(int x, int y);
-void drawFrame2(int x, int y);
-void drawFrame3(int x, int y);
-void drawFrame4(int x, int y);
-void drawFrame5(int x, int y);
+bool drawFrame1(SSD1306 *display, SSD1306UiState* state, int x, int y);
+bool drawFrame2(SSD1306 *display, SSD1306UiState* state, int x, int y);
+bool drawFrame3(SSD1306 *display, SSD1306UiState* state, int x, int y);
+bool drawFrame4(SSD1306 *display, SSD1306UiState* state, int x, int y);
+bool drawFrame5(SSD1306 *display, SSD1306UiState* state, int x, int y);
 void setReadyForWeatherUpdate();
-void drawForecast(int x, int y, int dayIndex);
+void drawForecast(SSD1306 *display, int x, int y, int dayIndex);

 // this array keeps function pointers to all frames
 // frames are the single views that slide from right to left


Approximation of a fix for TOF rollover.  PICstop increment problem not addressed yet.

--- TICC/TICC.ino
+++ TICC/TICC.ino
@@ -33,6 +33,8 @@
 long int ti_1;

 unsigned long tmp;
+long tof_rollovers = 0;
+long PICstop_long, tof_long, last_tof_long;

 // BigNumbers seem to need initialized with "1", "0" causes undertermined value.  BigNums are in string form
 BigNumber PICstop = "1";
@@ -89,28 +91,45 @@
     // If the TDC7200 has completed a measurement, INTB will be false.
     // Read and print the registers and computations, then clear the interrupt.
     if(digitalRead(channels[i].INTB)==0) {
-        // copy to tmp for speed
-        tmp = PICCount;
-        // convert long to string, then to bignumber
-        ltoa(tmp, buf, 10);
+
+        // grab this as soon as we can
+        PICstop_long = PICCount;
+
+        // read tof into tmp
+        last_tof_long = tof_long;
+        tof_long = channels[i].read();
+
+        // get ready for next reading
+        channels[i].ready_next(); // Re-arm for next measurement, clear TDC INTB
+
+        // has the TOF rolled over or under?  This depends on PICtick_ps being 1e8  HELP ME!!!
+        if ((tof_long <  4e7L) && (last_tof_long > 6e7L)) {
+          tof_rollovers--;
+        }
+        if ((tof_long >  4e7L) && (last_tof_long < 6e7L)) {
+          tof_rollovers++;
+        }
+
+        PICstop_long += tof_rollovers;
+
+        // convert long to string, then to bignumber and multiply to get ps result
+        ltoa(PICstop_long, buf, 10);
         // calculate the "raw" timestamp as BigNumber
         PICstop = BigNumber(buf) * PICtick_ps;

-        // read tof into tmp
-        tmp = channels[i].read();
+
         //convert long to string
-        ltoa(tmp, buf, 10);
+        ltoa(tof_long, buf, 10);
         // copy into BigNumber
         tof = BigNumber(buf);

-        // get ready for next reading
-        channels[i].ready_next(); // Re-arm for next measurement, clear TDC INTB
+

         // do some math
         tsprev = ts;
         ts = PICstop - tof;
         period = ts - tsprev;
-
+
         printBigNum(tof);
         Serial.print("  ");
         printBigNum(PICstop);


LowpassFilter_FD: improve comments update to myTympan

--- examples/04-FrequencyDomain/LowpassFilter_FD/LowpassFilter_FD.ino
+++ examples/04-FrequencyDomain/LowpassFilter_FD/LowpassFilter_FD.ino
@@ -1,8 +1,9 @@
-// FrequencyDomainDemo1
+// LowpassFilter_FD
 //
-// Demonstrate audio procesing in the frequency domain.
+// Demonstrate audio procesing in the frequency domain through the use of a very simple
+// lowpass filter.
 //
-// Created: Chip Audette  Sept-Oct 2016
+// Created: Chip Audette, Initial 2017
 //
 // Approach:
 //    * Take samples in the time domain
@@ -10,8 +11,6 @@
 //    * Manipulate the frequency bins as desired (LP filter?  BP filter?  Formant shift?)
 //    * Take IFFT to convert back to time domain
 //    * Send samples back to the audio interface
-//
-// Assumes the use of the Audio library from PJRC
 //
 // This example code is in the public domain (MIT License)

@@ -24,12 +23,11 @@
 AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);

 //create audio library objects for handling the audio
-Tympan audioHardware(TympanRev::D); //TympanRev::D or TympanRev::C
-AudioInputI2S_F32         i2s_in(audio_settings);           //Digital audio *from* the Tympan AIC.
-AudioSynthWaveformSine_F32  sinewave(audio_settings);
-AudioEffectLowpassFD_F32  audioEffectLowpassFD(audio_settings);  //create the frequency-domain processing block
-AudioOutputI2S_F32        i2s_out(audio_settings);          //Digital audio *to* the Tympan AIC.
-//AudioOutputUSB_F32        usb_out(audio_settings);
+Tympan                       myTympan(TympanRev::D);     //TympanRev::C or TympanRev::C or TympanRev::E
+AudioInputI2S_F32            i2s_in(audio_settings);           //Digital audio *from* the Tympan AIC.
+AudioSynthWaveformSine_F32   sinewave(audio_settings);
+AudioEffectLowpassFD_F32     audioEffectLowpassFD(audio_settings);  //create the frequency-domain processing block
+AudioOutputI2S_F32           i2s_out(audio_settings);          //Digital audio *to* the Tympan AIC.

 //Make all of the audio connections
 #if 1
@@ -39,49 +37,41 @@
 #endif
 AudioConnection_F32       patchCord12(audioEffectLowpassFD, 0, i2s_out, 0);  //connect the input to the local Freq Domain processor
 AudioConnection_F32       patchCord13(audioEffectLowpassFD, 0, i2s_out, 1);  //connect the Right gain to the Right output
-//AudioConnection_F32       patchCord14(i2s_in, 0, usb_out, 0);  //connect the input to the USB Audio Output
-//AudioConnection_F32       patchCord14(sinewave, 0, usb_out, 0);  //connect the sinewave to the USB Audio Output
-//AudioConnection_F32       patchCord15(audioEffectLowpassFD, 0, usb_out, 1);  //connect processed audio to the USB Audio Output
-
-#define POT_PIN A20  //potentiometer is tied to this pin

 // define the setup() function, the function that is called once when the device is booting
 const float input_gain_dB = 15.0f; //gain on the microphone
 float vol_knob_gain_dB = 0.0;      //will be overridden by volume knob
-int is_windowing_active = 0;
 void setup() {
- //begin the serial comms (for debugging)
-  Serial.begin(115200);  delay(500);
-  Serial.println("FrequencyDomainDemo2: starting setup()...");
+  //begin the serial comms (for debugging)
+  myTympan.beginBothSerial();delay(3000);
+  Serial.println("LowpassFilter_FD: starting setup()...");
   Serial.print("    : sample rate (Hz) = ");  Serial.println(audio_settings.sample_rate_Hz);
   Serial.print("    : block size (samples) = ");  Serial.println(audio_settings.audio_block_samples);

-  // Audio connections require memory to work.  For more
-  // detailed information, see the MemoryAndCpuUsage example
-  AudioMemory(10); AudioMemory_F32(20, audio_settings);
+  // Allocate working memory for audio
+  AudioMemory_F32(20, audio_settings);

   // Configure the frequency-domain algorithm
   int N_FFT = 128;
   audioEffectLowpassFD.setup(audio_settings,N_FFT); //do after AudioMemory_F32();

  //Enable the Tympan to start the audio flowing!
-  audioHardware.enable(); // activate AIC
-  Serial.println("Tympan enabled.");
+  myTympan.enable(); // activate AIC

   //Choose the desired input
-  audioHardware.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones
-  // audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V
-  //  audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF
+  myTympan.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on board microphones
+  // myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V
+  // myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF

   //Set the desired volume levels
-  audioHardware.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
-  audioHardware.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps
+  myTympan.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
+  myTympan.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps

+  //define sine wave properites (if used for debugging)
   sinewave.frequency(1000.0f);
   sinewave.amplitude(0.025f);

   // configure the blue potentiometer
-  pinMode(POT_PIN, INPUT); delay(50);  //set the potentiometer's input pin as an INPUT
   servicePotentiometer(millis(),0);  //update based on the knob setting the "0" is not relevant here.

   Serial.println("Setup complete.");
@@ -114,7 +104,7 @@
   if ((curTime_millis - lastUpdate_millis) > updatePeriod_millis) { //is it time to update the user interface?

     //read potentiometer
-    float val = float(analogRead(POT_PIN)) / 1024.0; //0.0 to 1.0
+    float val = float(myTympan.readPotentiometer()) / 1023.0; //0.0 to 1.0
     val = (1.0/15.0) * (float)((int)(15.0 * val + 0.5)); //quantize so that it doesn't chatter...0 to 1.0

     //send the potentiometer value to your algorithm as a control parameter
@@ -126,7 +116,7 @@
         const float min_val = 0, max_val = 40.0; //set desired range
         float new_value = min_val + (max_val - min_val)*val;
         input_gain_dB = new_value;
-        audioHardware.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps
+        myTympan.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps
         Serial.print("servicePotentiometer: Input Gain (dB) = "); Serial.println(new_value); //print text to Serial port for debugging
       #else
         //use the potentiometer to set the freq-domain low-pass filter


Example: WDRC_8Band_Full: lower volume

Example: WDRC_8Band_Full: lower volume

--- examples/05-FullSystems/WDRC_8BandFIR_full/WDRC_8BandFIR_full.ino
+++ examples/05-FullSystems/WDRC_8BandFIR_full/WDRC_8BandFIR_full.ino
@@ -348,7 +348,7 @@
     //float scaled_val = val / 3.0; scaled_val = scaled_val * scaled_val;
     if (abs(val - prev_val) > 0.05) { //is it different than befor?
       prev_val = val;  //save the value for comparison for the next time around
-      setDigitalGain_dB(val*45.0f - 10.0f,false);
+      setDigitalGain_dB(val*45.0f - 25.0f,false);
       Serial.print("servicePotentiometer: digital gain (dB) = ");Serial.println(myState.digital_gain_dB);
     }
     lastUpdate_millis = curTime_millis;


removed superfulous examples

removed superfulous examples

--- Examples/TLC5955_example/TLC5955_example.ino
+++ Examples/TLC5955_example/TLC5955_example.ino
@@ -1,84 +0,0 @@
-/*
- * TLC5955 Example Program
- * Zack Phillips, zkphil@berkeley.edu
- * Updated 11/16/2015
- */
-
-#include <TLC5955.h>
-#include <SPI.h>
-
-TLC5955 tlc;
-
-#define GSCLK 10 // On Arduino Mega
-#define LAT 44   // On Arduino Mega
-
-// Spi pins are needed to send out control bit (SPI only supports bytes)
-#define SPI_MOSI 11 // 51 on mega, 22 on teensy2.0++
-#define SPI_CLK 13 // 52 on mega, 21 on teensy2.0++
-
-
-void setup() {
-// Now set the GSCKGRB to an output and a 50% PWM duty-cycle
-  // For simplicity all three grayscale clocks are tied to the same pin
-  pinMode(GSCLK, OUTPUT);
-  pinMode(LAT,OUTPUT);
-
-  // Adjust PWM timer (Specific to each microcontroller)
-  //TCCR2B = TCCR2B & 0b11111000 | 0x01;
-
-  // Set up clock pulse
-  analogWrite(GSCLK, 127);
-
-  // The library does not ininiate SPI for you, so as to prevent issues with other SPI libraries
-  SPI.begin();
-
-  // init(GSLAT pin, XBLNK pin, default grayscale values for all LEDS)
-  tlc.init(LAT, SPI_MOSI,SPI_CLK);
-
-  // We must set dot correction values, so set them all to the brightest adjustment
-  tlc.setAllDcData(127);
-
-  // Set Max Current Values (see TLC5955 datasheet)
-  tlc.setMaxCurrent(4,4,4);
-
-  // Set Function Control Data Latch values. See the TLC5955 Datasheet for the purpose of this latch.
-  //tlc.setFunctionData(false, true, true, false, true); // WORKS with fast update
-  tlc.setFunctionData(true, false, false, true, true);   // WORKS generally
-
-  // set all brightness levels to max (127)
-  int currentVal = 127;
-  tlc.setBrightnessCurrent(currentVal,currentVal,currentVal);
-
-  // Update Control Register
-  tlc.updateControl();
-
-  // Update the GS register (ideally LEDs should be dark up to here)
-  tlc.setAllLed(0);
-  tlc.updateLeds();
-}
-
-void loop() {
-  tlc.setAllLed(0);
-  int led=7;
-  int16_t mDelay = 100;
-
-  int16_t dimMax = 60000;
-  int16_t dimDelta = 4000;
-
-  // PWM Dimming
-  for (uint16_t dimVal = 0; dimVal <= dimMax; dimVal += dimDelta)
-  {
-    delay(mDelay);
-    tlc.setAllLed(0);
-    tlc.setLed(led,dimVal,dimVal,dimVal);
-    tlc.updateLeds();
-  }
-
-  for (uint16_t dimVal = dimMax; dimVal >= dimDelta; dimVal -= dimDelta)
-  {
-    delay(mDelay);
-    tlc.setAllLed(0);
-    tlc.setLed(led,dimVal,dimVal,dimVal);
-    tlc.updateLeds();
-  }
-}