autoformatted

autoformatted

--- test_interfaces/test_interfaces.ino
+++ test_interfaces/test_interfaces.ino
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 BFH - Bern University of Applied Sciences, http://bfh.ch
+ * Copyright (C) 2017 BFH - Bern University of Applied Sciences, http://bfh.ch
  * Author: Pascal Mainini <pascal.mainini@bfh.ch>
  *
  * Licensed under MIT license, see included file LICENSE or
@@ -15,80 +15,80 @@
 boolean start = false;

 void setup() {
-    pinMode(pin_btn, INPUT_PULLUP);
-    pinMode(pin_led, OUTPUT);
+  pinMode(pin_btn, INPUT_PULLUP);
+  pinMode(pin_led, OUTPUT);

-    Serial.begin(115200);
-    Serial1.begin(115200);
+  Serial.begin(115200);
+  Serial1.begin(115200);

-    Can0.begin(CAN_BPS_250K);
-    Can1.begin(CAN_BPS_250K);
+  Can0.begin(CAN_BPS_250K);
+  Can1.begin(CAN_BPS_250K);

-    digitalWrite(pin_led, HIGH);
-    delay(2000);
-    digitalWrite(pin_led, LOW);
-    Serial.write("Initialized!\n\r");
+  digitalWrite(pin_led, HIGH);
+  delay(2000);
+  digitalWrite(pin_led, LOW);
+  Serial.write("Initialized!\n\r");
 }

 void loop() {
-    if(digitalRead(pin_btn) == LOW) {
-        start = true;
-        digitalWrite(pin_led, HIGH);
-        delay(500);
-        digitalWrite(pin_led, LOW);
-        delay(200);
-        digitalWrite(pin_led, HIGH);
-        delay(500);
-        digitalWrite(pin_led, LOW);
-        delay(1000);
+  if (digitalRead(pin_btn) == LOW) {
+    start = true;
+    digitalWrite(pin_led, HIGH);
+    delay(500);
+    digitalWrite(pin_led, LOW);
+    delay(200);
+    digitalWrite(pin_led, HIGH);
+    delay(500);
+    digitalWrite(pin_led, LOW);
+    delay(1000);
+  }
+
+  if (start) {
+    CAN_FRAME frame;
+    frame.id = 0x23;
+    frame.length = 8;
+    frame.data.low = 0xEFBEADDE;
+
+    digitalWrite(pin_led, HIGH);
+    delay(200);
+    digitalWrite(pin_led, LOW);
+    Serial.write("Testing Serial1 port...\n\r");
+    if (Serial1.available() > 0) {
+      Serial1.write("Received: ");
+      Serial1.print(Serial1.readString());
+      Serial1.write("\n\r");
+    } else {
+      Serial1.write("Waiting...\n\r");
     }
+    delay(1000);

-    if(start) {
-        CAN_FRAME frame;
-        frame.id = 0x23;
-        frame.length = 8;
-        frame.data.low = 0xEFBEADDE;
+    digitalWrite(pin_led, HIGH);
+    delay(200);
+    digitalWrite(pin_led, LOW);
+    Serial.write("Testing Can0 port...\n\r");
+    frame.data.high = 0x00000000;
+    Can0.sendFrame(frame);
+    Can0.sendFrame(frame);
+    Can0.sendFrame(frame);
+    delay(1000);

-        digitalWrite(pin_led, HIGH);
-        delay(200);
-        digitalWrite(pin_led, LOW);
-        Serial.write("Testing Serial1 port...\n\r");
-        if(Serial1.available() > 0) {
-            Serial1.write("Received: ");
-            Serial1.print(Serial1.readString());
-            Serial1.write("\n\r");
-        } else {
-            Serial1.write("Waiting...\n\r");
-        }
-        delay(1000);
+    digitalWrite(pin_led, HIGH);
+    delay(200);
+    digitalWrite(pin_led, LOW);
+    Serial.write("Testing Can1 port...\n\r");
+    frame.data.high = 0x11111111;
+    Can1.sendFrame(frame);
+    Can1.sendFrame(frame);
+    Can1.sendFrame(frame);
+    delay(1000);

-        digitalWrite(pin_led, HIGH);
-        delay(200);
-        digitalWrite(pin_led, LOW);
-        Serial.write("Testing Can0 port...\n\r");
-        frame.data.high = 0x00000000;
-        Can0.sendFrame(frame);
-        Can0.sendFrame(frame);
-        Can0.sendFrame(frame);
-        delay(1000);
-
-        digitalWrite(pin_led, HIGH);
-        delay(200);
-        digitalWrite(pin_led, LOW);
-        Serial.write("Testing Can1 port...\n\r");
-        frame.data.high = 0x11111111;
-        Can1.sendFrame(frame);
-        Can1.sendFrame(frame);
-        Can1.sendFrame(frame);
-        delay(1000);
-
-        digitalWrite(pin_led, HIGH);
-        delay(500);
-        digitalWrite(pin_led, LOW);
-        delay(200);
-        digitalWrite(pin_led, HIGH);
-        delay(500);
-        digitalWrite(pin_led, LOW);
-        start = false;
-    }
+    digitalWrite(pin_led, HIGH);
+    delay(500);
+    digitalWrite(pin_led, LOW);
+    delay(200);
+    digitalWrite(pin_led, HIGH);
+    delay(500);
+    digitalWrite(pin_led, LOW);
+    start = false;
+  }
 }


Update multiple.ino

Update multiple.ino

--- firmware/examples/multiple.ino
+++ firmware/examples/multiple.ino
@@ -4,15 +4,6 @@
 #define USE_TCS34725
 #define USE_TINKER
 #define USE_TMP006
-
-
-
-
-//
-// GLOBAL VARIABLES
-//
-unsigned long     publishTTL     = 21600;
-

 #ifdef USE_TINKER
@@ -38,6 +29,98 @@
 #ifdef USE_TMP006
     #include "tmp006.h"
 #endif
+
+
+//STRING (maximum string size is 622 bytes)
+unsigned long     publishTTL     = 21600;
+
+
+
+//#define ALL_FUNCTION
+//#define ALL_PUBLISH
+#define ALL_VARIABLE
+char              info_ALL[ 621];
+unsigned long     interval_ALL = 60000;
+unsigned long     lastTime_ALL;
+
+
+int getinfo_ALL(String command) {
+    //char              info_ALLt[ 621];
+    sprintf(info_ALL, "%s", "{");
+
+    #ifdef USE_ADJDS311
+        //sprintf(info_ALL, "\"ADJDS311\":%s", infoS_ADJDS311);
+        strcat(info_ALL, "\"ADJDS311\":");
+        strcat(info_ALL, infoS_ADJDS311);
+        strcat(info_ALL, ",");
+    #endif
+
+    #ifdef USE_BMP085
+        //sprintf(info_ALL, "\"BMP085\":%s,%s", infoS_BMP085, info_ALL);
+        strcat(info_ALL, "\"BMP085\":");
+        strcat(info_ALL, infoS_BMP085);
+        strcat(info_ALL, ",");
+    #endif
+
+    #ifdef USE_TCS34725
+        //sprintf(info_ALLt, "\"TCS34725\": %s, %s\x0", infoS_TCS34725, info_ALLt);
+        strcat(info_ALL, "\"TCS34725\":");
+        strcat(info_ALL, infoS_TCS34725);
+        strcat(info_ALL, ",");
+    #endif
+
+    #ifdef USE_TMP006
+        //sprintf(info_ALLt, "\"TMP006\": %s, %s\x0", infoS_TMP006, info_ALLt);
+        strcat(info_ALL, "\"TMP006\":");
+        strcat(info_ALL, infoS_TMP006);
+        strcat(info_ALL, ",");
+    #endif
+
+    //sprintf(info_ALL, "{%s\"time\": %lu}\x0", info_ALLt, millis());
+
+    //sprintf(info_ALL, "{\"ADJDS311\":%s,\"BMP085\":%s,\"TCS34725\":%s,\"TMP006\":%s,\"time\":%lu}\x0", infoS_ADJDS311, infoS_BMP085, infoS_TCS34725, infoS_TMP006, millis());
+
+    //sprintf(info_ALL , "%s", info_ALLt);
+
+
+    char    t[ 40];
+    sprintf(t, "\"time\":%lu}", millis());
+
+    strcat(info_ALL, t  );
+
+    return 1;
+}
+
+void InitializeApplication_ALL() {
+    #ifdef ALL_VARIABLE
+        Spark.variable( "ALL"   , &info_ALL   , STRING );
+    #endif
+
+    #ifdef ALL_FUNCTION
+        Spark.function( "getALL",  getinfo_ALL         );
+    #endif
+
+    getinfo_ALL("");
+}
+
+void updateinfo_ALL() {
+    if ( (millis()-lastTime_ALL) < interval_ALL ) {
+        return;
+    }
+
+    getinfo_ALL("");
+
+    lastTime_ALL = millis();
+}
+
+void run_ALL() {
+    updateinfo_ALL();
+}
+
+
+
+
+

@@ -66,6 +149,8 @@
     #ifdef USE_TMP006
         InitializeApplication_TMP006();
     #endif
+
+    InitializeApplication_ALL();
 }

 void loop() {
@@ -88,4 +173,6 @@
     #ifdef USE_TMP006
         run_TMP006();
     #endif
+
+    run_ALL();
 }


ミスの修正

ミスの修正

書く場所を間違えた．
機能には問題ない．

--- firmware/IR-station/IR-station.ino
+++ firmware/IR-station/IR-station.ino
@@ -47,8 +47,8 @@
     case IR_STATION_MODE_STA:
       static bool lost = false;
       if ((WiFi.status() != WL_CONNECTED)) {
-        println_dbg("Lost WiFi: " + station.ssid);
         if (lost == false) {
+          println_dbg("Lost WiFi: " + station.ssid);
           WiFi.mode(WIFI_AP_STA);
           delay(1000);
           setupAP(SOFTAP_SSID, SOFTAP_PASS);


final version of the OpenTherm relay

final version of the OpenTherm relay

--- examples/RF12/otRelay/otRelay.ino
+++ examples/RF12/otRelay/otRelay.ino
@@ -2,23 +2,21 @@
 /// Read out the OpenTherm gateway and relay readings using RFM12B.
 /// @see http://jeelabs.org/2012/11/20/opentherm-relay/
 /// @see http://jeelabs.org/2012/11/21/reducing-the-payload-size/
+/// @see http://jeelabs.org/2012/11/22/reducing-the-packet-rate/
 // 2012-11-11 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

 #include <JeeLib.h>

+#define RESEND_COUNT 10   // send each new value out this often
+
 // buffer to collect last data received
 byte lastChars[9], lastFill;

+MilliTimer resendTimer;   // fires once a second
+byte resendCursor;        // cycles over all the history entries
+
 // the last values received, one entry for each ID 0..255
-struct { byte values[2]; } history [256];
-
-static bool shouldSend (const byte* payload) {
-  byte id = payload[0];
-  if (memcmp(payload + 1, history[id].values, 2) == 0)
-    return false;
-  memcpy(history[id].values, payload + 1, 2);
-  return true;
-}
+struct { word value; byte resends; } history [256];

 static byte hex2bin (const byte* hex) {
   byte result = (hex[0] - (hex[0] <= '9' ? 0 : 7)) << 4;
@@ -26,16 +24,29 @@
   return result;
 }

-static void sendMessage () {
-  byte payload [3];
-  payload[0] = hex2bin(lastChars + 3);
-  payload[1] = hex2bin(lastChars + 5);
-  payload[2] = hex2bin(lastChars + 7);
+static void sendId (byte id) {
+  if (history[id].resends > 0) {
+    --history[id].resends;

-  if (shouldSend(payload)) {
+    byte payload [3];
+    payload[0] = id;
+    payload[1] = history[id].value;
+    payload[2] = history[id].value >> 8;
+
     while (!rf12_canSend())
       rf12_recvDone();
     rf12_sendStart(0, payload, sizeof payload);
+  }
+}
+
+static void sendIfChanged () {
+  byte id = hex2bin(lastChars+3);
+  word newval = hex2bin(lastChars+5) + (hex2bin(lastChars+7) << 8);
+
+  if (newval != history[id].value) {
+    history[id].value = newval;
+    history[id].resends = RESEND_COUNT;
+    sendId(id);
   }
 }

@@ -46,7 +57,7 @@
       switch (lastChars[1] & 7) {
         case 1: // Write-Data
         case 4: // Read-Ack
-          sendMessage();
+          sendIfChanged();
       }
   }
 }
@@ -70,4 +81,8 @@
     // done, or invalid: clear the lastChars buffer
     lastFill = 0;
   }
+
+  // periodically check whether the next id needs to be resent
+  if (resendTimer.poll(1000))
+    sendId(++resendCursor);
 }


Remove extraneous heartbeat.

Remove extraneous heartbeat.

--- experimental/arduino101/science-journal-arduino/science-journal-arduino.ino
+++ experimental/arduino101/science-journal-arduino/science-journal-arduino.ino
@@ -101,7 +101,5 @@
 #ifdef GOOSCI_DEVELOPER_MODE
   heartbeat();
 #endif
-
-  heartbeat();
 }


refactor: Rename Ultrasonic on example file

--- examples/UltrasonicSimple/UltrasonicSimple.ino
+++ examples/UltrasonicSimple/UltrasonicSimple.ino
@@ -1,5 +1,5 @@
 /*
- * Ultrassonick Simple
+ * Ultrasonic Simple
  * Print the distance read for the
  * HR-SC04 Ultrasonic Sensor in centimeters.
  *
@@ -17,7 +17,7 @@
  *
  * By default, the distance returned by the distanceRead() method is
  * in centimeters, to get the distance in inches, pass INC as a parameter.
- * Example: ultrasonick.distanceRead(INC)
+ * Example: Ultrasonic.distanceRead(INC)
  *
  * created 3 Apr 2014
  * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
@@ -27,9 +27,9 @@
  * This example code is released into the MIT License.
  */

-#include <Ultrasonick.h>
+#include <Ultrasonic.h>

-Ultrasonick ultrasonick(12, 13);
+Ultrasonic Ultrasonic(12, 13);

 void setup() {
   Serial.begin(9600);
@@ -38,6 +38,6 @@
 void loop() {
   Serial.print("Distance in CM: ");
   // Pass INC as a parameter to get the distance in inches
-  Serial.println(ultrasonick.distanceRead());
+  Serial.println(Ultrasonic.distanceRead());
   delay(1000);
 }


Update ArduCAM_Mini_2MP_Plus_short_movie_clip.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino
@@ -32,7 +32,7 @@
 #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file
 #endif

-#define   FRAMES_NUM    0x07
+#define   FRAMES_NUM    0xFF
 #define   rate     0x0a
 #define SD_CS 9
 #define KEY 2


AdvancedWebServer: remove mDNS from loop as well

--- hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
+++ hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer.ino
@@ -123,7 +123,6 @@
 }

 void loop ( void ) {
-	mdns.update();
 	server.handleClient();
 }


Commit of changes of 11-19-14

Commit of changes of 11-19-14

--- libraries/FreeIMU/examples/FreeIMU_serial_ARM_CPU/FreeIMU_serial_ARM_CPU.ino
+++ libraries/FreeIMU/examples/FreeIMU_serial_ARM_CPU/FreeIMU_serial_ARM_CPU.ino
@@ -39,7 +39,8 @@

 #define HAS_GPS 0
 #define BaudRate 57600
-static const unsigned long GPSBaud = 38400;
+static const unsigned long GPSBaud = 57600;
+#define gpsSerial Serial1

 KalmanFilter kFilters[4];
 int k_index = 3;
@@ -58,7 +59,10 @@
   #include <TinyGPS++.h>
   // The TinyGPS++ object
   TinyGPSPlus gps;
-  // The serial connection to the GPS device
+
+  // Setup GPS Serial and load config from i2c eeprom
+  boolean gpsStatus[] = {false, false, false, false, false, false, false};
+  unsigned long start;
 #endif

 //The command from the PC
@@ -83,8 +87,18 @@
   my3IMU.init(true);

   #if HAS_GPS
-	// For Galileo,DUE and Teensy use Serial port
-    Serial1.begin(GPSBaud);
+	// For Galileo,DUE and Teensy use Serial port 1
+	//Load configuration from i2c eeprom - this assumes you have saved
+	//a default configuration to the eeprom or permanent storage.
+	//If you do not have this setup you will have to remove the
+	//following lines and the additional code at the end of the sketch.
+    gpsSerial.begin(9600);
+	//Settings Array
+	//Code based on http://playground.arduino.cc/UBlox/GPS
+	byte settingsArray[] = {0x04}; // Not really used for this example
+	configureUblox(settingsArray);
+	//Retain this line
+	gpsSerial.begin(GPSBaud);
   #endif

   // LED
@@ -409,8 +423,107 @@
   unsigned long start = millis();
   do
   {
-    while (Serial1.available())
-      gps.encode(Serial1.read());
+    while (gpsSerial.available())
+      gps.encode(gpsSerial.read());
   } while (millis() - start < ms);
   #endif
-}+}
+
+#if HAS_GPS
+
+	void configureUblox(byte *settingsArrayPointer) {
+	byte gpsSetSuccess = 0;
+	//Serial.println("Configuring u-Blox GPS initial state...");
+
+	//Generate the configuration string for loading from i2c eeprom
+	byte setCFG[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x04, 0x1E,
+	0xB4 };
+	calcChecksum(&setCFG[2], sizeof(setCFG) - 4);
+
+	delay(2500);
+
+	gpsSetSuccess = 0;
+	while(gpsSetSuccess < 3) {
+		//Serial.print("Loading permanent configuration... ");
+		sendUBX(&setCFG[0], sizeof(setCFG));  //Send UBX Packet
+		gpsSetSuccess += getUBX_ACK(&setCFG[2]);
+               //Passes Class ID and Message ID to the ACK Receive function
+		if (gpsSetSuccess == 10) gpsStatus[1] = true;
+		if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
+	}
+	if (gpsSetSuccess == 3) Serial.println("Config update failed.");
+	gpsSetSuccess = 0;
+	}
+
+	void calcChecksum(byte *checksumPayload, byte payloadSize) {
+		byte CK_A = 0, CK_B = 0;
+		for (int i = 0; i < payloadSize ;i++) {
+			CK_A = CK_A + *checksumPayload;
+			CK_B = CK_B + CK_A;
+			checksumPayload++;
+		}
+		*checksumPayload = CK_A;
+		checksumPayload++;
+		*checksumPayload = CK_B;
+	}
+
+	void sendUBX(byte *UBXmsg, byte msgLength) {
+		for(int i = 0; i < msgLength; i++) {
+			gpsSerial.write(UBXmsg[i]);
+			gpsSerial.flush();
+		}
+		gpsSerial.println();
+		gpsSerial.flush();
+	}
+
+
+	byte getUBX_ACK(byte *msgID) {
+		byte CK_A = 0, CK_B = 0;
+		byte incoming_char;
+		boolean headerReceived = false;
+		unsigned long ackWait = millis();
+		byte ackPacket[10] = {0xB5, 0x62, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+		int i = 0;
+		while (1) {
+			if (gpsSerial.available()) {
+				incoming_char = gpsSerial.read();
+				if (incoming_char == ackPacket[i]) {
+					i++;
+				}
+			else if (i > 2) {
+				ackPacket[i] = incoming_char;
+				i++;
+			}
+		}
+		if (i > 9) break;
+		if ((millis() - ackWait) > 1500) {
+			//Serial.println("ACK Timeout");
+			return 5;
+			}
+		if (i == 4 && ackPacket[3] == 0x00) {
+			//Serial.println("NAK Received");
+			return 1;
+			}
+		}
+
+		for (i = 2; i < 8 ;i++) {
+			CK_A = CK_A + ackPacket[i];
+			CK_B = CK_B + CK_A;
+		}
+
+		if (msgID[0] == ackPacket[6] && msgID[1] == ackPacket[7] && CK_A == ackPacket[8] && CK_B == ackPacket[9]) {
+			//Serial.println("Success!");
+			//Serial.print("ACK Received! ");
+			//printHex(ackPacket, sizeof(ackPacket));
+			return 10;
+		}
+		else {
+			//Serial.print("ACK Checksum Failure: ");
+			//printHex(ackPacket, sizeof(ackPacket));
+			delay(1000);
+			return 1;
+		}
+	}
+
+#endif


Improving control over backlight intensity

--- examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
+++ examples/LCDKeyPadShieldAndRadioTEA5767Demo/LCDKeyPadShieldAndRadioTEA5767Demo.ino
@@ -74,7 +74,7 @@
   };

 byte searchLevel;
-byte backlightIntensity;
+int backlightIntensity;

 void loadDefaultStations() {
   for (int i=0 ; i < 16 ; i++) {
@@ -143,7 +143,7 @@

 void loadBacklightIntensity() {
   backlightIntensity = EEPROM.read(3);
-  analogWrite(BACKLIGHT_PIN, backlightIntensity);
+  analogWrite(BACKLIGHT_PIN, (byte) backlightIntensity);
 }

 void setupVolume() {
@@ -291,7 +291,7 @@
     //Necessary to elliminate noise while turning the radio back on
     delay(150);
     radio.turnTheSoundBackOn();
-    analogWrite(BACKLIGHT_PIN, backlightIntensity);
+    analogWrite(BACKLIGHT_PIN, (byte) backlightIntensity);

     lcd.clear();
     lcd.setCursor(0,0);
@@ -344,11 +344,12 @@
           }
           // Increment backlight intensity
           case 7: {
-            if ((backlightIntensity + 10) <= 255) {
-              backlightIntensity += 10;
-              analogWrite(BACKLIGHT_PIN, backlightIntensity);
-              EEPROM.write(3, backlightIntensity);
-            }
+            backlightIntensity += 10;
+            if (backlightIntensity > 255) {
+              backlightIntensity = 255;
+            }
+            analogWrite(BACKLIGHT_PIN, (byte) backlightIntensity);
+            EEPROM.write(3, (byte) backlightIntensity);
             break;
           }
         }
@@ -400,11 +401,12 @@
           }
           // Decrement backlight intensity
           case 7: {
-            if ((backlightIntensity - 10) >= 20) {
-              backlightIntensity -= 10;
-              analogWrite(BACKLIGHT_PIN, backlightIntensity);
-              EEPROM.write(3, backlightIntensity);
-            }
+            backlightIntensity -= 10;
+            if (backlightIntensity < 0) {
+              backlightIntensity = 0;
+            }
+            analogWrite(BACKLIGHT_PIN, (byte) backlightIntensity);
+            EEPROM.write(3, (byte) backlightIntensity);
             break;
           }
         }


tests

tests

--- arduino_control/arduino_control.ino
+++ arduino_control/arduino_control.ino
@@ -303,8 +303,7 @@
 }
 void loop() {

-
-  PotRead()
+  PotRead();

   switch (State) {
     case Startup:
@@ -315,7 +314,7 @@
       break;
     case Operational:
       PositionSetpoint();
-      DataRead();
+//      DataRead();
       break;
   }
 }


Corrected subscriber topics for conveyor and winch commands.

--- src/SabertoothDriverROS/SabertoothDriverROS.ino
+++ src/SabertoothDriverROS/SabertoothDriverROS.ino
@@ -205,9 +205,9 @@

 ros::Subscriber<command2ros::ManualCommand> setActualArticulationSubscriber("SetActualArticulationValues", &setActualArticulationValues);

-ros::Subscriber<std_msgs::Int16> conveyorSubscriber("ConveyorCommand", &newConveyorCommandCallback);
-
-ros::Subscriber<std_msgs::Int16> winchSubscriber("ConveyorCommand", &newWinchCommandCallback);
+ros::Subscriber<std_msgs::Int16> conveyorSubscriber("TransportConveyorCommand", &newConveyorCommandCallback);
+
+ros::Subscriber<std_msgs::Int16> winchSubscriber("TransportWinchCommand", &newWinchCommandCallback);

 // Print error message to "sabertooth_debugger" topic
@@ -906,7 +906,7 @@
       stopMovementMotors();
     }
   }
-
+
   pubwheelStatus.publish(&wheelStatus);// current rotation data for each wheel.

   //Sync with ROS


examples/stream: fix error handling

examples/stream: fix error handling

--- examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
+++ examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
@@ -48,7 +48,7 @@

 void loop() {
-  if (!stream.error()) {
+  if (stream.error()) {
     Serial.println("streaming error");
     Serial.println(stream.error().message());
   }


fix comments in main file.

fix comments in main file.

--- examples/ESP-DMXRGB/ESP-DMXRGB.ino
+++ examples/ESP-DMXRGB/ESP-DMXRGB.ino
@@ -1,28 +1,25 @@
 /**************************************************************************/
 /*!
-    @file     ESP-DMXNeoPixels.ino
+    @file     ESP-DMXRGB.ino
     @author   Claude Heintz
     @license  BSD (see LXDMXWiFi.h)
-    @copyright 2016-2021 by Claude Heintz All Rights Reserved
+    @copyright 2021 by Claude Heintz All Rights Reserved

     Example using LXDMXWiFi_Library for output of Art-Net or E1.31 sACN from
-    ESP8266 Adafruit Huzzah WiFi connection to an Adafruit NeoPixel Ring.
+    ESP8266 Adafruit Huzzah WiFi connection to 3 PWM Pins that could be used
+    for an RGB LED.

     Art-Net(TM) Designed by and Copyright Artistic Licence Holdings Ltd.
     sACN E 1.31 is a public standard published by the PLASA technical standards program
-
-    NOTE:  This example requires the Adafruit NeoPixel Library and WiFi101 Library
-
-           Remote config is supported using the configuration utility in the examples folder.
-           Otherwise edit initConfig() in LXDMXWiFiConfig.cpp.
+
+
+           Remote config is supported using the configuration utility in the examples
+           folder.  See the notes about enable/disable remote config below.
+           Edit initConfig() in LXDMXWiFiConfig.cpp if not using remote config.

     @section  HISTORY

     v1.0 - First release
-    v1.1 - Add USE_REMOTE_CONFIG option
-    v1.2 - Refactor order of utility functions in main sketch,
-           move WiFi connection setup to LXDMXWiFiConfig
-           move checkConfigReceived to LXDMXWiFiConfig

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


Added comments

Added comments

--- examples/SimpleList/SimpleList.ino
+++ examples/SimpleList/SimpleList.ino
@@ -10,27 +10,26 @@

 */
 #include "QList.h"
-// Need to be for unknown reason
-#include "QList.cpp"
 QList<String> myList;
 void setup()
 {
   Serial.begin(9600);
-  myList.push_back("First");
+  myList.push_back("First"); // Add item at the back of the line
   myList.push_back("Second");
-  myList.push_front("New first");
+  myList.push_front("New first"); // Ad item at the front of the line
+  Serial.println("Items:");
+  // Go through items
+  for(int i=0;i<myList.size();i++)
+  {
+    Serial.println(myList.at(i));
+  }
+  myList.pop_back(); // Remove item at the back of the line
   Serial.println("Items:");
   for(int i=0;i<myList.size();i++)
   {
     Serial.println(myList.at(i));
   }
-  myList.pop_back();
-  Serial.println("Items:");
-  for(int i=0;i<myList.size();i++)
-  {
-    Serial.println(myList.at(i));
-  }
-  myList.clear();
+  myList.clear(); // Clear all items in table
 }
 void loop()
 {


Updated example.

Updated example.

--- examples/DemoArcRPM/DemoArcRPM.ino
+++ examples/DemoArcRPM/DemoArcRPM.ino
@@ -11,12 +11,12 @@
 #include "RPMWS2812.h"

 #define SERIAL_BAUD_RATE 115200
-#define STARTING_BRIGHTNESS 150 //Out of 255
+#define STARTING_BRIGHTNESS 100 //Out of 255

 #define ANIMATION_STEPS 6000
-#define DEMO_RPM_RANGE 19000
-
-#define ANIMATION_DURATION 12000
+#define DEMO_RPM_RANGE 18000
+
+#define ANIMATION_DURATION 15000
 #define ANIMATION_UPDATE_INTERVAL 5
 #define DEMO_RPM_UPDATE_INTERVAL  5
 #define DEMO_LED_UPDATE_INTERVAL 100
@@ -33,13 +33,16 @@
 #define MAX_RPM 15000

 #define ALERT_PULSE_MILLIS 110
-#define ALERT_PULSE_DUTY_CYCLE 160
+#define ALERT_PULSE_DUTY_CYCLE 127
 #define ALERT_MIN_BRIGHTNESS 60
+
+#define DEAD_COLOR cHSV(225, 255, 255)
+#define DEAD_PULSE_DURATION 1000

 #define LOW_COLOUR cHSV(240, 255, 255)
 #define MEDIUM_COLOUR cHSV(100, 255, 255)
 #define HIGH_COLOUR cHSV(120, 255, 255)
-#define BACKGROUND_COLOUR cHSV(240, 255, 5)
+#define BACKGROUND_COLOUR cHSV(240, 0, 0)
 #define LED_MIN_BRIGHTNESS_VALUE 20

@@ -180,19 +183,20 @@
 	Success = RPMDriver.Begin();
 	RPMDriver.SetDesignModel(SUB_PIXEL_ENABLED | BACKGROUND_ENABLED);// | SUB_PIXEL_HIGH_RANGE_ENABLED | BACKGROUND_ENABLED);
 	RPMDriver.SetBrightness(GlobalBrightness);
-	RPMDriver.SetRangeRPM(600, 15000);
+	RPMDriver.SetRangeRPM(900, 15000);
 	RPMDriver.ClearSections();

 	RPMDriver.SetAlertBlink(HIGH_COLOUR, ALERT_PULSE_MILLIS, ALERT_PULSE_DUTY_CYCLE);
-
+	RPMDriver.SetDeadBlink(DEAD_COLOR, DEAD_PULSE_DURATION);
 	//RPMDriver.SetExtendedOverflowRange(constrain(GlobalBrightness + 50, 0, 255));

 	RPMDriver.SetSection(0, MEDIUM_RPM / 2, LOW_COLOUR, BACKGROUND_COLOUR);
-	RPMDriver.SetSection(MEDIUM_RPM / 2, MEDIUM_RPM, cHSV(300, 254, 254), BACKGROUND_COLOUR);
-	RPMDriver.SetSection(MEDIUM_RPM, HIGH_RPM, MEDIUM_COLOUR, BACKGROUND_COLOUR);
-	RPMDriver.SetSection(HIGH_RPM, MAX_RPM, HIGH_COLOUR, BACKGROUND_COLOUR);//, { 120,255,1 }
+	RPMDriver.SetSection(MEDIUM_RPM / 2, MEDIUM_RPM, cHSV(300, 255, 200), BACKGROUND_COLOUR);
+	RPMDriver.SetSection(MEDIUM_RPM, HIGH_RPM, MEDIUM_COLOUR, cHSV(100, 255, 22));
+	RPMDriver.SetSection(HIGH_RPM, MAX_RPM, HIGH_COLOUR, cHSV(120, 255, 10));//, { 120,255,1 }
 	RPMDriver.BootAnimation(LOW_COLOUR);

+	return Success;
 }

 void loop()


remove debugging code

remove debugging code

--- examples/quadcopter/quadcopter.ino
+++ examples/quadcopter/quadcopter.ino
@@ -169,7 +169,6 @@
                 /* implied prStickCentered == true, gpsAssist == true */
                 gpsStabilization = true;
                 positionHold.setTarget(gps.getLocation());
-                comms.sendString("gps");
             }

             // calculate gps stabilization corrections


Update BotBoarduino_LIDAR_Lite_Sweep_Scan.ino

--- BotBoarduino/BotBoarduino_LIDAR_Lite_Sweep_Scan/BotBoarduino_LIDAR_Lite_Sweep_Scan.ino
+++ BotBoarduino/BotBoarduino_LIDAR_Lite_Sweep_Scan/BotBoarduino_LIDAR_Lite_Sweep_Scan.ino
@@ -1,5 +1,5 @@
 /***********************************************************************************************************
-/* BotBoarduino LIDAR Lite Sweep Scan
+/* Lynxmotion BotBoarduino LIDAR Lite Sweep Scan
 /* Version: 1.0.0
 /* By: scharette
 /* Date: 2015-03-31


stable version but consuming too much battery

--- test_configSIM808.ino
+++ test_configSIM808.ino
@@ -1,5 +1,6 @@
-#define DEBUG 1
-#define PROTOCOL 2 //1 = TCP and 2 = UDP
+//#define DEBUG 1
+#define NO_NETLIGHT 1   //turn on or off netlight of sim808 board
+#define PROTOCOL 2   //1 = TCP and 2 = UDP

 #ifdef PROTOCOL
   static int const prot = PROTOCOL;
@@ -10,6 +11,12 @@
 /*******************************
  * Definition of error codes
  *******************************/
+#define CIPSHUT_FAIL 1
+#define IPR9600_FAIL 2
+#define CSTT_UNINET_FAIL 3
+#define CIICR_FAIL 4
+#define CDNSGIP_FAIL 5
+
 #define NO_GPRS_SIGNAL 20
 #define DNS_ERROR 21
 #define PDP_DEACT 22
@@ -20,7 +27,6 @@
 #define MESSAGE_LENGTH 30
 //#define MESSAGE_LENGTH 160
 char message[MESSAGE_LENGTH];
-int messageIndex = 0;

 char phone[16];
 char datetime[24];
@@ -42,7 +48,7 @@
 DFRobot_SIM808 sim808(&GPRS);
 SimpleTimer timer;

-char* key;
+//char* key;
 //All this char variable have reserved one extra char to insert \0 at end
 char gpsMode[4]="000";
 char dateTime[11]="000000.000";
@@ -58,7 +64,7 @@
 int previousRadioSig = 0;

-byte pos = 0;  //WHAT POSITION WE ARE AT IN THAT BUFFER
+//byte pos = 0;  //WHAT POSITION WE ARE AT IN THAT BUFFER
 //my variables MKY
 //const int BUFFER_SIZE = 110;
 const int BUFFER_SIZE = 90;
@@ -77,11 +83,17 @@
  *******************************************************************************************/
 void setup()
 {
+  //turn off led of Uno
+  pinMode(LED_BUILTIN, OUTPUT);
+  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
+
   GPRS.begin(9600);   //Set Uno serial connection with SIM808
   Serial.begin(9600); //Set Uno serial connection with Arduino IDE

   sim808_init(&GPRS,9600);

+
+  //delay(20000); //test to see if this reduce the drain of current of batery

   sim808_check_with_cmd("AT+CPOWD=1","OK\r\n",CMD);
   //delay(5000);
@@ -116,10 +128,10 @@

   //GSM and GPRS configuration
   //check which network GPRS module is connected with
-  GPRS.println("AT+COPS?");
+  //GPRS.println("AT+COPS?");

   //check if mobile number is register in the network
-  GPRS.println("AT+CREG=?");
+  //GPRS.println("AT+CREG=?");

   /*******************************************************
    * configuration of GPRS data
@@ -138,9 +150,9 @@
   //SerialSim808_Read();
   delay(50);

-  GPRS.println("AT+CGPSSTATUS?");
-  // SerialSim808_Read();
-  delay(50);
+//  GPRS.println("AT+CGPSSTATUS?");
+//  // SerialSim808_Read();
+//  delay(50);

   /*************************************************
    * Special config for SMS and voice call
@@ -162,9 +174,14 @@

   sim808_check_with_cmd("AT+CLIP=1\r\n","OK\r\n",CMD);
   delay(25);
+
+  //turn off netlight of sim808
+  #ifdef NO_NETLIGHT
+    sim808_send_cmd("AT+CNETLIGHT=0\r\n");
+  #endif

   timer.setInterval(60000, GetGPSLocation);
-  timer.setInterval(1000, PrintSecondsElapsed);
+  //timer.setInterval(1000, PrintSecondsElapsed);
 }

@@ -191,8 +208,8 @@
   //Receiving call
   if(sim808.readable()){
     sim808_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
-    Serial.print("LoopBuf:");
-    Serial.println(gprsBuffer);
+    //Serial.print("LoopBuf:");
+    //Serial.println(gprsBuffer);

     //**** Detect the current state of the telephone or SMS ****************
     if(NULL != strstr(gprsBuffer,"RING")) {
@@ -215,33 +232,33 @@

   //Receive SMS message
-  if(NULL != (s = strstr(gprsBuffer,"+CMTI: \"SM\""))) { //SMS: $$+CMTI: "SM",24$$
-    sim808_clean_buffer(gprsBuffer,32);
-    createSMSMessage(smsMessage,latitude, longitude, MSL_altitude, Speed);
-    if(!sim808_check_with_cmd("AT+CMGF=1\r\n","OK\r\n",CMD)){ //Set SMS for text mode not HEX when read it
-      delay(1); //Serial.println("fail CMGF");
-    }else {
-      delay(1);//Serial.println("ok CMGF");
-    }
-    delay(25);
-
-    GPRS.println("AT+CMGR=1");
-    sim808_read_buffer(gprsBuffer,64,DEFAULT_TIMEOUT);
-    //Serial.print(gprsBuffer);
-
-    if(!sim808_check_with_cmd("AT+CMGDA=\"DEL ALL\"\r\n","OK\r\n",CMD)){ //delete all SMS
-      delay(1);//Serial.println("fail del SMS");
-    }else {
-      delay(1);//Serial.println("ok del SMS");
-    }
-
-
-    if(extractCallingNumberSMS(gprsBuffer)){
-      sim808.sendSMS(phone,smsMessage);
-    }else{
-      Serial.println("No valid # for SMS");
-    }
-  }
+//  if(NULL != (s = strstr(gprsBuffer,"+CMTI: \"SM\""))) { //SMS: $$+CMTI: "SM",24$$
+//    sim808_clean_buffer(gprsBuffer,32);
+//    createSMSMessage(smsMessage,latitude, longitude, MSL_altitude, Speed);
+//    if(!sim808_check_with_cmd("AT+CMGF=1\r\n","OK\r\n",CMD)){ //Set SMS for text mode not HEX when read it
+//      delay(1); //Serial.println("fail CMGF");
+//    }else {
+//      delay(1);//Serial.println("ok CMGF");
+//    }
+//    delay(25);
+//
+//    GPRS.println("AT+CMGR=1");
+//    sim808_read_buffer(gprsBuffer,64,DEFAULT_TIMEOUT);
+//    //Serial.print(gprsBuffer);
+//
+//    if(!sim808_check_with_cmd("AT+CMGDA=\"DEL ALL\"\r\n","OK\r\n",CMD)){ //delete all SMS
+//      delay(1);//Serial.println("fail del SMS");
+//    }else {
+//      delay(1);//Serial.println("ok del SMS");
+//    }
+//
+//
+//    if(extractCallingNumberSMS(gprsBuffer)){
+//      sim808.sendSMS(phone,smsMessage);
+//    }else{
+//      Serial.println("No valid # for SMS");
+//    }
+//  }

@@ -287,7 +304,7 @@
     ************************************/

    if(!sim808_check_with_cmd("AT+CIPSHUT\r\n","OK\r\n",CMD)){
-    error = 1;
+    error = CIPSHUT_FAIL;
    }
    delay(50);

@@ -297,7 +314,7 @@
    *OK
    ***********************************/
    if(!sim808_check_with_cmd("AT+IPR=9600\r\n","OK\r\n",CMD)){
-    error = 2;
+    error = IPR9600_FAIL;
    }
    delay(50);

@@ -308,7 +325,7 @@
    *OK
    ******************************************/
   if(!sim808_check_with_cmd("AT+CSTT=\"UNINET\"\r\n","OK\r\n",CMD)){
-    error = 3;
+    error = CSTT_UNINET_FAIL;
   }
   delay(50);

@@ -318,7 +335,7 @@
    *OK
    *******************************************/
   if(!sim808_check_with_cmd("AT+CIICR\r\n","OK\r\n",CMD)){
-    error = 4;
+    error = CIICR_FAIL;
   }
   delay(50);

@@ -337,7 +354,7 @@
    *+CDNSGIP: 1,"ardugps.hopto.org","58.100.82.70"
    *******************************************/
   if(!sim808_check_with_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n","OK\r\n",CMD)){
-    error =5;
+    error = CDNSGIP_FAIL;
   }
   delay(50);
   return error;
@@ -360,7 +377,7 @@

    /* get the first token */
    //Serial.println("valor do buffer :");
-   Serial.println(inMessage);
+   //Serial.println(inMessage);

    if(NULL == strstr(inMessage,"+CLIP")){
      return false;
@@ -381,7 +398,7 @@
       phone[sizeof(phone)-1] = '\0';

       //strcpy(gpsMode,token);
-      Serial.print("phone: ");
+      Serial.print("ph#: ");
       Serial.println(phone);
    }else return false;

@@ -406,7 +423,7 @@

    /* get the first token */
    //Serial.println("valor do buffer :");
-   Serial.println(inMessage);
+   //Serial.println(inMessage);

    if(NULL == strstr(inMessage,"+CMGR")){
      return false;
@@ -441,7 +458,7 @@

       //strcpy(gpsMode,token);
-      Serial.print("phone: ");
+      Serial.print("ph#: ");
       Serial.println(phone);
    }else return false;

@@ -590,11 +607,6 @@
  ******************************************************************************************/

 int SendGPSLocation(){
-  //char latitude[10]="0000.0000";
-  //char longitude[11]="00000.00000";
-  //char MSL_altitude[8]="00000.0";
-  //char Speed[8]="000.000";
-  //char data2db[21]="0000.0000,00000.0000";  //"latitude,longitude"
   char data2db[36]="0000.0000,00000.0000,00000.0,000.000"; //"latitude,longitude,MSL_altitude,Speed"
   byte error;
   int signalStrenght;
@@ -609,123 +621,51 @@
   if(sim808.readable()) {
     sim808_read_buffer(gprsBuffer,24,DEFAULT_TIMEOUT);
     currentRadioSig = getSignalQuality(gprsBuffer);
-    Serial.print("signal:");
+    Serial.print("sig:");
     Serial.println(currentRadioSig);
   }
   sim808_clean_buffer(gprsBuffer,64);

-
-
+
+/*******************************************************************
+ * previousRadioSignal currentRadioSignal
+ * 0                   0                  nao faz nada e sai
+ * 1                   0                  nao faz nada e sai
+ * 0                   1                  initGPRS e send data
+ * 1                   1                  nao faz nada e send data
+ *******************************************************************/
   sim808_send_cmd("AT+CIPSTATUS\r\n");
-  //delay(50);
   if(sim808.readable()) {
     sim808_read_buffer(gprsBuffer,64,DEFAULT_TIMEOUT);
     //Serial.print(gprsBuffer);
-
-    //previousRadioSignal currentRadioSignal
-    // 0                   0                  nao faz nada e sai
-    // 1                   0                  nao faz nada e sai
-    // 0                   1                  initGPRS e send data
-    // 1                   1                  nao faz nada e send data
-
-
     if(currentRadioSig <= 7) {
          Serial.println("NOGPRSsig");
          sim808_send_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n");
          previousRadioSig = currentRadioSig;
-         return 20;  //error of weak signal or DNS failed
-    }else{ //radio signal > 7
+         return NO_GPRS_SIGNAL;            //error of weak signal or DNS failed
+    }else{                                 //radio signal > 7
       if(previousRadioSig > 7){            //signal still good
         previousRadioSig = currentRadioSig;
       }else {                              //signal recovered
         error = InitGPRS();
         previousRadioSig = currentRadioSig;
         if(error > 0) { //initGPRS failed
-          Serial.print("GPRS fail: ");
+          Serial.print("GPRSfail: ");
           Serial.println(error);
           return error;
         }
-          Serial.print("GPRS INIT_OK");
+          Serial.println("GprsInitOK");
       }
     }
   }
-
-
-
-
-
-//  sim808_send_cmd("AT+CIPSTATUS\r\n");
-//  //delay(50);
-//  if(sim808.readable()) {
-//    sim808_read_buffer(gprsBuffer,64,DEFAULT_TIMEOUT);
-//    //Serial.print(gprsBuffer);
-//
-//    if(strstr(gprsBuffer,"CONNECT OK")) {
-//       //Serial.println("GPRS UP");
-//       if(sim808_check_with_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n","ERROR\r\n",CMD)){
-//         Serial.println("NOGPRSsig");
-//         return 20;  //error of weak signal or DNS failed
-//       }
-//       //DNS_OK false if receive "CDNSGIP: 0,8"
-//       //currentRadioSig<7 signal is too weak to transmit data
-//       if((!DNS_OK)||(currentRadioSig<7)){
-//         Serial.println("NOGPRSsig");
-//         return 20;  //error of weak signal or DNS failed
-//       }
-//       //}
-//    }else{
-//      //Serial.println("gprsNotConn");
-//      error = InitGPRS();
-//      if(error > 0) { //initGPRS failed
-//        //Serial.print("GPRS fail: ");
-//        //Serial.println(error);
-//        return error;
-//      }
-//      else{
-//        //Serial.print("InitGPRS() successful");
-//        DNS_OK = true;
-//      }
-//     }
-//  }
-//  sim808_clean_buffer(gprsBuffer,64);
-
-
-
-
-
-
-
-
-
-
-
-
-
-

   //get the local ip number
   //GPRS.println("AT+CIFSR");
   sim808_send_cmd("AT+CIFSR\r\n");
-
-  //Get the remote IP address
-  //GPRS.println("AT+CDNSGIP=\"ardugps.hopto.org\"");
-//  if(!sim808_check_with_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n","OK\r\n",CMD)){
-//    delay(1);
-//    Serial.println("AT+CDNSGIP => FAIL");
-//  }else {
-//    delay(1);
-//    Serial.println("AT+CDNSGIP => OK");
-//  }
-//  //delay(1000);
-//  delay(100);
+  sim808_send_cmd("AT+CDNSGIP=\"ardugps.hopto.org\"\r\n");

   //start a connection to TCP to URL and port
-  /*if(!sim808_check_with_cmd("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789\r\n","OK\r\n",CMD)){
-    Serial.println("AT+CIPSTART => FAIL");
-  }else Serial.println("AT+CIPSTART => OK");
-  delay(1000);*/
-
   if (prot == TCP){
     if(!SendCIPSTART(TCP)){
       delay(1);
@@ -765,12 +705,6 @@

   if(!SendDataCIPSEND(data2db,sizeof(data2db))){
-    //Serial.println("CIPSEND => FAIL");
-    //Try to resend
-    /*if(!sim808_check_with_cmd("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789\r\n","OK\r\n",CMD)){
-      Serial.println("AT+CIPSTART => FAIL");
-    }else Serial.println("AT+CIPSTART => OK");*/
-
     if(prot == TCP){
       if(!SendCIPSTART(TCP)){
         delay(1);
@@ -797,15 +731,11 @@

   delay(50);

-  if (!CheckConnectionStatus()) {
-    //Serial.println("Uno was already disconnected from Server");
-    delay(1);
-  }
-  else{
+  if (CheckConnectionStatus()) {
     sim808_check_with_cmd("AT+CIPCLOSE\r\n", "CLOSE OK\r\n", CMD);
     //Serial.println("Uno have disconnected from Server");
   }
-  //delay(3000);
+
   return 0; // no error on GPRS

 }//end procedure


long and short button press

long and short button press

--- _64-esp8266-atmega328p-i2c8x8-mma-8452-dash-button/a-02-atmega328p/a-02-atmega328p.ino
+++ _64-esp8266-atmega328p-i2c8x8-mma-8452-dash-button/a-02-atmega328p/a-02-atmega328p.ino
@@ -129,15 +129,30 @@
 void loop() {
   goingSleep();
   turn_on_8x8();
-  delay(200);
   reset_esp();

   while (1) {
     if (bbutton_isr) {
       Serial.println("Button pressed....");
-      pir_interuptCount++;
+
+      while (!digitalRead(BUTTON_INT)) {
+        if ((millis() - startMiils) > 500) {
+          break;
+        }
+      }
+
+      if ((millis() - startMiils) < 500) {
+        pir_interuptCount = 1;
+      } else {
+        pir_interuptCount = 2;
+      }
+
       device_data_helper();
       bbutton_isr = false;
+
+      Serial.print("millis : ");
+      Serial.println(millis() - startMiils);
+
       Serial.print("Button : ");
       Serial.println(pir_interuptCount);
     }


Can now load frames and color stops from EEPROM

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -27,8 +27,8 @@
 #endif

 struct Frame {
+  uint16_t transitionTime;
   uint16_t pauseTime;
-  uint16_t transitionTime;
   uint8_t colorStopCount;

 };
@@ -41,9 +41,10 @@

 };

-Adafruit_NeoPixel* strip;
-struct Frame* currentFrame;
-struct ColorStops** colorStops;
+Adafruit_NeoPixel* strip       = NULL;
+struct Frame* currentFrame     = NULL;
+struct ColorStop** colorStops = NULL;
+uint8_t currentFrameIndex = 0;

 void setup() {
   //Beginn Serial Communication
@@ -82,8 +83,12 @@
   }

   //show the gradient
+  strip->setBrightness(64);
   strip->show();

+  //Load current profile
+  applyProfile();
+
   //Tell host boot is complete
   sendDone();

@@ -91,6 +96,99 @@

 void loop() {

+}
+
+void applyProfile() {
+  currentFrameIndex = 0;
+  loadFrame(currentFrameIndex);
+
+}
+
+void loadFrame(uint8_t index) {
+  uint8_t i;
+
+  //Create a Frame struct if not allocated
+  if(currentFrame == NULL) {
+    currentFrame = (struct Frame*) malloc(sizeof(struct Frame));
+    currentFrame->transitionTime = 0;
+    currentFrame->pauseTime =      0;
+    currentFrame->colorStopCount = 0;
+
+  }
+
+  uint8_t availableColorStops = currentFrame->colorStopCount;
+
+  //Init Frame address with the porfile start
+  uint16_t frameAddress = EEPROM_CURRENT_PROFILE_START;
+
+  //Iterate over all Frames until the desired one
+  for(i=0; i<index; i++) {
+    //Read how many ColorStops the Frame contains and multiply it by the size of one ColorStop, add it to Address
+    frameAddress += EEPROM.read(frameAddress + 4) * sizeof(struct ColorStop);
+    //Add the size of one frameAddress
+    frameAddress += sizeof(struct Frame);
+    //Now frameAddress is the address of the next Frame
+
+  }
+
+  //frameAddress is now the address of the desired Frame
+  //Read the values
+  currentFrame->transitionTime = EEPROM.readInt(frameAddress);
+  currentFrame->pauseTime =      EEPROM.readInt(frameAddress+2);
+  currentFrame->colorStopCount = EEPROM.read(frameAddress+4);
+
+  /*
+  Serial.print("colorStopCount: ");
+  Serial.println(currentFrame->colorStopCount);
+  Serial.print("transitionTime: ");
+  Serial.println(currentFrame->transitionTime);
+  Serial.print("pauseTime: ");
+  Serial.println(currentFrame->pauseTime);
+  Serial.print("availableColorStops: ");
+  Serial.println(availableColorStops);
+  */
+
+  //free all ColorStops
+  for(i=0; i<availableColorStops; i++) {
+    free(colorStops[i]);
+
+  }
+
+  //free colorStops and allocate new
+  free(colorStops);
+  colorStops = (ColorStop**) malloc(sizeof(struct ColorStop*) * currentFrame->colorStopCount);
+
+  //Serial.println("ColorStops: ");
+
+  //Load ColorStops
+  for(i=0; i<currentFrame->colorStopCount; i++) {
+    colorStops[i] = (ColorStop*) malloc(sizeof(struct ColorStop));
+    loadColorStop(i, frameAddress, colorStops[i]);
+
+    /*
+    Serial.println(i);
+    Serial.print("  ledIndex: ");
+    Serial.println(colorStops[i]->ledIndex);
+    Serial.print("  r: ");
+    Serial.println(colorStops[i]->r);
+    Serial.print("  g: ");
+    Serial.println(colorStops[i]->g);
+    Serial.print("  b: ");
+    Serial.println(colorStops[i]->b);
+    */
+
+  }
+}
+
+void loadColorStop(uint8_t index, uint16_t eepromFrameAddress, struct ColorStop* colorStop) {
+  eepromFrameAddress += sizeof(struct Frame);
+  eepromFrameAddress += sizeof(struct ColorStop) * index;
+
+  colorStop->ledIndex = EEPROM.readInt(eepromFrameAddress);
+  colorStop->r = EEPROM.readInt(eepromFrameAddress+2);
+  colorStop->g = EEPROM.readInt(eepromFrameAddress+3);
+  colorStop->b = EEPROM.readInt(eepromFrameAddress+4);
+
 }

 /*


Update motor_3.ino

Update motor_3.ino

--- arduino/motor_3.ino
+++ arduino/motor_3.ino
@@ -41,10 +41,7 @@
  }
 void loop()
 {
-            Serial.print("got: ");
-	    Serial.println(angle);
-	    if(angle > 127) digitalWrite(13, HIGH);
-	   else digitalWrite(13, LOW);
+
                  Errorcalc();
                 if (abs(Error) <.8){ // prevent integral 'windup'
                 Integral = Integral + Error; // accumulate the error integral
@@ -98,4 +95,9 @@
 {
   int x = Wire.read();
   angle = (double) x;
+
+  Serial.print("got: ");
+  Serial.println(angle);
+  if(angle == 40) digitalWrite(13, HIGH);
+  else digitalWrite(13, LOW);
 }


Implement bargraph code for seconds.

Implement bargraph code for seconds.

--- NTPclock/NTPclock.ino
+++ NTPclock/NTPclock.ino
@@ -54,40 +54,24 @@

   Serial.println(timeDisplay);

-  time_t nowTime = now(); // store the current time in time variable t
-  hour(nowTime);             // returns the hour for the given time t
-  minute(nowTime);           // returns the minute for the given time t
-  second(nowTime);           // returns the second for the given time t
-  day(nowTime);              // the day for the given time t
-  weekday(nowTime);          // day of the week for the given time t
-  month(nowTime);            // the month for the given time t
-  year(nowTime);             // the year for the given time t
+  time_t nowTime = now();            //store the current time in time variable t
+  int portion = second(nowTime) / 6; //get the number of bars that should be lit
+  setBar(portion);                   //and then set them

   delay(1000);         //TODO:   REMOVE DELAY FOR A COUNTER..............................PLEASE!!!!......../////////////////////////
 }

 // Controlls a 10-segment LED bargraph
-// int bars: 0-10
+// int bars: 0-10 number of bars that should be on
 void setBar(int bars) {
+  boolean segments[10] = {false, false, false, false, false, false, false, false, false, false};
+  for (int i = 0; i<bars; i++) {   //set true up to the number of bars
+    segments[i] = true;
+  }

-
-  for (int i=0; i<10; i++) {
-
-  }
-
-  switch(c) {
-  case 0:
-    lc.setLed(0,r,e,state);
-    break;
-
-  case 1:
-    lc.setLed(0,r+4,e,state);
-    break;
-
-  case 2:
-    lc.setLed(0,r,e,state);
-    lc.setLed(0,r+4,e,state);
-    break;
+  for (int i=0; i<5; i++) {        //Set the LEDs
+    lc1.setLed(0,4,segments[i]);     //0-4
+    lc1.setLed(0,5,i,segments[i+5]); //5-9
   }
 }


Delete BatReader_Example.ino

Delete BatReader_Example.ino

--- libraries/BatReader/examples/BatReader_Example/BatReader_Example.ino
+++ libraries/BatReader/examples/BatReader_Example/BatReader_Example.ino
@@ -1,18 +0,0 @@
-#include "BatReader.h"
-
-BatReader batreader;
-
-void setup() {
-  // put your setup code here, to run once:
-  Serial.begin(115200);
-
-}
-
-void loop() {
-  Serial.print("Battery Voltage: ");
-  Serial.println(batreader.readBatVoltage());
-  Serial.print("Battery Percentage: ");
-  Serial.print(batreader.readBatPercent());
-  Serial.println("%\n\r");
-  delay(1000);
-}


libraries: MegaDrive example: Just minor changes.

--- libraries/MegaDrive/examples/megadrive-example/megadrive-example.ino
+++ libraries/MegaDrive/examples/megadrive-example/megadrive-example.ino
@@ -6,7 +6,7 @@
   .D0 = 4, // Use pin 4 of Arduino uno as input (UP key)
 };

-static struct mg_three_callbacks clbs = {
+static struct mg_three_callbacks clbs_up = {
   .up_fnc = &up_keyup,
 };

@@ -14,7 +14,7 @@
   .up_fnc = &up_keydown,
 };

-MegaDrive<mg_three_callbacks> *X = new MegaDrive<mg_three_callbacks>(ps, clbs, clbs_down);;
+MegaDrive<mg_three_callbacks> *X = new MegaDrive<mg_three_callbacks>(ps, clbs_up, clbs_down);

 void up_keyup(void)
 {


Implements SEMI AUTOMATIC sleep mode postponing radio on until after data collected w/ updated comment

--- firmware/SVPA-FloodSensor-2016.ino
+++ firmware/SVPA-FloodSensor-2016.ino
@@ -14,6 +14,7 @@
 PRODUCT_ID(1623);
 PRODUCT_VERSION(12); //Remember to update const below

+// Impliments SEMI_AUTOMATIC sleep mode.
 SYSTEM_MODE(SEMI_AUTOMATIC);

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


Wording

Wording

--- paper_display.ino
+++ paper_display.ino
@@ -18,7 +18,7 @@
 // How long to sleep in between displays, in seconds
 int sleepTimeS = 60*60; // one hour
 #define LED_PIN 5 // ESP8266 LED PIN
-#define WAKEUP_PIN 4 // ESP8266 DTR pin
+#define WAKEUP_PIN 4 // ESP8266 pin that will wake up the EPD -- not to be confused with XPO/DTR to wake up the ESP
 #define MAX_H_CHARS 55 // Max characters to show horizontally
 char result[1000]; // Buffer to get web results in from


Added timestamp to the sent messages

Added timestamp to the sent messages

--- src/CAN/CAN_send_v2/CAN_send_v2.ino
+++ src/CAN/CAN_send_v2/CAN_send_v2.ino
@@ -3,6 +3,8 @@
 #include <mcp_can.h>
 #include <SPI.h>
 #include <SpritzCipher.h>
+#include <Time.h>
+
 #include "can_constants.h"

 // the cs pin of the version after v1.1 is default to D9
@@ -18,6 +20,9 @@
 const uint8_t HASH_LEN = 20; // 160-bit. The other 32 bits for timestamp
 uint8_t correct_hash[HASH_LEN];
 uint8_t hash[HASH_LEN]; // for the incoming hash?
+
+// For timestamping messages
+time_t timestamp;

 MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

@@ -141,6 +146,28 @@
 }

+void StampTime(uint8_t *buf)
+{
+    // Get current time
+    timestamp = now();
+
+    Serial.print("Timestamp: ");
+    Serial.print(day(timestamp));
+    Serial.print(" - ");
+    Serial.print(hour(timestamp));
+    Serial.print(":");
+    Serial.print(minute(timestamp));
+    Serial.print(":");
+    Serial.println(second(timestamp));
+
+    // Store the timestamp
+    buf[0] = day(timestamp);
+    buf[1] = hour(timestamp);
+    buf[2] = minute(timestamp);
+    buf[3] = second(timestamp);
+}
+
+
 // Sends the 3 authentication messages
 void SendAuthMessages()
 {
@@ -152,6 +179,9 @@
     for (int i = 8; i < 16; i++) msg2[i - 8] = correct_hash[i];
     for (int i = 16; i < 20; i++) msg3[i - 16] = correct_hash[i];

+    // Fill last 4 bytes of msg3 with the timestamp
+    StampTime(&msg3[4]);
+
     CAN.sendMsgBuf(id, 0, 8, msg1);
     CAN.sendMsgBuf(id, 0, 8, msg2);
     CAN.sendMsgBuf(id, 0, 8, msg3);
@@ -159,9 +189,10 @@
     Serial.print("Sending: ");
     PrintAuthMessage(&msg1[0], 8);
     PrintAuthMessage(&msg2[0], 8);
-    PrintAuthMessage(&msg3[0], 4);
+    PrintAuthMessage(&msg3[0], 8);
     Serial.print('\n');
 }
+

 void PrintAuthMessage(uint8_t *msg, uint8_t msgLen)
 {


Update JS_Shield.ino

Update JS_Shield.ino

--- app/firmware/JS_Shield/JS_Shield.ino
+++ app/firmware/JS_Shield/JS_Shield.ino
@@ -1,25 +1,95 @@
-char remainData;
+/**********************************************************************************
+ * The following software may be included in this software : orion_firmware.ino
+ * from http://www.makeblock.cc/
+ * This software contains the following license and notice below:
+ * CC-BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/)
+ * Author : Ander, Mark Yan
+ * Updated : Ander, Mark Yan
+ * Date : 01/09/2016
+ * Description : Firmware for Makeblock Electronic modules with Scratch.
+ * Copyright (C) 2013 - 2016 Maker Works Technology Co., Ltd. All right reserved.
+ **********************************************************************************/
+// 서보 라이브러리
+#include <Servo.h>
+
+// 동작 상수
+#define ALIVE 0
+#define DIGITAL 1
+#define ANALOG 2
+#define PWM 3
+#define SERVO_PIN 4
+#define TONE 5
+#define PULSEIN 6
+#define ULTRASONIC 7
+#define TIMER 8
+
+// 상태 상수
+#define GET 1
+#define SET 2
+#define RESET 3
+
+// val Union
+union{
+  byte byteVal[4];
+  float floatVal;
+  long longVal;
+}val;
+
+// valShort Union
+union{
+  byte byteVal[2];
+  short shortVal;
+}valShort;
+
+// 전역변수 선언 시작
+Servo servos[8];
+
+//울트라 소닉 포트
+int trigPin = 13;
+int echoPin = 12;
+
+//포트별 상태
+int analogs[6]={0,0,0,0,0,0};
+int digitals[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+int servo_pins[8]={0,0,0,0,0,0,0,0};
+
+// 울트라소닉 최종 값
+float lastUltrasonic = 0;
+
+// 버퍼
+char buffer[52];
+unsigned char prevc=0;
+
+byte index = 0;
+byte dataLen;
+
+double lastTime = 0.0;
+double currentTime = 0.0;
+
+uint8_t command_index = 0;
+
+boolean isStart = false;
+boolean isUltrasonic = false;
+// 전역변수 선언 종료

 void setup(){
-  Serial.begin(9600);
-  Serial.flush();
+  Serial.begin(115200);
   initPorts();
   delay(200);
 }

-void initPorts () {
+void initPorts() {
   for (int pinNumber = 0; pinNumber < 14; pinNumber++) {
     pinMode(pinNumber, OUTPUT);
     digitalWrite(pinNumber, LOW);
   }
 }

-void loop() {
+void loop(){
   while (Serial.available()) {
     if (Serial.available() > 0) {
-
-      char c = Serial.read();
-      updateDigitalPort(c);
+      char serialRead = Serial.read();
+      setPinValue(serialRead&0xff);
     }
   }
   delay(15);
@@ -27,88 +97,308 @@
   delay(10);
 }

-void sendPinValues() {
+void setPinValue(unsigned char c) {
+  if(c==0x55&&isStart==false){
+    if(prevc==0xff){
+      index=1;
+      isStart = true;
+    }
+  } else {
+    prevc = c;
+    if(isStart) {
+      if(index==2){
+        dataLen = c;
+      } else if(index>2) {
+        dataLen--;
+      }
+
+      writeBuffer(index,c);
+    }
+  }
+
+  index++;
+
+  if(index>51) {
+    index=0;
+    isStart=false;
+  }
+
+  if(isStart&&dataLen==0&&index>3){
+    isStart = false;
+    parseData();
+    index=0;
+  }
+}
+
+unsigned char readBuffer(int index){
+  return buffer[index];
+}
+
+void parseData() {
+  isStart = false;
+  int idx = readBuffer(3);
+  command_index = (uint8_t)idx;
+  int action = readBuffer(4);
+  int device = readBuffer(5);
+  int port = readBuffer(6);
+  switch(action){
+    case GET:{
+      if(device == ULTRASONIC) {
+        if(!isUltrasonic) {
+          setUltrasonicMode(true);
+          trigPin = readBuffer(6);
+          echoPin = readBuffer(7);
+          digitals[trigPin] = 1;
+          digitals[echoPin] = 1;
+          pinMode(trigPin, OUTPUT);
+          pinMode(echoPin, INPUT);
+          delay(50);
+        } else {
+          int trig = readBuffer(6);
+          int echo = readBuffer(7);
+          if(trig != trigPin || echo != echoPin) {
+            digitals[trigPin] = 0;
+            digitals[echoPin] = 0;
+            trigPin = trig;
+            echoPin = echo;
+            digitals[trigPin] = 1;
+            digitals[echoPin] = 1;
+            pinMode(trigPin, OUTPUT);
+            pinMode(echoPin, INPUT);
+            delay(50);
+          }
+        }
+      } else if(port == trigPin || port == echoPin) {
+        setUltrasonicMode(false);
+        digitals[port] = 0;
+      } else {
+        setUltrasonicMode(false);
+        digitals[port] = 0;
+      }
+    }
+    break;
+    case SET:{
+      runModule(device);
+      callOK();
+    }
+    break;
+    case RESET:{
+      callOK();
+    }
+    break;
+  }
+}
+
+void runModule(int device) {
+  //0xff 0x55 0x6 0x0 0x1 0xa 0x9 0x0 0x0 0xa
+  int port = readBuffer(6);
+  int pin = port;
+
+  if(pin == trigPin || pin == echoPin) {
+    setUltrasonicMode(false);
+  }
+
+  switch(device){
+    case DIGITAL:{
+      setPortWritable(pin);
+      int v = readBuffer(7);
+      digitalWrite(pin,v);
+    }
+    break;
+    case PWM:{
+      setPortWritable(pin);
+      int v = readBuffer(7);
+      analogWrite(pin,v);
+    }
+    break;
+    case TONE:{
+      setPortWritable(pin);
+      int hz = readShort(7);
+      int ms = readShort(9);
+      if(ms>0) {
+        tone(pin, hz, ms);
+      } else {
+        noTone(pin);
+      }
+    }
+    break;
+    case SERVO_PIN:{
+      setPortWritable(pin);
+      int v = readBuffer(7);
+      if(v>=0&&v<=180){
+        Servo sv = servos[searchServoPin(pin)];
+        sv.attach(pin);
+        sv.write(v);
+      }
+    }
+    break;
+    case TIMER:{
+      lastTime = millis()/1000.0;
+    }
+    break;
+  }
+}
+
+void sendPinValues() {
   int pinNumber = 0;
+  for (pinNumber = 0; pinNumber < 12; pinNumber++) {
+    if(digitals[pinNumber] == 0) {
+      sendDigitalValue(pinNumber);
+      callOK();
+    }
+  }
   for (pinNumber = 0; pinNumber < 6; pinNumber++) {
-    sendAnalogValue(pinNumber);
-  }
-  for (pinNumber = 0; pinNumber < 14; pinNumber++) {
-    if (!isPortWritable(pinNumber))
-      sendDigitalValue(pinNumber);
-  }
-}
-
-void updateDigitalPort (char c) {
-  // first data
-  if (c>>7) {
-    // is output
-    if ((c>>6) & 1) {
-      // is data end at this chunk
-      if ((c>>5) & 1) {
-        int port = (c >> 1) & B1111;
-        setPortWritable(port);
-        if (c & 1)
-          digitalWrite(port, HIGH);
-        else
-          digitalWrite(port, LOW);
-      }
-      else {
-        remainData = c;
-      }
-    } else {
-      int port = (c >> 1) & B1111;
-      setPortReadable(port);
-    }
+    if(analogs[pinNumber] == 0) {
+      sendAnalogValue(pinNumber);
+      callOK();
+    }
+  }
+
+  if(isUltrasonic) {
+    sendUltrasonic();
+    callOK();
+  }
+}
+
+void setUltrasonicMode(boolean mode) {
+  isUltrasonic = mode;
+  if(!mode) {
+    lastUltrasonic = 0;
+  }
+}
+
+void sendUltrasonic() {
+  digitalWrite(trigPin, LOW);
+  delayMicroseconds(2);
+  digitalWrite(trigPin, HIGH);
+  delayMicroseconds(10);
+  digitalWrite(trigPin, LOW);
+
+  float value = pulseIn(echoPin, HIGH, 30000) / 29.0 / 2.0;
+
+  if(value == 0) {
+    value = lastUltrasonic;
   } else {
-    int port = (remainData >> 1) & B1111;
-    int value = ((remainData & 1) << 7) + (c & B1111111);
-    setPortWritable(port);
-    analogWrite(port, value);
-    remainData = 0;
-  }
-
-  pinMode(4,INPUT);
-  pinMode(5,INPUT);
-  pinMode(8,INPUT);
-  pinMode(9,INPUT);
-  pinMode(10,INPUT);
-
+    lastUltrasonic = value;
+  }
+  writeHead();
+  sendFloat(value);
+  writeSerial(trigPin);
+  writeSerial(echoPin);
+  writeSerial(ULTRASONIC);
+  writeEnd();
+}
+
+void sendDigitalValue(int pinNumber) {
+  pinMode(pinNumber,INPUT);
+  writeHead();
+  sendFloat(digitalRead(pinNumber));
+  writeSerial(pinNumber);
+  writeSerial(DIGITAL);
+  writeEnd();
 }

 void sendAnalogValue(int pinNumber) {
-  int value = analogRead(pinNumber);
-  Serial.write(B11000000
-               | ((pinNumber & B111)<<3)
-               | ((value>>7) & B111));
-  Serial.write(value & B1111111);
-}
-
-void sendDigitalValue(int pinNumber) {
-  if (digitalRead(pinNumber) == HIGH) {
-    Serial.write(B10000000
-                 | ((pinNumber & B1111)<<2)
-                 | (B1));
-  } else {
-    Serial.write(B10000000
-               | ((pinNumber & B1111)<<2));
-  }
-}
-
-void setPortReadable (int port) {
-  if (isPortWritable(port)) {
-    pinMode(port, INPUT);
-  }
-}
-
-void setPortWritable (int port) {
-  if (!isPortWritable(port)) {
-    pinMode(port, OUTPUT);
-  }
-}
-
-boolean isPortWritable (int port) {
-  if (port > 7)
-    return bitRead(DDRB, port - 8);
-  else
-    return bitRead(DDRD, port);
-}
+  writeHead();
+  sendFloat(analogRead(pinNumber));
+  writeSerial(pinNumber);
+  writeSerial(ANALOG);
+  writeEnd();
+}
+
+void writeBuffer(int index,unsigned char c){
+  buffer[index]=c;
+}
+
+void writeHead(){
+  writeSerial(0xff);
+  writeSerial(0x55);
+}
+
+void writeEnd(){
+  Serial.println();
+}
+
+void writeSerial(unsigned char c){
+  Serial.write(c);
+}
+
+void sendString(String s){
+  int l = s.length();
+  writeSerial(4);
+  writeSerial(l);
+  for(int i=0;i<l;i++){
+    writeSerial(s.charAt(i));
+  }
+}
+
+void sendFloat(float value){
+  writeSerial(2);
+  val.floatVal = value;
+  writeSerial(val.byteVal[0]);
+  writeSerial(val.byteVal[1]);
+  writeSerial(val.byteVal[2]);
+  writeSerial(val.byteVal[3]);
+}
+
+void sendShort(double value){
+  writeSerial(3);
+  valShort.shortVal = value;
+  writeSerial(valShort.byteVal[0]);
+  writeSerial(valShort.byteVal[1]);
+}
+
+short readShort(int idx){
+  valShort.byteVal[0] = readBuffer(idx);
+  valShort.byteVal[1] = readBuffer(idx+1);
+  return valShort.shortVal;
+}
+
+float readFloat(int idx){
+  val.byteVal[0] = readBuffer(idx);
+  val.byteVal[1] = readBuffer(idx+1);
+  val.byteVal[2] = readBuffer(idx+2);
+  val.byteVal[3] = readBuffer(idx+3);
+  return val.floatVal;
+}
+
+long readLong(int idx){
+  val.byteVal[0] = readBuffer(idx);
+  val.byteVal[1] = readBuffer(idx+1);
+  val.byteVal[2] = readBuffer(idx+2);
+  val.byteVal[3] = readBuffer(idx+3);
+  return val.longVal;
+}
+
+int searchServoPin(int pin){
+  for(int i=0;i<8;i++){
+    if(servo_pins[i] == pin){
+      return i;
+    }
+    if(servo_pins[i]==0){
+      servo_pins[i] = pin;
+      return i;
+    }
+  }
+  return 0;
+}
+
+void setPortWritable(int pin) {
+  if(digitals[pin] == 0) {
+    digitals[pin] = 1;
+    pinMode(pin, OUTPUT);
+  }
+}
+
+void callOK(){
+  writeSerial(0xff);
+  writeSerial(0x55);
+  writeEnd();
+}
+
+void callDebug(char c){
+  writeSerial(0xff);
+  writeSerial(0x55);
+  writeSerial(c);
+  writeEnd();
+}


manual merge

manual merge

--- wled00/wled00.ino
+++ wled00/wled00.ino
@@ -98,7 +98,7 @@

 //version code in format yymmddb (b = daily build)
-#define VERSION 1912231
+#define VERSION 1912232
 char versionString[] = "0.9.0-b2";


v3.0.0 - code cleanup

v3.0.0 - code cleanup

--- examples/Scheduler_example21_OO_Callbacks/Scheduler_example21_OO_Callbacks.ino
+++ examples/Scheduler_example21_OO_Callbacks/Scheduler_example21_OO_Callbacks.ino
@@ -1,5 +1,5 @@
 /**
-    This is example 5 rewritten with Timeout, LTS, WDT functioanlity + multitab and extra classes
+    This is example 5 rewritten with dynamic binding of callback methods
     - 1 second timeout is set for the main calculation task
     - LTS is used to address task-specific sensor class object
     - WDT is used to set the Task ID and use that for identifying the tasks (debug)
@@ -36,8 +36,8 @@

 // Tasks

-Calculator* tCalculate;//(&hts, &ts);
-Ticker*     tCycle; //(&hts, (Task*) &tCalculate, &measure);
+Calculator* tCalculate;
+Ticker*     tCycle;

 int pins[] = { 1, 9, 3, 7, 5, 6, 4, 8, 2, 10 };


#3 Added ability to run traffic based on vehicle count in NS and EW.

--- src/main/main.ino
+++ src/main/main.ino
@@ -1,32 +1,189 @@
-int trafficLightCount = 3;
+//allows us to set actions to perform on separate timed intervals
+//http://playground.arduino.cc/Code/TimedAction
+#include <TimedAction.h>

-// Contains array of traffic led pins. Pin 0 - green, pin 1 - amber, pin 3 - red.
-int trafficLights[] = { 0, 1, 2 };
+const int trafficLightCount = 3;
+
+// Pin 2 - green, pin 3 - amber, pin 4 - red.
+int trafficNSLights[] = { 2, 3, 4 };
+
+// Pin 5 - green, pin 6 - amber, pin 7 - red.
+int trafficEWLights[] = { 5, 6, 7 };

 // Pin for controlling traffic
-int trafficController = 13;
+const int vehicleEW = 12;
+const int vehicleNS = 13;

 // Light delay
 int delayTime = 1000; //1sec
+
+// Light delays
+int amberLightDelay = 2000; //2sec
+int greenLightDelay = 5000; //20sec for now 5 sec
+int redLightDelay = 3000; //3 sec
+
+//boolean to control state
+boolean isNSTrafficGreen = false;
+
+int vehicleNSCounter = 0;   // counter for the number of button presses
+int vehicleNSState = 0;        // current state of the button
+int lastVehicleNSState = 0;    // previous state of the button
+
+int vehicleEWCounter = 0;   // counter for the number of button presses
+int vehicleEWState = 0;        // current state of the button
+int lastVehicleEWState = 0;    // previous state of the button
+
+//FUNCTIONS
+
+// Keep track of the number of vehicles in NS
+void countNSVehicles() {
+  if (vehicleNSState != lastVehicleNSState) {
+    if (vehicleNSState == HIGH) {
+      vehicleNSCounter = vehicleNSCounter + 1;
+      Serial.print("North-South vehicle total count: ");
+      Serial.println(vehicleNSCounter);
+    }
+  }
+  lastVehicleNSState = vehicleNSState;
+}
+
+// Keep track of the number of vehicles in EW
+void countEWVehicles() {
+  if (vehicleEWState != lastVehicleEWState) {
+    if (vehicleEWState == HIGH) {
+      vehicleEWCounter = vehicleEWCounter + 1;
+      Serial.print("East-West vehicle total count: ");
+      Serial.println(vehicleEWCounter);
+    }
+  }
+  lastVehicleEWState = vehicleEWState;
+}
+
+//our second task, fires every few seconds and rotates signals
+void changeSignal() {
+  //check current state. check if theres any vehicle in other side if so rotate signal
+  if (isNSTrafficGreen && vehicleEWCounter > 0) {
+    changeEWTrafficToGreen();
+  } else if (!isNSTrafficGreen && vehicleNSCounter > 0) {
+    changeNSTrafficToGreen();
+  } else {
+    //do nothing
+  }
+}
+
+//create a couple timers that will fire repeatedly every x ms
+TimedAction vehiclesNSThread = TimedAction(300, countNSVehicles);
+TimedAction vehiclesEWThread = TimedAction(300, countEWVehicles);
+TimedAction signalThread = TimedAction(5000, changeSignal); //minimum cycle green is 20s we use 5 for now
+TimedAction vehicleRemovalThread = TimedAction(1000, passVehicles); //minimum 1 second for a vehicle to pass
+
+
+
+// where's our third task? well, it's the loop itself :) the task
+// which repeats most often should be used as the loop. other
+// tasks are able to "interrupt" the fastest repeating task.
+

 void setup() {
   // Put your setup code here, to run once:

   // Make all traffic light pins output
   for (int thisTrafficLight = 0; thisTrafficLight < trafficLightCount; thisTrafficLight++) {
-    pinMode(trafficLights[thisTrafficLight], OUTPUT);
+    pinMode(trafficNSLights[thisTrafficLight], OUTPUT);
+    pinMode(trafficEWLights[thisTrafficLight], OUTPUT);
   }

   // Input pins
-  pinMode(trafficController, INPUT);
+  pinMode(vehicleEW, INPUT);
+
+  Serial.begin(9600);
+  setInitialTrafficCondition();
 }

 void loop() {
-    // put your main code here, to run repeatedly:
-    for (int thisTrafficLight = 0; thisTrafficLight < trafficLightCount; thisTrafficLight++) {
-      digitalWrite(trafficLights[thisTrafficLight], HIGH);
-      delay(delayTime);
-      digitalWrite(trafficLights[thisTrafficLight], LOW);
-      delay(delayTime);
+  // put your main code here, to run repeatedly:
+
+  //check on our threads. based on how long the system has been
+  //running, do they need to fire and do work? if so, do it!
+  vehiclesNSThread.check();
+  vehiclesEWThread.check();
+  signalThread.check();
+  vehicleRemovalThread.check();
+
+  vehicleEWState = digitalRead(vehicleEW);
+  vehicleNSState = digitalRead(vehicleNS);
+}
+
+void setInitialTrafficCondition() {
+  //initial stage
+  //NS green on, red and amber off
+  if (!isNSTrafficGreen) {
+    digitalWrite(trafficNSLights[0], HIGH);
+    digitalWrite(trafficEWLights[2], HIGH);
+    delay(greenLightDelay);
+    isNSTrafficGreen = true;
+  }
+}
+
+/**
+   Passes vehicles
+*/
+void passVehicles() {
+  //Pass any blocked vehicles in NS traffic
+  if (isNSTrafficGreen) {
+    //when NS traffic cycle change traffic to north south
+    if (vehicleNSCounter > 0) {
+      Serial.print("Total NORTH-SOUTH vehicles. ");
+      Serial.println(vehicleNSCounter);
+      vehicleNSCounter = vehicleNSCounter - 1;
+      Serial.print("Vehicle NORTH-SOUTH passing. Total Number remainning");
+      Serial.println(vehicleNSCounter);
     }
+  } else {
+    //when NS traffic cycle change traffic to north south
+    if (vehicleEWCounter > 0) {
+      Serial.print("Total EAST-WEST vehicles. ");
+      Serial.println(vehicleEWCounter);
+      vehicleEWCounter = vehicleEWCounter - 1;
+      Serial.print("Vehicle EAST-WEST passing. Total Number remainning");
+      Serial.println(vehicleEWCounter);
+    }
+  }
 }
+
+void changeEWTrafficToGreen() {
+  Serial.println("Vechile EAST-WEST direction. Changing signal EAST-WEST to green");
+  //Change NS to red
+  setNSTrafficLights(LOW, HIGH, LOW);
+  delay(amberLightDelay);
+  setNSTrafficLights(LOW, LOW, HIGH);
+  //Change EW to green
+  delay(redLightDelay);
+  setEWTrafficLights(HIGH, LOW, LOW);
+  isNSTrafficGreen = false;
+}
+
+void changeNSTrafficToGreen() {
+  Serial.println("Vechile NORTH-SOUTH direction. Changing signal NORTH-SOUTH to green");
+  //Change EW to red
+  setEWTrafficLights(LOW, HIGH, LOW);
+  delay(amberLightDelay);
+  setEWTrafficLights(LOW, LOW, HIGH);
+  //Change NS to green
+  delay(redLightDelay);
+  setNSTrafficLights(HIGH, LOW, LOW);
+  isNSTrafficGreen = true;
+}
+
+void setNSTrafficLights(uint8_t  greenValue, uint8_t amberValue, uint8_t redValue) {
+  digitalWrite(trafficNSLights[0], greenValue);
+  digitalWrite(trafficNSLights[1], amberValue);
+  digitalWrite(trafficNSLights[2], redValue);
+}
+
+void setEWTrafficLights(uint8_t  greenValue, uint8_t amberValue, uint8_t redValue) {
+  digitalWrite(trafficEWLights[0], greenValue);
+  digitalWrite(trafficEWLights[1], amberValue);
+  digitalWrite(trafficEWLights[2], redValue);
+}
+


going to sleep when fail

going to sleep when fail

--- _15-esp8266-dash-deepsleep-reset/_15-esp8266-dash-deepsleep-reset.ino
+++ _15-esp8266-dash-deepsleep-reset/_15-esp8266-dash-deepsleep-reset.ino
@@ -31,6 +31,9 @@
 String getResetInfo ;

 int vdd;
+
+//
+unsigned long startMills;

 IPAddress server(192, 168, 10, 10);
 WiFiClient wifiClient;
@@ -71,7 +74,6 @@

   subMsgReceived = HIGH;
   digitalWrite(greenLED, LOW);
-

 }

@@ -131,10 +133,12 @@
           Serial.println();
           Serial.println("-----> Could not connect to WIFI");
         }
+        /*
         ESP.restart();
         delay(200);
-      }
-
+        */
+        goingToSleepWithFail();
+      }
     }

     if (EVENT_PRINT) {
@@ -151,12 +155,16 @@

 void setup()
 {
+  //
+  startMills = millis();
+
   // pinmode setup
   pinMode(resetupPin, OUTPUT);
   pinMode(blueLED, OUTPUT);
   pinMode(greenLED, OUTPUT);
   pinMode(redLED, OUTPUT);

+  //`
   digitalWrite(resetupPin, LOW);
   digitalWrite(redLED, HIGH);

@@ -220,6 +228,14 @@
     goingToSleep();
   }

+  if ((millis() - startMills) > 15000) {
+    if (EVENT_PRINT) {
+      Serial.println("going to sleep with fail");
+    }
+    goingToSleepWithFail();
+  }
+
+
   client.loop();
 }

@@ -292,6 +308,26 @@
   delay(250);
 }

+
+void goingToSleepWithFail()
+{
+  digitalWrite(greenLED, LOW);
+  digitalWrite(blueLED, LOW);
+  digitalWrite(redLED, LOW);
+
+  digitalWrite(redLED, HIGH);
+  delay(300);
+  digitalWrite(redLED, LOW);
+  delay(300);
+  digitalWrite(redLED, HIGH);
+  delay(300);
+  digitalWrite(redLED, LOW);
+
+  ESP.deepSleep(0);
+  delay(250);
+}
+
+
 String macToStr(const uint8_t* mac)
 {
   String result;
@@ -302,3 +338,5 @@
   }
   return result;
 }
+
+//-----


new blah 2

new blah 2

--- proj/hypercube/HCS/Animations.ino
+++ proj/hypercube/HCS/Animations.ino
@@ -106,7 +106,7 @@
   }
 }

-void chase_mod(uint16_t shell, boolean reverse) {
+void chase_mod(uint16_t shell) {
   static uint8_t index = 0;
   EVERY_N_MILLISECONDS_I(thisTimer, 10) {
     thisTimer.setPeriod(gRate);
@@ -114,20 +114,10 @@
   }

   if(shell == INNER) {
-    if(reverse) {
-      chaser_mod(in_leds(in_LED_tot-1, 0), in_LED_tot, index, iPalette);
-    }
-    else {
-      chaser_mod(in_leds, in_LED_tot, index, iPalette);
-    }
+    chaser_mod(in_leds, in_LED_tot, index, iPalette);
   }
   if(shell == OUTER) {
-    if(reverse) {
-      chaser_mod(out_leds(out_LED_tot-1, 0), out_LED_tot, index, oPalette);
-    }
-    else {
-      chaser_mod(out_leds, out_LED_tot, index, oPalette);
-    }
+    chaser_mod(out_leds, out_LED_tot, index, oPalette);
   }

 }


Update spark-as-server.ino

Update spark-as-server.ino

--- spark-as-server/spark-as-server.ino
+++ spark-as-server/spark-as-server.ino
@@ -9,14 +9,16 @@
   server.begin();

   // Make sure your Serial Terminal app is closed before powering your Core
-  Serial.begin(9600);
+  // Serial.begin(9600);
   // Now open your Serial Terminal, and hit any key to continue!
-  while(!Serial.available()) SPARK_WLAN_Loop();
+  // while(!Serial.available())  SPARK_WLAN_Loop();

-  Serial.println(WiFi.localIP());
-  Serial.println(WiFi.subnetMask());
-  Serial.println(WiFi.gatewayIP());
-  Serial.println(WiFi.SSID());
+  //Serial.println(WiFi.localIP());
+  //Serial.println(WiFi.subnetMask());
+  //Serial.println(WiFi.gatewayIP());
+  //Serial.println(WiFi.SSID());
+
+   SPARK_WLAN_Loop();   // so cloud stuff can still happen
 }

 void loop()


v7.0 Restart nodeMCU if we lose WiFi connection

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -97,9 +97,14 @@

   if (counter >= GETDATACOUNT) //Get new data
   {
-    counter = 0;
-    getWeatherData();
-
+    // If we lost WiFi connection (it sometimes happens), restart the nodeMCU
+    if (WiFi.status() != WL_CONNECTED) {
+      ESP.restart();
+    }
+    else {
+      counter = 0;
+      getWeatherData();
+    }
   }
   else {
     counter++;
@@ -927,8 +932,8 @@
 }

 /*
- Computes Sun rise/set times, start/end of twilight, and
- the length of the day at any date and latitude
+  Computes Sun rise/set times, start/end of twilight, and
+  the length of the day at any date and latitude

   Written as DAYLEN.C, 1989-08-16


Delete JsonGeneratorExample.ino

Delete JsonGeneratorExample.ino

--- src/third-party/arduino-json-5.1.1/examples/JsonGeneratorExample/JsonGeneratorExample.ino
+++ src/third-party/arduino-json-5.1.1/examples/JsonGeneratorExample/JsonGeneratorExample.ino
@@ -1,70 +0,0 @@
-// Copyright Benoit Blanchon 2014-2016
-// MIT License
-//
-// Arduino JSON library
-// https://github.com/bblanchon/ArduinoJson
-// If you like this project, please add a star!
-
-#include <ArduinoJson.h>
-
-void setup() {
-  Serial.begin(9600);
-  while (!Serial) {
-    // wait serial port initialization
-  }
-
-  // Memory pool for JSON object tree.
-  //
-  // Inside the brackets, 200 is the size of the pool in bytes.
-  // If the JSON object is more complex, you need to increase that value.
-  StaticJsonBuffer<200> jsonBuffer;
-
-  // StaticJsonBuffer allocates memory on the stack, it can be
-  // replaced by DynamicJsonBuffer which allocates in the heap.
-  // It's simpler but less efficient.
-  //
-  // DynamicJsonBuffer  jsonBuffer;
-
-  // Create the root of the object tree.
-  //
-  // It's a reference to the JsonObject, the actual bytes are inside the
-  // JsonBuffer with all the other nodes of the object tree.
-  // Memory is freed when jsonBuffer goes out of scope.
-  JsonObject& root = jsonBuffer.createObject();
-
-  // Add values in the object
-  //
-  // Most of the time, you can rely on the implicit casts.
-  // In other case, you can do root.set<long>("time", 1351824120);
-  root["sensor"] = "gps";
-  root["time"] = 1351824120;
-
-  // Add a nested array.
-  //
-  // It's also possible to create the array separately and add it to the
-  // JsonObject but it's less efficient.
-  JsonArray& data = root.createNestedArray("data");
-  data.add(double_with_n_digits(48.756080, 6));
-  data.add(double_with_n_digits(2.302038, 6));
-
-  root.printTo(Serial);
-  // This prints:
-  // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
-
-  Serial.println();
-
-  root.prettyPrintTo(Serial);
-  // This prints:
-  // {
-  //   "sensor": "gps",
-  //   "time": 1351824120,
-  //   "data": [
-  //     48.756080,
-  //     2.302038
-  //   ]
-  // }
-}
-
-void loop() {
-  // not used in this example
-}


added command for controlling the LIDAR

added command for controlling the LIDAR

LG - LIDAR Go
LH - LIDAR Halt
LS- LIDAR Set speed and acceleration

--- jenny5-firmware/jenny5-firmware.ino
+++ jenny5-firmware/jenny5-firmware.ino
@@ -39,7 +39,7 @@
 void setup()
 {
   first_start = 0;
-  strcpy(firmware_version, "2016.07.27.0");
+  strcpy(firmware_version, "2016.08.20.0");

   current_buffer[0] = 0;

@@ -233,9 +233,26 @@
       }

 	  // LIDAR
-	  if (tmp_str[i] == 'L' || tmp_str[i] == 'l') {
-		  tera_ranger_one_lidar->start();
-		  i +=2;
+	  if (tmp_str[i] == 'L' || tmp_str[i] == 'l') {// lidar operations
+		  if (tmp_str[i + 1] == 'G' || tmp_str[i + 1] == 'g') {// lidar go
+			  tera_ranger_one_lidar->start();
+			  i += 3;
+		  }
+		  else
+			  if (tmp_str[i + 1] == 'H' || tmp_str[i + 1] == 'h') {// lidar halt
+				  tera_ranger_one_lidar->stop();
+				  i += 3;
+			  }
+			  else
+				  if (tmp_str[i + 1] == 'S' || tmp_str[i + 1] == 's') {// lidar halt
+					  int motor_speed, motor_acceleration;
+					  int num_consumed;
+					  sscanf(tmp_str + i + 2, "%d%d%n", &motor_speed, &motor_acceleration, &num_consumed);
+					  tera_ranger_one_lidar->set_motor_speed_and_acceleration(motor_speed, motor_acceleration);
+					  i += 2 + num_consumed;
+				  }
+			  else// unknown command
+				  i += 2;
 		  continue;
 	  }


Make it compile

Make it compile

--- teensy/teensy.ino
+++ teensy/teensy.ino
@@ -25,7 +25,7 @@
   SUGAR = 0,
   MILK,
   HONEY,
-}
+};

 char serial_buffer[BUFLEN] = {};
 long serial_index = 0;
@@ -44,15 +44,6 @@
 #define CMD_addin_insert 'i'

 int arglen[256] = {};
-arglen[CMD_mug_seek] = 1;
-arglen[CMD_mug_get] = 0;
-arglen[CMD_kcup_tray_open] = 0;
-arglen[CMD_kcup_tray_close] = 0;
-arglen[CMD_kcup_load] = 0;
-arglen[CMD_kcup_eject] = 0;
-arglen[CMD_kcup_count] = 0;
-arglen[CMD_brew] = 0;
-arglen[CMD_addin_insert] = 2;

 #define TRAY_OPEN 0
 #define TRAY_CLOSED 1
@@ -72,7 +63,7 @@
   Serial.write(result);
 }

-void handle_serial {
+void handle_serial() {
   if (Serial.available()) {
     int data = Serial.read();
     if (data == CMD_HEADER_A) {
@@ -113,7 +104,7 @@
 	break;
       case CMD_addin_insert:
 	// int, int
-	res = brew(serial_buffer[2], serial_buffer[3]);
+	res = addin_insert((enum Addin)serial_buffer[2], serial_buffer[3]);
 	break;
       default:
 	res = ERR_UNKNOWN;
@@ -157,7 +148,6 @@
     delay(500);
   }
   tray_state = TRAY_OPEN;
-  KCUP_LOADER, KCUP_EJECTOR, TRAY_PISTON
   return 0;
 }

@@ -165,7 +155,7 @@
 // Repeated calls will do nothing
 // Never returns an error, ideally
 int kcup_tray_close() {
-  digtalWriteFast(PIN_TRAY_PISTON, TRAY_CLOSED);
+  digitalWriteFast(PIN_TRAY_PISTON, TRAY_CLOSED);
   if (tray_state != TRAY_CLOSED) {
     delay(500);
   }
@@ -236,11 +226,11 @@
 }

 int kettle_set_temp(int temp) {
-
+  return ERR_NYI;
 }

 int kettle_dispense(int amount) {
-
+  return ERR_NYI;
 }

 void initialize() {
@@ -251,6 +241,16 @@
   pinMode(PIN_TRAY_PISTON, OUTPUT);

   Serial.begin(9600);
+
+  arglen[CMD_mug_seek] = 1;
+  arglen[CMD_mug_get] = 0;
+  arglen[CMD_kcup_tray_open] = 0;
+  arglen[CMD_kcup_tray_close] = 0;
+  arglen[CMD_kcup_load] = 0;
+  arglen[CMD_kcup_eject] = 0;
+  arglen[CMD_kcup_count] = 0;
+  arglen[CMD_brew] = 0;
+  arglen[CMD_addin_insert] = 2;
 }

 int main() {


Software timing more predictable in early tests. Almost ready to start moving to interrupt driven USI scheme

--- txtest/txtest.ino
+++ txtest/txtest.ino
@@ -6,7 +6,7 @@
 #define LED_GREEN 0  // PB0, pin 5
 #define TX 1         // PB1, pin 6

-#define HALF_BIT_TIME 5 //ms
+#define BIT_TIME 10 //ms

 void setup()
 {
@@ -32,27 +32,29 @@

   // Transmit a single byte using USI
   // Transmit start bit (low)
-  USIDR = 0x00; // high bit zero
+  //TODO could shift out two bits, for 1 bit of pad, to simplify timing/shifting
+  USIDR = 0x00; // high bit zero, pin changes low immediately
   // clock out start bit
-  delay(HALF_BIT_TIME*2);
+  delay(BIT_TIME);

   // Clock out 8 data bits
+  // use counter, so that later we can use timer counter hardware for accurate timing
+  USISR = B00001000; // overflow interrupt cleared, clock preloaded with 8 (+8=overflow)
   USIDR = 0xAA;
-  // use counter, so that later we can use timer counter hardware for accurate timing
-  USISR = B00001000; // overflow interrupt disabled, clock preloaded with 8 (+8=overflow)
-  //do
-  for (i=0; i<8; i++)
+
+  do
+  //for (i=0; i<8; i++)
   {
-    delay(HALF_BIT_TIME);
-    USICR |= B00000010; //USICLK;
-    delay(HALF_BIT_TIME);
-    USICR &= ~ B00000010; //USICLK;
+    delay(BIT_TIME);
+    USICR |= B00000010; //1<<USICLK; // shift happens here
+    USICR &= ~ B00000010; //1<<USICLK;
   }
-  //while ((USICR & B01000000) == 0);
+  //while ((USISR & B01000000) == 0); // 1<<USIOIF
+  while ((USISR & 0x0F) != 0);

   // Clock out stop bit (high)
-  USIDR = 0x80;
-  delay(HALF_BIT_TIME*2);
+  USIDR = 0x80; // high bit one, pin changes immediately
+  delay(BIT_TIME);

   digitalWrite(LED_GREEN, LOW);
   delay(100);


faster calibration

faster calibration

--- sketches/acuratrak_3G/acuratrak_3G.ino
+++ sketches/acuratrak_3G/acuratrak_3G.ino
@@ -17,7 +17,7 @@
 const unsigned int RESOLUTION = 255;
 const unsigned int PWM_MIN = 93; // 1.25 V + 4 bits = 1.33 V
 const unsigned int PWM_MAX = 169; // 3.75 V - 4 bits = 1.69 V
-const unsigned int CALIBRATION_DELAY = 5000; // ms for each voltage interval
+const unsigned int CALIBRATION_DELAY = 1500; // ms for each voltage interval
 const unsigned int PWM_CENTER = (PWM_MAX + PWM_MIN) / 2; // start at zero of effective range from PWM_MIN to PWM_MAX

 /* --- Variables --- */


Added 'Connection: close' header to upload handler.

--- webservertask.ino
+++ webservertask.ino
@@ -633,7 +633,9 @@
     {
       return request->requestAuthentication();
     }
-    request->send( 200 );
+    AsyncWebServerResponse *response = request->beginResponse( 200, textHtmlHeader );
+    response->addHeader("Connection", "close");
+    request->send(response);
   },
   []( AsyncWebServerRequest * request, String filename, size_t index, uint8_t *data, size_t len, bool final )
   {


Bug fixed

Bug fixed

--- source/monkeyDAB/monkeyDAB_display.ino
+++ source/monkeyDAB/monkeyDAB_display.ino
@@ -51,7 +51,7 @@
   // Clear display buffer
   //
   Display.clearDisplay();
-  if(isDisplayOn) {
+  if(!isDisplayOn) {
     Display.display();
     return;
   }
@@ -182,7 +182,7 @@
   // Clear display buffer
   //
   Display.clearDisplay();
-  if(isDisplayOn) {
+  if(!isDisplayOn) {
     Display.display();
     return;
   }


Remove board with SD

Remove board with SD

--- examples/BoardWithSD/BoardWithSD.ino
+++ examples/BoardWithSD/BoardWithSD.ino
@@ -1,46 +0,0 @@
-#include <DSPI.h>
-#include <OBCI32_SD.h>
-#include <EEPROM.h>
-#include <OpenBCI_32bit_Library.h>
-#include <OpenBCI_32bit_Library_Definitions.h>
-
-// Booleans Required for SD_Card_Stuff.ino
-boolean addAccelToSD = false; // On writeDataToSDcard() call adds Accel data to SD card write
-boolean addAuxToSD = false; // On writeDataToSDCard() call adds Aux data to SD card write
-boolean SDfileOpen = false; // Set true by SD_Card_Stuff.ino on successful file open
-
-void setup() {
-  // Bring up the OpenBCI Board
-  board.begin();
-}
-
-void loop() {
-  board.loop();
-  if (board.streaming) {
-    if (board.channelDataAvailable) {
-      // Read from the ADS(s), store data, set channelDataAvailable flag to false
-      board.updateChannelData();
-
-      // Verify the SD file is open
-      if(SDfileOpen) {
-        // Write to the SD card
-        writeDataToSDcard(board.sampleCounter);
-      }
-
-      // Send standard packet with channel data
-      board.sendChannelData();
-    }
-  }
-
-  // Check the serial port for new data
-  if (board.hasDataSerial0()) {
-    // Read one char from the serial port
-    char newChar = board.getCharSerial0();
-
-    // Send to the sd library for processing
-    sdProcessChar(newChar);
-
-    // Send to the board library
-    board.processChar(newChar);
-  }
-}


demo real updates

demo real updates

--- examples/DemoReel100/DemoReel100.ino
+++ examples/DemoReel100/DemoReel100.ino
@@ -15,35 +15,42 @@
 #warning "Requires FastLED 3.1 or later; check github for latest code."
 #endif

-#define DATA_PIN    3
-//#define CLK_PIN   4
-#define LED_TYPE    WS2811
-#define COLOR_ORDER GRB
-#define NUM_LEDS    64
+#define DATA_PIN    7
+#define CLK_PIN   14
+#define LED_TYPE    APA102
+#define COLOR_ORDER BGR
+#define NUM_LEDS    331
 CRGB leds[NUM_LEDS];

 #define BRIGHTNESS          96
 #define FRAMES_PER_SECOND  120

 void setup() {
-  delay(3000); // 3 second delay for recovery
+  delay(400); // 3 second delay for recovery

   // tell FastLED about the LED strip configuration
-  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
-  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
+  //FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
+  FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER,DATA_RATE_MHZ(12)>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

   // set master brightness control
   FastLED.setBrightness(BRIGHTNESS);
 }

+void bpm();
+void rainbow();
+void rainbowWithGlitter();
+void confetti();
+void sinelon();
+void juggle();

 // List of patterns to cycle through.  Each is defined as a separate function below.
 typedef void (*SimplePatternList[])();
-SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };
+SimplePatternList gPatterns = { rainbow/*, rainbowWithGlitter, confetti, sinelon, juggle, bpm */};

 uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
 uint8_t gHue = 0; // rotating "base color" used by many of the patterns
-
+
+  void nextPattern();
 void loop()
 {
   // Call the current pattern function once, updating the 'leds' array
@@ -73,18 +80,20 @@
   fill_rainbow( leds, NUM_LEDS, gHue, 7);
 }

-void rainbowWithGlitter()
-{
-  // built-in FastLED rainbow, plus some random sparkly glitter
-  rainbow();
-  addGlitter(80);
-}

 void addGlitter( fract8 chanceOfGlitter)
 {
   if( random8() < chanceOfGlitter) {
     leds[ random16(NUM_LEDS) ] += CRGB::White;
   }
+}
+
+
+void rainbowWithGlitter()
+{
+  // built-in FastLED rainbow, plus some random sparkly glitter
+  rainbow();
+  addGlitter(80);
 }

 void confetti()


deleted old arduair folder

deleted old arduair folder

--- src-arduino/arduair/arduair.ino
+++ src-arduino/arduair/arduair.ino
@@ -1,365 +0,0 @@
-//TODO: delete this file
-//libraries...
-#include "Wire.h"      //for I2C communication
-#include "DHT.h"       //for dht sensor
-#include <SPI.h>       //for Serial communication (with the SD card)
-#include <SD.h>        //SD card Library
-#include <SFE_BMP180.h>//Sparkfun BMP180 pressure Sensor Library
-//#include <VSync.h>
-
-#include <Adafruit_CC3000.h>//for CC3000 Wifi shield
-//#include <ccspi.h>
-//#include <string.h>
-
-//define...
-#define DS1307_ADDRESS 0x68 //clock pin
-#define DHTPIN 7            //DHT pin
-#define DHTTYPE DHT11
-#define ALTITUDE 1655.0
-
-#define ADAFRUIT_CC3000_IRQ   3  //CC3000 config
-#define ADAFRUIT_CC3000_VBAT  5
-#define ADAFRUIT_CC3000_CS    10
-Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,SPI_CLOCK_DIVIDER);
-#define WLAN_SSID       "myNetwork"           // cannot be longer than 32 characters!
-#define WLAN_PASS       "myPassword"
-#define WLAN_SECURITY   WLAN_SEC_WPA2
-#define IDLE_TIMEOUT_MS  3000
-#define WEBSITE      "arduair.herokuapp.com"
-#define WEBPAGE      "/test/"
-uint32_t ip; //it is for the CC3000 but I don't know what it does.
-
-
-File myFile;//Defining one file  class
-
-//Configuration Variables for the program and sensors
-//String sensorName1,  sensorName2,  sensorName3,  sensorName4,  sensorName5;//nombres que aparecen en la tabla
-//int    sensorPin1,   sensorPin2,   sensorPin3,   sensorPin4,   sensorPin5;//el pin donde estara ubicado el sensor
-//String sensorModel1, sensorModel2, sensorMode3,  sensorModel4, sensorModel5;//modelo del sensor para cosas de calibracion
-
-int arduFrequency; //frecuencia de medicion
-int beginYear, beginMonth, beginDay, beginHour, beginMinute; //inicio y final del muestreo
-int endYear,  endMonth, endDay, endHour,     endMinute;
-
-DHT dht(DHTPIN, DHTTYPE); //DHT constructor
-SFE_BMP180 bmp;           //bmp constructor
-
-void setup() {
-  Serial.begin(9600);
-  Wire.begin();
-  dht.begin();
-  bmp.begin();
-  sdBegin();
-  wifiBegin();
-}
-
-void loop() {
-  Serial.print("LOOP");
-  wifiSend();
-}
-
-void tableWrite(){
-  //escribe en la SD, la tabla
-
-  myFile = SD.open("DATA.txt", FILE_WRITE); //abrir la SD
-  if (myFile){
-    int h = dht.readHumidity();   // 1* medir humedad
-    myFile.print(h);
-    myFile.print(",");
-
-    int t= dht.readTemperature(); // 2* medir temperatura
-    myFile.print(t);
-    myFile.print(",");
-
-    float p= readPressure();      // 3* medir presion
-    myFile.print(p);
-    myFile.print(",");
-
-    float co=mq7Read();           // 4* medir sensor 1 y transformar
-    myFile.print(co);
-    myFile.print(",");
-
-    // 5* medir sensor 2 y transformar
-    // 6* medir sensor 3 y transformar
-    // 7* medir sensor 4 y transformar
-    // 8* medir sensor 5 y transformar
-    //enviar a la tabla
-    myFile.println(" ");
-    myFile.close();
-  }
-}
-
-void putOnTable(float variable, int X,int Y){
-  //envia la informacion a la tabla
-}
-
-void transform(float c, float x, float x2){
-  //transforma los datos de los sensores
-}
-
-/////                   DS1307                   /////
-void readTime(){
-  //lee el tiempo
-  // http://bildr.org/2011/03/ds1307-arduino/
-}
-
-byte bcdToDec(byte val)  {
-// Convert binary coded decimal to normal decimal numbers
-  return ( (val/16*10) + (val%16) );
-}
-
-void printDate(){
-
-  // Reset the register pointer
-  Wire.beginTransmission(DS1307_ADDRESS);
-
-  byte zero = 0x00;
-  Wire.write(zero);
-  Wire.endTransmission();
-
-  Wire.requestFrom(DS1307_ADDRESS, 7);
-
-  int second = bcdToDec(Wire.read());
-  int minute = bcdToDec(Wire.read());
-  int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
-  int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
-  int monthDay = bcdToDec(Wire.read());
-  int month = bcdToDec(Wire.read());
-  int year = bcdToDec(Wire.read());
-
-  //print the date EG   3/1/11 23:59:59
-  Serial.print(month);
-  Serial.print("/");
-  Serial.print(monthDay);
-  Serial.print("/");
-  Serial.print(year);
-  Serial.print(" ");
-  Serial.print(hour);
-  Serial.print(":");
-  Serial.print(minute);
-  Serial.print(":");
-  Serial.println(second);
-}
-/////                   BMP180                   /////
-float readPressure(){
- char state;
- double T,P,p0,a;
-  // Loop here getting pressure readings every 10 seconds.
-  state = bmp.startTemperature();
-  if (state != 0)
-  {
-    delay(state);
-    state = bmp.getTemperature(T);
-    if (state != 0)
-    {
-      state = bmp.startPressure(3);
-      if (state != 0)
-      {
-        delay(state);
-        state = bmp.getPressure(P,T);
-        if (state != 0)
-        {
-          // Print out the measurement:
-          //Serial.print("absolute pressure: ");
-          Serial.print(P*0.750061561303,2);
-          //Serial.println(" mmHg");
-
-          return P;
-        }
-        //else Serial.println("error retrieving pressure measurement\n");
-      }
-      //else Serial.println("error starting pressure measurement\n");
-    }
-    //else Serial.println("error retrieving temperature measurement\n");
-  }
-  //else Serial.println("error starting temperature measurement\n");
-
-  delay(5000);  // Pause for 5 seconds.
-}
-/////                   MQ7Sensor                   /////
-float mq7Read(){
-  int sensorValue = analogRead(0);       // read analog input pin 0
-  Serial.println(sensorValue, DEC);  // prints the value read
-  delay(100);// wait 100ms for next reading
-
-  float finalValue =sensorValue;
-  return finalValue;
-}
-/////                   MQ4Sensor                   /////
-float mq4Read(){
-  int sensorValue = analogRead(0);       // read analog input pin 0
-  Serial.println(sensorValue, DEC);  // prints the value read
-  delay(100);// wait 100ms for next reading
-
-  float finalValue =sensorValue;
-  return finalValue;
-}
-/////                   MQ131Sensor                   /////
-float mq131Read(){
-  int sensorValue = analogRead(0);       // read analog input pin 0
-  Serial.println(sensorValue, DEC);  // prints the value read
-  delay(100);// wait 100ms for next reading
-
-  float finalValue =sensorValue;
-  return finalValue;
-}
-/////                   SD CARD                   /////
-void sdBegin(){
-  if (!SD.begin(4)) {
-    //Serial.println("SD failed!");
-    return;
-  }
-  //Serial.println("SD done.");
-}
-//void getConfig(){
-//  //http://p3nlhclust404.shr.prod.phx3.secureserver.net/SharedContent/redirect_0.html
-//  myFile = SD.open("DATA.txt", FILE_READ);
-//  char character;
-//  String settingName;
-//  String settingValue;
-//    if (myFile) {
-//    while (myFile.available()) {
-//    character = myFile.read();
-//    while((myFile.available()) && (character != '[')){
-//    character = myFile.read();
-//    }
-//    character = myFile.read();
-//    while((myFile.available()) && (character != '=')){
-//    settingName = settingName + character;
-//    character = myFile.read();
-//    }
-//    character = myFile.read();
-//    while((myFile.available()) && (character != ']')){
-//    settingValue = settingValue + character;
-//    character = myFile.read();
-//    }
-//    if(character == ']'){
-//
-//    /*
-//    //Debuuging Printing
-//    Serial.print("Name:");
-//    Serial.println(settingName);
-//    Serial.print("Value :");
-//    Serial.println(settingValue);
-//    */
-//
-//    // Apply the value to the parameter
-//    //applySetting(settingName,settingValue);
-//    // Reset Strings
-//    settingName = "";
-//    settingValue = "";
-//    }
-//    }
-//    // close the file:
-//    myFile.close();
-//  }
-//}
-
-//void applySetting(String set, String valString){
-//  int val=valString.toInt();
-//  if (set == "frecuency") {
-//    arduFrequency=val;
-//  }
-//
-//  //begin parameters
-//  else if (set == "beginYear") {
-//    beginYear=val;
-//  }
-//  else if (set == "beginMonth") {
-//    beginMonth=val;
-//  }
-//  else if (set == "beginDay") {
-//    beginDay=val;
-//  }
-//  else if (set == "beginHour") {
-//    beginHour=val;
-//  }
-//  else if (set == "beginMinute") {
-//    beginMinute=val;
-//  }
-//
-//  //end parameters
-//  else if (set == "endYear") {
-//    endYear=val;
-//  }
-//  else if (set == "endMonth") {
-//    endMonth=val;
-//  }
-//  else if (set == "endDay") {
-//    endDay=val;
-//  }
-//  else if (set == "endHour") {
-//    endHour=val;
-//  }
-//  else if (set == "endMinute") {
-//    endMinute=val;
-//  }
-//  else{
-//    //Serial.println("the value " + set +" doesn´t exist in the config file");
-//  }
-//
-//}
-void wifiBegin(){
-  //CC3000 Initializing..
-  //Serial.println(F("\nwifi Begin"));
-  if (!cc3000.begin())
-  {
-    //Serial.println(F("Wifi_Failed"));
-    while(1);
-  }
-  //CC3000 Connecting...
-  //Serial.print(F("Connecting ")); Serial.println(WLAN_SSID);
-  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
-    //Serial.println(F("Failed!"));
-    while(1);
-  }
-  //Serial.println(F("Connected!"));
-
-  /* Wait for DHCP to complete */
-  //Serial.println(F("Request DHCP"));
-  while (!cc3000.checkDHCP())
-  {
-    delay(100); // ToDo: Insert a DHCP timeout!
-  }
-
-  /* Display the IP address DNS, Gateway, etc. */
-
-  ip = 0;
-  // Try looking up the website's IP address
-  Serial.print(WEBSITE); Serial.print(F(" -> "));
-  while (ip == 0) {
-    if (! cc3000.getHostByName(WEBSITE, &ip)) {
-      Serial.println(F("Couldn't resolve!"));
-    }
-    delay(500);
-  }
-
-  cc3000.printIPdotsRev(ip);
-}
-void wifiSend(){
-  //send the GET request
-  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
-  if (www.connected()) {
-    www.fastrprint(F("GET "));
-    www.fastrprint(WEBPAGE);
-    www.fastrprint(F(" HTTP/1.1\r\n"));
-    www.fastrprint(F("Host: ")); www.fastrprint(WEBSITE); www.fastrprint(F("\r\n"));
-    www.fastrprint(F("\r\n"));
-    www.println();
-  } else {
-    //Serial.println(F("Connection failed"));
-    return;
-  }
-  /* Read data until either the connection is closed, or the idle timeout is reached. */
-  unsigned long lastRead = millis();
-  while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
-    while (www.available()) {
-      char c = www.read();
-      Serial.print(c);
-      lastRead = millis();
-    }
-  }
-  //Serial.println(F("\n\nDisconnecting"));
-  //cc3000.disconnect();
- delay(10000);
-}


Adding cal procedure comment, adjusted color to yellow.

--- sketch/CurieDice/CurieDice.ino
+++ sketch/CurieDice/CurieDice.ino
@@ -262,11 +262,21 @@

 void diceCal()
 {
+  // Calibration procedure:
+  //  Die display will request user to orient die with requested face up.
+  //  User will have 6 seconds to do this for each face.  The display will go from RED -> YELLOW -> GREEN.
+  //  After the 6 seconds, the orientation is read and assigned to that face.
+  //  Tip: Notice the sequence being requested below in face[].
+  //       It is easiest to power on dice with logo & display facing you, upright so top value is 5 which is the first requested face.
+  //       Then, rotate die counter clockwise with logo continue to face you.  That would be 4, 2, 3.
+  //       Then, logo up is 1.
+  //       Then, logo down is 6.
+
   int face[] = {5, 4, 2, 3, 1, 6};
   for (int i=0; i<6; i++) {
     int f = face[i];
     pix.disp(orientDisp[f], 0xf00, 3000);
-    pix.disp(orientDisp[f], 0x0ff, 2000);
+    pix.disp(orientDisp[f], 0xf60, 2000);
     pix.disp(orientDisp[f], 0x0f0, 1000);
     CurieIMU.readAccelerometer(vcurr[0], vcurr[1], vcurr[2]);
     signed char *t = orientable[i];


Fixed non working example: StringStartsWithEndsWith.ino

--- build/shared/examples/08.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino
+++ build/shared/examples/08.Strings/StringStartsWithEndsWith/StringStartsWithEndsWith.ino
@@ -42,7 +42,7 @@
   String sensorReading = "sensor = ";
   sensorReading += analogRead(A0);
   Serial.print (sensorReading);
-  if (sensorReading.endsWith(0)) {
+  if (sensorReading.endsWith("0")) {
     Serial.println(". This reading is divisible by ten");
   }
   else {


nano update / ir tx and rx

nano update / ir tx and rx

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-nano/_04-mqtt-lcd-dust-sensor-nano.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-nano/_04-mqtt-lcd-dust-sensor-nano.ino
@@ -3,6 +3,38 @@

 IRsend irsend;

+/*
+ Standalone Sketch to use with a Arduino UNO and a
+ Sharp Optical Dust Sensor GP2Y1010AU0F
+*/
+
+// ------------------------------------------
+int measurePin = A6; //Connect dust sensor to Arduino A6 pin
+int ledPower = 2;   //Connect 3 led driver pins of dust sensor to Arduino D2
+
+// A6  : DUST IN
+// D2  : DUST OUT
+//
+// D3  : IR OUT
+//
+// D6  : IR IN
+// D7  : OUT GND
+// D8  : OUT VCC
+//
+// D12 : OUT GND
+// ------------------------------------------
+
+
+int samplingTime = 280;
+int deltaTime = 40;
+int sleepTime = 9680;
+
+int voMeasured = 0;
+float calcVoltage = 0;
+float dustDensity = 0;
+
+// ------------------------------------------
+// IR
 const int AC_TYPE  = 0;
 // 0 : TOWER
 // 1 : WALL
@@ -24,6 +56,7 @@
 // 2 : high
 // 3 : rotate

+// IR
 const int AC_FLOW_TOWER[4] = {0, 4, 6, 12};
 const int AC_FLOW_WALL[4]  = {0, 2, 4, 5};

@@ -36,24 +69,9 @@

 // IR

-/*
- Standalone Sketch to use with a Arduino UNO and a
- Sharp Optical Dust Sensor GP2Y1010AU0F
-*/
-
-int measurePin = A6; //Connect dust sensor to Arduino A0 pin
-int ledPower = 2;   //Connect 3 led driver pins of dust sensor to Arduino D2
-
-int samplingTime = 280;
-int deltaTime = 40;
-int sleepTime = 9680;
-
-int voMeasured = 0;
-float calcVoltage = 0;
-float dustDensity = 0;
-
-// IR
-
+// ------------------------------------------
+
+// IR
 void ac_send_code(unsigned long code)
 {
   Serial.print("code to send : ");
@@ -162,6 +180,14 @@
   digitalWrite(ledPower, HIGH); // turn the LED off
   delayMicroseconds(sleepTime);

+// ------------------------------------------
+/* test
+  ac_activate(25, 1);
+  delay(5000);
+  ac_activate(27, 0);
+  delay(5000);
+*/
+
   if ( r != o_r) {

     /*
@@ -246,7 +272,9 @@

     o_r = r ;
   }
+
   delay(100);
+
 }

 void requestEvent()