Update gradient test.

Update gradient test.

--- examples/ra8875-demo/ra8875-demo.ino
+++ examples/ra8875-demo/ra8875-demo.ino
@@ -90,17 +90,20 @@
   tft.clearMemory();

   int width = tft.getWidth();
-  int barHeight = tft.getHeight() / 3;
+  int barHeight = tft.getHeight() / 4;
+
+  uint32_t starttime = millis();

   for (int i = 0; i <= 255; i++)
   {
     tft.fillRect((width / 256.0) * i, 0, (width / 256.0) * i + 1, barHeight, RGB565(i, 0, 0));
     tft.fillRect((width / 256.0) * i, barHeight, (width / 256.0) * i + 1, barHeight * 2, RGB565(0, i, 0));
     tft.fillRect((width / 256.0) * i, barHeight * 2, (width / 256.0) * i + 1, barHeight * 3, RGB565(0, 0, i));
-    //tft.fillRect(0, 0, 479, 271, RGB332(0, i, 0));
-    //tft.fillRect(0, 0, 479, 271, RGB332(0, 0, i));
+    tft.fillRect((width / 256.0) * i, barHeight * 3, (width / 256.0) * i + 1, barHeight * 4, RGB565(i, i, i));
   }
-
+
+  uint32_t elapsedtime = millis() - starttime;
+  Serial.print("Gradient test took "); Serial.print(elapsedtime); Serial.println(" ms");
 }

 void pixelTest()


Moved firmware to separate repo

Moved firmware to separate repo

--- firmware/green-spike/green-spike.ino
+++ firmware/green-spike/green-spike.ino
@@ -1,92 +0,0 @@
-#include <aJSON.h>
-#include "SPI.h"
-#include "WiFi.h"
-
-#include "M2XStreamClient.h"
-
-char ssid[] = "HackathonV4"; //  your network SSID (name)
-char pass[] = "hackhack"; // your network password (use for WPA, or use as key for WEP)
-int keyIndex = 0;            // your network key Index number (needed only for WEP)
-
-int status = WL_IDLE_STATUS;
-
-#define LED RED_LED
-
-char deviceId[] = "0904d16113289ea7b0f7d0dcbf8167ed"; // Feed you want to post to
-char m2xKey[] = "5fa8ca77601afee8c23ea6f52fd0cb33"; // Your M2X access key
-char streamName[] = "wetness"; // Stream you want to post to
-
-bool pushed = false;
-unsigned long lastReport = 0;
-unsigned long lastPrint = 0;
-
-const unsigned long printDelay = 500;
-const unsigned long minReportDelay = 500;
-const unsigned long maxReportDelay = 60000;
-
-WiFiClient client;
-M2XStreamClient m2xClient(&client, m2xKey);
-
-void printWifiStatus() {
-  // print the SSID of the network you're attached to:
-  Serial.print("SSID: ");
-  Serial.println(WiFi.SSID());
-
-  // print your WiFi shield's IP address:
-  IPAddress ip = WiFi.localIP();
-  Serial.print("IP Address: ");
-  Serial.println(ip);
-}
-
-void setup() {
-
-    lastReport = 0;
-    Serial.begin(9600);
-    pinMode(PUSH1, INPUT_PULLUP);
-    pinMode(LED, OUTPUT);
-
-    // attempt to connect to Wifi network:x
-    Serial.print("Attempting to connect to Network named: ");
-    Serial.println(ssid);
-    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
-    WiFi.begin(ssid, pass);
-    while ( WiFi.status() != WL_CONNECTED) {
-      // print dots while we wait to connect
-      Serial.print(".");
-      delay(250);
-    }
-
-    Serial.println("\nYou're connected to the network");
-    Serial.println("Waiting for an ip address");
-
-    while (WiFi.localIP() == INADDR_NONE) {
-      // print dots while we wait for an ip addresss
-      Serial.print(".");
-      delay(250);
-    }
-
-    Serial.println("\nIP Address obtained");
-
-    // you're connected now, so print out the status
-    printWifiStatus();
-}
-
-void loop() {
-  int button = !digitalRead(PUSH1);
-  int w = analogRead(A5);
-  unsigned long now = millis();
-
-  if (lastPrint + printDelay < now) {
-    Serial.print("ADC: ");
-    Serial.println(w);
-    lastPrint = now;
-  }
-
-  if ((lastReport + maxReportDelay < now) || (button && (lastReport + minReportDelay < now))) {
-    Serial.print("Reporting: ");
-    int response = m2xClient.updateStreamValue(deviceId, streamName, w);
-    Serial.println(response);
-    lastReport = now;
-  }
-  digitalWrite(LED, (now % 1000) < 621);
-}


change air flow

change air flow

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-nano/_04-mqtt-lcd-dust-sensor-nano.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-nano/_04-mqtt-lcd-dust-sensor-nano.ino
@@ -74,11 +74,10 @@
 // 0 : low
 // 1 : mid
 // 2 : high
-// 3 : rotate
-
-// IR
-const int AC_FLOW_TOWER[4] = {0, 4, 6, 12};
-const int AC_FLOW_WALL[4]  = {0, 2, 4, 5};
+
+// IR
+const int AC_FLOW_TOWER[4] = {0, 4, 6};
+const int AC_FLOW_WALL[4]  = {0, 2, 4};

 unsigned long AC_CODE_TO_SEND;

@@ -238,7 +237,7 @@
       // flow up
       case 0x77E1E03C:
         Serial.println("IR -----> flow up");
-        if ( AC_FLOW < 3) {
+        if ( AC_FLOW < 2) {
           ac_activate(AC_TEMPERATURE, (AC_FLOW + 1));
         }
         delay(50);


Add bar saturation in all mode

Add bar saturation in all mode

--- Arduino/GroundUnit/GroundUnit.ino
+++ Arduino/GroundUnit/GroundUnit.ino
@@ -85,7 +85,6 @@
 // Potentiometer
 #define POT_RANGE_DEG      300 // 300 is the value for standard potentiometer
 #define POT_USED_RANGE_DEG  60 // To normalize and saturate rotation
-#define POT_OFFSET        0.05 // Distance from rotation axis to lever arm (in m)
 #define NEUTRAL_ANGLE_DEG    0 // Zero of the potentiometer
 // Linear encoder
 #define LINEAR_RESOLUTION 0.005// Resolution of the linear encoder
@@ -264,8 +263,6 @@

   // Linear encoder position
   Input2 = (data[1]-127)/255.;//*LINEAR_RESOLUTION/2./LINEAR_USED_RANGE;
-  // Correction for lever arm (potentiometer not on axis)
-  //Input2+= (rawAngle_deg - NEUTRAL_ANGLE_DEG)* POT_OFFSET*PI/180;

   // Line tension
   Input3 = data[3]/127. - 1;
@@ -352,6 +349,16 @@
     myPID2.Compute();
     power2 = Output2*127;
   }
+
+  //Saturation based on posSat
+  if (Input1>posSat1)
+  {
+    power1 = min(power1,0);
+  }
+  if (Input1<-posSat1)
+  {
+    power1 = max(power1,0);
+  }
 }

 void sendOrder()


Simple implentation for robot arm

Simple implentation for robot arm

--- sw-machine-control/module-robot-arm/src/main.ino
+++ sw-machine-control/module-robot-arm/src/main.ino
@@ -30,8 +30,10 @@

 enum jobs {
   JOB_IDLE,
-  JOB_PICKUP,
-  JOB_DROP
+  JOB_PICKUP_BACK,
+  JOB_DROP_BACK,
+  JOB_PICKUP_FRONT,
+  JOB_DROP_FRONT
 };

 int moduleJob;
@@ -79,13 +81,16 @@
   moduleJob = JOB_IDLE;
 }

-// Stupid, simple implemetation
+// Stupid, most simple implemetation
 void loop() {
   listenBT();
   if (moduleJob != JOB_IDLE) {
-    if (moduleJob == JOB_DROP) {
-      //Implement Left or Right;
-      posTurn = moveServo(SERVO_TURN, posTurn, TURN_BACK);
+    if (moduleJob == JOB_DROP_BACK || moduleJob == JOB_DROP_FRONT) {
+      if (moduleJob == JOB_DROP_BACK) {
+        posTurn = moveServo(SERVO_TURN, posTurn, TURN_BACK);
+      } else {
+        posTurn = moveServo(SERVO_TURN, posTurn, TURN_FRONT);
+      }
       posLift = moveServo(SERVO_LIFT, posLift, LIFT_DOWN);
       posGrab = moveServo(SERVO_GRAB, posGrab, GRAB_OPEN);
       posLift = moveServo(SERVO_LIFT, posLift, LIFT_UP);
@@ -94,10 +99,13 @@
       moduleJob = JOB_IDLE;
       sendBT("success(1)");
     }
-    if (moduleJob == JOB_PICKUP) {
+    if (moduleJob == JOB_PICKUP_BACK || moduleJob == JOB_PICKUP_FRONT) {
       posGrab = moveServo(SERVO_GRAB, posGrab, GRAB_OPEN);
-      //Implement Left or Right;
-      posTurn = moveServo(SERVO_TURN, posTurn, TURN_BACK);
+      if (moduleJob == JOB_PICKUP_BACK) {
+        posTurn = moveServo(SERVO_TURN, posTurn, TURN_BACK);
+      } else {
+        posTurn = moveServo(SERVO_TURN, posTurn, TURN_FRONT);
+      }
       posLift = moveServo(SERVO_LIFT, posLift, LIFT_DOWN);
       posGrab = moveServo(SERVO_GRAB, posGrab, GRAB_CLOSE);
       posLift = moveServo(SERVO_LIFT, posLift, LIFT_UP);
@@ -114,11 +122,17 @@
 // Handle API commands
 void handleApiCommands(String command) {
   //sendBT(command);
-  if (command.startsWith("pickup(")) {
-    moduleJob = JOB_PICKUP;
+  if (command.startsWith("pickup(0)")) {
+    moduleJob = JOB_PICKUP_BACK;
   }
-  if (command.startsWith("drop(")) {
-    moduleJob = JOB_DROP;
+  if (command.startsWith("pickup(1)")) {
+    moduleJob = JOB_PICKUP_FRONT;
+  }
+  if (command.startsWith("drop(0)")) {
+    moduleJob = JOB_DROP_BACK;
+  }
+  if (command.startsWith("drop(1)")) {
+    moduleJob = JOB_DROP_FRONT;
   }
 }


comments for new sensors

comments for new sensors

--- v2/Motor_control/Distance_Test/Distance_Test.ino
+++ v2/Motor_control/Distance_Test/Distance_Test.ino
@@ -39,6 +39,8 @@
 const byte backright = A7; //back-right line sensor
 const byte frontright = A2; //front-left line sensor
 const byte frontleft = A3; //front-right line sensor
+//A4: left peripheral sensor
+//A5: right peripheral sensor

 // Window size of the median filter (odd number, 1 = no filtering)
 const byte mediumFilterWindowSize = 5;


Modified formatting

Modified formatting

--- module/module.rfid.ino
+++ module/module.rfid.ino
@@ -13,9 +13,9 @@
   while(1) {
   	if (RFID.available()) {
   		response[i] = RFID.read();
-      if (response[i] == 0xBB) {
-        break;
-      }
+      	if (response[i] == 0xBB) {
+        	break;
+      	}
   		i++;
   	}
   }


Checking plus cleanup

Checking plus cleanup

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -15,14 +15,16 @@
 #include <LiquidCrystal.h>
 #include <EEPROM.h>

-
 //-----------------
 // #defines controlling configuration
 // set to "1" to turn on feature
 //-----------------

+// Defining this to be '1' ERASES EVERYTHING IN EEPROM
+#define INIT_EEPROM   0
+
 // show voltage on screen next to battery symbol, if symbol displayed
-#define SHOW_VOLTAGE  0
+#define SHOW_VOLTAGE  1

 //-----------------
 // debug bit masks
@@ -44,7 +46,7 @@
 // Digital VFO program name & version
 const char *ProgramName = "DigitalVFO";
 const char *Version = "1.5";
-const char *MinorVersion = ".1";
+const char *MinorVersion = ".2";
 const char *Callsign = "ac3dn";

 // display constants - below is for ubiquitous small HD44780 16x2 display
@@ -102,6 +104,23 @@
 const byte DDS_FQ_UD = 16;    // connected to AD9851 device select pin
 const byte DDS_W_CLK = 15;    // connected to AD9851 clock pin
 const byte DDS_DATA = 14;     // connected to AD9851 D7 (serial data) pin
+
+// Define the address in EEPROM of various things.
+#define NEXT_SLOT(a)    ((a) + sizeof(a))
+
+// number of frequency save slots in EEPROM
+const int NumSaveSlots = 10;
+
+const int EepromFreq = 0;
+const int EepromSelDigit = NEXT_SLOT(EepromFreq);
+const int EepromVfoClockOffset = NEXT_SLOT(EepromSelDigit);
+const int EepromContrast = NEXT_SLOT(EepromVfoClockOffset);
+const int EepromBrightness = NEXT_SLOT(EepromContrast);
+const int EepromHoldClickTime = NEXT_SLOT(EepromBrightness);
+const int EepromDClickTime = NEXT_SLOT(EepromHoldClickTime);
+const int EepromVoltsCalibrate = NEXT_SLOT(EepromDClickTime);
+const int EepromSaveFreqBase = NEXT_SLOT(EepromVoltsCalibrate);
+const int EepromSaveOffsetBase = EepromSaveFreqBase + NumSaveSlots*sizeof(Frequency);

 //-----
 // Data and values used by the LCD code.
@@ -155,7 +174,7 @@
 byte batt100[8]   = {0x0e,0x1b,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f};
 byte battover[8]  = {0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f};
 //byte battnone[8]  = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-byte battnone[8]  = {0x04,0x06,0x0d,0x15,0x14,0x10,0x00,0x00}; // a USB log (sort of)
+byte battnone[8]  = {0x04,0x06,0x0d,0x15,0x14,0x10,0x00,0x00}; // a USB logo (sort of)

 // array of references to the 9 'battery symbol' characters
 byte *batt_syms[] = {battunder, batt00, batt20, batt40, batt60, batt80, batt100, battover, battnone};
@@ -259,6 +278,18 @@
 const int FreqBufferLen = 16;
 char FreqBuffer[FreqBufferLen];

+// time when click becomes a "hold click" (milliseconds)
+// the delay is configurable in the UI
+const int MinHoldClickTime = 100;     // min configurable time
+const int MaxHoldClickTime = 1000;    // max configurable time
+const int DefaultHoldClickTime = 500; // default time
+
+// time when click becomes a "double click" (milliseconds)
+// the delay is configurable in the UI
+const int MinDClickTime = 100;        // min configurable time
+const int MaxDClickTime = 1000;       // max configurable time
+const int DefaultDClickTime = 300;    // default time
+
 //##############################################################################
 // The VFO state variables and typedefs
 //
@@ -308,6 +339,34 @@
 }

 //----------------------------------------
+// Overwrite everything in the EEPROM.
+//----------------------------------------
+
+#if INIT_EEPROM
+
+void initialize_eeprom()
+{
+  EEPROM.put(EepromFreq, DefaultFrequency);
+  EEPROM.put(EepromSelDigit, DefaultSelDigit);
+  EEPROM.put(EepromVfoClockOffset, DefaultVfoClockOffset);
+  EEPROM.put(EepromContrast, DefaultLcdContrast);
+  EEPROM.put(EepromBrightness, DefaultLcdBrightness);
+  EEPROM.put(EepromHoldClickTime, DefaultHoldClickTime);
+  EEPROM.put(EepromDClickTime, DefaultDClickTime);
+  EEPROM.put(EepromVoltsCalibrate, DefaultVoltsCalibrate);
+
+  for (int i = 0; i < NumSaveSlots; ++i)
+  {
+    int addr = EepromSaveFreqBase + i * sizeof(Frequency);
+    EEPROM.put(addr, (Frequency) 0);
+    addr = EepromSaveOffsetBase + i * sizeof(SelOffset);
+    EEPROM.put(addr, (SelOffset) 0);
+  }
+}
+
+#endif
+
+//----------------------------------------
 // Calculate the moving average.
 //     new_measurement  the new measurement to average
 // Returns the current moving average.
@@ -325,7 +384,7 @@
 // Only first NumRows*NumCols chars of message is displayed on LCD.
 //----------------------------------------

-void abort(const char *msg)
+void DV_abort(const char *msg)
 {
   char buf[NumCols*NumRows+1];
   char *ptr = buf;
@@ -562,7 +621,7 @@
   // measure the raw volts and adjust
   // the "measured" voltage read is in range [0..1023] over 3.3 volts
   // the VDIV_RATIO is the voltage divide ratio, R12 and R13
-  // VoltsCalibrate is the calibration value, a float
+  // VoltsCalibrate is the calibration value, an int
   UINT measured = analogRead(mc_BattVolts);
   float voltage = 3.3 * measured / 1023;   // this is the raw, unadjusted voltage

@@ -657,7 +716,7 @@
 // External commands are:
 //     H;           send help text to console
 //     BH;          boot hard, reload software via USB
-//     BS;          boot soft, restart program
+//     BS;          boot soft, just restart program
 //     ID;          get device identifier string
 //     MO;          set VFO mode to 'online'
 //     MS;          set VFO mode to 'standby'
@@ -791,7 +850,7 @@
 }

 //----------------------------------------
-// Mode commands:
+// Frequency commands:
 //     FSnnnnnnnn;  set frequency to 'nnnnnnnn'
 //     FG;          get frequency
 //----------------------------------------
@@ -880,6 +939,7 @@

 //----------------------------------------
 // Process an external command.
+//     answer  address of place to store answer string
 //     cmd     address of command string buffer
 //     index   index of last char in string buffer
 // 'cmd' is '\0' terminated.
@@ -995,7 +1055,7 @@
 // Draw a standard menuitem on the screen.
 //     menu      pointer to a Menu structure
 //     item_num  the item number to show
-// Custome menuitems are drawn by their handler.
+// Custom menuitems are drawn by their handler.
 //----------------------------------------

 void menuitem_draw(struct Menu *menu, int item_num)
@@ -1148,7 +1208,7 @@
 //----------------------------------------
 // Push an event onto the event queue.
 //     event  number of the event to push
-// If queue is full, abort()!
+// If queue is full, abort!
 //
 // This routine is called only from interrupt code, so needs no protection.
 //----------------------------------------
@@ -1171,7 +1231,7 @@
   if (queue_aft == queue_fore)
   {
       event_dump_queue("ERROR: event queue full!");
-      abort("Event queue full");
+      DV_abort("Event queue full");
   }
 }

@@ -1183,7 +1243,7 @@

 VFOEvent event_pop(void)
 {
-  // Must protect from RE code fiddling with queue
+  // Must protect from RE code while fiddling with queue
   noInterrupts();

   // if queue empty, return None event
@@ -1456,18 +1516,6 @@
 // Interrupt driven rotary encoder interface.  From code by Simon Merrett.
 // Based on insight from Oleg Mazurov, Nick Gammon, rt, Steve Spence.
 //##############################################################################
-
-// time when click becomes a "hold click" (milliseconds)
-// the delay is configurable in the UI
-const int MinHoldClickTime = 100;     // min configurable time
-const int MaxHoldClickTime = 1000;    // max configurable time
-const int DefaultHoldClickTime = 500; // default time
-
-// time when click becomes a "double click" (milliseconds)
-// the delay is configurable in the UI
-const int MinDClickTime = 100;        // min configurable time
-const int MaxDClickTime = 1000;       // max configurable time
-const int DefaultDClickTime = 300;    // default time

 // internal variables
 UINT ReHoldClickTime = DefaultHoldClickTime;
@@ -1658,58 +1706,6 @@
 // Code to save/restore in EEPROM.
 //##############################################################################

-// Define the address in EEPROM of various things.
-// The "NEXT_FREE" value is the address of the next free slot address.
-// Ignore "redefine errors" - not very helpful in this case!
-// The idea is that we are free to rearrange objects below with minimum fuss.
-
-// start storing at address 0
-#define NEXT_FREE   (0)
-
-// address for Frequency 'frequency'
-const int EepromFreq = NEXT_FREE;
-#define NEXT_FREE   (EepromFreq + sizeof(Frequency))
-
-// address for int 'selected digit'
-const int EepromSelDigit = NEXT_FREE;
-#define NEXT_FREE   (EepromSelDigit + sizeof(SelOffset))
-
-// address for 'VfoClockOffset' calibration
-const int EepromVfoClockOffset = NEXT_FREE;
-#define NEXT_FREE   (EepromVfoClockOffset + sizeof(VfoClockOffset))
-
-// address for byte 'contrast'
-const int EepromContrast = NEXT_FREE;
-#define NEXT_FREE   (EepromContrast + sizeof(LcdContrast))
-
-// address for byte 'brightness'
-const int EepromBrightness = NEXT_FREE;
-#define NEXT_FREE   (EepromBrightness + sizeof(LcdBrightness))
-
-// address for int 'hold click time'
-const int EepromHoldClickTime = NEXT_FREE;
-#define NEXT_FREE   (EepromHoldClickTime + sizeof(ReHoldClickTime))
-
-// address for int 'double click time'
-const int EepromDClickTime = NEXT_FREE;
-#define NEXT_FREE   (EepromDClickTime + sizeof(ReDClickTime))
-
-// address for int 'voltage calibrate'
-const int EepromVoltsCalibrate = NEXT_FREE;
-#define NEXT_FREE   (EepromVoltsCalibrate + sizeof(VoltsCalibrate))
-
-// number of frequency save slots in EEPROM
-const int NumSaveSlots = 10;
-
-const int EepromSaveFreqBase = NEXT_FREE;
-#define NEXT_FREE   (EepromSaveFreqBase + NumSaveSlots * sizeof(Frequency))
-
-//also save the offset for each frequency
-const int EepromSaveOffsetBase = NEXT_FREE;
-#define NEXT_FREE   (EepromSaveOffsetBase + NumSaveSlots * sizeof(SelOffset);
-
-// additional EEPROM saved items go here
-
 //----------------------------------------
 // Save VFO state to EEPROM.
 // Everything except slot data.
@@ -1962,7 +1958,10 @@
   // initialize the serial console
   Serial.begin(19200);

-//  initialize_eeprom();  // DEBUG
+#if INIT_EEPROM
+  Serial.printf(F("Erasing EVERYTHING in EEPROM!\n"));
+  initialize_eeprom();  // WARNING! Destroys the EEPROM stored values
+#endif

   // initialize the BlankRow global to a blank string length of a display row
   BlankRow = (char *) malloc(NumCols + 1);
@@ -2813,7 +2812,7 @@
 // a 'click' action only.
 //----------------------------------------

-#define VOLTS_DELAY_MS   500    // milkisecond delay between updates in menu screen
+#define VOLTS_DELAY_MS   500    // millisecond delay between updates in menu screen

 void volts_calibrate_action(struct Menu *menu, int item_num)
 {
@@ -2978,12 +2977,13 @@

     if (CommandIndex < MAX_COMMAND_LEN)
     {
+      // only add if command not over-length
       CommandBuffer[CommandIndex++] = ch;
     }

     if (ch == COMMAND_END_CHAR)   // if end of command, execute it
     {
-      char answer[1024];
+      char answer[512];    // place to construct answer strings

       CommandBuffer[CommandIndex] = '\0';
       Serial.printf(F("%s\n"), do_external_cmd(answer, CommandBuffer, CommandIndex-1));
@@ -3051,34 +3051,6 @@
 }

 //----------------------------------------
-// Overwrite everything in the EEPROM.
-//----------------------------------------
-
-#if 0
-
-void initialize_eeprom()
-{
-  EEPROM.put(EepromFreq, DefaultFrequency);
-  EEPROM.put(EepromSelDigit, DefaultSelDigit);
-  EEPROM.put(EepromVfoClockOffset, DefaultVfoClockOffset);
-  EEPROM.put(EepromContrast, DefaultLcdContrast);
-  EEPROM.put(EepromBrightness, DefaultLcdBrightness);
-  EEPROM.put(EepromHoldClickTime, DefaultHoldClickTime);
-  EEPROM.put(EepromDClickTime, DefaultDClickTime);
-  EEPROM.put(EepromVoltsCalibrate, DefaultVoltsCalibrate);
-
-  for (int i = 0; i < NumSaveSlots; ++i)
-  {
-    int addr = EepromSaveFreqBase + i * sizeof(Frequency);
-    EEPROM.put(addr, (Frequency) 0);
-    addr = EepromSaveOffsetBase + i * sizeof(SelOffset);
-    EEPROM.put(addr, (SelOffset) 0);
-  }
-}
-
-#endif
-
-//----------------------------------------
 // Standard Arduino loop() function.
 //----------------------------------------


1.0 RC2

1.0 RC2

- RGB Led (Luxeon styled) support
- Button triggers ported to OneButton library (which adds more trigger
=> we can add even more functions... Arduino Nano space will become a
problem).
- Added ledstring/RGB blaster effect ( randomly shut down one segment
for a
short amount of time - I forgot that one :P / change color on RGB)
- Added some more sounds to config Mode
- Added boot sounds of soundfont when selecting them in config mode.
(still buggy)
- Code cleaning

--- Lightsaber.ino
+++ Lightsaber.ino
@@ -1,8 +1,8 @@
 /*
- * LightSaberOS V1.0RC1
+ * LightSaberOS V1.0RC2
  * author: 		Sbastien CAPOU (neskweek@gmail.com)
  * Source : 	https://github.com/neskweek/LightSaberOS.
- * Date: 		2016-02-11
+ * Date: 		2016-02-14
  * Description:	Operating System for Arduino based LightSaber
  *
  * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
@@ -26,7 +26,8 @@
  */
 #define CONFIG_VERSION "LS01"

-//#define LEDSTRINGS
+
+#define LEDSTRINGS  // Comment this RGB users
 #ifndef LEDSTRINGS
 #define LUXEON
 #endif
@@ -50,6 +51,7 @@
 #define LEDSTRING5 			7
 #define LEDSTRING6 			8
 #endif
+
 #ifdef LUXEON
 #define COLORS		 		54   // Number of RGB (not RGBW) colors in our array. Do we need that much ?
 #define LED_RED 			3


odd whitespace

odd whitespace

--- bot_base.ino
+++ bot_base.ino
@@ -128,7 +128,7 @@
   int finalSpeedLeft = 0;
   int finalSpeedRight = 0;

-	if(speed == 0 && direction) {
+  if(speed == 0 && direction) {
     finalSpeedLeft = direction;
     finalSpeedRight = -direction;
 	} else {


push pull

push pull

--- discont/Motor_Shield/MotorShield/MotorShield.ino
+++ discont/Motor_Shield/MotorShield/MotorShield.ino
@@ -1,5 +1,3 @@
-#include "PWM.h"
-
 const int encoderRightData1 = 3;
 const int encoderRightData2 = 5;
 const int encoderLeftData1 = 2;
@@ -104,32 +102,31 @@
   gotCommand = false;
   while(Serial.available())
   {
-	if(Serial.read() == '$')
-	{
-	  desiredSpeedL = Serial.parseFloat();
-	  desiredSpeedR = Serial.parseFloat();
-	  lastCmdTime = millis();
-	  gotCommand = true;
-	}
+  if(Serial.read() == '$')
+  {
+    desiredSpeedL = Serial.parseFloat();
+    desiredSpeedR = Serial.parseFloat();
+    lastCmdTime = millis();
+    gotCommand = true;
+  }
   }
   if(gotCommand)
   {
-	Serial.print('$');
-	Serial.print(actualSpeedL);
-	Serial.print(',');
-	Serial.print(actualSpeedR);
-	Serial.print(',');
-	Serial.print(dT_sec);
-	Serial.print('\n');
-  }
-
+  Serial.print('$');
+  Serial.print(actualSpeedL);
+  Serial.print(',');
+  Serial.print(actualSpeedR);
+  Serial.print(',');
+  Serial.print(dT_sec);
+  Serial.print('\n');
+  }
   if( millis() - lastCmdTime > 500)
   {
-	Serial.println("TIMEOUT");
-	desiredSpeedL = 0;
-	desiredSpeedR = 0;
-	PWM_L = 0;
-	PWM_R = 0;
+  Serial.println("TIMEOUT");
+  desiredSpeedL = 0;
+  desiredSpeedR = 0;
+  PWM_L = 0;
+  PWM_R = 0;
   }

   dT_sec = (float)( millis() - lastLoopTime ) / 1000.0;
@@ -158,27 +155,27 @@
   PWM_R = min(255, max(-255, PWM_R) );

   // Deadband
-  if( abs(PWM_L) < 0 )
-	PWM_L = 0;
-  if( abs(PWM_R) < 0 )
-	PWM_R = 0;
+  if( abs(PWM_L) < 0.15 )
+  PWM_L = 0;
+  if( abs(PWM_R) < 0.15 )
+  PWM_R = 0;

   if(PWM_L < 0) {
-	//pwmWrite(leftForwardSpeed, 0);
-	//pwmWrite(leftBackwardSpeed, -PWM_L);
+  analogWrite(leftForwardSpeed, 0);
+  analogWrite(leftBackwardSpeed, -PWM_L);
   } else {
-	pwmWrite(leftForwardSpeed, PWM_L);
-	//pwmWrite(leftBackwardSpeed, 0);
+  analogWrite(leftForwardSpeed, PWM_L);
+  analogWrite(leftBackwardSpeed, 0);
   }

   if(PWM_R < 0) {
-	//pwmWrite(rightForwardSpeed, 0);
-	//pwmWrite(rightBackwardSpeed, -PWM_R);
+  analogWrite(rightForwardSpeed, 0);
+  analogWrite(rightBackwardSpeed, -PWM_R);
   } else {
-	//pwmWrite(rightForwardSpeed, PWM_R);
-	//pwmWrite(rightBackwardSpeed, 0);
-  }
-
+  analogWrite(rightForwardSpeed, PWM_R);
+  analogWrite(rightBackwardSpeed, 0);
+  }
+
   lastErrorL = ErrorL;
   lastErrorR = ErrorR;
 }
@@ -187,11 +184,11 @@
 {
   if (digitalRead(encoderRightData1) == digitalRead(encoderRightData2))
   {
-	tickDataRight++;
+  tickDataRight++;
   }
   else
   {
-	tickDataRight--;
+  tickDataRight--;
   }
 }

@@ -199,11 +196,73 @@
 {
   if (digitalRead(encoderLeftData1) == digitalRead(encoderLeftData2))
   {
-	tickDataLeft++;
+  tickDataLeft++;
   }
   else
   {
-	tickDataLeft--;
-  }
-}
-
+  tickDataLeft--;
+  }
+}
+
+/**
+ * Divides a given PWM pin frequency by a divisor.
+ *
+ * The resulting frequency is equal to the base frequency divided by
+ * the given divisor:
+ *   - Base frequencies:
+ *      o The base frequency for pins 3, 9, 10, and 11 is 31250 Hz.
+ *      o The base frequency for pins 5 and 6 is 62500 Hz.
+ *   - Divisors:
+ *      o The divisors available on pins 5, 6, 9 and 10 are: 1, 8, 64,
+ *        256, and 1024.
+ *      o The divisors available on pins 3 and 11 are: 1, 8, 32, 64,
+ *        128, 256, and 1024.
+ *
+ * PWM frequencies are tied together in pairs of pins. If one in a
+ * pair is changed, the other is also changed to match:
+ *   - Pins 5 and 6 are paired on timer0
+ *   - Pins 9 and 10 are paired on timer1
+ *   - Pins 3 and 11 are paired on timer2
+ *
+ * Note that this function will have side effects on anything else
+ * that uses timers:
+ *   - Changes on pins 3, 5, 6, or 11 may cause the delay() and
+ *     millis() functions to stop working. Other timing-related
+ *     functions may also be affected.
+ *   - Changes on pins 9 or 10 will cause the Servo library to function
+ *     incorrectly.
+ *
+ * Thanks to macegr of the Arduino forums for his documentation of the
+ * PWM frequency divisors. His post can be viewed at:
+ *   http://forum.arduino.cc/index.php?topic=16612#msg121031
+ */
+void setPwmFrequency(int pin, int divisor) {
+  byte mode;
+  if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {
+  switch(divisor) {
+    case 1: mode = 0x01; break;
+    case 8: mode = 0x02; break;
+    case 64: mode = 0x03; break;
+    case 256: mode = 0x04; break;
+    case 1024: mode = 0x05; break;
+    default: return;
+  }
+  if(pin == 5 || pin == 6) {
+    TCCR0B = TCCR0B & 0b11111000 | mode;
+  } else {
+    TCCR1B = TCCR1B & 0b11111000 | mode;
+  }
+  } else if(pin == 3 || pin == 11) {
+  switch(divisor) {
+    case 1: mode = 0x01; break;
+    case 8: mode = 0x02; break;
+    case 32: mode = 0x03; break;
+    case 64: mode = 0x04; break;
+    case 128: mode = 0x05; break;
+    case 256: mode = 0x06; break;
+    case 1024: mode = 0x07; break;
+    default: return;
+  }
+  TCCR2B = TCCR2B & 0b11111000 | mode;
+  }
+}


Working flasher, with thread disabled mode

--- bolt-arduino.ino
+++ bolt-arduino.ino
@@ -24,7 +24,8 @@

 Thread flasherThread;

-bool currentlyFlashing = true;
+bool flashingCurrentState = true;
+bool flashed = false;

 void setup() {
   Serial.begin(115200);
@@ -35,17 +36,22 @@
   pinMode(P_LED_CLOCK, OUTPUT);
   pinMode(P_LED_LATCH, OUTPUT);

-  states[1] = LED_STATE_FLASHING;
-  states[4] = LED_STATE_ON;
-  states[5] = LED_STATE_ON;
-  states[8] = LED_STATE_ON;
-  states[10] = LED_STATE_ON;
-  shiftOut();
-
   //Thread setup
   flasherThread = Thread();
   flasherThread.setInterval(1000);
   flasherThread.onRun(threadCallback);
+  flasherThread.enabled = false;
+
+  setState(1, LED_STATE_FLASHING);
+  setState(0, LED_STATE_ON);
+  setState(3, LED_STATE_ON);
+  setState(5, LED_STATE_ON);
+  setState(7, LED_STATE_ON);
+  setState(9, LED_STATE_ON);
+  setState(11, LED_STATE_ON);
+  shiftOut();
+
+
 }

 void loop() {
@@ -70,12 +76,8 @@
         digitalWrite(P_LED_DATA, HIGH);
         break;
       case LED_STATE_FLASHING:
-        if (currentlyFlashing) {
-          digitalWrite(P_LED_DATA, HIGH);
-        } else {
-          digitalWrite(P_LED_DATA, LOW);
-        }
-        currentlyFlashing = !currentlyFlashing;
+        flashed = true;
+        digitalWrite(P_LED_DATA, flashingCurrentState);
         break;
     }

@@ -90,10 +92,36 @@
   //Latch high. VCC adjust to two volts
   digitalWrite(P_LED_LATCH, HIGH);
   analogWrite(P_LED_VCC, LED_VCC_PWM);
+
+
 }

 void threadCallback() {
-
+  Serial.println("Flasher thread running");
+
+  //Variable should turn true if something flahed
+  flashed = false;
+
   shiftOut();
+
+  if (!flashed) {
+    //Nothing is flashing anymore
+    flasherThread.enabled = false;
+  } else {
+    //If it did flash switch flashing state
+    flashingCurrentState = !flashingCurrentState;
+  }
+
+
 }

+void setState(uint8_t led, uint8_t state) {
+
+  //If we have a flashing led turn on. The thread will automatically turn off if no leds are flashing.
+  if (state == LED_STATE_FLASHING) {
+    flasherThread.enabled = true;
+  }
+
+  states[led] = state;
+}
+


Add currently playing + play button to web interface. Fixed filter to play only mp3 files

--- RfidShelf/RfidShelf.ino
+++ RfidShelf/RfidShelf.ino
@@ -132,7 +132,6 @@
   Serial.print("Connected! IP address: ");
   Serial.println(WiFi.localIP());

-  server.on("/playMp3", HTTP_GET, handlePlayMp3);
   server.on("/stopMp3", HTTP_GET, handleStopMp3);
   server.on("/", HTTP_POST, handleNotFound, handleFileUpload);
   server.onNotFound(handleNotFound);
@@ -319,7 +318,7 @@
   }
 }

-bool switchFolder(char *folder) {
+bool switchFolder(const char *folder) {
   Serial.print(F("Switching folder to "));
   Serial.println(folder);

@@ -358,7 +357,7 @@
     file.close();

     String tmpFile = String(filenameChar);
-    if (file.isDir() && !isMP3File(tmpFile)) {
+    if (file.isDir() || !isMP3File(tmpFile)) {
       Serial.print(F("Ignoring "));
       Serial.println(tmpFile);
       continue;
@@ -390,6 +389,7 @@
   Serial.println(fullpath);

   playing = true;
+  currentFile = nextFile;
   musicPlayer.startPlayingFile((char *)fullpath.c_str());

   if (AMP_POWER > 0) {
@@ -424,13 +424,15 @@
       "function upload(folder){ var fileInput = document.getElementById('fileInput'); if(fileInput.files.length === 0){ alert('Choose a file first'); return; } xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { location.reload(); }};"
       "var formData = new FormData(); for(var i = 0; i < fileInput.files.length; i++) { formData.append('data', fileInput.files[i], folder.concat(fileInput.files[i].name)); }; xhr.open('POST', '/'); xhr.send(formData); }"
       "function writeRfid(url){ var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { location.reload(); }}; xhr.open('POST', url); var formData = new FormData(); formData.append('write', 1); xhr.send(formData);}"
-      "function mkdir() { var folder = document.getElementById('folder'); if(folder != ''){ var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { location.reload(); }}; xhr.open('POST', '/'); var formData = new FormData(); formData.append('folder', folder.value); xhr.send(formData);}}"
+      "function play(url){ var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { location.reload(); }}; xhr.open('POST', url); var formData = new FormData(); formData.append('play', 1); xhr.send(formData);}"
+      "function mkdir() { var folder = document.getElementById('folder'); if(folder != ''){ var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { location.reload(); }}; xhr.open('POST', '/'); var formData = new FormData(); formData.append('newFolder', folder.value); xhr.send(formData);}}"
       "function ota() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { document.write('Please wait and do NOT turn of the power!'); location.reload(); }}; xhr.open('POST', '/'); var formData = new FormData(); formData.append('ota', 1); xhr.send(formData);}"
       "</script><link rel=\"icon\" href=\"data:;base64,iVBORw0KGgo=\">"));

   String output;
   if (path == "/") {
-    output = F("<form><input type=\"text\" name=\"folder\" id=\"folder\"><input type=\"button\" value=\"mkdir\" onclick=\"mkdir()\"></form>");
+    output = F("
Currently playing: {currentFile}
<form><input type=\"text\" name=\"folder\" id=\"folder\"><input type=\"button\" value=\"mkdir\" onclick=\"mkdir()\"></form>");
+    output.replace("{currentFile}", currentFile);
     output.replace("{folder}", path);
     server.sendContent(output);
   } else {
@@ -451,7 +453,7 @@
     if (entry.isDir()) {
       // Currently only foldernames <= 16 characters can be written onto the rfid
       if (filename.length() <= 16) {
-        output += F("💾");
+        output += F("💾 ▶");
       }
       output.replace("{icon}", F("📂 "));
       output.replace("{path}", filename + "/");
@@ -513,11 +515,6 @@
   } else {
     returnHttpStatus((uint8_t)404, "Not found");
   }
-}
-
-void handlePlayMp3() {
-  playMp3();
-  returnOK();
 }

 void handleStopMp3() {
@@ -591,11 +588,14 @@
     returnOK();
     return;
   } else if (server.method() == HTTP_POST) {
-    if (server.hasArg("folder")) {
+    if (server.hasArg("newFolder")) {
       Serial.print(F("Creating folder"));
       Serial.print(F(" "));
-      Serial.println(server.arg("folder"));
-      SD.mkdir((char *)server.arg("folder").c_str());
+      Serial.println(server.arg("newFolder"));
+      stopMp3();
+      yield();
+      switchFolder("/");
+      SD.mkdir((char *)server.arg("newFolder").c_str());
       returnOK();
       return;
     } else if (server.hasArg("ota")) {
@@ -626,6 +626,12 @@
         handleWriteRfid(path);
         returnOK();
         return;
+      } else if(server.hasArg("play") && switchFolder((char *)path.c_str())) {
+        stopMp3();
+        yield();
+        playMp3();
+        returnOK();
+        return;
       }
     }
   }
@@ -667,7 +673,7 @@
       }
     }
   }
-  file.close(); //Close out this track
+  file.close();

   Serial.print(F("Number of bytes: ")); Serial.println(i);
 }


Modified canbus rece SD example

Modified canbus rece SD example

--- examples/recv_sd/recv_sd.ino
+++ examples/recv_sd/recv_sd.ino
@@ -4,7 +4,6 @@
 // loovee, Jun 12, 2017

 #include <SPI.h>
-#include "mcp_can.h"
 #include <SD.h>

 /*SAMD core*/
@@ -16,12 +15,25 @@

 File myFile;

+//#define CAN_2515
+#define CAN_2518FD
 // the cs pin of the version after v1.1 is default to D9
 // v0.9b and v1.0 is default D10
-const int SPI_CS_CAN    = 9;
-const int SPI_CS_SD     = 4;

-MCP_CAN CAN(SPI_CS_CAN);                                    // Set CS pin
+
+#ifdef CAN_2518FD
+#include "mcp2518fd_can.h"
+const int SPI_CS_PIN = BCM8;
+const int CAN_INT_PIN = BCM25;
+mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
+#endif
+
+#ifdef CAN_2515
+#include "mcp2515_can.h"
+const int SPI_CS_PIN = 9;
+const int CAN_INT_PIN = 2;
+mcp2515_can CAN(SPI_CS_PIN); // Set CS pin
+#endif                              // Set CS pin

 unsigned char flagRecv = 0;
 unsigned char len = 0;
@@ -31,7 +43,11 @@
 void setup() {
     SERIAL.begin(115200);

-    while (CAN_OK != CAN.begin(CAN_500KBPS)) {            // init can bus : baudrate = 500k
+#ifdef CAN_2518FD
+    while (0 != CAN.begin((byte)CAN_500K_1M)) {            // init can bus : baudrate = 500k
+#else
+    while (CAN_OK != CAN.begin(CAN_500KBPS)) {             // init can bus : baudrate = 500k
+#endif
         SERIAL.println("CAN BUS Shield init fail");
         SERIAL.println("Init CAN BUS Shield again");
         delay(100);
@@ -88,4 +104,4 @@
     }
 }

-// END FILE+// END FILE


version 0.1.1

version 0.1.1

--- Sequencer/Sequencer.ino
+++ Sequencer/Sequencer.ino
@@ -1,5 +1,5 @@
 /*
-KidModular - SEQUENCER - V.0.1.0
+KidModular - SEQUENCER - V.0.1.1
 by Tiago Angelo (aka p1nho)

 Built with:


hard configured remote for test

hard configured remote for test

--- VisSynthRemote/VisSynthRemote.ino
+++ VisSynthRemote/VisSynthRemote.ino
@@ -164,12 +164,12 @@
     if(!redFlyCommandRequired("AT+RSI_AUTHMODE=4")) continue;
     if(!redFlyCommandRequired("AT+RSI_SCAN=0")) continue;
     delay(1000);
-    if(!redFlyCommandRequired("AT+RSI_JOIN=AdHoc,0,0")) continue;
+    if(!redFlyCommandRequired("AT+RSI_JOIN=VisSynthBox II,0,0")) continue;
     delay(1000);
-    if(!redFlyCommandRequired("AT+RSI_IPCONF=0,10.42.0.2,255.255.255.0,10.42.0.1")) continue;
+    if(!redFlyCommandRequired("AT+RSI_IPCONF=0,168.254.20.10,255.255.0.0,168.254.10.10")) continue;
     delay(100);
     if(!redFlyCommandRequired("AT+RSI_LUDP=8083")) continue;
-    if(!redFlyCommandRequired("AT+RSI_UDP=10.42.0.1,8083,9083")) continue;
+    if(!redFlyCommandRequired("AT+RSI_UDP=168.254.10.10,8083,9083")) continue;

     success=true;
   }


working on sleep mode

working on sleep mode

--- WeatherStation/WeatherStation.ino
+++ WeatherStation/WeatherStation.ino
@@ -11,6 +11,8 @@
 #define DHTPIN 4     // what pin we're connected to
 DHT dht;

+#define XBEESLEEPPIN 2
+
 // Connect pin 1 (on the left) of the sensor to +5V
 // Connect pin 2 ouf the sensor to whatever your DHTPIN is
 // Connect pin 4 (on the right) of the sensor to GROUND
@@ -21,6 +23,9 @@
 int sample=0;

 void setup() {
+  pinMode( LEDPIN , OUTPUT);
+  pinMode( XBEESLEEPPIN , OUTPUT);
+
   Serial.begin(57600);
   dht.setup(DHTPIN);

@@ -36,15 +41,13 @@
     Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
     while(1);
   }
-
-  /* Setup the sensor gain and integration time */
-  configureLightSensor();
-
-
 }

 void loop() {
   digitalWrite(LEDPIN, HIGH);
+  digitalWrite(XBEESLEEPPIN, LOW);  //Wake UP XBEE
+
+  configureLightSensor();

   Serial.print("{'_sensor': 'weather', '_sample': {'_id':");
   Serial.print(sample++);
@@ -97,9 +100,9 @@
   Serial.println("}}");

   digitalWrite(LEDPIN, LOW);
+  digitalWrite(XBEESLEEPPIN, HIGH);  //Put XBEE to sleep

-  //delay(15000);
-  Narcoleptic.delay(30000);
+  sleep(30000);
 }

 void configureLightSensor(void)
@@ -115,3 +118,19 @@
   tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */
 }

+void sleep(long milliseconds)
+{
+   while(milliseconds > 0)
+   {
+      if(milliseconds > 8000)
+      {
+         milliseconds -= 8000;
+         Narcoleptic.delay(8000);
+      }
+      else
+      {
+        Narcoleptic.delay(milliseconds);
+        break;
+      }
+   }
+}


device_no needs to match recieve code

device_no needs to match recieve code

--- examples/CW_CarLights_Send/CW_CarLights_Send.ino
+++ examples/CW_CarLights_Send/CW_CarLights_Send.ino
@@ -18,7 +18,7 @@
 #endif

 // I2C device number you are sending to
-const byte device_no = 15;
+const byte device_no = 12;

 CW_CarLightsSend lights = CW_CarLightsSend(device_no);


Changes:

Changes:

* Do meteo update only after successfull time refresh
* Fix dew point calculation

--- meteo_lcd/meteo_lcd.ino
+++ meteo_lcd/meteo_lcd.ino
@@ -85,7 +85,7 @@
 // 01234567890123456789
 // 00:00:00  31.12.2017
 char time_format[21] = "17:34:59  31.12.2017";
-void print_time_string(unsigned row, bool full_update = false);
+bool print_time_string(unsigned row, bool full_update = false);

 // Error value
@@ -165,11 +165,11 @@
     if (temp < -31.0 || temp > 50)
         return 100; // treat it as an error.

-    int temp_idx = 40-(temp + 31.0)/2;
+    int temp_idx = 40 - (temp + 30.0)/2;
     if (temp_idx < 0) temp_idx = 0;
     if (temp_idx > 40) temp_idx = 40;

-    int humid_idx = (humid+2.5)/5;
+    int humid_idx = (humid + 2.5)/5;
     if (humid_idx < 0) humid_idx = 0;
     if (humid_idx > 20) humid_idx = 20;

@@ -461,9 +461,10 @@

 /*
  * Prints time-date string in global char time_format[]
- * Does an update/printing only when needed
+ * Does an update/printing only when needed and return true.
+ * Return false otherway.
  */
-void print_time_string(unsigned row, bool full_update)
+bool print_time_string(unsigned row, bool full_update)
 {
     /*
      * 01234567890123456789
@@ -474,7 +475,7 @@
     if (last_second == rtc.getSecond()) {
         // No update needed
         LOGLN("RTC No update needed");
-        return;
+        return false;
     }
     last_second = rtc.getSecond();

@@ -529,6 +530,7 @@
     LOGLN(time_format);
     lcd.setCursor(0, row);
     lcd.print(time_format);
+    return true;
 }

 ////////////////////////////////////////////////////////////////////////////////
@@ -819,8 +821,6 @@

 void loop ()
 {
-    static unsigned long lastTime;
-    unsigned long timeNow = millis();
     LOGLN("Loop");

     if (enter_time_setup())
@@ -829,9 +829,11 @@
     // Support backlight buttons
     backlight_buttons();

+    // Update the displayed time
+    //print_time_string(3 /* 4th row */);
+
     // Update meteo data
-    if (timeNow - lastTime > 1000) {
-        lastTime = timeNow;
+    if (print_time_string(3 /* 4th row */)) {
         digitalWrite(DEBUG_LED, HIGH);
         float temp_in, humid_in, temp_out, humid_out;
         int32_t pressure;
@@ -841,7 +843,6 @@
         digitalWrite(DEBUG_LED, LOW);
     }

-    // Update the displayed time
-    print_time_string(3 /* 4th row */);
-}
-
+
+}
+


Aux 로그 추가

Aux 로그 추가

--- MiniRover/MiniRover.ino
+++ MiniRover/MiniRover.ino
@@ -7,7 +7,7 @@
 //
 //    최종 수정	:
 //
-//    MPU_Type	:
+//    MPU_Type	: Arduino Micro
 //
 //    파일명		:
 //----------------------------------------------------------------------------
@@ -121,10 +121,41 @@
     int16_t Speed;
     int16_t Dir;

+    uint8_t Aux1;
+    uint8_t Aux2;
+    uint8_t Aux3;
+    uint8_t Aux4;
+
+
     Roll     = 1000 + pCmd->Data[0] * 4;
     Pitch    = 1000 + pCmd->Data[1] * 4;
     Yaw      = 1000 + pCmd->Data[2] * 4;
     Throthle = 1000 + pCmd->Data[3] * 4;
+
+    Aux1 = ( pCmd->Data[4] >> 6 ) & 0x03;
+    Aux2 = ( pCmd->Data[4] >> 4 ) & 0x03;
+    Aux3 = ( pCmd->Data[4] >> 2 ) & 0x03;
+    Aux4 = ( pCmd->Data[4] >> 0 ) & 0x03;
+
+    /*
+        pCmd->Data[0] : 0~250 - Roll 값
+        pCmd->Data[1] : 0~250 - Pitch 값
+        pCmd->Data[2] : 0~250 - Yaw 값
+        pCmd->Data[3] : 0~250 - Throttle 값
+        pCmd->Data[4] : 0~255 - Aux 값
+            7:6  Aux1
+            5:4  Aux2
+            3:2  Aux3
+            1:0  Aux4
+
+        Aux1
+            - 0 : Headfree Mode Off
+            - 2 : Headfree Mode On
+        Aux2
+            - 0 : 고도홀드 Off
+            - 2 : 고도홀드 On
+    */
+

     /*
     Serial.print("Receive : ");
@@ -132,6 +163,15 @@
     Serial.print(Pitch);    Serial.print("\t");
     Serial.print(Yaw);      Serial.print("\t");
     Serial.print(Throthle); Serial.print("\t");
+    Serial.println(" ");
+    */
+
+    /*
+    Serial.print("Receive Aux: \t");
+    Serial.print(Aux1); Serial.print("\t");
+    Serial.print(Aux2); Serial.print("\t");
+    Serial.print(Aux3); Serial.print("\t");
+    Serial.print(Aux4); Serial.print("\t");
     Serial.println(" ");
     */


Found some more IR codes (44-key).

Found some more IR codes (44-key).

--- tests/Tower/IR_test/IR_test.ino
+++ tests/Tower/IR_test/IR_test.ino
@@ -38,6 +38,126 @@
 #define BRIGTH_STEP        10
 #define CODE_REPEAT        0xFFFFFF

+/* from http://forum.osmc.tv/showthread.php?tid=7142
+
+      led-brighter            0x3AC5
+          led-dim               0xBA45
+          led-power             0x02FD
+
+
+          led-red               0x1AE5
+          led-green             0x9A65
+          led-blue              0xA25D
+          led-white        0x22DD
+
+
+          led-redorange        0x2AD5
+          led-warmwhite        0x12ED
+
+
+          led-orange        0x0AF5
+          led-pink        0x32CD
+
+
+          led-yellow        0x38C7
+          led-cyan        0xB847
+          led-lightpurple    0x7887
+          led-turquoise        0xF807
+
+
+          led-greenyellow    0x18E7
+          led-babyblue        0x9867
+          led-purple        0x58A7
+          led-bluewhite        0xD827
+
+
+          led-redup             0x28D7
+          led-greenup           0xA857
+          led-blueup            0x6897
+          led-faster            0xE817
+
+
+          led-reddown           0x08F7
+          led-greendown         0x8877
+          led-bluedown          0x48B7
+          led-slower            0xC837
+
+
+          led-diy1              0x30CF
+          led-diy2              0xB04F
+          led-diy3              0x708F
+          led-auto         0xF00F
+
+
+          led-diy4              0x10EF
+          led-diy5              0x906F
+          led-diy6              0x50AF
+          led-flash        0xD02F
+
+
+          led-jump3        0x20DF
+          led-jump7        0xA05F
+          led-fade3        0x609F
+          led-fade7        0xE01F
+
+*/
+/* or: for a 44-key remote:
+          LED_UP                0x3AC5
+          LED_DOWN              0xBA45
+          LED_Power_ON          0x827D
+          LED_Power_OFF         0x02FD
+
+          LED_RED               0x1AE5
+          LED_GREEN             0x9A65
+          LED_BLUE              0xA25D
+          LED_WHITE             0x22DD
+
+          LED_ORANGE            0x2AD5
+          LED_PEE-GREEN         0xAA55
+          LED_DARK-BLUE         0x926D
+          LED_MILK-WHITE        0x12ED
+
+          LED_DARK-YELLOW       0x0AF5
+          LED_CYAN              0x8A75
+          LED_LYON-BLUE         0xB24D
+          LED_WHITE-PINK        0x32CD
+
+          LED_YELLOW            0x38C7
+          LED_LIGHT-BLUE        0xB847
+          LED_PINK              0x7887
+          LED_GREEN-WHITE       0xF807
+
+          LED_LIGHT-YELLOW      0x18E7
+          LED_SKY-BLUE          0x9867
+          LED_BROWN             0x58A7
+          LED_BLUE-WHITE        0xD827
+
+          RED_UP                0x28D7
+          GREEN_UP              0xA857
+          BLUE_UP               0x6897
+          QUICKER               0xE817
+
+          RED_DOWN              0x08F7
+          GREEN_DOWN            0x8877
+          BLUE_DOWN             0x48B7
+          SLOWER                0xC837
+
+          DIY1                  0x30CF
+          DIY2                  0xB04F
+          DIY3                  0x708F
+          AUTO                  0xF00F
+
+          DIY4                  0x10EF
+          DIY5                  0x906F
+          DIY6                  0x50AF
+          FLASH                 0xD02F
+
+          JUMP3                 0x20DF
+          JUMP7                 0xA05F
+          FADE3                 0x609F
+          FADE7                 0xE01F
+
+*/
 void setup()
 {
   Serial.begin(115200);


close #32

close #32

--- crossbow.ino
+++ crossbow.ino
@@ -1,8 +1,8 @@
-#define DEVICE_MODE_TX
-// #define DEVICE_MODE_RX
+// #define DEVICE_MODE_TX
+#define DEVICE_MODE_RX

 // #define FEATURE_TX_OLED
-#define FORCE_TX_WITHOUT_INPUT
+// #define FORCE_TX_WITHOUT_INPUT

 #define DEBUG_SERIAL
 // #define DEBUG_PING_PONG
@@ -341,7 +341,7 @@
     if (lastRxStateTaskTime + RX_TASK_HEALTH < currentMillis) {
         lastRxStateTaskTime = currentMillis;
         updateRxDeviceState(&rxDeviceState);
-        rxDeviceState.channels[RSSI_CHANNEL - 1] = map(rxDeviceState.rssi, 0, 164, 1000, 2000);
+        rxDeviceState.channels[RSSI_CHANNEL - 1] = map(radioState.rssi, 0, 164, 1000, 2000);
         if (qsp.deviceState == DEVICE_STATE_FAILSAFE) {
             digitalWrite(LED_BUILTIN, HIGH);
         } else {


delete unused code

delete unused code

--- examples/hello/hello.ino
+++ examples/hello/hello.ino
@@ -4,72 +4,6 @@
 #include <Humblesoft_LedMat.h>	// https://github.com/h-nari/Humblesoft_LedMat

 uint8_t imgBuf[1024*4];
-
-void demo1()
-{
-	LedMat.clear();
-	LedMat.fillScreen(0);
-
-	LedMat.moveCursor(2,0);
-	LedMat.setTextColor("red");
-	LedMat.print("WiFi");
-	LedMat.setTextColor("green");
-	LedMat.print(" + ");
-	LedMat.setTextColor("blue");
-	LedMat.println("LED");
-
-	LedMat.moveCursor(2, 0);
-	LedMat.setTextColor("#004040");
-	LedMat.print("on ");
-	LedMat.setTextColor("white");
-	LedMat.println("ARDUINO");
-
-	LedMat.moveCursor(2, 5);
-	LedMat.setTextColor("#ff00ff");
-	LedMat.println("LED MATRIX");
-
-	LedMat.moveCursor(2, 0);
-	LedMat.setTextColor("#ffff00");
-	LedMat.println("CONTROLLER");
-
-	int x,y = LedMat.getCursorY() + 2;
-	int h = LedMat.height() - y;
-	int w = 64;
-
-	for(x=0; x<w; x++){
-		int r,g,b,xx;
-		int q = w/4;
-		if(x < q){
-			r = 255;
-			g = b = 255 * (q - x) / q;
-		} else if(x < 2*q) {
-			xx = x - q;
-			r = 255 * (q - xx) / q;
-			g = 255 * xx / q;
-			b = 0;
-		} else if(x < 3*q) {
-			xx = x - 2*q;
-			r = 0;
-			g = 255 * (q - xx) / q;
-			b = 255 * xx / q;
-		} else {
-			xx = x - 3*q;
-			r = g = 255 * xx / q;
-			b = 255;
-		}
-		LedMat.drawFastVLine(x, y, h, LedMat.rgb(r,g,b));
-	}
-
-	x = 31;
-	y = 52;
-	const char *mes = "FULL COLOR";
-	LedMat.setTextColor("white");
-	LedMat.alignPrintf(x+1, y+1, TA_CENTER, TA_CENTER, mes);
-	LedMat.setTextColor("#001000");
-	LedMat.alignPrintf(x, y, TA_CENTER, TA_CENTER, mes);
-	LedMat.display();
-}
-

 void setup(void)
 {


Now working with the rotary encoder as input

--- oven.ino
+++ oven.ino
@@ -12,12 +12,12 @@
 // This MOD the number of states determines the state we are in
 int buttonPressCounter = 0;

-// Potentiometer PIN
-const int potentiometerPin = A0;
-
-// Value of the potentiometer
-int potentiometerValue = 0;
-int lastPotentiometerValue = 0;
+// Number to display on the LED S7S
+int displayValue = 0;
+int lastDisplayValue = 0;
+
+// Rotary encoder signals
+int A_SIG=0, B_SIG=1;

 // Pin numbers for the RGB LEB
 const int ledRedPin = 9;
@@ -27,15 +27,18 @@
 // I2C address of our S7S
 const byte s7sAddress = 0x71;

-
-
-unsigned int counter = 990;  // This variable will count up to 65k
-char tempString[10];  // Will be used with sprintf to create strings
+// Will be used with sprintf to create strings
+char tempString[10];
+

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

+  // Attach interrupts for rotary encoder
+  attachInterrupt(0, A_RISE, RISING);
+  attachInterrupt(1, B_RISE, RISING);
+
   // Enable push button in LOW state
   pinMode(buttonPin, INPUT);
   digitalWrite(buttonPin, LOW);
@@ -62,13 +65,6 @@

 void loop()
 {
-  // Read value of potentiometer
-  potentiometerValue = analogRead(potentiometerPin);
-  if (potentiometerValue != lastPotentiometerValue) {
-    Serial.println(potentiometerValue);
-  }
-  lastPotentiometerValue = potentiometerValue;
-
   if (hasButtonBeenPushed()) {
     Serial.println("Button Pushed");
     buttonPressCounter++;
@@ -87,22 +83,21 @@
     case 2:
       setColor(0, 0, 0);
       clearDisplayI2C();
-      counter = 0;
+      displayValue = 0;
       break;
   }
 }

 void adjustTime() {
-  counter = potentiometerValue;
-  printCounter();
+  updateDisplay();
 }

 void countDown() {
-  counter--;
-  printCounter();
-
-  if (counter == 0) {
+  displayValue--;
+  updateDisplay();
+
+  if (displayValue == 0) {
     soupsReady();
   } else {
     delay(500);
@@ -128,10 +123,10 @@
   delay(500);
 }

-void printCounter() {
+void updateDisplay() {
   // Magical sprintf creates a string for us to send to the s7s.
   //  The %4d option creates a 4-digit integer.
-  sprintf(tempString, "%4d", counter);
+  sprintf(tempString, "%4d", displayValue);

   // This will output the tempString to the S7S
   s7sSendStringI2C(tempString);
@@ -209,3 +204,51 @@
   Wire.write(decimals);
   Wire.endTransmission();
 }
+
+void A_RISE(){
+ detachInterrupt(0);
+ A_SIG=1;
+
+ if(B_SIG==0)
+ displayValue++;//moving forward
+ if(B_SIG==1)
+ displayValue--;//moving reverse
+ Serial.println(displayValue);
+ attachInterrupt(0, A_FALL, FALLING);
+}
+
+void A_FALL(){
+  detachInterrupt(0);
+ A_SIG=0;
+
+ if(B_SIG==1)
+ displayValue++;//moving forward
+ if(B_SIG==0)
+ displayValue--;//moving reverse
+ Serial.println(displayValue);
+ attachInterrupt(0, A_RISE, RISING);
+}
+
+void B_RISE(){
+ detachInterrupt(1);
+ B_SIG=1;
+
+ if(A_SIG==1)
+ displayValue++;//moving forward
+ if(A_SIG==0)
+ displayValue--;//moving reverse
+ Serial.println(displayValue);
+ attachInterrupt(1, B_FALL, FALLING);
+}
+
+void B_FALL(){
+ detachInterrupt(1);
+ B_SIG=0;
+
+ if(A_SIG==0)
+ displayValue++;//moving forward
+ if(A_SIG==1)
+ displayValue--;//moving reverse
+ Serial.println(displayValue);
+ attachInterrupt(1, B_RISE, RISING);
+}


LDR_PIN set to A0, better than 14

LDR_PIN set to A0, better than 14

--- TreibBoje/TreibBoje.ino
+++ TreibBoje/TreibBoje.ino
@@ -84,7 +84,7 @@

 #ifdef USE_LDR
  // define a pin for Photo resistor (ADC input!)
- #define LDR_PIN    14
+ #define LDR_PIN    A0
 #endif // USE_LDR

 #ifdef USE_LEDS
@@ -478,5 +478,3 @@
   Serial.print(sensors.getResolution(deviceAddress));
   Serial.println();
 }
-
-


changed buffersize

changed buffersize

--- firmware/malduino_elite/malduino_elite.ino
+++ firmware/malduino_elite/malduino_elite.ino
@@ -1,4 +1,4 @@
-/*
+n/*
   ==============================================================
     Copyright (c) 2017 Seytonic, Spacehuhn (Licensed under MIT)
       For more information see: github.com/seytonic/malduino
@@ -21,7 +21,7 @@
 #define dip3 9
 #define dip4 10

-#define buffersize 128
+#define buffersize 256

 #define KEYPAD_0 234
 #define KEYPAD_1 225


added comments

added comments

--- CHMachineV2_Arduino/CHMachineV2_Arduino.ino
+++ CHMachineV2_Arduino/CHMachineV2_Arduino.ino
@@ -11,13 +11,12 @@
 #include <SoftwareSerial.h>
 int rxPin = 2;
 int txPin = 3;
-SoftwareSerial mySerial(rxPin, txPin); //rx,tx
+SoftwareSerial mySerial(rxPin, txPin);
 int PWMPin = 5;

-//long unsigned timer = 0;
-String softserial_str;//string buffer for softserial
-String str;
-String command_str;
+String softserial_str; //string buffer for softserial
+String str; //to store the command from serial
+String command_str;//to manipulate the command from serial
 String magnitude_str;
 String timeinterval_str;
 String magnituderamp_str;
@@ -26,12 +25,12 @@
 float timeinterval;
 float magnituderamp;
 int PWMspeed;
-int CHM_timelimit = 200;
-int TCODE_timelimit = 1000;
+int CHM_timelimit = 200; //timelimit to stop the motor if no commands are received
+int TCODE_timelimit = 1000; //timelimit to stop the motor if no commands are received
 long unsigned TICms;
 long unsigned timezero;
-long unsigned CHM_timer;
-long unsigned TCODE_timer;
+long unsigned CHM_timer; //time(ms)since the last CHM command
+long unsigned TCODE_timer; //time(ms)since the last TCODE command
 bool CHM_mode = false;
 bool TCODE_mode = false;


Enviado a cada 15min, ajustando buffer

Enviado a cada 15min, ajustando buffer

--- ESP-Logger/ESP-Logger.ino
+++ ESP-Logger/ESP-Logger.ino
@@ -1,18 +1,18 @@
-#include <ESP8266WiFi.h>
+#include "ntpUtils.h"
+#include "authUtils.h"
+
 #include <FirebaseArduino.h>
 #include <DHT.h>
-#include "authUtils.h"
-#include "ntpUtils.h"

 #define DHTPIN D2
 #define DHTTYPE DHT11
-#define DELAY_TIME_TO_SEND 1800000 // 30 min
+#define DELAY_TIME_TO_SEND  900000 // 15 min
 #define TABLE_NAME "leitura"
 #define CLIENT_EMAIL "user@mail.com"

 DHT dht(DHTPIN, DHTTYPE);

-StaticJsonBuffer<200> jsonBuffer;
+StaticJsonBuffer<1000> jsonBuffer;
 JsonObject &root = jsonBuffer.createObject();

 void inline readDataToSend();
@@ -34,14 +34,18 @@
     Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
     udp.begin(UDP_NTS_PORT);
     setSyncProvider(getNtpTime);
+    pinMode(LED_BUILTIN, OUTPUT);
+    digitalWrite(LED_BUILTIN, HIGH);
 }
+
+String errorToPrint = String(TABLE_NAME) + " failed to send:";

 void loop() {
     readDataToSend();
     Firebase.push(TABLE_NAME, root);

     if (Firebase.failed()) {
-        Serial.print(String(TABLE_NAME) + " failed to send:");
+        Serial.print(errorToPrint);
         Serial.println(Firebase.error());
         return;
     }
@@ -57,12 +61,14 @@
 }

 void inline readDataToSend() {
+    digitalWrite(LED_BUILTIN, LOW);
     String temperatura = String(dht.readTemperature());
     String umid = String(dht.readHumidity());
     String cliente = CLIENT_EMAIL;
     String data = String(getDateTime());
-    delay(1000);
+    delay(5000);

     setLeitura(temperatura, umid, cliente, data);
     Serial.println("temp=" + temperatura + " umid=" + umid + " clnt=" + cliente + " dateTime=" + data);
+    digitalWrite(LED_BUILTIN, HIGH);
 }


Updated pulse delay time

Updated pulse delay time

Was 10, changed to 5 (MAKE SURE TEST2 GETS THIS UPDATE AS WELL)

--- FlightCode/FlightCode.ino
+++ FlightCode/FlightCode.ino
@@ -316,7 +316,7 @@
       digitalWrite(statePinA, HIGH);

     digitalWrite(controlPin, LOW); //Once the output pins have been set properly, pulse the control pin to update the servo.
-    delay(10);
+    delay(5);
     digitalWrite(controlPin, HIGH);

     finPosition = goal; //Update the fin state tracking variable


adding comments

adding comments

--- rtty.ino
+++ rtty.ino
@@ -1,9 +1,11 @@
-// To be used on an arduino
-// Uses Fast PWM to produce 8kHz 8bit audio
-// Maybe in time go to 16 bit using Timer 2 but not yet...
+// Arduino RTTY Modulator
+// Uses Fast PWM to produce ~8kHz 8bit audio

 #include "baudot.h"
 #include "pwmsine.h"
+
+// Yeah, I really need to get rid of these globals.
+// Thats next on the to-do list

 char pflag = 0;
 unsigned int sampleRate = 7750;
@@ -75,14 +77,27 @@
     sign *= -1;
   }

+  // return the pwm value
   return (char)(128+(sign*sine[pstn]));
 }

+// sets the character buffer, the current character being sent
 void setCbuff(){
     int i = 0;
-    for(i = 0; i < (sizeof(baudot_letters)/sizeof(char)); i++){
-
+
+    // Note: the <<2)+3 is how we put the start and stop bits in
+    // the baudot table is MSB on right in the form 000xxxxx
+    // so when we shift two and add three it becomes 0xxxxx11 which is
+    // exactly the form we need for one start bit and two stop bits when read
+    // from left to right
+
+    // try to find a match of the current character in baudot
+    for(i = 0; i < (sizeof(baudot)/sizeof(char)); i++){
+
+      // look in letters
       if(msg[bytePstn] == baudot_letters[i]) {
+
+        // if coming from numbers, send shift to letters
         if(shiftToNum == 1){
           shiftToNum = 0;
           charbuf = ((baudot[31])<<2)+3;
@@ -91,7 +106,8 @@
           charbuf = ((baudot[i])<<2)+3;
         }
       }
-
+
+      //look in numbers
       if(msg[bytePstn] != ' ' && msg[bytePstn] != 10
 		&& msg[bytePstn] == baudot_figures[i]) {
         if(shiftToNum == 0){
@@ -103,6 +119,7 @@
         }
       }

+      // for printing the char to serial
       sym = charbuf;
       pflag = 1;
     }
@@ -110,6 +127,7 @@

 void setSymb(char mve){

+    // if its a 1 set change to dmark other wise set change to dspace
     if((charbuf&(0x01<<mve))>>mve) {
       change = dmark;
     } else {
@@ -118,19 +136,24 @@
 }

 // This interrupt run on every sample (7128.5 times a second)
+// though it should be every 7128.5 the sample rate had to be set differently
+// to produce the correct baud rate and frequencies (that agree with the math)
+// Why?! I'm going to figure that one out
 ISR(TIMER2_OVF_vect) {
   count++;
   if (tx == 0) return;

-  // if were done transmitting the last 1 or 0
-  // read the next bit and change the tone
-  // if end of the array, stop transmitting
+  // if we've played enough samples for the symbol were transmitting, get next symbol
   if (count >= sampPerSymb){
     count = 0;
     bitPstn++;
+
+    // if were at the end of the character return to the begining of a
+    // character and grab the next one
     if(bitPstn > (bits-1)) {
       bitPstn = 0;

+      // dont increment bytePstn if were transmitting a shift-to character
       if(justshifted != 1) {
         bytePstn++;
       } else {
@@ -138,6 +161,7 @@
       }

       setCbuff();
+      // if were at the end of the message, return to the begining
       if (bytePstn > (msgSize-2)){
         // clear variables used here
         bitPstn = 0;
@@ -148,14 +172,19 @@
     }

     unsigned char mve = 0;
-    // 0 or 1 to transmit?
+    // endianness thing
     if (lsbf != 1) {
-      mve = (bits-1)-bitPstn; // MSB first
+      // MSB first
+      mve = (bits-1)-bitPstn;
     } else {
-      mve = bitPstn; // LSB first
+      // LSB first
+      mve = bitPstn;
     }
+
+    // get if 0 or 1 that were transmitting
     setSymb(mve);
   }

+  // set PWM duty cycle
   OCR2B = calcAmp();
 }


[Cleanup] Fixed outdated comment.

[Cleanup] Fixed outdated comment.

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

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

   while (Serial.available() && Serial.read()); // empty buffer

-  // Lower to 500msec
+  // Lower to 60msec
   wdt_disable();
   wdt_enable(WDTO_60MS);
 }


Added held ticks

Added held ticks

--- chillduino.ino
+++ chillduino.ino
@@ -96,7 +96,8 @@
     .setCompressorTicksPerDefrost(100 * TICKS_PER_HOUR)
     .setDefrostDurationInTicks(30 * TICKS_PER_MINUTE)
     .setMinimumTicksForCompressorChange(10 * TICKS_PER_MINUTE)
-    .setMinimumTicksForDoorClose(100);
+    .setMinimumTicksForDoorClose(100)
+    .setMinimumTicksForHeldModeSwitch(3 * TICKS_PER_SECOND);

   pixels.begin();
   pixels.show();


Adding sound confirmation on successful function

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -128,6 +128,7 @@
 		}

 		Serial.write(END_CHAR);
+		state = 0;
 	}

 	if (characterRead[0] == COMMAND_RESET_TIME) {
@@ -139,6 +140,7 @@

 		Serial.write(done);
 		Serial.write(END_CHAR);
+		state = 0;
 	}

 	if (characterRead[0] == COMMAND_REGISTER) {
@@ -165,7 +167,7 @@
 		}

 		Serial.write(END_CHAR);
-
+		state = 0;
 	}
 }


Update to 2.0.1

Update to 2.0.1

--- 0_Test_Device/Python/tclab_v2/tclab_v2.ino
+++ 0_Test_Device/Python/tclab_v2/tclab_v2.ino
@@ -1,357 +1,358 @@
-/*
-  TCLab Temperature Control Lab Firmware
-  Jeffrey Kantor, Bill Tubbs, John Hedengren, Shawn Summey
-  June 2020
-
-  This firmware provides a high level interface to the Temperature Control Lab. The
-  firmware scans the serial port for commands. Commands are case-insensitive. Any
-  unrecognized command results in sleep model. Each command returns a result string.
-
-  A         software restart. Returns "Start".
-  LED float set LED to float for 10 sec. range 0 to 100. Returns actual float
-  P1 float  set pwm limit on heater 1, range 0 to 255. Default 200. Returns P1.
-  P2 float  set pwm limit on heater 2, range 0 to 255. Default 100. Returns P2.
-  Q1 float  set Heater 1, range 0 to 100. Returns value of Q1.
-  Q2 float  set Heater 2, range 0 to 100. Returns value of Q2.
-  Q1B float set Heater 1, range 0 to 100. Returns value of Q1 as a 32-bit float.
-  Q2B float set Heater 2, range 0 to 100. Returns value of Q2 as a 32-bit float.
-  R1        get value of Heater 1, range 0 to 100
-  R2        get value of Heater 2, range 0 to 100
-  SCAN      get values T1 T2 Q1 Q1 in line delimited values
-  T1        get Temperature T1. Returns value of T1 in °C.
-  T2        get Temperature T2. Returns value of T2 in °C.
-  T1B       get Temperature T1. Returns value of T1 in °C as a 32-bit float.
-  T2B       get Temperature T2. Returns value of T2 in °C as a 32-bit float.
-  VER       get firmware version string
-  X         stop, enter sleep mode. Returns "Stop"
-
-  Limits on the heater can be configured with the constants below.
-
-  Status is indicated by LED1 on the Temperature Control Lab. Status conditions are:
-
-      LED1        LED1
-      Brightness  State
-      ----------  -----
-      dim         steady     Normal operation, heaters off
-      bright      steady     Normal operation, heaters on
-      dim         blinking   High temperature alarm on, heaters off
-      bright      blinking   High temperature alarm on, heaters on
-
-  The Temperature Control Lab shuts down the heaters if it receives no host commands
-  during a timeout period (configure below), receives an "X" command, or receives
-  an unrecognized command from the host.
-
-  The constants can be used to configure the firmware.
-
-  Version History
-      1.0.1 first version included in the tclab package
-      1.1.0 added R1 and R2 commands to read current heater values
-            modified heater values to units of percent of full power
-            added P1 and P2 commands to set heater power limits
-            rewrote readCommand to avoid busy states
-            simplified LED status model
-      1.2.0 added LED command
-      1.2.1 correctly reset heater values on close
-            added version history
-      1.2.2 shorten version string for better display by TCLab
-      1.2.3 move baudrate to from 9600 to 115200
-      1.3.0 add SCAN function
-            report board type in version string
-      1.4.0 changed Q1 and Q2 to float from int
-      1.4.1 fix missing Serial.flush() at end of command loop
-      1.4.2 fix bug with X command
-      1.4.3 required Arduino IDE Version >= 1.0.0
-      1.5.0 remove webusb
-      1.6.0 average 10 temperature measurements to reduce noise
-      2.0.0 added binary communications.
-            T1B and T2B commands return 32-bit float
-            Q1B and Q2B commands return 32-bit float confirmation of heater setting
-            added calculation to use 1.75 AREF to match TMP36 voltage range
-*/
-
-#include "Arduino.h"
-
-// determine board type
-#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
-  String boardType = "Arduino Uno";
-#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
-  String boardType = "Arduino Leonardo/Micro";
-#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-  String boardType = "Arduino Mega";
-#else
-  String boardType = "Unknown board";
-#endif
-
-// Enable debugging output
-const bool DEBUG = false;
-
-// constants
-const String vers = "2.0.0";   // version of this firmware
-const long baud = 115200;      // serial baud rate
-const char sp = ' ';           // command separator
-const char nl = '\n';          // command terminator
-
-// pin numbers corresponding to signals on the TC Lab Shield
-const int pinT1   = 0;         // T1
-const int pinT2   = 2;         // T2
-const int pinQ1   = 3;         // Q1
-const int pinQ2   = 5;         // Q2
-const int pinLED1 = 9;         // LED1
-
-// temperature alarm limits
-const int limT1   = 50;       // T1 high alarm (°C)
-const int limT2   = 50;       // T2 high alarm (°C)
-
-// LED1 levels
-const int hiLED   =  60;       // hi LED
-const int loLED   = hiLED/16;  // lo LED
-
-// global variables
-char Buffer[64];               // buffer for parsing serial input
-int buffer_index = 0;          // index for Buffer
-String cmd;                    // command
-float val;                     // command value
-int ledStatus;                 // 1: loLED
-                               // 2: hiLED
-                               // 3: loLED blink
-                               // 4: hiLED blink
-long ledTimeout = 0;           // when to return LED to normal operation
-float LED = 100;               // LED override brightness
-float P1 = 200;                // heater 1 power limit in units of pwm. Range 0 to 255
-float P2 = 100;                // heater 2 power limit in units in pwm, range 0 to 255
-float Q1 = 0;                  // last value written to heater 1 in units of percent
-float Q2 = 0;                  // last value written to heater 2 in units of percent
-int alarmStatus;               // hi temperature alarm status
-boolean newData = false;       // boolean flag indicating new command
-
-int n = 10;                    // number of samples for each temperature measurement
-
-void readCommand() {
-  while (Serial && (Serial.available() > 0) && (newData == false)) {
-    int byte = Serial.read();
-    if ((byte != '\r') && (byte != nl) && (buffer_index < 64)) {
-      Buffer[buffer_index] = byte;
-      buffer_index++;
-    }
-    else {
-      newData = true;
-    }
-  }
-}
-
-// for debugging with the serial monitor in Arduino IDE
-void echoCommand() {
-  if (newData) {
-    Serial.write("Received Command: ");
-    Serial.write(Buffer, buffer_index);
-    Serial.write(nl);
-    Serial.flush();
-  }
-}
-
-// return thermister temperature in °C
-inline float readTemperature(int pin) {
-  float degC = 0.;
-  for (int i = 0; i < n; i++) {
-    // (analogRead * 3300.0/1024.0 - 500.0)/10.0
-    degC += analogRead(pin) * 0.322265625 - 50.0;    // use for 3.3v AREF
-    //degC += analogRead(pin) * 0.170898438 - 50.0;  // use for 1.75v AREF
-  }
-  // return average from n reads
-  return degC / float(n);
-}
-
-void parseCommand(void) {
-  if (newData) {
-    String read_ = String(Buffer);
-
-    // separate command from associated data
-    int idx = read_.indexOf(sp);
-    cmd = read_.substring(0, idx);
-    cmd.trim();
-    cmd.toUpperCase();
-
-    // extract data. toFloat() returns 0 on error
-    String data = read_.substring(idx + 1);
-    data.trim();
-    val = data.toFloat();
-
-    // reset parameter for next command
-    memset(Buffer, 0, sizeof(Buffer));
-    buffer_index = 0;
-    newData = false;
-  }
-}
-
-void sendResponse(String msg) {
-  Serial.println(msg);
-}
-
-void sendFloatResponse(float val) {
-  Serial.println(String(val,3));
-}
-
-void sendBinaryResponse(float val)
-{
-  byte *b = (byte*)&val;
-  Serial.write(b,4);
-}
-
-void dispatchCommand(void) {
-  if (cmd == "A") {
-    setHeater1(0);
-    setHeater2(0);
-    sendResponse("Start");
-  }
-  else if (cmd == "LED") {
-    ledTimeout = millis() + 10000;
-    LED = max(0, min(100, val));
-    sendResponse(String(LED));
-  }
-  else if (cmd == "P1") {
-    P1 = max(0, min(255, val));
-    sendResponse(String(P1));
-  }
-  else if (cmd == "P2") {
-    P2 = max(0, min(255, val));
-    sendResponse(String(P2));
-  }
-  else if (cmd == "Q1") {
-    setHeater1(val);
-    sendFloatResponse(Q1);
-  }
-  else if (cmd == "Q1B") {
-    setHeater1(val);
-    sendBinaryResponse(Q1);
-  }
-  else if (cmd == "Q2") {
-    setHeater2(val);
-    sendFloatResponse(Q2);
-  }
-  else if (cmd == "Q2B") {
-    setHeater1(val);
-    sendBinaryResponse(Q2);
-  }
-  else if (cmd == "R1") {
-    sendFloatResponse(Q1);
-  }
-  else if (cmd == "R2") {
-    sendFloatResponse(Q2);
-  }
-  else if (cmd == "SCAN") {
-    sendFloatResponse(readTemperature(pinT1));
-    sendFloatResponse(readTemperature(pinT2));
-    sendFloatResponse(Q1);
-    sendFloatResponse(Q2);
-  }
-  else if (cmd == "T1") {
-    sendFloatResponse(readTemperature(pinT1));
-  }
-  else if (cmd == "T1B") {
-    sendBinaryResponse(readTemperature(pinT1));
-  }
-  else if (cmd == "T2") {
-    sendFloatResponse(readTemperature(pinT2));
-  }
-  else if (cmd == "T2B") {
-    sendBinaryResponse(readTemperature(pinT2));
-  }
-  else if (cmd == "VER") {
-    sendResponse("TCLab Firmware " + vers + " " + boardType);
-  }
-  else if (cmd == "X") {
-    setHeater1(0);
-    setHeater2(0);
-    sendResponse("Stop");
-  }
-  else if (cmd.length() > 0) {
-    setHeater1(0);
-    setHeater2(0);
-    sendResponse(cmd);
-  }
-  Serial.flush();
-  cmd = "";
-}
-
-void checkAlarm(void) {
-  if ((readTemperature(pinT1) > limT1) or (readTemperature(pinT2) > limT2)) {
-    alarmStatus = 1;
-  }
-  else {
-    alarmStatus = 0;
-  }
-}
-
-void updateStatus(void) {
-  // determine led status
-  ledStatus = 1;
-  if ((Q1 > 0) or (Q2 > 0)) {
-    ledStatus = 2;
-  }
-  if (alarmStatus > 0) {
-    ledStatus += 2;
-  }
-  // update led depending on ledStatus
-  if (millis() < ledTimeout) {        // override led operation
-    analogWrite(pinLED1, LED);
-  }
-  else {
-    switch (ledStatus) {
-      case 1:  // normal operation, heaters off
-        analogWrite(pinLED1, loLED);
-        break;
-      case 2:  // normal operation, heater on
-        analogWrite(pinLED1, hiLED);
-        break;
-      case 3:  // high temperature alarm, heater off
-        if ((millis() % 2000) > 1000) {
-          analogWrite(pinLED1, loLED);
-        } else {
-          analogWrite(pinLED1, loLED/4);
-        }
-        break;
-      case 4:  // high temperature alarm, heater on
-        if ((millis() % 2000) > 1000) {
-          analogWrite(pinLED1, hiLED);
-        } else {
-          analogWrite(pinLED1, loLED);
-        }
-        break;
-    }
-  }
-}
-
-// set Heater 1
-void setHeater1(float qval) {
-  Q1 = max(0., min(qval, 100.));
-  analogWrite(pinQ1, (Q1*P1)/100);
-}
-
-// set Heater 2
-void setHeater2(float qval) {
-  Q2 = max(0., min(qval, 100.));
-  analogWrite(pinQ2, (Q2*P2)/100);
-}
-
-// arduino startup
-void setup() {
-  analogReference(EXTERNAL);
-  while (!Serial) {
-    ; // wait for serial port to connect.
-  }
-  Serial.begin(baud);
-  Serial.flush();
-  setHeater1(0);
-  setHeater2(0);
-  ledTimeout = millis() + 1000;
-}
-
-// arduino main event loop
-void loop() {
-  readCommand();
-  if (DEBUG) echoCommand();
-  parseCommand();
-  dispatchCommand();
-  checkAlarm();
-  updateStatus();
-}
+/*
+  TCLab Temperature Control Lab Firmware
+  Jeffrey Kantor, Bill Tubbs, John Hedengren, Shawn Summey
+  February 2021
+
+  This firmware provides a high level interface to the Temperature Control Lab. The
+  firmware scans the serial port for commands. Commands are case-insensitive. Any
+  unrecognized command results in sleep model. Each command returns a result string.
+
+  A         software restart. Returns "Start".
+  LED float set LED to float for 10 sec. range 0 to 100. Returns actual float
+  P1 float  set pwm limit on heater 1, range 0 to 255. Default 200. Returns P1.
+  P2 float  set pwm limit on heater 2, range 0 to 255. Default 100. Returns P2.
+  Q1 float  set Heater 1, range 0 to 100. Returns value of Q1.
+  Q2 float  set Heater 2, range 0 to 100. Returns value of Q2.
+  Q1B float set Heater 1, range 0 to 100. Returns value of Q1 as a 32-bit float.
+  Q2B float set Heater 2, range 0 to 100. Returns value of Q2 as a 32-bit float.
+  R1        get value of Heater 1, range 0 to 100
+  R2        get value of Heater 2, range 0 to 100
+  SCAN      get values T1 T2 Q1 Q1 in line delimited values
+  T1        get Temperature T1. Returns value of T1 in °C.
+  T2        get Temperature T2. Returns value of T2 in °C.
+  T1B       get Temperature T1. Returns value of T1 in °C as a 32-bit float.
+  T2B       get Temperature T2. Returns value of T2 in °C as a 32-bit float.
+  VER       get firmware version string
+  X         stop, enter sleep mode. Returns "Stop"
+
+  Limits on the heater power can be configured with the constants below.
+
+  Status is indicated by LED1 on the Temperature Control Lab. Status conditions are:
+
+      LED1        LED1
+      Brightness  State
+      ----------  -----
+      dim         steady     Normal operation, heaters off
+      bright      steady     Normal operation, heaters on
+      dim         blinking   High temperature alarm on, heaters off
+      bright      blinking   High temperature alarm on, heaters on
+
+  The Temperature Control Lab shuts down the heaters if it receives no host commands
+  during a timeout period (configure below), receives an "X" command, or receives
+  an unrecognized command from the host.
+
+  Constants are used to configure the firmware.
+
+  Changelog ordered by Semantic Version
+
+      1.0.1 first version included in the tclab package
+      1.1.0 added R1 and R2 commands to read current heater values
+            changed heater values to units of percent of full power
+            added P1 and P2 commands to set heater power limits
+            changed readCommand to avoid busy states
+            changed simplified LED status model
+      1.2.0 added LED command
+      1.2.1 fixed reset heater values on close
+            added version history
+      1.2.2 changed version string for better display by TCLab
+      1.2.3 changed baudrate to from 9600 to 115200
+      1.3.0 added SCAN function
+            added board type in version string
+      1.4.0 changed Q1 and Q2 to float from int
+      1.4.1 fixed missing Serial.flush() at end of command loop
+      1.4.2 fixed bug with X command
+      1.4.3 deprecated use of Arduino IDE Version < 1.0.0
+      1.5.0 removed webusb
+      1.6.0 changed temperature to average 10 measurements to reduce noise
+      2.0.0 added binary communications.
+            added T1B and T2B commands return 32-bit float
+            added Q1B and Q2B commands return 32-bit float confirmation of heater setting
+            added calculation to use 1.75 AREF to match TMP36 voltage range
+      2.0.1 added updates to Notre Dame and BYU versions of this firmware
+            changed version history to standard change log practices
+
+*/
+
+#include "Arduino.h"
+
+// determine board type
+#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
+  String boardType = "Arduino Uno";
+#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
+  String boardType = "Arduino Leonardo/Micro";
+#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+  String boardType = "Arduino Mega";
+#else
+  String boardType = "Unknown board";
+#endif
+
+// Enable debugging output
+const bool DEBUG = false;
+
+// constants
+const String vers = "2.0.1";   // version of this firmware
+const long baud = 115200;      // serial baud rate
+const char sp = ' ';           // command separator
+const char nl = '\n';          // command terminator
+
+// pin numbers corresponding to signals on the TC Lab Shield
+const int pinT1   = 0;         // T1
+const int pinT2   = 2;         // T2
+const int pinQ1   = 3;         // Q1
+const int pinQ2   = 5;         // Q2
+const int pinLED1 = 9;         // LED1
+
+// temperature alarm limits
+const int limT1   = 50;       // T1 high alarm (°C)
+const int limT2   = 50;       // T2 high alarm (°C)
+
+// LED1 levels
+const int hiLED   =  60;       // hi LED
+const int loLED   = hiLED/16;  // lo LED
+
+// global variables
+char Buffer[64];               // buffer for parsing serial input
+int buffer_index = 0;          // index for Buffer
+String cmd;                    // command
+float val;                     // command value
+int ledStatus;                 // 1: loLED
+                               // 2: hiLED
+                               // 3: loLED blink
+                               // 4: hiLED blink
+long ledTimeout = 0;           // when to return LED to normal operation
+float LED = 100;               // LED override brightness
+float P1 = 200;                // heater 1 power limit in units of pwm. Range 0 to 255
+float P2 = 100;                // heater 2 power limit in units in pwm, range 0 to 255
+float Q1 = 0;                  // last value written to heater 1 in units of percent
+float Q2 = 0;                  // last value written to heater 2 in units of percent
+int alarmStatus;               // hi temperature alarm status
+boolean newData = false;       // boolean flag indicating new command
+int n =  10;                   // number of samples for each temperature measurement
+
+
+void readCommand() {
+  while (Serial && (Serial.available() > 0) && (newData == false)) {
+    int byte = Serial.read();
+    if ((byte != '\r') && (byte != nl) && (buffer_index < 64)) {
+      Buffer[buffer_index] = byte;
+      buffer_index++;
+    }
+    else {
+      newData = true;
+    }
+  }
+}
+
+// for debugging with the serial monitor in Arduino IDE
+void echoCommand() {
+  if (newData) {
+    Serial.write("Received Command: ");
+    Serial.write(Buffer, buffer_index);
+    Serial.write(nl);
+    Serial.flush();
+  }
+}
+
+// return average  of n reads of thermister temperature in °C
+inline float readTemperature(int pin) {
+  float degC = 0.0;
+  for (int i = 0; i < n; i++) {
+    degC += analogRead(pin) * 0.322265625 - 50.0;    // use for 3.3v AREF
+    //degC += analogRead(pin) * 0.170898438 - 50.0;  // use for 1.75v AREF
+  }
+  return degC / float(n);
+}
+
+void parseCommand(void) {
+  if (newData) {
+    String read_ = String(Buffer);
+
+    // separate command from associated data
+    int idx = read_.indexOf(sp);
+    cmd = read_.substring(0, idx);
+    cmd.trim();
+    cmd.toUpperCase();
+
+    // extract data. toFloat() returns 0 on error
+    String data = read_.substring(idx + 1);
+    data.trim();
+    val = data.toFloat();
+
+    // reset parameter for next command
+    memset(Buffer, 0, sizeof(Buffer));
+    buffer_index = 0;
+    newData = false;
+  }
+}
+
+void sendResponse(String msg) {
+  Serial.println(msg);
+}
+
+void sendFloatResponse(float val) {
+  Serial.println(String(val, 3));
+}
+
+void sendBinaryResponse(float val) {
+  byte *b = (byte*)&val;
+  Serial.write(b, 4);
+}
+
+void dispatchCommand(void) {
+  if (cmd == "A") {
+    setHeater1(0);
+    setHeater2(0);
+    sendResponse("Start");
+  }
+  else if (cmd == "LED") {
+    ledTimeout = millis() + 10000;
+    LED = max(0, min(100, val));
+    sendResponse(String(LED));
+  }
+  else if (cmd == "P1") {
+    P1 = max(0, min(255, val));
+    sendResponse(String(P1));
+  }
+  else if (cmd == "P2") {
+    P2 = max(0, min(255, val));
+    sendResponse(String(P2));
+  }
+  else if (cmd == "Q1") {
+    setHeater1(val);
+    sendFloatResponse(Q1);
+  }
+  else if (cmd == "Q1B") {
+    setHeater1(val);
+    sendBinaryResponse(Q1);
+  }
+  else if (cmd == "Q2") {
+    setHeater2(val);
+    sendFloatResponse(Q2);
+  }
+  else if (cmd == "Q2B") {
+    setHeater1(val);
+    sendBinaryResponse(Q2);
+  }
+  else if (cmd == "R1") {
+    sendFloatResponse(Q1);
+  }
+  else if (cmd == "R2") {
+    sendFloatResponse(Q2);
+  }
+  else if (cmd == "SCAN") {
+    sendFloatResponse(readTemperature(pinT1));
+    sendFloatResponse(readTemperature(pinT2));
+    sendFloatResponse(Q1);
+    sendFloatResponse(Q2);
+  }
+  else if (cmd == "T1") {
+    sendFloatResponse(readTemperature(pinT1));
+  }
+  else if (cmd == "T1B") {
+    sendBinaryResponse(readTemperature(pinT1));
+  }
+  else if (cmd == "T2") {
+    sendFloatResponse(readTemperature(pinT2));
+  }
+  else if (cmd == "T2B") {
+    sendBinaryResponse(readTemperature(pinT2));
+  }
+  else if (cmd == "VER") {
+    sendResponse("TCLab Firmware " + vers + " " + boardType);
+  }
+  else if (cmd == "X") {
+    setHeater1(0);
+    setHeater2(0);
+    sendResponse("Stop");
+  }
+  else if (cmd.length() > 0) {
+    setHeater1(0);
+    setHeater2(0);
+    sendResponse(cmd);
+  }
+  Serial.flush();
+  cmd = "";
+}
+
+void checkAlarm(void) {
+  if ((readTemperature(pinT1) > limT1) or (readTemperature(pinT2) > limT2)) {
+    alarmStatus = 1;
+  }
+  else {
+    alarmStatus = 0;
+  }
+}
+
+void updateStatus(void) {
+  // determine led status
+  ledStatus = 1;
+  if ((Q1 > 0) or (Q2 > 0)) {
+    ledStatus = 2;
+  }
+  if (alarmStatus > 0) {
+    ledStatus += 2;
+  }
+  // update led depending on ledStatus
+  if (millis() < ledTimeout) {        // override led operation
+    analogWrite(pinLED1, LED);
+  }
+  else {
+    switch (ledStatus) {
+      case 1:  // normal operation, heaters off
+        analogWrite(pinLED1, loLED);
+        break;
+      case 2:  // normal operation, heater on
+        analogWrite(pinLED1, hiLED);
+        break;
+      case 3:  // high temperature alarm, heater off
+        if ((millis() % 2000) > 1000) {
+          analogWrite(pinLED1, loLED);
+        } else {
+          analogWrite(pinLED1, loLED/4);
+        }
+        break;
+      case 4:  // high temperature alarm, heater on
+        if ((millis() % 2000) > 1000) {
+          analogWrite(pinLED1, hiLED);
+        } else {
+          analogWrite(pinLED1, loLED);
+        }
+        break;
+    }
+  }
+}
+
+// set Heater 1
+void setHeater1(float qval) {
+  Q1 = max(0., min(qval, 100.));
+  analogWrite(pinQ1, (Q1*P1)/100);
+}
+
+// set Heater 2
+void setHeater2(float qval) {
+  Q2 = max(0., min(qval, 100.));
+  analogWrite(pinQ2, (Q2*P2)/100);
+}
+
+// arduino startup
+void setup() {
+  analogReference(EXTERNAL);
+  while (!Serial) {
+    ; // wait for serial port to connect.
+  }
+  Serial.begin(baud);
+  Serial.flush();
+  setHeater1(0);
+  setHeater2(0);
+  ledTimeout = millis() + 1000;
+}
+
+// arduino main event loop
+void loop() {
+  readCommand();
+  if (DEBUG) echoCommand();
+  parseCommand();
+  dispatchCommand();
+  checkAlarm();
+  updateStatus();
+}


use CS=10 for SD card

use CS=10 for SD card

--- Reaper/examples/CommandLoop/CommandLoop.ino
+++ Reaper/examples/CommandLoop/CommandLoop.ino
@@ -4,7 +4,7 @@

 #include <ReaperCommandProcessor.h>

-const int chipSelect = SS;
+const int chipSelect = 10;

 Reaper reaper = Reaper(SerialUSB, chipSelect);
 ReaperCommandProcessor proc(SerialUSB, reaper);


reset esp on bbutton_downp_isr

reset esp on bbutton_downp_isr

--- _64-esp8266-atmega328p-i2c8x8-mma-8452-dash-button/a-02-atmega328p/a-02-atmega328p.ino
+++ _64-esp8266-atmega328p-i2c8x8-mma-8452-dash-button/a-02-atmega328p/a-02-atmega328p.ino
@@ -52,6 +52,7 @@
 uint16_t pir_interuptCount = 0;
 volatile bool haveData = false;
 volatile bool bbutton_up_isr = false;
+volatile bool bbutton_downp_isr = false;

 unsigned long duration;

@@ -74,6 +75,7 @@

 void button_down_isr()
 {
+  bbutton_downp_isr = true;
   startMiils = millis();
   detachInterrupt(digitalPinToInterrupt(BUTTON_INT));
   attachInterrupt(digitalPinToInterrupt(BUTTON_INT), button_up_isr, RISING);
@@ -109,7 +111,7 @@
   Serial.println("going to sleep....");
   Serial.flush();

-  bbutton_up_isr = false;
+  bbutton_up_isr = bbutton_downp_isr = false;
   haveData = false;
   device_pro.button = device_pro.esp8266 = 0;
   device_pro.hash = calc_hash(device_pro);
@@ -117,8 +119,11 @@
   attachInterrupt(digitalPinToInterrupt(BUTTON_INT), button_down_isr, FALLING);
   LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

-  Serial.println("Wake up....");
-  reset_esp();
+  if (bbutton_downp_isr)
+  {
+    Serial.println("Wake up....");
+    reset_esp();
+  }
 }

 void setup()


Update z_interrupt_events.ino

Update z_interrupt_events.ino

Change to use serial input

--- z_interrupt_events.ino
+++ z_interrupt_events.ino
@@ -1,49 +1,136 @@
-// encoder event for the interrupt call
-
-void rightEncoderEvent() {
-  if (digitalRead(RH_ENCODER_A) == HIGH) {
-    if (digitalRead(RH_ENCODER_B) == LOW) {
-      rightCount++;
-    } else {
-      rightCount--;
-    }
-  } else {
-    if (digitalRead(RH_ENCODER_B) == LOW) {
-      rightCount--;
-    } else {
-      rightCount++;
-    }
-  }
-
-  //  Serial.println(rightCount);
-  //delay(1);
-}
-
-
-void receiveEvent(int howMany)
-{
-  String test = "";
-  while (1 < Wire2.available()) // loop through all but the last
-  {
-    Serial.println("");
-    Serial.println("Start:Received from Pi");
-    char c = Wire2.read(); // receive byte as a character
-    Serial.print("This is what c looks like:");
-    Serial.println(c);
-    test += c;
-    Serial.print("Test contents:");
-    Serial.println(test);
-
-  }
-    Serial.println("received from pi");
-  Serial.println(test);
-  String test2=test.substring(1);
-  PSARJ = test2.toFloat();
-  Serial.println(PSARJ);
-
-  int x = Wire2.read();    // receive byte as an integer
-  //Serial.println(x);         // print the integer
-  //Serial.println();
-  Serial.println("Inside the Wire Read loop");
-  Serial.flush();
+// encoder event for the interrupt call
+
+void rightEncoderEvent() {
+  if (digitalRead(RH_ENCODER_A) == HIGH) {
+    if (digitalRead(RH_ENCODER_B) == LOW) {
+      rightCount++;
+    } else {
+      rightCount--;
+    }
+  } else {
+    if (digitalRead(RH_ENCODER_B) == LOW) {
+      rightCount--;
+    } else {
+      rightCount++;
+    }
+  }
+
+  //  Serial.println(rightCount);
+  //delay(1);
 }
+
+
+/*void receiveEvent(int howMany)
+{
+  String test = "";
+  while (1 < Wire2.available()) // loop through all but the last
+  {
+    Serial.println("");
+    Serial.println("Start:Received from Pi");
+    char c = Wire2.read(); // receive byte as a character
+    Serial.print("This is what c looks like:");
+    Serial.println(c);
+    test += c;
+    Serial.print("Test contents:");
+    Serial.println(test);
+
+  }
+    Serial.println("received from pi");
+  Serial.println(test);
+  String test2=test.substring(1);
+  PSARJ = test2.toFloat();
+  Serial.println(PSARJ);
+
+  int x = Wire2.read();    // receive byte as an integer
+  //Serial.println(x);         // print the integer
+  //Serial.println();
+  Serial.println("Inside the Wire Read loop");
+  Serial.flush();
+}*/
+void checkSerial()
+{
+  //digitalWrite(ledBluePin, HIGH);
+  test = "";
+
+  while(Serial1.available())
+  {
+    test = Serial1.readString();
+  }
+  //Serial.println(test);
+  char sz[test.length() + 1];
+  char copy[test.length() + 1];
+  strcpy(sz, test.c_str());
+  char *p = sz;
+  char *str;
+  int delimeter = 0;
+  String test2 = "";
+
+  while((str = strtok_r(p," ",&p))!=NULL)
+  {
+    test2 = String(str);
+    delimeter = test2.indexOf('=');
+    if(test2.substring(0,delimeter)=="PSARJ")
+    {
+      PSARJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="SSARJ")
+    {
+      SSARJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="PTRRJ")
+    {
+      PTRRJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="STRRJ")
+    {
+      STRRJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta1B")
+    {
+      Beta1B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta1A")
+    {
+      Beta1A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta2B")
+    {
+      Beta2B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta2A")
+    {
+      Beta2A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta3B")
+    {
+      Beta3B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta3A")
+    {
+      Beta3A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta4B")
+    {
+      Beta4B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta4A")
+    {
+      Beta4A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="AOS")
+    {
+      //Serial.println(test2);
+      AOS = (test2.substring(delimeter+1)).toFloat();
+      //Serial.println(AOS);
+      if(AOS == 1.00)
+      {
+        //digitalWrite(ledGreenPin, HIGH);
+      }
+      else
+      {
+        //digitalWrite(ledRedPin, HIGH);
+      }
+    }
+  }
+
+}


Fixed Neopixel

Fixed Neopixel

--- examples/Firebase_ESP8266_LEDs/Firebase_ESP8266_Neopixel/Firebase_ESP8266_Neopixel.ino
+++ examples/Firebase_ESP8266_LEDs/Firebase_ESP8266_Neopixel/Firebase_ESP8266_Neopixel.ino
@@ -22,41 +22,45 @@
 #include <Adafruit_NeoPixel.h>
 #include "colors_ext.h"

-const int PIN=13;
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800);
-
 // Set these to run example.
 #define FIREBASE_HOST "example.firebaseio.com"
 #define FIREBASE_AUTH "token_or_secret"
 #define WIFI_SSID "SSID"
 #define WIFI_PASSWORD "PASSWORD"

+const int PIN=13;
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800);
+
+// TODO: Replace with your own credentials and keep these safe.
 Firebase fbase = Firebase(FIREBASE_HOST, FIREBASE_AUTH);

-void ConnectWifi(const String& ssid, const String& password = "") {
-  if (password != "") {
-    WiFi.begin(ssid, password);
-  } else {
-    WiFi.begin(ssid);
-  }
+void setup() {
+  Serial.begin(9600);

+  strip.begin();
+  strip.setBrightness(25); // 0 ... 255
+  strip.show(); // Initialize all pixels to 'off'
+
+  // Not connected, set the LEDs red
+  colorWipe(&strip, 0xFF0000, 50);
+
+  // connect to wifi.
+  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
   Serial.print("connecting");
+
+  int count = 0;
   while (WiFi.status() != WL_CONNECTED) {
+    // Draw rainbows while connecting
     Serial.print(".");
-    delay(500);
+    if (count < strip.numPixels()){
+       strip.setPixelColor(count++, Wheel(&strip, count * 8));
+       strip.show();
+    }
+    delay(20);
   }
   Serial.println();
   Serial.print("connected: ");
   Serial.println(WiFi.localIP());
-}
-
-void setup() {
-  Serial.begin(9600);
-  ConnectWifi(WIFI_SSID, WIFI_PASSWORD);
-
-  strip.begin();
-  strip.setBrightness(25); // 0 ... 255
-  strip.show(); // Initialize all pixels to 'off'

   // Connected, set the LEDs green
   colorWipe(&strip, 0x00FF00, 50);


update fixes still error in checksum

update fixes still error in checksum

--- Arduino/GT-86/GT-86.ino
+++ Arduino/GT-86/GT-86.ino
@@ -7,16 +7,39 @@
 MS5611 ms5611;

+uint32_t time;

 MPU6050 accelgyro;
 HMC5883L mag;

-int16_t ax, ay, az;
-int16_t gx, gy, gz;
-int16_t mx, my, mz;
+
+typedef struct {
+  uint16_t header;
+  int16_t ax, ay, az;
+  int16_t gx, gy, gz;
+  int16_t mx, my, mz;
+  float absoluteAltitude;
+  uint32_t t_stemp;
+  uint16_t footer;
+} data_struct;
+
+data_struct ds;
+
+void chksum()
+{
+  uint16_t sum=0;
+  ds.t_stemp=millis();
+  for(int i=1;i<(sizeof(ds)/2-2);i++)
+  {
+    uint16_t* pds=(uint16_t*)&ds;
+    sum+=pds[i];
+  }
+  ds.footer=sum;
+}

 #define LED_PIN 13
 bool blinkState = false;
+int iters=0;

 void setup() {

@@ -25,7 +48,7 @@
    accelgyro.setI2CBypassEnabled(true) ;
    accelgyro.setSleepEnabled(false);

-   Serial.begin(38400);
+   Serial.begin(115200);

    // initialize device
    Serial.println("Initializing I2C devices...");
@@ -37,30 +60,34 @@
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

+   ms5611.setOversampling(MS5611_ULTRA_HIGH_RES);
    ms5611.begin();

    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
+   ds.header=0xa5a5;
 }
+

 void loop() {

-   accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
-   mag.getHeading(&mx, &my, &mz);
+   accelgyro.getMotion6(&ds.ax, &ds.ay, &ds.az, &ds.gx, &ds.gy, &ds.gz);
+   mag.getHeading(&ds.mx, &ds.my, &ds.mz);
      // Read raw values
-   uint32_t rawTemp = ms5611.readRawTemperature();
-   uint32_t rawPressure = ms5611.readRawPressure();
+   //uint32_t rawTemp = ms5611.readRawTemperature();
+   //uint32_t rawPressure = ms5611.readRawPressure();

    // Read true temperature & Pressure
-   double realTemperature = ms5611.readTemperature();
-   long realPressure = ms5611.readPressure();
+   //double realTemperature = ms5611.readTemperature();
+   int32_t realPressure = ms5611.readPressure();

    // Calculate altitude
-   float absoluteAltitude = ms5611.getAltitude(realPressure);
+   ds.absoluteAltitude = ms5611.getAltitude(realPressure);
    //float relativeAltitude = ms5611.getAltitude(realPressure, referencePressure);

    // display tab-separated accel/gyro x/y/z values
+#if 0
    Serial.print("a/g:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.print(ay); Serial.print("\t");
@@ -83,7 +110,16 @@

    Serial.print("alt:\t");
    Serial.println( absoluteAltitude );
+#else
+
+   chksum();
+   Serial.write((const uint8_t*)&ds,sizeof(ds));
+#endif
    // blink LED to indicate activity
-   blinkState = !blinkState;
-   digitalWrite(LED_PIN, blinkState);
+   iters+=1;
+   if(iters%10==0){
+       blinkState = !blinkState;
+       digitalWrite(LED_PIN, blinkState);
+   }
+   delay(100);
 }


Unnecessary explicit array 0-initialization removed (http://arduino.stackexchange.com/a/35146/15425)

--- ArduinoAudioSpectrumAnalyzer.ino
+++ ArduinoAudioSpectrumAnalyzer.ino
@@ -62,7 +62,7 @@

 volatile bool samplingWindowFull = false;
 uint16_t currentSampleIndex = 0;
-volatile uint16_t samples[SamplingWindowSize] = {0};
+volatile uint16_t samples[SamplingWindowSize];

 ISR(ADC_vect) //when new ADC value ready
 {


Changed number of sensors to display to 1

--- resistive_cap_touch.ino
+++ resistive_cap_touch.ino
@@ -19,7 +19,7 @@
 #include "restouch.h"
 #include "configuration.h"

-#define BAR_N_SENSORS 4
+#define BAR_N_SENSORS 1
 #define BAR_LENGTH (40 * 4 / BAR_N_SENSORS)

 void serial_write(char *s)


updated parallel out 2

updated parallel out 2

--- proj/parallel_out_test_2/parallel_out_test_2.ino
+++ proj/parallel_out_test_2/parallel_out_test_2.ino
@@ -6,6 +6,8 @@

 CRGB leds[NUM_STRIPS * NUM_LED];
+
+CRGB led_inter[NUM_STRIPS][NUM_LED];

 // READ ME!!! //
@@ -60,8 +62,13 @@
   update_RainbowBlack_p();
   theater_chase();

+  for(uint8_t strip = 0; strip < NUM_STRIPS; strip++) {
+    for(uint8_t ll = 0; ll < NUM_LED; ll++) {
+      leds[strip*NUM_LED + ll] = led_inter[strip][ll];
+    }
+  }

-  //LEDS.setBrightness(32);
+  LEDS.show();
   LEDS.delay(100);
 }

@@ -71,10 +78,10 @@
     pal_index++;
   }

-  for (uint8_t ss = 0; ss < NUM_STRIPS; ss ++) {
-    fill_palette(leds + (ss * NUM_LED), NUM_LED, pal_index, 6, gPalette, 60, LINEARBLEND);
+  for (uint8_t ss = 0; ss < NUM_STRIPS; ss++) {
+    fill_palette(led_inter[ss], NUM_LED, pal_index, 6, gPalette, 60, LINEARBLEND);
   }
-  LEDS.show();
+
 }

 // RB|B|B|B repeating


updated parallel out 2

updated parallel out 2

--- proj/parallel_out_test_2/parallel_out_test_2.ino
+++ proj/parallel_out_test_2/parallel_out_test_2.ino
@@ -37,7 +37,7 @@
   // LEDS.addLeds<WS2811_PORTA,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
   // LEDS.addLeds<WS2811_PORTB,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
   // LEDS.addLeds<WS2811_PORTD,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
-  LEDS.addLeds<WS2811_PORTD, NUM_STRIPS>(leds, NUM_LED).setCorrection(TypicalLEDStrip);
+  LEDS.addLeds<WS2811_PORTD, NUM_STRIPS>(leds, NUM_LED);
   LEDS.setBrightness(32);

   LEDS.setMaxPowerInMilliWatts(24000);
@@ -45,12 +45,12 @@

 void loop() {

-  for (uint8_t ss = 0; ss < NUM_STRIPS; ss+=16) {
-    fill_solid(&(leds[ss*NUM_LED]), NUM_LED, CHSV(ss, 192, 55));
-
+
+  for (uint8_t ss = 0; ss < NUM_STRIPS; ss++) {
+    fill_solid(&(leds[ss*NUM_LED]), NUM_LED, CHSV(ss*16, 192, 55));
   }

   //LEDS.setBrightness(32);
   LEDS.show();
-  LEDS.delay(10);
+  LEDS.delay(100);
 }


Update edge agent

Update edge agent

--- AndroidTVGateway/edge-agent/edge-agent.ino
+++ AndroidTVGateway/edge-agent/edge-agent.ino
@@ -28,11 +28,11 @@
       digitalWrite(LED, LOW);
       XBee.print("OK\r");
     } else if (a == 'D') {
-      float h = dht.readHumidity();
-      float t = dht.readTemperature();
+      int h = dht.readHumidity();
+      int t = dht.readTemperature();
       XBee.print("Humidity: ");
       XBee.print(h);
-      XBee.print(" %\t");
+      XBee.print("%  ");
       XBee.print("Temperature: ");
       XBee.print(t);
       XBee.print("C\r");