Removed some unnecessary code for the joystick.

--- StuntCarRacer/Arduino_Code/ArduinoAmigaJoystick/ArduinoAmigaJoystick.ino
+++ StuntCarRacer/Arduino_Code/ArduinoAmigaJoystick/ArduinoAmigaJoystick.ino
@@ -1,4 +1,7 @@
-#include <math.h>
+/*
+ * Arduino code to read joystick states
+ */
+//#include<math.h>

 /*
     DECLARATION
@@ -15,35 +18,35 @@
 int joyRightPin = 12;
 int joyFirePin = 13;

-// position tracking
-
-int updatedPos = 0;     // keeps track of the latest updated value of the MR sensor reading
-int rawPos = 0;         // current raw reading from MR sensor
-int lastRawPos = 0;     // last raw reading from MR sensor
-int lastLastRawPos = 0; // last last raw reading from MR sensor
-int flipNumber = 0;     // keeps track of the number of flips over the 180deg mark
-int tempOffset = 0;
-int rawDiff = 0;
-int lastRawDiff = 0;
-int rawOffset = 0;
-int lastRawOffset = 0;
-const int flipThresh = 700;  // threshold to determine whether or not a flip over the 180 degree mark occurred
-boolean flipped = false;
-
-// Kinematics
-double xh = 0;         // position of the handle [m]
-double lastXh = 0;     //last x position of the handle
-double vh = 0;         //velocity of the handle
-double lastVh = 0;     //last velocity of the handle
-double lastLastVh = 0; //last last velocity of the handle
-double rp = 0.004191;   //[m]
-double rs = 0.073152;   //[m]
-double rh = 0.065659;   //[m]
-// Force output variables
-double force = 0;           // force at the handle
-double Tp = 0;              // torque of the motor pulley
-double duty = 0;            // duty cylce (between 0 and 255)
-unsigned int output = 0;    // output command to the motor
+//// position tracking
+//
+//int updatedPos = 0;     // keeps track of the latest updated value of the MR sensor reading
+//int rawPos = 0;         // current raw reading from MR sensor
+//int lastRawPos = 0;     // last raw reading from MR sensor
+//int lastLastRawPos = 0; // last last raw reading from MR sensor
+//int flipNumber = 0;     // keeps track of the number of flips over the 180deg mark
+//int tempOffset = 0;
+//int rawDiff = 0;
+//int lastRawDiff = 0;
+//int rawOffset = 0;
+//int lastRawOffset = 0;
+//const int flipThresh = 700;  // threshold to determine whether or not a flip over the 180 degree mark occurred
+//boolean flipped = false;
+//
+//// Kinematics
+//double xh = 0;         // position of the handle [m]
+//double lastXh = 0;     //last x position of the handle
+//double vh = 0;         //velocity of the handle
+//double lastVh = 0;     //last velocity of the handle
+//double lastLastVh = 0; //last last velocity of the handle
+//double rp = 0.004191;   //[m]
+//double rs = 0.073152;   //[m]
+//double rh = 0.065659;   //[m]
+//// Force output variables
+//double force = 0;           // force at the handle
+//double Tp = 0;              // torque of the motor pulley
+//double duty = 0;            // duty cylce (between 0 and 255)
+//unsigned int output = 0;    // output command to the motor

 /*
@@ -72,65 +75,65 @@
   digitalWrite(dirPin, LOW);  // set direction

   // Initialize position valiables
-  lastLastRawPos = analogRead(sensorPosPin);
-  lastRawPos = analogRead(sensorPosPin);
+//  lastLastRawPos = analogRead(sensorPosPin);
+//  lastRawPos = analogRead(sensorPosPin);
 }

 /*
     readPosCount() function
 */
-void readPosCount() {
-  // Get voltage output by MR sensor
-  rawPos = analogRead(sensorPosPin);  //current raw position from MR sensor
-  // Calculate differences between subsequent MR sensor readings
-  rawDiff = rawPos - lastRawPos;          //difference btwn current raw position and last raw position
-  lastRawDiff = rawPos - lastLastRawPos;  //difference btwn current raw position and last last raw position
-  rawOffset = abs(rawDiff);
-  lastRawOffset = abs(lastRawDiff);
-
-  // Update position record-keeping vairables
-  lastLastRawPos = lastRawPos;
-  lastRawPos = rawPos;
-
-  // Keep track of flips over 180 degrees
-  if ((lastRawOffset > flipThresh) && (!flipped)) { // enter this anytime the last offset is greater than the flip threshold AND it has not just flipped
-    if (lastRawDiff > 0) {       // check to see which direction the drive wheel was turning
-      flipNumber--;              // cw rotation
-    } else {                     // if(rawDiff < 0)
-      flipNumber++;              // ccw rotation
-    }
-    if (rawOffset > flipThresh) { // check to see if the data was good and the most current offset is above the threshold
-      updatedPos = rawPos + flipNumber * rawOffset; // update the pos value to account for flips over 180deg using the most current offset
-      tempOffset = rawOffset;
-    } else {                     // in this case there was a blip in the data and we want to use lastactualOffset instead
-      updatedPos = rawPos + flipNumber * lastRawOffset; // update the pos value to account for any flips over 180deg using the LAST offset
-      tempOffset = lastRawOffset;
-    }
-    flipped = true;            // set boolean so that the next time through the loop won't trigger a flip
-  } else {                        // anytime no flip has occurred
-    updatedPos = rawPos + flipNumber * tempOffset; // need to update pos based on what most recent offset is
-    flipped = false;
-  }
-
-  //Serial.println(updatedPos);
-}
+//void readPosCount() {
+//  // Get voltage output by MR sensor
+//  rawPos = analogRead(sensorPosPin);  //current raw position from MR sensor
+//  // Calculate differences between subsequent MR sensor readings
+//  rawDiff = rawPos - lastRawPos;          //difference btwn current raw position and last raw position
+//  lastRawDiff = rawPos - lastLastRawPos;  //difference btwn current raw position and last last raw position
+//  rawOffset = abs(rawDiff);
+//  lastRawOffset = abs(lastRawDiff);
+//
+//  // Update position record-keeping vairables
+//  lastLastRawPos = lastRawPos;
+//  lastRawPos = rawPos;
+//
+//  // Keep track of flips over 180 degrees
+//  if ((lastRawOffset > flipThresh) && (!flipped)) { // enter this anytime the last offset is greater than the flip threshold AND it has not just flipped
+//    if (lastRawDiff > 0) {       // check to see which direction the drive wheel was turning
+//      flipNumber--;              // cw rotation
+//    } else {                     // if(rawDiff < 0)
+//      flipNumber++;              // ccw rotation
+//    }
+//    if (rawOffset > flipThresh) { // check to see if the data was good and the most current offset is above the threshold
+//      updatedPos = rawPos + flipNumber * rawOffset; // update the pos value to account for flips over 180deg using the most current offset
+//      tempOffset = rawOffset;
+//    } else {                     // in this case there was a blip in the data and we want to use lastactualOffset instead
+//      updatedPos = rawPos + flipNumber * lastRawOffset; // update the pos value to account for any flips over 180deg using the LAST offset
+//      tempOffset = lastRawOffset;
+//    }
+//    flipped = true;            // set boolean so that the next time through the loop won't trigger a flip
+//  } else {                        // anytime no flip has occurred
+//    updatedPos = rawPos + flipNumber * tempOffset; // need to update pos based on what most recent offset is
+//    flipped = false;
+//  }
+//
+//  //Serial.println(updatedPos);
+//}

 /*
     calPosMeter()
 */
-void calPosMeter()
-{
-  double rh = 65.659;   //[mm]
-  double ts = -.0107 * updatedPos + 7.9513; // Compute the angle of the sector pulley (ts) in degrees based on updatedPos
-  xh = rh * (ts * 3.14159 / 180); // Compute the position of the handle based on ts
-  vh = -(.95 * .95) * lastLastVh + 2 * .95 * lastVh + (1 - .95) * (1 - .95) * (xh - lastXh) / .0001; // filtered velocity (2nd-order filter)
-  lastXh = xh;
-  lastLastVh = lastVh;
-  lastVh = vh;
-
-  //Serial.println(xh);
-}
+//void calPosMeter()
+//{
+//  double rh = 65.659;   //[mm]
+//  double ts = -.0107 * updatedPos + 7.9513; // Compute the angle of the sector pulley (ts) in degrees based on updatedPos
+//  xh = rh * (ts * 3.14159 / 180); // Compute the position of the handle based on ts
+//  vh = -(.95 * .95) * lastLastVh + 2 * .95 * lastVh + (1 - .95) * (1 - .95) * (xh - lastXh) / .0001; // filtered velocity (2nd-order filter)
+//  lastXh = xh;
+//  lastLastVh = lastVh;
+//  lastVh = vh;
+//
+//  //Serial.println(xh);
+//}

 // read joystick state
 uint8_t readJoystick() {
@@ -150,14 +153,12 @@
 int32_t nextcall = 1000;
 void loop() {
   // read the position in count
-  readPosCount();
-  calPosMeter();
+//  readPosCount();
+//  calPosMeter();

   if(millis() > nextcall) {
     nextcall += 50;

-	Serial.print(xh);
-    Serial.print("\t");
 	Serial.println(readJoystick()); // return joystick state
   }


Zapped debug code

Zapped debug code

--- signalboxes/kelberg/kelberg.ino
+++ signalboxes/kelberg/kelberg.ino
@@ -231,16 +231,6 @@
   }
 }

-/* void update_single_lever_led(int pin, int number) { */
-/*   if ((millis() % 1000) > 500) { */
-/*     digitalWrite(pin, HIGH); */
-/*   } */
-/*   else { */
-/*     digitalWrite(pin, LOW); */
-/*   } */
-/* } */
-
-// xxxx

 void setup() {
   pinMode(13, OUTPUT);


Fixed issue in Starter kit example number 4

--- build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino
+++ build/shared/examples/10.StarterKit/p04_ColorMixingLamp/p04_ColorMixingLamp.ino
@@ -10,9 +10,10 @@
  three 10 kilohm resistors
  3 220 ohm resistors
  3 photoresistors
- red green aand blue colored gels
+ red green and blue colored gels

  Created 13 September 2012
+ Modified 14 November 2012
  by Scott Fitzgerald
  Thanks to Federico Vanzati for improvements

@@ -42,32 +43,32 @@
   Serial.begin(9600);

   // set the digital pins as outputs
-  pinMode(greenLedPin,OUTPUT);
-  pinMode(redLedPin,OUTPUT);
-  pinMode(blueLedPin,OUTPUT);
+  pinMode(greenLEDPin,OUTPUT);
+  pinMode(redLEDPin,OUTPUT);
+  pinMode(blueLEDPin,OUTPUT);
 }

 void loop() {
   // Read the sensors first:

   // read the value from the red-filtered photoresistor:
-  redsensorValue = analogRead(redsensorPin);
+  redSensorValue = analogRead(redSensorPin);
   // give the ADC a moment to settle
   delay(5);
   // read the value from the green-filtered photoresistor:
-  greensensorValue = analogRead(greensensorPin);
+  greenSensorValue = analogRead(greenSensorPin);
   // give the ADC a moment to settle
   delay(5);
   // read the value from the blue-filtered photoresistor:
-  bluesensorValue = analogRead(bluesensorPin);
+  blueSensorValue = analogRead(blueSensorPin);

   // print out the values to the serial monitor
   Serial.print("raw sensor Values \t red: ");
-  Serial.print(redsensorValue);
+  Serial.print(redSensorValue);
   Serial.print("\t green: ");
-  Serial.print(greensensorValue);
+  Serial.print(greenSensorValue);
   Serial.print("\t Blue: ");
-  Serial.println(bluesensorValue);
+  Serial.println(blueSensorValue);

   /*
   In order to use the values from the sensor for the LED,
@@ -75,9 +76,9 @@
   but analogWrite() uses 8 bits. You'll want to divide your
   sensor readings by 4 to keep them in range of the output.
   */
-  redValue = redsensorValue/4;
-  greenValue = greensensorValue/4;
-  blueValue = bluesensorValue/4;
+  redValue = redSensorValue/4;
+  greenValue = greenSensorValue/4;
+  blueValue = blueSensorValue/4;

   //  print out the mapped values
   Serial.print("Mapped sensor Values \t red: ");
@@ -90,8 +91,8 @@
   /*
   Now that you have a usable value, it's time to PWM the LED.
   */
-  analogWrite(redLedPin, redValue);
-  analogWrite(greenLedPin, greenValue);
-  analogWrite(blueLedPin, blueValue);
+  analogWrite(redLEDPin, redValue);
+  analogWrite(greenLEDPin, greenValue);
+  analogWrite(blueLEDPin, blueValue);
 }


Main program updated with new constants

Main program updated with new constants

--- src/TenazAyuda.ino
+++ src/TenazAyuda.ino
@@ -1,33 +1,19 @@
-#include <Servo.h>
+#include "Configuration.h"
+#include "AnalogInput.h"
+#include "DigitalInput.h"
+#include "Joystick.h"
+#include "Motor.h"
 #include "MyServo.h"
+#include "MyStepper.h"
+#include "MotorsContainer.h"

 bool DEBUG = true;

 /* ***************************************************************************************
  *                                      PINES BOTONERA                                   *
  * ***************************************************************************************/
-const int up_button = 2;
-const int down_button = 4;
-const int left_button = 5;
-const int right_button = 3;
-const int start_button = 6;
-const int select_button = 7;
-const int analog_button = 8;
-const int x_axis = A0;
-const int y_axis = A1;
-const int buttons[] = {up_button, down_button, left_button, right_button, start_button, select_button, analog_button};
-const int buttons_quantity = 7;

-/* ***************************************************************************************
- *                                     MAPEO A FUNCIONES                                 *
- * ***************************************************************************************/
-const int boton_pinza = select_button;
-const int boton_palito = down_button;
-const int boton_cambios = analog_button;
-const int boton_grabarHacer = left_button;
-const int boton_preseteado = start_button;
-const int boton_standby = right_button;
-const int boton_giro[] = {x_axis, y_axis};
+const int buttons[] = {UP_BUTTON, DOWN_BUTTON, LEFT_BUTTON, RIGHT_BUTTON, START_BUTTON, SELECT_BUTTON, ANALOG_BUTTON};

 /* ***************************************************************************************
  *                                         MOTORES                                       *
@@ -40,7 +26,7 @@
  *                                         SETUP                                         *
  * ***************************************************************************************/
 void init_buttons() {
-  for (int i = 0; i < buttons_quantity; i++) {
+  for (int i = 0; i < BUTTONS_QUANTITY; i++) {
    pinMode(buttons[i], INPUT_PULLUP);
   }
 }
@@ -59,15 +45,6 @@
  *                                       PROGRAMA                                        *
  * ***************************************************************************************/

-void printButton(char* buttonName, int buttonId) {
-  Serial.print(buttonName),Serial.print(" = "),Serial.print(digitalRead(buttonId)),Serial.print("\t");
-}
-
-void printJoystick(int xAxisId, int yAxisId) {
-  Serial.print("X = "),Serial.print(map(analogRead(xAxisId), 0, 1023, -1, 1));Serial.print("\t");
-  Serial.print("Y = "),Serial.print(map(analogRead(yAxisId), 0, 1023, -1, 1));Serial.print("\n");
-}
-
 void update_servo(int axis_id, Servo* servo) {
   int val = analogRead(axis_id);
   val = map(val, 0, 1023, -100, 100);
@@ -76,12 +53,10 @@
 }

 void update_servos_pair() {
-  update_servo(x_axis, &servo_base);
+  update_servo(X_AXIS, &servo_base);
 }

 void loop() {
   update_servos_pair();
   delay(150);
 }
-
-


Update ArduCAM_Mini_Capture2SD.ino

Update ArduCAM_Mini_Capture2SD.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD/ArduCAM_Mini_Capture2SD.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD/ArduCAM_Mini_Capture2SD.ino
@@ -124,8 +124,16 @@
 Serial.println(F("ArduCAM Start!"));
 //set the CS as an output:
 pinMode(SPI_CS,OUTPUT);
+digitalWrite(SPI_CS, HIGH);
 // initialize SPI:
 SPI.begin();
+
+//Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
+
 while(1){
   //Check if the ArduCAM SPI bus is OK
   myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


MVP complete. Version 1

MVP complete. Version 1

--- module/module.ino
+++ module/module.ino
@@ -56,16 +56,16 @@
 		Serial.println("Read unsuccessful, please try again.");
 	else {
 		existingTime = getTime(readData);
-		//existingTime = 2000;
-		if(readData[8] != 0xDD)
-			Serial.println("Invalid card");
-		else if(existingTime >= quota)
+		if(existingTime >= quota) {
 			Serial.println("You have reached your quota for this month.");
+			delay(5000);
+		}
 		else {
-			Serial.println("User authenticated. Machine is ready to fire");
+			Serial.println("User authenticated. Machine is ready to fire.");
 			elapsedTime = accumulator();
 			Serial.print("Total time used: ");
 			Serial.println(elapsedTime + existingTime);
+			delay(5000);
 		}
 	}


Added wait for serial port when printing network configuration to support Leonardo boards.

--- examples/PrintNetworkConfig/PrintNetworkConfig.ino
+++ examples/PrintNetworkConfig/PrintNetworkConfig.ino
@@ -6,6 +6,9 @@
 /* Prints the network configuration stored in EEPROM. */
 void setup() {
   Serial.begin(9600);
+  while (!Serial) {
+    // Wait for serial for Leonardo
+  }

   if (NetEeprom.checkMagic()) {
     byte mac[6];


Delete spark-plotly.ino

Delete spark-plotly.ino

--- examples/spark-plotly.ino
+++ examples/spark-plotly.ino
@@ -1,30 +0,0 @@
-#include "spark-plotly.h"
-
-#define DATA_POINTS 4
-
-char* data_point_tokens[NUM_TOKENS] = {"token1", "token2", "token3","token4"};
-plotly graph = plotly("username", "secret", streaming_tokens, "streamname", DATA_POINTS);
-
-void setup() {
-   graph.init();
-   graph.fileopt = "extend";
-   graph.openStream();
-}
-
-void loop() {
-
-    float val1;
-    float val2;
-    float val3;
-    float val4;
-
-    // up to you to decide what these values represent and how they get initialized/updated.
-
-    unsigned long x = millis();
-
-    graph.plot(x, val1, data_point_tokens[0]);
-    graph.plot(x, val2, data_point_tokens[1]);
-    graph.plot(x, val3, data_point_tokens[2]);
-    graph.plot(x, val4, data_point_tokens[3]);
-
-}


reinstated working data push to cloud; added citsci address to wifi status page; added default citsci server

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -122,7 +122,7 @@
 #define startupDBG true
 #define valveDBG false
 #define monitorDBG false
-#define netDBG false
+#define netDBG true
 #define miscDBG false
 #define citsciDBG true

@@ -566,6 +566,8 @@
   toSend += "
\n";
   toSend += "\n
AP SSID name: "; toSend += apSSID;
   toSend += "
\n";
+  toSend += "\n
Data sharing server address: "; toSend += svrAddr;
+  toSend += "
\n";

   toSend += "

";

@@ -648,7 +650,7 @@
   }

   // persist the config
-  if(svrAddr.length() > 0) setSvrAddr(svrAddr);
+  setSvrAddr(svrAddr);
   setCloudShare(cloudShare);

   // TODO some way of verifying if server config worked
@@ -797,13 +799,14 @@

   dln(citsciDBG, "\npostSensorData");
   String jsonBuf = "";
-//String citsciAddr = "citsci.wegrow.social"; //Hardcoded? Also changed port from 8000 to 5984
   String citsciAddr = svrAddr;
+  if(citsciAddr.length() == 0) // default cloud server address
+    citsciAddr = "citsci.wegrow.social";
   formatMonitorEntry(monitorData, &jsonBuf, true);
   String envelope =
     "GET /collect/"; envelope += apSSIDStr; envelope += " HTTP/1.1\r\n";
   envelope += "User-Agent: WaterElf/0.000001\r\n";
-  envelope += "Host: "; envelope += citsciAddr; envelope += ":5984\r\n";
+  envelope += "Host: "; envelope += citsciAddr; envelope += ":8000\r\n";
   envelope += "Accept: application/json\r\n";
   envelope += "Content-Type: application/json\r\n";
   envelope += "Content-Length: " ;
@@ -812,7 +815,7 @@
   envelope += jsonBuf;

   WiFiClient citsciClient;
-  if(citsciClient.connect(citsciAddr.c_str(), 5984)) {
+  if(citsciClient.connect(citsciAddr.c_str(), 8000)) {
     dln(citsciDBG, "connected to citsci server; doing GET");
     citsciClient.print(envelope);
   } else {


split out the pump trig function from the web handler so can use in valve logic

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -571,15 +571,7 @@
   }

   // now we trigger MOSFETs off or on
-  Serial.print("Growbed Valve Air Pump ");
-  Serial.print(pumpNum);
-  if(newState == true){
-    mcp.digitalWrite(mcpPin, HIGH);
-    Serial.println(" on");
-  } else {
-    mcp.digitalWrite(mcpPin, LOW);
-    Serial.println(" off");
-  }
+  swapPumpState(pumpNum, newState, mcpPin);

   toSend += "
Water Pump ";
   toSend += pumpNum;
@@ -589,6 +581,18 @@
   toSend += ".)
\n";
   toSend += pageFooter;
   webServer.send(200, "text/html", toSend);
+}
+void swapPumpState(int pumpNum, boolean newState, int mcpPin) {
+  Serial.print("Growbed Valve Air Pump ");
+  Serial.print(pumpNum);
+
+  if(newState == true){
+    mcp.digitalWrite(mcpPin, HIGH);
+    Serial.println(" on");
+  } else {
+    mcp.digitalWrite(mcpPin, LOW);
+    Serial.println(" off");
+  }
 }

 /////////////////////////////////////////////////////////////////////////////
@@ -701,6 +705,7 @@
     buf->concat(", \"pH\": ");
     buf->concat(m->pH);
   }
+  // TODO add water levels
   buf->concat(" }");
 }
 void getTemperature(float* waterCelsius) {
@@ -811,7 +816,7 @@

 /////////////////////////////////////////////////////////////////////////////
 // misc utils ///////////////////////////////////////////////////////////////
-void ledOn() { digitalWrite(BUILTIN_LED, LOW); }
+void ledOn()  { digitalWrite(BUILTIN_LED, LOW); }
 void ledOff() { digitalWrite(BUILTIN_LED, HIGH); }
 void blink(int times) {
   ledOff();


Implement a minimal swell pedal

Implement a minimal swell pedal

--- roto.ino
+++ roto.ino
@@ -28,8 +28,14 @@
 AudioConnection patchCord3(percussion, 0, percussionEnv, 0);
 AudioConnection patchCord4(percussionEnv, 0, organOut, 1);

+AudioAmplifier swell;
+AudioConnection patchCord5(organOut, 0, swell, 0);
+
+// This antialias filter is here to band limit the organ signal, in
+// case key click transients are too high frequency, and also to give
+// a slight reduction in key click.
 AudioFilterBiquad antialias;
-AudioConnection patchCord5(organOut, 0, antialias, 0);
+AudioConnection patchCord6(swell, 0, antialias, 0);

 // Leslie 122
 Preamp preamp;
@@ -41,30 +47,30 @@
 AmFm leslieTrebleL;
 AudioMixer4 leslieL;

-AudioConnection patchCord6(antialias, 0, preamp, 0);
-AudioConnection patchCord7(preamp, 0, crossover, 0);
-
-AudioConnection patchCord8(crossover, 0, leslieBassR, 0);
-AudioConnection patchCord9(crossover, 2, leslieTrebleR, 0);
-AudioConnection patchCord10(leslieBassR, 0, leslieR, 0);
-AudioConnection patchCord11(leslieTrebleR, 0, leslieR, 1);
-
-AudioConnection patchCord12(crossover, 0, leslieBassL, 0);
-AudioConnection patchCord13(crossover, 2, leslieTrebleL, 0);
-AudioConnection patchCord14(leslieBassL, 0, leslieL, 0);
-AudioConnection patchCord15(leslieTrebleL, 0, leslieL, 1);
+AudioConnection patchCord7(antialias, 0, preamp, 0);
+AudioConnection patchCord8(preamp, 0, crossover, 0);
+
+AudioConnection patchCord9(crossover, 0, leslieBassR, 0);
+AudioConnection patchCord10(crossover, 2, leslieTrebleR, 0);
+AudioConnection patchCord11(leslieBassR, 0, leslieR, 0);
+AudioConnection patchCord12(leslieTrebleR, 0, leslieR, 1);
+
+AudioConnection patchCord13(crossover, 0, leslieBassL, 0);
+AudioConnection patchCord14(crossover, 2, leslieTrebleL, 0);
+AudioConnection patchCord15(leslieBassL, 0, leslieL, 0);
+AudioConnection patchCord16(leslieTrebleL, 0, leslieL, 1);

 // Teensy audio board output.
 AudioOutputI2S i2s1;
 AudioControlSGTL5000 audioShield;
-AudioConnection patchCord16(leslieR, 0, i2s1, 0);
-AudioConnection patchCord17(leslieL, 0, i2s1, 1);
+AudioConnection patchCord17(leslieR, 0, i2s1, 0);
+AudioConnection patchCord18(leslieL, 0, i2s1, 1);

 #ifdef AUDIO_INTERFACE
 // If the board is configured for USB audio, mirror the i2s output to USB.
 AudioOutputUSB usbAudio;
-AudioConnection patchCord18(leslieR, 0, usbAudio, 0);
-AudioConnection patchCord19(leslieL, 0, usbAudio, 1);
+AudioConnection patchCord19(leslieR, 0, usbAudio, 0);
+AudioConnection patchCord20(leslieL, 0, usbAudio, 1);
 #endif

 uint8_t keys[62] = {0};
@@ -94,8 +100,10 @@
     tonewheels.init();
     percussion.init();
     vibrato.init();
+
+    swell.gain(1.0);
+
     preamp.init();
-
     preamp.setK(50.0);

     crossover.frequency(800);
@@ -270,6 +278,14 @@
     Serial.print(", value=");
     Serial.print(val, DEC);
     Serial.println();
+
+    if (ctrl == 11) {
+	if (val == 0)  {
+	    swell.gain(0);
+	} else {
+	    swell.gain(127 / (float)(127 - val));
+	}
+    }

     if (ctrl == 16) {
         organOut.gain(0, float(127) / float(val));


Debug prints in receiver

Debug prints in receiver

--- sw/receiver/receiver.ino
+++ sw/receiver/receiver.ino
@@ -118,12 +118,13 @@
       // Read it
       radio.read(&packet, RF24_PAYLOAD);

-      /*Serial.print("-> Got ");
+      Serial.println("--> Got ");

       for(int i = 0; i < RF24_PAYLOAD; i++) {
-        Serial.print(packet[i], HEX); Serial.print(" ");
+        Serial.println(packet.command, HEX);
+        Serial.println(packet.id, HEX);
+        Serial.println(packet.state, HEX);
       }
-      Serial.println();*/

       // TODO: do something here
       delay(50);


Update RandomPlay.ino

Update RandomPlay.ino

play() is unnecessary here

--- examples/RandomPlay/RandomPlay.ino
+++ examples/RandomPlay/RandomPlay.ino
@@ -86,7 +86,6 @@

     // and play it
     mp3.playFileByIndexNumber(pick);
-    mp3.play();

     // if we are in SD Card mode, we can print the file name
     // the built in memory does not have file names


Replaces RGB_OLED_WIDTH/HEIGHT with SCREEN_WIDTH/HEIGHT

--- watch.ino
+++ watch.ino
@@ -97,8 +97,8 @@

   if (W.needs_redraw) toclear = 8;

-  uint8_t clearwidth = RGB_OLED_WIDTH*toclear/8;
-  xpos = RGB_OLED_WIDTH - clearwidth;
+  uint8_t clearwidth = SCREEN_WIDTH*toclear/8;
+  xpos = SCREEN_WIDTH - clearwidth;
   oled.clearWindow(xpos, ypos, xpos+clearwidth, ypos + FONT_Y*2);

   sprintf(_sbuf, "%02d:%02d:%02d", W.hours, W.minutes, W.seconds);
@@ -107,10 +107,10 @@
   if (changes > 3 || W.needs_redraw) {
     ypos += LINE_HEIGHT*2;

-    oled.clearWindow(0, ypos, RGB_OLED_WIDTH, ypos+FONT_Y);
+    oled.clearWindow(0, ypos, SCREEN_WIDTH, ypos+FONT_Y);

     sprintf(_sbuf, "%04d/%02d/%02d", W.year, W.month, W.day);
-    xpos = RGB_OLED_WIDTH - (8*FONT_X);
+    xpos = SCREEN_WIDTH - (8*FONT_X);
     xpos /= 2;
     oled.drawString(_sbuf, xpos, ypos, FONT_SIZE, W.color);
   }


small fix in demo

small fix in demo

set the correct pin number

--- examples/wifiLinkit/wifiLinkit.ino
+++ examples/wifiLinkit/wifiLinkit.ino
@@ -35,12 +35,12 @@
 char clientId[] = "YOUR_CLIENT_ID_HERE";
 char clientKey[] = "YOUR_CLIENT_KEY_HERE";

-//Warning the LinkIt maps pin numbers differently compared to the arduino. LinkIt pin numbers can be
+//Warning the LinkIt maps some pin numbers differently compared to the arduino. LinkIt pin numbers can be
 //bigger then 9, which doesn't work well with the AllthingsTalk library: it expects asset id's between 0 and 9,
 //the solution: define a different asset id for each pin, which is in the correct range.
 int a0=A0;
 int a0Id=0;
-int a1=13;
+int a1=8;
 int a1Id=1;

 ATTDevice Device(deviceId, clientId, clientKey);                //create the object that provides the connection to the cloud to manager the device.


Adds configuration overrides for gridconnect params to make the output performance better.

--- arduino/examples/ESP32IOBoard/ESP32IOBoard.ino
+++ arduino/examples/ESP32IOBoard/ESP32IOBoard.ino
@@ -75,6 +75,9 @@
 // used to generate the cdi.xml file. Here we instantiate the configuration
 // layout. The argument of offset zero is ignored and will be removed later.
 static constexpr openlcb::ConfigDef cfg(0);
+
+OVERRIDE_CONST(gridconnect_buffer_size, 512);
+OVERRIDE_CONST(gridconnect_buffer_delay_usec, 2000);

 // Declare output pins
 GPIO_PIN(IO0, GpioOutputSafeLow, 2);
@@ -210,7 +213,7 @@
     // Dump all packets as they are sent/received.
     // Note: This should not be enabled in deployed nodes as it will
     // have performance impact.
-    openmrn.stack()->print_all_packets();
+    // openmrn.stack()->print_all_packets();

     // Start the TCP/IP listener
     openMRNServer.setNoDelay(true);


Default no shift in VFO mode.

Default no shift in VFO mode.

--- src/Arduino/_23cm-trx/_23cm-trx.ino
+++ src/Arduino/_23cm-trx/_23cm-trx.ino
@@ -68,7 +68,7 @@
 /* TRX related settings */
 unsigned long rxFreqHz = 1298375000; // Defaults to PI2NOS
 int subAudioIndex      = -1;         // -1 is no audio. See subaudio.ino.
-int repeaterShiftIndex = 0;          // Min 0, max 4, see PLL.ino
+int repeaterShiftIndex = 2;          // No shift. See PLL.ino

 /* Loop structure */
 const byte LOOP_VFO      = 0;


celebrate and full batt 90 degree angles

--- sparkcode/ourrobotoverload.ino
+++ sparkcode/ourrobotoverload.ino
@@ -45,7 +45,7 @@
     int result = robotAction(command[i]);
     if(result == -1)
     {
-      return -1;
+        return -1;
     }
   }
   return 1;
@@ -97,7 +97,7 @@
     digitalWrite(leftMotorEnable,HIGH);
     digitalWrite(rightMotorEnable,HIGH);

-    delay(1250); // 90 Degrees, or angle times 13.8889
+    delay(833.33); // 90 Degrees, or angle times 13.8889
     return 1;
   }

@@ -109,12 +109,39 @@
     digitalWrite(leftMotorEnable,HIGH);
     digitalWrite(rightMotorEnable,HIGH);

-    delay(1250); // 90 Degrees
+    delay(833.33); // 90 Degrees
+    return 1;
+  }
+
+    if(command == 'C') //CELEBRATE
+  {
+    digitalWrite(leftMotorEnable,HIGH);
+    digitalWrite(rightMotorEnable,HIGH);
+
+    digitalWrite(leftMotorDir,LOW);
+    digitalWrite(rightMotorDir,HIGH);
+
+    delay(833.33);
+
+    digitalWrite(leftMotorDir,HIGH);
+    digitalWrite(rightMotorDir,LOW);
+
+    delay(833.33);
+
+    digitalWrite(leftMotorDir,LOW);
+    digitalWrite(rightMotorDir,HIGH);
+
+    delay(833.33);
+
+    digitalWrite(leftMotorDir,HIGH);
+    digitalWrite(rightMotorDir,LOW);
+
+    delay(4166.65);
+
+
     return 1;
   }

   // If none of the commands were executed, return false
   return -1;
 }
-
-


Testing additional power down of ATtiny internal modules.

--- examples/VWI/CosaVWItempsensor/CosaVWItempsensor.ino
+++ examples/VWI/CosaVWItempsensor/CosaVWItempsensor.ino
@@ -69,6 +69,8 @@
   VWI::disable();
   Power::adc_disable();
   Power::usi_disable();
+  Power::timer0_disable();
+  Power::timer1_disable();
 }

 // Message from the device. Use one-wire identity as virtual wire identity
@@ -88,12 +90,15 @@
   SLEEP(1);

   // Read temperature and send a message with identity and sequence number
+  Power::timer1_enable();
+  VWI::enable();
   sensor.read_scratchpad();
   memcpy(&msg.id, sensor.get_rom(), sizeof(msg.id));
   msg.nr = nr++;
   msg.temperature = sensor.get_temperature();
-  VWI::enable();
   tx.send(&msg, sizeof(msg));
   tx.await();
   VWI::disable();
+  Power::timer1_disable();
+  SLEEP(4);
 }


fixed #79

fixed #79

--- Modules/Modifier/Threshold/ArduinoCodes/ThresholdATtiny/ThresholdATtiny.ino
+++ Modules/Modifier/Threshold/ArduinoCodes/ThresholdATtiny/ThresholdATtiny.ino
@@ -42,6 +42,7 @@
 void loop()
 {
   int input_val = cutAndMap(input.filteredAnalogRead(AVERAGE), 50, 975, 0, 1023);
+  int output_val = 0;

   /*if(input_val < 0)
     input_val = 0;
@@ -52,9 +53,15 @@
   pot_val = cutAndMap(pot_val, 0, 1023, 1023, 0);

   if(state == LOW && input_val > pot_val+threshold)
+  {
     state = HIGH;
+    output_val = input_val/4;
+  }
   else if(state == HIGH && input_val < pot_val-threshold)
+  {
     state = LOW;
+    output_val = 0;
+  }

-  digitalWrite(output_pin, state);
+  digitalWrite(output_pin, output_val);
 }


modify example to use while loop, so it's more compact

--- examples-ltc/2.Effects/2_CascadeDefault/DefaultCode-LightCascade.ino
+++ examples-ltc/2.Effects/2_CascadeDefault/DefaultCode-LightCascade.ino
@@ -3,172 +3,44 @@
 // This is the default, out-of-box program loaded on the Chibi Chip:
 // a cascade of fading LEDs, wiping from left to right

-// The demo uses multi-threading to control every LED independently.
+// The demo uses multi-threading and while loops to control every LED
+// independently.

 #include "ChibiOS.h"

-int blink[6] = {0,0,0,0,0,0};
+#define HEAP_SIZE 32
+static int blink[6] = {0,0,0,0,0,0};

 #define FADE_RATE 4

-static THD_WORKING_AREA(blinky_area, 64);
 static THD_FUNCTION(do_blinky, arg) {
-  (void)arg;
+  int pin = (uint32_t)arg;
   int depth = 0;

+  pinMode(pin, OUTPUT);
+  digitalWrite(pin, 0);
+
   while (1) {
-    if (blink[0]) {
+    if (blink[pin]) {
       for (depth = 0; depth < 255; depth += FADE_RATE) {
-        analogWrite(A0, depth);
+        analogWrite(pin, depth);
         delay(10);
       }
       for (depth = 255; depth > 0; depth -= FADE_RATE) {
-        analogWrite(A0, depth);
+        analogWrite(pin, depth);
         delay(10);
       }
-      blink[0] = 0;
+      blink[pin] = 0;
     }
-    analogWrite(A0, 0);
+    analogWrite(pin, 0);
     delay(1);
   }
 }

-static THD_WORKING_AREA(blinky_area1, 64);
-static THD_FUNCTION(do_blinky1, arg) {
-  (void)arg;
-  int depth = 0;
-
-  while (1) {
-    if( blink[1] ) {
-      for( depth = 0; depth < 255; depth += FADE_RATE ) {
-        analogWrite(A1, depth);
-        delay(10);
-      }
-      for( depth = 255; depth > 0; depth -= FADE_RATE ) {
-        analogWrite(A1, depth);
-        delay(10);
-      }
-      blink[1] = 0;
-    }
-    analogWrite(A1, 0);
-    delay(1);
-  }
-}
-
-static THD_WORKING_AREA(blinky_area2, 64);
-static THD_FUNCTION(do_blinky2, arg) {
-  (void)arg;
-  int depth = 0;
-
-  while (1) {
-    if( blink[2] ) {
-      for( depth = 0; depth < 255; depth += FADE_RATE ) {
-        analogWrite(A2, depth);
-        delay(10);
-      }
-      for( depth = 255; depth > 0; depth -= FADE_RATE ) {
-        analogWrite(A2, depth);
-        delay(10);
-      }
-      blink[2] = 0;
-    }
-    analogWrite(A2, 0);
-    delay(1);
-  }
-}
-
-static THD_WORKING_AREA(blinky_area3, 64);
-static THD_FUNCTION(do_blinky3, arg) {
-  (void)arg;
-  int depth = 0;
-
-  while (1) {
-    if( blink[3] ) {
-      for( depth = 0; depth < 255; depth += FADE_RATE ) {
-        analogWrite(A3, depth);
-        delay(10);
-      }
-      for( depth = 255; depth > 0; depth -= FADE_RATE ) {
-        analogWrite(A3, depth);
-        delay(10);
-      }
-      blink[3] = 0;
-    }
-    analogWrite(A3, 0);
-    delay(1);
-  }
-}
-
-static THD_WORKING_AREA(blinky_area4, 64);
-static THD_FUNCTION(do_blinky4, arg) {
-  (void)arg;
-  int depth = 0;
-
-  while (1) {
-    if( blink[4] ) {
-      for( depth = 0; depth < 255; depth += FADE_RATE ) {
-        analogWrite(A4, depth);
-        delay(10);
-      }
-      for( depth = 255; depth > 0; depth -= FADE_RATE ) {
-        analogWrite(A4, depth);
-        delay(10);
-      }
-      blink[4] = 0;
-    }
-    analogWrite(A4, 0);
-    delay(1);
-  }
-}
-
-static THD_WORKING_AREA(blinky_area5, 64);
-static THD_FUNCTION(do_blinky5, arg) {
-  (void)arg;
-  int depth = 0;
-
-  while (1) {
-    if( blink[5] ) {
-      for (depth = 0; depth < 255; depth += FADE_RATE) {
-        analogWrite(A5, depth);
-        delay(10);
-      }
-      for (depth = 255; depth > 0; depth -= FADE_RATE) {
-        analogWrite(A5, depth);
-        delay(10);
-      }
-      blink[5] = 0;
-    }
-    analogWrite(A5, 0);
-    delay(1);
-  }
-}
-
-
 void setup(void) {
-  pinMode(A0, OUTPUT);
-  digitalWrite(A0, 0);
-
-  pinMode(A1, OUTPUT);
-  digitalWrite(A1, 0);
-
-  pinMode(A2, OUTPUT);
-  digitalWrite(A2, 0);
-
-  pinMode(A3, OUTPUT);
-  digitalWrite(A3, 0);
-
-  pinMode(D0, OUTPUT);
-  digitalWrite(D0, 0);
-
-  pinMode(D1, OUTPUT);
-  digitalWrite(D1, 0);
-
-  createThread(blinky_area, sizeof(blinky_area), 20, do_blinky, NULL);
-  createThread(blinky_area1, sizeof(blinky_area1), 20, do_blinky1, NULL);
-  createThread(blinky_area2, sizeof(blinky_area2), 20, do_blinky2, NULL);
-  createThread(blinky_area3, sizeof(blinky_area3), 20, do_blinky3, NULL);
-  createThread(blinky_area4, sizeof(blinky_area4), 20, do_blinky4, NULL);
-  createThread(blinky_area5, sizeof(blinky_area5), 20, do_blinky5, NULL);
+  int i;
+  for (i = 0; i < 6; i++)
+    createThreadFromHeap(HEAP_SIZE, 20, do_blinky, (void *)i);
 }

 void loop(void) {
@@ -178,5 +50,5 @@
     delay(500);
     blink[j] = 1;
   }
-  delay(1000); // added to keep patterns from overlapping
+  delay(1000); // prevent effects from overlapping
 }


Update Tuto1_DHT22WebserverESP8266_SPIFFS.ino

--- Tuto1_DHT22WebserverESP8266_SPIFFS/Tuto1_DHT22WebserverESP8266_SPIFFS.ino
+++ Tuto1_DHT22WebserverESP8266_SPIFFS/Tuto1_DHT22WebserverESP8266_SPIFFS.ino
@@ -1,10 +1,10 @@
 /*
  * ESP8266 + DHT22 + BMP180 + BOOTSTRAP + SPIFFS
  *
- * Step 1 - Start Project ESP8266 Web Server + SPIFFS + Bootstrap
+ * Part 1 - Start Project ESP8266 Web Server + SPIFFS + Bootstrap
  * Full tutorial on http://www.diyprojects.io/esp8266-web-server-part-1-store-web-interface-spiffs-area-html-css-js/
  *
- * Etape 1 - Démarrage du projet ESP8266 Web Serveur + Bootstrap
+ * Partie 1 - Démarrage du projet ESP8266 Web Serveur + Bootstrap
  * Tutoriel complet sur http://www.projetsdiy.fr/esp8266-web-server-partie1-stockage-spiffs-interface-web/
  *
  *
@@ -24,6 +24,7 @@
  * Licence : MIT
  * Copyright (C) 2017 : www.projetsdiy.fr and www.diyprojects.io
  */
+#include <ESP8266WiFi.h>
 #include <ESP8266WebServer.h>
 #include <DHT.h>
 #include <Adafruit_BMP085.h>


TODO-721: WIP

TODO-721: WIP

--- Arduino/V0p2_Main/V0p2_Main.ino
+++ Arduino/V0p2_Main/V0p2_Main.ino
@@ -32,6 +32,9 @@

 #ifdef ALLOW_CC1_SUPPORT
 #include <OTProtocolCC.h>
+#endif
+#if defined(ENABLE_OTSECUREFRAME_ENCODING_SUPPORT) || defined(ENABLE_SECURE_RADIO_BEACON)
+#include <OTAESGCM.h>
 #endif

 #include <util/crc16.h>


Initialize tft to NULL

Initialize tft to NULL

--- moros/moros.ino
+++ moros/moros.ino
@@ -67,11 +67,13 @@
     .cs_pin = 4,
     .dc_pin = 5,
     .rst_pin = 6,
+    .tft = NULL
   },
   {
     .cs_pin = 7,
     .dc_pin = 8,
     .rst_pin = 9,
+    .tft = NULL
   }
 };


Update sketch.ino

Update sketch.ino

--- dragino/sketch.ino
+++ dragino/sketch.ino
@@ -10,11 +10,15 @@

 char message_buff[100];

-
+////Please here paste info from "devinfo"//////////
 #define IOTUSERNAME "xxxxxxx"
 #define IOTPASSWORD "yyyyyyy"
 #define IOTDEVICE "zzzzzz"
 #define USERNAME "uuuuu"
+///////////////////////////////////////////////////
+
+
+////from here dont' modify anything///////////////////////////////////////////////

 #define TOPIC  "redlibre/iot/"USERNAME"/"IOTDEVICE"/"IOTUSERNAME"/iot/control/"
 #define STATUS "redlibre/iot/"USERNAME"/"IOTDEVICE"/"IOTUSERNAME"/status/"


Removed the "Y" eeprom test command. It actually did not test EEPROM but rather the memory cache. There is no reason for it to exist any longer.

--- GEVCU.ino
+++ GEVCU.ino
@@ -236,7 +236,7 @@
   SerialUSB.println("L = output raw input values (toggle)");
   SerialUSB.println("K = set all outputs high");
   SerialUSB.println("J = set all outputs low");
-  SerialUSB.println("Y,U,I = test EEPROM routines");
+  SerialUSB.println("U,I = test EEPROM routines");
   SerialUSB.println("");
 }

@@ -432,14 +432,6 @@
       else SerialUSB.println("Cease raw throttle output");
       break;
 #ifdef __arm__ // Arduino Due specific implementation
-      case 'Y':
-      SerialUSB.println("Trying to save 0x45 to eeprom location 10");
-      uint8_t temp;
-      MemCache.Write(10, (uint8_t) 0x45);
-      MemCache.Read(10, &temp);
-      SerialUSB.print("Got back value of ");
-      SerialUSB.println(temp);
-      break;
     case 'U':
       SerialUSB.println("Adding a sequence of values from 0 to 255 into eeprom");
       for (int i = 0; i<256; i++) MemCache.Write(1000+i,(uint8_t)i);


add tilt driving

add tilt driving

--- testing/arduino/self-driving-v6.ino
+++ testing/arduino/self-driving-v6.ino
@@ -46,17 +46,22 @@
 // Ultrasonic Servo
 Servo ServoMotor;
 const uint8_t servoPin = 10;
-uint8_t servoInitPos = 90;
-
-uint8_t servoLimitLeft = 10;
-uint8_t servoTiltLeft = 50;
-uint8_t servoLimitRight = 170;
-uint8_t servoTiltRight = 130;
-uint8_t servoCenter = 90;
+
+const uint8_t servoLimitLeft = 10;
+const uint8_t servoTiltLeft = 50;
+const uint8_t servoLimitRight = 170;
+const uint8_t servoTiltRight = 130;
+const uint8_t servoCenter = 90;
+
+enum direction {
+  LEFT,
+  NONE,
+  RIGHT
+};
+direction servoRangeDirection = NONE;

 // IR obstacle detection
 int obstaclePin = A1;
-

 void setup()
@@ -87,7 +92,7 @@

     // attach servo pin and set to initial direction
     ServoMotor.attach(servoPin);
-    ServoMotor.write(servoInitPos);
+    ServoMotor.write(servoCenter);
     ServoMotor.detach();
 }

@@ -96,10 +101,9 @@
     long range = sonar.ping_cm();

     // fallback if return value is out of range
+    if(range == 0 && rotating) { range = maxDistance; }
     if(range == 0) { range = lastRange; }
-    else { lastRange = range;}
-
-    if(range == 0 && rotating) { range = maxDistance; }
+    if(range > 0  && !rotating) { lastRange = range;}

     if(servoPos == servoCenter) { rangeCenter = range; }
     if(servoPos < servoCenter) { rangeLeft = range; }
@@ -183,6 +187,18 @@
     SetMotor(motorPin2_1, motorPin2_2, 0);
 }

+void SetServoRangeDirection()
+{
+    if(rangeLeft > rangeRight)
+    {
+        servoRangeDirection = LEFT;
+    }
+    else
+    {
+        servoRangeDirection = RIGHT;
+    }
+}
+
 void loop()
 {
     uint32_t uptime = millis();
@@ -194,7 +210,6 @@

     GetRange(servoPos, wheelSpinCompleted);

-
     // Wait for initial scans before performing any actions
     if(uptime < initialDelay)
     {
@@ -213,36 +228,63 @@
     }

     // obstacle is further away than X cm
-    if(wheelSpinCompleted && rangeCenter > rangeLimit_Stop)
-    {
-        // drive
+    // and no obstacle in front of the IR sensor
+    if(!obstacleFound || wheelSpinCompleted && rangeCenter > rangeLimit_Stop)
+    {
+        rangeLimit_Timestamp = uptime;
+
+        // slightly turn if side better than center
+        if(rangeCenter < rangeLimit_Warning1 && rangeRight > 0 && rangeLeft > 0)
+        {
+            if(rangeRight > rangeLeft && rangeRight > rangeCenter )
+            {
+                // drive straight
+                SetMotor(motorPin1_1, motorPin1_2, 255);
+                SetMotor(motorPin2_1, motorPin2_2, 128);
+            }
+
+            if(rangeLeft > rangeRight && rangeLeft > rangeCenter )
+            {
+                // drive straight
+                SetMotor(motorPin1_1, motorPin1_2, 128);
+                SetMotor(motorPin2_1, motorPin2_2, 255);
+            }
+        }
+
+
+        // drive straight
         SetMotor(motorPin1_1, motorPin1_2, 255);
         SetMotor(motorPin2_1, motorPin2_2, 255);

-        rangeLimit_Timestamp = uptime;
-    }
-
-    // TODO - slightly turn if side better than center
-
-    else
-    {
-        if(rangeLeft > rangeRight)
-        {
-            SetMotor(motorPin1_1, motorPin1_2, 255);
-            SetMotor(motorPin2_1, motorPin2_2, -255);
-        }
-        else
+        return;
+    }
+
+
+    else
+    {
+        if(servoRangeDirection == NONE)
+        {
+            SetServoRangeDirection();
+        }
+
+        if(servoRangeDirection == LEFT)
         {
             SetMotor(motorPin1_1, motorPin1_2, -255);
             SetMotor(motorPin2_1, motorPin2_2, 255);
         }
+        else
+        {
+            SetMotor(motorPin1_1, motorPin1_2, 255);
+            SetMotor(motorPin2_1, motorPin2_2, +255);
+        }

         wheelSpinCompleted = false;

         if(rangeCenter > rangeLimit_Warning3 && (rangeLimit_Timestamp + rangeLimit_RotateFor) <= uptime)
         {
             wheelSpinCompleted = true;
-        }
-    }
-}
-
+            servoRangeDirection = NONE;
+        }
+    }
+}
+


broken led fix

broken led fix

--- libgame/libgame.ino
+++ libgame/libgame.ino
@@ -267,6 +267,9 @@

     // call user render()
     render();
+
+    if (y == WIDTH / 4 - 1) // fix broken led
+        buf[WIDTH * 4 - 1] = 0;
 }

 void setup()


4 motor control!

4 motor control!

--- Arduino/TheKickAssSlider/TheKickAssSlider.ino
+++ Arduino/TheKickAssSlider/TheKickAssSlider.ino
@@ -10,6 +10,9 @@
 #define BLE_RST   7

 #define MOTOR_1_CONTROL_PIN   6
+#define MOTOR_2_CONTROL_PIN   5
+#define MOTOR_3_CONTROL_PIN   4
+#define MOTOR_4_CONTROL_PIN   3

 // create peripheral instance, see pinouts above
 BLEPeripheral            blePeripheral        = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST);
@@ -17,15 +20,24 @@
 // create service
 BLEService               sliderService           = BLEService("51d0");

-// create switch characteristic
+// create motor characteristics
 BLECharCharacteristic    motor1Characteristic = BLECharCharacteristic("51d1", BLERead | BLEWrite);
+BLECharCharacteristic    motor2Characteristic = BLECharCharacteristic("51d2", BLERead | BLEWrite);
+BLECharCharacteristic    motor3Characteristic = BLECharCharacteristic("51d3", BLERead | BLEWrite);
+BLECharCharacteristic    motor4Characteristic = BLECharCharacteristic("51d4", BLERead | BLEWrite);

 Servo motor1;
+Servo motor2;
+Servo motor3;
+Servo motor4;

 void setup() {
   Serial.begin(9600);

   motor1.attach(MOTOR_1_CONTROL_PIN);
+  motor2.attach(MOTOR_2_CONTROL_PIN);
+  motor3.attach(MOTOR_3_CONTROL_PIN);
+  motor4.attach(MOTOR_4_CONTROL_PIN);

   // set advertised local name and service UUID
   blePeripheral.setLocalName("TheKickAssSlider");
@@ -34,6 +46,9 @@
   // add service and characteristic
   blePeripheral.addAttribute(sliderService);
   blePeripheral.addAttribute(motor1Characteristic);
+  blePeripheral.addAttribute(motor2Characteristic);
+  blePeripheral.addAttribute(motor3Characteristic);
+  blePeripheral.addAttribute(motor4Characteristic);

   // begin initialization
   blePeripheral.begin();
@@ -52,11 +67,19 @@
     while (central.connected()) {
       // central still connected to peripheral
       if (motor1Characteristic.written()) {
-        unsigned char inputValue = motor1Characteristic.value();
+        updateMotorSpeed(motor1, motor1Characteristic.value());
+      }

-        int microSeconds = map(inputValue, -128, 127, 1000, 2000);
+      if (motor2Characteristic.written()) {
+        updateMotorSpeed(motor2, motor2Characteristic.value());
+      }

-        motor1.writeMicroseconds(microSeconds);
+      if (motor3Characteristic.written()) {
+        updateMotorSpeed(motor3, motor3Characteristic.value());
+      }
+
+      if (motor4Characteristic.written()) {
+        updateMotorSpeed(motor4, motor4Characteristic.value());
       }
     }

@@ -65,3 +88,10 @@
     Serial.println(central.address());
   }
 }
+
+void updateMotorSpeed(Servo& motor, unsigned char speed) {
+  int microSeconds = map(speed, -128, 127, 1000, 2000);
+
+  motor.writeMicroseconds(microSeconds);
+}
+


Update UbidotsSaveMultiValues.ino

Update UbidotsSaveMultiValues.ino

--- examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
+++ examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
@@ -5,11 +5,11 @@
 //at 19200 bps 8-N-1
 //Computer is connected to Hardware UART
 //GPRS Shield is connected to the Software UART
-
 #define APN "Your_apn_of_your_SIM_here"
-#define USER "Your_username_here"  // if your apn doesnt have username just put ""
-#define PASS "Your_password_here"  // if your apn doesnt have password just put ""
-#define TOKEN "Your_token_here"  // Remplace it with your token
+#define USER "Your_username_here"  // If your apn doesnt have username just put ""
+#define PASS "Your_password_here"  // If your apn doesnt have password just put ""
+#define TOKEN "Your_token_here"  // Replace it with your Ubidots token
+#define ID "Your_id_here" // Replace it with your Ubidots' variable ID
 // You can send 1 to 10 variable at the same time
 #define ID1 "Your_id_here" // Remplace it with your variable ID
 #define ID2 "Your_id_here" // Remplace it with your variable ID
@@ -33,16 +33,16 @@
   float value_4 = analogRead(A3);
   float value_5 = analogRead(A4);
   float value_6 = analogRead(A5);
-  // To send a value with a context is like: (ID,value,"NAME_CONTEXT:VALUE_CONTEXT","NAME_CONTEXT_2:VALUE_CONTEXT_2")
+  // To send a value with a context is like: (ID,value,"NAME_CONTEXT:VALUE_CONTEXT","")
   // If you don't want to send any context only put "" like this (ID,value,"","")
-  // Example:
-  // client.add(ID1, value_1, "Color:Red", "Sensor:Temp");
+  // Example with context:
+  // client.add(ID1, value_1, "Lat:9,786589", "Long:1,8688797");

-  client.add(ID1,value_1, "name_context_1:value_context_1", "name_context_2:value_context_2");
-  client.add(ID2,value_2, "name_context_1:value_context_1", "name_context_2:value_context_2");
-  client.add(ID3,value_3, "name_context_1:value_context_1", "name_context_2:value_context_2");
-  client.add(ID4,value_4, "name_context_1:value_context_1", "name_context_2:value_context_2");
-  client.add(ID5,value_5, "name_context_1:value_context_1", "name_context_2:value_context_2");
-  client.add(ID6,value_6, "name_context_1:value_context_1", "name_context_2:value_context_2");
+  client.add(ID1,value_1, "", "");
+  client.add(ID2,value_2, "", "");
+  client.add(ID3,value_3, "", "");
+  client.add(ID4,value_4, "", "");
+  client.add(ID5,value_5, "", "");
+  client.add(ID6,value_6, "", "");
   client.sendAll();
 }


Added serial debug printout of IR hex value for unknown codes. Just stupid not to...

--- Software/plotter/ir_control.ino
+++ Software/plotter/ir_control.ino
@@ -138,11 +138,10 @@
 #endif //NO_REMOTE
     }
     if(fail) {
-       SER_PRINTLN("???");
+       SER_PRINT("???: ");
     }
-    else {
-       SER_PRINTLN2(results.value, HEX);
-    }
+    SER_PRINTLN2(results.value, HEX);
+
     irrecv.resume(); // Receive the next value
   }
 }


Code cleanup Substituted all parameters with #define Added more comments

--- quadcopter/quadcopter.ino
+++ quadcopter/quadcopter.ino
@@ -10,7 +10,10 @@
 #define DEBUG

-// Arduino pin setup
+/*  Arduino Pin configuration
+ *
+ */
+
 #define ESC_A 9
 #define ESC_B 6
 #define ESC_C 5
@@ -23,56 +26,81 @@
 #define RC_5 8
 #define RC_PWR A0

-// PID configuration
-#define pKp 2
-#define pKi 5
-#define pKd 1
-
-#define rKp 0.1
-#define rKi 0.05
-#define rKd 0.25
-
-#define yKp 0.1
-#define yKi 0.05
-#define yKd 0.25
-
-/*
-  Arducopter v1.0
-
-  RC Channels:
-
-    Throttle - CH3
-    Pitch    - CH2
-    Roll     - CH1
-    Yaw      - CH4
-    Aux      - CH5
-
-
-*/
-
-// MPU SETUP //
-
-MPU6050 mpu; // mpu interface object
-
-bool dmpReady = false; //flag
-uint8_t mpuIntStatus;  //mpu statusbyte
-uint8_t devStatus; //device status byte
-uint16_t packetSize; //estimated packet size
-uint16_t fifoCount; //fifo buffer size
-uint8_t fifoBuffer[64]; //fifo buffer
-
-Quaternion q; //quaternion for mpu output
-VectorFloat gravity; //gravity vector for ypr
-float ypr[3] = {0.0f,0.0f,0.0f}; // yaw pitch roll values
-
-volatile bool mpuInterrupt = false; //interrupt flag
-
-// RC/CONTROL SETUP
-
-float ch1, ch2, ch3, ch4, ch5; //RC channel inputs
-float ch3_smooth = 1000;
-int va, vb, vc, vd; //velocities
-int v_ac, v_bd; // velocity of axes
+
+/* ESC configuration
+ *
+ */
+
+#define ESC_MIN 22
+#define ESC_MAX 115
+#define ESC_TAKEOFF_OFFSET 30
+#define ESC_ARM_DELAY 5000
+
+/* RC configuration
+ *
+ */
+
+#define RC_HIGH 1000
+#define RC_LOW 2000
+
+/*  PID configuration
+ *
+ */
+
+#define PITCH_P_VAL 2
+#define PITCH_I_VAL 5
+#define PITCH_D_VAL 1
+
+#define ROLL_P_VAL 2
+#define ROLL_I_VAL 5
+#define ROLL_D_VAL 1
+
+#define YAW_P_VAL 2
+#define YAW_I_VAL 5
+#define YAW_D_VAL 1
+
+
+/* Flight parameters
+ *
+ */
+
+#define PITCH_MIN -45
+#define PITCH_MAX 45
+#define ROLL_MIN -45
+#define ROLL_MAX 45
+#define YAW_MIN -180
+#define YAW_MAX 180
+#define PID_PITCH_INFLUENCE 15
+#define PID_ROLL_INFLUENCE 15
+#define PID_YAW_INFLUENCE 15
+
+
+/*  MPU variables
+ *
+ */
+
+MPU6050 mpu;                           // mpu interface object
+
+
+uint8_t mpuIntStatus;                  // mpu statusbyte
+uint8_t devStatus;                     // device status
+uint16_t packetSize;                   // estimated packet size
+uint16_t fifoCount;                    // fifo buffer size
+uint8_t fifoBuffer[64];                // fifo buffer
+
+Quaternion q;                          // quaternion for mpu output
+VectorFloat gravity;                   // gravity vector for ypr
+float ypr[3] = {0.0f,0.0f,0.0f};       // yaw pitch roll values
+
+volatile bool mpuInterrupt = false;    //interrupt flag
+
+
+/*  RC variables
+ *
+ */
+
+float ch1, ch2, ch3, ch4, ch5;         // RC channel inputs
+float ch3_smooth = 1000;               // may be unnecessary with new input method

 unsigned long rcLastChange1 = millis();
 unsigned long rcLastChange2 = millis();
@@ -80,71 +108,82 @@
 unsigned long rcLastChange4 = millis();
 unsigned long rcLastChange5 = millis();

-// MOTOR SETUP
-
-int velocity; //global velocity
-
-float bal_ac, bal_bd; // motor balances can vary between -100 & 100
-float bal_axes; // throttle balance between axes -100:ac , +100:bd
+/*  Motor controll variables
+ *
+ */
+
+int velocity;                         // global velocity
+
+float bal_ac, bal_bd;                 // motor balances can vary between -100 & 100
+float bal_axes;                       // throttle balance between axes -100:ac , +100:bd
+
+int va, vb, vc, vd;                   //velocities
+int v_ac, v_bd;                       // velocity of axes

 Servo a,b,c,d;

-// PID SETUP
-
-PID pitchReg(&ypr[1], &bal_bd, &ch2, pKp, pKi, pKd, REVERSE);
-PID rollReg(&ypr[2], &bal_ac, &ch1, rKp, rKi, rKd, REVERSE);
-PID yawReg(&ypr[0], &bal_axes, &ch4, yKp, yKi, yKd, DIRECT);
-
+/*  PID variables
+ *
+ */
+
+PID pitchReg(&ypr[1], &bal_bd, &ch2, PITCH_P_VAL, PITCH_I_VAL, PITCH_D_VAL, REVERSE);
+PID rollReg(&ypr[2], &bal_ac, &ch1, ROLL_P_VAL, ROLL_I_VAL, ROLL_D_VAL, REVERSE);
+PID yawReg(&ypr[0], &bal_axes, &ch4, YAW_P_VAL, YAW_I_VAL, YAW_D_VAL, DIRECT);
+
+
+/*  Setup function
+ *
+ */

 void setup(){

-  initRC();
+  initRC();                            // Self explaining
   initMPU();
   initESCs();
   initBalancing();
   initRegulators();

-  #ifdef DEBUG
-
-  Serial.begin(9600);
+  #ifdef DEBUG                        // Device tests go here
+
+  Serial.begin(9600);                 // Serial only necessary if in DEBUG mode
   Serial.flush();
   Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

   #endif
 }

+/* loop function
+ *
+ */
+
 void loop(){

   while(!mpuInterrupt && fifoCount < packetSize){
-     //Do nothing
-     //This should be a VERY short period
-  }
-
-  getYPR();
+
+    /* Do nothing while MPU is not working
+     * This should be a VERY short period
+     */
+
+  }
+
+  getYPR();
   computePID();
   calculateVelocities();
   updateMotors();

 }

-void initRegulators(){
-
-  pitchReg.SetMode(AUTOMATIC);
-  pitchReg.SetOutputLimits(-15, 15);
-
-  rollReg.SetMode(AUTOMATIC);
-  rollReg.SetOutputLimits(-20, 20);
-
-  yawReg.SetMode(AUTOMATIC);
-  yawReg.SetOutputLimits(-20, 20);
-
-}
+/*  computePID function
+ *
+ *  formats data for use with PIDLib
+ *  and computes PID output
+ */

 void computePID(){

-  ch2 = map(ch2, 100, 200, -45, 45);
-  ch1 = map(ch1, 100, 200, -45, 45);
-  ch4 = map(ch4, 100, 200, -180, 180);
+  ch2 = map(ch2, RC_LOW, RC_HIGH, PITCH_MIN, PITCH_MAX);
+  ch1 = map(ch1, RC_LOW, RC_HIGH, ROLL_MIN, ROLL_MAX);
+  ch4 = map(ch4, RC_LOW, RC_HIGH, YAW_MIN, YAW_MAX);

   ypr[0] = ypr[0] * 180/M_PI;
   ypr[1] = ypr[1] * 180/M_PI;
@@ -155,6 +194,12 @@
   yawReg.Compute();

 }
+
+/*  getYPR function
+ *
+ *  gets data from MPU and
+ *  computes pitch, roll, yaw on the MPU's DMP
+ */

 void getYPR(){

@@ -183,9 +228,15 @@

 }

+/*  calculateVelocities function
+ *
+ *  calculates the velocities of every motor
+ *  using the PID output
+ */
+
 void calculateVelocities(){

-  velocity = map(ch3, 100, 200, 115, 22);
+  velocity = map(ch3, RC_LOW, RC_HIGH, ESC_MIN, ESC_MAX);

   v_ac = (abs(-100+bal_axes)/100)*velocity;
   v_bd = ((100+bal_axes)/100)*velocity;
@@ -196,26 +247,25 @@
   vc = (abs((-100+bal_ac)/100))*v_ac;
   vd = (abs((-100+bal_bd)/100))*v_bd;

-  if(velocity < 30){
-
-    va = 22;
-    vb = 22;
-    vc = 22;
-    vd = 22;
+  if(velocity < ESC_TAKEOFF_OFFSET){
+
+    va = ESC_MIN;
+    vb = ESC_MIN;
+    vc = ESC_MIN;
+    vd = ESC_MIN;

   }

   #ifdef DEBUG

   //Serial.print("A: "+String(va)+" B: "+String(vb)+" C: "+String(vc)+" D: "+String(vd));
-  Serial.print("AC: ");
+  /*Serial.print("AC: ");
   Serial.print(bal_ac);
   Serial.print(" BD: ");
   Serial.print(bal_bd);
-  Serial.println("");
+  Serial.println("");*/
   #endif

-
 }

 void updateMotors(){
@@ -229,12 +279,12 @@

 void arm(){

-  a.write(22);
-  b.write(22);
-  c.write(22);
-  d.write(22);
-
-  delay(5000);
+  a.write(ESC_MIN);
+  b.write(ESC_MIN);
+  c.write(ESC_MIN);
+  d.write(ESC_MIN);
+
+  delay(ESC_ARM_DELAY);

 }

@@ -280,7 +330,6 @@
     mpu.setDMPEnabled(true);
     attachInterrupt(0, dmpDataReady, RISING);
     mpuIntStatus = mpu.getIntStatus();
-    dmpReady = true;
     packetSize = mpu.dmpGetFIFOPacketSize();

   }
@@ -307,6 +356,19 @@

 }

+void initRegulators(){
+
+  pitchReg.SetMode(AUTOMATIC);
+  pitchReg.SetOutputLimits(-PID_PITCH_INFLUENCE, PID_PITCH_INFLUENCE);
+
+  rollReg.SetMode(AUTOMATIC);
+  rollReg.SetOutputLimits(-PID_ROLL_INFLUENCE, PID_ROLL_INFLUENCE);
+
+  yawReg.SetMode(AUTOMATIC);
+  yawReg.SetOutputLimits(-PID_YAW_INFLUENCE, PID_YAW_INFLUENCE);
+
+}
+
 void rcInterrupt1(){
    ch1 = millis() - rcLastChange1;
    rcLastChange1 = millis();


Removed unneccessary identation

Removed unneccessary identation

--- examples/AccessPointFader/AccessPointFader.ino
+++ examples/AccessPointFader/AccessPointFader.ino
@@ -42,9 +42,9 @@

   WiFi.softAP(ssid, password);

-	IPAddress myIP = WiFi.softAPIP();
-	Serial.print("AP IP address: ");
-	Serial.println(myIP);
+  IPAddress myIP = WiFi.softAPIP();
+  Serial.print("AP IP address: ");
+  Serial.println(myIP);

   if (mdns.begin("esp8266", WiFi.localIP())) {
     Serial.println("MDNS responder started");


moved the dynon defines toward the top.. easier to find. default to d100

--- AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
+++ AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
@@ -13,6 +13,9 @@
 //
 // 7/9/2018 - fix for tone PPS between solid tones.  was not calucating the right ratio for the PPS changes.

+#define SETUP_DYNON_D100             // if this is defined then use settings (dynon D10 or D100)
+//#define SETUP_DYNON_SKYVIEW            // if defined then use settings for dynon skyview
+
 #include <DueTimer.h>         // timer lib functions for using DUE timers and callbacks.
 #include <stdint.h>
 #include <Arduino.h>
@@ -46,11 +49,9 @@
 #define DYNON_SERIAL_LEN              53
 #define DYNON_SKYVIEW_SERIAL_LEN      74

-//#define SETUP_DYNON_D100 1            // if this is defined then use settings (dynon D10 or D100)
-#define SETUP_DYNON_SKYVIEW 1           // if defined then use settings for dynon skyview
-
 #ifdef SETUP_DYNON_SKYVIEW
   // Dynon Skyview settings.
+  // For skyview export ahrs data out one of the 5 serialports (only needs serial output to AOA box, no serial input needed)
   // AOA values & Tone Pulse Per Sec (PPS)
   #define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
   #define HIGH_TONE_AOA_STALL   80      // % (and above) where stall happens.
@@ -64,8 +65,7 @@
   #define LOW_TONE_PPS_MAX      6.5
   #define LOW_TONE_PPS_MIN      0.5
   #define LOW_TONE_HZ           400     // freq of low tone
-  #define BAUDRATE_EFIS         9600
-
+  #define BAUDRATE_EFIS         9600    // set skyview to 9600 (or change this value to what you want)
 #else
 #ifdef SETUP_DYNON_D100
   // Dynon D100 or D10 settings.
@@ -99,10 +99,8 @@
   #define LOW_TONE_PPS_MIN      1.5
   #define LOW_TONE_HZ           400     // freq of low tone
   #define BAUDRATE_EFIS         115200
-
-#endif
-#endif
-
+#endif
+#endif

 #define TONE_PIN              2     // TIOA0
 #define PIN_LED1              13    // internal LED for showing AOA status.


fixed RPM calc code and interrupt type

fixed RPM calc code and interrupt type

--- Exhibit_MomentumTable.ino
+++ Exhibit_MomentumTable.ino
@@ -17,8 +17,11 @@
 #define DISCSLIPCOUNT       250     //How long alarm cond before alarm signal
 #define LOCKEDDISCRPM       30     //RPM to consider as "disc stopped"
 #define ROTATIONVARIANCE    2      //Variance in RPM before alarm condition
+
+#define LOCKEDDISCRPM       10      //RPM to consider as "disc stopped"
+#define ROTATIONVARIANCE    50      //Variance in RPM before alarm condition
 //#define TRANSMISSIONRATIO   10      //Tranmission drive ratio n:1
-#define NUMBEROFRESTARTS    3     //#of restarts attempted after stopped state
+#define NUMBEROFRESTARTS    5      //#of restarts attempted after stopped state
 #define STARTTIME           10000   //Expected ramp up time, in MS
 #define STOPTIME            10000   //Expected ramp down time, in MS
  /////////
@@ -48,7 +51,6 @@
 uint8_t discSlipPrecond     = 0 ;
 uint8_t restartCount        = 0 ;
 char msg[50];
-uint8_t reconnectAttempt 	= 0;

 /**************************************/
 /*               SETUP                 /
@@ -72,17 +74,16 @@
 /*                LOOP                 /
 /**************************************/
 void loop(){
-	delay(3);
 if  (allStopVar == 0){
     calculateRPM();
     discSlipCheck();
-    lockedRotorCheck();
+   // lockedRotorCheck();
 }
-    now = millis();
+    //now = millis();
     //MQTT Connection Check
-	//if (!client.connected()) {
-	//	reconnect();
-    //}
+    //if (!client.connected()) {
+    //reconnect();
+   // }
     //client.loop();
 }

@@ -97,34 +98,34 @@

 void calculateRPM(){
 if (millis() - prevMillis >= 5000){
-	Serial.println("CalculatingRPM");
     detachInterrupt(HALLSENSORPIN);              //disable interrupts while running calculate
-    rpm = pulseCount * 6;          //converting frequency to RPM(two magnets on disc x 5 sec)
+    rpm = pulseCount * 6;          //converting frequency to RPM
     pulseCount = 0;                 //reset pulse counter
     prevMillis = millis();          //update prevMillis
     Serial.print("RPM: ");
     Serial.println(rpm);
     attachInterrupt(digitalPinToInterrupt(HALLSENSORPIN), sensorPulseCount, FALLING);
-    }
+		}
   }

 void motionControlStart(){
+    Serial.println("Motor Control Start");
     if (restartCount < NUMBEROFRESTARTS){
-	    Serial.println("Motor Control Start");
-		digitalWrite(STARTRELAYPIN, HIGH); // enable start relay if not above fail counter
-        delay(3000); // wait for 3 second for a rotation
+        digitalWrite(STARTRELAYPIN, HIGH); // enable start relay if not above fail counter
+        delay(5000); // wait for 2 second for a rotation
         if (pulseCount == 0){               // if no rotation detected in interrupt
             digitalWrite(STARTRELAYPIN, LOW); // turn off motor becuase of no rotation
 			Serial.println("No rotation detected -- attempting restart");
             restartCount++;
-            delay (10000); // delay 10 seconds before attempting restart
+            delay (3000); // delay 3 seconds before attempting restart
             pulseCount = 0; // reset pulse count
             motionControlStart();
             }
         if (pulseCount > 1){
         Serial.println("motion started, system running");
 		delay(3000); 	// wait 3 seconds for disc to come up to fast enough speed
-						// to not trip locked rotor function
+						// to not trip locked rotor functiion
+		pulseCount = 0;
         restartCount = 0; // set restart counter to 0, since we're started
         allStopVar = 0; // Set allstop condition to off
         }
@@ -150,13 +151,11 @@
 }

 void discSlipCheck(){
-    if (rpm < (DESIREDRPM_TABLE - ROTATIONVARIANCE && allStopVar == 0)){
+    if (rpm < (DESIREDRPM_TABLE - ROTATIONVARIANCE)){
         discSlipPrecond++;
-		Serial.println("Disc is slipping from nominal RPM");
-		Serial.println(discSlipPrecond);
         }
     else
-        if (rpm >= (DESIREDRPM_TABLE - ROTATIONVARIANCE && allStopVar == 0)){
+        if (discSlipPrecond > 0){
         discSlipPrecond--;
         }
     if (discSlipPrecond > DISCSLIPCOUNT){
@@ -168,20 +167,17 @@
 void lockedRotorCheck(){
     if (rpm <= LOCKEDDISCRPM){
         digitalWrite(STARTRELAYPIN, LOW); // immediately shut down if RPM lowByte
-        client.publish(TOPIC_T, "CritErr: Disc rotation is locked, attempting restart");
-		Serial.println("Disc motion has been stopped. Attempting Restart");
-		delay(10000);
-		motionControlStart();
-		}
-
+        }
+        client.publish(TOPIC_T, "CritErr: Disc rotation is locked, attempting restart");
 }

 void allStop(){
     digitalWrite(STARTRELAYPIN, LOW);
     Serial.println("System in All-Stop");
+    delay(5000);
     client.publish(TOPIC_T, "CritErr: System halted. All stop active. Restart Required");
     allStopVar = 1;
-    delay(10000);
+    loop();
     }
 void exhibitStatusMsg(){
     char gs_msg [50];


Fix stupid bug

Fix stupid bug

I wondered why it never said anything other than "m"

--- lcd_temperature_display.ino
+++ lcd_temperature_display.ino
@@ -312,7 +312,6 @@
       // Then do the low
       timediff = minutesAgo(low_temp.time);
       normalizeTime(&timediff, &timespec);
-      timespec = 'm';

       lcd.setCursor(0, 1);
       snprintf(outstr, 17, "L%3d.%1d@%2d%c  deg%1c", low_temp.temperature/10,


Pull down LPG switching pin

Pull down LPG switching pin

--- MID/MID.ino
+++ MID/MID.ino
@@ -111,8 +111,7 @@
     carStat.setWorkState(eepRom.getWorkDistance());
     //
     // TODO testing ...
-
-#ifdef ADT_FUEL_SYSTEM_SERIAL
+#ifdef LPG_SWITCHING_DETECT
     lpgCom.begin();
 #endif


Update Radar test

Update Radar test


Removed old code

Removed old code

--- DiamondOre.ino
+++ DiamondOre.ino
@@ -12,20 +12,6 @@
 #define PIXEL_TYPE WS2812B

 Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
-
-// 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);
-  }
-}

 int cloud_set_colors(String _colors) {
   Serial.print("Received new colors from the cloud: "); Serial.println(_colors);


Removed a lot of debug, general clean up

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -15,12 +15,12 @@
 #include <EEPROM.h>

-//#define DEBUG   // define if debugging
+#define DEBUG   // define if debugging

 // Digital VFO program name & version
-const char *ProgramName = "Digital VFO";
-const char *Version = "0.5";
+const char *ProgramName = "DigitalVFO";
+const char *Version = "0.6";
 const char *Callsign = "vk4fawr";
 const char *Callsign16 = "vk4fawr         ";

@@ -100,13 +100,16 @@
 #define vfo_HoldClick 6

 ////////////////////////////////////////////////////////////////////////////////
-// The VFO state variables
+// The VFO state variables and typedefs
 ////////////////////////////////////////////////////////////////////////////////

 typedef unsigned long Frequency;
-
 Frequency VfoFrequency;     // VFO frequency (Hz)
-byte VfoSelectDigit;        // selected column index, zero at the right
+
+typedef int SelOffset;
+SelOffset VfoSelectDigit;   // selected column index, zero at the right
+
+typedef byte VFOEvent;

 ////////////////////////////////////////////////////////////////////////////////
@@ -117,26 +120,48 @@
 // Abort the program.
 // Tries to tell the world what went wrong, then just loops.
 //     msg  address of error string
+// Only first 32 chars of message is displayed.
 //----------------------------------------------------------

 void abort(const char *msg)
 {
+  char buf[NUM_COLS*2+1];
+  char *ptr = buf;
+
   // print error on console (maybe)
   Serial.println(msg);
   Serial.println("Teensy is paused!");

+  // truncate/pad message to 32 chars
+  for (int i = 0; i < NUM_COLS*2; ++i)
+    *ptr++ = ' ';
+  *ptr = '\0';
+  Serial.print("buf='"); Serial.print(buf); Serial.println("'");
+
+  strncpy(buf, msg, NUM_COLS*2);
+  Serial.print("buf='"); Serial.print(buf); Serial.println("'");
+  if (strlen(msg) < NUM_COLS*2)
+    strncpy(buf + strlen(msg), "                                ", NUM_COLS*2 - strlen(msg));
+  Serial.print("buf='"); Serial.print(buf); Serial.println("'");
+
   // show what we can on the display, forever
   while (1)
   {
     lcd.clear();
     lcd.setCursor(0, 0);
-    lcd.write(msg);
+    lcd.write(buf);
     lcd.setCursor(0, 1);
-    lcd.write(msg + NUM_COLS);
+    lcd.write(buf + NUM_COLS);
     delay(2000);

     lcd.clear();
-    lcd.write("Teensy is paused");
+    lcd.setCursor(0, 0);
+    lcd.write(" ");   // padding to centre name+version
+    lcd.write(ProgramName);
+    lcd.write(" ");
+    lcd.write(Version);
+    lcd.setCursor(0, 1);
+    lcd.write("   is paused");
     delay(2000);
   }
 }
@@ -145,8 +170,7 @@
 // Convert an event number to a display string
 //----------------------------------------------------------

-#ifdef DEBUG
-const char * event2display(byte event)
+const char * event2display(VFOEvent event)
 {
   switch (event)
   {
@@ -160,7 +184,6 @@
     default:            return "UNKNOWN!";
   }
 }
-#endif

 // display a simple banner
 void banner(void)
@@ -270,12 +293,7 @@
 {
   int item_index = 0;

-  Serial.print("show_menu("); Serial.print(menu->title); Serial.println(")");
   // update the menu display
-  Serial.print("Calling menu->display: menu->title=");
-  Serial.print(menu->title);
-  Serial.print(", item_index=");
-  Serial.println(item_index);
   menu->display(menu, item_index);

   flush_events();
@@ -287,9 +305,6 @@
     {
       // get next event and handle it
       byte event = pop_event();
-#ifdef DEBUG
-      Serial.print("show_menu: popped event "); Serial.println(event2display(event));
-#endif

       switch (event)
       {
@@ -328,10 +343,6 @@
       }

       // update the menu display
-      Serial.print("Calling menu->display: menu->title=");
-      Serial.print(menu->title);
-      Serial.print(", item_index=");
-      Serial.println(item_index);
       menu->display(menu, item_index);
     }
   }
@@ -345,11 +356,11 @@

 #define QueueLength 10

-byte event_queue[QueueLength];
+VFOEvent event_queue[QueueLength];
 int queue_fore = 0;   // fore pointer into circular buffer
 int queue_aft = 0;    // aft pointer into circular buffer

-void push_event(byte event)
+void push_event(VFOEvent event)
 {
   // put new event into next empty slot
   event_queue[queue_fore] = event;
@@ -367,7 +378,7 @@
   }
 }

-byte pop_event(void)
+VFOEvent pop_event(void)
 {
   // Must protect from RE code fiddling with queue
   noInterrupts();
@@ -377,7 +388,7 @@
     return vfo_None;

   // get next event
-  byte event = event_queue[queue_aft];
+  VFOEvent event = event_queue[queue_aft];

   // mkove aft pointer up one slot, wrap if necessary
   ++queue_aft;
@@ -417,15 +428,21 @@
   // Must protect from RE code fiddling with queue
   noInterrupts();

+  Serial.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
   Serial.print("Queue: "); Serial.println(msg);
   for (int i = 0; i < QueueLength; ++i)
   {
-    Serial.print(" "); Serial.print(event_queue[i]);
-  }
-  Serial.println("");
+    VFOEvent event = event_queue[i];
+
+    Serial.print("  ");
+    Serial.print(event);
+    Serial.print(" -> ");
+    Serial.println(event2display(event));
+  }
   Serial.print("Queue length="); Serial.println(events_pending());
   Serial.print("queue_aft="); Serial.print(queue_aft);
   Serial.print(", queue_fore="); Serial.println(queue_fore);
+  Serial.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

   interrupts();
 }
@@ -536,12 +553,10 @@
       if (push_time < HoldClickTime)
       {
         push_event(vfo_Click);
-        Serial.println("pinPush_isr pushed vfo_Click to queue");
       }
       else
       {
         push_event(vfo_HoldClick);
-        Serial.println("pinPush_isr pushed vfo_HoldClick to queue");
       }
     }
   }
@@ -562,7 +577,6 @@
     else
     {
       push_event(vfo_RLeft);
-      Serial.println("pinA_isr pushed vfo_RLeft to queue");
     }
     bFlag = 0; //reset flags for the next turn
     aFlag = 0; //reset flags for the next turn
@@ -584,13 +598,11 @@
     if (re_down)
     {
       push_event(vfo_DnRRight);
-      Serial.println("pinB_isr pushed vfo_DnRRight to queue");
       re_rotation = true;
     }
     else
     {
       push_event(vfo_RRight);
-      Serial.println("pinB_isr pushed vfo_RRight to queue");
     }
     bFlag = 0; //reset flags for the next turn
     aFlag = 0; //reset flags for the next turn
@@ -623,7 +635,7 @@
 const int SaveFreqBaseSize = NumSaveSlots * SaveFreqSize;

 //also save the offset for each frequency
-const int SaveOffsetSize = sizeof(byte);
+const int SaveOffsetSize = sizeof(SelOffset);
 const int SaveOffsetBase = SaveFreqBase + SaveFreqBaseSize;
 const int SaveOffsetBaseSize = NumSaveSlots * SaveOffsetSize;

@@ -645,40 +657,22 @@
 }

 // given slot number, return freq/offset
-void get_slot(int slot_num, Frequency &freq, byte &offset)
-{
-  Serial.print("get_slot: slot_num="); Serial.println(slot_num);
-
+void get_slot(int slot_num, Frequency &freq, SelOffset &offset)
+{
   int freq_address = SaveFreqBase + slot_num * SaveFreqSize;
   int offset_address = SaveOffsetBase + slot_num * SaveOffsetSize;

-  Serial.print("SaveFreqBase="); Serial.print(SaveFreqBase);
-  Serial.print(", freq_address="); Serial.println(freq_address);
-
   EEPROM.get(freq_address, freq);
-
-  Serial.print("SaveOffsetBase="); Serial.print(SaveOffsetBase);
-  Serial.print(", offset_address="); Serial.println(offset_address);
-
   EEPROM.get(offset_address, offset);
 }

 // put frequency/offset into given slot number
-void put_slot(int slot_num, Frequency freq, byte offset)
-{
-  Serial.print("put_slot: slot_num="); Serial.println(slot_num);
-
+void put_slot(int slot_num, Frequency freq, SelOffset offset)
+{
   int freq_address = SaveFreqBase + slot_num * SaveFreqSize;
   int offset_address = SaveOffsetBase + slot_num * SaveOffsetSize;

-  Serial.print("SaveFreqBase="); Serial.print(SaveFreqBase);
-  Serial.print(", freq_address="); Serial.println(freq_address);
-
   EEPROM.put(freq_address, freq);
-
-  Serial.print("SaveOffsetBase="); Serial.print(SaveOffsetBase);
-  Serial.print(", offset_address="); Serial.println(offset_address);
-
   EEPROM.put(offset_address, offset);
 }

@@ -686,7 +680,7 @@
 void dump_eeprom()
 {
   Frequency ulong;
-  byte offset;
+  SelOffset offset;

   EEPROM.get(AddressFreq, ulong);
   EEPROM.get(AddressSelDigit, offset);
@@ -705,7 +699,7 @@
   Serial.println("=================================================");
 }

-void get_vfo_freq_offset(Frequency &freq, byte &offset)
+void get_vfo_freq_offset(Frequency &freq, SelOffset &offset)
 {
   EEPROM.get(AddressFreq, freq);
   EEPROM.get(AddressSelDigit, offset);
@@ -731,14 +725,18 @@

 void zero_slots(void)
 {
-  Frequency freq = 0L;
-  byte offset = 0;
+  Frequency zero_freq = 0L;
+  SelOffset zero_offset = 0;
+
+  // zero the frequency+selected values
+  VfoFrequency = MIN_FREQ;
+  VfoSelectDigit = 0;
+  save_to_eeprom();

   for (int i = 0; i < NumSaveSlots; ++i)
   {
-    put_slot(i, freq, offset);
-  }
-  Serial.println("End of zero_slots()");
+    put_slot(i, zero_freq, zero_offset);
+  }
 }

 void setup(void)
@@ -751,9 +749,8 @@
   lcd.noCursor();
   lcd.createChar(SPACE_CHAR, sel_digits[SPACE_INDEX]);

+  // get state back from EEPROM
   restore_from_eeprom();
-//  zero_slots();
-//  Serial.println("After zero_slots()");

   // set up the rotary encoder
   re_setup(VfoSelectDigit);
@@ -762,9 +759,11 @@
 #ifndef DEBUG
   banner();
 #endif
-
+
   // dump EEPROM values
+#ifdef DEBUG
   dump_eeprom();
+#endif

   // we sometimes see random events on powerup, flush them here
   flush_events();
@@ -803,24 +802,16 @@

 void menu_display(Menu *menu, int slot_num)
 {
-  Serial.println("menu_display() called");
-
   // figure out max length of item strings
   int max_len = 0;

-  Serial.print("menu->num_items="); Serial.println(menu->num_items);
   for (int i = 0; i < menu->num_items; ++ i)
   {
     int new_len = strlen(menu->items[i]);

     if (new_len > max_len)
         max_len = new_len;
-
-    Serial.print("i="); Serial.print(i);
-    Serial.print(", new_len="); Serial.print(new_len);
-    Serial.print(", max_len="); Serial.println(max_len);
-  }
-  Serial.print("Max item len="); Serial.println(max_len);
+  }

   // write menu title on upper row
   lcd.clear();
@@ -831,16 +822,11 @@
   lcd.setCursor(0, 1);
   lcd.setCursor(NUM_COLS - max_len, 1);
   lcd.write(menu->items[slot_num]);
-  Serial.print("Set cursor to column "); Serial.println(NUM_COLS - max_len);
-  Serial.print("item text="); Serial.println(menu->items[slot_num]);
 }

 void menu_select(Menu *menu, int slot_num)
 {
-  Serial.print("menu_select: slot_num="); Serial.println(slot_num);
   const char *action_text = menu->items[slot_num];
-
-  Serial.print("action_text="); Serial.println(action_text);

   if (strcmp(action_text, menu->items[0]) == 0)
   {
@@ -864,27 +850,20 @@
   }
 }

-// draw the Save or Restore screen
+// draw the Save, Restore or Delete screen
 void savresdel_display(Menu *menu, int slot_num)
 {
-  Serial.print("savresdel_display: menu="); Serial.println(menu->title);
-  Serial.print("savresdel_display: slot_num="); Serial.println(slot_num);
-
-  // max length of item strings is "0: xxxxxxxxHz"
+  Frequency freq;
+  SelOffset offset;
+
+  // max length of item strings is "9: xxxxxxxxHz" - 13 chars
   const int max_len = 13;
   char buf[MAX_FREQ_CHARS + 1];

-  // get saved frequency, convert to a display buffer
-  Frequency freq = 0;
-  byte offset = 0;
-
   get_slot(slot_num, freq, offset);

   ltochbuff(buf, MAX_FREQ_CHARS, freq);
   buf[MAX_FREQ_CHARS] = 0;
-  Serial.print("savresdel_display: freq="); Serial.println(freq);
-  Serial.print("savresdel_display: buf="); Serial.write(buf, MAX_FREQ_CHARS);
-  Serial.println("");

   // write menu title on first row
   lcd.clear();
@@ -921,36 +900,32 @@

 void save_select(Menu *menu, int slot_num)
 {
+  // display an 'action flash'
+  action_flash();
+
   put_slot(slot_num, VfoFrequency, VfoSelectDigit);

-  // display an 'action flash' and then do it
+  savresdel_display(menu, slot_num);
+}
+
+void restore_select(Menu *menu, int slot_num)
+{
+  // display an 'action flash'
   action_flash();
+
+  get_slot(slot_num, VfoFrequency, VfoSelectDigit);
+
   savresdel_display(menu, slot_num);
 }

-void restore_select(Menu *menu, int slot_num)
-{
-  Serial.print("restore_select: slot_num="); Serial.println(slot_num);
-
-  // display an 'action flash' and then do it
+void delete_select(Menu *menu, int slot_num)
+{
+  // display an 'action flash'
   action_flash();
-  get_slot(slot_num, VfoFrequency, VfoSelectDigit);
-
-  Serial.print("restore_select: restoring frequency "); Serial.print(VfoFrequency);
-  Serial.print(" and offset "); Serial.print(VfoSelectDigit);
-  Serial.print(" from slot "); Serial.println(slot_num);
-}
-void delete_select(Menu *menu, int slot_num)
-{
-  Serial.print("delete_select: slot_num="); Serial.println(slot_num);
-
-  // display an 'action flash' and then do it
-  action_flash();
+
   put_slot(slot_num, 0L, 0);

-  Serial.print("delete_select: deleting frequency "); Serial.print(VfoFrequency);
-  Serial.print(" and offset "); Serial.print(VfoSelectDigit);
-  Serial.print(" from slot "); Serial.println(slot_num);
+  savresdel_display(menu, slot_num);
 }

 //----------------------------------------------------------
@@ -967,10 +942,7 @@
   while (events_pending() > 0)
   {
     // get next event and handle it
-    byte event = pop_event();
-#ifdef DEBUG
-    Serial.print("loop: popped event "); Serial.println(event2display(event));
-#endif
+    VFOEvent event = pop_event();

     switch (event)
     {
@@ -988,7 +960,7 @@
         break;
       case vfo_DnRLeft:
         Serial.println("vfo_DnRLeft");
-        VfoSelectDigit += 1;
+        VfoSelectDigit += 1;
         if (VfoSelectDigit >= MAX_FREQ_CHARS)
           VfoSelectDigit = MAX_FREQ_CHARS - 1;
         break;
@@ -1004,7 +976,6 @@
       case vfo_HoldClick:
         Serial.println("Got vfo_HoldClick: calling show_menu()");
         show_menu(&main_menu);
-        Serial.println("After show_menu()");
         dump_queue("After show_menu()");
         show_main_screen();
         break;


fixed algorithm

fixed algorithm

--- Arduino/sketches/TGimbal/TGimbal.ino
+++ Arduino/sketches/TGimbal/TGimbal.ino
@@ -36,7 +36,7 @@

   pitchAngularVelocity = gyroADC[GYRO_X_AXIS];
   rollAngularVelocity = gyroADC[GYRO_Y_AXIS];
-
+
   int32_t pitchP = pitchPID[0];
   int32_t pitchI = pitchPID[1];
   int32_t pitchD = pitchPID[2];
@@ -49,11 +49,10 @@
   setAngleRollLPF = setAngleRollLPF * (1.0f - (1.0f/PS_LPF_FACTOR)) + setAngleRoll * (1.0f/PS_LPF_FACTOR);

   desiredAngularVelocityPitch = stabilizePitch * (pitchAngle - setAnglePitchLPF);
-  desiredAngularVelocityRoll = stabilizeRoll * (-rollAngle - setAngleRollLPF);
+  desiredAngularVelocityRoll = stabilizeRoll * (-1*rollAngle - setAngleRollLPF);

-  int pitchPIDOutput = ComputePID(DT_INT_MS, DT_INT_INV,pitchInt, desiredAngularVelocityPitch, &pitchErrorSum, &pitchErrorOld,pitchP,pitchI,pitchD);//500,20,5,100 pwr,~10.7V
-  int rollPIDOutput = ComputePID(DT_INT_MS, DT_INT_INV,rollInt, desiredAngularVelocityRoll, &rollErrorSum, &rollErrorOld,rollP,rollI,rollD);//500,20,5,100 pwr,~10.7V
-
+  int pitchPIDOutput = ComputePID(DT_INT_MS, DT_INT_INV,pitchAngularVelocity, desiredAngularVelocityPitch, &pitchErrorSum, &pitchErrorOld,pitchP,pitchI,pitchD);//500,20,5,100 pwr,~10.7V
+  int rollPIDOutput = ComputePID(DT_INT_MS, DT_INT_INV,rollAngularVelocity, desiredAngularVelocityRoll, &rollErrorSum, &rollErrorOld,rollP,rollI,rollD);//500,20,5,100 pwr,~10.7V
   #ifdef ENABLE_VOLTAGE_COMPENSATION
     int correctedPitchMotorPower =(int) (MAX_VOLTAGE/(float)inputMillivolts * pitchMotorPower);
     int correctedRollMotorPower = (int) (MAX_VOLTAGE/(float)inputMillivolts * rollMotorPower);


7th Commit - FSRs Engaged

7th Commit - FSRs Engaged

--- SmartPakku/SmartPakku.ino
+++ SmartPakku/SmartPakku.ino
@@ -187,7 +187,10 @@
 		Serial.println("ready to send data");
 		uint8_t temp[2];
 		temp[0] = 0;
-		temp[1] = round(temperatureC);
+		//temp[1] = round(temperatureC);
+
+		// For determing backpack state
+		temp[1] = get_state();

 		nrf->sendData(PIPE_HEART_RATE_HEART_RATE_MEASUREMENT_TX, 2, (uint8_t *)&temp);
 		lastSent = millis();


fixed #17

fixed #17

--- Modules/Sensor/LightSensor/ArduinoCodes/LightSensorATtiny/LightSensorATtiny.ino
+++ Modules/Sensor/LightSensor/ArduinoCodes/LightSensorATtiny/LightSensorATtiny.ino
@@ -49,8 +49,8 @@

   if(photoresistor_value < 150)
     photoresistor_value = 150;
-  else if(photoresistor_value > 800)
-    photoresistor_value = 800;
+  else if(photoresistor_value > 850)
+    photoresistor_value = 850;

   //We are only mapping 0-1023 from ADC to 0-255
   int output_value = map(photoresistor_value, 150, 850, 0, input_val/4);


[Arduino] Code cleanup.

[Arduino] Code cleanup.

Signed-off-by: Juri Berlanda <5bfdca9e82c53adb0603ce7083f4ba4f2da5cacf@hotmail.com>

--- Arduino/vj-flight-controller/vj-flight-controller.ino
+++ Arduino/vj-flight-controller/vj-flight-controller.ino
@@ -104,7 +104,7 @@
 // ================================================================

 void sendData() {
-    char command;
+  char command;

   if (Serial.available()) {
     command = Serial.read();
@@ -234,11 +234,11 @@
     mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
     mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
     mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);
-
-    // blink LED to indicate activity
-    blinkState = !blinkState;
-    digitalWrite(LED_PIN, blinkState);
   }
+
+  // blink LED to indicate activity
+  blinkState = !blinkState;
+  digitalWrite(LED_PIN, blinkState);

   sendData();


timing

timing

--- _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
+++ _02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino
@@ -34,7 +34,7 @@
 #endif

 #define DEBUG_PRINT 0
-//#define DHT_DEBUG_TIMING
+#define DHT_DEBUG_TIMING

 // ****************
 time_t getNtpTime();
@@ -448,7 +448,7 @@
       if (bDHTstarted) {
         if (!DHT.acquiring()) {
           acquireresult = DHT.getStatus();
-#if defined(DHT_DEBUG_TIMING)
+#if defined(DHT_DEBUG_TIMING)
           printEdgeTiming(&DHT);
 #endif
           if ( acquireresult == 0 ) {
@@ -806,10 +806,10 @@

 void printEdgeTiming(class PietteTech_DHT *_d) {
   byte n;
-#if defined(DHT_DEBUG_TIMING)
+#if defined(DHT_DEBUG_TIMING)
   volatile uint8_t *_e = &_d->_edges[0];
 #endif
-  String udppayload = "edges2,device=esp-12-N1,debug=on ";
+  String udppayload = "edges2,device=esp-12-N1,debug=on,DHTLIB_ONE_TIMING=108 ";
   for (n = 0; n < 41; n++) {
     char buf[2];
     if ( n < 40 ) {
@@ -817,18 +817,18 @@
       sprintf(buf, "%02d", n);
       udppayload += buf;
       udppayload += "=";
-#if defined(DHT_DEBUG_TIMING)
+#if defined(DHT_DEBUG_TIMING)
       udppayload += *_e++;
-#endif
+#endif
       udppayload += "i,";
     } else {
       udppayload += "e";
       sprintf(buf, "%02d", n);
       udppayload += buf;
       udppayload += "=";
-#if defined(DHT_DEBUG_TIMING)
+#if defined(DHT_DEBUG_TIMING)
       udppayload += *_e++;
-#endif
+#endif
       udppayload += "i";
     }
   }


add novas funcoes

add novas funcoes

--- TesteMotor/TesteMotor.ino
+++ TesteMotor/TesteMotor.ino
@@ -3,26 +3,25 @@
 #include <Ultrasonic.h>

 //Configuracoes do sensor frontal.
-#define FrontalTriggerPin 8
-#define FrontalEchoPin 9
+#define FrontalTriggerPin  8
+#define FrontalEchoPin     9

 //Configuracoes do sensor lateral.
-#define LateralTriggerPin 11
-#define LateralEchoPin 10
+#define LateralTriggerPin  11
+#define LateralEchoPin     10

 //Configuracoes motorA
-#define IN1 2
-#define IN2 3
-#define PWMA 12    //Pino PWM do Motor A
-#define VA 130     //Valor analogico PWM
+#define IN1                2
+#define IN2                3
+#define PWMA               12      //Pino PWM do Motor A
+#define VA                 180     //Valor analogico PWM

 //Configuracoes motorB
-#define IN3 4
-#define IN4 5
-#define PWMB 13   //Pino PWM do Motor B
-#define VB 130    //Valor analogico PWM
+#define IN3                4
+#define IN4                5
+#define PWMB               13     //Pino PWM do Motor B
+#define VB                 130    //Valor analogico PWM

-//Ultrasonic sensor(8, 9);

 //Intanciando um objeto do tipos carrinho que recebe dois motores
 //Os dois motores devem estar previamente configurados.
@@ -43,17 +42,5 @@
 }

 void loop() {
-   if(!carrinho->livreAFrente() && !carrinho->livreAEsquerda())
-     carrinho->direita();
-
-   else if(!carrinho->livreAFrente() && carrinho->livreAEsquerda())
-     carrinho->esquerda();
-
-   else if(carrinho->livreAFrente() && !carrinho->livreAEsquerda())
-     carrinho->andar();
-
-   else if(carrinho->livreAFrente() && carrinho->livreAEsquerda()) {
-     carrinho->esquerda();
-     carrinho->andar();
-   }
+    if(carrinho->olhar() == 4)
 }


COHEAT-M2 bugfix

COHEAT-M2 bugfix

--- COHEAT2015/20160504-COHEAT-M2/COHEAT-M2/COHEAT-M2.ino
+++ COHEAT2015/20160504-COHEAT-M2/COHEAT-M2/COHEAT-M2.ino
@@ -3,9 +3,9 @@
 #define CONFIG_REV9 // REV9 as CC1 relay, cut 2 of the board.

 // IF DEFINED: entire comms model switches to secure.
-#define ENABLE_OTSECUREFRAME_ENCODING_SUPPORT
-
-//#define DEBUG // Uncomment for debug output.
+//#define ENABLE_OTSECUREFRAME_ENCODING_SUPPORT
+
+#define DEBUG // Uncomment for debug output.

 #include <Arduino.h>
 #include <Wire.h>
@@ -419,7 +419,10 @@
   // Non-secure: send raw frame as-is.
   // Send at default power...  One going missing won't hurt that much.
   if(!PrimaryRadio.sendRaw(txbuf, bodylen))
-    { OTV0P2BASE::serialPrintlnAndFlush(F("!TX fail")); return(false); } // FAIL
+    { OTV0P2BASE::serialPrintlnAndFlush(F("!TX *")); return(false); } // FAIL
+  // Note successful dispatch of response.
+  pollResponseNeeded = false;
+  return(true);
 #else
   // Secure: wrap frame in encrypted layer...
   uint8_t key[16];
@@ -430,8 +433,8 @@
   const uint8_t sbodylen = secureTXState.generateSecureOStyleFrameForTX(sbuf, sizeof(sbuf), OTRadioLink::FTS_RESERVED_A, lenTXID, txbuf, bodylen, e, NULL, key);
   const bool success = (0 != sbodylen) && PrimaryRadio.sendRaw(sbuf+1, sbodylen-1);
 #if 1 && defined(DEBUG)
-  if(!success) { OTV0P2BASE::serialPrintlnAndFlush(F("!TX A")); }
-  else { OTV0P2BASE::serialPrintlnAndFlush(F("TX A")); }
+  if(!success) { OTV0P2BASE::serialPrintlnAndFlush(F("!TX *")); }
+  else { OTV0P2BASE::serialPrintlnAndFlush(F("TX *")); }
 #endif
   if(success)
     {


Examples: removing unneeded #include

Examples: removing unneeded #include

--- examples/05-FullSystems/WDRC_8BandComp_wExp_wBT/WDRC_8BandComp_wExp_wBT.ino
+++ examples/05-FullSystems/WDRC_8BandComp_wExp_wBT/WDRC_8BandComp_wExp_wBT.ino
@@ -22,10 +22,6 @@

 // Include all the of the needed libraries
-#include <Wire.h>
-#include <SPI.h>
-//include <SD.h>
-//include <SerialFlash.h>
 #include <Tympan_Library.h>

 #include "AudioEffectCompWDRC2_F32.h"


Microview add laser text

Microview add laser text

--- arduino/microview_laserscan/microview_laserscan.ino
+++ arduino/microview_laserscan/microview_laserscan.ino
@@ -20,6 +20,8 @@
   // a++;
   // a %= 100;
   uView.clear(PAGE);
+  uView.setCursor(0,8);
+  uView.print("laser");
   //widget1->setValue(a++);
   //uView.setCursor(0,50);
   //uView.print(cmd_msg.data);
@@ -46,6 +48,12 @@
   // put your setup code here, to run once:
   uView.begin();
   uView.clear(PAGE);      // clear page
+  uView.setCursor(0,8);
+  uView.print("laser");
+  uView.line(SCREEN_WIDTH/2,SCREEN_HEIGHT,SCREEN_WIDTH/2-3,SCREEN_HEIGHT-3);
+  uView.line(SCREEN_WIDTH/2,SCREEN_HEIGHT,SCREEN_WIDTH/2+3,SCREEN_HEIGHT-3);
+  uView.line(0,SCREEN_HEIGHT-3,SCREEN_WIDTH,SCREEN_HEIGHT-3);
+  uView.display();
   //widget1 = new MicroViewSlider(0,0,0,100);   // declare widget0 as a Slider at x=0, y=0, min=0, max=100
   nh.subscribe(sub);
 }


no pin for RTC in comments

no pin for RTC in comments

--- examples/Widgets/RTC/RTC.ino
+++ examples/Widgets/RTC/RTC.ino
@@ -17,7 +17,7 @@
   Please note that the accuracy of this method is up to several seconds.

   App project setup:
-    RTC widget on V5
+    RTC
     Value Display M widget on V1
     Value Display M widget on V2


Remove old altimeter

Remove old altimeter

--- payload/payload.ino
+++ payload/payload.ino
@@ -11,12 +11,10 @@
 // To shorten RCR namespace, use namespace alias "custom".
 namespace custom = rcr::level1payload;

-custom::Bmp180 bmp;
-
 // Array of pointers to Setupable-implementing objects which require
 // initialization logic to take place in setup() function.
 // For more info, see "setupable.h".
-custom::Setupable* setupables[] = { &bmp };
+//custom::Setupable* setupables[] = {  };

 // Setup MicroSD card I/O. Trap the thread if no card is found.
 void setup_sd_card(void) {


Add support for more than 512 runs

Add support for more than 512 runs

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -4,7 +4,8 @@
 int dataPin = 2;
 int latchPin = 3;
 int clockPin = 4;
-int overflowPin = 5;
+int runs9 = 5;
+int runs10 = 10;
 int servoPin = 11;

 int wicketsPins[] = {
@@ -17,7 +18,8 @@
   pinMode(dataPin, OUTPUT);
   pinMode(latchPin, OUTPUT);
   pinMode(clockPin, OUTPUT);
-  pinMode(overflowPin, OUTPUT);
+  pinMode(runs9, OUTPUT);
+  pinMode(runs10, OUTPUT);

   for (int i = 0; i < 4; i++)
   {
@@ -74,7 +76,8 @@
       shiftOut(dataPin, clockPin, MSBFIRST, runs);
       digitalWrite(latchPin, HIGH);

-      digitalWrite(overflowPin, (runs >> 8) & 1 ? HIGH : LOW);
+      digitalWrite(runs9, (runs >> 8) & 1 ? HIGH : LOW);
+      digitalWrite(runs10, (runs >> 9) & 1 ? HIGH : LOW);
     }
   }
 }


WFE works, SerialUSB doesn't send until a newline is pushed at it.

--- arduino/due/due.ino
+++ arduino/due/due.ino
@@ -35,35 +35,45 @@
 const InterruptPin<greenLight, button2.number, CHANGE> greenirq;

 #include "polledtimer.h"
-
-class Flasher: public CyclicTimer {
-  void onDone(void) override {
-    CyclicTimer::onDone();
-    lamp.toggle();
-  }
-} flashLamp;
-
-#include "tableofpointers.h"
-RegisterTimer(flashLamp);
-
-
 extern "C" int sysTickHook(){
   PolledTimerServer();//all of our millisecond stuff hangs off of here.
   return false; //allowed standard code to run
 }

+class Flasher: public CyclicTimer {
+  using CyclicTimer::CyclicTimer;
+  void onDone(void) override {
+    CyclicTimer::onDone();
+    lamp.toggle();
+  }
+} flashLamp(451);
+
+#include "tableofpointers.h"
+RegisterTimer(flashLamp);
+
+CyclicTimer noncritical(1250);
+RegisterTimer(noncritical);
+
+CyclicTimer shorttimer(250);
+RegisterTimer(shorttimer);
+
 void setup() {
   SerialUSB.begin(230400);//'native' usb port
-  SerialUSB.print("Playing hooky\n");
+  SerialUSB.println("Playing hooky\n");
   Serial.begin(115200);//an actual uart
   //Pin structs take care of themselves, unless you need special modes outside arduino's libraries.
   greenirq.attach(true);//we don't build in attach() to the constructor as in many cases the isr needs stuff that isn't initialized until setup() is run.
-  redirq.attach();
-  flashLamp.restart(789);
+  redirq.attach(true);
 }
+

 char indicator='-';
 void loop() {
-  __WFE();
-  Serial.write(indicator);
+  __WFE();//this made the beat between the two timers go away, which is a good thing.
+  if(shorttimer.hasFired()){
+    SerialUSB.print(indicator);
+  }
+  if(noncritical.hasFired()){
+    SerialUSB.println();
+  }
 }


Rename variables, make function to organize, add comments

--- arduino/src/src.ino
+++ arduino/src/src.ino
@@ -1,21 +1,19 @@
 /*
-  Analog input, analog output, serial output
-
- Reads an analog input pin, maps the result to a range from 0 to 255
- and uses the result to set the pulsewidth modulation (PWM) of an output pin.
- Also prints the results to the serial monitor.
+  Prevyu source code
+  Prevyu is a project by Charly
+  Prevyu is an object connected to the cloud.
+  Prevyu get the rain forecast (with a raspberry), and relate it to the frequency
+  of drops of water in oil.
+  https://github.com/baptistelabat/prevyu/

  The circuit:
- * potentiometer connected to analog pin 0.
-   Center pin of the potentiometer goes to the analog pin.
-   side pins of the potentiometer go to +5V and ground
+  - a water level sensor http://composants.e44.com/capteurs/capteurs-niveau-d-eau/capteur-niveau-eau-normalement-ouvert-SCR4.html is linking 0V to analog pin A0 (with a 10kohm pull up resistor to 5V)
+  - an electromechanical relay commanding a pump is connected to digital output pin 4
+  - an electromechanical relay commanding an electrovanne is connected to pin 3
  * LED connected from digital pin 9 to ground

- created 29 Dec. 2008
- modified 9 Apr 2012
- by Tom Igoe
+ Program by Baptiste LABAT, 2013

- This example code is in the public domain.

  */

@@ -25,16 +23,19 @@
 const int analogInPin = A0;
 const int pumpPin = 4;
 const int ledPin = 13;
-long dropCounter;
-float delayValue = 0.0;
-int sensorValue;
+
+long dropCounter; // A counter of the number of drops since the last pumping action
+float delayValue = 0.0; // The delay between two drops
+int sensorValue; // The value of the water level sensor (0-1023)
 String inputString = "";         // A string to hold incoming data
 boolean stringComplete = false;  // Whether the string is complete
 int outputValue = 0;
 float receivedValue = 0.0;
+
 boolean levelWasDown = true;
 boolean levelIsDown = true;
 boolean freeze = false;
+
 void setup() {
   // initialize serial communications at 9600 bps:
   Serial.begin(9600);


Adding V0.1 of recive code

Adding V0.1 of recive code

--- Arduino/sendRF/sendRF.ino
+++ Arduino/sendRF/sendRF.ino
@@ -1,24 +1,57 @@
 #include <SPI.h>
 #include <RF24.h>
+#include "printf.h"

 // ce, csn pins
-RF24 radio(9,10);
+RF24 radio(9, 10);
+
+byte ID[4];
+char rxBuff[14];
+int state = 3;
+

 void setup() {
+  Serial.begin(9600);
   // put your setup code here, to run once:
   radio.begin();
   radio.setPALevel(RF24_PA_MAX);
   radio.setChannel(0x76);
-  radio.openWritingPipe(0xF0F0F0F0E1LL);
+  radio.openWritingPipe(0xE8E8F0F0E2LL);
+  radio.openReadingPipe(1, 0xE8E8F0F0E1LL);
   radio.enableDynamicPayloads();
+  radio.setAutoAck(true);
   radio.powerUp();
+  radio.printDetails();

+  radio.startListening();
+
+}
+
+void ForceSendID()
+{
+
+  if (radio.available())
+  {
+    radio.read(rxBuff, 14);
+    for (int i = 0 ; i < 14 ; i ++)
+      Serial.print(char(rxBuff[i]));
+    Serial.println(" ");
+    if (rxBuff[0] == '*')
+    {
+      Serial.print("Send Back: ");
+      Serial.println(rxBuff[1]);
+      radio.stopListening();
+      radio.write(&rxBuff[1], 1);
+      radio.startListening();
+    }
+    else{
+      Serial.println("Verify Byte Error");
+    }
+
+  }
 }

 void loop() {
-  // put your main code here, to run repeatedly:
-  const char text[] = "Hello World!";
-  radio.write(&text, sizeof(text));
-  delay(1000);
-
+  ForceSendID();
+  delay(100);
 }


change

change

--- examples/Unit/AMeter_ADS1115/AMeter_ADS1115.ino
+++ examples/Unit/AMeter_ADS1115/AMeter_ADS1115.ino
@@ -35,6 +35,8 @@
   M5.begin(); //Init M5Stack.  初始化M5Stack
   M5.Power.begin(); //Init power  初始化电源模块

+  Wire.begin();
+
   ammeter.setMode(SINGLESHOT);                /* | PAG      | Max Input Voltage(V) | */
   ammeter.setRate(RATE_8);                    /* | PAG_6144 |        128           | */
   ammeter.setGain(PAG_512);                   /* | PAG_4096 |        64            | */
@@ -43,7 +45,7 @@
                                               /* | PAG_256  |        8             | */
   M5.Lcd.setTextFont(4);  //Set font to 4 point font.  设置字体为4号字体
   M5.Lcd.setCursor(52, 210);  //Set the cursor at (52,210).  将光标设置在(52, 210)
-  M5.Lcd.printf("2A                         SAVE");
+  M5.Lcd.printf("2A                            SAVE");
 }

 void loop(void) {
@@ -62,7 +64,7 @@

   if (M5.BtnC.wasPressed()) {
     bool success = ammeter.saveCalibration2EEPROM(now_gain, hope, adc_raw);
-    M5.Lcd.setCursor(230, 210);
+    M5.Lcd.setCursor(224, 210);
     if (success) {
       M5.Lcd.setTextColor(GREEN, BLACK);
     } else {