Browse Source

initial commit in git, version 0.9

Wilfried Klaas 6 years ago
parent
commit
40cb208ec2
37 changed files with 4243 additions and 1 deletions
  1. 2 0
      .gitignore
  2. 28 1
      README.md
  3. 998 0
      SPS/SPS.ino
  4. 184 0
      SPS/advanceprg.ino
  5. 22 0
      SPS/notes.h
  6. 135 0
      SPS/prgmode.ino
  7. 21 0
      libraries/MCStools/EEPROMStruct.h
  8. 2 0
      libraries/MCStools/README.md
  9. 54 0
      libraries/MCStools/debug.h
  10. 45 0
      libraries/MCStools/debug2.h
  11. 45 0
      libraries/MCStools/debug3.h
  12. 49 0
      libraries/MCStools/debugAlt.h
  13. 37 0
      libraries/MCStools/keywords.txt
  14. 9 0
      libraries/MCStools/library.properties
  15. 37 0
      libraries/MCStools/makros.h
  16. 35 0
      libraries/Switch/Examples/SwitchCallbackExample/SwitchCallbackExample.ino
  17. 46 0
      libraries/Switch/Examples/SwitchExample/SwitchExample.ino
  18. 674 0
      libraries/Switch/LICENSE
  19. 338 0
      libraries/Switch/README.md
  20. 270 0
      libraries/Switch/avdweb_Switch.cpp
  21. 68 0
      libraries/Switch/avdweb_Switch.h
  22. 36 0
      libraries/Switch/keywords.txt
  23. 10 0
      libraries/Switch/library.properties
  24. 4 0
      libraries/TM1637-1.1.0/.gitignore
  25. 63 0
      libraries/TM1637-1.1.0/.travis.yml
  26. 165 0
      libraries/TM1637-1.1.0/LICENSE
  27. 27 0
      libraries/TM1637-1.1.0/README.md
  28. 223 0
      libraries/TM1637-1.1.0/TM1637Display.cpp
  29. 129 0
      libraries/TM1637-1.1.0/TM1637Display.h
  30. BIN
      libraries/TM1637-1.1.0/docs/TM1637_ V2.4.pdf
  31. BIN
      libraries/TM1637-1.1.0/docs/TM1637_V2.4_EN.pdf
  32. 112 0
      libraries/TM1637-1.1.0/examples/TM1637Test/TM1637Test.ino
  33. 14 0
      libraries/TM1637-1.1.0/library.json
  34. 217 0
      libraries/TM1637-1.1.0/old/TM1637Display.cpp
  35. 109 0
      libraries/TM1637-1.1.0/old/TM1637Display.h
  36. 28 0
      libraries/TM1637-1.1.0/platformio.ini
  37. 7 0
      libraries/TM1637-1.1.0/release_notes.md

+ 2 - 0
.gitignore

@@ -28,3 +28,5 @@
 *.out
 *.app
 
+
+*.hex

+ 28 - 1
README.md

@@ -1,3 +1,30 @@
 # ArduinoSPS
 
-A TPS Variant for the arduino with some major enhancments.
+A TPS Variant for the arduino with some major enhancments.
+
+**Version 0.9**
+  18.11.2018 WKLA
+  * BUGs entfernt. Release.
+  10.11.2018 WKLA
+  * Implementierung Tone Befehl
+
+**Version 0.8**
+  06.11.2018 WKLA
+  * Umstellung auf dbgOut
+  * Display TM1637 Anbindung
+
+**Version 0.7**
+  24.09.2012 WKLA
+  * neue Berechnung A = B - A und Swap A,B...
+  * Stack auf 16 Bytes berschränkt, wird zu oft gepusht, werden die alten Werte rausgeschoben.
+
+  Basierd auf dem TPS System vom elektronik-labor.
+  Erweiterungen:
+  * es können bis zu 6 Unterroutinen definiert werden und diese direkt angesprungen werden.
+  * neben return gibt's auch einen restart
+  * 2 Servoausgänge für übliche RC Servos. (10° Auflösung in Nibble Modus, <1° Auflösung im Bytemodus)
+  ACHTUNG: Servo und PWM Ausgänge sind nicht mischbar und können auch nicht gleichzeitig benutzt werden.
+  * 2 RC Eingänge (16 Schritte auflösung im nibble Modus, Mitte 8, 255 Schritte im Byte Modus)
+  * fkt. auch mit einem ATTiny84 (44 ist leider auf GRund der Programmgröße nicht mehr für den erweiterten Befehlssatz möglich)
+  * call stack von bis zu 16 Unterfunktionen
+  * neue Register e,f

+ 998 - 0
SPS/SPS.ino

@@ -0,0 +1,998 @@
+/*
+  SPS System mit dem Arduino.
+  Version 0.9
+  18.11.2018 WKLA
+  - BUGs entfernt. Release.
+  10.11.2018 WKLA
+  - Implementierung Tone Befehl
+
+  Version 0.8
+  06.11.2018 WKLA
+  - Umstellung auf dbgOut
+  - Display TM1637 Anbindung
+
+  Version 0.7
+  24.09.2012 WKLA
+  - neue Berechnung A = B - A und Swap A,B...
+  - Stack auf 16 Bytes berschränkt, wird zu oft gepusht, werden die alten Werte rausgeschoben.
+
+  Basierd auf dem TPS System vom elektronik-labor.
+  Erweiterungen:
+  - es können bis zu 6 Unterroutinen definiert werden und diese direkt angesprungen werden.
+  - neben return gibt's auch einen restart
+  - 2 Servoausgänge für übliche RC Servos. (10° Auflösung in Nibble Modus, <1° Auflösung im Bytemodus)
+  ACHTUNG: Servo und PWM Ausgänge sind nicht mischbar und können auch nicht gleichzeitig benutzt werden.
+  - 2 RC Eingänge (16 Schritte auflösung im nibble Modus, Mitte 8, 255 Schritte im Byte Modus)
+  - fkt. auch mit einem ATTiny84 (44 ist leider auf GRund der Programmgröße nicht mehr für den erweiterten Befehlssatz möglich)
+  - call stack von bis zu 16 Unterfunktionen
+  - neue Register e,f
+*/
+
+// Program im Debugmodus kompilieren, dann werden zus. Ausgaben auf die serielle Schnittstelle geschrieben.
+
+#ifdef __AVR_ATtiny4313__
+#define SPS_RCRECEIVER
+#endif
+
+#ifdef __AVR_ATmega328P__
+#define debug
+#define SPS_USE_DISPLAY
+#define SPS_RECEIVER
+#define SPS_ENHANCEMENT
+#define SPS_SERVO
+#define SPS_TONE
+#endif
+
+#ifdef __AVR_ATinyx4__
+#define SPS_ENHANCEMENT
+#define SPS_SERVO
+#endif
+
+#include <debug.h>
+#include <makros.h>
+#include <EEPROM.h>
+#include <avr/eeprom.h>
+
+#ifdef SPS_SERVO
+#include <Servo.h>
+#endif
+
+#ifdef SPS_ENHANCEMENT
+#include <avdweb_Switch.h>
+#endif
+
+#ifdef SPS_TONE
+#include "notes.h"
+#endif
+
+// Hardwareanbindung
+#ifdef __AVR_ATmega328P__
+// Arduino Hardware
+const byte Din_0 = 0;
+const byte Din_1 = 1;
+const byte Din_2 = 2;
+const byte Din_3 = 3;
+
+const byte Dout_0 = 4;
+const byte Dout_1 = 5;
+const byte Dout_2 = 6;
+const byte Dout_3 = 7;
+
+const byte ADC_0 = 0; //(15)
+const byte ADC_1 = 1; //(16)
+const byte PWM_1 = 9;
+const byte PWM_2 = 10;
+#ifdef SPS_RCRECEIVER
+const byte RC_0 = 18;
+const byte RC_1 = 19;
+#endif
+
+#ifdef SPS_SERVO
+const byte SERVO_1 = 9;
+const byte SERVO_2 = 10;
+#endif
+
+const byte SW_PRG = 8;
+const byte SW_SEL = 11;
+
+#ifdef SPS_USE_DISPLAY
+const byte DIGIT_DATA_IO = 12;
+const byte DIGIT_CLOCK = 13;
+#endif
+#endif
+
+#ifdef __AVR_ATtinyX4__
+// ATTiny84 Hardware
+const byte Dout_0 = 6;
+const byte Dout_1 = 5;
+const byte Dout_2 = 4;
+const byte Dout_3 = 1;
+
+const byte Din_0 = 10;
+const byte Din_1 = 9;
+const byte Din_2 = 8;
+const byte Din_3 = 7;
+const byte ADC_0 = 0;
+const byte ADC_1 = 1;
+const byte PWM_1 = 2;
+const byte PWM_2 = 3;
+#ifdef SPS_RCRECEIVER
+const byte RC_0 = 10;
+const byte RC_1 = 9;
+#endif
+
+#ifdef SPS_SERVO
+const byte SERVO_1 = 2;
+const byte SERVO_2 = 3;
+#endif
+
+const byte SW_PRG = 0;
+const byte SW_SEL = 8;
+
+#ifdef SPS_USE_DISPLAY
+const byte DIGIT_DATA_IO = 4;
+const byte DIGIT_CLOCK = 5;
+#endif
+#endif
+
+#ifdef __AVR_ATtiny4313__
+// ATTiny4313 Hardware
+const byte Dout_0 = 0;
+const byte Dout_1 = 1;
+const byte Dout_2 = 2;
+const byte Dout_3 = 3;
+
+const byte Din_0 = 4;
+const byte Din_1 = 5;
+const byte Din_2 = 6;
+const byte Din_3 = 7;
+const byte ADC_0 = 13;
+const byte ADC_1 = 14;
+const byte PWM_1 = 11;
+const byte PWM_2 = 12;
+
+#ifdef SPS_RCRECEIVER
+const byte RC_0 = 15;
+const byte RC_1 = 16;
+#endif
+
+#ifdef SPS_SERVO
+const byte SERVO_1 = 11;
+const byte SERVO_2 = 12;
+#endif
+
+const byte SW_PRG = 9;
+const byte SW_SEL = 8;
+#endif
+
+// Befehle
+const byte PORT = 0x10;
+const byte DELAY = 0x20;
+const byte JUMP_BACK = 0x30;
+const byte SET_A = 0x40;
+const byte IS_A = 0x50;
+const byte A_IS = 0x60;
+const byte CALC = 0x70;
+const byte PAGE = 0x80;
+const byte JUMP = 0x90;
+const byte C_COUNT = 0xA0;
+const byte D_COUNT = 0xB0;
+const byte SKIP_IF = 0xC0;
+const byte CALL = 0xD0;
+const byte CALL_SUB = 0xE0;
+const byte CMD_BYTE = 0xF0;
+
+// debouncing with 100ms
+const byte DEBOUNCE = 100;
+
+// sub routines
+const byte subCnt = 7;
+word subs[subCnt];
+
+word addr;
+word page;
+
+#ifdef SPS_ENHANCEMENT
+const byte SAVE_CNT = 16;
+#else
+const byte SAVE_CNT = 1;
+#endif
+
+word saveaddr[SAVE_CNT];
+byte saveCnt;
+
+#ifdef SPS_ENHANCEMENT
+byte stack[SAVE_CNT];
+byte stackCnt;
+#endif
+
+unsigned long tmpValue;
+
+byte a, b, c, d;
+
+#ifdef SPS_ENHANCEMENT
+byte e, f;
+#endif
+
+#ifdef SPS_SERVO
+Servo servo1;
+Servo servo2;
+#endif
+
+byte prog = 0;
+byte data = 0;
+byte com = 0;
+
+void setup() {
+  pinMode(Dout_0, OUTPUT);
+  pinMode(Dout_1, OUTPUT);
+  pinMode(Dout_2, OUTPUT);
+  pinMode(Dout_3, OUTPUT);
+
+  pinMode(PWM_1, OUTPUT);
+  pinMode(PWM_2, OUTPUT);
+
+  pinMode(Din_0, INPUT_PULLUP);
+  pinMode(Din_1, INPUT_PULLUP);
+  pinMode(Din_2, INPUT_PULLUP);
+  pinMode(Din_3, INPUT_PULLUP);
+
+  pinMode(SW_PRG, INPUT_PULLUP);
+  pinMode(SW_SEL, INPUT_PULLUP);
+
+#ifdef SPS_USE_DISPLAY
+  initDisplay();
+#endif
+
+  // Serielle Schnittstelle einstellen
+#ifndef __AVR_ATtinyX4__
+  initDebug();
+#endif
+
+  //  writeProgram();
+  doReset();
+
+  if (digitalRead(SW_PRG) == 0) {
+    programMode();
+  }
+}
+
+void doReset() {
+  dbgOutLn("Reset");
+#ifdef SPS_SERVO
+  servo1.detach();
+  servo2.detach();
+#endif
+
+  for (int i = 0; i < subCnt; i++) {
+    subs[i] = 0;
+  }
+
+  readProgram();
+
+  addr = 0;
+  page = 0;
+  saveCnt = 0;
+  a = 0;
+  b = 0;
+  c = 0;
+  d = 0;
+#ifdef SPS_ENHANCEMENT
+  e = 0;
+  f = 0;
+#endif
+}
+
+/*
+  getting all addresses of sub programms
+*/
+void readProgram() {
+  dbgOutLn("Read program");
+  word addr = 0;
+  for ( addr = 0; addr <= E2END; addr++) {
+    byte value = EEPROM.read(addr);
+
+#ifdef debug
+    dbgOut2(value, HEX);
+    if (((addr + 1) % 16) == 0) {
+      dbgOutLn();
+    }
+    else {
+      dbgOut(",");
+    }
+#endif
+
+    if (value == 0xFF) {
+      // ende des Programms
+      break;
+    }
+    byte cmd = (value & 0xF0);
+    byte data = (value & 0x0F);
+
+    dbgOut("(");
+    dbgOut2(cmd, HEX);
+    dbgOut2(data, HEX);
+    dbgOut(")");
+
+    if (cmd == CALL_SUB) {
+      if (data >= 8) {
+        data = data - 8;
+        subs[data] = addr + 1;
+      }
+    }
+#ifdef SPS_SERVO
+    if ((cmd == IS_A) && (data == 0x0B)) {
+      if (!servo1.attached()) {
+        dbgOutLn("attach Srv1");
+        servo1.attach(SERVO_1);
+      }
+    } else if ((cmd == CMD_BYTE) && (data == 0x06)) {
+      if (!servo1.attached()) {
+        dbgOutLn("attach Srv1");
+        servo1.attach(SERVO_1);
+      }
+    } else if ((cmd == IS_A) && (data == 0x0C)) {
+      if (!servo2.attached()) {
+        dbgOutLn("attach Srv2");
+        servo2.attach(SERVO_2);
+      }
+    } else if ((cmd == CMD_BYTE) && (data == 0x07)) {
+      if (!servo2.attached()) {
+        dbgOutLn("attach Srv2");
+        servo2.attach(SERVO_2);
+      }
+    }
+#endif
+  }
+  dbgOutLn();
+}
+
+/*
+  main loop
+*/
+void loop() {
+  byte value = EEPROM.read(addr);
+  byte cmd = (value & 0xF0);
+  byte data = (value & 0x0F);
+
+  dbgOut2(addr, HEX);
+  dbgOut(":");
+  dbgOut2(value, HEX);
+  dbgOut(",");
+  dbgOut2(cmd, HEX);
+  dbgOut(",");
+  dbgOut2(data, HEX);
+  dbgOut(",a:");
+  dbgOut2(a, HEX);
+  dbgOut(",");
+  dbgOut2(b, HEX);
+  dbgOut(",");
+  dbgOut2(c, HEX);
+  dbgOut(",");
+  dbgOut2(d, HEX);
+  dbgOut(",");
+  dbgOut2(e, HEX);
+  dbgOut(",");
+  dbgOut2(f, HEX);
+  dbgOutLn();
+
+  addr = addr + 1;
+  switch (cmd) {
+    case PORT:
+      doPort(data);
+      break;
+    case DELAY:
+      doDelay(data);
+      break;
+    case JUMP_BACK:
+      doJumpBack(data);
+      break;
+    case SET_A:
+      doSetA(data);
+      break;
+    case A_IS:
+      doAIs(data);
+      break;
+    case IS_A:
+      doIsA(data);
+      break;
+    case CALC:
+      doCalc(data);
+      break;
+    case PAGE:
+      doPage(data);
+      break;
+    case JUMP:
+      doJump(data);
+      break;
+    case C_COUNT:
+      doCCount(data);
+      break;
+    case D_COUNT:
+      doDCount(data);
+      break;
+    case SKIP_IF:
+      doSkipIf(data);
+      break;
+    case CALL:
+      doCall(data);
+      break;
+    case CALL_SUB:
+      doCallSub(data);
+      break;
+    case CMD_BYTE:
+      doByte(data);
+      break;
+    default:
+      ;
+  }
+  if (addr > E2END) {
+    doReset();
+  }
+}
+
+/*
+  output to port
+*/
+void doPort(byte data) {
+  digitalWrite(Dout_0, (data & 0x01) > 0);
+  digitalWrite(Dout_1, (data & 0x02) > 0);
+  digitalWrite(Dout_2, (data & 0x04) > 0);
+  digitalWrite(Dout_3, (data & 0x08) > 0);
+}
+
+/*
+  delay in ms
+*/
+void doDelay(byte data) {
+  dbgOut("dly: ");
+  dbgOutLn2(data, HEX);
+
+  switch (data) {
+    case 0:
+      delay(1);
+      break;
+    case 1:
+      delay(2);
+      break;
+    case 2:
+      delay(5);
+      break;
+    case 3:
+      delay(10);
+      break;
+    case 4:
+      delay(20);
+      break;
+    case 5:
+      delay(50);
+      break;
+    case 6:
+      delay(100);
+      break;
+    case 7:
+      delay(200);
+      break;
+    case 8:
+      delay(500);
+      break;
+    case 9:
+      delay(1000);
+      break;
+    case 10:
+      delay(2000);
+      break;
+    case 11:
+      delay(5000);
+      break;
+    case 12:
+      delay(10000);
+      break;
+    case 13:
+      delay(20000);
+      break;
+    case 14:
+      delay(30000);
+      break;
+    case 15:
+      delay(60000);
+      break;
+    default:
+      break;
+  }
+}
+
+/*
+  jump relative back
+*/
+void doJumpBack(byte data) {
+  addr = addr - data - 1;
+}
+
+/*
+  a = data
+*/
+void doSetA(byte data) {
+  a = data;
+}
+
+/*
+  a = somthing;
+*/
+void doAIs(byte data) {
+  switch (data) {
+    case 1:
+      a = b;
+      break;
+    case 2:
+      a = c;
+      break;
+    case 3:
+      a = d;
+      break;
+    case 4:
+      a = digitalRead(Din_0) + (digitalRead(Din_1) << 1) + (digitalRead(Din_2) << 2) + (digitalRead(Din_3) << 3);
+      break;
+    case 5:
+      a = digitalRead(Din_0);
+      break;
+    case 6:
+      a = digitalRead(Din_1);
+      break;
+    case 7:
+      a = digitalRead(Din_2);
+      break;
+    case 8:
+      a = digitalRead(Din_3);
+      break;
+#ifndef __AVR_ATtiny4313__
+    case 9:
+      tmpValue = analogRead(ADC_0);
+      a = tmpValue / 64; //(Umrechnen auf 4 bit)
+      break;
+    case 10:
+      tmpValue = analogRead(ADC_1);
+      a = tmpValue / 64; //(Umrechnen auf 4 bit)
+      break;
+#else
+    case 9:
+      a = digitalRead(ADC_0);
+      break;
+    case 10:
+      a = digitalRead(ADC_1);
+      break;
+#endif
+#ifdef SPS_RCRECEIVER
+    case 11:
+      tmpValue = pulseIn(RC_0, HIGH, 100000);
+      if (tmpValue < 1000) {
+        tmpValue = 1000;
+      }
+      if (tmpValue > 2000) {
+        tmpValue = 2000;
+      }
+      a = (tmpValue - 1000) / 64; //(Umrechnen auf 4 bit)
+      dbgOut("RC1:");
+      dbgOut(tmpValue);
+      dbgOut("=");
+      dbgOutLn(a);
+      break;
+    case 12:
+      tmpValue = pulseIn(RC_1, HIGH, 100000);
+      if (tmpValue < 1000) {
+        tmpValue = 1000;
+      }
+      if (tmpValue > 2000) {
+        tmpValue = 2000;
+      }
+      a = (tmpValue - 1000) / 64; //(Umrechnen auf 4 bit)
+      dbgOut("RC2:");
+      dbgOut(tmpValue);
+      dbgOut("=");
+      dbgOutLn(a);
+      break;
+#endif
+#ifdef SPS_ENHANCMENT
+    case 13:
+      a = e;
+      break;
+    case 14:
+      a = f;
+      break;
+    case 15:
+      if (stackCnt > 0) {
+        stackCnt -= 1;
+        a = stack[stackCnt];
+      } else {
+        a = 0;
+      }
+      break;
+#endif
+    default:
+      break;
+  }
+}
+
+/*
+  somthing = a;
+*/
+void doIsA(byte data) {
+  switch (data) {
+#ifdef SPS_ENHANCEMENT
+    case 0:
+      swap(a, b, byte);
+      break;
+#endif
+    case 1:
+      b = a;
+      break;
+    case 2:
+      c = a;
+      break;
+    case 3:
+      d = a;
+      break;
+    case 4:
+      doPort(a);
+      break;
+    case 5:
+      digitalWrite(Dout_0, (a & 0x01) > 0);
+      break;
+    case 6:
+      digitalWrite(Dout_1, (a & 0x01) > 0);
+      break;
+    case 7:
+      digitalWrite(Dout_2, (a & 0x01) > 0);
+      break;
+    case 8:
+      digitalWrite(Dout_3, (a & 0x01) > 0);
+      break;
+    case 9:
+      tmpValue = a * 16;
+      dbgOut("PWM1:");
+      dbgOutLn(tmpValue);
+      analogWrite(PWM_1, tmpValue);
+      break;
+    case 10:
+      tmpValue = a * 16;
+      dbgOut("PWM2:");
+      dbgOutLn(tmpValue);
+      analogWrite(PWM_2, tmpValue);
+      break;
+#ifdef SPS_SERVO
+    case 11:
+      if (servo1.attached()) {
+        tmpValue = (a * 10) + 10;
+        dbgOut("Srv1:");
+        dbgOutLn(tmpValue);
+        servo1.write(tmpValue);
+      }
+      break;
+    case 12:
+      if (servo2.attached()) {
+        tmpValue = (a * 10) + 10;
+        dbgOut("Srv2:");
+        dbgOutLn(tmpValue);
+        servo2.write(tmpValue);
+      }
+      break;
+#endif
+#ifdef SPS_ENHANCEMENT
+    case 13:
+      e = a;
+      break;
+    case 14:
+      f = a;
+      break;
+    case 15:
+      if (stackCnt < SAVE_CNT) {
+        stack[stackCnt] = a;
+        stackCnt += 1;
+      }
+      else {
+        for (int i = 1; i <= SAVE_CNT; i++) {
+          stack[i - 1] = stack[i];
+        }
+        stack[stackCnt] = a;
+      }
+      break;
+#endif
+    default:
+      break;
+  }
+}
+
+/*
+  calculations
+*/
+void doCalc(byte data) {
+  switch (data) {
+    case 1:
+      a = a + 1;
+      break;
+    case 2:
+      a = a - 1;
+      break;
+    case 3:
+      a = a + b;
+      break;
+    case 4:
+      a = a - b;
+      break;
+    case 5:
+      a = a * b;
+      break;
+    case 6:
+      a = a / b;
+      break;
+    case 7:
+      a = a & b;
+      break;
+    case 8:
+      a = a | b;
+      break;
+    case 9:
+      a = a ^ b;
+      break;
+    case 10:
+      a = !a;
+      break;
+#ifdef SPS_ENHANCEMENT
+    case 11:
+      a = a % b;
+      break;
+    case 12:
+      a = a + 16 * b;
+      break;
+    case 13:
+      a = b - a;
+      break;
+#endif
+    default:
+      break;
+  }
+#ifndef SPS_ENHANCEMENT
+  a = a & 15;
+#endif
+}
+
+/*
+  setting page
+*/
+void doPage(byte data) {
+  page = data * 16;
+}
+
+/*
+  jump absolute
+*/
+void doJump(byte data) {
+#ifdef debug
+  dbgOut("J");
+  dbgOut2(page, HEX);
+  dbgOutLn2(data, HEX);
+#endif
+  addr = page + data;
+}
+
+/*
+  counting with c register
+*/
+void doCCount(byte data) {
+  if (c > 0) {
+    c -= 1;
+    c = c & 0x0F;
+    doJump(data);
+  }
+}
+
+/*
+  counting with d register
+*/
+void doDCount(byte data) {
+  if (d > 0) {
+    d -= 1;
+    d = d & 0x0F;
+    doJump(data);
+  }
+}
+
+/*
+  simple comdition = true skip next command
+*/
+void doSkipIf(byte data) {
+  bool skip = false;
+  switch (data) {
+#ifdef SPS_ENHANCEMENT
+    case 0:
+      skip = (a == 0);
+      break;
+#endif
+    case 1:
+      skip = (a > b);
+      break;
+    case 2:
+      skip = (a < b);
+      break;
+    case 3:
+      skip = (a == b);
+      break;
+    case 4:
+      skip = digitalRead(Din_0);
+      break;
+    case 5:
+      skip = digitalRead(Din_1);
+      break;
+    case 6:
+      skip = digitalRead(Din_2);
+      break;
+    case 7:
+      skip = digitalRead(Din_3);
+      break;
+    case 8:
+      skip = !digitalRead(Din_0);
+      break;
+    case 9:
+      skip = !digitalRead(Din_1);
+      break;
+    case 10:
+      skip = !digitalRead(Din_2);
+      break;
+    case 11:
+      skip = !digitalRead(Din_3);
+      break;
+    case 12:
+      skip = !digitalRead(SW_PRG);
+      break;
+    case 13:
+      skip = !digitalRead(SW_SEL);
+      break;
+    case 14:
+      skip = digitalRead(SW_PRG);
+      break;
+    case 15:
+      skip = digitalRead(SW_SEL);
+      break;
+    default:
+      break;
+  }
+  if (skip) {
+    addr += 1;
+  }
+}
+
+/*
+  calling a subroutine
+*/
+void doCall(byte data) {
+  saveaddr[saveCnt] = addr;
+  saveCnt++;
+  addr = page + data;
+}
+
+/*
+  calling a subroutine, calling return and restart
+*/
+void doCallSub(byte data) {
+  if (data == 0) {
+    if (saveCnt < 0) {
+      doReset();
+      return;
+    }
+    saveCnt -= 1;
+    addr = saveaddr[saveCnt];
+    dbgOut("r:");
+    dbgOutLn(addr);
+    return;
+  }
+#ifdef SPS_ENHANCEMENT
+  if (data <= 7) {
+    // call subroutine number
+    doCall(addr);
+    addr = subs[data - 1];
+    dbgOut("c:");
+    dbgOutLn(addr);
+    return;
+  }
+  if (data == 0x0f) {
+    doReset();
+  }
+#endif
+}
+
+/*
+  calling a byte methods
+*/
+void doByte(byte data) {
+#ifdef SPS_ENHANCEMENT
+  dbgOut("B ");
+  switch (data) {
+    case 0:
+      tmpValue = analogRead(ADC_0);
+      a = tmpValue >> 2; //(Umrechnen auf 8 bit)
+      break;
+    case 1:
+      tmpValue = analogRead(ADC_1);
+      a = tmpValue >> 2; //(Umrechnen auf 8 bit)
+      break;
+#ifdef SPS_RCRECEIVER
+    case 2:
+      tmpValue = pulseIn(RC_0, HIGH, 100000);
+      if (tmpValue < 1000) {
+        tmpValue = 1000;
+      }
+      if (tmpValue > 2000) {
+        tmpValue = 2000;
+      }
+      a = (tmpValue - 1000) / 4; //(Umrechnen auf 4 bit)
+      dbgOut("RC1:");
+      dbgOut(tmpValue);
+      dbgOut("=");
+      dbgOutLn(a);
+      break;
+    case 3:
+      tmpValue = pulseIn(RC_1, HIGH, 100000);
+      if (tmpValue < 1000) {
+        tmpValue = 1000;
+      }
+      if (tmpValue > 2000) {
+        tmpValue = 2000;
+      }
+      a = (tmpValue - 1000) / 4; //(Umrechnen auf 4 bit)
+      dbgOut("RC2:");
+      dbgOut(tmpValue);
+      dbgOut("=");
+      dbgOutLn(a);
+      break;
+#endif
+    case 4:
+      tmpValue = a;
+      dbgOut("PWM1:");
+      dbgOutLn(a);
+      analogWrite(PWM_1, a);
+      break;
+    case 5:
+      tmpValue = a;
+      dbgOut("PWM2:");
+      dbgOutLn(a);
+      analogWrite(PWM_2, a);
+      break;
+#ifdef SPS_SERVO
+    case 6:
+      if (servo1.attached()) {
+        dbgOut("Srv1:");
+        tmpValue = map(a,0, 255,0,180);
+        dbgOutLn(tmpValue);
+        servo1.write(tmpValue);
+      }
+      break;
+    case 7:
+      if (servo2.attached()) {
+        dbgOut("Srv2:");
+        tmpValue = map(a,0, 255,0,180);
+        dbgOutLn(tmpValue);
+        servo2.write(tmpValue);
+      }
+      break;
+#endif
+#ifdef SPS_TONE
+    case 8:
+      if (a == 0) {
+        dbgOutLn("Tone off");
+        noTone(PWM_2);
+      } else {
+        if (between(a, MIDI_START, MIDI_START + MIDI_NOTES)) {
+          word frequenz = pgm_read_word(a - MIDI_START + midiNoteToFreq);
+          dbgOut("Tone on: midi ");
+          dbgOut2(a, DEC);
+          dbgOut(", ");
+          dbgOut2(frequenz, DEC);
+          dbgOutLn("Hz");
+          tone(PWM_2, frequenz);
+        }
+      }
+      break;
+#endif
+  }
+#endif
+}

+ 184 - 0
SPS/advanceprg.ino

@@ -0,0 +1,184 @@
+#ifdef SPS_USE_DISPLAY
+#include <TM1637Display.h>
+#endif
+
+#ifndef SPS_USE_DISPLAY
+void advancePrg() {}
+#endif
+
+#ifdef SPS_USE_DISPLAY
+TM1637Display display(DIGIT_CLOCK, DIGIT_DATA_IO);
+byte displayValues[4];
+
+const byte PRGS_ADDR = 0;
+const byte PRGS_COM = 1;
+const byte PRGS_DATA = 2;
+
+Switch prgSwitch = Switch(SW_PRG);
+Switch selSwitch = Switch(SW_SEL);
+
+void advancePrg() {
+  resetDisplay();
+  showPrg();
+  dbgOutLn("adv prg mode");
+  while ((digitalRead(SW_PRG) == 0) || (digitalRead(SW_SEL) == 0));
+  delay(DEBOUNCE);
+
+  addr = 0;
+  byte Eebyte = EEPROM.read(addr);
+  boolean dirty = false;
+
+  showAddress(addr, Eebyte);
+
+  unsigned long saveTime = millis();
+
+  byte prgState = PRGS_COM;
+  showActualState(prgState);
+  prgSwitch.poll();
+  selSwitch.poll();
+
+  // hier die Programmschleife
+  do {
+    prgSwitch.poll();
+    selSwitch.poll();
+
+    boolean lit = (((millis() - saveTime) % 500) > 250);
+    display.setColon(lit);
+    outputDisplay();
+    if (prgSwitch.pushed()) {
+      prgState += 1;
+      prgState = prgState % 3;
+      if (prgState == PRGS_ADDR) {
+        if (dirty) {
+          dbgOut("prg:");
+          dbgOut2(addr, HEX);
+          dbgOut(':');
+          dbgOutLn2(Eebyte, HEX);
+
+          displayValues[2] = 0x40;
+          displayValues[3] = 0x40;
+          outputDisplay();
+
+          EEPROM.write(addr, Eebyte);
+          delay(500);
+
+          displayValues[2] = 0x00;
+          displayValues[3] = 0x00;
+          outputDisplay();
+        }
+        addr = (addr + 1) % E2END;
+        Eebyte = EEPROM.read(addr);
+        dirty = false;
+        prgState = PRGS_COM;
+        showAddress(addr, Eebyte);
+      }
+      showActualState(prgState);
+    }
+
+    if (selSwitch.pushed()) {
+      switch (prgState) {
+        case PRGS_COM:
+          dbgOut('c');
+          dirty = true;
+          Eebyte = Eebyte + 0x10;
+          showAddress(addr, Eebyte);
+          break;
+        case PRGS_DATA:
+          dbgOut('d');
+          dirty = true;
+          byte data = Eebyte & 0x0F;
+          data += 1;
+          data = data & 0x0F;
+          Eebyte = (Eebyte & 0xF0) + data;
+          showAddress(addr, Eebyte);
+          break;
+      }
+    }
+  }
+  while (true);
+}
+
+void showActualState(byte prgState) {
+  switch (prgState) {
+    case PRGS_ADDR:
+      blinkAddr();
+      delay(250);
+      blinkAddr();
+      break;
+    case PRGS_COM:
+      blinkCol(2);
+      delay(250);
+      blinkCol(2);
+      break;
+    case PRGS_DATA:
+      blinkCol(3);
+      delay(250);
+      blinkCol(3);
+      break;
+  }
+}
+
+void blinkAddr() {
+  byte saveValue1 = displayValues[0];
+  byte saveValue2 = displayValues[1];
+  displayValues[0] = 0;
+  displayValues[1] = 0;
+  outputDisplay();
+  delay(250);
+  displayValues[0] = saveValue1;
+  displayValues[1] = saveValue2;
+  outputDisplay();
+}
+
+void blinkCol(byte col) {
+  byte saveValue1 = displayValues[col];
+  displayValues[col] = 0;
+  outputDisplay();
+  delay(250);
+  displayValues[col] = saveValue1;
+  outputDisplay();
+}
+
+void showPrg() {
+  displayValues[0] = 0b01110011;
+  displayValues[1] = 0b01010000;
+  displayValues[2] = 0b01101111;
+  outputDisplay();
+}
+
+void showAddress(word addr, byte Eebyte) {
+  displayValues[0] = display.encodeDigit(addr >> 4);
+  displayValues[1] = display.encodeDigit(addr & 15);
+
+  data = Eebyte & 15;
+  com = Eebyte >> 4;
+
+  displayValues[2] = display.encodeDigit(com);
+  displayValues[3] = display.encodeDigit(data);
+  outputDisplay();
+}
+
+// routines for the tm1637 display
+void outputDisplay() {
+  display.setSegments(displayValues);
+}
+
+void initDisplay() {
+  display.setBrightness(0x0f);
+  resetDisplay();
+  for (byte i = 0; i < 4; i++) {
+    displayValues[i] = 0x40;
+    delay(150);
+    outputDisplay();
+  }
+  delay(250);
+  resetDisplay();
+}
+
+void resetDisplay() {
+  for (byte i = 0; i < 4; i++) {
+    displayValues[i] = 0;
+  }
+  display.setSegments(displayValues);
+}
+#endif

+ 22 - 0
SPS/notes.h

@@ -0,0 +1,22 @@
+#include "avr/pgmspace.h"
+
+#define MIDI_START 36 // here starts our table, lowest is C2
+#define MIDI_NOTES 73
+// converting midi notes into the desired frequwnz for the tone function
+// the frequenz was calculated with libreoffice calc with this  fm = (440 Hz)* 2^((m−69)/12) and than rounded.
+const PROGMEM unsigned int midiNoteToFreq[MIDI_NOTES] =
+{
+  65, // C2
+  69, 73, 78, 82, 87, 92, 98, 104, 110, 117, 123,
+  131, // C3
+  139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247,
+  262, //C4
+  277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
+  523, //C5
+  554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
+  1047, //C6
+  1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976,
+  2093, //C7
+  2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951,
+  4186 //C8
+};

+ 135 - 0
SPS/prgmode.ino

@@ -0,0 +1,135 @@
+/*
+  entering the programming mode
+*/
+void programMode() {
+  // checking if advance programmer board connected?
+#ifdef SPS_ENHANCEMENT
+  if (digitalRead(SW_SEL) == 0) {
+    advancePrg();
+  }
+  else {
+#endif
+    dbgOutLn("PrgMode");
+    addr = 0;
+    do {
+      dbgOut("Adr:");
+      dbgOutLn(addr);
+      // LoNibble Adresse anzeigen
+      doPort(addr);
+      delay(300);
+      lighting();
+      // HiNibble Adresse anzeigen
+      data = (addr & 0xf0) >> 4;                                  //Adresse anzeigen
+      doPort(data);
+      delay(300);
+      lighting();
+
+      byte Eebyte = EEPROM.read(addr);
+      data = Eebyte & 15;
+      com = Eebyte >> 4;
+      dbgOutLn('commando eingeben');
+      doPort(com); //Befehl anzeigen
+      digitalWrite(PWM_1, HIGH);
+      do {
+      }
+      while (digitalRead(SW_SEL) == 1); // S2 = 1
+      delay(DEBOUNCE);
+
+      prog = 1;                                            //Phase 1: Befehl anzeigen
+      do {
+        dbgOut("C:");
+        dbgOut(com);
+        dbgOut(", D:");
+        dbgOut(data);
+        dbgOut(", P:");
+        dbgOutLn(prog);
+
+        if (digitalRead(SW_PRG) == 0) {
+          if (prog == 1) {
+            prog = 2;
+            com = 15;
+          }
+          if (prog == 2) {                                   //Phase 2: Befehl verändert
+            com = com + 1;
+            com = com & 15;
+            doPort(com);
+            digitalWrite(PWM_1, HIGH);
+          }
+          if (prog == 3) {                                   //Phase 3: Befehl unverändert, Daten ändern
+            prog = 5;
+            data = 15;
+          }
+          if (prog == 4) {                                   //Phase 4: Befehl und Daten geändert
+            prog = 5;
+            data = 15;
+          }
+          if (prog == 5) {                                   //Phase 5: Daten verändert
+            data += 1;
+            data = data & 15;
+            doPort(data);
+            digitalWrite(PWM_1, LOW);
+          }
+          delay(DEBOUNCE);
+          do {
+          }
+          while (digitalRead(SW_PRG) == 1);
+          delay(DEBOUNCE);
+        }
+
+        if (digitalRead(SW_SEL) == 0) {
+          if (prog == 3) {
+            prog = 7;          //nur angezeigt, nicht verändert
+          }
+          if (prog == 4) {
+            doPort(255 - data);
+            digitalWrite(PWM_1, LOW);
+            prog = 6;
+          }
+          if (prog == 2) {
+            doPort(data);             // Portd = Dat Or &HF0
+            digitalWrite(PWM_1, LOW);
+            prog = 4;
+          }
+          if (prog == 6) {                                    //nur Kommando wurde verändert
+            data = data & 15;
+            Eebyte = com * 16;
+            Eebyte = Eebyte + data;
+            EEPROM.write(addr, Eebyte); //           Writeeeprom Eebyte , Addr
+            doPort(0x0F);
+            delay(600);
+            addr += 1;
+            prog = 0;
+          }
+          if (prog == 5) {                                     //Daten wurden verändert
+            data = data & 15;
+            Eebyte = com * 16;
+            Eebyte = Eebyte + data;
+            EEPROM.write(addr, Eebyte); //           Writeeeprom Eebyte , Addr
+            doPort(0xF0);
+            delay(600);
+            addr += 1;
+            prog = 0;
+          }
+          if (prog == 7) {
+            addr += 1;
+            prog = 0;
+          }
+          delay(DEBOUNCE);
+          do {
+          }
+          while (digitalRead(SW_SEL) == 0);
+          delay(DEBOUNCE);
+        }
+      }
+      while (prog != 0);
+    }
+    while (true);
+#ifdef SPS_ENHANCEMENT
+  }
+#endif
+}
+
+void lighting() {
+  doPort(0x0F);
+  delay(200);
+}

+ 21 - 0
libraries/MCStools/EEPROMStruct.h

@@ -0,0 +1,21 @@
+#include <avr/eeprom.h>
+#include <EEPROM.h>
+#include <Arduino.h>  // for type definitions
+
+template <class T> int EEPROM_writeStruct(int address, const T& value)
+{
+    const byte* p = (const byte*)(const void*)&value;
+    unsigned int i;
+    for (i = 0; i < sizeof(value); i++)
+		  eeprom_write_byte((unsigned char *)address++, *p++);  
+    return i;
+}
+
+template <class T> int EEPROM_readStruct(int address, T& value)
+{
+    byte* p = (byte*)(void*)&value;
+    unsigned int i;
+    for (i = 0; i < sizeof(value); i++)
+          *p++ = eeprom_read_byte((unsigned char *)address++);
+    return i;
+}

+ 2 - 0
libraries/MCStools/README.md

@@ -0,0 +1,2 @@
+# RCReceiver
+An arduino library for comunicate with a rc receiver

+ 54 - 0
libraries/MCStools/debug.h

@@ -0,0 +1,54 @@
+/*
+  debug.h - Definition von 2 Debugfunktionen - Version 0.1
+  Copyright (c) 2012 Wilfried Klaas.  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+// Program im Debugmodus kompilieren, dann werden zus. Ausgaben auf die serielle Schnittstelle geschrieben.
+// Zum aktivieren der Debug Funktion bitte den Define VOR dem #include "debug.h" in die Hauptdatei eintragen.
+//#define debug
+#include <Arduino.h>
+#include <inttypes.h>
+
+#ifdef debug
+#define dbgOut(S) \
+Serial.print(S); 
+#define dbgOut2(S,P) \
+Serial.print(S,P); 
+#define dbgOutLn(S) \
+Serial.println(S); 
+#define dbgOutLn2(S,P) \
+Serial.println(S,P); 
+#define initDebug() \
+  Serial.begin(57600); \
+  Serial.flush(); \
+  delay(100);
+#else
+#define dbgOut(S)
+#define dbgOut2(S,P)
+#define dbgOutLn(S)
+#define dbgOutLn2(S,P)
+#define initDebug()
+#endif
+
+void dbgOutHex(uint8_t data) {
+  dbgOut(" 0x");
+  if (data < 0x10) {
+    dbgOut('0');
+  }
+  dbgOut2(data, HEX);
+}
+

+ 45 - 0
libraries/MCStools/debug2.h

@@ -0,0 +1,45 @@
+/*
+  debug2.h - Definition von 2 Debugfunktionen - Version 0.1
+  Copyright (c) 2012 Wilfried Klaas.  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+// Program im Debugmodus kompilieren, dann werden zus. Ausgaben auf die serielle Schnittstelle geschrieben.
+// Zum aktivieren der Debug Funktion bitte den Define VOR dem #include "debug.h" in die Hauptdatei eintragen.
+//#define debug
+
+#ifdef debug
+#define dbgOut(S) \
+Serial2.print(S); 
+#define dbgOut2(S,P) \
+Serial2.print(S,P); 
+#define dbgOutLn(S) \
+Serial2.println(S); 
+#define dbgOutLn2(S,P) \
+Serial2.println(S,P); 
+#define initDebug() \
+  Serial2.begin(57600); \
+  Serial2.flush(); \
+  delay(100);
+#else
+#define dbgOut(S)
+#define dbgOut2(S,P)
+#define dbgOutLn(S)
+#define dbgOutLn2(S,P)
+#define initDebug()
+#endif
+
+

+ 45 - 0
libraries/MCStools/debug3.h

@@ -0,0 +1,45 @@
+/*
+  debug3.h - Definition von 2 Debugfunktionen - Version 0.1
+  Copyright (c) 2012 Wilfried Klaas.  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+// Program im Debugmodus kompilieren, dann werden zus. Ausgaben auf die serielle Schnittstelle geschrieben.
+// Zum aktivieren der Debug Funktion bitte den Define VOR dem #include "debug.h" in die Hauptdatei eintragen.
+//#define debug
+
+#ifdef debug
+#define dbgOut(S) \
+Serial3.print(S); 
+#define dbgOut2(S,P) \
+Serial3.print(S,P); 
+#define dbgOutLn(S) \
+Serial3.println(S); 
+#define dbgOutLn2(S,P) \
+Serial3.println(S,P); 
+#define initDebug() \
+  Serial3.begin(57600); \
+  Serial3.flush(); \
+  delay(100);
+#else
+#define dbgOut(S)
+#define dbgOut2(S,P)
+#define dbgOutLn(S)
+#define dbgOutLn2(S,P)
+#define initDebug()
+#endif
+
+

+ 49 - 0
libraries/MCStools/debugAlt.h

@@ -0,0 +1,49 @@
+/*
+  debug.h - Definition von 2 Debugfunktionen - Version 0.1
+  Copyright (c) 2012 Wilfried Klaas.  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+// Program im Debugmodus kompilieren, dann werden zus. Ausgaben auf die serielle Schnittstelle geschrieben.
+// Zum aktivieren der Debug Funktion bitte den Define VOR dem #include "debug.h" in die Hauptdatei eintragen.
+//#define debug
+
+#ifdef debug
+#include <AltSoftSerial.h>
+AltSoftSerial dbgSerial;
+
+#define dbgOut(S) \
+dbgSerial.print(S); 
+#define dbgOut2(S,P) \
+dbgSerial.print(S,P); 
+#define dbgOutLn(S) \
+dbgSerial.println(S); 
+#define dbgOutLn2(S,P) \
+dbgSerial.println(S,P); 
+#define initDebug() \
+  dbgSerial.begin(57600); \
+  dbgSerial.flush(); \
+  delay(100);
+
+#else
+#define dbgOut(S)
+#define dbgOut2(S,P)
+#define dbgOutLn(S)
+#define dbgOutLn2(S,P)
+#define initDebug()
+#endif
+
+

+ 37 - 0
libraries/MCStools/keywords.txt

@@ -0,0 +1,37 @@
+#######################################
+# Syntax Coloring Map RCReceiver
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+RCReceive	KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+initInt	KEYWORD2
+attach	KEYWORD2
+getValue	KEYWORD2
+poll	KEYWORD2
+getNP	KEYWORD2
+hasError	KEYWORD2
+hasNP	KEYWORD2
+getLastRCValue	KEYWORD2
+handleInterrupt	KEYWORD2
+attachInt	KEYWORD2
+detachInt	KEYWORD2
+getMsValue	KEYWORD2
+between	KEYWORD2
+dbgOut	KEYWORD2
+dbgOutLn	KEYWORD2
+dbgOut2	KEYWORD2
+dbgOutLn2	KEYWORD2
+initDebug	KEYWORD2
+dbgOutHex   KEYWORD2
+ELEMENTS	KEYWORD2
+
+#######################################
+# Constants (LITERAL1)
+#######################################

+ 9 - 0
libraries/MCStools/library.properties

@@ -0,0 +1,9 @@
+name=MCStools
+version=1.3.0
+author=Wilfried Klaas
+maintainer=Wilfried Klaas
+sentence=A library to add support for rc receivers. 
+paragraph=This library can read and decode PPM signals from simple RC receivers.
+category=Communication
+url=https://github.com/willie68/RCReceiver.git
+architectures=avr

+ 37 - 0
libraries/MCStools/makros.h

@@ -0,0 +1,37 @@
+/*
+  makros.cpp - Ein paar nützliche Makros - Version 0.2
+  Copyright (c) 2012 Wilfried Klaas.  All right reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef swap
+#define swap(x,y,T) { T TMP_SWAP = x; x = y; y = TMP_SWAP; }
+#endif 
+
+#ifndef between
+#define between(a,x,y) ((a >=x) && (a <= y))
+#endif
+
+#ifndef cbi
+#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
+#endif
+#ifndef sbi
+#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
+#endif
+
+#ifndef ELEMENTS
+#define ELEMENTS(x)    (sizeof(x) / sizeof(x[0]))
+#endif

+ 35 - 0
libraries/Switch/Examples/SwitchCallbackExample/SwitchCallbackExample.ino

@@ -0,0 +1,35 @@
+#include "Arduino.h"
+#include "avdweb_Switch.h"
+
+const byte toggleSwitchpin = 4;
+const byte multiresponseButtonpin = 12;
+
+Switch toggleSwitch = Switch(toggleSwitchpin);
+Switch multiresponseButton = Switch(multiresponseButtonpin);
+
+void buttonCallbackFunction(void* s) {
+  Serial.print("Button: ");
+  Serial.println((char*)s);
+}
+
+void toggleCallbackFunction(void* s) {
+  Serial.print("Toggle: ");
+  Serial.println((char*)s);
+}
+
+void setup()
+{
+  Serial.begin(9600);
+  toggleSwitch.setPushedCallback(&toggleCallbackFunction, (void*)"turned on");
+  toggleSwitch.setReleasedCallback(&toggleCallbackFunction, (void*)"turned off");
+
+  multiresponseButton.setLongPressCallback(&buttonCallbackFunction, (void*)"long press");
+  multiresponseButton.setDoubleClickCallback(&buttonCallbackFunction, (void*)"double click");
+  multiresponseButton.setSingleClickCallback(&buttonCallbackFunction, (void*)"single click");
+}
+
+void loop()
+{
+  toggleSwitch.poll();
+  multiresponseButton.poll();
+}

+ 46 - 0
libraries/Switch/Examples/SwitchExample/SwitchExample.ino

@@ -0,0 +1,46 @@
+#include "Arduino.h"
+#include "avdweb_Switch.h"
+
+const byte pushButtonpin = 2;
+const byte toggleSwitchpin = 4;
+const byte multiresponseButtonpin = 12;
+const byte alleventsButtonpin = 13;
+int i;
+
+Switch pushButton = Switch(pushButtonpin); // button to GND, use internal 20K pullup resistor
+Switch toggleSwitch = Switch(toggleSwitchpin);
+Switch multiresponseButton = Switch(multiresponseButtonpin);
+Switch alleventsButton = Switch(alleventsButtonpin);
+// Other examples of constructors
+// Switch pushButtonVCC = Switch(pushButtonpin, INPUT, HIGH); // button to VCC, 10k pull-down resistor, no internal pull-up resistor, HIGH polarity
+// Switch pushButton1ms = Switch(pushButtonpin, INPUT_PULLUP, LOW, 1); // debounceTime 1ms
+
+void setup()
+{ Serial.begin(9600);
+}
+
+void loop()
+{ // pushButton simple events
+  pushButton.poll();
+  if(pushButton.switched()) Serial.print("pushButton switched ");
+  if(pushButton.pushed()) {Serial.print("pushButton pushed "); Serial.print(++i); Serial.println(" times");}
+  if(pushButton.released()) Serial.println("pushButton released");
+
+  // toggleSwitch report status only when changed
+  if(toggleSwitch.poll()) {Serial.print("toggleSwitch status changed to "); Serial.println(toggleSwitch.on());}
+
+  // multiresponseButton complex events
+  multiresponseButton.poll();
+  if(multiresponseButton.longPress()) Serial.println("multiresponseButton longPress");
+  if(multiresponseButton.doubleClick()) Serial.println("multiresponseButton doubleClick");
+  if(multiresponseButton.singleClick()) Serial.println("multiresponseButton singleClick");
+
+  // alleventsButton complex events
+  alleventsButton.poll();
+  if(alleventsButton.switched()) {Serial.println("all_e_B switched."); Serial.print(" all_e_B status to "); Serial.print(alleventsButton.on()); Serial.println(".");}
+  if(alleventsButton.pushed()) {Serial.println(" all_e_B pushed.");}
+  if(alleventsButton.released()) Serial.println(" all_e_B released.");
+  if(alleventsButton.longPress()) Serial.println("  ==> all_e_B longPress.");
+  if(alleventsButton.doubleClick()) Serial.println("  ==> all_e_B doubleClick.");
+  if(alleventsButton.singleClick()) Serial.println("  ==> all_e_B singleClick.");
+}

+ 674 - 0
libraries/Switch/LICENSE

@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 338 - 0
libraries/Switch/README.md

@@ -0,0 +1,338 @@
+# Switch library
+
+## About
+Arduino library for debouncing switches and buttons. Supports detecting longPress and doubleClick. Supports defining callback functions.
+
+Available at: https://github.com/avandalen/avdweb_Switch
+
+#### General features of the Switch library
+- Performs not just de-bouncing, but also de-glitching against EMC pulses.
+- External pull-up resistors are not required.
+- Supports also long press, double click, and single click detection.
+- Callback functions.
+
+## Introduction
+Switches and push buttons need debouncing. It is straightforward to do this with software, using this library.
+
+For a complete description see: http://www.avdweb.nl/arduino/hardware-interfacing/simple-switch-debouncer.html
+
+## Using the Switch library
+
+Declare each switch or button, by indicanting its GPIO number:
+
+```
+Switch buttonGND = Switch(4); // GPIO 4
+```
+
+The library sets GPIO in input mode with an internal pull-up resistor by default. The constructor accepts several arguments including the particular input mode (e.g. without pull-up), whether voltage level high must be interpreted as on or off (argument `polarity` must indicate the pushed voltage level), and the duration of the time periods that define the behaviour.
+
+All switches have to be repeatedly polled individually to update the status. This is usually done in the `loop()` function.
+
+```
+buttonGND.poll();
+```
+
+After refreshing the status, it can be checked with get functions. For example:
+
+```
+if(buttonGND.pushed()) Serial.print("pushed");
+```
+
+Any event occurs based on the deglitched and debounced pin signal. See below for details on this function of the library that happens transparently.
+
+Each possible event (each switch-status) has its own get function:
+
+#### switched()
+
+It returns "true" if the pin voltage level changed, no matter the direction (from low to high or from high to low).
+
+#### on()
+
+It returns "true" if the pin voltage agrees with the one defined by `polarity` (which is LOW by default). Use only for toggle switches. It returns "true" as long as the switch is in the "on" position. The polarity of the switch in the "on" position has to be filled in correctly. There is no off() function, this is simply !on().
+
+#### pushed()
+
+It returns "true" if a button was pushed (switched towards the on position). Use only for push buttons. Note that this provides instant response and can be used as "single-click" if "double-click" and "long-press" are not watched events. "Pushed" occurs simultaneously with "double-click" and "long-press".
+
+#### released()
+
+It returns "true" if a push button was released (switched towards the off position), this will however rarely be used.
+
+#### longPress()
+
+It returns "true" if a push button is pressed longer than 300ms (by default). Note that a longPress() always will be preceded by pushed() from the first push.
+
+#### doubleClick()
+
+It returns "true" if a push button is double clicked within 250ms (by default). Note that a doubleClick() always will be preceded by pushed() from the first push.
+
+The anteceding pushed() event can't be avoided, because to restrict the pushed() function to single clicks it would have to wait for a possible second click, which would introduce an annoying delay. So, the action on doubleClick() has to undo the previous action on pushed().
+
+#### singleClick()
+
+It returns "true" if a push button is clicked once and the requirements for doubleClick and longPress are not met. The event thus occur several miliseconds after the actual push, because it depends on the other events not happening after the push. Use this if three different interactions are needed in combination with doubleClick and longPress. Note that a singleClick() always will be preceded by pushed(). Use pushed() instead if immediate response is required and there is no interest in monitoring doubleClick and longPress.
+
+
+#### Example
+
+See the example in the library for a complete working program.
+
+### Transparent signal filtering
+#### Deglitching
+Sudden short changes in the microcontroler power supply may create inexistent switched() events if the pin is polled in that instant. Deglitching is achieved because the software will not believe that a voltage change has happened (a swithed event) until the voltage remains in the new level for a minimum period. A voltage change will be ignored if it returns to the original level before that period.
+
+#### Debouncing
+Due to the elastic properties of the metals in the contacts they bounce away from each other after the initial contact creating false switched() events after an initial true switch, until the voltage stabilizes in the new level. Debouncing forces a refractary period after an initial switch, during which any voltage level change is ignored.
+
+### Using callback functions to be triggered by button events
+
+Callbacks can be used, instead of needing to check with an `if` statement whether the relevant event has occurred after calling `switch.poll()`.
+
+With a callback registered, Switch will run the defined function when the conditions are met at the time `poll()` is called. Calling `poll()` periodically is the only requirement.
+
+First, define a function with the action you want to perform, with no return type (void) and one argument, a pointer to some reference (or use nullptr if you don't need it.): 
+
+```C++
+void foo(void* ref) {
+  //your code;
+}
+``` 
+... and then call one of the "set callback" methods in the `setup()` function, like so: 
+
+```C++
+void setup() {
+  ... // Other setup code 
+  ...
+  int reference;
+  switch.setPushedCallback(&foo, &reference);
+  ...
+}
+``` 
+
+The available callback setting functions are `setPushedCallback()`, `setReleasedCallback()`, `setLongPressCallback()`, `setDoubleClickCallback()`, and `setSingleClickCallback()` which allow defining the functions that will be called on such events. If using a toggle switch and not a push button, the "pushed" event will be of interest when the switch is turned on, and "released" when it is turned off.
+
+If the conditions for more than one event occur simultaneously and there are callback functions registered for them, they will be executed in the order of the functions above.
+
+See the example in the library for a complete working program.
+
+### Notes
+
+The poll instruction must be called at least 50 times per second, i.e. every 20ms; it takes about 20us in Arduino.
+
+The button states are saved till the next poll. Then all previous button states will be cleared, so the button states must be read every poll interval, after calling the poll function.
+
+Reading a button several times within a poll interval gives the same value, so reading doesn't clear the button state.
+
+### SUGESTION: Using an interrupt service routine for polling the buttons
+
+Polling buttons has a high priority and should be done often. Slow functions such as Serial.print() may disrupt the timing.
+
+Polling could be done in a function triggered by a timed interrupt. Remember to keep the subsequent button actions short as you would do with any code in interrupts.
+
+For Arduino see here how to use an ISR for polling the buttons:
+
+```C++
+#include <Arduino.h>
+#include "avdweb_Switch.h"
+#include <FrequencyTimer2.h>
+
+Switch speedUpBtn(1);
+Switch speedDownBtn(2);
+Switch buttonLeft(3);
+Switch buttonRight(4);
+
+void setup(void)
+{ Serial.begin(9600);
+  FrequencyTimer2::setPeriod(1000);
+  FrequencyTimer2::setOnOverflow(timer2ISR);
+}
+
+void loop(void)
+{ printAll(); // run slow functions in loop()
+}
+
+void timer2ISR()
+{ pollAll(); // polling buttons has priority
+  buttonActions();
+}
+
+// you should implement pollAll(), buttonActions(), and printAll()
+```
+
+For ESP8266 use the [Ticker](https://arduino-esp8266.readthedocs.io/en/latest/libraries.html#ticker) library.
+
+
+### How to use successive button events
+
+With the Switch library, you can use all button events at the same time with the same button. For example pushed(), released(), doubleClick() and longPress(). To see an example of what can be achieved with several button events in order to perform different functions, run Windows Explorer: a single click selects a file and a double click opens it.
+
+#### Button pushed event followed by a longPress event
+
+A long-press generates first a pushed event and after 300ms (by default) the longPress event. This is not a shortcoming but a logical consequence. We can, of course, not always wait 300ms to see if a push might be a long push.
+
+#### Button pushed event followed by a doubleClick event
+
+The same happens with doubleClick, which also generates two pushed() events. When doubleClick is used, ignore the second pushed() result or don't call pushed(). When doubleClick is not needed, simply don't call doubleClick().
+
+#### Combining singleClick, doubleClick, and longPress events
+
+If these three events must be used toghether the best strategy is to stick to their get functions and avoid using pushed().
+
+## Hardware considerations
+
+#### Connecting switches to the microcontroler
+
+There is nothing needed beyond the switches, just connect the switches between the ground and a digital pin.
+
+#### Switch between GND and digital pin
+
+This is technically speaking the best solution and it is taken by the library as default. An external pull-up resistor is not needed but allowed.
+
+#### Switch between VCC(3.3V or 5V) and digital pin
+
+For switches connected to the Arduino power supply, the settings are: polarity = HIGH and pinmode = INPUT, which disables the internal pull-up resistor. Note that we need external pull-down resistors of about 10k here.
+
+## Questions
+
+Post questions on the [Arduino board](http://forum.arduino.cc/index.php?topic=379308) and let me know, I will reply there.
+
+Post issues on the github repository.
+
+## Explanation of the inner working
+
+### New: software deglitch
+
+Normally, just debouncing is used. But debouncing doesn't make the software insensitive to noise pulses, which could lead to dangerous situations: if there is a poll() at the moment of a noise pulse, the software can detect an activated switch. To prevent this, a deglitch function is added now: during a "deglitchPeriod", all input values have to be equal.
+
+### Software debounce, how does it work
+
+The software debounce algorithm is based on the following assumptions; the 50ms (by default) is the so-called debounce period:
+
+- The switch bounce time is less than 50ms.
+- The time between successive keystrokes is larger than 50ms.
+- A reaction time of 50ms is acceptable.
+
+If the above assumptions are met, the software debounce algorithm can be quite simple: a switch event is only accepted when the elapsed time since the last switch event is larger than the debounce period.
+
+A debounce period of 50ms is a safe value; it doesn't hurt the reaction time, and will handle even bad switches.
+
+See the following pseudocode:
+
+```C++
+if((current_deglitched != previous_debounced) & ((current_ms - last_switchedTime) >= debouncePeriod)) current_debounced = current_deglitched;
+// otherwise current_debounced stays the same as previous_debounced
+```
+
+### Overall functioning
+
+Several discrete signals (updated at poll times) are created. The raw signal is deglitched, the later debounced, and that one in turn is processed to generate a signal for each one of the events.
+
+### Timing diagram
+
+```	
+..........................................DEGLITCHING..............................
+
+                        ________________   _
+               on      |                | | |    _
+                       |                | | |   | |
+                       |                |_| |___| |__
+ analog        off_____|_____________________________|____________________________
+
+                        ________________   _     _
+ input            _____|                |_| |___| |_______________________________
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+
+ equal           0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+
+ deglitchPeriod          <--------><--   <--     <-  <--------><--------><--------
+                                    ___________________________
+ deglitched       _________________|                           |__________________
+
+ deglitchTime            ^         ^     ^       ^   ^         ^        ^
+
+ ..........................................DEBOUNCING.............................
+
+ debouncePeriod                    <-------------------------------->
+                                    _________________________________
+ debounced        _________________|                                 |____________
+                                    _                                 _
+ _switched        _________________| |_______________________________| |__________
+
+ switchedTime                      ^                                 ^
+
+
+**********************************************************************************
+........................................DOUBLE CLICK..............................
+
+                           __________         ______
+ debounced        ________|          |_______|      |_____________________________
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+                           _                  _
+ pushed          _________| |________________| |__________________________________
+
+ pushedTime               ^                  ^
+                                      _              _
+ released        ____________________| |____________| |___________________________
+
+ releasedTime                        ^              ^
+
+ doubleClickPeriod         <------------------------------------->
+                                              _
+ _doubleClick     ___________________________| |__________________________________
+
+
+........................................LONG PRESS................................
+
+                           ___________________________
+ debounced        ________|                           |___________________________
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+
+ longPressPeriod            <--------------->
+                            _                           _
+ _switched        _________| |_________________________| |________________________
+                                              __________
+ longPressDisable ___________________________|          |_________________________
+                                              _
+ _longPress       ___________________________| |__________________________________
+
+
+........................................SINGLE CLICK..............................
+
+                           __________                                 ______
+ debounced        ________|          |_______________________________|      |_____
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+
+ longPressPeriod           <--------------->
+ doubleClickPeriod         <------------------------------------->
+                            _         _                               _      _
+ _switched        _________| |_______| |_____________________________| |____| |___
+                                                                  _____
+ singleClickDisable______________________________________________|     |__________
+                                                                  _
+ _singleClick     _______________________________________________| |______________
+```
+
+### Additional information
+See also: [A Guide To Debouncing](http://www.eng.utah.edu/~cs5780/debouncing.pdf)
+
+
+### Licenses
+#### Library
+
+[![GNU License](https://www.gnu.org/graphics/gplv3-88x31.png)](https://www.gnu.org/licenses/gpl-3.0.en.html)
+
+Copyright (C) 2012  Albert van Dalen
+
+http://www.avdweb.nl
+
+This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+#### Documents
+
+[![bt-nc-sa](http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png)](http://creativecommons.org/licenses/by-nc-sa/3.0/)
+
+This document is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-nc-sa/3.0/).
+

+ 270 - 0
libraries/Switch/avdweb_Switch.cpp

@@ -0,0 +1,270 @@
+/*
+Switch.cpp
+Copyright (C) 2012  Albert van Dalen http://www.avdweb.nl
+This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses .
+
+AUTHOR: Albert van Dalen
+WEBSITE: http://www.avdweb.nl/arduino/hardware-interfacing/simple-switch-debouncer.html
+
+HISTORY:
+1.0.0    20-04-2013 _debouncePeriod=50
+1.0.1    22-05-2013 Added longPress, doubleClick
+1.0.2    01-12-2015 added process(input)
+1.0.3    15-01-2016 added deglitching
+1.0.5    25-01-2017 file renamed to avdweb_Switch
+1.1.0    28-07-2018 added callbacks (code by Sean Lanigan, added by Martin Laclaustra)
+1.2.0-rc 28-07-2017 added singleclick. Reorganize, keeping variables for each event in one function
+
+..........................................DEGLITCHING..............................
+
+                        ________________   _
+               on      |                | | |    _
+                       |                | | |   | |
+                       |                |_| |___| |__
+ analog        off_____|_____________________________|____________________________
+
+                        ________________   _     _
+ input            _____|                |_| |___| |_______________________________
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+
+ equal           0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+
+ deglitchPeriod          <--------><--   <--     <-  <--------><--------><--------
+                                    ___________________________
+ deglitched       _________________|                           |__________________
+
+ deglitchTime            ^         ^     ^       ^   ^         ^        ^
+
+ ..........................................DEBOUNCING.............................
+
+ debouncePeriod                    <-------------------------------->
+                                    _________________________________
+ debounced        _________________|                                 |____________
+                                    _                                 _
+ _switched        _________________| |_______________________________| |__________
+
+ switchedTime                      ^                                 ^
+
+
+**********************************************************************************
+........................................DOUBLE CLICK..............................
+
+                           __________         ______
+ debounced        ________|          |_______|      |_____________________________
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+                           _                  _
+ pushed          _________| |________________| |__________________________________
+
+ pushedTime               ^                  ^
+                                      _              _
+ released        ____________________| |____________| |___________________________
+
+ releasedTime                        ^              ^
+
+ doubleClickPeriod         <------------------------------------->
+                                              _
+ _doubleClick     ___________________________| |__________________________________
+
+
+........................................LONG PRESS................................
+
+                           ___________________________
+ debounced        ________|                           |___________________________
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+
+ longPressPeriod            <--------------->
+                            _                           _
+ _switched        _________| |_________________________| |________________________
+                                              __________
+ longPressDisable ___________________________|          |_________________________
+                                              _
+ _longPress       ___________________________| |__________________________________
+
+
+........................................SINGLE CLICK..............................
+
+                           __________                                 ______
+ debounced        ________|          |_______________________________|      |_____
+
+ poll            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+
+ longPressPeriod           <--------------->
+ doubleClickPeriod         <------------------------------------->
+                            _         _                               _      _
+ _switched        _________| |_______| |_____________________________| |____| |___
+                                                                  _____
+ singleClickDisable______________________________________________|     |__________
+                                                                  _
+ _singleClick     _______________________________________________| |______________
+
+*/
+
+#include "Arduino.h"
+#include "avdweb_Switch.h"
+
+Switch::Switch(byte _pin, byte PinMode, bool polarity, int debouncePeriod, int longPressPeriod, int doubleClickPeriod, int deglitchPeriod):
+pin(_pin), polarity(polarity), deglitchPeriod(deglitchPeriod), debouncePeriod(debouncePeriod), longPressPeriod(longPressPeriod), doubleClickPeriod(doubleClickPeriod)
+{ pinMode(pin, PinMode);
+  switchedTime = millis();
+  debounced = digitalRead(pin);
+  singleClickDisable = true;
+}
+
+bool Switch::poll()
+{ input = digitalRead(pin);
+  ms = millis();
+  return process();
+}
+
+bool Switch::process()
+{ deglitch();
+  debounce();
+  calcSingleClick();
+  calcDoubleClick();
+  calcLongPress();
+  if(switched())
+  { switchedTime = ms; //stores last times for future rounds
+    if(pushed())
+    { pushedTime = ms;
+    } else { releasedTime = ms;
+    }
+  }
+  triggerCallbacks();
+  return _switched;
+}
+
+void inline Switch::deglitch()
+{
+  if(input == lastInput) equal = 1;
+  else
+  { equal = 0;
+    deglitchTime = ms;
+  }
+  if(equal && ((ms - deglitchTime) > deglitchPeriod)) // max 50ms, disable deglitch: 0ms
+  { deglitched = input;
+    deglitchTime = ms;
+  }
+  lastInput = input;
+}
+
+void inline Switch::debounce()
+{
+  _switched = 0;
+  if((deglitched != debounced) && ((ms - switchedTime) > debouncePeriod))
+  { debounced = deglitched;
+    _switched = 1;
+  }
+}
+
+void inline Switch::calcSingleClick()
+{ _singleClick = false;
+  if(pushed())
+  { if((ms - pushedTime) >= doubleClickPeriod)
+    { singleClickDisable = false; //resets when pushed not in second click of doubleclick
+    } else { singleClickDisable = true; //silence single click in second cl. doublecl.
+    }
+  }
+  if(!singleClickDisable)
+  { _singleClick = !switched() && !on() && ((releasedTime - pushedTime) <= longPressPeriod) && ((ms - pushedTime) >= doubleClickPeriod); // true just one time between polls
+    singleClickDisable = _singleClick; // will be reset at next push
+  }
+}
+
+void inline Switch::calcDoubleClick()
+{ _doubleClick = pushed() && ((ms - pushedTime) < doubleClickPeriod);
+}
+
+void inline Switch::calcLongPress()
+{ _longPress = false;
+  if(released()) longPressDisable = false; //resets when released
+  if(!longPressDisable)
+  { _longPress = !switched() && on() && ((ms - pushedTime) > longPressPeriod); // true just one time between polls
+    longPressDisable = _longPress; // will be reset at next release
+  }
+}
+
+bool Switch::switched()
+{ return _switched;
+}
+
+bool Switch::on()
+{ return !(debounced^polarity);
+}
+
+bool Switch::pushed()
+{ return _switched && !(debounced^polarity);
+}
+
+bool Switch::released()
+{ return _switched && (debounced^polarity);
+}
+
+bool Switch::longPress()
+{ return _longPress;
+}
+
+bool Switch::doubleClick()
+{ return _doubleClick;
+}
+
+bool Switch::singleClick()
+{ return _singleClick;
+}
+
+void Switch::triggerCallbacks()
+{
+  if(_pushedCallback && pushed())
+  { _pushedCallback(_pushedCallbackParam);
+  }
+    else if(_releasedCallback && released())
+  { _releasedCallback(_releasedCallbackParam);
+  }
+
+  if(_longPressCallback && longPress())
+  { _longPressCallback(_longPressCallbackParam);
+  }
+
+  if(_doubleClickCallback && doubleClick())
+  { _doubleClickCallback(_doubleClickCallbackParam);
+  }
+
+  if(_singleClickCallback && singleClick())
+  { _singleClickCallback(_singleClickCallbackParam);
+  }
+}
+
+void Switch::setPushedCallback(switchCallback_t cb, void* param)
+{ /// Store the "pushed" callback function
+  _pushedCallback = cb;
+  _pushedCallbackParam = param;
+}
+
+void Switch::setReleasedCallback(switchCallback_t cb, void* param)
+{ /// Store the "released" callback function
+  _releasedCallback = cb;
+  _releasedCallbackParam = param;
+}
+
+void Switch::setLongPressCallback(switchCallback_t cb, void* param)
+{ /// Store the "long press" callback function
+  _longPressCallback = cb;
+  _longPressCallbackParam = param;
+}
+
+void Switch::setDoubleClickCallback(switchCallback_t cb, void* param)
+{ /// Store the "double click" callback function
+  _doubleClickCallback = cb;
+  _doubleClickCallbackParam = param;
+}
+
+void Switch::setSingleClickCallback(switchCallback_t cb, void* param)
+{ /// Store the "double click" callback function
+  _singleClickCallback = cb;
+  _singleClickCallbackParam = param;
+}

+ 68 - 0
libraries/Switch/avdweb_Switch.h

@@ -0,0 +1,68 @@
+/*
+Switch.cpp
+Copyright (C) 2012  Albert van Dalen http://www.avdweb.nl
+This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses .
+
+AUTHOR: Albert van Dalen
+WEBSITE: http://www.avdweb.nl/arduino/hardware-interfacing/simple-switch-debouncer.html
+*/
+
+#ifndef AVDWEB_SWITCH_H
+#define AVDWEB_SWITCH_H
+
+typedef void (*switchCallback_t)(void*);
+
+class Switch
+{
+public:	
+  Switch(byte _pin, byte PinMode=INPUT_PULLUP, bool polarity=LOW, int debouncePeriod=50, int longPressPeriod=300, int doubleClickPeriod=250, int deglitchPeriod=10);
+  bool poll(); // Returns 1 if switched
+  bool switched(); // will be refreshed by poll()
+  bool on();
+  bool pushed(); // will be refreshed by poll()
+  bool released(); // will be refreshed by poll()
+  bool longPress(); // will be refreshed by poll()
+  bool doubleClick(); // will be refreshed by poll()
+  bool singleClick(); // will be refreshed by poll()
+
+  // Set methods for event callbacks
+  void setPushedCallback(switchCallback_t cb, void* param = nullptr);
+  void setReleasedCallback(switchCallback_t cb, void* param = nullptr);
+  void setLongPressCallback(switchCallback_t cb, void* param = nullptr);
+  void setDoubleClickCallback(switchCallback_t cb, void* param = nullptr);
+  void setSingleClickCallback(switchCallback_t cb, void* param = nullptr);
+
+  protected:
+  bool process(); // not inline, used in child class
+  void inline deglitch();
+  void inline debounce();
+  void inline calcLongPress();
+  void inline calcDoubleClick();
+  void inline calcSingleClick();
+  void triggerCallbacks();
+
+  unsigned long deglitchTime, switchedTime, pushedTime, releasedTime, ms;
+  const byte pin;
+  const int deglitchPeriod, debouncePeriod, longPressPeriod, doubleClickPeriod;
+  const bool polarity;
+  bool input, lastInput, equal, deglitched, debounced, _switched, _longPress, longPressDisable, _doubleClick, _singleClick, singleClickDisable;
+
+  // Event callbacks
+  switchCallback_t _pushedCallback = nullptr;
+  switchCallback_t _releasedCallback = nullptr;
+  switchCallback_t _longPressCallback = nullptr;
+  switchCallback_t _doubleClickCallback = nullptr;
+  switchCallback_t _singleClickCallback = nullptr;
+
+  void* _pushedCallbackParam = nullptr;
+  void* _releasedCallbackParam = nullptr;
+  void* _longPressCallbackParam = nullptr;
+  void* _doubleClickCallbackParam = nullptr;
+  void* _singleClickCallbackParam = nullptr;
+
+};
+
+#endif

+ 36 - 0
libraries/Switch/keywords.txt

@@ -0,0 +1,36 @@
+#######################################
+# Syntax Coloring Map For Switch
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+Switch	KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+poll	KEYWORD2
+switched	KEYWORD2
+on	KEYWORD2
+pushed	KEYWORD2
+released	KEYWORD2
+longPress	KEYWORD2
+doubleClick	KEYWORD2
+singleClick	KEYWORD2
+setPushedCallback	KEYWORD2
+setReleasedCallback	KEYWORD2
+setLongPressCallback	KEYWORD2
+setDoubleClickCallback	KEYWORD2
+setSingleClickCallback	KEYWORD2
+
+#######################################
+# Instances (KEYWORD2)
+#######################################
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+

+ 10 - 0
libraries/Switch/library.properties

@@ -0,0 +1,10 @@
+name=Switch
+version=1.2.0
+author=Albert van Dalen
+maintainer=Albert van Dalen <a@maxun.cc>
+sentence=Arduino library for deglitching and debouncing switches and buttons.
+paragraph=Supports detecting longPress, doubleClick, and singleClick. Supports defining callback functions.
+category=Signal Input/Output
+url=https://github.com/avandalen/avdweb_Switch
+architectures=avr, samd, esp8266, esp32
+license=GPL-3.0+

+ 4 - 0
libraries/TM1637-1.1.0/.gitignore

@@ -0,0 +1,4 @@
+.idea
+.pioenvs
+.clang_complete
+.gcc-flags.json

+ 63 - 0
libraries/TM1637-1.1.0/.travis.yml

@@ -0,0 +1,63 @@
+# Continuous Integration (CI) is the practice, in software
+# engineering, of merging all developer working copies with a shared mainline
+# several times a day < http://docs.platformio.org/en/latest/ci/index.html >
+#
+# Documentation:
+#
+# * Travis CI Embedded Builds with PlatformIO
+#   < https://docs.travis-ci.com/user/integration/platformio/ >
+#
+# * PlatformIO integration with Travis CI
+#   < http://docs.platformio.org/en/latest/ci/travis.html >
+#
+# * User Guide for `platformio ci` command
+#   < http://docs.platformio.org/en/latest/userguide/cmd_ci.html >
+#
+#
+# Please choice one of the following templates (proposed below) and uncomment
+# it (remove "# " before each line) or use own configuration according to the
+# Travis CI documentation (see above).
+#
+
+
+#
+# Template #1: General project. Test it using existing `platformio.ini`.
+#
+
+# language: python
+# python:
+#     - "2.7"
+#
+# sudo: false
+# cache:
+#     directories:
+#         - "~/.platformio"
+#
+# install:
+#     - pip install -U platformio
+#
+# script:
+#     - platformio run
+
+
+#
+# Template #2: The project is intended to by used as a library with examples
+#
+
+language: python
+python:
+    - "2.7"
+
+sudo: false
+cache:
+    directories:
+        - "~/.platformio"
+
+env:
+    - PLATFORMIO_CI_SRC=examples/TM1637Test/TM1637Test.ino
+
+install:
+    - pip install -U platformio
+
+script:
+    - platformio ci --lib="." --board=nodemcuv2 --board=ethernet

+ 165 - 0
libraries/TM1637-1.1.0/LICENSE

@@ -0,0 +1,165 @@
+GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.

+ 27 - 0
libraries/TM1637-1.1.0/README.md

@@ -0,0 +1,27 @@
+TM1637
+======
+Arduino library for TM1637 (LED Driver)
+
+
+Description
+-----------
+An Arduino library for 7-segment display modules based on the TM1637 chip, such as Seeed Studio's [Grove 4 digit display](http://www.seeedstudio.com/depot/grove-4digit-display-p-1198.html). The TM1637 chip also has keyboard input capability, but it's not implemented in this library.
+
+Hardware Connection
+-------------------
+The display modules has two signal connection (and two power connections) which are CLK and DIO. These pins can be connected to any pair of digital pins on the Arduino. When an object is created, the pins should be configured. There is no limitation on the number of instances used concurrently (as long as each instance has a pin pair of its own)
+
+Installation
+------------
+The library is installed as any Arduino library, by copying the files into a directory on the library search path of the Arduino IDE
+
+Usage
+-----
+The library provides a single class named TM1637Display. An instance of this class provides the following functions:
+
+* `setSegments` - Set the raw value of the segments of each digit
+* `showNumberDec` - Display a decimal number
+* `showNumberDecEx` - Display a decimal number with decimal points or colon
+* `setBrightness` - Sets the brightness of the display
+
+The information given above is only a summary. Please refer to TM1637Display.h for more information. An example is included, demonstrating the operation of most of the functions.

+ 223 - 0
libraries/TM1637-1.1.0/TM1637Display.cpp

@@ -0,0 +1,223 @@
+
+//  Author: avishorp@gmail.com
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License, or (at your option) any later version.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+extern "C" {
+  #include <stdlib.h>
+  #include <string.h>
+  #include <inttypes.h>
+}
+
+#include <TM1637Display.h>
+#include <Arduino.h>
+
+#define TM1637_I2C_COMM1    0x40
+#define TM1637_I2C_COMM2    0xC0
+#define TM1637_I2C_COMM3    0x80
+
+//
+//      A
+//     ---
+//  F |   | B
+//     -G-
+//  E |   | C
+//     ---
+//      D
+const uint8_t digitToSegment[] = {
+ // XGFEDCBA
+  0b00111111,    // 0
+  0b00000110,    // 1
+  0b01011011,    // 2
+  0b01001111,    // 3
+  0b01100110,    // 4
+  0b01101101,    // 5
+  0b01111101,    // 6
+  0b00000111,    // 7
+  0b01111111,    // 8
+  0b01101111,    // 9
+  0b01110111,    // A
+  0b01111100,    // b
+  0b00111001,    // C
+  0b01011110,    // d
+  0b01111001,    // E
+  0b01110001     // F
+  };
+
+
+TM1637Display::TM1637Display(uint8_t pinClk, uint8_t pinDIO)
+{
+	// Copy the pin numbers
+	m_pinClk = pinClk;
+	m_pinDIO = pinDIO;
+
+	// Set the pin direction and default value.
+	// Both pins are set as inputs, allowing the pull-up resistors to pull them up
+    pinMode(m_pinClk, INPUT);
+    pinMode(m_pinDIO,INPUT);
+	digitalWrite(m_pinClk, LOW);
+	digitalWrite(m_pinDIO, LOW);
+}
+
+void TM1637Display::setBrightness(uint8_t brightness, bool on)
+{
+	m_brightness = (brightness & 0x7) | (on? 0x08 : 0x00);
+}
+
+void TM1637Display::setColon(bool colon)
+{
+  m_colon = colon;
+}
+
+void TM1637Display::setSegments(const uint8_t segments[], uint8_t length, uint8_t pos)
+{
+    // Write COMM1
+	start();
+	writeByte(TM1637_I2C_COMM1);
+	stop();
+
+	// Write COMM2 + first digit address
+	start();
+	writeByte(TM1637_I2C_COMM2 + (pos & 0x03));
+
+	// Write the data bytes
+    uint8_t currentByte = 0x00;
+	for (uint8_t k=0; k < length; k++) {
+      currentByte = segments[k] & 0x7f;
+      if(k == COLON_POSITION){
+        if(m_colon){
+          currentByte |= 0x80;
+        }
+      }
+      writeByte(currentByte);
+	}
+	stop();
+
+	// Write COMM3 + brightness
+	start();
+	writeByte(TM1637_I2C_COMM3 + (m_brightness & 0x0f));
+	stop();
+}
+
+void TM1637Display::showNumberDec(int num, bool leading_zero, uint8_t length, uint8_t pos)
+{
+  showNumberDecEx(num, 0, leading_zero, length, pos);
+}
+
+void TM1637Display::showNumberDecEx(int num, uint8_t dots, bool leading_zero,
+                                    uint8_t length, uint8_t pos)
+{
+  uint8_t digits[4];
+	const static int divisors[] = { 1, 10, 100, 1000 };
+	bool leading = true;
+
+	for(int8_t k = 0; k < 4; k++) {
+	    int divisor = divisors[4 - 1 - k];
+		int d = num / divisor;
+    uint8_t digit = 0;
+
+		if (d == 0) {
+		  if (leading_zero || !leading || (k == 3))
+		      digit = encodeDigit(d);
+	      else
+		      digit = 0;
+		}
+		else {
+			digit = encodeDigit(d);
+			num -= d * divisor;
+			leading = false;
+		}
+    
+    // Add the decimal point/colon to the digit
+    digit |= (dots & 0x80); 
+    dots <<= 1;
+    
+    digits[k] = digit;
+	}
+
+	setSegments(digits + (4 - length), length, pos);
+}
+
+
+void TM1637Display::bitDelay()
+{
+	delayMicroseconds(50);
+}
+
+void TM1637Display::start()
+{
+  pinMode(m_pinDIO, OUTPUT);
+  bitDelay();
+}
+
+void TM1637Display::stop()
+{
+	pinMode(m_pinDIO, OUTPUT);
+	bitDelay();
+	pinMode(m_pinClk, INPUT);
+	bitDelay();
+	pinMode(m_pinDIO, INPUT);
+	bitDelay();
+}
+
+bool TM1637Display::writeByte(uint8_t b)
+{
+  uint8_t data = b;
+
+  // 8 Data Bits
+  for(uint8_t i = 0; i < 8; i++) {
+    // CLK low
+    pinMode(m_pinClk, OUTPUT);
+    bitDelay();
+
+	// Set data bit
+    if (data & 0x01)
+      pinMode(m_pinDIO, INPUT);
+    else
+      pinMode(m_pinDIO, OUTPUT);
+
+    bitDelay();
+
+	// CLK high
+    pinMode(m_pinClk, INPUT);
+    bitDelay();
+    data = data >> 1;
+  }
+
+  // Wait for acknowledge
+  // CLK to zero
+  pinMode(m_pinClk, OUTPUT);
+  pinMode(m_pinDIO, INPUT);
+  bitDelay();
+
+  // CLK to high
+  pinMode(m_pinClk, INPUT);
+  bitDelay();
+  uint8_t ack = digitalRead(m_pinDIO);
+  if (ack == 0)
+    pinMode(m_pinDIO, OUTPUT);
+
+
+  bitDelay();
+  pinMode(m_pinClk, OUTPUT);
+  bitDelay();
+
+  return ack;
+}
+
+uint8_t TM1637Display::encodeDigit(uint8_t digit)
+{
+	return digitToSegment[digit & 0x0f];
+}

+ 129 - 0
libraries/TM1637-1.1.0/TM1637Display.h

@@ -0,0 +1,129 @@
+//  Author: avishorp@gmail.com
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License, or (at your option) any later version.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef __TM1637DISPLAY__
+#define __TM1637DISPLAY__
+
+#include <inttypes.h>
+
+#define SEG_A   0b00000001
+#define SEG_B   0b00000010
+#define SEG_C   0b00000100
+#define SEG_D   0b00001000
+#define SEG_E   0b00010000
+#define SEG_F   0b00100000
+#define SEG_G   0b01000000
+
+// Defines which element's highest bit is the colon's control bit
+#define COLON_POSITION 1
+
+class TM1637Display {
+
+public:
+  //! Initialize a TM1637Display object, setting the clock and
+  //! data pins.
+  //!
+  //! @param pinClk - The number of the digital pin connected to the clock pin of the module
+  //! @param pinDIO - The number of the digital pin connected to the DIO pin of the module
+  TM1637Display(uint8_t pinClk, uint8_t pinDIO);
+
+  //! Sets the brightness of the display.
+  //!
+  //! The setting takes effect when a command is given to change the data being
+  //! displayed.
+  //!
+  //! @param brightness A number from 0 (lowes brightness) to 7 (highest brightness)
+  //! @param on Turn display on or off
+  void setBrightness(uint8_t brightness, bool on = true);
+
+   //! Sets the colon indicator mode on or off
+  //! @param colon When true, lights up the colon on next use of showNumberDec
+  void setColon(const bool colon);
+
+  //! Display arbitrary data on the module
+  //!
+  //! This function receives raw segment values as input and displays them. The segment data
+  //! is given as a byte array, each byte corresponding to a single digit. Within each byte,
+  //! bit 0 is segment A, bit 1 is segment B etc.
+  //! The function may either set the entire display or any desirable part on its own. The first
+  //! digit is given by the @ref pos argument with 0 being the leftmost digit. The @ref length
+  //! argument is the number of digits to be set. Other digits are not affected.
+  //!
+  //! @param segments An array of size @ref length containing the raw segment values
+  //! @param length The number of digits to be modified
+  //! @param pos The position from which to start the modification (0 - leftmost, 3 - rightmost)
+  void setSegments(const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0);
+
+  //! Displayes a decimal number
+  //!
+  //! Dispalyes the given argument as a decimal number
+  //!
+  //! @param num The number to be shown
+  //! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are
+  //!        blank
+  //! @param length The number of digits to set. The user must ensure that the number to be shown
+  //!        fits to the number of digits requested (for example, if two digits are to be displayed,
+  //!        the number must be between 0 to 99)
+  //! @param pos The position most significant digit (0 - leftmost, 3 - rightmost)
+  void showNumberDec(int num, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0);
+
+  //! Displayes a decimal number, with dot control
+  //!
+  //! Dispalyes the given argument as a decimal number. The dots between the digits (or colon)
+  //! can be individually controlled
+  //!
+  //! @param num The number to be shown
+  //! @param dots Dot enable. The argument is a bitmask, with each bit corresponding to a dot
+  //!        between the digits (or colon mark, as implemented by each module). The MSB is the 
+  //!        leftmost dot of the digit being update. For example, if pos is 1, the MSB of dots
+  //!        will correspond the dot near digit no. 2 from the left. Dots are updated only on
+  //!        those digits actually being update (that is, no more than len digits)
+  //! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are
+  //!        blank
+  //! @param length The number of digits to set. The user must ensure that the number to be shown
+  //!        fits to the number of digits requested (for example, if two digits are to be displayed,
+  //!        the number must be between 0 to 99)
+  //! @param pos The position least significant digit (0 - leftmost, 3 - rightmost)
+  void showNumberDecEx(int num, uint8_t dots = 0, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0);
+
+  //! Translate a single digit into 7 segment code
+  //!
+  //! The method accepts a number between 0 - 15 and converts it to the
+  //! code required to display the number on a 7 segment display.
+  //! Numbers between 10-15 are converted to hexadecimal digits (A-F)
+  //!
+  //! @param digit A number between 0 to 15
+  //! @return A code representing the 7 segment image of the digit (LSB - segment A;
+  //!         bit 6 - segment G; bit 7 - always zero)
+  uint8_t encodeDigit(uint8_t digit);
+
+protected:
+   void bitDelay();
+
+   void start();
+
+   void stop();
+
+   bool writeByte(uint8_t b);
+
+private:
+	uint8_t m_pinClk;
+	uint8_t m_pinDIO;
+	uint8_t m_brightness;
+    bool m_colon;
+};
+
+#endif // __TM1637DISPLAY__

BIN
libraries/TM1637-1.1.0/docs/TM1637_ V2.4.pdf


BIN
libraries/TM1637-1.1.0/docs/TM1637_V2.4_EN.pdf


+ 112 - 0
libraries/TM1637-1.1.0/examples/TM1637Test/TM1637Test.ino

@@ -0,0 +1,112 @@
+#include <Arduino.h>
+#include <TM1637Display.h>
+
+// Module connection pins (Digital Pins)
+#define CLK 2
+#define DIO 3
+
+// The amount of time (in milliseconds) between tests
+#define TEST_DELAY   2000
+
+const uint8_t SEG_DONE[] = {
+	SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,           // d
+	SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F,   // O
+	SEG_C | SEG_E | SEG_G,                           // n
+	SEG_A | SEG_D | SEG_E | SEG_F | SEG_G            // E
+	};
+
+TM1637Display display(CLK, DIO);
+
+void setup()
+{
+}
+
+void loop()
+{
+  int k;
+  uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
+  display.setBrightness(0x0f);
+
+  // All segments on
+  display.setSegments(data);
+  delay(TEST_DELAY);
+
+  // Selectively set different digits
+  data[0] = 0b01001001;
+  data[1] = display.encodeDigit(1);
+  data[2] = display.encodeDigit(2);
+  data[3] = display.encodeDigit(3);
+
+  for(k = 3; k >= 0; k--) {
+	display.setSegments(data, 1, k);
+	delay(TEST_DELAY);
+	}
+
+  display.setSegments(data+2, 2, 2);
+  delay(TEST_DELAY);
+
+  display.setSegments(data+2, 2, 1);
+  delay(TEST_DELAY);
+
+  display.setSegments(data+1, 3, 1);
+  delay(TEST_DELAY);
+
+
+  // Show decimal numbers with/without leading zeros
+  bool lz = false;
+  for (uint8_t z = 0; z < 2; z++) {
+	for(k = 0; k < 10000; k += k*4 + 7) {
+		display.showNumberDec(k, lz);
+		delay(TEST_DELAY);
+	}
+	lz = true;
+  }
+
+  // Show decimal number whose length is smaller than 4
+  for(k = 0; k < 4; k++)
+	data[k] = 0;
+  display.setSegments(data);
+
+	// Run through all the dots
+	for(k=0; k <= 4; k++) {
+		display.showNumberDecEx(0, (0x80 >> k), true);
+		delay(TEST_DELAY);
+	}
+
+  display.showNumberDec(153, false, 3, 1);
+  delay(TEST_DELAY);
+  display.showNumberDec(22, false, 2, 2);
+  delay(TEST_DELAY);
+  display.showNumberDec(0, true, 1, 3);
+  delay(TEST_DELAY);
+  display.showNumberDec(0, true, 1, 2);
+  delay(TEST_DELAY);
+  display.showNumberDec(0, true, 1, 1);
+  delay(TEST_DELAY);
+  display.showNumberDec(0, true, 1, 0);
+  delay(TEST_DELAY);
+
+  // Brightness Test
+  for(k = 0; k < 4; k++)
+	data[k] = 0xff;
+  for(k = 0; k < 7; k++) {
+    display.setBrightness(k);
+    display.setSegments(data);
+    delay(TEST_DELAY);
+  }
+  
+  // On/Off test
+  for(k = 0; k < 4; k++) {
+    display.setBrightness(7, false);  // Turn off
+    display.setSegments(data);
+    delay(TEST_DELAY);
+    display.setBrightness(7, true); // Turn on
+    display.setSegments(data);
+    delay(TEST_DELAY);  
+  }
+
+  // Done!
+  display.setSegments(SEG_DONE);
+
+  while(1);
+}

+ 14 - 0
libraries/TM1637-1.1.0/library.json

@@ -0,0 +1,14 @@
+{
+  "name": "TM1637",
+  "keywords": "LED, TM1637",
+  "description": "Arduino library for TM1637 (LED Driver)",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/avishorp/TM1637.git"
+  },
+  "frameworks": "arduino",
+  "platforms": [
+    "atmelavr",
+    "espressif"
+  ]
+}

+ 217 - 0
libraries/TM1637-1.1.0/old/TM1637Display.cpp

@@ -0,0 +1,217 @@
+
+//  Author: avishorp@gmail.com
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License, or (at your option) any later version.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+extern "C" {
+  #include <stdlib.h>
+  #include <string.h>
+  #include <inttypes.h>
+}
+
+#include <TM1637Display.h>
+#include <Arduino.h>
+
+#define TM1637_I2C_COMM1    0x40
+#define TM1637_I2C_COMM2    0xC0
+#define TM1637_I2C_COMM3    0x80
+
+//
+//      A
+//     ---
+//  F |   | B
+//     -G-
+//  E |   | C
+//     ---
+//      D
+const uint8_t digitToSegment[] = {
+ // XGFEDCBA
+  0b00111111,    // 0
+  0b00000110,    // 1
+  0b01011011,    // 2
+  0b01001111,    // 3
+  0b01100110,    // 4
+  0b01101101,    // 5
+  0b01111101,    // 6
+  0b00000111,    // 7
+  0b01111111,    // 8
+  0b01101111,    // 9
+  0b01110111,    // A
+  0b01111100,    // b
+  0b00111001,    // C
+  0b01011110,    // d
+  0b01111001,    // E
+  0b01110001     // F
+  };
+
+
+TM1637Display::TM1637Display(uint8_t pinClk, uint8_t pinDIO)
+{
+	// Copy the pin numbers
+	m_pinClk = pinClk;
+	m_pinDIO = pinDIO;
+	
+	// Set the pin direction and default value.
+	// Both pins are set as inputs, allowing the pull-up resistors to pull them up
+    pinMode(m_pinClk, INPUT);
+    pinMode(m_pinDIO,INPUT);
+	digitalWrite(m_pinClk, LOW);
+	digitalWrite(m_pinDIO, LOW);
+}
+
+void TM1637Display::setBrightness(uint8_t brightness)
+{
+  if(brightness > 0){
+  	m_brightness = ((brightness - 1) & 0x07) | 0x08;
+  } else {
+    m_brightness = 0x00;
+  }
+}
+
+void TM1637Display::setColon(bool colon)
+{
+  m_colon = colon;
+}
+
+void TM1637Display::setSegments(const uint8_t segments[], uint8_t length, uint8_t pos)
+{
+    // Write COMM1
+	start();
+	writeByte(TM1637_I2C_COMM1);
+	stop();
+	
+	// Write COMM2 + first digit address
+	start();
+	writeByte(TM1637_I2C_COMM2 + (pos & 0x03));
+  
+	// Write the data bytes
+  uint8_t currentByte = 0x00; 
+	for (uint8_t k=0; k < length; k++){
+    currentByte = segments[k] & 0x7f;
+    if(k == COLON_POSITION){
+      if(m_colon){
+        currentByte |= 0x80;
+      }
+    }
+    writeByte(currentByte);
+  }
+	
+	stop();
+
+	// Write COMM3 + brightness
+	start();
+	writeByte(TM1637_I2C_COMM3 + (m_brightness & 0x0f));
+	stop();
+}
+ 
+void TM1637Display::showNumberDec(int num, bool leading_zero, uint8_t length, uint8_t pos)
+{
+	uint8_t digits[4];
+	const static int divisors[] = { 1, 10, 100, 1000 };
+	bool leading = true;
+	
+	for(int8_t k = 0; k < 4; k++) {
+	    int divisor = divisors[4 - 1 - k];
+		int d = num / divisor;
+		
+		if (d == 0) {
+		  if (leading_zero || !leading || (k == 3))
+		    digits[k] = encodeDigit(d);
+	      else
+		    digits[k] = 0;
+		}
+		else {
+			digits[k] = encodeDigit(d);
+			num -= d * divisor;
+			leading = false;
+		}
+	}
+	
+	setSegments(digits + (4 - length), length, pos);
+}
+
+void TM1637Display::bitDelay()
+{
+	delayMicroseconds(50);
+}
+   
+void TM1637Display::start()
+{
+  pinMode(m_pinDIO, OUTPUT);
+  bitDelay();
+}
+   
+void TM1637Display::stop()
+{
+	pinMode(m_pinDIO, OUTPUT);
+	bitDelay();
+	pinMode(m_pinClk, INPUT);
+	bitDelay();
+	pinMode(m_pinDIO, INPUT);
+	bitDelay();
+}
+  
+bool TM1637Display::writeByte(uint8_t b)
+{
+  uint8_t data = b;
+
+  // 8 Data Bits
+  for(uint8_t i = 0; i < 8; i++) {
+    // CLK low
+    pinMode(m_pinClk, OUTPUT);
+    bitDelay();
+    
+	// Set data bit
+    if (data & 0x01)
+      pinMode(m_pinDIO, INPUT);
+    else
+      pinMode(m_pinDIO, OUTPUT);
+    
+    bitDelay();
+	
+	// CLK high
+    pinMode(m_pinClk, INPUT);
+    bitDelay();
+    data = data >> 1;
+  }
+  
+  // Wait for acknowledge
+  // CLK to zero
+  pinMode(m_pinClk, OUTPUT);
+  pinMode(m_pinDIO, INPUT);
+  bitDelay();
+  
+  // CLK to high
+  pinMode(m_pinClk, INPUT);
+  bitDelay();
+  uint8_t ack = digitalRead(m_pinDIO);
+  if (ack == 0)
+    pinMode(m_pinDIO, OUTPUT);
+	
+	
+  bitDelay();
+  pinMode(m_pinClk, OUTPUT);
+  bitDelay();
+  
+  return ack;
+}
+
+uint8_t TM1637Display::encodeDigit(uint8_t digit)
+{
+	return digitToSegment[digit & 0x0f];
+}
+
+   
+

+ 109 - 0
libraries/TM1637-1.1.0/old/TM1637Display.h

@@ -0,0 +1,109 @@
+//  Author: avishorp@gmail.com
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License, or (at your option) any later version.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef __TM1637DISPLAY__
+#define __TM1637DISPLAY__
+
+#include <inttypes.h>
+
+#define SEG_A   0b00000001
+#define SEG_B   0b00000010
+#define SEG_C   0b00000100
+#define SEG_D   0b00001000
+#define SEG_E   0b00010000
+#define SEG_F   0b00100000
+#define SEG_G   0b01000000
+
+// Defines which element's highest bit is the colon's control bit
+#define COLON_POSITION 1
+
+class TM1637Display {
+
+public:
+  //! Initialize a TM1637Display object, setting the clock and
+  //! data pins.
+  //!
+  //! @param pinClk - The number of the digital pin connected to the clock pin of the module
+  //! @param pinDIO - The number of the digital pin connected to the DIO pin of the module
+  TM1637Display(uint8_t pinClk, uint8_t pinDIO);
+  
+  //! Sets the brightness of the display.
+  //!
+  //! The setting takes effect when a command is given to change the data being
+  //! displayed.
+  //!
+  //! @param brightness A number from 0 (Off) to 8 (highest brightness)
+  void setBrightness(uint8_t brightness);
+  
+  //! Sets the colon indicator mode on or off
+  //! @param colon When true, lights up the colon on next use of showNumberDec
+  void setColon(const bool colon);
+  
+  //! Display arbitrary data on the module
+  //!
+  //! This function receives raw segment values as input and displays them. The segment data
+  //! is given as a byte array, each byte corresponding to a single digit. Within each byte,
+  //! bit 0 is segment A, bit 1 is segment B etc.
+  //! The function may either set the entire display or any desirable part on its own. The first
+  //! digit is given by the @ref pos argument with 0 being the leftmost digit. The @ref length
+  //! argument is the number of digits to be set. Other digits are not affected.
+  //!
+  //! @param segments An array of size @ref length containing the raw segment values
+  //! @param length The number of digits to be modified
+  //! @param pos The position from which to start the modification (0 - leftmost, 3 - rightmost)
+  void setSegments(const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0);
+  
+  //! Displayes a decimal number
+  //!
+  //! Dispalyes the given argument as a decimal number
+  //!
+  //! @param num The number to be shown
+  //! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are
+  //!        blank
+  //! @param length The number of digits to set. The user must ensure that the number to be shown
+  //!        fits to the number of digits requested (for example, if two digits are to be displayed,
+  //!        the number must be between 0 to 99)
+  //! @param pos The position least significant digit (0 - leftmost, 3 - rightmost)
+  void showNumberDec(int num, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0);
+  
+  //! Translate a single digit into 7 segment code
+  //!
+  //! The method accepts a number between 0 - 15 and converts it to the
+  //! code required to display the number on a 7 segment display.
+  //! Numbers between 10-15 are converted to hexadecimal digits (A-F)
+  //!
+  //! @param digit A number between 0 to 15
+  //! @return A code representing the 7 segment image of the digit (LSB - segment A;
+  //!         bit 6 - segment G; bit 7 - always zero)
+  uint8_t encodeDigit(uint8_t digit);
+
+protected:
+   void bitDelay();
+   
+   void start();
+   
+   void stop();
+   
+   bool writeByte(uint8_t b);
+   
+private:
+	uint8_t m_pinClk;
+	uint8_t m_pinDIO;
+	uint8_t m_brightness;
+  bool m_colon;
+};
+
+#endif // __TM1637DISPLAY__

+ 28 - 0
libraries/TM1637-1.1.0/platformio.ini

@@ -0,0 +1,28 @@
+#
+# Project Configuration File
+#
+# A detailed documentation with the EXAMPLES is located here:
+# http://docs.platformio.org/en/latest/projectconf.html
+#
+
+# A sign `#` at the beginning of the line indicates a comment
+# Comment lines are ignored.
+
+# Simple and base environment
+# [env:mybaseenv]
+# platform = %INSTALLED_PLATFORM_NAME_HERE%
+# framework =
+# board =
+#
+# Automatic targets - enable auto-uploading
+# targets = upload
+
+[env:nodemcuv2]
+platform = espressif
+framework = arduino
+board = nodemcuv2
+
+[env:ethernet]
+platform = atmelavr
+framework = arduino
+board = ethernet

+ 7 - 0
libraries/TM1637-1.1.0/release_notes.md

@@ -0,0 +1,7 @@
+- V1.1.0
+  * Add support for decimal points/colon
+  * Minor fixes
+  
+- V1.0.0
+  * Initial release
+