Compare commits
2 Commits
main
...
adjustable
Author | SHA1 | Date | |
---|---|---|---|
|
df174f6d26 | ||
|
d9e576c35c |
@ -481,6 +481,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
JsonObject if_ntp = interfaces[F("ntp")];
|
||||
CJSON(ntpEnabled, if_ntp["en"]);
|
||||
getStringFromJson(ntpServerName, if_ntp[F("host")], 33); // "1.wled.pool.ntp.org"
|
||||
CJSON(ntpSyncInterval, if_ntp[F("int")]);
|
||||
CJSON(currentTimezone, if_ntp[F("tz")]);
|
||||
CJSON(utcOffsetSecs, if_ntp[F("offset")]);
|
||||
CJSON(useAMPM, if_ntp[F("ampm")]);
|
||||
@ -939,6 +940,7 @@ void serializeConfig() {
|
||||
JsonObject if_ntp = interfaces.createNestedObject("ntp");
|
||||
if_ntp["en"] = ntpEnabled;
|
||||
if_ntp[F("host")] = ntpServerName;
|
||||
if_ntp[F("int")] = ntpSyncInterval;
|
||||
if_ntp[F("tz")] = currentTimezone;
|
||||
if_ntp[F("offset")] = utcOffsetSecs;
|
||||
if_ntp[F("ampm")] = useAMPM;
|
||||
|
@ -171,6 +171,13 @@
|
||||
Get time from NTP server: <input type="checkbox" name="NT"><br>
|
||||
<input type="text" name="NS" maxlength="32"><br>
|
||||
Use 24h format: <input type="checkbox" name="CF"><br>
|
||||
NTP refresh: <select name="NP">
|
||||
<option value="86400">once</option>
|
||||
<option value="43200" selected>twice</option>
|
||||
<option value="21600">4 times</option>
|
||||
<option value="14400">6 times</option>
|
||||
<option value="10800">8 times</option>
|
||||
</select> per day<br>
|
||||
Time zone:
|
||||
<select name="TZ">
|
||||
<option value="0" selected>GMT(UTC)</option>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,6 @@
|
||||
* Acquires time from NTP server
|
||||
*/
|
||||
//#define WLED_DEBUG_NTP
|
||||
#define NTP_SYNC_INTERVAL 42000UL //Get fresh NTP time about twice per day
|
||||
|
||||
Timezone* tz;
|
||||
|
||||
@ -180,7 +179,7 @@ void handleTime() {
|
||||
|
||||
void handleNetworkTime()
|
||||
{
|
||||
if (ntpEnabled && ntpConnected && millis() - ntpLastSyncTime > (1000*NTP_SYNC_INTERVAL) && WLED_CONNECTED)
|
||||
if (ntpEnabled && ntpConnected && millis() - ntpLastSyncTime > (1000UL*ntpSyncInterval) && WLED_CONNECTED)
|
||||
{
|
||||
if (millis() - ntpPacketSentTime > 10000)
|
||||
{
|
||||
|
@ -390,6 +390,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
ntpEnabled = request->hasArg(F("NT"));
|
||||
strlcpy(ntpServerName, request->arg(F("NS")).c_str(), 33);
|
||||
useAMPM = !request->hasArg(F("CF"));
|
||||
ntpSyncInterval = min(86400U, max(10800U, (unsigned int)request->arg(F("NP")).toInt()));
|
||||
currentTimezone = request->arg(F("TZ")).toInt();
|
||||
utcOffsetSecs = request->arg(F("UO")).toInt();
|
||||
|
||||
|
@ -639,13 +639,14 @@ WLED_GLOBAL DNSServer dnsServer;
|
||||
// network time
|
||||
WLED_GLOBAL bool ntpConnected _INIT(false);
|
||||
WLED_GLOBAL time_t localTime _INIT(0);
|
||||
WLED_GLOBAL uint32_t ntpSyncInterval _INIT(43200U);
|
||||
WLED_GLOBAL unsigned long ntpLastSyncTime _INIT(999000000L);
|
||||
WLED_GLOBAL unsigned long ntpPacketSentTime _INIT(999000000L);
|
||||
WLED_GLOBAL IPAddress ntpServerIP;
|
||||
WLED_GLOBAL uint16_t ntpLocalPort _INIT(2390);
|
||||
WLED_GLOBAL uint16_t rolloverMillis _INIT(0);
|
||||
WLED_GLOBAL float longitude _INIT(0.0);
|
||||
WLED_GLOBAL float latitude _INIT(0.0);
|
||||
WLED_GLOBAL float longitude _INIT(0.0f);
|
||||
WLED_GLOBAL float latitude _INIT(0.0f);
|
||||
WLED_GLOBAL time_t sunrise _INIT(0);
|
||||
WLED_GLOBAL time_t sunset _INIT(0);
|
||||
WLED_GLOBAL Toki toki _INIT(Toki());
|
||||
|
@ -574,6 +574,15 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
sappend('c',SET_F("NT"),ntpEnabled);
|
||||
sappends('s',SET_F("NS"),ntpServerName);
|
||||
sappend('c',SET_F("CF"),!useAMPM);
|
||||
int syncIntervalIndex;
|
||||
switch (ntpSyncInterval) {
|
||||
case 86400: syncIntervalIndex = 0; break;
|
||||
case 21600: syncIntervalIndex = 2; break;
|
||||
case 14400: syncIntervalIndex = 3; break;
|
||||
case 10800: syncIntervalIndex = 4; break;
|
||||
default : syncIntervalIndex = 1; break;
|
||||
}
|
||||
sappend('i',SET_F("NP"),syncIntervalIndex);
|
||||
sappend('i',SET_F("TZ"),currentTimezone);
|
||||
sappend('v',SET_F("UO"),utcOffsetSecs);
|
||||
char tm[32];
|
||||
|
Loading…
Reference in New Issue
Block a user