Switch to hardware serial

Switch to hardware serial

Avoids interrupt conflicts.

--- water_heater_monitor/water_heater_monitor.ino
+++ water_heater_monitor/water_heater_monitor.ino
@@ -2,13 +2,13 @@
  * Listens for serial data from an IMC Eagle solar water heater controller and
  * uploads it to a waiting server.
  *
- * Assumes an CC3000-based wireless network connectiom shield and serial connection
- * via SoftwareSerial on pins 6 and 7.
+ * Assumes an CC3000-based wireless network connectiom shield and serial
+ * connection to athe Eagle controller via hardware serial.
  */

 #include <Adafruit_CC3000.h>
+#include "utility/debug.h"
 #include <SPI.h>
-#include <SoftwareSerial.h>

 #include "keys.h"

@@ -17,25 +17,24 @@
 #define ADAFRUIT_CC3000_VBAT  5
 #define ADAFRUIT_CC3000_CS    10

-#define IDLE_TIMEOUT_MS  3000
+#define IDLE_TIMEOUT_MS       2000

 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER);
 Adafruit_CC3000_Client client;

-SoftwareSerial data_port(6, 7);
 unsigned long lastWebUpdateTime = 0;
 char eagle_data[81];
 uint8_t data_index = 0;

 void setup () {
-  Serial.begin(115200);
+  Serial.begin(2400);
   Serial.println(F("\nWater Heater Monitor"));

   // CC3000 setup
-  Serial.print(F("initializing network... "));
+  Serial.print(F("Initializing network... "));
   if (!cc3000.begin()) {
-    Serial.println(F("unable to initialise the CC3000! Check your wiring?"));
+    Serial.println(F("unable to initialise the CC3000!"));
     while(1);
   }
   if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
@@ -45,24 +44,17 @@
   Serial.println(F("wireless connection successful."));

   while (!cc3000.checkDHCP()) {
-    delay(100); // TODO: Insert a DHCP timeout!
+    delay(100);
   }

   uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
-  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) {
+  if (!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) {
     Serial.println(F("Unable to retrieve network info!"));
   } else {
-    Serial.print(F("  IP Addr: ")); cc3000.printIPdotsRev(ipAddress);
-    Serial.print(F("/"));           cc3000.printIPdotsRev(netmask);   Serial.println();
-    Serial.print(F("  Gateway: ")); cc3000.printIPdotsRev(gateway);   Serial.println();
-    Serial.print(F("  DHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);  Serial.println();
-    Serial.print(F("  DNSserv: ")); cc3000.printIPdotsRev(dnsserv);   Serial.println();
+    Serial.print(F("  IP Addr: ")); cc3000.printIPdotsRev(ipAddress); Serial.println();
   }

   initThermometer();
-
-  // Data port setup
-  data_port.begin(2400);

   Serial.println(F("Waiting for data..."));
 }
@@ -73,19 +65,27 @@

   // If we haven't updated in 5 minutes, send along a "PING" to keep showing something.
   if (now > lastWebUpdateTime + 300000 || now < lastWebUpdateTime) {
+    //strcpy(eagle_data, "0.05  120.0  110.0  12.0  159.0  100.0  110.0  ON  OFF  ");
+    //updateWeb();
+
     data_index = 0;
     eagle_data[data_index] = '\0';
     updateWeb();
   }
+}

-  if (data_port.available()) {
-    char c = data_port.read();
+
+void serialEvent() {
+  while (Serial.available()) {
+    char c = Serial.read();
     if (c) UDR0 = c;

     // Assume a LF is the end of the line
     if (c == '\n' && strlen(eagle_data) > 0) {
       // Update once per minute
       // Also, don't send any Eagle header messages we come across.
+      unsigned long now = millis();
+
       if ((now > lastWebUpdateTime + 60000 || now < lastWebUpdateTime) && strncmp(eagle_data, "RUNTIME", 7) != 0) {
         updateWeb();
       }
@@ -95,7 +95,12 @@
       eagle_data[data_index] = '\0';
     } else if (c != '\r') {
       // Capture everything else (but not a CR)
-      eagle_data[data_index++] = c;
+      if (data_index < 80) {
+        eagle_data[data_index++] = c;
+      } else {
+        // This case should never happen, but avoid the overrun just the same :)
+        data_index = 0;
+      }
       eagle_data[data_index] = '\0';
     }
   }
@@ -104,46 +109,48 @@

 void updateWeb() {
   Serial.println(F("Sending data..."));
-  Serial.println(eagle_data);
+
+  // The Adafruit CC3000 library only supports about 90 bytes in the fastrprint()
+  // method, therefore we need two char arrays to hold all the Eagle query args.
+  char eagle_query_args1[66] = "&runtime=0:00&coll_t=&stor_t=&diff_t=&hili_t=";
+  char eagle_query_args2[66] = "&aux_1=&aux_2=&pump=OFF&uplim=OFF&fault=";
+
+  if (strlen(eagle_data) > 0) {
+    char *tokenptr;
+
+    sprintf(eagle_query_args1, "&runtime=%s&coll_t=%s&stor_t=%s&diff_t=%s&hili_t=%s",
+      strtok_r(eagle_data, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr)
+    );
+
+    sprintf(eagle_query_args2, "&aux_1=%s&aux_2=%s&pump=%s&uplim=%s&fault=%s",
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr),
+      strtok_r(NULL, " ", &tokenptr)
+    );
+  }
+
+  // Convert the temerature float to something fastrprint likes
+  char temp_str[7]; // "123.45"
+  dtostrf(getTemperature(), 1, 2, temp_str);

   client.connect(PHANT_HOST, PHANT_HOST_PORT);
   if (client.connected()) {
-    lastWebUpdateTime = millis();
-
-    // Convert the temerature float to something fastrprint likes
-    char temp_str[7]; // "123.45"
-    dtostrf(getTemperature(), 1, 2, temp_str);
-
     client.fastrprint(F("GET /input/")); client.fastrprint(PHANT_PUBLIC_KEY);
     client.fastrprint(F("?private_key=")); client.fastrprint(PHANT_PRIVATE_KEY);
+    client.fastrprint(eagle_query_args1);
+    client.fastrprint(eagle_query_args2);
     client.fastrprint(F("&ambient_t=")); client.fastrprint(temp_str);
-
-    if (strlen(eagle_data) == 0) {
-      client.fastrprint(F("&runtime=0:00&coll_t=&stor_t=&diff_t=&hili_t=&aux_1=&aux_2=&pump=OFF&uplim=OFF&fault="));
-    } else {
-      char *tokenptr;
-
-      client.fastrprint(F("&runtime=")); client.fastrprint(strtok_r(eagle_data, " ", &tokenptr));
-      client.fastrprint(F("&coll_t=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&stor_t=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&diff_t=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&hili_t=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&aux_1=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&aux_2=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&pump=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-      client.fastrprint(F("&uplim=")); client.fastrprint(strtok_r(NULL, " ", &tokenptr));
-
-      // fault can be null and fastrprint pukes on NULL
-      client.fastrprint(F("&fault="));
-      char *fault = strtok_r(NULL, " ", &tokenptr);
-      if (fault != NULL) {
-        client.fastrprint(fault);
-      }
-    }
-    client.fastrprintln(F(" HTTP/1.1"));
+    client.fastrprint(F(" HTTP/1.1\r\n"));

     client.fastrprint(F("Host: ")); client.fastrprintln(PHANT_HOST);
-    client.fastrprintln("");
+
+    client.fastrprint("\r\n");

     // Show the response
     unsigned long lastRead = millis();
@@ -156,10 +163,9 @@
     }

     client.close();
+    lastWebUpdateTime = millis();
     Serial.println(F("Done."));
   } else {
     Serial.println(F("Web server connection failed."));
   }
-
-  data_port.flush();  // clear any data in the serial buffer we missed while sending.
 }


cleanups

cleanups

--- src/pirNet.ino
+++ src/pirNet.ino
@@ -1,7 +1,6 @@
 // Copyright 2016 Gary Boone

 #include <ArduinoOTA.h>
-#include <ESP8266WiFi.h>       // 1 Must come before ESP8266WebServer.h
 #include "./buildVersion.h"
 #include "./configMgr.h"
 #include "./displayMgr.h"
@@ -12,21 +11,16 @@
 #include "./wifiMgr.h"
 #include "./udpMgr.h"

-// Quotes and parentheses must be balanced.
-#define MULTILINE_STRING(...) #__VA_ARGS__
-
 // Pins
 const int pirInputPin = 12;
 const int neoPixelArrayPin = 15;
+
+// Display
 const int neoPixelBrightness = 50;

 // UDP
 IPAddress ipBroadCast(192, 168, 1, 255);
 unsigned int udplocalPort = 2390;  // TODO(Gary): change to 6484
-
-// LEDs
-const int ledBlue = 2;
-const int ledRed = LED_BUILTIN;

 // Timers
 const int flipBlueInterval = 200;  // ms
@@ -34,6 +28,10 @@
 const int updatePIRInterval = 1000;  // ms
 const int receiveUDPInterval = 100;  // ms
 const int testUDPSendInterval = 2000;  // ms
+
+// LEDs
+const int ledBlue = 2;
+const int ledRed = LED_BUILTIN;

 // Build version
 const String software_version = buildVersionString(__TIMESTAMP__);
@@ -46,7 +44,7 @@
 TimerMgr timerMgr;
 DisplayMgr displayMgr(neoPixelArrayPin, neoPixelBrightness);

-// Location
+// Location global
 location_t loc(1, 1, 0x123456);


cleanups

cleanups

--- src/pirNet.ino
+++ src/pirNet.ino
@@ -135,10 +135,10 @@
   enableTimers();

   // udpMgr.attach(6, handlePackets);  // TODO(Gary): magic number. Try sizeof(location_t)
-  udpMgr.attach(6, []() {
+  udpMgr.attach(6, []() {  // TODO(Gary): magic number 6. Try sizeof(location_t)
     readUDPFloorRoomColor();
     digitalWrite(ledRed, !digitalRead(ledRed));
-  });  // TODO(Gary): magic number. Try sizeof(location_t)
+  });

   configMgr.readLocation(&loc);


Add commented-out jack-o-lantern effect to effect list

--- RGBShades.ino
+++ RGBShades.ino
@@ -73,7 +73,8 @@
                              slantBars,
                              scrollTextTwo,
                              colorFill,
-                             sideRain
+                             sideRain,
+                             //pumpkin
                             };

 const byte numEffects = (sizeof(effectList)/sizeof(effectList[0]));


Update sketch_aug08b.ino

Update sketch_aug08b.ino

--- plane/RECEIVER/sketch_aug08b/sketch_aug08b.ino
+++ plane/RECEIVER/sketch_aug08b/sketch_aug08b.ino
@@ -1,5 +1,4 @@
 /*
-*
 * Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
 */
 struct dataStruct{


message

message

--- Mqtt/mqtt.ino
+++ Mqtt/mqtt.ino
@@ -28,7 +28,7 @@
 String urlon = "STRING FOR ON";
 String urloff = "STRING FOR OFF";
 long previousMillis = 0;
-long interval = 60000*5;   // 5 minutes delay
+long interval = 60000*5;   // 5 minutes delay
 boolean gotMessage = false;
 char c;

@@ -137,7 +137,7 @@
     mqtt.publish(arduino_response, "done", 1);
   } else if (atof(message) >= 120 && mode == 4) {                                     //
     client.connect(host, 80);                                                         //
-    client.print(String("GET ") + urlon + " HTTP/1.1\r\n" +                           //
+    client.print(String("GET ") + urlon + " HTTP/1.1\r\n" +                           //
                "Host: " + host + "\r\n" +                                             //
                "Connection: close\r\n\r\n");                                          //
   } else if (atof(message) < 120 && mode == 4) {                                      //  UPDATE THE DATABASE SO WE CAN CHECK WHICH AC
@@ -150,7 +150,7 @@
     delay(10);
     mqtt.publish(arduino_watt, message, 1);
   }
-
+
 }

 // Function to connect and reconnect as necessary to the MQTT server.


Recognize spaces between letters and words. Closes #1 Closes #3

--- MorseCodeDecoder.ino
+++ MorseCodeDecoder.ino
@@ -9,19 +9,30 @@
 const int NOTHING = 0; //represents no input
 const int DOT = 1; //represent dot input
 const int DASH = 2; //represent dash input
+const int LETTER_SPACE = 3; //represent letter space
+const int WORD_SPACE = 4; //represent word space

 unsigned long dotMillisMin = 50; //minimum length of a button press for a dot in milliseconds
 unsigned long dashMillisMin = 200; //minimum length of a button press for a dash in milliseconds

+unsigned long letterSpaceMillisMin = 500; //minimum length of no button press for a letter in milliseconds
+unsigned long wordSpaceMillisMin = 1700; //minimum length of no button press for a word space in milliseconds
+
 int inputVal = LOW; //the current input
 int previousInputVal = LOW; //the previous input
+
 unsigned long holdStart = 0; //the time the input started
 unsigned long currentHold = 0; //the length of time of the current button press in milliseconds
 unsigned long previousHold = 0; //the length of time of the previous button press in milliseconds

+unsigned long spaceStart = 0; //the time the space started
+unsigned long currentSpace = 0; //the length of time of the current space in milliseconds
+unsigned long previousSpace = 0; //the length of time of the previous space in milliseconds
+
 int determineDotDash(unsigned long holdMillis);
-String getDotDashString(int input);
-String getDotDashSymbolString(int input);
+int determineLetterWordSpace(unsigned long spaceMillis);
+String getDotDashOrSpaceString(int input);
+String getDotDashOrSpaceSymbolString(int input);

 void setup() {
   pinMode(LED, OUTPUT);
@@ -38,27 +49,40 @@
     holdStart = millis(); //capture the time the button started being pressed
   }

+  if (inputVal == LOW && previousInputVal == HIGH) {
+    spaceStart = millis();
+  }
+
   if (inputVal == HIGH) {
     currentHold = millis() - holdStart; //if the button is being pressed, see for how long
+    currentSpace = 0; //the button is being pressed, reset the space
   } else {
     currentHold = 0; //the button is not being pressed, reset the hold
+    currentSpace = millis() - spaceStart; //the button is not being pressed, see for how long
   }
+
+  int result = NOTHING;

   if (currentHold < previousHold) {

     //if the button stopped being pressed, determine if the previous press was a dot or dash
-    int result = determineDotDash(previousHold);
+    result = determineDotDash(previousHold);
+  } else if (currentSpace < previousSpace) {

+    //if the space is over, determine if the previous space was a letter or word space
+    result = determineLetterWordSpace(previousSpace);
+  }
+
+  if (result != NOTHING) {
     //print the results for now
-    if (result == DOT || DASH) {
-      //Serial.println(getDotDashString(result) + "(" + previousHold + ")");
-      Serial.print(getDotDashSymbolString(result));
-    }
+    Serial.print(getDotDashOrSpaceSymbolString(result));
+    //Serial.println(getDotDashOrSpaceString(result) + "(" + previousHold + ", " + previousSpace + ")");
   }

   //set the previous values
   previousInputVal = inputVal;
   previousHold = currentHold;
+  previousSpace = currentSpace;
 }

 /**
@@ -75,27 +99,48 @@
 }

 /**
- * Given DOT, DASH, or NOTHING, return a string representing it
+ * Given the length of a space in milliseconds, return LETTER_SPACE, WORD_SPACE, or NOTHING
  */
-String getDotDashString(int input) {
+int determineLetterWordSpace(unsigned long spaceMillis) {
+  int toReturn = NOTHING;
+  if (previousSpace >= wordSpaceMillisMin) {
+    toReturn = WORD_SPACE;
+  } else if (previousSpace >= letterSpaceMillisMin) {
+    toReturn = LETTER_SPACE;
+  }
+  return toReturn;
+}
+
+/**
+ * Given DOT, DASH, LETTER_SPACE, WORD_SPACE, or NOTHING, return a string representing it
+ */
+String getDotDashOrSpaceString(int input) {
   String toReturn = "nothing";
   if (input == DOT) {
     toReturn = "dot";
   } else if (input == DASH) {
     toReturn = "dash";
+  } else if (input == LETTER_SPACE) {
+    toReturn = "end of letter";
+  } else if (input == WORD_SPACE) {
+    toReturn = "end of word";
   }
   return toReturn;
 }

 /**
- * Given DOT, DASH, or NOTHING, return a string with a symbol
+ * Given DOT, DASH, LETTER_SPACE, WORD_SPACE, or NOTHING, return a string with a symbol
  */
-String getDotDashSymbolString(int input) {
+String getDotDashOrSpaceSymbolString(int input) {
   String toReturn = "";
   if (input == DOT) {
     toReturn = "·";
   } else if (input == DASH) {
     toReturn = "-";
+  } else if (input == LETTER_SPACE) {
+    toReturn = " ";
+  } else if (input == WORD_SPACE) {
+    toReturn = " | ";
   }
   return toReturn;
 }


Add some separators to the code.

Add some separators to the code.

--- MorseCodeDecoder.ino
+++ MorseCodeDecoder.ino
@@ -7,16 +7,22 @@

 #include "Symbols.h"

+//------------------------------------------------------------------------------
+
 #define ARRAY_SIZE 256

 const int LED = LED_BUILTIN;
 const int BUTTON = 7;

+//------------------------------------------------------------------------------
+
 unsigned long dotMillisMin = 50; //minimum length of a button press for a dot in milliseconds
 unsigned long dashMillisMin = 200; //minimum length of a button press for a dash in milliseconds

 unsigned long letterSpaceMillisMin = 500; //minimum length of no button press for a letter in milliseconds
 unsigned long wordSpaceMillisMin = 1700; //minimum length of no button press for a word space in milliseconds
+
+//------------------------------------------------------------------------------

 int inputVal = LOW; //the current input
 int previousInputVal = LOW; //the previous input
@@ -30,16 +36,22 @@
 unsigned long previousSpace = 0; //the length of time of the previous space in milliseconds
 boolean spaceProcessed = false;

+//------------------------------------------------------------------------------
+
 MorseNode * alphabet;

 int inputSymbols[ARRAY_SIZE];
 int inputIndex = 0;
+
+//------------------------------------------------------------------------------

 int determineDotDash(unsigned long holdMillis);
 int determineLetterWordSpace(unsigned long spaceMillis);
 String getDotDashOrSpaceString(int input);
 String getDotDashOrSpaceSymbolString(int input);

+//------------------------------------------------------------------------------
+
 void setup() {
   pinMode(LED, OUTPUT);
   pinMode(BUTTON, INPUT_PULLUP);
@@ -48,6 +60,8 @@

   alphabet = MorseNode::getInternationalAlphabet();
 }
+
+//------------------------------------------------------------------------------

 void loop() {
   inputVal = (digitalRead(BUTTON) == HIGH) ? LOW : HIGH; //switch high and low because it's a pullup
@@ -121,6 +135,8 @@
   previousSpace = currentSpace;
 }

+//------------------------------------------------------------------------------
+
 /**
  * Given the length of a button press in milliseconds, return DOT, DASH, or NOTHING
  */
@@ -134,6 +150,8 @@
   return toReturn;
 }

+//------------------------------------------------------------------------------
+
 /**
  * Given the length of a space in milliseconds, return LETTER_SPACE, WORD_SPACE, or NOTHING
  */
@@ -146,6 +164,8 @@
   }
   return toReturn;
 }
+
+//------------------------------------------------------------------------------

 /**
  * Given DOT, DASH, LETTER_SPACE, WORD_SPACE, or NOTHING, return a string representing it
@@ -164,6 +184,8 @@
   return toReturn;
 }

+//------------------------------------------------------------------------------
+
 /**
  * Given DOT, DASH, LETTER_SPACE, WORD_SPACE, or NOTHING, return a string with a symbol
  */
@@ -181,3 +203,5 @@
   return toReturn;
 }

+//------------------------------------------------------------------------------
+


Update iGPS.ino

Update iGPS.ino

修正SD存储，容错文件打开失败的情况

--- iGPS.ino
+++ iGPS.ino
@@ -131,8 +131,10 @@
     String sub = readLine();
     if(sub.length()) {
       sdFile = SD.open("gps.txt", FILE_WRITE);
-      sdFile.println(sub);
-      sdFile.close();
+      if (sdFile) {
+        sdFile.println(sub);
+        sdFile.close();
+      }
       int split = sub.indexOf(',');
       String field = sub.substring(0,split);
       if(field.equals(GPRMC)) {


-If timers are equal, don't calculate too much.

-Changed code that counts the number of milliseconds since midnight.

--- dimmertask.ino
+++ dimmertask.ino
@@ -2,17 +2,25 @@
 {
   int dimmerTaskdelayTime = 1000 / UPDATE_FREQ_LEDS;

+  /* I probably have to read more of this thread: */
+  /* https://stackoverflow.com/questions/3673226/how-to-print-time-in-format-2009-08-10-181754-811 */
+
   while (1)
   {
-    struct tm timeinfo;
-    getLocalTime(&timeinfo);
-
     struct timeval microSecondTime;

     gettimeofday( &microSecondTime, NULL );

-    time_t milliSecondsToday = ( timeinfo.tm_hour * 3600000 ) + ( timeinfo.tm_min * 60000 ) + ( timeinfo.tm_sec * 1000 ) + ( microSecondTime.tv_usec / 1000 );
-    for ( byte channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++ )
+    struct tm *localTime;
+
+    localTime = localtime( &microSecondTime.tv_sec );
+
+    suseconds_t milliSecondsToday = ( localTime->tm_hour * 3600000 )
+                                  + ( localTime->tm_min * 60000 )
+                                  + ( localTime->tm_sec * 1000 )
+                                  + ( microSecondTime.tv_usec / 1000 );
+
+    for ( uint8_t channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++ )
     {
       setPercentageFromProgram( channelNumber, milliSecondsToday );
     }
@@ -20,22 +28,31 @@
   }
 }

-void setPercentageFromProgram( const byte channelNumber, const time_t milliSecondsToday )
+void setPercentageFromProgram( const uint8_t channelNumber, const suseconds_t milliSecondsToday )
 {
+  /* to solve flashing at midnight due to the fact that the first timer has no predecessor */
   if ( milliSecondsToday )
-  { ///to solve flashing at midnight due to milliSecondsToday which cant be smaller than 0 -- so at midnight there is no adjusting
-    byte thisTimer = 0;
+  {
+    uint8_t thisTimer = 0;
     while ( channel[channelNumber].timer[thisTimer].time * 1000 < milliSecondsToday )
     {
       thisTimer++;
     }
-    float dimPercentage = channel[channelNumber].timer[thisTimer].percentage - channel[channelNumber].timer[thisTimer - 1].percentage;
-    time_t numberOfMilliSecondsBetween = ( channel[channelNumber].timer[thisTimer].time - channel[channelNumber].timer[thisTimer - 1].time ) * 1000;
-    time_t milliSecondsSinceLastTimer = milliSecondsToday - channel[channelNumber].timer[thisTimer - 1].time * 1000;
-    float changePerMilliSecond  = dimPercentage / numberOfMilliSecondsBetween;
-    channel[channelNumber].currentPercentage = channel[channelNumber].timer[thisTimer - 1].percentage + ( milliSecondsSinceLastTimer * changePerMilliSecond );
-
-    //check if channel has a minimum set
+    /* only do a lot of math if really neccesary */
+    if ( channel[channelNumber].timer[thisTimer].time != channel[channelNumber].timer[thisTimer - 1].time )
+    {
+      float dimPercentage = channel[channelNumber].timer[thisTimer].percentage - channel[channelNumber].timer[thisTimer - 1].percentage;
+      suseconds_t numberOfMilliSecondsBetween = ( channel[channelNumber].timer[thisTimer].time - channel[channelNumber].timer[thisTimer - 1].time ) * 1000;
+      suseconds_t milliSecondsSinceLastTimer = milliSecondsToday - ( channel[channelNumber].timer[thisTimer - 1].time * 1000 );
+      float changePerMilliSecond = dimPercentage / numberOfMilliSecondsBetween;
+      channel[channelNumber].currentPercentage = channel[channelNumber].timer[thisTimer - 1].percentage + ( milliSecondsSinceLastTimer * changePerMilliSecond );
+    }
+    else
+    {
+      /* timers are equal so no math neccesary */
+      channel[channelNumber].currentPercentage = channel[channelNumber].timer[thisTimer].percentage;
+    }
+    /* check if channel has a minimum set */
     if ( channel[channelNumber].currentPercentage < channel[channelNumber].minimumLevel )
     {
       channel[channelNumber].currentPercentage = channel[channelNumber].minimumLevel;
@@ -46,9 +63,9 @@

 double setupDimmerPWMfrequency( const double frequency )
 {
-  // Setup timers and attach timer to a led pin
+  /* Setup timers and attach timer to a led pin */
   double newFrequency;
-  for ( byte channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++ )
+  for ( uint8_t channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++ )
   {
     newFrequency = ledcSetup( channelNumber, frequency, ledcNumberOfBits );
     ledcAttachPin( channel[channelNumber].pin, channelNumber);


saving angu

saving angu

--- angu/angu.ino
+++ angu/angu.ino
@@ -1,6 +1,6 @@
 #include <CurieBLE.h>

-const int ledPin = 13; // set ledPin to on-board LED
+const int ledPin = 3; // set ledPin to on-board LED
 //                                                        V
 //ID IS A TEST. IT WAS 19B10010-E8F2-537E-4F6C-D104768A1214<<<<<
 BLEService ledService("19B10010-E8F2-537E-4F6C-D104768A1215"); // create service
@@ -11,13 +11,14 @@

 void setup() {
   Serial.begin(9600);
+  delay(1000);
   pinMode(ledPin, OUTPUT); // use the LED on pin 13 as an output
-
+  ledSignal(5,200);
   // begin initialization
   BLE.begin();

   // set the local name peripheral advertises
-  BLE.setLocalName("Blynk");
+  BLE.setLocalName("ANGU");
   // set the UUID for the service this peripheral advertises:
   BLE.setAdvertisedService(ledService);

@@ -26,13 +27,16 @@

   // add the service
   BLE.addService(ledService);
-
-  ledCharacteristic.setValue(0);
+
+  //const char* valueToWrite = "THIS IS A TEXT VALUE";
+  char c = 'A';
+  ledCharacteristic.setValue(c);

   // start advertising
   BLE.advertise();

   Serial.println("Bluetooth device active, waiting for connections...");
+
 }

 void loop() {
@@ -41,6 +45,8 @@

   if (ledCharacteristic.written()) {
     // update LED, either central has written to characteristic or button state has changed
+    Serial.println(ledCharacteristic.valueLength());
+    Serial.println(ledCharacteristic.value());
     Serial.println(ledCharacteristic.value());
     if (ledCharacteristic.value()) {
       Serial.println("LED on");
@@ -52,3 +58,11 @@
   }
 }

+void ledSignal(int times, int milliseconds){
+  for(int i=0; i<times; i++){
+    digitalWrite(ledPin, HIGH);
+    delay(milliseconds);
+    digitalWrite(ledPin, LOW);
+    delay(milliseconds);
+  }
+}


latest pin numbers

latest pin numbers

--- engine-room/engine_arduino/engine_arduino.ino
+++ engine-room/engine_arduino/engine_arduino.ino
@@ -26,13 +26,13 @@

 #define NO 98  // Represents no pin
 const uint16_t SWITCH_PINS[] = {
-  13,  6, 30,  9, 36, NO, 38,
-  NO,  7, 28, NO, 10, 32, 37,
-   8, 19, 18, 17, 16, 15, 14,
-  26, NO, 23, 22, 50, NO, 42,
-  40, 29, 25, 27, 51, 46, 44,
-  31, 33, 43, NO, 49, 48, NO,
-  39, NO, 35, 45, 47, 53, 34,
+  13, 26,  9, 10, 48, NO, 32,
+  NO, 17, 16, NO, 47, 50, 34,
+   7,  6, 15,  8, 46, 51, 36,
+  28, NO, 30, 22, 45, NO, 35,
+  25, 37, 39, 41, 42, 44, 33,
+  24, 27, 29, NO, 43, 52, NO,
+  25, NO, 31, 38, 40, 49, 53,
 };

 const uint16_t LED_INDEXES[] = {
@@ -261,91 +261,81 @@
 }

 //void loop() {
-//  if (DEBUG_FLAG) {
-//    if (USE_SERIAL) {
-//      Serial.println("DEBUG");
-//    }
-//    for (int index = 0; index < GRIDSIZE * GRIDSIZE; index++) {
-//      int value = getSwitchValue(getRow(index), getCol(index));
-//      if (index % GRIDSIZE == 0) {
-//        if (USE_SERIAL) {
-//          Serial.println("");
-//        }
-//      }
-//      if (value == SWITCH_WALL) {
-//        if (USE_SERIAL) {
-//          Serial.print("X");
-//        }
-//      } else {
-//        if (USE_SERIAL) {
-//          Serial.print(value);
-//        }
-//      }
-//
+//  Serial.println("DEBUG");
+//  for (int pin = 2; pin <= 53; pin++) {
+//    Serial.print(digitalRead(pin));
+//    Serial.print(" ");
+//  }
+//  delay(100);
+//}
+
+//void loop() {
+//  if (USE_SERIAL) {
+//    Serial.println("DEBUG");
+//  }
+//  for (int index = 0; index < GRIDSIZE * GRIDSIZE; index++) {
+//    int value = getSwitchValue(getRow(index), getCol(index));
+//    if (index % GRIDSIZE == 0) {
 //      if (USE_SERIAL) {
-//        Serial.print(' ');
+//        Serial.println("");
 //      }
 //    }
+//    if (value == SWITCH_WALL) {
+//      if (USE_SERIAL) {
+//        Serial.print("X");
+//      }
+//    } else {
+//      if (USE_SERIAL) {
+//        Serial.print(value);
+//      }
+//    }
+//
+//    if (USE_SERIAL) {
+//      Serial.print(' ');
+//    }
+//  }
 //
-//    if (USE_SERIAL) {
-//      Serial.print('\n');
-//      Serial.print('\n');
-//      Serial.flush();
-//    }
-////
-//    if (isSwitchOn(3, 3)) {
-//      //Serial.println("YES");
-//      setColor(3, 3, RED);
-//    } else {
-//      //Serial.println("NO");
-//      setColor(3, 3, BLUE);
-//    }
-//    leds.write(colors, STRIP_LENGTH);
-//    delay(50);
-//  } else {
-//    bool victory = update();
-//    // leds.write(colors, STRIP_LENGTH);
-//    if (victory) {
-//      delay(500);
-//      setAllBlue();
-//    }
+//  if (USE_SERIAL) {
+//    Serial.print('\n');
+//    Serial.print('\n');
+//    Serial.flush();
 //  }
 //
 //  delay(1000);
 //}

+//void loop() {
+//  for(uint16_t i = 0; i < STRIP_LENGTH; i++)
+//  {
+//    colors[i] = OFF;
+//  }
+//  setColor(3, 3, BLUE);
+//  setColor(3, 2, GREEN);
+//  setColor(3, 0, RED);
+//  setColor(3, 4, YELLOW);
+//  setColor(3, 6, OFF);
+//  setColor(0, 0, OFF);
+//  setColor(0, 3, GREEN);
+//  //  1. You must disconnect 5V to upload properly.
+//  //  2. Why does the following not work?
+////  if (isSwitchOn(3, 3)) {
+////    setColor(4, 3, GREEN);
+////  } else {
+////    setColor(4, 3, RED);
+////  }
+//  setColor(0, 3, BLUE);
+//  setColor(4, 3, YELLOW);
+////  isSwitchOn(3, 3);
+//  leds.write(colors, STRIP_LENGTH);
+//  delay(10);
+//}
+
 void loop() {
-  for(uint16_t i = 0; i < STRIP_LENGTH; i++)
-  {
-    colors[i] = OFF;
-  }
-  setColor(3, 3, BLUE);
-  setColor(3, 2, GREEN);
-  setColor(3, 0, RED);
-  setColor(3, 4, YELLOW);
-  setColor(3, 6, OFF);
-  setColor(0, 0, OFF);
-  setColor(0, 3, GREEN);
-  //  1. You must disconnect 5V to upload properly.
-  //  2. Why does the following not work?
-//  if (isSwitchOn(3, 3)) {
-//    setColor(4, 3, GREEN);
-//  } else {
-//    setColor(4, 3, RED);
-//  }
-  setColor(0, 3, BLUE);
-  setColor(4, 3, YELLOW);
-//  isSwitchOn(3, 3);
+  bool victory = update();
   leds.write(colors, STRIP_LENGTH);
-  delay(10);
-}
-
-//void loop() {
-//  bool victory = update();
-//  leds.write(colors, STRIP_LENGTH);
-//  delay(50);
-//  if (victory) {
-//    delay(500);
-//    setAllBlue();
-//  }
-//}
+  delay(50);
+  if (victory) {
+    delay(500);
+    setAllBlue();
+  }
+}


Update DemoReel100_RandomShiftedGlitter.ino

spelling fix

--- DemoReel100_RandomShiftedGlitter.ino
+++ DemoReel100_RandomShiftedGlitter.ino
@@ -3,7 +3,7 @@
 //    white glitter.  One picks random colors, the other slightly
 //    shifts the hue of whatever pixel is randomly selected.
 //
-//  These can be added to Mark Kreigman's DemoReel100 example as
+//  These can be added to Mark Kriegsman's DemoReel100 example as
 //    additional patterns to run.  Copy lines 25 and 26 as well
 //    as the two patterns below to your DemoReel100 program.
 //


fix http content length

fix http content length

--- sketches/EnerginoEthernet/EnerginoEthernet.ino
+++ sketches/EnerginoEthernet/EnerginoEthernet.ino
@@ -412,7 +412,7 @@
     client.print("X-ApiKey: ");
     client.println(settings.apikey);
     client.println("Content-Type: text/csv");
-    client.println("Content-Length: 49");
+    client.println("Content-Length: 53");
     client.println();

     char buffer[10];
@@ -432,6 +432,7 @@
     client.print("switch,");
     client.println(digitalRead(RELAYPIN));

+    client.flush();
     client.stop();
   }
 }


We introduce a bug and we fixed it. We also added the zip file.

--- BackEnd/BackEnd.ino
+++ BackEnd/BackEnd.ino
@@ -539,10 +539,12 @@
     }

    // Serial.println("Set Connections");
-
-    aJsonObject *pJsonSsid = aJson.getObjectItem(poMsg, "ssid");
-    if( pJsonSsid )  // Check if there is connection info
-      procSsidMsg( pJsonSsid );
+
+/////////////////////
+//    aJsonObject *pJsonSsid = aJson.getObjectItem(poMsg, "ssid");
+ //   if( pJsonSsid )  // Check if there is connection info
+//      procSsidMsg( pJsonSsid );
+/////////////////////

   //  Serial.println("System updated from file.");
   }
@@ -1129,7 +1131,7 @@
   aJsonObject* poJsonBoardState = aJson.createObject();

   // Create SSID object
-  aJsonObject* poSsid = aJson.createObject();
+//  aJsonObject* poSsid = aJson.createObject();

   // Creating pin JSON objects
   aJsonObject* poPins = aJson.createObject();
@@ -1143,7 +1145,7 @@
   aJsonObject* paConnections = aJson.createArray();

   // Create SSID
-  poSsid = aJson.createItem(g_sSsid);
+//  poSsid = aJson.createItem(g_sSsid);

   // Create PINS
   int iaPinConnects[TOTAL_NUM_OF_PINS];
@@ -1239,7 +1241,7 @@
   }

   // Push to JSON object
-  aJson.addItemToObject(poJsonBoardState,"ssid",poSsid);
+//  aJson.addItemToObject(poJsonBoardState,"ssid",poSsid);
   aJson.addItemToObject(poJsonBoardState,"pins",poPins);
   aJson.addItemToObject(poJsonBoardState,"connections",paConnections);


Changed colors and timing of the 30 lighting animations to match sound clip character color scheme and length.


Added RCSwitch for controls aukey plugs

Added RCSwitch for controls aukey plugs

--- Ambrogio.ino
+++ Ambrogio.ino
@@ -4,12 +4,14 @@
 #include "LedPanel.h"
 #include "OnboardLed.h"
 #include "WifiCredentials.h"
+#include "RCSwitch.h"

 #define LOOP_TIME 1000

 WifiUser wifiUsers[]  = { WifiUser(IPAddress(192,168,0,5), "Gruppio"),
                           WifiUser(IPAddress(192,168,0,3), "Fede") };

+RCSwitch *rcSwitch        = new RCSwitch();
 Powered *led              = new OnboardLed();
 Powered *ledPanel         = new LedPanel();
 Thermometer *thermometer  = new MCP9700();


update

update

--- spBox.ino
+++ spBox.ino
@@ -13,7 +13,7 @@
 BMP085            barometer;
 Adafruit_SSD1306  display = Adafruit_SSD1306();

-// store accel and gyro values from MPU6050, and accel using unit "g"(float)
+// store accel and gyro values from MPU6050, and accel using unit "g"(float)
 int16_t ax, ay, az;
 int16_t gx, gy, gz;
 int16_t mx, my, mz;
@@ -25,25 +25,108 @@
 int32_t lastMicros;

 #if defined(ESP8266)
-  #define BUTTON_A 0
-  #define BUTTON_B 16
-  #define BUTTON_C 2
-  #define LED      0
+#define BUTTON_A 0
+#define BUTTON_B 16
+#define BUTTON_C 2
+#define LED      0
 #elif defined(ARDUINO_STM32F2_FEATHER)
-  #define BUTTON_A PA15
-  #define BUTTON_B PC7
-  #define BUTTON_C PC5
-  #define LED PB5
+#define BUTTON_A PA15
+#define BUTTON_B PC7
+#define BUTTON_C PC5
+#define LED PB5
 #else
-  #define BUTTON_A 9
-  #define BUTTON_B 6
-  #define BUTTON_C 5
-  #define LED      13
+#define BUTTON_A 9
+#define BUTTON_B 6
+#define BUTTON_C 5
+#define LED      13
 #endif

 #if (SSD1306_LCDHEIGHT != 32)
 #error("Height incorrect, please fix Adafruit_SSD1306.h!");
 #endif
+
+
+// = dtostre() function experimental ============================
+char * dtostrf_sign(double number, signed char width, unsigned char prec, char *s) {
+    bool negative = false;
+
+    if (isnan(number)) {
+        strcpy(s, "nan");
+        return s;
+    }
+    if (isinf(number)) {
+        strcpy(s, "inf");
+        return s;
+    }
+
+    char* out = s;
+
+    int fillme = width; // how many cells to fill for the integer part
+    if (prec > 0) {
+        fillme -= (prec+1);
+    }
+
+    // Handle negative numbers
+    if (number < 0.0) {
+        negative = true;
+        fillme--;
+        number = -number;
+    } else {
+      fillme--;
+    }
+
+    // Round correctly so that print(1.999, 2) prints as "2.00"
+    // I optimized out most of the divisions
+    double rounding = 2.0;
+    for (uint8_t i = 0; i < prec; ++i)
+        rounding *= 10.0;
+    rounding = 1.0 / rounding;
+
+    number += rounding;
+
+    // Figure out how big our number really is
+    double tenpow = 1.0;
+    int digitcount = 1;
+    while (number >= 10.0 * tenpow) {
+        tenpow *= 10.0;
+        digitcount++;
+    }
+
+    number /= tenpow;
+    fillme -= digitcount;
+
+    // Pad unused cells with spaces
+    while (fillme-- > 0) {
+        *out++ = ' ';
+    }
+
+    // Handle negative sign
+    if (negative) {
+      *out++ = '-';
+    } else {
+      *out++ = ' ';
+    }
+
+    // Print the digits, and if necessary, the decimal point
+    digitcount += prec;
+    int8_t digit = 0;
+    while (digitcount-- > 0) {
+        digit = (int8_t)number;
+        if (digit > 9) digit = 9; // insurance
+        *out++ = (char)('0' | digit);
+        if ((digitcount == prec) && (prec > 0)) {
+            *out++ = '.';
+        }
+        number -= digit;
+        number *= 10.0;
+    }
+
+    // make sure the string is terminated
+    *out = 0;
+    return s;
+}
+// ====================================================================
+

 void setup() {
 #if !defined(ESP8266)
@@ -56,13 +139,13 @@
   pinMode(BUTTON_A, INPUT_PULLUP);
   pinMode(BUTTON_B, INPUT_PULLUP);
   pinMode(BUTTON_C, INPUT_PULLUP);
-
+
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
   display.clearDisplay();
   display.setTextSize(1);
   display.setTextColor(WHITE);
   display.display();
-
+
   accelgyro.setI2CMasterModeEnabled(false);
   accelgyro.setI2CBypassEnabled(true) ;
   accelgyro.setSleepEnabled(false);
@@ -79,16 +162,17 @@
   Serial.println("... initializing done.");
 }

+
 void loop() {
   char displaybuffer[4][21];  // 4 lines with 21 chars each
   char tempbuffer[3][15];     // temp for float to str conversion
-
+
   accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
   mag.getHeading(&mx, &my, &mz);

   // request temperature
   barometer.setControl(BMP085_MODE_TEMPERATURE);
-
+
   // wait appropriate time for conversion (4.5ms delay)
   lastMicros = micros();
   while (micros() - lastMicros < barometer.getMeasureDelayMicroseconds());
@@ -113,62 +197,62 @@
   az_f = az / 16384.0;

   // display tab-separated accel/gyro x/y/z values
-   Serial.print("a/g:\t");
-   Serial.print(ax_f); Serial.print("\t");
-   Serial.print(ay_f); Serial.print("\t");
-   Serial.print(az_f); Serial.print("\t");
-   Serial.print(gx); Serial.print("\t");
-   Serial.print(gy); Serial.print("\t");
-   Serial.print(gz);Serial.print("\t");
-
-   Serial.print("mag:\t");
-   Serial.print(mx); Serial.print("\t");
-   Serial.print(my); Serial.print("\t");
-   Serial.print(mz); Serial.print("\t");
+  Serial.print("a/g:\t");
+  Serial.print(ax_f); Serial.print("\t");
+  Serial.print(ay_f); Serial.print("\t");
+  Serial.print(az_f); Serial.print("\t");
+  Serial.print(gx); Serial.print("\t");
+  Serial.print(gy); Serial.print("\t");
+  Serial.print(gz); Serial.print("\t");
+
+  Serial.print("mag:\t");
+  Serial.print(mx); Serial.print("\t");
+  Serial.print(my); Serial.print("\t");
+  Serial.print(mz); Serial.print("\t");

   // To calculate heading in degrees. 0 degree indicates North
-   float heading = atan2(my, mz);
-   if(heading < 0)
-     heading += 2 * M_PI;
-   heading *= 180/M_PI;
-   Serial.print("heading:\t");
-   Serial.print(heading); Serial.print("\t");
-
-   // display measured values if appropriate
-   Serial.print("T/P/A\t");
-   Serial.print(temperature); Serial.print("\t");
-   Serial.print(pressure); Serial.print("\t");
-   Serial.print(altitude);
-   Serial.println("");
-
-  dtostrf(ax_f, 4, 2, tempbuffer[0]);   // -x.x
-  dtostrf(ay_f, 4, 2, tempbuffer[1]);   // -x.x
-  dtostrf(az_f, 4, 2, tempbuffer[2]);   // -x.x
+  float heading = atan2(my, mz);
+  if (heading < 0)
+    heading += 2 * M_PI;
+  heading *= 180 / M_PI;
+  Serial.print("heading:\t");
+  Serial.print(heading); Serial.print("\t");
+
+  // display measured values if appropriate
+  Serial.print("T/P/A\t");
+  Serial.print(temperature); Serial.print("\t");
+  Serial.print(pressure); Serial.print("\t");
+  Serial.print(altitude);
+  Serial.println("");
+
+  dtostrf_sign(ax_f, 4, 2, tempbuffer[0]);   // -x.x
+  dtostrf_sign(ay_f, 4, 2, tempbuffer[1]);   // -x.x
+  dtostrf_sign(az_f, 4, 2, tempbuffer[2]);   // -x.x
   snprintf(displaybuffer[0], 21, "A %s %s %s", tempbuffer[0], tempbuffer[1], tempbuffer[2]);
-
+
   snprintf(displaybuffer[1], 21, "G: %+4d %+4d %+4d", gx, gy, gz);

   dtostrf(heading, 3, 0, tempbuffer[0]);   // xxx
   snprintf(displaybuffer[2], 21, "H: %s", tempbuffer[0]);

-  dtostrf(temperature, 5, 2, tempbuffer[0]);   // -xx.x
-  dtostrf(pressure, 5, 2, tempbuffer[1]);   // -xx.x
+  dtostrf(temperature, 5, 2, tempbuffer[0]);   // -xx.x
+  dtostrf(pressure, 5, 2, tempbuffer[1]);   // -xx.x
   snprintf(displaybuffer[3], 21, "T: %s, P: %s", tempbuffer[0], tempbuffer[1]);

-//   Serial.println(displaybuffer[0]);
-//   Serial.println(displaybuffer[1]);
-//   Serial.println(displaybuffer[2]);
-//   Serial.println(displaybuffer[3]);
+  //   Serial.println(displaybuffer[0]);
+  //   Serial.println(displaybuffer[1]);
+  //   Serial.println(displaybuffer[2]);
+  //   Serial.println(displaybuffer[3]);

   display.clearDisplay();
-  display.setCursor(0,0);
+  display.setCursor(0, 0);
   display.println(displaybuffer[0]);
-//  display.println(displaybuffer[1]);
-//  display.println(displaybuffer[2]);
-//  display.println(displaybuffer[3]);
+  //  display.println(displaybuffer[1]);
+  display.println(displaybuffer[2]);
+  //  display.println(displaybuffer[3]);
   delay(10);
   yield();
   display.display();

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


added 5seconds delay for disconnecting (InitApp)

--- InitApp/App/App.ino
+++ InitApp/App/App.ino
@@ -55,9 +55,9 @@
     }
     Serial.print("MAC: ");
     Serial.println(MAC_char);
-    Serial.println(ssid);
+/*     Serial.println(ssid);
     Serial.println(pass);
-}
+ */}

 void loop()
 {
@@ -65,8 +65,12 @@
     // wait for WiFi connection
     if ((WiFiMulti.run() == WL_CONNECTED))
     {
-
+        Serial.println("Connected!");
+
         HTTPClient http;
+
+        Serial.println("5sec before starting update...!");
+        delay(5000);

         USE_SERIAL.print("[HTTP] begin...\n");
         // configure traged server and url


build robot sys struct

build robot sys struct

--- main.ino
+++ main.ino
@@ -80,10 +80,47 @@

 void loop() {
     waitForCommand();
+    x = 10;
+    y = 7;
+    cycle = 0;
+    pwd = 1;
     exploration();
     waitForCommand();
-    //memoryLane();
+    getSPInstructions();
     bridesheadRevisited();
+}
+void exploration() {
+    int counter_for_step = 0;
+    while (cycle >= 1 && x <= 2 && y <= 2) {
+        //check right
+        turn(1);
+        thinkForAWhile();
+        goAhead(1);
+        thinkForAWhile();
+    }
+}
+
+void bridesheadRevisited() {
+    //follow instruction
+    //
+    //turn(1);
+    //turn(-1);
+    //goAhead(l);
+}
+
+void thinkForAWhile() {
+    //TODO
+    //see and think
+    //send and delay
+}
+void turn(int direction) {
+    //TODO
+    //rotate
+    //update current direction
+}
+void getSPInstructions() {
+    //TODO
+    //get shortest path from RPi
 }

 void setTimerInterrupt() {
@@ -117,4 +154,15 @@
     md.setM1Speed((200 + leftCompensate) * neg);
   else
     md.setM1Speed((350 + leftCompensate) * neg);
-}+}
+
+void straighten() {
+    //Ultrasonic go until 5cm
+    for (int i = 0; i < 100; i++) {
+        if (shortIR_LR.getDis() > shortIR_LF.getDis()) {
+            md.setSpeeds(-300, 300);
+        } else if (shortIR_LR.getDis() < shortIR_LF.getDis()) {
+            md.setSpeeds(300, -300);
+        }
+    }
+}


Added HelloWorld code sample for blog post


VDP added

VDP added

--- examples/Button/Button_GUI.ino
+++ examples/Button/Button_GUI.ino
@@ -1,11 +1,12 @@
-#include <AmuletUART.h>
+#include <AmuletLCD.h>
+

 //initialize Virtual Dual Port RAM arrays:
 // these are the memory registers that the UART is going to read and write through the Amulet protocol

 word myWords[32] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };

-AmuletUART myModule(115200);  // initialize the AmuletUART module as a global
+AmuletLCD myModule(115200);  // initialize the AmuletUART module as a global

 void setup()                    // run once, when the sketch starts
 {


Made Template.ino compatible to Arduino "IDE" 1.6.6

--- examples/Template/Template.ino
+++ examples/Template/Template.ino
@@ -1,7 +1,6 @@
 #include "Eyebot.h"

-void
-setup ()
+void setup ()
   {
     /* Benutzercode ab hier einfügen  */

@@ -16,8 +15,7 @@
     /* Code nach Eyebot.Init () wird nicht ausgeführt!  */
   }

-void
-loop ()
+void loop ()
   {
     /* Verwenden Sie die Funktion "vTaskDelay ()" anstelle der Funktion
        "delay ()"!  */


Update selftest.ino

Update selftest.ino

--- examples/selftest/selftest.ino
+++ examples/selftest/selftest.ino
@@ -70,10 +70,10 @@
   int offset = Tsunami.measureCurrentVoltage();
   Tsunami.setOffset(-1000);
   delay(200);
-  assert_nearly_equal("output_offset_neg", Tsunami.measureCurrentVoltage(), offset - 1375, 75);
+  assert_nearly_equal("output_offset_neg", Tsunami.measureCurrentVoltage(), offset - 1325, 75);
   Tsunami.setOffset(1000);
   delay(200);
-  assert_nearly_equal("output_offset_pos", Tsunami.measureCurrentVoltage(), offset + 1375, 75);
+  assert_nearly_equal("output_offset_pos", Tsunami.measureCurrentVoltage(), offset + 1325, 75);
   return true;
 }

@@ -92,7 +92,7 @@

   Tsunami.setAmplitude(0);
   delay(500);
-  assert_nearly_equal("input_amp_0", Tsunami.measurePeakVoltage(), -3130, 150);
+  assert_nearly_equal("input_amp_0", Tsunami.measurePeakVoltage(), 0, 150);

   return true;
 }
@@ -107,7 +107,7 @@
   Tsunami.setFrequency(100000.0);
   delay(100);
   assert_nearly_equal("input_freq_100k", (int32_t)Tsunami.measureFrequency(), 100000l, 2l);
-  assert_nearly_equal("input_phase_100k", (int16_t)(1000 * Tsunami.measurePhase()), 0, 50);
+  assert_nearly_equal("input_phase_100k", (int16_t)(1000 * Tsunami.measurePhase()), 200, 50);

   Tsunami.setFrequency(1000000.0);
   // Reset phase counter for sensitive measurement


uncluttering code

uncluttering code

--- src/MotorAnalog.ino
+++ src/MotorAnalog.ino
@@ -11,13 +11,6 @@
 const char DIREITA = 'D';
 const char PARA = 'P';

-//codigo dos controles adicionais.
-const char NEON = 'N';
-const char BOMBA = 'B';
-
-//porta do rele da bomba.
-const int BOMBA_OUT = 13;
-
 //codigo se o botao de direcao foi apertado ou solto.
 const char APERTOU = 'P'; //seta speed
 const char SOLTOU = 'E';
@@ -42,7 +35,6 @@

 void setup(){
-    pinMode(BOMBA_OUT, OUTPUT);
     Serial.begin(9600);
     speed[0] = 0;
     speed[1] = 0;
@@ -61,25 +53,6 @@
         readSpeed();
         if(readed)
             calculateSpeed();
-    }else if(readed){
-        while(Serial.available() <=0)
-            delay(10);
-            controlaBombaGiro();
-        }
-}
-void doTheLogBT(){
-    while(Serial.available() > 0){
-        delay(10);
-        Serial.write(Serial.read());
-        char lido = Serial.read();
-        if(lido == 'L'){
-            digitalWrite(BOMBA_OUT, HIGH);
-            Serial.write("LIGOU!");
-        }
-        else if(lido == 'D'){
-            digitalWrite(BOMBA_OUT, LOW);
-            Serial.write("(des)LIGOU!");
-        }
     }
 }

@@ -139,33 +112,6 @@
     }
 }

-void controlaBombaGiro(){
-    // Serial.write("controlaBombaGiro");
-    while(Serial.available() <= 0)
-        delay(10);
-    peRead = Serial.read();
-    switch(lastRead){
-        case BOMBA:
-            if(peRead == APERTOU){
-                //liga a saida da bomba
-            }else if(peRead == SOLTOU){
-                //desliga a saida da bomba.
-            }
-            break;
-        case NEON:
-            if(peRead == APERTOU){
-                //liga o boolean que mexe na treta
-            }else if(peRead == SOLTOU){
-                //desliga o boolean que mexe na treta.
-            }
-            break;
-        case PARA:
-            if(peRead == APERTOU || peRead == SOLTOU){
-                stopAll();
-            }
-    }
-
-}
 //Calcula a velocidade que cada motor deve girar para mover o veiculo na direção proposta.
 void calculateSpeed(){
     unsigned char frente, lado;


Changed to measure every 15 minutes, but report every two hours.  Final version for the Leonardo-based Hera200.

--- PassingPersonCounter.ino
+++ PassingPersonCounter.ino
@@ -7,7 +7,9 @@
 #include <SPI.h>
 #include <GSM.h>
 #include <HttpClient.h>
+#include <Time.h>
 #include <Xively.h>
+#include <FreeMemory.h>

 //============================================================
 // IMPORTANT!
@@ -26,34 +28,84 @@
 #define GPRS_LOGIN     ""    // replace with your GPRS login
 #define GPRS_PASSWORD  "" // replace with your GPRS password

+#define DEBUG 0
+
+// How long each reading set should span (IN MINUTES!)
+const unsigned long kReadingInterval =15UL;
+// How many readings we should take before we report them to the Internet
+const int kReadingsPerReport = 8;
+
+// FIXME
+time_t readingsTime = 1401633365;
+
 // Define the strings for our datastream IDs
 char sensorId[] = "Movement";
 char batteryId[] = "Battery";
 char chargingId[] = "Charge";
-XivelyDatastream datastreams[] = {
-  XivelyDatastream(batteryId, strlen(batteryId), DATASTREAM_FLOAT),
-  XivelyDatastream(chargingId, strlen(chargingId), DATASTREAM_INT),
-  XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_INT)
+char freeMemId[] = "FreeRAM";
+XivelyDatapoint batteryReadings[kReadingsPerReport] = {
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT),
+  XivelyDatapoint(DATASTREAM_FLOAT)
+};
+XivelyDatapoint chargingReadings[kReadingsPerReport] = {
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT)
+};
+XivelyDatapoint sensorReadings[kReadingsPerReport] = {
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT)
+};
+XivelyDatapoint freeMemReadings[kReadingsPerReport] = {
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT),
+  XivelyDatapoint(DATASTREAM_INT)
+};
+XivelyHistoricDatastream datastreams[] = {
+  XivelyHistoricDatastream(batteryId, strlen(batteryId), DATASTREAM_FLOAT, batteryReadings, kReadingsPerReport),
+  XivelyHistoricDatastream(chargingId, strlen(chargingId), DATASTREAM_INT, chargingReadings, kReadingsPerReport),
+  XivelyHistoricDatastream(sensorId, strlen(sensorId), DATASTREAM_INT, sensorReadings, kReadingsPerReport),
+  XivelyHistoricDatastream(freeMemId, strlen(freeMemId), DATASTREAM_INT, freeMemReadings, kReadingsPerReport)
 };
 // Finally, wrap the datastreams into a feed
-XivelyFeed feed(xivelyFeedId, datastreams, 3 /* number of datastreams */);
+XivelyHistoricFeed feed(xivelyFeedId, datastreams, 4 /* number of datastreams */);

 volatile int movementCount =0;
 volatile unsigned long movementStart =0;
 int lastMovementCount =0;
 unsigned long lastMovementTime =0;
-unsigned long lastReportTime =0;
+unsigned long lastReadingTime =0;

 // How long it'd take one person to pass by the sensor
 const unsigned long kPassingTime =30*1000;

-// How long we should sleep between reporting results (IN MINUTES!)
-const unsigned long kReportInterval =2*60UL;
 // boilerplate for low-power waiting
 ISR(WDT_vect) { Sleepy::watchdogEvent(); }

 void setup() {
-#if 0
+#if DEBUG
   Serial.begin(9600);
   while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
@@ -82,23 +134,45 @@
   // loseSomeTime can only sleep for up to just over a minute (65535
   // milliseconds) so to get decent sleep intervals, we'll loop through
   // a number of times
-  for (int i =0; i < kReportInterval; i++) {
-    lastReportTime = millis();
-    while (Sleepy::loseSomeTime((60*1000)-(millis()-lastReportTime)) == 0)
-    {
-      // It was interrupted by the movement trigger, go back to sleep
-#if 0
-      digitalWrite(4, HIGH);
+  for (int readingIdx = 0; readingIdx < kReadingsPerReport; readingIdx++)
+  {
+    for (int i =0; i < kReadingInterval; i++) {
+      lastReadingTime = millis();
+#if DEBUG
+      delay(60000);
+#else
+      while (Sleepy::loseSomeTime((60*1000)-(millis()-lastReadingTime)) == 0)
+      {
+        // It was interrupted by the movement trigger, go back to sleep
+      }
+#endif
+    }
+    // Store these readings
+    // Record what our battery level is now too
+    // A4 is measuring the mid-point of a 100k/100k voltage divider
+    batteryReadings[readingIdx].setFloat(analogRead(A4)*2.0*3.3/1023.0);
+    // And whether or not we're charging
+    chargingReadings[readingIdx].setInt(analogRead(A5));
+    // Plus how much memory is free (so we'll maybe spot memory leaks)
+    freeMemReadings[readingIdx].setInt(FreeRam());
+
+    sensorReadings[readingIdx].setInt(movementCount);
+    movementCount = 0;
+    for (int i=0; i < sensorReadings[readingIdx].getInt(); i++)
+    {
+      digitalWrite(13, LOW);
       delay(300);
-      digitalWrite(4, LOW);
-#endif
+      digitalWrite(13, HIGH);
+      delay(200);
     }
   }

   digitalWrite(13, LOW);
-  delay(1000);
+
+#if 1
+  reportMovementCount();
   digitalWrite(13, HIGH);
-
+#else
   if (movementCount > lastMovementCount)
   {
     int diff = movementCount - lastMovementCount;
@@ -124,6 +198,7 @@
     lastMovementTime = movementTime;
 #endif
   }
+#endif
 }

 void movementDetected()
@@ -153,13 +228,16 @@
   }
 }

-void reportMovementCount(int aCount)
+void reportMovementCount()
 {
   GSM gsmAccess;     // include a 'true' parameter to enable debugging
   GPRS gprs;
   GSMClient client;
   XivelyClient xivelyclient(client);

+#if DEBUG
+  Serial.println("reporting movement count");
+#endif
   // connection state
   boolean notConnected = true;
   // After starting the modem with GSM.begin()
@@ -176,15 +254,30 @@
       digitalWrite(4, LOW);
     }
   }
+
+#if DEBUG
+  Serial.println("connected");
+#endif
+  // Set current value to whatever the last reading was
+  datastreams[0].setFloat(batteryReadings[kReadingsPerReport-1].getFloat());
+  datastreams[1].setInt(chargingReadings[kReadingsPerReport-1].getInt());
+  datastreams[2].setInt(sensorReadings[kReadingsPerReport-1].getInt());
+  datastreams[3].setInt(freeMemReadings[kReadingsPerReport-1].getInt());

-  // Record what our battery level is now too
-  // A4 is measuring the mid-point of a 100k/100k voltage divider
-  datastreams[0].setFloat(analogRead(A4)*2.0*3.3/1023.0);
-  // And whether or not we're charging
-  datastreams[1].setInt(analogRead(A5));
+  // Sort out the times FIXME!!!
+  for (int idx = 0; idx < kReadingsPerReport; idx++)
+  {
+    batteryReadings[idx].setTime(readingsTime);
+    chargingReadings[idx].setTime(readingsTime);
+    sensorReadings[idx].setTime(readingsTime);
+    freeMemReadings[idx].setTime(readingsTime);
+    readingsTime += kReadingInterval*60;
+  }

-  datastreams[2].setInt(aCount);
-
+#if DEBUG
+  Serial.println("putting data");
+  Serial.println(feed);
+#endif
   if (xivelyclient.put(feed, xivelyKey) < 0)
   {
     // Something went wrong
@@ -196,6 +289,9 @@
       delay(200);
     }
   }
+#if DEBUG
+  Serial.println("finished putting data");
+#endif

   while ( gsmAccess.shutdown() != 1 ) {
     delay (1000);


changed to neopoxel shield

changed to neopoxel shield

--- VisualMetronome.ino
+++ VisualMetronome.ino
@@ -5,7 +5,7 @@
 #define PIN            6

 // How many NeoPixels are attached to the Arduino?
-#define NUMPIXELS      12
+#define NUMPIXELS      40

 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


minor changes to keep up with the changes in library (steer renamed to turn)

--- examples/basic_bt_movement/basic_bt_movement.ino
+++ examples/basic_bt_movement/basic_bt_movement.ino
@@ -1,6 +1,7 @@
 #include <AFMotor.h>
 #include <Smartcar.h>
 #include <SoftwareSerial.h>
+

 SoftwareSerial bluetooth(50,51); // RX, TX
 // Only pins: 10, 11, 12, 13,  50, 51, 52, 53,  62, 63, 64, 65, 66, 67, 68, 69 will only work for SoftwareSerial on Arduino Mega!
@@ -30,17 +31,22 @@
     case 'b': //go backward
       bob.goBackward();
       break;
-    case 'z': //steer back left
-      bob.steerBackLeft();
+    case 'z': //turn back left
+      bob.turnBackLeft();
       break;
-    case 'x': //steer back right
-      bob.steerBackRight();
+    case 'x': //turn back right
+      bob.turnBackRight();
       break;
-    case 'p': //steer front left
-      bob.steerFrontLeft();
+    case 'p': //turn front left
+      bob.turnFrontLeft();
       break;
-    case 'k': //steer front right
-      bob.steerFrontRight();
+    case 'k': //turn front right
+      bob.turnFrontRight();
+      break;
+    case 'q': //go forward and backward
+      bob.goForward(100);
+      bob.goBackward(50);
+      bob.goForward(1);
       break;
     default: //if you receive something that you don't know, just stop
       bob.stop();


Update _03-hx711-scale-esp-12.ino

Update _03-hx711-scale-esp-12.ino

--- _03-hx711-scale/_03-hx711-scale-v2-battery-external-Interrupt-02/_03-hx711-scale-esp-12/_03-hx711-scale-esp-12.ino
+++ _03-hx711-scale/_03-hx711-scale-v2-battery-external-Interrupt-02/_03-hx711-scale-esp-12/_03-hx711-scale-esp-12.ino
@@ -137,7 +137,7 @@
   Serial.println(y);

-  if ( x >= 10000 ) {
+  if ( x >= 10000 | x == 0 ) {
     Serial.println("scale is sleeping");
     return;
   } else {


updated serial output

updated serial output

--- arduino+esp01/particle_monitor_with_P2_output_sparkfun_logging/particle_monitor_with_P2_output_sparkfun_logging.ino
+++ arduino+esp01/particle_monitor_with_P2_output_sparkfun_logging/particle_monitor_with_P2_output_sparkfun_logging.ino
@@ -93,12 +93,14 @@
    if ((millis()-starttime) > sampletime_ms)
   {
     ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100
-    // concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve for 1 um particles, shinyei PPD42ns
-    concentration = 0.1187*ratio - 0.0865; // using spec sheet curve for DSM501A
+    //concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve for 1 um particles, shinyei PPD42ns
+    //concentration = 0.1187*ratio - 0.0865; // mg/m3 using spec sheet curve for DSM501A
+    concentration = 620.61*ratio/10; // particles/0.01ft3 for DSM501A, /10 to correlate with dylos sensor
     if (i == 1) {
       analogWrite(setPin, threshDuty); // turns on P2 detection pin, have to wait 51 should be 1 um for P2, this will set the input P2 voltage for particle detection size. with 22kOhm and 10uF PWM power converter, this should take about a second
       pin = P2pin;
       Serial.println("P1:" + String(concentration));
+      Serial.println("P1 ratio: " + String(ratio));
       wifiSerial.println("currentDust.P1=" + String(roundf(concentration)));
       delay(1100); // wait for the ESP8266 to catch up with input, and for P2 voltage threshold to plateau
       while (wifiSerial.available()){
@@ -112,6 +114,7 @@
       pin = P1pin;
       analogWrite(setPin, 0);
       Serial.println("P2:" + String(concentration));
+      Serial.println("P2 ratio: " + String(ratio));
       wifiSerial.println("currentDust.P2=" + String(roundf(concentration)));
       delay(500); // wait for esp8266 to process input, and make sure don't garble P2 with dofile('... below
       while (wifiSerial.available()){


fixed Serial Event delegation

fixed Serial Event delegation

--- tactA_single/tactA_single.ino
+++ tactA_single/tactA_single.ino
@@ -71,10 +71,9 @@
   // pipe that has not been processed..
   while (Serial.available() > 0) {
     // Read incoming serial data
-    //serialEvent (Serial.read());
-    Serial.write(Serial.read());
+    serialEvent (Serial.read());
   }
-/*
+
   // If signal data has been requested
   // by the client (i.e. Processing) ...
   if (state == STATE_TRANSMIT_SENSOR) {
@@ -118,7 +117,7 @@

     state = STATE_IDLE;
   }
-  */
+
 }

 /**


Two new test cases, intendation fixes and output flushing.

--- tests/HILTester/HILTester.ino
+++ tests/HILTester/HILTester.ino
@@ -4,6 +4,49 @@
  * The test script will then compare the data that if received to the expected
  * results in order to determine whether the test has been successful or not.
  * */
+
+void sendSequences(void)
+/* Send various sequences of bytes with 0x00 in different places. Send
+each byte one at a time formatted in the raw binary representation. */
+{
+	// Test data from Python test-script. Various end cases.
+	// goodHex=[b'\x80\x81\x82',b'\x80\x00\x82',b'\x80\x82\x00',b'\x00\x80\x82',
+	// b'\x80\xA0\x00\x82\xA1',b'\x80\x82\xA1\x00',b'\x00\xA1\x80\x82',
+	// b'\x00\xAF\x80\x82',b'\x00\xAF\x00\x00',b'\x00\x00\xAF\x00']
+
+	// Send the data one byte at a time.
+ 	Serial.write(0x80);Serial.write(0x81);Serial.write(0x82);
+ 	Serial.write(0x80);Serial.write(0x00);Serial.write(0x82);
+ 	Serial.write(0x80);Serial.write(0x82);Serial.write(0x00);
+	Serial.write(0x00);Serial.write(0x80);Serial.write(0x82);
+	Serial.write(0x80);Serial.write(0xA0);Serial.write(0x00);Serial.write(0x82);Serial.write(0xA1);
+	Serial.write(0x80);Serial.write(0x82);Serial.write(0xA1);Serial.write(0x00);
+	Serial.write(0x00);Serial.write(0xA1);Serial.write(0x80);Serial.write(0x82);
+	Serial.write(0x00);Serial.write(0xAF);Serial.write(0x80);Serial.write(0x82);
+	Serial.write(0x00);Serial.write(0xAF);Serial.write(0x00);Serial.write(0x00);
+	Serial.write(0x00);Serial.write(0x00);Serial.write(0xAF);Serial.write(0x00);
+
+	// Wait for the outgoing buffer to be cleared.
+ 	Serial.flush();
+}
+
+void sendLongs(void)
+/* Send two-byte integers from 256 to 65535 inclusive (0x0100 to 0xFFFF). Do it
+in steps of 500 to speed up the test w/o loss of generality and end cases. Send
+each long one at a time formatted in the raw binary representation. */
+{
+	long thisByte = 256; // 0x0100, smallest two-byte int.
+
+	while(thisByte<65535) // Go through all ints until 0xFFFFF.
+	{
+		// Print thisByte unaltered, i.e. the raw binary version of the byte.
+		Serial.write(thisByte);
+		Serial.flush(); // Wait for the outgoing buffer to be cleared.
+
+		// Go on to the next long but in large steps to speed things up.
+		thisByte+=500;
+	}
+}

 void sendNonASCII(void)
 /* Send several non-ASCII bytes (128+, 0x80 to 0xFF, i.e. no longer ASCII but
@@ -17,6 +60,7 @@
 	{
 	  // Send this byte unaltered, i.e. the raw binary version of the byte.
 	  Serial.write(bytesToSend[i]);
+	  Serial.flush(); // Wait for the outgoing buffer to be cleared.
 	}
 }

@@ -32,29 +76,30 @@
 	{
 	  // Print thisByte unaltered, i.e. the raw binary version of the byte.
 	  Serial.write(thisByte);
+	  Serial.flush(); // Wait for the outgoing buffer to be cleared.

 	  // Go on to the next character.
 	  thisByte++;
 	}
 }

- void sendOne(void)
- /* Send '1' ASCII character, followed by a 0x00 and 0 integers. */
- {
-	 Serial.print("1"); // Send ASCII character.
-	 Serial.write(0x01); // Hex number.
-	 Serial.write(1); // Decimal number.
-	 Serial.flush(); // Wait for the outgoing buffer to be cleared.
- }
+void sendOne(void)
+/* Send '1' ASCII character, followed by a 0x00 and 0 integers. */
+{
+	Serial.print("1"); // Send ASCII character.
+	Serial.write(0x01); // Hex number.
+	Serial.write(1); // Decimal number.
+	Serial.flush(); // Wait for the outgoing buffer to be cleared.
+}

- void sendZero(void)
- /* Send '0' ASCII character, followed by a 0x00 and 0 integers. */
- {
- 	Serial.print("0"); // Send ASCII character.
- 	Serial.write(0x00); // Hex number.
- 	Serial.write(0); // Decimal number.
- 	Serial.flush(); // Wait for the outgoing buffer to be cleared.
- }
+void sendZero(void)
+/* Send '0' ASCII character, followed by a 0x00 and 0 integers. */
+{
+	Serial.print("0"); // Send ASCII character.
+	Serial.write(0x00); // Hex number.
+	Serial.write(0); // Decimal number.
+	Serial.flush(); // Wait for the outgoing buffer to be cleared.
+}

 void sendA(void)
 /* Send 'A' character, followed by a 0x41 and 65 (corresponding ASCII code in hex and decimal). */
@@ -104,6 +149,12 @@
 			case 'N': // Send several non-ASICC bytes.
 				sendNonASCII();
 				break;
+			case 'L': // Send two-byte integers.
+				sendLongs();
+				break;
+			case 'Q': // Send sequences of bytes.
+				sendSequences();
+				break;
 		}
 	}
 }


Mostly just switched back to USB output for the serial - Also small fix

Fixed it up so DMOC is set to RPM mode when not using throttle.

--- GEVCU.ino
+++ GEVCU.ino
@@ -66,7 +66,8 @@
   for(uint8_t count = 0; count < 5; count++) {
     CAN.mailbox_init(count);
     CAN.mailbox_set_mode(count, CAN_MB_RX_MODE);
-    CAN.mailbox_set_accept_mask(count, 0x7F0, false);
+
+    CAN.mailbox_set_accept_mask(count, 0x7F0, false); //pay attention to everything but the last hex digit
   }
   //First three mailboxes listen for 0x23x frames, last two listen for 0x65x frames
   CAN.mailbox_set_id(0, 0x230, false); CAN.mailbox_set_id(1, 0x230, false); CAN.mailbox_set_id(2, 0x230, false);
@@ -82,13 +83,13 @@
   //Enable interrupts for the RX boxes. TX interrupts aren't wired up yet
   CAN.enable_interrupt(CAN_IER_MB0 | CAN_IER_MB1 | CAN_IER_MB2 | CAN_IER_MB3 | CAN_IER_MB4);

-  Serial.println("CAN INIT OK");
+  SerialUSB.println("CAN INIT OK");

   NVIC_EnableIRQ(CAN0_IRQn); //tell the nested interrupt controller to turn on our interrupt

   Wire.begin();

-  Serial.println("TWI INIT OK");
+  SerialUSB.println("TWI INIT OK");

   rtc_clock.init();
   //Now, we have no idea what the real time is but the EEPROM should have stored a time in the past.
@@ -99,17 +100,17 @@
   sysPrefs.Read(EESYS_RTC_DATE, &temp);
   rtc_clock.change_date(temp);
   */
-  Serial.println("RTC INIT OK");
+  SerialUSB.println("RTC INIT OK");

   setup_sys_io(); //get calibration data for system IO
-  Serial.println("SYSIO INIT OK");
+  SerialUSB.println("SYSIO INIT OK");
 }

 void setup() {

-  Serial.begin(115200);
-
-  Serial.println("GEVCU alpha 03-21-2013");
+  SerialUSB.begin(115200);
+
+  SerialUSB.println("GEVCU alpha 04-21-2013");

   setup_due();

@@ -133,27 +134,27 @@
   //compiled into the ROM
   //Serial.println("Installed devices: DMOC645");

-  Serial.print("System Ready ");
+  SerialUSB.print("System Ready ");
   printMenu();

 }

 void printMenu() {
-  Serial.println("System Menu:");
-  Serial.println("D = disabled op state");
-  Serial.println("S = standby op state");
-  Serial.println("E = enabled op state");
-  Serial.println("n = neutral gear");
-  Serial.println("d = DRIVE gear");
-  Serial.println("r = reverse gear");
-  Serial.println("<space> = start/stop ramp test");
-  Serial.println("x = lock ramp at current value (toggle)");
-  Serial.println("t = Use accelerator pedal? (toggle)");
-  Serial.println("L = output raw input values (toggle)");
-  Serial.println("K = set all outputs high");
-  Serial.println("J = set all outputs low");
-  Serial.println("Y,U,I = test EEPROM routines");
-  Serial.println("");
+  SerialUSB.println("System Menu:");
+  SerialUSB.println("D = disabled op state");
+  SerialUSB.println("S = standby op state");
+  SerialUSB.println("E = enabled op state");
+  SerialUSB.println("n = neutral gear");
+  SerialUSB.println("d = DRIVE gear");
+  SerialUSB.println("r = reverse gear");
+  SerialUSB.println("<space> = start/stop ramp test");
+  SerialUSB.println("x = lock ramp at current value (toggle)");
+  SerialUSB.println("t = Use accelerator pedal? (toggle)");
+  SerialUSB.println("L = output raw input values (toggle)");
+  SerialUSB.println("K = set all outputs high");
+  SerialUSB.println("J = set all outputs low");
+  SerialUSB.println("Y,U,I = test EEPROM routines");
+  SerialUSB.println("");
 }

@@ -168,9 +169,9 @@
     CAN.get_rx_buff(&message);
     motorcontroller->handleFrame(message);
   }
-  if (Serial.available()) serialEvent(); //due doesnt have int driven serial yet
+  if (SerialUSB.available()) serialEvent(); //due doesnt have int driven serial yet
   if (tickReady) {
-    if (dotTick == 0) Serial.print('.'); //print . every 256 ticks (2.56 seconds)
+    if (dotTick == 0) SerialUSB.print('.'); //print . every 256 ticks (2.56 seconds)
     dotTick = dotTick + 1;
     tickReady = false;
     //do tick related stuff
@@ -186,26 +187,26 @@
      if (throttleval > 80) throttleval = 0;
      if (throttleDebug) {
        adcval = getAnalog(0);
-       Serial.print("A0: ");
-       Serial.print(adcval);
+       SerialUSB.print("A0: ");
+       SerialUSB.print(adcval);
        adcval = getAnalog(1);
-       Serial.print(" A1: ");
-       Serial.print(adcval);
+       SerialUSB.print(" A1: ");
+       SerialUSB.print(adcval);
        adcval = getAnalog(2);
-       Serial.print(" A2: ");
-       Serial.print(adcval);
+       SerialUSB.print(" A2: ");
+       SerialUSB.print(adcval);
        adcval = getAnalog(3);
-       Serial.print(" A3: ");
-       Serial.print(adcval);
-       if (getDigital(0)) Serial.print(" D0: HIGH");
-         else Serial.print(" D0: LOW");
-       if (getDigital(1)) Serial.print(" D1: HIGH");
-         else Serial.print(" D1: LOW");
-       if (getDigital(2)) Serial.print(" D2: HIGH");
-         else Serial.print(" D2: LOW");
-       if (getDigital(3)) Serial.print(" D3: HIGH");
-         else Serial.print(" D3: LOW");
-       Serial.println("");
+       SerialUSB.print(" A3: ");
+       SerialUSB.print(adcval);
+       if (getDigital(0)) SerialUSB.print(" D0: HIGH");
+         else SerialUSB.print(" D0: LOW");
+       if (getDigital(1)) SerialUSB.print(" D1: HIGH");
+         else SerialUSB.print(" D1: LOW");
+       if (getDigital(2)) SerialUSB.print(" D2: HIGH");
+         else SerialUSB.print(" D2: LOW");
+       if (getDigital(3)) SerialUSB.print(" D3: HIGH");
+         else SerialUSB.print(" D3: LOW");
+       SerialUSB.println("");
      }
    }
    if (!runThrottle) { //ramping test
@@ -233,7 +234,7 @@
 void serialEvent() {
   int incoming;
   DMOC* dmoc = (DMOC*)motorcontroller;
-  incoming = Serial.read();
+  incoming = SerialUSB.read();
   if (incoming == -1) return;
   switch (incoming) {
     case 'h':
@@ -244,85 +245,88 @@
     case ' ':
       runRamp = !runRamp;
         if (runRamp) {
-	  Serial.println("Start Ramp Test");
+	  SerialUSB.println("Start Ramp Test");
           dmoc->setPowerMode(DMOC::MODE_RPM);
         }
 	else {
-          Serial.println("End Ramp Test");
+          SerialUSB.println("End Ramp Test");
           dmoc->setPowerMode(DMOC::MODE_TORQUE);
         }
 	break;
     case 'd':
       dmoc->setGear(DMOC::DRIVE);
-      Serial.println("forward");
+      SerialUSB.println("forward");
       break;
     case 'n':
       dmoc->setGear(DMOC::NEUTRAL);
-      Serial.println("neutral");
+      SerialUSB.println("neutral");
       break;
     case 'r':
       dmoc->setGear(DMOC::REVERSE);
-      Serial.println("reverse");
+      SerialUSB.println("reverse");
       break;
     case 'D':
       dmoc->setOpState(DMOC::DISABLED);
-      Serial.println("disabled");
+      SerialUSB.println("disabled");
       break;
     case 'S':
       dmoc->setOpState(DMOC::STANDBY);
-      Serial.println("standby");
+      SerialUSB.println("standby");
       break;
     case 'E':
       dmoc->setOpState(DMOC::ENABLE);
-      Serial.println("enabled");
+      SerialUSB.println("enabled");
       break;
     case 'x':
       runStatic = !runStatic;
       if (runStatic) {
-        Serial.println("Lock RPM rate");
-      }
-      else Serial.println("Unlock RPM rate");
+        SerialUSB.println("Lock RPM rate");
+      }
+      else SerialUSB.println("Unlock RPM rate");
       break;
     case 't':
       runThrottle = !runThrottle;
       if (runThrottle) {
-        Serial.println("Use Throttle Pedal");
+        SerialUSB.println("Use Throttle Pedal");
         dmoc->setPowerMode(DMOC::MODE_TORQUE);
       }
-      else Serial.println("Ignore throttle pedal");
+      else {
+        SerialUSB.println("Ignore throttle pedal");
+        dmoc->setPowerMode(DMOC::MODE_RPM);
+      }
       break;
     case 'L':
       throttleDebug = !throttleDebug;
       if (throttleDebug) {
-        Serial.println("Output raw throttle");
-      }
-      else Serial.println("Cease raw throttle output");
+        SerialUSB.println("Output raw throttle");
+      }
+      else SerialUSB.println("Cease raw throttle output");
       break;
     case 'Y':
-      Serial.println("Trying to save 0x45 to eeprom location 10");
+      SerialUSB.println("Trying to save 0x45 to eeprom location 10");
       uint8_t temp;
       MemCache.Write(10, (uint8_t) 0x45);
       MemCache.Read(10, &temp);
-      Serial.print("Got back value of ");
-      Serial.println(temp);
+      SerialUSB.print("Got back value of ");
+      SerialUSB.println(temp);
       break;
     case 'U':
-      Serial.println("Adding a sequence of values from 0 to 255 into eeprom");
+      SerialUSB.println("Adding a sequence of values from 0 to 255 into eeprom");
       for (int i = 0; i<256; i++) MemCache.Write(1000+i,(uint8_t)i);
-      Serial.println("Flushing cache");
+      SerialUSB.println("Flushing cache");
       MemCache.FlushAllPages(); //write everything to eeprom
       MemCache.InvalidateAll(); //remove all data from cache
-      Serial.println("Operation complete.");
+      SerialUSB.println("Operation complete.");
       break;
     case 'I':
-      Serial.println("Retrieving data previously saved");
+      SerialUSB.println("Retrieving data previously saved");
       uint8_t val;
       for (int i = 0; i < 256; i++) {
         MemCache.Read(1000 + i, &val);
-        Serial.print(val);
-        Serial.print(" ");
-      }
-      Serial.println("");
+        SerialUSB.print(val);
+        SerialUSB.print(" ");
+      }
+      SerialUSB.println("");
       break;
     case 'K': //set all outputs high
       setOutput(0, true);


restored wsad functionality

restored wsad functionality

--- arduino/ConstantSpeedMega/ConstantSpeedMega.ino
+++ arduino/ConstantSpeedMega/ConstantSpeedMega.ino
@@ -14,20 +14,23 @@
 #define Y_MIN_PIN          14
 #define Y_MAX_PIN          15

-float stepsize = 500;
-int varDelay = 10;
+int stepsize = 100;
+int varDelay = 0;

 void setup() {
     pinMode(X_ENABLE_PIN, OUTPUT);
     pinMode(Y_ENABLE_PIN, OUTPUT);
-    digitalWrite(X_ENABLE_PIN, LOW);
-    digitalWrite(Y_ENABLE_PIN, LOW);
+    digitalWrite(X_ENABLE_PIN, HIGH);
+    digitalWrite(Y_ENABLE_PIN, HIGH);

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

 void stepX(int steps, int dir) {
+    digitalWrite(X_ENABLE_PIN, LOW);
+    digitalWrite(Y_ENABLE_PIN, LOW);
+
     if (dir == 0) {
         digitalWrite(X_DIR_PIN, LOW);
     } else {
@@ -36,12 +39,38 @@

     for (int x = 0; x < steps; x++) {
         digitalWrite(X_STEP_PIN, HIGH);
-        delay(varDelay);
+        //delay(varDelay);
         digitalWrite(X_STEP_PIN, LOW);
-        delay(varDelay);
+        //delay(varDelay);

         if(x%50==0)Serial.println(x);
     }
+
+    digitalWrite(X_ENABLE_PIN, HIGH);
+    digitalWrite(Y_ENABLE_PIN, HIGH);
+}
+
+void stepY(int steps, int dir) {
+    digitalWrite(X_ENABLE_PIN, LOW);
+    digitalWrite(Y_ENABLE_PIN, LOW);
+
+    if (dir == 0) {
+        digitalWrite(Y_DIR_PIN, LOW);
+    } else {
+        digitalWrite(Y_DIR_PIN, HIGH);
+    }
+
+    for (int x = 0; x < steps; x++) {
+        digitalWrite(Y_STEP_PIN, HIGH);
+        //delay(varDelay);
+        digitalWrite(Y_STEP_PIN, LOW);
+        //delay(varDelay);
+
+        if(x%50==0)Serial.println(x);
+    }
+
+    digitalWrite(X_ENABLE_PIN, HIGH);
+    digitalWrite(Y_ENABLE_PIN, HIGH);
 }

@@ -50,15 +79,11 @@
       Serial.println("1 Enable Motors ");
       Serial.println("0 Disable Motors ");
       Serial.println("");
-      Serial.println("2  - 9 delay from 20 to 90 ms");
-      Serial.println("u Motor 1 - CW  ");
-      Serial.println("n Motor 1 - CCW ");
-      Serial.println("t 5000 steps ");
-      Serial.println("b -5000 steps ");
-      Serial.println("o 100 steps ");
-      Serial.println("l -100 steps ");
-      Serial.println("i 10 steps");
-      Serial.println("k -10 steps");
+      Serial.println("2  - 9 stepsize from 1 to 1000");
+      Serial.println("w up");
+      Serial.println("s down");
+      Serial.println("a left");
+      Serial.println("d right");
 }

 void loop() {
@@ -68,6 +93,7 @@
         switch (r) {
             case '?':
               printHelp();
+              break;

             case '1':
                 digitalWrite(X_ENABLE_PIN, LOW);
@@ -78,79 +104,59 @@
                 digitalWrite(X_ENABLE_PIN, HIGH);
                 digitalWrite(Y_ENABLE_PIN, HIGH);
                 break;
-
-            case 'u':
-                Serial.print("U  ");
+
+            case 'a':
+                Serial.print("A  ");
                 Serial.println(stepsize);
                 stepX(stepsize, 1);
                 break;
-            case 'n':
-                Serial.print("N  ");
+            case 'd':
+                Serial.print("D  ");
                 Serial.println(stepsize);
                 stepX(stepsize, 0);
                 break;
-            case 't':
-                Serial.println("T  5000");
-                stepX(5000, 0);
+            case 'w':
+                Serial.print("W  ");
+                Serial.println(stepsize);
+                stepY(stepsize, 1);
                 break;
-
-            case 'b':
-                Serial.println("B -5000");
-                stepX(5000, 1);
+            case 's':
+                Serial.print("S  ");
+                Serial.println(stepsize);
+                stepY(stepsize, 0);
                 break;
-
-            case 'o':
-                Serial.println("O 100 ");
-                stepX(1000, 0);
-                break;
-
-            case 'l':
-                Serial.println("L -100 ");
-                stepX(1000, 1);
-                break;
-
-
-            case 'i':
-              Serial.println("I 10 ");
-              stepX(50, 0);
-              break;
-
-            case 'k':
-              Serial.println("K -10 ");
-              stepX(50, 1);
-              break;

             case '2':
-                Serial.println("delay = 20");
-                varDelay = 20;
+                Serial.println("stepsize = 1");
+                stepsize = 1;
                 break;
             case '3':
-                Serial.println("delay = 30");
-                varDelay = 30;
+                Serial.println("stepsize = 10");
+                stepsize = 10;
                 break;
             case '4':
-                Serial.println("delay = 40");
-                varDelay = 40;
+                Serial.println("stepsize = 100");
+                stepsize = 100;
                 break;
             case '5':
-                Serial.println("delay  =  50");
-                varDelay = 50;
+                Serial.println("stepsize = 500");
+                stepsize = 500;
                 break;
             case '6':
-                Serial.println("delay  =  60");
-                varDelay = 60;
+                Serial.println("stepsize = 1,000");
+                stepsize = 1000;
                 break;
             case '7':
-                Serial.println("delay  =  70");
-                varDelay = 70;
+                Serial.println("stepsize = 5,000");
+                stepsize = 5000;
                 break;
             case '8':
-                Serial.println("delay  =  80");
-                varDelay = 80;
+                Serial.println("stepsize = 10,000");
+                stepsize = 10000;
                 break;
             case '9':
-                Serial.println("delay  =  90");
-                varDelay = 90;
+                Serial.println("stepsize = 20,000");
+                stepsize = 20000;
                 break;

             default:


updated change date

updated change date

--- rp6control/rp6control.ino
+++ rp6control/rp6control.ino
@@ -8,7 +8,7 @@

    Made by: Rick van Schijndel
    Creation date: 8-4-2016
-   Last modified: 10-4-2016
+   Last modified: 1-6-2016
 */

 //For the people that downloaded this from github, use the shareddata header.


list sd card to wifi

list sd card to wifi

--- software/bladeBench.ino
+++ software/bladeBench.ino
@@ -1447,6 +1447,30 @@
 		doTestLog();
 	} else if (strncmp (serialCommand,"list",strlen("list")) == 0) {
 		Serial.println("got list");
+		SdFile file;
+		char name[100];
+
+		if (!sd.begin()) sd.initErrorHalt("SdFatSdioEX begin failed");
+		sd.chvol();
+		sd.vwd()->rewind();
+		Serial5.println("<BeginDirList>");
+
+		while (file.openNext(sd.vwd(), O_READ)) {
+			file.getName(name,100);
+			if (endsWith(name, ".txt")) {
+				if (!((strncmp(name,"config",strlen("config")) == 0)|
+					  (strncmp(name,"log",strlen("log")) == 0))  ) {
+
+					Serial5.print("<");
+					Serial5.print(name);
+					Serial5.println(">");
+				}
+			}
+			file.close();
+
+		}  // end of listing files
+		Serial5.println("<EndDirList>");
+

 	} else if (strncmp (serialCommand,"runprog",strlen("runprog")) == 0) {
 		Serial.println("got runprog");


added lock up watch dog

added lock up watch dog

--- apollo/apolloClient/apolloClient.ino
+++ apollo/apolloClient/apolloClient.ino
@@ -286,6 +286,11 @@
    {
      updateNow = true;
    }
+   // Quick Lock up watch Dawg.
+   else if (updateCounter * 8 / 60 >= updateInterval)
+   {
+    resetFunc();
+   }
 }

 /**


Let's make the LED not as bright as the sun if it starts up successfully

--- Arduino/GhostPassword/GhostPassword.ino
+++ Arduino/GhostPassword/GhostPassword.ino
@@ -136,6 +136,7 @@
    if(timeStatus() != timeSet) {
       setColor('r');
   } else {
+      pixels.setBrightness(16);
       setColor('g');
   }


Make demo code easier to understand

Make demo code easier to understand

--- examples/FTDebouncer_demo/FTDebouncer_demo.ino
+++ examples/FTDebouncer_demo/FTDebouncer_demo.ino
@@ -29,7 +29,9 @@
 	pinDebouncer.addPin(18, HIGH);
 	pinDebouncer.addPin(19, LOW);
 	pinDebouncer.begin();
+	Serial.print("Size of debouncer instance in bytes: ");
 	Serial.println(sizeof(pinDebouncer));
+	Serial.print("Amount of debounced pins: ");
 	Serial.println(pinDebouncer.getPinCount());
 	delay(5000);
 }
@@ -38,6 +40,7 @@
 	unsigned long usElapsed;
 	pinDebouncer.update();
 	usElapsed = micros() - us;
+	Serial.print("Elapsed microseconds since last debounce: ");
 	Serial.println(usElapsed);
 }
 void onPinActivated(int pinNr){


style: Set the Ultrasonic variable name to lowercase

Resolves: #36

--- examples/UltrasonicSimple/UltrasonicSimple.ino
+++ examples/UltrasonicSimple/UltrasonicSimple.ino
@@ -23,13 +23,15 @@
  * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
  * modified 23 Jan 2017
  * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
+ * modified 01 Mar 2017
+ * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
  *
  * This example code is released into the MIT License.
  */

 #include <Ultrasonic.h>

-Ultrasonic Ultrasonic(12, 13);
+Ultrasonic ultrasonic(12, 13);

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


added description for SxWiFi

added description for SxWiFi

--- examples/SxWiFi/SxWiFi.ino
+++ examples/SxWiFi/SxWiFi.ino
@@ -1,5 +1,5 @@
 /*
- * SxWiFie.ino
+ * SxWiFi.ino
  *
  *  Created on: 31.07.2016
  *
@@ -7,7 +7,10 @@
  *
  *  Example program for the Selectrix(TM) Library
  *  sends SX data to WiFi Interface with MKR100
- *  see http://opensx.net/projects/Funkregler2
+ *  (i.e. this is the Arduino Pro Mini part of the
+ *    interface SW)
+ *  needs special hardware:
+ *    see http://opensx.net/projects/Funkregler2
  *
  *  format:    F  80  16   (data bit 5 set on sx channel 80)
  *  and reads commands from the MKR serial port, interprets


example is for esp6266 not arduino

example is for esp6266 not arduino

--- examples/simple/simple.ino
+++ examples/simple/simple.ino
@@ -15,7 +15,6 @@
     * 2 x LEDs, with 220 ohm resistors in series.
     * A switch connected to a digital input pin.
     * A potentiometer connected to an analog input pin.
-    * A RS485 module (Optional) connected to RX/TX and a digital control pin.

     Created 8 12 2015
     By Yaacov Zamir


timer interrupt working with speed control

--- arduino/ConstantSpeedMega/ConstantSpeedMega.ino
+++ arduino/ConstantSpeedMega/ConstantSpeedMega.ino
@@ -14,7 +14,7 @@
 #define Y_MIN_PIN          14
 #define Y_MAX_PIN          15

-#define MIN_DELAY          10 // minimum timer tick
+#define MIN_DELAY          100 // minimum timer tick

 // these are initialized in reset()
 int stepsize;
@@ -22,11 +22,17 @@
 int varDelayY;
 int moveX;
 int moveY;
+
+// interrupt variables
 int timerX;
 int timerY;
 boolean stateX;
 boolean stateY;
 int timerTick;
+
+// variables for reading in speed
+String str;
+int number;

 void setup() {
     pinMode(X_ENABLE_PIN, OUTPUT);
@@ -142,15 +148,18 @@
       Serial.println("r reset");
 }

+void readNumber() {
+    str = "";
+    while (true) {
+      if (Serial.available()) {
+        byte c = Serial.read();
+        if (c >= '0' && c <= '9') str += (c - '0');
+        else break;
+      }
+    }
+}
+
 void loop() {
-//    if (moveX >= 0) {
-//      stepX(stepsize, moveX);
-//    }
-//
-//    if (moveY >= 0) {
-//      stepY(stepsize, moveY);
-//    }
-
     if (Serial.available()) {
         byte r = Serial.read();

@@ -224,24 +233,52 @@
                 break;

             case 'u':
+                noInterrupts();
                 if (moveY == 0) moveY = -1; else moveY = 1;
-                varDelayY = varDelayY + 100;
+                interrupts();
                 break;
             case 'j':
+                noInterrupts();
                 if (moveY == 1) moveY = -1; else moveY = 0;
-                varDelayY = varDelayY - 100;
+                interrupts();
                 break;
             case 'k':
+                noInterrupts();
                 if (moveX == 0) moveX = -1; else moveX = 1;
-                varDelayX = varDelayX + 100;
+                interrupts();
                 break;
             case 'h':
+                noInterrupts();
                 if (moveX == 1) moveX = -1; else moveX = 0;
-                varDelayX = varDelayX - 100;
+                interrupts();
+                break;
+
+            case 'm':
+                readNumber();
+                number = str.toInt();
+                noInterrupts();
+                varDelayX = number;
+                if (varDelayX < MIN_DELAY) varDelayX = MIN_DELAY;
+                interrupts();
+                Serial.print("speedX = ");
+                Serial.println(varDelayX);
+                break;
+
+            case 'n':
+                readNumber();
+                number = str.toInt();
+                noInterrupts();
+                varDelayY = number;
+                if (varDelayY < MIN_DELAY) varDelayY = MIN_DELAY;
+                interrupts();
+                Serial.print("speedY = ");
+                Serial.println(varDelayY);
                 break;

             case 'r':
+                noInterrupts();
                 reset();
+                interrupts();
                 break;

             default:


Added functionality to load map description document, read in the data, and populate arrays for coordinates and file names.

--- Elcano_C4_Planner/Elcano_C4_Planner.ino
+++ Elcano_C4_Planner/Elcano_C4_Planner.ino
@@ -32,9 +32,8 @@
 documentation to implement it, we decided to focus on implementing a file system with
 comma delimited values for the data we need to build junction objects.

-
 -----------------------
-| map_definitions.txt |
+|     MAP_DEFS.txt    |
 -----------------------

 This file provides the latitude and longitude coordinates for each of the maps, followed
@@ -49,8 +48,8 @@

 A practical example would look like this:

-47.758949,-122.190746,map_47_758949_-122_190746.txt,
-47.6213,-122.3509,map_47_6213_-122_3509.txt
+47.758949,-122.190746,MAP001.txt,
+47.6213,-122.3509,MAP002.txt

 -----------------------
@@ -83,6 +82,15 @@
 -73039,380865,0,3,7,END,1,1,1,1,
 -182101,338388,0,3,4,5,1,1,1,1

+-----------------------
+|     file names      |
+-----------------------
+
+The Arduino SD Card library uses a FAT file system. FAT file systems have a limitation when it comes to
+naming conventions. You must use the 8.3 format, so that file names look like “NAME001.EXT”, where
+“NAME001” is an 8 character or fewer string, and “EXT” is a 3 character extension. People commonly use
+the extensions .TXT and .LOG. It is possible to have a shorter file name (for example, mydata.txt, or
+time.log), but you cannot use longer file names.

 /*---------------------------------------------------------------------------------------

@@ -155,7 +163,8 @@

-#define MAX_WAYPOINTS 50
+#define MAX_MAPS 10         // The maximum number of map files stored to SD card.
+#define MAX_WAYPOINTS 20    // The maximum number of waypoints in each map file.
 /*   There are two coordinate systems.
      MDF and RNDF use latitude and longitude.
      C3 and C6 assume that the earth is flat at the scale that they deal with
@@ -613,55 +622,127 @@
 // SelectMap
 // Determines which map to load.
 // Takes in the current location as a waypoint and a string with the name of the file that
-// contains the origins and file names of the maps. Determines which origin is closest to
-// the waypoint and returns it as a junction.
+//   contains the origins and file names of the maps.
+// Determines which origin is closest to the waypoint and returns it as a junction.
+// Assumes the file is in the correct format according to the description above.
 char* SelectMap(waypoint currentLocation, char* fileName)
 {
-
-  Serial.print("Initializing SD card...");
-  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
-  // Note that even if it's not used as the CS pin, the hardware SS pin
-  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
-  // or the SD library functions will not work.
-   pinMode(SS, OUTPUT);
-
-  if (!SD.begin(chipSelect)) {
-    Serial.println("initialization failed!");
-    return NULL;
-  }
-  Serial.println("initialization done.");
-
   // open the file. note that only one file can be open at a time,
   // so you have to close this one before opening another.
-  myFile = SD.open("test.txt", FILE_WRITE);
+  myFile = SD.open(fileName, FILE_READ);

   // if the file opened okay, write to it:
   if (myFile) {
-    Serial.print("Writing to test.txt...");
-    myFile.println("testing 1, 2, 3.");
-	// close the file:
-    myFile.close();
-    Serial.println("done.");
-  } else {
-    // if the file didn't open, print an error:
-    Serial.println("error opening test.txt");
-  }
-
-  // re-open the file for reading:
-  myFile = SD.open("test.txt");
-  if (myFile) {
-    Serial.println("test.txt:");
+    // Initialize a string buffer to read lines from the file into
+    // Allocate an extra char at the end to add null terminator
+    char* buffer = (char*)malloc(myFile.size()+1);
+
+    // index for the next character to read into buffer
+    char* ptr = buffer;

     // read from the file until there's nothing else in it:
     while (myFile.available()) {
-      Serial.write(myFile.read());
-    }
+      *ptr = myFile.read();
+      ++ptr;
+    }
+
+    // Null terminate the buffer string
+    *ptr = '\0';
+
+    // Set up storage for coordinates and file names
+    // Note: we malloc here because the stack is too small
+    float* map_latitudes = (float*)malloc(MAX_MAPS * 4);
+    float* map_longitudes = (float*)malloc(MAX_MAPS * 4);
+    String* map_file_names = (String*)malloc(MAX_MAPS * sizeof(String));
+    for(int i = 0; i < MAX_MAPS; i++)
+    {
+      // initialize using invalid values so that we can ensure valid data in allocated memory
+      map_latitudes[i] = 91;
+      map_longitudes[i] = 181;
+      map_file_names[i] = "";
+    }
+
+    // Set up tokenizer for the file buffer string
+    char delimiter[2] = ",";
+    char* token;
+    int col = 0;
+    int row = 0;
+
+    // get the first token
+    token = strtok(buffer, delimiter);
+
+    // walk through other tokens
+    while( token != NULL && row < MAX_MAPS )
+    {
+      switch (col % 3)
+      {
+        case 0:  // latitude
+        map_latitudes[row] = String(token).toFloat();
+        col++;
+        break;
+
+        case 1:  // longitude
+        map_longitudes[row] = String(token).toFloat();
+        col++;
+        break;
+
+        case 2:  // filename
+        map_file_names[row] = String(token);
+        col++;
+        row++;
+        break;
+
+        default:  // unexpected condition; print error
+        Serial.println("Unexpected error happened while reading map description file. Please verify the file is in the correct format. Planner may not work correctly if this message appears.");
+        break;
+      }
+      token = strtok(NULL, delimiter);
+    }
+    Serial.println("Latitudes: ");
+    for (int i = 0; i < MAX_MAPS; i++)
+    {
+      if (map_latitudes[i] >= -90 && map_latitudes[i] <= 90)
+      {
+        Serial.println(map_latitudes[i],8);
+      }
+    }
+
+    Serial.println("Longitudes: ");
+    for (int i = 0; i < MAX_MAPS; i++)
+    {
+      if (map_longitudes[i] >= -180 && map_longitudes[i] <= 180)
+      {
+        Serial.println(map_longitudes[i],8);
+      }
+    }
+
+    Serial.println("File names: ");
+    for (int i = 0; i < MAX_MAPS; i++)
+    {
+      if (map_file_names[i] != "")
+      {
+        Serial.println(map_file_names[i]);
+      }
+    }
+
+    // Free the memory allocated for the buffer
+    free(buffer);
+
+    free(map_latitudes);
+    free(map_longitudes);
+    free(map_file_names);
+
     // close the file:
     myFile.close();
+    Serial.println("Map definitions loaded.");
   } else {
-  	// if the file didn't open, print an error:
-    Serial.println("error opening test.txt");
-  }
+
+    // if the file didn't open, print an error:
+    myFile.close();
+    Serial.println("error opening map_defs.txt");
+  }
+
+

   // Define serial connection to SD card
   // Attempt to load file
@@ -702,6 +783,18 @@
   {
     Nodes[i] = nodeList[i];
   }
+  Serial.print("Initializing SD card...");
+  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
+  // Note that even if it's not used as the CS pin, the hardware SS pin
+  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
+  // or the SD library functions will not work.
+   pinMode(SS, OUTPUT);
+
+  if (!SD.begin(chipSelect)) {
+    Serial.println("initialization failed!");
+  }
+  Serial.println("initialization done.");
+  SelectMap(Origin,"map_defs.txt");

      ConstructNetwork(Nodes, map_points);


Add Data Logging Shield to configuration.

--- libraries/DS1307/examples/CosaDS1307/CosaDS1307.ino
+++ libraries/DS1307/examples/CosaDS1307/CosaDS1307.ino
@@ -45,8 +45,11 @@
 #include "Cosa/Trace.hh"
 #include "Cosa/IOStream/Driver/UART.hh"

-// Set the real-time clock
+// Set the extern RTC
 // #define SET_TIME
+
+// Synchronized with external RTC square-ware
+// #define SQUARE_WAVE_CLOCK

 // The real-time device, latest start and sample time in ram
 DS1307 rtc;
@@ -61,10 +64,14 @@
 OutputPin ledPin(Board::LED);

 // Clock pin
+#if defined(SQUARE_WAVE_CLOCK)
 #if defined(ARDUINO_PRO_MICRO)
 InputPin clkPin(Board::D0);
 #else
 InputPin clkPin(Board::D2);
+#endif
+#else
+Watchdog::Clock clock;
 #endif

 void setup()
@@ -125,7 +132,11 @@
   static int32_t cycle = 1;

   // Wait for rising edge on clock pin
+#if defined(SQUARE_WAVE_CLOCK)
   while (clkPin.is_clear()) yield();
+#else
+  clock.await();
+#endif
   ledPin.set();

   // Read the time from the rtc device and print
@@ -136,6 +147,8 @@
   cycle += 1;

   // Wait for falling edge on clock pin
+#if defined(SQUARE_WAVE_CLOCK)
   while (clkPin.is_set()) yield();
+#endif
   ledPin.clear();
 }


Adding radio functionality

Adding radio functionality

--- BitDriverRadio/BitDriverRadio.ino
+++ BitDriverRadio/BitDriverRadio.ino
@@ -1,16 +1,47 @@
-#include <AFMotor.h>
+#include <AFMotor.h> //Motor library
+#include <nRF24L01.h> //Radio libraries
+#include <RF24.h>
+#include <RF24_config.h>
+#include <SPI.h>

+//MOTOR DRIVERS
 AF_DCMotor motor1(1);
 AF_DCMotor motor2(2);
 AF_DCMotor motor3(3);
 AF_DCMotor motor4(4);

+//ENVIRONMENT VARIABLES
+int radioBoolean = false;
+int messageLength = 12;
+int msg[1];
+RF24radio(9,10);
+const uint64_t pipe = 0xE8E8F0F0E1LL;
+int lastmsg = 1;
+String theMessage = "";

 void setup()
 {
   Serial.begin(9600);
+  Serial.println("Serial started");
+  radio.begin();
+  Serial.println("Radio started");
+  radio.openReadingPipe(1,pipe);
+  Serial.println("Pipe opened");
 }

 void loop()
 {
+  receiveRadio();
 }
+
+void receiveRadio()
+{
+    if (radio.available)
+    {
+
+    }
+    else
+    {
+      Serial.println("No radio signal");
+    }
+}