Use write instead of print to reduce overhead.

--- barf_esp8266.ino
+++ barf_esp8266.ino
@@ -304,14 +304,15 @@
 	}

 	// Send the response to the client
-	client.print("HTTP/1.1 ");
-	client.print(status_code);
-	client.print(" ");
-	client.print(status_reason);
-	client.print("\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>");
-	client.print(response_data);
-	client.print("</html>\n");
-
+  String response = String("HTTP/1.1 ") +
+    String(status_code) +
+    String(" ") +
+    String(status_reason) +
+    String("\r\nContent-Type: text/html\r\n\r\n") +
+    String(response_data) +
+    String("\n");
+
+	client.write(response.c_str(), response.length());
 	client.stop();

 	// Update activity timestamp


Update \\ Constrains Fixed for Proper Voltage Mapping

The Yaesu G-5500 outputs 0 to 4.5 V for elevation and azimuth feedback (comfortably!). The voltage mapping within the RotorControllerInterface.ino file was adjusted so that the Arduino responds properly to this 0 to 4.5 V voltage feedback. Before, by mistake, the Arduino responded to a 2.00 V feedback as its lower bound--not 0.00 V.

--- RotorControllerInterface.ino
+++ RotorControllerInterface.ino
@@ -4280,8 +4280,8 @@
   #endif

     #ifdef FEATURE_AZ_POSITION_POTENTIOMETER
-      analog_az = constrain(analogReadEnhanced(rotator_analog_az), 409, 921);
-      raw_azimuth = map(analog_az, 409, 921, (azimuth_starting_point * HEADING_MULTIPLIER), ((azimuth_starting_point + azimuth_rotation_capability) * HEADING_MULTIPLIER));
+      analog_az = constrain(analogReadEnhanced(rotator_analog_az), 0, 921);
+      raw_azimuth = map(analog_az, 0, 921, (azimuth_starting_point * HEADING_MULTIPLIER), ((azimuth_starting_point + azimuth_rotation_capability) * HEADING_MULTIPLIER));
       //raw_azimuth = map(analog_az* HEADING_MULTIPLIER, configuration.analog_az_full_ccw* HEADING_MULTIPLIER, configuration.analog_az_full_cw* HEADING_MULTIPLIER, (azimuth_starting_point * HEADING_MULTIPLIER), ((azimuth_starting_point + azimuth_rotation_capability) * HEADING_MULTIPLIER));

       #ifdef FEATURE_AZIMUTH_CORRECTION
@@ -5205,8 +5205,8 @@
   #endif

     #ifdef FEATURE_EL_POSITION_POTENTIOMETER
-    analog_el = constrain(analogReadEnhanced(rotator_analog_el), 409, 921);
-    elevation = (map(analog_el, 409, 921, 0, (ELEVATION_MAXIMUM_DEGREES * HEADING_MULTIPLIER)));
+    analog_el = constrain(analogReadEnhanced(rotator_analog_el), 0, 921);
+    elevation = (map(analog_el, 0, 921, 0, (ELEVATION_MAXIMUM_DEGREES * HEADING_MULTIPLIER)));
     #ifdef FEATURE_ELEVATION_CORRECTION
     elevation = (correct_elevation(elevation / (float) HEADING_MULTIPLIER) * HEADING_MULTIPLIER);
     #endif // FEATURE_ELEVATION_CORRECTION


Update loop()

Update loop()

--- ServoTestCode/ServoTestCode.ino
+++ ServoTestCode/ServoTestCode.ino
@@ -2,7 +2,6 @@
 Servo myservo;  // create servo object to control a servo

 int pos = 90;    // variable to store the servo position
-int ByteReceived;
 int Change = 0;

 void setup() {
@@ -13,11 +12,10 @@

 void loop() {
   int Read = Serial.read();
+  // When Serial.read() equals -1, then no data has been transferred
   if (Read != -1) {
-    ByteReceived = Read;
     Serial.print(Read);
+    myservo.write(Read);
   }
-  myservo.write(ByteReceived);
-  delay(1000);
-  ByteReceived = 0;
+  delay(100);
 }


Fixed parse cmd display_digit

Fixed parse cmd display_digit

--- tokens-firmware/Prototype#2/pawn/pawn.ino
+++ tokens-firmware/Prototype#2/pawn/pawn.ino
@@ -266,7 +266,7 @@
       send_uint8(sendData, 1);
       break;
     case DISPLAY_DIGIT:
-      tokenFeedback.diplayDigit(getData[0]);
+      tokenFeedback.displayDigit(getData[0]);
       send_uint8(sendData,1);
       break;
     default:


Correct example

Correct example

--- examples/01.Basics/DirectIO/DirectIO.ino
+++ examples/01.Basics/DirectIO/DirectIO.ino
@@ -1,4 +1,7 @@
 #include <ParkingShield.h>
+
+#define BUTTON_S1 A0
+#define LED_1 A4

 void setup()
 {


writeAllToEEPROM() renamed to writeAllErrorsToEEPROM()

--- skypointer.ino
+++ skypointer.ino
@@ -17,7 +17,6 @@
 #include "SkyPointer_MotorShield.h"
 #include <TimerOne.h>
 #include <EEPROM.h>
-//#include "EEPROM_Anything/EEPROM_Anything.h"

 // A modulo operator that handles negative numbers
 #define MOD(a,b) ((((a)%(b))+(b))%(b))
@@ -59,14 +58,18 @@
  ***************************************************************************/
 void writeErrorToEEPROM (int n, double Z) {
     // Writes to EEPROM the n-th error correction, where n = 1, 2 or 3
+    /*
+    The error, expressed in rads, is multiplied by 10e8 to get a long int.
+    Then it's divided in 4 bytes that are written in 4 EEPROM addresses.
+
+    */
     signed long _z = (signed long) (Z * 1e8);
-    for (unsigned int k = 0; k < 4; k++) {
-        // Write the 3 lowest bytes (not the sign)
+    for (int k = 0; k < 4; k++) {
         EEPROM.write(4*(n-1) + k, (int) ((_z >> 8*k) & 0xFF));
     }
 }

-void writeAllToEEPROM (double z1, double z2, double z3) {
+void writeAllErrorsToEEPROM (double z1, double z2, double z3) {
     writeErrorToEEPROM (1, Z1);
     writeErrorToEEPROM (2, Z2);
     writeErrorToEEPROM (3, Z3);
@@ -260,12 +263,10 @@

   // Array with the errors
   double Z[3] = {(double) Z1, (double) Z2, (double) Z3};
-  writeAllToEEPROM ((double) Z1, (double) Z2, (double) Z3);
-
-}
-
-void loop() {
-  sCmd.readSerial();  // Read commands from serial port
+  // Write the errors
+  writeAllErrorsToEEPROM ((double) Z1, (double) Z2, (double) Z3);
+
+  // Test: read the errors
   double a = readErrorFromEEPROM(1);
   double b = readErrorFromEEPROM(2);
   double c = readErrorFromEEPROM(3);
@@ -275,3 +276,7 @@
   Serial.print ("  |  "); Serial.print(c, 8);
   Serial.println("");
 }
+
+void loop() {
+  sCmd.readSerial();  // Read commands from serial port
+}


cleaned up commented out part from rfglow_serial

--- arduino/rfglow_master/rfglow_master.ino
+++ arduino/rfglow_master/rfglow_master.ino
@@ -174,36 +174,6 @@
   } else {
     previousMs = currentMs;
   }
-
-  /*
-  while (Serial.available() > 0) {
-    char aChar = Serial.read();
-    if (aChar == '\n') {
-      // Turn inData into a \0 terminated string
-      inData[index] = 0;
-
-      Serial.print("Confirmed ");
-      Serial.print(inData);
-      Serial.print(". ");
-
-      // Parse the line
-      int hue, saturation, brightness;
-      int numExtracted = sscanf(inData,"%u %u %u",&hue,&saturation,&brightness);
-      Serial.print(" # values = ");
-      Serial.println(numExtracted);
-      if (numExtracted == 3) {
-        sendCommand(hue, saturation, brightness);
-      }
-
-      // Reset index
-      index = 0;
-      Serial.println("ready, enter 3 space separated numbers like 30 30 30 for HSV:");
-    } else {
-      inData[index] = aChar;
-      index++;
-    }
-  }
-  */
 }

 void sendHueChange(unsigned int hue) {


Update Weather_mikroe_SAM3X.ino

Update Weather_mikroe_SAM3X.ino

SGP30 Dump in standard format

--- Weather_mikroe_SAM3X/Weather_mikroe_SAM3X.ino
+++ Weather_mikroe_SAM3X/Weather_mikroe_SAM3X.ino
@@ -61,7 +61,7 @@
 const int TMP116_temp_reg   = 0x00;  // Temperature register
 const int TMP116_config_reg = 0x01;  // Configuration register

-int counter=10;
+int counter=1000;

 bool has_bme = true;
 bool has_sgp = true;
@@ -79,6 +79,13 @@
     const float absoluteHumidity = 216.7f * ((humidity / 100.0f) * 6.112f * exp((17.62f * temperature) / (243.12f + temperature)) / (273.15f + temperature)); // [g/m^3]
     const uint32_t absoluteHumidityScaled = static_cast<uint32_t>(1000.0f * absoluteHumidity); // [mg/m^3]
     return absoluteHumidityScaled;
+}
+
+void bump_counter() {
+	counter++;
+	if (counter == 10000) {
+		counter = 1000;
+	}
 }

 void setup()
@@ -132,11 +139,6 @@
 		sgp_read();
 	}

-	counter++;
-	if (counter == 100) {
-		counter = 10;
-	}
-
 	delay(5000); // wait 5 seconds for the next I2C scan
 }

@@ -148,6 +150,7 @@
 }

 void bme_read() {
+	bump_counter();
 	bme.takeForcedMeasurement(); // has no effect in normal mode
 	Serial.print("MIKROESAM3X_WC:");
 	Serial.print(counter);
@@ -176,23 +179,22 @@
 }

 void sgp_read() {
+	bump_counter();
 	// If you have a temperature / humidity sensor, you can set the absolute humidity to enable the humditiy compensation for the air quality signals
 	//float bme_temperature = 22.1; // [°C]
 	//float bme_humidty = 45.2; // [%RH]
 	if (has_bme) {
 		sgp.setHumidity(getAbsoluteHumidity(bme_temperature, bme_humidty));
 	}
-
-	Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");
-	Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");
-
-	if (! sgp.IAQmeasureRaw()) {
-		Serial.println("Raw Measurement failed");
-		return;
-	}
-	Serial.print("Raw H2 "); Serial.print(sgp.rawH2); Serial.print(" \t");
-	Serial.print("Raw Ethanol "); Serial.print(sgp.rawEthanol); Serial.println("");

+	Serial.print("MIKROESAM3X_AQC:");
+	Serial.print(counter);
+	Serial.print(":TVOC:");
+	Serial.print(sgp.TVOC);
+	Serial.print(":ppb:eCO2:");
+	Serial.print(sgp.eCO2);
+	Serial.println(":ppm:#");
+
 	delay(1000);

 	counter_sgp++;
@@ -201,11 +203,14 @@

 		uint16_t TVOC_base, eCO2_base;
 		if (! sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) {
-			Serial.println("Failed to get baseline readings");
+			Serial.println("Failed to get baseline readings:#");
 			return;
 		}
-		Serial.print("****Baseline values: eCO2: 0x"); Serial.print(eCO2_base, HEX);
-		Serial.print(" & TVOC: 0x"); Serial.println(TVOC_base, HEX);
+		Serial.print("****Baseline values: eCO2: 0x");
+		Serial.print(eCO2_base, HEX);
+		Serial.print(" & TVOC: 0x");
+		Serial.print(TVOC_base, HEX);
+		Serial.println(":#");
 	}
 }


Fixed Frequency Display at startup

Fixed Frequency Display at startup

Added   Serial.println(radio.getFrequency()); to setup.  May have been
removed accidentaly

--- examples/AX25Receive/AX25Receive.ino
+++ examples/AX25Receive/AX25Receive.ino
@@ -47,6 +47,7 @@
   radio.frequency(145010);
   radio.setSQOff();
   Serial.println(F("Frequency"));
+  Serial.println(radio.getFrequency());
   delay(100);
   Serial.print(F("Squelch(H/L): "));
   Serial.print(radio.getSQHiThresh());


update time param

update time param

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/examples/turtlebot3_with_open_manipulator/turtlebot3_with_open_manipulator_core/turtlebot3_with_open_manipulator_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/examples/turtlebot3_with_open_manipulator/turtlebot3_with_open_manipulator_core/turtlebot3_with_open_manipulator_core.ino
@@ -652,8 +652,8 @@
       double goal_joint_position[joint_cnt];
       double move_time = 0.0f;

-      if (points == 0) move_time = 0.0f;
-      else if ((points + POINT_SIZE) >= all_points_cnt) move_time = 0.0f;
+      if (points == 0) move_time = joint_trajectory_point.data[points + POINT_SIZE] - joint_trajectory_point.data[points];
+      else if ((points + POINT_SIZE) >= all_points_cnt) move_time = joint_trajectory_point.data[points] / 2.0f;
       else  move_time = joint_trajectory_point.data[points] - joint_trajectory_point.data[points - POINT_SIZE];

       for (uint32_t positions = points + 1; positions < (points + POINT_SIZE); positions++)


Main loop cleaned

Main loop cleaned

--- src/TenazAyuda.ino
+++ src/TenazAyuda.ino
@@ -161,20 +161,8 @@
 int cyclesCount = 0;

 void loop() {
-  // temporal
-  //if (cyclesCount % 100 == 0) {
-    statedChanged = true;
-  //  cyclesCount = 0;
-  //} else {
-  //  cyclesCount++;
-  //}
-  // -----------
-
-  if (statedChanged) {
-    updateInputs();
-    motorsContainer.writeWithJoystick(joystick);
-    statedChanged = false;
-  }
+  updateInputs();
+  motorsContainer.writeWithJoystick(joystick);
   //updateActions();
   motorsContainer.update();
 }


improve FreqMeasureSerial

improve FreqMeasureSerial

--- FreqMeasureSerial/FreqMeasureSerial.ino
+++ FreqMeasureSerial/FreqMeasureSerial.ino
@@ -4,6 +4,8 @@
  * This example code is in the public domain.
  */
 #include <FreqMeasure.h>
+
+// pin D8

 void setup() {
   Serial.begin(9600);
@@ -14,17 +16,19 @@
 void loop() {
   Serial.print("available:");
   Serial.print(FreqMeasure.available());
-  if (FreqMeasure.available()) {
+  if (FreqMeasure.available())
+  {
     Serial.print(" ");
     int a = FreqMeasure.available();
     for (int i=0;i<a;i++)
     {
-    uint32_t n = FreqMeasure.read();
-    float frequency = FreqMeasure.countToFrequency(n);
-    //Serial.print(n);
-    //Serial.print(" ");
-    Serial.print(frequency);
-    Serial.print(" ");
+        uint32_t n = FreqMeasure.read();
+        float frequency = FreqMeasure.countToFrequency(n);
+        Serial.print(" (");
+        Serial.print(n);
+        Serial.print(") ");
+        Serial.print(frequency);
+        Serial.print(" ");
     }
   }
   Serial.println();


Updates for variable startup polling

Updates for variable startup polling

--- OxFloodNet_Sensor/OxFloodNet_Sensor.ino
+++ OxFloodNet_Sensor/OxFloodNet_Sensor.ino
@@ -1,17 +1,23 @@
 /**
- * LLAPDistance_Remote sketch for Ciseco RFu-328 and Maxbotix MB7060 XL-MaxSonar-WR1, Standard edition ultrasonic sensor
+ * OxFloodNet_SensorV32 sketch for Ciseco RFu-328 and Maxbotix MB7060 XL-MaxSonar-WR1, Standard edition ultrasonic sensor
  *
- * Transmits reading every 30s, 5, 10 or 15 minutes depending on jumpers. Default is 10 minutes
+ * Transmits reading every 1, 5, 10 or 15 minutes depending on jumpers. Default is 15 minutes
  * Data transmitted is of form aXXUnnn-----
  * Battery readings every 10th cycle  aXXBvvvv----
  *
  * Where XX is the device ID, nnn is the distance to the water in cm, vvvv is battery voltage in mV
- * Other messages sent are: aXXSTARTED upon startup
+ * Other messages sent are: aXXSTARTvvv- upon startup, vvv is version ID
  * aXXUMax----- and aXXUErr----- if max range is reached or an error in the reading is seen, i.e. too close.
+ * aXXUnnnn----, aXXDnnnn---- and aXXTnn.n----
+ * D is compensated distance, U is Raw Distance, T is temperature and B is battery reading
  *
  * Sensor is controled using a single N-Channel MOSFET, Gate to SENSOR_ENABLE,
  * Source to GND, Drain to -ve of sensor, Sensor +ve to +3V.
  *
+ * For first 10 minutes after reset/powerup, sensor wakeup is every twenty seconds (
+ * for next 10 minutes the sleep is every 1 minutes, after this sleep interval
+ * becomes value set on jumpers (5, 10 or 15 mins)
+ *
  * NOTE: For initial testing, wakeup time set to 5mins and battery interval to 4 cycles
  * (c) Andrew D Lindsay 2014
  */
@@ -20,16 +26,8 @@
 #include <OneWire.h>
 #include <DallasTemperature.h>

-#define VERSION_STRING "V3.1.2"
-
-// Number of readings before a battery reading is taken
-#define BATTERY_READ_INTERVAL 10
-
-// Polling interval values
-#define FIFTEENMINS 0
-#define TENMINS 1
-#define FIVEMINS 2
-#define TWENTYSEC 3
+// Used in START msg to indicate firmware version, 313 = 3.1.3
+#define VERSION_ID 313

 // Hardware pin defines
 // Enable SRF
@@ -40,12 +38,44 @@
 #define SENSOR_PIN 3
 // Using Sleep Mode 1, SLEEP must be HIGH to run
 // Using Sleep Mode 2, SLEEP must be LOW to run
-// Using Sleep Mode 3, SLEEP must be LOW to run
+// Using Sleep Mode 3, SLEEP must be LOW to run, uses interrupt to wakeup
 #define SRF_SLEEP 4
 #define WAKE_INT 2
-
-// Data wire is plugged into port 5 on the Arduino
+// OneWire bus pin for temperature sensor pin
 #define ONE_WIRE_BUS 5
+
+// Software configuration defines
+// Number of readings before a battery reading is taken
+#define BATTERY_READ_INTERVAL 10
+
+// Polling interval jumper link enumeration values, 1, 5, 10 or 15 minutes
+#define FIFTEENMINS 0
+#define TENMINS 1
+#define FIVEMINS 2
+#define ONEMIN 3
+#define TWENTYSEC 4
+
+// Define AT commands to set polling intervals defined above
+// Order is Fifteen Mins, Ten Mins, Five Mins, 1 Min, 20 seconds
+char *pollingIntervalCmds[] = {
+  "ATSDDBBA0",  // 15 Minutes
+  "ATSD927C0",  // 10 Minutes
+  "ATSD493E0",  // 5 Minutes
+  "ATSDEA60",   // 1 Minute
+  "ATSD4E20"    // 20s
+};
+
+// define startup polling modes
+// 10 minutes of 20s interval is 30 wakeups
+// After 10 mins this is reset to 10 and interval is 1 minute
+#define NORMAL_POLL 0
+#define MED_POLL 1
+#define FAST_POLL 2
+
+#define FAST_POLL_COUNT 30
+#define MED_POLL_COUNT 10
+
+// Hardware objects

 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
 OneWire oneWire(ONE_WIRE_BUS);
@@ -56,98 +86,49 @@
 // arrays to hold device address
 DeviceAddress temperatureSensor;

+// Define pins that are not used and are to be made inputs
+#define PIN_COUNT 5
+uint8_t inPin[] = { 9, 10, 11, 12, 13 };
+
+// Other global variables
 boolean tempSensorFound = false;
-float latestTemperature = 0.0;
-uint16_t lastUncompDistance = 0;
-
-// Define pins that are not used and are to be made inputs
-uint8_t inPin[] = { 9, 10, 11, 12, 13 };
-
 int batteryCountDown = BATTERY_READ_INTERVAL;
 int pollingInterval = FIFTEENMINS;
-
-uint8_t enterCommandMode();
+int startupSequence = FAST_POLL;
+int startupCounter = FAST_POLL_COUNT;
+
 // Node ID, default 00, set by input pins
 // Stricly speaking this should only be digits, according to the Ciseco LLAP spec.
 char nodeId[2] = { '0', '0' };

+// Forward reference
+uint8_t enterCommandMode();
+
 // Some functions to get the configured node address and polling
 void readJumpers() {
   // Set analog input pins to read digital values, set internal pullup
-  // TODO: ugly - refactor in loop.
-  pinMode(A0, INPUT);
-  pinMode(A1, INPUT);
-  pinMode(A2, INPUT);
-  pinMode(A3, INPUT);
-  pinMode(A4, INPUT);
-  pinMode(A5, INPUT);
-  pinMode(9,INPUT);
-  pinMode(10,INPUT);
-  pinMode(12,INPUT);
-  pinMode(13,INPUT);
-  digitalWrite(A0, HIGH);
-  digitalWrite(A1, HIGH);
-  digitalWrite(A2, HIGH);
-  digitalWrite(A3, HIGH);
-  digitalWrite(A4, HIGH);
-  digitalWrite(A5, HIGH);
-  digitalWrite(9, HIGH);
-  digitalWrite(10, HIGH);
-  digitalWrite(12, HIGH);
-  digitalWrite(13, HIGH);
-
+  uint8_t jumperPins[] = {
+    A0, A1, A2, A3, A4, A5, 9, 10, 12, 13 };
+  for( int n = 0; n < 10; n++ ) {
+    pinMode( jumperPins[n], INPUT );
+    digitalWrite( jumperPins[n], HIGH);
+  }
+
   // Read input and parse value
+  // TODO: These are upside down for the board layout.
   int digit2 = ((PINB & 0x30) >> 4) | ((PINC & 0x03) << 2);
   digit2 ^= 0x0f;
   int digit1 = (PINC & 0x3c) >> 2;
   digit1 ^= 0x0f;
+  // Only use digits 0 - 9,
   nodeId[0] = '0' + min(digit1,9);
   nodeId[1] = '0' + min(digit2,9);
   pollingInterval = ((PINB & 0x06) >> 1) ^ 0x03;

-  Serial.println("Debug: ");
-  Serial.print("Port B: ");
-  Serial.println(PINB,HEX);
-  Serial.print("Port C: ");
-  Serial.println(PINC,HEX);
-
-  Serial.print("Polling Interval: ");
-  Serial.println(pollingInterval,DEC);
-
-  Serial.print("Node ID Digits: ");
-  Serial.print(digit1,DEC);
-  Serial.print(" ");
-  Serial.println(digit2,DEC);
-  // A0, A1 are first part, R, S, T, W
-  // A2 - A5 are 0-9, A-F
-/*
-  int a = PINC & 0x3F;
-  a ^= 0x3F;
-  int id1 = a & 0x03;
-  switch( id1 ) {
-    case 0: nodeId[0] = 'R'; break;
-    case 1: nodeId[0] = 'S'; break;
-    case 2: nodeId[0] = 'T'; break;
-    case 3: nodeId[0] = 'W'; break;
-  }
-  int id2 = a >> 2;
-  if( id2 <10 )
-    nodeId[1] = '0' + id2;
-  else
-    nodeId[1] = 'A' + (id2-10);
-*/
-
-  // Reset analog inputs to set internal pullup off
-  digitalWrite(A0, LOW);
-  digitalWrite(A1, LOW);
-  digitalWrite(A2, LOW);
-  digitalWrite(A3, LOW);
-  digitalWrite(A4, LOW);
-  digitalWrite(A5, LOW);
-  digitalWrite(9, LOW);
-  digitalWrite(10, LOW);
-  digitalWrite(12, LOW);
-  digitalWrite(13, LOW);
+  // Reset inputs to set internal pullup off
+  for( int n = 0; n < 10; n++ ) {
+    digitalWrite( jumperPins[n], LOW);
+  }
 }

 // **************************************
@@ -200,7 +181,10 @@
 // Get the range in cm. Need to enable sensor first then wait briefly for it to power up
 // Also request temperture sensor, if previously detected, to take a reading.
 // Disable sensor after use.
-uint16_t getRange() {
+// Returns compensated, uncompensated and temperature values as reference params
+// boolean true returned form function for valid reading. false for <23cm or out of range
+// Calling function can still do checks to determine whether to use reading or not.
+boolean getRange( int *outRawDistance, int *outDistance, float *outTemperature ) {
   int16_t pulse;  // number of pulses from sensor
   int i=0;
   // These values are for calculating a mathematical median for a number of samples as
@@ -208,7 +192,7 @@
   int8_t arraysize = 9; // quantity of values to find the median (sample size). Needs to be an odd number
   //declare an array to store the samples. not necessary to zero the array values here, it just makes the code clearer
   uint16_t rangevalue[] = {
-    0, 0, 0, 0, 0, 0, 0, 0, 0 };
+    0, 0, 0, 0, 0, 0, 0, 0, 0           };

   float temperature = 0.0;
   digitalWrite(SENSOR_ENABLE, HIGH);
@@ -221,28 +205,29 @@
     if( rangevalue[i] < 645 && rangevalue[i] >= 15 ) i++;  // ensure no values out of range
     delay(10);                      // wait between samples
   }
-
+
+  // Turn off sensor as no longer needed
   digitalWrite(SENSOR_ENABLE, LOW);

   isort(rangevalue,arraysize);        // sort samples
   uint16_t distance = mode(rangevalue,arraysize);  // get median

-  lastUncompDistance = distance;
-  // Use temperature compensation if temp sensor found
+  *outRawDistance = distance;
+  // Use temperature comprensation if temp sensor found
   if( tempSensorFound ) {
-    //temperature = sensors.getTempC(temperatureSensor);
     sensors.requestTemperatures();
     temperature = sensors.getTempCByIndex(0);
-    latestTemperature = temperature;
-//  Serial.print("Uncomp Dist: ");
-//  Serial.println(distance,DEC);
-//  Serial.print("temperature: ");
-//  Serial.println(temperature);
+    *outTemperature = temperature;
     float tof = distance * 0.0058;
     uint16_t newDist = tof * (( 20.05 * sqrt( temperature + 273.15))/2);
-    distance = newDist;
-  }
-  return distance;
+    *outDistance = newDist;
+  }
+  // Add check for validity of reading
+  if( *outRawDistance <= 23 ) {    // 23cm seems to be the minimum value
+    return false;
+  }
+
+  return true;
 }

 // End of Maxbotix sensor code
@@ -252,66 +237,48 @@
 int readVcc() {
   // Read 1.1V reference against AVcc
   // set the reference to Vcc and the measurement to the internal 1.1V reference
-  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
-  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
-    ADMUX = _BV(MUX5) | _BV(MUX0);
-  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
-    ADMUX = _BV(MUX3) | _BV(MUX2);
-  #else
-    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
-  #endif
-
+#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
+#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
+  ADMUX = _BV(MUX5) | _BV(MUX0);
+#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
+  ADMUX = _BV(MUX3) | _BV(MUX2);
+#else
+  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
+#endif
+
   delay(2); // Wait for Vref to settle
   ADCSRA |= _BV(ADSC); // Start conversion
   while (bit_is_set(ADCSRA,ADSC)); // measuring
-
+
   uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
   uint8_t high = ADCH; // unlocks both
-
+
   long result = (high<<8) | low;
-
+
   result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
   return (int)result; // Vcc in millivolts
 }

 /*
-
+ Set the sleep mode on the SRF, this requires AT commands to set sleep interval
+ This is not written to permanent store as this resets back to no sleep on power cycle.
  */
-uint8_t setSRFSleep()
+
+// TODO need to be able to set sleep based on current startup sequence and polling interval
+uint8_t setSRFSleep( int inPolling )
 {
+  //  int selectedPollingInterval = TENMINS;    // Set a default
   if (!enterCommandMode())	// if failed once then try again
   {
-    if (!enterCommandMode()) return 1;
-  }
-  // Use D9 & D10 links to determine polling interval
-  // Select polling interval based on jumpers
-  switch( pollingInterval ) {
-    case TWENTYSEC:
-      if (!sendCommand("ATSD4E20")) return 2;	// 20 seconds
-      break;
- //   case ONEMIN:
- //     if (!sendCommand("ATSDEA60")) return 2;	// 1 Minute
- //     break;
-    case FIVEMINS:
-      if (!sendCommand("ATSD493E0")) return 2;	// 5 minutes
-      break;
-    case TENMINS:
-      if (!sendCommand("ATSD927C0")) return 2;	// 10 minutes
-      break;
-    default:
-      if (!sendCommand("ATSDDBBA0")) return 2;	// 15 minutes
-  }
-  //if (!sendCommand("ATSDDBBA0")) return 2;	// 15 minutes
-  //if (!sendCommand("ATSD927C0")) return 2;	// 10 minutes
-  //if (!sendCommand("ATSD493E0")) return 2;	// 5 minutes
-  //if (!sendCommand("ATSD4E20")) return 2;	// 20 seconds
-  //if (!sendCommand("ATSD1388")) return 2;	// 5 seconds
-  //if (!sendCommand("ATSD3E8")) return 2;	// 1 seconds
-
-//  if (!sendCommand("ATDR3")) return 3;	// Set data rate to 1.2kbps  (2= 38.4k)
-//  if (!sendCommand("ATAC")) return 3;	// Apply changes
-
+    if (!enterCommandMode())
+      if (!enterCommandMode())
+        return 1;
+  }
+
+  // setup the selected polling interval
+  if (!sendCommand( pollingIntervalCmds[inPolling]) ) return 2;
+  //  if (!sendCommand( pollingIntervalCmds[selectedPollingInterval]) ) return 2;
   if (!sendCommand("ATSM3")) return 3;
   if (!sendCommand("ATDN")) return 4;
   return 5; // success
@@ -335,9 +302,9 @@
   return checkOK(100);
 }

-uint8_t checkOK(int timeout)
+uint8_t checkOK(uint32_t timeout)
 {
-  static uint32_t time = millis();
+  uint32_t time = millis();
   while (millis() - time < timeout)
   {
     if (Serial.available() >= 3)
@@ -357,12 +324,13 @@
   Serial.begin(115200);
   // Get device ID
   readJumpers();
+
   // Initialise the LLAPSerial library
   LLAP.init( nodeId );
   analogReference(DEFAULT);

   // Set unused digital pins to input and turn on pull-up resistor
-  for(int i = 0; i< 5; i++ ) {
+  for(int i = 0; i< PIN_COUNT; i++ ) {
     pinMode(inPin[i], INPUT);
     digitalWrite(inPin[i], HIGH);
   }
@@ -390,62 +358,102 @@
   // Wait for it to be initialised
   delay(200);

-  // Send STARTED message if successful or ERROR if not able to set SleepMode 3.
+  // Send START message if successful or ERROR if not able to set SleepMode 3.
   // set up sleep mode 3 (low = awake)
   uint8_t val;
-  while ((val = setSRFSleep()) != 5)
-  {
+  while ((val = setSRFSleep(TWENTYSEC)) != 5) {
     LLAP.sendInt("ERR",val); // Diagnostic
     delay(5000);	// try again in 5 seconds
   }
-
-  // Repeat "STARTED" message 5 times to alert
-  for(int i=0;i<5;i++) {
-    LLAP.sendMessage("STARTED");
-    delay(1000);
-  }
-
+
+  // Send STARTED message upto 5 times if no ACK received.
+  for(int i = 0; i<5; i++) {
+    LLAP.sendInt("START", VERSION_ID);
+    // TODO: Wait 100mS for ACK, if received continue, otherwise send next STARTED
+    delay(20);
+  }
 }

 // The main loop, we basically wake up the SRF, take a reading, transmit reading then go back to sleep
 void loop() {
-
-  // Determine if we need to send a battery voltage reading yet
+  float temperature = 0.0;
+  int rawDistance = 0;
+  int distance = 0;
+
+  // Determine if we need to send a battery voltage reading or a distance reading
   if( --batteryCountDown <= 0 ) {
     int mV = readVcc();
     LLAP.sendIntWithDP("B", mV, 3 );
     batteryCountDown = BATTERY_READ_INTERVAL;
   }
-
-  // Start Ultrasonic distance reading
-  uint16_t cm = getRange();
-  // Send temperature reading
-  if( tempSensorFound ) {
-    int latestTemp = (int)(latestTemperature * 100);
-    LLAP.sendIntWithDP( "T", latestTemp, 2);
-  }
-  // Uncompensated distance
-//  LLAP.sendInt( "D", lastUncompDistance);
-
-  // Send reading n times to make sure it gets through
-  for(int n = 0; n < 1; n++ ) {
-    if( cm > 17 ) {
-      LLAP.sendInt( "D", cm );  // Send uncompensated distance
-    }
-    else if( cm == 0 ) {
-      LLAP.sendMessage( "DMax" );
+  else {
+    // Distance reading
+    boolean rangeValid = getRange( &rawDistance, &distance, &temperature);
+    // Send temperature reading
+    if( tempSensorFound ) {
+      int latestTemp = (int)(temperature * 100);
+      LLAP.sendIntWithDP( "T", latestTemp, 2);
+    }
+    // Uncompensated distance
+    LLAP.sendInt( "U", rawDistance);
+    // Send reading 3 times to make sure it gets through
+    //    for(int n = 0; n<1; n++ ) {
+
+    if( rangeValid ) {
+      //if( rawDistance > 23 ) {    // 23cm seems to be the minimum value
+      LLAP.sendInt( "D", distance );
     }
     else {
-      LLAP.sendMessage( "DErr" );
-    }
-  }
-
-  // Short delay to allow reading to be sent then sleep
+      if( rawDistance == 0 ) {
+        LLAP.sendMessage( "UMax" );
+      }
+      else {
+        LLAP.sendMessage( "UErr" );
+      }
+    }
+  }
+
+  // Determine if we are still in startup sequence, if so, do we need to
+  // adjust polling interval.
+  if( startupSequence != NORMAL_POLL ) {
+    if( --startupCounter <= 0 ) {
+      // Move to next sequence
+      startupSequence--;
+      // Reset time interval
+      int selectedPollingInterval = TENMINS;
+      // Setup for next polling sequence
+      switch( startupSequence ) {
+// removed as would never use this code
+//      case FAST_POLL:
+//        selectedPollingInterval = TWENTYSEC;
+//        break;
+      case MED_POLL:
+        selectedPollingInterval = ONEMIN;
+        startupCounter = MED_POLL_COUNT;
+        break;
+      default:
+        // Use value set by jumpers
+        selectedPollingInterval = pollingInterval;
+        break;
+      }
+      delay(50);
+      uint8_t val;
+      while ((val = setSRFSleep(selectedPollingInterval)) != 5) {
+        LLAP.sendInt("ERR",val); // Diagnostic
+        delay(5000);	// try again in 5 seconds
+      }
+    }
+  }
+  // Short delay to allow reading to be sent then put sensor to sleep
   delay(50);
   pinMode(SRF_SLEEP, INPUT);                // sleep the radio
   LLAP.sleep(WAKE_INT, RISING, false);      // sleep until woken on pin 2, no pullup (low power)
   pinMode(SRF_SLEEP, OUTPUT);               // wake the radio
-
 }
 // That's all folks

+
+
+
+
+


Stop advertising

Stop advertising

--- ESP32/ble_button/ble_button.ino
+++ ESP32/ble_button/ble_button.ino
@@ -12,6 +12,7 @@

 BLEServer* pServer = NULL;
 BLECharacteristic* pCharacteristic = NULL;
+BLEAdvertising *pAdvertising = NULL;

 bool connected = false;
 bool pendingValue = false;
@@ -57,12 +58,14 @@
 //      esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_N12);
 //      esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN, ESP_PWR_LVL_N12);
 //      esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT, ESP_PWR_LVL_N12);
+      pAdvertising->stop();
       connected = true;
     };

     void onDisconnect(BLEServer* pServer) {
       Serial.println("Disconnected");
       connected = false;
+      BLEDevice::startAdvertising();
     }
 };

@@ -89,7 +92,7 @@
   pService->start();

   // Start advertising
-  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
+  pAdvertising = BLEDevice::getAdvertising();
   pAdvertising->addServiceUUID(SERVICE_UUID);
   pAdvertising->setScanResponse(false);
   pAdvertising->setMinPreferred(0x0);  // set value to 0x00 to not advertise this parameter
@@ -120,6 +123,7 @@

   // Attach interrupt to input pin
   attachInterrupt(INPUT_PIN, onPinChanged, CHANGE);
+
 }

@@ -135,16 +139,16 @@

 void loop() {
-  while(pendingValue == true){
-    // Wait for pin to stabilize
-    delay(100);
-    if(notify()){
-      pendingValue = false;
-    }
-  }
-  if(connected == true){
-    if(millis() - lastEvent > SLEEP_TIME_MILLIS){
-      go_to_sleep();
-    }
-  }
+//  while(pendingValue == true){
+//    if(notify()){
+//      pendingValue = false;
+//    }
+//  }
+//  if(connected == true){
+//    if(millis() - lastEvent > SLEEP_TIME_MILLIS){
+//      go_to_sleep();
+//    }
+//  }
+//  delay(100);
+  return;
 }


comments + naming conventions

comments + naming conventions


Measure and display altitude from the barometer

--- Vertex.ino
+++ Vertex.ino
@@ -32,8 +32,9 @@
 struct SensorError {
   float pitch;
   float roll;
+  float elevation;
 };
-SensorError sensorError = {0, 0};
+SensorError sensorError = {0, 0, 0};
 boolean calibrating = true;

 Adafruit_10DOF                dof   = Adafruit_10DOF();
@@ -104,10 +105,12 @@
     sensors_vec_t sensorData = getOrientation();
     sensorError.pitch += (float)sensorData.pitch;
     sensorError.roll += (float)sensorData.roll;
+    sensorError.elevation += getAltitude();
     delay(20);
   }
   sensorError.pitch /= trials;
   sensorError.roll /= trials;
+  sensorError.elevation /= trials;
   calibrating = false;

   digitalWrite(armLED, HIGH);
@@ -117,12 +120,15 @@
   setThrottleAll(minThrottle);

   sensors_vec_t orientation = getOrientation();
+  float altitude = getAltitude();
   Serial.print(F("Roll: "));
   Serial.print(orientation.roll);
-  Serial.print(F("; Pitch: "));
+  Serial.print(F(";\tPitch: "));
   Serial.print(orientation.pitch);
-  Serial.print(F("; Heading: "));
-  Serial.println(orientation.heading);
+  Serial.print(F(";\tHeading: "));
+  Serial.print(orientation.heading);
+  Serial.print(F(";\tAltitude: "));
+  Serial.println(altitude);
 }

 sensors_vec_t getOrientation() {
@@ -142,6 +148,16 @@
   }
   orientation.heading = -orientation.heading;
   return orientation;
+}
+float getAltitude() {
+  sensors_event_t baroEvent;
+  bmp.getEvent(&baroEvent);
+  if (calibrating) {
+    return bmp.pressureToAltitude(SENSORS_PRESSURE_SEALEVELHPA, baroEvent.pressure);
+  }
+  else {
+    return bmp.pressureToAltitude(SENSORS_PRESSURE_SEALEVELHPA, baroEvent.pressure) - sensorError.elevation;
+  }
 }

 void setThrottleAll (int throttle) {


Refactoring bugs

Refactoring bugs

--- Weight.ino
+++ Weight.ino
@@ -81,6 +81,7 @@
   if (value > -10 && value < 10)  {
     value = 0;
   }
+  return value;
 }

 void printToSerial(const float value, const unsigned long now, String& weightName) {
@@ -122,7 +123,7 @@
 }

 void printWeightOnLCD(const float value, String weightName) {
-  char* weight = new char[6];
+  char* weight = new char[7];
   getWeight(value, weight);

   if (WEIGHT_SENSORS > 2) {


Fixed minor compiler warning

Fixed minor compiler warning

Fixed minor compiler warning

--- examples/SerialControl/SerialControl.ino
+++ examples/SerialControl/SerialControl.ino
@@ -30,7 +30,7 @@
     // and needs to be run repeatedly and often for smooth motion
     // you can do things this way, or you can put work() in a for/while loop
     // or you can call work() from a timer interrupt
-    bool moving = mot.work();
+    mot.work();

     // get commands from serial


anavi-miracle-controller-gestures.ino: OLED display

Add support for mini I2C OLED display.

Signed-off-by: Leon Anavi <be92910ae7bb6f58bb9b7c6f845bc30640119592@anavi.org>

--- anavi-miracle-controller/anavi-miracle-controller-gestures/anavi-miracle-controller-gestures.ino
+++ anavi-miracle-controller/anavi-miracle-controller-gestures/anavi-miracle-controller-gestures.ino
@@ -1,6 +1,13 @@
 #include <FS.h>
 #include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
+
+// For gesture sensor
 #include "Adafruit_APDS9960.h"
+
+// For OLED display
+#include <U8g2lib.h>
+// For I2C
+#include <Wire.h>

 // For FastLED
 #define FASTLED_ESP8266_RAW_PIN_ORDER
@@ -14,12 +21,60 @@
 #define COLOR_ORDER GRB
 #define FRAMES_PER_SECOND  120

-Adafruit_APDS9960 apds;
-
 CRGB leds1[NUM_LEDS];
 CRGB leds2[NUM_LEDS];

+U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
+
+Adafruit_APDS9960 apds;
+
+const int pinButton = 0;
+const int i2cDisplayAddress = 0x3c;
+
 int currentPosition = 1;
+
+void drawDisplay(const char *line1, const char *line2 = "", const char *line3 = "")
+{
+  // Write on OLED display
+  // Clear the internal memory
+  u8g2.clearBuffer();
+  // Set appropriate font
+  u8g2.setFont(u8g2_font_ncenR14_tr);
+  u8g2.drawStr(0,14, line1);
+  u8g2.setFont(u8g2_font_ncenR10_tr);
+  u8g2.drawStr(0,39, line2);
+  u8g2.setFont(u8g2_font_ncenR14_tr);
+  u8g2.drawStr(0,64, line3);
+  // Transfer internal memory to the display
+  u8g2.sendBuffer();
+}
+
+bool isSensorAvailable(int sensorAddress)
+{
+  // Check if I2C sensor is present
+  Wire.beginTransmission(sensorAddress);
+  return 0 == Wire.endTransmission();
+}
+
+void checkDisplay()
+{
+  Serial.print("Mini I2C OLED Display at address ");
+  Serial.print(i2cDisplayAddress, HEX);
+  if (isSensorAvailable(i2cDisplayAddress))
+  {
+      Serial.println(": OK");
+  }
+  else
+  {
+      Serial.println(": N/A");
+  }
+}
+
+void showPosition()
+{
+  String postext = "Position: " + String(currentPosition);
+  drawDisplay("ANAVI", "Miracle Controller", postext.c_str());
+}

 void updateColor(int numToFill)
 {
@@ -36,6 +91,8 @@

   FastLED.show();
   FastLED.delay(1000/FRAMES_PER_SECOND);
+
+  showPosition();
 }

 void setup()
@@ -47,6 +104,11 @@
   Serial.println("------------------------------");
   Serial.println("Control LED strip with gesture");
   Serial.println("------------------------------");
+
+  Wire.begin();
+  checkDisplay();
+  u8g2.begin();
+  delay(10);

   FastLED.addLeds<LED_TYPE, LED_PIN1, COLOR_ORDER>(leds1, NUM_LEDS).setCorrection( TypicalLEDStrip );
   FastLED.addLeds<LED_TYPE, LED_PIN2, COLOR_ORDER>(leds2, NUM_LEDS).setCorrection( TypicalLEDStrip );


updated parallel out 2 for the final time

--- proj/ledvo_lounge_button_test/ledvo_lounge_button_test.ino
+++ proj/ledvo_lounge_button_test/ledvo_lounge_button_test.ino
@@ -48,15 +48,15 @@
 // Variables for LED strands
 const uint16_t led_5ft_strand = 90; // The size of one module

-const uint16_t ih_LED_per_strand = led_5ft_strand; // 90 LED per 5' strand with 10' hexagon sides on the inside
-const uint16_t ih_LED_total = ih_LED_per_strand;
+const uint16_t ih_LED_per_strand = 2*led_5ft_strand; // 90 LED per 5' strand with 10' hexagon sides on the inside
+const uint16_t ih_LED_total = 6*ih_LED_per_strand;
 CRGB ih_leds[ih_LED_total];

-const uint16_t oh_LED_per_strand = led_5ft_strand; // 90 LED per 5' strand with 20' hexagon sides on outside
-const uint16_t oh_LED_total = oh_LED_per_strand;
+const uint16_t oh_LED_per_strand = 4*led_5ft_strand; // 90 LED per 5' strand with 20' hexagon sides on outside
+const uint16_t oh_LED_total = 6*oh_LED_per_strand;
 CRGB oh_leds[oh_LED_total];

-const uint16_t d_LED_num = led_5ft_strand; // 90 LED per 5' strand with 10' diagonals
+const uint16_t d_LED_num = 2*led_5ft_strand; // 90 LED per 5' strand with 10' diagonals
 CRGB d_leds[6][d_LED_num];

 // Variables for pin interrupts. There's a lot of these babies ;^)


Update COM_LTE.ino

Update COM_LTE.ino

--- examples/Modules/COM_LTE/COM_LTE.ino
+++ examples/Modules/COM_LTE/COM_LTE.ino
@@ -10,8 +10,8 @@
 * Date: 2021/9/2
 *******************************************************************************
   Set the DIP switch to 5 and 13 and the screen will display the signal strength
-and network access status press buttonA to dial phonenumber, ATD00000000000 is
-phone number, you can change 将 DIP 开关设置为 5 和 13
+and network access status press buttonA to dial phonenumber. ATD00000000000 is
+phone number which you can change for dial. 将 DIP 开关设置为 5 和 13
 并且屏幕会显示信号强度和网络访问状态 按按钮A拨打电话号码,ATD00000000000
 是电话号码，您可以更改
 */


Fixed screen calibration wiped after test

Signed-off-by: Irmo van den Berge <0370dce6b07866a7132582d46388cf81833cb900@home.nl>

--- examples/TestRoutine/TestRoutine.ino
+++ examples/TestRoutine/TestRoutine.ino
@@ -87,6 +87,7 @@
   // Setup eeprom to load home menu without saving on next reset
   if (isStationConnected) {
     PHN_Settings settings;
+    PHN_Settings_Load(settings);
     memcpy(settings.sketch_toload, "SKETCHES", 8);
     settings.flags = SETTINGS_LOAD;
     PHN_Settings_Save(settings);


fix commentary

fix commentary

--- examples/raw-feather/raw-feather.ino
+++ examples/raw-feather/raw-feather.ino
@@ -242,7 +242,7 @@
   // handle multiple nodes; in that case we'd have a way to do
   // production test and qualification. However, using an RWC5020A
   // is a much better use of development time.
-  const static bool fDownlink = false;
+  const static bool fDownlink = true;
   const static uint8_t kDownlinkChannel = 3;
   const static uint8_t kUplinkChannel = 8 + 3;
   uint32_t uBandwidth;


cv control via midi for the filter

cv control via midi for the filter

--- teensy_synth.ino
+++ teensy_synth.ino
@@ -200,6 +200,42 @@
 }

+#define CV_FREQUENCY 74
+#define CV_RESONANCE 71
+#define CV_AMP_ATTACK 73
+#define CV_AMP_DECAY 9
+#define CV_AMP_SUSTAIN 12
+#define CV_AMP_RELEASE 72
+
+int quad_freq_val = 0;
+int quad_res_val = 0;
+
+void midi_cv(int type, int cv, int value){
+  if(cv == CV_FREQUENCY){
+    quad_freq_val = value*10;
+
+    biquad1.setLowpass(0, quad_freq_val, quad_res_val);
+    Serial.print("setting biquad1 lowpass(0,");
+    Serial.print(quad_freq_val);
+    Serial.print(",");
+    Serial.print(quad_res_val);
+    Serial.print(")\n");
+  }
+  if(cv == CV_RESONANCE){
+
+    quad_res_val = 0.99/(float)value;
+
+    biquad1.setLowpass(0, quad_freq_val, quad_res_val);
+    Serial.print("setting biquad1 lowpass(0,");
+    Serial.print(quad_freq_val);
+    Serial.print(",");
+    Serial.print(quad_res_val);
+    Serial.print(")\n");
+  }
+
+
+}
+

 void midi_input() {
@@ -211,10 +247,6 @@
       case NoteOn:
         note = MIDI.getData1();
 	synth_note_on(note);
-	/* waveform1.frequency(notes[note]); */
-	/* envelope1.noteOn(); */
-	/* waveform1.noteOn(); */
-
         velocity = MIDI.getData2();
         channel = MIDI.getChannel();
         if (velocity > 0) {
@@ -224,8 +256,6 @@
         }
         break;
       case NoteOff:
-
-	/* envelope1.noteOff(); */
         note = MIDI.getData1();
 	synth_note_off(note);
         velocity = MIDI.getData2();
@@ -233,8 +263,10 @@
         Serial.println(String("Note Off: ch=") + channel + ", note=" + note + ", velocity=" + velocity);
         break;
     default:
+
         d1 = MIDI.getData1();
         d2 = MIDI.getData2();
+	midi_cv(type,d1,d2);
         Serial.println(String("Message, type=") + type + ", data = " + d1 + " " + d2);
     }
     t = millis();


add some Ex&explain

add some Ex&explain

--- examples/Advanced/Serial/Serial.ino
+++ examples/Advanced/Serial/Serial.ino
@@ -11,7 +11,7 @@
 *******************************************************************************
 */

-#include <M5Core2.h>
+#include <M5Stack.h>

 void setup() {
   M5.begin(); //Init M5Stack(Serial initialization is also included, the baud rate is 115200).  初始化M5Stack(串口初始化也包含在内,波特率为115200)


Revert "A few big bugs hopefully fixed. Timing on has ACK changed."

This reverts commit 40b3e10fb28c10d70f1868846cf7309c151d5431.

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -17,10 +17,9 @@

 #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
 #define SERIAL_BAUD 38400
-#define MAX_NODES 14
 #else
 #define SERIAL_BAUD 57600
-#define MAX_NODES 30
+
 // Enabling dataflash code may cause problems with non-JeeLink configurations
 #define DATAFLASH 0
 // check for presence of DataFlash memory on JeeLink
@@ -91,7 +90,7 @@
 static int value;
 static byte stack[RF12_MAXDATA+4], top, sendLen, dest;
 static byte testbuf[RF12_MAXDATA], testCounter, useHex;
-static byte nodes[MAX_NODES + 1];
+static byte nodes[31];
 static byte band;

 void displayVersion(uint8_t newline );
@@ -674,7 +673,7 @@
         showHelp();
         break;
       case 'i': // set node id
-        if ((value > 0) && (value < 32)) {
+        if ((value > 0) & (value < 32)) {
            config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F);
            saveConfig();
         } else {
@@ -698,7 +697,7 @@
 /// i.e. allowable frequencies and their use when selecting your operating frequencies.
 ///
           if (value) {
-            if ((value > 95) && (value < 3904)) {  // 96 - 3903 is the range of values supported by the RFM12B
+            if ((value > 95) & (value < 3904)) {  // 96 - 3903 is the range of values supported by the RFM12B
               frequency = value;
               Serial.print(">");
               Serial.println(frequency);
@@ -842,7 +841,7 @@
         }
         break;
       case 'n': // Clear node entries in RAM & eeprom
-        if ((stack[0] > 1) && (stack[0] < MAX_NODES+1) && (value == 123) && (nodes[stack[0]] == 0)) {
+        if ((stack[0] > 1) && (stack[0] < 31) && (value == 123) && (nodes[stack[0]] == 0)) {
           nodes[stack[0]] = 0xFF;                                           // Clear RAM entry
           for (byte i = 0; i < (RF12_EEPROM_SIZE); ++i) {
             eeprom_write_byte(RF12_EEPROM_ADDR + (stack[0]*32) + i, 0xFF);  // Clear complete eeprom entry
@@ -858,7 +857,7 @@
         // stack[0] contains the target node
         // and value contains the command to be posted
         // Assumed RF12Demo node is node 1
-        if ((stack[0] > 1) && (stack[0] < MAX_NODES+1) && (value < 255) && (nodes[stack[0]] == 0)) {   // No posting to self(1), special(31) or overwriting pending post
+        if ((stack[0] > 1) && (stack[0] < 31) && (value < 255) && (nodes[stack[0]] == 0)) {   // No posting to self(1), special(31) or overwriting pending post
           nodes[stack[0]] = value;
           nodes[0]++;            // Count post
         }
@@ -926,7 +925,7 @@
   activityLed(1);
  /// Initialise node table
   nodes[0] = nodes[1] = 0;          // Used as post counters
-  for (byte i = 1; i < MAX_NODES+1; i++) {
+  for (byte i = 1; i < 31; i++) {
     nodes[i] = eeprom_read_byte(RF12_EEPROM_ADDR + (i * 32));
     if (nodes[i] != 0xFF)
       nodes[i] = 0;   // No commands queued for node.
@@ -963,7 +962,8 @@
 /// Display stored nodes and show the command queued for each node
 /// the command queue is not preserved through a restart of RF12Demo
 void nodesShow() {
-  for (byte i = 0; i < MAX_NODES+1; i++) {
+  Serial.println("Stored Nodes");
+  for (byte i = 0; i < 31; i++) {
     if (nodes[i] != 0xFF) {
       Serial.print(i);
       Serial.print("(");
@@ -983,11 +983,11 @@
     if (rf12_crc == 0)
       Serial.print("OK");
     else {
-      if (config.flags && ~QUIET)
+      if (config.flags & ~QUIET);
         return;
       Serial.print(" ?");
-      if (n > 20) // print at most 20 bytes if crc is wrong
-        n = 20;
+      if (n > 16) // print at most 16 bytes if crc is wrong
+        n = 16;
     }
     if (useHex)
       Serial.print('X');
@@ -996,6 +996,20 @@
       showByte(rf12_grp);
     }
     Serial.print(' ');
+    if ((rf12_hdr & RF12_HDR_MASK) != 31) {
+      if (nodes[(rf12_hdr & RF12_HDR_MASK)] == 0xFF) {
+        byte len = 32;
+        Serial.print("\nNew Node ");
+        Serial.print(rf12_hdr & RF12_HDR_MASK);
+        Serial.print("\n    ");
+        nodes[(rf12_hdr & RF12_HDR_MASK)] = 0;
+        if (rf12_len < 33) len = rf12_len;
+
+        for (byte i = 0; i < len; ++i) {  // variable n
+          eeprom_write_byte(RF12_EEPROM_ADDR + ((rf12_hdr & RF12_HDR_MASK)*32) + i, rf12_data[i]);
+        }
+      }
+    }
     showByte(rf12_hdr);
     for (byte i = 0; i < n; ++i) {
       if (!useHex)
@@ -1015,35 +1029,18 @@
   }
     if (rf12_crc == 0) {
       activityLed(1);
-
-    if ((rf12_hdr & RF12_HDR_MASK) != 31) {
-      if (nodes[(rf12_hdr & RF12_HDR_MASK)] == 0xFF) {  // Extend mask to fix
-        byte len = 32;
-        Serial.print("New Node ");                      // Fix me, if THIS node and code (non node 1) receives an ACK targetted at itself a new node is created
-        Serial.println(rf12_hdr & RF12_HDR_MASK);
-        nodes[(rf12_hdr & RF12_HDR_MASK)] = 0;
-        if (rf12_len < 33)
-          len = rf12_len;
-
-        for (byte i = 0; i < len; ++i) {  // variable n
-          eeprom_write_byte(RF12_EEPROM_ADDR + ((rf12_hdr & RF12_HDR_MASK)*32) + i, rf12_data[i]);
-        }
-      }
-    }
-
 #if not defined(__AVR_ATtiny84__) || not defined(__AVR_ATtiny44__)
       if (df_present())
         df_append((const char*) rf12_data - 2, rf12_len + 2);
 #endif
       if (RF12_WANTS_ACK && (config.nodeId & COLLECT) == 0) {
-        Serial.print(" -> ack");
+        Serial.print(" -> ack ");
         testCounter = 0;
         if ((rf12_hdr & RF12_HDR_MASK) == 31) {          // Special Node 31?
           for (byte i = 1; i < 31; i++) {
             if (nodes[i] == 0xFF) {
-              testbuf[0] = i + 0xE0;  // Change Node number request matched in RF12Tune3
+              testbuf[0] = i + 0xE0;  // Change Node number request
               testCounter = 1;
-              Serial.print("Node allocation ");
               showByte(testbuf[0]);
               break;
             }
@@ -1051,13 +1048,11 @@
         }
         else {
           if (nodes[rf12_hdr & RF12_HDR_MASK] != 0) {
-            testbuf[0] = nodes[rf12_hdr & RF12_HDR_MASK];   // Pick up posted value
-            nodes[(rf12_hdr & RF12_HDR_MASK)] = 0;           // Assume it will be delivered.
+            testbuf[0] = nodes[rf12_hdr & RF12_HDR_MASK];  // Pick up posted value
+            nodes[rf12_hdr & RF12_HDR_MASK] = 0;           // Assume it will be delivered.
             testCounter = 1;
-            Serial.print("Posted ");
-            showByte(rf12_hdr & RF12_HDR_MASK);
-            Serial.print(",");
             showByte(testbuf[0]);
+            Serial.print(" Posted");
             nodes[1]++;                                    // Count
           }
         }


remove debug code

remove debug code

--- eeprom8.ino
+++ eeprom8.ino
@@ -9,7 +9,7 @@
 // Note: Flash storage is rated for 10K cycles.
 // There are 5020 half-words (16-bit entities) available per page, making for about 10M cycles.
 // Worst case scenario (and very unrealistic) is when GameCubeController's configuration changes every 15 seconds.
-// This will result in 4.25 years of operation.
+// This will result in 4.25 years of constant operation.
 // That should be good enough.

 static boolean invalid = true;


no message

no message

--- test/test.ino
+++ test/test.ino
@@ -11,14 +11,17 @@
 #define PIN_MOTOR_B_INPUT_1 30
 #define PIN_MOTOR_B_INPUT_2 32

-const int motor_max = 200;
+const int motor_speed_max = 200;
+int motor_speed_now = 0;
 String input_buffer = "";

 unsigned long moving_time = 0;
 unsigned long previous_millis_moving = 0;
+unsigned long previous_millis_accelarting = 0;
 unsigned long last_time_obstacle_check = 0;

-bool robot_is_moving = false;
+bool is_moving = false;
+bool is_acceleration = false;
 bool is_rotation = false;
 bool is_forward = false;

@@ -84,14 +87,14 @@
           case '3': //moveToByTime
             {
               moving_time = input_buffer.substring(2, last_char - 1).toInt();
-              robotMove(input_buffer[1] == '1', motor_max);
+              robotMove(input_buffer[1] == '1');
             }
             break;
           case '2': //rotateTo
           case '4': //rotateToByTime
             {
               moving_time = input_buffer.substring(2, last_char - 1).toInt();
-              robotRotate(input_buffer[1] == '1', motor_max);
+              robotRotate(input_buffer[1] == '1');
             }
             break;
           case '5': //changeLightMode
@@ -142,6 +145,12 @@
             {
               is_hand_control = false;
               robotStop();
+
+              interval_direction = 0;
+              interval_gabarit = 0;
+              analogWrite(LED_PIN_GABARIT, 0);
+              analogWrite(LED_PIN_DIRECTION, 0);
+
               sendShortAnswer(true);
             }
             break;
@@ -163,18 +172,18 @@
                 case '2':
                   {
                     switch (input_buffer[2]) {
-                      case '0': { robotMove(false, motor_max); } break; //backward
+                      case '0': { robotMove(false); } break; //backward
                       case '1': { robotStop(); } break; //stop
-                      case '2': { robotMove(true, motor_max); } break; //forward
+                      case '2': { robotMove(true); } break; //forward
                     }
                   }
                   break;
                 case '3':
                   {
                     switch (input_buffer[2]) {
-                      case '0': { robotRotate(true, motor_max); } break; //right
+                      case '0': { robotRotate(true); } break; //right
                       case '1': { robotStop(); } break; //stop
-                      case '2': { robotRotate(false, motor_max); } break; //left
+                      case '2': { robotRotate(false); } break; //left
                     }
                   }
                   break;
@@ -187,16 +196,29 @@
     }
   }

-  if (robot_is_moving) {
+  if (is_moving) {
+    if (is_acceleration) {
+      current_millis = millis();
+      if (current_millis - previous_millis_accelarting > 30) {
+        previous_millis_accelarting = current_millis;
+
+        motor_speed_now++;
+        analogWrite(PIN_MOTOR_A_ENABLE, motor_speed_now);
+        analogWrite(PIN_MOTOR_B_ENABLE, motor_speed_now);
+
+        if (motor_speed_now >= motor_speed_max) {
+          is_acceleration = false;
+        }
+      }
+    }
+
     if (!is_hand_control) {
       current_millis = millis();
       if (current_millis - previous_millis_moving > moving_time) {
         previous_millis_moving = current_millis;
         robotStop();
         sendShortAnswer(true);
-      }
-
-      if (!is_rotation) {
+      } else if (!is_rotation) {
         if (distanceIK(is_forward) < 15) {
           robotStop();
           sendShortAnswer(false);
@@ -232,7 +254,7 @@
   }
 }

-void robotMove(bool forward,  int speed){
+void robotMove(bool forward){
   if (forward) {
     motorForwardA();
     motorForwardB();
@@ -240,13 +262,14 @@
     motorBackwardA();
     motorBackwardB();
   }
-  changeDuty(speed);
-
+
+  motor_speed_now = 0;
+  is_acceleration = true;
+  is_moving = true;
+  is_rotation = false;
   is_forward = forward;
-  robot_is_moving = true;
-  is_rotation = false;
-}
-void robotRotate(bool right,  int speed){
+}
+void robotRotate(bool right){
   if (right) {
     motorBackwardA();
     motorForwardB();
@@ -254,9 +277,10 @@
     motorForwardA();
     motorBackwardB();
   }
-  changeDuty(speed);
-
-  robot_is_moving = true;
+
+  motor_speed_now = 0;
+  is_acceleration = true;
+  is_moving = true;
   is_rotation = true;
   is_forward = right;
 }
@@ -267,9 +291,11 @@
   analogWrite(PIN_MOTOR_B_ENABLE, 0);
   digitalWrite(PIN_MOTOR_B_INPUT_2, LOW);
   digitalWrite(PIN_MOTOR_B_INPUT_1, LOW);
-  robot_is_moving = false;
-
-  delay(200);
+  is_moving = false;
+  is_acceleration = false;
+  motor_speed_now = 0;
+
+  delay(500);
 }

 void motorForwardA(){
@@ -287,13 +313,6 @@
 void motorBackwardB(){
   digitalWrite(PIN_MOTOR_B_INPUT_1, HIGH);
   digitalWrite(PIN_MOTOR_B_INPUT_2, LOW);
-}
-void changeDuty(int speed){
-  for (int i = 0; i <= speed; ++i){
-    analogWrite(PIN_MOTOR_A_ENABLE, i);
-    analogWrite(PIN_MOTOR_B_ENABLE, i);
-    delay(30);
-  }
 }
 int distanceIK(boolean check_forward){
   unsigned int delay_time = millis() - last_time_obstacle_check;


COH-44

--- test/test.ino
+++ test/test.ino
@@ -372,6 +372,19 @@
   q0.validate(&Serial, n, o, c, bp, s);
   AssertIsEqual(1, c);
   AssertIsEqual(0, n); AssertIsEqual(3, o); // Contingent on impl.
+  // Pretend to be an ISR and try to load up a 3nd (min-size) message.
+  ib = q0._getRXBufForInbound();
+  AssertIsTrue(NULL != ib);
+  const uint8_t r3 = OTV0P2BASE::randRNG8();
+  ib[0] = r3;
+  q0._loadedBuf(1);
+  AssertIsTrue(!q0.isEmpty());
+  AssertIsTrue(q0.isFull());
+  q0.validate(&Serial, n, o, c, bp, s);
+  AssertIsEqual(2, c);
+  AssertIsEqual(2, n); AssertIsEqual(3, o); // Contingent on impl; 'next' index wrapped around.
+  AssertIsEqual(1, bp[0]);
+  AssertIsEqual(r3, bp[1]);
 #endif
   }

@@ -381,7 +394,7 @@
 static void testRNG8()
   {
   Serial.println("RNG8");
-  const uint8_t r = OTV0P2BASE::randRNG8(); // Capture a value before reset.
+  const uint8_t r = OTV0P2BASE::randRNG8(); // Capture a value and some noise before reset.
   // Reset to known state; API not normally exposed and only exists for unit tests.
   OTV0P2BASE::resetRNG8();
   // Extract and check a few initial values.


fix

fix

fix protocol

--- arduino/Led_Strip/Functions.ino
+++ arduino/Led_Strip/Functions.ino
@@ -28,13 +28,13 @@
           //spit the continent string into smaller strings
           String val = getValue(conti, ',', j); //, is the split identifier
           //convert string to int and put it in the matrix
-          if (nCount == 6 && cCount == 18) {
+          if (nCount == 6 && ( cCount == 18 || cCount == 24)) {
             numbers[i][j] = val.toInt();
           }
         }
       }
     }
-    if (nCount != 6 && cCount != 18) {
+    if (nCount != 6 && cCount != 18 && cCount !=24) {
         Serial.write("R");  //send R for resent
       }
   }


adjusted the orientation of right IR hence updated its offset

--- arduino_motor/mains/SideEye.ino
+++ arduino_motor/mains/SideEye.ino
@@ -99,7 +99,7 @@
 int SideEye::_output_reading_right(SharpIR* sensor, int model) {
   int OFFSET;
   if (model==SHORT) {
-    OFFSET = 5;
+    OFFSET = 7;
   }
   else {
     OFFSET = 4  ; // for LONG


updated version

updated version

--- Arduino/MEEPROMMERfirmware/MEEPROMMERfirmware.ino
+++ Arduino/MEEPROMMERfirmware/MEEPROMMERfirmware.ino
@@ -7,6 +7,10 @@
  * $Author: mario, edited by Zack $
  * $Date: 2013/05/05 11:01:54 $
  * $Revision: 1.3 $
+ *
+ * Updates for Python3 CLI client, Brendan Horan
+ * $Date 2015/01/09
+ * $Revision: 1.4 $
  *
  * This software is freeware and can be modified, reused or thrown away without any restrictions.
  *


サーボモーターの動作速度指定が速すぎるので調整。というかサーボ３が最高速度になってた。そりゃ暴れるわ。


include befor error check

include befor error check

--- BlackLED.ino
+++ BlackLED.ino
@@ -66,9 +66,6 @@
 #endif

 #ifdef _use_octoWS2811
-#ifndef octo_has_4_channel
-#warning "OctoWS2811 version 1.2.1 from https://github.com/alex-Arc/OctoWS2811.git"
-#endif
 #warning "using less than 8 outputs, octoWS2811 will stil runs 8 outputs"
 #if NUM_OF_OUTPUTS > 8
 #error "octoWS2811 only runs 8 outputs"
@@ -78,6 +75,9 @@
 #if NUM_CHANNEL_PER_LED > 4
 #error "max 4 channels per LED"
 #elif NUM_CHANNEL_PER_LED > 3
+#ifndef octo_has_4_channel
+#error "use OctoWS2811 version 1.2.1 from https://github.com/alex-Arc/OctoWS2811.git"
+#endif
 #ifndef _use_octoWS2811
 #error "only octoWS2811 has 4 channel support"
 #endif


Remove unnecessary code

Remove unnecessary code

--- arduino-controller/SDAnimation.ino
+++ arduino-controller/SDAnimation.ino
@@ -1,14 +1,11 @@
 #include "SD.h"
 #include "string.h"

-Sd2Card card;
-SdVolume volume;
-const int chipSelect = 4;
 File root;

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

 	pinMode(10, OUTPUT); // change this to 53 on a mega

@@ -25,22 +22,13 @@

 void sendAnimation(byte *data)
 {
-	Serial.write(0xf3);
-	Serial.write(data[1]);
-
-	Serial.write(0xf4);
-	Serial.write(data[2]);
-
-	Serial.write(0xf5);
-	Serial.write(data[3]);
-
-	Serial.write(0xf2);
+	Serial.write(0xf2); // batch update supported
 	for (byte i = 8; i < 72; i++)
 	{
 		Serial.write(data[i]);
 	}

-	delay(makeWord(data[6], data[7]));
+	delay(20);
 }

 void readAnimation(File & file)


clean up demo

clean up demo

--- libraries/ATT_IOT/examples/iot_demo/iot_demo.ino
+++ libraries/ATT_IOT/examples/iot_demo/iot_demo.ino
@@ -60,7 +60,7 @@

   while(!Device.Connect(&ethClient, httpServer))            // connect the device with the IOT platform.
     Serial.println("retrying");
-    Device.AddAsset(knobPin, "knob", "rotary switch",false, "{\"type\": \"integer\", \"minimum\": 0, \"maximum\": 1023}");
+  Device.AddAsset(knobPin, "knob", "rotary switch",false, "{\"type\": \"integer\", \"minimum\": 0, \"maximum\": 1023}");
   Device.AddAsset(ledPin, "led", "light emitting diode", true, "boolean");
   while(!Device.Subscribe(pubSub))                          // make certain that we can receive message from the iot platform (activate mqtt)
     Serial.println("retrying");


documentation finished - hopefully

documentation finished - hopefully

--- Arduino_codeline/fairytale23/fairytale23.ino
+++ Arduino_codeline/fairytale23/fairytale23.ino
@@ -6,16 +6,56 @@
 #endif
 /*
    Fairytale Main program
-
+   ---------------------------------------------------------------------------------------
    This programm will play albums (audiobooks or music) stored on the SD card inserted into
    the Adafruit Music Maker Shield. Selection of the album/audiobook to play is done by
    placing corresponding NFC Tags on the NFC Reader.
-
+
+   There are two pissibilities on how the connection between an NFC Tag and the corresponding
+   album on the SD card can be setup:
+   1. An NDEF Message written to the tag in the form of:  en [directory name]
+   2. Via the so called TrackDB - txt-files for each album in the directory trackdb0
+
+
+   NDEF Implementation
+   ---------------------------------------------------------------------------------------
+   This implementation is based on the Speedmaster PN532 and Don's NDEF Library. Upon
+   detection of an NFC Tag at the reader it will check if there is at least one NDEF Message
+   on the tag. This message must be of the form
+
+      en [directory name]
+
+   for example, the audiobook "Finding Nemo", stored in files in the directory
+
+      /findnemo
+
+   would have an NDEF message on the tag which reads as
+
+      en findnemo
+
+   There may also be a second NDEF message for the track to start playback with and this
+   would be in the form of
+
+      en 1
+
+   for the first track. To use this implementation you have to activate the configuration
+   option     NFCNDEF     below and you will have to write the NDEF Messages with the
+   directory name. This can bedone with the program staticNFCWriter.ino from this repository.
+
+   The downside of this implementation is it's lack for an usable update of the track to
+   start playback with - I simply could not get it to work. Secondly the implementation
+   lacks a reliable way of detecting the absence of a tag. Therefore the playback can only be
+   stopped by turning the box off. The third problem is with the used progmem. The two libraries
+   also consume way more progmem than the Adafruit PN532 library due to which I switched to:
+
+
+   TrackDB-Implementation:
+   ---------------------------------------------------------------------------------------
    Upon detection of an NFC Tag, the program will retrieve the tag's UID and use this to scan
    what I call the TrackDB to find a matching directory to play.

-   The TrackDB is a list of files in a special directory (SYSTEM00) on the SD card. The TrackDB
-   files are named after the directory of the album and of the form:
+   The TrackDB is a list of files in a special directory (TRACKDB0) on the SD card. The TrackDB
+   files are named after the directory of the album and their respective content is of the form:

       taguid:directory:track

@@ -25,7 +65,7 @@

    on the SD Card. The corresponding TrackDB file is stored at

-      /system00/findorie.txt
+      /trackdb0/findorie.txt

    It contains exactly one line:

@@ -34,23 +74,36 @@
    This line connects the Tag UID with the aformentioned directory plus the number of the track
    with which to start playback:

-      46722634231761290   is the UID of the NFC Tag
-      findorie            is the directory from which to play the files
-      1                   is the number of the track with which to start playback - here the 1st track
-
-
-   The program will take the retrieved information and then start a for-loop beginning with
-   the provided first track until all consecutive numbered tracks are played - for this it counts the
-   number of files in the given dierctory.
-
-   After playback of all files is finished, the program will resume it's main loop, delay operation
-   for roughly 15 seconds (to give the user the chance to remove the just used Tag from the reader)
-   and then wait until it detects the next tag.
-
-   While advancing through the files in the directory, the program will update the TrackDB-File with
-   the number of the currently played track. Doing so allows for interrupted playbacks - tag is
-   removed and later put back on when the playback will start with the last track in playback.
-
+      46722634231761290   the UID of the NFC Tag
+      findorie            the directory from which to play the files
+      1                   the number of the track with which to start playback - here the 1st
+
+   To use this implementation you need to activate the configuration   NFCTRACKDB
+   You will also need to create the necessary TrackDb files. This can be done with the program
+   createTrackDb.ino from this repository.
+
+
+   Playback and controls
+   ---------------------------------------------------------------------------------------
+   Regardless of the way the program retrieved the information on which directory to play
+   (NDEF message or TrackDB), it will store this in the global var plrCurrentFolder and then
+   start a for-loop beginning with the provided first track until all consecutive numbered
+   tracks are played - for this it counts the number of files in the given dierctory.
+
+   While the album (or file) is played an operations light is fading up and down in intensity.
+
+   After playback of all files is finished, the program will resume it's main loop, delay
+   operation for roughly 15 seconds (to give the user the chance to remove the just used Tag
+   from the reader) and then wait until it detects the next tag.
+
+   While advancing through the files in the directory, the program will update the TrackDB-File
+   with  the number of the currently played track. Doing so allows for interrupted playbacks -
+   tag is removed and later put back on when the playback will start with the last track in
+   playback.
+
+
+   Restrictions
+   ---------------------------------------------------------------------------------------
    For this to work, a couple of restrictions are in place:
    1. All filenames must be in the format  trackXXX.mp3, where XXX is a numbering from 001 to 127
    2. Follows from 1: You can have a maximum of 127 files per directory. I use a char to count the
@@ -60,23 +113,24 @@
    4. if a file is missing in a consecutive order, you may get a glitch in the sound
    5. As the Adafruit Music Maker Shield library does not support to jump to a specific
       position within a file, the box can always only start from the beginning of a track.
-
-   While the album (or file) is played an operations light is fading up and down in intensity.
-
-   On warnings or errors a warning or error light is lit up respectively. There are 3 different
-   warning or error conditions:
+
+
+   Warnings and errors
+   ---------------------------------------------------------------------------------------
+   On warnings or errors a warning or error light is lit up respectively. There are 3
+   different warning or error conditions:
    1) Missing information for playback warning
    2) Low Battery warning
    2) Missing hardware error

-   Errors shown via the error light (also cause the system to halt and the arduino must be turned off):
+   Errors shown via the error light (also cause the system to halt):
    - Music Maker Shield not found
    - Music Maker shield not on an interrupt enabled pin
    - SD card not found
    - NFC Reader not found

    Warnings shown via a light (Arduino can stay turned on):
-   - Low battery warning (surely the arduino will turn off but until then it will continue to operate)
+   - Low battery warning (surely the arduino will turn off but until then it will operate)
    - no directory found for the NFC Tag (aka TrackDB is missing an entry for the Tag)
    - no directory found on the SD card that match the NFC Tag TrackDB record
    - no files in the provided directory
@@ -91,7 +145,9 @@
    - no directory found on the SD card that match the NFC Tag TrackDB record
    - no file(s) in the directory on the SD card

-
+
+   Controls
+   ---------------------------------------------------------------------------------------
    4 buttons are included:
    - Previous Track       - play the previous track in a consecurtive list of ordered files
    - Next Track           - play the next track in a consecurtive list of ordered files
@@ -106,12 +162,10 @@
    - Next Track           - play the next track in a consecurtive list of ordered files
    - Pause / Resume       - pauses the playback or unpauses a paused playback
    - Light on / off       - turn the operations light fader on or off
-
-
-   Some features (as e.g. Remote Control, Buttons or operation LED etc.) can be turned off
-   or on via #define switches in the code below.
-
+
+
    Used Pins:
+   ---------------------------------------------------------------------------------------
      NAME             PIN  USAGE
    - CLK / PN532_SCK   13  SPI Clock shared with VS1053, SD card and NFC breakout board
    - MISO / PN532_MISO 12  Input data from VS1053, SD card and NFC breakout board
@@ -127,16 +181,46 @@

    - infoLedPin         5  the pin to which the operation led is connected to
    - warnLedPin         8  the pin to which the warning led is connected to
-   - errorLedPin        9  the pin to which the error led is connected to (e.g. used for LBO of powerboost 1000c)
+   - errorLedPin        9  the pin to which the error led is connected to
+                           e.g. used for LBO of powerboost 1000c

    - volPotPin         A0  the analog input pin that we use for the potentiometer
    - btnLinePin        A1  pin to which the button line (4 buttons) is connected to
-   - batLowPin         A2  the pin on which the powerboost 1000c indicates a low baterry (LBO) - ouput done via errorLedPin
-   - iRRemotePin       A3  the pin on which the powerboost 1000c indicates a low baterry (LBO) - ouput done via errorLedPin
-   - programming       A4  the pin the program button is connected to. The program button changes the functionality
-                           of the overall program in that (if pressed) the code will register a new tag for use with
-                           an album directory currently not connected to a tag (functionality yet to come)
+   - batLowPin         A2  the pin on which the powerboost 1000c indicates a low baterry
+   - iRRemotePin       A3  the pin on which the IR Remote Receiver is connected to
+   - programming       A4  the pin the program button is connected to. The program
+                           button changes the functionality of the overall program in
+                           that (if pressed) the code will register a new tag for use with
+                           an album directory currently not connected to a tag
+                           Functionality yet to come!
+
+
+   Configuration
+   ---------------------------------------------------------------------------------------
+   Some features (as e.g. Remote Control, Buttons or operation LED etc.) can be turned off
+   or on via #define switches in the code below.
+
+      #define IRREMOTE     enables the IR Remote Control option
+
+      #define BUTTONS      enables the 4 control buttons
+
+      #define VOLUMEPOT    enables the volume potentiometer
+
+      #define LOWBAT       enables the low battery warning with light and voice
+
+      #define OPRLIGHT     enables the operations light on the front of the box
+
+      #define OPRLIGHTTIME enables time based operations light - turns off the light after 30 Minutes
+
+      #define NFCNDEF      enables the use of NDEF messages to get the directory for a tag
+
+      #define NFCTRACKDB   enables the use of the TrackDB to get the directiry for a tag
+
+      #define RESUMELAST   enables the option to resume last played album upon startup.
+                           This is achieved via a file in the TrackDB and works without
+                           a tag but uses the pause/resume button instead
+
 */

 // make sure to comment this out before uploading in production as it turns on lots and lots of serial messages


Update _05-two-ds18b20.ino

Update _05-two-ds18b20.ino

--- _05-two-ds18b20/_05-two-ds18b20.ino
+++ _05-two-ds18b20/_05-two-ds18b20.ino
@@ -200,8 +200,6 @@
   Serial.println("DONE");
   Serial.println(millis() - startMills);

-  digitalWrite(dsout, LOW);
-
   // print the device information
   // printData(insideThermometer);
   // printData(outsideThermometer);
@@ -209,6 +207,9 @@
   Serial.println(millis() - startMills);
   float tempCinside  = sensors.getTempC(outsideThermometer);
   float tempCoutside = sensors.getTempC(insideThermometer);
+
+  digitalWrite(dsout, LOW);
+

   if ( isnan(tempCinside) || isnan(tempCoutside) || isnan(vdd) ) {
     Serial.println("Failed to read from sensor!");


Changed #include "DHT.h" to #include <DHT.h>

--- Merged/Merged.ino
+++ Merged/Merged.ino
@@ -1,3 +1,4 @@
+
 //  Sensor PINOUTS
 //  PINS		ARDUINO		ATMEGA
 //  GROVE		D3			5
@@ -31,6 +32,7 @@
 // GND <------> VSS

 #include <SPI.h>
+#include <Wire.h>

 //SRAM opcodes
 #define RDSR        5 // not used
@@ -106,7 +108,7 @@

 // **************** FOR TEMP & HUMIDITY SENSOR ****************

-#include "DHT.h"
+#include <DHT.h>
 #define DHTPIN A1     // Analong PIN 1 ATMEGA 24
 #define DHTTYPE DHT22   // DHT 22  (AM2302)
 DHT dht(DHTPIN, DHTTYPE);


v4.2 add additional  comments

v4.2 add additional  comments

--- PictureViewer.ino
+++ PictureViewer.ino
@@ -12,7 +12,7 @@
 int numberOfFiles = 0;
 int pastMode = HIGH;
 int pastTest = HIGH;
-boolean SD_OK = false;
+bool SD_OK = false;

 // The setup (runs once at start up)
 void setup(void) {
@@ -23,7 +23,7 @@
   Serial.begin(9600);
   tft.initR(INITR_BLACKTAB);

-  // Print program name nad version
+  // Print program name and version
   Serial.println("Picture Viewer");
   Serial.print("Version ");
   Serial.println(VERSION);
@@ -48,7 +48,9 @@
       break;
     }
     // Do not count any non-picxx.bmp files
-    if ((strncmp(entry.name(), "PIC", 3) == 0)) numberOfFiles++;
+    if ((strncmp(entry.name(), "PIC", 3) == 0)) {
+      numberOfFiles++;
+    }
     entry.close();
   }
   root.close();
@@ -67,7 +69,6 @@
   // Seed random number generator
   randomSeed(analogRead(A0));

-  // Display splash screen
   if (digitalRead(TEST_PIN) == LOW) {
     Serial.print("Mode = ");
     Serial.println((digitalRead(MODE_PIN)) ? "Random" : "Sequential");
@@ -142,7 +143,7 @@
   }
 }  // loop

-boolean bmpDraw(char *filename, uint8_t x, uint8_t y) {
+bool bmpDraw(char *filename, uint8_t x, uint8_t y) {
   File     bmpFile;
   int      bmpWidth, bmpHeight;   // W+H in pixels
   uint8_t  bmpDepth;              // Bit depth (currently must be 24)
@@ -150,8 +151,8 @@
   uint32_t rowSize;               // Not always = bmpWidth; may have padding
   uint8_t  sdbuffer[3 * BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
   uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
-  boolean  goodBmp = false;       // Set to true on valid header parse
-  boolean  flip    = true;        // BMP is stored bottom-to-top
+  bool     goodBmp = false;       // Set to true on valid header parse
+  bool     flip    = true;        // BMP is stored bottom-to-top
   int      w, h, row, col;
   uint8_t  r, g, b;
   uint32_t pos = 0;
@@ -326,7 +327,7 @@
 }

 // Displays the file name
-void displayFileName(char *fileName, boolean fileFound, int bmpWidth, int bmpHeight) {
+void displayFileName(char *fileName, bool fileFound, int bmpWidth, int bmpHeight) {
   static long lastRandomNumber;
   long randomColor;
   unsigned int textColor[] = {
@@ -361,7 +362,7 @@
   tft.setTextSize(1);
   if (!digitalRead(TEST_PIN)) {
     if (digitalRead(MODE_PIN)) { // Not test mode
-      tft.setCursor(40, 0);
+      tft.setCursor(45, 0);
       tft.println("Random");
     }
     else {


fixed multiple pin issue

fixed multiple pin issue

--- akeru-test-sketch_.ino
+++ akeru-test-sketch_.ino
@@ -1,6 +1,6 @@
 /**
 Arduino GPS Client to retrieve the Location data from the GPS shield.
-The information are processed through the TinyGPS library and logged to the console
+The information are processed through the TinyGPS library and send via the Akeru
 **/

 #include <SoftwareSerial.h>
@@ -8,23 +8,18 @@
 #include <TinyGPS.h>

 TinyGPS gps;
-SoftwareSerial ss(0,1);
+// Akeru uses RX=5, TX=4
+SoftwareSerial ssAkeru(5,4);
+SoftwareSerial ss(6,7);

 void setup()
-{
-  ss.begin(9600);
+{
   Serial.begin(9600);
   Serial.print("Finished setup");
-
-	// Wait 1 second for the modem to warm up
-  delay(1000);
-
-  // Init modem
-  Akeru.begin();
 }

 typedef struct {
-	bool theftprotection;
+  bool theftprotection;
   float lat;
   float lng;
 } Payload;
@@ -36,6 +31,9 @@
   unsigned short sentences, failed;
 	Payload p;

+  // start gps listening
+  ss.begin(9600);
+
   // parse GPS data for one second and report some key values
   for (unsigned long start = millis(); millis() - start < 1000;)
   {
@@ -48,6 +46,8 @@
         newData = true;
     }
   }
+  // end gps in order to make port listening for akeru available
+  ss.end();

     if (newData)
   {
@@ -59,32 +59,29 @@
     Serial.println(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
     Serial.print("LON = ");
     Serial.println(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
-    Serial.print("HDOP = ");
-    Serial.println(gps.hdop()/100.0);
-    Serial.print("SAT = ");
-    Serial.println(gps.satellites());
-    Serial.print("Speed = ");
-    Serial.println(gps.f_speed_kmph());
     newData = false;

-		p.theftprotection = true;
-		p.lat = flat;
-		p.lng = flon;
+    p.theftprotection = true;
+    p.lat = flat;
+    p.lng = flon;

-		if(!Akeru.isReady()) {
+    // Init modem
+    Akeru.begin();
+    // Wait 1 second for the modem to warm up
+    delay(1000);
+
+    if(!Akeru.isReady()) {
       Serial.println("Modem not ready");
       delay(1000);
     } else {
       Serial.println("Modem ready");
       delay(1000);

-			Serial.println(sizeof(p.lat));
-      Serial.println(sizeof(p.lng));
-      Serial.println(sizeof(p.theftprotection));
-      Serial.println(sizeof(p));
       Akeru.send(&p, sizeof(p));
       Serial.println("Message sent");
       delay(1000);
-   }
+    }
+    // end modem in order to make port listening for gps available
+    ssAkeru.end();
   }
 }


Update Led_fixture_sec.ino

Update Led_fixture_sec.ino

Add check and action if heatsink overheated

--- Led_fixture_sec.ino
+++ Led_fixture_sec.ino
@@ -4,6 +4,7 @@
 // 2014.06.20 v. 1.2 - partaisiju DIMMeasanu uz 1 sekundes intervalu
 // 2014.07.19 v. 2.0 - izlaboju lielu kludu DIMMesanas algoritma, pieliku DIMM rezima indikaciju
 // 2014.07.21 v. 2.1 - koda optimizacija, iznemtas liekas strukturas un mainigie
+// 2014.07.24 v. 2.11 - pieliku LED atslegsanu ja parkarst radiators

 // ~/Documents/Arduino/350W LED Fixture LDD/led_fixture

@@ -179,8 +180,10 @@
 // ventilatora izvads
 int pinFAN = 30;
 int fan_on=0; //ReadEEPROM(9);
-int fan_off=0;//ReadEEPROM(9);
-int FAN_status=0;
+int fan_off=0; //ReadEEPROM(9);
+int FAN_status=0; // 0-off, 1-on
+int fan_warning=40; // heatsink temperature warning, -50% light power
+int fan_alert=50; // heatsink temperature alert, power off all LEDs

 // koordinates screen saver rezima LED knalu statusiem,
 // kad visi uzreiz uz ekr'na
@@ -255,6 +258,7 @@

   "White",  //8
   "Royal Blue..", //9
+
   "Blue", // 10
   "Royal Blue.", //11
   "Green", //12
@@ -745,6 +749,7 @@
   second = RTC.get(DS1307_SEC,false);
   monthDay =RTC.get(DS1307_DATE,false);
   month = RTC.get(DS1307_MTH,false);
+
   year = RTC.get(DS1307_YR,false);
   lcd.setCursor(4, 1);
   lcd.print(toDouble(hour));
@@ -991,7 +996,7 @@
       lcd.write(4+i);
       BarS(DIMM_value[cha_incr+i],dimm_pos[i]+1,dimm_line[i]);
       DIMM_temp[cha_incr+i]=DIMM_value[cha_incr+i];
-      analogWrite(DIMM_pin[cha_incr+i], DIMM_value[cha_incr+i]);
+      aWrite(DIMM_pin[cha_incr+i], DIMM_value[cha_incr+i]);
     }
   }
 }
@@ -1356,7 +1361,7 @@
       if (DIMM_value[cha]!=DIMM_temp[cha]){
         BarL(DIMM_value[cha]);
         DIMM_temp[cha]=DIMM_value[cha];
-        analogWrite(DIMM_pin[cha], DIMM_value[cha]);
+        aWrite(DIMM_pin[cha], DIMM_value[cha]);
       }
       lcd.setCursor(1, 2);
       lcd.print(toTriple(DIMM_value[cha]));
@@ -1486,9 +1491,9 @@
         }
       }

-      if (manual_on==2) { analogWrite(DIMM_pin[i], DIMM_actual[i]); }
-      if (manual_on==0) { analogWrite(DIMM_pin[i], 0); }
-      if (manual_on==1) { analogWrite(DIMM_pin[i], DIMM_value[i]); }
+      if (manual_on==2) { aWrite(DIMM_pin[i], DIMM_actual[i]); }
+      if (manual_on==0) { aWrite(DIMM_pin[i], 0); }
+      if (manual_on==1) { aWrite(DIMM_pin[i], DIMM_value[i]); }

       if (menu_mode==-2) {
         lcd.setCursor(LED_pos[i], LED_line[i]);
@@ -1509,6 +1514,20 @@

   } // for

+}
+
+// *********************************************************************************************
+//            LED light analogWrite emulate
+// *********************************************************************************************
+void aWrite (pin,value){
+ if (temp[0]>=fan_warning){ // 50% of LED's power
+ value=value/2;
+ }
+
+ if (temp[0]>=fan_alert){ // turn off all LED's
+ value=0;
+ }
+ analogWrite(pin, value);
 }


Fine-tuned one of the motor ESCs for smooth rpm control

--- ROVMain/ROVMain.ino
+++ ROVMain/ROVMain.ino
@@ -61,7 +61,7 @@
 BrushlessDCMotor engine3 = BrushlessDCMotor("motorPortVer", THROTTLE_STEPS,MOTOR_MAX_PULSE_WIDTH,
 	MOTOR_MIN_PULSE_WIDTH, MOTOR_ARM_PULSE_WIDTH, 6, 7); // white
 BrushlessDCMotor engine4 = BrushlessDCMotor("motorStbdVer", THROTTLE_STEPS,
-	MOTOR_MAX_PULSE_WIDTH, 900, 1100, 9, 8); // blue
+	2050, 950, 1200, 9, 8); // blue

 /* =============================================================================
  * MISC ACTUATOR AND COMMAND DEFINITIONS.
@@ -82,6 +82,7 @@
  * SENSOR DEFINITIONS.
  * =============================================================================
  */
+// TODO depth sensor plugged in to analog A0 pin
 DepthSensor depthSensor = DepthSensor("depthReading",15); // For now a mock sensor.
 DepthSensor depthSensor2 = DepthSensor("depthReading2",16); // Another mock sensor to make sure the message concatenation works well.


Now working and bootable, with relay node

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -1,22 +1,30 @@
 /* WARNING: untested */

 #include <Homie.h>
+
+#define FW_NAME "homie-sonoff-touch"
+#define FW_VERSION "0.0.3"
+
+/* Magic sequence for Autodetectable Binary Upload */
+const char *__FLAGGED_FW_NAME = "\xbf\x84\xe4\x13\x54" FW_NAME "\x93\x44\x6b\xa7\x75";
+const char *__FLAGGED_FW_VERSION = "\x6a\x3f\x3e\x0e\xe1" FW_VERSION "\xb0\x30\x48\xd4\x1a";
+/* End of magic sequence for Autodetectable Binary Upload */

 const int PIN_RELAY = 12;
 const int PIN_LED = 13;
 const int PIN_BUTTON = 0;

-HomieNode switchNode("switch", "switch");
+HomieNode relayNode("relay", "relay");

-bool switchOnHandler(String value) {
+bool RelayHandler(String value) {
   if (value == "true") {
     digitalWrite(PIN_RELAY, HIGH);
-    Homie.setNodeProperty(switchNode, "on", "true");
-    Serial.println("Switch is on");
+    Homie.setNodeProperty(relayNode, "on", "true");
+    Serial.println("Relay is on");
   } else if (value == "false") {
     digitalWrite(PIN_RELAY, LOW);
-    Homie.setNodeProperty(switchNode, "on", "false");
-    Serial.println("Switch is off");
+    Homie.setNodeProperty(relayNode, "on", "false");
+    Serial.println("Relay is off");
   } else {
     return false;
   }
@@ -24,15 +32,24 @@
   return true;
 }

+
+void loopHandler() {
+  digitalWrite(PIN_RELAY, HIGH);
+}
+
 void setup() {
   pinMode(PIN_RELAY, OUTPUT);
   digitalWrite(PIN_RELAY, LOW);

-  Homie.setFirmware("itead-sonoff", "1.0.0");
-  Homie.setLedPin(PIN_LED, LOW);
+  Serial.println("Enabling touch switch interrupt");
+  //attachInterrupt(digitalPinToInterrupt(PIN_BUTTON), buttonChangeCallback, CHANGE);
+
+  Homie.setFirmware(FW_NAME, FW_VERSION);
+  Homie.setLedPin(PIN_LED, HIGH); // Status LED
   Homie.setResetTrigger(PIN_BUTTON, LOW, 5000);
-  switchNode.subscribe("on", switchOnHandler);
-  Homie.registerNode(switchNode);
+  Homie.setLoopFunction(loopHandler);
+  relayNode.subscribe("on", RelayHandler);
+  Homie.registerNode(relayNode);
   Homie.setup();
 }


Reversed right and left motors

Reversed right and left motors

--- rosserial/rosserial.ino
+++ rosserial/rosserial.ino
@@ -9,8 +9,8 @@

 SoftwareSerial SWSerial(NOT_A_PIN, 12);
 SabertoothSimplified ST(SWSerial); // Use SWSerial as the serial port.
-#define MOTOR_LEFT 1
-#define MOTOR_RIGHT 2
+#define MOTOR_LEFT 2
+#define MOTOR_RIGHT 1

 /*
 * Helper function to map Floats, based on Arduino map()


- reshuffled the motor bits. no change in function

--- GeheimTuer.ino
+++ GeheimTuer.ino
@@ -404,7 +404,7 @@
     } else {
       debounceIgnore--;
     }
-
+
     debounce(switchFront, &swFront, &swFrontDeglitch, &swFrontDebounce);
     debounce(switchBack, &swBack, &swBackDeglitch, &swBackDebounce);
     debounce(pirPin, &pirTrigger, &pirDeglitch, &pirDebounce);
@@ -958,8 +958,25 @@
   digitalWrite(motorInBPin, (bits & 0x01) ? (HIGH) : (LOW));
 }

+void _motorFree() {
+  setMotorBits(0x00);
+}
+
+void _motorBrake() {
+  _motorFree();
+  digitalWrite(motorPWMPin, HIGH);
+}
+
+void _motorForward() {
+  setMotorBits(0x02);
+}
+
+void _motorBackward() {
+  setMotorBits(0x01);
+}
+
 void motorDisable() {
-  // actively pull diag pins low, disables driver bridges
+  // actively pull diag pins low, disables both driver bridges
   digitalWrite(motorDiagAPin, LOW);
   pinMode(motorDiagAPin, OUTPUT);

@@ -981,36 +998,19 @@
   Serial.print(F("Brake engaged\r\n"));
 }

-void _motorBrake() {
-  setMotorBits(0x00);
-  digitalWrite(motorPWMPin, HIGH);
-}
-
 void motorFree() {
   _motorFree();
   Serial.print(F("Brake released\r\n"));
 }

-void _motorFree() {
-  setMotorBits(0x00);
-}
-
 void motorForward() {
   _motorForward();
   Serial.print(F("Forward\r\n"));
 }

-void _motorForward() {
-  setMotorBits(0x02);
-}
-
 void motorBackward() {
   _motorBackward();
   Serial.print(F("Backward\r\n"));
-}
-
-void _motorBackward() {
-  setMotorBits(0x01);
 }


change to official TSRP multicast IP

change to official TSRP multicast IP

--- OneWireTSRP.ino
+++ OneWireTSRP.ino
@@ -32,7 +32,7 @@
 PROGMEM prog_char *loopPacket6 = "}}]}}}";

 EthernetUDP udp;
-IPAddress ip(224,192,32,20);
+IPAddress ip(224,0,9,1);
 unsigned int port = 22601;

 void setup() {


Made the template blink.

Made the template blink.

--- Template/Template.ino
+++ Template/Template.ino
@@ -8,12 +8,18 @@
  *
  */

+// Pin 13 is the LED on your Arduino. This gives it a name.
+int led = 13;
+
 void setup() {
-
+  pinMode(led, OUTPUT);
 }

 void loop() {
-
+  digitalWrite(led, HIGH);
+  delay(500);
+  digitalWrite(led, LOW);
+  delay(500);
 }


update example

update example

--- examples/EncodeNdef/EncodeNdef.ino
+++ examples/EncodeNdef/EncodeNdef.ino
@@ -4,8 +4,9 @@
   Serial.begin(115200);
   Serial.println("\n");

+  // create a record the long way
   NdefRecord* r = new NdefRecord();
-  r->setTnf(0x2);  // TNF Mime Media
+  r->setTnf(TNF_MIME_MEDIA);

   String type = String("foo");
   String payload = String("17");
@@ -17,19 +18,30 @@
   byte payloadBytes[payload.length() + 1];
   payload.getBytes(payloadBytes, sizeof(payloadBytes));
   r->setPayload(payloadBytes, payload.length());
-
+
+  // create a message and add record
   NdefMessage* message = new NdefMessage();
   message->add(*r);
+
+  // a more records using the helper methods
   message->addMimeMediaRecord("foo", "17");
   message->addMimeMediaRecord("foo", payloadBytes, payload.length());
+  message->addTextRecord("foo");
+  message->addTextRecord("foo", "en");
+  message->addEmptyRecord();
+  message->addUriRecord("http://example.com");
+
+  // verify the contents
   message->print();

+  // create an array to hold the encoded message
   uint8_t encoded[message->getEncodedSize()];
+
   message->encode(encoded);
   // TODO need NdefUtil::PrintHex(encoded)

   Serial.println("\nExpecting");
-  Serial.println("0xd2 0x03 0x02 0x66 0x6f 0x6f 0x31 0x37");
+  Serial.println("0xd2 0x03 0x02 0x66 0x6f 0x6f 0x31 0x37...");

 }


Fix semicolon after define statement in LightOnOff example (#643)

Signed-off-by: Aitor Iturrioz <00eacf54ff31c4333948014852c3b67730502ebd@gmail.com>

--- examples/LightOnOff/LightOnOff.ino
+++ examples/LightOnOff/LightOnOff.ino
@@ -1,6 +1,6 @@
 #include <Homie.h>

-#define firmwareVersion "1.0.0";
+#define firmwareVersion "1.0.0"
 const int PIN_RELAY = 5;

 HomieNode lightNode("light", "Light", "switch");


Log time elapsed since last change in status

--- RouterReset.ino
+++ RouterReset.ino
@@ -43,6 +43,8 @@
 byte packetBuffer[NTP_PACKET_SIZE];
 WiFiUDP Udp;
 char time_as_string[] = "12/20/1969 00:00:00";
+unsigned long time_lastchange = 0;
+unsigned long time_now;

 // LED pins
 const int redLed = 3;
@@ -124,14 +126,19 @@

   // log change in connection status
   if(canConnect != canConnect_prev) {
-    time_to_string(now(), time_as_string);
+    time_now = now();
+    time_to_string(time_now, time_as_string);
     logfile.print(time_as_string);
     logfile.print(" - ");
-    if(canConnect)
-      logfile.println("connected.");
-    else
-      logfile.println("NOT CONNECTED!");
+    if(!canConnect) logfile.println("not");
+    logfile.println("connected");
     logfile.flush();
+
+    if(!time_lastchange) {
+      logfile.print("Seconds elapsed since last status change: ");
+      logfile.println(time_now - time_lastchange);
+    }
+    time_lastchange = time_now;

     canConnect_prev = canConnect;
   }
@@ -205,10 +212,8 @@
 }

 void resetRouter(void) {
-  flash_3leds(redLed, greenLed, yellowLed, 5, 100);
   digitalWrite(routerPin, LOW);
   delay(resetRouterTime);
   digitalWrite(routerPin, HIGH);
   delay(resetRouterTime);
-  flash_3leds(redLed, greenLed, yellowLed, 5, 100);
 }


Poll switches on the TX

Poll switches on the TX

--- transmitter/TX/TX.ino
+++ transmitter/TX/TX.ino
@@ -23,13 +23,17 @@

 #define PIN_CE  7
 #define PIN_CSN 8
-#define PIN_MONITOR_SS 4

 #define PIN_THROTTLE A0
 #define PIN_YAW      A1
 #define PIN_PITCH    A2
 #define PIN_ROLL     A3

+#define PIN_SWITCH_A 2 // (PD2 - PCINT18)
+#define PIN_SWITCH_B 3 // (PD3 - PCINT19)
+#define PIN_SWITCH_C 4 // (PD4 - PCINT20)
+#define PIN_SWITCH_D 5 // (PD5 - PCINT21)
+#define PIN_SWITCH_E 6 // (PD6 - PCINT22)

 RF24 radio(PIN_CE, PIN_CSN);

@@ -60,7 +64,7 @@
 int ppsLost = 0;
 int ppsLostCounter = 0;

-
+uint8_t switches = 0; // bit flag

 void resetPayload()
 {
@@ -73,6 +77,13 @@

 void setup()
 {
+  // Push button switches
+  pinMode(PIN_SWITCH_A, INPUT_PULLUP);
+  pinMode(PIN_SWITCH_B, INPUT_PULLUP);
+  pinMode(PIN_SWITCH_C, INPUT_PULLUP);
+  pinMode(PIN_SWITCH_D, INPUT_PULLUP);
+  pinMode(PIN_SWITCH_E, INPUT_PULLUP);
+
   Serial.begin(115200);

   if (DEBUG) {
@@ -137,7 +148,10 @@

 void loop(void)
 {
-
+  // http://www.labbookpages.co.uk/electronics/debounce.html
+  static uint8_t debounce_switches[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+  static unsigned long debounce_sample_last = 0;
+

   tx_payload.throttle = joystickMapValues(analogRead(PIN_THROTTLE), 125, 515, 1000);
   tx_payload.yaw      = joystickMapValues(analogRead(PIN_YAW), 10, 521, 1000);
@@ -189,6 +203,29 @@
   }

   unsigned long now = millis();
+
+  // Poll the switches
+  if (now - debounce_sample_last > 5) {
+    // Debounce, then set the mode.
+    debounce_sample_last = now;
+    // Read all the switch pins at once.
+    uint8_t port_d = PIND;
+
+    // Shift the variable towards the most significant bit
+    // and set the least significant bit to the current switch value
+    for (uint8_t i = 0; i < 5; i++) {
+      uint8_t pin = i + 2; // PD2 -> PD7
+      debounce_switches[i] <<= 1;
+      bitWrite(debounce_switches[i], 0, bitRead(port_d, pin));
+      if (debounce_switches[i] == 0) {
+        bitWrite(switches, i, 1);
+      } else {
+        bitWrite(switches, i, 0);
+      }
+    }
+
+  }
+
   if ( now - ppsLast > 250 ) {
     pps = ppsCounter;
     ppsLost = ppsLostCounter;


Document the RadiationClick example

Document the RadiationClick example

--- examples/RadiationClick/RadiationClick.ino
+++ examples/RadiationClick/RadiationClick.ino
@@ -1,4 +1,10 @@
 #include "RadiationWatch.h"
+/*
+This example works as the SimpleSerialPrinter, except it also generates
+a tick noise for each radiation hitting the Pocket Geiger.
+
+You need a piezo buzzer or similar connected to pin 8.
+*/

 const int PIN_TONE = 8;
 RadiationWatch radiationWatch(2, 3, 0, 1);
@@ -7,7 +13,10 @@
 {
   // Output classic geiger counter tick noise.
   tone(PIN_TONE, 800, 1);
-  Serial.println(radiationWatch.csvStatus());
+  Serial.println("A wild gamma ray appeared");
+  Serial.print(radiationWatch.uSvh());
+  Serial.print(" uSv/h +/- ");
+  Serial.println(radiationWatch.uSvhError());
 }

 void onNoise()
@@ -22,8 +31,6 @@
   // Register the callbacks.
   radiationWatch.registerRadiationCallback(&onRadiation);
   radiationWatch.registerNoiseCallback(&onNoise);
-  Serial.println(radiationWatch.csvKeys());
-  Serial.println(radiationWatch.csvStatus());
 }

 void loop()


Tweaking!

Tweaking!

--- examples/fastled_candle/fastled_candle.ino
+++ examples/fastled_candle/fastled_candle.ino
@@ -6,7 +6,7 @@
 #include <Candle.h>

 // How many leds in your strip?
-#define NUM_LEDS 40
+#define NUM_LEDS 41

 // For led chips like Neopixels, which have a data line, ground, and power, you just
 // need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
@@ -42,15 +42,15 @@
     // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
     // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

-    for (size_t i; i<NUM_LEDS; i++) {
+    for (size_t i=0; i<NUM_LEDS; i++) {
         // Reset LED values
         leds[i] = CRGB::Black;

         // Initialize candles
-        candles[i] = new Candle(random8(34, 96), random8(2, 6), random8(8, 20));
+        candles[i] = new Candle(random8(16, 96), random8(3, 8), random8(6, 22));

         // Initialize random hues
-        hues[i] = random8(32, 48);
+        hues[i] = random8(24, 32);
     }

     FastLED.show();
@@ -62,13 +62,11 @@

 void loop() {
     candleLoop();
-
-    delay(1);
 }

 void candleLoop() {
     if (candle_timer.check() == 1) {
-        for (size_t i; i<NUM_LEDS; i++) {
+        for (size_t i=0; i<NUM_LEDS; i++) {
             leds[i] = CHSV(hues[i], 255, candles[i]->get_next_brightness());
         }


Update Example_1.ino

Update Example_1.ino

--- firmware/examples/Example_1.ino
+++ firmware/examples/Example_1.ino
@@ -1,5 +1,4 @@
-#include "i2c_comm.h"
-#include "ncd_gateway.h"
+#include "ncd_gateway/ncd_gateway.h"

 String ncd_firmware = "gateway:v1.0";


Update Noika5110.ino

Update Noika5110.ino

--- firmware/examples/Noika5110.ino
+++ firmware/examples/Noika5110.ino
@@ -19,7 +19,7 @@
 *********************************************************************/

 #include "Adafruit_mfGFX/Adafruit_mfGFX.h"
-#include "Adafruit_PCD8544.h"
+#include "Adafruit_PCD8544_mfGFX.h"

 // (FAST) SOFTWARE SPI
 // pin A3 - Serial clock out (SCLK) - User defined


Update spark-web.ino

Update spark-web.ino

--- firmware/examples/spark-web.ino
+++ firmware/examples/spark-web.ino
@@ -1,9 +1,9 @@
 // This #include statement was automatically added by the Spark IDE.
-#include "SparkTime.h"
-#include "HttpRequest.h"
-#include "HttpResponse.h"
-#include "http_parser.h"
-#include "spark-web-embd-rest-json.h"
+#include "spark-web-embd-rest-json/SparkTime.h"
+#include "spark-web-embd-rest-json/HttpRequest.h"
+#include "spark-web-embd-rest-json/HttpResponse.h"
+#include "spark-web-embd-rest-json/http_parser.h"
+#include "spark-web-embd-rest-json/spark-web-embd-rest-json.h"
 #include <map>
 #include <list>


Input parsing todo list added

Input parsing todo list added

--- ppt/ppt.ino
+++ ppt/ppt.ino
@@ -515,6 +515,18 @@
     state_switch(const_power, current_target);
     //state_switch(const_volt, current_target);
   }*/
+
+  //TODO:
+  // Get data from serial
+  // Parse data
+  // if is "{P=0400}"
+  // state_switch(const_power, 400);
+  // if is "{V=0400}"
+  // state_switch(const_volt, 400);
+  // if is "{MPPT=1}"
+  // state_switch(mppt_on);
+  // if is "{OFF=1}"
+  // state_switch(off);

   // diagnosistic prints
   static int print_counter = 0;


Disable debug by default

Disable debug by default

We've seen problems where the size of the sketch, with debug enabled,
causes problems with older Arduinos/Bootloaders.  The motivation for
disabling by default is that more people will be able to get up and
running with the sketch "out of the box".

--- printer.ino
+++ printer.ino
@@ -35,7 +35,7 @@
 const byte buttonPin = 3;      // the print button
 const byte SD_Pin = 4;         // the SD Card SPI pin

-#define DEBUG // When debug is enabled, log a bunch of stuff to the hardware Serial
+// #define DEBUG // When debug is enabled, log a bunch of stuff to the hardware Serial

 // -- Everything below here can be left alone


refine blinking speed

refine blinking speed

--- client/client.ino
+++ client/client.ino
@@ -39,7 +39,9 @@
 char deviceId[3] = "00";
 char XBeeInString[50];

-unsigned int ledStateInterval = 600;
+unsigned int ledStateInterval = 500;
+unsigned int blinkFast = 500;
+unsigned int blinkSlow = 1500;
 unsigned long randomDelay = 0;
 unsigned long start_time;
 unsigned long end_time;
@@ -97,7 +99,7 @@

     //client starts blinking
     statePending = true;
-    ledStateInterval = 500;
+    ledStateInterval = 800;

   }
   else if (XBee.available()) {
@@ -133,13 +135,14 @@
         statePending = false;

       } else if(strcmp(p.data, "080") == 0) {
-        //the one is hovered => turn on
-        //the rest => blink slow
+        //the one is hovered => blink fast
+        //the rest => don't do anything
         if(atoi(p.id) == atoi(deviceId)) {
-          statePending = false;
-          digitalWrite(ledStatePin, HIGH);
+          statePending = true;
+          ledStateInterval = blinkFast;
+          // digitalWrite(ledStatePin, HIGH);
         } else {
-          ledStateInterval = 500;
+          ledStateInterval = blinkSlow;
           statePending = true;
         }