Modified Elcano_C2_LowLevel.ino

Modified Elcano_C2_LowLevel.ino

Added processHighLevel and convertDeg to Elcano_C2_LowLevel.ino.

--- Elcano_C2_LowLevel/Elcano_C2_LowLevel.ino
+++ Elcano_C2_LowLevel/Elcano_C2_LowLevel.ino
@@ -8,10 +8,10 @@
 const int softwareTx = 10;  // to 7 segment LED display
 const int softwareRx = 7;   // not used
 //SoftwareSerial s7s(softwareRx, softwareTx);
-#define s7s Serial3
+#define s7s Serial2

 #define LOOP_TIME_MS 400
-#define ERROR_HISTORY 20
+#define ERROR_HISTORY 20 //number of errors to accumulate

 /*================ReadTurnAngle ================*/
 // Value measured at analog input A2 from right steering column when wheels pointed straight ahead.
@@ -32,7 +32,7 @@
 int Right_Min_Count = 698;
 int Right_Max_Count = 808;

-// Channel order differs for differernt vehicles
+// Channel order differs for different vehicles
 // Indices for information stored in arrays RC_rise, RC_elapsed, local_results,...
 // Right joystick left/right to D21
 //#define RC_TURN 1
@@ -118,7 +118,8 @@
   attachInterrupt(IRPT_TURN, ISR_TURN_fall, FALLING);
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
+// RDR (rudder) is currently not used.
 void ISR_RDR_rise() {
 // RDR (rudder) is not used. Instead, use this interrupt for the motor phase feedback, which gives speed.
   noInterrupts();
@@ -133,28 +134,28 @@
   //  with R = 1K, C = 100 nF
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void ISR_GO_rise() {
   noInterrupts();
   ProcessRiseOfINT(RC_GO);
   attachInterrupt(IRPT_GO, ISR_GO_fall, FALLING);
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void ISR_ESTOP_rise() {
   noInterrupts();
   ProcessRiseOfINT(RC_ESTP);
   attachInterrupt(IRPT_ESTOP, ISR_ESTOP_fall, FALLING);
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void ISR_RVS_rise() {
   noInterrupts();
   ProcessRiseOfINT(RC_RVS);
   attachInterrupt(IRPT_RVS, ISR_RVS_fall, FALLING);
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void ISR_TURN_fall() {
   noInterrupts();
   ProcessFallOfINT(RC_TURN);
@@ -162,7 +163,7 @@
   attachInterrupt(IRPT_TURN, ISR_TURN_rise, RISING);
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void ISR_GO_fall() {
   noInterrupts();
   ProcessFallOfINT(RC_GO);
@@ -170,6 +171,7 @@
   attachInterrupt(IRPT_GO, ISR_GO_rise, RISING);
   interrupts();
 }
+/*---------------------------------------------------------------------------------------*/
 void ISR_ESTOP_fall() {
   noInterrupts();
   ProcessFallOfINT(RC_ESTP);
@@ -179,7 +181,7 @@
   attachInterrupt(IRPT_ESTOP, ISR_ESTOP_rise, RISING);
   interrupts();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void ISR_RVS_fall() {
   noInterrupts();
   ProcessFallOfINT(RC_RVS);
@@ -187,6 +189,34 @@
   attachInterrupt(IRPT_RVS, ISR_RVS_rise, RISING);
   interrupts();
 }
+/*---------------------------------------------------------------------------------------*/
+// An e-bike hub motor is powered by giving it 3 phase power. This is supplied
+// by the motor controller. The controller needs feeback from the hub.  It
+// receives three feedback signals from the motor, one for each phase.  These
+// are the *actual* phase rotation of the motor, not the phases supplied by the
+// controller, which differ from what the motor is currently doing whenever the
+// controller is attempting to speed up or slow down or change direction of the
+// motor. The motor phase feedback pulse rate is an integer multiple of wheel
+// rotation rate. The factor is the number of pole pairs in the motor. Note
+// that the controller has no idea how many pole pairs the motor has, so it
+// only controls the phase rate, not the actual rotation rate.  It is "someone
+// else's problem" to limit the actual rotation rate or speed. The feedback
+// signals are 5V square waves.  They have some noise -- spikes of several
+// volts, which exceeds the maximum voltage allowed for Arduino inputs, which
+// is 5.5V.  The signal is cleaned up by an RC low pass filter with R = 1K,
+// C = 100 nF.
+void ISR_MOTOR_FEEDBACK_rise() {
+  noInterrupts();
+  // This differs from the other interrupt routines since we need the *cycle*
+  // duration, not the width of the high pulse.  So here, we get the time from
+  // the previous rising edge to the current rising edge.  Q: Are we properly
+  // ignoring the first value from all of these interval computations?
+  unsigned long old_phase_rise = RC_rise[RC_MOTOR_FEEDBACK];
+  ProcessRiseOfINT(RC_MOTOR_FEEDBACK);
+  RC_elapsed[RC_MOTOR_FEEDBACK] = RC_rise[RC_MOTOR_FEEDBACK] - old_phase_rise;
+  interrupts();
+}
+/*---------------------------------------------------------------------------------------*/
 //----------------------------------------------------------------------------
 void setup()
 { //Set up pins
@@ -229,11 +259,12 @@
       attachInterrupt(IRPT_RDR,   ISR_RDR_rise,   RISING);
       attachInterrupt(IRPT_GO,    ISR_GO_rise,    RISING);
       attachInterrupt(IRPT_ESTOP, ISR_ESTOP_rise, RISING);
-      attachInterrupt(IRPT_RVS,   ISR_RVS_rise,   RISING);
-//      Print7headers(false);
+      //attachInterrupt(IRPT_RVS,   ISR_RVS_rise,   RISING);
+      attachInterrupt(IRPT_MOTOR_FEEDBACK, ISR_MOTOR_FEEDBACK_rise, RISING);
+      //Print7headers(false);
       PrintHeaders();
 }
-
+/*---------------------------------------------------------------------------------------*/
 void loop() {
     SerialData Results;

@@ -254,9 +285,11 @@
     // got data;
     for (int i = 0; i < 8; i++)
         local_results[i] = RC_elapsed[i];
-    Print7( false, local_results);
-    processRC(local_results);
-    Print7( true, local_results);
+    //Print7(false, local_results);
+    byte automate = processRC(local_results);
+    if(automate = 0x01)
+        processHighLevel();
+//    Print7( true, local_results);

     Results.Clear();
     Results.kind = MSG_SENSOR;
@@ -293,6 +326,7 @@
         nextTime = endTime + 1000 * LOOP_TIME_MS;
     }
 }
+/*---------------------------------------------------------------------------------------*/
 void PrintDone()
 {
   Serial.print("RC_Done values: RC_ESTP "); Serial.print(RC_Done[RC_ESTP]);
@@ -302,7 +336,7 @@
   // Not currently using RC_RVS, and it is always zero.

 }
-
+/*---------------------------------------------------------------------------------------*/
 void Print7headers (bool processed)
 {
     processed? Serial.print("processed data \t") : Serial.print("received data \t");
@@ -326,6 +360,7 @@
     Serial.println("Reverse\t");
 #endif
 }
+/*---------------------------------------------------------------------------------------*/
 void Print7 (bool processed, unsigned long results[7])
 {

@@ -338,25 +373,37 @@
     Serial.print(results[5]); Serial.print("\t");
     Serial.println(results[6]);
 }
+/*---------------------------------------------------------------------------------------*/
 void LogData(unsigned long commands[7], SerialData *sensors)  // data for spreadsheet
 {
-//     Serial.print(millis()); Serial.print("\t");
-//     Serial.print(sensors->speed_cmPs); Serial.print("\t");
-//
-//     Serial.print(sensors->speed_cmPs*36.0/1000.); Serial.print("\t"); // km/hr
-//     Serial.print(HubSpeed_kmPh); Serial.print("\t");\
      show7seg(HubSpeed_kmPh);
-//     Serial.print(sensors->angle_deg); Serial.print("\t");
-//     int right = analogRead(A2);
-//     int left = analogRead(A3);
-//     Serial.print(right); Serial.print("\t");
-//     Serial.print(left); Serial.print("\t");
-//     Serial.print(throttle_control); Serial.print("\t");
-//     Serial.print(brake_control); Serial.print("\t");
-//     Serial.print(steer_control); Serial.print("\t");
-//     Serial.println(Odometer_m);
+     /*Serial.print("(ms) Time\t");
+     Serial.print("(cm/s) Speed\t");
+     Serial.print("(km/h) Speed\t");
+     Serial.print("(km/h) Hub Speed\t");
+     Serial.print("(deg) Angle\t");
+     Serial.print("Right\t");
+     Serial.print("Left\t");
+     Serial.print("Throttle\t");
+     Serial.print("Brake\t");
+     Serial.print("Steer\t");
+     Serial.println("(m) Distance");*/
+     Serial.print(millis()); Serial.print("\t");                        //(ms) Time
+     Serial.print(sensors->speed_cmPs); Serial.print("\t");             //(cm/s) Speed
+     Serial.print(sensors->speed_cmPs*36.0/1000.); Serial.print("\t");  //(km/h) Speed
+     Serial.print(HubSpeed_kmPh); Serial.print("\t");                   //(km/h) Hub Speed
+     Serial.print(sensors->angle_deg); Serial.print("\t");              //(deg) Angle
+     int right = analogRead(A3);
+     int left = analogRead(A2);
+     Serial.print(right); Serial.print("\t");                           //Right turn sensor
+     Serial.print(left); Serial.print("\t");                            //Left turn sensor
+     Serial.print(throttle_control); Serial.print("\t");                //Throttle
+     Serial.print(brake_control); Serial.print("\t");                   //Brake
+     Serial.print(steer_control); Serial.print("\t");                   //Steer
+     Serial.println(Odometer_m);                                        //(m) Distance
 //     Print7 (true, commands);
 }
+/*---------------------------------------------------------------------------------------*/
 void PrintHeaders (void)
 {
     Serial.print("(ms) Time\t");
@@ -371,15 +418,16 @@
     Serial.print("Steer\t");
     Serial.println("(m) Distance");
 }
+/*---------------------------------------------------------------------------------------*/
 void startCapturingRCState()
 {
   for (int i = 1; i < 7; i++) {
     RC_Done[i] = 0;
   }
 }
-
+/*---------------------------------------------------------------------------------------*/
 // processRC modified by TCF  9/17/15
-void processRC (unsigned long *results)
+byte processRC (unsigned long *results)
 {
     // 1st pulse is aileron (position 5 on receiver; controlled by Right left/right joystick on transmitter)
     //     used for Steering
@@ -404,14 +452,14 @@
         if ((results[RC_AUTO] == LOW)  && (NUMBER_CHANNELS > 5)) // under RC control
             steer(results[RC_TURN]);
         Serial.println("Exiting processRC due to E-stop.");
-        return;
+        return 0x00;
     }

     if ((results[RC_AUTO] == HIGH)  && (NUMBER_CHANNELS > 5))
     {
-        Serial.println("Exiting processRC as not under RC control.");
-        return;  // not under RC control
+        Serial.println("Calling processHighLevel.");
+        return 0x01;  // not under RC control
     } else {
 //        Serial.println("Continuing processRC as under RC control.");
     }
@@ -450,8 +498,26 @@
         HubSpeed_kmPh = HubSpeed2kmPh / results[RC_RDR];

 //  Serial.println("");  // New line
-
-}
+    return 0x00;
+}
+/*---------------------------------------------------------------------------------------*/
+void processHighLevel()
+{
+    SerialData Results;
+    readSerial(&Serial3, &Results);
+    //Throttle
+
+    //End Throttle
+    //Brake
+
+    //End Brake
+    //Steer
+    int turn_signal = convertDeg(Results.angle_deg);
+    steer(turn_signal);
+    //End Steer
+    writeSerial(&Serial3, &Results);
+}
+/*---------------------------------------------------------------------------------------*/
 //Converts RC values to corresponding values for the PWM output
 int convertTurn(int input)
 {
@@ -498,36 +564,43 @@
         return trueOut;
     }
 }
-
+/*---------------------------------------------------------------------------------------*/
+int convertDeg(int deg)
+{
+    int result = STRAIGHT_TURN_OUT;
+    result += (deg * 2.25);
+    return result;
+}
+/*---------------------------------------------------------------------------------------*/
 int convertThrottle(int input)
 {
-      //full throttle = 227, min = 40
-      const int dacRange = MAX_ACC_OUT - MIN_ACC_OUT;
-      const int rcRange = MAX_RC - (MIDDLE + DEAD_ZONE);
-      input -= (MIDDLE + DEAD_ZONE);
-      double output = (double)input /(double)rcRange;
-      output *= dacRange;
-      output += MIN_ACC_OUT;
-      //set max values if out of range
-      int trueOut = (int)output;
-      if(trueOut > MAX_ACC_OUT)
-          trueOut = MAX_ACC_OUT;
-      return trueOut;
-}
-
+    //full throttle = 227, min = 40
+    const int dacRange = MAX_ACC_OUT - MIN_ACC_OUT;
+    const int rcRange = MAX_RC - (MIDDLE + DEAD_ZONE);
+    input -= (MIDDLE + DEAD_ZONE);
+    double output = (double)input /(double)rcRange;
+    output *= dacRange;
+    output += MIN_ACC_OUT;
+    //set max values if out of range
+    int trueOut = (int)output;
+    if(trueOut > MAX_ACC_OUT)
+        trueOut = MAX_ACC_OUT;
+    return trueOut;
+}
+/*---------------------------------------------------------------------------------------*/
 //Tests for inputs
 // Input not in throttle dead zone
 boolean liveThrottle(int acc)
 {
       return (acc > MIDDLE + DEAD_ZONE);
 }
-
+/*---------------------------------------------------------------------------------------*/
 // Input is not in brake dead zone
 boolean liveBrake(int brake)
 {
       return (brake < MIDDLE - DEAD_ZONE);
 }
-
+/*---------------------------------------------------------------------------------------*/
 // Emergency stop
 void E_Stop()
 {
@@ -536,7 +609,7 @@
     delay (2000);   // inhibit output
     // TO DO: disable 36V power
 }
-
+/*---------------------------------------------------------------------------------------*/
 //Send values to output pin
 void steer(int pos)
 {
@@ -544,6 +617,7 @@
 //      Serial.print("\tSteering to: \t"); Serial.print(pos);
      steer_control = pos;
 }
+/*---------------------------------------------------------------------------------------*/
 void convertBrake(long unsigned *amount)
 {
       if (*amount < (MIDDLE + MIN_RC)/2)
@@ -552,6 +626,7 @@
            *amount = MIN_BRAKE_OUT;
       brake (*amount);
 }
+/*---------------------------------------------------------------------------------------*/
 void brake (int amount)
 {
       analogWrite(BRAKE_OUT_PIN, amount);
@@ -617,6 +692,7 @@
           digitalWrite(SelectCD,HIGH);
       }
 }
+/*---------------------------------------------------------------------------------------*/
 void moveVehicle(int acc)
 {
       /* Observed behavior on ElCano #1 E-bike no load (May 10, 2013, TCF)
@@ -889,6 +965,7 @@
     show7seg( SpeedCyclometer_mmPs);   // Show speed on 7 segment LEDs

 }
+/*---------------------------------------------------------------------------------------*/
 /*========================CalibrateTurnAngle======================*/
 /*  This routine should only be called when
           - Wheels are pointed straight ahead, and have been for a while.
@@ -939,6 +1016,7 @@
 //    Serial.print("\tRight Straight\t"); Serial.println(RightStraight_A2);
     old_turn_degx1000 = 0; // straight
 }
+/*---------------------------------------------------------------------------------------*/
 /*======================ReadTurnAngle======================*/
 int TurnAngle_degx10()
 {
@@ -1033,6 +1111,7 @@
   // setting the max_error affacts control: anything bigger gets maximum response
   const long max_error_mmPs = 2500; // about 5.6 mph

+//lets look through this
   error_sum -= speed_errors[error_index];
   speed_errors[error_index] = error_speed_mmPs;
   error_sum += error_speed_mmPs;
@@ -1120,7 +1199,7 @@
 //  setBrightness(127);  // Medium brightness
   setBrightness(255);  // High brightness
 }
-
+/*---------------------------------------------------------------------------------------*/
 void show7seg(int speed_mmPs)
 {
   char tempString[4];  // Will be used with sprintf to create strings
@@ -1136,7 +1215,7 @@
   s7s.print(temp3);
   setDecimals(0b00000100);  // Sets digit 3 decimal on
 }
-
+/*---------------------------------------------------------------------------------------*/
 // Send the clear display command (0x76)
 //  This will clear the display and reset the cursor
 void clearDisplay()
@@ -1145,7 +1224,7 @@
   s7s.write(0x79); // Send the Move Cursor Command
   s7s.write(0x00); // Move Cursor to left-most digit
 }
-
+/*---------------------------------------------------------------------------------------*/
 // Set the displays brightness. Should receive byte with the value
 //  to set the brightness to
 //  dimmest------------->brightest
@@ -1155,7 +1234,7 @@
   s7s.write(0x7A);  // Set brightness command byte
   s7s.write(value);  // brightness data byte
 }
-
+/*---------------------------------------------------------------------------------------*/
 // Turn on any, none, or all of the decimals.
 //  The six lowest bits in the decimals parameter sets a decimal
 //  (or colon, or apostrophe) on or off. A 1 indicates on, 0 off.


examples: fix stream FirebaseObject usage

--- examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
+++ examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
@@ -55,16 +55,16 @@

   if (Firebase.available()) {
      FirebaseObject event = Firebase.readEvent();
-     String event_type = event["type"];
-     event_type.toLowerCase();
+     String eventType = event.getString("type");
+     eventType.toLowerCase();

      Serial.print("event: ");
-     Serial.println(event_type);
-     if (event_type == "put") {
+     Serial.println(eventType);
+     if (eventType == "put") {
        Serial.print("data: ");
-       Serial.println(event["data"].asString());
-       String path = event["path"];
-       float data = event["data"];
+       Serial.println(event.getString("data"));
+       String path = event.getString("path");
+       float data = event.getFloat("data");

        display.clearDisplay();
        display.setTextSize(2);


modified StringSubstring example to add gating on port readiness

--- build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino
+++ build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino
@@ -3,7 +3,7 @@

  Examples of how to use substring in a String

- created 27 July 2010
+ created 27 July 2010, modified 1 April 2012
  by Tom Igoe

  http://arduino.cc/en/Tutorial/StringSubstring
@@ -13,6 +13,9 @@

 void setup() {
   Serial.begin(9600);
+  // Wait for port to be opened:
+  while (!Serial)
+    ;
   Serial.println("\n\nString  substring():");
 }


Corrected the MIDIBLE example so it advertises correctly

--- libraries/CurieBLE/examples/peripheral/MIDIBLE/MIDIBLE.ino
+++ libraries/CurieBLE/examples/peripheral/MIDIBLE/MIDIBLE.ino
@@ -96,7 +96,7 @@

   BLESetup();
     // advertise the service
-
+  BLE.advertise();
   Serial.println(("Bluetooth device active, waiting for connections..."));
 }


Fixed calculation of uv intensity

Fixed calculation of uv intensity

--- files/template_home_wifi_feinstaub/template_home_wifi_feinstaub.ino
+++ files/template_home_wifi_feinstaub/template_home_wifi_feinstaub.ino
@@ -73,7 +73,7 @@
   sleep(1);
   if (Wire.available()) lsb = Wire.read();
   uvValue = (msb << 8) | lsb;
-  return uvValue * 5;
+  return uvValue * 5.625;
 }

 int printHexToStream(const uint8_t *data, uint8_t length, Print &stream) // prints 8-bit data in hex


Create Wrench-Mask-Wifi-ESP8266.ino

Create Wrench-Mask-Wifi-ESP8266.ino

--- Wifi-ESP8266/Wrench-Mask-Wifi-ESP8266.ino
+++ Wifi-ESP8266/Wrench-Mask-Wifi-ESP8266.ino
@@ -14,6 +14,7 @@
  * --------------------------------
  * ESP8266 Web Server with Arduino IDE
  * http://randomnerdtutorials.com/esp8266-web-server-with-arduino-ide/
+ *
 */

 /* Facial Expressions List


Arduino Yun: bug fix

Arduino Yun: bug fix

--- reference-realtime/arduino-yun/sketch/YunMQTT/YunMQTT.ino
+++ reference-realtime/arduino-yun/sketch/YunMQTT/YunMQTT.ino
@@ -21,34 +21,6 @@
 #ifdef MEMORY_DEBUG
 #include <MemoryFree.h>
 #endif
-
-// Update these with values suitable for your network.
-char * server = "stream.smartdatanet.it";
-
-// MQTT username
-char * userid = "sandbox";
-// MQTT password
-char * psw = "sandbox$1";
-// MQTT Topic
-char * topic = "input/sandbox";
-// MQTT client identifier
-char * clientID = "yunTEST";
-
-
-//! Stream
-char* stream = "flussoProva";
-// Sensor identifier
-char* id = "6e6fdf33-e8f0-4ee8-ba35-386de213e722";
-//char* json =  "{\"stream\":\"flussoProva\",\"sensor\":\"6e6fdf33-e8f0-4ee8-ba35-386de213e722\",\"values\":[{\"time\":\"2014-05-13T17:08:58+0200\",\"components\":{\"valoreDouble\":\"17.4\",\"valoreString\":\"51\"}}]}";
-
-// buffer to store the timestamp
-char timestamp[20] = {0};
-
-// Yun network client
-YunClient yunClient;
-
-// MQTT client
-PubSubClient client(server, 1883, callback, yunClient);

 /******************************************
  * Functions
@@ -105,7 +77,36 @@
  * \param payload message buffer
  * \param length number of byte received
  */
-void callback(char* topic, byte* payload, unsigned int length) {
+void callback(char* topic, byte* payload, unsigned int length);
+
+// Update these with values suitable for your network.
+char * server = "stream.smartdatanet.it";
+
+// MQTT username
+char * userid = "sandbox";
+// MQTT password
+char * psw = "sandbox$1";
+// MQTT Topic
+char * topic = "input/sandbox";
+// MQTT client identifier
+char * clientID = "yunTEST";
+
+
+//! Stream
+char* stream = "flussoProva";
+
+// Sensor identifier
+char* id = "6e6fdf33-e8f0-4ee8-ba35-386de213e722";
+//char* json =  "{\"stream\":\"flussoProva\",\"sensor\":\"6e6fdf33-e8f0-4ee8-ba35-386de213e722\",\"values\":[{\"time\":\"2014-05-13T17:08:58+0200\",\"components\":{\"valoreDouble\":\"17.4\",\"valoreString\":\"51\"}}]}";
+
+// buffer to store the timestamp
+char timestamp[20] = {0};
+
+// Yun network client
+YunClient yunClient;
+
+// MQTT client
+PubSubClient client(server, 1883, callback, yunClient);

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


Explicitly specify line endings

Explicitly specify line endings

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -35,6 +35,7 @@

 const char serialSeperator = ' ';
+const char lineEnding = '\n';

 void setup() {
@@ -135,14 +136,14 @@
             Serial.print(serialSeperator);
     }

-    Serial.println();
+    Serial.print(lineEnding);
 }

 #ifdef TEMP_MONITORING_ENABLED
 void writeTempMonitorData() {
     Serial.print(F("t "));
     Serial.print(tempMonitor.value, 2);
-    Serial.println();
+    Serial.print(lineEnding);
 }
 #endif

@@ -150,7 +151,7 @@
 void writeVoltMonitorData() {
     Serial.print(F("v "));
     Serial.print(voltMonitor.value, 2);
-    Serial.println();
+    Serial.print(lineEnding);
 }
 #endif

@@ -171,7 +172,7 @@
                 }

                 Serial.print(EepromSettings.rawMode ? 1 : 0, DEC);
-                Serial.println();
+                Serial.print(lineEnding);
             } break;

             // Set frequency.
@@ -194,7 +195,7 @@
             case 'n': {
                 for (uint8_t i = 0; i < RECEIVER_COUNT; i++) {
                     EepromSettings.rssiMin[i] =
-                        (uint16_t) receivers[i].rssiRaw * 0.975f;
+                        (uint16_t) receivers[i].rssiRaw;
                 }

                 EepromSettings.save();
@@ -204,7 +205,7 @@
             case 'm': {
                 for (uint8_t i = 0; i < RECEIVER_COUNT; i++) {
                     EepromSettings.rssiMax[i] =
-                        (uint16_t) receivers[i].rssiRaw * 1.025f;
+                        (uint16_t) receivers[i].rssiRaw;
                 }

                 EepromSettings.save();
@@ -224,7 +225,8 @@
         }

         Serial.find('\n');
-        Serial.println(F("ok"));
+        Serial.print(F("ok"));
+        Serial.print(lineEnding);
     }
 }


Change to use Pin defs

Change to use Pin defs

--- Caravan_Thermostat_TX/Caravan_Thermostat_TX.ino
+++ Caravan_Thermostat_TX/Caravan_Thermostat_TX.ino
@@ -25,6 +25,10 @@
 // DHT11
 #define DHT11PIN 2

+// BLE
+#define BLERXPIN 3
+#define BLETXPIN 4
+
 // IR Receiver
 #define IRPIN 5

@@ -33,7 +37,7 @@
 dht DHT;
 IRrecv irrecv(IRPIN);
 decode_results results;
-SoftwareSerial BT(7, 8); // RX, TX
+SoftwareSerial BT(BLERXPIN, BLETXPIN); // RX, TX

 // Define Global Variables


Clarify output a bit - count reconnects - quell channel profileration.

--- test/PoE-test/spacedeur-asis-2017/spacedeur-asis-2017.ino
+++ test/PoE-test/spacedeur-asis-2017/spacedeur-asis-2017.ino
@@ -36,6 +36,8 @@
 doorstate_t doorstate;
 unsigned long long last_doorstatechange = 0;

+long cnt_cards = 0, cnt_opens = 0, cnt_closes  = 0, cnt_fails = 0, cnt_misreads = 0, cnt_minutes = 0, cnt_reconnects = 0;
+
 #include <ETH.h>
 #include <SPI.h>

@@ -74,9 +76,11 @@
 #define PREFIX "test/"
 const char rfid_topic[] = PREFIX "deur/space2/rfid";
 const char door_topic[] = PREFIX "deur/space2/open";
-const char log_topic[] = PREFIX "deur/space2/log";
+const char log_topic[] = PREFIX "log";

 static bool eth_connected = false;
+
+const char * pname = __FILE__;

 static bool ota = false;
 void enableOTA() {
@@ -87,7 +91,7 @@
   // ArduinoOTA.setPort(3232);

   // Hostname defaults to esp3232-[MAC]
-  // ArduinoOTA.setHostname("myesp32");
+  ArduinoOTA.setHostname(pname);

   // No authentication by default
   // ArduinoOTA.setPassword("admin");
@@ -222,19 +226,30 @@
 PubSubClient client(wifiClient);

 static long lastReconnectAttempt = 0;
-const char * pname;

 boolean reconnect() {
-  if (client.connect(pname ? pname : "test-unit")) {
-    client.publish(log_topic, "reconnected");
-    client.subscribe(door_topic);
-  }
+  if (!client.connect(pname)) {
+    Serial.println("Failed to reconnect to MQTT bus.");
+    return false;
+  }
+
+  char buff[256];
+  snprintf(buff, sizeof(buff), "[%s] %sconnected.", pname, cnt_reconnects ? "re" : "");
+  client.publish(log_topic, buff);
+  client.subscribe(door_topic);
+
+  cnt_reconnects++;
+
   return client.connected();
 }

 void setup()
 {
-  pname = rindex(__FILE__, '/');
+  char * p = rindex(pname, '/');
+  if (p) pname = p;
+
+  p = index(pname, '.');
+  if (p) *p = 0;

   Serial.begin(115200);
   Serial.print("\n\n\nStart ");
@@ -248,7 +263,7 @@
   Serial.println("SPI init");
   spirfid.begin(MFRC522_SCK, MFRC522_MISO, MFRC522_MOSI, MFRC522_SS);

-  Serial.printf("MFRC522 init SPI=%p spi=%p setting=%d/%d/%d\n", &SPI, &spirfid, spiSettings._clock, spiSettings._bitOrder, spiSettings._dataMode);
+  Serial.printf("MFRC522 init SPI = %p spi = %p setting = %d / %d / %d\n", &SPI, &spirfid, spiSettings._clock, spiSettings._bitOrder, spiSettings._dataMode);
   mfrc522.PCD_Init();   // Init MFRC522

   Serial.println("MFRC522 dump version");
@@ -278,7 +293,6 @@
   Serial.println("setup() done");
 }

-long cnt_cards = 0, cnt_opens = 0, cnt_closes  = 0, cnt_fails = 0, cnt_misreads = 0, cnt_minutes = 0;

 void callback(char* topic, byte* payload, unsigned int length) {
   char buff[256];
@@ -288,7 +302,7 @@
     cnt_fails ++;
     return;
   };
-
+
   int l = 0;
   for (int i = 0; l < sizeof(buff) - 1 && i < length; i++) {
     char c = payload[i];
@@ -305,8 +319,8 @@
     return;
   };

-  snprintf(buff, sizeof(buff), "Cannot parse reply <%s>[len=%d, payload len=%d] or denied access.",
-           buff, l, length);
+  snprintf(buff, sizeof(buff), "[%s] Cannot parse reply <%s> [len = %d, payload len = %d] or denied access.",
+           pname, buff, l, length);

   client.publish(log_topic, buff);
   Serial.println(buff);
@@ -342,7 +356,8 @@
   switch (doorstate) {
     case OPENING:
       if (!is_moving) {
-        const char msg[] = "Door is open.";
+        char msg[256];
+        snprintf(msg, sizeof(msg), "[%s] Door is open.", pname);
         Serial.println(msg);
         client.publish(log_topic, msg);
         doorstate = OPEN;
@@ -357,7 +372,8 @@
       };
     case CLOSING:
       if (!is_moving) {
-        const char msg[] = "Door is closed.";
+        char msg[256];
+        snprintf(msg, sizeof(msg), "[%s] Door is closed.", pname);
         Serial.println(msg);
         client.publish(log_topic, msg);
         doorstate = CLOSED;
@@ -379,10 +395,11 @@
     cnt_minutes += ((millis() - tock) + 500) / 1000 / 60;

     snprintf(buff, sizeof(buff),
-             "alive - uptime %02ld:%02ld swipes %6ld, opens %6ld, closes %6ld, fails %6ld, misreads %6ld",
-             cnt_minutes / 12, (cnt_minutes % 12) * 5,
+             "[%s] alive - uptime %02ld: "
+             "%02ld swipes %6ld, opens %6ld, closes %6ld, fails %6ld, mis-swipes %6ld, mqtt reconnects %6ld",
+             pname, cnt_minutes / 12, (cnt_minutes % 12) * 5,
              cnt_cards,
-             cnt_opens, cnt_closes, cnt_fails, cnt_misreads);
+             cnt_opens, cnt_closes, cnt_fails, cnt_misreads, cnt_reconnects);
     client.publish(log_topic, buff);
     Serial.println(buff);
     tock = millis();
@@ -395,11 +412,14 @@

       String uidStr = "";
       for (int i = 0; i < uid.size; i++) {
-        if (i) uidStr += "-";
+        if (i) uidStr += " - ";
         uidStr += String(uid.uidByte[i], DEC);
       };
       client.publish(rfid_topic, uidStr.c_str());
-      client.publish(log_topic, uidStr.c_str());
+
+      char msg[256];
+      snprintf(msg, sizeof(msg), "[%s] Tag <%s> (len=%d) swiped", pname, uidStr.c_str(), uid.size);
+      client.publish(log_topic, msg);
     } else {
       Serial.println("Misread.");
       cnt_misreads++;


change claw direction

change claw direction

--- dfrdb/dfrdb.ino
+++ dfrdb/dfrdb.ino
@@ -114,11 +114,12 @@
     // for claw want to open/close base on stick, but then hold position;
     // so increment/decrement depending on position
     // and then keep that value if joystick centered
+    // now set so that moving stick R closes (righty tighty lefty loosey)
     if (clawPulse < ClawRDZ){
-      clawAngle -= 1;
+      clawAngle += 1;
     }
     else if (clawPulse > ClawLDZ){
-      clawAngle +=1;
+      clawAngle -=1;
     }
     clawAngle = constrain(clawAngle, minClawAngle, maxClawAngle);
     claw.write(clawAngle);


Update OnewireKeypad_EventKey.ino

Update OnewireKeypad_EventKey.ino

--- Examples/OnewireKeypad_EventKey/OnewireKeypad_EventKey.ino
+++ Examples/OnewireKeypad_EventKey/OnewireKeypad_EventKey.ino
@@ -1,3 +1,5 @@
+// Creator: Andrew Mascolo
+
 #include <OnewireKeypad.h>

 char KEYS[]= {


updating controlling bit with light sensors

--- BitController/BitController.ino
+++ BitController/BitController.ino
@@ -23,6 +23,11 @@

 uint8_t interrupt = 2;

+int l1_motor = 10;
+int l2_motor = 9;
+int r1_motor = 6;
+int r2_motor = 5;
+
 void setup()
 {
   //analogReference(EXTERNAL);
@@ -86,6 +91,7 @@
   readSensors();
   printSensors();
   determineDirection();
+  drive(sensorVals[n], sensorVals[s], sensorVals[e], sensorVals[w]);
   Serial.println();
   delay(500);
 }
@@ -184,3 +190,15 @@
   }
 }

+
+void drive(int nx, int sx, int ex, int wx)
+{
+  //north
+  if (nx <= 50) nx = 0;
+  nx = map(nx, 0, 600, 0, 255);
+  analogWrite(l1_motor, nx);
+  analogWrite(l2_motor, 0);
+  analogWrite(r1_motor, nx);
+  analogWrite(r2_motor, 0);
+}
+


Decrease debounceTime to 2s

Decrease debounceTime to 2s

Decreased debounceTime, as 2s achieved the same result as 5s, with the benefit of quicker reaction time on fast door status changes.

--- GarHAge/GarHAge.ino
+++ GarHAge/GarHAge.ino
@@ -55,7 +55,7 @@
 int door2_lastStatusValue = 2;
 unsigned long door1_lastSwitchTime = 0;
 unsigned long door2_lastSwitchTime = 0;
-int debounceTime = 5000;
+int debounceTime = 2000;

 // Temporary HASS workaround variables


Added tilt

Added tilt

--- ESP8266-code/ADXL335Test.ino
+++ ESP8266-code/ADXL335Test.ino
@@ -74,11 +74,12 @@
   float zG = zMilliG / 1000.0;

   Serial.println(String("Accelerations :")+xG+"G, "+yG+ "G, "+ zG +"G");
-  // convert to pitch and roll
+  // convert to pitch and roll and tilt from vertical

   float pitch = getPitch(xG,yG,zG);
   float roll = getRoll(xG,yG,zG);
-  Serial.println(String("roll=")+roll+" pitch= "+pitch);
+  float tilt = getTilt(xG,yG,zG);
+  Serial.println(String("roll=")+roll+" pitch= "+pitch +" tilt=" + tilt);

   delay(intervalms);

@@ -99,6 +100,10 @@
 float getRoll(float xG, float yG,float zG) {
     float mu= 0.01;
     return asDegree(atan2(yG, signum(zG) * sqrt(zG*zG + mu*xG*xG)));
+}
+
+float getTilt(float xG, float yG,float zG) {
+    return asDegree(acos(zG/ sqrt(xG*xG + yG*yG + zG*zG)));
 }

 int readAxis(int i) {


change wifi baud rate

change wifi baud rate

--- robots/maproom_esp/maproom_esp.ino
+++ robots/maproom_esp/maproom_esp.ino
@@ -43,9 +43,9 @@
 }

 void setup() {
-    Serial.begin(57600);
+    Serial.begin(19200);
     delay(10);
-
+
     Serial.println("ESSTART");

     WiFi.setAutoReconnect(true);
@@ -59,7 +59,7 @@

 void loop() {
   long now = millis();
-
+
   if (now - lastTime > 3000) {
     Serial.println("ESHB");
     lastTime = now;
@@ -105,14 +105,13 @@
     }

     bufLen = 0;
-    bufDone = false;
+    bufDone = false;
   }

   int packetSize = udp.parsePacket();
   if (packetSize) {
     int len = udp.read(incomingPacket, 255);
-    if (len > 0)
-    {
+    if (len > 0) {
       incomingPacket[len] = 0;
     }
     Serial.write(incomingPacket);


Changed baud

Changed baud

--- Arduino/_nano_firmware/nanoFirmware3/nanoFirmware3.ino
+++ Arduino/_nano_firmware/nanoFirmware3/nanoFirmware3.ino
@@ -62,7 +62,7 @@
   pinMode(digitalSelectPin, OUTPUT);
   digitalWrite(digitalSelectPin, LOW); //Set to HIGH for 6G sensitivity, OR LOW for 1.5G sensitivity
   digitalWrite(digitalSleepPin, HIGH);
-  Serial.begin(4800); // use the serial port
+  Serial.begin(9600); // use the serial port
   TIMSK0 = 0; //Reduces jitter
   ADCSRA = PS_32_i; //Set Prescaler Value
   ADMUX = 0x40; // use adc0


Added interrupt RX reading

Added interrupt RX reading

--- Firmware/R2-Quadcopter/R2-Quadcopter.ino
+++ Firmware/R2-Quadcopter/R2-Quadcopter.ino
@@ -25,8 +25,14 @@
 // RX
 int throttle = THROTTLE_RMIN;
 volatile int input[4];
-unsigned long timer[4];
-byte last_channel[4];
+volatile unsigned long chrono_start0;
+volatile unsigned long chrono_start1;
+volatile unsigned long chrono_start2;
+volatile unsigned long chrono_start3;
+volatile int last_interrupt_time0;
+volatile int last_interrupt_time1;
+volatile int last_interrupt_time2;
+volatile int last_interrupt_time3;

 // IMU
 float roll_speed, roll_angle;
@@ -98,18 +104,83 @@

 //TODO: fonction qui lit les interrupts pour une execution plus rapide(pas encore)
 void rx_initialize() {
-  pinMode(A0, INPUT);
-  pinMode(A1, INPUT);
-  pinMode(A2, INPUT);
-  pinMode(A3, INPUT);
-}
-
-// Fonction qui lit les valeurs de la radio
-void rx_read() {
-  input[0] = pulseIn(A0, HIGH);
-  input[1] = pulseIn(A1, HIGH);
-  input[2] = pulseIn(A2, HIGH);
-  input[3] = pulseIn(A3, HIGH);
+  attachInterrupt(A0, calcSignal0, CHANGE);
+  attachInterrupt(A1, calcSignal1, CHANGE);
+  attachInterrupt(A2, calcSignal2, CHANGE);
+  attachInterrupt(A3, calcSignal3, CHANGE);
+}
+
+// Fonctions qui lisent les valeurs de la radio
+void calcSignal0()
+{
+    last_interrupt_time0 = micros();
+
+    if(digitalRead(A0) == HIGH)
+    {
+        chrono_start0 = micros();
+    }
+    else
+    {
+        if(chrono_start0 != 0)
+        {
+            input[0] = ((volatile int)micros() - chrono_start0);
+            chrono_start0 = 0;
+        }
+    }
+}
+
+void calcSignal1()
+{
+    last_interrupt_time1 = micros();
+
+    if(digitalRead(A1) == HIGH)
+    {
+        chrono_start1 = micros();
+    }
+    else
+    {
+        if(chrono_start1 != 0)
+        {
+            input[1] = ((volatile int)micros() - chrono_start1);
+            chrono_start1 = 0;
+        }
+    }
+}
+
+void calcSignal2()
+{
+    last_interrupt_time2 = micros();
+
+    if(digitalRead(A2) == HIGH)
+    {
+        chrono_start2 = micros();
+    }
+    else
+    {
+        if(chrono_start2 != 0)
+        {
+            input[2] = ((volatile int)micros() - chrono_start2);
+            chrono_start2 = 0;
+        }
+    }
+}
+
+void calcSignal3()
+{
+    last_interrupt_time3 = micros();
+
+    if(digitalRead(A3) == HIGH)
+    {
+        chrono_start3 = micros();
+    }
+    else
+    {
+        if(chrono_start3 != 0)
+        {
+            input[3] = ((volatile int)micros() - chrono_start3);
+            chrono_start3 = 0;
+        }
+    }
 }

 // Fonction qui s'execute une fois et au début
@@ -155,7 +226,6 @@
   Serial.print(",");
   Serial.println(pid_yaw_setpoint);
 }
-
 void print_imu() {
   Serial.print(pid_roll_speed_in);
   Serial.print(",");
@@ -176,8 +246,7 @@

 // Fonction qui s'execute a chaque cycle
 void loop() {
-  rx_read();
   bno_get_values();
   control_update();
-  print_rx();
-}
+  print_motors();
+}


WIP Code

WIP Code

--- research/DCF-RTC/DCF-RTC.ino
+++ research/DCF-RTC/DCF-RTC.ino
@@ -3,11 +3,11 @@
  * example code illustrating time synced from a DCF77 receiver
  * Thijs Elenbaas, 2012
  * This example code is in the public domain.
-
-  This example shows how to fetch a DCF77 time and synchronize
-  the internal clock. In order for this example to give clear output,
-  make sure that you disable logging  from the DCF library. You can
-  do this by commenting out   #define VERBOSE_DEBUG 1   in Utils.cpp.
+
+ This example shows how to fetch a DCF77 time and synchronize
+ the internal clock. In order for this example to give clear output,
+ make sure that you disable logging  from the DCF library. You can
+ do this by commenting out   #define VERBOSE_DEBUG 1   in Utils.cpp.
  */

 #include <DCF77.h>       //https://github.com/thijse/Arduino-Libraries/downloads
@@ -22,11 +22,67 @@
 time_t time;
 DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);

+struct word_t
+{
+  int index;
+  int length;
+};

+int words(int minutesOfDay, word_t* buffer);
+
+
+const word_t WORT_ES = {0, 2};
+ const word_t WORT_IST = {3, 3};
+ const word_t MINUTE_FUENF = {7, 4};
+ const word_t MINUTE_ZEHN = {11, 4};
+ const word_t MINUTE_FUENFZEHN = {7, 8};
+ const word_t MINUTE_ZWANZIG = {15, 7};
+ const word_t MINUTE_DREIVIERTEL = {22, 11};
+ const word_t MINUTE_VIERTEL = {26, 7};
+ const word_t WORT_NACH = {35, 4};
+ const word_t WORT_VOR = {39, 3};
+ const word_t MINUTE_HALB = {44, 4};
+ const word_t STUNDE_ZWOELF = {49, 5};
+ const word_t STUNDE_ZWEI = {55, 4};
+ const word_t STUNDE_EIN = {57, 3};
+ const word_t STUNDE_EINS = {57, 4};
+ const word_t STUNDE_SIEBEN = {60, 6};
+ const word_t STUNDE_DREI = {67, 4};
+ const word_t STUNDE_FUENF = {73, 4};
+ const word_t STUNDE_ELF = {77, 3};
+ const word_t STUNDE_NEUN = {80, 4};
+ const word_t STUNDE_VIER = {84, 4};
+ const word_t STUNDE_ACHT = {89, 4};
+ const word_t STUNDE_ZEHN = {93, 4};
+ const word_t STUNDE_SECHS = {100, 5};
+ const word_t WORT_UHR = {107, 3};
+
+const word_t* MINUTE_WORDS[] = {
+ 0, &MINUTE_FUENF,
+ &MINUTE_ZEHN, &MINUTE_VIERTEL, &MINUTE_ZWANZIG,
+ &MINUTE_FUENF, &MINUTE_HALB, &MINUTE_FUENF,
+ &MINUTE_ZWANZIG, &MINUTE_VIERTEL, &MINUTE_ZEHN,
+ &MINUTE_FUENF
+ };
+
+ const word_t* CONNECTOR_WORDS[] = {
+ 0, &WORT_NACH,
+ &WORT_NACH, &WORT_NACH, &WORT_NACH, &WORT_VOR,
+ 0, &WORT_NACH, &WORT_VOR, &WORT_VOR, &WORT_VOR,
+ &WORT_VOR
+ };
+
+ const word_t* HOUR_WORDS[] = {
+ &STUNDE_ZWOELF,
+ &STUNDE_EINS, &STUNDE_ZWEI, &STUNDE_DREI,
+ &STUNDE_VIER, &STUNDE_FUENF, &STUNDE_SECHS,
+ &STUNDE_SIEBEN, &STUNDE_ACHT, &STUNDE_NEUN,
+ &STUNDE_ZEHN, &STUNDE_ELF
+ };

 void setup() {
   Serial.begin(9600);
-
+
   Serial.println("Setting system clock from RTC module");
   setSyncProvider(RTC.get);
   DCF.Start();
@@ -38,10 +94,10 @@
   Serial.println("Waiting for DCF77 time ... ");
   Serial.println("It will take at least 2 minutes until a first update can be processed.");
   while(timeStatus()== timeNotSet) {
-     // wait until the time is set by the sync provider
-     Serial.print("RTC: ");
-     digitalClockDisplay();
-     delay(2000);
+    // wait until the time is set by the sync provider
+    Serial.print("RTC: ");
+    digitalClockDisplay();
+    delay(2000);
   }
 }

@@ -50,14 +106,53 @@
 {
   if( now() != prevDisplay) //update the display only if the time has changed
   {
-    prevDisplay = now();
-    digitalClockDisplay();
+
   }
+}
+
+int words(int minutesOfDay, word_t* buffer)
+{
+ int bufferIndex = 0;
+  /*
+  int hours = (minutesOfDay + 2) / 60;
+ int minutes = (minutesOfDay + 2) % 60;
+ int minuteIndex = minutes / 5;
+ int hourIndex = hours % 12;
+
+ buffer[bufferIndex++] = &WORT_ES;
+ buffer[bufferIndex++] = &WORD_IST;
+
+ buffer[bufferIndex++] = MINUTE_WORDS[minuteIndex];
+ buffer[bufferIndex++] = CONNECTOR_WORDS[minuteIndex];
+
+ if (minuteIndex == 5 || minuteIndex == 7)
+ {
+ buffer[bufferIndex++] = &MINUTE_HALB;
+ }
+
+ if (minuteIndex == 0 && hourIndex == 1)
+ {
+ buffer[bufferIndex++] = &STUNDE_EIN;
+ }
+ else
+ {
+ if (minuteIndex > 4)
+ {
+ hourIndex = (hourIndex + 1) % 12;
+ }
+ buffer[bufferIndex++] = HOUR_WORDS[hourIndex];
+ }
+
+ if (minuteIndex == 0)
+ {
+ buffer[bufferIndex++] = WORT_UHR;
+ }
+ */
+ return bufferIndex;
 }

 void digitalClockDisplay(){
   // digital clock display of the time
-  Serial.println("");
   Serial.print(hour());
   printDigits(minute());
   printDigits(second());
@@ -83,9 +178,12 @@
   time_t DCFtime = DCF.getTime();
   // Indicator that a time check is done
   if (DCFtime!=0) {
-    Serial.println("Updating RTC...");
+    Serial.println("Reiceived DCF77 time signal, updating RTC...");
+    void digitalClockDisplay();
     // set the RTC
     RTC.set(DCFtime);
   }
   return DCFtime;
 }
+
+


Finetuning: Use better timeouts

Finetuning: Use better timeouts

--- Kleineswetter/Kleineswetter.ino
+++ Kleineswetter/Kleineswetter.ino
@@ -34,6 +34,7 @@
 SystemState systemState;

 unsigned long connectInvainThreshold = 8 * 60 * 1000L; // some minutes
+unsigned int connectTryThreshold = 7000;

 void setup() {
   unsigned long systemStart = millis();
@@ -64,7 +65,7 @@
   float h = 76.5 - random(5);

   if (bme_ok) {
-    delay(150);
+    delay(250);
     t = bme.readTemperature() - 1;
     h = bme.readHumidity();

@@ -120,7 +121,7 @@
   unsigned long connectStart = millis();
   while (WiFi.status() != WL_CONNECTED) {
     unsigned long now = millis();
-    if (now - connectStart > 5000) {
+    if (now - connectStart > connectTryThreshold) {
       sleepNowForFailedConnect(5000L, now - systemStart);

       /*


AES-128

--- experiments/crypto/crypto.ino
+++ experiments/crypto/crypto.ino
@@ -1,29 +1,33 @@

 /**
- * Speck-256-ECB
+ * AES-128-ECB
+ *
+ * https://rweather.github.io/arduinolibs/crypto.html
+ * https://github.com/rweather/arduinolibs/tree/master/libraries/Crypto
  */

 #include <Crypto.h>
-#include <SpeckSmall.h>
+#include <AES.h>
 #include "Payload.h"
 #include "GardenPayload.h"
+
+#define ENCRYPTION_BUFFER_SIZE 32

 uint8_t msg_id = 0;
 theapi::GardenPayload payload = theapi::GardenPayload();

-byte key[32] = {0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
-              0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
-              0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
-              0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};

-SpeckSmall cipher;
-byte encrypted_buffer[theapi::GardenPayload::SIZE];
+byte key[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+
+AES128 cipher;
+uint8_t encrypted_buffer[ENCRYPTION_BUFFER_SIZE];
+uint8_t decrypted_buf[ENCRYPTION_BUFFER_SIZE];

 void setup() {
   Serial.begin(115200);
   Serial.println();
-
-  cipher.setKey(key, 32);
+  Serial.println("Setup");

   payload.setMsgId(msg_id);
   payload.setVcc(1234);
@@ -35,18 +39,20 @@

 }

+
 void loop() {

   payload.setMsgId(++msg_id);
+  Serial.print("Encrypting msg_id: ");
+  Serial.println(msg_id);

   uint8_t payload_buf[payload.size()];
   payload.serialize(payload_buf);
-
+
   // Encrypt
   cipher.encryptBlock(encrypted_buffer, payload_buf);

   // Decrypt
-  uint8_t decrypted_buf[payload.size()];
   cipher.decryptBlock(decrypted_buf, encrypted_buffer);
   payload.unserialize(decrypted_buf);


bugfix: NCOLOURS should be number of elements, not bytes

--- Xmas2013/Rainbow/Rainbow.ino
+++ Xmas2013/Rainbow/Rainbow.ino
@@ -43,7 +43,7 @@
 // Colour table for rainbow
 const int COLOURS[] = {COLOR_RED, COLOR_ORANGE, COLOR_YELLOW, COLOR_GREEN, COLOR_BLUE,
                        COLOR_INDIGO, COLOR_VIOLET};
-const int NCOLOURS = sizeof(COLOURS);
+const int NCOLOURS = sizeof(COLOURS)/sizeof(int);

 // Counter - to insert a long pause, occasionally
 int pause = 0;


Update RandomPlay.ino

Update RandomPlay.ino

--- examples/RandomPlay/RandomPlay.ino
+++ examples/RandomPlay/RandomPlay.ino
@@ -68,7 +68,7 @@

 void loop() {

-  //  ** NOTE: Checking for STOPPED doesn't work with the builtin memory z
+  //  ** NOTE: Checking for STOPPED doesn't work with the builtin memory
   //      because in that case the devie appears to only return PAUSED, not STOPPED
   byte stat = mp3.getStatus();
   if(stat != MP3_STATUS_PLAYING)


handle space character. Add spark cloud API.

--- SparkCode/SparkLedMatrix.ino
+++ SparkCode/SparkLedMatrix.ino
@@ -4,70 +4,99 @@

 uint8_t data = A5;
 uint8_t load = A4;
-uint8_t myclock = A3;
-
-byte spaceChar = 0;
+uint8_t clk = A3;

 uint8_t displayCount = 2;
 uint8_t colsPerDisplay = 8;
 uint8_t maxCols = displayCount * colsPerDisplay;

+char message[64];
+char recvBuffer[64];
+int recvBufferLength = 0;
+bool newMessage = false;
+
 void setup() {
-    led = new LedControl(data, myclock, load, displayCount); //DIN,CLK,CS,HowManyDisplays
+    led = new LedControl(data, clk, load, displayCount); // DIN, CLK, CS, HowManyDisplays

     for (int i = 0; i < displayCount; i++) {
         led->shutdown(i,false);
         led->setIntensity(i,8);
     }
+
+    Spark.variable("recvBuffer", recvBuffer, STRING);
+    Spark.function("display", displayMessage);
 }

 void loop() {
-    scrollTextTrimSpaces("hello, world!", 13, 100);
+    if (newMessage) {
+        strcpy(message, recvBuffer);
+        newMessage = false;
+    }
+
+    scrollTextTrimSpaces(message, recvBufferLength, 50);
     delay(1000);
 }

+int displayMessage(String msg)
+{
+    recvBufferLength = msg.length() + 1;
+    msg.toCharArray(recvBuffer, recvBufferLength);
+    newMessage = true;
+    return recvBufferLength - 1;
+}
+
 void scrollTextTrimSpaces(char *message, int messageLength, int speed) {
-    // First compute the column table.
+    const byte emptyColumn = 0;
+    const byte spaceWidth = 4;
+
     byte columns[messageLength * 8 + maxCols * 2]; // 8 columns per letter by default + 2 times blank screens (before / after the message)
     bool alreadyHasSpace = false;
     int currentColumnIndex = 0;

+    // STEP 1: Compute the column table
     // add some space at the beginning
     for (int i = 0; i < maxCols; i++) {
-        columns[currentColumnIndex] = spaceChar;
+        columns[currentColumnIndex] = emptyColumn;
         currentColumnIndex++;
     }

     // scroll through letters and for each letter, copy columns, trimming all but one whitespace column.
     for(int i = 0; i < messageLength; i++) {
-        for (int j = 0; j < 8; j++) {
-            byte candidate = cp437_font[message[i]][j];
-
-            if (alreadyHasSpace && candidate == spaceChar) {
-                continue;
-            } else if (alreadyHasSpace && candidate != spaceChar) {
-                alreadyHasSpace = false;
-            } else if (!alreadyHasSpace && candidate == spaceChar) {
-                alreadyHasSpace = true;
+        if (message[i] == ' ') {
+            for (int j = 0; j < spaceWidth; j++) {
+                columns[currentColumnIndex] = emptyColumn;
+                currentColumnIndex++;
             }
+        } else {
+            for (int j = 0; j < 8; j++) {
+                byte candidate = cp437_font[message[i]][j];

-            columns[currentColumnIndex] = candidate;
-            currentColumnIndex++;
+                if (alreadyHasSpace && candidate == emptyColumn) {
+                    continue;
+                } else if (alreadyHasSpace && candidate != emptyColumn) {
+                    alreadyHasSpace = false;
+                } else if (!alreadyHasSpace && candidate == emptyColumn) {
+                    alreadyHasSpace = true;
+                }
+
+                columns[currentColumnIndex] = candidate;
+                currentColumnIndex++;
+            }
         }
     }

     // add some space at the end
     for (int i = 0; i < maxCols; i++) {
-        columns[currentColumnIndex] = spaceChar;
+        columns[currentColumnIndex] = emptyColumn;
         currentColumnIndex++;
     }

-    // clear displays
+    // STEP 2: clear displays
     for (int i = 0; i < displayCount; i++) {
         led->clearDisplay(i);
     }

-    // then scroll through the columns table and draw each time.
+    // STEP 3: scroll through the columns table and draw each time.
     for (int j = 0; j < currentColumnIndex - maxCols - 1; j++) {
         for(int i = maxCols; i >= 0; i--) {
             led->setColumn(i / colsPerDisplay, i % colsPerDisplay, columns[maxCols - i + j]);


Remove unused var.

Remove unused var.

--- temptask.ino
+++ temptask.ino
@@ -4,8 +4,6 @@
   {
     for ( byte thisSensor = 1; thisSensor <= numberOfFoundSensors; thisSensor++)
     {
-      byte data[12];
-
       ds.reset();
       ds.select( sensor[thisSensor].addr );
       ds.write( 0x44, 0);        // start conversion, with parasite power off at the end


Update victoria_teensy_ros_node.ino

Update victoria_teensy_ros_node.ino

Fixed bug with imu and magnetometer publish frequency.

--- Arduino/victoria_teensy_ros_node/victoria_teensy_ros_node.ino
+++ Arduino/victoria_teensy_ros_node/victoria_teensy_ros_node.ino
@@ -197,12 +197,12 @@

   int publish_imu_freq_hz;
   if (!ros_nh.getParam("publish_imu_freq_hz", &publish_imu_freq_hz)) {
-    publish_odom_freq_hz = 2;
+    publish_imu_freq_hz = 2;
   }

   int publish_magnetometer_freq_hz;
   if (!ros_nh.getParam("publish_magnetometer_freq_hz", &publish_magnetometer_freq_hz)) {
-    publish_odom_freq_hz = 2;
+    publish_magnetometer_freq_hz = 2;
   }

   // Initialize broadcasters
@@ -516,4 +516,3 @@
   ros_magnetometer_debug_pub.publish(&ros_debug_msg);
 }
 #endif
-


Firmware 2.0-240218. Fixed wrong story adressing

--- src/V20/tools/NOKO_EEPROM/NOKO_EEPROM.ino
+++ src/V20/tools/NOKO_EEPROM/NOKO_EEPROM.ino
@@ -1,11 +1,11 @@
 /*
- * NOKO Settings Disk1 V1.02 24.08.2017 - Nikolai Radke
+ * NOKO EEPROM writer V2.0 26.02.2017 - Nikolai Radke
  *
  * This sketch writes the event poems, phrases and stuff into 24LC256.
  * Umlaute are converted, NOKOs LCD uses another charset!
  * #=ä, $=ö, %=ü, *=ß. I never used capital letters.
  *
- * NOTE: Flashing takes about 20 Minutes!
+ * NOTE: Flashing takes about 18 Minutes!
  *       If you are using Windows10, uncommend line 17.
  *
  * See README in folder write_eeprom..


binary pulse count

binary pulse count


Adds battery log to status

Adds battery log to status

--- status.ino
+++ status.ino
@@ -4,8 +4,6 @@
 }

 void status_show() {
-  oled.fillScreen(COLOR_BLACK);
-
   uint8_t ypos = 0;

   dtostrf(Xadow.getBatVol(), 1, 1, _sbuf2);
@@ -13,15 +11,16 @@
   oled.drawString(_sbuf, 0, ypos, FONT_SIZE, STATUS_COLOR);

   ypos += LINE_SPACING;
+
   char *s;
   switch(Xadow.getChrgState()) {
-    case NOCHARGE:
-      s = "Not Charging";
-      break;
+      case NOCHARGE:
+        s = "Not Charging";
+        break;

-     case CHARGING:
-       s = "Charging";
-       break;
+      case CHARGING:
+        s = "Charging";
+        break;

       case CHARGDONE:
         s = "Done Charging";
@@ -31,5 +30,11 @@
          s = "UNKNOWN";
   }
   oled.drawString(s, 0, ypos, FONT_SIZE, STATUS_COLOR);
-
+
+  ypos += LINE_SPACING;
+
+  if (logbat) s = "Logging Battery";
+  else s = "Batt log exists";
+
+  oled.drawString(s, 0, ypos, FONT_SIZE, STATUS_COLOR);
 }


fix json format

fix json format

--- plant-monitor/plant-monitor.ino
+++ plant-monitor/plant-monitor.ino
@@ -62,12 +62,13 @@
               delay(1);
         }
       }
+      lastPost = 0;
     }
 }

 int postToParticle(int status) {
   char publishString[128];
-  sprintf(publishString,"{\"status\": \"%d\", \"temp\": \"%0.2f\", \"pressure\": %0.2f, \"humidity\": %0.2f}",status, temperature, pressure, humidity);
+  sprintf(publishString,"{\"status\": %d, \"temp\": %0.2f, \"pressure\": %0.2f, \"humidity\": %0.2f}",status, temperature, pressure, humidity);
   Particle.publish("sensor",publishString);
   return 1;
 }


Update hello.ino

Update hello.ino

--- hello-world/hello.ino
+++ hello-world/hello.ino
@@ -1,11 +1,10 @@
-
 #include "kriFram.h"

 void setup() {
   // initialize framework.
   kriFramSetup();

-  Setting("call","Callibrate");
+  kriFramAddSettings("call","Callibrate");
   server.on ( "/home", handleRoot );
   server.on ( "/", handleRoot );

@@ -25,6 +24,6 @@

 void handleRoot() {
   String body = "Hello World!";
-  server.send ( 200, "text/html", headder + body + footer );
+  server.send ( 200, "text/html", kriFramHeadder + body + kriFramFooter );
   Serial.println ( "root page sent" );
 }


9:22 1/12

9:22 1/12

--- MTM_MODULE.ino
+++ MTM_MODULE.ino
@@ -2,7 +2,7 @@

 #include <Wire.h>
 #define commandSize 6
-#define returnSize  3
+#define returnSize  6
 #define IN1PIN      3
 #define IN2PIN      5
 #define IN3PIN      6
@@ -25,13 +25,10 @@
 byte motor2Speed=0;
 char motor1Status;
 char motor2Status;
+
 void setup(){
     noInterrupts();
     //Serial.begin(9600);
-    // for(int i=0;i<dip;i++){
-    //     pinMode(dipPins[i],INPUT);
-    //     digitalWrite(dipPins[i],HIGH);
-    // }
     for(int i=0;i<4;i++){			//configures inPins
         pinMode(inPins[i],OUTPUT);
     }
@@ -40,74 +37,65 @@
     }
     //addr=address();
     readyData=false;
-    Wire.onRequest(requestHandler);
-    Wire.onReceive(receiveHandler);
+    Wire.onRequest(requestHandler); //calls requestH upon data request from master
+    Wire.onReceive(receiveHandler); //calls receiveH upon receiving data
 }
-byte address(){
-    byte j=0;
-    for(int i=0;i<dip;i++){
-        j=(j<<1)|digitalRead(dipPins[i]);
-    }
-    return j;
-}
-void requestHandler()
-{
+void requestHandler(){
     Wire.write(outData,commandSize);
 }
-void receiveHandler(int numBytes)
-{
+void receiveHandler(int numBytes){
     int i=0;
-    while(Wire.available())
-    {
+    while(Wire.available() && i<commandSize){
         inData[i]=Wire.read();
         i++;
     }
-    readyData=true;
+
+    readyData=true;
 }
-void loop()
-{
-    if(readyData)
-    {
-        for(int i=0;i<6;i++)
-            curData[i]=inData[i];
-        readyData=false;
+
+
+void loop(){
+    if(readyData){
+        for(int i=0;i<commandSize;i++){
+            curData[i] = inData[i];
+            outData[i] = inData[i];
+        }
+        readyData = false;
     }
     command();
 }
-void command()
-{
-    switch(curData[0])
-    {
-        case 0:
-            if(curData[1])
-                motorForward(0,curData[2]);
-            else
-                motorBackward(0,curData[2]);
-            if(curData[3])
-                motorForward(1,curData[4]);
-            else
-                motorBackward(1,curData[4]);
+void command(){ //motor controls
+//0: mode 		1: pump#		2: dir 		3: rate
+	//run until master sends STOP
+	//reset - get rid of air bubbles
+	//calibrate mode - test flow speed
+	//clear - get rid of all liquid
+    switch(curData[0]){
+        case 0: //run motor
+            if(curData[1]==0)	//pump0
+                runMotor(0,curData[2], curData[3]);
+            else 			 	//pump1
+            	runMotor(1,curData[2], curData[3]);
         break;
-        case 1:
-            motorBrake(0);
+        case 1://SSR x2 for sugar water and tea
+
         break;
-        case 2:
-            motorBrake(1);
+        default: //ping
         break;
     }
 }
-void motorForward(int motor,byte speed)
+void runMotor(int motor, byte dir, byte speed)
 {
-    analogWrite(inPins[motor*2],0);
-    analogWrite(inPins[motor*2+1],speed);
+    if(dir==0){ //stop
+    	analogWrite(inPins[motor],255);
+    	analogWrite(inPins[motor+1],255);
+    }
+    if(dir==1){ //forward
+	    analogWrite(inPins[motor*2],0);
+	    analogWrite(inPins[motor*2+1],speed);
+	}
+	else if(dir==2){ //backward
+		analogWrite(inPins[motor*2],speed);
+    	analogWrite(inPins[motor*2+1],0);
+	}
 }
-void motorBackward(int motor,byte speed)
-{
-    analogWrite(inPins[motor*2],speed);
-    analogWrite(inPins[motor*2+1],0);
-}
-void motorBrake(int motor)
-{
-    analogWrite(inPins[motor],255);
-    analogWrite(inPins[motor+1],255);
-}


Use chars instead of ints. Init sequence seems to work again..


SetTime: added support for binary sequences


added comment

added comment

--- Arduino/hardware/REV10/REV10SecureBHR/REV10SecureBHR.ino
+++ Arduino/hardware/REV10/REV10SecureBHR/REV10SecureBHR.ino
@@ -526,12 +526,11 @@
                     (realTXFrameStart - offset),
                     (MSG_BUF_SIZE - (realTXFrameStart-sW.buf) + offset));

-            // Assumed to be at least one free writeable byte ahead of bptr.
-            // Get current modelled valve position.
+            // Assumed to be at least one free writable byte ahead of bptr.
             const uint8_t bodylen = OTRadioLink::SimpleSecureFrame32or0BodyTXV0p2::getInstance().encodeValveFrame(
                                         fd,
                                         txIDLen,
-                                        0x7f,
+                                        0x7f, // As no valve present.
                                         eW,
                                         subScratch,
                                         key);


Delete AppManager.ino

Delete AppManager.ino

--- AppManager.ino
+++ AppManager.ino
@@ -1,88 +0,0 @@
-/*!
- * @file
- * @author Dan Nixon
- * @brief Example with application manager. Intended to be used as the badge
- *        firmware.
- */
-
-/* #include <GDBStub.h> */
-
-#include <SPI.h>
-#include <Wire.h>
-#include <Adafruit_GFX.h>
-#include <Adafruit_NeoPixel.h>
-#include <Adafruit_ILI9341.h>
-
-#include <Adafruit_MCP23017.h>
-#include <Dilbert.h>
-#include <AppManager.h>
-#include <MenuApp.h>
-#include <ButtonTestApp.h>
-#include <SystemSettingsApp.h>
-
-#include "ProfileApp.h"
-#include "StarsApp.h"
-#include "DilbertApp.h"
-
-/* #define USE_BUTTON_INTERRUPTS */
-
-Dilbert badge;                 //!< Badge driver
-AppManager appManager(&badge); //!< Badge application manager
-
-#ifdef USE_BUTTON_INTERRUPTS
-volatile bool gpio_interrupt;
-#endif
-
-void setup()
-{
-  badge.begin();
-
-  /* Add the app menu application
-   * Typically this shoud always be the first added */
-  appManager.addApp(new MenuApp(2));
-
-  /* Add other applications */
-  appManager.addApp(new SystemSettingsApp());
-  appManager.addApp(new ProfileApp());
-  appManager.addApp(new ButtonTestApp());
-  appManager.addApp(new StarsApp());
-  appManager.addApp(new DilbertApp());
-
-  /* Small delay before app manager start (which turns on backlight) */
-  delay(100);
-
-  /* Must call this after adding all apps */
-  appManager.begin();
-
-#ifdef USE_BUTTON_INTERRUPTS
-  /* Button interrupt setup */
-  gpio_interrupt = false;
-  attachInterrupt(Dilbert::MCP23017_INT_GPIO, handle_int, FALLING);
-#endif
-}
-
-void loop()
-{
-  appManager.run();
-
-#ifdef USE_BUTTON_INTERRUPTS
-  if (gpio_interrupt)
-  {
-    badge.buttons().poll();
-    gpio_interrupt = false;
-  }
-#else
-  badge.buttons().poll();
-#endif
-}
-
-#ifdef USE_BUTTON_INTERRUPTS
-/**
- * @brief Handle MCP23017 interrupt.
- */
-void handle_int()
-{
-  gpio_interrupt = true;
-}
-#endif
-


Accounted for new, high density pixel strip

--- RibbonLEDs.ino
+++ RibbonLEDs.ino
@@ -4,6 +4,7 @@
 #endif

 #define PIN 6
+#define N_LEDS 74

 //  The overall fire brightness
 //  (this can affect both color levels and power consumption)
@@ -21,9 +22,6 @@
   { 226, 15, 30}    // Red flame
   };

-//  Number of flame colors
-int NUMBER_OF_COLORS = sizeof(flameColors) / sizeof(RGB);
-
 //  Tracks the current color
 int currentColorIndex = 0;

@@ -34,7 +32,7 @@
 //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
 //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
 //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(74, PIN, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

 // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
 // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
@@ -54,7 +52,7 @@
   RGB currentColor = flameColors[currentColorIndex];

  //  Flicker, based on our initial RGB values
-  for(int i=4; i<13; i++) {
+  for(int i=9; i<29; i++) {
     int flicker = random(0,85);
     int r1 = currentColor.r-flicker;
     int g1 = currentColor.g-flicker;


ordered the tests to match order in Table 13-2. General-Purpose Timers Signals, added debug prints to figure out PWWrite hanging


switch off LED if no serial for 1 sec

switch off LED if no serial for 1 sec

--- XbmcSwitch.ino
+++ XbmcSwitch.ino
@@ -1,8 +1,8 @@
 int pushButton = 2;
-int switchLed = 13;
 int mainLed = 6;

 int switchState = 1;
+int noSerialCount = 0;

 #define ON 49	// 1
 #define OFF 48	// 0
@@ -16,15 +16,16 @@
 	// turn on pullup resistor
 	digitalWrite(pushButton, HIGH);

-	// output LED ports
-	pinMode(switchLed, OUTPUT);
+	// output port for LED
 	pinMode(mainLed, OUTPUT);
 }

 void loop(){
+	int serialRead = -1;
+
 	if (Serial.available() > 0) {
 		// read over serial port
-		int serialRead = Serial.read();
+		serialRead = Serial.read();

 		// set LED on/off from serial
 		if(serialRead == ON) {
@@ -33,22 +34,28 @@
 			digitalWrite(mainLed, 0);
 		}

-		// check for button press
-		int sensorRead = digitalRead(pushButton);
+		noSerialCount = 0;
+	}else{
+		noSerialCount += 1;

-		if(switchState != sensorRead) {
-			switchState = sensorRead;
+		// if no serial input for 1 second, switch off LED
+		if(noSerialCount == 5) {
+			digitalWrite(mainLed, 0);
+		}
+	}

-			// send on serial when switch pushed
-			if(sensorRead == 0) {
-				Serial.println(serialRead);
-			}
+	// check for button press
+	int sensorRead = digitalRead(pushButton);
+
+	if(switchState != sensorRead) {
+		switchState = sensorRead;
+
+		// send on serial when switch pushed
+		if(sensorRead == 0) {
+			Serial.println(serialRead);
 		}
+	}

-		// write the inverted switch value to the LED
-		digitalWrite(switchLed, !sensorRead);
-
-		// introduce a sensible delay
-		delay(100);
-	}
+	// introduce a sensible delay
+	delay(100);
 }


updated for demo (not completed)

updated for demo (not completed)

--- devices/cc3200_launchpad/example_energia_led/example_energia_led.ino
+++ devices/cc3200_launchpad/example_energia_led/example_energia_led.ino
@@ -10,6 +10,8 @@
 #include <WiFiClient.h>
 #include <aJSON.h>

+#define USE_UART
+
 #define DEFAULT_UDP_MEMBERSHIP  "225.0.0.37"
 #define DEFAULT_UDP_PORT  21928

@@ -18,10 +20,12 @@
 volatile int green_state = LOW;

 //access point should only work for b and g
-char ssid[] = "hellfire";
+char ssid[] = "nsynapseap";
 char password[] = "elec6887";
 WiFiServer server(8000);
 WiFiUDP Udp;
+byte mac[6];
+String mac_string;

 enum {IDLE = 0, ANNOUNCE=100, SERVICE=200 };
@@ -37,8 +41,11 @@
   digitalWrite(GREEN_LED, LOW);
   digitalWrite(YELLOW_LED, LOW);
   digitalWrite(RED_LED, LOW);
-
+
+#ifdef USE_UART
   Serial.begin(115200);
+#endif
+
   WiFi.begin(ssid, password);

   while(WiFi.status()!=WL_CONNECTED) {
@@ -51,14 +58,26 @@
     delay(300);
   }

+  WiFi.macAddress(mac);
+  for(int i=0;i<sizeof(mac);i++) {
+    mac_string += String(mac[sizeof(mac)-1-i],HEX);
+    if(i<(sizeof(mac)-1))
+      mac_string += ":";
+  }
+
   printWifiStatus();
+
   server.begin();
   Udp.begin(DEFAULT_UDP_PORT);

   //device profile
   if(announce) {
-    aJson.addStringToObject(announce, "devicename", "TI_cc3200_2");
-    aJson.addStringToObject(announce, "componentname", "cc3200led");
+    aJson.addStringToObject(announce, "uuid", "f2c958a3-1b8f-44e5-a725-78377066e983");  //dummy code
+    aJson.addStringToObject(announce, "devicename", "TI-CC3200");
+    aJson.addStringToObject(announce, "mac", mac_string.c_str());
+    aJson.addStringToObject(announce, "manufacturer", "Texas Instrument");
+    aJson.addStringToObject(announce, "author", "cossb");
+    aJson.addStringToObject(announce, "component", "cc3200led");
     aJson.addStringToObject(announce, "protocol", "tcp");
     aJson.addNumberToObject(announce, "port", 8000);
     aJson.addStringToObject(announce, "command","auth");
@@ -111,7 +130,6 @@
             char data = client.read();
            if(data=='}')
            {
-             Serial.print(buffer);
              memset(buffer, 0, 1024);
            }
            else
@@ -127,7 +145,7 @@

 void printWifiStatus()
 {
-
+#ifdef USE_UART
   // print the SSID of the network you're attached to:
   Serial.print("SSID: ");
   Serial.println(WiFi.SSID());
@@ -142,7 +160,20 @@
   Serial.print("signal strength (RSSI):");
   Serial.print(rssi);
   Serial.println(" dBm");
-
+
+  Serial.print("MAC: ");
+  Serial.print(mac[5],HEX);
+  Serial.print(":");
+  Serial.print(mac[4],HEX);
+  Serial.print(":");
+  Serial.print(mac[3],HEX);
+  Serial.print(":");
+  Serial.print(mac[2],HEX);
+  Serial.print(":");
+  Serial.print(mac[1],HEX);
+  Serial.print(":");
+  Serial.println(mac[0],HEX);
+#endif
 }

 boolean endsWith(char* inString, char* compString) {


Fixed payload not being sent. Programmer is working with a Sodaq ExpLoRer. Response given from the PIC inside the RN2483 is correct when requesting model number.

--- Arduino-RN2483-programmer.ino
+++ Arduino-RN2483-programmer.ino
@@ -154,7 +154,7 @@
       for (int n = 0; n < 8; n++) {
         //Lower PGC and write bit to PGD
         digitalWrite(PGC, LOW);
-        digitalWrite(PGD, bitRead(cmd, n));
+        digitalWrite(PGD, bitRead(payload, n));
         delayMicroseconds(1);

         //Raise PGC to send bit
@@ -188,7 +188,7 @@
       // Wait atleast 40ns (P5A)
       delayMicroseconds(1);
       SerialUSB.write("Sent 4 command bits and 8 data payload bits\r\nResponse: ");
-      SerialUSB.print(String(response, BIN)+"\r\n");
+      SerialUSB.print(String(response, HEX)+"\r\n");

       return response;
     } else {
@@ -196,7 +196,7 @@
       for (int n = 0; n < 16; n++) {
         //Lower PGC and write bit to PGD
         digitalWrite(PGC, LOW);
-        digitalWrite(PGD, bitRead(cmd, n));
+        digitalWrite(PGD, bitRead(payload, n));
         delayMicroseconds(1);

         //Raise PGC to send bit
@@ -242,8 +242,11 @@
         sendOp(B1001, 0x0000);
         break;
       case '3':
+        exitLVP();
+        enterLVP();
         break;
       case '4':
+        exitLVP();
         break;
       case '5':
         break;
@@ -255,4 +258,4 @@
         SerialUSB.write("Invalid input\r\n");
     }
   }
-}
+}


Documenting delays in ardutimer

Documenting delays in ardutimer

--- quick_release/quick_release.ino
+++ quick_release/quick_release.ino
@@ -14,14 +14,14 @@
 const int STIMDELAY = 250;     // in ms, between stim and shutter
 const int SHUTTERDELAY = 1000; // in µs, between shutter and length
 const int STEPDELAY = 200;     // in µs, between length and camera
-const int EXPOSUREDUR = 100;   // in µs, camera image duration
+const int EXPOSUREDUR = 100;   // in µs, camera image duration  TODO: SEND THIS ONE OVER SERIAL TOO
 const int POSTEXPOSURE = 1000; // in ms, before returning to length

 // Non-global variable declaration
 int stepdelay = STEPDELAY;
 bool run_now = false;

-// ArduTimer Hardware hconfiguration
+// ArduTimer Hardware configuration
 #define SIG1 2;
 #define LED1 3;
 #define SIG2 4;
@@ -101,24 +101,22 @@
 }

 // Control a run
-void run(int predelay, int stimdelay, int shutterdelay, int stepdelay, int exposureduration, int postexposure)
+void run(int predelay, int stimdelay, int shutterdelay, int stepdelay, int exposuredur, int postexposure)
 {
-    delay(predelay);
-    turn_stimulus(true);
-    delay(stimdelay);
-    turn_shutter(true);
-    // shutter opened before step delay
-    // may open during pre-delay in future as latency is established
-    delayMicroseconds(shutterdelay);
-    turn_length(true);
-    delayMicroseconds(stepdelay);
-    turn_exposure(true);
-    delayMicroseconds(exposureduration);
-    turn_stimulus(false);
-    turn_exposure(false);
-    turn_shutter(false);
-    delay(postexposure);
-    turn_length(false);
+    delay(predelay);                  // just to let things settle
+    turn_stimulus(true);              // shock the muscle
+    delay(stimdelay);                 // let force develop
+    turn_shutter(true);               // tell the shutter to open
+    delayMicroseconds(shutterdelay);  // let the shutter physically respond
+    turn_length(true);                // tell the length step to occur
+    delayMicroseconds(stepdelay);     // wait for the step plus propagation
+    turn_exposure(true);              // tell the camera to take a pic
+    delayMicroseconds(exposuredur);   // let the camera take a pic
+    turn_stimulus(false);             // stop shocking
+    turn_exposure(false);             // reset cam trigger
+    turn_shutter(false);              // tell the shutter to close
+    delay(postexposure);              // let the muscle rest
+    turn_length(false);               // reset (stretch) the muscle
 }

 // Series of control functions


BabelFish: Remove provisional debugging pulse

--- Utils/BabelFish/BabelFish.ino
+++ Utils/BabelFish/BabelFish.ino
@@ -457,11 +457,10 @@
         serialByte |= digitalRead(gameControllerDataPin);
         sendPulse(gameControllerPulsePin);
       }
-
-      if (serialByte == 255)
+      if (serialByte == 255)           // Skip if no button pressed
         break;
-      critical();                      // Forward byte to Gigatron
-      sendFirstByte(serialByte);
+      critical();
+      sendFirstByte(serialByte);       // Forward byte to Gigatron
       nonCritical();
     } // Loop locally while active to skip PS/2 and waitVSync

@@ -470,10 +469,6 @@
   #else
     delay(15);
   #endif
-
-  // debugging
-  PORTB &= ~gigatronDataBit;
-  PORTB |= gigatronDataBit;

   // PS/2 keyboard events
   byte key = keyboard_getState();


Add W5500 Example

Add W5500 Example


Fixed Arduino serial protocol

Fixed Arduino serial protocol

--- Arduino/Rover3Multifunction/Rover3Multifunction.ino
+++ Arduino/Rover3Multifunction/Rover3Multifunction.ino
@@ -821,25 +821,25 @@
   String otherData = "none"; // ***** PLACEHOLDER *****

   String logMessage = new String().concat(gps_latitude)
-    .concat(gps_longitude)
-    .concat(gps.f_altitude())
-    .concat(gps.f_course())
-    .concat(compass_heading)
-    .concat(gps.f_speed_kmph())
-    .concat(year)
-    .concat(month)
-    .concat(day)
-    .concat(hour)
-    .concat(minute)
-    .concat(second)
-    .concat(temperature_dht22)
-    .concat(humidity_dht22)
-    .concat(compass_pitch)
-    .concat(compass_roll)
-    .concat(fwd_range_cm)
-    .concat(rear_range_cm)
-    .concat(XbeeDataReceivedString)
-    .concat(XbeeDataSentString)
+    .concat(gps_longitude).concat(" ")
+    .concat(gps.f_altitude()).concat(" ")
+    .concat(gps.f_course()).concat(" ")
+    .concat(compass_heading).concat(" ")
+    .concat(gps.f_speed_kmph()).concat(" ")
+    .concat(year).concat(" ")
+    .concat(month).concat(" ")
+    .concat(day).concat(" ")
+    .concat(hour).concat(" ")
+    .concat(minute).concat(" ")
+    .concat(second).concat(" ")
+    .concat(temperature_dht22).concat(" ")
+    .concat(humidity_dht22).concat(" ")
+    .concat(compass_pitch).concat(" ")
+    .concat(compass_roll).concat(" ")
+    .concat(fwd_range_cm).concat(" ")
+    .concat(rear_range_cm).concat(" ")
+    .concat(XbeeDataReceivedString).concat(" ")
+    .concat(XbeeDataSentString).concat(" ")
     .concat(otherData);

   Serial.print(logmessage);


Updated file header/comments, author, documentation.

--- eeZee_microSD/examples/Arduino/microSD_Test1/microSD_Test1.ino
+++ eeZee_microSD/examples/Arduino/microSD_Test1/microSD_Test1.ino
@@ -1,22 +1,31 @@
 /*
-  SD card basic file example
-
- This example shows how to create and destroy an SD card file
- The circuit:
- * SD card attached to SPI bus as follows:
- ** MOSI - pin 11
- ** MISO - pin 12
- ** CLK - pin 13
- ** CS - pin 10
-
+  eeZee microSD test jig firmware
+
+  Tests boards with feedback via RG LED and Digole OLED display.
+
+  Creates and removes a file on the SD card. If it can do that, the
+  board is good.
+
+  SD card attached to SPI bus as follows:
+
+  MOSI - pin 11
+  MISO - pin 12
+  CLK - pin 13
+  CS - pin 10
+
+Based on example code:
  created   Nov 2010
  by David A. Mellis
+
  modified 9 Apr 2012
  by Tom Igoe
-
- This example code is in the public domain.
-
- */
+
+ modified 24 Apr 2015
+ by Michael Shimniok
+
+ MIT License
+
+*/
 #include <SD.h>
 #include <SoftwareSerial.h>


Improve NRF24L01P device driver; example sketch for client socket.

--- examples/Socket/CosaNRFclient/CosaNRFclient.ino
+++ examples/Socket/CosaNRFclient/CosaNRFclient.ino
@@ -40,8 +40,13 @@

 // Demonstrate client socket connection and periodic sending of message
 class Demo : public Client, public Periodic {
+  uint8_t m_size;
 public:
-  Demo(Socket::Device* dev, uint16_t ms) : Client(dev), Periodic(ms) {}
+  Demo(Socket::Device* dev, uint16_t ms) :
+    Client(dev),
+    Periodic(ms),
+    m_size(1)
+  {}
   virtual void on_connected();
   virtual void on_recv(const void* buf, size_t size);
   virtual void run();
@@ -70,11 +75,13 @@
   // Send a message of max payload size to server
   uint8_t msg[NRF24L01P::PAYLOAD_MAX];
   static uint8_t nr = 0;
-  for (uint8_t i = 0; i < sizeof(msg); i++)
+  for (uint8_t i = 0; i < m_size; i++)
     msg[i] = nr + i;
   trace << PSTR("Demo::run()::");
-  TRACE(send(&msg, sizeof(msg)));
+  TRACE(send(&msg, m_size));
   nr += 1;
+  m_size += 1;
+  if (m_size > sizeof(msg)) m_size = 1;
 }

 Demo client(&nrf, 1024);


Beginnings of receiving (doesn't decode correctly in IrRScrutinizer yet!)

--- ESP8266iTachEmulatorGUI/ESP8266iTachEmulatorGUI.ino
+++ ESP8266iTachEmulatorGUI/ESP8266iTachEmulatorGUI.ino
@@ -21,12 +21,12 @@
 */

 /*
- Circuit:
- To get good range, attach a resistor to pin 12 of the ESP-12E and connect the resistor to the G pin of a 2N7000 transistor.
- If you look at the flat side of the 2N7000 you have S, G, D pins.
- Connect S to GND, G to the resistor to the MCU, and D to the IR LED short pin.
- The long pin of the IR LED is connected to +3.3V.
- I picked the 2N7000 because unlike others it will not pull pin 2 down which would prevent the chip from booting.
+  Circuit:
+  To get good range, attach a resistor to pin 12 of the ESP-12E and connect the resistor to the G pin of a 2N7000 transistor.
+  If you look at the flat side of the 2N7000 you have S, G, D pins.
+  Connect S to GND, G to the resistor to the MCU, and D to the IR LED short pin.
+  The long pin of the IR LED is connected to +3.3V.
+  I picked the 2N7000 because unlike others it will not pull pin 2 down which would prevent the chip from booting.
 */

 #include <ESP8266WiFi.h>
@@ -91,9 +91,14 @@
 #include "user_interface.h"
 }

+int RECV_PIN = D1; // an IR detector/demodulatord
+IRrecv irrecv(RECV_PIN);
+decode_results results;
+
 void setup() {

   irsend.begin();
+  irrecv.enableIRIn(); // Start the receiver
   mySwitch.enableTransmit(3); // Pin 3 is RXD; 433 MHz

   ////////////
@@ -138,12 +143,47 @@
   sendDiscoveryBeacon();
 }

+String stringDecode;
+
+int clientToSendReceivedCodeTo = MAX_SRV_CLIENTS;
+
+void dump(decode_results *results) {
+  int count = results->rawlen;
+  unsigned long freq = 38400;        // FIXME DON'T HARDCODE _________________________________________
+  stringDecode = "sendir,1:0,0,";
+  stringDecode += freq;
+  stringDecode += (",1,1,");
+  for (int i = 1; i < count; i++) {
+    if (i & 1) {
+      stringDecode += results->rawbuf[i] * USECPERTICK * freq / 1000000 - 1, DEC;
+    } else
+    {
+      stringDecode += (unsigned long) results->rawbuf[i] * USECPERTICK * freq / 1000000 - 1, DEC;
+    }
+    stringDecode += ",";
+  }
+
+  Serial.println(stringDecode);
+
+  if (clientToSendReceivedCodeTo != MAX_SRV_CLIENTS) {
+    send(clientToSendReceivedCodeTo, stringDecode);
+    clientToSendReceivedCodeTo = MAX_SRV_CLIENTS;
+  }
+
+}
+
 String inData;
 String lircInData;

 void loop() {

   settings.handle();
+
+  if (irrecv.decode(&results))
+  {
+    dump(&results);
+    irrecv.resume(); // Receive the next value
+  }

   // Periodically send UDP Discovery Beacon
   unsigned long currentMillis = millis();
@@ -215,11 +255,13 @@
           }

           if (inData == "get_IRL") {
-            send(i, "IR Learner Disabled"); // TODO: Implement capture (once IRremoteESP8266 supports it)
+            send(i, "IR Learner Enabled");
+            clientToSendReceivedCodeTo = i;
+            // send(i, "sendir,1:1,4,38400,1,69,347,173,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,65,22,65,22,65,22,65,22,65,22,65,22,65,22,65,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,65,22,65,22,65,22,65,22,65,22,65,22,65,22,65,22,1527,347,87,22,3692");
           }

           if (inData == "stop_IRL") {
-            send(i, "IR Learner Disabled"); // TODO: Implement capture (once IRremoteESP8266 supports it)
+            send(i, "IR Learner Disabled");
           }

           if (inData == "getversion,0")


fix example

fix example

--- examples/OnDemandConfigPortal/OnDemandConfigPortal.ino
+++ examples/OnDemandConfigPortal/OnDemandConfigPortal.ino
@@ -22,19 +22,19 @@
 void loop() {
   // is configuration portal requested?
   if ( digitalRead(TRIGGER_PIN) == LOW) {
-    WiFiManager wifiManager;
+    WiFiManager wm;

     //reset settings - for testing
     //wifiManager.resetSettings();

     // set configportal timeout
-    wm.setConfigPortaltimeout(timeout);
+    wm.setConfigPortalTimeout(timeout);

     if (!wm.startConfigPortal("OnDemandAP")) {
       Serial.println("failed to connect and hit timeout");
       delay(3000);
       //reset and try again, or maybe put it to deep sleep
-      ESP.reset();
+      ESP.restart();
       delay(5000);
     }


Minor cleanup - Removed duplicated country list - Removed extra global variables - Optimized sprintf calls - Reduced scrollbar range - Updated title text background color

--- examples/builder/ex31_bld_listbox/ex31_bld_listbox.ino
+++ examples/builder/ex31_bld_listbox/ex31_bld_listbox.ino
@@ -114,14 +114,10 @@
 // Program Globals
 // ------------------------------------------------
 bool      m_bQuit = false;
-char      m_EmptyStr[] = "\0";
-char*     m_pEmptyStr = (char*)&m_EmptyStr;
-char      m_NewCountry[] = "New Country";
-char*     m_pNewCountry = (char*)&m_NewCountry;
-int16_t   m_nNumNewCountry = 0;
-char      m_NewCode[10];
-
-#define COUNTRY_CNT  13
+int16_t   m_nNumNewCountry = 0; // Counter for New Countries
+char      m_acNewCode[6];
+
+#define COUNTRY_CNT  12

 char m_CountryCodes[COUNTRY_CNT][4] = {
   "US",
@@ -136,10 +132,9 @@
   "PE",
   "UK",
   "VN",
-  "NEW"
 };

-char m_CountryNames[COUNTRY_CNT][15] = {
+char m_CountryNames[COUNTRY_CNT][10] = {
   "USA",
   "Brazil",
   "Canada",
@@ -152,23 +147,31 @@
   "Peru",
   "England",
   "Vietnam",
-  "New Country"
 };

-
-char* searchCountryCode(char* countryName) {
-
-   for(int i=0; i<COUNTRY_CNT-1; i++) {
-      if (strcmp(countryName,(char*)&m_CountryNames[i]) == 0) {
-         return m_CountryCodes[i];
-      }
-   }
-   // take care of case where we have "New Country1", "NewCountry2" and so on...
-   if (strncmp(countryName,m_pNewCountry,11) == 0) {
-     sprintf(m_NewCode,"%s%s","NEW",(char*)&countryName[11]);
-     return m_NewCode;
-   }
-   return m_pEmptyStr;
+// This is a basic example demonstrating a conversion
+// from full country name to a shortened country
+// code. In addition to the built-in country code
+// list, it fakes out codes for "New Country" entries.
+char* searchCountryCode(char* countryName)
+{
+  // Look through built-in list of countries
+  for(int i=0; i<COUNTRY_CNT; i++) {
+    if (strcmp(countryName,(char*)&m_CountryNames[i]) == 0) {
+      return m_CountryCodes[i];
+    }
+  }
+
+  // In this simplistic example, when dealing with "New Country##" entries,
+  // we just extract the country index from the name, ie:
+  //   "New Country5" -> "NEW5"
+  if (strncmp(countryName,"New Country",11) == 0) {
+    sprintf(m_acNewCode,"NEW%s",(char*)&countryName[11]);
+    return m_acNewCode;
+  }
+
+  // If no matches, return empty string
+  return (char*)("");
 }

@@ -199,13 +202,13 @@
     switch (pElem->nId) {
 //<Button Enums !Start!>
       case E_BTN_ADD:
-        sprintf(acTxt,"%s%d",m_pNewCountry,m_nNumNewCountry+1);
+        sprintf(acTxt,"New Country%d",m_nNumNewCountry+1);
         if (gslc_ElemXListboxInsertItemAt(&m_gui,m_pElemListbox,0,acTxt)) {
           // successfully added new country
           m_nNumNewCountry++;
           gslc_ElemSetTxtStr(&m_gui, m_pElemSel, searchCountryCode(acTxt));
         } else {
-          gslc_ElemSetTxtStr(&m_gui, m_pElemSel, m_pEmptyStr);
+          gslc_ElemSetTxtStr(&m_gui, m_pElemSel, "");
           gslc_PopupShow(&m_gui, E_PG_WARNING, true);
         }
         break;
@@ -213,7 +216,7 @@
         nSelId = gslc_ElemXListboxGetSel(&m_gui, m_pElemListbox);
         if (nSelId != XLISTBOX_SEL_NONE) {
           gslc_ElemXListboxDeleteItemAt(&m_gui,m_pElemListbox,nSelId);
-          gslc_ElemSetTxtStr(&m_gui, m_pElemSel, m_pEmptyStr);
+          gslc_ElemSetTxtStr(&m_gui, m_pElemSel, "");
         } else {
           Serial.println("No country selected for deletion");
         }
@@ -254,7 +257,7 @@
         gslc_ElemXListboxGetItem(&m_gui,m_pElemListbox,nSelId,acTxt,sizeof(acTxt));
         gslc_ElemSetTxtStr(&m_gui, m_pElemSel, searchCountryCode(acTxt));
       } else {
-        gslc_ElemSetTxtStr(&m_gui, m_pElemSel, m_pEmptyStr);
+        gslc_ElemSetTxtStr(&m_gui, m_pElemSel, "");
       }
       break;

@@ -299,6 +302,7 @@
 // ------------------------------------------------
 bool InitGUI()
 {
+  int8_t nInd;
   gslc_tsElemRef* pElemRef = NULL;

 //<InitGUI !Start!>
@@ -330,24 +334,16 @@
   gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_WHITE);
   gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_GRAY_DK3,GSLC_COL_GRAY_DK2);
   gslc_ElemXListboxSetSelFunc(&m_gui, pElemRef, &CbListbox);
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "USA");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Brazil");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Canada");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Denmark");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Germany");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "France");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "India");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Japan");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Mexico");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Peru");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "England");
-  gslc_ElemXListboxAddItem(&m_gui, pElemRef, "Vietnam");
+  // Populate the listbox with countries
+  for (nInd=0;nInd<COUNTRY_CNT;nInd++) {
+    gslc_ElemXListboxAddItem(&m_gui, pElemRef, m_CountryNames[nInd]);
+  }
   gslc_ElemSetFrameEn(&m_gui,pElemRef,true);
   m_pElemListbox = pElemRef;

   // Create vertical scrollbar for listbox
   pElemRef = gslc_ElemXSliderCreate(&m_gui,E_LISTSCROLL1,E_PG_MAIN,&m_sListScroll1,
-          (gslc_tsRect){20+200-21,75+4,20,100-8},0,100,0,5,true);
+          (gslc_tsRect){20+200-21,75+4,20,100-8},0,20,0,5,true);
   gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BLUE_LT1,GSLC_COL_BLACK,GSLC_COL_BLUE_LT1);
   gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
   m_pListSlider1 = pElemRef;
@@ -357,18 +353,15 @@
   pElemRef = gslc_ElemCreateTxt(&m_gui,E_TXT_COUNTRY_CODE,E_PG_MAIN,(gslc_tsRect){130,45,90,23},
     (char*)m_sDisplayText2,6,E_FREE_SANS9);
   gslc_ElemSetTxtAlign(&m_gui,pElemRef,GSLC_ALIGN_MID_MID);
-  gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_GRAY_DK2,GSLC_COL_BLACK);
   m_pElemSel = pElemRef;

   // Create E_LBL_COUNTRYCD text label
   pElemRef = gslc_ElemCreateTxt(&m_gui,E_LBL_COUNTRYCD,E_PG_MAIN,(gslc_tsRect){10,45,121,23},
     (char*)"Country Code:",0,E_FREE_SANS9);
-  gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_GRAY_DK2,GSLC_COL_BLACK);

   // Create E_LBL_TITLE text label
   pElemRef = gslc_ElemCreateTxt(&m_gui,E_LBL_TITLE,E_PG_MAIN,(gslc_tsRect){49,20,141,23},
     (char*)"Country Chooser",0,E_FREE_SANS9);
-  gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_GRAY_DK2,GSLC_COL_BLACK);

   // create E_BTN_ADD button with text label
   pElemRef = gslc_ElemCreateBtnTxt(&m_gui,E_BTN_ADD,E_PG_MAIN,


Fix MAC again

Fix MAC again

--- net_th_meter/net_th_meter.ino
+++ net_th_meter/net_th_meter.ino
@@ -63,7 +63,7 @@
 float dsT[ONE_WIRE_CNT] = { EMPTY_VAL, EMPTY_VAL, EMPTY_VAL };

 // Ethernet
-const byte mac[] = { 0x0B, 0xB6, 0xAA, 0x43, 0xA5, 0x9D };
+const byte mac[] = { 0x0A, 0xB6, 0xAA, 0x43, 0xA5, 0x9D };
 IPAddress ip(192, 168, 1, 8);
 EthernetServer server = EthernetServer(TCP_PORT);
 EthernetClient client;


Copy payload before republishing in mqtt_publish_in_callback example

--- PubSubClient/examples/mqtt_publish_in_callback/mqtt_publish_in_callback.ino
+++ PubSubClient/examples/mqtt_publish_in_callback/mqtt_publish_in_callback.ino
@@ -31,7 +31,17 @@

 // Callback function
 void callback(char* topic, byte* payload, unsigned int length) {
-  client.publish("outTopic", payload, length);
+  // In order to republish this payload, a copy must be made
+  // as the orignal payload buffer will be overwritten whilst
+  // constructing the PUBLISH packet.
+
+  // Allocate the correct amount of memory for the payload copy
+  byte* p = (byte*)malloc(length);
+  // Copy the payload to the new buffer
+  memcpy(p,payload,length);
+  client.publish("outTopic", p, length);
+  // Free the memory
+  free(p);
 }

 void setup()