From cde03edb4415b25240546fb0dc68c44f8f245909 Mon Sep 17 00:00:00 2001 From: Stefan Ostermann Date: Fri, 17 Sep 2021 19:35:55 +0200 Subject: [PATCH] working clock with 3 displays --- src/disp.h | 2 +- src/main.cpp | 177 ++++++++++++++++++++++++++++----------------------- 2 files changed, 97 insertions(+), 82 deletions(-) diff --git a/src/disp.h b/src/disp.h index 016090b..88d9e8c 100644 --- a/src/disp.h +++ b/src/disp.h @@ -27,7 +27,7 @@ void fadeIn(int max, int time, LedControl lc); // source: https://www.best-microcontroller-projects.com/max7219.html // For LedControl, I have to mirror each character. PROGMEM const unsigned char CH[] = { -3, 8, B0000000, B0000000, B0000000, B0000000, B0000000, // space +2, 8, B0000000, B0000000, B0000000, B0000000, B0000000, // space 1, 8, B1011111, B0000000, B0000000, B0000000, B0000000, // ! 3, 8, B0000011, B0000000, B0000011, B0000000, B0000000, // " 5, 8, B0010100, B0111110, B0010100, B0111110, B0010100, // # diff --git a/src/main.cpp b/src/main.cpp index 974a225..bf6cf14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,13 +46,23 @@ DateTime now; #define MAX_CS D6 #define MAX_DIN D7 -LedControl lc = LedControl(MAX_DIN, MAX_CLK, MAX_CS, 2); +LedControl lc = LedControl(MAX_DIN, MAX_CLK, MAX_CS, 3); /* we always wait a bit between updates of the display */ unsigned long delaytime = 500; +char str[24]; + void configModeCallback(WiFiManager *myWiFiManager); +ESP8266WebServer server(80); + +void handleRoot(); // function prototypes for HTTP handlers +void handleNotFound(); +void handleBody(); +void reconnect(); +void setTime(char* timeStr); +String SendHTML(); void setup() { @@ -60,16 +70,9 @@ void setup() //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around WiFiManager wifiManager; - //reset settings - for testing - //wifiManager.resetSettings(); - //set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode - - /* wifiManager.setAPCallback(configModeCallback); - - //fetches ssid and pass and tries to connect //if it does not connect it starts an access point with the specified name //here "AutoConnectAP" @@ -82,30 +85,22 @@ void setup() delay(1000); } - - //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); - */ + + server.on("/", handleRoot); + server.on("/set_time", handleBody); + server.onNotFound(handleNotFound); + + server.begin(); + Serial.println("HTTP server started"); + /* The MAX72XX is in power-saving mode on startup, we have to do a wakeup call */ - - lc.shutdown(0, false); - lc.shutdown(1, false); - - int devices = lc.getDeviceCount(); - Serial.print("devices: "); - Serial.println(devices, 10); - - /* Set the brightness to a medium values */ - - lc.setIntensity(0, 15); - - lc.clearDisplay(0); - - lc.setIntensity(1, 15); - - lc.clearDisplay(1); + for (int i=0;i\n"; + ptr += "TooManySevenSegmentsClock\n"; + ptr += "\n"; + ptr += "\n"; + ptr += "\n"; + ptr += "
\n"; + ptr += "

TooManySevenSegmentsClock

\n"; + + ptr += "

Time: "; + ptr += "

"; + + ptr += "
"; + ptr += "

"; + ptr += "

"; + ptr += " "; + ptr += "
"; + + + ptr += "
\n"; + ptr += "\n"; + ptr += "\n"; + return ptr; +} \ No newline at end of file