Change tests to use current settings instead of random

Signed-off-by: Mark Knoop <f1b5a91d4d6ad523f2610114591c007e75d15084@markknoop.com>

--- src/sketch.ino
+++ src/sketch.ino
@@ -244,72 +244,74 @@

 void test(int style) {
     if (style == 0) {
-        // random turn
-        int halfturns = random(1, 10);
-        int pitch = random(36, 72);
+        // turn
         Serial.print("halfturns ");
-        Serial.print(halfturns, DEC);
+        Serial.print(halfTurns, DEC);
         Serial.print(" pitch ");
-        Serial.print(pitch, DEC);
+        Serial.print(startPitch, DEC);
+        Serial.print(" direction ");
+        Serial.print(dir, DEC);
         Serial.print(" time ");
         unsigned long starttime = millis();
-        turn(halfturns, pitch, pitch % 2);
+        turn(halfTurns, startPitch, dir);
         Serial.println(millis() - starttime);
     } else if (style == 1) {
-        // random gliss
-        int startpitch = random(36, 72);
-        int endpitch = random(36, 72);
-        int halfturns = random(1, 10);
-        Serial.print("startpitch ");
-        Serial.print(startpitch, DEC);
+        // gliss
+        Serial.print("halfturns ");
+        Serial.print(halfTurns, DEC);
+        Serial.print(" startpitch ");
+        Serial.print(startPitch, DEC);
         Serial.print(" endpitch ");
-        Serial.print(endpitch, DEC);
-        Serial.print(" halfturns ");
-        Serial.print(halfturns, DEC);
+        Serial.print(endPitch, DEC);
+        Serial.print(" direction ");
+        Serial.print(dir, DEC);
         Serial.print(" time ");
         unsigned long starttime = millis();
-        gliss(halfturns, startpitch, endpitch, halfturns % 2);
+        gliss(halfTurns, startPitch, endPitch, dir);
         Serial.println(millis() - starttime);
     } else if (style == 2) {
-        // random timed turn
-        int halfturns = random(1, 4);
-        int duration = random(300, 5000);
+        // timed turn
         Serial.print("halfturns ");
-        Serial.print(halfturns, DEC);
+        Serial.print(halfTurns, DEC);
         Serial.print(" duration ");
         Serial.print(duration, DEC);
+        Serial.print(" direction ");
+        Serial.print(dir, DEC);
         Serial.print(" time ");
         unsigned long starttime = millis();
-        int pulse = timedturn(halfturns, duration, duration % 2);
+        int pulse = timedturn(halfTurns, duration, dir);
         Serial.print(millis() - starttime);
         Serial.print(" pulse ");
         Serial.println(pulse, DEC);
     } else if (style == 3) {
-        // random duration turn
-        int pitch = random(36, 72);
-        int duration = random(300, 5000);
-        Serial.print("pitch ");
-        Serial.print(pitch, DEC);
-        Serial.print(" duration ");
+        // duration turn
+        Serial.print("duration ");
         Serial.print(duration, DEC);
+        Serial.print(" pitch ");
+        Serial.print(startPitch, DEC);
+        Serial.print(" direction ");
+        Serial.print(dir, DEC);
+        Serial.print(" recentre ");
+        Serial.print(recentre, DEC);
         Serial.print(" time ");
         unsigned long starttime = millis();
-        durationturn(duration, pitch, duration % 2, false);
+        durationturn(duration, startPitch, dir, recentre);
         Serial.println(millis() - starttime);
     } else if (style == 4) {
-        // random duration gliss
-        int startpitch = random(36, 72);
-        int endpitch = random(36, 72);
-        int duration = random(300, 5000);
-        Serial.print("startpitch ");
-        Serial.print(startpitch, DEC);
+        // duration gliss
+        Serial.print("duration ");
+        Serial.print(duration, DEC);
+        Serial.print(" startpitch ");
+        Serial.print(startPitch, DEC);
         Serial.print(" endpitch ");
-        Serial.print(endpitch, DEC);
-        Serial.print(" duration ");
-        Serial.print(duration, DEC);
+        Serial.print(endPitch, DEC);
+        Serial.print(" direction ");
+        Serial.print(dir, DEC);
+        Serial.print(" recentre ");
+        Serial.print(recentre, DEC);
         Serial.print(" time ");
         unsigned long starttime = millis();
-        long calcdur = durationgliss(duration, startpitch, endpitch, duration % 2, false);
+        long calcdur = durationgliss(duration, startPitch, endPitch, dir, recentre);
         Serial.print(millis() - starttime);
         Serial.print(" calctime ");
         Serial.println(calcdur, DEC);


Whitespaces

Whitespaces

--- examples/CAN_read/CAN_read.ino
+++ examples/CAN_read/CAN_read.ino
@@ -10,24 +10,22 @@
   mcp2551.begin(CAN_125KBPS);
   Serial.println("------- CAN Read ----------");
   Serial.println("ID  DLC   DATA");
-
 }

 void loop() {

   if (mcp2551.readMessage(&canMsg) == MCP_CAN::ERROR_OK) {
-
+
     Serial.print(canMsg.can_id); // print ID

     Serial.print(canMsg.can_dlc); // print DLC

-    for(int i = 0; i<canMsg.can_dlc; i++)  {  // print the data
+    for (int i = 0; i<canMsg.can_dlc; i++)  {  // print the data

-        Serial.print(canMsg.data[i]);
-        Serial.print(" ");
+      Serial.print(canMsg.data[i]);
+      Serial.print(" ");

     }
-

     Serial.println();
   }


Several improvement.

Several improvement.

1. MAC address print out in hex/colon format.
2. Reuse INET print out functions.
3. Read line from request and print with uptime/request number.

--- examples/Ethernet/CosaWebServer/CosaWebServer.ino
+++ examples/Ethernet/CosaWebServer/CosaWebServer.ino
@@ -45,13 +45,6 @@
 W5100 ethernet(mac);
 Socket* sock;

-// Debugging mode; trace print
-#define NDEBUG
-#ifdef NDEBUG
-#undef TRACE
-#define TRACE(x) x
-#endif
-
 // HTML end of line
 #define CRLF "\r\n"

@@ -63,7 +56,7 @@
   setup_free_memory = free_memory();

   uart.begin(9600);
-  trace.begin(&uart, PSTR("CosaWebServer:started"));
+  trace.begin(&uart, PSTR("CosaWebServer: started"));
   Watchdog::begin();

   // Initiate ethernet controller with address
@@ -93,26 +86,19 @@
   // Bind the socket to an iostream
   IOStream page(sock);
   INET::addr_t addr;
-  char buf[32];
+  char buf[64];
   int res;

   // Get client connection information; MAC, IP address and port
   sock->get_src(addr);

   // Wait for the HTTP request
-  while ((res = sock->available()) == 0);
+  while ((res = sock->available()) == 0) Watchdog::delay(32);
   if (res < 0) goto error;
-  TRACE(sock->available());

-#ifndef NDEBUG
-  // Read request and print in debug mode. Ignore contents
-  trace << PSTR("Request#") << nr << endl;
-  while ((res = sock->recv(buf, sizeof(buf) - 1)) > 0) {
-    buf[res] = 0;
-    trace << buf;
-  }
-  trace << endl;
-#endif
+  // Read request and print contents
+  sock->gets(buf, sizeof(buf));
+  trace << uptime << ':' << nr << ':' << buf << endl;

   // Reply page; header and footer are static, contents dynamic
   static const char header[] PROGMEM =
@@ -141,18 +127,13 @@
   page << PSTR("(") << setup_free_memory << PSTR(")") << BR;
   page << PSTR("Uptime (h:m:s): ") << h << ':' << m << ':' << s << BR;
   page << PSTR("Requests: ") << nr++ << BR;
-  page << PSTR("MAC: ") << addr.mac[0];
-  for (uint8_t i = 1; i < 6; i++) page << PSTR(":") << addr.mac[i];
-  page << BR;
-  page << PSTR("IP: ") << addr.ip[0];
-  for (uint8_t i = 1; i < 4; i++) page << PSTR(".") << addr.ip[i];
-  page << BR;
-  page << PSTR("PORT: ") << addr.port << BR;
+  page << PSTR("MAC: "); INET::print_mac(page, addr.mac); page << BR;
+  page << PSTR("IP: "); INET::print_addr(page, addr.ip, addr.port); page << BR;
   page << footer;
   page << flush;

   // Disconnect the client and allow new connection requests
  error:
-  TRACE(sock->disconnect());
-  TRACE(sock->listen());
+  sock->disconnect();
+  sock->listen();
 }


Remove simulated values

Remove simulated values

--- particle-gui/firmware/setup.ino
+++ particle-gui/firmware/setup.ino
@@ -238,8 +238,8 @@
     if (statuses[0] == String("Active")) {
         // Send reading data
         String jsonSendSocketInformation = String(
-            "{ \"current\":" + String(random(300)) + // String(Irms0)
-             ",\"tension\":" + String(random(300)) + // String(voltage)
+            "{ \"current\":" + String(Irms0) + // random(300)
+             ",\"tension\":" + String(voltage) + // random(300)
              ",\"socketNum\":" + String(1) +
              ",\"apiKey\": \"" + String("{{{apiKey}}}") + "\"}");

@@ -247,14 +247,14 @@
         Particle.publish("sendSocketInformation", jsonSendSocketInformation, PRIVATE);
     }

-    // Wait 2 seconds
-    delay(2000);
+    // Wait 4 seconds
+    delay(4000);

     if (statuses[1] == String("Active")) {
         // Send reading data
         String jsonSendSocketInformation = String(
-            "{ \"current\":" + String(random(300)) + // String(Irms1)
-             ",\"tension\":" + String(random(300)) + // String(voltage)
+            "{ \"current\":" + String(Irms1) + // random(300)
+             ",\"tension\":" + String(voltage) + // random(300)
              ",\"socketNum\":" + String(2) +
              ",\"apiKey\": \"" + String("{{{apiKey}}}") + "\"}");

@@ -262,8 +262,8 @@
         Particle.publish("sendSocketInformation", jsonSendSocketInformation, PRIVATE);
     }

-    // Wait 2 seconds
-    delay(2000);
+    // Wait 4 seconds
+    delay(4000);

     if (statuses[0] != String("Deleted")) {
         // Send auth data
@@ -274,8 +274,8 @@
         Particle.publish("getServerInformation", jsonGetServerInformation, PRIVATE);
     }

-    // Wait 2 seconds
-    delay(2000);
+    // Wait 4 seconds
+    delay(4000);

     if (statuses[1] != String("Deleted")) {
         // Send auth data
@@ -287,8 +287,8 @@

     }

-    // Wait 2 seconds
-    delay(2000);
+    // Wait 4 seconds
+    delay(4000);

 /* SEND AND GET INFORMATION FROM SERVER - END */
 }


adjust SLEEP_DELAY to changed name

adjust SLEEP_DELAY to changed name

--- examples/SerialWithDeepSleepDelay/SerialWithDeepSleepDelay.ino
+++ examples/SerialWithDeepSleepDelay/SerialWithDeepSleepDelay.ino
@@ -1,8 +1,8 @@

 // show the awake times of the CPU on output LED_BUILTIN
 #define AWAKE_INDICATION_PIN LED_BUILTIN
-// delay deep sleep by 100 milli seconds to allow finishing serial write
-#define DEEP_SLEEP_DELAY 100
+// delay sleep by 100 milli seconds to allow finishing serial write
+#define SLEEP_DELAY 100
 #include <DeepSleepScheduler.h>

 void printMillis() {


extra check for frequencies exceeding the maximum valid one

--- examples/CaroloCar/CaroloCar.ino
+++ examples/CaroloCar/CaroloCar.ino
@@ -281,7 +281,7 @@
       throttleSignalStart = 0; //initialize the starting point of the measurement, so we do not go in here again, while the pulse is low
       throttleSignalPending = true; //signal loop() that there is a signal to handle
       qualityControl = qualityControl << 1;
-      if (throttleSignalFreq < MIN_OVERRIDE_FREQ) { //since we are using an analog RC receiver, there is a lot of noise, usually under the frequency of 900
+      if ((throttleSignalFreq < MIN_OVERRIDE_FREQ)  || (throttleSignalFreq > MAX_OVERRIDE_FREQ)) { //since we are using an analog RC receiver, there is a lot of noise, usually under the frequency of 900 or over 2000
         qualityControl |= 0; //put a 0 bit in the end of qualityControl byte
       } else { //this means that is a valid looking signal
         qualityControl |= 1; //put a 1 bit in the end of qualityControl byte


Removed some serial output to make Jason's life easier communicating to the arduino from the ODroid

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -74,7 +74,7 @@
   if (adk.isReady()) adk.write(len, (uint8_t*)str);

   // Copy string to debugging console.
-  Serial.print("-> ");
+  //Serial.print("-> ");
   Serial.print(str);
 }

@@ -223,13 +223,13 @@
   platypus::init();

   // Print header indicating that board successfully initialized
-  Serial.println(F("------------------------------"));
+  /*Serial.println(F("------------------------------"));
   Serial.println(companyName);
   Serial.println(url);
   Serial.println(accessoryName);
   Serial.println(versionNumber);
   Serial.println(F("------------------------------"));
-
+  */
   // Turn LED off
   // TODO: Investigate how this gets turned on in the first place
   rgb_led.set(0, 0, 0);
@@ -489,7 +489,7 @@
     debug_buffer[debug_buffer_idx] = '\0';
     debug_buffer_idx = 0;

-    Serial.println(debug_buffer);
+    //Serial.println(debug_buffer);
     if (strcmp(debug_buffer, "DOc") == 0){
       platypus::sensors[1]->calibrate(1);
     } else if (strcmp(debug_buffer, "DOc0") == 0){


signing test

signing test

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -91,7 +91,6 @@

     warnGPS();
 #endif
-

     logln("Done. System ready.");


numReadings 10 to 5

numReadings 10 to 5

--- _03-hx711-scale-v2-battery-external-Interrupt-02/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
+++ _03-hx711-scale-v2-battery-external-Interrupt-02/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
@@ -59,7 +59,7 @@
 // respond to the input.  Using a constant rather than a normal variable lets
 // use this value to determine the size of the readings array.

-const int numReadings = 10;
+const int numReadings = 5;

 int readings[numReadings];      // the readings from the analog input
 int indexof = 0;                // the indexof of the current reading
@@ -83,7 +83,7 @@
   pinMode(espResetPin, OUTPUT);

   digitalWrite(espnemoIsOnPadPin, LOW);
-  digitalWrite(espResetPin, LOW);
+  digitalWrite(espResetPin, HIGH);
   digitalWrite(ledPowerPin, HIGH);

   startMills = millis();
@@ -98,11 +98,11 @@

   attachInterrupt(0, WakeUp, CHANGE);

-  for (int thisReading = 0; thisReading < numReadings; thisReading++)
+  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
     readings[thisReading] = 0 ;
+  }

   sleepNow();
-

 }

@@ -151,11 +151,11 @@

   Serial.print("======> checking pad :  ");
   delay(500);
-  Serial.println(millis() - startMills);
+  Serial.print(millis() - startMills);

   Measured = int( scale.get_units(3) * 1000 );

-  Serial.print("======> weight : ");
+  Serial.print(" ====> weight : ");
   Serial.print(Measured);
   Serial.print(" ==> ");
   Serial.println(millis() - startMills);
@@ -163,7 +163,6 @@
   if ( Measured > 500 )
   {
     Serial.println("======> tilting detected, nemo is on pad");
-
     /*
     digitalWrite(espnemoIsOnPadPin, HIGH);
     espReset();
@@ -179,19 +178,18 @@
 void loop()
 {

-  Serial.print("======> checking weight :  ");
-  Serial.println(millis() - startMills);
+  //Serial.print("=====> checking weight :  ");
+  //Serial.println(millis() - startMills);

   Measured = int( scale.get_units(5) * 1000 );

-  Serial.print("======> weight : ");
+  Serial.print("==> weight : ");
   Serial.print(Measured);
   Serial.print(" ==> ");
-  Serial.println(millis() - startMills);
-
-  if ( Measured > 500 )
-  {
-    Serial.println("======> nemo is on pad now");
+
+  if (( Measured > 500 ) && ( Measured > (average - 200)) )
+  {
+    // Serial.println("======> nemo is on pad now");

     total = total - readings[indexof];
     readings[indexof] = Measured;
@@ -203,20 +201,23 @@

     average = total / numReadings;

-    Serial.print("======> average : ");
-    Serial.print(average);
-    Serial.print(" ==> ");
-    Serial.println(millis() - startMills);
+    Serial.print("  average ==>  ");
+    Serial.println(average);

   } else {
-    Serial.println("======> nemo is not on pad now");
+    if ( Attempt == 1) {
+      Serial.println("");
+      Serial.print("============> nemo is not on pad now");
+    }
+    Serial.println("");
     Attempt++;
   }

-  if ((( average > 3000 ) && ( Measured < 500) ) && ( IsEspReseted == LOW ))
+  if ((( average > 1000 ) && ( Measured < 500) ) && ( IsEspReseted == LOW ))
   {
     VccValue = vcc.Read_Volts() * 1000 ;
-    Serial.print("======> VCC ");
+    Serial.println("");
+    Serial.print("==========> VCC ");
     Serial.println(VccValue);
     digitalWrite(espnemoIsOnPadPin, HIGH);
     espReset();
@@ -237,7 +238,7 @@
     sleepNow();
   }

-  if ( MeasuredIsSent == HIGH )
+  if (( MeasuredIsSent == HIGH ) && ( Attempt == 1))
   {
     Serial.println("======> I2C msg has sent");
   }
@@ -245,7 +246,7 @@
   if (( MeasuredIsSent == HIGH) && ( mqttMsgSent == HIGH ))
   {
     Serial.println("======> mqtt msg has sent");
-    sleepNow();
+    sleepNow();
   }

   delay(500);
@@ -279,9 +280,9 @@
   int x = Wire.read();    // receive byte as an integer
   Serial.println(x);         // print the integer
   if ( x == 1 ) {
-     mqttMsgSent = HIGH;
-  }
-}
-
-
-
+    mqttMsgSent = HIGH;
+  }
+}
+
+
+


pid and param tuning

pid and param tuning

--- scr_arduino/scr_arduino.ino
+++ scr_arduino/scr_arduino.ino
@@ -20,10 +20,10 @@
 #include <SoftwareSerial.h>

 // Encoder Pins and Variables
-#define LEFT_ENCODER_A_PIN 2
-#define LEFT_ENCODER_B_PIN 4
-#define RIGHT_ENCODER_A_PIN 3
-#define RIGHT_ENCODER_B_PIN 5
+#define LEFT_ENCODER_A_PIN 3
+#define LEFT_ENCODER_B_PIN 5
+#define RIGHT_ENCODER_A_PIN 2
+#define RIGHT_ENCODER_B_PIN 4
 #define TICKS_PER_REVOLUTION 3200
 #define PI 3.141592654

@@ -65,7 +65,6 @@
 Encoder L_DCMotorEncoder(LEFT_ENCODER_A_PIN, LEFT_ENCODER_B_PIN);
 Encoder R_DCMotorEncoder(RIGHT_ENCODER_A_PIN, RIGHT_ENCODER_B_PIN);

-Timer g_TimerEncoder;
 float L_EncoderVelocity = 0; // Radians per second
 long L_LastEncoderValue = 0;
 double L_EncoderDelta = 0;
@@ -74,7 +73,7 @@
 long R_LastEncoderValue = 0;
 double R_EncoderDelta = 0;
 double R_LastEncoderDelta = 0;
-double beta = .90;  // Low Pass Parameter for encoder velocity
+double beta = .50;  // Low Pass Parameter for encoder velocity

 // Speed Controller Initialization
 double L_PIDout = 0;
@@ -84,17 +83,17 @@
 PID L_DCMotorPID(&L_WheelVelocity,
                  &L_PIDout,
                  &lw_cmd_spd,
-                 0.15,
-                 0.00,
-                 0.010,
+                 0.50,
+                 0.004,
+                 0.0320,
                  REVERSE);

 PID R_DCMotorPID(&R_WheelVelocity,
                  &R_PIDout,
                  &rw_cmd_spd,
-                 0.15,
-                 0.00,
-                 0.010,
+                 0.50,
+                 0.004,
+                 0.0320,
                  REVERSE);

 int mode = 0;


Update RS485_UnoR3_Slave.ino

Update RS485_UnoR3_Slave.ino

--- rs485/RS485_UnoR3_Slave.ino
+++ rs485/RS485_UnoR3_Slave.ino
@@ -42,24 +42,22 @@

   modbus_update();
   holdingRegs[ADC_VAL] = analogRead(A0);
-  sensorValue = holdingRegs[PWM_VAL];
+
+ digitalWrite(LED, HIGH);
+ delay(holdingRegs[PWM_VAL]);
+ digitalWrite(LED, LOW);
+ delay(holdingRegs[PWM_VAL]);
+
+
+ lcd.setCursor(0, 1);
+ lcd.print(holdingRegs[PWM_VAL]);
+ lcd.print("  ");
+ lcd.setCursor(5, 1);
+ lcd.print(holdingRegs[PWM_VAL]>>2);
+ lcd.print("  ");
+ lcd.setCursor(10, 1);
+ lcd.print(holdingRegs[PWM_VAL]>>4);
+ lcd.print("  ");

-  outputValue = map(sensorValue, 0, 1023, 0, 255);
-
- if ( holdingRegs[PWM_VAL] > 600)
- {digitalWrite(LED, HIGH);
- delay(250);
- digitalWrite(LED, LOW);
- delay(250);
- }
-
- else {digitalWrite(LED, HIGH);}
-
-lcd.setCursor(0, 1);
-lcd.print(outputValue);
-lcd.setCursor(5, 1);
-lcd.print(holdingRegs[PWM_VAL]>>4);
-lcd.setCursor(10, 1);
-lcd.print(holdingRegs[PWM_VAL]);

 }


deleted old file

deleted old file

--- src-arduino/arduair-mega-wifi-shield-noClock-allSensors/arduair-mega-wifi-shield-noClock-allSensors.ino
+++ src-arduino/arduair-mega-wifi-shield-noClock-allSensors/arduair-mega-wifi-shield-noClock-allSensors.ino
@@ -1,334 +0,0 @@
-//TODO: delete this file
-//libraries...
-#include "Wire.h"      //for I2C communication
-#include "DHT.h"       //for dht sensor
-#include <SPI.h>       //for Serial communication (with the SD card)
-#include <SD.h>        //SD card Library
-#include <SFE_BMP180.h>//Sparkfun BMP180 pressure Sensor Library
-#include <WiFi.h>      //wifi-shield library
-#include <SparkFunTSL2561.h>//light sensor library SparkFun TSL2561 Breakout
-#include <Wire.h>
-
-
-#define DS1307_ADDRESS 0x68 //clock pin
-#define DHTPIN 7            //DHT pin
-#define DHTTYPE DHT11
-#define server "arduair.herokuapp.com/test/"    // website address
-
-File myFile;//Defining one file  class
-
-char ssid[] = "yourNetwork"; //  your network SSID (name)
-char pass[] = "secretPassword";    // your network password (use for WPA, or use as key for WEP)
-String device,password;
-int timezone;
-int status = WL_IDLE_STATUS;
-
-WiFiClient client;
-float pm10,pm25;
-
-DHT dht(DHTPIN, DHTTYPE); //DHT constructor
-SFE_BMP180 bmp;           //bmp constructor
-SFE_TSL2561 light;        //TSL2561 constructor
-bool zeAvailable=true;
-unsigned long zeCo,zeNO2,zeSO2; //ze sensors serial port
-unsigned int zeCounter;// Ze counter of meausures
-
-void setup() {
-  Serial.begin(9600);
-  Serial1.begin(9600); //ZE CO-sensor
-  Serial2.begin(9600); //ZE NO2-sensor
-  Serial3.begin(9600); //ZE SO2-sensor
-  Wire.begin();
-  dht.begin();
-  bmp.begin();
-  light.begin();
-  //sdBegin();
-  wifiBegin();
-}
-
-void loop() {
-  Serial.print("LOOP");
-}
-
-void wifiBegin(){
-  while (status != WL_CONNECTED) {
-    Serial.print("Attempting to connect to SSID: ");
-    Serial.println(ssid);
-    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
-    status = WiFi.begin(ssid, pass);
-
-    // wait 10 seconds for connection:
-    delay(10000);
-  }
-  Serial.println("Connected to wifi");
-}
-
-void simple_request(int h,int t,float p,float l,float co,float so2,float no2){
-  // close any connection before send a new request.
-  // This will free the socket on the WiFi shield
-   client.stop();
-
-  // if there's a successful connection:
-  if (client.connect(server, 80)) {
-    Serial.println("connecting...");
-
-    //String getRequest ="GET"+"hola"+" "
-    // send the HTTP GET request:
-    client.print("GET "); client.print("/"); client.print(device); client.print("/"); client.print(password); client.print("/timezone"); client.print(" HTTP/1.1");
-    client.println("");
-    // parameters:
-    client.print("?z="); client.print(timezone); client.print(",");
-    client.print("h="); client.print(h); client.print(",");
-    client.print("t="); client.print(t); client.print(",");
-    client.print("l="); client.print(l); client.print(",");
-    client.print("co="); client.print(pm10); client.print(",");
-    client.print("o3="); client.print(pm10); client.print(",");
-    client.print("pm10="); client.print(pm10); client.print(",");
-    client.print("pm25="); client.print(pm25); client.print(",");
-    client.print("so2="); client.print(so2); client.print(",");
-    client.print("no2="); client.print(no2); client.print(",");
-    client.println("");
-    //server
-    client.print("Host: ");client.print(server);
-    client.println("User-Agent: Arduair");
-    client.println("Connection: close");
-    client.println();
-  }
- }
-void tableWrite(){
-  //escribe en la SD, la tabla
-
-  myFile = SD.open("DATA.txt", FILE_WRITE); //abrir la SD
-  if (myFile){
-
-    int   h = dht.readHumidity();  // 1* medir humedad
-    int   t = dht.readTemperature();// 2* medir temperatura
-    float p = readPressure();       // 3* medir presion
-    float co= mq7Read();            // 4* medir sensor 1 y transformar
-    float so2=zeso2Read();
-    float no2=zeno2Read();
-    pmRead();
-
-    myFile.print(h);
-    myFile.print(",");
-    myFile.print(t);
-    myFile.print(",");
-    myFile.print(p);
-    myFile.print(",");
-    myFile.print(co);
-    myFile.print(",");
-    myFile.print(so2);
-    myFile.print(",");
-    myFile.print(no2);
-    myFile.print(",");
-
-    myFile.println(" ");
-    myFile.close();
-  }
-}
-/*//////////////////////////////////////////////////////////////////
-MQ-7 CO sensor
-//////////////////////////////////////////////////////////////////*/
-float mq7Read(){
-  int sensorValue = analogRead(0);       // read analog input pin 0
-  Serial.println(sensorValue, DEC);  // prints the value read
-  delay(100);// wait 100ms for next reading
-
-  float finalValue =sensorValue;
-  return finalValue;
-}
-/*//////////////////////////////////////////////////////////////////
-SD card begin
-//////////////////////////////////////////////////////////////////*/
-void sdBegin(){
-  if (!SD.begin(4)) {
-    //Serial.println("SD failed!");
-    return;
-  }
-  //Serial.println("SD done.");
-}
-/*//////////////////////////////////////////////////////////////////
-MQ-131 O3 low concentration sensor
-//////////////////////////////////////////////////////////////////*/
-float mq131Read(){
-  int sensorValue = analogRead(0);       // read analog input pin 0
-  Serial.println(sensorValue, DEC);  // prints the value read
-  delay(100);// wait 100ms for next reading
-
-  float finalValue =sensorValue;
-  return finalValue;
-}
-/*//////////////////////////////////////////////////////////////////
-ZE03-SO2 winsen sensor
-//////////////////////////////////////////////////////////////////*/
-float zeso2Read(){
-  float c= zeSO2/zeCounter;
-  zeSO2=0;
-  return c;
-}
-
-void serialEvent1(){
-  if (zeAvailable==true){
-    String input;
-    while (Serial1.available()){
-      char inChar = (char)Serial.read();
-      input += inChar;
-      if (input.length()==8){
-        zeSO2=(input[2]*256+input[3])*0.1;
-      }
-    }
-  }
-}
-/*//////////////////////////////////////////////////////////////////
-ZE03-no2 winsen sensor
-//////////////////////////////////////////////////////////////////*/
-float zeno2Read(){
-
-}
-/*//////////////////////////////////////////////////////////////////
-ZE03-co winsen sensor
-//////////////////////////////////////////////////////////////////*/
-float ze03_co(){
-
-}
-/*//////////////////////////////////////////////////////////////////
-SparkFun Luminosity Sensor Breakout - TSL2561
-//////////////////////////////////////////////////////////////////*/
-float lightRead(){
-  boolean gain;     // Gain setting, 0 = X1, 1 = X16;
-  unsigned int ms;  // Integration ("shutter") time in milliseconds
-  unsigned char time = 2;
-  light.setTiming(gain,time,ms);
-  light.setPowerUp();
-  delay(ms);
-  unsigned int data0, data1;
-
-  if (light.getData(data0,data1))
-  {
-    // getData() returned true, communication was successful
-
-    Serial.print("data0: ");
-    Serial.print(data0);
-    Serial.print(" data1: ");
-    Serial.print(data1);
-
-    // To calculate lux, pass all your settings and readings
-    // to the getLux() function.
-
-    // The getLux() function will return 1 if the calculation
-    // was successful, or 0 if one or both of the sensors was
-    // saturated (too much light). If this happens, you can
-    // reduce the integration time and/or gain.
-    // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor
-
-    double lux;    // Resulting lux value
-    boolean good;  // True if neither sensor is saturated
-
-    // Perform lux calculation:
-
-    good = light.getLux(gain,ms,data0,data1,lux);
-
-    // Print out the results:
-
-    Serial.print(" lux: ");
-    Serial.print(lux);
-    if (good) Serial.println(" (good)"); else Serial.println(" (BAD)");
-  }
-}
-/*//////////////////////////////////////////////////////////////////
-Shinyei PPD42: dust sensor
-based on dustduino project
-//////////////////////////////////////////////////////////////////*/
-float pmRead(){
-  unsigned long starttime;
-
-  unsigned long triggerOnP10, triggerOffP10, pulseLengthP10, durationP10;
-  boolean P10 = HIGH, triggerP10 = false;
-  unsigned long triggerOnP25, triggerOffP25, pulseLengthP25, durationP25;
-  boolean P25 = HIGH, triggerP25 = false;
-  float ratioP10 = 0, ratioP25 = 0;
-  unsigned long sampletime = 30000;
-  float countP10, countP25;
-
-  while((millis()-starttime)<sampletime){
-    P10 = digitalRead(9);
-    P25 = digitalRead(8);
-    if(P10 == LOW && triggerP10 == false){
-      triggerP10 = true;
-      triggerOnP10 = micros();
-    }
-    if (P10 == HIGH && triggerP10 == true){
-        triggerOffP10 = micros();
-        pulseLengthP10 = triggerOffP10 - triggerOnP10;
-        durationP10 = durationP10 + pulseLengthP10;
-        triggerP10 = false;
-    }
-    if(P25 == LOW && triggerP25 == false){
-      triggerP25 = true;
-      triggerOnP25 = micros();
-    }
-    if (P25 == HIGH && triggerP25 == true){
-      triggerOffP25 = micros();
-      pulseLengthP25 = triggerOffP25 - triggerOnP25;
-      durationP25 = durationP25 + pulseLengthP25;
-      triggerP25 = false;
-    }
-  }
-  ratioP10 = durationP10/(sampletime*10.0);  // Integer percentage 0=>100
-  ratioP25 = durationP25/(sampletime*10.0);
-  countP10 = 1.1*pow(ratioP10,3)-3.8*pow(ratioP10,2)+520*ratioP10+0.62;
-  countP25 = 1.1*pow(ratioP25,3)-3.8*pow(ratioP25,2)+520*ratioP25+0.62;
-  float PM10count = countP10; ////confirmmm!!!
-  float PM25count = countP25 - countP10;
-
-  // first, PM10 count to mass concentration conversion
-  double r10 = 2.6*pow(10,-6);
-  double pi = 3.14159;
-  double vol10 = (4/3)*pi*pow(r10,3);
-  double density = 1.65*pow(10,12);
-  double mass10 = density*vol10;
-  double K = 3531.5;
-  pm10 = (PM10count)*K*mass10;
-
-  // next, PM2.5 count to mass concentration conversion
-  double r25 = 0.44*pow(10,-6);
-  double vol25 = (4/3)*pi*pow(r25,3);
-  double mass25 = density*vol25;
-  pm25 = (PM25count)*K*mass25;
-}
-/*//////////////////////////////////////////////////////////////////
- BMP180 Pressure Sensor
-//////////////////////////////////////////////////////////////////*/
-float readPressure(){
- char state;
- double T,P,p0,a;
-  // Loop here getting pressure readings every 10 seconds.
-  state = bmp.startTemperature();
-  if (state != 0)
-  {
-    delay(state);
-    state = bmp.getTemperature(T);
-    if (state != 0)
-    {
-      state = bmp.startPressure(3);
-      if (state != 0)
-      {
-        delay(state);
-        state = bmp.getPressure(P,T);
-        if (state != 0)
-        {
-          // Print out the measurement:
-          //Serial.print("absolute pressure: ");
-          Serial.print(P*0.750061561303,2);
-          //Serial.println(" mmHg");
-
-          return P;
-        }
-        //else Serial.println("error retrieving pressure measurement\n");
-      }
-      //else Serial.println("error starting pressure measurement\n");
-    }
-    //else Serial.println("error retrieving temperature measurement\n");
-  }
-  //else Serial.println("error starting temperature measurement\n");
-}


added minimum FFT sum to control light cutoff and more colors

--- super_freq.ino
+++ super_freq.ino
@@ -1,6 +1,6 @@
 #define LIN_OUT 1 // use the log output function
 #define FFT_N 128 // set number of FFT points
-#define DEBUG 1   // set to 1 to turn on Serial printing
+#define DEBUG 0   // set to 1 to turn on Serial printing

 #include <math.h>
 #include <FFT.h>
@@ -14,6 +14,17 @@
 float SAMPLE_RATE = 9600.0;
 int SKIP_MULT = 4;
 int MAX_FFT_BIN = 16383;
+
+/*
+ * used to cut the lights,
+ * some sources (iPhone) have amps that create a bit of noise that
+ * remains on for a few seconds even after music is stopped or paused.
+ * Perhaps this doesn't occur on mixers, and it may be possible to
+ * eliminate with an OpAmp and/or low pass filter circuit
+ */
+int MIN_FFT_SUM = 3200;
+
+// LEDeez
 int brightness;  // controls the LED brightness based on dB level
 // LEDs can be set up to 127, but it seems too bright so we tone it down a bit
 int MAX_BRIGHTNESS = 95;
@@ -119,7 +130,7 @@
     frequency = (peak_index * (SAMPLE_RATE / SKIP_MULT)) / (FFT_N / 4);
     brightness = round(1.0 * MAX_BRIGHTNESS * sum_fft / MAX_FFT_BIN);

-    if (max_value < 80 || sum_fft < 3000 || peak_index == 0) {
+    if (max_value < 80 || sum_fft < MIN_FFT_SUM || peak_index == 0) {
         // signal too weak or we got the 1st peak (0Hz), no lights
         setColor(strip.Color(0, 0, 0));
     } else if (frequency > 0 && frequency < base_freak * 2) {
@@ -142,7 +153,31 @@
         // blue
         setColor(strip.Color(0, 0, brightness));
     }
-    else if (frequency >= base_freak * 6 && frequency < SAMPLE_RATE/4) {
+    else if (frequency >= base_freak * 6 && frequency < base_freak * 8) {
+        // violence!!!
+        setColor(strip.Color(brightness, 0, brightness));
+    // we'll cycle through the colors again so all high freaks ain't purple!!!
+    } else if (frequency > 8 && frequency < base_freak * 10) {
+        // red
+        setColor(strip.Color(brightness, 0, 0));
+    }
+    else if (frequency >= base_freak * 10 && frequency < (base_freak * 12)) {
+        // yellow
+        setColor(strip.Color(brightness, brightness, 0));
+    }
+    else if (frequency >= base_freak * 12 && frequency < (base_freak * 14)) {
+        // green
+        setColor(strip.Color(0, brightness, 0));
+    }
+    else if (frequency >= base_freak * 14 && frequency < base_freak * 16) {
+        // cyan
+        setColor(strip.Color(0, brightness, brightness));
+    }
+    else if (frequency >= base_freak * 16 && frequency < base_freak * 18) {
+        // blue
+        setColor(strip.Color(0, 0, brightness));
+    }
+    else if (frequency >= base_freak * 18 && frequency < SAMPLE_RATE/SKIP_MULT) {
         // violence!!!
         setColor(strip.Color(brightness, 0, brightness));
     }


Alterado diametro da roda e quantidade de pulsos por volta

--- Arduino/telemetriaSerialSIMPLIFICADA/telemetriaSerialSIMPLIFICADA.ino
+++ Arduino/telemetriaSerialSIMPLIFICADA/telemetriaSerialSIMPLIFICADA.ino
@@ -46,8 +46,8 @@

 void setup() {
-  cfg.raioRoda = 0.255;
-  cfg.qtdPulsos = 4;
+  cfg.raioRoda = 0.261;
+  cfg.qtdPulsos = 8;
   cfg.intervaloLeitura = 100;

   Serial.begin(9600);


Added missing include needed for Arduino IDE

--- libraries/ESP8266WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino
+++ libraries/ESP8266WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino
@@ -31,6 +31,7 @@
 /* Create a WiFi access point and provide a web server on it. */

 #include <ESP8266WiFi.h>
+#include <WiFiClient.h>
 #include <ESP8266WebServer.h>

 /* Set these to your desired credentials. */


Update 1_RGBPongClock.ino

Update 1_RGBPongClock.ino

--- firmware/examples/1_RGBPongClock.ino
+++ firmware/examples/1_RGBPongClock.ino
@@ -114,11 +114,11 @@

 /***** Weather webhook definitions *****/
-#define HOOK_RESP		"hook-response/pmk_w3"
-#define HOOK_PUB		"pmk_w3"
+#define HOOK_RESP	"hook-response/hook event name"	// specify your hook event name here
+#define HOOK_PUB	"hook event name"		// and here
 #define DEFAULT_CITY	"\"mycity\":\"Ottawa,ON\""	// Change to desired default city,state
-#define API_KEY			"\"apikey\":\"62810bbd5419f1ff67f8f61588833bf6\""
-#define UNITS			"\"units\":\"metric\""		// Change to "imperial" for farenheit units
+#define API_KEY		"\"apikey\":\"xxxxxxxxxxxxxxx\""// Add your API key here
+#define UNITS		"\"units\":\"metric\""		// Change to "imperial" for farenheit units
 /***************************************/

 /***** Create RGBmatrix Panel instance *****


Remove unused include in example

Remove unused include in example

--- examples/FirebaseCloudMessaging_Send_ESP8266/FirebaseCloudMessaging_Send_ESP8266.ino
+++ examples/FirebaseCloudMessaging_Send_ESP8266/FirebaseCloudMessaging_Send_ESP8266.ino
@@ -20,7 +20,6 @@
 #include <ESP8266WiFi.h>

 #include <FirebaseCloudMessaging.h>
-#include <FirebaseHttpClient.h>

 // Set these to run example.
 #define WIFI_SSID "SSID"


Fix FirstLight default pin

Fix FirstLight default pin

--- examples/FirstLight/FirstLight.ino
+++ examples/FirstLight/FirstLight.ino
@@ -15,7 +15,7 @@
 #define NUM_LEDS 60

 // Data pin that led data will be written out over
-#define DATA_PIN 23
+#define DATA_PIN 3

 // Clock pin only needed for SPI based chipsets when not using hardware SPI
 //#define CLOCK_PIN 8
@@ -32,7 +32,7 @@
       // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
-      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
+      FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
@@ -40,7 +40,7 @@
       // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
-      FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
+      // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);

       // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
       // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);


We don't need 2-bytes for a pin number.

We don't need 2-bytes for a pin number.

Also, use the friendly type names.

Sketch size is now 27874 bytes.

--- wee_printer.ino
+++ wee_printer.ino
@@ -15,9 +15,9 @@
 #define debug2(a, b)
 #endif

-const int errorLED = 5;
-const int downloadLED = 6;
-const int readyLED = 7;
+const byte errorLED = 5;
+const byte downloadLED = 6;
+const byte readyLED = 7;

 void initDiagnosticLEDs() {
   pinMode(errorLED, OUTPUT);
@@ -32,16 +32,16 @@
   digitalWrite(readyLED, LOW);
 }

-const int printer_RX_Pin = 2;  // this is the green wire
-const int printer_TX_Pin = 3;  // this is the yellow wire
+const byte printer_RX_Pin = 2;  // this is the green wire
+const byte printer_TX_Pin = 3;  // this is the yellow wire
 Thermal printer(printer_RX_Pin, printer_TX_Pin);
-const int postPrintFeed = 3;
+const byte postPrintFeed = 3;

 void initPrinter() {
   printer.begin(150);
 }

-const int SD_Pin = 4;
+const byte SD_Pin = 4;
 void initSD() {
   pinMode(SD_Pin, OUTPUT);
   SD.begin(SD_Pin);
@@ -76,15 +76,15 @@
 // const char* host = "192.168.1.67"; // lazyatom
 // const char* host = "178.79.132.137"; // interblah
 const char* host = "wee-printer.gofreerange.com";
-const uint16_t port = 80;
+const unsigned int port = 80;
 const char *path = "/printer/1";

 boolean downloadWaiting = false;
 char* cacheFilename = "TMP";

 void checkForDownload() {
-  uint32_t length = 0;
-  uint32_t content_length = 0;
+  unsigned long length = 0;
+  unsigned long content_length = 0;

   if (SD.exists(cacheFilename)) SD.remove(cacheFilename);
   File cache = SD.open(cacheFilename, FILE_WRITE);
@@ -146,7 +146,7 @@
     }
   } else {
     debug("Couldn't connect");
-    for(int i=0; i < 10; i++) {
+    for(byte i=0; i < 10; i++) {
       digitalWrite(errorLED, HIGH);
       delay(100);
       digitalWrite(errorLED, LOW);
@@ -162,7 +162,7 @@
   cache.close();
 }

-const int buttonPin = 8;
+const byte buttonPin = 8;
 Bounce bouncer = Bounce(buttonPin, 5); // 5 millisecond debounce
 unsigned long pollingDelay = 10000; // 1 minute


lisätty älyä

lisätty älyä

--- realworld-test-codes/first_steps/first_steps.ino
+++ realworld-test-codes/first_steps/first_steps.ino
@@ -1,67 +1,152 @@
 // Using single ultrasound distance sensor;
 // Go forward and stay stile when there's an obstacle in front.
 int E1 = 4;
-int M1 = 5;
+int vasenM1 = 5; //vasen
 int E2 = 7;
-int M2 = 6;
-int trigPin = 13;
-int echoPin = 12;
+int oikeaM2 = 6; //oikea

-int motorVal;
-int distance;
+int frontTrigPin = 13;
+int frontEchoPin = 12;
+
+int leftTrigPin = 11;
+int leftEchoPin = 10;
+
+int rightTrigPin = 9;
+int rightEchoPin = 8;
+
+int motorValRight;
+int motorValLeft;
+int distanceFront;
+int distanceLeft;
+int distanceRight;
+int initialSpeed = 255;
+int maxSpeed = 255;
+int turnSpeed = 255;
+
+int distanceToStop = 20;
+
+
+int turningSteps = 0; // plus arvot on oikea käännös ja minus on vasen käännös
+int defaultTurningSteps = 8;

 void setup()
 {
   // Motor shield
   // http://www.dfrobot.com/wiki/index.php?title=Arduino_Motor_Shield_(L298N)_(SKU:DRI0009)
-  pinMode(M1, OUTPUT);
-  pinMode(M2, OUTPUT);
+  pinMode(vasenM1, OUTPUT);
+  pinMode(oikeaM2, OUTPUT);

   // Distance sensor
   // http://www.micropik.com/PDF/HCSR04.pdf
   Serial.begin (9600);
-  pinMode(trigPin, OUTPUT);
-  pinMode(echoPin, INPUT);
-  motorVal = 255;
+  pinMode(frontTrigPin, OUTPUT);
+  pinMode(frontEchoPin, INPUT);
+  pinMode(leftTrigPin, OUTPUT);
+  pinMode(leftEchoPin, INPUT);
+  pinMode(rightTrigPin, OUTPUT);
+  pinMode(rightEchoPin, INPUT);
+  motorValRight = initialSpeed;
+  motorValLeft = initialSpeed;
 }

 // Calculate current distance from obstacle
-float current_distance(){
+float current_distance(int trig,int echo){
   long duration;
   float distance;

-  digitalWrite(trigPin, LOW);
+  digitalWrite(trig, LOW);
   delayMicroseconds(2);
-  digitalWrite(trigPin, HIGH);
+  digitalWrite(trig, HIGH);
   delayMicroseconds(10);
-  digitalWrite(trigPin, LOW);
-  duration = pulseIn(echoPin, HIGH);
+  digitalWrite(trig, LOW);
+  duration = pulseIn(echo, HIGH);
   distance = (duration/2.0) / 29.1;

   return distance;
 }

-void loop()
-{
-  distance = current_distance();
-
-  if (distance < 30){
-    motorVal = 0;
-  } else {
-    motorVal = 255;
-  }
-
-  delay(100);
-
+void nextMove() {
+
   digitalWrite(E1, LOW);
   digitalWrite(E2, LOW);

-  analogWrite(M1, motorVal);
-  analogWrite(M2, motorVal);
+  analogWrite(vasenM1, motorValRight);
+  analogWrite(oikeaM2, motorValLeft);

-  Serial.print("Distance: ");
-  Serial.print(distance);
-  Serial.print(" cm - ");
-  Serial.print("setting motorVal to ");
-  Serial.println(motorVal);
+  Serial.print("Left: ");
+  Serial.print(motorValLeft);
+  Serial.print("Right: ");
+  Serial.println(motorValRight);
 }
+
+void printLog() {
+
+  Serial.print("Front: ");
+  Serial.print( distanceFront);
+  Serial.print(" Left: ");
+  Serial.print(distanceLeft);
+  Serial.print(" Right: ");
+  Serial.println(distanceRight);
+}
+
+void updateDistance() {
+  distanceFront = current_distance(frontTrigPin,frontEchoPin);
+  distanceLeft = current_distance(leftTrigPin,leftEchoPin);
+  distanceRight = current_distance(rightTrigPin,rightEchoPin);
+
+  printLog();
+}
+
+void processTurn () {
+  if(turningSteps > 0 ){
+     turningSteps--;
+     motorValLeft = turnSpeed;
+  }
+  else {
+     turningSteps++;
+     motorValRight = turnSpeed;
+  }
+
+}
+
+void process(){
+
+  if(turningSteps != 0) {
+    processTurn();
+    return;
+  }
+
+  if (distanceFront < distanceToStop){
+    motorValRight = 0;
+    motorValLeft = 0;
+    if(distanceRight > 30) {
+      // turn right
+      turningSteps = defaultTurningSteps;
+    }
+    else if (distanceLeft > 30) {
+      // turn left
+      turningSteps = -defaultTurningSteps;
+    }
+    else {
+      // advance a lil forward
+      motorValLeft = 255;
+      motorValRight = 255;
+    }
+
+  } else {
+    motorValLeft = maxSpeed;
+    motorValRight = maxSpeed;
+  }
+}
+
+void loop()
+{
+  updateDistance();
+
+  process();
+
+  nextMove();
+
+  delay(250);
+}
+


Update Firmware.ino

Update Firmware.ino

--- src/piggy_back_loggers/SD_prototype_Firmware/Firmware/Firmware.ino
+++ src/piggy_back_loggers/SD_prototype_Firmware/Firmware/Firmware.ino
@@ -91,6 +91,7 @@
   * ButtonCheck: Is the button pressed?
   * If button is pressed (active-low):
   *   Set serialOn flag.
+  *   call serialPowerUp()
   \*****************************************/
   if((digitalRead(5) == 0) && !State.serialOn)
   {


removing redundant (and incorrect) time check from readTemperatureAndHumidity()

--- DHTBLESensor.ino
+++ DHTBLESensor.ino
@@ -113,7 +113,8 @@
   myBLE.addAttribute(bleTemperatureC);

   // Initialize our BLE Characteristics
-  readTemperatureAndHumidity();
+  whenSensedMs = millis();
+  (void) readTemperatureAndHumidity();
   setBLETemperatureAndHumidity(dht22.temperature, dht22.humidity);

   // Because of Curie startup, no serial output will be seen until the loop.
@@ -135,8 +136,10 @@
     while (central.connected()) {  //XXX Not a good idea because connecting hangs all other Arduino functions (like reset and download)
       long nowMs = millis();
       if ((long)(nowMs - whenSensedMs) >= TEMPERATURE_UPDATE_INTERVAL_MS) {
-        readTemperatureAndHumidity();
-        setBLETemperatureAndHumidity(dht22.temperature, dht22.humidity);
+        whenSensedMs = nowMs;
+        if (readTemperatureAndHumidity()) {
+          setBLETemperatureAndHumidity(dht22.temperature, dht22.humidity);
+        }
       }
     }
     // Disconnected
@@ -153,18 +156,12 @@
    updating the corresponding global variables and
    the time of the reading.

-   If not enough time has passed since the last reading,
-   the sensor will not be read and the values will not be changed.
+   Returns true if the sensor responded correctly; false if an error occurred.
 */
-void readTemperatureAndHumidity() {
-  long nowMs = millis();
-  if (nowMs - whenSensedMs < TEMPERATURE_UPDATE_INTERVAL_MS) {
-    return;   // not ready to be read yet.
-  }
-  whenSensedMs = nowMs;
-
-  int result = dht22.read22(DHT22_DATA);
-
+boolean readTemperatureAndHumidity() {
+  int result;
+
+  result = dht22.read22(DHT22_DATA);
   if (result != DHTLIB_OK) {
     if (result == DHTLIB_ERROR_TIMEOUT) {
       Serial.println("Timeout waiting for DHT22");
@@ -173,10 +170,11 @@
     } else {
       Serial.println("Unknown failure from DHT22");
     }
-    return; // try again later.
+    return false; // try again later.
   }

   // Cached results are now available in dht22.humidity and dht22.temperature
+  return true;
 }

 /*


change notifications to serial monitor

change notifications to serial monitor

--- Lifter/Lifter.ino
+++ Lifter/Lifter.ino
@@ -253,7 +253,6 @@
     if (currentServoPos == (drop + extraServoBump)) {
         restServoPos = drop;
         stressedServo = true;
-
     }
     else if (currentServoPos == (suck - extraServoBump)) {
         restServoPos = suck;
@@ -278,7 +277,9 @@
   else if (stressedServo && ((currentTime - timeStart) > 900)) {
     myserv.write(restServoPos);
     if (DEBUG)
-      Serial.println("de-stressed to position: " + String(restServoPos));
+      Serial.println("go to resting spot: " + String(restServoPos));
+    Serial.println("READY")
+    Serial.println("at " + String(
   }
 }


encoder update

encoder update

--- src/arduino_sketchbook/Motor_test_ros.ino
+++ src/arduino_sketchbook/Motor_test_ros.ino
@@ -11,7 +11,6 @@
 #include <std_msgs/Empty.h>
 #include <std_msgs/Int32.h>

-
 Adafruit_MotorShield AFMS = Adafruit_MotorShield();
 Adafruit_DCMotor *myMotor1 = AFMS.getMotor(1);

@@ -23,8 +22,34 @@
   vel = msg.data;
 }
 void BWD1(){
-  encoder1_msg.data++;
+  // look for a low-to-high on channel A
+  if (digitalRead(19) == HIGH) {
+    // check channel B to see which way encoder is turning
+    if (digitalRead(18) == HIGH) {
+      encoder1_msg.data--;         // CW
+    }
+    else {
+      //encoder1_msg.data--;         // CCW
+    }
+  }
+
 }
+
+void BWD2(){
+  // look for a low-to-high on channel A
+  if (digitalRead(18) == HIGH) {
+    // check channel B to see which way encoder is turning
+    if (digitalRead(19) == HIGH) {
+      encoder1_msg.data++;         // CW
+    }
+    else {
+      //encoder1_msg.data--;         // CCW
+    }
+  }
+
+}
+
+

 ros::Subscriber<std_msgs::Float32> sub_vel1("/motor1_vel", &motor1VelCallBack);

@@ -41,7 +66,11 @@
   //Mega2560
   // external interrupt int.0    int.1    int.2   int.3   int.4   int.5
   // pin                  2         3      21      20      19      18
+  pinMode(19, INPUT);
+  pinMode(18, INPUT);
+
   attachInterrupt(4, BWD1, CHANGE); // Also LOW, RISING, FALLING
+  attachInterrupt(5, BWD2, CHANGE); // Also LOW, RISING, FALLING

   AFMS.begin(); // create with the default frequency 1.6KHz
   //AFMS.begin(1000); // OR with a different frequency, say 1KHz


changed power command to always off

changed power command to always off

--- IRBiasLight.ino
+++ IRBiasLight.ino
@@ -26,6 +26,8 @@
 #define POWER		0xE0E016E9	//Remote Enter/OK
 #define RAINBOW		0xE0E024DB	//Remote Sleep

+
+//Amount to step values by on each remote press
 #define BRIGHT_STEP 15
 #define COLOR_STEP 5

@@ -160,7 +162,7 @@

 inline void power()
 {
-	powerOn = !powerOn;
+	powerOn = false;
 	updateLEDs();
 }


Fixed blink example

Fixed blink example

--- examples/timedBlink/timedBlink.ino
+++ examples/timedBlink/timedBlink.ino
@@ -20,12 +20,8 @@
 // the state of the pin, we will toggle it.
 int ledOn = LOW;

-// create a task manager to look after our tasks
-TaskManager taskManager;
-
 // create an IO abstraction, so later we could put the led on a shift register or i2c.
 IoAbstractionRef ioDevice = ioUsingArduino();
-

 void setup() {
 	// set the pin we are to use as output using the io abstraction


Fix bug with lower moisture with sd sketch.

--- ARTF_Sensors/examples/LowPowerMoistureWithSD/LowPowerMoistureWithSD.ino
+++ ARTF_Sensors/examples/LowPowerMoistureWithSD/LowPowerMoistureWithSD.ino
@@ -8,8 +8,8 @@
   help verify similar calculations used in MoistureSensorGSM
   sketch. The results are written to the SD card

-  Created 10 7 2014
-  Modified 10 7 2014
+  Created 11 7 2014
+  Modified 11 7 2014
 */
 #include <LowPower.h>

@@ -29,7 +29,7 @@

 // SD Card Settings
 const byte SD_CS_PIN = 10;
-#define OUTPUT_FILENAME "ultra.txt"
+#define OUTPUT_FILENAME "veg.txt"

 ARTF_SDCard sd(SD_CS_PIN);
@@ -56,7 +56,7 @@
   delay(3000);

   // Take X readings
-  int moistureReadings[NUM_READINGS];
+  double moistureReadings[NUM_READINGS];
   for (int i = 0; i < NUM_READINGS; ++i)
   {
     int reading = analogRead(MOISTURE_PIN);


sped up heartbeat

sped up heartbeat

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -52,7 +52,7 @@
 			Serial.write(END_CHAR);
 		}

-		redBeat(10);
+		redBeat(1);
 		//colorWipe(LED.Color(127, 0, 0), 0);
 	}

@@ -180,4 +180,4 @@
 		LED.show();
 		delay(wait);
 	}
-}+}


After each seek recalculate the seek lock threshold. When returning from band scan set channel to users saved channel.

--- src/rx5808-pro-diversity/rx5808-pro-diversity.ino
+++ src/rx5808-pro-diversity/rx5808-pro-diversity.ino
@@ -99,6 +99,7 @@
 uint8_t diversity_mode = useReceiverAuto;
 char diversity_check_count = 0;
 #endif
+uint8_t rssi_seek_threshold = RSSI_SEEK_TRESHOLD;
 uint8_t hight = 0;
 uint8_t state = START_STATE;
 uint8_t state_last_used=START_STATE;
@@ -111,7 +112,6 @@
 uint8_t seek_direction=1;
 unsigned long time_of_tune = 0;        // will store last time when tuner was changed
 unsigned long time_screen_saver = 0;
-uint8_t last_maker_pos=0;
 uint8_t last_active_channel=0;
 uint8_t first_channel_marker=1;
 uint8_t update_frequency_view=0;
@@ -415,6 +415,8 @@
                 drawScreen.bandScanMode(state);
             break;
             case STATE_SEEK: // seek mode
+                rssi_seek_threshold = RSSI_SEEK_TRESHOLD;
+                rssi_best=RSSI_MIN_VAL;
             case STATE_MANUAL: // manual mode
                 state_last_used=state;
                 if (state == STATE_MANUAL)
@@ -426,6 +428,11 @@
                     time_screen_saver=0; // dont show screen saver until we found a channel.
                 }
                 drawScreen.seekMode(state);
+
+                // return user to their saved channel after bandscan
+                if(state_last_used == STATE_SCAN || state_last_used == STATE_RSSI_SETUP) {
+                    channelIndex=EEPROM.read(EEPROM_ADR_TUNE);
+                }

                 first_channel_marker=1;
                 update_frequency_view=1;
@@ -587,23 +594,15 @@
         // show signal strength
         wait_rssi_ready();
         rssi = readRSSI();
+        rssi_best = (rssi > rssi_best) ? rssi : rssi_best;
         channel=channel_from_index(channelIndex); // get 0...40 index depending of current channel
-
-        if(channel < CHANNEL_MAX_INDEX)
-        {
-            last_maker_pos=channel;
-        }
-        else
-        {
-          //  No action on last position to keep frame intact
-        }

         // handling for seek mode after screen and RSSI has been fully processed
         if(state == STATE_SEEK) //
         { // SEEK MODE
             if(!seek_found) // search if not found
             {
-                if ((!force_seek) && (rssi > RSSI_SEEK_TRESHOLD)) // check for found channel
+                if ((!force_seek) && (rssi > rssi_seek_threshold)) // check for found channel
                 {
                     seek_found=1;
                     time_screen_saver=millis();
@@ -619,12 +618,17 @@
                     channel+=seek_direction;
                     if (channel > CHANNEL_MAX)
                     {
+                        // calculate next pass new seek threshold
+                        rssi_seek_threshold = (int)((float)rssi_best * (float)(RSSI_SEEK_TRESHOLD/100.0));
                         channel=CHANNEL_MIN;
                     }
                     else if(channel < CHANNEL_MIN)
                     {
+                        // calculate next pass new seek threshold
+                        rssi_seek_threshold = (int)((float)rssi_best * (float)(RSSI_SEEK_TRESHOLD/100.0));
                         channel=CHANNEL_MAX;
                     }
+                    rssi_seek_threshold = rssi_seek_threshold < 5 ? 5 : rssi_seek_threshold; // make sure we are not stopping on everyting
                     channelIndex = pgm_read_byte_near(channelList + channel);
                 }
             }
@@ -665,15 +669,7 @@
             setChannelModule(channelIndex);
             last_channel_index=channelIndex;
         }
-        // channel marker
-        if(channel < CHANNEL_MAX_INDEX)
-        {
-            last_maker_pos=channel;
-        }
-        else
-        {
-          //  No action on last position to keep frame intact
-        }
+
         // print bar for spectrum
         wait_rssi_ready();
         // value must be ready


Adding ability to drop in different piles.

--- src/solitaire/solitaire.ino
+++ src/solitaire/solitaire.ino
@@ -147,6 +147,7 @@
           mode = drawingCards;
         }
         break;
+      case talon:
       case tableau1:
       case tableau2:
       case tableau3:
@@ -154,10 +155,12 @@
       case tableau5:
       case tableau6:
       case tableau7:
+        Pile* pile = getActiveLocationPile();
+        if (pile->getCardCount() == 0) break;
         moving.empty();
-        tableau[activeLocation - tableau1].removeCards(1, &moving);
-        moving.x = tableau[activeLocation - tableau1].x;
-        moving.y = tableau[activeLocation - tableau1].y + 2 * tableau[activeLocation - tableau1].getCardCount() + 2;
+        pile->removeCards(1, &moving);
+        moving.x = pile->x;
+        moving.y = pile->y + (activeLocation >= tableau1 ? 2 * pile->getCardCount() : 0);
         mode = movingPile;
         break;
     }
@@ -177,7 +180,7 @@
   }
   if (gb.buttons.pressed(BTN_DOWN)) {
     if (activeLocation == talon) activeLocation = tableau2;
-    else if (activeLocation <= foundation3) activeLocation = activeLocation + 7;
+    else if (activeLocation <= foundation4) activeLocation = activeLocation + 7;
   }
   if (gb.buttons.pressed(BTN_UP)) {
     if (activeLocation >= tableau4) activeLocation = activeLocation - 7;
@@ -185,6 +188,11 @@
   }
   if (gb.buttons.pressed(BTN_A)) {
     switch (activeLocation) {
+      case talon:
+      case foundation1:
+      case foundation2:
+      case foundation3:
+      case foundation4:
       case tableau1:
       case tableau2:
       case tableau3:
@@ -192,7 +200,7 @@
       case tableau5:
       case tableau6:
       case tableau7:
-        tableau[activeLocation - tableau1].addCard(moving.getCard(0));
+        getActiveLocationPile()->addCard(moving.getCard(0));
         mode = selecting;
         break;
     }
@@ -494,8 +502,10 @@
 void drawMovingPile() {
   drawPile(&moving);
   Pile* pile = getActiveLocationPile();
+  byte yDelta = 2;
+  if (activeLocation >= tableau1) yDelta += 2 * pile->getCardCount();
   moving.x = updatePosition(moving.x, pile->x);
-  moving.y = updatePosition(moving.y, pile->y + 2 * pile->getCardCount() + 2);
+  moving.y = updatePosition(moving.y, pile->y + yDelta);
 }

 Pile* getActiveLocationPile() {


fix arduino code

fix arduino code

--- src/projector/projector.ino
+++ src/projector/projector.ino
@@ -54,7 +54,9 @@
 #define X_AXIS_C_PIN				(6)
 #define X_AXIS_D_PIN				(7)
 #define LASER_PIN					(8)
+#define LIGHT_PIN					(11)
 #define BUTTON_PIN					(12)
+#define POWER_PIN					(13)
 #define Y_AXIS_A_PIN				(A0)
 #define Y_AXIS_B_PIN				(A1)
 #define Y_AXIS_C_PIN				(A2)
@@ -62,6 +64,9 @@

 #define _PINB_MASK(pin)				(1 << (pin - 8))
 #define LASER_MASK					(_PINB_MASK(LASER_PIN))
+#define LIGHT_MASK					(_PINB_MASK(LIGHT_PIN))
+#define BUTTON_MASK					(_PINB_MASK(BUTTON_PIN))
+#define POWER_MASK					(_PINB_MASK(POWER_PIN))

 // const uint8_t STEPS_MASKS[] = {0b0001, 0b0011, 0b0010, 0b0110, 0b0100, 0b1100, 0b1000, 0b1001};
 const uint8_t STEPS_MASKS[] = {0b1001, 0b1000, 0b1100, 0b0100, 0b0110, 0b0010, 0b0011, 0b0001};


Disabilitazione monitor seriale in codice Arduino. Modifica nome della funzione invio_bluetooth().

--- Smart_Green_House_codiceArduino/Smart_Green_House_codiceArduino.ino
+++ Smart_Green_House_codiceArduino/Smart_Green_House_codiceArduino.ino
@@ -76,7 +76,7 @@
 SoftwareSerial bluetooth = SoftwareSerial(rx_pin,tx_pin);       //creo un istanza in grado di definire una porta seriale virtuale utile alla comunicazione bluetooth dei dati

 void setup() {
-Serial.begin(9600);             //abilito la porta seriale (COM#) per la lettura dei dati prodotti dal sistema(posso anche eliminare se non stampo i dati sul monitor seriale)
+//Serial.begin(9600);             //abilito la porta seriale (COM#) per la lettura dei dati prodotti dal sistema(posso anche eliminare se non stampo i dati sul monitor seriale)
 dht.begin();                    //abilito la lettura dati mediante il modulo DHT
 bluetooth.begin(9600);          //abilito la comunicazione seriale virtuale, con baud 9600 bps, per interconnettermi al modulo bluetooth HC-05
 pinMode(echo,INPUT);            //abilito I/O del trasduttore a tempo di volo (echo = IN, trigger = OUT)
@@ -104,7 +104,7 @@
     selection_auto_manual();         //verifico il tipo di controllo da effettuare sull'impianto
     if(manual) manual_control();     //se manual = 1, abilito il controllo manuale tramite l'applicazione android(piloto opportunamente gli switch)
     else auto_control();             //se manual = 0, Arduino controllo autonomamente l'impianto
-    invio_BLUETOOTH();               //trasferisco, tramite bluetooth, i valori acquisiti riferiti allo stato della serra e della pianta
+    invio_bluetooth();               //trasferisco, tramite bluetooth, i valori acquisiti riferiti allo stato della serra e della pianta
    }

 //Funzione in gradi di aggiornare i parametri riferiti allo stato dell'impianto
@@ -206,7 +206,7 @@
 }

 //Funzione in grado di trasmettere, tramite una comunicazione seriale, i dati del sistema via bluetooth all'applicazione Android connessa al modulo HC-05
-void invio_BLUETOOTH(){  //invio una determinata stringa di dati che inizia per * e termina con # al fine di condificare correttamente tramite l'app l'inizio e la fine trasmissione dati
+void invio_bluetooth(){  //invio una determinata stringa di dati che inizia per * e termina con # al fine di condificare correttamente tramite l'app l'inizio e la fine trasmissione dati
   bluetooth.print("*");
   bluetooth.print(temp_aria);  //trametto il valore della temperatura dell aria
   bluetooth.print(" ");


Change prometheus format a bit

Change prometheus format a bit

--- temperature-relay.ino
+++ temperature-relay.ino
@@ -45,16 +45,17 @@
   /* server.httpSuccess(); */
   server.httpSuccess("text/plain; version=0.0.4");
   if (type != WebServer::HEAD) {
-    char s_temp[85];
-    char s_average_temp[110];
+    char s_temp[75];
+    char s_average_temp[75];
     char s_power[50];
     char s_freemem[110];
     uint32_t freemem;

     freemem = System.freeMemory();

-    snprintf(s_temp, 85,"# TYPE temp_degrees gauge\ntemp_degrees %.4f %li000\n\n", temperature, Time.now());
-    snprintf(s_average_temp, 110, "# TYPE average_temp_degrees gauge\naverage_temp_degrees %.4f %li000\n\n", minuteAverage, Time.now());
+    server << "# TYPE temp_degrees gauge\n";
+    snprintf(s_temp, 75,"temp_degrees{timespan=\"none\"} %.4f %li000\n", temperature, Time.now());
+    snprintf(s_average_temp, 75, "temp_degrees{timespan=\"minute\"} %.4f %li000\n\n", minuteAverage, Time.now());
     snprintf(s_power, 50, "# TYPE heater gauge\nheater %i %li000\n\n", power, Time.now());
     snprintf(s_freemem, 110, "# Type free_mem_bytes\nfree_mem_bytes %lu %li000\n\n", freemem, Time.now());


Added calibration for Rig 2

Added calibration for Rig 2

--- Arduino/private/ledpuff/ledpuff.ino
+++ Arduino/private/ledpuff/ledpuff.ino
@@ -6,8 +6,12 @@
 #define MAXDACUNIT 4095       // 2^12-1 (ie 12 bits)
 #define MINDACUNIT 0
 // For converstion from laser power to DAC units
-#define LASERSLOPE 27
-#define LASEROFFSET 2400
+// For laser 11140001, Rig 1
+//#define LASERSLOPE 27
+//#define LASEROFFSET 2400
+// For laser 11140002, Rig 2
+#define LASERSLOPE 36
+#define LASEROFFSET 2100
 //For devices with A0 pulled HIGH, use 0x61

 /*


Fixed calculation of uv intensity

Fixed calculation of uv intensity

--- files/template_home_wifi_feinstaub/template_home_wifi_feinstaub.ino
+++ files/template_home_wifi_feinstaub/template_home_wifi_feinstaub.ino
@@ -73,7 +73,7 @@
   sleep(1);
   if (Wire.available()) lsb = Wire.read();
   uvValue = (msb << 8) | lsb;
-  return uvValue * 5;
+  return uvValue * 5.625;
 }

 int printHexToStream(const uint8_t *data, uint8_t length, Print &stream) // prints 8-bit data in hex


better scrolling text

better scrolling text

--- CountDownToGrad/CountDownToGrad.ino
+++ CountDownToGrad/CountDownToGrad.ino
@@ -2,8 +2,8 @@
 #include <SimpleTimer.h>

 //--- SETTINGS ---
-String strTitle = " 2016 GRADUATION";         // title - must be 16 characters, add padding to front
-const String strGrad = "CONGRATS GRADS!";     // timer done message - max 16 characters
+const String strTitle = "2016 GRADUATION";    // title - must be a multiple of 16 characters
+const String strGrad = "CONGRATS GRADS!";     // timer done message - must be a multiple of 16 characters
 const int lcdPin = 2;                         // pin for LCD

 // time to count down from
@@ -25,21 +25,36 @@
 SimpleTimer myTimer;
 int timerId, timerId2, timerId3;                          // reference to clock timer, light timer, and title timer
 String strTime, strLine2;
+String strTitleDisplay = strTitle;
+String strGradDisplay = strGrad;
+boolean bTimerDone = false;

 // Configure display and timer.
 void setup() {
   pinMode(lcdPin, OUTPUT);                                // set lcdPin as output to LCD
   pinMode(onBoardLEDPin, OUTPUT);                         // set onBoardLEDPin as output to LCD
   mySerial.begin(9600);                                   // start serial
-  timerId = myTimer.setInterval(1000, modifyClock);       // update clock every 1 sec
+  mySerial.write(22);                                     // no cursor
+  timerId = myTimer.setInterval(1000, updateClock);       // update clock time every 1 sec
   timerId2 = myTimer.setInterval(500, flashLED);          // flash light every 0.5 sec
-  timerId3 = myTimer.setInterval(500, updateTitle);       // update title every 0.5 sec
+  timerId3 = myTimer.setInterval(350, updateLCD);         // update lcd every 0.35 sec
   setupTime();                                            // setup time left
   delay(100);

   // pad title string with 16 whitespaces in the front
-  for (int i = 0; i < 16; i++) {
-     strTitle = " " + strTitle;
+  int padding = strTitle.length() % 16;
+
+  // scroll left to right
+  for (int i = 0; i < padding; i++) {
+     strTitleDisplay = " " + strTitleDisplay;
+  }
+
+  // pad title string with 16 whitespaces in the front
+  padding = strGrad.length() % 16;
+
+  // scroll left to right
+  for (int i = 0; i < padding; i++) {
+     strGradDisplay = " " + strGradDisplay;
   }
 }

@@ -48,11 +63,13 @@
   myTimer.run();    // run the timer
 }

-// Modify clock display.
-void modifyClock() {
-  double s;
-
-  seconds--;  //update seconds
+// Update clock counter.
+void updateClock() {
+  if (bTimerDone) {
+   return;
+  }
+
+  seconds--;  // update seconds

   if (seconds <= 0)
   {
@@ -67,27 +84,7 @@

   if (d < 0) {
     // timer done
-    myTimer.disable(timerId);
-    myTimer.disable(timerId2);
-    myTimer.disable(timerId3);
     onTimerEnd();
-  }
-  else {
-    mySerial.write(22);                   // no cursor
-    mySerial.write(12);                   // clear
-    mySerial.println(strTitle);           // first line, display title
-    mySerial.write(148);                  // new line
-
-    int spaceCount = 16 - strTime.length() - 2;
-    String strSpace = "";
-    for (int i = 0; i < spaceCount; i++) {
-      strSpace += " ";
-    }
-
-    strLine2 = strTime + strSpace + "PK";
-
-    mySerial.print(strLine2);      // second line, display time and initials
-    Serial.println("Time: " + strTime);   // console debug
   }
 }

@@ -101,24 +98,58 @@
   }
 }

-void updateTitle() {
-  strTitle = strTitle.charAt(strTitle.length() - 1) + strTitle.substring(0, strTitle.length() - 1);
-
-  mySerial.write(22);                   // no cursor
-  mySerial.write(12);                   // clear
-  mySerial.println(strTitle);           // first line, display title
-  mySerial.write(148);                  // new line
-
-  int spaceCount = 16 - strTime.length() - 2;
-  String strSpace = "";
-  for (int i = 0; i < spaceCount; i++) {
-    strSpace += " ";
-  }
-
-  strLine2 = strTime + strSpace + "PK";
-
-  mySerial.print(strLine2);      // second line, display time and initials
-  Serial.println("Time: " + strTime);   // console debug
+// move the cursor to a specific place
+// e.g.: cursorSet(3,2) sets the cursor to x = 3 and y = 2
+void cursorSet(int xpos, int ypos){
+  Serial.write(254);
+  Serial.write(71);
+  Serial.write(xpos);   //Column position
+  Serial.write(ypos); //Row position
+}
+
+void updateLCD() {
+  // scroll left to right
+  strTitleDisplay = strTitleDisplay.charAt(strTitleDisplay.length() - 1) + strTitleDisplay.substring(0, strTitleDisplay.length() - 1);
+
+  if (bTimerDone) {
+    strGradDisplay = strGradDisplay.charAt(strGradDisplay.length() - 1) + strGradDisplay.substring(0, strGradDisplay.length() - 1);
+  }
+
+  // first line, display title
+  if (bTimerDone) {
+     mySerial.print(strGradDisplay);       // first line, display congrats
+     mySerial.write(148);                  // new line
+
+     int spaceCount = 16 - strTime.length() - 2;
+     String strSpace = "";
+     for (int i = 0; i < spaceCount; i++) {
+       strSpace += " ";
+     }
+
+     // format DD:HH:MM:SS
+     String strD = printDigits(0, true);
+     String strH = printDigits(0, true);
+     String strM = printDigits(0, true);
+     String strS = printDigits(0, false);
+     strTime = strD+strH+strM+strS;
+
+     // second line, display time and initials
+     strLine2 = strTime + strSpace + "PK";
+     mySerial.print(strLine2);
+     Serial.println("Time: " + strTime);   // console debug
+  } else {
+     mySerial.println(strTitleDisplay);
+     int spaceCount = 16 - strTime.length() - 2;
+     String strSpace = "";
+     for (int i = 0; i < spaceCount; i++) {
+       strSpace += " ";
+     }
+
+     // second line, display time and initials
+     strLine2 = strTime + strSpace + "PK";
+     mySerial.print(strLine2);
+     Serial.println("Time: " + strTime);   // console debug
+  }
 }

 // Get time left in DD:HH:MM:SS format.
@@ -135,11 +166,12 @@
   m -= h * 60;

   // format DD:HH:MM:SS
-  String strD = printDigits(daysLeft, true);
-  String strH = printDigits(h, true);
-  String strM = printDigits(m, true);
-  String strS = printDigits((int)s, false);
-  return strD+strH+strM+strS;
+  return formateClockTime(daysLeft, h, m, s);
+}
+
+// format DD:HH:MM:SS
+String formateClockTime(int days, int hours, int minutes, int seconds) {
+  return printDigits(days, true) + printDigits(hours, true) + printDigits(minutes, true) + printDigits(seconds, false);
 }

 /*
@@ -164,11 +196,10 @@
 // Timer is done.
 void onTimerEnd()
 {
-  mySerial.write(12);                   // clear
-  mySerial.println(strTitle);           // first line, display title
-  mySerial.write(148);                  // new line
-  mySerial.print(strGrad);              // second line, display congrats
-  Serial.println("Timer done!");        // console debug
+    // disable timers
+    myTimer.disable(timerId2);
+    mySerial.write(12);                   // clear
+    bTimerDone = true;
 }

 // Setup time to count.


.small fix

.small fix

--- V0p2_Main/V0p2_Main.ino
+++ V0p2_Main/V0p2_Main.ino
@@ -151,7 +151,7 @@
   '/',
   __DATE__[0], __DATE__[1], __DATE__[2],
   '/',
-  __DATE__[4], __DATE__[5],
+  ((' ' == __DATE__[4]) ? '0' : __DATE__[4]), __DATE__[5],
   '\0'
   };
 // Version (code/board) information printed as one line to serial (with line-end, and flushed); machine- and human- parseable.
@@ -160,7 +160,7 @@
   {
   OTV0P2BASE::serialPrintAndFlush(F("board V0.2 REV"));
   OTV0P2BASE::serialPrintAndFlush(V0p2_REV);
-  OTV0P2BASE::serialPrintAndFlush(F(" "));
+  OTV0P2BASE::serialPrintAndFlush(' ');
   OTV0P2BASE::serialPrintAndFlush(_YYYYMmmDD);
   OTV0P2BASE::serialPrintlnAndFlush(F(" " __TIME__));
   }


Fix signature of callback function in subscriber example

--- examples/mqtt_subscriber/mqtt_subscriber.ino
+++ examples/mqtt_subscriber/mqtt_subscriber.ino
@@ -14,7 +14,7 @@
 // Update these with values suitable for your network.
 IPAddress server(172, 16, 0, 2);

-void callback(MQTT::Publish& pub) {
+void callback(const MQTT::Publish& pub) {
   Serial.print(pub.topic());
   Serial.print(" => ");
   Serial.print(pub.payload_string());


--- esp8266_160220_BYOP.ino
+++ esp8266_160220_BYOP.ino
@@ -7,6 +7,7 @@

 /*
  * v0.11 2016 Feb 20
+ *  - display "ready" on 8x2 LCD just after power on
  *  - add [esp8266_160217_AQM0802.ino] to display characters on 8x2 LCD
  * v0.10 2016 Feb 20
  *  - fix proc_bye() to use nickName
@@ -45,7 +46,7 @@
  *  - add serial setup
  */

-
+#include <Wire.h> // for 8x2 LCD
 #include "dataStructure.h"

 //-------------------------------------------------------------------------
@@ -70,6 +71,12 @@

 void setup() {
   Serial.begin(115200);
+  Wire.begin();
+  AQM0802_Initialize(/* cursorOn=*/true, /* cursorPosOn=*/true, /* contrast=*/7);
+//  Test_AQM0802_cursorOn_posOff_contrastLow();
+//  Test_AQM0802_cursorOn_posOn_contrastLow();
+//  Test_AQM0802_cursorOn_posOn_contrastHigh();
+  AQM0802_PutMessage("ready", /* x_st1=*/1, /* y_st1=*/1);
 }

 void loop() {


Update mq3_shield.ino

Update mq3_shield.ino

--- arduino_code/mq3_shield/mq3_shield.ino
+++ arduino_code/mq3_shield/mq3_shield.ino
@@ -1,3 +1,7 @@
+/* Author: Pietro Pennestri'
+mail: pietro.pennestri@gmail.co
+ver: 3.65
+*/
 #include <LiquidCrystal.h>
 #include <OneSheeld.h>
 #include <GPSShield.h>


cleanup

cleanup

--- src/esp-soil-moisture-sensor-v2.1/esp-soil-moisture-sensor-v2.1.ino
+++ src/esp-soil-moisture-sensor-v2.1/esp-soil-moisture-sensor-v2.1.ino
@@ -72,8 +72,8 @@
   Serial.println(temp);
   delay(5000);

-  //sendData(temp, soil_hum);
-  //ESP.deepSleep(SLEEP_TIME, WAKE_RF_DEFAULT);
+  sendData(temp, soil_hum);
+  ESP.deepSleep(SLEEP_TIME, WAKE_RF_DEFAULT);
 }

 void connectWifi()
@@ -144,8 +144,8 @@
        client.print("\n\n");
        client.print(postStr);
        delay(1000);
+   }

-   }//end if
    sent++;
    client.stop();
-}//end send
+}


add mux0temp1 for ambient temp sensing per drawer string

--- examples/Habitat_Temps/Habitat_Temps.ino
+++ examples/Habitat_Temps/Habitat_Temps.ino
@@ -49,6 +49,7 @@
 TMP102 on board SALT has same address as TMP275 0 so don't use that
 */

+Systronix_TMP275 Mux0Temp1(TMP275_SLAVE_ADDR_1);  // D1 ambient temp
 Systronix_TMP275 Mux0Temp2(TMP275_SLAVE_ADDR_2);  // D1 C1 outside
 Systronix_TMP275 Mux0Temp3(TMP275_SLAVE_ADDR_3);  // D1 C1 inside
 Systronix_TMP275 Mux0Temp4(TMP275_SLAVE_ADDR_4);
@@ -328,6 +329,23 @@
   temp = Mux0Temp2.raw12_to_f(rawtemp);
   Serial.printf ("Mux0Temp2 %6.4f F\r\n", temp);

+  // ------------------------------
+  // Init Mux0Temp1 Sensors
+  stat = Mux0Temp1.init(TMP275_CFG_RES12);
+  if (SUCCESS != stat) Serial.printf(" Mux0Temp1 init failed with return of 0x%.2X: %s\r\n", Mux0Temp1.error.ret_val);
+
+  // leave the pointer set to read temperature
+  stat = Mux0Temp1.pointerWrite(TMP275_TEMP_REG_PTR);
+  if (SUCCESS != stat) Serial.printf(" Mux0Temp1 ptr write failed with return of 0x%.2X: %s\r\n", Mux0Temp1.error.ret_val);
+
+  // Read Temp on Mux0Temp1
+  rawtemp=0;
+  temp=0.0;
+  stat = Mux0Temp1.register16Read (&rawtemp);
+  if (stat != SUCCESS) Serial.printf("Mux0Temp1 error, stat=%u\r\n", stat);
+  temp = Mux0Temp1.raw12_to_f(rawtemp);
+  Serial.printf ("Mux0Temp1 %6.4f F\r\n", temp);
+

   Serial.println();


added missing #include <JeeLib.h>

added missing #include <JeeLib.h>

--- examples/Ports/isp_repair/isp_repair.ino
+++ examples/Ports/isp_repair/isp_repair.ino
@@ -34,6 +34,7 @@

 #include <avr/pgmspace.h>
 #include <avr/sleep.h>
+#include <JeeLib.h>

 #define OPTIBOOT    1   // 1 = OptiBoot, 0 = Duemilanove boot loader


High five!

High five!

--- Ws2811Rings/Ws2811Rings.ino
+++ Ws2811Rings/Ws2811Rings.ino
@@ -14,9 +14,9 @@
 #include "chasers.h"

 rgb Green = {20, 0, 0};
-rgb Yellow= {10,10, 0};
-rgb Red	  = { 0,10, 0};
-rgb Blue  = { 0, 0,05};
+rgb Yellow= {15,15, 0};
+rgb Red	  = { 0,15, 0};
+rgb Blue  = { 0, 0,15};

 rgb buffer[] =
  {
@@ -52,12 +52,12 @@
 	DDRB = _BV(3);

 	RingSet rings(buffer, 15);
-	const uint8_t chaserCount = 1;
+	const uint8_t chaserCount = 4;
 	Chaser chasers[chaserCount] = {
-		Chaser(1, 2, false, Green),/*
-		Chaser(1, 0, Yellow),
-		Chaser(2, 0, Red),
-		Chaser(3, 0, Blue)*/
+		Chaser(0, 0, true, Green),
+		Chaser(1, 0, false, Yellow),
+		Chaser(2, 9, true, Red),
+		Chaser(3, 4, true, Blue)
 	};

 	ChasePattern chasePattern(&rings, chasers, chaserCount);
@@ -87,7 +87,7 @@
 		chasePattern.Logic();
 		chasePattern.Render();

-		_delay_ms(50);
+		_delay_ms(30);

 		// Update the display twice, because sending once seems to miss the first pixel
 		// and I dno't have time to figure out why.


[TheMatrix/LedTest] play with pixel addressing

--- BoldportClub/TheMatrix/LedTest/LedTest.ino
+++ BoldportClub/TheMatrix/LedTest/LedTest.ino
@@ -2,27 +2,27 @@

   TheMatrix/LedTest
   This example tests all connected LEDs.
+
+  Based on LedTest.ino from the LRAS1130 library examples.

   For info and circuit diagrams see https://github.com/tardate/LittleArduinoProjects/tree/master/BoldportClub/TheMatrix/LedTest

  */

 #include <Wire.h>
-#include "LRAS1130.h"
-
-/// @example LedTest.ino
-/// This example tests all connected LEDs.
+#include <LRAS1130.h>

 using namespace lr;
 AS1130 ledDriver;

+AS1130Picture24x5 picture;

 void setup() {
   // Initialize the Wire library.
   Wire.begin();

   // Initialize the serial port.
-  Serial.begin(9600);
+  Serial.begin(115200);

   // Wait until the chip is ready.
   delay(100);
@@ -46,11 +46,17 @@
   // Enable the chip
   ledDriver.startChip();

-  // Check for dead LEDs
-  Serial.println(F("Run the LED test"));
+  runLedTest();
+}
+
+void loop() {
+  runPixelTest();
+}
+
+void runLedTest() {
+  Serial.println(F("Testing the status of all LEDs"));
   ledDriver.runManualTest();

-  // Display the status of all leds.
   for (uint8_t ledIndex = 0x00; ledIndex < 0xbb; ++ledIndex) {
     Serial.print(F("LED 0x"));
     Serial.print(ledIndex, HEX);
@@ -69,6 +75,16 @@
   }
 }

-
-void loop() {
-}+void runPixelTest() {
+  Serial.println(F("Visual inspection one LED at a time..."));
+  for(uint8_t speed=0; speed<5; speed++) {
+    for(uint8_t x=0; x<24; x++) {
+      for(uint8_t y=0; y<5; y++) {
+        picture.setPixel(x, y, true);
+        ledDriver.setOnOffFrame(0, picture);
+        picture.setPixel(x, y, false);
+        delay(50 + 20 * speed);
+      }
+    }
+  }
+}


using arrays for follower

using arrays for follower

--- Helios.ino
+++ Helios.ino
@@ -7,6 +7,10 @@
 int green = 245;
 int blue = 60;
 int randRed, randGreen, randBlue, randPix;
+int colorVals[11][3];
+int pos=0;
+int pos1=0;
+int incNum = 1;

 // Parameter 1 = number of pixels in strip
 // Parameter 2 = Arduino pin number (most are valid)
@@ -81,16 +85,23 @@
       int green_ = percentage * g;
       int blue_ = percentage * b;
       //strip.setPixelColor(a, strip.Color(red,green,blue));
+      if(a <=11) {
+        colorVals[pos][0] = red_;
+        colorVals[pos][1] = green_;
+        colorVals[pos][2] = blue_;
+      }
+      else {
+        strip.setPixelColor(((strip.numPixels() - 1) - a - 11), strip.Color((colorVals[pos1][0] + incNum), (colorVals[pos1][1] + incNum), (colorVals[pos1][2] + incNum)));
+      }
       strip.setPixelColor(((strip.numPixels() - 1) - a), strip.Color(red_,green_,blue_));
       strip.show();
       delay(5);
     }
+    pos++;
+    pos1++;
  //   delay(wait);
   }
-  Serial.println((int)(.8*245));
-  Serial.println((int)(.8*245));
-  Serial.println((int)(.8*60));
-  Serial.println(splitColor(strip.getPixelColor(15), 'b'));
+  /*
   for(int k = 0; k < strip.numPixels(); k++) {
     for(int g = 10; g <= 100; g+=30) {
       double percentage = (double)g/100;
@@ -98,11 +109,6 @@
       int red_ = percentage * red;
       int green_ = percentage * green;
       int blue_ = percentage * blue;
-      Serial.println(red_);
-      Serial.println(green_);
-      Serial.println(blue_);
-      Serial.println("-----------------------------------------------------");
-      Serial.println();
     //  delay(1000);
       strip.setPixelColor(((strip.numPixels()-1) - k), strip.Color(red_,green_,blue_));
       strip.show();
@@ -110,6 +116,7 @@
     }
     //delay(wait);
   }
+  */
 }

 void powerOff() {


TX on pin 13 RX on pin 8

TX on pin 13
RX on pin 8

LED on TX, save pin 9 for PWM (3,5,6,9,10,11)

--- dummycomm.ino
+++ dummycomm.ino
@@ -6,8 +6,7 @@

 #include <Servo.h>

-#define LED 13
-#define BTX 9
+#define BTX 13
 #define BRX 8
 #define SRV 7
 #define CARRIER 2
@@ -21,7 +20,6 @@
 Servo servo;

 void setup() {
-	pinMode(LED, OUTPUT);
 	pinMode(BTX, OUTPUT);
 	pinMode(BRX, INPUT);
 	servo.attach(SRV);
@@ -136,9 +134,7 @@
 		while((frame = getFrame(BRX)) >= CARRIER) {
 			if (frame == NOFRAME) {
 				if (Serial.available() > 0) {
-					digitalWrite(LED, HIGH);
 					frame = Serial.parseInt();
-					digitalWrite(LED, LOW);
 					return frame;
 				}
 			}


Update GAC.ino

Update GAC.ino

--- GAC/GAC.ino
+++ GAC/GAC.ino
@@ -1,22 +1,5 @@
-/*
-  SD card datalogger
-
- This example shows how to log data from three analog sensors
- to an SD card using the SD library.
-
- The circuit:
- * SD card attached to SPI bus as follows:
- ** MOSI - pin 11
- ** MISO - pin 12
- ** CLK - pin 13
- ** CS - pin 10
-
- */
-
 #include <SPI.h>
-#include <SD.h>
 #include <Wire.h>
-#include "RTClib.h"
 #include <Adafruit_RGBLCDShield.h>
 #include <utility/Adafruit_MCP23017.h>
 Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
@@ -29,20 +12,12 @@
 #define WHITE 0x7
 const int chipSelect = 10;

-unsigned long LOG_INTERVAL = 25000;
+unsigned long LOG_INTERVAL = 15000;
 unsigned long previousMillis = 0;

 // The analog pins that connect to the sensors
 #define PressureAnalog A0      // analog 1

-// define the Real Time Clock object
-RTC_PCF8523 RTC;
-
-char sensordata[30];                //we make a 48 byte character array to hold incoming data from the Flow Meter Totalizer.
-char sensordatajunk[30];
-byte received_from_computer=0;     //we need to know how many characters have been received.
-byte sensor_bytes_received=0;       //we need to know how many characters have been received.
-byte string_received=0;            //used to identify when we have received a string from the Flow Meter Totalizer.
 float f;
 char *flotot;

@@ -52,21 +27,6 @@

 void setup() {
     lcd.begin(16, 2);
-  /* if (! rtc.begin()) {
-    lcd.print("Couldn't find RTC");
-    while (1);
-  }
-
-  if (rtc.lostPower()) {
-    lcd.print("RTC lost power, lets set the time!");
-    // following line sets the RTC to the date & time this sketch was compiled
-    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
-    // This line sets the RTC with an explicit date & time, for example to set
-    // January 21, 2014 at 3am you would call:
-    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
-  }
-  // Print a message to the LCD. We track how long it takes since
-  // this library has been optimized a bit and we're proud of it :)*/
   lcd.print("start!");
   lcd.setBacklight(WHITE);
   delay(5000);
@@ -75,28 +35,17 @@
   // Open serial communications and wait for port to open:

   Serial.begin(9600);
-  /*while (!Serial) {
-    ; // wait for serial port to connect. Needed for native USB port only
-  }
-  Serial.print("Initializing SD card...");
-  // see if the card is present and can be initialized:
-  if (!SD.begin(chipSelect)) {
-    Serial.println("Card failed, or not present");
-    // don't do anything more:
-    return;
-  }
-  Serial.println("card initialized.");
-  // connect to RTC
-  Wire.begin();  */
 }

 void loop() {
   float t=millis();
   float number= (analogRead(PressureAnalog)*.7018-52)*.868;
   PressureReadingSUM = PressureReadingSUM + number;
+  int runtime = t/1000/60;
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("GAC ");
+  lcd.print(runtime);lcd.print("min   ");
   lcd.setCursor(0,1);
   lcd.print(number);//lcd.print(PressureAnalogReading);
   lcd.setCursor(6,1);
@@ -111,57 +60,17 @@
   if (currentMillis - previousMillis >= LOG_INTERVAL) {
     previousMillis = currentMillis;

-    // create a filename
-    /*
-    DateTime now;
-    now = RTC.now();
-    int YR = now.year();
-    String YRs = String(YR,DEC);
-    int MO = now.month();
-    String MOs = String(MO,DEC);
-    int DY = now.day();
-    //int DY = now.minute();  //testing clear command
-    String DYs = String(DY,DEC);
-    String DATE = YRs + MOs + DYs;
-    String filename = DATE + ".CSV";
-  */
+    //
     //collect data
     //Average repetative current and voltage readings between sampling interval
     PressureAnalogReading = PressureReadingSUM / readingCount;
     float P = PressureAnalogReading;
     lcd.clear();
-    lcd.setCursor(0,0);
+    lcd.setCursor(0,1);
     lcd.print(P);
     delay(10000);
     Serial.println(P);
     //read total flow once per sampling interval
-
-    delay(200);
-
-    /*/ make a string for assembling the data to log:
-    String dataString = "";
-    dataString += String(now.unixtime());dataString += ",";
-    dataString += String(P);
-
-
-    // open the file. note that only one file can be open at a time,
-    // so you have to close this one before opening another.
-    File dataFile = SD.open(filename, FILE_WRITE);
-
-    // if the file is available, write to it:
-    if (dataFile) {
-      dataFile.println(dataString);
-      dataFile.close();
-      // print to the serial port too:
-      Serial.println(dataString);
-      lcd.setCursor(0,1);
-    lcd.print("it works");
-    }
-    // if the file isn't open, pop up an error:
-    else {
-      Serial.print("error opening ");Serial.print(filename);Serial.println("!");
-    }
-  */
     delay(10000);
     //reset averaging tools if interval is met
     readingCount=0;


Enhanced touch pin detect diagnostic - Provide error report if detection failed - Revised detection method

--- examples/arduino/diag_ard_touch_detect/diag_ard_touch_detect.ino
+++ examples/arduino/diag_ard_touch_detect/diag_ard_touch_detect.ino
@@ -40,6 +40,7 @@
   // Import MCUFRIEND to support ID reporting
   #include <MCUFRIEND_kbv.h>
   extern MCUFRIEND_kbv m_disp;
+  int m_nMcuFriendId = -1;
 #endif

 #define MAX_STR             30
@@ -58,6 +59,7 @@
 char m_acTxt[MAX_STR];
 gslc_tsRect m_rStatus = (gslc_tsRect) { 40, 60, 50, 10 };
 gslc_tsRect m_rReport = (gslc_tsRect) { 40, 80, 140, 10 };
+gslc_tsRect m_rError = (gslc_tsRect) { 40, 120, 140, 10 };
 gslc_tsFont* m_pFont = NULL;

 #define MAX_FONT                1
@@ -74,8 +76,16 @@
   gslc_DrawFillRect(&m_gui, rBack, GSLC_COL_BLACK);

   // Status
-  gslc_DrvDrawTxt(&m_gui, m_rStatus.x, m_rStatus.y, m_pFont, "Detecing Pins", GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK);
+  gslc_DrvDrawTxt(&m_gui, m_rStatus.x, m_rStatus.y, m_pFont, "Detecting Pins", GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK);
   gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y, m_pFont, "See Serial Monitor output...", GSLC_TXT_DEFAULT, GSLC_COL_GREEN, GSLC_COL_BLACK);
+}
+
+void DetectId()
+{
+  #if defined(DRV_DISP_ADAGFX_MCUFRIEND)
+  // For MCUFRIEND displays, detect the ID
+  m_nMcuFriendId = m_disp.readID();
+  #endif // DRV_DISP_ADAGFX_MCUFRIEND
 }

 bool DetectPins()
@@ -86,12 +96,7 @@
   int nPinYm = -1;

   int i, j, value, Apins[2], Dpins[2], Values[2], found = 0;
-  int nMcuFriendId = -1;
-
-  #if defined(DRV_DISP_ADAGFX_MCUFRIEND)
-    // For MCUFRIEND displays, detect the ID
-    nMcuFriendId = m_disp.readID();
-  #endif // DRV_DISP_ADAGFX_MCUFRIEND
+  bool bRet = false;

   GSLC_DEBUG_PRINT("Making all control and bus pins INPUT_PULLUP\n", "");
   GSLC_DEBUG_PRINT("Typical 30k Analog pullup with corresponding pin\n", "");
@@ -109,18 +114,20 @@
       digitalWrite(j, LOW);
       value = analogRead(i);   // ignore first reading
       value = analogRead(i);
-      if (value < 100) {
+      if (value < 100 && value > 0) {
         GSLC_DEBUG_PRINT(" Detected: (A%u, D%u) = %u\n", (i - A0), j, value);
         if (found < 2) {
           Apins[found] = i;
           Dpins[found] = j;
           Values[found] = value;
-          found++;
         }
+        found++;
       }
       pinMode(j, INPUT_PULLUP);
     }
-  }
+    pinMode(i, INPUT_PULLUP);
+  }
+
   if (found == 2) {
     if (Values[0] < Values[1]) {
       nPinXm = Apins[0];
@@ -149,7 +156,7 @@
     GSLC_DEBUG_PRINT("  // Pinout for DRV_TOUCH_SIMPLE 4-wire resistive touchscreen\n", "");
     #if defined(DRV_DISP_ADAGFX_MCUFRIEND)
       // For MCUFRIEND displays, report the ID
-      snprintf(m_acTxt, MAX_STR, "(MCUFRIEND ID=0x%04X)", nMcuFriendId);
+      snprintf(m_acTxt, MAX_STR, "(MCUFRIEND ID=0x%04X)", m_nMcuFriendId);
       GSLC_DEBUG_PRINT("  // %s\n", m_acTxt);
     #endif
     GSLC_DEBUG_PRINT("  #define ADATOUCH_PIN_YP   A%d    // \"Y+\": Must be an analog pin\n", (nPinYp - A0));
@@ -168,29 +175,41 @@
       (nPinYp != ADATOUCH_PIN_YP) || (nPinYm != ADATOUCH_PIN_YM))
     {
       GSLC_DEBUG_PRINT("MISMATCH - Please update config\n", "");
-      return false;
+      bRet = true;
     }
     else {
       GSLC_DEBUG_PRINT("OK - No need to update config\n", "");
-      return true;
-    }
-    GSLC_DEBUG_PRINT("-----------------------------------------------\n", "");
-
+      bRet = true;
+    }
   }
   else {
-    return false;
-  }
-
+    GSLC_DEBUG_PRINT("\nERROR - Touchscreen is probably broken\n", "");
+    bRet = false;
+  }
+
+  GSLC_DEBUG_PRINT("-----------------------------------------------\n\n", "");
+  return bRet;
 }

 void setup()
 {
+  bool bDetectPinsOk = false;
+
   // Initialize debug output
   Serial.begin(9600);
   gslc_InitDebug(&DebugOut);
   //delay(1000);  // NOTE: Some devices require a delay after Serial.begin() before serial port can be used

+  // Detect pins before we initialize the display driver
+  DetectId();
+  bDetectPinsOk = DetectPins();
+
+  // mcufriend displays need re-init after detect
+  #if defined(DRV_DISP_ADAGFX_MCUFRIEND)
+    m_disp.begin(m_nMcuFriendId);
+  #endif // DRV_DISP_ADAGFX_MCUFRIEND
+
   // Initialize (with no support for GUI elements)
   if (!gslc_Init(&m_gui, &m_drv, NULL, 0, m_asFont, MAX_FONT)) { return; }

@@ -201,7 +220,10 @@

   DrawBackground();

-  bool m_bDetectPinsOk = DetectPins();
+  // Alert the user visually if we failed to detect the pins
+  if (!bDetectPinsOk) {
+    gslc_DrvDrawTxt(&m_gui, m_rError.x, m_rError.y, m_pFont, "*** Broken Touchscreen ***", GSLC_TXT_DEFAULT, GSLC_COL_RED, GSLC_COL_BLACK);
+  }
 }

 void loop()


-Bump to pre-release 0.0.3.

-Bump to pre-release 0.0.3.


javance case 14

javance case 14

--- calibrateur.ino
+++ calibrateur.ino
@@ -180,9 +180,10 @@

          case 13:
              Serial.println("ICI");
-
-             //leServo.setObjectif(leServo.getMilieu()+DELTA);
-             leServo.setObjectif(1900);
+             compteur=0;
+             compteurRef=0;
+             leServo.setObjectif(leServo.getMilieu()+DELTA);
+
              sleep(TEMPOSLEEP);
              etatCalibrateur=14;
              Serial.println("la");


Fixing IsoTP PCI Index bug

Fixing IsoTP PCI Index bug

--- sketches/M2_CAN_haz_bus/M2_CAN_haz_bus.ino
+++ sketches/M2_CAN_haz_bus/M2_CAN_haz_bus.ino
@@ -34,7 +34,7 @@
 volatile uint16_t isotp_tx_index = 0;
 volatile uint16_t isotp_tx_length = 0;
 volatile uint8_t isotp_tx_go = 0;
-uint8_t isotp_tx_PCIIndex = 0;
+uint8_t isotp_tx_PCIIndex = 1;

 /* Functions for serial communication */
 void send(unsigned char *data, unsigned char cmd, unsigned char len)
@@ -351,7 +351,7 @@
             if(isotp_tx_index == isotp_tx_length)
             {
                 isotp_tx_go = 0;
-                isotp_tx_PCIIndex = 0;
+                isotp_tx_PCIIndex = 1;
                 isotp_tx_index = 0;
                 isotp_tx_length = 0;
                 if (mode != CMD_CAN_MODE_CITM)
@@ -612,7 +612,7 @@
         isotp_tx_go = 0;
         isotp_tx_index = 6;
         isotp_tx_length = serial_buf_count - 12;
-        isotp_tx_PCIIndex = 0;
+        isotp_tx_PCIIndex = 1;
         /* Copy the data from the serial buffer into the isotp buffer */
         for(uint16_t i = isotp_tx_index; i < isotp_tx_length; i++)
             isotp_tx_buffer[i] = serial_buffer[i + 12];


remove example of TimerOne

remove example of TimerOne

--- libraries/TimerOne/examples/ISRBlink/ISRBlink.ino
+++ libraries/TimerOne/examples/ISRBlink/ISRBlink.ino
@@ -1,26 +0,0 @@
-#include <TimerOne.h>
-
-void setup()
-{
-  // Initialize the digital pin as an output.
-  // Pin 13 has an LED connected on most Arduino boards
-  pinMode(13, OUTPUT);
-
-  Timer1.initialize(100000); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
-  Timer1.attachInterrupt( timerIsr ); // attach the service routine here
-}
-
-void loop()
-{
-  // Main code loop
-  // TODO: Put your regular (non-ISR) logic here
-}
-
-/// --------------------------
-/// Custom ISR Timer Routine
-/// --------------------------
-void timerIsr()
-{
-    // Toggle LED
-    digitalWrite( 13, digitalRead( 13 ) ^ 1 );
-}


check node-red msg

check node-red msg

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -16,7 +16,7 @@

 RtcDS3231 Rtc;

-#define DEBUG_PRINT 0
+#define DEBUG_PRINT 1

 // wifi
 #ifdef __IS_MY_HOME
@@ -25,9 +25,9 @@
 #include "ap_setting.h"
 #endif

-char* topic = "esp8266/arduino/s03";
-char* subtopic = "#";
-char* hellotopic = "HELLO";
+const char* topic = "esp8266/arduino/s03";
+const char* subtopic = "#";
+const char* hellotopic = "HELLO";

 LiquidCrystal_I2C lcd(0x27, 20, 4);

@@ -50,7 +50,7 @@
 float PW ;
 int NW ;
 int PIR  ;
-String HO  ;
+int HO  ;

 int sleepmode = LOW ;
 int o_sleepmode = LOW ;
@@ -64,7 +64,7 @@
 float OLD_PW ;
 int OLD_NW ;
 int OLD_PIR  ;
-String OLD_HO  ;
+int OLD_HO  ;

 float OLD_dustDensity ;

@@ -192,7 +192,7 @@
   // esp8266/arduino/s06 : Scale
   // esp8266/arduino/s02  : T, H
   // esp8266/arduino/aircon : ________
-  // home/check/checkhwmny : host
+  // home/check/checkhwmny : unihost, rsphost, unitot, rsptot

   if ( receivedtopic == "esp8266/arduino/s02" ) {
     H   = root["Humidity"];
@@ -219,8 +219,17 @@

   if ( receivedtopic == "home/check/checkhwmny" )
   {
+    if ( root["unihost"] ) {
+      Serial.println(root["unihost"]);
+    }
+    /*
+    const char*
+    const char*
+
+
     const char* HOTEMP = root["host"];
     HO = String(HOTEMP);
+    */
   }
 }

@@ -449,11 +458,13 @@
     o_sleepmode = sleepmode;
   }

-  if ( HO != OLD_HO )
-  {
-    displayHost(HO);
-    OLD_HO = HO;
-  }
+  /*
+    if ( HO != OLD_HO )
+    {
+      displayHost(HO);
+      OLD_HO = HO;
+    }
+  */

   if (( PW != OLD_PW ) && ( 0 <= PW < 10000 ))
   {
@@ -512,18 +523,20 @@
     Serial.print(" ===> ");
     Serial.print(PW);
     Serial.print(" ===> ");
-    Serial.print(HO);
+    Serial.print(HO);
     Serial.print(" ===> ");
     Serial.println(NW);
   }

 }

+/*
 void displayHost(String HO)
 {
   lcd.setCursor(18, 2);
   lcd.print(HO);
 }
+*/

 void displaysleepmode(int sleepmode)
 {


below zero

below zero

--- _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
+++ _04-mqtt-lcd-dust-sensor/_04-mqtt-lcd-dust-sensor-esp-12/_04-mqtt-lcd-dust-sensor-esp-12.ino
@@ -332,12 +332,20 @@
   lcd.setCursor(0, 2);
   lcd.write(2);

-  lcd.setCursor(0, 3);
+  lcd.setCursor(0, 3);  // dust
   lcd.write(3);

-  lcd.setCursor(8, 2);
+  lcd.setCursor(8, 2);  // power
   lcd.write(6);

+  lcd.setCursor(6, 1);
+  lcd.print((char)223); //degree sign
+
+  lcd.setCursor(12, 1);
+  lcd.print((char)223); //degree sign
+
+  lcd.setCursor(6, 2);
+  lcd.print("%");

   H  = -1000 ;
   T1 = -1000 ;
@@ -475,7 +483,7 @@
        lcd.write(5);
     }
   } else {
-    for ( int l =0 ; l <= 3 ; l ++ ) {
+    for ( int l = 0 ; l <= 3 ; l ++ ) {
        lcd.setCursor(19, l);
        lcd.write(" ");
     }
@@ -484,62 +492,45 @@

 void displayTemperaturedigit(float Temperature)
 {
-  int abs_Temperature    abs(Temperature);
-  int int_Temperature    = int(abs_Temperature);
-  int length_Temperature = String(int_Temperature).length;
-
-  Serial.print(" abs ===> ");
-  Serial.print(abs_Temperature);
-  Serial.print(" int ===> ");
-  Serial.print(int_Temperature);
-  Serial.print(" leng ===> ");
-  Serial.println(length_Temperature);
-
-
+  String str_Temperature = String(int(Temperature)) ;
+  int length_Temperature = str_Temperature.length();
+
+  for ( int i = 0; i < ( 3 - length_Temperature ) ; i++ ) {
+      lcd.write(" ");
+  }
+  lcd.print(Temperature, 1);
 }

 void displayTemperature()
 {
-
-  lcd.setCursor(2, 1);
-  if ( ((T1 + T2) / 2) >= 10 ) {
-    lcd.print((T1 + T2) / 2, 1);
-    lcd.print((char)223); //degree sign
-    lcd.print(" ");
-  } else {
-    lcd.print(" ");
-    lcd.print((T1 + T2) / 2, 1);
-    lcd.print((char)223); //degree sign
-    lcd.print(" ");
-  }
-
-  float tempdiff = OT - ((T1 + T2) / 2) ;
-
-  if ( OT > 0 ) {
-    lcd.setCursor(8, 1);
-    if ( OT >= 10 ) {
-      lcd.print(OT, 1);
-      lcd.print((char)223); //degree sign
-      lcd.print(" ");
-    } else {
-      lcd.print(" ");
-      lcd.print(OT, 1);
-      lcd.print((char)223); //degree sign
-      lcd.print(" ");
-    }
-
-    if ( tempdiff >= 0 ) {
+  lcd.setCursor(1, 1);
+  displayTemperaturedigit((T1 + T2) / 2);
+
+  lcd.setCursor(7, 1);
+
+  if ( OT != -1000 ) {
+
+    float tempdiff = OT - ((T1 + T2) / 2) ;
+    displayTemperaturedigit(OT);
+
+    lcd.setCursor(14, 1);
+    if ( tempdiff > 0 ) {
       lcd.print("+");
-    }
-
-    if ( tempdiff >= 10 ) {
-      lcd.print(tempdiff, 1);
-    } else {
-      lcd.print(" ");
-      lcd.print(tempdiff, 1);
-    }
-
-  }
+    } else if ( tempdiff < 0 ) {
+      lcd.print("-");
+    }
+
+    String str_tempdiff = String(int abs(tempdiff));
+    int length_tempdiff = str_tempdiff.length();
+
+    lcd.setCursor(15, 1);
+    lcd.print(abs(tempdiff), 1);
+    if ( n = 1) {
+            lcd.write(" ");
+    }
+
+  }
+

   lcd.setCursor(2, 2);
   if ( H >= 10 ) {
@@ -549,8 +540,8 @@
     lcd.print(H, 1);
   }

-  lcd.print("%");
-}
+}
+

 void displaydustDensity()
 {
@@ -591,10 +582,12 @@
     Serial.println(x);
   }

-  if (( x < 1024 ) && (x != OLD_x )) {
+  if (( 1 < x < 1024 ) && ( x != OLD_x )) {
     float calcVoltage = x * (5.0 / 1024.0);
-    dustDensity = 0.17 * calcVoltage - 0.1;
-    OLD_x = x ;
+    if ( (0.17 * calcVoltage - 0.1) > 0 ) {
+       dustDensity = 0.17 * calcVoltage - 0.1;
+       OLD_x = x ;
+    }
     // //    0 ~ 0.5
   }


play/stop specific music track

play/stop specific music track

--- sketch/sketch.ino
+++ sketch/sketch.ino
@@ -14,14 +14,24 @@
  ****************************************************/

 #include <Wire.h>
+#include <SPI.h>
+#include <SD.h>
+#include <Adafruit_VS1053.h>
 #include <Adafruit_Trellis.h>

 #define NUMKEYS 4
 #define BLINK_DELAY 100
 #define READ_DELAY   50

-// Trellis wiring
+// Trellis pin setup
 #define INTPIN 1
+
+// Feather/Wing pin setup
+#define MUSIC_RESET   -1     // VS1053 reset pin (not used!)
+#define CARD_CS        5     // Card chip select pin
+#define MUSIC_CS       6     // VS1053 chip select pin (output)
+#define MUSIC_DCS     10     // VS1053 Data/command select pin (output)
+#define MUSIC_DREQ     9     // VS1053 Data request, ideally an Interrupt pin (not possible on 32u4)

 // States
 #define IDLE_LIGHT_UP 1
@@ -31,6 +41,8 @@

 Adafruit_Trellis trellis = Adafruit_Trellis();
+Adafruit_VS1053_FilePlayer player = Adafruit_VS1053_FilePlayer(MUSIC_RESET, MUSIC_CS, MUSIC_DCS, MUSIC_DREQ, CARD_CS);
+
 unsigned long nextIdleTick = millis();
 unsigned long nextReadTick = millis();
 byte state = IDLE_LIGHT_UP;
@@ -46,10 +58,12 @@
   // INT pin requires a pullup
   pinMode(INTPIN, INPUT_PULLUP);

-  initializeTrellis(false);
+  initializeCard();
+  initializePlayer();
+  initializeTrellis(0);
 }

-void initializeTrellis(boolean delay) {
+void initializeTrellis(int delay) {
   trellis.begin(0x70);
   //trellis.readSwitches(); // ignore already pressed switches

@@ -61,7 +75,32 @@

   state = IDLE_LIGHT_UP;
   nextLED = 0;
-  nextIdleTick = millis() + (delay ? 1200 : 0);
+  nextIdleTick = millis() + delay;
+}
+
+void initializeCard() {
+  if (!SD.begin(CARD_CS)) {
+    Serial.println(F("SD failed, or not present"));
+    while (1);  // don't do anything more
+  }
+  Serial.println("SD OK!");
+}
+
+void initializePlayer() {
+  if (!player.begin()) {
+     Serial.println(F("Couldn't find VS1053"));
+     while (1);
+  }
+  Serial.println(F("VS1053 found"));
+  player.softReset();
+  player.sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working
+
+  // Set volume for left, right channels. lower numbers == louder volume!
+  player.setVolume(64,64);
+
+  // Timer interrupts are not suggested, better to use DREQ interrupt!
+  // but we don't have them on the 32u4 feather...
+  player.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int
 }

 void loop() {
@@ -120,10 +159,12 @@
 void onKey(byte index) {
   if (state == PLAY_SELECTED && playingAlbum == index) {
     // Pressed playing key again
+    stopPlayingAlbum();
     Serial.print("Stopped album #"); Serial.println(index);
-    initializeTrellis(true);
+    initializeTrellis(1200);
   } else {
     // Pressed key to play a new album
+    if (state == PLAY_SELECTED) stopPlayingAlbum();
     trellis.clear();
     trellis.setLED(index);
     trellis.blinkRate(HT16K33_BLINK_1HZ);
@@ -131,8 +172,23 @@

     state = PLAY_SELECTED;
     playingAlbum = index;
+    playAlbumNew(index);

     Serial.print("Playing album #"); Serial.println(index);
   }
 }

+void playAlbumNew(byte index) {
+  switch (index) {
+    case 0: player.startPlayingFile("track001.mp3"); break;
+    case 1: player.startPlayingFile("track002.mp3"); break;
+    case 2: player.startPlayingFile("track003.mp3"); break;
+    case 3: player.sineTest(0x44, 500); break;
+  }
+}
+
+void stopPlayingAlbum() {
+  player.stopPlaying();
+  delay(20);
+}
+