nano cleanup

nano cleanup

--- nano/nano.ino
+++ nano/nano.ino
@@ -26,16 +26,12 @@
 GattCharacteristic *uartChars[] = {&characteristic1, &characteristic2};
 GattService         uartService(service1_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *));

-
-uint8_t outDataBuffer[5];
 OutgoingMessage om = OutgoingMessage();
 mduino m = mduino();

 void setup() {
   Serial.begin(9600);
   m.setSerial(Serial);
-  om.setData(outDataBuffer);
-  om.setDataLength(sizeof(outDataBuffer));
   om.setMsgId(0);

   Serial.attach(uart_handle);


Fixing note for channel creation

Fixing note for channel creation

--- examples/Basic/Basic.ino
+++ examples/Basic/Basic.ino
@@ -36,8 +36,8 @@
     // Begin communicating with the channel. This should only need to
     // be done once.
     //
-    // NOTE: Please ensure you've created a channel called mqtt in the
-    // Helium Dashboard.
+    // NOTE: Please ensure you've created a channel called "Helium
+    // Cloud MQTT" called in the Helium Dashboard.
     int8_t result;
     Serial.print("Creating Channel - ");
     status = channel.begin("Helium Cloud MQTT", &result);


Update basic.ino

Update basic.ino

--- examples/basic/basic.ino
+++ examples/basic/basic.ino
@@ -1,17 +1,23 @@
 #include <TM16xxRAW.h>
+

 //data_pin,clock_pin,strobe_pin
 TM16xxRAW tm(3,4,5);

 void setup() {
-//optional:brightness(0:7),displayOn(0=off,1=on)
- tm.begin();
-//column,row,state(0,1)
- tm.setLed(0,1,1);
+  //optional:brightness(0:7),displayOn(0=off,1=on)
+  tm.begin();
+  //column,row,state(0,1)
+  tm.setLed(0,1,1);
 }

 void loop() {
+  randomLed2();
+}
+
+//this use column,row led addressing
+void randomLed1(){
   byte col = random(0,8);
   byte row = random(0,8);
   byte val = 0;
@@ -23,5 +29,23 @@
   }
   tm.setLed(col,row,val);
   delay(5);
-
-}+}
+
+//this use just led addressing.
+/*
+using 8x8 matrix you have 64 led addressable.
+you can use any number from 0 to 63, the led are addressed as colums
+so led 0 to 7 will be in the column 0 and so on.
+*/
+void randomLed2(){
+  byte led = random(0,63);
+  byte val = 0;
+  if (tm.getLed(led) == 1){
+    val = 0;
+  }
+  else {
+    val = 1;
+  }
+  tm.setLed(led,val);
+  delay(5);
+}


Update Motor_Driver_2_Test.ino

Update Motor_Driver_2_Test.ino

--- Testing/Motor_Driver_2_Test/Motor_Driver_2_Test.ino
+++ Testing/Motor_Driver_2_Test/Motor_Driver_2_Test.ino
@@ -1,7 +1,7 @@
-int E1 = 6; //Speed 1
-int M1 = 7; //Direction 1
-int E2 = 5; //Speed 2
-int M2 = 4; //Direction 2
+int E1 = 6; //Speed 1       RIGHT MOTOR
+int M1 = 7; //Direction 1   RIGHT MOTOR
+int E2 = 5; //Speed 2       LEFT MOTOR
+int M2 = 4; //Direction 2   LEFT MOTOR

 //OUTPUT HIGH for Forward
 //OUTPUT LOW for Reverse


device mounting

device mounting

--- init.ino
+++ init.ino
@@ -62,6 +62,27 @@
 	prev_time = millis();
 }

+void mount_devices() {
+	// order matters
+																									// device id
+	// equalizers
+	device_manager.mount(new MSGEQ7(F("Left Equalizer"), EQ_L_STROBE, EQ_L_RESET, EQ_L_INPUT));		// 0
+	device_manager.mount(new MSGEQ7(F("Right Equalizer"), EQ_R_STROBE, EQ_R_RESET, EQ_R_INPUT));	// 1
+
+	// LED buttons
+	device_manager.mount(new LEDButton(F("Desk 1 Mode"), MODE_DESK1_LED_PIN, MODE_DESK1_BTN_PIN));	// 2
+	device_manager.mount(new LEDButton(F("Desk 2 Mode"), MODE_DESK2_LED_PIN, MODE_DESK2_BTN_PIN));	// 3
+	device_manager.mount(new LEDButton(F("Desk Mode"), MODE_DESK_LED_PIN, MODE_DESK_BTN_PIN));		// 4
+
+	device_manager.mount(new LEDButton(F("Win 1 Mode"), MODE_WIN1_LED_PIN, MODE_WIN1_BTN_PIN));		// 5
+	device_manager.mount(new LEDButton(F("Win 2 Mode"), MODE_WIN2_LED_PIN, MODE_WIN2_BTN_PIN));		// 6
+	device_manager.mount(new LEDButton(F("Win 3 Mode"), MODE_WIN3_LED_PIN, MODE_WIN3_BTN_PIN));		// 7
+	device_manager.mount(new LEDButton(F("Window Mode"), MODE_WIN_LED_PIN, MODE_WIN_BTN_PIN));		// 8
+
+	device_manager.mount(new LEDButton(F("Select"), SELECT_LED_PIN, SELECT_BTN_PIN));				// 9
+	device_manager.mount(new LEDButton(F("Disable"), DISABLE_LED_PIN, DISABLE_BTN_PIN));			// 10
+}
+
 void queue_sys_threads() {
 	// system processes
 	//thread_handler.queue();


Revert crazy memory-saving technique

Revert crazy memory-saving technique

--- lcd_temperature_display.ino
+++ lcd_temperature_display.ino
@@ -32,9 +32,8 @@
 ColorValue current_color;
 ColorValue new_color;
 ColorName next_color;
-byte voltageBins[AVERAGE_BINS] = {127};
+int voltageBins[AVERAGE_BINS] = {0};
 int currentVoltageBin = -1;
-int voltageEpsilon;
 TemperatureRecord high_temp = {0.0, 0};
 TemperatureRecord low_temp = {999.9, 0};

@@ -69,34 +68,17 @@
   if (currentVoltageBin < 0)
   {
     // special case: first time through.
-    // Initialize our voltageEpsilon and the current voltage bin.
-    voltageEpsilon = readval-127;
     currentVoltageBin = 0;
+    for (int i = 0; i < AVERAGE_BINS; i++)
+    {
+      voltageBins[i] = readval;
+    }
     #ifdef DEBUG
-      Serial.print("getTemperature: voltageEpsilon initialized to ");
-      Serial.println(voltageEpsilon);
+      Serial.print("getTemperature: voltageBins initialized to ");
+      Serial.println(readval);
     #endif
-  }
-
-  // Shift our readval by the voltageEpsilon, constrain to fit within a byte, then save to the array
-  readval_shifted = (byte)constrain((readval - voltageEpsilon), 0, 255);
-  voltageBins[currentVoltageBin] = readval_shifted;
-
-  // Nudge voltageEpsilon as required to avoid overflow the next time around
-  if (readval_shifted > 200)
-  {
-    voltageEpsilon += 1;
-    #ifdef DEBUG
-      Serial.print("getTemperature: voltageEpsilon increased to ");
-      Serial.println(voltageEpsilon);
-    #endif
-  } else if (readval_shifted < 50)
-  {
-    voltageEpsilon -= 1;
-    #ifdef DEBUG
-      Serial.print("getTemperature: voltageEpsilon decreased to ");
-      Serial.println(voltageEpsilon);
-    #endif
+  } else {
+    voltageBins[currentVoltageBin] = readval;
   }

   // increment the current bin, but wrap if we're at the end
@@ -107,9 +89,6 @@
   {
     bigsum += voltageBins[i];
   }
-
-  // re-add our voltageEpsilon across all slots
-  bigsum += voltageEpsilon << AVERAGE_BINS_BITS;

   // Compute the average, scaled from ADC value to temperature.
   *averageval  = (float)(bigsum >> AVERAGE_BINS_BITS);
@@ -197,12 +176,6 @@
   // set up the LCD's number of columns and rows:
   lcd.begin(16, 2);

-  // initialize voltageBins
-  for (int i = 0; i < AVERAGE_BINS; i++)
-  {
-    voltageBins[i] = 127;
-  }
-
   // serial for troubleshooting
   #ifdef DEBUG
     Serial.begin(9600);


add user and pwd into the captive setting portal (while initiating device)

--- src/esp_8266_sensor.ino
+++ src/esp_8266_sensor.ino
@@ -51,6 +51,8 @@
 #define CLIENT_ID     "1"
 char mqtt_server[120]="mqtt.broker.net";
 char mqtt_port_config[5]="1883";
+char mqtt_user[120]="";
+char mqtt_password[120]="";
 int mqtt_port = 1883;
 const char* topicCmd    = "/esp/1/cmd";
 const char* topicStatus = "/esp/1/status";
@@ -107,7 +109,8 @@
     JsonObject& json = jsonBuffer.createObject();
     json["mqtt_server"] = mqtt_server;
     json["mqtt_port"] = mqtt_port;
-    // json["blynk_token"] = blynk_token;
+    json["mqtt_user"] = mqtt_user;
+    json["mqtt_password"] = mqtt_password;

     File configFile = SPIFFS.open("/config.json", "w");
     if (!configFile) {
@@ -150,6 +153,8 @@

           strcpy(mqtt_server, json["mqtt_server"]);
           strcpy(mqtt_port_config, json["mqtt_port"]);
+          strcpy(mqtt_user, json["mqtt_user"]);
+          strcpy(mqtt_password, json["mqtt_password"]);

         } else {
           Serial.println("failed to load json config");
@@ -162,19 +167,16 @@
   //end read
 }

-
-WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 120);
-WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port_config, 5);
-
-void initWifiManager() {
-
-
   // The extra parameters to be configured (can be either global or just in the setup)
   // After connecting, parameter.getValue() will get you the configured value
   // id/name placeholder/prompt default length
-  // WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 120);
-  // WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port_config, 5);
-  // WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 32);
+
+WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 120);
+WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port_config, 5);
+WiFiManagerParameter custom_mqtt_user("user", "mqtt user", mqtt_user, 120);
+WiFiManagerParameter custom_mqtt_password("password", "mqtt password", mqtt_password, 120);
+
+void initWifiManager() {

   //WiFiManager
   //Local intialization. Once its business is done, there is no need to keep it around
@@ -189,7 +191,8 @@
   //add all your parameters here
   wifiManager.addParameter(&custom_mqtt_server);
   wifiManager.addParameter(&custom_mqtt_port);
-  // wifiManager.addParameter(&custom_blynk_token);
+  wifiManager.addParameter(&custom_mqtt_user);
+  wifiManager.addParameter(&custom_mqtt_password);

   //reset settings - for testing
   //wifiManager.resetSettings();
@@ -229,6 +232,8 @@
     //read updated parameters
     strcpy(mqtt_server, custom_mqtt_server.getValue());
     strcpy(mqtt_port_config, custom_mqtt_port.getValue());
+    strcpy(mqtt_user, custom_mqtt_user.getValue());
+    strcpy(mqtt_password, custom_mqtt_password.getValue());
     // strcpy(blynk_token, custom_blynk_token.getValue());

     // convert port
@@ -317,11 +322,13 @@
     ESP.reset();
   }

+  int cpt=10;
+
   // Loop until we're reconnected to MQTT server
   while (!client.connected()) {
     Serial.print("Attempting MQTT connection...");
     // Attempt to connect
-    if (client.connect(clientId)) {
+    if (client.connect(clientId, mqtt_user, mqtt_password)) {
       Serial.print("connected with id : ");
       Serial.println(clientId);
       // Once connected, publish an announcement...
@@ -334,6 +341,12 @@
         Serial.println(" failed");
       }
     } else {
+
+      if(--cpt==0){
+        wifiManager.startConfigPortal();
+        return;
+      }
+
       Serial.print("failed, rc=");
       Serial.print(client.state());
       Serial.println(" try again in 5 seconds");


Fix pen going down at the beginning of every run

Merge pull request #13 from jvolker/patch-1

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -328,9 +328,8 @@
   initRobotSetup();
   initPosition();

+  servoPen.write(servo_position);
   servoPen.attach(servopin);
-  delay(100);
-  servoPen.write(servo_position);
   delay(1000);

   goHome();
@@ -414,4 +413,4 @@
   Serial.print(digitalRead(xlimit_pin2)); Serial.print(" ");
   Serial.print(digitalRead(ylimit_pin1)); Serial.print(" ");
   Serial.println(digitalRead(ylimit_pin2));
-}+}


Generic ssid and password

Generic ssid and password

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -2,8 +2,8 @@
 #include "Adafruit_MQTT.h"
 #include "Adafruit_MQTT_Client.h"

-#define WLAN_SSID   "FRITZ!Box 7272"
-#define WLAN_PASS   "Aezakmi123!"
+#define WLAN_SSID   "YOUR SSID"
+#define WLAN_PASS   "YOUR PASSWORD"

 #define SERVER      "minibian"
 #define SERVERPORT  1883


fixed pin numbering for Analg A2

fixed pin numbering for Analg A2

--- sketch_soil/sketch_soil.ino
+++ sketch_soil/sketch_soil.ino
@@ -1,6 +1,5 @@
 int powerPin = 12;
 int ledPin = 2; // digital 2
-int sensorPin = 2; //Analog A2

 void setup() {
   pinMode(powerPin, OUTPUT);  // Sensor Power
@@ -33,7 +32,7 @@
   digitalWrite(ledPin, HIGH);
   digitalWrite(powerPin, HIGH);
   delay(1000);
-  val = analogRead(sensorPin);
+  val = analogRead(A2);
   digitalWrite(powerPin, LOW);
   digitalWrite(ledPin, LOW);
   sendmessage(val);


digitalinputpullup works!

digitalinputpullup works!

--- html/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino
+++ html/examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino
@@ -1,3 +1,4 @@
+//  This example is Chibitronics Love to Code tested!
 /*
  Input Pullup Serial

@@ -5,8 +6,8 @@
  digital input on pin 2 and prints the results to the serial monitor.

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

  Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
  20K-ohm resistor is pulled to 5V. This configuration causes the input to
@@ -14,6 +15,8 @@

  created 14 March 2012
  by Scott Fitzgerald
+ modified 25 May 2016
+ by bunnie

  http://www.arduino.cc/en/Tutorial/InputPullupSerial

@@ -23,28 +26,28 @@

 void setup(){
   //start serial connection
-  Serial.begin(9600);
-  //configure pin2 as an input and enable the internal pull-up resistor
-  pinMode(2, INPUT_PULLUP);
-  pinMode(13, OUTPUT);
+  Serial.begin(115200);
+  //configure A3 as an input and enable the internal pull-up resistor
+  pinMode(A3, INPUT_PULLUP);
+  pinMode(A2, OUTPUT);

 }

 void loop(){
   //read the pushbutton value into a variable
-  int sensorVal = digitalRead(2);
+  int sensorVal = digitalRead(A3);
   //print out the value of the pushbutton
   Serial.println(sensorVal);

   // Keep in mind the pullup means the pushbutton's
   // logic is inverted. It goes HIGH when it's open,
-  // and LOW when it's pressed. Turn on pin 13 when the
+  // and LOW when it's pressed. Turn on pin A2 when the
   // button's pressed, and off when it's not:
   if (sensorVal == HIGH) {
-    digitalWrite(13, LOW);
+    digitalWrite(A2, LOW);
   }
   else {
-    digitalWrite(13, HIGH);
+    digitalWrite(A2, HIGH);
   }
 }


Just a little clean up

Just a little clean up

--- examples/PulseSensor_Speaker/PulseSensor_Speaker.ino
+++ examples/PulseSensor_Speaker/PulseSensor_Speaker.ino
@@ -140,7 +140,7 @@
   }

   /*
-    The Pulse variable is true only for a short time after heartbeat detected
+    The Pulse variable is true only for a short time after the heartbeat is detected
     Use this to time the duration of the beep
   */
   if(pulseSensor.isInsideBeat() == false){


add command process

add command process

--- neurite.ino
+++ neurite.ino
@@ -88,6 +88,7 @@
 #endif
 Ticker ticker_worker;
 Ticker ticker_led;
+Ticker ticker_cmd;
 WiFiClient wifi_cli;
 PubSubClient mqtt_cli(wifi_cli);

@@ -198,8 +199,8 @@
 	log_dbg("topic (%d): %s\n\r", strlen(topic), topic);
 	log_dbg("data (%d): ", length);
 	for (int i = 0; i < length; i++)
-		USE_SERIAL.print((char)payload[i]);
-	USE_SERIAL.println();
+		LOG_SERIAL.print((char)payload[i]);
+	LOG_SERIAL.println();
 }

 static inline bool mqtt_check_status(void)
@@ -224,7 +225,7 @@
 	dbg_assert(cp);
 	if (cp->data_len > 0) {
 		log_dbg("msg launch(len %d): %s\n\r", cp->data_len, cp->buf);
-//		MQTT_Publish(&g_nd.mc, g_nd.nmcfg.topic_to, cp->buf, cp->data_len, 0, 0);
+		mqtt_cli.publish(g_nd.nmcfg.topic_to, cp->buf);
 	}
 	__bzero(cp->buf, cp->buf_size);
 	cp->data_len = 0;
@@ -242,7 +243,10 @@

 void neurite_child_worker(void)
 {
-	log_dbg("my time is: %d ms\n\r", millis());
+	struct neurite_data_s *nd = &g_nd;
+	char tmp[64];
+	sprintf(tmp, "%s time: %d ms", nd->nmcfg.uid, millis());
+	mqtt_cli.publish(nd->nmcfg.topic_to, tmp);
 }

 static inline void start_child_worker(void)
@@ -270,7 +274,7 @@

 			log_dbg("WiFi connected\n\r");
 			log_dbg("IP address: ");
-			USE_SERIAL.println(WiFi.localIP());
+			LOG_SERIAL.println(WiFi.localIP());

 			if (digitalRead(NEURITE_BUTTON) == LOW) {
 				ticker_led.detach();
@@ -303,8 +307,34 @@
 	}
 }

+static void cmd_parse_byte(struct cmd_parser_s *cp, char value)
+{
+	dbg_assert(cp);
+	switch (value) {
+		case '\r':
+			if (cp->callback != NULL)
+				cp->callback(cp);
+			break;
+		default:
+			if (cp->data_len < cp->buf_size)
+				cp->buf[cp->data_len++] = value;
+			break;
+	}
+}
+
+static void ticker_cmd_task(struct neurite_data_s *nd)
+{
+	char c;
+	if (CMD_SERIAL.available() <= 0)
+		return;
+	c = CMD_SERIAL.read();
+	LOG_SERIAL.printf("%c", c);
+	cmd_parse_byte(nd->cp, c);
+}
+
 void neurite_cmd_init(struct neurite_data_s *nd)
 {
+	ticker_cmd.attach_ms(1, ticker_cmd_task, nd);
 }

 void neurite_init(void)
@@ -350,10 +380,10 @@

 void setup()
 {
-	USE_SERIAL.begin(115200);
-	USE_SERIAL.setDebugOutput(false);
-	USE_SERIAL.printf("\n\r");
-	USE_SERIAL.flush();
+	LOG_SERIAL.begin(115200);
+	LOG_SERIAL.setDebugOutput(false);
+	LOG_SERIAL.printf("\n\r");
+	LOG_SERIAL.flush();
 	pinMode(NEURITE_LED, OUTPUT);
 	digitalWrite(NEURITE_LED, HIGH);
 	pinMode(NEURITE_BUTTON, INPUT);


update web server

update web server

--- neurite.ino
+++ neurite.ino
@@ -471,12 +471,167 @@
 ESP8266WebServer *server;
 File fsUploadFile;

-void handleRoot() {
-	server->send(200, "text/plain", "hello from esp8266!");
-}
-
 void handleNotFound() {
-	String message = "File Not Found\n\n";
+	if (!handleFileRead(server->uri())) {
+		String message = "File Not Found\n\n";
+		message += "URI: ";
+		message += server->uri();
+		message += "\nMethod: ";
+		message += (server->method() == HTTP_GET)?"GET":"POST";
+		message += "\nArguments: ";
+		message += server->args();
+		message += "\n";
+		for (uint8_t i=0; i<server->args(); i++) {
+			message += " " + server->argName(i) + ": " + server->arg(i) + "\n";
+		}
+		server->send(404, "text/plain", message);
+	}
+}
+
+static String formatBytes(size_t bytes)
+{
+	if (bytes < 1024) {
+		return String(bytes)+"B";
+	} else if (bytes < (1024 * 1024)) {
+		return String(bytes/1024.0)+"KB";
+	} else if (bytes < (1024 * 1024 * 1024)) {
+		return String(bytes/1024.0/1024.0)+"MB";
+	} else {
+		return String(bytes/1024.0/1024.0/1024.0)+"GB";
+	}
+}
+
+String getContentType(String filename)
+{
+	if (server->hasArg("download")) return "application/octet-stream";
+	else if (filename.endsWith(".htm")) return "text/html";
+	else if (filename.endsWith(".html")) return "text/html";
+	else if (filename.endsWith(".css")) return "text/css";
+	else if (filename.endsWith(".js")) return "application/javascript";
+	else if (filename.endsWith(".png")) return "image/png";
+	else if (filename.endsWith(".gif")) return "image/gif";
+	else if (filename.endsWith(".jpg")) return "image/jpeg";
+	else if (filename.endsWith(".ico")) return "image/x-icon";
+	else if (filename.endsWith(".xml")) return "text/xml";
+	else if (filename.endsWith(".pdf")) return "application/x-pdf";
+	else if (filename.endsWith(".zip")) return "application/x-zip";
+	else if (filename.endsWith(".gz")) return "application/x-gzip";
+	return "text/plain";
+}
+
+bool handleFileRead(String path)
+{
+	LOG_SERIAL.println("handleFileRead: " + path);
+	if (path.endsWith("/"))
+		path += "index.htm";
+	String contentType = getContentType(path);
+	String pathWithGz = path + ".gz";
+	if (SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) {
+		if (SPIFFS.exists(pathWithGz))
+			path += ".gz";
+		File file = SPIFFS.open(path, "r");
+		size_t sent = server->streamFile(file, contentType);
+		file.close();
+		return true;
+	}
+	return false;
+}
+
+void handleFileUpload()
+{
+	if (server->uri() != "/edit")
+		return;
+	HTTPUpload& upload = server->upload();
+	if (upload.status == UPLOAD_FILE_START) {
+		String filename = upload.filename;
+		if (!filename.startsWith("/"))
+			filename = "/"+filename;
+		log_info(": ");
+		LOG_SERIAL.println(filename);
+		fsUploadFile = SPIFFS.open(filename, "w");
+		filename = String();
+	} else if (upload.status == UPLOAD_FILE_WRITE) {
+		//LOG_SERIAL.print("handleFileUpload Data: "); LOG_SERIAL.println(upload.currentSize);
+		if (fsUploadFile)
+			fsUploadFile.write(upload.buf, upload.currentSize);
+	} else if (upload.status == UPLOAD_FILE_END) {
+		if (fsUploadFile)
+			fsUploadFile.close();
+		log_info("done, size: ");
+		LOG_SERIAL.println(upload.totalSize);
+	}
+}
+
+void handleFileDelete()
+{
+	if (server->args() == 0) return server->send(500, "text/plain", "BAD ARGS");
+	String path = server->arg(0);
+	log_info(": ");
+	LOG_SERIAL.println(path);
+	if (path == "/")
+		return server->send(500, "text/plain", "BAD PATH");
+	if (!SPIFFS.exists(path))
+		return server->send(404, "text/plain", "FileNotFound");
+	SPIFFS.remove(path);
+	server->send(200, "text/plain", "");
+	path = String();
+}
+
+void handleFileCreate()
+{
+	if (server->args() == 0)
+		return server->send(500, "text/plain", "BAD ARGS");
+	String path = server->arg(0);
+	log_info(": ");
+	LOG_SERIAL.println(path);
+	if (path == "/")
+		return server->send(500, "text/plain", "BAD PATH");
+	if (SPIFFS.exists(path))
+		return server->send(500, "text/plain", "FILE EXISTS");
+	File file = SPIFFS.open(path, "w");
+	if (file)
+		file.close();
+	else
+		return server->send(500, "text/plain", "CREATE FAILED");
+	server->send(200, "text/plain", "");
+	path = String();
+}
+
+void handleFileList()
+{
+	if (!server->hasArg("dir"))
+		server->send(500, "text/plain", "BAD ARGS"); return;
+	String path = server->arg("dir");
+	log_info(": ");
+	LOG_SERIAL.println(path);
+	Dir dir = SPIFFS.openDir(path);
+	path = String();
+
+	String output = "[";
+	while (dir.next()) {
+		File entry = dir.openFile("r");
+		if (output != "[") output += ',';
+		bool isDir = false;
+		output += "{\"type\":\"";
+		output += (isDir)?"dir":"file";
+		output += "\",\"name\":\"";
+		output += String(entry.name()).substring(1);
+		output += "\"}";
+		entry.close();
+	}
+	output += "]";
+	server->send(200, "text/json", output);
+}
+
+void handleRoot()
+{
+	if (!handleFileRead("/index.html"))
+		server->send(404, "text/plain", "FileNotFound");
+}
+
+void handleSave()
+{
+	String message = "Jolly good config!\n\n";
 	message += "URI: ";
 	message += server->uri();
 	message += "\nMethod: ";
@@ -484,131 +639,10 @@
 	message += "\nArguments: ";
 	message += server->args();
 	message += "\n";
-	for (uint8_t i=0; i<server->args(); i++){
+	for (uint8_t i=0; i<server->args(); i++) {
 		message += " " + server->argName(i) + ": " + server->arg(i) + "\n";
 	}
 	server->send(404, "text/plain", message);
-}
-
-static String formatBytes(size_t bytes){
-  if (bytes < 1024) {
-    return String(bytes)+"B";
-  } else if(bytes < (1024 * 1024)) {
-    return String(bytes/1024.0)+"KB";
-  } else if(bytes < (1024 * 1024 * 1024)) {
-    return String(bytes/1024.0/1024.0)+"MB";
-  } else {
-    return String(bytes/1024.0/1024.0/1024.0)+"GB";
-  }
-}
-
-String getContentType(String filename){
-  if(server->hasArg("download")) return "application/octet-stream";
-  else if(filename.endsWith(".htm")) return "text/html";
-  else if(filename.endsWith(".html")) return "text/html";
-  else if(filename.endsWith(".css")) return "text/css";
-  else if(filename.endsWith(".js")) return "application/javascript";
-  else if(filename.endsWith(".png")) return "image/png";
-  else if(filename.endsWith(".gif")) return "image/gif";
-  else if(filename.endsWith(".jpg")) return "image/jpeg";
-  else if(filename.endsWith(".ico")) return "image/x-icon";
-  else if(filename.endsWith(".xml")) return "text/xml";
-  else if(filename.endsWith(".pdf")) return "application/x-pdf";
-  else if(filename.endsWith(".zip")) return "application/x-zip";
-  else if(filename.endsWith(".gz")) return "application/x-gzip";
-  return "text/plain";
-}
-
-bool handleFileRead(String path){
-  LOG_SERIAL.println("handleFileRead: " + path);
-  if(path.endsWith("/")) path += "index.htm";
-  String contentType = getContentType(path);
-  String pathWithGz = path + ".gz";
-  if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){
-    if(SPIFFS.exists(pathWithGz))
-      path += ".gz";
-    File file = SPIFFS.open(path, "r");
-    size_t sent = server->streamFile(file, contentType);
-    file.close();
-    return true;
-  }
-  return false;
-}
-
-void handleFileUpload(){
-  if(server->uri() != "/edit") return;
-  HTTPUpload& upload = server->upload();
-  if(upload.status == UPLOAD_FILE_START){
-    String filename = upload.filename;
-    if(!filename.startsWith("/")) filename = "/"+filename;
-    LOG_SERIAL.print("handleFileUpload Name: "); LOG_SERIAL.println(filename);
-    fsUploadFile = SPIFFS.open(filename, "w");
-    filename = String();
-  } else if(upload.status == UPLOAD_FILE_WRITE){
-    //LOG_SERIAL.print("handleFileUpload Data: "); LOG_SERIAL.println(upload.currentSize);
-    if(fsUploadFile)
-      fsUploadFile.write(upload.buf, upload.currentSize);
-  } else if(upload.status == UPLOAD_FILE_END){
-    if(fsUploadFile)
-      fsUploadFile.close();
-    LOG_SERIAL.print("handleFileUpload Size: "); LOG_SERIAL.println(upload.totalSize);
-  }
-}
-
-void handleFileDelete(){
-  if(server->args() == 0) return server->send(500, "text/plain", "BAD ARGS");
-  String path = server->arg(0);
-  LOG_SERIAL.println("handleFileDelete: " + path);
-  if(path == "/")
-    return server->send(500, "text/plain", "BAD PATH");
-  if(!SPIFFS.exists(path))
-    return server->send(404, "text/plain", "FileNotFound");
-  SPIFFS.remove(path);
-  server->send(200, "text/plain", "");
-  path = String();
-}
-
-void handleFileCreate(){
-  if(server->args() == 0)
-    return server->send(500, "text/plain", "BAD ARGS");
-  String path = server->arg(0);
-  LOG_SERIAL.println("handleFileCreate: " + path);
-  if(path == "/")
-    return server->send(500, "text/plain", "BAD PATH");
-  if(SPIFFS.exists(path))
-    return server->send(500, "text/plain", "FILE EXISTS");
-  File file = SPIFFS.open(path, "w");
-  if(file)
-    file.close();
-  else
-    return server->send(500, "text/plain", "CREATE FAILED");
-  server->send(200, "text/plain", "");
-  path = String();
-}
-
-void handleFileList() {
-  if(!server->hasArg("dir")) {server->send(500, "text/plain", "BAD ARGS"); return;}
-
-  String path = server->arg("dir");
-  LOG_SERIAL.println("handleFileList: " + path);
-  Dir dir = SPIFFS.openDir(path);
-  path = String();
-
-  String output = "[";
-  while(dir.next()){
-    File entry = dir.openFile("r");
-    if (output != "[") output += ',';
-    bool isDir = false;
-    output += "{\"type\":\"";
-    output += (isDir)?"dir":"file";
-    output += "\",\"name\":\"";
-    output += String(entry.name()).substring(1);
-    output += "\"}";
-    entry.close();
-  }
-
-  output += "]";
-  server->send(200, "text/json", output);
 }

 /* server test end */
@@ -678,38 +712,25 @@
 			*/
 			server = new ESP8266WebServer(80);
 			server->on("/list", HTTP_GET, handleFileList);
-			server->on("/edit", HTTP_GET, [](){
-					if(!handleFileRead("/edit.htm")) server->send(404, "text/plain", "FileNotFound");
-					});
+			server->on("/edit", HTTP_GET, []() {
+				if (!handleFileRead("/edit.htm")) server->send(404, "text/plain", "FileNotFound");
+			});
 			server->on("/edit", HTTP_PUT, handleFileCreate);
 			server->on("/edit", HTTP_DELETE, handleFileDelete);
-			server->on("/edit", HTTP_POST, [](){ server->send(200, "text/plain", ""); }, handleFileUpload);
-
-			server->onNotFound([](){
-				if (!handleFileRead(server->uri())) {
-					String message = "File Not Found\n\n";
-					message += "URI: ";
-					message += server->uri();
-					message += "\nMethod: ";
-					message += (server->method() == HTTP_GET)?"GET":"POST";
-					message += "\nArguments: ";
-					message += server->args();
-					message += "\n";
-					for (uint8_t i=0; i<server->args(); i++)
-						message += " " + server->argName(i) + ": " + server->arg(i) + "\n";
-					server->send(404, "text/plain", message);
-				}
+			server->on("/edit", HTTP_POST, []() { server->send(200, "text/plain", ""); }, handleFileUpload);
+			server->on("/save", HTTP_POST, handleSave);
+
+			server->onNotFound(handleNotFound);
+
+			server->on("/all", HTTP_GET, []() {
+				String json = "{";
+				json += "\"heap\":"+String(ESP.getFreeHeap());
+				json += ", \"analog\":"+String(analogRead(A0));
+				json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
+				json += "}";
+				server->send(200, "text/json", json);
+				json = String();
 			});
-
-			server->on("/all", HTTP_GET, [](){
-					String json = "{";
-					json += "\"heap\":"+String(ESP.getFreeHeap());
-					json += ", \"analog\":"+String(analogRead(A0));
-					json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
-					json += "}";
-					server->send(200, "text/json", json);
-					json = String();
-					});

 			server->on("/", handleRoot);
 			server->begin();


Started button debouncing code

Started button debouncing code

--- src/bikelight/bikelight.ino
+++ src/bikelight/bikelight.ino
@@ -8,28 +8,36 @@

 This code is written for a destination board of a digispark V4. Hence pin
 references and other libraries may be used in a unusual manner from normal
-arduino coding .
+arduino coding.
+
+Code borrowed from some of the tutorials at https://www.arduino.cc/en/Tutorial/HomePage
 */

 #include <arduino.h>
 #include <wire.h>

-const byte frontLED 1 //digital pin 1 (PWM) - Output
-const byte backLED  4 //digital pin 4 (PWM) - Output
-const byte frontSwitch 3 //digital pin 3 - Input
-const byte backSwitch 5 //digital pin 5 - Input
-const byte slaveAddress 8
+const byte frontLED 1; //digital pin 1 (PWM) - Output
+const byte backLED  4; //digital pin 4 (PWM) - Output
+const byte frontSwitch 3; //digital pin 3 - Input
+const byte backSwitch 5; //digital pin 5 - Input
+const byte slaveAddress 8;
 //SDA = pin D0
 //SCL = pin D2

 int frontLEDpulse = 0;
 int backLEDpulse = 0;

-int frontButtonState; //current reading for front button input pin
-int frontLastButtonState; //previous reading from front button input pin
-int backButtonState; //current reading for back button input pin
-int backLastButtonState; //previous reading from back button input pin
+byte frontButtonState; //current reading for front button input pin
+byte frontLastButtonState = HIGH; //previous reading from front button input pin
+byte backButtonState; //current reading for back button input pin
+byte backLastButtonState = HIGH; //previous reading from back button input pin
+int frontButtonCounter = 0; //pulse counter for buttons
+int backButtonCounter = 0;

+// the following variables are unsigned longs because the time, measured in
+// milliseconds, will quickly become a bigger number than can be stored in an int.
+unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
+unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers

 void setup() {
   pinMode(frontLED, OUTPUT);
@@ -44,8 +52,27 @@
 }

 void loop() {
+  //store state of switch
   int frontReading = digitalRead(frontSwitch);
   int backReading = digitalRead(backSwitch);
+
+  if (frontReading != frontLastButtonState ||backReading != backLastButtonState) {
+    //reset debounce timer
+    lastDebounceTime = millis();
+  }
+  if ((millis()-lastDebounceTime) > debounceDelay){
+    // whatever the reading is at, it's been there for longer than the debounce
+    // delay, so take it as the actual current state:
+
+    //if button state has changed
+    if (frontReading!= frontButtonState){
+      frontButtonState = frontReading;
+    }
+    if (backReading!= backButtonState){
+      backButtonState = backReading;
+    }
+  }
+
 }

 void receiveEvent(int quantity){


fixed volume on headphone change

fixed volume on headphone change

--- src/src.ino
+++ src/src.ino
@@ -580,6 +580,7 @@
     volume = volume + SPEAKER_VOLUME_MAX - HEADPHONE_VOLUME_MAX;
   }
   enableAmplifier(!headphone);
+  player.setVolume(volume, volume);
 }

 // Set volume for left, right channels. lower numbers == louder volume!


Moved to a folder to be easily open in Arduino IDE.

--- examples/SimpleRadioStationSelection.ino
+++ examples/SimpleRadioStationSelection.ino
@@ -1,16 +0,0 @@
-#include <Wire.h>
-#include <TEA5767N.h>
-
-TEA5767N radio = TEA5767N();
-
-void setup() {
-
-  radio.selectFrequency(89.1);
-
-}
-
-void loop() {
-
-}
-
-


stappen motor erin verwerkt. geen idee of het met die intervals gaat werken

--- programmaNano/programmaNano.ino
+++ programmaNano/programmaNano.ino
@@ -2,10 +2,11 @@
 int reader;
 // Generally, you should use "unsigned long" for variables that hold time
 // The value will quickly become too large for an int to store
-unsigned long previousMillis = 0;        // will store last time LED was updated
-
-// constants won't change :
-const long interval = 500;           // interval at which to blink (milliseconds)
+unsigned long previousMillis = 0;
+unsigned long previousMillisStappenmotor = 0;
+
+const long interval = 50;
+const long intervalStappenmotor = 50;

 #define echoPin 5          // Echo Pin
 #define trigPin 4          // Trigger Pin
@@ -41,11 +42,12 @@
   else if (reader == 3) { myservo.write(0); delay(550); reader = -1; }
   else if (reader == 4) { myservo.write(180); delay(550); reader = -1; }
   else{
-    Distance();
-    delay(100);
-    }
-
-
+
+     if (currentMillis - previousMillis >= interval) {
+        Distance();
+        previousMillis = currentMillis;
+     }
+    }
 }

 void Distance() { // meet de afstand van de sensor
@@ -78,3 +80,125 @@
   Serial.println(distance);
 }

+void 1draaiNaarBeneden(){
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+    previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, HIGH);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, HIGH);
+    delay(10);
+  }
+
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, HIGH);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, HIGH);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, HIGH);
+    delay(10);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, HIGH);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, HIGH);
+    digitalWrite(coilb1, HIGH);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, HIGH);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, HIGH);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, HIGH);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, HIGH);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, LOW);
+  }
+}
+
+void 1draaiNaarBoven(){
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, HIGH);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, HIGH);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, HIGH);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+  previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, HIGH);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+    previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, HIGH);
+    digitalWrite(coilb1, HIGH);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+    previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, HIGH);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, LOW);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+    previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, HIGH);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, HIGH);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+    previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, LOW);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, HIGH);
+  }
+  if (currentMillis - previousMillisStappenmotor >= intervalStappenmotor) {
+    previousMillisStappenmotor = currentMillis;
+    digitalWrite(coila1, HIGH);
+    digitalWrite(coila2, LOW);
+    digitalWrite(coilb1, LOW);
+    digitalWrite(coilb2, HIGH);
+  }
+}
+


Fixed arkanoid for Linux platform

Fixed arkanoid for Linux platform

--- examples/arkanoid/arkanoid.ino
+++ examples/arkanoid/arkanoid.ino
@@ -195,7 +195,7 @@

 void loop()
 {
-    if ( ((uint16_t)millis()) - lastDrawTimestamp > 30 )
+    if ( (uint16_t)(((uint16_t)millis()) - lastDrawTimestamp) > 30 )
     {
         uint8_t lastx = (ballx >> SPEED_SHIFT);
         uint8_t lasty = (bally >> SPEED_SHIFT);


remove mqtt cert

remove mqtt cert


--- esp8266_160528_MPL115A2.ino
+++ esp8266_160528_MPL115A2.ino
@@ -4,6 +4,7 @@

 /*
  * v0.8 2016 Jun. 26
+ *   - modify UdpTxAltitude() to have bettern handling as csv format
  *   - tweak delay in loop() to have approximately 1 second in total
  * v0.7 2016 Jun. 26
  *   - esp8266_160602_udpTxToLogger > increase connection retry from 3 to 6
@@ -162,12 +163,12 @@
   // 1. pressure
   whl = (int)prs;
   frac = (int)(prs*100) % 100;
-  pos = sprintf(&szbuf[pos],"Pressure(kPa)=%d.%02d", whl, frac);
+  pos = sprintf(&szbuf[pos],"Pressure(kPa)=,%d.%02d", whl, frac);

   // 2. altitude
   whl = (int)alt;
   frac = (int)(alt*100) % 100;
-  pos = sprintf(&szbuf[pos],",Altitude(m)=%d.%02d\r\n", whl, frac);
+  pos = sprintf(&szbuf[pos],",Altitude(m)=,%d.%02d\r\n", whl, frac);

   WiFi_txMessage(szbuf);
 }


Added blinking functions.

Added blinking functions.

--- wip/wip.ino
+++ wip/wip.ino
@@ -12,7 +12,7 @@
 }

 void loop() {
-  blinking(leds, NUM_LEDS, 0, 10, 0, 5000);
+  blinking(leds, NUM_LEDS, 0, 10, 0, 3000);
 }

 void runner(CRGB *leds, int numOfLeds, int red, int green, int blue, int ms) {
@@ -71,6 +71,13 @@
     }
 }

+void progressbarCentered(CRGB *leds, int numOfLeds, int red, int green, int blue, int ms) {
+
+    int i, center;
+
+    center = numOfLeds / 2;
+}
+
 void blinking(CRGB *leds, int numOfLeds, int red, int green, int blue, int ms) {

   int i;
@@ -91,3 +98,26 @@
   FastLED.show();
   delay(ms);
 }
+
+void blinkingParts(CRGB *leds, int numOfLeds, int parts, int red, int green, int blue, int ms) {
+
+    int i, steps;
+
+    steps = numOfLeds / parts;
+
+    for(i = 0; i < numOfLeds; i += steps) {
+
+        leds[i].setRGB(red, green, blue);
+    }
+
+    FastLED.show();
+    delay(ms);
+
+    for(i = 0; i < numOfLeds; i += steps) {
+
+        leds[i].setRGB(0, 0, 0);
+    }
+
+    FastLED.show();
+    delay(ms);
+}


update library paths for Build and temporary FastLEDSmartMatrix

--- firmware/examples/FastLedComparison/FastLedComparison.ino
+++ firmware/examples/FastLedComparison/FastLedComparison.ino
@@ -3,10 +3,10 @@
 #include "application.h"

 #if (SMARTMATRIX_ENABLED == 1)
-  #include <SmartMatrix3.h>
+  #include "SmartMatrix3/SmartMatrix3.h"
 #endif

-#include "FastLED/FastLED.h"
+#include "FastLEDSmartMatrix/FastLEDSmartMatrix.h"
 FASTLED_USING_NAMESPACE;

 #if (SMARTMATRIX_ENABLED == 1)


update arduino/servo_test to accept speed command over serial port

--- arduino/servo_test/servo_test.ino
+++ arduino/servo_test/servo_test.ino
@@ -1,31 +1,43 @@
 #include <Servo.h>

+#define PIN 2
+#define PULSEMIN 1
+#define PULSEMAX 1
+
 Servo s1;
-int PWMPIN = 2;
-bool toggle = true;
+char buffer[128];
+int8_t i = 0;
+uint8_t speed = 0;
+bool ready = false;

 void setup() {
   // put your setup code here, to run once:
   Serial.begin(115200);
-  s1.attach(PWMPIN, 1, 2);
-  s1.write(0);
+  s1.attach(PIN, PULSEMIN, PULSEMAX);
+  s1.write(90);

-  Serial.println("start");
-
+  Serial.println("Enter a number between 0 and 180");
 }

 void loop() {
   // put your main code here, to run repeatedly:
-  Serial.println("live");
-  if (toggle)
-  {
-    s1.write(90);
-    toggle = false;
+  if(Serial.available()>0) {
+    buffer[i] = Serial.read();
+    if(buffer[i]==';') {
+      buffer[i] = '\0'; // replace ';' with '\0'
+      speed = atoi(buffer); // convert string to int
+
+      // reset
+      ready = true;
+      i = -1;
+    }
+    i++;
   }
-  else
-  {
-    s1.write(0);
-    toggle = true;
+
+  if(ready) {
+    Serial.print("Sending: ");
+    Serial.println(speed, DEC);
+    s1.write(speed);
+    ready = false;
   }
-  delay(3 * 1000);
 }


update

update

--- PixelViews/Goomba/Goomba.ino
+++ PixelViews/Goomba/Goomba.ino
@@ -10,9 +10,13 @@
 #define PIN_MODE 4
 #define PIN_LED A1

-int currentMode = 1;
+int currentMode = 4;
 #define MAXMODE 5
 int eeprom_addr = 0;
+
+long lastMillis = millis();
+long currentMillis = millis();
+long pauseMillis = 10 * 1000;

 const uint8_t kMatrixWidth = 20;
 const uint8_t kMatrixHeight = 10;
@@ -106,15 +110,17 @@

   EEPROM.write(eeprom_addr, currentMode);

+  FastLED.clear();
+
   switch(currentMode)
   {
-    case 0: ShowGoomba(); break;
-    case 1: Test(); break;
-    case 2: ShowPotValue(); break;
-    case 3: RainbowA(); break;
+    case 0: Test(); break;
+    case 1: ShowPotValue(); break;
+    case 2: RainbowA(); break;
+    case 3: ShowGoomba(); break;
     case 4: ShowMario(); break;
   }
-
+
   FastLED.show();
   FastLED.setBrightness(newBrightness);
 }
@@ -148,10 +154,9 @@

 void Test()
 {
-  FastLED.clear();
-  set_led_rgb(1, 1, 255, 0, 0);
-  set_led_rgb(2, 1, 0, 255, 0);
-  set_led_rgb(2, 1, 0, 0, 255);
+  set_led_rgb(0, 1, 255, 0, 0);
+  set_led_rgb(1, 1, 0, 255, 0);
+  set_led_rgb(2, 1, 0, 0, 255);
 }

 void ShowPotValue()
@@ -168,8 +173,6 @@

 void ShowGoomba()
 {
-  FastLED.clear();
-  // Shows a Goomba, see https://raw.githubusercontent.com/cbries/rgbwall/master/Photos,%20Images,%20Videos/Goomba01.jpg
 set_led_rgb(0, 0, 235, 168, 130);
 set_led_rgb(1, 0, 227, 91, 6);
 set_led_rgb(2, 0, 143, 58, 6);


Updated example Touchscreen_GUI_Demo

Updated example Touchscreen_GUI_Demo

--- examples/Touchscreen_GUI_Demo/Touchscreen_GUI_Demo.ino
+++ examples/Touchscreen_GUI_Demo/Touchscreen_GUI_Demo.ino
@@ -27,9 +27,9 @@
 #define TS_CS 0   // Wemos D1 Mini D3

 // For MH-ET Live esp32 MiniKit (ESP32)
-#define TFT_CS 26 // esp32 MiniKit D0
-#define TFT_DS 5  // esp32 MiniKit D8
-#define TS_CS 17  // esp32 MiniKit D3
+//#define TFT_CS 26 // esp32 MiniKit D0
+//#define TFT_DS 5  // esp32 MiniKit D8
+//#define TS_CS 17  // esp32 MiniKit D3

 #define BG_COLOR 0xDFE  //Background color (light blue)
 Canvas_XPT2046 canvas = Canvas_XPT2046(TFT_PORTRAIT,BG_COLOR,TFT_CS,TFT_DS,TS_CS);
@@ -66,7 +66,7 @@
 }

 void btnMainEventHandler(Button* btn){
-  header.setText("Main");
+  header.setText("Main",true);
   canvas.setScreen(&screen_main);
   terminal.clear();
   welcomeMessage();
@@ -76,6 +76,7 @@
   // Show the numkey to enter a password
   // The numkey event handler will verify the password
   // and change the screen if the password is correct
+
   terminal.clear();
   terminal.print("Enter the numeric password:");
   terminal.print("1234",GREEN);
@@ -83,7 +84,7 @@
 }

 void btnButtonsEventHandler(Button* btn){
-  header.setText("Buttons");
+  header.setText("Buttons",true);
   canvas.setScreen(&screen_buttons);
   terminal.clear();
   terminal.print("Icon buttons use images to");
@@ -116,7 +117,7 @@
       if(nk->getText()[i] != password[i]) match = false;
     }
     if(match){
-      header.setText("Dial");
+      header.setText("Dial",true);
       canvas.setScreen(&screen_dial);
       terminal.clear();
       terminal.print("Dial reprents a value in a range");


Fixed unit in uController code

Fixed unit in uController code

--- ucontroller/ucontroller.ino
+++ ucontroller/ucontroller.ino
@@ -41,7 +41,7 @@
 char readByte;

 // 10-bit ADC, measuring 0-5V, the LM335AZ sensor outputs 10mV/K
-const float ADC_STEPS_TO_MV = (5.0/*V*/ / 1024.0/*steps*/) * 100.0;
+const float ADC_STEPS_TO_CV = (5.0/*V*/ / 1024.0/*steps*/) * 100.0/*cV/V*/;

 // Temperature Pin #
 const int TEMPERATURE_PIN = 19;
@@ -204,7 +204,7 @@
  * Reads the temperature from the temperature pin
  */
  void updateTemp() {
-  currentTemp = analogRead(TEMPERATURE_PIN) * ADC_STEPS_TO_MV - 273.15; // approximate Kelvin->Celsius
+  currentTemp = analogRead(TEMPERATURE_PIN) * ADC_STEPS_TO_CV - 273.15; // steps->cV, 1cV/K, Kelvin->Celsius
  }

 /**


RaceTimer: improved code structure & began menu control logic

--- RaceTimer/RaceTimer/RaceTimer.ino
+++ RaceTimer/RaceTimer/RaceTimer.ino
@@ -2,6 +2,7 @@
 #include <Chrono.h>
 #include <LightChrono.h>

+/* Pin Definitions */
 const int laserPin = 2;     // the number of the pushbutton pin
 const int buzzerPin =  3;      // the number of the LED pin
 const int onPin = 4;     // the number of the pushbutton pin
@@ -10,22 +11,37 @@
 const int prevPin = 6;
 const int nextPin = 7;
 const int setPin = 8;
+/* End Pin Definitions*/

+/* Variable Definitions */
 Chrono chrono(Chrono::MICROS);
+LightChrono measurementTimeout;
+
 unsigned long measuredTimes[10];
 int measurementIndex = 0;
 int maxMeasurements = 5;

-LightChrono measurementTimeout;
-
 int laserState = 0;         // variable for reading the pushbutton status
 int oldLaserState = 0;
 bool enabled = true;
+/* End Variable Definitions */
+
+/* Menu Definitions */
+int menuIndex = 0;
+
+void mainMenu();
+void settingsMenu();
+void chronoView();
+void resultsView();
+
+int (*views[4]) ();
+/* End Menu Definitions */

 void setup() {
   Serial.begin(9600);   // Test
   Serial.println("Stopwatch");

+  // Pin Modes
   pinMode(buzzerPin, OUTPUT);
   pinMode(laserPin, INPUT);
   pinMode(onPin, INPUT);
@@ -35,9 +51,15 @@
   pinMode(nextPin, INPUT);
   pinMode(setPin, INPUT);

+  // Chrono initializations
   measurementTimeout.restart();
-
   chrono.stop();
+
+  // Menu initializations
+  views[0] = mainMenu;
+  views[1] = settingsMenu;
+  views[2] = chronoView;
+  views[3] = resultsView;
 }

 void loop() {
@@ -84,6 +106,22 @@

 }

+void mainMenu() {
+	Serial.println("RaceTimer");
+
+	switch(menuIndex){
+		case 0:
+			Serial.println("Start");
+			break;
+		case 1:
+			Serial.println("Settings");
+			break;
+		default:
+			break;
+	}
+
+}
+
 void settingsMenu() {

   do {
@@ -102,6 +140,23 @@

   } while (!digitalRead(returnPin));

+}
+
+void chronoView() {
+	Serial.println("Chrono");
+}
+
+void resultsView() {
+	Serial.println("Results");
+}
+
+void checkMenuIndex() {
+	if (digitalRead(nextPin)) {
+		menuIndex++;
+	}
+	if (digitalRead(prevPin)) {
+		menuIndex--;
+	}
 }

 void logAndRestart() {


to debug more

to debug more

--- _41-promini-nrf24-ads1115/_41-promini-nrf24-ads1115.ino
+++ _41-promini-nrf24-ads1115/_41-promini-nrf24-ads1115.ino
@@ -52,6 +52,9 @@
 int rangeStatus;
 volatile int recordNo;
 volatile boolean dorecored;
+//unsigned long startmilis;
+//unsigned long stopmilis;
+unsigned long loopcount;

 void record() {
   recordNo++;
@@ -61,7 +64,6 @@
 void setup() {
   delay(20);
   adc_disable();
-
   pinMode(doRecordPin, INPUT);
   pinMode(microPin, INPUT_PULLUP);
   pinMode(nanoPin, INPUT_PULLUP);
@@ -75,6 +77,10 @@
   rangeStatus = microStatus << 1;
   rangeStatus = rangeStatus + nanoStatus;

+  //startmilis = 0;
+  //stopmilis = 0;
+  loopcount = 0;
+
   recordNo = 0;
   dorecored = false;

@@ -93,6 +99,7 @@

   payload._salt = 0;
   payload.devid = DEVICE_ID;
+  payload.volt  = 0;

   ads.setGain(GAIN_ONE);
   ads.begin();
@@ -112,6 +119,7 @@

 void loop() {
   if (dorecored == true) {
+    //startmilis = millis();
     digitalWrite(ledPin, HIGH);
     int microStatus = digitalRead(microPin);
     int nanoStatus  = digitalRead(nanoPin);
@@ -126,15 +134,17 @@

     payload.data1 = results * multiplier ;
     payload.data2 = rangeStatus;
-
+    payload.volt = loopcount;
     payload._salt = recordNo ;
-    payload.volt = 3300;

     ads.readADC_Differential_0_1_no_delay();

-    radio.write(&payload , sizeof(payload));
+    radio.write(&payload, sizeof(payload));

     digitalWrite(ledPin, LOW);
+    //stopmilis = millis();
+    //payload.volt = ( stopmilis - startmilis ) ;
+    loopcount++;
   } else {
     digitalWrite(ledPin, LOW);
   }


oled-dispay-sketch.ino: Check I2C OLED display

Add a quick check at the beginning to verify if mini OLED
display has been attached by testing I2C address 3c. Keep
in mind that this is the default address of the supported
OLED display. Some other display models may have a
different I2C address.

Signed-off-by: Leon Anavi <be92910ae7bb6f58bb9b7c6f845bc30640119592@anavi.org>

--- peripherals/oled-dispay-sketch/oled-dispay-sketch.ino
+++ peripherals/oled-dispay-sketch/oled-dispay-sketch.ino
@@ -4,10 +4,13 @@

 // For OLED display
 #include <U8g2lib.h>
+// For I2C
+#include <Wire.h>

 U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

 const int pinButton = 0;
+const int i2cDisplayAddress = 0x3c;

 void drawDisplay(const char *line1, const char *line2 = "", const char *line3 = "")
 {
@@ -23,11 +26,36 @@
   u8g2.sendBuffer();
 }

+bool isSensorAvailable(int sensorAddress)
+{
+  // Check if I2C sensor is present
+  Wire.beginTransmission(sensorAddress);
+  return 0 == Wire.endTransmission();
+}
+
+void checkDisplay()
+{
+  Serial.print("Mini I2C OLED Display at address ");
+  Serial.print(i2cDisplayAddress, HEX);
+  if (isSensorAvailable(i2cDisplayAddress))
+  {
+      Serial.println(": OK");
+  }
+  else
+  {
+      Serial.println(": N/A");
+  }
+}
+
 void setup()
 {
   // put your setup code here, to run once:
   Serial.begin(115200);
   Serial.println();
+
+  Wire.begin();
+  checkDisplay();
+
   u8g2.begin();

   delay(10);


whoops

whoops

--- sounddetector/sounddetector.ino
+++ sounddetector/sounddetector.ino
@@ -84,7 +84,7 @@

       // Send channel 0 as test:
       if(pin == 0){
-        uint16_t number = averageSoundValues[pin];
+        uint16_t number = soundValues[pin];
         uint16_t mask   = B11111111;
         uint8_t first_half   = number >> 8;
         uint8_t sencond_half = number & mask;


Update LCD.ino

Update LCD.ino

--- examples/Widgets/LCD/LCD.ino
+++ examples/Widgets/LCD/LCD.ino
@@ -39,8 +39,11 @@
     // Wait until connected
   }

-  lcd.clear();
-  lcd.print(0, 1, "Wow! :)");
+  lcd.clear(); //Use it to clear the LCD Widget
+  lcd.print(4, 0, "Hello"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
+  lcd.print(4, 1, "World");
+  // Please use timed events when LCD printintg in void loop to avoid sending too many commands
+  // It will cause a FLOOD Error, and connection will be dropped
 }

 void loop()


only available for boards with ADC_USE_PDB

--- examples/adc_pdb/adc_pdb.ino
+++ examples/adc_pdb/adc_pdb.ino
@@ -44,6 +44,7 @@
 int value2;

 void loop() {
+    #ifdef ADC_USE_PDB

     if (Serial.available()) {
         c = Serial.read();
@@ -100,6 +101,8 @@
     //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));

     delay(10);
+
+    #endif // ADC_USE_PDB
 }

@@ -116,8 +119,10 @@
 }
 #endif

+#ifdef ADC_USE_PDB
 // pdb interrupt is enabled in case you need it.
 void pdb_isr(void) {
         PDB0_SC &=~PDB_SC_PDBIF; // clear interrupt
         //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) );
 }
+#endif


Fix typo.

Fix typo.

DeserializationOpion --> DeserializationOption

--- examples/JsonFilterExample/JsonFilterExample.ino
+++ examples/JsonFilterExample/JsonFilterExample.ino
@@ -2,7 +2,7 @@
 // Copyright © 2014-2022, Benoit BLANCHON
 // MIT License
 //
-// This example shows how to use DeserializationOpion::Filter
+// This example shows how to use DeserializationOption::Filter
 //
 // https://arduinojson.org/v6/example/filter/


Old restoration

Old restoration

--- interocitor/interocitor.ino
+++ interocitor/interocitor.ino
@@ -57,7 +57,7 @@
 #define pulse_mode_switch   9
 #define estop_switch        11

-#define channel_1_out       23
+#define channel_1_out       22
 #define channel_2_out       22

 #define pulsewidth_pot A0
@@ -67,7 +67,7 @@
 #define NOTE_MIN 21
 #define NOTE_MAX 108
 #define PULSEWIDTH_MIN 35
-#define PULSEWIDTH_MAX 300
+#define PULSEWIDTH_MAX 250

 int clamp_pulse_width(float nominal_width) {
   return (int) constrain(nominal_width, PULSEWIDTH_MIN, PULSEWIDTH_MAX);
@@ -182,8 +182,8 @@
 }

 bool update_pulse_duty_cycle() {
-  if( (old_pulse_duty_cycle_setpoint + 5) < pulse_duty_cycle_setpoint ||
-      (old_pulse_duty_cycle_setpoint - 5) > pulse_duty_cycle_setpoint ) {
+  if( (old_pulse_duty_cycle_setpoint + 50) < pulse_duty_cycle_setpoint ||
+      (old_pulse_duty_cycle_setpoint - 50) > pulse_duty_cycle_setpoint ) {
     old_pulse_duty_cycle_setpoint = pulse_duty_cycle_setpoint;
     return true;
   }
@@ -238,6 +238,7 @@
     while (system_mode == 4) {
       read_controls();
       update_bottom_display_line();
+      update_pulse_duty_cycle();

       digitalWriteFast(channel_1_out, HIGH);
       delay_safe_micros(interrupter_pulsewidth_setpoint);
@@ -417,7 +418,7 @@
 // For the pulsed (tick) mode
 void pulse_static() {
   digitalWriteFast(channel_1_out, HIGH);
-  delay_safe_micros(velocity_to_pulse_length(64));
+  delay_safe_micros(interrupter_pulsewidth_setpoint);
   digitalWriteFast(channel_1_out, LOW);
 }


html and vehicle esp8266 move

html and vehicle esp8266 move

--- html_esp8266_control/html_esp8266_control.ino
+++ html_esp8266_control/html_esp8266_control.ino
@@ -1,22 +1,32 @@
-#include <Servo.h>
+
 #include <ESP8266WiFi.h>

-const int leftF = -1;
-const int rightF = 1;
-const int pinL = 4;
-const int pinR = 5;
+const int pinPWML = 4;
+const int pinPWMR = 5;
+const int pinDL = 0;
+const int pinDR = 2;
+int power = 1023;
+char lastCommand = ' ';

 WiFiServer server(80);

-long lastCommand = 0;
+long lastCommandTime = 0;
 long currentTime;
 long previousTime;
 long timeoutTime = 2000;
 String header;
 //bool stopedL = true;
 //bool stopedR = true;
+
+void showPage(WiFiClient& client);
+void left();
+void right();
+void forward();
+void backward();
+void stop();
+void setPower(int p);

 void setup() {
@@ -26,9 +36,13 @@
   Serial.println("WIFI IP address");
   Serial.println(WiFi.localIP());
   server.begin();
-}
-
-void showPage(WifiClient& client){
+  pinMode(pinPWML, OUTPUT);
+  pinMode(pinPWMR, OUTPUT);
+  pinMode(pinDR, OUTPUT);
+  pinMode(pinDL, OUTPUT);
+}
+
+void showPage(WiFiClient& client){
 	client.println("<!DOCTYPE html><html> <head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
         client.println("<link rel=\"icon\" href=\"data:,\">");
             client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
@@ -58,30 +72,39 @@
  // turns the GPIOs on and off
 	    if(header.length() < 14) return 'i';
             if (header.indexOf("GET /command/f") >= 0) {
+              lastCommand = 'f';
               Serial.println("f");
-              return 'f'
+              return 'f';
             } else if (header.indexOf("GET /command/b") >= 0) {
+              lastCommand = 'b';
               Serial.println("b");
               return 'b';
             } else if (header.indexOf("GET /command/r") >= 0) {
+              lastCommand = 'b';
               Serial.println("r");
               return 'r';
             } else if (header.indexOf("GET /command/l") >= 0) {
+              lastCommand = 'l';
               Serial.println("l");
               return 'l';
             } else if (header.indexOf("GET /command/x") >= 0) {
+              lastCommand = 'x';
               Serial.println("x");
               return 'x';
             } else if (header.indexOf("GET /command/a") >= 0) {
+              lastCommand = 'a';
               Serial.println("a");
               return 'a';
             } else if (header.indexOf("GET /command/u") >= 0) {
+              lastCommand = 'u';
               Serial.println("u");
               return 'u';
             } else if (header.indexOf("GET /command/d") >= 0) {
+              lastCommand = 'd';
               Serial.println("d");
               return 'd';
             } else if (header.indexOf("GET /command/c") >= 0) {
+              lastCommand = 'c';
               Serial.println("c");
               return 'c';
             } else if (header.indexOf("GET /command/0") >= 0) {
@@ -111,7 +134,7 @@
             } else if (header.indexOf("GET /command/8") >= 0) {
               Serial.println("8");
               return '8';
-            } else return '-';
+            } else return 'i';
 }

 void loop() {
@@ -142,7 +165,39 @@

             char command = getCommand(header);

-            if(command == i) showPage(client);
+            if(command == 'i') showPage(client);
+            else {
+              switch(command){
+                case 'f':
+                 forward();
+                 break;
+                case 'b':
+                 backward();
+                 break;
+                case 'x':
+                 stop();
+                 break;
+                case 'r':
+                 right();
+                 break;
+                case 'l':
+                 left();
+                 break;
+                case '0':
+                case '1':
+                case '2':
+                case '3':
+                case '4':
+                case '5':
+                case '6':
+                case '7':
+                case '8':
+                setPower((int)command-48);
+                break;
+                default:
+                break;
+              }
+            }
             break;
           } else { // if you got a newline, then clear currentLine
             currentLine = "";
@@ -171,3 +226,48 @@
 //      stopAll();
 //    }
 }
+
+void forward(){
+  digitalWrite(pinDR, HIGH);
+  digitalWrite(pinDL, HIGH);
+  analogWrite(pinPWMR, power);
+  analogWrite(pinPWML, power);
+}
+void backward(){
+  digitalWrite(pinDR, LOW);
+  digitalWrite(pinDL, LOW);
+  analogWrite(pinPWMR, power);
+  analogWrite(pinPWML, power);
+}
+
+void left(){
+  digitalWrite(pinDR, HIGH);
+  digitalWrite(pinDL, LOW);
+  analogWrite(pinPWMR, power);
+  analogWrite(pinPWML, power);
+}
+
+void right(){
+  digitalWrite(pinDR, LOW);
+  digitalWrite(pinDL, HIGH);
+  analogWrite(pinPWMR, power);
+  analogWrite(pinPWML, power);
+}
+
+void stop(){
+  analogWrite(pinPWMR, 0);
+  analogWrite(pinPWML, 0);
+}
+
+void setPower(int p){
+  if(p == 0) power = 0;
+  else {
+    power = 512;
+    for(int i = 0; i < p; i++) power += 64;
+    power--;
+  }
+  if(lastCommand != 'x') {
+   analogWrite(pinPWMR, power);
+   analogWrite(pinPWML, power);
+  }
+}


Clean up of Serial report for pySerial bridge

--- protoshield/mwsv3/mwsv3.ino
+++ protoshield/mwsv3/mwsv3.ino
@@ -113,7 +113,8 @@
   float dallasT = sensors.getTempCByIndex(0);// Why "byIndex"?
   // You can have more than one IC on the same bus.
   // 0 refers to the first IC on the wire
-  Serial.print(dallasT);
+  Serial.print("Temperature D12B80 (C): ");
+  Serial.println(dallasT);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Temperature D12B80 ");
@@ -141,9 +142,8 @@
   if (event.pressure)
   {
     /* Display atmospheric pressure in hPa */
-    Serial.print("Pressure: ");
-    Serial.print(event.pressure);
-    Serial.println(" hPa");
+    Serial.print("Pressure (hPa): ");
+    Serial.println(event.pressure);
     lcd.clear();
     lcd.setCursor(0, 0);
     lcd.print("Pressure ");
@@ -161,11 +161,11 @@

   int chk = DHT11.read(DHT11PIN);

-  Serial.print("Read sensor: ");
+  //Serial.print("Read sensor: ");
   switch (chk)
   {
   case DHTLIB_OK:
-    Serial.println("DHT11 OK");
+    //Serial.println("DHT11 OK");
     break;
   case DHTLIB_ERROR_CHECKSUM:
     Serial.println("DHT11 Checksum error");
@@ -191,7 +191,7 @@
   sd.print((float)DHT11.humidity,2);
   sd.print(",");
   delay(2000);
-  Serial.print("Temperature (°C): ");
+  Serial.print("Temperature (C): ");
   Serial.println((float)DHT11.temperature, 2);
   lcd.clear();
   lcd.setCursor(0, 0);
@@ -203,7 +203,7 @@
   sd.print(",");
   delay(2000);

-  Serial.print("Temperature (°F): ");
+  Serial.print("Temperature (F): ");
   Serial.println(Fahrenheit(DHT11.temperature), 2);
   lcd.clear();
   lcd.setCursor(0, 0);
@@ -212,7 +212,7 @@
   lcd.print(Fahrenheit(DHT11.temperature), 2);
   lcd.print(" F");
   delay(2000);
-  Serial.print("Temperature (°K): ");
+  Serial.print("Temperature (K): ");
   Serial.println(Kelvin(DHT11.temperature), 2);
   lcd.clear();
   lcd.setCursor(0, 0);
@@ -222,7 +222,7 @@
   lcd.print(" K");
   //lcd.print("hello, world!");
   delay(2000);
-  Serial.print("Dew Point (°C): ");
+  Serial.print("Dew Point (C): ");
   Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));
   lcd.clear();
   lcd.setCursor(0, 0);
@@ -232,7 +232,7 @@
   lcd.print(" C");
   //lcd.print("hello, world!");
   delay(2000);
-  Serial.print("Dew PointFast (°C): ");
+  Serial.print("Dew PointFast (C): ");
   Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));
   lcd.clear();
   lcd.setCursor(0, 0);


Delete p_ptp.ino

Delete p_ptp.ino


Update links to library used

Update links to library used

--- Arduino/Complete/src/src.ino
+++ Arduino/Complete/src/src.ino
@@ -13,11 +13,11 @@

 // Includes
 #define NO_PORTB_PINCHANGES // PortB used for mySofwareSerial
-#include <mySoftwareSerial.h> // This is a modified version of SoftwareSerial to be able to use interrupt pin as well
-#include <SabertoothSimplified.h> // From http://www.dimensionengineering.com/software/SabertoothSimplifiedArduinoLibrary/html/_sabertooth_simplified_8h_source.html
+#include <mySoftwareSerial.h> // From https://github.com/baptistelabat/robokite/tree/master/Arduino/libraries/mySoftwareSerial  This is a modified version of SoftwareSerial to be able to use interrupt pin as well
+#include <SabertoothSimplified.h> // From http://www.dimensionengineering.com/software/SabertoothArduinoLibraries.zip
 #include <TinyGPS++.h>    // From https://github.com/mikalhart/TinyGPSPlus
 #include <PID_v1.h>       // From https://github.com/br3ttb/Arduino-PID-Library/tree/master/PID_v1
-#include <PinChangeInt.h> // From http://code.google.com/p/arduino-pinchangeint/
+#include <PinChangeInt.h> // From https://github.com/GreyGnome/PinChangeInt

 // Port definition
 #define   POT_PIN  1 // Potentiometer


Update LED.ino

Update LED.ino

--- examples/Widgets/LED/LED.ino
+++ examples/Widgets/LED/LED.ino
@@ -47,7 +47,9 @@
 {
   Serial.begin(9600); // See the connection status in Serial Monitor
   Blynk.begin(auth);
-
+  while (!Blynk.connect()) {
+    // Wait until connected
+  }
   timer.setInterval(1000, blinkLedWidget);
   timer.setInterval(200, fadeLedWidget);
 }


Adding smoothing of data

Adding smoothing of data

--- SensorShirt/SensorShirt.ino
+++ SensorShirt/SensorShirt.ino
@@ -5,45 +5,57 @@
 #include "ArduinoJson.h";
 #include "Data.h";

+//Initialize Pins
 const int backPin = 16;
 const int rShoulderPin = 15;
 const int rUnderarmPin = 14;
 const int lShoulderPin = 18;
 const int lUnderarmPin = 17;
 const int buttonPin = 0;
-/*
-int backValue = -1;
-int lShoulderValue = -1;
-int rShoulderValue = -1;
-int lUnderarmValue = -1;
-int rUnderarmValue = -1;
-*/
+
+//Strings of json to update
 String jsonString;
 String oldJSON;

+//Data for json
 const char* leftArmData;
 const char* rightArmData;
 const char* backData;
 String type = "out";
 const char* name;

+//Buffer for json parsing
 //Could potentially take up too much memory
 DynamicJsonBuffer jsonBuffer;
 bool updated = false;

+//For smoothing of data
+bool prevBackData[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+bool prevLeftData[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+bool prevRightData[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+int counter = 0;
+
+int prevBackCount = 0;
+int prevLeftCount = 0;
+int prevRightCount = 0;
+
+
+//Setup
 void setup() {
   Serial.begin(9600);
   pinMode(buttonPin, INPUT);
 }

+//Run loop continuously
 void loop() {
   String content = "";
   char character;

   while(Serial.available()) {
-      character = Serial.read();
-      content.concat(character);
-      updated = true;
+    character = Serial.read();
+    content.concat(character);
+    updated = true;
   }

   if (updated) {
@@ -54,6 +66,7 @@
   delay(500);
 }

+//Parse json string
 void parseJSON(String content) {
   updated = false;
   JsonObject& in = jsonBuffer.parseObject(const_cast<char*>(content.c_str()));
@@ -71,6 +84,7 @@
   checkPosition();
 }

+//Check if the position from json data is right
 void checkPosition() {
   //Define variables to use to build our JSON
   bool leftArm = false;
@@ -78,6 +92,7 @@
   bool back = false;

   //Evaluate
+  //checks left arm data
   if (strcmp(leftArmData, "fwd45")==0) {
     leftArm = armFwdLeft45();
   } else if (strcmp(leftArmData, "fwd90")==0) {
@@ -98,6 +113,7 @@
     leftArm = armAtSideLeft();
   }

+  //checks right arm data
   if (strcmp(rightArmData, "fwd45")==0) {
     rightArm = armFwdRight45();
   } else if (strcmp(rightArmData, "fwd90")==0) {
@@ -118,6 +134,7 @@
     rightArm = armAtSideRight();
   }

+  //check back data
   if (strcmp(backData, "straight")==0) {
     back = backStraight();
   } else if (strcmp(backData, "fwd")==0) {
@@ -126,6 +143,52 @@
     back = backBentBack();
   }

+  //add new data to the arrays
+  prevBackData[counter] = back;
+  prevLeftData[counter] = leftArm;
+  prevRightData[counter] = rightArm;
+
+  if (counter < 10){
+    counter++;
+  } else {
+    counter = 0;
+  }
+
+  //collect # right
+  for (int i = 0; i < 10; i++){
+    if (prevBackData[i]){
+      prevBackCount++;
+    }
+    if (prevLeftData[i]){
+      prevLeftCount++;
+    }
+    if (prevRightData[i]){
+      prevRightCount++;
+    }
+  }
+
+  //smooth data
+  //if 50% of previous entries are correct
+  if (prevBackCount >= 5){
+    back = true;
+  } else {
+    back = false;
+  }
+
+  if (prevLeftCount >= 5){
+    leftArm = true;
+  } else {
+    leftArm = false;
+  }
+
+  if (prevRightCount >= 5){
+    rightArm = true;
+  } else {
+    rightArm = false;
+  }
+
+
+
   //build JSON string
   jsonString = "{\"type\":\"";
   jsonString += type;


Initialize spin knob state at start, so that the toggle will work.

--- NeoPixelSwitchBox/NeoPixelSwitchBox.ino
+++ NeoPixelSwitchBox/NeoPixelSwitchBox.ino
@@ -5,14 +5,14 @@
   /*
   Tasks

-  updateSpinKnob() should probably have a delta to allow for "close to center" to stop it
-
-  BUG (believe I fixed it): when calling stopBlinking, if the light is off, won't turn on because it won't be queried during updateBlinkingLights.
-  Or, something else may be going on. Seems like it sometimes gets one more update.
-
-  rainbow button
-  random button
-  increment/decrement buttons
+  Test fixes for:
+    updateSpinKnob() should probably have a delta to allow for "close to center" to stop it
+
+    BUG (believe I fixed it): when calling stopBlinking, if the light is off, won't turn on because it won't be queried during updateBlinkingLights.
+    Or, something else may be going on. Seems like it sometimes gets one more update.
+
+  TODO:
+    increment/decrement buttons
   */

   // have to include libraries referenced within libraries in the sketch as well!
@@ -135,13 +135,10 @@
     updateBlinkKnob();
     updateBrightnessKnob();
     updateRGBKnobs();
-
-    // update light knobs
-    // update blink and brightness sliders
-    // update switches and other buttons
-
-    // update the status of all switches/buttons - might be worth putting them in an array to make it an easy loop
+
+    // update the status of buttons
     updateRandomButton();
+    updateRainbowButton();
   }

   boolean potentiometerPercentAtMiddle(float percent) {
@@ -151,6 +148,12 @@
   void updateSpinKnob() {
     spinKnob.update();
     if (spinKnob.valChangedThisUpdate()) {
+      handleSendSpinState();
+    }
+  }
+
+  /* Broke this out into a separate method so it can be transmitted at startup */
+  vod handleSendSpinState() {
       float spinKnobPercent = spinKnob.getPercentVal();
       logger.log("spin knob changed to: ", spinKnobPercent);

@@ -308,7 +311,15 @@
     This way, we won't register changes until the knob is moved by the user
   */
   void initializePotentiometers() {
+    // For the spin knob - if the spin knob isn't centered at start, actually send the state to the ring, and then stop spinning at init
+    // This will allow the spin toggle button to function without having touched the spin knob first
     spinKnob.update();
+    if (!potentiometerPercentAtMiddle(spinKnobPercent)) {
+      handleSendSpinState();
+      ring.toggleSpin();
+    }
+
+
     blinkKnob.update();
     brightnessKnob.update();
     redKnob.update();


serial comms compiles

serial comms compiles

--- teensy_rc_control/teensy_rc_control.ino
+++ teensy_rc_control/teensy_rc_control.ino
@@ -86,11 +86,11 @@

   if (now - lastPrint >= 500) {
     lastPrint = now;
-    if (SerialUSB.availableForWriting() >= 62) {
+    if (SerialUSB.availableForWrite() >= 62) {
       char buf[62];
       sprintf(buf, "%04x %04x %04x %04x %04x %04x %04x %04x %04x %04x",
-        fsValues[0], fsValues[1], fsValues[2], fsValues[3], vsValues[4],
-        fsValues[5], fsValues[6], fsValues[7], fsValues[8], vsValues[9]);
+        fsValues[0], fsValues[1], fsValues[2], fsValues[3], fsValues[4],
+        fsValues[5], fsValues[6], fsValues[7], fsValues[8], fsValues[9]);
       SerialUSB.println(buf);
     }
   }


It gets really hot in here

It gets really hot in here

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

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


syntax error in examples

syntax error in examples

--- examples/OnDemand/OnDemandWebPortal/onDemandWebPortal.ino
+++ examples/OnDemand/OnDemandWebPortal/onDemandWebPortal.ino
@@ -31,7 +31,7 @@

   // is configuration portal requested?
   if(digitalRead(TRIGGER_PIN) == LOW) {
-    delay(50)
+    delay(50);
     if(digitalRead(TRIGGER_PIN) == LOW) {
       if(!portalRunning){
         Serial.println("Button Pressed, Starting Portal");


Sleep mode added

Sleep mode added

At 02:00, device will turn off the lights and backlight, switch to 12V leds.

--- Sketch.ino
+++ Sketch.ino
@@ -1,78 +1,40 @@
-/*
-My IR Remote codes, see this video to find out the codes for your remote: https://youtu.be/ftdJ0R_5NZk
-
-PLAY: FFA25D
-EQ:	  FF22DD
-CH+:  FFE21D
-CH-:  FF629D
-VOL+: FFC23D
-VOL-: FF02FD
-0:    FFE01F
-PREV: FFA857
-NEXT: FF906F
-1:    FF6897
-2:    FF9867
-3:    FFB04F
-4:    FF30CF
-5:    FF18E7
-6:    FF7A85
-7:    FF10EF
-8:    FF38C7
-9:    FF5AA5
-PICK SONG: FF42BD
-CH SET: FF52AD
-*/
-
 #include <IRremote.h>
 #include <Wire.h>
 #include <LiquidCrystal.h>

-LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
+LiquidCrystal lcd(12, 11, 10, 2, 8, 7);
 int RECV_PIN = 14;
 IRrecv irrecv(RECV_PIN);
 decode_results results;

 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // Values to read from DS3231 RTC Module
-byte alarmHour = 5;
+byte alarmHour = 6;
 byte alarmMinute = 0;
 bool alarmOn = true;
 bool alarmActive = false;
 long lastTimeReading = 0;

-const int backlightLCD = 2;
-const int btnAlarmHour = 3;
-const int btnAlarmMinute = 4;
-const int btnAlarmToggle = 5;
-const int ledMosfet = 6;
+const int backlightLCD = 9;
+
+const int LEDStrip12V = 6;
+const int LEDStrip6V = 5;
+
+int activeLED = LEDStrip12V;

 long alarmTurnedOnAt = 0;
-long alarmDuration = 10800000; //3 hours.
+long alarmDuration = 14400000; //4 hours.
 long alarmStepTime = 0;

-long pushedButtonAt = 0;
-long backlightDuration = 10000;
-bool backlightOnForButton = false;
-
 int brightness = 0;
+int softLightBrightness = 0;
 int brightnessStep = 51;
 int smallBrightnessStep = 10;
 bool lightOn = false;

-
-// Variables for debouncing the buttons
-int stateBtnAlarmHour = 0;
-int stateBtnAlarmMinute = 0;
-int stateBtnAlarmToggle = 0;
-int lastStateBtnAlarmHour = 0;
-int lastStateBtnAlarmMinute = 0;
-int lastStateBtnAlarmToggle = 0;
-int readingBtnAlarmHour = 0;
-int readingBtnAlarmMinute = 0;
-int readingBtnAlarmToggle = 0;
-long lastDebounceTimeBtnAlarmHour = 0;
-long lastDebounceTimeBtnAlarmMinute = 0;
-long lastDebounceTimeBtnAlarmToggle = 0;
-const long debounceDelay = 50;
+int backlightBrightnessForNight = 20;
+int backlightBrightnessForDay = 255;
+bool isNight = false;
+bool backlightManuallyTurnedOff = false;

 #define DS3231_I2C_ADDRESS 0x68
 // Convert normal decimal numbers to binary coded decimal
@@ -102,12 +64,9 @@
 {
 	Wire.begin();
 	irrecv.enableIRIn();
-	Serial.begin(9600);
 	pinMode(backlightLCD, OUTPUT);
-	pinMode(ledMosfet, OUTPUT);
-	pinMode(btnAlarmHour, INPUT);
-	pinMode(btnAlarmMinute, INPUT);
-	pinMode(btnAlarmToggle, INPUT);
+	pinMode(LEDStrip12V, OUTPUT);
+	pinMode(LEDStrip6V, OUTPUT);

 	lcd.createChar(0, sunCharacter);
 	lcd.begin(16, 2);
@@ -115,34 +74,39 @@
 	   DS3231 seconds, minutes, hours, day(1 for sunday, 2 for monday...), date, month, year
 	   Set the time by uncommenting the following line after editing the values and load the sketch on your arduino. Right after that, comment out the line and load the sketch again. */

-	// setDS3231time(00,59,23,1,31,12,16);
+	   // setDS3231time(00,59,23,1,31,12,16);
 }

 void loop()
 {
-	ListenForButtonPress();
-
 	if (millis() - lastTimeReading > 1000) //Once every second
 	{
 		ReadTime();
-		DisplayTimeAndDateOnSerialMonitor();
+		lastTimeReading = millis();
+		CheckAlarmEveryMinute();
+		if (HourStart())
+		{
+			CheckDayOrNight();
+			DisableBacklightOverrideAt(6);
+			AdjustSettingsForSleepTimeAt(2);
+		}
 		RefreshLCD();
-		if (alarmOn)
-		{
-			if (second == 0)
-			{
-				CheckAlarm();
-			}
-		}
-		lastTimeReading = millis();
+	}
+
+	if (!backlightManuallyTurnedOff)
+	{
+		LCDBacklight();
+	}
+	else
+	{
+		analogWrite(backlightLCD, 0);
 	}

 	if (alarmActive)
 	{
 		if (millis() - alarmTurnedOnAt < alarmDuration) //For the duration of alarm
 		{
-			digitalWrite(backlightLCD, HIGH);
-			if (millis() - alarmStepTime > 7000) //Once in seven seconds, will  reach full brightness at 30 minutes
+			if (millis() - alarmStepTime > 7000) //Once in 7 seconds, will  reach full brightness at 30 minutes
 			{
 				ChangeBrightness(1);
 				alarmStepTime = millis();
@@ -153,184 +117,124 @@
 			brightness = 0;
 			SetBrightness(brightness);
 			alarmActive = false;
-			digitalWrite(backlightLCD, LOW);
-		}
-	}
-
-	if (backlightOnForButton)
-	{
-		if (millis() - pushedButtonAt < backlightDuration) //For the backlight duration
-		{
-			digitalWrite(backlightLCD, HIGH);
-		}
-		else //Once at the end of backlight duration
-		{
-			digitalWrite(backlightLCD, LOW);
-			backlightOnForButton = false;
 		}
 	}

 	if (irrecv.decode(&results)) {		//If a button is pressed on the IR remote
-		if (results.value == 0xFFA25D)
+		if (results.value == 0xFFA25D) //PLAY button
 		{
 			LightOn();
 			PushedAnyButton();
 		}
-		if (results.value == 0xFF22DD)
+		if (results.value == 0xFF22DD) //EQ button
 		{
 			LightOff();
 			PushedAnyButton();
 		}
-		if (results.value == 0xFFE21D)
+		if (results.value == 0xFFE21D) //CH+ button
 		{
 			ChangeBrightness(brightnessStep);
 			PushedAnyButton();
 		}
-		if (results.value == 0xFF629D)
+		if (results.value == 0xFF629D) //CH- button
 		{
 			ChangeBrightness(-brightnessStep);
 			PushedAnyButton();
 		}
-		if (results.value == 0xFFC23D)
+		if (results.value == 0xFFC23D) //VOL+ button
 		{
 			ChangeBrightness(smallBrightnessStep);
 			PushedAnyButton();
 		}
-		if (results.value == 0xFF02FD)
+		if (results.value == 0xFF02FD) // VOL- button
 		{
 			ChangeBrightness(-smallBrightnessStep);
 			PushedAnyButton();
 		}
-		if (results.value == 0xFF52AD)
+		if (results.value == 0xFF52AD) //CH SET button
 		{
 			ChangeBrightness(-1);
 			PushedAnyButton();
 		}
-		if (results.value == 0xFF5AA5)
+		if (results.value == 0xFF5AA5) //9 button
 		{
 			ChangeBrightness(1);
 			PushedAnyButton();
 		}
-		if (results.value == 0xFF6897)
-		{
-			if (backlightOnForButton)
-			{
-				IncreaseAlarmHour();
-				PushedAnyButton();
-			}
-			else
-			{
-				PushedAnyButton();
-			}
-		}
-		if (results.value == 0xFF9867)
-		{
-			if (backlightOnForButton)
-			{
-				IncreaseAlarmMinute();
-				PushedAnyButton();
-			}
-			else
-			{
-				PushedAnyButton();
-			}
-		}
-		if (results.value == 0xFFB04F)
-		{
-			if (backlightOnForButton)
-			{
-				ToggleAlarm();
-				PushedAnyButton();
-			}
-			else
-			{
-				PushedAnyButton();
-			}
-		}
+		if (results.value == 0xFFA857) //PREV button
+		{
+			IncreaseAlarmHour();
+			PushedAnyButton();
+		}
+		if (results.value == 0xFF906F) //NEXT button
+		{
+			IncreaseAlarmMinute();
+			PushedAnyButton();
+		}
+		if (results.value == 0xFFE01F) //0 button
+		{
+			ToggleAlarm();
+			PushedAnyButton();
+		}
+
+		if (results.value == 0xFF42BD) //PICK SONG button
+		{
+			ToggleLedMosfet();
+			PushedAnyButton();
+		}
+
+		if (results.value == 0xFF38C7) //8 button
+		{
+			backlightManuallyTurnedOff = !backlightManuallyTurnedOff;
+			PushedAnyButton();
+		}
+
 		irrecv.resume();
 	}
-	//delay(100);
-}
-
-void ListenForButtonPress() //https://www.arduino.cc/en/Tutorial/Debounce
-{
-	readingBtnAlarmHour = digitalRead(btnAlarmHour);
-	readingBtnAlarmMinute = digitalRead(btnAlarmMinute);
-	readingBtnAlarmToggle = digitalRead(btnAlarmToggle);
-
-	if (readingBtnAlarmHour != lastStateBtnAlarmHour)
-	{
-		lastDebounceTimeBtnAlarmHour = millis();
-	}
-	if (readingBtnAlarmMinute != lastStateBtnAlarmMinute)
-	{
-		lastDebounceTimeBtnAlarmMinute = millis();
-	}
-	if (readingBtnAlarmToggle != lastStateBtnAlarmToggle)
-	{
-		lastDebounceTimeBtnAlarmToggle = millis();
-	}
-
-	if (millis() - lastDebounceTimeBtnAlarmHour > debounceDelay)
-	{
-		if (readingBtnAlarmHour != stateBtnAlarmHour)
-		{
-			stateBtnAlarmHour = readingBtnAlarmHour;
-			if (stateBtnAlarmHour == LOW)
-			{
-				if (backlightOnForButton)
-				{
-					IncreaseAlarmHour();
-					PushedAnyButton();
-				}
-				else
-				{
-					PushedAnyButton();
-				}
-			}
-		}
-	}
-	if (millis() - lastDebounceTimeBtnAlarmMinute > debounceDelay)
-	{
-		if (readingBtnAlarmMinute != stateBtnAlarmMinute)
-		{
-			stateBtnAlarmMinute = readingBtnAlarmMinute;
-			if (stateBtnAlarmMinute == LOW)
-			{
-				if (backlightOnForButton)
-				{
-					IncreaseAlarmMinute();
-					PushedAnyButton();
-				}
-				else
-				{
-					PushedAnyButton();
-				}
-			}
-		}
-	}
-	if (millis() - lastDebounceTimeBtnAlarmToggle > debounceDelay)
-	{
-		if (readingBtnAlarmToggle != stateBtnAlarmToggle)
-		{
-			stateBtnAlarmToggle = readingBtnAlarmToggle;
-			if (stateBtnAlarmToggle == LOW)
-			{
-				if (backlightOnForButton)
-				{
-					ToggleAlarm();
-					PushedAnyButton();
-				}
-				else
-				{
-					PushedAnyButton();
-				}
-			}
-		}
-	}
-	lastStateBtnAlarmHour = readingBtnAlarmHour;
-	lastStateBtnAlarmMinute = readingBtnAlarmMinute;
-	lastStateBtnAlarmToggle = readingBtnAlarmToggle;
+	delay(100); //Documentation recommended this, but it may not be necessary.
+}
+
+void CheckAlarmEveryMinute() {
+	if (alarmOn)
+	{
+		if (second == 0)
+		{
+			CheckAlarm();
+		}
+	}
+}
+
+void DisableBacklightOverrideAt(int hourToDisableBacklightOverride) {
+	if (hour == hourToDisableBacklightOverride)
+	{
+		backlightManuallyTurnedOff = false;
+	}
+}
+
+void LCDBacklight() {
+	if (isNight)
+	{
+		analogWrite(backlightLCD, backlightBrightnessForNight);
+	}
+	else
+	{
+		analogWrite(backlightLCD, backlightBrightnessForDay);
+	}
+}
+
+void ToggleLedMosfet() {
+	if (activeLED == LEDStrip12V)
+	{
+		activeLED = LEDStrip6V;
+		analogWrite(LEDStrip12V, 0);
+		brightness = 0;
+	}
+	else
+	{
+		activeLED = LEDStrip12V;
+		analogWrite(LEDStrip6V, 0);
+		brightness = 0;
+	}
 }

 void ReadTime()
@@ -339,67 +243,26 @@
 	readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
 }

-
-void DisplayTimeAndDateOnSerialMonitor()
-{
-	Serial.print(hour, DEC);
-	Serial.print(":");
-	if (minute < 10)
-	{
-		Serial.print("0");
-	}
-	Serial.print(minute, DEC);
-	Serial.print(":");
-	if (second < 10)
-	{
-		Serial.print("0");
-	}
-	Serial.print(second, DEC);
-	Serial.print(" ");
-	Serial.print(dayOfMonth, DEC);
-	Serial.print("/");
-	Serial.print(month, DEC);
-	Serial.print("/");
-	Serial.print(year, DEC);
-	Serial.print(" Day of week: ");
-	switch (dayOfWeek) {
-	case 1:
-		Serial.println("Sunday");
-		break;
-	case 2:
-		Serial.println("Monday");
-		break;
-	case 3:
-		Serial.println("Tuesday");
-		break;
-	case 4:
-		Serial.println("Wednesday");
-		break;
-	case 5:
-		Serial.println("Thursday");
-		break;
-	case 6:
-		Serial.println("Friday");
-		break;
-	case 7:
-		Serial.println("Saturday");
-		break;
-	}
-}
-
-
 void RefreshLCD()
 {
 	lcd.clear();
-	PrintOnLCD(hour);
+	PrintTimeValueOnLCD(hour);
 	lcd.print(":");
-	PrintOnLCD(minute);
+	PrintTimeValueOnLCD(minute);
 	lcd.print(":");
-	PrintOnLCD(second);
-	lcd.print("   ");
-	if (alarmActive)
+	PrintTimeValueOnLCD(second);
+	lcd.print("  ");
+	if (backlightManuallyTurnedOff)
 	{
 		lcd.print("!");
+	}
+	else
+	{
+		lcd.print(" ");
+	}
+	if (activeLED == LEDStrip12V)
+	{
+		lcd.write(byte(0));
 	}
 	else
 	{
@@ -409,10 +272,17 @@
 	lcd.print(brightness);

 	lcd.setCursor(0, 1);
-	lcd.print("Alarm:");
-	PrintOnLCD(alarmHour);
+	if (!alarmActive)
+	{
+		lcd.print("Alarm:");
+	}
+	else
+	{
+		lcd.print("ALARM:");
+	}
+	PrintTimeValueOnLCD(alarmHour);
 	lcd.print(":");
-	PrintOnLCD(alarmMinute);
+	PrintTimeValueOnLCD(alarmMinute);
 	if (alarmOn)
 	{
 		lcd.print(" (on)");
@@ -423,7 +293,7 @@
 	}
 }

-void PrintOnLCD(byte value)
+void PrintTimeValueOnLCD(byte value)
 {
 	if (value < 10)
 	{
@@ -448,6 +318,7 @@
 	alarmActive = true;
 	alarmTurnedOnAt = millis();
 	alarmStepTime = millis();
+	backlightManuallyTurnedOff = false;
 }

 void IncreaseAlarmHour()
@@ -480,12 +351,6 @@
 {
 	alarmOn = !alarmOn;
 	RefreshLCD();
-}
-
-void BacklightForButtonPress()
-{
-	backlightOnForButton = true;
-	pushedButtonAt = millis();
 }

 void ChangeBrightness(int step) {
@@ -503,7 +368,7 @@

 void SetBrightness(int brightnessValue)
 {
-	analogWrite(ledMosfet, brightnessValue);
+	analogWrite(activeLED, brightnessValue);
 	if (brightnessValue == 0)
 	{
 		lightOn = false;
@@ -540,12 +405,43 @@

 void PushedAnyButton()
 {
-	BacklightForButtonPress();
 	if (alarmActive)
 	{
 		alarmActive = false;
 		brightness = 0;
 		SetBrightness(brightness);
+	}
+}
+
+void CheckDayOrNight() {
+	if ((hour > 20) || (hour >= 0 && hour < 6))
+	{
+		isNight = true;
+	}
+	else
+	{
+		isNight = false;
+	}
+}
+
+bool HourStart() {
+	if (second == 0)
+	{
+		if (minute == 0)
+		{
+			return true;
+		}
+	}
+	return false;
+}
+
+void AdjustSettingsForSleepTimeAt(int hourToSwitchToSleepMode) {
+	if (hour == hourToSwitchToSleepMode)
+	{
+		backlightManuallyTurnedOff = true;
+		brightness = 0;
+		SetBrightness(brightness);
+		activeLED = LEDStrip12V;
 	}
 }


Add stepper outputs to arduino code.

Add stepper outputs to arduino code.

--- shipStation/lbcc_ship_stepper/lbcc_ship_stepper.ino
+++ shipStation/lbcc_ship_stepper/lbcc_ship_stepper.ino
@@ -1,11 +1,12 @@
+#include <Adafruit_Sensor.h>
+#include <Adafruit_BNO055.h>
+#include <AccelStepper.h>
+#include <math.h>
 #include <SoftwareSerial.h>
-#include <Wire.h>
 #include <SPI.h>
 #include <TinyGPS++.h>
-#include <Adafruit_Sensor.h>
-#include <Adafruit_BNO055.h>
 #include <utility/imumaths.h>
-#include <math.h>
+#include <Wire.h>

 #define DEBUGGING true
 #define GPSBAUD 9600
@@ -16,6 +17,7 @@
 sensors_event_t event;           //Create a new local event instance
 uint8_t sys, gyro, accel, mag;   //Create local variables gyro, accel, mag
 double azimuth_deg, elevation_deg, distance_meters, delta_altitude;
+double azimuth_steps, elevation_steps;

 // Initializes an instance of the BNO055 called bno with an I2C address of 55
 Adafruit_BNO055 bno = Adafruit_BNO055(55);
@@ -26,6 +28,9 @@
 TinyGPSPlus trackerGPS;
 TinyGPSPlus payloadGPS;
 TinyGPSCustom magneticVariation(trackerGPS, "GPRMC", 10);
+
+AccelStepper xAxis(1,12,11);
+AccelStepper yAxis(1,10,9);

 void setup()
@@ -47,6 +52,12 @@
   }
 //  bno.setExtCrystalUse(true);                     //Use the external clock in the IMU
 //  bno.setMode(bno.OPERATION_MODE_NDOF);
+
+  // Set stepper motor acceleration and top speeds
+  xAxis.setMaxSpeed(10000);
+  xAxis.setAcceleration(5000);
+  yAxis.setMaxSpeed(10000);
+  yAxis.setAcceleration(5000);
 }

@@ -68,7 +79,12 @@
   if(payloadGPS.location.isUpdated() || trackerGPS.location.isUpdated()){
     // Update target solution every time new GPS info is available
     get_tracking_solution();
-  }
+    // Update solution based on IMU
+    updateMotors(azimuth_deg, elevation_deg);
+  }
+
+  xAxis.run();
+  yAxis.run();

   // Display GPS info about every 2 seconds
   if(millis() - gpsTimer > 2000){
@@ -91,6 +107,21 @@
   }
 }

+void updateMotors(double aziDegs, double eleDegs){
+  azimuth_steps = radsToSteps(aziDegs);
+  elevation_steps = radsToSteps(eleDegs);
+  xAxis.moveTo(azimuth_steps);
+  yAxis.moveTo(elevation_steps);
+}
+
+
+float radsToSteps(float rad)
+{
+  // Takes radians, returns steps (assuming 16*3060 = 48960 total steps)
+  // rad/(2*pi) = steps / (microsteps * motor steps)
+  return rad * 24480 / M_PI;
+}
+

 void get_tracking_solution(){
   // Update the tracking solution variables when new gps information is available


Update Keypad.ino

Update Keypad.ino

--- ComboKeypad/Keypad.ino
+++ ComboKeypad/Keypad.ino
@@ -6,13 +6,17 @@

 const int combination[] = {3, 1, 2, 4};  //what the combination is, to add just add a "," and a number

+const bool useFiveVoltpin = false;   //Change this if you want to use the
+///////////////////////////////////////5Volt PIN instead of PIN 2(IN MY CASE)
+
+//USER VARIABLES END
+
 const int numOfCombos = sizeof(combination) / sizeof(combination[0]);   //How many combinations

 const int numOfButtons = sizeof(buttons) / sizeof(buttons[0]);   //How many buttons you have

-const bool useFiveVoltpin = false;   //Change this if you want to use the
-///////////////////////////////////////5Volt PIN instead of PIN 2(IN MY CASE)
-//USER VARIABLES END
+
+
 ///
 bool doonce = false;   //Button stopper
 int count = 0;   //How many buttens that have been pressed


mounting and using constant port for random seed

--- dorm-leds.ino
+++ dorm-leds.ino
@@ -70,7 +70,7 @@

 	// random seed
 	Serial.println(F("Generating random seed..."));
-	randomSeed(analogRead(A0));
+	randomSeed(analogRead(RAND_SEED_ANALOG_NOISE_PORT));

 	// initialize pins
 	Serial.println(F("Setting pin modes..."));
@@ -83,6 +83,11 @@
 	// initialize LCD display
 	Serial.println(F("Initializing LCD display..."));
 	init_lcd();
+
+	// mount other devices
+	mem_available = freeMemory();
+	Serial.println(F("Mounting Additional Devices..."));
+	mount_devices();

 	// manual queue
 	mem_available = freeMemory();


Fixed some misspells and improved grammar.

--- ArduCAM/examples/Shield_V2/ArduCAM_Capture2SD/ArduCAM_Capture2SD.ino
+++ ArduCAM/examples/Shield_V2/ArduCAM_Capture2SD/ArduCAM_Capture2SD.ino
@@ -51,7 +51,7 @@
   myCAM.clear_fifo_flag();
   //Start capture
   myCAM.start_capture();
-  Serial.println("star Capture");
+  Serial.println("Start Capture");
  while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK));
  Serial.println("Capture Done!");

@@ -75,7 +75,7 @@
  //Open the new file
  outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC);
  if(! outFile){
-  Serial.println("open file faild");
+  Serial.println("File open failed");
   return;
  }
  i = 0;
@@ -95,7 +95,7 @@
         outFile.write(buf, i);
       //Close the file
         outFile.close();
-        Serial.println("CAM Save OK!");
+        Serial.println("Image save OK!");
         is_header = false;
         i = 0;
     }


Prettier formatting o f the Core version number.

Signed-off-by: Sacha Telgenhof <2491008b05e873c0de4356ab23a0a79a07dc9d9d@gmail.com>

--- src/light.ino
+++ src/light.ino
@@ -294,7 +294,11 @@
   object["device_ip"] = (WiFi.getMode() == WIFI_AP) ? WiFi.softAPIP().toString()
                                                     : WiFi.localIP().toString();
   object["mac"] = WiFi.macAddress();
-  object["core"] = ESP.getCoreVersion();
+
+  String version = ESP.getCoreVersion();
+  version.replace("_", ".");
+
+  object["core"] = version;
 }

 /**


adding bug program, automatic switching between bug and tetris

--- rgbdisplay.ino
+++ rgbdisplay.ino
@@ -2,6 +2,7 @@
 #include "SPI.h"
 #include "display.h"
 #include "tetris.h"
+#include "bug.h"
 #include "utils.h"

@@ -12,8 +13,12 @@
 const int powerPin = 11;
 const int power = 20;

+#define BUG_SPEED (100ul * 5)
+#define TETRIS_SPEED (1000ul * 60 * 10)
+
 DisplayWrapper display = DisplayWrapper(nLEDs, dataPin, clockPin, powerPin, power);
-Tetris tetris = Tetris();
+Tetris tetris;
+environment_t environment;

 void setup() {
   Serial.begin(9600);
@@ -22,7 +27,22 @@
   display.show();
 }

+long previousMillis = 0;
+const long interval = 1000 * 60 * 30;
+
 void loop() {
-  tetris.drawRandomTetrisGrid();
-  delay(1000ul * 60 * 10);
+  while (millis() - previousMillis < interval) {
+    tetris.drawRandomTetrisGrid();
+    delay(TETRIS_SPEED);
+  }
+
+  previousMillis = millis();
+
+  while (millis() - previousMillis < interval) {
+    environment.advance();
+    environment.show();
+    delay(BUG_SPEED);
+  }
+
+  previousMillis = millis();
 }


Revert "Update RetroWatchArduino.ino"

Revert "Update RetroWatchArduino.ino"

This reverts commit 5f84c0a3d69ee43d002e9a6d68a405c501d68650.

--- RetroWatch_Arduino/RetroWatchArduino/RetroWatchArduino.ino
+++ RetroWatch_Arduino/RetroWatchArduino/RetroWatchArduino.ino
@@ -30,7 +30,7 @@
 #include <Wire.h>
 #include <SoftwareSerial.h>
 #include <Adafruit_GFX.h>
-#include <Adafruit_SSD1331.h>
+#include <Adafruit_SSD1306.h>
 #include <math.h>
 #include "bitmap.h"
 #include <SPI.h>


Edit SD Server example to use the new Write(Stream) method

--- libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino
+++ libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino
@@ -111,23 +111,10 @@
     dataType = 0;
     path = 0;

-    uint8_t obuf[WWW_BUF_SIZE];
+    if(client.write(dataFile) != dataFile.size()){
+      DBG_OUTPUT_PORT.println("Sent less data than expected!");
+    }

-    while (dataFile.available() > WWW_BUF_SIZE){
-      dataFile.read(obuf, WWW_BUF_SIZE);
-      if(client.write(obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE){
-        DBG_OUTPUT_PORT.println("Sent less data than expected!");
-        dataFile.close();
-        return true;
-      }
-    }
-    uint16_t leftLen = dataFile.available();
-    dataFile.read(obuf, leftLen);
-    if(client.write(obuf, leftLen) != leftLen){
-      DBG_OUTPUT_PORT.println("Sent less data than expected!");
-      dataFile.close();
-      return true;
-    }
     dataFile.close();
     client.stop();
     return true;


Add Z range reporting in calibration sketch

--- examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino
+++ examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino
@@ -852,7 +852,8 @@
     }
     if (bTouchUp) {
       CalcDatapoint(m_eCalibPt);
-      GSLC_DEBUG_PRINT("%s: X=%d Y=%d Cnt=%u\n", sCalibStage.acStr, m_nPointFinalX, m_nPointFinalY, m_nPointBufCnt);
+      GSLC_DEBUG_PRINT("%s: X=%d Y=%d Cnt=%u, Z=(%d..%d)\n", sCalibStage.acStr, m_nPointFinalX, m_nPointFinalY, m_nPointBufCnt,
+        m_nTouchZMin, m_nTouchZMax);
       m_eState = sCalibStage.eStateNxt;
     }
     break;


Removed errorCount from NewController firmware

Message timeouts triggering errors requires the connecting software to send keepalives. To avoid this requirement, the errorCount has been removed. Whenever a bad message has been received, all outputs are turned off.

Also added a number of small comments explaining the purpose of various functions and sections of code.

--- arduino/NewController/NewController.ino
+++ arduino/NewController/NewController.ino
@@ -6,13 +6,13 @@

 const byte
   characterTimeout = 10,
-  maxErrors = 10,
+  outputs = 5,
   pcaBaseAddress = 0x40,
   pcaFirstLedOn  = 0x06,
   pcaFirstLedOff = 0x08,
   pcaMode1 = 0x00,
   pcaMode2 = 0x01;
-const int messageTimeout = 1000;
+const int commandTimeout = 1000;
 PROGMEM prog_uint16_t gammaCorrected[256] = {
     // 8-bit intensity levels mapped to 12-bit PWM values corrected for the
     // non-linear sensitivity of the human eye. Gamma value = 2.2
@@ -44,47 +44,47 @@
 void setup(void) {
   Wire.begin();
   setupDriver();
-  for (byte output = 16; output-- > 0;)
-    setDriverPinLevel(output, 0);
+  for (byte pin = 16; pin-- > 0;)
+    setDriverPinLevel(pin, 0);
   Serial.begin(57600);
+  // Tell the connecting side that this is a Lightbox.
   Serial.println("[Lightbox]");
 }

 void loop(void) {
-  static byte errorCount = 0;
   byte receivedByte;
-  if (readByte(receivedByte, messageTimeout)) {
-    errorCount = 0;
+  if (readByte(receivedByte, commandTimeout)) {
     switch (receivedByte) {
       case '\x01':
-        messageAllOutputs();
+        commandAllOutputs();
         break;
       case '\x02':
-        messageSingleOutput();
+        commandSingleOutput();
         break;
+      default:
+        // Bad command TYPE, turn off all inputs
+        for (byte output = outputs; output-- > 0;)
+          setOutputColor(output, 0, 0, 0);
     }
-  } else if (++errorCount > maxErrors) {
-    // No transmission for 10 seconds, everything dark.
-    for (byte output = 16; output-- > 0;)
-      setDriverPinLevel(output, 0);
-    errorCount = 0;
   }
 }

 void messageAllOutputs(void) {
   byte receivedByte, red, green, blue;
+  // Verify payload length, if correct, read payload and set colors.
   if (readByte(receivedByte, characterTimeout) && receivedByte == '\x03')
     if (readByte(red, characterTimeout) &&
         readByte(green, characterTimeout) &&
         readByte(blue, characterTimeout))
-      for (byte output = 5; output-- > 0;)
+      for (byte output = outputs; output-- > 0;)
         setOutputColor(output, red, green, blue);
 }

 void messageSingleOutput(void) {
   byte receivedByte, red, green, blue, output;
+  // Verify payload length, if correct, read payload and set output color.
   if (readByte(receivedByte, characterTimeout) && receivedByte == '\x04')
-    if (readByte(output, characterTimeout) && output < 5 &&
+    if (readByte(output, characterTimeout) && output < outputs &&
         readByte(red, characterTimeout) &&
         readByte(green, characterTimeout) &&
         readByte(blue, characterTimeout))
@@ -92,6 +92,7 @@
 }

 void setOutputColor(byte output, byte red, byte green, byte blue) {
+  // Set the given output to the configured red, green and blue levels.
   output *= 3;
   setDriverPinLevel(output++, red);
   setDriverPinLevel(output++, green);
@@ -99,6 +100,7 @@
 }

 bool readByte(byte &receivedByte, int timeout) {
+  // Read a single byte from Serial, with a provided timeout
   long starttime = millis();
   while (!Serial.available())
     if ((millis() - starttime) > timeout)
@@ -114,19 +116,21 @@
 }

 void writeRegister(byte regAddress, byte regData) {
+  // Writes register values for the PCA9685 driver
   Wire.beginTransmission(pcaBaseAddress);
   Wire.write(regAddress);
   Wire.write(regData);
   Wire.endTransmission();
 }

-void setDriverPinLevel(byte output, byte level) {
+void setDriverPinLevel(byte pin, byte level) {
+  // Sets the 12-bit PWM pin value based on the 8-bit level input.
   int intensity = pgm_read_word_near(gammaCorrected + level);
   Wire.beginTransmission(pcaBaseAddress);
   // Only write OFF registers, skip ON registers.
   // This means all PWM load starts at zero, which is not ideal
   // but will have to do for the moment.
-  Wire.write(pcaFirstLedOff + 4 * output);
+  Wire.write(pcaFirstLedOff + 4 * pin);
   Wire.write(lowByte(intensity));  // OFF_LOW
   Wire.write(highByte(intensity)); // OFF_HIGH
   Wire.endTransmission();


Notion of run-once tests...

Notion of run-once tests...

--- test_SECFRAME/test_SECFRAME.ino
+++ test_SECFRAME/test_SECFRAME.ino
@@ -810,6 +810,19 @@
   AssertIsTrue(!OTRadioLink::increment3BytePersistentTXRestartCounter(loadBuf));
   }

+// Test handling of persistent/reboot/restart part of primary message counter.
+// Tests to only be run once because they may cause device wear.
+static void testPermMsgCountRunOnce()
+  {
+  Serial.println("PermMsgCountRunOnce");
+  uint8_t loadBuf[OTV0P2BASE::VOP2BASE_EE_LEN_PERSISTENT_MSG_RESTART_CTR];
+  uint8_t buf[OTRadioLink::primaryPeristentTXMessageRestartCounterBytes];
+//  // Initial test that blank EEPROM after processing yields all zeros.
+//  OTRadioLink::loadRaw3BytePersistentTXRestartCounterFromEEPROM(buf);
+//  for(int i = 0; i < sizeof(buf); ++i) { AssertIsEqual(0, buf[i]); }
+  }
+
+

 // To be called from loop() instead of main code when running unit tests.
 // Tests generally flag an error and stop the test cycle with a call to panic() or error().
@@ -846,6 +859,18 @@
   testBeaconEncoding();

+  // Run-once tests.
+  // May cause wear on (eg) EEPROM, so only run once,
+  // and only after all other tests have passed.
+  static bool runOnce;
+  if(!runOnce)
+    {
+    runOnce = true;
+    Serial.println(F("Run-once tests... "));
+    testPermMsgCountRunOnce();
+    }
+
+
   // Announce successful loop completion and count.
   ++loopCount;
   Serial.println();