MQTT433gateway.ino: Store strings in flash instead of SRAM

This saves 464 bytes of dynamic memory.

--- MQTT433gateway.ino
+++ MQTT433gateway.ino
@@ -67,8 +67,8 @@
   rf.setCallback(rfCallback);
   rf.setPulseTrainCallBack(rfRawCallback);
   rf.initReceiver(RECEIVER_PIN);
-  Serial.println("");
-  Serial.print("Name: ");
+  Serial.println();
+  Serial.print(F("Name: "));
   Serial.println(mainTopic);
 }

@@ -77,7 +77,7 @@
   beatLED.on();
   // We start by connecting to a WiFi network
   Serial.println();
-  Serial.print("Connecting to ");
+  Serial.print(F("Connecting to "));
   Serial.println(ssid);

   WiFi.begin(ssid, password);
@@ -88,22 +88,22 @@
     beatLED.off();
     delay(500);
     beatLED.on();
-    Serial.print(".");
-  }
-
-  Serial.println("");
-  Serial.println("WiFi connected");
-  Serial.println("IP address: ");
+    Serial.print(F("."));
+  }
+
+  Serial.println();
+  Serial.println(F("WiFi connected"));
+  Serial.println(F("IP address: "));
   Serial.println(WiFi.localIP());
 }

 void transmitt(const String &protocol, const char *message) {
-  Serial.print("rf send ");
+  Serial.print(F("rf send "));
   Serial.print(message);
-  Serial.print(" with protocol ");
+  Serial.print(F(" with protocol "));
   Serial.println(protocol);

-  if (protocol == "RAW") {
+  if (protocol == F("RAW")) {
     int rawpulses[MAXPULSESTREAMLENGTH];
     int rawlen = rf.stringToPulseTrain(message, rawpulses, MAXPULSESTREAMLENGTH);
     if (rawlen > 0) {
@@ -115,9 +115,9 @@
 }

 void mqttCallback(const char* topic_, const byte* payload_, unsigned int length) {
-  Serial.print("Message arrived [");
+  Serial.print(F("Message arrived ["));
   Serial.print(topic_);
-  Serial.print("] ");
+  Serial.print(F("] "));
   for (int i = 0; i < length; i++) {
     Serial.print((char)payload_[i]);
   }
@@ -128,16 +128,16 @@
   strncpy(payload, (char *)payload_, length);
   payload[length] = '\0';

-  String sendTopic = globalTopic + "/send/";
+  String sendTopic = globalTopic + F("/send/");
   if (topic.startsWith(sendTopic)) {
     transmitt(topic.substring(sendTopic.length()), payload);
   }
-  sendTopic = mainTopic + "/send/";
+  sendTopic = mainTopic + F("/send/");
   if (topic.startsWith(sendTopic)) {
     transmitt(topic.substring(sendTopic.length()), payload);
   }
-  if (topic == (mainTopic + "/set/raw")) {
-    Serial.println("Change raw mode.");
+  if (topic == (mainTopic + F("/set/raw"))) {
+    Serial.println(F("Change raw mode."));
     if (payload[0] == '1') {
       rawMode = true;
     }
@@ -145,8 +145,8 @@
       rawMode = false;
     }
   }
-  if (topic == (mainTopic + "/set/log")) {
-    Serial.println("Change log mode.");
+  if (topic == (mainTopic + F("/set/log"))) {
+    Serial.println(F("Change log mode."));
     if (payload[0] == '1') {
       logMode = true;
     }
@@ -154,58 +154,61 @@
       logMode = false;
     }
   }
-  if (topic == (mainTopic + "/ota/url")) {
+  if (topic == (mainTopic + F("/ota/url"))) {
     otaURL = String(payload);
-    mqtt.publish((mainTopic+ "/ota/nonce").c_str(), otaAuth.nonce().c_str());
-  }
-  if ((topic == (mainTopic + "/ota/passwd")) && (otaURL.length() > 7)) {
+    mqtt.publish((mainTopic+ F("/ota/nonce")).c_str(), otaAuth.nonce().c_str());
+  }
+  if ((topic == (mainTopic + F("/ota/passwd"))) && (otaURL.length() > 7)) {
     if (otaAuth.verify(payload)) {
       beatLED.on();
-      Serial.print("Start OTA update from: ");
+      Serial.print(F("Start OTA update from: "));
       Serial.println(otaURL);
       rf.disableReceiver();
       t_httpUpdate_return ret = ESPhttpUpdate.update(otaURL);
       switch (ret) {
         case HTTP_UPDATE_FAILED:
-          Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
+          Serial.print(F("HTTP_UPDATE_FAILD Error ("));
+          Serial.print(ESPhttpUpdate.getLastError());
+          Serial.print(F("): "));
+          Serial.println(ESPhttpUpdate.getLastErrorString());
           break;
         case HTTP_UPDATE_NO_UPDATES:
-          Serial.println("HTTP_UPDATE_NO_UPDATES");
+          Serial.println(F("HTTP_UPDATE_NO_UPDATES"));
           break;
         case HTTP_UPDATE_OK:
-          Serial.println("HTTP_UPDATE_OK"); // may not called ESPhttpUpdate reboot the ESP?
+          Serial.println(F("HTTP_UPDATE_OK")); // may not called ESPhttpUpdate reboot the ESP?
           ESP.restart();
           break;
       }
       rf.enableReceiver();
     } else {
-      Serial.println("OTA authentication failed!");
+      Serial.println(F("OTA authentication failed!"));
     }
   }
 }

 void rfCallback(const String &protocol, const String &message, int status, int repeats, const String &deviceID) {
-  Serial.print("RF signal arrived [");
+  Serial.print(F("RF signal arrived ["));
   Serial.print(protocol);
-  Serial.print("]/[");
+  Serial.print(F("]/["));
   Serial.print(deviceID);
-  Serial.print("] (");
+  Serial.print(F("] ("));
   Serial.print(status);
-  Serial.print(") ");
+  Serial.print(F(") "));
   Serial.print(message);
-  Serial.print(" (");
+  Serial.print(F(" ("));
   Serial.print(repeats);
-  Serial.println(")");
+  Serial.println(F(")"));

   if (status == VALID) {
-    String topic = globalTopic + String("/recv/") + protocol;
+    String topic = globalTopic + String(F("/recv/")) + protocol;
     if (deviceID != NULL) {
       topic += String('/') + deviceID;
     }
     mqtt.publish(topic.c_str(), message.c_str(), true);
   }
   if (logMode) {
-    String topic = mainTopic + String("/log/") + String(status) + String('/') + protocol;
+    String topic = mainTopic + String(F("/log/")) + String(status) + String('/') + protocol;
     mqtt.publish(topic.c_str(), message.c_str());
   }
 }
@@ -214,13 +217,13 @@
   if (rawMode) {
     String data = rf.pulseTrainToString(pulses, length);
     if (data.length() > 0) {
-      Serial.print("RAW RF signal (");
+      Serial.print(F("RAW RF signal ("));
       Serial.print(length);
-      Serial.print("): ");
+      Serial.print(F("): "));
       Serial.print(data);
       Serial.println();

-      mqtt.publish((mainTopic + "/recvRaw").c_str(), data.c_str());
+      mqtt.publish((mainTopic + F("/recvRaw")).c_str(), data.c_str());
     }
   }
 }
@@ -229,19 +232,19 @@
   beatLED.on();
   // Loop until we're reconnected
   while (!mqtt.connected()) {
-    Serial.print("Attempting MQTT connection...");
+    Serial.print(F("Attempting MQTT connection..."));
     // Attempt to connect
     if (mqtt.connect(mainTopic.c_str(), mainTopic.c_str(), 0, true, "offline")) {
-      Serial.println("connected");
+      Serial.println(F("connected"));
       mqtt.publish(mainTopic.c_str(), "online", true);
-      mqtt.subscribe((mainTopic + "/set/+").c_str());
-      mqtt.subscribe((mainTopic + "/ota/+").c_str());
-      mqtt.subscribe((mainTopic + "/send/+").c_str());
-      mqtt.subscribe((globalTopic + "/send/+").c_str());
+      mqtt.subscribe((mainTopic + F("/set/+")).c_str());
+      mqtt.subscribe((mainTopic + F("/ota/+")).c_str());
+      mqtt.subscribe((mainTopic + F("/send/+")).c_str());
+      mqtt.subscribe((globalTopic + F("/send/+")).c_str());
     } else {
-      Serial.print("failed, rc=");
+      Serial.print(F("failed, rc="));
       Serial.print(mqtt.state());
-      Serial.println(" try again in 5 seconds");
+      Serial.println(F(" try again in 5 seconds"));
       // Wait 5 seconds before retrying
       beatLED.off();
       delay(500);


Update arduino_md03_v_5_0.ino

Update arduino_md03_v_5_0.ino

modified dbug code

--- arduino/arduino_md03_v_5_0/arduino_md03_v_5_0.ino
+++ arduino/arduino_md03_v_5_0/arduino_md03_v_5_0.ino
@@ -2,25 +2,27 @@
                 ArcEyes USB Serial
 ****************************************************/

-/*
-#include <Wire.h>
-#include <LCD.h>
-#include <LiquidCrystal_I2C.h>
-
- //int LCD pins on I2C bus
- #define I2C_ADDR 0x27
- #define BACKLIGHT_PIN 3
- #define En_pin  2
- #define Rw_pin  1
- #define Rs_pin  0
- #define D4_pin  4
- #define D5_pin  5
- #define D6_pin  6
- #define D7_pin  7
- LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
-*/
-
 const int debug = 0;
+
+if (debug == 1){
+   #include <Wire.h>
+   #include <LCD.h>
+   #include <LiquidCrystal_I2C.h>
+
+    //int LCD pins on I2C bus
+    #define I2C_ADDR 0x27
+    #define BACKLIGHT_PIN 3
+    #define En_pin  2
+    #define Rw_pin  1
+    #define Rs_pin  0
+    #define D4_pin  4
+    #define D5_pin  5
+    #define D6_pin  6
+    #define D7_pin  7
+    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
+}
+
+
 const int potPin1 = A0;
 const int potPin2 = A1;
 const int potPin3 = A2;


Add function to disable all channelbuttons

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -680,6 +680,12 @@
   lcd.print(" bars");
 }

+void turnAllChannelButtonsOff() {
+  for (byte i = 0; i < numberOfChannelButtons; i++) {
+    channelButtons[i].turnLedOff();
+  }
+}
+
 void RealTimeSystem(byte realtimebyte) {
   if (realtimebyte == CLOCK) {
     counter++;


power saver - such is life

power saver - such is life

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -30,6 +30,7 @@

 	for(int i = 0; i < 3; i++)
 		Serial.print(F("==============="));
+

 	// Startup a heartbeat LED.
 	Heartbeat::start();
@@ -40,10 +41,26 @@
   // Setup the pressure sensor.
   sensors.init_MPL3115A2();

+  // set pinmode for the CH_PD
+  pinMode(12, OUTPUT);
+
 }

 void loop(){

+  // turn on the module
+  digitalWrite(12, HIGH);
+
+  delay(2000); // let it turn on
+
+  // Startup our network.
+  while (!network.init_wireless("TRYME", "Damian126No#ash!")){
+    Serial.println(F("Failed connecting to wireless network, retying in 3 seconds."));
+    Heartbeat::panic();
+    delay(3000);
+  }
+  delay(3000);
+
   // time stamp each iteration
   Serial.print("************ Time now in millis: ");
   Serial.print(millis());
@@ -64,30 +81,22 @@

   // wake up the led after the measurements
   Heartbeat::start();
-
-  // Startup our network.
-  while (!network.init_wireless("TRYME", "Damian126No#ash!")){
-    Serial.println(F("Failed connecting to wireless network, retying in 3 seconds."));
-    Heartbeat::panic();
-    delay(3000);
-  }

   // Make our heartbeat LED blink at a normal rate again if we were panicking earlier.
   Heartbeat::start();

-  // try to send 3 times, if 3 fail restart the module
-  for(int i = 0; i < 3; i++){
+  // try to send 5 times, if 5 fail restart the module
+  for(int i = 0; i < 5; i++){
     Serial.print("Trying to send data: ");
     Serial.println(i);

     if(!network.send_packet(sensor_data)){
       if(i == 2){
         // we have reached the limit of our patience, restart the module and continue
-        network.send_command("AT+RST", "OK", 2, 1500);
+        network.send_command("AT+RST", "OK", 2, 5000);

         // start panic mode
         Heartbeat::panic();
-        break;
       }
     }
     else{
@@ -96,9 +105,14 @@
       break;
     }
   }
-
+
+  // close the TCP connection
+  network.send_command("AT+CIPCLOSE", "OK", 2, 1500);
   // disconnect from the AP to conserve energy
   network.send_command("AT+CWQAP", "OK", 2, 1500);
+
+  // turn off the module
+  digitalWrite(12, LOW);

 	Serial.println(F("Waiting 5 min... - sleep time"));
   delay(10); // necessary in order to get the text out the serial
@@ -107,7 +121,7 @@
   Heartbeat::stop();

   // sleep for 5 min = 10 sec * 30
-  for(int i = 0; i < 30; i++){
+  for(int i = 0; i < 1; i++){
     EnableWatchDog(0b100001); // sleep for 8 seconds
     digitalWrite(13, HIGH);
     EnableWatchDog(0b000110); // sleep for 1 second


Update base2clock.ino

Update base2clock.ino

Cleaned up initial time set.

--- base2clock.ino
+++ base2clock.ino
@@ -18,13 +18,14 @@

 //adjust fudge factor and offset to tune the arduino.
+
 //slow float fudge_factor = 1.001;
 //slightly fast float fudge_factor = 1.0012;
 //very slightly fast float fudge_factor = 1.0011;
 float fudge_factor = 1.00107;
 int offset = 15;

-unsigned long prev_mils,mil,sec,mins,hr,reset_mills = 0;
+unsigned long prev_mils,mil,sec,mins,hr,reset_mil = 0;

 //initially set hours to zero and minutes to zero.
 int hr_init = 0;
@@ -38,22 +39,26 @@

 //call this function if a time set button is pressed.
 void reset_init(){
-  reset_mills = mil;
-
-  //use current time setting as new initial values.
+  reset_mil = mil;
+
   hr_init = 0;
   min_init = 2;
-  if(p1 == 1) hr_init = 4;
-  if(p2 == 1) hr_init += 2;
-  if(p3 == 1) hr_init += 1;
-  if(p4 == 1) min_init += 30;
-  if(p5 == 1) min_init += 15;
-  if(p6 == 1) min_init += 8;
-  if(p7 == 1) min_init += 4;
-  if(p8 == 1) min_init += 2;
-
-  if(p6 == 1 && p7 == 1 && p8 == 1)
-    min_init -= 1;
+
+  if(time_set){
+    //use current time setting as new initial values.
+    if(p1 == 1) hr_init = 4;
+    if(p2 == 1) hr_init += 2;
+    if(p3 == 1) hr_init += 1;
+    if(p4 == 1) min_init += 30;
+    if(p5 == 1) min_init += 15;
+    if(p6 == 1) min_init += 8;
+    if(p7 == 1) min_init += 4;
+    if(p8 == 1) min_init += 2;
+
+    if(p6 == 1 && p7 == 1 && p8 == 1)
+      min_init -= 1;
+  }
+  else time_set = true;
 }

 void setup(){
@@ -92,12 +97,10 @@
   //see if the time is being set.
   if(digitalRead(5) == LOW){
     reset_slow = true;
-    time_set = true;
     reset_init();
   }  else {
     if(digitalRead(4) == LOW){
       reset_fast = true;
-      time_set = true;
       reset_init();
     }
   }
@@ -145,7 +148,7 @@
   }else{

     //subtract lapsed time since last occasion that the time was set.
-    mil -= reset_mills;
+    mil -= reset_mil;

     // TUNE your arduino
     sec = (mil/1000 * fudge_factor) + offset;


calibration change, powerAvg add

calibration change, powerAvg add

--- _06-power-meter/_06-power-meter.ino
+++ _06-power-meter/_06-power-meter.ino
@@ -130,7 +130,7 @@
   pinMode(IRPIN, INPUT);
   attachInterrupt(4, IRCHECKING_START, RISING);

-  emon1.current(A0, 70);  // Current: input pin, calibration.
+  emon1.current(A0, 75);  // Current: input pin, calibration.

   OLDIRSTATUS = LOW ;

@@ -190,7 +190,10 @@
     payload += ( revValue + oldrevValue ) / 2 ;
     payload += ",\"revMills\":";
     payload += ( revMills + oldrevMills ) / 2 ;
+    payload += ",\"powerAvg\":";
+    payload += ( average + ((revValue + oldrevValue ) / 2 )) / 2 ;
     payload += "}";
+

   if (( IRSTATUS != OLDIRSTATUS ) && ( revMills > 600 )) {
     sendmqttMsg(payload);


Update power monitor rate.

Update power monitor rate.

--- riptide_hardware/firmware/power_monitor/power_monitor.ino
+++ riptide_hardware/firmware/power_monitor/power_monitor.ino
@@ -6,29 +6,23 @@

 ros::Publisher state_pub("state/batteries", &battery);

-int DELAY = 200;
-int timer;
-
 void setup()
 {
   nh.initNode();
   nh.advertise(state_pub);
-
-  timer = millis() + DELAY;
 }

 void loop()
 {
   nh.spinOnce();

-  if(timer > millis())
-  {
-    battery.port.current = (analogRead(A3)-104)*0.03755;
-    battery.port.voltage = analogRead(A2)*0.03015;
-    battery.stbd.current = (analogRead(A0)-104)*0.03755;
-    battery.stbd.voltage = analogRead(A1)*0.03016;
-
-    state_pub.publish(&battery);
-    timer = millis() + DELAY;
-  }
+  battery.port.current = (analogRead(A3) - 104) * 0.03755;
+  battery.port.voltage = analogRead(A2) * 0.03015;
+  battery.stbd.current = (analogRead(A0) - 104) * 0.03755;
+  battery.stbd.voltage = analogRead(A1) * 0.03016;
+
+  state_pub.publish(&battery);
+
+  delay(200);
 }
+


Show current and next part

Show current and next part

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -91,6 +91,8 @@
 const byte SONG_CONFIGURATION = 0;
 const byte CONFIGURATION_START = 1;
 const byte CONFIGURATION_FINISHED = 2;
+const byte CURRENT_PART = 3;
+const byte NEXT_PART = 4;

 const byte SONG_OFFSET = 10;

@@ -138,8 +140,38 @@
       case CONFIGURATION_FINISHED:
         handleConfigurationFinished();
         break;
-    }
-  }
+      case CURRENT_PART:
+        handleCurrentPart(decoded + 4);
+        break;
+      case NEXT_PART:
+        handleNextPart(decoded + 4);
+        break;
+    }
+  }
+}
+
+void handleCurrentPart(char* message) {
+  if (mode != SONG_MODE) {
+    return;
+  }
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print(message);
+}
+
+void clearLine(byte line) {
+  lcd.setCursor(0, line);
+  lcd.print(F("                "));
+}
+
+void handleNextPart(char* message) {
+  if (mode != SONG_MODE) {
+    return;
+  }
+
+  clearLine(1);
+  lcd.setCursor(0, 1);
+  lcd.print(message);
 }

 void handleConfigurationStart() {
@@ -211,6 +243,10 @@
     return CONFIGURATION_START;
   } else if (strcmp(strings , "CF") == 0) {
     return CONFIGURATION_FINISHED;
+  } else if (strcmp(strings, "CP") == 0) {
+    return CURRENT_PART;
+  } else if (strcmp(strings, "NP") == 0) {
+    return NEXT_PART;
   }
   return -1;
 }
@@ -539,7 +575,7 @@
 void RealTimeSystem(byte realtimebyte) {
   if (realtimebyte == CLOCK) {
     counter++;
-    if (counter >= 23) {
+    if (counter == 24) {
       counter = 0;
       digitalWrite(bpmLed, HIGH);
     }
@@ -561,7 +597,7 @@
   if (realtimebyte == STOP) {
     digitalWrite(bpmLed, LOW);
     playing = false;
-  }
-}
-
-
+    changeMode(NORMAL_MODE);
+  }
+}
+


Send stop clips command in normal mode

Send stop clips command in normal mode

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -116,6 +116,7 @@
 const byte STOP_MIDI_NOTE = 0;
 const byte REPEAT_MIDI_NOTE = CONTROL_OFFSET;
 const byte SEND_CONFIGURATION = CONTROL_OFFSET + 1;
+const byte STOP_CLIPS = CONTROL_OFFSET + 2;

 const byte INVALID_MIDI_NOTE = 254;
 byte midiNoteToSend = INVALID_MIDI_NOTE;
@@ -535,6 +536,7 @@
     midiNoteToSend = STOP_MIDI_NOTE;
     bars = 0;
     changeMode(NORMAL_MODE);
+    return;
   }

   if (playButton.isJustReleased()) {
@@ -642,6 +644,18 @@
     playButton.turnLedOff();
   }

+  if (stopButton.isJustPressed()) {
+    stopButton.turnLedOn();
+  }
+
+  if (stopButton.isJustReleased()) {
+    if (midiNoteToSend == INVALID_MIDI_NOTE) {
+      midiNoteSendStart = 0;
+      midiNoteToSend = STOP_CLIPS;
+    }
+    stopButton.turnLedOff();
+  }
+
   sendMidiNote();
 }


Minor formatting change.

Minor formatting change.

--- arduino/test/rx_test/rx_test.ino
+++ arduino/test/rx_test/rx_test.ino
@@ -8,7 +8,8 @@
   DURATION = 5000u,  // μs
 };

-unsigned const long SPACINGS[4] = {117766u, 95420u, 77814u, 709001u};
+unsigned const long SPACINGS[NUM_TRANSMITTERS] =
+    {117766u, 95420u, 77814u, 709001u};

 void setup() {
   pinMode(RX_PIN, OUTPUT);


Update Beacon.ino

Update Beacon.ino

--- FastLED/Beacon.ino
+++ FastLED/Beacon.ino
@@ -1,103 +1,229 @@
 // This #include statement was automatically added by the Particle IDE.
 #include <FastLED.h>
-FASTLED_USING_NAMESPACE;
-
-//The FastLED variables
+FASTLED_USING_NAMESPACE; //Gotta include the namespace because reasons
+
+/*
+__________________________FastLED variables__________________________
+*/
 #define RING_PIN    D1
 #define RING_LEDS    24
-CRGB ringLeds[RING_LEDS];
+CRGB ringLeds[RING_LEDS]; //Gotta use CRGB because FastLED won't auto convert from HSV to RGB
+CHSV HSVRing[RING_LEDS]; //All the real magic happens to this array
+
 #define STRIP_PIN    D0
 #define STRIP_LEDS    15
-CRGB stripLeds[STRIP_LEDS];
-
-//The fastLED color declarations
-const int  colors = 3;
+CRGB stripLeds[STRIP_LEDS]; //Same situation as the ring stuff above
+//CHSV HSVStrip[STRIP_LEDS];
+
+/*
+__________________________FastLED color declarations__________________________
+*/
+const int  colors = 5;
 CHSV red = CHSV(0, 0 , 0);
+CHSV yellow  = CHSV(64, 0 , 0);
 CHSV green  = CHSV(85, 0 , 0);
 CHSV blue  = CHSV(171, 0 , 0);
-CHSV currentPalette[colors] =  {red, green, blue};
+CHSV purple  = CHSV(192, 0 , 0);
+CHSV currentPalette[colors] =  { blue, green, yellow, purple, red};

 CHSV beaconColor; //The color beacon sent
-CHSV baseColor;  //The beacon color received
-
-
-
+CHSV baseColor = CHSV(0,0,0);  //The beacon color received
+
+/*
+__________________________Communication Variables__________________________
+*/
 char beaconString[40]; //the string being published
-
+String selfName = "Tim"; //The name of this device
+String otherName = "Bonnie"; //The name of the device you're listening to
+
+/*
+__________________________Misc Variables__________________________
+*/
+const int button = D3; //The push button pin
 uint8_t brightness = 254; //Global brightness assignment
-int button = D3; //The push button pin
-
-
+uint8_t baseLedsLit; //The current number of lit LEDS
+uint8_t whileDelay = 4; //delay used in the while loop, in ms (Zero might mess with the wifi if held too long)
+
+unsigned long decayRate = 11500; //decay rate in MS. a fully lit beacon decays to zero in a bit more than 8 hours.
+unsigned long decayUpdate = 0;
+
+unsigned long spinRate = 210; //spin rate in MS. ideally a full rotation happens every 5 seconds or so
+unsigned long spinUpdate = 0;
+
+/*
+__________________________Function Declarations__________________________
+*/
+void beaconFill(NSFastLED::CHSV color); //This function fills the beacon with various colors based on the input beacon color calculated
+void beaconSpin(); //This function spins the beacon colors
+
+/*
+__________________________The Big Show__________________________
+*/
 void setup() {
-    pinMode(button, INPUT_PULLDOWN);
+    pinMode(button, INPUT_PULLDOWN); //Push button (for now... muhaahahaha)
 	delay(3000); // 3 second delay for recovery
-
-
-  	FastLED.addLeds<NEOPIXEL, RING_PIN>(ringLeds, RING_LEDS);
-	FastLED.addLeds<NEOPIXEL, STRIP_PIN>(stripLeds, STRIP_LEDS);
-
+    Particle.subscribe("Beacon Update", ColorUpdate, MY_DEVICES); //Subscribe to the updates
+
+  	FastLED.addLeds<NEOPIXEL, RING_PIN>(ringLeds, RING_LEDS); //initalize the ring
+	FastLED.addLeds<NEOPIXEL, STRIP_PIN>(stripLeds, STRIP_LEDS); //initialize the strip
+	fill_solid(stripLeds, STRIP_LEDS, CRGB::Black); //black out the strip
+
+	fill_rainbow(ringLeds, RING_LEDS, 0, 10); //add rainbow to ring
+	for(int i = 0; i < 3 * RING_LEDS; i++){ //this will spin the ring around 3 times
+	    CRGB tempColor = ringLeds[0];
+	    for(int j = 0; j <RING_LEDS-1; j++){
+	        ringLeds[j] = ringLeds[j+1];
+	    }
+	    ringLeds[RING_LEDS - 1] = tempColor;
+	    FastLED.show();
+	}
   	// set master brightness control
   	FastLED.setBrightness(brightness);
 }

-
 void loop()
-{	if(digitalRead(button) == HIGH){
-        whileTouching();
-    }
-}
-
+{
+    if(digitalRead(button) == HIGH){ //If the button is pressed
+        delay(50); //bullshit debounce delay
+        whileTouching(); //this badboy runs while the
+    }
+    if((decayUpdate + decayRate) < millis()){  //Check if enough time has passed to decay the lights
+        colorDecay(); //the function to decay the colors (duh)
+        decayUpdate = millis();
+    }
+    if((spinUpdate + spinRate) < millis()){  //Check if enough time has passed to decay the lights
+        beaconSpin(); //the function to spin the beacon
+        spinUpdate = millis();
+    }
+    if(HSVRing[0].value){
+        hsv2rgb_rainbow( HSVRing, ringLeds, RING_LEDS); // convert the HSV array to the RGB array (if the beacon is still lit)
+    }
+
+    FastLED.show(); //Light the beacon
+}
+
+
+/*
+__________________________Touch Functions__________________________
+*/

 void whileTouching() {
-
-	unsigned int colorIndex = 0; //Integer used to select applied color
+	uint8_t colorIndex = 0; //Integer used to select applied color
 	unsigned int satBright = 0; //The initial brightness and saturation of the lights
-	CHSV color = green; //The first color
+    CHSV color; //The resulting color
+
+    //Set the colors black
 	fill_solid(stripLeds, STRIP_LEDS, CRGB::Black);
 	fill_solid(ringLeds, RING_LEDS, CRGB::Black);

-    while (digitalRead(button) == HIGH) {
-
-		if(satBright > 250){
+    while (digitalRead(button) == HIGH) { //Loop that runs while the button is pressed
+        color = currentPalette[colorIndex % colors]; //The first color
+        //The saturation and value are equal and stepped
+        color.saturation = satBright;
+		color.value = satBright;
+
+		if(satBright > 250){ //If light hits the maximum, trip the ring animation and reset
 		    ringFill(color.hue);
 		    fill_solid(stripLeds, STRIP_LEDS, CRGB::Black);
 		    fill_solid(ringLeds, RING_LEDS, CRGB::Black);
 			satBright = 0;
 			colorIndex ++;
-			color = currentPalette[colorIndex % colors];
-
 			}

-		uint8_t pixelsLit = map(satBright,0,250,0,STRIP_LEDS);
+		uint8_t pixelsLit = map(satBright,0,245,0,STRIP_LEDS); //map the number of lit pixels in the base

-		for (int i = 0; i <= pixelsLit && i <= STRIP_LEDS;i++){
-			stripLeds[i] = color;
+		for (int i = 0; i <= pixelsLit && i <= STRIP_LEDS;i++){ //assign all the strip LED's
+			stripLeds[i] = color;
 			}

-
-		color.saturation = satBright;
-		color.value = satBright;
-		satBright += 15;
-		FastLED.show();
-		delay(60);
-		now = millis();
+		satBright += 5; //increment the saturation and brightness
+		FastLED.show(); //Light em up
+		delay(whileDelay); //wait
 	}
 	FastLED.show();
-	beaconColor = color;
-	fill_solid(stripLeds, STRIP_LEDS, CRGB::Black);
-	fill_solid(ringLeds, RING_LEDS, CRGB::Black);
-	sprintf(publishString, "%u:%u:%u",beaconColor.hue,beaconColor.saturation,beaconColor.value);
-    Spark.publish("Color: ",publishString);
-    lastTime = now;
-
-}
-
+	fill_solid(stripLeds, STRIP_LEDS, CRGB::Black); //black the strip again
+	fill_solid(stripLeds, baseLedsLit, baseColor); //write the relevant LEDs the base color
+	beaconColor = color; //assign the final color to beacon
+	beaconFill(color); //fill the beacon accordingly
+
+	char publishString [64];
+	sprintf(publishString, "%u~%u~%u",beaconColor.hue,beaconColor.saturation,beaconColor.value);
+    Spark.publish("Beacon Update", String(selfName) + "~" + publishString); //Publish the beacon color to the cloud
+}
+
+
+/*
+__________________________Color Functions__________________________
+*/

 void ringFill(int colorHue){ //This function lights up the beacon when the colors are maxed

     for(int i = 0; i <= 255; i++){
         fill_solid(ringLeds, RING_LEDS, CHSV(colorHue,255,i));
         FastLED.show();
-        delay(5);
-    }
-}
+        //delay(3);
+    }
+}
+
+void colorDecay(){
+    if(baseColor.value){ //test if the base is still lit
+        baseColor.value--; //cut the brightness
+    }
+    if(beaconColor.value){ //test if the beacon is still lit
+        beaconColor.value--; //decrement the inital beacon color brightness
+
+        //make the entire ring array as bright as the initial beacon color
+        for(int i = 0; i <RING_LEDS;i++){
+            HSVRing[i].value = beaconColor.value;
+        }
+
+    }
+    baseLedsLit = map(baseColor.value,0,255,2,STRIP_LEDS); // figure out how many base LEDs are lit
+    fill_solid(stripLeds, STRIP_LEDS, CRGB::Black); //turn the beacon black
+    fill_solid(stripLeds, baseLedsLit, baseColor); //write the relevant LEDs the color
+}
+
+void beaconFill(NSFastLED :: CHSV color){ //Fills the ring LED's with the HSV array made from the beacon color sent
+    fill_solid(HSVRing, RING_LEDS, color);
+    uint8_t hue = color.hue;
+    for (int i = 1; i < RING_LEDS/2; i++){ //this tweaks the hues around the ring
+        HSVRing[i].hue = hue+i;
+        HSVRing[RING_LEDS-i].hue = hue + i;
+    }
+}
+void beaconSpin(){
+    CHSV tempColor = HSVRing[0];
+    for(int i = 0; i < RING_LEDS-1; i++){
+        HSVRing[i] = HSVRing[i+1];
+    }
+    HSVRing[RING_LEDS-1] = tempColor;
+}
+
+/*
+__________________________Communication Functions__________________________
+*/
+
+void ColorUpdate(const char *name, const char *data) { //The function to received the base color from the cloud
+    uint8_t receivedHue;
+    uint8_t receivedSaturation;
+    uint8_t receivedValue;
+    String receivedID;
+    if (data) {
+        char input[64];
+        strcpy(input,data);
+        char *p;
+        receivedID = strtok(input,"~");
+        p = strtok(NULL,"~");
+        receivedHue = atoi(p);
+        p = strtok(NULL,"~");
+        receivedSaturation = atoi(p);
+        p = strtok(NULL,"~");
+        receivedValue = atoi(p);
+    }
+    // DEBUG
+    Particle.publish("Color_Recieved", selfName + "~" + receivedHue + "~" + receivedSaturation + "~" + receivedValue);
+    // END DEBUG
+    if(receivedID ==otherName ){
+        baseColor = CHSV(receivedHue, receivedSaturation, receivedValue);
+    }
+}


typo fix

typo fix


in progress

in progress

--- esp8266_dht22.ino
+++ esp8266_dht22.ino
@@ -2,11 +2,11 @@
 #include "DHT.h"

 //WiFi setup
-#define ssid       "nord"
-#define password   "asusn18urouter"
+#define ssid       "......."
+#define password   "......."

 //Thingspeak setup
-#define thingspeakApiKey "WCS2YMWLH97A4GOS"
+#define thingspeakApiKey "................"
 #define thingSpeakAddress "api.thingspeak.com"
 #define thingSpeakUpdateJsonEndpoint "/update.json"
 #define thingSpeakHttpPort 80


Changed too counter vs millis() for timing things.

--- Code/CounterCat/CounterCat.ino
+++ Code/CounterCat/CounterCat.ino
@@ -56,6 +56,7 @@
 #define ACTIVE_FLICKER 100
 #define COOLDOWN_FLICKER  200
 #define BUTTON_DEBOUNCE 500
+#define WARM_UP_PRINIT_RATE 100

 #define EYE_SCANNING_RATE 10

@@ -163,8 +164,9 @@
 ///LOOP/////////////////////////////////////////////////////////////////////////
 void loop(void)
 {
-  now = millis();
-
+  //now = millis();
+  now++;
+
   //Step the scanning eye.
   if (now % EYE_SCANNING_RATE == 0)
   {
@@ -220,7 +222,7 @@
   {

   case S_WARMING_UP:
-    if (now % 1000 == 0)
+    if (now % WARM_UP_PRINIT_RATE == 0)
     {
       Serial.println(String(now*100/WARM_UP_TIME_MS, DEC) + "%");
     }
@@ -344,7 +346,7 @@
     break;
   }

-  delay(1);
+ // delay(1);

 }


get rid of read thingspeak

get rid of read thingspeak

--- controlBox.ino
+++ controlBox.ino
@@ -3,9 +3,6 @@
 //################### update these vars ###################
 unsigned long myWriteChannelNumber = your channel number; // e.g 101223
 const char * myWriteAPIKey = "your write API key for the pump controller channel";
-// channel we're reading water height from
-unsigned long myReadChannelNumber = 101982; // e.g 101223
-const char * myReadAPIKey = "your read API key for the telemetry channel";
 //################### update these vars ###################
 TCPClient client;
 unsigned long lastMeasureTime = 0;


don't need legacy code in doc too

don't need legacy code in doc too

--- doc/LED_Power_Meter_EA_Display_v7.ino
+++ doc/LED_Power_Meter_EA_Display_v7.ino
@@ -1,880 +0,0 @@
-/********************************************************
- ******** LED Power Meter Display CODE ******************
- ******** by Matt Little ********************************
- ******** Date: 13/3/2017 *******************************
- ******** info@re-innovation.co.uk **********************
- ******** www.re-innovation.co.uk ***********************
- ********************************************************
-
-  See www.re-innovation.co.uk for information and
-  construction details
-
-  This is code for the Embedded Adventures LED display unit:
-  https://www.embeddedadventures.com/datasheets/PLT-1001_hw_v4_doc_v3.pdf
-
-  This unit takes values of Time and Power and displays
-  them on a large LED matrix Time Mode:
-  The data is sent "aXXT0001-----" where XX is aa reference
-  (does not matter which). The time is a three digit value of 100's
-  milli-seconds (eg 0.1, 1.2, 10.5 etc).
-  Want the display to take serial data and update the LED display
-  Want a display to show 3 - 2 - 1 GO then show
-
- *************** Details of Code ************************
-
-  The PCB/schematic files are available from: www.re-innovation.co.uk
-
-  This code is for an Arduino Nano
-
-  It reads serial data (on D0/D1, Tx/Rx).
-  It parses that data and displays the power on a large Embedded
-  Adventures serial LED display.
-
-  Display connections:
-  EA controller is on Tx = D12, Rx = D11
-
-  Serial Input is on Tx = D0, Rx = D1
-
-  Two switches are included on D5 and D9
-
-  Power data is read on the serial port at 115200 baud
-
-  **** Protocol for straming data to serial ****
-
-  There are a number of functions which can be adjusted via software
-  commands. The main protocol is based upon LLAP (Lightweight Local
-  Automation Protocol), with some additional features.
-
-  http://openmicros.org/index.php/articles/85-llap-lightweight-local-automation-protocol/101-llap-starter
-
-  This uses a 12 character message in the format:
-  “aXXDDDDDDDDD”
-  Where a is the start signifier and XX is the device ID, from AA to ZZ.
-  Everything else is in upper case.
-
-  Commands this unit can process:
-  Change device ID
-  “aXXCHID??---“
-  Where the XX is the old ID and ?? is the new ID. This is stored to EEPROM
-
-  Power
-  “aXXPDDDDD---“
-  This is the power output (0000.0W to 9999.9W). This will be an output approximately every second.
-
-  Voltage and Current
-  “aXXVDDDIDDDD“
-  This is the voltage and current output (V is 00.0 to 99.9V DC) (I is 00.00A to 99.99A). This will be an output approximately every second.
-
-  Maximum graph power
-  “aXXMGP????--“
-  This is for adjusting the display bar graph height to show the max power displayed:
-  Max power value = 32 LEDs lit up in a column. Where ???? is the power in watts.
-  This is stored to EEPROM. Device ID does not matter
-
-  Count Down
-  "aXXCD?------"
-  Where ? can be 0,1,2,3.
-  If 3: Show a big 3
-  If 2: Show a big 2
-  If 1: Show a big 1
-  if 0: Show a big "GO!" Text
-  Device ID does not matter
-
-  Timer
-  "aXXT????----"
-  Where ???? is the time in 100's millis second (0.1 seconds)
-  Device ID does not matter
-
-  Winner
-  "aXXW?-------"
-  Where ? is a number from 1 to 9. This will display "WINNER:" and The player number below
-  This should flash to highlight
-  Device ID does not matter.
-
-  Clear
-  "aXXCL-------"
-  This will clear the display
-
-  Updates:
-  06/06/2016 Code started - Matt Little
-  13/3/2017 update of code for timer - Matt Little
-  16/3/2017 Added new functions for game style unit - Matt Little
-
-**********************************************************************************************************/
-/************ External Libraries*****************************/
-
-#include <stdlib.h>
-#include <avr/pgmspace.h>  // Library for putting data into program memory
-#include <EEPROM.h>        // For writing values to the EEPROM
-#include <avr/eeprom.h>    // For writing values to EEPROM
-#include <SoftwareSerial.h>
-
-/************User variables and hardware allocation**********************************************/
-
-// ********** Hardware information********************************************
-// These constants won't change.  They're used to give names to the pins used:
-// Set up the software serial line to put data to the display
-SoftwareSerial mySerial(12, 11); // RX, TX
-
-//*********END of hardware information****************************************
-
-// Useful variables
-char deviceID[3]; // A buffer to hold the device ID
-
-unsigned int graphDisplay[64];  // A buffer to hold the graphical bar graph display
-int maxGraphPower;  // Power in Watts which is max power to display (=16 on output)
-String maxGraphPowerStr;
-
-String outputString;    // This is the holder for the data as a string. Start as blank
-
-// ****** Serial Data Read***********
-// Variables for the serial data read
-char inByte;         // incoming serial char
-String str_buffer = "";  // This is the holder for the string which we will display
-#define MAX_STRING 25     // Sets the maximum length of string probably could be lower
-char stringBuffer[MAX_STRING];  // A buffer to hold the string when pulled from program memory
-
-// Varibales for writing to EEPROM
-int hiByte;      // These are used to store longer variables into EERPRPROM
-int loByte;
-long int number;
-
-int averagecounter = 1000;  // The number of samples to average over
-int displaycounter = 20;   // When to update the display
-int displaycountermax = 20;  // This is when to display the data ( x 10mS)
-
-long int oldTime = 0;  // This is for outputting the data every 1S or so
-
-int averageCounter = 100;  // This counts the number of times an average has been taken.
-unsigned long int time = 0;  // This holds the averaging
-
-int displayOffset = 0;  // This is for putting the power data in the middle of the display.
-
-// Commands for writing to serial port (put into const to save RAM)
-
-int powerAve = 0;  // DC power in
-String powerAveStr; // Holds the power value as a string
-
-int timeValue = 0;  // Holds the time in 100's milliseconds. Aldo holds the Count Down value
-String timeValueStr;
-
-int displayMode = 1; // Display Mode 0: Power, 1: Time
-
-const String hello = "HELLO";
-const String paint = "paint\r";
-const String clearLED = "clear\r";
-
-
-boolean checkStringOK(String dataString)
-{
-  boolean fail = true; // Holds the check
-  // Check the string is all numbers, not characters
-  for (int n = 0; n < dataString.length(); n++)
-  {
-    if (isDigit(dataString[n]) == false)
-    {
-      fail = false;
-    }
-  }
-
-  return (fail);
-}
-
-
-//****************INITIALISE ROUTINE******************************
-void setup()
-{
-  Serial.begin(115200);    // Set up a serial output for data display and changing parameters
-
-  Serial.flush();
-
-  // set the data rate for the SoftwareSerial port
-  mySerial.begin(115200);
-
-  // Read in the values from EEPROM
-  // Read the device ID
-  deviceID[0] = char(EEPROM.read(0));
-  deviceID[1] = char(EEPROM.read(1));
-  Serial.print("Device ID is: ");
-  Serial.print(deviceID[0]);
-  Serial.println(deviceID[1]);
-
-  // Read in the max Graph Power
-  hiByte = EEPROM.read(9);
-  loByte = EEPROM.read(10);
-  maxGraphPower = (hiByte << 8) + loByte;
-  Serial.print("Max Graph Power: ");
-  Serial.println(maxGraphPower);
-
-  for (int z = 0; z < 64; z++)
-  {
-    // Ensure the graphDisplay buffer is clear
-    graphDisplay[z] = 0;
-  }
-
-  // Clear the display
-  mySerial.print(clearLED);
-  // Draw a big "GO!" in centre
-  mySerial.print("font 6\r");
-  mySerial.print("text 2 3 24 ");
-  mySerial.print('"');
-  mySerial.print(hello);
-  mySerial.print('"');
-  mySerial.print("\r");
-  // Then we display it all
-  mySerial.print(paint);
-  delay(500); // Show this message for a little bit at least
-
-}
-
-void loop()
-{
-  // This is the main loop.
-
-  //*********Here we check to see if any serial data has been seen***********
-  getData();  // Check the serial port for data
-
-  //Decide which mode depending up Time or Power data being sent
-  switch (displayMode)
-  {
-    case 0:
-      // ********** POWER MODE *********************************
-      // ***********Display data********************************
-      // Here we keep a count of the milliseconds
-      // If more than 1000mS has passed then update the display
-      // Output data on serial:
-      if ((millis()) >= (oldTime + 1000))
-      {
-        oldTime = millis();  // Save the time ready for the next output display
-        // We enter this point every 1000mS (approx, it might be out by a bit (+/-5mS))
-
-        // Sort out the graphDisplay with the power values
-        // First move all the power values along
-        // Then fit the new powerAve into the buffer
-        for (int z = 1; z < 64; z++)
-        {
-          // Shift all the graph display values along
-          graphDisplay[z - 1] = graphDisplay[z];
-        }
-        graphDisplay[63] = powerAve;
-
-        // Output things to the Embedded Adventures display unit (serial)
-        // More info can be found here: http://www.embeddedadventures.com/datasheets/PLT-1001_hw_v4_doc_v3.pdf
-
-        // Here we calculate the offset for the power text so that it stays to one side
-        // The display is 64 px wide.
-        // Each number is 10+1(space) px wide
-        // So if power is 0-9W, Offset is 38
-        // So if power is 10-99W, Offset is 27
-        // So if power is 100-999W, Offset is 16
-        // So if power is 1000-9999W, Offset is 5
-
-        if (powerAve >= 0 && powerAve < 10)
-        {
-          displayOffset = 38;
-        }
-        else if (powerAve >= 10 && powerAve < 20)
-        {
-          displayOffset = 29;
-        }
-        else if (powerAve >= 20 && powerAve < 100)
-        {
-          displayOffset = 27;
-        }
-        else if (powerAve >= 100 && powerAve < 200)
-        {
-          displayOffset = 18;
-        }
-        else if (powerAve >= 200 && powerAve < 1000)
-        {
-          displayOffset = 16;
-        }
-        else if (powerAve >= 1000 && powerAve < 2000)
-        {
-          displayOffset = 7;
-        }
-        else if (powerAve >= 2000 && powerAve < 10000)
-        {
-          displayOffset = 5;
-        }
-
-        // Clear the LED display (just in case)
-        mySerial.print(clearLED);
-        mySerial.print("font 5\r");
-
-        // Then also want to display a scrolling bar graph of power along the bottom
-        // This takes the values in graphDisplay and creates a line from 0 to value all along the bottom
-
-        // To draw a line we need to write the command:
-        //  "line colour x1 y1 x2 y2" for every data point
-
-        // Power values is converted into a graph.
-        // The power value is also displayed on top of the graph.
-
-        for (int y = 0; y < 64; y++)
-        {
-          if (graphDisplay[y] > 0)
-          {
-            mySerial.print("line 1 ");
-            mySerial.print(y);
-            mySerial.print(" 31 ");
-            //mySerial.print(graphDisplay[y]);
-            mySerial.print(y);
-            mySerial.print(' ');
-            // This is where we draw the bar graph section:
-            // We have maxGraphPower = 32 LEDs lit.
-            // So to convert from power reading to LEDs to light we use the calculation:
-            // (power now / maxGraphPower) *32
-            int LEDtoLight = (((float)graphDisplay[y] / (float)maxGraphPower) * 32);
-            mySerial.print(31 - LEDtoLight);
-            mySerial.print('\r');
-            mySerial.print('\r');
-          }
-        }
-
-        mySerial.print("text 2 ");
-        mySerial.print(displayOffset);  // This ensure the numbers are in the middle of the display
-        mySerial.print(" 23 ");
-        mySerial.print('"');
-        // Want to display the power here:
-        mySerial.print(powerAve);
-        mySerial.print('w');
-        mySerial.print('"');
-        mySerial.print('\r');
-        delay(2);
-        // Then we display it all
-        mySerial.print(paint);
-      }
-      break;
-
-    case 1:
-      // *********** TIME MODE *********************************
-      // In this mode we have the following commands:
-      // aXXCD?--------
-      // Where ? = 3,2,1,0 if ? = 0 then we show GO!
-
-      // Nothing really needs to happen here
-
-      break;
-
-    default:
-      Serial.println("Bad display mode"); // Error
-      break;
-
-  }
-
-  delay(30);   // Short pause to stop everything running too quick
-}
-
-
-// This routine pulls the string stored in program memory so we can use it
-// It is temporaily stored in the stringBuffer
-char* getString(const char* str) {
-  strcpy_P(stringBuffer, (char*)str);
-  return stringBuffer;
-}
-
-// **********************GET DATA SUBROUTINE*****************************************
-// This sub-routine picks up and serial string sent to the device and sorts out a power string if there is one
-// All values are global, hence nothing is sent/returned
-
-void getData()
-{
-  // **********GET DATA*******************************************
-  // We want to find the bit of interesting data in the serial data stream
-  // As mentioned above, we are using LLAP for the data.
-  // All the data arrives as serial commands via the serial interface.
-  // All data is in format aXXDDDDDDDDD where XX is the device ID
-  while(Serial.available())
-  {
-    inByte = (char)Serial.read(); // Read whatever is happening on the serial port
-    str_buffer += inByte;
-    if((inByte=='-')||(inByte=='\r')||(inByte=='\n'))
-    {
-      break;
-    }
-  }
-  if(str_buffer[0]=='a'&&((str_buffer[str_buffer.length()-1]=='-')||(str_buffer[str_buffer.length()-1]=='\r')||(str_buffer[str_buffer.length()-1]=='\n')))
-  {
-    Serial.println(str_buffer);  // TEST - print the str_buffer data (if it has arrived)
-    sortData();
-    str_buffer = ""; // Reset the buffer to be filled again
-  }
-  else
-  {
-    str_buffer = ""; // Reset the buffer to be filled again
-    //Serial.println("Not OK");
-  }
-}
-
-// **********************SORT DATA SUBROUTINE*****************************************
-// This sub-routine takes the read-in data string (12 char, starting with a) and does what is required with it
-// The str-buffer is global so we do not need to send it to the routine
-
-void sortData()
-{
-  // We first want to check if the device ID matches.
-  // If it does not then we disregard the command (as it was not meant for this device
-  if (str_buffer.substring(1, 3) == deviceID)
-  {
-    // If yes then we can do further checks on ths data
-    // This is where we do all of the checks on the incomming serial command:
-
-    //Serial.println("ID OK");  // TEST - got into this routine
-
-    // Change device ID:
-    // Device ID
-    // “aXXCHIDXXE--“
-    // Where the last two values (XX) are the new device ID (from AA to ZZ).
-    if (str_buffer.substring(3, 7) == "CHID")
-    {
-      // First check if the NEW device ID is within the allowable range (AA-ZZ)
-      // to do this we can convert to an int and check if it is within the OK levels
-      // A -> int is 65, Z -. int is 90
-      // So our new device ID as an int must be between 65 and 90 for it to be valid
-      if (65 <= int(str_buffer[7]) && int(str_buffer[7]) <= 90 && 65 <= int(str_buffer[8]) && int(str_buffer[8]) <= 90)
-      { // If is all OK then write the data
-        // Change device ID
-        Serial.print("CHID: ");
-        Serial.println(str_buffer.substring(7, 9)); // This will change the device ID
-        deviceID[0] = str_buffer[7];
-        deviceID[1] = str_buffer[8];
-        // Also want to store this into EEPROM
-        EEPROM.write(0, deviceID[0]);    // Do this seperately
-        EEPROM.write(1, deviceID[1]);
-      }
-      else
-      {
-        Serial.println("Invalid ID");
-      }
-    }
-  }
-
-
-  //  Power Value
-  //  “aXXP????-“
-  //  Where the value ???? is the power in Watts
-  if (str_buffer.substring(3, 4) == "P")
-  {
-    // Update the power value if its valid
-    powerAveStr = str_buffer.substring(4, 8);
-
-    if (checkStringOK(powerAveStr) == true)
-    {
-      powerAve = powerAveStr.toInt();
-      displayMode = 0;  // Display mode 0: Power 1: Time
-    }
-    else
-    {
-      Serial.println("Invalid P");
-    }
-  }
-
-  //  Timer
-  //  “aXXT????-“
-  //  Where the value ???? is the time in 100's milliseconds
-  else if (str_buffer.substring(3, 4) == "T")
-  {
-    // Update the Timer Value
-    timeValueStr = str_buffer.substring(4, 8);
-    if (checkStringOK(timeValueStr) == true)
-    {
-      timeValue = timeValueStr.toInt();
-      displayMode = 1;  // Display mode 0: Power 1: Time
-      displayTime(timeValueStr, 11, 24, 1);  // display the time depending upon the string
-    }
-    else
-    {
-      Serial.println("Invalid T");
-    }
-  }
-
-  //  Count Down
-  //  “aXXCD?------“
-  //  Where the value ? is 3,2,1,0 and 0 will show "GO1"
-  else if (str_buffer.substring(3, 5) == "CD")
-  {
-    // Show the count down
-
-    timeValueStr = str_buffer.substring(5, 6);
-
-    if (checkStringOK(timeValueStr))
-    {
-      timeValue = timeValueStr.toInt();
-
-      displayMode = 1;  // Display mode 0: Power 1: Time
-      //Clear the display
-      mySerial.print(clearLED);
-      delay(2);
-      // Then we display it all
-      mySerial.print(paint);
-      delay(2);
-      // Set the font size
-      mySerial.print("font 6\r");
-      switch (timeValue)
-      {
-        case 0:
-          // Draw a big GO! in the screen
-          for (int j = 1; j < 16; j++)
-          {
-            displayRectangleColour(2, j);
-            delay(2);
-
-            // Then we display it all
-            mySerial.print(paint);
-            delay(5);
-          }
-          // Draw a big "GO!" in centre
-          mySerial.print("text 1 18 24 ");
-          mySerial.print('"');
-          mySerial.print("GO!");
-          mySerial.print('"');
-          mySerial.print("\r");
-          delay(2);
-          mySerial.print(paint);
-          break;
-
-        case 1:
-          // Draw a big "1" in centre
-          for (int j = 1; j < 16; j++)
-          {
-            displayRectangleColour(1, j);
-            delay(2);
-            // Then we display it all
-            mySerial.print(paint);
-            delay(5);
-          }
-          mySerial.print("text 2 27 24 ");
-          mySerial.print('"');
-          mySerial.print("1");
-          mySerial.print('"');
-          mySerial.print("\r");
-          // Then we display it all
-          mySerial.print(paint);
-
-          break;
-
-        case 2:
-          for (int j = 1; j < 16; j++)
-          {
-            displayRectangleColour(2, j);
-            delay(2);
-            // Then we display it all
-            mySerial.print(paint);
-            delay(5);
-          }
-          mySerial.print("text 1 27 24 ");
-          mySerial.print('"');
-          mySerial.print("2");
-          mySerial.print('"');
-          mySerial.print("\r");
-          // Then we display it all
-          mySerial.print(paint);
-          break;
-
-        case 3:
-          for (int j = 1; j < 16; j++)
-          {
-            displayRectangleColour(1, j);
-            delay(2);
-            // Then we display it all
-            mySerial.print(paint);
-            delay(5);
-          }
-          // Draw a big "3" in centre
-          mySerial.print("text 2 27 24 ");
-          mySerial.print('"');
-          mySerial.print("3");
-          mySerial.print('"');
-          mySerial.print("\r");
-          // Then we display it all
-          mySerial.print(paint);
-          break;
-        default:
-          // Do nothing
-          break;
-      }
-    }
-  }
-
- //  Winner
-  //  “aXXWN?------“
-  //  Where the value ? is 0 to 9 and will show "Winner!" then the team that won
-  else if (str_buffer.substring(3, 5) == "WN")
-  {
-    // Show the winner
-    // This will do a faded full background
-    // then show the winner on the screen
-    timeValueStr = str_buffer.substring(5, 6);
-    if (checkStringOK(timeValueStr))
-    {
-      displayMode = 1;  // Display mode 0: Power 1: Time
-      timeValue = timeValueStr.toInt();
-
-      mySerial.print(clearLED);
-      delay(2);
-
-      // Want to display text "WINNER:"
-      // Set the font size
-      mySerial.print("font 4\r");
-
-      // Then Display the number of the winner
-      mySerial.print("text 1 15 7 ");
-      mySerial.print('"');
-      mySerial.print("WINNER:");
-      mySerial.print('"');
-      mySerial.print("\r");
-
-
-      // Set the font size
-      mySerial.print("font 6\r");
-
-      if(timeValue==0)
-      {
-        // This is a tie
-        mySerial.print("text 3 16 28 ");
-        mySerial.print('"');
-        mySerial.print("TIE");
-        mySerial.print('"');
-        mySerial.print("\r");
-      }
-      else
-      {
-        // Then Display the number of the winner
-        mySerial.print("text 3 27 28 ");
-        mySerial.print('"');
-        mySerial.print(timeValue);
-        mySerial.print('"');
-        mySerial.print("\r");
-      }
-      // Then we display it all
-      mySerial.print(paint);
-    }
-  }
-
-  //  Clear
-  //  “aXXWN?------“
-  //  This clears the display
-  else if (str_buffer.substring(3, 5) == "CL")
-  {
-    mySerial.print(clearLED);
-    delay(2);
-    mySerial.print(paint);
-  }
-
-  //  String
-  //  “aXXST------------“
-  //  This daw a string on the display
-  else if (str_buffer.substring(3, 5) == "ST")
-  {
-    mySerial.print(clearLED);
-    delay(2);
-    // Set the font size
-    mySerial.print("font 2\r");
-    timeValueStr = str_buffer.substring(5, (str_buffer.length()-1));
-    mySerial.print("text 3 0 16 ");
-    mySerial.print('"');
-    mySerial.print(timeValueStr);
-    mySerial.print('"');
-    mySerial.print("\r");
-    mySerial.print(paint);
-  }
-
-
-  //  Maximum Graph Power
-  //  To change this we use the command:
-  //  “aXXMGPDDDD--“
-  //  Where the value DDDD is the maximum graph power in watts
-  // This corresponds to 32 red LEDs being lit.
-  else if (str_buffer.substring(3, 6) == "MGP")
-  {
-    maxGraphPowerStr = str_buffer.substring(6, 10);
-    maxGraphPower = maxGraphPowerStr.toInt();
-    // DO NOT CHANGE if outside of max/min values or rubbish data
-    if (maxGraphPower >= 0 && maxGraphPower <= 3000)
-    {
-      // Change max Graph Power
-      Serial.print("MGP: ");
-      Serial.println(maxGraphPower);
-
-      // Also want to store this into EEPOM
-      EEPROM.write(9, maxGraphPower >> 8);    // Do this seperately
-      EEPROM.write(10, maxGraphPower & 0xff);
-    }
-    else
-    {
-      Serial.println("Invalid MGP");
-    }
-  }
-}
-
-void displayTime(String data, int startx, int starty, int timerColour)
-{
-  // This displays the time onto the LED
-  // Start position startx and starty
-  // Timer colour 1= red, 2 = green, 3 = orange
-  int timeValueInt;
-  int timeValueDec;
-  int startXOffset=0;
-
-  timeValue = timeValueStr.toInt();
-  timeValueInt=timeValue / 10;  // Find pre decimal point
-  timeValueDec = timeValue % 10; // find post decimal point
-
-  // Use font style 5 - all except 1's are 10 wide , 1s are 8 wide
-
-  //Clear the display
-  mySerial.print(clearLED);
-  // Set the font size
-  mySerial.print("font 5\r");
-
-  // Serach through timeValueInt to see how many 1's are in the number
-  int numberOfOnes = 0;
-  for(int y=0;y<(timeValueStr.length()-1);y++)
-  {
-    if(timeValueStr[y]=='1')
-    {
-      numberOfOnes++;
-    }
-  }
-
-  if (timeValueInt < 10)
-  {
-    if (timeValueInt == 0)
-    {
-      // Plot starting at corect value
-      mySerial.print("text ");
-      mySerial.print(timerColour);
-      mySerial.print(' ');
-      mySerial.print(startx + 22);
-      mySerial.print(' ');
-      mySerial.print(starty);
-      mySerial.print(' ');
-      mySerial.print('"');
-      mySerial.print('0');
-      mySerial.print('"');
-      mySerial.print("\r");
-    }
-    else
-    {
-      // Plot starting at corect value
-      mySerial.print("text ");
-      mySerial.print(timerColour);
-      mySerial.print(' ');
-      mySerial.print(startx + 22 + (numberOfOnes*2));
-      mySerial.print(' ');
-      mySerial.print(starty);
-      mySerial.print(' ');
-      mySerial.print('"');
-      mySerial.print(timeValueInt);
-      mySerial.print('"');
-      mySerial.print("\r");
-    }
-  }
-  else if (timeValueInt < 100)
-  {
-    // Plot starting at corect value
-    mySerial.print("text ");
-    mySerial.print(timerColour);
-    mySerial.print(' ');
-    mySerial.print(startx + 11+(numberOfOnes*2));
-    mySerial.print(' ');
-    mySerial.print(starty);
-    mySerial.print(' ');
-    mySerial.print('"');
-    mySerial.print(timeValueInt);
-    mySerial.print('"');
-    mySerial.print("\r");
-
-  }
-  else if (timeValueInt < 1000)
-  {
-    mySerial.print("text ");
-    mySerial.print(timerColour);
-    mySerial.print(' ');
-    mySerial.print(startx + (numberOfOnes*2));
-    mySerial.print(' ');
-    mySerial.print(starty);
-    mySerial.print(' ');
-    mySerial.print('"');
-    mySerial.print(timeValueInt);
-    mySerial.print('"');
-    mySerial.print("\r");
-  }
-
-  // Plot the dot
-  mySerial.print("text ");
-  mySerial.print(timerColour);
-  mySerial.print(' ');
-  mySerial.print(startx + 33);
-  mySerial.print(' ');
-  mySerial.print(starty);
-  mySerial.print(' ');
-  mySerial.print('"');
-  mySerial.print('.');
-  mySerial.print('"');
-  mySerial.print("\r");
-
-
-  // Plot starting at corect value
-  mySerial.print("text ");
-  mySerial.print(timerColour);
-  mySerial.print(' ');
-  mySerial.print(startx + 36);
-  mySerial.print(' ');
-  mySerial.print(starty);
-  mySerial.print(' ');
-  mySerial.print('"');
-  mySerial.print(timeValueDec);
-  mySerial.print('"');
-  mySerial.print("\r");
-
-  // Then we display it all
-  mySerial.print(paint);
-}
-
-void displayBlockColour(int blockColour)
-{
-  // This routine fills the background with a single colour
-
-  for (int i = 0; i < 32; i++)
-  {
-    mySerial.print("line ");
-    mySerial.print(blockColour);
-    mySerial.print(" 0 ");
-    mySerial.print(i);
-    mySerial.print(" 64 ");
-    mySerial.print(i);
-    mySerial.print("\r");
-  }
-
-}
-
-void displayRectangleColour(int rectColour, int n)
-{
-  // This routine adds rectanlge with colour rectColour at position n
-  // n will be from 0 to 15
-
-  int sizeDisplayx = 64;
-  int sizeDisplayy = 32;
-
-  // Code: rect colour x y width height
-  // x = (sizeDisplayx/2)-((n-1)*2)
-  // y = (sizeDisplayy/2)+n)
-  // width = n*4
-  // height = n*2
-
-  mySerial.print("rect ");
-  mySerial.print(rectColour);
-  mySerial.print(' ');
-  mySerial.print(((sizeDisplayx / 2) - 2) - ((n - 1) * 2)); // x position for start
-  mySerial.print(' ');
-  mySerial.print(((sizeDisplayy / 2) - 1) + n); // y position for start
-  mySerial.print(' ');
-  mySerial.print(n * 4); // width
-  mySerial.print(' ');
-  mySerial.print(n * 2); // height
-  mySerial.print("\r");
-
-}
-


Update ADXL345_demo_code.ino

Update ADXL345_demo_code.ino

--- examples/ADXL345_demo_code/ADXL345_demo_code.ino
+++ examples/ADXL345_demo_code/ADXL345_demo_code.ino
@@ -106,7 +106,7 @@
 	Serial.print(ay);
     Serial.println(" g");
 	Serial.print("Z=");
-	Serial.println(az);
+	Serial.print(az);
     Serial.println(" g");
 	Serial.println("**********************");
 	delay(500);


Replaced tabs with spaces

Replaced tabs with spaces

--- examples/SimpleThermometer/SimpleThermometer.ino
+++ examples/SimpleThermometer/SimpleThermometer.ino
@@ -18,8 +18,8 @@
   Serial.println("");

   // Initialize the thermocouple
-	// The CS pin can be passed as a parameter if different than pin D8,
-	//  e.g. thermocouple.begin(7)
+  // The CS pin can be passed as a parameter if different than pin D8,
+  //  e.g. thermocouple.begin(7)
   thermocouple.begin();
 }


Alpha release

Alpha release

Is this what you a were looking for jcw?

--- examples/RF12/RF12tune3/RF12tune3.ino
+++ examples/RF12/RF12tune3/RF12tune3.ino
@@ -7,7 +7,7 @@
 /// 2013-10-04 <john<AT>o-hare<DOT>net> http://opensource.org/licenses/mit-license.php
 ////
 const char NodeConfiguration[] PROGMEM =
-   "1640o 8b 209g 9i Harvington";
+   "1640o 8b 209g 9i Harvington Node";
 ////0....5....10...5....20...5....30...5....40...5....50...5....60..

 /// Recommended fuse settings:
@@ -75,9 +75,9 @@
 #define SERIAL_BAUD 57600
 #endif

-byte h, w, command, loc = 0;
+byte h, w, command, enough = 0, loc = 0;
 unsigned int value = 0;
-boolean enough = 0;
+byte parameters = 0;

 void setup() {
 #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
@@ -89,20 +89,19 @@
 #else
   Serial.begin(SERIAL_BAUD);
 #endif
+  showString(PSTR("\n[RF12tune3.0]\n"));
   delay(5000);  // Startup delay to debounce disconnection
-  showString(PSTR("\n[RF12tune3.0]\n"));
   while (!enough) {
     command = getCmd();
-Serial.print(value);
-Serial.println(char(command));
     switch (command) {
       default:
       for (byte i = 0; i < sizeof config.msg; i++ ) {
         config.msg[i] = getString(NodeConfiguration, (loc + i));
-        if (config.msg[i] == 0) {
-         break;
-        }
-        enough = 1;
+        if (config.msg[i] == 0) {    // End of string?
+          parameters = parameters | 0x01;
+          enough = 1;
+          break;
+        }
       }
       break;
       case 'b': // set band: 4 = 433, 8 = 868, 9 = 915
@@ -110,37 +109,59 @@
       if (value) {
         config.nodeId = (value << 6) + (config.nodeId & 0x3F);
       }
+      parameters = parameters | 0x02;
       break;
       case 'g': // set network group
       config.group = value;
+      parameters = parameters | 0x04;
       break;
       case 'i': // set node id
-        if ((value > 0) & (value < 32)) {
-          config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F);
-        }
+      if ((value > 0) & (value < 32)) {
+        config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F);
+      }
+      parameters = parameters | 0x08;
       break;
       case 'o': // Set frequency offset within band
       if ((value > (96 + SCAN_WIDTH )) && (value < (3903 - SCAN_WIDTH))) {  // 96 - 3903 is the range of values supported by the RFM12B
          frequency_offset = value;
       }
+      parameters = parameters | 0x10;
+      break;
     }
     loc++;
-}
-Serial.println(config.group);
-Serial.println(config.nodeId);
-//Serial.println(config.nodeId);
-Serial.println(frequency_offset);
-delay(32767);
-    /////
+  }
+
+  if (parameters != 0x1F) {
+    showString(PSTR("Insufficient parameters 0x"));
+    showNibble(0x1F - parameters >> 4);
+    showNibble(0x1F - parameters);
+#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
+    mySerial.println();
+    mySerial.println(config.group);
+    mySerial.println(config.nodeId);
+    mySerial.println(frequency_offset);
+#else
+    Serial.println();
+    Serial.println(config.group);
+    Serial.println(config.nodeId);
+    Serial.println(frequency_offset);
+#endif
+    while(1) // Nothing more
+    {
+      delay(32767);
+    }
+  }
+
   setEEProm();
 }

 static byte getCmd() {
   value = 0;
-  for (byte i = 0; i < 5; ++i ) {
+  for (byte i = 0;; ++i ) {
     char c = getString(NodeConfiguration, (loc + i));
-    if (c != 32) {
-      if ((c < 48) || (c > 57)) {  // 0 - 9
+    if (c == 0) enough = 1;         // Null, premature end of string
+    if (c != 32) {                  // Space
+      if ((c < 48) || (c > 57)) {   // 0 - 9
         loc = loc + i;
         return c;
       }
@@ -163,7 +184,7 @@
   mySerial.println(SCAN_WIDTH);
 #else
   Serial.print(frequency_offset);
-  showString(PSTR("+/-"));
+  showString(PSTR(" +/- "));
   Serial.println(SCAN_WIDTH);
 #endif
   delay(50);


Testing

Testing

--- module/module.ino
+++ module/module.ino
@@ -292,9 +292,11 @@
 	unsigned int sum = periodX + periodY;

 	if (0 < sum && sum <= maximumValue) {
+		delay(debounce);
 		return 1;
 	}
 	else {
+		delay(debounce);
 		return 0;
 	}
 }


House code

House code

--- walterHouse/walterHouse.ino
+++ walterHouse/walterHouse.ino
@@ -33,6 +33,7 @@
   HTTPClient http;
  http.begin("http://arduinoday.azurewebsites.net/");
   Serial.println(http.GET());
+  pinMode(0,OUTPUT);
 }

 void loop() {
@@ -40,7 +41,7 @@

     HTTPClient http;  //Declare an object of class HTTPClient

-    http.begin("http://arduinoday.azurewebsites.net/data.txt");  //Specify request destination
+    http.begin("http://arduinoday.azurewebsites.net/lights.txt");  //Specify request destination
     int httpCode = http.GET();                                                                  //Send the request

     if (httpCode > 0) { //Check the returning code
@@ -48,18 +49,24 @@
       String payload = http.getString();   //Get the request response payload
       Serial.println(payload);                     //Print the response payload
       if(payload.length()>0){
-                  boundLow = payload.indexOf(':');
+                  boundLow = payload.indexOf(',');
                   index2 = payload.substring(0, boundLow).toInt();
                   boundHigh = payload.indexOf(delimiter, boundLow+1);
                   dir = payload.substring(boundLow+1, boundHigh).toInt();
                   boundLow = payload.indexOf(delimiter, boundHigh+1);
                   msec = payload.substring(boundHigh+1, boundLow).toInt();
+                  Serial.println(index2);
+      if(index2==16){
+        digitalWrite(0,HIGH);
+        delay(1000);
+        digitalWrite(0,LOW);
+      }
                   }
                   Serial.printf("index: %d, dir: %d time%d",index2,dir,msec);
     }

     http.end();   //Close connection
-
+
   }
-  delay(15000);
+  delay(1000);
 }


Remove the click

Remove the click

--- nuncha/nuncha.ino
+++ nuncha/nuncha.ino
@@ -161,12 +161,12 @@
      aSin1.setFreq((int)pitch);
      if (rollLeft > rollRight )
      {
-       aRight1.setFreq(0);
+       aRight1.setFreq( rollLeft );
        aLeft1.setFreq( rollLeft );
      }
      else
      {
-       aLeft1.setFreq(0);
+       aLeft1.setFreq( rollRight );
        aRight1.setFreq( rollRight );
      }


[Bug] IRMQTTServer: Fix sending >64 bit codes. (#811)

* Off by one error in string pointer.

Fixes #810

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -2383,7 +2383,7 @@
           // send received MQTT value by IR signal
           lastSendSucceeded = sendIRCode(
               IrSendTable[channel], ir_type, code,
-              strchr(sequence_item, kCommandDelimiter[0]), nbits, repeat);
+              strchr(sequence_item, kCommandDelimiter[0]) + 1, nbits, repeat);
         }
     }
     free(ircommand);


Add serial offset calibration

Add serial offset calibration

--- tpsu1.ino
+++ tpsu1.ino
@@ -5,7 +5,7 @@
 // Reference voltage measured from device
 #define Vref 4881
 // Vsense1 ratio
-#define VDRP 4925
+#define VDRP 4950

 #define DAC_P 9
 #define DAC_N 7
@@ -50,8 +50,11 @@
 long vSenseN = 0;
 long aSenseN = 0;

+int offsetP = 320;
+int offsetN = 200;
+
 unsigned long previousMillis = 0;
-const long interval = 200;
+const long interval = 10;

 DAC_MCP49xx PosDac(DAC_MCP49xx::MCP4921, DAC_P);
 DAC_MCP49xx NegDac(DAC_MCP49xx::MCP4921, DAC_N);
@@ -63,6 +66,17 @@
   } else {
     return 0;
   }
+}
+
+void EEPROMWriteInt(int addr, int p_value) {
+  EEPROM.write(addr, ((p_value >> 0) & 0xFF));
+  EEPROM.write(addr + 1, ((p_value >> 8) & 0xFF));
+}
+
+unsigned int EEPROMReadInt(int addr) {
+  byte lowByte = EEPROM.read(addr);
+  byte highByte = EEPROM.read(addr + 1);
+  return ((lowByte << 0) & 0xFF) + ((highByte << 8) & 0xFF00);
 }

 void readEEPROM() {
@@ -80,6 +94,8 @@
   digitalWrite(AC_3, stateAC3);
   stateAC4 = readAddress(6);
   digitalWrite(AC_4, stateAC4);
+  offsetP = EEPROMReadInt(7);
+  offsetN = EEPROMReadInt(9);
 }

 void writeEEPROM() {
@@ -170,6 +186,12 @@
 void setV_N(int param) {
   // Set negative voltage
   setVN = param;
+  dacValN = (4095.0/20000.0)*-1*setVN;
+  NegDac.output(dacValN);
+  delay(5); // Wait for DAC to settle a bit
+  updateReadings();
+  // Allow recalibration
+  vlockN = false;
   Serial.println("ACK");
 }

@@ -242,18 +264,38 @@
         case 20:
           // Diagnostic function - set DAC1
           PosDac.output(param);
-          break;
+          Serial.println("ACK");
+          break;
+
         case 21:
           // Diagnostic function - set DAC2
           NegDac.output(param);
-          break;
+          Serial.println("ACK");
+          break;
+
         case 22:
           // Diagnostic function - raw ADC voltages
-          int vsp = analogReadV(10, Vsense_P);
-          int vsn = analogReadV(10, Vsense_N);
-          int asp = analogReadV(10, Asense_P);
-          int asn = analogReadV(10, Asense_N);
-          Serial.println(String("ADC:") + vsp + ", " + vsn + ", " + asp + ", " + asn);
+          {
+            int vsp = analogRead(Vsense_P);
+            int vsn = analogRead(Vsense_N);
+            int asp = analogRead(Asense_P);
+            int asn = analogRead(Asense_N);
+            Serial.println(String("ADC:") + vsp + ", " + vsn + ", " + asp + ", " + asn);
+          }
+          break;
+
+        case 23:
+          // Diagnostic function - change offset calibration
+          offsetP = param;
+          EEPROMWriteInt(7, offsetP);
+          Serial.println("ACK");
+          break;
+
+        case 24:
+          // Diagnostic function - change negative offset calibration
+          offsetN = param;
+          EEPROMWriteInt(9, offsetN);
+          Serial.println("ACK");
           break;
       }
     }
@@ -272,10 +314,10 @@
   int cval = 0;

   // Read positive voltage
-  vSenseP = (analogReadV(10, Vsense_P) * VDRP) / 1000;
+  vSenseP = (analogReadV(10, Vsense_P) * (VDRP+offsetP)) / 1000;

   // Read negative voltage
-  vSenseN = ((Vref/2) - analogReadV(10, Vsense_N)) * 10;
+  vSenseN = (((Vref/2)-offsetN) - analogReadV(10, Vsense_N)) * -10;

   // Read positive current
   cval =  analogReadV(10, Asense_P) - 2500;


Updates and improvements

Updates and improvements

--- wifi/wifi.ino
+++ wifi/wifi.ino
@@ -1,102 +1,60 @@
 #include <SoftwareSerial.h>
-#define DEBUG true

-#define accesspoint "AndroidAP"
-#define password "jaime1980"
+// Pin 2: Rx, Pin 3: Tx
+SoftwareSerial wifi(2,3);

-#define baud_rate 19200  //115200
-
-// In Arduino> RX: pin 3, TX: pin 2
-
-SoftwareSerial esp8266(3,2);
-
-void setup()
+void sendWifi(char *msg, long tout, long toutS)
 {
+  long t0, t;
   int c;
-  pinMode(13,OUTPUT);
-  Serial.begin(9600);
-  esp8266.begin(baud_rate);
+
+  wifi.write(msg);
+  t0=millis()+tout;

-  delay(1000);
-  Serial.write("AT+CIOBAUD=19200\r\n");
-
-  //for(;;);
-  Serial.println("Hola radiola....");
-
-  esp8266.write("AT+CIOBAUD=19200\r\n");
-  while((c=esp8266.read())==-1);
-Serial.println(c);
-  //sendData("AT+RST\r\n",10000,DEBUG); // Deletes previous configuration
-
-  for(;;);
-
-  sendData("AT+CWJAP=\""accesspoint"\",\""password"\"\r\n\n", 2000, DEBUG);
-
-  delay(5000);
-  sendData("AT+CWMODE=3\r\n",1000,DEBUG); //Client and server side
-  sendData("AT+CIFSR\r\n",1000,DEBUG); // Show client and server IP in Serial Monitor
-  sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // Several connections
-  sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // webserver port = 80
+  while(1) {
+    t=millis();
+    if (t>t0){
+      break;
+    }
+    c=wifi.read();
+    if (c!=-1){
+      t0=t+toutS;
+      Serial.write(c);
+    }
+  }
 }

-void loop()
+#define TOUTS 5000
+#define TOUT  5000
+
+void setup ( )
 {
-  if(esp8266.available())
-    {
+  char buff[32];
+  char msg[1024];
+  long tout=5000;
+  long t0, t;
+
+  wifi.begin(9600);
+  Serial.begin(9600);

-      if(esp8266.find("+IPD,"))
-	{
-	  delay(1000);
+  Serial.println("Modulo WIFI test");
+
+  sendWifi("AT+GMR\r\n", TOUT, TOUTS);
+  sendWifi("AT+RST\r\n",TOUT,TOUTS); // Borra la configuración que tenía el módulo
+  //sendWifi("AT+CWJAP=\"RodrigoAP\",\"xxxxxx\"\r\n", TOUT,TOUTS);

-	  int connectionId = esp8266.read()-48;
-
-	  String webpage = "<meta http-equiv=\"refresh\" content=\"4\">";
-	  webpage += "
KIO4.COM
";
-	  webpage += "Switch 8 status: ";
-	  int p8 = digitalRead(8);
-	  webpage += p8;
-	  webpage += "
Switch 9 status: ";
-	  int p9 = digitalRead(9);
-	  webpage += p9;
-
-	  String cipSend = "AT+CIPSEND=";
-	  cipSend += connectionId;
-	  cipSend += ",";
-	  cipSend +=webpage.length();
-	  cipSend +="\r\n";
-
-	  sendData(cipSend,1000,DEBUG);
-	  sendData(webpage,1000,DEBUG);
-
-	  // Close the connection
-	  String closeCommand = "AT+CIPCLOSE=";
-	  closeCommand+=connectionId;
-	  closeCommand+="\r\n";
-
-	  sendData(closeCommand,3000,DEBUG);
-	}
-    }
+//delay(5000); // Espera un poco que conecte con el Router.
+//sendData("AT+CWMODE=3\r\n",1000,DEBUG); // Modo de cliente y servidor.
+//sendData("AT+CIFSR\r\n",1000,DEBUG); // En el Serial Monitor aparece la IP de cliente y servidor.
+//sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // Multiples conexiones.
+//sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // El Puerto web es el 80
+    sendWifi("AT+CIPSTART=\"TCP\",\"192.168.43.1\",2221\r\n", TOUT , TOUTS);
+    sendWifi("AT+CIPSEND=5\r\n", TOUT, TOUTS);
+    sendWifi("HEL\r\n", TOUT, TOUTS);
+  Serial.println("Se acabo");
 }

-String sendData(String command, long timeout, boolean debug)
+void loop ()
 {
-  String response = "";
-  esp8266.print(command);
-  long time = millis();
-Serial.println("comando 0000");
-  while( (time+timeout) > millis())
-    {
-      while(esp8266.available())
-	{
-
-	  char c = esp8266.read();
-	  response+=c;
-	}
-    }
-Serial.println("tout....");
-  if(debug)
-    {
-      Serial.print(response);
-    }
-  return response;
+   // your code here ...
 }


better debug code for water level sensors

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -244,7 +244,8 @@
   void step(monitor_t* now, char cycleMins) {   // check conditions and adjust
     dbg(valveDBG, "\nvalve[].step - number = "); dln(valveDBG, number);
     int t = millis();
-    dbg(valveDBG, "t = "); dln(valveDBG, t);
+    dbg(valveDBG, "t = "); dbg(valveDBG, t);
+    dbg(valveDBG, "; filling = "); dln(valveDBG, filling);
     if(filling && ( lastFlip + (floodMins * 60 * 1000) ) <= t) { // flood over
       dbg(valveDBG, "t = "); dln(valveDBG, t);
       dbg(valveDBG, "lastFlip = "); dln(valveDBG, lastFlip);
@@ -396,6 +397,10 @@
       getLevel(LEVEL_ECHO_PIN1, &now->waterLevel1);     yield();
       getLevel(LEVEL_ECHO_PIN2, &now->waterLevel2);     yield();
       getLevel(LEVEL_ECHO_PIN3, &now->waterLevel3);     yield();
+      dln(valveDBG, "");
+      dbg(valveDBG, "wL1: "); dbg(valveDBG, now->waterLevel1);
+      dbg(valveDBG, "; wL2: "); dbg(valveDBG, now->waterLevel2);
+      dbg(valveDBG, "; wL3: "); dln(valveDBG, now->waterLevel3);
     }

     flowController.step(now); yield();  // set valves on and off etc.


moved peripheral startups into a separate function

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -59,7 +59,7 @@
   "

\n";
 const char* pageFooter =
   "\n
WaterElf   "
-  "Fish4Tea
";
+  "CleanFood
";

 /////////////////////////////////////////////////////////////////////////////
 // data monitoring stuff ////////////////////////////////////////////////////
@@ -102,8 +102,7 @@
   pinMode(BUILTIN_LED, OUTPUT);
   blink(3);

-  // RC Transmitter is connected to Pin #13
-  mySwitch.enableTransmit(13);
+  startPeripherals();

   // TODO don't do this if wifi config'd and connected
   startAP();
@@ -388,7 +387,11 @@
 }

 /////////////////////////////////////////////////////////////////////////////
-// sensor stuff /////////////////////////////////////////////////////////////
+// sensor/actuator stuff ////////////////////////////////////////////////////
+void startPeripherals() {
+  // RC Transmitter is connected to Pin #13
+  mySwitch.enableTransmit(13);
+}
 void updateSensorData(monitor_t *monitorData) {
   // Serial.print("monitorCursor = "); Serial.print(monitorCursor);
   // Serial.print(" monitorSize = ");  Serial.println(monitorSize);


Bluetooth

Bluetooth

Updated Code with HC-05

--- BitBangingMpu6050/BitBangingMpu6050.ino
+++ BitBangingMpu6050/BitBangingMpu6050.ino
@@ -11,6 +11,9 @@
 #define I2C_FASTMODE 1

 #include "SoftWire.h"
+
+#include <SoftwareSerial.h>
+SoftwareSerial mySerial(2, 3);

 SoftWire Wire = SoftWire();

@@ -660,7 +663,7 @@

   Wire.begin();

-  Serial.begin(115200);
+  Serial.begin(9600);
   Serial.println(F("InvenSense MPU-6050"));
   Serial.println(F("June 2012"));

@@ -699,6 +702,8 @@
   MPU6050_write_reg (MPU6050_PWR_MGMT_1, 0);
   Serial.println("\nI2C Scanner");
     }
+      mySerial.begin(9600);
+
 }
 void loop(){

@@ -773,12 +778,25 @@
   // Print the raw acceleration values

   Serial.print(F("accel x,y,z: "));
-  Serial.print(accel_t_gyro.value.x_accel, DEC);
-  Serial.print(F(", "));
-  Serial.print(accel_t_gyro.value.y_accel, DEC);
-  Serial.print(F(", "));
-  Serial.print(accel_t_gyro.value.z_accel, DEC);
-  Serial.println(F(""));
+  mySerial.println("The Accl X value is : ");
+  //Serial.print(accel_t_gyro.value.x_accel, DEC);
+  //Serial.print(F(", "));
+    mySerial.print(accel_t_gyro.value.x_accel);
+  mySerial.print("\n");
+    mySerial.println("The Accl Y value is : ");
+//Serial.print(accel_t_gyro.value.y_accel, DEC);
+      mySerial.print(accel_t_gyro.value.y_accel);
+  mySerial.print("\n");
+
+ // Serial.print(F(", "));
+   mySerial.println("The Accl X value is : ");
+
+  //Serial.print(accel_t_gyro.value.z_accel, DEC);
+     mySerial.print(accel_t_gyro.value.z_accel);
+
+  //Serial.println(F(""));
+    mySerial.print("\n");
+

   // The temperature sensor is -40 to +85 degrees Celsius.
@@ -787,23 +805,34 @@
   //   340 per degrees Celsius, -512 at 35 degrees.
   // At 0 degrees: -512 - (340 * 35) = -12412

-  Serial.print(F("temperature: "));
+  /*Serial.print(F("temperature: "));
   dT = ( (double) accel_t_gyro.value.temperature + 12412.0) / 340.0;
   Serial.print(dT, 3);
   Serial.print(F(" degrees Celsius"));
-  Serial.println(F(""));
+  Serial.println(F(""));*/

   // Print the raw gyro values.

   Serial.print(F("gyro x,y,z : "));
-  Serial.print(accel_t_gyro.value.x_gyro, DEC);
-  Serial.print(F(", "));
-  Serial.print(accel_t_gyro.value.y_gyro, DEC);
-  Serial.print(F(", "));
-  Serial.print(accel_t_gyro.value.z_gyro, DEC);
-  Serial.print(F(", "));
-  Serial.println(F(""));
+  mySerial.println("The Gyro X value is : ");
+  mySerial.print(accel_t_gyro.value.x_gyro);
+      mySerial.print("\n");
+  //Serial.print(accel_t_gyro.value.x_gyro, DEC);
+  //Serial.print(F(", "));
+  //Serial.print(accel_t_gyro.value.y_gyro, DEC);
+    mySerial.println("The Gyro Y value is : ");
+    mySerial.print(accel_t_gyro.value.y_gyro);
+        mySerial.print("\n");
+
+  //Serial.print(F(", "));
+  //Serial.print(accel_t_gyro.value.z_gyro, DEC);
+    mySerial.println("The Gyro Z value is : ");
+    mySerial.print(accel_t_gyro.value.z_gyro);
+        mySerial.print("\n");
+
+  //Serial.print(F(", "));
+  //Serial.println(F(""));

  //delay(1000);

@@ -824,7 +853,7 @@
   else
     Serial.println("done\n");

-  if(flag==1078io)
+  if(flag==10)
     flag=6;
     else
       flag++;


Add ReadColor example

Add ReadColor example

This example read the sensor and print the result in hex color code and
8 bit grayscale.

--- examples/ReadColor/ReadColor.ino
+++ examples/ReadColor/ReadColor.ino
@@ -39,11 +39,16 @@
   byte green = tcs.readColor(GREEN);
   byte blue = tcs.readColor(BLUE);

-  // Write color code
+  // Write RGB color code
   Serial.print("Color: #");
   Serial.print(red, HEX);
   Serial.print(green, HEX);
-  Serial.println(blue, HEX);
+  Serial.print(blue, HEX);
+
+  // Write grayscale color
+  byte grayscale = tcs.readGrayscale();
+  Serial.print("\tGrayscale: ");
+  Serial.println(grayscale);

   delay(500);
 }


delete serial state

delete serial state

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Chain/open_manipulator_chain/open_manipulator_chain.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Chain/open_manipulator_chain/open_manipulator_chain.ino
@@ -28,8 +28,8 @@
 {
   Serial.begin(57600);
   DEBUG.begin(57600);
-  while (!Serial)
-  ;
+  // while (!Serial)
+  // ;

   connectProcessing();
   connectRC100();


Alert mode blinking

Alert mode blinking

--- resilient_network/resilient_network.ino
+++ resilient_network/resilient_network.ino
@@ -31,6 +31,8 @@
 int lampState;
 int alertState = false;
 int alertTimer;
+int alertBlinkTimer;
+int blinkLedState = false;
 boolean isSource = false;

 void sendEnergy() {
@@ -85,6 +87,7 @@

   // relax alert state
   alertState = false;
+  stopBlink();
 }

 // ToDo: why not call this on a fixed interval?
@@ -94,6 +97,14 @@
   for (int i =0; i<NUM_CONN; i++) if (distanceToSource[i] < shortestDistanceToSource) shortestDistanceToSource = distanceToSource[i];

   if(SERIAL_DEBUG) {
+
+    Serial.print("d:");
+    for (int i =0; i<NUM_CONN; i++) {
+      Serial.print(" ");
+      Serial.print(distanceToSource[i]);
+    }
+    Serial.println("");
+
     Serial.print("sd: ");
     Serial.println(shortestDistanceToSource);
   }
@@ -111,11 +122,12 @@
       switchLampOff();
       for(int i=0; i<NUM_CONN; i++) digitalWrite(coil[i], LOW);
       addTimer(1000, resetConnectors);
+      stopBlink();
     }
   }

   for (int i=0; i<NUM_CONN; i++) distanceToSource[i] = 99;
-  addTimer(1000, processEnergy);
+  addTimer(500, processEnergy);
 }

 uint8_t rxRead(int busIndex) {
@@ -184,6 +196,7 @@
         alertTimer = addTimer(random(1000, 5000), dropConnector);
         // propagate signal though network
         for (int j=0; j<NUM_CONN; j++) if (j!=busIndex) txWrite(j, ALERT);
+        blink();
       }
       break;
     case DROPPING_CONNECTOR: // some connector in the network is dropped
@@ -193,6 +206,7 @@
         alertState = false;
         // propagate signal though network
         for (int j=0; j<NUM_CONN; j++) if (j!=busIndex) txWrite(j, DROPPING_CONNECTOR);
+        stopBlink();
       }
       break;
     default: // distance to source
@@ -207,6 +221,24 @@
   }
 }

+void blink() {
+	// toggle one led group
+	blinkLedState = !blinkLedState;
+	digitalWrite(leds1pin, blinkLedState? HIGH : LOW);
+
+  digitalWrite(debugLedPin, HIGH);
+  removeTimer(alertTimer);
+	alertBlinkTimer = addTimer(300, blink);
+}
+void stopBlink() {
+  removeTimer(alertTimer);
+  // restore leds
+  if(lampState) switchLampOn();
+  else switchLampOff();
+  digitalWrite(debugLedPin, LOW);
+}
+
+
 void setup() {
   // set up pins
   for (int i=0; i<NUM_CONN; i++) {
@@ -220,6 +252,7 @@
   }
   pinMode(leds1pin, OUTPUT);
   pinMode(leds2pin, OUTPUT);
+  pinMode(debugLedPin, OUTPUT);
   pinMode(button1pin, INPUT_PULLUP);
   pinMode(button2pin, INPUT_PULLUP);


flo edges going

flo edges going

also sets run_state(0) on no transition out

--- hb.ino
+++ hb.ino
@@ -87,33 +87,46 @@
 }

 void process_message() {
-  String msg = deq_message();
-  int e_index;
+  String msg = deq_message(); // example "msg:graph_init"
+  String e_type = msg.substring(0, 3);
+  String e_part2 = msg.substring(4);
+  char e2[12];
+  int e_index = -1;
   int n0_index, n1_index;
+  #ifdef DUBUG_BUILD
+  debug("pm");
+  debug(e_type);
+  debug(e_part2);
+  #endif
   if (msg[0] == '\0')  {
     #ifdef DUBUG_BUILD
-    debug("no edge 1");
+    debug("no msg in pm");
     #endif
     set_run_state(0);
     return;
   }
-  e_index = get_edge("msg", msg, -1);
+  if (e_type == "msg") {
+    e_part2.toCharArray(e2, 11);
+    e_index = get_edge("msg", e2, -1);
+  }
+  if (e_type == "flo") {
+    e_part2.toCharArray(e2, 11);
+    n0_index = atoi(e2);
+    e_index = get_edge("flo", "from", n0_index);
+  }
   if (e_index < 0) {
-    e_index = get_edge("flo", msg, -1);
-  }
-  if (e_index < 0) {
-    #ifdef DUBUG_BUILD
-    debug("no edge 2");
+    #ifdef DUBUG_BUILD
+    debug("no edge in pm");
     #endif
     set_run_state(0);
     return;
   }
   else {
     #ifdef DUBUG_BUILD
-    debug("test of process edge (type) ");
+    debug("pm processing edge (type) ");
     debug(edges[e_index].type);
     #endif
-    n0_index = get_node("id", edges[e_index].from);
+    //n0_index = get_node("id", edges[e_index].from);
     n1_index = get_node("id", edges[e_index].to);
     run_node(n1_index);
   }
@@ -125,12 +138,25 @@
     message_count++;
     message_str = msg;
   }
+  #ifdef DUBUG_BUILD
+  else {
+    debug("enq_message count error");
+    debug(msg);
+  }
+  #endif
+
 }
 String deq_message() {
   if (message_count > 0) {
     message_count--;
     return message_str;
   }
+  #ifdef DUBUG_BUILD
+  else {
+    debug("deq_message count error");
+    Serial.println(message_count);
+  }
+  #endif
 }

 // get edge
@@ -140,8 +166,11 @@
   for (i = 0; i < 10; i++) {
     t = edges[i].type;
     n = edges[i].name;
-    if (t == e_type && (n == msg || (msg == "*" && edges[i].from == from))) {
-      return i;
+    if (t == e_type) {
+      if ((n == msg || (msg == "*" && edges[i].from == from)) ||
+          (msg == "from" && edges[i].from == from)) {
+        return i;
+      }
     }
   }
   return -1;
@@ -163,7 +192,7 @@
   //nodes[n_index].value = run_get_edges(n_index);
   //run_process();
   run_set_edges(n_index);
-  run_transition();
+  run_transition(n_index);

 }

@@ -188,8 +217,30 @@
   }
 }

-void run_transition() {
-  // put a message in the queue
+void run_transition(int n_index) {
+  int e_i = get_edge("flo", "from", n_index);
+  char itoa_buff[7];
+  if (e_i >= 0) {
+    int from_n_i = edges[e_i].from;
+    #ifdef DUBUG_BUILD
+    Serial.print("flo edge ");
+    Serial.print(e_i, DEC);
+    Serial.println(" enqueued");
+    #endif
+    // put a message in the queue
+    itoa(from_n_i, itoa_buff, 10);
+    String message = "flo:";
+    message += itoa_buff;
+    enq_message(message);
+  }
+  else {
+    set_run_state(0);
+    #ifdef DUBUG_BUILD
+    Serial.print("no transition form ");
+    Serial.print(n_index, DEC);
+    Serial.println(" party is over.");
+    #endif
+  }
 }

 void set_run_state(short new_state) {
@@ -197,10 +248,8 @@
   if (graph_loaded) {
     run_state = new_state;
   }
-  // next line... just for fun (remove later ;)
-  //digitalWrite(led, (int)run_state);
   if (!previous_state && run_state) { // rising edge
-    enq_message("graph_init");
+    enq_message("msg:graph_init");

     #ifdef DUBUG_BUILD
     debug("sent msg graph_init");


fix SDWebServer sample

fix SDWebServer sample

--- hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino
+++ hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino
@@ -55,7 +55,6 @@
   message += "Access-Control-Allow-Origin: *\r\n";
   message += "\r\n";
   client.print(message);
-  message = 0;
   client.stop();
 }

@@ -69,7 +68,6 @@
   message += msg;
   message += "\r\n";
   client.print(message);
-  message = 0;
   client.stop();
 }

@@ -108,8 +106,8 @@
     head += "\r\nAccess-Control-Allow-Origin: *";
     head += "\r\n\r\n";
     client.print(head);
-    dataType = 0;
-    path = 0;
+    dataType = String();
+    path = String();

     uint8_t obuf[WWW_BUF_SIZE];

@@ -172,11 +170,11 @@
       entry.close();
       SD.remove((char *)entryPath.c_str());
     }
-    entryPath = 0;
+    entryPath = String();
     yield();
   }
   SD.rmdir((char *)path.c_str());
-  path = 0;
+  path = String();
   file.close();
 }

@@ -186,7 +184,7 @@
   if(path == "/" || !SD.exists((char *)path.c_str())) return returnFail("BAD PATH");
   deleteRecursive(path);
   returnOK();
-  path = 0;
+  path = String();
 }

 void handleCreate(){
@@ -203,7 +201,7 @@
     SD.mkdir((char *)path.c_str());
   }
   returnOK();
-  path = 0;
+  path = String();
 }

 void printDirectory() {
@@ -211,7 +209,7 @@
   String path = server.arg("dir");
   if(path != "/" && !SD.exists((char *)path.c_str())) return returnFail("BAD PATH");
   File dir = SD.open((char *)path.c_str());
-  path = 0;
+  path = String();
   if(!dir.isDirectory()){
     dir.close();
     return returnFail("NOT DIR");
@@ -242,7 +240,7 @@
  output += "]";
  client.write(output.c_str(), output.length());
  client.stop();
- output = 0;
+ output = String();
 }

 void handleNotFound(){


Added LED to InputPullup example

Added LED to InputPullup example

--- build/shared/examples/2.Digital/DigitalIputPullup/DigitalIputPullup.ino
+++ build/shared/examples/2.Digital/DigitalIputPullup/DigitalIputPullup.ino
@@ -6,6 +6,7 @@

  The circuit:
  * Momentary switch attached from pin 2 to ground
+ * Built-in LED on pin 13

  Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
  20K-ohm resistor is pulled to 5V. This configuration causes the input to
@@ -24,7 +25,8 @@
   //start serial connection
   Serial.begin(9600);
   //configure pin2 as an input and enable the internal pull-up resistor
-  pinMode(2, INPUT_PULLUP);
+  pinMode(2, INPUT_PULLUP);
+  pinMode(13, OUTPUT);

 }

@@ -33,9 +35,18 @@
   int sensorVal = digitalRead(2);
   //print out the value of the pushbutton
   Serial.println(sensorVal);
-  //brief delay
-  delay(10);
-
+
+  // Keep in mind the pullup means the pushbutton's
+  // logic is inverted. It goes HIGH when it's pressed,
+  // and LOW when it's not. Turn on pin 13 when the
+  // button's pressed, and off when it's not:
+  if (sensorVal == HIGH) {
+    digitalWrite(13, LOW);
+  }
+  else {
+    digitalWrite(13, HIGH);
+  }
 }

+


Adde case statements

Adde case statements

--- arduino/semSim/semSim.ino
+++ arduino/semSim/semSim.ino
@@ -5,35 +5,56 @@

  */

-String inputCommand = "";
-String inputValue = "";  // a string to hold incoming data
-String inputString = "";
-
-int myInts[30];
-int myIntsIndex = 0;
+String inputCommand = ""; // A string to capture the command before the space
+String inputValue = "";  // A string to capture command value after space
+String inputString = ""; // The raw Readline string

 boolean stringComplete = false;  // whether the string is complete
-boolean separator = false;
+boolean separator = false; // When a space is received

 int led = 13; // An indication LED Pin
+int res; // Response status

 void setup() {
   // initialize serial:
   Serial.begin(9600);
   // reserve 200 bytes for the inputString:
-  inputString.reserve(200);
-  inputCommand.reserve(20);
-  inputValue.reserve(20);
+  inputString.reserve(200); // Who knows
+  inputCommand.reserve(20);  // These need to be short
+  inputValue.reserve(20); //TODO: Stop appending if to many chars a rerecived.
+  digitalWrite(led, LOW);
 }

 void loop() {
   // print the string when a newline arrives:
   if (stringComplete) {
-    digitalWrite(led, LOW);
+    digitalWrite(led, LOW); // Turn off the LED.  We are processing now
+    // Stuff
+    //Serial.print(inputString);
+    //Serial.println(inputCommand);
+    //Serial.println(inputValue);

-    Serial.print(inputString);
-    Serial.println(inputCommand);
-    Serial.println(inputValue);
+    switch (var) {
+      case 0:
+        // No Error
+        break;
+      case 3:
+        // Format Error
+        break;
+      case 4:
+        // Argument Error
+        break;
+      case 5:
+        // Command Execution Impossible
+        // busy for other command execution
+        break;
+      case 6:
+        // Command Execution Impossible
+        // mismatch in interpretation of entered command
+        break;
+      default:
+        // statements
+    }

     // clear the string:
     inputString = "";