Fix everything

Fix everything

- The time calculator was completely wrong
- Got rid of a bunch of commented-out junk
- Split up HTTP request into to distinct calls. It seems like fastrprint
  can't handle buffers longer than a few dozen chars at a time.

--- src/TempGauge/TempGauge.ino
+++ src/TempGauge/TempGauge.ino
@@ -18,7 +18,7 @@
                                          SPI_CLOCK_DIV2);

 // Other sketch configuration
-#define     READING_DELAY_SECS     1      // Number of seconds to wait between readings.
+#define     READING_DELAY_SECS     10     // Number of seconds to wait between readings.
 #define     TIMEOUT_MS             15000  // How long to wait (in milliseconds) for a server connection to respond
 #define     SERVER                "fremont"

@@ -27,8 +27,8 @@
 OneWire ds(8);  // on pin 8

 // State used to keep track of the current time and time since last temp reading.
-unsigned long lastPolledTime = 0;   // Last value retrieved from time server
-unsigned long sketchTime = 0;       // CPU milliseconds since last server query
+unsigned long unixTimeAtStart = 0;   // Last value retrieved from time server
+unsigned long sketchTimeAtStartMillis = 0;       // CPU milliseconds since last server query
 unsigned long lastReading = 0;      // Time of last temperature reading.

 void setup(void) {
@@ -56,8 +56,8 @@
     delay(60*1000);
     t = getTime();
   }
-  lastPolledTime = t;
-  sketchTime = millis();
+  unixTimeAtStart = t;
+  sketchTimeAtStartMillis = millis();

   if (!ds.search(addr))  {
     ds.reset_search();
@@ -93,7 +93,7 @@
   // Update the current time.
   // Note: If the sketch will run for more than ~24 hours, you probably want to query the time
   // server again to keep the current time from getting too skewed.
-  unsigned long currentTime = lastPolledTime + (millis() - sketchTime);
+  unsigned long currentTime = unixTimeAtStart + (millis() - sketchTimeAtStartMillis)/1000;

   Serial.print(F("Starting read. Current time: ")); Serial.println(currentTime);
   lastReading = currentTime;
@@ -129,35 +129,6 @@
 }

 void dbWrite(unsigned long currentTime, float currentTemp) {
-  // Generate time and date strings
-//  DateTime dt(currentTime);
-  // Set dateTime to the ISO8601 simple date format string.
-//  char dateTime[17];
-//  memset(dateTime, 0, 17);
-//  dateTime8601(dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dateTime);
-
-  // Set date to just the year month and day of the ISO8601 simple date string.
-//  char date[9];
-//  memset(date, 0, 9);
-//  memcpy(date, dateTime, 8);
-
-  // Set currentTimeStr to the string value of the current unix time (seconds since epoch).
-  char currentTimeStr[11]; // 32-bit int + null
-  sprintf(currentTimeStr, "%ld", currentTime); // Format unsigned long as decimal
-
-  // Generate string for the temperature reading.
-//  char temp[8*sizeof(unsigned long)+5];
-//  memset(temp, 0, 8*sizeof(unsigned long)+5);
-
-  // Convert to fixed point string.  Using a proper float to string function
-  // like dtostrf takes too much program memory (~1.5kb) to use in this sketch.
-//  ultoa((unsigned long) currentTemp, temp, 10);
-//  int n = strlen(temp);
-//  temp[n] = '.';
-//  temp[n+1] = '0' + ((unsigned long) (currentTemp*10)) % 10;
-//  temp[n+2] = '0' + ((unsigned long) (currentTemp*100)) % 10;
-//  temp[n+3] = '0' + ((unsigned long) (currentTemp*1000)) % 10;
-
   // Resolve server IP address
   Serial.print(SERVER);
   uint32_t ip = 0;
@@ -176,20 +147,25 @@
   if (client.connected()) {
     Serial.println(F("done."));

-    String body = F("{\"time\":0,\"temp\":20}");
-    String request = F("POST /temp_gauge/reading HTTP/1.1\r\n"
+    String body = F("{\"time\":");
+    body += currentTime;
+    body += F("000,\"temp\":"); // currentTime is in seconds, need milliseconds
+    body += currentTemp;
+    body += F("}");
+
+    String head = F("POST /temp_gauge/reading HTTP/1.1\r\n"
     "Host: fremont:9200\r\n"
     "Content-Length: ");
-    request += body.length();
-    request += "\r\n\r\n";
-
-    request += body;
+    head += body.length();
+    head += F("\r\n\r\n");

     Serial.println(F("Request:"));
-    Serial.println(request.c_str());
+    Serial.print(head.c_str());
+    Serial.println(body.c_str());

     Serial.print(F("Sending request... "));
-    client.fastrprint(request.c_str());
+    client.fastrprint(head.c_str());
+    client.fastrprint(body.c_str());
     Serial.println(F("done."));
   } else {
     Serial.println(F("Connection failed"));
@@ -209,8 +185,6 @@
   }
   client.close();
 }
-
-

 // Convert an array of bytes into a lower case hex string.
 // Buffer MUST be two times the length of the input bytes array!


[WifiDude] Implemented block state on local pin A0.

Signed-off-by: Juri Berlanda <5bfdca9e82c53adb0603ce7083f4ba4f2da5cacf@hotmail.com>

--- laundry-dude-xbee-bridge/laundry-dude-xbee-bridge.ino
+++ laundry-dude-xbee-bridge/laundry-dude-xbee-bridge.ino
@@ -3,10 +3,12 @@
 #include <Console.h>

 #define SERVER_URI "http://192.168.1.147:5000/laundrydude/api/data"
+#define BLOCKER_STATE_URI "http://192.168.1.147:5000/laundrydude/api/blocker"

 const byte numChars = 32;
 char receivedChars[numChars];		// an array to store the received data
 bool newData = false;
+char block = false;

 SoftwareSerial xbeeSerial(8, 9); // RX, TX
 Process curl;
@@ -16,6 +18,14 @@

 	Console.begin();
 	xbeeSerial.begin(9600);
+
+	// Setup lock
+	pinMode(A0, OUTPUT);
+	setLockState(false);
+}
+
+void setLockState(bool locked) {
+	digitalWrite(A0, locked);
 }

 void loop() {
@@ -27,6 +37,14 @@
 	delay(1000);
 	request('a');
 	delay(1000);
+	getData();
+	set('b', block);
+	setLockState(block == '1');
+}
+
+void set(char type, char value) {
+	xbeeSerial.print(type);
+	xbeeSerial.println(value);
 }

 void request(char type) {
@@ -88,3 +106,19 @@
 	curl.runAsynchronously();
 }

+void getData() {
+	Process p;
+	p.begin("curl");
+	p.addParameter(BLOCKER_STATE_URI);
+	p.run();
+
+	while (p.available()>0) {
+		char c = p.read();
+		switch(c) {
+			case 'b':
+				if (p.read() == '=')
+					block = p.read();
+				break;
+		}
+	}
+}


Fixes & Improvements

Fixes & Improvements

-Fixing a bug regarding checking "isAutoMode".
-Improving code.

--- Ned.ino
+++ Ned.ino
@@ -7,6 +7,9 @@
 -Fixing a bug caused by changing the RTC Lib.
 -Changing Time calculation from minutes to military.
 -Implementing Manual Mode in DEBUG mode.
+March 23, 2017:
+-Fixing a bug regarding checking "isAutoMode".
+-Improving code.
 */

 #include <DS1302.h>
@@ -55,12 +58,10 @@

 void loop()
 {
-  isItAutoMode = digitalRead(13) == HIGH;
   int threshold = 60000; //In final product, the board will check and write every minute.
   #ifdef DEBUG
+  isItAutoMode = digitalRead(13) == HIGH;
   threshold = 1000; //Under development, the board will check and write every second.
-  //Serial.print("Is it automode? ");
-  //Serial.println(isItAutoMode);
   #endif
   if (millis() - timer >= threshold)
   {
@@ -109,14 +110,11 @@

 void MeasureTime()
 {
-  #ifdef DEBUG
   int reading = analogRead(5);
+  Serial.println("Manual Mode");
   sprintf(buffer, "Reading from pot: %04d\n", reading);
   Serial.print(buffer);
   isItDayTime = analogRead(5) > 511;
-  #else
-  isItDayTime = analogRead(5) > 511;
-  #endif
   WriteOutput(!isItDayTime); //Make changes if needed.
 }

@@ -131,4 +129,4 @@
     digitalWrite(i, level);
     i += i == 9 ? 4 : 1; //Skip the RTC Pins (10, 11, 12).
   }
-}
+}


Fix overlooked old-style constructor

Fix overlooked old-style constructor

--- examples/header_test_ttn/header_test_ttn.ino
+++ examples/header_test_ttn/header_test_ttn.ino
@@ -1,6 +1,6 @@
 /*

-Module:  header_test_lmic.ino
+Module:  header_test_ttn.ino

 Function:
         Simple compile-test app for Arduino_LoRaWAN_ttn.h
@@ -15,19 +15,8 @@

 #include <Arduino_LoRaWAN_ttn.h>

-// example pinmap - this is for Feather M0 LoRa
-const Arduino_LoRaWAN::lmic_pinmap myPinmap = {
-     .nss = 8,
-     .rxtx = Arduino_LoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN,
-     .rst = 4,
-     .dio = { 3, 6, Arduino_LoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN },
-     .rxtx_rx_active = 0,
-     .rssi_cal = 0,
-     .spi_freq = 8000000,
-};
-
 // set up the data structures.
-Arduino_LoRaWAN_ttn myLoRaWAN(myPinmap);
+Arduino_LoRaWAN_ttn myLoRaWAN {};

 void setup() {
     myLoRaWAN.begin();


Add the code from my UserDefinedFunctions example, to start to work with the app supporting these functions.

--- Arduino/BlueCube/BlueCube.ino
+++ Arduino/BlueCube/BlueCube.ino
@@ -17,6 +17,9 @@
 #include "Cube.h"

 Cube cube;
+
+byte action = 0; // Track which user defined function to run
+rgb_t theColour; // Track the colour to use with user defined function

 #include "Adafruit_BLE.h"
 #include "Adafruit_BluefruitLE_UART.h"
@@ -78,6 +81,11 @@
   // -1: Don't attach any serial port to interact with the Cube.
   cube.begin(0, 115200); // Start on serial port 0 (USB) at 115200 baud

+  // Tell the cube library that the function 'userFunctionHandler' should be
+  // called if the user uses the 'user ### colour;' serial command line
+  // instruction
+  setDelegate(userFunctionHandler);
+
   pinMode(BLUEFRUIT_UART_MODE_PIN, OUTPUT);
 //  while (!Serial);  // required for Flora & Micro
 //  delay(500);
@@ -152,5 +160,286 @@
 void loop(void)
 {
   readPacket(&ble, BLE_READPACKET_TIMEOUT);
-}
-
+  if (cube.inUserMode())
+  {
+      // The last processed serial command was for a user
+      // defined function, so run the action based on the
+      // users input
+      switch (action)
+      {
+        case 1:
+          zigzag();
+          break;
+        case 2:
+          randomPastels();
+          break;
+        case 3:
+          randomColours();
+          break;
+        case 4:
+          randomPrimaries();
+          break;
+        case 5:
+          faceSweep();
+          break;
+      }
+  }
+}
+
+void zigzag()
+{
+  // Zig Zag style pattern
+  // The Zig
+  cube.all(BLACK);
+  cube.set(0,0,0, theColour);
+  cube.set(2,0,0, theColour);
+  cube.set(1,1,0, theColour);
+  cube.set(3,1,0, theColour);
+  cube.set(0,2,0, theColour);
+  cube.set(2,2,0, theColour);
+  cube.set(1,3,0, theColour);
+  cube.set(3,3,0, theColour);
+  cube.copyplane(Z, 0, 2);
+  cube.set(1,0,1, theColour);
+  cube.set(3,0,1, theColour);
+  cube.set(0,1,1, theColour);
+  cube.set(2,1,1, theColour);
+  cube.set(1,2,1, theColour);
+  cube.set(3,2,1, theColour);
+  cube.set(0,3,1, theColour);
+  cube.set(2,3,1, theColour);
+  cube.copyplane(Z, 1, 3);
+  delay(300);
+
+  // The Zag
+  cube.all(BLACK);
+  cube.set(1,0,0, theColour);
+  cube.set(3,0,0, theColour);
+  cube.set(0,1,0, theColour);
+  cube.set(2,1,0, theColour);
+  cube.set(1,2,0, theColour);
+  cube.set(3,2,0, theColour);
+  cube.set(0,3,0, theColour);
+  cube.set(2,3,0, theColour);
+  cube.copyplane(Z, 0, 2);
+  cube.set(0,0,1, theColour);
+  cube.set(2,0,1, theColour);
+  cube.set(1,1,1, theColour);
+  cube.set(3,1,1, theColour);
+  cube.set(0,2,1, theColour);
+  cube.set(2,2,1, theColour);
+  cube.set(1,3,1, theColour);
+  cube.set(3,3,1, theColour);
+  cube.copyplane(Z, 1, 3);
+  delay(300);
+}
+
+void randomPastels()
+{
+  // Function by Jonathan Oxer (jon@freetronics.com), from
+  // the RandomPastels example sketch
+  cube.set(random(4), random(4), random(4), RGB(random(255), random(255), random(255)));
+  delay(2);
+}
+
+void randomColours()
+{
+  // Function by Jonathan Oxer (jon@freetronics.com), from
+  // the RandomColours example sketch
+  byte xPos;
+  byte yPos;
+  byte zPos;
+  byte rr;
+  byte gg;
+  byte bb;
+
+  xPos = random(4);
+  yPos = random(4);
+  zPos = random(4);
+  rr = random(0, 2) * 255;
+  gg = random(0, 2) * 255;
+  bb = random(0, 2) * 255;
+
+
+  cube.set(xPos, yPos, zPos, RGB(rr, gg, bb));
+  delay(2);
+}
+
+void randomPrimaries()
+{
+  // Function by Jonathan Oxer (jon@freetronics.com), from
+  // the RandomPrimaries example sketch
+  rgb_t colours[3] = {RED, GREEN, BLUE};
+  byte xPos;
+  byte yPos;
+  byte zPos;
+
+  xPos = random(0, 4);
+  yPos = random(0, 4);
+  zPos = random(0, 4);
+  byte i = random(0, 3);
+
+  cube.set(xPos, yPos, zPos, colours[i]);
+  delay(2);
+}
+
+void faceSweep()
+{
+  cube.all(BLACK);
+  // Move 1
+  cube.setplane(Y, 0, BLUE);
+  delay(100);
+
+  // Move 2
+  cube.set(0,0,0, BLACK);
+  cube.set(1,0,0, BLACK);
+  cube.set(2,0,0, BLACK);
+  cube.set(3,0,0, BLACK);
+  cube.set(0,1,0, BLUE);
+  cube.set(1,1,0, BLUE);
+  cube.set(2,1,0, BLUE);
+  cube.set(3,1,0, BLUE);
+  delay(100);
+
+  // Move 3
+  cube.set(0,1,0, BLACK);
+  cube.set(1,1,0, BLACK);
+  cube.set(2,1,0, BLACK);
+  cube.set(3,1,0, BLACK);
+  cube.set(0,0,1, BLACK);
+  cube.set(1,0,1, BLACK);
+  cube.set(2,0,1, BLACK);
+  cube.set(3,0,1, BLACK);
+  cube.set(0,2,0, BLUE);
+  cube.set(1,2,0, BLUE);
+  cube.set(2,2,0, BLUE);
+  cube.set(3,2,0, BLUE);
+  cube.set(0,1,1, BLUE);
+  cube.set(1,1,1, BLUE);
+  cube.set(2,1,1, BLUE);
+  cube.set(3,1,1, BLUE);
+  delay(100);
+
+  // Move 4
+  cube.set(0,2,0, BLACK);
+  cube.set(1,2,0, BLACK);
+  cube.set(2,2,0, BLACK);
+  cube.set(3,2,0, BLACK);
+  cube.set(0,1,1, BLACK);
+  cube.set(1,1,1, BLACK);
+  cube.set(2,1,1, BLACK);
+  cube.set(3,1,1, BLACK);
+  cube.set(0,0,2, BLACK);
+  cube.set(1,0,2, BLACK);
+  cube.set(2,0,2, BLACK);
+  cube.set(3,0,2, BLACK);
+  cube.set(0,3,0, BLUE);
+  cube.set(1,3,0, BLUE);
+  cube.set(2,3,0, BLUE);
+  cube.set(3,3,0, BLUE);
+  cube.set(0,2,1, BLUE);
+  cube.set(1,2,1, BLUE);
+  cube.set(2,2,1, BLUE);
+  cube.set(3,2,1, BLUE);
+  cube.set(0,1,2, BLUE);
+  cube.set(1,1,2, BLUE);
+  cube.set(2,1,2, BLUE);
+  cube.set(3,1,2, BLUE);
+  delay(100);
+
+  // Move 5
+  cube.set(0,3,0, BLACK);
+  cube.set(1,3,0, BLACK);
+  cube.set(2,3,0, BLACK);
+  cube.set(3,3,0, BLACK);
+  cube.set(0,2,1, BLACK);
+  cube.set(1,2,1, BLACK);
+  cube.set(2,2,1, BLACK);
+  cube.set(3,2,1, BLACK);
+  cube.set(0,1,2, BLACK);
+  cube.set(1,1,2, BLACK);
+  cube.set(2,1,2, BLACK);
+  cube.set(3,1,2, BLACK);
+  cube.set(0,1,3, BLUE);
+  cube.set(1,1,3, BLUE);
+  cube.set(2,1,3, BLUE);
+  cube.set(3,1,3, BLUE);
+  cube.set(0,2,2, BLUE);
+  cube.set(1,2,2, BLUE);
+  cube.set(2,2,2, BLUE);
+  cube.set(3,2,2, BLUE);
+  cube.set(0,3,1, BLUE);
+  cube.set(1,3,1, BLUE);
+  cube.set(2,3,1, BLUE);
+  cube.set(3,3,1, BLUE);
+  delay(100);
+
+  // Move 6
+  cube.set(0,2,2, BLACK);
+  cube.set(1,2,2, BLACK);
+  cube.set(2,2,2, BLACK);
+  cube.set(3,2,2, BLACK);
+  cube.set(0,3,1, BLACK);
+  cube.set(1,3,1, BLACK);
+  cube.set(2,3,1, BLACK);
+  cube.set(3,3,1, BLACK);
+  cube.set(0,2,3, BLUE);
+  cube.set(1,2,3, BLUE);
+  cube.set(2,2,3, BLUE);
+  cube.set(3,2,3, BLUE);
+  cube.set(0,3,2, BLUE);
+  cube.set(1,3,2, BLUE);
+  cube.set(2,3,2, BLUE);
+  cube.set(3,3,2, BLUE);
+  delay(100);
+
+  // Move 7
+  cube.set(0,3,2, BLACK);
+  cube.set(1,3,2, BLACK);
+  cube.set(2,3,2, BLACK);
+  cube.set(3,3,2, BLACK);
+  cube.set(0,3,3, BLUE);
+  cube.set(1,3,3, BLUE);
+  cube.set(2,3,3, BLUE);
+  cube.set(3,3,3, BLUE);
+
+  delay(500);
+}
+
+void userFunctionHandler(int itemID, rgb_t selectedColour)
+{
+  /*  This function is called when the user askes for a user defined item via the
+   *  serial command line interface. The format is 'user ### colour;', where ### is
+   *  a integer, and colour is either the predefined colours, or a HTML colour code.
+   *  The colour variable is optional, (so 'user 1;' is valid) but if it is not present
+   *  and expected, black is used in it's place.
+   */
+
+  // Set the global variables for action and colour based on
+  // what the user requested. This will cause them to run
+  // repeateadly in the main loop, until the user requests a
+  // different action
+  action = itemID;
+  theColour = selectedColour;
+
+  // Inform the user which action was selected
+  switch (action)
+  {
+    case 1:
+      serial->println("ZigZag");
+      break;
+    case 2:
+      serial->println("Random Pastels");
+      break;
+    case 3:
+      serial->println("Random Colours");
+      break;
+    case 4:
+      serial->println("Random Primaries");
+      break;
+    case 5:
+      serial->println("Face Sweep");
+      break;
+  }
+}
+


HA! HA! I'm altering boundary conditions.

--- examples/ButtonExample/ButtonExample.ino
+++ examples/ButtonExample/ButtonExample.ino
@@ -84,7 +84,7 @@

     strip.setPixelColor(i, pix);

-    if ((millis() - last_time > 15) && pixel_index < LED_COUNT) {
+    if ((millis() - last_time > 15) && pixel_index <= LED_COUNT + 1) {
       last_time = millis();
       count = LED_COUNT - pixel_index;
       pixel_index++;


added OLED support and Dell adapter module

--- JBC-Soldering-Controller.ino
+++ JBC-Soldering-Controller.ino
@@ -3,12 +3,19 @@
  *
  * MIT License. See LICENSE file for details.
  */
-
+
+#include <SPI.h>
+#include <Wire.h>
+#include <Adafruit_GFX.h>
+#include <Adafruit_SSD1306.h>
+
+#include <dell_psu.h>

 #include <TimerOne.h>
 #include "DigitalIO.h"
 #include <SPI.h>
 #include "ads1118.h"
+

 //Pin Mapping
 const int LPINA = 9;
@@ -22,6 +29,11 @@
 volatile int16_t temperature_value=0;  //internal temp of ADS1118

 //Global Objects
+#define OLED_RESET 4
+Adafruit_SSD1306 display(OLED_RESET);
+
+DellPSU dell(1);   //specify the desired Arduino pin number
+

 //----------------Setup-------------------------
 void setup(void)
@@ -29,21 +41,13 @@
   //Start our debug serial port
   Serial.begin(115200);
   while(!Serial);
-  /*
-  Serial.println(ADS1118_INT_TEMP_C(0x1000<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0FFF<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0C80<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0960<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0640<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0320<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0008<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0001<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x0000<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x3FF8<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x3CE0<<2));
-  Serial.println(ADS1118_INT_TEMP_C(0x3B00<<2));
-  delay(5000);
-  */
+
+  //Setup the OLED
+    // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
+    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
+    // Clear the buffer.
+    display.clearDisplay();
+
   //these are for debugging the Interrupts
   fastPinMode(debug_pin_A, OUTPUT);
   fastPinMode(debug_pin_B, OUTPUT);
@@ -194,18 +198,67 @@
  //convert to degrees C
  temperature_copy=ADS1118_INT_TEMP_C(temperature_copy);

- //static int16_t last_temp=0;
-
- //if (last_temp!=temperature_copy)
- //{
- //Serial.print(adc_copy);
- //Serial.print("    ");
-
- Serial.print(temperature_copy);
- Serial.print(" ");
- Serial.println(adc_copy);
- //last_temp=temperature_copy;
- //}
- delay(300);
-
-}
+
+ //Serial.print(temperature_copy);
+ //Serial.print(" ");
+ //Serial.println(adc_copy);
+
+    display.clearDisplay();
+    display.setTextSize(1);
+    display.setTextColor(WHITE);
+    display.setCursor(0,0);
+
+  display.print(temperature_copy);
+ display.print(" ");
+ display.println(adc_copy);
+
+display.display();
+
+ delay(300);
+}
+
+
+/*
+   display.clearDisplay();
+    display.setTextSize(1);
+    display.setTextColor(WHITE);
+    display.setCursor(0,0);
+
+
+    if (dell.read_data()==true)
+  {
+    display.print(dell.watts());
+    display.print("W ");
+    display.print(dell.millivolts());
+    display.print("mv ");
+    display.print(dell.milliamps());
+    display.println("mA ");
+    display.println(dell.response_string());
+    //Serial.println(dell.milliamps());
+    Serial.println(dell.response_string());
+  }
+  else
+  {
+    display.print("plug in adapter");
+  }
+  display.display();
+  delay(1000);
+
+ */
+
+
+ /*
+  Serial.println(ADS1118_INT_TEMP_C(0x1000<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0FFF<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0C80<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0960<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0640<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0320<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0008<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0001<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x0000<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x3FF8<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x3CE0<<2));
+  Serial.println(ADS1118_INT_TEMP_C(0x3B00<<2));
+  delay(5000);
+  */


Modified canbus receive blink example

Modified canbus receive blink example

--- examples/receive_Blink/receive_Blink.ino
+++ examples/receive_Blink/receive_Blink.ino
@@ -3,7 +3,6 @@
 // loovee, 2014-6-13

 #include <SPI.h>
-#include "mcp_can.h"

 /*SAMD core*/
 #ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
@@ -12,19 +11,37 @@
     #define SERIAL Serial
 #endif

+#define CAN_2515
+//#define CAN_2518FD
 // the cs pin of the version after v1.1 is default to D9
 // v0.9b and v1.0 is default D10
+
+#ifdef CAN_2518FD
+#include "mcp2518fd_can.h"
+const int SPI_CS_PIN = BCM8;
+const int CAN_INT_PIN = BCM25;
+mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
+#endif
+
+#ifdef CAN_2515
+#include "mcp2515_can.h"
 const int SPI_CS_PIN = 9;
+const int CAN_INT_PIN = 2;
+mcp2515_can CAN(SPI_CS_PIN); // Set CS pin
+#endif                              // Set CS pin
+
 const int LED        = 8;
 boolean ledON        = 1;
-
-MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

 void setup() {
     SERIAL.begin(115200);
     pinMode(LED, OUTPUT);

-    while (CAN_OK != CAN.begin(CAN_500KBPS)) {            // init can bus : baudrate = 500k
+#ifdef CAN_2518FD
+    while (0 != CAN.begin((byte)CAN_500K_1M)) {            // init can bus : baudrate = 500k
+#else
+    while (CAN_OK != CAN.begin(CAN_500KBPS)) {             // init can bus : baudrate = 500k
+#endif
         SERIAL.println("CAN BUS Shield init fail");
         SERIAL.println("Init CAN BUS Shield again");
         delay(100);
@@ -64,4 +81,4 @@
     }
 }

-//END FILE+//END FILE


Updated example.

Updated example.

--- examples/Alarms/Alarms.ino
+++ examples/Alarms/Alarms.ino
@@ -1,3 +1,26 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2013 Mathias Munk Hansen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
 #include <OneWire.h>
 #include <DS18B20.h>

@@ -10,40 +33,37 @@
 // 1-Wire devices connected to digital pin 2 on the Arduino.
 DS18B20 ds(2);

-// Array for holding the 64 bit address of the current device.
-uint8_t address[8];
-
 void setup() {
   Serial.begin(9600);

   // Set low and high alarms of all devices.
-  while(ds.getNextDevice(address))
+  while(ds.selectNext())
   {
-    ds.setAlarms(LOW_ALARM, HIGH_ALARM, address);
+    ds.setAlarms(LOW_ALARM, HIGH_ALARM);
   }
 }

 void loop()
 {
   // Tell every device to start a temperature conversion.
-  ds.startConversion();
+  ds.doConversion();

-  // Print alarm values and current temperature for every device with an active alarm.
-  while(ds.getNextAlarm(address))
+  // Print alarm values and current temperature for every device with an active alarm condition.
+  while(ds.selectNextAlarm())
   {
     // Print value of low alarm.
     Serial.print("Alarm Low: ");
-    Serial.print(ds.getAlarmLow(address));
+    Serial.print(ds.getAlarmLow());
     Serial.println(" C");

     // Print value of high alarm.
     Serial.print("Alarm High: ");
-    Serial.print(ds.getAlarmHigh(address));
+    Serial.print(ds.getAlarmHigh());
     Serial.println(" C");

     // Print current temperature to verify that it is still either < LOW_ALARM or > HIGH_ALARM.
     Serial.print("Temperature: ");
-    Serial.print(ds.getTempC(address));
+    Serial.print(ds.getTempC());
     Serial.println(" C\n");
   }


baudrate -> baud.

baudrate -> baud.

--- examples/Simple/Simple.ino
+++ examples/Simple/Simple.ino
@@ -7,7 +7,7 @@
  * tokens is predictable.
  */

-const long BAUDRATE = 115200;
+const long BAUD = 115200;

 const char *JSON_STRING =
   "{\"user\": \"johndoe\", \"admin\": false, \"uid\": 1000,\n  "
@@ -26,7 +26,7 @@

 void setup()
 {
-  Serial.begin(BAUDRATE);
+  Serial.begin(BAUD);
 }

 void loop()


Remove old stuff

Remove old stuff

--- lampka.ino
+++ lampka.ino
@@ -143,183 +143,6 @@
   //_delay_us( (RES / 1000UL) + 1);       // Round up since the delay must be _at_least_ this long (too short might not work, too long not a problem)
  delayMicroseconds((RES / 1000UL) + 1);
 }
-
-
-/*
-
-  That is the whole API. What follows are some demo functions rewriten from the AdaFruit strandtest code...
-
-  https://github.com/adafruit/Adafruit_NeoPixel/blob/master/examples/strandtest/strandtest.ino
-
-  Note that we always turn off interrupts while we are sending pixels becuase an interupt
-  could happen just when we were in the middle of somehting time sensitive.
-
-  If we wanted to minimize the time interrupts were off, we could instead
-  could get away with only turning off interrupts just for the very brief moment
-  when we are actually sending a 0 bit (~1us), as long as we were sure that the total time
-  taken by any interrupts + the time in our pixel generation code never exceeded the reset time (5us).
-
-*/
-
-
-/*
-// Fill the dots one after the other with a color
-// rewrite to lift the compare out of the loop
-void colorWipe(uint8_t r , uint8_t g, uint8_t b, unsigned  char wait ) {
-  for(unsigned int i=0; i<PIXELS; i+= (PIXELS/60) ) {
-
-    cli();
-    unsigned int p=0;
-
-    while (p++<=i) {
-        sendPixel(r,g,b);
-    }
-
-    while (p++<=PIXELS) {
-        sendPixel(0,0,0);
-
-    }
-
-    sei();
-    show();
-    delay(wait);
-  }
-}
-*/
-
-/*
-// Theatre-style crawling lights.
-// Changes spacing to be dynmaic based on string size
-
-#define THEATER_SPACING (PIXELS/20)
-
-void theaterChase( uint8_t r , uint8_t g, uint8_t b, uint8_t wait ) {
-
-  for (int j=0; j< 3 ; j++) {
-
-    for (int q=0; q < THEATER_SPACING ; q++) {
-
-      unsigned int step=0;
-
-      cli();
-
-      for (int i=0; i < PIXELS ; i++) {
-
-        if (step==q) {
-
-          sendPixel( r , g , b );
-
-        } else {
-
-          sendPixel( 0 , 0 , 0 );
-
-        }
-
-        step++;
-
-        if (step==THEATER_SPACING) step =0;
-
-      }
-
-      sei();
-
-      show();
-      delay(wait);
-
-    }
-
-  }
-
-}
-
-*/
-
-/*
-
-// I rewrite this one from scrtach to use high resolution for the color wheel to look nicer on a *much* bigger string
-
-void rainbowCycle(uint8_t frames , unsigned int frameAdvance, unsigned int pixelAdvance ) {
-
-  // Hue is a number between 0 and 3*256 than defines a mix of r->g->b where
-  // hue of 0 = Full red
-  // hue of 128 = 1/2 red and 1/2 green
-  // hue of 256 = Full Green
-  // hue of 384 = 1/2 green and 1/2 blue
-  // ...
-
-  unsigned int firstPixelHue = 0;     // Color for the first pixel in the string
-
-  for(unsigned int j=0; j<frames; j++) {
-
-    unsigned int currentPixelHue = firstPixelHue;
-
-    cli();
-
-    for(unsigned int i=0; i< PIXELS; i++) {
-
-      if (currentPixelHue>=(3*256)) {                  // Normalize back down incase we incremented and overflowed
-        currentPixelHue -= (3*256);
-      }
-
-      uint8_t phase = currentPixelHue >> 8;
-      uint8_t step = currentPixelHue & 0xff;
-
-      switch (phase) {
-
-        case 0:
-          sendPixel( ~step , step ,  0 );
-          break;
-
-        case 1:
-          sendPixel( 0 , ~step , step );
-          break;
-
-        case 2:
-          sendPixel(  step ,0 , ~step );
-          break;
-
-      }
-
-      currentPixelHue+=pixelAdvance;
-
-
-    }
-
-    sei();
-
-    show();
-
-    firstPixelHue += frameAdvance;
-
-  }
-}
-*/
-
-
-/*
-// I added this one just to demonstrate how quickly you can flash the string.
-// Flashes get faster and faster until *boom* and fade to black.
-
-void detonate( uint8_t r , uint8_t g , uint8_t b , unsigned int startdelayms) {
-  while (startdelayms) {
-
-    showColor( r , g , b );      // Flash the color
-    showColor( 0 , 0 , 0 );
-
-    delay( startdelayms );
-
-    startdelayms =  ( startdelayms * 4 ) / 5 ;           // delay between flashes is halved each time until zero
-
-  }
-
-  // Then we fade to black....
-  for( int fade=256; fade>0; fade-- ) {
-    showColor( (r * fade) / 256 ,(g*fade) /256 , (b*fade)/256 );
-  }
-  showColor( 0 , 0 , 0 );
-}
-*/
-

 ////////////////////////////////////////////////////////////////////////////////////
@@ -558,18 +381,6 @@

 const uint8_t test_pixel[3] = {32,32,32};

-const uint8_t rgb_colors[CONSTANT_COLORS_LEN][3] = {
-{255,0,0},
-{255,127,0},
-{255,255,0},
-{0,255,0},
-{0,255,255},
-{0,0,255},
-{255,0,255},
-{255,127,255},
-{255,255,255}
-};
-
 ISR(PCINT0_vect) {
     cli();
     if (PINB & (1<<3)) { //change direction


add servo and ultrasonic to test

add servo and ultrasonic to test

--- testing/arduino/tf_test_v2.ino
+++ testing/arduino/tf_test_v2.ino
@@ -1,18 +1,12 @@
-#include <ros.h>
-#include <ros/time.h>
-#include <tf/transform_broadcaster.h>
+#include "Arduino.h"
+#include "Servo.h"
+#include "NewPing.h"
+#include "ros.h"
+#include "ros/time.h"
+#include "tf/transform_broadcaster.h"
 #include "sensor_msgs/Range.h" // Ultrasonic Range

 ros::NodeHandle  nh;
-
-sensor_msgs::Range rangeMessage;
-ros::Publisher rangePublisher1("/ultrasound/1", &rangeMessage);
-ros::Publisher rangePublisher2("/ultrasound/2", &rangeMessage);
-
-const char rangeFrameid[] = "/ultrasound";
-
-
-

 geometry_msgs::TransformStamped t;
 tf::TransformBroadcaster broadcaster;
@@ -21,6 +15,65 @@
 char servo_node_2[] = "/servo_node_2";
 char base_link[] = "/base_link";
 char odom[] = "/odom";
+
+sensor_msgs::Range rangeMessage;
+ros::Publisher rangePublisher1("/ultrasound/1", &rangeMessage);
+ros::Publisher rangePublisher2("/ultrasound/2", &rangeMessage);
+
+
+// Ultrasonic Sensor
+const uint16_t maxDistance = 250;
+
+// Ultrasonic Sensor #1
+const uint8_t trigPin = 9;
+const uint8_t echoPin = 10;
+
+NewPing sonar1(trigPin, echoPin, maxDistance);
+
+// Ultrasonic Sensor #2
+const uint8_t trigPin2 = 11;
+const uint8_t echoPin2 = 12;
+
+NewPing sonar2(trigPin2, echoPin2, maxDistance);
+
+// Ultrasonic Servo
+Servo ServoMotor;
+const uint8_t servoPin = 6;
+const uint8_t servoRotationAngel = 5;
+
+enum direction {
+    left,
+    center,
+    right
+};
+
+uint8_t servoPos = 90;
+direction servoMovement = right;
+
+// ------------------------------
+//            SETUP
+// ------------------------------
+
+void setup()
+{
+    nh.initNode();
+    broadcaster.init(nh);
+
+    nh.advertise(rangePublisher1);
+    nh.advertise(rangePublisher2);
+
+    rangeMessage.radiation_type = sensor_msgs::Range::ULTRASOUND;
+    rangeMessage.field_of_view = 0.1;
+    rangeMessage.min_range = 0.0;
+    rangeMessage.max_range = maxDistance/100; // cm to meter
+
+    // attach servo pin and set to initial direction
+    ServoMotor.attach(servoPin, 400, 2350); // 400, 2600 to fix rotation issues
+    ServoMotor.write(servoPos);
+}
+
+
+// ------------------------------

 static geometry_msgs::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw) {
@@ -38,24 +91,129 @@
     return q;
 }

-
-
-
-
-void setup()
-{
-    nh.initNode();
-    broadcaster.init(nh);
-
-    nh.advertise(rangePublisher1);
-    nh.advertise(rangePublisher2);
-}
-
-float tempNumber = 0;
+double RadianToDegree(double rad)
+{
+    return (rad * 4068) / 71.0;
+}
+
+double DegreeToRadian(double deg)
+{
+    return (deg * 71) / 4068.0;
+}
+
+
+// ------------------------------
+
+
+
+long GetRange(int id)
+{
+    long range = 0;
+    if(id == 1)
+    {
+        range = sonar1.ping_cm();
+    }
+
+    if(id == 2)
+    {
+        range = sonar2.ping_cm();
+    }
+
+    return range;
+}
+
+
+uint8_t GetNextServoAngle()
+{
+    if(servoPos <= 0)
+    {
+        servoMovement = right;
+        servoPos = 0;
+    }
+
+    if(servoPos >= 180)
+    {
+        servoMovement = left;
+        servoPos = 180;
+    }
+
+
+    if(servoMovement == right)
+    {
+        servoPos += servoRotationAngel;
+    }
+    else
+    {
+        servoPos -= servoRotationAngel;
+    }
+
+    return servoPos;
+}
+
+
+void SendServoAngleToROS(int angle)
+{
+
+}
+
+void SendTransformToROS()
+{
+
+}
+
+
+void SendDistanceToROS(int sensorID, float rangeInCentimeter)
+{
+    rangeMessage.range = rangeInCentimeter/100;
+    rangeMessage.header.stamp = nh.now();
+
+    if(sensorID == 1)
+    {
+        rangeMessage.header.frame_id = servo_node_1;
+        rangePublisher1.publish(&rangeMessage);
+    }
+
+    if(sensorID == 2)
+    {
+        rangeMessage.header.frame_id = servo_node_2;
+        rangePublisher2.publish(&rangeMessage);
+    }
+}
+

 void loop()
 {
-    tempNumber += 0.1;
+    long rangeFront = GetRange(1);
+    long rangeBack = GetRange(2);
+
+    uint8_t actualServoPos = ServoMotor.read();
+    if(servoPos == actualServoPos)
+    {
+        ServoMotor.write(GetNextServoAngle());
+        if(!nh.connected())
+        {
+            delay(5);
+        }
+    }
+
+    if(rangeFront > 0)
+    {
+        SendDistanceToROS(1, rangeFront);
+    }
+
+    if(rangeBack > 0)
+    {
+        SendDistanceToROS(2, rangeBack);
+    }
+
+    SendServoAngleToROS(servoPos);
+
+
+
+
+
+
+

     t.header.frame_id = odom;
     t.child_frame_id = base_link;
@@ -63,7 +221,7 @@
     t.transform.translation.y = 0.0;
     t.transform.translation.z = 1.0;

-    t.transform.rotation = createQuaternionFromRPY(0.0, 0.0, tempNumber);
+    t.transform.rotation = createQuaternionFromRPY(0.0, 0.0, DegreeToRadian(servoPos));
     /*
     t.transform.rotation.x = 0.0;
     t.transform.rotation.y = 0.0;
@@ -75,11 +233,16 @@

     broadcaster.sendTransform(t);

+
     t.header.frame_id = base_link;
     t.child_frame_id = servo_node_1;
     t.transform.translation.x = 0.0;
     t.transform.translation.y = 0.05;
     t.transform.translation.z = 0.0;
+
+    /// radian = (degree * 71) / 4068.0
+    /// degree = (radians * 4068) / 71.0
+
     t.transform.rotation = createQuaternionFromRPY(0.0, 0.0, ((90 * 71) / 4068.0));
     t.header.stamp = nh.now();

@@ -97,31 +260,7 @@
     broadcaster.sendTransform(t);

-    rangeMessage.radiation_type = sensor_msgs::Range::ULTRASOUND;
-    rangeMessage.field_of_view = 0.1;
-    rangeMessage.min_range = 0.0;
-    rangeMessage.max_range = 200/100; // cm to meter
-    rangeMessage.header.frame_id = servo_node_1;
-    rangeMessage.range = 195/100;
-    rangeMessage.header.stamp = nh.now();
-    rangePublisher1.publish(&rangeMessage);
-
-
-    rangeMessage.radiation_type = sensor_msgs::Range::ULTRASOUND;
-    rangeMessage.field_of_view = 0.1;
-    rangeMessage.min_range = 0.0;
-    rangeMessage.max_range = 200/100; // cm to meter
-    rangeMessage.header.frame_id = servo_node_2;
-    rangeMessage.range = 195/100;
-    rangeMessage.header.stamp = nh.now();
-    rangePublisher2.publish(&rangeMessage);
-
-
-      /// radian = (degree * 71) / 4068.0
-      /// degree = (radians * 4068) / 71.0
-

     nh.spinOnce();
-    delay(1);
-}
+}


Fix up compile errors

Fix up compile errors

--- software/firmware/QuadruloopBasic/QuadruloopBasic.ino
+++ software/firmware/QuadruloopBasic/QuadruloopBasic.ino
@@ -18,6 +18,9 @@
 String cmd;  // cmd received over serial - builds up char at a time

 COMMAND tempCmd;
+
+static void parseCommand(String c);
+static void doCommand(COMMAND *c);

 void setup() {
   Serial.begin(9600);


Included Link to YouTube Video

Included Link to YouTube Video

--- examples/StarterProject_and_SignalTester/StarterProject_and_SignalTester.ino
+++ examples/StarterProject_and_SignalTester/StarterProject_and_SignalTester.ino
@@ -1,7 +1,13 @@

-/*  PulseSensor™ Starter Project   http://www.pulsesensor.com
+/*  PulseSensor™ Starter Project and Signal Tester
+ *  The Best Way to Get Started  With, or See the Raw Signal of, your PulseSensor™ & Arduino.
+
+ *  http://www.pulsesensor.com
  *
-This an Arduino project. It's Best Way to Get Started with your PulseSensor™ & Arduino.
+ *  WATCH ME (Tutorial Video):
+ *  https://www.youtube.com/watch?v=82T_zBZQkOE
+ *
+ *
 -------------------------------------------------------------
 1) This shows a live human Heartbeat Pulse.
 2) Live visualization in Arduino's Cool "Serial Plotter".
@@ -52,4 +58,3 @@

-


remove unneeded code

remove unneeded code

--- vibrate_alarm_clock_2.ino
+++ vibrate_alarm_clock_2.ino
@@ -157,26 +157,6 @@
 }

 int getVoltageADCReading(){
-  //  // subtract the last reading:
-  //  total= total - readings[index];
-  //  // read from the sensor:
-  //  readings[index] = analogRead(VOLTAGE_MEASURE_PIN);
-  //  Serial.println(readings[index]);
-  //  // add the reading to the total:
-  //  total= total + readings[index];
-  //  // advance to the next position in the array:
-  //  index = index + 1;
-  //
-  //  // if we're at the end of the array...
-  //  if (index >= numReadings)
-  //    // ...wrap around to the beginning:
-  //    index = 0;
-  //
-  //  // calculate the average:
-  //  average = total / numReadings;
-  //  // send it to the computer as ASCII digits
-  //
-  //    return average;
   return analogRead(VOLTAGE_MEASURE_PIN);
 }
 void processLeftButtonPressed(){


analog read

analog read

--- Ardunio/makey/KeyboardPress/KeyboardPress.ino
+++ Ardunio/makey/KeyboardPress/KeyboardPress.ino
@@ -20,31 +20,22 @@
  http://www.arduino.cc/en/Tutorial/KeyboardMessage
  */

-const int buttonPin = 2;          // input pin for pushbutton
-int previousButtonState = HIGH;   // for checking the state of a pushButton
-int counter = 0;                  // button push counter
-
 void setup() {
   // make the pushButton pin an input:
-  pinMode(buttonPin, INPUT);
   // initialize control over the keyboard:
   Keyboard.begin();
 }

 void loop() {
   // read the pushbutton:
-  int buttonState = digitalRead(buttonPin);
+  int sensorValue = analogRead(A2);
   // if the button state has changed,
-  if ((buttonState != previousButtonState)
-    // and it's currently pressed:
-  && (buttonState == HIGH)) {
+  if ((sensorValue > 0)) {
     // increment the button counter
     // type out a message
     Keyboard.press('a');
-    delay(100);
+    delay(10);
     Keyboard.releaseAll();
   }
-  // save the current button state for comparison next time:
-  previousButtonState = buttonState;
 }


fix BlinkMTester if you have CR+NL turned on, also enable multi-number color (e.g. "c 255, 0, 255")

--- BlinkM/examples/BlinkMTester/BlinkMTester.ino
+++ BlinkM/examples/BlinkMTester/BlinkMTester.ino
@@ -28,10 +28,14 @@
  * Gnd - Gnd, 3V - Vcc, D0 - SDA, D2 - SCL
  *
  *
- * Can upload to Arduino via commandline with:
+ * Can upload to Arduino via commandline with:
  *  arduino-cli compile --fqbn arduino:avr:micro BlinkMTester  (say for Arduino Pro Micro)
  *  arduino-cli -v upload -p /dev/tty.usbmodem141301 --fqbn arduino:avr:micro BlinkMTester
  *
+ * BlinkM2 feature ideas:
+ * - expand algorithmic pattern generation (lots of work on this already)
+ * - low-power sleep mode
+ * - wake from sleep on input
  *
  */

@@ -81,9 +85,10 @@
   "'W'          write EEPROM scirpt line\n"
   "'b'          set brightness (v2)\n"
   "'.'          set which LED to act on (0=all) (v2)\n"
+  "'%'          return free RAM (v2)\n"
   "'s'/'S'      scan i2c bus for 1st BlinkM / search for devices\n"
   "'@<nn>'      select which BlinkM addr to talk on\n"
-  "'!'          return BlinkM to factory settings\n"
+  "'!'          return BlinkM to factory settings\n"
   "'?'          for this help msg\n\n"
                       ));
 }
@@ -98,13 +103,13 @@
 }

 // look for the first blinkm on the i2c bus and set up talk to it
-void lookForBlinkM()
+void lookForBlinkM()
 {
   Serial.print(F("Looking for a BlinkM: "));
   int ad = blinkm.FindFirstI2CDevice();
   if( ad == -1 ) {
     Serial.println(F("No I2C devices found"));
-  } else {
+  } else {
     Serial.print(F("Device found at addr "));
     Serial.println( ad, DEC);
     //blinkm_addr = ad;
@@ -136,7 +141,7 @@
   /*
   byte addr = blinkm.getAddress(blinkm_addr);
   if( addr != blinkm_addr ) {
-    if( addr == -1 )
+    if( addr == -1 )
       Serial.println("\r\nerror: no response");
     else if( addr != blinkm_addr ) {
       Serial.print("\r\nerror: addr mismatch, addr received: ");
@@ -147,6 +152,7 @@
   printCmdPrompt();
 }

+//
 void printCmdPrompt()
 {
     Serial.print("BlinkM addr ");
@@ -154,6 +160,20 @@
     Serial.print(F(": cmd> "));
 }

+
+//
+// if 6-digit color, assume hex, otherwise any num
+int str_to_nums(int32_t* buffer, char *str, int buflen)
+{
+    char    *s;
+    int     pos = 0;
+    while((s = strtok(str, ", ")) != NULL && pos < buflen){
+        str = NULL;
+        buffer[pos++] = strtol(s, NULL, strlen(s)==6 ? 16 : 0); // parse as hexstring
+    }
+    return pos;
+}
+
 // arduino loop func
 void loop()
 {
@@ -161,23 +181,26 @@

   if( !Serial.available() ) { return; }
   serInStr = Serial.readStringUntil('\n');
+  serInStr.trim();
   Serial.println(serInStr);

   char cmd = serInStr[0];  // first char is command
-
+
   // argument parsing
-
-  //char* str = serInStr;
+
   const char* str = serInStr.c_str();
-  while( *++str == ' ' );  // go past any intervening whitespace
-  if( strlen(str) >= 6 ) { // 6 chars in a hex color code
-      //str[6] = '\0';
-      num = strtol(str, NULL, 16); // parse color
-  } else {
-      num = atoi(str);
-  }
-
+  char str_work[40];
+  strcpy(str_work, str+1);
+  int32_t nums[8];
+  int n = str_to_nums( nums, str_work, 8);
+
+  num = nums[0]; // by default, assuming we got a hex string
+  if( n > 1 )  {  // we parsed more than a single number, so make it a single number
+      num = (nums[0] << 16 ) | (nums[1] << 8) | (nums[0] << 0);
+  }
+
   // command parsing
+
   if( cmd == '?' ) {
       help();
   }
@@ -185,19 +208,19 @@
       byte a = (num >> 16) & 0xff;
       byte b = (num >>  8) & 0xff;
       byte c = (num >>  0) & 0xff;
-
+
       if( cmd == 'c' ) {
           Serial.print(F("Fade to r,g,b:"));
           blinkm.fadeToRGB( a,b,c );
-      }
+      }
       else if( cmd == 'h' ) {
           Serial.print(F("Fade to h,s,b:"));
           blinkm.fadeToHSB( a,b,c );
-      }
+      }
       else if( cmd == 'C' ) {
           Serial.print(F("Random by r,g,b:"));
           blinkm.fadeToRandomRGB( a,b,c );
-      }
+      }
       else if( cmd == 'H' ) {
           Serial.print(F("Random by h,s,b:"));
           blinkm.fadeToRandomHSB( a,b,c );
@@ -227,7 +250,7 @@
       Serial.println(F("Stop script & turn off"));
       blinkm.stopScript();
       blinkm.fadeToRGB( 0,0,0 );
-  }
+  }
   else if( cmd == 'g' ) {
       Serial.print(F("Current color: "));
       byte r,g,b;
@@ -243,7 +266,7 @@
       Serial.print(F("  scriptline: duration:")); Serial.print(line.dur);
       Serial.print(F(" cmd:")); Serial.print((char)line.cmd[0]);
       for( int i=0; i<4; i++) {
-          Serial.print(','); Serial.print(line.cmd[i]);
+          Serial.print(','); Serial.print(line.cmd[i]);
       }
       Serial.println();
   }
@@ -269,8 +292,8 @@
   }
   else if( cmd == 'a' ) {
       Serial.print(F("Address: "));
-      //num = blinkm.getAddress(0);
-      num = blinkm.getAddress();
+      //num = blinkm.getAddress(0);
+      num = blinkm.getAddress();
       Serial.println(num);
   }
   else if( cmd == '@' ) {
@@ -278,12 +301,12 @@
       Serial.println(num,DEC);
       blinkm.talkTo( num );
   }
-  else if( cmd == 'Z' ) {
+  else if( cmd == 'Z' ) {
       Serial.print(F("BlinkM version: "));
       num = blinkm.getVersion();
       if( num == -1 )
           Serial.println(F("couldn't get version"));
-      Serial.print( (char)(num>>8) );
+      Serial.print( (char)(num>>8) );
       Serial.println( (char)(num&0xff) );
   }
   else if( cmd == 'B' ) {
@@ -293,13 +316,13 @@
   else if( cmd == 'i' ) {
       Serial.print(F("get Inputs: "));
       byte inputs[4];
-      blinkm.getInputs(inputs);
+      blinkm.getInputs(inputs);
       for( byte i=0; i<4; i++ ) {
           Serial.print(inputs[i],HEX);
           Serial.print( (i<3)?',':'\n');
       }
   }
-  else if( cmd == 's' ) {
+  else if( cmd == 's' ) {
       lookForBlinkM();
   }
   else if( cmd == 'S' ) {
@@ -311,7 +334,7 @@
       Serial.println(F("Doing Factory Reset"));
       blinkm.doFactoryReset();
   }
-  else if( cmd == '.' ) {
+  else if( cmd == '.' ) {
       Serial.print(F("Set LEDn: "));
       Serial.println(num, BIN);
       blinkm.setLEDn( num );
@@ -325,7 +348,7 @@
       Serial.print("Free RAM: ");
       uint8_t addr = blinkm.getAddress();
       Wire.beginTransmission(addr);
-      Wire.write('@');
+      Wire.write('%');
       Wire.endTransmission();
       Wire.requestFrom(addr, (byte)2);
       while( Wire.available() < 2 ) ;
@@ -333,12 +356,12 @@
       num |= (Wire.read() << 8);
       Serial.println(num);
   }
-
-  else {
+
+  else {
       Serial.print(F("Unrecognized cmd '")); Serial.print(serInStr); Serial.println("'");
   }
   //serInStr[0] = 0;  // say we've used the string
-
+
   printCmdPrompt();
-
-}
+
+}


Added a way to define static IPs.

Added a way to define static IPs.

--- Alicorn.ino
+++ Alicorn.ino
@@ -174,6 +174,7 @@
 char* host;
 char* ssid[COUNT_WIFI];
 char* pass[COUNT_WIFI];
+char* conf[COUNT_WIFI];

 // Timers
 os_timer_t timer;
@@ -257,6 +258,7 @@
 bool checkInterval(int *counter, int interval);
 void resetAverage();
 void geigerClick();
+IPAddress getIPFromString(char* addressString, int id);

 // String Manipulation
 String formatNumbers(long number, int compact, bool usePrefix, bool useSuffix, String suffix);
@@ -361,6 +363,11 @@

 void geigerClick() {
     data.cpmNow++;
+}
+
+IPAddress getIPFromString(char* addressString, int id) {
+    String address = splitData(String(addressString), '|', id);
+    return IPAddress(splitData(address, '.', 0).toInt(), splitData(address, '.', 1).toInt(), splitData(address, '.', 2).toInt(), splitData(address, '.', 3).toInt());
 }

 /* =====================
@@ -499,10 +506,18 @@

 void setupWiFi() {
     host    = WIFI_HOST;
-    ssid[0] = WIFI_SSID_0;
-    ssid[1] = WIFI_SSID_1;
-    pass[0] = WIFI_PASS_0;
-    pass[1] = WIFI_PASS_1;
+
+    ssid[0] = WIFI_0_SSID;
+    pass[0] = WIFI_0_PASS;
+    conf[0] = WIFI_0_CONF;
+
+    ssid[1] = WIFI_1_SSID;
+    pass[1] = WIFI_1_PASS;
+    conf[1] = WIFI_1_CONF;
+
+    ssid[2] = WIFI_2_SSID;
+    pass[2] = WIFI_2_PASS;
+    conf[2] = WIFI_2_CONF;
 }

 void setupDevices() {
@@ -595,8 +610,20 @@
     WiFi.mode(WIFI_STA);
     WiFi.hostname(host);

-    if (settings.wifi < COUNT_WIFI)
+    if (settings.wifi < COUNT_WIFI) {
+        if (conf[settings.wifi] != "DHCP") {
+            String address;
+
+            IPAddress ipLocal =   getIPFromString(conf[settings.wifi], 0);
+            IPAddress ipGateway = getIPFromString(conf[settings.wifi], 1);
+            IPAddress ipSubnet =  getIPFromString(conf[settings.wifi], 2);
+            IPAddress ipDNS1 =    getIPFromString(conf[settings.wifi], 3);
+            IPAddress ipDNS2 =    getIPFromString(conf[settings.wifi], 4);
+
+            WiFi.config(ipLocal, ipGateway, ipSubnet, ipDNS1, ipDNS2);
+        }
         WiFi.begin(ssid[settings.wifi], pass[settings.wifi]);
+    }
 }

 /* ===========


code into separate function; function HexDump() added

--- Flasher.ino
+++ Flasher.ino
@@ -56,10 +56,77 @@
   Serial << F("Starting ...") << endl;
 }

-uint8_t addr = 0x01;
+// data buffer
+uint8_t eepromData[512];
+uint32_t eepromAddr = 0;

 /**  */
 void loop() {
+
+  static bool first = true;
+
+  if ( first ) {
+
+    for ( int i=0; i<sizeof(eepromData); ++i )
+      eepromData[i] = (uint8_t)(i & 0xff);
+
+    HexDump(eepromData, sizeof(eepromData), eepromAddr);
+
+    first = false;
+  }
+
+  testAddressLatches();
+}
+
+/** Function to create hex dump from data, organized as 8 bit words. */
+void HexDump(uint8_t *data,size_t length,uint32_t addr) {
+
+  for ( size_t j=0; j<length/16+1; ++j ) {
+
+    if ( j*16 >= length ) break;
+
+    // to be fixed: https://forum.arduino.cc/index.php?topic=38107.0
+    Serial.print(F("0x"));
+    if ( addr+j*16 < 0x1000 )
+      Serial.print(F("0"));
+    if ( addr+j*16 < 0x100 )
+      Serial.print(F("0"));
+    if ( addr+j*16 < 0x10 )
+      Serial.print(F("0"));
+    Serial.print(addr+j*16, HEX);   // output real address
+
+    for (size_t i=0; i<16; ++i ) {  // output binary data, 1-byte format
+      if ( i == 8 )
+        Serial.print( " -");
+      if ( j*16+i >= length )
+        Serial.print(F("     "));
+      else {
+        Serial.print(F(" 0x"));
+        if ( data[j*16+i] < 0x10 )
+          Serial.print(F("0"));
+        Serial.print(data[j*16+i], HEX );
+      }
+    }
+
+    Serial.print(F("  "));
+
+    for (size_t i=0; i<16; ++i ) {  // output char representation (if any)
+
+      if ( j*16+i >= length ) break;
+
+      if ( data[j*16+i]<0x20 || data[j*16+i]>0x7f )
+        Serial.print(F("."));
+      else
+        Serial.write(data[j*16+i]);
+    }
+    Serial.println();
+  }
+}
+
+/** Test code to test the address latching unit. */
+void testAddressLatches() {
+
+  static uint8_t addr = 0x01;

 #ifdef DEBUG
   Serial.print("0x");
@@ -78,10 +145,11 @@

   eeprom.setAddressHSB(addr);

-  delay(2500);
-
   addr <<= 1;
   //addr += 1;

   if ( !addr ) addr = 0x01;
-}
+
+  delay(2500);
+}
+


Another Typo

Another Typo

--- src/WiFiSensor/WiFiSensor.ino
+++ src/WiFiSensor/WiFiSensor.ino
@@ -108,7 +108,7 @@
     case 2:
       // Exception Reset, GPIO status won't change
       Serial.println("Exception Reset");
-	  sWebOverride = true;
+	  dsWebOverride = true;
 	  dsOverrideCycleCount = 0;
       ESP.restart();
       break;


Remove unnecessary files

Remove unnecessary files

--- new_version/BMP180.ino
+++ new_version/BMP180.ino
@@ -1,380 +0,0 @@
-#include <SPI.h>
-#include <nRF24L01.h>
-#include <RF24.h>
-#include <RF24_config.h>
-#include <Wire.h>
-// BMP180 read/write i2c bus addres
-#define BMP180_READ_ADDR 0xF7
-#define BMP180_WRITE_ADDR 0x77
-// BMP180 calibration registers addresses
-#define BMP180_REG_ADDR_AC1 0xAA
-#define BMP180_REG_ADDR_AC2 0xAC
-#define BMP180_REG_ADDR_AC3 0xAE
-#define BMP180_REG_ADDR_AC4 0xB0
-#define BMP180_REG_ADDR_AC5 0xB2
-#define BMP180_REG_ADDR_AC6 0xB4
-#define BMP180_REG_ADDR_B1 0xB6
-#define BMP180_REG_ADDR_B2 0xB8
-#define BMP180_REG_ADDR_MB 0xBA
-#define BMP180_REG_ADDR_MC 0xBC
-#define BMP180_REG_ADDR_MD 0xBE
-// BMP180 ADC and control registers addresses
-#define BMP180_REG_ADDR_XLSB 0xF8
-#define BMP180_REG_ADDR_LSB 0xF7
-#define BMP180_REG_ADDR_MSB 0xF6
-#define BMP180_REG_ADDR_CTRL_MEAS 0xF4
-#define BMP180_REG_ADDR_RES 0xE0
-#define BMP180_REG_ADDR_ID 0xD0
-// BMP180 control commands
-#define BMP180_CMD_TEMP 0x2E
-#define BMP180_CMD_PRESS 0x34
-
-// BH1750 i2c bus address
-#define BH1750_ADDR 0x23
-// BH1750 commands
-#define BH1750_PWR_DOWN 0x00
-#define BH1750_PWR_ON 0x01
-#define BH1750_RESET 0x07
-#define BH1750_CONT_HR 0x10
-#define BH1750_CONT_HR2 0x11
-#define BH1750_CINT_LR 0x13
-#define BH1750_1TIME_HR 0x20
-#define BH1750_1TIME_HR2 0x21
-#define BH1750_1TIME_LR 0x23
-// BH1750 resolution mods
-enum BH1750_MOD{LR = 0, HR, HR2};
-// nRF24L01 CE, CS and INT pins
-enum nRF24_ADD_PINS{CE_PIN = 7, CS_PIN = 8, INT_PIN = 2};
-
-#define DEBUG 0
-
-struct BMP180_COEFF
-{
-	int16_t ac1;
-	int16_t ac2;
-	int16_t ac3;
-	uint16_t ac4;
-	uint16_t ac5;
-	uint16_t ac6;
-	int16_t b1;
-	int16_t b2;
-	int16_t mb;
-	int16_t mc;
-	int16_t md;
-} bmp180_coeff;
-
-struct BMP180_REGS
-{
-	uint8_t xlsb;
-	uint8_t lsb;
-	uint8_t msb;
-	uint8_t ctrl;
-	uint8_t id;
-} bmp180_regs;
-
-struct measure_data
-{
-	int32_t pressure;
-	int32_t temperature;
-	float lux;
-};
-
-// init RF24 class
-RF24 radio(CE_PIN, CS_PIN);
-// adress width (in bytes)
-#define RF24_ADDR_WIDTH 4
-// default adresses for base station and slave
-uint16_t adresses[][RF24_ADDR_WIDTH] = {0x0666, 0x7777};
-
-void setup()
-{
-	// init i2c bus
-	Wire.begin();
-	// init BMP180 pressure sensor and read calibration table
-	bmp180_init();
-	bmp180_read_calibration();
-	// init radio
-	radio.begin();
-	radio.setChannel(127);
-	radio.setAddressWidth(RF24_ADDR_WIDTH);
-	radio.setPALevel(RF24_PA_MAX);
-	#if DEBUG
-	Serial.begin(115200);
-	Serial.println(F("BMP180 inited"));
-	#endif
-}
-
-void loop()
-{
-	uint8_t oss = 0;
-	uint16_t lux;
-	struct measure_data measured;
-
-	measured.pressure = bmp180_get_pressure(oss);
-	measured.temperature = bmp180_get_temp();
-	/*
-	lux = bh1750_meas_Lmode();
-	Serial.print(F("Ambient light LR: "));
-	Serial.println(lux);
-	delay(5000);
-
-	lux = bh1750_meas_Hmode();
-	Serial.print(F("Ambient light HR: "));
-	Serial.println(lux);
-	delay(5000);
-	*/
-	measured.lux = bh1750_meas_H2mode();
-
-	#if DEBUG
-	Serial.print(F("Pressure: "));
-	Serial.print(measured.pressure);
-	Serial.println(F(" Pa"));
-	Serial.print(F("Temp: "));
-	Serial.println(measured.temperature);
-	Serial.print(F("Ambient light HR2: "));
-	Serial.println(measured.lux);
-	#endif
-
-	delay(5000);
-}
-// read 2 bytes from sensor
-uint16_t bmp180_read16(uint8_t reg)
-{
-	uint16_t tmp;
-	// write address of register
-	Wire.beginTransmission(BMP180_WRITE_ADDR);
-	Wire.write(reg);
-	Wire.endTransmission();
-	// request 2 bytes
-	Wire.requestFrom(BMP180_READ_ADDR, 2);
-	tmp = Wire.read();
-	tmp = (tmp << 8) | Wire.read();
-	Wire.endTransmission();
-
-	return tmp;
-}
-// read 1 byte from sensor
-uint8_t bmp180_read8(uint8_t reg)
-{
-	uint8_t tmp;
-	// write addres of register
-	Wire.beginTransmission(BMP180_WRITE_ADDR);
-	Wire.write(reg);
-	Wire.endTransmission();
-	// request 1 byte
-	Wire.requestFrom(BMP180_READ_ADDR, 1);
-	tmp = Wire.read();
-	Wire.endTransmission();
-
-	return tmp;
-}
-// read calibration table from sensor
-void bmp180_read_calibration()
-{
-	bmp180_coeff.ac1 = bmp180_read16(BMP180_REG_ADDR_AC1);
-	bmp180_coeff.ac2 = bmp180_read16(BMP180_REG_ADDR_AC2);
-	bmp180_coeff.ac3 = bmp180_read16(BMP180_REG_ADDR_AC3);
-	bmp180_coeff.ac4 = bmp180_read16(BMP180_REG_ADDR_AC4);
-	bmp180_coeff.ac5 = bmp180_read16(BMP180_REG_ADDR_AC5);
-	bmp180_coeff.ac6 = bmp180_read16(BMP180_REG_ADDR_AC6);
-	bmp180_coeff.b1 = bmp180_read16(BMP180_REG_ADDR_B1);
-	bmp180_coeff.b2 = bmp180_read16(BMP180_REG_ADDR_B2);
-	bmp180_coeff.mb = bmp180_read16(BMP180_REG_ADDR_MB);
-	bmp180_coeff.mc = bmp180_read16(BMP180_REG_ADDR_MC);
-	bmp180_coeff.md = bmp180_read16(BMP180_REG_ADDR_MD);
-}
-// check that device on this address really bmp180 sensor
-void bmp180_init()
-{
-	bmp180_regs.id = bmp180_read8(BMP180_REG_ADDR_ID);
-	if (bmp180_regs.id != 0x55)
-	{
-		#if DEBUG
-		Serial.println(F("Not BMP180 device ID !!!"));
-		Serial.println(bmp180_regs.id);
-		#endif
-		return;
-	}
-	bmp180_regs.ctrl = bmp180_read8(BMP180_REG_ADDR_CTRL_MEAS);
-}
-// read raw temperature value from regs
-int32_t bmp180_read_raw_temp()
-{
-	int32_t ut;
-	// write temperature measurement command
-	Wire.beginTransmission(BMP180_WRITE_ADDR);
-	Wire.write(BMP180_REG_ADDR_CTRL_MEAS);
-	Wire.write(BMP180_CMD_TEMP);
-	Wire.endTransmission();
-	// wait
-	delay(5);
-	// read data
-	ut = bmp180_read16(BMP180_REG_ADDR_MSB);
-
-	return ut;
-}
-// read raw pressure value from regs
-int32_t bmp180_read_raw_press(uint8_t oss)
-{
-	uint16_t tmp;
-	int32_t up;
-	// write pressure measurement command
-	Wire.beginTransmission(BMP180_WRITE_ADDR);
-	Wire.write(BMP180_REG_ADDR_CTRL_MEAS);
-	Wire.write(BMP180_CMD_PRESS | (oss << 6));
-	Wire.endTransmission();
-	// wait depend on OSS setting
-	switch (oss) {
-		case 0:
-			delay(5);
-			break;
-		case 1:
-	    	delay(8);
-	    	break;
-	    case 2:
-	    	delay(14);
-	    	break;
-	    case 3:
-	    	delay(26);
-	    default:
-	    	delay(5);
-	    	break;
-	}
-	// read data from REGs
-	tmp = bmp180_read16(BMP180_REG_ADDR_MSB);
-	up = (uint32_t) tmp << 8;
-	up |= bmp180_read8(BMP180_REG_ADDR_XLSB);
-	up = up >> (8 - oss);
-
-	return up;
-}
-// calc B5 coeff
-int32_t bmp180_calc_b5(int32_t ut)
-{
-	int32_t x1, x2, b5;
-
-	x1 = ((ut - bmp180_coeff.ac6) * bmp180_coeff.ac5) >> 15;
-	x2 = ((int32_t) bmp180_coeff.mc << 11) / (x1 + bmp180_coeff.md);
-	b5 = x1 + x2;
-
-	return b5;
-}
-// get real value of temperature
-int32_t bmp180_get_temp()
-{
-	int32_t ut, t;
-	// read raw values of regs
-	ut = bmp180_read_raw_temp();
-	// calc real temperature
-	t = (bmp180_calc_b5(ut) + 8) >> 4;
-
-	return t;
-}
-// get real value of pressure
-int32_t bmp180_get_pressure(uint8_t oss)
-{
-	int32_t ut, up, x1, x2, x3, b5, b3, b6, p;
-	uint32_t b4, b7;
-	// read raw registers values
-	ut = bmp180_read_raw_temp();
-	up = bmp180_read_raw_press(oss);
-	// doing some *__* MAGICK *v_v*
-	b5 = bmp180_calc_b5(ut);
-	b6 = b5 - 4000;
-	x1 = (bmp180_coeff.b2 * ((b6 * b6) >> 12)) >> 11;
-	x2 = (bmp180_coeff.ac2 * b6) >> 11;
-	x3 = x1 + x2;
-	b3 = ((((bmp180_coeff.ac1 * 4) + x3) << oss) + 2) >> 2;
-	x1 = (bmp180_coeff.ac3 * b6) >> 13;
-	x2 = (bmp180_coeff.b1 * ((b6 * b6) >> 12)) >> 16;
-	x3 = ((x1 + x2) + 2) >> 2;
-	b4 = (bmp180_coeff.ac4 * (uint32_t) (x3 + 32768)) >> 15;
-	b7 = ((uint32_t) up - b3) * (50000 >> oss);
-	if (b7 < 0x80000000) {
-		p = (b7 << 1) / b4;
-	} else {
-		p = (b7 / b4) >> 1;
-	}
-	x1 = (p >> 8) * (p >> 8);
-	x1 = (x1 * 3038) >> 16;
-	x2 = (-7357 * p) >> 16;
-	p = p + ((x1 + x2 + 3791) >> 4);
-
-	return p;
-}
-
-void bh1750_write_cmd(uint8_t cmd)
-{
-	Wire.beginTransmission(BH1750_ADDR);
-	Wire.write(cmd);
-	Wire.endTransmission();
-}
-
-uint16_t bh1750_read_data()
-{
-	uint16_t tmp;
-
-	Wire.requestFrom(BH1750_ADDR, 2);
-	tmp = Wire.read();
-	tmp = (tmp << 8) | Wire.read();
-	Wire.endTransmission();
-
-	return tmp;
-}
-
-uint16_t bh1750_meas_Lmode()
-{
-	uint16_t val, tmp;
-
-	bh1750_write_cmd(BH1750_PWR_ON);
-	bh1750_write_cmd(BH1750_1TIME_LR);
-	delay(24);
-	tmp = bh1750_read_data();
-	#if DEBUG
-	Serial.print(F("Raw value: "));
-	Serial.println(tmp);
-	#endif
-	val = (float) tmp / 1.2;
-	return val;
-}
-
-uint16_t bh1750_meas_Hmode()
-{
-	uint16_t val, tmp;
-
-	bh1750_write_cmd(BH1750_PWR_ON);
-	bh1750_write_cmd(BH1750_1TIME_HR);
-	delay(180);
-	tmp = bh1750_read_data();
-	#if DEBUG
-	Serial.print(F("Raw value: "));
-	Serial.println(tmp);
-	#endif
-	val = (float) tmp / 1.2;
-	return val;
-}
-
-float bh1750_meas_H2mode()
-{
-	float val;
-	uint16_t tmp, fl;
-
-	bh1750_write_cmd(BH1750_PWR_ON);
-	bh1750_write_cmd(BH1750_1TIME_HR2);
-	delay(180);
-	tmp = bh1750_read_data();
-	#if DEBUG
-	Serial.print(F("Raw value: "));
-	Serial.println(tmp);
-	#endif
-	fl = tmp & 0x0001;
-	#if DEBUG
-	Serial.println(fl);
-	#endif
-	tmp >>= 1;
-	#if DEBUG
-	Serial.println(tmp);
-	#endif
-	val = (float) tmp / 1.2 + fl * 0.5;
-	return val;
-}


Add detection for DRV_TOUCH_ADA_RA8875

Add detection for DRV_TOUCH_ADA_RA8875

--- examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino
+++ examples/arduino/diag_ard_touch_calib/diag_ard_touch_calib.ino
@@ -31,6 +31,7 @@
 // ------------------------------------------------------------
 #if   defined(DRV_TOUCH_ADA_STMPE610)
 #elif defined(DRV_TOUCH_ADA_SIMPLE)
+#elif defined(DRV_TOUCH_ADA_RA8875)
 #elif defined(DRV_TOUCH_XPT2046_STM)
 #elif defined(DRV_TOUCH_XPT2046_PS)
 #else
@@ -799,7 +800,7 @@
 {
   snprintf(m_acTxt, MAX_STR, "ADATOUCH_X_MIN: %u", m_nTouchCalXMin);
   gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 00, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK);
-  snprintf(m_acTxt, MAX_STR, "ADATOUCH_U_MIN: %u", m_nTouchCalYMin);
+  snprintf(m_acTxt, MAX_STR, "ADATOUCH_Y_MIN: %u", m_nTouchCalYMin);
   gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 20, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK);
   snprintf(m_acTxt, MAX_STR, "ADATOUCH_X_MAX: %u", m_nTouchCalXMax);
   gslc_DrvDrawTxt(&m_gui, m_rReport.x, m_rReport.y + 40, m_pFont, m_acTxt, GSLC_TXT_DEFAULT, GSLC_COL_YELLOW, GSLC_COL_BLACK);


Update SBR.ino

Update SBR.ino

--- SBR/SBR.ino
+++ SBR/SBR.ino
@@ -121,60 +121,7 @@
     digitalWrite(stir, LOW);
     digitalWrite(air, LOW);
 }
-void fillplusair(int lvl, int airadd){//check depth and fill until level is 25gal plus stir
-  lcd.clear();
-  lcd.setCursor(0,0);
-  lcd.print("FILL ");
-  lcd.setBacklight(TEAL);//Writes fill and changes color of led screen
-  measurevol();
-  lcd.setCursor(0,1);
-  lcd.print(tank);lcd.print("gal");
-  DateTime now = rtc.now();
-  float lastair = millis();
-    while (tank<lvl){
-      digitalWrite(fillpump, HIGH);
-      measurevol();
-      lcd.setCursor(0,1);
-      lcd.print(tank);lcd.print("gal");
-      delay(3000);
-      measurevol();
-      lcd.setCursor(0,1);
-      lcd.print(tank);lcd.print("gal");
-      //digitalWrite(air,LOW);
-      if ((airadd == 1) && (millis()-lastair > 300000)){
-       digitalWrite(air,HIGH);
-       lastair = millis();
-      }
-      else if ((airadd == 1) && (millis()-lastair > 30000)){
-       digitalWrite(air,LOW);
-      }
-    }
-  digitalWrite(fillpump, LOW);
-  digitalWrite(stir, LOW);
-  digitalWrite(air, LOW);
-}
-
-void RASfill(int lvl){//check depth and fill until level is 25gal plus stir
-  //digitalWrite(stir, HIGH);
-  lcd.clear();
-  lcd.setCursor(0,0);
-  lcd.print("FILL ");
-  lcd.setBacklight(TEAL);
-  measurevol();
-  lcd.setCursor(0,1);
-  lcd.print(tank);lcd.print("gal");
-  DateTime now = rtc.now();
-    while (tank<lvl){
-      digitalWrite(fillpump, HIGH);
-      digitalWrite(air, HIGH);
-      measurevol();
-      lcd.setCursor(0,1);
-      lcd.print(tank);lcd.print("gal");
-      delay(15000);
-    }
-    digitalWrite(air, LOW);
-    digitalWrite(fillpump, LOW);
-}
+
 void periodicaeration(float ontime){//on for 15 min freq is 60 min
   ontime=ontime*60;
   lcd.clear();


Where to get the library

Where to get the library

--- examples/OLED_SSD1306_Demo/OLED_SSD1306_Demo.ino
+++ examples/OLED_SSD1306_Demo/OLED_SSD1306_Demo.ino
@@ -22,6 +22,8 @@

 See more at http://blog.squix.ch
 */
+// Install the SSD1306 library from https://github.com/squix78/esp8266-oled-ssd1306
+
 #include <Wire.h>
 #include <SPI.h>
 #include "SSD1306.h"


robust timer initialization

robust timer initialization

--- f_ATmegaTimer.ino
+++ f_ATmegaTimer.ino
@@ -18,35 +18,13 @@
  * D45 (OC5B/PL4) ------------------------- VSYNC
  *
  */
-uint16_t clock_stretch;
+volatile uint16_t clock_stretch;

 ISR(TIMER5_COMPC_vect) {
   // compare match interrupt service routine (Timer 5 C)
-  // in order to know the exact delay by subtracting clock_stretch, we must use assembly here
-
-  // C code equivalent is the following:
-
-  //   noInterrupts(); // temporary disable other high priority interrupts
-  //   TCNT4 -= clock_stretch; // this statement takes AVR microcontroller 13 clock cycles to update TCNT4 io location
-  //   interrupts(); // enable other interrupts again
-
-  asm volatile(          // number of clocks needed
-    // noInterrupts();
-    "in  r18,__SREG__\n"
-    "cli\n"
-    // TCNT4 -= clock_stretch;
-    "lds r16,%0\n"       // 2 TCNT4 is latched before this instruction
-    "lds r17,%1\n"       // 2
-    "ld  r18,Z+\n"       // 1
-    "ld  r19,Z\n"        // 1
-    "sub r16,r18\n"      // 1
-    "sbc r17,r19\n"      // 1
-    "sts %1,r17\n"       // 2
-    "sts %0,r16\n"       // 2 TCNT4 is updated after this instruction
-    // interrupts();
-    "out __SREG__,r18\n"
-    :: "M" (_SFR_MEM_ADDR(TCNT4L)), "M" (_SFR_MEM_ADDR(TCNT4H)), "z" (&clock_stretch)
-  );
+  noInterrupts(); // temporary disable other high priority interrupts
+  TCNT4 -= clock_stretch; // this statement takes AVR microcontroller 13 clock cycles to update TCNT4 io location
+  interrupts(); // enable other interrupts again
 }

 void StartSyncSignal(int vidmode)
@@ -73,14 +51,14 @@
   if (firsttime) {
     // * using an external clock source ATmega2560 has a bug that causes the first match ignored
     // WORKAROUND: toggle T5 to go beyond the first
-    for (int i = 0; i < syncTime[vidmode][SYNC_TIME_VSYNC] + 1; i++) {
+    for (int i = 0; i < syncTime[vidmode][SYNC_TIME_VSYNC]; i++) {
       TCCR4C |= _BV(FOC4C); TCCR4C |= _BV(FOC4C);
     }
     firsttime = false;
-  } else {
-    TCCR4C |= _BV(FOC4C); TCCR4C |= _BV(FOC4C);
   }
-
+
+  TCCR4C |= _BV(FOC4C); TCCR4C |= _BV(FOC4C);
+
   if (syncTime[vidmode][SYNC_TIME_STRETCH] != 0) {
     // number of ticks the 2nd last HSYNC before VSYNC longer than others
     clock_stretch = syncTime[vidmode][SYNC_TIME_STRETCH] - 13; // updating TCNT4 requires 13 clock cycles (81.25ns)
@@ -97,7 +75,7 @@
   // the following registers can be set properly only after WGMn is set
   OCR4B = syncTime[vidmode][SYNC_TIME_HSYNC] - 3; // MATCH
   OCR4C = syncTime[vidmode][SYNC_TIME_HSYNC] - 5; // ADVANCE MATCH
-  TCNT4 = syncTime[vidmode][SYNC_TIME_HSYNC] - 7; // START
+  TCNT4 = syncTime[vidmode][SYNC_TIME_HSYNC] - 6; // START
   ICR4 = syncTime[vidmode][SYNC_TIME_HSYNC] - 1; // TOP
   interrupts();
   TCCR4B |= _BV(CS40); // CS4[2:0] = 1 (no prescaling)
@@ -115,17 +93,21 @@
   TIMSK5 = 0; // disable timer 5 interrupts
   TCCR5B = 0;
   TCCR5A = _BV(COM5B0); // toggle on compare match
+  DDRL |= _BV(4); // set OC5B to output
+  noInterrupts();
   if (!(PINL & _BV(4))) { // toggle if LOW
     TCCR5C |= _BV(FOC5B);
   }
-  DDRL |= _BV(4); // set OC5B to output
+  interrupts();

   // Timer 4 (HSYNC)
   TCCR4B = 0;
   TCCR4A = _BV(COM4B0) | _BV(COM4C0); // toggle on compare match
+  DDRH |= _BV(4) | _BV(5); // set OC4B and OC4C to output
+  noInterrupts();
   if (!(PINH & _BV(4)) || !(PINH & _BV(5))) { // toggle if LOW
     TCCR4C |= (PINH & _BV(4) ? 0 : _BV(FOC4B)) | (PINH & _BV(5) ? 0 : _BV(FOC4C));
   }
-  DDRH |= _BV(4) | _BV(5); // set OC4B and OC4C to output
+  interrupts();
 }


implemented the option to place the matrix vertically

--- examples/XYMatrix/XYMatrix.ino
+++ examples/XYMatrix/XYMatrix.ino
@@ -30,6 +30,7 @@

 // Param for different pixel layouts
 const bool    kMatrixSerpentineLayout = true;
+const bool    kMatrixVertical = false;
 // Set 'kMatrixSerpentineLayout' to false if your pixels are
 // laid out all running the same way, like this:
 //
@@ -88,17 +89,29 @@
   uint16_t i;

   if( kMatrixSerpentineLayout == false) {
-    i = (y * kMatrixWidth) + x;
+    if (kMatrixVertical == false) {
+      i = (y * kMatrixWidth) + x;
+    } else {
+      i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
+    }
   }

   if( kMatrixSerpentineLayout == true) {
-    if( y & 0x01) {
-      // Odd rows run backwards
-      uint8_t reverseX = (kMatrixWidth - 1) - x;
-      i = (y * kMatrixWidth) + reverseX;
-    } else {
-      // Even rows run forwards
-      i = (y * kMatrixWidth) + x;
+    if (kMatrixVertical == false) {
+      if( y & 0x01) {
+        // Odd rows run backwards
+        uint8_t reverseX = (kMatrixWidth - 1) - x;
+        i = (y * kMatrixWidth) + reverseX;
+      } else {
+        // Even rows run forwards
+        i = (y * kMatrixWidth) + x;
+      }
+    } else { // vertical positioning
+      if ( x & 0x01) {
+        i = kMatrixHeight * (kMatrixWidth - (x+1))+y;
+      } else {
+        i = kMatrixHeight * (kMatrixWidth - x) - (y+1);
+      }
     }
   }


hw test - ir, ds18b20

hw test - ir, ds18b20

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -1,10 +1,8 @@
-
-#
 /*
 A4, A5 - I2C

 A2 - SETUP / IN
-D13 - ENTER / IN
+A0 - ENTER / IN
 D12 - DOWN / IN
 D11 - UP / IN
 D10 - IR / IN
@@ -12,29 +10,39 @@
 D4 - TEMP(DS18B20) /IN
 D3 - IR / OUT
 D2 - PIR /IN
- */
+*/

-#include <Wire.h>
+
+
+
+#include <Wire.h>
 #include <OneWire.h>
 #include <DallasTemperature.h>
 #include <LiquidCrystal_I2C.h>
 #include <IRremote.h>

 //
-#define SETUP_IN_PIN A2;
-#define ENTER_IN_PIN 13;
-#define DN_IN_PIN    12;
-#define UP_IN_PIN    11;
+int SETUP_IN_PIN = A2;
+//int ENTER_IN_PIN = A0;
+int ENTER_IN_PIN = 13;
+int UP_IN_PIN    = 12;
+int DN_IN_PIN    = 11;
+
 //
-#define IR_IN_PIN    10;
-#define PIR_IN_PIN   2;
+int IR_IN_PIN    = 10;
+int PIR_IN_PIN   = 2;

-#define BZ_OU_PIN    9;
+int BZ_OU_PIN    =  9;

 // LCD
 LiquidCrystal_I2C lcd(0x27, 20, 4);

 // IR
+#define maxLen 800
+
+volatile  unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
+volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR
+
 IRrecv irrecv(IR_IN_PIN);
 IRsend irsend;

@@ -50,7 +58,7 @@
 long startMills;
 long tv_startMills;

-byte termometru[8] =
+byte termometru[8] =
 {
   B00100,
   B01010,
@@ -65,37 +73,38 @@
 void setup()
 {

-// lcd
+  // lcd
   lcd.init();
   lcd.backlight();
   lcd.clear();
   lcd.createChar(1, termometru);
   lcd.setCursor(0, 0);
   lcd.write(1);
-// lcd
-/
+  // lcd
+
   Serial.begin (38400);
   Serial.println("TV controller Starting");
   delay(20);

+  irrecv.enableIRIn(); // Start the receiver
+
   startMills = millis();

-// pin mode
+  // pin mode

   pinMode(SETUP_IN_PIN, INPUT_PULLUP);
   pinMode(ENTER_IN_PIN, INPUT_PULLUP);
-  pinMode(DN_IN_PIN, INPUT_PULLUP);
+  pinMode(DN_IN_PIN, INPUT_PULLUP);
   pinMode(UP_IN_PIN, INPUT_PULLUP);
-  pinMode(PIR_IN_PIN, INPUT_PULLUP)
+  pinMode(PIR_IN_PIN, INPUT_PULLUP);

-  pinMode(BZ_OU_PIN, OUTPUT);
-
-  digitalWrite(BZ_OU_PIN, LOW)
+  pinMode(BZ_OU_PIN, OUTPUT);
+  digitalWrite(BZ_OU_PIN, HIGH);

-// temp
+  // temp
   sensors.begin();
-  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
+  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
   sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
   sensors.requestTemperatures();
   tempCinside  = sensors.getTempC(insideThermometer);
@@ -104,21 +113,61 @@
     Serial.println("Failed to read from sensor!");
     return;
   }
-// temp
+  // temp

- }
+}

 void loop()
 {
+  /*
+   *
+    pinMode(SETUP_IN_PIN, INPUT_PULLUP);
+    pinMode(ENTER_IN_PIN, INPUT_PULLUP);
+    pinMode(DN_IN_PIN, INPUT_PULLUP);
+    pinMode(UP_IN_PIN, INPUT_PULLUP);
+    pinMode(PIR_IN_PIN, INPUT_PULLUP);
+   *
+   */
+  /*
+    int x = digitalRead(ENTER_IN_PIN);
+    Serial.println(x);
+    //getdalastemp();
+    //Serial.println(tempCinside);
+    delay(1000);
+  */
+
+  decode_results results;
+
+  if (irrecv.decode(&results)) {
+    dumpInfo(&results);
+
+  }

 }

+void  dumpInfo (decode_results *results)
+{
+  // Check if the buffer overflowed
+  if (results->overflow) {
+    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN");
+    return;
+  }
+
+  if ( results->bits > 0 && results->bits == 32 ) {
+
+    // Show Code & length
+    Serial.print("Code      : ");
+    Serial.println(results->value, HEX);
+  }
+  delay(50);
+  irrecv.resume();
+}

 void getdalastemp()
 {
-    sensors.requestTemperatures();
-    tempCinside  = sensors.getTempC(insideThermometer);
+  sensors.requestTemperatures();
+  tempCinside  = sensors.getTempC(insideThermometer);

   if ( isnan(tempCinside) ) {
     Serial.println("Failed to read from sensor!");
@@ -129,9 +178,10 @@
 void alarm_set()
 {
   Serial.println("===> alarm_set");
-
+
+  digitalWrite(BZ_OU_PIN, LOW);
+  delay(100);
   digitalWrite(BZ_OU_PIN, HIGH);
-  delay(100);
-  digitalWrite(BZ_OU_PIN, LOW);
 }

+


Delete PictureViewer.ino

Delete PictureViewer.ino

--- PictureViewer.ino
+++ PictureViewer.ino
@@ -1,457 +0,0 @@
-/* Picture Viewer
-
-    By GK Grotsky
-    8/14/16
-
-Picture Viewer displays bitmap (bmp) files on a 1.8” TFT display.
-The files are read from a SD card. Both the TFT display and the SD card
-use the SPI protocol. The files can be displayed  randomly or sequentially.
-Note: The picture file names must have the format picxx.bmp, where xx is a number
-      from 1 to 99.
-      If you want a picture theme, add a text file named theme.txt containing
-      the theme up to 22 charactors.
-
-  https://github.com/Grommet123/PictureViewer
-
-  The MIT License (MIT)
-
-  Permission is hereby granted, free of charge, to any person obtaining a copy
-  of this software and associated documentation files (the "Software"), to deal
-  in the Software without restriction, including without limitation the rights
-  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-  copies of the Software, and to permit persons to whom the Software is
-  furnished to do so, subject to the following conditions:
-
-  The above copyright notice and this permission notice shall be included in all
-  copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-  SOFTWARE.
-
-*/
-#include "PictureViewer.h"
-#include <Adafruit_GFX.h>    // Core graphics library
-#include <Adafruit_ST7735.h> // Hardware-specific library
-
-Adafruit_ST7735 tft(TFT_CS, TFT_DC, TFT_RST);
-
-int numberOfFiles = 0;
-int pastMode = HIGH;
-int pastTest = HIGH;
-bool SD_OK = false;
-String themeField;
-
-// The setup (runs once at start up)
-void setup(void) {
-  File root, entry, themeName;
-
-  pinMode(TEST_PIN, INPUT);
-  pinMode(MODE_PIN, INPUT);
-  Serial.begin(9600);
-  tft.initR(INITR_BLACKTAB);
-
-  // Print program name and version
-  Serial.println("Picture Viewer");
-  Serial.print("Version ");
-  Serial.println(VERSION);
-
-  // Initialize the SD card
-  Serial.print("Initializing SD card...");
-  if (!SD.begin(SD_CS)) {
-    Serial.println("failed!");
-    SD_OK = false;
-    numberOfFiles = 99;
-    themeField = "??????";
-    displaySplashScreen();
-    return;
-  }
-  Serial.println("OK!");
-  SD_OK = true;
-
-  // Count the number of files on the SD card
-  root = SD.open("/");
-  while (true) {
-    entry = root.openNextFile();
-    if (!entry) {
-      // no more files
-      break;
-    }
-    // Do not count any non-picxx.bmp files
-    if ((strncmp(entry.name(), "PIC", 3) == 0)) {
-      numberOfFiles++;
-    }
-    entry.close();
-  }
-  root.close();
-
-  // Get and store the pictures theme
-  if ((themeName = SD.open("theme.txt", FILE_READ)) != NULL) {
-    while (themeName.available()) {
-      uint8_t tempByte = read8(themeName); // Reads one byte
-      themeField += (char)tempByte; // Store byte for displayFileName
-    }
-    themeName.close();
-  }
-  else { // No theme file, so set theme field to "?"
-    themeField = "??????";
-  }
-
-  // Print # of files and mode
-  Serial.print("Number of files = ");
-  if ((digitalRead(TEST_PIN) == HIGH)) {
-    Serial.println('1');
-  }
-  else {
-    Serial.println(numberOfFiles);
-  }
-
-  tft.setRotation(0); // Portrait
-
-  // Seed random number generator
-  randomSeed(analogRead(A0));
-
-  if (digitalRead(TEST_PIN) == LOW) {
-    Serial.print("Mode = ");
-    Serial.println((digitalRead(MODE_PIN)) ? "Random" : "Sequential");
-    Serial.println();
-    pastMode = !(digitalRead(MODE_PIN));
-  }
-  else {
-    Serial.print("Mode = ");
-    Serial.println("TEST");
-    Serial.println();
-    pastTest = !(digitalRead(TEST_PIN));
-  }
-  pastMode = digitalRead(MODE_PIN);
-}  // setup
-
-// The loop (runs forever and a day :-))
-void loop() {
-
-  char fileName[] = "pic";
-  char randomNumberChar[] = "  ";
-  char listNumberChar[] = "  ";
-  static long lastRandomNumber = 0;
-  static int fileNumber = 1;
-
-  if (digitalRead(TEST_PIN) == LOW) {  // Used for debugging
-    // Check if the mode switch has changed
-    if ((digitalRead(MODE_PIN) != pastMode) || (digitalRead(TEST_PIN) != pastTest)) {
-      Serial.print("Mode = ");
-      Serial.println((digitalRead(MODE_PIN)) ? "Random" : "Sequential");
-      Serial.println();
-      // Display splash screen
-      displaySplashScreen();
-      pastMode = digitalRead(MODE_PIN);
-      pastTest = digitalRead(TEST_PIN);
-    }
-    // Check fo mode
-    if (digitalRead(MODE_PIN) == HIGH) {
-      // Random was selected, get random number
-      long randNumber = random(1, numberOfFiles + 1);
-      // If random number repeats, try again
-      while (randNumber == lastRandomNumber) {
-        randNumber = random(1, numberOfFiles + 1);
-      }
-      lastRandomNumber = randNumber;
-      // Convert it to a string
-      sprintf(randomNumberChar, "%d", randNumber);
-      strncat(fileName, randomNumberChar, 3);
-      strncat(fileName, ".bmp", 4);
-      if (bmpDraw(fileName, 0, 0)) {
-        delay(DELAY_TIME);
-        fileNumber = 1;
-      }
-    }
-    // Sequential was selected, dislpay files from begining to end
-    else {
-      // Convert list of files to a string
-      sprintf(listNumberChar, "%d", fileNumber);
-      strncat(fileName, listNumberChar, 3);
-      strncat(fileName, ".bmp", 4);
-      if (bmpDraw(fileName, 0, 0)) delay(DELAY_TIME);
-      fileNumber++;
-      if (fileNumber > numberOfFiles) fileNumber = 1;
-    }
-  }
-  else { // Uesd to debug a bmp file
-    if (digitalRead(TEST_PIN) != pastTest) {
-      displaySplashScreen(Test);
-      fileNumber = 1;
-      pastTest = digitalRead(TEST_PIN);
-    }
-    if (bmpDraw(TESTPICTURE, 0, 0)) delay(DELAY_TIME);
-  }
-}  // loop
-
-bool bmpDraw(char *filename, uint8_t x, uint8_t y) {
-  File     bmpFile;
-  int      bmpWidth, bmpHeight;   // W+H in pixels
-  uint8_t  bmpDepth;              // Bit depth (currently must be 24)
-  uint32_t bmpImageoffset;        // Start of image data in file
-  uint32_t rowSize;               // Not always = bmpWidth; may have padding
-  uint8_t  sdbuffer[3 * BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
-  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
-  bool     goodBmp = false;       // Set to true on valid header parse
-  bool     flip    = true;        // BMP is stored bottom-to-top
-  int      w, h, row, col;
-  uint8_t  r, g, b;
-  uint32_t pos = 0;
-
-  if ((x >= tft.width()) || (y >= tft.height())) return;
-
-  Serial.println();
-  Serial.print("Loading image '");
-  Serial.print(filename);
-  Serial.println('\'');
-
-  // Open requested file on SD card
-  if ((bmpFile = SD.open(filename)) == NULL) {
-    Serial.print("File not found");
-    displayFileName(filename, false);
-    return (false);
-  }
-
-  // Parse BMP header
-  if (read16(bmpFile) == 0x4D42) { // BMP signature
-    Serial.print("File size: ");
-    Serial.println(read32(bmpFile));
-    (void)read32(bmpFile); // Read & ignore creator bytes
-    bmpImageoffset = read32(bmpFile); // Start of image data
-    Serial.print("Image Offset: ");
-    Serial.println(bmpImageoffset, DEC);
-    // Read DIB header
-    Serial.print("Header size: ");
-    Serial.println(read32(bmpFile));
-    bmpWidth  = read32(bmpFile);
-    bmpHeight = read32(bmpFile);
-    if (read16(bmpFile) == 1) { // # planes -- must be '1'
-      bmpDepth = read16(bmpFile); // bits per pixel
-      Serial.print("Bit Depth: ");
-      Serial.println(bmpDepth);
-      if ((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed
-
-        goodBmp = true; // Supported BMP format -- proceed!
-        Serial.print("Image size: ");
-        Serial.print(bmpWidth);
-        Serial.print("W ");
-        Serial.print("x ");
-        Serial.print(bmpHeight);
-        Serial.print('H');
-        Serial.println(" Pixels");
-
-        displayFileName(filename, true, bmpWidth, bmpHeight, numberOfFiles);
-
-        // BMP rows are padded (if needed) to 4-byte boundary
-        rowSize = (bmpWidth * 3 + 3) & ~3;
-
-        // If bmpHeight is negative, image is in top-down order.
-        // This is not canon but has been observed in the wild.
-        if (bmpHeight < 0) {
-          bmpHeight = -bmpHeight;
-          flip      = false;
-        }
-
-        // Crop area to be loaded
-        w = bmpWidth;
-        h = bmpHeight;
-        if ((x + w - 1) >= tft.width())  w = tft.width()  - x;
-        if ((y + h - 1) >= tft.height()) h = tft.height() - y;
-
-        // Set TFT address window to clipped image bounds
-        tft.setAddrWindow(x, y, x + w - 1, y + h - 1);
-
-        for (row = 0; row < h; row++) { // For each scanline...
-
-          // Seek to start of scan line.  It might seem labor-
-          // intensive to be doing this on every line, but this
-          // method covers a lot of gritty details like cropping
-          // and scanline padding.  Also, the seek only takes
-          // place if the file position actually needs to change
-          // (avoids a lot of cluster math in SD library).
-          if (flip) // Bitmap is stored bottom-to-top order (normal BMP)
-            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
-          else     // Bitmap is stored top-to-bottom
-            pos = bmpImageoffset + row * rowSize;
-          if (bmpFile.position() != pos) { // Need seek?
-            bmpFile.seek(pos);
-            buffidx = sizeof(sdbuffer); // Force buffer reload
-          }
-
-          for (col = 0; col < w; col++) { // For each pixel...
-            // Time to read more pixel data?
-            if (buffidx >= sizeof(sdbuffer)) { // Indeed
-              bmpFile.read(sdbuffer, sizeof(sdbuffer));
-              buffidx = 0; // Set index to beginning
-            }
-
-            // Convert pixel from BMP to TFT format, push to display
-            b = sdbuffer[buffidx++];
-            g = sdbuffer[buffidx++];
-            r = sdbuffer[buffidx++];
-            tft.pushColor(tft.Color565(r, g, b));
-          } // end pixel
-        } // end scanline
-      } // end goodBmp
-    }
-  }
-
-  bmpFile.close();
-  if (!goodBmp) {
-    Serial.println("BMP format not recognized.");
-    return (false);
-  }
-  return (true);
-}  // bmpDraw
-
-// These read 16-, 32-bit and 8- types from the SD card file.
-// BMP data is stored little-endian, Arduino is little-endian too.
-// May need to reverse subscript order if porting elsewhere.
-
-uint8_t read8(File f) {
-  uint8_t result;
-  ((uint8_t *)&result)[0] = f.read(); // One byte
-  return result;
-}
-
-uint16_t read16(File f) {
-  uint16_t result;
-  ((uint8_t *)&result)[0] = f.read(); // LSB
-  ((uint8_t *)&result)[1] = f.read(); // MSB
-  return result;
-}
-
-uint32_t read32(File f) {
-  uint32_t result;
-  ((uint8_t *)&result)[0] = f.read(); // LSB
-  ((uint8_t *)&result)[1] = f.read();
-  ((uint8_t *)&result)[2] = f.read();
-  ((uint8_t *)&result)[3] = f.read(); // MSB
-  return result;
-}
-
-// Displays the splash screen
-void displaySplashScreen(displayModeEnum displayMode) {
-  byte maxLeghtOfTheme;
-
-  tft.setTextWrap(false);
-  tft.fillScreen(ST7735_BLACK);
-  tft.setCursor(0, 5);
-  tft.setTextColor(ST7735_RED);
-  tft.setTextSize(2);
-  tft.println("Picture");
-  tft.setCursor(15, 20);
-  tft.println("Viewer");
-  tft.setTextSize(1);
-  tft.setCursor(20, 40);
-  tft.print("Version ");
-  tft.println(VERSION);
-  tft.setTextColor(ST7735_YELLOW);
-  maxLeghtOfTheme = min(themeField.length(), MAXTHEMELENGTH); // Limit characters
-  tft.setCursor((HALFTHEMELENGTH - (maxLeghtOfTheme / 2)) * LCDWIDTHOFFSET, 55);
-  tft.println(themeField);
-  tft.setTextSize(2);
-  tft.setCursor(0, 75);
-  tft.setTextColor(ST7735_BLUE);
-  tft.println("GK Grotsky");
-  tft.setCursor(0, 100);
-  tft.setTextColor(ST7735_GREEN);
-  tft.println("Mode:");
-  tft.setCursor(0, 115);
-  if (displayMode == NonTest) {
-    tft.println((digitalRead(MODE_PIN)) ? "Random" : "Sequential");
-  }
-  else {
-    tft.println("Test");
-  }
-  tft.setTextColor(ST7735_CYAN);
-  tft.setTextSize(1);
-  if (SD_OK) {
-    tft.setCursor(15, 140);
-    tft.print("# of pictures ");
-    tft.println(numberOfFiles);
-    tft.setCursor(30, 150);
-    tft.println("SD Card OK");
-  }
-  else {
-    tft.setCursor(30, 150);
-    tft.println("SD Card Fail");
-  }
-  delay(10000);
-}
-
-// Displays the file name among other things
-void displayFileName(char *fileName, bool fileFound = true,
-                     int bmpWidth = 0, int bmpHeight = 0, int numberOfFiles = 99) {
-  static long lastRandomNumber;
-  long randomColor;
-  byte maxLeghtOfTheme;
-  unsigned int textColor[] = {
-    ST7735_BLUE,
-    ST7735_RED,
-    ST7735_GREEN,
-    ST7735_CYAN,
-    ST7735_MAGENTA,
-    ST7735_YELLOW,
-    ST7735_WHITE
-  };
-
-  randomColor =  random(0, 7);
-  // If random number repeats, try again
-  while (randomColor == lastRandomNumber) {
-    randomColor = random(0, 7);
-  }
-  lastRandomNumber = randomColor;
-  tft.setTextWrap(false);
-  tft.fillScreen(ST7735_BLACK);
-  tft.setTextColor(textColor[randomColor]);
-  tft.setTextSize(1);
-  if (!digitalRead(TEST_PIN)) {
-    if (digitalRead(MODE_PIN)) { // Not test mode
-      tft.setCursor(45, 0);
-      tft.println("Random");
-    }
-    else {
-      tft.setCursor(30, 0);
-      tft.println("Sequential");
-    }
-  } // Test mode
-  else {
-    tft.setCursor(50, 0);
-    tft.println("Test");
-  }
-  tft.setCursor(0, 15);
-  // Center the theme
-  maxLeghtOfTheme = min(themeField.length(), MAXTHEMELENGTH); // Limit characters
-  tft.setCursor((HALFTHEMELENGTH - (maxLeghtOfTheme / 2)) * LCDWIDTHOFFSET, 20);
-  tft.println(themeField);
-  tft.setTextSize(2);
-  tft.setCursor(10, 50);
-  tft.println(fileName);
-  tft.setTextSize(1);
-  tft.setCursor(50, 70);
-  tft.print("of ");
-  tft.println(numberOfFiles);
-  if (!fileFound) {
-    tft.setCursor(15, 110);
-    tft.println("File not found");
-  }
-  else {
-    tft.setCursor(10, 110);
-    tft.println("File Size: ");
-    tft.setCursor(10, 120);
-    tft.print(bmpWidth);
-    tft.print("W ");
-    tft.print("x ");
-    tft.print(bmpHeight);
-    tft.print('H');
-    tft.println(" Pixels");
-  }
-  delay(5000);
-  tft.fillScreen(ST7735_BLACK);
-}


Update selftest.ino

Update selftest.ino

--- examples/selftest/selftest.ino
+++ examples/selftest/selftest.ino
@@ -61,7 +61,7 @@
 bool test_zero_offset() {
   Tsunami.measureCurrentVoltage();
   delay(200);
-  assert_nearly_equal("input_offset", Tsunami.measureCurrentVoltage(), 0, 75);
+  assert_nearly_equal("input_offset", Tsunami.measureCurrentVoltage(), 0, 100);
   return true;
 }

@@ -70,10 +70,10 @@
   int offset = Tsunami.measureCurrentVoltage();
   Tsunami.setOffset(-1000);
   delay(200);
-  assert_nearly_equal("output_offset_neg", Tsunami.measureCurrentVoltage(), offset - 1325, 75);
+  assert_nearly_equal("output_offset_neg", Tsunami.measureCurrentVoltage(), offset - 1325, 100);
   Tsunami.setOffset(1000);
   delay(200);
-  assert_nearly_equal("output_offset_pos", Tsunami.measureCurrentVoltage(), offset + 1325, 75);
+  assert_nearly_equal("output_offset_pos", Tsunami.measureCurrentVoltage(), offset + 1325, 100);
   return true;
 }

@@ -81,7 +81,7 @@
   Tsunami.setFrequency(32768);
   Tsunami.setAmplitude(6000);
   delay(500);
-  assert_nearly_equal("input_amp_6", Tsunami.measurePeakVoltage(), 3048, 75);
+  assert_nearly_equal("input_amp_6", Tsunami.measurePeakVoltage(), 3048, 100);

   // TODO: Figure out why we don't get consistent values for this reading
   Tsunami.setAmplitude(1000);
@@ -114,7 +114,7 @@
   Tsunami.reset(true); Tsunami.reset(false);
   delay(100);
   assert_nearly_equal("input_freq_1m", (int32_t)Tsunami.measureFrequency(), 1000000l, 2l);
-  assert_nearly_equal("input_phase_1m", (int16_t)(1000 * Tsunami.measurePhase()), 730, 50);
+  assert_nearly_equal("input_phase_1m", (int16_t)(1000 * Tsunami.measurePhase()), 1000, 50);
 }

 test_t tests[] = {


dont know why yet, but seems like first connect times out often, so fail faster and keep retrying

--- examples/skynetim/skynetim.ino
+++ examples/skynetim/skynetim.ino
@@ -26,6 +26,7 @@
  * #define SKYNETCLIENT_DEBUG
  */

+#include <utility/w5100.h>
 #include <EEPROM.h>
 #include <aJSON.h>
 #include "Ethernet.h"
@@ -53,6 +54,8 @@
       ;
   }

+  W5100.setRetransmissionTime(0x7D);
+
   // print your local IP address:
   Serial.print(F("My IP address: "));
   for (byte thisByte = 0; thisByte < 4; thisByte++) {
@@ -63,15 +66,16 @@
   Serial.println();

   skynetclient.setMessageDelegate(onMessage);
-  if (!skynetclient.connect(hostname, port)){
-    Serial.println(F("Not connected :("));
-    while(1); //no use in moving on
-  }else
-  {
+
+  bool status;
+  do {
+    status=skynetclient.connect(hostname, port);
+  }while(!status);
+
     Serial.println(F("Connected!"));
 	Serial.println(skynetclient.uuid);
 	Serial.println(skynetclient.token);
-  }
+
 }

 aJsonObject *msg;


backed out accidental change to waterelf

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -148,7 +148,7 @@

 /////////////////////////////////////////////////////////////////////////////
 // pH sensor stuff //////////////////////////////////////////////////////////
-const byte pH_Add = 0x29;  // change this to match ph ADC address
+const byte pH_Add = 0x4E;  // change this to match ph ADC address
 int pH7Cal = 2048; // assume ideal probe and amp conditions 1/2 of 4096
 int pH4Cal = 1286; // ideal probe slope -> this many 12bit units on 4 scale
 float pHStep = 59.16; // ideal probe slope


--- lampka.ino
+++ lampka.ino
@@ -128,11 +128,11 @@

 }

-void sendPixel( uint8_t r, uint8_t g , uint8_t b )  {
-
-  sendByte(r);          // Neopixel wants colors in green then red then blue order
-  sendByte(g);
-  sendByte(b);
+void sendPixel( const uint8_t rgb[3] )  {
+
+  sendByte(rgb[0]);
+  sendByte(rgb[1]);
+  sendByte(rgb[2]);

 }

@@ -543,67 +543,103 @@
 }

 void setup() {
+    //precompute_colors();
     interruptSetup();
     ledsetup();
 }

 const uint8_t delta = (256/PIXELS); //delta of hue between each pixel, spread out evenly
-volatile boolean constant=0;
-volatile int8_t direction = 1;
-//volatile uint8_t constant_color_hue=0;
+boolean constant=0;
+int8_t direction = 1;
+uint8_t constant_color_hue=0;
 uint8_t led_colors[PIXELS][3];
-volatile uint8_t constant_color_index=0;
-
-
-const uint8_t rgb_colors[8][3] {
-255,0,0,
-255,128,0,
-255,255,0,
-0,255,0,
-0,255,255,
-0,0,255,
-255,0,255,
-//255,128,128,
-255,255,255
+uint8_t constant_color_index=0;
+#define CONSTANT_COLORS_LEN 9
+
+const uint8_t test_pixel[3] = {32,32,32};
+
+const uint8_t rgb_colors[CONSTANT_COLORS_LEN][3] = {
+{255,0,0},
+{255,127,0},
+{255,255,0},
+{0,255,0},
+{0,255,255},
+{0,0,255},
+{255,0,255},
+{255,127,255},
+{255,255,255}
 };

+/*
+void precompute_colors() {
+    for (uint8_t color_index=0; color_index < CONSTANT_COLORS_LEN; color_index++) {
+        hsv2rgb_rainbow(constant_color_hue, rgb_colors[color_index]);
+    }
+}*/
+
 ISR(PCINT0_vect) {
-
+    //uint8_t button0 = digitalRead(0);
+    //uint8_t button3 = digitalRead(3);
+
+    //clear_led_colors();
     if (PINB & (1<<3)) { //change direction
+        //set_one_led(3);
         //transition between -1,0,1
         constant = 0;
         direction += 2;
         direction = direction % 3;
         direction -= 1;
     }
-    else if (PINB & 1) { //constant color
+    if (PINB & 1) { //constant color
+        //set_one_led(0);
         //stop color shifting
         constant = 1;
-        //constant_color_hue += 32;
-        ++constant_color_index % 8;
-    }
+        constant_color_hue += 32;
+        constant_color_index++;
+        constant_color_index %= CONSTANT_COLORS_LEN;
+    }
+    //show_all_led_colors();
+}
+
+void clear_led_colors() {
+    for (uint8_t index=0; index < PIXELS; index++) {
+        led_colors[index][0]=0;
+        led_colors[index][1]=0;
+        led_colors[index][2]=0;
+    }
+}
+
+void set_one_led(uint8_t index) {
+    led_colors[index][0]=255;
+    led_colors[index][1]=255;
+    led_colors[index][2]=255;
 }

 void show_all_led_colors() {
-    cli();
+    cli();
     for (uint8_t index=0; index < PIXELS; index++) {
-      sendPixel( led_colors[index][0] , led_colors[index][1] , led_colors[index][2] );
-    }
+      sendPixel(led_colors[index]);
+    }
+    show();
     sei();
-    show();
 }

 void loop() {
-    if (constant) {
+    if (constant == 1) {
+        delay(1000);
+        /*
+        //hsv2rgb_rainbow(constant_color_hue, led_colors[0]);
+
+        cli();
         for (uint8_t index=0; index < PIXELS; index++) {
-            //hsv2rgb_rainbow(constant_color_hue, led_colors[index]);
-            memcpy(led_colors[index], rgb_colors[constant_color_index], 3);
-            //led_colors[index][0] = rgb_colors[constant_color_index][0];
-            //led_colors[index][1] = rgb_colors[constant_color_index][1];
-            //led_colors[index][2] = rgb_colors[constant_color_index][2];
+          sendPixel(rgb_colors[constant_color_index]);
+          //sendPixel(test_pixel);
+          //sendPixel(rgb_colors[3]);
         }
-        show_all_led_colors();
-        delay(20);
+        show();
+        sei();
+        delay(500);
+        */
     } else {
         for (uint8_t hue=0; hue < 255; hue++) {
             for (uint8_t index=0; index < PIXELS; index++) {
@@ -613,11 +649,11 @@
             show_all_led_colors();
             delay(20);
             if (constant) {
+                clear_led_colors();
+                show_all_led_colors();
+                delay(300);
                 break;
             }
         }
     }
 }
-
-
-


Code cleanup/bug fixes

Code cleanup/bug fixes

Some comments and code cleanup, a few negligible improvements to code.

--- esp32LightServerRGB.ino
+++ esp32LightServerRGB.ino
@@ -13,32 +13,31 @@
 #include <DallasTemperature.h>
 #include <DHT.h>
 #include <ESPmDNS.h>
-#define ONE_WIRE_BUS 5
-#define DHTPIN 15
-#define DHTTYPE DHT11
+#define ONE_WIRE_BUS 5 //dallas sensor pin
+#define DHTPIN 15 // dht sensor pin
+#define DHTTYPE DHT11 //dht type 11 or 22
 DHT dht(DHTPIN, DHTTYPE);
 OneWire oneWire(ONE_WIRE_BUS);
 DallasTemperature sensors(&oneWire);
 // end of sensors

-// Settings you should check/change !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! mabe not anymore !!!!!!!!!!!!!
-
-const char* www_username = "admin";
-String resetpass = "admin"; // password to reset wifimanager when allready connected
-String thingkey = "none"; //your thingspeak API key
-String thingchanel = "none"; //your thingspeak Chanel #
-const long interval = 60000; // interval in ms for sending temperature data to thingspeak
-String liens = "";
-String dernadd = "Fraichement booté"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
 // led pins
 uint8_t pinRouge = 12;
-uint8_t pinVerte = 14; // internally pulled up
+uint8_t pinVerte = 14;
 uint8_t pinBleu = 13;
-// end of settings you should check/change
+//end of led pins

 // internally used vars
+// Some used vars, some of these are set and loaded in setup() using esp32 Preferences
+const long interval = 60000; // interval in ms for sending temperature data to thingspeak
+const char* www_username = "admin";
+String dernadd = "Fraichement booté"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
+String resetpass = ""; // password to reset wifimanager when allready connected
+String thingkey = ""; //your thingspeak API key
+String thingchanel = ""; //your thingspeak Chanel #
+String liens = "";
+String derncoul = "";
 WebServer server(80);
-String derncoul = "#000000";
 long r = 0;
 long g = 0;
 long b = 0;
@@ -180,8 +179,7 @@
 // log rotator
 void logtourne() {
   for (int i = 49; i > 0; i--) {
-    int l = i;
-    l = l + 1;
+    int l = i + 1;
     logs[l] = logs[i];
   }
 }
@@ -538,13 +536,16 @@

 //setup page
 void handleSetup() {
-  if (!server.authenticate(www_username, string2char(resetpass)))
-    return server.requestAuthentication();
-  int ouireset = 0;
   String addy = server.client().remoteIP().toString();
   Serial.println("");
   Serial.println(addy);
   Serial.println("!!! SETTINGS PAGE !!!");
+  if (!server.authenticate(www_username, string2char(resetpass))) {
+    Serial.println("Setup request no/bad password");
+    return server.requestAuthentication();
+
+  }
+  int ouireset = 0;
   String testteu = server.arg("RESET");
   String passme = server.arg("PASSME");
   String noupass = server.arg("LAPASSE");
@@ -606,22 +607,39 @@
   logtourne();
   logs[1] = addy;
   logs[1] += " : Settings : Password=";
-  logs[1] += passme;
+  if (passme != resetpass) {
+    logs[1] += passme;
+  } else {
+    logs[1] += "!!! Not showing password !!!";
+  }
   logs[1].replace("<", "</"); //prevent html tags in logs so hackers cant code in log page lol
   if (ouireset == 1) {
     Serial.println("Settings changed");
-    preferences.putString("resetpass", noupass);
-    preferences.putString("thingkey", lakey);
-    preferences.putString("thingchanel", lechan);
-    resetpass = noupass;
-    thingkey = lakey;
-    thingchanel = lechan;
-    liens = "Acceuil - Température - Version - Setup - Reset - Temp stats\n";
-  }
-}
-
+    if (noupass != resetpass) {
+      preferences.putString("resetpass", noupass);
+      resetpass = noupass;
+      Serial.print("NEW Password : ");
+      Serial.println(resetpass);
+    }
+    if (lakey != thingkey) {
+      preferences.putString("thingkey", lakey);
+      thingkey = lakey;
+      Serial.print("NEW API KEY : ");
+      Serial.println(thingkey);
+    }
+    if (lechan != thingchanel) {
+      preferences.putString("thingchanel", lechan);
+      thingchanel = lechan;
+      liens = "Acceuil - Température - Version - Setup - Reset - Temp stats\n";
+      Serial.print("NEW channel : ");
+      Serial.println(thingchanel);
+    }
+  }
+}
+
+// convert string 2 char*
 char* string2char(String command) {
   if (command.length() != 0) {
     char *p = const_cast<char*>(command.c_str());
@@ -754,7 +772,7 @@
   contenu += "°C Humidité : ";
   contenu += h;
   contenu += "

\n";
-  if (thingkey != "none") {
+  if (thingchanel != "none") {
     contenu += ""
@@ -790,19 +808,19 @@
 }

 int fadecomment(int claire) {
-  int combien = 70;
+  int combien = 77;
   if (claire > 0)
-    combien = 90;
+    combien = 77;
   if (claire > 40)
-    combien = 80;
+    combien = 60;
   if (claire > 80)
-    combien = 60;
+    combien = 40;
   if (claire > 100)
-    combien = 40;
+    combien = 30;
   if (claire > 120)
-    combien = 30;
+    combien = 20;
   if (claire > 140)
-    combien = 20;
+    combien = 15;
   if (claire > 180)
     combien = 9;
   return combien;
@@ -815,11 +833,11 @@
 }

 void setup() {
+  Serial.begin(115200);
   preferences.begin("lumiere", false);
   videCoeur();
-  Serial.begin(115200);
   dht.begin();
-  ledcAttachPin(pinRouge, 1); // assign RGB led pins to channels
+  ledcAttachPin(pinRouge, 1);
   ledcAttachPin(pinVerte, 2);
   ledcAttachPin(pinBleu, 3);
   pinMode(pinRouge, OUTPUT);
@@ -838,7 +856,7 @@
   resetpass = preferences.getString("resetpass", "admin");
   thingkey = preferences.getString("thingkey", "none");
   thingchanel = preferences.getString("thingchanel", "none");
-  liens = "Acceuil - Température - Version - Setup - Version - Reset - <a href=\"https://thingspeak.com/channels/";
+  liens = "Acceuil - Température - Version - Setup - Reset - Temp stats\n";
   WiFiManager wifiManager;