Fix of NTP logic. Minor refactoring.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define WORDCLOCK_ESP8266_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdlib.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include "led_matrix.h"
|
||||
#include "udp_logger.h"
|
||||
@@ -11,6 +12,13 @@
|
||||
|
||||
#define EEPROM_SIZE (sizeof(EepromLayout_st) / sizeof(uint8_t))
|
||||
|
||||
#define BUILD_YEAR (__DATE__ + 7) /* Will expand to current year at compile time as string. */
|
||||
#define NTP_MININUM_RX_YEAR (atoi(BUILD_YEAR) - 1) /* Will expand to current year at compile time minus one. */
|
||||
#define NTP_MININUM_YEAR (1900) // NTP minimum year is 1900
|
||||
#define NTP_MAX_UPDATE_TIME_US (500000) // 500ms max update time
|
||||
#define NTP_NEXT_UPDATE_DELAY_US (10000000) // 10s delay time between updates
|
||||
#define NTP_WATCHDOG_COUNTER_INIT (30) // Watchdog value, count of retries before restart
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int start_hour;
|
||||
@@ -54,6 +62,7 @@ typedef enum
|
||||
NUM_STATES
|
||||
} ClockState_en;
|
||||
|
||||
bool get_ntp_time(uint32 usec);
|
||||
String leading_zero2digit(int value);
|
||||
uint8_t calculate_dynamic_brightness(uint8_t min_brightness, uint8_t max_brightness, int hours, int minutes, bool summertime);
|
||||
uint8_t update_brightness(void);
|
||||
@@ -67,8 +76,7 @@ void handle_data_request(void);
|
||||
void handle_led_direct(void);
|
||||
void limit_value_ranges(void);
|
||||
void log_time(tm local_time);
|
||||
void ntp_time_update(uint32 *last_ntp_update_us);
|
||||
void ntp_time_update(uint32 *last_ntp_update_us);
|
||||
void ntp_time_update(uint32 max_update_time);
|
||||
void on_state_entry(uint8_t state);
|
||||
void read_settings_from_EEPROM(void);
|
||||
void reset_wifi_credentials(void);
|
||||
|
||||
Reference in New Issue
Block a user