finished web UI for analog sensor config, and persistence

--- ardesp/waterelf/waterelf.ino
+++ ardesp/waterelf/waterelf.ino
@@ -80,7 +80,7 @@
   "

\n"
   "
Monitor
\n"
   "

\n"
-  "
Wifi status
\n"
+  "
Elf status
\n"
   "
Sensor data
\n"
   "

\n";
 const char* pageFooter =
@@ -184,6 +184,14 @@
 boolean GOT_LEVEL_SENSOR = false;  // we'll change later if we detect sensor

 /////////////////////////////////////////////////////////////////////////////
+// analog sensor stuff //////////////////////////////////////////////////////
+String ANALOG_SENSOR_NONE = "analog_none";
+String ANALOG_SENSOR_MAINS = "analog_mains";
+String ANALOG_SENSOR_PRESSURE = "analog_pressure";
+String analogSensor = ANALOG_SENSOR_NONE;
+boolean GOT_ANALOG_SENSOR = false; // change later if we config a sensor
+
+/////////////////////////////////////////////////////////////////////////////
 // valves and flow control //////////////////////////////////////////////////
 /*
 user settable parameters:
@@ -320,6 +328,8 @@
 void setCloudShare(boolean b);
 String getSvrAddr();
 void setSvrAddr(String s);
+String getAnalogSensor();
+void setAnalogSensor(String s);

 /////////////////////////////////////////////////////////////////////////////
 // setup ////////////////////////////////////////////////////////////////////
@@ -332,6 +342,7 @@
   // read persistent config
   SPIFFS.begin();
   svrAddr = getSvrAddr();
+  analogSensor = getAnalogSensor();

   // start the sensors, the DNS and webserver, etc.
   startPeripherals();
@@ -430,7 +441,7 @@
   webServer.on("/ALL", handle_root);
   webServer.onNotFound(handleNotFound);
   webServer.on("/wifi", handle_wifi);
-  webServer.on("/wifistatus", handle_wifistatus);
+  webServer.on("/elfstatus", handle_elfstatus);
   webServer.on("/serverconf", handle_serverconf);
   webServer.on("/analogconf", handle_analogconf);
   webServer.on("/wfchz", handle_wfchz);
@@ -535,13 +546,13 @@
   webServer.send(200, "text/html", toSend);
 }

-void handle_wifistatus() {
-  dln(netDBG, "serving page at /wifistatus");
+void handle_elfstatus() {
+  dln(netDBG, "serving page at /elfstatus");

   String toSend = pageTop;
-  toSend += ": Wifi Status";
+  toSend += ": Elf Status";
   toSend += pageTop2;
-  toSend += "\n
Wifi Status

\n";
+  toSend += "\n
Elf Status

\n";

   toSend += "\n
SSID: ";
   toSend += WiFi.SSID();
@@ -574,6 +585,8 @@
   toSend += "
\n";
   toSend += "\n
Data sharing server address: "; toSend += svrAddr;
   toSend += "
\n";
+  toSend += "\n
Analog sensor type: "; toSend += analogSensor;
+  toSend += "
\n";

   toSend += "

";

@@ -601,7 +614,7 @@
     toSend += "
Looks like a bug :-(
";
   } else {
     toSend += "
Done! Now trying to join network...
";
-    toSend += "
Check wifi status here.
";
+    toSend += "
Check wifi status here.
";
     char ssidchars[ssid.length()+1];
     char keychars[key.length()+1];
     ssid.toCharArray(ssidchars, ssid.length()+1);
@@ -638,13 +651,12 @@

   f += "<form method='POST' action='algchz'> ";
   f += "
Analog sensor:\n
\n";
-  f += "
none <input type='radio' name='analogsensor' value='none' checked>\n";
-  f += "
mains current <input type='radio' name='analogsensor' value='mains'>\n";
-  f += "
water pressure <input type='radio' name='analogsensor' value='pressure'>\n";
+  f += "
none <input type='radio' name='analog_sensor' value='analog_none' checked>\n";
+  f += "
mains current <input type='radio' name='analog_sensor' value='analog_mains'>\n";
+  f += "
water pressure <input type='radio' name='analog_sensor' value='analog_pressure'>\n";
   f += "<input type='submit' value='Submit'></form>

";

   f += pageFooter;
-  dbg(analogDBG, f);
   return f;
 }
 void handle_serverconf() {
@@ -682,7 +694,7 @@
   setCloudShare(cloudShare);

   // TODO some way of verifying if server config worked
-  // add srvstatus, or roll that into wifistatus, or...?
+  // add srvstatus, or roll that into elfstatus, or...?

   toSend += pageFooter;
   webServer.send(200, "text/html", toSend);
@@ -694,42 +706,29 @@
   toSend += pageTop2;

   for(uint8_t i = 0; i < webServer.args(); i++) {
-    if(webServer.argName(i) == "analogsensor") {
-      // TODO store the sensor type
-    }
-
-    svrAddr = webServer.arg(i);
-    toSend += "
webServer.arg(";
-    toSend += i;
-    toSend += ") = ";
-    toSend += webServer.arg(i);
-    toSend += "
argName = ";
-    toSend += webServer.argName(i);
-    toSend += "
\n";
-  }
-
-/*
-  boolean cloudShare = false;
-  for(uint8_t i = 0; i < webServer.args(); i++) {
-    if(webServer.argName(i) == "svraddr") {
-      svrAddr = webServer.arg(i);
-      toSend += "
Added local server config...
";
-      toSend += "
...at ";
-      toSend += svrAddr;
+    if(webServer.argName(i) == "analog_sensor") { // remember/persist the type
+      String argVal = webServer.arg(i);
+      analogSensor = ANALOG_SENSOR_NONE; // the default is...
+      GOT_ANALOG_SENSOR = false;         // ...no sensor
+      if(argVal == "analog_mains") {
+        analogSensor = ANALOG_SENSOR_MAINS;
+        GOT_ANALOG_SENSOR = true;
+      } else if(argVal == "analog_pressure") {
+        analogSensor = ANALOG_SENSOR_PRESSURE;
+        GOT_ANALOG_SENSOR = true;
+      } else if(argVal != "analog_none") {
+        Serial.println("unknown analog sensor type");
+      }
+      toSend += "
Added analog sensor config...
";
+      toSend += "
...for ";
+      toSend += analogSensor;
       toSend += "
";
-    } else if(webServer.argName(i) == "key") {
-      if(webServer.arg(i) == "on")
-        cloudShare = true;
-    }
-  }
-
-  // persist the config
-  setSvrAddr(svrAddr);
-  setCloudShare(cloudShare);
-*/
+      setAnalogSensor(analogSensor);
+    }
+  }

   toSend += pageFooter;
-  dbg(analogDBG, toSend);
+  dbg(analogDBG, analogSensor); dbg(analogDBG, "\n");
   webServer.send(200, "text/html", toSend);
 }
 void handle_actuate() {
@@ -1054,6 +1053,23 @@
   f.println(s);
   f.close();
 }
+String getAnalogSensor() {
+  analogSensor = ANALOG_SENSOR_NONE; // the default is...
+  GOT_ANALOG_SENSOR = false;         // ...no sensor
+  String s = "";
+  File f = SPIFFS.open("/analogSensor.txt", "r");
+  if(f) {
+    s = f.readString();
+    s.trim();
+    f.close();
+  }
+  return s;
+}
+void setAnalogSensor(String s) {
+  File f = SPIFFS.open("/analogSensor.txt", "w");
+  f.println(s);
+  f.close();
+}

 /////////////////////////////////////////////////////////////////////////////
 // misc utils ///////////////////////////////////////////////////////////////


Example: BasicGain_wApp: update for BLE

Example: BasicGain_wApp: update for BLE

--- examples/06-AppTutorial/01-BasicGain_wApp/01-BasicGain_wApp.ino
+++ examples/06-AppTutorial/01-BasicGain_wApp/01-BasicGain_wApp.ino
@@ -1,7 +1,7 @@
 /*
 *   BasicGain_wApp
 *
-*   Created: Chip Audette, June 2020
+*   Created: Chip Audette, June 2020 (updated June 2021 for BLE)
 *   Purpose: Process audio using Tympan by applying gain.
 *      Also, illustrate how to change Tympan setting via the TympanRemote App.
 *
@@ -33,6 +33,9 @@
 #include "TympanRemoteFormatter.h"
 TympanRemoteFormatter myGUI;  //Creates the GUI-writing class for interacting with TympanRemote App

+//Create BLE
+BLE ble = BLE(&Serial1);
+

 // define the setup() function, the function that is called once when the device is booting
 const float input_gain_dB = 10.0f; //gain on the microphone
@@ -40,8 +43,7 @@
 void setup() {

   //begin the serial comms (for debugging)
-  myTympan.beginBothSerial();
-  delay(3000);
+  myTympan.beginBothSerial();delay(3000);
   myTympan.println("BasicGain_wApp: starting setup()...");

   //allocate the dynamic memory for audio processing blocks
@@ -59,6 +61,10 @@
   myTympan.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
   myTympan.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps

+  //setup BLE
+  while (Serial1.available()) Serial1.read(); //clear the incoming Serial1 (BT) buffer
+  ble.setupBLE(myTympan);
+
   //Create the GUI description (but not yet transmitted to the App...that's after it connects)
   createTympanRemoteLayout();

@@ -71,7 +77,15 @@

   //look for in-coming serial messages (via USB or via Bluetooth)
   if (Serial.available()) respondToByte((char)Serial.read());   //USB Serial
-  if (Serial1.available()) respondToByte((char)Serial1.read()); //BT Serial
+
+  //respond to BLE
+  if (ble.available() > 0) {
+    String msgFromBle; int msgLen = ble.recvBLE(&msgFromBle);
+    for (int i=0; i < msgLen; i++) respondToByte(msgFromBle[i]);
+  }
+
+  //service the BLE advertising state
+  ble.updateAdvertising(millis(),5000); //check every 5000 msec to ensure it is advertising (if not connected)

 } //end loop();

@@ -104,6 +118,8 @@
 // Please don't put commas or colons in your ID strings!
 void printTympanRemoteLayout(void) {
   myTympan.println(myGUI.asString());
+  ble.sendMessage(myGUI.asString());
+  setButtonText("gainIndicator", String(digital_gain_dB));
 }

 //define the GUI for the App
@@ -121,14 +137,14 @@
           card_h->addButton("-","K","minusButton",4);  //displayed string, command, button ID, button width (out of 12)

           //Add an indicator that's a button with no command:  Label (value of the digital gain); Command (""); Internal ID ("gain indicator"); width (4).
-          card_h->addButton(String(digital_gain_dB),"","gainIndicator",4);  //displayed string (blank), command (blank), button ID, button width (out of 12)
+          card_h->addButton("","","gainIndicator",4);  //displayed string (blank for now), command (blank), button ID, button width (out of 12)

           //Add a "+" digital gain button with the Label("+"); Command("K"); Internal ID ("minusButton"); and width (4)
           card_h->addButton("+","k","plusButton",4);   //displayed string, command, button ID, button width (out of 12)

   //add some pre-defined pages to the GUI
   myGUI.addPredefinedPage("serialMonitor");
-  myGUI.addPredefinedPage("serialPlotter");
+  //myGUI.addPredefinedPage("serialPlotter");
 }

@@ -149,5 +165,7 @@
 }

 void setButtonText(String btnId, String text) {
-  myTympan.println("TEXT=BTN:" + btnId + ":"+text);
+  String str = "TEXT=BTN:" + btnId + ":"+text;
+  myTympan.println(str);
+  ble.sendMessage(str);
 }


Update blink timing; different intervals for RBG.

--- examples/Blink/CosaBlinkTemp/CosaBlinkTemp.ino
+++ examples/Blink/CosaBlinkTemp/CosaBlinkTemp.ino
@@ -95,13 +95,13 @@
   // Set LED according to temperature
   if (temp < low) {
     blue.on();
-    powerdown(32);
+    powerdown(16);
     blue.off();
-    powerdown(1024);
+    powerdown(1000);
   }
   else if (temp > high) {
     red.on();
-    powerdown(32);
+    powerdown(16);
     red.off();
     powerdown(1000);
   }


Remove compiler warnings on program memory.

--- examples/Drivers/CosaTSOP4838/CosaTSOP4838.ino
+++ examples/Drivers/CosaTSOP4838/CosaTSOP4838.ino
@@ -47,13 +47,13 @@
 #include "Cosa/IOStream/Driver/UART.hh"
 #include "Cosa/Memory.h"
 #else
-#include "Cosa/IOStream/Driver/PCD8544.hh"
+#include "Cosa/LCD/Driver/PCD8544.hh"
 #endif

 /**
  * Key mapping for LG AKB72913104. Store in program memory.
  */
-static const IR::Receiver::keymap_t LG_keymap[] PROGMEM = {
+static const IR::Receiver::keymap_t LG_keymap[] __PROGMEM = {
   { 0x08f7, '0'  },
   { 0x8877, '1'  },
   { 0x48b7, '2'  },


Update production sketch to control up to 256 connected LEDs. Only the first 64 will display the pattern, the remaining can be controlled by serial.

--- examples/ProductionSketch/ProductionSketch.ino
+++ examples/ProductionSketch/ProductionSketch.ino
@@ -9,7 +9,8 @@
 #include "Scanner.h"
 #include "Flashlight.h"

-struct CRGB leds[LED_COUNT];
+// Allow longer patterns to be played back from serial, just don't draw the default patterns on them.
+struct CRGB leds[LED_COUNT*4];

 #define BRIGHT_STEP_COUNT 8
 #define STARTING_BRIGHTNESS 4


Add TinyGps++ library to sketch and add debug statement

--- src/teensy_sketch/teensy_sketch.ino
+++ src/teensy_sketch/teensy_sketch.ino
@@ -50,6 +50,7 @@
 // region includes
 #include <i2c_t3.h>
 #include <SPI.h>
+#include <TinyGPS++.h>

 #include <Data_module.h>
 #include <Sensor_helper.h>
@@ -98,6 +99,7 @@
 // end region

 // region library instantiation
+TinyGPSPlus gps;
 Data_module dataModule(sdChipSelect, debugSerialBaud, initFileName, dataFileName);
 Sensor_helper helper(Ascale, Gscale, Mscale, Mmode, &dataModule); // Data_module required for sensor debug
 // end region
@@ -108,7 +110,10 @@

   // begin I2C for MPU IMU
   Wire1.begin(I2C_MASTER, 0x000, I2C_PINS_29_30, I2C_PULLUP_EXT, I2C_RATE_400);
-
+
+  // begin serial used for GPS data
+  gpsSerial.begin(gpsSerialBaud);
+
   // begin SPI for high-accuracy gyro
   SPI.begin();

@@ -121,12 +126,15 @@
 }

 void loop() {
+  readGPS();
+
   readIMU();
   readGyro();
-
+
   delay(200);
   dataModule.println(getIMULogString(accelData)+getIMULogString(gyroData)+getIMULogString(magData));
   dataModule.println(getGyroLogString(L3G4200DData));
+  dataModule.println("Got " + String(gps.charsProcessed(), DEC) + " chars");
 }

 // ------------------------------------------------------------
@@ -167,6 +175,13 @@
   }
 }

+// function to be called each iteration to feed the GPS instantiation
+void readGPS() {
+  if (gpsSerial.available()) {
+    gps.encode(gpsSerial.read());
+  }
+}
+
 // Simple function for building a CSV formatted string from a 3 element array
 String getIMULogString(float * data) {
   return (String(data[0], DEC) + "," + String(data[1], DEC) + "," + String(data[2], DEC) + ",");


fixed bug, was because of an ambigously named variable

--- src/SabertoothDriverROS/SabertoothDriverROS.ino
+++ src/SabertoothDriverROS/SabertoothDriverROS.ino
@@ -78,6 +78,20 @@
   }
   driveTimeMillis = (long)(nmc.drive_duration * 1000);
   emergencyStop = nmc.e_stop;
+
+  if(emergencyStop == true)
+  {
+    char* error = "Setting E-Stop to TRUE.";
+    msg.data = error;
+    pubResults.publish(&msg);
+  }
+  else
+  {
+    char* error = "Setting E-Stop to FALSE.";
+    msg.data = error;
+    pubResults.publish(&msg);
+  }
+
 }

@@ -149,7 +163,14 @@
   // Short-circuit on EStop!
   if(emergencyStop)
   {
+    if (!currentlyStopped) {
+      char* error = "E-Stopped all motors.";
+      msg.data = error;
+      pubResults.publish(&msg);
+
+    }
     stopAllMotors();
+
     // short-circuit
     return;
   }
@@ -174,19 +195,24 @@
     else
     {
       currentlyDriving = false;
+      char* error = "done: Stopped all motors.";
+      msg.data = error;
+      pubResults.publish(&msg);
+
       stopAllMotors();
     }
   }

 }

+bool currentlyMoving[6];
 // A function to articulate the wheels to face the desired orientation.
 void articulate()
 {
   // For now, only articulate the FRONT LEFT wheel.
   int delta = 0;
   int motorIDX;
-  static bool currentlyMoving[6];
+
   bool stillRotating = false;

   for(motorIDX = 0; motorIDX <= 5; ++motorIDX)
@@ -208,6 +234,7 @@
     else if (((delta > 0) && (delta < 180)) ||
       ((delta + 360) < 180 ))
     {
+      stillRotating = true;
       if(!currentlyMoving[motorIDX])
       {
         char* error = "Starting motor: X";
@@ -217,7 +244,6 @@
         pubResults.publish(&msg);
         driveCounterclockwise(ARTICULATION_SPEED, motorIDX + ARTICULATION_OFFSET);
         driveCounterclockwise(ARTICULATION_DRIVE_SPEED, motorIDX);
-        stillRotating = true;
         currentlyMoving[motorIDX] = true;
       }


John Rees is back

John Rees is back

--- code/arduino/_1rev/_1rev.ino
+++ code/arduino/_1rev/_1rev.ino
@@ -2,11 +2,18 @@

 // Steppers 1, 2 and 4 on big easy driver, stepper 3 on easydriver

+String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";

 AccelStepper stepper1(1,12,13);
 AccelStepper stepper2(1,10,11);
 AccelStepper stepper3(1,6,7);
 AccelStepper stepper4(1,8,9);
+
+boolean calibrated = false;
+
+char serialdata[4];
+    int lf = 10;
+
 void setup()
 {
    Serial.begin(9600);
@@ -16,53 +23,44 @@
   }

   Serial.write("Flip-Flap Ready!");
+      Serial.println("Enter the 4 characters that the flipflap is displaying:");
+
    stepper1.setMaxSpeed(12000);
    stepper1.setAcceleration(24000.0);

    stepper2.setMaxSpeed(12000);
-   stepper2.setAcceleration(12000.0);
+   stepper2.setAcceleration(24000.0);

-   stepper3.setMaxSpeed(4000);
-   stepper3.setAcceleration(3000.0);
+   stepper3.setMaxSpeed(12000);
+   stepper3.setAcceleration(24000.0);

    stepper4.setMaxSpeed(12000);
-   stepper4.setAcceleration(12000.0);
+   stepper4.setAcceleration(24000.0);
 }
 void loop()
 {
    if (Serial.available() > 0) {
-    // read incoming serial data:
-    char inChar = Serial.read();
-    // Type the next ASCII value from what you received:
-     switch (inChar){
-     case 'a':
-     stepper1.runToNewPosition(480);
-     stepper1.setCurrentPosition(0);
-     break;
-     case 'b':
-     stepper2.runToNewPosition(480);
-     stepper2.setCurrentPosition(0);
-     break;
-     case 'c':
-     stepper3.runToNewPosition(240);
-     stepper3.setCurrentPosition(0);
-     break;
-     case 'd':
-     stepper4.runToNewPosition(480);
-     stepper4.setCurrentPosition(0);
-     break;
-     }
+
+    Serial.readBytesUntil(lf, serialdata, 4);
+
+    char inChar = serialdata[3];
+    int p = s.indexOf(inChar);
+
+    if (calibrated) {
+      // read incoming serial data:
+      if (p >= 0) {
+        stepper1.runToNewPosition(480 * p);
+        stepper1.setCurrentPosition(0);
+        s = s.substring(p) + s.substring(0,p);
+      } else if (inChar == '`') {
+        stepper1.runToNewPosition(480);
+        stepper1.setCurrentPosition(0);
+      }
+    } else {
+      s = s.substring(p) + s.substring(0,p);
+      calibrated = true;
+    }
+
   }
-
-
- //  stepper1.runToNewPosition(9600); //240 steps per letter
- //  stepper2.runToNewPosition(9600);
- //  stepper3.runToNewPosition(-4800); //120 steps per letter
- //  stepper4.runToNewPosition(9600);
- //  stepper1.setCurrentPosition(0);
- //  stepper2.setCurrentPosition(0);
- //  stepper3.setCurrentPosition(0);
- //  stepper4.setCurrentPosition(0);
- //  delay(2000);

 }


Version 2.6a - 19th April 2019

Version 2.6a - 19th April 2019

Fixes #23

--- ulisp.ino
+++ ulisp.ino
@@ -1,5 +1,5 @@
-/* uLisp AVR Version 2.6 - www.ulisp.com
-   David Johnson-Davies - www.technoblogy.com - 9th April 2019
+/* uLisp AVR Version 2.6a - www.ulisp.com
+   David Johnson-Davies - www.technoblogy.com - 19th April 2019

    Licensed under the MIT license: https://opensource.org/licenses/MIT
 */
@@ -2624,13 +2624,16 @@
 object *fn_pinmode (object *args, object *env) {
   (void) env;
   int pin = integer(first(args));
+  int pm = INPUT;
   object *mode = second(args);
-  if ((integerp(mode) && mode->integer == 1) || mode != nil) pinMode(pin, OUTPUT);
-  else if (integerp(mode) && mode->integer == 2) pinMode(pin, INPUT_PULLUP);
-  #if defined(INPUT_PULLDOWN)
-  else if (integerp(mode) && mode->integer == 4) pinMode(pin, INPUT_PULLDOWN);
-  #endif
-  else pinMode(pin, INPUT);
+  if (integerp(mode)) {
+    int nmode = integer(mode);
+    if (nmode == 1) pm = OUTPUT; else if (nmode == 2) pm = INPUT_PULLUP;
+    #if defined(INPUT_PULLDOWN)
+    else if (nmode == 4) pm = INPUT_PULLDOWN;
+    #endif
+  } else if (mode != nil) pm = OUTPUT;
+  pinMode(pin, pm);
   return nil;
 }

@@ -2772,9 +2775,9 @@
   else supersub(form, lm + PPINDENT, 1, pfun);
 }

-const int ppspecials = 14;
+const int ppspecials = 15;
 const char ppspecial[ppspecials] PROGMEM =
-  { DOTIMES, DOLIST, IF, SETQ, TEE, LET, LETSTAR, LAMBDA, WHEN, UNLESS, WITHI2C, WITHSERIAL, WITHSPI, WITHSDCARD };
+  { DOTIMES, DOLIST, IF, SETQ, TEE, LET, LETSTAR, LAMBDA, WHEN, UNLESS, WITHI2C, WITHSERIAL, WITHSPI, WITHSDCARD, FORMILLIS };

 void supersub (object *form, int lm, int super, pfun_t pfun) {
   int special = 0, separate = 1;
@@ -3292,7 +3295,7 @@
   object *function = car(form);
   object *args = cdr(form);

-  if (function == NULL) error(PSTR("'nil' is an illegal function"));
+  if (function == NULL) error3(NIL, PSTR("is an illegal function"));
   if (!listp(args)) error(PSTR("Can't evaluate a dotted pair"));

   // List starts with a symbol?


temperature_mote_v0_1: - Added zero of RSSI field (for clarity)

--- temperature_mote_v0_1/temperature_mote_v0_1.ino
+++ temperature_mote_v0_1/temperature_mote_v0_1.ino
@@ -135,10 +135,12 @@
 //
 static void sendReadingReport() {
     memset(&outbound, 0, sizeof(outbound));
+
     outbound.msg.direction = RF_TO_MQTT  ;
     outbound.msg.type = MSG_READING;
     outbound.msg.source = NODEID;
     outbound.msg.destination = 0;
+    outbound.msg.rssi = 0;

     SensorData* report = temperature.report();
     memcpy(&outbound.msg.data, report, sizeof(*report));


Pretty up display

Pretty up display

Enlarged weather info characters. Turn on RGB LED only when OLED is on to preserve power.

--- weatherstation.ino
+++ weatherstation.ino
@@ -303,6 +303,33 @@

 }

+void display_string_8x16(byte y,byte x,const char *text)
+{
+  unsigned char i= 0;
+  unsigned char addrHigh,addrMid,addrLow ;
+  while((text[i]>0x00))
+  {
+
+    if((text[i]>=0x20) &&(text[i]<=0x7e))
+    {
+      unsigned char fontbuf[16];
+      fontaddr = (text[i] - 0x20);
+      fontaddr = (unsigned long)(fontaddr*16);
+      fontaddr = (unsigned long)(fontaddr+0x3cf80);
+      addrHigh = (fontaddr&0xff0000)>>16;
+      addrMid = (fontaddr&0xff00)>>8;
+      addrLow = fontaddr&0xff;
+
+      get_n_bytes_data_from_ROM(addrHigh,addrMid,addrLow,fontbuf,16 );
+
+      display_graphic_8x16(y,x,fontbuf);
+      i+=1;
+      x+=8;
+    }
+    else
+    i++;
+  }
+}

 /****************************************************************************
 *****************************************************************************
@@ -312,9 +339,10 @@

 void sendToThingSpeak(const char * key, String mesg)
 {
+    backLightOn();
+    RGB.control(true);
     noInterrupts();
     client.stop();
-    RGB.control(true);
     RGB.color(0,255,0);
     int lt = millis();
     display_string_5x7(6,1,"Wifi");
@@ -356,7 +384,6 @@
         }
         client.flush();
         client.stop();
-        RGB.control(false);
         display_string_5x7(6,1,"Done          ");
     }
     else{
@@ -387,6 +414,7 @@

 void backLightOn()
 {
+    RGB.control(false);
     trigger = millis() + BACKLDUR;
     transfer_command_lcd(0xaf);//--turn on oled panel
     //display_string_5x7(6,1,"DISP ON ");
@@ -395,6 +423,8 @@

 void backLightOff()
 {
+    RGB.control(true);
+    RGB.color(0,0,0);
     //display_string_5x7(6,1,"DISP OFF");
     transfer_command_lcd(0xae);//--turn off oled panel
     refresh=false;
@@ -427,31 +457,31 @@
   switch (result)
   {
     case IDDHTLIB_OK:
-      status = "OK";
+      status = "OK                 ";
       break;
     case IDDHTLIB_ERROR_CHECKSUM:
-      status = "Checksum";
+      status = "Checksum           ";
       break;
     case IDDHTLIB_ERROR_ISR_TIMEOUT:
-      status = "ISR Time out";
+      status = "ISR Time out       ";
       break;
     case IDDHTLIB_ERROR_RESPONSE_TIMEOUT:
-      status = "Response time out";
+      status = "Response time out  ";
       break;
     case IDDHTLIB_ERROR_DATA_TIMEOUT:
-      status = "Data time out";
+      status = "Data time out      ";
       break;
     case IDDHTLIB_ERROR_ACQUIRING:
-      status = "Acquiring";
+      status = "Acquiring          ";
       break;
     case IDDHTLIB_ERROR_DELTA:
       status = "Delta time to small";
       break;
     case IDDHTLIB_ERROR_NOTSTARTED:
-      status = "Not started";
+      status = "Not started        ";
       break;
     default:
-      status = "Unknown";
+      status = "Unknown            ";
       break;
   }

@@ -515,11 +545,13 @@
       display_string_5x7(1,20,dispCS);

       readAM2321();
-      status.toCharArray(dispCS, 18);
+      status.toCharArray(dispCS, 20);
       display_string_5x7(6,1,dispCS);

-      sprintf(dispCS, "T: %0.1f, H: %0.1f    ", temp, humi);
-      display_string_5x7(3,1,dispCS);
+//      sprintf(dispCS, "T: %0.1f, H: %0.1f    ", temp, humi);
+//      display_string_5x7(3,1,dispCS);
+      sprintf(dispCS, "%0.1fC, %0.1f%%    ", temp, humi);
+      display_string_8x16(3,1,dispCS);
     }

     publishReadings();
@@ -532,8 +564,3 @@

     delay(500);
 }
-
-
-
-
-


Fixed tube cycling

Fixed tube cycling

--- arduino-nixie-clock/arduino-nixie-clock.ino
+++ arduino-nixie-clock/arduino-nixie-clock.ino
@@ -102,7 +102,7 @@
     minuteIncremented = false;
   }

-  if (milliseconds <= 9 * secondDivisor)
+  if (milliseconds < 10 * secondDivisor)
   {
     hour = minute = second = second * 11;
   }


Updated comments

Updated comments

--- examples/ReceiveInterrupt/ReceiveInterrupt.ino
+++ examples/ReceiveInterrupt/ReceiveInterrupt.ino
@@ -70,14 +70,19 @@
     while (true);
   }

-  // if needed, 'listen' mode can be disabled by calling
-  // any of the following methods:
+  // if needed (e.g. to transmit after
+  // receiving packet with interrupt),
+  // 'listen' mode will be disabled automatically
+  // by calling any of the following methods:
   //
   // lora.standby()
   // lora.sleep()
   // lora.transmit();
   // lora.receive();
   // lora.scanChannel();
+  //
+  // call lora.startReceive() to re-enable
+  // 'listen mode'
 }

 // flag to indicate that a packet was received


Arduino programma updated

Arduino programma updated

--- Arduino/Arduino.ino
+++ Arduino/Arduino.ino
@@ -58,7 +58,6 @@

 		if (DataManager.usableInput)
 		{
-
 			ComData params = DataManager.getComData();
 			processdata(params);
 		}


Kapitola: Osvetlenie

Kapitola: Osvetlenie


New WU station and its hi/lo temps

New WU station and its hi/lo temps

--- hvacMonitor.ino
+++ hvacMonitor.ino
@@ -31,14 +31,15 @@
 // HTTP request
 const char WUNDERGROUND_REQ[] =
   //"GET /test.json HTTP/1.1\r\n"  // Keep for test/debug
-  "GET /api/myApiKey/conditions/q/pws:KAZTEMPE29.json HTTP/1.1\r\n"
+  //"GET /api/myApiKey/conditions/q/pws:KAZTEMPE29.json HTTP/1.1\r\n" // Local PWS
+  "GET /api/myApiKey/conditions/q/KPHX.json HTTP/1.1\r\n" // Airport
   "User-Agent: ESP8266/0.1\r\n"
   "Accept: */*\r\n"
   "Host: " WUNDERGROUND "\r\n"
   "Connection: close\r\n"
   "\r\n";

-float temp_f;
+int temp_f;

 WidgetLED led1(V2); // Heartbeat
 WidgetRTC rtc;
@@ -61,6 +62,9 @@

 int resetLatch = 0;

+int dailyOutsideHigh = 0;
+int dailyOutsideLow = 200;
+
 int currentRuntimeSec; // Sum of today's blower runtime in seconds
 int currentOfftimeSec = 0;
 int currentRuntimeMin; // Sum of today's blower runtime in minutes
@@ -108,9 +112,6 @@

   yesterdayRuntime = (EEPROM.read(200) * 4);

-  Blynk.virtualWrite(17, eeWBsum);
-  Blynk.virtualWrite(18, EEPROM.read(eeIndex));
-  Blynk.virtualWrite(21, EEPROM.read(200));
   // END EEPROM WRITEBACK ROUTINE

   rtc.begin();
@@ -172,6 +173,20 @@
     Blynk.virtualWrite(12, "ERR");
     Blynk.tweet(String("WU API error reporting a temp value of ") + temp_f + " at " + hour() + ":" + minute() + ":" + second() + " " + month() + "/" + day() + "/" + year());
   }
+
+
+  if (temp_f > dailyOutsideHigh)
+  {
+    dailyOutsideHigh = temp_f;
+    Blynk.virtualWrite(5, dailyOutsideHigh);
+  }
+
+  if (temp_f < dailyOutsideLow)
+  {
+    dailyOutsideLow = temp_f;
+    Blynk.virtualWrite(13, dailyOutsideLow);
+  }
+
 }

 void sendWU()
@@ -423,7 +438,6 @@
     eeCurrent++;
     EEPROM.write(eeIndex, eeCurrent);
     EEPROM.commit();
-    Blynk.virtualWrite(18, eeCurrent);
     currentRuntimeStint = 0;
   }
 }
@@ -561,7 +575,7 @@
   // Resets the timer on the next day if the blower is running.
   else if (digitalRead(blowerPin) == LOW && todaysDate != day())
   {
-    Blynk.tweet(String("On ") + yesterdaysMonth + "/" + yesterdaysDate + "/" + year() + " the A/C ran for " + currentRuntimeMin + " minutes total."); // Tweet total runtime.
+    Blynk.tweet(String("On ") + yesterdaysMonth + "/" + yesterdaysDate + "/" + year() + " the A/C ran for " + currentRuntimeMin + " minutes total. Airport was " + dailyOutsideHigh + "°F/" + dailyOutsideLow + "°F."); // Tweet total runtime and outdoor high/low.
     yesterdayRuntime = currentRuntimeMin; // Moves today's runtime to yesterday for the app display.
     dayCountLatch = 0; // Allows today's date to be reset.
     currentRuntimeSec = 0; // Reset today's sec timer.
@@ -579,6 +593,8 @@
   else if (digitalRead(blowerPin) == HIGH && todaysDate != day())
   {
     Blynk.tweet(String("On ") + yesterdaysMonth + "/" + yesterdaysDate + "/" + year() + " the A/C ran for " + currentRuntimeMin + " minutes total."); // Tweet total runtime.
+    dailyOutsideHigh = 0;
+    dailyOutsideLow = 200;
     yesterdayRuntime = currentRuntimeMin;
     dayCountLatch = 0;
     currentRuntimeSec = 0;


activate led on every loop

activate led on every loop

--- src/basic/basic.ino
+++ src/basic/basic.ino
@@ -55,19 +55,22 @@
 // the loop routine runs over and over again forever:
 void loop() {
   Serial.println("starting loop...");
+  led_on();
   while (gpsSerial.available() > 0){
     if (gps.encode(gpsSerial.read())){
       displayInfo();
       if (gps.location.isValid()){
         transmit_coords(gps.location.lat(), gps.location.lng());
+        delay(5000);
+        break;
       }
-      break;
     }
   }
   if(receivedBikeKillSignal()){
     Serial.println("Deactivating Bike...");
   }
   Serial.println("end of loop...");
+  led_off();
   delay(5000);
 }


v2.1 Date/time bug fix

v2.1 Date/time bug fix

--- GPSLCD.ino
+++ GPSLCD.ino
@@ -360,16 +360,14 @@
           lcd.print("            "); // Clear the extra chars
         }
       } // if (now - prevCreditTime > TOGGLETIME_INTERVAL)
-      prevDateTime = TOGGLETIME_INTERVAL;
-      dateTimeToggle = true; // Default first to display date
     } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
     else {
       // Toggle date/time every TOGGLETIME_INTERVAL seconds
       if (now - prevDateTime > TOGGLETIME_INTERVAL) {
         prevDateTime = now;
-        if (!dateTimeToggle) {
+        if (dateTimeToggle) {
           // Display time
-          dateTimeToggle = true;
+          dateTimeToggle = false;
           lcd.print("Time: ");
           uint8_t hour = GPSData.hour;
           uint8_t day  = GPSData.day;
@@ -418,10 +416,10 @@
           lcd.print("   UTC");
 #endif // #ifdef DISPLAY_12_HOUR
 #endif // #ifndef CONVERT_TO_LOCAL
-        } // if (!dateTimeToggle)
+        } // if (dateTimeToggle)
         else {
           // Display date
-          dateTimeToggle = false;
+          dateTimeToggle = true;
           lcd.print("Date: ");
           uint8_t hour = GPSData.hour;
           uint8_t day  = GPSData.day;
@@ -440,7 +438,7 @@
           lcd.print("/");
           lcd.print(year);
           printDay (dayOfWeek (year, month, day));
-        } // if (!dateTimeToggle)
+        } // if (dateTimeToggle)
       } // if (now - prevDateTime > TOGGLETIME_INTERVAL)
     } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
 #endif //------------------------------------------------------------


Delete GPSLCD.ino

Delete GPSLCD.ino

--- GPSLCD.ino
+++ GPSLCD.ino
@@ -1,642 +0,0 @@
-/* GPS LCD
-
-    By GK Grotsky
-    8/30/16
-
-  This program communicate with the u-blox NEO-6M GPS module
-  through a software serial interface. It then displays certain GPS
-  parameters on a I2C 16x2 (or 20x4) character LCD display module. The
-  GPS messages are received by the on-board Arduino UART circuit using
-  the SoftwareSerial library. It then uses the TinyGPS++ library to
-  decode the GPS NMEA messages. The parameters are then displayed on a
-  16x4 (or 20x4) LCD using the LiquidCrystal_I2C library.
-
-  Note: Both the 16x2 and 20x4 LCDs are supported as these are the most popular
-        LCDs available.
-*/
-#include "GPSLCD.h"
-#include <TinyGPS++.h>
-#include <SoftwareSerial.h>
-#include <LiquidCrystal_I2C.h>
-
-TinyGPSPlus gps; // This is the GPS object that will pretty much do all the grunt work with the NMEA data
-SoftwareSerial GPSModule(10, 11); // RX, TX
-LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); // Initializes class variables and defines the I2C address of the LCD
-bool dataValid; // Data is valid from the GPS module
-GPSStruct GPSData; // Holds the GPS data coming from the GPS module
-
-// The setup (runs once at start up)
-void setup()
-{
-  pinMode(BACKLIGHT_SW, INPUT);
-
-#ifdef _16x2
-  // Selects either speed or heading to be displayed
-  pinMode(SPEED_ALTITUDE_SW, INPUT);
-#else
-  // Selects either altitude or the date/time to be displayed
-  pinMode(ALTITUDE_DATE_TIME_SW, INPUT);
-#endif
-
-#ifdef DEBUG
-  Serial.begin(9600); // This opens up communications to the serial monitor in the Arduino IDE
-  Serial.flush();
-#endif
-  GPSModule.begin(9600); // This opens up communications to the software serial tx and rx lines
-  GPSModule.flush();
-
-  lcd.begin (COLUMN, ROW); // Defines LCD type
-  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE); // Sets the pin to control the backlight
-  lcd.clear(); // Clear the LCD
-  lcd.home (); // Go to the home position on the LCD
-} // setup
-
-// The loop (runs forever and a day :-))
-void loop()
-{
-  static uint32_t pastSatellites = 0;
-  static byte initializingCounter = 0;
-  static unsigned long prevInitializationTime = INITIALIZATION_INTERVAL;
-  static unsigned long prevCreditTime = TOGGLETIME_INTERVAL;
-  static unsigned long prevInvalidSatellitesTime = TOGGLETIME_INTERVAL;
-  static bool leftInitialization = false;
-  static bool creditToggle = true;
-  static bool InvalidSatellitesToggle = true;
-#ifndef _16x2
-  static unsigned long prevDateTime = TOGGLETIME_INTERVAL;
-  static unsigned long prevHeadingTime = TOGGLETIME_INTERVAL;
-  static bool dateTimeToggle = true;
-  static bool headingToggle = true;
-#endif
-#ifdef DEBUG
-  static unsigned long prevDebugTime = 0;
-#endif
-#ifdef DATA_VALID_OVERRIDE
-  const bool dataValidOverride = true; // Set true to override data valid for debugging
-#else
-  const bool dataValidOverride = false; // Set false not to override data valid
-#endif
-#ifdef BACKLIGHT_OVERRIDE
-  // Override LCD backlight switch
-  // Force LCD backlight on/off
-  lcd.setBacklight(BACKLIGHT_ONOFF);
-#else
-  // Turn LCD backlight on/off
-  lcd.setBacklight(digitalRead(BACKLIGHT_SW));
-#endif
-  unsigned long now = millis();
-
-  while (GPSModule.available()) // While there are characters to come from the GPS
-  {
-    bool b = gps.encode(GPSModule.read()); // This feeds the serial NMEA data into the GPS library one char at a time
-  }
-
-  // Get the GPS data valid flags
-  dataValid =
-    gps.location.isValid()   &&
-    gps.speed.isValid()      &&
-    gps.altitude.isValid()   &&
-    gps.course.isValid()     &&
-    gps.date.isValid()       &&
-    gps.time.isValid()       &&
-    gps.satellites.isValid();
-
-  // Check if the GPS data is valid or data valid override is set (for debugging)
-  if (dataValid || dataValidOverride) {
-#ifndef DATA_VALID_OVERRIDE
-    // Store the real GPS data
-    GPSData.satellites = gps.satellites.value();
-    GPSData.lat        = gps.location.lat();
-    GPSData.lon        = gps.location.lng();
-    GPSData.speed      = gps.speed.mph();
-    GPSData.altitude   = gps.altitude.feet();
-#ifndef _16x2
-    GPSData.heading    = gps.course.deg();
-    GPSData.year       = gps.date.year();
-    GPSData.month      = gps.date.month();
-    GPSData.day        = gps.date.day();
-    GPSData.hour       = gps.time.hour();
-    GPSData.minute     = gps.time.minute();
-    GPSData.second     = gps.time.second();
-#endif // #ifndef _16x2
-#else // #ifndef DATA_VALID_OVERRIDE
-    // Store the fake GPS data (for debugging)
-    GPSData.satellites = 0; // Invalid satellites
-    GPSData.lat        = 39.16d; // East coast
-    GPSData.lon        = -77.07d; //   "
-    GPSData.speed      = 55.0d;
-    GPSData.altitude   = 555.0d;
-#ifndef _16x2
-    GPSData.heading    = 60.0d; // ENE or NE (16 cardinal point or 8 cardinal point)
-    GPSData.year       = 2016;
-    GPSData.month      = 11; // Day before ST starts
-    GPSData.day        = 5;  //      "
-    GPSData.hour       = 23; // 7pm my local time
-    GPSData.minute     = 10;
-    GPSData.second     = 25;
-#endif // #ifndef _16x2
-#endif // #ifndef DATA_VALID_OVERRIDE
-    // Clear the screen once when leaving initialization
-    if (!leftInitialization) {
-      leftInitialization = true;
-      lcd.clear(); // Clear the LCD
-    }
-    // Display the latest info from the gps object which it derived from the data sent by the GPS unit
-    // Send data to the LCD
-#ifdef _16x2 //------------------------------------------------------
-    lcd.home (); // Go to 1st line
-    lcd.print("Lat: ");
-    lcd.print(GPSData.lat);
-    lcd.setCursor (11, 0);
-    lcd.print("SV:");
-    if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0)) {
-      pastSatellites = GPSData.satellites;
-      if (GPSData.satellites == 0) {
-        // Toggle invalid satellites indicator every TOGGLETIME_INTERVAL seconds
-        if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL / 4) {
-          prevInvalidSatellitesTime = now;
-          if (InvalidSatellitesToggle) {
-            InvalidSatellitesToggle = false;
-            lcd.print("XX");
-          }
-          else {
-            InvalidSatellitesToggle = true;
-            lcd.print("  ");
-          } // if (InvalidSatellitesToggle)
-        } // if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL)
-      } // if (GPSData.satellites == 0)
-      else if (GPSData.satellites <= 9) {
-        lcd.print(" "); // Blank leading char
-        lcd.print(GPSData.satellites);
-      }
-      else {
-        lcd.print(GPSData.satellites);
-      }
-    } // if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0))
-    lcd.setCursor (0, 1); // Go to 2nd line
-    lcd.print("Lon: ");
-    lcd.print(GPSData.lon);
-    if ((digitalRead(SPEED_ALTITUDE_SW))) {
-      lcd.setCursor (12, 1);
-      if (GPSData.speed < SPEED_CUTOUT) {
-        lcd.print("0  ");
-      }
-      else {
-        lcd.print((int)GPSData.speed);
-        lcd.print(" "); // Clear the extra char
-      }
-    }
-    else {
-      lcd.print("     "); // Clear the extra chars
-      if (GPSData.altitude <= 99.9) {
-        lcd.setCursor (14, 1);
-      }
-      else {
-        lcd.setCursor (13, 1);
-      }
-      lcd.print((int)GPSData.altitude); // Altitude
-      // Toggle credit every TOGGLETIME_INTERVAL seconds
-      if (now - prevCreditTime > (TOGGLETIME_INTERVAL / 2)) {
-        prevCreditTime = now;
-        if (creditToggle) { // Display credit
-          creditToggle = false;
-          lcd.print("     "); // Clear the extra chars
-          lcd.print(CREDIT); // Yours truly :-)
-        }
-        else {
-          creditToggle = true;
-          lcd.print("        "); // Clear the extra chars
-        }
-      } // if (now - prevCreditTime > TOGGLETIME_INTERVAL)
-    } // if ((digitalRead(SPEED_ALTITUDE_SW)))
-#else // 20x4 ----------------------------------------------------
-    lcd.home (); // Go to 1st line
-    lcd.print("Lat: ");
-    lcd.print(GPSData.lat);
-    lcd.setCursor (15, 0);
-    lcd.print("SV:");
-    if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0)) {
-      pastSatellites = GPSData.satellites;
-      if (GPSData.satellites == 0) {
-        // Toggle invalid satellites indicator every TOGGLETIME_INTERVAL seconds
-        if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL / 3) {
-          prevInvalidSatellitesTime = now;
-          if (InvalidSatellitesToggle) {
-            InvalidSatellitesToggle = false;
-            lcd.print("XX");
-          }
-          else {
-            InvalidSatellitesToggle = true;
-            lcd.print("  ");
-          } // if (InvalidSatellitesToggle)
-        } // if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL)
-      } // if (GPSData.satellites == 0)
-      else if (GPSData.satellites <= 9) {
-        lcd.print(" "); // Blank leading char
-        lcd.print(GPSData.satellites);
-      }
-      else {
-        lcd.print(GPSData.satellites);
-      }
-    } // if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0))
-    lcd.setCursor (0, 1); // Go to 2nd line
-    lcd.print("Lon: ");
-    lcd.print(GPSData.lon);
-#ifndef CONVERT_TO_LOCAL
-    // Only display if time/date is selected
-    if (!(digitalRead(ALTITUDE_DATE_TIME_SW))) {
-      lcd.print("      "); // Clear the extra chars
-      uint8_t DOW = dayOfWeek(GPSData.year, GPSData.month, GPSData.day);
-      if (IsDST(GPSData.day, GPSData.month, DOW)) {
-        lcd.print("DST");
-      }
-      else {
-        lcd.print(" ST");
-      }
-    }
-    else {
-      lcd.print("         "); // Clear the extra chars
-    }
-#endif // #ifndef CONVERT_TO_LOCAL
-    lcd.setCursor (0, 2); // Go to 3rd line
-    lcd.print("Spd: ");
-    if (GPSData.speed < SPEED_CUTOUT) {
-      lcd.print("0  ");
-    }
-    else {
-      lcd.print((int)GPSData.speed);
-      lcd.print(" "); // Clear the extra chars
-    }
-    lcd.setCursor (12, 2);
-    lcd.print("Hdg: ");
-    if (GPSData.speed < SPEED_CUTOUT) {
-      lcd.print("0  ");
-    }
-    else {
-      // Toggle heading every TOGGLETIME_INTERVAL seconds
-      if (now - prevHeadingTime > TOGGLETIME_INTERVAL) {
-        prevHeadingTime = now;
-        if (headingToggle) { // Display cardinal heading
-          headingToggle = false;
-          lcd.print(cardinal(GPSData.heading));
-        }
-        else { // Display degrees heading
-          headingToggle = true;
-          lcd.print((int)GPSData.heading);
-          if (GPSData.heading <= 99.9) lcd.print(" "); // Clear the extra char
-        } // if (headingToggle)
-      } // if (now - prevHeadingTime > TOGGLETIME_INTERVAL)
-    } // if (GPSData.speed < SPEED_CUTOUT)
-    lcd.setCursor (0, 3); // Go to 4th line
-    if ((digitalRead(ALTITUDE_DATE_TIME_SW))) {
-      lcd.print("Alt: ");
-      lcd.print((int)GPSData.altitude);
-      // Toggle credit every TOGGLETIME_INTERVAL seconds
-      if (now - prevCreditTime > (TOGGLETIME_INTERVAL / 2)) {
-        prevCreditTime = now;
-        if (creditToggle) { // Display credit
-          creditToggle = false;
-          lcd.print("         "); // Clear the extra chars
-          lcd.print(CREDIT); // Yours truly :-)
-        }
-        else {
-          creditToggle = true;
-          lcd.print("            "); // Clear the extra chars
-        }
-      } // if (now - prevCreditTime > TOGGLETIME_INTERVAL)
-      prevDateTime = TOGGLETIME_INTERVAL;
-      dateTimeToggle = true; // Default first to display date
-    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
-    else {
-      // Toggle date/time every TOGGLETIME_INTERVAL seconds
-      if (now - prevDateTime > TOGGLETIME_INTERVAL) {
-        prevDateTime = now;
-        if (dateTimeToggle) {
-          // Display date
-          dateTimeToggle = false;
-          lcd.print("Date: ");
-          uint8_t hour = GPSData.hour;
-          uint8_t day  = GPSData.day;
-          uint8_t month = GPSData.month;
-          uint16_t year = GPSData.year;
-#ifdef CONVERT_TO_LOCAL
-          // Convert UTC date to local date
-          bool DST = convertToLocal (&hour, &year, &month,
-                                     &day, GPSData.lon, true); // true means date conversion
-#endif // #ifdef CONVERT_TO_LOCAL
-          if (month < 10) lcd.print("0");
-          lcd.print(month);
-          lcd.print("/");
-          if (day < 10) lcd.print("0");
-          lcd.print(day);
-          lcd.print("/");
-          lcd.print(year);
-          printDay (dayOfWeek (year, month, day));
-        } // if (dateTimeToggle)
-        else {
-          // Display time
-          dateTimeToggle = true;
-          lcd.print("Time: ");
-          uint8_t hour = GPSData.hour;
-          uint8_t day  = GPSData.day;
-          uint8_t month = GPSData.month;
-          uint16_t year = GPSData.year;
-#ifdef CONVERT_TO_LOCAL
-          // Convert UTC time to local time (no need to convert the date)
-          bool DST = convertToLocal (&hour, &year, &month,
-                                     &day, GPSData.lon, false); // false means no date conversion
-#else // #ifdef CONVERT_TO_LOCAL
-#ifdef DISPLAY_12_HOUR
-          if (hour == 0) { // 12 hour clocks don't display 0
-            hour = 12;
-          }
-#endif // #ifdef DISPLAY_12_HOUR
-#endif // #ifdef CONVERT_TO_LOCAL
-#ifdef DISPLAY_12_HOUR
-          char AMPM[] = "am";
-          if (hour >= 12) { // Convert to 12 hour format
-            if (hour > 12) hour -= 12;
-            strcpy (AMPM, "pm");
-          }
-#endif
-          if (hour < 10) lcd.print("0");
-          lcd.print(hour);
-          lcd.print(":");
-          if (GPSData.minute < 10) lcd.print("0");
-          lcd.print(GPSData.minute);
-          lcd.print(":");
-          if (GPSData.second < 10) lcd.print("0");
-          lcd.print(GPSData.second);
-#ifdef DISPLAY_12_HOUR
-          lcd.print(AMPM);
-#endif // #ifdef DISPLAY_12_HOUR
-#ifdef CONVERT_TO_LOCAL
-#ifdef DISPLAY_12_HOUR
-          (DST) ? lcd.print(" DST") : lcd.print("  ST");
-#else // #ifdef DISPLAY_12_HOUR
-          (DST) ? lcd.print("   DST") : lcd.print("    ST");
-#endif // #ifdef DISPLAY_12_HOUR
-#endif // #ifndef CONVERT_TO_LOCAL
-#ifndef CONVERT_TO_LOCAL
-#ifdef DISPLAY_12_HOUR
-          lcd.print(" UTC");
-#else // #ifdef DISPLAY_12_HOUR
-          lcd.print("   UTC");
-#endif // #ifdef DISPLAY_12_HOUR
-#endif // #ifndef CONVERT_TO_LOCAL
-        } // if (dateTimeToggle)
-      } // if (now - prevDateTime > TOGGLETIME_INTERVAL)
-    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
-#endif //------------------------------------------------------------
-  } // if (dataValid)
-  else {
-    // GPS data is not valid, so it must be initializing
-#ifdef _16x2 //------------------------------------------------------
-    // Display initialization screen once every INITIALIZATION_INTERVAL
-    if (now - prevInitializationTime > INITIALIZATION_INTERVAL) {
-      prevInitializationTime = now;
-      lcd.setCursor (6, 0); // Go to 1st line
-      lcd.print("GPS");
-      lcd.setCursor (11, 0);
-      lcd.print("v");
-      lcd.print(VERSION);
-      lcd.setCursor (2, 1); // Go to 2nd line
-      lcd.print("Initializing");
-      lcd.setCursor (15, 1);
-      if (++initializingCounter > 9) initializingCounter = 1; // Limit 1 - 9
-      lcd.print(initializingCounter);
-      leftInitialization = false;
-    }
-#else // 20x4 -------------------------------------------------------
-    // Display initialization screen once every INITIALIZATION_INTERVAL
-    if (now - prevInitializationTime > INITIALIZATION_INTERVAL) {
-      prevInitializationTime = now;
-      lcd.setCursor (8, 0); // Go to 1st line
-      lcd.print("GPS");
-      lcd.setCursor (14, 0);
-      lcd.print("v");
-      lcd.print(VERSION);
-      lcd.setCursor (4, 1); // Go to 2nd line
-      lcd.print("Initializing");
-      lcd.setCursor (6, 2); // Go to 3rd line
-      lcd.print("Data Not");
-      lcd.setCursor (7, 3); // Go to 4th line
-      lcd.print("Valid");
-      lcd.setCursor (19, 3);
-      if (++initializingCounter > 9) initializingCounter = 1; // Limit 1 - 9
-      lcd.print(initializingCounter);
-      leftInitialization = false;
-    }
-#endif //------------------------------------------------------------
-  } // GPS data is not valid
-#ifdef DEBUG
-  // Display debug info to the serial monitor (if DEBUG is enabled)
-  // Display debug data once every DEBUG_INTERVAL
-  if (now - prevDebugTime > DEBUG_INTERVAL) {
-    prevDebugTime = now;
-    displayDebugData();
-  }
-#endif // #ifdef DEBUG
-} // loop
-
-#ifndef _16x2
-/* Helper functions start here
-
-  Ripped off from Electrical Engineering Stack Exchange
-  http://electronics.stackexchange.com/questions/66285/how-to-calculate-day-of-the-week-for-rtc
-  ------------------------------------------------------------
-   Returns the number of days to the start of the specified year, taking leap
-   years into account, but not the shift from the Julian calendar to the
-   Gregorian calendar. Instead, it is as though the Gregorian calendar is
-   extrapolated back in time to a hypothetical "year zero".
-*/
-uint16_t leap (uint16_t year)
-{
-  return year * 365 + (year / 4) - (year / 100) + (year / 400);
-}
-/* Returns a number representing the number of days since March 1 in the
-   hypothetical year 0, not counting the change from the Julian calendar
-   to the Gregorian calendar that occurred in the 16th century. This
-   algorithm is loosely based on a function known as "Zeller's Congruence".
-   This number MOD 7 gives the day of week, where 0 = Monday and 6 = Sunday.
-*/
-uint16_t zeller (uint16_t year, uint8_t month, uint8_t day)
-{
-  year += ((month + 9) / 12) - 1;
-  month = (month + 9) % 12;
-  return leap (year) + month * 30 + ((6 * month + 5) / 10) + day + 1;
-}
-
-// Returns the day of week for a given date.
-uint8_t dayOfWeek (uint16_t year, uint8_t month, uint8_t day)
-{
-  return (zeller (year, month, day) % 7) + 1;
-}
-//----------------------------------------------------------
-
-// Print the day of the week on the LCD
-void printDay(uint8_t day)
-{
-  if (day == 7) day = 0;
-  switch (day)
-  {
-    case 0:  lcd.print(" Mon"); break;
-    case 1:  lcd.print(" Tue"); break;
-    case 2:  lcd.print(" Wed"); break;
-    case 3:  lcd.print(" Thu"); break;
-    case 4:  lcd.print(" Fri"); break;
-    case 5:  lcd.print(" Sat"); break;
-    case 6:  lcd.print(" Sun"); break;
-    default: lcd.print(" Err");
-  }
-}
-
-// Compute the cardinal points of the compass
-const char* cardinal(double course)
-{
-#ifdef _16CARDINAL
-  const char* directions[] = {"N  ", "NNE", "NE ", "ENE", "E  ", "ESE", "SE ", "SSE",
-                              "S  ", "SSW", "SW ", "WSW", "W  ", "WNW", "NW ", "NNW"
-                             };
-#else
-  const char* directions[] = {"N  ", "N  ", "NE ", "NE ", "E  ", "E  ", "SE ", "SE ",
-                              "S  ", "S  ", "SW ", "SW ", "W  ", "W  ", "NW ", "NW "
-                             };
-#endif // #ifdef _16CARDINAL
-  uint8_t direction = (uint8_t)((course + 11.25d) / 22.5d);
-  return directions[direction % 16];
-}
-
-/* Ripped off from Stackoverflow
-  http://stackoverflow.com/questions/5590429/calculating-daylight-saving-time-from-only-date
-
-  Check to see if it's Daylight Savings Time (DST)
-*/
-bool IsDST(uint8_t day, uint8_t month , uint8_t DOW)
-{
-  // Make Day of Week (DOW) match with what Stackoverflow suggests
-  // for DOW (Sunday = 0 to Saturday = 6)
-  switch (DOW)
-  {
-    case 6:  DOW = 0; break; // Sun
-    case 7:  DOW = 1; break; // Mon
-    case 1:  DOW = 2; break; // Tue
-    case 2:  DOW = 3; break; // Wed
-    case 3:  DOW = 4; break; // Thu
-    case 4:  DOW = 5; break; // Fri
-    case 5:  DOW = 6; break; // Sat
-    default: break;
-  }
-  // January, February, and December are out
-  if (month < 3 || month > 11) {
-    return false;
-  }
-  // April to October are in
-  if (month > 3 && month < 11) {
-    return true;
-  }
-  int previousSunday = (int)(day - DOW);
-  // In march, we are DST if our previous Sunday was on or after the 8th
-  if (month == 3) {
-    return previousSunday >= 8;
-  }
-  // In November we must be before the first Sunday to be DST
-  // That means the previous Sunday must be before the 1st
-  return previousSunday <= 0;
-}
-
-#ifdef CONVERT_TO_LOCAL
-/* Convert UTC time and date to local time and date
-   Difference between UTC time/date (at Greenwich) and local time/date is 15 minutes
-   per 1 degree of longitude. See the following:
-   http://www.edaboard.com/thread101516.html
-*/
-bool convertToLocal (uint8_t* hour, uint16_t* year, uint8_t* month,
-                     uint8_t* day, const double lon, bool convertDate) {
-
-  uint8_t DaysAMonth [] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-
-  // Get Day of Week (DOW)
-  uint8_t DOW = dayOfWeek(*year, *month, *day);
-  // Get Daylight Saving Time (DST) or Standard Time (ST)
-  bool DST = IsDST(*day, *month, DOW);
-  // Compute local time (hours)
-  int UTCOffset = (int)(lon / 15.0d); // UTC offset
-  if (UTCOffset < 0) {
-    // West of Greenwich, subtract
-    UTCOffset = abs(UTCOffset); // Make offset positive
-    if (DST) --UTCOffset; // Compensate for DST
-    if (*hour <= UTCOffset) *hour += 24;
-    *hour = *hour - UTCOffset; // Subtract offset
-  }
-  else {
-    // East of Greenwich, add
-    if (DST) ++UTCOffset; // Compensate for DST
-    if (*hour <= UTCOffset) *hour += 24;
-    *hour = *hour + UTCOffset; // Add offset
-  }
-  // Convert date if convertDate flag is set
-  // Portions of the following code (with some modifications) ripped off from Instructables
-  // http://www.instructables.com/id/GPS-time-UTC-to-local-time-conversion-using-Arduin/?ALLSTEPS
-  if (convertDate) {
-    if ((24 - *hour) <= UTCOffset) { // A new UTC day started
-      if (*year % 4 == 0) DaysAMonth[1] = 29; //leap year check (the simple method)
-      if (*hour < 24) {
-        *day -= 1;
-        if (*day < 1) {
-          if (*month == 1) {
-            *month = 12;
-            *year -= 1;
-          } // if (*month == 1)
-          else {
-            *month -= 1;
-          }
-          *day = DaysAMonth[*month - 1];
-        } // if (*day < 1)
-      } // if (*hour < 24)
-      else if (*hour >= 24) {
-        day += 1;
-        if (*day > DaysAMonth[*month - 1]) {
-          *day = 1;
-          *month += 1;
-          if (*month > 12) *year += 1;
-        } // if (*day > DaysAMonth[*month - 1])
-      } // if (*hour >= 24)
-    } // if ((24 - *hour) <= UTCOffset)
-  } // if (convertDate)
-  return (DST);
-}
-#endif // #ifdef CONVERT_TO_LOCAL
-#endif // #ifndef _16x2
-
-#ifdef DEBUG
-// Displays debug data to the serial monitor
-void displayDebugData() {
-  Serial.print("Version: ");
-  Serial.println(VERSION);
-  Serial.print("Satellite Count: ");
-  Serial.println(GPSData.satellites);
-  Serial.print("Latitude: ");
-  Serial.println(GPSData.lat, 6);
-  Serial.print("Longitude: ");
-  Serial.println(GPSData.lon, 6);
-  Serial.print("Speed MPH: ");
-  Serial.println(GPSData.speed);
-  Serial.print("Altitude Feet: ");
-  Serial.println(GPSData.altitude);
-#ifdef _16x2
-  Serial.print("Alt/SPD: ");
-  Serial.println((digitalRead(SPEED_ALTITUDE_SW)) ? "Speed" : "Altitude");
-#else
-  Serial.print("Altitude/Date: ");
-  Serial.println(!(digitalRead(ALTITUDE_DATE_TIME_SW)) ? "Date/Time" : "Altitude");
-#endif
-  Serial.println((digitalRead(BACKLIGHT_SW)) ? "Backlight On" : "Backlight Off");
-  Serial.print("Data valid: ");
-  Serial.println(dataValid);
-  uint8_t DOW = dayOfWeek(GPSData.year, GPSData.month, GPSData.day);
-  Serial.print("DST = ");
-  Serial.println(IsDST(GPSData.day, GPSData.month, DOW));
-  Serial.println("");
-}
-#endif


Use DAC

Use DAC

--- receiver_analog/receiver_analog.ino
+++ receiver_analog/receiver_analog.ino
@@ -35,7 +35,7 @@

 byte sleep_mode = SLEEP_MODE_PWR_SAVE;
 int parsed_val = 0;
-int solar_val = 4000; // 12bit DAC
+int solar_val = 3685; // 12bit DAC (max 4095 = 0xFFF)
 volatile byte wd_isr = WD_DO_STUFF;

@@ -61,12 +61,11 @@
   ACSR = (1 << ACD) | (0 << ACIE);

   power_spi_disable();
-  power_twi_disable();

   watchdog_setup();

   // Try a lower frequency pwm to prevent the buzzzzz from the analogue voltmeter.
-  setPwmFrequency(256);
+  //setPwmFrequency(256);

   pinMode(DEBUG_LED_PIN, OUTPUT);
   analogWrite(DEBUG_LED_PIN, DEBUG_LED_PWM_AWAKE);
@@ -273,18 +272,9 @@
   // ensure ADC is off
   ADCSRA = 0;

-  if (mode == SLEEP_MODE_PWR_DOWN) {
-    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
-    power_all_disable();
-  } else {
-    // Keep pwm on
-    set_sleep_mode(SLEEP_MODE_PWR_SAVE);
-    power_timer0_disable();
-    power_timer1_disable();
-    power_usart0_disable();
-    // leaving timer2 on for the pwm
-  }
-
+  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+  power_all_disable();
+
   sleep_enable();
   sei();

@@ -296,10 +286,12 @@
   sleep_disable();
   MCUSR = 0; // clear the reset register

+
   power_timer0_enable();
   power_timer1_enable();
-  power_timer2_enable();
+  //power_timer2_enable();
   power_usart0_enable();
+  power_twi_enable();

   // turn on the RF receiver
   digitalWrite(RF_POWER_PIN, HIGH);


File rename

File rename

--- T0/src/AFE-MQTT-listener.ino
+++ T0/src/AFE-MQTT-listener.ino
@@ -1,75 +0,0 @@
-/* AFE Firmware for smart home devices
-  LICENSE: https://github.com/tschaban/AFE-Firmware/blob/master/LICENSE
-  DOC: http://smart-house.adrian.czabanowski.com/afe-firmware-pl/ */
-
-#if defined(ARDUINO) && ARDUINO >= 100
-#include "arduino.h"
-#else
-#include "WProgram.h"
-#endif
-
-/* Method is launched after MQTT Message is received */
-void MQTTMessagesListener(char *topic, byte *payload, unsigned int length) {
-
-  char _mqttTopic[50];
-  Led.on();
-  // Serial << endl << "INFO: MQTT message recieved: " << topic << " \\ ";
-
-  if (length >= 1) { // command arrived
-                     /*
-                         for (uint8_t i = 0; i < length; i++) {
-                           Serial << (char)payload[i];
-                         }
-                     */
-    sprintf(_mqttTopic, "%scmd", Relay.getMQTTTopic());
-    /*
-        Serial << endl
-               << "DEBUG: "
-               << "checking relay messages: " << _mqttTopic;
-    */
-    if (strcmp(topic, _mqttTopic) == 0) {
-      if ((char)payload[1] == 'n') {
-        Relay.on();
-        Mqtt.publish(Relay.getMQTTTopic(), "state", "on");
-      } else if ((char)payload[1] == 'f') {
-        Relay.off();
-        Mqtt.publish(Relay.getMQTTTopic(), "state", "off");
-      } else if ((char)payload[1] == 'e') { // reportState
-        Mqtt.publish(Relay.getMQTTTopic(), "state",
-                     Relay.get() == RELAY_ON ? "on" : "off");
-      } else if ((char)payload[1] == 'o') { // toggle
-        Relay.get() == RELAY_ON ? Relay.off() : Relay.on();
-        Mqtt.publish(Relay.getMQTTTopic(), "state",
-                     Relay.get() == RELAY_ON ? "on" : "off");
-      }
-    }
-
-    sprintf(_mqttTopic, "%scmd", MQTTConfiguration.topic);
-    /*
-        Serial << endl
-               << "DEBUG: "
-               << "checking device level messages: " << _mqttTopic;
-    */
-    if (strcmp(topic, _mqttTopic) == 0) {
-      if ((char)payload[2] == 'b') { // reboot
-        //      Serial << endl << "INFO: Process: reboot";
-        Device.reboot(MODE_NORMAL);
-      } else if ((char)payload[2] == 'n') { // configurationMode
-        //    Serial << endl << "INFO: Process: configuration Mode";
-        Device.reboot(MODE_CONFIGURATION);
-      }
-    }
-  }
-  Led.off();
-}
-
-/* Metod publishes Relay state (used eg by HTTP API) */
-void MQTTPublishRelayState() {
-  if (Device.configuration.mqttAPI) {
-    if (Relay.get() == RELAY_ON) {
-      Mqtt.publish(Relay.getMQTTTopic(), "state", "on");
-    } else {
-      Mqtt.publish(Relay.getMQTTTopic(), "state", "off");
-    }
-  }
-}


version 1.5

version 1.5

update GPRS_ConnectTCP.ino

--- example/GPRS_ConnectTCP/GPRS_ConnectTCP.ino
+++ example/GPRS_ConnectTCP/GPRS_ConnectTCP.ino
@@ -12,12 +12,12 @@
 #include <gprs.h>
 #include <SoftwareSerial.h>

-#define PHONE_NUMBER    "13925257382"
+#define PHONE_NUMBER    "139****7382"
 #define IP_ADDRSS       "216.52.233.120" //api.xively.com
 #define PORT            80 //port addr
-#define FEED_ID         "259586273"
-#define SENSOR_ID       "LED"
-#define XIVELY_KEY      "d3V6YQek8iBSxoFg0xZYkZBhpBhXTH485XFY0ubPqZIvm0e8"
+#define FEED_ID         "YOUR FEED ID"
+#define SENSOR_ID       "YOUR SENSOR ID"
+#define XIVELY_KEY      "YOUR XIVELY KEY"
 #define REQUEST_LENGTH  36
 #define DATA_LENGTH     90
 #define HEAD_LEN        270
@@ -42,11 +42,6 @@
     goto STOP;
   }
 STOP:
-#if 0
-  while(gprsTest.serialSIM800.available()){
-     gprsTest.serialSIM800.read();
-  }
-#endif
   gprsTest.closeTCP();
   return 0;
 }


update button test

update button test

--- proj/ledvo_lounge_button_test/ledvo_lounge_button_test.ino
+++ proj/ledvo_lounge_button_test/ledvo_lounge_button_test.ino
@@ -50,14 +50,14 @@
 const uint16_t led_5ft_strand = 90; // The size of one module

 const uint16_t ih_LED_per_strand = 2*led_5ft_strand; // 90 LED per 5' strand with 10' hexagon sides on the inside
-const uint16_t ih_LED_total = 3*ih_LED_per_strand;
+const uint16_t ih_LED_total = led_5ft_strand;
 CRGBArray<ih_LED_total> ih_leds;

 const uint16_t oh_LED_per_strand = 4*led_5ft_strand; // 90 LED per 5' strand with 20' hexagon sides on outside
-const uint16_t oh_LED_total = 3*oh_LED_per_strand;
+const uint16_t oh_LED_total = led_5ft_strand;
 CRGBArray<oh_LED_total> oh_leds;

-const uint16_t d_LED_num = 2*led_5ft_strand; // 90 LED per 5' strand with 10' diagonals
+const uint16_t d_LED_num = led_5ft_strand; // 90 LED per 5' strand with 10' diagonals
 CRGBArray<d_LED_num> d_leds[3];

 // Variables for pin interrupts. There's a lot of these babies ;^)


modified:   Gbrl_H_07-03-2015/Gbrl_H_07-03-2015.ino

--- Gbrl_H_07-03-2015/Gbrl_H_07-03-2015.ino
+++ Gbrl_H_07-03-2015/Gbrl_H_07-03-2015.ino
@@ -293,6 +293,7 @@
           }   //AA
         case 2:       //BB
           ZZ.information("gsender active");
+// update 03-06
           Serial3.write('CTRL-X'); // Reset Grbl
           // read from port 3, send to port 0:
           while (1==1) {


Update Docking.ino

Update Docking.ino

--- 10Docking/Docking.ino
+++ 10Docking/Docking.ino
@@ -12,21 +12,27 @@
 }

 void loop(){
+  int val = None;
+  if (val == None || val != digitalRead(3)){
+    val = digitalRead(3);
+
+    if (val == HIGH){
+      Serial.write("ON");
+      Serial.println("000"); //healthy
+    }

-  if (digitalRead(3) == HIGH){
-    Serial.write("ON");
-    Serial.println("000"); //healthy
+    else if (val == LOW){
+      Serial.write("OFF");
+      Serial.println("000"); //healthy
+    }
+
+    else{
+      Serial.println("003"); //Something is wrong with the detection circuit
+    }
   }

-  else if (digitalRead(3) == LOW){
-    Serial.write("OFF");
-    Serial.println("000"); //healthy
-  }
-
-  else{
-    Serial.println("003"); //Something is wrong with the detection circuit
-  }
-
+  else{}
+
   if (Serial.available()){
     int i = Serial.read();


Update Otto_avoid_TRIMS.ino

Update Otto_avoid_TRIMS.ino


Added support for push button

Added support for push button

--- Particle/THDweeter/src/THDweeter.ino
+++ Particle/THDweeter/src/THDweeter.ino
@@ -20,6 +20,7 @@

 int led = D7;           // internal LED
 int pushButton = D5;    // Push button is connected to D5
+int i = 0;              // time counter

 // Connect pin 1 (on the left) of the sensor to +5V
 // Connect pin 2 of the sensor to whatever your DHTPIN is
@@ -36,7 +37,6 @@
   { "Accept" , "*/*"},
   { NULL, NULL } // NOTE: Always terminate headers will NULL
 };
-
 http_request_t request;
 http_response_t response;

@@ -70,18 +70,15 @@
  	// cast floats to string
  	String st(t, 2);
  	String sh(h, 2);
- 	// publish data
- 	Particle.publish("TEMP", st);
- 	Particle.publish("HUMIDITY", sh);

  	//post to dweet
  	request.hostname = "dweet.io";
   request.port = 80;
   request.path = "/dweet/for/glp_photon_vth?temp=" + st + "&humidity=" + sh + "&time=" + Time.timeStr();
- 	Particle.publish("DEBUG",request.body);
+ 	Particle.publish("Sensor data", request.path);
   http.get(request, response, headers);
   //Particle.publish("DEBUG",response.status);
-  Particle.publish("DEBUG",response.body);
+  Particle.publish("DEBUG", response.body);

   // Done, switch off LED
   digitalWrite(led, LOW);
@@ -90,8 +87,19 @@
  }

 void loop() {
-  // Wait a minute between measurements.
-  delay(10000);
-  // read and publish sensor data
-  readout();
+  int pushButtonState = digitalRead(pushButton);
+  if(pushButtonState == LOW) {
+    // button was pressed, readout
+    Particle.publish("BUTTON", "Button pressed, reading data");
+    readout();
+    i = 0;
+  }
+  else {
+    i++;
+    // after 5 minutes force a readout
+    if(i == 100) {
+      readout();
+    }
+  }
+  delay(100);
 }


small calculation fixed

small calculation fixed

--- ArduCAM_OSD/OSD_Config_Func.ino
+++ ArduCAM_OSD/OSD_Config_Func.ino
@@ -220,14 +220,14 @@
 	//	}
 	ch_toggle = EEPROM.read(ch_toggle_ADDR);
 	//  battp = EEPROM.read(battp_ADDR);
-	rssical = EEPROM.read(OSD_RSSI_HIGH_ADDR);
+	//rssical = EEPROM.read(OSD_RSSI_HIGH_ADDR);
 	//rssipersent = EEPROM.read(OSD_RSSI_LOW_ADDR);
 	rssiraw_on = EEPROM.read(OSD_RSSI_RAW_ADDR);

 	rssi_min = EEPROM.read(RSSI_MIN_ADDR);
 	rssi_max = EEPROM.read(RSSI_MAX_ADDR);
-	rssi_range = rssi_max - rssi_min;
-	rssi_scale = rssi_range / 100.0f;
+	//rssi_range = rssi_max - rssi_min;
+	rssi_scale = (float)(rssi_max - rssi_min) / 100.0f;

 	/*batt_A_warn_level = EEPROM.read(OSD_BATT_A_WARN_ADDR);
 	batt_B_warn_level = EEPROM.read(OSD_BATT_B_WARN_ADDR);*/


[LogToCSV] Optimized code, added comments

--- LogToCSV/LogToCSV.ino
+++ LogToCSV/LogToCSV.ino
@@ -3,8 +3,10 @@

   This sketch sents values temperature, humidity, CO2 and the digital filter setting to the serial port in CSV format.
   After uploading, open the serial monitor (ctrl+shift+m) and follow instructions. The CSV data can be copied and pasted into a spreadsheet.
-  In order to keep memory and storage consumption low, but not average out extremes, the sketch polls 30 times as often as it logs. With every log entry, the extremes and the averages of those 30 measurements are recorded.
-
+  In order to keep memory and storage consumption low, but not average out extremes, the sketch polls more frequently than it logs.
+  As the log is kept in RAM, only a around 9 data points can be recorded. As opening the serial monitor resets the Arduino, logs can only be read if the computer is connected the whole logging period. Until I have a datalogger shield, it's something at least.
+  When memory is full, logs are no longer saved. Some messy last entries may show up.
+
   created 13 Feb 2015
   by Koos Looijesteijn

@@ -35,11 +37,12 @@
 SoftwareSerial nss(2,3); // Pin 2 = Arduino receiver pin (Rx), connect to sensor transmitter pin (Tx). Pin 3 = Arduino Tx, connect it to sensor Rx.
 COZIR czr(nss);

+// We poll more often than we log, so we can register some extremes occurring during the logging intervals without having to log huge amounts of data.
+const byte MEASUREMENTS_PER_LOG = 10;
 // Set measure and log intervals
-const byte MEASUREMENTS_PER_LOG = 30; // We poll more often than we record, so we can register the extremes without having to log huge amounts of data.
-byte pollingInterval = 1; // In seconds.  It takes about 30s for big changes even to be picked up by the sensor, so this number can stay high.
+const byte pollingInterval = 600; // In seconds. This number can stay high. It takes about 30s for big changes even to be picked up as a small difference by the sensor.
 byte pollingLoopCounter = 0;
-byte logInterval = MEASUREMENTS_PER_LOG*pollingInterval; // In seconds. This defines how often logs are saved.
+const byte logInterval = MEASUREMENTS_PER_LOG*pollingInterval; // In seconds. This defines how much time is between each log. It's not accurate.
 byte logLoopCounter = 0;

 // Special declaration for variables that are averaged with the Average library.
@@ -47,30 +50,24 @@
 Average<float> humidity(MEASUREMENTS_PER_LOG);
 Average<int> CO2(MEASUREMENTS_PER_LOG);

-// This will contain the measurement and now gets the CSV headings:
-String sLog = "Time,Temperature (low),Temperature,Temperature (high),Humidity (low),Humidity,Humidity (high),Carbon Dioxide (high),Carbon Dioxide,Carbon Dioxide (low)\r\n";
-
-// LED indicates when the clock needs to be reset
-const byte LED = 13;
+// This will contain the log:
+String sLog;

 /****************************
  Setup
 /****************************/
 void setup(){
-  pinMode(LED, OUTPUT); // LED needs pin set to output
   Serial.begin(9600); // Start communication over serial port.
   //setSyncProvider( requestSync );  //set function to call when sync required
-  Serial.println("\r\nPlease enter the current Unix time, for instance: 1423856136\r\n");// You can find the current time stamp on unixtimestamp.com
+  Serial.println("\r\nPlease enter the current Unix time, for instance: 1420070400\r\n");// You can find the current time stamp on unixtimestamp.com
 }

 /****************************
  Loop
 /****************************/
 void loop(){
-
+
   if (timeStatus() == timeSet) {
-    digitalWrite(LED, LOW); // Turn off LED when clock is set
-    //TODO klopt dat wel
     if ( pollingLoopCounter == pollingInterval ){
       pollData();
       pollingLoopCounter = 0;
@@ -86,7 +83,6 @@
     }
   }
   else {
-    digitalWrite(LED, HIGH); // Turn on LED when clock needs to be se
     if (Serial.available()) {
       processDateInput();
     }
@@ -97,7 +93,7 @@
 /****************************
  Functions called from Loop
 /****************************/
-// Process serial monitor commands
+// Process date commands
 void processDateInput() {
   unsigned long pctime;
   const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
@@ -111,6 +107,7 @@
     Serial.println("What?");
   }
 }
+// Process serial monitor commands
 void processSerialCommandInput() {
   String userInputMsg = "";
   char character;
@@ -123,11 +120,18 @@
     Serial.println("- " + userInputMsg + "\r\n");
   }
   if( userInputMsg == "csv" ){ // User requests CSV
-    Serial.println(sLog);
+    if ( sLog.length() > 0){
+      Serial.println("Time,Temperature (low),Temperature,Temperature (high),Humidity (low),Humidity,Humidity (high),Carbon Dioxide (low),Carbon Dioxide,Carbon Dioxide (high)");
+      Serial.println(sLog);
+    }
+    else{
+      Serial.println("Try again in a bit.");
+    }
   }
 }
 // Polling - requesting measurements from the sensor
 void pollData(){
+  // Measurements are pushed in arrays for each measurement type:
   temperatures.push(czr.Celsius());
   humidity.push(czr.Humidity());
   CO2.push(czr.CO2());
@@ -135,6 +139,7 @@
 // Logging of measurements
 void logData(){
   String sTime = getTimeString();
+  // Get for temperature, humidity and CO2 the lowest, average and highest measurements of the last logging interval:
   String sTemperatureMin = floatToString( temperatures.minimum() );
   String sTemperatureAvg = floatToString( temperatures.mean() );
   String sTemperatureMax = floatToString( temperatures.maximum() );
@@ -144,6 +149,7 @@
   String sCO2Min = floatToString( CO2.minimum() );
   String sCO2Avg = floatToString( CO2.mean() );
   String sCO2Max = floatToString( CO2.maximum() );
+  // Append the values to the log variable:
   sLog += sTime + "," + sTemperatureMin + "," + sTemperatureAvg + "," + sTemperatureMax + "," + sHumidityMin + "," + sHumidityAvg + "," + sHumidityMax + "," + sCO2Min + "," + sCO2Avg + "," + sCO2Max + "\r\n" ; // Append all measurements to the string
 }
 // Returns time as string
@@ -167,6 +173,4 @@
   dtostrf(f, 4, 1, buff);  // Convert float to string (variable, mininum width, precision, buffer)
   s += buff;
   return s;
-}
-
-
+}


Small changes.

Small changes.

--- Weight.ino
+++ Weight.ino
@@ -91,20 +91,11 @@

 //MENU
 char* EMPTY = "                ";
-char* beerSizes[] = {
-  "0.33", "0.5"};
-MenuItem menu[] = {
-  {
-    "Calibrate", 0  }
-  , {
-    "Tare", 1  }
-  , {
-    "Beersize", 2  }
-  , {
-    "Keg Weight", 3  }
-};
+char* beerSizes[] = {"0.33", "0.5"};
+MenuItem menu[] = {{"Calibrate", 0} , {"Tare", 1  } , {"Beersize", 2  } , {"Keg Weight", 3  }};
 unsigned int lastItem = 3;
 unsigned int menuMarker = 0;
+unsigned int level = 0;

 //GUI VARIABLES
 unsigned int printGUI = 0;
@@ -390,11 +381,16 @@
     Serial.println(sum);
 #endif
     EEPROM.writeDouble(scales[i].eepromAddress, sum);
-
-  }
-}
-
-void doSelect(int value) {
+  }
+}
+
+void beerSize() {
+  if (level > 0) {
+   //TODO:
+  }
+}
+
+void doSelect(const int value) {
   switch (value) {
   case 0:
     doCalibrate();
@@ -402,6 +398,9 @@
   case 1:
     doTare();
     break;
+  case 2:
+    beerSize();
+    break;
   case 3:
     kegWeight();
     break;
@@ -414,7 +413,9 @@
 }

 void doRight() {
-  if (printGUI) {}
+  if (printGUI) {
+    level++;
+  }
   else {
     lcd.clear();
     printGUI = 1;
@@ -424,6 +425,35 @@
 void doSelect() {
   if (printGUI) {
     doSelect(menuMarker);
+  }
+}
+
+void doLeft() {
+  if (printGUI) {
+    if (level > 0) {
+      level--;
+    } else {
+      lcd.clear();
+      printGUI = 0;
+    }
+   }
+}
+
+void doUp() {
+  if (menuMarker == 0) {
+    menuMarker = lastItem;
+   } else {
+    menuMarker--;
+   }
+}
+
+void doDown() {
+ if (printGUI) {
+   if (menuMarker >= lastItem) {
+      menuMarker = 0;
+    } else {
+      menuMarker++;
+    }
   }
 }

@@ -434,45 +464,16 @@
 #endif
     switch (btn) {
     case btnRIGHT: {
-        doRight();
-        break;
+        doRight(); break;
       } case btnSELECT: {
-        doSelect();
-        break;
+        doSelect(); break;
       } case btnLEFT: {
-        if (printGUI) {
-          lcd.clear();
-          printGUI = 0;
-        }
-        else {
-
-        }
-        break;
-      }
-    case btnUP:
-      {
-        if (menuMarker == 0) {
-          menuMarker = lastItem;
-        }
-        else {
-          menuMarker = menuMarker - 1;
-        }
-        break;
-      }
-    case btnDOWN:
-      {
-        if (printGUI) {
-          if (menuMarker >= lastItem) {
-            menuMarker = 0;
-          }
-          else {
-            menuMarker = menuMarker + 1;
-          }
-        }
-        break;
-      }
-    case btnNONE:
-      {
+        doLeft(); break;
+      } case btnUP: {
+        doUp(); break;
+      } case btnDOWN: {
+        doDown(); break;
+      } case btnNONE: {
         break;
       }
     }


goal and side

goal and side

--- f-preform-02/f-preform-02.ino
+++ f-preform-02/f-preform-02.ino
@@ -229,7 +229,7 @@
     }
 };

-int game = GAME_START,
+int game = GAME_START, rScore = 0, gScore = 0,
 x = -1, y = -1, vector = 0, xPrev = -1, yPrev = -1, vectorPrev = 0;
 unsigned long currentMillis = 0, previousMillis = 0;
 boolean ballkick = false;
@@ -411,46 +411,150 @@
     }
 }

-void loop()
-{
-    // put your main code here, to run repeatedly:
-    switch (game)
-    {
-        case GAME_START:
-            start_game();
-            /*#define GAME_SIDE_OUT 2
-            #define GAME_END_OUT 3
-            #define GAME_OFFSIDE 4
-            #define GAME_GOAL 9
-            */
-            break;
-        case GAME_PERFORMED:
-            in_game();
-            // выполняется когда  var равно 2
-            break;
-        default:
-        // выполняется, если не выбрана ни одна альтернатива
-        // default необязателен
-        for (int i = 2; i <= 13; i++)
-        {
-            lcd.setCursor(2, 1);
-            lcd.print(millis() / 1000);
-            digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
-            delay(1000); // wait for a second
-            digitalWrite(i, LOW); // turn the LED off by making the voltage LOW
-            delay(1000); // wait for a second
-        }
-        for (int i = 22; i <= 45; i++)
-        {
-            lcd.setCursor(2, 1);
-            lcd.print(millis() / 1000);
-            digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
-            delay(1000); // wait for a second
-            digitalWrite(i, LOW); // turn the LED off by making the voltage LOW
-            delay(1000); // wait for a second
-            // if (i == 45) {
-            // i = 22;
-            // }
-        }
-    }
-}
+void goal()
+{
+    currentMillis = millis();
+    previousMillis = currentMillis;
+    tone(SPEAKER_PIN, 3000, 250);
+    reset_buttons_flagClick;
+    ballkick = false;
+    game = GAME_PERFORMED;
+    lcd.setCursor(0, 0);
+    if (x == 0)
+    {
+        rScore++;
+        lcd.print("Red plr has scored!");
+        newxy(5, 2, GREENS);
+    }
+    else
+    {
+        gScore++;
+        lcd.print("Green plr has scored!");
+        newxy(6, 2, REDS);
+    }
+}
+
+void side()
+{
+    currentMillis = millis();
+    previousMillis = currentMillis;
+    reset_buttons_flagClick();
+    ballkick = false;
+    game = GAME_PERFORMED;
+    if (vector == GREENS)
+    {
+        if (y == 0)
+        {
+            if (x == 1 || x == 2 || x == 3)
+            {
+                newxy(2, 1, REDS);
+            }
+            elif(x == 4 || x == 5 || x == 6)
+            {
+                newxy(4, 1, REDS);
+            }
+            else // если х = 7, 8, 9
+            {
+                newxy(8, 1, REDS);
+            }
+        }
+        else // если y= 4
+        {
+            if (x == 1 || x == 2 || x == 3)
+            {
+                newxy(2, 3, REDS);
+            }
+            elif(x == 4 || x == 5 || x == 6)
+            {
+                newxy(4, 3, REDS);
+            }
+            else // если x= 7, 8, 9
+            {
+                newxy(8, 3, REDS);
+            }
+        }
+    }
+    else // если вектор равен красным
+    {
+        if (y == 0)
+        {
+            if (x == 8 || x == 9 || x == 10)
+            {
+                newxy(9, 1, GREENS);
+            }
+            elif(x == 5 || x == 6 || x == 7)
+            {
+                newxy(7, 1, GREENS);
+            }
+            else
+            {
+                newxy(3, 1, GREENS);
+            }
+        }
+        else
+        {
+            if (x == 8 || x == 9 || x == 10)
+            {
+                newxy(9, 4, GREENS);
+            }
+            elif(x == 5 || x == 6 || x == 7)
+            {
+                newxy(7, 4, GREENS);
+            }
+            else
+            {
+                newxy(3, 4, GREENS);
+            }
+        }
+    }
+    void loop()
+    {
+        // put your main code here, to run repeatedly:
+        switch (game)
+        {
+            case GAME_START:
+                start_game();
+                /*#define GAME_SIDE_OUT 2
+                #define GAME_END_OUT 3
+                #define GAME_OFFSIDE 4
+                #define GAME_GOAL 9
+                */
+                break;
+            case GAME_PERFORMED:
+                in_game();
+                // выполняется когда  var равно 2
+                break;
+                case GAME_SIDE_OUT;
+                side();
+                // выход мяча за поле в сторону
+                break;
+            case GAME_GOAL:
+                goal();
+                // выполняется, когда противнику забит гол
+                break;
+            default:
+            // выполняется, если не выбрана ни одна альтернатива
+            // default необязателен
+            for (int i = 2; i <= 13; i++)
+            {
+                lcd.setCursor(2, 1);
+                lcd.print(millis() / 1000);
+                digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
+                delay(1000); // wait for a second
+                digitalWrite(i, LOW); // turn the LED off by making the voltage LOW
+                delay(1000); // wait for a second
+            }
+            for (int i = 22; i <= 45; i++)
+            {
+                lcd.setCursor(2, 1);
+                lcd.print(millis() / 1000);
+                digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
+                delay(1000); // wait for a second
+                digitalWrite(i, LOW); // turn the LED off by making the voltage LOW
+                delay(1000); // wait for a second
+                // if (i == 45) {
+                // i = 22;
+                // }
+            }
+        }
+    }


Minor modifications

Minor modifications

Enable/disable CRC, separate commands to enable/disable motors driver.

--- RobotBase.ino
+++ RobotBase.ino
@@ -1,7 +1,5 @@
 #include <BMSerial.h>
 #include <RoboClaw.h>
-#include <Wire.h>
-#include <Adafruit_PWMServoDriver.h>

 #define LED_PIN 13

@@ -12,6 +10,7 @@
 byte cmd = 0;
 byte bytes = 0;
 byte crc = 0;
+boolean doCRC = false;

 // power management //
 #define AUX_PIN 7
@@ -23,7 +22,6 @@
 unsigned long lastCommandTime;
 unsigned long commandTime;
 unsigned long cmdTimeout = 2500;
-boolean ledCmdOn = false;
 boolean IsConnected = false;

 // RoboClaw //
@@ -31,17 +29,19 @@
 #define RC_RX_PIN 12
 #define RC_TX_PIN 11
 RoboClaw roboclaw(RC_RX_PIN, RC_TX_PIN);
+boolean driveEnabled = false;

 // propulsion vars
 #define MOTOR_VELOCITY_0 64
 #define MOTOR_VELOCITY_MAX 63
+#define MOTOR_TARGET_MAX 127
 byte motor1 = MOTOR_VELOCITY_0;
 byte motor1_target = MOTOR_VELOCITY_0;
 byte motor2 = MOTOR_VELOCITY_0;
 byte motor2_target = MOTOR_VELOCITY_0;
 byte motor_velocity = 30;
 byte motor_velocity_increment = 5;
-unsigned int motor_counter_start = 4000;
+unsigned int motor_counter_start = 3000;
 unsigned int motor_counter = 0;

 //=======================================
@@ -71,9 +71,9 @@
   // host communication //
   Serial.begin(38400);

-  // propulsion (RoboClaw) //
-  driveInit(true);
-  driveInit(false);
+  // init motor driver //
+  driveUART(true);
+  driveUART(false);
 }

 //=======================================
@@ -99,8 +99,11 @@
     buf[bytes] = Serial.read();
     if (buf[bytes] == 10 || buf[bytes] == 13 || bytes >= MAX_COMMAND)
     {
-      if (bytes > 0) Execute();
-      //if (bytes > 0) if (crc8_ok()) Execute();
+      if (bytes > 0)
+      {
+        if (!doCRC) Execute();
+        else { if (crc8_ok()) Execute(); }
+      }
       return;
     }
     bytes++;
@@ -148,20 +151,12 @@
 {
   driveStop();
   IsConnected = false;
-  if (ledCmdOn) switchCommandLed();
 }

 void OnValidCommand()
 {
   IsConnected = true;
   lastCommandTime = millis();
-  switchCommandLed();
-}
-
-void switchCommandLed()
-{
-  ledCmdOn = !ledCmdOn;
-  //if (ledCmdOn) digitalWrite(LED_PIN, HIGH); else digitalWrite(LED_PIN, LOW);
 }

 //=======================================
@@ -189,26 +184,13 @@
   else
   if (cmd == 'P' || cmd == 'p') power();
   else
-  if (cmd == 'S' || cmd == 's') settings();
+  if (cmd == 'S' || cmd == 's') set();
   else
   if (cmd == 'B' || cmd == 'b') battery();
   else
-  if (cmd == 'R' || cmd == 'r')
-  {
-    cmd = buf[1];
-    if (cmd == 'D' || cmd == 'd') dread();
-    else
-    if (cmd == 'A' || cmd == 'a') aread();
-    else
-    {
-      nak(); return;
-    }
-
-    OnValidCommand();
-    return;
-  }
-  else
-  if (cmd == 'W' || cmd == 'w') dwrite();
+  if (cmd == 'R' || cmd == 'r') _read();
+  else
+  if (cmd == 'W' || cmd == 'w') _write();
   else
   if (cmd == 'Z' || cmd == 'z') { OnDisconnected(); return; }
   else
@@ -236,8 +218,8 @@

 // 'drive' command. both motors in one command
 // ex: DF - drive forward at 'motor_velocity'
-// ex: DD127127 - drive differential. full forward at velocity 63
-// ex: DD000000 - drive differential. full backward at vel 64
+// ex: DD127127 - drive differential. full forward
+// ex: DD000000 - drive differential. full backward
 void drive()
 {
   cmd = buf[1];
@@ -246,19 +228,11 @@
   {
     motor1_target = bctoi(2, 3);
     motor2_target = bctoi(5, 3);
-    if (motor1_target > MOTOR_VELOCITY_0 + MOTOR_VELOCITY_MAX) motor1_target = MOTOR_VELOCITY_0 + MOTOR_VELOCITY_MAX;
-    if (motor2_target > MOTOR_VELOCITY_0 + MOTOR_VELOCITY_MAX) motor2_target = MOTOR_VELOCITY_0 + MOTOR_VELOCITY_MAX;
-  }
-  else
-  if (cmd == 'Z' || cmd == 'z') // stop immediately
-  {
-    motor1_target = MOTOR_VELOCITY_0;
-    motor1 = MOTOR_VELOCITY_0;
-    motor2_target = MOTOR_VELOCITY_0;
-    motor2 = MOTOR_VELOCITY_0;
-    roboclaw.ForwardBackwardM1(RC_ADDR, motor1);
-    roboclaw.ForwardBackwardM2(RC_ADDR, motor2);
-  }
+    if (motor1_target > MOTOR_TARGET_MAX) motor1_target = MOTOR_TARGET_MAX;
+    if (motor2_target > MOTOR_TARGET_MAX) motor2_target = MOTOR_TARGET_MAX;
+  }
+  else
+  if (cmd == 'Z' || cmd == 'z') driveStop(); // stop immediately
   else
   if (cmd == 'F' || cmd == 'f') { motor1_target = MOTOR_VELOCITY_0 + motor_velocity; motor2_target = motor1_target; }
   else
@@ -268,9 +242,11 @@
   else
   if (cmd == 'R' || cmd == 'r') { motor1_target = MOTOR_VELOCITY_0 + motor_velocity; motor2_target = MOTOR_VELOCITY_0 - motor_velocity; }
   else
-  if (cmd == 'S' || cmd == 's') { driveStop(); }
-  else
-  if (cmd == 'E' || cmd == 'e') { driveInit(buf[2] == '1'); }
+  if (cmd == 'S' || cmd == 's') { motor1_target = MOTOR_VELOCITY_0; motor2_target = MOTOR_VELOCITY_0; }
+  else
+  if (cmd == 'E' || cmd == 'e') driveEnable(true);
+  else
+  if (cmd == 'O' || cmd == 'o') driveEnable(false);
   else
   if (cmd == 'V' || cmd == 'v')
   {
@@ -278,25 +254,20 @@
     if (motor_velocity > MOTOR_VELOCITY_MAX) motor_velocity = MOTOR_VELOCITY_MAX;
   }
   else
-  if (cmd == 'I' || cmd == 'i') { motor_velocity_increment = bctoi(2, 2); }
-  else
-  if (cmd == 'C' || cmd == 'c') { motor_counter_start = bctoi(2, 1) * 1000; }
+  if (cmd == 'I' || cmd == 'i') motor_velocity_increment = bctoi(2, 2);
+  else
+  if (cmd == 'C' || cmd == 'c') motor_counter_start = (unsigned int)bctoi(2, 1) * 1000;
   else
   {
     nak();
   }
-}
-
-// stop both motors
-void driveStop()
-{
-  motor1_target = MOTOR_VELOCITY_0;
-  motor2_target = MOTOR_VELOCITY_0;
 }

 // update motor velocities
 void updateMotors()
 {
+  if (!driveEnabled) return;
+
   // M1
   if (motor1 != motor1_target)
   {
@@ -333,10 +304,39 @@
   }
 }

-void driveInit(boolean action)
+// stop both motors immediately
+void driveStop()
+{
+  if (!driveEnabled) return;
+  motor1_target = MOTOR_VELOCITY_0;
+  motor1 = MOTOR_VELOCITY_0;
+  motor2_target = MOTOR_VELOCITY_0;
+  motor2 = MOTOR_VELOCITY_0;
+  roboclaw.ForwardBackwardM1(RC_ADDR, motor1);
+  roboclaw.ForwardBackwardM2(RC_ADDR, motor2);
+}
+
+// enable/disable motor driver communication and power
+void driveEnable(boolean action)
+{
+  if (action)
+  {
+    pulsePin(MOTORS_PIN, 20);
+    driveUART(true);
+  }
+  else
+  {
+    driveUART(false);
+    pulsePin(MOTORS_PIN, 20);
+  }
+}
+
+// enable/disable motor driver communication
+void driveUART(boolean action)
 {
   if (action) roboclaw.begin(38400);
   else roboclaw.end();
+  driveEnabled = action;
 }

 //=======================================
@@ -358,7 +358,7 @@
 // ex: V
 void ver()
 {
-  Serial.println("V3");
+  Serial.println("V4");
 }

 // 'power' command
@@ -370,19 +370,27 @@
   if (cmd == 'M' || cmd == 'm') pulsePin(MOTORS_PIN, 20);
   else
   if (cmd == 'U' || cmd == 'u') pulsePin(UPS_PIN, 5500);
+  else
+    nak();
 }

 // 'set parameter' command
-// ex: ST2500
-void settings()
+// ex: ST25 - set timeout = 2500ms
+// ex: SC1 - enable CRC
+void set()
 {
   cmd = buf[1];
   // command timeout
-  if (cmd == 'T' || cmd == 't') { cmdTimeout = bctoi(2, 5); Serial.println(cmdTimeout); }
-}
-
-// 'battery voltage' command. result in mV
+  if (cmd == 'T' || cmd == 't') cmdTimeout = bctoi(2, 2) * 100;
+  else
+  if (cmd == 'C' || cmd == 'c') doCRC = buf[2] == '1';
+  else
+    nak();
+}
+
+// 'battery voltage' command
 // ex: B
+// result in mV
 void battery()
 {
   digitalWrite(BATTERY_PIN, HIGH);
@@ -394,32 +402,45 @@
 }

 // 'digitalWrite' command
-// ex: "W031" or "W3 1" (write 1 to pin 3)
-void dwrite()
+// ex: W031 - set pin 3 HIGH, W100 - set pin 10 LOW
+void _write()
 {
   byte pin = bctoi(1, 2);
   if (pin < 2 || pin > 10) { err(); return; }
   pinMode(pin, OUTPUT);
-  if (buf[3] == '0') digitalWrite(pin, 0); else digitalWrite(pin, 1);
+  if (buf[3] == '0') digitalWrite(pin, LOW); else digitalWrite(pin, HIGH);
+}
+
+//=======================================
+
+// 'read' command
+void _read()
+{
+  cmd = buf[1];
+  if (cmd == 'D' || cmd == 'd') dread();
+  else
+  if (cmd == 'A' || cmd == 'a') aread();
+  else
+    nak();
 }

 // 'digitalRead' command
-// ex: RD5 or RD10
+// ex: RD5 or RD05 or RD10
 void dread()
 {
   byte pin = bctoi(2, 2);
   if (pin < 2 || pin > 10) { err(); return; }
   pinMode(pin, INPUT_PULLUP);
-  unsigned int a;
-  a = digitalRead(pin);
+  unsigned int a = digitalRead(pin);
   Serial.print("RD");
-  Serial.print((unsigned int) pin);
+  Serial.print((unsigned int)pin);
   Serial.print("=");
   Serial.println(a);
 }

 // 'analogRead' command
 // ex: RA0
+// result in mV
 void aread()
 {
   byte pin = bctoi(2, 1);
@@ -431,7 +452,12 @@
   Serial.println(a);
 }

+//=======================================
 //
+// helper functions
+//
+//=======================================
+
 void pulsePin(int pin, int ms)
 {
   digitalWrite(pin, HIGH);


added comments

added comments

--- NTPclock/NTPclock.ino
+++ NTPclock/NTPclock.ino
@@ -51,14 +51,14 @@

 // Main program loop
 void loop() {
-  updateDigits(); //
-  updateMisc();   //
-  delay(1000);    //
+  updateDigits(); //Update the time display
+  updateMisc();   //Update the rest of the display
+  delay(1000);    //CHANGE THIS TO A COUNTER-BASED DELAY.  NOT THIS EVIL STUFF THAT IS A DELAY()

   Serial.println(NTP.getTimeDateString(now() ) );
 }

-//
+// Handles updating the primary 7-segment display
 void updateDigits() {
   if ((hour() / 10) == 0) {
     lc1.setChar(0, 0, ' ', false);
@@ -84,13 +84,14 @@
     segment[i] = true;
   }

-  for (int i=0; i<5; i++) {        //Set the LEDs
+  for (int i=0; i<5; i++) {         //Set the LEDs
     lc1.setLed(0,4,i,segment[i]);   //0-4
     lc1.setLed(0,5,i,segment[i+5]); //5-9
   }
 }

 // Initial connection to WiFi
+// We wait for 5 seconds to connect, but do not block on the connection.
 void connectWifi() {
   Serial.print("Connecting to ");
   Serial.println(ssid);
@@ -103,13 +104,13 @@
   time_t RTCTime = RTC.get();  //Get RTC time
   setTime(RTCTime);            //Set it as current time
   RTC.squareWave(SQWAVE_NONE); //Never assume the Rtc was last configured by you, so just clear them to your needed state
-  updateDigits();  //Force update of display while loop() not running
+  updateDigits();              //Force update of display while loop() not running
 }

 // Initial set up of NTP
 void beginNTP() {
   Serial.print("Starting NTP client...");
-  NTP.begin("pool.ntp.org", -8, true);
-  NTP.setInterval(21600);
+  NTP.begin("pool.ntp.org", -8, true);    //-8 is pacific time, true means dst
+  NTP.setInterval(21600);                 //every 6 hours
   Serial.println("Done.");
 }


Update sketch_ardrumoid.ino

Update sketch_ardrumoid.ino

--- arduino/sketch_ardrumoid.ino
+++ arduino/sketch_ardrumoid.ino
@@ -1,9 +1,5 @@
-int BTNLEDPIN = 8;
+  const int BTNLEDPIN = 8;

-void setup() {
-  Serial.begin(115200);
-  pinMode(BTNLEDPIN, OUTPUT);
-}
   int val0_old , val1_old, val2_old, val3_old, val4_old;
   int val0;   //Symbal
   int val1;   //Hihat
@@ -11,9 +7,12 @@
   int val3;  //Tom
   int val4;  //Kick

+void setup() {
+  Serial.begin(115200);
+  pinMode(BTNLEDPIN, OUTPUT);
+}

 void loop() {
-
   val0 = analogRead(0); //Connect the sensor to analog pin 0
   val1 = analogRead(1);
   val2 = analogRead(2);


Backup for further developement

Backup for further developement

--- arduino/involt-basic/involt-basic.ino
+++ arduino/involt-basic/involt-basic.ino
@@ -2,10 +2,9 @@
   INVOLT BASIC ARDUINO SKETCH
   by Ernest Warzocha 2015
   ------------------------------------------------------
-  This file can be used for serial communication
-  between Arduino Uno and Involt Chrome App. It can be
-  used with HC-05 Bluetooth device connected via
-  hardware serial.
+  This file is for serial communication between Arduino
+  Uno and Involt Chrome App. It can be used with HC-05
+  Bluetooth device connected via hardware serial.
 */

 /*
@@ -14,7 +13,7 @@
   this array. involtString is array for values received
   with "S" pin. You can increase the length of array to
   store more values then arduino total pins. Use them
-  in sketch.
+  in sketch for not only pin-to-pin communication.
 */
 int    involtDigital[14] = {};
 String involtString[2] ={};
@@ -106,6 +105,9 @@
       sscanf(involt, "S%dV%s", &pin, &value);
       involtString[pin] = value;
     }
+    else if (involt[0] == 'F'){
+      sscanf(involt, "F%s", &fname);
+    };
     memset(involt,0,sizeof(involt));
   };
 };


Ajout de la fonction fileNameCreator

Ajout de la fonction fileNameCreator

--- TIRL_Arduino_TEST.ino
+++ TIRL_Arduino_TEST.ino
@@ -77,11 +77,30 @@
     if (commande == "TR") return TR;
     if (commande == "TL") return TL;
 }
+
+//----------------------------------------------------------------------------------------------------------------------
+// fonction : filenameContructor
+// cree le nom de fichier pour accéder à la lettre
+// le lettre est convertie en majuscules
+// pas de vérification !
+String fileNameConstructor( char lettre ){
+    lettre = toupper( lettre );
+    return String("letters/")+lettre+String(".txt");
+}
+
+
+//----------------------------------------------------------------------------------------------------------------------
+// Fonction readLetter
+// in:
+//
+
 void setup() {
+    Serial.begin(9600);
     randomSeed(analogRead(1));
-    String fileName = "letters/A.txt";
+    String fileName = fileNameConstructor( 'a' );
+
     String lettre = "";
-    Serial.begin(9600);
+
     for(int pin=0; pin<4; pin++){
         pinMode(L_stepper_pins[pin], OUTPUT);
         digitalWrite(L_stepper_pins[pin], LOW);
@@ -91,6 +110,7 @@
     penServo.write(PEN_UP);
     penServo.attach(servoPin);
     Serial.println(F("setup"));
+    sp("file name : ");spl( fileNameConstructor ('a'));
     pinMode( SWITCH, INPUT_PULLUP);
     pinMode( LED, OUTPUT );
     //penup();


Fiddling with Node commands a bit

Fiddling with Node commands a bit

--- Prototype/Node/Node.ino
+++ Prototype/Node/Node.ino
@@ -7,8 +7,9 @@
 	- node_id    xy-1
 	- version    0

-- Should compile but does not give usable node, iow. util functions / init only.
+- Depends on JeeLib InputParser
 - Subtypes of this prototype: SerialNode.
+

 See
 - AtmegaEEPROM
@@ -26,8 +27,18 @@

 		2,0 C

+	Write to EEPROM::
+
+		1 W
+
+	Reload from EEPROM (reset changes)::
+
+		0 W
+
+
   */

+#include <SoftwareSerial.h>
 #include <EEPROM.h>
 //#include <util/crc16.h>

@@ -58,11 +69,14 @@
 /* IO pins */
 static const byte ledPin = 13;

+SoftwareSerial virtSerial(11, 12); // RX, TX
+

 /* Command parser */
+Stream& cmdIo = virtSerial;
 extern InputParser::Commands cmdTab[] PROGMEM;
 byte* buffer = (byte*) malloc(50);
-InputParser parser (buffer, 50, cmdTab);
+InputParser parser (buffer, 50, cmdTab, virtSerial);

 /* *** Device params *** {{{ */

@@ -85,7 +99,7 @@
 #define CONFIG_START 0

 struct Config {
-	char node[3];
+	char node[4];
 	int node_id;
 	int version;
 	char config_id[4];
@@ -116,7 +130,7 @@

 	} else {
 #if SERIAL && DEBUG
-		Serial.println("No valid data in eeprom");
+		cmdIo.println("No valid data in eeprom");
 #endif
 		return false;
 	}
@@ -133,7 +147,7 @@
 		{
 			// error writing to EEPROM
 #if SERIAL && DEBUG
-			Serial.println("Error writing "+ String(t)+" to EEPROM");
+			cmdIo.println("Error writing "+ String(t)+" to EEPROM");
 #endif
 		}
 	}
@@ -218,12 +232,18 @@

 /* *** Initialization routines *** {{{ */

+void initConfig(void)
+{
+	sprintf(node_id, "%s%i", static_config.node, static_config.node_id);
+}
+
 void doConfig(void)
 {
 	/* load valid config or reset default config */
 	if (!loadConfig(static_config)) {
 		writeConfig(static_config);
 	}
+	initConfig();
 }

 void initLibs()
@@ -235,40 +255,48 @@
 /* InputParser handlers */

 static void helpCmd() {
-	Serial.println("c: print config");
-	Serial.println("C: set Node (2 byte char)");
-	Serial.println("N: set Node ID (2 byte int)");
-	Serial.println("?/h: this help");
+	cmdIo.println("n: print Node ID");
+	cmdIo.println("c: print config");
+	cmdIo.println("N: set Node (3 byte char)");
+	cmdIo.println("C: set Node ID (1 byte int)");
+	cmdIo.println("W: load/save EEPROM");
+	cmdIo.println("?/h: this help");
 }

 static void configCmd() {
-	Serial.print("c ");
-	Serial.print(static_config.node);
-	Serial.print(" ");
-	Serial.print(static_config.node_id);
-	Serial.print(" ");
-	Serial.print(static_config.version);
-	Serial.print(" ");
-	Serial.print(static_config.config_id);
-	Serial.println();
-}
-
-static void configNodeCmd() {
+	cmdIo.print("c ");
+	cmdIo.print(static_config.node);
+	cmdIo.print(" ");
+	cmdIo.print(static_config.node_id);
+	cmdIo.print(" ");
+	cmdIo.print(static_config.version);
+	cmdIo.print(" ");
+	cmdIo.print(static_config.config_id);
+	cmdIo.println();
+}
+
+static void configSetNodeCmd() {
 	const char *node;
 	parser >> node;
 	static_config.node[0] = node[0];
 	static_config.node[1] = node[1];
 	static_config.node[2] = node[2];
-	Serial.print("N ");
-	Serial.println(static_config.node);
+	initConfig();
+	cmdIo.print("N ");
+	cmdIo.println(static_config.node);
 }

 static void configNodeIDCmd() {
 	parser >> static_config.node_id;
-	sprintf(node_id, "%s%i", node, static_config.node_id);
-	Serial.print("C ");
-	Serial.println(node_id);
+	initConfig();
+	cmdIo.print("C ");
+	cmdIo.println(node_id);
 	serialFlush();
+}
+
+static void configNodeCmd() {
+	cmdIo.print("n ");
+	cmdIo.println(node_id);
 }

 static void configEEPROM() {
@@ -278,17 +306,19 @@
 		writeConfig(static_config);
 	} else {
 		loadConfig(static_config);
-	}
-	Serial.print("W ");
-	Serial.println(write);
+		initConfig();
+	}
+	cmdIo.print("W ");
+	cmdIo.println(write);
 }

 InputParser::Commands cmdTab[] = {
 	{ '?', 0, helpCmd },
 	{ 'h', 0, helpCmd },
 	{ 'c', 0, configCmd},
-	{ 'N', 1, configNodeCmd },
-	{ 'C', 2, configNodeIDCmd },
+	{ 'n', 0, configNodeCmd },
+	{ 'N', 3, configSetNodeCmd },
+	{ 'C', 1, configNodeIDCmd },
 	{ 'W', 1, configEEPROM },
 	{ 0 }
 };
@@ -310,18 +340,29 @@
 {
 #if SERIAL
 	Serial.begin(57600);
-	Serial.println(SERIAL);
+	virtSerial.begin(4800);
 #endif

 	initLibs();

 	doReset();
+
+	cmdIo.print("\n[");
+	cmdIo.print(sketch);
+	cmdIo.print(".");
+	cmdIo.print(version);
+	cmdIo.println("]");
+
+	cmdIo.println(node_id);
 }

 void loop(void)
 {
-    parser.poll();
-}
-
-/* }}} *** */
-
+	// FIXME: seems virtSerial receive is not working
+	//if (virtSerial.available())
+	//	virtSerial.write(virtSerial.read());
+	parser.poll();
+}
+
+/* }}} *** */
+