diff --git a/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr.ino b/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr.ino index 4c40dd9..451de35 100644 --- a/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr.ino +++ b/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr.ino @@ -1,10 +1,15 @@ /* N-Tools 2023 + "ESP32 Dev Module" 231112 -> Webseite Optimiert; kleinigkeiten für Uli; 231210 -> Fehler in der Schrift NT7x10 behoben + 240306 -> ??? + 240517 -> V2.3 WiFi.setAutoReconnect(true); + 250702 -> V2.4 Wochennummern korrektur + 251207 -> V2.5 NTP Überarbeitet; Webserver send_P ausgebaut */ -#define VERSION (char *) "V2.1" +#define VERSION (char *) "V2.5" char ChipID[10] = "ERROR"; uint64_t macAddress = ESP.getEfuseMac(); @@ -32,7 +37,7 @@ uint64_t macAddressTrunc = (macAddress << 40); #define NUM_COLS 1 // Number of INDIVIDUAL PANELS per ROW #define PANEL_CHAIN NUM_ROWS*NUM_COLS // total number of panels chained one to another -//#define PIXEL_COLOR_DEPTH_BITS 2 +#define PIXEL_COLOR_DEPTH_BITS 4 // library includes //#include @@ -44,8 +49,9 @@ MatrixPanel_I2S_DMA *display = nullptr; #include #include #include -#include +#define ELEGANTOTA_USE_ASYNC_WEBSERVER 1 #include +#include #include AsyncWebServer webServer(80); DNSServer dnsServer; @@ -96,7 +102,7 @@ MatrixPanel_I2S_DMA *display = nullptr; } void html_root(AsyncWebServerRequest *request); void html_root(AsyncWebServerRequest *request) { - request->send_P(200, "text/html", html_page_index, html_processor); + request->send(200, "text/html", html_page_index, html_processor); } void html_poll(AsyncWebServerRequest *request); @@ -116,7 +122,8 @@ MatrixPanel_I2S_DMA *display = nullptr; bool doRTCSecond = false; #include -#include +#include +#include long ti_second = 0; float brightness = 1.0; @@ -170,14 +177,23 @@ void doClearTacticalLEDs(uint8_t x=0,uint8_t y=0){ //eigene Schriften #include +#include #include #include -#include +//#include #include -#include -#include +//#include +//#include +void delay_ex(uint16_t _ms){ + for(uint16_t ms = 0;ms<_ms;ms++){ + yield(); + //esp_task_wdt_reset(); + delay(1); + } + +} void showNTOOLS(void){ uint8_t zeile=12; @@ -201,15 +217,15 @@ void drawSeconds(time_t t, uint8_t x=0, uint8_t y=0){ uint8_t g = timeColor[1]; uint8_t b = timeColor[2]; - for(uint8_t i=0;i<16;i++){ - display->drawFastHLine(x,y+i, 21, 0); + for(uint8_t i=0;i<8;i++){ + display->drawFastHLine(x,y+i, 13, 0); } tmp = second(t); - Out10x16Char((tmp/10)+0x30,x,y,r,g,b); + Out6x8Char((tmp/10)+0x30,x,y,r,g,b); tmp -= (tmp/10)*10; - x += 11; - Out10x16Char((tmp)+0x30,x,y,r,g,b); + x += 7; + Out6x8Char((tmp)+0x30,x,y,r,g,b); } void drawTime(time_t t,uint8_t x=0,uint8_t y=0){ @@ -252,8 +268,8 @@ void showTime(time_t t,uint8_t x=12,uint8_t y=22){ uint16_t tmp = minute(t); if(withSeconds){ - drawSeconds(t,x+62,y+8); - x -= 11; + drawSeconds(t,x+75,y+16); + x -= 6; } if(lastminutes != tmp){ @@ -375,8 +391,8 @@ void showTimeTactical(time_t t){ uint8_t x = 8; uint8_t y = 22; if(withSeconds){ - drawSeconds(t,x+62,y+8); - x -= 11; + drawSeconds(t,x+75,y+16); + x -= 6; } if(lastminutes != tmp){ @@ -460,12 +476,13 @@ void setup() { mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M; mxconfig.latch_blanking = 4; mxconfig.min_refresh_rate = 50; + mxconfig.clkphase = false; display = new MatrixPanel_I2S_DMA(mxconfig); display->begin(); display->setPanelBrightness(100); display->clearScreen(); - display->setFont(&TTHCENT8pt7b); + display->setFont(&NT7x10); EEPROM.begin(256); EEPROM.get(0, timeIndex); @@ -500,10 +517,9 @@ void setup() { EEPROM.get(101,ssid); EEPROM.get(201,pass); EEPROM.get(151,appass); - showNTOOLS(); - display->setCursor(1, 34); + display->setCursor(16, 34); display->print("bitte warten"); Wire.begin(21,22); @@ -534,6 +550,7 @@ void setup() { strcat(APName, ChipID); WiFi.persistent(false); + WiFi.setAutoReconnect(true); WiFi.begin(ssid,pass); WiFi.hostname(NetName); int xc = 0; @@ -560,15 +577,21 @@ void setup() { show5x7( 5, 2, localip, 255, 255, 255); display->drawPixelRGB888(2, 0, 0, 255, 0); configTime(0,0, "ptbtime1.ptb.de", "ptbtime2.ptb.de", "ptbtime3.ptb.de"); - time_t timenow = time(nullptr); + delay_ex(2000); xc = 0; - while((timenow < SECS_YR_2000) && (xc < 10)) { - delay(1000); - timenow = time(nullptr); - xc++; + sntp_sync_status_t syncStatus; + syncStatus = sntp_get_sync_status(); + while((syncStatus != SNTP_SYNC_STATUS_COMPLETED) && (xc < 40)) { + delay_ex(1000); + syncStatus = sntp_get_sync_status(); display->drawPixelRGB888(xc+17,0,255,255,0); + xc++; } - if(timenow > SECS_YR_2000){ + esp_sntp_stop(); + if(syncStatus == SNTP_SYNC_STATUS_COMPLETED){ + time_t timenow = time(nullptr); + timenow = time(nullptr); + timenow += 1; //Zeit korrektur byte Month, Day, Hour; setTime(timenow); Month = month(timenow); @@ -587,10 +610,16 @@ void setup() { EEPROM.put(10, savediDL); EEPROM.commit(); display->drawPixelRGB888(3,0,0,255,0); + lastTimeSyncTyp = 2; + lastTimeSyncTime = now(); }else{ display->drawPixelRGB888(3,0,255,0,255); } - delay(5000); + for(uint8_t i=0;i<5;i++){ + delay_ex(1000); + display->drawPixelRGB888(xc+17,0,0,255,0); + xc++; + } }else{ display->drawPixelRGB888(2,0,255,0,0); APEnabled = true; @@ -603,6 +632,7 @@ void setup() { WiFi.mode(WIFI_AP); delay(100); WiFi.softAPConfig(ip_local, ip_gateway, ip_subnet); + //APEnabled = WiFi.softAP(APName, "1234567890",2,0,1); APEnabled = WiFi.softAP(APName, appass,2,0,1); if(!APEnabled) display->drawPixelRGB888(4,0,255,0,0); @@ -622,19 +652,10 @@ void setup() { webServer.on("/poll", HTTP_GET, [] (AsyncWebServerRequest *request) {html_poll(request);}); webServer.begin(); - delay(1000); + delay(500); display->setPanelBrightness(ceil(255 * brightness)); display->clearScreen(); - - /*display->setTextColor(display->color565(128,255,0)); - display->setFont(&NT7x10); - display->setCursor(13, 11); - display->print("alles gute im"); - display->setCursor(17, 22); - display->setTextColor(display->color565(255,0,0)); - display->print("neuen heim"); - */ } void loop() { @@ -721,10 +742,10 @@ void html_poll(AsyncWebServerRequest *request) { itoa(timeIndex,tempBuff,DEC); strcat(ret,(char *)","); strcat(ret,tempBuff); - itoa(lastTimeSyncTyp,tempBuff,DEC); + itoa(lastTimeSyncTime,tempBuff,DEC); strcat(ret,(char *)","); strcat(ret,tempBuff); - itoa(lastTimeSyncTime,tempBuff,DEC); + itoa(lastTimeSyncTyp,tempBuff,DEC); strcat(ret,(char *)","); strcat(ret,tempBuff); dtostrf(brightness, 10, 2, tempBuff); diff --git a/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/index_html.h b/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/index_html.h index be7ed5d..d5ed769 100644 --- a/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/index_html.h +++ b/ESP32_MasterPx_DesignUhr/ESP32_MasterPx_DesignUhr/index_html.h @@ -1,4 +1,4 @@ -const char html_page_index[] PROGMEM = R"rawliteral( +static const char *html_page_index PROGMEM = R"rawliteral( N-Tools.de Uhr @@ -389,7 +389,8 @@ const char html_page_index[] PROGMEM = R"rawliteral( document.getElementById('actDate').style.color = colorString; document.getElementById('showWhat').value = parseInt(data[4]); - switch(data[5]){ + showTimeFromUnix(data[5],'sync'); + switch(data[6]){ case 0: document.getElementById('sync').innerHTML = " keiner"; break; @@ -403,7 +404,7 @@ const char html_page_index[] PROGMEM = R"rawliteral( document.getElementById('sync').innerHTML += " (manuel)"; break; } - showTimeFromUnix(data[6],'sync'); + document.getElementById('brigtness').innerHTML = (data[7]*100); document.getElementById("rtcactive").checked = (data[8] == 1);