ADD: animation

ADD: animation

--- src/drumkit/drumkit.ino
+++ src/drumkit/drumkit.ino
@@ -1,293 +1,105 @@
-
-/*
-  Bunches of definitions for the WS2812 Breakout Board example code
-
-*/
-
-// These are for the cascade function
-#define TOP_DOWN 0
-#define DOWN_TOP 1
-
-/* A world of colors to set your LED to
-  Standard HTML Color Codes sorted by Hex Value
-    to see the colors in action, check out:
-   http://www.w3schools.com/html/html_colorvalues.asp */
-
-#define BLACK      0x000000
-#define NAVY      0x000080
-#define DARKBLUE    0x00008B
-#define MEDIUMBLUE    0x0000CD
-#define BLUE      0x0000FF
-#define DARKGREEN   0x006400
-#define GREEN     0x008000
-#define TEAL      0x008080
-#define DARKCYAN    0x008B8B
-#define DEEPSKYBLUE   0x00BFFF
-#define DARKTURQUOISE   0x00CED1
-#define MEDIUMSPRINGGREEN 0x00FA9A
-#define LIME      0x00FF00
-#define SPRINGGREEN   0x00FF7F
-#define AQUA      0x00FFFF
-#define CYAN      0x00FFFF
-#define MIDNIGHTBLUE    0x191970
-#define DODGERBLUE    0x1E90FF
-#define LIGHTSEAGREEN   0x20B2AA
-#define FORESTGREEN   0x228B22
-#define SEAGREEN    0x2E8B57
-#define DARKSLATEGRAY   0x2F4F4F
-#define LIMEGREEN   0x32CD32
-#define MEDIUMSEAGREEN    0x3CB371
-#define TURQUOISE   0x40E0D0
-#define ROYALBLUE   0x4169E1
-#define STEELBLUE   0x4682B4
-#define DARKSLATEBLUE   0x483D8B
-#define MEDIUMTURQUOISE   0x48D1CC
-#define INDIGO      0x4B0082
-#define DARKOLIVEGREEN    0x556B2F
-#define CADETBLUE   0x5F9EA0
-#define CORNFLOWERBLUE    0x6495ED
-#define MEDIUMAQUAMARINE  0x66CDAA
-#define DIMGRAY     0x696969
-#define SLATEBLUE   0x6A5ACD
-#define OLIVEDRAB   0x6B8E23
-#define SLATEGRAY   0x708090
-#define LIGHTSLATEGRAY    0x778899
-#define MEDIUMSLATEBLUE   0x7B68EE
-#define LAWNGREEN   0x7CFC00
-#define CHARTREUSE    0x7FFF00
-#define AQUAMARINE    0x7FFFD4
-#define MAROON      0x800000
-#define PURPLE      0x800080
-#define OLIVE     0x808000
-#define GRAY      0x808080
-#define SKYBLUE     0x87CEEB
-#define LIGHTSKYBLUE    0x87CEFA
-#define BLUEVIOLET    0x8A2BE2
-#define DARKRED     0x8B0000
-#define DARKMAGENTA   0x8B008B
-#define SADDLEBROWN   0x8B4513
-#define DARKSEAGREEN    0x8FBC8F
-#define LIGHTGREEN    0x90EE90
-#define MEDIUMPURPLE    0x9370DB
-#define DARKVIOLET    0x9400D3
-#define PALEGREEN   0x98FB98
-#define DARKORCHID    0x9932CC
-#define YELLOWGREEN   0x9ACD32
-#define SIENNA      0xA0522D
-#define BROWN     0xA52A2A
-#define DARKGRAY    0xA9A9A9
-#define LIGHTBLUE   0xADD8E6
-#define GREENYELLOW   0xADFF2F
-#define PALETURQUOISE         0xAFEEEE
-#define LIGHTSTEELBLUE    0xB0C4DE
-#define POWDERBLUE    0xB0E0E6
-#define FIREBRICK   0xB22222
-#define DARKGOLDENROD   0xB8860B
-#define MEDIUMORCHID    0xBA55D3
-#define ROSYBROWN   0xBC8F8F
-#define DARKKHAKI   0xBDB76B
-#define SILVER      0xC0C0C0
-#define MEDIUMVIOLETRED         0xC71585
-#define INDIANRED     0xCD5C5C
-#define PERU      0xCD853F
-#define CHOCOLATE   0xD2691E
-#define TAN     0xD2B48C
-#define LIGHTGRAY   0xD3D3D3
-#define THISTLE     0xD8BFD8
-#define ORCHID      0xDA70D6
-#define GOLDENROD   0xDAA520
-#define PALEVIOLETRED   0xDB7093
-#define CRIMSON     0xDC143C
-#define GAINSBORO   0xDCDCDC
-#define PLUM      0xDDA0DD
-#define BURLYWOOD   0xDEB887
-#define LIGHTCYAN   0xE0FFFF
-#define LAVENDER    0xE6E6FA
-#define DARKSALMON    0xE9967A
-#define VIOLET      0xEE82EE
-#define PALEGOLDENROD   0xEEE8AA
-#define LIGHTCORAL    0xF08080
-#define KHAKI     0xF0E68C
-#define ALICEBLUE   0xF0F8FF
-#define HONEYDEW    0xF0FFF0
-#define AZURE     0xF0FFFF
-#define SANDYBROWN    0xF4A460
-#define WHEAT     0xF5DEB3
-#define BEIGE     0xF5F5DC
-#define WHITESMOKE    0xF5F5F5
-#define MINTCREAM   0xF5FFFA
-#define GHOSTWHITE    0xF8F8FF
-#define SALMON      0xFA8072
-#define ANTIQUEWHITE    0xFAEBD7
-#define LINEN     0xFAF0E6
-#define LIGHTGOLDENRODYELLOW  0xFAFAD2
-#define OLDLACE     0xFDF5E6
-#define RED     0xFF0000
-#define FUCHSIA     0xFF00FF
-#define MAGENTA     0xFF00FF
-#define DEEPPINK    0xFF1493
-#define ORANGERED   0xFF4500
-#define TOMATO      0xFF6347
-#define HOTPINK     0xFF69B4
-#define CORAL     0xFF7F50
-#define DARKORANGE    0xFF8C00
-#define LIGHTSALMON   0xFFA07A
-#define ORANGE      0xFFA500
-#define LIGHTPINK   0xFFB6C1
-#define PINK      0xFFC0CB
-#define GOLD      0xFFD700
-#define PEACHPUFF   0xFFDAB9
-#define NAVAJOWHITE   0xFFDEAD
-#define MOCCASIN    0xFFE4B5
-#define BISQUE      0xFFE4C4
-#define MISTYROSE   0xFFE4E1
-#define BLANCHEDALMOND    0xFFEBCD
-#define PAPAYAWHIP    0xFFEFD5
-#define LAVENDERBLUSH   0xFFF0F5
-#define SEASHELL    0xFFF5EE
-#define CORNSILK    0xFFF8DC
-#define LEMONCHIFFON    0xFFFACD
-#define FLORALWHITE   0xFFFAF0
-#define SNOW      0xFFFAFA
-#define YELLOW      0xFFFF00
-#define LIGHTYELLOW   0xFFFFE0
-#define IVORY     0xFFFFF0
-#define WHITE     0xFFFFFF
-
 #include <Adafruit_NeoPixel.h>

-#define PIN 13
+#define SOUND_PIN 2 // Use Pin 10 as our Input
+#define LED_PIN 13
 #define LED_COUNT 60
+#define STRIP_COUNT 1

-// Create an instance of the Adafruit_NeoPixel class called "leds".
-// That'll be what we refer to from here on...
-Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel strips[STRIP_COUNT] = {
+  Adafruit_NeoPixel(LED_COUNT, 13, NEO_GRB + NEO_KHZ800)
+};

-/*
-* Connect sound sensor to digital pin 2
-* We will use the onboard lED to indicate sound detected and output to sr=erial monitor
-*/
-#define soundPin 2 // Use Pin 10 as our Input
+boolean lights[LED_COUNT];

-int soundValue = HIGH; // This is where we record our Sound Measurement
-boolean bSound = false;
-unsigned long lastSoundTime; // Record the time that we measured a sound
-int soundTime = 300; // Number of milli seconds to keep the sound alarm high
+int soundValue    = HIGH;
+boolean bSound    = false;
+int soundTime     = 10; // Number of milli seconds to keep the sound alarm high
+unsigned long lastSoundTime;
+boolean animate   = false;

 void setup () {
   Serial.begin(9600);
-  pinMode (soundPin, INPUT) ; // input from the Sound Detection Module
-  //pinMode(led, OUTPUT);
-  leds.begin();  // Call this to start up the LED strip.
-  leds.show();   // turn leds off
+  pinMode (SOUND_PIN, INPUT) ;
+  for (int i = 0; i < STRIP_COUNT; i++)
+  {
+    strips[i].begin();
+    strips[i].show();
+  }
 }

 void loop ()
 {
-  //clearLEDs();
-  //digitalWrite(13, HIGH);
-  soundValue = digitalRead (soundPin) ; // read the sound alarm time
-  //Serial.println(soundValue);
-  if (soundValue == LOW) // If we hear a sound
+  soundValue = digitalRead (SOUND_PIN) ;
+  if (soundValue == LOW)
   {
-
     lastSoundTime = millis(); // record the time of the sound alarm
-    // We don't want to fill up monitor
     if (!bSound){
-      Serial.println("##########    #########       #########");
-      Serial.println("    #         #       #       #       #");
-      Serial.println("    #         #       #       #       #");
-      Serial.println("    #         #########       #########");
-      Serial.println("    #         #       #       #");
-      Serial.println("    #         #       #       #");
-      Serial.println("    #         #       #       #");
-      Serial.println("\n\n\n");
-      //digitalWrite(led, HIGH);
-      lightOn(VIOLET);
+      pulse(); // Someone just hit the drum
+      animate = false;
       bSound = true;
+      return;
     }
   }
-  else
-  {
-    if( (millis()-lastSoundTime) > soundTime && bSound){
-      Serial.println("quiet");
-      //cylon(MEDIUMSPRINGGREEN, 1);
-      lightOn(BLUE);
-      bSound = false;
+  else if( (millis()-lastSoundTime) > soundTime && bSound){
+    Serial.println("quiet");
+    //cylon(MEDIUMSPRINGGREEN, 1);
+    animate = true;
+    bSound = false;
+  }
+
+  tick();
+}
+
+/**
+ *
+ * Continues the animation
+ */
+void tick()
+{
+  if (!animate) {
+    return;
+  }
+
+  int r = 255;
+  int g = 0;
+  int b = 255;
+
+  for (int i = 0; i < STRIP_COUNT; i++)
+  {
+    for (int j = LED_COUNT -1; j > 0; j--)
+    {
+      if (lights[j - 1] == true) {
+        lights[j] = true;
+        lights[j - 1] = false;
+      }
+      if (lights[j]) {
+        strips[i].setPixelColor(j, r, g, b);
+      } else {
+        strips[i].setPixelColor(j, 0, 0, 0);
+      }
     }
+    strips[i].show();
   }
 }

-// Sets all LEDs to off, but DOES NOT update the display;
-// call leds.show() to actually turn them off after this.
-void lightOff()
+/**
+ *
+ * Makes all the lights blink at the same time
+ */
+void pulse()
 {
-  for (int i = 0; i < LED_COUNT; i++)
+  for (int i = 0; i < STRIP_COUNT; i++)
   {
-    leds.setPixelColor(i, 0, 0, 0);
-  }
-  Serial.println("CLEARED");
-  leds.show();
-}
-
-
-void lightOn(unsigned long color)
-{
-  byte red = (color & 0xFF0000) >> 16;
-  byte green = (color & 0x00FF00) >> 8;
-  byte blue = (color & 0x0000FF);
-
-  // Start at closest LED, and move to the outside
-  for (int i = 0; i <= LED_COUNT; i++)
-  {
-    leds.setPixelColor(i, 232, 134, 0);
-  }
-  leds.show();
-}
-
-// Implements a little larson "cylon" sanner.
-// This'll run one full cycle, down one way and back the other
-void cylon(unsigned long color, byte wait)
-{
-  // weight determines how much lighter the outer "eye" colors are
-  const byte weight = 4;
-  // It'll be easier to decrement each of these colors individually
-  // so we'll split them out of the 24-bit color value
-  byte red = (color & 0xFF0000) >> 16;
-  byte green = (color & 0x00FF00) >> 8;
-  byte blue = (color & 0x0000FF);
-
-  // Start at closest LED, and move to the outside
-  for (int i = 0; i <= LED_COUNT - 1; i++)
-  {
-    lightOff();
-    leds.setPixelColor(i, red, green, blue);  // Set the bright middle eye
-    // Now set two eyes to each side to get progressively dimmer
-    for (int j = 1; j < 3; j++)
+    for (int j = 0; j < LED_COUNT; j++)
     {
-      if (i - j >= 0)
-        leds.setPixelColor(i - j, red / (weight * j), green / (weight * j), blue / (weight * j));
-      if (i - j <= LED_COUNT)
-        leds.setPixelColor(i + j, red / (weight * j), green / (weight * j), blue / (weight * j));
+      strips[i].setPixelColor(j, 0, 0, 255);
     }
-    leds.show();  // Turn the LEDs on
-    delay(wait);  // Delay for visibility
+    strips[i].show();
   }

-  // Now we go back to where we came. Do the same thing.
-  for (int i = LED_COUNT - 2; i >= 1; i--)
-  {
-    lightOff();
-    leds.setPixelColor(i, red, green, blue);
-    for (int j = 1; j < 3; j++)
-    {
-      if (i - j >= 0)
-        leds.setPixelColor(i - j, red / (weight * j), green / (weight * j), blue / (weight * j));
-      if (i - j <= LED_COUNT)
-        leds.setPixelColor(i + j, red / (weight * j), green / (weight * j), blue / (weight * j));
-    }
-
-    leds.show();
-    delay(wait);
-  }
+  lights[0] = true;
+  lights[1] = true;
+  lights[2] = true;
+  lights[3] = true;
+  lights[4] = true;
 }


Flipped greater than in time if

Flipped greater than in time if

--- Arduino_HVAC_Controller/Networked_HVAC_Controller/Networked_HVAC_Controller.ino
+++ Arduino_HVAC_Controller/Networked_HVAC_Controller/Networked_HVAC_Controller.ino
@@ -185,7 +185,7 @@
     lcd.print(currentTemp);
   }

-  if ((millis() - timeDelay) < 10000) {
+  if ((millis() - timeDelay) > 10000) {
     hoursSeconds = get_time();
     timeDelay = millis();
   }


Cleaned up various bits

Cleaned up various bits

--- Arduino_HVAC_Controller/Networked_HVAC_Controller/Networked_HVAC_Controller.ino
+++ Arduino_HVAC_Controller/Networked_HVAC_Controller/Networked_HVAC_Controller.ino
@@ -1,7 +1,7 @@
 // name:     Networked_HVAC_Controller.ino
 // author:   Chad Hobbs
 // created:  130121
-// last edit: 130121
+// last edit: 130128
 //
 // description: This program controls multiple temperature sensors via the 1-wire protocol, and turns off and on an HVAC system based on
 // presets. It communicates with a server to provide data and remote access/control.
@@ -58,14 +58,11 @@
 unsigned long hoursSeconds = 0;             // Return variable for the get_Time function
 unsigned long timeDelay = 0;                // Counter to prevent time from getting retrieved too often
 const int timeZone = -5;                    // Eastern Standard Time (USA)
-time_t prevDisplay = 0;                     // TODO REMOVE _________________________________

 // --------------- NTP Variables ---------------
 const int NTP_PACKET_SIZE = 48;             // NTP time is in the first 48 bytes of message
 byte packetBuffer[NTP_PACKET_SIZE];         //buffer to hold incoming & outgoing packets
-
-

 // --------------- LCD Shield Variables ---------------
@@ -73,7 +70,6 @@
 char* menu[] = {"Cooling", "Heating"};  // Menu display for either setting the high point or the low point of the temp range
 int menuPosition = 1;             // Current position in the setting menu
 boolean editable = FALSE;         // Determines whether or not button presses will do anything, used to avoid accidental changes
-

 // --------------- General Variables ---------------
@@ -89,15 +85,6 @@
 unsigned long coolLastRan;        // Stores the time the AC last ran

-
-
-
-
-
-
-
-
-
 // -------------Library Interaction--------------

 #define ONE_WIRE_BUS busPin       // Data wire is plugged into busPin on the Arduino
@@ -125,15 +112,6 @@

-
-
-
-
-
-
-
-
-
 // ----------------------------------------------------------------------------------------
 // Function Name: setup()
 // Parameters:    None
@@ -173,6 +151,11 @@
 // Description:   This is the main executing block of the program, calling all ancillary functions to operate the Arduino
 // ----------------------------------------------------------------------------------------
 void loop(){
+
+  uint8_t buttons = lcd.readButtons();  // Constantly check to see if something has been put on the bus
+
+  power_control();                      // Handle Heat and Cooling Cycles
+

   if ((millis() - timeOut) > 30000) {   // Turn on backlight for 30 seconds, else turn it off
     lcd.setBacklight(OFF);
@@ -183,7 +166,6 @@

-  uint8_t buttons = lcd.readButtons();  // Constantly check to see if something has been put on the bus

   // --------------Handle updating Temp and Time change display---------------------
   if ((millis() - timeDelay) > 10000) {    // Update every 10 seconds
@@ -193,7 +175,6 @@
     lcd.print(get_temp());
     lcd.setCursor(0, 1);
     lcd.print(get_time());
-
     timeDelay = millis();
   }

@@ -203,7 +184,6 @@
   if (buttons) {
     timeOut = millis();
     lcd.setBacklight(ON);
-

     if (buttons & BUTTON_SELECT) {      // Allow parameters to be changed only if the Select button has been pressed first
       editable = TRUE;
@@ -213,8 +193,7 @@
     }
   }

-  // --------------Handle Heat and Cooling Cycles---------------------
-  power_control();
+

 }

@@ -386,8 +365,8 @@
 // ----------------------------------------------------------------------------------------
 // Function Name: get_time()
 // Parameters:    None
-// Returns:       An unsigned long representing time in hours and minutes
-// Description:   TODO ____________________________________________________
+// Returns:       A string representing the time and date
+// Description:   This function gets the current time and returns it as a string to display
 // ----------------------------------------------------------------------------------------
 String get_time() {
   String timeString = "";
@@ -437,7 +416,7 @@
 // Function Name: getNtpTime()
 // Parameters:    None
 // Returns:       Variable time_t, a time object
-// Description:   TODO
+// Description:   Queries the NTP server to get the current universal time, in UTC
 // ----------------------------------------------------------------------------------------
 time_t getNtpTime()
 {


Delete motorcontrol.ino

Delete motorcontrol.ino

--- motorcontrol.ino
+++ motorcontrol.ino
@@ -1,115 +0,0 @@
-#include "Time.h"
-#include "math.h"
-
-
-/* Rotary encoder read example */
-#define ENC_A 14
-#define ENC_B 15
-#define ENC_PORT PINC
-#define DC_MOTOR 9
-
-
-time_t time_start = micros();
-time_t time_end = 0;
-
-time_t from_last_speedup = 0;
-time_t speeduptime = millis();
-
-const float pi = 3.141593;
-float target_w = 0;
-float omega = (2*pi * pow(10,6)) / (time_end - time_start);   //angular velocity rad/s
-
-
-
-
-
-void setup()
-{
-  /* Setup encoder pins as inputs */
-  pinMode(ENC_A, INPUT);
-  digitalWrite(ENC_A, HIGH);
-  pinMode(ENC_B, INPUT);
-  digitalWrite(ENC_B, HIGH);
-  pinMode(DC_MOTOR, OUTPUT);
-
-  Serial.begin (115200);
-  Serial.println("Start");
-  Serial.println("give the target angular velocity (int)");
-  target_w = read_serial();
-  //starting motor and waiting for a bit
-  analogWrite(DC_MOTOR, 255);
-  delay(100);
-}
-
-void loop()
-{
-  static uint16_t counter = 0;      //this variable will be changed by encoder input
-  int16_t tmpdata;
-
-  /**/
-  tmpdata = read_encoder();
-
-  //if enough time has passed since the last speed change -> check if wanted speed
-  /*
-  from_last_speedup = millis() - speeduptime;
-  if( from_last_speedup > 100){
-      analogWrite(DC_MOTOR, map(target_w, 0, 1000, 0, 255);
-  }*/
-
-
-  if( tmpdata ) {
-    if( !(counter % 50)){
-      Serial.print("Counter value: ");
-      Serial.println(counter, DEC);
-    }
-    counter += tmpdata;
-    counter = counter % 4092;
-
-    if( !(counter) ) {
-      time_end = micros();
-      omega = (2*pi * pow(10,6)) / (time_end - time_start);
-      Serial.print("angular velocity: ");
-      Serial.println(omega, 5);
-      time_start = micros();
-
-
-    }
-  }
-}
-
-
-/* reads the serial for user inputted numbers*/
-int read_serial()
-{
-  char intBuffer[12];
-  String intData = "";
-  int delimiter = (int) '\n';
-
-  while(!Serial.available());
-    while(1){
-      int ch = Serial.read();
-      if(ch == -1) {}
-      else if (ch == delimiter) {
-        break;
-      }
-      else {
-        intData += (char) ch;
-    }
-  }
-  int intLength = intData.length() +1;
-  intData.toCharArray(intBuffer, intLength);
-  intData = "";
-  int i = atoi(intBuffer);
-  return i;
-}
-
-/* returns change in encoder state (-1,0,1) */
-int16_t read_encoder()
-{
-  static int16_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
-  static uint16_t old_AB = 0;
-  /**/
-  old_AB <<= 2;                   //remember previous state
-  old_AB |= ( ENC_PORT & 0x03 );  //add current state
-  return ( enc_states[( old_AB & 0x0f )]);
-}


fix typo

fix typo

--- super_freq/super_freq.ino
+++ super_freq/super_freq.ino
@@ -569,7 +569,7 @@
     // So, if we check our strip_color to determine if
     // the current color is "off" we would have to do
     // some bit shifting and bit masking. Instead,
-    // we just read the first LED instead.
+    // we just read the first LED.
     if (strip.getPixelColor(0) <= 0) {
         return;
     }


removed overide of goaldetected

removed overide of goaldetected

--- master/master.ino
+++ master/master.ino
@@ -873,7 +873,7 @@
 		else{
 			kickTime = KICK_TIME;
 		}
-		goalDetected = true;
+
 		if (ballInZone && goalDetected && abs(goalAngle) < 10){
 			// GO!
 			targetDir = goalAngle;


Small logic change for hi score delay.

Small logic change for hi score delay.

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -217,17 +217,18 @@
   printText("3.  000000  AAA", 15, 45, 1);
   printText("4.  000000  AAA", 15, 57, 1);
   arduboy.display();
-
   while (totalDelay < 4000) {
-    delay(15);
-    totalDelay += 15;
-
     if (arduboy.pressed(UP_BUTTON) || arduboy.pressed(DOWN_BUTTON) || arduboy.pressed(LEFT_BUTTON) || arduboy.pressed(RIGHT_BUTTON) || arduboy.pressed(A_BUTTON)  || arduboy.pressed(B_BUTTON)) {
       if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
         totalDelay = 4000;
         lastDebounceTime = millis();
       }
-    }
+    }
+
+    if (totalDelay < 4000) {
+      delay(15);
+      totalDelay += 15;
+    }
   }
 }


Improved debugging

Improved debugging

--- arduino/fasnacht/fasnacht.ino
+++ arduino/fasnacht/fasnacht.ino
@@ -93,47 +93,51 @@
     ChannelFrq = ChannelCount * 100 / time / 2 * 10;

     //get channel data and write output LEFT AUIO CHANNEL
+    Serial.print(ValueCount);
+    Serial.print(" ");
     if( (ValueFrq > 140) && (ValueFrq <= 160) ) {
       digitalWrite(3, 0); //B
       digitalWrite(5, 0); //D
       Serial.println("B OFF D OFF ");
-    }
-    if( (ValueFrq > 240) && (ValueFrq <= 260) ) {
+    } else if( (ValueFrq > 240) && (ValueFrq <= 260) ) {
       digitalWrite(3, 1); //B
       digitalWrite(5, 0); //D
       Serial.println("B ON  D OFF ");
-    }
-    if( (ValueFrq > 340) && (ValueFrq <= 360) ) {
+    } else if( (ValueFrq > 340) && (ValueFrq <= 360) ) {
       digitalWrite(3, 0); //B
       digitalWrite(5, 1); //D
       Serial.println("B OFF D ON  ");
-    }
-    if( (ValueFrq > 440) && (ValueFrq <= 460) ) {
+    } else if( (ValueFrq > 440) && (ValueFrq <= 460) ) {
       digitalWrite(3, 1); //B
       digitalWrite(5, 1); //D
       Serial.println("B ON  D ON  ");
+    } else {
+      Serial.print(ValueCount);
+      Serial.println(" UNKNOWN B / D");
     }

     //get channel data and write output RIGHT AUIO CHANNEL
+    Serial.print(ChannelCount);
+    Serial.print(" ");
     if( (ChannelFrq > 140) && (ChannelFrq <= 160) ) {
       digitalWrite(6, 0); //E
       digitalWrite(9, 0); //H
       Serial.println("E OFF H OFF ");
-    }
-    if( (ChannelFrq > 240) && (ChannelFrq <= 260) ) {
+    } else if( (ChannelFrq > 240) && (ChannelFrq <= 260) ) {
       digitalWrite(6, 1); //E
       digitalWrite(9, 0); //H
       Serial.println("E ON  H OFF ");
-    }
-    if( (ChannelFrq > 340) && (ChannelFrq <= 360) ) {
+    } else if( (ChannelFrq > 340) && (ChannelFrq <= 360) ) {
       digitalWrite(6, 0); //E
       digitalWrite(9, 1); //H
       Serial.println("E OFF H ON  ");
-    }
-    if( (ChannelFrq > 440) && (ChannelFrq <= 460) ) {
+    } else if( (ChannelFrq > 440) && (ChannelFrq <= 460) ) {
       digitalWrite(6, 1); //E
       digitalWrite(9, 1); //H
       Serial.println("E ON  H ON  ");
+    } else {
+      Serial.print(ChannelFrq);
+      Serial.println(" UNKNOWN E / H");
     }

     /*


put all strings into program memory

put all strings into program memory

--- arduino/sensebox/sensebox.ino
+++ arduino/sensebox/sensebox.ino
@@ -14,6 +14,7 @@
 #include <Makerblog_TSL45315.h>
 #include <SPI.h>
 #include <Ethernet.h>
+#include <avr/pgmspace.h>

 //SenseBox ID
 #define SENSEBOX_ID "5719c4037514d05c121e317c"
@@ -53,20 +54,20 @@
   // Open serial communications and wait for port to open:
   Serial.begin(9600);
   // start the Ethernet connection:
-  Serial.println("SenseBox Home software version 2.1");
+  Serial.println(F("SenseBox Home software version 2.1"));
   Serial.println();
-  Serial.print("Starting ethernet connection...");
+  Serial.print(F("Starting ethernet connection..."));
   if (Ethernet.begin(mac) == 0) {
-    Serial.println("Failed to configure Ethernet using DHCP");
+    Serial.println(F("Failed to configure Ethernet using DHCP"));
     Ethernet.begin(mac, myIp);
   }
-  Serial.print("IP: ");
+  Serial.print(F("IP: "));
   Serial.print(Ethernet.localIP());
-  Serial.print(" Gateway: ");
+  Serial.print(F(" Gateway: "));
   Serial.println(Ethernet.gatewayIP());
   delay(1000);
   //Initialize sensors
-  Serial.print("Initializing sensors...");
+  Serial.print(F("Initializing sensors..."));
   Wire.begin();
   Wire.beginTransmission(UV_ADDR);
   Wire.write((IT_1<<2) | 0x02);
@@ -75,9 +76,9 @@
   HDC.begin(HDC100X_TEMP_HUMI,HDC100X_14BIT,HDC100X_14BIT,DISABLE);
   TSL.begin();
   BMP.begin();
-  BMP.setOversampling(2);
-  Serial.println("done!");
-  Serial.println("Starting loop.");
+  BMP.setOversampling(3);
+  Serial.println(F("done!"));
+  Serial.println(F("Starting loop."));
   temperature = HDC.getTemp();
 }

@@ -93,45 +94,45 @@
   if (millis() - oldTime > postingInterval) {
     oldTime = millis();
     //-----Pressure-----//
-    Serial.println("Posting pressure");
+    Serial.println(F("Posting pressure"));
     messTyp = 2;
     char result = BMP.startMeasurment();
     if(result!=0){
       delay(result);
       result = BMP.getTemperatureAndPressure(tempBaro,pressure);
       postObservation(pressure, PRESSURESENSOR_ID, SENSEBOX_ID);
-      Serial.print("Temp_baro = ");Serial.println(tempBaro,2);
-      Serial.print("Pressure  = ");Serial.println(pressure,2);
+      Serial.print(F("Temp_baro = "));Serial.println(tempBaro,2);
+      Serial.print(F("Pressure  = "));Serial.println(pressure,2);
     } else {
-      Serial.print("Error: ");Serial.println((int)BMP.getError());
+      Serial.print(F("Error: "));Serial.println((int)BMP.getError());
     }
     delay(2000);
     //-----Humidity-----//
-    Serial.println("Posting humidity");
+    Serial.println(F("Posting humidity"));
     messTyp = 2;
     humidity = HDC.getHumi();
-    Serial.print("Humidity = "); Serial.println(humidity);
+    Serial.print(F("Humidity = ")); Serial.println(humidity);
     postObservation(humidity, HUMISENSOR_ID, SENSEBOX_ID);
     delay(2000);
     //-----Temperature-----//
-    Serial.println("Posting temperature");
+    Serial.println(F("Posting temperature"));
     messTyp = 2;
     temperature = HDC.getTemp();
     //Serial.println(temperature,2);
-    Serial.print("Temperature = ");Serial.println(temperature);
+    Serial.print(F("Temperature = "));Serial.println(temperature);
     postObservation(temperature, TEMPSENSOR_ID, SENSEBOX_ID);
     delay(2000);
     //-----Lux-----//
-    Serial.println("Posting illuminance");
+    Serial.println(F("Posting illuminance"));
     messTyp = 1;
     lux = TSL.readLux();
-    Serial.print("Illumi = "); Serial.println(lux);
+    Serial.print(F("Illumi = ")); Serial.println(lux);
     postObservation(lux, LUXSENSOR_ID, SENSEBOX_ID);
     delay(2000);
     //UV intensity
     messTyp = 1;
     uv = getUV();
-    Serial.print("UV = "); Serial.println(uv);
+    Serial.print(F("UV = ")); Serial.println(uv);
     postObservation(uv, UVSENSOR_ID, SENSEBOX_ID);
   }
 }
@@ -143,24 +144,24 @@
   Serial.println(obs);
   //json must look like: {"value":"12.5"}
   //post observation to: http://opensensemap.org:8000/boxes/boxId/sensorId
-  Serial.println("connecting...");
+  Serial.println(F("connecting..."));
   String value = "{\"value\":";
   value += obs;
   value += "}";
   if (client.connect(server, 8000))
   {
-    Serial.println("connected");
+    Serial.println(F("connected"));
     // Make a HTTP Post request:
-    client.print("POST /boxes/");
+    client.print(F("POST /boxes/"));
     client.print(boxId);
-    client.print("/");
+    client.print(F("/"));
     client.print(sensorId);
-    client.println(" HTTP/1.1");
+    client.println(F(" HTTP/1.1"));
     // Send the required header parameters
-    client.println("Host:opensensemap.org");
-    client.println("Content-Type: application/json");
-    client.println("Connection: close");
-    client.print("Content-Length: ");
+    client.println(F("Host:opensensemap.org"));
+    client.println(F("Content-Type: application/json"));
+    client.println(F("Connection: close"));
+    client.print(F("Content-Length: "));
     client.println(value.length());
     client.println();
     // Send the data
@@ -185,7 +186,7 @@
     if (!client.connected())
     {
       Serial.println();
-      Serial.println("disconnecting.");
+      Serial.println(F("disconnecting."));
       client.stop();
       repeat = false;
     }


add todo

add todo

--- arduino/sensor_server/thermometer_client.ino
+++ arduino/sensor_server/thermometer_client.ino
@@ -45,6 +45,7 @@
 //      - Wait until they both complete.
 //      - Wake up, read temperature, and save it to memory.
 //      - Go back to sleep.
+//      - Encryption
 //   2) Use the radio's low power operation mode.
 //   3) Right now we sleep for INTERVAL millis, so each iteration will last INTERVAL plus whatever
 //      it takes to run. It would be nice to make each loop last INTERVAL millis.


instruemnts work as well. checkout setup how an instrument sequence msg with notes looks like

--- msgSeq/msgSeq.ino
+++ msgSeq/msgSeq.ino
@@ -1,13 +1,15 @@
 #include <Process.h>

-String hashTags[] = {"PS", "BD", "SD", "KI", "SN", "CR","I1","I2"};
+String hashTags[] = {"PS", "BD", "SD", "KI", "SN", "CR", "I1", "I2"};
 //PS: play sample, BD: bass drum, SD: snare, KI: kick,SN: snare, CR: crash
 //I1: instrument 1, I2: instrument 2
 // marker // TODO
-int drumsStart = 1;
-int drumsEnd = 5;
-int instrumentStart = 6;
-int instrumentEnd = 7;
+const int DRUMSSTART = 1;
+const int DRUMSEND = 5;
+const int INSTRUMENTSTART = 6;
+const int INSTRUMENTEND = 7;
+const int EFFECTSTART = 8;
+const int EFFECTEND = 10;
 //
 const int numIns = 6;
 byte patterns[numIns - 1];
@@ -24,6 +26,9 @@
 int pos;
 // sequence-bits
 int bs[] = {1, 2, 4, 8, 16, 32, 64, 128, 256};
+
+int instrument_1_seq[8];
+int instrument_2_seq[8];

 const String sampleFolder = "/mnt/twitterOrchestra/samples/";

@@ -75,30 +80,36 @@
   }
   if (tag == 0)
     playSample(msg.substring(hashInd + 4));
-  else {
-    tag--;
-    // pattern
+  else if (tag >= DRUMSSTART && tag <= DRUMSEND) {
     String pa = msg.substring(hashInd + 4, hashInd + 4 + patternL);
-    if (pa.charAt(0) == 'p') {
-      playDrumSample(s);
-    }
-    byte pattern = 0;
-    Serial.println(pa);
-    for (int i = 0; i < patternL; i++) {
-      pattern = pattern << 1;
-      byte b = pa.charAt(i) == '1' ? 1 : 0;
-      pattern += b;
-    }
-    Serial.println(pattern);
-    patterns[tag] = pattern;
+    drums(tag - DRUMSSTART, pa);
+  } else if (tag >= INSTRUMENTSTART && tag <= INSTRUMENTEND) {
+
   }
 }

 void playSample(String sampleName) {
   Process p;
-  p.runShellCommandAsynchronously("madplay " + sampleFolder + sampleName+".wav");
+  p.runShellCommandAsynchronously("madplay " + sampleFolder + sampleName + ".wav");
 }

-void playDrumSample(String sampleName) {
-
+void playDrumSample(int tag) {
+
+}
+
+void drums(int tag, String patternS) {
+  // pattern
+  if (patternS.charAt(0) == 'p') {
+    playDrumSample(tag);
+    return;
   }
+  byte pattern = 0;
+  Serial.println(patternS);
+  for (int i = 0; i < patternL; i++) {
+    pattern = pattern << 1;
+    byte b = patternS.charAt(i) == '1' ? 1 : 0;
+    pattern += b;
+  }
+  Serial.println(pattern);
+  patterns[tag] = pattern;
+}


print emoncms url to serial

print emoncms url to serial

--- projects/YunHub/YunHub.ino
+++ projects/YunHub/YunHub.ino
@@ -160,6 +160,7 @@
                      + String(dataPackage.Vcc);

         client.get(emonapiurl);
+        Serial.println(emonapiurl);

         //
     }


Removed unecessary lines

Removed unecessary lines

--- node_A/node_A.ino
+++ node_A/node_A.ino
@@ -22,7 +22,6 @@
   unsigned light;
   unsigned door;
   unsigned long hkey;
-  unsigned test; //why isn't it working ?
 };

 struct data_received {
@@ -47,11 +46,11 @@
 const int doorPinA  = 2;
 const int led_A_Pin = 6;
 const int led_B_Pin = 5;
-volatile bool led_B_state = LOW;
+bool led_B_state = LOW;
 const int buzzPin   = 9;
-volatile bool buzzPin_state = LOW;
+bool buzzPin_state = LOW;
 unsigned long start_buzz_time = 0;
-volatile bool soft_alarm_state = false;
+bool soft_alarm_state = false;

 unsigned long currentTime = 0;
 unsigned long startTime   = 0;


changes in version 0.10:        * added temperatureDifference to fix DHT measurements with existing thermostat        * reduced END_OF_CYCLE_TIMEOUT to one sec since the HVAC controller           takes care of waiting of evacuating the heat/cold from the vents

--- minimalistthermostat.ino
+++ minimalistthermostat.ino
@@ -24,12 +24,16 @@
 #include "FiniteStateMachine.h"
 #define APP_NAME "Thermostat"

-String VERSION = "Version 0.09";
+String VERSION = "Version 0.10";
 /*******************************************************************************
  * changes in version 0.09:
        * reorganized code to group functions
        * added minimum time to protect on-off on the fan and the heating element
           in function heatingUpdateFunction()
+ * changes in version 0.10:
+       * added temperatureDifference to fix DHT measurements with existing thermostat
+       * reduced END_OF_CYCLE_TIMEOUT to one sec since the HVAC controller
+          takes care of waiting of evacuating the heat/cold from the vents
 *******************************************************************************/

 /*******************************************************************************
@@ -50,7 +54,7 @@

 //milliseconds to leave the fan on when the target temp has been reached
 //this evacuates the heat or the cold air from vents
-#define END_OF_CYCLE_TIMEOUT 15000
+#define END_OF_CYCLE_TIMEOUT 1000
 elapsedMillis endOfCycleTimer;

 //minimum number of milliseconds to leave the heating element on
@@ -93,7 +97,11 @@
 float targetTemp = 19.0;
 float currentTemp = 20.0;
 float currentHumidity = 0.0;
-float margin = 0.5;
+float margin = 0.3;
+//DHT difference with real temperature (if none set to zero)
+//use this variable to fix DHT measurements with your existing thermostat
+float temperatureDifference = -1.6;
+
 //temperature related variables - to be exposed in the cloud
 String targetTempString = String(targetTemp); //String to store the target temp so it can be exposed and set
 String currentTempString = String(currentTemp); //String to store the sensor's temp so it can be exposed
@@ -110,7 +118,7 @@
  *******************************************************************************/
 void setup() {

-  //pulish startup message with firmware version
+  //publish startup message with firmware version
   Particle.publish(APP_NAME, VERSION, 60, PRIVATE);

   //declare and init pins
@@ -233,8 +241,12 @@
     return 0;
   }

+  //sample acquired, adjust DHT difference if any
+  float tmpTemperature = (float)DHT.getCelsius();
+  tmpTemperature = tmpTemperature + temperatureDifference;
+
   //sample acquired - go ahead and store temperature and humidity in internal variables
-  publishTemperature( (float)DHT.getCelsius(), (float)DHT.getHumidity() );
+  publishTemperature( tmpTemperature, (float)DHT.getHumidity() );

   //reset the sample flag so we can take another
   bDHTstarted = false;
@@ -265,8 +277,8 @@
  currentHumidityString = String(currentHumidityChar);

  //publish readings
- Particle.publish(APP_NAME, "Current temperature: " + currentTempString, 60, PRIVATE);
- Particle.publish(APP_NAME, "Current humidity: " + currentHumidityString, 60, PRIVATE);
+ Particle.publish(APP_NAME, "Home temperature: " + currentTempString, 60, PRIVATE);
+ Particle.publish(APP_NAME, "Home humidity: " + currentHumidityString, 60, PRIVATE);

  return 0;


Changed code

Changed code

--- module_Communication.ino
+++ module_Communication.ino
@@ -62,7 +62,7 @@
     ether.packetLoop(ether.packetReceive());

     const char* reply = ether.tcpReply(session);
-    if (reply != 0) {
+    if (reply == 0) {
         Serial.println("Got a response!");
         Serial.println(reply);
     }


modified:   pulse_width_modulation/pulse_width_modulation.ino

--- pulse_width_modulation/pulse_width_modulation.ino
+++ pulse_width_modulation/pulse_width_modulation.ino
@@ -16,6 +16,7 @@
    * analogWrite values from 0 to 255
    */
     analogWrite(ledPin, val / 4);
+//    analogWrite(ledPin, map(val, 0,1023,0,255)); // <-- This is actually better

 }


Revised Sketch to reduce display flicker while in numerical readout modes

Signed-off-by: jmhrvy <6a3cd8a1b2d47d05877db3d1fefa06cbe0a9a3f0@epbfi.com>

--- CNCSpindleSpeedControl/CNCSpindleSpeedControl.ino
+++ CNCSpindleSpeedControl/CNCSpindleSpeedControl.ino
@@ -146,7 +146,7 @@

 // the event counter
 volatile int eventCounter = 0;
-volatile int LoopCounter = 0;
+//volatile int LoopCounter = 0;

 char buf [16]; // used to concatenate strings & numerical data for display on SanSmart LCD

@@ -292,7 +292,7 @@
      SpndlPWM = CalcMtrPID(calcrpm);//Max+CalcMtrPID(calcrpm);
      analogWrite(PWMpin, SpndlPWM);
      dutycycle = (int)((SpndlPWM*100)/(Max));//(int)((SpndlPWM*100)/(2*Max));// convert PWM signal to a precentage
-    LoopCounter = 1;//reset loopcounter so main loop will know that Motor is still running
+   // LoopCounter = 1;//reset loopcounter so main loop will know that Motor is still running
     eventCounter = 0;
     }
 //   delay(3); //wait at least the equivalent of 20K rpm before reacting to another spindle interrupt
@@ -355,6 +355,7 @@
   bool UpdtDis = false;
   chkBtns = true;
   unsigned long CurPrdTime;
+  unsigned long lstDspTime =millis();
   lcd.setCursor(0,1);
   lcd.print("Speed Cntl Ready");
   lcd.setCursor(0,0);
@@ -376,7 +377,7 @@
     if(CurPrdTime >= Maxperiod/1000 ){// if true, it looks like the motor isn't turning

       eventCounter = 0;
-      LoopCounter = 0;
+     // LoopCounter = 0;
       LstIntTime = millis();
       NewTrgtVal = true;
       ActivIntrpt = false;
@@ -391,7 +392,7 @@
       //sprintf (buf, "PWMpin:%02i PWM:%02i", PWMpin, SpndlPWM);
       //Serial.println(buf);
       //delay(100);
-      UpdtDis = ScanButtons();
+      ScanButtons();

       if (NewTrgtVal)
        {
@@ -417,7 +418,13 @@
       lcd.print(buf);
       NewTrgtVal = false;
     }
+    if((millis()-lstDspTime)>500){
+      UpdtDis= true;
+      lstDspTime =millis();
+    }
+    else UpdtDis= false;
     if (UpdtDis){
+      //Serial.println(millis()-lstDspTime);
       lcd.setCursor(0,1);//lcdPosition (lcdHandle, 0, 1) ;
      if (Mode == 7) // Original Display Mode; Show Measured RPM, on the 2nd line
       {
@@ -532,8 +539,10 @@
 // ############ End O-Scope Mode #################

-   UpdtDis = ScanButtons();
-   if (UpdtDis)  LoopCounter++;
+   ScanButtons();
+//   if (UpdtDis){
+//    LoopCounter++;
+//   }
    long TotalRunTime = calcruntime();
   } //end of 1st while loop
  //kill the PWM signal
@@ -643,7 +652,7 @@
 // ================================================================

-bool ScanButtons()
+void ScanButtons()
 {
   if(!chkBtns){
     if (millis()-QrtrSecTimeOut >250){
@@ -651,14 +660,14 @@
       //LoopCounter = LoopCounter + 1;
       chkBtns = !chkBtns;
     }
-    else return false;
+    else return;
   }

   int buttonPressed = Keypad.button();
   if (buttonPressed==KEYPAD_NONE){
     NuInput = true;
-     return true;
+     return;
   }
   int buttons = 0;
   int NubtnVal = 0;
@@ -667,11 +676,11 @@
   if (buttonPressed==KEYPAD_LEFT) buttons += 4;
   if (buttonPressed==KEYPAD_RIGHT) buttons += 8;
   if (buttonPressed==KEYPAD_SELECT) buttons += 16;
-  bool Same = true;
+  //bool Same = true;
   int i = 0;
-  NubtnVal = buttons;
+  NubtnVal = buttons; //remember previous button reading
   // Switch debounce code to help ensure a true button reading
-  while(i<6 && NubtnVal == buttons){
+  while(i<6 ){
     buttonPressed = Keypad.button();
     buttons = 0;
     if (buttonPressed==KEYPAD_UP) buttons += 1;
@@ -680,14 +689,17 @@
     if (buttonPressed==KEYPAD_RIGHT) buttons += 8;
     if (buttonPressed==KEYPAD_SELECT) buttons += 16;
     if (NubtnVal == buttons) i++;
-    else {
+    else {// doesn't match; Rest & Start over
       NubtnVal = buttons;
       i= 0;
     }
   }
-  if (buttons > 0 ) chkBtns = false;;
+  if (buttons > 0 ){
+    chkBtns = false;// lock out new button scan for another delay interval (original wait period was250 ms)
+    QrtrSecTimeOut = millis(); // reset 1/4 second timer
+  }
   UpDateSettings(buttons, Mode);
-  return true;
+  return;
 }

 void UpDateSettings(int UsrInput, int mode)


Put arming modules into a dedicated function to not freeze the GUI when doing so.

--- ROVMain/ROVMain.ino
+++ ROVMain/ROVMain.ino
@@ -9,14 +9,15 @@
  * @author: Aleksander Lidtke
  * @email: alekasdner.lidtke@gmail.com
  * @url: www.aleksanderlidtke.com
- * @since: 24 Sep 2015
- * @version: 2.1.1
+ * @since: 26 Sep 2015
+ * @version: 2.1.2
  *
  * CHANGELOG
  *  5 Sep 2015 - 1.0.0 - Alek Lidtke - released the first version.
  *  6 Sep 2015 - 2.0.0 - Alek & Artur Lidtke - derived motor class from the Module class.
  * 24 Sep 2015 - 2.1.0 - Alek Lidtke - added command handling via dummy Modules.
  * 				 2.1.1 - Alek Lidtke - added ROV identifying strings.
+ * 26 Sep 2015 - 2.1.2 - Alek Lidtke - put arming modules into a dedicated function to not freeze the GUI when doing so.
  */

 // Custom includes.
@@ -30,7 +31,7 @@

 // ROV identifiers.
 const String ROV_MODEL = "zy3b";
-const String ROV_SW_VERSION = "2.1.1";
+const String ROV_SW_VERSION = "2.1.2";

 /* =============================================================================
  * FUNCTION DECLARATIONS.
@@ -39,6 +40,7 @@
 void parseInput(void);
 boolean getSerial(void);
 void sendSensorReadings(void);
+void armModules(void);

 /* =============================================================================
  * MOTOR DEFINITIONS.
@@ -64,6 +66,8 @@
  * MISC ACTUATOR AND COMMAND DEFINITIONS.
  * =============================================================================
  */
+Module armModulesModule = Module("armModules"); // Arms all the sensors and actuators.
+
 Module sendSensorReadingsModule = Module("sendSensorReadings"); // Sends sensor readings over serial.

 Module refreshRate = Module("refreshRate"); // Changes the delay in the main loop.
@@ -95,7 +99,7 @@
 const char END_CHAR = ';'; // End of the command message sent to and from the Arduino.
 const char DATA_DELIMITER[2] = ","; // Splits the command name and value. For some reason has to be size 2.

-Module* actuators[] = {&engine1, &engine2, &engine3, &engine4, &sendSensorReadingsModule, &refreshRate, &forwardLED};
+Module* actuators[] = {&armModulesModule, &engine1, &engine2, &engine3, &engine4, &sendSensorReadingsModule, &refreshRate, &forwardLED};
 Module* sensors[] = {&depthSensor, &depthSensor2};

 /* =============================================================================
@@ -105,6 +109,7 @@
 void setup(void)
 /* Prepare to listen to commands over serial and start everything up. */
 {
+	armModulesModule.setValue(0); // Don't arm the modules by default, wait for a command.
 	refreshRate.setValue(100); // Set default delay in milliseconds in the main loop/

 	//TODO: do some system checks, like battery level, connections etc.
@@ -112,23 +117,7 @@
 	// Start serial comms at the same baud rate as the engines.
 	Serial.begin(engine1.serialBaudRate);

-	// Arm all the modules.
-	int setupDelay(0);
-	for(int i=0;i<sizeof(actuators)/sizeof(actuators[0]);i++)
-	{
-		int delayRequested = actuators[i]->arm();
-		if (delayRequested > setupDelay) setupDelay = delayRequested;
-	}
-	for(int i=0;i<sizeof(sensors)/sizeof(sensors[0]);i++)
-	{
-		int delayRequested = sensors[i]->arm();
-		if (delayRequested > setupDelay) setupDelay = delayRequested;
-	}
-	delay(setupDelay); // Wait for as long as required by the slowest arming module.
-
-	//TODO: do whatever else operations we want to do at start-up.
-
-	Serial.println("ROV "+ROV_MODEL+" v. "+ROV_SW_VERSION+" listening to commands."); //TODO: could add VERSION, ROVMODEL etc. consts somewhere so we know what ROV we're using.
+	Serial.println("ROV "+ROV_MODEL+" v. "+ROV_SW_VERSION+" listening to commands.");
 }

 void loop(void)
@@ -145,6 +134,12 @@
 		}
 	}

+	// Arm the modules if requested.
+	if(armModulesModule.getValue()==1)
+	{
+		armModules(); // This function handles everything.
+	}
+
 	// Send readings from all the sensors over serial after this has been requested by a command.
 	if(sendSensorReadingsModule.getValue()==1)
 	{
@@ -272,3 +267,34 @@
 	Serial.println( outputDataBuffer ); // Send the formatted message.
 	outputDataBuffer = ""; // Restart the buffer so it's clean before sending the next message.
 }
+
+void armModules(void)
+/* Arm all the modules registered in actuators and sensors arrays by calling their
+ * arm methods and waiting for the requested duration. Wait for the longest
+ * duration necessary to arm any module and send a message over serial saying for
+ * how long Arduino  will be sleeping so that the GUI knows.
+ */
+{
+	int setupDelay(0); // By default wait for 0 seconds, i.e. arm nothing.
+	for(int i=0;i<sizeof(actuators)/sizeof(actuators[0]);i++) // Arm all actuators.
+	{
+		int delayRequested = actuators[i]->arm();
+		if (delayRequested > setupDelay) setupDelay = delayRequested;
+	}
+	for(int i=0;i<sizeof(sensors)/sizeof(sensors[0]);i++) // Arm all sensors.
+	{
+		int delayRequested = sensors[i]->arm();
+		if (delayRequested > setupDelay) setupDelay = delayRequested;
+	}
+
+	// Send the message saying how long the delay will last.
+	outputDataBuffer += OUTPUT_START_CHAR; // Start the message.
+	outputDataBuffer += "setupDelay";
+	outputDataBuffer += DATA_DELIMITER;
+	outputDataBuffer += String(setupDelay);
+	outputDataBuffer += END_CHAR; // Terminate the message.
+	Serial.println( outputDataBuffer ); // Send the formatted message.
+	outputDataBuffer = ""; // Restart the buffer so it's clean before sending the next message.
+
+	delay(setupDelay); // Wait for as long as required by the slowest arming module.
+}


Changed startup screen.

Changed startup screen.

--- Alicorn.ino
+++ Alicorn.ino
@@ -1354,7 +1354,8 @@
     lcd.init();
     lcd.setBacklight(true);

-    drawScreen(" == Alicorn ==", "  Loading...");
+    drawScreen(" == Alicorn ==", "  Starting...");
+
     setupSettings();
     setupStates();
     setupCounters();
@@ -1362,11 +1363,9 @@
     setupDevices();
     setupClock();
     resetAverage();
-
-    drawScreen(" == Alicorn ==", "  Connecting...");
     connectWiFi();

-    drawScreen(" == Alicorn ==", "  Ready!");
+    drawScreen("", "");

     setupTimer();
 }


Send data every ~4min

Send data every ~4min

--- Tx_Node/Tx_Node.ino
+++ Tx_Node/Tx_Node.ino
@@ -46,7 +46,7 @@
 #endif

 #define WATCHDOG_TIMER WDTO_8S // 8 sec
-#define SLEEP_LOOP  2 // Deep Sleep total time = WATCHDOG_TIMER * SLEEP_LOOP
+#define SLEEP_LOOP  30 // Deep Sleep total time = WATCHDOG_TIMER * SLEEP_LOOP

 #define sensID 42  // Sensor ID


Replace trumpet with string pizz

Replace trumpet with string pizz

--- Guzheng/Guzheng.ino
+++ Guzheng/Guzheng.ino
@@ -24,8 +24,8 @@
 #define NOTEON 0x90
 #define NOTEOFF 0x80
 #define CHANGEINSTRUMENT 0xC0
-#define TRUMPET 0x39
-#define PIANO 0x00
+#define STRING 0x2E
+#define PIANO 0x01

 // Values for different notes
 // Currently a C scale, starting from middle C (C4)
@@ -139,13 +139,6 @@
   Serial.begin(115200);
   // Wait 1 second for ttymidi to come up
   delay(1000);
-  // Set instrument to trumpet
-  // 0xC0 is the change instrument command
-  // 0x39 is the instrument ID in hex
-#ifdef WIND
-  Serial.write(CHANGEINSTRUMENT);
-  Serial.write(INSTRUMENT);
-#endif
 }

 void loop()
@@ -155,8 +148,8 @@
   for (int i = 0; i <= LASTPORT; i++) {
     if(digitalRead(BUTTONPORT) == HIGH) {
       if (buttonState == 0) {
-        Serial.write(CHANGEINTSTRUMENT);
-        Serial.write(TRUMPET);
+        Serial.write(CHANGEINSTRUMENT);
+        Serial.write(STRING);
         buttonState = 1;
       }
     } else {


Near final

Near final

--- examples/RpmCounterAudio/RpmCounterAudio.ino
+++ examples/RpmCounterAudio/RpmCounterAudio.ino
@@ -27,10 +27,20 @@
 #define SDCARD_MOSI_PIN  7
 #define SDCARD_SCK_PIN   14

+// LEDS
 const byte ledPin1 = 13;
 const byte ledPin2 = 14;
-const byte sensorPin1 = 2;
-const byte sensorPin2 = 3;
+// Sensors
+const byte sensorPin1 = 5;
+const byte sensorPin2 = 6;
+// Sync
+const byte syncPin = 3;
+const byte playPin =  4;
+bool play = 0;
+
+const char *tounes[] = {"toune1.wav", "toune2.wav", "toune3.wav", "toune4.wav"};
+int nbTounes = sizeof(tounes)/sizeof(tounes[0]);
+int currentSong = 0;

 void setup()
 {
@@ -43,9 +53,16 @@
 	rpmCounter1.begin(sensorPin1, 4, 400, 4, 10);
 	rpmCounter2.begin(sensorPin2, 4, 400, 4, 10);

-  // LED
-  pinMode(ledPin, OUTPUT);
-  digitalWrite(ledPin, HIGH);
+	// LED
+	pinMode(ledPin1, OUTPUT);
+	pinMode(ledPin2, OUTPUT);
+	digitalWrite(ledPin1, HIGH);
+	digitalWrite(ledPin2, HIGH);
+
+	// Sync and play
+	pinMode(syncPin, OUTPUT);
+	pinMode(playPin, INPUT);
+	attachInterrupt(playPin, playTrigger, RISING);

 	AudioMemory(8);

@@ -55,44 +72,65 @@
 	SPI.setMOSI(SDCARD_MOSI_PIN);
 	SPI.setSCK(SDCARD_SCK_PIN);
 	if (!(SD.begin(SDCARD_CS_PIN))) {
-	  // stop here, but print a message repetitively
-	  while (1) {
-	    Serial.println("Unable to access the SD card");
-	    delay(500);
-	  }
+		// stop here, but print a message repetitively
+		while (1) {
+			Serial.println("Unable to access the SD card");
+			delay(500);
+		}
 	}
 	dc1.amplitude(1.);
 	dc2.amplitude(1.);
+
+	// Start playback
+	digitalWrite(syncPin, HIGH);
 }

 void loop()
 {
-	playFile("stereo.wav");
+	if (play)
+		playFile(tounes[currentSong]);
 }

 void playFile(const char *filename)
 {
-  Serial.print("Playing file: ");
-  Serial.println(filename);
+	digitalWrite(syncPin, LOW);
+	play = 0;
+
+	Serial.print("Playing file: ");
+	Serial.println(filename);

-  // Start playing the file.  This sketch continues to
-  // run while the file plays.
-  playWav1.play(filename);
+	// Start playing the file.  This sketch continues to
+	// run while the file plays.
+	playWav1.play(filename);

-  // A brief delay for the library read WAV info
-  delay(5);
+	// A brief delay for the library read WAV info
+	delay(5);

-  // Simply wait for the file to finish playing.
-  while (playWav1.isPlaying()) {
-  	rpmCounter1.update();
-	  rpmCounter2.update();
-    updateLed();
-    // uncomment these lines if you audio shield
-    // has the optional volume pot soldered
-    float vol = analogRead(15);
-    vol = vol / 1024;
-    sgtl5000_1.volume(vol);
-  }
+	// Simply wait for the file to finish playing.
+	while (playWav1.isPlaying()) {
+		rpmCounter1.update();
+		rpmCounter2.update();
+		updateLed1();
+		updateLed2();
+		// uncomment these lines if you audio shield
+		// has the optional volume pot soldered
+		float vol = analogRead(15);
+		vol = vol / 1024;
+		sgtl5000_1.volume(vol);
+	}
+
+	// Increment next song
+	currentSong++;
+	if (currentSong >= nbTounes)
+		currentSong = 0;
+
+	// Set play flag to true for next song
+	digitalWrite(syncPin, HIGH);
+}
+
+void playTrigger()
+{
+	play = 1;
 }

 void onRpm1(float val)
@@ -110,7 +148,7 @@
 	Serial.print("Sensor 2: ");
 	//Serial.println(val);
 	float vol = map(val, 0, 300, 0, 100) / 100.;
-	//Serial.println(val);
+	Serial.println(val);
 	dc2.amplitude(vol);
 }

@@ -126,25 +164,17 @@

 void updateLed1()
 {
-  if (digitalRead(sensorPin1) == HIGH)
-  {
-    digitalWrite(ledPin1, HIGH);
-  }
-  else
-  {
-    digitalWrite(ledPin1, LOW);
-  }
+	if (digitalRead(sensorPin1) == HIGH)
+		digitalWrite(ledPin1, HIGH);
+	else
+		digitalWrite(ledPin1, LOW);
 }

 void updateLed2()
 {
-  if (digitalRead(sensorPin2) == HIGH)
-  {
-    digitalWrite(ledPin2, HIGH);
-  }
-  else
-  {
-    digitalWrite(ledPin2, LOW);
-  }
+	if (digitalRead(sensorPin2) == HIGH)
+		digitalWrite(ledPin2, HIGH);
+	else
+		digitalWrite(ledPin2, LOW);
 }


Update Relay.ino

Update Relay.ino

--- Examples/Relay/Relay.ino
+++ Examples/Relay/Relay.ino
@@ -32,7 +32,7 @@
   int state = client.ReadSPIFFS("12"); // get previously stored state of pin-12 in flash memory
   digitalWrite(12, state); // drives pin-12 to previous state

-  client.OverRide(); // search in Flash memory if pin state was over-riden manually
+  client.OverRide(12); // search in Flash memory if pin state was over-riden manually
   //If over-ride = 0, It means pin was pulled LOW against the program schedule
   //If over-ride = 1, It means pin was pushed HIGH against the program schedule
   //If over-ride = 3, There is no over-ride associated with pin


Add Include SoftwareSerial ready for BLE device

--- Caravan_Thermostat_TX/Caravan_Thermostat_TX.ino
+++ Caravan_Thermostat_TX/Caravan_Thermostat_TX.ino
@@ -13,6 +13,7 @@
 #include <TimeLib.h>
 #include <DS1307RTC.h> // RTC Library
 #include <IRremote.h> // IR Library
+#include <SoftwareSerial.h>

 // Define the pins.

@@ -32,6 +33,7 @@
 dht DHT;
 IRrecv irrecv(IRPIN);
 decode_results results;
+SoftwareSerial BT(7, 8); // RX, TX

 // Define Global Variables


the server randomly selects which player has the first move

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -3,7 +3,8 @@

 #include <Wire.h>
 #include <GraphicDisplay.h>
-#include <SM125.h>
+#include <SM125.h> //RFID
+#include <SoundPlayer.h>

 #define DISPLAY_ADDRESS  0x51
 #define BUTTONS_CHANGE   43
@@ -13,6 +14,8 @@
 GraphicDisplay display;
 // Baseboard RFID reader
 SM125 sm125;
+// Baseboard sound player
+SoundPlayer soundPlayer;

 // Configuration for the shift registers
 int numShifts = 3;
@@ -23,8 +26,14 @@
 Shiftduino _sd(datapin, clockpin, latchpin, numShifts);

 // Unique board ID (TODO: right now is set manually for testing purposes)
-int player_id = 1;
-int rival_id = 0;
+String player_id = "1000";
+// Rival board id
+String rival_id = "0";
+// Who starts playing: 0 the player, 1 the rival.
+char start_turn = '2';
+
+// Current turn
+int turn = 0;

 // Each of the squares of the tictactoe
 Square * squares[9];
@@ -55,7 +64,7 @@
 void setup() {
   Serial.begin(9600);
   Serial.println("Setup...");
-  // Initialize the tictactoe board
+  // 1 - Initialize the tictactoe board
   for (int i = 0; i < 9; i++){
     squares[i] = new Square(8 - i, i + 1, &_sd);
   }
@@ -64,87 +73,90 @@
   allGreen();
   delay(1000);
   clearSquares();
-  // Initialize the baseboard peripherals
+  // 2 - Initialize the baseboard peripherals
   initializeHardwarePeripherals();
-  // Show the welcome message
+  // 3 - Show the welcome message
   doWelcome();
-  // Find other player
-  rival_id = findPlayer();
+  // 4 - Find other player
+  String result = findPlayer();
+  start_turn = result[4];
+  rival_id = result.substring(0,4);
 }

 void loop() {
   delay(200);
-
-  // ************************************************************************
-  // ******** Player turn ***************************************************
-  // ************************************************************************
-  for (int i = 0; i < 9; i++){
-    previousGreenStatus[i] = greenStatus[i];
-  }
-  // 1 -Update color status
-  //   -Check player move, wait until it happens
-  printMsg("Your turn.");
-  boolean waitForMove = true;
-  int player_move = 0;
-
-  while (waitForMove){
-    updateBoardStatus();
-    player_move = checkPlayerMove();
-    if (player_move == -1){
-      // No move, wait and check again
-      delay(30);
-    }else if (player_move > -1){
-      // Legal move, continue
-      waitForMove = false;
-    } else if (player_move == -2){
-      // Player has moved 2 pieces, illegal move
-      msgAndWait("You moved two pieces! Correct you move.");
-    } else if (player_move == -3){
-      // Player has moved the piece into an square already used.
-      msgAndWait("You moved your piece into an already used square! Correct you move.");
-    }
-  }
-
-  // 2- Send move to server
-  sendMove(player_move);
-
-  // 3 -Check victory conditions
-  greenVictory = checkWin(greenStatus);
-  if (greenVictory){
-    printMsg("A winner is you"); //TODO think some proper msgs
-    victoryLoop('g');
-  }
-
-
-
-  // ************************************************************************
-  // ******* Rival turn *****************************************************
-  // ************************************************************************
-  printMsg("Wait for your rival's move.");
-
-  // 1- Check rival move, wait until it happens
-  waitForMove = true;
-  int rival_move = -1;
-  while(waitForMove){
-    rival_move = getMove();
-    // Wait and check again
-    if (rival_move < 0){
-      delay(100);
-    } else{
-      waitForMove = false;
-    }
-  }
-  // 2- Update color status
-  if (rival_move > -1 && rival_move  < 9){
-    redStatus[rival_move] = 1;
-    squares[rival_move]->setRed();
-  }
-
-  // 3 -Check victory conditions
-  redVictory = checkWin(redStatus);
-  if (redVictory){
-    printMsg("You lose!");
-    victoryLoop('r');
+  if ((turn > 0) || (turn == 0 && start_turn=='0')){
+    // ************************************************************************
+    // ******** Player turn ***************************************************
+    // ************************************************************************
+    for (int i = 0; i < 9; i++){
+      previousGreenStatus[i] = greenStatus[i];
+    }
+    // 1 -Update color status
+    //   -Check player move, wait until it happens
+    printMsg("Your turn.");
+    boolean waitForMove = true;
+    int player_move = 0;
+
+    while (waitForMove){
+      updateBoardStatus();
+      player_move = checkPlayerMove();
+      if (player_move == -1){
+        // No move, wait and check again
+        delay(30);
+      }else if (player_move > -1){
+        // Legal move, continue
+        waitForMove = false;
+      } else if (player_move == -2){
+        // Player has moved 2 pieces, illegal move
+        msgAndWait("You moved two pieces! Correct you move.");
+      } else if (player_move == -3){
+        // Player has moved the piece into an square already used.
+        msgAndWait("You moved your piece into an already used square! Correct you move.");
+      }
+    }
+
+    // 2- Send move to server
+    sendMove(player_move);
+
+    // 3 -Check victory conditions
+    greenVictory = checkWin(greenStatus);
+    if (greenVictory){
+      printMsg("A winner is you"); //TODO think some proper msgs
+      victoryLoop('g');
+    }
+  }
+
+  if ((turn > 0) || (turn == 0 && start_turn=='1')){
+    // ************************************************************************
+    // ******* Rival turn *****************************************************
+    // ************************************************************************
+    printMsg("Wait for your rival's move.");
+
+    // 1- Check rival move, wait until it happens
+    waitForMove = true;
+    int rival_move = -1;
+    while(waitForMove){
+      rival_move = getMove();
+      // Wait and check again
+      if (rival_move < 0){
+        delay(100);
+      } else{
+        waitForMove = false;
+      }
+    }
+    // 2- Update color status
+    if (rival_move > -1 && rival_move  < 9){
+      redStatus[rival_move] = 1;
+      squares[rival_move]->setRed();
+    }
+
+    // 3 -Check victory conditions
+    redVictory = checkWin(redStatus);
+    if (redVictory){
+      printMsg("You lose!");
+      victoryLoop('r');
+    }
   }
 }

@@ -154,11 +166,23 @@

 void initializeHardwarePeripherals(){
   initializeRFID();
+  initializeSoundPlayer();
   initializeScreen();
 }

 void initializeRFID(){
   sm125.begin(SM125_ADDRESS);
+}
+
+void initializeSoundPlayer(){
+  soundPlayer.begin(0x61);
+  int ver = soundPlayer.getVersion();
+  switch(ver)
+  {
+  case 0x10:
+    Serial.println("Version: 1.0)");
+    break;
+  }
 }

 void initializeScreen(){
@@ -230,23 +254,28 @@
  *   COMMUNICATION WITH THE GAME SERVER
  **********************************************/

-int findPlayer(){
+String findPlayer(){
   //TODO
   // rival_id = send ("REGISTER " + player_id + "\0n")
-  // returns the rival_id
-  return 113;
+  // returns the rival_id and who starts playing
+  // REGISTER ####
+  // ##### -> first 4 numbers is the rival id and the 5th is who plays first. 0 the player and 1 the rival
+  return "10020";

 }

 int getMove(){
   //TODO
   // move = send ("GET_MOVE " + rival_id)
+  // GET_MOVE ####
+  // # -> a number between 0 and 8
   return 0;
 }

 void sendMove(int player_move){
   //TODO
   // send ("MOVE " + player_move + player_id)
+  // MOVE # ####
   Serial.println("sending move");
 }


Added method for restarting the game

Added method for restarting the game

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -57,8 +57,7 @@
     clearSquares();
     allGreen();
   }
-
-  //Serial.println();
+
 }

@@ -141,6 +140,22 @@
   }
 }

+void restartGame(){
+  allClear();
+  allGreen();
+  delay(200);
+  allRed();
+  delay(200);
+  allGreen();
+  delay(600);
+  allClear();
+
+  redStatus [] = {0,0,0,0,0,0,0,0,0};
+  greenStatus [] = {0,0,0,0,0,0,0,0,0};
+  redVictory = false;
+  greenVictory = false;
+}
+
 void printStatus(){
   Serial.println("Red");
   for (int i=0; i < 9; i++){


Upload % 1 off

Upload % 1 off

--- ESPrinkler2.ino
+++ ESPrinkler2.ino
@@ -214,6 +214,7 @@
   if (update.status == UPLOAD_FILE_START) {
     String filename = update.filename;
     fullSize = atoi(server.header("Content-Length").c_str());
+    priorPct = 0;
     DBG_OUTPUT_PORT.printf("handleFileUpdate Name: %s %d\n",
       filename.c_str(), fullSize);
     displayStatus(1, "HTTP Update start");


Fully implemented the reading of registers and printing them to serial, and the reverse byte order correction, and a user interface of sorts

--- MSDOS/MSDOS.ino
+++ MSDOS/MSDOS.ino
@@ -3,6 +3,7 @@

 #include <FlexCAN.h>
 #include <TimerOne.h>
+#include "MCRegIDs.h"

 const char *menuMain =
   "\nWelcome to EVOS!\n"
@@ -12,20 +13,48 @@
   "2: Blink an LED\n";

 const char *menuCAN =
-  "\nSelect an option to continue\n"
+  "\nSelect a CAN option\n"
   "0: Back to main menu\n"
-  "1: Read a value from MC\n"
-  "2: Set a value in the MC\n";
+  "1: Set a value in the MC *WIP*\n"
+  "2: Read a value from MC\n"
+  "3: Configure MC register for polling\n";
+
+const char *readMCRegMenu =
+  "\nSelect a register to read from\n"
+  "0: Back to CAN menu\n"
+  "1: ERROR/warnings\n"
+  "2: Various internal states\n"
+  "3: Digital PORT\n"
+  "4: RUN status\n"
+  "5: BTB relay status\n"
+  "6: Internal GO status\n"
+  "7: High Voltage line value\n"
+  "8: Current speed limit\n"
+  "9: Current speed amount\n"
+  "A: Tempurature of the motor\n"
+  "B: Tempurature inside the MC\n";
+
+const char *setMCRegMenu =
+  "\nSelect a register to set\n"
+  "0: Back to CAN menu\n"
+  "1: REG_SPEEDVAL\n"
+  "2: REG_SPEEDLIM\n"
+  "3: Comparison value 1\n"
+  "4: Comparison value 2\n"
+  "5: Comparison value 3\n"
+  "6: Comparison value 4\n"
+  "7: Tempurature limit for the motor\n";

 char rx_byte;
 bool ledState = HIGH;
 bool blinking = false;

+
 //CAN stuffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

 static CAN_message_t msgON;

-static uint8_t hex[17] = "0123456789abcdef";
+//static uint8_t hex[17] = "0123456789abcdef";

 class CANClass : public CANListener
 {
@@ -35,20 +64,27 @@
    void gotFrame(CAN_message_t &frame, int mailbox);

    void testFunc(void);
+   CAN_message_t setupMCMessage(uint8_t regID, uint8_t buf1, uint8_t buf2 = 0x00, bool polling = false);
+
 };

 void CANClass::printFrame(CAN_message_t &frame, int mailbox)
 {
+   Serial.print("This just in!\n");
    Serial.print("ID: ");
    Serial.print(frame.id, HEX);
+
+   //Print regID from buf[0]
+   Serial.print(" RegID: ");
+   Serial.print(frame.buf[0], HEX);
+
+   //Print value from register in reverse byte order
    Serial.print(" Data: ");
-   for (int c = 0; c < frame.len; c++)
-   {
-      Serial.print(frame.buf[c], HEX);
-      Serial.write(' ');
-   }
-   Serial.write('\r');
+   Serial.print(frame.buf[2], HEX);
+   Serial.print(" ");
+   Serial.print(frame.buf[1], HEX);
+
    Serial.write('\n');
 }

@@ -65,20 +101,326 @@
 }

-CANClass CANMessage;
-
-//End CAN stufffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-
-
-//TODO: put CAN option stuff here (call from) case 1
-void case1()
-{
-  bool caseCAN = true;
-
-  //discard anything more than one char long
+//helper function cause I use this too much
+void clearSerialBuf()
+{
+  //discard anything within the buffer
   while (Serial.available() > 0)
     Serial.read();
-
+}
+
+
+CAN_message_t setupMCMessage(uint8_t regID, uint8_t buf1 = 0x00, uint8_t buf2 = 0x00, bool stopPolling = false)
+{
+  CAN_message_t tx;
+
+  tx.ext = 0;
+  tx.id = 0x201;
+  tx.len = 3;
+
+  if(regID == REG_READ)
+  {
+    //performing a read operation set buf[0] to READ command
+    tx.buf[0] = REG_READ;
+    tx.buf[1] = buf1;
+
+    //default is 0 but can represent time (in ms) for polling
+    tx.buf[2] = buf2;
+
+    //deactivates polling
+    if(stopPolling)
+    {
+      tx.buf[2] = REG_HALTPOLL;
+    }
+  }
+  else
+  {
+    //performing write opration
+    tx.buf[0] = regID;
+
+    //storing the value in byte flipped order
+    tx.buf[2] = buf1;
+    tx.buf[1] = buf2;
+  }
+
+  return tx;
+}
+
+
+CANClass CANMessage;
+
+//End CAN stufffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+
+
+//confirmation message from user
+bool confirmPopUp(CAN_message_t message)
+{
+  bool feedback = false;
+  bool waitingOnUser = true;
+
+  clearSerialBuf();
+
+  Serial.print(F("\nAre you sure you want to send: \n"));
+  Serial.print("ID: ");
+  Serial.print(message.id, HEX);
+
+  //Print regID from buf[0]
+  Serial.print(" RegID: ");
+  Serial.print(message.buf[0], HEX);
+
+  //Print value from register in reverse byte order
+  Serial.print(" Data: ");
+  Serial.print(message.buf[2], HEX);
+  Serial.print(" ");
+  Serial.print(message.buf[1], HEX);
+
+  Serial.print(F("\ny/n?\n"));
+
+
+  while(waitingOnUser)
+  {
+    if (Serial.available() > 0)
+    {
+      rx_byte = Serial.read();
+
+      //discard anything more than one char long
+      clearSerialBuf();
+
+      switch(rx_byte)
+      {
+        case '0':
+        case 'N':
+        case 'n':
+          feedback = false;
+          //No long waiting on user
+          waitingOnUser = false;
+        break;
+
+        case '1':
+        case 'Y':
+        case 'y':
+          feedback = true;
+          //No long waiting on user
+          waitingOnUser = false;
+        break;
+
+        default:
+          Serial.print(F("Invalid syntax\n"));
+          Serial.print(F("\ny/n?\n"));
+        break;
+      }
+    }
+  }
+
+  return feedback;
+}
+
+
+//TODO: WORK ON THIS///////////////////////////////////
+void setMCReg()
+{
+  bool caseSetMCReg = true;
+  uint8_t regID;
+  uint16_t value = 0x0000;
+
+
+  //discard anything more than one char long from prev call
+  clearSerialBuf();
+
+  Serial.print(F(setMCRegMenu));
+  Serial.print("\n");
+  while(caseSetMCReg)
+  {
+    if (Serial.available() > 0)
+    {
+      rx_byte = Serial.read();
+
+      //discard anything more than one char long
+      clearSerialBuf();
+
+      switch(rx_byte)
+      {
+        case '0':
+          Serial.print(F("CAN Menu\n"));
+          caseSetMCReg = false;
+        break;
+
+        case '1':
+          Serial.print(F("REG_SPEEDVAL\n"));
+          regID = REG_SPEEDVAL;
+        break;
+
+        case '2':
+          Serial.print(F("REG_SPEEDLIM\n"));
+          regID = REG_SPEEDLIM;
+        break;
+
+        case '3':
+          Serial.print(F("REG_VAR1\n"));
+          regID = REG_VAR1;
+        break;
+
+        case '4':
+          Serial.print(F("REG_VAR2\n"));
+          regID = REG_VAR2;
+        break;
+
+        case '5':
+          Serial.print(F("REG_VAR3\n"));
+          regID = REG_VAR3;
+        break;
+
+        case '6':
+          Serial.print(F("REG_VAR4\n"));
+          regID = REG_VAR4;
+        break;
+
+        case '7':
+          Serial.print(F("REG_MTEMPLIM\n"));
+          regID = REG_MTEMPLIM;
+        break;
+
+        default:
+          Serial.print(F("Invalid syntax\n"));
+          Serial.print(F(setMCRegMenu));
+        break;
+      }
+
+      if(caseSetMCReg)
+      {
+        CAN_message_t txMessage = setupMCMessage(regID, (value && 0xFF00), (value && 0x00FF));
+
+        //send message if the user confirms they want to send it
+        if(confirmPopUp(txMessage))
+          Serial.print(F("\nNothing sent :) (WIP)\n"));
+          //Can0.write(txMessage);
+
+        Serial.print(F(setMCRegMenu));
+      }
+
+      Serial.print("\n");
+    }
+  }
+}
+
+
+//user interaction for reading registers over CAN
+void readMCReg()
+{
+  bool caseReadMCReg = true;
+
+  //register that the user chooses to read
+  uint8_t regID;
+
+  //discard anything more than one char long from prev call
+  clearSerialBuf();
+
+  Serial.print(F(readMCRegMenu));
+  Serial.print("\n");
+  while(caseReadMCReg)
+  {
+    if (Serial.available() > 0)
+    {
+      rx_byte = Serial.read();
+
+      //discard anything more than one char long
+      clearSerialBuf();
+
+
+      switch(rx_byte)
+      {
+        case '0':
+          Serial.print(F("CAN Menu\n"));
+          caseReadMCReg = false;
+        break;
+
+        case '1':
+          Serial.print(F("REG_ERROR\n"));
+          regID = REG_ERROR;
+        break;
+
+        case '2':
+          Serial.print(F("REG_STATE\n"));
+          regID = REG_STATE;
+        break;
+
+        case '3':
+          Serial.print(F("REG_DPORT\n"));
+          regID = REG_DPORT;
+        break;
+
+        case '4':
+          Serial.print(F("REG_RUN\n"));
+          regID = REG_RUN;
+        break;
+
+        case '5':
+          Serial.print(F("REG_BTB\n"));
+          regID = REG_BTB;
+        break;
+
+        case '6':
+          Serial.print(F("REG_GO\n"));
+          regID = REG_GO;
+        break;
+
+        case '7':
+          Serial.print(F("REG_HVBUS\n"));
+          regID = REG_HVBUS;
+        break;
+
+        case '8':
+          Serial.print(F("REG_SPEEDLIM\n"));
+          regID = REG_SPEEDLIM;
+        break;
+
+        case '9':
+          Serial.print(F("REG_SPEEDRN\n"));
+          regID = REG_SPEEDRN;
+        break;
+
+        case 'A':
+          Serial.print(F("REG_TEMPM\n"));
+          regID = REG_TEMPM;
+        break;
+
+        case 'B':
+          Serial.print(F("REG_TEMPAIRMC\n"));
+          regID = REG_TEMPAIRMC;
+        break;
+
+        default:
+          Serial.print(F("Invalid syntax\n"));
+          Serial.print(F(readMCRegMenu));
+        break;
+      }
+
+      if(caseReadMCReg)
+      {
+        CAN_message_t txMessage = setupMCMessage(REG_READ, regID);
+
+        //send message if the user confirms they want to send it
+        if(confirmPopUp(txMessage))
+          Can0.write(txMessage);
+
+        Serial.print(F(readMCRegMenu));
+      }
+
+      Serial.print("\n");
+    }
+  }
+}
+
+
+//CAN option stuff here called from case 1
+void case1()
+{
+  bool caseCAN = true;
+
+  //discard anything more than one char long
+  clearSerialBuf();
+
+  //printing the options of CAN to the user
   Serial.print(F(menuCAN));
   Serial.print("\n");
   while(caseCAN)
@@ -90,9 +432,6 @@
       //discard anything more than one char long
       while (Serial.available() > 0)
         Serial.read();
-
-      Serial.print("You typed: ");
-      Serial.println(rx_byte);

       switch(rx_byte)
       {
@@ -102,13 +441,21 @@
         break;

         case '1':
-          Serial.print(F("Case 1\n"));
-
+          Serial.print(F("Case 1: set a val\n"));
+          setMCReg();
+          Serial.print(F(menuCAN));
         break;

         case '2':
-          Serial.print(F("Case 2\n"));
-
+          Serial.print(F("Case 2: read a val\n"));
+          readMCReg();
+          Serial.print(F(menuCAN));
+        break;
+
+        case '3':
+          Serial.print(F("Case 3: config polling from MC\n"));
+          //configMCPolling();
+          Serial.print(F(menuCAN));
         break;

         default:
@@ -198,8 +545,7 @@
     rx_byte = Serial.read();

     //discard anything more than one char long
-    while (Serial.available() > 0)
-      Serial.read();
+    clearSerialBuf();

     Serial.print("You typed: ");
     Serial.println(rx_byte);


get ready fam

get ready fam

--- MSDOS/MSDOS.ino
+++ MSDOS/MSDOS.ino
@@ -61,7 +61,7 @@

 void CANClass::testFunc()
 {
-  Serial.println(F("YCP EV YAY! :("));
+  Serial.println(F("YCP EV is making me go crazy! "));
 }


Added MI, MD for now

Added MI, MD for now

--- Arduino/BLuB/BLuB.ino
+++ Arduino/BLuB/BLuB.ino
@@ -429,12 +429,44 @@
 	if( OpcodeIs( 'S', 'E' )) return kJRNextLine;

 	// math + - / * ++ --
-	if( OpcodeIs( 'M', '+' )) return kJRNextLine;
-	if( OpcodeIs( 'M', '-' )) return kJRNextLine;
-	if( OpcodeIs( 'M', '/' )) return kJRNextLine;
-	if( OpcodeIs( 'M', '*' )) return kJRNextLine;
-	if( OpcodeIs( 'M', 'I' )) return kJRNextLine;
-	if( OpcodeIs( 'M', 'D' )) return kJRNextLine;
+	if( OpcodeIs( 'M', '+' )) {
+		return kJRNextLine;
+	}
+	if( OpcodeIs( 'M', '-' )) {
+		return kJRNextLine;
+	}
+	if( OpcodeIs( 'M', '/' )) {
+		return kJRNextLine;
+	}
+	if( OpcodeIs( 'M', '*' )) {
+		return kJRNextLine;
+	}
+	if( OpcodeIs( 'M', 'I' )) {
+		line += 2;	// advance past opcode
+		// param 1
+		SKIP_WHITESPACE( line );
+		if( !isVarName( *line )) {
+			return kJRSyntaxError;
+		}
+		varname = *line;
+		line += 1; // skip past the varname
+
+		variables[VarCharToIndex( varname )]++;
+		return kJRNextLine;
+	}
+	if( OpcodeIs( 'M', 'D' )) {
+		line += 2;	// advance past opcode
+		// param 1
+		SKIP_WHITESPACE( line );
+		if( !isVarName( *line )) {
+			return kJRSyntaxError;
+		}
+		varname = *line;
+		line += 1; // skip past the varname
+
+		variables[VarCharToIndex( varname )]--;
+		return kJRNextLine;
+	}

 	// bitwise << >> & | !
 	if( OpcodeIs( 'M', '<' )) return kJRNextLine;


updated links and a few typos

updated links and a few typos

--- Grove_Dust_Sensor.ino
+++ Grove_Dust_Sensor.ino
@@ -4,8 +4,8 @@
  Program by Christopher Nafis
  Written April 2012

- http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html
- http://www.sca-shinyei.com/pdf/PPD42NS.pdf
+ https://www.seeedstudio.com/Grove-Dust-Sensor-PPD42N-p-1050.html
+  https://www.shinyei.co.jp/stc/eng/optical/main_ppd42.html

  JST Pin 1 (Black Wire)  => Arduino GND
  JST Pin 3 (Red wire)    => Arduino 5VDC
@@ -15,7 +15,7 @@
 int pin = 8;
 unsigned long duration;
 unsigned long starttime;
-unsigned long sampletime_ms = 30000;//sampe 30s ;
+unsigned long sampletime_ms = 30000;//sample 30s ;
 unsigned long lowpulseoccupancy = 0;
 float ratio = 0;
 float concentration = 0;
@@ -32,7 +32,7 @@
     duration = pulseIn(pin, LOW);
     lowpulseoccupancy = lowpulseoccupancy+duration;

-    if ((millis()-starttime) > sampletime_ms)//if the sampel time == 30s
+    if ((millis()-starttime) > sampletime_ms)//if the sample time == 30s
     {
         ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100
         concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve


changed fastexecuterequest to reflect Websockets better.

--- FH_Tbot.ino
+++ FH_Tbot.ino
@@ -197,7 +197,7 @@
  * A faster version of exeReq for websockets.
  * Features WS response and a shorter command list.
  */
-void fastExecuteRequest(String req) {
+void WSRequest(String req) {
   // Empty request tripwire
   if (!req.length()) {
     // empty request
@@ -426,7 +426,7 @@
     // webSocket.sendTXT(num, "Pong");
     // Heartbeat
     HeartBeatRcvd = true;
-    fastExecuteRequest(b);
+    WSRequest(b);
     // Feedback
   } break;
   }


Update gCommand

Update gCommand

--- examples/BasicExample/BasicExample.ino
+++ examples/BasicExample/BasicExample.ino
@@ -63,7 +63,7 @@
 		Serial.printf("In Setup\n");

 		// Register a serial port command.
-		gCmd->RegisterCommand("hello", this, static_cast<TCmdHandlerMethod>(&CExampleModule::SerialCmdHello));
+		gCommand->RegisterCommand("hello", this, static_cast<TCmdHandlerMethod>(&CExampleModule::SerialCmdHello));

 		// Register a digital io event handler on pin 1
 		gDigitalIO->RegisterEventHandler(1, false, this, static_cast<TDigitalIOEventMethod>(&CExampleModule::PinActivated), NULL);
@@ -121,7 +121,7 @@
 setup(
 	void)
 {
-	CModule::SetupAll("v0.2", true);	// Passing in true blinks the led when the blink_led config var is set to one
+	CModule::SetupAll("v0.3", true);	// Passing in true blinks the led when the blink_led config var is set to one
 }

 void


Improve MQTT topic usage for feedback messages. (#663)

- Move log messages to their own MQTT topic. (ir_server/log)
- Set up a Last Will & Testament topic (ir_server/status)
- Change MQTT QoS to 1, which should hopefully handle messages lost during disconnects.

Tested log and LWT functionality on my personal device. Everything seems to work as normal.

Fixes #662
Ref #661

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -113,8 +113,7 @@
  * This server will send (back) what ever IR message it just transmitted to
  * the MQTT topic 'ir_server/sent' to confirm it has been performed. This works
  * for messages requested via MQTT or via HTTP.
- * Note: Other status messages are also sent to 'ir_server/sent' from time to
- * time.
+ *
  *   Unix command line usage example:
  *     # Listen to MQTT acknowledgements.
  *     $ mosquitto_sub -h 10.0.0.4 -t ir_server/sent
@@ -131,6 +130,9 @@
  *   Unix command line usage example:
  *     # Listen via MQTT for IR messages captured by this server.
  *     $ mosquitto_sub -h 10.0.0.4 -t ir_server/received
+ *
+ * Note: General logging messages are also sent to 'ir_server/log' from
+ *       time to time.
  *
  * If DEBUG is turned on, there is additional information printed on the Serial
  * Port.
@@ -237,9 +239,11 @@

 #define MQTTprefix HOSTNAME  // Change this if you want the MQTT topic to be
                              // independent of the hostname.
-#define MQTTack MQTTprefix "/sent"  // Topic we send back acknowledgements on
-#define MQTTcommand MQTTprefix "/send"  // Topic we get new commands from.
+#define MQTTack MQTTprefix "/sent"  // Topic we send back acknowledgements on.
+#define MQTTcommand MQTTprefix "/send"   // Topic we get new commands from.
 #define MQTTrecv MQTTprefix "/received"  // Topic we send received IRs to.
+#define MQTTlog MQTTprefix "/log"        // Topic we send log messages to.
+#define MQTTstatus MQTTprefix "/status"  // Topic for the Last Will & Testament.
 #endif  // MQTT_ENABLE

 const char* kHtmlUsername = "admin";    // <=- CHANGE_ME (optional)
@@ -275,7 +279,7 @@
 // NOTE: Make sure you set your Serial Monitor to the same speed.
 #define BAUD_RATE 115200  // Serial port Baud rate.

-// ADVANCED USAGE ONLY
+// ------------------------ Advanced Usage Only --------------------------------

 // Change if you need multiple independent send gpio/topics.
 const uint8_t gpioTable[] = {
@@ -287,15 +291,22 @@
   // 16,  // GPIO 16 / D0 e.g. ir_server/send_3
 };

+#define QOS 1  // MQTT broker should queue up any unreceived messages for us
+// #define QOS 0  // MQTT broker WON'T queue up messages for us. Fire & Forget.
+
 // ----------------- End of User Configuration Section -------------------------

 // Globals
-#define _MY_VERSION_ "v0.9.0"
+#define _MY_VERSION_ "v0.9.1"
 // HTML arguments we will parse for IR code information.
 #define argType "type"
 #define argData "code"
 #define argBits "bits"
 #define argRepeat "repeats"
+
+// Text for Last Will & Testament status messages.
+#define LWT_ONLINE  "Online"
+#define LWT_OFFLINE "Offline"

 ESP8266WebServer server(kHttpPort);
 #ifdef IR_RX
@@ -459,6 +470,9 @@
 #ifdef IR_RX
     "IR Received topic: " MQTTrecv "
"
 #endif  // IR_RX
+    "Log topic: " MQTTlog "
"
+    "LWT topic: " MQTTstatus "
"
+    "QoS: " + String(QOS) + "
"
     "Last MQTT command seen: " + lastMqttCmdTopic + " : " +
     // lastMqttCmd is unescaped untrusted input.
     // Avoid any possible HTML/XSS when displaying it.
@@ -1283,8 +1297,8 @@
 #if MQTT_ENABLE
 // MQTT subscribing to topic
 void subscribing(const String topic_name) {
-  // subscription to topic for receiving data
-  if (mqtt_client.subscribe(topic_name.c_str()))
+  // subscription to topic for receiving data with QoS.
+  if (mqtt_client.subscribe(topic_name.c_str(), QOS))
     debug("Subscription OK to " + topic_name);
   else
     debug("Subscription FAILED to " + topic_name);
@@ -1300,13 +1314,19 @@
           "... ");
     if (kMqttUsername && kMqttPassword)
       connected = mqtt_client.connect(mqtt_clientid.c_str(), kMqttUsername,
-                                      kMqttPassword);
+                                      kMqttPassword, MQTTstatus, QOS, true,
+                                      LWT_OFFLINE);
     else
-      connected = mqtt_client.connect(mqtt_clientid.c_str());
+      connected = mqtt_client.connect(mqtt_clientid.c_str(), MQTTstatus, QOS,
+                                      true, LWT_OFFLINE);
     if (connected) {
     // Once connected, publish an announcement...
-      mqtt_client.publish(MQTTack, "Connected");
-      debug("connected.");
+      mqtt_client.publish(MQTTlog, "(Re)Connected");
+      debug("reconnected.");
+
+      // Update Last Will & Testament to say we are back online.
+      mqtt_client.publish(MQTTstatus, LWT_ONLINE, true);
+
       // Subscribing to topic(s)
       subscribing(MQTTcommand);
       for (uint8_t i = 0; i < kSendTableSize; i++) {
@@ -1345,12 +1365,12 @@
         lastReconnectAttempt = 0;
         wasConnected = true;
         if (boot) {
-          mqtt_client.publish(MQTTack, "IR Server just booted");
+          mqtt_client.publish(MQTTlog, "IR Server just booted");
           boot = false;
         } else {
           String text = "IR Server just (re)connected to MQTT. "
               "Lost connection about " + timeSince(lastConnectedTime);
-          mqtt_client.publish(MQTTack, text.c_str());
+          mqtt_client.publish(MQTTlog, text.c_str());
         }
         lastConnectedTime = now;
         debug("successful client mqtt connection");


Remove leftover debug message in IRrecvDumpV2 (#526)

--- examples/IRrecvDumpV2/IRrecvDumpV2.ino
+++ examples/IRrecvDumpV2/IRrecvDumpV2.ino
@@ -139,8 +139,6 @@
     IRMitsubishiAC ac(0);
     ac.setRaw(results->state);
     description = ac.toString();
-  } else {
-    Serial.println("Not Mitsu AC.");
   }
 #endif  // DECODE_MITSUBISHI_AC
 #if DECODE_TOSHIBA_AC


Implement : flashing every second

Implement : flashing every second

--- NTPclock/NTPclock.ino
+++ NTPclock/NTPclock.ino
@@ -89,6 +89,13 @@
 void updateMisc() {
   int portion = (second() / 6) + 1; //get the number of bars that should be lit
   setBar(portion);                  //and then set them
+
+  //Every other second....
+  if (second() % 2 == 1) {
+    lc1.setLed(0,0,0,true);
+  } else {
+    lc1.setLed(0,0,0,false);
+  }
 }

 // Controlls a 10-segment LED bargraph


Arkanoid8 is updated to make playing easier

--- examples/games/arkanoid8/arkanoid8.ino
+++ examples/games/arkanoid8/arkanoid8.ino
@@ -34,6 +34,8 @@
 #include "arkanoid.h"
 #include "levels.h"

+#define PIX_BITS  2
+
 NanoEngine8 engine;

 static uint8_t g_level = 0;
@@ -57,8 +59,8 @@
     {
         NanoRect  platform;  // platform position on the screen
         NanoPoint ball;      // ball position on the screen
-        int16_t   ballX;     // ball position in *2 coordinates
-        int16_t   ballY;     // ball position in *2 coordinates
+        int16_t   ballX;     // ball position in ^PIX_BITS coordinates
+        int16_t   ballY;     // ball position in ^PIX_BITS coordinates
         NanoPoint ballSpeed; // ball speed in *2 coordinates
         uint8_t   blocks[BLOCK_NUM_ROWS][MAX_BLOCKS_PER_ROW];
         uint8_t   blocksLeft;
@@ -208,17 +210,17 @@
     {
         if (gameState.battleField.ball.x < gameState.battleField.platform.p1.x + 3)
         {
-            gameState.battleField.ballSpeed.x = -2;
+            gameState.battleField.ballSpeed.x = -3;
             gameState.battleField.ballSpeed.y = -gameState.battleField.ballSpeed.y;
         }
         else if (gameState.battleField.ball.x > gameState.battleField.platform.p2.x - 3)
         {
-            gameState.battleField.ballSpeed.x = +2;
+            gameState.battleField.ballSpeed.x = +3;
             gameState.battleField.ballSpeed.y = -gameState.battleField.ballSpeed.y;
         }
         else
         {
-            gameState.battleField.ballSpeed.x = gameState.battleField.ballSpeed.x > 0 ? 1: -1;
+            gameState.battleField.ballSpeed.x = gameState.battleField.ballSpeed.x > 0 ? 2: -2;
             gameState.battleField.ballSpeed.y = -gameState.battleField.ballSpeed.y;
         }
         return true;
@@ -255,7 +257,8 @@
         gameState.battleField.ballX += gameState.battleField.ballSpeed.x;
         gameState.battleField.ballY += gameState.battleField.ballSpeed.y;
         moveBall = false;
-        gameState.battleField.ball.setPoint(gameState.battleField.ballX>>1, gameState.battleField.ballY>>1);
+        gameState.battleField.ball.setPoint(gameState.battleField.ballX>>PIX_BITS,
+                                            gameState.battleField.ballY>>PIX_BITS);
         if (checkGameAreaHit())
         {
             moveBall = true;
@@ -317,9 +320,9 @@
     engine.refresh();
     gameState.battleField.platform.setRect( 20, 56, 31, 58 );
     gameState.battleField.ball.setPoint( 25, 55);
-    gameState.battleField.ballX = gameState.battleField.ball.x << 1;
-    gameState.battleField.ballY = gameState.battleField.ball.y << 1;
-    gameState.battleField.ballSpeed.setPoint( 2, -2);
+    gameState.battleField.ballX = gameState.battleField.ball.x << PIX_BITS;
+    gameState.battleField.ballY = gameState.battleField.ball.y << PIX_BITS;
+    gameState.battleField.ballSpeed.setPoint( 3, -(1<<PIX_BITS) );
     engine.drawCallback( drawBattleField );
     engine.loopCallback( battleFieldLoop );
     loadLevel();


Update for STANDARD USB variant.

Update for STANDARD USB variant.

--- examples/Sandbox/CosaLowPower/CosaLowPower.ino
+++ examples/Sandbox/CosaLowPower/CosaLowPower.ino
@@ -80,7 +80,9 @@
   // 0 uA, already done by startup
   ACSR = _BV(ACD);
   ADCSRA = 0;
+#if !defined(__ARDUINO_STANDARD_USB__)
   UCSR0B = 0;
+#endif
 #endif
 #if defined(USE_DISABLE_PINS)
   // 2 uA, possible uart pin needed disconnecting


fix typo

fix typo

--- Arduino/laser-radar/laser-radar.ino
+++ Arduino/laser-radar/laser-radar.ino
@@ -20,10 +20,10 @@
 // Servo
 Servo ServoMotor;
 const uint8_t servoPin = 6;
-uint8_t servoRotationAngel = 5;
-const uint8_t servoRotationAngelFast = 10;
-const uint8_t servoRotationAngelMedium = 5;
-const uint8_t servoRotationAngelDetailed = 1;
+uint8_t servoRotationAngle = 5;
+const uint8_t servoRotationAngleFast = 10;
+const uint8_t servoRotationAngleMedium = 5;
+const uint8_t servoRotationAngleDetailed = 1;

 const uint8_t seroRotationDurationPerAngle = 2;

@@ -65,7 +65,7 @@
     // attach servo pin and set to initial direction
     ServoMotor.attach(servoPin, 450, 2400); // 400, 2600 to fix rotation issues
     ServoMotor.write(servoPos);
-    servoRotationAngel = servoRotationAngelMedium;
+    servoRotationAngle = servoRotationAngleMedium;
 }

@@ -111,11 +111,11 @@

     if(servoMovement == right)
     {
-        servoPos += servoRotationAngel;
+        servoPos += servoRotationAngle;
     }
     else
     {
-        servoPos -= servoRotationAngel;
+        servoPos -= servoRotationAngle;
     }

     if(servoPos <= 0) { servoPos = 0; }
@@ -133,19 +133,19 @@

         if(data == "fast")
         {
-            servoRotationAngel = servoRotationAngelFast;
+            servoRotationAngle = servoRotationAngleFast;
             return;
         }

         if(data == "medium")
         {
-            servoRotationAngel = servoRotationAngelMedium;
+            servoRotationAngle = servoRotationAngleMedium;
             return;
         }

         if(data == "detail")
         {
-            servoRotationAngel = servoRotationAngelDetailed;
+            servoRotationAngle = servoRotationAngleDetailed;
             return;
         }
     }
@@ -159,7 +159,9 @@
     Serial.print("|");
     Serial.print(pos);
     Serial.print("|");
-    Serial.println(distance);
+    Serial.print(distance);
+    Serial.print("|");
+    Serial.println(servoRotationAngle);
 }


Change pin setup and push button delay

Change pin setup and push button delay

--- arduino.ino
+++ arduino.ino
@@ -7,18 +7,18 @@

 // We set the push delay
 // (delay between the high and low signal to simulate a push button action).
-int PUSH_BTN_DELAY = 100;
+int PUSH_BTN_DELAY = 500;
 // Wired to the Senseo Power push button.
-int PIN_POWER = 1;
+int PIN_POWER = 2;
 // Wired to the Senseo Short Coffee push button.
 // If we put that to high it make a short coffee: obvious man being obvious here.
-int PIN_MAKE_SHORT = 2;
+int PIN_MAKE_SHORT = 3;
 // Wired to the Senseo Long Coffee push button.
-int PIN_MAKE_LONG = 3;
+int PIN_MAKE_LONG = 4;
 // Wired to the RPi, so it can order a short coffee.
-int PIN_ORDER_SHORT = 4;
+int PIN_ORDER_SHORT = 5;
 // Wired to the RPi, so it can order a short coffee.
-int PIN_ORDER_LONG = 5;
+int PIN_ORDER_LONG = 6;
 int is_short_ordered;
 int is_long_ordered;

@@ -59,3 +59,4 @@
     delay(30000);
   }
 }
+


Fixed voltage problem. Both 2s and 3s LiPos can be used


working

working

--- invPendulum/invPendulum.ino
+++ invPendulum/invPendulum.ino
@@ -20,6 +20,14 @@
 bool flipper = false;
 int Kp = 3;

+// Infomation from glove
+enum state {idle,forward_drive, backup, left_turn,right_turn};
+state gesture_state = idle;
+uint8_t turning_speed;
+bool should_catapult;
+
+
+
 void setup(){
   Wire.begin();
   mpu.initialize();
@@ -36,6 +44,42 @@
   pinMode(test, OUTPUT);
   Serial.begin(9600);
 }
+
+void receive_info() {
+   String command1 =  Serial.readStringUntil('#');
+   String combine_string = NULL;
+   String string1;
+   String string2;
+   String string3;
+   int int_command1;
+   int int_command2;
+   int int_command3;
+   int pos = 0;
+   int pre_pos = 0;
+   for (int i = 0; i < string.length(command1);i++){
+     pos++;
+     if (command1.substring(i,i+1) == " "){
+        string1 = command1.substring(pos-i,i-1);
+
+     }
+
+    }
+
+
+
+   //int int_command1 = command1.toInt();
+   //String command2 = Serial.readStringUntil(' ');
+   //int int_command2 = command2.toInt();
+   //String command3 = Serial.readStringUntil('#');
+   //int int_command3 = command3.toInt();
+   //Serial.println("Command: ");
+   //Serial.println(int_command1);
+   //Serial.println(int_command2);
+   //Serial.println(int_command3);
+
+
+}
+
 void motorControl(int pwm1, int pwm2, int dir1, int dir2) {
   int p1, p2;
   if (pwm1 >= 255) {p1 = 255;}
@@ -76,6 +120,9 @@
 }

 void loop(){
+  while(Serial.available()>0){
+    receive_info();
+    }
   flipper = !flipper;
   if (flipper) {digitalWrite(test, HIGH);}
   else {digitalWrite(test, LOW);}


GUI_UART_Test removed

GUI_UART_Test removed

--- GUI/GUI_UART_Test/GUI_UART_Test.ino
+++ GUI/GUI_UART_Test/GUI_UART_Test.ino
@@ -1,32 +0,0 @@
-/*
-  Blink
-  Turns on an LED on for one second, then off for one second, repeatedly.
-
-  Most Arduinos have an on-board LED you can control. On the Uno and
-  Leonardo, it is attached to digital pin 13. If you're unsure what
-  pin the on-board LED is connected to on your Arduino model, check
-  the documentation at http://arduino.cc
-
-  This example code is in the public domain.
-
-  modified 8 May 2014
-  by Scott Fitzgerald
- */
-
-
-// the setup function runs once when you press reset or power the board
-void setup() {
-  Serial.begin(9600);
-  // initialize digital pin 13 as an output.
-  pinMode(13, OUTPUT);
-}
-
-// the loop function runs over and over again forever
-void loop() {
-  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
-  Serial.println("yellow on");
-  delay(1000);              // wait for a second
-  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
-  Serial.println("yellow off");
-  delay(1000);              // wait for a second
-}