From 0272e83c3dbd36e63a712361f9dd92487515d05a Mon Sep 17 00:00:00 2001 From: Spacehuhn Date: Sat, 23 Jan 2021 11:52:16 +0100 Subject: [PATCH] Fixed clock update https://github.com/SpacehuhnTech/esp8266_deauther/issues/1385 https://github.com/SpacehuhnTech/esp8266_deauther/issues/1384 --- esp8266_deauther/A_config.h | 2 +- esp8266_deauther/DisplayUI.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/esp8266_deauther/A_config.h b/esp8266_deauther/A_config.h index 50b57cc..0374830 100644 --- a/esp8266_deauther/A_config.h +++ b/esp8266_deauther/A_config.h @@ -563,7 +563,7 @@ // ===== Reset ====== // #ifndef RESET_BUTTON - #if BUTTON_UP != 0 && BUTTON_DOWN != 0 && BUTTON_A != 0 && BUTTON_B != 0 && BUTTON_B != 0 + #if BUTTON_UP != 0 && BUTTON_DOWN != 0 && BUTTON_A != 0 && BUTTON_B != 0 #define RESET_BUTTON 0 #else // if BUTTON_UP != 0 && BUTTON_DOWN != 0 && BUTTON_A != 0 && BUTTON_B != 0 #define RESET_BUTTON 255 diff --git a/esp8266_deauther/DisplayUI.cpp b/esp8266_deauther/DisplayUI.cpp index e23cb97..32de03d 100644 --- a/esp8266_deauther/DisplayUI.cpp +++ b/esp8266_deauther/DisplayUI.cpp @@ -88,7 +88,7 @@ void DisplayUI::setup() { mode = DISPLAY_MODE::PACKETMONITOR; }); - addMenuNode(&mainMenu, D_CLOCK, [this]() { // PACKET MONITOR + addMenuNode(&mainMenu, D_CLOCK, [this]() { // CLOCK mode = DISPLAY_MODE::CLOCK; display.setFont(ArialMT_Plain_24); display.setTextAlignment(TEXT_ALIGN_CENTER); @@ -523,7 +523,7 @@ void DisplayUI::setupButtons() { else currentMenu->selected = currentMenu->list->size() - 1; } else if (mode == DISPLAY_MODE::PACKETMONITOR) { // when in packet monitor, change channel scan.setChannel(wifi_channel + 1); - } else if (mode == DISPLAY_MODE::CLOCK) { + } else if (mode == DISPLAY_MODE::CLOCK) { // when in clock, change time setTime(clockHour, clockMinute + 1, clockSecond); } } @@ -539,7 +539,7 @@ void DisplayUI::setupButtons() { else currentMenu->selected = currentMenu->list->size() - 1; } else if (mode == DISPLAY_MODE::PACKETMONITOR) { // when in packet monitor, change channel scan.setChannel(wifi_channel + 1); - } else if (mode == DISPLAY_MODE::CLOCK) { // when in packet monitor, change channel + } else if (mode == DISPLAY_MODE::CLOCK) { // when in clock, change time setTime(clockHour, clockMinute + 10, clockSecond); } } @@ -662,12 +662,19 @@ void DisplayUI::draw(bool force) { updatePrefix(); -#ifndef RTC_DS3231 - if (clockTime < currentTime - 1000) { - setTime(clockHour, clockMinute++, clockSecond + 1); + if (currentTime - clockTime >= 1000) { +#ifdef RTC_DS3231 + bool h12; + bool PM_time; + clockHour = clock.getHour(h12, PM_time); + clockMinute = clock.getMinute(); + clockSecond = clock.getSecond(); +#else // ifdef RTC_DS3231 + ++clockSecond; +#endif // ifdef RTC_DS3231 + setTime(clockHour, clockMinute, clockSecond); clockTime += 1000; } -#endif // ifndef RTC_DS3231 switch (mode) { case DISPLAY_MODE::BUTTON_TEST: