Fixed issue where timout didn't occur on initialization.

--- tests/drive-test/Chassis_Control/Chassis_Control.ino
+++ tests/drive-test/Chassis_Control/Chassis_Control.ino
@@ -3,7 +3,8 @@
 #include <map>
 #include <string>

-#include "C:\Users\Taylor\Documents\Arduino\libraries\ChassisData.h" // Insert own filepath here
+// Insert own filepath here
+#include "C:\Users\Taylor\Documents\Arduino\libraries\ChassisData.h"

 #ifndef I2C_ADDRESS
 #define I2C_ADDRESS  1
@@ -23,6 +24,10 @@
 Servo leftMotor, rightMotor;

 ChassisData data;
+boolean dataValid;
+
+void I2CReceive(int count);
+boolean readBytes(void* dest, size_t len);

 void setup() {
   // Attach the motors and set their starting speed to neutral/zero speed
@@ -36,10 +41,15 @@
   Wire.onReceive(I2CReceive);
   Serial.begin(115200);
   timeLastPacket = 0;
+  dataValid = false;
 }

 void loop() {
-  if(millis() - timeLastPacket < TIMEOUT) {
+  static boolean timedOut = false;
+
+  if(millis() - timeLastPacket < TIMEOUT && dataValid) {
+    timedOut = false;
+
     // Map values from 5-bit char to int from full reverse to full forwards
     int leftSpeed = map(data.left_motor, 0, 32, MIN_FREQUENCY, MAX_FREQUENCY);
     int rightSpeed = map(data.right_motor, 0, 32, MIN_FREQUENCY, MAX_FREQUENCY);
@@ -55,7 +65,10 @@
     // Timeout handling (stop motors)
     leftMotor.writeMicroseconds(1500);
     rightMotor.writeMicroseconds(1500);
-    Serial.println("TIMEOUT REACHED");
+    if(!timedOut) {
+      timedOut = true;
+      Serial.println("TIMEOUT REACHED");
+    }
   }
 }

@@ -67,8 +80,9 @@
   if(count % NECESSARY_PACKET_SIZE == 0) {
     timeLastPacket = millis();

-    for(int i = 0; i < count / NECESSARY_PACKET_SIZE && Wire.available() >= 3; i++) {
+    for(int i = 0; i < count / NECESSARY_PACKET_SIZE && Wire.available() >= NECESSARY_PACKET_SIZE; i++) {
       readBytes(&data, NECESSARY_PACKET_SIZE);
+      dataValid = true;
     }
   }
 }


modified manipulator

modified manipulator

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Test/manager/manager.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Test/manager/manager.ino
@@ -27,15 +27,15 @@
   Serial.begin(57600);
   while (!Serial)
     ;
-
+
   Manipulator manipulator;
   manipulator.addWorld(WORLD, COMP1);
-  manipulator.addComponent(COMP1, WORLD, COMP2, makeEigenVector3(-0.100, 0.0, 0.0), IDENTITY_MATRIX, 1, Z_AXIS, 0.5, makeEigenMatrix3(1, 1, 1, 1, 1, 1, 3, 1, 1));
-  manipulator.addComponent(COMP2, COMP1, COMP3, makeEigenVector3(0.0, 0.0, 0.050), IDENTITY_MATRIX, 2, Y_AXIS, 1.5);
+  manipulator.addComponent(COMP1, WORLD, COMP2, MATH::makeVector3(-0.100, 0.0, 0.0), IDENTITY_MATRIX, 1, Z_AXIS, 0.5, MATH::makeMatrix3(1, 1, 1, 1, 1, 1, 3, 1, 1));
+  manipulator.addComponent(COMP2, COMP1, COMP3, MATH::makeVector3(0.0, 0.0, 0.050), IDENTITY_MATRIX, 2, Y_AXIS, 1.5);
   manipulator.addComponentChild(COMP2, COMP4);
-  manipulator.addComponent(COMP3, COMP2, COMP4, makeEigenVector3(0.0, 0.050, 0.0), IDENTITY_MATRIX, NONE);
-  manipulator.addComponent(COMP4, COMP2, TOOL, makeEigenVector3(0.0, 0.0, 0.050), IDENTITY_MATRIX, 3, Y_AXIS, 2.0);
-  manipulator.addTool(TOOL, COMP4, makeEigenVector3(0.0, 0.0, 0.025), IDENTITY_MATRIX, 4, 0.1);
+  manipulator.addComponent(COMP3, COMP2, TOOL, MATH::makeVector3(0.0, 0.050, 0.0), IDENTITY_MATRIX, 3, Y_AXIS, 2.0);
+  manipulator.addComponent(COMP4, COMP2, TOOL, MATH::makeVector3(0.0, 0.0, 0.050), IDENTITY_MATRIX, NONE);
+  manipulator.addTool(TOOL, COMP3, MATH::makeVector3(0.0, 0.0, 0.025), IDENTITY_MATRIX, 4, 0.1);

   manipulator.checkManipulatorSetting();
 }


speed increase to ~377khz

speed increase to ~377khz

--- mega6502.ino
+++ mega6502.ino
@@ -54,7 +54,9 @@

 #define ADDR ((addrh << 8) | addrl)

-uint8_t memRead(const uint8_t addrh, const uint8_t addrl) {
+static uint8_t memRead() {
+  const uint8_t addrh = PINC;
+  const uint8_t addrl = PINA;
   const uint16_t addr = ADDR;
   uint8_t val;
   switch (addr >> 12) {
@@ -68,7 +70,7 @@
       return val;
     case 0xd:
       // fake 6821
-      switch (addrl & 0xff) {
+      switch (addrl) {
         case 0x10:
           val = 0x80 | (uint8_t)Serial.read();
           break;
@@ -80,7 +82,7 @@
           }
           break;
         default:
-          val = pia[addrl & 0xff];
+          val = pia[addrl];
       }
       if (LCD) printAddr(addr, 8, 0);
       if (LCD) printByte(val, 14, 0);
@@ -94,8 +96,11 @@
   }
 }

-void memWrite(const uint8_t addrh, const uint8_t addrl, const uint8_t val) {
+static void memWrite() {
+  const uint8_t addrh = PINC;
+  const uint8_t addrl = PINA;
   const uint16_t addr = ADDR;
+  const uint8_t val = PINL;
   switch (addr >> 12) {
     default:
       // nothing in the address space ignore the write;
@@ -108,7 +113,7 @@
     case 0xd:
       if (LCD) printAddr(addr, 8, 1);
       if (LCD) printByte(val, 14, 1);
-      switch (addr & 0xff) {
+      switch (addrl) {
         default:
           pia[addr & 0xff] = val;
           break;
@@ -162,18 +167,17 @@
     cli();
     cbi(PORTB, 0);
     __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t"); // 4 * 62.5ns delay @ 16mhz
-    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");
     sbi(PORTB, 0);
     sei();
     if (PINB & _BV(PB2)) {
       // read cycle
       DDRL = 0xff;
-      PORTL = memRead(PINC, PINA);
+      PORTL = memRead();
     } else {
       // write cycle
       DDRL = 0x00;
       PORTL = 0;
-      memWrite(PINC, PINA, PINL);
+      memWrite();
     }
   }
 }


Move bit flip to PORT writes

Move bit flip to PORT writes

--- leonardo/leo595/leo595.ino
+++ leonardo/leo595/leo595.ino
@@ -17,93 +17,93 @@
 extern "C" {
 #endif

-#define MYDELAY 10
+#define MYDELAY 500

 void clockout(uint8_t);

-  /* pin11 goes to 595 pin 11 */
+/* pin11 goes to 595 pin 11 */
 #define SHIFTCLOCK 11
-  /* pin 8 goes to 595 pin 14 */
-#define SERDATAIN  8
-  /* to control when data goes out */
+/* pin 8 goes to 595 pin 14 */
+#define SERDATAIN  8
+/* to control when data goes out */
 #define STROBEPIN 12

 void setup(void) {
-  pinMode(SERDATAIN,OUTPUT);
-  pinMode(SHIFTCLOCK,OUTPUT);
-  pinMode(STROBEPIN,OUTPUT);
-  pinMode(13,OUTPUT);
+  pinMode(SERDATAIN, OUTPUT);
+  pinMode(SHIFTCLOCK, OUTPUT);
+  pinMode(STROBEPIN, OUTPUT);
+  pinMode(13, OUTPUT);
   return;
 }

 void loop(void) {
-  uint8_t value=0, overall=0;
+  uint8_t value = 0, overall = 0;
   unsigned long now;
-
-  for (value=0;value<255;value++) {
-    uint8_t temp=value >> 4; /* need only 4 major bits */
-    now=millis();
+
+  for (value = 0; value < 255; value++) {
+    uint8_t temp = value >> 4; /* need only 4 major bits */
+    now = micros();
     do {
-      for (overall=0;overall < 16;overall++) {
-	if (temp > overall) {
-	  clockout(255);
-	  digitalWrite(13,HIGH);
-	} else {
-	  clockout(0);
-	  digitalWrite(13,LOW);
-	}
+      for (overall = 0; overall < 16; overall++) {
+        if (temp > overall) {
+          clockout(255);
+          digitalWrite(13, HIGH);
+        } else {
+          clockout(0);
+          digitalWrite(13, LOW);
+        }
       }
-    } while (millis() < (now+MYDELAY));
+    } while (micros() < (now + MYDELAY));
     //    delay(20); /* make the 0-255 stepping visible */
     clockout(0);
-    digitalWrite(13,HIGH);
+    digitalWrite(13, HIGH);
   }
-
-  for (value=255;value>0;value--) {
-    uint8_t temp=value >> 4; /* need only 4 major bits */
-    now=millis();
+
+  for (value = 255; value > 0; value--) {
+    uint8_t temp = value >> 4; /* need only 4 major bits */
+    now = micros();
     do {
-      for (overall=0;overall < 16;overall++) {
-	if (temp > overall) {
-	  clockout(255);
-	  digitalWrite(13,HIGH);
-	} else {
-	  clockout(0);
-	  digitalWrite(13,LOW);
-	}
+      for (overall = 0; overall < 16; overall++) {
+        if (temp > overall) {
+          clockout(255);
+          digitalWrite(13, HIGH);
+        } else {
+          clockout(0);
+          digitalWrite(13, LOW);
+        }
       }
-    } while (millis() < (now+MYDELAY));
-    //    delay(20); /* make the 0-255 stepping visible */
+    } while (micros() < (now + MYDELAY));
+    // delay(20); /* make the 0-255 stepping visible */
     clockout(0);
-    digitalWrite(13,HIGH);
+    digitalWrite(13, HIGH);
   }
-
+
   return;
 }
-  /* SAMPLE
-  clockout(255);
-  digitalWrite(13,HIGH);
-  delay(1000);
-  */
+/* SAMPLE
+clockout(255);
+digitalWrite(13,HIGH);
+delay(1000);
+*/

 void clockout(uint8_t data) {
-  uint8_t loop,pin=1;
+  uint8_t loop, pin = 1;

-  digitalWrite(STROBEPIN,HIGH); /* disable output */
-  for (loop=0;loop<8;loop++) {
+  digitalWrite(STROBEPIN, HIGH); /* disable output */
+  for (loop = 0; loop < 8; loop++) {
     if (data & pin) {
-      // PORTB |= PORTB4; /* set bit one */
-      digitalWrite(SERDATAIN,HIGH);
+      PORTB |= _BV(PORTB4); /* set bit one */
+      // digitalWrite(SERDATAIN, HIGH);
     } else {
-      // PORTB &= ~PORTB4;  /* clear bit one */
-      digitalWrite(SERDATAIN,LOW);
+      PORTB &= ~_BV(PORTB4);  /* clear bit one */
+      // digitalWrite(SERDATAIN, LOW);
     }
     pin = pin << 1;
-    digitalWrite(SHIFTCLOCK,LOW);
-    digitalWrite(SHIFTCLOCK,HIGH);
+    digitalWrite(SHIFTCLOCK, LOW);
+    digitalWrite(SHIFTCLOCK, HIGH);
   }
-  digitalWrite(STROBEPIN,LOW); /* enable output */
+  digitalWrite(STROBEPIN, LOW); /* enable output */
   return;
 }


A bit of refactoring and code cleanup inspired by https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/all

--- musicbox.ino
+++ musicbox.ino
@@ -2,8 +2,8 @@
 #include "constants.h"

 //Rotary pins
-int encPinA = D1;
-int encPinB = D2;
+const int encPinA = D1;
+const int encPinB = D2;

 //Delay for unsupervised stream change
 int strChangeDelay = 750;
@@ -41,24 +41,8 @@

   Serial.begin (19200);

-  Serial.print("Connecting to ");
-  Serial.print(ssid);
-  WiFi.begin(ssid, password);
-  while (WiFi.status() != WL_CONNECTED) {
-    delay(500);
-    Serial.print(".");
-  }
-  Serial.println("");
-  Serial.println("WiFi connected");
-  Serial.print("IP address: ");
-  Serial.println(WiFi.localIP());
-
-  pinMode(encPinA, INPUT_PULLUP);
-  digitalWrite(encPinA, HIGH);
-  lastEncPinAVal = digitalRead(encPinA);
-
-  pinMode(encPinB, INPUT_PULLUP);
-  digitalWrite(encPinB, HIGH);
+  initHardware();
+  initWiFi();

 }

@@ -72,7 +56,7 @@
       //We want to change the stream when the timer expires,
       //unles the rotary is in the same position we started
       if (strIndex != playingStrIndex) {
-        sendStreamChange();
+        sendStreamChange(streams[strIndex]);
         playingStrIndex = strIndex;
       }
     }
@@ -114,38 +98,74 @@
 }

-void sendStreamChange() {
+
+void initHardware() {
+
+  pinMode(LED_BUILTIN, OUTPUT);
+  digitalWrite(LED_BUILTIN, LOW);
+
+  pinMode(encPinA, INPUT_PULLUP);
+  digitalWrite(encPinA, HIGH);
+  lastEncPinAVal = digitalRead(encPinA);
+
+  pinMode(encPinB, INPUT_PULLUP);
+  digitalWrite(encPinB, HIGH);
+
+}
+
+
+
+void initWiFi() {
+
+  byte ledStatus = LOW;
+
+  Serial.print("Connecting to ");
+  Serial.println(ssid);
+  WiFi.begin(ssid, password);
+  while (WiFi.status() != WL_CONNECTED) {
+    digitalWrite(LED_BUILTIN, ledStatus); // Write LED high/low
+    ledStatus = !ledStatus;
+    delay(100);
+  }
+  Serial.print("IP address: ");
+  Serial.println(WiFi.localIP());
+  digitalWrite(LED_BUILTIN, HIGH);
+
+}
+
+int sendStreamChange(char* stream) {
+
+  digitalWrite(LED_BUILTIN, LOW);
+
   WiFiClient client;

   if (!client.connect(boseIP, bosePort)) {
-    Serial.println("connection failed");
-    Serial.println("wait 5 sec...");
-    delay(5000);
-    return;
+    return 0;
   }

-  String boseURL = "/now_playing";
-  Serial.print("Requesting URL: ");
-  Serial.println(boseURL);
+  Serial.print("Requesting stream: ");
+  Serial.println(stream);

   // This will send the request to the server
-  client.print(String("GET ") + boseURL + " HTTP/1.1\r\n" +
-               "Host: " + boseIP + "\r\n" +
-               "Connection: close\r\n\r\n");
-  unsigned long timeout = millis();
+  client.print(String("GET ") + "/now_playing HTTP/1.1\r\nHost: " + boseIP + "\r\nConnection: close\r\n\r\n");
+  /*unsigned long timeout = millis();
   while (client.available() == 0) {
+    //TODO: test failed connections
     if (millis() - timeout > 5000) {
       Serial.println(">>> Client Timeout !");
       client.stop();
       return;
     }
+  }*/
+
+  while (client.available()) {
+    String line = client.readStringUntil('\r');
+    //Serial.print(line);
   }

-  // Read all the lines of the reply from server and print them to Serial
-  while (client.available()) {
-    String line = client.readStringUntil('\r');
-    Serial.print(line);
-  }
+  digitalWrite(LED_BUILTIN, HIGH);
+  return 1;
+

 }


Add queue test

Add queue test

--- examples/klipframeworktest/klipframeworktest.ino
+++ examples/klipframeworktest/klipframeworktest.ino
@@ -6,6 +6,11 @@

 VirtualTimer timerTest;
+
+uint8_t queueBuffer[8];
+
+Queue queueTest(queueBuffer,8);
+

 void setup()
 {


[cordwood/tuner] refactored sketch (source)


Version as currently deployed.

Version as currently deployed.

--- lib-arduino/ACNode/examples/SpaceDeur/SpaceDeur.ino
+++ lib-arduino/ACNode/examples/SpaceDeur/SpaceDeur.ino
@@ -48,8 +48,8 @@

 // Introduced by alex - 2020-01-8
 #define GROTE_SCHAKELAAR_SENSOR       (34)
-#define GROTE_SCHAKELAAR_IS_OPEN     (LOW)
-#define GROTE_SCHAKELAAR_TOPIC      "makerspace/groteschakelaar"
+#define GROTE_SCHAKELAAR_IS_OPEN      (HIGH)
+#define GROTE_SCHAKELAAR_TOPIC        "makerspace/groteschakelaar"

 #define BUZZ_TIME (5 * 1000) // Buzz 8 seconds.

@@ -264,7 +264,8 @@
 void grote_schakelaar_loop() {
   // debounce
   static unsigned long lst = 0;
-
+  static int last_grote_schakelaar = -2;
+
   if (digitalRead(GROTE_SCHAKELAAR_SENSOR) != last_grote_schakelaar && lst = 0) {
     last_grote_schakelaar = digitalRead(GROTE_SCHAKELAAR_SENSOR);
     lst = millis();
@@ -274,7 +275,7 @@
   //
   if (lst && millis() - lst > 100) {
     // stable for over 100 milliseconds; so we trust this value;
-    if (last_grote_schakelaar == GROTE_SCHAKELAAR_OPEN) {
+    if (last_grote_schakelaar == GROTE_SCHAKELAAR_IS_OPEN) {
       Log.println("Grote schakelaar: Space is now open.");
       node.send(GROTE_SCHAKELAAR_TOPIC, "1");
     } else {


Update SW01_Altitude_Measurement.ino

Update SW01_Altitude_Measurement.ino

--- examples/SW01_Altitude_Measurement/SW01_Altitude_Measurement.ino
+++ examples/SW01_Altitude_Measurement/SW01_Altitude_Measurement.ino
@@ -45,12 +45,12 @@
 }

 void loop(){
-	// Create a variable to store the data read from SW0
+	// Create a variable to store the data read from SW01
 	float alt;
 	alt = 0;

-  // Read and calculate data from SW01 sensor
-  SW01.poll();
+  	// Read and calculate data from SW01 sensor
+  	SW01.poll();

 	// Request SW01 to get the altitude measurement and store in
 	// the altitude variable


Update OBSIDEM_NEW_GAME.ino

Update OBSIDEM_NEW_GAME.ino

--- OBSIDEM_NEW_GAME/OBSIDEM_NEW_GAME.ino
+++ OBSIDEM_NEW_GAME/OBSIDEM_NEW_GAME.ino
@@ -1,556 +1,557 @@
-#include <SPI.h>
-#include "Mfrc522.h"
-
-
-
-
-//r1 pins
-#define r1_shield_pin 6
-#define r1_bust_pin 2
-#define r1_motor_relay_pin 18
-#define r1_motor_mosfet_pin 40
-#define r1_large_frame_pin 39
-#define r1_pedestal_pin 38
-
-//r2 pins
-#define r2_houselight_pin 37
-#define r2_uv_pin 36
-#define r2_entry_door_pin 24
-#define r2_exit_door_pin 11
-#define r2_laserrx1_pin 28
-#define r2_laserrx2_pin 27
-#define r2_laserrx3_pin 26
-#define r2_laserrx4_pin 25
-#define r2_door_lights_pin 19
-
-//r3 pins
-#define r3_picture_pin 13
-#define r3_g1_pin 34
-#define r3_g2_pin 33
-#define r3_g3_pin 32
-#define r3_g4_pin 31
-#define r3_shield_pin 23
-#define r3_statue_orientation_pin 8
-
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-class Room1
-{
-public:
-
-int off_state;
-
-  Room1()
-{
- pinMode(r1_shield_pin,INPUT_PULLDOWN);
- pinMode(r1_bust_pin,INPUT);
- pinMode(r1_motor_relay_pin,OUTPUT);
- pinMode(r1_motor_mosfet_pin,OUTPUT);
- pinMode(r1_large_frame_pin,OUTPUT);
- pinMode(r1_pedestal_pin,OUTPUT);
- calibrate_bust();
-}
-
-//r1 functions
-bool check_shield()
-{
-  return (digitalRead(r1_shield_pin));
-}
-
-void calibrate_bust()
-{
-  off_state = analogRead(r1_bust_pin);
-}
-
-bool check_bust()
-{
-  if (analogRead(r1_bust_pin) > 200)
-    return true;
-  else
-    return false;
-}
-
-void set_pedestal(bool state)
-{
-  digitalWrite(r1_pedestal_pin,state);
-}
-
-void set_frame(bool state)
-{
-  digitalWrite(r1_large_frame_pin,state);
-}
-
-void activate_slider(bool direction)
-{
-  digitalWrite(r1_motor_relay_pin,direction);
-  digitalWrite(r1_motor_mosfet_pin,true);
-  delay (5000);
-  digitalWrite(r1_motor_mosfet_pin,false);
-}
-};
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-class Room2
-{
-public:
-
-Room2()
-{
-pinMode(r2_houselight_pin,OUTPUT);
-pinMode(r2_uv_pin,OUTPUT);
-pinMode(r2_entry_door_pin,INPUT_PULLDOWN);
-pinMode(r2_exit_door_pin,OUTPUT);
-pinMode(r2_laserrx1_pin,INPUT);
-pinMode(r2_laserrx2_pin,INPUT);
-pinMode(r2_laserrx3_pin,INPUT);
-pinMode(r2_laserrx4_pin,INPUT);
-pinMode(r2_door_lights_pin, OUTPUT);
-calibrate_laserrx();
-}
-//room2 objects
-const int code[4] =  {1,2,3,4};
-int puzzle_state = 0;
-int avg_base_value;
-//
-
-//
-//r2_functions
-void set_houselights (bool status)
-{
-  digitalWrite(r2_houselight_pin, status);
-}
-
-void set_uv (bool status)
-{
-  digitalWrite(r2_uv_pin, status);
-}
-
-void set_door_lights(int intensity)
-{
-  analogWrite(r2_door_lights_pin,intensity);
-}
-
-bool get_entry_door_status()
-{
-  return (digitalRead(r2_entry_door_pin));
-}
-
-void set_exit_door(bool status)
-{
-  digitalWrite(r2_exit_door_pin,status);
-}
-
-int calibrate_laserrx()
-{
-  int avg = 0;
-  avg = analogRead(r2_laserrx1_pin) + analogRead(r2_laserrx2_pin) + analogRead(r2_laserrx3_pin) + analogRead(r2_laserrx4_pin);
-  avg /= 4;
-  return avg;
-}
-
-
-bool check_laser_rx (int laser_number)
-{
-  int rx_value;
-  switch(laser_number)
-  {
-  case 1: rx_value = analogRead(r2_laserrx1_pin);
-  case 2: rx_value = analogRead(r2_laserrx2_pin);
-  case 3: rx_value = analogRead(r2_laserrx3_pin);
-  case 4: rx_value = analogRead(r2_laserrx4_pin);
-  }
-  if (rx_value > avg_base_value)
-    return true;
-  else
-    return false;
-}
-
-int check_laser_puzzle()
-{
-  if (puzzle_state == 0 && (check_laser_rx(code[0])))
-    {
-    puzzle_state = 1;
-    set_door_lights(63);
-    delay (500);
-    }
-
-  if (puzzle_state == 1 && (check_laser_rx(code[1])))
-    {
-    puzzle_state = 2;
-    set_door_lights(126);
-    delay(500);
-    }
- /* else
-  {
-    puzzle_state = 0;
-    set_door_lights(0);
-  }*/
-
-  if (puzzle_state == 2 && (check_laser_rx(code[2])))
-    {
-      puzzle_state = 3;
-      set_door_lights(189);
-      delay(500);
-    }
-  /*else
-  {
-    puzzle_state = 0;
-    set_door_lights(0);
-  }*/
-
-  if (puzzle_state == 3 && (check_laser_rx(code[3])))
-    {
-      puzzle_state = 4;
-      set_door_lights(255);
-      set_exit_door(false);
-      delay(500);
-    }
-  /*else
-    {
-    puzzle_state = 0;
-    set_door_lights(0);
-    }*/
-
-
-
-  return puzzle_state;
-}
-
-};
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-class Room3
-{
-public:
-
-Room3()
-{
-pinMode(r3_picture_pin,INPUT);
-pinMode(r3_g1_pin, OUTPUT);
-pinMode(r3_g2_pin,OUTPUT);
-pinMode(r3_g3_pin,OUTPUT);
-pinMode(r3_g4_pin,OUTPUT);
-pinMode(r3_shield_pin,INPUT_PULLDOWN);
-pinMode(r3_statue_orientation_pin,INPUT_PULLDOWN);
-}
-
-
-
-bool check_pictures()
-{
-  return (digitalRead(r3_picture_pin));
-}
-
-void set_glyph(int glyph, bool status)
-{
-  switch (glyph)
-  {
-  case 1: digitalWrite(r3_g1_pin,status);
-  case 2: digitalWrite(r3_g2_pin,status);
-  case 3: digitalWrite(r3_g3_pin,status);
-  case 4: digitalWrite(r3_g4_pin,status);
-  }
-}
-
-bool check_shield()
-{
-  return(digitalRead(r3_shield_pin));
-}
-
-bool check_statue_orientation()
-{
-  return(digitalRead(r3_statue_orientation_pin));
-}
-};
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-class RFID_EFFECTS
-{
-private:
-Mfrc522 * rfid [6];
-unsigned char codes [6][5];
-
-public:
-RFID_EFFECTS()
-{
-  SPI.begin();
-  for (int i = 0; i < 6 ; i++)
-  {
-    rfid[i] = new Mfrc522(i);
-    rfid[i]->Init();
-  }
-}
-
-void set_codes()
-  {
-    unsigned char temp[16];
-    for (int i = 0 ; i < 6 ; i++)
-    {
-      if ( rfid[i]->Request(PICC_REQIDL, temp) == '0' )
-      {
-        if (rfid[i]->Anticoll(temp) == '0')
-        {
-          for(int j = 0 ; i < 5 ; i++)
-          {
-          codes[i][j] = temp[j];
-          }
-        }
-      }
-    }
-  }
-
-bool compare_codes_r1()
-{
-  bool compare = true;
-  unsigned char temp[16];
-    for (int i = 0 ; i < 3 ; i++)
-    {
-      if ( rfid[i]->Request(PICC_REQIDL, temp) == '0' )
-      {
-        if (rfid[i]->Anticoll(temp) == '0')
-        {
-         for (int j = 0 ; j < 6 ; i++)
-         {
-
-            if (codes[i][j] == temp[j])
-              compare &= true;
-              else
-              compare &= false;
-
-         }
-        }
-      }
-    }
-}
-bool compare_codes_r3()
-{
-  bool compare = true;
-  unsigned char temp[16];
-    for (int i = 3 ; i < 6 ; i++)
-    {
-      if ( rfid[i]->Request(PICC_REQIDL, temp) == '0' )
-      {
-        if (rfid[i]->Anticoll(temp) == '0')
-        {
-         for (int j = 0 ; j < 6 ; i++)
-         {
-
-            if (codes[i][j] == temp[j])
-              compare &= true;
-              else
-              compare &= false;
-
-         }
-        }
-      }
-    }
-}
-
-
-
-};
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-//status registers
-int status = 0;
-/*
- 0 = standby
- 1 = room1
- 2 = room2
- 3 = room3
- 4 = game over
- 5 = reset1
- 6 = reset2
- 7 = rfid_set
- */
-
-
-void serial_readin()
-{
-  String serial_in = "NULL";
-  if (Serial.available())
-  serial_in = Serial.readString();
-  else
-  serial_in = "NULL";
-
-    if (serial_in == "status = 0")
-    status = 0;
-
-    if (serial_in == "status = 1")
-    status = 1;
-
-    if (serial_in == "status = 2")
-    status = 2;
-
-    if (serial_in == "status = 3")
-    status = 3;
-
-    if (serial_in == "status = 4")
-    status = 4;
-
-    if (serial_in == "status = 5")
-    status = 5;
-
-    if (serial_in == "status = 6")
-    status = 6;
-
-    if (serial_in == "status = 7")
-    status = 7;
-
-    if (serial_in == "reset_1")
-    status = 5;
-
-    if (serial_in == "reset_2")
-    status = 6;
-
-    if (serial_in == "set_rfid")
-    status = 7;
-
-
-}
-
-
-
-
-
-
-Room1 room1;
-Room2 room2;
-Room3 room3;
-RFID_EFFECTS rfid;
-
-void setup() {
-  // put your setup code here, to run once:
-Serial.begin(9600);
-
-
-}
-
-void loop() {
-
-  //standby***********************************************************************************
-  while(status == 0)
-  {
-    serial_readin();
-  }
-
-  //room1************************************************************************************
-  while(status == 1)
-  {
-
-    serial_readin();
-
-    if(room1.check_shield())
-      room1.set_frame(false);
-
-    if(room1.check_bust())
-      room1.set_pedestal(false);
-
-    if(rfid.compare_codes_r1())
-      room1.activate_slider(true);
-  }
-
-  //room2****************************************************************************************
-  while(status == 2)
-  {
-    serial_readin();
-
-    room2.set_uv(room2.get_entry_door_status());
-    room2.set_houselights(!room2.get_entry_door_status());
-    room2.check_laser_puzzle();
-  }
-
-  //room3*****************************************************************************************
-  while(status == 3)
-  {
-    serial_readin();
-
-    if(room3.check_shield())
-      room3.set_glyph(1,true);
-
-    if(rfid.compare_codes_r3())
-      room3.set_glyph(2,true);
-
-    if(room3.check_pictures())
-      room3.set_glyph(3,true);
-
-    if(room3.check_statue_orientation())
-      room3.set_glyph(4,true);
-  }
-
-//reset1**********************************************************************************************
-while(status == 4)
-{
-  serial_readin();
-
-  room1.set_frame(false);
-  room1.set_pedestal(false);
-  room1.activate_slider(true);
-
-  room2.set_uv(true);
-  room2.set_houselights(true);
-  room2.set_exit_door(false);
-  room2.set_door_lights(255);
-
-  room3.set_glyph(1,true);
-  room3.set_glyph(2,true);
-  room3.set_glyph(3,true);
-  room3.set_glyph(4,true);
-
-}
-
-//reset2**********************************************************************************************
-while(status == 5)
-{
-  serial_readin();
-
-  room1.set_frame(true);
-  room1.set_pedestal(true);
-  room1.activate_slider(false);
-  room1.calibrate_bust();
-
-  room2.set_uv(false);
-  room2.set_houselights(false);
-  room2.set_exit_door(true);
-  room2.set_door_lights(0);
-  room2.calibrate_laserrx();
-
-  room3.set_glyph(1,false);
-  room3.set_glyph(2,false);
-  room3.set_glyph(3,false);
-  room3.set_glyph(4,false);
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
+#include <SPI.h>
+#include "Mfrc522.h"
+
+
+
+
+//r1 pins
+#define r1_shield_pin 6
+#define r1_bust_pin 2
+#define r1_motor_relay_pin 18
+#define r1_motor_mosfet_pin 40
+#define r1_large_frame_pin 39
+#define r1_pedestal_pin 38
+
+//r2 pins
+#define r2_houselight_pin 37
+#define r2_uv_pin 36
+#define r2_entry_door_pin 24
+#define r2_exit_door_pin 11
+#define r2_laserrx1_pin 28
+#define r2_laserrx2_pin 27
+#define r2_laserrx3_pin 26
+#define r2_laserrx4_pin 25
+#define r2_door_lights_pin 19
+
+//r3 pins
+#define r3_picture_pin 13
+#define r3_g1_pin 34
+#define r3_g2_pin 33
+#define r3_g3_pin 32
+#define r3_g4_pin 31
+#define r3_shield_pin 23
+#define r3_statue_orientation_pin 8
+
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+class Room1
+{
+public:
+
+int off_state;
+
+  Room1()
+{
+ pinMode(r1_shield_pin,INPUT_PULLDOWN);
+ pinMode(r1_bust_pin,INPUT);
+ pinMode(r1_motor_relay_pin,OUTPUT);
+ pinMode(r1_motor_mosfet_pin,OUTPUT);
+ pinMode(r1_large_frame_pin,OUTPUT);
+ pinMode(r1_pedestal_pin,OUTPUT);
+ calibrate_bust();
+}
+
+//r1 functions
+bool check_shield()
+{
+  return (digitalRead(r1_shield_pin));
+}
+
+void calibrate_bust()
+{
+  off_state = analogRead(r1_bust_pin);
+}
+
+bool check_bust()
+{
+  if (analogRead(r1_bust_pin) > 200)
+    return true;
+  else
+    return false;
+}
+
+void set_pedestal(bool state)
+{
+  digitalWrite(r1_pedestal_pin,state);
+}
+
+void set_frame(bool state)
+{
+  digitalWrite(r1_large_frame_pin,state);
+}
+
+void activate_slider(bool direction)
+{
+  digitalWrite(r1_motor_relay_pin,direction);
+  digitalWrite(r1_motor_mosfet_pin,true);
+  delay (5000);
+  digitalWrite(r1_motor_mosfet_pin,false);
+}
+};
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+class Room2
+{
+public:
+
+Room2()
+{
+pinMode(r2_houselight_pin,OUTPUT);
+pinMode(r2_uv_pin,OUTPUT);
+pinMode(r2_entry_door_pin,INPUT_PULLDOWN);
+pinMode(r2_exit_door_pin,OUTPUT);
+pinMode(r2_laserrx1_pin,INPUT);
+pinMode(r2_laserrx2_pin,INPUT);
+pinMode(r2_laserrx3_pin,INPUT);
+pinMode(r2_laserrx4_pin,INPUT);
+pinMode(r2_door_lights_pin, OUTPUT);
+calibrate_laserrx();
+}
+//room2 objects
+const int code[4] =  {1,2,3,4};
+int puzzle_state = 0;
+int avg_base_value;
+//
+
+//
+//r2_functions
+void set_houselights (bool status)
+{
+  digitalWrite(r2_houselight_pin, status);
+}
+
+void set_uv (bool status)
+{
+  digitalWrite(r2_uv_pin, status);
+}
+
+void set_door_lights(int intensity)
+{
+  analogWrite(r2_door_lights_pin,intensity);
+}
+
+bool get_entry_door_status()
+{
+  return (digitalRead(r2_entry_door_pin));
+}
+
+void set_exit_door(bool status)
+{
+  digitalWrite(r2_exit_door_pin,status);
+}
+
+int calibrate_laserrx()
+{
+  int avg = 0;
+  avg = analogRead(r2_laserrx1_pin) + analogRead(r2_laserrx2_pin) + analogRead(r2_laserrx3_pin) + analogRead(r2_laserrx4_pin);
+  avg /= 4;
+  return avg;
+}
+
+
+bool check_laser_rx (int laser_number)
+{
+  int rx_value;
+  switch(laser_number)
+  {
+  case 1: rx_value = analogRead(r2_laserrx1_pin);
+  case 2: rx_value = analogRead(r2_laserrx2_pin);
+  case 3: rx_value = analogRead(r2_laserrx3_pin);
+  case 4: rx_value = analogRead(r2_laserrx4_pin);
+  }
+  if (rx_value > avg_base_value)
+    return true;
+  else
+    return false;
+}
+
+int check_laser_puzzle()
+{
+  if (puzzle_state == 0 && (check_laser_rx(code[0])))
+    {
+    puzzle_state = 1;
+    set_door_lights(63);
+    delay (500);
+    }
+
+  if (puzzle_state == 1 && (check_laser_rx(code[1])))
+    {
+    puzzle_state = 2;
+    set_door_lights(126);
+    delay(500);
+    }
+ /* else
+  {
+    puzzle_state = 0;
+    set_door_lights(0);
+  }*/
+
+  if (puzzle_state == 2 && (check_laser_rx(code[2])))
+    {
+      puzzle_state = 3;
+      set_door_lights(189);
+      delay(500);
+    }
+  /*else
+  {
+    puzzle_state = 0;
+    set_door_lights(0);
+  }*/
+
+  if (puzzle_state == 3 && (check_laser_rx(code[3])))
+    {
+      puzzle_state = 4;
+      set_door_lights(255);
+      set_exit_door(false);
+      delay(500);
+    }
+  /*else
+    {
+    puzzle_state = 0;
+    set_door_lights(0);
+    }*/
+
+
+
+  return puzzle_state;
+}
+
+};
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+class Room3
+{
+public:
+
+Room3()
+{
+pinMode(r3_picture_pin,INPUT);
+pinMode(r3_g1_pin, OUTPUT);
+pinMode(r3_g2_pin,OUTPUT);
+pinMode(r3_g3_pin,OUTPUT);
+pinMode(r3_g4_pin,OUTPUT);
+pinMode(r3_shield_pin,INPUT_PULLDOWN);
+pinMode(r3_statue_orientation_pin,INPUT_PULLDOWN);
+}
+
+
+
+bool check_pictures()
+{
+  return (digitalRead(r3_picture_pin));
+}
+
+void set_glyph(int glyph, bool status)
+{
+  switch (glyph)
+  {
+  case 1: digitalWrite(r3_g1_pin,status);
+  case 2: digitalWrite(r3_g2_pin,status);
+  case 3: digitalWrite(r3_g3_pin,status);
+  case 4: digitalWrite(r3_g4_pin,status);
+  }
+}
+
+bool check_shield()
+{
+  return(digitalRead(r3_shield_pin));
+}
+
+bool check_statue_orientation()
+{
+  return(digitalRead(r3_statue_orientation_pin));
+}
+};
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+class RFID_EFFECTS
+{
+private:
+Mfrc522 * rfid [6];
+unsigned char codes [6][5];
+
+public:
+RFID_EFFECTS()
+{
+  SPI.begin();
+  for (int i = 0; i < 6 ; i++)
+  {
+    rfid[i] = new Mfrc522(i);
+    rfid[i]->Init();
+  }
+}
+
+void set_codes()
+  {
+    unsigned char temp[16];
+    for (int i = 0 ; i < 6 ; i++)
+    {
+      if ( rfid[i]->Request(PICC_REQIDL, temp) == '0' )
+      {
+        if (rfid[i]->Anticoll(temp) == '0')
+        {
+          for(int j = 0 ; i < 5 ; i++)
+          {
+          codes[i][j] = temp[j];
+          }
+        }
+      }
+    }
+  }
+
+bool compare_codes_r1()
+{
+  bool compare = true;
+  unsigned char temp[16];
+    for (int i = 0 ; i < 3 ; i++)
+    {
+      if ( rfid[i]->Request(PICC_REQIDL, temp) == '0' )
+      {
+        if (rfid[i]->Anticoll(temp) == '0')
+        {
+         for (int j = 0 ; j < 6 ; i++)
+         {
+
+            if (codes[i][j] == temp[j])
+              compare &= true;
+              else
+              compare &= false;
+
+         }
+        }
+      }
+    }
+}
+bool compare_codes_r3()
+{
+  bool compare = true;
+  unsigned char temp[16];
+    for (int i = 3 ; i < 6 ; i++)
+    {
+      if ( rfid[i]->Request(PICC_REQIDL, temp) == '0' )
+      {
+        if (rfid[i]->Anticoll(temp) == '0')
+        {
+         for (int j = 0 ; j < 6 ; i++)
+         {
+
+            if (codes[i][j] == temp[j])
+              compare &= true;
+              else
+              compare &= false;
+
+         }
+        }
+      }
+    }
+}
+
+
+
+};
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//status registers
+int status = 0;
+/*
+ 0 = standby
+ 1 = room1
+ 2 = room2
+ 3 = room3
+ 4 = game over
+ 5 = reset1
+ 6 = reset2
+ 7 = rfid_set
+ */
+
+
+void serial_readin()
+{
+  String serial_in = "NULL";
+  if (Serial.available())
+  serial_in = Serial.readString();
+  else
+  serial_in = "NULL";
+
+    if (serial_in == "status = 0")
+    status = 0;
+
+    if (serial_in == "status = 1")
+    status = 1;
+
+    if (serial_in == "status = 2")
+    status = 2;
+
+    if (serial_in == "status = 3")
+    status = 3;
+
+    if (serial_in == "status = 4")
+    status = 4;
+
+    if (serial_in == "status = 5")
+    status = 5;
+
+    if (serial_in == "status = 6")
+    status = 6;
+
+    if (serial_in == "status = 7")
+    status = 7;
+
+    if (serial_in == "reset_1")
+    status = 5;
+
+    if (serial_in == "reset_2")
+    status = 6;
+
+    if (serial_in == "set_rfid")
+    status = 7;
+
+
+}
+
+
+
+
+
+
+Room1 room1;
+Room2 room2;
+Room3 room3;
+RFID_EFFECTS rfid;
+
+void setup() {
+  // put your setup code here, to run once:
+Serial.begin(9600);
+  Serial.setTimeout (100);
+
+
+}
+
+void loop() {
+
+  //standby***********************************************************************************
+  while(status == 0)
+  {
+    serial_readin();
+  }
+
+  //room1************************************************************************************
+  while(status == 1)
+  {
+
+    serial_readin();
+
+    if(room1.check_shield())
+      room1.set_frame(false);
+
+    if(room1.check_bust())
+      room1.set_pedestal(false);
+
+    if(rfid.compare_codes_r1())
+      room1.activate_slider(true);
+  }
+
+  //room2****************************************************************************************
+  while(status == 2)
+  {
+    serial_readin();
+
+    room2.set_uv(room2.get_entry_door_status());
+    room2.set_houselights(!room2.get_entry_door_status());
+    room2.check_laser_puzzle();
+  }
+
+  //room3*****************************************************************************************
+  while(status == 3)
+  {
+    serial_readin();
+
+    if(room3.check_shield())
+      room3.set_glyph(1,true);
+
+    if(rfid.compare_codes_r3())
+      room3.set_glyph(2,true);
+
+    if(room3.check_pictures())
+      room3.set_glyph(3,true);
+
+    if(room3.check_statue_orientation())
+      room3.set_glyph(4,true);
+  }
+
+//reset1**********************************************************************************************
+while(status == 4)
+{
+  serial_readin();
+
+  room1.set_frame(false);
+  room1.set_pedestal(false);
+  room1.activate_slider(true);
+
+  room2.set_uv(true);
+  room2.set_houselights(true);
+  room2.set_exit_door(false);
+  room2.set_door_lights(255);
+
+  room3.set_glyph(1,true);
+  room3.set_glyph(2,true);
+  room3.set_glyph(3,true);
+  room3.set_glyph(4,true);
+
+}
+
+//reset2**********************************************************************************************
+while(status == 5)
+{
+  serial_readin();
+
+  room1.set_frame(true);
+  room1.set_pedestal(true);
+  room1.activate_slider(false);
+  room1.calibrate_bust();
+
+  room2.set_uv(false);
+  room2.set_houselights(false);
+  room2.set_exit_door(true);
+  room2.set_door_lights(0);
+  room2.calibrate_laserrx();
+
+  room3.set_glyph(1,false);
+  room3.set_glyph(2,false);
+  room3.set_glyph(3,false);
+  room3.set_glyph(4,false);
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}


added static ip

added static ip

as commented out

--- arduino/WiFi-Car_WEMOS-aRest/WiFi-Car_WEMOS-aRest.ino
+++ arduino/WiFi-Car_WEMOS-aRest/WiFi-Car_WEMOS-aRest.ino
@@ -32,6 +32,12 @@

 // Create an instance of the server
 WiFiServer server(LISTEN_PORT);
+
+//// Set the IP address for the shield //also later in setup
+//IPAddress ip(192, 168, 88, 200);
+//IPAddress gateway(192,168,88,1);
+//IPAddress subnet(255,255,255,0);
+

 // Functions from aRest.js
 int stop(String message);
@@ -98,6 +104,7 @@

   // Connect to WiFi
   WiFi.begin(ssid, password);
+//  WiFi.config(ip, gateway, subnet); // Set the static ip
   while (WiFi.status() != WL_CONNECTED) {
     delay(500);
     Serial.print(".");


Add option to output to Adafruit TFT screen. Fixes #4

--- ArduinoMorseCodeDecoder.ino
+++ ArduinoMorseCodeDecoder.ino
@@ -6,6 +6,18 @@
 #include "MorseNode.h"

 #include "Symbols.h"
+
+//#define TFT_DISPLAY
+#ifdef TFT_DISPLAY
+
+#include <Adafruit_ST7735.h>
+
+const int TFT_CS = 10;
+const int TFT_RST = 9;
+const int TFT_DC = 8;
+Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);
+
+#endif

 //------------------------------------------------------------------------------

@@ -45,6 +57,9 @@

 //------------------------------------------------------------------------------

+int getInput();
+void outputCharacter(char character);
+void outputString(String string);
 int determineDotDash(unsigned long holdMillis);
 int determineLetterWordSpace(unsigned long spaceMillis);
 String getDotDashOrSpaceString(int input);
@@ -53,9 +68,17 @@
 //------------------------------------------------------------------------------

 void setup() {
-  pinMode(LED, OUTPUT);
-  pinMode(BUTTON, INPUT_PULLUP);
-
+  #ifdef TFT_DISPLAY
+    tft.initR(INITR_BLACKTAB);
+    tft.fillScreen(ST7735_BLACK);
+    tft.setTextSize(2);
+    tft.setCursor(0, 0);
+
+  #else
+    pinMode(LED, OUTPUT);
+    pinMode(BUTTON, INPUT_PULLUP);
+  #endif
+
   Serial.begin(9600);

   alphabet = MorseNode::getInternationalAlphabet();
@@ -64,7 +87,8 @@
 //------------------------------------------------------------------------------

 void loop() {
-  inputVal = (digitalRead(BUTTON) == HIGH) ? LOW : HIGH; //switch high and low because it's a pullup
+  inputVal = getInput();
+
   digitalWrite(LED, inputVal);

   if (inputVal == HIGH && previousInputVal == LOW) {
@@ -113,15 +137,15 @@
       char c = alphabet->decode(&inputSymbols[0], inputIndex);

       if (c != '\0') { //print the character
-        Serial.print(c);
+        outputCharacter(c);
       } else { // couldn't find character, print symbols
         for (int i = 0; i < inputIndex; i++) {
-          Serial.print(getDotDashOrSpaceSymbolString(inputSymbols[i]));
+          outputString(getDotDashOrSpaceSymbolString(inputSymbols[i]));
         }
       }

       if (result == WORD_SPACE) {
-        Serial.print(' ');
+        outputCharacter(' ');
         spaceProcessed = true;
       }

@@ -205,3 +229,52 @@

 //------------------------------------------------------------------------------

+int getButtonInput() {
+  return (digitalRead(BUTTON) == HIGH) ? LOW : HIGH; //switch high and low because it's a pullup
+}
+
+//------------------------------------------------------------------------------
+
+int getJoystickInput()
+{
+  int joystickState = analogRead(3);
+
+  if (joystickState < 650) {
+    return HIGH;
+  } else {
+    return LOW;
+  }
+}
+
+//------------------------------------------------------------------------------
+
+int getInput() {
+  #ifdef TFT_DISPLAY
+    return getJoystickInput();
+  #else
+    return getButtonInput();
+  #endif
+
+}
+
+//------------------------------------------------------------------------------
+
+void outputCharacter(char character) {
+  Serial.print(character);
+
+  #ifdef TFT_DISPLAY
+    tft.print(character);
+  #endif
+}
+
+//------------------------------------------------------------------------------
+
+void outputString(String string) {
+  Serial.print(string);
+
+  #ifdef TFT_DISPLAY
+    tft.print(string);
+  #endif
+}
+
+//------------------------------------------------------------------------------


Insignificant Change

Insignificant Change

Not sure what changed, looks like i commented out a delay

--- MotorControlling/BasicStepping2/BasicStepping2.ino
+++ MotorControlling/BasicStepping2/BasicStepping2.ino
@@ -151,5 +151,5 @@
   }

   // Wait for 300 ms.
-  delay(300);
+  //delay(300);
   }


Add a net status in keep alive

Add a net status in keep alive

--- arduino/sketch_tc_hitachi/sketch_tc_hitachi.ino
+++ arduino/sketch_tc_hitachi/sketch_tc_hitachi.ino
@@ -497,6 +497,8 @@
   snprintf(addr, sizeof(addr), "%02x%02x", g_zigbee_short_addr[0], g_zigbee_short_addr[1]);
   root["addr"] = addr;

+  root["status"] = g_net_ok;
+
   g_body_len = root.printTo((char *)g_buf + HEADER_LEN, BUF_LEN - HEADER_LEN);

   send_msg(MSG_TYPE_CONTROL);


Fixed compilation error 1

Fixed compilation error 1

--- 2018-FirefighterL1/gyro.ino
+++ 2018-FirefighterL1/gyro.ino
@@ -89,7 +89,7 @@
     return angle_pitch_output;
 }

-void getGyroRoll()
+float getGyroRoll()
 {

     read_mpu_6050_data();


map trigger battery level to percent

map trigger battery level to percent

--- esp8266/trigger/trigger.ino
+++ esp8266/trigger/trigger.ino
@@ -108,10 +108,14 @@

   // read the battery level from the ESP8266 analog in pin.
   // analog read level is 10 bit 0-1023 (0V-1V).
-  // our 10K & 2.2K voltage divider takes the max
+  // our 1M & 220K voltage divider takes the max
   // lipo value of 4.2V and drops it to 0.758V max.
-  // this means our max analog read value should be 774
+  // this means our min analog read value should be 590 (3.2V battery)
+  // and the max analog read value should be 774 (4.2V battery).
   int level = analogRead(A0);
+
+  // convert battery level to percent
+  level = map(level, 590, 774, 0, 100);

   // turn on wifi if we aren't connected
   if(WiFi.status() != WL_CONNECTED)


Use wifi helper.

Use wifi helper.

--- examples/mqtt_config_test/mqtt_config_test.ino
+++ examples/mqtt_config_test/mqtt_config_test.ino
@@ -4,59 +4,28 @@
 #include <ArduinoJson.h>
 #include <MqttWrapper.h>
 #include <PubSubClient.h>
+#include <WiFiHelper.h>

-// const char* ssid     = "OpenWrt_NAT_500GP.101";
-// const char* pass = "activegateway";
-
-// const char* ssid     = "MAKERCLUB-CM";
-// const char* pass = "welcomegogogo";
-
-const char* ssid     = "Opendream Play";
-const char* pass = "5k,skrijv',7'sik";
-
-// const char* ssid     = "Opendream";
-// const char* pass = "gfkgvkgv'2015!!!!";
-
+const char* ssid     = "CMMC.32";
+const char* pass     = "guestnetwork";

 MqttWrapper *mqtt;
-
-void connect_wifi()
-{
-    WiFi.begin(ssid, pass);
-
-    int retries = 0;
-    while ((WiFi.status() != WL_CONNECTED))
-    {
-        Serial.print(".");
-        retries++;
-        delay(500);
-    }
-
-    Serial.println("WIFI CONNECTED ");
-}
-
-void reconnect_wifi_if_link_down() {
-    if (WiFi.status() != WL_CONNECTED) {
-        DEBUG_PRINTLN("WIFI DISCONNECTED");
-        connect_wifi();
-    }
-}
-
+WiFiHelper *wifi;

 void callback(const MQTT::Publish& pub) {
-    if (pub.payload_string() == "0") {
-        Serial.print(" => ");
-        Serial.println(pub.payload_string());
-    }
-    else if(pub.payload_string() == "1") {
-        Serial.print(" => ");
-        Serial.println(pub.payload_string());
-    }
-    else {
-        Serial.print(pub.topic());
-        Serial.print(" => ");
-        Serial.println(pub.payload_string());
-    }
+  if (pub.payload_string() == "0") {
+    Serial.print(" => ");
+    Serial.println(pub.payload_string());
+  }
+  else if (pub.payload_string() == "1") {
+    Serial.print(" => ");
+    Serial.println(pub.payload_string());
+  }
+  else {
+    Serial.print(pub.topic());
+    Serial.print(" => ");
+    Serial.println(pub.payload_string());
+  }
 }

 void hook_prepare_data(JsonObject** root) {
@@ -68,54 +37,57 @@
 }

 void hook_configuration(MqttWrapper::Config config) {
-    uint8_t mac[6];
-    WiFi.macAddress(mac);
-    String result;
-    for (int i = 0; i < 6; ++i)
-    {
-        result += String(mac[i], 16);
-    }
+  uint8_t mac[6];
+  WiFi.macAddress(mac);
+  String result;
+  for (int i = 0; i < 6; ++i)
+  {
+    result += String(mac[i], 16);
+  }

-    *(config.clientId) = String("d:quickstart:arduino:") + result;
-    *(config.username) = String("test");
-    *(config.password) = String("test");
-    *(config.channelId) = String("esp8266/");
-    *(config.topicPub) = "iot-2/evt/status/fmt/json";
+  *(config.clientId) = String("d:quickstart:arduino:") + result;
+  *(config.username) = String("test");
+  *(config.password) = String("test");
+  *(config.channelId) = String("esp8266/");
+  *(config.topicPub) = "iot-2/evt/status/fmt/json";
 }

 void hook_publish_data(char* data) {
-    Serial.print("PUBLISH: ->");
-    Serial.println(data);
+  Serial.print("PUBLISH: ->");
+  Serial.println(data);
 }

 void setup() {
-    Serial.begin(115200);
-    pinMode(0, INPUT_PULLUP);
-    delay(10);
-    Serial.println();
-    Serial.println();
+  Serial.begin(115200);
+  pinMode(0, INPUT_PULLUP);
+  delay(10);
+  Serial.println();
+  Serial.println();

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

-    mqtt = new MqttWrapper("m20.cloudmqtt.com", 19642, hook_configuration);
-    mqtt->connect(callback);
-    mqtt->set_prepare_data_hook(hook_prepare_data, 5000);
-    mqtt->set_publish_data_hook(hook_publish_data);
+  mqtt = new MqttWrapper("m20.cloudmqtt.com", 19642, hook_configuration);
+  mqtt->connect(callback);
+  mqtt->set_prepare_data_hook(hook_prepare_data, 5000);
+  mqtt->set_publish_data_hook(hook_publish_data);
 }

 void loop() {
-    reconnect_wifi_if_link_down();
-    mqtt->loop();
+  wifi->loop();
+  mqtt->loop();

-    // ตรวจจับการกด Switch
-    if (digitalRead(0) == LOW) {
-        // วนลูปจนกว่าจะเอาปล่อย Switch
-        while(digitalRead(0) == LOW) {
-            mqtt->loop();
-            yield();
-        }
-        String status = "0";
-        mqtt->sync_pub(status);
+  // ตรวจจับการกด Switch
+  if (digitalRead(0) == LOW) {
+    // วนลูปจนกว่าจะเอาปล่อย Switch
+    while (digitalRead(0) == LOW) {
+      mqtt->loop();
+      yield();
     }
+    String status = "0";
+    mqtt->sync_pub(status);
+  }

 }


chmod

chmod


Changed motor code to help reduce missed pellets

--- fed-arduino/fed-arduino.ino
+++ fed-arduino/fed-arduino.ino
@@ -29,6 +29,7 @@

 int PIStates[] = { 1, 1 };
 int lastStates[] = { 1, 1 };
+bool justMoved[] = { true, true };
 int pelletCount[] = { 0, 0 };

 #define FILENAME "PelletData.csv"
@@ -37,7 +38,7 @@
 File dataFile;

 const int MOTOR_STEPS_PER_REVOLUTION = 513;
-const int STEPS_TO_INCREMENT = 32;
+const int STEPS_TO_INCREMENT = 72; //24
 Adafruit_MotorShield gMotorShield = Adafruit_MotorShield();
 Adafruit_StepperMotor *motor1 = gMotorShield.getStepper(MOTOR_STEPS_PER_REVOLUTION,1);
 Adafruit_StepperMotor *motor2 = gMotorShield.getStepper(MOTOR_STEPS_PER_REVOLUTION,2);
@@ -67,8 +68,8 @@

   //motor shield stuff
   gMotorShield.begin();
-  motor1->setSpeed(12);
-  motor2->setSpeed(2);
+  motor1->setSpeed(30);
+  motor2->setSpeed(30);

   //SD card init stuff
   Wire.begin();
@@ -153,14 +154,19 @@

     logData();
     updateDisplay();
+    justMoved[inputNum] = false;
   }
   else if (PIStates[inputNum] == 1) {
     //need to replace pellet
-    Serial.print(F("Replacing pellet #"));
-    Serial.print(String(inputNum + 1));
-    Serial.println(F("..."));
-    moveMotor(inputNum);
-    delay(500);
+    if (!justMoved[inputNum]) {
+      Serial.print(F("Replacing pellet #"));
+      Serial.print(String(inputNum + 1));
+      Serial.println(F("..."));
+      moveMotor(inputNum);
+      justMoved[inputNum] = true;
+    }
+    else
+    { delay(500); justMoved[inputNum] = false; }
   }

   else if (PIStates[inputNum] == 0 & PIStates[inputNum] != lastStates[inputNum]) {
@@ -168,11 +174,13 @@
     Serial.print(F("Pellet #"));
     Serial.print(String(inputNum + 1));
     Serial.println(F(" replaced"));
+    justMoved[inputNum] = false;
   }

   else  { //if PIStates == 0
     //pellet still there, do nothing
     lastStates[inputNum] = PIStates[inputNum];
+    justMoved[inputNum] = false;
     return false;
   }
   lastStates[inputNum] = PIStates[inputNum];
@@ -181,6 +189,7 @@

 void enterSleep()
 {
+  Serial.println(F("Going to sleep.")); delay(50);
   power_usart0_disable(); //Serial (USART)
   sleep_enable();

@@ -203,6 +212,7 @@
   detachInterrupt(digitalPinToInterrupt(PHOTO_INTERRUPTER_PIN_2));
   sleep_disable(); //disabling sleep
   power_usart0_enable(); //re-enabling serial
+  Serial.println(F("Exiting sleep."));
   delay(300);
 }


Remove the version header as it was causing errors.

When the version header was present, the Arduino would download data, but then
fail because the cache size (the file on the SD) was apparently zero length. I
tried this with other dummy headers, and basically any other header seemed to
screw up the Arduino cache.

Why sending another header would affect the behaviour of the downloading, or
the SD card, I have absolutely no idea :(

I've tried making the requests locally via curl, but the responses are completely identical, even down to a binary diff.

--- printer.ino
+++ printer.ino
@@ -39,7 +39,6 @@

 // -- Everything below here can be left alone

-const char* sketchVersion = "1.0.1";

 // -- Debugging

@@ -179,7 +178,6 @@
     client.print("GET "); client.print("/printer/"); client.print(printerId); client.println(" HTTP/1.0");
     client.print("Host: "); client.print(host); client.print(":"); client.println(port);
     client.print("Accept: application/vnd.freerange.printer."); client.println(printerType);
-    client.print("X-Printer-Version: "); client.println(sketchVersion);
     client.println();
     boolean parsingHeader = true;


BETA 0.5

BETA 0.5

- Add Core.h
- Fix enum declaration

--- Core.ino
+++ Core.ino
@@ -12,20 +12,12 @@
   @license MIT License
   @authors "Filipe Laíns" <filipe.lains@gmail.com>
   @authors "Luís Ferreira" <lsferreira169@gmail.com>
-  @version BETA 0.4 14/11/2016
+  @version BETA 0.5 14/11/2016
 */

 // External Libraries
 #include <FastLED.h>
-
-// Constants
-#define DATA_LED_PIN   13 // D13
-#define RGB_PIN        13 // D13
-#define MOTOR_LEFT     7  // D7 - TODO: Know if it's correct!
-#define MOTOR_RIGHT    4  // D4 - TODO: Know if it's correct!
-#define PX_F 0  // A0 - Front Side
-#define PX_L 1  // A1 - Left Side
-#define NUM_RGB_LEDS   2
+#include "Core.h"

 // Objects
 CRGB rgb_strip[NUM_RGB_LEDS];


Update OpenCTD_master_m0.ino

Update OpenCTD_master_m0.ino

Missing semicolon.

--- OpenCTD_Feather_Adalogger/OpenCTD_master_m0/OpenCTD_master_m0.ino
+++ OpenCTD_Feather_Adalogger/OpenCTD_master_m0/OpenCTD_master_m0.ino
@@ -113,7 +113,7 @@
     dataFile.close();

   } else {
-    Serial.println("Err: Can't open datalog!")
+    Serial.println("Err: Can't open datalog!");
   }

   //Initialize real-time clock


Revert "no timer version"

Revert "no timer version"

This reverts commit 6aa9e6ca4c24f804f4ef50f9f95500a6c012e708.

--- arduino_pico/arduino_pico.ino
+++ arduino_pico/arduino_pico.ino
@@ -1,8 +1,9 @@
 #include "OneWire.h"
 #include "DallasTemperature.h"
+#include "TimerOne.h"

 // Data wire is plugged into port 2 on the Arduino
-#define ONE_WIRE_BUS A0
+#define ONE_WIRE_BUS 7
 #define TEMPERATURE_PRECISION 12

 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
@@ -49,8 +50,9 @@
   sensors.setResolution(pipeThermometer, TEMPERATURE_PRECISION);
   sensors.setResolution(boilThermometer, TEMPERATURE_PRECISION);

-  sensors.setWaitForConversion(true);
-
+  Timer1.initialize(10000000); // set a timer of length 20000 microseconds (or 0.02 sec - or 50Hz => frequency of electricity in europe)
+  Timer1.attachInterrupt( timerIsr ); // attach the service routine here
+
 }

 // function to print a device address
@@ -92,7 +94,8 @@
   Serial.println();
 }

-void loop(void){
+void timerIsr()
+{
   // call sensors.requestTemperatures() to issue a global temperature
   // request to all devices on the bus
   Serial.print("Requesting temperatures...");
@@ -103,6 +106,10 @@
   printData(heatThermometer);
   printData(pipeThermometer);
   printData(boilThermometer);
+}
+
+void loop(void){
+

 }


Correct Arduino keypad map

Correct Arduino keypad map

--- Payphone/Arduino/Payphone/Payphone.ino
+++ Payphone/Arduino/Payphone/Payphone.ino
@@ -42,7 +42,7 @@
     {'1','2','3'},
     {'4','5','6'},
     {'7','8','9'},
-    {'#','0','*'}
+    {'*','0','#'}
 };
 byte rowPins[rows] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
 byte colPins[cols] = {10, 9, 8}; //connect to the column pinouts of the keypad


add YunHub.ino, RF12 > SD > emoncms.org

add YunHub.ino, RF12 > SD > emoncms.org

//
// Receive RFM12B packets and log to
// 1) measurement data file = interpreted data, assuming from
Temperature Node
//      --> time stamp, RF12 group ID, node ID, Vcc, T
// 2) raw data file
//      --> time stamp, RF12 group ID, node ID, all data byte received
// 3) send via http to emoncms.org
//
// Blink LED #13 for each package received
//

--- projects/YunHub/YunHub.ino
+++ projects/YunHub/YunHub.ino
@@ -4,12 +4,15 @@
 //      --> time stamp, RF12 group ID, node ID, Vcc, T
 // 2) raw data file
 //      --> time stamp, RF12 group ID, node ID, all data byte received
+// 3) send via http to emoncms.org
 //
 // Blink LED #13 for each package received
 //

 #include <Bridge.h>
+#include <HttpClient.h>
 #include <JeeLib.h>
+#include "mytokens.h"

 // temperature node data structure. Timestamp created locally, at time of receival.
 typedef struct
@@ -25,7 +28,7 @@

 // data logging and time stamping from http://arduino.cc/en/Tutorial/YunDatalogger
 #include <FileIO.h>
-String fileName, dataStr, rawdataStr;
+String fileName, dataStr, rawdataStr, emonapiurl;
 char __fileName_rawdata[43] = "/mnt/sda1/datalogs/YYYY-MM-DD_RF12_raw.dat";  // value as pattern only, to get size right
 char __fileName_data[39] = "/mnt/sda1/datalogs/YYYY-MM-DD_RF12.dat";  // value as pattern only, to get size right

@@ -39,13 +42,15 @@

     Serial.begin(57600);
     Serial.println("***");
-    Serial.println("*** 150105 Yun RF12 Data Logger");
+    Serial.println("*** 150108 YunHub: Log RF12 data and send to emoncms.org account");
     Serial.println("***");
     Serial.println("*** Format:     time stamp, RF12 group ID, node ID, Vcc, T");
     Serial.println("***             time stamp, RF12 group ID, node ID, raw data bytes");
     Serial.println("***");
     Serial.println("*** Logging to  /mnt/sda1/datalogs/YYYY-MM-DD_RF12.dat");
     Serial.println("***             /mnt/sda1/datalogs/YYYY-MM-DD_RF12_raw.dat");
+    Serial.println("***");
+    Serial.println("*** Sending to: http://www.emoncms.org");
     Serial.println("***");

     // initialize digital pin 13 as an output.
@@ -57,8 +62,12 @@

 void loop ()
 {
+
+    HttpClient client;
+
     if (rf12_recvDone() && rf12_crc == 0)
     {
+
         /*
             // debugging only: examine packet byte by byte
             for (byte i = 0; i < rf12_len; ++i) {
@@ -107,7 +116,6 @@
             Serial.println("error opening measurement data log file");
         }

-        //
         // Log raw data to separate file, to prevent data gets lost or misinterpreted
         //
         rawdataStr = dataPackage.timeStamp + ","
@@ -141,6 +149,19 @@
             Serial.println("error opening raw data log file");
         }

+        // send data for to emoncms.org: node id, T, Vcc
+        emonapiurl = "http://emoncms.org/input/post.json?apikey="
+                     + EMONCMS_APIKEY
+                     + "&node="
+                     + String(dataPackage.rf12_nodeid)
+                     + "&csv="
+                     + String(dataPackage.T)
+                     + ","
+                     + String(dataPackage.Vcc);
+
+        client.get(emonapiurl);
+
+        //
     }
     digitalWrite(13, LOW);   // turn the LED off (HIGH is the voltage level)
 }


Make the filters look in what I believe is the direction of the ABS button

--- Sniff_Arduino_Terminal/Sniff_to_arduino_serial/Sniff_to_arduino_serial.ino
+++ Sniff_Arduino_Terminal/Sniff_to_arduino_serial/Sniff_to_arduino_serial.ino
@@ -16,18 +16,26 @@
     }

     Serial.println("Starting to initialize CAN");
-
+
     //Set filter masks
     CAN.init_Mask(0, 0, 0xfff);
     CAN.init_Mask(1, 0, 0xfff);

     //Set filters
+    // Look for button presses
+    CAN.init_Filt(0, 0, 0x2D0); // ZFE
+    CAN.init_Filt(1, 0, 0x294); // ABS
+    CAN.init_Filt(2, 0, 0x130); // ZFE 2
+    /*
     CAN.init_Filt(0, 0, 0x10C);
     CAN.init_Filt(1, 0, 0x130);
     CAN.init_Filt(2, 0, 0x294);
     CAN.init_Filt(3, 0, 0x2BC);
     CAN.init_Filt(4, 0, 0x2D0);
     CAN.init_Filt(5, 0, 0x3F8);
+    CAN.init_Filt(6, 0, 0x2A8);
+    CAN.init_Filt(7, 0, 0x3FF);
+    */
     Serial.println("CAN Initialized");
 }


WDRC_8Band_Full.ino: change sketch name displayed in Serial Monitor

--- examples/05-FullSystems/WDRC_8BandFIR_full/WDRC_8BandFIR_full.ino
+++ examples/05-FullSystems/WDRC_8BandFIR_full/WDRC_8BandFIR_full.ino
@@ -111,7 +111,7 @@
 void setup() {
   myTympan.beginBothSerial();
   if (Serial) Serial.print(CrashReport);
-  Serial.println("WDRC_FIRbank_Compbank: setup():...");
+  Serial.println("WDRC_8Band_Full: setup():...");
   Serial.print("Sample Rate (Hz): "); Serial.println(audio_settings.sample_rate_Hz);
   Serial.print("Audio Block Size (samples): "); Serial.println(audio_settings.audio_block_samples);


Pellet counting reliability tweaks

Pellet counting reliability tweaks

--- fed-arduino/fed-arduino.ino
+++ fed-arduino/fed-arduino.ino
@@ -31,6 +31,8 @@
 int lastStates[] = { 1, 1 };
 int lastTime[] = { 0, 0 };
 int pelletCount[] = { 0, 0 };
+bool pelletCounted[] = { false, false };
+bool countMe[] = { false, false };

 #define FILENAME "PelletData.csv"
 const int CS_pin = 10;
@@ -145,18 +147,26 @@

   if (PIStates[inputNum] == 1  & PIStates[inputNum] != lastStates[inputNum]) {
     //pellet taken
-    pelletCount[inputNum]++;
-    Serial.println(F("Pellet taken"));
-    Serial.print(F("Pellets of type #"));
-    Serial.print(String(inputNum + 1));
-    Serial.print(F(" taken: "));
-    Serial.println(String(pelletCount[inputNum]));
-
-    logData();
-    updateDisplay();
-    lastTime[inputNum] = 0;
+    if (!pelletCounted[inputNum])
+    {
+      countMe[inputNum] = true;
+      pelletCounted[inputNum] = true;
+    }
   }
   else if (PIStates[inputNum] == 1) {
+    if (countMe[inputNum] && lastTime[inputNum] >= 8) {
+      pelletCount[inputNum]++;
+      Serial.println(F("Pellet taken"));
+      Serial.print(F("Pellets of type #"));
+      Serial.print(String(inputNum + 1));
+      Serial.print(F(" taken: "));
+      Serial.println(String(pelletCount[inputNum]));
+
+      logData();
+      updateDisplay();
+      lastTime[inputNum] = 0;
+      countMe[inputNum] = false;
+    }
     //need to replace pellet
     if (lastTime[inputNum] >= 8) {
       Serial.print(F("Replacing pellet #"));
@@ -164,6 +174,7 @@
       Serial.println(F("..."));
       moveMotor(inputNum);
       lastTime[inputNum] = 6;
+      pelletCounted[inputNum] = false;
       delay(200);
     }
     else


minor change to ble_my_project_template

minor change to ble_my_project_template

--- libraries/BLE/examples/ble_my_project_template/ble_my_project_template.ino
+++ libraries/BLE/examples/ble_my_project_template/ble_my_project_template.ino
@@ -175,7 +175,7 @@
               Serial.println(F("Evt Device Started: Standby"));
               if (aci_evt->params.device_started.hw_error)
               {
-                //do nothing, wait for the HW-error.
+                delay(20); //Magic number used to make sure the HW error event is handled correctly.
               }
               else
               {


Got the 1 bit reader working with Raspberry Pi

--- ReadSensors/ReadSensors.ino
+++ ReadSensors/ReadSensors.ino
@@ -13,7 +13,8 @@

 #define TX 1         // pin 6
 #define RX 3         // not used, pin 2
-#define BAUD 9600
+#define BAUD 1200
+#define PAD() delay(2)

 #define REG      3   // pin 2
 #define D7       4   // pin 3
@@ -28,6 +29,7 @@

 #if defined(__AVR_ATmega32U4__)
 #define BAUD 115200
+#define PAD()

 // Pinouts for Sparkfun ProMicro:
 // https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro
@@ -160,11 +162,17 @@
   delay(500);
   digitalWrite(LED_D7, LOW);

-  sendCardReport(REPORT_OK_BOOT, NULL, 0);
-}
-
-
-//------------------------------------------------------------------------------------------------
+  //sendCardReport(REPORT_OK_BOOT, NULL, 0);
+}
+
+
+//------------------------------------------------------------------------------------------------
+
+void loopz()
+{
+  serport.write('*');
+  delay(100);
+}

 void loop()
 {
@@ -322,6 +330,7 @@
 void sendCardReport(byte type, byte* pData, byte len)
 {
   serport.write(":"); // Start char
+  PAD();
   sendHexByte(type); // mandatory type

   // Show optional data of any length
@@ -338,7 +347,9 @@
 void sendHexByte(byte val)
 {
   serport.write(tohexch(val>>4)); // high nybble
+  PAD();
   serport.write(tohexch(val));    // low nybble
+  PAD();
 }


adapt examples for String return type from SSID

--- libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino
+++ libraries/DNSServer/examples/CaptivePortalAdvanced/handleHttp.ino
@@ -73,7 +73,7 @@
   Serial.println("scan done");
   if (n > 0) {
     for (int i = 0; i < n; i++) {
-      server.sendContent(String() + "\r\n
SSID " + String(WiFi.SSID(i)) + String((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":" *") + " (" + WiFi.RSSI(i) + ")
");
+      server.sendContent(String() + "\r\n
SSID " + WiFi.SSID(i) + String((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":" *") + " (" + WiFi.RSSI(i) + ")
");
     }
   } else {
     server.sendContent(String() + "
No WLAN found
");


Revert "Update RetroWatchArduino.ino"

Revert "Update RetroWatchArduino.ino"

This reverts commit a65dbdff976df8135f83ca44193c7c93fdc2c995.

--- RetroWatch_Arduino/RetroWatchArduino/RetroWatchArduino.ino
+++ RetroWatch_Arduino/RetroWatchArduino/RetroWatchArduino.ino
@@ -37,10 +37,10 @@
 ///////////////////////////////////////////////////////////////////
 //----- OLED instance
 #define OLED_RESET 9
-Adafruit_SSD1331 display(OLED_RESET);
-
-#if (SSD1331_LCDHEIGHT != 64)
-#error("Height incorrect, please fix Adafruit_SSD1331.h!");
+Adafruit_SSD1306 display(OLED_RESET);
+
+#if (SSD1306_LCDHEIGHT != 64)
+#error("Height incorrect, please fix Adafruit_SSD1306.h!");
 #endif
 ///////////////////////////////////////////////////////////////////

@@ -165,7 +165,7 @@
   init_msg_array();

   //----- by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
-  display.begin(SSD1331_SWITCHCAPVCC, 0x3c);  // initialize with the I2C addr 0x3D (for the 128x64)
+  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);  // initialize with the I2C addr 0x3D (for the 128x64)
   display.display();    // show splashscreen
   delay(1000);
   drawStartUp();    // Show RetroWatch Logo


Compatibility with older arduino compilers.

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@17281 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/zimodem.ino
+++ zimodem/zimodem.ino
@@ -63,7 +63,7 @@
 # define UART_NB_STOP_BIT_15   0B00100000
 # define UART_NB_STOP_BIT_2    0B00110000
 # define preEOLN serial.prints
-# define echoEOLN(...) serial.write(...)
+# define echoEOLN serial.write
 #else  // ESP-8266, e.g. ESP-01, ESP-12E, inverted for C64Net WiFi Modem
 # define DEFAULT_PIN_DSR 13
 # define DEFAULT_PIN_DTR 12


one Interrupt

one Interrupt

--- _08_hc-sr04/_08_hc-sr04.ino
+++ _08_hc-sr04/_08_hc-sr04.ino
@@ -1,12 +1,10 @@
 #include <Average.h>

-#define Trig_pin 4
+#define Trig_pin 11

-volatile unsigned long echoBufferx[2];
-volatile unsigned long echoBuffery[2];
+volatile unsigned long echoBuffer[2];

 volatile unsigned int x = 0;
-volatile unsigned int y = 0;

 Average<float> ave(5);

@@ -14,24 +12,19 @@
   Serial.begin (38400);
   pinMode(Trig_pin, OUTPUT);
   pinMode(2, INPUT_PULLUP);
-  pinMode(3, INPUT_PULLUP);
 }

 long check_distance() {
-
+
   x = 0 ;
-  y = 0 ;

-  int distancex = 0;
-  int distancey = 0;
+  int distance = 0;

   for ( int i = 0 ; i < 2 ; i++ ) {
-    echoBufferx[i] = 0;
-    echoBuffery[i] = 0;
+    echoBuffer[i] = 0;
   }

-  attachInterrupt(0, echo1_Interrupt_Handler, CHANGE);
-  attachInterrupt(1, echo2_Interrupt_Handler, CHANGE);
+  attachInterrupt(0, echo_Interrupt_Handler, CHANGE);

   delay(200);

@@ -41,29 +34,18 @@
   delayMicroseconds(10);
   digitalWrite(Trig_pin, LOW);

-  delay(300);
+  delay(500);

-  if ( echoBufferx[1] > echoBufferx[0]   ) {
-    distancex = ( echoBufferx[1] - echoBufferx[0] ) / 29 / 2 ;
+  if ( echoBuffer[1] > echoBuffer[0]   ) {
+    distance = ( echoBuffer[1] - echoBuffer[0] ) / 29 / 2 ;
   } else {
-    distancex = 1000 ;
-  }
-
-  if ( echoBuffery[1] > echoBuffery[0]  ) {
-     distancey = ( echoBuffery[1] - echoBuffery[0] ) / 29 / 2 ;
-  } else {
-    distancey = 1000;
+    distance = 1000 ;
   }

   detachInterrupt(0);
-  detachInterrupt(1);

-  if ( distancex >= distancey ) {
-    return distancey;
-  } else {
-    return distancex;
-  }
-
+  return distance;
+
 }

 void loop() {
@@ -82,10 +64,6 @@
 }

-void echo1_Interrupt_Handler() {
-  echoBufferx[x++] = micros();
+void echo_Interrupt_Handler() {
+  echoBuffer[x++] = micros();
 }
-
-void echo2_Interrupt_Handler() {
-  echoBuffery[y++] = micros();
-}


Update src.ino

Update src.ino

--- src/src.ino
+++ src/src.ino
@@ -1,8 +1,5 @@
 #include <DynamixelProtocol.h>
 #include <AS5048A.h>
-
-//TODO check if serial of maple core is in the correct pins
-//HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);

 #define SEA_ID 105
 #define INVERTED


Don't call normal handler code if both banks are down

--- ableton-midi-foot-controller.ino
+++ ableton-midi-foot-controller.ino
@@ -194,6 +194,10 @@
     return;
   }

+  if (bothBanksDown) {
+    return;
+  }
+
   switch (mode) {
     case normalMode:
       handleNormalMode();
@@ -214,7 +218,7 @@
   boolean update = false;
   if (bankDownButton.isJustReleased()) {
     initBank--;
-    if(initBank == 255) {
+    if (initBank == 255) {
       initBank = 126;
     }
     update = true;
@@ -223,7 +227,7 @@
     initBank = initBank % 127;
     update = true;
   }
-  if (update) {
+  if (update) {
     Serial.print("MIDI offset ");
     Serial.println(initBank);
   }


Update ArduCAM_Mini_2MP_Plus_short_movie_clip.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino
@@ -85,11 +85,16 @@

 // set the CS as an output:
 pinMode(CS, OUTPUT);
+digitalWrite(CS, HIGH);
 pinMode(SD_CS, OUTPUT);
 pinMode(KEY, INPUT);
 // initialize SPI:
 SPI.begin();
-
+  //Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
 while(1){
   //Check if the ArduCAM SPI bus is OK
   myCAM.write_reg(ARDUCHIP_TEST1, 0x55);


some testing

some testing

--- examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino
+++ examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino
@@ -11,17 +11,50 @@
 char ssid[] = "*************";  //  your network SSID (name)
 char pass[] = "********";       // your network password

+void debugchipid(){
+  // WiFi.mode(WIFI_STA);
+  // WiFi.printDiag(Serial);
+  // Serial.println(modes[WiFi.getMode()]);
+
+  // ESP.eraseConfig();
+  // wm.resetSettings();
+  // wm.erase(true);
+  WiFi.mode(WIFI_AP);
+  // WiFi.softAP();
+  WiFi.enableAP(true);
+  delay(500);
+  // esp_wifi_start();
+  delay(1000);
+  WiFi.printDiag(Serial);
+  delay(60000);
+  ESP.restart();
+
+  // AP esp_267751
+  // 507726A4AE30
+  // ESP32 Chip ID = 507726A4AE30
+}
+
+void saveCallback(){
+  Serial.println("saveCallback fired");
+}
+
+
+//gets called when WiFiManager enters configuration mode
+void configModeCallback (WiFiManager *myWiFiManager) {
+  Serial.println("configModeCallback fired");
+  // myWiFiManager->setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
+  // Serial.println(WiFi.softAPIP());
+  //if you used auto generated SSID, print it
+  // Serial.println(myWiFiManager->getConfigPortalSSID());
+}

 void setup() {
   // put your setup code here, to run once:
   Serial.begin(115200);
   Serial.setDebugOutput(true);
-  delay(3000);
+  // delay(3000);
   Serial.println("\n Starting");

-  // WiFi.mode(WIFI_STA);
-  // WiFi.printDiag(Serial);
-  // Serial.println(modes[WiFi.getMode()]);
   //WiFiManager
   //Local intialization. Once its business is done, there is no need to keep it around
   // WiFiManager wm;
@@ -31,14 +64,16 @@
   //Local intialization. Once its business is done, there is no need to keep it around
   //reset settings - for testing
   // wm.resetSettings();
-  //
+  // wm.erase();
+
   wm.setClass("invert");
+  wm.setAPCallback(configModeCallback);

   //sets timeout until configuration portal gets turned off
   //useful to make it all retry or go to sleep
   //in seconds
   // wm.setConfigPortalTimeout(600);
-  wm.setConnectTimeout(10);
+  // wm.setConnectTimeout(5);
   // wm.setShowStaticFields(true);

   // uint8_t menu[] = {wm.MENU_WIFI,wm.MENU_INFO,wm.MENU_PARAM,wm.MENU_CLOSE};
@@ -56,6 +91,9 @@
   WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6);
   WiFiManagerParameter custom_token("api_token", "api token", "", 16);
   WiFiManagerParameter custom_tokenb("invalid token", "invalid token", "", 0);
+
+  // callbacks
+  wm.setSaveConfigCallback(saveCallback);

   //add all your parameters here
   wm.addParameter(&custom_html);
@@ -83,10 +121,14 @@
   std::vector<const char *> menu = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"};
   wm.setMenu(menu);

-  //set static ip
+  // set static sta ip
   // wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
   // wm.setShowStaticFields(false);
   // wm.setShowDnsFields(false);
+
+  // set static ip
+  // wm.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
+  // wm.setAPStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));

   // WiFi.mode(WIFI_STA);
   // const wifi_country_t COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO};
@@ -116,18 +158,17 @@
   pinMode(TRIGGER_PIN, INPUT);
 }

-
 void loop() {
   // is configuration portal requested?
   if ( digitalRead(TRIGGER_PIN) == LOW ) {
+    Serial.println("BUTTON PRESSED");
     //WiFiManager
     //Local intialization. Once its business is done, there is no need to keep it around
     //reset settings - for testing
     //wm.resetSettings();

     //sets timeout until configuration portal gets turned off
-    //useful to make it all retry or go to sleep
-    //in seconds
+    //useful to make it all retry or go to sleep, in seconds
     wm.setConfigPortalTimeout(120);

     //it starts an access point with the specified name
@@ -150,5 +191,5 @@
   }

   // put your main code here, to run repeatedly:
-  delay(10000);
+  delay(5000);
 }


dev example country and bounce

dev example country and bounce

--- examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino
+++ examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino
@@ -1,5 +1,7 @@
 /**
  * This is a kind of unit test for DEV for now
+ * It contains many of the public methods
+ *
  */
 #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
 #include <time.h>
@@ -167,14 +169,13 @@
   // wm.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
   // wm.setAPStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));

-  // WiFi.mode(WIFI_STA);
-  // const wifi_country_t COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO};
-  // const wifi_country_t COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO};
-  // const wifi_country_t COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO};
-  // esp_wifi_set_country(&COUNTRY_US);
-
-  // wm.setCountry("US");
-
+  // set country
+  wm.setCountry("US"); // setting wifi country seems to improve OSX soft ap connectivity, may help others as well
+
+  // set channel
+  wm.setWiFiAPChannel(13);
+
+  // set configrportal timeout
   wm.setConfigPortalTimeout(120);
   // wm.startConfigPortal("AutoConnectAP", "password");

@@ -189,6 +190,8 @@
     print_oled("Not Connected",2);
   }
   else if(TEST_CP) {
+    delay(1000);
+    Serial.println("TEST_CP ENABLED");
     // start configportal always
     wm.setConfigPortalTimeout(60);
     wm.startConfigPortal();
@@ -204,17 +207,20 @@
 void loop() {
   // is configuration portal requested?
   if ( digitalRead(TRIGGER_PIN) == LOW ) {
-    Serial.println("BUTTON PRESSED");
-    wm.setConfigPortalTimeout(140);
-    wm.setWiFiAPChannel(13);
-
-    // disable captive portal redirection
-    // wm.setCaptivePortalEnable(false);
-
-    if (!wm.startConfigPortal("OnDemandAP","12345678")) {
-      Serial.println("failed to connect and hit timeout");
-      delay(3000);
-    } else {
+    delay(100);
+    if ( digitalRead(TRIGGER_PIN) == LOW ){
+      Serial.println("BUTTON PRESSED");
+      wm.setConfigPortalTimeout(140);
+
+      // disable captive portal redirection
+      // wm.setCaptivePortalEnable(false);
+
+      if (!wm.startConfigPortal("OnDemandAP","12345678")) {
+        Serial.println("failed to connect and hit timeout");
+        delay(3000);
+      }
+    }
+    else {
       //if you get here you have connected to the WiFi
       Serial.println("connected...yeey :)");
       print_oled("Connected\nIP: " + WiFi.localIP().toString() + "\nSSID: " + WiFi.SSID(),1);


fixed example with lat lng

fixed example with lat lng

--- examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
+++ examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
@@ -34,7 +34,7 @@
   float value_3 = analogRead(A2);

   // To send geolocation of the variable put it like this:
-  client.add(VARIABLE_NAME_ONE, value_1, "lat:9.92323$lng:1.12323");
+  client.add(VARIABLE_NAME_ONE, value_1, "lat=9.92323$lng=1.12323");
   // lng is longitude, and lat is latitude, split it with "$"
   client.add(VARIABLE_NAME_TWO, value_2);
   client.add(VARIABLE_NAME_THREE, value_3);


update network_uplink

update network_uplink

--- exemples/arduino/network_uplink/network_uplink.ino
+++ exemples/arduino/network_uplink/network_uplink.ino
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 // This file is a example for use the library armapi with
-// ARM NANO (NANO_LP with sigfox) on arduino board.
+// ARM NANO (NANO_LP with sigfox and NANO_LW) on arduino board.
 //
 // This software send periodically 'Hello world' to Sigfox network or
 // Lora network. The choice of the network is automatically choose by


Removed old sketch

Removed old sketch

--- magbot_test/magbot_test.ino
+++ magbot_test/magbot_test.ino
@@ -1,168 +0,0 @@
-/**
- HC-SR04 Ultrasonic Range Finder.
- Two motors attached to the motor shield.
- speaker/piezo for sound
-
- Arduino Uno has three timers; timer 0, timer 1, timer 2,
- Timer 0 is used by the arduino for millis().
- The motorsheild uses timer 2, for pwm on pins 3 & 11.
- Since the standard arduino tone function uses timer 2 also,
- we have to use a different library "NewTone" this uses timer 1 instead
- which means no pwm on pins 10 & 9. it also means it is incompatable with the
- standard servo library.
- So we have pwm left on pins 5 & 6 to put some leds on.
-
-
- */
-
-#include <util/delay.h>
-#include <NewPing.h> // From https://code.google.com/p/arduino-new-ping/
-#include <NewTone.h> // From https://code.google.com/p/arduino-new-tone/
-
-// Motor attached to channel A:
-const byte motorA_direction = 12;
-const byte motorA_pwm = 3;
-const byte motorA_brake = 9;
-const byte motorA_sensor = A0;
-// Motor attached to channel B:
-const byte motorB_direction = 13;
-const byte motorB_pwm = 11;
-const byte motorB_brake = 8;
-const byte motorB_sensor = A1;
-
-// Sonar configuration
-const byte sonar_trigger = 7;  // Arduino pin tied to trigger pin on the ultrasonic sensor.
-const byte sonar_echo = 4;  // Arduino pin tied to echo pin on the ultrasonic sensor.
-const int sonar_distance = 80; // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
-const byte sonar_delay = 50; // Number of milliseconds to wait before next ping
-unsigned long sonar_last = 0; // When the last ping happened.
-NewPing sonar(sonar_trigger, sonar_echo, sonar_distance); // NewPing setup of pins and maximum distance.
-
-// Tone configuration
-const byte tone_pin = 2;
-unsigned long melody_delay = 10000; // Number of milliseconds to wait before next melody
-unsigned long melody_last = 0; // When the last melody played.
-// Melody (liberated from the toneMelody Arduino example sketch by Tom Igoe).
-int melody[] = { 262, 196, 196, 220, 196, 0, 247, 262 };
-int noteDurations[] = { 4, 8, 8, 4, 4, 4, 4, 4 };
-
-// Led configuration
-const byte led_battery = 5;
-
-unsigned long millis_now;
-
-void setup() {
-  Serial.begin(9600); // Open serial monitor at 9600 baud to see ping results.
-
-
-  // Setup Channel A
-  pinMode(motorA_direction, OUTPUT); // Initiates motor pin for channel A
-  pinMode(motorA_brake, OUTPUT); // Initiates break pin for channel A
-
-  // Setup Channel B
-  pinMode(motorB_direction, OUTPUT); // Initiates motor pin for channel B
-  pinMode(motorB_brake, OUTPUT);  // Initiates break pin for channel B
-
-  // Ensure the brakes are off
-  digitalWrite(motorA_brake, LOW);   // Disengage the Brake for Channel A
-  digitalWrite(motorB_brake, LOW);   // Disengage the Brake for Channel B
-
-
-  batteryLevel();
-
-  // Turn in place constantly.
-  digitalWrite(motorA_direction, HIGH); // Channel A forward
-  digitalWrite(motorB_direction, LOW); // Channel B backward
-  analogWrite(motorA_pwm, 255); // Channel A at max speed
-  analogWrite(motorB_pwm, 255); // Channel B at max speed
-
-  playMelody();
-}
-
-void loop() {
-  millis_now = millis();
-
-  // Check to see if it's time for another ping.
-  if (millis_now - sonar_last > sonar_delay) {
-    // Remeber when this ping was done, so we know when to do the next one.
-    sonar_last = millis_now;
-
-    unsigned int cm = sonar.ping_cm(); // Send a ping, get ping time in microseconds (uS).
-    //Serial.print("Ping: ");
-    //Serial.print(cm);
-    //Serial.println("cm");
-  }
-
-  // Check to see if it's time for another melody.
-  if (millis_now - melody_last > melody_delay) {
-    // Remeber when this ping was done, so we know when to do the next one.
-    melody_last = millis_now;
-    playMelody();
-
-    batteryLevel();
-  }
-
-}
-
-void playMelody()
-{
-  // iterate over the notes of the melody:
-  for (int thisNote = 0; thisNote < 8; thisNote++) {
-
-    // to calculate the note duration, take one second
-    // divided by the note type.
-    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
-    int noteDuration = 1000/noteDurations[thisNote];
-    NewTone(tone_pin, melody[thisNote],noteDuration);
-
-    // to distinguish the notes, set a minimum time between them.
-    // the note's duration + 30% seems to work well:
-    int pauseBetweenNotes = noteDuration * 1.30;
-    delay(pauseBetweenNotes);
-    // stop the tone playing:
-    noNewTone(tone_pin);
-  }
-}
-
-void batteryLevel()
-{
-  // Check battery level
-  long vcc = readVcc();
-  byte batt = map(vcc, 2500, 5500, 0, 255);
-  analogWrite(led_battery, batt);
-  Serial.print("Battery: ");
-  Serial.print(vcc);
-  Serial.print(" : ");
-  Serial.println(batt);
-}
-
-/**
- * Read the internal voltage.
- */
-long readVcc()
-{
-  // Read 1.1V reference against AVcc
-  // set the reference to Vcc and the measurement to the internal 1.1V reference
-  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
-  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
-    ADMUX = _BV(MUX5) | _BV(MUX0);
-  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
-    ADMUX = _BV(MUX3) | _BV(MUX2);
-  #else
-    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
-  #endif
-
-  _delay_ms(2); // Wait for Vref to settle
-  ADCSRA |= _BV(ADSC); // Start conversion
-  while (bit_is_set(ADCSRA,ADSC)); // measuring
-
-  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
-  uint8_t high = ADCH; // unlocks both
-
-  long result = (high<<8) | low;
-
-  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
-  return result; // Vcc in millivolts
-}
-


Saving

Saving

--- examples/DefaultBoard/DefaultBoard.ino
+++ examples/DefaultBoard/DefaultBoard.ino
@@ -87,6 +87,7 @@

   if (!wifi.sentGains) {
     if(wifi.present && wifi.tx) {
+      Serial0.println("Synced with Wifi$$$");
       wifi.sendGains(board.numChannels, board.getGains());
     }
   }


fix example error message

fix example error message

--- examples/IRrecvDumpV2/IRrecvDumpV2.ino
+++ examples/IRrecvDumpV2/IRrecvDumpV2.ino
@@ -66,7 +66,7 @@
 {
   // Check if the buffer overflowed
   if (results->overflow) {
-    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN");
+    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
     return;
   }


Update E00_KY-040_RotaryEncoder.ino

Update E00_KY-040_RotaryEncoder.ino

--- RotaryEncoder/examples/E00_KY-040_RotaryEncoder/E00_KY-040_RotaryEncoder.ino
+++ RotaryEncoder/examples/E00_KY-040_RotaryEncoder/E00_KY-040_RotaryEncoder.ino
@@ -45,9 +45,9 @@

 #if ARDUINO >= 100
 #include "Arduino.h"
-#else
+#else  /* !ARDUINO */
 #include "WProgram.h"
-#endif
+#endif /* end !ARDUINO */

 // This implementation based on
 // "Another Interrupt Library THAT REALLY WORKS" by rafbuff


fix LED as it is in reverse logic

fix LED as it is in reverse logic

--- examples/SONOFF/SONOFF.ino
+++ examples/SONOFF/SONOFF.ino
@@ -153,7 +153,7 @@
           Serial.println("RELAY STATE ON received");
           currentRelayState= RELAY_STATE_ON;

-          digitalWrite(LED, HIGH);
+          digitalWrite(LED, LOW);
           digitalWrite(RELAY, HIGH);
           char tmpChar = RELAY_STATE_ON;
           myMqtt->publishValue("state", &tmpChar);
@@ -162,7 +162,7 @@
         Serial.println("RELAY STATE OFF received");
           currentRelayState= RELAY_STATE_OFF;

-          digitalWrite(LED, LOW);
+          digitalWrite(LED, HIGH);
           digitalWrite(RELAY, LOW);
           char tmpChar = RELAY_STATE_OFF;
           myMqtt->publishValue("state", &tmpChar);


Remove compiler warning on macro redefinition.

--- examples/LCD/CosaLCDspeed/CosaLCDspeed.ino
+++ examples/LCD/CosaLCDspeed/CosaLCDspeed.ino
@@ -77,6 +77,7 @@

 // Measurement support
 void measure(str_P name, benchmark_t fn, uint16_t nr);
+#undef MEASURE
 #define MEASURE(fn,nr) measure(PSTR(#fn),fn,nr)

 void setup()


removed whitespaces in the end of the sketch

--- examples/basic_bt_movement/basic_bt_movement.ino
+++ examples/basic_bt_movement/basic_bt_movement.ino
@@ -50,9 +50,3 @@
     }
   }
 }
-
-
-
-
-
-


Update ready_to_localize.ino

Update ready_to_localize.ino

--- examples/ready_to_localize/ready_to_localize.ino
+++ examples/ready_to_localize/ready_to_localize.ino
@@ -66,19 +66,7 @@

 void printCoordinates(coordinates_t coor){

-  i++;
-
-  Serial.print("pos(");
-  Serial.print(i);
-  Serial.print(") = [");
-  Serial.print(coor.x);
-  Serial.print(" ");
-  Serial.print(coor.y);
-  Serial.print(" ");
-  Serial.print(coor.z);
-  Serial.print("];");
-
-  /*Serial.print("x_mm: ");
+  Serial.print("x_mm: ");
   Serial.print(coor.x);
   Serial.print("\t");
   Serial.print("y_mm: ");
@@ -87,13 +75,6 @@
   Serial.print("z_mm: ");
   Serial.print(coor.z);
   Serial.println();
-  */
-  /*
-  Serial.print("pos;");
-  Serial.print(coor.y + 500);
-  Serial.print(";");
-  Serial.println(coor.x + 500);
-  */
 }

 void printCalibrationResult(){


add example URL to FadeColor

add example URL to FadeColor

--- examples-ltc/4.RainbowTape/5_FadeColor/FadeColor.ino
+++ examples-ltc/4.RainbowTape/5_FadeColor/FadeColor.ino
@@ -3,6 +3,7 @@
 // Rainbow tape "Fade Color" demo.

 // This simple demo enables you to fade a pixel between two colors
+// Example at https://www.instagram.com/p/BVjnnc-AcSA/

 // select colors codes using the "Rainbow Gadget".
 // or use any color from https://github.com/chibitronics/ltc-compiler-layer/blob/master/support/html_colors.h


work on skyview and solution for Mike's RV4 testing.

--- AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
+++ AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
@@ -45,20 +45,39 @@
 #define DYNON_SERIAL_LEN              53
 #define DYNON_SKYVIEW_SERIAL_LEN      74

-// AOA values & Tone Pulse Per Sec (PPS)
-#define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
-#define HIGH_TONE_AOA_STALL   90      // % (and above) where stall happens.
-#define HIGH_TONE_AOA_START   70      // % (and above) where high tone starts
-#define HIGH_TONE_PPS_MAX     6.5     // 6.5
-#define HIGH_TONE_PPS_MIN     1.5     // 1.5
-#define HIGH_TONE_HZ          1600    // freq of high tone
-//#define HIGH_TONE2_HZ         1500    // a 2nd high tone that it will cycle between (if defined)
-
-#define LOW_TONE_AOA_SOLID    60      // % (and above) where a solid low tone is played.
-#define LOW_TONE_AOA_START    20      // % (and above) where low
-#define LOW_TONE_PPS_MAX      8.5
-#define LOW_TONE_PPS_MIN      1.5
-#define LOW_TONE_HZ           400     // freq of low tone
+#define MIKE_SETUP            // if this is defined then use settings for his RV4 (dynon D10)
+
+#ifdef MIKE_SETUP
+  // AOA values & Tone Pulse Per Sec (PPS)
+  #define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
+  #define HIGH_TONE_AOA_STALL   80      // % (and above) where stall happens.
+  #define HIGH_TONE_AOA_START   60      // % (and above) where high tone starts
+  #define HIGH_TONE_PPS_MAX     6.5     // 6.5
+  #define HIGH_TONE_PPS_MIN     1.5     // 1.5
+  #define HIGH_TONE_HZ          1600    // freq of high tone
+  //#define HIGH_TONE2_HZ         1500    // a 2nd high tone that it will cycle between (if defined)
+  #define LOW_TONE_AOA_SOLID    50      // % (and above) where a solid low tone is played.
+  #define LOW_TONE_AOA_START    20      // % (and above) where low
+  #define LOW_TONE_PPS_MAX      8.5
+  #define LOW_TONE_PPS_MIN      1.5
+  #define LOW_TONE_HZ           400     // freq of low tone
+#else
+  // AOA values & Tone Pulse Per Sec (PPS)
+  #define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
+  #define HIGH_TONE_AOA_STALL   90      // % (and above) where stall happens.
+  #define HIGH_TONE_AOA_START   70      // % (and above) where high tone starts
+  #define HIGH_TONE_PPS_MAX     6.5     // 6.5
+  #define HIGH_TONE_PPS_MIN     1.5     // 1.5
+  #define HIGH_TONE_HZ          1600    // freq of high tone
+  //#define HIGH_TONE2_HZ         1500    // a 2nd high tone that it will cycle between (if defined)
+  #define LOW_TONE_AOA_SOLID    60      // % (and above) where a solid low tone is played.
+  #define LOW_TONE_AOA_START    20      // % (and above) where low
+  #define LOW_TONE_PPS_MAX      8.5
+  #define LOW_TONE_PPS_MIN      1.5
+  #define LOW_TONE_HZ           400     // freq of low tone
+#endif
+
+

 #define TONE_PIN              2     // TIOA0
 #define PIN_LED1              13    // internal LED for showing AOA status.
@@ -189,8 +208,8 @@
   if(ASI <= MUTE_AUDIO_UNDER_IAS) {
 #ifdef SHOW_SERIAL_DEBUG
   // show audio muted and debug info.
-  sprintf(tempBuf, "AUDIO MUTED: Airspeed to low. Min:%i ASI:%i",MUTE_AUDIO_UNDER_IAS, ASI);
-  Serial.println(tempBuf);
+  //sprintf(tempBuf, "AUDIO MUTED: Airspeed to low. Min:%i ASI:%i",MUTE_AUDIO_UNDER_IAS, ASI);
+  //Serial.println(tempBuf);
   toneMode = TONE_OFF;
   return;
 #endif
@@ -209,7 +228,7 @@
   } else if(AOA >= HIGH_TONE_AOA_START) {
     // play HIGH tone at Pulse Rate 1.5 PPS to 6.2 PPS (depending on AOA value)
     highTone = true;
-    OldValue = AOA-69;
+    OldValue = AOA-(HIGH_TONE_AOA_START-1);
     toneMode = PULSE_TONE;
     // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
     OldRange = 20 - 1;  //(OldMax - OldMin)
@@ -225,7 +244,7 @@
     highTone = false;
     // play LOW tone at Pulse Rate 1.5 PPS to 8.2 PPS (depending on AOA value)
     // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
-    OldValue = AOA-20;
+    OldValue = AOA-LOW_TONE_AOA_START;
     OldRange = 40 - 1;  //(OldMax - OldMin)
     NewRange = LOW_TONE_PPS_MAX - LOW_TONE_PPS_MIN; // (NewMax - NewMin)
     NewValue = (((OldValue - 1) * NewRange) / OldRange) + LOW_TONE_PPS_MAX; //(((OldValue - OldMin) * NewRange) / OldRange) + NewMin
@@ -258,7 +277,7 @@
         input[inputPos]=inChar;
         inputPos++;
         cyclesWOSerialData = 0;
-
+        //Serial.println(inChar);
         // check for dynon skyview data.
         if (inChar == '\n' && inputPos == DYNON_SKYVIEW_SERIAL_LEN && input[0]=='!' && input[1]=='1') {
           // skyview data starts with a '!1'... the D series efis has no line prefix.
@@ -280,6 +299,13 @@
           tempBuf[2] = input[25]; //
           tempBuf[3] = '\0'; //
           ASI = strtol(tempBuf, NULL, 10); //convert to int (data comes in knots already on skyview)
+
+#ifdef SHOW_SERIAL_DEBUG
+  // show serial debug info for skyview data found.
+  sprintf(tempBuf, "SKYVIEW AOA:%i Live:%i ASI:%ikts ALT:%i PPS:%f cycleCounterResetAt: %i",AOA, liveAOA, ASI, ALT, pps, cycleCounterResetAt);
+  Serial.println(tempBuf);
+#endif
+
           validAOADataFound();
         } else if (inChar == '\n' && inputPos == DYNON_SERIAL_LEN) {  // is EOL?
           // else check for dynon d series data.


Sped up the pulsing animation to accomodate 3.3V 8mHz Arduino

--- sploder.ino
+++ sploder.ino
@@ -29,7 +29,7 @@
 // current brightness of the firing LED (to enable pulsing); see the helpers for a little more detail
 const float START_RADIAN = 4.712; // Start at the mid-point of the sin wave (all the way off)
 const float MAX_RADIAN = 10.995;
-const float RADIAN_STEP = 0.000225; // how many radians do we step the sign wave per loop?
+const float RADIAN_STEP = 0.00045; // how many radians do we step the sign wave per loop? optimized for 3.3v, 8mHz set to 0.000225 for a 16mHz Arduino
 const float SIN_OFFSET = 127.5; // the offset to map the sin values back to 0-255 for analogWrite
 float firingLEDBrightness = START_RADIAN;


Fixed tinyrun init

Fixed tinyrun init

--- arduino/tinyrun/tinyrun.ino
+++ arduino/tinyrun/tinyrun.ino
@@ -7,7 +7,7 @@
 #include "game_main.h"

-TinyScreen display = TinyScreen(0);
+TinyScreen display = TinyScreen(TinyScreenPlus);
 RenderBuffer<uint16_t,RENDER_COMMAND_COUNT> buffer;

 void setup() {


better steps to mm conversion (I think)

better steps to mm conversion (I think)

--- longhand_firmware_due/longhand_firmware_due.ino
+++ longhand_firmware_due/longhand_firmware_due.ino
@@ -76,7 +76,7 @@
 LongPoint delta_steps;						// the distances on each axis
 LongPoint offSet;

-float mmToStep = 42.735;					// convert mm commands to steps!
+float mmToStep = 42.929; //42.735;			// convert mm commands to steps!

 // scale existing drawings, but only when drawing from file!
 bool isDrawingFromFile = false;             // are we drawing from a file?


reset score points back to original values

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -517,7 +517,7 @@
     }

     if (!isBossAlive) {
-      if ((score >= 50) && (spawnedBoss < 1)) {
+      if ((score >= 5000) && (spawnedBoss < 1)) {

         if (!enemiesAlive) {
           boss.set(129, 28, 128);
@@ -528,7 +528,7 @@
           stopSpawningEnemies = true;
         }
       }
-      else if ((score >= 1000) && (spawnedBoss < 2)) {
+      else if ((score >= 12000) && (spawnedBoss < 2)) {
         if (!enemiesAlive) {
           boss.set(129, 24, 129);
           spawnedBoss = 2;
@@ -538,7 +538,7 @@
           stopSpawningEnemies = true;
         }
       }
-      else if ((score >= 30000) && (spawnedBoss < 3)) {
+      else if ((score >= 20000) && (spawnedBoss < 3)) {
         if (!enemiesAlive) {
           boss.set(129, 10, 130);
           spawnedBoss = 3;


added speed steps support for forward and backward command

--- arduino/pi_rover/pi_rover.ino
+++ arduino/pi_rover/pi_rover.ino
@@ -5,7 +5,9 @@
 AF_DCMotor motor3(3);
 AF_DCMotor motor4(4);

-int motorSpeed = 200;
+int motorSpeed = 100;
+bool isMovingForward = false;
+bool isMovingBackward = false;

 String input = "";

@@ -30,7 +32,7 @@
     input = "";
   }

-  delay(100);
+  delay(250);
 }

 String getCommandFromInput(String input) {
@@ -57,6 +59,16 @@
   }

   return result;
+}
+
+void setMotorSpeed(int speedInPercentage) {
+  motorSpeed = map(
+    speedInPercentage,
+    0, 100,
+    0, 255
+  );
+
+  Serial.print(String("Set speed to ") + motorSpeed + " ("+ speedInPercentage +"%)\n");
 }

@@ -85,8 +97,15 @@
   return result;
 }

-String forward(int speedInP87ercentage)
-{
+String forward(int speedInPercentage)
+{
+  if (speedInPercentage > 0)
+  {
+    setMotorSpeed(speedInPercentage);
+  }
+
+  isMovingForward = true;
+
   turnMotorsOn();

   motor1.run(BACKWARD);
@@ -97,8 +116,15 @@
   return "ok";
 }

-String backward(int argument)
-{
+String backward(int speedInPercentage)
+{
+  if (speedInPercentage > 0)
+  {
+    setMotorSpeed(speedInPercentage);
+  }
+
+  isMovingBackward = true;
+
   turnMotorsOn();

   motor1.run(FORWARD);
@@ -113,13 +139,19 @@
 {
   turnMotorsOff();

-  return "ok";
-}
-
-
-
-String left(int argument)
-{
+  isMovingForward = false;
+  isMovingBackward = false;
+
+  return "ok";
+}
+
+
+
+String left(int speedInPercentage)
+{
+  int currentMotorSpeed = motorSpeed;
+  setMotorSpeed(100);
+
   turnMotorsOn();

   motor1.run(FORWARD);
@@ -127,15 +159,26 @@
   motor3.run(FORWARD);
   motor4.run(BACKWARD);

-  delay(250);
-
-  turnMotorsOff();
-
-  return "ok";
-}
-
-String right(int argument)
-{
+  delay(100);
+
+  motorSpeed = currentMotorSpeed;
+
+  if (isMovingForward) {
+    forward(0);
+  } else if (isMovingBackward) {
+    backward(0);
+  } else {
+    turnMotorsOff();
+  }
+
+  return "ok";
+}
+
+String right(int speedInPercentage)
+{
+  int currentMotorSpeed = motorSpeed;
+  setMotorSpeed(100);
+
   turnMotorsOn();

   motor1.run(BACKWARD);
@@ -143,9 +186,17 @@
   motor3.run(BACKWARD);
   motor4.run(FORWARD);

-  delay(250);
-
-  turnMotorsOff();
+  delay(100);
+
+  motorSpeed = currentMotorSpeed;
+
+  if (isMovingForward) {
+    forward(0);
+  } else if (isMovingBackward) {
+    backward(0);
+  } else {
+    turnMotorsOff();
+  }

   return "ok";
 }


support lower battery levels

support lower battery levels

--- examples/RF12/radioBlip/radioBlip.ino
+++ examples/RF12/radioBlip/radioBlip.ino
@@ -9,13 +9,17 @@
 ISR(WDT_vect) { Sleepy::watchdogEvent(); }

 void setup() {
-#if defined(__AVR_ATtiny84__)
     cli();
     CLKPR = bit(CLKPCE);
+#if defined(__AVR_ATtiny84__)
     CLKPR = 0; // div 1, i.e. speed up to 8 MHz
+#else
+    CLKPR = 1; // div 2, i.e. slow down to 8 MHz
+#endif
     sei();
-#endif
     rf12_initialize(17, RF12_868MHZ, 5);
+    // see http://tools.jeelabs.org/rfm12b
+    rf12_config(0xC040); // set low-battery level to 2.2V i.s.o. 3.1V
 }

 void loop() {


Fixed display error

Fixed display error

--- seven-segment-integers/src/seven-segment-integers.ino
+++ seven-segment-integers/src/seven-segment-integers.ino
@@ -84,7 +84,7 @@

 void pickDigit(int j) {
   // pick which digit to display depending on the value passed in j
-  for (int i=1; i<4; i++)
+  for (int i=0; i<4; i++)
     digitalWrite(digits[i], HIGH);

   digitalWrite(digits[j], LOW);
@@ -106,7 +106,7 @@
   //takes the input n and puts into the array num, split in ones, tens, hundreds, and thousands place

   //clear previous values of the num array, -1 value allows checking to see if a new value has been placed
-  for (int i=0; i<4; i++)
+  for (int i=1; i<4; i++)
     num[i] = -1;

   //if n is 0-9
@@ -147,7 +147,7 @@
 }

 //global variables for the test function
-const long testInterval = 500; //counter delay in milliseconds
+const long testInterval = 1000; //counter delay in milliseconds
 long previousTestTime = 0; //previous count time
 int testLoop = 0; //counter for counting loop