Skip to content

Commit 0272e83

Browse files
author
Spacehuhn
committed
Fixed clock update
#1385 #1384
1 parent 333e3eb commit 0272e83

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

esp8266_deauther/A_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@
563563

564564
// ===== Reset ====== //
565565
#ifndef RESET_BUTTON
566-
#if BUTTON_UP != 0 && BUTTON_DOWN != 0 && BUTTON_A != 0 && BUTTON_B != 0 && BUTTON_B != 0
566+
#if BUTTON_UP != 0 && BUTTON_DOWN != 0 && BUTTON_A != 0 && BUTTON_B != 0
567567
#define RESET_BUTTON 0
568568
#else // if BUTTON_UP != 0 && BUTTON_DOWN != 0 && BUTTON_A != 0 && BUTTON_B != 0
569569
#define RESET_BUTTON 255

esp8266_deauther/DisplayUI.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void DisplayUI::setup() {
8888
mode = DISPLAY_MODE::PACKETMONITOR;
8989
});
9090

91-
addMenuNode(&mainMenu, D_CLOCK, [this]() { // PACKET MONITOR
91+
addMenuNode(&mainMenu, D_CLOCK, [this]() { // CLOCK
9292
mode = DISPLAY_MODE::CLOCK;
9393
display.setFont(ArialMT_Plain_24);
9494
display.setTextAlignment(TEXT_ALIGN_CENTER);
@@ -523,7 +523,7 @@ void DisplayUI::setupButtons() {
523523
else currentMenu->selected = currentMenu->list->size() - 1;
524524
} else if (mode == DISPLAY_MODE::PACKETMONITOR) { // when in packet monitor, change channel
525525
scan.setChannel(wifi_channel + 1);
526-
} else if (mode == DISPLAY_MODE::CLOCK) {
526+
} else if (mode == DISPLAY_MODE::CLOCK) { // when in clock, change time
527527
setTime(clockHour, clockMinute + 1, clockSecond);
528528
}
529529
}
@@ -539,7 +539,7 @@ void DisplayUI::setupButtons() {
539539
else currentMenu->selected = currentMenu->list->size() - 1;
540540
} else if (mode == DISPLAY_MODE::PACKETMONITOR) { // when in packet monitor, change channel
541541
scan.setChannel(wifi_channel + 1);
542-
} else if (mode == DISPLAY_MODE::CLOCK) { // when in packet monitor, change channel
542+
} else if (mode == DISPLAY_MODE::CLOCK) { // when in clock, change time
543543
setTime(clockHour, clockMinute + 10, clockSecond);
544544
}
545545
}
@@ -662,12 +662,19 @@ void DisplayUI::draw(bool force) {
662662

663663
updatePrefix();
664664

665-
#ifndef RTC_DS3231
666-
if (clockTime < currentTime - 1000) {
667-
setTime(clockHour, clockMinute++, clockSecond + 1);
665+
if (currentTime - clockTime >= 1000) {
666+
#ifdef RTC_DS3231
667+
bool h12;
668+
bool PM_time;
669+
clockHour = clock.getHour(h12, PM_time);
670+
clockMinute = clock.getMinute();
671+
clockSecond = clock.getSecond();
672+
#else // ifdef RTC_DS3231
673+
++clockSecond;
674+
#endif // ifdef RTC_DS3231
675+
setTime(clockHour, clockMinute, clockSecond);
668676
clockTime += 1000;
669677
}
670-
#endif // ifndef RTC_DS3231
671678

672679
switch (mode) {
673680
case DISPLAY_MODE::BUTTON_TEST:

0 commit comments

Comments
 (0)