This commit is contained in:
e2002
2022-06-09 13:16:32 +03:00
parent bcdd181d18
commit 441ffa02a3
6 changed files with 24 additions and 6 deletions

View File

@@ -293,6 +293,11 @@ Work is in progress...
--- ---
## Version history ## 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 #### v0.6.278
- added support for LCD2004 displays - added support for LCD2004 displays
- added support for SSD1305/SSD1309 I2C displays - added support for SSD1305/SSD1309 I2C displays

View File

@@ -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 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 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 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
/******************************************/ /******************************************/

View File

@@ -346,7 +346,9 @@ void Display::swichMode(displayMode_e newmode) {
void Display::drawPlayer() { void Display::drawPlayer() {
if (clockRequest) { if (clockRequest) {
getLocalTime(&network.timeinfo); //getLocalTime(&network.timeinfo);
network.timeinfo.tm_sec ++;
mktime(&network.timeinfo);
time(); time();
clockRequest = false; clockRequest = false;
} }

View File

@@ -11,6 +11,10 @@ void syncTime() {
network.requestTimeSync(true); network.requestTimeSync(true);
} }
void getFirstTime() {
getLocalTime(&network.timeinfo);
}
void Network::begin() { void Network::begin() {
config.initNetwork(); config.initNetwork();
if (config.ssidsCount == 0) { if (config.ssidsCount == 0) {
@@ -53,13 +57,15 @@ void Network::begin() {
} }
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_BUILTIN, LOW);
status = CONNECTED; 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); ntimer.attach_ms(TSYNC_DELAY, syncTime);
if (network_on_connect) network_on_connect(); if (network_on_connect) network_on_connect();
} }
void Network::requestTimeSync(bool withTelnetOutput) { 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) { if (withTelnetOutput) {
getLocalTime(&timeinfo); getLocalTime(&timeinfo);
char timeStringBuff[50]; char timeStringBuff[50];

View File

@@ -5,7 +5,8 @@
#define apSsid "yoRadioAP" #define apSsid "yoRadioAP"
#define apPassword "12345987" #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 }; enum n_Status_e { CONNECTED, SOFT_AP, FAILED };
@@ -18,7 +19,7 @@ class Network {
void begin(); void begin();
void requestTimeSync(bool withTelnetOutput=false); void requestTimeSync(bool withTelnetOutput=false);
private: private:
Ticker ntimer; Ticker ntimer, stimer;
void raiseSoftAP(); void raiseSoftAP();
}; };

View File

@@ -1,7 +1,7 @@
#ifndef options_h #ifndef options_h
#define options_h #define options_h
#define VERSION "0.6.278" #define VERSION "0.6.292"
/******************************************************* /*******************************************************
DO NOT EDIT THIS FILE. 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 #ifndef PLAYER_FORCE_MONO
#define PLAYER_FORCE_MONO false // mono option - false stereo, true mono #define PLAYER_FORCE_MONO false // mono option - false stereo, true mono
#endif #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 *** *** ST7735 display submodel ***
INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html