forked from btclock/btclock_v3
feat: Replace timezone offset with timezone selector
This commit is contained in:
parent
7266a51a92
commit
c62563c3c2
5 changed files with 739 additions and 6 deletions
|
@ -259,7 +259,7 @@ void setupWifi()
|
|||
|
||||
void syncTime()
|
||||
{
|
||||
configTime(preferences.getInt("gmtOffset", DEFAULT_TIME_OFFSET_SECONDS), 0,
|
||||
configTime(0, 0,
|
||||
NTP_SERVER);
|
||||
struct tm timeinfo;
|
||||
|
||||
|
@ -267,15 +267,24 @@ void syncTime()
|
|||
{
|
||||
auto& ledHandler = getLedHandler();
|
||||
ledHandler.queueEffect(LED_EFFECT_CONFIGURING);
|
||||
configTime(preferences.getInt("gmtOffset", DEFAULT_TIME_OFFSET_SECONDS), 0,
|
||||
configTime(0, 0,
|
||||
NTP_SERVER);
|
||||
delay(500);
|
||||
Serial.println(F("Retry set time"));
|
||||
}
|
||||
|
||||
setTimezone(get_timezone_value_string(timezone_data::find_timezone_value(preferences.getString("tzString", DEFAULT_TZ_STRING))));
|
||||
|
||||
lastTimeSync = esp_timer_get_time() / 1000000;
|
||||
}
|
||||
|
||||
void setTimezone(String timezone) {
|
||||
Serial.printf(" Setting Timezone to %s\n",timezone.c_str());
|
||||
setenv("TZ",timezone.c_str(),1); // Now adjust the TZ. Clock settings are adjusted to show the new local time
|
||||
tzset();
|
||||
}
|
||||
|
||||
|
||||
void setupPreferences()
|
||||
{
|
||||
preferences.begin("btclock", false);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "shared.hpp"
|
||||
#include "defaults.hpp"
|
||||
|
||||
#include "timezone_data.hpp"
|
||||
#define NTP_SERVER "pool.ntp.org"
|
||||
#define DEFAULT_TIME_OFFSET_SECONDS 3600
|
||||
#ifndef MCP_DEV_ADDR
|
||||
|
@ -43,6 +43,7 @@
|
|||
|
||||
void setup();
|
||||
void syncTime();
|
||||
void setTimezone(String timezone);
|
||||
uint getLastTimeSync();
|
||||
void setupPreferences();
|
||||
void setupWebsocketClients(void *pvParameters);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD
|
||||
|
||||
#define DEFAULT_TIME_OFFSET_SECONDS 3600
|
||||
#define DEFAULT_TZ_STRING "Europe/Amsterdam"
|
||||
|
||||
#define DEFAULT_HOSTNAME_PREFIX "btclock"
|
||||
#define DEFAULT_MEMPOOL_INSTANCE "mempool.space"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
static const char* JSON_CONTENT = "application/json";
|
||||
|
||||
static const char *const PROGMEM strSettings[] = {
|
||||
"hostnamePrefix", "mempoolInstance", "nostrPubKey", "nostrRelay", "bitaxeHostname", "miningPoolName", "miningPoolUser", "nostrZapPubkey", "httpAuthUser", "httpAuthPass", "gitReleaseUrl", "poolLogosUrl", "ceEndpoint", "fontName", "localPoolEndpoint"};
|
||||
"hostnamePrefix", "mempoolInstance", "nostrPubKey", "nostrRelay", "bitaxeHostname", "miningPoolName", "miningPoolUser", "nostrZapPubkey", "httpAuthUser", "httpAuthPass", "gitReleaseUrl", "poolLogosUrl", "ceEndpoint", "fontName", "localPoolEndpoint", "tzString"};
|
||||
|
||||
static const char *const PROGMEM uintSettings[] = {"minSecPriceUpd", "fullRefreshMin", "ledBrightness", "flMaxBrightness", "flEffectDelay", "luxLightToggle", "wpTimeout"};
|
||||
|
||||
|
@ -692,8 +692,9 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
|||
root["fullRefreshMin"] =
|
||||
preferences.getUInt("fullRefreshMin", DEFAULT_MINUTES_FULL_REFRESH);
|
||||
root["wpTimeout"] = preferences.getUInt("wpTimeout", DEFAULT_WP_TIMEOUT);
|
||||
root["tzOffset"] = preferences.getInt("gmtOffset", DEFAULT_TIME_OFFSET_SECONDS) / 60;
|
||||
|
||||
//root["tzOffset"] = preferences.getInt("gmtOffset", DEFAULT_TIME_OFFSET_SECONDS) / 60;
|
||||
root["tzString"] = preferences.getString("tzString", DEFAULT_TZ_STRING);
|
||||
|
||||
// Add data source settings
|
||||
root["dataSource"] = preferences.getUChar("dataSource", DEFAULT_DATA_SOURCE);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue