Update SampleEmic2Code.ino

Update SampleEmic2Code.ino

--- Speech/Emic-2-Arduino-Compatible-Module/SampleEmic2Code.ino
+++ Speech/Emic-2-Arduino-Compatible-Module/SampleEmic2Code.ino
@@ -1,7 +1,7 @@
 #include <SoftwareSerial.h>

-#define rxPin 2    // Connect to SOUT
-#define txPin 3    // Connect to SIN
+#define rxPin 2    // Connect this to SOUT
+#define txPin 3    // Connect this to SIN

 SoftwareSerial roboSerial =  SoftwareSerial(rxPin, txPin);


WriteSpace, better 'E'

WriteSpace, better 'E'

--- software/firmware/LogoBotWifiScribbler/LogoBotWifiScribbler.ino
+++ software/firmware/LogoBotWifiScribbler/LogoBotWifiScribbler.ino
@@ -591,6 +591,9 @@
       case 'Z':
         writeZ();
         break;
+      case ' ':
+        writeSpace();
+        break;

       default:
         pushCmd("BZ 500");
@@ -687,15 +690,15 @@
   float y = state.y;
   float w = fontSize * 0.5;

-  pushCmd("PD");
-  pushTo(x, y + capHeight);
-  pushTo(x + w, y + capHeight);
+  pushTo(x + w, y + capHeight);
+  pushCmd("PD");
+  pushTo(x, y + capHeight);
+  pushTo(x, y);
+  pushTo(x + w, y);
   pushCmd("PU");
-  pushTo(x + w, y + capHeight / 2);
-  pushCmd("PD");
   pushTo(x, y + capHeight / 2);
-  pushTo(x, y);
-  pushTo(x + w, y);
+  pushCmd("PD");
+  pushTo(x + w, y + capHeight /2);
   NEXTLETTER
 }

@@ -1005,6 +1008,14 @@
   NEXTLETTER
 }

+static void writeSpace()
+{
+  float x = state.x;
+  float y = state.y;
+  float w = fontSize * 0.5;
+  NEXTLETTER
+}
+

 long sqr(long v) {
   return v*v;


dividing incoming speed by 10, to make a float out of int


/ ‘Touch_Screen/Touch_Screen.ino’

/ ‘Touch_Screen/Touch_Screen.ino’

--- Touch_Screen/Touch_Screen.ino
+++ Touch_Screen/Touch_Screen.ino
@@ -1,7 +1,15 @@
 /* This is my Sketch for the Touch Screen interface for the relay box that will be installed in my Jeep
     Robert L. Wardecker
     cna2rn@gmail.com
-    This code is in public domain
+    This code is in public domain.
+
+Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
+
+NonCommercial — You may not use the material for commercial purposes.
+
+ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
+
+No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
 */

 #include <SoftwareSerial.h>


Fixed gameplay bounds. Moved start location to center screen

--- snack/snack.ino
+++ snack/snack.ino
@@ -2,6 +2,11 @@

 // make an instance of arduboy used for many functions
 Arduboy arduboy;
+
+int maxX = 127;
+int minX = 0;
+int maxY = 63;
+int minY = 10;

 class coords
 {
@@ -28,11 +33,6 @@
 Coords foodLocation;
 Coords previousPosition;

-int maxX = 127;
-int minX = 0;
-int maxY = 53;
-int minY = 10;
-
 int score = 0;
 int arrayPosition = 0;

@@ -45,12 +45,11 @@

 void StartGame()
 {
-  p1.X = 1;
-  p1.Y = 1;
+  p1.X = maxX / 2;
+  p1.Y = (maxY / 2) + 10;
   GenerateFood();
 }

-//TODO only log move if location has changed.
 void LogMove()
 {
   if(p1.Moves[arrayPosition] == NULL)
@@ -113,7 +112,7 @@

 void DrawFrame()
 {
-  arduboy.drawRect(minX,minY, maxX, maxY, WHITE);
+  arduboy.drawRect(minX,minY, maxX +1, (maxY - minY) +1, WHITE);
 }

 // This function runs once in your game.


Fixed trying to write out of bounds of tail array. Causing graphics corruption. Fixes #3

--- snack/snack.ino
+++ snack/snack.ino
@@ -17,7 +17,7 @@
   int X = 0;
   int Y = 0;
   char dir = 'R';
-  int Len = 1;
+  int Len = 0;
   static const int MaxLength = 10;
   Coords *Moves[MaxLength] = {NULL};
 };
@@ -76,7 +76,11 @@
 {
   if(p1.X == foodLocation.X && p1.Y == foodLocation.Y)
   {
-    p1.Len += 1;
+    if(p1.Len < p1.MaxLength)
+    {
+      p1.Len += 1;
+    }
+
     score += 1;
     LogMove();
     GenerateFood();


Control four Neopixel strips

Control four Neopixel strips

--- arduino/NeopixelSerialCommslib/NeopixelSerialCommslib.ino
+++ arduino/NeopixelSerialCommslib/NeopixelSerialCommslib.ino
@@ -6,7 +6,7 @@
 #define LED 13

 // Which pin on the Arduino is connected to the NeoPixels?
-#define PIN            8
+#define PIN_BASE            8

 // How many NeoPixels are attached to the Arduino?
 #define NUMPIXELS      16
@@ -16,25 +16,31 @@
 // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
 // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
 // example for more information on possible values.
-Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

-HSVColori myColor(100,255,100); // h,s,v
+Adafruit_NeoPixel pixels[] = {
+  Adafruit_NeoPixel(NUMPIXELS, PIN_BASE + 0, NEO_GRB + NEO_KHZ800),
+  Adafruit_NeoPixel(NUMPIXELS, PIN_BASE + 1, NEO_GRB + NEO_KHZ800),
+  Adafruit_NeoPixel(NUMPIXELS, PIN_BASE + 2, NEO_GRB + NEO_KHZ800),
+  Adafruit_NeoPixel(NUMPIXELS, PIN_BASE + 3, NEO_GRB + NEO_KHZ800)
+};
+
+HSVColori myColor(100, 255, 100); // h,s,v

 CljComms comms;

 //
 // I expect 'L 1' or 'L 0'
-//
+//

 void do_LED(int n, byte *args) {
   if (n >= 1) {
-
+
     byte state = args[0]; // 0-255

     if (state == 1) {
       digitalWrite(LED, HIGH);
-    }
+    }
     else {
       digitalWrite(LED, LOW);
     }
@@ -57,23 +63,51 @@
 }

-void do_HSV(int n, byte *args)
+void do_HSV(int n, byte *args)
 {
-   byte response[1];
-   response[0] =  '0'; // assume failure
+  byte response[1];
+  uint32_t c;
+  int i, j;
+  response[0] =  '0'; // assume failure

-  if (n == 3)
+  if (n == 12)
   {
-    myColor.h = args[0];
-    myColor.s = args[1];
-    myColor.v = args[2];
+    for (j = 0; j < 4; j++) {
+      HSVColori myColor(args[j*3 + 0], args[j*3 + 1], args[j*3 + 2]);
+
+      c = myColor.toRGB();
+      for (i = 0; i < NUMPIXELS; i++) {
+        // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
+        pixels[j].setPixelColor(i, c );
+      }
+      pixels[j].show(); // This sends the updated pixel color to the hardware.
+    }
+
+    response[0] =  '1'; // SUCCESS
+  }
+  comms.xmit('!', 1, response);
+}
+
+
+void do_Off(int n, byte *args)
+{
+  byte response[1];
+  int i, j;
+  response[0] =  '0'; // assume failure
+
+  if (n >= 1)
+  {
+    HSVColori myColor(0, 0, 0);

     uint32_t c = myColor.toRGB();

-    for(int i=0;i<NUMPIXELS;i++){
-      // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
-      pixels.setPixelColor(i, c );
-      pixels.show(); // This sends the updated pixel color to the hardware.
+    for (j = 0; j < 4; j++) {
+      for (i = 0; i < NUMPIXELS; i++) {
+        // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
+        pixels[0].setPixelColor(i, c );
+        pixels[0].show();
+      }
+      pixels[j].show(); // This sends the updated pixel color to the hardware.
     }
     response[0] =  '1'; // SUCCESS
   }
@@ -81,32 +115,10 @@
 }

-void do_Off(int n, byte *args)
+void do_On(int n, byte *args)
 {
-   byte response[1];
-   response[0] =  '0'; // assume failure
-
-  if (n >= 1)
-  {
-    myColor.v = 0;
-
-    uint32_t c = myColor.toRGB();
-
-    for(int i=0;i<NUMPIXELS;i++){
-      // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
-      pixels.setPixelColor(i, c );
-      pixels.show(); // This sends the updated pixel color to the hardware.
-    }
-    response[0] =  '1'; // SUCCESS
-  }
-  comms.xmit('!', 1, response);
-}
-
-
-void do_On(int n, byte *args)
-{
-   byte response[1];
-   response[0] =  '0'; // assume failure
+  byte response[1];
+  response[0] =  '0'; // assume failure

   if (n >= 1)
   {
@@ -114,11 +126,11 @@

     uint32_t c = myColor.toRGB();

-    for(int i=0;i<NUMPIXELS;i++){
+    for (int i = 0; i < NUMPIXELS; i++) {
       // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
-      pixels.setPixelColor(i, c );
-      pixels.show(); // This sends the updated pixel color to the hardware.
+      pixels[0].setPixelColor(i, c );
     }
+    pixels[0].show(); // This sends the updated pixel color to the hardware.
     response[0] =  '1'; // SUCCESS
   }
   comms.xmit('!', 1, response);
@@ -129,20 +141,24 @@

 void setup() {
   pinMode(LED, OUTPUT);
-
+
   delay(5); // let things settle
+  HSVColori myColor(100, 255, 100);
   uint32_t c = myColor.toRGB();

   // debug:
   //Serial.println(c,BIN);

-  pixels.begin(); // This initializes the NeoPixel library.
-  for(int i=0;i<NUMPIXELS;i++){
-    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
-    pixels.setPixelColor(i, c ); // Moderately bright green color.
-    pixels.show(); // This sends the updated pixel color to the hardware.
+  for (int n = 0; n < 4; n++) {
+    pixels[n].begin(); // This initializes the NeoPixel library.
+
+    for (int i = 0; i < NUMPIXELS; i++) {
+      // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
+      pixels[n].setPixelColor(i, c ); // Moderately bright green color.
+    }
+
+    pixels[n].show(); // This sends the updated pixel color to the hardware.
   }
-

   comms.begin(BAUDRATE);
   comms.bind('L', do_LED);
@@ -158,4 +174,3 @@
   }
 }

-


use pre-defined LED_BUILTIN variable.

use pre-defined LED_BUILTIN variable.

--- examples/_0012_ADC/_0012_ADC.ino
+++ examples/_0012_ADC/_0012_ADC.ino
@@ -1,14 +1,11 @@
-//#define ESPERT_BOARD_ESPRESSO_LITE2
-
-#ifdef ESPERT_BOARD_ESPRESSO_LITE2
-static const int PIN_LED = 2; // ESPresso Lite v2.0
-#else
-static const int PIN_LED = 16; // ESPresso Lite
-#endif
+/*
+ * EPresso 1.0 LED_BUILTIN = 16;
+ * EPresso 2.0 LED_BUILTIN = 2;
+ */

 void setup() {
   Serial.begin(115200);
-  pinMode(PIN_LED, OUTPUT);
+  pinMode(LED_BUILTIN, OUTPUT);
   pinMode(A0, INPUT);
   Serial.println("ADC init");
 }
@@ -18,4 +15,4 @@
   Serial.println("ADC: " + String(out));

   delay(1000);
-}
+}


Removed WIFI init

Removed WIFI init

--- GEVCU.ino
+++ GEVCU.ino
@@ -87,8 +87,8 @@
 SerialUSB.begin(115200); // use SerialUSB only as the programming port doesn't work
 Serial2.begin(115200); // use Serial3 for GEVCU2, use Serial2 for GEVCU3+4

-sendWiReach("AT+iFD");//Host connection set to serial port
-delay(5000);
+//sendWiReach("AT+iFD");//Host connection set to serial port
+//delay(5000);
 sendWiReach("AT+iHIF=1");//Host connection set to serial port
 sendWiReach("AT+iBDRF=9");//Automatic baud rate on host serial port
 sendWiReach("AT+iRPG=secret"); //Password for iChip wbsite
@@ -268,7 +268,7 @@
             {
 	      Logger::info("Initializing EEPROM");
 	      initSysEEPROM();
-              initWiReach();
+             // initWiReach();
 	    }
           else {Logger::info("Using existing EEPROM values");}//checksum is good, read in the values stored in EEPROM


Fixed number of analog pins.

Fixed number of analog pins.

--- examples/Canvas/CosaCanvasHistogram/CosaCanvasHistogram.ino
+++ examples/Canvas/CosaCanvasHistogram/CosaCanvasHistogram.ino
@@ -80,8 +80,9 @@

 void loop()
 {
-  for (uint8_t ix = 0; ix < membersof(analog_pin_map); ix++) {
-    static uint16_t sample[membersof(analog_pin_map)];
+  const uint8_t ANALOG_PIN_MAX = 6;
+  for (uint8_t ix = 0; ix < ANALOG_PIN_MAX; ix++) {
+    static uint16_t sample[ANALOG_PIN_MAX];
     if (sample[ix] < 20) sample[ix] = 20;
     uint8_t x = 6 + (25*ix);
     uint8_t y = tft.HEIGHT - sample[ix];


Testing CC1101 device driver build.

Testing CC1101 device driver build.

--- examples/Wireless/CosaWirelessButton/CosaWirelessButton.ino
+++ examples/Wireless/CosaWirelessButton/CosaWirelessButton.ino
@@ -35,20 +35,20 @@
 #include "Cosa/RTC.hh"

 // Select Wireless device driver (network = 0xC05A, device = 0x02)
-// #include "Cosa/Wireless/Driver/CC1101.hh"
-// CC1101 rf(0xC05A, 0x02);
+#include "Cosa/Wireless/Driver/CC1101.hh"
+CC1101 rf(0xC05A, 0x02);

 // #include "Cosa/Wireless/Driver/NRF24L01P.hh"
 // NRF24L01P rf(0xC05A, 0x02);

-#include "Cosa/Wireless/Driver/VWI.hh"
-#include "Cosa/Wireless/Driver/VWI/Codec/VirtualWireCodec.hh"
-VirtualWireCodec codec;
-#if defined(__ARDUINO_TINYX5__)
-VWI rf(0xC05A, 0x03, 4000, Board::D1, Board::D0, &codec);
-#else
-VWI rf(0xC05A, 0x02, 4000, Board::D7, Board::D8, &codec);
-#endif
+// #include "Cosa/Wireless/Driver/VWI.hh"
+// #include "Cosa/Wireless/Driver/VWI/Codec/VirtualWireCodec.hh"
+// VirtualWireCodec codec;
+// #if defined(__ARDUINO_TINYX5__)
+// VWI rf(0xC05A, 0x03, 4000, Board::D1, Board::D0, &codec);
+// #else
+// VWI rf(0xC05A, 0x02, 4000, Board::D7, Board::D8, &codec);
+// #endif

 // Connect button between ground and pin TinyX4 EXT0/D10, TinyX5
 // EXT0/D2, Mega EXT2/D29 and others to Arduino EXT1 which is


fix a crash while ota

fix a crash while ota

we need to suspend all the possible isr to ensure ota process

--- src/neurite.ino
+++ src/neurite.ino
@@ -110,7 +110,6 @@

 ESP8266WebServer *server;
 File fsUploadFile;
-Servo myservo;

 static void reboot(struct neurite_data_s *nd);

@@ -129,6 +128,30 @@
 	worker_st = st;
 }

+static void ota_hold(void)
+{
+	struct neurite_data_s *nd = &g_nd;
+#ifdef NEURITE_ENABLE_USER
+	neurite_user_hold();
+#endif
+	stop_ticker_but(nd);
+	stop_ticker_mon(nd);
+	stop_ticker_led(nd);
+	stop_ticker_cmd(nd);
+}
+
+static void ota_release(void)
+{
+	struct neurite_data_s *nd = &g_nd;
+	start_ticker_cmd(nd);
+	start_ticker_led_breath(nd);
+	start_ticker_mon(nd);
+	start_ticker_but(nd);
+#ifdef NEURITE_ENABLE_USER
+	neurite_user_setup();
+#endif
+}
+
 static int ota_over_http(char *url)
 {
 	if (!url) {
@@ -138,6 +161,7 @@
 	CMD_SERIAL.print("ota: ");
 	CMD_SERIAL.println(url);

+	ota_hold();
 	t_httpUpdate_return ret;
 	ret = ESPhttpUpdate.update(url);

@@ -154,6 +178,7 @@
 			log_info("ok\n\r");
 			break;
 	}
+	ota_release();
 	return ret;
 }

@@ -166,6 +191,7 @@
 	CMD_SERIAL.print("otafs: ");
 	CMD_SERIAL.println(url);

+	ota_hold();
 	t_httpUpdate_return ret;
 	ret = ESPhttpUpdate.updateSpiffs(url);

@@ -182,6 +208,7 @@
 			log_info("ok\n\r");
 			break;
 	}
+	ota_release();
 	return ret;
 }

@@ -484,50 +511,43 @@
 	}
 }

-static inline void stop_ticker_led(struct neurite_data_s *nd)
+inline void stop_ticker_led(struct neurite_data_s *nd)
 {
 	ticker_led.detach();
 }
-static inline void start_ticker_led_breath(struct neurite_data_s *nd)
+inline void start_ticker_led_breath(struct neurite_data_s *nd)
 {
 	stop_ticker_led(nd);
 	ticker_led.attach_ms(50, ticker_led_breath);
 }
-
-static inline void start_ticker_led_blink(struct neurite_data_s *nd)
+inline void start_ticker_led_blink(struct neurite_data_s *nd)
 {
 	stop_ticker_led(nd);
 	ticker_led.attach_ms(50, ticker_led_blink);
 }
-
-static inline void stop_ticker_mon(struct neurite_data_s *nd)
+inline void stop_ticker_mon(struct neurite_data_s *nd)
 {
 	ticker_mon.detach();
 }
-
-static inline void start_ticker_mon(struct neurite_data_s *nd)
+inline void start_ticker_mon(struct neurite_data_s *nd)
 {
 	stop_ticker_mon(nd);
 	ticker_mon.attach_ms(100, ticker_monitor_task, nd);
 }
-
-static inline void stop_ticker_worker(struct neurite_data_s *nd)
+inline void stop_ticker_worker(struct neurite_data_s *nd)
 {
 	ticker_worker.detach();
 }
-
-static inline void start_ticker_worker(struct neurite_data_s *nd)
+inline void start_ticker_worker(struct neurite_data_s *nd)
 {
 	stop_ticker_worker(nd);
 	ticker_worker.attach(1, ticker_worker_task);
 }
-
-static inline void stop_ticker_but(struct neurite_data_s *nd)
+inline void stop_ticker_but(struct neurite_data_s *nd)
 {
 	ticker_but.detach();
 }
-
-static inline void start_ticker_but(struct neurite_data_s *nd)
+inline void start_ticker_but(struct neurite_data_s *nd)
 {
 	stop_ticker_but(nd);
 	ticker_but.attach_ms(50, ticker_button_task, nd);
@@ -582,12 +602,12 @@
 	cmd_parse_byte(nd->cp, c);
 }

-static inline void stop_ticker_cmd(struct neurite_data_s *nd)
+inline void stop_ticker_cmd(struct neurite_data_s *nd)
 {
 	ticker_cmd.detach();
 }

-static void start_ticker_cmd(struct neurite_data_s *nd)
+inline void start_ticker_cmd(struct neurite_data_s *nd)
 {
 	stop_ticker_cmd(nd);
 	ticker_cmd.attach_ms(1, ticker_cmd_task, nd);
@@ -957,13 +977,8 @@
 			update_worker_state(WORKER_ST_2);
 			break;
 		case WORKER_ST_2:
-			if (digitalRead(NEURITE_BUTTON) == LOW) {
-				stop_ticker_led(nd);
-				stop_ticker_but(nd);
+			if (digitalRead(NEURITE_BUTTON) == LOW)
 				ota_over_http(OTA_URL_DEFAULT);
-				start_ticker_but(nd);
-				start_ticker_led_blink(nd);
-			}
 			mqtt_config(nd);
 			update_worker_state(WORKER_ST_3);
 			break;
@@ -1091,6 +1106,8 @@

 #define USER_LOOP_INTERVAL 1000
 static bool b_user_loop_run = false;
+
+Servo myservo;

 void neurite_user_loop(void)
 {
@@ -1222,10 +1239,17 @@
 	}
 }

+/* called on critical neurite behavior such as OTA */
+void neurite_user_hold(void)
+{
+	log_dbg("\n\r");
+	myservo.detach();
+}
+
 /* will be called after neurite system setup */
 void neurite_user_setup(void)
 {
-	log_dbg("called\n\r");
+	log_dbg("\n\r");
 	myservo.attach(13);
 	pinMode(14, OUTPUT);
 	analogWrite(14, 1023);


main: make it easier to enter OTA mode

main: make it easier to enter OTA mode

Move checking of set button press after printing "hello". Wait 1s before
reading it.

--- src/main.ino
+++ src/main.ino
@@ -97,7 +97,27 @@
     dht22.begin();

 #ifdef ESP8266
-
+    WiFi.mode(WIFI_STA);
+    WiFi.disconnect();
+    delay(100);
+    WiFi.forceSleepBegin(); // Use WiFi.forceSleepWake() to enable wifi
+
+    String r = ESP.getResetReason();
+
+    if (r == "Deep-Sleep Wake") {
+        clear = false;
+    }
+#endif
+
+    if (clear) {
+        display.clear();
+        display.setCursor(0,0);
+        display.println("Hello");
+    }
+
+#ifdef ESP8266
+
+    delay(1000);
     set_press = (expand.readByte() & 0b10 ) != 0b10;
     if (set_press) {
         display.clear();
@@ -122,26 +142,6 @@
     expand.attachInterrupt(iter);
 #endif

-
-#ifdef ESP8266
-    WiFi.mode(WIFI_STA);
-    WiFi.disconnect();
-    delay(100);
-    WiFi.forceSleepBegin(); // Use WiFi.forceSleepWake() to enable wifi
-
-    String r = ESP.getResetReason();
-
-    if (r == "Deep-Sleep Wake") {
-        clear = false;
-    }
-#endif
-
-    if (clear) {
-        display.clear();
-        display.setCursor(0,0);
-        display.println("Hello");
-    }
-
     sensor.set_sleep(false);
     sensor.set_mode(sds011::QUERY);


Equalizre_8BandBiquad: add missing channel to mixer

--- examples/03-Intermediate/Equalizer_8BandBiquad/Equalizer_8BandBiquad.ino
+++ examples/03-Intermediate/Equalizer_8BandBiquad/Equalizer_8BandBiquad.ino
@@ -55,6 +55,7 @@
 AudioConnection_F32       patchCord34(gainBlocks[3],0,mixer,3);   //connect gain block back to mixer
 AudioConnection_F32       patchCord35(gainBlocks[4],0,mixer,4);   //connect gain block back to mixer
 AudioConnection_F32       patchCord36(gainBlocks[5],0,mixer,5);   //connect gain block back to mixer
+AudioConnection_F32       patchCord36(gainBlocks[6],0,mixer,6);   //connect gain block back to mixer
 AudioConnection_F32       patchCord37(gainBlocks[7],0,mixer,7);   //connect gain block back to mixer

 AudioConnection_F32       patchCord51(mixer,0,gainOverall,0);     //connect gain block back to mixer


Fixed magnetometer axis bug

Fixed magnetometer axis bug

Signed-off-by: bergerkiller <34c1d059d3a687c0064b6822cf3cda4335a41a9c@gmail.com>

--- examples/HMC5883L/HMC5883L.ino
+++ examples/HMC5883L/HMC5883L.ino
@@ -23,7 +23,7 @@
   color_t bar_colors[3] = {RED, GREEN, BLUE};
   for (int i = 0; i < 3; i++) {
     bars[i].setBounds(10 + i * 25, 20, 23, 200);
-    bars[i].setRange(0.0F, 4096.0F);
+    bars[i].setRange(-4096.0F, 4096.0F);
     bars[i].setColor(CONTENT, bar_colors[i]);
     display.addWidget(bars[i]);
   }
@@ -38,9 +38,9 @@
   MagnetometerRaw raw = compass.ReadRawAxis();

   // Obtain the x/y/z values
-  float x = (float) abs(raw.ZAxis);
-  float y = (float) abs(raw.YAxis);
-  float z = (float) abs(raw.ZAxis);
+  float x = (float) raw.XAxis;
+  float y = (float) raw.YAxis;
+  float z = (float) raw.ZAxis;
   bars[0].setValue(x);
   bars[1].setValue(y);
   bars[2].setValue(z);
@@ -63,4 +63,4 @@
   int dx = (int) ((float) (compass_rad - 2) * cos(angle));
   int dy = (int) ((float) (compass_rad - 2) * sin(angle));
   display.drawLine(compass_x + dx, compass_y + dy, compass_x, compass_y, color);
-}
+}


fix adc_test commit typo

fix adc_test commit typo

--- examples/adc_test/adc_test.ino
+++ examples/adc_test/adc_test.ino
@@ -62,10 +62,7 @@

     for (int i=0;i<DIG_PINS;i++) {
         pinMode(adc_pins_dig[i], mode);
-<<<<<<< HEAD
-=======
         delay(50); // settle time
->>>>>>> 98cde6a... improve adc_test, it works for all boards
         value = adc->analogRead(adc_pins_dig[i]);
         bool fail_condition = pullup ? (value < 0.95*max_val) : (value > 0.05*max_val);
         if (fail_condition) {


Reduced code and problematic text on serial

--- arduinofences.ino
+++ arduinofences.ino
@@ -69,34 +69,19 @@
     Serial.println("Started webserver ...");
 }

-void printStates()
-{
-        for (stateCounter = 0 ; stateCounter < 1; stateCounter++)
-        {
+void changeStates() {
+        for (stateCounter = 0 ; stateCounter < 1; stateCounter++) {
             boolToString(states[stateCounter], stateBuff);
-
-            Serial.print("State of ");
-            Serial.print(stateCounter);
-            Serial.print(": ");
-            Serial.println(stateBuff);
+            digitalWrite(ledPin1, states[stateCounter]);
         }
 }

-void writeStates()
-{
-        //set led states
-        digitalWrite(ledPin1, states[0]);
-}
-
-void boolToString (boolean test, char returnBuffer[4])
-{
+void boolToString (boolean test, char returnBuffer[4]) {
   returnBuffer[0] = '\0';
-  if (test)
-  {
+  if (test) {
     strcat(returnBuffer, "On");
   }
-  else
-  {
+  else {
     strcat(returnBuffer, "Off");
   }
 }
@@ -104,25 +89,17 @@
 // This is our page serving function that generates web pages
 boolean sendPage(char* URL) {

-  Serial.println("Page printing begun");
-
-    printStates();
-    writeStates();
+  changeStates();

   //check whether we need to change the led state
-  if (URL[1] == '?' && URL[2] == 'L' && URL[3] == 'E' && URL[4] == 'D') //url has a leading /
-  {
+  if (URL[1] == '?' && URL[2] == 'L' && URL[3] == 'E' && URL[4] == 'D') { //url has a leading /
     ledChange = (int)(URL[5] - 48); //get the led to change.

-    for (stateCounter = 0 ; stateCounter < 1; stateCounter++)
-    {
-      if (ledChange == stateCounter)
-      {
+    for (stateCounter = 0 ; stateCounter < 1; stateCounter++) {
+      if (ledChange == stateCounter) {
         states[stateCounter] = !states[stateCounter];
-            Serial.print("Have changed ");
-            Serial.println(ledChange);
-            Serial.print("Sending RFID .... ");
-            sendCode();
+        Serial.print("Sending RFID .... ");
+        sendCode();
       }
     }

@@ -163,14 +140,13 @@
         return true;
    }
    else {
-     return true;
+     return false;
    }
 }

 // Storage for the recorded code
 int codeType = -1; // The type of code
 unsigned long codeValue; // The code value if not raw
-unsigned int rawCodes[RAWBUF]; // The durations if raw
 int codeLen; // The length of the code
 int toggle = 0; // The RC5/6 toggle state

@@ -183,29 +159,7 @@
   int count = results->rawlen;

   if (codeType == UNKNOWN) {
-    Serial.println("Received unknown code, saving as raw");
-
-    codeLen = results->rawlen - 1;
-    // To store raw codes:
-    // Drop first value (gap)
-    // Convert from ticks to microseconds
-    // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
-    for (int i = 1; i <= codeLen; i++) {
-      /*
-      if (i % 2) {
-        // Mark
-        //rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
-        Serial.print(" m");
-      }
-      else {
-        // Space
-        //rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
-        Serial.print(" s");
-      }
-      //Serial.print(rawCodes[i - 1], DEC);
-      */
-    }
-    Serial.println("");
+    //Serial.println("Received unknown code, ignoring");
   }
   else {
     if (codeType == NEC) {
@@ -238,7 +192,6 @@
 }

 void sendCode() {
-  Serial.print("1");
   if (codeType == NEC) {
     Serial.print("Sent NEC ");
     Serial.println(codeValue, HEX);
@@ -268,11 +221,8 @@
     }
   }
   else if (codeType == UNKNOWN) {
-    // Assume 38 KHz
-    Serial.println("Sent raw");
-    //irsend.sendRaw(rawCodes, codeLen, 38);
-  }
-  Serial.print("2");
+    //Serial.println("Ignoring unknown code");
+  }
 }

 void loop()
@@ -287,6 +237,7 @@
   }
   else {
     sendCode();
+  //  delay(500);
   }
   lastButtonState = buttonState;


updated parallel out test

updated parallel out test

--- proj/parallel_out_test/parallel_out_test.ino
+++ proj/parallel_out_test/parallel_out_test.ino
@@ -1,7 +1,7 @@
 #include<FastLED.h>

-#define NUM_LED 90
+#define NUM_LED 180
 #define NUM_STRIPS 8

@@ -30,12 +30,7 @@
 void loop() {

   for (uint8_t ss = 0; ss < NUM_STRIPS; ss++) {
-    if (ss == 0) {
-      fill_solid(leds, NUM_LED, ColorFromPalette(test, ss * 16, 32, LINEARBLEND));
-    }
-    else {
-      fill_solid(&(leds[ss * NUM_LED]), NUM_LED, ColorFromPalette(test, ss * 16, 32, LINEARBLEND));
-    }
+    fill_solid(&(leds[ss*NUM_LED]), NUM_LED, ColorFromPalette(test, ss * 16, 32, LINEARBLEND));
   }


Work around MCCI STM32 BSP V2.5 issue

Work around MCCI STM32 BSP V2.5 issue

--- examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
+++ examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
@@ -580,6 +580,18 @@
     }
 }

+// there's a problem with running 2.5 of the MCCI STM32 BSPs;
+// hack around it.
+#ifdef ARDUINO_ARCH_STM32
+# ifdef _mcci_arduino_version
+#  if _mcci_arduino_version <= _mcci_arduino_version_calc(2, 5, 0, 0)
+uint32_t USBD_LL_ConnectionState(void) {
+  return 1;
+}
+#  endif // _mcci_arduino_version
+# endif // defined(_mcci_arduino_version)
+#endif // ARDUINO_ARCH_STM32
+
 void setup() {
     delay(5000);
     while (! Serial)


Switch compliance version macro to one that is not BSP-dependent

--- examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
+++ examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino
@@ -22,7 +22,7 @@
 #include <SPI.h>
 class cEventQueue;

-#define APPLICATION_VERSION _mcci_arduino_version_calc(3,0,99,10)
+#define APPLICATION_VERSION ARDUINO_LMIC_VERSION_CALC(3,0,99,10)

 //
 // For compliance tests with the RWC5020A, we use the default addresses


update

update

--- src/Firmware.ino
+++ src/Firmware.ino
@@ -2,8 +2,7 @@
 #include <MeStepper.h>
 #define SBI(n, b) (n |= _BV(b))
 #define CBI(n, b) (n &= ~_BV(b))
-
-#define POINTS_COUNT 8
+#define POINTS_COUNT 100
 #define PULSES_PER_MM 100
 #define CURVE_SECTION 0.5
 #define NUM_STEPS 10
@@ -26,22 +25,21 @@
     volatile long targetCount[NUM_AXIS];
     volatile long totalCount = 0;
     volatile uint16_t speed = 1000;
-    volatile uint16_t exitSpeed = 100;
+    volatile uint16_t exitSpeed = 1000;
     volatile uint16_t acceleration = 1;
     volatile uint8_t power = 0;
 } PlannerPoint;
 typedef struct
 {
-    bool running = false;
     volatile long currentPosition[NUM_AXIS] = {0, 0};
     volatile long targetPosition[NUM_AXIS];
     volatile long startPosition[NUM_AXIS];
     volatile long lastPosition[NUM_AXIS] = {0, 0};
-    long defaultAcceleration = 64;
-    long defaultAccelCount = 200;
-    long defaultDecelCount = 200;
-    uint16_t defaultSpeed = 1000;
-    volatile long currentSpeed = 1;
+    volatile long defaultAcceleration = 64;
+    volatile long defaultAccelCount = 200;
+    volatile long defaultDecelCount = 200;
+    volatile uint16_t defaultSpeed = 1000;
+    volatile long currentSpeed = 100;
     volatile uint8_t power = 0;
     volatile uint16_t speed = 1000;
     volatile uint16_t acceleration = 100;
@@ -50,19 +48,23 @@
     volatile uint8_t isRunningState = MOTION_ACCELETING;
     volatile bool isRelative = false;
     uint8_t powerPin = 10;
-    String buffer = "";
+    String buffer;
+    volatile int bufferIndex = 0;
+    volatile long during = 1000;
+    volatile long currentTime = 0;
 } SystemStatus;
 static SystemStatus _sys;
 static PlannerPoint _points[POINTS_COUNT];
 static PlannerPoint _prevPoint;
 volatile bool busy = false;
+volatile bool isbusy = false;
 MeStepper steppers[NUM_AXIS] = {MeStepper(SLOT_1), MeStepper(SLOT_2)};

 void setup()
 {
-    Serial.begin(115200);
+    Serial.begin(250000);
     delay(1000);
-    initTimer();
+    // initTimer();
     for (int i = 0; i < NUM_AXIS; i++)
     {
         steppers[i].setMicroStep(16);
@@ -71,61 +73,103 @@
     Serial.println("opened");
     setPower(0);
     moveTo(0, 0);
-    for (;;)
-    {
-        if (Serial.available())
-        {
-            char c = Serial.read();
-            parseBuffer(c);
-        }
-    }
+    finishCommand();
 }

 void loop()
 {
-}
-void parseBuffer(char c)
-{
-    if (c == '\n')
-    {
-        parseCommand();
-        _sys.buffer = "";
-    }
-    else
-    {
-        _sys.buffer += c;
-    }
-}
-
-void parseCommand()
-{
-    _sys.buffer.toLowerCase();
+    if (Serial.available())
+    {
+        char c = Serial.read();
+        if (c == '\n')
+        {
+            finishCommand();
+            // if (!isbusy)
+            parseCommand(_sys.buffer);
+            _sys.buffer = "";
+            // _sys.bufferIndex = 0;
+            // for (int i = 0; i < 128; i++)
+            // {
+            //     _sys.buffer[i] = 0;
+            // }
+        }
+        else
+        {
+            _sys.buffer += c;
+            // _sys.buffer[_sys.bufferIndex] = c;
+            // _sys.bufferIndex++;
+            // if (_sys.bufferIndex > 128)
+            // {
+            //     _sys.bufferIndex = 0;
+            //     while (Serial.read() != '\n')
+            //     {
+            //         break;
+            //     }
+            //     Serial.println("error!!!!!");
+            // }
+        }
+    }
+    motion();
+}
+void parseCommands()
+{
+    isbusy = true;
+    // cli();
+    // String cmds;
+    // int i = 0;
+    // for (i = 0; i <= _sys.bufferIndex; i++)
+    // {
+    //     cmds += _sys.buffer[i];
+    // }
+    // int counter = 0;
+    // int lastIndex = 0;
+    // for (i = 0; i < cmds.length(); i++)
+    // {
+    //     if (cmds.charAt(i) == ';')
+    //     {
+    //         parseCommand(cmds.substring(lastIndex, i));
+    //         finishCommand();
+    //         lastIndex = i + 1;
+    //     }
+    // }
+    // parseCommand(cmds.substring(lastIndex, i));
+    // sei();
+    isbusy = false;
+    // if (_sys.plannedLength % 2 == 0)
+}
+void parseCommand(String cmd)
+{
+    cmd.toLowerCase();
+    // Serial.println(cmd);
     int cmdId;
-    if (_sys.buffer.length() > 2)
-    {
-        if (hasCommand('g'))
-        {
-            cmdId = getCommand('g');
+    if (cmd.length() > 2)
+    {
+        if (hasCommand(cmd, 'g'))
+        {
+            cmdId = getCommand(cmd, 'g');
             switch (cmdId)
             {
             case 0:
             case 1:
             {
-                if (hasCommand('p') && cmdId == 1)
-                {
-                    setPower(getCommand('p'));
+                if (hasCommand(cmd, 'p') && cmdId == 1)
+                {
+                    setPower(getCommand(cmd, 'p'));
                 }
                 if (cmdId == 0)
                 {
                     setPower(0);
                 }
-                if (hasCommand('f'))
-                {
-                    setSpeed(getCommand('f'));
-                    setAccel(200);
-                }
-                double x = (hasCommand('x') ? getCommand('x') : 0) * PULSES_PER_MM;
-                double y = (hasCommand('y') ? getCommand('y') : 0) * PULSES_PER_MM;
+                if (hasCommand(cmd, 'f'))
+                {
+                    setSpeed(getCommand(cmd, 'f'));
+                }
+                if (hasCommand(cmd, 'a'))
+                {
+                    setAccel(getCommand(cmd, 'a'));
+                }
+                double x = (hasCommand(cmd, 'x') ? fmax(-30, fmin(30, getCommand(cmd, 'x'))) * PULSES_PER_MM : _sys.targetPosition[0]);
+                double y = (hasCommand(cmd, 'y') ? fmax(-30, fmin(30, getCommand(cmd, 'y'))) * PULSES_PER_MM : _sys.targetPosition[1]);
                 if (_sys.isRelative)
                 {
                     x += _sys.targetPosition[0];
@@ -164,15 +208,15 @@
             break;
             }
         }
-        else if (hasCommand('m'))
-        {
-            cmdId = getCommand('m');
+        else if (hasCommand(cmd, 'm'))
+        {
+            cmdId = getCommand(cmd, 'm');
             switch (cmdId)
             {
             case 1:
             {
                 waitingForFinish();
-                if (hasCommand('p') && getCommand('p') == 1)
+                if (hasCommand(cmd, 'p') && getCommand(cmd, 'p') == 1)
                 {
                     for (int i = 0; i < NUM_AXIS; i++)
                     {
@@ -191,9 +235,9 @@
             case 4:
             {
                 waitingForFinish();
-                if (hasCommand('p'))
-                {
-                    firePower(getCommand('p'));
+                if (hasCommand(cmd, 'p'))
+                {
+                    firePower(getCommand(cmd, 'p'));
                 }
                 else
                 {
@@ -204,7 +248,6 @@
             }
         }
     }
-    finishCommand();
 }

 void addMotion(long x, long y, uint8_t power, uint16_t speed, uint16_t acceleration)
@@ -219,14 +262,14 @@
     _points[_sys.plannedIndex].delta[1] = (_points[_sys.plannedIndex].targetCount[1]);
     _points[_sys.plannedIndex].totalCount = _points[_sys.plannedIndex].delta[0] + _points[_sys.plannedIndex].delta[1];
     _points[_sys.plannedIndex].speed = speed;
-    if (_sys.plannedIndex > 1)
+    if (_sys.plannedIndex > 0)
     {
         _points[_sys.plannedIndex - 1].exitSpeed = _points[_sys.plannedIndex].speed;
     }
     _points[_sys.plannedIndex].acceleration = acceleration;
     long dist = sqrt(_points[_sys.plannedIndex].delta[0] * _points[_sys.plannedIndex].delta[0] + _points[_sys.plannedIndex].delta[1] * _points[_sys.plannedIndex].delta[1]) / 2;
     _points[_sys.plannedIndex].accelCount = _points[_sys.plannedIndex].totalCount - min(dist, _sys.defaultAccelCount);
-    _points[_sys.plannedIndex].decelCount = min(dist, _sys.defaultDecelCount);
+    _points[_sys.plannedIndex].decelCount = 3; //min(dist, _sys.defaultDecelCount);
     _points[_sys.plannedIndex].power = power;
     _points[_sys.plannedIndex].err = (_points[_sys.plannedIndex].delta[0] > _points[_sys.plannedIndex].delta[1] ? _points[_sys.plannedIndex].delta[0] : -_points[_sys.plannedIndex].delta[1]) / 2;

@@ -284,22 +327,6 @@
         _sys.plannedLength -= 1;
     }
 }
-void lockTimer()
-{
-    cli();
-}
-void unlockTimer()
-{
-    sei();
-}
-void setRun()
-{
-    _sys.running = true;
-}
-void setStop()
-{
-    _sys.running = false;
-}
 uint8_t isRunningState()
 {
     return _sys.isRunningState;
@@ -346,24 +373,27 @@
     TCCR1A = 0;
     TCCR1B = 0;
     TCNT1 = 0;
-    OCR1A = 2000;
+    OCR1A = 100;
     TCCR1B |= (1 << WGM12);
     TCCR1B |= (1 << CS11);
     TIMSK1 |= (1 << OCIE1A);
     sei();
 }
 int tt = 0;
-ISR(TIMER1_COMPA_vect)
-{
-    if (busy)
-    {
-        return;
-    }
-    sei();
-    busy = true;
-    run();
-    busy = false;
-    cli();
+// ISR(TIMER1_COMPA_vect)
+void motion()
+{
+    if (micros() - _sys.currentTime >= _sys.during)
+    {
+        // if (busy)
+        // {
+        //     return;
+        // }
+        // busy = true;
+        run();
+        // busy = false;
+        _sys.currentTime = micros();
+    }
 }
 void run()
 {
@@ -378,7 +408,7 @@
     {
         return false;
     }
-    firePower(_points[0].power);
+    // firePower(_points[0].power);
     long distX = _points[0].delta[0];
     long distY = _points[0].delta[1];
     if (distX <= 0 && distY <= 0)
@@ -413,56 +443,53 @@
 }
 void nextWait()
 {
-    if (tt % 2 == 0)
-    {
-        if (_points[0].totalCount > _points[0].accelCount)
-        {
-            _sys.isRunningState = MOTION_ACCELETING;
-        }
-        else if (_points[0].totalCount > _points[0].decelCount)
-        {
-            _sys.isRunningState = MOTION_NORMAL;
-        }
-        else
-        {
-            _sys.isRunningState = MOTION_DECELETING;
-        }
-        switch (_sys.isRunningState)
-        {
-        case MOTION_ACCELETING:
-        {
-            if (_sys.currentSpeed < _points[0].speed)
-            {
-                _sys.currentSpeed += _points[0].acceleration;
-                if (_sys.currentSpeed > _points[0].speed)
-                {
-                    _sys.currentSpeed = _points[0].speed;
-                }
-            }
-            break;
-        }
-        case MOTION_DECELETING:
-        {
-            if (_sys.currentSpeed > _points[0].exitSpeed)
-            {
-                _sys.currentSpeed -= _points[0].acceleration;
-                if (_sys.currentSpeed < _points[0].exitSpeed)
-                {
-                    _sys.currentSpeed = _points[0].exitSpeed;
-                }
-            }
-            break;
-        }
-        case MOTION_NORMAL:
-        {
-            // OCR1A;
-            break;
-        }
-        }
-        tt = 0;
-        OCR1A = 1600000 / _sys.currentSpeed - 1;
-    }
-    tt++;
+    if (_points[0].totalCount > _points[0].accelCount)
+    {
+        _sys.isRunningState = MOTION_ACCELETING;
+    }
+    else if (_points[0].totalCount > _points[0].decelCount)
+    {
+        _sys.isRunningState = MOTION_NORMAL;
+    }
+    else
+    {
+        _sys.isRunningState = MOTION_DECELETING;
+    }
+    switch (_sys.isRunningState)
+    {
+    case MOTION_ACCELETING:
+    {
+        if (_sys.currentSpeed < _points[0].speed)
+        {
+            _sys.currentSpeed += _points[0].acceleration;
+            if (_sys.currentSpeed > _points[0].speed)
+            {
+                _sys.currentSpeed = _points[0].speed;
+            }
+        }
+        break;
+    }
+    case MOTION_DECELETING:
+    {
+        if (_sys.currentSpeed > _points[0].exitSpeed)
+        {
+            _sys.currentSpeed -= _points[0].acceleration;
+            if (_sys.currentSpeed < _points[0].exitSpeed)
+            {
+                _sys.currentSpeed = _points[0].exitSpeed;
+            }
+        }
+        break;
+    }
+    case MOTION_NORMAL:
+    {
+        // OCR1A;
+        break;
+    }
+    }
+    tt = 0;
+    _sys.during = 1600000 / _sys.currentSpeed - 1;
+    _sys.during = _sys.during > 10000 ? 10000 : (_sys.during < 10 ? 10 : _sys.during);
 }
 /**
  * Motion Parse
@@ -497,40 +524,40 @@
     addMotion(x, y, _sys.power, _sys.speed, _sys.acceleration);
 }

-bool hasCommand(char cmd)
+bool hasCommand(String cmd, char cmdId)
 {
     int index = 0;
     char c = 0;
-    while (c != cmd)
-    {
-        if (index >= _sys.buffer.length())
+    while (c != cmdId)
+    {
+        if (index >= cmd.length())
         {
             return false;
         }
         else
         {
-            c = _sys.buffer.charAt(index);
+            c = cmd.charAt(index);
         }
         index++;
     }
     return true;
 }
-double getCommand(char cmd)
-{
-    int index = _sys.buffer.indexOf(cmd);
-    int startIndex = _sys.buffer.indexOf(cmd) + 1;
+double getCommand(String cmd, char cmdId)
+{
+    int index = cmd.indexOf(cmdId);
+    int startIndex = cmd.indexOf(cmdId) + 1;
     char c = 0;
     while (c != ' ')
     {
         index++;
-        if (index >= _sys.buffer.length())
+        if (index >= cmd.length())
         {
             break;
         }
         else
         {
-            c = _sys.buffer.charAt(index);
-        }
-    }
-    return _sys.buffer.substring(startIndex, index).toDouble();
+            c = cmd.charAt(index);
+        }
+    }
+    return cmd.substring(startIndex, index).toDouble();
 }


Update EthernetWebserver.ino

Update EthernetWebserver.ino

Fixes while() loop hang with FireFox for Windows, if the client connects and never sends data.

--- hardware/lm4f/libraries/Ethernet/examples/EthernetWebserver/EthernetWebserver.ino
+++ hardware/lm4f/libraries/Ethernet/examples/EthernetWebserver/EthernetWebserver.ino
@@ -9,12 +9,12 @@

  Circuit:
  * WiFi BoosterPack
-
+
  Created: October 16, 2013 by Robert Wessels (http://energia.nu)
  Derived from example Sketch by Hans Scharler (http://www.iamshadowlord.com)

  */
-
+
 #include "Ethernet.h"
 // Prototypes
 void printConfig();
@@ -25,14 +25,17 @@
 EthernetServer server(80);
 int statusConfig = 0;

+boolean newConnection = true;     // flag for new connections
+unsigned long connectionActiveTimer;  // will hold the connection start time
+
 void setup() {
   Serial.begin(115200);
-
+
   pinMode(D1_LED, OUTPUT);
   pinMode(D2_LED, OUTPUT);
   pinMode(PUSH1, INPUT_PULLUP); // released = HIGH, pressed = LOW
   pinMode(PUSH2, INPUT_PULLUP);
-
+
   Serial.println("Connecting to Ethernet....");
   IPAddress ip = IPAddress(146,252,242,129);
   IPAddress dns = IPAddress(146,252,242,12);
@@ -40,7 +43,7 @@
   IPAddress mask = IPAddress(255,255,255,0);

   Ethernet.begin(0);
-//  Ethernet.begin(0, ip, dns, gw);
+  //  Ethernet.begin(0, ip, dns, gw);

   server.begin();

@@ -51,16 +54,26 @@

 void loop() {
   client = server.available();
-
+
   if (client) {                             // if you get a client,
     Serial.print("new client on port ");           // print a message out the serial port
     Serial.println(client.port());
     String currentLine = "";                // make a String to hold incoming data from the client
-    while (client.connected()) {            // loop while the client's connected
+
+    while (client.connected()) {       // loop while the client's connected
+      if (newConnection){                 // it's a new connection, so
+        connectionActiveTimer = millis(); // log when the connection started
+        newConnection = false;          // not a new connection anymore
+      }
+      if (!newConnection && connectionActiveTimer + 1000 < millis()){
+        // if this while loop is still active 1000ms after a web client connected, something is wrong
+        break;  // leave the while loop, something bad happened
+      }
+

       if (client.available()) {             // if there's bytes to read from the client,
         char c = client.read();             // read a byte, then
-                                            // This lockup is because the recv function is blocking.
+        // This lockup is because the recv function is blocking.
         Serial.print(c);
         if (c == '\n') {                    // if the byte is a newline character
           // if the current line is blank, you got two newline characters in a row.
@@ -88,10 +101,22 @@
           printIndex();
         }
         // Check to see if the client request was "GET /H" or "GET /L":
-        if (currentLine.endsWith("GET /LED1_H")) {digitalWrite(D1_LED, HIGH);printConfig();}
-        if (currentLine.endsWith("GET /LED1_L")) {digitalWrite(D1_LED, LOW);printConfig();}
-        if (currentLine.endsWith("GET /LED2_H")) {digitalWrite(D2_LED, HIGH);printConfig();}
-        if (currentLine.endsWith("GET /LED2_L")) {digitalWrite(D2_LED, LOW);printConfig();}
+        if (currentLine.endsWith("GET /LED1_H")) {
+          digitalWrite(D1_LED, HIGH);
+          printConfig();
+        }
+        if (currentLine.endsWith("GET /LED1_L")) {
+          digitalWrite(D1_LED, LOW);
+          printConfig();
+        }
+        if (currentLine.endsWith("GET /LED2_H")) {
+          digitalWrite(D2_LED, HIGH);
+          printConfig();
+        }
+        if (currentLine.endsWith("GET /LED2_L")) {
+          digitalWrite(D2_LED, LOW);
+          printConfig();
+        }
       }
     }
     // close the connection:
@@ -104,24 +129,24 @@
 {
   // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
   // and a content-type so the client knows what's coming, then a blank line:
-//  Serial.println("Index");
+  //  Serial.println("Index");
   client.println("HTTP/1.1 200 OK");
-
+
   client.println("Content-type:text/html");
   client.println();
   client.println("<title>Energia Ethernet Web Server</title>");
   client.println("
Welcome To Ethernet Web Server
");
   client.println("

");
   client.println("
	");
-
-
+
+
   client.println("
The Ethernet Web Server provides the");
   client.println("capability to remotely read and write GPIOs ");
   client.println("on/off.

");
   client.println("
Click here ");
   client.println("to check status and configure the board
");
   client.println("

");
-
+
   client.println();

 }
@@ -135,7 +160,7 @@
   client.println();
   client.println("<title>Energia Ethernet Web Server</title>");
   client.println("
Welcome to the Ethernet Web Server
");
-
+
   // the content of the HTTP response follows the header:
   // Added: nicer buttons
   client.print("LED 1<button onclick=\"location.href='/LED1_H'\">HIGH</button>");
@@ -149,7 +174,7 @@
   client.println("PUSH2 ");
   if(digitalRead(PUSH2))client.print("is HIGH
");
   else client.print("is LOW
");
-
+
   client.println("refresh
");
   client.println("home
");
   client.println("");
@@ -163,15 +188,15 @@
     // get the new byte:
     char inChar = (char)Serial.read();
     switch(inChar) {
-      case 'h':
-        printHelp();
-        break;
-      case 'i':
-        printEthernetData();
-        break;
-      default:
-        Serial.println();
-        Serial.println("Invalid menu option");
+    case 'h':
+      printHelp();
+      break;
+    case 'i':
+      printEthernetData();
+      break;
+    default:
+      Serial.println();
+      Serial.println("Invalid menu option");
     }
   }
 }
@@ -186,13 +211,13 @@
 }

 void printHex(int num, int precision) {
-      char tmp[16];
-      char format[128];
-
-      sprintf(format, "%%.%dX", precision);
-
-      sprintf(tmp, format, num);
-      Serial.print(tmp);
+  char tmp[16];
+  char format[128];
+
+  sprintf(format, "%%.%dX", precision);
+
+  sprintf(tmp, format, num);
+  Serial.print(tmp);
 }

 void printEthernetData() {
@@ -200,11 +225,11 @@
   Serial.println();
   Serial.println("IP Address Information:");
   IPAddress ip = Ethernet.localIP();
-    Serial.print("IP Address:\t");
+  Serial.print("IP Address:\t");
   Serial.println(ip);
-
+
   // print your MAC address:
-
+
   IPAddress subnet = Ethernet.subnetMask();
   Serial.print("NetMask:\t");
   Serial.println(subnet);
@@ -220,3 +245,8 @@
   Serial.println(dns);

 }
+
+
+
+
+


attempt to fix the omoplate thumb issue on uno

--- src/resource/Arduino/MRLComm.ino
+++ src/resource/Arduino/MRLComm.ino
@@ -16,8 +16,8 @@
 *
 */

-#ifndef MRLComm_h
-#define MRLComm_h
+// #ifndef MRLComm_h
+// #define MRLComm_h

 #include "Servo.h"

@@ -26,19 +26,6 @@

 #include <inttypes.h>

-#if defined(ARDUINO) && ARDUINO >= 100
-#include "Arduino.h"	// for digitalRead, digitalWrite, etc
-#else
-#include "WProgram.h"
-#endif
-
-// Normally Servo.h must be included before Firmata.h (which then includes
-// this file).  If Servo.h wasn't included, this allows the code to still
-// compile, but without support for any Servos.  Hopefully that's what the
-// user intended by not including Servo.h
-#ifndef MAX_SERVOS
-#define MAX_SERVOS 0
-#endif

 // ----------  MRLCOMM FUNCTION INTERFACE BEGIN -----------
 #define MRLCOMM_VERSION				19
@@ -327,27 +314,9 @@
 	bool blinkState;
 };

-#endif
-/*==================== MRLCOMM.H END ====================*/
+// #endif
+/*==================== MRLCOMM.H END ========================*/
 /*==================== MRLCOMM.CPP BEGIN ====================*/
-/**
-*
-* @author GroG (at) myrobotlab.org
-*
-* This file is part of MyRobotLab.
-*
-* Enjoy !
-*
-* MRLComm Library
-* -----------------
-* Purpose: support servos, sensors, analog & digital polling
-* oscope, motors, range sensors, pingdar & steppers.
-*
-* Requirements: MyRobotLab running on a computer & a serial connection
-*
-*/
-
-// FIXED BY MOVING UP #include "Servo.h"
 // FIXME #include <MRLComm.h>

 MRLComm::MRLComm(){


Modified blinkTest sketch to add all 5 LEDs(will be vibrator motors eventually).

--- blink_test/blink_test.ino
+++ blink_test/blink_test.ino
@@ -1,29 +1,22 @@
 bool currentlyReading = false;
-bool finishedReading = false;
-
-//values 1-9 for sensitivity of each pin. PWM
-int inVal1 = 0; // pin 9
-int inVal2 = 0; // pin 10
-int inVal3 = 0; // pin 11
-int inVal4 = 0; // pin 3
-int inVal5 = 0; // pin 5

 int result = 0;
 int result2 = 0;

-int ledPin = 9;
-int ledPin2 = 6;
-int ledPin3 = 3;
+int ledPin1 = 11;
+int ledPin2 = 10;
+int ledPin3 = 9;
+int ledPin4 = 6;
+int ledPin5 = 3;
 int val = 0;
-int pins[3] = {9, 6, 3};
-int vals[3];
+int vals[5];

 int current = 0;
 void setup() {

     Serial.begin(9600);
-    pinMode(ledPin, OUTPUT);
+    pinMode(ledPin1, OUTPUT);

 }
@@ -34,19 +27,17 @@
         val = Serial.read();
         if(val == '>'){
             currentlyReading = true;
-            Serial.println("Reading engaged");
         }
-
         if(val == ','){
              current++;
-         }
-         if(val == ':'){
-           // currentlyReading = false;
-         //   Serial.println("Reading disengaged");
-           current = 0;
+        }
+        if(val == ':'){
+             current = 0;
         }
         if(currentlyReading == true){
-
+            if(val == '0'){
+                vals[current] = 0;
+            }
             if(val == '1'){
                 vals[current] = map(1, 1, 9, 1, 255);
             }
@@ -75,9 +66,11 @@
                 vals[current] = map(9, 1, 9, 1, 255);
             }

-             analogWrite(ledPin, vals[0]);
+             analogWrite(ledPin1, vals[0]);
              analogWrite(ledPin2, vals[1]);
              analogWrite(ledPin3, vals[2]);
+             analogWrite(ledPin4, vals[3]);
+             analogWrite(ledPin5, vals[4]);
       }

     }


Adding PID logic

Adding PID logic

--- syde362_pid.ino
+++ syde362_pid.ino
@@ -3,18 +3,33 @@
  */
 #include <Wire.h>
 #include "Adafruit_VCNL4010.h"
+#include <PID_v1.h>

 Adafruit_VCNL4010 vcnl;

-static int FIDELITY = 100;
+//Define Variables we'll be connecting to
+double Setpoint, Input, Output;
+
+//Specify the links and initial tuning parameters
+double Kp = 32609.0;
+double Ki = 34517.0;
+double Kd = 7086;
+
+PID pid(&Input, &Output, &Setpoint, Kp,Ki,Kd, DIRECT);
+
+static double FIDELITY = 157.35;

 static int FET_ONE = 3; // The black magnet
-static int FET_TWO = 6; // The yellow magnet
+static int FET_TWO = 5; // The yellow magnet

 double HIGH_PROX_VAL = 0.0;
 double LOW_PROX_VAL  = 0.0;

+int WindowSize = 5000;
+unsigned long windowStartTime;
+
 void setupProximitySensor(double &high_val, double &low_val);
+void setupPID();
 double pollProximity();
 void pwm(int pin, double high, double low);

@@ -31,8 +46,12 @@
     while(1);
   }
   Serial.println("############## SENSOR CALIBRATION ###############");
-  // setupProximitySensor(HIGH_PROX_VAL, LOW_PROX_VAL);
+  setupProximitySensor(HIGH_PROX_VAL, LOW_PROX_VAL);
   Serial.println("############ DONE SENSOR CALIBRATION ############");
+
+  Serial.println("################### SET UP PID ##################");
+  setupPID();
+  Serial.println("################### DONE PID ####################");

   // Set up the fets and set them both low.
   pinMode(FET_ONE, OUTPUT);
@@ -41,51 +60,30 @@
   digitalWrite(FET_ONE, LOW);
   digitalWrite(FET_TWO, LOW);
   Serial.println("############## BEGINNING MAIN LOOP ##############");
-  for(int i = 1; i < 6; ++i){
-    Serial.println(i);
+  for(int i = 5; i > 0; --i){
+    Serial.print(i); Serial.print("\r");
     delay(1000);
   }
 }

 void loop() {
-  int delay_ms = 2500;
-  int ledPin = FET_ONE;
-  // fade in from min to max in increments of 5 points:
-  for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
-    // sets the value (range from 0 to 255):
-    analogWrite(ledPin, fadeValue);
-    // wait for 30 milliseconds to see the dimming effect
-    delay(30);
+
+  double yellow_dist = pollProximity();
+  yellow_dist /= 10000;
+  double black_dist = -yellow_dist;
+  if(yellow_dist > 0.003){
+    Input = yellow_dist;
+  }else if(black_dist > 0.003){
+    Input = black_dist;
+  }else{
+    Input = 0.0;
   }
-
-  // fade out from max to min in increments of 5 points:
-  for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
-    // sets the value (range from 0 to 255):
-    analogWrite(ledPin, fadeValue);
-    // wait for 30 milliseconds to see the dimming effect
-    delay(30);
-  }
-
-  /*
-
-  Serial.println("FET_ONE IS HIGH AF");
-  digitalWrite(FET_ONE, HIGH);
-  delay(delay_ms);
-  digitalWrite(FET_ONE, LOW);
-  Serial.println("FET_ONE IS LOWWWWW");
-  //Serial.print("FET_ONE: Proximity to plate: \t"); Serial.print(pollProximity()); Serial.print("\t\t\t\r");
-  delay(delay_ms);
-  */
-  /*
-  Serial.println("FET_TWO IS HIGH AF");
-  digitalWrite(FET_TWO, HIGH);
-  delay(delay_ms);
-  digitalWrite(FET_TWO, LOW);
-  Serial.println("FET_TWO IS LOWWWWW");
-  Serial.print("FET_TWO: Proximity to plate: \t"); Serial.print(pollProximity()); Serial.print("\t\t\t\r");
-  delay(delay_ms);
-  */
+  pid.Compute();
+  Serial.print("Output of PID: "); Serial.println(Output, DEC);
+  Serial.print("Input to PID: "); Serial.println(Input, DEC);
+  Serial.print("Ylw: "); Serial.print(yellow_dist, DEC); Serial.print("\tBlk: "); Serial.println(black_dist, DEC);
+  delay(1000);
 }

 /*
@@ -97,7 +95,7 @@
  * e.g. [-100, 100]
  */
 double pollProximity(){
-  return map(vcnl.readProximity(), HIGH_PROX_VAL, LOW_PROX_VAL, -FIDELITY, FIDELITY);
+  return map(vcnl.readProximity(), HIGH_PROX_VAL, LOW_PROX_VAL, FIDELITY, -FIDELITY) + (FIDELITY / 2.0);
 }

 /*
@@ -149,3 +147,14 @@
   Serial.print("I'll use the high value: "); Serial.println(high_val);
   Serial.print("and the low value: ");       Serial.println(low_val);
 }
+
+void setupPID(){
+  //initialize the variables we're linked to
+  Setpoint = 0;
+
+  //tell the PID to range between 0 and the full window size
+  pid.SetOutputLimits(0, 1);
+
+  //turn the PID on
+  pid.SetMode(AUTOMATIC);
+}


minor change 2

minor change 2

--- proj/hypercube/HCS/HCS.ino
+++ proj/hypercube/HCS/HCS.ino
@@ -240,41 +240,41 @@

   // Add the random strobe to this list of animations since we aren't going to use it
   // for the overlays
-  switch (iAnimCounter) {
-    case 0:
-      chase_straight(INNER, false);
-      break;
-    case 1:
-      shell_wrap(INNER, false, 0);
-      break;
-    case 2:
-      chase_mod(INNER, 0, false);
-      break;
-    case 3:
-      chase_spiral_static(INNER, 16, false);
-      break;
-    case 4:
-      shell_wrap(INNER, false, 1);
-      break;
-    case 5:
-      chase_mod(INNER, 1, false);
-      break;
-    case 6:
-      chase_spiral_mod(INNER, false);
-      break;
-    case 7:
-      shell_wrap(INNER, false, 2);
-      break;
-    case 8:
-      chase_mod(INNER, 2, false);
-      break;
-    case 9:
-      shell_wrap(INNER, false, 3);
-      break;
-    case 10:
-      fill_shell(INNER);
-      break;
-  }
+  //switch (iAnimCounter) {
+  //  case 0:
+  //    chase_straight(INNER, false);
+  //    break;
+  //  case 1:
+  //    shell_wrap(INNER, false, 0);
+  //    break;
+  //  case 2:
+  //    chase_mod(INNER, 0, false);
+  //    break;
+  //  case 3:
+  //    chase_spiral_static(INNER, 16, false);
+  //    break;
+  //  case 4:
+  //    shell_wrap(INNER, false, 1);
+  //    break;
+  //  case 5:
+  //    chase_mod(INNER, 1, false);
+  //    break;
+  //  case 6:
+  //    chase_spiral_mod(INNER, false);
+  //    break;
+  //  case 7:
+  //    shell_wrap(INNER, false, 2);
+  //    break;
+  //  case 8:
+  //    chase_mod(INNER, 2, false);
+  //    break;
+  //  case 9:
+  //    shell_wrap(INNER, false, 3);
+  //    break;
+  //  case 10:
+  //    fill_shell(INNER);
+  //    break;
+  //}
   switch (oAnimCounter) {
     case 0:
       chase_straight(OUTER, true);


added missing space to flight mode

added missing space to flight mode

--- ArduCAM_OSD/OSD_Panels.ino
+++ ArduCAM_OSD/OSD_Panels.ino
@@ -1029,8 +1029,8 @@
 	if (osd_mode == 0) mode_str = "manu"; //Manual
 	if (osd_mode == 2) mode_str = "stab"; //Stabilize
 	if (osd_mode == 5) mode_str = "wayp"; //FLY_BY_WIRE_A
-	if (osd_mode == 10) mode_str = "auto"; //AUTO
-	if (osd_mode == 11) mode_str = "rth"; //Return to Launch
+	if (osd_mode == 10) mode_str = "auto"; // this is unknown mode in MP (error)
+	if (osd_mode == 11) mode_str = "rth "; //Return to Launch
 	if (osd_mode == 15) mode_str = "rthh"; //GUIDED
 	osd.printf("%c%s", 0x7f, mode_str);
 	//      osd.printf("%c%i", 0x7f, osd_mode);


added code to flush software serial buffer for 250ms before reading this ensures a fresh sample

--- software/serial_dmm/serial_dmm.ino
+++ software/serial_dmm/serial_dmm.ino
@@ -26,6 +26,15 @@
   void sync()
   {
     start_frame_seen = false;
+
+    // toss anything in the recieve buffer for the next 250ms
+    //   to ensure fresh data
+    unsigned long start = millis();
+    do {
+      while (port->available() > 0){
+        byte bitbucket = port->read();
+      }
+    } while ((millis() - start) < 250);
   }

   bool poll()


Delete CapacitiveSensorSketch.ino

Delete CapacitiveSensorSketch.ino

--- CapacitiveSensorSketch.ino
+++ CapacitiveSensorSketch.ino
@@ -1,65 +0,0 @@
-#include "CapacitiveSensor.h"
-
-/*
- * jack-the-coder's soundSynth 2
- *
- * BASED ON THE FOLLOWING:
- *
- * CapitiveSense Library Demo Sketch
- * Paul Badger 2008
- * Uses a high value resistor e.g. 10M between send pin and receive pin
- * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
- * Receive pin is the sensor pin - try different amounts of foil/metal on this pin
- */
-
-
-CapacitiveSensor cs_7_8 = CapacitiveSensor(7, 8);
-CapacitiveSensor cs_7_9 = CapacitiveSensor(7, 9);
-CapacitiveSensor cs_7_10 = CapacitiveSensor(7, 10);
-CapacitiveSensor cs_7_11 = CapacitiveSensor(7, 11);
-CapacitiveSensor cs_7_12 = CapacitiveSensor(7, 12);
-void setup()
-{
-   cs_7_8.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
-   Serial.begin(9600);
-   pinMode(13, OUTPUT);
-}
-
-void loop()
-{
-    long start = millis();
-      int scale = map(analogRead(0), 0, 1023, 0, 4);
-  int len = analogRead(5) + 50;
-  float t1 = 220;
-  float t2 = 246.94;
-  float t3 = 277.18;
-  float t4 = 293.66;
-  float t5 = 329.63;
-
-  long total0 = cs_7_8.capacitiveSensor(30);
-  long total1 = cs_7_9.capacitiveSensor(30);
-  long total2 = cs_7_10.capacitiveSensor(30);
-  long total3 = cs_7_11.capacitiveSensor(30);
-  long total4 = cs_7_12.capacitiveSensor(30);
-
-    Serial.print(millis() - start);        // check on performance in milliseconds
-    Serial.print("\t");                    // tab character for debug windown spacing
-
-    Serial.print(total0);                  // print sensor output 1
-    Serial.print("\t");
-    Serial.print(total1);                  // print sensor output 2
-    Serial.print("\t");
-    Serial.println(total2);                // print sensor output 3
-
-    delay(10);                             // arbitrary delay to limit data to serial port
-
-
-
-    if (total0 > 200) {
-      Serial.println("KSJSF");
-
-      tone(13, 440);
-      delay(200);
-      noTone(13);
-    }
-}


Switch to generalized animation handling

--- Clock.ino
+++ Clock.ino
@@ -33,7 +33,7 @@

 BackEase ease;

-std::vector<Flash*> flashes;
+std::vector<Animation*> animations;

 uint16_t OuterLED(uint16_t n)
 {
@@ -93,7 +93,7 @@
         if (LEDsEnabled)
         {
             Flash* flash = new Flash(OuterLED(currentDateTime.second()), 1.15, Brightness, 0, 0);
-            flashes.push_back(flash);
+            animations.push_back(flash);
         }

         unsigned long timeSinceLastTick = millis() - lastSecondMillis;
@@ -139,13 +139,13 @@

             if (LEDsEnabled)
             {
-                for(std::vector<Flash*>::iterator it = flashes.begin(); it != flashes.end(); )
+                for(std::vector<Animation*>::iterator it = animations.begin(); it != animations.end(); )
                 {
-                    Flash* flash = *it;
-                    if (!flash->update(time))
+                    Animation* animation = *it;
+                    if (!animation->update(time))
                     {
-                        it = flashes.erase(it);
-                        delete flash;
+                        it = animations.erase(it);
+                        delete animation;
                     }
                     else
                     {


Dotted the i's

Dotted the i's

--- particleFiles/Particle.ino
+++ particleFiles/Particle.ino
@@ -12,7 +12,6 @@
 double r1 = 0, g1 = 0, b1 = 0, r2 = 0, b2 = 0, g2 = 0, dim = 0;

 String print, t;
-
 bool nightTime = false, party = false, userColor = false, strobe = false, rain = false, initParty = false, initRain = true, rainOff = false, initNight = true, nightOff = false;

 Timer timer(7200000, LEDTimeOut);
@@ -322,4 +321,4 @@
     {

     }
-}+}


Adds some explanatory comments

Adds some explanatory comments

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_waffle/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_waffle/turtlebot3_core/turtlebot3_core.ino
@@ -224,6 +224,14 @@
 void loop()
 {
   receiveRemoteControlData();
+  /*
+   * the update_time() call below
+   * reduces the amount of calls to
+   * nh.now(), and allows the returned
+   * time to be interpolated on an
+   * as-needed basis with the ros_now()
+   * function.
+   */
   uint32_t t = millis();
   update_time();
   if ((millis()-tTime[0]) >= (1000 / CONTROL_MOTOR_SPEED_PERIOD))
@@ -268,6 +276,8 @@

   // Call all the callbacks waiting to be called at that point in time
   nh.spinOnce();
+
+  // give the serial link time to process
   delay(10);
 }


refactor > use kReturnFormat defined at the top

--- esp8266_160104_ADsensor.ino
+++ esp8266_160104_ADsensor.ino
@@ -8,24 +8,24 @@

 /*
    Define your SSID and WiFi password at [wifiConfig.h] using [TemplateWifiConfig.h]
-
 */

 /*
- * v0.2 2016 Dec. 04
- *   - add AD input
- * v0.1 2016 Dec. 04
- *    can echo back
- *    - add loop()
- *    - add setup()
- *    - add Serial_setup()
- *    - add WiFi_setup()
- *    - add wifiConfig.h
- */
+   v0.2 2016 Dec. 04
+     - add AD input
+   v0.1 2016 Dec. 04
+      can echo back
+      - add loop()
+      - add setup()
+      - add Serial_setup()
+      - add WiFi_setup()
+      - add wifiConfig.h
+*/

 static WiFiUDP wifiUdp;

 static char receivedBuffer[255];
+static const char *kReturnFormat = "AD,%d\n"; // e.g. "AD,1023\n"

 static void WiFi_setup()
 {
@@ -61,7 +61,7 @@
 static void handleUdpReceive(uint ADvalue)
 {
   char retBuf[20];
-
+
   int rcvdSize = wifiUdp.parsePacket();
   if (rcvdSize == 0) {
     delay(100);
@@ -77,12 +77,8 @@
   receivedBuffer[len] = 0x00;

   wifiUdp.beginPacket( wifiUdp.remoteIP(), wifiUdp.remotePort() );
-#if 0
-  wifiUdp.write(receivedBuffer);
-#else
-  sprintf(retBuf, "AD=%d", ADvalue);
+  sprintf(retBuf, kReturnFormat, ADvalue);
   wifiUdp.write(retBuf);
-#endif
   wifiUdp.endPacket();
 }


Set the initMode on every single tap to determine what state it should be on restart.

--- src/homie-sonoff-touch.ino
+++ src/homie-sonoff-touch.ino
@@ -3,7 +3,7 @@
 #include <EEPROM.h>

 #define FW_NAME "homie-sonoff-touch"
-#define FW_VERSION "2.0.7"
+#define FW_VERSION "2.0.7-persistent"

 // Disable this if you don't want the relay to turn on with any single tap event

@@ -217,9 +217,11 @@
   //digitalWrite(PIN_RELAY, LOW);
   if (EEpromData.initialState)
   {
-    digitalWrite(PIN_RELAY,1);
-  } else {
-    digitalWrite(PIN_RELAY,0);
+    Serial.println("Startup: Relay On");
+    digitalWrite(PIN_RELAY,HIGH);
+  } else {
+    Serial.println("Startup: Relay Off");
+    digitalWrite(PIN_RELAY,LOW);
     EEpromData.initialState=0;
   }

@@ -296,6 +298,9 @@
         relayNode.setProperty("relayState").send("ON");
         buttonNode.setProperty("event").setRetained(false).send("SINGLE");
       }
+      // Read the new state, and use it to set the initial startup state
+      String PIN_STATE = String(digitalRead(PIN_RELAY));
+      relayNode.setProperty("relayInitMode").send(PIN_STATE);
       Serial.println("SINGLE click");
     }


goes in rgb branch

goes in rgb branch

--- espLightServerRGB.ino
+++ espLightServerRGB.ino
@@ -1,359 +0,0 @@
-#include <ESP8266WiFi.h>
-#include <DNSServer.h>
-#include <ESP8266WebServer.h>
-#include <WiFiManager.h>
-#include <ESP8266HTTPClient.h>
-#include <Ticker.h>
-#include <ESP8266mDNS.h>
-#include <OneWire.h>
-#include <DallasTemperature.h>
-#define ONE_WIRE_BUS D4
-String resetpass = "YourResetPassword"; // password to reset wifimanager when allready connected
-const String thingkey = "YOURTHINGSPEKKEY"; //your thingspeak API key
-String dernadd = "Fraichement booté"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
-int pinRouge = D1; // pin for red leds
-int pinVerte = D7; // pin for green leds
-int pinBleu = D5; // pin for blue leds
-const long interval = 60000; // interval in ms for sending temperature data to thingspeak
-const String liens = "Acceuil - Température - Version - Reset - Temp stats\n"; // html/links shown at bottom of pages
-ESP8266WebServer server(80);
-String derncoul;
-long r;
-long g;
-long b;
-int rouge = 0;
-int vert = 0;
-int bleu = 0;
-unsigned long previousMillis = 0;
-OneWire oneWire(ONE_WIRE_BUS);
-DallasTemperature sensors(&oneWire);
-int roulepastusuite = 0;
-Ticker tiqueFade;
-
-const String css = "\n";
-
-void fadeRGB() {
-  if (r == rouge && g == vert && b == bleu) {
-    tiqueFade.detach();
-//    Serial.println("Stopping");
-  }
-  for (int i = 0; i <= 2; i++) {
-    int couleur;
-    int tc;
-    int pinouche;
-    switch (i) {
-      case 0:
-        pinouche = pinRouge;
-        tc = r;
-        couleur = rouge;
-        break;
-      case 1:
-        pinouche = pinVerte;
-        tc = g;
-        couleur = vert;
-        break;
-      case 2:
-        pinouche = pinBleu;
-        tc = b;
-        couleur = bleu;
-        break;
-    }
-    if (couleur < tc) {
-      couleur++;
-      analogWrite(pinouche, couleur);
-    } else if (couleur > tc) {
-      couleur--;
-      analogWrite(pinouche, couleur);
-    }
-    switch (i) {
-      case 0:
-        rouge = couleur;
-        break;
-      case 1:
-        vert = couleur;
-        break;
-      case 2:
-        bleu = couleur;
-        break;
-    }
-  }
-}
-
-void handleRoot() {
-  String addy = server.client().remoteIP().toString();
-  //  Serial.println("");
-  //  Serial.println(addy);
-  String testteu = server.arg("COULEUR");
-  //  Serial.println(testteu);
-  if (testteu != 0) {
-    derncoul = testteu;
-    long number = strtol( &testteu[1], NULL, 16);
-    // Split them up into r, g, b values
-    r = number >> 16;
-    g = number >> 8 & 0xFF;
-    b = number & 0xFF;
-    if (r != rouge) {
-      //      Serial.print("Rouge = ");
-      //      Serial.println(r);
-      tiqueFade.attach_ms(40, fadeRGB);
-      dernadd = addy;
-      delay(5);
-    }
-    if (g != vert) {
-      //      Serial.print("Vert = ");
-      //      Serial.println(g);
-      tiqueFade.attach_ms(40, fadeRGB);
-      dernadd = addy;
-      delay(5);
-    }
-    if (b != bleu) {
-      //      Serial.print("Bleu = ");
-      //      Serial.println(b);
-      tiqueFade.attach_ms(40, fadeRGB);
-      dernadd = addy;
-    }
-  }
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  if (server.args()) { // recharge la page / pour permetre d'appuyer refresh sans re-poster la form
-    contenu += "<meta http-equiv=\"refresh\" content=\"0;url=/\" />\n";
-  }
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "
\n"
-             "<form action=\"/\" method=\"post\">\n"
-             "
Change la couleur de mon bureau:
"
-             "<input type=\"color\" name=\"COULEUR\" value=\"" + derncoul + "\">
\n"
-             "<input type=\"submit\" class=\"button1\" value=\"Changer\">\n"
-             "</form>\n
Dernier IP à avoir changé la couleur : ";
-  contenu += dernadd;
-  contenu += "
\n";
-  contenu += liens;
-  contenu += "
\n";
-  server.send(200, "text/html", contenu);
-}
-
-void handleReset() {
-  int ouireset = 0;
-  String addy = server.client().remoteIP().toString();
-  //  Serial.println("");
-  //  Serial.println(addy);
-  //  Serial.println("!!! RESET PAGE !!!");
-  String testteu = server.arg("RESET");
-  String passme = server.arg("PASSME");
-  if (testteu == "OUI") {
-    if (passme == resetpass) {
-      ouireset = 1;
-    } else {
-      ouireset = 2;
-    }
-  }
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere se RESET</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "
\n";
-  if (!ouireset) {
-    contenu += "<form action=\"/reset\" method=\"post\">\n"
-               "
Tu veux resetter le wifi network pour reconfigurer ?
"
-               "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
-               "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
-               "</form>\n";
-  } else if (ouireset != 1) {
-    contenu += "<form action=\"/reset\" method=\"post\">\n"
-               "
Tu veux resetter le wifi network pour reconfigurer ?
"
-               "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
-               "
!!! MAUVAIS PASSWORD !!!

\n"
-               "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
-               "</form>\n";
-    //    Serial.print("BAD PASSWORD : ");
-    //    Serial.println(passme);
-  } else if (ouireset == 1) {
-    contenu += "
Reset Dans 10 Secondes
\n";
-  }
-  contenu += "
Dernier IP à avoir changé la couleur :";
-  contenu += dernadd;
-  contenu += "\n
";
-  contenu += liens;
-  contenu += "\n

\n";
-  server.send(200, "text/html", contenu);
-  if (ouireset == 1) {
-    //    Serial.println("Reset dans 10 secondes");
-    delay(10000);
-    WiFiManager wifiManager;
-    wifiManager.resetSettings();
-    ESP.restart();
-  }
-}
-
-void handleNotFound() {
-  String addy = server.client().remoteIP().toString();
-  //  Serial.println("");
-  //  Serial.println(addy);
-  String htmlmessage = "<!DOCTYPE html>\n\n\n";
-  htmlmessage += "<meta charset=\"UTF-8\" />\n<title>404 Not found</title>\n"
-                 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  htmlmessage += css;
-  htmlmessage += "\n\n"
-                 "
\n";
-  htmlmessage += "
404 File Not Found

\n";
-  htmlmessage += "URI: ";
-  htmlmessage += server.uri();
-  htmlmessage += "
\nMethod: ";
-  htmlmessage += (server.method() == HTTP_GET) ? "GET" : "POST";
-  htmlmessage += "
\nArguments: ";
-  htmlmessage += server.args();
-  htmlmessage += "
\n";
-  for (uint8_t i = 0; i < server.args(); i++) {
-    htmlmessage += " " + server.argName(i) + ": " + server.arg(i) + "
\n";
-  }
-  htmlmessage += "
\n";
-  htmlmessage += liens;
-  htmlmessage += "
\n
\n";
-  server.send(404, "text/html", htmlmessage);
-  String message = "404 File Not Found\n";
-  message += "URI: ";
-  message += server.uri();
-  message += "\nMethod: ";
-  message += (server.method() == HTTP_GET) ? "GET" : "POST";
-  message += "\nArguments: ";
-  message += server.args();
-  message += "\n";
-  for (uint8_t i = 0; i < server.args(); i++) {
-    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
-  }
-  //  Serial.print(message);
-}
-
-void updateTemp(String tempe) {
-  if (tempe != "-127.00") {
-    //    Serial.print("Sending temp : ");
-    //    Serial.println(tempe);
-    HTTPClient http;
-    String webadd = "http://api.thingspeak.com/update?key=";
-    webadd += thingkey;
-    webadd += "&field1=";
-    webadd += tempe;
-    http.begin(webadd);
-    int httpCode = http.GET();//Send the request
-    if (httpCode > 0) { //Check the returning code
-      String payload = http.getString();   //Get the request response payload
-      //      Serial.println(payload);                     //Print the response payload
-    }
-    http.end();   //Close connection
-  }
-}
-
-void latemp() {
-  sensors.requestTemperatures();
-  float thetemp = sensors.getTempCByIndex(0);// Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
-  char buffer[10];
-  String tempF = dtostrf(thetemp, 5, 2, buffer);
-  updateTemp(tempF);
-}
-
-void handleTemp() {
-  sensors.requestTemperatures();
-  float latemp = sensors.getTempCByIndex(0);
-  while (latemp == -127.00) {
-    sensors.requestTemperatures();
-    latemp = sensors.getTempCByIndex(0);
-  }
-  String addy = server.client().remoteIP().toString();
-  //  Serial.println("");
-  //  Serial.println(addy);
-  //  Serial.print("Temperature : ");
-  //  Serial.println(latemp);
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Quel chaleur</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "
\n";
-  contenu += "<form action=\"/\" method=\"get\">\n"
-             "
Voici la temperature
"
-             "
";
-  contenu += latemp;
-  contenu += "°C

\n<input type=\"submit\" class=\"button1\" value=\"Go Home\">\n"
-             "</form>\n"
-             "
Dernier IP à avoir changé la couleur :";
-  contenu += dernadd;
-  contenu += "\n
";
-  contenu += liens;
-  contenu += "\n

\n";
-  server.send(200, "text/html", contenu);
-}
-
-void setup() {
-  analogWriteRange(255);
-  //  analogWriteFreq(500);
-  //  Serial.begin(9600);
-  pinMode(pinRouge, OUTPUT);
-  pinMode(pinVerte, OUTPUT);
-  pinMode(pinBleu, OUTPUT);
-  digitalWrite(pinRouge, LOW);
-  digitalWrite(pinBleu, LOW);
-  digitalWrite(pinVerte, LOW);
-  WiFiManager wifiManager;
-  wifiManager.autoConnect();
-  delay(500);
-  if (!MDNS.begin("esp8266")) {
-    //Serial.println("Error setting up MDNS responder!");
-    while (1) {
-      delay(1000);
-    }
-  }
-  server.on("/", handleRoot);
-  server.on("/reset", handleReset);
-  server.on("/temp", handleTemp);
-  server.on("/version", []() {
-    String addy = server.client().remoteIP().toString();
-    //Serial.println("");
-    //Serial.println(addy);
-    //Serial.println("Version request");
-    server.send(200, "text/html", "V1.7, Steve Olmstead sansillusion@gmail.com\n\n

"
-                "Added fader function\nRemoved connection watchdog (better have good signal)\n
"
-                "Removed mDns (did not work anyway)\n\n

"
-                "Added smoother fading\n\n

"
-                "Added AutoConect WifiManager !\n\n

"
-                "Added basic last IP logging\n
"
-                "Added /reset page to reset wifiManager connection settings\n\n

"
-                "Added /temp (temperature sensor read of ky-001)\n\n

"
-                "Added thingspeak support to send temperature each minute
\n\n
"
-                "Major rewrite for RGB led trip usin mosfet
\n"
-                "Removed serial to free resources for software pwm (still flikers but less than before)
\n" + liens);
-  });
-  server.onNotFound(handleNotFound);
-  server.begin();
-  //Serial.println("HTTP server started");
-  MDNS.addService("http", "tcp", 80);
-  sensors.begin();
-}
-
-void loop() {
-  server.handleClient();
-  unsigned long currentMillis = millis();
-  if (currentMillis - previousMillis >= interval) {
-    previousMillis = currentMillis;
-    latemp();
-  }
-}
-


Reduced RAM usage to get rid of compile time warning

--- fed-arduino/fed-arduino.ino
+++ fed-arduino/fed-arduino.ino
@@ -21,33 +21,17 @@
 SoftwareSerial LEDserial = SoftwareSerial(rxPin, txPin);

-///
-// any pins can be used
-//#define SCK 13
-//#define MOSI 11
-//#define SS 4
-
-//Adafruit_SharpMem display(SCK, MOSI, SS);
-
-//#define BLACK 0
-//#define WHITE 1
-
-///
-
-//int pokeCount = 0;
-
 long previousMillis = 0;
 long startTime = 0;
 long timeElapsed = 0;
-long day2 = 86400000; // 86400000 milliseconds in a day
-long hour2 = 3600000; // 3600000 milliseconds in an hour
-long minute2 = 60000; // 60000 milliseconds in a minute
-long second2 =  1000; // 1000 milliseconds in a second
+const long day2 = 86400000; // 86400000 milliseconds in a day
+const long hour2 = 3600000; // 3600000 milliseconds in an hour
+const long minute2 = 60000; // 60000 milliseconds in a minute
+const long second2 =  1000; // 1000 milliseconds in a second

 const int CS_pin = 10;
 RTC_DS1307 RTC;    // refer to the real-time clock on the SD shield
-String year, month, day, hour, minute, second, date, time;
-String time2, time3;
+String time;
 File dataFile;

 const int MOTOR_INPUT1_PIN = 7 ;
@@ -70,6 +54,7 @@
 Stepper motor(MOTOR_STEPS_PER_REVOLUTION, MOTOR_INPUT1_PIN, MOTOR_INPUT2_PIN, MOTOR_INPUT3_PIN, MOTOR_INPUT4_PIN);

 int logData() {
+  String year, month, day, hour, minute, second;
   DateTime datetime = RTC.now();
   year = String(datetime.year(), DEC);
   month = String(datetime.month(), DEC);
@@ -88,7 +73,7 @@

   dataFile = SD.open("PELLETJuly.csv", FILE_WRITE);
   if (dataFile) {
-    Serial.println("File successfully written...");
+    Serial.println(F("File successfully written..."));
     Serial.println(time);
     dataFile.print(time);
     dataFile.print(",");
@@ -120,7 +105,7 @@
 void setup()
 {
   Serial.begin(9600);
-  Serial.println("Starting up...");
+  Serial.println(F("Starting up..."));

   LEDserial.begin(9600); //Talk to the Serial7Segment at 9600 bps

@@ -152,7 +137,7 @@
   RTC.begin();

   if (! RTC.isrunning()) {
-    Serial.println("RTC is NOT running!");
+    Serial.println(F("RTC is NOT running!"));
     // following line sets the RTC to the date & time this sketch was compiled
     RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
     // This line sets the RTC with an explicit date & time, for example to set
@@ -161,23 +146,23 @@
   }

   if (!SD.begin(CS_pin)) {
-    Serial.println("Card failed, or not present");
+    Serial.println(F("Card failed, or not present"));
     // don't do anything more:
     while (1) ;
   }

-  Serial.println("card initialized.");
+  Serial.println(F("Card initialized."));

   dataFile = SD.open("PELLETJuly.csv", FILE_WRITE);
   if (! dataFile) {
-    Serial.println("error opening datalog.txt");
+    Serial.println(F("Error opening datalog.txt"));
     // Wait forever since we cant write data
     while (1) ;
   }

   else {
     dataFile.print(time);
-    dataFile.println("Time,Pellet Count,Pellet Drop Delay");
+    dataFile.println(F("Time,Pellet Count,Pellet Drop Delay"));
     dataFile.close();
   }

@@ -205,30 +190,27 @@
     digitalWrite(MOTOR_INPUT3_PIN, HIGH);
     digitalWrite(MOTOR_INPUT4_PIN, HIGH);
     startTime = millis();
-    Serial.print("Time Elapsed Check: ");
+    Serial.print(F("Time Elapsed Check: "));
     Serial.println(timeElapsed);
     timecounter(timeElapsed);
     logData();
     pelletCount ++;
-    Serial.println("It did work");
+    Serial.println(F("It did work"));
     LEDserial.print("v"); // this is the reset display command
     delay(5); // allow a very short delay for display response
     LEDserial.print(pelletCount);
-    //    Serial.println("It did work again");
     lastState = PIState;

   }
   else if (PIState == 1) {
-    //Serial.print("Beam Broken: ");
-    //Serial.println("No");
-    Serial.println("Turning motor...");
+    Serial.println(F("Turning motor..."));
     motor.step(-steps / 2);
     motor.step(steps);
     lastState = PIState;
   }

   else if (PIState == 0 & PIState != lastState) {
-    Serial.print("Time Elapsed Since Last Pellet: ");
+    Serial.print(F("Time Elapsed Since Last Pellet: "));
     timeElapsed = millis() - startTime;
     Serial.println(timeElapsed);
     lastState = PIState;
@@ -236,8 +218,6 @@
   }

   else  {
-    //Serial.print("Beam Broken: ");
-    //Serial.println("Yes");
     lastState = PIState;
     digitalWrite(MOTOR_INPUT1_PIN, LOW);
     digitalWrite(MOTOR_INPUT2_PIN, LOW);
@@ -245,7 +225,6 @@
     digitalWrite(MOTOR_INPUT4_PIN, LOW);
     setMotorToSleep();
     enterSleep();
-
   }

@@ -269,19 +248,11 @@
   int mil = ((((timeNow % day2) % hour2) % minute2) % second2);

   // digital clock display of current time
-  //Serial.print(days,DEC);
-  //time2 = '';
-  //time3 = 'Time';
   printDigits(hours); Serial.print(":");
-  //time3 += time2; time3 += ":";
   printDigits(minutes); Serial.print(":");
-  //time3 += time2; time3 += ":";
   printDigits(seconds); Serial.print(":");
-  //time3 += time2; time3 += ":";
   printDigits(mil);
-  //time3 += time2;
   Serial.println();
-  Serial.println(time3);

 }


Some timing adjustments

Some timing adjustments

--- craniosacral/craniosacral.ino
+++ craniosacral/craniosacral.ino
@@ -10,27 +10,28 @@

 // 2 - 2.5 cycles per minute
 unsigned long midtide_last = 0;
-unsigned long midtide_interval = 135000;
+unsigned long midtide_interval = 150; //135000;
 byte midtide_direction = 1;
-byte midtide_pos = 0;
+byte midtide_pos = 45;

 // 100 secs per cycle
 unsigned long longtide_last = 0;
-unsigned long longtide_interval = 100000;
+unsigned long longtide_interval = 500;
 byte longtide_direction = 1;
-byte longtide_pos = 0;
+byte longtide_pos = 45;

 // 8 - 14 cycles per minute
 unsigned long cri_last = 0;
-unsigned long cri_interval = 600000;
+unsigned long cri_interval = 26; //600000;
 byte cri_direction = 1;
-byte cri_pos = 0;
+byte cri_pos = 45;

 void setup()
 {
   midtide.attach(4);
   longtide.attach(5);
   cri.attach(6);
+
 }