From: Roman Bazalevskiy Date: Thu, 17 Nov 2022 05:26:38 +0000 (+0300) Subject: Исправлен будильник по дням + немного причесаны диагностические сообщения X-Git-Url: https://git.rvb.name/esp-clock.git/commitdiff_plain/7fff81f521f6b9d6f277d972f59411452fb4a677?ds=sidebyside;hp=9d5bed5c1af4aca9cb37dbff3e111f51c67da451 Исправлен будильник по дням + немного причесаны диагностические сообщения --- diff --git a/ESP8266_clock.ino b/ESP8266_clock.ino new file mode 100644 index 0000000..b8e8c4a --- /dev/null +++ b/ESP8266_clock.ino @@ -0,0 +1,50 @@ +#include "Clock.h" +#include + +void setup() { + // put your setup code here, to run once: + + Serial.begin(115200); + Serial.println(); + Serial.println(F("Starting...")); + + setupConfig(); + Serial.println(cfg); + + setupHandlers(); + + setupHardware(); + setupPanel(); + + setupNet(); + setupTime(); + + setupAlarm(); + setupWeatherRequest(); + + setupWeb(); +} + +void mem() { + Serial.println(F("-------------------------------------------------------------")); + Serial.print("Heap:"); Serial.print(ESP.getFreeHeap()); + Serial.print(" Largest chunk:"); Serial.print(ESP.getMaxFreeBlockSize()); + Serial.print(" Fragmentation:"); Serial.print(ESP.getHeapFragmentation()); + Serial.print(" Stack:"); Serial.println(ESP.getFreeContStack()); + Serial.println(F("-------------------------------------------------------------")); +} + +void loop() { + static unsigned long lastMillis = 0; + int interval = 15000; + // put your main code here, to run repeatedly: + if (millis() - lastMillis > interval) { + lastMillis = millis(); + mem(); + } + tickNet(); + tickTime(); + tickHardware(); + tickPanel(); + tickWeb(); +} diff --git a/alarm.cpp b/alarm.cpp index 4028b6c..e609dba 100644 --- a/alarm.cpp +++ b/alarm.cpp @@ -22,7 +22,7 @@ void checkAlarm() { int alarm_length = cfg.getIntValue(F("alarm_length")); int alarm_beep_ms = cfg.getIntValue(F("alarm_beep_ms")); int alarm_silent_ms = cfg.getIntValue(F("alarm_silent_ms")); - if ( enable_alarm && hh == alarm_hour && mi == alarm_minute && alarm_days[dd?dd-1:6]!='0') { + if ( enable_alarm && (hh == alarm_hour) && (mi == alarm_minute) && (alarm_days[dw?dw-1:6]!='0')) { beep(alarm_tone, alarm_length * 1000, alarm_beep_ms, alarm_silent_ms); } } diff --git a/config.cpp b/config.cpp index bb60f3a..0835802 100644 --- a/config.cpp +++ b/config.cpp @@ -489,7 +489,6 @@ void saveConfig(bool force) { if (File f = LittleFS.open(F("/config.txt"),"w")) { f.print(cfg); f.close(); - Serial.print(cfg); Serial.println(F("Конфигурация сохранена")); cfg.resetTimestamp(); } diff --git a/net.cpp b/net.cpp index b211f63..ff18fcc 100644 --- a/net.cpp +++ b/net.cpp @@ -15,7 +15,7 @@ void setupNet(bool AP) { WiFi.mode(WIFI_STA); WiFi.begin(SSID,PSK); isApEnabled = false; - Serial.println(F("STA mode active")); + Serial.println(F("Режим беспроводного клиента")); } else { SSID = cfg.getCharValue(F("ap_ssid")); PSK = cfg.getCharValue(F("ap_psk")); @@ -24,7 +24,7 @@ void setupNet(bool AP) { } WiFi.mode(WIFI_AP); WiFi.softAP(SSID,PSK); - Serial.println(F("AP mode active")); + Serial.println(F("Режим точки доступа")); isApEnabled = true; String IP = WiFi.softAPIP().toString(); char buf[256]; @@ -44,11 +44,11 @@ void tickNet() { if (isApEnabled) { if (WiFi.status() == WL_CONNECTED && !isNetConnected) { isNetConnected = true; - Serial.print(F("Device connected to SSID ")); Serial.println(SSID); + Serial.print(F("Выполнено подключение к сети ")); Serial.println(SSID); message(F("Соединение установлено")); } else if (WiFi.status() != WL_CONNECTED && isNetConnected) { isNetConnected = false; - Serial.println(F("Network connection lost")); + Serial.println(F("Сеть потеряна")); message(F("Сеть потеряна")); } } diff --git a/time.cpp b/time.cpp index c874bb9..e6f81c9 100644 --- a/time.cpp +++ b/time.cpp @@ -23,7 +23,7 @@ std::function tTimeHandlers[maxTimeHandlers]; void timeIsSet(bool ntp) { if (ntp) { - Serial.println(F("Time syncronized with NTP")); + Serial.println(F("Время синхронизировано")); message(F("Время синхронизировано")); if (isRTCEnabled) { RTC.adjust(DateTime(now)); diff --git a/web.cpp b/web.cpp index b34d7cf..7b7f1bc 100644 --- a/web.cpp +++ b/web.cpp @@ -129,7 +129,6 @@ void setupWeb() { isWebStarted = true; - Serial.println("Setting authentication..."); strncpy(auth_user,cfg.getCharValue(F("auth_user")),31); strncpy(auth_pwd,cfg.getCharValue(F("auth_pwd")),31); @@ -308,18 +307,18 @@ void tickWeb() { static bool connectInProgress = false; static unsigned long connectMillis = 0; if (actionScheduled && millis()>millisScheduled+300) { - Serial.print(F("Scheduled action ")); Serial.println(actionScheduled); + Serial.print(F("Запланированная операция ")); Serial.println(actionScheduled); // if (strcmp(actionScheduled,"restart") == 0) { server.end(); reboot(); } else if (strcmp(actionScheduled,"auth") == 0) { - Serial.println("New authentication credentials"); + Serial.println("Логин/пароль изменены"); strncpy(auth_user,cfg.getCharValue(F("auth_user")),31); strncpy(auth_pwd,cfg.getCharValue(F("auth_pwd")),31); pendingAuth = false; } else if (strcmp(actionScheduled,"wifi") == 0) { - Serial.println("New wifi credentials"); + Serial.println("Применяю настройки сети"); strcpy(storedSSID,WiFi.SSID().c_str()); strcpy(storedPSK,WiFi.psk().c_str()); WiFi.mode(WIFI_STA);