debounce button press

debounce button press

--- short-circuit-limiter/short-circuit-limiter.ino
+++ short-circuit-limiter/short-circuit-limiter.ino
@@ -7,6 +7,11 @@
 #define TEMP_MAX 85
 #define TEMP_WARN 70
 #define TEMP_WARNING_RATE 120000 //2 x 60 x 1000ms
+
+#define CT_CALIBRATION_VALUE 60.6  // (100A / 0.05A) / 33 ohms
+#define INITIAL_SETTLE_TIME 20000 //20 seconds
+
+#define BUTTON_DEBOUNCE 300

 #define PIN_LED 26
 #define PIN_CT A0
@@ -24,9 +29,6 @@
 #define BUZZER_BEEP_OFF_TIME 200
 #define BUZZER_LONG_BEEP_TIME 2000

-#define CT_CALIBRATION_VALUE 60.6  // (100A / 0.05A) / 33 ohms
-#define INITIAL_SETTLE_TIME 20000 //20 seconds
-
 #define DELAY_BEFORE_LIMITER_RELAY_ENABLE 1000

 //Number of temperature reads to average over
@@ -79,9 +81,9 @@
   unsigned long timeElapsedSinceStart;

   while((timeElapsedSinceStart = (millis() - initialTime)) < INITIAL_SETTLE_TIME){
-  if(isAtLeastOneButtonPressed()){
-    break;
-  }
+    if(isAtLeastOneButtonPressed()){
+      break;
+    }

     getCurrentMeasurement();

@@ -510,7 +512,17 @@
   int downPressed = digitalRead(PIN_BUTTON_DOWN);

   if(upPressed == LOW || enterPressed == LOW || downPressed == LOW){
-    return true;
+
+    static unsigned long lastPressedTime = 0;
+    unsigned long currentTime = millis();
+
+    if((currentTime - lastPressedTime) > BUTTON_DEBOUNCE){
+      lastPressedTime = currentTime;
+      return true;
+    } else {
+      return false;
+    }
+
   } else {
     return false;
   }


BabelFish: Fixed missing newline for 'V' command [bug]

--- Utils/BabelFish/BabelFish.ino
+++ Utils/BabelFish/BabelFish.ino
@@ -553,7 +553,7 @@
     Serial.print(": size=");
     Serial.print(EEPROM.length());
     Serial.print(" mapping=");
-    Serial.print(getKeymapName());
+    Serial.println(getKeymapName());
     Serial.println(":PROGMEM slots:");
     for (byte i=0; i<arrayLen(gt1Files); i++) {
       Serial.print(": P");


Proved on logic analyser that the whole of our TEXT record comes back.

--- arduino_proto/NFC_gemma/NFC_gemma.ino
+++ arduino_proto/NFC_gemma/NFC_gemma.ino
@@ -64,133 +64,132 @@
 //  delay(250);
 //}

-void loop(){
+void loop()
+{
   //Serial.println("\nstarting");
   //digitalWrite(LED1, HIGH);

   // kill RF, select I2C
   //Serial.println("selectI2C");
-  digitalWrite(CAPTURE, HIGH);
   Wire.beginTransmission(NFC_ADDR_7BIT);
   Wire.write(selectI2C, sizeof(selectI2C));
   Wire.endTransmission();
-  digitalWrite(CAPTURE, LOW);
   delay(1);

   //select NFC app
   //Serial.println("selectNFCApp");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(selectNFCApp, sizeof(selectNFCApp));
-  //Wire.endTransmission();
-  //delay(1);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(selectNFCApp, sizeof(selectNFCApp));
+  Wire.endTransmission();
+  delay(1);
   //readAndDisplay(5);

   //select CC file
   //Serial.println("selectCCFile");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(selectCCFile, sizeof(selectCCFile));
-  //Wire.endTransmission();
-  //delay(1);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(selectCCFile, sizeof(selectCCFile));
+  Wire.endTransmission();
+  delay(1);
   //readAndDisplay(5);

   //readCCLen
   //Serial.println("readCCLen");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(readCCLen, sizeof(readCCLen));
-  //Wire.endTransmission();
-  //delay(1);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(readCCLen, sizeof(readCCLen));
+  Wire.endTransmission();
+  delay(1);
   //readAndDisplay(7);

-  //int len=20; //TODO get from above payload, not overly critical
+  int len=20; //TODO get from above payload, not overly critical

   //readCCFile
   //Serial.println("readCCFile");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(readCCFile, sizeof(readCCFile));
-  //Wire.endTransmission();
-  //delay(1);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(readCCFile, sizeof(readCCFile));
+  Wire.endTransmission();
+  delay(1);
   //readAndDisplay(len);

   //selectNDEFFile
   //Serial.println("selectNDEFFile");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(selectNDEFFile, sizeof(selectNDEFFile));
-  //Wire.endTransmission();
-  //delay(1);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(selectNDEFFile, sizeof(selectNDEFFile));
+  Wire.endTransmission();
+  delay(1);
   //readAndDisplay(5);

   //readNDEFLen
   //Serial.println("readNDEFLen");
   //digitalWrite(CAPTURE, HIGH); // so we can capture on logic analyser
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(readNDEFLen, sizeof(readNDEFLen));
-  //Wire.endTransmission();
-  //delay(1);
-
-  //Wire.requestFrom(NFC_ADDR_7BIT, 7);
-  //int idx = 0;
-  //while (Wire.available())
-  //{
-  //  byte b = Wire.read();
-  //  //Serial.print(b, HEX);
-  //  //Serial.write(' ');
-  //  if (idx == 2) // TODO max len is 255?
-  //  {
-  //    len = b;
-  //  }
-  //  idx++;
-  //}
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(readNDEFLen, sizeof(readNDEFLen));
+  Wire.endTransmission();
+  delay(1);
+
+  Wire.requestFrom(NFC_ADDR_7BIT, 7);
+  int idx = 0;
+  while (Wire.available())
+  {
+    byte b = Wire.read();
+    //Serial.print(b, HEX);
+    //Serial.write(' ');
+    if (idx == 2) // TODO max len is 255?
+    {
+      len = b;
+    }
+    idx++;
+  }
   //Serial.println();

   //readNDEFMsg
   //len = full NDEF length, (5 byte prefix+actual URI)
   //Serial.println("readNDEFMsg");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
+  digitalWrite(CAPTURE, HIGH);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
   // Patch in the length and fix the broken CRC
-  //readNDEFMsg[5] = len; // this is the len returned from ReadNDEFLen
-  //ComputeCrc(readNDEFMsg, sizeof(readNDEFMsg)-2, &(readNDEFMsg[6]), &(readNDEFMsg[7]));
-  //Wire.write(readNDEFMsg, sizeof(readNDEFMsg));
-  //Wire.endTransmission();
-  //delay(1);
+  readNDEFMsg[5] = len; // this is the len returned from ReadNDEFLen
+  ComputeCrc(readNDEFMsg, sizeof(readNDEFMsg)-2, &(readNDEFMsg[6]), &(readNDEFMsg[7]));
+  Wire.write(readNDEFMsg, sizeof(readNDEFMsg));
+  Wire.endTransmission();
+  delay(1);

 // (PCB,SW1,SW2,CRC0,CRC1)
-//#define PROTO_OVERHEAD 5
+#define PROTO_OVERHEAD 5
 // 5 bytes for NDEF header (in URI format)
-//#define HEADER_LEN 5
-
-  //int msgStart = 1 + HEADER_LEN;
-  //int msgEnd   = 1 + HEADER_LEN + (len-HEADER_LEN);
-
-  //Wire.requestFrom(NFC_ADDR_7BIT, len+PROTO_OVERHEAD);
-  //idx = 0;
-  //while (Wire.available())
-  //{
-  //  byte b = Wire.read();
-  //  if (idx >= msgStart && idx <= msgEnd)
-  //  {
-  //    //Serial.write(b);
-  //  }
-  //  idx++;
-  //}
+#define HEADER_LEN 5
+
+  int msgStart = 1 + HEADER_LEN;
+  int msgEnd   = 1 + HEADER_LEN + (len-HEADER_LEN);
+
+  Wire.requestFrom(NFC_ADDR_7BIT, len+PROTO_OVERHEAD);
+  idx = 0;
+  while (Wire.available())
+  {
+    byte b = Wire.read();
+    if (idx >= msgStart && idx <= msgEnd)
+    {
+  //    //Serial.write(b); //TODO process this character
+    }
+    idx++;
+  }
   //Serial.println();
   //readAndDisplay(len+PROTO_OVERHEAD);

-  //digitalWrite(CAPTURE, LOW); // marks end of capture region for logic analyser
+  digitalWrite(CAPTURE, LOW); // marks end of capture region for logic analyser

   //deselectI2C
   //Serial.println("deselectI2C");
-  //Wire.beginTransmission(NFC_ADDR_7BIT);
-  //Wire.write(deselectI2C, sizeof(deselectI2C));
-  //Wire.endTransmission();
-  //delay(1);
+  Wire.beginTransmission(NFC_ADDR_7BIT);
+  Wire.write(deselectI2C, sizeof(deselectI2C));
+  Wire.endTransmission();
+  delay(1);
   //readAndDisplay(3);

-  digitalWrite(CAPTURE, LOW);
   delay(1000);
 }


Added parity encoding to prevent overlap issues

--- MIDIToLED.ino
+++ MIDIToLED.ino
@@ -9,7 +9,9 @@
 #define seg_args(OFFS, WID) \
   leds + ((NUM_LEDS / WID) * (note - OFFS)), NUM_LEDS / WID , color

-void fillSegment(byte note, CRGB& color) {
+void fillSegment(byte note, CRGB color) {
+  color.setParity(1); // Set parity to 1 to prevent ray overlap
+
   if      (note < 1) // 0 .. 1 -> Full
     fill_solid(seg_args(0, 1));
   else if (note < 3) // 1 .. 3 -> 1/2
@@ -35,20 +37,22 @@
   for (int i = 0; i != rays.size(); i++) {
     uint8_t rayPos = rays.get(i)->position();
     uint8_t rayWid = min(rays.get(i)->width(), NUM_LEDS - rayPos); // Less/equal to ray width to not overflow
-    CRGB& rayCol = rays.get(i)->color();
-
-    if (rayPos > 0 && rays.get(i)->direction() == 0)
-      leds[rayPos-1] = black;
-    else if (rayPos > 1 && rays.get(i)->direction() == 1)
-      leds[NUM_LEDS-(rayPos-1)] = black;
-
-
+    CRGB rayCol = rays.get(i)->color().setParity(0); // Overlap with other rays is allowed
+
+    if (leds[rayPos].getParity() == 0) { // Rays cannot overlap static segments
+      if (rayPos > 0 && rays.get(i)->direction() == 0)
+        leds[rayPos-1] = black;
+      else if (rayPos > 1 && rays.get(i)->direction() == 1)
+        leds[NUM_LEDS-(rayPos-1)] = black;
+

-    for (int j = 0; j != rayWid; j++) {
-      if (rays.get(i)->direction() == 0)
-        leds[constrain(rayPos+j, 0, NUM_LEDS-1)] = rayCol;
-      else
-        leds[constrain(NUM_LEDS-(rayPos+j), 0, NUM_LEDS-1)] = rayCol;
+
+      for (int j = 0; j != rayWid; j++) {
+        if (rays.get(i)->direction() == 0)
+          leds[constrain(rayPos+j, 0, NUM_LEDS-1)] = rayCol;
+        else
+          leds[constrain(NUM_LEDS-(rayPos+j), 0, NUM_LEDS-1)] = rayCol;
+      }
     }


Removing unnecessary comments.

Removing unnecessary comments.

--- firmware/control.ino
+++ firmware/control.ino
@@ -5,9 +5,9 @@
 // Motor PID control
 const int MAX_MOTOR_POWER = 255;
 const float MAX_CONTROL_OUTPUT = MAX_MOTOR_POWER;
-const float KP = 1; // Previous: 1
-const float KI = 0; // Previous: 0
-const float KD = 0.1; // Previous: 0.1
+const float KP = 1;
+const float KI = 0;
+const float KD = 0.1;
 float errorAInt = 0;
 float errorBInt = 0;
 float errorAPrev = 0;


Fix Syntax

Fix Syntax

--- GyroSketch/GyroSketch.ino
+++ GyroSketch/GyroSketch.ino
@@ -1,11 +1,11 @@
 /*===================
- *=     TO DO       =
- *===================
- *
- *1. Find BaudRate of CAN system
- *Determine id
- *Determine what frame is (CAN library)
- *
+  =     TO DO       =
+  ===================
+
+  1. Find BaudRate of CAN system
+  Determine id
+  Determine what frame is (CAN library)
+
 */

@@ -19,12 +19,12 @@
 #include "mcp_can.h"    //CAN communication library

 #define CAN_ID 0x150
-#define debug   //comment out to disable debug serial output
+#define debug 1

 // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
 // is used in I2Cdev.h
 #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
-    #include "Wire.h"
+#include "Wire.h"
 #endif

 // class default I2C address is 0x68
@@ -64,7 +64,7 @@
 int8_t hiZ;
 int8_t loZ;

-unsigned long lastTime = millis();
+unsigned long lastTime = millis();

 // ================================================================
 // ===               INTERRUPT DETECTION ROUTINE                ===
@@ -72,7 +72,7 @@

 volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
 void dmpDataReady() {
-    mpuInterrupt = true;
+  mpuInterrupt = true;
 }

 // ================================================================
@@ -80,222 +80,222 @@
 // ================================================================

 void setup() {
-    // join I2C bus (I2Cdev library doesn't do this automatically)
-    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
-        Wire.begin();
-        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz). Comment this line if having compilation difficulties with TWBR.
-    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
-        Fastwire::setup(400, true);
-    #endif
-
-    // initialize serial communication
-    // (115200 chosen because it is required for Teapot Demo output, but it's
-    // really up to you depending on your project)
-    Serial.begin(115200);
-    while (!Serial); // wait for Leonardo enumeration, others continue immediately
-
-    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
-    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
-    // the baud timing being too misaligned with processor ticks. You must use
-    // 38400 or slower in these cases, or use some kind of external separate
-    // crystal solution for the UART timer.
-
-    // initialize device
-    Serial.println(F("Initializing I2C devices..."));
-    mpu.initialize();
-
-    // verify connection
-    Serial.println(F("Testing device connections..."));
-    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
-
-    // load and configure the DMP
-    Serial.println(F("Initializing DMP..."));
-    devStatus = mpu.dmpInitialize();
-
-    // supply your own gyro offsets here, scaled for min sensitivity
-    mpu.setXAccelOffset(-2265);
-    mpu.setYAccelOffset(-585);
-    mpu.setZAccelOffset(2110);
-    mpu.setXGyroOffset(50);
-    mpu.setYGyroOffset(12);
-    mpu.setZGyroOffset(25);
-
-    // make sure it worked (returns 0 if so)
-    if (devStatus == 0) {
-        // turn on the DMP, now that it's ready
-        Serial.println(F("Enabling DMP..."));
-        mpu.setDMPEnabled(true);
-
-        // enable Arduino interrupt detection
-        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
-        attachInterrupt(0, dmpDataReady, RISING);
-        mpuIntStatus = mpu.getIntStatus();
-
-        // set our DMP Ready flag so the main loop() function knows it's okay to use it
-        Serial.println(F("DMP ready! Waiting for first interrupt..."));
-        dmpReady = true;
-
-        // get expected DMP packet size for later comparison
-        packetSize = mpu.dmpGetFIFOPacketSize();
+  // join I2C bus (I2Cdev library doesn't do this automatically)
+#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
+  Wire.begin();
+  TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz). Comment this line if having compilation difficulties with TWBR.
+#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
+  Fastwire::setup(400, true);
+#endif
+
+  // initialize serial communication
+  // (115200 chosen because it is required for Teapot Demo output, but it's
+  // really up to you depending on your project)
+  Serial.begin(115200);
+  while (!Serial); // wait for Leonardo enumeration, others continue immediately
+
+  // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
+  // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
+  // the baud timing being too misaligned with processor ticks. You must use
+  // 38400 or slower in these cases, or use some kind of external separate
+  // crystal solution for the UART timer.
+
+  // initialize device
+  Serial.println(F("Initializing I2C devices..."));
+  mpu.initialize();
+
+  // verify connection
+  Serial.println(F("Testing device connections..."));
+  Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
+
+  // load and configure the DMP
+  Serial.println(F("Initializing DMP..."));
+  devStatus = mpu.dmpInitialize();
+
+  // supply your own gyro offsets here, scaled for min sensitivity
+  mpu.setXAccelOffset(-2265);
+  mpu.setYAccelOffset(-585);
+  mpu.setZAccelOffset(2110);
+  mpu.setXGyroOffset(50);
+  mpu.setYGyroOffset(12);
+  mpu.setZGyroOffset(25);
+
+  // make sure it worked (returns 0 if so)
+  if (devStatus == 0) {
+    // turn on the DMP, now that it's ready
+    Serial.println(F("Enabling DMP..."));
+    mpu.setDMPEnabled(true);
+
+    // enable Arduino interrupt detection
+    Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
+    attachInterrupt(0, dmpDataReady, RISING);
+    mpuIntStatus = mpu.getIntStatus();
+
+    // set our DMP Ready flag so the main loop() function knows it's okay to use it
+    Serial.println(F("DMP ready! Waiting for first interrupt..."));
+    dmpReady = true;
+
+    // get expected DMP packet size for later comparison
+    packetSize = mpu.dmpGetFIFOPacketSize();
+  } else {
+    // ERROR!
+    // 1 = initial memory load failed
+    // 2 = DMP configuration updates failed
+    // (if it's going to break, usually the code will be 1)
+    Serial.print(F("DMP Initialization failed (code "));
+    Serial.print(devStatus);
+    Serial.println(F(")"));
+  }
+
+  // init can bus, baudrate: 500k
+  if (CAN.begin(CAN_500KBPS) == CAN_OK) Serial.print("can init ok!!\r\n");
+  else Serial.print("Can init fail!!\r\n");
+
+  // configure LED for output
+  pinMode(LED_PIN, OUTPUT);
+
+  // set accelerometer sensitivity
+  mpu.setFullScaleAccelRange(1); // +- 4g
+  //mpu.setFullScaleGyroRange(0); // 0 is default
+}
+
+
+// ================================================================
+// ===                    MAIN PROGRAM LOOP                     ===
+// ================================================================
+
+void loop() {
+  // if programming failed, don't try to do anything
+  if (!dmpReady) return;
+
+  // wait for MPU interrupt or extra packet(s) available
+  while (!mpuInterrupt && fifoCount < packetSize) {
+    // other program behavior stuff here
+    // .
+    // if you are really paranoid you can frequently test in between other
+    // stuff to see if mpuInterrupt is true, and if so, "break;" from the
+    // while() loop to immediately process the MPU data
+    // .
+    //Serial.println("Waiting for MPU interrupt or extra packets");
+  }
+
+  // reset interrupt flag and get INT_STATUS byte
+  mpuInterrupt = false;
+  mpuIntStatus = mpu.getIntStatus();
+
+  // get current FIFO count
+  fifoCount = mpu.getFIFOCount();
+
+  // check for overflow (this should never happen unless our code is too inefficient)
+  if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
+    // reset so we can continue cleanly
+    mpu.resetFIFO();
+    Serial.println(F("FIFO overflow!"));
+
+    // otherwise, check for DMP data ready interrupt (this should happen frequently)
+  } else if (mpuIntStatus & 0x02) {
+    // wait for correct available data length, should be a VERY short wait
+    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
+
+    // read a packet from FIFO
+    mpu.getFIFOBytes(fifoBuffer, packetSize);
+
+    // track FIFO count here in case there is > 1 packet available
+    // (this lets us immediately read more without waiting for an interrupt)
+    fifoCount -= packetSize;
+
+    //Grab/Process Data
+    mpu.dmpGetQuaternion(&q, fifoBuffer);
+    mpu.dmpGetAccel(&aa, fifoBuffer);
+    mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
+    mpu.dmpGetGravity(&gravity, &q);
+    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
+
+#ifdef debug
+    //Print Data to Serial bus (For Debuggin):
+    //FIFO buffer size counter
+    Serial.print(fifoCount);
+    Serial.print("\t");
+    Serial.print(mpu.getFullScaleAccelRange());
+    Serial.print("\t");
+
+    //yaw (Direction)/pitch/roll
+    Serial.print(ypr[0]);
+    Serial.print(",\t");
+    Serial.print(ypr[1]);
+    Serial.print(",\t");
+    Serial.print(ypr[2]);
+    Serial.print("\t");
+
+    //Quaternerion Coordinates
+    Serial.print(q.w);
+    Serial.print(",\t");
+    Serial.print(q.x);
+    Serial.print(",\t");
+    Serial.print(q.y);
+    Serial.print(",\t");
+    Serial.print(q.z);
+    Serial.print("\t");
+
+    //accelerations output (straight from MPU6050)
+    Serial.print(aa.x);
+    Serial.print(",\t");
+    Serial.print(aa.y);
+    Serial.print(",\t");
+    Serial.print(aa.z);
+    Serial.print("\t");
+
+    //gravity components (unit vector)
+    Serial.print(gravity.x);
+    Serial.print(",\t");
+    Serial.print(gravity.y);
+    Serial.print(",\t");
+    Serial.print(gravity.z);
+    Serial.print("\t");
+
+    //acceleartion with gravity removed
+    Serial.print(aaReal.x);
+    Serial.print(",\t");
+    Serial.print(aaReal.y);
+    Serial.print(",\t");
+    Serial.print(aaReal.z);
+    Serial.print("\n");
+#endif
+
+    //Prep data to send over CAN
+    ypr[0] = map(ypr[0] * 100, -M_PI * 100, M_PI * 100, 0, 65535);
+    aaReal.x = map(aaReal.x, -32768, 32768, 0, 65535);
+    aaReal.y = map(aaReal.y, -32768, 32768, 0, 65535);
+    aaReal.z = map(aaReal.z, -32768, 32768, 0, 65535);
+
+
+    //separates value into two 8 bit sets for transmission by typecasting as an integer and shifting and bitwise &ing into 8bit int vars
+    //break down Direction data
+    unsigned char hiDir = ((((unsigned int) (ypr[0])) >> 8) & 0xff);
+    unsigned char loDir = ((((unsigned int) (ypr[0])) >> 0) & 0xff);
+    //break down X data
+    unsigned char hiX = ((((unsigned int) (aaReal.x)) >> 8) & 0xff);
+    unsigned char loX = ((((unsigned int) (aaReal.x)) >> 0) & 0xff);
+    //break down Y data
+    unsigned char hiY = ((((unsigned int) (aaReal.y)) >> 8) & 0xff);
+    unsigned char loY = ((((unsigned int) (aaReal.y)) >> 0) & 0xff);
+    //break down Z data
+    unsigned char hiZ = ((((unsigned int) (aaReal.z)) >> 8) & 0xff);
+    unsigned char loZ = ((((unsigned int) (aaReal.z)) >> 0) & 0xff);
+
+    //Create package to send over CAN
+    unsigned char CANbuf[8] = {hiDir, loDir, hiX, loX, hiY, loY, hiZ, loZ};
+
+    //Send data over CAN
+    if (millis() - lastTime > 50) {
+      lastTime = millis();
+      CAN.sendMsgBuf(CAN_ID, 0, 8, CANbuf); //send out the package above to the bus and tell other devices this is a standard frame from 0x00.
     } else {
-        // ERROR!
-        // 1 = initial memory load failed
-        // 2 = DMP configuration updates failed
-        // (if it's going to break, usually the code will be 1)
-        Serial.print(F("DMP Initialization failed (code "));
-        Serial.print(devStatus);
-        Serial.println(F(")"));
+      Serial.println("No CAN message sent - time limit not exceded (this is okay)");
     }

-    // init can bus, baudrate: 500k
-    if(CAN.begin(CAN_500KBPS) == CAN_OK) Serial.print("can init ok!!\r\n");
-    else Serial.print("Can init fail!!\r\n");
-
-    // configure LED for output
-    pinMode(LED_PIN, OUTPUT);
-
-    // set accelerometer sensitivity
-    mpu.setFullScaleAccelRange(1); // +- 4g
-    //mpu.setFullScaleGyroRange(0); // 0 is default
+    // blink LED to indicate activity
+    blinkState = !blinkState;
+    digitalWrite(LED_PIN, blinkState);
+  }
 }
-
-
-// ================================================================
-// ===                    MAIN PROGRAM LOOP                     ===
-// ================================================================
-
-void loop() {
-    // if programming failed, don't try to do anything
-    if (!dmpReady) return;
-
-    // wait for MPU interrupt or extra packet(s) available
-    while (!mpuInterrupt && fifoCount < packetSize) {
-        // other program behavior stuff here
-        // .
-        // if you are really paranoid you can frequently test in between other
-        // stuff to see if mpuInterrupt is true, and if so, "break;" from the
-        // while() loop to immediately process the MPU data
-        // .
-        //Serial.println("Waiting for MPU interrupt or extra packets");
-    }
-
-    // reset interrupt flag and get INT_STATUS byte
-    mpuInterrupt = false;
-    mpuIntStatus = mpu.getIntStatus();
-
-    // get current FIFO count
-    fifoCount = mpu.getFIFOCount();
-
-    // check for overflow (this should never happen unless our code is too inefficient)
-    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
-        // reset so we can continue cleanly
-        mpu.resetFIFO();
-        Serial.println(F("FIFO overflow!"));
-
-    // otherwise, check for DMP data ready interrupt (this should happen frequently)
-    } else if (mpuIntStatus & 0x02) {
-        // wait for correct available data length, should be a VERY short wait
-        while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
-
-        // read a packet from FIFO
-        mpu.getFIFOBytes(fifoBuffer, packetSize);
-
-        // track FIFO count here in case there is > 1 packet available
-        // (this lets us immediately read more without waiting for an interrupt)
-        fifoCount -= packetSize;
-
-        //Grab/Process Data
-        mpu.dmpGetQuaternion(&q, fifoBuffer);
-        mpu.dmpGetAccel(&aa, fifoBuffer);
-        mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
-        mpu.dmpGetGravity(&gravity, &q);
-        mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
-
-        #ifdef debug
-          //Print Data to Serial bus (For Debuggin):
-          //FIFO buffer size counter
-          Serial.print(fifoCount);
-          Serial.print("\t");
-          Serial.print(mpu.getFullScaleAccelRange());
-          Serial.print("\t");
-
-          //yaw (Direction)/pitch/roll
-          Serial.print(ypr[0]);
-          Serial.print(",\t");
-          Serial.print(ypr[1]);
-          Serial.print(",\t");
-          Serial.print(ypr[2]);
-          Serial.print("\t");
-
-          //Quaternerion Coordinates
-          Serial.print(q.w);
-          Serial.print(",\t");
-          Serial.print(q.x);
-          Serial.print(",\t");
-          Serial.print(q.y);
-          Serial.print(",\t");
-          Serial.print(q.z);
-          Serial.print("\t");
-
-          //accelerations output (straight from MPU6050)
-          Serial.print(aa.x);
-          Serial.print(",\t");
-          Serial.print(aa.y);
-          Serial.print(",\t");
-          Serial.print(aa.z);
-          Serial.print("\t");
-
-          //gravity components (unit vector)
-          Serial.print(gravity.x);
-          Serial.print(",\t");
-          Serial.print(gravity.y);
-          Serial.print(",\t");
-          Serial.print(gravity.z);
-          Serial.print("\t");
-
-          //acceleartion with gravity removed
-          Serial.print(aaReal.x);
-          Serial.print(",\t");
-          Serial.print(aaReal.y);
-          Serial.print(",\t");
-          Serial.print(aaReal.z);
-          Serial.print("\n");
-        #endif
-
-        //Prep data to send over CAN
-        ypr[0] = map(ypr[0]*100,-M_PI*100, M_PI*100, 0, 65535);
-        aaReal.x = map(aaReal.x, -32768, 32768, 0, 65535);
-        aaReal.y = map(aaReal.y, -32768, 32768, 0, 65535);
-        aaReal.z = map(aaReal.z, -32768, 32768, 0, 65535);
-
-
-        //separates value into two 8 bit sets for transmission by typecasting as an integer and shifting and bitwise &ing into 8bit int vars
-        //break down Direction data
-        unsigned char hiDir = ((((unsigned int) (ypr[0])) >> 8) & 0xff);
-        unsigned char loDir = ((((unsigned int) (ypr[0])) >> 0) & 0xff);
-        //break down X data
-        unsigned char hiX = ((((unsigned int) (aaReal.x)) >> 8) & 0xff);
-        unsigned char loX = ((((unsigned int) (aaReal.x)) >> 0) & 0xff);
-        //break down Y data
-        unsigned char hiY = ((((unsigned int) (aaReal.y)) >> 8) & 0xff);
-        unsigned char loY = ((((unsigned int) (aaReal.y)) >> 0) & 0xff);
-        //break down Z data
-        unsigned char hiZ = ((((unsigned int) (aaReal.z)) >> 8) & 0xff);
-        unsigned char loZ = ((((unsigned int) (aaReal.z)) >> 0) & 0xff);
-
-        //Create package to send over CAN
-        unsigned char CANbuf[8] = {hiDir, loDir, hiX, loX, hiY, loY, hiZ, loZ};
-
-        //Send data over CAN
-        if (millis() - lastTime > 50) {
-          lastTime = millis();
-          CAN.sendMsgBuf(CAN_ID, 0, 8, CANbuf); //send out the package above to the bus and tell other devices this is a standard frame from 0x00.
-        } else {
-          Serial.println("No CAN message sent - time limit not exceded (this is okay)");
-        }
-
-        // blink LED to indicate activity
-        blinkState = !blinkState;
-        digitalWrite(LED_PIN, blinkState);
-    }
-}


Added arduino type for detection by the json gateway

--- MagnusCoreNeoPixel_v1.ino
+++ MagnusCoreNeoPixel_v1.ino
@@ -107,22 +107,30 @@
   if( collect_serial() )
   {
     // we have valid buffer of serial input
-    if( command[0] == 'e' || command[0] == 'E' )
-    {
+    switch (command[0]) {
+    case '*':
+        Serial.println("Magnus Resonators Node");
+    break;
+    case 'E':
+    case 'e':
       owner = enlightened;
       percent = getPercent(&command[1]);
-    }
-    else if( command[0] == 'r' || command[0] == 'R' )
-    {
+      break;
+    case 'R':
+    case 'r':
       owner = resistance;
       percent = getPercent(&command[1]);
-    }
-    else if( command[0] == 'n' || command[0] == 'N' )
-    {
+      break;
+    case 'n':
+    case 'N':
       owner = neutral;
       percent = 100;
-    }
+      break;
+    default:
+    Serial.println("?");
     //Serial.print((char *)command); Serial.print(" - ");Serial.print(command[0],DEC);Serial.print(": ");
+    //Serial.print("owner "); Serial.print(owner,DEC); Serial.print(", percent "); Serial.println(percent,DEC);
+  }    //Serial.print((char *)command); Serial.print(" - ");Serial.print(command[0],DEC);Serial.print(": ");
     //Serial.print("owner "); Serial.print(owner,DEC); Serial.print(", percent "); Serial.println(percent,DEC);
   }

@@ -163,4 +171,4 @@

 }

-
+


20190524 Fix some Bug

20190524 Fix some Bug

Port Error .... X_X

--- slides/20190510-Arduino/example/Main/Main.ino
+++ slides/20190510-Arduino/example/Main/Main.ino
@@ -5,9 +5,9 @@
 // DEBUG
 bool DEBUG = true;
 // Bluetooth
-#define KEY 9
-#define RXD 10
-#define TXD 11
+#define KEY 10
+#define RXD 11
+#define TXD 12
 #define MAX_BTCMDLEN 128 // the maximum received command length from an Android system (over the bluetooth)
 SoftwareSerial BTSerial(RXD, TXD);
 // Servo motor


Restores playMusic that was accidentally committed disabled.

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -102,7 +102,6 @@

 void playMusic(byte song) {
-  return;
     if (! soundOn) {
       return;
     }


mem usage info

mem usage info

--- dorm-leds.ino
+++ dorm-leds.ino
@@ -68,6 +68,10 @@
 	Serial.begin(115200);
 	Serial.println(F("Initializing..."));

+	// starting available memory
+	Serial.print(freeMemory());
+	Serial.println(F(" bytes of free SRAM."));
+
 	// random seed
 	Serial.println(F("Generating random seed..."));
 	randomSeed(analogRead(RAND_SEED_ANALOG_NOISE_PORT));
@@ -104,6 +108,8 @@
 	init_timing();

 	Serial.println(F("System Initialized."));
+	Serial.print(freeMemory());
+	Serial.println(F(" bytes of free SRAM."));
 }

 // the loop function runs over and over again forever


add api for race director software

add api for race director software

--- Arduino/chorus_rf_laptimer/chorus_rf_laptimer.ino
+++ Arduino/chorus_rf_laptimer/chorus_rf_laptimer.ino
@@ -38,7 +38,7 @@
     remove already existing items from queue
 */

-#define API_VERSION 2 // version number to be increased with each API change (int16)
+#define API_VERSION 3 // version number to be increased with each API change (int16)

 // #define DEBUG

@@ -67,6 +67,7 @@

 // input control byte constants
 #define CONTROL_START_RACE      'R'
+#define CONTROL_START_RACE_ABS  'P' // race with absolute laps timing
 #define CONTROL_END_RACE        'r'
 #define CONTROL_DEC_MIN_LAP     'm'
 #define CONTROL_INC_MIN_LAP     'M'
@@ -177,6 +178,7 @@

 //----- Lap timings--------------------------------
 uint32_t lastMilliseconds = 0;
+uint32_t raceStartTime = 0;
 #define MIN_MIN_LAP_TIME 1 //seconds
 #define MAX_MIN_LAP_TIME 60 //seconds
 uint8_t minLapTime = 5; //seconds
@@ -196,6 +198,7 @@
 uint8_t channelIndex = 0;
 uint8_t bandIndex = 0;
 uint8_t isRaceStarted = 0;
+uint8_t raceType = 0; // type 1: lap times are counted as absolute for each lap; type 2: lap times are relative to the race start (sum of previous absolute lap times);
 uint8_t isSoundEnabled = 1;
 uint8_t isConfigured = 0; //changes to 1 if any input changes the state of the device. it will mean that externally stored preferences should not be applied
 uint8_t rssiMonitor = 0;
@@ -276,7 +279,7 @@
                 gen_rising_edge(pinRaspiInt);  //generate interrupt for EasyRaceLapTimer software

                 uint32_t now = millis();
-                uint32_t diff = now - lastMilliseconds;
+                uint32_t diff = now - lastMilliseconds; //time diff with the last lap (or with the race start)
                 if (timeCalibrationConst) {
                     diff = diff + (int32_t)diff/timeCalibrationConst;
                 }
@@ -284,7 +287,17 @@
                     if (diff > minLapTime*1000 || (shouldSkipFirstLap && newLapIndex == 0)) { // if minLapTime haven't passed since last lap, then it's probably false alarm
                         digitalLow(led);
                         if (newLapIndex < MAX_LAPS-1) { // log time only if there are slots available
-                            lapTimes[newLapIndex] = diff;
+                            if (raceType == 1) {
+                                // for the raceType 1 count time spent for each lap
+                                lapTimes[newLapIndex] = diff;
+                            } else {
+                                // for the raceType 2 count times relative to the race start (ever-growing with each new lap within the race)
+                                uint32_t diffStart = now - raceStartTime;
+                                if (timeCalibrationConst) {
+                                    diffStart = diffStart + (int32_t)diffStart/timeCalibrationConst;
+                                }
+                                lapTimes[newLapIndex] = diffStart;
+                            }
                             newLapIndex++;
                             lastLapsNotSent++;
                             addToSendQueue(SEND_LAST_LAPTIMES);
@@ -585,12 +598,25 @@
     } else {
         switch (controlByte) {
             case CONTROL_START_RACE: // start race
-                lastMilliseconds = millis();
+                raceStartTime = millis();
+                lastMilliseconds = raceStartTime;
                 DEBUG_CODE(
                     digitalHigh(serialTimerPin);
                 );
                 newLapIndex = 0;
                 isRaceStarted = 1;
+                raceType = 1;
+                allowEdgeGeneration = 0;
+                playStartRaceTones();
+                addToSendQueue(SEND_RACE_STATE);
+                isConfigured = 1;
+                break;
+            case CONTROL_START_RACE_ABS: // start race with absolute laps timing
+                raceStartTime = millis();
+                lastMilliseconds = raceStartTime;
+                newLapIndex = 0;
+                isRaceStarted = 1;
+                raceType = 2;
                 allowEdgeGeneration = 0;
                 playStartRaceTones();
                 addToSendQueue(SEND_RACE_STATE);


final acceleration test

final acceleration test

--- longboard-ctl.ino
+++ longboard-ctl.ino
@@ -31,14 +31,14 @@
 #define AccelerationRange MMA_RANGE_2G
 #define AccelerationDataRate MMA_12_5hz
 #define AccelerometerNewDataInterrupt 1
-// Filter for
-#define AccelerometerSoftLPFilter 1
-
-
-
-#if AccelerometerSoftLPFilter
+// Software Filter for acceleration
+#define AccelerometerSoftFilter 1
+
+
+
+#if AccelerometerSoftFilter
 #include <FilterOnePole.h>
-#define LowpassFreq 0.005
+#define LowpassFreq 0.006
 auto lpFilter = FilterOnePole( LOWPASS, LowpassFreq );
 #endif

@@ -96,7 +96,7 @@
     float x, y, z;
     mma.getAcceleration(&x, &y, &z);
     lastAccValue = x;
-#if AccelerometerSoftLPFilter
+#if AccelerometerSoftFilter
     lpFilter.input(x);
 #endif

@@ -145,14 +145,15 @@
     float x = getUnfilteredXAcc();

     if (abs(x) < ZeroResetCounterEps)
-        zeroResetCounter < MaxZeroCounter ? ++zeroResetCounter : 0 ;
+        zeroResetCounter +=
+            (zeroResetCounter < MaxZeroCounter) ? 2 : 0 ;
     else
         zeroResetCounter = (float) zeroResetCounter * 0.4;

     Bluetooth.print('E');
     Bluetooth.print(x*1000);
     Bluetooth.print(',');
-#if AccelerometerSoftLPFilter
+#if AccelerometerSoftFilter
     lpFilter.input(x);
     x = lpFilter.output();
 #endif


Removed overly complex example

Removed overly complex example


Remove lcd_advanced_nav example

Remove lcd_advanced_nav example

The example quality was quite low and the serial_nav example covers most
of the functionality.

--- examples/lcd_advanced_nav/lcd_advanced_nav.ino
+++ examples/lcd_advanced_nav/lcd_advanced_nav.ino
@@ -1,253 +0,0 @@
-/*
- * lcd_advanced_nav.ino - Example code using the menu system library
- *
- * This example shows using the menu system with a 16x2 LCD display
- * (controled over serial).
- *
- * Copyright (c) 2015 arduino-menusystem
- * Licensed under the MIT license (see LICENSE)
- */
-
-#include <MenuSystem.h>
-#include <LiquidCrystal.h>
-
-// Menu variables
-MenuSystem ms;
-Menu mm("Main Menu");
-MenuItem mm_mi1("Read Analog 0 A0");
-MenuItem mm_mi2("Blink led");
-Menu mu1("Date & Time");
-MenuItem mu1_mi1("Show current");
-MenuItem mu1_mi2("Set");
-MenuItem mu1_mi3("Go back");
-
-/*
-The LCD circuit:
- * LCD RS pin to digital pin 8
- * LCD Enable pin to digital pin 9
- * LCD D4 pin to digital pin 4
- * LCD D5 pin to digital pin 5
- * LCD D6 pin to digital pin 6
- * LCD D7 pin to digital pin 7
- * LCD R/W pin to ground
- */
-// initialize the library with the numbers of the interface pins
-LiquidCrystal lcd(8     ,     9 ,      4 ,      5 ,      6 ,      7 );
-
-//Example related
-#define SELECTED_DISPLAY_DELAY 1500
-// menuSelected:  State var that indicates that a menu item has been
-//                selected. The plan is to update acordingly the LCD
-//                if we want to use the display to other thing
-//                like set up a variable (show on this example with time)
-bool menuSelected = false; // no menu item has been selected
-bool commandReceived = false;// no command has been received (Seria, button, etc)
-enum setMenuSelected_Type {
-  DATETIME, OTHER }; // this enum is in case we want to expand this example
-setMenuSelected_Type setMenu;
-byte cursorPosition;
-String setString;
-
-int led = 41; // connect a led+resistor on pin 41 or change this number to 13 to use default arduino led on board
-int ledState = LOW;
-String dateTime = "2012-12-02 17:55";
-
-// Menu callback functions
-void on_item1_selected(MenuItem* p_menu_item) {
-  lcd.setCursor(0,1);
-  lcd.print("Analog A0: ");
-  lcd.print(analogRead(A0));
-  delay(SELECTED_DISPLAY_DELAY);
-}
-
-void on_item2_selected(MenuItem* p_menu_item) {
-  ledState = !ledState;
-  digitalWrite(led,ledState);
-  lcd.setCursor(0,1);
-  lcd.print("Led state: ");
-  if(ledState)
-    lcd.print("ON");
-  else
-    lcd.print("OFF");
-  delay(SELECTED_DISPLAY_DELAY);
-}
-// on_back_selected is usefull if you don't have a button to make the back function
-void on_back_selected(MenuItem* p_menu_item) {
-  ms.back();
-}
-void on_time_show_selected(MenuItem* p_menu_item) {
-  lcd.setCursor(0,1);
-  lcd.print(dateTime);
-  delay(SELECTED_DISPLAY_DELAY);
-}
-void on_time_set_selected(MenuItem* p_menu_item)
-{
-  setString = dateTime;
-  lcd.setCursor(0,1);
-  lcd.print(setString);
-  cursorPosition = 0;
-  lcd.setCursor(cursorPosition,1);
-  lcd.blink();
-  setMenu = DATETIME;
-  menuSelected = true;
-
-}
-
-// Standard arduino functions
-
-void setup() {
-  Serial.begin(9600);
-  pinMode(led,OUTPUT);
-  lcd.begin(16, 2);
-  serialPrintHelp();
-  Serial.println("Setting up the menu.");
-
-  // init example vars
-  menuSelected = false;
-
-  // Menu setup
-  /*
-  Menu Structure:
-   -Analog read
-   -Led blink
-   -Date & Time
-   --Show current
-   --Set
-   --Back
-
-   */
-  mm.add_item(&mm_mi1, &on_item1_selected);
-  mm.add_item(&mm_mi2, &on_item2_selected);
-  mm.add_menu(&mu1);
-  mu1.add_item(&mu1_mi1, &on_time_show_selected);
-  mu1.add_item(&mu1_mi2, &on_time_set_selected);
-  mu1.add_item(&mu1_mi3, &on_back_selected);
-  ms.set_root_menu(&mm);
-  Serial.println("Menu setted.");
-  displayMenu();
-}
-
-void loop() {
-  // Handle serial commands
-  serialHandler();
-  //SELECTED_DISPLAY_DELAY
-  updateDisplay();
-
-}
-
-void displayMenu() {
-  lcd.clear();
-  lcd.setCursor(0,0);
-
-  // Display the menu
-  Menu const* cp_menu = ms.get_current_menu();
-  lcd.print(cp_menu->get_current_component()->get_name());
-}
-
-void updateDisplay() {
-  if(!menuSelected && commandReceived) {
-    displayMenu();
-    commandReceived = false;
-  }
-  else if (commandReceived) {
-    switch(setMenu) {
-    case DATETIME:
-
-      break;
-      // add new cases as you add set menus (don't forget to add the corresponding enum)
-    default:
-      break;
-    }
-  }
-}
-
-void serialHandler() {
-  char inChar;
-  if((inChar = Serial.read())>0) {
-
-    switch (inChar) {
-    case 'w': // Previus item
-      if(!menuSelected)
-        ms.prev();
-      else {
-        if(setMenu == DATETIME) {
-          if(setString[cursorPosition]>47 && setString[cursorPosition]<57)
-            setString[cursorPosition]++;
-          lcd.write(setString[cursorPosition]);
-          lcd.setCursor(cursorPosition,1);
-        }
-      }
-      break;
-    case 's': // Next item
-      if(!menuSelected)
-        ms.next();
-      else {
-        if(setMenu == DATETIME) {
-          if(setString[cursorPosition]>48 && setString[cursorPosition]<58)
-            setString[cursorPosition]--;
-          lcd.write(setString[cursorPosition]);
-          lcd.setCursor(cursorPosition,1);
-          }
-      }
-      break;
-    case 'a': // Back presed
-      if(!menuSelected)
-        ms.back();
-      else if(cursorPosition>0)
-        lcd.setCursor(--cursorPosition,1);
-      break;
-    case 'd': // Select presed
-      if(!menuSelected)
-        ms.select();
-      else if(cursorPosition<15)
-        lcd.setCursor(++cursorPosition,1);
-      break;
-    case 'e': // Cancel (clear menuSelected) For debug purpose
-      menuSelected = false;
-      break;
-    case 'q': // Set
-      if(menuSelected) {
-        if(setMenu == DATETIME) {
-          dateTime = setString;
-          lcd.setCursor(0,1);
-          lcd.print("Time seted      ");
-          delay(SELECTED_DISPLAY_DELAY);
-          menuSelected = false;
-        }
-      lcd.noBlink();
-      }
-    case '?':
-    case 'h': // Display help
-      serialPrintHelp();
-      break;
-    default:
-      break;
-    }
-    commandReceived = true;
-  }
-}
-
-
-void serialPrintHelp() {
-  Serial.println("***************");
-  Serial.println("w: go to previus item (up)");
-  Serial.println("s: go to next item (down)");
-  Serial.println("a: go back (right)");
-  Serial.println("d: select \"selected\" item (left)");
-  Serial.println("q: set (no meaning while moving");
-  Serial.println("   over the menu, see LCDNav");
-  Serial.println("   example if you get confuse");
-  Serial.println("e: erase menuSelected flag");
-  Serial.println("   can be used as a cancel button");
-  Serial.println("?: print this help");
-  Serial.println("h: print this help");
-  Serial.println("***************");
-
-}
-
-
-
-
-
-
-


Update string return

Update string return

--- arduino-app/arduino-app.ino
+++ arduino-app/arduino-app.ino
@@ -92,7 +92,7 @@
 {
   // buttons
   getButtonsState();
-
+
   // RFID
   getRFIDModuleValue();

@@ -124,23 +124,23 @@
   int button4 = digitalRead(PIN_BUTTON_4);

   // boutton 1
-  if (button1 == HIGH) {
-    Serial.println("[ BUTTON ]:[ B1 ]");
-  }
-
+  if (button1 == HIGH) {
+    Serial.println("BUTTON --> B1");
+  }
+
   // boutton 2
-  if (button2 == HIGH) {
-    Serial.println("[ BUTTON ]:[ B2 ]");
+  if (button2 == HIGH) {
+    Serial.println("BUTTON --> B2");
   }

   // boutton 3
-  if (button3 == HIGH) {
-    Serial.println("[ BUTTON ]:[ B3 ]");
+  if (button3 == HIGH) {
+    Serial.println("BUTTON --> B3");
   }

   // boutton 4
-  if (button4 == HIGH) {
-    Serial.println("[ BUTTON ]:[ B4 ]");
+  if (button4 == HIGH) {
+    Serial.println("BUTTON --> B4");
   }
 }

@@ -158,7 +158,7 @@
 void getPotentiometerValue()
 {
   int value;
-
+
   // récupére la valeur du potentiometre
   value = analogRead(PIN_POTENTIOMETER);

@@ -168,9 +168,8 @@
   // retourner la valeur du potentiomètre
   // pour la traiter avec le RaspberryPI
   if (potentiometer < value -5 || potentiometer > value + 5) {
-    Serial.print("[ POTENTIOMETER ]:[ ");
-    Serial.print(value);
-    Serial.println(" ]");
+    Serial.print("POTENTIOMETER --> ");
+    Serial.println(value);
     potentiometer = value;
   }
 }
@@ -196,9 +195,8 @@
   tag=tag.substring(1,13);

   while(tag.length() > 0) {
-    Serial.print("[ RFID ]:[ ");
-    Serial.print(tag);
-    Serial.println(" ]");
+    Serial.print("RFID --> ");
+    Serial.println(tag);
     tag = "";
   }
   delay(500);
@@ -212,7 +210,7 @@
  */

 /**
- * Retourner la valeur de l'accélèromètre afin
+ * Retourner la valeur de l'accélèromètre afin
  * qu'elle puisse être traitée par le RaspberryPI
  */
  void getAccelerometreValue()
@@ -224,13 +222,12 @@

    // retourner la valeur de l'accélèromètre
    // pour la traiter avec le RaspberryPI
-   Serial.print("[ ACCELEROMETER ]:[ ");
+   Serial.print("ACCELEROMETER --> ");
    Serial.print(x);
    Serial.print(",");
    Serial.print(y);
    Serial.print(",");
-   Serial.print(z);
-   Serial.println(" ]");
+   Serial.println(z);
  }

 /**
@@ -445,4 +442,3 @@
     delay(params[0]);
   }
 }
-


connected the wifly. ePIR sends signals to the server. the led receives signals from the server. first step: both on one wifly. next: use two wiflys, one as sensor and one as signal.

--- epir/epir.ino
+++ epir/epir.ino
@@ -1,47 +1,81 @@
+#include "WiFly.h"
+
 /*
 *
 * occupy ping pong
 *
-* sven kraeuter for
-*
-* makers & co.
+* sven kraeuter for makers & co. and miami ad school europe
 *
 * http://makersand.co
 *
 * code inspired by http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287148367
 *
+* wifly library for arduino 1.0: https://github.com/timr/WiFly-Shield
+*
 */

-byte calibrationTime = 30;
+// Wifi parameters
+char passphrase[] = "ENTER PASSPHRASE";
+char ssid[] = "ENTER SSID";
+
+byte calibrationTime = 15;

 long unsigned int pause = 1000;

 byte motionCounter = 0;

+boolean occupied = false;
+
 byte pirPin = 2;
 byte ledPin = 9;

+char* USERAGENT="occupy-ping-pong/alpha";
+char* HOST="YOUR-SERVER-ADDRESS.herokuapp.com";
+char* RESOURCE="/status.json";
+
+Client client("http://YOUR-SERVER-ADDRESS.herokuapp.com", 80);
+
 void setup(){
- Serial.begin(9600);
- pinMode(pirPin, INPUT);
- pinMode(ledPin, OUTPUT);
- digitalWrite(pirPin, LOW);
+  //------------------------ wifly setup ----------------------------------
+  Serial.begin(9600);
+
+  WiFly.begin();
+
+  if (WiFly.join(ssid, passphrase)) {
+    Serial.println("associted with wifly network.");
+  }
+  else {
+    Serial.println("Association failed.");
+    while (1) {
+      // Hang on failure.
+    }
+  }
+
+  //------------------------------ epir setup ----------------------------
+  pinMode(pirPin, INPUT);
+  pinMode(ledPin, OUTPUT);
+  digitalWrite(pirPin, LOW);

- Serial.print("calibrating sensor ");
-   for(int i = 0; i < calibrationTime; i++){
-   Serial.print(".");
-   delay(1000);
-   }
-   Serial.println(" done");
-   Serial.println("SENSOR ACTIVE");
-   delay(50);
- }
+  Serial.print("calibrating sensor ");
+    for(int i = 0; i < calibrationTime; i++){
+    Serial.print(".");
+    delay(1000);
+  }
+  Serial.println(" done");
+  Serial.println("SENSOR ACTIVE");
+  delay(50);
+}

 void loop(){
+  //------------------- ePIR sensor part ---------------------------------------
   if(digitalRead(pirPin) == HIGH){
     Serial.println("Continuous motion ended.");
     motionCounter = 0;
-    digitalWrite(ledPin, LOW);
+    //--------- send status to server
+    connectClient(generateHttpPut(HOST, RESOURCE, '0'));
+    Serial.println();
+    Serial.println("disconnecting.");
+    client.stop();
   }
   else if(digitalRead(pirPin) == LOW){
     motionCounter += 1;
@@ -49,9 +83,68 @@
     Serial.print(motionCounter);
     Serial.println(" times in a row.");
   }
-  if(motionCounter > 5){
+  if(motionCounter > 4){
     Serial.println("Continuous motion detected!");
-    digitalWrite(ledPin, HIGH);
+    //--------- send status to server
+    connectClient(generateHttpPut(HOST, RESOURCE, '1'));
+    Serial.println();
+    Serial.println("disconnecting.");
+    client.stop();
   }
-  delay(pause);
+
+  //-------------------- signalling led part -------------------------------------
+
+  connectClient("GET http://YOUR-SERVER-ADDRESS.herokuapp.com/status.json HTTP/1.0\r\n");
+
+  if (client.available()) {
+    // receiving status from server
+    if(client.find("\"occupied\": ")){
+      char state[1];
+      client.readBytes(state, 1);
+      if(atoi(state) == 1){
+        Serial.println("PING PONG OCCUPIED");
+        digitalWrite(ledPin, HIGH);
+      }
+      else if(atoi(state) == 0) {
+        Serial.println("PING PONG VACANT");
+        digitalWrite(ledPin, LOW);
+      }
+    }
+    if (!client.connected()) {
+      Serial.println();
+      Serial.println("disconnecting.");
+      client.stop();
+    }
+
+  }
+
+
+  delay(pause);
 }
+
+char* generateHttpPut(char* host, char* resource, char occupied){
+  char postString[255];
+  sprintf(postString, "PUT %s HTTP/1.1\r\nUser-Agent: %s\r\nHost: %s\r\nContent-Length: 15\r\nContent-Type: application/json\r\n\r\n{\"occupied\": %c}"
+  , resource, USERAGENT, host, occupied);
+
+  return postString;
+}
+
+void connectClient(char* http_request){
+
+
+  if (client.connect()) {
+    Serial.println("connected");
+    Serial.println(http_request);
+    client.print(http_request);
+    client.println();
+  } else {
+    Serial.println("connection failed");
+  }
+
+  Serial.print("Waiting for the response...");
+  while(!client.available()){
+    Serial.print('.');
+  }
+  Serial.println();
+}


Added debug print relaying of BLE debug messages

--- Sensorizer.ino
+++ Sensorizer.ino
@@ -144,7 +144,7 @@
   delay(6); // ~5ms to warm up and boot

   // TODO: uncomment this to implement reprograming the BLE firmware via its HCI UART
-  // Serial.begin(57600);
+  Serial.begin(115200);

   #endif

@@ -222,6 +222,17 @@
 #endif
   }

+
+  // relay all debug messages from BLE
+#if ENABLE_DEBUG_PRINTING && defined(BLE_RESET_PIN)
+
+  while(Serial.available()) {
+    SerialUSB.write(Serial.read());
+  }
+
+#endif
+
+
 #if ENABLE_LOOPER
   // loop that shit!
   server->tick();


[AudioDSP] mimic delay between button scans


Added support for flashing external led.

--- Sensors/Sensor-Main.ino
+++ Sensors/Sensor-Main.ino
@@ -3,6 +3,7 @@
 #include "Wire.h"

 //Definitions
+int ledPin = 5;
 #define DS1307_ADDRESS 0x86;//Need to get updated I2C Address
 byte zero = 0x00; //Needed as a workaround for issue #537 RTC Support
 File testFile;
@@ -13,15 +14,26 @@
 	Serial.print("Initializing SD card on pin 10...");
 	pinMode(10, OUTPUT);
 	if (!SD.begin(10)) {
-    	Serial.println("SD Initialization Failed!");
-    	return;
+		Serial.println("SD Initialization Failed!");
+		return;
 	}
 	Serial.println("SD Initialization Done.");
+
+	pinMode(ledPin, OUTPUT);

 }

 void loop(){
+
+	/*This is for flashing the leds
+	digitalWrite(ledPin, HIGH);
+	delay(10);
+	digitalWrite(ledPin, LOW);
+	delay(10);
+	*/
+
 	/*This is testing writing to a file on the sdcard
+
 	testFile = SD.open("test.txt", FILE_WRITE);

 	if (testFile) {
@@ -38,7 +50,7 @@
   	/*
   	//This is for testing the RTC and printing to serial
   	Wire.beginTransmission(DS1307_ADDRESS);
- 	Wire.write(zero); //Workaround
+ 	Wire.write(zero); //Workaround
    	Wire.endTransmission();

 	Wire.requestFrom(DS1307_ADDRESS, 7);
@@ -64,4 +76,4 @@
   	Serial.print(":");
   	Serial.print(second);
   	*/
-}+}


changed enable pins

changed enable pins

--- arduino/src/mpu9250_basicDMP/mpu9250_basicDMP.ino
+++ arduino/src/mpu9250_basicDMP/mpu9250_basicDMP.ino
@@ -5,7 +5,8 @@

 //#define DMP_DEBUG

-const byte ENABLE_PIN = 7;
+const byte ENABLE_PIN = 3;
+const byte RECEIVE_PIN = 4;
 const byte SLAVE_ID = 1;
 union float2bytes { float f; byte b[sizeof(float)]; };
 float2bytes ypr0;
@@ -40,8 +41,10 @@
     Fastwire::setup(400,0);
     Serial.begin(57600);
     ret = mympu_open(100);
-    pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
+    pinMode (ENABLE_PIN, OUTPUT);
+    pinMode (RECEIVE_PIN, OUTPUT);// driver output enable
     digitalWrite (ENABLE_PIN, LOW);
+    digitalWrite (RECEIVE_PIN, LOW);

 #ifdef DMP_DEBUG
     Serial.print("MPU init: "); Serial.println(ret);
@@ -124,10 +127,12 @@
 		  };

 		  digitalWrite (ENABLE_PIN, HIGH);  // enable sending
+		  digitalWrite (RECEIVE_PIN, HIGH);  // enable sending
 		  delay(1);
 		  sendMsg (fWrite, msg, sizeof msg);
 		  Serial.flush();
 		  digitalWrite (ENABLE_PIN, LOW);  // disable sending
+		  digitalWrite (RECEIVE_PIN, LOW);  // disable sending
 		  //delay (100);

      }


 Fire = A or B buttons and invert directions for initials

Allow the use of either A or B for FIRE and make the directions more
logical when entering initials.

--- examples/ArduBreakout/ArduBreakout.ino
+++ examples/ArduBreakout/ArduBreakout.ino
@@ -230,7 +230,7 @@
     xb=xPaddle + 5;

     //Release ball if FIRE pressed
-    pad3 = arduboy.pressed(B_BUTTON);
+    pad3 = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
     if (pad3 == 1 && oldpad3 == 0)
     {
       released=true;
@@ -308,7 +308,7 @@
   {
     delay(150);
     //Unpause if FIRE is pressed
-    pad2 = arduboy.pressed(B_BUTTON);
+    pad2 = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
     if (pad2 > 1 && oldpad2 == 0 && released)
     {
         arduboy.fillRect(52, 45, 30, 11, 0);
@@ -367,7 +367,7 @@
   for(int i = 0; i < n; i++)
   {
     delay(15);
-    pad = arduboy.pressed(B_BUTTON);
+    pad = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
     if(pad == 1 && oldpad == 0)
     {
       oldpad3 = 1; //Forces pad loop 3 to run once
@@ -510,7 +510,7 @@
     arduboy.drawLine(56 + (index*8), 28, 56 + (index*8) + 6, 28, 1);
     delay(150);

-    if (arduboy.pressed(RIGHT_BUTTON))
+    if (arduboy.pressed(LEFT_BUTTON) || arduboy.pressed(B_BUTTON))
     {
       index--;
       if (index < 0)
@@ -522,7 +522,7 @@
       }
     }

-    if (arduboy.pressed(LEFT_BUTTON))
+    if (arduboy.pressed(RIGHT_BUTTON))
     {
       index++;
       if (index > 2)
@@ -533,7 +533,7 @@
       }
     }

-    if (arduboy.pressed(UP_BUTTON))
+    if (arduboy.pressed(DOWN_BUTTON))
     {
       initials[index]++;
       arduboy.tunes.tone(523, 250);
@@ -556,7 +556,7 @@
       }
     }

-    if (arduboy.pressed(DOWN_BUTTON))
+    if (arduboy.pressed(UP_BUTTON))
     {
       initials[index]--;
       arduboy.tunes.tone(523, 250);
@@ -574,7 +574,7 @@
       }
     }

-    if (arduboy.pressed(B_BUTTON))
+    if (arduboy.pressed(A_BUTTON))
     {
       if (index < 2)
       {
@@ -703,7 +703,7 @@
     drawPaddle();

     //Pause game if FIRE pressed
-    pad = arduboy.pressed(B_BUTTON);
+    pad = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);

     if(pad >1 && oldpad==0 && released)
     {


add commented wdt_reset to input example

--- examples/DMXInputTest/DMXInputTest.ino
+++ examples/DMXInputTest/DMXInputTest.ino
@@ -43,4 +43,5 @@
     //ESP8266 PWM is 10bit 0-1024
     analogWrite(14,2*ESP8266DMX.getSlot(1));
   }
+  //wdt_reset();
 }


Fix: default board not compiling

Fix: default board not compiling

--- examples/DefaultBoard/DefaultBoard.ino
+++ examples/DefaultBoard/DefaultBoard.ino
@@ -14,7 +14,7 @@
   board.begin();

   // Notify the board we want to use accel data
-  board.curAccelMode = board.ACCEL_MODE_ON;
+  board.useAccel = true;
 }

 void loop() {


removal of old commented code

removal of old commented code

--- WVO_Controller_0.6.3/WVO_Controller_0.6.3.ino
+++ WVO_Controller_0.6.3/WVO_Controller_0.6.3.ino
@@ -852,18 +852,6 @@

 void homebutton()						// function that draws the home button
 {
-  // home icon (rotated right now)
-  //Tft.drawLine(219, 280, 200, 299, WHITE);
-  //Tft.drawLine(200, 300, 204, 304, WHITE);
-  //Tft.drawLine(203, 304, 200, 304, WHITE);
-  //Tft.drawLine(200, 305, 200, 307, WHITE);
-  //Tft.drawLine(200, 308, 208, 308, WHITE);
-  //Tft.drawLine(209, 309, 219, 319, WHITE);
-  //Tft.drawLine(219, 281, 219, 283, WHITE);
-  //Tft.drawLine(219, 316, 219, 318, WHITE);
-  //Tft.drawRectangle(219, 284, 21, 32, WHITE);
-  //Tft.drawRectangle(225, 295, 15, 10, WHITE);
-
   Tft.drawRectangle(203, 300, 32, 19, WHITE);
   Tft.drawRectangle(214, 304, 10, 15, WHITE);
   Tft.drawRectangle(207, 282, 4, 10, WHITE);


display reply on LCD in proc_bye()

display reply on LCD in proc_bye()

--- esp8266_160220_BYOP.ino
+++ esp8266_160220_BYOP.ino
@@ -6,6 +6,8 @@

 /*
+ * v0.12 2016 Feb. 20
+ *  - display reply on LCD in proc_bye()
  * v0.11 2016 Feb 20
  *  - display "ready" on 8x2 LCD just after power on
  *  - add [esp8266_160217_AQM0802.ino] to display characters on 8x2 LCD
@@ -134,7 +136,12 @@

 bool proc_bye(String csvline)
 {
-  Serial.println(kCmdList[CMD_BYE] + "," + g_owner.nickName);
+  String reply = kCmdList[CMD_BYE] + "," + g_owner.nickName;
+
+  Serial.println(reply);
+
+  AQM0802_Clear();
+  AQM0802_PutMessage(reply, /* x_st1=*/1, /* y_st1=*/1);
 }


Updates animation.ino to use new SSD1306 API

--- animations.ino
+++ animations.ino
@@ -9,18 +9,16 @@
     NULL
   };

-  oled.setBufferRegion(0, 16, 128, 32);
+  oled.setBufferRegion(SSD1306_REGION_MID);
   uint8_t w = 128, h=32;

   for (uint8_t idx = 0; sequence[idx] != NULL; ++idx) {
     if (sequence[idx+1] == NULL) {
-      oled.drawString(sequence[idx-1], (w*5)/2, h/2-FONT_Y/2, 1, COLOR_BLACK);
-      oled.uploadBuffer();
+      oled.drawString(sequence[idx-1], (w-FONT_SPACE*6)/2, h/2-FONT_Y/2, 1, COLOR_BLACK);
     }

     oled.clearBuffer();
-    oled.drawString(sequence[idx], (w-FONT_X*5)/2, h/2-FONT_Y/2, 1, COLOR_BLUE);
-    oled.uploadBuffer();
+    oled.drawString(sequence[idx], (w-FONT_SPACE*6)/2, h/2-FONT_Y/2, 1, COLOR_BLUE);
     delay(200);
   }
   delay(1000);


Serial Command test

Serial Command test

--- XV_Lidar_Controller.ino
+++ XV_Lidar_Controller.ino
@@ -12,6 +12,7 @@
 #include <PID.h>
 #include <EEPROM.h>
 #include "EEPROMAnything.h"
+#include <SerialCommand.h>

 #define DEBUG_MOTOR_RPM false

@@ -31,11 +32,9 @@

 const byte EEPROM_ID = 0x99;  // used to validate EEPROM initialized

-
 double pwm_val = xv_config.pwm_min;  // start slow
 double pwm_last;
 double motor_rpm;
-

 PID myPID(&motor_rpm, &pwm_val, &xv_config.rpm_setpoint,xv_config.Kp,xv_config.Ki,xv_config.Kd, DIRECT);

@@ -47,6 +46,7 @@
 unsigned char motor_rph_low_byte = 0;
 int motor_rph = 0;

+SerialCommand sCmd;

 void setup() {
   EEPROM_readAnything(0, xv_config);
@@ -63,9 +63,13 @@
   myPID.SetOutputLimits(xv_config.pwm_min,xv_config.pwm_max);
   myPID.SetSampleTime(20);
   myPID.SetMode(AUTOMATIC);
+
+  initSerialCommands();
 }

 void loop() {
+  sCmd.readSerial();  // check for incoming serial commands
+
   // read byte from LIDAR and retransmit to USB
   if (Serial1.available() > 0) {
     inByte = Serial1.read();  // get incoming byte:
@@ -161,3 +165,12 @@
   EEPROM_writeAnything(0, xv_config);
 }

+void initSerialCommands() {
+  sCmd.addCommand("MOTOROFF",    motorOff);
+}
+
+void motorOff() {
+  myPID.SetMode(MANUAL);
+  Timer3.pwm(xv_config.motor_pwm_pin, 0);
+  pwm_last = 0;
+}


Removing unused variable in smc.ino.

Removing unused variable in smc.ino.

--- smc/smc.ino
+++ smc/smc.ino
@@ -30,9 +30,6 @@
   // Now the ESCs may have power.
 }

-int buffer[128];    // consistent with arduino's recive buffer.
-int index = 0;
-
 void loop() {
   if (Serial.available() > 0) {
     int percent = Serial.parseInt();


Added mode changing via screen-serial when in -ANY-MODE-

--- 00_Firmware/Firmware/Firmware.ino
+++ 00_Firmware/Firmware/Firmware.ino
@@ -5,7 +5,8 @@
 		CW - Christian Weichel
 		JV - John Vidler
 		MS - Matthias Schitthelm
-
+
+	v2.4 - JV - Moved serial buffer updates to a seperate call, serial now updated regardless of mode.
 	v2.3 - JH - Fixes to serial RGB colour display.
 	v2.2 - JH - Motor driver accumulator. Known bug which does not let it drive to the extents.
 	v2.1 - JH - Bug fixes to the 2.0, added stepper optimisation, decrunchified sync-pulse mode.
@@ -17,6 +18,27 @@
 	v1.2 - CW - Added LDR.h and LDR.cpp
 	v1.1 - CW + MS - Added cool stepper.
 	v1.0 - JH - First version, sync-pulse based control of RGB and Height
+
+
+	/------------------------\
+	| SCREEN SERIAL COMMANDS |
+ 	\------------------------/
+
+        Format: [Command][Parameter][X]
+        Each part is a single byte, and the last byte should always be ASCII 'X'.
+
+        When in serial mode:
+        [R][0-255][X] - Set red value
+        [G][0-255][X] - Set green value
+        [B][0-255][X] - Set blue value
+        [H][0-255][X] - Set height value
+
+        When in any mode:
+        [M][H][X] - Change to height mode
+        [M][Y][X] - Change to syncpulse mode
+        [M][S][X] - Change to serial command mode.
+
+
 */

 /* External and 3rd party libraries. */
@@ -1117,9 +1139,14 @@

 	// Attempt to read a serial bit from the screen.
 	screenSerialRead();
-	if( cmdBuffer[2] == 'X' )
+	if( cmdBuffer[2] == 'M' && cmdBuffer[2] == 'X' )
 	{
 		switch( cmdBuffer[1] )
+		{
+			case 'H': detectAndSetModeChange( EEMODE_HEIGHTONLY ); break;
+			case 'Y': detectAndSetModeChange( EEMODE_SYNCPULSE ); break;
+			case 'S': detectAndSetModeChange( EEMODE_SERIAL ); break;
+		}
 	}

 	// Detect which mode we are in.


removed incorrect file

removed incorrect file

--- Arduino/hardware/REV14/rn2483test/rn2483test.ino
+++ Arduino/hardware/REV14/rn2483test/rn2483test.ino
@@ -1,56 +0,0 @@
-uint8_t ch = 0;
-
-void setup() {
-  // put your setup code here, to run once:
-  Serial.begin(19200);
-  Serial.println("start");
-}
-
-void loop() {
-  // put your main code here, to run repeatedly:
-  uint8_t inBuf[64];
-  uint8_t outBuf[128];
-
-  for(uint8_t i = 0; i < sizeof(inBuf); i++) {
-    inBuf[i] = i + (ch * sizeof(inBuf));
-  }
-
-  Serial.print("ReturnVal: ");
-  Serial.println(getHex(inBuf, outBuf, sizeof(outBuf)));
-  for(uint8_t i = 0; i < sizeof(inBuf); i++) {
-    Serial.print(inBuf[i], HEX);
-  }
-  Serial.println();
-  Serial.write(outBuf, sizeof(outBuf));
-  Serial.println();
-  Serial.println();
-  ch++;
-  while (ch == 4) {}
-  delay(500);
-}
-
-bool getHex(const uint8_t *string, uint8_t *output, uint8_t outputLen)
-{
-  if((string || output) == NULL) return false; // check for null pointer
-    uint8_t counter = outputLen;
-    // convert to hex
-  while(counter) {
-    uint8_t highValue = *string >> 4;
-    uint8_t lowValue  = *string & 0x0f;
-    uint8_t temp;
-
-    temp = highValue;
-    if(temp <= 9) temp += '0';
-    else temp += ('A' - 10);
-    *output++ = temp;
-
-    temp = lowValue;
-    if(temp <= 9) temp += '0';
-    else temp += ('A'-10);
-    *output++ = temp;
-
-    string++;
-    counter -= 2;
-  }
-  return true;
-}


we also need to output the chopper value

--- examples/TMC262MotorTester/Serial.ino
+++ examples/TMC262MotorTester/Serial.ino
@@ -102,10 +102,23 @@
       Serial.print("xe,");
     }
     if (tmc262Stepper.isEnabled()) {
-      Serial.println("e1,");
-    }
-    else {
-      Serial.println("e0,");
+      Serial.print("e1,");
+    }
+    else {
+      Serial.print("e0,");
+    }
+    //write out the current chopper config
+    Serial.print("co");
+    Serial.print(t_off,DEC);
+    Serial.print(",cb");
+    Serial.print(t_blank,DEC);
+    if (chopperMode==0) {
+      Serial.print(",cs");
+      Serial.print(h_start,DEC);
+      Serial.print(",ce");
+      Serial.print(h_end,DEC);
+      Serial.print(",cd");
+      Serial.print(h_decrement,DEC);
     }
     Serial.println();
   }


minor update

minor update

--- linefollower/linefollower.ino
+++ linefollower/linefollower.ino
@@ -1,8 +1,6 @@
 // TODO:
 //
-//    * Weigh down axis
-//    * Build functions instead
-//    * Measure three times and use average
+//    If there are problems, add a value to turnDelay

 // Include libraries:
 #include <Adafruit_MotorShield.h>
@@ -19,7 +17,7 @@
 int rightSensor = 0;

 // This is the speed value, (0-255)
-int speedVal = 60; // 60 seem to be a good value
+int speedVal = 70; // 60 seem to be a good value
 //int turnSpeed = 60;
 int turnDelay = 0;
 // int containing last action: 0 starting value, 1 fwd, 2 steerLeft, 3 steerRight
@@ -27,6 +25,8 @@

 // Variable that works as a factor regulating the turn speed. i.e 1.8*spedVal = turnspeed
 float turnMulti = 1.7;
+
+int loopDelay = 0;

 myMotors Motors;   // Create Motors object
 mySensors Sensors; // Create Sensors object
@@ -48,24 +48,31 @@
   if((leftSensor == 0 && middleSensor == 1 && rightSensor == 0))
   {
     fwd();
+    Serial.println("Forward");
     lastAction = 1;
   }
   // if the right sensor is the only sensor that have the value 1, the bot need to compensate by turning right
   else if((leftSensor == 0 && middleSensor == 0 && rightSensor == 1))
   {
     steerLeft();
+    Serial.println("SteerLeft");
     lastAction = 2;
   }
   // if the left sensor is the only sensor that have the value 1, the bot need to compensate by turning left
   else if((leftSensor == 1 && middleSensor == 0 && rightSensor == 0))
   {
     steerRight();
+    Serial.println("SteerRight");
     lastAction = 3;
   }
   else
   {
-    stop();
+    if(lastAction == 1){fwd();Serial.println("Forward**");}
+    else if(lastAction == 2){steerLeft();Serial.println("SteerLeft**");}
+    else if(lastAction == 3){steerRight();Serial.println("SteerRight**");}
+    else {stop();Serial.println("Stop");}
   }
+  delay(loopDelay);
 }

 void readSensors(){
@@ -80,7 +87,8 @@
   Serial.print("Reflect 0: ");Serial.print(leftSensor);
   Serial.print("\tReflect 1: ");Serial.print(middleSensor);
   Serial.print("\tReflect 2: ");Serial.print(rightSensor);
-  Serial.print("\tMotor speed: ");Serial.println(speedVal);
+  Serial.print("\tMotor speed: ");Serial.print(speedVal);
+  Serial.print("\tAction: ");
 }

 //


Example line for static IP as discussed in https://github.com/toblum/McLighting/issues/187

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -319,6 +319,10 @@
   #endif

   WiFi.setSleepMode(WIFI_NONE_SLEEP);
+
+  // Uncomment if you want to set static IP
+  // Order is: IP, Gateway and Subnet
+  //wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,128), IPAddress(192,168,0,1), IPAddress(255,255,255,0));

   //fetches ssid and pass and tries to connect
   //if it does not connect it starts an access point with the specified name


it compiles! needs to be tested on hardware

--- twohbridge/twohbridge.ino
+++ twohbridge/twohbridge.ino
@@ -3,23 +3,26 @@
 int LBL = 11; //digital pin
 int LBR = 12; //digital pin

-int RTL = ; //PWM
-int RTR = ; //PWM
-int RBL = ; //digital pin
-int RBR = ; //digital pin
+int RTL = 6; //PWM
+int RTR = 9; //PWM
+int RBL = 8; //digital pin
+int RBR = 13; //digital pin

 int eyeballLeft = A1; //analog read
-int eyeballRight = ; //analog read
+int eyeballRight = A2; //analog read
+int Malp = 0;

 int brainLeft = 0;
 int brainRight = 0;

 void setup(){
+  //This is all of the pins controlling the left motor
   pinMode(LTL, OUTPUT);
   pinMode(LTR, OUTPUT);
   pinMode(LBL, OUTPUT);
   pinMode(LBR, OUTPUT);

+  //This is all of the pins controlling the right motor
   pinMode(RTL, OUTPUT);
   pinMode(RTR, OUTPUT);
   pinMode(RBL, OUTPUT);
@@ -40,12 +43,17 @@
   analogWrite(LTR, 0);
   analogWrite(RTL, 0);
   analogWrite(RTR, 0);
+
   //look around
   brainLeft = analogRead(eyeballLeft);
   brainRight = analogRead(eyeballRight);
+
   //map brain inputs to motor numbers
+  Malp = brainRight - brainLeft;
+
   //react
   if (brainLeft > 2 * brainRight){
+    //case 1: sharp left turn
     //safety
     digitalWrite(LBL, HIGH); //NPN
     digitalWrite(RBL, HIGH); //NPN
@@ -55,10 +63,11 @@
     digitalWrite(LBR, LOW); //NPN
     digitalWrite(RBR, LOW); //NPN
     analogWrite(LTL, brainRight); //PNP
-    analogWrite(RTL, Malp); //PNP how calculate Malp??? need testing
+    analogWrite(RTL, Malp); //how fast should this motor spin backwards
     delay(1000);
   }
-  elif (brainLeft > brainRight){
+  else if (brainLeft > brainRight){
+    //case 2: soft left turn
     //safety
     digitalWrite(LBL, HIGH); //NPN
     digitalWrite(RBR, HIGH); //NPN
@@ -71,7 +80,8 @@
     analogWrite(RTR, brainLeft); //PNP
     //delay(1000);
   }
-  elif (brainRight > 2 * brainLeft){
+  else if (brainRight > 2 * brainLeft){
+    //case 3: sharp turn to the right
     //safety
     digitalWrite(RBR, HIGH); //NPN
     digitalWrite(LBR, HIGH); //NPN
@@ -81,10 +91,11 @@
     digitalWrite(RBL, LOW); //NPN
     digitalWrite(LBL, LOW); //NPN
     analogWrite(RTR, brainRight); //PNP
-    analogWrite(LTR, Malp); //PNP how calculate Malp??? need testing
+    analogWrite(LTR, Malp); //how fast should this motor spin backwards?
     //delay(1000);
   }
-  elif (brainRight > brainLeft){
+  else if (brainRight > brainLeft){
+    //case 4: soft turn to the left
     //safety
     digitalWrite(RBL, HIGH); //NPN
     digitalWrite(LBR, HIGH); //NPN
@@ -97,6 +108,10 @@
     analogWrite(LTR, brainLeft); //PNP
     //delay(1000);
   }
+  else {
+  //delay(1);
+  }
+}


longer range

longer range

--- experiments/nrf24_test/nrf24_test.ino
+++ experiments/nrf24_test/nrf24_test.ino
@@ -30,7 +30,7 @@
 byte addresses[][6] = {"1Node","2Node"};

-byte role = 1; // 0 is receiver
+byte role = 0; // 0 is receiver
 unsigned long id = 0;

@@ -43,10 +43,12 @@

   // Setup and configure nrf24 radio
   radio.begin(); // Start up the radio
-  radio.setChannel(2);
-  radio.setPayloadSize(Nrf24Payload_SIZE);
-  radio.setAutoAck(1); // Ensure autoACK is enabled
-  radio.setRetries(3,15); //  delay between retries & number of retries
+  radio.setChannel(80);
+  radio.setPayloadSize(Nrf24Payload_SIZE);
+  // For the slower data rate (further range) see https://github.com/TMRh20/RF24/issues/98
+  radio.setDataRate(RF24_250KBPS);
+  radio.setAutoAck(false); // Ensure autoACK is enabled
+  radio.setRetries(3, 15); //  delay between retries & number of retries


Update based on latest code

Update based on latest code

--- push_start.ino
+++ push_start.ino
@@ -162,11 +162,14 @@
           case RUN: // Run -> Off or ACC
             //Serial.println(millis() - pressTime);
             // Transition back to ACC if button was held longer than HOLD_MS otherwise
-            // go to OFF
+            // go to OFF.
+            runState = OFF;
             if (millis() - pressTime > HOLD_MS) {
-              runState = ACC;
-            } else {
-              runState = OFF;
+              // In order for the engine to turn off to we need to transition to OFF,
+              //wait and then to ACC
+              setRelayState();
+              delay(500);
+              runState = ACC;
             }
             break;
         }


bug fixed

bug fixed

--- differential-thermostat/thermostat/thermostat.ino
+++ differential-thermostat/thermostat/thermostat.ino
@@ -26,7 +26,7 @@
  * Analog inputs attached to pins A0 through A5

- created 18 Dec 2009
+ created 18 Dec 2014
  by Davide Buldrini
  ideozone.it

@@ -120,8 +120,6 @@

 Thermostat thermostat;

-//unsigned long loopTimer
-

 void setup() {

@@ -177,6 +175,7 @@

   thermostat.onOvercome = &onOvercome; // callback function that fires when a sensor temperature overcome the minimum delta t
   thermostat.onNormal = &onNormal; // callback function that fires when the sensor value return within the minimum delta t
+  thermostat.onAllNormal = &onAllNormal; // callback function that fires when all sensors are within the minimum delta t

   loadSettings("set.txt");
 }


Update COM_SigFox.ino

Update COM_SigFox.ino

--- examples/Modules/COM_SigFox/COM_SigFox.ino
+++ examples/Modules/COM_SigFox/COM_SigFox.ino
@@ -20,9 +20,6 @@

   M5.begin();
   Serial2.begin(9600, SERIAL_8N1, rxPin, txPin);
-
-
-  Serial.begin(115200);

   delay(2000);
   getID();


ino sketch update

ino sketch update

--- examples/pseudopod-wifi/pseudopod-wifi.ino
+++ examples/pseudopod-wifi/pseudopod-wifi.ino
@@ -20,8 +20,8 @@
 #include "wifi-credentials.h"
 #define port 8111

-static const char uuid[]  = "b9944342-b8c7-4ca6-9d3e-074eb4706264";
-static const char token[] = "6d1f0dd95bf0dc0beb64ab7252152de6a2c08583";
+static const char uuid[]  = "ff12c403-04c7-4e63-9073-2e3b1f8e4450";
+static const char token[] = "28d2c24dfa0a5289799a345e683d570880a3bc41";

 int status = WL_IDLE_STATUS;
 WiFiClient conn;


Spark Core: Add delay before entering STOP mode to see serial print

Signed-off-by: Greg Meiste <8a8f45e57c045ec63dc7e56e5eda862ea8c7cd4f@gmail.com>

--- hw/spark/temp-alarm.ino
+++ hw/spark/temp-alarm.ino
@@ -65,6 +65,7 @@
         if (buttonReleaseMillis > 0) {
             if ((millis() - buttonReleaseMillis) >= BUTTON_PRESS_MS) {
                 SERIAL.println("Entering STOP mode");
+                delay(20);
                 Spark.sleep(BUTTON_PIN, FALLING);
             }
         } else {


Spark Core: Add defines to set which serial and baud rate to use

- Switch to Serial1
- Switch to higher 115200 baud

Signed-off-by: Greg Meiste <8a8f45e57c045ec63dc7e56e5eda862ea8c7cd4f@gmail.com>

--- hw/spark/temp-alarm.ino
+++ hw/spark/temp-alarm.ino
@@ -15,6 +15,9 @@
  */

 #include "Adafruit_DHT/Adafruit_DHT.h"
+
+#define SERIAL             Serial1
+#define SERIAL_BAUD        115200

 #define DHT_PIN            D2
 #define DHT_TYPE           DHT22
@@ -50,10 +53,10 @@
             // Button press debounced
             if (isReporting) {
                 digitalWrite(LED_PIN, HIGH);
-                Serial.println("Reporting stopped!");
+                SERIAL.println("Reporting stopped!");
             } else {
                 digitalWrite(LED_PIN, LOW);
-                Serial.println("Reporting started!");
+                SERIAL.println("Reporting started!");
             }
             isReporting = !isReporting;
             buttonPressMillis = 0;
@@ -61,7 +64,7 @@
     } else if (!isReporting && (digitalRead(BUTTON_PIN) == HIGH)) {
         if (buttonReleaseMillis > 0) {
             if ((millis() - buttonReleaseMillis) >= BUTTON_PRESS_MS) {
-                Serial.println("Entering STOP mode");
+                SERIAL.println("Entering STOP mode");
                 Spark.sleep(BUTTON_PIN, FALLING);
             }
         } else {
@@ -80,20 +83,20 @@

         // Check if any reads failed and exit early (to try again).
         if (isnan(h) || isnan(f)) {
-            Serial.println("Failed to read from DHT sensor!");
+            SERIAL.println("Failed to read from DHT sensor!");
             return;
         }

         currentHumid = h;
         currentTempF = f;

-        Serial.print("Humid: ");
-        Serial.print(currentHumid);
-        Serial.print("% - ");
-        Serial.print("Temp: ");
-        Serial.print(currentTempF);
-        Serial.print("*F ");
-        Serial.println(Time.timeStr());
+        SERIAL.print("Humid: ");
+        SERIAL.print(currentHumid);
+        SERIAL.print("% - ");
+        SERIAL.print("Temp: ");
+        SERIAL.print(currentTempF);
+        SERIAL.print("*F ");
+        SERIAL.println(Time.timeStr());

         lastReadingMillis = now;
     }
@@ -106,7 +109,7 @@
     char publishString[64];

     if (firstTime || ((now - lastReportMillis) >= SENSOR_REPORT_MS)) {
-        Serial.println("Reporting sensor data to server");
+        SERIAL.println("Reporting sensor data to server");

         snprintf(publishString, sizeof(publishString), "{\"tempF\": %.1f, \"humid\": %.1f}", currentTempF, currentHumid);
         Spark.publish("sensorData", publishString);
@@ -117,7 +120,7 @@
 }

 void setup() {
-    Serial.begin(9600);
+    SERIAL.begin(SERIAL_BAUD);

     pinMode(LED_PIN, OUTPUT);


refine the examples.

refine the examples.

--- examples/DHT11WithRawBits/DHT11WithRawBits.ino
+++ examples/DHT11WithRawBits/DHT11WithRawBits.ino
@@ -5,6 +5,7 @@
 //      GND: GND
 //      DATA: 2
 int pinDHT11 = 2;
+SimpleDHT11 dh11;

 void setup() {
   Serial.begin(115200);
@@ -19,7 +20,7 @@
   byte temperature = 0;
   byte humidity = 0;
   byte data[40] = {0};
-  if (simple_dht11_read(pinDHT11, &temperature, &humidity, data)) {
+  if (dh11.read(pinDHT11, &temperature, &humidity, data)) {
     Serial.print("Read DHT11 failed");
     return;
   }


Adding example of mapping from registry to struct with sensor data.

--- examples/Sandbox/CosaRegistry/CosaRegistry.ino
+++ examples/Sandbox/CosaRegistry/CosaRegistry.ino
@@ -33,7 +33,7 @@
  *   1.1 device address (8b)
  *   1.2 sleep period (ms)
  *   2 status
- *   2.0 battery satus (mV)
+ *   2.0 sensor data
  *   2.1 processor load (%)
  *   2.2 error count
  *   3 actions
@@ -74,12 +74,17 @@
 REGISTRY_END(CM)

 // Status variables and registry
-REGISTRY_BLOB_VAR(uint16_t, vcc, "battery status (mV)", 0, true)
+struct sensor_t {
+  int16_t temperature;
+  uint16_t battery;
+};
+
+REGISTRY_BLOB_STRUCT(sensor_t, sensor, "sensor data", true)
 REGISTRY_BLOB_VAR(uint8_t, load, "processor load (%)", -1, true)
 REGISTRY_BLOB_VAR(uint16_t, errors, "error count", 0, false)

 REGISTRY_BEGIN(STATUS, "status") 	// 2
-  REGISTRY_BLOB_ITEM(vcc)		// 2.0
+  REGISTRY_BLOB_ITEM(sensor)		// 2.0
   REGISTRY_BLOB_ITEM(load)		// 2.1
   REGISTRY_BLOB_ITEM(errors)		// 2.2
 REGISTRY_END(STATUS)
@@ -89,7 +94,7 @@
 public:
   virtual int run(void* buf, size_t size)
   {
-    trace << (const char*) buf << endl;
+    trace << PSTR("Action::Restart:") << (const char*) buf << endl;
     return (strlen_P((const char*) buf));
   }
 };
@@ -127,8 +132,9 @@
   eeprom.write(&DEVICE, 0x42);
   eeprom.write(&TIMEOUT, 2000);

-  // Initiate battery status
-  vcc = AnalogPin::bandgap(1100);
+  // Initiate sensor status
+  sensor.battery = AnalogPin::bandgap(1100);
+  sensor.temperature = 200;
 }

 void loop()
@@ -142,7 +148,6 @@

   // Access reg root item (item list)
   item = reg.lookup(NULL);
-  trace << item << endl;
   list = Registry::to_list(item);
   ASSERT(list != NULL);
   trace << list << endl;
@@ -150,7 +155,6 @@
   // Access 0 blob product information management
   path[0] = 0;
   item = reg.lookup(path, 1);
-  trace << item << endl;
   list = Registry::to_list(item);
   ASSERT(list != NULL);
   trace << list << endl;
@@ -194,17 +198,18 @@
   ASSERT(network == 0xbeef);
   trace << hex << network << endl;

-  // Access 2.0 blob battery status (mV)
+  // Access 2.0 blob sensor data
   path[0] = 2;
   path[1] = 0;
   item = reg.lookup(path, sizeof(path));
   trace << item << endl;
   blob = Registry::to_blob(item);
   ASSERT(blob != NULL);
-  uint16_t vcc;
-  ASSERT(reg.get_value(blob, &vcc, sizeof(vcc)) == sizeof(vcc));
-  ASSERT(!reg.set_value<uint16_t>(blob, &vcc));
-  trace << PSTR("vcc = ") << vcc << PSTR(" mV") << endl;
+  sensor_t sensor;
+  ASSERT(reg.get_value(blob, &sensor, sizeof(sensor)) == sizeof(sensor));
+  ASSERT(!reg.set_value<sensor_t>(blob, &sensor));
+  trace << sensor.temperature << PSTR(" C") << endl;
+  trace << sensor.battery << PSTR(" mV") << endl;

   // Access 2.1 blob processor load %
   path[0] = 2;
@@ -216,7 +221,7 @@
   uint8_t load;
   ASSERT(reg.get_value<uint8_t>(blob, &load));
   ASSERT(!reg.set_value<uint8_t>(blob, &load));
-  trace << PSTR("load = ") << load << PSTR(" %") << endl;
+  trace << load << PSTR(" %") << endl;

   // Access 2.2 blob errors
   path[0] = 2;
@@ -227,14 +232,14 @@
   ASSERT(blob != NULL);
   uint16_t errs;
   ASSERT(reg.get_value<uint16_t>(blob, &errs));
-  trace << PSTR("errors = ") << errs << endl;
+  trace << errs << endl;
   errors += 42;
   ASSERT(reg.get_value<uint16_t>(blob, &errs));
-  trace << PSTR("errors = ") << errs << endl;
+  trace << errs << endl;
   errs = 0;
   ASSERT(reg.set_value<uint16_t>(blob, &errs));
   ASSERT(reg.get_value<uint16_t>(blob, &errs));
-  trace << PSTR("errors = ") << errs << endl;
+  trace << errs << endl;

   // Access 3.0 action restart
   path[0] = 3;
@@ -250,9 +255,11 @@
   ASSERT(blob != NULL);
   bool flag;
   ASSERT(reg.get_value<bool>(blob, &flag));
-  trace << PSTR("flag = ") << flag << endl;
+  trace << flag << endl;
   flag = true;
   ASSERT(reg.set_value<bool>(blob, &flag));
+  ASSERT(reg.get_value<bool>(blob, &flag));
+  trace << flag << endl;

   // Access 3.2 illegal path
   path[0] = 3;


Added more light Cycles.  Whee!

Added more light Cycles.  Whee!

--- src/Light/Light.ino
+++ src/Light/Light.ino
@@ -48,7 +48,7 @@
   byte movePref; // CW or CCW preference
 } cycle_t;

-#define MAX_CYCLES 20
+#define MAX_CYCLES 50
 cycle_t cycles[MAX_CYCLES];

 #define CYCLE_DICK_MOVE_PERCENT 15 // chance that a cycle will throw some "zigs" in it's path around the rim
@@ -168,12 +168,18 @@
     ledStatus = !ledStatus;
     digitalWrite(LED_PIN, ledStatus);

-    // dispatch the requests to the rim
-    if( inst.light[I_RED].red > 0 ) addCycle(RED_X, ALL_Y, Red);
-    if( inst.light[I_GRN].green > 0 ) addCycle(GRN_X, ALL_Y, Grn);
-    if( inst.light[I_BLU].blue > 0 ) addCycle(BLU_X, ALL_Y, Blu);
-    if( inst.light[I_YEL].red > 0 && inst.light[I_YEL].green > 0 ) addCycle(YEL_X, ALL_Y, Yel);
-
+    // dispatch the requests to the rim. number of cycles is proportional to the light level at each button
+    for( int i=0; i< inst.light[I_RED].red / 64; i++ ) addCycle(RED_X, ALL_Y, Red);
+    for( int i=0; i< inst.light[I_GRN].green / 64; i++ ) addCycle(GRN_X, ALL_Y, Grn);
+    for( int i=0; i< inst.light[I_BLU].blue / 64; i++ ) addCycle(BLU_X, ALL_Y, Blu);
+    if( inst.light[I_YEL].red > 64 && inst.light[I_YEL].green > 64 )
+      for( int i=0; i< (int)(inst.light[I_YEL].red+inst.light[I_YEL].green) / 128; i++ ) addCycle(YEL_X, ALL_Y, Yel);
+/*
+    if( inst.light[I_RED].red > 64 ) addCycle(RED_X, ALL_Y, Grn);
+    if( inst.light[I_GRN].green > 64 ) addCycle(GRN_X, ALL_Y, Grn);
+    if( inst.light[I_BLU].blue > 64 ) addCycle(BLU_X, ALL_Y, Blu);
+    if( inst.light[I_YEL].red > 64 && inst.light[I_YEL].green > 64 ) addCycle(YEL_X, ALL_Y, Yel);
+*/
     quietUpdateInterval.reset();
     addCycles.reset();
   }
@@ -183,6 +189,7 @@
     Serial << F("Quiet interval elapsed.") << endl;
     Serial << F("Free RAM=") << freeRam() << endl;

+/*
     // add some light cycles
     switch( random(0,4) ) {
       case 0: addCycle(RED_X, ALL_Y, Red); break;
@@ -190,6 +197,11 @@
       case 2: addCycle(BLU_X, ALL_Y, Blu); break;
       case 3: addCycle(YEL_X, ALL_Y, Yel); break;
     }
+    */
+    addCycle(RED_X, ALL_Y, Red);
+    addCycle(GRN_X, ALL_Y, Grn);
+    addCycle(BLU_X, ALL_Y, Blu);
+    addCycle(YEL_X, ALL_Y, Yel);

   }

@@ -455,8 +467,9 @@

   rimJob.setPixelColor(getPixelN(x,y), color);

-  cycles[availableCycle].x = x;
-  cycles[availableCycle].y = y;
+  // cycles don't start in exactly the same place; "thereabouts"
+  cycles[availableCycle].x = constrain((int)x + random(-5,6), 0, RIM_X);
+  cycles[availableCycle].y = constrain((int)y + random(-1,2), 0, RIM_Y);
   cycles[availableCycle].color = color;
   cycles[availableCycle].live = true;


fixing a comment, we don't use bluetooth anymore

--- examples/CaroloCar/CaroloCar.ino
+++ examples/CaroloCar/CaroloCar.ino
@@ -57,7 +57,7 @@
 }

 void loop() {
-  handleOverride(); //look for an override signal and if it exists disable bluetooth input
+  handleOverride(); //look for an override signal and if it exists disable serial input from the HLB
   handleInput(); //look for a serial input if override is not triggered and act accordingly
   updateLEDs(); //update LEDs depending on the mode we are currently in
   transmitSensorData(); //fetch and transmit the sensor data in the correct intervals if bluetooth is connected


Wrong method called when reading POST params.

--- examples/Web_Parms/Web_Parms.ino
+++ examples/Web_Parms/Web_Parms.ino
@@ -205,7 +205,7 @@
   if (type == WebServer::POST)
   {
     server.printP(Post_params_begin);
-    while (server.nextURLparam(&url_tail, name, NAMELEN, value, VALUELEN))
+    while (server.readPOSTparam(name, NAMELEN, value, VALUELEN))
     {
       server.print(name);
       server.printP(Parsed_item_separator);


Update sketch_aug08b.ino

Update sketch_aug08b.ino

--- plane/RECEIVER/sketch_aug08b/sketch_aug08b.ino
+++ plane/RECEIVER/sketch_aug08b/sketch_aug08b.ino
@@ -1,9 +1,5 @@
 /*
-* Arduino Wireless Communication Tutorial
-*     Example 2 - Receiver Code
-*
-* by Dejan Nedelkovski, www.HowToMechatronics.com
-*
+*
 * Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
 */
 struct dataStruct{
@@ -32,7 +28,11 @@
   radio.begin();
   radio.openWritingPipe(addresses[0]); // 00002
   radio.openReadingPipe(1, addresses[1]); // 00001
-  radio.setPALevel(RF24_PA_MIN);
+      radio.setPALevel(RF24_PA_MAX);
+      radio.setDataRate(RF24_250KBPS);
+
+      radio.setRetries(15,15);
+
   Serial.begin(115200);
 }
 void loop() {
@@ -48,31 +48,15 @@
       int angleV = 0;

-     angleV = myData1.angleV;  //so move elemtes to local variables*
-      //angleV1= myData1.angleV1; //added*
-      //angleV1= myData1.angleV1; //added*
-     //comments, I would make send receive tyme names same myData both
-//txrx*
-      //also do not need angle V variables as i believe you can use
-//directly myData1.angleV instead of angleV etc*
-      //hope this helps, PeterSek*
-
-
+      angleV = myData1.angleV;
       myServo.write( myData1.angleV);
-      int angleV1 = 0;
+      int angleV1 = 0;//variable reserved for further valor tests or adaptations if needed

-      angleV1= myData1.angleV1; //added...**//also do not need angle V
-//variables as i believe you can use directly myData1.angleV instead of
-//angleV etc*
-
-
+      angleV1= myData1.angleV1;
       myServo1.write( myData1.angleV1);
-      int angleV2 =  0;
+      int angleV2 =  0;//variable reserved for further valor tests or adaptations if needed

-     angleV1= myData1.angleV1; //added...**//also do not need angle V
-//variables as i believe you can use directly myData1.angleV instead of
-//angleV etc*
-
+     angleV1= myData1.angleV1;


changelog put in line with community norms

--- html/examples/02.Digital/Button/Button.ino
+++ html/examples/02.Digital/Button/Button.ino
@@ -16,7 +16,7 @@
  modified 30 Aug 2011
  by Tom Igoe
  modified 25 May 2016
- by chibitronics
+ by bunnie

  This example code is in the public domain.


Example: SerialControlledSDWriter: change to 44117

--- examples/02-Utility/SerialControlledSDWriter/SerialControlledSDWriter.ino
+++ examples/02-Utility/SerialControlledSDWriter/SerialControlledSDWriter.ino
@@ -24,7 +24,7 @@
 #include "SerialManager.h"

 //set the sample rate and block size
-const float sample_rate_Hz = 96000.0f ; //24000 or 44117 (or other frequencies in the table in AudioOutputI2S_F32)
+const float sample_rate_Hz = 44117.0f ; //24000 or 44117 or 96000 (or other frequencies in the table in AudioOutputI2S_F32)
 const int audio_block_samples = 128;     //do not make bigger than AUDIO_BLOCK_SAMPLES from AudioStream.h (which is 128)  Must be 128 for SD recording.
 AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);

@@ -242,8 +242,8 @@

     max_bytes_written = max(max_bytes_written, bytes_written);
     max_dT_micros = max((int)max_dT_micros, (int)dT_micros);
-
-    if (dT_micros > 1000) {  //if the write took a while, print some diagnostic info
+
+    if (dT_micros > 10000) {  //if the write took a while, print some diagnostic info

       max_max_bytes_written = max(max_bytes_written,max_max_bytes_written);
       max_max_dT_micros = max(max_dT_micros, max_max_dT_micros);


Latch Pin Addition

Latch Pin Addition

Definie MCP pin 3 to latch power on for 10 minutes if no user
intervention, and for an additional 10 minutes when any user action
occurs.

--- pHPhotometerBTLE.ino
+++ pHPhotometerBTLE.ino
@@ -1,9 +1,7 @@
-// pH Photometer
-
 #include "Photometer.h"

+#include <Wire.h>
 #include <SPI.h>
-#include <Wire.h>
 #include "utilities.h"
 #include <RFduinoBLE.h>
 #include "BTLE.h"
@@ -18,8 +16,11 @@
 #define BLUELEDPIN 7
 #define GREENLEDPIN 0
 #define DETECTORPIN 6
+#define LATCHPIN 3
+#define IDLETIME 600000      // This indicages 600 secs * 1000 ms for an idle time reset

 #define DEBUG
+unsigned long latchtime;

 // I2C Wire Setup
 #define SCLPIN 3
@@ -39,10 +40,15 @@
 int readLightConverter(){
   return analogRead(DETECTORPIN);
 }
+void latchControl(int level){
+  mcp.digitalWrite(LATCHPIN, level);
+}
 Photometer photometer(blueLEDControl, greenLEDControl, readLightConverter);

 void setupPhotometer(){
   mcp.begin();
+  mcp.pinMode(LATCHPIN, OUTPUT);
+  mcp.digitalWrite(LATCHPIN, HIGH);
   mcp.pinMode(BLUELEDPIN, OUTPUT);
   mcp.digitalWrite(BLUELEDPIN, LOW);
   mcp.pinMode(GREENLEDPIN, OUTPUT);
@@ -251,6 +257,7 @@
   sendBuffer[length++] = '\n';

   sendBTLEString(sendBuffer, length);
+  latchtime = millis();    // Reset the base latchtime for the IDLETIME timeout count, since activity has occurred
 }

 void sendConductivityString(volatile char* buffer, volatile int len){
@@ -276,6 +283,7 @@
   } else {
     sendBTLEString(response, strlen(response));
   }
+  latchtime = millis();    // Reset the base latchtime for the IDLETIME timeout count, since activity has occurred
 }

 void setupBTLEHandlers(){
@@ -305,14 +313,24 @@
   Serial.print(F("BTLE Handlers Setup..."));
   setupBTLEHandlers();
   Serial.println(F("OK"));
+
+  latchtime = millis();      // We'll keep track of idle time using millis(), and turn the system off if we exceed IDLETIME seconds
 }

 void loop(){
+  unsigned long temptime;
+
   if(sendBlankPending){
     sendBlank();
+    latchtime = millis();    // Reset the base latchtime for the IDLETIME timeout count, since activity has occurred
   }

   if(sendDataPending){
     sendData();
-  }
-}
+    latchtime = millis();    // Reset the base latchtime for the IDLETIME timeout count, since activity has occurred
+  }
+
+  temptime = millis();
+  if ((temptime - latchtime)>IDLETIME)      // If we've exceeded the max idle time,
+        mcp.digitalWrite(LATCHPIN, LOW);    // we'll reset the latch pin. This will remove power from the system in the final wired version.
+}


Cleanup

Cleanup

--- mech/mech.ino
+++ mech/mech.ino
@@ -6,8 +6,6 @@

 #include "proto/device_id.h"  // communication protocol device ID
 #include <AccelStepper.h>     / Accel Stepper library
-
-#include <SoftwareSerial.h>

 #define PJON_ID ID_MECH       // PJON definition (communication protocol)
 #include "proto/common.h"     // communication protocol library


Simplify flashing tft backlight during SmartConfig.

--- wifitask.ino
+++ wifitask.ino
@@ -53,14 +53,7 @@
       }
       else
       {
-        if ( !gpio_get_level( gpio_num_t( TFT_BACKLIGHT_PIN ) ) )
-        {
-          digitalWrite( TFT_BACKLIGHT_PIN, HIGH );
-        }
-        else
-        {
-          digitalWrite( TFT_BACKLIGHT_PIN, LOW );
-        }
+        digitalWrite( TFT_BACKLIGHT_PIN, !gpio_get_level( gpio_num_t( TFT_BACKLIGHT_PIN ) ) );
       }
       vTaskDelay( 500 / portTICK_PERIOD_MS );
     }


fix to config pspec

fix to config pspec

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@21750 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/zconfigmode.ino
+++ zimodem/zconfigmode.ino
@@ -577,9 +577,7 @@
       }
       break;
     case ZCFGMENU_NEWPRINT:
-      if(cmd.length()==0)
-        currState=ZCFGMENU_MAIN;
-      else
+      if(cmd.length()>0)
       {
         if(!printMode.testPrinterSpec(cmd.c_str(),cmd.length(),commandMode.serial.isPetsciiMode()))
         {
@@ -592,9 +590,9 @@
           printMode.setLastPrinterSpec(cmd.c_str());
           settingsChanged=true;
         }
-        currState=ZCFGMENU_MAIN;
-        showMenu=true;
-      }
+      }
+      currState=ZCFGMENU_MAIN;
+      showMenu=true;
       break;
     case ZCFGMENU_WIFIPW:
       if(cmd.length()==0)


Use BUILTIN_LED

Use BUILTIN_LED

--- libraries/esp8266/examples/Blink/Blink.ino
+++ libraries/esp8266/examples/Blink/Blink.ino
@@ -2,22 +2,23 @@
  ESP8266 Blink by Simon Peter
  Blink the blue LED on the ESP-01 module
  This example code is in the public domain
+
+ The blue LED on the ESP-01 module is connected to GPIO1
+ (which is also the TXD pin; so we cannot use Serial.print() at the same time)
+
+ Note that this sketch uses BUILTIN_LED to find the pin with the internal LED
 */

-const int ledPin =  1;         // The blue LED on the ESP-01 module is connected to GPIO1
-                               // (which is also the TXD pin; so we cannot use
-                               // Serial.print() at the same time
-
 void setup() {
-  pinMode(ledPin, OUTPUT);     // Initialize the ledPin as an output
+  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
 }

 // the loop function runs over and over again forever
 void loop() {
-  digitalWrite(ledPin, LOW);   // turn the LED on (Note that LOW is the voltage level
-                               // but actually the LED is on; this is because
-                               // it is acive low on the ESP-01)
-  delay(1000);                 // Wait for a second
-  digitalWrite(ledPin, HIGH);  // Turn the LED off by making the voltage HIGH
-  delay(2000);                 // Wait for two seconds (to demonstrate the active low LED)
+  digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level
+                                    // but actually the LED is on; this is because
+                                    // it is acive low on the ESP-01)
+  delay(1000);                      // Wait for a second
+  digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH
+  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
 }


Use pin 0 for the DT22.

Use pin 0 for the DT22.

--- water_heater_monitor/water_heater_monitor.ino
+++ water_heater_monitor/water_heater_monitor.ino
@@ -16,7 +16,7 @@
 char eagle_data[81];
 uint8_t data_index = 0;

-DHT dht = DHT(4, DHT22);               // Pin 4, DHT 22 (AM2302)
+DHT dht = DHT(0, DHT22);               // Pin 0, DHT 22 (AM2302)

 void setup () {
   initHardware();