Optimized delays and PROGMEM usage

Optimized delays and PROGMEM usage

Sketch uses 14276 bytes (44%) of program storage space.
Global variables use 616 bytes (30%) of dynamic memory

--- Rubiks_cube_sketch/Rubiks_cube_sketch.ino
+++ Rubiks_cube_sketch/Rubiks_cube_sketch.ino
@@ -21,13 +21,14 @@
 #define maxAngleMotor3 95   // maximum limit for turning
 #define minAngleMotor4 35   // minimum limit fur turning
 #define maxAngleMotor4 98   // maximum limit for turning
-#define standardDelay 200   // standard delay for motor movement
+#define standardDelay 175   // standard delay for motor movement

 //Including libraries
 #include <Servo.h>
 #include <MsTimer2.h>
 #include <Wire.h>
 #include <LiquidCrystal_I2C.h>
+#include <avr/pgmspace.h>

 //Defining variables
@@ -63,8 +64,8 @@

 //Data arrays and matrixes
 //Arrays for color scanning
-byte Motor_1_ScanAngles [9] = {44, 85, 120, 4, 4, 168, 134, 96, 58};
-byte Motor_4_ScanAngles [9] = {71, 74, 70, 74, 82, 73, 94, 90, 94};
+const byte Motor_1_ScanAngles [9] PROGMEM = {44, 85, 120, 4, 4, 168, 134, 96, 58};
+const byte Motor_4_ScanAngles [9] PROGMEM = {71, 74, 70, 74, 82, 73, 94, 90, 94};
 //Arrays for side and cube scanning
 char SideScanResult [10];
 char ScannedCube [55];               // = "woybogwrybwbbwggygoyoogoryryowbrgyrwbybbyggwgrwrrbrowo";
@@ -125,13 +126,13 @@
   Serial.begin(9600);

   turnMotor1(89, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor3(90, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor4(35, 7);
-  delay(standardDelay);
+  //delay(standardDelay);

   // Setting frequency-scaling to 20%
   //digitalWrite(S0, HIGH);
@@ -151,29 +152,8 @@

   normalFlow();

-  //solveOrCaliblate();
-
-  //operateOrNot();
-
-  //scanCube();
-
-  //verifyScannedCube();
-  //writePortData();
-  //delay(500);
-
-  //readPortData();
-
   //String movementString = "rLUdBBUUllFFllUUllFF";
   //assembleCube(SolvedCube);
-
-  //scanTopSide();
-  //printSide(SideScanResult);
-  //addSideToScanCubeString(SideScanResult);
-
-
-
-  //calibrationScan();
-

 }

@@ -373,154 +353,6 @@
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////METHODS FOR COMMUNICATING VIA COM-PORT/////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-/*/Method for reading data from COM-port (the string with solution from Python script)
-void readPortData() {
-  char PortReadyFlag;
-  boolean connectionError;
-  volatile long PortTimeout;
-
-  resendData:
-
-  storeLCD(F("Waiting for data"), 0);
-  storeLCD(F("from Python..."), 1);
-
-  PortReadyFlag = '0';
-  connectionError = false;
-
-  PortTimeout = millis();
-  do {
-    PortReadyFlag = '0';
-    PortReadyFlag = char(Serial.read());
-    while(Serial.available()) Serial.read();
-    delay(100);
-    } while ((PortReadyFlag != '!') && (millis() - PortTimeout < 10000));
-
-  if ((millis() - PortTimeout) >= 10000) {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  delay(300);
-  Serial.print('!');
-
-  storeLCD(F("Receiving data.."), 0);
-  storeLCD(F(""), 1);
-
-  PortTimeout = millis();
-  do {
-      SolvedCube = "";
-      while (Serial.available()) {
-      SolvedCube += char(Serial.read());
-    }
-    delay(100);
-  } while ((SolvedCube.length() == 0) && (millis() - PortTimeout < 10000));
-
-  if ((millis() - PortTimeout) >= 10000) {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  storeLCD(F("Verifying data.."), 0);
-
-  if (SolvedCube.length() < 10) Serial.print('0');
-  Serial.print(SolvedCube.length());
-
-  PortTimeout = millis();
-  do {
-      PortReadyFlag = '0';
-      PortReadyFlag = char(Serial.read());
-      while(Serial.available()) Serial.read();
-      delay(100);
-  } while(!((PortReadyFlag == '+')||(PortReadyFlag == 'x')) && (millis() - PortTimeout < 10000));
-
-  if ((millis() - PortTimeout) >= 10000) {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  if (PortReadyFlag == '+') {
-    storeLCD(F("Data received"), 0);
-    storeLCD(F("successfully"), 1);
-    }
-  else {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  sendingError:
-    if (connectionError == true) {
-      connectionError = false;
-      selectedButton = selectOption(F("Receiving error"), F("Repeat   Restart"), F("Repeat"), F("         Restart"));
-        if (selectedButton == 0) goto resendData;
-        else normalFlow();
-      }
-}
-
-//Method for sending data to COM-port (the char array with cube colors to Python script)
-void writePortData() {
-  char PortReadyFlag;
-  boolean connectionError;
-  volatile long PortTimeout;
-
-  resendData:
-
-  storeLCD(F("Waiting for"), 0);
-  storeLCD(F("connection..."), 1);
-
-  Serial.print('!');
-
-  PortReadyFlag = '0';
-  connectionError = false;
-
-  PortTimeout = millis();
-  do {
-    PortReadyFlag = '0';
-    PortReadyFlag = char(Serial.read());
-    while(Serial.available()) Serial.read();
-    delay(100);
-  } while ((PortReadyFlag != '!') && (millis() - PortTimeout < 10000));
-
-  if ((millis() - PortTimeout) >= 10000) {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  storeLCD(F("Sending data"), 0);
-  storeLCD(F(""), 1);
-  Serial.print(ScannedCube);
-
-  PortTimeout = millis();
-  do {
-      PortReadyFlag = '0';
-      PortReadyFlag = char(Serial.read());
-      while(Serial.available()) Serial.read();
-      delay(100);
-  } while(!((PortReadyFlag == '+')||(PortReadyFlag == 'x')) && (millis() - PortTimeout < 10000));
-
-  if ((millis() - PortTimeout) >= 10000) {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  if (PortReadyFlag == '+') {
-    storeLCD(F("Data sent"), 0);
-    storeLCD(F("successfully"), 1);
-    }
-  else {
-    connectionError = true;
-    goto sendingError;
-    }
-
-  sendingError:
-    if (connectionError == true) {
-      connectionError = false;
-      selectedButton = selectOption(F("Sending error"), F("Resend   Restart"), F("Resend"), F("         Restart"));
-        if (selectedButton == 0) goto resendData;
-        else normalFlow();
-      }
-}
-*/

 //Method for sending and receiving data from Python script
@@ -765,13 +597,13 @@
   lcd.setCursor(0, 0);
   lcd.print(F("Calibrating..."));
   turnMotor2(95, 5);
-  delay(200);
+  //delay(200);
   turnMotor4(35, 7);
-  delay(200);
+  //delay(200);
   for (byte i = 0; i<9; i++) {
-    turnMotor1(Motor_1_ScanAngles[i], 4);
-    turnMotor4(Motor_4_ScanAngles[i], 7);
-    delay(100);
+    turnMotor1(pgm_read_byte(&(Motor_1_ScanAngles[i])), 4);
+    turnMotor4(pgm_read_byte(&(Motor_4_ScanAngles[i])), 7);
+    //delay(200);
     scan_item();
     delay(100);
     if (serialOutput == true) {
@@ -792,18 +624,17 @@
 //Method for scanning cube's top side
 void scanTopSide() {
   turnMotor2(95, 5);
-  delay(200);
+  //delay(200);
   turnMotor4(35, 7);
-  delay(200);
+  //delay(200);
   attachInterrupt (0, leftButtonPressed, RISING);
   operateFlag = true;
   for (byte i = 0; i<9; i++) {
-    turnMotor1(Motor_1_ScanAngles[i], 4);
-    delay(50);
-    turnMotor4(Motor_4_ScanAngles[i], 5);
-    delay(200);
+    turnMotor1(pgm_read_byte(&(Motor_1_ScanAngles[i])), 4);
+    turnMotor4(pgm_read_byte(&(Motor_4_ScanAngles[i])), 7);
+    //delay(200);
     SideScanResult[i] = scanResult();
-    delay(200);
+    delay(100);
   }
   turnMotor4(35, 7);
   turnCubeStraight();
@@ -890,40 +721,7 @@
   return color;
 }

-//Supportive function for device calibration
-/*void calibrate() {
-  // Setting red filtered photodiodes to be read
-  digitalWrite(S2,LOW);
-  digitalWrite(S3,LOW);
-  // Reading the output frequency
-  frequency = pulseIn(scanSensor, LOW);
-  // Printing the value on the serial monitor
-  Serial.print("R= ");//printing name
-  Serial.print(frequency);//printing RED color frequency
-  Serial.print("  ");
-  delay(100);
-  // Setting Green filtered photodiodes to be read
-  digitalWrite(S2,HIGH);
-  digitalWrite(S3,HIGH);
-  // Reading the output frequency
-  frequency = pulseIn(scanSensor, LOW);
-  // Printing the value on the serial monitor
-  Serial.print("G= ");//printing name
-  Serial.print(frequency);//printing GREEN color frequency
-  Serial.print("  ");
-  delay(100);
-  // Setting Blue filtered photodiodes to be read
-  digitalWrite(S2,LOW);
-  digitalWrite(S3,HIGH);
-  // Reading the output frequency
-  frequency = pulseIn(scanSensor, LOW);
-  // Printing the value on the serial monitor
-  Serial.print("B= ");//printing name
-  Serial.print(frequency);//printing BLUE color frequency
-  Serial.println("  ");
-  delay(100);
-}
-
+/*
 void printSide(String side[]) {
   byte e = 0;
   for (byte i=0; i<3; i++) {
@@ -1139,6 +937,7 @@
     }
   }
   motor_1_Position = limitedDegree;
+  delay(standardDelay);
 }

@@ -1160,6 +959,7 @@
     }
   }
   motor_2_Position = limitedDegree;
+  delay(standardDelay);
 }

@@ -1181,6 +981,7 @@
     }
   }
   motor_3_Position = limitedDegree;
+  delay(standardDelay);
 }

@@ -1202,56 +1003,57 @@
     }
   }
   motor_4_Position = limitedDegree;
+  delay(standardDelay);
 }

 //Method for pushing the cube
 void push() {
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor3(45, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(118, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor3(95, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor3(90, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
 }

 //Method for turning the cube ClockWise
 void turnCubeCW() {
   turnMotor2(95, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(5, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
 }

 //Method for turning the cube CounterClockWise
 void turnCubeCCW() {
   turnMotor2(95, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(171, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
 }

 //Method for turning the cube straight
 void turnCubeStraight() {
   turnMotor2(95, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(88, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
 }

@@ -1259,17 +1061,17 @@
 void downCW() {
   turnCubeCW();
   turnMotor3(45, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(135, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(95, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(88, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor3(90, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
 }

@@ -1277,16 +1079,16 @@
 void downCCW() {
   turnCubeCCW();
   turnMotor3(45, 2);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(135, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(80, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor1(88, 3);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor2(105, 5);
-  delay(standardDelay);
+  //delay(standardDelay);
   turnMotor3(90, 2);
-  delay(standardDelay);
-}
-
+  //delay(standardDelay);
+}
+


Deleted Dial_demo example.

Deleted Dial_demo example.

--- examples/Dial_demo/Dial_demo.ino
+++ examples/Dial_demo/Dial_demo.ino
@@ -1,116 +0,0 @@
-// Required includes
-#include <SPI.h>
-#include <StandardCplusplus.h>
-#include <vector>
-
-// GUI includes
-#include <Gauge.h>
-#include <Dial.h>
-#include <Button.h>
-#include <Display.h>
-
-// Create the objects
-//==========================================
-Canvas canvas = Canvas();
-Gauge gauge = Gauge();//Gauge(40,100,0,50,100);
-Dial dial = Dial();
-Display valueDisplay = Display();//Display(80,40,BLACK,GREEN,WHITE);
-Button btnInc = Button();//Button(50,50,GRAY1,BLACK,WHITE);
-Button btnDec = Button();//Button(50,50,GRAY1,BLACK,WHITE);
-
-/*
- *  Setup function
- */
-void setup() {
-  Serial.begin(9600);
-
-  //Configure the objects
-  //=========================================
-    canvas.init(TFT_LANDSCAPE);
-
-    //Prepare widgets
-    btnInc.setSize(50,50);
-    btnInc.setColors(GRAY1,BLACK,WHITE);
-    btnInc.setText("+");
-    btnInc.setEventHandler(&incEventHandler);
-    btnInc.init();
-    btnInc.setDebounce(200);
-
-    btnDec.setSize(50,50);
-    btnDec.setColors(GRAY1,BLACK,WHITE);
-    btnDec.setText("-");
-    btnDec.setEventHandler(&decEventHandler);
-    btnDec.init();
-    btnDec.setDebounce(200);
-
-    gauge.setSize(40,100);
-    gauge.setColors(BLACK,BLUE,WHITE);
-    gauge.setLimits(0,65,100);
-    gauge.init();
-    gauge.setHiLimit(85,GREEN);
-    gauge.setLowLimit(45,RED);
-
-    dial.setSize(40);
-    dial.setColors(GRAY2,WHITE,GRAY1);
-    dial.setLimits(0,65,100);
-    dial.init();
-    dial.setHiLimit(85,GREEN);
-    dial.setLowLimit(45,RED);
-
-    valueDisplay.setSize(80,40);
-    valueDisplay.setColors(BLACK,YELLOW,WHITE);
-    valueDisplay.setNum(dial.getCV());
-    valueDisplay.init();
-
-    //Add them to the canvas
-    canvas.add(&btnInc,120,0);
-    canvas.add(&btnDec,120,100);
-    canvas.add(&valueDisplay,0,0);
-    canvas.add(&gauge,0,50);
-    canvas.add(&dial,240,40);
-    canvas.setDebounce(200);
-}
-
-
-/*
- *  Main program
- *  Must call canvas scan to check for touch events
- */
-void loop() {
-  //Updates the canvas and monitor for touch events
-  canvas.scan();
-}
-
-
-/*
- *  Auxiliary Functions
- */
-
-// Event Handler Functions for buttons
-//==========================================
-void incEventHandler(Button* btn){
-  int val = gauge.getCV()+5;
-  dial.setCV(val);
-  gauge.setCV(val);
-  valueDisplay.fgColor = gauge.fgColor;
-  if(gauge.getCV() >= gauge.hiLimit) valueDisplay.fgColor = gauge.hiLimitColor;
-  if(gauge.getCV() <= gauge.lowLimit) valueDisplay.fgColor = gauge.lowLimitColor;
-  valueDisplay.setNum(gauge.getCV());
-  valueDisplay.show();
-
-}
-
-void decEventHandler(Button* btn){
-  int val;
-  if(gauge.getCV()>=5) {
-    val = gauge.getCV()-5;
-  }
-  dial.setCV(val);
-  gauge.setCV(val);
-  valueDisplay.fgColor = gauge.fgColor;
-  if(gauge.getCV() >= gauge.hiLimit) valueDisplay.fgColor = gauge.hiLimitColor;
-  if(gauge.getCV() <= gauge.lowLimit) valueDisplay.fgColor = gauge.lowLimitColor;
-  valueDisplay.setNum(gauge.getCV());
-  valueDisplay.show();
-
-}


- enable the FMT_OPT option, such that the program will parse the GPGGA from GPS iff there is GPS installed

--- Device_LinkItOne/LASS/LASS.ino
+++ Device_LinkItOne/LASS/LASS.ino
@@ -183,7 +183,7 @@
   #define SENSOR_ID_HUMIDITY_BLYNK 6
   #define SENSOR_ID_LIGHT_BLYNK 7
 #endif
-
+XSWZA
 enum pinSensorConfig{
   DUST_SENSOR_PIN = 8,
   SOUND_SENSOR_PIN = A1,
@@ -928,7 +928,13 @@
       Serial.print((char*)info.GPVTG);

-      parseGPGGA((const char*)info.GPGGA);
+
+      if(FMT_OPT==0){ // there is a GPS
+        parseGPGGA((const char*)info.GPGGA);
+      }else{          // there are no GPS
+        parseGPGGA((const char*)GPS_FIX_INFOR);
+      }
+      // parseGPGGA((const char*)info.GPGGA);
       parseGPRMC((const char*)info.GPRMC);
       parseGPVTG((const char*)info.GPVTG);
         break;
@@ -966,17 +972,7 @@
       msg_tmp.concat(str_GPS_satellite);
       msg_tmp.concat("|gps-alt=");
       msg_tmp.concat(str_GPS_altitude);
-/*
-      // the following content is kept in v0.7.0, but should be removed in the next version
-      // default gps result, must have.
-      msg_tmp.concat("|gps=");
-      if(FMT_OPT==0){
-        msg_tmp.concat((char*)info.GPGGA);
-      }else{
-        msg_tmp.concat((char*)GPS_FIX_INFOR);
-
-      }
-*/
+
 //msg_tmp.concat("|gpgga=");
       //msg_tmp.concat((char*)info.GPGGA);
       //msg_tmp.concat("|gpgsa=");


Update E02_KY-040_RotaryEncoder.ino

Update E02_KY-040_RotaryEncoder.ino

--- RotaryEncoder/examples/E02_KY-040_RotaryEncoder/E02_KY-040_RotaryEncoder.ino
+++ RotaryEncoder/examples/E02_KY-040_RotaryEncoder/E02_KY-040_RotaryEncoder.ino
@@ -1,88 +1,88 @@
-//  Extended: E02 KY-040 RotaryEncoder Demo
-//
-//  Search string:
-//    "ky-040 rotary decoder encoder module for arduino"
-//
-//  Functions:
-//    Rotate CW:   count up         1..59, 1  or 1..31, 1  or 1..12, 1  or 0..99, 0
-//    Rotate CCW:  count down       59..1, 59 or 32..1, 31 or 12..1, 12 or 99..0, 99
-//    Push Button
-//      - short:   switch to next digit group;  HH or MM or SS or YY or MM or DD
-//      - long:    ready                        20YY-MM-DDTHH:MM:SS
-//
-//
-//  Wiring:
-//         KY-040                 Arduino AVR (UNO, Nano, etc.)
-//    +-------------+
-//    |             |--- CLK  >   o Pin 3
-//    |             |--- DAT  >   o Pin 2
-//    |   top view  |--- SW   >   o Pin A1
-//    |             |--- VCC  >   o 5.0V
-//    |             |--- GND  >   o GND
-//    +-------------+
-//
-//     No external RC- or R-parts are used. Debouncing will be supported by Rotary Encoder library 'RotaryEncoder.h'
-//
-//  Copyright (c) 2015 Thomas Walloschke (artkeller at gmx.de). All rights reserved.
-//
-//  Permission is hereby granted, free of charge, to any person obtaining a copy
-//  of this software and associated documentation files (the "Software"), to deal
-//  in the Software without restriction, including without limitation the rights
-//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-//  copies of the Software, and to permit persons to whom the Software is
-//  furnished to do so, subject to the following conditions:
-//
-//  The above copyright notice and this permission notice shall be included in
-//  all copies or substantial portions of the Software.
-//
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-//  THE SOFTWARE.
-
-// ***************************************************************
-
-#if ARDUINO >= 100
-#include "Arduino.h"
-#else
-#include "WProgram.h"
-#endif
-
-#include <RotaryEncoder.h>
-#include <Time.h>
-
-// Default Rotary Encoder Object
-RotaryEncoder rotaryEncoder = RotaryEncoder();  // CLK = pin 3, DAT = pin 2, SW = pin A1, CW = count up, CCW = count down
-
-// ***************************************************************
-
-void setup() {
-
-  rotaryEncoder.setRange(1,12);                                 // set min and max encoder position
-
-  Serial.begin(115200);
-  Serial.print(F("E02 KY-040 RotaryEncoder Demo"));
-  Serial.println(F(" (compiled " __DATE__ " " __TIME__ ")"));
-}
-
-// ***************************************************************
-
-void loop() {                                                   // apply Rotary Encoder methods
-
-  // Get Rotary Encoder status
-  rotaryEncoder.startDebouncer();                               // has to be inside loop to enable debouncer
-  rotaryEncoder.updateClearButton();                            // enable Button to clear recent encoder position if pushed, set to 0
-
-  // Print changes
-  if (rotaryEncoder.hasChanged()) {                             // verify if encoder position has changed
-    volatile byte encoderPos = rotaryEncoder.encodedPos();      // update counter for the dial (values 0..15)
-    Serial.print(F("Position: "));
-    Serial.println(encoderPos, DEC);
-  }
-}
-
-// ***************************************************************
+//  Extended: E02 KY-040 RotaryEncoder Demo
+//
+//  Web Search String:
+//    "ky-040 rotary decoder encoder module for arduino"
+//
+//  Functions:
+//    Rotate CW:   count up         1..59, 1  or 1..31, 1  or 1..12, 1  or 0..99, 0
+//    Rotate CCW:  count down       59..1, 59 or 32..1, 31 or 12..1, 12 or 99..0, 99
+//    Push Button
+//      - short:   switch to next digit group;  HH or MM or SS or YY or MM or DD
+//      - long:    ready                        20YY-MM-DDTHH:MM:SS
+//
+//
+//  Wiring:
+//         KY-040                 Arduino AVR (UNO, Nano, etc.)
+//    +-------------+
+//    |             |--- CLK  >   o Pin 3
+//    |             |--- DAT  >   o Pin 2
+//    |   top view  |--- SW   >   o Pin A1
+//    |             |--- VCC  >   o 5.0V
+//    |             |--- GND  >   o GND
+//    +-------------+
+//
+//     No external RC- or R-parts are used. Debouncing will be supported by Rotary Encoder library 'RotaryEncoder.h'
+//
+//  Copyright (c) 2015 Thomas Walloschke (artkeller at gmx.de). All rights reserved.
+//
+//  Permission is hereby granted, free of charge, to any person obtaining a copy
+//  of this software and associated documentation files (the "Software"), to deal
+//  in the Software without restriction, including without limitation the rights
+//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+//  copies of the Software, and to permit persons to whom the Software is
+//  furnished to do so, subject to the following conditions:
+//
+//  The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+//  THE SOFTWARE.

+// ***************************************************************
+
+#if ARDUINO >= 100
+#include "Arduino.h"
+#else
+#include "WProgram.h"
+#endif
+
+#include <RotaryEncoder.h>
+#include <Time.h>
+
+// Default Rotary Encoder Object
+RotaryEncoder rotaryEncoder = RotaryEncoder();  // CLK = pin 3, DAT = pin 2, SW = pin A1, CW = count up, CCW = count down
+
+// ***************************************************************
+
+void setup() {
+
+  rotaryEncoder.setRange(1,12);                                 // set min and max encoder position
+
+  Serial.begin(115200);
+  Serial.print(F("E02 KY-040 RotaryEncoder Demo"));
+  Serial.println(F(" (compiled " __DATE__ " " __TIME__ ")"));
+}
+
+// ***************************************************************
+
+void loop() {                                                   // apply Rotary Encoder methods
+
+  // Get Rotary Encoder status
+  rotaryEncoder.startDebouncer();                               // has to be inside loop to enable debouncer
+  rotaryEncoder.updateClearButton();                            // enable Button to clear recent encoder position if pushed, set to 0
+
+  // Print changes
+  if (rotaryEncoder.hasChanged()) {                             // verify if encoder position has changed
+    volatile byte encoderPos = rotaryEncoder.encodedPos();      // update counter for the dial (values 0..15)
+    Serial.print(F("Position: "));
+    Serial.println(encoderPos, DEC);
+  }
+}
+
+// ***************************************************************
+


fixed spacing in example

fixed spacing in example

--- firmware/examples/GA1A12S202.ino
+++ firmware/examples/GA1A12S202.ino
@@ -1,12 +1,12 @@
-
 #include "GA1A12S202/GA1A12S202.h"

-GA1A12S202 lux(A0); void setup() {
+GA1A12S202 lux(A0);
+
+void setup() {
     Serial.begin(115200);
     delay(5000);
-
-
 }
+
 void loop() {
     Serial.print("Raw = ");
     Serial.print(lux.getRaw());


build fix

build fix

--- examples/Widgets/Bridge/Bridge.ino
+++ examples/Widgets/Bridge/Bridge.ino
@@ -46,22 +46,6 @@
 // Timer for blynking
 SimpleTimer timer;

-void setup()
-{
-  Blynk.begin(auth);
-
-  while (Blynk.connect() == false) {
-    // Wait until connected
-  }
-
-  // Call blynkAnotherDevice every second
-  timer.setInterval(1000L, blynkAnotherDevice);
-}
-
-BLYNK_CONNECTED() {
-  bridge1.setAuthToken("OtherAuthToken"); // Place the AuthToken of the second hardware here
-}
-
 static bool value = true;
 void blynkAnotherDevice() // Here we will send HIGH or LOW once per second
 {
@@ -69,7 +53,7 @@
   if (value) {
     bridge1.digitalWrite(9, HIGH);  // Digital Pin 9 on the second board will be set HIGH
     bridge1.virtualWrite(V5, 1); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.
-
+
   /////////////////////////////////////////////////////////////////////////////////////////
   // Keep in mind that when performing virtualWrite with Bridge,
   // second board will need to process the incoming command.
@@ -88,6 +72,22 @@
   value = !value;
 }

+void setup()
+{
+  Blynk.begin(auth);
+
+  while (Blynk.connect() == false) {
+    // Wait until connected
+  }
+
+  // Call blynkAnotherDevice every second
+  timer.setInterval(1000L, blynkAnotherDevice);
+}
+
+BLYNK_CONNECTED() {
+  bridge1.setAuthToken("OtherAuthToken"); // Place the AuthToken of the second hardware here
+}
+
 void loop()
 {
   Blynk.run();


cleaned up source

cleaned up source

--- Firmware/Firmware.ino
+++ Firmware/Firmware.ino
@@ -20,17 +20,19 @@
     CAN.begin();
     CAN.baudConfig(BUS_SPEED);
     CAN.setMode(NORMAL);
-    //CAN.setMode(LOOPBACK);  // set to "NORMAL" for standard com
+    // CAN.setMode(LOOPBACK);  // set to "NORMAL" for standard com

-    //Wait 10 seconds so that I can still upload even
-    //if the previous iteration spams the serial port
+    // Wait 10 seconds so that I can still upload even
+    // if the previous iteration spams the serial port
     delay(100);
 }

 void loop()
 {
     static byte val = 0;
-    byte length,rx_status,i;
+    val++;
+
+    byte length, rx_status,i;
     unsigned short frame_id;
     byte frame_data[8];

@@ -46,11 +48,10 @@
     frame_id = 0x1d4;
     length = 8;

-    CAN.load_ff_0(length,frame_id,frame_data);
-    CAN.load_ff_1(1,0x1d5,frame_data);
+    CAN.load_ff_0(length, frame_id, frame_data);
+    CAN.load_ff_1(1, 0x1d5, frame_data);
     CAN.send_0();
     CAN.send_1();

-    val++;
     delay(100);
 }


Extend trommelbold serial protocol

Extend trommelbold serial protocol


Replace demo mode with real serial I/O; allow setting color and pulse speed

--- arduino/blinkytape_orb.ino
+++ arduino/blinkytape_orb.ino
@@ -8,25 +8,25 @@
 // visuals
 #define PULSE_MAX_VAL 255
 #define PULSE_MIN_VAL 160
-#define PULSE_DURATION 3000
+#define PULSE_DURATION_SLOW 3000
+#define PULSE_DURATION_MED 1500
+#define PULSE_DURATION_FAST 0

 #define CHANGE_MIN_VAL 64
-#define CHANGE_DURATION 1000
-
-// demo mode
-#define DEMO_PULSES 5
+#define CHANGE_DURATION 800

 // state
 CRGB leds[NUM_LEDS];
 uint8_t hue = HUE_RED;
 uint8_t val = PULSE_MAX_VAL;
-uint8_t demo_pulse_count = 0;
+bool pulse = true;
+long pulse_duration = PULSE_DURATION_FAST;

-void fade(uint8_t new_val, uint16_t duration) {
-  uint8_t incr;
-  uint8_t delay_ms;
+void fade(uint8_t new_val, long duration) {
+  int incr;
+  long delay_ms;
   if (val < new_val) {
     incr = 1;
     delay_ms = duration / (new_val - val);
@@ -39,7 +39,7 @@
   }

   for (uint8_t v = val; v != new_val; v += incr) {
-    for (uint8_t i = 0; i < NUM_LEDS; i++) {
+    for (int i = 0; i < NUM_LEDS; i++) {
       leds[i] = CHSV(hue, 255, v);
     }
     FastLED.show();
@@ -50,20 +50,70 @@
 }

 void setup() {
+  Serial.begin(57600);
+
   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);

-  for (uint8_t i = 0; i < NUM_LEDS; i++) {
+  for (int i = 0; i < NUM_LEDS; i++) {
     leds[i] = CHSV(hue, 255, val);
   }
 }

 void loop() {
-  demo_pulse_count = (demo_pulse_count + 1) % DEMO_PULSES;
-  fade(PULSE_MIN_VAL, PULSE_DURATION / 2);
-  if (demo_pulse_count == 0) {
+  if (pulse) {
+    fade(PULSE_MIN_VAL, pulse_duration / 2);
+  }
+
+  if (Serial.available() > 0) {
+    byte c = Serial.read();
+
     fade(CHANGE_MIN_VAL, CHANGE_DURATION / 2);
-    hue = (hue + 32) % 255;
+
+    c -= 65; // align to ASCII "A"
+
+    switch (c & B00000011) {
+      case 0:
+        pulse = false;
+        break;
+      case 1:
+        pulse = true;
+        pulse_duration = PULSE_DURATION_SLOW;
+        break;
+      case 2:
+        pulse = true;
+        pulse_duration = PULSE_DURATION_MED;
+        break;
+      case 3:
+        pulse = true;
+        pulse_duration = PULSE_DURATION_FAST;
+        break;
+    }
+
+    switch ((c & B00011100) >> 2) {
+      case 0:
+        hue = HUE_RED;
+        break;
+      case 1:
+        hue = HUE_ORANGE;
+        break;
+      case 2:
+        hue = HUE_YELLOW;
+        break;
+      case 3:
+        hue = HUE_GREEN;
+        break;
+      case 4:
+        hue = HUE_BLUE;
+        break;
+      case 5:
+        hue = HUE_PURPLE;
+        break;
+    }
+
     fade(PULSE_MIN_VAL, CHANGE_DURATION / 2);
   }
-  fade(PULSE_MAX_VAL, PULSE_DURATION / 2);
+
+  if (pulse) {
+    fade(PULSE_MAX_VAL, pulse_duration / 2);
+  }
 }


Finale version of Arduino SERVO

Finale version of Arduino SERVO

--- code/arduino/SG90_and_dynamixel/SG90_and_dynamixel.ino
+++ code/arduino/SG90_and_dynamixel/SG90_and_dynamixel.ino
@@ -3,10 +3,11 @@
 #include <DynamixelSerial.h>

 //Dynamixel const
-const int DYNAMIXEL_ADDRESS = 4;
+const int DYNAMIXEL_ADDRESS = 6;
 const int DYNAMIXEL_CTRL_PIN = 2;
+//RIGHT VALUE FOR DYNAMIXEL
 const int ANGLE_DYNAMIXEL_HORIZONTAL = 508;
-const int ANGLE_DYNAMIXEL_VERTICAL = 810;
+const int ANGLE_DYNAMIXEL_VERTICAL = 830;
 //const int ANGLE_VERTICAL = 205; Depend on the dynamixel's position

 //I2C slave adresses
@@ -14,14 +15,14 @@

 //Clamp servo const
 const int SERVO_CLAMP_PIN = 9;
-const int SERVO_PUSH_PIN = 10; //TO DEFINE
-const int SERVO_PUSH_PIN = 11;
-const int CLAMP_OPEN_ANGLE = 0;
+const int SERVO_PUSH_PIN = 10;
+const int PUSH_BACK = 60;
+const int PUSH_OUT = 25;
+const int CLAMP_OPEN_ANGLE = 70;
 const int CLAMP_CLOSE_ANGLE = 180;
 Servo servo_clamp;
 Servo servo_push;
-Servo servo_stack;
-
+
 int servo;
 int action;

@@ -39,11 +40,11 @@
   //Attache the servo on the PWM pin;
   servo_clamp.attach(SERVO_CLAMP_PIN);
   servo_push.attach(SERVO_PUSH_PIN);
-  servo_stack.attach(SERVO_STACK_PIN);
+  //servo_stack.attach(SERVO_STACK_PIN);
 }

 void loop() {
-process_action(servo, action);
+  process_action(servo, action);
 }

 void receive_data(int byte_count) {
@@ -85,25 +86,16 @@
       break;
     case 2:
       if (action == 0) {
-        change_servo_angle(&servo_push, CLAMP_OPEN_ANGLE);
+        change_servo_angle(&servo_push, PUSH_BACK);
       }
       else if (action == 1) {
-        change_servo_angle(&servo_push, CLAMP_CLOSE_ANGLE);
-      }
-      break;
-    case 3:
-      if (action == 0) {
-        change_servo_angle(&servo_stack, CLAMP_OPEN_ANGLE);
-      }
-      else if (action == 1) {
-        change_servo_angle(&servo_stack, CLAMP_CLOSE_ANGLE);
+        change_servo_angle(&servo_push, PUSH_OUT);
       }
       break;
    default :
-     break; //TODO : do something when value is not right?
+     break; //do something when value is not right?
   }
 }
-

 //Use a specifique servo and give it an angle
 void change_servo_angle(Servo *servo, int angle) {


Update Arduino_16_Zone_Irrigation_Controller.ino

Adds the ability to hard code a delay before the optional pump/master valve turns off

--- 16_Zone_Controller/Arduino_16_Zone_Irrigation_Controller.ino
+++ 16_Zone_Controller/Arduino_16_Zone_Irrigation_Controller.ino
@@ -2,7 +2,7 @@
 /**
 *
  ****************************************************************************************************************************
- * Irrigation Controller 16 Zones With Options for Master Valve and Pump  v3_0
+ * Irrigation Controller 16 Zones With Options for Master Valve and Pump  v3_1
  * Simple, elegant irrigation controller that takes advantage of the cloud and SmartThings ecosystem
  * Arduino MEGA with SmartThings Shield  and 16 relay modules
  * Works by receiving irrigation run times from the Cloud and then builds a queue to execute
@@ -219,7 +219,7 @@
 //user configurable global variables to set before loading to Arduino
 int relays = 16;  //set up before loading to Arduino (max = 16 with current code and assumes last relay is a master valve/pump actuator)
 boolean isActiveHigh=false; //set to true if using "active high" relay, set to false if using "active low" relay
-boolean isDebugEnabled=false;    // enable or disable debug in this example
+boolean isDebugEnabled=true;    // enable or disable debug in this example
 boolean isPin4Pump =false;  //set to true if you add an additional relay to pin4 and use as pump or master valve.

 //set global variables
@@ -241,6 +241,7 @@
 const char* pin4PumpStatus= "off";
 boolean doUpdate = false;
 boolean doPumpUpdate = false;
+long pumpOffDelay = 0; // set number of minutes to delay turning pump or master valve off after last zone has finished running

 void setup()
 {
@@ -416,22 +417,16 @@
   scheduleUpdate();
   schedulePumpUpdate();
 }
+
 void toggleOff() {
   digitalWrite(relay[trafficCop], relayOff);
   smartthing.shieldSetLED(0, 0, 1);
   queue[trafficCop]=0; //remove relay from from queue
-  if (isConfigPump== true) {
-    if (maxvalue() ==0) {
-      digitalWrite(relay[16], relayOff);
-      configPumpStatus = "off";
-    }
-  }
-  if (isPin4Pump) {
-    if (maxvalue() ==0) {
-      digitalWrite(pin4Relay, relayOff);
-      pin4PumpStatus = "off";
-    }
-  }
+  if (maxvalue() ==0) {
+    if (isConfigPump || isPin4Pump) {
+      int8_t pumpOffEvent = t.after(pumpOffDelay*60L*1000L, pumpOff);  //turns off pump after delay
+    }
+  }
   trafficCop=0; //ready to check queue or watch for new commmonds
   scheduleUpdate();
   schedulePumpUpdate();
@@ -445,15 +440,9 @@
     digitalWrite(relay[i], relayOff);
     i++;
   }
-   if (isConfigPump) {
-     digitalWrite(relay[16], relayOff);
-     configPumpStatus="off";
+  if (isConfigPump || isPin4Pump) {
+    int8_t pumpOffEvent = t.after(pumpOffDelay*60L*1000L, pumpOff);  //turns off pump after delay
   }
-
-  if (isPin4Pump) {
-    digitalWrite(pin4Relay, relayOff);
-    pin4PumpStatus="off";
-  }
   smartthing.shieldSetLED(0, 0, 1);
   trafficCop=0;
   scheduleUpdate();
@@ -469,6 +458,7 @@
       digitalWrite(pin4Relay, relayOff);
       pin4PumpStatus="off";
   }
+  schedulePumpUpdate();
 }

 void pumpOn() {
@@ -480,6 +470,7 @@
       digitalWrite(pin4Relay, relayOn);
       pin4PumpStatus = "on";
   }
+  schedulePumpUpdate();
 }

 void timeToUpdate() {


Fix typo.

Fix typo.

--- webserver.ino
+++ webserver.ino
@@ -93,7 +93,7 @@
           return;
         }
       }
-      WIFIhostname= newHostName;
+      WIFIhostname = newHostName;
       hostNameChanged = true;
       writeWifiDataToEEPROM();
       webServer.send( 200, "text/plain", "Hostname set to " + WIFIhostname);


removed repetitive/never-active code

removed repetitive/never-active code

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -60,8 +60,6 @@
 		delay(20000);
 	}

-	// Make our heartbeat LED blink at a normal rate again if we were panicking earlier.
-	Heartbeat::start();
 }

 void loop(){


Changed mapping of dial to be able to place it with 12 up on whichever direction is wanted

--- neoclock.ino
+++ neoclock.ino
@@ -46,6 +46,12 @@
     182,184,186,188,191,193,195,197,199,202,204,206,209,211,213,215,
     218,220,223,225,227,230,232,235,237,240,242,245,247,250,252,255
 };
+
+//  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
+const uint8_t LEDmap[] = {
+    8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7
+};
+
 // Parameter 1 = number of pixels in strip
 // Parameter 2 = pin number (most are valid)
 //               note: if not specified, D2 is selected for you.
@@ -75,8 +81,8 @@
 uint32_t minute_color      = strip.Color ( 20, 0, 0);
 uint32_t hour_color        = strip.Color (  0, 20,  0);

-uint32_t off_color    = strip.Color (  0,  0,  2);
-uint32_t off_color_strong    = strip.Color (  0,  0,  1);
+uint32_t off_color    = strip.Color (  1,  1,  1);
+uint32_t off_color_strong    = strip.Color (  0,  1,  0);

 /* TODO 0.0 to 1.0 percent between current and next value. for color fading */
@@ -164,7 +170,7 @@

 void ClockSegments::add_color (uint8_t position, uint32_t color)
 {
-  uint32_t blended_color = blend (strip.getPixelColor (position), color);
+  uint32_t blended_color = blend (strip.getPixelColor (LEDmap[position]), color);

   /* Gamma mapping */
   uint8_t r,b,g;
@@ -173,7 +179,7 @@
   g = (uint8_t)(blended_color >>  8),
   b = (uint8_t)(blended_color >>  0);

-  strip.setPixelColor (position, blended_color);
+  strip.setPixelColor (LEDmap[position], blended_color);
 }

@@ -200,9 +206,9 @@
 {
   for(uint16_t i=0; i<strip.numPixels (); i++) {
     if ((i == 0) || (i == 3) || (i == 6) || (i == 9)) {
-      strip.setPixelColor (i, off_color_strong);
+      strip.setPixelColor (LEDmap[i], off_color_strong);
     } else {
-    strip.setPixelColor (i, off_color);
+    strip.setPixelColor (LEDmap[i], off_color);
     }
   }
 }
@@ -226,6 +232,10 @@
   strip.begin ();
   strip.show (); // Initialize all pixels to 'off'

+  // Dim on board LED
+  RGB.control(true);
+  RGB.color(50, 0, 0);
+
   request.hostname = "www.timeapi.org";
   request.port = 80;
   request.path = "/utc/now";
@@ -239,40 +249,3 @@
 }

-
-
-// Fill the dots one after the other with a color
-void colorWipe(uint32_t c, uint32_t wait) {
-  for(uint16_t i=0; i<strip.numPixels(); i++) {
-      strip.setPixelColor(i, c);
-      strip.show();
-      delay(wait);
-  }
-}
-
-// Slightly different, this makes the rainbow equally distributed throughout
-void rainbowCycle(uint8_t wait) {
-  uint16_t i, j;
-
-  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
-    for(i=0; i< strip.numPixels(); i++) {
-      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
-    }
-    strip.show();
-    delay(wait);
-  }
-}
-
-// Input a value 0 to 255 to get a color value.
-// The colours are a transition r - g - b - back to r.
-uint32_t Wheel(byte WheelPos) {
-  if(WheelPos < 85) {
-   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
-  } else if(WheelPos < 170) {
-   WheelPos -= 85;
-   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
-  } else {
-   WheelPos -= 170;
-   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
-  }
-}


Add defines to change  inter frame gap and CSMA random wait time feature: -add inter frame gap define -add CSMA random wait time define

--- exapmles/iprs485.ino
+++ exapmles/iprs485.ino
@@ -9,9 +9,11 @@
 #define IPLENMAX 9999

 //node settings
-#define IPADDR 0x020BA8C0//192.168.11.*
+#define IPADDR 0x050BA8C0//192.168.11.*
 #define BRADDR 0xFF0BA8C0//broadcast
-#define NODENAME "node1"
+#define NODENAME "node4"
+#define INTERFRAMEGAP 1000//us
+#define CSMAWAIT 60//ms, max wait

 #define DEBUG 0

@@ -461,7 +463,7 @@
 	ct = 0;
 	Serial.print("thread_read start\n");
 	while(1){
-		utimer_set(&timeout,1000);//wait for data
+		utimer_set(&timeout,INTERFRAMEGAP);//wait for data
 		PT_WAIT_UNTIL(pt,Serial3.available() || utimer_expired(&timeout));
 		if (utimer_expired(&timeout)){//timeout and reset
 			#if DEBUG
@@ -472,7 +474,7 @@
 			packet_len = 0;
 			ip_len=IPLENMAX;
 			if (sendque_lest > 0){//if there are any data on queue
-				utimer_set(&timeout3,(random(0,1000)*100));//random wait
+				utimer_set(&timeout3,(random(0,1000)*CSMAWAIT));//random wait
 				PT_WAIT_UNTIL(pt,Serial3.available() || utimer_expired(&timeout3));
 				if (Serial3.available()){
 					continue;


добавил строчку

добавил строчку

--- sms_thermo/sms_thermo.ino
+++ sms_thermo/sms_thermo.ino
@@ -5,6 +5,7 @@
 #include <DallasTemperature.h>
 #include <SoftwareSerial.h>
 #include <math.h>
+

 SoftwareSerial SIM900 (10, 11);                   //SIM900 is connected to 10 & 11 PINs RX, TX


s/CLOCK_STOP/NONE/g

--- moros/moros.ino
+++ moros/moros.ino
@@ -12,7 +12,7 @@
 #include <SPI.h>
 #include <TFT.h>

-#define CLOCK_STOP -1
+#define NONE -1

 #define DISPLAY_FONT_SIZE 7
 #define CHAR_HEIGHT_PX DISPLAY_FONT_SIZE * 10
@@ -23,8 +23,8 @@
 #define INITIAL_TIME_MS 5000

-int active_player = CLOCK_STOP;
-volatile int button_pressed = CLOCK_STOP;
+int active_player = NONE;
+volatile int button_pressed = NONE;

 inline void handle_button_press(int button) {
   button_pressed = button;
@@ -104,10 +104,10 @@
     loop_count++;
   }
  // Serial.println(button_pressed);
-  if (active_player != CLOCK_STOP) {
+  if (active_player != NONE) {
     if (players[active_player].time_remaining_ms <= 0) {
-      active_player = CLOCK_STOP;
-      button_pressed = CLOCK_STOP;
+      active_player = NONE;
+      button_pressed = NONE;
       return;
     }
     players[active_player].time_remaining_ms -= (millis() - players[active_player].last_update_ms);
@@ -129,7 +129,7 @@
     }
     strncpy(players[active_player].display_time, timea, sizeof(players[active_player].display_time));
   }
-  if ((active_player == CLOCK_STOP || button_pressed == active_player) && button_pressed != CLOCK_STOP)   {
+  if ((active_player == NONE || button_pressed == active_player) && button_pressed != NONE)   {
     Serial.print("pre button_pressed: ");
     Serial.println(button_pressed);
     Serial.print("pre active_player: ");


commented out drum notes

commented out drum notes

--- linkinhart/linkinhart.ino
+++ linkinhart/linkinhart.ino
@@ -17,6 +17,12 @@
 int noteB = 64;
 int noteC = 67;
 int noteD = 72;
+
+// Drums
+//int noteA = 36;
+//int noteB = 42;
+//int noteC = 40;
+//int noteD = 39;

 int inputA = 5;
 int inputB = 6;


Minor change to setup order for aesthetics.

--- pHPhotometerBTLE.ino
+++ pHPhotometerBTLE.ino
@@ -192,6 +192,10 @@
   setupPhotometer();
   Serial.println(F("OK"));

+  Serial.print(F("Conductivity Probe Setup..."));
+  condProbe.begin(&Serial3);
+  Serial.println(F("OK"));
+
   Serial.print(F("BTLE Hardware Setup..."));
   btle = setupBTLE("pH-1");
   Serial.println(F("OK"));
@@ -199,10 +203,6 @@
   Serial.print(F("BTLE Handlers Setup..."));
   setupBTLEHandlers();
   Serial.println(F("OK"));
-
-  Serial.print(F("Conductivity Probe Setup..."));
-  condProbe.begin(&Serial3);
-  Serial.println(F("OK"));
 }

 void loop(){


Link to humble object

Link to humble object

--- arduino/sainsmart.ino
+++ arduino/sainsmart.ino
@@ -1,6 +1,9 @@
 #include <Servo.h>
 #include "../calibration.hh"
 #include "../controllerbase.hh"
+
+
+// Humble Object connecting device to tested code http://xunitpatterns.com/Humble%20Object.html

 class Controller: public ControllerBase
 {


Reset laser events count when turning autosend on

WALT device was sending the timestamp of the last laser transition from before
turning autosend on. It was already dealt with in
7ca4b10a1860e2068dab8ac54093dbe1293d72d1 on Android side but there is no need
to send this timestamp anyway.

--- arduino/walt/walt.ino
+++ arduino/walt/walt.ino
@@ -344,6 +344,7 @@
     screen.count = 0;
   } else if (cmd == CMD_AUTO_LASER_ON) {
     laser.autosend = true;
+    laser.count = 0;
     send_ack(CMD_AUTO_LASER_ON);
   } else if (cmd == CMD_AUTO_LASER_OFF) {
     laser.autosend = false;


Delete 28kVersion.ino

Delete 28kVersion.ino

--- 28kVersion.ino
+++ 28kVersion.ino
@@ -1,697 +0,0 @@
-//Arduino code for the ESP8226 Module running the 9.2.2 firmware at 9600bps by David Watts
-//youtube.com/mrdavidjwatts
-#include "U8glib.h"
-#include "SoftwareSerial.h"
-
-U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// Display which does not send AC
-SoftwareSerial esp8266Module(10, 11); // RX, TX
-
-// Misc variables
-int statusLED = 13;
-// Store network credentials variables
-int epWifiStart;
-int epPasswordStart;
-// Inputting text variables
-int colNum = 1;
-int rowNum = 1;
-char selectedChar;
-char allChars[4][26] = {
-	{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'},
-	{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'},
-	{32,'!','"','#','$','%','&','\'','(',')','*','+','`','-','_','.','\\','/',']','[','^','}','{','|','~',':'},
-	{'0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5'}
-};
-int cursorPos = 1;
-String cursor = "  <";
-// Display only variables
-char* mainTitles[] = {"ESP8266","Connect to Wifi", "Find Networks", "Run"};
-char* runningTitles[] = {"Running","Status:", "Network:","Time:", "Date:", "Loops:", "Temperature"};
-// Output variables
-int loopNum = 0; // how many successful requests have we made?
-String runningValues[7] = {"","","","","","",""};
-String RecData; // Data returned
-// Program flow variables
-bool connected = false;
-bool breakOut = false;
-enum States {
-	main,
-	connect,
-	findWifi,
-	selectWifi,
-	enterPassword,
-	run
-
-};
-States state = main;
-bool runningFunctionNow = 0;
-int wifiStatus = 1; // tracking the module status
-// Finding networks variables
-String password; // important
-String network; // important
-String DiscoveredNetworks[15] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
-int selectedNetwork = 0;
-String tempWifi;
-int wifiNumber = 0;
-int foundNetworks = 0;
-bool foundWifi  = false;
-unsigned long functionStartTime; //used to store the time a function started
-const unsigned long timeout = 8000; //the timeout/maximum time in milliseconds
-
-
-void setup() {
-	delay(5000);
-	//Serial.begin(9600);
-	esp8266Module.begin(9600); // Starting up the Serial for the ESP8266
-	delay(5000);
-	pinMode(statusLED, OUTPUT);
-	pinMode(7, INPUT); // Getting the input buttons ready
-	pinMode(6, INPUT);
-	pinMode(5, INPUT);
-	pinMode(4, INPUT);
-	// Finding out if we have stored network credentials in EEPROM
-
-}
-
-void loop() {
-	// Start Display Stuff
-	if(breakOut == false){
-		u8g.firstPage();
-		do {
-			displayShow();
-		} while ( u8g.nextPage() );
-
-	}
-	// End Display Stuff
-
-	// Running the menu
-	menu();
-
-	// if we selected run then let the ESP8266 fly
-	if (state == run)
-	{
-		runEsp8266("www.davidjwatts.com", "/arduino/esp8266.php");
-	}
-	// end flying ESP8266
-
-
-}
-
-// Our display function, display and font dependant, feel free to mess around here
-void displayShow() {
-	int posText = 23;
-	switch (state) {
-		case main:
-		u8g.setFont(u8g_font_8x13B);
-		u8g.setPrintPos(0, 13);
-		u8g.print(mainTitles[0]);
-		for(int i = 1; i < 4; i++){
-			u8g.setFont(u8g_font_5x8);
-			u8g.setPrintPos(0, posText);
-			if(cursorPos == i){
-				u8g.print(mainTitles[i] + cursor);
-			}
-			else
-			{
-				u8g.print(mainTitles[i]);
-			}
-			posText = posText + 8;
-		}
-		break;
-		case connect:
-		u8g.setFont(u8g_font_8x13B);
-		u8g.setPrintPos(0, 13);
-		u8g.print("Connect to Wifi");
-		u8g.setFont(u8g_font_5x8);
-		u8g.setPrintPos(0, 26);
-		if(network == ""){
-			u8g.print("No credentials");
-		}
-		else
-		{
-			if(password == ""){
-				//u8g.print("No stored credentials");
-			}
-			else
-			{
-				//u8g.print("Connect to?");
-				u8g.setPrintPos(0, 36);
-				u8g.print(network);
-			}
-
-		}
-		break;
-		case findWifi:
-		u8g.setFont(u8g_font_8x13B);
-		u8g.setPrintPos(0, 13);
-		u8g.print("Finding Network");
-		u8g.setFont(u8g_font_5x8);
-		u8g.setPrintPos(0, 26);
-		//u8g.print("Be patient...");
-		break;
-		case selectWifi:
-		u8g.setFont(u8g_font_8x13B);
-		u8g.setPrintPos(0, 13);
-		u8g.print("Select Network");
-		u8g.setFont(u8g_font_5x8);
-		//////up///////// top    left    right
-		u8g.drawTriangle(64,20, 58,26, 70,26);
-		u8g.setPrintPos(0, 36);
-		u8g.print(DiscoveredNetworks[cursorPos]);
-		//////down/////// top    left    right
-		u8g.drawTriangle(64,50, 58,44, 70,44);
-		break;
-		case enterPassword:
-		u8g.setFont(u8g_font_5x8);
-		u8g.setPrintPos(0, 10);
-		u8g.print(network);
-		u8g.setFont(u8g_font_helvB14);
-		u8g.setPrintPos(60, 30);
-		u8g.print(selectedChar);
-		u8g.setFont(u8g_font_5x8);
-		u8g.setPrintPos(0, 50);
-		u8g.print(password);
-		break;
-		case run:
-		runningValues[2] = network;
-		runningValues[3] = splitToVal(RecData, "+", "@");
-		runningValues[4] = splitToVal(RecData, "@", "|");
-		runningValues[5] = String(loopNum);
-		runningValues[6] = splitToVal(RecData, "$", "^");
-		//WeatherVal = splitToVal(RecData, "^", "~");
-		u8g.setFont(u8g_font_8x13B);
-		u8g.setPrintPos(0, 13);
-		u8g.print(runningTitles[0]);
-		for(int i = 1; i < 6; i++){
-			u8g.setFont(u8g_font_5x8);
-			u8g.setPrintPos(0, posText);
-			u8g.print(runningTitles[i]);
-			String valuetemp = runningTitles[i];
-			u8g.setPrintPos((valuetemp.length() * 5) + 5, posText);
-			u8g.print(runningValues[i]);
-			posText = posText + 8;
-		}
-
-		break;
-	}
-
-
-}
-
-// Menu function for selecting modes and states
-void menu(){
-	switch (state) {
-		case main:
-		wifiStatus = 0;
-		if(digitalRead(7) == HIGH){
-			if(cursorPos < 3){
-				cursorPos++;
-			}
-			else{
-				cursorPos = 1;
-			}
-		}
-		if(digitalRead(5) == HIGH){
-			switch(cursorPos) {
-				case 1:
-				state=connect;
-				break;
-				case 2:
-				state=findWifi;
-				break;
-				case 3:
-				state=run;
-				break;
-			}
-
-		}
-		break;
-		case connect:
-		if(digitalRead(5) == HIGH){
-
-
-			if (network != "" && connected == false)
-			{
-
-			if (password == ""){
-			state = enterPassword;
-			}
-			else
-			{
-			connectToWifi();
-			}
-			}
-
-			}
-
-
-		if(digitalRead(4) == HIGH){
-			state = main;
-
-		}
-		break;
-		case findWifi:
-		if(runningFunctionNow == 0){
-			functionStartTime = millis();
-			foundNetworks = 0;
-			findWifiNetworks();
-		}
-		else
-		{
-			findWifiNetworks();
-		}
-
-		if(digitalRead(4) == HIGH){
-			state = main;
-		}
-		break;
-		case selectWifi:
-		if(digitalRead(7) == HIGH){
-			//Serial.println(cursorPos);
-			if(cursorPos < foundNetworks-1){
-				cursorPos++;
-			}
-			else{
-				cursorPos = 0;
-			}
-		}
-		if(digitalRead(4) == HIGH){
-			state = main;
-		}
-		if(digitalRead(5) == HIGH){
-			network = DiscoveredNetworks[cursorPos];
-			state = enterPassword;
-		}
-		break;
-		case enterPassword:
-		selectedChar = allChars[rowNum][colNum];
-		if(digitalRead(7) == HIGH){
-			if(rowNum < 3){
-				rowNum++;
-			}
-			else{
-				rowNum = 0;
-			}
-		}
-		if(digitalRead(6) == HIGH){
-
-			if(colNum < 25){
-				colNum++;
-			}
-			else{
-				colNum = 0;
-			}
-		}
-		if(digitalRead(5) == HIGH){
-			password += selectedChar;
-		}
-		if(digitalRead(4) == HIGH){
-			state = main;
-		}
-		break;
-		case run:
-		if(digitalRead(4) == HIGH){
-			state = main;
-		}
-		break;
-        default:
-      // statements
-        break;
-
-	}
-}
-
-
-
-// END STORED DETAILS CHECK
-
-
-// END READ DETAILS FROM EEPROM
-
-// START FIND WIFI NETWORKS
-bool findWifiNetworks() {
-	breakOut = true;
-
-	char character;
-	if (runningFunctionNow == 1 && wifiNumber < 16) {
-		if (esp8266Module.available() > 0) {
-			character = esp8266Module.read();
-
-
-			if(!foundWifi){
-				//Serial.write(temp);
-				if (character == ':') {
-					foundWifi = true;
-				}
-			}
-			else{
-				if (character == '\n') {
-					DiscoveredNetworks[wifiNumber] = splitWifi(tempWifi);
-					tempWifi = "";
-					wifiNumber++;
-					foundNetworks++;
-					foundWifi = false;
-				}
-				else {
-					tempWifi.concat(character);
-				}
-			}
-		}
-
-
-	}
-	else {
-		if (wifiNumber < 1 && runningFunctionNow == 0) {
-			runningFunctionNow = 1;
-			esp8266Module.println("AT+CWLAP");
-		}
-
-	}
-	if((millis() - functionStartTime) > timeout){
-		if(wifiNumber > 0){
-			runningFunctionNow = 0;
-			breakOut = false;
-			selectedNetwork = 0;
-			functionStartTime = 0;
-			password = "";
-			network = "";
-			wifiNumber = 0;
-			foundWifi = false;
-			tempWifi = "";
-			digitalWrite(statusLED, LOW);
-			state = selectWifi;
-			return true;
-		}
-		else{
-			return false;
-		}
-	}
-
-}
-// END FIND WIFI NETWORKS
-
-// SPLIT UP STRINGS --- This is not ready
-String splitWifi(String inputWifi) {
-	int firstListItem = inputWifi.indexOf("\"");
-	int secondListItem = inputWifi.indexOf("\"", firstListItem + 1 );
-	return inputWifi.substring(firstListItem + 1, secondListItem);
-
-}
-// END SPLIT UP STRINGS
-
-// MAIN ESP8266 FUNCTION
-void runEsp8266(String website, String page) {
-	// 0 need to reset or beginning of loop
-	// 1 reset complete check wifi mode
-	// 2 wifi mode is 3, now check network connection
-	// 3 If not connected connect to network
-	// 4 request page from server
-	// 5 unlink from server after request
-	// 6 close network connection
-	switch (wifiStatus) {
-		case 0:    // 0 need to reset or beginning of loop
-//Serial.println(F("TRYING esp8266Reset"));
-		esp8266Reset();
-		break;
-		case 1:    // 1 reset complete check wifi mode
-		//Serial.println(F("TRYING changeWifiMode"));
-		changeWifiMode();
-		break;
-		case 2:    // 2 wifi mode is 3, now check network connection
-		//Serial.println(F("TRYING checkWifiStatus"));
-		checkWifiStatus();
-		break;
-		case 3:    // 3 If not connected connect to network
-		//Serial.println(F("TRYING connectToWifi"));
-		//connectToWifi();
-		connectToWifi("---", "---");
-		break;
-		case 4:    // 4 request page from server
-		//Serial.println(F("TRYING getPage"));
-		getPage(website, page);
-		//getPage(website, page, "?num=", "3", "&num2=", "2000");
-		break;
-		case 5:    // 5 unlink from server after request
-		//Serial.println(F("TRYING unlinkPage"));
-		unlinkPage();
-		break;
-        default:
-        // statements
-		break;
-	}
-}
-// END MAIN ESP8266 FUNCTION
-
-// 0 - RESET
-bool esp8266Reset() {
-	esp8266Module.println("AT+RST");
-	delay(7000);
-	if (esp8266Module.find("OK"))
-	{
-		runningValues[1] = "-RESET-";
-		wifiStatus = 1;
-		return true;
-	}
-	else
-	{
-		runningValues[1] = "-FAILED-";
-		wifiStatus = 0;
-		return false;
-	}
-}
-// END RESET
-
-// 1 - CHANGE MODE
-bool changeWifiMode()
-{
-	esp8266Module.println("AT+CWMODE?");
-	delay(5000);
-	if (esp8266Module.find("3"))
-	{
-		runningValues[1] = "Mode is 3";
-		wifiStatus = 2;
-		return true;
-	}
-	else
-	{
-		esp8266Module.println("AT+CWMODE=3");
-		delay(5000);
-		if (esp8266Module.find("no change") || esp8266Module.find("OK"))
-		{
-			runningValues[1]= "Mode is 3";
-			wifiStatus = 2;
-			return true;
-		}
-		else
-		{
-			//val1 = F("Wifi Mode failed");
-			wifiStatus = 0;
-			return false;
-		}
-	}
-
-}
-// END CHANGE MODE
-
-// 2 - CHECK WIFI NETWORK STATUS
-bool checkWifiStatus() {
-	esp8266Module.println("AT+CWJAP?");
-	delay(5000);
-	if (esp8266Module.find(":")) {
-		//Serial.println(F("WIFI NETWORK CONNECTED"));
-		String tempor = esp8266Module.readStringUntil('\n');
-		tempor.replace("\"", "");
-		network = tempor;
-		runningValues[1] = tempor;
-		wifiStatus = 4;
-		return true;
-	}
-	else
-	{
-		wifiStatus = 3;
-		return false;
-	}
-}
-// END CHECK WIFI NETWORK STATUS
-
-// 3 - CONNECT TO WIFI
-bool connectToWifi() {
-	if (network == "" || password == "")
-	{
-		state = findWifi;
-	}
-	else
-	{
-
-		String cmd = "AT+CWJAP=\"";
-		cmd += network;
-		cmd += F("\",\"");
-		cmd += password;
-		cmd += F("\"");
-		esp8266Module.println(cmd);
-		delay(5000);
-		if (esp8266Module.find("OK"))
-		{
-			//Serial.println(F("CONNECTED TO WIFI"));
-
-			runningValues[1] = "CONNECTED";
-			wifiStatus = 4;
-			return true;
-			if(state == connect){
-			state = main;
-		}
-		}
-		else
-		{
-			wifiStatus = 0;
-			return false;
-		}
-	}
-}
-// optional function that accepts the network ID and password as variables
-bool connectToWifi(String networkId, String networkPassword) {
-	network = networkId;
-	String cmd = "AT+CWJAP=\"";
-	cmd += networkId;
-	cmd += F("\",\"");
-	cmd += networkPassword;
-	cmd += F("\"");
-	esp8266Module.println(cmd);
-	delay(5000);
-	if (esp8266Module.find("OK"))
-	{
-		//Serial.println(F("CONNECTED TO WIFI"));
-
-		runningValues[1] = "CONNECTED";
-		wifiStatus = 4;
-		return true;
-		if(state == connect){
-			state = main;
-		}
-	}
-	else
-	{
-		wifiStatus = 0;
-		return false;
-	}
-}
-// END CONNECT TO WIFI NETWORK
-
-// 4 - GET PAGE
-bool getPage(String website, String page) {
-	//runningValues[1] = "";
-	//Serial.println(website);
-	String cmd = "AT+CIPSTART=\"TCP\",\"";
-	cmd += website;
-	cmd += F("\",80");
-	esp8266Module.println(cmd);
-	delay(5000);
-	if (esp8266Module.find("Linked"))
-	{
-		//Serial.print(F("Connected to server"));
-
-	}
-	cmd =  F("GET ");
-	cmd += page;
-	cmd += F("?num=");  //construct the http GET request
-	cmd += F("1");
-	cmd += F("&weather=");
-	cmd += F("2644668");
-	cmd += F(" HTTP/1.0\r\n");
-	cmd += F("Host:");
-	cmd += website;
-	cmd += F("\r\n\r\n");
-	Serial.println(cmd);
-	esp8266Module.print(F("AT+CIPSEND="));
-	esp8266Module.println(cmd.length());
-	Serial.println(cmd.length());
-
-	if (esp8266Module.find(">"))
-	{
-		//Serial.println(F("found > prompt - issuing GET request"));
-		esp8266Module.println(cmd);
-	}
-	else
-	{
-		wifiStatus = 5;
-		//Serial.println(F("No '>' prompt received after AT+CPISEND"));
-		runningValues[1] = F("Failed request");
-		return false;
-	}
-
-	while (esp8266Module.available() > 0)
-	{
-		esp8266Module.read();
-	}
-
-	if (esp8266Module.find("*")) {
-		String tempMsg = esp8266Module.readStringUntil('\n');
-		RecData = tempMsg;
-		Serial.println(tempMsg);
-		wifiStatus = 5;
-		return true;
-	}
-	else {
-		wifiStatus = 5;
-		return false;
-	}
-
-}
-
-// optional getPage function that accepts user variables
-
-// END GET PAGE
-
-// 5 - UNLINK
-bool unlinkPage() {
-	esp8266Module.println(F("AT+CIPCLOSE"));
-	delay(5000);
-	if (esp8266Module.find("Unlink"))
-	{
-		runningValues[1] = F("UNLINKED");
-		wifiStatus = 0;
-		loopNum++;
-		return true;
-	}
-	else
-	{
-		wifiStatus = 4;
-		return false;
-	}
-}
-// END UNLINK
-
-// 6 - CLOSE NETWORK  --- This is not ready
-bool closeNetwork() {
-	esp8266Module.println(F("AT+CWQAP"));
-	delay(5000);
-	if (esp8266Module.find("OK"))
-	{
-		runningValues[1] = "DISCONNECTED";
-		wifiStatus = 0;
-		return true;
-	}
-	else
-	{
-		wifiStatus = 4;
-		return false;
-	}
-}
-// END CLOSE NETWORK
-
-// SPLIT UP STRINGS
-String splitToVal(String inputString, String delimiter, String endChar) {
-	String tempString = "";
-	int from = 0;
-	int to = 0;
-	for (int i = 0; i < inputString.length(); i++) {
-		if (inputString.substring(i, i + 1) == delimiter) {
-			from = i + 1;
-		}
-		if (inputString.substring(i, i + 1) == endChar) {
-			to = i;
-		}
-	}
-	tempString = inputString.substring(from, to);
-	return tempString;
-}
-// END SPLIT UP STRINGS


prototype-3: added test for rotation speed

--- prototype/prototype-3/prototype-3.ino
+++ prototype/prototype-3/prototype-3.ino
@@ -1,5 +1,6 @@
-//#define COMPONENT_TESTING_ROTATION_COAST
-//#define KILLALL
+//#define COMPONENT_TEST_MOTOR_COAST
+//#define COMPONENT_TEST_MOTOR_TIME
+//#define KILLALL // Uncomment this to kill the system, and stop all components

 #define MOTOR_1_PIN 12
 #define MOTOR_2_PIN 11
@@ -45,9 +46,14 @@
   attachInterrupt(digitalPinToInterrupt(MOTOR_2_INT_PIN), motor2_interrupt, CHANGE);
   //attachInterrupt(digitalPinToInterrupt(MOTOR_3_INT_PIN), motor3_interrupt, CHANGE);

-#ifdef COMPONENT_TESTING_ROTATION_COAST
+#ifdef COMPONENT_TEST_MOTOR_COAST
   component_test_motor_coast(&motor1);
 #endif
+
+#ifdef COMPONENT_TEST_MOTOR_TIME
+  component_test_motor_time(&motor1);
+#endif
+
 }

 void motor1_interrupt() {
@@ -104,7 +110,7 @@
 /*****************************
    COMPONENT TESTING METHODS
  *****************************/
-
+#ifdef COMPONENT_TEST_MOTOR_COAST
 void component_test_motor_coast(Motor* motor) {
   for (int i = 0; i < 20; i++) {
     motor->deg = 0;
@@ -119,3 +125,23 @@
     delay(500);                 // Should be 360 + coast degrees for the motor.
   }
 }
+#endif
+
+#ifdef COMPONENT_TEST_MOTOR_TIME
+void component_test_motor_time(Motor* motor) {
+  for (int i = 0; i < 20; i++) {
+    motor->deg = 0;
+    unsigned long t_start = millis();
+    motor_turn_deg(motor, 360, COUNTERCLOCKWISE);
+    unsigned long t_end = millis();
+    if (motor->deg < 360) {
+      Serial.println("ERROR");
+      exit(0);
+    }
+
+    Serial.println(t_end-t_start);
+    delay(1000);
+  }
+}
+#endif
+


Added bulk erase, deviceID reading, address read and sequence write

--- Arduino-RN2483-programmer.ino
+++ Arduino-RN2483-programmer.ino
@@ -1,11 +1,14 @@
 // Arduino RN2483 programmer
 // Implemented using http://ww1.microchip.com/downloads/en/DeviceDoc/41398B.pdf
+#define SIZE 14
 #define MCLR 4
 #define PGD 5
 #define PGC 6

 int keyseq[] = {0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0};
+int testseq[SIZE] = {0xFE, 0xED, 0xFD, 0xAA, 0xDA, 0x01, 0x01, 0x02, 0x13, 0x37, 0x19, 0x93, 0x4E, 0xFA};
 bool serialcomplete = false;
+bool inLVP = false;
 String input = "";

 void setup()
@@ -45,51 +48,56 @@
 // Enter low-voltage program/verify mode
 void enterLVP()
 {
-  SerialUSB.write("Entering low-voltage program/verify mode\r\n");
-
-  // Pull all programming pins Low
-  digitalWrite(MCLR, LOW);
-  digitalWrite(PGD, LOW);
-  digitalWrite(PGC, LOW);
-
-  // Wait atleast 100ns (P13)
-  delayMicroseconds(1);
-
-  // Set MCLR High then Low
-  digitalWrite(MCLR, HIGH);
-  delayMicroseconds(1);
-  digitalWrite(MCLR, LOW);
-
-  // Wait atleast 1ms (P18)
-  delayMicroseconds(2);
-
-  // Enter key sequence on PGD
-  for (int n = 0; n < 32; n++)
-  {
-    //Lower PGC and write bit to PGD
+  if (not(inLVP))
+  {
+    inLVP = true;
+    SerialUSB.write("Entering low-voltage program/verify mode\r\n");
+
+    // Pull all programming pins Low
+    digitalWrite(MCLR, LOW);
+    digitalWrite(PGD, LOW);
     digitalWrite(PGC, LOW);
-    digitalWrite(PGD, keyseq[n]);
-    delayMicroseconds(1);
-
-    //Raise PGC to send bit
-    digitalWrite(PGC, HIGH);
-    delayMicroseconds(1);
-  }
-  digitalWrite(PGC, LOW);
-
-  // Wait atleast 40ns
-  delayMicroseconds(1);
-
-  // Set MCLR High
-  digitalWrite(MCLR, HIGH);
-
-  // Wait atleast 400us
-  delayMicroseconds(450);
+
+    // Wait atleast 100ns (P13)
+    delayMicroseconds(1);
+
+    // Set MCLR High then Low
+    digitalWrite(MCLR, HIGH);
+    delayMicroseconds(1);
+    digitalWrite(MCLR, LOW);
+
+    // Wait atleast 1ms (P18)
+    delayMicroseconds(2);
+
+    // Enter key sequence on PGD
+    for (int n = 0; n < 32; n++)
+    {
+      //Lower PGC and write bit to PGD
+      digitalWrite(PGC, LOW);
+      digitalWrite(PGD, keyseq[n]);
+      delayMicroseconds(1);
+
+      //Raise PGC to send bit
+      digitalWrite(PGC, HIGH);
+      delayMicroseconds(1);
+    }
+    digitalWrite(PGC, LOW);
+
+    // Wait atleast 40ns
+    delayMicroseconds(1);
+
+    // Set MCLR High
+    digitalWrite(MCLR, HIGH);
+
+    // Wait atleast 400us
+    delayMicroseconds(450);
+  }
 }

 // Exit low-voltage program/verify mode
 void exitLVP()
 {
+  inLVP = false;
   SerialUSB.write("Exiting low-voltage program/verify mode\r\n");
   delayMicroseconds(1);
   digitalWrite(MCLR, LOW);
@@ -202,8 +210,8 @@

       // Wait atleast 40ns (P5A)
       delayMicroseconds(1);
-      SerialUSB.write("Sent 4 command bits and 8 data payload bits\r\nResponse: ");
-      SerialUSB.print(String(response, HEX) + "\r\n");
+      //SerialUSB.write("Sent 4 command bits and 8 data payload bits\r\nResponse: ");
+      //SerialUSB.print(String(response, HEX) + "\r\n");

       return response;
     }
@@ -225,7 +233,7 @@

       // Wait atleast 40ns (P5A)
       delayMicroseconds(1);
-      SerialUSB.write("Sent 4 command bits and 16 data payload bits\r\n");
+      //SerialUSB.write("Sent 4 command bits and 16 data payload bits\r\n");

       return true;
     }
@@ -237,44 +245,100 @@
   }
 }

+// Bulk erase the entire device
 void bulkErase()
 {
-  sendOp(B0000, 0x0E3C);
-  sendOp(B0000, 0x6EF8);
-  sendOp(B0000, 0x0E00);
-  sendOp(B0000, 0x6EF7);
-  sendOp(B0000, 0x0E05);
-  sendOp(B0000, 0x6EF6);
-  sendOp(B1100, 0x0F0F);
-  sendOp(B0000, 0x0E3C);
-  sendOp(B0000, 0x6EF8);
-  sendOp(B0000, 0x0E00);
-  sendOp(B0000, 0x6EF7);
-  sendOp(B0000, 0x0E04);
-  sendOp(B0000, 0x6EF6);
-  sendOp(B1100, 0x8F8F);
+  // Write 0F0F to 3C0005h
+  writeAddressConfig(0x3C, 0x00, 0x05, 0x0F0F);
+  // Write 8F8F to 3C0004h
+  writeAddressConfig(0x3C, 0x00, 0x04, 0x8F8F);
   sendOp(B0000, 0x0000);
   sendOp(B0000, 0x0000);
   // Wait atleast 15ms (P11) to let the erase complete
-  delay(15);
-}
-
-void readDeviceID(){
-      sendOp(B0000, 0x0E3F);
-      sendOp(B0000, 0x6EF8);
-      sendOp(B0000, 0x0EFF);
-      sendOp(B0000, 0x6EF7);
-      sendOp(B0000, 0x0EFE);
-      sendOp(B0000, 0x6EF6);
-      sendOp(B1001, 0x0000);
-
-      sendOp(B0000, 0x0E3F);
-      sendOp(B0000, 0x6EF8);
-      sendOp(B0000, 0x0EFF);
-      sendOp(B0000, 0x6EF7);
-      sendOp(B0000, 0x0EFF);
-      sendOp(B0000, 0x6EF6);
-      sendOp(B1001, 0x0000);
+  delay(20);
+}
+
+// Print device IDs on serial
+void readDeviceID()
+{
+  int DEVID1 = readAddress(0x3F, 0xFF, 0xFE);
+  int DEVID2 = readAddress(0x3F, 0xFF, 0xFF);
+  SerialUSB.print("DEVID1: " + String(DEVID1, HEX) + "h\r\n");
+  SerialUSB.print("DEVID2: " + String(DEVID2, HEX) + "h\r\n");
+}
+
+// Sets the TBLPTR to the address to be read/written
+void setTBLPTR(int addru, int addrh, int addrl)
+{
+  sendOp(B0000, 0x0E00 + addru); // MOVLW <Addr[21:16]>
+  sendOp(B0000, 0x6EF8);         // MOVWF TBLPTRU
+  sendOp(B0000, 0x0E00 + addrh); // MOVLW <Addr[15:8]>
+  sendOp(B0000, 0x6EF7);         // MOVWF TBLPTRH
+  sendOp(B0000, 0x0E00 + addrl); // MOVLW <Addr[7:0]>
+  sendOp(B0000, 0x6EF6);         // MOVWF TBLPTRL
+}
+
+// Read value at address
+int readAddress(int addru, int addrh, int addrl)
+{
+  setTBLPTR(addru, addrh, addrl);
+  return sendOp(B1001, 0x0000); // TBLRD *+
+}
+
+// Write value to address in config block
+void writeAddressConfig(int addru, int addrh, int addrl, int value)
+{
+  setTBLPTR(addru, addrh, addrl);
+  sendOp(B1100, value);
+}
+
+// Writes a sequence of bytes into the code memmory
+// bytes.length <= 64, bytes[n] <= 0xFFFF
+void writeCodeSequence(int addru, int addrh, int addrl, int bytes[])
+{
+  int LoopCount = 0;
+
+  // Direct access to code memory
+  sendOp(B0000, 0x8EA6); // BSF EECON1, EEPGD
+  sendOp(B0000, 0x9CA6); // BCF EECON1, CFGS
+  sendOp(B0000, 0x84A6); // BSF EECON1, WREN
+
+  // Point to row to write.
+  setTBLPTR(addru, addrh, addrl);
+
+  // Load write buffer. Repeat for all but the last two bytes.
+  for (int n = 0; n < SIZE - 2; n = n + 2)
+  {
+    sendOp(B1101, (bytes[n + 1] << 8) + bytes[n]);
+  }
+
+  // Load write buffer for last two bytes and start programming
+  sendOp(B1111, (bytes[SIZE - 2] << 8) + bytes[SIZE - 1]);
+
+  // Send NOP and Hold 4th PGC HIGH for atleast 1ms (P9)
+  digitalWrite(PGD, LOW);
+  for (int n = 0; n < 4; n++)
+  {
+    digitalWrite(PGC, LOW);
+    delayMicroseconds(1);
+    digitalWrite(PGC, HIGH);
+    delayMicroseconds(1);
+  }
+  delay(100);
+
+  // Hold PGC LOW for atleast 200us (P10)
+  digitalWrite(PGC, LOW);
+  delayMicroseconds(400);
+}
+
+void readTest()
+{
+  int response;
+  for (int n = 0; n < SIZE; n++)
+  {
+    response = readAddress(0, 0, n);
+    SerialUSB.print(String(response, HEX) + "\r\n");
+  }
 }

 void loop()
@@ -283,9 +347,12 @@
   {
     char c = SerialUSB.read();

-    if (c == '\n' || c == '\r')
-    {
-      serialcomplete = true;
+    if (c == '\n' || c == '\r' || c == 'X')
+    {
+      if (input != "")
+      {
+        serialcomplete = true;
+      }
       break;
     }
     input += c;
@@ -293,18 +360,34 @@

   if (serialcomplete)
   {
+    int response;
+    enterLVP();
     switch (input.charAt(0))
     {
     case 'W':
+      SerialUSB.print("Bulk erasing\r\n");
+      bulkErase();
+      SerialUSB.print("Writing\r\n");
+      writeCodeSequence(0, 0, 0, testseq);
+      SerialUSB.print("Done writing\r\n");
       break;
     case 'R':
+      SerialUSB.print("Reading\r\n");
+      readTest();
       break;
     case 'D':
+      SerialUSB.print("Reading device ID\r\n");
+      readDeviceID();
       break;
     case 'E':
+      SerialUSB.print("Bulk erasing\r\n");
+      bulkErase();
       break;
     default:
-      SerialUSB.write("Invalid serial command.");
-    }
-  }
-}
+      SerialUSB.write("Invalid serial command\r\n");
+    }
+    serialcomplete = false;
+    input = "";
+    exitLVP();
+  }
+}


Updated due to new platform macro definitions

--- examples/BlinkList/BlinkList.ino
+++ examples/BlinkList/BlinkList.ino
@@ -5,7 +5,6 @@
 #undef min
 #undef max

-#include <etl_arduino.h> // Contains platform macros for Arduino.
 #include <list.h>
 #include <container.h>


Disable BNO-055 if present My MS5637 sensor is on a carrier board right next to a BNO-055 9-DOF sensor. By default it is active and dissipates enough power to raise the baseline temperature sensed by almost 2 degrees C - putting this unused sensor in power suspend mode alleviates the problem.

--- firmware/environmental-array.ino
+++ firmware/environmental-array.ino
@@ -182,12 +182,68 @@
     return true;
 }

+bool disable9DOFSensor(char outbuf[]) {
+    snprintf(outbuf, 128, "BNO-055:");
+    int BNO_i2c = 0x29;
+    int rcw = 0;
+    const int MAX_VALS = 8;
+    uint8_t vals[MAX_VALS];
+    uint8_t aval = 0x42;
+
+    Wire.beginTransmission(BNO_i2c);
+    rcw = Wire.write(0x00);
+    Wire.endTransmission();
+    rcw = Wire.requestFrom(BNO_i2c, MAX_VALS);
+    if (rcw == MAX_VALS) {
+        for (int i = 0; i < MAX_VALS; i++) {
+            vals[i] = Wire.read();
+        }
+    }
+    snprintf(outbuf, 128, "%s [", outbuf);
+    for (int i = 0; i < MAX_VALS-1; i++) {
+        snprintf(outbuf, 128, "%s%02X ", outbuf, vals[i]);
+    }
+    snprintf(outbuf, 128, "%s%02X]", outbuf, vals[MAX_VALS-1]);
+
+    Wire.beginTransmission(BNO_i2c);
+    rcw = Wire.write(0x3D);
+    Wire.endTransmission();
+    rcw = Wire.requestFrom(BNO_i2c, 1);
+    aval = Wire.read() & 0x0f;
+    snprintf(outbuf, 128, "%s OPR=%02X", outbuf, aval);
+
+    Wire.beginTransmission(BNO_i2c);
+    rcw = Wire.write(0x3E);
+    Wire.endTransmission();
+    rcw = Wire.requestFrom(BNO_i2c, 1);
+    aval = Wire.read() & 0x03;
+    snprintf(outbuf, 128, "%s PWR_prev=%02X", outbuf, aval);
+
+    Wire.beginTransmission(BNO_i2c);
+    rcw = Wire.write(0x3E);
+    rcw = Wire.write(0x02);
+    Wire.endTransmission();
+
+    Wire.beginTransmission(BNO_i2c);
+    rcw = Wire.write(0x3E);
+    Wire.endTransmission();
+    rcw = Wire.requestFrom(BNO_i2c, 1);
+    aval = Wire.read() & 0x03;
+    snprintf(outbuf, 128, "%s PWR_curr=%02X", outbuf, aval);
+
+    return true;
+}
+

 void setup() {
     Serial.begin(serial0DataRate);
     Wire.setSpeed(i2cDataRate);
     Wire.begin();
     delay(500);
+    char outbuf_tester[128];
+    disable9DOFSensor(outbuf_tester);
+    Particle.publish(DataSource, outbuf_tester, 60, PRIVATE);
+    delay(2000);
 }

@@ -196,6 +252,7 @@
 const char header_rht[]  = "RHT03: T_C RH_pct RHT_RAW";
 const char header_pms[]  = "PMS7003: PM_RAW";
 const char header_rht2[] = "RHT03: T_C RH_pct RHT_RAW";
+

 void loop() {
     int prevErrCnt = globalErrorCount;


redesigned analog axis handling; nicely working control

--- uArm.ino
+++ uArm.ino
@@ -259,6 +259,10 @@
 }

 // nunchuk
+#define NUNCHUK_DEADZONE 5
+#define NUNCHUK_SWEEP_SCALE DEFAULT_SERVO_SWEEP_SPEED * 2
+#define NUNCHUK_SWEEP_INCREMENT 5
+
 ArduinoNunchuk nunchuk = ArduinoNunchuk();
 bool nunchukControlMode = false;

@@ -274,13 +278,27 @@
 	messageScrollUpdate(true);
 }

-#define NUNCHUK_DEADZONE 5
-bool nunchukControlIsDeadzone(int x) {
-	if (x >= 127 - NUNCHUK_DEADZONE && x <= 127 + NUNCHUK_DEADZONE)
-		return true;
-	return false;
-}
-#define NUNCHUK_SWEEP_SCALE DEFAULT_SERVO_SWEEP_SPEED * 2
+#define nunchukControlIsDeadzone(x) (x >= 127 - NUNCHUK_DEADZONE && x <= 127 + NUNCHUK_DEADZONE ? true : false)
+void nunchukControlServo(VarSpeedServo &servo, uint8_t servoIndex, MicroViewWidget *widget, uint8_t reading) {
+	uint8_t pos, min_or_max;
+	uint8_t speed;
+
+	if (reading > 127) {
+		min_or_max = config.servoSafe[servoIndex].max;
+		pos = servo.read() + map(reading, 127, 255, 1, NUNCHUK_SWEEP_INCREMENT);
+		pos = (pos < min_or_max ? pos : min_or_max);
+		speed = map(reading, 127, 255, 0, NUNCHUK_SWEEP_SCALE);
+	} else {
+		min_or_max = config.servoSafe[servoIndex].min;
+		pos = servo.read() - map(reading, 127, 0, 1, NUNCHUK_SWEEP_INCREMENT);
+		pos = (pos > min_or_max ? pos : min_or_max);
+		speed = map(reading, 127, 0, 0, NUNCHUK_SWEEP_SCALE);
+	}
+
+	// should this wait or not?
+	//moveServo(servo, widget, pos, speed, true, true);
+	moveServo(servo, widget, pos, speed, false, true);
+}

 void nunchukControlModeUpdate() {
 	uint8_t pos;
@@ -293,37 +311,23 @@
 	else  {
 		if (!nunchukControlMode)
 			return;
-		// if the stick is centered, hold the current position
+
+		// handle X
 		if (nunchukControlIsDeadzone(nunchuk.analogX)) {
-			moveServo(servoRot, widgetRot, servoRot.read(), DEFAULT_SERVO_SWEEP_SPEED, false, true);
-		} else if (nunchuk.analogX < 127) {
-			// rotate
-			pos = config.servoSafe[EEPROM_CONFIG_SERVO_ROT].min;
-			moveServo(servoRot, widgetRot, 30, map(nunchuk.analogX, 127, 0, 0, NUNCHUK_SWEEP_SCALE), false, true);
-			//moveServo(servoRot, widgetRot, 30, DEFAULT_SERVO_SWEEP_SPEED, false, true);
+			moveServo(servoRot, widgetRot, servoRot.read(), DEFAULT_SERVO_SWEEP_SPEED, true, true);
 		} else {
-			pos = config.servoSafe[EEPROM_CONFIG_SERVO_ROT].max;
-			moveServo(servoRot, widgetRot, 120, map(nunchuk.analogX, 127, 255, 0, NUNCHUK_SWEEP_SCALE), false, true);
-			//moveServo(servoRot, widgetRot, 120, DEFAULT_SERVO_SWEEP_SPEED, false, true);
+			nunchukControlServo(servoRot, EEPROM_CONFIG_SERVO_ROT, widgetRot, nunchuk.analogX);
 		}
+
+		// handle Y
 		if (nunchukControlIsDeadzone(nunchuk.analogY)) {
-			moveServo(servoL, widgetL, servoL.read(), DEFAULT_SERVO_SWEEP_SPEED, true, true);
+			moveServo(servoL, widgetL, servoL.read(), DEFAULT_SERVO_SWEEP_SPEED, false, true);
 			moveServo(servoR, widgetR, servoR.read(), DEFAULT_SERVO_SWEEP_SPEED, true, true);
-		} else if (nunchuk.analogY < 127) {
-			if (nunchuk.cButton) {
-				pos = config.servoSafe[EEPROM_CONFIG_SERVO_R].min;
-				moveServo(servoR, widgetR, pos, map(nunchuk.analogY, 127, 0, 0, NUNCHUK_SWEEP_SCALE), false, true);
-			} else {
-				pos = config.servoSafe[EEPROM_CONFIG_SERVO_L].min;
-				moveServo(servoL, widgetL, pos, map(nunchuk.analogY, 127, 0, 0, NUNCHUK_SWEEP_SCALE), false, true);
-			}
 		} else {
 			if (nunchuk.cButton) {
-				pos = config.servoSafe[EEPROM_CONFIG_SERVO_R].max;
-				moveServo(servoR, widgetR, pos, map(nunchuk.analogY, 127, 255, 0, NUNCHUK_SWEEP_SCALE), false, true);
+				nunchukControlServo(servoR, EEPROM_CONFIG_SERVO_R, widgetR, nunchuk.analogY);
 			} else {
-				pos = config.servoSafe[EEPROM_CONFIG_SERVO_L].max;
-				moveServo(servoL, widgetL, pos, map(nunchuk.analogY, 127, 255, 0, NUNCHUK_SWEEP_SCALE), false, true);
+				nunchukControlServo(servoL, EEPROM_CONFIG_SERVO_L, widgetL, nunchuk.analogY);
 			}
 		}
 	}


just a rename of a property

just a rename of a property

--- firmware/src/PoolBuddy.ino
+++ firmware/src/PoolBuddy.ino
@@ -56,7 +56,7 @@
 }

 String water_data() {
-  return String::format("{temp:%f,ph:%f,orp:%f,soc:%f}",celsius,pH,ORP,soc);
+  return String::format("{temperature:%f,ph:%f,orp:%f,soc:%f}",celsius,pH,ORP,soc);
 }

 void getPh() {


Revert to 59c468c4912844c1a20c57da1ec4ca37ade6c13a

--- main.ino
+++ main.ino
@@ -1,37 +1,16 @@
 /*
-Benjamin Matase, AC Li, Mark (Rick) Moyer, Yash Mittal
+Benjamin Matase, AC Li, Mark (Rick) Moyer
 20 February, 2016

 An arduino C program used to control a robot to navigate a simulated Mars
 evironment.

-Servo setup:   brown-  gnd
-               red  -  5v
-               yellow- servoPin
 */

-#include <Servo.h>
-
-Servo myservo; // create servo object to control a servo
-
-int servoPos = 0; // variable to store the servo position
-int servoInc = 1;
-int servoPin = 9; //pin to put servo output to
-
-void setup()
-{
-  myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object
-  Serial.begin(9600);
-}
-
-void loop()
-{
-  if(servoPos > 180) {
-    servoInc = -1;
-  } else if(servoPos < 1) {
-    servoInc = 1;
-  }
-  servoPos += servoInc;
-  myservo.write(servoPos);
-  Serial.println("loop completed");
+static setup() {
+
 }
+
+static loop {
+
+}


Remove duplicate break

Remove duplicate break

Remove duplicate break

--- examples/ttn-otaa/ttn-otaa.ino
+++ examples/ttn-otaa/ttn-otaa.ino
@@ -141,7 +141,6 @@
         case EV_REJOIN_FAILED:
             Serial.println(F("EV_REJOIN_FAILED"));
             break;
-            break;
         case EV_TXCOMPLETE:
             Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
             if (LMIC.txrxFlags & TXRX_ACK)


Spelling error

Spelling error

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -454,7 +454,7 @@
 // External command routines.
 //
 // External commands are:
-//     ID;          get device identifire string
+//     ID;          get device identifier string
 //     MSO;         set VFO mode to 'online'
 //     MSS;         set VFO mode to 'standby'
 //     MG;          get VFO mode


Update main.ino

Update main.ino

--- main/main.ino
+++ main/main.ino
@@ -23,7 +23,7 @@
 Serial.begin(115200);
 inputs.begin(); // set inputs
 outputs.begin(); // set outputs
-attachInterrupt(JogWheelPinA, sendJogWheel, RISING); // interrupts
+interruptsfunctions.begin(); // set interrupts

 }


Update Esp8266GatewayPimatic.ino

Update Esp8266GatewayPimatic.ino

Make dynamic ip adress optional

--- Esp8266GatewayPimatic.ino
+++ Esp8266GatewayPimatic.ino
@@ -104,7 +104,7 @@
 char authValEncoded[40];

 ///////////// Configure a static ip address ////////////
-IPAddress ip(192,168,144,245);
+IPAddress ip(192,168,144,245);        // Leave empty if you want a dynamic ip address
 IPAddress gateway(192,168,144,1);
 IPAddress subnet(255,255,255,0);

@@ -237,8 +237,11 @@
       delay(500);
       Serial.print(".");
     }
-    // When connected set static ip
-    WiFi.config(ip, gateway, subnet);
+    // When connected set static ip, but only if an ip address has been provided
+    // in the heading of this ino
+    if (ip != ""){
+      WiFi.config(ip, gateway, subnet);
+    }
   Serial.println("Connected!");  Serial.print("IP: "); Serial.println(WiFi.localIP());  Serial.flush();
   }
 }


changed RPM decay time to a lower limit

changed RPM decay time to a lower limit

--- arduino/car_control/src/main_control_nano/main_control_nano.ino
+++ arduino/car_control/src/main_control_nano/main_control_nano.ino
@@ -153,14 +153,13 @@
   //sweep steering
   for (int i = -45; i < 45; i++) {
     set_steer_angle(i);
-    delay(10);
+    delay(5);
   }
   for (int i = 45; i >= -45; i--) {
     set_steer_angle(i);
-    delay(10);
+    delay(5);
   }
   set_steer_angle(0);
-  delay(100);
 }

 void toggle_LED(int led, bool visable) {
@@ -198,15 +197,6 @@
   while (!TX_found) {
     //read in the from the controller
     steer_input = pulseIn(STEER_IN, HIGH, 25000);
-    throttle_input = pulseIn(THROTTLE_IN, HIGH, 25000);
-    //Serial.println(steer_input);
-    //Serial.println(throttle_input);
-
-    //toggle red led while waiting to arm
-    toggle_LED(LED_RED, true);
-    delay(10);
-    toggle_LED(LED_RED, false);
-    delay(10);

     if (steer_input > (STEER_MAX - 100) && !TX_high) {
       commander.sendCmd(cmd_info, "LEFT RX");
@@ -219,13 +209,6 @@

     if (TX_low && TX_high) {
       TX_found = true;
-      toggle_LED(LED_RED, false);
-      for (int i = 0; i < 30; i++) {
-        toggle_LED(LED_GREEN, true);
-        delay(80);
-        toggle_LED(LED_GREEN, false);
-        delay(80);
-      }
       enter_auto_mode();
     }

@@ -257,17 +240,13 @@

   delay(1);
   sweep();
-  commander.sendCmd(cmd_info, "setup complete in 1s");
-  delay(1000);
-
+  commander.sendCmd(cmd_info, "setup complete");
   //init rpm
   half_revolutions = 0;
   rpm = 0;
   timeold = 0;

-
   attach_commander_callbacks();
-
   enter_arming_mode();
 }

@@ -301,7 +280,7 @@

   //decay rpms incase vehicle has stopped
   rpm_decay++;
-  if (rpm_decay >20){
+  if (rpm_decay >10){
     rpm = 0;
     rpm_decay = 0;
     commander.sendBinCmd(cmd_rpm, rpm);
@@ -357,7 +336,7 @@
 }

 void write_rpms(){
-  if (half_revolutions >= 2) {
+  if (half_revolutions >= 4) {
      rpm = 30 * 1000/(millis() - timeold) * half_revolutions;
      rpm_decay = 0;
      timeold = millis();


#298 fix for esp8266

#298 fix for esp8266

--- arduino/ws2812_controller_esp8266/ws2812_controller_esp8266.ino
+++ arduino/ws2812_controller_esp8266/ws2812_controller_esp8266.ino
@@ -1,3 +1,10 @@
+
+/*
+* This example works for ESP8266 and uses the NeoPixelBus library instead of the one bundle
+* Sketch contributed to by Joey Babcock - https://joeybabcock.me/blog/
+* Codebase created by ScottLawsonBC - https://github.com/scottlawsonbc
+*/
+
 #include <Arduino.h>
 #include <ESP8266WiFi.h>
 #include <WiFiUdp.h>
@@ -33,6 +40,7 @@

 void setup() {
     Serial.begin(115200);
+
     WiFi.config(ip, gateway, subnet);
     WiFi.begin(ssid, password);
     Serial.println("");


Introduced a channel_map array

Introduced a channel_map array

--- Mega/mega2560.ino
+++ Mega/mega2560.ino
@@ -37,6 +37,8 @@
 char* navigation_status = "";
 uint8_t voltage = 0, voltage_count = 0;
 float voltage_sum = 0, voltage_avg = 0;
+
+uint8_t channel_map[4] = { 0, 0, 0, 0 }; // Values in range 0-7

 void setup() {


Added LED functionality to show successful/not successful adds

--- ReqMachine/reqmachine.ino
+++ ReqMachine/reqmachine.ino
@@ -13,10 +13,12 @@
  * Signal      Pin          Pin
  * -----------------------------------------------------------------------------------------
  * RST/Reset   RST          9
- * SPI SS      SDA(SS)      7
+ * SPI SS      SDA(NSS)      7
  * SPI MOSI    MOSI         11 / ICSP-4
  * SPI MISO    MISO         12 / ICSP-1
  * SPI SCK     SCK          13 / ICSP-3
+ *             VCC          5V
+ *
  *
  * This program will allow the arduino to read an RFID card
  * and send data to a listening port on a server.
@@ -35,6 +37,9 @@
 #define DEST_PORT         5000        //Arbtrary port number, can change
 #define MACHINE_LOCATION  "emrg"     //Dept code. This will change
 #define BIN_LOCATION_SIZE  6          //number of characters in your MMIS number
+#define GREEN_PIN          5
+#define RED_PIN            6
+#define  BLUE_PIN           3

 MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
 MFRC522::MIFARE_Key key;
@@ -45,9 +50,13 @@
 byte trailerBlock   = 7;

+
 void setup() {

    Serial.begin(9600);
+   pinMode(GREEN_PIN,OUTPUT);
+   pinMode(RED_PIN,OUTPUT);
+   pinMode(BLUE_PIN,OUTPUT);

   //start up wifly
   WiFly.begin();
@@ -71,6 +80,7 @@
   for (int i = 0; i < 6; i++) {
       key.keyByte[i] = 0xFF;
   }
+

 }

@@ -218,12 +228,25 @@
          client.print(c = buffer[i]);

       }
-
+      analogWrite(GREEN_PIN,191);
+      analogWrite(RED_PIN,48);
+      analogWrite(BLUE_PIN,196);
+      delay(1000);
+      digitalWrite(GREEN_PIN,LOW);
+      digitalWrite(RED_PIN,LOW);
+      digitalWrite(BLUE_PIN,LOW);
       //disconnects from socket
       client.stop();
     }
     else
     {
+      digitalWrite(RED_PIN,HIGH);
+      delay(500);
+      digitalWrite(RED_PIN,LOW);
+      delay(500);
+      digitalWrite(RED_PIN,HIGH);
+      delay(500);
+      digitalWrite(RED_PIN,LOW);
       Serial.println("Connection failed. Is port open?");

     }


Update ArduCAM_Mini_2MP_OV2640_functions.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_2MP_OV2640_functions/ArduCAM_Mini_2MP_OV2640_functions.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_2MP_OV2640_functions/ArduCAM_Mini_2MP_OV2640_functions.ino
@@ -492,7 +492,8 @@
     {
       Serial.write(pgm_read_byte(&bmp_header[temp]));
     }
-    SPI.transfer(0x00);
+    //for old version, enable it else disable
+   // SPI.transfer(0x00);
     char VH, VL;
     int i = 0, j = 0;
     for (i = 0; i < 240; i++)


add include EEPROM.h

add include EEPROM.h

--- waFirmata_buzzer_ultrasonic_dht_MaxMatrix_MFRC522_PM25.ino
+++ waFirmata_buzzer_ultrasonic_dht_MaxMatrix_MFRC522_PM25.ino
@@ -30,6 +30,7 @@
 #include <MaxMatrix.h>
 #include <SPI.h>
 #include <MFRC522.h>
+#include "EEPROM.h"
 #include <WAEEPROM.h>

 #define PIN_MODE_IGNORE         0x7F // pin configured to be ignored by digitalWrite and capabilityResponse


test arduino output sentence

test arduino output sentence

--- arduino/sadr_meteo_no_firmata/sadr_meteo_no_firmata.ino
+++ arduino/sadr_meteo_no_firmata/sadr_meteo_no_firmata.ino
@@ -438,14 +438,20 @@
 /*==============================================================================
  * OUPUT SERIAL
  *============================================================================*/
+String serialString() {
+    String output="N:25.05:0:0.00:0:26.80:63.60:23.60:71.80:19.62:0:25.05:21.39:12.63:100.00:1:1015.57:25.49:0.00:0.00:0:66.79:0:25.00:26.13:0.00";
+    return output;
+}
+
 void outputChain() {
     // send sensor values:
     Serial.print("N:");
-//Generic value
+    //Generic value
     Serial.print(T);
     Serial.print(":");
     Serial.print(frezzing);
     Serial.print(":");
+
 #ifdef USE_LIGHT_SENSOR
     Serial.print(Light);
     Serial.print(":");
@@ -527,7 +533,8 @@
 void loop() {
   if ((millis() - tempo) > SERIAL_DELAY ) { // debounce the switch contact.
     runMeteoStation();
-    outputChain();
+    //outputChain();
+    Serial.println(serialString());
     tempo = millis();
     Rotations = 0; // Set Rotations count to 0 after calculations
     MiniTime = 1000; // Set MiniTime value to 1000ms after calculations


updated State class 	modified:   mcu_main/mcu_main.ino

--- mcu_main/mcu_main.ino
+++ mcu_main/mcu_main.ino
@@ -7,19 +7,32 @@
 //!  struct storing the state information
 class State
 {
-  public:
+  public:
+
+  State(const String& cmd):
+    spd(cmd[1] * 5),
+    steps((cmd[2] << 8) + cmd[3]),
+    running(true),
+    cw(cmd[0] & 0x10),
+    mode(cmd[0] & 0x0f)
+  {}
+
   unsigned spd;
   unsigned steps;
-  boolean  running;
+  boolean  running = true;
   boolean  cw;
+  unsigned mode;
 };

 void wave(const State* state);
 void full(const State* state);
 void half(const State* state);
 void micr(const State* state);
+
 void pwm(unsigned pin, unsigned period, unsigned duty);
 void indicate(boolean running);
+
+void build(String& cmd);

 void setup()
 {
@@ -38,25 +51,13 @@
 void loop()
 {
   String cmd;
-  while (Serial.available())
-  {
-    delay(3);  //delay to allow buffer to fill
-    if (Serial.available() > 0)
-    {
-      char c = Serial.read();  //gets one byte from serial buffer
-      cmd += c; //makes the string readString
-    }
-  }
+  build(cmd);

   if(cmd.length() > 3)
   {
-    State state;
-    state.spd = cmd[1] * 5;
-    state.steps =  cmd[3] + (cmd[2] << 8);
-    state.running = true;
-    state.cw = cmd[0] & 0x10;
-
-    switch (cmd[0] & 0x0f)
+    State state(cmd);
+
+    switch (state.mode)
     {
       case 1  :  wave(&state);  break;
       case 2  :  full(&state);  break;
@@ -249,3 +250,17 @@
 {
     digitalWrite(indicator, running);
 }
+
+//!  @brief  :  receive the command from pc.
+void build(String& cmd)
+{
+  while (Serial.available())
+  {
+    delay(3);  //delay to allow buffer to fill
+    if (Serial.available() > 0)
+    {
+      char c = Serial.read();  //gets one byte from serial buffer
+      cmd += c; //makes the string readString
+    }
+  }
+}


Allow full brightness

Allow full brightness

Since the ESP is a 10 bit PWM device, max brightness is at 1023.
[[Source](http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations#pwm)]

--- ha_mqtt_rgb_light/ha_mqtt_rgb_light.ino
+++ ha_mqtt_rgb_light/ha_mqtt_rgb_light.ino
@@ -92,7 +92,7 @@
 // function called to adapt the brightness and the color of the led
 void setColor(uint8_t p_red, uint8_t p_green, uint8_t p_blue) {
   // convert the brightness in % (0-100%) into a digital value (0-255)
-  uint8_t brightness = map(m_rgb_brightness, 0, 100, 0, 255);
+  uint8_t brightness = map(m_rgb_brightness, 0, 100, 0, 1023);

   analogWrite(RGB_LIGHT_RED_PIN, map(p_red, 0, 255, 0, brightness));
   analogWrite(RGB_LIGHT_GREEN_PIN, map(p_green, 0, 255, 0, brightness));


Added functionality to turn pin on and off with CAN

--- examples/arduino_mcp2515/arduino_mcp2515.ino
+++ examples/arduino_mcp2515/arduino_mcp2515.ino
@@ -1,22 +1,28 @@
 #include <SPI.h>
 #include <mcp2515.h>

+#define AUTH  8
 #define INT   9
 #define SS    10
 #define MOSI  11
 #define MISO  12
 #define SCK   13

+#define DEVICE_ID 0x0005 // 1234 in decimal
+
 void printCanMessage();

-static CanMessage message = {MTYPE_EXTENDED_DATA, 5, 6, 2, {1,2}};
+static CanMessage message = {MTYPE_STANDARD_DATA, 0x0400 | DEVICE_ID, 0, 1, {0}};

 void setup() {
+  pinMode(AUTH, OUTPUT);
   pinMode(INT, INPUT);
   pinMode(MOSI, OUTPUT);
   pinMode(MISO, INPUT);
   pinMode(SCK, OUTPUT);
   pinMode(SS, OUTPUT);
+
+  digitalWrite(AUTH, LOW);
   digitalWrite(SS, HIGH);
   SPI.begin();

@@ -51,6 +57,19 @@
     mcp2515_readRX0(&message);
     printCanMessage();
     mcp2515_clearCANINTF(0xFF);
+
+    if (message.mtype == MTYPE_STANDARD_DATA && message.sid == 1) {
+      uint8_t* data = &message.data[0];
+      int device_id = data[0] << 3 | data[1] << 2 | data[2] << 1 | data[3];
+
+      if (device_id == DEVICE_ID) {
+        if (data[4] == 0) {
+          digitalWrite(AUTH, LOW);
+        } else {
+          digitalWrite(AUTH, HIGH);
+        }
+      }
+    }
   }
 }


1.0

1.0

-Full gapless sound system
-New Clash detection system made by Protonerd
-New Blaster blocks system based on JakeSoft idea
-Added several modularisation option (ways to desactivate some parts of
code)
-Low/critical Battery detection system
-Deep sleep system added
-Added support for accent LED
-Added support for FlashOnClash (for LEDStrings)
-Added flicker effects (for LEDSTRINGS)
-Added timer options for ignition and retractation effect to sync sound
with light
-Enhancements on flicker effect management
-Ventilated code throught several files
-several bug fixes

--- Lightsaber.ino
+++ Lightsaber.ino
@@ -29,9 +29,6 @@
 #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
 #include <Wire.h>
 #endif
-
-
-

 /*
  * DO NOT MODIFY
@@ -486,9 +483,16 @@
 				lowBattery = true;
 			}
 			delay(1000);
-			lowBattery = false;
-			randomBlink = 0;
-			blink = 0;
+			dfplayer.playPhysicalTrack(soundFont.getHum());
+			delay(40);
+			if (actionMode) {
+
+				dfplayer.setSingleLoop(true);
+				delay(40);
+				lowBattery = false;
+				randomBlink = 0;
+				blink = 0;
+			}
 		}

 		lastBatterycheck = millis();


Fix Smoothing.ino: var index conflicts with string.h index funcion

--- build/shared/examples/03.Analog/Smoothing/Smoothing.ino
+++ build/shared/examples/03.Analog/Smoothing/Smoothing.ino
@@ -28,7 +28,7 @@
 const int numReadings = 10;

 int readings[numReadings];      // the readings from the analog input
-int index = 0;                  // the index of the current reading
+int idx = 0;                  // the index of the current reading
 int total = 0;                  // the running total
 int average = 0;                // the average

@@ -45,18 +45,18 @@

 void loop() {
   // subtract the last reading:
-  total= total - readings[index];
+  total= total - readings[idx];
   // read from the sensor:
-  readings[index] = analogRead(inputPin);
+  readings[idx] = analogRead(inputPin);
   // add the reading to the total:
-  total= total + readings[index];
+  total= total + readings[idx];
   // advance to the next position in the array:
-  index = index + 1;
+  idx = idx + 1;

   // if we're at the end of the array...
-  if (index >= numReadings)
+  if (idx >= numReadings)
     // ...wrap around to the beginning:
-    index = 0;
+    idx = 0;

   // calculate the average:
   average = total / numReadings;


This code enables pin 13 and turns it on. It also connects A0 with ~3 and controls its output based on A0's input.


Add OctaveChange

Add OctaveChange

--- MusicalCar.ino
+++ MusicalCar.ino
@@ -3,10 +3,8 @@

 String notes[] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
 int stepArr[] = {0,2,4,5,7,9,11,12};
-//int keyStep[] = {10, 5, 0, 7, 2, 9, 4};
-int update[] = {0,0};
-int _note, _key, _range;
-int index;
+int keyStep[] = {10, 5, 0, 7, 2, 9, 4}; //A#, F, C, G, D, A, E
+int _note, _key, _octave;
 int counterS = 0;
 int counterP = 0;
 int counterG = 0;
@@ -33,6 +31,9 @@
 const int outputG = 8;
 const int outputH = 9;

+// Button
+const int buttonPin = 10;
+int buttonState = 0;
 void noteOn(byte channel, byte pitch, byte velocity) {
   MIDIEvent noteOn = {0x09, 0x90 | channel, pitch, velocity};
   MIDIUSB.write(noteOn);
@@ -99,7 +100,7 @@
         counterT ++;
       }
     else {
-      counterP --;
+      counterT --;
     }
     Serial.print("PositionT: ");
     Serial.println(counterT);
@@ -107,9 +108,20 @@
   gLastState = state;
   }
 }
+int changeOctave(){
+  buttonState = digitalRead(buttonPin);
+  if (buttonState == HIGH) {
+    return 7;
+  }
+  else {
+    return 6;
+  }
+}
+

 void setup(){
   //Setup encoders' pins
+  pinMode (buttonPin, INPUT);
   pinMode (outputA,INPUT);
   pinMode (outputB,INPUT);
   pinMode (outputC,INPUT);
@@ -131,11 +143,11 @@
 void loop(){
   // put your main code here, to run repeatedly:
   eRead(outputE, outputF);
-  _key = (int)((double) counterG/20*11);
+  _key = keyStep[(int)((double) counterG/20*7)];
+  _octave = changeOctave();
   eRead(outputA, outputB);
-  _note = _key+stepArr[(int)((double) counterS/40*7)];
+  _note = _key+stepArr[(int)((double) counterS/40*7)]+_octave;
   //counterP = encoderRead(outputC, outputD, cLastState);
   //counterG = eRead(outputE, outputF, eLastState);
   playNote(_note, 0);
-  //delay(100);
 }


Bugfix for OctoWS

Bugfix for OctoWS

--- examples/ArtnetOctoWS2811/ArtnetOctoWS2811.ino
+++ examples/ArtnetOctoWS2811/ArtnetOctoWS2811.ino
@@ -15,7 +15,7 @@
 // Artnet settings
 Artnet artnet;
 const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as zero.
-const int numberOfChannels = ledsPerStrip * 3; // Total number of channels you want to receive (1 led = 3 channels)
+const int numberOfChannels = ledsPerStrip * numStrips * 3; // Total number of channels you want to receive (1 led = 3 channels)
 byte channelBuffer[numberOfChannels]; // Combined universes into a single array

 // Check if we got all universes
@@ -71,7 +71,7 @@
   }

   // send to leds
-  for (int i = 0; i < ledsPerStrip; i++)
+  for (int i = 0; i < ledsPerStrip * numStrips; i++)
   {
     leds.setPixel(i, channelBuffer[(i) * 3], channelBuffer[(i * 3) + 1], channelBuffer[(i * 3) + 2]);
   }
@@ -86,19 +86,19 @@

 void initTest()
 {
-  for (int i = 0 ; i < ledsPerStrip ; i++)
+  for (int i = 0 ; i < ledsPerStrip * numStrips ; i++)
     leds.setPixel(i, 127, 0, 0);
   leds.show();
   delay(500);
-  for (int i = 0 ; i < ledsPerStrip ; i++)
+  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
     leds.setPixel(i, 0, 127, 0);
   leds.show();
   delay(500);
-  for (int i = 0 ; i < ledsPerStrip ; i++)
+  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
     leds.setPixel(i, 0, 0, 127);
   leds.show();
   delay(500);
-  for (int i = 0 ; i < ledsPerStrip ; i++)
+  for (int i = 0 ; i < ledsPerStrip * numStrips  ; i++)
     leds.setPixel(i, 0, 0, 0);
   leds.show();
 }


unneeded statics

unneeded statics

--- WallBot_v3/PIDControl.ino
+++ WallBot_v3/PIDControl.ino
@@ -38,10 +38,9 @@
 {
   static int16_t lticks = 0, rticks = 0;
   static uint16_t ms = 0;
-  int16_t diff;
+  int16_t dlticks, drticks, diff;
   int32_t delta;
-  static int16_t dlticks = 0, drticks = 0;
-  static uint16_t dms = 0;
+  uint16_t dms;

   get_ticks_since_last( &dlticks, &drticks, &dms);


bugfix

bugfix

--- RGB_matrix.ino
+++ RGB_matrix.ino
@@ -23,34 +23,38 @@
 void loop(){

     //音が変わるたびに発光箇所が変わる
-    song1.play();
-    while( song1.isPlaying() || !isPress() ){
-        static int cnt=0;
-        cnt += song1.play();
+    while( !isPress() ){
+        delay(500);
+        song1.play();
+        while( song1.isPlaying() || !isPress() ){
+            static int cnt=0;
+            cnt += song1.play();
+            Led::setAll(OFF);
+            Led::set(cnt%9,WHITE);
+            Led::lighting();
+        }
+        song1.stop();
         Led::setAll(OFF);
-        Led::set(cnt%9,WHITE);
         Led::lighting();
     }
-    song1.stop();
-    Led::setAll(OFF);
-    Led::lighting();
-    delay(200);
     while( isPress() );  //スイッチが離されるまで待つ

     //音の高さによって色が変わる
-    song2.play();
-    while( song2.isPlaying() || !isPress()){
+    while( !isPress() ){
+        delay(500);
         song2.play();
-        LedColor color = int2color( song2.getPitch() );
-        Led::setAll(color);
+        while( song2.isPlaying() || !isPress()){
+            song2.play();
+            LedColor color = int2color( song2.getPitch() );
+            Led::setAll(color);
+            Led::lighting();
+        }
+        song2.stop();
+        Led::setAll(OFF);
         Led::lighting();
     }
-    song2.stop();
-    Led::setAll(OFF);
-    Led::lighting();
-    delay(200);
     while( isPress() );  //スイッチが離されるまで待つ

 }


Set tester to not pollute CSV output, still gets the F8 but we'll just ignore that for now

--- Sensorizer.ino
+++ Sensorizer.ino
@@ -92,11 +92,14 @@

-
+/**
+ * Set to 1 to send one sensor's data with timestamps as a CSV to the USB.
+ * Used for the sensorizerTester Xcode app.
+ */
 #define ENABLE_TIMESTAMP_VAL_TEST 1
 #if ENABLE_TIMESTAMP_VAL_TEST

-#define TIMSTAMP_VAL_TEST_SENSOR_IDX_TO_LOG 0
+#define TIMSTAMP_VAL_TEST_SENSOR_IDX_TO_LOG 8
 #define TEST_VAL_TIMESTAMPS_LENGTH 256

 int testValTimestampsIdx = 0;
@@ -306,7 +309,7 @@
           if (++testValTimestampsIdx >= TEST_VAL_TIMESTAMPS_LENGTH) {
             testValTimestampsIdx = 0;

-            SerialUSB.println("ValTimestamps:");
+            //SerialUSB.println("ValTimestamps:");
             unsigned long firstValTimestamp = testValTimestamps[0];
             for (int i = 0; i < TEST_VAL_TIMESTAMPS_LENGTH; i++) {
               SerialUSB.print(testValTimestamps[i]);
@@ -315,6 +318,8 @@
             }
           }
         }
+
+        val = 0; // disable all notes so we don't pollute the CSV with garbage
 #endif


Fixed Broadcom BLE to reset so it's not stuck in programming mode. Not sure what setting the TX pin will do for the actual communication later.

--- Sensorizer.ino
+++ Sensorizer.ino
@@ -122,11 +122,26 @@

   #ifdef BLE_RESET_PIN
+
   // broadcom has reset line attached, make sure it's not reseting!
   // active-low.

+  // first, set programming HCI UART to low, because the BLE will just wait to be programmed
+  // if it starts up with the TX line high.
+  // TODO: Not sure what setting the TX pin will do for the actual communication later. Will the UART class successfully regain control of the TX line?
+#define BLE_PROGRAMMING_TX_PIN 1
+  pinMode(BLE_PROGRAMMING_TX_PIN, OUTPUT);
+  digitalWrite(BLE_PROGRAMMING_TX_PIN, LOW);
+
+  // reset the BLE
+  pinMode(BLE_RESET_PIN, OUTPUT);
+  digitalWrite(BLE_RESET_PIN, LOW);
+  delay(2); // 20uS to reset
+
   pinMode(BLE_RESET_PIN, OUTPUT);
   digitalWrite(BLE_RESET_PIN, HIGH);
+
+  delay(6); // ~5ms to warm up and boot

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