changed freq ranges and debug messages

changed freq ranges and debug messages

--- arduino/fasnacht/fasnacht.ino
+++ arduino/fasnacht/fasnacht.ino
@@ -38,14 +38,13 @@
                  ValueLast,     //last state of ValuePassed
                  ChannelLast,   //last state of ChannelPassed
                  Value,         //analog input of data
-                 Channel,       //analog input of channel
+                 Channel = 0,       //analog input of channel
                  ValueAvg,      //voltage average
                  ChannelAvg,    //voltage average
                  ValueHighest = 0,     //peak value
                  ChannelHighest = 0,   //peak value
                  ValueLowest = 1023,   //peak value
-                 ChannelLowest = 1023, //peak value
-                 Channel = 0;  //output channel to write
+                 ChannelLowest = 1023; //peak value

     int brightness; //brighness data

@@ -57,8 +56,8 @@

     for (Ctr = 0; Ctr < 500; Ctr++) {
         //get input voltage
-        Value = analogRead(2);   // 2 = Audio left -> data
-        Channel = analogRead(3); // 2 = Audio right -> channel
+        Value = analogRead(3);   // 2 = Audio left -> data
+        Channel = analogRead(2); // 2 = Audio right -> channel

         //save peak values
         if (Value > ValueHighest) ValueHighest = Value;
@@ -100,28 +99,43 @@
     if (brightness < 0)     brightness = 0;

     //get channel data and write output
-    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+    if( (ChannelFrq > 140) && (ChannelFrq <= 160) ) {
       analogWrite(3, brightness);
-      Serial.print("Refresh Channel 3");
+      Serial.print("Refresh Channel 3 ");
+      Serial.print("Brightness ");
+      Serial.println(brightness);
     }
-    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+    if( (ChannelFrq > 240) && (ChannelFrq <= 260) ) {
       analogWrite(5, brightness);
-      Serial.print("Refresh Channel 5");
+      Serial.print("Refresh Channel 5 ");
+      Serial.print("Brightness ");
+      Serial.println(brightness);
     }
-    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+    if( (ChannelFrq > 340) && (ChannelFrq <= 360) ) {
       analogWrite(6, brightness);
-      Serial.print("Refresh Channel 6");
+      Serial.print("Refresh Channel 6 ");
+      Serial.print("Brightness ");
+      Serial.println(brightness);
     }
-    if( (ChannelFrq > 100) && (ChannelFrq < 200) ) {
+    if( (ChannelFrq > 440) && (ChannelFrq <= 460) ) {
       analogWrite(9, brightness);
-      Serial.print("Refresh Channel 9");
+      Serial.print("Refresh Channel 9 ");
+      Serial.print("Brightness ");
+      Serial.println(brightness);
     }

+
+    Serial.println("");
     //debug
-    Serial.print("Frequency: ");
+    /*Serial.print("Channel: ");
+    Serial.println(ChannelFrq);
+    Serial.print("Value: ");
     Serial.println(ValueFrq);
     Serial.print("Brightness: ");
     Serial.println(brightness);
+    */
+    Serial.print("---------------");
+

 //    analogWrite(3, brightness);
 //    analogWrite(5, brightness);


Refactorings

Refactorings

--- arduino/sketch/src/sketch.ino
+++ arduino/sketch/src/sketch.ino
@@ -1,5 +1,17 @@
 #include "LED_Bar.h"
 #include <math.h>
+
+// analog sensor mapping
+#define PLANT_SENSOR_1 A0
+#define PLANT_SENSOR_2 A1
+#define PLANT_SENSOR_3 A2
+#define VOLTAGE_SENSOR A3
+#define LIGHT_SENSOR A4
+#define TEMPERATURE_SENSOR A5
+
+#define THERMISTOR_VALUE 3975 //B value of the thermistor
+
+LED_Bar led_bar;

 int led_pin = 3;
 int relay_pin = 4;
@@ -7,22 +19,15 @@
 int plant1_value = 0;
 int plant2_value = 0;
 int plant3_value = 0;
-long voltage_value = 0;
-int temperature_value = 0;
+float voltage_value = 0.0f;
+float temperature_value = 0;
 int light_value = 0;

 int led_bar_value = 0;
-int B=3975; //B value of the thermistor

 int incomingByte = 0; // for incoming serial data
 int relay_delay = 0;
 bool relay_delay_counting = false;
-
-float battery_value = 0.0f;
-float temperature = 0.0f;
-float resistance = 0.0f;
-
-LED_Bar led_bar;

 void setup() {
     // set up pins and serial baud rate
@@ -34,35 +39,14 @@

 void loop() {
     // read sensor data
-    plant1_value = analogRead(A0);
-    plant2_value = analogRead(A1);
-    plant3_value = analogRead(A2);
-    voltage_value = analogRead(A3);
-    light_value = analogRead(A4);
-    temperature_value = analogRead(A5);
+    plant1_value = analogRead(PLANT_SENSOR_1);
+    plant2_value = analogRead(PLANT_SENSOR_2);
+    plant3_value = analogRead(PLANT_SENSOR_3);
+    voltage_value = get_voltage_value();
+    light_value = analogRead(LIGHT_SENSOR);
+    temperature_value = get_temperature_value();

-    // voltage probing (takes 2s)
-    long sum=0;
-    for(int i=0;i<1000;i++)
-    {
-        sum=voltage_value+sum;
-        voltage_value=analogRead(A3);
-        delay(2);
-    }
-    sum=sum/1000;
-
-    // voltage mapping
-    battery_value = 10*sum*4980/(1023.00*1000) * 12.96/14.07; // voltmeter used to determine last factor
-
-    // set led bar accordingly to solar value
-    led_bar_value = round((battery_value-10.0)/4.0*10); // min: 10V max: 14V
-    led_bar_value = max(min(led_bar_value,10),0); // make sure led_bar_value is in range 0-10
-    led_bar.set_LED_Range(1,led_bar_value);
-
-    // temperature mapping to celsius
-    resistance=(float)(1023-temperature_value)*10000/temperature_value;
-    temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
-
+    set_led_bar();

     if (Serial.available() > 0) { // check if serial input is available
         // turn status led on
@@ -92,11 +76,11 @@
             Serial.print(", \"plant3_value\": ");
             Serial.print(plant3_value);
             Serial.print(", \"battery_value\": ");
-            Serial.print(battery_value);
+            Serial.print(voltage_value, 2);
             Serial.print(", \"light_value\": ");
             Serial.print(light_value);
             Serial.print(", \"temperature_value\": ");
-            Serial.print(temperature);
+            Serial.print(temperature_value, 2);
             Serial.println(" }");
         }

@@ -114,4 +98,36 @@
             }
         }
     }
+}
+
+float get_temperature_value()
+{
+    int sensor_value;
+    float resistance = 0.0f;
+    sensor_value = analogRead(TEMPERATURE_SENSOR);
+    // temperature mapping to celsius
+    resistance=(float)(1023-sensor_value)*10000/sensor_value;
+    return 1/(log(resistance/10000)/THERMISTOR_VALUE+1/298.15)-273.15;
+}
+
+float get_voltage_value()
+{
+    // voltage probing (takes 2s)
+    long sum=0;
+    for(int i=0;i<1000;i++)
+    {
+        sum=voltage_value+sum;
+        voltage_value=analogRead(VOLTAGE_SENSOR);
+        delay(2);
+    }
+    // voltage mapping
+    return 10*(sum/1000)*4980/(1023.00*1000) * (12.96/14.07); // voltmeter used to determine last factor
+}
+
+void set_led_bar()
+{
+    // set led bar accordingly to solar value
+    led_bar_value = round((voltage_value-10.0)/4.0*10); // min: 10V max: 14V
+    led_bar_value = max(min(led_bar_value,10),0); // make sure led_bar_value is in range 0-10
+    led_bar.set_LED_Range(1,led_bar_value);
 }


Added temperature option to Arduino.

Added temperature option to Arduino.

--- arduino/surfcube/surfcube.ino
+++ arduino/surfcube/surfcube.ino
@@ -53,9 +53,6 @@
    7 -> red + yellow + green
    */
 int LEDBreathingState = 0;
-int LEDRedValue = 0;
-int LEDYellowValue = 0;
-int LEDGreenValue = 0;

 void setup() {
   Serial.begin(9600);
@@ -86,6 +83,28 @@
   ml = mm3 / 1000;
   stepperTargetPosition = ml * STEPS_PER_ML;
   stepperTargetPosition = clamp(stepperTargetPosition, 0, STEPPER_MAX_POSITION);
+}
+
+/*
+   Temperature in Celsius
+      < 15 green
+   15 - 20 green + yellow
+   20 - 25 yellow
+   25 - 30 yellow + red
+   30 >    red
+   */
+void setTemperature(int temperature) {
+  if(temperature <= 15) {
+    LEDBreathingState = 1;
+  } else if(15 < temperature && temperature <= 20) {
+    LEDBreathingState = 3;
+  } else if(20 < temperature && temperature <= 25) {
+    LEDBreathingState = 2;
+  } else if(25 < temperature && temperature <= 30) {
+    LEDBreathingState = 6;
+  } else if(30 < temperature) {
+    LEDBreathingState = 4;
+  }
 }

 void checkSerial() {
@@ -135,6 +154,8 @@
       stepperCurrentPosition = clamp(val, 0, STEPPER_MAX_POSITION);
       stepperTargetPosition  = clamp(val, 0, STEPPER_MAX_POSITION);
       EEPROM.put(EEPROM_STEPPER_ADDR, stepperCurrentPosition);
+    } else if (command == "temperature") {
+      setTemperature(val);
     } else {
       Serial.println("Command not understood!");
     }


corrigido funçãoBloqueante, da Refrigeração para o Vertical

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -224,9 +224,9 @@
     leFotocelula();
     funcaoSimples(mandibula, NomeMandibula, ti_mandibula, tf_mandibula);
     funcaoSegura(faca, NomeFaca, ti_faca, tf_faca, sensor_mandibula);
-    funcaoBloqueante(refrigeracao, NomeRefrigeracao, ti_refrigeracao, tf_refrigeracao);
+    funcaoSimples(refrigeracao, NomeRefrigeracao, ti_refrigeracao, tf_refrigeracao);
     funcaoComLiberacao(datador, NomeDatador, ti_datador, tf_datador, datador_ligado);
-    funcaoSimples(vertical, NomeVertical, ti_vertical, tf_vertical);
+    funcaoBloqueante(vertical, NomeVertical, ti_vertical, tf_vertical);
   }
   funcaoReset();
 }


icon update

icon update


Vibrate support and more...

Vibrate support and more...

--- sketch/CurieDice/CurieDice.ino
+++ sketch/CurieDice/CurieDice.ino
@@ -54,6 +54,10 @@
 #define SERIAL_PRINTLN(...)
 #endif

+unsigned long ledLapse;
+uint8_t ledState = LOW;
+
+#define VIBE_PIN        7
 // ************* NeoPixel ********************************************
 #define PIXEL_PIN       6     // Where the NeoPixel DIN pin is connected
 #define NUMPIXELS       8     // Number of LEDS on NeoPixel
@@ -69,7 +73,9 @@
     if (mask&(1<<i)) pixels.setPixelColor(i,c);
   }
   pixels.show();
+  delay(10);
   pixels.show();  // 2nd time helps fix a bug with bright LED0 issue.
+  delay(10);
   delay(dlay);
 }

@@ -117,8 +123,20 @@
       stillBegin = millis();
       stillMillis = 1;
     }
-    else
+    else {
       stillMillis = millis() - stillBegin;
+      if (stillMillis > 250) {
+        int a = vraw[0]>>8;
+        int b = vraw[1]>>8;
+        int c = vraw[2]>>8;
+        if (a>0x1d && a<0x3d && b>-10 && b<13 && c>0x12 && c<0x32) dispLed(0x1,0x0f0, 30);
+        else if (a>0x13 && a<0x37 && b>-13 && b<13 && c>(signed char)0xb3 && c<(signed char)0xd6) dispLed(0x3, 0x0f0, 30);
+        else if (a>(signed char)0xee && a<10 && b>(signed char)0xb1 && b<(signed char)0xd1 && c>(signed char)0xe6 && c<10) dispLed(0x7, 0x0f0, 30);
+        else if (a>(signed char)0xed && a<10 && b>0x30 && b<0x50 && c>(signed char)0xeb && c<10) dispLed(0x17, 0x0f0, 30);
+        else if (a>(signed char)0xc5 && a<(signed char)0xe0 && b>-10 && b<10 && c>0x1a && c<0x36) dispLed(0x37, 0x0f0, 30);
+        else if (a>(signed char)0xbb && a<(signed char)0xdb && b>-10 && b<10 && c>(signed char)0xbb && c<(signed char)0xdb) dispLed(0x77, 0x0f0, 30);
+      }
+    }
   }
   else stillMillis=0;

@@ -126,10 +144,22 @@
   SERIAL_PRINT("\t");

   SERIAL_PRINTLN(stillMillis);
-
-  dispLed(0xff, 0x000, 0);
-  dispLed(mask, 0x00f, 0);
-
+
+  if (stillMillis <=250) {
+    dispLed(0xff, 0x000, 0);
+    dispLed(mask, 0x00f, 0);
+  }
+
+  if (movement > 64)
+  {
+    digitalWrite(VIBE_PIN,1);
+    delay(50);
+    digitalWrite(VIBE_PIN,0);
+    delay(50);
+    digitalWrite(VIBE_PIN,1);
+    delay(50);
+    digitalWrite(VIBE_PIN,0);
+  }
   return movement;
 }

@@ -138,6 +168,9 @@
 boolean blinkState = false; // state of the LED
 // ************* setup **************************************************
 void setup() {
+  pinMode(VIBE_PIN, OUTPUT);
+  digitalWrite(VIBE_PIN,0);
+
   pixels.begin();
   pixels.show();
   dispLed(0xff, 0x0, 0);        // all off
@@ -247,6 +280,7 @@

   dispLed(0x02, 0x0f0, 0);      // 1 - green IMU setup done

+  ledLapse = millis();
 }

 void atten(int16_t *a, int len, int shiftBy)
@@ -287,4 +321,11 @@
     vraw[9] = nextSeqNum();
     batteryLevelChar.setValue((unsigned char*) vraw, 20);
   }
-}
+
+  if ((millis()-ledLapse) > 1000) {
+    ledLapse = millis();
+    ledState = !ledState;
+    digitalWrite(13,ledState);
+      //digitalWrite(VIBE_PIN,ledState);
+  }
+}


update

update

--- src/Firmware.ino
+++ src/Firmware.ino
@@ -1,13 +1,17 @@
 #include <Arduino.h>
 #include <MeStepper.h>
 #include <28BYJ.h>
+// #define MAKEBLOCK 1
+// #define DEBUG true
 #define POINTS_COUNT 10
-#define PULSES_PER_MM 80 //166.66
+#ifdef MAKEBLOCK
+#define PULSES_PER_MM 80
+#else
+#define PULSES_PER_MM 166.66
+#endif
 #define CURVE_SECTION 0.5
 #define NUM_STEPS 10
 #define NUM_AXIS 2
-#define MAKEBLOCK 1
-// #define DEBUG true
 enum MOTION_STATE
 {
     MOTION_ACCELETING = 0,
@@ -17,7 +21,8 @@
 typedef struct
 {
     volatile long err;
-    volatile double delta[NUM_AXIS];
+    volatile long delta[NUM_AXIS];
+    volatile long restCount[NUM_AXIS];
     volatile bool dir[NUM_AXIS];
     volatile long accelCount = 0;
     volatile long decelCount = 0;
@@ -100,7 +105,20 @@
     moveTo(0, 0);
     for (;;)
     {
-        // motion();
+        if (Serial.available)
+        {
+            char c = Serial.read();
+            if (c == '\n')
+            {
+                Serial.println(_sys.buffer);
+                parseCommand();
+                _sys.buffer = "";
+            }
+            else
+            {
+                _sys.buffer += c;
+            }
+        }
         if (_sys.isSpiProcessing)
         {
             _sys.isSpiReceiving = false;
@@ -150,31 +168,9 @@
         }
     }
 }
-// double tttt = 0;
-// long kkk = 0;
 ISR(SPI_STC_vect)
 {
     char c = SPDR;
-    /*test speed
-    if (tttt == 0)
-    {
-        tttt = micros() / 1000.0;
-    }
-    if (c > 9)
-    {
-        ttt++;
-    }
-    if (ttt >= 1024)
-    {
-        kkk++;
-        float n = (micros() / 1000.0 - tttt) / 1000.0;
-        Serial.print(ttt / n / 1024.0);
-        Serial.print(":");
-        Serial.print(kkk);
-        Serial.print("\n");
-        ttt = 0;
-        tttt = micros() / 1000.0;
-    }*/
     if (c > 0 && c < 0xff)
     {
         if (!_sys.isSpiProcessing)
@@ -332,6 +328,8 @@
     _points[_sys.plannedIndex].targetCount[1] = abs(_points[_sys.plannedIndex].targetPosition[1] - _prevPoint.targetPosition[1]);
     _points[_sys.plannedIndex].delta[0] = (_points[_sys.plannedIndex].targetCount[0]);
     _points[_sys.plannedIndex].delta[1] = (_points[_sys.plannedIndex].targetCount[1]);
+    _points[_sys.plannedIndex].restCount[0] = (_points[_sys.plannedIndex].targetCount[0]);
+    _points[_sys.plannedIndex].restCount[1] = (_points[_sys.plannedIndex].targetCount[1]);
     _points[_sys.plannedIndex].totalCount = _points[_sys.plannedIndex].delta[0] + _points[_sys.plannedIndex].delta[1];
     _points[_sys.plannedIndex].speed = speed;
     if (_sys.plannedIndex > 0)
@@ -494,20 +492,18 @@
     {
         return false;
     }
-    // firePower(_points[0].power);
-    long distX = _points[0].delta[0];
-    long distY = _points[0].delta[1];
-    if (distX <= 0 && distY <= 0)
+    firePower(_points[0].power);
+    if (_points[0].restCount[0] <= 0 && _points[0].restCount[1] <= 0)
         return false;
     long e2 = _points[0].err;
-    if (e2 > -distX)
-    {
-        _points[0].err -= distY;
+    if (e2 > -_points[0].delta[0])
+    {
+        _points[0].err -= _points[0].delta[1];
         stepX(_points[0].dir[0]);
     }
-    if (e2 < distY)
-    {
-        _points[0].err += distX;
+    if (e2 < _points[0].delta[1])
+    {
+        _points[0].err += _points[0].delta[0];
         stepY(_points[0].dir[1]);
     }
     nextWait();
@@ -516,14 +512,14 @@
 void stepX(bool dir)
 {
     _sys.currentPosition[0] += dir ? 1 : -1;
-    _points[0].delta[0]--;
+    _points[0].restCount[0]--;
     _points[0].totalCount--;
     steppers[0].step(dir);
 }
 void stepY(bool dir)
 {
     _sys.currentPosition[1] += dir ? 1 : -1;
-    _points[0].delta[1]--;
+    _points[0].restCount[1]--;
     _points[0].totalCount--;
     steppers[1].step(dir);
 }
@@ -573,12 +569,9 @@
         break;
     }
     }
-    tt = 0;
-    // _sys.during = 160000 / (_sys.currentSpeed + 1);
     _sys.currentSpeed = _sys.currentSpeed > 5000 ? 5000 : (_sys.currentSpeed < 5 ? 5 : _sys.currentSpeed);
     long during = min(62500, ((2000000 / _sys.currentSpeed))) - 1;
     OCR1A = during;
-    // _sys.during = _sys.during > 100000 ? 100000 : (_sys.during < 1500 ? 1500 : _sys.during);
 }
 /**
  * Motion Parse
@@ -649,4 +642,31 @@
         }
     }
     return _sys.buffer.substring(startIndex, index).toDouble();
-}+}
+
+double tttt = 0;
+long kkk = 0;
+///*test speed
+void testSpeed(char c)
+{
+    if (tttt == 0)
+    {
+        tttt = micros() / 1000.0;
+    }
+    if (c > 9)
+    {
+        ttt++;
+    }
+    if (ttt >= 1024)
+    {
+        kkk++;
+        float n = (micros() / 1000.0 - tttt) / 1000.0;
+        Serial.print(ttt / n / 1024.0);
+        Serial.print(":");
+        Serial.print(kkk);
+        Serial.print("\n");
+        ttt = 0;
+        tttt = micros() / 1000.0;
+    }
+}
+//*/


rtc test is done

rtc test is done

remove rtc

--- _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-lcd-dust/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -10,7 +10,7 @@
 #include <Wire.h>
 #include <PubSubClient.h>
 #include "PietteTech_DHT.h"
-#include <RtcDS1307.h>
+//#include <RtcDS1307.h>

 #define REPORT_INTERVAL 5000 // in msec

@@ -68,11 +68,13 @@
 #define DEBUG_PRINT 1

 // rtc
+/*
 #define SquareWavePin 1
 volatile unsigned long SquareWaveCount;
 unsigned long old_SquareWaveCount;

 RtcDS1307 Rtc;
+*/

 //---------
 char* topic = "esp8266/arduino/s03";
@@ -132,8 +134,8 @@
 byte nemoicon[8]        = { B11011, B11011, B00100, B11111, B10101, B11111, B01010, B11011, };

 // system defines
-#define DHTTYPE  DHT22              // Sensor type DHT11/21/22/AM2301/AM2302
-#define DHTPIN   3              // Digital pin for communications
+#define DHTTYPE  DHT22        // Sensor type DHT11/21/22/AM2301/AM2302
+#define DHTPIN   3            // Digital pin for communications
 #define DHT_SAMPLE_INTERVAL   2100

 //declaration
@@ -166,7 +168,6 @@
   for (int i = 0; i < length; i++) {
     receivedpayload += (char)inpayload[i];
   }
-
   parseMqttMsg(receivedpayload, receivedtopic);
 }

@@ -244,7 +245,6 @@
       rsptot = atoi(temprsptot);
     }
   }
-
   msgcallback = !msgcallback;
 }

@@ -308,9 +308,11 @@
   return client.connected();
 }

+/*
 void check_SquareWaveCount() {
   SquareWaveCount++;
 }
+*/

 void setup() {
   delay(20);
@@ -319,18 +321,23 @@
   startMills = sentMills = millis();
   Wire.begin(0, 2);

-  T2 =  OT = PW = NW =  dustDensity = SquareWaveCount = old_SquareWaveCount = 0 ;
+//T2 =  OT = PW = NW =  dustDensity = SquareWaveCount = old_SquareWaveCount = 0 ;
+  T2 =  OT = PW = NW =  dustDensity = 0 ;
   PIR = HO = HL = moisture = unihost = rsphost = unitot = rsptot = 0;
   msgcallback = false;

+/*
   Rtc.Begin();
   Rtc.SetIsRunning(true);
   Rtc.SetSquareWavePin(DS1307SquareWaveOut_1Hz);
+*/

   lastReconnectAttempt = 0;

+/*
   pinMode(SquareWavePin, INPUT_PULLUP);
   attachInterrupt(SquareWavePin, check_SquareWaveCount, FALLING);
+*/

   getResetInfo = "hello from ESP8266 s03 ";
   getResetInfo += ESP.getResetInfo().substring(0, 30);
@@ -456,10 +463,12 @@
         }
       }
     } else {
+      /*
       if ( SquareWaveCount > old_SquareWaveCount ) {
         printSquareWaveCount();
         old_SquareWaveCount = SquareWaveCount;
       }
+      */

       if (bDHTstarted) {
         if (!DHT.acquiring()) {
@@ -510,17 +519,20 @@
         payload += H;
         payload += ",\"Temperature\":";
         payload += T1;
+        /*
         payload += ",\"SquareWaveCount\":";
         payload += SquareWaveCount;
+        */
+        // to check DHT.acquiring()
         payload += ",\"acquireresult\":";
         payload += acquireresult;
-        // to check DHT.acquiring()
         payload += ",\"acquirestatus\":";
         payload += DHT.acquiring();
         payload += ",\"bDHTstarted\":";
         payload += bDHTstarted;
         payload += ",\"FreeHeap\":";
         payload += ESP.getFreeHeap();
+        //
         payload += ",\"RSSI\":";
         payload += WiFi.RSSI();
         payload += ",\"millis\":";
@@ -566,6 +578,7 @@
   free(p);
 }

+/*
 void printSquareWaveCount() {
   String udppayload = "SquareWave,device=esp-1 ";
   udppayload += " SquareWaveCount=";
@@ -574,6 +587,7 @@

   sendUdpmsg(udppayload);
 }
+*/

 void printEdgeTiming(class PietteTech_DHT *_d) {
   byte n;


COH-80: WIP

COH-80: WIP

--- COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -329,6 +329,15 @@
 // Support for secure TX side using FHT8V ID plus 0x80 padding from REV2 hub.
 // (High bits of trailing bytes should be low for traffic TO node whose ID is in header.)
 OTRadioLink::SimpleSecureFrame32or0BodyTXV0p2SuppliedID secureTXState(NULL);
+// Set TX ID for target; two bytes of housecode padded with zeros (for reverse traffic).
+static void setTXID(const uint8_t hc1, const uint8_t hc2)
+  {
+  uint8_t id[OTV0P2BASE::OpenTRV_Node_ID_Bytes];
+  id[0] = hc1;
+  id[1] = hc2;
+  memset(id + 2, 0, OTV0P2BASE::OpenTRV_Node_ID_Bytes - 2);
+  secureTXState.setTXID(id);
+  }
 #endif // defined(ALLOW_CC1_SUPPORT_RELAY)
 #endif // defined(ENABLE_OTSECUREFRAME_ENCODING_SUPPORT)

@@ -353,13 +362,13 @@
   if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
     { OTV0P2BASE::serialPrintlnAndFlush(F("!TX key")); return(false); } // FAIL
   const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
-  uint8_t buf[OTRadioLink::SimpleSecureFrame32or0BodyTXBase::generateSecureBeaconMaxBufSize];
-  const uint8_t bodylen = secureTXState.generateSecureBeaconRawForTX(buf, sizeof(buf), lenTXID, e, NULL, key); // 2 byte ID.
+  uint8_t sbuf[OTRadioLink::SimpleSecureFrame32or0BodyTXBase::generateSecureBeaconMaxBufSize];
+  const uint8_t sbodylen = secureTXState.generateSecureBeaconRawForTX(sbuf, sizeof(sbuf), lenTXID, e, NULL, key); // 2 byte ID.
   // ASSUME FRAMED CHANNEL 0 (but could check with config isUnframed flag).
   // When sending on a channel with framing, do not explicitly send the frame length byte.
   // DO NOT attempt to send if construction of the secure frame failed;
   // doing so may reuse IVs and destroy the cipher security.
-  const bool success = (0 != bodylen) && PrimaryRadio.sendRaw(buf+1, bodylen-1);
+  const bool success = (0 != sbodylen) && PrimaryRadio.sendRaw(sbuf+1, sbodylen-1);
 #if 1 && defined(DEBUG)
   if(!success) { OTV0P2BASE::serialPrintlnAndFlush(F("!TX")); }
   else { OTV0P2BASE::serialPrintlnAndFlush(F("TX alert")); }
@@ -756,9 +765,9 @@
           if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
             { OTV0P2BASE::serialPrintlnAndFlush(F("!TX key")); return; } // FAIL
           const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
-          uint8_t buf[OTRadioLink::SecurableFrameHeader::maxSmallFrameSize];
-          const uint8_t sbodylen = secureTXState.generateSecureOStyleFrameForTX(buf, sizeof(buf), OTRadioLink::FTS_RESERVED_A, lenTXID, txbuf, bodylen, e, NULL, key);
-          const bool success = (0 != sbodylen) && PrimaryRadio.sendRaw(buf+1, bodylen-1);
+          uint8_t sbuf[OTRadioLink::SecurableFrameHeader::maxSmallFrameSize];
+          const uint8_t sbodylen = secureTXState.generateSecureOStyleFrameForTX(sbuf, sizeof(sbuf), OTRadioLink::FTS_RESERVED_A, lenTXID, txbuf, bodylen, e, NULL, key);
+          const bool success = (0 != sbodylen) && PrimaryRadio.sendRaw(sbuf+1, sbodylen-1);
 #if 1 && defined(DEBUG)
           if(!success) { OTV0P2BASE::serialPrintlnAndFlush(F("!TX A")); }
           else { OTV0P2BASE::serialPrintlnAndFlush(F("TX A")); }
@@ -981,13 +990,13 @@
 #ifndef ENABLE_OTSECUREFRAME_ENCODING_SUPPORT
   if((buflen < 8) || (OTRadioLink::FTp2_CC1PollAndCmd != buf[0])) { return(false); }
   // Filter for only this unit address/housecode as FHT8V.getHC{1,2}() are thread-safe.
-  if((FHT8V.getHC1() == buf[1]) || (FHT8V.getHC2() == buf[2])) { return(false); }
+  if((FHT8V.getHC1() != buf[1]) || (FHT8V.getHC2() != buf[2])) { return(false); }
 #else
   // Expect secure frame with 2-byte ID and 32-byte encrypted body.
   if((buflen < 60) || ((0x80|OTRadioLink::FTp2_CC1PollAndCmd) != buf[0])) { return(false); }
   // Filter for only this unit address/housecode as FHT8V.getHC{1,2}() are thread-safe.
   if((buf[1] & 0xf) < 2) { return(false); }
-  if((FHT8V.getHC1() == buf[2]) || (FHT8V.getHC2() == buf[3])) { return(false); }
+  if((FHT8V.getHC1() != buf[2]) || (FHT8V.getHC2() != buf[3])) { return(false); }
 #endif // ENABLE_OTSECUREFRAME_ENCODING_SUPPORT
   return(true); // Accept message.
   }
@@ -1148,9 +1157,9 @@
           if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
             { OTV0P2BASE::serialPrintlnAndFlush(F("!TX key")); return(false); } // FAIL
           const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
-          uint8_t buf[OTRadioLink::SecurableFrameHeader::maxSmallFrameSize];
-          const uint8_t sbodylen = secureTXState.generateSecureOStyleFrameForTX(buf, sizeof(buf), OTRadioLink::FTS_RESERVED_Q, lenTXID, txbuf, bodylen, e, NULL, key);
-          const bool success = (0 != sbodylen) && PrimaryRadio.sendRaw(buf+1, bodylen-1);
+          uint8_t sbuf[OTRadioLink::SecurableFrameHeader::maxSmallFrameSize];
+          const uint8_t sbodylen = secureTXState.generateSecureOStyleFrameForTX(sbuf, sizeof(sbuf), OTRadioLink::FTS_RESERVED_Q, lenTXID, txbuf, bodylen, e, NULL, key);
+          const bool success = (0 != sbodylen) && PrimaryRadio.sendRaw(sbuf+1, sbodylen-1);
 #if 1 && defined(DEBUG)
           if(!success) { OTV0P2BASE::serialPrintlnAndFlush(F("!TX Q")); }
           else { OTV0P2BASE::serialPrintlnAndFlush(F("TX Q")); }


remove useless code

remove useless code

--- tests/bluetooth/src/sketch.ino
+++ tests/bluetooth/src/sketch.ino
@@ -8,58 +8,38 @@

 #include <SoftwareSerial.h>

-#define LEDpin 13
+#define LEDpin 8

-#define BluRX 0
-#define BluTX 1
+#define bluRX 2
+#define bluTX 3

-SoftwareSerial bluSerial(BluRX, BluTX);
+SoftwareSerial bluSerial(bluRX, bluTX);
+char val;

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

-    pinMode(BluRX, INPUT);
-    pinMode(BluTX, OUTPUT);
+    pinMode(13, OUTPUT);
+    pinMode(LEDpin, OUTPUT);
+
+    pinMode(bluRX, INPUT);
+    pinMode(bluTX, OUTPUT);

-    setupBlueToothConnection();
-
-    pinMode(LEDpin, OUTPUT);
+    bluSerial.begin(9600);
+    Serial.println("starting...");
 }

 void loop() {
-    /* digitalWrite(13, LOW); */
-    digitalWrite(LEDpin, HIGH);
-    delay(2000);
+    digitalWrite(13, LOW);
     digitalWrite(LEDpin, LOW);
-    delay(2000);
+
+    if(bluSerial.available()) {
+      val = bluSerial.read();
+    }

-    /* char val; */
-    /* while(1) { */
-    /*     if (Serial.available()) { */
-    /*         if (bluSerial.available()) { */
-    /*             val = bluSerial.read(); */
-    /*             Serial.print(val); */
-    /*         } */
-    /*     } */
-    /* } */
-    /* if (val == '1') { */
-    /*     digitalWrite(LEDpin, HIGH); */
-    /* } */
-    /* if (val == '0') { */
-    /*     digitalWrite(LEDpin, LOW); */
-    /* } */
+    if (Serial.available()) {
+      Serial.println("! blutooth");
+      Serial.println(val);
+    }
+    delay(1000);
 }
-
-void setupBlueToothConnection()
-{
- bluSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
- bluSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
- bluSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
- bluSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
- bluSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
- delay(2000); // This delay is required.
- bluSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
- Serial.println("The slave bluetooth is inquirable!");
- delay(2000); // This delay is required.
- bluSerial.flush();
-}


Update MultipleSteppers.ino

Update MultipleSteppers.ino

--- examples/MultipleSteppers/MultipleSteppers.ino
+++ examples/MultipleSteppers/MultipleSteppers.ino
@@ -15,16 +15,15 @@

 #include <StepControl.h>

-Stepper motor_1(2, 3);
-Stepper motor_2(9,10);
-Stepper motor_3(14,15);
+Stepper motor_1(2, 3);   //STEP pin =  2, DIR pin = 3
+Stepper motor_2(9,10);   //STEP pin =  9, DIR pin = 10
+Stepper motor_3(14,15);  //STEP pin = 14, DIR pin = 15

 StepControl<> controller;

 void setup()
 {
-  // setup the used motors
-
+  // setup the motors
    motor_1
     .SetMaxSpeed(50000)       // steps/s
     .SetAcceleration(200000); // steps/s^2
@@ -62,8 +61,8 @@
   controller.move(motor_1, motor_2);

   // now move motor_2 together with motor_3
-  motor_2.SetTargetRel(300);
-  motor_3.SetTargetRel(-800);
+  motor_2.SetTargetRel(spr/3);
+  motor_3.SetTargetRel(-spr*2);
   controller.move(motor_2, motor_3);

   // move motor_1 and motor_3 back to their start positions


compass example: moved turn base speed to a define

--- ZumoMotors/examples/CompassExample/CompassExample.ino
+++ ZumoMotors/examples/CompassExample/CompassExample.ino
@@ -25,7 +25,9 @@
  * reliable.
  */

-#define SPEED 200 // Maximum motor speed when turning or going straight
+#define SPEED           200 // Maximum motor speed when going straight; variable speed when turning
+#define TURN_BASE_SPEED 100 // Base speed when turning (added to variable speed)
+

 #define CALIBRATION_SAMPLES 70  // Number of compass readings to take when calibrating
 #define CRA_REG_M_220HZ 0x1C    // CRA_REG_M value for magnetometer 220 Hz update rate
@@ -157,15 +159,15 @@
   {
     // To avoid overshooting, the closer the Zumo gets to the target
     // heading, the slower it should turn. Set the motor speeds to a
-    // minimum of +/-100 plus an additional amount based on the
-    // heading difference.
+    // minimum base amount plus an additional variable amount based
+    // on the heading difference.

     speed = SPEED*relative_heading/180;

     if (speed < 0)
-      speed -= 100;
+      speed -= TURN_BASE_SPEED;
     else
-      speed += 100;
+      speed += TURN_BASE_SPEED;

     motors.setSpeeds(speed, -speed);


Update Firmware.ino

Update Firmware.ino

--- src/piggy_back_loggers/SD_prototype_Firmware/Firmware/Firmware.ino
+++ src/piggy_back_loggers/SD_prototype_Firmware/Firmware/Firmware.ino
@@ -88,6 +88,8 @@
   digitalWrite(4, HIGH);
   pinMode(5, INPUT);

+  rtcTransfer(reg_Control_2, WRITE, 0x02);
+
   attachInterrupt(digitalPinToInterrupt(2), INT0_ISR, FALLING);   // Setup Interrupts
   attachInterrupt(digitalPinToInterrupt(3), INT1_ISR, FALLING);
   EIMSK &= ~(1 << INT0);        // Disable Hall Effect Sensor interrupt
@@ -131,6 +133,10 @@
   *                 function)
   \*****************************************/
   if(State.flag4)
+  {
+    State.flag4 = false;
+    rtcTransfer(reg_Control_2, WRITE, 0x02);
+  }
     // Daniel's function
       // Don't forget to clear flag on RTC!


added persistence for local server address and cloud server sharing

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -102,7 +102,7 @@
 boolean GOT_HUMID_SENSOR = false;  // we'll change later if we detect sensor

 /////////////////////////////////////////////////////////////////////////////
-// Light sensor stuff ///////////////////////////////////////////////////////
+// light sensor stuff ///////////////////////////////////////////////////////
 Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591); // sensor id
 boolean GOT_LIGHT_SENSOR = false; // we'll change later if we detect sensor

@@ -122,6 +122,13 @@
 RCSwitch mySwitch = RCSwitch();

 /////////////////////////////////////////////////////////////////////////////
+// config utils /////////////////////////////////////////////////////////////
+boolean getCloudShare();
+void setCloudShare(boolean b);
+String getSvrAddr();
+void setSvrAddr(String s);
+
+/////////////////////////////////////////////////////////////////////////////
 // misc utils ///////////////////////////////////////////////////////////////
 void ledOn();
 void ledOff();
@@ -133,10 +140,12 @@
   Serial.begin(115200);

   pinMode(BUILTIN_LED, OUTPUT); // turn built-in LED on
-  blink(3); // signal we're starting config
-
+  blink(3); // signal we're starting setup
+
+  // read persistent config
   SPIFFS.begin();
-  readConfig();
+  svrAddr = getSvrAddr();
+
   startPeripherals();
   startAP();
   printIPs();
@@ -369,14 +378,6 @@
     ssid.toCharArray(ssidchars, sizeof(ssid));
     key.toCharArray(keychars, sizeof(key));
     WiFi.begin(ssidchars, keychars);
-
-    // TODO causes reset in /wifistatus
-    /*
-    if(WiFi.hostname("waterelf"))
-      Serial.println("set hostname succeeded");
-    else
-      Serial.println("set hostname failed");
-    */
   }

   toSend += pageFooter;
@@ -392,6 +393,7 @@
   f += "
Local server IP address: ";
   f += "<input type='textarea' name='svraddr'>

 ";
   f += "Sharing on WeGrow.social: ";
+  // TODO set checked dependent on getCloudShare()
   f += "on <input type='radio' name='wegrow' value='on' checked>\n";
   f += "off <input type='radio' name='wegrow' value='off'>

\n";
   f += "<input type='submit' value='Submit'></form>
";
@@ -410,6 +412,7 @@
   toSend += ": server configured";
   toSend += pageTop2;

+  boolean cloudShare = false;
   for(uint8_t i = 0; i < webServer.args(); i++) {
     if(webServer.argName(i) == "svraddr") {
       svrAddr = webServer.arg(i);
@@ -417,14 +420,18 @@
       toSend += "
...at ";
       toSend += svrAddr;
       toSend += "
";
+    } else if(webServer.argName(i) == "key") {
+      if(webServer.arg(i) == "on")
+        cloudShare = true;
     }
-
-    // TODO else if got "wegrow" turn cloud server share on
-  }
-
-  // TODO persist the config
+  }
+
+  // persist the config
+  if(svrAddr.length() > 0) setSvrAddr(svrAddr);
+  setCloudShare(cloudShare);

   // TODO some way of verifying if server config worked
+  // add srvstatus, or roll that into wifistatus, or...?

   toSend += pageFooter;
   webServer.send(200, "text/html", toSend);
@@ -649,6 +656,42 @@
 }

 /////////////////////////////////////////////////////////////////////////////
+// config utils /////////////////////////////////////////////////////////////
+boolean getCloudShare() {
+  boolean b = false;
+  File f = SPIFFS.open("/cloudShare.txt", "r");
+  if(f) {
+    b = true;
+    f.close();
+  }
+  return b;
+}
+void setCloudShare(boolean b) {
+  if(b) {
+    File f = SPIFFS.open("/cloudShare.txt", "w");
+    f.println("");
+    f.close();
+  } else {
+    SPIFFS.remove("/cloudShare.txt");
+  }
+}
+String getSvrAddr() {
+  String s = "";
+  File f = SPIFFS.open("/svrAddr.txt", "r");
+  if(f) {
+    s = f.readString();
+    s.trim();
+    f.close();
+  }
+  return s;
+}
+void setSvrAddr(String s) {
+  File f = SPIFFS.open("/svrAddr.txt", "w");
+  f.println(s);
+  f.close();
+}
+
+/////////////////////////////////////////////////////////////////////////////
 // misc utils ///////////////////////////////////////////////////////////////
 void ledOn() { digitalWrite(BUILTIN_LED, LOW); }
 void ledOff() { digitalWrite(BUILTIN_LED, HIGH); }


Minor formatting changes to SD card filenames.

--- Calibration/sdWrite/sdWrite.ino
+++ Calibration/sdWrite/sdWrite.ino
@@ -53,7 +53,7 @@
  */
 bool SD_write(String data)
 {
-    File dataFile = SD.open("alex.txt", FILE_WRITE);
+    File dataFile = SD.open("temp.txt", FILE_WRITE);
     // If the file is available, write to it:
     if (dataFile) {
         dataFile.println(data);
@@ -63,7 +63,7 @@
       }
   // If the file isn't open, pop up an error:
     else {
-        Serial.println("error opening file");
+        Serial.println("Error opening file");
         dataFile.close();
     }
 }


force server to reinit if it loses connection

--- drone/WebServerESC/WebServerESC.ino
+++ drone/WebServerESC/WebServerESC.ino
@@ -110,13 +110,24 @@
     WiServer.init(sendMyPage);
 }

+U8 state = 0;
+
 void loop()
 {
-  // Run WiServer
-  WiServer.server_task();
-  delay(10);
+    U8 newState = WiServer.getConnectionState();
+
+    if(newState != state) {
+        state = newState;
+    }
+
+    if(!state) {
+        WiServer.init(sendMyPage);
+    }
+
+    // Run WiServer
+    WiServer.server_task();
+    delay(10);
 }
-

 void _webpageHelper()
 {


add toggling patterns with setup button

add toggling patterns with setup button

--- src/blinky.ino
+++ src/blinky.ino
@@ -12,11 +12,13 @@
 #define PIXEL_TYPE WS2812B
 #define HUE_STEP 10 // 1..255, each loop increments hue by this value
 #define LOOP_DELAY 100 //ms
+#define BASE_BRIGHTNESS 40 //0-255
+#define BASE_SATURATION 255
+#define N_PATTERNS 2

 Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
 uint8_t base_hue = 0;
-uint8_t base_brightness = 100; //0-255
-uint8_t base_saturation = 255;
+uint8_t pattern = 0;

 // setup() runs once, when the device is first turned on.
 void setup() {
@@ -25,7 +27,7 @@
 }

 void pattern_hsv_circle_loop(Adafruit_NeoPixel *strip){
-  HsvColor hsv(base_hue, base_saturation, base_brightness);
+  HsvColor hsv(base_hue, BASE_SATURATION, BASE_BRIGHTNESS);
   RgbColor rgb = HsvToRgb(hsv);
   for (int i = 0 ; i < PIXEL_COUNT ; ++i){
     (*strip).setPixelColor(i, rgb.r, rgb.g, rgb.b);
@@ -39,7 +41,7 @@
   HsvColor hsv;
   for (int i = 0 ; i < PIXEL_COUNT ; ++i){
     offset = ((float)i/(PIXEL_COUNT-1))*255;
-    hsv = HsvColor(base_hue+offset, base_saturation, base_brightness);
+    hsv = HsvColor(base_hue+offset, BASE_SATURATION, BASE_BRIGHTNESS);
     rgb = HsvToRgb(hsv);
     (*strip).setPixelColor(i, rgb.r, rgb.g, rgb.b);
   }
@@ -48,7 +50,17 @@

 // loop() runs over and over again, as quickly as it can execute.
 void loop() {
-  pattern_hsv_offset_circle_loop(&strip);
+  if (HAL_Core_Mode_Button_Pressed(1000)) {
+    ++pattern;
+    if (pattern >= N_PATTERNS) {
+      pattern = 0;
+    }
+  }
+  if (pattern == 0){
+    pattern_hsv_offset_circle_loop(&strip);
+  } else if (pattern == 1) {
+    pattern_hsv_circle_loop(&strip);
+  }
   strip.show();
   delay(LOOP_DELAY);
 }


fixing

fixing

--- coni/arduino/main/big/big.ino
+++ coni/arduino/main/big/big.ino
@@ -23,7 +23,7 @@
 #define DE 10

 #define MAXSPEED 6000
-#define MAXACC 400
+#define MAXACC 4000

 SoftwareSerial mySerial(pinRX, pinTX);
 AccelStepper stepper_C(1, pinStep_C, pinDirection_C);


Save where I am

Save where I am

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -3,7 +3,7 @@
 // 2009-05-06 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

 // this version adds flash memory support, 2009-11-19
-
+// Adding frequency features. 2013-09-05 JohnOH
 #include <JeeLib.h>
 #include <util/crc16.h>
 #include <util/parity.h>
@@ -44,7 +44,8 @@
 typedef struct {
   byte nodeId;
   byte group;
-  char msg[RF12_EEPROM_SIZE-4];
+  word frequency;
+  char msg[RF12_EEPROM_SIZE-6];
   word crc;
 } RF12Config;

@@ -96,9 +97,14 @@
   addInt(config.msg, config.group);

   strcat(config.msg, " @ ");
-  static word bands[4] = { 315, 433, 868, 915 };
+  static word bands[4] = { 3150, 4300, 8600, 9000 };
   word band = config.nodeId >> 6;
-  addInt(config.msg, bands[band]);
+  word freq = bands[band];
+  word incr = freq + ((((config.frequency)/100) * (band * 25 )) / 10);
+  word characteristic = incr/10;
+  addInt(config.msg, characteristic);
+  strcat(config.msg, ".");
+  addInt(config.msg, (incr - (characteristic * 10)));
   strcat(config.msg, " MHz ");

   config.crc = ~0;
@@ -550,6 +556,7 @@
   "Available commands:" "\n"
   "  <nn> i     - set node ID (standard node ids are 1..30)" "\n"
   "  <n> b      - set MHz band (4 = 433, 8 = 868, 9 = 915)" "\n"
+  "  <n> o      - Adjust frequency within the frequency band above" "\n"
   "  <nnn> g    - set network group (RFM12 only allows 212, 0 = any)" "\n"
   "  <n> c      - set collect mode (advanced, normally 0)" "\n"
   "  t          - broadcast max-size test packet, request ack" "\n"
@@ -610,13 +617,33 @@
         showHelp();
         break;
       case 'i': // set node id
-        config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F);
-        saveConfig();
+        if (value > 0 & value < 32) {
+           config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F);
+           saveConfig();
+        } else {
+           showHelp();
+        }
         break;
       case 'b': // set band: 4 = 433, 8 = 868, 9 = 915
-        if (value)
-          config.nodeId = (bandToFreq(value) << 6) + (config.nodeId & 0x3F);
-        saveConfig();
+         value = value == 4 ? RF12_433MHZ :
+                 value == 8 ? RF12_868MHZ :
+                 value == 9 ? RF12_915MHZ : 0;
+        if (value) {
+         config.nodeId = (value << 6) + (config.nodeId & 0x3F);
+         config.frequency = 1600;
+         saveConfig();
+        } else {
+            showHelp();
+        }
+        break;
+      case 'o': // set frequency
+        Serial.print(config.frequency);
+        config.frequency = value*(20*25*band);
+        Serial.print("->");
+        Serial.print(config.frequency);
+        rf12_control(config.frequency);
+        }
+        Serial.println();
         break;
       case 'g': // set network group
         config.group = value;
@@ -722,7 +749,7 @@
 }

 void displayVersion(uint8_t newline ) {
-  Serial.print("\n[RF12demo.10]");
+  Serial.print("\n[RF12demo.11]");
   if(newline!=0)  Serial.println();

 }
@@ -735,9 +762,11 @@
   if (rf12_config()) {
     config.nodeId = eeprom_read_byte(RF12_EEPROM_ADDR);
     config.group = eeprom_read_byte(RF12_EEPROM_ADDR + 1);
+    config.frequency = eeprom_read_word(RF12_EEPROM_ADDR + 2);
   } else {
     config.nodeId = 0x41; // 433 MHz, node 1
     config.group = 0xD4;  // default group 212
+    config.frequency = 1600;
     saveConfig();
   }


sensible moisture readings

sensible moisture readings

--- plantstation.ino
+++ plantstation.ino
@@ -50,8 +50,8 @@

 //===== For moisture readings ====================
 // todo - find right value for these
-const int moistureMaxVal = 453;
-const int moistureMinVal = 799;
+const int moistureMaxVal = 255;
+const int moistureMinVal = 878;
 int moistureThreshold = 1000; // <- made this up

 //===== For water level sensor ===================
@@ -70,12 +70,12 @@
 //===== For water pump ===========================
 const byte waterPumpPin = A3;
 // todo - find right value for this
-const int waterLevelThreshold = 300; // <- made this up
+const int waterLevelThreshold = 300; // <- made this up
 boolean waterPumpIsOn = false;
 unsigned long wateringSeconds = 61000;
 unsigned long prevWatering = 0;
 int waterMaxVal = 369;
-int waterMinVal = 123;
+int waterMinVal = 110;

 //===== For timed events =========================
 // todo - timed events use regule marers for 1 min 1 hour etc and divide blah
@@ -179,7 +179,7 @@

 void readMoistureSensor() {
   moistureSensorVal = analogRead(hygroPin);
-  moisturePercent = map(moistureSensorVal, moistureMinVal, moistureMaxVal, 0, 100);
+  moisturePercent = reversemap(moistureSensorVal, moistureMinVal, moistureMaxVal, 0, 100);
 }

 void readWaterLevelSensor() {
@@ -310,3 +310,21 @@
   Console.println(my_output);
 }

+long reversemap(long x, long in_min, long in_max, long out_min, long out_max)
+{
+  return (in_min - x) * out_max / (in_min - in_max);
+}
+
+/*
+const int moistureMaxVal = 453;
+const int moistureMinVal = 799;
+range = 346 (.5 = 173)
+626
+
+173
+346
+
+799 ------------------------626 ------------------------ 453
+  0 ------------------------ 50 ------------------------ 100
+
+*/


Faster maxPulse

Faster maxPulse

Signed-off-by: Mark Knoop <f1b5a91d4d6ad523f2610114591c007e75d15084@markknoop.com>

--- src/sketch.ino
+++ src/sketch.ino
@@ -13,7 +13,7 @@
 #define decelDiff      10 // shorten decel to be sure of finding sensor
 #define halfTurnSteps 200 // steps for a half turn
 #define minPulse      500
-#define maxPulse     2500
+#define maxPulse     2300
 #define durationGlissCompensation 480

 /*************************


adding pixel counts for the two cores I have

--- firmware/spark-neopixel-control.ino
+++ firmware/spark-neopixel-control.ino
@@ -5,7 +5,8 @@
 //the pin your spark is using to control neopixels
 #define PIXEL_PIN D2
 //the number of pixels you are controlling
-#define PIXEL_COUNT 150
+#define PIXEL_COUNT 467 //giggle
+//#define PIXEL_COUNT 150 //colossus
 //the neopixel chip type
 #define PIXEL_TYPE WS2812B


Use UNKNOWN instead of -1 (#590)

Use UNKNOWN instead of -1 (#590)

Minor code cleanup.

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -1278,7 +1278,7 @@
 #if REPORT_UNKNOWNS
   if (irrecv.decode(&capture)) {
 #else
-  if (irrecv.decode(&capture) && capture.decode_type != -1) {
+  if (irrecv.decode(&capture) && capture.decode_type != UNKNOWN) {
 #endif  // REPORT_UNKNOWNS
     lastIrReceivedTime = millis();
     lastIrReceived = String(capture.decode_type) + "," +


Allow CosaVWIkey to work on all variants.

--- examples/VWI/CosaVWIkey/CosaVWIkey.ino
+++ examples/VWI/CosaVWIkey/CosaVWIkey.ino
@@ -57,8 +57,13 @@
 #endif
 const uint16_t SPEED = 4000;

-// Connect button with pullup to EXT0/D2
+// Connect button with pullup to Arduino Mega EXT2/D19
+#if defined(__ARDUINO_MEGA__)
+ExternalInterruptPin wakeup(Board::EXT2, ExternalInterruptPin::ON_LOW_LEVEL_MODE);
+// others to Arduino EXT0; Mighty/D10, TinyX4/D10, Standard and TinyX5/D2.
+#else
 ExternalInterruptPin wakeup(Board::EXT0, ExternalInterruptPin::ON_LOW_LEVEL_MODE);
+#endif

 // Analog pins to sample for values to send
 AnalogPin luminance(Board::A2);


Typo Correction

Typo Correction

--- NRF24L01/Mask/NRF24L01-Mask.ino
+++ NRF24L01/Mask/NRF24L01-Mask.ino
@@ -291,7 +291,7 @@
     {
     FaceMode='N';
     }
-    else if(textstring == "O") // Draw Face0223
+    else if(textstring == "O") // Draw Face023
     {
     FaceMode='O';
     }


skull

skull

--- firmware/http-neopixel-skull/skull.ino
+++ firmware/http-neopixel-skull/skull.ino
@@ -3,7 +3,7 @@
 #include "led-strip-particles.h"

 //the pin your spark is using to control neopixels
-#define PIXEL_PIN D2
+#define PIXEL_PIN D2
 //the number of pixels you are controlling
 #define PIXEL_COUNT 168

@@ -12,7 +12,7 @@
 //pixels 155-158 = small skull 2
 //pixels 159-162 = big skull bottom
 //pixels 163-165 = left eye
-//pixels 166-168 = right eye
+//pixels 166-168 = right eye pix

 //the neopixel chip type
 #define PIXEL_TYPE WS2812B


low battery check now only uses time to decide whether or not voice the message

--- Arduino_codeline/fairytale23/fairytale23.ino
+++ Arduino_codeline/fairytale23/fairytale23.ino
@@ -445,7 +445,7 @@
   const byte lowBatPin      = A2;      // pin on which the Adafruit PowerBoost will indicate a low battery
                                        // this pin will usually be pulled high but when the charger detects
                                        // a low voltage (under 3.2V) the pin will drop down to 0V (LOW)
-  boolean lowBatWarn        = true;    // used to throttle low battery messages to every 5 minutes
+  unsigned long lowBatCheckTime = 0;   // used to throttle low battery messages to every 5 minutes
 #endif

@@ -733,14 +733,14 @@
   } // end of tag is present

   delay(1000); // throttle the loop for 1 second
+
   // check if the battery is still good
   #ifdef LOWBAT
     if (digitalRead(lowBatPin == LOW)) {
-      if (lowBatWarn && (millis()-lightStartUpTime > 300000)) {
+      if ((millis()-lowBatCheckTime > 300000)) {
         digitalWrite(errorLedPin, HIGH);
         issueWarning("BATTERY LOW", "/system00/lowbat01.mp3", true);
-        lowBatWarn = false;
-        lightStartUpTime = millis();
+        lowBatCheckTime = millis();
       }
     }
   #endif
@@ -959,7 +959,6 @@
         }
       #endif

-      // TODO: check if this really works this way
       // check if the battery is still good
       #ifdef LOWBAT
         if (digitalRead(lowBatPin == LOW)) digitalWrite(errorLedPin, HIGH);


First version where all sensors are working together


Reduce number of int. sent to 6

Reduce number of int. sent to 6

--- RadioReceiver/RadioReceiver.ino
+++ RadioReceiver/RadioReceiver.ino
@@ -10,7 +10,7 @@

 #include <VirtualWire.h>
 int receive_pin = 2;
-int numbers[10]; // Change 3 to number of integers you wish to send.
+int numbers[6]; // Change 3 to number of integers you wish to send.

 void setup()
 {
@@ -33,15 +33,45 @@

   if (vw_get_message(buf, &buflen)) // check to see if anything has been received
   {
-    for (int i = 0; i < 10; i++)
+    for (int i = 0; i < 6; i++)
     {
       numbers[i] = word(buf[i*2+1], buf[i*2]);
       //Serial.print("numbers[");
       //Serial.print(i, DEC);
       //Serial.print("]=");
       //Serial.print(numbers[i], DEC);
+
+      if (i == 0)
+      {
+        Serial.print("Sensor ID = ");
+      }
+
+      if (i == 1)
+      {
+        Serial.print("Light = ");
+      }
+
+      if (i == 2)
+      {
+        Serial.print("Temp = ");
+      }
+
+      if (i == 3)
+      {
+        Serial.print("Random 1 = ");
+      }
+
+      if (i == 4)
+      {
+        Serial.print("Random 2 = ");
+      }
+
+      if (i == 5)
+      {
+        Serial.print("Count = ");
+      }
+
       Serial.println(numbers[i], DEC);
-      //Serial.print("  ");
     }
     Serial.println();
   }


Add BrightWheel

Add BrightWheel

Use BrightWheel for selecting colors from a palette. It uses maximum
luminocity for every color.

Use SmoothWheel for color fades. It uses a more consistant luminocity
for every color.

--- Receiver_test/Receiver_test.ino
+++ Receiver_test/Receiver_test.ino
@@ -159,7 +159,7 @@
       case 2:  // rainbow rotating around
         n = (addr-1) * 16;
         while(!done){
-          setLantern(Wheel((64 + n) & 255));
+          setLantern(SmoothWheel((64 + n) & 255));
           delay(rate);
           n++;
           done = process_msg();
@@ -182,7 +182,7 @@

 // Input a value 0 to 255 to get a color value.
 // The colours are a transition r - g - b - back to r.
-uint32_t Wheel(byte WheelPos){
+uint32_t SmoothWheel(byte WheelPos){
   WheelPos = 255 - WheelPos;
   if(WheelPos < 85){
     return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
@@ -192,6 +192,27 @@
   }else{
     WheelPos -= 170;
     return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
+  }
+}
+
+uint32_t BrightWheel(byte WheelPos){
+  // 6 phases for each color
+  //     fades in for 1 cycle
+  //     stays for 2 cycles
+  //     fades out for 1 cycle
+  //     stays out for 2 cycles
+  if(WheelPos < 43){
+    return strip.Color(255, WheelPos * 6, 0);
+  }else if(43 <= WheelPos && WheelPos < 85){
+    return strip.Color(255 - (WheelPos - 43) * 6, 255, 0);
+  }else if(85 <= WheelPos && WheelPos < 128){
+    return strip.Color(0, 255, (WheelPos - 85) * 6);
+  }else if(128 <= WheelPos && WheelPos < 170){
+    return strip.Color(0, 255 - (WheelPos - 128) * 6, 255);
+  }else if(170 <= WheelPos && WheelPos < 213){
+    return strip.Color((WheelPos - 170) * 6, 0, 255);
+  }else{
+    return strip.Color(255, 0, 255 - (WheelPos - 213) * 6);
   }
 }


Disable memorylogging.

Disable memorylogging.

--- aquacontrol2.ino
+++ aquacontrol2.ino
@@ -35,7 +35,7 @@
 String lightStatus; //To keep track if lights are on, off or programmed, this string is displayed on the webif

 //Serial logging switches
-bool memoryLogging = true;
+bool memoryLogging = false;
 bool channelLogging = false; //logging of percentage % values over Serial. Useful when debugging unrelated stuff and a uncluttered screen

 //channel setup


0.7.17 hot fix 2

0.7.17 hot fix 2

Hardware issue

--- Device_LinkItOne/LASS_WEB/LASS_WEB.ino
+++ Device_LinkItOne/LASS_WEB/LASS_WEB.ino
@@ -2118,7 +2118,12 @@

   //Web Setup Server
   pinMode(INPUT_PULLUP,13);
-  if(!setting_load() || digitalRead(13) == 1){
+  boolean isHigh=false;
+  for(int i=0;i<=10;i++){
+     if(digitalRead(13)==1) isHigh=true;
+     delay(50);
+  }
+  if(!setting_load() || isHigh){
     setting_init();
     setting_save();
     LWiFiEncryption wifi_auth;


make center LED mirror patterns for rainbow

--- src/blinky.ino
+++ src/blinky.ino
@@ -110,6 +110,12 @@
     rgb = HsvToRgb(hsv);
     (*strip).setPixelColor(i, rgb.r, rgb.g, rgb.b);
   }
+
+  // set the center pixel to mirror what pixel 0 is
+  hsv = HsvColor(base_hue+offset, HSV_SATURATION, HSV_BRIGHTNESS);
+  rgb = HsvToRgb(hsv);
+  RGB.color(rgb.r, rgb.g, rgb.b);
+
   base_hue += HUE_STEP;
   (*strip).show();
 }
@@ -121,6 +127,9 @@
   for (int i = 0 ; i < PIXEL_COUNT ; ++i){
     (*strip).setPixelColor(i, rgb.r, rgb.g, rgb.b);
   }
+  // set the center pixel to mirror what pixel 0 is
+  RGB.color(rgb.r, rgb.g, rgb.b);
+
   base_hue += HUE_STEP;
   (*strip).show();
 }


Changing %i to %u for the unsigned int lastWatts

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -380,7 +380,7 @@
 {
   IPAddress ip XS1_IP;
   char url[100];
-  sprintf(url, "%s%i", XS1_URL, lastWatts);
+  sprintf(url, "%s%u", XS1_URL, lastWatts);

   if (networkRequestIP(ip, url))
   {


Fixed Arduino Code

Fixed Arduino Code

--- ArduinoCode/RObhat_motor_controller_v2/RObhat_motor_controller_v2.ino
+++ ArduinoCode/RObhat_motor_controller_v2/RObhat_motor_controller_v2.ino
@@ -1,5 +1,5 @@
 #include <Arduino.h>
-#include <stdio.h>
+// #include <stdio.h>

 const int motorAF_neutral = 9; // motor circuit is connected to pin 5
 const int motorAF_hot = 8;
@@ -124,17 +124,18 @@

         // Below this is turning on output  based on push buttons
         bool * buttonState = getButtons();
-        // for (int i = 0; i < 4; i++) {
-        //         Serial.print("Button ");
-        //         Serial.print(buttonLabels[i]);
-        //         Serial.print(":\t ");
-        //         Serial.println(!buttonState[i]);
-        // }
+        for (int i = 0; i < 4; i++) {
+                Serial.print("Button ");
+                Serial.print(buttonLabels[i]);
+                Serial.print(":\t ");
+                Serial.println(!buttonState[i]);
+        }

         // Serial monitor
-        // if (Serial.available())
+        if (Serial.available())
         {
-                String serialText = Serial.readStringUntil('&'); // reads incoming data from the serial port
+                String serialText =
+                        Serial.readStringUntil('&'); // reads incoming data from the serial port
                 if (serialText == "onAF") { // turn on A
                         // motorOn("A", "F");
                         buttonState[0] = LOW;


Add sustain at start and end of durationgliss

Signed-off-by: Mark Knoop <f1b5a91d4d6ad523f2610114591c007e75d15084@markknoop.com>

--- src/sketch.ino
+++ src/sketch.ino
@@ -82,7 +82,7 @@
     halfTurns = 1;
     duration = 500;
     midDuration = 500;
-    sustainDuration = 180;
+    sustainDuration = 50;
     startPitch = 72;
     midPitch = 48;
     endPitch = 60;
@@ -233,29 +233,38 @@
 }

 long _durationgliss(int duration, float startpitch, float endpitch, bool dir,
-        bool recentre, bool accel, bool decel, int sustain) {
+        bool recentre, bool accel, bool decel, int sustainstart, int sustainend) {
     int startpulse = pitchToPulse(startpitch);
     int endpulse = pitchToPulse(endpitch);
     int accelsteps = accelSteps * accel;
     int decelsteps = accelSteps * decel;
-    unsigned long glissTime = (duration * 1000L) -
+    unsigned long glissTime = ((duration - sustainstart) * 1000L) -
         (((max(maxPulse, startpulse) + startpulse) * (accelsteps / 2)) +
          ((endpulse + max(maxPulse, endpulse)) * (decelsteps / 2)));
     glissTime = max(0, (glissTime * durationGlissMult) - (durationGlissDiff * 1000L));
     int glisssteps = glissTime / ((startpulse + endpulse) / 2);
-    int sustainsteps = (sustain * 1000L) / endpulse;
+    int sustainstartsteps = (sustainstart * 1000L) / startpulse;
+    int sustainendsteps = (sustainend * 1000L) / endpulse;
     digitalWrite(LED_BUILTIN, HIGH);
     digitalWrite(dirPin, dir);
     delayMicroseconds(pulseWidth);
+    // accelerando
     for (int i=0; i<accelsteps; i++) {
         onestep(map(i, 0, accelsteps, max(maxPulse, startpulse), startpulse));
     }
+    // sustain start
+    for (int i=0; i<sustainstartsteps; i++) {
+        onestep(map(i, 0, sustainstartsteps, startpulse, startpulse));
+    }
+    // glissando
     for (int i=0; i<glisssteps; i++) {
         onestep(map(i, 0, glisssteps, startpulse, endpulse));
     }
-    for (int i=0; i<sustainsteps; i++) {
-        onestep(map(i, 0, sustainsteps, endpulse, endpulse));
-    }
+    // sustain end
+    for (int i=0; i<sustainendsteps; i++) {
+        onestep(map(i, 0, sustainendsteps, endpulse, endpulse));
+    }
+    // decelerando
     for (int i=0; i<decelsteps; i++) {
         onestep(map(i, 0, decelsteps, endpulse, max(maxPulse, endpulse)));
     }
@@ -267,16 +276,16 @@
 long durationgliss(int duration, float startpitch, float endpitch, bool dir,
         bool recentre, int sustain) {
     return _durationgliss(duration, startpitch, endpitch,
-            dir, recentre, true, true, sustain);
+            dir, recentre, true, true, sustain, sustain);
 }

 long doublegliss(int durationone, int durationtwo, float startpitch,
         float midpitch, float endpitch, bool dir, bool recentre, int sustain) {
     long glissTime;
     glissTime = _durationgliss(durationone, startpitch, midpitch,
-            dir, false, true, false, 0);
+            dir, false, true, false, sustain, 0);
     glissTime += _durationgliss(durationtwo, midpitch, endpitch,
-            dir, recentre, false, true, sustain);
+            dir, recentre, false, true, sustain, sustain);
     return glissTime;
 }

@@ -425,7 +434,9 @@
         Serial.print("direction ");
         Serial.print(dir, BIN);
         Serial.print(", recentre ");
-        Serial.println(recentre, BIN);
+        Serial.print(recentre, BIN);
+        Serial.print(", sustain ");
+        Serial.println(sustainDuration, BIN);
     } else {
         // show test styles
         Serial.println("203: 0xcb: turn");
@@ -525,4 +536,10 @@
 void loop() {
     receivedata();
     if (newData) processdata();
-}
+    /* DEBUG gliss code
+    durationgliss(500, 60, 70, true, false, 50);
+    delay(5000);
+    doublegliss(500, 500, 60, 72, 61, true, false, 50);
+    delay(5000);
+    */
+}


Thruster controller communicates with thruster boards.

--- riptide_serial/firmware/thruster_control_sketch/thruster_control_sketch.ino
+++ riptide_serial/firmware/thruster_control_sketch/thruster_control_sketch.ino
@@ -1,46 +1,107 @@
 #include <Wire.h>

 #include <ros.h>
-#include <std_msgs/Int8.h>
+#include <riptide_msgs/PwmStamped.h>

 ros::NodeHandle nh;

-std_msgs::Int8 state;
+riptide_msgs::Pwm checksum;

-ros::Publisher state_pub("state", &state);
+ros::Publisher state_pub("checksum", &checksum);

-void callback(const std_msgs::Int8 &cmd)
+void callback(const riptide_msgs::PwmStamped &cmd)
 {
-  state.data = cmd.data;
-  state_pub.publish(&state);
+  checksum.f1 = -512;
+  checksum.f2 = -512;
+  checksum.f3 = -512;
+  checksum.f4 = -512;
+  checksum.u1 = -512;
+  checksum.u2 = -512;
+  checksum.u3 = -512;
+  checksum.u4 = -512;
+  checksum.s1 = -512;
+  checksum.s2 = -512;

-  Wire.beginTransmission(3);
-  Wire.write(0x10);
-  Wire.write(0x10);
-  Wire.write(0x10);
+  Wire.beginTransmission(1);
+  Wire.write(cmd.pwm.f2>>8); //port
+  Wire.write(cmd.pwm.f2 %256);
+  Wire.write(cmd.pwm.f1>>8);
+  Wire.write(cmd.pwm.f1%256);
   Wire.endTransmission();

-  delay(5);
+  Wire.requestFrom(1, 1);
+  checksum.f2  = Wire.read();
+  checksum.f1 = checksum.f2;

-  Wire.beginTransmission(3);
-  Wire.write(0x20);
-  Wire.write(0x20);
-  Wire.write(0x20);
+  Wire.beginTransmission(2);
+  Wire.write(cmd.pwm.f3>>8);
+  Wire.write(cmd.pwm.f3%256);
+  Wire.write(cmd.pwm.f4>>8);
+  Wire.write(cmd.pwm.f4%256);
   Wire.endTransmission();

-  delay(5);
+  Wire.requestFrom(2, 1);
+  checksum.f3  = Wire.read();
+  checksum.f4 = checksum.f3;

-  Wire.requestFrom(0x10, 4);
+  Wire.beginTransmission(4);
+  Wire.write(cmd.pwm.s1>>8);
+  Wire.write(cmd.pwm.s1%256);
+  Wire.write(cmd.pwm.s2>>8);
+  Wire.write(cmd.pwm.s2%256);
+  Wire.endTransmission();

-  while(Wire.available())
-  {
-    char c = Wire.read();
-    state.data = c;
-    state_pub.publish(&state);
-  }
+  Wire.requestFrom(4, 1);
+  checksum.s1  = Wire.read();
+  checksum.s2 = checksum.s1;
+
+  Wire.beginTransmission(8);
+  Wire.write(cmd.pwm.u4>>8);
+  Wire.write(cmd.pwm.u4%256);
+  Wire.write(cmd.pwm.u3>>8);
+  Wire.write(cmd.pwm.u3%256);
+  Wire.endTransmission();
+
+  Wire.requestFrom(8, 1);
+  checksum.u4  = Wire.read();
+  checksum.u3 = checksum.u4;
+
+  Wire.beginTransmission(16);
+  Wire.write(cmd.pwm.u1>>8);
+  Wire.write(cmd.pwm.u1%256);
+  Wire.write(cmd.pwm.u2>>8);
+  Wire.write(cmd.pwm.u2%256);
+  Wire.endTransmission();
+
+  Wire.requestFrom(16, 100);
+  checksum.u1  = Wire.read();
+  checksum.u2 = checksum.u1;
+
+  state_pub.publish(&checksum);
+  if(cmd.pwm.f1 != 1500) { digitalWrite(2, HIGH); }
+  else {digitalWrite(2, LOW); }
+  if(cmd.pwm.f2 != 1500) { digitalWrite(3, HIGH); }
+  else {digitalWrite(3, LOW); }
+  if(cmd.pwm.f3 != 1500) { digitalWrite(4, HIGH); }
+  else {digitalWrite(4, LOW); }
+  if(cmd.pwm.f4 != 1500) { digitalWrite(5, HIGH); }
+  else {digitalWrite(5, LOW); }
+  if(cmd.pwm.u1 != 1500) { digitalWrite(6, HIGH); }
+  else {digitalWrite(6, LOW); }
+  if(cmd.pwm.u2 != 1500) { digitalWrite(7, HIGH); }
+  else {digitalWrite(7, LOW); }
+  if(cmd.pwm.u3 != 1500) { digitalWrite(8, HIGH); }
+  else {digitalWrite(8, LOW); }
+  if(cmd.pwm.u4 != 1500) { digitalWrite(9, HIGH); }
+  else {digitalWrite(9, LOW); }
+  if(cmd.pwm.s1 != 1500) { digitalWrite(10, HIGH); }
+  else {digitalWrite(10, LOW); }
+  if(cmd.pwm.s2 != 1500) { digitalWrite(11, HIGH); }
+  else {digitalWrite(11, LOW); }
+
 }

-ros::Subscriber<std_msgs::Int8> cmd_sub("command", &callback);
+ros::Subscriber<riptide_msgs::PwmStamped> cmd_sub("thrust_cal/pwm", &callback);

 void setup()
 {
@@ -49,10 +110,24 @@
   nh.initNode();
   nh.advertise(state_pub);
   nh.subscribe(cmd_sub);
+
+  pinMode(2, OUTPUT);
+  pinMode(3, OUTPUT);
+  pinMode(4, OUTPUT);
+  pinMode(5, OUTPUT);
+  pinMode(6, OUTPUT);
+  pinMode(7, OUTPUT);
+  pinMode(8, OUTPUT);
+  pinMode(9, OUTPUT);
+  pinMode(10, OUTPUT);
+  pinMode(11, OUTPUT);
+
+
+
 }

 void loop()
-{
+{
   nh.spinOnce();

   delay(33);


update example

update example

--- examples/Teensy3ArtNetSACN2Universes_rdm/Teensy3ArtNetSACN2Universes_rdm.ino
+++ examples/Teensy3ArtNetSACN2Universes_rdm/Teensy3ArtNetSACN2Universes_rdm.ino
@@ -66,9 +66,18 @@
 // RDM defines
 #define DISC_STATE_SEARCH 0
 #define DISC_STATE_TBL_CK 1
+/*
+ * If RDM_DISCOVER_ALWAYS == 0, the times RDM discovery runs is limited to 10 cycles
+ * of table check and search.  When rdm_discovery_enable reaches zero, continous RDM
+ * discovery stops.  Other ArtRDM packets continue to be relayed.
+ * If an Art-Net TODRequest or TODControl packet is received, the rdm_discovery_enable
+ * counter is reset and discovery runs again until rdm_discovery_enable reaches zero.
+ */
+#define RDM_DISCOVER_ALWAYS 0

 // RDM globals
 uint8_t rdm_enabled = 1;
+uint8_t rdm_discovery_enable = 10;				// limit RDM discovery which can cause flicker in some equipment
 uint8_t discovery_state = DISC_STATE_TBL_CK;
 uint8_t discovery_tbl_ck_index = 0;
 uint8_t tableChangedFlag = 0;
@@ -107,8 +116,6 @@

 uint8_t led_state = 0;
 uint8_t led_state2 = 0;
-// used to toggle stored scene on and off
-uint8_t scene_state = 0;

 void blinkLED() {
   if ( led_state ) {
@@ -134,6 +141,7 @@
   if ( type[0] ) {
     tableOfDevices.reset();
   }
+  rdm_discovery_enable = 10;
   artNetInterface->send_art_tod(&aUDP, tableOfDevices.rawBytes(), tableOfDevices.count());
 }

@@ -154,10 +162,10 @@
 }

 void artCmdReceived(uint8_t* pdata) {
-  if ( strcmp((const char*)pdata, "record=1") == 0 ) {
-    //rememberScene();
-  }
-
+  if ( strcmp((const char*)pdata, "clearSACN") == 0 ) {
+    sACNInterface->clearDMXOutput();
+    sACNInterfaceUniverse2->clearDMXOutput();
+  }
 }

 /************************************************************************/
@@ -254,38 +262,46 @@
   return 0;     // none left to pop
 }

+void sendTODifChanged() {
+  if ( tableChangedFlag ) {   //if the table has changed...
+    tableChangedFlag--;
+
+    artNetInterface->send_art_tod(&aUDP, tableOfDevices.rawBytes(), tableOfDevices.count());
+#if defined PRINT_DEBUG_MESSAGES
+    Serial.println("_______________ Table Of Devices _______________");
+    tableOfDevices.printTOD();
+#endif
+  }
+}
+
 void updateRDMDiscovery() {
-  if ( discovery_state ) {
-    // check the table of devices#if defined PRINT_DEBUG_MESSAGES
-
-    discovery_tbl_ck_index = checkTable(discovery_tbl_ck_index);
-
-    if ( discovery_tbl_ck_index == 0 ) {
-      // done with table check
-      discovery_state = DISC_STATE_SEARCH;
-      pushInitialBranch();
+  	if ( rdm_discovery_enable ) {  // run RDM updates for a limited number of times
+	  if ( discovery_state ) {
+		// check the table of devices#if defined PRINT_DEBUG_MESSAGES
+
+		discovery_tbl_ck_index = checkTable(discovery_tbl_ck_index);
+
+		if ( discovery_tbl_ck_index == 0 ) {
+		  // done with table check
+		  discovery_state = DISC_STATE_SEARCH;
+		  pushInitialBranch();

-      if ( tableChangedFlag ) {   //if the table has changed...
-        tableChangedFlag = 0;
-
-        artNetInterface->send_art_tod(&aUDP, tableOfDevices.rawBytes(), tableOfDevices.count());
-        // if this were an Art-Net application, you would send an
-        // ArtTOD packet here, because the device table has changed.
-        // for this test, we just print the list of devices
-#if defined PRINT_DEBUG_MESSAGES
-        Serial.println("_______________ Table Of Devices _______________");
-        tableOfDevices.printTOD();
-#endif
-      }
-    } //end table check ended
-  } else {    // search for devices in range popped from discoveryTree
-
-    if ( checkNextRange() == 0 ) {
-      // done with search
-      discovery_tbl_ck_index = 0;
-      discovery_state = DISC_STATE_TBL_CK;
-    }
-  }           //end search
+		  sendTODifChanged();
+		} //end table check ended
+	  } else {    // search for devices in range popped from discoveryTree
+
+		if ( checkNextRange() == 0 ) {
+		  // done with search
+		  discovery_tbl_ck_index = 0;
+		  discovery_state = DISC_STATE_TBL_CK;
+
+		  sendTODifChanged();
+		  if ( RDM_DISCOVER_ALWAYS == 0 ) {
+		     rdm_discovery_enable--;
+		  }
+		}
+	  }           //end search
+  }               //end rdm_discovery_enable
 }

@@ -317,8 +333,8 @@
   Ethernet.begin(mac);

   // Initialize Interfaces
-  uint8_t interface1univ = 1;
-  uint8_t interface2univ = 0;
+  uint8_t interface1univ = 0;
+  uint8_t interface2univ = 1;
   sACNInterface = new LXSACN(sACNBuffer);
   sACNInterface->enableHTP();
   sACNInterface->setUniverse(interface1univ+1);
@@ -354,8 +370,8 @@

 // multicast requires modificaton of Ethernet library.  see LXDMXEthernet.h
 #if defined ( use_multicast )
-  sUDP.beginMulticast(IPAddress(239,255,0,1), sACNInterface->dmxPort());
-  tUDP.beginMulticast(IPAddress(239,255,0,2), sACNInterface->dmxPort());
+  sUDP.beginMulticast(IPAddress(239,255,0,(interface1univ+1)), sACNInterface->dmxPort());
+  tUDP.beginMulticast(IPAddress(239,255,0,(interface2univ+1)), sACNInterface->dmxPort());
 #else
   sUDP.begin(sACNInterface->dmxPort());
 #endif
@@ -406,7 +422,6 @@
         Teensy3DMX.setSlot(i , s);
       }
    }
-   scene_state = 0;
 }

 void copyDMX2ToOutput(void) {
@@ -443,58 +458,60 @@
 *************************************************************************/

 void loop() {
+
   read_result_artnet1 = RESULT_NONE;
   read_result_artnet2 = RESULT_NONE;
   read_result_sacn1 = RESULT_NONE;
   read_result_sacn2 = RESULT_NONE;
-
+
   packetSize = aUDP.parsePacket();
   if ( packetSize ) {
-  	packetSize = aUDP.read(artnetBuffer, ARTNET_BUFFER_MAX);
+	packetSize = aUDP.read(artnetBuffer, ARTNET_BUFFER_MAX);
 	  read_result_artnet1 = artNetInterface->readDMXPacketContents(&aUDP, packetSize);
 	  if ( read_result_artnet1 == RESULT_NONE ) {				// if not good_dmx or otherwise handled, try 2nd universe
-      read_result_artnet2 = artNetInterfaceUniverse2->readDMXPacketContents(&aUDP, packetSize);
+	  read_result_artnet2 = artNetInterfaceUniverse2->readDMXPacketContents(&aUDP, packetSize);
 	  }
   }
-
+
 #if defined ( use_multicast )
   packetSize = sUDP.parsePacket();
   if ( packetSize ) {
-    packetSize = sUDP.read(sACNBuffer, SACN_BUFFER_MAX);
-  	read_result_sacn1 = sACNInterface->readDMXPacketContents(&sUDP, packetSize);
+	  packetSize = sUDP.read(sACNBuffer, SACN_BUFFER_MAX);
+	  read_result_sacn1 = sACNInterface->readDMXPacketContents(&sUDP, packetSize);
   }
   // read packet from 2nd multicast address
   packetSize = tUDP.parsePacket();
   if ( packetSize ) {
-    packetSize = tUDP.read(sACNBuffer, SACN_BUFFER_MAX);
-    read_result_sacn2 = sACNInterfaceUniverse2->readDMXPacketContents(&tUDP, packetSize);
+	  packetSize = tUDP.read(sACNBuffer, SACN_BUFFER_MAX);
+	  read_result_sacn2 = sACNInterfaceUniverse2->readDMXPacketContents(&tUDP, packetSize);
   }
 #else
   //assume sender unicasts both universes to same IP address
   packetSize = sUDP.parsePacket();
   if ( packetSize ) {
-    packetSize = sUDP.read(sACNBuffer, SACN_BUFFER_MAX);
-    read_result_sacn1 = sACNInterface->readDMXPacketContents(&sUDP, packetSize);
-    if ( read_result_sacn1 == RESULT_NONE ) {       // if not good_dmx or otherwise handled, try 2nd universe
-      read_result_sacn2 = sACNInterfaceUniverse2->readDMXPacketContents(&sUDP, packetSize);
-    }   // was not dmx first universe
+	  packetSize = sUDP.read(sACNBuffer, SACN_BUFFER_MAX);
+	  read_result_sacn1 = sACNInterface->readDMXPacketContents(&sUDP, packetSize);
+	if ( read_result_sacn1 == RESULT_NONE ) {       // if not good_dmx or otherwise handled, try 2nd universe
+	  read_result_sacn2 = sACNInterfaceUniverse2->readDMXPacketContents(&sUDP, packetSize);
+	}   // was not dmx first universe
   }     // no packetSize
 #endif

   if ((read_result_artnet1 == RESULT_DMX_RECEIVED) || (read_result_sacn1 == RESULT_DMX_RECEIVED)) {
-    copyDMX1ToOutput();
-    blinkLED();
+	  copyDMX1ToOutput();
+	  blinkLED();
   } else if ( rdm_enabled ) {
-  	updateRDMDiscovery();
+	  updateRDMDiscovery();
   }
   if ((read_result_artnet2 == RESULT_DMX_RECEIVED) || (read_result_sacn2 == RESULT_DMX_RECEIVED)) {
-    copyDMX2ToOutput();
-    blinkLED2();
+	  copyDMX2ToOutput();
+	  blinkLED2();
   }

   uint8_t dhcpr = Ethernet.maintain();
   if (( dhcpr == 4 ) || (dhcpr == 2)) {	//renew/rebind success, update ArtPollReply
-  	artNetInterface->setLocalIP(Ethernet.localIP(), Ethernet.subnetMask());
-  	artNetInterfaceUniverse2->setLocalIP(Ethernet.localIP(), Ethernet.subnetMask());
-  }
+	  artNetInterface->setLocalIP(Ethernet.localIP(), Ethernet.subnetMask());
+	  artNetInterfaceUniverse2->setLocalIP(Ethernet.localIP(), Ethernet.subnetMask());
+  }
+
 } //loop()


Delete walkingBot.ino

Delete walkingBot.ino

--- walkingBot.ino
+++ walkingBot.ino
@@ -1,141 +0,0 @@
-// MPU-6050 Short Example Sketch
-// By Arduino User JohnChi
-// August 17, 2014
-// Public Domain
-#include<Wire.h>
-#include <Servo.h>
-
-const int MPU_addr=0x68;  // I2C address of the MPU-6050
-int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
-int16_t offset_gx, offset_gy, offset_gz;
-double ax, ay, az;
-double gx, gy, gz;
-
-Servo s1;
-Servo s2;
-Servo s3;
-Servo s4;
-int angle1 = 90;
-int angle2 = 80;
-int angle3 = 90;
-int angle4 = 90;
-
-void setup(){
-  //  Initialize servomotors
-  s1.attach(3); //  angle == 75 is the middle (vertical) but not accessible
-  s2.attach(5);
-  s3.attach(6);
-  s4.attach(9);
-  s1.write(angle1);
-  s2.write(angle2);
-  s3.write(angle3);
-  s4.write(angle4);
-
-  //  Initialize transmission
-  Wire.begin();
-  Wire.beginTransmission(MPU_addr);
-  Wire.write(0x6B);  // PWR_MGMT_1 register
-  Wire.write(0);     // set to zero (wakes up the MPU-6050)
-  Wire.endTransmission(true);
-  Serial.begin(9600);
-
-  //  Initialize gyroscope offsets
-  offset_gx = 0; offset_gy = 0; offset_gz = 0;
-  int NB_DATA_INIT_GYRO_OFFSET = 10;
-  for(int i=0; i<NB_DATA_INIT_GYRO_OFFSET; i++)
-  {
-    Wire.beginTransmission(MPU_addr);
-    Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
-    Wire.endTransmission(false);
-    Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
-    AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
-    AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
-    AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
-    Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
-    GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
-    GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
-    GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
-
-    offset_gx += GyX;
-    offset_gy += GyY;
-    offset_gz += GyZ;
-  }
-  offset_gx = (int16_t)(double(offset_gx)/NB_DATA_INIT_GYRO_OFFSET);
-  offset_gy = (int16_t)(double(offset_gy)/NB_DATA_INIT_GYRO_OFFSET);
-  offset_gz = (int16_t)(double(offset_gz)/NB_DATA_INIT_GYRO_OFFSET);
-}
-
-void loop(){
-  Wire.beginTransmission(MPU_addr);
-  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
-  Wire.endTransmission(false);
-  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
-  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
-  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
-  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
-  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
-  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
-  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
-  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
-  /*Serial.print("AcX = "); Serial.print(AcX);
-  Serial.print(" | AcY = "); Serial.print(AcY);
-  Serial.print(" | AcZ = "); Serial.print(AcZ);
-  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
-  Serial.print(" | GyX = "); Serial.print(GyX);
-  Serial.print(" | GyY = "); Serial.print(GyY);
-  Serial.print(" | GyZ = "); Serial.println(GyZ);*/
-
-  //  Convert raw data into appropriate values
-  ax = double(AcX)/16384;
-  ay = double(AcY)/16384;
-  az = double(AcZ)/16384;
-  gx = double(GyX-offset_gx)/131;
-  gy = double(GyY-offset_gy)/131;
-  gz = double(GyZ-offset_gz)/131;
-  Serial.print("ax = "); Serial.print(ax);
-  Serial.print(" | ay = "); Serial.print(ay);
-  Serial.print(" | az = "); Serial.print(az);
-  Serial.print(" | gx = "); Serial.print(gx);
-  Serial.print(" | gy = "); Serial.print(gy);
-  Serial.print(" | gz = "); Serial.println(gz);
-
-  //  test servomotor n°1 & 2 1:
-  Serial.println("90");
-  s1.write(90);
-  delay(1000);
-  Serial.println("100");
-  s1.write(100);
-  Serial.println("105");
-  s1.write(105);
-
-  /*Serial.println("60");
-  s2.write(60);
-  delay(1000);
-  Serial.println("80");
-  s2.write(80);
-  delay(1000);
-  Serial.println("100");
-  s2.write(100);
-  delay(1000);*/
-
-  //  test servomotor n°3 & 4 3: 90+++
-  Serial.println("70");
-  s3.write(90);
-  Serial.println("90");
-  s3.write(90);
-  delay(1000);
-  Serial.println("130");
-  s3.write(110);
-  delay(1000);
-
-  /*Serial.println("60");
-  s4.write(60);
-  delay(1000);
-  Serial.println("90");
-  s4.write(90);
-  delay(1000);
-  Serial.println("100");
-  s4.write(110);
-  delay(1000);*/
-
-}


added a better configurarion string for the line following example

--- libraries/Robot_Control/examples/explore/R02_Line_Follow/R02_Line_Follow.ino
+++ libraries/Robot_Control/examples/explore/R02_Line_Follow/R02_Line_Follow.ino
@@ -41,7 +41,9 @@
   Robot.waitContinue();

   // These are some general values that work for line following
-  Robot.lineFollowConfig(11, 5, 50, 10);
+  // uncomment one or the other to see the different behaviors of the robot
+  // Robot.lineFollowConfig(11, 5, 50, 10);
+  Robot.lineFollowConfig(14, 9, 50, 10);

   //set the motor board into line-follow mode
   Robot.setMode(MODE_LINE_FOLLOW);


Update neopixel_bluetooth_picker.ino

Update neopixel_bluetooth_picker.ino

--- arduino_files/neopixel_bluetooth_picker/neopixel_bluetooth_picker.ino
+++ arduino_files/neopixel_bluetooth_picker/neopixel_bluetooth_picker.ino
@@ -106,7 +106,7 @@
 /**************************************************************************/
 void setup(void)
 {
-  while (!Serial);  // required for Flora & Micro
+//  while (!Serial);  // required for Flora & Micro
   delay(500);

   Serial.begin(115200);


COH-77: WIP

COH-77: WIP

--- Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -20,14 +20,6 @@
 // Force-enable RX if not already so.
 #define ENABLE_RADIO_RX
 #define ENABLE_CONTINUOUS_RX // was #define CONFIG_IMPLIES_MAY_NEED_CONTINUOUS_RX true
-// By default (up to 2015), use the RFM22/RFM23 module to talk to an FHT8V wireless radiator valve.
-#ifdef ENABLE_FHT8VSIMPLE
-#define ENABLE_RADIO_RFM23B
-#define ENABLE_FS20_CARRIER_SUPPORT
-#define ENABLE_FS20_ENCODING_SUPPORT
-#define ENABLE_FHT8VSIMPLE_RX
-#define LISTEN_FOR_FTp2_FS20_native
-#endif // ENABLE_FHT8VSIMPLE

 // Indicate that the system is broken in an obvious way (distress flashing of the main UI LED).
 // DOES NOT RETURN.
@@ -626,8 +618,8 @@
       if(c.isValid())
         {
         // Process the message only if it is targetted at this node.
-        const uint8_t hc1 = FHT8VGetHC1();
-        const uint8_t hc2 = FHT8VGetHC2();
+        const uint8_t hc1 = FHT8V.nvGetHC1();
+        const uint8_t hc2 = FHT8V.nvGetHC2();
         if((c.getHC1() == hc1) && (c.getHC2() == hc2))
           {
           // Act on the incoming command.
@@ -1320,24 +1312,24 @@
   const bool doubleTXForFTH8V = false;
   // FHT8V is highest priority and runs first.
   // ---------- HALF SECOND #0 -----------
-  bool useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_First(doubleTXForFTH8V); // Time for extra TX before UI.
+  bool useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8V.FHT8VPollSyncAndTX_First(doubleTXForFTH8V); // Time for extra TX before UI.
   if(useExtraFHT8VTXSlots)
     {
     handleQueuedMessages(&Serial, true, &PrimaryRadio);
     // ---------- HALF SECOND #1 -----------
-    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
+    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8V.FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
     }
   if(useExtraFHT8VTXSlots)
     {
     handleQueuedMessages(&Serial, true, &PrimaryRadio);
     // ---------- HALF SECOND #2 -----------
-    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
+    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8V.FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
     }
   if(useExtraFHT8VTXSlots)
     {
     handleQueuedMessages(&Serial, true, &PrimaryRadio);
     // ---------- HALF SECOND #3 -----------
-    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
+    useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8V.FHT8VPollSyncAndTX_Next(doubleTXForFTH8V);
     }
 #endif


Added code to publish tf and ros odometry.

--- Arduino/victoria_teensy_ros_node/victoria_teensy_ros_node.ino
+++ Arduino/victoria_teensy_ros_node/victoria_teensy_ros_node.ino
@@ -25,9 +25,10 @@

 // ROS includes
 #include <ros.h>
+#include <geometry_msgs/Quaternion.h>
 #include <geometry_msgs/Twist.h>
-#include <geometry_msgs/Pose.h>
 #include <nav_msgs/Odometry.h>
+#include <tf/tf.h>
 #include <tf/transform_broadcaster.h>
 #include <std_msgs/String.h>

@@ -55,7 +56,6 @@
 #define MAX_SPEED 4.71      // in meters/second

 // Bumper sensors
-#define BUMPER_THRESHOLD 300  // Threshold that will indicate robot should stop
 bool bumper_stop = false; // Set to true if bumpers indicate robot should stop
 unsigned int bumper_left;
 unsigned int bumper_right;
@@ -67,8 +67,9 @@
 unsigned long encoder_right_pos;
 ros::Time last_encoder_read_time;

-double ang_vel_l[10];
-double ang_vel_r[10];
+#define NUM_VEL_SAMPLES 10
+double ang_vel_samples_l[NUM_VEL_SAMPLES];
+double ang_vel_samples_r[NUM_VEL_SAMPLES];
 int velocity_index = 0;

 // IMU and Magnetometer
@@ -98,6 +99,10 @@
 geometry_msgs::TransformStamped ros_odom_transform;
 tf::TransformBroadcaster ros_odom_broadcaster;

+double x;
+double y;
+double th;
+
 ros::Time current_time;
 ros::Time previous_time;

@@ -168,6 +173,9 @@
   encoder_right_pos = 0.0;
   motor_left_speed = 0.0;
   motor_right_speed = 0.0;
+  x = 0.0;
+  y = 0.0;
+  th = 0.0;

   // Initialize and connect to ros
   ros_nh.initNode();
@@ -234,7 +242,6 @@

 void loop() {
   // Check bumper thresholds to stop robot
-  // TODO(mwomack): Figure out how to support ROS instructing going backwards
   bumper_left = analogRead(BUMPER_LEFT_PIN);
   bumper_right = analogRead(BUMPER_RIGHT_PIN);
   bumper_stop = bumper_left < 450 || bumper_right < 450;
@@ -291,6 +298,11 @@
   motor_right_speed = max(-1, min(1, wr / MAX_SPEED));
 }

+/*
+ * Reads the current values of the motor encoders and uses
+ * the difference with the previous value from the encoders
+ * to calculate the angular velocity of each wheel.
+ */
 void doReadEncoders() {
   ros::Time current_time = ros_nh.now();
   unsigned long new_encoder_left_pos = encoder_left.read();
@@ -301,10 +313,10 @@
   unsigned long diff_r = new_encoder_right_pos - encoder_right_pos;
   double diff_t = current_time.toSec() - last_encoder_read_time.toSec();

-  ang_vel_l[velocity_index] = (diff_l/TICKS_PER_RADIAN)/diff_t;
-  ang_vel_r[velocity_index] = (diff_r/TICKS_PER_RADIAN)/diff_t;
-
-  velocity_index = (velocity_index + 1) % 10;
+  ang_vel_samples_l[velocity_index] = (diff_l/TICKS_PER_RADIAN)/diff_t;
+  ang_vel_samples_r[velocity_index] = (diff_r/TICKS_PER_RADIAN)/diff_t;
+
+  velocity_index = (velocity_index + 1) % NUM_VEL_SAMPLES;
   encoder_left_pos = new_encoder_left_pos;
   encoder_right_pos = new_encoder_right_pos;
   last_encoder_read_time = current_time;
@@ -312,21 +324,63 @@

 void doPublishOdom() {
   ros::Time current_time = ros_nh.now();
+  double wl = getAngularVelocityFromSamples(ang_vel_samples_l);
+  double wr = getAngularVelocityFromSamples(ang_vel_samples_r);
+  double vl = wl * WHEEL_RADIUS;
+  double vr = wr * WHEEL_RADIUS;
+  double vx = (vl + vr)/2;
+  double vth = (vr - vl)/(2 * TRACK_RADIUS);
+
   double dt = current_time.toSec() - last_odom_publish_time.toSec();
-
+  double delta_x = (vx * cos(th)) * dt;
+  double delta_y = (vx * sin(th)) * dt;
+  double delta_th = vth * dt;
+
+  x += delta_x;
+  y += delta_y;
+  th += delta_th;
+
   // Broadcast odometry transform
+
+  // Since all odometry is 6DOF we'll need a quaternion created from yaw
+  geometry_msgs::Quaternion odom_quat = tf::createQuaternionFromYaw(th);
+
+  // First, we'll publish the transform over tf
   ros_odom_transform.header.stamp = current_time;
-
-  // TODO: set all the transform data
-
+  ros_odom_transform.transform.translation.x = x;
+  ros_odom_transform.transform.translation.y = y;
+  ros_odom_transform.transform.translation.z = 0.0;
+  ros_odom_transform.transform.rotation = odom_quat;
   ros_odom_broadcaster.sendTransform(ros_odom_transform);

-  // Publish Odometry
+  // Next, we'll publish the odometry message over ROS
   ros_odom_msg.header.stamp = current_time;
-
-  // TODO: Set all the odometry data
+
+  //set the position
+  ros_odom_msg.pose.pose.position.x = x;
+  ros_odom_msg.pose.pose.position.y = y;
+  ros_odom_msg.pose.pose.position.z = 0.0;
+  ros_odom_msg.pose.pose.orientation = odom_quat;
+
+  //set the velocity
+  ros_odom_msg.twist.twist.linear.x = vx;
+  ros_odom_msg.twist.twist.linear.y = 0.0;
+  ros_odom_msg.twist.twist.angular.z = vth;

   ros_odom_pub.publish(&ros_odom_msg);
+}
+
+/*
+ * Returns the calculated angular velocity from all of
+ * the samples. Right now it just returns the average
+ * of all the samples.
+ */
+double getAngularVelocityFromSamples(double* samples) {
+  double total = 0;
+  for (int count = 0; count < NUM_VEL_SAMPLES; count++) {
+    total += samples[count];
+  }
+  return total/10.0;
 }

 /*


updated test. Will include it in the Examples repo

--- examples/LightBlueBean/01.Basics/ChangeInterrupts/ChangeInterrupts.ino
+++ examples/LightBlueBean/01.Basics/ChangeInterrupts/ChangeInterrupts.ino
@@ -1,10 +1,13 @@
 #include <PinChangeInt.h>

 /*
-  This sketch uses the Bean library to trigger interrupts when changes are detected on pins 0, 1, and 2.
+  This sketch shows how to use low-power interrupts to detect when the Bean's digital inputs have changed.
+
+  To use the sketch, conect a wire between the Bean's ground pin and one of it's 6 digital pins.
+  Pins 0, 1, and 2 will enabled colors in the LED, while the other pins disable colors.

   Notes:
-    - This is not a low-power sketch
+    - This is not a low-power sketch because of LED use
     - A Bean with a low battery might show a faint blue and green LED color

   This example code is in the public domain.
@@ -18,17 +21,17 @@
 //   Set a flag and perform the desired operation within the superloop
 void zeroChangeDetected( void )
 {
-  red += 16;
+  red = 128;
 }

 void oneChangeDetected( void )
 {
-  green += 16;
+  green = 128;
 }

 void twoChangeDetected( void )
 {
-  blue += 16;
+  blue = 128;
 }

 void threeChangeDetected( void )
@@ -59,12 +62,11 @@
   attachPinChangeInterrupt(3, threeChangeDetected, CHANGE);
   attachPinChangeInterrupt(4, fourChangeDetected, CHANGE);
   attachPinChangeInterrupt(5, fiveChangeDetected, CHANGE);
-  Bean.setLed(0xFF, 0xFF, 0xFF);  // Flash to show the sketch is running
-  Bean.sleep(250);
 }

 void loop() {
   // Set the Bean's LED based upon RGBs changed by interrupts
   Bean.setLed(red, green, blue);
-  Bean.sleep(100);
+  Bean.sleep(1000);
 }
+


Update ArduCAM_Mini_5MP_Plus_Video_Streaming.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Video_Streaming/ArduCAM_Mini_5MP_Plus_Video_Streaming.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Video_Streaming/ArduCAM_Mini_5MP_Plus_Video_Streaming.ino
@@ -320,6 +320,7 @@
   if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK))
   {
     Serial.println(F("ACK CMD CAM Capture Done. END"));
+    delay(50);
     uint8_t temp, temp_last;
     uint32_t length = 0;
     length = myCAM.read_fifo_length();


Remove Extra BasicGain_wApp_BLE

Remove Extra BasicGain_wApp_BLE

--- examples/07-Bluetooth/01-BasicGain_wApp_BLE/01-BasicGain_wApp_BLE.ino
+++ examples/07-Bluetooth/01-BasicGain_wApp_BLE/01-BasicGain_wApp_BLE.ino
@@ -1,209 +0,0 @@
-/*
-*   BasicGain_wApp
-*
-*   Created: Chip Audette, June 2020
-*   Purpose: Process audio using Tympan by applying gain.
-*      Also, illustrate how to change Tympan setting via the TympanRemote App.
-*
-*   Blue potentiometer adjusts the digital gain applied to the audio signal.
-*
-*   Uses default sample rate of 44100 Hz with Block Size of 128
-*
-*   TympanRemote App: https://play.google.com/store/apps/details?id=com.creare.tympanRemote&hl=en_US
-*
-*   MIT License.  use at your own risk.
-*/
-
-//here are the libraries that we need
-#include <Tympan_Library.h>  //include the Tympan Library
-
-//create audio library objects for handling the audio
-Tympan                    myTympan(TympanRev::D);  //do TympanRev::D or TympanRev::C
-AudioInputI2S_F32         i2s_in;        //Digital audio *from* the Tympan AIC.
-AudioEffectGain_F32       gain1, gain2;  //Applies digital gain to audio data.
-AudioOutputI2S_F32        i2s_out;       //Digital audio *to* the Tympan AIC.  Always list last to minimize latency
-
-//Make all of the audio connections
-AudioConnection_F32       patchCord1(i2s_in, 0, gain1, 0);    //connect the Left input
-AudioConnection_F32       patchCord2(i2s_in, 1, gain2, 0);    //connect the Right input
-AudioConnection_F32       patchCord11(gain1, 0, i2s_out, 0);  //connect the Left gain to the Left output
-AudioConnection_F32       patchCord12(gain2, 0, i2s_out, 1);  //connect the Right gain to the Right output
-
-//define class for handling the GUI on the app
-#include "TympanRemoteFormatter.h"
-TympanRemoteFormatter myGUI;  //Creates the GUI-writing class for interacting with TympanRemote App
-
-usb_serial_class *USB_Serial = &Serial;
-HardwareSerial *BT_Serial = &Serial1;
-BLE *ble;
-String msgFromBle = String(""); // Message from ble
-int msgLen;
-
-// define the setup() function, the function that is called once when the device is booting
-const float input_gain_dB = 10.0f; //gain on the microphone
-float digital_gain_dB = 0.0;      //this will be set by the app
-void setup() {
-
-  //begin the serial comms (for debugging)
-  USB_Serial->begin(9600);
-  BT_Serial->begin(9600);
-
-  delay(3000);
-  Serial.println("BasicGain_wApp: starting setup()...");
-
-  //allocate the dynamic memory for audio processing blocks
-  AudioMemory_F32(10);
-
-  //switch BT to command mode
-  USB_Serial->println("Setup: Switching BT module into command mode...");
-  myTympan.forceBTtoDataMode(false); delay(50);  //removing any forcing of being in data mode so that hopefully we're in command mode
-  BT_Serial->print("$");  delay(400);
-  BT_Serial->print("$$$");  delay(400);
-
-  //create BLE object
-  USB_Serial->println("Setup: new BLE()...");
-  ble = new BLE(&Serial1);
-
-  //Enable the Tympan to start the audio flowing!
-  myTympan.enable(); // activate the Tympan's audio module
-
-  //Choose the desired input
-  myTympan.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC);     // use the on board microphones
-  //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_MIC);    // use the microphone jack - defaults to mic bias 2.5V
-  //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF
-
-  //Set the desired volume levels
-  myTympan.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
-  myTympan.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps
-
-  //Create the GUI description (but not yet transmitted to the App...that's after it connects)
-  createTympanRemoteLayout();
-
-  // Get the BLE up and running
-  setupBLE();
-
-  Serial.println("Setup complete.");
-} //end setup()
-
-
-// define the loop() function, the function that is repeated over and over for the life of the device
-void loop() {
-
-  //look for in-coming serial messages (via USB or via Bluetooth)
-  if (Serial.available()) respondToByte((char)Serial.read());   //USB Serial
-  //if (Serial1.available()) respondToByte((char)Serial1.read()); //BT Serial
-
-  if (ble.available() > 0) {
-    msgFromBle = "";
-    msgLen = ble.recvBLE(&msgFromBle);
-    for (int i=0; i < msgLen; i++) {
-      respondToByte(msgFromBle[i]);
-    }
-  }
-
-} //end loop();
-
-
-// ///////////////// Servicing routines
-
-//respond to serial commands
-void respondToByte(char c) {
-  Serial.print("Received character "); Serial.println(c);
-
-  switch (c) {
-    case 'J': case 'j':
-      printTympanRemoteLayout();
-      break;
-    case 'k':
-      changeGain(3.0);
-      printGainLevels();
-      setButtonText("gainIndicator", String(digital_gain_dB));
-      break;
-    case 'K':
-      changeGain(-3.0);
-      printGainLevels();
-      setButtonText("gainIndicator", String(digital_gain_dB));
-      break;
-  }
-}
-
-// Print the layout for the Tympan Remote app, in a JSON-ish string
-// (single quotes are used here, whereas JSON spec requires double quotes.  The app converts ' to " before parsing the JSON string).
-// Please don't put commas or colons in your ID strings!
-void printTympanRemoteLayout(void) {
-  //myTympan.println(myGUI.asString());
-  ble.sendMessage(myGUI.asString());
-}
-
-//define the GUI for the App
-void createTympanRemoteLayout(void) {
-
-  // Create some temporary variables
-  TR_Page *page_h;  //dummy handle for a page
-  TR_Card *card_h;  //dummy handle for a card
-
-  //Add first page to GUI
-  page_h = myGUI.addPage("MyFirstPage");
-      //Add a card under the first page
-      card_h = page_h->addCard("Change Loudness");
-          //Add a "-" digital gain button with the Label("-"); Command("K"); Internal ID ("minusButton"); and width (4)
-          card_h->addButton("-","K","minusButton",4);  //displayed string, command, button ID, button width (out of 12)
-
-          //Add an indicator that's a button with no command:  Label (value of the digital gain); Command (""); Internal ID ("gain indicator"); width (4).
-          card_h->addButton(String(digital_gain_dB),"","gainIndicator",4);  //displayed string (blank), command (blank), button ID, button width (out of 12)
-
-          //Add a "+" digital gain button with the Label("+"); Command("K"); Internal ID ("minusButton"); and width (4)
-          card_h->addButton("+","k","plusButton",4);   //displayed string, command, button ID, button width (out of 12)
-
-  //add some pre-defined pages to the GUI
-  myGUI.addPredefinedPage("serialMonitor");
-  myGUI.addPredefinedPage("serialPlotter");
-}
-
-
-//change the gain from the App
-void changeGain(float change_in_gain_dB) {
-  digital_gain_dB = digital_gain_dB + change_in_gain_dB;
-  gain1.setGain_dB(digital_gain_dB);  //set the gain of the Left-channel gain processor
-  gain2.setGain_dB(digital_gain_dB);  //set the gain of the Right-channel gain processor
-}
-
-
-//Print gain levels
-void printGainLevels(void) {
-  Serial.print("Analog Input Gain (dB) = ");
-  Serial.println(input_gain_dB); //print text to Serial port for debugging
-  Serial.print("Digital Gain (dB) = ");
-  Serial.println(digital_gain_dB); //print text to Serial port for debugging
-}
-
-void setButtonText(String btnId, String text) {
-  ble.sendMessage("TEXT=BTN:" + btnId + ":"+text);
-}
-
-// Set up the BLE
-void setupBLE()
-{
-    // Announce if connected
-    if (ble.isConnected()) {
-        Serial.println("*** Connected...");
-    } else {
-        Serial.println("*** Not Connected...");
-    }
-
-    // Turn on advertising and wait for a connection
-    Serial.println("*** Advertising on...");
-    ble.advertise(true);
-    if (!ble.waitConnect(60000)) {
-        Serial.println("*** Timed out on Connect.");
-    } else {
-        Serial.println("*** Connected...");
-    }
-
-    // Check if connected
-    if (ble.isConnected()) {
-        Serial.println("*** Is Connected...");
-    } else {
-        Serial.println("*** Is Not Connected...");
-    }
-}


Add Serial1

Add Serial1

--- Segment16Sign.ino
+++ Segment16Sign.ino
@@ -6,23 +6,33 @@

 void setup(){
   Serial.begin(9600);
-  while (!Serial) {}  // wait for Leonard
-  Serial.println("Type any character to start");
-  while (Serial.read() <= 0) {}
+  Serial1.begin(9600);
+  while (!Serial || !Serial1) {}  // wait for Leonard
+
+  String prompt = "Type any character to start";
+  Serial.println(prompt);
+  Serial1.println(prompt);
+
+  while (Serial.read() <= 0 || Serial1.read() <= 0) {}
   delay(200);  // Catch Due reset problem
   display.init();
-  // assume the user typed a valid character and no reset happened
+  // assume the user typed a valid character and no reset happened
 }

 void loop(){
-  if(Serial.available() > 0){
+  if(Serial.available() > 0 || Serial1.available() > 0){
     input = 0;
     while(Serial.available() > 0){
       incomingByte = Serial.read();
       input = (input << 8) | incomingByte;
     }
+    while(Serial1.available() > 0){
+      incomingByte = Serial.read();
+      input = (input << 8) | incomingByte;
+    }
     display.pushChar(input);
     Serial.println(input, HEX);
+    Serial1.println(input, HEX);
     //incomingByte = Serial.read();
   }
   display.show();


bug fix

bug fix

--- Arduino/hardware/REV10/REV10MessagePathTest/REV10SecureBHR/REV10SecureBHR.ino
+++ Arduino/hardware/REV10/REV10MessagePathTest/REV10SecureBHR/REV10SecureBHR.ino
@@ -152,7 +152,7 @@
 inline void stackCheck()
 {
     const int16_t minsp = OTV0P2BASE::MemoryChecks::getMinSPSpaceBelowStackToEnd();
-#if 0 && defined(DEBUG)
+#if 0 //&& defined(DEBUG)
     const uint8_t location = OTV0P2BASE::MemoryChecks::getLocation();
     OTV0P2BASE::serialPrintAndFlush(F("minsp: "));
     OTV0P2BASE::serialPrintAndFlush(minsp);
@@ -162,7 +162,7 @@
     OTV0P2BASE::MemoryChecks::forceResetIfStackOverflow();
     OTV0P2BASE::MemoryChecks::resetMinSP();
 #else
-    if(128 < minsp) { OTV0P2BASE::serialPrintAndFlush(F("!SP")); }
+    if(128 > minsp) { OTV0P2BASE::serialPrintlnAndFlush(F("!SP")); }
     OTV0P2BASE::MemoryChecks::forceResetIfStackOverflow();
 #endif
 }
@@ -520,7 +520,7 @@
     const uint8_t oldResetCount = eeprom_read_byte((uint8_t *)V0P2BASE_EE_START_RESET_COUNT);
     eeprom_write_byte((uint8_t *)V0P2BASE_EE_START_RESET_COUNT, 1 + oldResetCount);

-#if 0  // Print reset count. Intended for testing purposes.
+#if 1  // Print reset count. Intended for testing purposes.
     OTV0P2BASE::serialPrintAndFlush(F("\rResets: "));
     OTV0P2BASE::serialPrintAndFlush(oldResetCount);
     OTV0P2BASE::serialPrintlnAndFlush();


Tare on boot

Tare on boot

--- coffee-scale.ino
+++ coffee-scale.ino
@@ -14,6 +14,7 @@

 #define SCALE_FACTOR 1874
 #define SCALE_OFFSET 984550
+#define TARE_AVERAGES 10

 TimerDisplay    timerDisplay(DISP_TIMER_CLK, DISP_TIMER_DIO);
 GramsDisplay    gramsDisplay(DISP_SCALE_CLK, DISP_SCALE_DIO);
@@ -28,7 +29,7 @@
   // Load cell
   scale.begin(SCALE_DT, SCALE_SCK);
   scale.set_scale(SCALE_FACTOR);
-  scale.set_offset(SCALE_OFFSET);
+  scale.tare(TARE_AVERAGES);
 }