Revert "Clean up"

Revert "Clean up"

This reverts commit 1cc41362a7edf90dbaecc19a8334832e626d1877.

--- Pan_Tilt_laser/Pan_Tilt_laser.ino
+++ Pan_Tilt_laser/Pan_Tilt_laser.ino
@@ -26,8 +26,10 @@
 #include "stuPanTilt.h"
 #include "stuLaser.h"

+#define DIRECTION_CHANGE_PROBABILITY 15
+
+
 #define BAUD_RATE 115200
-#define DIRECTION_CHANGE_PROBABILITY 15

 //X Position: lower numbers == Right
@@ -35,6 +37,7 @@

 panTiltPos_t panTiltX(0, 55, 125, -20);
 panTiltPos_t panTiltY(0, 10, 45);
+

 PanTilt panTilt(9, &panTiltX, 10, &panTiltY, 98);

@@ -78,6 +81,8 @@
   changeVal = getMarkovSpeed(changeVal);

   panTiltX.angle = getDeltaPosition(&panTiltX, changeVal, DIRECTION_CHANGE_PROBABILITY) + panTiltX.angle;
+
+

   panTiltY.angle = getDeltaPosition(&panTiltY, changeVal, DIRECTION_CHANGE_PROBABILITY) + panTiltY.angle;

@@ -128,6 +133,7 @@
     if(random(1001) <= prob << 1 || (pt->angle >= pt->maxAngle && pt->dir == 1) || pt->angle <= pt->minAngle && pt->dir == -1){
       pt->dir *= -1;

+
     }

     return pt->dir;


Fixed bug in call to web app

Fixed bug in call to web app

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -66,7 +66,7 @@
 			playCoinSound();

 			WIFI.listen();
-			if (id != 6 && id != 12 && id != 0 && id < 100) {
+			if (scannedID != 6 && scannedID != 12 && scannedID != 0 && scannedID < 100) {
 				scanTest(scannedID);
 			}


Add start text.

Add start text.

--- examples/bluemix/mqtt_bluemix_test/mqtt_bluemix_test.ino
+++ examples/bluemix/mqtt_bluemix_test/mqtt_bluemix_test.ino
@@ -9,7 +9,7 @@
 #include "mqtt_configuration.h"

-const char* ssid     = "CMMC.32";
+const char* ssid     = "CMMC.47";
 const char* pass     = "guestnetwork";

 MqttWrapper *mqtt;
@@ -37,11 +37,16 @@
     delay(10);
     Serial.println();
     Serial.println();
+    Serial.println("START");
 }

 void init_wifi()
 {
     wifi = new WiFiHelper(ssid, pass);
+    wifi->on_connecting([](const char* message)
+    {
+        Serial.println (message);
+    });
     wifi->on_connected([](const char* message)
     {
         Serial.println (message);


Updated arduino code - needs testing!

Updated arduino code - needs testing!

--- software/Arduino/ServoController/ServoController.ino
+++ software/Arduino/ServoController/ServoController.ino
@@ -14,40 +14,29 @@
 // ================ SYSTEM PARAMETERS ===================
 // Sample rates
 int motorUpdateRate = 50; // gyro sample rate
-
 int calibrationSamples = 1000;

-// Initial calibration values
-float calibratedYOffset = 0;
-float calibratedZOffset = 0;
-
-// Stepper motor
-int stepperPins[] = {9, 10, 11, 12};
-int stepperSteps = 200;
-float stepperStepSize = 9.0/5;
-
-// Servo motor
-float currentServoVal = 90;
+// Initial calibration value
+float calibratedOffset = 0;

 // Indicator LED
 const int LED = 13;
+
+// These values will need to be experimentally found using
+// a servo
+const float RPM = 1.5;
+const float CLOCK_WISE_SPEED = 40;
+const float COUNTER_CLOCK_WISE_SPEED = 100;
+const float ZERO_SPEED = 75;
 // =======================================================

 // ============ Initialize electronic interfaces =========
-// Stepper
-Stepper motor(stepperSteps, stepperPins[0], stepperPins[1], stepperPins[2], stepperPins[3]);
-
-// Servo
-Servo altitude;
-
-// Gyro
+Servo azimuth;
 LSM9DS1 imu;

 // ============ Runtime variables ========================
 // Orientation data
-float currentYBodyPosition = 90;
-float currentZBodyPosition = 0;
-float currentZMotorPosition = 0;
+float positionChange;

 // Misc.
 int timer = millis();
@@ -61,11 +50,10 @@

   // Setup hardware
   setupIMU();         // Gyro
-  motor.setSpeed(20); // Stepper
-  altitude.attach(3); // Servo
+  azimuth.attach(3);

   // Calibrate the gyro
-  zeroGyro();
+  calibratedOffset = zeroGyro(calibrationSamples);

   // Setup motor update interval timer
   MsTimer2::set(motorUpdateRate, updateMotor);
@@ -79,48 +67,28 @@

   // Accept corrections from serial
   if (Serial.available() == 4) {
-    int correctionFactorXY = 0;
-    int correctionFactorZ = 0;
-    byte negXY = 0;
-    byte negZ = 0;
-    if (Serial.read() == '1') negXY = 1;
-    correctionFactorXY += (Serial.read() - '0') * 100;
-    correctionFactorXY += (Serial.read() - '0') * 10;
-    correctionFactorXY += (Serial.read() - '0');
-    if (negXY) correctionFactorXY = -correctionFactorXY;
-    rotateStepperBy(correctionFactorXY);
-    /*
-    currentZBodyPosition += correctionFactorXY;
-    currentZMotorPosition += correctionFactorXY;
-    if (Serial.read() == '1') negZ = 1;
-    correctionFactorZ += (Serial.read() - '0') * 100;
-    correctionFactorZ += (Serial.read() - '0') * 10;
-    correctionFactorZ += (Serial.read() - '0');
-    if (negZ) correctionFactorZ = -correctionFactorZ;
-    altitude.write(currentYBodyPosition + correctionFactorZ);
-    currentYBodyPosition += correctionFactorZ;
-    */
+    int correctionFactor = 0;
+    byte negative = 0;
+    if (Serial.read() == '1') negative = 1;
+    for (int i = 100; i >= 1; i /= 10) {
+      correctionFactor += (Serial.read() - '0') * 100;
+    }
+    if (negative) correctionFactor = -correctionFactor;
+    rotateServoBy(correctionFactor);
   }

   // Update orientation data with measurements from gyro
   // Just using angular rates from gyro and time deltas to track position using a Reimann sum.
   int currentTime = millis();
   int deltaT = currentTime - timer;
-  currentZBodyPosition += deltaT * readGyroZ() / 1000; // Gyro data is given in 1000ths of a degree, so we divide by 1000
-  currentYBodyPosition += deltaT * readGyroY() / 1000;
+  positionChange += deltaT * readGyro() / 1000; // Gyro data is given in 1000ths of a degree, so we divide by 1000
   timer = currentTime;

-  // Update motor positions
+  // Update motor position
   if(update_flag) {
-    // Debug output
-    // Update servo position (Y/ALT)
-    altitude.write(currentYBodyPosition);
-
     // Update stepper position (Z/AZM)
-    float difference = currentZBodyPosition - currentZMotorPosition; // we want currentZMotorPosition + currentZBodyPosition = 0
-    int steps = rotateStepperBy(-difference);
-    currentZMotorPosition += -steps * stepperStepSize;
-
+    rotateServoBy(-positionChange);
+    positionChange = 0;
     // Reset flag
     update_flag = false;
   }
@@ -140,24 +108,19 @@
 }

 // For stepper motors
-int rotateStepperBy(float deg) {
-  int steps = deg/stepperStepSize;
-  motor.step(steps);
-  return steps;
+void rotateServoBy(float deg) {
+  float wait = abs((deg / 360) / RPM);
+  if (deg < 0) azimuth.write(COUNTER_CLOCK_WISE_SPEED);
+  else azimuth.write(CLOCK_WISE_SPEED);
+  delay(wait);
+  azimuth.write(ZERO_SPEED);
 }

-float readGyroZ() {
+float readGyro() {
   if (imu.gyroAvailable()) {
     imu.readGyro();
   }
-  return imu.calcGyro(imu.gz) - calibratedZOffset;
-}
-
-float readGyroY() {
-  if (imu.gyroAvailable()) {
-    imu.readGyro();
-  }
-  return imu.calcGyro(imu.gy) - calibratedYOffset;
+  return imu.calcGyro(imu.gz) - calibratedOffset;
 }

 void blinkLED(int del, int n) {
@@ -169,28 +132,17 @@
   }
 }

-void zeroGyro() {
-  float ySum = 0;
+int zeroGyro(int calibrationSamples) {
   float zSum = 0;
-
   for(int i = 0; i < calibrationSamples; i++) {
-
-    if(i%100==0) {
-      digitalWrite(LED, HIGH);
+    if(i % 1000 == 0) {
+      blinkLED(500, 1);
     }
-    else if(i%100==10) {
-      digitalWrite(LED, LOW);
-    }
-
     imu.readGyro();
-    float y = imu.calcGyro(imu.gy);
     float z = imu.calcGyro(imu.gz);
-    ySum += y;
     zSum += z;
     delay(10);
   }
-
-  calibratedYOffset = ySum/calibrationSamples;
-  calibratedZOffset = zSum/calibrationSamples;
+  return zSum / calibrationSamples;
 }


split mac and site mac, added DHCP Ethernet.maintain() call to maintain DHCP lease.

--- arduinolifx.ino
+++ arduinolifx.ino
@@ -14,6 +14,7 @@
  Set the following variables below to suit your Arduino and network
  environment:
  - mac (unique mac address for your arduino)
+ - site_mac (same as mac (above))
  - redPin (PWM pin for RED)
  - greenPin  (PWM pin for GREEN)
  - bluePin  (PWM pin for BLUE)
@@ -42,6 +43,7 @@
 // Enter a MAC address and IP address for your controller below.
 // The IP address will be dependent on your local network:
 byte mac[] = { 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD };
+byte site_mac[] = { 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD };

 // pins for the RGB LED:
 const int redPin = 3;
@@ -161,6 +163,8 @@
     handleRequest(request);

   }
+
+  Ethernet.maintain();

   //delay(10);
 }
@@ -443,7 +447,7 @@
   Udp.write(lowByte(0x00));
   Udp.write(lowByte(0x00));

-  // buldAddress mac address
+  // bulbAddress mac address
   for(int i = 0; i < sizeof(mac); i++) {
     Udp.write(lowByte(mac[i]));
   }
@@ -453,8 +457,8 @@
   Udp.write(lowByte(0x00));

   // site mac address
-  for(int i = 0; i < sizeof(mac); i++) {
-    Udp.write(lowByte(mac[i]));
+  for(int i = 0; i < sizeof(site_mac); i++) {
+    Udp.write(lowByte(site_mac[i]));
   }

   // reserved3
@@ -514,7 +518,7 @@
   TCPBuffer[byteCount++] = lowByte(0x00);
   TCPBuffer[byteCount++] = lowByte(0x00);

-  // buldAddress mac address
+  // bulbAddress mac address
   for(int i = 0; i < sizeof(mac); i++) {
     TCPBuffer[byteCount++] = lowByte(mac[i]);
   }
@@ -524,8 +528,8 @@
   TCPBuffer[byteCount++] = lowByte(0x00);

   // site mac address
-  for(int i = 0; i < sizeof(mac); i++) {
-    TCPBuffer[byteCount++] = lowByte(mac[i]);
+  for(int i = 0; i < sizeof(site_mac); i++) {
+    TCPBuffer[byteCount++] = lowByte(site_mac[i]);
   }

   // reserved3
@@ -584,7 +588,7 @@
   Serial.print(lowByte(0x00), HEX);
   Serial.print(" ");

-  // buldAddress mac address
+  // bulbAddress mac address
   for(int i = 0; i < sizeof(mac); i++) {
     Serial.print(lowByte(mac[i]), HEX);
     Serial.print(" ");
@@ -597,8 +601,8 @@
   Serial.print(" ");

   // site mac address
-  for(int i = 0; i < sizeof(mac); i++) {
-    Serial.print(lowByte(mac[i]), HEX);
+  for(int i = 0; i < sizeof(site_mac); i++) {
+    Serial.print(lowByte(site_mac[i]), HEX);
     Serial.print(" ");
   }


Update Timer_Interrupt_Notes.ino

Update Timer_Interrupt_Notes.ino

--- PulseSensorAmped_Arduino_1dot4/Timer_Interrupt_Notes.ino
+++ PulseSensorAmped_Arduino_1dot4/Timer_Interrupt_Notes.ino
@@ -151,6 +151,9 @@
   ******************************************************************************************
   ADAFRUIT Gemma (or any other board with ATtiny85 running at 8MHz)

+    NOTE: Gemma does not do serial communication!
+          Comment out or remove the Serial code in the Arduino sketch!
+
   Timer1

     Use of Timer1 breaks PWM output on pin D1


Fix ThingSpeak TalkBack sketch for Arduino Mega.

1. PING is a reserved symbol.

--- examples/IoT/ThingSpeak/CosaThingSpeakTalkBack/CosaThingSpeakTalkBack.ino
+++ examples/IoT/ThingSpeak/CosaThingSpeakTalkBack/CosaThingSpeakTalkBack.ino
@@ -57,17 +57,17 @@
   trace << Watchdog::millis() << ':' << m_string << endl;
 }

-const char LED_ON[] __PROGMEM = "LED_ON";
-Command led_on(&talkback, LED_ON);
+const char LED_ON_COMMAND[] __PROGMEM = "LED_ON";
+Command led_on(&talkback, LED_ON_COMMAND);

-const char LED_OFF[] __PROGMEM = "LED_OFF";
-Command led_off(&talkback, LED_OFF);
+const char LED_OFF_COMMAND[] __PROGMEM = "LED_OFF";
+Command led_off(&talkback, LED_OFF_COMMAND);

-const char REBOOT[] __PROGMEM = "REBOOT";
-Command reboot(&talkback, REBOOT);
+const char REBOOT_COMMAND[] __PROGMEM = "REBOOT";
+Command reboot(&talkback, REBOOT_COMMAND);

-const char PONG[] __PROGMEM = "PONG";
-Command pong(&talkback, PONG);
+const char PONG_COMMAND[] __PROGMEM = "PONG";
+Command pong(&talkback, PONG_COMMAND);

 // Thingspeak TalkBack command handler; add command(PONG) back
 // to the command queue;
@@ -86,8 +86,8 @@
   m_talkback->add_command_P(PSTR("PONG"));
 }

-const char PING[] __PROGMEM = "PING";
-Ping ping(&talkback, PING);
+const char PING_COMMAND[] __PROGMEM = "PING";
+Ping ping(&talkback, PING_COMMAND);

 void setup()
 {


mechSetPosition(round (valueRotateL), round (valueRotateC)); void calibrateMotors();

--- hal100/hal100.ino
+++ hal100/hal100.ino
@@ -53,6 +53,8 @@
 float valueL = 0;           // calculated value L float
 float Cmult;                // constant multiplier to calculate C value
 float Lmult;                // constant multiplier to calculate L value
+float valueRotateC;
+float valueRotateL;

 boolean presentValue = false;

@@ -146,6 +148,7 @@
   displayC(), displayL();                           // display current values L and C at display
   tuningDisplay();                                  // flashing tuning - this to be changed to start at CmoveStage1 and finish after LmoveStage1
   displayTunedFreqTopScreen();                      // emulation of Green Tuned after motors in place
+  mechSetPosition(round (valueRotateL), round (valueRotateC));
   // End STAGE 1 tuning process
 }

@@ -299,7 +302,7 @@
   Serial.println(pFtotalValue);
   float pFperStep = pFtotalValue / ( totalStepsC / 2 );
   Serial.println(pFperStep);
-  float valueRotateC = ( valueC - pFmin ) / pFperStep;
+  valueRotateC = ( valueC - pFmin ) / pFperStep;
   Serial.print("steps C to rotate=");
   Serial.println(valueRotateC);
 }
@@ -313,7 +316,7 @@
  // y = -0.0299x2 + 1.3867x + 0.5894
  float totalStepsL = 2964;                                                              // total motor steps for 1 rotation
  float LturnsRequred = ( -0.0299 * valueL * valueL ) + ( 1.3867 * valueL ) + 0.5894;    // poly math
- float valueRotateL = LturnsRequred * totalStepsL;
+ valueRotateL = LturnsRequred * totalStepsL;
  Serial.print("L turns requred=");
  Serial.println(LturnsRequred);
  Serial.print("steps L to rotate=");
@@ -349,9 +352,13 @@
         case '*':                           // erase entered frequency
           eraseFrequency();
           break;
-        case 'K':                           // calibrate both motors
-          calibrateMotors();
-          break;
+        case 'U':                           // calibrate both motors
+          mechCalibrate(channelC);
+          break;
+        case 'D':                           // calibrate both motors
+          mechCalibrate(channelL);
+          break;
+
       }
   }
 }


Re-added the delay/button press function

--- arduino/ClockFOUR_TiM/ClockFOUR_TiM.ino
+++ arduino/ClockFOUR_TiM/ClockFOUR_TiM.ino
@@ -321,11 +321,7 @@
 //				disp_ScrollWords("Hour:", -15, 6);

 				disp_showBWBitmap(Hour_bw_bmp, 0x00FFFFFF, 0x00000000);	// White on black
-				delay(2000);
-				disp_showBWBitmap(Hour_bw_bmp, 0x00000000, 0x00FFFFFF);	// Black on white
-				delay(2000);
-				disp_showBWBitmap(Hour_bw_bmp, 0x00FF00FF, 0x0000FFFF);	// Some nasty colour combination
-				delay(2000);
+				waitDelayOrButton(2000);

 				PRINTLN_DEBUG("Now entering hour value");
 				rtc.setHour(changeSetting(rtc.getHour(h12, PM), 0, 23, disp_displayVal));
@@ -366,6 +362,24 @@
 }

+// Creates a delay loop that exits when either the time given
+// has passed, or one of the buttons has been pressed
+void waitDelayOrButton(uint16_t delayTime) {
+	unsigned long stopTime = millis() + delayTime;
+
+	waitWhilePressed();
+
+	while(millis() < stopTime) {
+		buttonsTick();
+
+		if(popEvent() != NO_EVENT) {
+			// Some event has happened, quit the loop early
+			break;
+		}
+	}
+}
+
+
 void exampleDisplayFunction(uint8_t value) {
 	PRINTLN_DEBUG(value);
 }


Fixed function naming error in NewController.

--- arduino/NewController/NewController.ino
+++ arduino/NewController/NewController.ino
@@ -69,7 +69,7 @@
   }
 }

-void messageAllOutputs(void) {
+void commandAllOutputs(void) {
   byte receivedByte, red, green, blue;
   // Verify payload length, if correct, read payload and set colors.
   if (readByte(receivedByte, characterTimeout) && receivedByte == '\x03')
@@ -80,7 +80,7 @@
         setOutputColor(output, red, green, blue);
 }

-void messageSingleOutput(void) {
+void commandSingleOutput(void) {
   byte receivedByte, red, green, blue, output;
   // Verify payload length, if correct, read payload and set output color.
   if (readByte(receivedByte, characterTimeout) && receivedByte == '\x04')


adding device code

adding device code

--- device_src/pull_alarm/pull_alarm.ino
+++ device_src/pull_alarm/pull_alarm.ino
@@ -44,6 +44,9 @@
         APIclient.readBytes(APIresponse, API_RESPONSE_ARRAY_SIZE);
         digitalWrite(LED_PIN, HIGH);
     }
+    else{
+        digitalWrite(LED_PIN, LOW);
+    }

     APIclient.stop();
     delay(6000);


Update Test

Update Test

--- examples/LLShitFullTest/LLShitFullTest.ino
+++ examples/LLShitFullTest/LLShitFullTest.ino
@@ -7,6 +7,9 @@
 #include <SpawwnNet.h>
 #include <LLShitCore.h>
 #include <LLShitFull.h>
+
+#define SDCARD_PIN 4
+#define SDCARD_SUPPORT_PIN 10

 namespace TESTMETRICS {
   enum{
@@ -18,14 +21,26 @@
     END_IDLE,
     NUM_RAM_VALUES
   };
+
+  enum{
+    LOG_0_FILE,
+    STRING_TABLE_ENUM_COUNT
+  };
+  const char LOG_0_FILE_STRING[] PROGMEM = "0.log";
+  const char DUMMY_STRING[] PROGMEM = "";
+  PGM_P const STRING_TABLE[] PROGMEM = {
+    LOG_0_FILE_STRING,
+    DUMMY_STRING
+  };
+
   #if defined(__AVR_ATmega2560__)
     const PROGMEM unsigned int ram[NUM_RAM_VALUES+1] = {
-      7274,
-      7269,
-      7265,
-      7265,
-      7261,
-      7277,
+      7273,
+      7268,
+      7264,
+      7264,
+      7260,
+      7276,
       0
     };
   #elif defined(__AVR_ATmega328P__)
@@ -83,6 +98,8 @@
   strcpy_P(event,PSTR("Testing Char*"));
   lls.writeEvent(event);
   delete(event);
+  loggerSize(lls);
+  loggerSize(lls);
   ramIs(TESTMETRICS::ram[TESTMETRICS::FULL_LOGGER_INSTANCE_MADE],lls);

   //Use Flash Mem to post an event
@@ -98,14 +115,52 @@
   strcpy_P(logPath,PSTR("logs/"));
   lls.setLogPath(logPath);
   delete(logPath);
-  ramIs(TESTMETRICS::ram[TESTMETRICS::FULL_LOGGER_INSTANCE_MADE]-4,lls);
+  ramIs(TESTMETRICS::ram[TESTMETRICS::FULL_LOGGER_INSTANCE_MADE]-4,lls);//subtract size difference of logPath - "" to "logs/"
   loggerSize(lls);
   FullLoggerStringTest(lls);
+}
+
+void deleteTestLogs(){
+  char buffer[13];
+  strcpy_P(buffer,(PGM_P)pgm_read_word(&(TESTMETRICS::STRING_TABLE[TESTMETRICS::LOG_0_FILE])));
+  SD.remove(buffer);
+}
+
+void dumpLog(const char* logName){
+  Serial.print(logName);
+  Serial.println(F(" Log Contents:"));
+  Serial.println(F("---------------------------------------"));
+  File fileHandle;
+  fileHandle = SD.open(logName);
+  if(fileHandle){
+    while(fileHandle.available()){
+      Serial.write(fileHandle.read());
+    }
+    fileHandle.close();
+  }else{
+    Serial.println(F("Error Opening File"));
+  }
+  Serial.println(F("---------------------------------------"));
+}
+
+void checkLogs(){
+  char* logName = new char[13];
+  strcpy_P(logName,(PGM_P)pgm_read_word(&(TESTMETRICS::STRING_TABLE[TESTMETRICS::LOG_0_FILE])));
+  dumpLog(logName);
+  delete(logName);
 }

 void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
+  while(!Serial){;}
+  pinMode(SDCARD_SUPPORT_PIN,OUTPUT);
+  digitalWrite(SDCARD_SUPPORT_PIN, HIGH);
+  if(!SD.begin(SDCARD_PIN)){
+    Serial.println(F("**** sd init failed ****\n"));
+  }else{
+    deleteTestLogs();
+  }

   ramIs(TESTMETRICS::ram[TESTMETRICS::START_IDLE],NULL);
   Serial.println(F("Starting BaseLogger Test"));
@@ -117,6 +172,9 @@
   Serial.println(F("Re-running Full Logger Test"));
   FullLoggerTest();
   ramIs(TESTMETRICS::ram[TESTMETRICS::START_IDLE],NULL);
+
+  checkLogs();
+
   Serial.println(F("Closing"));
   ramIs(TESTMETRICS::ram[TESTMETRICS::END_IDLE],NULL);
 }


Possible compiler difference between work stations... will investigate

--- examples/LLShitFullTest/LLShitFullTest.ino
+++ examples/LLShitFullTest/LLShitFullTest.ino
@@ -71,7 +71,8 @@
     return false;
   }
 }
-#define ramIs(target,obj) ramIsWorker(target,sizeof(obj),__LINE__)
+#define RAMMOD -18
+#define ramIs(target,obj) ramIsWorker(target+RAMMOD,sizeof(obj),__LINE__)

 void BaseLoggerTest(){
   ShitLoggerBase *lls;


Correct BLE serial example (#140)

Correct BLE serial example (#140)

--- examples/serial/serial.ino
+++ examples/serial/serial.ino
@@ -21,19 +21,19 @@
 #include "BLESerial.h"

 //custom boards may override default pin definitions with BLESerial(PIN_REQ, PIN_RDY, PIN_RST)
-BLESerial BLESerial();
+BLESerial bleSerial;

 void setup() {
   // custom services and characteristics can be added as well
-  BLESerial.setLocalName("UART");
+  bleSerial.setLocalName("UART");

   Serial.begin(115200);
-  BLESerial.begin();
+  bleSerial.begin();
 }

 void loop() {
-  BLESerial.poll();
+  bleSerial.poll();

   forward();
   // loopback();
@@ -43,26 +43,26 @@

 // forward received from Serial to BLESerial and vice versa
 void forward() {
-  if (BLESerial && Serial) {
+  if (bleSerial && Serial) {
     int byte;
-    while ((byte = BLESerial.read()) > 0) Serial.write((char)byte);
-    while ((byte = Serial.read()) > 0) BLESerial.write((char)byte);
+    while ((byte = bleSerial.read()) > 0) Serial.write((char)byte);
+    while ((byte = Serial.read()) > 0) bleSerial.write((char)byte);
   }
 }

 // echo all received data back
 void loopback() {
-  if (BLESerial) {
+  if (bleSerial) {
     int byte;
-    while ((byte = BLESerial.read()) > 0) BLESerial.write(byte);
+    while ((byte = bleSerial.read()) > 0) bleSerial.write(byte);
   }
 }

 // periodically sent time stamps
 void spam() {
-  if (BLESerial) {
-    BLESerial.print(millis());
-    BLESerial.println(" tick-tacks!");
+  if (bleSerial) {
+    bleSerial.print(millis());
+    bleSerial.println(" tick-tacks!");
     delay(1000);
   }
 }


h4x0r

--- ModifiedForMega/Pickup_sponge_Mega/Pickup_sponge_Mega.ino
+++ ModifiedForMega/Pickup_sponge_Mega/Pickup_sponge_Mega.ino
@@ -20,25 +20,24 @@
 #include <SoftwareSerial.h>

 #define SERVO_ControlPin 0x02       // Control pin of buffer chip, NOTE: this does not matter becasue we are not using a half to full contorl buffer.
-#define SERVO_SET_Baudrate 57600    // Baud rate speed which the Dynamixel will be set to (57600)
+#define SERVO_SET_Baudrate 57600    // Baud rate speed which the Dynamixel will be set too (57600)
 #define LED13 0x0D
 #define CW_LIMIT_ANGLE 0x001        // lowest clockwise angle is 1, as when set to 0 it set servo to wheel mode
 #define CCW_LIMIT_ANGLE 0xFFF       // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode
 #define OPEN 'o'
 #define CLOSE 'c'

-//SoftwareSerial mySerial(10, 11);    // RX, TX
+SoftwareSerial mySerial(10, 11);    // RX, TX

 void setup() {
   Serial.flush();                                       // Clear the serial buffer of garbage data before running the code.
-  Serial1.flush();
-  Serial1.begin(SERVO_SET_Baudrate);                    // We now need to set Ardiuno to the new Baudrate speed 115200
+  mySerial.begin(SERVO_SET_Baudrate);                   // We now need to set Ardiuno to the new Baudrate speed 115200
   Serial.begin(SERVO_SET_Baudrate);                                  // Start serial communication on baudrate 57600
-  Dynamixel.begin(Serial1);                             // Calling mySerial function which sets 10 pin as the 2nd RX serial pin, and sets pin 11 as the 2nd TX serial pin
+  Dynamixel.begin(mySerial);                            // Calling mySerial function which sets 10 pin as the 2nd RX serial pin, and sets pin 11 as the 2nd TX serial pin
   Dynamixel.setDirectionPin(SERVO_ControlPin);          // Optional. Set direction control pin which controls if the program writes or reads

   //Turn on hold for the servos, so they stay in place
-  Dynamixel.setHoldingTorque(0x01, true);               //Set on hold torque for each servo
+  Dynamixel.setHoldingTorque(0x01, true);               //Set on hold turque for each servo
   Dynamixel.setHoldingTorque(0x02, true);
   Dynamixel.setHoldingTorque(0x03, true);
   Dynamixel.setHoldingTorque(0x04, true);
@@ -52,12 +51,11 @@
   Dynamixel.setProfileAcceleration(0x05, 300);

   //Set profile velocity
-  Dynamixel.setProfileVelocity(0x01, 100);              //Set profile vel for each servo
+  Dynamixel.setProfileVelocity(0x01, 100);              //Set profile vel for each servo
   Dynamixel.setProfileVelocity(0x02, 100);
   Dynamixel.setProfileVelocity(0x03, 100);
   Dynamixel.setProfileVelocity(0x04, 200);
-  Dynamixel.setProfileVelocity(0x05, 200);
-  //Serial.println("reset");
+  Dynamixel.setProfileVelocity(0x05, 200);
  }

 void loop() {
@@ -75,12 +73,11 @@
   delay(2000);

-  Dynamixel.performMovement(1600, 2800, 3200, OPEN);      //Move to sponge.
+  Dynamixel.performMovement(1600, 2800, 3200, OPEN);      //Move to sponge.
   Dynamixel.gripper(CLOSE);                               //Grab
   Dynamixel.performMovement(2148, 1850, 3250, CLOSE);     //Detour
   Dynamixel.performMovement(2650, 2800, 3200, CLOSE);     //Move to destination
   delay(500);
   Dynamixel.gripper(OPEN);                                //Release
-  delay(500);
-
+delay(500);
 }


Update _2000_ESPert_workshop.ino

Update _2000_ESPert_workshop.ino

Remove fixed board type in workshop example.

--- examples/_2000_ESPert_workshop/_2000_ESPert_workshop.ino
+++ examples/_2000_ESPert_workshop/_2000_ESPert_workshop.ino
@@ -92,7 +92,7 @@
 }

 void setup() {
-  espert.init(2);
+  espert.init();
   delay(100);
   espert.buzzer.init(15);
   espert.dht.init();


remove unneeded register, change to 2g range default

--- examples/MMA8451demo/MMA8451demo.ino
+++ examples/MMA8451demo/MMA8451demo.ino
@@ -35,8 +35,7 @@
   }
   Serial.println("MMA8451 found!");

-  mma.setRange(MMA8451_RANGE_8_G);
-    mma.writeRegister8(MMA8451_REG_CTRL_REG4, 0x01);
+  mma.setRange(MMA8451_RANGE_2_G);

   Serial.print("Range = "); Serial.print(2 << mma.getRange());
   Serial.println("G");


Create init function

Create init function

--- examples/SimpleCycle/SimpleCycle.ino
+++ examples/SimpleCycle/SimpleCycle.ino
@@ -12,6 +12,7 @@

 void setup()
 {
+  leds.init();
 }

 byte pos = 0;


RF24_PA_LOW to RF24_PA_MIN

RF24_PA_LOW to RF24_PA_MIN

--- _25-attiny85-nrf24-ds18b20/_25-attiny85-nrf24-ds18b20.ino
+++ _25-attiny85-nrf24-ds18b20/_25-attiny85-nrf24-ds18b20.ino
@@ -72,7 +72,8 @@
   // radio begin to power down : 80 ms
   radio.begin();
   radio.setChannel(CHANNEL);
-  radio.setPALevel(RF24_PA_LOW);
+  //radio.setPALevel(RF24_PA_LOW);
+  radio.setPALevel(RF24_PA_MIN);
   radio.setDataRate(RF24_250KBPS);
   //radio.setAutoAck(1);
   radio.setRetries(15, 15);
@@ -136,7 +137,9 @@
   LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
   */
   /* 1 sec */
-  LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
+  LowPower.powerDown(SLEEP_500MS, ADC_OFF, BOD_OFF);
+  LowPower.powerDown(SLEEP_250MS, ADC_OFF, BOD_OFF);
+  LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_OFF);
 }

 int readVcc() {


Add copyright.

Add copyright.

--- microcontrollers/arduino-esp32/lora32-morse-beacon/lora32-morse-beacon.ino
+++ microcontrollers/arduino-esp32/lora32-morse-beacon/lora32-morse-beacon.ino
@@ -1,3 +1,22 @@
+/*
+ * Morse CW beacon for LoRa ESP32 board with OLED display.
+ *
+ * Copyright (c) 2018 Serge Vakulenko
+ *
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
 #include <SPI.h>
 #include <LoRa.h>
 #include <Wire.h>


examples/FirebaseNeoPixel: fix begin call and rebase

--- examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino
+++ examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino
@@ -27,9 +27,6 @@
 #define WIFI_SSID "SSID"
 #define WIFI_PASSWORD "PASSWORD"

-const int PIN=13;
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800);
-
 const int pixelPin = 13;
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, pixelPin, NEO_GRB + NEO_KHZ800);

@@ -51,7 +48,7 @@
   Serial.print("connected: ");
   Serial.println(WiFi.localIP());

-  Firebase.begin("example.firebaseio.com", "secret_or_token");
+  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
 }


Update McLighting.ino

Update McLighting.ino

- Delete pointers before reinitialization

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -101,6 +101,7 @@
 #endif

 void initDMA(uint16_t stripSize = NUMLEDS){
+  if (dma) delete dma;
 #ifdef USE_WS2812FX_DMA // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
   dma = new NeoEsp8266Dma800KbpsMethod(stripSize, 3);  //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
   //NeoEsp8266Dma400KbpsMethod dma = NeoEsp8266Dma400KbpsMethod(NUMLEDS, 3);  //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
@@ -109,16 +110,16 @@
   dma = new NeoEsp8266Uart0800KbpsMethod(stripSize, 3);
 #endif
 #ifdef USE_WS2812FX_UART2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
-   dma = new NeoEsp8266Uart1800KbpsMethod(stripSize, 3);
+  dma = new NeoEsp8266Uart1800KbpsMethod(stripSize, 3);
 #endif
   dma->Initialize();
 }
-  void DMA_Show(void) {
-    if(dma->IsReadyToUpdate()) {
-      memcpy(dma->getPixels(), strip->getPixels(), dma->getPixelsSize());
-      dma->Update();
-    }
-  }
+void DMA_Show(void) {
+  if(dma->IsReadyToUpdate()) {
+    memcpy(dma->getPixels(), strip->getPixels(), dma->getPixelsSize());
+    dma->Update();
+  }
+}
 #endif

 // ***************************************************************************
@@ -227,8 +228,14 @@
 // ***************************************************************************
 #include "request_handlers.h"

+neoPixelType RGBOrderOnStrip = NEO_GRB;
 //
 void initStrip(uint16_t stripSize = NUMLEDS, neoPixelType RGBOrder = NEO_GRB){
+  if (strip) {
+    if (strip->getLength() == stripSize && RGBOrderOnStrip == RGBOrder) return;
+    delete strip;
+    RGBOrderOnStrip = RGBOrder;
+  }
   strip = new WS2812FX(stripSize, PIN, RGBOrder + NEO_KHZ800);
   // Parameter 1 = number of pixels in strip
   // Parameter 2 = Arduino pin number (most are valid)
@@ -740,7 +747,9 @@
     if(server.hasArg("ct")){
       uint16_t pixelCt = server.arg("ct").toInt();
       if (pixelCt > 0) {
+        if(strip->isRunning()) strip->stop();
         initStrip(pixelCt);
+        if(mode != HOLD) mode = SET_MODE;
         DBG_OUTPUT_PORT.printf("/pixels: Count# %d\n", pixelCt);
       }
     }


Update rx5808-pro-diversityGc9n.ino

Update rx5808-pro-diversityGc9n.ino

--- rx5808-pro-diversityGc9n/rx5808-pro-diversityGc9n.ino
+++ rx5808-pro-diversityGc9n/rx5808-pro-diversityGc9n.ino
@@ -324,7 +324,7 @@
         #define MAX_MENU 5
         #define MENU_Y_SIZE 15

-        char menu_id=state_last_used-1;
+        char menu_id=2;//state_last_used-1;
         // Show Mode Screen
         if(state==STATE_SEEK_FOUND)
         {
@@ -390,7 +390,9 @@
             // draw mode select screen
             ////Serial.println (state);
             if (menu_id>4)
-            {drawScreen.mainMenuSecondPage(menu_id);}
+            {
+              drawScreen.mainMenuSecondPage(menu_id-5);
+            }
             else
             {
               drawScreen.mainMenu(menu_id);


Fixed format by padding zero

Fixed format by padding zero

--- arduino/tempLogger/tempLogger.ino
+++ arduino/tempLogger/tempLogger.ino
@@ -15,6 +15,7 @@
   @author Humane Interface Design Enterprise, Michigan Tech
     -Stephen Radachy
     -Nicholas Lanter
+    -Kyle Bray

     NOTES:
     1) AFTER SETTING THE TIME COMMENT IT OUT
@@ -44,7 +45,7 @@
 #include <avr/sleep.h>  //sleep library
 #include <DS3231.h> //clock
 #define DEBUG 1
-#define DEBUG_TO_SD 1
+#define DEBUG_TO_SD 0
 #define POWA 4    // pin 4 supplies power to microSD card breakout and temp sensor

 //Clock var's
@@ -194,20 +195,18 @@
   &year);

   // print to the serial port:
-  //yyyy-mm-dd hh:mm:ss,temperature
+  //yyyy-mm-dd hh:mm:ss
   Serial.print(year);
   Serial.print("-");
+  Serial.print(month);
+  Serial.print("-");
   Serial.print(dayOfMonth);
-  Serial.print("-");
-  Serial.print(day);
   Serial.print(" ");
   Serial.print(hour);
   Serial.print(":");
   Serial.print(minute);
   Serial.print(":");
   Serial.print(second);
-  Serial.print(",");
-  Serial.println(temp);

 }

@@ -261,18 +260,48 @@
   Serial.println("Printing Data:");
 #endif

+
+
+
   //print comma seperated values in form:
   //yyyy-mm-dd hh:mm:ss,temperature
+  //Pad with 20 to make year XXXX
+  dataFile.print("20");
   dataFile.print(year);
   dataFile.print("-");
+
+  //Pad with zero
+    if(month<10){
+      dataFile.print("0");
+    }
+  dataFile.print(month);
+  dataFile.print("-");
+
+  //Pad with zero
+    if(dayOfMonth<10){
+      dataFile.print("0");
+    }
   dataFile.print(dayOfMonth);
-  dataFile.print("-");
-  dataFile.print(day);
   dataFile.print(" ");
+
+  //Pad with zero
+    if(hour<10){
+      dataFile.print("0");
+    }
   dataFile.print(hour);
   dataFile.print(":");
+
+  //Pad with zero
+    if(minute<10){
+      dataFile.print("0");
+    }
   dataFile.print(minute);
   dataFile.print(":");
+
+  //Pad with zero
+    if(second<10){
+      dataFile.print("0");
+    }
   dataFile.print(second);
   dataFile.print(",");
   dataFile.println(temp);
@@ -441,3 +470,4 @@
   }

 }
+


[4Digit7Segment/SingleShift] refactor code to take numeric processing out of the ISR

--- playground/Led4Digit7Segment/SingleShift/SingleShift.ino
+++ playground/Led4Digit7Segment/SingleShift/SingleShift.ino
@@ -19,6 +19,29 @@
 #define DIGIT_BASE_PIN 6
 #define DIGITS 4

+// the number we'll be updating and using for display
+int my_counter = 0;
+
+void setup() {
+  pinMode(ST_CP_LATCH_PIN, OUTPUT);
+  pinMode(SH_CP_CLOCK_PIN, OUTPUT);
+  pinMode(DS_DATA_PIN, OUTPUT);
+  for(int p=0; p<DIGITS; p++) {
+    pinMode(DIGIT_BASE_PIN + p, OUTPUT);
+  }
+
+  FlexiTimer2::set(1, redrawLedDisplay); // update an LED character every 5ms
+  FlexiTimer2::start();
+}
+
+void loop() {
+  // increment a number every little while
+  delay(100);
+  if(my_counter++ >= 9999) my_counter = 0;
+  pushToLedDisplay(my_counter, false, 1);
+}
+
+
 // define the bitmasks for characters 0-9
 byte LED_DIGIT_MASK[] = {
   0b00111111,
@@ -36,42 +59,43 @@
 #define LED_CLEAR_MASK 0b00000000
 #define LED_DP_MASK    0b10000000

-volatile int number_for_display = 0;   // the number we'll display on the LED unit
-volatile byte current_digit = 0;       // 0-3 left to right
+volatile byte display_values[] = {0,0,0,0}; // current display values for each digit
+volatile byte current_digit = 0;            // 0-3 left to right

-void setup() {
-  pinMode(ST_CP_LATCH_PIN, OUTPUT);
-  pinMode(SH_CP_CLOCK_PIN, OUTPUT);
-  pinMode(DS_DATA_PIN, OUTPUT);
-  for(int p=0; p<DIGITS; p++) {
-    pinMode(DIGIT_BASE_PIN + p, OUTPUT);
+// Command: submit +value+ for display.
+// If +leading_zeros+ is true, display leading zeros, else blank.
+// If +scale+ >= 0, place decimal point at 10^-scale
+void pushToLedDisplay(int value, boolean leading_zeros, int scale) {
+  if(!leading_zeros && value<1000) {
+    display_values[0] = LED_CLEAR_MASK;
+  } else {
+    display_values[0] = LED_DIGIT_MASK[value/1000 % 10];
   }
-
-  FlexiTimer2::set(5, redrawLedDisplay); // update an LED character every 5ms
-  FlexiTimer2::start();
+  if(!leading_zeros && value<100) {
+    display_values[1] = LED_CLEAR_MASK;
+  } else {
+    display_values[1] = LED_DIGIT_MASK[value/100 % 10];
+  }
+  if(!leading_zeros && value<10) {
+    display_values[2] = LED_CLEAR_MASK;
+  } else {
+    display_values[2] = LED_DIGIT_MASK[value/10 % 10];
+  }
+  display_values[3] = LED_DIGIT_MASK[value % 10];
+  if(scale >= 0) display_values[3-scale] = display_values[3-scale] ^ LED_DP_MASK;
+}
+// Command: submit +value+ for display, no leading zeroes or decimal point
+void pushToLedDisplay(int value) {
+  pushToLedDisplay(value, false, -1);
 }

-void loop() {
-  // increment a number every little while
-  delay(100);
-  if(number_for_display<9999) number_for_display += 1;
-  else number_for_display = 0;
-}
-
-
+// Command: update the LED display
 void redrawLedDisplay() {
   // stop glowing the current digit and move to the next
   digitalWrite(DIGIT_BASE_PIN + current_digit, LOW);
-  current_digit++;
-  if(current_digit>3) current_digit = 0;
-
-  // do some gymnastics to figure out which number to display for this digit
-  int digit_scale = 1;
-  for(byte s=3; s>current_digit; s--) digit_scale = digit_scale * 10;
-  byte digit_value = (number_for_display / digit_scale) % 10;
-
+  if(current_digit++ > 3) current_digit = 0;
   // push the digit to the LED display
-  pushSegmentRegister(LED_DIGIT_MASK[digit_value]);
+  pushSegmentRegister(display_values[current_digit]);
   digitalWrite(DIGIT_BASE_PIN + current_digit, HIGH);
 }


Baudios to 19200

Baudios to 19200

--- HC06_BT_config/HC06_BT_config.ino
+++ HC06_BT_config/HC06_BT_config.ino
@@ -1,46 +1,46 @@
-/*
-	http://giltesa.com/?p=11738
-	09/08/2012
-	(CC) BY-NC-SA: giltesa.com
-
-ConfigBluetooth HC-06 from Arduino.
-Change name, password and baud using serial port, only configurate one time
-After upload code you have 10 seconds to connect the module
-BT ---- Arduino
-TX ----> RX
-RX <---- TX
-
-Once the LED off configuration will start and at the end LED will blink
-After this you can pair your module
-*/
-// Options:
-
-	char ssid[10]		= "Zowi";	// Name for Bluetooth.
-	char baudios		 = '8';		   // 1=>1200 baudios, 2=>2400, 3=>4800, 4=>9600 (default), 5=>19200, 6=>38400, 7=>57600, 8=>115200
-	char password[10]	= "1234";		// Password for pairing
-
-void setup()
-{
-	Serial.begin(9600);
-
-	// Waiting time (10 seconds):
-		pinMode(9,OUTPUT);
-		digitalWrite(9,HIGH);
-		delay(10000);
-		digitalWrite(9,LOW);
-
-Serial.print("AT"); delay(1000); // Now configuration start
-
-Serial.print("AT+NAME"); Serial.print(ssid); delay(1000);   // Change Name of BT
-
-Serial.print("AT+BAUD"); Serial.print(baudios); delay(1000);    // Change Baud
-
-Serial.print("AT+PIN"); Serial.print(password); delay(1000);	    // Change Password
-}
-
-void loop()
-{
-	// After LED Blinking is finish.
-	digitalWrite(9, !digitalRead(9));
-	delay(500);
+/*
+	http://giltesa.com/?p=11738
+	09/08/2012
+	(CC) BY-NC-SA: giltesa.com
+
+ConfigBluetooth HC-06 from Arduino.
+Change name, password and baud using serial port, only configurate one time
+After upload code you have 10 seconds to connect the module
+BT ---- Arduino
+TX ----> RX
+RX <---- TX
+
+Once the LED off configuration will start and at the end LED will blink
+After this you can pair your module
+*/
+// Options:
+
+	char ssid[10]		= "Zowi";	// Name for Bluetooth.
+	char baudios		 = '5';		   // 1=>1200 baudios, 2=>2400, 3=>4800, 4=>9600 (default), 5=>19200, 6=>38400, 7=>57600, 8=>115200
+	char password[10]	= "1234";		// Password for pairing
+
+void setup()
+{
+	Serial.begin(19200);
+
+	// Waiting time (10 seconds):
+		pinMode(9,OUTPUT);
+		digitalWrite(9,HIGH);
+		delay(10000);
+		digitalWrite(9,LOW);
+
+Serial.print("AT"); delay(1000); // Now configuration start
+
+Serial.print("AT+NAME"); Serial.print(ssid); delay(1000);   // Change Name of BT
+
+Serial.print("AT+BAUD"); Serial.print(baudios); delay(1000);    // Change Baud
+
+Serial.print("AT+PIN"); Serial.print(password); delay(1000);	    // Change Password
 }
+
+void loop()
+{
+	// After LED Blinking is finish.
+	digitalWrite(9, !digitalRead(9));
+	delay(500);
+}


Debugging mode improvements

Debugging mode improvements

Cleaned up debugging mode code

--- csarc/csarc.ino
+++ csarc/csarc.ino
@@ -48,13 +48,11 @@
   if (input!="") { // if connected
     switch (input[0]) {

-      case 'd': { //enables debug mode, lowercase commands
+      case 'd': {
         DEBUG=!DEBUG;
         Serial.print("Debug mode ");
-        if (DEBUG)
-          Serial.println("ON");
-         else
-          Serial.println("OFF");
+        if(DEBUG)Serial.println("ON");
+         else    Serial.println("OFF");
         break;
       }

@@ -62,30 +60,25 @@
         char colorInput[] = {input[1],input[2],input[3],input[4],input[5],input[6],input[7],'\0'}; // who needs loops
         if (DEBUG) {
           Serial.print("Serial input:");
-          Serial.println(colorInput);
-        }
-
+          Serial.println(colorInput);  }
         decodeHex(colorInput,rgb);
         setOutput(rgb);
-
         printColors();
-
         if (DEBUG) {
           Serial.println("Color set.  Results:");
-          Serial.print("red: ");
-          Serial.println(red, DEC);
-          Serial.print("green: ");
-          Serial.println(green, DEC);
-          Serial.print("blue: ");
-          Serial.println(blue, DEC);
-          Serial.println("");
-        }
-
+          Serial.print("red: ");  Serial.println(red, DEC);
+          Serial.print("green: ");Serial.println(green, DEC);
+          Serial.print("blue: "); Serial.println(blue, DEC);
+          Serial.println(""); }
         break;
       }
+
     case 'G' : {
-        // run gradient pulse between a and b with appropriate timestep; "G#000000:#123456:time" input
-        if (input[1]=='#' && input[9]=='#') {
+        // run gradient pulse between a and b over a length of time; "G#000000:#123456:time" input
+        if ((input[1]!='#' || input[9]!='#')) {
+          Serial.println("Error: invalid gradient request");
+          Serial.println(input);
+        } else {
           char hex1[8], hex2[8];
           char timev[8]; //well our buffer is 7 chars now.
           for (int x=0; x<7; x++) {
@@ -96,28 +89,64 @@
           int col1[4],col2[4];
           int *col1p[4] = {&col1[0],&col1[1],&col1[2],0};
           int *col2p[4] = {&col2[0],&col2[1],&col2[2],0};
+
           decodeHex(hex1,col1p);
           decodeHex(hex2,col2p);
-
           float timeVal = atoi(timev); //use strtol or sscanf instead

           gradientPulse(col1,col2,timeVal);
-
+
           if (DEBUG) {
             Serial.println(hex1);
             Serial.println(hex2);
-            Serial.println(timev);
+            Serial.println(timev); }
+        }
+        break;
+      }
+
+      // begin debugging char commands go here
+
+
+    }
+
+    if (DEBUG) {
+      switch(input[0]) {
+        case '0' : {
+          setValue(0,0,0);
+          Serial.println("LEDs turned off.");
+          break; }
+        case '1' : {
+          setValue(255,255,0);
+          Serial.println("LEDs turned on.");
+          break; }
+        case 'r' : {
+          setValue(255,0,0);
+          Serial.println("Color set to red.");
+          break;
+        }
+        case 'g' : {
+          setValue(0,255,0);
+          Serial.println("Color set to green.");
+          break;
+        }
+        case 'b' : {
+          setValue(0,0,255);
+          Serial.println("Color set to blue.");
+          break;
+        }
+        case '?' : { // display contents of *rgb: three colors and a null pointer
+          Serial.println("Current color values:");
+          for (int i=0; i<3; i++) {
+            Serial.print(*rgb[i]); Serial.print(',');
           }
-        } else {
-          Serial.println("Error: malformed gradient request");
-          Serial.println(input);
-        }
-        break;
-      }
-
-      // begin debugging char commands
-
-
+          Serial.println(*rgb[3]);
+        }
+//        case
+
+      }
+
+
+
     }
   } else {
     // no input;
@@ -241,3 +270,9 @@
   if (blue<=16) {Serial.print('0');}
   Serial.println(blue, HEX);
 }
+
+void setValue ( int r, int g, int b) {
+  red=r; green=g; blue=b;
+  setOutput(rgb);
+}
+


Just a capitalization change to have consistent style

No functional difference.

--- examples/06-AppTutorial/01-BasicGain_wApp/01-BasicGain_wApp.ino
+++ examples/06-AppTutorial/01-BasicGain_wApp/01-BasicGain_wApp.ino
@@ -89,12 +89,12 @@
     case 'k':
       changeGain(3.0);
       printGainLevels();
-      SetButtonText("gainIndicator", String(digital_gain_dB));
+      setButtonText("gainIndicator", String(digital_gain_dB));
       break;
     case 'K':
       changeGain(-3.0);
       printGainLevels();
-      SetButtonText("gainIndicator", String(digital_gain_dB));
+      setButtonText("gainIndicator", String(digital_gain_dB));
       break;
   }
 }
@@ -148,6 +148,6 @@
   myTympan.println(digital_gain_dB); //print text to Serial port for debugging
 }

-void SetButtonText(String btnId, String text) {
+void setButtonText(String btnId, String text) {
   myTympan.println("TEXT=BTN:" + btnId + ":"+text);
 }


the main program

the main program

debugged version...not yet tested

--- main_rev1/main_rev1.ino
+++ main_rev1/main_rev1.ino
@@ -3,39 +3,40 @@
 ==== ======
 rev v.1

+adaptive lighting
+al-adaptive lighting
+
+external lighting
+el-external lighting
+
+water pump system
+pc-pumpcontrol
+
+temperature mesuring system
+tm-temperature measurement
+
+preprosessor definitions:
+al
 */

-//adaptive lighting
-//al-adaptive lighting

-//external lighting
-//el-external lighting
-
-//water pump system
-//pc-pumpcontrol
-
-//temperature mesuring system
-//tm-temperature measurement
-
-//preprosessor definitions:
-//al
 #define alinput A0
 #define aloutput 9
-#define alinterrupt 2
-#define aloverride 3
+#define aloverride 2
+#define altoggle 3

 //el
 #define elinput A1
 #define eloutput 10
 #define treshold 500
-#define elinterrupt 4
-#define eloverride 5
+#define eloverride 4
+#define eltoggle 5

 //pc
 #define pcinput A2
 #define pcoutput 11
-#define pcinterrupt 6
-#define pcoverride 7
+#define pcoverride 6
+#define pctoggle 7

 //tm
 #define tminput A3
@@ -60,12 +61,12 @@
 {
   Serial.begin(9600);
   //al
-  pinMode(alinterrupt,INPUT);
   pinMode(aloverride,INPUT);
+  pinMode(altoggle,INPUT);
   //el
   pinMode(eloutput,OUTPUT);
-  pinMode(elinterrupt,INPUT);
   pinMode(eloverride,INPUT);
+  pinMode(eltoggle,INPUT);
   elstate=0;
   //pc
   pinMode(pcinput,INPUT);
@@ -78,56 +79,79 @@
 //loop function:
 void loop()
 { //al
-  alsensor = analogRead(alinput); //read the sensor value
-  albrightness = alsensor / 4; //convert the value from 10-bit resolution to 8-bit res
-  alvoltage = alsensor * (5.0 / 1024.0); //convert the value into actual voltage range 0-5V
-  Serial.print("The voltage is: ");  //prints the voltage through serial
-  Serial.println(alvoltage);
-  analogWrite(aloutput,albrightness); //output the PWM to the LED
-  while(digitalRead(alinterrupt)) //interrupt function
-  { if(digitalRead(aloverride)) //override - ON
+  if(!digitalRead(aloverride))
+  { alsensor = analogRead(alinput); //read the sensor value
+    albrightness = alsensor / 4; //convert the value from 10-bit resolution to 8-bit res
+    alvoltage = alsensor * (5.0 / 1024.0); //convert the value into actual voltage range 0-5V
+    Serial.print("The voltage is: ");  //prints the voltage through serial
+    Serial.println(alvoltage);
+    analogWrite(aloutput,albrightness); //output the PWM to the LED
+  }
+  else //override function
+  { if(digitalRead(altoggle)) //toggle - ON
      analogWrite(aloutput,255);
-    else //override - OFF
+    else //toggle - OFF
      analogWrite(aloutput,0);
   }
   delay(500);

   //el
-  elsensor=analogRead(elinput);
-  if((elsensor>treshold) && (elstate==0))
-  { digitalWrite(eloutput,HIGH);
-    Serial.println("External light is ON");
-    elstate=1;
+  if(!digitalRead(eloverride))
+  { elsensor=analogRead(elinput);
+    if((elsensor>treshold) && (elstate==0))
+    { digitalWrite(eloutput,HIGH);
+      Serial.println("External light is ON");
+      elstate=1;
+    }
+    else if((elsensor<treshold) && (elstate==1))
+    { digitalWrite(eloutput,LOW);
+      Serial.println("External light is OFF");
+      elstate=0;
+    }
   }
-  else if((elsensor<treshold) && (elstate==1))
-  { digitalWrite(eloutput,LOW);
-    Serial.println("External light is OFF");
-    elstate=0;
+  else //override function
+  { if(digitalRead(eltoggle));
+    { digitalWrite(eloutput,HIGH);
+      Serial.println("External light is ON-toggle");
+    }
+    else
+    { digitalWrite(eloutput,LOW);
+      Serial.println("External light is OFF-toggle");
+    }
   }
-  while(digitalRead(elinterrupt)) //interrupt function
-  { digitalWrite(eloutput,digitalRead(eloverride));
-   Serial.println("External light is ON-Override");
-  }
-  delay(500);

   //pc
-  pcsensor = digitalRead(pcinput);
-  if(pcsensor!=pcstate)
-  {
-    if(pcsensor == 1)
-    { digitalWrite(pcoutput,HIGH);
-      Serial.println("Motor is ON");
-      pcstate = pcsensor;
-    }
-    else
-    { digitalWrite(pcoutput,LOW);
-      Serial.println("Motor is OFF");
-      pcstate = pcsensor;
+  if(!digitalRead(pcoverride))
+  { pcsensor = digitalRead(pcinput);
+    if(pcsensor!=pcstate)
+    { if(pcsensor == 1)
+      { digitalWrite(pcoutput,HIGH);
+        Serial.println("Motor is ON");
+        pcstate = pcsensor;
+      }
+      else
+      { digitalWrite(pcoutput,LOW);
+        Serial.println("Motor is OFF");
+        pcstate = pcsensor;
+      }
     }
   }
-  while(digitalRead(pcinterrupt)) //interrupt function
-   digitalWrite(pcoutput,digitalRead(pcoverride));
-  delay(500);
+  else //override function
+  { pcsensor = digitalRead(pctoggle);
+    if(pcstate!=pcsensor)
+    { if(pcsensor == 1)
+      { digitalWrite(pcoutput,HIGH);
+        Serial.println("Motor is ON - toggle");
+        pcstate = pcsensor;
+      }
+      else
+      { digitalWrite(pcoutput,LOW);
+        Serial.println("Motor is OFF - toggle");
+        pcstate = pcsensor;
+      }
+    }
+  }
+

   //tm
   tm=analogRead(tminput);//read the temperature value


compass example: removed extraneous defines

--- ZumoMotors/examples/CompassExample/CompassExample.ino
+++ ZumoMotors/examples/CompassExample/CompassExample.ino
@@ -32,9 +32,6 @@

 // Allowed deviation (in degrees) relative to target angle that must be achieved before driving straight
 #define DEVIATION_THRESHOLD 5
-
-#define DEVIATION_RIGHT_THRESHOLD   DEVIATION_THRESHOLD
-#define DEVIATION_LEFT_THRESHOLD    (360 - DEVIATION_THRESHOLD)

 ZumoMotors motors;
 Pushbutton button(ZUMO_BUTTON);


better description in the comments

better description in the comments

--- examples/SimpleCommandParsing/SimpleCommandParsing.ino
+++ examples/SimpleCommandParsing/SimpleCommandParsing.ino
@@ -1,6 +1,6 @@
 //Parser expects commands to be separated by semicolons (;) and will ignore input that is not terminated this way
 //To test, send commands like "p;" or "s;"
-//Parser also processes command indices (ie "p1;" "t5")
+//Parser also processes command indices (ie "p1;" "t5;")
 //and space-separated data (ie "p 123;")
 //or all of the above (ie "p1 1234,64356;")
 #include "SerialCmdParser.h"


Back to strcmp for safer compare; init brightness

--- battlestation/arduino/arduino.ino
+++ battlestation/arduino/arduino.ino
@@ -30,7 +30,7 @@
 #define TEAMS 3
 static uint32_t team_colors[TEAMS];

-static char cmd[32];
+static char cmd[20];
 static byte cmd_idx = 0;

 void setup() {
@@ -44,6 +44,7 @@
     score_strips[i] = new Adafruit_NeoPixel(SCORE_STRIP_LEDS, score_pins[i], NEO_GRB + NEO_KHZ800);
     score_strips[i]->begin();
     for (byte l = 0; l < SCORE_STRIP_LEDS; l++) {
+      score_strips[i]->setBrightness(l, 255);
       score_strips[i]->setPixelColor(l, 0, 0, 0);
     }
     score_strips[i]->show();
@@ -82,14 +83,14 @@
   boolean ok = false;
   char * tok = NULL;
   const char * cmd_name = strtok_r(cmd, " ", &tok);
-  if (cmd_name[0] == 's') {
+  if (strcmp(cmd_name, "s") == 0) {
     ok = exec_score(tok);
-  } else if (cmd_name[0] == 'f') {
+  } else if (strcmp(cmd_name, "f") == 0) {
     ok = exec_flash(tok);
-  } else if (cmd_name[0] == 'p') {
+  } else if (strcmp(cmd_name, "p") == 0) {
     // the "ok" is the result
     ok = true;
-  } else if (cmd_name[0] == 'h') {
+  } else if (strcmp(cmd_name, "h") == 0) {
     Serial.println("f(lash) s");
     Serial.println("h(elp)");
     Serial.println("s(core) s t # t # t #");
@@ -117,6 +118,7 @@
     return false;
   }
   flash(*score_strips[strip], Adafruit_NeoPixel::Color(255, 255, 0), 5, 80);
+  return true;
 }

 boolean exec_score(char * tok) {


sonar driver synchronous fix

sonar driver synchronous fix

--- ThingThree/Code/OpenCM/OpenCM.ino
+++ ThingThree/Code/OpenCM/OpenCM.ino
@@ -16,7 +16,7 @@
 		Dxl.goalPosition(5,1024-GRIPPER_OPEN);
 	} else {
 		Dxl.goalPosition(4,GRIPPER_CLOSED);
-		Dxl.goalPosition(5,1024-GRIPPER_CLOSED);
+		Dxl.goalPosition(5,1024-GRIPPER_CLOSED);
 	}
 }

@@ -33,14 +33,14 @@
 	for (int id=1; id<6; id++) {
 		Dxl.jointMode(id);
 		Dxl.ledOn(id);
-	}
+	}

 	Dxl.writeWord(BROADCAST_ID,11,100);

 	Dxl.goalPosition(1, START_1);
 	Dxl.goalPosition(2, START_2);
 	Dxl.goalPosition(3, START_3);
-
+
 	for (int i=0; i<5; i++) {
 		gripper(i%2);
 		delay(500);
@@ -54,27 +54,27 @@

 boolean readInt(int *outVal) {
 	byte inBuffer[sizeof(short)];
-
+

 	for (int i=0; i<sizeof(short); i++) {
 		inBuffer[i] = blockingRead();
 	}
-
-	*outVal = *((short*)inBuffer);
-	return true;
+
+	*outVal = *((short*)inBuffer);
+	return true;
 }

 void processWrite(byte cmd, byte id) {
 	int val;
 	readInt(&val);

-  	switch (cmd) {
+  	switch (cmd) {
 		case 's': { // set speed
 			Dxl.goalSpeed(id, val);
 			break;
 		} case 'p': { // move to position
 			Dxl.goalPosition(id, val);
-			break;
+			break;
 		} case 'o': {
 			gripper(true);
 			break;
@@ -85,11 +85,11 @@
 			Dxl.maxTorque(id,val);
 			break;
 		} case 'g': { // general write command
-			int add;
-			if (!readInt(&add)) break;
+			int add;
+			if (!readInt(&add)) break;
 			Dxl.writeWord(id, add, val);
 			break;
-
+
 			// examples of using writeWord()
 			//Dxl.writeWord(id, 30, val); //move to Goal Position
 			//Dxl.writeWord(id, 32, val); //move at Speed
@@ -120,15 +120,15 @@
 			break;
 		} case 'v': {
 			digitalWrite(SONAR_TRIGGER, HIGH);
-  			delay(10);
-
+  			delay(1);
+			digitalWrite(SONAR_TRIGGER, LOW);
+
   			int sonarOne = analogRead(SONAR_LEFT);
-    			int sonarTwo = analogRead(SONAR_RIGHT);
-
+    		int sonarTwo = analogRead(SONAR_RIGHT);
+
   			Serial2.println(sonarOne);
   			Serial2.println(sonarTwo);
-
-			digitalWrite(SONAR_TRIGGER, LOW);
+
 			break;
 		}
 	}
@@ -145,5 +145,3 @@
 		else processRead(cmd, id);
 	}
 }
-
-


Pull those changes back out, we don't start parsing HS NMEA unless it has _alread_ been validated.

--- mega/mega.ino
+++ mega/mega.ino
@@ -2297,14 +2297,9 @@
   {
     a_string = nmea_read_buffer;
     nmea_read_buffer = hsnmea_read_buffer;
-    if(validate_nmea_buffer())
-    {
-      parse_nmea_sentence();
-    }
+    parse_nmea_sentence();
     nmea_read_buffer = a_string;
   }
-
-
 }

 void update_nmea()


Added flush

Added flush

--- wifi_robot/wifi_robot.ino
+++ wifi_robot/wifi_robot.ino
@@ -12,8 +12,8 @@
   int front, back;
   sp();
   Serial.println("Clearing buffers...");
-  while(Serial1.available()) Serial1.read();
-  while(Serial2.available()) Serial2.read();
+	Serial1.flush();
+  Serial2.flush();
   do {
     Serial.println("Waiting for front sensor...");
     while(!Serial1.available()) {


Expanded Webserver, changed Baudrate

Expanded Webserver, changed Baudrate

--- esp8266_wifi_duck/esp8266_wifi_duck.ino
+++ esp8266_wifi_duck/esp8266_wifi_duck.ino
@@ -7,7 +7,11 @@
 #include <EEPROM.h>
 #include "data.h"

-#define BAUD_RATE 115200
+#include "Settings.h"
+
+#define BAUD_RATE 57200
+#define bufferSize 600
+#define debug false

 /* ============= CHANGE WIFI CREDENTIALS ============= */
 const char *ssid = "WiFi Duck";
@@ -17,44 +21,51 @@
 AsyncWebServer server(80);
 FSInfo fs_info;

+Settings settings;
+
+bool shouldReboot = false;
+
+//Web stuff
 extern const uint8_t data_indexHTML[] PROGMEM;
 extern const uint8_t data_updateHTML[] PROGMEM;
 extern const uint8_t data_error404[] PROGMEM;
 extern const uint8_t data_styleCSS[] PROGMEM;
 extern const uint8_t data_functionsJS[] PROGMEM;
+extern const uint8_t data_liveHTML[] PROGMEM;
+extern const uint8_t data_infoHTML[] PROGMEM;
+extern const uint8_t data_nomalizeCSS[] PROGMEM;
+extern const uint8_t data_skeletonCSS[] PROGMEM;
+extern const uint8_t data_license[] PROGMEM;
+extern const uint8_t data_settingsHTML[] PROGMEM;
+extern const uint8_t data_viewHTML[] PROGMEM;
+
 extern String formatBytes(size_t bytes);

+//Script stuff
 bool runLine = false;
 bool runScript = false;
 File script;

-bool shouldReboot = false;
-
-const int bufferSize = 600;
 uint8_t scriptBuffer[bufferSize];
 uint8_t scriptLineBuffer[bufferSize];
 int bc = 0; //buffer counter
 int lc = 0; //line buffer counter

+
 void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
   File f;
-  String _name = filename;
-
-  if(!_name.startsWith("/")) _name = "/"+_name;
-
-  if(!index){
-    //Serial.printf("UploadStart: %s\n", filename.c_str());
-    f = SPIFFS.open(_name, "w");
-  } else{
-    f = SPIFFS.open(_name, "a");
-  }
-
-  //Serial.write(data,len);
+
+  if(!filename.startsWith("/")) filename = "/" + filename;
+
+  if(!index) f = SPIFFS.open(filename, "w"); //create or trunicate file
+  else f = SPIFFS.open(filename, "a"); //append to file (for chunked upload)
+
+  if(debug) Serial.write(data, len);
   f.write(data, len);

-  if(final){
-    //Serial.printf("UploadEnd: %s, %u B\n", filename.c_str(), index+len);
-    f.close();
+  if(final){ //upload finished
+	  if(debug) Serial.printf("UploadEnd: %s, %u B\n", filename.c_str(), index+len);
+	  f.close();
   }
 }

@@ -69,89 +80,205 @@
   request->send(response);
 }

+void sendSettings(AsyncWebServerRequest *request) {
+	AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_settingsHTML, sizeof(data_settingsHTML));
+	request->send(response);
+}
+
 void setup() {

   Serial.begin(BAUD_RATE);
   delay(2000);
-  Serial.println();
-
-  //Serial.println(WiFi.SSID());
-  WiFi.mode(WIFI_STA);
-  WiFi.softAP(ssid,password);
-
+  if(debug) Serial.println("\nstarting...\nSSID: "+ (String)ssid +"\nPassword: "+ (String)password);
+
   EEPROM.begin(4096);
   SPIFFS.begin();
-
+
+  settings.load();
+  if(debug) settings.print();
+
+  if(settings.autoExec) {
+	  String _name = (String)settings.autostart;
+	  script = SPIFFS.open("/" + _name, "r");
+	  runScript = true;
+	  runLine = true;
+  }
+
+  WiFi.mode(WIFI_STA);
+  WiFi.softAP(settings.ssid, settings.password, settings.channel, settings.hidden);
+
+  // ===== WebServer ==== //
   MDNS.addService("http","tcp",80);

-  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
-    AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_indexHTML, sizeof(data_indexHTML));
-    request->send(response);
-  });
-
-  server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){
-    AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", data_styleCSS, sizeof(data_styleCSS));
-    request->send(response);
-  });
-
-  server.on("/functions.js", HTTP_GET, [](AsyncWebServerRequest *request){
-    AsyncWebServerResponse *response = request->beginResponse_P(200, "text/javascript", data_functionsJS, sizeof(data_functionsJS));
-    request->send(response);
-  });
-
-
-  server.on("/list.json", HTTP_GET, [](AsyncWebServerRequest *request){
-    SPIFFS.info(fs_info);
-    Dir dir = SPIFFS.openDir("");
-    String output;
-    output += "{";
-    output += "\"totalBytes\":"+(String)fs_info.totalBytes+",";
-    output += "\"usedBytes\":"+(String)fs_info.usedBytes+",";
-    output += "\"list\":[ ";
-    while(dir.next()){
-      File entry = dir.openFile("r");
-      String filename = String(entry.name()).substring(1);
-      output += '{';
-      output += "\"n\":\""+filename+"\",";//name
-      output += "\"s\":\""+formatBytes(entry.size())+"\"";//size
-      output += "},";
-      entry.close();
-    }
-    output = output.substring(0, output.length()-1);
-    output += "]}";
-    request->send(200, "text/json", output);
-  });
-
-  server.on("/view", HTTP_GET, [](AsyncWebServerRequest *request){
-    if(request->hasArg("n")){
-      String _name = request->arg("n");
+  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_indexHTML, sizeof(data_indexHTML));
+	  request->send(response);
+  });
+  server.on("/index.html", HTTP_GET, sendToIndex);
+
+  server.on("/live.html", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_liveHTML, sizeof(data_liveHTML));
+	  request->send(response);
+  });
+
+  server.on("/view.html", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_viewHTML, sizeof(data_viewHTML));
+	  request->send(response);
+  });
+
+  server.on("license", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/plain", data_license, sizeof(data_license));
+	  request->send(response);
+  });
+
+  server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", data_styleCSS, sizeof(data_styleCSS));
+	  request->send(response);
+  });
+
+  server.on("/normalize.css", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", data_nomalizeCSS, sizeof(data_nomalizeCSS));
+	  request->send(response);
+  });
+
+  server.on("/skeleton.css", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", data_skeletonCSS, sizeof(data_skeletonCSS));
+	  request->send(response);
+  });
+
+  server.on("/functions.js", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/javascript", data_functionsJS, sizeof(data_functionsJS));
+	  request->send(response);
+  });
+
+  server.on("/info.html", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_infoHTML, sizeof(data_infoHTML));
+	  request->send(response);
+  });
+
+  server.on("/settings.html", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  sendSettings(request);
+  });
+
+  server.on("/settings.html", HTTP_POST, [](AsyncWebServerRequest *request) {
+
+	  if(request->hasArg("ssid")) {
+		  String _ssid = request->arg("ssid");
+		  settings.ssidLen = _ssid.length();
+		  _ssid.toCharArray(settings.ssid, 32);
+		  if(debug) Serial.println("new SSID = '"+_ssid+"'");
+	  }
+	  if(request->hasArg("pswd")) {
+		  String _pswd = request->arg("pswd");
+		  settings.passwordLen = _pswd.length();
+		  _pswd.toCharArray(settings.password, 32);
+		  if(debug) Serial.println("new password = '" + _pswd + "'");
+	  }
+	  if(request->hasArg("autostart")) {
+		  String _autostart = request->arg("autostart");
+		  settings.autostartLen = _autostart.length();
+		  _autostart.toCharArray(settings.autostart, 32);
+		  if(debug) Serial.println("new autostart = '" + _autostart + "'");
+	  }
+	  if(request->hasArg("ch")) settings.channel = request->arg("ch").toInt();
+	  if(request->hasArg("hidden")) settings.hidden = true;
+	  else settings.hidden = false;
+	  if(request->hasArg("autoExec")) settings.autoExec = true;
+	  else settings.autoExec = false;
+
+	  settings.save();
+	  if(debug) settings.print();
+
+	  sendSettings(request);
+  });
+
+  server.on("/settings.json", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  String output = "{";
+	  output += "\"ssid\":\"" + (String)settings.ssid + "\",";
+	  output += "\"password\":\"" + (String)settings.password + "\",";
+	  output += "\"channel\":" + String((int)settings.channel) + ",";
+	  output += "\"hidden\":" + String((int)settings.hidden) + ",";
+	  output += "\"autoExec\":" + String((int)settings.autoExec) + ",";
+	  output += "\"autostart\":\"" + (String)settings.autostart + "\"";
+	  output += "}";
+	  request->send(200, "text/json", output);
+  });
+
+  server.on("/list.json", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  SPIFFS.info(fs_info);
+	  Dir dir = SPIFFS.openDir("");
+	  String output;
+	  output += "{";
+	  output += "\"totalBytes\":" + (String)fs_info.totalBytes + ",";
+	  output += "\"usedBytes\":" + (String)fs_info.usedBytes + ",";
+	  output += "\"list\":[ ";
+	  while(dir.next()) {
+		  File entry = dir.openFile("r");
+		  String filename = String(entry.name()).substring(1);
+		  output += '{';
+		  output += "\"n\":\"" + filename + "\",";//name
+		  output += "\"s\":\"" + formatBytes(entry.size()) + "\"";//size
+		  output += "},";
+		  entry.close();
+	  }
+	  output = output.substring(0, output.length() - 1);
+	  output += "]}";
+	  request->send(200, "text/json", output);
+  });
+
+  server.on("/script", HTTP_GET, [](AsyncWebServerRequest *request){
+    if(request->hasArg("name")){
+      String _name = request->arg("name");
       request->send(SPIFFS, "/"+_name, "text/plain");
     }else send404(request);
   });

-  server.on("/run", HTTP_GET, [](AsyncWebServerRequest *request){
-    if(request->hasArg("n")){
-      String _name = request->arg("n");
-      script = SPIFFS.open("/"+_name, "r");
-      runScript = true;
-      runLine = true;
-      /*
-      while(f.available() && outc <2000){
-        Serial.write(f.read());
-      }*/
-      request->send(200, "text/plain", "true");
-    }else if(request->hasArg("script")){
-      Serial.println(request->arg("script"));
-      sendToIndex(request);
-    } else send404(request);
-  });
+  server.on("/run", HTTP_POST, [](AsyncWebServerRequest *request) {
+	  if(request->hasArg("name")) {
+		  String _name = request->arg("name");
+		  script = SPIFFS.open("/" + _name, "r");
+		  runScript = true;
+		  runLine = true;
+		  request->send(200, "text/plain", "true");
+	  }
+	  else if(request->hasArg("script")) {
+		  Serial.println(request->arg("script"));
+		  request->send(200, "text/plain", "true");
+	  }
+	  else send404(request);
+  });
+
+  server.on("/save", HTTP_POST, [](AsyncWebServerRequest *request) {
+	  if(request->hasArg("name") && request->hasArg("script")) {
+		  String _name = request->arg("name");
+		  String _script = request->arg("script");
+		  File f = SPIFFS.open("/" + _name, "w");
+		  if(f) {
+			  f.print(_script);
+			  request->send(200, "text/plain", "true");
+		  }
+		  else request->send(200, "text/plain", "false");
+	  }
+	  else send404(request);
+  });
+

   server.on("/delete", HTTP_GET, [](AsyncWebServerRequest *request){
-    if(request->hasArg("n")){
-      String _name = request->arg("n");
+    if(request->hasArg("name")){
+      String _name = request->arg("name");
       SPIFFS.remove("/"+_name);
       request->send(200, "text/plain", "true");
     }else send404(request);
+  });
+
+  server.on("/rename", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  if(request->hasArg("name") && request->hasArg("newName")) {
+		  String _name = request->arg("name");
+		  String _newName = request->arg("newName");
+		  SPIFFS.rename("/" + _name, "/" + _newName);
+		  request->send(200, "text/plain", "true");
+	  }
+	  else send404(request);
   });

   server.on("/format", HTTP_GET, [](AsyncWebServerRequest *request){
@@ -168,11 +295,23 @@
     send404(request);
   });

-  // Simple Firmware Update Form
-  server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){
-    AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", data_updateHTML, sizeof(data_updateHTML));
-    request->send(response);
-  });
+  server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  AsyncWebServerResponse *response = request->beginResponse(302, "text/plain", "");
+	  response->addHeader("Location", "/info.html");
+	  request->send(response);
+  });
+
+  server.on("/restart", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  shouldReboot = true;
+  });
+
+  server.on("/reset", HTTP_GET, [](AsyncWebServerRequest *request) {
+	  settings.reset();
+	  request->send(200, "text/plain", "true");
+	  sendToIndex(request);
+  });
+
+  //update
   server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){
     shouldReboot = !Update.hasError();
     AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", shouldReboot?"OK":"FAIL");
@@ -180,10 +319,10 @@
     request->send(response);
   },[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
     if(!index){
-      Serial.printf("Update Start: %s\n", filename.c_str());
+      if(debug) Serial.printf("Update Start: %s\n", filename.c_str());
       Update.runAsync(true);
       if(!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)){
-        Update.printError(Serial);
+		  if(debug) Update.printError(Serial);
       }
     }
     if(!Update.hasError()){
@@ -193,17 +332,16 @@
     }
     if(final){
       if(Update.end(true)){
-        Serial.printf("Update Success: %uB\n", index+len);
+		if(debug) Serial.printf("Update Success: %uB\n", index+len);
       } else {
-        Update.printError(Serial);
+		if(debug) Update.printError(Serial);
       }
     }
   });

-
   server.begin();

-  Serial.println("started");
+  if(debug) Serial.println("started");
 }

 void sendBuffer(){
@@ -224,18 +362,26 @@
 void loop() {
   if(shouldReboot) ESP.restart();

-  if(Serial.available() > 0) {
-    byte answer = Serial.read();
+  if(Serial.available()) {
+    uint8_t answer = Serial.read();
     if(answer == 0x99) {
-      //Serial.println("REM done");
+      if(debug) Serial.println("done");
       runLine = true;
-    }
+	}
+	else {
+		String command = (char)answer + Serial.readStringUntil('\n');
+		command.replace("\r", "");
+		if(command == "reset") {
+			settings.reset();
+			shouldReboot = true;
+		}
+	}
   }

   if(runScript && runLine){
     if(script.available()){
       uint8_t nextChar = script.read();
-      //Serial.write(nextChar);
+	  if(debug) Serial.write(nextChar);
       scriptLineBuffer[lc] = nextChar;
       lc++;
       if(nextChar == 0x0D || lc == bufferSize) addToBuffer();
@@ -246,6 +392,5 @@
       script.close();
     }
   }
-
-}
-
+
+}


Update mouthcontrol_hardware.ino (#40)

Update mouthcontrol_hardware.ino (#40)

--- home/moz4r/mouthcontrol_hardware.ino
+++ home/moz4r/mouthcontrol_hardware.ino
@@ -41,6 +41,7 @@

   Serial.begin(9600);
   Serial.println("--- Start DEBUG ---");
+
   myservo.attach(servoPin);
   myservo.write(50);
   delay(1000);
@@ -79,6 +80,11 @@
       if (BoucheStatus == 0 && ActionBouche == 0)

       {
+           if (Repos==0)
+        {
+        myservo.attach(servoPin);
+        delay(1);
+        }
       //Serial.println(val);
       ActionBouche = 1;
       //myservo.attach(9);
@@ -94,11 +100,7 @@
       if (BoucheStatus == 1 && ActionBouche == 1)
       {

-        if (Repos==0)
-        {
-        myservo.attach(servoPin);
-        delay(10);
-        }
+

        myservo.write(90);


Corrected include.

Corrected include.

--- firmware/examples/mdns.ino
+++ firmware/examples/mdns.ino
@@ -1,5 +1,5 @@
 // This #include statement was automatically added by the Spark IDE.
-#include "MDNS.h"
+#include "MDNS/MDNS.h"

 #define HTTP_PORT 80


Changed some stuff :p

Changed some stuff :p

--- BareTest/BareTest.ino
+++ BareTest/BareTest.ino
@@ -62,7 +62,7 @@
 void loop() {
   // put your main code here, to run repeatedly:

-  /*
+

   for(int i=0;i<200;i++){
     strobe();
@@ -86,11 +86,13 @@
   for(int l=0;l<3;l++){
     cubeHorizPlaneShift();
   }
-  */
-
-  snake(1000);
-
-}
+
+
+  snake(500);
+
+}
+
+

 void snake(int num) {
   int proposedX = 0;
@@ -172,10 +174,10 @@
       currentY = proposedY;
       currentZ = proposedZ;

-      changePix(cube[currentX][currentY][currentZ], 1);
-      changePix(cube[previousX1][previousY1][previousZ1], 1, 18);
-      changePix(cube[previousX2][previousY2][previousZ2], 1, 11);
-      changePix(cube[previousX3][previousY3][previousZ3], 1, 4);
+      changePix(cube[currentX][currentY][currentZ], 1, 250);
+      changePix(cube[previousX1][previousY1][previousZ1], 2, 250);
+      changePix(cube[previousX2][previousY2][previousZ2], 3, 250);
+      changePix(cube[previousX3][previousY3][previousZ3], 4, 250);

       refresh();
       delay(100);
@@ -186,6 +188,10 @@
       proposedZ = currentZ;
     }
   }
+  changePix(cube[currentX][currentY][currentZ], 0, 25);
+  changePix(cube[previousX1][previousY1][previousZ1], 0, 25);
+  changePix(cube[previousX2][previousY2][previousZ2], 0, 25);
+  changePix(cube[previousX3][previousY3][previousZ3], 0, 25);
 }


buzzer support [not completed].

buzzer support [not completed].

--- pomodoro/pomodoro.ino
+++ pomodoro/pomodoro.ino
@@ -14,13 +14,17 @@
 static  const int       pin_button  = 14;
 static  const int       pin_alert   = 12;

+static  bool      alerting    = false;
+
 void setup() {
+  pinMode(pin_alert, OUTPUT);
+  digitalWrite(pin_alert, LOW);
+
   led_init();
   btn_.init(pin_button);
   logic_.init();
   timer_.reset(0);

-  pinMode(pin_alert, OUTPUT);
   timing_confirm_.init();
   timing_alert_.init();

@@ -44,19 +48,25 @@
       } else {
         timing_confirm_.reset();
       }
+      alerting  = true;
       digitalWrite(pin_alert, HIGH);
     }
     // check & stop alert
     if (timing_alert_.check_periodic(timestamp, 500, 10)) {
       alert_status  = !alert_status;
-      //digitalWrite(pin_alert, alert_status ? HIGH : LOW);
+      digitalWrite(pin_alert, alert_status ? HIGH : LOW);
     }
     if (timing_confirm_.check_timeout(timestamp, 1000)) {
+      alerting  = false;
       digitalWrite(pin_alert, LOW);
     }
-  } else {
+  } else if (alerting) {
     digitalWrite(pin_alert, LOW);
+    alerting  = false;
+    timing_confirm_.done();
+    timing_alert_.done();
   }
+
   led_setblink(logic_.confirming);
   led_update(logic_.remain_seconds);


+added power_router.ino (removed identifier)

--- power_router/power_router.ino
+++ power_router/power_router.ino
@@ -17,8 +17,8 @@
 #include <elapsedMillis.h>
 #include <SoftwareSerial.h>

-#define XBLEN 93 //paylenght+2(identifier)+3(randnum)+1(null)
-#define PAYLEN 90
+#define XBLEN 83 //paylenght+2(identifier)+3(randnum)+1(null)
+#define PAYLEN 80

 SoftwareSerial customDue(3, 4); //Rx, Tx
 SoftwareSerial altserial(8,9);
@@ -65,8 +65,6 @@
 int length=0;
 int paylength=77;
 int datalen=0;
-char id='A';
-//char id='B';

 int count_success=0;
 int verify_send[24]={0};
@@ -309,9 +307,8 @@
 		for (j=0;j<XBLEN+1;j++) payload[j]=0x00;

 		delay(500);
-		payload[0]=(uint8_t)id;

-		for (j=1;j<PAYLEN;j++){
+		for (j=0;j<PAYLEN;j++){
 			payload[j]=(uint8_t)streamBuffer[datalen];
 			datalen++;
 		}


personal tokens moved out, functionality tested ok

--- projects/YunMon/YunMon.ino
+++ projects/YunMon/YunMon.ino
@@ -1,33 +1,38 @@
 /*
-  Arduino Yun - Power and temperature measurement
-
-    1) Interrupt-driven light pulse detection on IRQ 0 and 1
-    - PV Produktion: pin3 (Yun) = IRQ 0
-    - Zweirichtungszaehler: pin2 (Yun) = IRQ 1
-    - calculate power based on ppwh pulses per Wh
-
-    2) OneWire temperature measurement via Dallas DS18B20
-
-    3) Plot averaged powers to plot.ly as streaming plot
-
-    4) Log data to /mnt/sda1/datalogs: timestamp, production [W], abs(production - consumption) [W], temperature [°C]
-
-
-    Possible improvements / backlog:
-    - check power calculations for pathological cases (zero difference etc)
-
-
-    History:
-
-    140927 Merged with DS18B20 temperature measurement - on port 4, writing to col 4
-
-    140921 Move from appending to one single datafile datalog.txt to daily datalog files
-
-    140912  timing approach adjusted: timestamp with 1s precision is logged, looping until measurementinterval with
-            ms precision has passed by. Should be ok for intervals >= 10s. Not ok for sub-second measurements.
-
-    140911: data logging to SD card added
+Arduino Yun - Power and temperature measurement
+
+1) Interrupt-driven light pulse detection on IRQ 0 and 1
+- PV Produktion: pin3 (Yun) = IRQ 0
+- Zweirichtungszaehler: pin2 (Yun) = IRQ 1
+- calculate power based on ppwh pulses per Wh
+
+2) OneWire temperature measurement via Dallas DS18B20
+
+3) Plot averaged powers to plot.ly as streaming plot
+
+4) Log data to /mnt/sda1/datalogs: timestamp, production [W], abs(production - consumption) [W], temperature [°C]
+
+
+Possible improvements / backlog:
+- check power calculations for pathological cases (zero difference etc)
+
+
+History:
+
+141229 change of dev env to Win158, and moved to git
+
+140927 Merged with DS18B20 temperature measurement - on port 4, writing to col 4
+
+140921 Move from appending to one single datafile datalog.txt to daily datalog files
+
+140912  timing approach adjusted: timestamp with 1s precision is logged, looping until measurementinterval with
+ms precision has passed by. Should be ok for intervals >= 10s. Not ok for sub-second measurements.
+
+140911: data logging to SD card added
 */
+
+// plot.ly streaming tokens, gitignored, same directory
+#include "mytokens.h"

 #include <Bridge.h>
 #include <Console.h>
@@ -41,7 +46,7 @@
 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
 OneWire oneWire(ONE_WIRE_BUS);

-// Pass our oneWire reference to Dallas Temperature.
+// Pass our oneWire reference to Dallas Temperature.
 DallasTemperature sensors(&oneWire);

 // Data logging and time stamping from http://arduino.cc/en/Tutorial/YunDatalogger
@@ -58,7 +63,7 @@
 // Initialize as many plotters as you want! Each plotter will send data to the same plot as a separate line.
 // Make sure that you place these exact-same stream tokens in your `config.json` file on the Linino.

-plotly plotter1("rs7ymb8xpy"); plotly plotter2("3lkrelrfxt"); // plot.ly tokens
+plotly plotter1(PLOTLY_TOKEN_1); plotly plotter2(PLOTLY_TOKEN_2); // plot.ly tokens

 // Measurement interval in milliseconds
 int measurementInterval = 10000;
@@ -75,150 +80,159 @@
 //power and energy
 double power0, averagedPower0, power1, averagedPower1;

-void setup() {
-
-  // start-up the bridge
-  Bridge.begin();
-  FileSystem.begin();
-
-  delay(2000);
-  Console.begin();
-  while (!Console) {
-    ; // wait for Console port to connect.
-  }
-
-  Console.buffer(64);
-  delay(2000);
-
-  // attach interrupt routines
-  attachInterrupt(0, onPulse0, FALLING); attachInterrupt(1, onPulse1, FALLING);
-
-// Start up the OneWire library
-  sensors.begin();
-
-  plotter1.timezone  = "Europe/Berlin"; plotter2.timezone = "Europe/Berlin";
-  millis_current = millis();
+void setup()
+{
+
+    // start-up the bridge
+    Bridge.begin();
+    FileSystem.begin();
+
+    delay(2000);
+    Console.begin();
+    while (!Console)
+    {
+        ; // wait for Console port to connect.
+    }
+
+    Console.buffer(64);
+    delay(2000);
+
+    // attach interrupt routines
+    attachInterrupt(0, onPulse0, FALLING); attachInterrupt(1, onPulse1, FALLING);
+
+    // Start up the OneWire library
+    sensors.begin();
+
+    plotter1.timezone  = "Europe/Berlin"; plotter2.timezone = "Europe/Berlin";
+    millis_current = millis();

 }

 void loop()
 {
-  if (millis() - millis_current > measurementInterval) {
+    if (millis() - millis_current > measurementInterval)
+    {

         // reset timer
-    millis_current = millis();
-
-    sensors.requestTemperatures(); // Send the command to get temperatures
-
-    // Target: YY-MM-DD hh:mm:ss, elapsed Millis, analogValues
-    dataString = getTimeStamp() + ",";
-    dataString += String(averagedPower0); dataString += ",";
-    dataString += String(averagedPower1); dataString += ",";
-    dataString += String(sensors.getTempCByIndex(0));
-
-    // open the file. note that only one file can be open at a time,
-    // so you have to close this one before opening another.
-    // The FileSystem card is mounted at the following "/mnt/sda1"
-    fileName = "/mnt/sda1/datalogs/" + getDate() + ".txt";
-    // convert fileName string to char array
-    fileName.toCharArray(__fileName, sizeof(__fileName));
-    File dataFile = FileSystem.open(__fileName, FILE_APPEND);
-
-    // if the file is available, write to it:
-    if (dataFile) {
-      dataFile.println(dataString);
-      dataFile.close();
-      // print to the serial port too:
-      Console.println(dataString);
-    }
-    // if the file isn't open, pop up an error:
-    else {
-      Console.println("error opening datalog.txt");
-    }
-
-    //Plot the value
-    plotter1.plot(averagedPower0); // Solar production
-    plotter2.plot(averagedPower1); // Zweirichtungszaehler
-
-    //Reset averaging
-    averageCount0 = 0; accumulatedPulseTime0 = 0;
-    averageCount1 = 0; accumulatedPulseTime1 = 0;
-  }
+        millis_current = millis();
+
+        sensors.requestTemperatures(); // Send the command to get temperatures
+
+        // Target: YY-MM-DD hh:mm:ss, elapsed Millis, analogValues
+        dataString = getTimeStamp() + ",";
+        dataString += String(averagedPower0); dataString += ",";
+        dataString += String(averagedPower1); dataString += ",";
+        dataString += String(sensors.getTempCByIndex(0));
+
+        // open the file. note that only one file can be open at a time,
+        // so you have to close this one before opening another.
+        // The FileSystem card is mounted at the following "/mnt/sda1"
+        fileName = "/mnt/sda1/datalogs/" + getDate() + ".txt";
+        // convert fileName string to char array
+        fileName.toCharArray(__fileName, sizeof(__fileName));
+        File dataFile = FileSystem.open(__fileName, FILE_APPEND);
+
+        // if the file is available, write to it:
+        if (dataFile)
+        {
+            dataFile.println(dataString);
+            dataFile.close();
+            // print to the serial port too:
+            Console.println(dataString);
+        }
+        // if the file isn't open, pop up an error:
+        else
+        {
+            Console.println("error opening datalog.txt");
+        }
+
+        //Plot the value
+        plotter1.plot(averagedPower0); // Solar production
+        plotter2.plot(averagedPower1); // Zweirichtungszaehler
+
+        //Reset averaging
+        averageCount0 = 0; accumulatedPulseTime0 = 0;
+        averageCount1 = 0; accumulatedPulseTime1 = 0;
+    }
 }

 //Interrupt routine 0 - PV production
 void onPulse0()
 {
-  //pulseCounters
-  pulseCount0++; averageCount0++;
-
-  //used to measure time between pulses.
-  lastTime0 = pulseTime0;
-  pulseTime0 = micros();
-  deltaTime0 = pulseTime0 - lastTime0;
-  accumulatedPulseTime0 += deltaTime0;
-
-  //Calculate power
-  power0 = 3600000000.0 / (deltaTime0 * ppwh0);
-  averagedPower0 = (3600000000.0 * averageCount0) / (accumulatedPulseTime0 * ppwh0);
-  //  }
+    //pulseCounters
+    pulseCount0++; averageCount0++;
+
+    //used to measure time between pulses.
+    lastTime0 = pulseTime0;
+    pulseTime0 = micros();
+    deltaTime0 = pulseTime0 - lastTime0;
+    accumulatedPulseTime0 += deltaTime0;
+
+    //Calculate power
+    power0 = 3600000000.0 / (deltaTime0 * ppwh0);
+    averagedPower0 = (3600000000.0 * averageCount0) / (accumulatedPulseTime0 * ppwh0);
+    //  }
 }

 //Interrupt routine 1 - Zweirichtungszaehler
 void onPulse1()
 {
-  //pulseCounters
-  pulseCount1++; averageCount1++;
-
-  //used to measure time between pulses.
-  lastTime1 = pulseTime1;
-  pulseTime1 = micros();
-  deltaTime1 = pulseTime1 - lastTime1;
-  accumulatedPulseTime1 += deltaTime1;
-
-  //Calculate power
-  power1 = 3600000000.0 / (deltaTime1 * ppwh1);
-  averagedPower1 = (3600000000.0 * averageCount1) / (accumulatedPulseTime1 * ppwh1);
-  //  }
+    //pulseCounters
+    pulseCount1++; averageCount1++;
+
+    //used to measure time between pulses.
+    lastTime1 = pulseTime1;
+    pulseTime1 = micros();
+    deltaTime1 = pulseTime1 - lastTime1;
+    accumulatedPulseTime1 += deltaTime1;
+
+    //Calculate power
+    power1 = 3600000000.0 / (deltaTime1 * ppwh1);
+    averagedPower1 = (3600000000.0 * averageCount1) / (accumulatedPulseTime1 * ppwh1);
+    //  }
 }

 // This function returns a string with the current date
-String getDate() {
-  String result;
-  Process time;
-  // date is a command line utility to get the date and the time
-  // in different formats depending on the additional parameter
-  time.begin("date");
-  time.addParameter("+%Y-%m-%d");  // parameters: D for the complete date mm/dd/yy, T for the time hh:mm:ss
-  time.run();  // run the command
-
-  // read the output of the command
-  while (time.available() > 0) {
-    char c = time.read();
-    if (c != '\n')
-      result += c;
-  }
-
-  return result;
+String getDate()
+{
+    String result;
+    Process time;
+    // date is a command line utility to get the date and the time
+    // in different formats depending on the additional parameter
+    time.begin("date");
+    time.addParameter("+%Y-%m-%d");  // parameters: D for the complete date mm/dd/yy, T for the time hh:mm:ss
+    time.run();  // run the command
+
+    // read the output of the command
+    while (time.available() > 0)
+    {
+        char c = time.read();
+        if (c != '\n')
+            result += c;
+    }
+
+    return result;
 }

 // This function returns a string with the time stamp
-String getTimeStamp() {
-  String result;
-  Process time;
-  // date is a command line utility to get the date and the time
-  // in different formats depending on the additional parameter
-  time.begin("date");
-  time.addParameter("+%Y-%m-%d %T");  // parameters: D for the complete date mm/dd/yy, T for the time hh:mm:ss
-  time.run();  // run the command
-
-  // read the output of the command
-  while (time.available() > 0) {
-    char c = time.read();
-    if (c != '\n')
-      result += c;
-  }
-
-  return result;
-}
-
+String getTimeStamp()
+{
+    String result;
+    Process time;
+    // date is a command line utility to get the date and the time
+    // in different formats depending on the additional parameter
+    time.begin("date");
+    time.addParameter("+%Y-%m-%d %T");  // parameters: D for the complete date mm/dd/yy, T for the time hh:mm:ss
+    time.run();  // run the command
+
+    // read the output of the command
+    while (time.available() > 0)
+    {
+        char c = time.read();
+        if (c != '\n')
+            result += c;
+    }
+
+    return result;
+}
+


Update TestStepRampCom.ino

Update TestStepRampCom.ino


divide circle by instrument color and effect color

--- arduino-neopixel.ino
+++ arduino-neopixel.ino
@@ -34,19 +34,28 @@

 void loop() {
   if (0<Serial.available()) {
+    // 255,255,255 255,255,255
     String str = Serial.readStringUntil('\n');
-    int r = str.substring(0,3).toInt();
-    int g = str.substring(4,7).toInt();
-    int b = str.substring(8,11).toInt();
+    int inst_r = str.substring(0,3).toInt();
+    int inst_g = str.substring(4,7).toInt();
+    int inst_b = str.substring(8,11).toInt();
+
+    int effect_r = str.substring(0,3).toInt();
+    int effect_g = str.substring(4,7).toInt();
+    int effect_b = str.substring(8,11).toInt();

     // あまり強く光らせると色が安定しないのでリミットを設ける
-    int _r = constrainValue(r);
-    int _g = constrainValue(g);
-    int _b = constrainValue(b);
-    Serial.println("::: setInstColor :::");
-    Serial.println("input:["+String(r)+","+String(g)+","+String(b)+"] constrains to ["+String(_r)+","+String(_g)+","+String(_b)+"]");
+    int _inst_r = constrainValue(inst_r);
+    int _inst_g = constrainValue(inst_g);
+    int _inst_b = constrainValue(inst_b);
+    int _effect_r = constrainValue(effect_r);
+    int _effect_g = constrainValue(effect_g);
+    int _effect_b = constrainValue(effect_b);
+    Serial.println("::: setColor :::");
+    Serial.println("instrument:["+String(inst_r)+","+String(inst_g)+","+String(inst_b)+"] constrains to ["+String(_inst_r)+","+String(_inst_g)+","+String(_inst_b)+"]");
+    Serial.println("effect:["+String(effect_r)+","+String(effect_g)+","+String(effect_b)+"] constrains to ["+String(_effect_r)+","+String(_effect_g)+","+String(_effect_b)+"]");

-    color(strip.Color(_r, _g, _b));
+    updateColor(strip.Color(_inst_r, _inst_g, _inst_b), strip.Color(_effect_r, _effect_g, _effect_b));
   }
 }

@@ -70,9 +79,21 @@
   return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
 }

-void color(uint32_t c) {
+void updateColor(uint32_t instrumentColor, uint32_t effectColor) {
   for(uint16_t i=0; i<strip.numPixels(); i++) {
-    strip.setPixelColor(i, c);
+    if(i<TOTAL_PIXELS/4){
+      strip.setPixelColor(i, instrumentColor);
+    }
+    else if(i<TOTAL_PIXELS/2){
+      strip.setPixelColor(i, effectColor);
+    }
+    else if(i<TOTAL_PIXELS*3/4){
+      strip.setPixelColor(i, instrumentColor);
+    }
+    else {
+      strip.setPixelColor(i, effectColor);
+    }
+
   }
   strip.show();
 }


update calibration values

update calibration values

--- Arduino/Bluetooth_Sensor_combo/Bluetooth_Sensor_combo.ino
+++ Arduino/Bluetooth_Sensor_combo/Bluetooth_Sensor_combo.ino
@@ -352,6 +352,11 @@
 Check that your sensor readings are close to 0 0 16384 0 0 0
 If calibration was succesful write down your offsets so you can set them in your projects using something similar to mpu.setXAccelOffset(youroffset)

+
+Sensor readings with offsets:  -2  -9  16380 0 0 0
+Your offsets: 95  5489  774 50  229 22
+
+
 */
 /**************************************************************************************/

@@ -362,13 +367,13 @@
     //mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

     // supply your own gyro offsets here, scaled for min sensitivity
-      mpu.setXAccelOffset(-100);
-      mpu.setYAccelOffset(5623);
-      mpu.setZAccelOffset(740); // 1688 factory default for my test chip
+      mpu.setXAccelOffset(95);
+      mpu.setYAccelOffset(5489);
+      mpu.setZAccelOffset(774); // 1688 factory default for my test chip

-      mpu.setXGyroOffset(47);
-      mpu.setYGyroOffset(234);
-      mpu.setZGyroOffset(24);
+      mpu.setXGyroOffset(50);
+      mpu.setYGyroOffset(229);
+      mpu.setZGyroOffset(22);

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


Bridge: slowing down ConsoleRead a bit to keep the python side of the Bridge from consuming 100% of the CPU

--- libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
+++ libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino
@@ -53,6 +53,8 @@
     else {  	 // if the buffer is empty Cosole.read() returns -1
       name += c; // append the read char from Console to the name string
     }
+  } else {
+    delay(100);
   }
 }


Add relay control for first relay

Add relay control for first relay

This is the one driving the fan

--- arduinoApp/gardenSketch/gardenSketch.ino
+++ arduinoApp/gardenSketch/gardenSketch.ino
@@ -29,9 +29,12 @@
 // activity led setup
 int ledPin = 13; // this is just for checking activity

+// relay related setup
+int relayPin1 = 8;
+
 // setup sensor reading interval
 unsigned long prevMillis = 0; // initialize previous milliseconds variable
-unsigned long interval = 5000; // number of milliseconds to wait
+unsigned long interval = 5*1000; // seconds to wait

 // Initialize settings
 void setup() {
@@ -40,6 +43,7 @@

   // Initialize output pins.
   pinMode(ledPin, OUTPUT);
+  pinMode(relayPin1, OUTPUT);

   // Initialize input pins.
   pinMode(lightSensorPin, INPUT);
@@ -59,6 +63,14 @@
     // Read sensor values
     sensorReadings();
   }
+
+  if(airTemperature < 27.5) { // activate fan to cool when it temperature is above 27.5 degrees Celsius
+    digitalWrite(relayPin1, HIGH);
+  } else {
+    digitalWrite(relayPin1, LOW);
+  }
+
+

 }


Fixed the getKeys() function so it returns recently pressed keys, long pressed keys and also has repeat after long-press functionality

--- arduino/libraries/ClockTiM/examples/ClockTiM/ClockTiM.ino
+++ arduino/libraries/ClockTiM/examples/ClockTiM/ClockTiM.ino
@@ -16,9 +16,7 @@

 typedef struct KeyStates{
 	uint8_t justPressed;	// Buttons that have just been pressed
-	uint8_t longPressed;	// Buttons that have been pressed for a long time
-	uint8_t up;				// Buttons that are pressed
-	uint8_t down;			// Buttons that are released
+	uint8_t longPressed;	// Buttons that have just been pressed for a long time
 };

 void setup() {
@@ -32,7 +30,7 @@
 	digitalWrite(PIN_LOW, LOW);

 	// Start the serial port
-	Serial.begin(9600);
+	Serial.begin(115200);

 	// Initialise the display
 	disp_init();
@@ -46,7 +44,7 @@

 	uint16_t ledStates[8] = { 0 };
 	KeyStates *keys = NULL;
-
+
 	keys = getKeys();

 	// Depending on the keys just pressed, take the necessary action
@@ -112,16 +110,23 @@
 	}
 }

+struct KeyStates *getKeys() {
+	return getKeys(false, LONG_PRESS_MILLIS);
+}
+
 // Returns a byte with the idx of any newly pressed keys set to '1'. Also includes debouncing.
-struct KeyStates *getKeys() {
-	static uint8_t debounce[4];			// Stores the queue of the push button states
-	static uint8_t debounceIdx = 0;		// Stores the index we are current at within the debounce queue
-	static uint8_t states;				// Stores the state of the keys
-	static long timeInStates = 0;		// Records the amount of time <states> has been in its current state
+struct KeyStates *getKeys(boolean repeat, long repeatAfter) {
+	static uint8_t debounce[4] = { 0 };			// Stores the queue of the push button states
+	static uint8_t debounceIdx = 0;				// Stores the index we are current at within the debounce queue
+	static uint8_t states = 0;					// Stores the state of the keys
+	static unsigned long timeInStates = 0;		// Records the amount of time <states> has been in its current state
+	static boolean longPressDetect;

 	static KeyStates keys;

-	uint8_t pressed = 0;				// Holds which buttons are currently pressed
+	uint8_t pressed = 0;						// Holds which buttons are currently pressed
+	uint8_t up;									// Buttons that are pressed
+	uint8_t down;								// Buttons that are released

 	if(digitalRead(BUTTON_L) == LOW) {
 		pressed |= BUTTON_L_IDX;
@@ -134,25 +139,36 @@
 	debounce[debounceIdx++] = pressed;
 	debounceIdx &= 3;

-	keys.down = debounce[0] & debounce[1] & debounce[2] & debounce[3];
-	keys.up = debounce[0] | debounce[1] | debounce[2] | debounce[3];
+	down = debounce[0] & debounce[1] & debounce[2] & debounce[3];
+	up = debounce[0] | debounce[1] | debounce[2] | debounce[3];

-	// Determine which buttons have freshly been pressed and return the result
+	// Determine which buttons have freshly been pressed
 	uint8_t prevStates = states;
-	states &= keys.up;
-	states |= keys.down;
+	states &= up;
+	states |= down;
 	keys.justPressed = states & (states ^ prevStates);

+	// Now test which keys have been pressed for a long time
+	keys.longPressed = 0x00;
 	if(states != 0) {
-		if(states != prevStates) {
+		if(longPressDetect) {
+			// We are already in the middle of a long-press
+
+			// Don't do anything unless we are repeating
+			if(repeat) {
+				keys.justPressed = up;
+			}
+		} else if(states != prevStates) {
+			// A button has just been pressed. Mark the time at which this happened
 			timeInStates = millis();
-		} else {
-			if(millis() - timeInStates > LONG_PRESS_MILLIS) {
-				keys.longPressed = keys.up;
-			}
+			longPressDetect = false;
+		} else if(millis() - timeInStates > repeatAfter) {
+			// Enough time has elapsed for a long press - mark it as such
+			keys.longPressed = up;
+			longPressDetect = true;
 		}
 	} else {
-		keys.longPressed = 0;
+		longPressDetect = false;
 	}

 	return &keys;


updated nano printing for graphics

updated nano printing for graphics

--- beanWheelwriterControlNano/beanWheelwriterControlNano.ino
+++ beanWheelwriterControlNano/beanWheelwriterControlNano.ino
@@ -84,7 +84,7 @@
           //Serial.println(int(command));

           if (command == 0) { // text to print
-            // look for next two bytes
+            // look for next two bytesp
             // reset the typewriter so we know we are on the begining of a line
             resetTypewriter();
             Serial.readBytes(buffer,2);
@@ -304,7 +304,7 @@
         if (timeout) {
             paper_vert(1,1);
             Serial.println("timeout");
-            micro_backspace(rowBitsPrinted);
+            micro_backspace(rowBitsPrinted * 3);
             break;
         }
         bitsRead = Serial.readBytes(buffer, 3);
@@ -324,7 +324,7 @@
     if (c == '\n') {
       paper_vert(1,1); // Move down one pixel
       if (runLength > 0) {
-          micro_backspace(runLength);
+          micro_backspace(runLength * 3);
       }
     }
     else if (c == ' ') {
@@ -640,7 +640,7 @@
 }

 void micro_backspace(int microspaces) {
-    // 5 microspaces is one space
+    // 10 microspaces is one space
     sendByte(0b100100001);
     sendByte(0b000001110);
     sendByte(0b011010000);