KAKU smart licht begin

KAKU smart licht begin

--- Arduino/KAKUSender/KAKUSender.ino
+++ Arduino/KAKUSender/KAKUSender.ino
@@ -2,6 +2,7 @@
 #include "SocketIOClient.h"
 #include "Ethernet.h"
 #include "SPI.h"
+#include <Time.h>
 #include <string.h>

 // Used for the KAKU remote functionality
@@ -9,6 +10,22 @@
 const int transmitterPin = 7;
 const int transmitterPeriod = 254;

+// Used for smart lights
+const byte ldrPin = A0;
+const short numValues = 3;
+const short timeFrameBefore = 30;
+const short timeFrameAfter = 90;
+
+// Smart learning variables
+short lightThresholds[numValues];
+short lightThreshold = 200;
+
+short minutes[numValues];
+short minutesThreshold;
+
+byte timeArrayPosition = 0;
+
+// KAKU transmitter
 NewRemoteTransmitter transmitter(transmitterAddress, transmitterPin, transmitterPeriod);

 // Ethernet details
@@ -20,59 +37,88 @@

 void setup() {
   Serial.begin(57600);
-
+
   // Init the Ethernet shield
   Ethernet.begin(mac);
-
+
   // Connect!
   if (!client.connect(hostname, port))
     Serial.println("Not connected.");
-
+  else
+    Serial.println("Connected.");
+
   // Catch any received data
   client.setDataArrivedDelegate(onData);
-
+
   // Second handshake
   client.send("Say welcome");
 }

 void loop() {
+  smartCheck();
   client.monitor();
 }

 // Websocket message handler
 void onData(SocketIOClient client, char *data) {
   int lightNumber;
-
+
   // Light 1
-  if(strstr(data, "1")) {
+  if (strstr(data, "1")) {
     lightNumber = 0;
   }
-
+
   // Light 2
-  if(strstr(data, "2")) {
+  if (strstr(data, "2")) {
     lightNumber = 1;
   }
-
+
   // Light 3
-  if(strstr(data, "3")) {
+  if (strstr(data, "3")) {
     lightNumber = 2;
   }
-
+
   // Light 4
-  if(strstr(data, "4")) {
+  if (strstr(data, "4")) {
     lightNumber = 3;
   }
-
+
   // Turn on the light
-  if(strstr(data, "on")) {
+  if (strstr(data, "on")) {
     transmitter.sendUnit(lightNumber, true);
   } else { // Turn off
     transmitter.sendUnit(lightNumber, false);
   }
 }

-void timeUpdate(char *timeString)
-{
+// Check for turing on the light using the smart function
+void smartCheck() {
+  Serial.println("Check");
+  short currentLightValue = analogRead(ldrPin);
+  if (currentLightValue <= lightThreshold) {
+    Serial.println("On");
+    transmitter.sendGroup(true);
+    transmitter.sendUnit(0, true);
+    transmitter.sendUnit(1, true);
+    transmitter.sendUnit(2, true);
+    transmitter.sendUnit(3, true);
+  }
+
+}
+
+void updateSmartValues() {
+  short onTimeMinutes;
+  for (int i = 0; i < numValues; i++) {
+    onTimeMinutes += minutes[i];
+    lightThreshold += lightThresholds[i];
+  }
+  onTimeMinutes /= numValues;
+  lightThreshold /= numValues;
+}
+
+// Sets the current date to the data in the string
+// The used format is "hours,minutes,seconds,day,month,year"
+void timeUpdate(char *timeString) {
   char *p = timeString;
   char *str;
   byte second, minute, hour, day, month;
@@ -90,5 +136,5 @@
   if ((str = strtok_r(p, ",", &p)) != NULL)
     year = atoi(str);

-  setTime(hour,minute,second,day,month,year);
+  setTime(hour, minute, second, day, month, year);
 }


Last working version

Last working version

--- Arduino/_firmware2/_firmware2.ino
+++ Arduino/_firmware2/_firmware2.ino
@@ -140,7 +140,7 @@
 //A is the calibration slope in levels / cm
 //B is the reference level
 double A_water_rate = 12.125;
-double B_water_reference_level = 789.25;
+double B_water_reference_level = 845;
 double vesicle_diameter_cm = 11.43;//4.5 inch x 2.54 cm / inch
 double vesicle_area_cm_2 = (3.14159) * (vesicle_diameter_cm / 2) * (vesicle_diameter_cm / 2);

@@ -232,7 +232,7 @@
   analogReference(EXTERNAL); //Important or we send 5V into the 3V3 pin!

   // Tachometer setup
-  pinMode(solenoidValvePin,OUTPUT);
+  pinMode(solenoidValvePin,OUTPUT);\
   digitalWrite (TACH, HIGH);  // internal pull-up resistor built in :-)
   attachInterrupt (digitalPinToInterrupt(2), revolution, RISING);  // attach interrupt handler for tachometer
   attachInterrupt (digitalPinToInterrupt(3), flowCalc, RISING);  // attach interrupt handler for flow meter
@@ -482,9 +482,9 @@
     data += ",";
     data += rpm;
     data += ",";
-//    data += load1_in_lbs; //Load Washers
-    data += ",";
-//    data += load2_in_lbs; //Load Washers
+    data += load1_in_lbs; //Load Washers
+    data += ",";
+    data += load2_in_lbs; //Load Washers
     data += ",";
     data += flow_rate_cc_per_sec; //This is for the level sensor rate
     data += ",";
@@ -549,18 +549,18 @@
 //      counter++;
 //    }

-  Serial.println("DATA = " + data);
-  Serial.println("MIC = " + data_mic);
-  Serial.println("X = " + data_x);
-  Serial.println("Y = " + data_y);
-  Serial.println("Z = " + data_z);
-
-
-//  Serial.print(data);
-//  Serial.print(data_mic);
-//  Serial.print(data_x);
-//  Serial.print(data_y);
-//  Serial.print(data_z);
+//  Serial.println("DATA = " + data);
+//  Serial.println("MIC = " + data_mic);
+//  Serial.println("X = " + data_x);
+//  Serial.println("Y = " + data_y);
+//  Serial.println("Z = " + data_z);
+
+
+  Serial.print(data);
+  Serial.print(data_mic);
+  Serial.print(data_x);
+  Serial.print(data_y);
+  Serial.print(data_z);

 //  //This loop prints the data from the FFT. The waits
 //for (int i = 0; i < 50; i++){


v1 TODO list

v1 TODO list

--- sensorSlave/sensorSlave.ino
+++ sensorSlave/sensorSlave.ino
@@ -1,9 +1,17 @@
 #include <Wire.h>

+  //TODO
+  // read analog pins
+  // reverse current direction at each measure
+  //
+  // For test readablity replace count, with currentMillis/numberofcalls/3/4/5/6
+  //
+  // make adress configurable with digital pins
+  // write read frequency via I2C
+  // read frequency via I2C
+
 void setup()
-{
-
-  //TODO make adress configurable with digital pins
+{
   Wire.begin(2);
   Wire.onRequest(requestEvent);
 }


Serial.println overkill...

Serial.println overkill...

--- Arduino/KAKUSender/KAKUSender.ino
+++ Arduino/KAKUSender/KAKUSender.ino
@@ -146,7 +146,7 @@
     //Serial.println("Check");
     short currentLightValue = analogRead(ldrPin);
     if (currentLightValue <= lightThreshold) {
-      Serial.println("Dark");
+      // Serial.println("Dark");

       short curTimeMinutes = hour() * 60 + minute();
       if (curTimeMinutes > (minutesThreshold - timeFrameBefore) && curTimeMinutes < (minutesThreshold + timeFrameAfter)) {


Add multiple independent GPIO sending support via MQTT. (#661)

Experimental code for #645 feature request.

Note: Only tested with just a single transmit channel/gpio.


Cleaning up code

Cleaning up code

--- examples/RGBCalibrate/RGBCalibrate.ino
+++ examples/RGBCalibrate/RGBCalibrate.ino
@@ -41,7 +41,7 @@
    	LEDS.setBrightness(255);

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


F() Macro demo

F() Macro demo

--- examples/Widgets/Terminal/Terminal.ino
+++ examples/Widgets/Terminal/Terminal.ino
@@ -40,9 +40,9 @@
   // This will print Blynk Software version to the Terminal Widget when
   // your hardware gets connected to Blynk Server
   terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
-  terminal.println("-------------");
-  terminal.println("Type 'Marco' and get a reply, or type");
-  terminal.println("anything else and get it printed back.");
+  terminal.println(F("-------------"));
+  terminal.println(F("Type 'Marco' and get a reply, or type"));
+  terminal.println(F("anything else and get it printed back."));
   terminal.flush();
 }


Optimizations.

Optimizations.

--- arduino/osc_binary_spi/osc_binary_spi.ino
+++ arduino/osc_binary_spi/osc_binary_spi.ino
@@ -1,15 +1,24 @@
-int startPin = 2;
-int busyPin = 3;
-int clockPin = 13;
-int dataPin = 12;
+
+#define STARTPIN 2
+#define BUSYPIN 3
+#define CLOCKPIN 13
+#define DATAPIN 12
+
+#define DEBUG false
+
+#if DEBUG
+#define toread 4
+#else
+#define toread 512
+#endif

 byte clr;

 void setup() {
-  pinMode(startPin, OUTPUT);
-  pinMode(busyPin, INPUT);
-  pinMode(clockPin, OUTPUT);
-  pinMode(dataPin, INPUT);
+  pinMode(STARTPIN, OUTPUT);
+  pinMode(BUSYPIN, INPUT);
+  pinMode(CLOCKPIN, OUTPUT);
+  pinMode(DATAPIN, INPUT);
   pinMode(10, OUTPUT);

   // SPCR = 01010000
@@ -32,9 +41,6 @@
   return SPDR;                    // return the received byte
 }

-int iter = 0;
-boolean DEBUG = false;
-
 void loop() {
   boolean tostart = DEBUG;
   if (!DEBUG && Serial.available() > 0) {
@@ -51,18 +57,14 @@
       Serial.println("read starting");

     // Throw out first bit
-    digitalWrite(startPin, HIGH);
-    digitalWrite(startPin, LOW);
+    digitalWrite(STARTPIN, HIGH);
+    digitalWrite(STARTPIN, LOW);

-    delayMicroseconds(5);
+    //delayMicroseconds(5);

-    while(digitalRead(busyPin)) {}
+    while(digitalRead(BUSYPIN)) {}

-    delayMicroseconds(5);
-
-    int toread = 512;
-    if (DEBUG)
-      toread = 4;
+    //delayMicroseconds(5);

     for (int j = 0; j < toread*2; j++) {


Corrected print to telem for sensor time

--- DaguRover5AutoNav/SensorReads.ino
+++ DaguRover5AutoNav/SensorReads.ino
@@ -85,7 +85,7 @@

     //compass_update();
     //getInclination();
-Serial.println(millis()-start);
+telem.println(millis()-start);

 }


Missed a print to println -- fixed!

Missed a print to println -- fixed!

--- firmware/examples/SparkTimeExample.ino
+++ firmware/examples/SparkTimeExample.ino
@@ -31,7 +31,7 @@
 	Serial.println(timeStr);
       } else if (sec == 40) {
 	// Including current timezone
-	Serial.print(rtc.ISODateString(currentTime));
+	Serial.println(rtc.ISODateString(currentTime));
       } else if (sec == 50) {
 	// UTC or Zulu time
 	Serial.println(rtc.ISODateUTCString(currentTime));


Fix typos #20

Fix typos #20

--- examples/SSD1306Demo/SSD1306Demo.ino
+++ examples/SSD1306Demo/SSD1306Demo.ino
@@ -66,7 +66,7 @@
   ui.setIndicatorDirection(LEFT_RIGHT);

   // You can change the transition that is used
-  // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN
+  // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_UP, SLIDE_DOWN
   ui.setFrameAnimation(SLIDE_LEFT);

   // Add frames
@@ -131,11 +131,11 @@

   // The coordinates define the center of the text
   display->setTextAlignment(TEXT_ALIGN_CENTER);
-  display->drawString(64 + x, 22, "Center aligned (64,22)");
+  display->drawString(64 + x, 22 + y, "Center aligned (64,22)");

   // The coordinates define the right end of the text
   display->setTextAlignment(TEXT_ALIGN_RIGHT);
-  display->drawString(128 + x, 33, "Right aligned (128,33)");
+  display->drawString(128 + x, 33 + y, "Right aligned (128,33)");
 }

 void drawFrame4(SSD1306 *display, SSD1306UiState* state, int16_t x, int16_t y) {
@@ -144,5 +144,5 @@
   // Currently only spaces and "-" are allowed for wrapping
   display->setTextAlignment(TEXT_ALIGN_LEFT);
   display->setFont(ArialMT_Plain_10);
-  display->drawStringMaxWidth(0 + x, 10 + y, 128, "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore.");
+  display->drawStringMaxWidth(0 + x, 10 + y, 128, "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore.");
 }


Remove OLED message from boot sequence.

Remove OLED message from boot sequence.

Message was shown for < 1 second.

--- aquacontrol2.ino
+++ aquacontrol2.ino
@@ -142,10 +142,6 @@
   }
   initNTP();
   setupWebServer();
-
-  OLED.clear();
-  OLED.drawString( 64, 30, F("Ready." ) );
-  OLED.display();

   if ( defaultTimersAreLoaded() ) {
     Serial.println( "Timers loaded from SPIFFS." );


added most of server config form

added most of server config form

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -29,6 +29,7 @@
 ESP8266WebServer webServer(80);
 String apSSIDStr = "WaterElf-" + String(ESP.getChipId());
 const char* apSSID = apSSIDStr.c_str();
+String svrAddr = ""; // address of a local server

 /////////////////////////////////////////////////////////////////////////////
 // page generation stuff ////////////////////////////////////////////////////
@@ -46,6 +47,7 @@
   "

\n"
   "
Join a wifi network
\n"
   "
Wifi status
\n"
+  "
Configure server location
\n"
   "
\n"
     "<form method='POST' action='actuate'>\n"
     "Operate actuator: "
@@ -64,7 +66,7 @@

 /////////////////////////////////////////////////////////////////////////////
 // data monitoring stuff ////////////////////////////////////////////////////
-const boolean SEND_DATA = false;  // turn of posting of data if required here
+const boolean SEND_DATA = true;  // turn of posting of data if required here
 const int MONITOR_POINTS = 60; // number of data points to store
 struct monitor_t {
   unsigned long timestamp;
@@ -86,10 +88,9 @@
 // temperature sensor stuff /////////////////////////////////////////////////
 OneWire ds(2); // DS1820 on pin 2 (a 4.7K resistor is necessary)
 DallasTemperature tempSensor(&ds);  // pass through reference to library
-//void getTemperature(float* waterCelsius);
+void getTemperature(float* waterCelsius);
 boolean GOT_TEMP_SENSOR = false;
-// array to hold device address
-DeviceAddress tempAddr;
+DeviceAddress tempAddr; // array to hold device address

 /////////////////////////////////////////////////////////////////////////////
 // humidity sensor stuff ////////////////////////////////////////////////////
@@ -149,7 +150,7 @@

   if(loopCounter == TICK_MONITOR) {
     updateSensorData(monitorData);
-    delay(100);
+    delay(250);
     if(SEND_DATA) postSensorData(monitorData);
   }
   if(loopCounter == TICK_WIFI_DEBUG) {
@@ -195,7 +196,9 @@

   webServer.on("/wifi", handle_wifi);
   webServer.on("/wifistatus", handle_wifistatus);
-  webServer.on("/chz", handle_chz);
+  webServer.on("/serverconf", handle_serverconf);
+  webServer.on("/wfchz", handle_wfchz);
+  webServer.on("/svrchz", handle_svrchz);
   webServer.on("/data", handle_data);
   webServer.on("/actuate", handle_actuate);
   webServer.begin();
@@ -257,7 +260,7 @@
   } else {
     Serial.print(n);
     Serial.println(" networks found");
-    f += "<form method='POST' action='chz'> ";
+    f += "<form method='POST' action='wfchz'> ";
     for(int i = 0; i < n; ++i) {
       // print SSID and RSSI for each network found
       Serial.print(i + 1);
@@ -332,8 +335,8 @@
   toSend += pageFooter;
   webServer.send(200, "text/html", toSend);
 }
-void handle_chz() {
-  Serial.println("serving page at /chz");
+void handle_wfchz() {
+  Serial.println("serving page at /wfchz");
   String toSend = pageTop;
   toSend += ": joining wifi network";
   toSend += pageTop2;
@@ -368,6 +371,42 @@
       Serial.println("set hostname failed");
     */
   }
+
+  toSend += pageFooter;
+  webServer.send(200, "text/html", toSend);
+}
+String genServerConfForm() {
+  String f = pageTop;
+  f += ": Server Config";
+  f += pageTop2;
+  f += "
Configure a server

\n";
+
+  f += "<form method='POST' action='svrchz'> ";
+  f += "
IP address: <input type='textarea' name='svraddr'>

 ";
+  f += "<input type='submit' value='Submit'></form>
";
+
+  f += pageFooter;
+  return f;
+}
+void handle_serverconf() {
+  Serial.println("serving page at /serverconf");
+  String toSend = genServerConfForm();
+  webServer.send(200, "text/html", toSend);
+}
+void handle_svrchz() {
+  Serial.println("serving page at /svrchz");
+  String toSend = pageTop;
+  toSend += ": server configured";
+  toSend += pageTop2;
+
+  for(uint8_t i = 0; i < webServer.args(); i++) {
+    if(webServer.argName(i) == "svraddr")
+      svrAddr = webServer.arg(i);
+  }
+
+  // TODO persist the config
+
+  // TODO some way of verifying if server config worked

   toSend += pageFooter;
   webServer.send(200, "text/html", toSend);
@@ -470,6 +509,8 @@
   Serial.println(envelope);

   IPAddress couchServer(10,0,0,24);
+  //TODO parse svrAddr
+  //IPAddress couchServer(svrAddr);
   WiFiClient couchClient;
   Serial.print("couchServer: ");
   Serial.println(ip2str(couchServer));
@@ -532,14 +573,11 @@
   }
 }
 void getTemperature(float* waterCelsius) {
-  float _waterCelsius = *waterCelsius;
   tempSensor.requestTemperatures(); // Send the command to get temperatures
-  //Serial.println("Temp requested from sensor");
-  _waterCelsius = (tempSensor.getTempC(tempAddr));
+  *waterCelsius = tempSensor.getTempC(tempAddr);
   Serial.print("Temp: ");
-  Serial.print(_waterCelsius);
+  Serial.print(*waterCelsius);
   Serial.println(" C, ");
-  *waterCelsius = _waterCelsius;
   return;
 }
 void getHumidity(float* airCelsius, float* airHumid) {


added triplicate water level sensing

added triplicate water level sensing

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -100,6 +100,9 @@
   float airHumid;
   uint16_t lux;
   float pH;
+  long waterLevel1;
+  long waterLevel2;
+  long waterLevel3;
 };
 monitor_t monitorData[MONITOR_POINTS];
 int monitorCursor = 0;
@@ -153,6 +156,14 @@
 const int PUMP3_MCP_PIN = 7;

 /////////////////////////////////////////////////////////////////////////////
+// level sensing stuff //////////////////////////////////////////////////////
+const int LEVEL_TRIG_PIN=12;
+const int LEVEL_ECHO_PIN1=13;
+const int LEVEL_ECHO_PIN2=14;
+const int LEVEL_ECHO_PIN3=16;
+boolean GOT_LEVEL_SENSOR = false;  // we'll change later if we detect sensor
+
+/////////////////////////////////////////////////////////////////////////////
 // config utils /////////////////////////////////////////////////////////////
 boolean getCloudShare();
 void setCloudShare(boolean b);
@@ -205,6 +216,7 @@

   if(loopCounter == TICK_MONITOR) {
     updateSensorData(monitorData);
+    // TODO pump logic
     delay(500); // TODO a better way?!
   }
   if(loopCounter == TICK_WIFI_DEBUG) {
@@ -562,7 +574,7 @@
     tempSensor.setResolution(tempAddr, 12); // 12 bit res (DS18B20 does 9-12)
   }

-  dht.begin();    // Start the humidity and air temperature sensor
+  dht.begin();    // start the humidity and air temperature sensor
   float airHumid = dht.readHumidity();
   float airCelsius = dht.readTemperature();
   if (isnan(airHumid) || isnan(airCelsius)) {
@@ -570,6 +582,13 @@
   } else {
     GOT_HUMID_SENSOR = true;
   }
+
+  // configure the level sensors
+  pinMode(LEVEL_TRIG_PIN, OUTPUT);
+  pinMode(LEVEL_ECHO_PIN1, INPUT);
+  pinMode(LEVEL_ECHO_PIN2, INPUT);
+  pinMode(LEVEL_ECHO_PIN3, INPUT);
+  GOT_LEVEL_SENSOR = true;

   Wire.begin();
   byte error;
@@ -612,7 +631,7 @@
     monitorSize++;
   now->timestamp = millis();
   if(GOT_TEMP_SENSOR)
-    getTemperature(&(now->waterCelsius));
+    getTemperature(&now->waterCelsius);

   if(GOT_HUMID_SENSOR)
     getHumidity(&now->airCelsius, &now->airHumid);
@@ -622,6 +641,12 @@

   if(GOT_PH_SENSOR)
     getPH(&now->pH);
+
+  if(GOT_LEVEL_SENSOR) {
+    getLevel(LEVEL_ECHO_PIN1, &now->waterLevel1);
+    getLevel(LEVEL_ECHO_PIN2, &now->waterLevel2);
+    getLevel(LEVEL_ECHO_PIN3, &now->waterLevel3);
+  }

   if(SEND_DATA) postSensorData(&monitorData[monitorCursor]);

@@ -730,6 +755,28 @@
   Serial.println(" pH");
   return;
 }
+void getLevel(int echoPin, long* waterLevel) {
+  long duration;
+  int TIMEOUT = 15000;                          // how long to wait for pulse
+
+  digitalWrite(LEVEL_TRIG_PIN, LOW);            // prepare for ping
+  delayMicroseconds(2);
+  digitalWrite(LEVEL_TRIG_PIN, HIGH);           // start ping
+  delayMicroseconds(10);                        // allow 10ms ping
+  digitalWrite(LEVEL_TRIG_PIN, LOW);            // stop ping
+  duration = pulseIn(echoPin, HIGH, TIMEOUT);   // wait for response
+
+  (*waterLevel) = (duration/2) / 29.1;
+
+  Serial.print("Water Level: ");
+  if ((*waterLevel) >= 200 || (*waterLevel) <= 0){
+    Serial.println("is out of range!");
+  } else {
+    Serial.print(*waterLevel);
+    Serial.println(" cm, ");
+  }
+  return;
+}

 /////////////////////////////////////////////////////////////////////////////
 // config utils /////////////////////////////////////////////////////////////


Swaped joystick axis controls

Swaped joystick axis controls

--- MotorLab/MotorLab.ino
+++ MotorLab/MotorLab.ino
@@ -171,6 +171,9 @@
             digitalWrite(motors[iMotor].iSignalAddress[3], 1);
             break;

+#define STEP_OFF 99
+
+        case STEP_OFF:
         default:
             digitalWrite(motors[iMotor].iSignalAddress[0], 0);
             digitalWrite(motors[iMotor].iSignalAddress[1], 0);
@@ -225,78 +228,99 @@
     Serial.print("] \n");
 }

+#define JOY_THRESH_LO 200
+#define JOY_THRESH_HI 850
+void setMotorDir(int iJoy, int isX, int iMotor, int iDir)
+{
+    if( isX )
+    {
+        if (iDir > 0)
+        {
+            if      (joy[iJoy].iXVal > JOY_THRESH_HI) { motors[iMotor].iDirection =  1; }
+            else if (joy[iJoy].iXVal < JOY_THRESH_LO) { motors[iMotor].iDirection = -1; }
+            else                                      { motors[iMotor].iDirection =  0; }
+        }
+        else
+        {
+            if      (joy[iJoy].iXVal > JOY_THRESH_HI) { motors[iMotor].iDirection = -1; }
+            else if (joy[iJoy].iXVal < JOY_THRESH_LO) { motors[iMotor].iDirection =  1; }
+            else                                      { motors[iMotor].iDirection =  0; }
+        }
+    }
+    else // is Y
+    {
+        if (iDir > 0)
+        {
+            if      (joy[iJoy].iYVal > JOY_THRESH_HI) { motors[iMotor].iDirection =  1; }
+            else if (joy[iJoy].iYVal < JOY_THRESH_LO) { motors[iMotor].iDirection = -1; }
+            else                                      { motors[iMotor].iDirection =  0; }
+        }
+        else
+        {
+            if      (joy[iJoy].iYVal > JOY_THRESH_HI) { motors[iMotor].iDirection = -1; }
+            else if (joy[iJoy].iYVal < JOY_THRESH_LO) { motors[iMotor].iDirection =  1; }
+            else                                      { motors[iMotor].iDirection =  0; }
+        }
+    }
+
+}
+
+
 void loop()
 {
     PollJoysticks();
     //debugJoy(0);
-
-    int i= 0;
-    int iMotor = 1;
-    if      (joy[i].iXVal > 900) { motors[iMotor].iDirection =  1; }
-    else if (joy[i].iXVal < 432) { motors[iMotor].iDirection = -1; }
-    else                         { motors[iMotor].iDirection =  0; }
-
-    iMotor = 0;
-    if      (joy[i].iYVal > 900) { motors[iMotor].iDirection =  1; }
-    else if (joy[i].iYVal < 432) { motors[iMotor].iDirection = -1; }
-    else                         { motors[iMotor].iDirection =  0; }
-
-
-    i = 1; iMotor = 2;
-    if      (joy[i].iYVal > 900) { motors[iMotor].iDirection =  1; }
-    else if (joy[i].iYVal < 432) { motors[iMotor].iDirection = -1; }
-    else                         { motors[iMotor].iDirection =  0; }
-
-    iMotor = 3;
-    if      (joy[i].iXVal > 900) { motors[iMotor].iDirection = -1; }
-    else if (joy[i].iXVal < 432) { motors[iMotor].iDirection =  1; }
-    else                         { motors[iMotor].iDirection =  0; }
+    #define XDIR 1
+    #define YDIR 0
+    #define JOY0 0
+    #define JOY1 1
+    #define MOTOR0 0
+    #define MOTOR1 1
+    #define MOTOR2 2
+    #define MOTOR3 3
+    #define DIRFWD 1
+    #define DIRREV 0
+
+    setMotorDir(JOY0, YDIR, MOTOR0, DIRFWD);
+
+
+    setMotorDir(JOY1, XDIR, MOTOR1, DIRFWD);
+
+    // int iMotor = 1;
+    // if      (joy[i].iXVal > 900) { motors[iMotor].iDirection =  1; }
+    // else if (joy[i].iXVal < 432) { motors[iMotor].iDirection = -1; }
+    // else                         { motors[iMotor].iDirection =  0; }
+    //
+    //
+    // iMotor = 2;
+
+    setMotorDir(JOY1, YDIR, MOTOR2, DIRFWD);
+    // if      (joy[i].iYVal > 900) { motors[iMotor].iDirection =  1; }
+    // else if (joy[i].iYVal < 432) { motors[iMotor].iDirection = -1; }
+    // else                         { motors[iMotor].iDirection =  0; }
+    //
+    // iMotor = 3;
+
+    setMotorDir(JOY1, YDIR, MOTOR3, DIRREV);
+
+    // if      (joy[i].iYVal > 900) { motors[iMotor].iDirection = -1; }
+    // else if (joy[i].iYVal < 432) { motors[iMotor].iDirection =  1; }
+    // else                         { motors[iMotor].iDirection =  0; }

     for (int i=0; i<4; i++)
     {
         if (motors[i].iDirection !=0)
         {

-           if      (motors[i].iDirection > 0) { if (++(motors[i].iStep) >=8){ motors[i].iStep = 0; } }
-           else if (motors[i].iDirection < 0) { if (--(motors[i].iStep) < 0){ motors[i].iStep = 7; } }
+           if      (motors[i].iDirection > 0) { if (++(motors[i].iStep) >=8){ motors[i].iStep = 0;        } }
+           else if (motors[i].iDirection < 0) { if (--(motors[i].iStep) < 0){ motors[i].iStep = 7;        } }
+           else                               {                               motors[i].iStep = STEP_OFF;   }

             debugFoo(i, motors[i].iStep, motors[i].iDirection);

             SetMotor(i, motors[i].iStep);
-
-        }
-
+        }
     }
     //delay(6 );
     //delayMicroseconds(1);
-
-
-
-
-/*
-    if (joy[0].iXVal > 900)
-    {
-        motors[iMotor].iDirection = 1;
-
-        SetMotor(iMotor, motors[iMotor].iStep);
-        delayMicroseconds(1000);
-    }
-    else if (joy[0].iXVal < 412)
-    {
-        motors[iMotor].iDirection = -1;
-        if (--(motors[iMotor].iStep) < 0){ motors[iMotor].iStep = 7; }
-        SetMotor(iMotor, motors[iMotor].iStep);
-        delayMicroseconds(1000);
-    }
-    else { motors[iMotor].iDirection = 0; }
-*/
-
-//debugJoyXY();
-
-    // if  (motors[0].bDirection == 1) { if (++(motors[0].iStep) >=8){ motors[0].iStep = 0; } }
-    // else                            { if (--(motors[0].iStep) < 0){ motors[0].iStep = 7; } }
-    //
-    //
-    // delayMicroseconds(2000);
-
-}
+}


this is the main file.

this is the main file.

--- MyBlinkySketch/MyBlinkySketch.ino
+++ MyBlinkySketch/MyBlinkySketch.ino
@@ -35,7 +35,7 @@
 uint8_t brightnesSteps[brightnessCount] = {93,70,40,15,5,15,40,70,93};
 uint8_t currentBrightness;
 uint8_t lastBrightness;
-//
+
 // For fading in a new sketch
 long lastTime;


Now the sketch sends command that make sense for Android

--- Arduino/Arduino.ino
+++ Arduino/Arduino.ino
@@ -55,7 +55,7 @@
     } else {
       Serial.print("*");
     }
-    sendToADK(millis(), millis(), millis());
+    sendToADKDelayed( random(0,2), random(0,4) + random(1,3)*100, random(150,152));
   }
   delay(DELAY);
 }
@@ -92,13 +92,13 @@
   delay(DELAY / 10);
 }

-void sendToADKDelayed() {
+void sendToADKDelayed(int command, int param1, int param2) {
   int time = millis();
-  if (time - last_send > 5000) {
+  if (time - last_send > 2000) {
     last_send = time;
     randomint = random(-1500, 1500);
     memset(outStringBuffer, 0, BUFFSIZE);
-    sprintf(outStringBuffer, "%d,%d,%d", randomint, randomint - 1000, randomint + 1000);
+    sprintf(outStringBuffer, "%d,%d,%d",command, param1, param2);
     memcpy(outBuffer, outStringBuffer, BUFFSIZE);
     adk.write(strlen(outStringBuffer), outBuffer);
     if (DEBUG_MODE) {


minor change 1

minor change 1

--- proj/hypercube/HCS/HCS.ino
+++ proj/hypercube/HCS/HCS.ino
@@ -204,72 +204,77 @@
   // already switching the inner shell though, don't want to figure that out
   EVERY_N_SECONDS(10) {
     oAnimCounter = (oAnimCounter + 1) % numAnimation;
+    if(oAnimCounter == 0) {
+      oPaletteCounter = (oPaletteCounter + 1) % numPalStyles;
+      if(oPaletteCounter == 0) {
+        gPaletteCounter = (gPaletteCounter+1)%numPalettes;
+      }
+    }
   }

   // Same deal for the inner shell
-  EVERY_N_SECONDS(125) {
-    iAnimCounter = (iAnimCounter + 1) % numAnimation;
-  }
-
-  // Update the global color palette. This is just the color scheme
-  // that we will then repackage to have different spacial distributions
-  EVERY_N_SECONDS(480) {
-    gPaletteCounter = (gPaletteCounter+1)%numPalettes;
-  }
+  //EVERY_N_SECONDS(125) {
+  //  iAnimCounter = (iAnimCounter + 1) % numAnimation;
+  //}
+
+  //// Update the global color palette. This is just the color scheme
+  //// that we will then repackage to have different spacial distributions
+  //EVERY_N_SECONDS(480) {
+  //  gPaletteCounter = (gPaletteCounter+1)%numPalettes;
+  //}
   updatePaletteScheme();

   // Update the palette style for the inner and outer shells. This
   // is basically how we package the given color palette.
-  EVERY_N_SECONDS(130) {
-    oPaletteCounter = (oPaletteCounter +1) % numPalStyles;
-  }
-  // For the inner palette, switch it up so that every other time it uses
-  // a white palette.
-  EVERY_N_SECONDS(190) {
-    //  The white black is no longer part of the usual rotation
-    // though since it alternates every time the timer is up.
-      iPaletteCounter = (iPaletteCounter + 1) % numPalStyles;
-  }
+  //EVERY_N_SECONDS(130) {
+  //  oPaletteCounter = (oPaletteCounter +1) % numPalStyles;
+  //}
+  //// For the inner palette, switch it up so that every other time it uses
+  //// a white palette.
+  //EVERY_N_SECONDS(190) {
+  //  //  The white black is no longer part of the usual rotation
+  //  // though since it alternates every time the timer is up.
+  //    iPaletteCounter = (iPaletteCounter + 1) % numPalStyles;
+  //}
   updateGPalette();

   // Add the random strobe to this list of animations since we aren't going to use it
   // for the overlays
-  //switch (iAnimCounter) {
-  //  case 0:
-  //    chase_straight(INNER, false);
-  //    break;
-  //  case 1:
-  //    shell_wrap(INNER, false, 0);
-  //    break;
-  //  case 2:
-  //    chase_spiral(INNER, 16, false);
-  //    break;
-  //  case 3:
-  //    shell_wrap(INNER, false, 1);
-  //    break;
-  //  case 4:
-  //    static uint8_t iOffset = 0;
-  //    EVERY_N_MILLISECONDS(100) {
-  //      iOffset++;
-  //    }
-  //    chase_spiral(INNER, iOffset, false);
-  //    break;
-  //  case 5:
-  //    shell_wrap(INNER, false, 2);
-  //    break;
-  //  case 6:
-  //    chase_mod(INNER, false);
-  //    break;
-  //  case 7:
-  //    shell_wrap(INNER, false, 3);
-  //    break;
-  //  case 8:
-  //    snow_anim(INNER, 0.3);
-  //    break;
-  //  case 9:
-  //    fill_shell(INNER);
-  //    break;
-  //}
+  switch (iAnimCounter) {
+    case 0:
+      chase_straight(INNER, false);
+      break;
+    case 1:
+      shell_wrap(INNER, false, 0);
+      break;
+    case 2:
+      chase_mod(INNER, 0, false);
+      break;
+    case 3:
+      chase_spiral_static(INNER, 16, false);
+      break;
+    case 4:
+      shell_wrap(INNER, false, 1);
+      break;
+    case 5:
+      chase_mod(INNER, 1, false);
+      break;
+    case 6:
+      chase_spiral_mod(INNER, false);
+      break;
+    case 7:
+      shell_wrap(INNER, false, 2);
+      break;
+    case 8:
+      chase_mod(INNER, 2, false);
+      break;
+    case 9:
+      shell_wrap(INNER, false, 3);
+      break;
+    case 10:
+      fill_shell(INNER);
+      break;
+  }
   switch (oAnimCounter) {
     case 0:
       chase_straight(OUTER, true);


Version 2.2 - 19th May 2018

Version 2.2 - 19th May 2018

--- ulisp.ino
+++ ulisp.ino
@@ -1,5 +1,5 @@
-/* uLisp Version 2.1 - www.ulisp.com
-   David Johnson-Davies - www.technoblogy.com - 21st April 2018
+/* uLisp AVR Version 2.2 - www.ulisp.com
+   David Johnson-Davies - www.technoblogy.com - 19th May 2018

    Licensed under the MIT license: https://opensource.org/licenses/MIT
 */
@@ -688,19 +688,9 @@
   return NULL;
 }

-void dropframe (int tc, object **env) {
-  if (tc) {
-    while (*env != NULL && car(*env) != NULL) {
-      pop(*env);
-    }
-  } else {
-    push(nil, *env);
-  }
-}
-
 // Handling closures

-object *closure (object *fname, object *state, object *function, object *args, object **env) {
+object *closure (int tc, object *fname, object *state, object *function, object *args, object **env) {
   int trace = 0;
   if (fname != NULL) trace = tracing(fname->name);
   if (trace) {
@@ -729,7 +719,9 @@
       value = first(args);
       args = cdr(args);
     }
-    push(cons(var,value), *env);
+    object *pair = findtwin(var, *env);
+    if (tc && (pair != NULL)) cdr(pair) = value;
+    else push(cons(var,value), *env);
     params = cdr(params);
     if (trace) { pserial(' '); printobject(value, pserial); }
   }
@@ -751,12 +743,12 @@
   }
   if (listp(function) && issymbol(car(function), LAMBDA)) {
     function = cdr(function);
-    object *result = closure(NULL, NULL, function, args, env);
+    object *result = closure(0, NULL, NULL, function, args, env);
     return eval(result, *env);
   }
   if (listp(function) && issymbol(car(function), CLOSURE)) {
     function = cdr(function);
-    object *result = closure(NULL, car(function), cdr(function), args, env);
+    object *result = closure(0, NULL, car(function), cdr(function), args, env);
     return eval(result, *env);
   }
   error2(function, PSTR("is an illegal function"));
@@ -1062,6 +1054,45 @@
 void nonote (int pin) {
   (void) pin;
   TCCR2B = 0<<WGM22 | 0<<CS20;
+}
+
+// Sleep
+
+// Interrupt vector for sleep watchdog
+ISR(WDT_vect) {
+  WDTCSR |= 1<<WDIE;
+}
+
+void initsleep () {
+  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+}
+
+void sleep (int secs) {
+  // Set up Watchdog timer for 1 Hz interrupt
+  WDTCSR = 1<<WDCE | 1<<WDE;
+  WDTCSR = 1<<WDIE | 6<<WDP0;     // 1 sec interrupt
+  delay(100);  // Give serial time to settle
+  // Disable ADC and timer 0
+  ADCSRA = ADCSRA & ~(1<<ADEN);
+#if defined(__AVR_ATmega328P__)
+  PRR = PRR | 1<<PRTIM0;
+#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__)
+  PRR0 = PRR0 | 1<<PRTIM0;
+#endif
+  while (secs > 0) {
+    sleep_enable();
+    sleep_cpu();
+    secs--;
+  }
+  WDTCSR = 1<<WDCE | 1<<WDE;     // Disable watchdog
+  WDTCSR = 0;
+  // Enable ADC and timer 0
+  ADCSRA = ADCSRA | 1<<ADEN;
+#if defined(__AVR_ATmega328P__)
+  PRR = PRR & ~(1<<PRTIM0);
+#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__)
+  PRR0 = PRR0 & ~(1<<PRTIM0);
+#endif
 }

 // Special forms
@@ -1345,7 +1376,7 @@
   int mode = 0;
   if (params != NULL && first(params) != NULL) mode = integer(first(params));
   int oflag = O_READ;
-  if (mode == 1) oflag = O_RDWR | O_CREAT; else if (mode == 2) oflag = O_RDWR | O_CREAT | O_TRUNC;
+  if (mode == 1) oflag = O_RDWR | O_CREAT | O_APPEND; else if (mode == 2) oflag = O_RDWR | O_CREAT | O_TRUNC;
   if (mode >= 1) {
     SDpfile = SD.open(MakeFilename(filename), oflag);
     if (!SDpfile) error(PSTR("Problem writing to SD card"));
@@ -1843,7 +1874,8 @@
   int result = integer(first(args));
   args = cdr(args);
   while (args != NULL) {
-    result = max(result,integer(car(args)));
+    int next = integer(car(args));
+    if (next > result) result = next;
     args = cdr(args);
   }
   return number(result);
@@ -1854,7 +1886,8 @@
   int result = integer(first(args));
   args = cdr(args);
   while (args != NULL) {
-    result = min(result,integer(car(args)));
+    int next = integer(car(args));
+    if (next < result) result = next;
     args = cdr(args);
   }
   return number(result);
@@ -2151,7 +2184,7 @@
     return temp;
   }
   char c = nthchar(GlobalString, GlobalStringIndex++);
-  return (c != 0) ? c : '\n';
+  return (c != 0) ? c : '\n'; // -1?
 }

 object *fn_readfromstring (object *args, object *env) {
@@ -2298,9 +2331,9 @@

 object *fn_print (object *args, object *env) {
   (void) env;
-  pln(pserial);
   object *obj = first(args);
   pfun_t pfun = pstreamfun(cdr(args));
+  pln(pfun);
   printobject(obj, pfun);
   (pfun)(' ');
   return obj;
@@ -2363,7 +2396,7 @@
   char temp = PrintReadably;
   PrintReadably = 0;
   printstring(obj, pfun);
-  (pfun)('\n');
+  pln(pfun);
   PrintReadably = temp;
   return nil;
 }
@@ -2393,7 +2426,7 @@
   pint(Freespace - initial, pserial);
   pfstring(PSTR(" bytes, Time: "), pserial);
   pint(elapsed, pserial);
-  pfstring(PSTR(" uS\r"), pserial);
+  pfstring(PSTR(" us\r"), pserial);
   return nil;
 }

@@ -2440,7 +2473,8 @@
   (void) env;
   int pin = integer(first(args));
   object *mode = second(args);
-  digitalWrite(pin, (mode != nil));
+  if (numberp(mode)) digitalWrite(pin, mode->integer);
+  else digitalWrite(pin, (mode != nil));
   return mode;
 }

@@ -2472,40 +2506,10 @@
   return number(millis());
 }

-// Interrupt vector for sleep watchdog
-ISR(WDT_vect) {
-  WDTCSR |= 1<<WDIE;
-}
-
 object *fn_sleep (object *args, object *env) {
   (void) env;
   object *arg1 = first(args);
-  int secs = integer(arg1);
-  // Set up Watchdog timer for 1 Hz interrupt
-  WDTCSR = 1<<WDCE | 1<<WDE;
-  WDTCSR = 1<<WDIE | 6<<WDP0;     // 1 sec interrupt
-  delay(100);  // Give serial time to settle
-  // Disable ADC and timer 0
-  ADCSRA = ADCSRA & ~(1<<ADEN);
-#if defined(__AVR_ATmega328P__)
-  PRR = PRR | 1<<PRTIM0;
-#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__)
-  PRR0 = PRR0 | 1<<PRTIM0;
-#endif
-  while (secs > 0) {
-    sleep_enable();
-    sleep_cpu();
-    secs--;
-  }
-  WDTCSR = 1<<WDCE | 1<<WDE;     // Disable watchdog
-  WDTCSR = 0;
-  // Enable ADC and timer 0
-  ADCSRA = ADCSRA | 1<<ADEN;
-#if defined(__AVR_ATmega328P__)
-  PRR = PRR & ~(1<<PRTIM0);
-#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__)
-  PRR0 = PRR0 & ~(1<<PRTIM0);
-#endif
+  sleep(integer(arg1));
   return arg1;
 }

@@ -3020,8 +3024,8 @@
   int TC=0;
   EVAL:
   // Enough space?
+  if (End != 0xA5) error(PSTR("Stack overflow"));
   if (Freespace < 20) gc(form, env);
-  if (End != 0xA5) error(PSTR("Stack overflow"));
   // Escape
   if (tstflag(ESCAPE)) { clrflag(ESCAPE); error(PSTR("Escape!"));}
   #if defined (serialmonitor)
@@ -3131,8 +3135,7 @@
   }

   if (listp(function) && issymbol(car(function), LAMBDA)) {
-    dropframe(TCstart, &env);
-    form = closure(fname, NULL, cdr(function), args, &env);
+    form = closure(TCstart, fname, NULL, cdr(function), args, &env);
     pop(GCStack);
     int trace = tracing(fname->name);
     if (trace) {
@@ -3151,8 +3154,7 @@

   if (listp(function) && issymbol(car(function), CLOSURE)) {
     function = cdr(function);
-    dropframe(TCstart, &env);
-    form = closure(fname, car(function), cdr(function), args, &env);
+    form = closure(TCstart, fname, car(function), cdr(function), args, &env);
     pop(GCStack);
     TC = 1;
     goto EVAL;
@@ -3406,11 +3408,10 @@

 void setup () {
   Serial.begin(9600);
-  while (!Serial);  // wait for Serial to initialize
   initworkspace();
   initenv();
-  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
-  pfstring(PSTR("uLisp 2.1 "), pserial); pln(pserial);
+  initsleep();
+  pfstring(PSTR("uLisp 2.2 "), pserial); pln(pserial);
 }

 // Read/Evaluate/Print loop


added setting of height multiple continents

not tested yet!!

--- arduino/Led_Strip/Steppers.ino
+++ arduino/Led_Strip/Steppers.ino
@@ -16,6 +16,16 @@

 Stepper steppers[AMOUNTSTEPPERS];

+typedef struct Steps Steps;
+
+struct Steps {
+  int steps;
+  boolean down;
+  boolean finished;
+};
+
+Steps steps[AMOUNTSTEPPERS];
+
 void setupSteppers(){
   //set how the steppers are connected //TODO add other steppers
   steppers[0].directionPort = 2;
@@ -52,7 +62,7 @@
     pinMode(steppers[i].caliPort, INPUT);
     calib(i);
   }
-   Serial.write("READY");
+  Serial.write("READY");
 }

 void rotate(int stepper,boolean down,int steps){ //rotate in direction right == true; left == false and for x amount of steps
@@ -74,6 +84,10 @@
   }
 }

+void rotateMultiple(int []){
+
+}
+
 void calib(int stepper){ //Set the Steppermotor to bottom most position
   for(int i = 0; i < MAXHEIGHTINSTEPS * 1.2; i++){
     if(!bottom(stepper)){
@@ -114,8 +128,85 @@
   }
 }

-
-
-
-
-
+void setHeigthMultiple(int numbers[6][3]){
+  Steps steps[AMOUNTSTEPPERS];
+  for(int i = 0; i < AMOUNTSTEPPERS; i++){ //calculate the amount of steps all steppers have to move
+  steppers[i].height = numbers[i][3]; //set height of steppers
+    int amountOfSteps = int(((steppers[i].height - numbers[i][3]) / MAXHEIGHT) * MAXHEIGHTINSTEPS);
+      steps[i].steps = abs(amountOfSteps); //steps
+    steps[i].down = amountOfSteps > 0; //direction
+    if(amountOfSteps ==0) //if stepper does not have to move
+      steps[i].finished = true;
+    else
+      steps[i].finished = false;
+  }
+  for(int q = 0; q < AMOUNTSTEPPERS; q++){ //set direction of all steppermotors
+    if(steps[q].down)
+      digitalWrite(steppers[q].directionPort, HIGH);
+    else
+      digitalWrite(steppers[q].directionPort, LOW);
+  }
+  for(int i = 0; i < MAXHEIGHTINSTEPS * 1.2; i++){ //the maximum amount of steps all steppers can take
+    if(steppersfinished() >= AMOUNTSTEPPERS){ //if not all steppers have finished moving
+      for(int q = 0; q < AMOUNTSTEPPERS; q++){ //for all steppers
+        if(!steps[q].finished && steps[q].steps > 0){ //if stepper has not finished movement
+          if(!bottom(q)){//steppers has not reached the bottom
+            steps[q].steps--;
+            digitalWrite(steppers[q].PWMPort, LOW);
+          }
+          else{ //if reached the botttom
+            steps[q].finished = true;
+            upFromBottom(q);
+            break;
+          }
+        }
+        else{ //if finished with taking steps
+          steps[q].finished = true;
+          break;
+        }
+      }
+      delayMicroseconds(STEPPERDELAY);
+      for(int q = 0; q < AMOUNTSTEPPERS; q++){
+        if(!steps[q].finished && steps[q].steps > 0){ //if stepper has not finished movement
+          if(!bottom(q)){
+            digitalWrite(steppers[q].PWMPort, HIGH);
+          }
+          else{
+            steps[q].finished = true;
+            upFromBottom(q);
+            continue;
+          }
+        }
+        else{
+          steps[q].finished = true;
+          continue;
+        }
+      }
+      delayMicroseconds(STEPPERDELAY);
+    }
+    else
+      break;
+  }
+}
+
+int steppersfinished(){
+  int finished;
+  for(int i = 0; i < AMOUNTSTEPPERS; i++)
+    if(steps[i].finished) finished++;
+
+  return finished;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+


Updates watch api to take time keeping information from ext source

--- watch.ino
+++ watch.ino
@@ -72,14 +72,17 @@
 This function performs time keeping. To draw the watch face call
 watch_show().

+  now:  the number of milliseconds since some epoch which uniquely identifies the
+        current time
+
 This function returns an integer indiciating the number of changed counters:

-0 - no change
-1 - seconds
-2 - minutes
-3 - hours
-4 - day
-5 - month
+  0 - no change
+  1 - seconds
+  2 - minutes
+  3 - hours
+  4 - day
+  5 - month

 Because all changes start with seconds and propagate forward, a change in a high
 value counter implies all counter below it have also changed. e.g. if 2 is returned,
@@ -88,8 +91,9 @@
 Note that this kind of time keeping on the Xadow has an error of about 1000 ppm, which
 is around 30 seconds over 8 hours.
 */
-uint8_t watch_tick () {
-  int16_t elapsed = millis() - _watch_state.next_second_millis;
+uint8_t watch_tick (uint16_t now) {
+  int16_t elapsed = now - _watch_state.next_second_millis;
+
   if (elapsed > 0) {
     _watch_state.next_second_millis += 1000;


testing: passed

testing: passed

--- IMUtest/IMUtest.ino
+++ IMUtest/IMUtest.ino
@@ -166,7 +166,7 @@

  // display of roll, pitch, heading formatted for displayIMU.py
  if (RPH) {
-    Serial.print("RPH ");
+    Serial.print("tt,RPH,");
     Serial.print((int)withGyro.roll);
     Serial.print(",");
     Serial.print((int)withGyro.pitch);
@@ -177,7 +177,7 @@
   }

  if (QUAT) {
-    Serial.print("QUAT");
+    Serial.print("tt,QUAT,");
     Serial.print(withGyro.q0);
     Serial.print(",");
     Serial.print(withGyro.q1);


support moving speed and blink commands

support moving speed and blink commands

--- car_server/arduino/arduino.ino
+++ car_server/arduino/arduino.ino
@@ -1,12 +1,19 @@
 #include <Servo.h>

 const int MOTOR_PIN = 3;
+const int LED_PIN = 5;
 const int SERVO_PIN = 9;
+const int MIN_SPEED = 1;
+const int MAX_SPEED = 3;
+const int MAX_COMMAND_LENGTH = 6;

-boolean isMoveForward = 0;
-boolean isMoveBackward = 0;
-boolean isMoveLeft = 0;
-boolean isMoveRight = 0;
+bool isMoveForward = false;
+bool isMoveBackward = false;
+bool isMoveLeft = false;
+bool isMoveRight = false;
+bool isLedBlink = false;
+int movingSpeed = MAX_SPEED;
+char command[MAX_COMMAND_LENGTH] = "";

 Servo servo;

@@ -23,20 +30,21 @@
   else if (isMoveRight)
     right();
   else
-    center ();
+    center();
+
+  if (isHeartBeat)
+    blinkLed();
 }

 void setup() {
   Serial.begin(9600);
   servo.attach(SERVO_PIN);
   pinMode(MOTOR_PIN, OUTPUT);
+  pinMode(LED_PIN, OUTPUT);
 }

-char command[4] = "";
-int i = 0;
-
 void loop() {
-//  moveForward();
+  int i = 0;
   if (Serial.available() > 0 ) {
     char ch = Serial.read();
     if (ch == '\n') {
@@ -58,13 +66,22 @@
   isMoveBackward = command[1] == '1';
   isMoveLeft = command[2] == '1';
   isMoveRight = command[3] == '1';
+  isLedBlink = command[4] == '1';
+
+  int speed = command[5] - '0';
+  if (speed > MIN_SPEED && speed < MAX_SPEED)
+      movingSpeed = speed;

   comply();
 }

 void moveForward() {
-//  analogWrite(MOTOR_PIN, 200);
-  digitalWrite(MOTOR_PIN, HIGH);
+  if (movingSpeed == 1)
+    analogWrite(MOTOR_PIN, 200);
+  else if (movingSpeed == 2)
+    analogWrite(MOTOR_PIN, 225);
+  else
+    digitalWrite(MOTOR_PIN, HIGH);
 }

 void stopMoving() {
@@ -72,18 +89,24 @@
 }

 void left() {
-  servo.write(40);
+  servo.write(140);
 };
 void center() {
   servo.write(90);
 };
 void right() {
-  servo.write(140);
+  servo.write(40);
 };

 void clearCommand() {
-  for (int i = 0; i < 4; i++) {
+  for (int i = 0; i < MAX_COMMAND_LENGTH; i++) {
     command[i] = '0';
   }
 }

+void blinkLed() {
+  analogWrite(LED_PIN, 10);
+  delay(50);
+  digitalWrite(LED_PIN, LOW);
+}
+


More bug fixes

More bug fixes

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -198,7 +198,7 @@
   serial_rx_buffer_controller[9] = 0x00; //  Delay Byte 2
   serial_rx_buffer_controller[10] = 0x00; // Delay Byte 1
   serial_rx_buffer_controller[11] = 0x01; // Postamble
-  //delay(5000); // Wait for the serial program on the computer to startup before sending any data
+  delay(5000); // Wait for the serial program on the computer to startup before sending any data
   //  Count bytes and parse ASCII values to their respective commands, such as buttons and axis
   for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer); serial_rx_buffer_counter++) {
     Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
@@ -229,7 +229,9 @@
     if (serial_rx_buffer_counter == 11) {
       Serial.write(0x03);
     }
-  }
+    sentPing = true;
+  }
+  sentPing = false;
   Serial.flush();
   sendPing();
   calculatePing();
@@ -255,7 +257,7 @@
   //  << PING 3000  // This is data sent from the Arduino
   //  >> PONG 3000  // This is data the Arduino received

-  //  Preamble/Postamble = 0x04 for PONG for BOTH wayy
+  //  Preamble/Postamble = 0x04 for PONG for BOTH ways
   //  PING/PONG System where PING is sent from the Computer and PONG is sent from the Arduino:
   //  Where ">>" is incoming data and "<<" is outgoing data
   //  >> PING 1487568769420  // This is data the Arduino received
@@ -275,7 +277,7 @@
   //  The Arduino then sends Reconnect Successful to tell the computer Connection is working as intended
   //  Or:
   //  Computer sends Disconnect to the Arduino in case of PING timeout (The Arduino didn't respond with PONG in time)
-  //  The Arduino then sends Disconnect Understood back to the Computer, both close connections on their ends, then start connection again
+  //  The Arduino then sends Disconnect Ungderstood back to the Computer, both close connections on their ends, then start connection again
   //  The Computer then sends Reconnect Successful to tell the Arduino Connection is working as intended
   if (Serial.available() > 0) {

@@ -321,7 +323,7 @@
       for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_pong_in); serial_rx_buffer_counter++) {
         //  Pass Serial Buffer to Pong Input Buffer
         serial_rx_buffer_pong_in[serial_rx_buffer_counter] = serial_rx_buffer[serial_rx_buffer_counter];
-      }
+      }s
       getPong();
     }
     else if ((serial_rx_buffer[0] == 0xA0) && (serial_rx_buffer[11] == 0xA0)) {
@@ -525,7 +527,7 @@
       Serial.write(0x04);
     }
     if ((serial_rx_buffer_counter == 1) || (serial_rx_buffer_counter == 2) || (serial_rx_buffer_counter == 3) || (serial_rx_buffer_counter == 4)) {
-      Serial.write(0x00);
+      Serial.write(serial_rx_buffer_pong_out[serial_rx_buffer_counter]);
     }
     if ((serial_rx_buffer_counter == 5) || (serial_rx_buffer_counter == 6) || (serial_rx_buffer_counter == 7) || (serial_rx_buffer_counter == 8)) {
       Serial.write(serial_rx_buffer_pong_out[serial_rx_buffer_counter]);


Update pt_ex4_led_individually.ino

Update pt_ex4_led_individually.ino

--- pt_ex/pt_ex4_led_individually.ino
+++ pt_ex/pt_ex4_led_individually.ino
@@ -175,7 +175,13 @@
 void loop() {
   //Check each thread by priority

-  Serial.println(Serial.read());
+  while (Serial.available() > 0) {
+      char c = Serial.read();
+      if (c != -1) {
+        Serial.println("recieve");
+        Serial.println(c);
+      }
+    }

   /*thread8_entry(&thread8);
   thread1_entry(&thread1);


Adding delay after myTouch.dataAvailable

--- src/aquarium_wise_controller.ino
+++ src/aquarium_wise_controller.ino
@@ -180,6 +180,7 @@

   if (myTouch.dataAvailable())
   {
+    delay(5);
     if (currentMillis - prevMillisTouch > 500)
     {
       if (backlightTouch == false)
@@ -806,7 +807,6 @@
 void processMyTouch()
 {
   myTouch.read();
-  delay(5);

   int x = myTouch.getX();
   int y = myTouch.getY();


Updated comments

Updated comments

--- avr/examples/CANBusTriple_Mazda/CANBusTriple_Mazda.ino
+++ avr/examples/CANBusTriple_Mazda/CANBusTriple_Mazda.ino
@@ -1,8 +1,8 @@
 /*
 *  CANBus Triple
 *  The Car Hacking Platform
-*  http://canb.us
-*  https://github.com/etx/CANBus-Triple
+*  https://canb.us
+*  https://github.com/CANBus-Triple
 */

 #include <avr/wdt.h>
@@ -171,7 +171,7 @@

 /*
-*  TODO, Comment on this method
+*  Main Loop
 */
 void loop() {

@@ -214,7 +214,7 @@

 /*
-*  TODO, Comment on this method
+*  Load CAN Controller buffer and set send flag
 */
 boolean sendMessage( Message msg, CANBus bus ){

@@ -251,7 +251,7 @@

 /*
-*  TODO, Comment on this method
+*  Read Can Controller Buffer
 */
 void readBus( CANBus bus ){

@@ -285,7 +285,7 @@

 /*
-*  TODO, Comment on this method
+*  Process recieved CAN message through middleware
 */
 void processMessage( Message msg ){


added black mode for no wifi

added black mode for no wifi

--- client/RGB_control/RGB_control.ino
+++ client/RGB_control/RGB_control.ino
@@ -188,11 +188,12 @@
   Serial.println("Version " + Version);
 }

-bool mqttTryReconnect() {
+void mqttTryReconnect() {
   Serial.print("Attempting MQTT connection...");
   // Attempt to connect
   if (mqttClient.connect(clientID.c_str())) {
     Serial.println("connected");
+    registration();
     for (int i = 0; i < subscriptions_length; i++ )
     {
       mqttClient.subscribe(subscriptions[i].c_str());
@@ -201,9 +202,7 @@
         Serial.println(subscriptions[i]);
       #endif
     }
-    return true;
-  } else {
-    return false;
+
   }
 }

@@ -264,7 +263,6 @@
   mqttClient.setServer(mqtt_server, 1883);
   mqttClient.setCallback(callback);
   mqttTryReconnect();
-  registration();
 }

 unsigned int loopCounter = 1;
@@ -283,4 +281,9 @@
       }
     }
   }
-}
+  if (WiFi.status() != WL_CONNECTED) {
+    parseRGB("#000000");
+    setParsedRGB();
+    delay(100);
+  }
+}


Increase FastLED SPI speed from 1MHz to 12MHz to reduce flicker

--- firmware/examples/FastLedComparison/FastLedComparison.ino
+++ firmware/examples/FastLedComparison/FastLedComparison.ino
@@ -111,7 +111,7 @@
   matrix.setBrightness(BRIGHTNESS);
   backgroundLayer.enableColorCorrection(false);
 #else
-  FastLED.addLeds<CHIPSET, DATA_PIN, CLOCK_PIN, COLOR_ORDER, DATA_RATE_MHZ(1)>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
+  FastLED.addLeds<CHIPSET, DATA_PIN, CLOCK_PIN, COLOR_ORDER, DATA_RATE_MHZ(12)>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
   FastLED.setBrightness( BRIGHTNESS );

   #if (MODE == MODE_FASTLED_DITHERING)


gpsLogger example tested

gpsLogger example tested

--- examples/gpsLogger/gpsLogger.ino
+++ examples/gpsLogger/gpsLogger.ino
@@ -9,7 +9,7 @@
 */
 List<Waypoint> *eeList;
 NMEA            nmea(Serial1);
-const uint32_t  UPDATE_INTERVAL = 50;
+const uint32_t  UPDATE_INTERVAL = 4000;

 void setup(){
     eeList = EEPROMlist::getInstance();
@@ -34,14 +34,13 @@

     //update the gps and store good readings periodically
     nmea.update();
-    if(nmea.newData()){
+    if(nmea.newData() && !nmea.getWarning()){
         Waypoint newPoint = nmea.getLocation();
-        static uint16_t count = 0;
-        newPoint.setExtra(count++);//nmea.getWarning());
-
         static uint32_t intervalTimer;
         if(millis()>intervalTimer){
-            intervalTimer += UPDATE_INTERVAL;
+            intervalTimer = millis()+UPDATE_INTERVAL;
+            static uint16_t count = 0;
+            newPoint.setExtra(count++);
             addToList(newPoint);
         }
     }


fixed auto restart after interval, and clean up auto turn off wifi code.

minor refactoring

--- esp-rfid.ino
+++ esp-rfid.ino
@@ -48,14 +48,14 @@
 bool activateRelay = false;
 bool inAPMode = false;
 bool isWifiConnected = false;
+int autoRestartIntervalSeconds = 0;

 bool wifiDisabled = true;
 bool doDisableWifi = false;
 bool doEnableWifi = false;
-unsigned long const defaultWifiTimeout = 240000;
-long wifiTimeout = defaultWifiTimeout;
-
-char * our_hostname = 0;
+int wifiTimeout = -1;
+unsigned long wiFiUptimeMillis = 0;
+char * deviceHostname = 0;

 int relayPin;
 int relayType;
@@ -144,15 +144,24 @@

 // Main Loop
 void loop() {
+
+  unsigned long currentMillis = millis();
+  unsigned long deltaTime = currentMillis-previousLoopMillis;
+  unsigned long uptime = NTP.getUptime();
+  previousLoopMillis = currentMillis;
+
+  if (autoRestartIntervalSeconds > 0 && uptime > autoRestartIntervalSeconds*1000)
+  {
+    Serial.println(F("[ UPDT ] Auto restarting..."));
+    shouldReboot = true;
+  }
+
   // check for a new update and restart
   if (shouldReboot) {
     Serial.println(F("[ UPDT ] Rebooting..."));
     delay(100);
     ESP.restart();
   }
-  unsigned long currentMillis = millis();
-  unsigned long deltaTime = currentMillis-previousLoopMillis;
-  previousLoopMillis = currentMillis;
   if (currentMillis - previousMillis >= activateTime && activateRelay) {
     activateRelay = false;
     digitalWrite(relayPin, relayType);
@@ -160,18 +169,19 @@
   if (activateRelay) {
     digitalWrite(relayPin, !relayType);
   }
+
+  if (isWifiConnected)
+    wiFiUptimeMillis += deltaTime;

-  if (wifiTimeout > 0)
-    wifiTimeout -= deltaTime;
-
-  if (wifiTimeout <= 0 && isWifiConnected == true)
+  if (wifiTimeout>0 && wiFiUptimeMillis>(wifiTimeout*1000) && isWifiConnected == true)
   {
     doDisableWifi = true;
   }
-
+
   if (doDisableWifi==true)
   {
     doDisableWifi=false;
+    wiFiUptimeMillis = 0;
     disableWifi();
   }
   else if (doEnableWifi==true)
@@ -179,7 +189,7 @@
     doEnableWifi = false;
     if (!isWifiConnected)
     {
-      wifiTimeout = defaultWifiTimeout;
+      wiFiUptimeMillis = 0;
       enableWifi();
     }
   }
@@ -199,7 +209,7 @@
 void disableWifi()
 {
     isWifiConnected = false;
-    WiFi.mode(WIFI_OFF);
+    WiFi.disconnect(true);
     Serial.println("Turn wifi off.");
 }

@@ -630,7 +640,7 @@
   inAPMode = true;
   WiFi.mode(WIFI_AP);
   Serial.print(F("[ INFO ] Configuring access point... "));
-  Serial.println(WiFi.softAP(our_hostname) ? "Ready" : "Failed!");
+  Serial.println(WiFi.softAP(deviceHostname) ? "Ready" : "Failed!");
   // Access Point IP
   IPAddress myIP = WiFi.softAPIP();
   Serial.print(F("[ INFO ] AP IP address: "));
@@ -678,20 +688,23 @@
   setupRFID(rfidss, rfidgain);
   const char * l_hostname = json["hostnm"];

-  if (our_hostname != 0)
-    free(our_hostname);
-  our_hostname = (char*) malloc(sizeof(l_hostname));
-  strcpy(our_hostname, l_hostname);
+  autoRestartIntervalSeconds = json["auto_restart_interval_seconds"].as<int>();
+  wifiTimeout = json["disable_wifi_after_seconds"].as<int>();
+
+  if (deviceHostname != 0)
+    free(deviceHostname);
+  deviceHostname = (char*) malloc(sizeof(l_hostname));
+  strcpy(deviceHostname, l_hostname);

   const char * bssidmac = json["bssid"];
   byte bssid[6];
   parseBytes(bssidmac, ':', bssid, 6, 16);

   // Set Hostname.
-  WiFi.hostname(our_hostname);
+  WiFi.hostname(deviceHostname);

   // Start mDNS service so we can connect to http://esp-rfid.local (if Bonjour installed on Windows or Avahi on Linux)
-  if (!MDNS.begin(our_hostname)) {
+  if (!MDNS.begin(deviceHostname)) {
     Serial.println("Error setting up MDNS responder!");
   }
   // Add Web Server service to mDNS
@@ -755,9 +768,13 @@

 // Try to connect Wi-Fi
 bool connectSTA(const char* ssid, const char* password, byte bssid[6]) {
+
+  WiFi.disconnect(true);
   WiFi.mode(WIFI_STA);
+
   // First connect to a wi-fi network
   WiFi.begin(ssid, password, 0, bssid);
+
   // Inform user we are trying to connect
   Serial.print(F("[ INFO ] Trying to connect WiFi: "));
   Serial.print(ssid);


Version bump

Version bump

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -2,7 +2,7 @@
 #include <LinkedList.h>

 #include "config.h"
-#define VERSION 10501
+#define VERSION 10502

 #if PINSERVO == 1


update baud rate

update baud rate

--- Arduino/v0.2.0_no_conditioning/v0.2.0_no_conditioning.ino
+++ Arduino/v0.2.0_no_conditioning/v0.2.0_no_conditioning.ino
@@ -11,7 +11,8 @@

 void setup()
 {
-  Serial.begin(230400);
+  Serial.begin(2000000);
+//  Serial.begin(230400);
   //Set B pins to input
   DDRB = B00000000;
   delay(1000);


Add reset led function

Add reset led function

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -17,6 +17,12 @@
 const byte bankUpLed = 23;
 const byte playLed = 20;
 const byte stopLed = 21;
+
+const byte allLeds[] = {ledPin, bpmLed, ledPins[0], ledPins[1], ledPins[2],
+                        ledPins[3], ledPins[4], ledPins[5], bankDownLed, bankUpLed, playLed, stopLed
+                       };
+
+const byte numberOfLeds = 12;

 // Buttons
 const byte channelButtonStart = 0;
@@ -183,6 +189,7 @@
   boolean modeChange = changeMode();
   if (modeChange) {
     Serial.println(modeNames[mode]);
+    resetLeds();
   }

   switch (mode) {
@@ -265,6 +272,12 @@
   }
 }

+void resetLeds() {
+  for (byte i = 0; i < numberOfLeds; i++) {
+    digitalWrite(allLeds[i], LOW);
+  }
+}
+
 void RealTimeSystem(byte realtimebyte) {
   if (realtimebyte == CLOCK) {
     counter++;


Made arduino check more

Made arduino check more

--- data/arduino_sound_detect/arduino_sound_detect.ino
+++ data/arduino_sound_detect/arduino_sound_detect.ino
@@ -28,7 +28,7 @@

 void setup(){

-  //Serial.begin(9600);
+  Serial.begin(9600);

   pinMode(13,OUTPUT);//clipping indicator pin
   pinMode(2,OUTPUT);//led indicator pin
@@ -81,12 +81,12 @@
   /*Serial.print(frequency);
   Serial.println(" hz");*/

-  if (3300 < frequency && 4300 > frequency) {
+  if (3400 < frequency && 4200 > frequency) {
     correct++;
   } else {
     wrong++;
   }
-  if (wrong + correct > 10) {
+  if (wrong + correct > 20) {
     //Serial.print(wrong);
     //Serial.print(" ");
     //Serial.println(correct);


being extracting mifare.write

being extracting mifare.write

--- examples/WriteTag/WriteTag.ino
+++ examples/WriteTag/WriteTag.ino
@@ -57,70 +57,16 @@
       // We probably have a Mifare Classic card ...
       Serial.println("Seems to be a Mifare Classic card (4 byte UID)");

-      // Now we need to try to authenticate it for read/write access
-      Serial.println("Trying to authenticate block 4 with default key value");
-      uint8_t key[6] = { 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7 }; // this is Sector 1 - 15 key
-
-      // Start with block 4, the first block of sector 1. Note sector 0 contains the manufacturer data.
-      success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 4, 0, key);
-
-      if (success)
-      {
-        Serial.println("Sector 1 (Blocks 4..7) has been authenticated");
-
-        NdefMessage* m = new NdefMessage();
-        m->addTextRecord("Hello, World");
-        m->addUriRecord("http://arduino.cc");
-        m->print();
-
-        // most code from here down should be handled in mifare.write(message)
+      NdefMessage* m = new NdefMessage();
+      m->addTextRecord("Hello, World");
+      m->addUriRecord("http://arduino.cc");
+      m->print();

-        uint8_t encoded[m->getEncodedSize()];
-        m->encode(encoded);
-
-        // TLV wrapper
-        // assuming short TLV  3 bytes type +  byte length of data + NDEF_DATA + 1 byte terminator
-        uint8_t buffer[sizeof(encoded) + 5];
-        buffer[0] = 0x0;
-        buffer[1] = 0x0;
-        buffer[2] = 0x3;
-        buffer[3] = sizeof(encoded);
-        memcpy(&buffer[4], encoded, sizeof(encoded));
-        buffer[4+sizeof(encoded)] = 0xFE; // terminator
-
-        // Write to Mifare Classic Tag
-        int index = 0;
-        int currentBlock = 4;
-        int BLOCK_SIZE = 16;
-
-        if (sizeof(buffer) > BLOCK_SIZE * 3) {
-          Serial.println();
-          Serial.println("ERROR: Message is too large.");
-          //Serial.println("This code can only write messages that are less than 3 blocks (48 bytes) long");
-          Serial.println("Message can not exceed 3 blocks or 48 bytes (with TLV)");
-          while(1); // halt
-        }
+      write(*m, uid, uidLength);

-        while (index < sizeof(buffer))
-        {
-          int write_success = nfc.mifareclassic_WriteDataBlock (currentBlock, &buffer[index]);
-          if (write_success) {
-              Serial.print("wrote block ");Serial.println(currentBlock);
-          } else {
-              Serial.println("write failed");
-          }
-          index += BLOCK_SIZE;
-          currentBlock++; // this will fail on block 7
-        }
-
-        Serial.println("\nTry and read the tag with your phone.");
-
-        delay(5000);
-      }
-      else
-      {
-        Serial.println("Error. Block Authentication failed.");
-      }
+      Serial.println("\nTry and read the tag with your phone.");
+
+      delay(5000);
     }
     else
     {
@@ -131,3 +77,62 @@
   }
 }

+// TODO this belongs in MifareClassic Library
+// TODO return success / failure
+void write(NdefMessage& m, uint8_t * uid, int uidLength)
+{
+
+    uint8_t encoded[m.getEncodedSize()];
+    m.encode(encoded);
+
+    // TLV wrapper
+    // assuming short TLV  3 bytes type +  byte length of data + NDEF_DATA + 1 byte terminator
+    uint8_t buffer[sizeof(encoded) + 5];
+    buffer[0] = 0x0;
+    buffer[1] = 0x0;
+    buffer[2] = 0x3;
+    buffer[3] = sizeof(encoded);
+    memcpy(&buffer[4], encoded, sizeof(encoded));
+    buffer[4+sizeof(encoded)] = 0xFE; // terminator
+
+    // Write to tag
+    int index = 0;
+    int currentBlock = 4;
+    int BLOCK_SIZE = 16;
+
+    // lame check dues to bad implemenation
+    if (sizeof(buffer) > BLOCK_SIZE * 3) {
+      Serial.println();
+      Serial.println("ERROR: Message is too large.");
+      Serial.println("Message can not exceed 3 blocks or 48 bytes (with TLV)");
+      while(1); // halt
+    }
+
+    uint8_t key[6] = { 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7 }; // this is Sector 1 - 15 key
+
+    // Start with block 4, the first block of sector 1. Note sector 0 contains the manufacturer data.
+    uint8_t success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength, currentBlock, 0, key);
+
+    if (success)
+    {
+      Serial.println("Sector 1 (Blocks 4..7) has been authenticated");
+
+      while (index < sizeof(buffer))
+      {
+        int write_success = nfc.mifareclassic_WriteDataBlock (currentBlock, &buffer[index]);
+        if (write_success) {
+            Serial.print("wrote block ");Serial.println(currentBlock);
+        } else {
+            Serial.println("write failed");
+        }
+        index += BLOCK_SIZE;
+        currentBlock++; // this will fail on block 7
+      }
+
+    }
+    else
+    {
+      Serial.println("Error. Block Authentication failed.");
+    }
+}
+


fixed linting error

fixed linting error

--- examples/dual_led/dual_led.ino
+++ examples/dual_led/dual_led.ino
@@ -5,7 +5,7 @@
 // the LED connected to gpio 9 is in breathe mode, the builtin LED
 // LED is blinking with the same frequency.
 JLed led1 = JLed(9).Breathe(2000).Forever().DelayAfter(2000);
-JLed led2 = JLed(LED_BUILTIN).Blink(2000,2000).Forever();
+JLed led2 = JLed(LED_BUILTIN).Blink(2000, 2000).Forever();

 void setup() {
 }


more sensitive

more sensitive

--- embedded-particle/sense-motion.ino
+++ embedded-particle/sense-motion.ino
@@ -19,7 +19,7 @@

 // tracks how many PIR reads have been high in a row
 const int reallyOnThreshold = 180;
-const int onThreshold = 20;
+const int onThreshold = 10;
 int highReads = 0;

 // 0 is off, 1 is motion, 2 is waving motion


Update EEPROM1024.ino

Update EEPROM1024.ino

--- examples/EEPROM1024/EEPROM1024.ino
+++ examples/EEPROM1024/EEPROM1024.ino
@@ -1,21 +1,9 @@
 /*
   EEPROM1024.ino
   AT24C1024 EEPROM Benchmark Sketch
-
-  Our project page is here:
-  http://www.arduino.cc/playground/Code/I2CEEPROM24C1024
-
-  From the datasheet:
+  http://playground.arduino.cc/Code/I2CEEPROM24C1024
+*/

-  The AT24C1024B provides 1,048,576 bits of serial electrically
-  erasable and programmable read only memory (EEPROM) organized
-  as 131,072 words of 8 bits each. The device’s cascadable
-  feature allows up to four devices to share a common two-wire
-  bus.
-
-  http://www.atmel.com/dyn/resources/prod_documents/doc5194.pdf
-
-*/
 #include <Wire.h>
 #include <AT24C1024.h>

@@ -41,7 +29,7 @@
   loop_size = random(1, 100);
   Serial.begin(9600);
   Serial.println();
-  Serial.println("AT24C1024 Library Benchmark Sketch");
+  Serial.println("AT24C1024 EEPROM Library Benchmark Sketch");
   Serial.println();
   writeByByteTest();
   readByByteTest();


Polished HelloWorld demo

Polished HelloWorld demo

--- examples/HelloWorld/HelloWorld.ino
+++ examples/HelloWorld/HelloWorld.ino
@@ -44,7 +44,8 @@
     }

     String str = TIVar::strVarToString8x(data, model);
-    Serial.println("Received: " + str);
+    Serial.print("Received: ");
+	Serial.println(str.c_str());
     return 0;
 }

@@ -66,8 +67,8 @@
     memset(header, 0, sizeof(header));
     TIVar::intToSizeWord(rval, header);
     header[2] = VarTypes82::VarString; // Variable type
-    header[3] = 0xAA; // Variable name (Str1)
-    header[4] = 0x00; // ^
+    header[3] = 0xAA; // Variable name (tVarStr)
+    header[4] = 0x00; // ^ (tStr1)
     *headerlen = 13;

     Serial.println("Sending: " + hello);


Update example.

Update example.

--- examples/humidity/humidity.ino
+++ examples/humidity/humidity.ino
@@ -7,7 +7,7 @@
 #include <Wire.h>
 #include <FaBoHumidity_HTS221.h>

-FaBoHumidity_HTS221 fabo_hts221;
+FaBoHumidity_HTS221 faboHumidity;

 void setup()
 {
@@ -15,17 +15,17 @@

   Serial.println("Checking I2C device...");

-  if(fabo_hts221.searchDevice()){
+  if(faboHumidity.searchDevice()){
     Serial.println("I am HTS221");
-    fabo_hts221.configuration();
-    fabo_hts221.powerOn();
+    faboHumidity.configuration();
+    faboHumidity.powerOn();
   }
 }

 void loop()
 {
-  double temp = fabo_hts221.getTemperature()/10;
-  double humidity = fabo_hts221.getHumidity()/10;
+  double temp = faboHumidity.getTemperature()/10;
+  double humidity = faboHumidity.getHumidity()/10;

   Serial.print(temp);
   Serial.println(" C");


Fixed missing scheduler.

Fixed missing scheduler.

--- examples/Sandbox/CosaPingPong/CosaPingPong.ino
+++ examples/Sandbox/CosaPingPong/CosaPingPong.ino
@@ -34,17 +34,17 @@
  */
 class Echo : public FSM {

-private:
-  str_P m_name;
-  uint16_t m_count;
-  FSM* m_port;
-
 public:
   /**
    * Construct the echo state machine. Name and port must be bound
    * before started.
    */
-  Echo() : FSM(initState), m_name(0), m_count(0), m_port(0) {}
+  Echo(Job::Scheduler* scheduler) :
+    FSM(initState, scheduler),
+    m_name(0),
+    m_count(0),
+    m_port(0)
+  {}

   /**
    * Bind name and port. The name is used for the trace print
@@ -58,6 +58,11 @@
     m_port = fsm;
   }

+private:
+  str_P m_name;
+  uint16_t m_count;
+  FSM* m_port;
+
   /**
    * The states; init, listen and echo.
    * init -> listen: print init message
@@ -68,9 +73,7 @@
   {
     UNUSED(type);
     Echo* echo = (Echo*) fsm;
-    trace.print(PSTR("init "));
-    trace.print(echo->m_name);
-    trace.println();
+    trace << PSTR("init ") << echo->m_name << endl;
     fsm->set_state(listenState);
     return (true);
   }
@@ -79,10 +82,11 @@
   {
     UNUSED(type);
     Echo* echo = (Echo*) fsm;
-    trace.print(echo->m_name);
-    trace.printf(PSTR("(count = %d)\n"), echo->m_count++);
+    trace << echo->time() << ':' << echo->m_name
+	  << '(' << echo->m_count++ << ')'
+	  << endl;
     fsm->set_state(echoState);
-    fsm->set_timer(512);
+    fsm->set_timer(500);
     return (true);
   }

@@ -96,10 +100,13 @@
   };
 };

+// Use the Watchdog job scheduler
+Watchdog::Scheduler scheduler;
+
 // The three echo state machines
-Echo ping;
-Echo pong;
-Echo pang;
+Echo ping(&scheduler);
+Echo pong(&scheduler);
+Echo pang(&scheduler);

 void setup()
 {


Update selftest.ino

Update selftest.ino

--- examples/selftest/selftest.ino
+++ examples/selftest/selftest.ino
@@ -81,7 +81,7 @@
   Tsunami.setFrequency(32768);
   Tsunami.setAmplitude(6000);
   delay(500);
-  assert_nearly_equal("input_amp_6", Tsunami.measurePeakVoltage(), 3048, 100);
+  assert_nearly_equal("input_amp_6", Tsunami.measurePeakVoltage(), 3048, 150);

   // TODO: Figure out why we don't get consistent values for this reading
   Tsunami.setAmplitude(1000);


fix ledNode ramps and rates

fix ledNode ramps and rates


Added stuff for using RTC

Added stuff for using RTC

--- fed-arduino_V3/fed-arduino_V3.ino
+++ fed-arduino_V3/fed-arduino_V3.ino
@@ -24,8 +24,7 @@
 const long minute2 = 60000; // 60000 milliseconds in a minute
 const long second2 =  1000; // 1000 milliseconds in a second

-RTC_DS1307 RTC;    //real time clock (on SD shield)
-String time;
+RTC_DS1307 RTC; //real time clock (on SD shield)

 int PIStates[] = { 1, 1 };
 int lastStates[] = { 1, 1 };
@@ -56,12 +55,13 @@
   setDisplayBrightness(64);
   updateDisplay();

-  //some stuff
+  //SD card pin setup
   pinMode(10, OUTPUT); //CS pin
   pinMode(SS, OUTPUT);

   //motor shield stuff
-
+  /*gMotorShield.begin();
+  gPtrToStepper->setSpeed(30);//*/

   //SD card stuff
   /*Wire.begin();
@@ -70,7 +70,7 @@
   if (! RTC.isrunning()) {
     Serial.println(F("RTC is NOT running!"));
     RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
-  }*/
+  }//*/

   delay(500);

@@ -183,3 +183,15 @@

 void setDisplayValues(String value)
 { LEDserial.print(value); }
+
+String currentTime()
+{
+  DateTime datetime = RTC.now();
+  String year = String(datetime.year(), DEC);
+  String month = String(datetime.month(), DEC);
+  String day  = String(datetime.day(),  DEC);
+  String hour  = String(datetime.hour(),  DEC);
+  String minute = String(datetime.minute(), DEC);
+  String second = String(datetime.second(), DEC);
+  return (month + "/" + day + " " + hour + ":" + minute + ":" + second);
+}


Delete Navigation_Array.ino

Delete Navigation_Array.ino

--- Arduino/Navigation_Array.ino
+++ Arduino/Navigation_Array.ino
@@ -1,216 +0,0 @@
-#include <TinyGPS++.h>
-#include <SoftwareSerial.h>
-/*
-This code reads the Analog Voltage output from the
-LV-MaxSonar sensors
-If you wish for code with averaging, please see
-playground.arduino.cc/Main/MaxSonar
-Please note that we do not recommend using averaging with our sensors.
-Mode and Median filters are recommended.
-*/
-/*
-  This code also uses TinyGPS++ liabrary to get lat and long
-  from adafruit gps
- */
-
-//Define GPS pins and boadrate
-static const int RXPin = 4, TXPin = 3;
-static const uint32_t GPSBaud = 9600;
-//Define gps object
-TinyGPSPlus gps;
-// The serial connection to the GPS device
-SoftwareSerial ss(RXPin, TXPin);
-
-const int anPin1 = 0;
-const int anPin2 = 1;
-const int anPin3 = 2;
-int digPin6 = 6, i=0,x = 0,num = 0;
-int distance1, distance2, distance3;
-
-const int sample = 5;// define number of samples when taking a reading -- min 3
-const int error = 5;// the number of inches between values that the sample fuction will read as the same
-int sum1[sample];
-int sum2[sample];
-int sum3[sample];
-void setup() {
-  Serial.begin(9600);  // sets the serial port to 9600
-  pinMode(digPin6, OUTPUT);
-  ss.begin(GPSBaud);
-}
-
-void start_sensor(){
-  digitalWrite(digPin6,HIGH);
-  delay(1);
-  digitalWrite(digPin6,LOW);
-}
-
-void calibrate(){
-  float samples = 5;
-  float latitude = 0;
-  float longitude = 0;
-  Serial.print(F("UP "));
-
-  if (gps.location.isValid())
-  {
-    for(i=0;i<samples;i++){
-      latitude = latitude + gps.location.lat();
-      longitude = longitude + gps.location.lng();
-      delay(1000);
-    }
-  }
-  else
-  {
-    Serial.print(F("INVALID"));
-  }
-  Serial.print(latitude/samples, 6);
-  Serial.print(" ");
-  Serial.print(longitude/samples, 6);
-  Serial.print(" ");
-
-}
-void read_sensors(){
-  /*
-  Scale factor is (Vcc/512) per inch. A 5V supply yields ~9.8mV/in
-  Arduino analog pin goes from 0 to 1024, so the value has to be divided by 2 to get the actual inches
-  */
-
-  distance1 = 0;
-  distance2 = 0;
-  distance3 = 0;
-
-   for(i=0;i<sample;i++){
-     sum1[i] = analogRead(anPin1)/2;
-     delay(50);
-     sum2[i] = analogRead(anPin2)/2;
-     delay(50);
-     sum3[i] = analogRead(anPin3)/2;
-     delay(50); //This is the equivant of the amount of sensors times 50.  If you changed this to 5 sensors the delay would be 250.
-   }
-
-
-
-  distance1 = mode(sum1);
-  distance2 = mode(sum2);
-  distance3 = mode(sum3);
-
-}
-
-int mode(int a[]) {
-
-   int maxValue = 0, maxCount = 0, i, j;
-
-   for (i = 0; i < sample; ++i) {
-      int count = 0;
-
-      for (j = 0; j < sample; ++j) {
-         if (a[j]<= a[i] + error && a[j]>= a[i] - error)
-         ++count;
-      }
-
-      if (count > maxCount) {
-         maxCount = count;
-         maxValue = a[i];
-      }
-
-   }
-
-  return maxValue;
-
-}
-void print_all(){
-
-  if(distance1 <= 200){
-    Serial.print("SF ");
-    Serial.print(distance1);// In inches
-    Serial.print(" ");
-    //Serial.println();
-  }
-  else{
-    Serial.print("SF ");
-    Serial.print(0);// In inches
-    Serial.print(" ");
-  }
-  if(distance2 >= 100){
-    Serial.print("SL ");
-    Serial.print(distance2);// In inches
-    Serial.print(" ");
-    //Serial.println();
-  }
-  else{
-    Serial.print("SL ");
-    Serial.print(0);// In inches
-    Serial.print(" ");
-  }
-  if(distance3 >= 100){
-    Serial.print("SR ");
-    Serial.print(distance3);// In inches
-    Serial.print(" ");
-    //Serial.println();
-  }
-  else{
-    Serial.print("SR ");
-    Serial.print(0);// In inches
-    Serial.print(" ");
-  }
-}
-//Print gps lat and long
-void print_gps(){
-Serial.print(F("LC "));
-  if (gps.location.isValid())
-  {
-    Serial.print(gps.location.lat(), 6);
-    Serial.print(F(" "));
-    Serial.print(gps.location.lng(), 6);
-  }
-  else
-  {
-    Serial.print(F("INVALID"));
-  }
-  //Serial.print(" ");
-  //Serial.println();
-
-}//end print_gps
-
-
-//Read gps Lat and long
-void read_gps(){
-  while(true){
-  while (ss.available() > 0)
-    if (gps.encode(ss.read())){
-      //gps.encode(ss.read());
-      print_gps();
-      return;
-    }
-
-  if (millis() > 5000 && gps.charsProcessed() < 10)
-  {
-    Serial.println(F("No GPS detected: check wiring."));
-  }
-
-  }
-}//end read_gps
-
-
-void loop() {
-  start_sensor();
-  read_sensors();
-  if(Serial.available())
-  {
-    x=(Serial.read()-'0');
-  }
-  if(x == 1)
-  {
-    print_all();
-    calibrate();
-    x=0;
-  }
-  else
-  {
-    print_all();
-    read_gps();
-  }
-
-  Serial.println();
-}
-
-


Update feather_code.ino

Update feather_code.ino

--- code/feather_code.ino
+++ code/feather_code.ino
@@ -54,6 +54,21 @@

 // LoRaWAN end-device address (DevAddr)
 static const u4_t DEVADDR = 0x26011CD5 ; // <-- Change this address for every node!
+
+
+//Lichtsensor
+const int analogInPin = A1; //Analog input pin that potentiometer is attached to
+const int analogOutPin = 9; // Analog output pin that the LED is attached to
+
+int sensorValue = 0;        // value read from the pot
+int outputValue = 0;        // value output to the PWM (analog out)
+
+
+//Bodenfeuchtigkeitssensor
+int val = 0; //value for storing moisture value
+int soilPin = A2; //Declare a variable for the soil moisture sensor
+int soilPower = 7; //Variable for Soil moisture
+

 // These callbacks are only used in over-the-air activation, so they are
 // left empty here (we cannot leave them out completely unless
@@ -64,7 +79,7 @@

-static uint8_t mydata[5];
+static uint8_t mydata[7];
 static osjob_t sendjob;

 // Schedule TX every this many seconds (might become longer due to duty
@@ -76,7 +91,7 @@
   .nss = 8,
   .rxtx = LMIC_UNUSED_PIN,
   .rst = 5,
-  .dio = {3, 6, LMIC_UNUSED_PIN},
+  .dio = {3, 6, LMIC_UNUSED_PIN},
 };

 void onEvent (ev_t ev) {
@@ -162,7 +177,7 @@
   mydata[1] = lowtemp;

   float alt = bme.readAltitude(SEALEVELPRESSURE_HPA);
-  uint16_t altitude = (uint16_t) ((alt / 1013.25) * 100);
+  uint16_t altitude = (uint16_t) (alt / 1013.25 * 100);
   uint8_t alti = (uint8_t) altitude;

   mydata[2] = alti;
@@ -180,22 +195,37 @@
   Serial.println(humidity);
   Serial.println(mydata[3]);
   Serial.println();
-  Serial.println(mydata[4]);
+  Serial.println(mydata[4]);
+
+
+  sensorValue = analogRead(analogInPin);
+  float voltage = (3.3/4096*sensorValue);
+  float strom = (voltage/10020);
+  float lichtstrom = (strom*2*1000000);
+  lichtstrom = lichtstrom / 6.5852;         //In Prozent 658,52 (Maximalwert) / 100
+  uint8_t lichtstrom_int = (uint8_t) lichtstrom;
+
+  Serial.print("Helligkeit: ");
+  Serial.print(lichtstrom);
+  Serial.print("%");
+  Serial.print("\n");
+
+
+  mydata[5] = lichtstrom_int;
+
+  soilPower = analogRead(soilPin);
+
+  uint8_t percent = (uint8_t) ((analogRead(A2)/33.30F) * 100);
+  Serial.println(percent);
+
+  mydata[6] = percent;
+
+
 }

 void do_send(osjob_t* j) {
-
-  /*void sensor_data() {
-    uint16_t temperature = bme.readTemperature();
-    uint8_t hightemp = (temperature & 0xFF00) >> 8;
-    uint8_t lowtemp = (temperature & 0x00FF);
-
-    uint8_t altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
-
-    uint16_t humidity = bme.readHumidity();
-    uint8_t highhum = (humidity & 0xFF00);
-    uint8_t lowhum = (humidity & 0x00FF);*/
+
   sensor_data();

   // Check if there is not a current TX/RX job running
@@ -207,14 +237,6 @@
     Serial.println(F("Packet queued"));
   }
   // Next TX is scheduled after TX_COMPLETE event.
-
-  //Messwerte der Sensoren
-
-  //Serial.print(bme.readTemperature());
-
-  /*Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
-
-    Serial.print(bme.readHumidity());*/
 }

 void setup() {
@@ -231,6 +253,11 @@

   Serial.begin(115200);
   Serial.println(F("Starting"));
+
+  analogReadResolution(12); //Lichtsensor, Bodenfeuchtigkeitssensor
+
+  pinMode(soilPower, OUTPUT); //Set D7 as an output
+  digitalWrite(soilPower, LOW); //Set to Low so no power is flowing through the sensor

 #ifdef VCC_ENABLE
   // For Pinoccio Scout boards


Esp8266_01 now show a map of all connected i2c devices

--- src/resource/Esp8266_01/Esp8266_01.ino
+++ src/resource/Esp8266_01/Esp8266_01.ino
@@ -59,7 +59,7 @@

 bool i2cInitiated = false;

-int16_t bus;
+int16_t bus = 0;
 int16_t device;
 int16_t size;
 String i2cBuffer;
@@ -114,11 +114,53 @@
   Response when accessing the esp8266-01 root
 */
 void rootResponse(){
-
-  String msg = "Welcome to ESP8266 and the i2c interface
Hostname: ";
+
+  Serial.println("rootResponse");
+  int error;
+  int nDevices;
+
+  String msg = "<!DOCTYPE html>";
+  msg = msg + "Welcome to ESP8266 and the i2c interface
Hostname: ";
   msg = msg + String(hostName);
   msg = msg + "
Ip-address: ";
   msg = msg +  DisplayAddress(ipaddress);
+  msg = msg + "
";
+  msg = msg + "

Address	0	1	2	3	4	5	6	7	8	9	a	b	c	d	e	f	" ;
+  // Loop over all i2c addresses to create a map of all connected devices
+  Serial.println("Scanning i2c devices");
+  if (!i2cInitiated) i2cBegin(bus);
+  nDevices = 0;
+  for(int address = 0; address < 127; address++ ){
+    Serial.println(address);
+    // The i2c_scanner uses the return value of
+    // the Write.endTransmisstion to see if
+    // a device did acknowledge to the address.
+    // if (address == 0){msg = msg + "
";}
+    if (address % 16 == 0){msg = msg + "

	";}
+
+    if (address > 3){
+      Wire.beginTransmission(address);
+      error = Wire.endTransmission();
+    }
+    else {
+      error = 4;
+    }
+
+    if (error == 0){
+      if (address<16){
+        msg = msg + "0x0" + String(address, HEX) + "	";
+        }
+      else{
+        msg = msg + "0x" + String(address, HEX) + "	";
+        }
+      nDevices++;
+      }
+    else {
+        msg = msg + "----	";
+      }
+    }
+
+  msg = msg + "----

";
   server.send(200, "text/html", msg);
 }

@@ -281,5 +323,4 @@
     Wire.begin(1,3);
   }
   i2cInitiated = true;
-}
-
+}


WMS Update

WMS Update

--- BiotechHardware/wms/wms.ino
+++ BiotechHardware/wms/wms.ino
@@ -21,10 +21,6 @@
   Wire.begin();
   Serial.begin(9600);
   Serial.println("Start");
-  /*if(Ethernet.begin(mac) == 0){
-    Serial.println("Failed to configure Ethernet using DHCP");
-    Ethernet.begin(mac, ip);
-  }*/
   Ethernet.begin(mac, ip);
   pinMode(relay1, OUTPUT);
   pinMode(relay2, OUTPUT);
@@ -67,12 +63,13 @@

   if(lux < 50){
     Serial.println("Kuras");
+    digitalWrite(relay1, HIGH);
     digitalWrite(relay2, LOW);
     kuras = true;
   }

   if(kuras){
-    if((val.toInt()-cm) < 5){
+    if((val.toInt()-cm) < 10){
       Serial.println("Kosong abis kuras");
       digitalWrite(relay2, HIGH);
       digitalWrite(relay1, HIGH);


3 e 4

3 e 4

+


LEDs now show all green when in AP setup mode.


Addressed comments by @tfoote.

Addressed comments by @tfoote.

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_waffle/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_waffle/turtlebot3_core/turtlebot3_core.ino
@@ -154,18 +154,8 @@
 *******************************************************************************/
 void update_time()
 {
-  uint32_t n_micros = micros();
-  ros::Time next = nh.now();
-  if (next.sec < current_time.sec) {
-    /*
-     * bad time was received, so we
-     * continue to interpolate the
-     * existing time.
-     */
-    return;
-  }
-  current_time = next;
-  current_offset = n_micros;
+  current_offset = micros();
+  current_time = nh.now();
 }

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


Fixing bug :D

Fixing bug :D

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -315,8 +315,9 @@
   int pointer = millis() / 1000 / TIMEFRAME % timeStorage;
   if (pointer != storagePointer)
   {
-    storage[storagePointer] = 1;
     storagePointer = pointer;
+    storage[storagePointer] = 0;
+
     pointerChanged();
   }
 }


mit struct data erweitert um die Daten besser zu uebertragen

--- ATtiny_Humidor_Monitoring/ATtiny_Humidor_Monitoring.ino
+++ ATtiny_Humidor_Monitoring/ATtiny_Humidor_Monitoring.ino
@@ -1,74 +1,73 @@
 /*
- * Humidor Überwachung mit einem ATtiny85 und einem 433MHz Sender.
- *
- * Der ATtiny85 wird die Sensorendaten von der Luftfeuchte und Temperatur Auswerten, und falls es einen Grenzwert
- * überschreitet einen Lüfter für die Luftfeuchte einschalten.
- *
- * Somit erzeugt es die richtige Feuchtigkeit im Humidor.
- *
- * Da der ATtiny85 nur begrenzte Pins hat, wird noch ein Shiftregister und ein Transistor in die Schaltung eingebaut.
- *
- *
- * ATtiny85:
- * ---------
- * VCC = 5V
- * GND = GND
- * PB0 = Shift Register Clock
- * PB1 = Shift Register Serial Data
- * PB2 = Shift Register Latchpin
- * PB3 = 433MHz Sender
- * PB4 = DHT11 Sensor
- *
- * shiftRegister SN74HC165N Belegung:
- * out1 = schieber / oeffner
- * out2 = Luefter
- * in planung:
- * out3 = 2 Wire LCD Pin 1
- * out4 = 2 Wire LCD Pin 2
- *
- * Info:
- * Falls ein anderer Arduino Controller verwendet wird, muss man die Pins anpassen.
- *
- * MIT License:
- * Copyright (c) 2017 Günter Bailey
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- * documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * MIT Lizenz in Deutsch:
- * Copyright (c) 2017 Günter Bailey
- *
- * Hiermit wird unentgeltlich jeder Person, die eine Kopie der Software und der zugehörigen Dokumentationen (die "Software") erhält,
- * die Erlaubnis erteilt, sie uneingeschränkt zu nutzen, inklusive und ohne Ausnahme mit dem Recht, sie zu verwenden,
- * zu kopieren, zu verändern, zusammenzufügen, zu veröffentlichen, zu verbreiten, zu unterlizenzieren und/oder zu verkaufen,
- * und Personen, denen diese Software überlassen wird, diese Rechte zu verschaffen, unter den folgenden Bedingungen:
- *
- * Der obige Urheberrechtsvermerk und dieser Erlaubnisvermerk sind in allen Kopien oder Teilkopien der Software beizulegen.
- * DIE SOFTWARE WIRD OHNE JEDE AUSDRÜCKLICHE ODER IMPLIZIERTE GARANTIE BEREITGESTELLT,
- * EINSCHLIESSLICH DER GARANTIE ZUR BENUTZUNG FÜR DEN VORGESEHENEN ODER EINEM BESTIMMTEN ZWECK SOWIE JEGLICHER RECHTSVERLETZUNG,
- * JEDOCH NICHT DARAUF BESCHRÄNKT. IN KEINEM FALL SIND DIE AUTOREN ODER COPYRIGHTINHABER FÜR JEGLICHEN SCHADEN ODER
- * SONSTIGE ANSPRÜCHE HAFTBAR ZU MACHEN, OB INFOLGE DER ERFÜLLUNG EINES VERTRAGES,
- * EINES DELIKTES ODER ANDERS IM ZUSAMMENHANG MIT DER SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN.
- *
- *
- * https://www.arduino.cc/en/Tutorial/ShiftOut
- *
- * Im Bereich von 65-75% relativer Luftfeuchtigkeit können Zigarren bedenkenlos langfristig gelagert werden.
- * Vorsicht ist allerdings geboten, wenn die relative Luftfeuchtigkeit 80% übersteigt.
- * In diesen Fällen kann die Zigarre anfangen zu faulen, es können sich Schimmelpilze und andere Pilzarten bilden.
- *
- */
-#include<stdlib.h>
+   Humidor Überwachung mit einem ATtiny85 und einem 433MHz Sender.
+
+   Der ATtiny85 wird die Sensorendaten von der Luftfeuchte und Temperatur Auswerten, und falls es einen Grenzwert
+   überschreitet einen Lüfter für die Luftfeuchte einschalten.
+
+   Somit erzeugt es die richtige Feuchtigkeit im Humidor.
+
+   Da der ATtiny85 nur begrenzte Pins hat, wird noch ein Shiftregister und ein Transistor in die Schaltung eingebaut.
+
+
+   ATtiny85:
+   ---------
+   VCC = 5V
+   GND = GND
+   PB0 = Shift Register Clock
+   PB1 = Shift Register Serial Data
+   PB2 = Shift Register Latchpin
+   PB3 = 433MHz Sender
+   PB4 = DHT11 Sensor
+
+   shiftRegister SN74HC165N Belegung:
+   out1 = schieber / oeffner
+   out2 = Luefter
+   in planung:
+   out3 = 2 Wire LCD Pin 1
+   out4 = 2 Wire LCD Pin 2
+
+   Info:
+   Falls ein anderer Arduino Controller verwendet wird, muss man die Pins anpassen.
+
+   MIT License:
+   Copyright (c) 2017 Günter Bailey
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
+   documentation files (the "Software"), to deal in the Software without restriction,
+   including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+   subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+   MIT Lizenz in Deutsch:
+   Copyright (c) 2017 Günter Bailey
+
+   Hiermit wird unentgeltlich jeder Person, die eine Kopie der Software und der zugehörigen Dokumentationen (die "Software") erhält,
+   die Erlaubnis erteilt, sie uneingeschränkt zu nutzen, inklusive und ohne Ausnahme mit dem Recht, sie zu verwenden,
+   zu kopieren, zu verändern, zusammenzufügen, zu veröffentlichen, zu verbreiten, zu unterlizenzieren und/oder zu verkaufen,
+   und Personen, denen diese Software überlassen wird, diese Rechte zu verschaffen, unter den folgenden Bedingungen:
+
+   Der obige Urheberrechtsvermerk und dieser Erlaubnisvermerk sind in allen Kopien oder Teilkopien der Software beizulegen.
+   DIE SOFTWARE WIRD OHNE JEDE AUSDRÜCKLICHE ODER IMPLIZIERTE GARANTIE BEREITGESTELLT,
+   EINSCHLIESSLICH DER GARANTIE ZUR BENUTZUNG FÜR DEN VORGESEHENEN ODER EINEM BESTIMMTEN ZWECK SOWIE JEGLICHER RECHTSVERLETZUNG,
+   JEDOCH NICHT DARAUF BESCHRÄNKT. IN KEINEM FALL SIND DIE AUTOREN ODER COPYRIGHTINHABER FÜR JEGLICHEN SCHADEN ODER
+   SONSTIGE ANSPRÜCHE HAFTBAR ZU MACHEN, OB INFOLGE DER ERFÜLLUNG EINES VERTRAGES,
+   EINES DELIKTES ODER ANDERS IM ZUSAMMENHANG MIT DER SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN.
+
+
+   https://www.arduino.cc/en/Tutorial/ShiftOut
+
+   Im Bereich von 65-75% relativer Luftfeuchtigkeit können Zigarren bedenkenlos langfristig gelagert werden.
+   Vorsicht ist allerdings geboten, wenn die relative Luftfeuchtigkeit 80% übersteigt.
+   In diesen Fällen kann die Zigarre anfangen zu faulen, es können sich Schimmelpilze und andere Pilzarten bilden.
+
+*/
 //VirtualWire lib
 #include <VirtualWire.h>
 #undef int
@@ -77,14 +76,17 @@
 #undef float
 #undef round

-int txPin = 3; //ueber Pin 3 die Daten senden
+const int txPin = 3; //ueber Pin 3 die Daten senden
+//const int rxPin_unused = 99;
+//const int pttPin_unused = 98;
+

 //attiny85 shiftregister
 /*
-#define latchPin PB2
-#define clockPin PB0
-#define dataPin PB1
-int dhtPin = PB4; //DHT11 Pin
+  #define latchPin PB2
+  #define clockPin PB0
+  #define dataPin PB1
+  int dhtPin = PB4; //DHT11 Pin
 */
 //arduino shiftregister
 #define latchPin 9 //PL
@@ -94,12 +96,11 @@
 byte reg = 0;

 //DHT11 und 22 lib
-#include <Adafruit_Sensor.h>
 #include <DHT.h>
 #include <DHT_U.h>
 #define dhtPin 5 //DHT Pin
 // Uncomment the type of sensor in use:
-//#define DHTTYPE DHT11 // DHT 11
+//#define DHTTYPE DHT11 // DHT 11
 #define DHTTYPE DHT22 // DHT 22 (AM2302)
 //#define DHTTYPE DHT21 // DHT 21 (AM2301)
 DHT_Unified dht(dhtPin, DHTTYPE);
@@ -112,11 +113,14 @@
 boolean fan1 = false;

 void setup() {
-  Serial.begin(115200);
+  //Serial.begin(115200);
   // Initialise the IO and ISR
-  vw_set_ptt_inverted(true); // Required for RF Link module
-  vw_setup(1200); // Bits per sec
+  vw_set_ptt_inverted(false); // Required for RF Link module
   vw_set_tx_pin(txPin); // pin 3 is used as the transmit data out into the TX Link module, change this as per your needs
+  //vw_set_ptt_pin(pttPin_unused);
+  //vw_set_rx_pin(rxPin_unused);
+  vw_setup(1200); //Bits pro Sekunde
+
   //shiftregister
   pinMode(latchPin, OUTPUT);
   pinMode(clockPin, OUTPUT);
@@ -126,43 +130,42 @@
   //init DHT device
   dht.begin();
   sensor_t sensor;
-  Serial.println(F("setup ende"));
+  //Serial.println(F("setup ende"));
 }

 unsigned long task1, task2 = 0;
 void loop() {
   unsigned long currmillis = millis();
-
+
   // Wenn die Zeit (worktime) kleiner als die Vergangene Zeit ist, Sende eine Nachricht.
   if ((unsigned long)(currmillis - task1) >= stime || (currmillis == 1000)) {
-    Serial.println(F("check DHT22"));
-    //send_msg("Testnachricht_1");
-    compute_msg(get_temp(), get_hum());
+    //Serial.println(F("check DHT22"));
+    TransmitData(get_temp(), get_hum());
     task1 = millis();
   }

   // checke die Luftfeuchtigkeit und wenn zu niedrig schalte Luefter ein.
   if ((unsigned long)(currmillis - task2) >= mtime) {
-    Serial.println(F("check if hum"));
+    //Serial.println(F("check if hum"));
     if ((float)(get_hum() <= 65.0 || get_hum() <= 75.0)) {
       // switch ventilator on
-      Serial.println(F("switch Ventilator on"));
+      //Serial.println(F("switch Ventilator on"));
       if (!fan1) {
         //oeffne Luefter schlitz
         int i = 1;
         //bitSet(reg, i);
         updateShiftRegister(i);
-        delay(60);
+        delay(15);
         //switch fan1 on
         i = 14;
         bitSet(reg, i);
         updateShiftRegister(i);
-        delay(60);
+        delay(20);
         fan1 = true;
       }
     } else {
       if (fan1) {
-        Serial.println(F("Switch Ventilator off"));
+        //Serial.println(F("Switch Ventilator off"));
         // switch fan1 off und schliesse den Schlitz
         reg = 0;
         updateShiftRegister(0);
@@ -172,58 +175,67 @@
     }
     task2 = millis();
   }
-
+
 }

 void updateShiftRegister(int i) {
+  /*
   Serial.print(F("REG = "));
   Serial.println(i);
   Serial.println(F("use shiftregister"));
-   digitalWrite(latchPin, LOW);
-   shiftOut(dataPin, clockPin, MSBFIRST, i);
-   digitalWrite(latchPin, HIGH);
+  */
+  digitalWrite(latchPin, LOW);
+  shiftOut(dataPin, clockPin, MSBFIRST, i);
+  digitalWrite(latchPin, HIGH);
 }

 float get_temp() {
   // Read temperature as Celsius (the default)
-  sensors_event_t event;
+  sensors_event_t event;
   dht.temperature().getEvent(&event);
-  Serial.print(F("Temperature in C = "));
-  Serial.println(event.temperature);
+  //Serial.print(F("Temperature in C = "));
+  //Serial.println(event.temperature);
   return event.temperature;
 }

 float get_hum() {
   // Read humidity
-  sensors_event_t event;
+  sensors_event_t event;
   dht.humidity().getEvent(&event);
-  Serial.print(F("Humidity in % = "));
-  Serial.println(event.relative_humidity);
+  //Serial.print(F("Humidity in % = "));
+  //Serial.println(event.relative_humidity);
   return event.relative_humidity;
 }

-void compute_msg(float temp, float hum){
+void TransmitData(float temp, float hum) {
   /*
-   * compute message for sending data
-   * dtostrf(FLOAT,WIDTH,PRECSISION,BUFFER);
-   */
-   Serial.println(temp);
-   Serial.println(hum);
-   char str1, str2;
-   str1 = dtostrf(temp,5,2,7);
-   str2 = dtostrf(hum,5,2,7);
-   Serial.println(str1);
-   send_msg(str1);
-}
-
-void send_msg(char message) {
-  /*
-   * Sending data over 433MHz Sender
-   */
-  Serial.print(F("Sending Message = "));
-  Serial.println(message);
-  const char *msg = message; // this is your message to send
-  vw_send((uint8_t *)msg, strlen(msg));
-  vw_wait_tx(); // Wait for message to finish
-}
-
+   * Erstelle eine Datenstruktur und
+   * sende es danach mit einer simplen
+   * Pruefsumme an den Empfaenger
+   *
+  */
+  struct wData_STRUCT {
+    byte identity;
+    float s1;
+    float s2;
+    int checksum;
+  };
+  //Serial.println((temp * 100));
+  //Serial.println((hum * 100));
+
+  //Defines structure wData as a variable (retaining structure);
+  wData_STRUCT wData;
+
+  //Fill in the data.
+  wData.identity = 90;
+  wData.s1 = (temp * 100);
+  wData.s2 = (hum * 100);
+  wData.checksum = ((temp * 100) + (hum * 100)); //erstelle eine Pruefsumme mit den 2 Werten
+
+  //Sende die Daten zur Sicherheit 3x
+  //Serial.println(F("sending data"));
+  vw_send((uint8_t *)&wData, sizeof(wData));
+  vw_wait_tx();
+  delay(20);
+}
+


Cleaned up conflicts

Cleaned up conflicts

--- Pan_Tilt_laser/Pan_Tilt_laser.ino
+++ Pan_Tilt_laser/Pan_Tilt_laser.ino
@@ -69,8 +69,6 @@
   delay(2000);

   Serial.println("setup complete");
-
-
 }

 int probVal = 10;
@@ -119,21 +117,13 @@

 int getMarkovDirection(panTiltPos_t *pt, int changeProb){
-<<<<<<< HEAD
+
     int prob = changeProb;

     if(pt->dir == 0){
       pt->dir = 1;
     }
-=======
-  int prob = changeProb;
->>>>>>> Dev
-
-
-<<<<<<< HEAD
-=======
-
->>>>>>> Dev
+

     if((pt->dir == 1 && pt->angle >= pt->midAngle) || (pt->dir == -1 && pt->angle <= pt->midAngle)){
       prob += abs(pt->midAngle - pt->angle);


fixed function pointer array

fixed function pointer array

--- RaceTimer/RaceTimer/RaceTimer.ino
+++ RaceTimer/RaceTimer/RaceTimer.ino
@@ -34,7 +34,7 @@
 void chronoView();
 void resultsView();

-int (*views[4]) ();
+void (*views[4]) ();
 /* End Menu Definitions */

 void setup() {


Update edge agent

Update edge agent

--- AndroidTVGateway/edge-agent/edge-agent.ino
+++ AndroidTVGateway/edge-agent/edge-agent.ino
@@ -5,7 +5,8 @@

 #define DHTPIN            6
 #define DHTTYPE           DHT11
-#define LED               13
+#define LED_LIGHT         13
+#define DOOR_LOCK         7

 DHT dht(DHTPIN, DHTTYPE);
 SoftwareSerial XBee(2, 3); // RX, TX
@@ -14,20 +15,29 @@
   XBee.begin(9600);
   Serial.begin(9600);
   dht.begin();
-  pinMode(LED, OUTPUT);
+  pinMode(LED_LIGHT, OUTPUT);
+  pinMode(DOOR_LOCK, OUTPUT);
+  digitalWrite(DOOR_LOCK, HIGH);
+  XBee.print("Device Connected\r");
 }

 void loop() {
   if (XBee.available()) {
-    char a = XBee.read();
-    Serial.write(a);
-    if (a == 'H') {
-      digitalWrite(LED, HIGH);
-      XBee.print("OK\r");
-    } else if (a == 'L') {
-      digitalWrite(LED, LOW);
-      XBee.print("OK\r");
-    } else if (a == 'D') {
+    String msg = XBee.readString();
+    Serial.println(msg);
+    if (msg == "LON\r") {
+      digitalWrite(LED_LIGHT, HIGH);
+      XBee.print("Light ON\r");
+    } else if (msg == "LOFF\r") {
+      digitalWrite(LED_LIGHT, LOW);
+      XBee.print("Light OFF\r");
+    }else if (msg == "DOPEN\r") {
+      digitalWrite(DOOR_LOCK, LOW);
+      XBee.print("Door Lock Open\r");
+    } else if (msg == "DCLOSE\r") {
+      digitalWrite(DOOR_LOCK, HIGH);
+      XBee.print("Door Lock Close\r");
+    } else if (msg == "D\r") {
       int h = dht.readHumidity();
       int t = dht.readTemperature();
       XBee.print("Humidity: ");


fix example

fix example

--- examples/full_test_suite/full_test_suite.ino
+++ examples/full_test_suite/full_test_suite.ino
@@ -130,7 +130,8 @@

 void DELETE_tests(){
   describe("Test DELETE with path");
-  test_status(client.del("/data"));
+  //note: requires a special endpoint
+  test_status(client.del("/del"));

   describe("Test DELETE with path and body");
   test_status(client.del("/data", post_body));