diff --git a/README.md b/README.md index f89ff58..3e34fbb 100644 --- a/README.md +++ b/README.md @@ -293,6 +293,11 @@ Work is in progress... --- ## Version history +#### v0.6.290 +- fixed interface blocking error when synchronizing time +- time sync optimization +- new option **SNTP_SERVER**, to set your custom server for synchronization (see [myoptions.h](exsamples/myoptions.h) for exsample) + #### v0.6.278 - added support for LCD2004 displays - added support for SSD1305/SSD1309 I2C displays diff --git a/exsamples/myoptions.h b/exsamples/myoptions.h index dcf5d45..eb4d8fb 100644 --- a/exsamples/myoptions.h +++ b/exsamples/myoptions.h @@ -107,6 +107,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti //#define MUTE_VAL HIGH /* Write this to MUTE_PIN when player is stopped */ //#define PL_WITH_NUMBERS /* show the number of station in the playlist */ //#define PLAYER_FORCE_MONO false /* mono option on boot - false stereo, true mono */ +//#define SNTP_SERVER "pool.ntp.org", "0.ru.pool.ntp.org" // custom ntp servers min 1 max 3 comma separated values /******************************************/ diff --git a/yoRadio/display.cpp b/yoRadio/display.cpp index 2a1844a..72124a8 100644 --- a/yoRadio/display.cpp +++ b/yoRadio/display.cpp @@ -346,7 +346,9 @@ void Display::swichMode(displayMode_e newmode) { void Display::drawPlayer() { if (clockRequest) { - getLocalTime(&network.timeinfo); + //getLocalTime(&network.timeinfo); + network.timeinfo.tm_sec ++; + mktime(&network.timeinfo); time(); clockRequest = false; } diff --git a/yoRadio/network.cpp b/yoRadio/network.cpp index d649401..bbf2091 100644 --- a/yoRadio/network.cpp +++ b/yoRadio/network.cpp @@ -11,6 +11,10 @@ void syncTime() { network.requestTimeSync(true); } +void getFirstTime() { + getLocalTime(&network.timeinfo); +} + void Network::begin() { config.initNetwork(); if (config.ssidsCount == 0) { @@ -53,13 +57,15 @@ void Network::begin() { } digitalWrite(LED_BUILTIN, LOW); status = CONNECTED; - requestTimeSync(); + configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), SNTP_SERVER); + //getLocalTime(&timeinfo); + stimer.once_ms(200,getFirstTime); ntimer.attach_ms(TSYNC_DELAY, syncTime); if (network_on_connect) network_on_connect(); } void Network::requestTimeSync(bool withTelnetOutput) { - configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), "pool.ntp.org", "ru.pool.ntp.org"); + //configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), "pool.ntp.org", "ru.pool.ntp.org"); if (withTelnetOutput) { getLocalTime(&timeinfo); char timeStringBuff[50]; diff --git a/yoRadio/network.h b/yoRadio/network.h index 3788ecb..1b44ef2 100644 --- a/yoRadio/network.h +++ b/yoRadio/network.h @@ -5,7 +5,8 @@ #define apSsid "yoRadioAP" #define apPassword "12345987" -#define TSYNC_DELAY 10800000 // 1000*60*60*3 = 3 hours +//#define TSYNC_DELAY 10800000 // 1000*60*60*3 = 3 hours +#define TSYNC_DELAY 3600000 // 1000*60*60 = 1 hour enum n_Status_e { CONNECTED, SOFT_AP, FAILED }; @@ -18,7 +19,7 @@ class Network { void begin(); void requestTimeSync(bool withTelnetOutput=false); private: - Ticker ntimer; + Ticker ntimer, stimer; void raiseSoftAP(); }; diff --git a/yoRadio/options.h b/yoRadio/options.h index 29d475f..713fab6 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define VERSION "0.6.278" +#define VERSION "0.6.292" /******************************************************* DO NOT EDIT THIS FILE. @@ -212,6 +212,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #ifndef PLAYER_FORCE_MONO #define PLAYER_FORCE_MONO false // mono option - false stereo, true mono #endif +#ifndef SNTP_SERVER + #define SNTP_SERVER "pool.ntp.org", "0.ru.pool.ntp.org" // custom ntp servers min 1 max 3 comma separated values +#endif /* *** ST7735 display submodel *** INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html