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
#### 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

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

View File

@@ -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;
}

View File

@@ -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];

View File

@@ -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();
};

View File

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