Remove some external commands and cleanup

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -15,24 +15,28 @@
 #include <LiquidCrystal.h>
 #include <EEPROM.h>

-// debug bit masks:
-#define DEBUG_DDS     (1 << 0)
-#define DEBUG_FREQ    (1 << 1)
-#define DEBUG_MENU    (1 << 2)
-#define DEBUG_EVENT   (1 << 3)
-#define DEBUG_ACT     (1 << 4)
-#define DEBUG_RE      (1 << 5)
-#define DEBUG_INT     (1 << 6)
-#define DEBUG_DISP    (1 << 7)
-#define DEBUG_BATT    (1 << 8)
-
-#define DEBUG         (DEBUG_BATT)
-//#define DEBUG         0
+
+//-----------------
+// debug bit masks
+//-----------------
+#define DEBUG_DDS     (1 << 0)  // DDS debug
+#define DEBUG_FREQ    (1 << 1)  // frequency stuff
+#define DEBUG_MENU    (1 << 2)  // menu
+#define DEBUG_EVENT   (1 << 3)  // virtual events
+#define DEBUG_ACT     (1 << 4)  // actions
+#define DEBUG_RE      (1 << 5)  // rotary encoder
+#define DEBUG_INT     (1 << 6)  // interrupts
+#define DEBUG_DISP    (1 << 7)  // display
+#define DEBUG_BATT    (1 << 8)  // battery
+
+// DEBUG word for debugging program - bitmask values
+//#define DEBUG         (DEBUG_EVENT)
+#define DEBUG         0

 // Digital VFO program name & version
 const char *ProgramName = "DigitalVFO";
 const char *Version = "1.4";
-const char *MinorVersion = ".0";
+const char *MinorVersion = ".1";
 const char *Callsign = "vk4fawr";

 // display constants - below is for ubiquitous small HD44780 16x2 display
@@ -69,9 +73,9 @@
 const byte mc_BattVolts = 19;

 // define microcontroller pins connected to the rotary encoder
-const int re_pinPush = 4;  // encoder pushbutton pin
-const int re_pinA = 3;     // encoder A pin
-const int re_pinB = 2;     // encoder B pin
+const int re_pinPush = 4;     // encoder pushbutton pin
+const int re_pinA = 3;        // encoder A pin
+const int re_pinB = 2;        // encoder B pin

 // define microcontroller pins that control the DDS-60
 const byte DDS_FQ_UD = 16;    // connected to AD9851 device select pin
@@ -258,14 +262,16 @@
 /* restart the Teensy, without invoking bootloader. */
 void restart(void)
 {
-  // 0000101111110100000000000000100
-  // Assert [2]SYSRESETREQ
+  Serial.printf(F("Restarting ...\n"));
+  delay(500);
   WRITE_RESTART(0x5FA0004);
 }

 /* reboot the Teensy, invoking bootloader. */
 void reboot(void)
 {
+  Serial.printf(F("Rebooting ...\n"));
+  delay(500);
   _reboot_Teensyduino_();
 }

@@ -397,10 +403,10 @@
   for (int i = LcdBrightness; i; --i)
   {
     analogWrite(mc_Brightness, i);
-    delay(15);
+    delay(20);
   }
   lcd.clear();
-  delay(400);
+  delay(200);
   analogWrite(mc_Brightness, LcdBrightness);
 }

@@ -535,8 +541,6 @@

 void vfo_display_mode(void)
 {
-// FIXME: if we display something else on bottom row change this code!
-
   // clear row 1 and write new mode string
   lcd.setCursor(0, 1);
   lcd.write(BlankRow);
@@ -553,19 +557,11 @@
 //     BH;          boot hard, reload software via USB
 //     BS;          boot soft, restart program
 //     ID;          get device identifier string
-//     MSO;         set VFO mode to 'online'
-//     MSS;         set VFO mode to 'standby'
+//     MO;          set VFO mode to 'online'
+//     MS;          set VFO mode to 'standby'
 //     MG;          get VFO mode
 //     FSnnnnnnnn;  set frequency to 'nnnnnnnn'
 //     FG;          get frequency
-//     CSn;         set cursor to index 'n'
-//     CG;          get cursor index
-//     DS+n;        increment display selected digit by 'n'
-//     DS-n;        decrement display selected digit by 'n'
-//     DBSn;        set display brightness to N (0, 128)
-//     DBG;         get display brightness
-//     DCSn;        set display contrast to N (0, 128)
-//     DCG;         get display contrast
 //     VG;          get measured battery voltage
 //##############################################################################

@@ -586,21 +582,13 @@
   strcat(answer, (char *) F("MG;          get VFO mode\n"));
   strcat(answer, (char *) F("FSnnnnnnnn;  set frequency to 'nnnnnnnn'\n"));
   strcat(answer, (char *) F("FG;          get frequency\n"));
-  strcat(answer, (char *) F("CSn;         set cursor to index 'n'\n"));
-  strcat(answer, (char *) F("CG;          get cursor index\n"));
-  strcat(answer, (char *) F("DS+n;        increment display selected digit by 'n'\n"));
-  strcat(answer, (char *) F("DS-n;        decrement display selected digit by 'n'\n"));
-  strcat(answer, (char *) F("PBSnn;       set presentation brightness to N [1, 16]\n"));
-  strcat(answer, (char *) F("PBG;         get presentation brightness\n"));
-  strcat(answer, (char *) F("PCSnn;       set presentation contrast to N [1, 16]\n"));
-  strcat(answer, (char *) F("PCG;         get presentation contrast\n"));
   strcat(answer, (char *) F("------------------------------------------------\n"));
   return answer;
 }

 //----------------------------------------
 // Boot:
-//     BR;  boot, reload software via USB
+//     BH;  boot, reload software via USB
 //     BS;  boot soft, restart program
 //----------------------------------------

@@ -612,7 +600,6 @@
   switch (cmd[1])
   {
     case 'H':
-      // hard reboot DOESN'T SEEM TO WORK YET, not reloading from IDE?
       reboot();
       return "Doing hard reboot";
     case 'S':
@@ -643,8 +630,8 @@

 //----------------------------------------
 // Mode commands:
-//     MSO;
-//     MSS;
+//     MO;
+//     MS;
 //     MG;
 //----------------------------------------

@@ -721,269 +708,6 @@
 }

 //----------------------------------------
-// Cursor commands:
-//     CSn;  set cursor index to 'n'
-//     CG;   get cursor index
-//----------------------------------------
-
-const char * xcmd_cursor(char *answer, char *cmd)
-{
-  switch (cmd[1])
-  {
-    case 'G':
-      // return cursor index
-      if (strlen(cmd) == 3)
-      {
-        answer[0] = VfoSelectDigit + '0';
-        answer[1] = '\0';
-        return answer;
-      }
-      break;
-    case 'S':
-      if (strlen(cmd) == 4)
-      {
-        char *result_ptr = cmd + 2;
-
-        int new_index = *result_ptr - '0';
-        if (new_index <= 7)
-        {
-          VfoSelectDigit = new_index;
-          display_sel_value(VfoFrequency, VfoSelectDigit,
-                            NumFreqChars, NumCols - NumFreqChars - 2, 0);
-          return "OK";
-        }
-      }
-      break;
-  }
-
-  return "ERROR";
-}
-
-//----------------------------------------
-// Digit commands:
-//     DS+n;        increment frequency digit by 'n'
-//     DS-n;        decrement frequency digit by 'n'
-//----------------------------------------
-
-const char * xcmd_digit(char *answer, char *cmd)
-{
-  switch (cmd[1])
-  {
-    case 'S':
-      if (strlen(cmd) == 5)
-      {
-        char sign = *(cmd + 2);
-
-        if (sign == '+' || sign == '-')
-        {
-          int inc = *(cmd + 3) - '0';
-
-          if (inc >= 0 && inc <= 9)
-          {
-            if (sign == '+')
-            {
-              while (inc--)
-              {
-                VfoFrequency += offset2bump[VfoSelectDigit];
-              }
-              if (VfoFrequency > MaxFreq)
-                VfoFrequency = MaxFreq;
-              display_sel_value(VfoFrequency, VfoSelectDigit,
-                                NumFreqChars, NumCols - NumFreqChars - 2, 0);
-            }
-            else
-            {
-              while (inc--)
-              {
-                VfoFrequency -= offset2bump[VfoSelectDigit];
-              }
-              if (VfoFrequency < MinFreq)
-                VfoFrequency = MinFreq;
-              display_sel_value(VfoFrequency, VfoSelectDigit,
-                                NumFreqChars, NumCols - NumFreqChars - 2, 0);
-            }
-            return "OK";
-          }
-        }
-      }
-      break;
-  }
-
-  return "ERROR";
-}
-
-//----------------------------------------
-// Convert a brightness 'index' to a brightness value.
-//
-//     index  brightness index in [1, 16]
-//
-// Returns the brightness value in range [15, 255], step 16.
-//----------------------------------------
-int brightness_index2value(int index)
-{
-  // clamp 'index' to range [1, 16]
-  if (index < 1) index = 1;
-  if (index > 16) index = 16;
-
-  // return the appropriate value
-  return index * 16 - 1;
-}
-
-//----------------------------------------
-// Convert a brightness value to a brightness 'index'.
-//
-//     value  brightness value in the range [15, 255], step 16
-//
-// Returns the brightness index in range [1, 16].
-//----------------------------------------
-int brightness_value2index(int value)
-{
-  // clamp 'value' to canonical value in range [15, 255], step 10
-  if (value < 15) value = 15;
-  if (value > 255) value = 255;
-  value = ((value + 1) / 16) * 16 - 1;
-
-  return (value + 16) / 16;
-}
-
-//----------------------------------------
-// Convert a contrast 'index' to a contrast value.
-//
-//     index  contrast index in [0, 15]
-//
-// Returns the contrast value in range [0, 150], step 10.
-//----------------------------------------
-int contrast_index2value(int index)
-{
-  // clamp 'index' to range [0, 15]
-  if (index < 0) index = 0;
-  if (index > 15) index = 15;
-
-  // return the appropriate value
-  return index * 10;
-}
-
-//----------------------------------------
-// Convert a contrast value to a contrast 'index'.
-//
-//     value  contrast value in the range [0, 150], step 10
-//
-// Returns the contrast index in range [0, 15].
-//----------------------------------------
-int contrast_value2index(int value)
-{
-  // clamp 'value' to canonical value in range [0, 150], step 10
-  if (value < 0) value = 0;
-  if (value > 150) value = 150;
-  value = (value / 10) * 10;
-
-  return value / 10;
-}
-
-//----------------------------------------
-// Display:
-//     PBSn;  presentation brightness set to N [1, 16]
-//     PBG;   get presentation brightness
-//     PCSn;  presentation contrast set to N [0, 15]
-//     PCG;   get presentation contrast
-//----------------------------------------
-
-const char * xcmd_presentation(char *answer, char *cmd)
-{
-  switch (cmd[1])
-  {
-    case 'B':
-      // brightness
-      switch (cmd[2])
-      {
-        case 'S':
-        {
-            // set brightness
-            char *ch_ptr = cmd + 3;
-
-            while (*ch_ptr != ';')
-            {
-              char ch = *ch_ptr++;
-
-              if (ch < '0' || ch > '9')
-              {
-                return "ERROR";
-              }
-            }
-            *ch_ptr = '\0';    // remove terminating ';'
-            int b_index = (int) str2ulong(cmd+3);
-            if ((b_index < 1) || (b_index > 16))
-              return "ERROR";
-            LcdBrightness = brightness_index2value(b_index);
-            analogWrite(mc_Brightness, LcdBrightness);
-            return "OK";
-        }
-
-        case 'G':
-          // get brightness
-          int b_index = brightness_value2index(LcdBrightness);
-          Serial.printf(F("PBG: LcdBrightness=%d, b_index=%d\n"), LcdBrightness, b_index);
-          if (b_index > 9)
-          {
-            ulong2str(answer, 2, (int) b_index);
-            answer[2] = '\0';
-          }
-          else
-          {
-            ulong2str(answer, 1, (int) b_index);
-            answer[1] = '\0';
-          }
-          return answer;
-      }
-
-    case 'C':
-      // contrast
-      switch (cmd[2])
-      {
-        case 'S':
-          {
-            // set contrast
-            char *ch_ptr = cmd + 3;
-
-            while (*ch_ptr != ';')
-            {
-              char ch = *ch_ptr++;
-
-              if (ch < '0' || ch > '9')
-              {
-                return "ERROR";
-              }
-            }
-            *ch_ptr = '\0';    // remove terminating ';'
-            int c_index = (int) str2ulong(cmd+3);
-            if ((c_index < 0) || (c_index > 15))
-              return "ERROR";
-            LcdContrast = contrast_index2value(c_index);
-            analogWrite(mc_Contrast, LcdContrast);
-            return "OK";
-          }
-
-        case 'G':
-          // get contrast
-          int c_index = contrast_value2index(LcdContrast);
-          if (c_index > 9)
-          {
-            ulong2str(answer, 2, (int) c_index);
-            answer[2] = '\0';
-          }
-          else
-          {
-            ulong2str(answer, 1, (int) c_index);
-            answer[1] = '\0';
-          }
-          return answer;
-      }
-  }
-
-  return "ERROR";
-}
-
-//----------------------------------------
 // Convert a positive float < 10.0 to a string with 2 decimal places.
 //     buff         address of buffer to fill
 //     value        the float value to convert
@@ -1050,10 +774,6 @@
   {
     case 'B':
       return xcmd_boot(answer, cmd);
-    case 'C':
-      return xcmd_cursor(answer, cmd);
-    case 'D':
-      return xcmd_digit(answer, cmd);
     case 'F':
       return xcmd_freq(answer, cmd);
     case 'H':
@@ -1062,8 +782,6 @@
       return xcmd_id(answer, cmd);
     case 'M':
       return xcmd_mode(answer, cmd);
-    case 'P':
-      return xcmd_presentation(answer, cmd);
     case 'V':
       return xcmd_voltage(answer, cmd);
   }
@@ -1802,42 +1520,42 @@
 #define NEXT_FREE   (0)

 // address for Frequency 'frequency'
-const int AddressFreq = NEXT_FREE;
-#define NEXT_FREE   (AddressFreq + sizeof(Frequency))
+const int EepromFreq = NEXT_FREE;
+#define NEXT_FREE   (EepromFreq + sizeof(Frequency))

 // address for int 'selected digit'
-const int AddressSelDigit = NEXT_FREE;
-#define NEXT_FREE   (AddressSelDigit + sizeof(SelOffset))
+const int EepromSelDigit = NEXT_FREE;
+#define NEXT_FREE   (EepromSelDigit + sizeof(SelOffset))

 // address for 'VfoClockOffset' calibration
-const int AddressVfoClockOffset = NEXT_FREE;
-#define NEXT_FREE   (AddressVfoClockOffset + sizeof(VfoClockOffset))
+const int EepromVfoOffset = NEXT_FREE;
+#define NEXT_FREE   (EepromVfoOffset + sizeof(VfoClockOffset))

 // address for byte 'contrast'
-const int AddressContrast = NEXT_FREE;
-#define NEXT_FREE   (AddressContrast + sizeof(LcdContrast))
+const int EepromContrast = NEXT_FREE;
+#define NEXT_FREE   (EepromContrast + sizeof(LcdContrast))

 // address for byte 'brightness'
-const int AddressBrightness = NEXT_FREE;
-#define NEXT_FREE   (AddressBrightness + sizeof(LcdBrightness))
+const int EepromBrightness = NEXT_FREE;
+#define NEXT_FREE   (EepromBrightness + sizeof(LcdBrightness))

 // address for int 'hold click time'
-const int AddressHoldClickTime = NEXT_FREE;
-#define NEXT_FREE   (AddressHoldClickTime + sizeof(ReHoldClickTime))
+const int EepromHoldClickTime = NEXT_FREE;
+#define NEXT_FREE   (EepromHoldClickTime + sizeof(ReHoldClickTime))

 // address for int 'double click time'
-const int AddressDClickTime = NEXT_FREE;
-#define NEXT_FREE   (AddressDClickTime + sizeof(ReDClickTime))
+const int EepromDClickTime = NEXT_FREE;
+#define NEXT_FREE   (EepromDClickTime + sizeof(ReDClickTime))

 // number of frequency save slots in EEPROM
 const int NumSaveSlots = 10;

-const int SaveFreqBase = NEXT_FREE;
-#define NEXT_FREE   (SaveFreqBase + NumSaveSlots * sizeof(Frequency))
+const int EepromSaveFreqBase = NEXT_FREE;
+#define NEXT_FREE   (EepromSaveFreqBase + NumSaveSlots * sizeof(Frequency))

 //also save the offset for each frequency
-const int SaveOffsetBase = NEXT_FREE;
-#define NEXT_FREE   (SaveOffsetBase + NumSaveSlots * sizeof(SelOffset);
+const int EepromSaveOffsetBase = NEXT_FREE;
+#define NEXT_FREE   (EepromSaveOffsetBase + NumSaveSlots * sizeof(SelOffset);

 // additional EEPROM saved items go here

@@ -1848,13 +1566,13 @@

 void save_to_eeprom(void)
 {
-  EEPROM.put(AddressFreq, VfoFrequency);
-  EEPROM.put(AddressSelDigit, VfoSelectDigit);
-  EEPROM.put(AddressVfoClockOffset, VfoClockOffset);
-  EEPROM.put(AddressBrightness, LcdBrightness);
-  EEPROM.put(AddressContrast, LcdContrast);
-  EEPROM.put(AddressHoldClickTime, ReHoldClickTime);
-  EEPROM.put(AddressDClickTime, ReDClickTime);
+  EEPROM.put(EepromFreq, VfoFrequency);
+  EEPROM.put(EepromSelDigit, VfoSelectDigit);
+  EEPROM.put(EepromVfoOffset, VfoClockOffset);
+  EEPROM.put(EepromBrightness, LcdBrightness);
+  EEPROM.put(EepromContrast, LcdContrast);
+  EEPROM.put(EepromHoldClickTime, ReHoldClickTime);
+  EEPROM.put(EepromDClickTime, ReDClickTime);
 }

 //----------------------------------------
@@ -1864,13 +1582,13 @@

 void restore_from_eeprom(void)
 {
-  EEPROM.get(AddressFreq, VfoFrequency);
-  EEPROM.get(AddressSelDigit, VfoSelectDigit);
-  EEPROM.get(AddressVfoClockOffset, VfoClockOffset);
-  EEPROM.get(AddressBrightness, LcdBrightness);
-  EEPROM.get(AddressContrast, LcdContrast);
-  EEPROM.get(AddressHoldClickTime, ReHoldClickTime);
-  EEPROM.get(AddressDClickTime, ReDClickTime);
+  EEPROM.get(EepromFreq, VfoFrequency);
+  EEPROM.get(EepromSelDigit, VfoSelectDigit);
+  EEPROM.get(EepromVfoOffset, VfoClockOffset);
+  EEPROM.get(EepromBrightness, LcdBrightness);
+  EEPROM.get(EepromContrast, LcdContrast);
+  EEPROM.get(EepromHoldClickTime, ReHoldClickTime);
+  EEPROM.get(EepromDClickTime, ReDClickTime);
 }

 //----------------------------------------
@@ -1881,8 +1599,8 @@

 void get_slot(int slot_num, Frequency &freq, SelOffset &offset)
 {
-  int freq_address = SaveFreqBase + slot_num * sizeof(Frequency);
-  int offset_address = SaveOffsetBase + slot_num * sizeof(SelOffset);
+  int freq_address = EepromSaveFreqBase + slot_num * sizeof(Frequency);
+  int offset_address = EepromSaveOffsetBase + slot_num * sizeof(SelOffset);

   EEPROM.get(freq_address, freq);
   EEPROM.get(offset_address, offset);
@@ -1896,8 +1614,8 @@

 void put_slot(int slot_num, Frequency freq, SelOffset offset)
 {
-  int freq_address = SaveFreqBase + slot_num * sizeof(Frequency);
-  int offset_address = SaveOffsetBase + slot_num * sizeof(SelOffset);
+  int freq_address = EepromSaveFreqBase + slot_num * sizeof(Frequency);
+  int offset_address = EepromSaveOffsetBase + slot_num * sizeof(SelOffset);

   EEPROM.put(freq_address, freq);
   EEPROM.put(offset_address, offset);
@@ -1918,17 +1636,17 @@
   UINT hold;
   UINT dclick;

-  EEPROM.get(AddressFreq, freq);
-  EEPROM.get(AddressSelDigit, offset);
-  EEPROM.get(AddressVfoClockOffset, clkoffset);
-  EEPROM.get(AddressBrightness, brightness);
-  EEPROM.get(AddressContrast, contrast);
-  EEPROM.get(AddressHoldClickTime, hold);
-  EEPROM.get(AddressDClickTime, dclick);
+  EEPROM.get(EepromFreq, freq);
+  EEPROM.get(EepromSelDigit, offset);
+  EEPROM.get(EepromVfoOffset, clkoffset);
+  EEPROM.get(EepromBrightness, brightness);
+  EEPROM.get(EepromContrast, contrast);
+  EEPROM.get(EepromHoldClickTime, hold);
+  EEPROM.get(EepromDClickTime, dclick);

   Serial.printf(F("=================================================\n"));
   Serial.printf(F("dump_eeprom: VfoFrequency=%ld\n"), freq);
-  Serial.printf(F("             AddressSelDigit=%d\n"), offset);
+  Serial.printf(F("             EepromSelDigit=%d\n"), offset);
   Serial.printf(F("             VfoClockOffset=%d\n"), clkoffset);
   Serial.printf(F("             LcdBrightness=%d\n"), brightness);
   Serial.printf(F("             LcdContrast=%d\n"), contrast);
@@ -2074,13 +1792,6 @@
 {
   // initialize the serial console
   Serial.begin(115200);
-
-#if (DEBUG > 0)
-  Serial.printf(F("DEBUG is defined as %06X:\n"), DEBUG);
-  decode_debug_levels(DEBUG);
-#else
-  Serial.println("DEBUG is not turned on.");
-#endif

   // initialize the BlankRow global to a blank string length of a display row
   BlankRow = (char *) malloc(NumCols + 1);
@@ -2160,6 +1871,13 @@
   Serial.printf(F("%s %s%s (%s)\n"), ProgramName, Version, MinorVersion, Callsign);
 #endif

+#if (DEBUG > 0)
+  Serial.printf(F("DEBUG is defined as %06X:\n"), DEBUG);
+  decode_debug_levels(DEBUG);
+#else
+  Serial.println("DEBUG is not turned on.");
+#endif
+
   // dump EEPROM values
 #if (DEBUG != 0)
   dump_eeprom();
@@ -2565,7 +2283,6 @@
   int old_contrast = LcdContrast;

   // convert contrast value to a display value in [0, 15]
-//  int index = LcdContrast / 8;
   int index = LcdContrast / 10;

   if (index > 15)   // ensure in range
@@ -2619,7 +2336,6 @@
       }

       // adjust display contrast so we can see the results
-//      LcdContrast = index * 8;
       LcdContrast = index * 10;
       analogWrite(mc_Contrast, LcdContrast);
       Serial.printf(F("contrast_action: contrast set to %d\n"), LcdContrast);
@@ -3087,8 +2803,7 @@
       char answer[2048];

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


Update FX-SaberOS.ino

Update FX-SaberOS.ino

Reenable lockup button double-click so that jukebox mode can be enabled

--- FX-SaberOS.ino
+++ FX-SaberOS.ino
@@ -474,7 +474,7 @@
   lockupButton.setClickTicks(CLICK);
   lockupButton.setPressTicks(PRESS_CONFIG);
   lockupButton.attachClick(lockupClick);
-  //lockupButton.attachDoubleClick(lockupDoubleClick);
+  lockupButton.attachDoubleClick(lockupDoubleClick);
   lockupButton.attachLongPressStart(lockupLongPressStart);
   lockupButton.attachLongPressStop(lockupLongPressStop);
   lockupButton.attachDuringLongPress(lockupLongPress);


Fixed keybutton & strips

Fixed keybutton & strips

--- Pad/pad/pad.ino
+++ Pad/pad/pad.ino
@@ -23,15 +23,14 @@
 const int mouseLeft = 15; // click left mouse

-// neopixels
+// neopixels edge strip
 const int STRIP1_PIN = 9;
-#define NUM_LEDS_STRIP1      16
-int delay_strip1 = 500;
+#define NUM_LEDS_STRIP1      40
 CRGB strip1[NUM_LEDS_STRIP1];

+// neopixels top strip
 const int STRIP2_PIN = 10;
-#define NUM_LEDS_STRIP2      16
-int delay_strip2 = 500;
+#define NUM_LEDS_STRIP2      6
 CRGB strip2[NUM_LEDS_STRIP2];

 const int responseDelay = 70;
@@ -42,6 +41,7 @@

 byte mouse_read = 1;
 byte button_read = 1;
+int delay_strip = 50;

 void setup() {
   // initialize digital pins
@@ -58,19 +58,22 @@
   Keyboard.begin();
   FastLED.addLeds<NEOPIXEL, STRIP1_PIN>(strip1, NUM_LEDS_STRIP1);
   FastLED.addLeds<NEOPIXEL, STRIP2_PIN>(strip2, NUM_LEDS_STRIP2);
+  FastLED.setBrightness(50);
 }

 void loop() {
   // strip function
   for (int dot = 0; dot < NUM_LEDS_STRIP1; dot++) {
     strip1[dot] = CRGB::Blue;
+    strip2[dot] = CRGB::Blue;
     FastLED.show();

     button_check();

-    delay(30);
+    delay(delay_strip);
     // clear this led for the next time around the loop
     strip1[dot] = CRGB::Black;
+    strip2[dot] = CRGB::Black;
   }
 }

@@ -96,7 +99,7 @@
   if (i == 3) // right
     Keyboard.press('d');
   if (i == 4) // mouseLeft
-    Mouse.click(MOUSE_LEFT);
+    Mouse.click(MOUSE_RIGHT);
   if (i == 5) // jumpButton
     Keyboard.press(' ');
 }


Fixed 7-segment display pins for Garoa Dojo Shield

--- arduino/WildSnakeGS/WildSnakeGS.ino
+++ arduino/WildSnakeGS/WildSnakeGS.ino
@@ -61,7 +61,7 @@
 */

 //                A   B  C  D  E   F   G
-int display[] = {11, 10, 8, 7, 6, 12, 13}; // DojoXXG
+int display[] = {8, 9, 10, 11, 12, 13, 7}; // Garoa Dojo Shield
 const int SEGMENTS = 7;

 int head = 1; // segment B


Started filling in things for UPnP discovery of receiver.

--- MarantzVolumeMonitor.ino
+++ MarantzVolumeMonitor.ino
@@ -14,6 +14,13 @@
 LiquidCrystal lcd(LCD_RS, LCD_ENABLE, LCD_DB4, LCD_DB5, LCD_DB6, LCD_DB7);
 bool receiverOn;

+// For discovery...
+char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
+int discoveryPort = 1900;
+int localPort = 8888;
+IPAddress discoveryAddress(239, 255, 255, 250);
+EthernetUDP Udp;
+
 void setup()
 {
     // Initialize application state
@@ -69,8 +76,7 @@
     {
         Serial.println("Initiating setup");
         DisplayManager.showMessage("Running Setup");
-
-        delay(5000);
+        runDiscovery();
     }
     else
     {
@@ -116,6 +122,23 @@
     refreshDHCP();
 }

+void runDiscovery()
+{
+    Udp.begin(localPort);
+    memset(packetBuffer, 0, UDP_TX_PACKET_MAX_SIZE);
+    //"M-SEARCH * HTTP/1.1\r\nContent-Length: 0\r\nST: urn:schemas-upnp-org:device:MediaRenderer:1\r\nMX: 3\r\nMAN: \"ssdp:discover\"\r\nHOST: 239.255.255.250:1900\r\n"
+/*
+M-SEARCH * HTTP/1.1
+Content-Length: 0
+ST: urn:schemas-upnp-org:device:MediaRenderer:1
+MX: 3
+MAN: "ssdp:discover"
+HOST: 239.255.255.250:1900
+*/
+    // TODO: Send UDP search to get UPnP devices.
+    // TODO: Find Marantz receivers.
+}
+
 void refreshDHCP()
 {
     // Ethernet.maintain() ensures the DHCP lease is


no changes

no changes

--- Box_joint_final/Box_joint_final.ino
+++ Box_joint_final/Box_joint_final.ino
@@ -72,10 +72,9 @@
 void mainMenu() { //this is the overall menu controller

   if (green.isHit()){
-    noClear();
+    lcd.clear();
     menuMode++;
-    delay(50);
-
+
   }
   if (menuMode == 3) {
     menuMode = 0;
@@ -130,7 +129,10 @@
   }

   if (refreshScreen == 1 && !left_Rb.isHit() && !right_Rb.isHit()) {
-    noClearBottom();
+    lcd.setCursor(6,3);
+    lcd.print("         ");
+    lcd.setCursor(6, 2);
+    lcd.print("      ");
     refreshScreen = 0;
   }
   lcd.setCursor(0,0);
@@ -150,13 +152,13 @@
         }

   lcd.setCursor(0, 2);
-  lcd.print("Steps ");
-
-  lcd.setCursor(8, 2);
-  lcd.print("Inches ");
-  lcd.setCursor(1, 3);
-  lcd.print(targetSteps, DEC);
-  lcd.setCursor(9,3);
+  lcd.print("Step:");
+  lcd.setCursor(6, 2);
+  lcd.print(targetSteps, DEC);
+
+  lcd.setCursor(0, 3);
+  lcd.print("Inch:");
+  lcd.setCursor(6,3);
   lcd.print(targetInches,4);
 }


fixed servo issues

fixed servo issues

--- Firmeware/EnsembleSeven/EnsembleSeven.ino
+++ Firmeware/EnsembleSeven/EnsembleSeven.ino
@@ -51,6 +51,8 @@
 // servos
 Servo servo1, servo2;
 bool servoState[2]; // servo state to control servos out of MIDI loop
+bool _servoState[2]; // servo previous state
+
 float servoPos[2]; // servo current position
 float servoInc[2]; //servo increment value which relates to movement speed
 float servoMinInc[2]; // servo min increment values
@@ -67,7 +69,7 @@
 void setup() {
   MIDI.begin(MIDICH);
   MIDI.turnThruOn();
-
+
   // set output pins
   pinMode(A1, OUTPUT);
   pinMode(A2, OUTPUT);
@@ -91,6 +93,10 @@

   servoPos[1] = midi2angle(EEPROM.read(S2MINANG));
   servo2.write(servoPos[1]);
+
+  // set servos previous state
+  _servoState[0] = false;
+  _servoState[1] = false;

   // set servos' min&max increment values
   // NOTE: min/max inc values are between 0 and 127 (after mapped correspond to 0.1 to 10 degrees per millisecond)
@@ -139,10 +145,14 @@
             case 14:
               servoInc[0] = velocity2inc( servoMinInc[0], servoMaxInc[0], vel);
               servoState[0] = true;
+              _servoState[0] = true;
+
             break;
             case 24:
               servoInc[1] = velocity2inc( servoMinInc[1], servoMaxInc[1], vel);
               servoState[1] = true;
+              _servoState[1] = true;
+
             break;
             // activate motors and solenoids
             default:
@@ -179,7 +189,7 @@
   }

   runServos(); // activate servos
-  delay(1); // (used only to set servo increments in a millisecond basis)*/
+  //delay(1); // (used only to set servo increments in a millisecond basis)*/
 }

 /***************** FUNTCIONS *****************/
@@ -202,9 +212,10 @@
     servoPos[0] += servoInc[0];
   }
   // servo1 release
-  else if (servoState[0] == false){
+  else if (servoState[0] == false && _servoState[0] == true){
     servoPos[0] = servoMinAng[0];
-    servo1.write( servoPos[0] );
+    servo1.write( servoPos[0] );
+    _servoState[0] = false;
   }

   // servo2 attack
@@ -213,9 +224,10 @@
     servoPos[1] += servoInc[1];
   }
   // servo2 release
-  else if (servoState[1] == false){
+  else if (servoState[1] == false && _servoState[1] == true){
     servoPos[1] = servoMinAng[1];
     servo2.write( servoPos[1] );
+    _servoState[1] = false;
   }
 }

@@ -235,15 +247,19 @@
       break;
     case 124:
       servoMinAng[0] = midi2angle(v);
+      servo1.write(servoMinAng[0]);
       break;
     case 125:
       servoMaxAng[0] = midi2angle(v);
+      servo1.write(servoMaxAng[0]);
       break;
     case 126:
-      servoMinAng[1] = midi2angle(v);
+      servoMinAng[1] = midi2angle(v);
+      servo1.write(servoMinAng[1]);
       break;
     case 127:
       servoMaxAng[1] = midi2angle(v);
+      servo1.write(servoMaxAng[1]);
       break;

     default:


remove some glitches

remove some glitches

--- KillSwitchduino/KillSwitchduino.ino
+++ KillSwitchduino/KillSwitchduino.ino
@@ -1211,7 +1211,6 @@
       if (CalibratingStageCounter==2 || CalibratingStageCounter==4 )
         {
           for (CalibratingCounter=0; CalibratingCounter <= 255; CalibratingCounter++){
-            MainStateHandler();
            CalibratingInput(CalibratingStageCounter);
           }
         } else {CalibratingInput(CalibratingStageCounter);}


1_0 example can't send all commands out over client instead of serial so deleting

--- examples/skynetim_StandardFirmata_1_0/skynetim_StandardFirmata_1_0.ino
+++ examples/skynetim_StandardFirmata_1_0/skynetim_StandardFirmata_1_0.ino
@@ -1,719 +0,0 @@
-/*
- *                SSSSS  kk                            tt
- *               SS      kk  kk yy   yy nn nnn    eee  tt
- *                SSSSS  kkkkk  yy   yy nnn  nn ee   e tttt
- *                    SS kk kk   yyyyyy nn   nn eeeee  tt
- *                SSSSS  kk  kk      yy nn   nn  eeeee  tttt
- *                               yyyyy
- *
- * SkynetClient for http://skynet.im, OPEN COMMUNICATIONS NETWORK & API FOR
- * THE INTERNET OF THINGS.
- *
- * This sketch is for Arduino 1.0 and waits for firmata commands via Skynet.
- * For a node example to communicate with the Arduino, see
- * https://www.npmjs.org/package/skynet-serial
- *
- * Main changes from Standard Firmata were:
- * Pass the SkynetClient object to Firmata.begin() instead of baud rate or
- * Serial object.
- *
- * Make sure systemResetCallback doesnt mess with the ethernet's unavailable pins.
- * If you mess with them remotely beyond that, its on you. (10,11,12 and 13)
- *
- * Works with ethernet shields compatible with EthernetClient library from
- * Arduino. If you don't know, grab the original
- * http://arduino.cc/en/Main/ArduinoEthernetShield
- *
- * Also requires the ArduinoJsonParser
- * https://github.com/bblanchon/ArduinoJsonParser
- *
- * You can turn on debugging within SkynetClient.h by uncommenting
- * #define SKYNETCLIENT_DEBUG
- */
-
-/*
- * Firmata is a generic protocol for communicating with microcontrollers
- * from software on a host computer. It is intended to work with
- * any host computer software package.
- *
- * To download a host software package, please clink on the following link
- * to open the download page in your default browser.
- *
- * http://firmata.org/wiki/Download
- */
-
-/*
-  Copyright (C) 2006-2008 Hans-Christoph Steiner.  All rights reserved.
-  Copyright (C) 2010-2011 Paul Stoffregen.  All rights reserved.
-  Copyright (C) 2009 Shigeru Kobayashi.  All rights reserved.
-  Copyright (C) 2009-2011 Jeff Hoefs.  All rights reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  See file LICENSE.txt for further informations on licensing terms.
-
-  formatted using the GNU C formatting and indenting
-*/
-
-/*
- * TODO: use Program Control to load stored profiles from EEPROM
- */
-
-#include <Servo.h>
-#include <Wire.h>
-#include <Firmata.h>
-#include <EEPROM.h>
-#include "Ethernet.h"
-#include "SPI.h"
-#include "SkynetClient.h"
-#include <JsonParser.h>
-
-EthernetClient client;
-
-SkynetClient skynetclient(client);
-
-//you can't have 2 of the same mac on your network!
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-
-char hostname[] = "skynet.im";
-int port = 80;
-
-// move the following defines to Firmata.h?
-#define I2C_WRITE B00000000
-#define I2C_READ B00001000
-#define I2C_READ_CONTINUOUSLY B00010000
-#define I2C_STOP_READING B00011000
-#define I2C_READ_WRITE_MODE_MASK B00011000
-#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
-
-#define MAX_QUERIES 8
-#define MINIMUM_SAMPLING_INTERVAL 10
-
-#define REGISTER_NOT_SPECIFIED -1
-
-/*==============================================================================
- * GLOBAL VARIABLES
- *============================================================================*/
-
-/* analog inputs */
-int analogInputsToReport = 0; // bitwise array to store pin reporting
-
-/* digital input ports */
-byte reportPINs[TOTAL_PORTS];       // 1 = report this port, 0 = silence
-byte previousPINs[TOTAL_PORTS];     // previous 8 bits sent
-
-/* pins configuration */
-byte pinConfig[TOTAL_PINS];         // configuration of every pin
-byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else
-int pinState[TOTAL_PINS];           // any value that has been written
-
-/* timer variables */
-unsigned long currentMillis;        // store the current value from millis()
-unsigned long previousMillis;       // for comparison with currentMillis
-int samplingInterval = 19;          // how often to run the main loop (in ms)
-
-/* i2c data */
-struct i2c_device_info {
-  byte addr;
-  byte reg;
-  byte bytes;
-};
-
-/* for i2c read continuous more */
-i2c_device_info query[MAX_QUERIES];
-
-byte i2cRxData[32];
-boolean isI2CEnabled = false;
-signed char queryIndex = -1;
-unsigned int i2cReadDelayTime = 0;  // default delay time between i2c read request and Wire.requestFrom()
-
-Servo servos[MAX_SERVOS];
-/*==============================================================================
- * FUNCTIONS
- *============================================================================*/
-
-void readAndReportData(byte address, int theRegister, byte numBytes) {
-  // allow I2C requests that don't require a register read
-  // for example, some devices using an interrupt pin to signify new data available
-  // do not always require the register read so upon interrupt you call Wire.requestFrom()
-  if (theRegister != REGISTER_NOT_SPECIFIED) {
-    Wire.beginTransmission(address);
-    #if ARDUINO >= 100
-    Wire.write((byte)theRegister);
-    #else
-    Wire.send((byte)theRegister);
-    #endif
-    Wire.endTransmission();
-    delayMicroseconds(i2cReadDelayTime);  // delay is necessary for some devices such as WiiNunchuck
-  } else {
-    theRegister = 0;  // fill the register with a dummy value
-  }
-
-  Wire.requestFrom(address, numBytes);  // all bytes are returned in requestFrom
-
-  // check to be sure correct number of bytes were returned by slave
-  if(numBytes == Wire.available()) {
-    i2cRxData[0] = address;
-    i2cRxData[1] = theRegister;
-    for (int i = 0; i < numBytes; i++) {
-      #if ARDUINO >= 100
-      i2cRxData[2 + i] = Wire.read();
-      #else
-      i2cRxData[2 + i] = Wire.receive();
-      #endif
-    }
-  }
-  else {
-    if(numBytes > Wire.available()) {
-      Firmata.sendString("I2C Read Error: Too many bytes received");
-    } else {
-      Firmata.sendString("I2C Read Error: Too few bytes received");
-    }
-  }
-
-  // send slave address, register and received bytes
-  Firmata.sendSysex(SYSEX_I2C_REPLY, numBytes + 2, i2cRxData);
-}
-
-void outputPort(byte portNumber, byte portValue, byte forceSend)
-{
-  // pins not configured as INPUT are cleared to zeros
-  portValue = portValue & portConfigInputs[portNumber];
-  // only send if the value is different than previously sent
-  if(forceSend || previousPINs[portNumber] != portValue) {
-    Firmata.sendDigitalPort(portNumber, portValue);
-    previousPINs[portNumber] = portValue;
-  }
-}
-
-/* -----------------------------------------------------------------------------
- * check all the active digital inputs for change of state, then add any events
- * to the Serial output queue using Serial.print() */
-void checkDigitalInputs(void)
-{
-  /* Using non-looping code allows constants to be given to readPort().
-   * The compiler will apply substantial optimizations if the inputs
-   * to readPort() are compile-time constants. */
-  if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false);
-  if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false);
-  if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false);
-  if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false);
-  if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false);
-  if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false);
-  if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false);
-  if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false);
-  if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false);
-  if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false);
-  if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false);
-  if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false);
-  if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false);
-  if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false);
-  if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false);
-  if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false);
-}
-
-// -----------------------------------------------------------------------------
-/* sets the pin mode to the correct state and sets the relevant bits in the
- * two bit-arrays that track Digital I/O and PWM status
- */
-void setPinModeCallback(byte pin, int mode)
-{
-  if (pinConfig[pin] == I2C && isI2CEnabled && mode != I2C) {
-    // disable i2c so pins can be used for other functions
-    // the following if statements should reconfigure the pins properly
-    disableI2CPins();
-  }
-  if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) {
-    servos[PIN_TO_SERVO(pin)].detach();
-  }
-  if (IS_PIN_ANALOG(pin)) {
-    reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting
-  }
-  if (IS_PIN_DIGITAL(pin)) {
-    if (mode == INPUT) {
-      portConfigInputs[pin/8] |= (1 << (pin & 7));
-    } else {
-      portConfigInputs[pin/8] &= ~(1 << (pin & 7));
-    }
-  }
-  pinState[pin] = 0;
-  switch(mode) {
-  case ANALOG:
-    if (IS_PIN_ANALOG(pin)) {
-      if (IS_PIN_DIGITAL(pin)) {
-        pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver
-        digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
-      }
-      pinConfig[pin] = ANALOG;
-    }
-    break;
-  case INPUT:
-    if (IS_PIN_DIGITAL(pin)) {
-      pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver
-      digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
-      pinConfig[pin] = INPUT;
-    }
-    break;
-  case OUTPUT:
-    if (IS_PIN_DIGITAL(pin)) {
-      digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM
-      pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
-      pinConfig[pin] = OUTPUT;
-    }
-    break;
-  case PWM:
-    if (IS_PIN_PWM(pin)) {
-      pinMode(PIN_TO_PWM(pin), OUTPUT);
-      analogWrite(PIN_TO_PWM(pin), 0);
-      pinConfig[pin] = PWM;
-    }
-    break;
-  case SERVO:
-    if (IS_PIN_SERVO(pin)) {
-      pinConfig[pin] = SERVO;
-      if (!servos[PIN_TO_SERVO(pin)].attached()) {
-          servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin));
-      }
-    }
-    break;
-  case I2C:
-    if (IS_PIN_I2C(pin)) {
-      // mark the pin as i2c
-      // the user must call I2C_CONFIG to enable I2C for a device
-      pinConfig[pin] = I2C;
-    }
-    break;
-  default:
-    Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM
-  }
-  // TODO: save status to EEPROM here, if changed
-}
-
-void analogWriteCallback(byte pin, int value)
-{
-  if (pin < TOTAL_PINS) {
-    switch(pinConfig[pin]) {
-    case SERVO:
-      if (IS_PIN_SERVO(pin))
-        servos[PIN_TO_SERVO(pin)].write(value);
-        pinState[pin] = value;
-      break;
-    case PWM:
-      if (IS_PIN_PWM(pin))
-        analogWrite(PIN_TO_PWM(pin), value);
-        pinState[pin] = value;
-      break;
-    }
-  }
-}
-
-void digitalWriteCallback(byte port, int value)
-{
-  byte pin, lastPin, mask=1, pinWriteMask=0;
-
-  if (port < TOTAL_PORTS) {
-    // create a mask of the pins on this port that are writable.
-    lastPin = port*8+8;
-    if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS;
-    for (pin=port*8; pin < lastPin; pin++) {
-      // do not disturb non-digital pins (eg, Rx & Tx)
-      if (IS_PIN_DIGITAL(pin)) {
-        // only write to OUTPUT and INPUT (enables pullup)
-        // do not touch pins in PWM, ANALOG, SERVO or other modes
-        if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) {
-          pinWriteMask |= mask;
-          pinState[pin] = ((byte)value & mask) ? 1 : 0;
-        }
-      }
-      mask = mask << 1;
-    }
-    writePort(port, (byte)value, pinWriteMask);
-  }
-}
-
-
-// -----------------------------------------------------------------------------
-/* sets bits in a bit array (int) to toggle the reporting of the analogIns
- */
-//void FirmataClass::setAnalogPinReporting(byte pin, byte state) {
-//}
-void reportAnalogCallback(byte analogPin, int value)
-{
-  if (analogPin < TOTAL_ANALOG_PINS) {
-    if(value == 0) {
-      analogInputsToReport = analogInputsToReport &~ (1 << analogPin);
-    } else {
-      analogInputsToReport = analogInputsToReport | (1 << analogPin);
-    }
-  }
-  // TODO: save status to EEPROM here, if changed
-}
-
-void reportDigitalCallback(byte port, int value)
-{
-  if (port < TOTAL_PORTS) {
-    reportPINs[port] = (byte)value;
-  }
-  // do not disable analog reporting on these 8 pins, to allow some
-  // pins used for digital, others analog.  Instead, allow both types
-  // of reporting to be enabled, but check if the pin is configured
-  // as analog when sampling the analog inputs.  Likewise, while
-  // scanning digital pins, portConfigInputs will mask off values from any
-  // pins configured as analog
-}
-
-/*==============================================================================
- * SYSEX-BASED commands
- *============================================================================*/
-
-void sysexCallback(byte command, byte argc, byte *argv)
-{
-  byte mode;
-  byte slaveAddress;
-  byte slaveRegister;
-  byte data;
-  unsigned int delayTime;
-
-  switch(command) {
-  case I2C_REQUEST:
-    mode = argv[1] & I2C_READ_WRITE_MODE_MASK;
-    if (argv[1] & I2C_10BIT_ADDRESS_MODE_MASK) {
-      Firmata.sendString("10-bit addressing mode is not yet supported");
-      return;
-    }
-    else {
-      slaveAddress = argv[0];
-    }
-
-    switch(mode) {
-    case I2C_WRITE:
-      Wire.beginTransmission(slaveAddress);
-      for (byte i = 2; i < argc; i += 2) {
-        data = argv[i] + (argv[i + 1] << 7);
-        #if ARDUINO >= 100
-        Wire.write(data);
-        #else
-        Wire.send(data);
-        #endif
-      }
-      Wire.endTransmission();
-      delayMicroseconds(70);
-      break;
-    case I2C_READ:
-      if (argc == 6) {
-        // a slave register is specified
-        slaveRegister = argv[2] + (argv[3] << 7);
-        data = argv[4] + (argv[5] << 7);  // bytes to read
-        readAndReportData(slaveAddress, (int)slaveRegister, data);
-      }
-      else {
-        // a slave register is NOT specified
-        data = argv[2] + (argv[3] << 7);  // bytes to read
-        readAndReportData(slaveAddress, (int)REGISTER_NOT_SPECIFIED, data);
-      }
-      break;
-    case I2C_READ_CONTINUOUSLY:
-      if ((queryIndex + 1) >= MAX_QUERIES) {
-        // too many queries, just ignore
-        Firmata.sendString("too many queries");
-        break;
-      }
-      queryIndex++;
-      query[queryIndex].addr = slaveAddress;
-      query[queryIndex].reg = argv[2] + (argv[3] << 7);
-      query[queryIndex].bytes = argv[4] + (argv[5] << 7);
-      break;
-    case I2C_STOP_READING:
-	  byte queryIndexToSkip;
-      // if read continuous mode is enabled for only 1 i2c device, disable
-      // read continuous reporting for that device
-      if (queryIndex <= 0) {
-        queryIndex = -1;
-      } else {
-        // if read continuous mode is enabled for multiple devices,
-        // determine which device to stop reading and remove it's data from
-        // the array, shifiting other array data to fill the space
-        for (byte i = 0; i < queryIndex + 1; i++) {
-          if (query[i].addr = slaveAddress) {
-            queryIndexToSkip = i;
-            break;
-          }
-        }
-
-        for (byte i = queryIndexToSkip; i<queryIndex + 1; i++) {
-          if (i < MAX_QUERIES) {
-            query[i].addr = query[i+1].addr;
-            query[i].reg = query[i+1].addr;
-            query[i].bytes = query[i+1].bytes;
-          }
-        }
-        queryIndex--;
-      }
-      break;
-    default:
-      break;
-    }
-    break;
-  case I2C_CONFIG:
-    delayTime = (argv[0] + (argv[1] << 7));
-
-    if(delayTime > 0) {
-      i2cReadDelayTime = delayTime;
-    }
-
-    if (!isI2CEnabled) {
-      enableI2CPins();
-    }
-
-    break;
-  case SERVO_CONFIG:
-    if(argc > 4) {
-      // these vars are here for clarity, they'll optimized away by the compiler
-      byte pin = argv[0];
-      int minPulse = argv[1] + (argv[2] << 7);
-      int maxPulse = argv[3] + (argv[4] << 7);
-
-      if (IS_PIN_SERVO(pin)) {
-        if (servos[PIN_TO_SERVO(pin)].attached())
-          servos[PIN_TO_SERVO(pin)].detach();
-        servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse);
-        setPinModeCallback(pin, SERVO);
-      }
-    }
-    break;
-  case SAMPLING_INTERVAL:
-    if (argc > 1) {
-      samplingInterval = argv[0] + (argv[1] << 7);
-      if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) {
-        samplingInterval = MINIMUM_SAMPLING_INTERVAL;
-      }
-    } else {
-      //Firmata.sendString("Not enough data");
-    }
-    break;
-  case EXTENDED_ANALOG:
-    if (argc > 1) {
-      int val = argv[1];
-      if (argc > 2) val |= (argv[2] << 7);
-      if (argc > 3) val |= (argv[3] << 14);
-      analogWriteCallback(argv[0], val);
-    }
-    break;
-  case CAPABILITY_QUERY:
-    Serial.write(START_SYSEX);
-    Serial.write(CAPABILITY_RESPONSE);
-    for (byte pin=0; pin < TOTAL_PINS; pin++) {
-      if (IS_PIN_DIGITAL(pin)) {
-        Serial.write((byte)INPUT);
-        Serial.write(1);
-        Serial.write((byte)OUTPUT);
-        Serial.write(1);
-      }
-      if (IS_PIN_ANALOG(pin)) {
-        Serial.write(ANALOG);
-        Serial.write(10);
-      }
-      if (IS_PIN_PWM(pin)) {
-        Serial.write(PWM);
-        Serial.write(8);
-      }
-      if (IS_PIN_SERVO(pin)) {
-        Serial.write(SERVO);
-        Serial.write(14);
-      }
-      if (IS_PIN_I2C(pin)) {
-        Serial.write(I2C);
-        Serial.write(1);  // to do: determine appropriate value
-      }
-      Serial.write(127);
-    }
-    Serial.write(END_SYSEX);
-    break;
-  case PIN_STATE_QUERY:
-    if (argc > 0) {
-      byte pin=argv[0];
-      Serial.write(START_SYSEX);
-      Serial.write(PIN_STATE_RESPONSE);
-      Serial.write(pin);
-      if (pin < TOTAL_PINS) {
-        Serial.write((byte)pinConfig[pin]);
-	Serial.write((byte)pinState[pin] & 0x7F);
-	if (pinState[pin] & 0xFF80) Serial.write((byte)(pinState[pin] >> 7) & 0x7F);
-	if (pinState[pin] & 0xC000) Serial.write((byte)(pinState[pin] >> 14) & 0x7F);
-      }
-      Serial.write(END_SYSEX);
-    }
-    break;
-  case ANALOG_MAPPING_QUERY:
-    Serial.write(START_SYSEX);
-    Serial.write(ANALOG_MAPPING_RESPONSE);
-    for (byte pin=0; pin < TOTAL_PINS; pin++) {
-      Serial.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
-    }
-    Serial.write(END_SYSEX);
-    break;
-  }
-}
-
-void enableI2CPins()
-{
-  byte i;
-  // is there a faster way to do this? would probaby require importing
-  // Arduino.h to get SCL and SDA pins
-  for (i=0; i < TOTAL_PINS; i++) {
-    if(IS_PIN_I2C(i)) {
-      // mark pins as i2c so they are ignore in non i2c data requests
-      setPinModeCallback(i, I2C);
-    }
-  }
-
-  isI2CEnabled = true;
-
-  // is there enough time before the first I2C request to call this here?
-  Wire.begin();
-}
-
-/* disable the i2c pins so they can be used for other functions */
-void disableI2CPins() {
-    isI2CEnabled = false;
-    // disable read continuous mode for all devices
-    queryIndex = -1;
-    // uncomment the following if or when the end() method is added to Wire library
-    // Wire.end();
-}
-
-/*==============================================================================
- * SETUP()
- *============================================================================*/
-
-void systemResetCallback()
-{
-  // initialize a defalt state
-  // TODO: option to load config from EEPROM instead of default
-  if (isI2CEnabled) {
-  	disableI2CPins();
-  }
-  for (byte i=0; i < TOTAL_PORTS; i++) {
-    reportPINs[i] = false;      // by default, reporting off
-    portConfigInputs[i] = 0;	// until activated
-    previousPINs[i] = 0;
-  }
-  // pins with analog capability default to analog input
-  // otherwise, pins default to digital output
-  for (byte i=0; i < TOTAL_PINS; i++) {
-
-    // skip SPI pins for Ethernet/Wifi Shield
-    if ( (i==MOSI) || (i==MISO) || (i==SCK) || (i==SS) )
-      continue;
-
-    if (IS_PIN_ANALOG(i)) {
-      // turns off pullup, configures everything
-      setPinModeCallback(i, ANALOG);
-    } else {
-      // sets the output to 0, configures portConfigInputs
-      setPinModeCallback(i, OUTPUT);
-    }
-  }
-  // by default, do not report any analog inputs
-  analogInputsToReport = 0;
-
-  /* send digital inputs to set the initial state on the host computer,
-   * since once in the loop(), this firmware will only send on change */
-  /*
-  TODO: this can never execute, since no pins default to digital input
-        but it will be needed when/if we support EEPROM stored config
-  for (byte i=0; i < TOTAL_PORTS; i++) {
-    outputPort(i, readPort(i, portConfigInputs[i]), true);
-  }
-  */
-}
-
-void setup()
-{
-  Serial.begin(9600);
-
-  // start the Ethernet connection:
-  if (Ethernet.begin(mac) == 0) {
-    Serial.println(F("Failed to configure Ethernet using DHCP"));
-    // no point in carrying on, so do nothing forevermore:
-    for(;;)
-      ;
-  }
-
-  Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
-
-  Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
-  Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
-  Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
-  Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
-  Firmata.attach(SET_PIN_MODE, setPinModeCallback);
-  Firmata.attach(START_SYSEX, sysexCallback);
-  Firmata.attach(SYSTEM_RESET, systemResetCallback);
-
-  Firmata.begin(skynetclient);
-  systemResetCallback();  // reset to default config
-}
-
-/*==============================================================================
- * LOOP()
- *============================================================================*/
-void loop()
-{
-  while(!skynetclient.monitor()){
-
-    bool skynetStatus = false;
-    do {
-      skynetStatus = skynetclient.connect(hostname, port);
-    } while (!skynetStatus);
-
-    Serial.println(F("Connected!"));
-
-    char uuid[UUIDSIZE];
-
-    skynetclient.getUuid(uuid);
-    Serial.print(F("uuid: "));
-    Serial.println(uuid);
-
-    skynetclient.getToken(uuid);
-    Serial.print(F("token: "));
-    Serial.println(uuid);
-  }
-
-  byte pin, analogPin;
-
-  /* DIGITALREAD - as fast as possible, check for changes and output them to the
-   * FTDI buffer using Serial.print()  */
-  checkDigitalInputs();
-
-  /* SERIALREAD - processing incoming messagse as soon as possible, while still
-   * checking digital inputs.  */
-  while(Firmata.available())
-    Firmata.processInput();
-
-  /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over
-   * 60 bytes. use a timer to sending an event character every 4 ms to
-   * trigger the buffer to dump. */
-
-  currentMillis = millis();
-  if (currentMillis - previousMillis > samplingInterval) {
-    previousMillis += samplingInterval;
-    /* ANALOGREAD - do all analogReads() at the configured sampling interval */
-    for(pin=0; pin<TOTAL_PINS; pin++) {
-      if (IS_PIN_ANALOG(pin) && pinConfig[pin] == ANALOG) {
-        analogPin = PIN_TO_ANALOG(pin);
-        if (analogInputsToReport & (1 << analogPin)) {
-          Firmata.sendAnalog(analogPin, analogRead(analogPin));
-        }
-      }
-    }
-    // report i2c data for all device with read continuous mode enabled
-    if (queryIndex > -1) {
-      for (byte i = 0; i < queryIndex + 1; i++) {
-        readAndReportData(query[i].addr, query[i].reg, query[i].bytes);
-      }
-    }
-  }
-}


Added setud for the servo to open the parachute (Not functional yet)

--- OpenRocket.ino
+++ OpenRocket.ino
@@ -101,7 +101,6 @@
 #define DEBUG__PRINT_LOOP_TIME false

 /****************** BMP085  *********************/
-
 #define BMP085_ADDRESS 0x77  // I2C address of BMP085

 const unsigned char OSS = 0;  // Oversampling Setting
@@ -117,18 +116,19 @@
 int mb;
 int mc;
 int md;
-// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
-// so ...Temperature(...) must be called before ...Pressure(...).
 long b5;
 float temperature;
 float pressure;
 float atm; // "standard atmosphere"
 float alti;
-
 /*****************************************************************/

 #include <Wire.h>
 #include <SD.h>
+Servo myservo;
+
+int pos = 0;
+int servoPin = 9;

 // Sensor calibration scale and offset values
 #define ACCEL_X_OFFSET ((ACCEL_X_MIN + ACCEL_X_MAX) / 2.0f)
@@ -353,6 +353,8 @@

   turn_output_stream_on();
   //turn_output_stream_off();
+
+  myservo.attach(servoPin);
 }

 void loop()


Update BH1750FVI_Simple.ino

Update BH1750FVI_Simple.ino

Serial.print is now Arduino compatible

--- examples/BH1750FVI_Simple/BH1750FVI_Simple.ino
+++ examples/BH1750FVI_Simple/BH1750FVI_Simple.ino
@@ -30,6 +30,7 @@
 void loop()
 {
   uint16_t lux = LightSensor.GetLightIntensity();
-  Serial.printf("Light: %d lux", lux);
+  Serial.print("Light: ");
+  Serial.println(lux);
   delay(250);
 }


Updated to support all sensors and write them to the sdcard

--- Sensors/Sensor-Main/Sensor-Main.ino
+++ Sensors/Sensor-Main/Sensor-Main.ino
@@ -1,38 +1,57 @@
 //Imports
-#include "Adafruit_ADXL345_U.h"
-#include "Adafruit_Sensor.h"
+#include "Adafruit_ADXL345_U.h" //Accelrometer
+#include "Adafruit_Sensor.h" //Adafruit Products
 #include <SFE_BMP180.h> //Barometer
 #include "RTClib.h" //RTC
-#include <SparkFunTSL2561.h>
-#include "Wire.h"
-#include <SPI.h>
-#include <SD.h>
-
-
-//Definitions
-int ledPin = 5;
-#define DS1307_ADDRESS 0x86;//Need to get updated I2C Address
-byte zero = 0x00; //Needed as a workaround for issue #537 RTC Support
-Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
-RTC_DS1307 rtc;
-SFE_BMP180 pressure;
-#define ALTITUDE 254 //ALTITUDE of Newark
-File dataFile;
-
-void setup(){
+#include "Wire.h" //Wire for I2C
+#include <SPI.h> //SPI for SD
+#include <SD.h> //SDcard
+#include <Adafruit_TSL2561_U.h> //Luminosity Sensor
+
+/*Deffinations*/
+int ledPin = 5; //Pin for LEDs
+
+ //Accel
+ #define DS1307_ADDRESS 0x86;//Need to get updated I2C Address
+ byte zero = 0x00; //Needed as a workaround for issue #537 RTC Support
+ Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
+
+ //RTC
+ RTC_DS1307 rtc;
+
+ //Pressure
+ SFE_BMP180 pressure;
+ #define ALTITUDE 254 //ALTITUDE of Newark
+
+ //SDcard
+ File dataFile;
+
+ //UV
+ int UVOUT = A0; //Output from the sensor
+ int REF_3V3 = A2; //3.3V power on the Arduino board
+
+ //Luminosity
+ Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
+ //Magneto
+ #define address 0x1E //0011110b, I2C 7bit address of HMC5883
+//Humidity
+int HIH4030_Pin = A3;
+
+/*End Deffinations*/
+
+
+void setup()
+{
   /*Serial Setup*/
 	Serial.begin(9600);
-	Serial.begin(9600);
-
-	/*Led Setup*/
+  Wire.begin();
+
+  /*Led Setup*/
   pinMode(ledPin, OUTPUT);

 	/*Barometer Setup*/
 	if (pressure.begin())
-    Serial.println("BMP180 init success");
-  else
-	{
-    Serial.println("BMP180 init fail\n\n");
+  {
   }

 	/*RTC Setup*/
@@ -43,21 +62,20 @@
 	#endif
 		rtc.begin();
 	if (! rtc.isrunning()) {
-		Serial.println("RTC is NOT running!");
+
 	}
-	/*Accel Setup*/
-	if(!accel.begin())
-	{
-		Serial.println("ADXL345 Not Detected");
+
+  /*Accel Setup*/
+	if(!accel.begin()){
 	}
 	accel.setRange(ADXL345_RANGE_16_G);

+  /*SDcard Setup*/
 	if (!SD.begin(4)) {
-	Serial.println("initialization failed!");
-	return;
 	}
 	dataFile = SD.open("datatest.csv", FILE_WRITE);
-	dataFile.print("Year");
+  dataFile.println(",");
+  dataFile.print("Year");
 	dataFile.print(",");
 	dataFile.print("Month");
 	dataFile.print(",");
@@ -67,8 +85,50 @@
 	dataFile.print(",");
 	dataFile.print("Minute");
 	dataFile.print(",");
-	dataFile.println("Second");
+	dataFile.print("Second");
+  dataFile.print(",");
+  dataFile.print("External Temp F");
+  dataFile.print(",");
+  dataFile.print("Absolute Pressure(mB)");
+  dataFile.print(",");
+  dataFile.print("Relative (sea-level) Pressure(mb)");
+  dataFile.print(",");
+  dataFile.print("Computed altitude(m)");
+  dataFile.print(",");
+  dataFile.print("Ax");
+  dataFile.print(",");
+  dataFile.print("Ay");
+  dataFile.print(",");
+  dataFile.print("Az");
+  dataFile.print(",");
+  dataFile.print("Relative Humidity");
+  dataFile.print(",");
+  dataFile.print("Luminosity");
+  dataFile.print(",");
+  dataFile.print("UV (mW/cm^2)");
+  dataFile.print(",");
+  dataFile.print("Mx");
+  dataFile.print(",");
+  dataFile.print("My");
+  dataFile.print(",");
+  dataFile.print("Mz");
+  dataFile.println(",");
+
+
 	dataFile.close();
+
+  /*UV */
+	pinMode(UVOUT, INPUT);
+	pinMode(REF_3V3, INPUT);
+
+  /*Luminosity*/
+  tsl.begin();
+  configureSensor();
+  /*Magneto*/
+  Wire.beginTransmission(address); //open communication with HMC5883
+  Wire.write(0x02); //select mode register
+  Wire.write(0x00); //continuous measurement mode
+  Wire.endTransmission();
 }

 void loop(){
@@ -86,22 +146,10 @@
 	dataFile.print(",");
 	dataFile.print(now.minute(), DEC);
 	dataFile.print(",");
-	dataFile.println(now.second(), DEC);
-	dataFile.close();
-
-	Serial.println("----------------------------Time Stamp----------------------------");
-	Serial.print(now.year(), DEC);
-	Serial.print('/');
-	Serial.print(now.month(), DEC);
-	Serial.print('/');
-	Serial.print(now.day(), DEC);
-	Serial.print(' ');
-	Serial.print(now.hour(), DEC);
-	Serial.print(':');
-	Serial.print(now.minute(), DEC);
-	Serial.print(':');
-	Serial.print(now.second(), DEC);
-	Serial.println();
+	dataFile.print(now.second(), DEC);
+  dataFile.print(",");
+
+

 	/*Leds*/
   digitalWrite(ledPin, HIGH);
@@ -109,13 +157,7 @@
   /*Barometer*/
   char status;
   double T,P,p0,a;
-	Serial.println("-----------------------------Barometer----------------------------");
   Serial.println();
-  Serial.print("provided altitude: ");
-  Serial.print(ALTITUDE,0);
-  Serial.print(" meters, ");
-  Serial.print(ALTITUDE*3.28084,0);
-  Serial.println(" feet");
   status = pressure.startTemperature();
   if (status != 0)
   {
@@ -123,11 +165,11 @@
     status = pressure.getTemperature(T);
     if (status != 0)
     {
-      Serial.print("temperature: ");
-      Serial.print(T,2);
-      Serial.print(" deg C, ");
+      Serial.print("temp: ");
       Serial.print((9.0/5.0)*T+32.0,2);
       Serial.println(" deg F");
+      dataFile.print((9.0/5.0)*T+32.0,2);
+      dataFile.print(",");

       status = pressure.startPressure(3);
       if (status != 0)
@@ -136,55 +178,149 @@
         status = pressure.getPressure(P,T);
         if (status != 0)
         {
-          Serial.print("absolute pressure: ");
+          Serial.print("aP: ");
           Serial.print(P,2);
-          Serial.print(" mb, ");
-          Serial.print(P*0.0295333727,2);
-          Serial.println(" inHg");
+          Serial.println(" mb");
+          dataFile.print(P,2);
+          dataFile.print(",");

           p0 = pressure.sealevel(P,ALTITUDE);
-          Serial.print("relative (sea-level) pressure: ");
+          Serial.print("rP: ");
           Serial.print(p0,2);
-          Serial.print(" mb, ");
-          Serial.print(p0*0.0295333727,2);
-          Serial.println(" inHg");
+          Serial.println(" mb");
+          dataFile.print(p0,2);
+          dataFile.print(",");

           a = pressure.altitude(P,p0);
           Serial.print("computed altitude: ");
           Serial.print(a,0);
-          Serial.print(" meters, ");
-          Serial.print(a*3.28084,0);
-          Serial.println(" feet");
+          Serial.println(" meters");
+          dataFile.print(a,0);
+          dataFile.print(",");
         }
-        else Serial.println("error retrieving pressure measurement\n");
       }
-      else Serial.println("error starting pressure measurement\n");
     }
-    else Serial.println("error retrieving temperature measurement\n");
-  }
-  else Serial.println("error starting temperature measurement\n");
+  }

 	/*Accel*/
-	sensors_event_t event;
-  accel.getEvent(&event);
-	Serial.println("------------------------------Accel------------------------------");
-	Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print("  ");
-	Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print("  ");
-	Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print("  ");Serial.println("m/s^2 ");
-	Serial.println("-----------------------------------------------------------------");
-	/*Magneto*/
+  sensors_event_t events;
+  accel.getEvent(&events);
+	dataFile.print(events.acceleration.x);
+  dataFile.print(",");
+  dataFile.print(events.acceleration.y);
+  dataFile.print(",");
+  dataFile.print(events.acceleration.z);
+  dataFile.print(",");
+  Serial.print(events.acceleration.x);
+	Serial.print(events.acceleration.y);
+	Serial.print(events.acceleration.z);

 	/*Humidity*/
-
+  float temperature = 25; //replace with a thermometer reading if you have it
+  float relativeHumidity  = getHumidity(T);
+  dataFile.print(relativeHumidity);
+  dataFile.print(",");
+  Serial.println(relativeHumidity);
 	/*Luminosity*/
+  sensors_event_t event;
+  tsl.getEvent(&event);
+  if (event.light)
+  {
+    Serial.print(event.light); Serial.println(" lux");
+    dataFile.print(event.light);
+    dataFile.print(",");
+  }
+  else
+  {
+    Serial.println("Sensor overload");
+  }

 	/*UV Sensor*/

-
-	Serial.println(" ");
-	Serial.println(" ");
-  Serial.println(" ");
-	Serial.println(" ");
-	Serial.println(" ");
-	delay(500);
-}
+  int uvLevel = averageAnalogRead(UVOUT);
+  int refLevel = averageAnalogRead(REF_3V3);
+
+  //Use the 3.3V power pin as a reference to get a very accurate output value from sensor
+  float outputVoltage = 3.3 / refLevel * uvLevel;
+
+  float uvIntensity = mapfloat(outputVoltage, 0.99, 2.9, 0.0, 15.0);
+
+  Serial.print(" UV Intensity (mW/cm^2): ");
+  Serial.println(uvIntensity);
+  dataFile.print(uvIntensity);
+  dataFile.print(",");
+
+  /*Magneto*/
+  int x,y,z; //triple axis data
+
+  //Tell the HMC5883L where to begin reading data
+  Wire.beginTransmission(address);
+  Wire.write(0x03); //select register 3, X MSB register
+  Wire.endTransmission();
+
+  Wire.requestFrom(address, 6);
+  if(6<=Wire.available()){
+    x = Wire.read()<<8; //X msb
+    x |= Wire.read(); //X lsb
+    z = Wire.read()<<8; //Z msb
+    z |= Wire.read(); //Z lsb
+    y = Wire.read()<<8; //Y msb
+    y |= Wire.read(); //Y lsb
+  }
+
+  Serial.print(x);
+  Serial.print(y);
+  Serial.println(z);
+  dataFile.print(x);
+  dataFile.print(",");
+  dataFile.print(y);
+  dataFile.print(",");
+  dataFile.print(z);
+  dataFile.println(",");
+
+
+  Serial.println();
+	dataFile.close();
+  delay(500);
+
+}
+
+float getHumidity(float degreesCelsius){
+  float supplyVolt = 5.0;
+
+  int HIH4030_Value = analogRead(HIH4030_Pin);
+  float voltage = HIH4030_Value/1023. * supplyVolt; // convert to voltage value
+
+  float sensorRH = 161.0 * voltage / supplyVolt - 25.8;
+  float trueRH = sensorRH / (1.0546 - 0.0026 * degreesCelsius); //temperature adjustment
+
+  return trueRH;
+}
+
+void configureSensor(void)
+{
+  // tsl.setGain(TSL2561_GAIN_1X);      /* No gain ... use in bright light to avoid sensor saturation */
+  // tsl.setGain(TSL2561_GAIN_16X);     /* 16x gain ... use in low light to boost sensitivity */
+  tsl.enableAutoRange(true);            /* Auto-gain ... switches automatically between 1x and 16x */
+
+  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */
+  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);  /* medium resolution and speed   */
+  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */
+}
+
+//Values
+int averageAnalogRead(int pinToRead){
+  byte numberOfReadings = 8;
+  unsigned int runningValue = 0;
+
+  for(int x = 0 ; x < numberOfReadings ; x++)
+    runningValue += analogRead(pinToRead);
+  runningValue /= numberOfReadings;
+
+  return(runningValue);
+}
+
+
+float mapfloat(float x, float in_min, float in_max, float out_min, float out_max){
+  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+}


Condensed Time Data Into a Formatted Timestamp

--- Sensors/Sensor-Main/Sensor-Main.ino
+++ Sensors/Sensor-Main/Sensor-Main.ino
@@ -75,17 +75,7 @@
 	}
 	dataFile = SD.open("datatest.csv", FILE_WRITE);
   dataFile.println(",");
-  dataFile.print("Year");
-	dataFile.print(",");
-	dataFile.print("Month");
-	dataFile.print(",");
-	dataFile.print("Day");
-	dataFile.print(",");
-	dataFile.print("Hour");
-	dataFile.print(",");
-	dataFile.print("Minute");
-	dataFile.print(",");
-	dataFile.print("Second");
+  dataFile.print("Timestamp");
   dataFile.print(",");
   dataFile.print("External Temp F");
   dataFile.print(",");
@@ -136,17 +126,17 @@
 	DateTime now = rtc.now();

 	dataFile = SD.open("datatest.csv", FILE_WRITE);
-	dataFile.print(now.year(), DEC);
-	dataFile.print(",");
-	dataFile.print(now.month(), DEC);
-	dataFile.print(",");
-	dataFile.print(now.day(), DEC);
-	dataFile.print(",");
-	dataFile.print(now.hour(), DEC);
-	dataFile.print(",");
-	dataFile.print(now.minute(), DEC);
-	dataFile.print(",");
-	dataFile.print(now.second(), DEC);
+  dataFile.print(now.month(), DEC);
+  dataFile.print("/");
+  dataFile.print(now.day(), DEC);
+  dataFile.print("/");
+  dataFile.print(now.year(), DEC);
+  dataFile.print(" ");
+  dataFile.print(now.hour(), DEC);
+  dataFile.print(":");
+  dataFile.print(now.minute(), DEC);
+  dataFile.print(":");
+  dataFile.print(now.second(), DEC);
   dataFile.print(",");


Add sending updates

Add sending updates

Change buffer from EEPROM to RAM
Now ASB writing to buffer ONLY changed values
Now ASB Sending packet every time when buffer changes

--- ArduinoSensorBoard/ArduinoSensorBoard.ino
+++ ArduinoSensorBoard/ArduinoSensorBoard.ino
@@ -8,39 +8,47 @@

 #define DHTPIN 2
 #define DHTTYPE DHT11
+#define ADDRBASE 0xF0F0F0F000LL
+
+byte serialIncomingByte = 0;
+
+int sensorValues[32] = {};
+
+int rwBytes[] = {
+  10};
+int rwPins[] = {
+  3};
+
+
+int isUpdate = 0;
+int shortRCHomeAddr = 1;
+int shortASBoardAddr = 2;
+int lightsSnsorPin = A0;

 RF24 radio(8,9);
 DHT dht(DHTPIN, DHTTYPE);
-byte incomingByte = 0;

-const uint64_t pipes[2] = {
-  0xF0F0F0F001LL, 0xF0F0F0F002LL };
-const byte shortAddr = 0x02;
-int switchsPins[] = {
-  3};
-int switchesBytes[] = {
-  10};
-int switchStatus[] = {
-  0};

-int lightsSnsorPin = A0;
 void setup(void)
 {
   Serial.begin(57600);

   dht.begin();
   radio.begin();
-
   radio.setAutoAck(true);
   radio.setRetries(15,15);
   radio.setPALevel(RF24_PA_MAX);
-  radio.openReadingPipe(1,pipes[1]);
-  radio.openWritingPipe(pipes[0]);
-
+
+  EEPROM.write(1,shortASBoardAddr);
+  EEPROM.write(2,shortRCHomeAddr);
+
+  radio.openReadingPipe(1,ADDRBASE + EEPROM.read(1));
+  radio.openWritingPipe(ADDRBASE + EEPROM.read(2));
+
   radio.startListening();

-  for(int i = 0; i < sizeof(switchesBytes)-1; i++){
-    pinMode(switchsPins[i], OUTPUT);
+  for(int i = 0; i < sizeof(rwBytes)-1; i++){
+    pinMode(rwPins[i], OUTPUT);
   }

@@ -53,17 +61,22 @@
   uint8_t pipenum = 0;

   readSensors(ptr);
+  if (isUpdate){
+    Serial.println("Update");
+    Serial.println(isUpdate);
+    sendUpdate();
+  }

   if (Serial.available() > 0) {  //если есть доступные данные
     // считываем байт
-    incomingByte = Serial.read();
+    serialIncomingByte = Serial.read();

     // отсылаем то, что получили
-    Serial.println(incomingByte);
-    switch(incomingByte){
+    Serial.println(serialIncomingByte);
+    switch(serialIncomingByte){
     case 49:
       Serial.println("EEEPROM:");
-      for (int i=0;i<32;i++){
+      for (int i=0;i<35;i++){
         Serial.print(EEPROM.read(i));
         Serial.print(" ");
       }
@@ -83,28 +96,39 @@
       delay(10);
     }
     if (pipenum==1){
+      Serial.println(ptr[0]);
       runCommand(ptr);
     }
-    Serial.println(ptr[1]);
-
-    radio.stopListening();
-    radio.write(ptr, sizeof(byte[32]));
-    radio.startListening();
   }

 }
+
+void sendUpdate(){
+    isUpdate = 0;
+    radio.stopListening();
+    radio.write(sensorValues, sizeof(byte[32]));
+    radio.startListening();
+}
+
+
+
+
 void runCommand(byte *ptr)
 {
-  Serial.println(ptr[0]);
-  if(!ptr[0]){
-    for(int i =0; i < 32; i++){
-      ptr[i] = EEPROM.read(i);
-    }
+    if(!ptr[0]){
+    sendUpdate();
   }
   else{
-    writeSensors(ptr);
+    for(int i = 0; i < sizeof(rwBytes)-1; i++){
+       if (sensorValues[rwBytes[i]] != ptr[rwBytes[i]]){
+           sensorValues[rwBytes[i]] = ptr[rwBytes[i]];
+           writeSwitch(i);
+       }
+  }
+    Serial.println("Write");
+    sendUpdate();
   }

 }
@@ -112,56 +136,45 @@
   readTemp(ptr);
   readHum(ptr);
   readLum(ptr);
-  readSwitch(ptr);
-
+
 }

-void writeSensors(byte* ptr){
-  writeSwitch(ptr);
-  readSensors(ptr);
-
-}

 void readTemp(byte* ptr){
   float t = dht.readTemperature();
-  if (!isnan(t)){
-    EEPROM.write(2,(byte)t);
+  if ((!isnan(t)) && (t != sensorValues[2])){
+    sensorValues[2] = (int)t;
+    isUpdate = 1;
+    Serial.println("tupdate");
   }
-  else{
-    EEPROM.write(32,13);
-  }
+

 }
 void readHum(byte* ptr){
   float h = dht.readHumidity();
-  if (!isnan(h)){
-    EEPROM.write(3,(byte)h);
-
+  if ((!isnan(h)) && (h != sensorValues[3])){
+      sensorValues[3] = (int)h;
+      isUpdate = 1;
+      Serial.println("hupdate");
   }
-  else{
-    EEPROM.write(32,14);
-
-  }
+
 }
 void readLum(byte* ptr){
-  EEPROM.write(4,analogRead(lightsSnsorPin));
-
+  int l = analogRead(lightsSnsorPin);
+  if(l!=sensorValues[4]){
+     sensorValues[4] = l;
+     isUpdate = 1;
+     Serial.println("lupdate");
+  }

 }

-void readSwitch(byte* ptr){
-  for(int i = 0; i < sizeof(switchesBytes)-1; i++){
-     EEPROM.write(switchesBytes[i],switchStatus[i]);
-  }
-}

-void writeSwitch(byte* ptr){
-  for(int i = 0; i < sizeof(switchesBytes)-1; i++){
-    digitalWrite(switchsPins[i], ptr[switchesBytes[i]]);
-    switchStatus[i] = ptr[switchesBytes[i]];
-    ptr[1] = 255;
-  }
+void writeSwitch(int i){
+    digitalWrite(rwPins[i], sensorValues[rwBytes[i]]);
+
+
 }


Fix return codes for power on/off

Fix return codes for power on/off

--- temperature-relay.ino
+++ temperature-relay.ino
@@ -44,6 +44,7 @@

 int led1 = D7;
 int powertail = D5;
+int iotrelay = D6;

 double temperature;
 double minuteAverage;
@@ -56,6 +57,7 @@
 void startup() {
   pinMode(led1, OUTPUT);
   pinMode(powertail, OUTPUT);
+  pinMode(iotrelay, OUTPUT);
 }

 STARTUP( startup() );
@@ -124,13 +126,14 @@
 }

 int adjustPower(String command) {
-  if(command == "on") {
+  if(command == "on" || command == "1") {
     turnOnPower();
-  }
-  if(command == "off") {
+    return 1;
+  } else if(command == "off" || command == "0") {
     turnOffPower();
-  }
-  return 1;
+    return 1;
+  }
+  return -1;
 }

 int setTempOn(String temp) {
@@ -157,6 +160,7 @@
   if(power != 1) {
     power = 1;
     digitalWrite(powertail, HIGH);
+    digitalWrite(iotrelay, HIGH);
     publishPowerStatus();
   }
 }
@@ -165,6 +169,7 @@
   if(power != 0) {
     power = 0;
     digitalWrite(powertail, LOW);
+    digitalWrite(iotrelay, LOW);
     publishPowerStatus();
   }
 }


Set reset speed to 300.

Set reset speed to 300.

--- starsynctrackers.ino
+++ starsynctrackers.ino
@@ -28,7 +28,7 @@

 static const int STOP_BUTTON_PIN = A4;      // The pin the stop push switch is on
 static const int STOP_BUTTON_TYPE = 1;     // The type of switch 0 - Normally Closed; 1 - Normally Open
-static const float RESET_SPEED = -8000.0;  // The speed to go back to initial position at
+static const float RESET_SPEED = -300.0;  // The speed to go back to initial position at
 static const float DIRECTION = 1.0; // 1 forward is forward; -1 + is forward is backward


all modes nominally working

all modes nominally working

--- NeoPixelNightLight/NeoPixelNightLight.ino
+++ NeoPixelNightLight/NeoPixelNightLight.ino
@@ -22,7 +22,8 @@

 #define ANALOG_COLOR_PIN A0
 #define ANALOG_BRIGHTNESS_PIN A1
-#define SWIPE_WAIT 50
+// how fast the wipe is when changing colors
+#define SWIPE_WAIT 0

 // Parameter 1 = number of pixels in strip
 // Parameter 2 = Arduino pin number (most are valid)
@@ -38,14 +39,12 @@
 // and minimize distance between Arduino and first pixel.  Avoid connecting
 // on a live circuit...if you must, connect GND first.

-byte sensorValue = 0;        // value read from the pot
+byte sensorValue = 0;          // value read from the pot
 float brightnessValue = 1.0;   // value read from the pot
 // end neopixel

 // clock settings
-int hr = 0;
-int min = 0;
-int sec = 0;
+DateTime current;

 uint32_t secColor = 0;
 uint32_t minColor = 0;
@@ -56,56 +55,150 @@
 #define CLOCK_MODE  1
 #define NIGHTLIGHT_MODE 2

-int mode = BACKLIGHT_MODE;
+#define MODE_SWITCH_PIN 10
+int mode = CLOCK_MODE; // BACKLIGHT_MODE;
+char s[200];
+
+DateTime wakeTime = DateTime( 2016,1,1,17,45); // 5:45am

 /*******************************************************************************
 *******************************************************************************/
 void setup() {
+
+  pinMode(MODE_SWITCH_PIN,INPUT_PULLUP);

   rtcSetup();
   neoPixelSetup();

 }

+bool pressed = false;
 /*******************************************************************************
 *******************************************************************************/
 void loop() {

-  Serial.print("in loop with mode of");
-  Serial.println(mode);
+  current = rtc.now();
+
   switch ( mode )
   {
     case BACKLIGHT_MODE:
       backlight();
       break;
     case CLOCK_MODE:
-      clocklight();
+      clocklight(current);
       break;
     case NIGHTLIGHT_MODE:
-      nightlight();
+      nightlight(current);
       break;
   }
-
-}
-
-/*******************************************************************************
-*******************************************************************************/
-void clocklight()
-{
-}
-
-/*******************************************************************************
-*******************************************************************************/
-void nightlight()
-{
-
-}
-
-/*******************************************************************************
-*******************************************************************************/
-void backlight()
-{
-
+
+  if ( digitalRead(MODE_SWITCH_PIN) == LOW )
+  {
+    if ( !pressed )
+    {
+      pressed = true;
+      mode++;
+      if ( mode > NIGHTLIGHT_MODE )
+        mode = BACKLIGHT_MODE;
+
+      Serial.print("Switching mode to ");
+      Serial.println(mode);
+      clearPixels();
+    }
+  }
+  else
+    pressed = false;
+}
+
+int sec = 0;
+int min = 0;
+int hr = 0;
+
+void clearPixels()
+{
+  for ( int i = 0; i < NEOPIXEL_LEDS; i++ )
+    strip.setPixelColor(i,0);
+}
+/*******************************************************************************
+*******************************************************************************/
+void clocklight(DateTime current)
+{
+  strip.setPixelColor(sec,0);
+  strip.setPixelColor(min,0);
+  strip.setPixelColor(hr,0);
+
+  sec = current.second() / 5;
+  min = current.minute() / 5;
+  hr = current.hour() % 12;
+
+  strip.setPixelColor(sec,secColor);
+  strip.setPixelColor(min,minColor);
+  strip.setPixelColor(hr,hrColor);
+
+  if ( sec == min && sec == hr )
+    strip.setPixelColor(sec,secColor | minColor | hrColor );
+  else if ( sec == min )
+    strip.setPixelColor(sec,secColor | minColor);
+  else if ( sec == hr )
+    strip.setPixelColor(sec,secColor | hrColor);
+  else if ( min == hr )
+    strip.setPixelColor(min,minColor | hrColor);
+
+  strip.show();
+
+  sprintf( s, "%d:%d:%d - %d %d %d", current.hour(), current.minute(), current.second(), hr,min,sec);
+  Serial.println(s);
+}
+
+int prevHours = -1;
+
+/*******************************************************************************
+*******************************************************************************/
+void nightlight(DateTime current)
+{
+  // how many hours until wakey?
+  double currentMin = 60.0*current.hour() + current.minute();
+  double wakeyMin = 60.0*wakeTime.hour() + wakeTime.minute();
+
+  double diffMin = wakeyMin - currentMin;
+  if ( diffMin < 0 )
+    diffMin = wakeyMin + (24.0*60)-currentMin; // remains of today + until wakey
+  int newHours = (diffMin / 60)+.5;
+  if ( newHours > 12 )
+    newHours = 12;
+
+  bool show = checkColorChange();
+
+  if ( prevHours != newHours || show )
+  {
+    show = true;
+    if ( prevHours >= 0 )
+      strip.setPixelColor(prevHours,0);
+    for ( int i = 0; i < abs(newHours); i++ )
+      strip.setPixelColor(i,sensorValue);
+    Serial.print( "PreHours ");
+    Serial.print( prevHours );
+    Serial.print( " newHours ");
+    Serial.println( newHours );
+    prevHours = newHours;
+  }
+
+  Serial.print( "Wakey current is ");
+  Serial.print( currentMin );
+  Serial.print( " and wakey is ");
+  Serial.print( wakeyMin );
+  Serial.print( " and diffMin is ");
+  Serial.print( diffMin );
+  Serial.print( " and show is ");
+  Serial.println( show );
+  delay(500);
+
+  if ( show )
+    strip.show();
+}
+
+bool checkColorChange()
+{
   // read the analog in value:
   byte newSensorValue = map(analogRead(ANALOG_COLOR_PIN), 0, 1023, 0, 255);
   bool updateNeo = false;
@@ -114,8 +207,8 @@
       sensorValue = newSensorValue;
       updateNeo = true;
   }
+
   float newSensorBrightness = map(analogRead(ANALOG_BRIGHTNESS_PIN), 0, 1023, 0, 255);
-
   if (  brightnessValue != newSensorBrightness )
   {
       updateNeo = true;
@@ -123,7 +216,14 @@
       strip.setBrightness(brightnessValue);
   }

-  if ( updateNeo )
+  return updateNeo;
+}
+
+/*******************************************************************************
+*******************************************************************************/
+void backlight()
+{
+  if ( checkColorChange() )
   {
     colorWipe(Wheel(sensorValue),SWIPE_WAIT);
   }


Fix to ADXL335 Arduino code comments.

Fix to ADXL335 Arduino code comments.

--- Arduino/ADXL335/ADXL335.ino
+++ Arduino/ADXL335/ADXL335.ino
@@ -2,19 +2,24 @@
 int ypin = A4;
 int xpin = A5;

-// Uncomment the following lines if you're using an ADXL335 on an
-// Adafruit breakout board (https://www.adafruit.com/products/163)
-// and want to plug it directly into (and power it from) the analog
-// input pins of your Arduino board.
-//int vinpin = A0;
-//int voutpin = A1;
-//int gndpin = A2;
+// These are only used if you're plugging the ADXL335 (on the
+// Adafruit breakout board) directly into the analog input pins
+// of your Arduino. See comment below.
+int vinpin = A0;
+int voutpin = A1;
+int gndpin = A2;

 void setup() {
   Serial.begin(9600);
-  pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH);
-  pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW);
-  pinMode(voutpin, INPUT);
+
+  // Uncomment the following lines if you're using an ADXL335 on an
+  // Adafruit breakout board (https://www.adafruit.com/products/163)
+  // and want to plug it directly into (and power it from) the analog
+  // input pins of your Arduino board.
+//  pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH);
+//  pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW);
+//  pinMode(voutpin, INPUT);
+
   pinMode(xpin, INPUT);
   pinMode(ypin, INPUT);
   pinMode(zpin, INPUT);


cleanup

cleanup

--- Arduino_Thermostat/Arduino_Thermostat.ino
+++ Arduino_Thermostat/Arduino_Thermostat.ino
@@ -46,12 +46,6 @@

 #define KEYB_OFF_DELAY_LONG   500
 #define KEYB_OFF_DELAY_SHORT  200
-/*
-Button *btnLeft;
-Button *btnRight;
-bool keybOff = false;
-unsigned long keybOffTime;
-*/
 Keyboard kbd(200);

 //


Add logic to retransmit CAN message if sending fails. Timeout after 10 failures

--- CAN_haz_bus/CAN_haz_bus.ino
+++ CAN_haz_bus/CAN_haz_bus.ino
@@ -33,6 +33,7 @@
 INT8U results;
 INT8U  extflag;
 INT8U baud = CAN_500KBPS;
+int failCnt = 0;

@@ -168,8 +169,20 @@
                         (inbuf[2] << 24);
                 extflag = inbuf[6];
                 len = inbuf[0] - 7;
-                results = CAN.sendMsgBuf(canId, extflag, len, inbuf+7);
+                failCnt = 0;
+                do
+                {
+                  results = CAN.sendMsgBuf(canId, extflag, len, inbuf+7);
+                  if(results != CAN_OK)
+                  {
+                    failCnt++;
+                  }
+                } while (results != CAN_OK && failCnt < 10);
                 send(&results, CMD_CAN_SEND_RESULT, 1);
+                if(failCnt >= 10)
+                {
+                    //logHexStr(results, "Send failed. Error: ", 20);
+                }

                 break;


knock

knock

--- KnockSensor/KnockSensor.ino
+++ KnockSensor/KnockSensor.ino
@@ -2,55 +2,78 @@

 /* Knock Sensor

-   This sketch reads a piezo element to detect a knocking sound.
-   It reads an analog pin and compares the result to a set threshold.
-   If the result is greater than the threshold, it writes
-   "knock" to the serial port, and toggles the LED on pin 13.
+ This sketch reads a piezo element to detect a knocking sound.
+ It reads an analog pin and compares the result to a set threshold.
+ If the result is greater than the threshold, it writes
+ "knock" to the serial port, and toggles the LED on pin 13.

-   The circuit:
-    * + connection of the piezo attached to analog in 0
-    * - connection of the piezo attached to ground
-    * 1-megohm resistor attached from analog in 0 to ground
+ The circuit:
+ * + connection of the piezo attached to analog in 0
+ * - connection of the piezo attached to ground
+ * 1-megohm resistor attached from analog in 0 to ground

-   http://www.arduino.cc/en/Tutorial/Knock
+ http://www.arduino.cc/en/Tutorial/Knock

-   created 25 Mar 2007
-   by David Cuartielles <http://www.0j0.org>
-   modified 30 Aug 2011
-   by Tom Igoe
+ created 25 Mar 2007
+ by David Cuartielles <http://www.0j0.org>
+ modified 30 Aug 2011
+ by Tom Igoe

-   This example code is in the public domain.
+ This example code is in the public domain.

  */
-

 // these constants won't change:
 const int ledPin = 13;      // led connected to digital pin 13
 const int knockSensor = A0; // the piezo is connected to analog pin 0
-const int threshold = 100;  // threshold value to decide when the detected sound is a knock or not
-
+const int threshold = 30; // threshold value to decide when the detected sound is a knock or not
+const int threshold_low = 8;
+const int wait = 100;    // ms

 // these variables will change:
-int sensorReading = 0;      // variable to store the value read from the sensor pin
-int ledState = LOW;         // variable used to store the last LED status, to toggle the light
+int sensorReading = 0;   // variable to store the value read from the sensor pin
+int ledState = LOW; // variable used to store the last LED status, to toggle the light

-void setup() {
-  pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
-  Serial.begin(9600);       // use the serial port
+void setup()
+{
+    pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
+    Serial.begin(9600);       // use the serial port
 }

-void loop() {
-  // read the sensor and store it in the variable sensorReading:
-  sensorReading = analogRead(knockSensor);
+int on = 0;
+unsigned long last_time = 0;
+void loop()
+{
+    // read the sensor and store it in the variable sensorReading:
+    sensorReading = analogRead(knockSensor);
+    unsigned long time = millis();
+//    Serial.println(sensorReading);

-  // if the sensor reading is greater than the threshold:
-  if (sensorReading >= threshold) {
-    // toggle the status of the ledPin:
-    ledState = !ledState;
+    // if the sensor reading is greater than the threshold:
+    if (sensorReading >= threshold)
+    {
+        if (!on)
+            if (time - last_time >= wait)
+            {
+                // toggle the status of the ledPin:
+                ledState = !ledState;
+
+//                ledState=1;
+
+                // send the string "Knock!" back to the computer, followed by newline
+                Serial.println("Knock!");
+                on = 1;
+                last_time = time;
+            }
+    }
+    if (sensorReading < threshold_low)
+    {
+        on = 0;
+//        ledState=0;
+    }
+
     // update the LED pin itself:
     digitalWrite(ledPin, ledState);
-    // send the string "Knock!" back to the computer, followed by newline
-    Serial.println("Knock!");
-  }
-  delay(100);  // delay to avoid overloading the serial port buffer
-}+
+    //delay(100);  // delay to avoid overloading the serial port buffer
+}


impl proc_check()

impl proc_check()

--- esp8266_160220_BYOP.ino
+++ esp8266_160220_BYOP.ino
@@ -7,6 +7,7 @@

 /*
  * v0.18 2016 Feb. 23
+ *  - impl proc_check()
  *  - msgStorageLib: add Test_MsgServer_Clear()
  *  - msgStorageLib: fix MsgServer_Remove1stMessage()
  * v0.17 2016 Feb. 23
@@ -143,10 +144,9 @@

 bool proc_check(String csvline)
 {
-#if 1
-  Test_MsgServer_postThenGet();
-#endif
-  debug_outputDebugString("proc_check", "line116 > start");
+  int msgcnt = MsgServer_GetMessageCount(g_owner.nickName);
+  String resstr = kCmdList[CMD_CHECK] + "," + String(msgcnt);
+  Serial.println(resstr);
 }

 bool proc_get(String csvline)


Update IR.ino

Update IR.ino

--- examples/Unit/IR/IR.ino
+++ examples/Unit/IR/IR.ino
@@ -24,7 +24,6 @@
 void setup() {
   M5.begin();
   M5.Power.begin();
-  Serial.begin(115200);
   pinMode(ir_recv_pin, INPUT);
   pinMode(ir_send_pin, OUTPUT);
   //send infrared light.  发送红外线


バグ修正（過去の受信履歴表示の初期値の誤り）

バグ修正（過去の受信履歴表示の初期値の誤り）

--- 2_example/example28_lcdkey/example28_lcdkey.ino
+++ 2_example/example28_lcdkey/example28_lcdkey.ino
@@ -81,8 +81,10 @@
                     disp_p=-1; strcpy(&lcd0[9],"IP_ADDR");
                     sprintf(lcd1,"%d.%d.%d.%d",ip&255,ip>>8&255,ip>>16&255,ip>>24);
                     break;
-                case BUTTON_UP: disp_p--; if(disp_p<0) disp_p=HIST_MAX-1; break;
-                case BUTTON_DOWN: disp_p++;if(disp_p>=HIST_MAX) disp_p=0; break;
+                case BUTTON_UP: if(disp_p<0) disp_p=hist_p;
+                    disp_p--; if(disp_p<0) disp_p=HIST_MAX-1; break;
+                case BUTTON_DOWN: if(disp_p<0) disp_p=hist_p;
+                    disp_p++;if(disp_p>=HIST_MAX) disp_p=0; break;
                 case BUTTON_LEFT: lcd_p=-8; if(lcd_p<0) lcd_p=0; break;
                 case BUTTON_RIGHT:
                     lcd_p=+8; if(strlen(&hist[disp_p][8])<=lcd_p)lcd_p=-8;break;


日付未取得時のダミー値

日付未取得時のダミー値

--- 2_example/example60_lcdkey/example60_lcdkey.ino
+++ 2_example/example60_lcdkey/example60_lcdkey.ino
@@ -96,7 +96,7 @@
 int disp_p=-1;                              // 履歴表示位置,負は非表示
 int disp_mode=0;                            // 表示モード(0:通常,1:棒グラフ)
 IPAddress ip;                               // IPアドレス保持用
-char date[20];                              // 日時保持用
+char date[20]="2000/01/01,00:00:00";        // 日時保持用
 int LOG_FILE_OUTPUT=1;                      // ファイル書込みの有効(1)／無効(0)
 int JPEG_FILE_OUTPUT=1;                     // 画像の書き込みの有効(1)／無効(0)
 int JPEG_FILE_VIEWER=0;                     // 画像表示の有効(1)／無効(0)


Use correct method for pin 2

Use correct method for pin 2

--- ESP8266HueEmulator/ESP8266HueEmulator.ino
+++ ESP8266HueEmulator/ESP8266HueEmulator.ino
@@ -35,7 +35,7 @@
 RgbColor black = RgbColor(0);
 unsigned int transitionTime = 800; // by default there is a transition time to the new state of 400 milliseconds

-NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(pixelCount, pixelPin);
+NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(pixelCount, pixelPin);
 NeoPixelAnimator animator(pixelCount, NEO_DECISECONDS); // NeoPixel animation management object

 RgbColor StripRgbColors[pixelCount]; // Holds all colors of the pixels on the strip even if they are off


formatting

formatting

--- dorm-leds.ino
+++ dorm-leds.ino
@@ -76,5 +76,6 @@
 	//ctrl_main_loop();

 	Serial.print(F("Free SRAM: "));
-	Serial.println(freeMemory());
+	Serial.print(freeMemory());
+	Serial.println(F(" bytes"));
 }


Added simple watering the plants method Removed serial

--- plantstation.ino
+++ plantstation.ino
@@ -53,40 +53,34 @@
 const int moistureThreshold = 500; // <- made this up
 int moistureSensorVal;

-//=====For Water Level=========================
+//=====For Water===============================
 const byte waterSensorPin = A2;
 // todo - find right value for this
 const int waterLevelThreshold = 400; // <- made this up
 boolean waterPumpIsOn = false;
 int waterLevelVal;
+unsigned long wateringSeconds = 10000;
+unsigned long prevWatering = 0;
 String waterLevel = "OK";

 //=====For Timed Events=========================
-//long prevSecTenMillis = 0;
-//long secTenInterval = 10000;
-
 long prevMinOneMillis = 0;
 long minOneInterval = 60000;
-
 long prevMinFiveMillis = 0;
 long minFiveInterval = 300000;
-
 long prevHourTwelveMillis = 0;
 long hourTwelveInterval = 43200000;

 void setup() {
   pinMode(LightSwitch, OUTPUT);
-  Serial.begin(9600);
-  Serial.println("PlantStation is warming up\n");

   myDHT.begin();
   Bridge.begin();
   Console.begin();

-  while (!Console) { ; }
+  while (!Console);
   Console.print("\nPlantStation is warming up.\nYun Console is warming up.\nKeen is warming up.\n\n");

-  while (!Serial);
   delay(5000);
 }

@@ -106,6 +100,7 @@
     prevMinOneMillis = currentMillis;

     sendToKeen();
+    waterPlants();
   }

   // these happen every five minutes (or so)
@@ -121,19 +116,29 @@

     waterPlants();
   }
+
+  if (waterPumpIsOn && currentMillis >= prevWatering + 10000) {
+    waterPumpIsOn = false;
+    Console.println("Watering stopped");
+  }
 }

 void waterPlants() {
-//  if (moistureThreshold < moistureSensorVal && !waterPumpIsOn && waterLevel == "OK") {
-//    if (currentMillis - prevSecTenMillis >= secTenInterval) {
-//      // digitalWrite(WaterPump, LOW);
-//      waterPumpIsOn = true;
-//    }
-//    // todo - water for ten seconds at a time and no more than twice a day?!?
-//    // digitalWrite(WaterPump, HIGH);
-//    waterPumpIsOn = true;
-//  }
-//  if (moistureThreshold > moistureSensorVal && waterPumpIsOn) {}
+
+  // todo - implement all the sensors (water level, moisture)
+  // todo - figure out how to send a water pump is on event for log even thou its off at time.
+  // todo - leave a trail that pump ran for event log
+  // todo - cleanup vars
+
+  // todo - timed events use regule marers for 1 min 1 hour etc and divide blah
+
+  prevWatering = millis();
+  if (!waterPumpIsOn) {
+    waterPumpIsOn = true;
+    Console.println("Watering started");
+  }
+
+
 }

 void switchLights() {
@@ -159,7 +164,7 @@
   waterLevelVal = analogRead(waterSensorPin);

   if (waterLevelVal < waterLevelThreshold) {
-    waterLevel = "LOW";
+   waterLevel = "LOW";
   } else {
    waterLevel = "OK";
   }
@@ -172,7 +177,6 @@
   am.heatIndex = myDHT.computeHeatIndex(am.tempAirF, am.humidityAir);

   if (am.humidityAir == 0  && am.tempAirC == 0) {
-    Serial.println("Failed to read from DHT sensor.");
     Console.println("Failed to read from DHT sensor.");
   }
 }
@@ -185,17 +189,14 @@
   if ( !myPT.search(addr)) {
       //no more sensors on chain, reset search
       myPT.reset_search();
-      Serial.println("No probe sensor detected");
       Console.println("No probe sensor detected");
   }

   if ( OneWire::crc8( addr, 7) != addr[7]) {
-      Serial.println("CRC is not valid!");
       Console.println("CRC is not valid!");
   }

   if ( addr[0] != 0x10 && addr[0] != 0x28) {
-      Serial.print("Device is not recognized");
       Console.print("Device is not recognized");
   }

@@ -298,7 +299,6 @@
   my_output += ";WaterPumptIsOn:";
   my_output += waterPumpIsOn;

-  Serial.println(my_output);
   Console.println(my_output);
 }


Build the MQTT output

Build the MQTT output

Signed-off-by: Nicolas Lamirault <57a11b2dec5b8363280015e1663433805cc2169e@gmail.com>

--- arduino/teleinfo/src/jarvis-teleinfo.ino
+++ arduino/teleinfo/src/jarvis-teleinfo.ino
@@ -136,23 +136,34 @@

 void NewFrameCallback(ValueList * teleinfodata) {
-  Serial.println(F("[jarvis] Teleinfo new frame"));
+  Serial.println("[jarvis] Teleinfo new frame");
   sendTeleinfoData(teleinfodata);
 }

 void UpdatedFrameCallback(ValueList * teleinfodata) {
-   Serial.println(F("[jarvis] Teleinfo frame updated"));
+   Serial.println("[jarvis] Teleinfo frame updated");
    sendTeleinfoData(teleinfodata);
 }

 void  sendTeleinfoData(ValueList * teleinfodata) {
   if (teleinfodata) {
+    String output = "";
+    bool firstdata = true;
     while (teleinfodata->next) {
       teleinfodata = teleinfodata->next;
-
+      if (firstdata) {
+          firstdata = false;
+      } else {
+          output += ", ";
+      }
+      output += teleinfodata->name;
+      output += "=";
+      output += teleinfodata->value;
     }
+    Serial.print("[jarvis] Teleinfo mqtt output: ");
+    Serial.println(output);
   }
 }


Improved read performance slightly with some optimisations

--- ReadSensors/ReadSensors.ino
+++ ReadSensors/ReadSensors.ino
@@ -96,19 +96,13 @@
   unsigned int d1  = analogRead(D1);
   unsigned int d0  = analogRead(D0);

-  // Generate filtered versions (character states)
-  byte freg = getData(reg);
-  byte fd7  = getData(d7);
-  byte fd6  = getData(d6);
-  byte fd5  = getData(d5);
-  byte fd4  = getData(d4);
-  byte fd3  = getData(d3);
-  byte fd2  = getData(d2);
-  byte fd1  = getData(d1);
-  byte fd0  = getData(d0);
-
-  // turn into a byte
-  byte now = (fd7<<7)|(fd6<<6)|(fd5<<5)|(fd4<<4)|(fd3<<3)|(fd2<<2)|(fd1<<1)|(fd0<<0);
+  // Generate filtered version, as a byte
+  byte freg = getData(reg, 0);
+
+  byte now = getData(d7, 7) | getData(d6, 6) | getData(d5, 5) | getData(d4, 4)
+           | getData(d3, 3) | getData(d2, 2) | getData(d1, 1) | getData(d0, 0);
+
+  // Show live diagnostics on LEDs
   writeLEDs(freg, now);

   // crank round the acquisition state machine
@@ -221,9 +215,9 @@
 }

-byte getData(unsigned int adc)
-{
-  if (adc < 200) return 1;
+byte getData(unsigned int adc, byte bitno)
+{
+  if (adc < 200) return (1<<bitno);
   return 0;
 }