small editing

small editing

--- sketches/prototype/prototype.ino
+++ sketches/prototype/prototype.ino
@@ -137,7 +137,6 @@
      if(mode<=0){ //read
         int pin = Str2int(data);
         Serial.println(analogRead(pin));
-
     }else{
         String sdata[2];
         split(sdata,2,data,'%');
@@ -149,7 +148,6 @@

 void ConfigurePinHandler(String data){
     int pin = Str2int(data);
-
     if(pin <=0){
         pinMode(-pin,INPUT);
     }else{
@@ -158,7 +156,6 @@
 }

 void shiftOutHandler(String data) {
-
     String sdata[4];
     split(sdata, 4, data, '%');
     int dataPin = sdata[0].toInt();
@@ -403,7 +400,6 @@
   else if (cmd == "sz") {
       sizeEEPROM();
   }
-
 }

 void setup()  {


bug fixed during serial read

bug fixed during serial read

There was a ignored case when nothing was received from Serial. Still we
added a -1 char to the current buffer which was wrong.

Also we have removed references to Serial.write from the
parse_and_execute_commands function. Now a string is constructed and
returned by that function.

--- jenny5-firmware/jenny5-firmware.ino
+++ jenny5-firmware/jenny5-firmware.ino
@@ -22,7 +22,7 @@

 char is_command_running;

-char firmware_version[] = "2016.01.17.0";// year.month.day.build number
+char firmware_version[] = "2016.01.17.4";// year.month.day.build number

 char current_buffer[65];

@@ -37,7 +37,7 @@

 current_buffer[0] = 0;

-  Serial.begin(250000); //Open Serial connection
+  Serial.begin(115200); //Open Serial connection

   Serial.write("Jenny 5 firmware version: ");
   Serial.write(firmware_version);
@@ -71,12 +71,13 @@
 }

 //--------------------------------------------------------------------------------------------
-void parse_and_execute_commands(char* tmp_str, byte str_length)
+void parse_and_execute_commands(char* tmp_str, byte str_length, char *serial_out)
 {
   byte i = 0;
+  serial_out[0] = 0;
   while (i < str_length){
     // can be more than 1 command in a string, so I have to check again for a letter
-    if (tmp_str[i] >= 'A' && tmp_str[i] <= 'Z' || tmp_str[i] >= 'a' && tmp_str[i] <= 'z'){
+    if ((tmp_str[i] >= 'A' && tmp_str[i] <= 'Z') || (tmp_str[i] >= 'a' && tmp_str[i] <= 'z')){

       if (tmp_str[i] == 'M' || tmp_str[i] == 'm'){// moves motor
         int motor_index, num_steps;
@@ -90,33 +91,24 @@
           if (tmp_str[i] == 'P' || tmp_str[i] == 'p'){// potentiometer
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            Serial.write('P');
-            Serial.print(sensor_index);
-            Serial.write(' ');
-            Serial.print(potentiometers_control.get_position(sensor_index));
-            Serial.write('#');
+            int sensor_value = potentiometers_control.get_position(sensor_index);
+            sprintf(serial_out, "P%d %d#", sensor_index, sensor_value);
             i += 2;
           }
         else
           if (tmp_str[i] == 'U' || tmp_str[i] == 'u'){// ultrasonic
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            Serial.write('U');
-            Serial.print(sensor_index);
-            Serial.write(' ');
-            Serial.print(ultrasonic_sensors_controller.getDistanceForSensor(sensor_index));
-            Serial.write('#');
+            int sensor_value = ultrasonic_sensors_controller.getDistanceForSensor(sensor_index);
+            sprintf(serial_out, "U%d %d#", sensor_index, sensor_value);
             i += 2;
           }
         else
           if (tmp_str[i] == 'I' || tmp_str[i] == 'i'){// infrared
             int sensor_index;
             sscanf(tmp_str + i + 1, "%d", &sensor_index);
-            Serial.write('I');
-            Serial.print(sensor_index);
-            Serial.write(' ');
-            Serial.print(infrared_sensors_control.get_distance(sensor_index));
-            Serial.write('#');
+            int sensor_value = infrared_sensors_control.get_distance(sensor_index);
+            sprintf(serial_out, "I%d %d#", sensor_index, sensor_value);
             i += 2;
           }
         else
@@ -124,9 +116,7 @@
           int motor_index;
           sscanf(tmp_str + i + 1, "%d", &motor_index);
           motors_control.disable_motor(motor_index);
-          Serial.write("D");
-          Serial.print(motor_index);
-          Serial.write('#');
+          sprintf(serial_out, "D%d#", motor_index);
           i += 2;
         }
         else
@@ -134,9 +124,7 @@
             int motor_index;
             sscanf(tmp_str + i + 1, "%d", &motor_index);
             motors_control.lock_motor(motor_index);
-            Serial.write("L");
-            Serial.print(motor_index);
-            Serial.write('#');
+            sprintf(serial_out, "L%d#", motor_index);
             i += 2;
           }
         else
@@ -144,6 +132,7 @@
             int motor_index;
             sscanf(tmp_str + i + 1, "%d", &motor_index);
             motors_control.go_home(motor_index);
+            sprintf(serial_out, "H%d#", motor_index);
           }
           else
           if (tmp_str[i] == 'S' || tmp_str[i] == 's'){ // sets something
@@ -186,12 +175,7 @@
               int motor_index, motor_speed, motor_acceleration;
               sscanf(tmp_str + i + 2, "%d", &motor_index);
               motors_control.get_motor_speed_and_acceleration(motor_index, &motor_speed, &motor_acceleration);
-              Serial.write("MP");// motor parameters
-              Serial.print(motor_index);
-              Serial.write(' ');
-              Serial.print(motor_speed);
-              Serial.write(' ');
-              Serial.print(motor_acceleration);
+              sprintf(serial_out, "MP%d %d %d#", motor_index, motor_speed, motor_acceleration);
               i += 4;
             }
             else
@@ -199,45 +183,14 @@
                 int pot_index, pot_min, pot_max, pot_home;
                 sscanf(tmp_str + i + 2, "%d", &pot_index);
                 potentiometers_control.get_limits(pot_index, &pot_min, &pot_max, &pot_home);
-                Serial.write("PP"); // potentiometer parameters
-                Serial.print(pot_index);
-                Serial.write(' ');
-                Serial.print(pot_min);
-                Serial.write(' ');
-                Serial.print(pot_max);
-                Serial.write(' ');
-                Serial.print(pot_home);
-                Serial.write('#');
+                sprintf(serial_out, "PP%d %d %d %d#", pot_index, pot_min, pot_max, pot_home);
                 i += 4;
               }
-              else{
-                          // for all motors, unformated data
-                int index;
-                Serial.write("G ");
-                for(index = 0; index < motors_control.num_motors; index++) {
-                  Serial.write("Motor: ");
-                  Serial.println(index);
-                  for (byte j = 0 ; j < motors_control.sensors[index].count ; ++j) {
-                    byte sensor_index = motors_control.sensors[index].sensors_array[j].index;
-                    byte type = motors_control.sensors[index].sensors_array[j].type;
-                    Serial.write("Sensor index: ");
-                    Serial.print(sensor_index);
-                    Serial.write(", Type: ");
-
-                    if (POTENTIOMETER == type)
-                      Serial.write("potentiometer, Value: ");
-                      Serial.print(potentiometers_control.get_position(sensor_index));
-                      Serial.write(", Is whitin limits: ");
-                      Serial.println(potentiometers_control.isWithinLimits(sensor_index));
-                    }
-                }
-                Serial.write("#");
-                i += 2;
-              }
         }
         else
          if (tmp_str[i] == 'T' || tmp_str[i] == 't'){// test connection
-           Serial.write("T#");
+           sprintf(serial_out, "T#");
+           i += 2;
          }
     }
     else
@@ -248,15 +201,18 @@
 //Main loop
 void loop()
 {
-
+char serial_out[100];
   if (Serial.available() || current_buffer[0]) {
     int num_read = 0;
     char serial_buffer[65];

     //num_read = Serial.readBytes(serial_buffer, 64); //Read up to 64 bytes

-    serial_buffer[0] = Serial.read();
-    num_read = 1;
+    int incomingByte = Serial.read();
+      if (incomingByte != -1){
+      serial_buffer[0] = incomingByte;
+      num_read = 1;
+    }
     serial_buffer[num_read] = 0;// terminate the string
     if (serial_buffer[0] || current_buffer[0]){
       strcat(current_buffer, serial_buffer);
@@ -270,7 +226,7 @@
       // parse from the beginning until I find a M, D, L, S, A, P, B, U, G, T
       int buffer_length = strlen(current_buffer);
       for (int i = 0; i < buffer_length; i++)
-        if (current_buffer[i] >= 'A' && current_buffer[i] <= 'Z' || current_buffer[i] >= 'a' && current_buffer[i] <= 'z'){// a command
+        if ((current_buffer[i] >= 'A' && current_buffer[i] <= 'Z') || (current_buffer[i] >= 'a' && current_buffer[i] <= 'z')){// a command
           // find the terminal character #
           int j = i + 1;
           for (; j < buffer_length && current_buffer[j] != '#'; j++);// parse until I find the termination char
@@ -285,8 +241,9 @@
                 Serial.println();
               #endif

-             //parse_and_execute_commands(tmp_str, j - i);
-             parse_and_execute_commands(current_buffer + i, j - i);
+             parse_and_execute_commands(current_buffer + i, j - i, serial_out);
+             if (serial_out[0])
+               Serial.write(serial_out);

               // remove the current executed command
@@ -307,6 +264,9 @@
         }
     }
   }
-  motors_control.run_motors(potentiometers_control);
+  motors_control.run_motors(potentiometers_control, serial_out);
+  if (serial_out[0])
+    Serial.write(serial_out);
+
 }
 //------------------------------------------------------------------------------


better type for time-variables

better type for time-variables

--- Vsens/src/sketch.ino
+++ Vsens/src/sketch.ino
@@ -29,8 +29,8 @@
 int sumSamples = 0;         // sum of samples
 int cntSamples = 0;         // sample counter
 float voltage = 0.0;
-long startTime;
-long elapsedTime;
+unsigned long startTime;
+unsigned long elapsedTime;

 void setup()
 {


Update i2c_datatest.ino

Update i2c_datatest.ino

--- code/i2c_datatest.ino
+++ code/i2c_datatest.ino
@@ -30,5 +30,8 @@
   // convert into ints
   // ...

+  // print the ints
+  // ...
+
   delay(30);
 }


cleanup

cleanup

--- demoboard/DemoBoard/DemoBoard.ino
+++ demoboard/DemoBoard/DemoBoard.ino
@@ -322,7 +322,6 @@
    //
    Serial.begin(115200); // default SERIAL_8N1
    Serial.setTimeout(10);
-   //Serial.flush();

    // setup SRDP channel over serial
    //
@@ -354,16 +353,10 @@
 }

-#ifdef SRDP_DUMMY
-   bool did_report = false;
-#endif
-

 // Arduino main run loop
 //
 void loop() {
-
-#ifndef SRDP_DUMMY

    // process SRDP
    //
@@ -392,19 +385,6 @@
       srdp_register_change(&channel, IDX_DEV, IDX_REG_POT2, 0, 0);
    }

-#else
-
-   Serial.flush();
-   Serial.println("Arduino connected.");
-/*
-   if (!did_report) {
-      Serial.println(freeRam());
-      did_report = true;
-      Serial.println("Report end.");
-   }
-*/
-#endif
-
    // limit update frequency
    //
    delay(20);


Implment version protocol for arduino101.

--- src/arduino101/science-journal-arduino/science-journal-arduino.ino
+++ src/arduino101/science-journal-arduino/science-journal-arduino.ino
@@ -21,7 +21,8 @@
 #include "heartbeat.h"
 #include "internal/ble_client.h"
 #include "services/ble/ble_service_gap_api.h"
-
+#include "sensor.pb.h"
+
 BLEPeripheral blePeripheral; // create peripheral instance
 BLEService whistlepunkService("555a0001-0aaa-467a-9538-01f0652c74e8"); // create service
 // Must be 20 char long to accomodate full-size messages.
@@ -29,6 +30,9 @@
 const char *config = "                     ";
 BLECharacteristic valueCharacteristic( "555a0003-0aaa-467a-9538-01f0652c74e8", BLENotify, value);
 BLECharacteristic configCharacteristic("555a0010-0aaa-467a-9538-01f0652c74e8", BLEWrite, config);
+const unsigned int version = goosci_Version_Version_LATEST;
+
+BLEUnsignedIntCharacteristic versionCharacteristic("555a0011-0aaa-467a-9538-01f0652c74e8", BLERead);

 String BleLongName = "Sci";
 bool serialConnected = false;
@@ -79,6 +83,8 @@
   blePeripheral.addAttribute(whistlepunkService);
   blePeripheral.addAttribute(valueCharacteristic);
   blePeripheral.addAttribute(configCharacteristic);
+  blePeripheral.addAttribute(versionCharacteristic);
+  versionCharacteristic.setValue(version);

   // assign event handlers for connected, disconnected to peripheral
   blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);


Fixing whitespace in example

Fixing whitespace in example

--- examples/mDNSResolver.ino
+++ examples/mDNSResolver.ino
@@ -2,8 +2,8 @@
 #include <WiFiUdp.h>
 #include <mDNSResolver.h>

-#define WIFI_AP 	"my-wifi-ap"
-#define WIFI_PASS "my-wifi-pass"
+#define WIFI_AP         "my-wifi-ap"
+#define WIFI_PASS       "my-wifi-pass"
 #define NAME_TO_RESOLVE "test.local"

 using namespace mDNSResolver;


added tone to speaker on PB0

added tone to speaker on PB0

--- eggfckr_ard/eggfckr_ard.ino
+++ eggfckr_ard/eggfckr_ard.ino
@@ -1,28 +1,61 @@
+/*
+Note1: some code from the adafriut gemma simple thermain example.
+Note2: The Arduino tone library does not work for the ATTiny85 on the
+Trinket and Gemma.  The beep function below is similar.  The beep code
+is adapted from Dr. Leah Buechley at
+http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html
+ */

-
+#define SPEAKER   0    // Speaker on GPIO #0
+#define SCALE     2.0  // You can change this to change the tone scale

 #define led1 2
-#define led2 3
-#define pot A2
+#define led2 1
+#define pot A3
 #define hightimes 10 //time to keep led on in cycle
+
 int logy = 5;
-float freq = 250;

 void setup() {
+  pinMode(SPEAKER,OUTPUT);
+
   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);
   pinMode(pot, INPUT);

 }
 void loop() {
-  freq = analogRead(pot);  //between 4-32Hz blinks, 4 is 250ms, 32 is 31ms
-  freq = map(freq, 100, 1024, 31, 250);
-  freq = constrain(freq, 31,250);

+  int input = analogRead(pot);  //between 4-32Hz blinks, 4 is 250ms, 32 is 31ms
+  int freqLight = map(input, 100, 1024, 31, 250);
+  freqLight = constrain(freqLight, 31,250);
+
+  int freqAudio=220+(int)(input*SCALE); // change the voltage read to a frequency
+                             // you can change the values to scale
+                             // your frequency range
+  beep(SPEAKER,freqAudio,400);    // output the tone to digital pin 0
+                             // you can change 400 to different times}
+
   digitalWrite(led1, LOW);
   digitalWrite(led2, LOW);
   delay(hightimes);
   digitalWrite(led1, HIGH);
   digitalWrite(led2, HIGH);
-  delay(freq-hightimes);
+  delay(freqLight-hightimes);
 }
+
+
+// the sound producing function
+void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)
+{   // http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html
+          int x;
+          long delayAmount = (long)(1000000/frequencyInHertz);
+          long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
+          for (x=0;x<loopTime;x++)
+          {
+              digitalWrite(speakerPin,HIGH);
+              delayMicroseconds(delayAmount);
+              digitalWrite(speakerPin,LOW);
+              delayMicroseconds(delayAmount);
+          }
+}


Remove dhrdata method

Remove dhrdata method

--- examples/WeatherStationDemo/WeatherStationDemo.ino
+++ examples/WeatherStationDemo/WeatherStationDemo.ino
@@ -124,7 +124,6 @@
 void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
 void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
 void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex);
-void drawDHTData(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
 void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
 void setReadyForWeatherUpdate();

@@ -132,8 +131,8 @@
 // Add frames
 // this array keeps function pointers to all frames
 // frames are the single views that slide from right to left
-FrameCallback frames[] = { drawDateTime, drawCurrentWeather, drawForecast, drawDHTData };
-int numberOfFrames = 4;
+FrameCallback frames[] = { drawDateTime, drawCurrentWeather, drawForecast };
+int numberOfFrames = 3;

 OverlayCallback overlays[] = { drawHeaderOverlay };
 int numberOfOverlays = 1;
@@ -310,12 +309,6 @@
   display->setTextAlignment(TEXT_ALIGN_LEFT);
 }

-void drawDHTData(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
-  display->setTextAlignment(TEXT_ALIGN_CENTER);
-  display->setFont(ArialMT_Plain_10);
-  display->drawString(x + 64, y, "Sensor Data");
-}
-
 void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
   now = time(nullptr);
   struct tm* timeInfo;


"i:255.255.255"の記法でもOKだった

--- arduino-neopixel.ino
+++ arduino-neopixel.ino
@@ -58,7 +58,7 @@
   if (0<Serial.available()) {
     String command = Serial.readStringUntil(':');
     String argument = Serial.readStringUntil(';');
-    if(command=="0") {
+    if(command=="i") {
       Serial.println(command);
       if(argument.length()==11) {
         // argument likes "255.255.255"
@@ -73,7 +73,7 @@
         Serial.println(argument);
       }
     }
-    else if(command=="1") {
+    else if(command=="e") {
       if(argument.length()==11) {
         // argument likes "255.255.255"
         int r = constrainValue(argument.substring(0,3).toInt());


Seperated reset speed into driver type

Seperated reset speed into driver type

--- starsynctrackers.ino
+++ starsynctrackers.ino
@@ -28,12 +28,11 @@

 static const int STOP_BUTTON_PIN = A4;      // The pin the stop push switch is on
 static const int STOP_BUTTON_TYPE = 1;     // The type of switch 0 - Normally Closed; 1 - Normally Open
-static const float RESET_SPEED = -300.0;  // The speed to go back to initial position at
 static const float DIRECTION = 1.0; // 1 forward is forward; -1 + is forward is backward

 #if STEPPER_DRIVER == 0
-
+static const float RESET_SPEED = -1000.0;  // The speed to go back to initial position at
 #include <Adafruit_MotorShield.h>
 #include "utility/Adafruit_PWMServoDriver.h"

@@ -70,6 +69,7 @@
 #endif

 #if STEPPER_DRIVER == 1
+static const float RESET_SPEED = -2000.0;  // The speed to go back to initial position at

 AccelStepper Astepper1(1, 9, 8);
 #define MICROSTEPS 8
@@ -78,7 +78,7 @@

 #if STEPPER_DRIVER == 2
-
+static const float RESET_SPEED = -800.0;  // The speed to go back to initial position at
 #include <AFMotor.h>
 AF_Stepper myStepper1(STEPS_PER_ROTATION, 2);
 // you can change these to DOUBLE or INTERLEAVE or MICROSTEP!


little interface fixes

little interface fixes

--- space/space.ino
+++ space/space.ino
@@ -24,6 +24,7 @@
 #define LEFT 11
 #define RIGHT 12
 #define FIRE 13
+#define FIRE2 A4

 #define WIDTH 64

@@ -37,10 +38,10 @@

 volatile uint8_t
     *latport, *oeport, *addraport, *addrbport, *addrcport, *addrdport,
-    *leftport, *rightport, *fireport;
+    *leftport, *rightport, *fireport, *fire2port;
 uint8_t
     sclkpin, latpin, oepin, addrapin, addrbpin, addrcpin, addrdpin,
-    leftpin, rightpin, firepin;
+    leftpin, rightpin, firepin, fire2pin;

 int16_t hiscore;
 int16_t score;
@@ -67,6 +68,8 @@
   rightpin  = digitalPinToBitMask(RIGHT);
   fireport = portInputRegister(digitalPinToPort(FIRE));
   firepin  = digitalPinToBitMask(FIRE);
+  fire2port = portInputRegister(digitalPinToPort(FIRE2));
+  fire2pin  = digitalPinToBitMask(FIRE2);

   // put your setup code here, to run once:
   pinMode(CLK , OUTPUT);
@@ -490,6 +493,7 @@

 #define MAX_LIVES 3
 int lives;
+bool started;

 void render_digits(uint16_t num, int len, int x, int y, uint8_t *buf, int line, uint8_t color)
 {
@@ -556,7 +560,7 @@
   // draw score
   sprite_render(&hiLabel, HISCORE_LABEL_X, HISCORE_Y, buf, y, CYAN);
   render_digits(hiscore, SCORE_DIGITS, SCORE_X, HISCORE_Y, buf, y, WHITE);
-  if (phase == PHASE_GAME)
+  if (started)
     render_digits(score, SCORE_DIGITS, SCORE_X, SCORE_Y, buf, y, WHITE);

   // draw logo
@@ -795,7 +799,7 @@
       {
         cannonX = cannonX - step;
       }
-      if ((*fireport & firepin) == 0
+      if (((*fireport & firepin) == 0 || (*fire2port & fire2pin) == 0)
         && curTime - shootTime >= 500) // shoot
       {
         shootTime = curTime;
@@ -812,8 +816,10 @@
     }
   }

-  if (step == 0 && phase == PHASE_LOGO && (*fireport & firepin) == 0)
-  {
+  if (step == 0 && phase == PHASE_LOGO
+      && ((*fireport & firepin) == 0 || (*fire2port & fire2pin) == 0))
+  {
+    started = true;
     phase = PHASE_GAME;
     lives = MAX_LIVES;
     wave = 0;


Update feather_code.ino

Update feather_code.ino

Code übersichtlicher gestaltet und vereinheitlicht.

--- code/feather_code.ino
+++ code/feather_code.ino
@@ -31,13 +31,13 @@

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

-#include <lmic.h>
+#include <lmic.h> //lmic master library (LoRa)
 #include <hal/hal.h>
-#include <SPI.h>
-
-#include <Adafruit_BME280.h>
-#include <Adafruit_Sensor.h>
-#define SEALEVELPRESSURE_HPA (1013.25)
+//#include <SPI.h> falls Sensoren mit SPI betrieben werden sollen
+
+#include <Adafruit_BME280.h> //bme library einbinden
+#include <Adafruit_Sensor.h> //Zusatz zur bme library
+#define SEALEVELPRESSURE_HPA (1013.25) //

 Adafruit_BME280 bme; //I2C

@@ -60,14 +60,13 @@
 const int analogInPin = A1; //Analog input pin that potentiometer is attached to
 const int analogOutPin = 9; // Analog output pin that the LED is attached to

-int sensorValue = 0;        // value read from the pot
-int outputValue = 0;        // value output to the PWM (analog out)
+int lightsensorValue = 0;

 //Bodenfeuchtigkeitssensor
-int val = 0; //value for storing moisture value
-int soilPin = A2; //Declare a variable for the soil moisture sensor
-int soilPower = 7; //Variable for Soil moisture
+int gndSoilValue = 0; //value for storing moisture value
+int gndSoilPin = A2; //Declare a variable for the soil moisture sensor
+int gndSoilPower = 7; //Variable for Soil moisture

 // These callbacks are only used in over-the-air activation, so they are
@@ -79,7 +78,7 @@

-static uint8_t mydata[7];
+static uint8_t sensordata[7];
 static osjob_t sendjob;

 // Schedule TX every this many seconds (might become longer due to duty
@@ -160,65 +159,56 @@
 }

 void sensor_data() {
-  float temp = (bme.readTemperature() + 50) * 100;
-  uint16_t temperature = (uint16_t) temp;
-  Serial.println();
-  Serial.print(temperature);
-  Serial.println();
-  uint8_t hightemp = (uint8_t) ((temperature & 0xFF00) >> 8);
-  uint8_t lowtemp = (uint8_t) (temperature & 0xFF);
-  Serial.println();
-  Serial.print(hightemp);
-  Serial.println();
-  Serial.println();
-  Serial.print(lowtemp);
-  Serial.println();
-  mydata[0] = hightemp;
-  mydata[1] = lowtemp;
-
-  float pre = bme.readPressure() / 100.0F;
-  uint16_t pressure = (uint16_t ) ((pre / 1013.25) * 100);
-  uint8_t pres = (uint8_t) pressure;
-
-  mydata[2] = pres;
-  Serial.println(pressure);
-  Serial.println();
-
-  float hum = bme.readHumidity() * 100;
-  uint16_t humidity = (uint16_t) hum;
-  uint8_t highhum = (uint8_t) ((humidity & 0xFF00) >> 8);
-  uint8_t lowhum = (uint8_t) (humidity & 0xFF);
-
-  mydata[3] = highhum;
-  mydata[4] = lowhum;
-
-  Serial.println(humidity);
-  Serial.println(mydata[3]);
-  Serial.println();
-  Serial.println(mydata[4]);
+
+  //Temperatur
+  float tempratureReadout = (bme.readTemperature() + 50) * 100; //Temperatur wird um 50°C nach rechts verschoben, dass Temperaturen von -50°C bis +50°C gemessen werden, danach wird mit 100 multipliziert, um Komma zahlen zu vermeiden
+  uint16_t temperature = (uint16_t) tempratureReadout; //Temperatur wird gecastet, also von float in ein uint16_t umgewandelt
+  uint8_t hightempratureByte = (uint8_t) ((temperature & 0xFF00) >> 8); // bitshift um 8 Stellen nach rechts
+  uint8_t lowtempratureByte = (uint8_t) (temperature & 0xFF); //bitshift um 8 Stellen nach links
+  Serial.println(hightempratureByte);
+  Serial.println(lowtempratureByte);
+
+
+  //Luftdruck
+  float pressureReadout = bme.readPressure() / 100.0F;
+  uint16_t pressure = (uint16_t ) ((pressure / 1013.25) * 100);
+  uint8_t pressureByte = (uint8_t) pressure;
+  Serial.println(pressureByte);
+
+
+  //Luftfeuchtigkeit
+  float humidityReadout = bme.readHumidity() * 100;
+  uint16_t humidity = (uint16_t) humidityReadout;
+  uint8_t highhumidityByte = (uint8_t) ((humidity & 0xFF00) >> 8);
+  uint8_t lowhumidityByte = (uint8_t) (humidity & 0xFF);
+  Serial.println(highhumidityByte);
+  Serial.println(lowhumidityByte);
+

-
-  sensorValue = analogRead(analogInPin);
-  float voltage = (3.3/4096*sensorValue);
-  float strom = (voltage/10020);
-  float lichtstrom = (strom*2*1000000);
-  lichtstrom = lichtstrom / 6.5852;         //In Prozent 658,52 (Maximalwert) / 100
-  uint8_t lichtstrom_int = (uint8_t) lichtstrom;
-
-  Serial.print("Helligkeit: ");
-  Serial.print(lichtstrom);
-  Serial.print("%");
-  Serial.print("\n");
-
-
-  mydata[5] = lichtstrom_int;
-
-  soilPower = analogRead(soilPin);
-
-  uint8_t percent = (uint8_t) ((analogRead(A2)/33.30F) * 100);
-  Serial.println(percent);
-
-  mydata[6] = percent;
+  //Lichtsensor
+  lightsensorValue = analogRead(analogInPin);
+  float lightsensorVoltage = (3.3/4096*lightsensorValue);
+  float lightsensorStrom = (lightsensorVoltage/10020);
+  float lightstrom = (lightsensorStrom*2*1000000);
+  lightstrom = lightstrom / 6.5852;         //In Prozent 658,52 (Maximalwert) / 100
+  uint8_t lightstromInt = (uint8_t) lightstrom;
+  Serial.println(lightstromInt);
+
+
+  //Bodenfeuchtigkeitssensor
+  gndSoilPower = analogRead(gndSoilPin);
+  uint8_t gndPercent = (uint8_t) ((analogRead(A2)/33.30F) * 100);
+  Serial.println(gndPercent);
+
+
+  //Werte ins Array schreiben
+  sensordata[0] = hightempratureByte;
+  sensordata[1] = lowtempratureByte;
+  sensordata[2] = pressureByte;
+  sensordata[3] = highhumidityByte;
+  sensordata[4] = lowhumidityByte;
+  sensordata[5] = lightstromInt;
+  sensordata[6] = gndPercent;

 }
@@ -233,7 +223,7 @@
     Serial.println(F("OP_TXRXPEND, not sending"));
   } else {
     // Prepare upstream data transmission at the next possible time.
-    LMIC_setTxData2(1, mydata, sizeof(mydata) , 0);
+    LMIC_setTxData2(1, sensordata, sizeof(sensordata) , 0);
     Serial.println(F("Packet queued"));
   }
   // Next TX is scheduled after TX_COMPLETE event.
@@ -243,7 +233,7 @@
   delay (5000);
   bool status;

-  // default settings
+  //bme Initialisierung
   status = bme.begin();
   delay(1000);
   if (!status) {
@@ -256,8 +246,11 @@

   analogReadResolution(12); //Lichtsensor, Bodenfeuchtigkeitssensor

-  pinMode(soilPower, OUTPUT); //Set D7 as an output
-  digitalWrite(soilPower, LOW); //Set to Low so no power is flowing through the sensor
+  //Bodenfeuchtigkeitssensor
+  pinMode(gndSoilPower, OUTPUT); //Set D7 as an output
+  digitalWrite(gndSoilPower, LOW); //Set to Low so no power is flowing through the sensor
+
+

 #ifdef VCC_ENABLE
   // For Pinoccio Scout boards


made motors faster

made motors faster

--- StepperDriver/StepperDriver.ino
+++ StepperDriver/StepperDriver.ino
@@ -9,14 +9,14 @@
 // Connect a stepper motor with 48 steps per revolution (7.5 degree)
 // to motor port #2 (M3 and M4)
 AF_Stepper motor(200, 2);
-AF_Stepper motor1(48, 1);
+AF_Stepper motor1(200, 1);

 void setup() {
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");

-  motor.setSpeed(20);  // 10 rpm
-  motor1.setSpeed(20);  // 10 rpm
+  motor.setSpeed(80);  // 10 rpm
+  motor1.setSpeed(80);  // 10 rpm

 }


Undo typo

Undo typo

--- testjig/production/production.ino
+++ testjig/production/production.ino
@@ -29,7 +29,7 @@
 {
     Serial.println("");
     Serial.println("--------------------------------------------");
-    Serial.println(" Fadecanday Test Jig : Press button to start");
+    Serial.println(" Fadecandy Test Jig : Press button to start");
     Serial.println("--------------------------------------------");
     Serial.println("");


Cleared numberOfKnocks variable

Cleared numberOfKnocks variable

Fixed according to #2294

--- build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino
+++ build/shared/examples/10.StarterKit/p12_KnockLock/p12_KnockLock.ino
@@ -140,6 +140,8 @@
       digitalWrite(greenLed, HIGH);
       digitalWrite(redLed, LOW);
       Serial.println("the box is unlocked!");
+
+      numberOfKnocks = 0;
     }
   }
 }


some organization of the manual queue

some organization of the manual queue

now does rainbow on inner window with purple on outer and purple fade
for desk

--- init.ino
+++ init.ino
@@ -90,14 +90,21 @@

 void led_man_queue() {
 	// manually queue animations for startup
-	//thread_handler.queue(new Animation_Simple_DeskWhitePurpleFade());
-	thread_handler.queue(new Animation_Static_DeskThirdDimAmbient());
-	thread_handler.queue(new Animation_Simple_Indiv_Rainbow(&desk1));
-	thread_handler.queue(new Animation_Simple_Indiv_Rainbow(&desk2));
+  thread_handler.queue(new Animation_Simple_DeskWhitePurpleFade());
+	//thread_handler.queue(new Animation_Static_DeskThirdDimAmbient());
+	//thread_handler.queue(new Animation_Simple_Indiv_Rainbow(&desk1));
+	//thread_handler.queue(new Animation_Simple_Indiv_Rainbow(&desk2));
+
 	//thread_handler.queue(new Animation_Holiday_Halloween_WinAllHalloweenSparkle());
-	thread_handler.queue(new Animation_Seasonal_Winter_WindowSnow(&window1));
-	//thread_handler.queue(new Animation_Simple_Win2RainbowWipe());
-	thread_handler.queue(new Animation_Simple_Indiv_RainbowCycle(&window2));
-	//thread_handler.queue(new Animation_Simple_WinAllPurpleFade());
-	thread_handler.queue(new Animation_Seasonal_Winter_WindowSnow(&window3));
+
+	//thread_handler.queue(new Animation_Seasonal_Winter_WindowSnow(&window1));
+	//thread_handler.queue(new Animation_Seasonal_Winter_WindowSnow(&window3));
+
+  thread_handler.queue(new Animation_Simple_Indiv_CalmPurpleFade(&window1));
+  //thread_handler.queue(new Animation_Simple_Indiv_CalmPurpleFade(&window2));
+  thread_handler.queue(new Animation_Simple_Indiv_CalmPurpleFade(&window3));
+
+  //thread_handler.queue(new Animation_Simple_Indiv_RainbowCycle(&window1));
+  thread_handler.queue(new Animation_Simple_Indiv_RainbowCycle(&window2));
+  //thread_handler.queue(new Animation_Simple_Indiv_RainbowCycle(&window3));
 }


deleting useless http example

deleting useless http example

--- examples/SendValuesHttp/SendValuesHttp.ino
+++ examples/SendValuesHttp/SendValuesHttp.ino
@@ -1,55 +0,0 @@
-// This example is to get the last value of variable from the Ubidots API
-
-// This example is to save multiple variables to the Ubidots API with TCP method
-
-/****************************************
- * Include Libraries
- ****************************************/
-
-#include "Ubidots.h"
-
-/****************************************
- * Define Constants
- ****************************************/
-
-#ifndef TOKEN
-#define TOKEN "Your_Token"  // Put here your Ubidots TOKEN
-#endif
-
-Ubidots ubidots(TOKEN, UBI_HTTP);
-
-
-/****************************************
- * Auxiliar Functions
- ****************************************/
-
-//Put here your auxiliar functions
-
-
-/****************************************
- * Main Functions
- ****************************************/
-
-void setup() {
-  Serial.begin(115200);
-  //ubidots.setDebug(true);  // Uncomment this line for printing debug messages
-}
-
-void loop() {
-  float value1 = analogRead(A0);
-  float value2 = analogRead(A1);
-  float value3 = analogRead(A2);
-  ubidots.add("Variable_Name_One", value1);  // Change for your variable name
-  ubidots.add("Variable_Name_Two", value2);
-  ubidots.add("Variable_Name_Three", value3);
-
-  bool bufferSent = false;
-  bufferSent = ubidots.send();  // Will send data to a device label that matches the device Id
-
-  if(bufferSent){
-    // Do something if values were sent properly
-    Serial.println("Values sent by the device");
-  }
-
-  delay(5000);
-}


Fixed case of esp8266serial

Fixed case of esp8266serial

Signed-off-by: Suxsem <ffd6300eb7bdb77a8898cee133390f47c44c6773@live.com>

--- Domo.ino
+++ Domo.ino
@@ -18,7 +18,7 @@
 #define MQTTretry 20
 #define MQTTqos 2
 #define esp8266alive 40
-#define esp8266Serial Serial
+#define esp8266serial Serial

 #define rumorePin 2
 #define buzzPin 4
@@ -100,8 +100,8 @@
         lastAliveCheck = millis();
         connected = false;
     }
-    if (esp8266Serial.find("[(")) {
-        esp8266Serial.readBytes(cb, 1);
+    if (esp8266serial.find("[(")) {
+        esp8266serial.readBytes(cb, 1);
         if (cb[0] == 'r') {
             //ready
             if (connected) {
@@ -109,18 +109,18 @@
                 onDisconnected();
             }
             lastAliveCheck = millis();
-            esp8266Serial.println("startAlive(" + String(esp8266alive) + ")");
-            esp8266Serial.flush();
-            esp8266Serial.println("connectAP(\"" + String(APssid) + "\", \"" + String(APpsw) + "\")");
-            esp8266Serial.flush();
+            esp8266serial.println("startAlive(" + String(esp8266alive) + ")");
+            esp8266serial.flush();
+            esp8266serial.println("connectAP(\"" + String(APssid) + "\", \"" + String(APpsw) + "\")");
+            esp8266serial.flush();
         } else if (cb[0] == 'a') {
             lastAliveCheck = millis();
             checkComm();
         } else if (cb[0] == 'w') {
             //wifi connected
-            esp8266Serial.println("mqttInit(\"" + String(MQTTid) + "\", \"" + String(MQTTip) + "\", " + MQTTport + ", \"" + String(MQTTuser)
+            esp8266serial.println("mqttInit(\"" + String(MQTTid) + "\", \"" + String(MQTTip) + "\", " + MQTTport + ", \"" + String(MQTTuser)
                             + "\", \"" + String(MQTTpsw) + "\", " + MQTTalive + ", " + MQTTretry + ")");
-            esp8266Serial.flush();
+            esp8266serial.flush();
         } else if (cb[0] == 'c') {
             //mqtt connected
             connected = true;
@@ -136,10 +136,10 @@
             if (!success)
                 messageQueued = true;
             memset(in_buffer, 0, sizeof(in_buffer));
-            esp8266Serial.readBytesUntil('|', in_buffer, buffer_l);
+            esp8266serial.readBytesUntil('|', in_buffer, buffer_l);
             String topic = String(in_buffer);
             memset(in_buffer, 0, sizeof(in_buffer));
-            esp8266Serial.readBytesUntil('|', in_buffer, buffer_l);
+            esp8266serial.readBytesUntil('|', in_buffer, buffer_l);
             String message = String(in_buffer);
             waitForSuccess();
             onMessage(topic, message);
@@ -163,16 +163,16 @@
     if (!connected)
         return;
     success = false;
-    esp8266Serial.println("mqttPublish(\"" + topic + "\", \"" + message + "\",  " + MQTTqos + ", " + retain + ")");
-    esp8266Serial.flush();
+    esp8266serial.println("mqttPublish(\"" + topic + "\", \"" + message + "\",  " + MQTTqos + ", " + retain + ")");
+    esp8266serial.flush();
     waitForSuccess();
 }
 void mqttSubscribe(String topic) {
     if (!connected)
         return;
     success = false;
-    esp8266Serial.println("mqttSubscribe(\"" + String(topic) + "\", " + MQTTqos + ")");
-    esp8266Serial.flush();
+    esp8266serial.println("mqttSubscribe(\"" + String(topic) + "\", " + MQTTqos + ")");
+    esp8266serial.flush();
     waitForSuccess();
 }

@@ -246,8 +246,8 @@
 // #################### setup e loop ####################

 void setup() {
-  esp8266Serial.begin(9600);
-  esp8266Serial.setTimeout(500);
+  esp8266serial.begin(9600);
+  esp8266serial.setTimeout(500);

   while(!connected)
     checkComm();


Fixed more typos

Fixed more typos

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -257,11 +257,17 @@
   //  << PING 3000  // This is data sent from the Arduino
   //  >> PONG 3000  // This is data the Arduino received

-  //  Preamble/Postamble = 0x04 for PONG for BOTH ways
+  //  Preamble/Postamble = 0x04 for PING for BOTH ways
+  //  PING/PONG System where PING is sent from the Arduino and PONG is sent from the Computer:
+  //  Where ">>" is incoming data and "<<" is outgoing data
+  //  << PING 3000  // This is data sent from the Arduino
+  //  >> PONG 3000  // This is data the Arduino received
+
+  //  Preamble/Postamble = 0x05 for PONG for BOTH ways
   //  PING/PONG System where PING is sent from the Computer and PONG is sent from the Arduino:
   //  Where ">>" is incoming data and "<<" is outgoing data
-  //  >> PING 1487568769420  // This is data the Arduino received
-  //  << PONG 1487568769420  // This is data sent from the Arduino
+  //  << PONG (0x04) 3000  // This is data sent from the Arduino
+  //  >> PONG (0x05) 3000  // This is data the Arduino received

   //  NOTE: This is in no way supposed to represent actual communication, it's only a way to making visualizing data traffic more easily

@@ -384,6 +390,7 @@
     Serial.write(serial_rx_buffer_reset[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values
   }
   Serial.flush();
+  delay(5000); // Wait 5 seconds before resetting
   asm volatile ("  jmp 0");
   resetDone = currentMillis;
   for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_reset); serial_rx_buffer_counter++) {


Random saturation.

Random saturation.

--- examples/fastled_candle/fastled_candle.ino
+++ examples/fastled_candle/fastled_candle.ino
@@ -17,7 +17,7 @@
 // Define the array of leds
 CRGB leds[NUM_LEDS];
 Candle *candles[NUM_LEDS];
-char hues[NUM_LEDS];
+char hues[NUM_LEDS], saturation[NUM_LEDS];

 #define CANDLE_TICK_TIME 20

@@ -49,8 +49,9 @@
         // Initialize candles
         candles[i] = new Candle(random8(16, 96), random8(3, 8), random8(6, 22));

-        // Initialize random hues
+        // Initialize random hues and saturation
         hues[i] = random8(24, 32);
+        saturation[i] = random8(192, 255);
     }

     FastLED.show();
@@ -67,7 +68,7 @@
 void candleLoop() {
     if (candle_timer.check() == 1) {
         for (size_t i=0; i<NUM_LEDS; i++) {
-            leds[i] = CHSV(hues[i], 255, candles[i]->get_next_brightness());
+            leds[i] = CHSV(hues[i], saturation[i], candles[i]->get_next_brightness());
         }

         FastLED.show();


Logging uses F()   TRANSFORMUS CODE?

Logging uses F()   TRANSFORMUS CODE?

--- mutually-assured-destruction.ino
+++ mutually-assured-destruction.ino
@@ -130,7 +130,7 @@

     if ( last_command == RemoteCommandLeft ) {
 #if MAD_LOGGING
-      Serial.println("Relay 0 on");
+      Serial.println(F("Relay 0 on"));
 #endif
       r0->setOnWithPattern(current_burst_pattern());
 //      r1->off();
@@ -138,7 +138,7 @@
     } else if ( last_command == RemoteCommandRight ) {

 #if MAD_LOGGING
-      Serial.println("Relay 1 on");
+      Serial.println(F("Relay 1 on"));
 #endif
 //      r0->off();
       r1->setOnWithPattern(current_burst_pattern());
@@ -146,15 +146,15 @@
     } else if ( last_command == RemoteCommandBoth ) {

 #if MAD_LOGGING
-      Serial.println("Both Relays OnForDuration");
+      Serial.println(F("Both Relays on"));
 #endif
       r0->setOnWithPattern(current_burst_pattern());
       r1->setOnWithPattern(current_burst_pattern());

     } else if ( last_command == RemoteCommandDigit9 ) {

-      r0->setOnWithPattern(RAPID_BURST_A);
-      r1->setOnWithPattern(RAPID_BURST_B);
+      r0->setOnWithPattern(JAWS_LEFT);
+      r1->setOnWithPattern(JAWS_RIGHT);

     } else if ( last_command == RemoteCommandDigit8 ) {

@@ -165,6 +165,11 @@

       r0->setOnWithPattern(GOLDBERG_A);
       r1->setOnWithPattern(GOLDBERG_B);
+
+    } else if ( last_command == RemoteCommandDigit6 ) {
+
+      r0->setOnWithPattern(SHAVE_LEFT);
+      r1->setOnWithPattern(SHAVE_RIGHT);

     } else if ( last_command == RemoteCommandDigit5 ) {


This resolves enhancement #11

This resolves enhancement #11

--- src/smartletterbox.ino
+++ src/smartletterbox.ino
@@ -10,6 +10,9 @@
 }

 #include <ESP8266WiFi.h>
+#include <ESP8266mDNS.h>
+#include <WiFiUdp.h>
+#include <ArduinoOTA.h>
 #include <PubSubClient.h> // https://github.com/knolleary/pubsubclient/releases/tag/v2.3
 #include <Wire.h>
 #include "DHT.h"
@@ -59,7 +62,9 @@

 void init_wifi() {
-  Serial.print("Connecting to ");
+  Serial.println("Initialising Wifi");
+  WiFi.mode(WIFI_STA);
+  Serial.println("Connecting to ");
   Serial.print(ssid);

   if (strcmp (WiFi.SSID().c_str(), ssid) != 0) {
@@ -73,6 +78,39 @@
   Serial.println("");
   Serial.print("WiFi connected, IP address: ");
   Serial.println(WiFi.localIP());
+
+// Port defaults to 8266
+// ArduinoOTA.setPort(8266);
+
+// Hostname defaults to esp8266-[ChipID]
+  ArduinoOTA.setHostname(IOT_DEVICE_ID);
+
+// No authentication by default
+// ArduinoOTA.setPassword((const char *)"123");
+
+  ArduinoOTA.onStart([]() {
+    Serial.println("Starting OTA update");
+  });
+  ArduinoOTA.onEnd([]() {
+    Serial.println("\nEnding OTA update");
+  });
+  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
+    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
+  });
+  ArduinoOTA.onError([](ota_error_t error) {
+    Serial.printf("Error[%u]: ", error);
+    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
+    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
+    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
+    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
+    else if (error == OTA_END_ERROR) Serial.println("End Failed");
+  });
+  ArduinoOTA.begin();
+  Serial.println("Ready");
+  Serial.print("IP address: ");
+  Serial.print("Test: ");
+  Serial.println(WiFi.localIP());
+
 }

 // Initialise Sensor
@@ -134,8 +172,9 @@
     debugDisplayPayload();
     publishPayload();
     ++counter;
-    delay(15000);
-  }
+    delay(5000);
+  }
+  ArduinoOTA.handle();
 }

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


Update iGPS.ino

Update iGPS.ino

调整显示

--- iGPS.ino
+++ iGPS.ino
@@ -18,12 +18,12 @@

 #define LOCAL_AREA 8 // 本地时区 TODO：使用$GPZDA替换

-#define CHAR_DEGREE char(132) // 度 LCD显示 132 ，iso8859-1 176
+#define CHAR_DEGREE char(122) // 度 LCD显示 122 ，iso8859-1 176
 #define CHAR_MINUTE char(39)  // 分
 #define CHAR_SECOND char(34)  // 秒

 // SoftwareSerial 缓冲
-//#define _SS_MAX_RX_BUFF 128
+#define _SS_MAX_RX_BUFF 256

 //SD card attached to SPI bus as follows:
 //#define SD_MOSI 11
@@ -79,7 +79,6 @@
   Serial.begin(4800);
   Serial.flush();
   Serial1.begin(9600);
-//  Serial3.flush();

   lcd.init();
   lcd.clear();
@@ -130,7 +129,7 @@
 boolean readGPS() {
     String sub = readLine();
     if(sub.length()) {
-      sdFile = SD.open("gps.txt", FILE_WRITE);
+      sdFile = SD.open("gps-0726.txt", FILE_WRITE);
       if (sdFile) {
         sdFile.println(sub);
         sdFile.close();
@@ -158,7 +157,7 @@
   gps.second = second.toInt();
   gps.time = hour + ':' + minute + ':' + second;

- Serial.println(gps.time);
+// Serial.println(gps.time);

   int localHour = ((gps.hour + LOCAL_AREA) % 24); // 8
   String localHourStr = String(100 + localHour); // 108
@@ -167,7 +166,7 @@
   gps.localTime = gps.time;
   gps.localTime.replace(gps.localTime.substring(0,2),localHourStr);

- Serial.println(gps.localTime);
+// Serial.println(gps.localTime);

   String date = splitString(sub,',',9);
   gps.day = date.substring(0,2);
@@ -175,7 +174,7 @@
   gps.year = date.substring(4,6);
   gps.date = gps.day + '/' + gps.month + '/' + gps.year;

- Serial.println(gps.date);
+// Serial.println(gps.date);

   String valid = splitString(sub,',',2);
   gps.isValid = (valid.equals(VALID) ? true : false);
@@ -192,7 +191,7 @@

     gps.northingIndicator = splitString(sub,',',4);
     gps.latString = degreeOfLat + CHAR_DEGREE + minuteOfLat + CHAR_MINUTE + gps.secondOfLat + CHAR_SECOND + gps.northingIndicator;
- Serial.println(gps.latString);
+// Serial.println(gps.latString);

     // Longitude
     gps.lon = splitString(sub,',',5);
@@ -205,7 +204,7 @@

     gps.eastingIndicator = splitString(sub,',',6);
     gps.lonString = degreeOfLon + CHAR_DEGREE + minuteOfLon + CHAR_MINUTE + gps.secondOfLon + CHAR_SECOND + gps.eastingIndicator;
- Serial.println(gps.lonString);
+// Serial.println(gps.lonString);
   }
 }

@@ -215,17 +214,17 @@
   if((ggaStatus==1)||(ggaStatus==2)){
     gps.altString = splitString(sub,',',9);
     gps.altString += splitString(sub,',',10);
-  Serial.println(gps.altString);
+//  Serial.println(gps.altString);
   }
 }

 //0x0D 0x0A CR LF \r \n
 String readLine(){
   String line = "";
-  delay(500);
+//  delay(50);
   while(Serial1.available()) {
       char c = char(Serial1.read());
-      delay(50);
+      delay(5);
       Serial.print(c);
       if(c == '\r'){
         // do nothing


BETA 0.4 fix #1

BETA 0.4 fix #1

- Minor changes and bugfixes

--- Core.ino
+++ Core.ino
@@ -95,7 +95,8 @@

 /**
      Walks
-*/inline void walk(){
+*/
+inline void walk(){
   digitalWrite(MOTOR_RIGHT, HIGH);
   digitalWrite(MOTOR_LEFT, HIGH);
 }


Verified that it works.

Verified that it works.

--- hacks/rf_blink_link/rf_blink_link.ino
+++ hacks/rf_blink_link/rf_blink_link.ino
@@ -1,8 +1,10 @@
 /*
- * Send and receive RF on 433 MHz using a FS1000A TX/RX receiver module for two arduinos.
+ * Send and receive RF on 433 MHz using a FS1000A TX/RX receiver module for two arduino nanos.
  * The transmitting arduino (IS_TX == true) has a button, the receiving arduino has a led.
  * When you push the transmitting arduinos button it sends a message  and
  * the receiving arduinos led lights up and the message is sent on the serial line.
+ *
+ * Note: Cheap arduino nano copy builds as an Arduino Nano!
  */

 #include <RH_ASK.h>


fix spacing

fix spacing

--- examples/FullyFeatured-ESP32/FullyFeatured-ESP32.ino
+++ examples/FullyFeatured-ESP32/FullyFeatured-ESP32.ino
@@ -42,7 +42,7 @@
     case SYSTEM_EVENT_STA_DISCONNECTED:
         Serial.println("WiFi lost connection");
         xTimerStop(mqttReconnectTimer, 0); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
-		xTimerStart(wifiReconnectTimer, 0);
+        xTimerStart(wifiReconnectTimer, 0);
         break;
     }
 }


Move volatiles into private members and move ISR code into internal callback methods.

--- examples/adsr/adsr.ino
+++ examples/adsr/adsr.ino
@@ -73,10 +73,6 @@
   uint16_t R;  // ms
 };

-volatile bool gate, retrigger;
-volatile uint8_t selected_env;
-volatile unsigned long debounce;
-
 static const unsigned char label[4] = {'A', 'D', 'S', 'R'};

 void gate_isr();
@@ -106,6 +102,9 @@
     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;
@@ -241,6 +240,25 @@
     }
   }

+  void gate_callback()
+  {
+    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();
+    }
+  }
+
   void widget_adsr_scroll_callback(uint8_t selected, int delta)
   {
     const int8_t v_last = widget_save_->params.vals.v[selected];
@@ -276,53 +294,36 @@
   }

 private:
+  struct ParameterValues
+  {
+    int8_t v[8];
+  };
+
+  DUINO_WidgetContainer<2> * container_outer_;
+  DUINO_WidgetContainer<8> * container_adsr_;
+  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;
-
-  struct ParameterValues
-  {
-    int8_t v[8];
-  };
-
-  DUINO_WidgetContainer<2> * container_outer_;
-  DUINO_WidgetContainer<8> * container_adsr_;
-  DUINO_SaveWidget<ParameterValues> * widget_save_;
-  DUINO_DisplayWidget * widgets_adsr_[8];
 };

 DU_ADSR_Function * function;

-void gate_isr()
-{
-  gate = function->gt_read_debounce(DUINO_Function::GT3);
-  if (gate)
-  {
-    retrigger = true;
-  }
-}
-
-void switch_isr()
-{
-  if (millis() - debounce > DEBOUNCE_MS)
-  {
-    selected_env++;
-    selected_env %= 2;
-    debounce = millis();
-  }
-}
+void gate_isr() { function->gate_callback(); }
+void switch_isr() { function->switch_callback(); }

 void adsr_scroll_callback(uint8_t selected, int delta) { function->widget_adsr_scroll_callback(selected, delta); }

 void setup()
 {
-  gate = retrigger = false;
-  selected_env = 0;
-  debounce = 0;
-
   function = new DU_ADSR_Function();

   function->begin();


Errors corrected, better handling, turbo mode added

--- ardubottino.ino
+++ ardubottino.ino
@@ -1,166 +1,206 @@
-#include <IRremoteInt.h>
+/*Ardubottino
+ * Basic control for the Ardubottino rover, via IR or auto mode.
+ *
+ * This code is in the public domain.
+ *
+ * Emiliano Mattioli
+ * last modified 5 July 2015
+ */
+
 #include <IRremote.h>

- int IRpin =2; //pin del sensore IR
- IRrecv irrecv(IRpin);
- long duration;
- long dursx;
- long durdx;
-
- const int en1 = 10; //pin enable
- const int en2 = 5;
- const int m1fd = 4; //controlli motore
- const int m2fd = 3;
- const int m1bk = 8;
- const int m2bk = 11;
- const int pinping = 7; //pin sensore distanza
- const int sterzo = 600; //durata dello sterzo
- const int ridster = 550; //diminuzione per i cingoli
- const int distanza = 500; //distanza minima ostacoli
- int motore1 = 78;//pwm motore dx
- int motore2 = 72;//pwm motore sx
- boolean automat = false;
-
- decode_results results;
-
- void setup() {
-  Serial.begin(9600);
-  pinMode(m1fd, OUTPUT);
-  pinMode(m1bk, OUTPUT);
-  pinMode(m2fd, OUTPUT);
-  pinMode(m2bk, OUTPUT);
-  pinMode(en1, OUTPUT);
-  pinMode(en2, OUTPUT);
-  analogWrite(en1,motore1);
-  analogWrite(en2,motore2);
+
+//PINS
+IRrecv irrecv(2); //IR sensor output to pin       #2
+const int en1 = 10; //Motor 1 enable to pin       #10
+const int m1fd = 8; //Motor 1 fd control to pin   #4
+const int m1bk = 4; //Motor 1 bk control to pin   #8
+const int en2 = 5;  //Motor 2 enable to pin       #5
+const int m2fd = 3; //Motor 2 fd control to pin   #3
+const int m2bk = 11;//Motor 2 bk control to pin   #11
+const int ping = 7; //Echo sensor to pin          #7
+
+
+//IR
+decode_results results;
+
+//Echo
+
+int distlt;
+int distrt;
+const int tooclose = 500;
+
+//Auto
+const int steer = 800;
+const int steeravoid = 100;
+bool automat = false;
+
+//Speed
+int motor1PWM = 75;
+int motor2PWM = 80;
+bool turbo = false;
+
+//Debug
+bool debug = false;
+
+void setup() {
+  pinMode(m1fd,OUTPUT);
+  pinMode(m1bk,OUTPUT);
+  pinMode(en1,OUTPUT);
+  pinMode(m2fd,OUTPUT);
+  pinMode(m2bk,OUTPUT);
+  pinMode(en2,OUTPUT);
+  analogWrite(en1,motor1PWM);
+  analogWrite(en2,motor2PWM);
+
   irrecv.enableIRIn();
- }
-
- void loop(){
-   if(irrecv.decode(&results)){
-     if (!automat) {
-       if(results.value == 2742014623 || results.value == 31889539){
-         dritto();
-       } else if (results.value == 2383694249 || results.value == 2039764837 ) {
-         sinistra();
-       } else if (results.value == 15111918 || results.value == 2725237002) {
-         rovescia();
-       } else if (results.value == 1665824360 || results.value == 3250666572 ) {
-         destra();
-       } else if (results.value == 1463772700|| results.value == 4173897784) {
-         motore1 += 1;
-         debugmot(motore1,motore2);
-         analogWrite(en1,motore1);
-       } else if (results.value == 2117945733|| results.value == 2461875145) {
-         motore2 += 1;
-         debugmot(motore1,motore2);
-         analogWrite(en2,motore2);
-       } else if (results.value == 188078261|| results.value == 532007673) {
-         motore1 -=1;
-         debugmot(motore1,motore2);
-         analogWrite(en1,motore1);
+  delay(800);
+  if (debug) {
+    Serial.begin(9600);
+    Serial.println("READY");
+  }
+}
+
+void loop() {
+   if (debug) {
+      Serial.print("IR:");
+      Serial.print(results.value);
+      Serial.print(" Distance:");
+      Serial.print(echo());
+      Serial.print(" Motor1:");
+      Serial.print(motor1PWM);
+      Serial.print(" Motor2:");
+      Serial.println(motor2PWM);
+    }
+  if (irrecv.decode(&results)) {
+
+    if (!automat) {
+      if(results.value == 2742014623 || results.value == 31889539){
+         forward();
+      } else if (results.value == 2383694249 || results.value == 2039764837 ) {
+         left();
+      } else if (results.value == 15111918 || results.value == 2725237002) {
+         backward();
+      } else if (results.value == 1665824360 || results.value == 3250666572 ) {
+         right();
+      } else if (results.value == 1463772700|| results.value == 4173897784) {
+         motor2PWM += 1;
+         analogWrite(en2,motor2PWM);
+      } else if (results.value == 2117945733|| results.value == 2461875145) {
+         motor1PWM += 1;
+         analogWrite(en1,motor1PWM);
+      } else if (results.value == 188078261|| results.value == 532007673) {
+         motor2PWM -= 1;
+         analogWrite(en2,motor2PWM);
        } else if (results.value == 2411542288|| results.value == 2067612876) {
-         motore2 -=1;
-         debugmot(motore1,motore2);
-         analogWrite(en2,motore2);
-       } else  {
-         ferma();
-       }
-     }
-     if (results.value == 3969632309 || results.value == 18594425) {
+         motor1PWM -= 1;
+         analogWrite(en1,motor1PWM);
+       }  else  {
+         noMotion();
+       }
+    }
+    if (results.value == 3969632309 || results.value == 18594425) {
        if (automat) {
          automat = false;
-         ferma();
-         delayMicroseconds(300000);
+         noMotion();
+         delay(500);
        }else{
          automat = true;
-         dritto();
-         delayMicroseconds(300000);
+         noMotion();
+         delay(500);
+         forward();
        }
-     }
-     irrecv.resume();
-   }
-   if (automat && echo() < distanza){ //trovato un ostacolo
+    }
+    if (results.value == 3190304459|| results.value == 480179375) {
+       if (turbo) {
+           turbo = false;
+           motor1PWM -= 100;
+           motor2PWM -= 100;
+         } else {
+           turbo = true;
+           motor1PWM += 100;
+           motor2PWM += 100;
+         }
+         analogWrite(en1,motor1PWM);
+         analogWrite(en2,motor2PWM);
+         delay(500);
+    }
+    irrecv.resume();
+  }
+  if (automat && echo() < tooclose) {
     analogWrite(en1,170);
     analogWrite(en2,170);
-    ferma();
-    sinistra();
-    delay(sterzo);
-    ferma();
-    dursx = echo(); //guarda a sinistra
-    destra();
-    delay(sterzo*2);
-    ferma();
-    durdx = echo(); //guarda a destra
-    if (dursx < distanza && durdx < distanza){
-      destra();
-      delay(sterzo*2);
-    } else if (dursx > durdx) {
-      sinistra();
-      Serial.println(1);
-      delay(sterzo+ridster);
+    right();
+    delay(steer);
+    distrt = echo();
+    left();
+    delay(steer*2);
+    distlt = echo();
+    noMotion();
+    if (distrt < tooclose && distlt < tooclose) {
+      left();
+      delay(steer*2);
+    } else if (distrt < distlt) {
+      left();
+      delay(steeravoid);
     } else {
-      sinistra();
-      delay(ridster);
-    }
-    //sceglie dove c'è più spazio
-    dritto();
-    analogWrite(en1,motore1);
-    analogWrite(en2,motore2);
+      right();
+      delay(steer*2+steeravoid);
+    }
+    analogWrite(en1,motor1PWM);
+    analogWrite(en2,motor2PWM);
+    forward();
   }
- }
-
-
- void dritto() {
-  digitalWrite(m1bk,LOW);
-  digitalWrite(m2bk,LOW);
-  digitalWrite(m2fd,HIGH);
-  digitalWrite(m1fd,HIGH);
- }
-
- void rovescia() {
-  digitalWrite(m1fd,LOW);
-  digitalWrite(m2fd,LOW);
-  digitalWrite(m1bk,HIGH);
-  digitalWrite(m2bk,HIGH);
- }
-
- void destra() {
-  digitalWrite(m1fd,LOW);
-  digitalWrite(m2fd,HIGH);
-  digitalWrite(m1bk,HIGH);
-  digitalWrite(m2bk,LOW);
- }
-
- void sinistra() {
-  digitalWrite(m1fd,HIGH);
-  digitalWrite(m2fd,LOW);
-  digitalWrite(m1bk,LOW);
-  digitalWrite(m2bk,HIGH);
- }
-
- void debugmot(int sm1, int sm2) {
-  Serial.print(sm1);
-  Serial.print(",");
-  Serial.println(sm2);
- }
-
- void ferma() {
+}
+
+void noMotion() {
   digitalWrite(m1fd,LOW);
   digitalWrite(m2fd,LOW);
   digitalWrite(m1bk,LOW);
   digitalWrite(m2bk,LOW);
   delay(50);
- }
-
- long echo() {
-  pinMode(pinping, OUTPUT);
-  digitalWrite(pinping, LOW);
+}
+
+void forward() {
+  digitalWrite(m1bk,LOW);
+  digitalWrite(m2bk,LOW);
+  digitalWrite(m2fd,HIGH);
+  digitalWrite(m1fd,HIGH);
+}
+
+void backward() {
+  digitalWrite(m1fd,LOW);
+  digitalWrite(m2fd,LOW);
+  digitalWrite(m1bk,HIGH);
+  digitalWrite(m2bk,HIGH);
+}
+
+void right() {
+  digitalWrite(m1fd,HIGH);
+  digitalWrite(m2fd,LOW);
+  digitalWrite(m1bk,LOW);
+  digitalWrite(m2bk,HIGH);
+}
+
+void left() {
+  digitalWrite(m1fd,LOW);
+  digitalWrite(m2fd,HIGH);
+  digitalWrite(m1bk,HIGH);
+  digitalWrite(m2bk,LOW);
+
+}
+
+long echo() {
+  long distance;
+  pinMode(ping, OUTPUT);
+  digitalWrite(ping, LOW);
   delayMicroseconds(2);
-  digitalWrite(pinping, HIGH);
+  digitalWrite(ping, HIGH);
   delayMicroseconds(5);
-  digitalWrite(pinping, LOW);
-  pinMode(pinping, INPUT);
-  duration = pulseIn(pinping,HIGH);
-  return duration;
- }
+  digitalWrite(ping, LOW);
+  pinMode(ping, INPUT);
+  distance = pulseIn(ping, HIGH);
+  delay(100);
+  return distance;
+}
+


Update MWB.ino

Update MWB.ino


minor modify

minor modify

--- main.ino
+++ main.ino
@@ -105,9 +105,6 @@
     find my way to start point
     then make a travel
      */
-    goalX = 1;
-    goalY = 1;
-    while ()

     empty_space_R = 0;
     while (abs(goalX - currentX) >= 2 && abs(goalY - currentY) >= 2) {


updating RTC

updating RTC

--- Arduino/I2CSensorsMicro/I2CSensorsMicro.ino
+++ Arduino/I2CSensorsMicro/I2CSensorsMicro.ino
@@ -104,6 +104,62 @@
 }

+/*
+
+*********************************************************
+*                                                       *
+*               Real Time Clock                         *
+*                                                       *
+*********************************************************
+
+For the real time clock we are going to use the code available from gravitech http://site.gravitech.us/MicroResearch/I2C/I2C-RTC/I2C-RTC-Arduino.pde
+This just displays the time. At some point we need to have set the time!
+
+*/
+
+
+
+String RTC_time() {
+  char tempchar [7];
+  byte i = 0;
+  Wire.beginTransmission(rtc_address);
+  Wire.write(0);
+  Wire.endTransmission();
+
+  Wire.requestFrom(rtc_address, 7);
+  while(Wire.available()) {
+    tempchar[i] = Wire.read(); // receive a byte as character
+    i++;
+  }
+
+  byte Second = tempchar[0];
+  byte Minute = tempchar[1];
+  byte Hour   = tempchar[2];
+  byte Day    = tempchar[3];
+  byte Date   = tempchar[4];
+  byte Month  = tempchar[5];
+  byte Year   = tempchar[6];
+
+  // Display time
+  String ret = "";
+  ret += String(Month, HEX) + "/" + String(Date, HEX) + "/";
+  if (Year<10)
+    ret += "0";
+  ret += String(Year, HEX) + "\t";
+  if (Hour < 10)
+    ret += "0";
+  ret += String(Hour, HEX) + ":";
+  if (Minute < 10)
+    ret += "0";
+  ret += String(Minute, HEX) + ":";
+  if (Second < 10)
+    ret += "0";
+  ret += String(Second, HEX);
+
+  return ret;
+
+}
+

 /*


Improve the commands switch

Improve the commands switch

--- Arduino/linkit_duo_led5/linkit_duo_led5.ino
+++ Arduino/linkit_duo_led5/linkit_duo_led5.ino
@@ -224,66 +224,73 @@
     breathe_step = 0;
     breathe_counter = 0;

-    if(is_command(str, "pause")){
-      paused = true;
-    } else if(is_command(str, "continue")){
-      paused = false;
-    } else if(is_command(str, "erase")){
-      erase(true);
-    } else if(is_command(str, "red")){
-      push_color(red);
-    }
-    else if(is_command(str, "green")){
-      push_color(green);
-    }
-    else if(is_command(str, "blue")){
-      push_color(blue);
-    }
-    else if(is_command(str, "black")){
-      push_color(black);
-    }
-    else if(is_command(str, "yellow")){
-      push_color(yellow);
-    }
-    else if(is_command(str, "orange")){
-      push_color(orange);
-    }
-    else if(is_command(str, "purple")){
-      push_color(purple);
-    }
-    else if(is_command(str, "cyan")){
-      push_color(cyan);
-    }
-    else if(is_command(str, "magenta")){
-      push_color(magenta);
-    }
-    else if(is_command(str, "pink")){
-      push_color(pink);
-    }
-    else if(is_command(str, "white")){
-      push_color(white);
-    }
-    else if(is_command(str, "gray")){
-      push_color(gray);
-    }
-    else if(is_command(str, "ltgreen")){
-      push_color(ltgreen);
-    }
-    else if(is_command(str, "seafoam")){
-      push_color(seafoam);
-    }
-    else if(is_command(str, "ltblue")){
-      push_color(ltblue);
-    }
-    else if(is_command(str, "blink")){
-      start_blinking();
-    }
-    else if(is_command(str, "breathe")){
-      start_breathing();
-    }
-    else if(is_command(str, "flush")){
-      flush();
-    }
+    if     (is_command(str, "pause"))    paused = true;
+    else if(is_command(str, "continue")) paused = false;
+    else if(is_command(str, "erase"))    erase(true);
+    else if(is_command(str, "blink"))    start_blinking();
+    else if(is_command(str, "breathe"))  start_breathing();
+    else if(is_command(str, "flush"))    flush();
+    else if(is_command(str, "red"))      push_color(red);
+    else if(is_command(str, "green"))    push_color(green);
+    else if(is_command(str, "blue"))     push_color(blue);
+    else if(is_command(str, "black"))    push_color(black);
+    else if(is_command(str, "yellow"))   push_color(yellow);
+    else if(is_command(str, "orange"))   push_color(orange);
+    else if(is_command(str, "purple"))   push_color(purple);
+    else if(is_command(str, "cyan"))     push_color(cyan);
+    else if(is_command(str, "magenta"))  push_color(magenta);
+    else if(is_command(str, "pink"))     push_color(pink);
+    else if(is_command(str, "white"))    push_color(white);
+    else if(is_command(str, "gray"))     push_color(gray);
+    else if(is_command(str, "ltgreen"))  push_color(ltgreen);
+    else if(is_command(str, "seafoam"))  push_color(seafoam);
+    else if(is_command(str, "ltblue"))   push_color(ltblue);
+
+//
+//
+//    if(is_command(str, "pause")){
+//      paused = true;
+//    } else if(is_command(str, "continue")){
+//      paused = false;
+//    } else if(is_command(str, "erase")){
+//      erase(true);
+//    } else if(is_command(str, "red")){
+//      push_color(red);
+//    } else if(is_command(str, "blink")){
+//      start_blinking();
+//    } else if(is_command(str, "breathe")){
+//      start_breathing();
+//    } else if(is_command(str, "flush")){
+//      flush();
+//    } else if(is_command(str, "green")){
+//      push_color(green);
+//    } else if(is_command(str, "blue")){
+//      push_color(blue);
+//    } else if(is_command(str, "black")){
+//      push_color(black);
+//    } else if(is_command(str, "yellow")){
+//      push_color(yellow);
+//    } else if(is_command(str, "orange")){
+//      push_color(orange);
+//    } else if(is_command(str, "purple")){
+//      push_color(purple);
+//    } else if(is_command(str, "cyan")){
+//      push_color(cyan);
+//    } else if(is_command(str, "magenta")){
+//      push_color(magenta);
+//    } else if(is_command(str, "pink")){
+//      push_color(pink);
+//    } else if(is_command(str, "white")){
+//      push_color(white);
+//    } else if(is_command(str, "gray")){
+//      push_color(gray);
+//    } else if(is_command(str, "ltgreen")){
+//      push_color(ltgreen);
+//    } else if(is_command(str, "seafoam")){
+//      push_color(seafoam);
+//    } else if(is_command(str, "ltblue")){
+//      push_color(ltblue);
+//    }
   } else {
     bool should_flush = false;


button example works!

button example works!

--- html/examples/02.Digital/Button/Button.ino
+++ html/examples/02.Digital/Button/Button.ino
@@ -1,24 +1,23 @@
+//  This example is Chibitronics Love to Code tested!
 /*
   Button

- Turns on and off a light emitting diode(LED) connected to digital
- pin 13, when pressing a pushbutton attached to pin 2.
+ Turns on and off a light emitting diode(LED) connected to
+ pin A2, when pressing a pushbutton attached to pin A3.

  The circuit:
- * LED attached from pin 13 to ground
- * pushbutton attached to pin 2 from +5V
- * 10K resistor attached to pin 2 from ground
-
- * Note: on most Arduinos there is already an LED on the board
- attached to pin 13.
-
+ * LED attached from pin A2 to ground
+ * pushbutton attached to pin A3 from ground
+ * on chibitronics boards, A3 can be configured to have an intenal pull-up

  created 2005
  by DojoDave <http://www.0j0.org>
  modified 30 Aug 2011
  by Tom Igoe
-
+ modified 25 May 2016
+ by chibitronics
+
  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Button
@@ -26,8 +25,8 @@

 // constants won't change. They're used here to
 // set pin numbers:
-const int buttonPin = 2;     // the number of the pushbutton pin
-const int ledPin =  13;      // the number of the LED pin
+const int buttonPin = A3;     // the number of the pushbutton pin
+const int ledPin =  A2;      // the number of the LED pin

 // variables will change:
 int buttonState = 0;         // variable for reading the pushbutton status
@@ -36,7 +35,7 @@
   // initialize the LED pin as an output:
   pinMode(ledPin, OUTPUT);
   // initialize the pushbutton pin as an input:
-  pinMode(buttonPin, INPUT);
+  pinMode(buttonPin, INPUT_PULLUP);
 }

 void loop(){
@@ -44,8 +43,8 @@
   buttonState = digitalRead(buttonPin);

   // check if the pushbutton is pressed.
-  // if it is, the buttonState is HIGH:
-  if (buttonState == HIGH) {
+  // if it is, the buttonState is LOW:
+  if (buttonState == LOW) {
     // turn LED on:
     digitalWrite(ledPin, HIGH);
   }


Working version, cleanup necessary

Working version, cleanup necessary

--- spBox.ino
+++ spBox.ino
@@ -23,6 +23,7 @@
 #include "Adafruit_SSD1306.h"

 #define	SERIAL_STATUS_OUTPUT
+#define MEASURE_PREFORMANCE

 // #define BUTTON_A		0		// huzzah oled
 #define BUTTON_B		16		// huzzah oled
@@ -509,18 +510,6 @@
 	display.println(display_struct.displaybuffer[3]);
 }

-
-//void long_button_press_cb(void *arg) {
-//	// TODO
-//}
-//
-//void long_button_press_timer() {
-//	os_timer_disarm(&timer_long_button_press);
-//	os_timer_setfn(&timer_long_button_press, (os_timer_func_t *)long_button_press_cb, (void *)0);
-//	os_timer_arm(&timer_long_button_press, DELAY_MS_TWOSEC, true);
-//}
-
-
 void setup() {
 #if !defined(ESP8266)
 	while (!Serial) delay(1);
@@ -546,35 +535,35 @@
 }

 void loop() {
-
-//int32_t perfStopWatch_getvalues;
-//int32_t perfStopWatch_output;
-//perfStopWatch_getvalues = micros();
+#ifdef MEASURE_PREFORMANCE
+	int32_t perfStopWatch_getvalues;
+	int32_t perfStopWatch_output;
+	perfStopWatch_getvalues = micros();
+#endif

 	check_sensor_updates();
 	check_sensor_calc();

-//perfStopWatch_getvalues -= micros();
-//perfStopWatch_output = micros();
-//
-//perfStopWatch_output -= micros();
+#ifdef MEASURE_PREFORMANCE
+	perfStopWatch_getvalues -= micros();
+	perfStopWatch_output = micros();
+	perfStopWatch_output -= micros();
+#endif

 	if (display_struct.update_display) {
 		display_struct.update_display = false;
 		update_display();
 	}
-
-//Serial.print("performance: ");
-//Serial.print(-perfStopWatch_getvalues);
-//Serial.print(" ");
-//Serial.println(-perfStopWatch_output);
-
+#ifdef MEASURE_PREFORMANCE
+	Serial.print("performance us: ");
+	Serial.print(-perfStopWatch_getvalues);
+	Serial.print(" ");
+	Serial.println(-perfStopWatch_output);
+#endif
+
 	yield();
 	display.display();
 	yield();
-
-//	delay(100);
-

 	//// display tab-separated accel/gyro x/y/z values
 	//Serial.print("a/g:\t");
@@ -598,22 +587,22 @@
 	//Serial.print(sensors.pressure); Serial.print("\t");
 	//Serial.print(sensors.altitude); Serial.print("\t");

-	if (rotenc.changed_rotEnc || button.changed) {
-
-		Serial.print("Rot.enc:\t");
-		Serial.print(rotenc.actualRotaryTicks);
-		Serial.print(" Button: changed ");
-		Serial.print(button.changed);
-		Serial.print(", long ");
-		Serial.print(button.long_diff_change);
-		Serial.print(", int_signal ");
-		Serial.print(button.int_signal);
-		Serial.print(",  button signal ");
-		Serial.print(digitalRead(ENCODER_SW));
-		Serial.println("");
-
-		rotenc.changed_rotEnc = false;
-		button.changed = false;
-		button.long_diff_change = false;
-	}
+	//if (rotenc.changed_rotEnc || button.changed) {
+	//
+	//	Serial.print("Rot.enc:\t");
+	//	Serial.print(rotenc.actualRotaryTicks);
+	//	Serial.print(" Button: changed ");
+	//	Serial.print(button.changed);
+	//	Serial.print(", long ");
+	//	Serial.print(button.long_diff_change);
+	//	Serial.print(", int_signal ");
+	//	Serial.print(button.int_signal);
+	//	Serial.print(",  button signal ");
+	//	Serial.print(digitalRead(ENCODER_SW));
+	//	Serial.println("");
+
+	//	rotenc.changed_rotEnc = false;
+	//	button.changed = false;
+	//	button.long_diff_change = false;
+	//}
 }


first working frequency generator

first working frequency generator


Added INT1 interrupt handling for water leak circuit.

--- laundrymote_v0_1/laundrymote_v0_1.ino
+++ laundrymote_v0_1/laundrymote_v0_1.ino
@@ -10,7 +10,7 @@
    * A2 - Temperature
    * D3 - Water Leak detector

-   Created 05-MAR-2015 by Jon Brule
+   Created 15-MAR-2015 by Jon Brule
 ----------------------------------------------------------------------------- */
 #include <avr/sleep.h>
 #include <avr/power.h>
@@ -48,51 +48,50 @@
 // Initialization
 //
 void setup () {
-    #if SERIAL || DEBUG
-        Serial.begin(BAUD_RATE);
-        Serial.print("\n[laundryMote - ");
-        Serial.print(VERSION);
-        Serial.println("]");
-    #endif
-    setupRadio();
-    setupSensors();
-    setupSleep();
+  #if SERIAL || DEBUG
+    Serial.begin(BAUD_RATE);
+    Serial.print("\n[laundryMote - ");
+    Serial.print(VERSION);
+    Serial.println("]");
+  #endif
+  setupRadio();
+  setupSensors();
+  setupSleep();
 }

 void setupRadio() {
-    #if DEBUG
-        Serial.print("setup radio...");
-    #endif
+  #if DEBUG
+    Serial.print("setup radio...");
+  #endif

-    radio.initialize(FREQUENCY,NODEID,NETWORKID);
-    radio.setHighPower();
-    delay(1000);
+  radio.initialize(FREQUENCY,NODEID,NETWORKID);
+  radio.setHighPower();
+  delay(1000);

-    #if DEBUG
-        Serial.println("ok!");
-    #endif
+  #if DEBUG
+    Serial.println("ok!");
+  #endif
 }

 void setupSensors() {
-    sensors = new Sensors();
-    sensorData = new SensorData();
-    memset(sensorData, 0, sizeof(*sensorData));
-
-
+  sensors = new Sensors();
+  sensorData = new SensorData();
+  memset(sensorData, 0, sizeof(*sensorData));
+  attachInterrupt(1, waterLeak, CHANGE);
 }

 void setupSleep() {
-    // normal timer operation
-    TCCR1A = 0x00;
+  // normal timer operation
+  TCCR1A = 0x00;

-    // clear the timer counter register
-    TCNT1=0x0000;
+  // clear the timer counter register
+  TCNT1 = 0x0000;

-    // configure the prescaler for 1:1024, a 4.09 sec timeout
-    TCCR1B = 0x05;
+  // configure the prescaler for 1:1024, a 4.09 sec timeout
+  TCCR1B = 0x05;

-    // enable the timer overlow interrupt
-    TIMSK1=0x01;
+  // enable the timer overlow interrupt
+  TIMSK1 = 0x01;
 }

@@ -100,31 +99,44 @@
 // Main Loop
 //
 void loop () {
-    if (f_timer == 1) {
-        f_timer = 0;
-        enterSleep();
-    }
-
+  if (f_timer == 1) {
+    f_timer = 0;
+    enterSleep();
+  }
 }

 //-----------------------------------------------------------------------------
-// Timer1 Interrupt Service Routine
-ISR(TIMER1_OVF_vect) {
-     if (f_timer == 0) {
-        f_timer = 1;
-
-        noInterrupts();
-        digitalWrite(MOTE_LED_PIN, HIGH);
-        sensors->measure();
-        report();
-        digitalWrite(MOTE_LED_PIN, LOW);
-        interrupts();
-
-     }
+// ISR - Water Leak
+void waterLeak() {
+  #if DEBUG
+    Serial.println("WATER LEAK detcted!!!");
+  #endif
+
+  noInterrupts();
+  digitalWrite(MOTE_LED_PIN, HIGH);
+  sensors->measure();
+  report(MSG_ALERT, 1);
+  digitalWrite(MOTE_LED_PIN, LOW);
+  interrupts();
 }

 //-----------------------------------------------------------------------------
-// sleeps the microcontroller until the internal timer expires
+// ISR - Sensor Measurement / Report
+ISR(TIMER1_OVF_vect) {
+  if (f_timer == 0) {
+    f_timer = 1;
+
+    noInterrupts();
+    digitalWrite(MOTE_LED_PIN, HIGH);
+    sensors->measure();
+    report(MSG_READING, 0);
+    digitalWrite(MOTE_LED_PIN, LOW);
+    interrupts();
+  }
+}
+
+//-----------------------------------------------------------------------------
+// Sleeps the microcontroller
 void enterSleep(void) {
   set_sleep_mode(SLEEP_MODE_IDLE);

@@ -153,29 +165,29 @@
 }

 //-----------------------------------------------------------------------------
-// generates a sensor report, sending it to the RF gateway
-void report() {
-    sensors->report(sensorData);
+// Generates a sensor report, sending it to the RF gateway
+void report(byte type, byte component) {
+  sensors->report(sensorData);

-    memset(&outbound, 0, sizeof(outbound));
-    outbound.msg.type = MSG_READING;
-    outbound.msg.source = NODEID;
-    outbound.msg.destination = 0;
-    outbound.msg.component = 0;
-    outbound.msg.rssi = 0;
-    memcpy(&outbound.msg.data, sensorData, sizeof(*sensorData));
+  memset(&outbound, 0, sizeof(outbound));
+  outbound.msg.type = type;
+  outbound.msg.source = NODEID;
+  outbound.msg.destination = 0;
+  outbound.msg.component = component;
+  outbound.msg.rssi = 0;
+  memcpy(&outbound.msg.data, sensorData, sizeof(*sensorData));

+  #if DEBUG
+    Serial.print("Broadcasting report to gateway...");
+  #endif
+  if (radio.sendWithRetry(GATEWAYID, outbound.raw, MSG_LENGTH)) {
     #if DEBUG
-        Serial.print("Broadcasting report to gateway...");
+      Serial.println("ACK");
     #endif
-    if (radio.sendWithRetry(GATEWAYID, outbound.raw, MSG_LENGTH)) {
-        #if DEBUG
-            Serial.println("ACK");
-        #endif
-    } else {
-        #if DEBUG
-            Serial.println("No ACK!");
-        #endif
-    }
+  } else {
+    #if DEBUG
+      Serial.println("No ACK!");
+    #endif
+  }
 }


Add a small wait for the serial monitor to be connected, then show the script's name and version.

--- Arduino/BlueCube/BlueCube.ino
+++ Arduino/BlueCube/BlueCube.ino
@@ -8,6 +8,7 @@
     APPLICATION SETTINGS (USER EDITABLE)

     - General
+    SCRIPT_VERSION            The version of this code
     VERBOSE_MODE              Set to 'true' enables debug output to

     BLUEFRUIT_HWSERIAL_NAME   Name of the HW serial port the Bluefruit BLE
@@ -25,6 +26,7 @@
     RANDOM_COLOURS_DELAY      Delay before randomly setting the next colour
     FACESWEEP_DELAY           Delay between the movements in the animation
 ============================================================================ */
+#define SCRIPT_VERSION              "0.8"
 #define VERBOSE_MODE                true
 #define BLUEFRUIT_UART_MODE_PIN     5
 #define BLUEFRUIT_HWSERIAL_NAME     Serial1
@@ -69,11 +71,28 @@

 void setup(void)
 {
+  Serial.begin(115200);
+
   // Serial port options for control of the Cube using serial commands are:
   // 0: Control via the USB connector (most common).
   // 1: Control via the RXD and TXD pins on the main board.
   // -1: Don't attach any serial port to interact with the Cube.
   cube.begin(0, 115200); // Start on serial port 0 (USB) at 115200 baud
+
+  // Wait for the serial interface, to be established, or for a maximum of
+  // 3 seconds.
+  byte waitCounter = 0;
+  while (waitCounter < 30 && !Serial) {
+    delay(100);
+    waitCounter++;
+  }
+
+  // Print Debug Info if a serial interface is present
+  if (Serial)
+  {
+    Serial.print("BlueCube v");
+    Serial.println(SCRIPT_VERSION);
+  }

   // Tell the cube library that the function 'userFunctionHandler' should be
   // called if the user uses the 'user ### colour;' serial command line
@@ -82,7 +101,6 @@

   pinMode(BLUEFRUIT_UART_MODE_PIN, OUTPUT);

-  Serial.begin(115200);
   Serial.println(F("Adafruit Bluefruit App Controller Example"));
   Serial.println(F("-----------------------------------------"));


Documnent out everything for debouncing

Documnent out everything for debouncing

--- Arduino_Code/Arduino_Code.ino
+++ Arduino_Code/Arduino_Code.ino
@@ -2,20 +2,25 @@
 Created by Geoff Spielman on 2016-06-25.
 Copyright (c) 2016 Geoff Spielman. All rights reserved.
 */
-
- // put your setup code here, to run once:
-  const int btn0 = 2;
-  const int btn1 = 7;
-  const int btn2 = 12;
-  const int btn3 = 8;
-  const int led0 = 5;
-  const int led1 = 3;
-  const int led2 = 4;
-  const int led3 = 10;
-
- int btn[] = {btn0, btn1, btn2, btn3};
- int led[] = {led0, led1, led2, led3};
-
+const int btn0 = 2;
+const int btn1 = 7;
+const int btn2 = 12;
+const int btn3 = 8;
+const int led0 = 5;
+const int led1 = 3;
+const int led2 = 4;
+const int led3 = 10;
+
+int btn[] = {btn0, btn1, btn2, btn3};
+int led[] = {led0, led1, led2, led3};
+
+//debouncing purposes
+long prevChangeTime[] = {millis(), millis(), millis(), millis()};
+int prevButtonState[] = {0,0,0,0};
+long debounceTime = 50;
+
+
+/*
  String recString = "";
  boolean arduinoTurn = false;
  String recMessage = "";
@@ -28,10 +33,10 @@
  boolean playerRepeating = false;
  boolean playerCreating = false;
  boolean prevBtns[] = {false, false, false, false};
-
+*/

 void setup() {
- timeOfLastChange = millis();
+ //timeOfLastChange = millis();
  Serial.begin(9600);
  pinMode(btn0, INPUT);
  pinMode(btn1, INPUT);
@@ -41,12 +46,61 @@
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
- recString.reserve(200);
- seqIndex = 0;
+ //recString.reserve(200);
+ //seqIndex = 0;
 }

 void loop() {

+for (int i = 0; i < 4; i ++)
+{
+
+  Serial.print("Btn 0: ");
+  Serial.print(digitalRead(btn[0]));
+  Serial.print("    Btn 1: ");
+  Serial.print(digitalRead(btn[1]));
+  Serial.print("    Btn 2: ");
+  Serial.print(digitalRead(btn[2]));
+  Serial.print("    Btn 3: ");
+  Serial.println(digitalRead(btn[3]));
+
+  //just incase something changes while executing (very unlikely, but I just read it once
+  int cur = digitalRead(btn[i]);
+
+  //just saves the time of last change
+  if (cur != prevButtonState[i])
+    prevChangeTime[i] = millis();
+
+  //if enough time has passed that the button is being held down or has been released (intended state)
+  if ((millis() - prevChangeTime[i]) > debounceTime)
+  {
+    if (cur != prevButtonState[i])
+    {
+      prevButtonState[i] = cur;
+      //now that the new state has been officially changed, make appropriate change
+      if (cur)
+      {
+        //button pressed down
+        Serial.println("down");
+        digitalWrite(led[0], HIGH);
+        digitalWrite(led[1], LOW);
+      }
+      else {
+        //button released
+        Serial.println("up");
+        digitalWrite(led[0], LOW);
+        digitalWrite(led[1], HIGH);
+      }
+    }
+  }
+}
+
+
+
+
+
+/*
+  'all this does is read all the buttons and light them up when pressed
   if (playerCreating || playerRepeating)
   {
     'if button is pressed, turn on LED
@@ -68,6 +122,7 @@
      Serial.print("seqSize: ");
      Serial.println(seqSize);
      */
+     /*

     //If sequence index is less than the length, we are still outputting the sequence
@@ -219,8 +274,11 @@
   Serial.println(" ");
   */

-}
-
+
+
+}
+
+/*
 void serialEvent()
 {
   while (Serial.available())
@@ -231,7 +289,7 @@
     Serial.print("inChar: ");
     Serial.println(inChar);
     */
-
+    /*
     if (inChar == '|')
     {
       int endIndex = recString.indexOf("|");
@@ -256,6 +314,7 @@
         {
         }
         */
+        /*
         for (int i = 2; i <= (seqSize*2); i += 2)
         {
           seqArr[i/2 -1] = recString.charAt(i) - '0';
@@ -271,6 +330,7 @@
           Serial.println(seqArr[i]);
         }
         */
+        /*
         seqIndex = 0;
         LEDon = false;
         for (int i = 0; i < 4; i ++)


Added the Optical Encoder functionality to the steering to determine angle

--- GolfCart_Control_3_/GolfCart_Control_3_.ino
+++ GolfCart_Control_3_/GolfCart_Control_3_.ino
@@ -7,6 +7,7 @@
 #define STEER_RUN 	2000
 #define STEER_LUN       1000
 #define STEER_TIME 	800
+#define STEER_UNIT      0.1
 #define STEER_INTER_1   2 //pin 21
 #define STEER_INTER_2   3 //pin 20
 #define STEER_INTER_G   4 //pin 19
@@ -35,7 +36,10 @@
 Servo brake;

 int readSpeed;
-volatile int steeringAngle = 0;
+volatile double steeringAngle = 0.0;
+volatile boolean inter_1_state;
+volatile boolean inter_2_state;
+volatile boolean inter_g_state;
 int steerSetTime;
 boolean forwardDirection = true;
 volatile boolean brake_state = false;
@@ -115,24 +119,52 @@
   setTime();
 }

-//void moveSteering(bool right)
-//{
-//  if(right)
-//  {
-//    steer.writeMicroseconds(1100);
-//    cmdMessenger.sendCmd(kACK,"I send right");
-//  }
-//  else
-//  {
-//    steer.writeMicroseconds(1900);
-//    cmdMessenger.sendCmd(kACK,"I send left");
-//  }
-//}
-
 void stopSteering()
 {
   steer.writeMicroseconds(1500);
 }
+
+//steer_inter_1 is called when ever the opical encoder inits a interupt
+// that is defined in the Setup(). When the 1 wire wiggles steer_inter_1
+// checks the statis of the 2 wire to deturmine the direction the wheel is
+// turning and sets steeringAngle plus or minus the STEER_UNIT accordingly
+void steer_inter_1()
+{
+  inter_1_state = !inter_1_state;
+  if (inter_2_state)
+  {
+    if(inter_1_state)
+      steeringAngle = steeringAngle - STEER_UNIT;
+    else
+      steeringAngle = steeringAngle + STEER_UNIT;
+  }
+  else
+  {
+    if(inter_1_state)
+      steeringAngle = steeringAngle + STEER_UNIT;
+    else
+      steeringAngle = steeringAngle - STEER_UNIT;
+  }
+}
+
+void steer_inter_2()
+{
+  inter_2_state = !inter_2_state;
+  if (inter_1_state)
+  {
+    if(inter_2_state)
+      steeringAngle = steeringAngle + STEER_UNIT;
+    else
+      steeringAngle = steeringAngle - STEER_UNIT;
+  }
+  else
+  {
+    if(inter_1_state)
+      steeringAngle = steeringAngle - STEER_UNIT;
+    else
+      steeringAngle = steeringAngle + STEER_UNIT;
+  }
+}

 void Steering()
 {
@@ -304,6 +336,9 @@
   SPI.setBitOrder(MSBFIRST);
   SPI.begin();

+  attachInterrupt(STEER_INTER_1, steer_inter_1, CHANGE);
+  attachInterrupt(STEER_INTER_2, steer_inter_2, CHANGE);
+  attachInterrupt(STEER_INTER_G, steer_inter_180, RISING);
   steer.attach(STEER_PIN);

   attachInterrupt(BRAKE_ON_PIN, brakeState, RISING);


Adds default rotation

Adds default rotation

--- iot-hexspider-esp8266.ino
+++ iot-hexspider-esp8266.ino
@@ -12,6 +12,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *****************************************************************************/
+#define HEXBUG_FULL_ROTATION 18
+
 #include "hexbug_spider.h"
 #include "backoff.h"
 #include "cli.h"


Disabled debug output, allowing for stand alone operation

--- src/Full_decoder/Full_decoder.ino
+++ src/Full_decoder/Full_decoder.ino
@@ -5,7 +5,7 @@
 without computer connected this line should be commented out.
 */
 #define DEBUG_OUTPUT
-//#undef DEBUG_OUTPUT
+#undef DEBUG_OUTPUT

 #ifdef DEBUG_OUTPUT
 #define USE_SERIAL


Motor turning demo

Motor turning demo

--- main_sketch/main_sketch.ino
+++ main_sketch/main_sketch.ino
@@ -48,13 +48,14 @@

 //WHEELS
 //left motor
-const int speedLPin = 7;    //speed pin for left motor
-const int enableLForPin = 6;   //enable left forward pin
-  const int enableLRevPin = 5;   //enable left forward pin
+const int speedL = 7;    //speed pin for left motor (ENA)
+const int enLForPin = 6;   //enable left forward pin (IN2)
+  const int enLRevPin = 5;   //enable left forward pin (IN1)
 //right motor
-const int speedR = 4;    //speed pin for right motor
-const int enRFor = 3;   //controller pin 1 for right motor
-const int enRRev = 2;   //controller pin 2 for right motor
+const int speedR = 4;    //speed pin for right motor (ENB)
+const int enRForPin = 3;   //controller pin 1 for right motor (IN4)
+const int enRRevPin = 2;   //controller pin 2 for right motor (IN3)
+const int Speed = 100; // Default speed

 int wheelTurn = 0; //Magnitude of turn, I guess could be difference of wheels
                    //(- is left and + is right and 0 is straight)
@@ -80,12 +81,12 @@
   pinMode(prRPin, INPUT);

   //Wheels
-  pinMode(enL, OUTPUT);
-  pinMode(inL1, OUTPUT);
-  pinMode(inL2, OUTPUT);
-  pinMode(enR, OUTPUT);
-  pinMode(inR1, OUTPUT);
-  pinMode(inR2, OUTPUT);
+  pinMode(speedL, OUTPUT);
+  pinMode(enLForPin, OUTPUT);
+  pinMode(enLRevPin, OUTPUT);
+  pinMode(speedR, OUTPUT);
+  pinMode(enRForPin, OUTPUT);
+  pinMode(enRRevPin, OUTPUT);

   //Serial
   Serial.begin(9600);
@@ -146,3 +147,64 @@
   //if hit line, what do?
   //How know if green?
 }
+
+void moveForward() {
+  analogWrite(speedL, Speed);
+  analogWrite(speedR, Speed);
+  digitalWrite(enLForPin, HIGH);
+  digitalWrite(enLRevPin, LOW);
+  digitalWrite(enRForPin, HIGH);
+  digitalWrite(enRRevPin, LOW);
+}
+
+void moveBackward() {
+	analogWrite(speedL, Speed);
+  analogWrite(speedR, Speed);
+  digitalWrite(enLForPin, LOW);
+  digitalWrite(enLRevPin, HIGH);
+  digitalWrite(enRForPin, LOW);
+  digitalWrite(enRRevPin, HIGH);
+}
+
+void moveRight() {
+	analogWrite(speedL, Speed);
+  analogWrite(speedR, Speed);
+  digitalWrite(enLForPin, HIGH);
+  digitalWrite(enLRevPin, LOW);
+  digitalWrite(enRForPin, LOW);
+  digitalWrite(enRRevPin, HIGH);
+}
+
+void moveLeft() {
+	analogWrite(speedL, Speed);
+  analogWrite(speedR, Speed);
+  digitalWrite(enLForPin, LOW);
+  digitalWrite(enLRevPin, HIGH);
+  digitalWrite(enRForPin, HIGH);
+  digitalWrite(enRRevPin, LOW);
+}
+
+void moveStop() {
+	digitalWrite(speedL, LOW);
+	digitalWrite(speedR, LOW);
+}
+
+void quarterRight() {
+	moveRight();
+	delay(500);
+}
+
+void quarterLeft() {
+	moveLeft();
+	delay(500);
+}
+
+void turnaroundL() {
+	moveLeft();
+	delay(1000);
+}
+
+void turnaroundR() {
+	moveRight();
+	delay(1000);
+}


working with multiple I2C buses

working with multiple I2C buses

--- utils/i2c_scanner/i2c_scanner.ino
+++ utils/i2c_scanner/i2c_scanner.ino
@@ -3,59 +3,75 @@
 //
 // see i2c discussion on  http://www.gammon.com.au/forum/?id=10896

-#include <Wire.h>
+#include "i2c_t3.h"
+
+#define BUSES 3

 void setup()
 {
-  Wire.begin();
-  Serial.begin(115200);
+    Serial.begin(115200);

-  while (!Serial); // Leonardo: wait for serial monitor
-  Serial.println(F("\nI2C Scanner"));
+    while (!Serial); // Leonardo: wait for serial monitor
+    Serial.println(F("I2C Scanner"));
+
+    for (int bus = 0; bus<BUSES; bus++)
+    {
+        Serial.print(F("Initializing bus "));
+        Serial.println(bus);
+        i2c_t3(bus).begin();
+    }
 }

 void loop()
 {
-  byte error;
-  byte address;
-  int nDevices;
+    byte error;
+    byte address;
+    int nDevices;

-  Serial.println(F("Scanning..."));
+    for (int bus = 0; bus<BUSES; bus++)
+    {
+        Serial.print(F("Scanning bus "));
+        Serial.println(bus);
+        nDevices = 0;

-  nDevices = 0;
-  for (address = 1; address < 127; address++ )
-  {
-    // The i2c_scanner uses the return value of
-    // the Write.endTransmisstion to see if
-    // a device did acknowledge to the address.
+        for (address = 1; address < 127; address++ )
+        {
+            // The i2c_scanner uses the return value of
+            // the Write.endTransmisstion to see if
+            // a device did acknowledge to the address.

-    Wire.beginTransmission(address);
-    error = Wire.endTransmission();
+            i2c_t3(bus).beginTransmission(address);
+            error = i2c_t3(bus).endTransmission();
+
+            if (error == 0)
+            {
+                Serial.print(F("I2C device found on bus "));
+                Serial.print(bus);
+                Serial.print(F(" at address 0x"));
+                printhex(address);

-    if (error == 0)
-    {
-      Serial.print(F("I2C device found at address 0x"));
-      printhex(address);
+                nDevices++;
+            }
+            else if (error == 4)
+            {
+                Serial.print(F("Unknow error at address 0x"));
+                printhex(address);
+            }
+        }

-      nDevices++;
+        if (nDevices == 0)
+        {
+            Serial.println(F("No I2C devices found on bus "));
+            Serial.println(bus);
+        }
+        else
+        {
+            Serial.println(F("done"));
+        }
     }
-    else if (error == 4)
-    {
-      Serial.print(F("Unknow error at address 0x"));
-      printhex(address);
-    }
-  }

-  if (nDevices == 0)
-  {
-    Serial.println(F("No I2C devices found\n"));
-  }
-  else
-  {
-    Serial.println(F("done\n"));
-  }
-
-  delay(5000); // wait 5 seconds for next scan
+    Serial.println();
+    delay(5000); // wait 5 seconds for next scan
 }

 void printhex(byte b)


Refactoring CosaBlinkThread; compressing class structure.

--- examples/Blink/CosaBlinkThread/CosaBlinkThread.ino
+++ examples/Blink/CosaBlinkThread/CosaBlinkThread.ino
@@ -35,49 +35,40 @@
 // delay period. The delay may be changed dynamically.
 class LED : public Nucleo::Thread {
 public:
+
+  // This class is a thread that periodically changes a LED delay
+  // from low to high with a given increment
+  template <uint16_t LOW, uint16_t HIGH, uint16_t INC, uint16_t PERIOD>
+  class Controller : public Nucleo::Thread {
+  public:
+    Controller(LED* led) : Thread(), m_led(led) {}
+    virtual void run()
+    {
+      for (uint16_t ms = LOW; ms < HIGH; ms += INC) {
+	m_led->set_delay(ms);
+	delay(PERIOD);
+      }
+      for (uint16_t ms = HIGH; ms > LOW; ms -= INC) {
+	m_led->set_delay(ms);
+	delay(PERIOD);
+      }
+    }
+  private:
+    LED* m_led;
+  };
+
   LED(Board::DigitalPin pin) : Thread(), m_pin(pin, 1), m_delay(200) {}
   void set_delay(uint16_t ms) { m_delay = ms; }
-  virtual void run();
+  virtual void run() { m_pin.toggle(); delay(m_delay); }
+
 private:
   OutputPin m_pin;
   uint16_t m_delay;
 };

-void
-LED::run()
-{
-  m_pin.toggle();
-  delay(m_delay);
-}
-
-// This class is a thread that periodically changes a LED delay
-// from low to high with a given increment
-template <uint16_t LOW, uint16_t HIGH, uint16_t INC, uint16_t PERIOD>
-class Controller : public Nucleo::Thread {
-public:
-  Controller(LED* led) : Thread(), m_led(led) {}
-  virtual void run();
-private:
-  LED* m_led;
-};
-
-template <uint16_t LOW, uint16_t HIGH, uint16_t INC, uint16_t PERIOD>
-void
-Controller<LOW, HIGH, INC, PERIOD>::run()
-{
-  for (uint16_t ms = LOW; ms < HIGH; ms += INC) {
-    m_led->set_delay(ms);
-    delay(PERIOD);
-  }
-  for (uint16_t ms = HIGH; ms > LOW; ms -= INC) {
-    m_led->set_delay(ms);
-    delay(PERIOD);
-  }
-}
-
 // The instances of the LED and the Controller
 LED buildin(Board::LED);
-Controller<25,500,5,200> controller(&buildin);
+LED::Controller<25,500,5,200> controller(&buildin);

 void setup()
 {
@@ -88,10 +79,7 @@
   // Allocate the threads with given stack size
   Nucleo::Thread::begin(&buildin, 64);
   Nucleo::Thread::begin(&controller, 64);
-}

-void loop()
-{
   // Start the threads
   Nucleo::Thread::begin();
 }


fix travis build

fix travis build

--- examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino
+++ examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino
@@ -2,6 +2,7 @@
 #include <ESP8266mDNS.h>
 #include <ArduinoOTA.h>
 #include <FS.h>
+#include <Hash.h>
 #include <ESPAsyncTCP.h>
 #include <ESPAsyncWebServer.h>


v3.0.1 - updated template with _DEBUG_ and _TEST_ options

--- examples/Scheduler_template/Scheduler_template.ino
+++ examples/Scheduler_template/Scheduler_template.ino
@@ -12,6 +12,18 @@
 // #define _TASK_OO_CALLBACKS      // Support for dynamic callback method binding
 #include <TaskScheduler.h>

+// Debug and Test options
+#define _DEBUG_
+//#define _TEST_
+
+#ifdef _DEBUG_
+#define _PP(a) Serial.print(a);
+#define _PL(a) Serial.println(a);
+#else
+#define _PP(a)
+#define _PL(a)
+#endif
+

 // Scheduler
 Scheduler ts;
@@ -20,7 +32,7 @@
 void task2Callback();

 /*
-Scheduling defines:
+  Scheduling defines:
   TASK_MILLISECOND
   TASK_SECOND
   TASK_MINUTE
@@ -37,7 +49,11 @@

 void setup() {
   // put your setup code here, to run once:
-
+#if defined(_DEBUG_) || defined(_TEST_)
+  Serial.begin(115200);
+  delay(2000);
+  _PL("Scheduler Template: setup()");
+#endif
 }

 void loop() {
@@ -46,10 +62,14 @@

 void task1Callback() {
+_PP(millis());
+_PL(": task1Callback()");

 }

 void task2Callback() {
+_PP(millis());
+_PL(": task2Callb()");

 }