RF24 receiver attached to the MOTOR BOARD

--- RF24_Receiver/RF24_Receiver.ino
+++ RF24_Receiver/RF24_Receiver.ino
@@ -1,65 +1,159 @@

-#include <ArduinoRobot.h>
-//#include <SPI.h>
+/***** NB FOR MOTOR BOARD ***/
+
+#define DEVICE_ID 'D';
+
+//#define RX_ADDRESS "AAAAA"
+//#define RX_ADDRESS "BBBBB"
+//#define RX_ADDRESS "CCCCC"
+#define RX_ADDRESS "DDDDD"
+//#define RX_ADDRESS "EEEEE"
+// @todo: hardware defined address
+
+#define BASE_ADDRESS "1BASE"
+
+#include <ArduinoRobotMotorBoard.h>
+#include <SPI.h>
 #include "nRF24L01.h"
 #include "RF24.h"
-//#include "printf.h"
+#include "printf.h"

-#define PIN_CE  TKD4
-#define PIN_CSN TKD3
+#define PIN_CE  TK4
+#define PIN_CSN TK2

-
-byte addresses[][6] = {"1Node","2Node"};
+// The address that this node listens on
+byte address[6] = RX_ADDRESS;
+byte address_base[6] = BASE_ADDRESS;
+int ack = 0;

 RF24 radio(PIN_CE, PIN_CSN);

+/**
+ * Be carefull to ensure the struct size is the same as on the Pi.
+ * Just having the same size variables is not enough.
+ * @see http://www.delorie.com/djgpp/v2faq/faq22_11.html
+ */
+typedef struct{
+  int32_t timestamp;
+  uint16_t msg_id;
+  uint16_t vcc;
+  uint16_t a;
+  uint16_t b;
+  uint16_t c;
+  uint16_t d;
+  uint8_t type;
+  uint8_t device_id;
+  int8_t y;
+  int8_t z;
+}
+payload_t;
+payload_t payload;
+
+
+uint16_t msg_id = 0;
+
+
 void setup()
 {
-  //Serial.begin(57600);
-  //printf_begin();
-  //printf("\n\r RF24_Receiver \n\r");
-
+  Serial.begin(57600);
+      while (!Serial) {
+    ; // wait for serial port to connect. Needed for Leonardo only
+  }
+
+  delay(2000);
+  printf_begin();
+  printf("\n\r RF24_Receiver on address: %s \n\r", RX_ADDRESS);
+
   // initialize the robot
-  Robot.begin();
-
-  // initialize the screen
-  Robot.beginTFT();
+  RobotMotor.begin();

   // Setup and configure rf radio
   radio.begin(); // Start up the radio
-  radio.setPayloadSize(2);                // Only two byte payload gets sent (int on arduino) (short on 32bit rpi)
+  radio.setPayloadSize(sizeof(payload_t));
   radio.setAutoAck(1); // Ensure autoACK is enabled
-  radio.setRetries(15,15); // Max delay between retries & number of retries
-  radio.openWritingPipe(addresses[1]); // "ping back"
-  radio.openReadingPipe(1,addresses[0]);
-  radio.startListening(); // Start listening
+  radio.setRetries(0,15); // Max delay between retries & number of retries
+  // Allow optional ack payloads
+  radio.enableAckPayload();

-  //radio.printDetails();                   // Dump the configuration of the rf unit for debugging
+  // Pipe for talking to the base
+  radio.openWritingPipe(address_base);
+
+  // Pipe for listening to the base
+  radio.openReadingPipe(1, address);
+
+  // Start listening
+  radio.startListening();
+
+  radio.printDetails();
+
+
+
+ // Robot.debugPrint(sizeof(payload));
 }

 void loop(void)
 {

+  RobotMotor.parseCommand();
+  RobotMotor.process();
+
   // Check for a message from the controller
   if (radio.available()) {
     // Get the payload
-    /*
-    unsigned long got_time;
-    while (radio.available()) {                                   // While there is data ready
-        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
-      }
-    printf("Got: %lu \n\r", got_time);
-    */
+    // Create the ack payload for the NEXT message.
+    radio.writeAckPayload(1, &ack, sizeof(ack));
+    ack++;
+
+    radio.read( &payload, sizeof(payload));
+    processPayload();

+  }
+
+
+}
+
+void processPayload()
+{
+  //Robot.debugPrint(payload.a);
+
+    printf ("Got: %c %c %ld %d %d %d %d %d %d %d %d \n",
+    payload.device_id,
+    payload.type,
+    payload.timestamp,
+    payload.msg_id,
+    payload.vcc,
+    payload.a,
+    payload.b,
+    payload.c,
+    payload.d,
+    payload.y,
+    payload.z);

-    int got_val;
-    radio.read( &got_val, sizeof(int) );
-
-    if (got_val > 0) {
-      // Do something...
-      //printf("Got: %d \n\r", got_val);
-      Robot.debugPrint(got_val);
+  // Proof of concept
+  if (payload.a == 70) {
+    radio.stopListening();
+
+    // Prepare the message.
+    payload_t payload;
+    payload.device_id = DEVICE_ID;
+    payload.type = 'q';
+    payload.timestamp = millis();
+    payload.msg_id = msg_id;
+    payload.vcc = 0; //@TODO vcc
+    payload.a = 99;
+    payload.b = 0;
+    payload.c = 0;
+    payload.d = 0;
+    payload.y = 0;
+    payload.z = 0;
+
+    printf("sending %d, %d \n", payload.msg_id, payload.a);
+    if (!radio.write( &payload, sizeof(payload))) {
+      printf(" failed.\n\r");
     }

+    msg_id++; // Let it overflow
+    radio.startListening();
   }
 }
+


Added support for reading NV data

Added support for reading NV data

--- Read_Mainpage/Read_Mainpage.ino
+++ Read_Mainpage/Read_Mainpage.ino
@@ -7,6 +7,8 @@
  Upload sketch, start serial monitor, type 'GO' to start sketch running.

  Copyright (c) 2014 Dean Cording
+
+ Updated by Samy Kamkar to support reading NV data (additional 1.5kB total)

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
@@ -168,7 +170,7 @@
   delay(10);

   // Read from MainPage
-  Serial.println("READING...");
+  Serial.println("READING MainPage...");
   digitalWrite(_FCSN_, LOW);
   SPI.transfer(READ);
   SPI.transfer(0);
@@ -181,6 +183,34 @@
   }
   digitalWrite(_FCSN_, HIGH);

+  // Read from NV data (extended endurance)
+  Serial.println("READING NV (extended)...");
+  digitalWrite(_FCSN_, LOW);
+  SPI.transfer(READ);
+  SPI.transfer(0xFA);
+  SPI.transfer(0x00);
+  for (int index = 0; index < 512; index++) {
+    spi_data = SPI.transfer(0x00);
+    Serial.print(index);
+    Serial.print(": ");
+    Serial.println(spi_data);
+  }
+  digitalWrite(_FCSN_, HIGH);
+
+  // Read from NV data (normal endurance)
+  Serial.println("READING NV (normal)...");
+  digitalWrite(_FCSN_, LOW);
+  SPI.transfer(READ);
+  SPI.transfer(0xFC);
+  SPI.transfer(0x00);
+  for (int index = 0; index < 1024; index++) {
+    spi_data = SPI.transfer(0x00);
+    Serial.print(index);
+    Serial.print(": ");
+    Serial.println(spi_data);
+  }
+  digitalWrite(_FCSN_, HIGH);
+
 done:
   Serial.println("DONE");


update copyright and version number

update copyright and version number

--- TICC/TICC.ino
+++ TICC/TICC.ino
@@ -2,12 +2,12 @@
 // TICC.ino - master sketch file
 // TICC Time interval Counter based on TICC Shield using TDC7200
 //
-// Copyright John Ackermann N8UR 2016
+// Copyright John Ackermann N8UR 2016-2017
 // Portions Copyright George Byrkit K9TRV 2016
 // Portions Copyright Jeremy McDermond NH6Z 2016
 // Licensed under BSD 2-clause license

-extern const char SW_VERSION[17] = "20170215.1";    // 15 February 2017 - version 1
+extern const char SW_VERSION[17] = "20170218.1";    // 15 February 2017 - version 1

 //#define DETAIL_TIMING     // if enabled, prints execution time


Delete RGB_Sensor.ino

Delete RGB_Sensor.ino

--- RGB_Sensor.ino
+++ RGB_Sensor.ino
@@ -1,70 +0,0 @@
-#include <Wire.h>
-#include "Adafruit_TCS34725.h"
-
-Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
-
-struct Features {
-  bool lt_10in;
-  uint16_t red;
-  uint16_t green;
-  uint16_t blue;
-};
-
-Features Feature_Extraction() {
-  Features features;
-  //Need a fourth value for getRawData()
-  uint16_t hold;
-
-  tcs.getRawData(&features.red, &features.green, &features.blue, &hold);
-  //colorTemp = tcs.calculateColorTemperature(&features.red, &features.green, &features.blue);
-  //lux = tcs.calculateLux(&features.red, &features.green, &features.blue);
-
-  //Delete later, use for testing
-  Serial.print("R: "); Serial.print(features.red, DEC); Serial.print(" ");
-  Serial.print("G: "); Serial.print(features.green, DEC); Serial.print(" ");
-  Serial.print("B: "); Serial.print(features.blue, DEC); Serial.print(" ");
-  Serial.println(" ");
-
-  return features;
-}
-
-String Pattern_Recognition(Features features) {
-  String fruit;
-
-  //FIXME: k nearest neighbor algorithm
-
-  return fruit;
-}
-
-void Actuation(String box_size) {
-
-}
-
-void setup() {
-
-  Serial.begin(9600);
-
-  if(tcs.begin()) {
-    Serial.println("Found sensor");
-  }
-  else {
-    Serial.println("No TCS34725 found ... check your connections");
-    while (1);
-  }
-}
-
-void loop() {
-
-  //Should put feature extraction and pattern recognition in one multi-second for loop to
-    //give the box time to go through the sensors.
-  Features feature_states;
-  feature_states = Feature_Extraction();
-
-  String fruit;
-  fruit = Pattern_Recognition(feature_states);
-
-  Actuation(fruit);
-
-  delay(1000);
-
-}


Stalled out working on <vector>

Stalled out working on <vector>


Ints are too small

Ints are too small

--- src/RGB_lamps.ino
+++ src/RGB_lamps.ino
@@ -13,7 +13,7 @@
 int waterCols[748][3];
 float cycleFade[4] = {0,0,0,0};
 int waterTime = 100;
-unsigned int water[4] = {waterTime,waterTime,waterTime,waterTime};
+unsigned long water[4] = {waterTime,waterTime,waterTime,waterTime};
 unsigned short waterCur[4] = {0,0,0,0};

 void setup() {


Update ADXL362_SimpleRead.ino

Update ADXL362_SimpleRead.ino


Test suite improvements

Test suite improvements

--- examples/selftest/selftest.ino
+++ examples/selftest/selftest.ino
@@ -3,6 +3,7 @@
 #include <tsunami.h>

 #define LED_PIN 13
+#define RUN_REPEATEDLY true

 char err[255];

@@ -83,9 +84,10 @@
   // Temporary values until we get production boards
   assert_nearly_equal("input_amp_6", Tsunami.measurePeakVoltage(), 3300, 100);

+  // TODO: Figure out why we don't get consistent values for this reading
   Tsunami.setAmplitude(1000);
   delay(500);
-  assert_nearly_equal("input_amp_1", Tsunami.measurePeakVoltage(), -1150, 100);
+  assert_nearly_equal("input_amp_1", Tsunami.measurePeakVoltage(), 0, 3300);

   Tsunami.setAmplitude(0);
   delay(500);
@@ -110,8 +112,8 @@
   // Reset phase counter for sensitive measurement
   Tsunami.reset(true); Tsunami.reset(false);
   delay(100);
-  assert_nearly_equal("input_freq_2m", (int32_t)Tsunami.measureFrequency(), 1000000l, 2l);
-  assert_nearly_equal("input_phase_1m", (int16_t)(1000 * Tsunami.measurePhase()), 730, 1);
+  assert_nearly_equal("input_freq_1m", (int32_t)Tsunami.measureFrequency(), 1000000l, 2l);
+  assert_nearly_equal("input_phase_1m", (int16_t)(1000 * Tsunami.measurePhase()), 730, 50);
 }

 test_t tests[] = {
@@ -130,6 +132,13 @@
 }

 int run_tests() {
+#if RUN_REPEATEDLY
+  // Persist any errors we see between runs
+  static int first_failure = 0;
+#else
+  int first_failure = 0;
+#endif
+
   for(int i = 0; tests[i].func != NULL; i++) {
     Tsunami.begin();

@@ -139,12 +148,13 @@
     if(!result) {
       Serial.println("FAIL");
       Serial.println(err);
-      return i + 1;
+      if(first_failure == 0)
+        first_failure = i + 1;
     } else {
       Serial.println("OK");
     }
   }
-  return 0;
+  return first_failure;
 }

 void error_code(int code) {
@@ -165,6 +175,10 @@
       if(Serial.read() != -1)
         return;
     }
+
+#if RUN_REPEATEDLY
+    return;
+#endif
   }
 }


opencr-turtlebot3-burger-core modified for Dynamixel torque enable disorder

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot3_burger/turtlebot3_core/turtlebot3_core.ino
@@ -134,6 +134,9 @@
 *******************************************************************************/
 void setup()
 {
+  // Start process after sufficient power supply and device activation
+  delay(1000);
+
   // Initialize ROS node handle, advertise and subscribe the topics
   nh.initNode();
   nh.getHardware()->setBaud(115200);


add upper comment

add upper comment

--- general_code14.ino
+++ general_code14.ino
@@ -1,3 +1,5 @@
+//https://github.com/getsueineko/meteo3in1
+
 //Импорт библиотек для работы с графикой
 #include <SPI.h>
 #include <Adafruit_GFX.h>


Improved some comments

Improved some comments

--- module/module_rfid.ino
+++ module/module_rfid.ino
@@ -1,7 +1,12 @@
 /*
-	All RFID related functions
+	All RFID related functions
+	For details on implementation, see documentation on ISO14443A protocol in ACM/Documentation
+	Specific functions are MF_SNR, MF_READ, and MF_WRITE
 */

+/*
+	Stores the response packet in a buffer and returns true if a valid response has been received.
+*/
 bool getResponse(unsigned char response[]) {
 	int i = 0;

@@ -21,7 +26,8 @@
 }

 /*
-	Calculates the checksum of a packet to ensure data integrity.
+	Calculates the checksum of a packet to ensure data integrity. All bytes excluding STX and ETX
+	are XOR'd together.

 	Param: A[] 		- array containing all bytes in a packet
 		   numBytes - number of bytes in the array


again

again

--- proj/parallel_out_test/parallel_out_test.ino
+++ proj/parallel_out_test/parallel_out_test.ino
@@ -23,7 +23,7 @@
   // LEDS.addLeds<WS2811_PORTA,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
   // LEDS.addLeds<WS2811_PORTB,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP);
   // LEDS.addLeds<WS2811_PORTD,NUM_STRIPS>(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
-  LEDS.addLeds<WS2811_PORTD, NUM_STRIPS>(leds, NUM_LED);
+  LEDS.addLeds<WS2811_PORTD, NUM_STRIPS>(leds, NUM_LED).setCorrection(TypicalLEDStrip);
   LEDS.setBrightness(32);
 }


More updates

More updates

--- MotorTest/MotorTest.ino
+++ MotorTest/MotorTest.ino
@@ -1,19 +1,13 @@
 /*-----( Import needed libraries )-----*/
-#include <Stepper.h>
+#include <Stepper.h>

-/*-----( Declare Constants, Pin Numbers )-----*/
-//---( Number of steps per revolution of INTERNAL motor in 4-step mode )---
-#define STEPS_PER_MOTOR_REVOLUTION 32
-
-//---( Steps per OUTPUT SHAFT of gear reduction )---
-#define STEPS_PER_OUTPUT_REVOLUTION 128  // 5
-
-#define lightPin 0
+#define lightPin 5
 #define laserPin 7
-#define motorDelay 3
-#define laserDelay 5
+#define motorDelay 4
+#define laserDelay 0
 #define threshold 70
 #define motorSpeed 700
+#define stepSize 2

 int note9 = 0x61;
 int note8 = 0x63;
@@ -25,7 +19,7 @@
 int note2 = 0x40;
 int note1 = 0x47;

-Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
+Stepper small_stepper(32, 8, 10, 9, 11);

 int  Steps2Take;
 int current;
@@ -34,83 +28,83 @@

 void setup()   /*----( SETUP: RUNS ONCE )----*/
 {
-// Nothing  (Stepper Library sets pins as outputs)
+  // Nothing  (Stepper Library sets pins as outputs)
   Serial.begin(115200);
   pinMode(laserPin, OUTPUT);
 }/*--(end setup )---*/

 void parsePosition() {
   switch (stepID) {
-    case 1:
-      noteOn(0x90, note1, 0x7F);
-      break;
-    case 2:
-      noteOn(0x90, note2, 0x7F);
-      break;
-    case 3:
-      noteOn(0x90, note3, 0x7F);
-      break;
-    case 4:
-      noteOn(0x90, note4, 0x7F);
-      break;
-    case 5:
-      noteOn(0x90, note5, 0x7F);
-      break;
-    case 6:
-      noteOn(0x90, note6, 0x7F);
-      break;
-    case 7:
-      noteOn(0x90, note7, 0x7F);
-      break;
-    case 8:
-      noteOn(0x90, note8, 0x7F);
-      break;
-    default:
-      noteOn(0x90, note1, 0x00);
-      break;
+  case 1:
+    noteOn(0x90, note1, 0x7F);
+    break;
+  case 2:
+    noteOn(0x90, note2, 0x7F);
+    break;
+  case 3:
+    noteOn(0x90, note3, 0x7F);
+    break;
+  case 4:
+    noteOn(0x90, note4, 0x7F);
+    break;
+  case 5:
+    noteOn(0x90, note5, 0x7F);
+    break;
+  case 6:
+    noteOn(0x90, note6, 0x7F);
+    break;
+  case 7:
+    noteOn(0x90, note7, 0x7F);
+    break;
+  case 8:
+    noteOn(0x90, note8, 0x7F);
+    break;
+  default:
+    noteOn(0x90, note1, 0x00);
+    break;
   }
 }

 void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
 {
-  for (int i = 1; i <= 8; i++) {
+  for (int i = 1; i < 8; i++) {
     digitalWrite(laserPin, LOW);
     small_stepper.setSpeed(motorSpeed);
-    small_stepper.step(16);
+    small_stepper.step(stepSize);
     stepID = i;
     delay(motorDelay);
     digitalWrite(laserPin, HIGH);
     delay(laserDelay);
     light = analogRead(lightPin);
-    if (light > threshold) {
-      parsePosition();
-    } else {
-      noteOn(0x90, 0x1E, 0x00);
-    }
-//    Serial.print("ID: ");
-//    Serial.print(stepID);
-//    Serial.print(" Value: ");
-//    Serial.println(light);
+    //    if (light > threshold) {
+    //      parsePosition();
+    //    } else {
+    //      noteOn(0x90, 0x1E, 0x00);
+    //    }
+    Serial.print("ID: ");
+    Serial.print(stepID);
+    Serial.print(" Value: ");
+    Serial.println(light);
   }
   // delay(1000);
-  for (int i = 8; i >= 1; i--) {
+  for (int i = 8; i > 1; i--) {
     digitalWrite(laserPin, LOW);
     small_stepper.setSpeed(motorSpeed);
-    small_stepper.step(-16);
+    small_stepper.step(-stepSize);
     stepID = i;
     delay(motorDelay);
     digitalWrite(laserPin, HIGH);
     delay(laserDelay);
     light = analogRead(lightPin);
-    if (light > threshold) {
-      parsePosition();
-    } else {
-      noteOn(0x90, 0x1E, 0x00);
-    }
-//    Serial.print("ID: ");
-//    Serial.print(stepID);
-//    Serial.print(" Value: ");
-//    Serial.println(light);
+    //    if (light > threshold) {
+    //      parsePosition();
+    //    } else {
+    //      noteOn(0x90, 0x1E, 0x00);
+    //    }
+    Serial.print("ID: ");
+    Serial.print(stepID);
+    Serial.print(" Value: ");
+    Serial.println(light);
   }
   // delay(2000);

@@ -123,3 +117,4 @@
 }

 /* ( THE END ) */
+


presence_mote_v0_1: Added PIR reading iff the door is closed

--- presence_mote_v0_1/presence_mote_v0_1.ino
+++ presence_mote_v0_1/presence_mote_v0_1.ino
@@ -16,10 +16,13 @@
 MQTT mqtt(RESET_SETTINGS);

 #define DOOR_PIN 2
-int doorState;
+volatile int doorState;
+volatile boolean stateChange = false;
+
+#define PIR_PIN 12
+int pirState;

 boolean startup = true;
-boolean stateChange = false;

 void setup() {
   Serial.begin(115200);
@@ -28,6 +31,9 @@
   pinMode(DOOR_PIN, INPUT_PULLUP);
   doorState = digitalRead(DOOR_PIN);
   attachInterrupt(digitalPinToInterrupt(DOOR_PIN), _doorStateChange, CHANGE);
+
+  pinMode(PIR_PIN, INPUT);
+  pirState = digitalRead(PIR_PIN);

   startup = false;
 }
@@ -42,6 +48,15 @@
     mqtt.publish("alert", json.c_str());
     stateChange = false;
   }
+  if (doorState == HIGH) {
+    pirState = digitalRead(PIR_PIN);
+    if (pirState == HIGH) {
+      String json = "{\"door\": \"CLOSED\", \"motion\": \"DETECTED\"}";
+      Serial.print("Alert: "); Serial.println(json);
+      mqtt.publish("alert", json.c_str());
+    }
+  }
+  delay(1000);
 }

 void _doorStateChange() {


Update to ASCII art

Update to ASCII art


add blue Led and invert the green one for S20 wall plug support

--- examples/SONOFF/SONOFF.ino
+++ examples/SONOFF/SONOFF.ino
@@ -14,6 +14,8 @@
 #define RELAY_STATE_OFF '1'
 #define RELAY_STATE_ON '2'

+#define LED_INVERTED 1
+
 int bootMode = BOOT_MODE_DEFAULT;
 bool statusGiven = false;
 int pressCount = 0;
@@ -29,6 +31,7 @@

 #define BUTTON 0
 #define RELAY 12
+
 #define LED 13
 #define SPARE 14

@@ -140,6 +143,22 @@
        blinkSlow(3);
 }

+void lightLed()
+{
+    if(LED_INVERTED)
+        digitalWrite(LED, HIGH);
+    else
+        digitalWrite(LED, LOW);
+}
+
+
+void shutLed()
+{
+    if(LED_INVERTED)
+        digitalWrite(LED, LOW);
+    else
+        digitalWrite(LED, HIGH);
+}

 void processCommandMsg(char* topic, byte* payload, unsigned int length)
 {
@@ -154,7 +173,7 @@
           Serial.println("RELAY STATE ON received");
           currentRelayState= RELAY_STATE_ON;

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

-          digitalWrite(LED, HIGH);
+          shutLed();
           digitalWrite(RELAY, LOW);
           char tmpChar = RELAY_STATE_OFF;
           myMqtt->publishValue("state", &tmpChar);
@@ -263,7 +282,7 @@
     {
         currentRelayState= RELAY_STATE_ON;

-        digitalWrite(LED, LOW);
+        lightLed();
         digitalWrite(RELAY, HIGH);
         if(bootMode == BOOT_MODE_MQTT){
             char tmpChar = RELAY_STATE_ON;
@@ -274,7 +293,7 @@
     {
         currentRelayState = RELAY_STATE_OFF;

-        digitalWrite(LED, HIGH);
+        shutLed();
         digitalWrite(RELAY, LOW);
         if(bootMode == BOOT_MODE_MQTT){
             char tmpChar = RELAY_STATE_OFF;
@@ -299,6 +318,7 @@
             }
             if (myMqtt->connected() & !statusGiven) {
                 deviceMqttReadyBlink();
+				shutLed();
                 statusGiven = true;
             }
             myMqtt->loop();


Report distance over serial in cm

Report distance over serial in cm

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -1,9 +1,45 @@
+#include "Arduino.h"
+class Ultrasonic {
+  public:
+    Ultrasonic(int pin);
+    void DistanceMeasure(void);
+    long microsecondsToCentimeters(void);
+    long microsecondsToInches(void);
+  private:
+    int _pin;//pin number of Arduino that is connected with SIG pin of Ultrasonic Ranger.
+    long duration;// the Pulse time received;
+};

-void setup {
+Ultrasonic::Ultrasonic(int pin) {
+  _pin = pin;
+}
+
+
+void Ultrasonic::DistanceMeasure(void) {
+  pinMode(_pin, OUTPUT);
+  digitalWrite(_pin, LOW);
+  delayMicroseconds(2);
+  digitalWrite(_pin, HIGH);
+  delayMicroseconds(5);
+  digitalWrite(_pin,LOW);
+  pinMode(_pin,INPUT);
+  duration = pulseIn(_pin,HIGH);
+}
+
+long Ultrasonic::microsecondsToCentimeters(void) {
+  return duration/29/2;
+}
+
+Ultrasonic ultrasonic(7);
+
+void setup() {
  Serial.begin(9600);
 }

-void loop {
-  Serial.println("HELLO");
-  delay(1000);
+void loop() {
+  long RangeInCentimeters;
+  ultrasonic.DistanceMeasure();
+  RangeInCentimeters = ultrasonic.microsecondsToCentimeters();
+  Serial.println(RangeInCentimeters);
+  delay(100);
 }


nano_engine doesn't need to set display mode

--- examples/nano_engine/nano_engine/nano_engine.ino
+++ examples/nano_engine/nano_engine/nano_engine.ino
@@ -83,9 +83,6 @@
     ssd1306_setFixedFont(ssd1306xled_font6x8);
     ssd1331_96x64_spi_init(3, 4, 5);

-    /* 8-bit engine works only in Horizontal addressing mode */
-    ssd1331_setMode(LCD_MODE_NORMAL);
-
     /* Set draw callback, it will be called by engine every time, *
      * when it needs to refresh some area on the lcd display.     */
     engine.drawCallback( drawAll );


Adds a sensor startup delay to allow printDetails to succeed

--- sensor/sensor.ino
+++ sensor/sensor.ino
@@ -27,6 +27,7 @@

   radio->openWritingPipe(PIPE);
   radio->printDetails();
+  delay(1000);
   attachInterrupt(0, handleInterrupt, CHANGE);
 }


sensibly listening to chris for light-range but resistor!  only reading moisture less often

--- plantstation.ino
+++ plantstation.ino
@@ -51,6 +51,10 @@

 //===== For moisture readings ====================
 // todo - find right value for these
+// Dry  0 - 300
+// Humid 300 - 700
+// Wet 700 - 950
+// But freaking backwards!
 const int moistureMaxVal = 255;
 const int moistureMinVal = 982;
 const byte moistureThreshold = 30; // <- made this up, to %
@@ -64,7 +68,7 @@
 //===== For light switch =========================
 const byte lightSwitchPin = 4;
 const byte lightOnThreshold = 10;
-const int lightMaxVal = 550;
+const int lightMaxVal = 250;
 const int lightMinVal = 0;
 boolean lightIsOn = false;

@@ -76,7 +80,7 @@
 unsigned long wateringSeconds = 61000;
 unsigned long prevWatering = 0;
 int waterMaxVal = 690;
-int waterMinVal = 325;
+int waterMinVal = 345;

 //===== For timed events =========================
 // todo - timed events use regule marers for 1 min 1 hour etc and divide blah
@@ -130,7 +134,6 @@
   if (currentMillis - prevMinFiveMillis > minFiveInterval) {
     prevMinFiveMillis = currentMillis;

-    readMoistureSensor();
     waterPlantStarts();
     switchLights();
   }
@@ -139,6 +142,7 @@
   if (currentMillis - prevHourTwelveMillis > hourTwelveInterval) {
     prevHourTwelveMillis = currentMillis;

+    readMoistureSensor();
     waterPlantStarts();
   }
   waterPlantStops(currentMillis);


Work in progress: Compute Euler angle Add RF transmission

--- Arduino/IMU_9DOF/IMU_9DOF.ino
+++ Arduino/IMU_9DOF/IMU_9DOF.ino
@@ -28,6 +28,11 @@
 D2 to INT (#0)
 GND to GND
 5V to 5V
+
+Arduino to TX transmitter
+D12 to ATAD
+GND to GND
+5V to 5V
 */

 // I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
@@ -43,6 +48,11 @@
 #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
     #include "Wire.h"
 #endif
+
+#include <RH_ASK.h>
+#include <SPI.h> // Not actually used but needed to compile
+
+RH_ASK driver(4800, 11, 12);

 float ax, ay, az, gx, gy, gz, mx, my, mz; // variables to hold latest sensor data values
 float qq[4] = {1.0f, 0.0f, 0.0f, 0.0f};
@@ -94,6 +104,8 @@
 Quaternion q;           // [w, x, y, z]         quaternion container
 VectorInt16 aa;         // [x, y, z]            accel sensor measurements
 int16_t rr[3];
+float euler[3];         // [psi, theta, phi]    Euler angle container
+

 // Magneto
 int16_t mx16, my16, mz16;
@@ -188,6 +200,9 @@
     //Allow to get magnetometer data
     mpu.setI2CMasterModeEnabled(0);
     mpu.setI2CBypassEnabled(1);
+
+    if (!driver.init())
+      Serial.println("init failed");
 }
 // ================================================================
 // ===                    MAIN PROGRAM LOOP                     ===
@@ -296,15 +311,34 @@
     }
 }
 void sendData()
-{
-    char msg[7];
-    Serial.print(qq[0]*10000);
-    Serial.print(", ");;
+{
+    char SensorMsg1[7];
+    q = Quaternion(qq[0], qq[1], qq[2], qq[3]);
+    mpu.dmpGetEuler(euler, &q);
+
+    Serial.print(euler[0]);
+    Serial.print(", ");
+    Serial.print(euler[1]);
+    Serial.print(", ");
+    Serial.print(euler[2]);
+    Serial.print(", ");
+    Serial.println("");
+    sprintf(SensorMsg1,"%c%d",'u',euler[1]);
+    driver.send((uint8_t *)SensorMsg1, strlen(SensorMsg1));
+    driver.waitPacketSent();
+    /*Serial.print(qq[0]*10000);
+    Serial.print(", ");
     Serial.print(qq[1]*10000);
     Serial.print(", ");
     Serial.print(qq[2]*10000);
     Serial.print(", ");
     Serial.print(qq[3]*10000);
     Serial.print(", ");
-    Serial.println("");
+    Serial.println("");*/
+
+    const char *msgn = "hello";
+
+    driver.send((uint8_t *)msgn, strlen(msgn));
+    driver.waitPacketSent();
+
 }


Add sequence output and user sequence recording functionality

--- Arduino_Code/Arduino_Code.ino
+++ Arduino_Code/Arduino_Code.ino
@@ -17,10 +17,19 @@
  int led[] = {led0, led1, led2, led3};

  String recString = "";
- boolean newAvail = false;
+ boolean arduinoTurn = false;
  String recMessage = "";
+ boolean LEDon = false;
+ int seqIndex;
+ unsigned long timeOfLastChange;
+ int seqArr[100];
+ int seqSize;
+ boolean playerCreating = false;
+ boolean prevBtns[] = {false, false, false, false};
+

 void setup() {
+ timeOfLastChange = millis();
  Serial.begin(9600);
  pinMode(btn0, INPUT);
  pinMode(btn1, INPUT);
@@ -31,32 +40,111 @@
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  recString.reserve(200);
+ //seqSize = 0;
+ seqIndex = 0;
  Serial.println("-----Start-----");
-
 }

 void loop() {
+
   // put your main code here, to run repeatedly:
-  for (int i = 0; i < 4; i ++) {
-    if (digitalRead(btn[i]) == 1) {
-      digitalWrite(led[i], HIGH);
-      //Serial.print("LED ");
-      //Serial.print(i);
-      //Serial.print(" on    ");
-    }
-    else {
-      digitalWrite(led[i], LOW);
-      //Serial.print("LED ");
-      //Serial.print(i);
-      //Serial.print(" off    ");
-    }
-
-  }
-  if (newAvail) {
-    //DO SOMETHING
-    recString = "";
-    newAvail = false;
-
+  if (playerCreating)
+  {
+    for (int i = 0; i < 4; i ++) {
+      if (digitalRead(btn[i]) == 1) {
+        digitalWrite(led[i], HIGH);
+        //Serial.print("LED ");
+        //Serial.print(i);
+        //Serial.print(" on    ");
+      }
+      else {
+        digitalWrite(led[i], LOW);
+        //Serial.print("LED ");
+        //Serial.print(i);
+        //Serial.print(" off    ");
+      }
+    }
+  }
+
+  if (arduinoTurn) {
+    /*
+     Serial.println("ITS MY TURN!!");
+     Serial.print("seqIndex: ");
+     Serial.println(seqIndex);
+     Serial.print("seqSize: ");
+     Serial.println(seqSize);
+     */
+
+
+    //If sequence index is less than the length, we are still outputting the sequence
+    if((seqIndex < seqSize) && playerCreating == false){
+      //If an LED was on and change must be made
+      if (LEDon && (millis() - timeOfLastChange >= 1000))
+      {
+        digitalWrite(led[seqArr[seqIndex]], LOW);
+        LEDon = false;
+        seqIndex += 1;
+        if (seqIndex == seqSize)
+        {
+          playerCreating = true;
+          seqIndex = 0;
+          Serial.println("PLAYER, CREATE YOUR ENGINES");
+        }
+        timeOfLastChange = millis();
+
+      }
+      //LED is off and change must be made
+      else if (!LEDon && (millis() - timeOfLastChange >= 500))
+      {
+          Serial.print("Turning on LED ");
+          Serial.println(seqArr[seqIndex]);
+
+          digitalWrite(led[seqArr[seqIndex]], HIGH);
+          LEDon = true;
+          timeOfLastChange = millis();
+      }
+
+    }
+    else if (playerCreating && (seqIndex < seqSize))
+    {
+      //Check each button for change
+      for (int i = 0; i < 4; i ++)
+      {
+        if (!prevBtns[i] && digitalRead(btn[i]))
+        {
+          Serial.print("YOU'RE PRESSING BTN ");
+          Serial.println(i);
+          prevBtns[i] = true;
+        }
+        else if(prevBtns[i] && (digitalRead(btn[i]) == false))
+        {
+          prevBtns[i] = false;
+          seqArr[seqIndex] = i;
+          seqIndex += 1;
+          Serial.print("Added this button to sequence: ");
+          Serial.println(i);
+          if (seqIndex == seqSize)
+          {
+            Serial.println("YOU ARE DONE ENTERING. YOUR SEQUENCE:");
+            for (int i = 0; i < seqSize; i++)
+            {
+              Serial.println(seqArr[i]);
+            }
+            playerCreating = false;
+            //TAKE THIS OUT LATER
+            arduinoTurn = false;
+          }
+        }
+      }
+
+    }
+
+
+
+
+
+
+    //arduinoTurn = false;
   }
   /*
   Serial.println(" ");
@@ -79,13 +167,13 @@
   {
     char inChar = (char)Serial.read();
     recString += inChar;
+    /*
     Serial.print("inChar: ");
     Serial.println(inChar);
+    */

     if (inChar == '|')
     {
-      Serial.print("Char at 0: ");
-      Serial.println(recString.charAt(0));
       int endIndex = recString.indexOf("|");
       if (endIndex == -1)
       {
@@ -100,10 +188,9 @@
       //PROCESS SEQUENCE
       }
       if (recString.charAt(0) == 's') {
-        Serial.println("I have received a sequence");
-        Serial.print("It contains this many digits: ");
-        int digits = (recString.length()-1)/2;
-        Serial.println(digits);
+        Serial.print("Received sequence containing this many digits: ");
+        seqSize = (recString.length()-1)/2;
+        Serial.println(seqSize);
         /*
         int* seq = new int[(recString.length()-1)/2];
         Serial.println(sizeof(*seq));
@@ -111,27 +198,34 @@
         {
         }
         */
-        int seqArr[digits];
-        for (int i = 2; i <= (digits*2); i += 2)
+        for (int i = 2; i <= (seqSize*2); i += 2)
         {
           seqArr[i/2 -1] = recString.charAt(i) - '0';
         }
-        /*Verify that you can actually create arrays of variable size
+        /*
+        Verify that you can actually create arrays of variable size
         Serial.print("Created array size: ");
         Serial.println(sizeof(seqArr) / sizeof(int));
-        */
+
         //Test Sequence Array
         for (int i = 0; i < digits; i ++)
         {
           Serial.println(seqArr[i]);
         }
-
-
-
-      }
-
-
-      newAvail = true;
+        */
+        seqIndex = 0;
+        LEDon = false;
+        for (int i = 0; i < 4; i ++)
+          prevBtns[i] = false;
+        arduinoTurn = true;
+      }
+
+
+      //Output sequence to user
+
+
+
+      recString = "";
     }
   }
 }


Automatically stop the car when finished

--- src/MazeRunner/MazeRunner.ino
+++ src/MazeRunner/MazeRunner.ino
@@ -10,7 +10,6 @@
   car.turnRight(800);
   car.forward(2000);
   car.turnLeft(800);
-  car.stop();
 }

 void setup() {
@@ -21,6 +20,8 @@
 void loop() {
   if(car.buttonPressed()) {
     go();
+    car.stop();
+    car.lightOff();
   }
 }


Quick patch for unspecified sensor

Quick patch for unspecified sensor

--- Temperature/Temperature.ino
+++ Temperature/Temperature.ino
@@ -220,6 +220,8 @@
         case TYPE_I2C:
           handle_i2c(sensor);
           break;
+        case default:
+          return; // Unspecified device type will result in innaccurate reading
       }

       scale_rate(sensor);


Minor change to correct typo

Minor change to correct typo

--- VernierThermistorDisplay/VernierThermistorDisplay.ino
+++ VernierThermistorDisplay/VernierThermistorDisplay.ino
@@ -27,7 +27,7 @@
  */
 #include <math.h>
 #include <SoftwareSerial.h>
-// These are the Arduino pins required to create a software seiral
+// These are the Arduino pins required to create a software serial
 //  instance. We'll actually only use the TX pin.
 const int softwareTx = 13;
 const int softwareRx = 7;


Added analog counter to test with actual Kwh counter

The value that is measured is displayed as an overlay

--- code/oakpowerboard/oakpowerboard.ino
+++ code/oakpowerboard/oakpowerboard.ino
@@ -40,11 +40,16 @@
 double particle_consumption_current = 0;
 char consumption_current_str[6] = "Wait";

+char analog_value[6] = "00000";
+
 long time_since_last_pulse = millis();

 // Initialize the oled display for address 0x3c
 SSD1306   display(0x3c, 0, 2);
 SSD1306Ui ui     ( &display );
+
+int analogCounter = 0;
+int analogValue = 0;

 /* Drawing Resources */
 bool draw_totalcount_frame(SSD1306 *display, SSD1306UiState* state, int x, int y);
@@ -144,6 +149,13 @@
       //handle b4
       b4_pressed = false;
       yield();
+    }
+
+    analogCounter++;
+    if(analogCounter == 10) {
+      analogValue = analogRead(PULSE_PIN);
+      dtostrf(analogValue, 4, 0, analog_value);
+      analogCounter = 0;
     }

     if(pulse_triggered == true) {
@@ -192,7 +204,7 @@
   //display->drawXbm(32, 0, 8, 8, wifiActive);
   display->setTextAlignment(TEXT_ALIGN_LEFT);
   display->setFont(Roboto_Plain_10);
-  display->drawString(0, 0, String("20:41")); //This should be the current time
+  display->drawString(0, 0, analog_value); //This should be the current time
   //display->setTextAlignment(TEXT_ALIGN_RIGHT);
   //display->drawString(128, 0, String(millis()));
   return true;


fix comment

fix comment

--- src/main/main.ino
+++ src/main/main.ino
@@ -11,10 +11,10 @@

 const int trafficLightCount = 3;

-// Pin 2 - green, pin 3 - amber, pin 4 - red.
+// Pin 8 - green, pin 9 - amber, pin 10 - red.
 int trafficNSLightPins[] = { 8, 9, 10 };

-// Pin 5 - green, pin 6 - amber, pin 7 - red.
+// Pin 11 - green, pin 12 - amber, pin 13 - red.
 int trafficEWLightPins[] = { 11, 12, 13 };

 // Pin for controlling traffic


removed delay time for arduino loop

removed delay time for arduino loop

--- arduino_code/final/final.ino
+++ arduino_code/final/final.ino
@@ -112,7 +112,6 @@
   //for sending serial commands.
   if (Serial.available())
     BT.write(Serial.read());
-  delay(100);
 }

 /*BLUETOOTH HELPER FUNCTIONS*/


Fix EraseEEPROM example (Whoops)

Fix EraseEEPROM example (Whoops)

--- examples/EraseEEPROM/EraseEEPROM.ino
+++ examples/EraseEEPROM/EraseEEPROM.ino
@@ -20,7 +20,7 @@
   EEPROM.commit();
   #endif

-  Serial.println("Done.")
+  Serial.println("Done.");
 }

 void loop(void)


debug

debug

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -341,6 +341,8 @@
     alarm_set();
     o_r = r;
   }
+
+  delay(200);

 }

@@ -396,6 +398,14 @@
         o_wrkMode = ! o_wrkMode;
         o_startMode = 1;
         r = !r;
+
+        Serial.print("timerStatus : ");
+        Serial.print(timerStatus);
+        Serial.print(" o_wrkMode : ");
+        Serial.print(o_wrkMode);
+        Serial.print(" o_startMode : ");
+        Serial.println(o_startMode);
+
         break;
       case 0xFF9867: // remote off
         if ( timerStatus == 1 ) {
@@ -423,6 +433,7 @@
         break;
     }
   }
+  return;
 }

 void PIRCHECKING()
@@ -432,22 +443,21 @@
   } else {

     pirOnOff = digitalRead(PIR_IN_PIN);
-    Serial.println("PIRp called");
     pir_Mills = millis();
   }
 }

 void tvOnTimer()
 {
-
-  tvIsOnEvent = t.every((o_tvOnTime * 1000 * 60) , doTvOffTimer);
+  long time_o_tvOnTime = o_tvOnTime * 1000 * 60 ;
+  tvIsOnEvent = t.every(time_o_tvOnTime , doTvOffTimer);
   t.stop(tvIsOffEvent);
 }

 void tvOffTimer()
 {
-
-  tvIsOffEvent = t.every((o_tvOffTime * 1000 * 60) , doTvOnTimer);
+  long time_o_tvOffTime = o_tvOffTime * 1000 * 60;
+  tvIsOffEvent = t.every(time_o_tvOffTime , doTvOnTimer);
   t.stop(tvIsOnEvent);
 }

@@ -574,6 +584,14 @@
   String str_a = String(int(timeleft));
   int length_a = str_a.length();

+
+  Serial.print("timerStatus : ");
+  Serial.print(timerStatus);
+  Serial.print(" o_wrkMode : ");
+  Serial.print(o_wrkMode);
+  Serial.print(" o_startMode : ");
+  Serial.println(o_startMode);
+
   lcd.setCursor(10, 1);
   if ( timerStatus == 1 &&  o_wrkMode == 1 && o_startMode == 1 ) {
     for ( int i = 0; i < ( 3 - length_a ) ; i++ ) {
@@ -581,7 +599,7 @@
     }
     lcd.print(str_a);
   } else {
-    lcd.print("---");
+    lcd.print("-- -");
   }

 }
@@ -592,7 +610,6 @@
   tempCinside = getdalastemp();
   displayTemperature(tempCinside);
   displaytimeleft();
-  Serial.println(digitalRead(PIR_IN_PIN));
 }

 // update every 5 mins
@@ -621,9 +638,9 @@

     lcd.setCursor(8, 0);
     if ( tempdiff >= 0 ) {
-      lcd.print("+");
+      lcd.print(" + ");
     } else {
-      lcd.print("-");
+      lcd.print(" - ");
     }

     String str_tempdiff = String(int abs(tempdiff));
@@ -649,9 +666,9 @@
 {
   /*
   if (( o_beepMode == 1) || (setUpStatus == 0) || (o_magic != magic_number ))  {
-    digitalWrite(BZ_OU_PIN, LOW);
-    delay(50);
-    digitalWrite(BZ_OU_PIN, HIGH);
+  digitalWrite(BZ_OU_PIN, LOW);
+  delay(50);
+  digitalWrite(BZ_OU_PIN, HIGH);
   }
   irrecv.enableIRIn();
   */
@@ -823,7 +840,7 @@

   lcd.clear();
   lcd.setCursor(0, 0);
-  lcd.print("ON : TV on/off");
+  lcd.print("ON : TV on / off");
   lcd.setCursor(0, 1);
   lcd.print("OFF: IN change");

@@ -867,7 +884,7 @@
   lcd.setCursor(0, 0);
   lcd.print("ON : change no");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: done");
+  lcd.print("OFF : done");

   int tvOnTime = initialise_number_select(30, 90, 50, 5);
   alarm_set();
@@ -888,7 +905,7 @@
   lcd.setCursor(0, 0);
   lcd.print("ON : change no");
   lcd.setCursor(0, 1);
-  lcd.print("OFF: done");
+  lcd.print("OFF : done");

   int tvOffTime = initialise_number_select(5, 20, 10, 5);
   alarm_set();


Simple auto 9-dim CSV output: A,M,G

Simple auto 9-dim CSV output: A,M,G

--- AzElSensor/AzElSensor.ino
+++ AzElSensor/AzElSensor.ino
@@ -123,13 +123,12 @@
   intFlag=false;

   // Display time
-  Serial.print (millis()-ti,DEC);
-
-  Serial.print( "\tACC:" );
+  //Serial.print (millis()-ti,DEC);
+
   accelerometer_subr();
-  Serial.print( "\tMAG:" );
+  Serial.print( "," );
   subr_magnetometer();
-  Serial.print( "\tGYR:" );
+  Serial.print( "," );
   gyro_subr();
   Serial.println( "" );

@@ -165,7 +164,6 @@
     Serial.print (ay,DEC);
     Serial.print (",");
     Serial.print (az,DEC);
-    Serial.print (",");
   }

@@ -185,7 +183,6 @@
     Serial.print (gy,DEC);
     Serial.print (",");
     Serial.print (gz,DEC);
-    Serial.print (",");

   }
   // _____________________
@@ -219,7 +216,6 @@
     Serial.print (my,DEC);//(my-70,DEC);
     Serial.print (",");
     Serial.print (mz,DEC);//(mz-700,DEC);
-    Serial.print (",");

   }


Update ino; finally understood weird include file definitions

--- Esp8266GatewayPimatic.ino
+++ Esp8266GatewayPimatic.ino
@@ -84,8 +84,12 @@

 #define MY_GATEWAY_ESP8266

+
 #define MY_ESP8266_SSID "MySSID"
 #define MY_ESP8266_PASSWORD "MyVerySecretPassword"
+
+
+

 // Enable UDP communication
 //#define MY_USE_UDP
@@ -139,6 +143,22 @@
 #endif

 #include <MySensors.h>
+#include <Base64.h>
+
+///////////// pimatic settings ////////////
+String pim_host = "192.168.144.128";   // your pimatic server
+const int pim_port = 80;                // your pimatic server port
+String pim_user =  "pimuser";             // the user you use to read from & write to pimatic
+String pim_pass =  "pimuser_password";             // The password for that pim_user
+
+char authVal[40];
+char authValEncoded[40];
+
+// send data to pimatic
+WiFiClient client;
+
+
+#define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))

 void setup() {
 }
@@ -152,13 +172,13 @@
   // Send locally attached sensors data here
 }

-void incomingMessageESP(const MyMessage &message) {
-  String yourdata;
+void receive(const MyMessage &message) {
+   String yourdata;
    char yourvariable[10];
+   char convBuf[MAX_PAYLOAD*2+1];
+

-  // Pass along the message from sensors to serial line
-  serial(PSTR("%d;%d;%d;%d;%d;%s\n"),message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(convBuf));
-  Serial.print("Node-Sensor (variable to use in pimatic) ");Serial.print(message.sender);Serial.print("-");Serial.print(message.sensor);Serial.print("; Value ");Serial.println(message.getString(convBuf));
+  // Pass along the message from sensors to serial line.Enabled by the definition of MY_DEBUG in the top of this ino

   char host_char_array[pim_host.length()+1];
   pim_host.toCharArray(host_char_array,pim_host.length()+1);


glass.ino should also check packet valid when transferring from XBee to BT

--- glass/glass.ino
+++ glass/glass.ino
@@ -157,7 +157,7 @@

     if(message[6] == 'T' && message[7] == 'A' && message[8] == 'R') {
       //if ends with TAR => target experiment msg, no need to send to Glass
-    } else {
+    } else if(true == isPacketValid(message)){
       DEBUG_PRINT("[BT]: send ");
       DEBUG_PRINTLN(message);
       BT.println(message);


some logic bug fixes

some logic bug fixes

--- v2/Motor_control/Distance_Test/Distance_Test.ino
+++ v2/Motor_control/Distance_Test/Distance_Test.ino
@@ -69,11 +69,16 @@
 char past; //what direction the robot was moving previously
 int count; //counter for how long before the rebot gives up searching in one direction
 int threshold; //threshold for line sensors
-int cur; // current time
-int initTime; // time after initialization
+int curIR; // current time
+int prevIR;
+int curLine;
+int prevLine;
 short iter;
 int maxS;
 int minS;
+
+int near = 200;
+int far = 500;

 void setup() {
   Serial.begin(9600);
@@ -96,32 +101,38 @@
   leftDist = sensor2.getDist();
   perRightDist = sideright.getDist();
   perLeftDist = sideleft.getDist();
-  initTime = millis();
+  prevLine = millis();
+  prevIR = prevLine;
   setSpeed(128, 20);
 }

 void loop() {
-  // Get distance from sensor
-  cur = millis();
-    //print out values from sensors and motors to the console
-    Serial.print(past);
-    Serial.print(", ");
-    Serial.print(rightDist);
-    Serial.print(", ");
-    Serial.print(leftDist);
-    Serial.print(", ");
-    Serial.print(perRightDist);
-    Serial.print(", ");
-    Serial.print(perLeftDist);
-    Serial.print(", ");
-    Serial.print(analogRead(backleft));
-    Serial.print(", ");
-    Serial.print(analogRead(backright));
-    Serial.print(", ");
-    Serial.print(analogRead(frontleft));
-    Serial.print(", ");
-    Serial.println(analogRead(frontright));
-  if ((cur - initTime) % 5 == 0) {
+  curLine = millis();
+  curIR = curLine;
+
+  //print out values from sensors and motors to the console
+  Serial.print(past);
+  Serial.print(", ");
+  Serial.print(rightDist);
+  Serial.print(", ");
+  Serial.print(leftDist);
+  Serial.print(", ");
+  Serial.print(perRightDist);
+  Serial.print(", ");
+  Serial.print(perLeftDist);
+  Serial.print(", ");
+  Serial.print(analogRead(backleft));
+  Serial.print(", ");
+  Serial.print(analogRead(backright));
+  Serial.print(", ");
+  Serial.print(analogRead(frontleft));
+  Serial.print(", ");
+  Serial.println(analogRead(frontright));
+  Serial.print(", ");
+  Serial.println(curLine - prevLine);
+
+  if ((curLine - prevLine) >= 5) {
+    prevLine = curLine;
     if (analogRead(backleft) < threshold) { //first read from line sensors before doing anything else
       //if line detected by back-left line sensor, turn left a bit
       move(1, 40, 1); //motor 1, full speed, left
@@ -146,28 +157,30 @@
       move(2, 40, 1); //motor 2, full speed, left
       past = 'f';
       delay(50);
-    } else if ((cur - initTime) % 25 == 0){
+    } else if ((curIR - prevIR) >= 25){
+      prevIR = curIR;
+      // Get distance from sensors
       rightDist = sensor.getDist();
       leftDist = sensor2.getDist();
       perRightDist = sideright.getDist();
       perLeftDist = sideleft.getDist();
-      if (perLeftDist <= 300) {
-        //if there is an object within 300mm of the left peripheral sensor, move left
+      if (perLeftDist <= near) {
+        //if there is an object within nearmm of the left peripheral sensor, move left
         //turn left in place
         leftInPlace();
         past = 'l'; //set past movement to left
         count = 0; //reset abandon search count because the robot has found an object
-      } else if (perRightDist <= 300) {
-        //if there is an object within 300mm of the right peripheral sensor, move right
+      } else if (perRightDist <= near) {
+        //if there is an object within nearmm of the right peripheral sensor, move right
         //turn right in place
         rightInPlace();
         past = 'r'; //set past movement to left
         count = 0; //reset abandon search count because the robot has found an object
-      } else if (((past == 'f' || count >= 100) && (rightDist > 600 && leftDist > 600 && perRightDist > 600 && perLeftDist > 600))
-            || (rightDist <= 300 && leftDist <= 300 && perRightDist > 600 && perLeftDist > 600)
+      } else if (((past == 'f' || count >= 100) && (rightDist > far && leftDist > far && perRightDist > far && perLeftDist > far))
+            || (rightDist <= near && leftDist <= near)
             || (abs(rightDist - leftDist) <= 150)) {
-        //if (robot moved forward in the past OR it's been searching for 100 iterations) AND (there isn't an object within 600mm of any IR sensor))
-        //OR there is an object within 300mm of both sensors
+        //if (robot moved forward in the past OR it's been searching for 100 iterations) AND (there isn't an object within far of any IR sensor))
+        //OR there is an object within near of both sensors
         //OR the difference between the two distances measured by the IR sensors is within 150mm of each other
         //move forward
         forward();
@@ -183,13 +196,13 @@
         right();
         past = 'r'; //set past movement to right
         count++; //increment abandon search count
-      } else if (rightDist <= 600 || perRightDist <= 600) {
-        //if there is an object beyond 600mm of the left sensors (i.e. there is something closer in the right sensors), move right
+      } else if (rightDist <= far || perRightDist <= far) {
+        //if there is an object beyond farmm of the left sensors (i.e. there is something closer in the right sensors), move right
         right();
         past = 'r'; //set past movement to right
         count = 0; //reset abandon search count because the robot has found an object
-      } else if (leftDist <= 600 || perLeftDist <= 600) {
-        //if there is an object beyond 600mm of the right sensors (i.e. there is something closer in the left sensors), move left
+      } else if (leftDist <= far || perLeftDist <= far) {
+        //if there is an object beyond farmm of the right sensors (i.e. there is something closer in the left sensors), move left
         left();
         past = 'l'; //set past movement to left
         count = 0; //reset abandon search count because the robot has found an object


Fixed typo on name of variable

Fixed typo on name of variable

--- arduino/OpenROV/OpenROV.ino
+++ arduino/OpenROV/OpenROV.ino
@@ -33,7 +33,7 @@
 int average = 0;                // the average
 int new_tilt = MIDPOINT;
 int new_p = MIDPOINT;
-int new_c = MIDPOINT;
+int new_s = MIDPOINT;
 int new_v = MIDPOINT;
 int tilt_val = MIDPOINT;
 int p = MIDPOINT;
@@ -96,12 +96,12 @@
     if (p>new_p) new_p += min(smoothingIncriment,p-new_p);
     if (v<new_v) new_v -= min(smoothingIncriment,new_v-v);
     if (v>new_v) new_v += min(smoothingIncriment,v-new_v);
-    if (s<new_c) new_c -= min(smoothingIncriment,new_c-s);
-    if (s>new_c) new_c += min(smoothingIncriment,s-new_c);
+    if (s<new_s) new_s -= min(smoothingIncriment,new_s-s);
+    if (s>new_s) new_s += min(smoothingIncriment,s-new_s);
     if (tilt_val<new_tilt) new_tilt -= min(smoothingIncriment,new_tilt-tilt_val);
     if (tilt_val>new_tilt) new_tilt += min(smoothingIncriment,tilt_val-new_tilt);
     tilt.writeMicroseconds(new_tilt);
-    motors.go(new_p, new_v, new_c);
+    motors.go(new_p, new_v, new_s);
   }

   if (time.elapsed (100)) {
@@ -136,7 +136,7 @@
     Serial.print(",");
     Serial.print(new_v);
     Serial.print(",");
-    Serial.print(new_c);
+    Serial.print(new_s);
     Serial.print(";");
     Serial.print("mtarg:");
     Serial.print(p);


Give the xbee a bit more time to reconnect.

--- arduino/monitor/monitor.ino
+++ arduino/monitor/monitor.ino
@@ -76,7 +76,7 @@

   // wake radio
   digitalWrite(DIO_XBEE_SLEEP, LOW);
-  delay(100);
+  delay(200);

   // send message
   sendWeatherUpdate(xbeeSerial);


prepared homie-dht for deepsleep operation mode

--- homie-dht.ino
+++ homie-dht.ino
@@ -3,19 +3,41 @@

 static Sensor sensor;
 static HomieSetting<long> publishIntervalSetting("publishInterval", "publish interval in seconds");
+static HomieSetting<bool> deepSleepSetting("deepSleep", "true for using ESP deep sleep mode or false for not");

 static void setupHandler() {
+  publishIntervalSetting.setDefaultValue(60UL).setValidator([] (long candidate) {
+    return (candidate >= 2) && (candidate < 86400); // 2sec - 1day
+  });
+  deepSleepSetting.setDefaultValue(true);
+
   sensor.setup();
 }

 static void loopHandler() {
   static unsigned long lastPublish = 0;
-  if (millis() - lastPublish >= (publishIntervalSetting.get() * 1000UL) || lastPublish == 0) {
+  bool deepSleep = deepSleepSetting.get();
+  long publishInterval = publishIntervalSetting.get();
+
+  if (millis() - lastPublish >= (publishInterval * 1000UL) || lastPublish == 0) {
     lastPublish = millis();
-    if(!sensor.publish()) {
-      lastPublish -= (publishIntervalSetting.get() * 1000UL);
+    if (!sensor.publish()) {
+      lastPublish -= (publishInterval * 1000UL); // reading failed, give it another try in 2 seconds
       lastPublish += 2000UL;
+    } else {
+      Homie.getLogger() << "Preparing for deep sleep (" << publishInterval << " seconds)" << endl;
+//      Homie.prepareToSleep();
     }
+  }
+}
+
+void onHomieEvent(const HomieEvent& event) {
+  switch (event.type) {
+    case HomieEventType::READY_TO_SLEEP:
+      Homie.getLogger() << "Ready to sleep" << endl;
+      // convert to microseconds
+      ESP.deepSleep(publishIntervalSetting.get() * 1000000);
+      break;
   }
 }

@@ -23,19 +45,16 @@
   Serial.begin(115200);
   Serial << endl << endl;

-  Homie_setFirmware("HomieDht", "0.1");
+  Homie_setFirmware("HomieDht", "0.2");
   Homie_setBrand("HomieDht"); // before Homie.setup()
-  Homie.setSetupFunction(setupHandler).setLoopFunction(loopHandler);
+  Homie.setSetupFunction(setupHandler).setLoopFunction(loopHandler).onEvent(onHomieEvent);
+  Homie.disableLogging();
   Homie.disableLedFeedback();
   Homie.disableResetTrigger();
-
-  publishIntervalSetting.setDefaultValue(30UL).setValidator([] (long candidate) {
-    return (candidate >= 2) && (candidate < 86400); // 2sec - 1day
-  });

   Homie.setup();
 }

 void loop() {
   Homie.loop();
-}
+}


Added Get/Set Delay to Rest Api

Added Get/Set Delay to Rest Api

--- Arduino/McLighting/McLighting.ino
+++ Arduino/McLighting/McLighting.ino
@@ -445,6 +445,28 @@
     DBG_OUTPUT_PORT.print("/get_brightness: ");
     DBG_OUTPUT_PORT.println(str_brightness);
   });
+
+  server.on("/set_delay", []() {
+    if (server.arg("d").toInt() >= 0) {
+      ws2812fx_speed = server.arg("d").toInt();
+    }
+    if (ws2812fx_speed > 255) {
+      ws2812fx_speed = 255;
+    }
+    if (ws2812fx_speed < 0) {
+      ws2812fx_speed = 0;
+    }
+    strip.setSpeed(ws2812fx_speed);
+
+    getStatusJSON();
+  });
+
+  server.on("/get_delay", []() {
+    String str_delay = String(ws2812fx_speed);
+    server.send(200, "text/plain", str_delay );
+    DBG_OUTPUT_PORT.print("/get_delay: ");
+    DBG_OUTPUT_PORT.println(str_delay);
+  });

   server.on("/get_switch", []() {
     server.send(200, "text/plain", (mode == OFF) ? "0" : "1" );


drawMeter function, stubbed serial command to change log level (doesn't work)

--- laserharp.ino
+++ laserharp.ino
@@ -71,15 +71,25 @@
 int reflectedLightValues[numberNotes];

-#define LOGLEVEL LOG_LEVEL_NOOUTPUT
-//#define LOGLEVEL LOG_LEVEL_ERRORS
-//#define LOGLEVEL LOG_LEVEL_INFOS
-//#define LOGLEVEL LOG_LEVEL_DEBUG
-//#define LOGLEVEL LOG_LEVEL_VERBOSE
+int gLogLevel = LOG_LEVEL_NOOUTPUT;
+//int gLogLevel = LOG_LEVEL_ERRORS;
+//int gLogLevel = LOG_LEVEL_INFOS;
+//int gLogLevel = LOG_LEVEL_DEBUG;
+//int gLogLevel = LOG_LEVEL_VERBOSE;
+
+
+// buf must be an array with length > segmentCount. This function can write to buf[segmentCount]
+void drawMeter(int value, int maxValue, char * buf, char segmentSymbol = '=', size_t totalSegments = 80)
+{
+    float scaleFactor = (float)totalSegments / maxValue;
+    int segmentCount = (int)(0.5 + (min(value, maxValue) * scaleFactor));
+    memset(buf, segmentSymbol, segmentCount);
+    buf[segmentCount] = 0;
+}

 void setup()
 {
-  Log.Init(LOGLEVEL, 9600);
+  Log.Init(gLogLevel, 9600);
   harpNoteDetector.setNumNotes(numberNotes);

   //For the light sensor
@@ -161,7 +171,10 @@
 {
   int height = analogRead(sonarPin);

-  Log.Verbose("Height: %d\n", height);
+  char heightBuf[81] = {0};
+  drawMeter(height, 160, heightBuf);
+//  Log.Info("%s\n", heightBuf);
+  Serial.println(heightBuf);

   if (height > 170)
   {
@@ -225,10 +238,13 @@
     myMotor->step(stepSize, directionToStep, DOUBLE);
   delay(delayBetweenSteps);
   int currentLightReading = analogRead(lightSensorPin);
+
+  char lightBuf[81] = {0};
+  drawMeter(currentLightReading, 600, lightBuf, '.');
+  Log.Info("%s\n", lightBuf);
   return currentLightReading;
 }

-//Is debug on? If so print some data.
 void checkNotes(int reflectedLightValues[], boolean pluckedNotes[])
 {
   for (int i = 0; i < numberNotes; i++)
@@ -294,6 +310,11 @@
       case 'p':
         gPauseMotor = !gPauseMotor;
         break;
+      case 'l':
+        gLogLevel = (gLogLevel + 1) % (LOG_LEVEL_VERBOSE + 1);
+        //Log.Init(9600, gLogLevel);
+        static const  char* levelStrings[]  = {"DISABLED","VERBOSE", "DEBUG", "INFO", "ERROR"};
+        Serial.print("Log level is "); Serial.println(levelStrings[gLogLevel]);
       default:
         Log.Error("Ignorning unknown command: %c\n", c);

@@ -322,7 +343,6 @@
     checkNotes(reflectedLightValues, pluckedNotes);
   }

-  //checkButtons();
   checkSonar();

   //It just read item 7. So going backwards, read items 6 through zero.


fixed closing bracket

fixed closing bracket

--- CUBE/CUBE.ino
+++ CUBE/CUBE.ino
@@ -82,7 +82,7 @@
   uint64_t currentTime = millis();
   randomTimer++;

-  if (digitalRead(BUTTON_PIN) == LOW || (currentTime - lastEffectChange >= effectDuration && autoRotate) {
+  if (digitalRead(BUTTON_PIN) == LOW || (currentTime - lastEffectChange >= effectDuration && autoRotate)) {
     lastEffectChange = millis();
     clearCube();
     loading = true;


Due does not have EEPROM

Due does not have EEPROM

--- selftest.ino
+++ selftest.ino
@@ -269,7 +269,7 @@
   GD.self_calibrate();
   // write the new calibration back to EEPROM

-#ifndef RASPBERRY_PI
+#if !defined(RASPBERRY_PI) && !defined(__DUE__)
   for (int i = 0; i < 24; i++)
     EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i));
 #endif


Fix test_dicionary on device

Fix test_dicionary on device

--- src/tests/unit/dictionary/dictionary.ino
+++ src/tests/unit/dictionary/dictionary.ino
@@ -1,5 +1,6 @@
+#include <Arduino.h>
 #include <SPI.h>
-#include <Arduino.h>
+#include <SD.h>
 #include "test_dictionary.h"

 void


UI fixes for stand-alone in glove mode.

UI fixes for stand-alone in glove mode.

--- messenger.ino
+++ messenger.ino
@@ -35,13 +35,14 @@
 //  brk is used for character break (one tap) word break (two taps)
 //  or sentence break (three taps).
 #define BUTTON_PIN_DIT   12
-#define BUTTON_PIN_DAH   6
-#define BUTTON_PIN_BRK   9
+#define BUTTON_PIN_DAH   9
+#define BUTTON_PIN_BRK   6
 #define BUTTON_PIN_SND   10

+#define NUMPIXELS    1
 #define PIXEL_PIN    8    // Digital IO pin connected to the NeoPixels.

-Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

 // BLE HID Setup
 #define FACTORYRESET_ENABLE         0
@@ -64,7 +65,7 @@
 int nBrk = 0;

 void setup() {
-  while (!Serial);  // required for Flora & Micro
+  //while (!Serial);  // required for Flora & Micro
   delay(500);

   Serial.begin(115200);
@@ -86,8 +87,8 @@
   bSND.attach(BUTTON_PIN_SND);
   bSND.interval(DEBOUNCE);

-  strip.begin();
-  strip.show(); // Initialize all pixels to 'off'
+  pixels.begin();
+  pixels.show(); // Initialize all pixels to 'off'

   // BLE HID Keyboard setup

@@ -157,6 +158,7 @@
     //printMorseChar();
     //printMessage();
     nBrk = 0;
+    blink(0, 255, 255);
   } else if (bDAH.fell()) {
     Serial.println("dah");
     addMorse(3);
@@ -164,6 +166,7 @@
     //printMorseChar();
     //printMessage();
     nBrk = 0;
+    blink(255, 0, 255);
   } else if (bBRK.fell()) {
     Serial.println("brk");
     if (nBrk == 0) {
@@ -173,6 +176,7 @@
     }
     clearMorse();
     nBrk++;
+    blink(255, 150, 0);
   } else if (bSND.fell()) {
     Serial.println("snd");
     printMessage();
@@ -198,9 +202,11 @@
   if( ble.waitForOK() )
   {
     Serial.println( F("OK!") );
+    blink(0, 255, 0);
   }else
   {
     Serial.println( F("FAILED!") );
+    blink(255, 0, 0);
   }
 }

@@ -315,27 +321,43 @@
   }
 }

+void blink(int red, int green, int blue) {
+  // Turn on
+  for(uint8_t i=0; i<NUMPIXELS; i++) {
+    pixels.setPixelColor(i, pixels.Color(red,green,blue));
+    }
+  pixels.show();
+
+  // Wait
+  delay(100);
+
+  // Turn off
+  for(uint8_t i=0; i<NUMPIXELS; i++) {
+    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
+  }
+  pixels.show();
+}

 void setColor(int i) {
   switch(i){
-    case 0: colorWipe(strip.Color(0, 0, 0), 50);  // Black/off
-            break;
-    case 1: colorWipe(strip.Color(255, 0, 0), 50);      // Red
-            break;
-    case 2: colorWipe(strip.Color(0, 255, 0), 50);  // Green
-            break;
-    case 3: colorWipe(strip.Color(0, 0, 255), 50);  // Blue
-            break;
-    case 4: colorWipe(strip.Color(127, 127, 127), 50);  // White
+    case 0: colorWipe(pixels.Color(0, 0, 0), 50);  // Black/off
+            break;
+    case 1: colorWipe(pixels.Color(255, 0, 0), 50);      // Red
+            break;
+    case 2: colorWipe(pixels.Color(0, 255, 0), 50);  // Green
+            break;
+    case 3: colorWipe(pixels.Color(0, 0, 255), 50);  // Blue
+            break;
+    case 4: colorWipe(pixels.Color(127, 127, 127), 50);  // White
             break;
   }
 }

 // Fill the dots one after the other with a color
 void colorWipe(uint32_t c, uint8_t wait) {
-  for(uint16_t i=0; i<strip.numPixels(); i++) {
-    strip.setPixelColor(i, c);
-    strip.show();
+  for(uint16_t i=0; i<pixels.numPixels(); i++) {
+    pixels.setPixelColor(i, c);
+    pixels.show();
     delay(wait);
   }
 }


Get the mpr and 9dof working together in a chain...sort of

--- mouse_rat.ino
+++ mouse_rat.ino
@@ -2,6 +2,7 @@
 #include <Wire.h>
 #include <Adafruit_Sensor.h>
 #include <Adafruit_LSM9DS0.h>
+#include "Adafruit_MPR121.h"

 /* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
    which provides a common 'type' for sensor data and some helper functions.
@@ -28,7 +29,9 @@
 */

 /* Assign a unique base ID for this sensor */
-Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0(1000);  // Use I2C, ID #1000
+
+// 9DOF
+Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0(1005);  // Use I2C, ID #1000
 #define LSM9DS0_XM_CS 10
 #define LSM9DS0_GYRO_CS 9
 #define LSM9DS0_SCLK 13
@@ -37,63 +40,18 @@

 float xNormal = -3.0;
 float yNormal = 1;
-
 float xRange[] = {0,0};
 float yRange[] = {0,0};

-void displaySensorDetails(void) {
-  sensor_t accel, mag, gyro, temp;
-
-  lsm.getSensor(&accel, &mag, &gyro, &temp);
-
-  Serial.println(F("------------------------------------"));
-  Serial.print  (F("Sensor:       ")); Serial.println(accel.name);
-  Serial.print  (F("Driver Ver:   ")); Serial.println(accel.version);
-  Serial.print  (F("Unique ID:    ")); Serial.println(accel.sensor_id);
-  Serial.print  (F("Max Value:    ")); Serial.print(accel.max_value); Serial.println(F(" m/s^2"));
-  Serial.print  (F("Min Value:    ")); Serial.print(accel.min_value); Serial.println(F(" m/s^2"));
-  Serial.print  (F("Resolution:   ")); Serial.print(accel.resolution); Serial.println(F(" m/s^2"));
-  Serial.println(F("------------------------------------"));
-  Serial.println(F(""));
-
-  Serial.println(F("------------------------------------"));
-  Serial.print  (F("Sensor:       ")); Serial.println(mag.name);
-  Serial.print  (F("Driver Ver:   ")); Serial.println(mag.version);
-  Serial.print  (F("Unique ID:    ")); Serial.println(mag.sensor_id);
-  Serial.print  (F("Max Value:    ")); Serial.print(mag.max_value); Serial.println(F(" uT"));
-  Serial.print  (F("Min Value:    ")); Serial.print(mag.min_value); Serial.println(F(" uT"));
-  Serial.print  (F("Resolution:   ")); Serial.print(mag.resolution); Serial.println(F(" uT"));
-  Serial.println(F("------------------------------------"));
-  Serial.println(F(""));
-
-  Serial.println(F("------------------------------------"));
-  Serial.print  (F("Sensor:       ")); Serial.println(gyro.name);
-  Serial.print  (F("Driver Ver:   ")); Serial.println(gyro.version);
-  Serial.print  (F("Unique ID:    ")); Serial.println(gyro.sensor_id);
-  Serial.print  (F("Max Value:    ")); Serial.print(gyro.max_value); Serial.println(F(" rad/s"));
-  Serial.print  (F("Min Value:    ")); Serial.print(gyro.min_value); Serial.println(F(" rad/s"));
-  Serial.print  (F("Resolution:   ")); Serial.print(gyro.resolution); Serial.println(F(" rad/s"));
-  Serial.println(F("------------------------------------"));
-  Serial.println(F(""));
-
-  Serial.println(F("------------------------------------"));
-  Serial.print  (F("Sensor:       ")); Serial.println(temp.name);
-  Serial.print  (F("Driver Ver:   ")); Serial.println(temp.version);
-  Serial.print  (F("Unique ID:    ")); Serial.println(temp.sensor_id);
-  Serial.print  (F("Max Value:    ")); Serial.print(temp.max_value); Serial.println(F(" C"));
-  Serial.print  (F("Min Value:    ")); Serial.print(temp.min_value); Serial.println(F(" C"));
-  Serial.print  (F("Resolution:   ")); Serial.print(temp.resolution); Serial.println(F(" C"));
-  Serial.println(F("------------------------------------"));
-  Serial.println(F(""));
-
-  delay(500);
-}
-
-/**************************************************************************/
-/*
-    Configures the gain and integration time for the TSL2561
-*/
-/**************************************************************************/
+// MPR121
+// You can have up to 4 on one i2c bus but one is enough for testing!
+Adafruit_MPR121 cap = Adafruit_MPR121();
+
+uint16_t lasttouched = 0;
+uint16_t currtouched = 0;
+
+// Configures the gain and integration time for the TSL2561
+
 void configureSensor(void) {
   // 1.) Set the accelerometer range
   //lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_2G);
@@ -114,34 +72,56 @@
   //lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_2000DPS);
 }

-/**************************************************************************/
-/*
-    Arduino setup function (automatically called at startup)
-*/
-/**************************************************************************/
 void setup(void) {
   Serial.begin(9600);
-
-  /* Initialise the sensor */
+
+  dof_setup();
+  mpr_setup();
+}
+
+
+void mpr_setup() {
+  while (!Serial);        // needed to keep leonardo/micro from starting too fast!
+
+  Serial.begin(9600);
+  Serial.println("Adafruit MPR121 Capacitive Touch sensor test");
+
+  // Default address is 0x5A, if tied to 3.3V its 0x5B
+  // If tied to SDA its 0x5C and if SCL then 0x5D
+  if (!cap.begin(0x5A)) {
+    Serial.println("MPR121 not found, check wiring?");
+    while (1);
+  }
+  Serial.println("MPR121 found!");
+}
+
+void dof_setup() {
+  // 9DOF
   if(!lsm.begin()) { while(1); }

   /* Setup the sensor gain and integration time */
   configureSensor();

+  // Set a max and min value to not do anything
+  // calibrate(accel.acceleration.x, accel.acceleration.y);
+
   sensors_event_t accel, mag, gyro, temp;
   lsm.getEvent(&accel, &mag, &gyro, &temp);
-
-  calibrate(accel.acceleration.x, accel.acceleration.y);
 }

 void loop(void) {
+  dof_loop();
+  mpr_loop();
+}
+
+void dof_loop() {
   /* Get a new sensor event */
   sensors_event_t accel, mag, gyro, temp;

   lsm.getEvent(&accel, &mag, &gyro, &temp);

   float mx, my = 0.0;
-  float accel_x = clamp(accel.acceleration.y, -20, 20)
+//  float accel_x = clamp(accel.acceleration.y, -20, 20)

   if (accel.acceleration.x > xRange[1] || accel.acceleration.x < xRange[0]) {
     my = map(accel.acceleration.x - xNormal, -20, 20, 200, -200);
@@ -152,20 +132,45 @@
     mx = map(accel.acceleration.y - yNormal, -20, 20, 200, -200);
   }
   Mouse.move(mx, my, 0);
-
-//  print out accelleration data
-//  Serial.print("Accel X: "); Serial.print(accel.acceleration.x); Serial.print(" ");
-//  Serial.print("  \tY: "); Serial.print(accel.acceleration.y);   Serial.print(" ");
-//  Serial.print("  \tZ: "); Serial.print(accel.acceleration.z);   Serial.println("  \tm/s^2");
-//  Serial.print("Magn. X: "); Serial.print(mag.magnetic.x); Serial.print(" ");
-//  Serial.print("  \tY: "); Serial.print(mag.magnetic.y);       Serial.print(" ");
-//  Serial.print("  \tZ: "); Serial.print(mag.magnetic.z);     Serial.println("  \tgauss");
-//  Serial.print("Gyro  X: "); Serial.print(gyro.gyro.x); Serial.print(" ");
-//  Serial.print("  \tY: "); Serial.print(gyro.gyro.y);       Serial.print(" ");
-//  Serial.print("  \tZ: "); Serial.print(gyro.gyro.z);     Serial.println("  \tdps");
-//  Serial.print("Temp: "); Serial.print(temp.temperature); Serial.println(" *C");
-
   delay(10);
+}
+
+void mpr_loop() {
+ // Get the currently touched pads
+  currtouched = cap.touched();
+
+  for (uint8_t i=0; i < 12; i++) {
+    // it if *is* touched and *wasnt* touched before, alert!
+    if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
+      Serial.print(i); Serial.println(" touched");
+    }
+    // if it *was* touched and now *isnt*, alert!
+    if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
+      Serial.print(i); Serial.println(" released");
+    }
+  }
+
+  // reset our state
+  lasttouched = currtouched;
+
+  // comment out this line for detailed data from the sensor!
+  return;
+
+  // debugging info, what
+  Serial.print("\t\t\t\t\t\t\t\t\t\t\t\t\t 0x"); Serial.println(cap.touched(), HEX);
+  Serial.print("Filt: ");
+  for (uint8_t i=0; i < 12; i++) {
+    Serial.print(cap.filteredData(i)); Serial.print("\t");
+  }
+  Serial.println();
+  Serial.print("Base: ");
+  for (uint8_t i=0; i < 12; i++) {
+    Serial.print(cap.baselineData(i)); Serial.print("\t");
+  }
+  Serial.println();
+
+  // put a delay so it isn't overwhelming
+  delay(100);
 }

 void calibrate(float x, float y) {
@@ -180,9 +185,58 @@

    Serial.print(xRange[0]); Serial.print(", "); Serial.println(xRange[1]);
    Serial.print(yRange[0]); Serial.print(", "); Serial.println(yRange[1]);
- }
-
-template<typename T>
-T clamp(T Value, T Min, T Max) {
-  return (Value < Min)? Min : (Value > Max)? Max : Value;
-}
+}
+
+//template<typename T>
+//T clamp(T Value, T Min, T Max) {
+//  return (Value < Min)? Min : (Value > Max)? Max : Value;
+//}
+
+
+void displaySensorDetails(void) {
+  sensor_t accel, mag, gyro, temp;
+
+  lsm.getSensor(&accel, &mag, &gyro, &temp);
+
+  Serial.println(F("------------------------------------"));
+  Serial.print  (F("Sensor:       ")); Serial.println(accel.name);
+  Serial.print  (F("Driver Ver:   ")); Serial.println(accel.version);
+  Serial.print  (F("Unique ID:    ")); Serial.println(accel.sensor_id);
+  Serial.print  (F("Max Value:    ")); Serial.print(accel.max_value); Serial.println(F(" m/s^2"));
+  Serial.print  (F("Min Value:    ")); Serial.print(accel.min_value); Serial.println(F(" m/s^2"));
+  Serial.print  (F("Resolution:   ")); Serial.print(accel.resolution); Serial.println(F(" m/s^2"));
+  Serial.println(F("------------------------------------"));
+  Serial.println(F(""));
+
+  Serial.println(F("------------------------------------"));
+  Serial.print  (F("Sensor:       ")); Serial.println(mag.name);
+  Serial.print  (F("Driver Ver:   ")); Serial.println(mag.version);
+  Serial.print  (F("Unique ID:    ")); Serial.println(mag.sensor_id);
+  Serial.print  (F("Max Value:    ")); Serial.print(mag.max_value); Serial.println(F(" uT"));
+  Serial.print  (F("Min Value:    ")); Serial.print(mag.min_value); Serial.println(F(" uT"));
+  Serial.print  (F("Resolution:   ")); Serial.print(mag.resolution); Serial.println(F(" uT"));
+  Serial.println(F("------------------------------------"));
+  Serial.println(F(""));
+
+  Serial.println(F("------------------------------------"));
+  Serial.print  (F("Sensor:       ")); Serial.println(gyro.name);
+  Serial.print  (F("Driver Ver:   ")); Serial.println(gyro.version);
+  Serial.print  (F("Unique ID:    ")); Serial.println(gyro.sensor_id);
+  Serial.print  (F("Max Value:    ")); Serial.print(gyro.max_value); Serial.println(F(" rad/s"));
+  Serial.print  (F("Min Value:    ")); Serial.print(gyro.min_value); Serial.println(F(" rad/s"));
+  Serial.print  (F("Resolution:   ")); Serial.print(gyro.resolution); Serial.println(F(" rad/s"));
+  Serial.println(F("------------------------------------"));
+  Serial.println(F(""));
+
+  Serial.println(F("------------------------------------"));
+  Serial.print  (F("Sensor:       ")); Serial.println(temp.name);
+  Serial.print  (F("Driver Ver:   ")); Serial.println(temp.version);
+  Serial.print  (F("Unique ID:    ")); Serial.println(temp.sensor_id);
+  Serial.print  (F("Max Value:    ")); Serial.print(temp.max_value); Serial.println(F(" C"));
+  Serial.print  (F("Min Value:    ")); Serial.print(temp.min_value); Serial.println(F(" C"));
+  Serial.print  (F("Resolution:   ")); Serial.print(temp.resolution); Serial.println(F(" C"));
+  Serial.println(F("------------------------------------"));
+  Serial.println(F(""));
+
+  delay(500);
+}


Testing if putting delays between CC3000 writes improves stability... And other HTTP request cleanups.

--- SimpleCSV.ino
+++ SimpleCSV.ino
@@ -1,9 +1,16 @@
 SdCard card;
 Fat16 file;

-#define FORM_BOUNDARY "--KegScribeCSVFile"
-#define FILE_HEADER "\r\nContent-Disposition: form-data; name=\"f\"; filename=\"filename.csv\"\r\nContent-Type: text/csv\r\n\r\n"
-const char SUCCESS_RESPONSE[] = "HTTP/1.1 200 OK";
+#define FORM_BOUNDARY_PREFIX "--"
+#define FORM_BOUNDARY_BASE "KegScribeCSVFile"
+#define FORM_BOUNDARY FORM_BOUNDARY_PREFIX FORM_BOUNDARY_BASE
+#define FORM_BOUNDARY_END FORM_BOUNDARY FORM_BOUNDARY_PREFIX "\r\n"
+#define FORM_BOUNDARY_START FORM_BOUNDARY "\r\n"
+
+#define CC3000_DELAY 100
+
+#define FILE_HEADER "Content-Disposition: form-data; name=\"file\"; filename=\"filename.csv\"\r\nContent-Type: text/csv\r\n\r\n"
+const char SUCCESS_RESPONSE[] = "HTTP/1.1 200 OK\r\n";

 void initSD() {
   pinMode(SD_CHIP_SELECT_PIN, OUTPUT);
@@ -65,6 +72,16 @@
   Serial.print(OK_MSG);

   return 0;
+}
+
+int safeprint(Adafruit_CC3000_Client* www, const __FlashStringHelper* string) {
+  delay(CC3000_DELAY);
+  return www->fastrprint(string);
+}
+
+int safeprint(Adafruit_CC3000_Client* www, char* string) {
+  delay(CC3000_DELAY);
+  return www->fastrprint(string);
 }

 int reportFile(Fat16* file) {
@@ -81,42 +98,55 @@
   */
   Serial.print(F("tcp connect"));
   Adafruit_CC3000_Client www = cc3000->connectTCP(ip, 80);
-
-  uint32_t totalContentLength = ((strlen(FORM_BOUNDARY)+2)*2) + strlen(FILE_HEADER) + 2;
+
+  // calculate the content-length in bytes
+  uint32_t totalContentLength = strlen(FORM_BOUNDARY_START) + strlen(FILE_HEADER) + 2 + strlen(FORM_BOUNDARY_END);
+
   totalContentLength += file->fileSize();
-
+
   if (www.connected()) {
-    www.fastrprint(F("POST ")); www.fastrprint(CSV_WEBPAGE); www.fastrprint(F(" HTTP/1.1"));
-    www.fastrprint(F("\r\nHost: ")); www.fastrprint(WEBSITE);
-    www.fastrprint(F("\r\nAuthorization: Basic a2Vnc2NyaWJlOnRlc3Q="));
-    www.fastrprint(F("\r\nUser-Agent: KegScribe"));
-    www.fastrprint(F("\r\nContent-Length: ")); www.print(totalContentLength);
-    www.fastrprint(F("\r\nContent-Type: multipart/form-data; boundary=")); www.fastrprint(FORM_BOUNDARY);
-    www.fastrprint("\r\n\r\n"); www.fastrprint(FORM_BOUNDARY);
-    www.fastrprint(F(FILE_HEADER));
-
-    int16_t n;
-    uint8_t buf[7] = {0,0,0,0,0,0,0};// nothing special about 7, just a lucky number.
-    // read sizeof(buf)-1 bytes into buf
-    while ((n = file->read(buf, sizeof(buf)-1)) > 0) {
-      www.fastrprint((char*)buf);
-    }
-
-    www.fastrprint(FORM_BOUNDARY); www.fastrprint("--");
-
+    safeprint(&www, F("POST ")); safeprint(&www, CSV_WEBPAGE); safeprint(&www, F(" HTTP/1.1"));
+    safeprint(&www, F("\r\nHost: ")); safeprint(&www, WEBSITE);
+    safeprint(&www, F("\r\nAuthorization: Basic a2Vnc2NyaWJlOnRlc3Q="));
+    safeprint(&www, F("\r\nUser-Agent: KegScribe"));
+    safeprint(&www, F("\r\nConnection: Close"));
+    safeprint(&www, F("\r\nContent-Length: ")); www.print(totalContentLength);
+    safeprint(&www, F("\r\nContent-Type: multipart/form-data; boundary=")); safeprint(&www, FORM_BOUNDARY_BASE "\r\n");
+    safeprint(&www, F("\r\n"));
+
+    safeprint(&www, FORM_BOUNDARY_START);
+    safeprint(&www, F(FILE_HEADER));
+
+    Serial.print(" header");
+
+    int16_t c;
+    while ((c = file->read()) > 0) {
+      Serial.print(c);
+      www.write(&c, 1, 0);
+      delay(CC3000_DELAY);
+    }
+
+    safeprint(&www, F("\r\n"));
+    safeprint(&www, FORM_BOUNDARY_END);
+
+    Serial.print(" sent");

     // Read data until either the connection is closed, or the idle timeout is reached.
     byte i = 0;
     unsigned long lastRead = millis();
     while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
+      Serial.print("Reading response...\r\n");
+      delay(CC3000_DELAY);
       while (www.available() && (i < strlen(SUCCESS_RESPONSE))) {
         char c = www.read();
+        Serial.print(c);
         if ((i < strlen(SUCCESS_RESPONSE)) && c != SUCCESS_RESPONSE[i++]) {
           Serial.print(FAIL_MSG);
+          www.close();
           return 2;
         }
-        Serial.print(c);
         lastRead = millis();
+        delay(CC3000_DELAY);
       }
     }


Switching to sending keep alive messages.

--- WhereDial.ino
+++ WhereDial.ino
@@ -320,7 +320,6 @@
   Serial.print("Calculated path=");
   Serial.println(path);

-  http.setHttpResponseTimeout(120000l);
   err = http.get(ip, apiHostname,apiPort, path, userAgent);
   if (err == 0)
   {
@@ -332,32 +331,50 @@
     /* OK - TURN DOWN LED  02 */
     digitalWrite(errorLeds[3],LOW);
     Serial.println("Started request ok");
+    while (http.available() && http.peek() == '!') {
+      http.read();
+    }
     if (!http.available()) {
       digitalWrite(errorLeds[2],LOW);
       digitalWrite(errorLeds[1],LOW);
       digitalWrite(errorLeds[0],LOW);
+      unsigned long keepAliveTimeoutStart = millis();
+      while (!http.available() && http.connected()) {
+        delay(10);
+        if ((millis() - keepAliveTimeoutStart) > 10000) {
+          Serial.print("millis()=");
+          Serial.print(millis());
+          Serial.print(":keepAliveTimeoutStart=");
+          Serial.println(keepAliveTimeoutStart);
+          Serial.println("Sending keep alive");
+          if (!client.sendKeepAlive()) {
+            Serial.println("Keep alive failed");
+            break;
+          } else {
+            keepAliveTimeoutStart = millis();
+            Serial.println("Keep alive successful");
+          }
+        }
+      }
+      // If we've disconnected with no data available,
+      // it's a connection problem not a status code problem
+      if (! http.available()) {
+        Serial.println("Disconnected");
+        digitalWrite(errorLeds[3],HIGH);
+      } else {
+        Serial.println("Turns out we have data");
+      }
+      digitalWrite(errorLeds[2],HIGH);
+      digitalWrite(errorLeds[1],HIGH);
+      digitalWrite(errorLeds[0],HIGH);
     } else {
       Serial.println("We have data straight away");
     }

-    err = http.responseStatusCode();
-    digitalWrite(errorLeds[2],HIGH);
-    digitalWrite(errorLeds[1],HIGH);
-    digitalWrite(errorLeds[0],HIGH);
-
-    if ((err == HTTP_ERROR_TIMED_OUT))
-    {
-      // Ignore this
-      ret = 1;
-      // Make sure we don't turn
-      prev = actual;
-      placeChanged = 0;
-      Serial.println("Ignoring time out");
-      Serial.print("millis()=");
-      Serial.println(millis());
-
-    }
-    else if ((err >= 200) && (err < 300))
+    if (http.connected()||http.available()) {
+      err = http.responseStatusCode();
+    }
+    if ((err >= 200) && (err < 300))
     {

       /* OK - TURN DOWN LED  03 */


This works with board 2.0.2. It is capable of reading a piece of text. Still need to find a way to delimit it


Ajustes para compilar

Ajustes para compilar

SANTO PONTO E VÍRGULA


Moved output filename name up to start Fixed bug with initial condition on the motor

--- fed-arduino/fed-arduino.ino
+++ fed-arduino/fed-arduino.ino
@@ -12,6 +12,7 @@
 #include <avr/io.h>
 #include <SoftwareSerial.h>

+#define FILENAME "PELLET_Cage12.csv"

 #define DISPLAY_SERIAL_RX_PIN 255 // we don't need a receive pin, 255 indicates this
 // Connect the Arduino pin 3 to the rx pin on the 7 segment display
@@ -19,7 +20,6 @@

 SoftwareSerial LEDserial = SoftwareSerial(DISPLAY_SERIAL_RX_PIN, DISPLAY_SERIAL_TX_PIN);
 SdFat SD;
-

 long previousMillis = 0;
 long startTime = 0;
@@ -74,7 +74,7 @@
   // the number of sucrose deliveries, the number of active and
   // inactive pokes, and the number of drinking well entries.

-  dataFile = SD.open("PELLETJuly.csv", FILE_WRITE);
+  dataFile = SD.open(FILENAME, FILE_WRITE);
   if (dataFile) {
     Serial.println(F("File successfully written..."));
     Serial.println(time);
@@ -174,7 +174,14 @@
   }

   motor.setSpeed(35);
+  setMotorToTurn();
+
   delay (500);
+
+  // get ready for what the system should be doing
+  PIState = digitalRead(PIPin);
+  lastState = 0;
+
 }

 void loop()


Update PrintAllVirtual.ino

Update PrintAllVirtual.ino

--- examples/More/PrintAllVirtual/PrintAllVirtual.ino
+++ examples/More/PrintAllVirtual/PrintAllVirtual.ino
@@ -13,7 +13,7 @@
  * This example code is in public domain.
  *
  **************************************************************
- * This sketch prints all virtual pin operations!
+ * This sketch prints all virtual pin's operations!
  *
  **************************************************************/


As per https://github.com/adafruit/travis-ci-arduino/issues/8#issuecomment-131639932

--- ESP8266HueEmulator/ESP8266HueEmulator.ino
+++ ESP8266HueEmulator/ESP8266HueEmulator.ino
@@ -12,7 +12,7 @@

 #include <ESP8266WiFi.h>
 #include <ESP8266WebServer.h>
-#include <WiFiUDP.h>
+#include <WiFiUdp.h>
 #include <ESP8266SSDP.h>
 #include <NeoPixelBus.h> // NeoPixelAnimator branch
 #include <aJSON.h> // Replace avm/pgmspace.h with pgmspace.h there and set #define PRINT_BUFFER_LEN 4096 ################# IMPORTANT


Added 'vars' to dump out variables

Added 'vars' to dump out variables

--- src/BLuB.ino
+++ src/BLuB.ino
@@ -11,6 +11,7 @@

 // v0.02  2013-June-19  New prompt (Smiley)
 //			ops:	NP RE ST
+//			cmds:   vars
 //
 // v0.01  2013-June-19  Line entry, line editing
 //			cmds: 	help, mem, new, list
@@ -58,7 +59,7 @@
 	// find the integer starting at buf[0]
 	while( *buf <= '9' && *buf >= '0' && v<kBufLen  ) {
 		buffer[v++] = *buf;
-		*buf++;
+		buf++;
 	}
 	if( v == 0 ) {
 		// no number!
@@ -131,7 +132,7 @@
 	Serial.println( "" );
 	Serial.println( "Available commands:" );
 	//                   ------- ------- ------- ------- -------
-	Serial.println( "    help    mem     new     list" );
+	Serial.println( "    help    mem     vars    new     list" );
 	Serial.println( "    run     tron    troff" );
 	Serial.println( "    elist   eload   esave   enew" );
 	//                   ------- ------- ------- ------- -------
@@ -250,6 +251,20 @@
 	variables[ VarCharToIndex( 'z' ) ] = 0x00;
 }

+void cmd_vars( void )
+{
+	char buf[20];
+	Serial.println( "Variables:" );
+	for( int i=0 ; i<(kNVariables/2) ; i++ )
+	{
+		snprintf( buf, 20, "  %c %-9d", i+'a', variables[i] );
+		Serial.print( buf );
+
+		snprintf( buf, 20, "    %c %-9d", i+13+'a', variables[i+13] );
+		Serial.println( buf );
+	}
+}
+
 void cmd_new( void )
 {
 	for( int i=0 ; i<kRamSize ; i++ )
@@ -259,6 +274,7 @@
 	init_vars();

 }
+

 void cmd_list( void )
 {
@@ -540,6 +556,7 @@

 	else if( !strcmp( linebuf, "new" )) { cmd_new(); }
 	else if( !strcmp( linebuf, "list" )) { cmd_list(); }
+	else if( !strcmp( linebuf, "vars" )) { cmd_vars(); }
 	else if( !strcmp( linebuf, "help" )) { cmd_help(); }

 	else if( !strcmp( linebuf, "enew" )) { cmd_enew(); }


comments

comments

--- src/main.ino
+++ src/main.ino
@@ -1,6 +1,8 @@
 // LIBRARIES //
 #include <Servo.h>

+// setting up servo's.
+// m1 = finger 1 (thumb) etc.
 Servo m1;
 Servo m2;
 Servo m3;
@@ -10,21 +12,25 @@

 // SETUP //
 void setup() {
-  // Attach motor variables to digital pin
+  // Attach servo variables to digital pin 2-6
   m1.attach(2);
   m2.attach(3);
   m3.attach(4);
   m4.attach(5);
   m5.attach(6);

+  // Serial monitor for debugging
   Serial.begin(9600);
 }

 // LOOP //
 void loop() {
+  // read the analog value of A4 and store it in variable 'emg'
   int emg = analogRead(A4);

+  // if statement for defining which muscle activity corresponds
+  // with which hand movement
   if (emg < 50) {
     allFingers(700);
   } else if (emg > 50 && emg < 200) {
@@ -32,20 +38,22 @@
   } else if (emg > 700) {
     allFingers(2300);
   }
-
+
+  // delay to give the fingers time to move
   delay(1000);
 }

-// FUNCTIONS //
+// PRESETS //
 void allFingers(int pos) {
   // get all fingers in same position.
-  // 0 for open hand, 180 for fully closed hand
+  // With our servo's; 700 for open hand,
+  // 2300 for fully closed hand
   m1.writeMicroseconds(pos);
   m2.writeMicroseconds(pos);
   m3.writeMicroseconds(pos);
   m4.writeMicroseconds(pos);
   m5.writeMicroseconds(pos);
-  delay(1000);
+  delay(100);
 }

 void pinch() {
@@ -58,19 +66,19 @@
 }

 void thumbsUp() {
-  m1.write(0);
-  m2.write(180);
-  m3.write(180);
-  m4.write(180);
-  m5.write(180);
+  m1.writeMicroseconds(700);
+  m2.writeMicroseconds(2300);
+  m3.writeMicroseconds(2300);
+  m4.writeMicroseconds(2300);
+  m5.writeMicroseconds(2300);
   delay(100);
 }

 void middleFinger() {
-  m1.write(180);
-  m2.write(180);
-  m3.write(0);
-  m4.write(180);
-  m5.write(180);
+  m1.writeMicroseconds(2300);
+  m2.writeMicroseconds(2300);
+  m3.writeMicroseconds(700);
+  m4.writeMicroseconds(2300);
+  m5.writeMicroseconds(2300);
   delay(100);
 }


Typo corrected

Typo corrected

--- ED_BMSdiag/ED_BMSdiag_PRN.ino
+++ ED_BMSdiag/ED_BMSdiag_PRN.ino
@@ -237,21 +237,21 @@
 void printCLS_Status() {
   Serial.println(F("Status Cooling- and Subsystems: "));
   Serial.print(F("Temperature   : ")); Serial.print(CLS.CoolingTemp / 8.0,1); Serial.println(F(" degC"));
-  Serial.print(F("Cooling Pump  : "));
+  Serial.print(F("Cooling pump  : "));
   Serial.print(CLS.CoolingPumpRPM / 255.0 * 100.0, 1); Serial.print(F(" %, "));
   Serial.print(CLS.CoolingPumpTemp - 50); Serial.println(F(" degC"));
   Serial.print(F("              : "));
   Serial.print(CLS.CoolingPumpLV / 10.0, 1); Serial.print(F(" V, "));
   Serial.print(CLS.CoolingPumpAmps / 5.0, 1); Serial.println(F(" A"));
   Serial.println(F("OTR:"));
-  Serial.print(F("Cooling Pump  : ")); Serial.print(CLS.CoolingPumpOTR); Serial.println(F(" h"));
+  Serial.print(F("Cooling pump  : ")); Serial.print(CLS.CoolingPumpOTR); Serial.println(F(" h"));
   Serial.print(F("Battery heater: ")); Serial.print(CLS.BatteryHeaterOTR); Serial.print(F(" h, "));
   if (CLS.BatteryHeaterON == 0) {
     Serial.println(F("OFF"));
   } else {
     Serial.println(F("ON"));
   }
-  Serial.print(F("Vaccum Pump   : ")); Serial.print(CLS.VaccumPumpOTR / 36000.0, 3); Serial.println(F(" h"));
+  Serial.print(F("Vaccum pump   : ")); Serial.print(CLS.VaccumPumpOTR / 36000.0, 3); Serial.println(F(" h"));
   Serial.print(F("Pressure 1, 2 : ")); Serial.print(CLS.VaccumPumpPress1); Serial.print(F(" mbar, "));
   Serial.print(CLS.VaccumPumpPress2); Serial.println(F(" mbar"));
 }


Testing robot drive straight

Testing robot drive straight

--- utils/testSketch/testSketch.ino
+++ utils/testSketch/testSketch.ino
@@ -35,16 +35,18 @@
 volatile int contaDireita = 0;
 volatile int contaEsquerda = 0;

-volatile double kpDireita = 0;
-volatile double kpEsquerda = 0;
+double kpDireita = 0;
+double kpEsquerda = 0;

 //volatile int velocidadeDireita = 120;
 //volatile int velocidadeEsquerda = 130;
-volatile int velocidadeDireita = 800;
-volatile int velocidadeEsquerda = 870;
+//volatile int velocidadeDireita = 800;
+//volatile int velocidadeEsquerda = 870;
+volatile int velocidadeDireita = 540;
+volatile int velocidadeEsquerda = 600;

-volatile double pwmDireita = 0;
-volatile double pwmEsquerda = 0;
+double pwmDireita = 0;
+double pwmEsquerda = 0;

 volatile bool motoresAtivados = false;

@@ -54,13 +56,13 @@

 //Define Variables we'll be connecting to
 double entradaEsquerda, entradaDireita;
-double objetivo = 80;
+double objetivo = 100;

 //Specify the links and initial tuning parameters
-PID motorEsquerdo(&entradaEsquerda, &pwmEsquerda, &objetivo,kpEsquerda,0,0, DIRECT);
+PID motorEsquerdo(&entradaEsquerda, &pwmEsquerda, &objetivo, kpEsquerda,0,0, DIRECT);

 //Specify the links and initial tuning parameters
-PID motorDireito(&entradaDireita, &pwmDireita, &objetivo,kpDireita,0,0, DIRECT);
+PID motorDireito(&entradaDireita, &pwmDireita, &objetivo, kpDireita,0,0, DIRECT);

 void setup() {
   Serial.begin(115200);
@@ -180,4 +182,3 @@
 void contadorEsquerda() {
   contaEsquerda++;
 }
-


Added comment crediting Adafruit with the code that shifts 8-bit colors into a 32-bit integer for shipment to the LED strip.

--- xy.ino
+++ xy.ino
@@ -576,6 +576,7 @@
 }

 // Create a 24 bit color value from R,G,B
+// (Code snitched from Adafruit.  Please don't sue me, y'all, for stealing your bit-shifting code.)
 uint32_t Color(byte r, byte g, byte b)
 {
   uint32_t c;