updating firmware to include relay

updating firmware to include relay

--- firmware/aquaponicMCP/aquaponicMCP.ino
+++ firmware/aquaponicMCP/aquaponicMCP.ino
@@ -1,15 +1,11 @@

 #include "OneWire.h"

-//analog pins
-#define plantLight A0
-#define aquaLight A3
-#define waterTurbSensor A1
-#define ovenTempSensor A4
+//digital pins
+OneWire ds1(2); //water temp sensor
+OneWire ds2(3); //living room temp sensor

-//digital pins
-OneWire  ds(2); //water temp sensor
-#define RELAY1 3
+#define RELAY1 10

 bool powerIsOn = true;

@@ -28,26 +24,14 @@
   GetInput();
 }

-/*these will be raw readings, converting from voltage to
- * degrees or light etc should most likly done in a seperate
- * function or even in the data logger.
- */
 void SendData(){
   String mystr = "['data', {'station': 'aquaponicStation', 'sensors': [";
-  mystr += "{'sensor': 'aquaLight', 'type': 'lightsensor', 'value': ";
-  mystr += analogRead(aquaLight) ;
-  mystr += "},{'sensor':'ovenTemp', 'type': 'temperature', 'value':";
-  mystr += analogRead(ovenTempSensor);
-  mystr += "},{'sensor':'plantLight', 'type': 'lightsensor', 'value':";
-  mystr += analogRead(plantLight);
-  mystr += "},{'sensor':'waterTurb', 'type': 'cleanliness', 'value':";
-  mystr += analogRead(waterTurbSensor);
-
-  mystr += "},{'sensor':'waterTemp', 'type': 'temperature', 'value':";
-  mystr += ReadTemp();
+  mystr += "{'sensor':'waterTemp', 'type': 'temperature', 'value':";
+  mystr += ReadTemp(ds1);
+  mystr += "},{'sensor':'livingRoomTemp', 'type': 'temperature', 'value':";
+  mystr += ReadTemp(ds2);
   mystr += "},{'sensor':'lightSwitch', 'type': 'lightswitch', 'value':";
   mystr += powerIsOn;
-
   mystr += "}]}]";
   Serial.println(mystr);
 }
@@ -72,7 +56,7 @@
 }

 //Script I found online and modifed using the OneWire library, returns the temperature in fahrenheit.
-float ReadTemp(){
+float ReadTemp(OneWire ds){
   byte i;
   byte present = 0;
   byte type_s;


Testing id greater than 1 byte

Testing id greater than 1 byte

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -77,7 +77,9 @@
 	int i = 0;
 	while (Serial.available()) {
 		if (i > 0) {
-			id = Serial.parseInt();
+			if (characterRead[0] == COMMAND_REGISTER) {
+				id = Serial.parseInt();
+			}
 		}
 		else {
 			characterRead[i] = Serial.read();


Use int for mouse speed

Use int for mouse speed

--- volvo_hid.ino
+++ volvo_hid.ino
@@ -8,7 +8,7 @@
 #define RX_LED 17

 #define KEY_TIMEOUT 100
-#define MOUSE_BASE_SPEED 8.0
+#define MOUSE_BASE_SPEED 8
 #define MOUSE_SPEEDUP 3

 #define SYN_FIELD 0x55
@@ -47,7 +47,7 @@
 LinFrame frame;

 unsigned long lastBackDown, lastEnterDown, lastMouseDown;
-float mouseSpeed = MOUSE_BASE_SPEED;
+int mouseSpeed = MOUSE_BASE_SPEED;

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


display data amended

display data amended

--- hal100/hal100.ino
+++ hal100/hal100.ino
@@ -149,17 +149,30 @@
   TFTscreen.setTextSize(2);                         // set the font size 2
   TFTscreen.text("SWR", 5, 5);                     // write the text to coordinates
   // Displays L
-  TFTscreen.stroke(0, 255, 0);                      // set the font color
-  TFTscreen.setTextSize(2);                         // set the font size 2
-  TFTscreen.text("L", 5, 25);                     // write the text to coordinates
+  TFTscreen.stroke(0, 255, 0);
+  TFTscreen.setTextSize(2);
+  TFTscreen.text("L", 5, 25);
+  // Displays uH
+  TFTscreen.stroke(0, 255, 0);
+  TFTscreen.setTextSize(2);
+  TFTscreen.text("uH", 105, 25);
   // Displays C1
-  TFTscreen.stroke(0, 255, 0);                      // set the font color
-  TFTscreen.setTextSize(2);                         // set the font size 2
-  TFTscreen.text("C1", 5, 55);                     // write the text to coordinates
+  TFTscreen.stroke(0, 255, 0);
+  TFTscreen.setTextSize(2);
+  TFTscreen.text("C1", 5, 55);
+  // Displays pF for C1
+  TFTscreen.stroke(0, 255, 0);
+  TFTscreen.setTextSize(2);
+  TFTscreen.text("pF", 105, 55);
   // Displays C2
-  TFTscreen.stroke(0, 255, 0);                      // set the font color
-  TFTscreen.setTextSize(2);                         // set the font size 2
-  TFTscreen.text("C2", 5, 85);                     // write the text to coordinates
+  TFTscreen.stroke(0, 255, 0);
+  TFTscreen.setTextSize(2);
+  TFTscreen.text("C2", 5, 85);
+  // Displays pF for C2
+  TFTscreen.stroke(0, 255, 0);
+  TFTscreen.setTextSize(2);
+  TFTscreen.text("pF", 105, 85);
+

   keypad.addEventListener(keypadEvent);             //add an event listener for this keypad
 }


L steps and uH display - now displaying, but still NAN in uH after L stops

--- hal100/hal100.ino
+++ hal100/hal100.ino
@@ -280,7 +280,7 @@
   TFTscreen.text(DisplayValueSWR, 40, 5);
 }

-void displayLSteps() {                                         // display L values
+void displayLSteps() {                                         // display L steps values
   dtostrf(valueRotateL, 5, 0, DisplayValueL);
   if (isBusy) {
     TFTscreen.stroke(255, 255, 0);
@@ -291,7 +291,7 @@
   TFTscreen.text(DisplayValueL, 40, 40);
 }

-void displayValueLuH() {                                         // display L values (in Mh)
+void displayValueLuH() {                                         // display L values (in uH)
   dtostrf(stepsToMh(valueRotateL), 4, 2, DisplayValueLUH);
   TFTscreen.stroke(0, 255, 0);
   TFTscreen.setTextSize(2);
@@ -299,15 +299,24 @@
 }

 void displayL() {
-//  displayLSteps();
+  displayLSteps();
   displayValueLuH();
 }

-
-void EraseDisplayL() {                                   // erase display L values
+void EraseDisplayL() {
+  EraseDisplayLSteps();
+  ErasDisplayValueLuH();
+}
+
+void EraseDisplayLSteps() {                                   // erase display L steps values
   TFTscreen.stroke(0, 20, 30);
   TFTscreen.setTextSize(2);
   TFTscreen.text(DisplayValueL, 40, 40);
+}
+
+void ErasDisplayValueLuH() {                                   // erase display L values in uH
+  TFTscreen.stroke(0, 20, 30);
+  TFTscreen.setTextSize(2);
   TFTscreen.text(DisplayValueLUH, 40, 25);
 }


Update Air_monitor.ino

Update Air_monitor.ino

Included loudness sensor code and restructured variable structure


Reverse West East and Add Reset State

Reverse West East and Add Reset State

--- code/demos/ir-tv-remote/ir-tv-remote.ino
+++ code/demos/ir-tv-remote/ir-tv-remote.ino
@@ -20,6 +20,9 @@
 }

 void loop() {
+
+  // Reset states
+  reset_states();

   // Check for IR commands
   if (My_Receiver.GetResults (&My_Decoder)) {
@@ -42,7 +45,7 @@
       break;

     case 0xd5055bb4:
-      set_state_bit (true, GM_CMD_MOVE_E, &state);
+      set_state_bit (true, GM_CMD_MOVE_W, &state);
       break;

     case 0x8e623846:
@@ -51,8 +54,12 @@
       break;

     case 0x42505f87:
-      set_state_bit (true, GM_CMD_MOVE_W, &state);
+      set_state_bit (true, GM_CMD_MOVE_E, &state);
       // left
+      break;
+
+    default
+      reset_states();
       break;
     }

@@ -62,3 +69,10 @@
   }
 }

+void reset_states(){
+  set_state_bit (false, GM_CMD_GRAB, &state);
+  set_state_bit (false, GM_CMD_MOVE_N, &state);
+  set_state_bit (false, GM_CMD_MOVE_W, &state);
+  set_state_bit (false, GM_CMD_MOVE_S, &state);
+  set_state_bit (false, GM_CMD_MOVE_E, &state);
+}


Remove Empty sketch

Remove Empty sketch

--- Empty/Empty.ino
+++ Empty/Empty.ino
@@ -1,6 +0,0 @@
-void setup() {
-}
-
-void loop() {
-}
-


getBits and setBits working:

getBits and setBits working:

--- CANDuino.ino
+++ CANDuino.ino
@@ -74,11 +74,18 @@
     return val;
 }

-// TODO - Get Working
-void setBits(int startBit, int length, unsigned char *buf, unsigned int data) {
-    for (int i = 0; i < length; i++) {
-        buf[(startBit + i)/8] = (buf[(startBit + i)/8] & ~(~(data & 1) << ((startBit + i) % 8)));
-        data = data >> 1;
+void setBits(unsigned int startBit, unsigned int length, unsigned char *buf, unsigned int data) {
+    unsigned int endBit = startBit + length - 1;
+    for  (int i = 0; i < length; i++) {
+      unsigned maskedData = data & 1;
+      if (maskedData) {
+        unsigned char mask = maskedData << (7 - ((endBit - i) % 8));
+        buf[(endBit - i) / 8] = buf[(endBit - i) / 8] | mask;
+      } else {
+        unsigned char mask = ~(~maskedData << (7 - ((endBit - i) % 8)));
+        buf[(endBit - i) / 8] = buf[(endBit - i) / 8] & mask;
+      }
+      data = data >> 1;
     }
 }


Use the denbit library too

Use the denbit library too

--- examples/OLED_SSD1306_Demo/OLED_SSD1306_Demo.ino
+++ examples/OLED_SSD1306_Demo/OLED_SSD1306_Demo.ino
@@ -27,6 +27,12 @@
 #include "SSD1306.h"
 #include "SSD1306Ui.h"
 #include "images.h"
+
+// Include the Denbit library.
+#include <Denbit.h>
+// Initialize the denbit.
+Denbit denbit;
+

 // Pin definitions for I2C
 #define OLED_SDA    4


refactor

refactor

--- esp8266_160220_BYOP.ino
+++ esp8266_160220_BYOP.ino
@@ -56,11 +56,20 @@
 }

 //-------------------------------------------------------------------------
+// functoins related to sequence

 void setup() {
   Serial.begin(115200);
 }

+void loop() {
+  String rcvd = Serial_readCommand();
+  if (rcvd.length() > 0) {
+    Serial_replyToCommand(rcvd);
+  }
+}
+
+//-------------------------------------------------------------------------

 bool proc_hello(String csvline)
 {
@@ -72,13 +81,13 @@
     return false;
   }

-  debug_outputDebugString("proc_hello", "line89 > " + csvline);
+//  debug_outputDebugString("proc_hello", "line89 > " + csvline);

   s_owner.nickName = nickname;
   s_owner.serialNo = serno;

-  debug_outputDebugString("proc_hello", "line105 > [S/N]" + serno);
-  debug_outputDebugString("proc_hello", "line106 > [name]" + nickname);
+//  debug_outputDebugString("proc_hello", "line105 > [S/N]" + serno);
+//  debug_outputDebugString("proc_hello", "line106 > [name]" + nickname);

   // TODO: 0m > display "Hello,<CR><LF>[nickName]" to LCD

@@ -105,9 +114,4 @@
     Serial.println("bye,7of9");
 }

-void loop() {
-  String rcvd = Serial_readCommand();
-  if (rcvd.length() > 0) {
-    Serial_replyToCommand(rcvd);
-  }
-}
+


New SD files for maps

New SD files for maps

--- Elcano_C6_Navigator/Elcano_C6_Navigator.ino
+++ Elcano_C6_Navigator/Elcano_C6_Navigator.ino
@@ -1,7 +1,11 @@
+#include <Common.h>
+#include <IO.h>
+//#include <Matrix.h>
+
 /*
 Elcano Module C6: Navigator.
   Includes C5 Obstacle detection.
-
+
 Documentation:
   NavigationSystem (TO DO: Write document, based on these comments).
   Wiring_C6Mega.xls
@@ -12,7 +16,7 @@

 It uses a variety of sensors, some of which may not be present or reliable.

-Yes: S1: Hall Odometer.  This unit gives wheel spin speed feedback.
+Yes: S1: Hall Odometer.  This unit gives wheel spin speed feedback.
 TO DO: Connect hardware and integrate into Kalman Filter

 Future: Visual Odometry from S4 (Smart camera) as passed though C7 (Visual Data
@@ -27,19 +31,19 @@

 Yes: Distance and bearing to landmarks / obstacles.

-Yes: S7: GPS.  GPS should not the primary navigation sensor and the robot should be
+Yes: S7: GPS.  GPS should not the primary navigation sensor and the robot should be
 able to operate indoors, in tunnels or other areas where GPS is not available
 or accurate.

-Sensed navigation information is passed to C3/C4, which use prexisting or SLAM
+Sensed navigation information is passed to C3/C4, which use prexisting or SLAM
 digital maps, intended path to refine the estimated position.
-C3/C4 may use a particle filter.
+C3/C4 may use a particle filter.
 C3/C4 may also receive lateral lane deviation from a camera (C7).

-The odometry sensor is one dimensional and gives the position along the
+The odometry sensor is one dimensional and gives the position along the
 intended path. Lane deviation is also one dimensional and gives position
 normal to the intended path. Odometry, lane following and a digital map
-should be sufficient for localization.  An odometer will drift. This drift
+should be sufficient for localization.  An odometer will drift. This drift
 can be nulled out by landmark recognition or GPS.

 An alternative to the Kalman Filter (KF) is fuzzy numbers.
@@ -50,16 +54,16 @@
 the position is known.

 GPS provides a pyramid aligned north-south and east-west, in contrast to
-odometry / lane deviation, which is a pyramid oriented in the direction of
+odometry / lane deviation, which is a pyramid oriented in the direction of
 vehicle motion. The intersection of two fuzzy sets is their minimum.
 By taking the minima of all position estimate pyramids, we get a surface
-describing the possible positions of the vehicle, whichcan be used by a
+describing the possible positions of the vehicle, whichcan be used by a
 particle filter.

 Serial lines:
 0: Monitor
 1: INU
-2: Tx: Estimated state;
+2: Tx: Estimated state;
       $C6EST,<east_mm>,<north_mm>,<speed_mmPs>,<bearing>,<time_ms><positionStndDev_mm>*CKSUM
       $C6OBS,<number>,<obstacle1_range_mm>,<obstacle1_bearing>, ...*CKSUM
    Rx: Desired course
@@ -72,22 +76,9 @@
   Tx: $PSRF103,...
 */

-/*---------------------------------------------------------------------------------------*/
-
-#define MEGA
-#include <Common.h>
-#include <SPI.h>
+/*---------------------------------------------------------------------------------------*/
+
 #include <SD.h>
-#include <IO.h>
-#include <Matrix.h>
-#include <Wire.h>
-#include "Adafruit_Sensor.h"
-#include "Adafruit_LSM303_U.h"
-
-/* Assign a unique ID to this sensor at the same time */
-Adafruit_LSM303_Mag mag = Adafruit_LSM303_Mag(1366123);
-
-float CurrentHeading = -1;

 // On the Ethernet Shield, CS is pin 4. Note that even if it's not
 // used as the CS pin, the hardware CS pin (10 on most Arduino boards,
@@ -99,12 +90,10 @@
 #endif

-namespace C6_Navigator
-{
+namespace C6_Navigator {
     void setup();
     void loop();
 }
-
 // Set the GPSRATE to the baud rate of the GPS module. Most are 4800
 // but some are 38400 or other. Check the datasheet!
 #define GPSRATE 4800
@@ -128,9 +117,8 @@
 #endif
 // limited to 8+3 characters
 #define FILE_NAME "GPSLog.csv"
-
 File dataFile;
-char GPSfile[BUFFSIZ] = "mmddhhmm.csv";
+char GPSfile[BUFFSIZ] = "mmddhhmm.csv";
 char ObstacleString[BUFFSIZ];
 char StartTime[BUFFSIZ] = "yy,mm,dd,hh,mm,ss,xxx";
 const char TimeHeader[] = "year,month,day,hour,minute,second,msec";
@@ -150,7 +138,6 @@
 waypoint estimated_position;
 //instrument IMU;
 const unsigned long LoopPeriod = 100;  // msec
-
 //---------------------------------------------------------------------------
 char* obstacleDetect()
 {
@@ -160,13 +147,13 @@
     int Range =      analogRead(FRONT) + OFFSET;
     int RightRange = analogRead(RIGHT) + OFFSET;

-  sprintf(ObstacleString,
+  sprintf(ObstacleString,
   "%d.%0.2d,%d.%0.2d,%d.%0.2d,",
   LeftRange/100, LeftRange%100, Range/100, Range%100, RightRange/100, RightRange%100);
-
+
   return ObstacleString;
 }
-/*---------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------------------*/
 // WheelRev is called by an interrupt.
 void WheelRev()
 {
@@ -185,7 +172,7 @@
     Odometer_mm += WHEEL_DIAMETER_MM * PI;
     OldTick = TickTime;
 }
-/*---------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------------------*/

 void initialize()
 {
@@ -195,13 +182,13 @@
   char* disable =   "$PSRF103,02,00,00,01*26\r\n";
   char* querryGGA = "$PSRF103,00,01,00,01*25";
   bool GPS_available = false;
-  Serial3.begin(GPSRATE);
+  Serial3.begin(GPSRATE);
   digitalWrite(GPS_POWER, LOW);         // pull low to turn on!
   Serial.flush();
   Serial3.flush();
   delay(5000);
-  // prints title with ending line break
-  Serial.println(" GPS parser");
+  // prints title with ending line break
+  Serial.println(" GPS parser");
 //  Serial.print("Acquiring GPS RMC...");
   checksum(protocol);
   Serial3.println(protocol);
@@ -209,10 +196,7 @@
   checksum(disable);
   Serial3.println(disable);   // no GSA

-  if(estimated_position)
-  {
-    GPS_available = estimated_position.AcquireGPRMC(70000);
-  }
+  GPS_available = estimated_position.AcquireGPRMC(70000);
   Serial.println(TimeHeader);
   Serial.println(StartTime);
   Serial.println(RawKF);
@@ -239,7 +223,7 @@
   estimated_position.Evector_x1000 = 1000;  // to be taken from path or set by hand
   estimated_position.Nvector_x1000 = 0;
   GPS_reading = estimated_position;
-  GPSString = estimated_position.formPointString();
+  GPSString = estimated_position.formPointString();
   Serial.println(GPSString);
   // Set Odometer to 0.
   // Set lateral deviation to 0.
@@ -269,11 +253,12 @@
     // ready to roll
     // Fuse all position estimates.
     // Send vehicle state to C3 and C4.
-}
-/*---------------------------------------------------------------------------------------*/
-
-void setup()
-{
+
+}
+/*---------------------------------------------------------------------------------------*/
+
+void setup()
+{
     pinMode(Rx0, INPUT);
     pinMode(Tx0, OUTPUT);
     pinMode(GPS_RX, INPUT);
@@ -283,7 +268,7 @@
     pinMode(INU_RX, INPUT);
     pinMode(INU_TX, OUTPUT);
     pinMode(GPS_POWER, OUTPUT);
-    Serial3.begin(GPSRATE); // GPS
+    Serial3.begin(GPSRATE); // GPS
     Serial.begin(9600);
     digitalWrite(GPS_POWER, LOW);         // pull low to turn on!
     // make sure that the default chip select pin is set to
@@ -292,26 +277,14 @@
     pinMode(53, OUTPUT);  // Unused CS on Mega
     pinMode(GPS_RED_LED, OUTPUT);
     pinMode(GPS_GREEN_LED, OUTPUT);
-    digitalWrite(GPS_GREEN_LED, LOW);
+    digitalWrite(GPS_GREEN_LED, LOW);
     digitalWrite(GPS_RED_LED, LOW);

     initialize();
-    //Serial.print("Initializing GPS SD card...");
-
-
-    //Enable auto-gain
-    mag.enableAutoRange(true);
-
-    //Initialise the sensor
-    if(!mag.begin())
-    {
-        //There was a problem detecting the LSM303 ... check your connections
-        Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
-        while(1);
-    }
-
+//    Serial.print("Initializing GPS SD card...");
+
     // see if the card is present and can be initialized:
-    if (!SD.begin(chipSelect))
+    if (!SD.begin(chipSelect))
     {
       Serial.println("Card failed, or not present");
       digitalWrite(GPS_RED_LED, HIGH);
@@ -321,7 +294,7 @@
       Serial.println("card initialized.\n");
       dataFile = SD.open(GPSfile, FILE_WRITE);
       // if the file is available, write date and time to it:
-      if (dataFile)
+      if (dataFile)
       {
           dataFile.println(TimeHeader);
           dataFile.println(StartTime);
@@ -330,33 +303,34 @@
           dataFile.print(Header);
           dataFile.println(ObstHeader);
           dataFile.close();
-      }
+      }
     }
     pinMode(CYCLOMETER, INPUT);
     attachInterrupt (5, WheelRev, RISING);

 }
-/*---------------------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------------------*/
 void waypoint::SetTime(char *pTime, char * pDate)
 {
-    //GPSfile = "mmddhhmm.CSV";
-    strncpy(GPSfile,   pDate+2, 2);  // month
-    strncpy(GPSfile+2, pDate, 2);    // day
-    strncpy(GPSfile+4, pTime,2);     // GMT hour
-    strncpy(GPSfile+6, pTime+2,2);   // minute
-    Serial.println(GPSfile);
-
-    strncpy(StartTime,     pDate+4, 2);  // year
-    strncpy(StartTime+3,   pDate+2, 2);  // month
-    strncpy(StartTime+6,   pDate, 2);    // day
-    strncpy(StartTime+9,   pTime,2);     // GMT hour
-    strncpy(StartTime+12,  pTime+2,2);   // minute
-    strncpy(StartTime+15,  pTime+4,2);   // second
-    strncpy(StartTime+18,  pTime+7,3);   // millisecond
-}
-
-/*---------------------------------------------------------------------------------------*/
-void loop()
+//    GPSfile = "mmddhhmm.CSV";
+     strncpy(GPSfile,   pDate+2, 2);  // month
+     strncpy(GPSfile+2, pDate, 2);    // day
+     strncpy(GPSfile+4, pTime,2);     // GMT hour
+     strncpy(GPSfile+6, pTime+2,2);   // minute
+     Serial.println(GPSfile);
+
+     strncpy(StartTime,     pDate+4, 2);  // year
+     strncpy(StartTime+3,   pDate+2, 2);  // month
+     strncpy(StartTime+6,   pDate, 2);    // day
+     strncpy(StartTime+9,   pTime,2);     // GMT hour
+     strncpy(StartTime+12,  pTime+2,2);   // minute
+     strncpy(StartTime+15,  pTime+4,2);   // second
+     strncpy(StartTime+18,  pTime+7,3);   // millisecond
+
+}
+
+/*---------------------------------------------------------------------------------------*/
+void loop()
 {
     unsigned long deltaT_ms;
     unsigned long time = millis();
@@ -374,10 +348,10 @@
     ReadINU.
     Set attitude.
     Read Hall Odometer;  */
-//   IMU.Read(GPS_reading);
-
+//   IMU.Read(GPS_reading);
+
 /*  Read Optical Odometer;
-    Read lane deviation;
+    Read lane deviation;
     If (message from C4)
     { */
 //      readline(2);  // C4 Path planner on serial 2 get new route and speed
@@ -388,39 +362,25 @@
 /*    }
     if (landmarks availabe)
     {  // get the position based on bearing and angle to a known location.
-      ReadLandmarks(C4);
+      ReadLandmarks(C4);
     }
     // Fuse all position estimates with a Kalman Filter */
     deltaT_ms = GPS_reading.time_ms - estimated_position.time_ms;
     estimated_position.fuse(GPS_reading, deltaT_ms);
     estimated_position.time_ms = GPS_reading.time_ms;
-/*  Serial.print("time, gps, dt_ms = ");
+/*  Serial.print("time, gps, dt_ms = ");
     Serial.print(time, DEC); Serial.print(", ");
     Serial.print(GPS_reading.time_ms, DEC); Serial.print(", ");
     Serial.println(deltaT_ms, DEC);
-*/
-    // Send vehicle state to C3 and C4.
-
-    //Get a new sensor event from the magnitomitor
-    sensors_event_t event;
-    mag.getEvent(&event);
-
-    //Calculate the current heading (angle of the vector y,x)
-    float heading = (atan2(event.magnetic.y, event.magnetic.x) * 180) / M_PI;
-
-    //Normalize the heading
-    if (heading < 0)
-    {
-        heading = 360 + heading;
-    }
-    CurrentHeading = heading;
+*/
+    // Send vehicle state to C3 and C4.

     // open the file. note that only one file can be open at a time,
     // so you have to close this one before opening another.
     dataFile = SD.open(GPSfile, FILE_WRITE);
-
+
     // if the file is available, write to it:
-    if (GPS_available)
+    if (GPS_available)
     {
         digitalWrite(GPS_GREEN_LED, HIGH);
         pGPS = GPS_reading.formPointString();
@@ -432,21 +392,21 @@
         Serial.print(pData);
         Serial3.print(pData);  // send data to C4 path planner
         pObstacles = obstacleDetect();
-        if (dataFile)
+        if (dataFile)
         {
           dataFile.print(pObstacles);
         }
         Serial.print(pObstacles);
-    }
-    else
+    }
+    else
     {
         digitalWrite(GPS_GREEN_LED, LOW);
         Serial.print("GPS not available");
     }
-
+
     work_time = millis() - time;
-    PerCentBusy = (100 * work_time) / LoopPeriod;
-    if (dataFile)
+    PerCentBusy = (100 * work_time) / LoopPeriod;
+    if (dataFile)
     {
       dataFile.println(PerCentBusy);
     }
@@ -462,7 +422,7 @@
         digitalWrite(GPS_RED_LED, HIGH);
  //     Serial.println("error opening file");
     }
-
+
   // delay, but don't count time in loop
   while (time < endTime)
   {
@@ -491,4 +451,4 @@
 */
 void C6_Navigator_setup() { C6_Navigator::setup(); }

-void C6_Navigator_loop() { C6_Navigator::loop(); }
+void C6_Navigator_loop() { C6_Navigator::loop(); }


Better calibrated ticks per revolution

Better calibrated ticks per revolution

--- arduino/DiskInterface/DiskInterface.ino
+++ arduino/DiskInterface/DiskInterface.ino
@@ -54,13 +54,13 @@
 // Set to 1 to start in debug mode
 #define DEBUG_MODE 0

-// Top disk
+// Bottom disk
 const int DISK0_HOME_SENSOR = A0;
 const int DISK0_ENC_A = 5;
 const int DISK0_ENC_B = 6;
 const int DISK0_MOTOR_A = 4;
 const int DISK0_MOTOR_B = 3;
-const int DISK0_TICKS_PER_REVOLUTION = 30513;
+const int DISK0_TICKS_PER_REVOLUTION = 30089;

 // Middle disk
 const int DISK1_HOME_SENSOR = A1;
@@ -68,15 +68,15 @@
 const int DISK1_ENC_B = 10;
 const int DISK1_MOTOR_A = 8;
 const int DISK1_MOTOR_B = 7;
-const int DISK1_TICKS_PER_REVOLUTION = 29689;
-
-// Bottom disk
+const int DISK1_TICKS_PER_REVOLUTION = 31348;
+
+// Top disk
 const int DISK2_HOME_SENSOR = A2;
 const int DISK2_ENC_A = 20;
 const int DISK2_ENC_B = 19;
 const int DISK2_MOTOR_A = 17;
 const int DISK2_MOTOR_B = 18;
-const int DISK2_TICKS_PER_REVOLUTION = 30252;
+const int DISK2_TICKS_PER_REVOLUTION = 31385;

 // Globals


Overwritten with new version

Overwritten with new version

Preparatory work for M5Stack

--- ANI_CameraRemote/ANI_CameraRemote.ino
+++ ANI_CameraRemote/ANI_CameraRemote.ino
@@ -2,7 +2,7 @@
   ANI Camera Remote by Andreas Niggemann, 2017
   Versions:
   20170607 Base functions
-	20170613 Shot counter for WebGUI
+  20170613 Shot counter for WebGUI
   20170712 Defining triggerPin, settings
   20170717 Refactoring
   20170720 Bugfix: Restarting timelapse after reconnect removed
@@ -11,9 +11,15 @@
   20170722 Input pin as timelapse start
   20170724 Setting for autostart timelapse mode
   20170724 Calculate remaining time
+  20180503 Preparatory work for M5Stack (display and keyboard)
   --------------------------------------------------*/
-
+#ifdef ESP32
+#include <M5Stack.h>
+#include <WiFi.h>
+#include <Free_Fonts.h>
+#else
 #include <ESP8266WiFi.h>
+#endif

 //--------------------------------------------------
 // Settings:
@@ -29,7 +35,7 @@
 const unsigned long default_delayToStart = 0;      // Delay in seconds till start of timelapse
 const unsigned long default_numberOfShots = 10;    // Number of shots in timelapse mode
 const unsigned long default_delayBetweenShots = 5; // Delay between shots in timelapse mode
-const unsigned long default_autorefresh = 15;      // In timelapse mode autorefresh webGUI every 15 seconds, 0 = autorefresh off
+const unsigned long default_autorefresh = 5;       // In timelapse mode autorefresh webGUI every 5 seconds, 0 = autorefresh off
 const int timelapseAutoStart = 0;                  // 1 = Autostart timelapse mode, 0 = No autostart

 // End of settings
@@ -62,6 +68,8 @@
 unsigned long secCounter = 0; // count the seconds since start of timelapse
 unsigned long timeSlotCounter = 0; // count the timeslots since start of timelapse

+bool displayIsOn = true;
+
 String myIPStr = "";

 enum triggerModes { ON = 0, OFF = 1 };
@@ -72,21 +80,18 @@

 // Create webserver on webServerPort
 WiFiServer server(webServerPort);
-
 WiFiClient client;

 void setup()
 {
+  displaySetup();
+
   pinMode(triggerPin, OUTPUT); // setup GPIO as camera trigger
   trigger(OFF);
   if (startPin > -1)
     pinMode(startPin, INPUT_PULLUP); // Setup GPIO input for start signal

-  WiFi.mode(WIFI_AP); // AP mode for connections
-  WiFi.softAP(ssid, password);
-  server.begin();
-  IPAddress ip = WiFi.softAPIP();
-  myIPStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
+  setupWiFi();

   checkAndProcessAutoStart();
 }
@@ -98,6 +103,8 @@
   process();

   checkAndProcessStartPin();
+
+  processKeyboard();

   client = server.available(); // Check if a client has connected
   String sRequest = getRequest(client);
@@ -335,6 +342,7 @@
                   ;
   if (refreshLine != "")
     retVal += "Page will refresh every " + String(currentAutorefresh) +  " seconds
";
+  onDisplay();
   return retVal;
 }

@@ -445,3 +453,81 @@
   currentTriggerMode =  tMode;
 }

+#ifdef ESP32
+//void setupWiFi() { }
+void setupWiFi()
+{
+  WiFi.mode(WIFI_AP); // AP mode for connections
+  WiFi.softAP(ssid, password);
+  server.begin();
+  IPAddress ip = WiFi.softAPIP();
+  myIPStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
+}
+
+void displaySetup()
+{
+  M5.begin();
+  onDisplay();
+}
+
+void onDisplay()
+{
+  int actuLine = 0;
+  M5.Lcd.fillScreen(TFT_BLACK);
+  M5.Lcd.setFreeFont(FF9);
+  outLCD(1, prgTitle + " " + prgVersion);
+  outLCD(2, "RESET");
+  outLCD(3, "Delay to Start: " + String(delayToStart));
+  outLCD(4, "Number of Shots: " + String(numberOfShots));
+  outLCD(5, "Interval: " + String(delayBetweenShots));
+  if (startPin > -1)
+    outLCD(6, "Wait for GPIO" + String(startPin));
+  outLCD(7, "START");
+  outLCD(8, "STOP");
+  outLCD(9, "ONE SHOT");
+  outLCD(10, "Remaining delay: " + String(currentDelayToStart));
+  outLCD(11, "Remaining shots: " + String(currentNShots));
+}
+
+void outLCD(int lineNumber, String outStr)
+{
+  const int lineFactor = 20;
+  M5.Lcd.setCursor(0, lineNumber * lineFactor);
+  M5.Lcd.printf(outStr.c_str());
+}
+
+void processKeyboard()
+{
+  // Will not work currently because of a glitch in the Arduino ESP32 IDF
+  // conflicts between WIFI and Buttons
+  // Later version will not need WIFI and will have a complete UI via display and buttons
+  if (M5.BtnA.pressedFor(1000)) // 1 second press to engage screen off or on
+  {
+    if (displayIsOn)
+    {
+      M5.Lcd.writecommand(ILI9341_DISPOFF);
+      M5.Lcd.setBrightness(0);
+      displayIsOn = false;
+    }
+    else
+    {
+      M5.Lcd.writecommand(ILI9341_DISPON);
+      M5.Lcd.setBrightness(50);
+      displayIsOn = true;
+    }
+  }
+}
+#else
+// Methods for ESP8266
+void setupWiFi()
+{
+  WiFi.mode(WIFI_AP); // AP mode for connections
+  WiFi.softAP(ssid, password);
+  server.begin();
+  IPAddress ip = WiFi.softAPIP();
+  myIPStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
+}
+void displaySetup() { }
+void onDisplay() { }
+void processKeyboard() { }
+#endif


adding more debug, and fixes

adding more debug, and fixes

still not working correctly, but on the way

--- KSPboard.ino
+++ KSPboard.ino
@@ -67,6 +67,7 @@

 // delays
 #define DELAY_LOOP 10 // these are milliseconds
+#define DELAY_DEBUG 750
 #define DELAY_START 30
 #define DELAY_CTRL 100
 #define DELAY_OP 100
@@ -151,17 +152,35 @@
   uint16_t matrix = 0;
   uint8_t row = 0, col = 0;

+#ifdef DEBUG
+  Serial.println(F(" => matrix"));
+#endif
+
   for (row = PIN_HELM_MAT_ROW; row < PIN_HELM_MAT_ROWS; row++)
   {
     digitalWrite(row, LOW); // turn on the active-low row

     for (col = PIN_HELM_MAT_COL; col < PIN_HELM_MAT_COLS; col++)
     {
-      matrix <<= !digitalRead(col); // invert and shift in the next column bit
+      boolean switchState = !digitalRead(col); // get inverted result
+      matrix <<= switchState; // and shift it onto the matrix
+
+#ifdef DEBUG
+      Serial.print(F("\t"));
+      Serial.print(switchState);
+#endif
     }

     digitalWrite(row, HIGH); // turn off the active-low row
-  }
+
+#ifdef DEBUG
+    Serial.println();
+#endif
+  }
+
+#ifdef DEBUG
+  Serial.println();
+#endif

   return (matrix);
 }
@@ -260,6 +279,11 @@
   {
     pinMode(index, INPUT_PULLUP); // active low matrix
   }
+
+  for (index = PIN_HELM_MAT_ROW; index < PIN_HELM_MAT_ROWS; index++)
+  {
+    digitalWrite(index, HIGH); // pull these up to 5V so current cannot flow
+  }
 }

 void setupOps()
@@ -324,12 +348,12 @@
 {
   // get the matrix state used in the pitch/roll/yaw masks below
   uint16_t helm = helmReadMatrix();
-
+/*
 #ifdef DEBUG
   Serial.print(F(" => maxtrix:\n\t"));
   Serial.println(helm, BIN);
 #endif
-
+*/
   // update control surface inputs
   // the MASKED_ contants have "helm | DIR_MASK_x" format for convenience
   pitchAdjust = helmGetAdjustment(MASKED_PITCH_U, MASKED_PITCH_D, pitchAdjust);
@@ -425,7 +449,12 @@
     updateOps();
   }

+#ifndef DEBUG
   delay(DELAY_LOOP);
+#else
+  delay(DELAY_DEBUG);
+#endif
+
   Serial.flush();
 }


add single cycle to CLI

add single cycle to CLI

--- src/monitor-firmware.ino
+++ src/monitor-firmware.ino
@@ -29,6 +29,9 @@

 // Are we wanting the processor to be halted?
 bool halt_request;
+
+// Should we cycle the processor?
+bool cycle_request;

 DebouncedSwitch mode_switch(BTN_MODE);
 DebouncedSwitch select_switch(BTN_SELECT);
@@ -99,9 +102,33 @@
     return { .next = &readingCommandState };
 }

+void printHelp() {
+    Serial.println("?       - show brief help message");
+    Serial.println("p       - print current address/data bus");
+    Serial.println("h       - toggle halt state");
+    Serial.println("c       - single cycle");
+}
+
 SerialState processCommand() {
-    Serial.print("cmd: ");
-    Serial.println(reinterpret_cast<char*>(cmd_buf));
+    if(cmd_buf[0] == 'p') {
+        // print current state
+        Serial.print("A: ");
+        Serial.print(address_bus, HEX);
+        Serial.print(" D: ");
+        Serial.print(data_bus, HEX);
+        Serial.println("");
+    } else if(cmd_buf[0] == '?') {
+        printHelp();
+    } else if(cmd_buf[0] == 'h') {
+        halt_request = !halt_request;
+        Serial.print("halt ");
+        Serial.println(halt_request ? "on" : "off");
+    } else if(cmd_buf[0] == 'c') {
+        cycle_request = true;
+    } else {
+        Serial.println("unknown cmd");
+        printHelp();
+    }
     return serialPrompt();
 }

@@ -146,6 +173,7 @@

     // Processor is in running state
     halt_request = false;
+    cycle_request = false;

     // OK, all done, just wait for display test to time out
     while(millis() - dt_shown_at < DPY_TST_DURATION) {
@@ -169,6 +197,8 @@
     if(mode_trigger.triggered()) {
         halt_request = !halt_request;
     }
+
+    cycle_request = cycle_request || select_trigger.triggered();

     // Update control lines
     digitalWrite(HALT, halt_request ? HIGH : LOW);
@@ -201,10 +231,13 @@
         }
     } else {
         // step only makes sense if processor halted
-        if(select_trigger.triggered()) {
+        if(cycle_request) {
             // Pulse step pin
             digitalWrite(STEP, HIGH);
             digitalWrite(STEP, LOW);
+
+            // Reset cycle request
+            cycle_request = false;
         }

         // Update address bus


Clean merge conflict text

Clean merge conflict text

--- src/Gortobot_v3c.ino
+++ src/Gortobot_v3c.ino
@@ -4,11 +4,8 @@
 // battery classes, abstract, fake
 // gps classes, abstract, fake
 // get rid of warnings in build log
-<<<<<<< HEAD
 // merge back into master
-=======
 // vref maxes at 4.096, do something about this
->>>>>>> Event-driven_serials

 // Program Modes (config)
 #include "configs/config.h"


remove .ino from Firmware it belongs in examples apparently

--- firmware/blinkLED.ino
+++ firmware/blinkLED.ino
@@ -1,73 +0,0 @@
-// This #include statement was automatically added by the Particle IDE.
-
-// ------------
-// Blink an LED
-// ------------
-
-/*-------------
-
-We've heavily commented this code for you. If you're a pro, feel free to ignore it.
-
-Comments start with two slashes or are blocked off by a slash and a star.
-You can read them, but your device can't.
-It's like a secret message just for you.
-
-Every program based on Wiring (programming language used by Arduino, and Particle devices) has two essential parts:
-setup - runs once at the beginning of your program
-loop - runs continuously over and over
-
-You'll see how we use these in a second.
-
-This program will blink an led on and off every second.
-It blinks the D7 LED on your Particle device. If you have an LED wired to D0, it will blink that LED as well.
-
--------------*/
-
-
-// First, we're going to make some variables.
-// This is our "shorthand" that we'll use throughout the program:
-
-int led1 = D0; // Instead of writing D0 over and over again, we'll write led1
-// You'll need to wire an LED to this one to see it blink.
-
-int led2 = D7; // Instead of writing D7 over and over again, we'll write led2
-// This one is the little blue LED on your board. On the Photon it is next to D7, and on the Core it is next to the USB jack.
-
-// Having declared these variables, let's move on to the setup function.
-// The setup function is a standard part of any microcontroller program.
-// It runs only once when the device boots up or is reset.
-
-void setup() {
-
-  // We are going to tell our device that D0 and D7 (which we named led1 and led2 respectively) are going to be output
-  // (That means that we will be sending voltage to them, rather than monitoring voltage that comes from them)
-
-  // It's important you do this here, inside the setup() function rather than outside it or in the loop function.
-
-  pinMode(led1, OUTPUT);
-  pinMode(led2, OUTPUT);
-
-}
-
-// Next we have the loop function, the other essential part of a microcontroller program.
-// This routine gets repeated over and over, as quickly as possible and as many times as possible, after the setup function is called.
-// Note: Code that blocks for too long (like more than 5 seconds), can make weird things happen (like dropping the network connection).  The built-in delay function shown below safely interleaves required background activity, so arbitrarily long delays can safely be done if you need them.
-
-void loop() {
-  // To blink the LED, first we'll turn it on...
-  digitalWrite(led1, HIGH);
-  digitalWrite(led2, LOW);
-
-  // We'll leave it on for 1 second...
-  delay(1000);
-
-  // Then we'll turn it off...
-  digitalWrite(led1, LOW);
-  digitalWrite(led2, HIGH);
-
-  // Wait 1 second...
-  delay(1000);
-
-  // And repeat!
-}
-


Update firmware to check if the led strip is already on/off and correspondingly apply new changes or not

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -11,8 +11,10 @@
 #define LED         4
 #define DS18B20     5 // Dallas DS18B20 digital thermometer

+
+unsigned int i = 0;
 unsigned int brightness = 1023;
-
+bool led_on = false;
 // Create an ESP8266 WiFiClient class to connect to the MQTT server.
 WiFiClient client;

@@ -22,6 +24,8 @@
 // Bug workaround for Arduino 1.6.6, it seems to need a function declaration
 // for some reason (only affects ESP8266, likely an arduino-builder bug).
 void MQTT_connect();
+
+

 void setup() {
   pinMode(LED, OUTPUT);
@@ -35,7 +39,7 @@

   WiFi.begin(WLAN_SSID, WLAN_PASS);
   if (WiFi.status() != WL_CONNECTED) {
-    delay(300);
+    delay(500);
     Serial.print(F("."));
   }
   Serial.println();
@@ -47,8 +51,7 @@
   mqtt.subscribe(&onoffsw);
 }

-uint32_t x = 0;
-unsigned int i = 0;
+
 void loop() {
   // Ensure the connection to the MQTT server is alive (this will make the first
   // connection and automatically reconnect when disconnected).  See the MQTT_connect
@@ -59,7 +62,8 @@
   Adafruit_MQTT_Subscribe *subscription;
   while ((subscription = mqtt.readSubscription(10000))) {

-    if (strcmp((char *)onoffsw.lastread, "{\"On\":1}") == 0) {
+    if (strcmp((char *)onoffsw.lastread, "{\"On\":1}") == 0 && !led_on) {
+      led_on = true;
       Serial.println(F("On"));
       i = 0;
       while (i < brightness) {
@@ -68,7 +72,8 @@
         delay(4);
       }
     }
-    else if (strcmp((char *)onoffsw.lastread, "{\"On\":0}") == 0) {
+    else if (strcmp((char *)onoffsw.lastread, "{\"On\":0}") == 0 && led_on) {
+      led_on = false;
       Serial.println(F("Off"));
       while (i > 10) {
         analogWrite(LED, i);
@@ -81,35 +86,36 @@
     // Check if the brightness setting has been updated
     else if (strncmp((char *)onoffsw.lastread, "{\"Brightness\":", 14) == 0 ) {
       Serial.print(F("Brightness: "));
-
+
       unsigned int l = strlen((char *)onoffsw.lastread);
       onoffsw.lastread[l - 1] = '\0'; // overwrite the ending bracket
       unsigned int bright_perc = atoi((char *)onoffsw.lastread + 14);
       Serial.println(bright_perc);
       unsigned int new_brightness = 1023 * bright_perc / 100;
       if (new_brightness > 1023) new_brightness = 1023;
-
-      if (new_brightness > brightness) {
-        i = brightness;
-        while (i < new_brightness) {
-          analogWrite(LED, i);
-          i += 2;
-          delay(4);
+      if (led_on) {
+        if (new_brightness > i) {
+          while (i < new_brightness) {
+            analogWrite(LED, i);
+            i += 2;
+            delay(4);
+          }
+          analogWrite(LED, new_brightness);
+          i = new_brightness;
+
         }
-        analogWrite(LED, new_brightness);
-        i = new_brightness;
-
+        else {
+          while (i > new_brightness) {
+            analogWrite(LED, i);
+            i -= 1;
+            delay(2);
+
+          }
+          analogWrite(LED, new_brightness);
+          i = new_brightness;
+        }
       }
-      else {
-        while (i > new_brightness) {
-          analogWrite(LED, i);
-          i -= 1;
-          delay(2);
-
-        }
-        analogWrite(LED, new_brightness);
-        i = new_brightness;
-      }
+
       brightness = new_brightness;
     }
   }


added free ram code

added free ram code

--- Arduino/Base/Base.ino
+++ Arduino/Base/Base.ino
@@ -33,6 +33,14 @@
 String nodeId = "";
 String identifier = "";

+
+int freeRam ()
+{
+  extern int __heap_start, *__brkval;
+  int v;
+  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
+}
+
 void setup()
 {
   DEBUG_INIT(9600);
@@ -52,6 +60,7 @@
 }

 void loop(){
+    DEBUG_PRINTLN(freeRam());
   /*
   This limits the sending of updates to the server by sending a maximum of 10 once every minute
   or once the array of requests reaches its maximum
@@ -127,6 +136,7 @@
 			else{
 				DEBUG_PRINTLN(F("Get request returned NULL"));
 			}
+
 		}
 		else if(identifier.equals("U")){
 			xcomm.sendMessage(nodeId, "OK");


more hostcm progress

more hostcm progress

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

--- zimodem/proto_hostcm.ino
+++ zimodem/proto_hostcm.ino
@@ -136,11 +136,11 @@
     sendError("error: file not open %c", inbuf[1]);
     return;
   }
-  if(strchr("RLrl",(char)h->mode)!=0)
+  /*if((h->mode)=='r')||(h->mode=='l'))
   {
     sendError("error: read-only file %c", inbuf[1]);
     return;
-  }
+  }*/
   if(h->format == 'b')
   {
     FROMHEX(&inbuf[3], pkti - 4);


Working on interval messages with encoder

--- ArduinoCode/main/main.ino
+++ ArduinoCode/main/main.ino
@@ -1,3 +1,4 @@
+
 // main.ino
 // Communicates with RPi through serial data stream
 // Steven Rofrano
@@ -122,6 +123,8 @@
 	EIMSK |= (1 << INT0);				// enable external interrupt INT0 (I/O pin 2)
 	EICRA |= (1 << ISC00);				// trigger INT0 on any logical change

+
+

 }

@@ -169,7 +172,7 @@

-	// if (sendMsg) sendSensorData();
+	if (sendMsg) sendSensorData();

 }

@@ -186,4 +189,5 @@
 	sendMsg = true;

-}+}
+


Reduce header count requirement

Reduce header count requirement

--- Arduino_OS_WeatherV26.ino
+++ Arduino_OS_WeatherV26.ino
@@ -62,8 +62,8 @@
 #define ledPin 13          //Human feedback
 #define sDelay 230         //One Quarter Manchester Bit duration
 #define lDelay 460         //One Half Manchester Bit duration
-byte    headerHits=0;      //How many ones detected as a header bit
-byte    headerBits=15;     //How many '1's to detect before accepting it as a valid header
+byte    headerHits= 0;     //How many ones detected as a header bit
+byte    headerBits= 10;    //How many '1's to detect before accepting it as a valid header
 boolean header    = false; //State of header detection
 boolean logic     = false; //State of the Manchester decoding
 byte    signal    = 0;     //state of RF
@@ -83,12 +83,12 @@
 float  rainTotal = 0.0;
 float  rainRate  = 0.0;
 double  temperature = 0.0;
-int     humidity  = 0;
+int     humidity = 0;
 double  intTemp;
 double  intHumi;
 double  intPres;
-int     scan=0; //On start up lower three bits used to show data from all sensors has been received before pooling and sending out data
-byte    activity=0;//6 Bits, Flags whether good or bad checksum for a given sensor received in last minute
+int     scan     = 0; //On start up lower three bits used to show data from all sensors has been received before pooling and sending out data
+byte    activity = 0;//6 Bits, Flags whether good or bad checksum for a given sensor received in last minute
 int     seconds;
 const char windDir[16][4] = {
   "N  ", "NNE", "NE ", "ENE",  "E  ", "ESE", "SE ", "SSE",  "S  ", "SSW", "SW ", "WSW",  "W  ", "WNW", "NW ", "NNW"};


Use digital pin to power the IMU board in order to simplify electronic connection

--- Arduino/MPU9150_MS5611_IMU/MPU9150_MS5611_IMU.ino
+++ Arduino/MPU9150_MS5611_IMU/MPU9150_MS5611_IMU.ino
@@ -177,8 +177,15 @@
 short n_accel_range = 0;
 short n_accel_range_old = 0;

+#define   PIN_5V_1 4
+#define   PIN_0V_1 3
+
 void setup()
 {
+  pinMode(PIN_0V_1, OUTPUT);
+  pinMode(PIN_5V_1, OUTPUT);
+  digitalWrite(PIN_5V_1, HIGH);
+  digitalWrite(PIN_0V_1, LOW);
   // join I2C bus (I2Cdev library doesn't do this automatically)
   Wire.begin();
   Serial.begin(57600); // Start serial at 57600 bps
@@ -263,7 +270,9 @@

 void loop()
-{
+{
+  digitalWrite(PIN_5V_1, HIGH);
+  digitalWrite(PIN_0V_1, LOW);
   //ground_press = baro.getPressure(MS561101BA_OSR_4096);
     processSerialInput();
     if (fabs(millis()-last_baro_read_ms)>1./BaroRate)


Minor fixup

Minor fixup

--- meteo_lcd/meteo_lcd.ino
+++ meteo_lcd/meteo_lcd.ino
@@ -291,10 +291,10 @@
     const int default_state = HIGH; /*assume that button is pull-up*/

     if (digitalRead(pin) != default_state) {
-        delay(50); /*ms*/
+        delay(20); /*ms*/
         if (digitalRead(pin) != default_state) {
             do {} while (digitalRead(pin) == !default_state); // wait for button releases
-            delay(50);
+            delay(20);
             return true;
         }
     }
@@ -546,12 +546,13 @@

     lcd.setCursor(0, 2);
-    if (show_dew_point)
+    lcd.print("                 hPa");
+    if (show_dew_point) {
+      lcd.setCursor(0, 2);
         lcd.print("DP:   ");
-    else
-        lcd.print("      ");
-    lcd.print((char)223); // '°'
-    lcd.print("C         hPa");
+        lcd.print((char)223); // '°'
+        lcd.print("C");
+    }

     lcd.setCursor(0, 3);
     lcd.print("                    ");
@@ -800,6 +801,8 @@

 void loop ()
 {
+    static byte iter;
+    iter = iter + 1;
     LOGLN("Loop");

     if (enter_time_setup())
@@ -809,14 +812,16 @@
     backlight_buttons();

     // Update meteo data
-    float temp_in, humid_in, temp_out, humid_out;
-    int32_t pressure;
-
-    read_meteo_data(temp_in, humid_in, temp_out, humid_out, pressure);
-    fill_data(temp_in, temp_out, humid_in, humid_out, pressure);
+    if (!iter) {
+        float temp_in, humid_in, temp_out, humid_out;
+        int32_t pressure;
+
+        read_meteo_data(temp_in, humid_in, temp_out, humid_out, pressure);
+        fill_data(temp_in, temp_out, humid_in, humid_out, pressure);
+    }

     // Clock icon - optional. Only if show_dew_point is disabled
-    // print_clock()
+    //print_clock();

     // Update the displayed time
     print_time_string(3 /* 4th row */);


agregue un sensor de puerta

agregue un sensor de puerta

--- Arduino/src/sketch.ino
+++ Arduino/src/sketch.ino
@@ -236,7 +236,7 @@
     json="{\"luz\": \[{\"nombre\": \"Entrada\",\"topico\": 22},{\"nombre\": \"Showroom\",\"topico\": 23}]}";
   }
   if(servicio == "sensor"){
-    json="{\"sensor\": [{\"nombre\": \"ambiente\",\"topico\": \"ard1/ambiente/temp\",\"tipo\": \"numero\"}]}";
+    json="{\"sensor\": [{\"nombre\": \"ambiente\",\"topico\": \"ard1/ambiente/temp\",\"tipo\": \"numero\"},{\"nombre\": \"patio\",\"topico\": \"ard1/patio\",\"tipo\": \"bool\"}]}";
   }
     client.publish("resp/discover", json);
 }


Update Arduino sketch to receive optional RGB triplet before on LEDs sequence

--- AndroidThings/arduino/arduino.ino
+++ AndroidThings/arduino/arduino.ino
@@ -9,15 +9,21 @@
 const int LEDS_SIDE = 12;
 const char LED_SEPARATOR = ',';
 const char START = '/';
+const char RED = 'r';
+const char GREEN = 'g';
+const char BLUE = 'b';
 const char END = '!';

 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(LEDS_COUNT, PIXELS_DATA_PIN, NEO_GRB + NEO_KHZ800);
-uint32_t colorOn = pixels.Color(0, 255,255);
+uint32_t colorOn;
 uint32_t colorOff = pixels.Color(0,0,0);

 String readString;
 char c;
 boolean matrix[LEDS_COUNT];
+int r = 0;
+int g = 255;
+int b = 255;

 void setup() {
   pixels.begin();
@@ -36,6 +42,27 @@
       reset();
       break;
     }
+    if (c == RED) {
+      if (readString.length() > 0) {
+        r = stringToInt(readString);
+        readString="";
+      }
+      break;
+    }
+    if (c == GREEN) {
+      if (readString.length() > 0) {
+        g = stringToInt(readString);
+        readString="";
+      }
+      break;
+    }
+    if (c == BLUE) {
+      if (readString.length() > 0) {
+        b = stringToInt(readString);
+        readString="";
+      }
+      break;
+    }
     if (c == END) {
       break;
     }
@@ -43,9 +70,7 @@
   }

   if (readString.length() > 0) {
-    char carray[readString.length() + 1];
-    readString.toCharArray(carray, sizeof(carray));
-    int ledIndex = atoi(carray);
+    int ledIndex = stringToInt(readString);
     if (ledIndex < LEDS_COUNT) {
       matrix[ledIndex] = true;
     }
@@ -55,6 +80,7 @@

   if (c == END) {
     // logMatrix(); //Useful for debugging
+    colorOn = pixels.Color(r, g, b);
     updateLEDs();
     pixels.show();
     c = ' ';
@@ -65,6 +91,12 @@
   for (int i=0; i<LEDS_COUNT; i++) {
     matrix[i] = false;
   }
+}
+
+int stringToInt(String string) {
+  char carray[readString.length() + 1];
+  readString.toCharArray(carray, sizeof(carray));
+  return atoi(carray);
 }

 void logMatrix() {


this is the main file

this is the main file

--- MyBlinkySketch/MyBlinkySketch.ino
+++ MyBlinkySketch/MyBlinkySketch.ino
@@ -4,7 +4,7 @@
 #--------- oddacon@live.com ----------#
 #------------------------------------*/
 // This is my version of Blinkinlab's Blinkytape 'ProductionSketch'
-// Most of these examples I found and rewrote for BlinkyTape. Enjoy ^_^
+// Most of these examples I found and re-wrote for BlinkyTape. Enjoy! ^_^

 #include <EEPROM.h>
 #include <FastLED.h>
@@ -24,7 +24,7 @@
 #include "Scanner.h"
 #include "SerialLoop.h"
 #include "Shimmer.h"
-#include "VerticalRainbowLoop.h"
+#include "RandomColorFade.h"
 #include "xmas.h"

 // LED data array
@@ -67,8 +67,8 @@
 // Our patterns
 ColorSwirl OriginalColorSwirl(1,1,1);
 RainbowLoop OriginalRainbowLoop(CRGB(0, 0, 0));
-VerRainbowLoop OriginalVerRainbowLoop(CRGB(0, 0, 0));
 ColorFade OriginalColorFade(CRGB(0, 0, 0));
+RndColFade OriginalRndColFade(CRGB(0, 0, 0));
 ColorPulse Pulse(CRGB(255, 0, 0)); //red
 Scanner scanner(4, CRGB(255,0,0)); //red
 Flicker flicker(CRGB(0,0,0));
@@ -78,7 +78,7 @@
 RandomColorPop RandomColorPopLoop(CRGB(0,0,0));
 Shimmer shimmer(1,1,1);
 RandomMarch RandomMarchLoop(CRGB(0,0,0));
-RWBMarch RWBMarchLoop(CRGB(0,0,0));
+RWBMarch RWBMarchLoop(CRGB(0,0,0));
 ColorLoop1 xmas(CRGB(0, 0, 0));

@@ -175,21 +175,21 @@
   PCICR  |= (1 << PCIE0);  // Enable interrupt

-  registerPattern(&OriginalColorSwirl);
-  registerPattern(&OriginalRainbowLoop);
-  registerPattern(&OriginalVerRainbowLoop);
-  registerPattern(&OriginalColorFade);
-  registerPattern(&Pulse);
-  registerPattern(&scanner);
-  registerPattern(&flicker);
-  registerPattern(&flashlight);
-  registerPattern(&EMS);
-  registerPattern(&OriginalMatrix);
-  registerPattern(&RandomColorPopLoop);
-  registerPattern(&shimmer);
-  registerPattern(&RandomMarchLoop);
-  registerPattern(&RWBMarchLoop);
-  registerPattern(&xmas);
+registerPattern(&OriginalColorSwirl);
+registerPattern(&OriginalRainbowLoop);
+registerPattern(&OriginalColorFade);
+registerPattern(&OriginalRndColFade);
+registerPattern(&Pulse);
+registerPattern(&scanner);
+registerPattern(&flicker);
+registerPattern(&flashlight);
+registerPattern(&EMS);
+registerPattern(&OriginalMatrix);
+registerPattern(&RandomColorPopLoop);
+registerPattern(&shimmer);
+registerPattern(&RandomMarchLoop);
+registerPattern(&RWBMarchLoop);
+registerPattern(&xmas);

   // If the EEPROM hasn't been initialized, do so now
@@ -232,4 +232,3 @@
   }
   LEDS.show();
 }
-


Modified sketch to use byte flags for each button

--- megaDriveTesting/megaDriveTesting.ino
+++ megaDriveTesting/megaDriveTesting.ino
@@ -5,6 +5,15 @@
 int leftPin = 9;
 int rightPin = 8;
 int startCPin = 7;
+
+byte upFlag = B00000001;
+byte downFlag = B00000010;
+byte leftFlag = B00000100;
+byte rightFlag = B00001000;
+byte aFlag = B00010000;
+byte bFlag = B00100000;
+byte cFlag = B01000000;
+byte startFlag = B10000000;

 void setup() {
   // put your setup code here, to run once:
@@ -23,37 +32,37 @@
   digitalWrite(selectPin, LOW);
   if(digitalRead(upPin) == LOW)
   {
-    Serial.write("UP pressed\n");
+    Serial.write(upFlag);
   }
   if(digitalRead(downPin) == LOW)
   {
-    Serial.write("DOWN pressed\n");
+    Serial.write(downFlag);
   }
   if(digitalRead(aBPin) == LOW)
   {
-    Serial.write("A pressed\n");
+    Serial.write(aFlag);
   }
   if(digitalRead(startCPin) == LOW)
   {
-    Serial.write("START pressed\n");
+    Serial.write(startFlag);
   }

   // now poll the buttons with Select=+5V
   digitalWrite(selectPin, HIGH);
   if(digitalRead(leftPin) == LOW)
   {
-    Serial.write("LEFT pressed\n");
+    Serial.write(leftFlag);
   }
   if(digitalRead(rightPin) == LOW)
   {
-    Serial.write("RIGHT pressed\n");
+    Serial.write(rightFlag);
   }
   if(digitalRead(aBPin) == LOW)
   {
-    Serial.write("B pressed\n");
+    Serial.write(bFlag);
   }
   if(digitalRead(startCPin) == LOW)
   {
-    Serial.write("C pressed\n");
+    Serial.write(cFlag);
   }
 }


moving on

moving on

--- arduino/vaz2103mon.ino
+++ arduino/vaz2103mon.ino
@@ -4,41 +4,43 @@

   This example code is in the public domain.
  */
+int ledPin = 13;

 void setup() {
   // initialize the digital pin as an output.
   // Pin 13 has an LED connected on most Arduino boards:
   pinMode(13, OUTPUT);
+  //init the PWM pins
+  pinMode(3, OUTPUT);
+  pinMode(5, OUTPUT);
+  pinMode(6, OUTPUT);
+  pinMode(9, OUTPUT);
+  pinMode(10, OUTPUT);
   pinMode(11, OUTPUT);
+  //init serial
+  Serial.begin(9600);
 }

 void loop() {

+// this part is from http://www.suffix.be/blog/send-data-to-arduino
+// some info on PWM here: http://www.uchobby.com/index.php/2008/02/12/arduino-analog-gauge/
+// need to add resistors
+ if (Serial.available() > 0) {
+//    char value = Serial.read();
+    int value = Serial.parseInt();
+    if (value > 1) {
+      if (value < 256) {
+        analogWrite(11, value);
+      }
+    }
+/*    if (value == '1') {
+      digitalWrite(ledPin, HIGH);
+    } else {
+      digitalWrite(ledPin, LOW);
+    } */
+    Serial.println(value);
+  }

-for (int i=1; i<15; i+=1)
-{
-  for(int j=1; j<x;j++)
-   {
-     digitalWrite(13, HIGH);   // set the LED on
-     delay(10);              // wait for a second
-     digitalWrite(13, LOW);    // set the LED off
-     delay(i);  // wait for a second
-
-   }
-   int qq=i*10;
-   analogWrite(11, qq);
-}
-for (int i=15; i>1; i-=1)
-{
-  for(int j=1; j<x;j++)
-   {
-    digitalWrite(13, HIGH);   // set the LED on
-    delay(10);              // wait for a second
-    digitalWrite(13, LOW);    // set the LED off
-    delay(i);  // wait for a second
-   }
-   int qq=i*10;
-   analogWrite(11, qq);
-}
 }


Changed volume increments

Changed volume increments

--- arduino_signal/arduino_signal.ino
+++ arduino_signal/arduino_signal.ino
@@ -44,9 +44,17 @@
       SendVolUpCode();
       delay(1);
       SendVolUpCode();
+      delay(1);
+      SendVolUpCode();
+      delay(1);
+      SendVolUpCode();
       break;
       case 122:
       Serial.write('4');
+      SendVolDownCode();
+      delay(1);
+      SendVolDownCode();
+      delay(1);
       SendVolDownCode();
       delay(1);
       SendVolDownCode();


Rename arduino source file

Rename arduino source file

--- arduino/src/salalivre.ino
+++ arduino/src/salalivre.ino
@@ -1,125 +0,0 @@
-// http://archive.wired.com/geekdad/2012/09/using-motion-detectors-with-an-arduino/
-// https://github.com/prampec/arduino-softtimer/blob/wiki/WhyHow.md
-// https://nurdspace.nl/ESP8266
-// http://contractorwolf.com/esp8266-wifi-arduino-micro
-// http://www.instructables.com/id/ESP8266-Wifi-Temperature-Logger/
-
-#include <AltSoftSerial.h>
-#include <SoftTimer.h>
-
-String ID = "1D";
-String SSID = "";
-String PASS = "";
-
-int SERVER_PORT = 5000;
-String SERVER_ADDRESS = "192.168.23.104";
-String healthcheckAction = "GET /healthcheck/" + ID;
-String eventAction = "POST /room/" + ID + "/event";
-
-int sensor = 2;
-int light = 13;
-bool presenceDetected = false;
-
-AltSoftSerial wifi(8, 9); // RX, TX
-
-Task wifiTask(30000, sendStatus);
-Task sensorTask(1200, detectPresence);
-Task blinkTask(500, pblink);
-
-void setup() {
-    pinMode(sensor, INPUT);
-    pinMode(light, OUTPUT);
-
-    Serial.begin(9600);
-    while(!connectWiFi()) {
-      Serial.println("Retrying connect to network");
-    }
-
-    digitalWrite(light, HIGH);
-
-    SoftTimer.add(&blinkTask);
-    SoftTimer.add(&sensorTask);
-    SoftTimer.add(&wifiTask);
-}
-
-boolean toggle = false;
-void pblink(Task* me) {
-    if (presenceDetected) {
-      toggle = !toggle;
-      digitalWrite(light, toggle ? LOW : HIGH);
-      Serial.print("blink ");
-      Serial.println(toggle);
-    }
-}
-
-void detectPresence(Task* me) {
-    if (!presenceDetected) {
-      presenceDetected = digitalRead(sensor) == HIGH;
-    }
-
-    Serial.println(presenceDetected ? "There is something here" : "No presence detected");
-}
-
-void sendStatus(Task* me) {
-    if (presenceDetected) {
-        registerEvent();
-        presenceDetected = false;
-    } else {
-        healthcheck();
-    }
-}
-
-
-void healthcheck() {
-    request(SERVER_ADDRESS, SERVER_PORT, healthcheckAction);
-}
-
-void registerEvent() {
-    request(SERVER_ADDRESS, SERVER_PORT, eventAction);
-}
-
-
-void request(String host, int port, String action) {
-    wifi.println("AT+CIPSTART=\"TCP\",\"" + host + "\"," + port);
-    delay(2000);
-    if (wifi.find("Error")) {
-        Serial.println("Connection error");
-        return;
-    }
-
-    Serial.print("Requesting " + action + "... ");
-    action = action + " HTTP/1.0\r\n\r\n";
-    wifi.print("AT+CIPSEND=");
-    delay(100);
-    wifi.println(action.length());
-    delay(500);
-    wifi.println(action);
-    delay(1000);
-    //wifi.println("AT+CIPCLOSE");
-    Serial.println("ok");
-    wifi.flush();
-}
-
-boolean connectWiFi() {
-    wifi.begin(9600);
-
-    Serial.print("Connecting... ");
-
-    wifi.println("AT");
-    if (!wifi.find("OK")) {
-        Serial.println("error connecting module");
-        return false;
-    }
-
-    wifi.println("AT+RST");
-    wifi.println("AT+CWMODE=1");
-    delay(500); //delay after mode change
-    wifi.println("AT+CWJAP=\"" + SSID + "\",\"" + PASS + "\"");
-    if (wifi.find("OK")) {
-        Serial.println("error connecting AP");
-        return false;
-    }
-
-    Serial.println("ok");
-    return true;
-}


Reduce cost of time stamping by factor 4

--- projects/RF12_Yun_DataLogger/RF12_Yun_DataLogger.ino
+++ projects/RF12_Yun_DataLogger/RF12_Yun_DataLogger.ino
@@ -11,9 +11,10 @@
 #include <Bridge.h>
 #include <JeeLib.h>

-// temperature node: expected data structure
+// temperature node data structure. Timestamp created locally, at time of receival.
 typedef struct
 {
+    String timeStamp;   // "+%Y-%m-%d %T": format "YYYY-MM-DD hh:mm:ss"
     byte rf12_group;    // RF12 group ID
     byte rf12_nodeid;   // RF12 node ID
     float Vcc;          // Supply voltage
@@ -22,9 +23,9 @@

 dataPackageStruc dataPackage;

-// Data logging and time stamping from http://arduino.cc/en/Tutorial/YunDatalogger
+// data logging and time stamping from http://arduino.cc/en/Tutorial/YunDatalogger
 #include <FileIO.h>
-String fileName, timeStamp, dataStr, rawdataStr;
+String fileName, dataStr, rawdataStr;
 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

@@ -38,7 +39,7 @@

     Serial.begin(57600);
     Serial.println("***");
-    Serial.println("*** 150103 Yun RF12 Data Logger");
+    Serial.println("*** 150105 Yun RF12 Data Logger");
     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");
@@ -77,14 +78,17 @@
         //
         // Log measurement data to file
         //
-        dataStr = getTimeStamp() + ","
+        dataPackage.timeStamp = getTimeStamp();
+        dataStr = dataPackage.timeStamp + ","
                   + String(dataPackage.rf12_group) + ","
                   + String(dataPackage.rf12_nodeid) + ","
                   + String(dataPackage.Vcc) + ","
                   + String(dataPackage.T);

         // open file, one one can be open at a time
-        fileName = "/mnt/sda1/datalogs/" + getDate() + "_RF12.dat";
+        fileName = "/mnt/sda1/datalogs/"
+                   + dataPackage.timeStamp.substring(0, 10)
+                   + "_RF12.dat";
         // convert fileName string to char array
         fileName.toCharArray(__fileName_data, sizeof(__fileName_data));
         File dataFile = FileSystem.open(__fileName_data, FILE_APPEND);
@@ -106,7 +110,7 @@
         //
         // Log raw data to separate file, to prevent data gets lost or misinterpreted
         //
-        rawdataStr = getTimeStamp() + ","
+        rawdataStr = dataPackage.timeStamp + ","
                      + String(dataPackage.rf12_group) + ","
                      + String(dataPackage.rf12_nodeid);
         for (byte i = 0; i < rf12_len; ++i)
@@ -115,7 +119,9 @@
             rawdataStr += rf12_data[i];
         }
         // open file, one one can be open at a time
-        fileName = "/mnt/sda1/datalogs/" + getDate() + "_RF12_raw.dat";
+        fileName = "/mnt/sda1/datalogs/"
+                   + dataPackage.timeStamp.substring(0, 10)
+                   + "_RF12_raw.dat";
         // convert fileName string to char array
         fileName.toCharArray(__fileName_rawdata, sizeof(__fileName_rawdata));
         File rawdataFile = FileSystem.open(__fileName_rawdata, FILE_APPEND);
@@ -143,28 +149,6 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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


Update magnetometer.ino

Update magnetometer.ino

--- code/magnetometer.ino
+++ code/magnetometer.ino
@@ -7,18 +7,18 @@
 #define YAXIS 1
 #define ZAXIS 2

-#define M1// to be filled after calibration
-#define M2
-#define M3
-#define M4
-#define M5
-#define M6
-#define M7
-#define M8
-#define M9
-#define B1
-#define B2
-#define B3
+#define M1 0.988692
+#define M2 -0.005989
+#define M3 -0.014164
+#define M4 -0.005989
+#define M5 1.048870
+#define M6 -0.023919
+#define M7 -0.014164
+#define M8 -0.023919
+#define M9 0.988458
+#define B1 37.589576
+#define B2 4.844294
+#define B3 132.379174

 #define MAGNET_SCALING_FACTOR
 double heading;


Fix naming of member variables.

Fix naming of member variables.

--- examples/adsr/adsr.ino
+++ examples/adsr/adsr.ino
@@ -102,14 +102,14 @@
     container_outer_->attach_child(container_adsr_, 1);
     container_adsr_->attach_scroll_callback_array(adsr_scroll_callback);

-    gate = retrigger = false;
-    selected_env = 0;
-    debounce = 0;
-    env = 0;
-    gate_time = 0;
-    release_time = 0;
-    last_selected_env = 0;
-    last_gate = false;
+    gate_ = retrigger_ = false;
+    selected_env_ = 0;
+    debounce_ = 0;
+    env_ = 0;
+    gate_time_ = 0;
+    release_time_ = 0;
+    last_selected_env_ = 0;
+    last_gate_ = false;

     gt_attach_interrupt(GT3, gate_isr, CHANGE);
     gt_attach_interrupt(GT4, switch_isr, FALLING);
@@ -122,10 +122,10 @@
     }
     for (uint8_t e = 0; e < 2; ++e)
     {
-      adsr_values[e].A = uint16_t(widget_save_->params.vals.v[2 * e]) * 24;
-      adsr_values[e].D = uint16_t(widget_save_->params.vals.v[2 * e + 1]) * 24;
-      adsr_values[e].S = (float(widget_save_->params.vals.v[2 * e + 2]) / float(V_MAX)) * ENV_PEAK;
-      adsr_values[e].R = uint16_t(widget_save_->params.vals.v[2 * e + 3]) * 24;
+      adsr_values_[e].A = uint16_t(widget_save_->params.vals.v[2 * e]) * 24;
+      adsr_values_[e].D = uint16_t(widget_save_->params.vals.v[2 * e + 1]) * 24;
+      adsr_values_[e].S = (float(widget_save_->params.vals.v[2 * e + 2]) / float(V_MAX)) * ENV_PEAK;
+      adsr_values_[e].R = uint16_t(widget_save_->params.vals.v[2 * e + 3]) * 24;
     }

     // draw title
@@ -155,80 +155,80 @@

   virtual void function_loop()
   {
-    if (retrigger)
-    {
-      env = selected_env;
-      gate_time = 0;
-      release_time = 0;
-      retrigger = false;
-    }
-
-    if (gate_time)
-    {
-      if (gate)
-      {
-        uint16_t elapsed = millis() - gate_time;
-        if (elapsed < adsr_values[env].A)
+    if (retrigger_)
+    {
+      env_ = selected_env_;
+      gate_time_ = 0;
+      release_time_ = 0;
+      retrigger_ = false;
+    }
+
+    if (gate_time_)
+    {
+      if (gate_)
+      {
+        uint16_t elapsed = millis() - gate_time_;
+        if (elapsed < adsr_values_[env_].A)
         {
           // attack
-          cv_current = ENV_PEAK * ENV_SATURATION * (1.0 - exp(-(float(elapsed) / float(adsr_values[env].A))));
+          cv_current_ = ENV_PEAK * ENV_SATURATION * (1.0 - exp(-(float(elapsed) / float(adsr_values_[env_].A))));
         }
         else
         {
           // decay/sustain
-          cv_current = adsr_values[env].S + (ENV_PEAK - adsr_values[env].S)
-              * exp(ENV_DECAY_COEFF * (float(elapsed - adsr_values[env].A) / float(adsr_values[env].D)));
+          cv_current_ = adsr_values_[env_].S + (ENV_PEAK - adsr_values_[env_].S)
+              * exp(ENV_DECAY_COEFF * (float(elapsed - adsr_values_[env_].A) / float(adsr_values_[env_].D)));
         }
       }
       else
       {
-        if (release_time)
+        if (release_time_)
         {
-          uint16_t elapsed = millis() - release_time;
-          if(elapsed < adsr_values[env].R * ENV_RELEASE_HOLD)
+          uint16_t elapsed = millis() - release_time_;
+          if(elapsed < adsr_values_[env_].R * ENV_RELEASE_HOLD)
           {
             // release
-            cv_current = exp(ENV_RELEASE_COEFF * (float(elapsed) / float(adsr_values[env].R))) * cv_released;
+            cv_current_ = exp(ENV_RELEASE_COEFF * (float(elapsed) / float(adsr_values_[env_].R))) * cv_released_;
           }
           else
           {
-            cv_current = 0.0;
-            release_time = 0;
-            gate_time = 0;
+            cv_current_ = 0.0;
+            release_time_ = 0;
+            gate_time_ = 0;
           }
         }
         else
         {
-          release_time = millis();
-          cv_released = cv_current;
+          release_time_ = millis();
+          cv_released_ = cv_current_;
         }
       }

-      cv_out(CO1, cv_current);
-      cv_out(CO3, cv_current / 2.0);
-    }
-    else if (gate)
-    {
-      gate_time = millis()
-          - (unsigned long)(-float(adsr_values[env].A) * log(1 - (cv_current / (ENV_PEAK * ENV_SATURATION))));
+      cv_out(CO1, cv_current_);
+      cv_out(CO3, cv_current_ / 2.0);
+    }
+    else if (gate_)
+    {
+      gate_time_ = millis()
+          - (unsigned long)(-float(adsr_values_[env_].A) * log(1 - (cv_current_ / (ENV_PEAK * ENV_SATURATION))));
     }

     widget_loop();

     // display selected envelope
-    if (selected_env != last_selected_env)
-    {
-      last_selected_env = selected_env;
+    if (selected_env_ != last_selected_env_)
+    {
+      last_selected_env_ = selected_env_;
       Display.fill_rect(53, 55, 7, 9, DUINO_SH1106::Inverse);
       Display.fill_rect(68, 55, 7, 9, DUINO_SH1106::Inverse);
       Display.display(53, 74, 6, 7);
     }

     // display gate
-    if (gate != last_gate)
-    {
-      last_gate = gate;
-      if (gate)
+    if (gate_ != last_gate_)
+    {
+      last_gate_ = gate_;
+      if (gate_)
       {
         Display.draw_bitmap_7(60, 25, icons, 0, DUINO_SH1106::White);
       }
@@ -242,20 +242,20 @@

   void gate_callback()
   {
-    gate = gt_read_debounce(DUINO_Function::GT3);
-    if (gate)
-    {
-      retrigger = true;
+    gate_ = gt_read_debounce(DUINO_Function::GT3);
+    if (gate_)
+    {
+      retrigger_ = true;
     }
   }

   void switch_callback()
   {
-    if (millis() - debounce > DEBOUNCE_MS)
-    {
-      selected_env++;
-      selected_env %= 2;
-      debounce = millis();
+    if (millis() - debounce_ > DEBOUNCE_MS)
+    {
+      selected_env_++;
+      selected_env_ %= 2;
+      debounce_ = millis();
     }
   }

@@ -275,16 +275,16 @@
       switch (selected % 4)
       {
         case 0:
-          adsr_values[e].A = uint16_t(widget_save_->params.vals.v[selected]) * 24;
+          adsr_values_[e].A = uint16_t(widget_save_->params.vals.v[selected]) * 24;
           break;
         case 1:
-          adsr_values[e].D = uint16_t(widget_save_->params.vals.v[selected]) * 24;
+          adsr_values_[e].D = uint16_t(widget_save_->params.vals.v[selected]) * 24;
           break;
         case 2:
-          adsr_values[e].S = (float(widget_save_->params.vals.v[selected]) / float(V_MAX)) * ENV_PEAK;
+          adsr_values_[e].S = (float(widget_save_->params.vals.v[selected]) / float(V_MAX)) * ENV_PEAK;
           break;
         case 3:
-          adsr_values[e].R = uint16_t(widget_save_->params.vals.v[selected]) * 24;
+          adsr_values_[e].R = uint16_t(widget_save_->params.vals.v[selected]) * 24;
           break;
       }

@@ -304,15 +304,15 @@
   DUINO_SaveWidget<ParameterValues> * widget_save_;
   DUINO_DisplayWidget * widgets_adsr_[8];

-  volatile bool gate, retrigger;
-  volatile uint8_t selected_env;
-  volatile unsigned long debounce;
-  DU_ADSR_Values adsr_values[2];
-  uint8_t env;
-  unsigned long gate_time, release_time;
-  float cv_current, cv_released;
-  uint8_t last_selected_env;
-  bool last_gate;
+  volatile bool gate_, retrigger_;
+  volatile uint8_t selected_env_;
+  volatile unsigned long debounce_;
+  DU_ADSR_Values adsr_values_[2];
+  uint8_t env_;
+  unsigned long gate_time_, release_time_;
+  float cv_current_, cv_released_;
+  uint8_t last_selected_env_;
+  bool last_gate_;
 };

 DU_ADSR_Function * function;


Remove unused display flag.

Remove unused display flag.

--- examples/test/test.ino
+++ examples/test/test.ino
@@ -113,7 +113,6 @@
  public:
   virtual void setup()
   {
-    display_changed = false;
     last_calibration_value = 0;

     display->draw_logick_logo(0, 0, DUINO_SH1106::White);
@@ -240,7 +239,6 @@
     }
   }

-  bool display_changed;
   int8_t last_calibration_value;
 };


added images

added images

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -5,6 +5,12 @@
 #include <GraphicDisplay.h>
 #include <SM125.h> //RFID
 #include <SoundPlayer.h>
+
+//Game ID
+#define GAME_ID 0x01 //tictactoe
+//Board ID
+#define BOARD_ID 0x01 //TODO: Change it for each board
+

 // Hardware addresses
 #define DISPLAY_ADDRESS  0x51
@@ -16,6 +22,11 @@
 #define YOU_LOSE 0x3 //The Rival wins :-(
 #define VICTORY_LOOP 0x4 //Victory loop!!!
 #define NO_NO 0x5 //Illegal move
+// Image addresses
+#define GAME_OVER 0x0049
+#define WINNER 0x00DB
+#define TICTACTOE 0x0092
+#define DOWN_OFFSET 11 // How many pixels we are leaving for the status bar

 // Communication msgs
 String MSG_REGISTER = "REGISTER"; // id
@@ -153,7 +164,8 @@
     // 3 -Check victory conditions
     greenVictory = checkWin(greenStatus);
     if (greenVictory){
-      printMsg("A winner is you"); //TODO think some proper msgs
+      //printMsg("A winner is you");
+      display.drawImage(0x0000, WINNER, 0, DOWN_OFFSET);
       soundPlayer.play(YOU_WIN);
       victoryLoop('g');
     }
@@ -178,8 +190,9 @@
     // 3 -Check victory conditions
     redVictory = checkWin(redStatus);
     if (redVictory){
-      printMsg("You lose!");
-     soundPlayer.play(YOU_LOSE);
+      //printMsg("You lose!");
+      display.drawImage(0x0000, GAME_OVER, 0, DOWN_OFFSET);
+      soundPlayer.play(YOU_LOSE);
       victoryLoop('r');
     }
   }
@@ -190,9 +203,17 @@
  **********************************************/

 void initializeHardwarePeripherals(){
+  initializeScreen();
+  display.printText("Initializing...", 6, 1, GREEN);
   initializeRFID();
   initializeSoundPlayer();
-  initializeScreen();
+  initializeBoard();
+}
+
+void initializeBoard(){
+  // TODO program it once the protocol is defined in the board
+  // Send game ID
+  // Send board ID
 }

 void initializeRFID(){
@@ -233,15 +254,18 @@
 /**********************************************
  *   SCREEN PRONTS
  **********************************************/
+
+

 void doWelcome(){
   display.clear();
   soundPlayer.stop();
-  display.printText("Welcome to the tictactoe game!", 6, 1, BLUE);
+  //display.printText("Welcome to the tictactoe game!", 6, 1, BLUE);
+  display.drawImage(0x0000, TICTACTOE, 0, DOWN_OFFSET);
   soundPlayer.play(WELCOME);
   delay(1000);
   display.clear();
-  display.printText("Press green button to find another player...", 6, 1, GREEN);
+  display.printText("Press the green button to find another player...", 6, 1, GREEN);
   boolean doLoop = true;
   while(doLoop){
     if (display.buttonsChanged()) {


Fixed arduino font rendering

Fixed arduino font rendering

--- libgame/libgame.ino
+++ libgame/libgame.ino
@@ -220,14 +220,13 @@
         int pos = (int)*c * 5;
         for (int i = 0; i < 5; ++i)
         {
-            uint8_t d = ((const unsigned char*)pgm_read_pointer(&font_data))[pos + i];
+            uint8_t d = pgm_read_byte_near(font_data + pos + i);
             if ((d >> (game_render_y - yy)) & 1)
                 game_render_buf[xx + i] = game_make_color(color);
         }
         xx += 6;
     }
 }
-

 bool game_is_button_pressed(uint8_t button)
 {


Use static MQTT port

Use static MQTT port

--- esp8266-MagicMushroom.ino
+++ esp8266-MagicMushroom.ino
@@ -44,7 +44,7 @@
   }

   mqttClient.setClient(wifiClient);
-  mqttClient.setServer(MQTT_HOST, MQTT_PORT);
+  mqttClient.setServer(MQTT_HOST, 1883);

   ArduinoOTA.setHostname(WIFI_HOSTNAME);
   ArduinoOTA.setPassword(OTA_PASSWORD);


Time.h to TimeLib.h

Time.h to TimeLib.h

--- jemmaclock/jemmaclock.ino
+++ jemmaclock/jemmaclock.ino
@@ -15,7 +15,7 @@
 #ifndef _HEADERS_JEMMA
 #define _HEADERS_JEMMA

-#include <Time.h>
+#include <TimeLib.h>
 #include <EEPROM.h>
 #include <LiquidCrystal.h>
 #include <TinyGPS++.h>


Change pins for v2 PCB

Change pins for v2 PCB

--- Arduino/TurquoiseBicuspidATTinyBLE.ino
+++ Arduino/TurquoiseBicuspidATTinyBLE.ino
@@ -1,7 +1,10 @@
 #include <SoftwareSerial.h>

 // ATtiny settings: ATtiny85 @8MHz (internal oscillator; BOD disabled), burn bootloader
-SoftwareSerial btSerial(1, 2); // ATtiny RX, TX: HM10 TX, RX
+SoftwareSerial btSerial(2, 1); // ATtiny RX, TX: HM10 TX, RX
+// ATtiny   HM-10
+// 2 -------> TX
+// 1 -------> RX

 // Global
 int TIME_START = 0;
@@ -28,7 +31,7 @@
   pinMode(REDPIN, OUTPUT);
   pinMode(GREPIN, OUTPUT);
   pinMode(BLUPIN, OUTPUT);
-
+
   // AC-BT v4 defaults to 9600.
   btSerial.begin(9600);
   //btSerial.write("AT+RENEW"); // Reset all settings.


added msg for Albert

added msg for Albert

--- gestureDetection/gestureDetection.ino
+++ gestureDetection/gestureDetection.ino
@@ -18,8 +18,9 @@
  *
  *In each execution loop, we first acquire the accel readings (need to determine freq (John's job)) and ADC reading of flex sensor
  *use switch cases to see which state we should be in, if there is a state change, we go into that state
+ *
  *Albert's task: set up different states and action in those states(now just use distinguishable LED pattern so we can debug. Use serial.print for prelimanary testing but not in final testing)
- *
+ *For example: use LED intensity to show degress of rotation of hand, use distinct blinking patterns to indicate forward_drive and idle state
  */

 /*notes on unit conversion*/
@@ -40,7 +41,7 @@

 #include<Wire.h>
 #define relax(a) (((a)<(650))? (true):(false)) //whehter a finger is in relax state
-enum state {forward_drive, backup, left_turn, right_turn, catapult_throw};
+enum state {forward_drive, backup, left_turn, right_turn, catapult_throw}; //catapult_throw should be an interrupt, not a state
 const int MPU=0x68;  // I2C address of the MPU-6050
 int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
 bool indexRelax, middleRelax, ringRelax;


chaging servername to RF_SERVER_ADDRESS

chaging servername to RF_SERVER_ADDRESS

--- nest-rest.ino
+++ nest-rest.ino
@@ -3,13 +3,11 @@
 #include <RF22.h>
 #include <SPI.h>
 #include <avr/pgmspace.h>
-
 #include <EtherCard.h>

+#define RF_SERVER_ADDRESS 0

-#define SERVER_ADDRESS 0
-
-RF22ReliableDatagram manager(SERVER_ADDRESS, 8, 0);
+RF22ReliableDatagram manager(RF_SERVER_ADDRESS, 8, 0);

 static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };


disabled "e" command

disabled "e" command

--- ptw-wheel.ino
+++ ptw-wheel.ino
@@ -93,19 +93,19 @@
     }
     // set effect color
     // "e:[000-255].[000-255].[000-255];"
-    else if(command=="e") {
-      Serial.println(command);
-      if(argument.length()==11) {
-        e_color_r = argument.substring(0,3).toInt();
-        e_color_g = argument.substring(4,7).toInt();
-        e_color_b = argument.substring(8,11).toInt();
-        updateLED();
-      }
-      else {
-        Serial.print("Invalid argument: ");
-        Serial.println(argument);
-      }
-    }
+    // else if(command=="e") {
+    //   Serial.println(command);
+    //   if(argument.length()==11) {
+    //     e_color_r = argument.substring(0,3).toInt();
+    //     e_color_g = argument.substring(4,7).toInt();
+    //     e_color_b = argument.substring(8,11).toInt();
+    //     updateLED();
+    //   }
+    //   else {
+    //     Serial.print("Invalid argument: ");
+    //     Serial.println(argument);
+    //   }
+    // }
     // set effect_brightness_target value
     // "b:[0.0-1.0];"
     else if(command=="E") {