Fixes

Fixes

--- Arduino/SpiritMinimial/SpiritMinimial.ino
+++ Arduino/SpiritMinimial/SpiritMinimial.ino
@@ -12,8 +12,22 @@
 // ##############################
 // available options
 // ##############################
-const bool useGameCyclotronEffect = true; // set this to true to get the fading previous cyclotron light in the idle sequence
-const bool useCyclotronFadeInEffect = false; // Instead of the yellow alternate flashing on boot/vent this fades the cyclotron in from off to red
+const bool useGameCyclotronEffect = true;     // set this to true to get the fading previous cyclotron light in the idle sequence
+const bool useCyclotronFadeInEffect = true;   // Instead of the yellow alternate flashing on boot this fades the cyclotron in from off to red
+
+// ##############################
+// bootup animation speeds
+// ##############################
+const int pwr_boot_interval = 30;       // How fast to do the powercell drop animation on bootup
+const int cyc_boot_interval = 400;      // If useCyclotronFadeInEffect is false this alternates the cycltron lights yellow
+const int cyc_boot_alt_interval = 100;  // How fast to fade in the cyclotron lights from black to red on bootup
+
+// ##############################
+// idle animation speeds
+// ##############################
+const int pwr_interval = 50;            // how fast the powercell cycles
+const int cyc_interval = 750;           // how fast the cycltron cycles from one cell to the next
+const int cyc_fade_interval = 1;        // if useGameCyclotronEffect is true this is how fast to fade the previous cyclotron to light to nothing

 void setup() {
   // configure powercell/cyclotron
@@ -26,22 +40,19 @@
   cyclotron.show(); // Initialize all pixels to 'off'
 }

-int pwr_interval = 60;       // interval at which to cycle lights for the powercell.
-int cyc_interval = 1000;      // interval at which to cycle lights for the cyclotron.
-int cyc_fade_interval = 1;   // fade the inactive cyclotron to light to nothing
-
 void loop() {
   // get the current time
   int currentMillis = millis();
   if( powerBooted == false ){
-	powerSequenceBoot(currentMillis);
+    powerSequenceBoot(currentMillis);
   } else {
-	powerSequenceOne(currentMillis, pwr_interval, cyc_interval, cyc_fade_interval);
+    powerSequenceOne(currentMillis, pwr_interval, cyc_interval, cyc_fade_interval);
   }
   delay(1);
 }

-int cyclotronRunningFadeOut = 255;
+int cyclotronRunningFadeOut = 255;  // we reset this variable every time we change the cyclotron index so the fade effect works
+int cyclotronRunningFadeIn = 0;     // we reset this to 0 to fade the cyclotron in from nothing
 void setCyclotronLightState(int startLed, int endLed, int state ){
   switch ( state ) {
     case 0: // set all leds to red
@@ -69,13 +80,13 @@
         }
       }
       break;
-	case 4: // fade all leds to red
+  case 4: // fade all leds to red
       for(int i=startLed; i <= endLed; i++) {
         if( cyclotronRunningFadeIn < 255 ){
-          powerStick.setPixelColor(i, 255 * cyclotronRunningFadeIn/255, 0, 0);
+          cyclotron.setPixelColor(i, 255 * cyclotronRunningFadeIn/255, 0, 0);
           cyclotronRunningFadeIn++;
         }else{
-          powerStick.setPixelColor(i, powerStick.Color(255, 0, 0));
+          cyclotron.setPixelColor(i, cyclotron.Color(255, 0, 0));
         }
       }
       break;
@@ -95,13 +106,15 @@
 int c4Start = 3;
 int c4End = 3;

+unsigned long prevPwrBootMillis = 0;    // the last time we changed a powercell light in the boot sequence
+unsigned long prevCycBootMillis = 0;    // the last time we changed a cyclotron light in the boot sequence
 unsigned long prevPwrMillis = 0;        // last time we changed a powercell light in the idle sequence
 unsigned long prevCycMillis = 0;        // last time we changed a cyclotron light in the idle sequence
 unsigned long prevFadeCycMillis = 0;    // last time we changed a fading cyclotron light in the idle sequence

 // LED indexes into the neopixel powerstick chain for the cyclotron
-const int powercellLedCount = 14; 	// total number of led's in the animation
-int powerSeqNum = 0;          		// current running powercell sequence leds
+const int powercellLedCount = 14;   // total number of led's in the animation
+int powerSeqNum = 0;                // current running powercell sequence leds

 // animation level trackers for the boot and shutdown
 int currentBootLevel = 0;                          // current powercell boot level sequence led
@@ -111,6 +124,7 @@
 bool reverseBootCyclotron = false;
 void powerSequenceBoot(int currentMillis) {
   bool doUpdate = false;
+  bool doCycUpdate = false;

   // START CYCLOTRON
   if( useCyclotronFadeInEffect == false ){
@@ -123,7 +137,7 @@
         setCyclotronLightState(c3Start, c3End, 1);
         setCyclotronLightState(c4Start, c4End, 2);

-        doUpdate = true;
+        doCycUpdate = true;
         reverseBootCyclotron = true;
       }else{
         setCyclotronLightState(c1Start, c1End, 2);
@@ -131,7 +145,7 @@
         setCyclotronLightState(c3Start, c3End, 2);
         setCyclotronLightState(c4Start, c4End, 1);

-        doUpdate = true;
+        doCycUpdate = true;
         reverseBootCyclotron = false;
       }
     }
@@ -139,8 +153,12 @@
     if (currentMillis - prevCycBootMillis > cyc_boot_alt_interval) {
       prevCycBootMillis = currentMillis;
       setCyclotronLightState(c1Start, c4End, 4);
-      doUpdate = true;
-    }
+      doCycUpdate = true;
+    }
+  }
+
+  if( doCycUpdate == true ){
+    cyclotron.show(); // send to the neopixels
   }
   // END CYCLOTRON

@@ -330,3 +348,4 @@
   }
 }

+


nothing

nothing

--- Musical_Instruments_2017_2018/Musical_Glove/Gloves_R/Gloves_R.ino
+++ Musical_Instruments_2017_2018/Musical_Glove/Gloves_R/Gloves_R.ino
@@ -68,8 +68,6 @@
     color_to_note_normal(color);
   }
   delay(500);
-
-
 }

 int get_colors(){
@@ -266,4 +264,3 @@
     break;
   }
 }
-


COH-80: WIP

COH-80: WIP

--- Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ Arduino/COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -351,10 +351,7 @@
 #else
   uint8_t key[16];
   if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
-    {
-    OTV0P2BASE::serialPrintlnAndFlush("!TX key");
-    return(false); // Failed.
-    }
+    { OTV0P2BASE::serialPrintlnAndFlush("!TX key"); return(false); } // FAIL
   const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
   uint8_t buf[OTRadioLink::SimpleSecureFrame32or0BodyTXBase::generateSecureBeaconMaxBufSize];
   const uint8_t bodylen = secureTXState.generateSecureBeaconRawForTX(buf, sizeof(buf), lenTXID, e, NULL, key); // 2 byte ID.
@@ -579,9 +576,7 @@
   // Get the 'building' key.
   if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
     {
-#if 1 && defined(DEBUG)
-DEBUG_SERIAL_PRINTLN_FLASHSTRING("!RX key");
-#endif
+    DEBUG_SERIAL_PRINTLN_FLASHSTRING("!RX key");
     return; // FAIL
     }
   // Attempt to authenticate (and decrypt) the frame before inspecting content.
@@ -735,15 +730,34 @@
           // TODO: may need to insert a delay to allow hub to be ready if use of read() above is not enough.
           uint8_t txbuf[OTProtocolCC::CC1PollResponse::primary_frame_bytes+1]; // More than large enough for preamble + sync + alert message.
           const uint8_t bodylen = r.encodeSimple(txbuf, sizeof(txbuf), true);
-#if 0 && defined(DEBUG)
-OTRadioLink::printRXMsg(p, txbuf, bodylen);
-#endif
-          if(PrimaryRadio.sendRaw(txbuf, bodylen)) // Send at default volume...  One going missing won't hurt that much.
-            {
 #if 1 && defined(DEBUG)
-            p->println(F("polled")); // Done it!
-#endif
-            }
+          p->println(F("polled")); // Done it!
+#endif
+#if !defined(ENABLE_OTSECUREFRAME_ENCODING_SUPPORT)
+          // Non-secure: send raw frame as-is.
+          if(!PrimaryRadio.sendRaw(txbuf, bodylen)) // Send at default power...  One going missing won't hurt that much.
+            { OTV0P2BASE::serialPrintlnAndFlush("!TX fail"); return; } // FAIL
+#else
+          // Secure: wrap frame in encrypted layer...
+          uint8_t key[16];
+          if(!OTV0P2BASE::getPrimaryBuilding16ByteSecretKey(key))
+            { OTV0P2BASE::serialPrintlnAndFlush("!TX key"); return; } // FAIL
+          const OTRadioLink::SimpleSecureFrame32or0BodyTXBase::fixed32BTextSize12BNonce16BTagSimpleEnc_ptr_t e = OTAESGCM::fixed32BTextSize12BNonce16BTagSimpleEnc_DEFAULT_STATELESS;
+          uint8_t buf[OTRadioLink::SecurableFrameHeader::maxSmallFrameSize];
+
+
+
+
+
+// FIXME FIXME FIXME
+
+
+
+
+
+
+          OTV0P2BASE::serialPrintlnAndFlush("!TX not impl"); // FAIL
+#endif // !defined(ENABLE_OTSECUREFRAME_ENCODING_SUPPORT)
           }
         }
       return;


Support for 1.0.5 IMU corelib, refactored source, boot cal sequence...

Should be more tolerate to interference from other dice.
Less aggressive anti-cheat.


Set the hostname.

Set the hostname.

time.h is not needed?

--- aquacontrol32.ino
+++ aquacontrol32.ino
@@ -5,7 +5,7 @@
 #include "MHDS18B20.h"
 #include <WiFi.h>
 #include <ESPmDNS.h>
-#include "time.h"
+//#include "time.h"
 #include <Preferences.h>
 #include "SSD1306.h"              //https://github.com/squix78/esp8266-oled-ssd1306
 #include <ESP32WebServer.h>       //http://www.fisch.lu/junk/ESP32-WebServer.zip
@@ -256,6 +256,7 @@
   Serial.println("mDNS responder started");
   Serial.print( "mDNS name: ");  Serial.print( mDNSname );  Serial.println( ".local" );

+  WiFi.setHostname( mDNSname.c_str() );
   tft.println( "Starting webserver. " );

   setupWebServer();


Allow URL notation with plus; e.g. digitalread+all

--- examples/Ethernet/CosaShellWebServer/CosaShellWebServer.ino
+++ examples/Ethernet/CosaShellWebServer/CosaShellWebServer.ino
@@ -82,7 +82,7 @@
   if (query != NULL) {
     char c;
     for (char* qp = query; (c = *qp) != 0; qp++)
-      if (c == '&') *qp = ' ';
+      if (c == '&' || c == '+') *qp = ' ';
     res = shell.execute(query);
   }
   if (res != 0) page << PSTR("illegal query") << endl;


Work on linknode registry in eeprom

Work on linknode registry in eeprom

--- Prototype/RadioLinkRF24/RadioLinkRF24.ino
+++ Prototype/RadioLinkRF24/RadioLinkRF24.ino
@@ -18,8 +18,11 @@
   And maybe add SD logging, for Relay Nodes (with no or minimal on-board
   sensors).

-TODO: on announce store node_id, reserve 5 bytes per node.
-That should allow almost 200 nodes. Load ids into array on start-up.
+TODO: store node_id (3+2 bytes + null=6 byte) with adress (uint16_t=2 byte)
+on announce.
+
+XXX: Load ids into array on start-up for quick lookup of address.
+

 TODO: map alphachar node_id prefix to sketch payload struct.

@@ -44,6 +47,7 @@
 #include <DotmpeLib.h>
 #include <mpelib.h>
 #include "printf.h"
+#include <hashmap.h>

@@ -61,6 +65,8 @@

 // Network address of current node
 const uint16_t link_node = 0;
+
+

@@ -109,7 +115,7 @@

 struct Config {
-	char node[4]; // Alphanumeric Id (for sketch)
+	char node[3]; // Alphanumeric Id (for sketch)
 	int node_id; // Id suffix integer (for unique run-time Id)
 	int version; // Sketch version
 	signed int temp_offset;
@@ -118,12 +124,18 @@
 	uint16_t nodes; // Node count
 } static_config = {
 	/* default values */
-	{ node[0], node[1], node[2], 0 }, 0, version,
+	{ node[0], node[1], node[2] }, 0, version,
 	TEMP_OFFSET, TEMP_K,
 	00, 00
 };

 Config config;
+
+struct Record {
+	char node[3];
+	int node_id;
+	uint16_t address;
+};

 bool loadConfig(Config &c)
 {
@@ -168,6 +180,16 @@
 	}
 }

+Record* nodes;
+
+bool nodeConfigured(uint16_t address)
+{
+	for (Record * r = nodes; ; ++r) {
+		if (r->address == address)
+			return true;
+	}
+	return false;
+}

 /* *** /EEPROM config *** }}} */
@@ -246,9 +268,28 @@

 /* *** Run-time handlers *** {{{ */

+void loadNodeAddresses(void)
+{
+	Record record;
+	unsigned int x;
+	unsigned int y = sizeof(config);
+	unsigned int w = sizeof(record);
+	nodes = (Record*) malloc(config.nodes * w);
+	for (unsigned int i=0; i<config.nodes; i++) {
+		x = i * w;
+		for (unsigned int t=0; t<w; t++)
+		{
+			*((char*)&record + t) = EEPROM.read(CONFIG_EEPROM_START + y + x + t);
+			nodes[i] = record;
+		}
+	}
+}
+
 void doReset(void)
 {
 	doConfig();
+
+	loadNodeAddresses();

 #ifdef _DBG_LED
 	pinMode(_DBG_LED, OUTPUT);
@@ -258,18 +299,21 @@
 	//scheduler.timer(MEASURE, 0);    // get the measurement loop going
 }

-bool nodeConfigured(uint16_t id)
-{
-}
-
 void nodeReportRead(RF24NetworkHeader header)
 {
-//	header.type;
+		header.type;
 	network.read(header, &payload, sizeof(payload));
 }

 void registerNode(RF24NetworkHeader header)
 {
+	Record record;
+	Record announce;
+	// XXX: read bytes until announce header
+	network.read(header, &announce, sizeof(announce));
+	//record.node = announce.node;
+	//record.node_id = announce.node_id;
+	//record.address = announce.address;
 }

 /* *** /Run-time handlers }}} *** */
@@ -333,20 +377,18 @@
 		//Serial.println();
 #endif

-		if (nodeConfigured(header.from_node)) {
-
-			nodeReportRead(header);
-
-		} else {
-
-			if (header.id == 0) {
-
+		switch (header.type) {
+			case 0:
 				registerNode(header);
-
-			} else {
-				Serial.println("Discarded messsage, no node config");
-				// TODO request node config
-			}
+				break;
+			case 1:
+				if (nodeConfigured(header.from_node)) {
+					nodeReportRead(header);
+				} else {
+		//		Serial.println("Discarded messsage, no node config");
+		//		// TODO request node config
+				}
+				break;
 		}

 	}


Project to use PID control to levitate ping pong ball. Hardware includes Motion Detector, small fan, clear tube and ping pong ball.

--- VernierPingPongPID/VernierPingPongPID.ino
+++ VernierPingPongPID/VernierPingPongPID.ino
@@ -74,12 +74,15 @@
   Serial.print("\t");
   Serial.print ("D"); //short name
   Serial.print("\t");
+  Serial.print("\t");
   Serial.println("0 - 255");
   Serial.print("micro seconds");//units
   Serial.print("\t"); // tab character
-  Serial.print ("centimeters"); //units
+  Serial.print ("cm"); //units
   Serial.print("\t"); // tab character
-  Serial.print ("centimeters"); //units
+  Serial.print("\t");
+  Serial.print ("cm"); //units
+  Serial.print("\t");
   Serial.print("\t");
   Serial.println("#");
   // This would be the end of the grayed out portion if using VPython
@@ -115,10 +118,13 @@
   //* Grayed out for python connection
   Serial.print(Duration);// print the time it took until the echo
   Serial.print("\t"); // tab character
+  Serial.print("\t");
   Serial.print(Setpoint);
   Serial.print("\t"); // tab character
+  Serial.print("\t");
   // This would be the end of the grayed out portion
-  Serial.println(Distance);
+  Serial.print(Distance);
+  Serial.print("\t");
   Serial.print("\t"); //tab character
   Serial.println(Output);
   delay (100);


Fixes for ros startup

Fixes for ros startup

--- Arduino/victoria_teensy_ros_node/victoria_teensy_ros_node.ino
+++ Arduino/victoria_teensy_ros_node/victoria_teensy_ros_node.ino
@@ -143,7 +143,7 @@

 // Debug blink
 // Blink duration is in milliseconds.
-#define BLINK_DURATION 2000
+#define BLINK_DURATION 500
 int blink_state = LOW;

 void setup() {
@@ -180,9 +180,11 @@
   y = 0.0;
   th = 0.0;

+  unsigned long rosStartTimeout = millis() + 500;
+
   // Initialize and connect to ros
   ros_nh.initNode();
-  while(!ros_nh.connected()) {
+  while(!ros_nh.connected() && millis() < rosStartTimeout) {
     ros_nh.spinOnce();
   }

@@ -226,7 +228,7 @@
   timer.every((1.0/publish_imu_freq_hz) * 1000, doPublishImu);
   timer.every((1.0/publish_magnetometer_freq_hz) * 1000, doPublishMagnetometer);
   timer.every(BLINK_DURATION, doBlink);
-
+
   ros::Time current_time = ros_nh.now();
   last_cmd_vel_time = current_time;
   last_odom_publish_time = current_time;


Added sensors

Added sensors

--- workspace/serialWithoutDistortion/serialWithoutDistortion.ino
+++ workspace/serialWithoutDistortion/serialWithoutDistortion.ino
@@ -28,4 +28,5 @@
   }

 //  delay(100);
+
 }


COH-77: WIP

COH-77: WIP

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

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


COH-71: making compile when non-secure

COH-71: making compile when non-secure

--- COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -1081,6 +1081,7 @@
       Serial.print(' ');
       Serial.print('s'); // Indicate syncing with trailing lower-case 's' in field...
       }
+#if defined(ENABLE_OTSECUREFRAME_ENCODING_SUPPORT)
     // Now show TX ID for secure association.
     Serial.print(F(" TX ID"));
     uint8_t idbuf[OTV0P2BASE::OpenTRV_Node_ID_Bytes];
@@ -1090,6 +1091,7 @@
       Serial.print(' ');
       Serial.print(idbuf[i], HEX);
       }
+#endif // defined(ENABLE_OTSECUREFRAME_ENCODING_SUPPORT)
     Serial.println();
     }
   // Terminate line.


Fixed animation selection mode

Fixed animation selection mode

--- BlinkenScreen.ino
+++ BlinkenScreen.ino
@@ -21,10 +21,11 @@
 };

 enum modes {
+  MODE_SENTINAL_L,
   RAW_WIPE,
   WIPE,
   BUMP,
-  MODE_SENTINAL
+  MODE_SENTINAL_H
 };

@@ -198,8 +199,13 @@
       break;

     // Outside range, correct it
-    default:
-      mode %= MODE_SENTINAL;
+    case MODE_SENTINAL_H:
+      mode = MODE_SENTINAL_L + 1;
+      break;
+
+    case MODE_SENTINAL_L:
+      mode = MODE_SENTINAL_H - 1;
+      break;
   }

   print_framebuffer(s);


changing baud rate to led driver

changing baud rate to led driver

--- examples/CaroloCar/CaroloCar.ino
+++ examples/CaroloCar/CaroloCar.ino
@@ -53,7 +53,7 @@
   setupChangeInterrupt(OVERRIDE_THROTTLE_PIN);
   setupChangeInterrupt(OVERRIDE_SERVO_PIN);
   Serial.begin(9600); //to HLB
-  Serial3.begin(9600); //to LED driver
+  Serial3.begin(38400); //to LED driver
 }

 void loop() {


Update chat_room.ino

Update chat_room.ino

--- examples/chat_room/chat_room.ino
+++ examples/chat_room/chat_room.ino
@@ -9,8 +9,8 @@
   within range. They will see your message appear in their Serial monitor.
 */

-#include "Pozyx.h"
-#include "Pozyx_definitions.h"
+#include <Pozyx.h>
+#include <Pozyx_definitions.h>
 #include <Wire.h>

 uint16_t source_id;                 // the network id of this device


add comments to sketch

add comments to sketch

--- src/gauge/gauge.ino
+++ src/gauge/gauge.ino
@@ -4,32 +4,53 @@
 int newGaugeVal = 0;
 int distance;

-int state = 1; // Start at the tens
+// The state variable determines what digit the next value of Serial.read() is.
+//   0: one's digit
+//   1: ten's digit
+// The starting state is the ten's digit, as the state machine reads digits in
+// most-significant to least-significant order.
+int state = 1;

+// Init
 void setup() {
+  // Initialize the serial port
   Serial.begin(baud);
+
+  // Initialize the gauge output pin
   pinMode(gaugePin, OUTPUT);
 }

+// Main loop
 void loop() {
+  // Only update the gauge output if the gauge value has changed
   if (gaugeVal != newGaugeVal) {
+    // Compute the absolute distance between the new and old gauge values
     distance = abs(gaugeVal - newGaugeVal);
+
+    // Update the output pin. We expect the gauge values to range from 0-99,
+    // and the analog output pin expects values between 0-255.
     gaugeVal = newGaugeVal;
     analogWrite(gaugePin, map(gaugeVal, 0, 99, 0, 255));
+
+    // Wait a small amount of time for the gauge to settle. The delay is
+    // proportional to the distance the gauge needle has to travel.
     delay(map(distance, 0, 99, 0, 200));
   }
 }

+// Callback for whenever there's data on the serial port
 void serialEvent(){
   char ch = Serial.read();
   if (isDigit(ch)) {
-    int val = ch - '0';
+    int val = ch - '0'; // Convert the char input into an integer
+
+    // Input state machine.
     switch(state) {
-      case 1: // Tens
+      case 1: // Got a ten's digit, expect a one's digit next
         newGaugeVal = val * 10;
         state = 0;
       break;
-      case 0: // Ones
+      case 0: // Got a one's digit, expect a ten's digit next
         newGaugeVal = newGaugeVal + val;
         state = 1;
       break;


Reorganization; Gradient Progress

Reorganization; Gradient Progress

Gradients still don't work.  Debug now toggleable with 'd'.

--- csarc/csarc.ino
+++ csarc/csarc.ino
@@ -6,21 +6,24 @@
  */

 #include <stdarg.h>
-static boolean DEBUGGING_MODE = true; // toggle serial debug text
-static boolean SINGLE_LED = true; // false = Grove LED driver;
-                                  // true = RGB LED for at-home testing
+
+
+static boolean SINGLE_LED = true; // real LED driver or test rig?
 static int R_PIN = 6;   // pins for
 static int G_PIN = 5;   // directly driven
 static int B_PIN = 4;   // test setup
-static int GND = 7;     // (<- so we don't have to split cables)
+static int GND = 7;     // ( <-so we don't have to split cables)
+
 #include "RGBdriver.h"
 #define CLK 2 //pin definitions for Grove driver
 #define DIO 3
-
 RGBdriver Driver(CLK,DIO);
+
 static int BAUDRATE = 19200;
+boolean DEBUG = false; // toggle serial debug text
+int TIMEOUT = 300;  //timeout in seconds before beginning default pattern
 int red,green,blue;
-int* rgb[4] = {&red, &green, &blue};
+int* rgb[4] = {&red, &green, &blue, 0};
 // In use, & means "address of"; * means "follow this address".
 // This is an array of pointers (which lead to our RGB vars).  Write
 // to it with *rgb[x], which means "follow the address at rgb[x]" which
@@ -34,71 +37,30 @@
     pinMode(GND,OUTPUT);
   }
   Serial.begin(BAUDRATE);
-  rgb[4]=0;
 }

 int timeOutCount = 0;
 char input[128];

-void loop() {
-
-
+void loop() {
   Serial.readStringUntil('\n').toCharArray(input,255);
   if (input!="") { // if connected
     switch (input[0]) {
-      case 'c' : {
-        sClear();
-        break;
-      }
-      case 'B': {
-        *rgb[0]=0;
-        *rgb[1]=0;
-        *rgb[2]=255;
-        setOutput(rgb);
-        if (SINGLE_LED) { Serial.println(digitalRead(B_PIN)); }
+
+      case 'd': { //enables debug mode, lowercase commands
+        DEBUG=!DEBUG;
+        Serial.print("Debug mode ");
+        if (DEBUG)
+          Serial.println("ON");
+         else
+          Serial.println("OFF");
         break;
       }
-      case 'b': {
-        analogWrite(B_PIN,127.5);
-        break;
-      }
-      case '1': {
-        *rgb[0]=255;
-        *rgb[1]=255;
-        *rgb[2]=255;
-        setOutput(rgb);
-        break;
-      }
-      case 'o': {
-        setOutput(rgb);
-        break;
-      }
-      case '*': {
-        Serial.println(*rgb[0]);
-        Serial.println(*rgb[1]);
-        Serial.println(*rgb[2]);
-        break;
-      }
-      case '?': {
-        Serial.println(red);
-        Serial.println(green);
-        Serial.println(blue);
-        break;
-      }
-      case 'X' : {
-        red=0; green=0; blue=0;
-        setOutput(rgb);
-        break;
-      }
-      case '!': {
-        red=0; green=0; blue=0;
-        setOutput(red,green,blue);
-        break;
-      }
+
       case 'V': { // set value specified in V#FFFFFF input
         char colorInput[] = {input[1],input[2],input[3],input[4],input[5],input[6],input[7],'\0'}; // who needs loops
-        if (DEBUGGING_MODE) {
+        if (DEBUG) {
           Serial.print("Serial input:");
           Serial.println(colorInput);
         }
@@ -106,19 +68,10 @@
         decodeHex(colorInput,rgb);
         setOutput(rgb);

-        if (DEBUGGING_MODE) {
+        printColors();
+
+        if (DEBUG) {
           Serial.println("Color set.  Results:");
-        }
-        // echo current colors:
-        Serial.print('#');
-        if (red<=16) {Serial.print('0');}
-        Serial.print(red, HEX);
-        if (green<=16) {Serial.print('0');}
-        Serial.print(green, HEX);
-        if (blue<=16) {Serial.print('0');}
-        Serial.println(blue, HEX);
-
-        if (DEBUGGING_MODE) {
           Serial.print("red: ");
           Serial.println(red, DEC);
           Serial.print("green: ");
@@ -132,17 +85,17 @@
       }
     case 'G' : {
         // run gradient pulse between a and b with appropriate timestep; "G#000000:#123456:time" input
-        if (input[9]=='#') {
-          char hex1[7], hex2[7];
-          char timev[7]; //well our buffer is 7 chars now.
+        if (input[1]=='#' && input[9]=='#') {
+          char hex1[8], hex2[8];
+          char timev[8]; //well our buffer is 7 chars now.
           for (int x=0; x<7; x++) {
             hex1[x]=input[x+1];
             hex2[x]=input[x+9];
             timev[x]=input[x+16];
           }
           int col1[4],col2[4];
-          int *col1p[4] = {&col1[0],&col1[1],&col1[2]};
-          int *col2p[4] = {&col2[0],&col2[1],&col2[2]};
+          int *col1p[4] = {&col1[0],&col1[1],&col1[2],0};
+          int *col2p[4] = {&col2[0],&col2[1],&col2[2],0};
           decodeHex(hex1,col1p);
           decodeHex(hex2,col2p);

@@ -150,7 +103,7 @@

           gradientPulse(col1,col2,timeVal);

-          if (DEBUGGING_MODE) {
+          if (DEBUG) {
             Serial.println(hex1);
             Serial.println(hex2);
             Serial.println(timev);
@@ -161,11 +114,15 @@
         }
         break;
       }
+
+      // begin debugging char commands
+
+
     }
   } else {
     // no input;
-    if (timeOutCount > 5*60) { // 5 minutes with no comms
-      setOutput( random(255), random(255), random(255) );
+    if (timeOutCount > TIMEOUT) { // after TIMEOUT, flash randomly per second
+      setOutput( random(255), random(255), random(255) ); // change to be nicer (1s gradients?)
     }

@@ -175,13 +132,12 @@

   void setOutput( int r, int g, int b) {
-    //"local variable hides a field" :p

     if (!SINGLE_LED) {
       Driver.begin();
       Driver.SetColor(r, g, b);
       Driver.end();
-    } else { //testing setup: single RGB led with cathode on 7
+    } else {
       analogWrite(R_PIN,r);
       analogWrite(G_PIN,g);
       analogWrite(B_PIN,b);
@@ -189,75 +145,77 @@
   }

   void setOutput( int *color[]) {
-    Serial.println(); // without this the first line below doesn't show up.
-    Serial.println("---Setting output:---"); // v mysterious
-    Serial.println(*color[0]);
-    Serial.println(*color[1]);
-    Serial.println(*color[2]);
-    Serial.println(*color[3]);
-    Serial.println("---------------------");
-
-
+
+    if (DEBUG) {
+      Serial.println(); // for some reason a lot of this output
+      Serial.println("---Setting output:---"); // doesn't show up
+      Serial.println(*color[0]);
+      Serial.println(*color[1]);
+      Serial.println(*color[2]);
+      Serial.println(*color[3]);
+      Serial.println("---------------------");
+    }
       setOutput(*color[0],*color[1],*color[2]);

   }

-  void decodeHex( char hexColor[], int * output[] ) { // #FFFFFF
-    // function strtol() returns a long when given (string,end pointer,radix)
-    unsigned long number = strtol( &hexColor[1], NULL, 16);   // from Stack Exchange
-    // Split them up into r, g, b values
-    *output[0] = number >> 16;
-    *output[1] = number >> 8 & 0xFF;
-    *output[2] = number & 0xFF;
-
-    if (DEBUGGING_MODE) {
+  void decodeHex( char hexColor[], int * output[] ) { //in: #FFFFFF\0
+    unsigned long number = strtol( &hexColor[1], NULL, 16);
+    *output[0] = number >> 16;      //first
+    *output[1] = number >> 8 & 0xFF;//mid
+    *output[2] = number & 0xFF;     //last
+    if (DEBUG) {
       Serial.println("---decodeHex debugging---");
-      Serial.println("hexColor[]: ");
+      Serial.print("hexColor[]: ");
       Serial.println(hexColor);
-      Serial.println("unsigned long number:");
+      Serial.print("unsigned long number: ");
       Serial.println(number);
-      Serial.println("Output[]:");
+      Serial.println("*output[0-4]: ");
       Serial.println(*output[0]);
       Serial.println(*output[1]);
       Serial.println(*output[2]);
       Serial.println(*output[4]);
-      Serial.println("output:");
-      printArray(*output);
       Serial.println("--------------------------");
       Serial.println();
-    }
-
-  }
-
-  void printArray( int r[]) {
-    int x=0;
-    while (r[x]!='\0') {
-      Serial.print(r[x]);
-      Serial.print(' ');
-      x++;
-    }
-   Serial.println();
-   Serial.print(r[0]);
-   Serial.print(r[1]);
-   Serial.println(r[2]);
-  }
-
-
-  void gradientPulse (int col1[], int col2[], float timev) {
+    }
+  }
+
+
+  static int numdivs = 60; //change this to adjust gradient smoothness
+  void gradientPulse (int col1[], int col2[], float timev) {
     // in this initial version, gradient pulses are going to be locking.
     // This is obviously a problem - add an interrupt when you have time.
-    double tick = timev;
-    double percentPerTick = tick/1;
-    for (float percentage = 0; percentage+=percentPerTick; percentage < 1) {
-      gradientValue(col1, col2, percentage,*rgb);
+
+    float delayPerTick = (float) timev/numdivs;
+    float   perPerTick = (float) 1/numdivs;
+
+    if (DEBUG) {
+      Serial.println("---gradientPulse---");
+      Serial.println("col1,col2:");
+      for (int i=0; i<3;i++) {
+        Serial.print(col1[i]);
+        Serial.print(' ');
+      }
+      Serial.println();
+      for (int i=0; i<3;i++) {
+        Serial.print(col2[i]);
+        Serial.print(' ');
+      }
+      Serial.println();
+    }
+
+    for (float per = 0; per+=perPerTick; per<=1.0) {
+      Serial.println(per);
+      gradientValue(col1,col2,per,rgb);
       setOutput(rgb);
-    }
-  }
-
-  void gradientValue(int col1[3], int col2[3], float percentage, int output[3]) {
-    output[0] = col1[0]*percentage + col2[0]*(1-percentage);
-    output[1] = col1[1]*percentage + col2[1]*(1-percentage);
-    output[2] = col1[2]*percentage + col2[2]*(1-percentage);
+      delay(delayPerTick);
+    }
+  }
+
+  void gradientValue(int col0[3], int col1[3], float percentage, int *output[3]) {
+    *output[0] = col1[0]*percentage + col0[0]*(1-percentage);
+    *output[1] = col1[1]*percentage + col0[1]*(1-percentage);
+    *output[2] = col1[2]*percentage + col0[2]*(1-percentage);

   }

@@ -274,3 +232,12 @@
   for (int x=0; x<40; x++) { Serial.println(); }
 }

+void printColors() {
+  Serial.print('#');
+  if (red<=16) {Serial.print('0');}
+  Serial.print(red, HEX);
+  if (green<=16) {Serial.print('0');}
+  Serial.print(green, HEX);
+  if (blue<=16) {Serial.print('0');}
+  Serial.println(blue, HEX);
+}


Ajout du node ID du eqbe 2

Ajout du node ID du eqbe 2

--- eqbe.ino
+++ eqbe.ino
@@ -146,7 +146,7 @@
   switch (nodeId) {
     case 0xa6182c9a:
       return SEBASTIEN;
-    case 0x7f0fc58c: // Witty board
+    case 0x7f0fb8c3:
       return PASCAL;
     default:
       return UNKNOWN_RIDER;


Fixed Clock project for work with DS1302

--- clock/clock.ino
+++ clock/clock.ino
@@ -1,9 +1,12 @@
 // Date and time functions using a DS1307 RTC connected via I2C and Wire lib

 #include <Wire.h>
-#include "RTClib.h"
 #include <LiquidCrystal_I2C.h>
-RTC_DS1307 rtc;
+#include <Time.h>
+#include <DateTime.h>
+#include <DS1302RTC.h>
+// Set pins:  CE, IO,CLK
+DS1302RTC RTC(13, 12, 11);
 LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

 byte LT[8] =
@@ -109,7 +112,6 @@
 void setup () {
   Serial.begin(57600);
   Wire.begin();
-  rtc.begin();
   lcd.init();                      // initialize the lcd
   lcd.backlight();
   lcd.home();
@@ -128,11 +130,6 @@

-  if (! rtc.isrunning()) {
-    Serial.println("RTC is NOT running!");
-    // following line sets the RTC to the date & time this sketch was compiled
-    // rtc.adjust(DateTime(__DATE__, __TIME__));
-  }
 }

@@ -280,20 +277,21 @@

 void digitalClockDisplay(){
   // digital clock display of the time
-  DateTime now = rtc.now();
-
-  printDigits(now.hour()/10,0);
-  printDigits(now.hour()%10,4);
-
-  printDigits(now.minute()/10,9);
-  printDigits(now.minute()%10,13);
+  tmElements_t tm;
+  RTC.read(tm);
+
+  printDigits(tm.Hour/10,0);
+  printDigits(tm.Hour%10,4);
+
+  printDigits(tm.Minute/10,9);
+  printDigits(tm.Minute%10,13);

   // lcd.setCursor(7, 1);
   //  lcd.print(now.second()/10);
   //   lcd.print(now.second()%10);

-  if (now.second()%10%2==0){
+  if (tm.Second%10%2==0){
     lcd.setCursor(7, 0);
     lcd.print("+ ");
     lcd.setCursor(7, 1);


Update OpenCTD_master_m0.ino

Update OpenCTD_master_m0.ino

--- OpenCTD_Feather_Adalogger/OpenCTD_master_m0/OpenCTD_master_m0.ino
+++ OpenCTD_Feather_Adalogger/OpenCTD_master_m0/OpenCTD_master_m0.ino
@@ -96,7 +96,7 @@

   }

-  get_numbered_filename(datalogFileName, "WW07", "CSV");
+  get_numbered_filename(datalogFileName, "LOG", "CSV");

   Serial.print("Writing to datalog: ");
   Serial.println(datalogFileName);


v1.2 update version number display

v1.2 update version number display

--- PictureViewer.ino
+++ PictureViewer.ino
@@ -176,8 +176,10 @@
         goodBmp = true; // Supported BMP format -- proceed!
         Serial.print("Image size: ");
         Serial.print(bmpWidth);
-        Serial.print('x');
+        Serial.print("W ");
+        Serial.print("x ");
         Serial.print(bmpHeight);
+        Serial.print('H');
         Serial.println(" Pixels");

         // BMP rows are padded (if needed) to 4-byte boundary
@@ -275,6 +277,11 @@
   tft.println("Picture");
   tft.setCursor(15, 20);
   tft.println("Viewer");
+  tft.setTextSize(1);
+  tft.setCursor(20, 40);
+  tft.print("Version ");
+  tft.println(VERSION);
+  tft.setTextSize(2);
   tft.println("");
   tft.setTextColor(ST7735_BLUE);
   tft.println("GK Grotsky");
@@ -289,9 +296,6 @@
   }
   tft.setTextColor(ST7735_CYAN);
   tft.setTextSize(1);
-  tft.setCursor(30, 130);
-  tft.print("Version ");
-  tft.println(VERSION);
   if (SD_OK) {
     tft.setCursor(30, 140);
     tft.print("# of files ");


Updated CabrilloCalibrator.ino ============================= Was previously using an outdate .ino file. Was notified by @darrenchurchill to use their updated version.

--- Swarmathon-Arduino/CabrilloCalibrator/CabrilloCalibrator.ino
+++ Swarmathon-Arduino/CabrilloCalibrator/CabrilloCalibrator.ino
@@ -12,7 +12,7 @@
 ros::NodeHandle_<ArduinoHardware, 2, 2, 125, 125> nh;

 std_msgs::Int32MultiArray imu_msg;
-long int imu_data[9];
+long int imu_data[8];
 ros::Publisher imu_pub("/imu_raw", &imu_msg);

 void setup()
@@ -20,13 +20,13 @@
   nh.initNode();

   imu_msg.data = (long int *) &imu_data;
-  imu_msg.data_length = 9;
+  imu_msg.data_length = 8;
   nh.advertise(imu_pub);
   nh.spinOnce();

   Wire.begin();

-  /* Initialise the sensor */
+  /* Initialize the sensor */
   if(iicScan() > 0) {
     lsm303.init();
     lsm303.enableDefault();
@@ -38,9 +38,19 @@

     // Set the mag data rate to 50Hz
     ctrl5 &= ~0b00011100;
-    ctrl5 |= ~0b00010000;
-
+    ctrl5 |=  0b00010000;
+
     lsm303.writeReg(0x24, ctrl5);
+
+    // Set the acc data rate to 50Hz
+    byte ctrl1 = lsm303.readReg(0x20);
+    ctrl1 &= ~0b11110000;
+    ctrl1 |=  0b01010000;
+
+    // Enable BDU - Synchronized conversion.
+    ctrl1 |= 0b00001000;
+
+    lsm303.writeReg(0x20, ctrl1);
   }
 }

@@ -77,7 +87,6 @@
     imu_data[5] = acc.z;
     imu_data[6] = temp_lo;
     imu_data[7] = temp_hi;
-    imu_data[8] = lsm303.readReg(0x24);
     imu_pub.publish(&imu_msg);
   }


Straighten out some debugging statements, and fix an elusive bug where an uninitialized checksum value was causing no data to be transmitted in rare circumstances.

--- esp8266/esp8266.ino
+++ esp8266/esp8266.ino
@@ -1363,27 +1363,24 @@
   String wifi_names[12];
   byte num_names = 0;

-//  if(WiFi.localIP() > 0)
-//  {
-    byte numSsid = WiFi.scanNetworks();
-    for (int i = 0; i < numSsid; i++)
-    {
-      bool match = false;
-      for(int j = 0; j < num_names; j++)
-      {
-        if (wifi_names[j] == String(WiFi.SSID(i)))
-        {
-          match = true;
-          break;
-        }
-      }
-      if(!match && num_names < 12)
-      {
-        wifi_names[num_names] = String(WiFi.SSID(i));
-        num_names++;
-      }
-    }
-//  }
+  byte numSsid = WiFi.scanNetworks();
+  for (int i = 0; i < numSsid; i++)
+  {
+    bool match = false;
+    for(int j = 0; j < num_names; j++)
+    {
+      if (wifi_names[j] == String(WiFi.SSID(i)))
+      {
+        match = true;
+        break;
+      }
+    }
+    if(!match && num_names < 12)
+    {
+      wifi_names[num_names] = String(WiFi.SSID(i));
+      num_names++;
+    }
+  }

   //
   // Now build the page to send
@@ -2440,6 +2437,7 @@

 void queueMessage(String a_message)
 {
+
   //
   //   Check a few things
   //
@@ -2452,11 +2450,12 @@
     #endif
     return;
   }
+
   String checksum_a = a_message.substring(checksum_start + 1);

   a_message = a_message.substring(0, a_message.length() - 3);

-  byte a_byte;
+  byte a_byte = 0;
   for (int i = 0; i < a_message.length(); i++)
   {
     a_byte = a_byte ^ a_message.charAt(i);
@@ -2677,12 +2676,12 @@
     {
       processNewPortValue("p=", float_hub_server_port, new_value);
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad number"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("p="))
@@ -2759,12 +2758,12 @@
       processNewFlagValue("F=", public_ip_is_static, new_value);
       kickWiFi();
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad boolean"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("F="))
@@ -2784,12 +2783,12 @@
         kickWiFi();
       }
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad IP"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("I="))
@@ -2809,12 +2808,12 @@
         kickWiFi();
       }
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad IP"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("G="))
@@ -2833,12 +2832,12 @@
         kickWiFi();
       }
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad IP"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("M="))
@@ -2858,12 +2857,12 @@
         kickWiFi();
       }
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad IP"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("D="))
@@ -2937,12 +2936,12 @@
       processNewFlagValue("N=", nmea_mux_on, new_value);
       kickNMEA();
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad boolean"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("N="))
@@ -2959,12 +2958,12 @@
       processNewFlagValue("e=", nmea_mux_private, new_value);
       kickNMEA();
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad boolean"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("e="))
@@ -2980,12 +2979,12 @@
     {
       processNewPortValue("n=", nmea_mux_port, new_value);
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad number"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("n="))
@@ -3023,12 +3022,12 @@
     {
       processNewFlagValue("P=", phone_home_on, new_value);
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad boolean"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("P="))
@@ -3045,12 +3044,12 @@
       processNewFlagValue("Z=", virtual_serial_on, new_value);
       kickVirtualSerial();
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad boolean"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("Z="))
@@ -3067,12 +3066,12 @@
       processNewPortValue("z=", virtual_serial_port, new_value);
       kickVirtualSerial();
     }
+    #ifdef INPT_DEBUG_ON
     else
     {
-      #ifdef INPT_DEBUG_ON
       debug_info(F("Bad number"));
-      #endif
-    }
+    }
+    #endif
   }
   #ifdef INPT_DEBUG_ON
   else if(the_input.startsWith("z="))
@@ -3385,13 +3384,13 @@
             wifi_read_buffer = "";
             expected_fdr_response_time = millis() + FDR_RESPONSE_MAX ;
           }
-          #ifdef WIFI_DEBUG_ON
           else
           {
+            #ifdef WIFI_DEBUG_ON
             debug_info(F("wifi sock prob"));
+            #endif
             fdr_client.stop();
           }
-          #endif
         }
         else
         {


Added example file

Added example file

--- examples/LCD1602KeyPad_SimpleTest/LCD1602KeyPad_SimpleTest.ino
+++ examples/LCD1602KeyPad_SimpleTest/LCD1602KeyPad_SimpleTest.ino
@@ -68,7 +68,7 @@
     case SELECT:
     {
       lcd.setCursor( 4, 1 );
-      lcd.print( "SELECT" );
+      lcd.print( "SELECT" );
       break;
     }
     default:
@@ -85,5 +85,4 @@
     lcd.print( " " );   //quick trick to right-justify this 2 digit value when it's a single digit
   }
   lcd.print( timestamp, DEC );
-}
-
+}


verified

verified

--- libraries/Ethernet/examples/ChatServer/ChatServer.ino
+++ libraries/Ethernet/examples/ChatServer/ChatServer.ino
@@ -7,27 +7,28 @@
  Using an Arduino Wiznet Ethernet shield.

  Circuit:
- * Ethernet shield attached to pins 10, 11, 12, 13
  * Analog inputs attached to pins A0 through A5 (optional)

  created 18 Dec 2009
  by David A. Mellis
- modified 12 March 2012
+ modified 9 Apr 2012
  by Tom Igoe
+
+ modified 2/19/2014
+ by Craig Hollabaugh
+   removed SPI and leonardo references

  */

-#include <SPI.h>
 #include <Ethernet.h>

 // Enter a MAC address and IP address for your controller below.
 // The IP address will be dependent on your local network.
 // gateway and subnet are optional:
-byte mac[] = {
-  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-IPAddress ip(192,168,1, 177);
-IPAddress gateway(192,168,1, 1);
-IPAddress subnet(255, 255, 0, 0);
+byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+IPAddress ip(192,168,1,177);
+IPAddress gateway(192,168,1,1);
+IPAddress subnet(255,255,255,0);

 // telnet defaults to port 23
@@ -39,8 +40,8 @@
   Ethernet.begin(mac, ip, gateway, subnet);
   // start listening for clients
   server.begin();
-  // open the serial port
   Serial.begin(9600);
+
   Serial.print("Chat server address:");
   Serial.println(Ethernet.localIP());
 }
@@ -70,5 +71,3 @@
   }
 }

-
-


Avoid compiler warning in debug method signature.

While I'm not familiar enough with Arduino programming to fully
understand this change, I do know that it reduces the number of
`warning: deprecated conversion from string constant to 'char*'`
warnings from 14 to 5 (once for each of the calls to debug that pass a
string).

--- printer.ino
+++ printer.ino
@@ -47,7 +47,7 @@
 void debugTimeAndSeparator() {
   Serial.print(millis()); Serial.print(": ");
 }
-void debug(char *a) {
+void debug(const char *a) {
   debugTimeAndSeparator(); Serial.println(a);
 }
 #define debug2(a, b) debugTimeAndSeparator(); Serial.print(a); Serial.println(b);


Update the Printer Arduino sketch.

Update the Printer Arduino sketch.

We should always set the mode of the 3 LED pins to OUTPUT, irrespective
of whether we've enabled debugging or not.

I did consider splitting the initDiagnosticLEDs function into two: one
containing the logic for initialising the LED pins and the other to turn
then on for a second. I mentioned this to @lazyatom and he suggested
that it's probably useful to always flash the LEDs at boot time.

--- printer.ino
+++ printer.ino
@@ -116,9 +116,7 @@
   initSD();
   initNetwork();
   initPrinter();
-#ifdef DEBUG
   initDiagnosticLEDs();
-#endif
 }

 boolean downloadWaiting = false;


Fixed heart beat hat sync

Fixed heart beat hat sync

--- heartbeat_with_pulse.ino
+++ heartbeat_with_pulse.ino
@@ -127,8 +127,9 @@
   }

   // Channel 2
+  int halfPoint = (int)sizeof(bufr)/2;
   for (i=0;i<NUM_LEDS_CH2;i++){
-      leds2[i] = CHSV(hue, bufr[0], bufr[0]/brightnessFactor);
+      leds2[i] = CHSV(hue, bufr[halfPoint], bufr[halfPoint]/brightnessFactor);
   }

   FastLED.show();


Merging feature relay-watchdog into develop

--- chillduino.ino
+++ chillduino.ino
@@ -34,6 +34,7 @@
 #define DOOR_SWITCH      13
 #define MODE_SWITCH      SCK
 #define THERMISTOR       A0
+#define RELAY_WATCHDOG   A2
 #define LEDS             A4
 #define LED_COUNT        10
 #define LED_OFF_R        0
@@ -56,9 +57,13 @@

 Chillduino chillduino;
 Adafruit_NeoPixel pixels(LED_COUNT, LEDS, NEO_GRB + NEO_KHZ800);
+int watchdog = 0;

 SIGNAL(TIMER0_COMPA_vect) {
   chillduino.tick();
+
+  digitalWrite(RELAY_WATCHDOG, watchdog);
+  watchdog ^= 1;
 }

 void setInterrupt(void) {


change red button pin number

change red button pin number

--- crypt-gears/gear_arduino/gear_arduino.ino
+++ crypt-gears/gear_arduino/gear_arduino.ino
@@ -1,7 +1,7 @@
 // PIN NUMBERS
 int output_lights[7] = {38, 39, 40, 41, 42, 43, 44};

-int red_button = 30;
+int red_button = 53;

 int calibration_light = 31;


Do photoresistors by averages, not just the first thing we see

--- crypt-gears/gear_arduino/gear_arduino.ino
+++ crypt-gears/gear_arduino/gear_arduino.ino
@@ -16,6 +16,7 @@
 int pot_locs[14] = {1024, 885, 825, 690, 640, 450, 390, 280, 190, 70, 50, 24, 12, 0};

 // above this = white; below = black (unlodged is undefined)
+// TODO(benkraft): Recompute after we move them.
 int photoresistor_thresholds[3] = {28, 6, 15};

 // STATE OF THE WORLD
@@ -32,16 +33,21 @@
 // we perhaps win.
 int last_selector_pos = 0;

-// photoresistor_history[i][j] is the state of the photoresistor i when we were
-// at selector position j.  Only meaningful in state 1, and then only for
-// 0 <= j <= the current selector gear position.  When we transition to state 2
-// we use this to populate gear_types and gear_orientations.
+// These store the state of the photoresistors in the current calibration
+// phose.  photoresistor_totals[i][j] is the sum of the values we saw from
+// photoresistor i in selector position j, and photoresistor_counts[i][j] is
+// the number of such values.  (We use these to compute the average value.)
+//
+// Only meaningful in state 1, and then only for 0 <= j <= the current selector
+// gear position.  When we transition to state 2 we use this to populate
+// gear_types and gear_orientations.
 // NOTE: The photoresistor is positioned down.
-boolean photoresistor_history[3][7];
+int photoresistor_totals[3][7];
+int photoresistor_counts[3][7];

 // The state of the ith gear, if we know it.  This is not its current position,
 // but rather the position corresponding to selector gear 0!  Only meaningful
-// in state 2; set from photoresistor_history when we transition there.
+// in state 2; set from photoresistor_{totals,counts} when we transition there.
 // Type is 0, 1, 2, in order of the correct solution.
 // Orientation is 0 in the correct solution, 1 if we are one step clockwise
 // from it, and so on.
@@ -131,7 +137,15 @@
     {
       // We have started calibrating!
       state = 1;
-      last_selector_pos = -1; // state 1 case will fix
+      // initialize photoresistor data.
+      for (int i=0; i<3; i++)
+      {
+        for (int j=0; j<7; j++)
+        {
+          photoresistor_totals[i][j] = 0;
+          photoresistor_counts[i][j] = 0;
+        }
+      }
     }
   }

@@ -142,21 +156,16 @@
         || selector_pos > last_selector_pos + 1)
     {
       // They have gone backwards or too fast.
-      // TODO(benkraft): We may wish to debounce here, or say it's ok for them
-      // to go back and forth as long as they get there eventually (and we only
-      // consider the position they last got to in order).
       state = 0;
       resetLights();
     }
-    else if (selector_pos == last_selector_pos + 1)
+    else
     {
       // Fill in new photoresistor states.
-      // TODO(benkraft): We almost certainly want to wait until we're closer to
-      // the middle of this state to check; probably this will be solved at the
-      // same time as debouncing.
       for (int i=0; i<3; i++)
       {
-        photoresistor_history[i][selector_pos] = getPhotoresistor(i);
+        photoresistor_totals[i][selector_pos] += getRawPhotoresistor(i);
+        photoresistor_counts[i][selector_pos]++;
       }

       // If we are at the end, move on to state 2.
@@ -170,45 +179,15 @@
         int types_seen = 0;
         for (int i=0; i<3; i++)
         {
-          if (debug_state > 0)
-          {
-            Serial.print("GEAR ");
-            Serial.print(i);
-          }
           if (!computeGearPosition(i))
           {
             failed = true;
-            if (debug_state > 0)
-            {
-              Serial.println(" none");
-            }
+            printGearRead(i, true);
           }
           else
           {
             types_seen |= 1 << gear_types[i];
-            if (debug_state > 0)
-            {
-              Serial.print(" type ");
-              Serial.print(gear_types[i]);
-              Serial.print(", orientation ");
-              Serial.println(gear_orientations[i]);
-            }
-          }
-        }
-
-        if (debug_state > 0)
-        {
-          for (int i=0; i<3; i++)
-          {
-            Serial.print("history ");
-            Serial.print(i);
-            Serial.print(":");
-            for (int j=0; j<=last_selector_pos; j++)
-            {
-              Serial.print(" ");
-              Serial.print(photoresistor_history[i][j]);
-            }
-            Serial.println("");
+            printGearRead(i, false);
           }
         }

@@ -220,8 +199,6 @@

         if (failed)
         {
-          // Or should we say you failed calibration, not an error?
-          sendCastleErrorMessage();
           state = 0;
           resetLights();
         }
@@ -284,8 +261,6 @@
     resetLights();
   }

-  // TODO(benkraft): How do we exit state 3?  When the button is pressed?
-
   last_selector_pos = selector_pos;
 }

@@ -299,10 +274,17 @@
 boolean computeGearPosition(int i)
 {
   // Hold on tight; this is kinda bespoke and messy.
+
+  // First, figure out what, on average, we saw.
+  int photoresistor_history[7];
   int positions_white = 0;
   for (int j=0; j<7; j++)
   {
-    positions_white += photoresistor_history[i][j];
+    photoresistor_history[j] = (
+      photoresistor_totals[i][j] / photoresistor_counts[i][j]
+      < photoresistor_thresholds[i]);
+
+    positions_white += photoresistor_history[j];
   }

   // If we saw 2 white, they should be in 1, 4 or 2, 5, and that means we have
@@ -310,12 +292,12 @@
   if (positions_white == 2)
   {
     gear_types[i] = 1;
-    if (photoresistor_history[i][1] && photoresistor_history[i][4])
+    if (photoresistor_history[1] && photoresistor_history[4])
     {
       gear_orientations[i] = 1;
       return true;
     }
-    else if (photoresistor_history[i][2] && photoresistor_history[i][5])
+    else if (photoresistor_history[2] && photoresistor_history[5])
     {
       gear_orientations[i] = 2;
       return true;
@@ -330,8 +312,8 @@
   // 1, in position 0.
   else if (positions_white == 3)
   {
-    if (photoresistor_history[i][0] && photoresistor_history[i][3]
-        && photoresistor_history[i][6])
+    if (photoresistor_history[0] && photoresistor_history[3]
+        && photoresistor_history[6])
     {
       gear_types[i] = 1;
       gear_orientations[i] = 0;
@@ -347,8 +329,8 @@
   // 0 in position 1.
   else if (positions_white == 4)
   {
-    if (!photoresistor_history[i][0] && !photoresistor_history[i][3]
-        && !photoresistor_history[i][6])
+    if (!photoresistor_history[0] && !photoresistor_history[3]
+        && !photoresistor_history[6])
     {
       gear_types[i] = 0;
       gear_orientations[i] = 1;
@@ -366,31 +348,31 @@
   // respectively.
   else if (positions_white == 5)
   {
-    if (!photoresistor_history[i][1] && !photoresistor_history[i][4])
+    if (!photoresistor_history[1] && !photoresistor_history[4])
     {
       gear_types[i] = 0;
       gear_orientations[i] = 2;
       return true;
     }
-    else if (!photoresistor_history[i][2] && !photoresistor_history[i][5])
+    else if (!photoresistor_history[2] && !photoresistor_history[5])
     {
       gear_types[i] = 0;
       gear_orientations[i] = 0;
       return true;
     }
-    else if (!photoresistor_history[i][0] && !photoresistor_history[i][4])
+    else if (!photoresistor_history[0] && !photoresistor_history[4])
     {
       gear_types[i] = 2;
       gear_orientations[i] = 2;
       return true;
     }
-    else if (!photoresistor_history[i][1] && !photoresistor_history[i][5])
+    else if (!photoresistor_history[1] && !photoresistor_history[5])
     {
       gear_types[i] = 2;
       gear_orientations[i] = 3;
       return true;
     }
-    else if (!photoresistor_history[i][2] && !photoresistor_history[i][6])
+    else if (!photoresistor_history[2] && !photoresistor_history[6])
     {
       gear_types[i] = 2;
       gear_orientations[i] = 0;
@@ -405,7 +387,7 @@
   // If we saw 1 black, it should be in 3, and we have gear 2 in position 2.
   else if (positions_white == 6)
   {
-    if (!photoresistor_history[i][3])
+    if (!photoresistor_history[3])
     {
       gear_types[i] = 2;
       gear_orientations[i] = 1;
@@ -591,7 +573,6 @@

 void printState()
 {
-  // TODO(benkraft): internal state too?
   // print out position of the pot
   Serial.print("pot: ");
   Serial.println(getSelectorGearPosition());
@@ -600,7 +581,7 @@
   for (int i=0; i<3; i++)
   {
     Serial.print(" ");
-    Serial.print(getPhotoresistor(i));
+    Serial.print(getRawPhotoresistor(i));
     Serial.print(" (");
     Serial.print(analogRead(photoresistors[i]));
     Serial.print(")");
@@ -612,21 +593,7 @@
   Serial.print("last selector pos: ");
   Serial.println(last_selector_pos);

-  if (state == 1)
-  {
-    for (int i=0; i<3; i++)
-    {
-      Serial.print("history ");
-      Serial.print(i);
-      Serial.print(":");
-      for (int j=0; j<=last_selector_pos; j++)
-      {
-        Serial.print(" ");
-        Serial.print(photoresistor_history[i][j]);
-      }
-      Serial.println("");
-    }
-  }
+  // history gets printed when we finish it

   if (state == 2)
   {
@@ -646,19 +613,49 @@
 }

+void printGearRead(int i, boolean failed)
+{
+  if (debug_state > 0)
+  {
+    Serial.print("GEAR ");
+    Serial.print(i);
+    if (failed)
+    {
+      Serial.println(" none");
+    }
+    else
+    {
+      Serial.print(" type ");
+      Serial.print(gear_types[i]);
+      Serial.print(", orientation ");
+      Serial.println(gear_orientations[i]);
+    }
+
+    for (int i=0; i<3; i++)
+    {
+      Serial.print("history ");
+      Serial.print(i);
+      Serial.print(":");
+      for (int j=0; j<=last_selector_pos; j++)
+      {
+        Serial.print(" ");
+        Serial.print(photoresistor_totals[i][j]);
+        Serial.print("/");
+        Serial.print(photoresistor_counts[i][j]);
+      }
+      Serial.println("");
+    }
+  }
+}
+
+
 // INPUT READING

-// True if white gear is in front of photo resistor.  False if black paper.
-// Undefined if gear not lodged.
-boolean getPhotoresistor(int i)
-{
-  // sees white gear
-  if(analogRead(photoresistors[i]) > photoresistor_thresholds[i])
-  {
-    return true;
-  }
-  // sees black paper
-  return false;
+// Raw value of the photoresistor.  We'll average this over time
+// to figure out what it sees.
+int getRawPhotoresistor(int i)
+{
+  return analogRead(photoresistors[i]);
 }

 // based on the pot value, we know which of the 7 positions the selector gear is in


change ArduinoPhoneCode.ino to ArduinoPhone.ino

--- ArduinoPhoneCode.ino
+++ ArduinoPhoneCode.ino
@@ -1,696 +0,0 @@
-#include <SeeedTouchScreen.h>
-#include "UI_ArduinoPhone.h"
-#include <stdint.h>
-#include <MsTimer2.h>
-#include <SoftwareSerial.h>
-#include "phone.h"
-#include <TimerOne.h>
-#include <Wire.h>
-#include "UI_ArduinoPhone_dfs.h"
-
-#include <TFTv2.h>
-#include <SPI.h>
-
-
-
-// serial data
-char serialDta[100];
-unsigned char serialDtaCnt = 0;     // when use data, it shoule be changed to zero(0)
-bool serialGot  = false;            // when use data, it shoule be changed to false
-
-// serial event
-void __serialEvent()
-{
-    disableTimer();         // disable timer irq
-    while (Serial.available()) {
-
-        char inChar = (char)Serial.read();
-        serialDta[serialDtaCnt++]= inChar;
-        if (inChar == '\n') {
-            serialGot = true;
-            serialDta[serialDtaCnt] = '\0';
-            break;
-        }
-    }
-    enableTimer();          // enable timer irq
-}
-
-
-int strdo(char *str)
-{
-    int sum = 0;
-    //str_get(str);
-    while(*(str)<'A' || *(str)>'Z')str++;
-
-    if(*(str+12)>'0' && *(str+12)<'9')// >10
-    {
-        sum = (*(str+11)-'0')*10 + (*(str+12)-'0');
-    }
-    else
-    sum = (*(str+11)-'0');
-
-    return sum;
-}
-
-
-//const unsigned char __numAbc[10][6] PROGMEM =
-char __numAbc[10][5] =
-{
-    {' ', '0', ' ', ' ', ' '},
-    {',', '.', '!', '1', ' '},
-    {'a', 'b', 'c', '2', ' '},
-    {'d', 'e', 'f', '3', ' '},
-    {'g', 'h', 'i', '4', ' '},
-    {'j', 'k', 'l', '5', ' '},
-    {'m', 'n', 'o', '6', ' '},
-    {'p', 'q', 'r', 's', '7'},
-    {'t', 'u', 'v', '8', ' '},
-    {'w', 'x', 'y', 'z', '9'},
-};
-
-//const unsigned char __numAbcBit[10] PROGMEM =
-unsigned char __numAbcBit[10] =
-{
-    2, 4, 4, 4, 4, 4, 4, 5, 4, 5
-};
-
-// test if call in or msg in , return 0:  return : break;  stateNow, state
-bool checkMsgCall(unsigned char stateNow)
-{
-    if(Phone.isMsg(serialDta))
-    {
-        UI.state_buf = stateNow;
-        UI.state     = ST_GETSMS;
-
-        serialGot    = false;
-        serialDtaCnt = 0;
-        UI.msgReadCodeMax = strdo(serialDta);
-        //UI.msgReadNewMsg = 1; // get new msg
-        return true;
-    }
-
-    if(Phone.isCall(serialDta))
-    {
-        serialGot    = false;
-        serialDtaCnt = 0;
-        UI.state_buf = stateNow;
-        UI.state     = ST_GETCALL;
-        return true;
-    }
-
-    serialGot    = false;
-    serialDtaCnt = 0;
-    return 0;
-}
-//state machine
-
-long time1 = 0;
-void stateMachine()
-{
-    switch(UI.state)
-    {
-        //***************************************main page*************************
-        case ST_TIME:
-
-        Tft.fillScreen();
-        UI.getTime();
-        UI.drawTimeDate(25, 90);
-        UI.showMainPage();
-        time1 = millis();
-        while(1)
-        {
-            // get call
-            long time = millis();
-            if(time - time1 > 1000)
-            {
-                time1 = time;
-                UI.getTime();
-                if(UI.minute != UI.minute_buf)
-                {
-                    UI.drawTimeDate(25, 90);
-                }
-            }
-            if(serialGot)
-            {
-                disableTimer();
-#if I2CUART
-                UI.I2C_Uart(serialDta);
-#endif
-                if(checkMsgCall(ST_TIME)){ enableTimer();break;}
-                enableTimer();
-
-            }
-
-            if(UI.isTouch())// get touch
-            {
-
-                if(UI.getTouchRect(12, 200, 112, 270))   // phone
-                {
-                    UI.state        = ST_CALL;
-                    UI.state_buf    = ST_TIME;
-                    break;
-                }
-                else if(UI.getTouchRect(128, 200, 228, 270))  // sms
-                {
-                    UI.state        = ST_MSG;
-                    UI.state_buf    = ST_TIME;
-                    break;
-                }
-            }
-        }
-
-        break;
-
-        //***************************************phone*****************************
-        case ST_CALL:
-
-        if(UI.state_buf == ST_MSG)
-        {
-            UI.drawDialogBox();
-            UI.showCall();
-        }
-        else
-        {
-            Tft.fillScreen();
-            UI.drawDialogBox();
-            UI.showPageKB();
-            UI.showCall();
-        }
-
-        while(1)
-        {
-            if(UI.isTouch())
-            {
-                while(1)
-                {
-                    stateCall();
-
-                    if(serialGot){
-#if I2CUART
-                        UI.I2C_Uart(serialDta);
-#endif
-                        if(checkMsgCall(ST_CALL))break;
-                    }
-                    if(UI.state != ST_CALL)break;
-                }
-            }
-            if(serialGot){
-                disableTimer();
-#if I2CUART
-                UI.I2C_Uart(serialDta);
-#endif
-                if(checkMsgCall(ST_CALL)){enableTimer();break;}
-                enableTimer();
-            }
-
-            // check if call in or msg
-
-            if(UI.state != ST_CALL)break;
-        }
-
-        UI.callCount = 0;
-
-        break;
-
-        //***************************************make phone calling***************
-        case ST_CALLING:
-        Tft.fillScreen();
-        Tft.drawString("calling...", 20, 100, 3, WHITE);
-        Tft.fillRectangle(10, 200, 230, 50, GRAY1);
-        Tft.drawString("HANDUP", 20, 215, 3, RED);
-        while(1)
-        {
-            if(UI.getTouchRect(10, 200, 240, 250))// hand up
-            {
-                Phone.handUpCall();
-                UI.state     = UI.state_buf;
-                UI.state_buf = ST_CALLING;
-                break;
-            }
-
-            // serial get data
-            if(serialGot)
-            {
-                disableTimer();
-#if I2CUART
-                UI.I2C_Uart(serialDta);
-#endif
-                if(Phone.isCallOver(serialDta))
-                {
-                    UI.state     = UI.state_buf;
-                    UI.state_buf = ST_CALLING;
-                    enableTimer();
-                    break;
-                }
-                serialGot    = false;
-                serialDtaCnt = 0;
-                enableTimer();
-                delay(1);
-            }
-
-        }
-
-        Tft.drawString("calling...", 20, 100, 3, BLACK);
-        Tft.fillRectangle(10, 200, 230, 50, BLACK);
-        Tft.drawString("HANDUP", 20, 215, 3, BLACK);
-
-        break;
-        //***************************************get call*************************
-        case ST_GETCALL:
-
-        Tft.fillScreen();
-        Tft.drawString("calling...", 20, 100, 2, WHITE);
-        Tft.fillRectangle(10, 200, 100, 50, GRAY1);
-        Tft.fillRectangle(130, 200, 100, 50, GRAY1);
-        Tft.drawString("ACCEPT", 15, 215, 2, GREEN);
-        Tft.drawString("HANDUP", 135, 215, 2, RED);
-        while(1)
-        {
-            // serial get data
-            if(serialGot)
-            {
-                disableTimer();
-#if I2CUART
-                UI.I2C_Uart(serialDta);
-#endif
-                if(Phone.isCallOver(serialDta))
-                {
-                    UI.state     = UI.state_buf;
-                    UI.state_buf = ST_GETCALL;
-                    enableTimer();
-                    break;
-                }
-                serialGot    = false;
-                serialDtaCnt = 0;
-                enableTimer();
-            }
-
-            if(UI.getTouchRect(10, 200, 110, 250))// accept
-            {
-                Phone.acceptCall();
-                Tft.drawString("calling...", 20, 100, 2, BLACK);
-                Tft.drawString("call connected!", 20, 100, 2, WHITE);
-                Tft.drawString("call connected!", 20, 100, 2, BLACK);
-            }
-
-            // hand up
-            if(UI.getTouchRect(130, 200, 230, 250)) // hand up
-            {
-                UI.state     = UI.state_buf;
-                UI.state_buf = ST_GETCALL;
-                Phone.handUpCall();
-                break;
-            }
-
-        }
-
-        Tft.fillRectangle(10, 200, 100, 50, BLACK);
-        Tft.fillRectangle(130, 200, 100, 50, BLACK);
-
-        break;
-        //***************************************message***************************
-        case ST_MSG:
-
-
-        if(UI.state_buf == ST_CALL)
-        {
-            UI.drawMsgDialogBox();
-            UI.showMsg();
-        }
-        else
-        {
-            Tft.fillScreen();
-            UI.showPageKB();
-            UI.drawMsgDialogBox();
-            UI.showMsg();
-        }
-
-        while(1)
-        {
-            if(UI.isTouch())
-            {
-                while(1)
-                {
-                    stateMsg();
-                    if(UI.state != ST_MSG)break;
-                    if(serialGot)
-                    {
-                        disableTimer();
-#if I2CUART
-                        UI.I2C_Uart(serialDta);
-#endif
-                        if(checkMsgCall(ST_MSG)){enableTimer();break;}
-                        enableTimer();
-                    }
-                }
-            }
-            if(serialGot)
-            {
-                disableTimer();
-#if I2CUART
-                UI.I2C_Uart(serialDta);
-#endif
-                if(checkMsgCall(ST_MSG)){enableTimer();break;}
-                enableTimer();
-            }
-            if(UI.state != ST_MSG)break;
-        }
-
-        UI.msgCount     = 0;
-        UI.msgNumCount  = 0;
-
-
-        break;
-
-        //***************************************message sending*******************
-        case ST_SENDSMS:
-
-        Tft.fillScreen();
-        Tft.drawString("SMS Sending", 20, 120, 3, WHITE);
-        while(1)
-        {
-            // delay(1000);
-            if(Phone.isMsgSendOver())
-            {
-                UI.state_buf = ST_SENDSMS;
-                UI.state     = ST_MSG;
-                break;
-            }
-        }
-        Tft.drawString("SMS Sending", 20, 120, 3, BLACK);
-
-        break;
-        //**************************************get msg******************************
-        case ST_GETSMS:
-
-        UI.drawReadMsgPage();
-        // get new msg
-
-        Serial.print("AT+CMGR=");Serial.println(UI.msgReadCodeMax, DEC);
-        UI.msgReadCodeNow = UI.msgReadCodeMax;
-
-        while(1)
-        {
-            stateMsgRead();
-            if(UI.state != ST_GETSMS)
-            break;
-        }
-
-        break;
-
-        default:
-        ;
-    }
-}
-
-// state: phone call
-
-
-void stateCall()
-{
-    unsigned char button = 0;
-    long timercall = millis();
-    UI.getTouch(&button);
-    long t = millis();
-    if(button>0 && button<10)
-    {
-
-        UI.callAdd(button);
-    }
-    else if(button == 11)
-    {
-        long deltT = t - timercall;
-
-        if((UI.callCount < 1) && (deltT>400))
-        {
-            UI.callAdd(15);
-        }
-        else UI.callAdd(0);
-    }
-    else if(button == 12)
-    {
-        UI.callDel();
-    }
-    else if(button == 10)// call
-    {
-        Phone.makeCall();
-        UI.callCount = 0;
-        UI.state_buf = ST_CALL;
-        UI.state     = ST_CALLING;
-    }
-    else if(button == TOUCH_DRAG_LEFT)
-    {
-        UI.state_buf = ST_CALL;
-        UI.state     = ST_MSG;
-    }
-    else if(button == TOUCH_DRAG_RIGHT)
-    {
-        UI.state_buf = ST_CALL;
-        UI.state     = ST_TIME;
-    }
-}
-
-// state: message
-void stateMsg()
-{
-    long time =  millis();
-    long time1 = time;
-    unsigned char buttonNum     = 100;
-    unsigned char buttonNumBuf  = 100;
-
-    int count = 0;
-    unsigned char button = 0;
-
-    char let2[4] = {'a', 'b', 'c', '4'};
-
-    if(!UI.isTouch())return;
-
-    while(1)
-    {
-        long time1 = millis();
-
-        unsigned char msgState = UI.getMsgInputState();
-
-        if(msgState == 1)
-        {
-            UI.state_msg = MSG_STATE_NUM;
-            //  UI.I2C_Uart("state = NUM\r\n");
-            delay(100);
-            button = 0;
-        }
-        else if(msgState == 2)
-        {
-            UI.state_msg = MSG_STATE_TXT;
-            //  UI.I2C_Uart("state = TXT\r\n");
-            delay(100);
-            button = 0;
-        }
-        else
-        {
-            //  UI.I2C_Uart("get in getTouch\r\n");
-            button = UI.getTouch(&button);
-            //   UI.I2C_Uart("get out getTouch\r\n");
-        }
-
-
-
-        // input txt
-
-        if(button == TOUCH_DRAG_LEFT)
-        {
-            UI.state_buf = ST_MSG;
-            UI.state     = ST_GETSMS;
-            break;
-        }
-        else if(button == TOUCH_DRAG_RIGHT)
-        {
-            UI.state_buf = ST_MSG;
-            UI.state     = ST_CALL;
-            break;
-        }
-        else if(button>0 && button<10)
-        {
-            if(UI.state_msg == MSG_STATE_TXT)
-            {
-                buttonNum    = button;
-                UI.msgAdd(__numAbc[buttonNum][count % __numAbcBit[buttonNum]], RED);
-                count++;
-                time = time1;
-            }
-            else
-            {
-                buttonNum = button;
-                UI.msgNumAdd(buttonNum);
-                buttonNum = 100;
-            }
-        }
-        else if(button == 11)//0
-        {
-            if(UI.state_msg == MSG_STATE_TXT)
-            {
-                buttonNum = 10;
-                UI.msgAdd(__numAbc[0][count % __numAbcBit[0]], RED);
-                count++;
-                time = time1;
-            }
-            else
-            {
-                long t = millis();
-                long deltT = t - time1;
-
-                if(deltT > 500 && UI.msgNumCount == 0)
-                UI.msgNumAdd(15);
-                else
-                UI.msgNumAdd(0);
-                buttonNum = 100;
-            }
-        }
-        else if(button == 12) // del
-        {
-            if(UI.state_msg == MSG_STATE_TXT)
-            UI.msgDel();
-            else
-            UI.msgNumDel();
-            break;
-        }
-        else if(button == 10)       // send
-        {
-            Phone.msgSend();
-            UI.state_buf  =  ST_MSG;
-            UI.state      =  ST_SENDSMS;
-            break;
-        }
-
-        if(((time1 - time) > 600)&& UI.state_msg == MSG_STATE_TXT)
-        {
-            if(buttonNum>0 && buttonNum<10)UI.msgAdd(__numAbc[buttonNum][(count-1) % __numAbcBit[buttonNum]]);
-            else if(buttonNum == 10)UI.msgAdd(__numAbc[0][(count-1) % 2]);
-            break;
-        }
-    }
-}
-
-// state read msg
-void stateMsgRead()
-{
-    unsigned char button  = 0;
-    unsigned char button1 = 0;
-    unsigned char cnt = 0;
-    unsigned flag_getMsgTime = 0;
-    char s[20];
-    while(1)
-    {
-        if(serialGot)
-        {
-            disableTimer();
-#if I2CUART
-            UI.I2C_Uart(serialDta);
-            delay(5);
-#endif
-            if(flag_getMsgTime == 1)// get msg
-            {
-#if I2CUART
-                int sss = UI.getReadMsgMsg(serialDta);
-#else
-                UI.getReadMsgMsg(serialDta);
-#endif
-
-#if I2CUART
-                sprintf(s, "txt long = %d\r\n", sss);
-                UI.I2C_Uart(s);
-                delay(5);
-                UI.I2C_Uart("\r\ntxt:\t");
-                delay(5);
-                UI.I2C_Uart(UI.msgReadTxt);
-                delay(5);
-                UI.I2C_Uart("\r\n");
-#endif
-
-                UI.drawReadMsg();
-                flag_getMsgTime = 0;
-            }
-            else if(UI.getReadMsgTimeAndFrom(serialDta, UI.msgReadNum, UI.msgReadTime))
-            {
-#if I2CUART
-                UI.I2C_Uart("num:\t");
-                delay(5);
-                UI.I2C_Uart(UI.msgReadNum);
-                delay(5);
-                UI.I2C_Uart("\r\ndate:\t");
-                delay(5);
-                UI.I2C_Uart(UI.msgReadTime);
-                UI.I2C_Uart("\r\n");
-#endif
-                flag_getMsgTime = 1;
-            }
-
-            serialGot = false;
-            serialDtaCnt = 0;
-            enableTimer();
-        }
-
-        if(UI.isTouch())
-        {
-            if(UI.getTouchRect(0, 270, 239, 319))
-            {
-                //UI.state     = UI.state_buf;
-                UI.state     = UI.state_buf;
-                UI.state_buf = ST_GETSMS;
-                button1 = 0;
-                break;
-            }
-            else button1 = UI.getTouch(&button);
-        }
-        else button1 = 0;
-        //drag right: read format
-        if(button1 == TOUCH_DRAG_RIGHT)
-        {
-            button1 = 0;
-            cnt = 0;
-            if(UI.msgReadCodeNow>2)
-            UI.msgReadCodeNow--;
-            Serial.print("AT+CMGR=");Serial.println(UI.msgReadCodeNow, DEC);
-        }
-        //drag left: read <-- msg
-        else if(button1 == TOUCH_DRAG_LEFT)
-        {
-            cnt = 0;
-            button1 = 0;
-            //if(UI.msgReadCodeNow<UI.msgReadCodeMax && UI.msgReadCodeMax != 1)
-            UI.msgReadCodeNow++;
-            Serial.print("AT+CMGR=");Serial.println(UI.msgReadCodeNow, DEC);
-        }
-        // return
-
-    }
-}
-// setup
-void enableTimer()
-{
-    Timer1.attachInterrupt(__serialEvent);
-}
-
-void disableTimer()
-{
-    Timer1.detachInterrupt();
-}
-
-//setup
-void setup()
-{
-    Phone.init();
-    UI.init();
-    Wire.begin();
-    Timer1.initialize(10000);                // 10 ms
-    Timer1.attachInterrupt(__serialEvent);   // attach the service routine here
-}
-
-// loop
-void loop()
-{
-    stateMachine();
-}
-
-/*********************************************************************************************************
-  END FILE
-*********************************************************************************************************/


Make client compatible with new brew monitor server

Trying things out with Grails because I'm a millennial software developer
and that means I'm fickle about my technology choices.

--- src/TempGauge/TempGauge.ino
+++ src/TempGauge/TempGauge.ino
@@ -21,6 +21,7 @@
 #define     READING_DELAY_SECS     10     // Number of seconds to wait between readings.
 #define     TIMEOUT_MS             15000  // How long to wait (in milliseconds) for a server connection to respond
 #define     SERVER                "fremont"
+#define     PORT                  8080

 #define MAX_DS1820_SENSORS 1
 byte addr[8];
@@ -143,7 +144,7 @@
   Serial.println("");

   Serial.print(F("Opening TCP connection... "));
-  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 9200);
+  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 8080);
   if (client.connected()) {
     Serial.println(F("done."));

@@ -153,8 +154,9 @@
     body += currentTemp;
     body += F("}");

-    String head = F("POST /temp_gauge/reading HTTP/1.1\r\n"
-    "Host: fremont:9200\r\n"
+    String head = F("POST /thermReadings HTTP/1.1\r\n"
+    "Host: fremont:8080\r\n"
+    "Content-Type: application/json\r\n"
     "Content-Length: ");
     head += body.length();
     head += F("\r\n\r\n");
@@ -175,7 +177,7 @@

   // Read data until either the connection is closed, or the idle timeout is reached.
   unsigned long lastRead = millis();
-  Serial.println(F("Elasticsearch response: "));
+  Serial.println(F("Server response: "));
   while (client.connected() && (millis() - lastRead < TIMEOUT_MS)) {
     while (client.available()) {
       char c = client.read();


Fix reset button's use of the internal AVR pull-up resistor

--- moros/moros.ino
+++ moros/moros.ino
@@ -1,6 +1,5 @@
 /*
 * TODO:
-* reset button (chronos style?) - P1
 * time setting - P1
 * case - P1
 * wiring diagram - P2 S3
@@ -43,6 +42,7 @@
     pressed_at(0),
     pin_number(pin_number_) {
     pinMode(pin_number, INPUT);
+    digitalWrite(pin_number, HIGH); // connect the internal pull-up resistor
   };

   // returns the number of ms for which the button has been held down
@@ -50,7 +50,7 @@
     int pin_status = digitalRead(pin_number);
     // serprintf("PollButton::poll: status is %d (%s)\r\n", pin_status, pin_status == HIGH ? "high" : "not high");

-    if (pin_status == HIGH) {
+    if (pin_status == LOW) {
       if (!pressed) {
         pressed_at = millis();
         pressed = true;
@@ -59,7 +59,7 @@

       //serprintf("pressed_at=%lu, millis=%lu\r\n", pressed_at, millis());
       return millis()-pressed_at;
-    } else if (pin_status == LOW) {
+    } else if (pin_status == HIGH) {
       if (pressed)
         serprintf("PollButton::poll: released\r\n");
       pressed = false;


adding inside display code

adding inside display code

--- 900MHZ_ESP8266_INDOOR_WEATHER_DISPLAY/ESP8266_RFM69_ILI9341.ino
+++ 900MHZ_ESP8266_INDOOR_WEATHER_DISPLAY/ESP8266_RFM69_ILI9341.ino
@@ -101,6 +101,7 @@
   Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
   Serial.println(" MHz");
   tft.begin();
+  tft.setRotation(3);
 }

@@ -122,7 +123,224 @@
       theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else

-      Serial.print("soiltempf: ");
+
+
+
+
+
+
+
+
+
+
+float Windchill = 35.74 + 0.6215*theData.soiltempf - 35.75*pow(theData.windspeedmph,0.16) + 0.4275*theData.soiltempf*pow(theData.windspeedmph,0.16);
+
+
+
+  tft.setTextSize(2);
+  tft.setCursor(0,226);
+  tft.println("(MON) 11/11/16  08:34:12AM");
+
+
+  tft.setTextSize(2);
+  tft.setCursor(0,0);
+  tft.println("Feels Like:   Temperature:");
+
+  tft.setCursor(0,20);
+  tft.setTextSize(6);
+
+
+
+  if(round(Windchill) <= 32) {
+    tft.setTextColor(ILI9341_BLUE);
+    tft.print(round(Windchill));
+  } else if (round(Windchill) > 32 && round(Windchill) <= 88) {
+    tft.setTextColor(ILI9341_WHITE);
+    tft.print(round(Windchill));
+  } else if (round(Windchill) > 88) {
+    tft.setTextColor(ILI9341_RED);
+    tft.print(round(Windchill));
+  } else {
+    tft.setTextColor(ILI9341_YELLOW);
+    tft.print("err");
+  }
+
+
+
+
+
+
+
+  tft.setTextSize(2);
+  tft.println((char)247);
+
+
+
+
+  tft.setTextSize(8);
+
+  switch (String(round(theData.soiltempf)).length()) {
+    case 1:
+      tft.setTextColor(ILI9341_WHITE);
+      tft.setCursor(218,20);
+      tft.print(round(theData.soiltempf));
+      tft.setTextSize(3);
+      tft.println((char)247);
+      break;
+    case 2:
+      tft.setTextColor(ILI9341_WHITE);
+      tft.setCursor(183,20);
+      tft.print(round(theData.soiltempf));
+      tft.setTextSize(3);
+      tft.println((char)247);
+      break;
+    case 3:
+      tft.setTextColor(ILI9341_WHITE);
+      tft.setCursor(157,20);
+      tft.print(round(theData.soiltempf));
+      tft.setTextSize(3);
+      tft.println((char)247);
+
+      break;
+    default:
+      tft.setTextColor(ILI9341_WHITE);
+      tft.setCursor(0,0);
+      tft.print("err");
+    break;
+  }
+/////////////////////////////////
+//                 left top
+//      tft.setCursor(0,0);
+/////////////////////////////////
+  tft.setCursor(185,89);
+  tft.setTextSize(2);
+  tft.print("Rain (24h):");
+  tft.setCursor(183,110);
+  tft.setTextSize(3);
+  if(theData.rainin >= 10) {
+    theData.rainin=theData.rainin+.05;
+    tft.print(theData.rainin, 1);
+  } else {
+    theData.rainin=theData.rainin+.005;
+    tft.print(theData.rainin, 2);
+  }
+  tft.print("in.");
+
+  tft.setCursor(0,80);
+  tft.setTextSize(2);
+  tft.print("Wind Speed:");
+  tft.setTextSize(4);
+  tft.setCursor(0,100);
+  if(theData.windspeedmph >= 100) {
+    tft.print(round(theData.windspeedmph));
+  } else if (theData.windspeedmph >= 10) {
+    theData.windspeedmph=theData.windspeedmph+.05;
+    tft.print(theData.windspeedmph, 1);
+  } else {
+    theData.windspeedmph=theData.windspeedmph+.005;
+    tft.print(theData.windspeedmph, 2);
+  }
+  tft.print("mph");
+
+
+
+
+
+
+  tft.setCursor(0,140);
+  tft.setTextSize(2);
+  tft.print("W Dir:");
+  tft.setTextSize(4);
+
+
+  switch (theData.winddir)
+  {
+    case 0:
+    tft.setCursor(20,160);
+      tft.print("N");
+      break;
+    case 45:
+    tft.setCursor(5,160);
+      tft.print("NE");
+      break;
+    case 90:
+    tft.setCursor(20,160);
+      tft.print("E");
+      break;
+    case 135:
+    tft.setCursor(5,160);
+      tft.print("SE");
+      break;
+    case 180:
+    tft.setCursor(20,160);
+      tft.print("S");
+      break;
+    case 225:
+    tft.setCursor(5,160);
+      tft.print("SW");
+      break;
+    case 270:
+    tft.setCursor(20,160);
+      tft.print("W");
+      break;
+    case 315:
+    tft.setCursor(0,160);
+      tft.print("NW");
+      break;
+    default:
+    tft.setCursor(0,160);
+      tft.print("eR");
+      // if nothing else matches, do the
+      // default (which is optional)
+  }
+
+  tft.setCursor(90,140);
+  tft.setTextSize(2);
+  tft.print("Forcast:");
+  tft.setCursor(90,165);
+  tft.setTextSize(3);
+  tft.print("H:");
+//  tft.print(round(fHgh));
+  tft.setTextSize(2);
+  tft.print((char)247);
+  tft.setTextSize(3);
+  tft.print(" L:");
+//  tft.print(round(fLow));
+  tft.setTextSize(2);
+  tft.println((char)247);
+  tft.setCursor(90,190);
+  tft.print("Rain Today");
+
+  //tft.setCursor(0,207);
+  //tft.print("Some extra text goes here!");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /*     Serial.print("soiltempf: ");
       Serial.println(theData.soiltempf);

       Serial.print("humidity: ");
@@ -168,7 +386,7 @@

       Serial.print("dailyrainin: ");
       Serial.println(theData.dailyrainin);
-
+*/
     }
   }


Make ready message format compatible.

Make ready message format compatible.

--- brotherKH930_arduino.ino
+++ brotherKH930_arduino.ino
@@ -6,7 +6,7 @@
 void setup() {
   Serial.begin(115200);
   brother.start();
-  Serial.println("Ready.");
+  Serial.println("*\tReady");

   for (int i=0; i<200; i++)
     brother.needle(0, false);


Control 7 LEDs via light level.

Control 7 LEDs via light level.

--- 7/shift/shift.ino
+++ 7/shift/shift.ino
@@ -6,6 +6,7 @@
 int latchPin = 5;
 int clockPin = 6;
 int dataPin = 4;
+int lightPin = A0;

 byte leds = 0;

@@ -14,6 +15,8 @@
   pinMode(latchPin, OUTPUT);
   pinMode(dataPin, OUTPUT);
   pinMode(clockPin, OUTPUT);
+  pinMode(lightPin, INPUT);
+  Serial.begin(9600);
 }

 void updateShiftRegister()
@@ -27,12 +30,11 @@
 {
   leds = 0;
   updateShiftRegister();
-  delay(500);
-  for (int i = 0; i < 8; i++)
+  /* delay(500); */
+  for (int i = 0; i < map(analogRead(lightPin), 40, 115, 0, 7); i++)
   {
     bitSet(leds, i);
     updateShiftRegister();
-    delay(500);
   }
 }


Remove unused library import

Remove unused library import

--- arduino/ws2812_controller_esp8266/ws2812_controller_esp8266.ino
+++ arduino/ws2812_controller_esp8266/ws2812_controller_esp8266.ino
@@ -1,6 +1,5 @@
 #include <Arduino.h>
 #include <ESP8266WiFi.h>
-#include <Hash.h>
 #include <WiFiUdp.h>
 #include <NeoPixelBus.h>


Added code in order to allow substring_reader function to return NULL when there isn't any data between start_char and terminator.

--- Drones/Drones.ino
+++ Drones/Drones.ino
@@ -207,12 +207,14 @@
   int counter=0;
   int array_length=0;
   while(src[counter]!=start_char) counter++;//Wait until find the start_char
+  counter++;//Can remove this line by using advanced approach?
   if(src[counter]==NULL) return NULL;//Counldn't find the start_char? Return NULL!
   while(src[counter]!=terminator){
     temp[array_length]=src[counter];
     counter++;
     array_length++;
   }
+  if(array_length==0) return NULL;//Can remove this line by using advanced approach?
   char* result=(char*)malloc(sizeof(char) * array_length);
   for(int i=0;i<array_length;i++) result[i]=temp[i];
   free(temp);


swap pm10 and pm2.5 (#88)

swap pm10 and pm2.5 (#88)

--- files/template_home_wifi_feinstaub/template_home_wifi_feinstaub.ino
+++ files/template_home_wifi_feinstaub/template_home_wifi_feinstaub.ino
@@ -260,8 +260,8 @@
     pm25 = 0;
     pm10 = 0;
   }
+  addValue(pm10);
   addValue(pm25);
-  addValue(pm10);

   submitValues();


Fix bugs regarding fading animations, thanks sticilface

--- ESP8266HueEmulator/ESP8266HueEmulator.ino
+++ ESP8266HueEmulator/ESP8266HueEmulator.ino
@@ -2,6 +2,10 @@
  * Emulate Philips Hue Bridge ; so far the Hue app finds the emulated Bridge and gets its config
  * and switch on 3 NeoPixels with it so far (TODO)
  **/
+
+// TODO: Change SSDP to get rid of local copies of ESP8266SSDP use the new scheme from the Arduino IDE instead
+// https://github.com/esp8266/Arduino/commit/f5ba04d46c0b6df75348f005e68411a856f89e48
+// can then get rid of the SSDP.update();

 #include <ESP8266WiFi.h>
 #include <ESP8266WebServer.h>
@@ -145,10 +149,9 @@
       AnimUpdateCallback animUpdate = [ = ](float progress)
       {
         // progress will start at 0.0 and end at 1.0
-        HslColor updatedColor = HslColor::LinearBlend(originalColor, white, (uint8_t)(255 * progress));
+        HslColor updatedColor = HslColor::LinearBlend(originalColor, white, progress);
         strip.SetPixelColor(numberOfTheLight, updatedColor);
       };
-      strip.SetPixelColor(numberOfTheLight, white); // For now we ignore the color (FIXME)
       animator.StartAnimation(numberOfTheLight, transitionTime, animUpdate);
     }
     if (onValue == false)
@@ -156,10 +159,9 @@
       AnimUpdateCallback animUpdate = [ = ](float progress)
       {
         // progress will start at 0.0 and end at 1.0
-        HslColor updatedColor = HslColor::LinearBlend(originalColor, black, (uint8_t)(255 * progress));
+        HslColor updatedColor = HslColor::LinearBlend(originalColor, black, progress);
         strip.SetPixelColor(numberOfTheLight, updatedColor);
       };
-      strip.SetPixelColor(numberOfTheLight, black);
       animator.StartAnimation(numberOfTheLight, transitionTime, animUpdate);
     }

@@ -192,6 +194,7 @@
   strip.Show();

   // Show that the NeoPixels are alive
+  delay(120); // Apparently needed to make the first few pixels animate correctly
   infoLight(white);

   Serial.begin(115200);


Keep state of light color and on/off state

--- ESP8266HueEmulator/ESP8266HueEmulator.ino
+++ ESP8266HueEmulator/ESP8266HueEmulator.ino
@@ -18,7 +18,6 @@
 #include <aJSON.h> // Replace avm/pgmspace.h with pgmspace.h there and set #define PRINT_BUFFER_LEN 4096 ################# IMPORTANT
 #include "xy.h"
 #include <math.h>
-

 #include "/secrets.h" // Delete this line and populate the following
 //const char* ssid = "********";
@@ -38,7 +37,10 @@
 NeoPixelBus strip = NeoPixelBus(pixelCount, pixelPin);
 NeoPixelAnimator animator(&strip); // NeoPixel animation management object

-// Determines wheter a client is already authorized
+RgbColor StripRgbColors[pixelCount]; // Holds all colors of the pixels on the strip even if they are off
+bool StripLightIsOn[pixelCount]; // Holds on/off information for all the pixels
+
+// Determines whether a client is already authorized
 bool isAuthorized = false;

 byte mac[6]; // MAC address
@@ -94,7 +96,7 @@
     aJsonObject *lights;
     aJson.addItemToObject(root, "lights", lights = aJson.createObject());
     for (int i = 1; i <= 8; i++) // FIXME: Why does this not work for more than 8?
-      addLightJson(lights, i);
+      addLightJson(lights, i, StripRgbColors[i-1]);
     aJsonObject *schedules;
     aJson.addItemToObject(root, "schedules", schedules = aJson.createObject());
     sendJson(root);
@@ -136,10 +138,19 @@
     // If multiple ones are submitted at once, the following convention is used: xy beats ct beats hue/sat
     // TODO: Implement this

-    // Default values in case the request does not send new ones
-    int hue = 10000; // 10000 is white
-    int sat = 254;
-    int bri = 254;
+    // Get values from the saved state in case the request does not send new ones
+    HsbColor savedHsb = HsbColor(StripRgbColors[numberOfTheLight]);
+    Serial.println("Retrieved saved HSB");
+    Serial.print("H=");
+    Serial.println(savedHsb.H);
+    Serial.print("S=");
+    Serial.println(savedHsb.S);
+    Serial.print("B=");
+    Serial.println(savedHsb.B);
+
+    int hue = floor(savedHsb.H * 182.04 * 360.0);
+    int sat = floor(savedHsb.S * 254);
+    int bri = floor(savedHsb.B * 254);

     // Read hue, sat, bri from pixel if available
     if (aJsonObject* hueState = aJson.getObjectItem(parsedRoot, "hue"))
@@ -151,6 +162,9 @@

     RgbColor rgb;
     rgb = hsb2rgb(hue, sat, bri);
+
+    // Set values in the saved state
+    StripRgbColors[numberOfTheLight] = rgb;

     aJson.deleteItem(parsedRoot);
     Serial.print("I should --> ");
@@ -165,6 +179,7 @@
         // progress will start at 0.0 and end at 1.0
         HslColor updatedColor = HslColor::LinearBlend(originalColor, rgb, progress);
         strip.SetPixelColor(numberOfTheLight, updatedColor);
+        StripLightIsOn[numberOfTheLight] = true; // Keep track of on/off state
       };
       animator.StartAnimation(numberOfTheLight, transitionTime, animUpdate);
     }
@@ -175,6 +190,7 @@
         // progress will start at 0.0 and end at 1.0
         HslColor updatedColor = HslColor::LinearBlend(originalColor, black, progress);
         strip.SetPixelColor(numberOfTheLight, updatedColor);
+        StripLightIsOn[numberOfTheLight] = false; // Keep track of on/off state
       };
       animator.StartAnimation(numberOfTheLight, transitionTime, animUpdate);
     }
@@ -257,6 +273,13 @@
   SSDP.setManufacturer((char*)"Royal Philips Electronics");
   SSDP.setManufacturerURL((char*)"http://www.philips.com");
   Serial.println("SSDP Started");
+
+  // Initialize all pixels to white
+  for (int i = 0; i < pixelCount; i++)
+  {
+    StripRgbColors[i] = RgbColor(white);
+  }
+
 }

 void loop() {
@@ -357,7 +380,7 @@
   aJsonObject *state;
   aJson.addItemToObject(light, "state", state = aJson.createObject());
   unsigned int brightness = rgb.CalculateBrightness();
-  if (brightness == 0)
+  if (StripLightIsOn[numberOfTheLight-1] == false)
     aJson.addBooleanToObject(state, "on", false);
   else
     aJson.addBooleanToObject(state, "on", true);
@@ -474,23 +497,23 @@

   Serial.println("1.: H, S, B");

-  Serial.print("H = ");
-  Serial.println(hsb.H);
-  Serial.print("S = ");
-  Serial.println(hsb.S);
-  Serial.print("B = ");
-  Serial.println(hsb.B);
+  //  Serial.print("H = ");
+  //  Serial.println(hsb.H);
+  //  Serial.print("S = ");
+  //  Serial.println(hsb.S);
+  //  Serial.print("B = ");
+  //  Serial.println(hsb.B);

   Serial.println("2.: Convert to hue, sat, bri");
   hue = floor(hsb.H * 182.04 * 360.0);
   sat = floor(hsb.S * 254);
   bri = floor(hsb.B * 254);
-  Serial.print("hue = ");
-  Serial.println(hue);
-  Serial.print("sat = ");
-  Serial.println(sat);
-  Serial.print("bri = ");
-  Serial.println(bri);
+  //  Serial.print("hue = ");
+  //  Serial.println(hue);
+  //  Serial.print("sat = ");
+  //  Serial.println(sat);
+  //  Serial.print("bri = ");
+  //  Serial.println(bri);

   hsb.H = hue;
   hsb.S = sat;
@@ -502,35 +525,35 @@
 RgbColor hsb2rgb(int hue, int sat, int bri)
 {
   Serial.println("Running hsb2rgb");
-  Serial.println("1.: hue, sat, bri");
-  Serial.print("hue = ");
-  Serial.println(hue);
-  Serial.print("sat = ");
-  Serial.println(sat);
-  Serial.print("bri = ");
-  Serial.println(bri);
+  //  Serial.println("1.: hue, sat, bri");
+  //  Serial.print("hue = ");
+  //  Serial.println(hue);
+  //  Serial.print("sat = ");
+  //  Serial.println(sat);
+  //  Serial.print("bri = ");
+  //  Serial.println(bri);

   Serial.println("2.: Convert to H, S, L");
   float H, S, B;
   H = hue / 182.04 / 360.0;
-  Serial.print("H = ");
-  Serial.println(H);
+  //  Serial.print("H = ");
+  //  Serial.println(H);
   S = sat / 254.0; // I changed this
-  Serial.print("S = ");
-  Serial.println(S);
+  //  Serial.print("S = ");
+  //  Serial.println(S);
   B = bri / 254.0; // I changed this as well
-  Serial.print("B = ");
-  Serial.println(B);
+  //  Serial.print("B = ");
+  //  Serial.println(B);
   HsbColor hsb = HsbColor(H, S, B);

   Serial.println("3.: Convert to RgbColor");
   RgbColor rgb = RgbColor(hsb);
-  Serial.print("R = ");
-  Serial.println(rgb.R);
-  Serial.print("G = ");
-  Serial.println(rgb.G);
-  Serial.print("B = ");
-  Serial.println(rgb.B);
+  //  Serial.print("R = ");
+  //  Serial.println(rgb.R);
+  //  Serial.print("G = ");
+  //  Serial.println(rgb.G);
+  //  Serial.print("B = ");
+  //  Serial.println(rgb.B);

   return rgb;
 }


Changes Syr variable declaration to Syren10

Syren10 is used elsewhere in the code instead of SyR. Errors otherwise.

--- padawan360_body/padawan360_body_mega_i2c_ino/padawan360_body_mega_i2c.ino
+++ padawan360_body/padawan360_body_mega_i2c_ino/padawan360_body_mega_i2c.ino
@@ -93,7 +93,7 @@

 /////////////////////////////////////////////////////////////////
 Sabertooth Sabertooth2x(128, Serial1);
-Sabertooth SyR(128, Serial2);
+Sabertooth Syren10(128, Serial2);

 // Satisfy IDE, which only needs to see the include statment in the ino.
 #ifdef dobogusinclude


updates

updates

--- BitController/BitController.ino
+++ BitController/BitController.ino
@@ -17,8 +17,8 @@

 #include <SoftwareSerial.h>
-#define BT_SERIAL_TX_DIO 10
-#define BT_SERIAL_RX_DIO 11
+#define BT_SERIAL_TX_DIO 2
+#define BT_SERIAL_RX_DIO 3

 SoftwareSerial BT(BT_SERIAL_TX_DIO, BT_SERIAL_RX_DIO);

@@ -66,9 +66,9 @@

   delay(1000);

-  n_base = analogRead(north) - 150;
-  w_base = analogRead(west) - 150;
-  e_base = analogRead(east) - 150;
+  n_base = analogRead(north) - 50;
+  w_base = analogRead(west) - 50;
+  e_base = analogRead(east) - 50;
   //s_base = analogRead(south) - 50;

 //  lcd.clear();
@@ -81,6 +81,16 @@
 //  delay(3000);
   //lcd.println(s_base);

+  BT.print("north: ");
+  BT.print(n_base);
+  BT.print("\t");
+  BT.print("west: ");
+  BT.print(w_base);
+  BT.print("\t");
+  BT.print("east: ");
+  BT.print(e_base);
+  BT.println();
+  BT.println();
 }

@@ -109,6 +119,17 @@

 void printSensors()
 {
+  BT.print("north: ");
+  BT.print(nVal);
+  BT.print("\t");
+  BT.print("west: ");
+  BT.print(wVal);
+  BT.print("\t");
+  BT.print("east: ");
+  BT.print(eVal);
+  BT.println();
+  BT.println();
+
 //  lcd.clear();
 //  lcd.setCursor(0,0);
 //  lcd.print("north ");
@@ -137,6 +158,7 @@
 {
   readSensors();
   printSensors();
+  //BT.println("hello world");
   move();
   //determineDirection();
   //drive(sensorVals[n], sensorVals[s], sensorVals[e], sensorVals[w]);
@@ -155,6 +177,7 @@
   {
     //go north
     //lcd.print("go north");
+    BT.print("go north");
     analogWrite(l1_motor, 255);
     analogWrite(l2_motor, 0);
     analogWrite(r1_motor, 255);
@@ -165,6 +188,7 @@
   {
     //go east
     //lcd.print("go east");
+    BT.print("go east");
     analogWrite(l1_motor, 255);
     analogWrite(l2_motor, 0);
     analogWrite(r1_motor, 0);
@@ -174,6 +198,7 @@
   {
     //go north east
     //lcd.print("go north-east");
+    BT.print("go north-east");
     analogWrite(l1_motor, 255);
     analogWrite(l2_motor, 0);
     analogWrite(r1_motor, 55);
@@ -184,16 +209,21 @@
     //some error
     //continue along previous path
     //lcd.print("don't know");
+    BT.print("don't know");
   }
   }
   else
   {
     //lcd.print("no signal");
+    BT.print("no signal");
     analogWrite(l1_motor, 0);
     analogWrite(l2_motor, 0);
     analogWrite(r1_motor, 0);
     analogWrite(r2_motor, 0);
   }
+
+  BT.println();
+  BT.println();
 }


Fix indent

Fix indent

--- examples/Boards_BLE/RedBearLab_BLE_Nano/RedBearLab_BLE_Nano.ino
+++ examples/Boards_BLE/RedBearLab_BLE_Nano/RedBearLab_BLE_Nano.ino
@@ -43,11 +43,11 @@

   ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
   ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
-                                        device_name, sizeof(device_name) - 1);
-
+                                         device_name, sizeof(device_name) - 1);
+
   ble.gap().setDeviceName(device_name);
   ble.gap().setTxPower(4);
-
+
   // Add Blynk service...
   Blynk.begin(auth);