diff --git a/LibreMetric.ino b/LibreMetric.ino index bf1faaa..d442305 100644 --- a/LibreMetric.ino +++ b/LibreMetric.ino @@ -11,28 +11,9 @@ #include #include // https://github.com/markruys/arduino-Max72xxPanel #include -#include -// in a terminal: telnet esp IP -#ifdef DEBUG_TELNET -WiFiServer telnetServer(23); -WiFiClient telnetClient; -#endif - -// ################# Macros for debugging ################ -#ifdef DEBUG_TELNET -#define DEBUG_PRINT(x) telnetClient.print(x) -#define DEBUG_PRINTF(x,y) telnetClient.printf(x,y) -#define DEBUG_PRINT_WITH_FMT(x, fmt) telnetClient.print(x, fmt) -#define DEBUG_PRINTLN(x) telnetClient.println(x) -#define DEBUG_PRINTLN_WITH_FMT(x, fmt) telnetClient.println(x, fmt) -#else -#define DEBUG_PRINT(x) Serial.print(x) -#define DEBUG_PRINTF(x,y) Serial.printf(x,y) -#define DEBUG_PRINT_WITH_FMT(x, fmt) Serial.print(x, fmt) -#define DEBUG_PRINTLN(x) Serial.println(x) -#define DEBUG_PRINTLN_WITH_FMT(x, fmt) Serial.println(x, fmt) -#endif +#include "OTAsetup.h" +#include "d_helper.h" //################# DISPLAY CONNECTIONS ################ @@ -61,38 +42,19 @@ int numberOfVerticalDisplays = 1; //################## INITIALIZING ###################### char time_value[20]; String message, webpage; -ESP8266WebServer server(PORT); +ESP8266WebServer server(PORT); Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays); -/////////////////////////////////////////////////////////////////////////// -// TELNET -/////////////////////////////////////////////////////////////////////////// -/* - Function called to handle Telnet clients - https://www.youtube.com/watch?v=j9yW10OcahI -*/ -#ifdef DEBUG_TELNET -void handleTelnet(void) { - if (telnetServer.hasClient()) { - if (!telnetClient || !telnetClient.connected()) { - if (telnetClient) { - telnetClient.stop(); - } - telnetClient = telnetServer.available(); - } else { - telnetServer.available().stop(); - } - } -} -#endif void setup() { Serial.begin(115200); // initialize serial communications - DEBUG_PRINT("\n\r"); - matrix.fillScreen(LOW); //clr screen - + DEBUG_PRINT(F("\n\r")); + matrix.fillScreen(LOW); //clr screen + + initOTA(); + for (int i=0; i