Delete AuroraInverter3.ino

Delete AuroraInverter3.ino

--- AuroraInverter3.ino
+++ AuroraInverter3.ino
@@ -1,1190 +0,0 @@
-#include <ESP8266WiFi.h>
-#include <WiFiClient.h>
-#include <ESP8266WiFiMulti.h>
-#include <ESP8266mDNS.h>
-#include <ESP8266WebServer.h>
-#include <SoftwareSerial.h>
-
-//RS485 control
-#define SSerialTxControl 5 //GPIO5 (D1)
-#define RS485Transmit HIGH
-#define RS485Receive LOW
-
-// TX1 at GPIO15 and RX1 at GPIO13 => Serial1.println
-
-class clsAurora {
-private:
-  int MaxAttempt = 1;
-  byte Address = 0;
-
-  void clearData(byte *data, byte len) {
-    for (int i = 0; i < len; i++) {
-      data[i] = 0;
-    }
-  }
-
-  int Crc16(byte *data, int offset, int count)
-  {
-    byte BccLo = 0xFF;
-    byte BccHi = 0xFF;
-
-    for (int i = offset; i < (offset + count); i++)
-    {
-      byte New = data[offset + i] ^ BccLo;
-      byte Tmp = New << 4;
-      New = Tmp ^ New;
-      Tmp = New >> 5;
-      BccLo = BccHi;
-      BccHi = New ^ Tmp;
-      Tmp = New << 3;
-      BccLo = BccLo ^ Tmp;
-      Tmp = New >> 4;
-      BccLo = BccLo ^ Tmp;
-
-    }
-
-    return (int)word(~BccHi, ~BccLo);
-  }
-
-  bool Send(byte address, byte param0, byte param1, byte param2, byte param3, byte param4, byte param5, byte param6)
-  {
-
-    SendStatus = false;
-    ReceiveStatus = false;
-
-    byte SendData[10];
-    SendData[0] = address;
-    SendData[1] = param0;
-    SendData[2] = param1;
-    SendData[3] = param2;
-    SendData[4] = param3;
-    SendData[5] = param4;
-    SendData[6] = param5;
-    SendData[7] = param6;
-
-    int crc = Crc16(SendData, 0, 8);
-    SendData[8] = lowByte(crc);
-    SendData[9] = highByte(crc);
-
-    clearReceiveData();
-
-    for (int i = 0; i < MaxAttempt; i++)
-    {
-      digitalWrite(SSerialTxControl, RS485Transmit);
-      delay(50);
-
-      if (Serial1.write(SendData, sizeof(SendData)) != 0) {
-        Serial1.flush();
-        SendStatus = true;
-
-        digitalWrite(SSerialTxControl, RS485Receive);
-
-        if (Serial1.readBytes(ReceiveData, sizeof(ReceiveData)) != 0) {
-          if ((int)word(ReceiveData[7], ReceiveData[6]) == Crc16(ReceiveData, 0, 6)) {
-            ReceiveStatus = true;
-            break;
-          }
-        }
-      }
-    }
-    return ReceiveStatus;
-  }
-
-  union {
-    byte asBytes[4];
-    float asFloat;
-  } foo;
-
-  union {
-    byte asBytes[4];
-    unsigned long asUlong;
-  } ulo;
-
-public:
-  bool SendStatus = false;
-  bool ReceiveStatus = false;
-  byte ReceiveData[8];
-
-  clsAurora(byte address) {
-    Address = address;
-
-    SendStatus = false;
-    ReceiveStatus = false;
-
-    clearReceiveData();
-  }
-
-  void clearReceiveData() {
-    clearData(ReceiveData, 8);
-  }
-
-  String TransmissionState(byte id) {
-    switch (id)
-    {
-    case 0:
-      return F("Everything is OK.");
-      break;
-    case 51:
-      return F("Command is not implemented");
-      break;
-    case 52:
-      return F("Variable does not exist");
-      break;
-    case 53:
-      return F("Variable value is out of range");
-      break;
-    case 54:
-      return F("EEprom not accessible");
-      break;
-    case 55:
-      return F("Not Toggled Service Mode");
-      break;
-    case 56:
-      return F("Can not send the command to internal micro");
-      break;
-    case 57:
-      return F("Command not Executed");
-      break;
-    case 58:
-      return F("The variable is not available, retry");
-      break;
-    default:
-      return F("Sconosciuto");
-      break;
-    }
-  }
-
-  String GlobalState(byte id) {
-    switch (id)
-    {
-    case 0:
-      return F("Sending Parameters");
-      break;
-    case 1:
-      return F("Wait Sun / Grid");
-      break;
-    case 2:
-      return F("Checking Grid");
-      break;
-    case 3:
-      return F("Measuring Riso");
-      break;
-    case 4:
-      return F("DcDc Start");
-      break;
-    case 5:
-      return F("Inverter Start");
-      break;
-    case 6:
-      return F("Run");
-      break;
-    case 7:
-      return F("Recovery");
-      break;
-    case 8:
-      return F("Pausev");
-      break;
-    case 9:
-      return F("Ground Fault");
-      break;
-    case 10:
-      return F("OTH Fault");
-      break;
-    case 11:
-      return F("Address Setting");
-      break;
-    case 12:
-      return F("Self Test");
-      break;
-    case 13:
-      return F("Self Test Fail");
-      break;
-    case 14:
-      return F("Sensor Test + Meas.Riso");
-      break;
-    case 15:
-      return F("Leak Fault");
-      break;
-    case 16:
-      return F("Waiting for manual reset");
-      break;
-    case 17:
-      return F("Internal Error E026");
-      break;
-    case 18:
-      return F("Internal Error E027");
-      break;
-    case 19:
-      return F("Internal Error E028");
-      break;
-    case 20:
-      return F("Internal Error E029");
-      break;
-    case 21:
-      return F("Internal Error E030");
-      break;
-    case 22:
-      return F("Sending Wind Table");
-      break;
-    case 23:
-      return F("Failed Sending table");
-      break;
-    case 24:
-      return F("UTH Fault");
-      break;
-    case 25:
-      return F("Remote OFF");
-      break;
-    case 26:
-      return F("Interlock Fail");
-      break;
-    case 27:
-      return F("Executing Autotest");
-      break;
-    case 30:
-      return F("Waiting Sun");
-      break;
-    case 31:
-      return F("Temperature Fault");
-      break;
-    case 32:
-      return F("Fan Staucked");
-      break;
-    case 33:
-      return F("Int.Com.Fault");
-      break;
-    case 34:
-      return F("Slave Insertion");
-      break;
-    case 35:
-      return F("DC Switch Open");
-      break;
-    case 36:
-      return F("TRAS Switch Open");
-      break;
-    case 37:
-      return F("MASTER Exclusion");
-      break;
-    case 38:
-      return F("Auto Exclusion");
-      break;
-    case 98:
-      return F("Erasing Internal EEprom");
-      break;
-    case 99:
-      return F("Erasing External EEprom");
-      break;
-    case 100:
-      return F("Counting EEprom");
-      break;
-    case 101:
-      return F("Freeze");
-    default:
-      return F("Sconosciuto");
-      break;
-    }
-  }
-
-  String DcDcState(byte id) {
-    switch (id)
-    {
-    case 0:
-      return F("DcDc OFF");
-      break;
-    case 1:
-      return F("Ramp Start");
-      break;
-    case 2:
-      return F("MPPT");
-      break;
-    case 3:
-      return F("Not Used");
-      break;
-    case 4:
-      return F("Input OC");
-      break;
-    case 5:
-      return F("Input UV");
-      break;
-    case 6:
-      return F("Input OV");
-      break;
-    case 7:
-      return F("Input Low");
-      break;
-    case 8:
-      return F("No Parameters");
-      break;
-    case 9:
-      return F("Bulk OV");
-      break;
-    case 10:
-      return F("Communication Error");
-      break;
-    case 11:
-      return F("Ramp Fail");
-      break;
-    case 12:
-      return F("Internal Error");
-      break;
-    case 13:
-      return F("Input mode Error");
-      break;
-    case 14:
-      return F("Ground Fault");
-      break;
-    case 15:
-      return F("Inverter Fail");
-      break;
-    case 16:
-      return F("DcDc IGBT Sat");
-      break;
-    case 17:
-      return F("DcDc ILEAK Fail");
-      break;
-    case 18:
-      return F("DcDc Grid Fail");
-      break;
-    case 19:
-      return F("DcDc Comm.Error");
-      break;
-    default:
-      return F("Sconosciuto");
-      break;
-    }
-  }
-
-  String InverterState(byte id) {
-    switch (id)
-    {
-    case 0:
-      return F("Stand By");
-      break;
-    case 1:
-      return F("Checking Grid");
-      break;
-    case 2:
-      return F("Run");
-      break;
-    case 3:
-      return F("Bulk OV");
-      break;
-    case 4:
-      return F("Out OC");
-      break;
-    case 5:
-      return F("IGBT Sat");
-      break;
-    case 6:
-      return F("Bulk UV");
-      break;
-    case 7:
-      return F("Degauss Error");
-      break;
-    case 8:
-      return F("No Parameters");
-      break;
-    case 9:
-      return F("Bulk Low");
-      break;
-    case 10:
-      return F("Grid OV");
-      break;
-    case 11:
-      return F("Communication Error");
-      break;
-    case 12:
-      return F("Degaussing");
-      break;
-    case 13:
-      return F("Starting");
-      break;
-    case 14:
-      return F("Bulk Cap Fail");
-      break;
-    case 15:
-      return F("Leak Fail");
-      break;
-    case 16:
-      return F("DcDc Fail");
-      break;
-    case 17:
-      return F("Ileak Sensor Fail");
-      break;
-    case 18:
-      return F("SelfTest: relay inverter");
-      break;
-    case 19:
-      return F("SelfTest : wait for sensor test");
-      break;
-    case 20:
-      return F("SelfTest : test relay DcDc + sensor");
-      break;
-    case 21:
-      return F("SelfTest : relay inverter fail");
-      break;
-    case 22:
-      return F("SelfTest timeout fail");
-      break;
-    case 23:
-      return F("SelfTest : relay DcDc fail");
-      break;
-    case 24:
-      return F("Self Test 1");
-      break;
-    case 25:
-      return F("Waiting self test start");
-      break;
-    case 26:
-      return F("Dc Injection");
-      break;
-    case 27:
-      return F("Self Test 2");
-      break;
-    case 28:
-      return F("Self Test 3");
-      break;
-    case 29:
-      return F("Self Test 4");
-      break;
-    case 30:
-      return F("Internal Error");
-      break;
-    case 31:
-      return F("Internal Error");
-      break;
-    case 40:
-      return F("Forbidden State");
-      break;
-    case 41:
-      return F("Input UC");
-      break;
-    case 42:
-      return F("Zero Power");
-      break;
-    case 43:
-      return F("Grid Not Present");
-      break;
-    case 44:
-      return F("Waiting Start");
-      break;
-    case 45:
-      return F("MPPT");
-      break;
-    case 46:
-      return F("Grid Fail");
-      break;
-    case 47:
-      return F("Input OC");
-      break;
-    default:
-      return F("Sconosciuto");
-      break;
-    }
-  }
-
-  String AlarmState(byte id) {
-    switch (id)
-    {
-    case 0:
-      return F("No Alarm");
-      break;
-    case 1:
-      return F("Sun Low");
-      break;
-    case 2:
-      return F("Input OC");
-      break;
-    case 3:
-      return F("Input UV");
-      break;
-    case 4:
-      return F("Input OV");
-      break;
-    case 5:
-      return F("Sun Low");
-      break;
-    case 6:
-      return F("No Parameters");
-      break;
-    case 7:
-      return F("Bulk OV");
-      break;
-    case 8:
-      return F("Comm.Error");
-      break;
-    case 9:
-      return F("Output OC");
-      break;
-    case 10:
-      return F("IGBT Sat");
-      break;
-    case 11:
-      return F("Bulk UV");
-      break;
-    case 12:
-      return F("Internal error");
-      break;
-    case 13:
-      return F("Grid Fail");
-      break;
-    case 14:
-      return F("Bulk Low");
-      break;
-    case 15:
-      return F("Ramp Fail");
-      break;
-    case 16:
-      return F("Dc / Dc Fail");
-      break;
-    case 17:
-      return F("Wrong Mode");
-      break;
-    case 18:
-      return F("Ground Fault");
-      break;
-    case 19:
-      return F("Over Temp.");
-      break;
-    case 20:
-      return F("Bulk Cap Fail");
-      break;
-    case 21:
-      return F("Inverter Fail");
-      break;
-    case 22:
-      return F("Start Timeout");
-      break;
-    case 23:
-      return F("Ground Fault");
-      break;
-    case 24:
-      return F("Degauss error");
-      break;
-    case 25:
-      return F("Ileak sens.fail");
-      break;
-    case 26:
-      return F("DcDc Fail");
-      break;
-    case 27:
-      return F("Self Test Error 1");
-      break;
-    case 28:
-      return F("Self Test Error 2");
-      break;
-    case 29:
-      return F("Self Test Error 3");
-      break;
-    case 30:
-      return F("Self Test Error 4");
-      break;
-    case 31:
-      return F("DC inj error");
-      break;
-    case 32:
-      return F("Grid OV");
-      break;
-    case 33:
-      return F("Grid UV");
-      break;
-    case 34:
-      return F("Grid OF");
-      break;
-    case 35:
-      return F("Grid UF");
-      break;
-    case 36:
-      return F("Z grid Hi");
-      break;
-    case 37:
-      return F("Internal error");
-      break;
-    case 38:
-      return F("Riso Low");
-      break;
-    case 39:
-      return F("Vref Error");
-      break;
-    case 40:
-      return F("Error Meas V");
-      break;
-    case 41:
-      return F("Error Meas F");
-      break;
-    case 42:
-      return F("Error Meas Z");
-      break;
-    case 43:
-      return F("Error Meas Ileak");
-      break;
-    case 44:
-      return F("Error Read V");
-      break;
-    case 45:
-      return F("Error Read I");
-      break;
-    case 46:
-      return F("Table fail");
-      break;
-    case 47:
-      return F("Fan Fail");
-      break;
-    case 48:
-      return F("UTH");
-      break;
-    case 49:
-      return F("Interlock fail");
-      break;
-    case 50:
-      return F("Remote Off");
-      break;
-    case 51:
-      return F("Vout Avg errror");
-      break;
-    case 52:
-      return F("Battery low");
-      break;
-    case 53:
-      return F("Clk fail");
-      break;
-    case 54:
-      return F("Input UC");
-      break;
-    case 55:
-      return F("Zero Power");
-      break;
-    case 56:
-      return F("Fan Stucked");
-      break;
-    case 57:
-      return F("DC Switch Open");
-      break;
-    case 58:
-      return F("Tras Switch Open");
-      break;
-    case 59:
-      return F("AC Switch Open");
-      break;
-    case 60:
-      return F("Bulk UV");
-      break;
-    case 61:
-      return F("Autoexclusion");
-      break;
-    case 62:
-      return F("Grid df / dt");
-      break;
-    case 63:
-      return F("Den switch Open");
-      break;
-    case 64:
-      return F("Jbox fail");
-      break;
-    default:
-      return F("Sconosciuto");
-      break;
-    }
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    byte InverterState;
-    byte Channel1State;
-    byte Channel2State;
-    byte AlarmState;
-    bool ReadState;
-  } DataState;
-
-  DataState State;
-
-  bool ReadState() {
-    State.ReadState = Send(Address, (byte)50, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    if (State.ReadState == false) {
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-      ReceiveData[2] = 255;
-      ReceiveData[3] = 255;
-      ReceiveData[4] = 255;
-      ReceiveData[5] = 255;
-    }
-
-    State.TransmissionState = ReceiveData[0];
-    State.GlobalState = ReceiveData[1];
-    State.InverterState = ReceiveData[2];
-    State.Channel1State = ReceiveData[3];
-    State.Channel2State = ReceiveData[4];
-    State.AlarmState = ReceiveData[5];
-
-    return State.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    String Par1;
-    String Par2;
-    String Par3;
-    String Par4;
-    bool ReadState;
-  } DataVersion;
-
-  DataVersion Version;
-
-  bool ReadVersion() {
-    Version.ReadState = Send(Address, (byte)58, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    if (Version.ReadState == false) {
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-    }
-
-    Version.TransmissionState = ReceiveData[0];
-    Version.GlobalState = ReceiveData[1];
-
-    switch ((char)ReceiveData[2])
-    {
-    case 'i':
-      Version.Par1 = F("Aurora 2 kW indoor");
-      break;
-    case 'o':
-      Version.Par1 = F("Aurora 2 kW outdoor");
-      break;
-    case 'I':
-      Version.Par1 = F("Aurora 3.6 kW indoor");
-      break;
-    case 'O':
-      Version.Par1 = F("Aurora 3.0 - 3.6 kW outdoor");
-      break;
-    case '5':
-      Version.Par1 = F("Aurora 5.0 kW outdoor");
-      break;
-    case '6':
-      Version.Par1 = F("Aurora 6 kW outdoor");
-      break;
-    case 'P':
-      Version.Par1 = F("3 - phase interface (3G74)");
-      break;
-    case 'C':
-      Version.Par1 = F("Aurora 50kW module");
-      break;
-    case '4':
-      Version.Par1 = F("Aurora 4.2kW new");
-      break;
-    case '3':
-      Version.Par1 = F("Aurora 3.6kW new");
-      break;
-    case '2':
-      Version.Par1 = F("Aurora 3.3kW new");
-      break;
-    case '1':
-      Version.Par1 = F("Aurora 3.0kW new");
-      break;
-    case 'D':
-      Version.Par1 = F("Aurora 12.0kW");
-      break;
-    case 'X':
-      Version.Par1 = F("Aurora 10.0kW");
-      break;
-    default:
-      Version.Par1 = F("Sconosciuto");
-      break;
-    }
-
-    switch ((char)ReceiveData[3])
-    {
-    case 'A':
-      Version.Par2 = F("UL1741");
-      break;
-    case 'E':
-      Version.Par2 = F("VDE0126");
-      break;
-    case 'S':
-      Version.Par2 = F("DR 1663 / 2000");
-      break;
-    case 'I':
-      Version.Par2 = F("ENEL DK 5950");
-      break;
-    case 'U':
-      Version.Par2 = F("UK G83");
-      break;
-    case 'K':
-      Version.Par2 = F("AS 4777");
-      break;
-    default:
-      Version.Par2 = F("Sconosciuto");
-      break;
-    }
-
-    switch ((char)ReceiveData[4])
-    {
-    case 'N':
-      Version.Par3 = F("Transformerless Version");
-      break;
-    case 'T':
-      Version.Par3 = F("Transformer Version");
-      break;
-    default:
-      Version.Par3 = F("Sconosciuto");
-      break;
-    }
-
-    switch ((char)ReceiveData[5])
-    {
-    case 'W':
-      Version.Par4 = F("Wind version");
-      break;
-    case 'N':
-      Version.Par4 = F("PV version");
-      break;
-    default:
-      Version.Par4 = F("Sconosciuto");
-      break;
-    }
-
-    return Version.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    float Valore;
-    bool ReadState;
-  } DataDSP;
-
-  DataDSP DSP;
-
-  bool ReadDSP(byte type, byte global) {
-    if ((((int)type >= 1 && (int)type <= 9) || ((int)type >= 21 && (int)type <= 63)) && ((int)global >= 0 && (int)global <= 1)) {
-      DSP.ReadState = Send(Address, (byte)59, type, global, (byte)0, (byte)0, (byte)0, (byte)0);
-      if (DSP.ReadState == false) {
-        ReceiveData[0] = 255;
-        ReceiveData[1] = 255;
-      }
-
-    }
-    else {
-      DSP.ReadState = false;
-      clearReceiveData();
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-    }
-
-    DSP.TransmissionState = ReceiveData[0];
-    DSP.GlobalState = ReceiveData[1];
-
-    foo.asBytes[0] = ReceiveData[5];
-    foo.asBytes[1] = ReceiveData[4];
-    foo.asBytes[2] = ReceiveData[3];
-    foo.asBytes[3] = ReceiveData[2];
-
-    DSP.Valore = foo.asFloat;
-
-    return DSP.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    unsigned long Secondi;
-    bool ReadState;
-  } DataTimeDate;
-
-  DataTimeDate TimeDate;
-
-  bool ReadTimeDate() {
-    TimeDate.ReadState = Send(Address, (byte)70, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    if (TimeDate.ReadState == false) {
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-    }
-
-    TimeDate.TransmissionState = ReceiveData[0];
-    TimeDate.GlobalState = ReceiveData[1];
-    TimeDate.Secondi = ((unsigned long)ReceiveData[2] << 24) + ((unsigned long)ReceiveData[3] << 16) + ((unsigned long)ReceiveData[4] << 8) + (unsigned long)ReceiveData[5];
-    return TimeDate.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    byte Alarms1;
-    byte Alarms2;
-    byte Alarms3;
-    byte Alarms4;
-    bool ReadState;
-  } DataLastFourAlarms;
-
-  DataLastFourAlarms LastFourAlarms;
-
-  bool ReadLastFourAlarms() {
-    LastFourAlarms.ReadState = Send(Address, (byte)86, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    if (LastFourAlarms.ReadState == false) {
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-      ReceiveData[2] = 255;
-      ReceiveData[3] = 255;
-      ReceiveData[4] = 255;
-      ReceiveData[5] = 255;
-    }
-
-    LastFourAlarms.TransmissionState = ReceiveData[0];
-    LastFourAlarms.GlobalState = ReceiveData[1];
-    LastFourAlarms.Alarms1 = ReceiveData[2];
-    LastFourAlarms.Alarms2 = ReceiveData[3];
-    LastFourAlarms.Alarms3 = ReceiveData[4];
-    LastFourAlarms.Alarms4 = ReceiveData[5];
-
-    return LastFourAlarms.ReadState;
-  }
-
-  bool ReadJunctionBoxState(byte nj) {
-    return Send(Address, (byte)200, nj, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  bool ReadJunctionBoxVal(byte nj, byte par) {
-    return Send(Address, (byte)201, nj, par, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  // Inverters
-  typedef struct {
-    String PN;
-    bool ReadState;
-  } DataSystemPN;
-
-  DataSystemPN SystemPN;
-
-  bool ReadSystemPN() {
-    SystemPN.ReadState = Send(Address, (byte)52, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    SystemPN.PN = String(String((char)ReceiveData[0]) + String((char)ReceiveData[1]) + String((char)ReceiveData[2]) + String((char)ReceiveData[3]) + String((char)ReceiveData[4]) + String((char)ReceiveData[5]));
-
-    return SystemPN.ReadState;
-  }
-
-  typedef struct {
-    String SerialNumber;
-    bool ReadState;
-  } DataSystemSerialNumber;
-
-  DataSystemSerialNumber SystemSerialNumber;
-
-  bool ReadSystemSerialNumber() {
-    SystemSerialNumber.ReadState = Send(Address, (byte)63, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    SystemSerialNumber.SerialNumber = String(String((char)ReceiveData[0]) + String((char)ReceiveData[1]) + String((char)ReceiveData[2]) + String((char)ReceiveData[3]) + String((char)ReceiveData[4]) + String((char)ReceiveData[5]));
-
-    return SystemSerialNumber.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    String Week;
-    String Year;
-    bool ReadState;
-  } DataManufacturingWeekYear;
-
-  DataManufacturingWeekYear ManufacturingWeekYear;
-
-  bool ReadManufacturingWeekYear() {
-    ManufacturingWeekYear.ReadState = Send(Address, (byte)65, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    if (ManufacturingWeekYear.ReadState == false) {
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-    }
-
-    ManufacturingWeekYear.TransmissionState = ReceiveData[0];
-    ManufacturingWeekYear.GlobalState = ReceiveData[1];
-    ManufacturingWeekYear.Week = String(String((char)ReceiveData[2]) + String((char)ReceiveData[3]));
-    ManufacturingWeekYear.Year = String(String((char)ReceiveData[4]) + String((char)ReceiveData[5]));
-
-    return ManufacturingWeekYear.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    String Release;
-    bool ReadState;
-  } DataFirmwareRelease;
-
-  DataFirmwareRelease FirmwareRelease;
-
-  bool ReadFirmwareRelease() {
-    FirmwareRelease.ReadState = Send(Address, (byte)72, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-    if (FirmwareRelease.ReadState == false) {
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-    }
-
-    FirmwareRelease.TransmissionState = ReceiveData[0];
-    FirmwareRelease.GlobalState = ReceiveData[1];
-    FirmwareRelease.Release = String(String((char)ReceiveData[2]) + "." + String((char)ReceiveData[3]) + "." + String((char)ReceiveData[4]) + "." + String((char)ReceiveData[5]));
-
-    return FirmwareRelease.ReadState;
-  }
-
-  typedef struct {
-    byte TransmissionState;
-    byte GlobalState;
-    unsigned long Energia;
-    bool ReadState;
-  } DataCumulatedEnergy;
-
-  DataCumulatedEnergy CumulatedEnergy;
-
-  bool ReadCumulatedEnergy(byte par) {
-    if ((int)par >= 0 && (int)par <= 6) {
-      CumulatedEnergy.ReadState = Send(Address, (byte)78, par, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-
-      if (CumulatedEnergy.ReadState == false) {
-        ReceiveData[0] = 255;
-        ReceiveData[1] = 255;
-      }
-
-    }
-    else {
-      CumulatedEnergy.ReadState = false;
-      clearReceiveData();
-      ReceiveData[0] = 255;
-      ReceiveData[1] = 255;
-    }
-
-    CumulatedEnergy.TransmissionState = ReceiveData[0];
-    CumulatedEnergy.GlobalState = ReceiveData[1];
-    if (CumulatedEnergy.ReadState == true) {
-            ulo.asBytes[0] = ReceiveData[5];
-           ulo.asBytes[1] = ReceiveData[4];
-            ulo.asBytes[2] = ReceiveData[3];
-            ulo.asBytes[3] = ReceiveData[2];
-
-           CumulatedEnergy.Energia = ulo.asUlong;
-    }
-    return CumulatedEnergy.ReadState;
-  }
-
-  bool WriteBaudRateSetting(byte baudcode) {
-    if ((int)baudcode >= 0 && (int)baudcode <= 3) {
-      return Send(Address, (byte)85, baudcode, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-    }
-    else {
-      clearReceiveData();
-      return false;
-    }
-  }
-
-  // Central
-  bool ReadFlagsSwitchCentral() {
-    return Send(Address, (byte)67, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  bool ReadCumulatedEnergyCentral(byte var, byte ndays_h, byte ndays_l, byte global) {
-    return Send(Address, (byte)68, var, ndays_h, ndays_l, global, (byte)0, (byte)0);
-  }
-
-  bool ReadFirmwareReleaseCentral(byte var) {
-    return Send(Address, (byte)72, var, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  bool ReadBaudRateSettingCentral(byte baudcode, byte serialline) {
-    return Send(Address, (byte)85, baudcode, serialline, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  bool ReadSystemInfoCentral(byte var) {
-    return Send(Address, (byte)101, var, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  bool ReadJunctionBoxMonitoringCentral(byte cf, byte rn, byte njt, byte jal, byte jah) {
-    return Send(Address, (byte)103, cf, rn, njt, jal, jah, (byte)0);
-  }
-
-  bool ReadSystemPNCentral() {
-    return Send(Address, (byte)105, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-  bool ReadSystemSerialNumberCentral() {
-    return Send(Address, (byte)107, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);
-  }
-
-};
-
-
-
-//======================================================
-clsAurora Inverter2 = clsAurora(2);  //aggiornare l'id dell'inverter
-
-byte Menu = 0;
-
-
-String LeggiProduzioneCallback(byte Menu) {
-  switch (Menu)
-  {
-  case 0:
-    Inverter2.ReadCumulatedEnergy(0);
-    break;
-  case 1:
-    Inverter2.ReadTimeDate();
-    break;
-  case 2:
-    Inverter2.ReadLastFourAlarms();
-    break;
-  case 3:
-    Inverter2.ReadSystemPN();
-    break;
-  case 4:
-    Inverter2.ReadSystemSerialNumber();
-    break;
-  case 5:
-    Inverter2.ReadManufacturingWeekYear();
-    break;
-  case 6:
-    Inverter2.ReadFirmwareRelease();
-    break;
-  case 7:
-    Inverter2.ReadVersion();
-    break;
-  case 8:
-    Inverter2.ReadState();
-    break;
-  default:
-    break;
-  }
-}
-
-
-void setup()
-{
-  Serial1.setTimeout(500);
-  Serial.begin(9600);
-  pinMode(SSerialTxControl, OUTPUT);
-  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver
-
-  Serial.println(Inverter2.ReadCumulatedEnergy(0));
-  Serial.println(Inverter2.ReadTimeDate());
-  Serial.println(Inverter2.ReadLastFourAlarms());
-  Serial.println(Inverter2.ReadSystemPN());
-  Serial.println(Inverter2.ReadSystemSerialNumber());
-  Serial.println(Inverter2.ReadManufacturingWeekYear());
-  Serial.println(Inverter2.ReadFirmwareRelease());
-  Serial.println(Inverter2.ReadManufacturingWeekYear());
-  Serial.println(Inverter2.ReadFirmwareRelease());
-  Serial.println(Inverter2.ReadManufacturingWeekYear());
-  Serial.println(Inverter2.ReadFirmwareRelease());
-  Serial.println(Inverter2.ReadFirmwareRelease());
-  Serial.println(Inverter2.ReadVersion());
-  Serial.println(Inverter2.ReadState());
-
-  delay(50);
-}
-
-void loop()
-{
-  yield();
- }


added note about NewPing library

added note about NewPing library

--- a02_ultrasoundSensor/a02_ultrasoundSensor.ino
+++ a02_ultrasoundSensor/a02_ultrasoundSensor.ino
@@ -5,6 +5,9 @@
  * sensor connected. If this program doesn't work, trace the wires
  * to find which pins on the motherboard the pins on the sensor are
  * connected to. You may need to try a few different pin numbers.
+ *
+ * This uses the NewPing library, which I installed as a zip from
+ * here: http://playground.arduino.cc/Code/NewPing
  */

 #define TRIGGER_PIN  7


Added blinking of address

Added blinking of address

--- RS485/ModuleConfigTest/ModuleConfigTest.ino
+++ RS485/ModuleConfigTest/ModuleConfigTest.ino
@@ -14,10 +14,12 @@
 #include "HMTLTypes.h"
 #include "PixelUtil.h"

+#define PIN_DEBUG_LED  13
+
 // Pixel strand outputs
 PixelUtil pixels;

-#define MAX_OUTPUTS 3
+#define MAX_OUTPUTS 4
 config_hdr_t config;
 output_hdr_t *outputs[MAX_OUTPUTS];
 config_max_t readoutputs[MAX_OUTPUTS];
@@ -56,5 +58,7 @@
     hmtl_update_output(outputs[i], &pixels);
   }

+  blink_value(PIN_DEBUG_LED, config.address, 500, 4);
+
   delay(DELAY);
 }


Fixed calculation of uv intensity

Fixed calculation of uv intensity

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

 int printHexToStream(const uint8_t *data, uint8_t length, Print &stream) // prints 8-bit data in hex
@@ -252,4 +252,4 @@
     sleep(5000);
     asm volatile (" jmp 0");
   }
-}+}


added delay() to give some time for core processes

--- Esp8266/Esp8266.ino
+++ Esp8266/Esp8266.ino
@@ -72,25 +72,25 @@
   // cache-control 15 seconds
   // add dynamic http resources
   SERVER.on("/fs", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, FILESYSTEM.getStorageDetails());
+    SERVER.send(request, esp8266utils::APP_JSON, FILESYSTEM.getStorageDetails());
   });
   SERVER.on("/files", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, FILESYSTEM.getFileListing());
+    SERVER.send(request, esp8266utils::APP_JSON, FILESYSTEM.getFileListing());
   });
   SERVER.on("/sta", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, WIFI_STA_CFG.getDetails());
+    SERVER.send(request, esp8266utils::APP_JSON, WIFI_STA_CFG.getDetails());
   });
   SERVER.on("/ap", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, WIFI_AP_CFG.getDetails());
+    SERVER.send(request, esp8266utils::APP_JSON, WIFI_AP_CFG.getDetails());
   });
   SERVER.on("/esp", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, SYS_CFG.getDetails());
+    SERVER.send(request, esp8266utils::APP_JSON, SYS_CFG.getDetails());
   });
   SERVER.on("/motor_a", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, _motorA.getDetails());
+    SERVER.send(request, esp8266utils::APP_JSON, _motorA.getDetails());
   });
   SERVER.on("/motor_b", HTTP_GET, [](AsyncWebServerRequest *request) {
-    SERVER.send(request, esp8266utils::TEXT_JSON, _motorB.getDetails());
+    SERVER.send(request, esp8266utils::APP_JSON, _motorB.getDetails());
   });
   // add web socket support
   _wsl.onTextMessage([](AsyncWebSocket *ws, AsyncWebSocketClient *client, AwsEventType type, AwsFrameInfo *info, uint8_t *data, size_t len) {
@@ -144,7 +144,12 @@
 }

 void loop() {
+
+  ESP.wdtDisable();
   if (SYS_CFG.nextLoopInterval()) {
     MDNS.update();
   }
+  ESP.wdtEnable(30000);
+  // reserve time for core processes
+  delay(500);
 }


Added patternPicker()

Added patternPicker()

Will not work yet - finish adding buttonVal’s first!

--- IR_Test/IR_Test.ino
+++ IR_Test/IR_Test.ino
@@ -1,510 +1,530 @@
-#include <IRremote.h>
-
-int IRpin = 11;  // pin for the IR sensor
-int lastButton = 0;
-boolean continuing = false;
-String button = "";
-IRrecv irrecv(IRpin);
-decode_results results;
-int someNum = 0;
-int buttonId = 0;
-int buttonVal = 0;
-int nums [6];
-
-int m11 = 22;
-int m12 = 23;
-int m13 = 24;
-int m14 = 25;
-int m15 = 26;
-int m21 = 27;
-int m22 = 28;
-int m23 = 29;
-int m24 = 30;
-int m25 = 31;
-int m31 = 32;
-int m32 = 33;
-int m33 = 34;
-int m34 = 35;
-int m35 = 36;
-int m41 = 37;
-int m42 = 38;
-int m43 = 39;
-int m44 = 40;
-int m45 = 41;
-int m51 = 42;
-int m52 = 43;
-int m53 = 44;
-int m54 = 45;
-int m55 = 46;
-int motors[25] = {m11,m12,m13,m14,m15,m21,m22,m23,m24,m25,m31,m32,m33,m34,m35,m41,m42,m43,m44,m45,m51,m52,m53,m54,m55};
-
-void setup() {
-  Serial.begin(9600);
-  irrecv.enableIRIn(); // Start the receiver
-  for (int i = 0; i <= 24; i++) {
-    pinMode(motors[i], OUTPUT);
-  }
-}
-
-void whatButton(int x){
-  switch(x){
-    case 16753245:
-      button = "CH-";
-      buttonId = 53245;
-      buttonVal = 147775;
-      break;
-    case 16736925:
-      button="CH";
-      buttonId = 36925;
-      buttonVal = 110075;
-      break;
-    case 16769565:
-      button="CH+";
-      buttonId = 69565;
-      buttonVal = 207675;
-      break;
-    case 16720605:
-      button="|<<";
-      buttonId = 20605;
-      buttonVal = 50175;
-      break;
-    case 16712445:
-      button="|>>";
-      buttonId = 12445;
-      buttonVal = 30235;
-      break;
-    case 16761405:
-      button=">||";
-      buttonId = 61405;
-      buttonVal = 167735;
-      break;
-    case 16769055:
-      button="-";
-      buttonId = 69005;
-      break;
-    case 16754775:
-      button="+";
-      buttonId = 54775;
-      break;
-    case 16748655:
-      button="EQ";
-      buttonId = 48655;
-      break;
-    case 16738455:
-      button="0";
-      buttonId = 38455;
-      break;
-    case 16750695:
-      button="100+";
-      buttonId = 50695;
-      break;
-    case 16756815:
-      button="200+";
-      buttonId = 56815;
-      break;
-    case 16724175:
-      button="1";
-      buttonId = 24175;
-      break;
-    case 16718055:
-      button="2";
-      buttonId = 18055;
-      break;
-    case 16743045:
-      button="3";
-      buttonId = 43045;
-      break;
-    case 16716015:
-      button="4";
-      buttonId = 16015;
-      break;
-    case 16726215:
-      button="5";
-      buttonId = 26215;
-      break;
-    case 16734885:
-      button="6";
-      buttonId = 34885;
-      break;
-    case 16728765:
-      button="7";
-      buttonId = 28765;
-      break;
-    case 16730805:
-      button="8";
-      buttonId = 30805;
-      break;
-    case 16732845:
-      button="9";
-      buttonId = 32845;
-      break;
-    default:
-      button="";
-      buttonId = 0;
-      break;
-  }
-}
-
-void separate(int x) {
-  int n1;
-  int n2;
-  int n3;
-  int n4;
-  int n5;
-  int n6;
-  n6 = x % 10;
-  n5 = floor(x / 10) % 10;
-  n4 = floor(x / 100) % 10;
-  n3 = floor(x / 1000) % 10;
-  n2 = floor(x / 10000) % 10;
-  n1 = floor(x / 100000) % 10;
-  int nums[6] = {n1,n2,n3,n4,n5,n6};
-}
-
-void p0() {
-  digitalWrite(m21, HIGH);
-  digitalWrite(m31, HIGH);
-  digitalWrite(m41, HIGH);
-  delay(100);
-  digitalWrite(m21, LOW);
-  digitalWrite(m31, LOW);
-  digitalWrite(m41, LOW);
-
-  digitalWrite(m22, HIGH);
-  digitalWrite(m32, HIGH);
-  digitalWrite(m42, HIGH);
-  delay(100);
-  digitalWrite(m22, LOW);
-  digitalWrite(m32, LOW);
-  digitalWrite(m42, LOW);
-
-  digitalWrite(m23, HIGH);
-  digitalWrite(m33, HIGH);
-  digitalWrite(m43, HIGH);
-  delay(100);
-  digitalWrite(m23, LOW);
-  digitalWrite(m33, LOW);
-  digitalWrite(m43, LOW);
-
-  digitalWrite(m24, HIGH);
-  digitalWrite(m34, HIGH);
-  digitalWrite(m44, HIGH);
-  delay(100);
-  digitalWrite(m24, LOW);
-  digitalWrite(m34, LOW);
-  digitalWrite(m44, LOW);
-
-  digitalWrite(m25, HIGH);
-  digitalWrite(m35, HIGH);
-  digitalWrite(m45, HIGH);
-  delay(100);
-  digitalWrite(m25, LOW);
-  digitalWrite(m35, LOW);
-  digitalWrite(m45, LOW);
-}
-
-void p1() {
-  digitalWrite(m11, HIGH);
-  delay(100);
-  digitalWrite(m11, LOW);
-
-  digitalWrite(m12, HIGH);
-  digitalWrite(m21, HIGH);
-  digitalWrite(m22, HIGH);
-  delay(100);
-  digitalWrite(m12, LOW);
-  digitalWrite(m21, LOW);
-  digitalWrite(m22, LOW);
-
-  digitalWrite(m23, HIGH);
-  digitalWrite(m32, HIGH);
-  digitalWrite(m33, HIGH);
-  delay(100);
-  digitalWrite(m23, LOW);
-  digitalWrite(m32, LOW);
-  digitalWrite(m33, LOW);
-
-  digitalWrite(m34, HIGH);
-  digitalWrite(m43, HIGH);
-  digitalWrite(m44, HIGH);
-  delay(100);
-  digitalWrite(m34, LOW);
-  digitalWrite(m43, LOW);
-  digitalWrite(m44, LOW);
-
-  digitalWrite(m45, HIGH);
-  digitalWrite(m54, HIGH);
-  digitalWrite(m55, HIGH);
-  delay(100);
-  digitalWrite(m45, LOW);
-  digitalWrite(m54, LOW);
-  digitalWrite(m55, LOW);
-}
-
-void p2() {
-  digitalWrite(m12, HIGH);
-  digitalWrite(m13, HIGH);
-  digitalWrite(m14, HIGH);
-  delay(100);
-  digitalWrite(m12, LOW);
-  digitalWrite(m13, LOW);
-  digitalWrite(m14, LOW);
-
-  digitalWrite(m22, HIGH);
-  digitalWrite(m23, HIGH);
-  digitalWrite(m24, HIGH);
-  delay(100);
-  digitalWrite(m22, LOW);
-  digitalWrite(m23, LOW);
-  digitalWrite(m24, LOW);
-
-  digitalWrite(m32, HIGH);
-  digitalWrite(m33, HIGH);
-  digitalWrite(m34, HIGH);
-  delay(100);
-  digitalWrite(m32, LOW);
-  digitalWrite(m33, LOW);
-  digitalWrite(m34, LOW);
-
-  digitalWrite(m42, HIGH);
-  digitalWrite(m43, HIGH);
-  digitalWrite(m44, HIGH);
-  delay(100);
-  digitalWrite(m42, LOW);
-  digitalWrite(m43, LOW);
-  digitalWrite(m44, LOW);
-
-  digitalWrite(m52, HIGH);
-  digitalWrite(m53, HIGH);
-  digitalWrite(m54, HIGH);
-  delay(100);
-  digitalWrite(m52, LOW);
-  digitalWrite(m53, LOW);
-  digitalWrite(m54, LOW);
-}
-
-void p3() {
-  digitalWrite(m15, HIGH);
-  delay(100);
-  digitalWrite(m15, LOW);
-
-  digitalWrite(m14, HIGH);
-  digitalWrite(m24, HIGH);
-  digitalWrite(m25, HIGH);
-  delay(100);
-  digitalWrite(m14, LOW);
-  digitalWrite(m24, LOW);
-  digitalWrite(m25, LOW);
-
-  digitalWrite(m23, HIGH);
-  digitalWrite(m34, HIGH);
-  digitalWrite(m33, HIGH);
-  delay(100);
-  digitalWrite(m23, LOW);
-  digitalWrite(m34, LOW);
-  digitalWrite(m33, LOW);
-
-  digitalWrite(m32, HIGH);
-  digitalWrite(m43, HIGH);
-  digitalWrite(m42, HIGH);
-  delay(100);
-  digitalWrite(m32, LOW);
-  digitalWrite(m43, LOW);
-  digitalWrite(m42, LOW);
-
-  digitalWrite(m41, HIGH);
-  digitalWrite(m52, HIGH);
-  digitalWrite(m51, HIGH);
-  delay(100);
-  digitalWrite(m41, LOW);
-  digitalWrite(m52, LOW);
-  digitalWrite(m51, LOW);
-}
-
-void p4() {
-  digitalWrite(m25, HIGH);
-  digitalWrite(m35, HIGH);
-  digitalWrite(m45, HIGH);
-  delay(100);
-  digitalWrite(m25, LOW);
-  digitalWrite(m35, LOW);
-  digitalWrite(m45, LOW);
-
-  digitalWrite(m24, HIGH);
-  digitalWrite(m34, HIGH);
-  digitalWrite(m44, HIGH);
-  delay(100);
-  digitalWrite(m24, LOW);
-  digitalWrite(m34, LOW);
-  digitalWrite(m44, LOW);
-
-  digitalWrite(m23, HIGH);
-  digitalWrite(m33, HIGH);
-  digitalWrite(m43, HIGH);
-  delay(100);
-  digitalWrite(m23, LOW);
-  digitalWrite(m33, LOW);
-  digitalWrite(m43, LOW);
-
-  digitalWrite(m22, HIGH);
-  digitalWrite(m32, HIGH);
-  digitalWrite(m42, HIGH);
-  delay(100);
-  digitalWrite(m22, LOW);
-  digitalWrite(m32, LOW);
-  digitalWrite(m42, LOW);
-
-  digitalWrite(m21, HIGH);
-  digitalWrite(m31, HIGH);
-  digitalWrite(m41, HIGH);
-  delay(100);
-  digitalWrite(m21, LOW);
-  digitalWrite(m31, LOW);
-  digitalWrite(m41, LOW);
-}
-
-void p5() {
-  digitalWrite(m55, HIGH);
-  delay(100);
-  digitalWrite(m55, LOW);
-
-  digitalWrite(m44, HIGH);
-  digitalWrite(m45, HIGH);
-  digitalWrite(m54, HIGH);
-  delay(100);
-  digitalWrite(m44, LOW);
-  digitalWrite(m45, LOW);
-  digitalWrite(m54, LOW);
-
-  digitalWrite(m33, HIGH);
-  digitalWrite(m34, HIGH);
-  digitalWrite(m43, HIGH);
-  delay(100);
-  digitalWrite(m33, LOW);
-  digitalWrite(m34, LOW);
-  digitalWrite(m43, LOW);
-
-  digitalWrite(m22, HIGH);
-  digitalWrite(m23, HIGH);
-  digitalWrite(m32, HIGH);
-  delay(100);
-  digitalWrite(m22, LOW);
-  digitalWrite(m23, LOW);
-  digitalWrite(m32, LOW);
-
-  digitalWrite(m11, HIGH);
-  digitalWrite(m12, HIGH);
-  digitalWrite(m21, HIGH);
-  delay(100);
-  digitalWrite(m11, LOW);
-  digitalWrite(m12, LOW);
-  digitalWrite(m21, LOW);
-}
-
-void p6() {
-  digitalWrite(m52, HIGH);
-  digitalWrite(m53, HIGH);
-  digitalWrite(m54, HIGH);
-  delay(100);
-  digitalWrite(m52, LOW);
-  digitalWrite(m53, LOW);
-  digitalWrite(m54, LOW);
-
-  digitalWrite(m42, HIGH);
-  digitalWrite(m43, HIGH);
-  digitalWrite(m44, HIGH);
-  delay(100);
-  digitalWrite(m42, LOW);
-  digitalWrite(m43, LOW);
-  digitalWrite(m44, LOW);
-
-  digitalWrite(m32, HIGH);
-  digitalWrite(m33, HIGH);
-  digitalWrite(m34, HIGH);
-  delay(100);
-  digitalWrite(m32, LOW);
-  digitalWrite(m33, LOW);
-  digitalWrite(m34, LOW);
-
-  digitalWrite(m22, HIGH);
-  digitalWrite(m23, HIGH);
-  digitalWrite(m24, HIGH);
-  delay(100);
-  digitalWrite(m22, LOW);
-  digitalWrite(m23, LOW);
-  digitalWrite(m24, LOW);
-
-  digitalWrite(m12, HIGH);
-  digitalWrite(m13, HIGH);
-  digitalWrite(m14, HIGH);
-  delay(100);
-  digitalWrite(m12, LOW);
-  digitalWrite(m13, LOW);
-  digitalWrite(m14, LOW);
-}
-
-void p7() {
-  digitalWrite(m51, HIGH);
-  delay(100);
-  digitalWrite(m51, LOW);
-
-  digitalWrite(m41, HIGH);
-  digitalWrite(m42, HIGH);
-  digitalWrite(m52, HIGH);
-  delay(100);
-  digitalWrite(m41, LOW);
-  digitalWrite(m42, LOW);
-  digitalWrite(m52, LOW);
-
-  digitalWrite(m32, HIGH);
-  digitalWrite(m43, HIGH);
-  digitalWrite(m33, HIGH);
-  delay(100);
-  digitalWrite(m32, LOW);
-  digitalWrite(m43, LOW);
-  digitalWrite(m33, LOW);
-
-  digitalWrite(m23, HIGH);
-  digitalWrite(m34, HIGH);
-  digitalWrite(m24, HIGH);
-  delay(100);
-  digitalWrite(m23, LOW);
-  digitalWrite(m34, LOW);
-  digitalWrite(m24, LOW);
-
-  digitalWrite(m14, HIGH);
-  digitalWrite(m25, HIGH);
-  digitalWrite(m15, HIGH);
-  delay(100);
-  digitalWrite(m14, LOW);
-  digitalWrite(m25, LOW);
-  digitalWrite(m15, LOW);
-}
-
-void patternPicker(int x) {
-
-}
-
-void loop() {
-  if (irrecv.decode(&results)) {
-    irrecv.resume();
-  }
-
-  whatButton(results.value);
-  /*if (continuing == true) {
-    whatButton(lastButton);
-  }
-  else {
-    lastButton = results.value;
-  }
-  delay(100); */
-  if ((someNum % 1000) == 0){
-    if (buttonId != 0){
-      Serial.println(button);
-      Serial.println(buttonId);
-      Serial.println(convertToOct(buttonId));
-      Serial.println("");
-    }
-  }
-  someNum = someNum + 1;
-}
+#include <IRremote.h>
+
+int IRpin = 11;  // pin for the IR sensor
+int lastButton = 0;
+boolean continuing = false;
+String button = "";
+IRrecv irrecv(IRpin);
+decode_results results;
+int someNum = 0;
+int buttonId = 0;
+int buttonVal = 0;
+int nums [6];
+
+int m11 = 22;
+int m12 = 23;
+int m13 = 24;
+int m14 = 25;
+int m15 = 26;
+int m21 = 27;
+int m22 = 28;
+int m23 = 29;
+int m24 = 30;
+int m25 = 31;
+int m31 = 32;
+int m32 = 33;
+int m33 = 34;
+int m34 = 35;
+int m35 = 36;
+int m41 = 37;
+int m42 = 38;
+int m43 = 39;
+int m44 = 40;
+int m45 = 41;
+int m51 = 42;
+int m52 = 43;
+int m53 = 44;
+int m54 = 45;
+int m55 = 46;
+int motors[25] = {m11,m12,m13,m14,m15,m21,m22,m23,m24,m25,m31,m32,m33,m34,m35,m41,m42,m43,m44,m45,m51,m52,m53,m54,m55};
+
+void setup() {
+  Serial.begin(9600);
+  irrecv.enableIRIn(); // Start the receiver
+  for (int i = 0; i <= 24; i++) {
+    pinMode(motors[i], OUTPUT);
+  }
+}
+
+void whatButton(int x){
+  switch(x){
+    case 16753245:
+      button = "CH-";
+      buttonId = 53245;
+      buttonVal = 147775;
+      break;
+    case 16736925:
+      button="CH";
+      buttonId = 36925;
+      buttonVal = 110075;
+      break;
+    case 16769565:
+      button="CH+";
+      buttonId = 69565;
+      buttonVal = 207675;
+      break;
+    case 16720605:
+      button="|<<";
+      buttonId = 20605;
+      buttonVal = 50175;
+      break;
+    case 16712445:
+      button="|>>";
+      buttonId = 12445;
+      buttonVal = 30235;
+      break;
+    case 16761405:
+      button=">||";
+      buttonId = 61405;
+      buttonVal = 167735;
+      break;
+    case 16769055:
+      button="-";
+      buttonId = 69005;
+      break;
+    case 16754775:
+      button="+";
+      buttonId = 54775;
+      break;
+    case 16748655:
+      button="EQ";
+      buttonId = 48655;
+      break;
+    case 16738455:
+      button="0";
+      buttonId = 38455;
+      break;
+    case 16750695:
+      button="100+";
+      buttonId = 50695;
+      break;
+    case 16756815:
+      button="200+";
+      buttonId = 56815;
+      break;
+    case 16724175:
+      button="1";
+      buttonId = 24175;
+      break;
+    case 16718055:
+      button="2";
+      buttonId = 18055;
+      break;
+    case 16743045:
+      button="3";
+      buttonId = 43045;
+      break;
+    case 16716015:
+      button="4";
+      buttonId = 16015;
+      break;
+    case 16726215:
+      button="5";
+      buttonId = 26215;
+      break;
+    case 16734885:
+      button="6";
+      buttonId = 34885;
+      break;
+    case 16728765:
+      button="7";
+      buttonId = 28765;
+      break;
+    case 16730805:
+      button="8";
+      buttonId = 30805;
+      break;
+    case 16732845:
+      button="9";
+      buttonId = 32845;
+      break;
+    default:
+      button="";
+      buttonId = 0;
+      break;
+  }
+}
+
+void separate(int x) {
+  int n1;
+  int n2;
+  int n3;
+  int n4;
+  int n5;
+  int n6;
+  n6 = x % 10;
+  n5 = floor(x / 10) % 10;
+  n4 = floor(x / 100) % 10;
+  n3 = floor(x / 1000) % 10;
+  n2 = floor(x / 10000) % 10;
+  n1 = floor(x / 100000) % 10;
+  int nums[6] = {n1,n2,n3,n4,n5,n6};
+}
+
+void p0() {
+  digitalWrite(m21, HIGH);
+  digitalWrite(m31, HIGH);
+  digitalWrite(m41, HIGH);
+  delay(100);
+  digitalWrite(m21, LOW);
+  digitalWrite(m31, LOW);
+  digitalWrite(m41, LOW);
+
+  digitalWrite(m22, HIGH);
+  digitalWrite(m32, HIGH);
+  digitalWrite(m42, HIGH);
+  delay(100);
+  digitalWrite(m22, LOW);
+  digitalWrite(m32, LOW);
+  digitalWrite(m42, LOW);
+
+  digitalWrite(m23, HIGH);
+  digitalWrite(m33, HIGH);
+  digitalWrite(m43, HIGH);
+  delay(100);
+  digitalWrite(m23, LOW);
+  digitalWrite(m33, LOW);
+  digitalWrite(m43, LOW);
+
+  digitalWrite(m24, HIGH);
+  digitalWrite(m34, HIGH);
+  digitalWrite(m44, HIGH);
+  delay(100);
+  digitalWrite(m24, LOW);
+  digitalWrite(m34, LOW);
+  digitalWrite(m44, LOW);
+
+  digitalWrite(m25, HIGH);
+  digitalWrite(m35, HIGH);
+  digitalWrite(m45, HIGH);
+  delay(100);
+  digitalWrite(m25, LOW);
+  digitalWrite(m35, LOW);
+  digitalWrite(m45, LOW);
+}
+
+void p1() {
+  digitalWrite(m11, HIGH);
+  delay(100);
+  digitalWrite(m11, LOW);
+
+  digitalWrite(m12, HIGH);
+  digitalWrite(m21, HIGH);
+  digitalWrite(m22, HIGH);
+  delay(100);
+  digitalWrite(m12, LOW);
+  digitalWrite(m21, LOW);
+  digitalWrite(m22, LOW);
+
+  digitalWrite(m23, HIGH);
+  digitalWrite(m32, HIGH);
+  digitalWrite(m33, HIGH);
+  delay(100);
+  digitalWrite(m23, LOW);
+  digitalWrite(m32, LOW);
+  digitalWrite(m33, LOW);
+
+  digitalWrite(m34, HIGH);
+  digitalWrite(m43, HIGH);
+  digitalWrite(m44, HIGH);
+  delay(100);
+  digitalWrite(m34, LOW);
+  digitalWrite(m43, LOW);
+  digitalWrite(m44, LOW);
+
+  digitalWrite(m45, HIGH);
+  digitalWrite(m54, HIGH);
+  digitalWrite(m55, HIGH);
+  delay(100);
+  digitalWrite(m45, LOW);
+  digitalWrite(m54, LOW);
+  digitalWrite(m55, LOW);
+}
+
+void p2() {
+  digitalWrite(m12, HIGH);
+  digitalWrite(m13, HIGH);
+  digitalWrite(m14, HIGH);
+  delay(100);
+  digitalWrite(m12, LOW);
+  digitalWrite(m13, LOW);
+  digitalWrite(m14, LOW);
+
+  digitalWrite(m22, HIGH);
+  digitalWrite(m23, HIGH);
+  digitalWrite(m24, HIGH);
+  delay(100);
+  digitalWrite(m22, LOW);
+  digitalWrite(m23, LOW);
+  digitalWrite(m24, LOW);
+
+  digitalWrite(m32, HIGH);
+  digitalWrite(m33, HIGH);
+  digitalWrite(m34, HIGH);
+  delay(100);
+  digitalWrite(m32, LOW);
+  digitalWrite(m33, LOW);
+  digitalWrite(m34, LOW);
+
+  digitalWrite(m42, HIGH);
+  digitalWrite(m43, HIGH);
+  digitalWrite(m44, HIGH);
+  delay(100);
+  digitalWrite(m42, LOW);
+  digitalWrite(m43, LOW);
+  digitalWrite(m44, LOW);
+
+  digitalWrite(m52, HIGH);
+  digitalWrite(m53, HIGH);
+  digitalWrite(m54, HIGH);
+  delay(100);
+  digitalWrite(m52, LOW);
+  digitalWrite(m53, LOW);
+  digitalWrite(m54, LOW);
+}
+
+void p3() {
+  digitalWrite(m15, HIGH);
+  delay(100);
+  digitalWrite(m15, LOW);
+
+  digitalWrite(m14, HIGH);
+  digitalWrite(m24, HIGH);
+  digitalWrite(m25, HIGH);
+  delay(100);
+  digitalWrite(m14, LOW);
+  digitalWrite(m24, LOW);
+  digitalWrite(m25, LOW);
+
+  digitalWrite(m23, HIGH);
+  digitalWrite(m34, HIGH);
+  digitalWrite(m33, HIGH);
+  delay(100);
+  digitalWrite(m23, LOW);
+  digitalWrite(m34, LOW);
+  digitalWrite(m33, LOW);
+
+  digitalWrite(m32, HIGH);
+  digitalWrite(m43, HIGH);
+  digitalWrite(m42, HIGH);
+  delay(100);
+  digitalWrite(m32, LOW);
+  digitalWrite(m43, LOW);
+  digitalWrite(m42, LOW);
+
+  digitalWrite(m41, HIGH);
+  digitalWrite(m52, HIGH);
+  digitalWrite(m51, HIGH);
+  delay(100);
+  digitalWrite(m41, LOW);
+  digitalWrite(m52, LOW);
+  digitalWrite(m51, LOW);
+}
+
+void p4() {
+  digitalWrite(m25, HIGH);
+  digitalWrite(m35, HIGH);
+  digitalWrite(m45, HIGH);
+  delay(100);
+  digitalWrite(m25, LOW);
+  digitalWrite(m35, LOW);
+  digitalWrite(m45, LOW);
+
+  digitalWrite(m24, HIGH);
+  digitalWrite(m34, HIGH);
+  digitalWrite(m44, HIGH);
+  delay(100);
+  digitalWrite(m24, LOW);
+  digitalWrite(m34, LOW);
+  digitalWrite(m44, LOW);
+
+  digitalWrite(m23, HIGH);
+  digitalWrite(m33, HIGH);
+  digitalWrite(m43, HIGH);
+  delay(100);
+  digitalWrite(m23, LOW);
+  digitalWrite(m33, LOW);
+  digitalWrite(m43, LOW);
+
+  digitalWrite(m22, HIGH);
+  digitalWrite(m32, HIGH);
+  digitalWrite(m42, HIGH);
+  delay(100);
+  digitalWrite(m22, LOW);
+  digitalWrite(m32, LOW);
+  digitalWrite(m42, LOW);
+
+  digitalWrite(m21, HIGH);
+  digitalWrite(m31, HIGH);
+  digitalWrite(m41, HIGH);
+  delay(100);
+  digitalWrite(m21, LOW);
+  digitalWrite(m31, LOW);
+  digitalWrite(m41, LOW);
+}
+
+void p5() {
+  digitalWrite(m55, HIGH);
+  delay(100);
+  digitalWrite(m55, LOW);
+
+  digitalWrite(m44, HIGH);
+  digitalWrite(m45, HIGH);
+  digitalWrite(m54, HIGH);
+  delay(100);
+  digitalWrite(m44, LOW);
+  digitalWrite(m45, LOW);
+  digitalWrite(m54, LOW);
+
+  digitalWrite(m33, HIGH);
+  digitalWrite(m34, HIGH);
+  digitalWrite(m43, HIGH);
+  delay(100);
+  digitalWrite(m33, LOW);
+  digitalWrite(m34, LOW);
+  digitalWrite(m43, LOW);
+
+  digitalWrite(m22, HIGH);
+  digitalWrite(m23, HIGH);
+  digitalWrite(m32, HIGH);
+  delay(100);
+  digitalWrite(m22, LOW);
+  digitalWrite(m23, LOW);
+  digitalWrite(m32, LOW);
+
+  digitalWrite(m11, HIGH);
+  digitalWrite(m12, HIGH);
+  digitalWrite(m21, HIGH);
+  delay(100);
+  digitalWrite(m11, LOW);
+  digitalWrite(m12, LOW);
+  digitalWrite(m21, LOW);
+}
+
+void p6() {
+  digitalWrite(m52, HIGH);
+  digitalWrite(m53, HIGH);
+  digitalWrite(m54, HIGH);
+  delay(100);
+  digitalWrite(m52, LOW);
+  digitalWrite(m53, LOW);
+  digitalWrite(m54, LOW);
+
+  digitalWrite(m42, HIGH);
+  digitalWrite(m43, HIGH);
+  digitalWrite(m44, HIGH);
+  delay(100);
+  digitalWrite(m42, LOW);
+  digitalWrite(m43, LOW);
+  digitalWrite(m44, LOW);
+
+  digitalWrite(m32, HIGH);
+  digitalWrite(m33, HIGH);
+  digitalWrite(m34, HIGH);
+  delay(100);
+  digitalWrite(m32, LOW);
+  digitalWrite(m33, LOW);
+  digitalWrite(m34, LOW);
+
+  digitalWrite(m22, HIGH);
+  digitalWrite(m23, HIGH);
+  digitalWrite(m24, HIGH);
+  delay(100);
+  digitalWrite(m22, LOW);
+  digitalWrite(m23, LOW);
+  digitalWrite(m24, LOW);
+
+  digitalWrite(m12, HIGH);
+  digitalWrite(m13, HIGH);
+  digitalWrite(m14, HIGH);
+  delay(100);
+  digitalWrite(m12, LOW);
+  digitalWrite(m13, LOW);
+  digitalWrite(m14, LOW);
+}
+
+void p7() {
+  digitalWrite(m51, HIGH);
+  delay(100);
+  digitalWrite(m51, LOW);
+
+  digitalWrite(m41, HIGH);
+  digitalWrite(m42, HIGH);
+  digitalWrite(m52, HIGH);
+  delay(100);
+  digitalWrite(m41, LOW);
+  digitalWrite(m42, LOW);
+  digitalWrite(m52, LOW);
+
+  digitalWrite(m32, HIGH);
+  digitalWrite(m43, HIGH);
+  digitalWrite(m33, HIGH);
+  delay(100);
+  digitalWrite(m32, LOW);
+  digitalWrite(m43, LOW);
+  digitalWrite(m33, LOW);
+
+  digitalWrite(m23, HIGH);
+  digitalWrite(m34, HIGH);
+  digitalWrite(m24, HIGH);
+  delay(100);
+  digitalWrite(m23, LOW);
+  digitalWrite(m34, LOW);
+  digitalWrite(m24, LOW);
+
+  digitalWrite(m14, HIGH);
+  digitalWrite(m25, HIGH);
+  digitalWrite(m15, HIGH);
+  delay(100);
+  digitalWrite(m14, LOW);
+  digitalWrite(m25, LOW);
+  digitalWrite(m15, LOW);
+}
+
+void patternPicker(int x) {
+  separate(x)
+  for (int i = 1; i < 6; i++) {
+    if (nums[i] = 0) {
+      p0();
+    } else if (nums[i] = 1) {
+      p1();
+    } else if (nums[i] = 2) {
+      p2();
+    } else if (nums[i] = 3) {
+      p3();
+    } else if (nums[i] = 4) {
+      p4();
+    } else if (nums[i] = 5) {
+      p5();
+    } else if (nums[i] = 6) {
+      p6();
+    } else if (nums[i] = 7) {
+      p7();
+    }
+  }
+}
+
+void loop() {
+  if (irrecv.decode(&results)) {
+    irrecv.resume();
+  }
+
+  whatButton(results.value);
+  /*if (continuing == true) {
+    whatButton(lastButton);
+  }
+  else {
+    lastButton = results.value;
+  }
+  delay(100); */
+  if ((someNum % 1000) == 0){
+    if (buttonId != 0){
+      Serial.println(button);
+      Serial.println(buttonId);
+      Serial.println(convertToOct(buttonId));
+      Serial.println("");
+      patternPicker(buttonVal);
+    }
+  }
+  someNum = someNum + 1;
+}


imported required libraries, syntax adaptions

--- IrrigationController.ino
+++ IrrigationController.ino
@@ -6,13 +6,13 @@
  * @version 4
  */

-#include <TimerOne.h>                   // https://github.com/PaulStoffregen/TimerOne
 #include <Streaming.h>                  // http://arduiniana.org/libraries/streaming/
 #include <LED.h>                        // http://playground.arduino.cc/Code/LED
 #include <DS3232RTC.h>                  // http://github.com/JChristensen/DS3232RTC
 #include <Wire.h>                       // http://arduino.cc/en/Reference/Wire
-#include <TimeAlarms.h>                 // https://www.pjrc.com/teensy/td_libs_TimeAlarms.html
-#include <Time.h>                       // http://www.arduino.cc/playground/Code/Time
+#include <TimeAlarms.h>                 // https://github.com/PaulStoffregen/TimeAlarms
+#include <TimerOne.h>                   // https://github.com/PaulStoffregen/TimerOne
+#include <Time.h>                       // https://github.com/PaulStoffregen/Time
 #include <Sensirion.h>                  // http://playground.arduino.cc/Code/Sensirion
 #include <Relay.h>                      // Relay library
 #include <FlowMeter.h>                  // Flow Meter library
@@ -99,7 +99,7 @@
   /* only process once per tick */
   if (tickHistory != tickCount) {

-    Alarm.serviceAlarms();                   // run the irrigation scheduler
+    Alarm.delay(0);                          // run the irrigation scheduler (odd way of saying: TimeAlarms::serviceAlarms())
     DEBUG_LED.toggle();                      // show a pulse, indicating that we might still be alive

     Meter.tick(tickPeriod);                  // update flow meter calculations


Fixed bug when decreasing freq

Fixed bug when decreasing freq

--- DigitalVFO.ino
+++ DigitalVFO.ino
@@ -765,11 +765,11 @@
   dump_eeprom();
 #endif

+  // get going
+  show_main_screen();
+
   // we sometimes see random events on powerup, flush them here
   flush_events();
-
-  // get going
-  show_main_screen();
 }

 void show_main_screen(void)
@@ -951,10 +951,14 @@
         VfoFrequency -= offset2bump[VfoSelectDigit];
         if (VfoFrequency < MIN_FREQ)
           VfoFrequency = MIN_FREQ;
-        break;
+        if (VfoFrequency > MAX_FREQ)
+          VfoFrequency = MAX_FREQ;
+       break;
       case vfo_RRight:
         Serial.println("vfo_RRight");
         VfoFrequency += offset2bump[VfoSelectDigit];
+        if (VfoFrequency < MIN_FREQ)
+          VfoFrequency = MIN_FREQ;
         if (VfoFrequency > MAX_FREQ)
           VfoFrequency = MAX_FREQ;
         break;


Improved dim function

Improved dim function

--- arduino/alarm/alarm.ino
+++ arduino/alarm/alarm.ino
@@ -1,15 +1,16 @@
 const int gate_pin = 5;
 String light_state;
+int light_brightness;

 void serialEvent();
-boolean dim(unsigned long, boolean);
+boolean dim(long);
 void alarm(unsigned long);
 void blink(unsigned long);

 void alarm(unsigned long duration) {
   unsigned long startMillis = millis();
   unsigned long dimDuration = 2ul * duration / 3ul;
-  if (dim(dimDuration, true)) {
+  if (dim(dimDuration)) {
     light_state = "alarm";
     while (millis() - startMillis < duration) {
       loop();
@@ -22,7 +23,7 @@
 }

 void blink(unsigned long interval) {
-  unsigned int previousMillis;
+  unsigned long previousMillis;
   light_state = "blink";
   while(light_state == "blink") {
     digitalWrite(gate_pin, LOW);
@@ -39,21 +40,27 @@
   }
 }

-// Returns false if was interrupted, otherwise returns true
-boolean dim(unsigned long duration, boolean brighten) {
-  double lnb = log(pow(256.0, 1.0 / (float) duration));
-  for (int i = 1; i < 256; i++) {
+boolean dim(long duration) {
+  boolean brighten;
+  light_state = "dimming";
+  if (duration > 0) {
+    brighten = true;
+  } else {
+    brighten = false;
+    duration = -(duration);
+  }
+  for (double i = 1; i < 256; i++) {
     if (light_state != "dimming") {
       return false;
     }
     unsigned long interval;
     if (brighten) {
       analogWrite(gate_pin, i);
-      interval = (unsigned long) round(log(((float) i + 1) / (float) i) / lnb);
+      interval = (unsigned long) round(duration * (sqrt(i / 254) - sqrt((i - 1) / 254)));
     } else {
-      int x = 256 - i;
-      analogWrite(gate_pin, x - 1);
-      interval = (unsigned long) round(log((float) x / ((float) x - 1)) / lnb);
+      double x = 256 - i;
+      analogWrite(gate_pin, (int) x - 1);
+      interval = (unsigned long) round(duration * (sqrt(x / 254) - sqrt((x - 1) / 254)));
     }
     unsigned long previousMillis = millis();
     if (i < 255) {
@@ -67,29 +74,20 @@
   } else {
     light_state = "off";
   }
+  Serial.println(light_state);
   return true;
 }

 void serialEvent() {
   String serial_data = Serial.readString();
+  long serial_num = serial_data.toInt();
   Serial.flush();
   if (serial_data == "i") {
     Serial.println(light_state);
-  } else if (light_state == "alarm" && serial_data == "o") {
-    light_state = "on";
-    Serial.println(light_state);
-  } else if (light_state != "on" && serial_data == "o") {
-    light_state = "dimming";
-    dim(500, true);
-    Serial.println(light_state);
-  } else if (serial_data == "o") {
-    light_state = "dimming";
-    dim(500, false);
-    Serial.println(light_state);
-  } else if (serial_data == "a" && light_state == "off") {
-    light_state = "dimming";
-    //alarm(1800000);
-    alarm(1800000);
+  } else if (serial_num >= 300000l) {
+    alarm(serial_num);
+  } else if (serial_num != 0){
+    dim(serial_num);
   }
 }

@@ -97,6 +95,7 @@
   pinMode(gate_pin, OUTPUT);
   analogWrite(gate_pin, 0);
   light_state = "off";
+  light_brightness = 0;
   Serial.begin(9600);
 }


changed delay

changed delay

--- MoBiFloC/SDP6x/SDP6x.ino
+++ MoBiFloC/SDP6x/SDP6x.ino
@@ -14,7 +14,6 @@

 void setup()
 {
-  Serial.print("Starting");
   Wire.begin();
   Serial.begin(9600);
   difPressure = 0.0;
@@ -22,12 +21,12 @@

 void loop()
 {
-  //Serial.print("Pressure Differential (Pa): ");
+  Serial.print("Pressure Differential (Pa): ");
   difPressure = SDP6x.GetPressureDiff();
   //Serial.print("Reading: ");
   Serial.print(difPressure);
   Serial.print("\n");
-  delay(3);
+  delay(5);
 }


upd example multireader

upd example multireader

- comments
- reader info after init
- serial speed

--- examples/ReadUidMultiReader/ReadUidMultiReader.ino
+++ examples/ReadUidMultiReader/ReadUidMultiReader.ino
@@ -20,8 +20,8 @@
  * Signal      Pin          Pin           Pin       Pin        Pin              Pin
  * -----------------------------------------------------------------------------------------
  * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
- * SPI SS 1    SDA(SS)      10            53        D10        10               10
- * SPI SS 2    SDA(SS)      2             53        D10        10               10
+ * SPI SS 1    SDA(SS)      ** custom, take a unused pin, only HIGH/LOW required **
+ * SPI SS 2    SDA(SS)      ** custom, take a unused pin, only HIGH/LOW required **
  * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
  * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
  * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
@@ -31,9 +31,9 @@
 #include <SPI.h>
 #include <MFRC522.h>

-#define RST_PIN        10           // Configurable, see typical pin layout above
-#define SS_1_PIN        5          // Configurable, see typical pin layout above
-#define SS_2_PIN        3          // Configurable, see typical pin layout above
+#define RST_PIN         9          // Configurable, see typical pin layout above
+#define SS_1_PIN        10         // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
+#define SS_2_PIN        8          // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1

 #define NR_OF_READERS   2

@@ -46,13 +46,17 @@
  */
 void setup() {

-  Serial.begin(115200); // Initialize serial communications with the PC
+  Serial.begin(9600); // Initialize serial communications with the PC
   while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

   SPI.begin();        // Init SPI bus

   for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
     mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
+    Serial.print(F("Reader "));
+    Serial.print(reader);
+    Serial.print(F(": "));
+    mfrc522[reader].PCD_DumpVersionToSerial();
   }
 }

@@ -61,14 +65,14 @@
  */
 void loop() {

-    for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
+  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
     // Look for new cards

     if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
-      Serial.print(F("Reader: "));
+      Serial.print(F("Reader "));
       Serial.print(reader);
       // Show some details of the PICC (that is: the tag/card)
-      Serial.print(F(" Card UID:"));
+      Serial.print(F(": Card UID:"));
       dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
       Serial.println();
       Serial.print(F("PICC type: "));


Display command queued to each node

Display command queued to each node

I am using git for Windows. Created a tag against this commit using "git
bash". I was unable to commit my changes using "git bash"

--- examples/RF12/RF12demo/RF12demo.ino
+++ examples/RF12/RF12demo/RF12demo.ino
@@ -911,7 +911,7 @@
     if (nodes[i] != 0xFF)
       nodes[i] = 0;   // No commands queued for node.
   }
-  nodesShow();
+//  nodesShow();

   if (rf12_config())
     initialize();
@@ -940,12 +940,16 @@
   else // Lose flag nibble to get frequency high order
     frequency = ((frequency & 0x0F)  << 8) + (eeprom_read_byte(RF12_EEPROM_ADDR + 3));
 }
+/// Display stored nodes and show the command queued for each node
+/// the command queue is not preserved through a restart of RF12Demo
 void nodesShow() {
   Serial.println("Stored Nodes");
   for (byte i = 1; i < 31; i++) {
     if (nodes[i] != 0xFF) {
       Serial.print(i);
-      Serial.print(" ");
+      Serial.print("(");
+      Serial.print(nodes[i]);
+      Serial.print(") ");
     }
   }
   Serial.println();


Update MultipleSteppers.ino

Update MultipleSteppers.ino

--- examples/MultipleSteppers/MultipleSteppers.ino
+++ examples/MultipleSteppers/MultipleSteppers.ino
@@ -29,19 +29,13 @@
     .setAcceleration(200000); // steps/s^2

   motor_2
-<<<<<<< HEAD
     .setMaxSpeed(50000)       // steps/s
     .setAcceleration(200000); // steps/s^2
-=======
-    .SetMaxSpeed(50000)       // steps/s
-    .SetAcceleration(200000); // steps/s^2
->>>>>>> origin/master
-
   motor_3
     .setPullInSpeed(300)      // steps/s
     .setMaxSpeed(10000)       // steps/s
     .setAcceleration(50000)   // steps/s^2
-	.setStepPinPolarity(LOW); // driver expects active low pulses
+    .setStepPinPolarity(LOW); // driver expects active low pulses
 }

 void loop()
@@ -67,13 +61,8 @@
   controller.move(motor_1, motor_2);

   // now move motor_2 together with motor_3
-<<<<<<< HEAD
   motor_2.setTargetRel(300);
   motor_3.setTargetRel(-800);
-=======
-  motor_2.SetTargetRel(spr/3);
-  motor_3.SetTargetRel(-spr*2);
->>>>>>> origin/master
   controller.move(motor_2, motor_3);

   // move motor_1 and motor_3 back to their start positions


test program for the yun

test program for the yun

--- yun/yun.ino
+++ yun/yun.ino
@@ -1,9 +1,11 @@
 void setup() {
-  // put your setup code here, to run once:
-
+  pinMode(13,OUTPUT);
 }

 void loop() {
   // put your main code here, to run repeatedly:
-
+  digitalWrite(13, HIGH);
+  delay(1000);
+  digitalWrite(13, LOW);
+  delay(1000);
 }


saving

saving

--- examples/BoardWithWifiDebug/BoardWithWifiDebug.ino
+++ examples/BoardWithWifiDebug/BoardWithWifiDebug.ino
@@ -1,44 +1,87 @@
 #include <DSPI.h>
-#include <EEPROM.h>
-#include <OpenBCI_32bit_Library.h>
-#include <OpenBCI_32bit_Library_Definitions.h>

 int packetSendIntervalMs = 50; // 50 ms
 unsigned long lastPacketSent = millis();
+const int packetSize = 32;
+uint8_t buf[packetSize];
+uint8_t WIFI_SS = 18;

+DSPI0 spi;  // use DSPI library
+
+boolean streaming = false;

 void setup() {

-  // Notify the board we want to use accel data
-  // board.wifi.rx = false;
-  board.iWifi.tx = true;

-  // Bring up the OpenBCI Board
-  board.begin();
-  // Change the sample rate
-  // board.curSampleRate = board.SAMPLE_RATE_500;
+  buf[1] = (uint8_t)'A';
+  buf[2] = (uint8_t)'J';
+  buf[3] = (uint8_t)' ';
+  buf[4] = (uint8_t)'K';
+  buf[5] = (uint8_t)'E';
+  buf[6] = (uint8_t)'L';
+  buf[7] = (uint8_t)'L';
+  buf[8] = (uint8_t)'E';
+  buf[9] = (uint8_t)'R';

-  board.streaming = true;
+  pinMode(WIFI_SS,OUTPUT); digitalWrite(WIFI_SS,HIGH);
+
+  spi.begin();
+  spi.setSpeed(20000000);  // use 4MHz for ADS and LIS3DH
+  spi.setMode(DSPI_MODE0);  // default to SD card mode!
+
+  Serial0.begin(115200);
 }

 void loop() {
   if (millis() > lastPacketSent + packetSendIntervalMs) {
-    board.sendChannelData();
+    if (streaming) {
+      flushbufToSpi();
+    }
     lastPacketSent = millis();
   }

   // Check serial 0 for new data
-  if (board.hasDataSerial0()) {
+  if (Serial0.available()) {
     // Read one char from the serial 0 port
-    char newChar = board.getCharSerial0();
-    //
-    if (Serial0) {
-       Serial0.print("Recieved char from serial0 ");
-       Serial0.println(newChar);
+    char newChar = Serial0.read();
+
+    switch (newChar) {
+      case 'b':
+        streaming = true;
+        Serial0.println("starting stream");
+        break;
+      case 's':
+        streaming = true;
+        Serial0.println("stopping stream");
+        break;
+      case '0':
+        digitalWrite(WIFI_SS,LOW);
+        Serial0.println("forced pin 13 to low");
+        break;
+      case '1':
+        digitalWrite(WIFI_SS,HIGH);
+        Serial0.println("forced pin 13 to high");
+        break;
+      default:
+        Serial0.print("Sup? Dis char i don't get... ");
+        Serial0.println(newChar);
+        break;
     }
-
-    // Send to the board library
-    board.processChar(newChar);
   }
 }
+
+void flushbufToSpi() {
+  uint8_t i = 0;
+  uint8_t len = packetSize;
+  digitalWrite(WIFI_SS,LOW);
+  spi.transfer(0x02);
+  spi.transfer(0x00);
+  while(len-- && i < packetSize) {
+      spi.transfer(buf[i++]);
+  }
+  while(i++ < packetSize) {
+      spi.transfer(0); // Pad with zeros till 32
+  }
+  digitalWrite(WIFI_SS,HIGH);
+}


Clean code

Clean code

--- SpeakersControl.ino
+++ SpeakersControl.ino
@@ -26,6 +26,7 @@
 byte system_status = 1;
 byte error_count = 0;
 byte source = 0;
+byte last_led_color = 255;
 bool power_on = true;
 /*
  * 0 -> normal no errors
@@ -67,37 +68,36 @@

 }

+void setInfoColor(byte i)
+{
+  if (last_led_color == i) return;
+  LedRGB colors[8] = {
+    {0, 0, 0},       // 0 -> if "0" and powerOff
+    {0, 0, 255},     // 1 -> Init in progress
+    {255, 140, 0},   // 2 -> WiFi problem
+    {255, 0, 0},     // 3 -> big error
+    {255, 255, 255}, // 4 white, reserved for future idiea ;)
+    {45, 255, 215},  // 5 -> if "0" and powerOn and source "0" (PC)
+    {25, 255, 80},   // 6 -> if "0" and powerOn and source "1" (RPi3/Phone)
+    {255, 0, 255}    // 7 -> if powerOff and error (for blinking)
+  };
+  ledSupport.setColor(LED_PIN_MAIN, 0, colors[i]);
+  last_led_color = i;
+}
+
 void setInfoLed()
 {
   if (!power_on and system_status==0) {
-    ledSupport.setColor(LED_PIN_MAIN, 0, {0, 0, 0});
+    setInfoColor(0);
     return;
   }
   if (not (blink or power_on)) {
-    ledSupport.setColor(LED_PIN_MAIN, 0, {255, 0, 255});
-  } else {
-    switch (system_status) {
-      case 0:
-        if (source == 0) {
-          ledSupport.setColor(LED_PIN_MAIN, 0, {45, 255, 215});
-        } else {
-          ledSupport.setColor(LED_PIN_MAIN, 0, {25, 255, 80});
-        }
-        break;
-      case 1:
-        ledSupport.setColor(LED_PIN_MAIN, 0, {0, 0, 255});
-        break;
-      case 2:
-        ledSupport.setColor(LED_PIN_MAIN, 0, {255, 140, 0});
-        break;
-      case 3:
-        ledSupport.setColor(LED_PIN_MAIN, 0, {255, 0, 0});
-        break;
-      default:
-        ledSupport.setColor(LED_PIN_MAIN, 0, {255, 255, 255});
-    }
-  }
-
+    setInfoColor(7);
+  } else if (system_status == 0) {
+    setInfoColor(5 + source);
+  } else if ( system_status < 5){
+    setInfoColor(system_status);
+  }
 }

 void powerOff()
@@ -125,16 +125,14 @@
 void setMainColor(LedRGB rgb)
 {
   setLedColor(LED_PIN_MAIN, 0, rgb);
+  last_led_color = 255;
   // restet wachdog,: give time to see message :)
   timer0_write(ESP.getCycleCount() + WACHDOG_INTERVAL);
 }

 void setBackColor(LedRGB rgb)
 {
-  Serial.println("Back Light");
-  //ledSupport.setColor(LED_PIN_MAIN, 0, {255, 140, 0});
   ledSupport.setColor(LED_PIN_MAIN, 1, rgb);
-  //setLedColor(LED_PIN_MAIN, 1, rgb);
 }

 void setLedColor(uint16_t pin, uint8_t id, LedRGB rgb)
@@ -152,7 +150,7 @@
   Serial.println("Init LedSupport");
   ledSupport.init();
   ledSupport.addLedPin(LED_PIN_MAIN, 2);
-  Serial.println("Set Init Collor");
+
   ledSupport.setColor(LED_PIN_MAIN, 1, {255, 140, 0});
   ledSupport.setDimmer(20, LED_PIN_MAIN, 0);
   setInfoLed();
@@ -180,7 +178,26 @@
   WiFi.config(ip, gateway, subnet);
 }

-void setup(void){
+void initWachdog()
+{
+  Serial.println("Init Wachdog");
+  noInterrupts();
+  timer0_isr_init();
+  timer0_attachInterrupt(wachdogLed);
+  timer0_write(ESP.getCycleCount() + WACHDOG_INTERVAL);
+  interrupts();
+}
+
+void initRichServer()
+{
+  Serial.println("Init RichServer");
+  serverRich.setMainColorHandler = setMainColor;
+  serverRich.setBackColorHandler = setBackColor;
+  serverRich.getWeatherHandler = getWeather;
+}
+
+void setup(void)
+{
   system_update_cpu_freq(SYS_CPU_160MHZ);
   pinMode(SRD_SRC_PIN, OUTPUT);
   pinMode(SRD_POWER_PIN, OUTPUT);
@@ -192,35 +209,24 @@
   Serial.println("Zurek ESP starting!");

   initWiFi();
-
   initLed();
-
-  Serial.println("Init RichServer");
-  serverRich.setMainColorHandler = setMainColor;
-  serverRich.setBackColorHandler = setBackColor;
-  serverRich.getWeatherHandler = getWeather;
+  initRichServer();
+

   if (MDNS.begin("esp8266")) {
     Serial.println("MDNS responder started");
   }

+  initWachdog();
+  system_status = 0;
+
+  setInfoLed();
   Serial.println("Setup End");
-  ledSupport.setColor(LED_PIN_MAIN, 0, {25, 107, 100});
-
-  pinMode(0, INPUT);
-  //attachInterrupt(0, green, CHANGE);
-  //timer0_attachInterrupt(green);
-  noInterrupts();
-  timer0_isr_init();
-  timer0_attachInterrupt(wachdogLed);
-  timer0_write(ESP.getCycleCount() + WACHDOG_INTERVAL);
-  interrupts();
-  system_status = 0;
-  setInfoLed();
-}
-
-void loop(void){
+}
+
+void loop(void)
+{
   serverRich.handleClient();
 }


add Buzzer

add Buzzer

--- StandardFirmata.ino
+++ StandardFirmata.ino
@@ -449,6 +449,11 @@
               break;
           }
           break;
+        case 7: //Buzzer f004070b131805f7
+          pinMode(argv[1], OUTPUT);
+          tone(argv[1], (String(argv[2], HEX)).toInt() * 100 +
+               (String(argv[3], HEX)).toInt(), argv[4] * 100);
+          break;
       }
       break;
     case I2C_REQUEST:


Simple sketch to blink neopixels for halloween

--- Halloween/Halloween.ino
+++ Halloween/Halloween.ino
@@ -10,8 +10,11 @@
 // On a Trinket or Gemma we suggest changing this to 1
 #define PIN            6

+#define STRANDLENGTH 7
+#define NUMSTRANDS 4
+
 // How many NeoPixels are attached to the Arduino?
-#define NUMPIXELS      28
+#define NUMPIXELS STRANDLENGTH * NUMSTRANDS

 // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
 // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
@@ -51,15 +54,121 @@
   pixels.show();
 }

+float hue = 0;
+const float hueOffset = 0.01f;
+float phase = 0;
+const float phaseOffset = 1.0f / 167;
+
+Color3F GenerateHue(float hue)
+{
+  float u = cos(hue * 2 * M_PI);
+  float w = sin(hue * 2 * M_PI);
+
+  Color3F ret;
+  float s = 255;
+
+  float third = 1.0f / 3;
+  ret.R = (cos(hue * 2 * M_PI) / 2 + 0.5f) * s;
+  ret.G = (cos((hue + third) * 2 * M_PI) / 2 + 0.5f) * s;
+  ret.B = (cos((hue + 2 * third) * 2 * M_PI) / 2 + 0.5f) * s;
+
+  return ret;
+}
+
+void patternHue()
+{
+  for (int j = 0; j < 700; j++)
+  {
+    for(int i = 0; i < NUMPIXELS; i++)
+    {
+      Color3F c = GenerateHue(hue + ((float)i) / NUMPIXELS);
+
+      float brightness = cos((phase + 1.0f * i / NUMPIXELS) * 2 * M_PI) / 2 + 0.5f;
+      pixels.setPixelColor(i, pixels.Color(c.R * brightness, c.G * brightness, c.B * brightness));
+
+      pixels.show(); // This sends the updated pixel color to the hardware.
+    }
+
+    delay(1); // Delay for a period of time (in milliseconds).
+
+    hue = hue + hueOffset >= 1 ? 0 : hue + hueOffset;
+    phase = phase + phaseOffset >= 1 ? 0 : phase + phaseOffset;
+  }
+}
+
+void patternBlink()
+{
+  for (int i = 0; i < 7  ; i++)
+  {
+    setPixels(yellow, 0, NUMPIXELS);
+    delay(1000);
+    setPixels(black, 0, NUMPIXELS);
+    delay(100);
+    setPixels(red, 0, NUMPIXELS);
+    delay(100);
+    setPixels(black, 0, NUMPIXELS);
+    delay(100);
+  }
+}
+
+void patternFlicker()
+{
+  for (int i = 0; i < 7; i++)
+  {
+    setPixels(yellow, 0, NUMPIXELS);
+    delay(2000 + random(10) * 1000);
+
+    setPixels(black, 0, NUMPIXELS);
+    delay(50);
+    setPixels(yellow, 0, NUMPIXELS);
+    delay(100);
+    setPixels(black, 0, NUMPIXELS);
+    delay(50);
+  }
+}
+
+void patternParade()
+{
+  for (int i = 0; i < 10; i++)
+  {
+    for (int j = 0; j < NUMSTRANDS; j++)
+    {
+      setPixels(black, 0, NUMPIXELS);
+      setPixels(white, j * STRANDLENGTH, (j + 1) * STRANDLENGTH);
+      delay(200);
+    }
+  }
+}
+
+void patternParadeAndBack()
+{
+  for (int i = 0; i < 7; i++)
+  {
+    for (int j = 1; j < NUMSTRANDS; j++)
+    {
+      setPixels(black, 0, NUMPIXELS);
+      setPixels(white, j * STRANDLENGTH, (j + 1) * STRANDLENGTH);
+      delay(200);
+    }
+
+    for (int j = NUMSTRANDS - 2; j >= 0; j--)
+    {
+      setPixels(black, 0, NUMPIXELS);
+      setPixels(white, j * STRANDLENGTH, (j + 1) * STRANDLENGTH);
+      delay(200);
+    }
+  }
+}
+
 void loop()
 {
-  setPixels(yellow, 0, NUMPIXELS);
-  delay(1000);
-  setPixels(black, 0, NUMPIXELS);
-  delay(100);
-  setPixels(red, 0, NUMPIXELS);
-  delay(100);
-  setPixels(black, 0, NUMPIXELS);
-  delay(100);
+  switch (random(0, 5))
+  {
+    case 0: patternBlink(); break;
+    case 1: patternFlicker(); break;
+    case 2: patternParade(); break;
+    case 3: patternParadeAndBack(); break;
+    case 4: patternHue(); break;
+  }
 }


Add servomotor

Add servomotor

--- script/core/arduino/robot/robot.ino
+++ script/core/arduino/robot/robot.ino
@@ -1,16 +1,54 @@
+#include <Servo.h>
+
 int mAvant = 5;
 int mArrier = 6;
-int angle = 9;
+int servoPin = 9;
+int feedbackPin = A0;
 int data = 0;
+
+Servo myservo;
+
+// Calibration values
+int minDegrees;
+int maxDegrees;
+int minFeedback;
+int maxFeedback;
+int tolerance = 2; // max feedback measurement error
+
+/*
+This function establishes the feedback values for 2 positions of the servo.
+With this information, we can interpolate feedback values for intermediate positions
+*/
+void calibrate(Servo servo, int analogPin, int minPos, int maxPos)
+{
+  // Move to the minimum position and record the feedback value
+  servo.write(minPos);
+  minDegrees = minPos;
+  delay(2000); // make sure it has time to get there and settle
+  minFeedback = analogRead(analogPin);
+  // Move to the maximum position and record the feedback value
+  servo.write(maxPos);
+  maxDegrees = maxPos;
+  delay(2000); // make sure it has time to get there and settle
+  maxFeedback = analogRead(analogPin);
+}

 void setup(){
   Serial.begin(9600);
-  pinMode(angle, OUTPUT);
-  analogWrite(angle, 0);
+  Serial.println("Moteur");
   pinMode(mAvant, OUTPUT);
   pinMode(mArrier, OUTPUT);
   digitalWrite(mAvant, HIGH);
   digitalWrite(mArrier, LOW);
+  Serial.println("Servo-moteur");
+  myservo.attach(servoPin);
+  calibrate(myservo, feedbackPin, 20, 160); // calibrate for the 20-160 degree range
+  Serial.begin(9600);
+  Serial.println("20 : " + minFeedback);
+  Serial.println("160 : " + maxFeedback);
+  myservo.write(90);
+  delay(2000);
+  Serial.println("90 : " + analogRead(feedbackPin));
   Serial.println("Go !");
 }

@@ -36,7 +74,7 @@
           delay(1);
         data = Serial.read();
         Serial.println(data);
-        analogWrite(angle, data);
+        myservo.write(data);
         break;
       default:
         Serial.println('Error');


Engine room comms

Engine room comms

--- engine-room/engine_arduino/engine_arduino.ino
+++ engine-room/engine_arduino/engine_arduino.ino
@@ -158,6 +158,18 @@
     int row = getRow(index);
     int col = getCol(index);
     setColor(row, col, BLUE);  // Victory! Make everything blue.
+  }
+}
+
+void sendRedLightsMessage() {
+  if (USE_SERIAL) {
+    Serial.println(10);  // Send "Ahhhhhh!" audio signal.
+  }
+}
+
+void sendBadLightsMessage() {
+  if (USE_SERIAL) {
+    Serial.println(11);  // Send "I don't like the lights." audio signal.
   }
 }

@@ -174,8 +186,7 @@
       if (illuminationCount(row, col) > 1) {
         anyInvalid = true;
         setColor(row, col, RED);  // Conflicting lights.
-        // TODO(dbieber): Send message
-        // Serial.println(10);  // Send "Ahhhhhh!" audio signal.
+        sendRedLightsMessage();  // Send "Ahhhhhh!" audio signal.
       } else {
         setColor(row, col, GREEN);  // Light you've turned on directly.
       }
@@ -195,7 +206,14 @@
       }
     }
   }
+
   bool victory = !anyInvalid && !anyEmpty && !anyWallConstrainsViolated;
+
+  if (!anyEmpty && !victory) { // Board is full but incorrect.
+    sendBadLightsMessage();  // Send "I don't like the lights." audio signal.
+  }
+
+
   return victory;
 }

@@ -321,3 +339,13 @@
   delay(10);
 }

+//void loop() {
+//  bool victory = update();
+//  leds.write(colors, STRIP_LENGTH);
+//  delay(50);
+//  if (victory) {
+//    delay(500);
+//    setAllBlue();
+//  }
+//}
+


no TFT debug

no TFT debug

[ci skip]

--- library/examples/HardwareDemo/HardwareDemo.ino
+++ library/examples/HardwareDemo/HardwareDemo.ino
@@ -4,7 +4,7 @@
 #include <Adafruit_NeoPixel.h>
 #include <Dilbert.h>

-#define TFT_DEBUG
+/* #define TFT_DEBUG */

 Dilbert *badge;


new travis CI file

new travis CI file

--- examples/ESP8266WiFiList/ESP8266WiFiList.ino
+++ examples/ESP8266WiFiList/ESP8266WiFiList.ino
@@ -1,3 +1,4 @@
+#include "arduino.h"
 #include <ESP8266WiFi.h>
 #include <WiFiClient.h>
 #include <ESP8266WebServer.h>


Knock sensor

Knock sensor

--- examples/Knock/Knock.ino
+++ examples/Knock/Knock.ino
@@ -1,3 +1,4 @@
+
 /**
    Knock Sensor

@@ -15,13 +16,10 @@

 */

-#define LED_S_GREEN   13 // D7
-#define LED_S_RED     12 // D6
-#define LED_RGB_RED   15 // D8
-#define LED_RGB_GREEN 14 // D5
-#define LED_RGB_BLUE  10 // SD3
-#define SW1 2
-#define SW2 16
+// Include the Denbit library.
+#include <Denbit.h>
+// Initialize the denbit.
+Denbit denbit;

 // these constants won't change:
 const int knockSensor = A0; // the piezo is connected to analog pin 0
@@ -32,26 +30,17 @@
 int sensorReading = 0;      // variable to store the value read from the sensor pin
 int ledState = LOW;         // variable used to store the last LED status, to toggle the light

+
 void setup() {
-  Serial.begin(115200);       // use the serial port
-
-  pinMode(LED_S_GREEN, OUTPUT);
-  pinMode(LED_S_RED, OUTPUT);
-
-// RGB led
-  pinMode(LED_RGB_RED, OUTPUT);
-  pinMode(LED_RGB_GREEN, OUTPUT);
-  pinMode(LED_RGB_BLUE, OUTPUT);
-
-// Switches
-  pinMode(SW1, INPUT_PULLUP);
-  pinMode(SW2, INPUT_PULLUP);
+  // Inital the serial port to output sensor values.
+  Serial.begin(115200);
+
 }

 void loop() {
   // read the sensor and store it in the variable sensorReading:
   sensorReading = analogRead(knockSensor);
-  analogWrite(LED_S_RED, sensorReading);
+  analogWrite(DENBIT_RED, sensorReading);
   Serial.println(sensorReading);

@@ -60,7 +49,7 @@
     // toggle the status of the ledPin:
     ledState = !ledState;
     // update the LED pin itself:
-    digitalWrite(LED_S_GREEN, ledState);
+    digitalWrite(DENBIT_GREEN, ledState);
     // send the string "Knock!" back to the computer, followed by newline
     Serial.println("Knock!");
   }


Add heartbeat with LED

Add heartbeat with LED

--- WirelessTrigger.ino
+++ WirelessTrigger.ino
@@ -27,11 +27,18 @@
 const byte ackVal = 0b11110000;

 #if ROLE == ROLE_SENDER
+#define HEARTBEAT_THRESH_MILLIS 1000
+
 uint8_t triggerButtonPin = 2;
 uint8_t resetButtonPin = 3;

 Switch triggerButton = Switch(triggerButtonPin);
 Switch resetButton = Switch(resetButtonPin);
+
+uint8_t heartbeatLEDPin = 13;
+
+unsigned long lastHeartbeat = 0;
+bool isCommHealthy = false;

 #else
 #define TRIGGER_SERVO_ANGLE 90
@@ -62,7 +69,9 @@
     radio.startListening();
     radio.writeAckPayload(1, &ackVal, 1);

-#if ROLE == ROLE_RECEIVER
+#if ROLE == ROLE_SENDER
+    pinMode(heartbeatLEDPin, OUTPUT);
+#else
     actuationServo.attach(servoPin);
     actuationServo.write(RESET_SERVO_ANGLE);
 #endif
@@ -76,6 +85,7 @@
     if (radio.write(&val, 1)) {
         if (!radio.available()) {
             Serial.println("Empty recv!");
+            return 0;
         }
         else {
             radio.read(&recvByte, 1);
@@ -84,7 +94,22 @@
     }
     else {
         Serial.println("Unknown failure");
+        return 0;
     }
+
+    return recvByte;
+}
+
+void validateAck(byte ackResponse) {
+    if (ackResponse == ackVal)
+        isCommHealthy = true;
+    else {
+        isCommHealthy = false;
+        Serial.println("Bad ack received! This probably means that the connection is unstable.");
+    }
+
+    // We have validated that data was successfully sent; we can consider this a heartbeat.
+    lastHeartbeat = millis();
 }
 #endif

@@ -96,11 +121,17 @@

     // Require a long press to activate
     if (triggerButton.longPress()) {
-        sendByte(triggerVal);
+        validateAck(sendByte(triggerVal));
     }
     else if (resetButton.pushed()) {
-        sendByte(resetVal);
+        validateAck(sendByte(resetVal));
     }
+    else if (millis() - lastHeartbeat >= HEARTBEAT_THRESH_MILLIS) {
+        // Re-use ack byte for heartbeat
+        validateAck(sendByte(triggerVal));
+    }
+
+    digitalWrite(heartbeatLEDPin, isCommHealthy);
 #else
     if (radio.available()) {
         byte recvByte;
@@ -114,6 +145,10 @@
             Serial.println("RESET");
             actuationServo.write(RESET_SERVO_ANGLE);
         }
+        else if (recvByte == ackVal) {
+            // Heartbeat received. Just no-op.
+            Serial.println("Heartbeat byte received");
+        }
         else {
             Serial.print("Received bad signal ");
             Serial.println((int)recvByte);


speed up channel seek and band scan.

speed up channel seek and band scan.

--- src/rx5808-pro-diversity/rx5808-pro-diversity.ino
+++ src/rx5808-pro-diversity/rx5808-pro-diversity.ino
@@ -1055,8 +1055,8 @@
     // check if RSSI is stable after tune by checking the time
     uint16_t tune_time = millis()-time_of_tune;
     // module need >20ms to tune.
-    // 30 ms will to a 32 channel scan in 1 second.
-    #define MIN_TUNE_TIME 30
+    // 25 ms will to a 40 channel scan in 1 second.
+    #define MIN_TUNE_TIME 25
     if(tune_time < MIN_TUNE_TIME)
     {
         // wait until tune time is full filled
@@ -1142,7 +1142,6 @@
 rssi=rssiA;
 #endif

-
     // special case for RSSI setup
     if(state==STATE_RSSI_SETUP)
     { // RSSI setup


Fix paths to libraries Comment using serial port

--- Sensor/Photon/sensor.ino
+++ Sensor/Photon/sensor.ino
@@ -1,13 +1,13 @@
 // This #include statement was automatically added by the Particle IDE.
-#include "HTU21D.h"
+#include "HTU21D/HTU21D.h"
 #include "application.h"
-#include "HttpClient.h"
+#include "HttpClient/HttpClient.h"

 unsigned int nextTime = 0;    // Next time to contact the server
 HttpClient http;
 HTU21D htu = HTU21D();

-char* serverUrl = "192.168.43.219";
+char* serverUrl = "192.168.178.34";
 char* clientId = "photo1";
 char* requestBody = "{ \"name\":\"%s\", \"weatherData\": { \"temperature\":\"%f\", \"humidity\":\"%f\" } }";

@@ -34,14 +34,14 @@
         return;
     }

-	Serial.println("Application>\tStart of Loop.");
+	//Serial.println("Application>\tStart of Loop.");

     float temperature = htu.readTemperature();
     float humidity = htu.readHumidity();

-	Serial.println("Temperature: %f, Humidity: %f", temperature, humidity);
+	//Serial.println("Temperature: %f, Humidity: %f", temperature, humidity);

-    Serial.println("Sending data...");
+    //Serial.println("Sending data...");

 	char payload[128];
     snprintf(payload, sizeof(payload), requestBody, clientId, temperature, humidity);
@@ -53,8 +53,9 @@

     http.post(request, response, headers);

-    Serial.println("Data sent");
+    //Serial.println("Data sent");

 	// do delay
     nextTime = millis() + delayInMillis;
 }
+


modifications due to @UPetersen's code review

--- LBridge_RFduino_V09.ino
+++ LBridge_RFduino_V09.ino
@@ -1,4 +1,4 @@
- /*
+/*
  * LBridge for RFduino / Simblee
  *
  * BLE Transmitter for read blood glucose from the Freestyle Libre Sensor via NFC and transfer to
@@ -30,6 +30,9 @@
  *  - 8 h backfilling - send per default last 8 h, xDrip+ will only accept and display values which are missing
  *  - shadow FRAM added (@UPetersen)
  *  - system, start with faster cycle time @FPV-UAV
+ * V0.9.01
+ *  - modifications due to @UPetersen s code review
+ *  - bit mask for raw BG data 13 bits = 0x1FFF
  */

 /* ********************* program configuration options **********************/
@@ -61,7 +64,8 @@
 #define LB_ADVERT "rfduino"     // dont change "rfduino"
                                 // length of device name and advertisement <=15!!!
 #define LB_VERSION "V0.9"       // program version
-#define LB_DATETIME "180203_2134" // date_time
+#define LB_MINOR_VERSION ".01"  // indicates minor version
+#define LB_DATETIME "180206_1837" // date_time
 #define SPIKE_HEIGHT 40         // minimum delta to be a spike

 #define MAX_VOLTAGE 3600        // adjust voltage measurement to have a wider rrange
@@ -151,7 +155,7 @@

 unsigned long startMinutesSinceStart = 0;
 unsigned long startMillisSinceStart = 0;
-unsigned long minutesSinceProgramStart;
+unsigned long minutesSinceProgramStart = 0;

 uint16_t lastGlucose = 0;
 uint16_t currentGlucose = 0;
@@ -257,7 +261,7 @@
   uint16_t trend[16];
   float trendTemperature[16];
   uint16_t history[32];
-  float historyTemperature[16];
+  float historyTemperature[32];
 } SensorDataDataType;

 IDNDataType idnData;
@@ -340,7 +344,7 @@
   Serial.print(" =====================================================================================================");

   print_statef("LBridge starting");
-  Serial.printf("\r\n\tBLE Name: %s, Version: %s from %s", LB_NAME, LB_VERSION, LB_DATETIME);
+  Serial.printf("\r\n\tBLE Name: %s, Version: %s%s from %s", LB_NAME, LB_VERSION, LB_MINOR_VERSION, LB_DATETIME);
   Serial.printf("\r\n\tRAM used: %d, , Flash used: %d", ramUsed(), flashUsed());
   Serial.printf("\r\n\tQueue size: %d (%d h)", DXQUEUESIZE, DXQUEUESIZE/12);
   Serial.printf("\r\n\tCompiled Options:");
@@ -958,6 +962,7 @@

   if ( !use_shadowfram ) {
     clearBuffer(dataBuffer);
+    // @UPetersen: Footer sollte nur einmal gelesen werden, da er nicht verwendet wird
     for (int i = 0; i < 43; i++) {
       resultCode = ReadSingleBlockReturn(i);
       if (resultCode != 0x80 && trials < maxTrials) {
@@ -1011,6 +1016,7 @@
     readBody(RXBuffer, &sensor, SS_PIN);
     if (!checkCRC16(sensor.fram, (byte) 1)) readBody(RXBuffer, &sensor, SS_PIN); // one more time

+    // @UPetersen: footer will not be used, shall only be read once at program start
     readFooter(RXBuffer, &sensor, SS_PIN);
     if (!checkCRC16(sensor.fram, (byte) 2)) readFooter(RXBuffer, &sensor, SS_PIN); // one more time

@@ -1738,7 +1744,10 @@
     if (index < 4) index = index + 96;
     for (int k = index; k < index + 6; k++)
       pomiar[k - index] = sensorDataBody[k];
-    sensorData.trend[i] = ((pomiar[1] << 8) & 0x0F00) + pomiar[0];
+//    sensorData.trend[i] = ((pomiar[1] << 8) & 0x0F00) + pomiar[0];
+    // 13 Bits for raw BG reading are valid with the Libre sensor
+    // meanwhile also hardcoded in xDrip+ (manual scan via NFC and blucon)
+    sensorData.trend[i] = ((pomiar[1] << 8) & 0x1F00) + pomiar[0];
   	sensorData.trendTemperature[i] = decode_temperature(&pomiar[3]);

     // print rawdata
@@ -1896,7 +1905,7 @@
   RFduinoBLE.advertisementData = "data";
   RFduinoBLE.customUUID = "c97433f0-be8f-4dc8-b6f0-5343e6100eb4";
 #endif /* USE_XBRIDGE2 */
-  RFduinoBLE.advertisementInterval = MILLISECONDS(300);
+  RFduinoBLE.advertisementInterval = MILLISECONDS(500);
   RFduinoBLE.txPowerLevel = 4;
   RFduinoBLE.begin();
 #else /* RFD */
@@ -1910,7 +1919,7 @@
   SimbleeBLE.advertisementData = "data";
   SimbleeBLE.customUUID = "c97433f0-be8f-4dc8-b6f0-5343e6100eb4";
 #endif /* USE_XBRIDGE2 */
-  SimbleeBLE.advertisementInterval = MILLISECONDS(300);
+  SimbleeBLE.advertisementInterval = MILLISECONDS(500);
   SimbleeBLE.txPowerLevel = 4;
   SimbleeBLE.begin();
 #endif /* RFD */


updated the port to the one that stupid Jade made me use

--- firmware/examples/example.ino
+++ firmware/examples/example.ino
@@ -2,7 +2,7 @@
 #include "tentacle-particle/tentacle-particle.h"

 #define server "tentacle.octoblu.com"
-#define port 80
+#define port 1528

 // IPAddress server(192,168,100,9);
 // #define port 8111


initial steps towards RadiationWatch class

--- PocketGeigerArduino.ino
+++ PocketGeigerArduino.ino
@@ -3,13 +3,6 @@
 // URL http://www.radiation-watch.org/
 //////////////////////////////////////////////////

-///　Digital I/O PIN Settings　///
-int signPin = 2; //Radiation Pulse (Yellow)
-int noisePin = 5; //Vibration Noise Pulse (White)
-//VCC 5V (Red)
-//GND (Blue)
-////////////////////////////////
-
 const double alpha=53.032; // cpm = uSv x alpha

 int index=0; //Number of loops
@@ -22,12 +15,10 @@
 int nON=0;//Lock flag for Noise Puls

 double cpm = 0; //Count rate [cpm] of current
-double cpmHistory[200]; //History of count rates
 int cpmIndex=0;//Position of current count rate on cpmHistory[]
 int cpmIndexPrev=0;//Flag to prevent duplicative counting

 //Timing Settings for Loop Interval
-int prevTime=0;
 int currTime=0;

 int totalSec=0; //Elapsed time of measurement [sec]
@@ -43,40 +34,97 @@
 char uSvBuff[20];
 char uSvdBuff[20];

+class RadiationWatch
+{
+  public:
+    RadiationWatch(int signPin, int noisePin);
+
+    void setup();
+    void loop();
+
+    void printKey();
+
+    int signPin();
+    int noisePin();
+
+    static const unsigned int kHistoryCount = 200;
+
+    double _cpmHistory[kHistoryCount]; //History of count rates
+
+    int _prevTime;
+
+  private:
+    int _signPin;   //Radiation Pulse (Yellow)
+    int _noisePin;  //Vibration Noise Pulse (White)
+
+
+};
+
+RadiationWatch::RadiationWatch(int signPin, int noisePin) : _signPin(signPin), _noisePin(noisePin)
+{
+  _prevTime = 0;
+}
+
+void RadiationWatch::setup()
+{
+  //PIN setting for Radiation Pulse
+  pinMode(_signPin,INPUT);
+  digitalWrite(_signPin,HIGH);
+
+  //PIN setting for Noise Pulse
+  pinMode(_noisePin,INPUT);
+  digitalWrite(_noisePin,HIGH);
+
+  //Initialize cpmHistory[]
+  for(int i=0; i < kHistoryCount;i++ )
+  {
+    _cpmHistory[i]=0;
+  }
+
+  _prevTime = millis();
+}
+
+void RadiationWatch::printKey()
+{
+  //CSV-formatting for serial output (substitute , for _)
+  Serial.println("hour[h]_sec[s]_count_cpm_uSv/h_uSv/hError");
+}
+
+int RadiationWatch::signPin()
+{
+  return digitalRead(_signPin);
+}
+
+int RadiationWatch::noisePin()
+{
+  return digitalRead(_noisePin);
+}
+
+RadiationWatch radiationWatch(2, 5);
+
+
+
 void setup()
 {
   //Serial setup
   //9600bps
   Serial.begin(9600);

-  //PIN setting for Radiation Pulse
-  pinMode(signPin,INPUT);
-  digitalWrite(signPin,HIGH);
-
-  //PIN setting for Noise Pulse
-  pinMode(noisePin,INPUT);
-  digitalWrite(noisePin,HIGH);
-
-  //CSV-formatting for serial output (substitute , for _)
-  Serial.println("hour[h]_sec[s]_count_cpm_uSv/h_uSv/hError");
-
-  //Initialize cpmHistory[]
-  for(int i=0; i<200;i++ )
-  {
-    cpmHistory[i]=0;
-  }
+  radiationWatch.setup();
+
+  radiationWatch.printKey();

   //Get start time of a loop
-  prevTime = millis();
+
 }

 void loop()
 {
   // Raw data of Radiation Pulse: Not-detected -> High, Detected -> Low
-  int sign = digitalRead(signPin);
+  int sign = radiationWatch.signPin();

   // Raw data of Noise Pulse: Not-detected -> Low, Detected -> High
-  int noise = digitalRead(noisePin);
+  int noise = radiationWatch.noisePin();

   //Radiation Pulse normally keeps low for about 100[usec]
   if(sign==0 && sON==0)
@@ -111,20 +159,20 @@
         cpmIndexPrev = totalSec;
         cpmIndex++;

-        if(cpmIndex >= 200)
+        if(cpmIndex >= RadiationWatch::kHistoryCount)
         {
           cpmIndex = 0;
         }

-        if(cpmHistory[cpmIndex] > 0)
-        {
-          cpm -= cpmHistory[cpmIndex];
-        }
-        cpmHistory[cpmIndex]=0;
+        if(radiationWatch._cpmHistory[cpmIndex] > 0)
+        {
+          cpm -= radiationWatch._cpmHistory[cpmIndex];
+        }
+        radiationWatch._cpmHistory[cpmIndex]=0;
       }

       //Store count log
-      cpmHistory[cpmIndex] += signCount;
+      radiationWatch._cpmHistory[cpmIndex] += signCount;
       //Add number of counts
       cpm += signCount;


Optimize one code lines in the LCDML_021_dynUpdatedContent example (2)

--- examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino
+++ examples/02_functionality/LCDML_021_dynUpdatedContent/LCDML_display_menu.ino
@@ -34,7 +34,7 @@
     uint8_t maxi = _LCDML_DISP_rows + i;
     uint8_t n = 0;

-    // check the type off a menu element
+    // reset a state
     dyn_menu_is_displayed = false;

     // check if this element has children
@@ -45,7 +45,8 @@
       {
         // check if a menu element has a condition and if the condition be true
         if (tmp->checkCondition())
-        {
+        {
+          // check the type off a menu element
           if(tmp->checkType_menu() == true)
           {
             // display normal content