code moved to new repo

code moved to new repo

--- drone/WebServerESC/WebServerESC.ino
+++ drone/WebServerESC/WebServerESC.ino
@@ -1,223 +0,0 @@
-/*
- * Allows control of an Electronic Speed Controller (ESC) via a web server.
- * The request happens through a GET http method.
- */
-
-#include <avr/pgmspace.h>
-#include <Servo.h>
-#include <WiServer.h>
-
-byte armed = 0;
-
-#define WIRELESS_MODE_INFRA	1
-#define WIRELESS_MODE_ADHOC	2
-
-// Wireless configuration parameters ----------------------------------------
-unsigned char local_ip[] = {192,168,16,110};	// IP address of WiShield
-unsigned char gateway_ip[] = {192,168,16,254};	// router or gateway IP address
-unsigned char subnet_mask[] = {255,255,255,0};	// subnet mask for the local network
-const prog_char ssid[] PROGMEM = {"MP01"};		// max 32 bytes
-
-unsigned char security_type = 0;	// 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
-
-// WPA/WPA2 passphrase
-const prog_char security_passphrase[] PROGMEM = {"1872822821"};	// max 64 characters
-
-// WEP 128-bit keys
-// sample HEX keys
-prog_uchar wep_keys[] PROGMEM = { 0x83, 0x7A, 0xAF, 0x74, 0xEC,	// Key 0
-                                  0x5F, 0xE5, 0x65, 0x9F, 0xF2,	// Key 1
-                                  0x69, 0x61, 0x53, 0x1C, 0x51, // Key 2
-                                  0xB5, 0x6F, 0xBE, 0xCB, 0x6B,	// Key 3
-                                };
-
-// setup the wireless mode
-// infrastructure - connect to AP
-// adhoc - connect to another WiFi device
-unsigned char wireless_mode = WIRELESS_MODE_INFRA;
-
-unsigned char ssid_len;
-unsigned char security_passphrase_len;
-// End of wireless configuration parameters ----------------------------------------
-
-// Webpage in flash memory
-const prog_char htmlHead[] PROGMEM = {"<meta http-equiv=""content-type"" content=""text/html; charset=utf-8"" /><title>OneButtonAlert Device</title>"};
-const prog_char htmlMotor[] PROGMEM = {
-"<select name=""OPERATION"" id=""OPERATION"" style=""font-size:50px""><option value=""reset"">Reset Motors</option><option value=""arm"">Arm Motors</option><option value=""throttle25"">Throttle 25</option><option value=""throttle50"">Throttle 50</option><option value=""throttle75"">Throttle 75</option></select>
<input type=submit value=SUBMIT style=""font-size:50px"">
</form>

"};
-
-// time of last arming
-unsigned long lastArmTime = 0;
-
-// wifi connection state
-U8 state = 0;
-
-// These are the motors
-Servo throttleMotor;
-Servo pitchMotor;
-Servo yawMotor;
-Servo rollMotor;
-
-/*
-Servo angle : PWM range
-40 : 0    - 1230
-60 : 1231 - 1360
-70 : 1361 - 1490
-90 : 1491 - 1620
-100: 1621 - 1749
-120: 1750 +
-*/
-// speed is 0-100
-int servoAngleForSpeed(int speed)
-{
-    return map(speed, 0, 100, 40, 120);
-}
-
-// This is our page serving function that generates web pages
-boolean sendMyPage(char* URL)
-{
-    // Check if the requested URL matches "/"
-    if (strcmp(URL, "/") == 0) {
-        _webpageHelper();
-        // URL was recognized
-        return true;
-    }
-
-    if (strcmp (URL, "/?OPERATION=reset") == 0) {
-        resetMotors();
-        _webpageHelper();
-        return (true);
-    }
-
-    if (strcmp (URL, "/?OPERATION=arm") == 0) {
-        arm();
-        _webpageHelper();
-        return (true);
-    }
-
-    if (strcmp (URL, "/?OPERATION=throttle25") == 0) {
-        throttleMotor.write(servoAngleForSpeed(25));
-        _webpageHelper();
-        return (true);
-    }
-
-    if (strcmp (URL, "/?OPERATION=throttle50") == 0) {
-        throttleMotor.write(servoAngleForSpeed(50));
-        _webpageHelper();
-        return (true);
-    }
-
-    if (strcmp (URL, "/?OPERATION=throttle75") == 0) {
-        throttleMotor.write(servoAngleForSpeed(75));
-        _webpageHelper();
-        return (true);
-    }
-
-
-
-    Serial.println("url not found");
-    // URL not found
-    return false;
-}
-
-void resetMotors()
-{
-    throttleMotor.write(servoAngleForSpeed(0));
-    yawMotor.write(servoAngleForSpeed(50));
-    rollMotor.write(servoAngleForSpeed(50));
-    pitchMotor.write(servoAngleForSpeed(50));
-}
-
-void setup()
-{
-     // Required for I/O from Serial monitor
-    Serial.begin(57600);
-
-    Serial.println("Starting WiFi");
-     // Initialize WiServer and have it use the sendMyPage function to serve pages
-    WiServer.init(sendMyPage);
-
-
-    rollMotor.attach(6);
-    yawMotor.attach(7);
-    throttleMotor.attach(8);
-    pitchMotor.attach(9);
-
-    WiServer.enableVerboseMode(true);
-
-    Serial.println("setting all channels at resting state");
-    resetMotors();
-    delay(5000);
-
-    arm();
-
-    /*
-    Serial.println("setting throttle to 25");
-    throttleMotor.write(servoAngleForSpeed(25));
-    */
-
- }
-
-void loop()
-{
-    U8 newState = WiServer.getConnectionState();
-
-    if(newState != state) {
-        state = newState;
-    }
-
-    if(!state) {
-        WiServer.init(sendMyPage);
-    }
-
-    // Run WiServer
-    WiServer.server_task();
-    delay(10);
-}
-
-void _webpageHelper()
-{
-    WiServer.print_P(htmlHead);
-
-    WiServer.print ("
");
-    WiServer.print ("Device Local IP Address Status
");
-    WiServer.print ("");
-    WiServer.print (local_ip[0], DEC);
-    WiServer.print (".");
-    WiServer.print (local_ip[1]), DEC;
-    WiServer.print (".");
-    WiServer.print (local_ip[2], DEC);
-    WiServer.print (".");
-    WiServer.print (local_ip[3], DEC);
-    WiServer.print ("
");
-
-    if (armed) {
-        WiServer.print("
<form> Engine Motor - ON
");
-        WiServer.print("<method=GET>");
-        WiServer.print_P(htmlMotor);
-    }
-    else {
-        WiServer.print("
<form> Engine Motor - OFF
");
-        WiServer.print("<method=GET>");
-        WiServer.print_P(htmlMotor);
-    }
-
-    WiServer.print ("
");
-}
-
-void arm()
-{
-    unsigned long now = millis();
-
-    // don't try rearming if we already tried earlier, this will confusing the APM
-    if(now - lastArmTime < 6000) {
-         return;
-    }
-
-    Serial.println("arming");
-    throttleMotor.write(servoAngleForSpeed(0));
-    yawMotor.write(servoAngleForSpeed(130));
-    delay(5000);
-    resetMotors();
-    armed = 1;
-    lastArmTime = now;
-}


adding todo notes

adding todo notes

--- firmware/beer/beersensor.ino
+++ firmware/beer/beersensor.ino
@@ -1,3 +1,16 @@
+/*
+TODO
+  * Persist data to SVRAM
+  * track more than one tap (pin)
+  * change LED color over range of full -> empty
+  * calibration mode
+  * API endpoints:
+    * reset
+    * get data
+    * set tap name
+    * animation (beer) type
+
+*/
 // This #include statement was automatically added by the Particle IDE.
 #include "neopixel/neopixel.h"


Clean up

Clean up

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -88,11 +88,11 @@

 		// If tag is removed, go back to scan state
 		if (!isValidResponse) {
-      pollCounter++;
-      if (pollCounter == 1) {
-        state = 0;
-        pollCounter = 0;
-      }
+      		pollCounter++;
+      		if (pollCounter == 1) {
+        		state = 0;
+        		pollCounter = 0;
+      		}
 		}
 	}
 	else {


make holdms on servo a constant, lowered it to 800 from 900

--- Lifter/Lifter.ino
+++ Lifter/Lifter.ino
@@ -45,6 +45,7 @@
 const int proxSense2 = 620;                 // threshold for OPB606A showing a card riding on fan housing
 const int proxSense3 = 900;                 // below this a passenger card is still engaged
 const int liftSenseTop = 740;               // above threshold nothing is close to face of OPB606A
+const int HOLDms = 800;                     // this long to get to extremes of servo travel, then relax
 const long int hoverArmPos = 15;            // pick up postion after zeroing against armLimit
 const long int firstArmPos = 120;           // experimentally determined drop-off position
 const long int secondArmPos = 220;          // 2nd drop (less frequent) and max Arm travel
@@ -76,7 +77,7 @@
 AccelStepper stepperLift(AccelStepper::DRIVER, PINST2_ST, PINST2_DIR);

 const long int liftUpToTop = -200000;     // arbitrary rise until limit switch hit.
-long int liftBackOff = 500;              // back off the switch; zero is limit-switch position
+long int liftBackOff = 500;              // steps to back off the switch; zero is limit-switch position

 Servo myserv;

@@ -203,7 +204,7 @@
     stepperArm.run();

     // first character sent switches us into LOADED mode
-    // 97="a", 98="b", 99="c", 100="d"
+    // 97="a", 98="b", 99="c", 100="d", 120="x"
     if (Serial.available() > 0) {
       inputString = String(Serial.read());
       if (!LOADED) {
@@ -252,7 +253,7 @@
   currentServoPos = myserv.read();

   // after allowing time for travel, check stress levels...
-  if (((currentTime - timeStart) > 900)) {
+  if (((currentTime - timeStart) > HOLDms)) {
     if (currentServoPos == (drop + extraServoBump)) {
         restServoPos = drop;
         stressedServo = true;
@@ -277,7 +278,7 @@
               myserv.write(suck - extraServoBump);
               timeStart = currentTime;
    }
-  else if (stressedServo && ((currentTime - timeStart) > 900)) {
+  else if (stressedServo && ((currentTime - timeStart) > HOLDms)) {
     myserv.write(restServoPos);
     if (DEBUG)
       Serial.println("go to resting spot: " + String(restServoPos));


split out function for better reading

split out function for better reading

--- testing/arduino/self-driving-v4.ino
+++ testing/arduino/self-driving-v4.ino
@@ -24,7 +24,7 @@
 const uint8_t rangeLimit_Warning3 = 25;
 const uint8_t rangeLimit_Stop = 15;

-const uint16_t rangeLimit_RotateFor = 250;
+const uint16_t rangeLimit_RotateFor = 500;
 unsigned long rangeLimit_Timestamp = 0;

 bool wheelSpinCompleted = true;
@@ -178,6 +178,17 @@
     return servoPos;
 }

+void SetLightByRange(long range)
+{
+    uint32_t color = LEDStrip.Color(0, 255, 0);
+    if(range < rangeLimit_Warning1) { color = LEDStrip.Color(127, 255, 0);}
+    if(range < rangeLimit_Warning2) { color = LEDStrip.Color(255, 255, 0); }
+    if(range < rangeLimit_Warning3) { color = LEDStrip.Color(255, 127, 0); }
+    if(range < rangeLimit_Stop) { color = LEDStrip.Color(255, 0, 0); }
+
+    ColorSet(color);
+}
+

 void loop()
 {
@@ -192,21 +203,15 @@
         return;
     }

-    uint8_t motorSpeed = 1 * 255;
-    uint32_t color = LEDStrip.Color(0, 255, 0);
-    if(range < rangeLimit_Warning1) { color = LEDStrip.Color(127, 255, 0);}
-    if(range < rangeLimit_Warning2) { color = LEDStrip.Color(255, 255, 0); }
-    if(range < rangeLimit_Warning3) { motorSpeed = 0.8 * 255; color = LEDStrip.Color(255, 127, 0); }
-    if(range < rangeLimit_Stop) { color = LEDStrip.Color(255, 0, 0); }
-
-    ColorSet(color);
+    SetLightByRange(range);
+

     // obstacle is further away than X cm
     if(wheelSpinCompleted && range > rangeLimit_Stop)
     {
         // drive
-        SetMotor(motorPin1_1, motorPin1_2, motorSpeed);
-        SetMotor(motorPin2_1, motorPin2_2, motorSpeed);
+        SetMotor(motorPin1_1, motorPin1_2, 255);
+        SetMotor(motorPin2_1, motorPin2_2, 255);

         rangeLimit_Timestamp = millis();
     }


squeeze out a few more flash and ram bytes for ATtiny

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -27,6 +27,7 @@
 #define SERIAL_BAUD 38400   // can only be 9600 or 38400
 #define DATAFLASH   0       // do not change
 #undef  LED_PIN             // do not change
+#define rf12_configDump()   // disabled
 #else
 #define TINY        0
 #define SERIAL_BAUD 57600   // adjust as needed
@@ -123,6 +124,10 @@
 #endif
 }

+static void printOneChar (char c) {
+    Serial.print(c);
+}
+
 /// @details
 /// For the EEPROM layout, see http://jeelabs.net/projects/jeelib/wiki/RF12demo
 /// Useful url: http://blog.strobotics.com.au/2009/07/27/rfm12-tutorial-part-3a/
@@ -162,7 +167,7 @@
         showNibble(value >> 4);
         showNibble(value);
     } else
-        Serial.print((int) value);
+        Serial.print(value);
 }

 static uint16_t calcCrc (const void* ptr, uint8_t len) {
@@ -188,15 +193,10 @@
     config.crc = calcCrc(&config, sizeof config - 2);
     eeprom_write_block(&config, RF12_EEPROM_ADDR, sizeof config);

-#if !TINY
     if (rf12_configSilent())
         rf12_configDump();
     else
         showString(INITFAIL);
-#else
-    if (!rf12_configSilent())
-        showString(INITFAIL);
-#endif
 }

 static byte bandToFreq (byte band) {
@@ -321,7 +321,7 @@
         if (c == 0)
             break;
         if (c == '\n')
-            showString(PSTR("\r"));
+            printOneChar('\r');
         Serial.print(c);
     }
 }
@@ -354,8 +354,8 @@
     if ('a' <= c && c <= 'z') {
         showString(PSTR("> "));
         for (byte i = 0; i < top; ++i) {
-            Serial.print((int) stack[i]);
-            showString(PSTR(","));
+            Serial.print(stack[i]);
+            printOneChar(',');
         }
         Serial.print(value);
         Serial.println(c);
@@ -423,7 +423,7 @@
             for (byte i = 0; i < RF12_MAXDATA; ++i)
                 testbuf[i] = i + testCounter;
             showString(PSTR("test "));
-            Serial.println((int) testCounter); // first byte in test buffer
+            Serial.println(testCounter); // first byte in test buffer
             ++testCounter;
             break;

@@ -494,9 +494,9 @@
             // 127 is the desired value to be posted stack[0] contains the
             // target node and value contains the command to be posted
             if ((!stack[0]) && (!value)) {
-                Serial.print((int)postingsIn);
-                showString(PSTR(","));
-                Serial.println((int)postingsOut);
+                Serial.print(postingsIn);
+                printOneChar(',');
+                Serial.println(postingsOut);
                 nodesShow();
             } else if (stack[0] != (config.nodeId & RF12_HDR_MASK) &&
                     stack[0] <= MAX_NODES && value < 255 &&
@@ -593,7 +593,7 @@

 static void displayASCII (const uint8_t* data, byte count) {
     for (byte i = 0; i < count; ++i) {
-        showString(PSTR(" "));
+        printOneChar(' ');
         char c = (char) data[i];
         Serial.print(c < ' ' || c > '~' ? '.' : c);
     }
@@ -608,9 +608,9 @@
 }

 void setup () {
-    delay(100); // shortened for now. Particularly handy with JeeNode Micro V1
-                //                    where ISP interaction can be upset by RF12B
-                //                    startup process.
+    delay(100); // shortened for now. Handy with JeeNode Micro V1 where ISP
+                // interaction can be upset by RF12B startup process.
+
 #if TINY
     PCMSK0 |= (1<<PCINT2);  // tell pin change mask to listen to PA2
     GIMSK    |= (1<<PCIE0); // enable PCINT interrupt in general interrupt mask
@@ -635,24 +635,25 @@
         saveConfig();
         rf12_configSilent();
     }
+
+    rf12_configDump();

-#if !TINY
-    rf12_configDump();
-#endif
-
     // Initialise node table
+    Serial.print("Node Table:");
     for (byte i = 1; i <= MAX_NODES; i++) {
         nodes[i] = eeprom_read_byte(RF12_EEPROM_ADDR + (i * RF12_EEPROM_SIZE));
         // http://forum.arduino.cc/index.php/topic,140376.msg1054626.html
         if (nodes[i] != 0xFF)
             nodes[i] = 0;       // Indicate no post waiting for node!
-    }
+        Serial.print(nodes[i]);
+    }
+    Serial.println();

     // Prevent allocation of this nodes number.
     nodes[(config.nodeId & RF12_HDR_MASK)] = 0;

+    df_initialize();
 #if !TINY
-    df_initialize();
     showHelp();
 #endif
 }
@@ -662,9 +663,9 @@
 void nodesShow() {
     for (byte i = 1; i <= MAX_NODES; i++) {
         if (nodes[i] != 0xFF) { // Entry 0 is unused at present
-            Serial.print((int) i);
-            showString(PSTR("("));
-            Serial.print((int) nodes[i]);
+            Serial.print(i);
+            printOneChar('(');
+            Serial.print(nodes[i]);
             showString(PSTR(") "));
         }
     }
@@ -690,25 +691,25 @@
                 n = 20;
         }
         if (config.hex_output)
-            showString(PSTR("X"));
+            printOneChar('X');
         if (config.group == 0) {
             showString(PSTR(" G"));
             showByte(rf12_grp);
         }
-        showString(PSTR(" "));
+        printOneChar(' ');
         showByte(rf12_hdr);
         for (byte i = 0; i < n; ++i) {
             if (!config.hex_output)
-                showString(PSTR(" "));
+                printOneChar(' ');
             showByte(rf12_data[i]);
         }
 #if RF69_COMPAT
         // display RSSI value after packet data
         showString(PSTR(" ("));
         if (config.hex_output)
-                showByte(RF69::rssi);
+            showByte(RF69::rssi);
         else
-                Serial.print(-(RF69::rssi>>1));
+            Serial.print(-(RF69::rssi>>1));
         showString(PSTR(") "));
 #endif
         Serial.println();
@@ -725,10 +726,10 @@

         if (rf12_crc == 0) {
             activityLed(1);
-#if !TINY
+
             if (df_present())
                 df_append((const char*) rf12_data - 2, rf12_len + 2);
-#endif
+
             if (((rf12_hdr & (RF12_HDR_MASK | RF12_HDR_DST)) <= MAX_NODES) &&
                     // Source node packets only
                     (nodes[(rf12_hdr & RF12_HDR_MASK)] == 0xFF)) {
@@ -774,9 +775,9 @@
                         testCounter = 1;
                         showString(PSTR("Posted "));
                         showByte(rf12_hdr & RF12_HDR_MASK);
-                        showString(PSTR(","));
+                        printOneChar(',');
                         showByte(testbuf[0]);
-                        postingsOut++;                  // Count as delivered
+                        postingsOut++;
                         Serial.println();
                     }
                 }
@@ -791,7 +792,7 @@
         activityLed(1);

         showString(PSTR(" -> "));
-        Serial.print((int) sendLen);
+        Serial.print(sendLen);
         showString(PSTR(" b\n"));
         byte header = cmd == 'a' ? RF12_HDR_ACK : 0;
         if (dest)


Correct bug when nobody is acking, loop instead

--- examples/RF12/RF12tune/RF12tune.ino
+++ examples/RF12/RF12tune/RF12tune.ino
@@ -72,7 +72,7 @@
 byte h, w;

 void setup() {
-
+  delay(5000);  // Startup delay to debounce disconnection
   Serial.begin(SERIAL_BAUD);
   Serial.println("\n[RF12tune.0]");

@@ -120,6 +120,7 @@
         delay(50);
       }
   }
+  if ((upHigh == 0) || (upLow == 0xFFFF)) return;  // If nobody answers then restart loop
 Serial.print("Scan up complete ");
 Serial.print(upLow);
 Serial.print("-");
@@ -145,6 +146,7 @@
         delay(50);
       }
   }
+  if ((downHigh == 0) || (downLow == 0xFFFF)) return;  // If nobody answers then restart loop
 Serial.print("Scan down complete ");
 Serial.print(downLow);
 Serial.print("-");
@@ -154,6 +156,7 @@
  frequency = ( ((upLow + downLow) / 2) + ((((upHigh + downHigh) / 2) - ((upLow + downLow)/ 2)) / 2)   );
  Serial.print("Centre frequency offset is ");
  Serial.println(frequency);
+ delay(50);
  config.ee_frequency_hi = frequency >> 8;
  config.ee_frequency_lo = frequency & 0x00FF;

@@ -166,11 +169,13 @@
     byte b = ((byte*) &config)[i];
     eeprom_write_byte(RF12_EEPROM_ADDR + i, b);
   }
-  if (!rf12_config())
+  if (!rf12_config()) {
     Serial.println("config save failed");
-
-  byte good = probe(); // Transmit new settings
-
+  }
+  else {
+    delay(50);
+    byte good = probe(); // Transmit new settings
+  }
   while(1) // Nothing more
   {
      delay(32767);


Eliminate tabs

Eliminate tabs

--- libraries/ir_messaging/samples/ir_rx_sniff/ir_rx_sniff.ino
+++ libraries/ir_messaging/samples/ir_rx_sniff/ir_rx_sniff.ino
@@ -19,12 +19,12 @@
 const bool INVERT_IRRX_SIGNAL = true; //Depends on polarity of rx module

 #if (_HW_SELECTCONFIG == 1)
-	#define TIMER_IRRX 1                 //!*
-	IRRX_CREATE_TMR16B(irRx, TIMER_IRRX, PIN_IRRX, INVERT_IRRX_SIGNAL)
+   #define TIMER_IRRX 1                 //!*
+   IRRX_CREATE_TMR16B(irRx, TIMER_IRRX, PIN_IRRX, INVERT_IRRX_SIGNAL)
 #elif (_HW_SELECTCONFIG == 2)
-	// ***ATmega1280/2560 only***
-	#define TIMER_IRRX 4                 //!*
-	IRRX_CREATE_TMR16B(irRx, TIMER_IRRX, PIN_IRRX, INVERT_IRRX_SIGNAL)
+   // ***ATmega1280/2560 only***
+   #define TIMER_IRRX 4                 //!*
+   IRRX_CREATE_TMR16B(irRx, TIMER_IRRX, PIN_IRRX, INVERT_IRRX_SIGNAL)
 #endif
 //!*Must be #define-d to work with pre-processor macro


Removed mic pin

Removed mic pin

Removed it because the FreqCount class does not allow us to choose which pin the mic is attached to

--- 2018-Firefighter/2018-Firefighter.ino
+++ 2018-Firefighter/2018-Firefighter.ino
@@ -6,7 +6,6 @@
 #define RIGHT_SERVO_PIN 5
 #define IR_PIN 6
 #define EXTINGUISHER_PIN 7
-#define MIC_PIN 43
 #define FLAME_LED 9
 #define MIC_LED 11
 #define BABY_LED 17
@@ -111,7 +110,6 @@
   pinMode(IR_PIN, INPUT);
   pinMode(FLAME_LED, OUTPUT);

-  pinMode(MIC_PIN, INPUT);
   pinMode(MIC_LED, OUTPUT);

   pinMode(BABY_LED, OUTPUT);


Cleaned out unneeded functions

Cleaned out unneeded functions

--- Arduino/Node/Node.ino
+++ Arduino/Node/Node.ino
@@ -235,71 +235,6 @@
     return (char)(index + 64);
 }

-// int sendMessageBase(String message){
-	// //sends message to base
-	// //wait for response from base!!!!!!!!!!!!!!!!
-	// xbee.listen();
-
-	// //To check
-	// int responseCount = 0;
-	// String baseResponse;
-	// while(responseCount < 5){
-		// xbee.println(message);
-		// baseResponse = getBaseMessage();
-		// if(baseResponse != NULL){
-			// break;
-		// }
-		// delay(10);
-		// responseCount++;
-	// }
-
-	// uint8_t total = -1;
-
-	// if(responseCount >= 5){
-		// DEBUG_PRINTLN(F("getBaseMessage() timed out!"));
-		// //total = -1;
-	// }
-	// else{
-		// if(baseResponse != NULL){
-			// uint8_t start = 0;
-			// uint8_t end = baseResponse.indexOf(',');
-			// String target = baseResponse.substring(start, end);
-
-			// start = end + 1;
-			// end = baseResponse.indexOf(',', start);
-			// total = baseResponse.substring(start, end).toInt();
-
-			// DEBUG_PRINTLN("Target Node:  " + String(target));
-			// DEBUG_PRINTLN("Number: " + String(total));
-		// }
-		// else{
-			// DEBUG_PRINTLN("Base Response = NULL");
-		// }
-	// }
-    // //DEBUG_PRINT("This is what sendMessageBase returns: ");
-    // //DEBUG_PRINTLN(total);
-    // //delay(2000);
-    // return total;
-// }
-
-
-// String getBaseMessage() {
-
-  // xbee.listen();
-  // String xResponse = xbeeResponse();
-  // uint8_t start = 0;
-  // uint8_t end = xResponse.indexOf(',');
-  // String targetNode = xResponse.substring(start, end);
-  // if(targetNode.equals(nodeId)){
-	// return xResponse;
-  // }
-  // else{
-	// return NULL;
-  // }
-// }
-
-
-
 // Timeout Functions
 // ========================================
 unsigned long _timeout_end = 0;


Set Speed of stepper motor in RPM.

Set Speed of stepper motor in RPM.

This could be the cause of the stepper motor problems we were having yesterday. I will test the motor to find out.

--- software/Arduino/ServoController/ServoController.ino
+++ software/Arduino/ServoController/ServoController.ino
@@ -30,9 +30,11 @@

 int stepperPins[] = {9, 10, 11, 12};
 int numSteps = 200;
+int stepperRPM = 20;
 float stepSize = 9.0 / 5.0;

 Stepper azimuth(numSteps, stepperPins[0], stepperPins[1], stepperPins[2], stepperPins[3]);
+azimuth.setSpeed(stepperRPM);
 // ============ Runtime variables ========================
 // Orientation data
 float positionChange;


Fixed clapMeter

Fixed clapMeter

--- sketches/clapMeter/clapMeter.ino
+++ sketches/clapMeter/clapMeter.ino
@@ -1,15 +1,29 @@
+/*
+  The circuit:
+  * A connect to digital 2
+  * B connect to digital 3
+  * C connect to digital 4
+  * D connect to digital 5
+  * OE connect to digital 6
+  * STB connect to digital 10
+  * R1 connect to digital 11
+  * CLK connect to digital 13
+  * GND connect to GND
+*/
+
+
 #include <SoftwareSerial.h>
+#include <SPI.h>
+#include "bars.h"
+#include "words.h"

 #define SOUND_SENSOR A0
 #define SOUND_SENSOR_2 A2
-#define GREEN 2      // the number of the LED pin
-#define RED 3
-#define THRESHOLD_GREEN 200//The threshold to turn the led on 400.00*5/1024 = 1.95v
-#define THRESHOLD_RED 500
+#define THRESHOLD_FAIL 200//The threshold to turn the led on 400.00*5/1024 = 1.95v
+#define THRESHOLD_GOOD 400
+#define THRESHOLD_WIN 600
 #define LCD_OUT 8

-#include <SPI.h>
-#include "bars.h"

 #define RowA 2
 #define RowB 3
@@ -24,31 +38,6 @@

 byte *hz;

-byte hz1[] =
-{
-  //[16*16]
-0x00,0x00,
-0x04,0x80,
-0x04,0x80,
-0x05,0xFE,
-0x09,0x02,
-0x0A,0x04,
-0x18,0x20,
-0x28,0x20,
-0x08,0xA8,
-0x08,0xA4,
-0x09,0x24,
-0x09,0x22,
-0x0A,0x22,
-0x08,0x20,
-0x08,0xE0,
-0x00,0x00,
-  //[16*16]
-0x00,0x00,0x10,0x00,0x11,0xF8,0x10,0x08,0x7C,0x10,0x24,0x20,0x24,0x20,0x25,0xFC,
-0x44,0x20,0x24,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x24,0x20,0x40,0xE0,0x00,0x00
-};
-
-
 int sensorValue;

 int average;
@@ -67,190 +56,177 @@
      int normValue = value/DBNORM;
      normValue = min(normValue*2,32);
      if (normValue == 0){
-      hz = zero;
+      hz = zero;
      }
      else if (normValue == 1){
-      hz = one;
+      hz = one;
      }
      else if (normValue == 2){
-      hz = two;
+      hz = two;
      }
      else if (normValue == 3){
-      hz = three;
+      hz = three;
      }
      else if (normValue == 4){
-      hz = four;
+      hz = four;
      }
      else if (normValue == 5){
-      hz = five;
+      hz = five;
      }
      else if (normValue == 6){
-      hz = six;
+      hz = six;
      }
      else if (normValue == 7){
-      hz = seven;
+      hz = seven;
      }
      else if (normValue == 8){
-      hz = eight;
+      hz = eight;
      }
      else if (normValue == 9){
-      hz = nine;
+      hz = nine;
      }
      else if (normValue == 10){
-      hz = ten;
+      hz = ten;
      }
      else if (normValue == 11){
-      hz = eleven;
+      hz = eleven;
      }
      else if (normValue == 12){
-      hz = twelve;
+      hz = twelve;
      }
      else if (normValue == 13){
-      hz = thirteen;
+      hz = thirteen;
      }
      else if (normValue == 14){
-      hz = fourteen;
+      hz = fourteen;
      }
      else if (normValue == 15){
-      hz = fifteen;
+      hz = fifteen;
      }
      else if (normValue == 16){
-      hz = sixteen;
+      hz = sixteen;
      }
      else {
-      hz = sixteen;
-     }
-
-
-
-     //Serial.println(hz.size);
-
-
-/**
-     for (int i=0;i<64;i++){
-     	 if (i<normValue){
-     	     hz1[i] = ~0xFF;
-     }
-         else if(i>32 && i<normValue+32){
-     	     hz1[i] = ~0xFF;
-     	 }
-         else{
-             hz1[i] = ~0x00;
-         }
-
-	 }
-  */
-
-
+      hz = sixteen;
+     }
 }
 void setup()
 {

-
+
     Serial.begin(9600);
     pins_init();
-    //Serial.println("HHHA");
+
     pinMode(LCD_OUT, OUTPUT);
     lcd.begin(9600);
-
     lcd_init();
-    lcd.print("HOLA");
-
-     pinMode(RowA, OUTPUT);
-     pinMode(RowB, OUTPUT);
-     pinMode(RowC, OUTPUT);
-     pinMode(RowD, OUTPUT);
-     pinMode(OE, OUTPUT);
-     pinMode(R1, OUTPUT);
-     pinMode(CLK, OUTPUT);
-     pinMode(STB, OUTPUT);
-     SPI.begin();
-     delay(10);
+
+    pinMode(RowA, OUTPUT);
+    pinMode(RowB, OUTPUT);
+    pinMode(RowC, OUTPUT);
+    pinMode(RowD, OUTPUT);
+    pinMode(OE, OUTPUT);
+    pinMode(R1, OUTPUT);
+    pinMode(CLK, OUTPUT);
+    pinMode(STB, OUTPUT);
+    SPI.begin();
+    delay(10);

 }

 void loop()
 {
-
+
     sensor = analogRead(SOUND_SENSOR);
     sensor_2 = analogRead(SOUND_SENSOR_2);

-//    sensor = 300;
-//    sensor_2 = 300;
     if(min(sensor,sensor_2) > 0)
     {
         sensorValue = max(sensor, sensor_2);
         setHistogram(sensorValue);
-  //SPI.begin();
-  //delay(100);
-
-  for(row=0;row<16;row++){
-       for (int i=0;i<2;i++){
-         SPI.transfer(~(hz[i*32+row*2]));
-         SPI.transfer(~(hz[i*32+row*2+1]));
-  }
-  digitalWrite(OE,HIGH);
-  hc138sacn(row);
-  digitalWrite(STB,LOW);
-  digitalWrite(STB,HIGH);
-  delayMicroseconds(500);
-  digitalWrite(OE,LOW);
-  delayMicroseconds(500);
-
-  }
-
-  Serial.print("sensorValue ");
-  Serial.println(sensorValue);
-
-    if(sensorValue > THRESHOLD_GREEN)
+
+        for(row=0;row<16;row++){
+            for (int i=0;i<2;i++){
+                SPI.transfer(~(hz[i*32+row*2]));
+                SPI.transfer(~(hz[i*32+row*2+1]));
+            }
+            digitalWrite(OE,HIGH);
+            hc138sacn(row);
+            digitalWrite(STB,LOW);
+            digitalWrite(STB,HIGH);
+            delayMicroseconds(500);
+            digitalWrite(OE,LOW);
+            delayMicroseconds(500);
+        }
+
+        if(sensorValue > THRESHOLD_FAIL)
         {
-            turnOnLED(GREEN);
-
-            if(counter==0){
-                //Serial.println("********************* INICIO APLAUSOMETRO");
-            }
             clapMeterOn = true;
             clapMeter = clapMeter + sensorValue;
             counter++;
         }
-        if(sensorValue > THRESHOLD_RED)
-        {
-            turnOnLED(RED);
-        }
-        //delay(500);
-        turnOffLEDS();
-
-    if (clapMeterOn == true && sensorValue < 50)
-    {
+   }
+   if (clapMeterOn == true && sensorValue < 50)
+   {
         average = clapMeter/counter;
         clapMeterOn = false;
-        //Serial.println("HA SALIDO ===============> ");
-        //Serial.println(average);
-        lcd_blink(average);
+        if (average >= THRESHOLD_WIN)
+        {
+            Serial.println("WIN");
+            for (row=0;row<16;row++){
+                for (int i=0;i<2;i++){
+                    SPI.transfer(~(win[i*32+row*2]));
+                    SPI.transfer(~(win[i*32+row*2+1]));
+                }
+                digitalWrite(OE,HIGH);
+                hc138sacn(row);
+                digitalWrite(STB,LOW);
+                digitalWrite(STB,HIGH);
+                delayMicroseconds(500);
+                digitalWrite(OE,LOW);
+                delayMicroseconds(500);
+            }
+        } else if (average >= THRESHOLD_GOOD){
+            Serial.println("GOOD");
+            for (row=0;row<16;row++){
+                for (int i=0;i<2;i++){
+                    SPI.transfer(~(good[i*32+row*2]));
+                    SPI.transfer(~(good[i*32+row*2+1]));
+                }
+                digitalWrite(OE,HIGH);
+                hc138sacn(row);
+                digitalWrite(STB,LOW);
+                digitalWrite(STB,HIGH);
+                delayMicroseconds(500);
+                digitalWrite(OE,LOW);
+                delayMicroseconds(500);
+            }
+         } else {
+            Serial.println("FAIL");
+            for (row=0;row<16;row++){
+                for (int i=0;i<2;i++){
+                    SPI.transfer(~(fail[i*32+row*2]));
+                    SPI.transfer(~(fail[i*32+row*2+1]));
+                }
+                digitalWrite(OE,HIGH);
+                hc138sacn(row);
+                digitalWrite(STB,LOW);
+                digitalWrite(STB,HIGH);
+                delayMicroseconds(500);
+                digitalWrite(OE,LOW);
+                delayMicroseconds(500);
+            }
+        }
+
         counter = 0;
         clapMeter = 0;
-        //delay(1000);
     }
-    }

 }

 void pins_init()
 {
-    pinMode(GREEN, OUTPUT);
-    pinMode(RED, OUTPUT);
     pinMode(SOUND_SENSOR, INPUT);
-}
-
-void turnOnLED(int led)
-{
-    digitalWrite(led,HIGH);
-}
-
-void turnOffLEDS()
-{
-    digitalWrite(RED,LOW);
-    digitalWrite(GREEN,LOW);
 }

 void lcd_init()


removed the now-obsolete TimingAnalysis.ino example

--- examples/TimingAnalysis/TimingAnalysis.ino
+++ examples/TimingAnalysis/TimingAnalysis.ino
@@ -1,288 +0,0 @@
-/*
-   An example of how to use the Timing Statistics Playground functions.
-   This Sketch is basically NonInterruptBeatDetector.ino plus
-   Timing Statistics calls.
-
-   See https://www.pulsesensor.com to get started.
-
-   Copyright World Famous Electronics LLC - see LICENSE
-   Contributors:
-     Joel Murphy, https://pulsesensor.com
-     Yury Gitman, https://pulsesensor.com
-     Bradford Needham, @bneedhamia, https://bluepapertech.com
-
-   Licensed under the MIT License, a copy of which
-   should have been included with this software.
-
-   This software is not intended for medical use.
-*/
-#include <PulseSensorPlayground.h>
-
-/*
-   Non-interrrupt code for reading from the PulseSensor
-   can be sensitive to the other code you add to your loop().
-   In some cases, this sensitivity can cause errors in the Beat Detector's
-   measurements.
-
-   Use the Timing Statistics functions to measure how much
-   your Sketch's time-per-PulseSensor sample is affected by the rest of
-   your Sketch's code.
-
-   A little background on sample rate timing statistics:
-   Whenever you want to do something at a consistent rate, there are two
-   engineering measures of variations in that rate:
-
-   1) Jitter. Jitter describes how much the timing varies from one sample
-   to the next. In this example, we describe Jitter by two statistics:
-   the minimum and maximum difference between the desired time between
-   samples, and the actual time between samples. By definition, the average
-   Jitter is 0.
-
-   2) Offset. Offset describes the *average* difference between the
-   desired time between samples and the actual time between samples.
-   In other words, Offset says how much slower or faster your sample rate
-   is than your desired sample rate.
-
-
-   Once you've measured Jitter and Offset, you can correct for them.
-   If the Offset is larger than you'd like, subtract the Offset from the
-   desired time between samples. That should reduce the measured offset.
-   If the Jitter is larger than you'd like, that suggests that there is
-   something in your code that sometimes (but not always) takes longer
-   than you can afford. The solution here is to look for places in your
-   code that can sometimes take extra time, and rewrite them to be more
-   consistent or to not take so much time.
-
-   So you're probably asking "how much is too much?"
-   That depends on how accurate your Pulse Sensor signal needs to be.
-   If you don't care about measuring a slightly high or low beats-per-minute
-   or inter-beat interval, you can probably ignore timing statistics.
-   If instead, you care that your beats per minute is a few percent higher
-   or lower than an accurate Pulse Oximeter would measure, you probably
-   want to run Timing Statistics on your sketch.
-
-   For example, suppose your Sketch is doing an analogRead() from
-   from a PulseSensor every 2000 microseconds (2 milliseconds,
-   or 500 samples per second). Suppose that your Timing Statistics
-   report an offset of 60 microseconds. 60 microseconds is 3% of 2000
-   (60/2000), so your Sketch's beats-per-minute and inter-beat interval
-   will be 3% lower than they should be.
-
-   Suppose that after adding Offset correction into your Sketch, the
-   Timing Statistics report an offset of 10 microseconds. 10 microseconds
-   is 1/2 of 1% of 2000 (10/2000), which is very good for a non-medical-grade
-   pulse measurement.
-*/
-
-
-/*
-   During code development:
-   If you want to see the accuracy of sample timing, set this to
-   the number of samples to collect before reporting and stopping.
-   Also look at the output only with the Arduino Serial Monitor
-   rather than with the Processing Visualizer or Serial Plotter.
-
-   500 * 30 = 500 samples per second * 30 seconds.
-
-   Normally, set this value to 0L, to turn off those measures.
-*/
-
-#define SAMPLES_BEFORE_STOPPING (500 * 30L)
-
-/*
-   The format of our output.
-
-   Set this to PROCESSING_VISUALIZER if you're normally going to run
-    the Processing Visualizer Sketch.
-    See https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
-
-   Set this to SERIAL_PLOTTER if you're normally going to run
-    the Arduino IDE's Serial Plotter.
-*/
-const int OUTPUT_TYPE = PROCESSING_VISUALIZER;
-
-/*
-   Pinout:
-     HAS_A_REF = set to true if you have connected
-       the pulse sensor power pin to A-REF.
-       If you are powering the pulse sensor below 5V,
-       you must set HAS_A_REF to true.
-     PIN_INPUT = Analog Input. Connected to the pulse sensor
-      purple (signal) wire.
-     PIN_BLINK = digital Output. Connected to an LED (and 220 ohm resistor)
-      that will flash on each detected pulse.
-     PIN_FADE = digital Output. Connected to an LED (and resistor)
-      that will smoothly fade with each pulse.
-*/
-const boolean HAS_A_REF = false;
-const int PIN_INPUT = A0;
-const int PIN_BLINK = 13;    // Pin 13 is the on-board LED
-const int PIN_FADE = 5;      // must be a pin that supports PWM. Can't be pin 3 or 11 (see ISR()).
-
-/*
-   Planned time (microseconds) between calls to readSensor().
-   2000 microseconds = 500 samples per second, that is 1000000/2000.
-*/
-const unsigned long MICROS_PER_READ = 2 * 1000L;
-
-/*
-   The offset compensation (microseconds) to subtract from
-   MICROS_PER_READ so that the measured offset is close to zero.
-
-   For some slow or older Arduinos, this value may need to be
-   as high as 30.
-*/
-const int OFFSET_MICROS = 0;
-
-/*
-   PWM steps per fade step.  More fades faster; less fades slower.
-   Because we fade once per sample rather than a slower rate,
-   this value is lower than the one in the InterruptBeatDetector.
-*/
-const int PWM_STEPS_PER_FADE = 2;
-
-/*
-   fadePWM = Pulse Width Modulation value for our fading LED
-   (0 = off; 255 = full on)
-*/
-int fadePWM;
-
-/*
-   The next time, in micros() value, that we wish to call readSensor().
-*/
-unsigned long wantMicros;
-
-/*
-   samplesUntilReport = the number of readSensor() calls remaining to perform
-   until we want to report a sample over the serial connection.
-
-   We want to report a sample value over the serial port
-   only once every 20ms to avoid doing Serial output
-   faster than the Arduino can do.
-*/
-byte samplesUntilReport;
-const byte SAMPLES_PER_SERIAL_SAMPLE = 20;
-
-/*
-   the latest analog value we've read from the PulseSensor
-*/
-int lastSampleValue;
-
-/*
-   All the PulseSensor Playground functions.
-*/
-PulseSensorPlayground pulseSensor;
-
-void setup() {
-  /*
-     Use 115200 baud because that's what the Processing Sketch expects to read,
-     and because that speed provides about 11 bytes per millisecond.
-
-     If we used a slower baud rate, we'd likely write bytes faster than
-     they can be transmitted, which would mess up the timing
-     of readSensor() calls, which would make the pulse measurement
-     not work properly.
-  */
-  Serial.begin(115200);
-  pulseSensor.beginSerialOutput(OUTPUT_TYPE);
-
-  // Set up the I/O pins
-
-#if !defined (__arc__) // EXTERNAL causes a compile error on Arduino 101.
-  if (HAS_A_REF) {
-    analogReference(EXTERNAL);
-  }
-#endif
-
-  // no setup is necessary for PIN_INPUT.
-  pinMode(PIN_BLINK, OUTPUT);
-  digitalWrite(PIN_BLINK, LOW);
-  pinMode(PIN_FADE, OUTPUT);
-  fadePWM = 0;
-  analogWrite(PIN_FADE, fadePWM);   // sets PWM duty cycle
-
-  // Setup our pulse detector
-  pulseSensor.beginBeatDetection();
-  pulseSensor.setBeatSampleIntervalMs(MICROS_PER_READ / 1000L);
-
-#if SAMPLES_BEFORE_STOPPING > 0
-  // Set up our timing statistics.
-  pulseSensor.beginTimingStatistics(MICROS_PER_READ, SAMPLES_BEFORE_STOPPING);
-#endif
-
-  // wait one sample interval before starting to search for pulses.
-  wantMicros = micros() + MICROS_PER_READ - OFFSET_MICROS;
-}
-
-void loop() {
-
-  /*
-     Find whether it's time to read from the sensor.
-     Note: because micros() overflows every 90 minutes or so,
-     we must calculate differences in time via (long) (b - a).
-  */
-  unsigned long nowMicros = micros();
-  if ((long) (wantMicros - nowMicros) < 0L) {
-    wantMicros = nowMicros + MICROS_PER_READ - OFFSET_MICROS;
-
-#if SAMPLES_BEFORE_STOPPING > 0
-    /*
-       Put this code immediately before your analogRead() call.
-
-       Update the sample timing statistics.
-       If enough samples have been collected, report results and stop.
-    */
-    if (pulseSensor.recordSampleTime() <= 0) {
-      pulseSensor.outputStatistics();
-      for (;;); // hang
-    }
-#endif
-
-    // Read from the PulseSensor and give that value to the Beat Detector.
-    lastSampleValue = analogRead(PIN_INPUT);
-    boolean QS = pulseSensor.addBeatValue(lastSampleValue);
-
-    /*
-       Every so often, send the latest Sample.
-       We don't print every sample, because our baud rate
-       won't support that much I/O.
-    */
-    if (--samplesUntilReport == (byte) 0) {
-      samplesUntilReport = SAMPLES_PER_SERIAL_SAMPLE;
-
-      pulseSensor.output(lastSampleValue
-                         , pulseSensor.getBeatsPerMinute()
-                         , pulseSensor.getInterBeatIntervalMs());
-    }
-
-    // Blink the non-fading LED when the start of a pulse is detected.
-    if (pulseSensor.isBeat()) {
-      digitalWrite(PIN_BLINK, HIGH);
-    } else {
-      digitalWrite(PIN_BLINK, LOW);
-    }
-
-    // Every beat, report the heart rate and inter-beat-interval
-    if (QS) {
-      fadePWM = 255;  // start fading on the start of each beat.
-
-      pulseSensor.outputBeat(
-        pulseSensor.getBeatsPerMinute()
-        , pulseSensor.getInterBeatIntervalMs());
-    }
-
-    /*
-       This is a good place to add code that could take up
-       to a millisecond or so to run.
-    */
-
-    // fade the LED a bit.
-    fadePWM = constrain(fadePWM - PWM_STEPS_PER_FADE, 0, 255);
-    analogWrite(PIN_FADE, fadePWM);
-  }
-
-  /*
-     Don't add code here, because it could slow the sampling
-     from the PulseSensor.
-  */
-}


fixed dependency

fixed dependency

--- examples/AnalogButtons/AnalogButtons.ino
+++ examples/AnalogButtons/AnalogButtons.ino
@@ -1,4 +1,4 @@
-#include "AnalogButtons.h"
+#include <AnalogButtons.h>

 #define ANALOG_PIN A1


Add Arduino.h header file to fix build issues

--- examples/AstronomyDemo/AstronomyDemo.ino
+++ examples/AstronomyDemo/AstronomyDemo.ino
@@ -23,6 +23,7 @@
 See more at https://thingpulse.com
 */

+#include <Arduino.h>
 #include <ESP8266WiFi.h>
 #include <time.h>
 #include <Astronomy.h>


Use defined LED_OUT pin in PatternPlayer

--- examples/PatternPlayer/PatternPlayer.ino
+++ examples/PatternPlayer/PatternPlayer.ino
@@ -29,7 +29,7 @@
 {
   Serial.begin(57600);

-  LEDS.addLeds<WS2811, 5, GRB>(leds, LED_COUNT);
+  LEDS.addLeds<WS2811, LED_OUT, GRB>(leds, LED_COUNT);
   LEDS.showColor(CRGB(0, 0, 0));
   LEDS.setBrightness(93); // Limit max current draw to 1A
   LEDS.show();


Added GPL header

Added GPL header

--- quadcopter/quadcopter.ino
+++ quadcopter/quadcopter.ino
@@ -1,3 +1,22 @@
+/*
+    Arduino-Quadcopter - An Arduino sketch to control the hardware of a quadcopter
+    Copyright (C) <2013>  <Noah Hummel>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
 #ifndef QUADARDU
 #define QUADARDU


wait until power on completed

wait until power on completed

--- GenlockDongle.ino
+++ GenlockDongle.ino
@@ -89,6 +89,9 @@
   if (digitalRead(BPRDY) == LOW && digitalRead(PWRBTN) == LOW) { // slave: power button of main camera depressed
     pwrbtn = false;
     delayMicroseconds(10500);
+    while (digitalRead(PWRBTN) == LOW) {
+      ;
+    }
   } else if (!pwrbtn) {
     emptyQueue();
     pwrbtn = true;


[FW] Status indication now on 7-segment display.

--- firmware/MultiRomVC4000/MultiRomVC4000.ino
+++ firmware/MultiRomVC4000/MultiRomVC4000.ino
@@ -11,11 +11,10 @@
 #define SD_CS          4  // Chip Select for SD card
 #define LED           13

-#define DISP_OE A2        // 7-segment display
-#define DISP_LATCH A3     // 7-segment display
-#define DISP_CLK A4       // 7-segment display
-#define DISP_DATA A5      // 7-segment display
-
+#define DISP_OE       A2  // 7-segment display
+#define DISP_LATCH    A3  // 7-segment display
+#define DISP_CLK      A4  // 7-segment display
+#define DISP_DATA     A5  // 7-segment display

 // Miscellaneous other defines
 #define NOKEY           0
@@ -24,16 +23,31 @@
 #define SELECTKEY       3
 #define MAX_ROMS       99
 #define MAX_ROM_SIZE 6144
+#define GO_MSG          9  // 7-segment Message offset
+#define ER_MSG         11  // 7-segment Message offset

 // Global variables
 byte lastkey = NOKEY;
+byte message = GO_MSG;
 byte romNumber = 1;
 char romName[] = { 0, 0, 0, 0, 0, 0, 0 };
 File romFile;
-unsigned blinkTimeHigh = 500;
-unsigned blinkTimeLow  = 500;

-byte digitOne[10]= {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};
+byte SevenSegChar[]= {
+  0x3f,  // 0
+  0x06,  // 1
+  0x5b,  // 2
+  0x4f,  // 3
+  0x66,  // 4
+  0x6d,  // 5
+  0x7d,  // 6
+  0x07,  // 7
+  0x7f,  // 8
+  0x6f,  // 9
+  0x63,  // o
+  0x79,  // E
+  0x50   // r
+};

 void setup() {
   pinMode(SD_CS, OUTPUT);
@@ -54,32 +68,33 @@
   // Isolate MultiROM from console bus
   disableVCBus();

-  // Init and enable 7-segment display
-  dispShowNumber(romNumber);
-
-  // Wait for user selecting a ROM number
-  byte key = getKey(A7);
-  do {
-    if (key == UPKEY && lastkey != UPKEY && romNumber < MAX_ROMS)
-      ++romNumber;
-    else if (key == DOWNKEY && lastkey != DOWNKEY && romNumber > 1)
-      --romNumber;
+  // Initialize SD card
+  if (SD.begin(SD_CS)) {
+    // Init 7-segment display
     dispShowNumber(romNumber);
-    lastkey = key;
-    key = getKey(A7);
-  } while (key != SELECTKEY);

-  // Construct ROM file name
-  if (romNumber < 10) {
-    romName[0] = '0';
-    itoa(romNumber, romName+1, 10);
-  } else {
-    itoa(romNumber, romName, 10);
-  }
-  strcpy(romName+2, ".bin");
+    // Wait for user selecting a ROM number
+    byte key = getKey(A7);
+    do {
+      if (key == UPKEY && lastkey != UPKEY && romNumber < MAX_ROMS)
+        ++romNumber;
+      else if (key == DOWNKEY && lastkey != DOWNKEY && romNumber > 1)
+        --romNumber;
+      dispShowNumber(romNumber);
+      lastkey = key;
+      key = getKey(A7);
+    } while (key != SELECTKEY);

-  // Initialize SD card and open ROM file
-  if (SD.begin(SD_CS)) {
+    // Construct ROM file name
+    if (romNumber < 10) {
+      romName[0] = '0';
+      itoa(romNumber, romName+1, 10);
+    } else {
+      itoa(romNumber, romName, 10);
+    }
+    strcpy(romName+2, ".bin");
+
+    // Open ROM file
     romFile = SD.open(romName);

     // Write ROM file to SRAM
@@ -91,30 +106,23 @@
         }
       } else {
         // ROM size too big.
-        blinkTimeHigh =   50;
-        blinkTimeLow  = 1000;
+        message = ER_MSG;
       }
       romFile.close();
       enableVCBus();
     } else {
       // ROM file could not be opened.
-      blinkTimeHigh =  50;
-      blinkTimeLow  = 200;
+      message = ER_MSG;
     }
   } else {
     // SD card not found or otherwise failing initialization
-    blinkTimeHigh = 50;
-    blinkTimeLow  = 50;
+    message = ER_MSG;
   }
-  SPI.end();  // Otherwise on-board LED does not work!
 }

 void loop() {
   // Status indication
-  digitalWrite(LED, HIGH);
-  delay(blinkTimeHigh);
-  digitalWrite(LED, LOW);
-  delay(blinkTimeLow);
+  dispMessage(message);
 }

 void disableVCBus() {
@@ -168,9 +176,15 @@
 void dispShowNumber(byte num) {
   byte i = num % 10;
   byte j = (num - i) / 10;
-      digitalWrite(DISP_LATCH, LOW);
-      shiftOut(DISP_DATA, DISP_CLK, MSBFIRST, digitOne[i]); // digitTwo
-      shiftOut(DISP_DATA, DISP_CLK, MSBFIRST, digitOne[j]); // digitOne
-      digitalWrite(DISP_LATCH, HIGH);
-
+  digitalWrite(DISP_LATCH, LOW);
+  shiftOut(DISP_DATA, DISP_CLK, MSBFIRST, SevenSegChar[i]); // digitTwo
+  shiftOut(DISP_DATA, DISP_CLK, MSBFIRST, SevenSegChar[j]); // digitOne
+  digitalWrite(DISP_LATCH, HIGH);
 }
+
+void dispMessage(byte offset) {
+  digitalWrite(DISP_LATCH, LOW);
+  shiftOut(DISP_DATA, DISP_CLK, MSBFIRST, SevenSegChar[offset+1]);
+  shiftOut(DISP_DATA, DISP_CLK, MSBFIRST, SevenSegChar[offset]);
+  digitalWrite(DISP_LATCH, HIGH);
+}


Delete Ada_CurieBot_Phone.ino

Delete Ada_CurieBot_Phone.ino

--- Ada_CurieBot_Phone.ino
+++ Ada_CurieBot_Phone.ino
@@ -1,352 +0,0 @@
-/*********************************************************************
- This is CurieBot RC -- the Arduino 101 based robot using Bluetooth LE
- Modified to drive a 3-wheeled BLE Robot Rover! by http://james.devi.to
-
- Pick one up today in the Adafruit shop!
-
- Adafruit invests time and resources providing this open source code,
- please support Adafruit and open-source hardware by purchasing
- products from Adafruit!
-
- MIT license, check LICENSE for more information
- All text above, and the splash screen below must be included in
- any redistribution
-*********************************************************************/
-
-#include <string.h>
-#include <Arduino.h>
-#include <SPI.h>
-#include <Wire.h>
-#include <Adafruit_MotorShield.h>
-
-  #include <CurieBLE.h>
-  #include <BLEPeripheral.h>
-  #include "BLESerial.h"
-
-  BLESerial ble = BLESerial();
-
-static int lightPin = 13;
-
-// Create the motor shield object with the default I2C address
-Adafruit_MotorShield AFMS = Adafruit_MotorShield();
-
-// And connect 2 DC motors to port M1 & M2 !
-Adafruit_DCMotor *L_MOTOR = AFMS.getMotor(1);
-Adafruit_DCMotor *R_MOTOR = AFMS.getMotor(2);
-
-//not used, testing acceleration
-// int accelTime = 200;
-
-
-#define BLUETOOTH_NAME                 "CurieBot" //Name your RC here
-#define BLE_READPACKET_TIMEOUT         500   // Timeout in ms waiting to read a response
-
-// A small helper
-void error(const __FlashStringHelper*err) {
-  Serial.println(err);
-  while (1);
-}
-
-// function prototypes over in packetparser.cpp
-uint8_t readPacket(Stream *ble, uint16_t timeout);
-float parsefloat(uint8_t *buffer);
-void printHex(const uint8_t * data, const uint32_t numBytes);
-
-// the packet buffer
-extern uint8_t packetbuffer[];
-
-char buf[60];
-
-/**************************************************************************/
-/*!
-    @brief  Sets up the HW an the BLE module (this function is called
-            automatically on startup)
-*/
-/**************************************************************************/
-void setup(void)
-{
-  //while (!Serial);// For use only while plugged into USB an with Serial Monitor open
-  AFMS.begin();  // create with the default frequency 1.6KHz
-
-  // turn off both motors
-  L_MOTOR->setSpeed(0);
-  R_MOTOR->setSpeed(0);
-  L_MOTOR->run(RELEASE);
-  R_MOTOR->run(RELEASE);
-
-  Serial.begin(115200);
-  Serial.println(F("Adafruit Bluefruit Robot Controller Example"));
-  Serial.println(F("-----------------------------------------"));
-
-  /* Initialize the module */
-  BLEsetup();
-
-  pinMode(lightPin, OUTPUT);
-
-}
-
-int velocity = 0;
-
-float x, y;
-
-int L_restrict = 0;
-int R_restrict = 0;
-
-unsigned long lastAccelPacket = 0;
-
-bool modeToggle = false;
-
-void loop(void)
-{
-  // read new packet data
-  uint8_t len = readPacket(&ble, BLE_READPACKET_TIMEOUT);
-  if (len == 0) return;
-
-  Serial.print("Packet type: ");
-  Serial.println(packetbuffer[1]);
-
-  // Read from Accelerometer input
-  if( accelMode() ) {
-    lastAccelPacket = millis();
-    modeToggle = true;
-    return;
-  }
-
-  // Stop motors if accelerometer data is turned off (100ms timeout)
-  if(((millis() - lastAccelPacket) > 100) & modeToggle) {
-    L_MOTOR->run(RELEASE);
-    R_MOTOR->run(RELEASE);
-    modeToggle = false;
-    return;
-  }
-
-  //if no accelerometer, use control pad
-  if( !modeToggle ) {
-    buttonMode();
-  }
-}
-
-
-bool accelMode(){
-  if (packetbuffer[1] == 'A') {
-        memcpy(&x, packetbuffer + 2, sizeof x);
-        memcpy(&y, packetbuffer + 6, sizeof y);
-//        x /= 10;
-//        y /= 10;
-  Serial.print("x = ");
-  Serial.print(x);
-  Serial.print("; y = ");
-  Serial.println(y);
-        if( x <= -0.2 ){
-          x += 0.2;
-          velocity = x * -320;
-          L_MOTOR->run( BACKWARD );
-          R_MOTOR->run( BACKWARD );
-        }
-        else if( x >= 0.2 ){
-          x-= 0.2;
-          velocity = x * 320;
-          L_MOTOR->run( FORWARD );
-          R_MOTOR->run( FORWARD );
-        }
-        else{
-          L_MOTOR->run( RELEASE );
-          R_MOTOR->run( RELEASE );
-          velocity = 0;
-        }
-
-        if (velocity > 255) velocity = 255;
-        if (velocity < 0) velocity = 0;
-
-        //account for L / R accel
-
-        if( y >= 0.1 ){
-            y -= 0.1;
-            y *= 100;
-            if( y >= 50 ) y = 50;
-            if( y <= 0 ) y = 0;
-
-            R_restrict = fscale( y, 0.0, 50.0, 0.0, 100.0, -4.0 );
-        }
-        else if( y <= -0.1 ){
-            y += 0.1;
-            y *= -100;
-            if( y>= 50 ) y = 50;
-            if( y<= 0 ) y = 0;
-
-            L_restrict = fscale( y, 0.0, 50.0, 0.0, 100.0, -4.0 );
-        }
-        else{
-            L_restrict = 0;
-            R_restrict = 0;
-        }
-
-          float Lpercent = ( 100.0 - L_restrict ) / 100.00 ;
-          float Rpercent = ( 100.0 - R_restrict ) / 100.00 ;
-
-          // Serial.print( x );
-          // Serial.print( "\t" );
-          // Serial.print( Lpercent );
-          // Serial.print( "\t" );
-          // Serial.print( velocity );
-          // Serial.print( "\t" );
-          // Serial.println( Rpercent );
-
-          L_MOTOR->setSpeed( velocity * Lpercent );
-          R_MOTOR->setSpeed( velocity * Rpercent );
-
-          return true;
-    }
-    return false;
-}
-
-bool isMoving = false;
-unsigned long lastPress = 0;
-
-bool buttonMode(){
-
-   // Buttons
-  if (packetbuffer[1] == 'B') {
-    uint8_t buttnum = packetbuffer[2] - '0';
-    boolean pressed = packetbuffer[3] - '0';
-
-    Serial.print("Button #"); Serial.print(buttnum);
-    if (pressed)
-      Serial.println(" pressed");
-    else
-      Serial.println(" released");
-    //Serial.println(isMoving);
-
-    if (pressed) {
-      isMoving = true;
-      if(buttnum == 5){
-        L_MOTOR->run(FORWARD);
-        R_MOTOR->run(FORWARD);
-      }
-      if(buttnum == 6){
-        L_MOTOR->run(BACKWARD);
-        R_MOTOR->run(BACKWARD);
-      }
-      if(buttnum == 7){
-        L_MOTOR->run(RELEASE);
-        R_MOTOR->run(FORWARD);
-      }
-      if(buttnum == 8){
-        L_MOTOR->run(FORWARD);
-        R_MOTOR->run(RELEASE);
-      }
-      if(buttnum == 1){
-        digitalWrite(lightPin, HIGH);
-      }
-
-      lastPress = millis();
-
-      // speed up the motors
-      for (int speed=0; speed < 255; speed+=5) {
-        L_MOTOR->setSpeed(speed);
-        R_MOTOR->setSpeed(speed);
-        delay(5); // 250ms total to speed up
-      }
-    } else if (buttnum == 1) {
-        digitalWrite(lightPin, LOW);
-    } else {
-      isMoving = false;
-      // slow down the motors
-      for (int speed=255; speed >= 0; speed-=5) {
-        L_MOTOR->setSpeed(speed);
-        R_MOTOR->setSpeed(speed);
-        delay(5); // 50ms total to slow down
-      }
-      L_MOTOR->run(RELEASE);
-      R_MOTOR->run(RELEASE);
-    }
-     return true;
-  }
-
-  return false;
-
-}
-
-void BLEsetup() {
-  // using Curie
-  ble.setLocalName("CurieBot");
-  ble.begin();
-
-
-}
-
-//Logarithmic mapping function from http://playground.arduino.cc/Main/Fscale
-float fscale( float inputValue,  float originalMin, float originalMax, float newBegin, float newEnd, float curve){
-
-  float OriginalRange = 0;
-  float NewRange = 0;
-  float zeroRefCurVal = 0;
-  float normalizedCurVal = 0;
-  float rangedValue = 0;
-  boolean invFlag = 0;
-
-
-  // condition curve parameter
-  // limit range
-
-  if (curve > 10) curve = 10;
-  if (curve < -10) curve = -10;
-
-  curve = (curve * -.1) ; // - invert and scale - this seems more intuitive - postive numbers give more weight to high end on output
-  curve = pow(10, curve); // convert linear scale into lograthimic exponent for other pow function
-
-  /*
-   Serial.println(curve * 100, DEC);   // multply by 100 to preserve resolution
-   Serial.println();
-   */
-
-  // Check for out of range inputValues
-  if (inputValue < originalMin) {
-    inputValue = originalMin;
-  }
-  if (inputValue > originalMax) {
-    inputValue = originalMax;
-  }
-
-  // Zero Refference the values
-  OriginalRange = originalMax - originalMin;
-
-  if (newEnd > newBegin){
-    NewRange = newEnd - newBegin;
-  }
-  else
-  {
-    NewRange = newBegin - newEnd;
-    invFlag = 1;
-  }
-
-  zeroRefCurVal = inputValue - originalMin;
-  normalizedCurVal  =  zeroRefCurVal / OriginalRange;   // normalize to 0 - 1 float
-
-  /*
-  Serial.print(OriginalRange, DEC);
-   Serial.print("   ");
-   Serial.print(NewRange, DEC);
-   Serial.print("   ");
-   Serial.println(zeroRefCurVal, DEC);
-   Serial.println();
-   */
-
-  // Check for originalMin > originalMax  - the math for all other cases i.e. negative numbers seems to work out fine
-  if (originalMin > originalMax ) {
-    return 0;
-  }
-
-  if (invFlag == 0){
-    rangedValue =  (pow(normalizedCurVal, curve) * NewRange) + newBegin;
-
-  }
-  else     // invert the ranges
-  {
-    rangedValue =  newBegin - (pow(normalizedCurVal, curve) * NewRange);
-  }
-
-  return rangedValue;
-}
-
-


Updates API for watch_init

Updates API for watch_init

--- watch.ino
+++ watch.ino
@@ -26,8 +26,8 @@

 WatchState _watch_state = {0};

-void watch_init() {
-  _watch_state.next_second_millis = millis() + 1000;
+void watch_init(uint16_t now) {
+  _watch_state.next_second_millis = now;
 }

 /**
@@ -36,8 +36,12 @@

 To redraw the entire watch face, pass in changes = 0xff. Otherwise pass in
 whatever is returned by watch_tick() for optimised update of watch face.
+
+If 0 is passed in, nothing happens.
 */
 void watch_show(uint8_t changes) {
+  if (changes == 0) return;
+
   uint8_t seconds = _watch_state.seconds;
   uint8_t minutes = _watch_state.minutes;
   uint8_t hours = _watch_state.hours;


handle hex id

handle hex id

--- client/client.ino
+++ client/client.ino
@@ -284,7 +284,8 @@
   readStringfromSerial(&XBee, XBeeInString);

   // deviceId = XBeeInString[];
-  int id = atoi(XBeeInString);
+  Serial.println(XBeeInString);
+  int id = (int)strtol(XBeeInString, NULL, 16);
   // string_copy(deviceId, XBeeInString, 0, 1);

   if(id<10) { //append 0 at beginning


Stroller_interruptHandling_1.ino edited online with Bitbucket to incorporate changes from here: http://playground.arduino.cc/Learning/ArduinoSleepCode

--- Stroller_interruptHandling_1/Stroller_interruptHandling_1.ino
+++ Stroller_interruptHandling_1/Stroller_interruptHandling_1.ino
@@ -16,8 +16,9 @@
 int hadRound=0;
 void countRPM(void)
 {
+  sleep_disable();
   detachInterrupt(0);
- hadRound=1;
+  hadRound=1;

 }

@@ -31,12 +32,12 @@
 {

   /* Setup pin2 as an interrupt and attach handler. */
+  sleep_enable();
   attachInterrupt(0, countRPM, LOW);
   delay(100);

   set_sleep_mode(SLEEP_MODE_PWR_DOWN);

-  sleep_enable();

   sleep_mode();


-arduino light work

-arduino light work

--- arduino/src/robotLEDControllerrev2/robotLEDControllerrev2.ino
+++ arduino/src/robotLEDControllerrev2/robotLEDControllerrev2.ino
@@ -171,7 +171,7 @@
   }
   else if (dataRecieved[0] == false && dataRecieved[1] == false && dataRecieved[2] == true && dataRecieved[3] == false){
     //set lights to yellow
-//    distanceColor = 0xFFFF00;
+    distanceColor = 0xFFFF00;
   }
   else if (dataRecieved[0] == false && dataRecieved[1] == false && dataRecieved[2] == true && dataRecieved[3] == true){
     //signal to other robots
@@ -179,11 +179,11 @@
   }
   else if (dataRecieved[0] == false && dataRecieved[1] == true && dataRecieved[2] == true && dataRecieved[3] == false){
     //set lights to green
-//    distanceColor = 0x008000;
+    distanceColor = 0x008000;
   }
   else if (dataRecieved[0] == true && dataRecieved[1] == false && dataRecieved[2] == false && dataRecieved[3] == false){
     //sets the distance color to red
-//    distanceColor = 0xFF0000;
+    distanceColor = 0xFF0000;
   }
   else if (dataRecieved[0] == true && dataRecieved[1] == true && dataRecieved[2] == false && dataRecieved[3] == false){
     //signal to other teams
@@ -195,11 +195,11 @@
   }
   else if (dataRecieved[0] == true && dataRecieved[1] == true && dataRecieved[2] == true && dataRecieved[3] == false){
     //if the alliance color is blue
-//    allianceColor = CRGB::Blue;
+    allianceColor = CRGB::Blue;
   }
   else if (dataRecieved[0] == true && dataRecieved[1] == true && dataRecieved[2] == false && dataRecieved[3] == true){
     //if the alliance color is red
-//    allianceColor = CRGB::Red;
+    allianceColor = CRGB::Red;
   }
   else if (dataRecieved[0] == false && dataRecieved[1] == true && dataRecieved[2] == false && dataRecieved[3] == true){
     //rainbow after fireworks


Fixes #298 for ESP32

Fixes #298 for ESP32

Fixes #298 for ESP32, thanks @NotUnderi

--- arduino/ws2812_controller_esp32/ws2812_controller_esp32.ino
+++ arduino/ws2812_controller_esp32/ws2812_controller_esp32.ino
@@ -1,14 +1,15 @@
 /*
-*This example works for ESP32 and uses the NeoPixelBus library instead of the one bundle
-*
+* This example works for ESP32 and uses the NeoPixelBus library instead of the one bundle
+* Sketch Written by Joey Babcock - https://joeybabcock.me/blog/
+* Codebase cretaed by ScottLawsonBC - https://github.com/scottlawsonbc
 */
+
 #include <Arduino.h>
 #include <WiFi.h>
 #include <WiFiUdp.h>
 #include <NeoPixelBus.h>

 // Set to the number of LEDs in your LED strip
-
 #define NUM_LEDS 60
 // Maximum number of packets to hold in the buffer. Don't change this.
 #define BUFFER_LEN 1024
@@ -37,6 +38,7 @@

 void setup() {
     Serial.begin(115200);
+    WiFi.mode(WIFI_STA);
     WiFi.config(ip, gateway, subnet);
     WiFi.begin(ssid, password);
     Serial.println("");
@@ -45,12 +47,15 @@
         delay(500);
         Serial.print(".");
     }
+
     Serial.println("");
     Serial.print("Connected to ");
     Serial.println(ssid);
     Serial.print("IP address: ");
     Serial.println(WiFi.localIP());
+
     port.begin(localPort);
+
     ledstrip.Begin();//Begin output
     ledstrip.Show();//Clear the strip for use
 }
@@ -85,4 +90,4 @@
             fpsCounter = 0;
         }
     #endif
-}+}


Update to v1.6.8.

Update to v1.6.8.

--- aquacontrol32.ino
+++ aquacontrol32.ino
@@ -25,7 +25,7 @@

 #define SET_STATIC_IP              false                 /* If SET_STATIC_IP is set to true then STATIC_IP, GATEWAY, SUBNET and PRIMARY_DNS have to be set to some sane values */

-const IPAddress STATIC_IP(192, 168, 0, 60);              /* This should be outside your router dhcp range! */
+const IPAddress STATIC_IP(192, 168, 0, 80);              /* This should be outside your router dhcp range! */
 const IPAddress GATEWAY(192, 168, 0, 1);                 /* Set to your gateway ip address */
 const IPAddress SUBNET(255, 255, 255, 0);                /* Usually 255,255,255,0 but check in your router or pc connected to the same network */
 const IPAddress PRIMARY_DNS(192, 168, 0, 30);            /* Check in your router */
@@ -37,7 +37,7 @@
 #if GIT_TAG
 #include "gitTagVersion.h"
 #else
-const char * sketchVersion = "v1.6.71-master";
+const char * sketchVersion = "v1.6.8";
 #endif

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


Update ArduCAM_Shield_V2_Capture2SD.ino

Update ArduCAM_Shield_V2_Capture2SD.ino

--- ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Capture2SD/ArduCAM_Shield_V2_Capture2SD.ino
+++ ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Capture2SD/ArduCAM_Shield_V2_Capture2SD.ino
@@ -130,8 +130,16 @@
 Serial.println(F("ArduCAM Start!"));
 //set the CS as an output:
 pinMode(SPI_CS,OUTPUT);
+digitalWrite(SPI_CS, HIGH);
 // initialize SPI:
 SPI.begin();
+
+//Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
+
 while(1){
   //Check if the ArduCAM SPI bus is OK
   myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


Update _04-mqtt-lcd-dust-sensor-nano.ino

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-nano/_04-mqtt-lcd-dust-sensor-nano.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-nano/_04-mqtt-lcd-dust-sensor-nano.ino
@@ -189,7 +189,7 @@
     ac_power_down();
     Serial.println("CHANGE AC MODE : OFF");
   }
-  irrecv.enableIRIn(); // Start the receiver
+  //irrecv.enableIRIn(); // Start the receiver
 }

 // IR


Adding pulse mode for transmit LEDs

Adding pulse mode for transmit LEDs

Adding cool pulsing light mode for transmit status

--- Arduino/MIMIC_Extras/SGANT/SGANT.ino
+++ Arduino/MIMIC_Extras/SGANT/SGANT.ino
@@ -1,12 +1,19 @@
-#include <Adafruit_NeoPixel.h>
+#include <FastLED.h>
 #include <Servo.h>
 #include <string.h>

+#define NUM_LEDS 32
+#define DATA_PIN 6
+#define BRIGHTNESS  200
+#define FRAMES_PER_SECOND 60
+CRGBPalette16 gPal;
+CRGB leds[NUM_LEDS];
 //Connect USB port to Pi USB Port

-Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, 6, NEO_GRB + NEO_KHZ800);
+//Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, 6, NEO_GRB + NEO_KHZ800);
 Servo XEL_servo;
 Servo EL_servo;
+bool gReverseDirection = false;
 const int ledBluePin = 13;
 String test;
 int EL = 0;
@@ -18,13 +25,25 @@
 int oldXEL = 0;
 int oldnewEL = 0;
 int oldnewXEL = 0;
+int index = 0;
+
+uint32_t stickone[] = {0,1,2,3,4,5,6,7};
+uint32_t sticktwo[] = {15,14,13,12,11,10,9,8};
+uint32_t stickthree[] = {16,17,18,19,20,21,22,23};
+uint32_t stickfour[] = {31,30,29,28,27,26,25,24};
+
+int fadeAmount = 255;  // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.
+int brightness = 0;

 void setup()
 {
   pinMode(ledBluePin, OUTPUT);
   Serial.begin(9600);
   Serial.setTimeout(50);
-  strip.begin();
+  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
+  gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White);
+  allSet(CRGB::Black);
+  //strip.begin();

   EL_servo.attach(10);
   XEL_servo.attach(9);
@@ -38,8 +57,8 @@

 void loop()
 {
-
   digitalWrite(ledBluePin, LOW);
+  random16_add_entropy( random());
   //Serial.print("El ");
   //Serial.println(EL);
   if(Serial.available())
@@ -49,19 +68,45 @@

   if(EL == 0 && XEL == 0)
   {
-    Fire(55,120,5);
+    Fire2012WithPalette(); // run simulation frame, using palette colors
+    FastLED.show(); // display this frame
+    FastLED.delay(1000 / FRAMES_PER_SECOND);
   }
   else
   {
     if(Transmit)
     {
-      allSet(strip.Color(50,50,50),10);
-      strip.show();
+      //allSet(CRGB::Black);
+      leds[stickone[index]] = CRGB::White;
+      leds[sticktwo[index]] = CRGB::White;
+      leds[stickthree[index]] = CRGB::White;
+      leds[stickfour[index]] = CRGB::White;
+      leds[stickone[index]].fadeLightBy(brightness);
+      leds[sticktwo[index]].fadeLightBy(brightness);
+      leds[stickthree[index]].fadeLightBy(brightness);
+      leds[stickfour[index]].fadeLightBy(brightness);
+
+      //allSet(strip.Color(50,50,50),10);
+      FastLED.show();
+      delay(100);
+      index++;
+      if(index >= 8)
+      {
+        index = 0;
+        brightness = brightness + fadeAmount;
+        // reverse the direction of the fading at the ends of the fade:
+        if(brightness == 0 || brightness == 255)
+        {
+          fadeAmount = -fadeAmount ;
+        }
+      }
+      Serial.println("Transmitting");
     }
     else
     {
-      allSet(strip.Color(50,0,0),10);
-      strip.show();
+      allSet(CRGB::Black);
+      //allSet(strip.Color(50,0,0),10);
+      FastLED.show();
     }
   }

@@ -166,65 +211,59 @@
     }
   }
 }
-void allSet(uint32_t c, uint8_t wait)
-{
-  for(uint16_t i=0; i<strip.numPixels(); i++)
-  {
-    strip.setPixelColor(i, c);
-    strip.show();
-    delay(wait);
-  }
-}
-void Fire(int Cooling, int Sparking, int SpeedDelay) {
-  static byte heat[60];
-  int cooldown;
-
+void allSet(uint32_t c)
+{
+  for(int dot=0; dot<NUM_LEDS; dot++)
+  {
+    leds[dot] = CRGB::Black;
+    //pixels.setPixelColor(i,c);
+  }
+  FastLED.show();
+}
+// COOLING: How much does the air cool as it rises?
+// Less cooling = taller flames.  More cooling = shorter flames.
+// Default 55, suggested range 20-100
+#define COOLING  55
+
+// SPARKING: What chance (out of 255) is there that a new spark will be lit?
+// Higher chance = more roaring fire.  Lower chance = more flickery fire.
+// Default 120, suggested range 50-200.
+#define SPARKING 120
+
+
+void Fire2012WithPalette()
+{
+// Array of temperature readings at each simulation cell
+  static byte heat[NUM_LEDS];
+
   // Step 1.  Cool down every cell a little
-  for( int i = 0; i < strip.numPixels(); i++) {
-    cooldown = random(0, ((Cooling * 10) / strip.numPixels()) + 2);
-
-    if(cooldown>heat[i]) {
-      heat[i]=0;
-    } else {
-      heat[i]=heat[i]-cooldown;
-    }
-  }
-
-  // Step 2.  Heat from each cell drifts 'up' and diffuses a little
-  for( int k= strip.numPixels() - 1; k >= 2; k--) {
-    heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
-  }
-
-  // Step 3.  Randomly ignite new 'sparks' near the bottom
-  if( random(255) < Sparking ) {
-    int y = random(7);
-    heat[y] = heat[y] + random(160,255);
-    //heat[y] = random(160,255);
-  }
-
-  // Step 4.  Convert heat to LED colors
-  for( int j = 0; j < strip.numPixels(); j++) {
-    setPixelHeatColor(j, heat[j] );
-  }
-
-  strip.show();
-  delay(SpeedDelay);
-}
-
-void setPixelHeatColor (int Pixel, byte temperature) {
-  // Scale 'heat' down from 0-255 to 0-191
-  byte t192 = round((temperature/255.0)*191);
-
-  // calculate ramp up from
-  byte heatramp = t192 & 0x3F; // 0..63
-  heatramp <<= 2; // scale up to 0..252
-
-  // figure out which third of the spectrum we're in:
-  if( t192 > 0x80) {                     // hottest
-    strip.setPixelColor(Pixel, random(0,256), random(0,256), random(0,256));
-  } else if( t192 > 0x40 ) {             // middle
-    strip.setPixelColor(Pixel, random(0,256), random(0,256), 0);
-  } else {                               // coolest
-    strip.setPixelColor(Pixel, heatramp, 0, 0);
-  }
-}
+    for( int i = 0; i < NUM_LEDS; i++) {
+      heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
+    }
+
+    // Step 2.  Heat from each cell drifts 'up' and diffuses a little
+    for( int k= NUM_LEDS - 1; k >= 2; k--) {
+      heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
+    }
+
+    // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
+    if( random8() < SPARKING ) {
+      int y = random8(7);
+      heat[y] = qadd8( heat[y], random8(160,255) );
+    }
+
+    // Step 4.  Map from heat cells to LED colors
+    for( int j = 0; j < NUM_LEDS; j++) {
+      // Scale the heat value from 0-255 down to 0-240
+      // for best results with color palettes.
+      byte colorindex = scale8( heat[j], 240);
+      CRGB color = ColorFromPalette( gPal, colorindex);
+      int pixelnumber;
+      if( gReverseDirection ) {
+        pixelnumber = (NUM_LEDS-1) - j;
+      } else {
+        pixelnumber = j;
+      }
+      leds[pixelnumber] = color;
+    }
+}


Fix dew point calculation and displaying

--- meteo_lcd/meteo_lcd.ino
+++ meteo_lcd/meteo_lcd.ino
@@ -155,16 +155,17 @@

 /*
- * Return a dew point for temperatures in range -30°C up to +70°C.
+ * Return a dew point for temperatures in range -30°C up to +50°C.
  * Humidity should be from 0 up to 100%.
  * Functions returns esimated dew point in °C
+ * Returns 100 as an error - Temperature beyond the scale.
  */
 int8_t get_dew_point (float temp, float humid)
 {
     if (temp < -31.0 || temp > 50)
-        return 0;
-
-    int temp_idx = (temp + 31.0)/2;
+        return 100; // treat it as an error.
+
+    int temp_idx = 40-(temp + 31.0)/2;
     if (temp_idx < 0) temp_idx = 0;
     if (temp_idx > 40) temp_idx = 40;

@@ -639,7 +640,16 @@
     // Dew point
     if (show_dew_point) {
         lcd.setCursor(3, 2);
-        dtostrf(get_dew_point(temp_out, humid_out), 3, 0, buff);
+        int8_t ret = get_dew_point(temp_out, humid_out);
+        if (ret != 100) {
+            dtostrf(get_dew_point(temp_out, humid_out), 3, 0, buff);
+        }
+        else {
+            buff[0] = 'N';
+            buff[1] = (char)47; // '/'
+            buff[2] = 'A';
+            buff[3] = '\0';
+        }
         lcd.print(buff);
     }
 }