Fixed NTP read and init of tc data block in RAM.
This commit is contained in:
parent
510f6756b0
commit
0188bb763f
3 changed files with 14 additions and 11 deletions
|
@ -14,8 +14,8 @@
|
||||||
#define EEPROM_LAST_STATE_ADDRESS 4 // the first "last state" information for the first light
|
#define EEPROM_LAST_STATE_ADDRESS 4 // the first "last state" information for the first light
|
||||||
#define EEPROM_TIMING_DATA_ADDRESS (EEPROM_LAST_STATE_ADDRESS + LIGHTS_COUNT) // Stored data date per light ELE_USED; HH; MM; CH1; CH2; CH3; CH4;
|
#define EEPROM_TIMING_DATA_ADDRESS (EEPROM_LAST_STATE_ADDRESS + LIGHTS_COUNT) // Stored data date per light ELE_USED; HH; MM; CH1; CH2; CH3; CH4;
|
||||||
|
|
||||||
#define TIME_CHECK_INTERVAL_MS (10000UL) // 600000
|
#define TIME_CHECK_INTERVAL_MS (60000UL) // 60 second interval
|
||||||
|
|
||||||
#define MY_NTP_SERVER "de.pool.ntp.org"
|
#define MY_NTP_SERVER "de.pool.ntp.org"
|
||||||
|
|
||||||
#define DISABLE_WEB_CONTROL
|
//#define DISABLE_WEB_CONTROL
|
||||||
|
|
|
@ -15,6 +15,7 @@ uint8_t pins[LIGHTS_COUNT] = {12, 15, 13, 14};
|
||||||
IPAddress strip_ip ( 192, 168, 0, 26); // choose an unique IP Adress
|
IPAddress strip_ip ( 192, 168, 0, 26); // choose an unique IP Adress
|
||||||
IPAddress gateway_ip ( 192, 168, 0, 1); // Router IP
|
IPAddress gateway_ip ( 192, 168, 0, 1); // Router IP
|
||||||
IPAddress subnet_mask( 255, 255, 255, 0);
|
IPAddress subnet_mask( 255, 255, 255, 0);
|
||||||
|
IPAddress dns ( 192, 168, 0, 1);
|
||||||
|
|
||||||
//********************************//
|
//********************************//
|
||||||
|
|
||||||
|
@ -190,13 +191,13 @@ void read_eeprom_config()
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
EEPROM.begin(512);
|
EEPROM.begin(256);
|
||||||
|
|
||||||
Serial.begin(SERIAL_BAUD_RATE);
|
Serial.begin(SERIAL_BAUD_RATE);
|
||||||
|
|
||||||
if (EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS) == 0)
|
if (EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS) == 0)
|
||||||
{
|
{
|
||||||
WiFi.config(strip_ip, gateway_ip, subnet_mask);
|
WiFi.config(strip_ip, gateway_ip, subnet_mask, dns);
|
||||||
}
|
}
|
||||||
|
|
||||||
read_eeprom_config();
|
read_eeprom_config();
|
||||||
|
|
|
@ -24,13 +24,12 @@
|
||||||
//***********************************//
|
//***********************************//
|
||||||
/* Globals */
|
/* Globals */
|
||||||
|
|
||||||
uint32_t tc_last_check = 0;
|
uint32_t tc_last_check = 60000;
|
||||||
|
|
||||||
const long updateInterval = 60000;
|
|
||||||
const long utcOffsetInSeconds = 3600;
|
const long utcOffsetInSeconds = 3600;
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, MY_NTP_SERVER, utcOffsetInSeconds, updateInterval);
|
NTPClient timeClient(ntpUDP, MY_NTP_SERVER, utcOffsetInSeconds);
|
||||||
|
|
||||||
struct tc_data_st {
|
struct tc_data_st {
|
||||||
uint8_t enstate;
|
uint8_t enstate;
|
||||||
|
@ -42,7 +41,7 @@ struct tc_data_st {
|
||||||
uint8_t ch4;
|
uint8_t ch4;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tc_data_st tc_data[LIGHTS_COUNT];
|
struct tc_data_st tc_data[10];
|
||||||
|
|
||||||
uint8_t example_timer_data_block[] = {
|
uint8_t example_timer_data_block[] = {
|
||||||
// state hour min ch1 ch2 ch3 ch3
|
// state hour min ch1 ch2 ch3 ch3
|
||||||
|
@ -151,16 +150,19 @@ void tc_update()
|
||||||
|
|
||||||
void tc_updateTime()
|
void tc_updateTime()
|
||||||
{
|
{
|
||||||
if (timeClient.update())
|
/**/
|
||||||
|
if (timeClient.update() || millis() > (tc_last_check + TIME_CHECK_INTERVAL_MS))
|
||||||
{
|
{
|
||||||
Serial.println("TC: Reading time from server...");
|
tc_last_check = millis();
|
||||||
Serial.println(timeClient.getFormattedTime());
|
//Serial.println("TC: Read time from server...");
|
||||||
|
//Serial.println(timeClient.getFormattedTime());
|
||||||
|
|
||||||
Serial.print("Local time: ");
|
Serial.print("Local time: ");
|
||||||
Serial.print(timeClient.getHours());
|
Serial.print(timeClient.getHours());
|
||||||
Serial.print(":");
|
Serial.print(":");
|
||||||
Serial.println(timeClient.getMinutes());
|
Serial.println(timeClient.getMinutes());
|
||||||
}
|
}
|
||||||
|
/**/
|
||||||
}
|
}
|
||||||
|
|
||||||
//********************************//
|
//********************************//
|
||||||
|
|
Loading…
Reference in a new issue