Moved FEATURE_NTP into config-system
This commit is contained in:
@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
# -DFEATURE_GAMETRAK
|
||||
-DFEATURE_POWERSUPPLY
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
-DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
-DFEATURE_ESPNOW
|
||||
|
||||
|
@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
# -DFEATURE_GAMETRAK
|
||||
# -DFEATURE_POWERSUPPLY
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
# -DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
-DFEATURE_ESPNOW
|
||||
|
||||
|
@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
# -DFEATURE_GAMETRAK
|
||||
-DFEATURE_POWERSUPPLY
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
-DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
# -DFEATURE_ESPNOW
|
||||
|
||||
|
@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
# -DFEATURE_GAMETRAK
|
||||
-DFEATURE_POWERSUPPLY
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
# -DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
-DFEATURE_ESPNOW
|
||||
|
||||
|
@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
# -DFEATURE_GAMETRAK
|
||||
# -DFEATURE_POWERSUPPLY
|
||||
# -DFEATURE_LEDBACKLIGHT
|
||||
# -DFEATURE_NTP
|
||||
# -DFEATURE_WIRELESS_CONFIG
|
||||
# -DFEATURE_ESPNOW
|
||||
|
||||
|
@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
# -DFEATURE_GAMETRAK
|
||||
-DFEATURE_POWERSUPPLY
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
# -DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
-DFEATURE_ESPNOW
|
||||
|
||||
|
@@ -50,13 +50,11 @@ struct CloudTransmitTimeoutAccessor : public NewSettingsAccessor<int16_t> { Conf
|
||||
//struct TimezoneOffsetAccessor : public NewSettingsAccessor<int32_t> { ConfigWrapper<int32_t> &getConfig() const override { return configs.timezoneOffset; } };
|
||||
struct TimezoneOffsetAccessor : public NewSettingsChronoAdaptorAccessor<espchrono::minutes32> { ConfigWrapper<espchrono::minutes32> &getConfig() const override { return configs.timezoneOffset; } };
|
||||
struct DaylightSavingModeAccessor : public NewSettingsAccessor<espchrono::DayLightSavingMode> { ConfigWrapper<espchrono::DayLightSavingMode> &getConfig() const override { return configs.timeDst; } };
|
||||
#ifdef FEATURE_NTP
|
||||
struct TimeServerEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.timeServerEnabled; } };
|
||||
struct TimeServerAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.timeServer; } };
|
||||
struct TimeSyncModeAccessor : public NewSettingsAccessor<sntp_sync_mode_t> { ConfigWrapper<sntp_sync_mode_t> &getConfig() const override { return configs.timeSyncMode; } };
|
||||
//struct TimeSyncIntervalAccessor : public NewSettingsAccessor<int32_t> { ConfigWrapper<int32_t> &getConfig() const override { return configs.timeSyncInterval; } };
|
||||
struct TimeSyncIntervalAccessor : public NewSettingsChronoAdaptorAccessor<espchrono::milliseconds32> { ConfigWrapper<espchrono::milliseconds32> &getConfig() const override { return configs.timeSyncInterval; } };
|
||||
#endif
|
||||
|
||||
// Controller Hardware
|
||||
struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return profileSettings.controllerHardware.enableFrontLeft; } };
|
||||
|
@@ -69,7 +69,6 @@ using DaylightSavingModeChangeDisplay = espgui::makeComponent<
|
||||
espgui::BackActionInterface<espgui::SwitchScreenAction<TimeSettingsMenu>>
|
||||
>;
|
||||
|
||||
#ifdef FEATURE_NTP
|
||||
using TimeServerChangeDisplay = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<std::string>,
|
||||
espgui::StaticText<TEXT_NTPSERVER>,
|
||||
@@ -102,7 +101,6 @@ public:
|
||||
return fmt::format("Status: {}", espcpputils::toString(sntp_get_sync_status()));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
TimeSettingsMenu::TimeSettingsMenu()
|
||||
@@ -112,13 +110,14 @@ TimeSettingsMenu::TimeSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, CurrentLocalDateTimeText, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OFFSET>, SwitchScreenAction<TimezoneOffsetChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DAYLIGHTSAVINGMODE>, SwitchScreenAction<DaylightSavingModeChangeDisplay>>>();
|
||||
#ifdef FEATURE_NTP
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPENABLED>, BobbyCheckbox, TimeServerEnabledAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPSERVER>, SwitchScreenAction<TimeServerChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPMODE>, SwitchScreenAction<TimeSyncModeChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPINTERVAL>, SwitchScreenAction<TimeSyncIntervalChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, NtpSyncStatusText, DummyAction>>();
|
||||
#endif
|
||||
if (configs.feature.ntp.value)
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPENABLED>, BobbyCheckbox, TimeServerEnabledAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPSERVER>, SwitchScreenAction<TimeServerChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPMODE>, SwitchScreenAction<TimeSyncModeChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPINTERVAL>, SwitchScreenAction<TimeSyncIntervalChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, NtpSyncStatusText, DummyAction>>();
|
||||
}
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
|
@@ -312,6 +312,7 @@ public:
|
||||
ConfigWrapper<bool> cloud {false, DoReset, {}, "f_cloud" };
|
||||
ConfigWrapper<bool> udpcloud {false, DoReset, {}, "f_udpcloud" };
|
||||
ConfigWrapper<bool> dnsannounce {false, DoReset, {}, "f_dnsannounce" };
|
||||
ConfigWrapper<bool> ntp {false, DoReset, {}, "f_ntp" };
|
||||
ConfigWrapper<bool> gschissene_diode {false, DoReset, {}, "f_gschissDiode" };
|
||||
} feature;
|
||||
|
||||
@@ -610,7 +611,8 @@ public:
|
||||
x(feature.garage) \
|
||||
x(feature.udpcloud) \
|
||||
x(feature.cloud) \
|
||||
x(feature.dnsannounce)
|
||||
x(feature.dnsannounce) \
|
||||
x(feature.ntp)
|
||||
//x(bleSettings.bleEnabled)
|
||||
|
||||
#define FEATURES(x) \
|
||||
@@ -619,7 +621,8 @@ public:
|
||||
x(feature.garage) \
|
||||
x(feature.udpcloud) \
|
||||
x(feature.cloud) \
|
||||
x(feature.dnsannounce)
|
||||
x(feature.dnsannounce) \
|
||||
x(feature.ntp)
|
||||
//x(feature.gschisseneDiode)
|
||||
|
||||
template<typename T>
|
||||
|
@@ -1,18 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// esp-idf includes
|
||||
#ifdef FEATURE_NTP
|
||||
#include <lwip/apps/snmp.h>
|
||||
#include <esp_sntp.h>
|
||||
#endif
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <espchrono.h>
|
||||
|
||||
// local includes
|
||||
#include "profilesettings.h"
|
||||
#include "ledstripdefines.h"
|
||||
#include "ledstrip.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
@@ -2,21 +2,8 @@
|
||||
|
||||
// system includes
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <FastLED.h>
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_wifi_types.h>
|
||||
#ifdef FEATURE_NTP
|
||||
#include <lwip/apps/snmp.h>
|
||||
#include <esp_sntp.h>
|
||||
#endif
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <espchrono.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbycar-common.h"
|
||||
#include "unifiedmodelmode.h"
|
||||
#include "modes/larsmmode.h"
|
||||
|
||||
|
@@ -6,10 +6,8 @@
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
#include <nvs_flash.h>
|
||||
#ifdef FEATURE_NTP
|
||||
#include <lwip/apps/snmp.h>
|
||||
#include <esp_sntp.h>
|
||||
#endif
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
@@ -209,7 +207,6 @@ template<> struct nvsGetterHelper<espchrono::hours32> { static esp_err_t nvs_get
|
||||
*out_value = espchrono::hours32(tempValue);
|
||||
return err;
|
||||
}};
|
||||
#ifdef FEATURE_NTP
|
||||
template<> struct nvsGetterHelper<sntp_sync_mode_t> { static esp_err_t nvs_get(nvs_handle handle, const char* key, sntp_sync_mode_t* out_value)
|
||||
{
|
||||
uint8_t tempValue;
|
||||
@@ -218,7 +215,6 @@ template<> struct nvsGetterHelper<sntp_sync_mode_t> { static esp_err_t nvs_get(n
|
||||
*out_value = sntp_sync_mode_t(tempValue);
|
||||
return err;
|
||||
}};
|
||||
#endif
|
||||
template<> struct nvsGetterHelper<std::array<int8_t, 4>> { static esp_err_t nvs_get(nvs_handle handle, const char* key, std::array<int8_t, 4>* out_value)
|
||||
{
|
||||
uint32_t tempValue;
|
||||
@@ -322,12 +318,10 @@ template<> struct nvsSetterHelper<espchrono::hours32> { static esp_err_t nvs_set
|
||||
{
|
||||
return nvs_set_i32(handle, key, value.count());
|
||||
}};
|
||||
#ifdef FEATURE_NTP
|
||||
template<> struct nvsSetterHelper<sntp_sync_mode_t> { static esp_err_t nvs_set(nvs_handle handle, const char* key, sntp_sync_mode_t value)
|
||||
{
|
||||
return nvs_set_u8(handle, key, uint8_t(value));
|
||||
}};
|
||||
#endif
|
||||
template<> struct nvsSetterHelper<std::array<int8_t, 4>> { static esp_err_t nvs_set(nvs_handle handle, const char* key, std::array<int8_t, 4> value)
|
||||
{
|
||||
return nvs_set_u32(handle, key, std::bit_cast<uint32_t>(value));
|
||||
|
@@ -30,9 +30,7 @@
|
||||
#ifdef FEATURE_MOSFETS
|
||||
#include "mosfets.h"
|
||||
#endif
|
||||
#ifdef FEATURE_NTP
|
||||
#include "time_bobbycar.h"
|
||||
#endif
|
||||
#include "potis.h"
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
#include "bluetooth_bobby.h"
|
||||
@@ -97,9 +95,7 @@ BobbySchedulerTask schedulerTasksArr[] {
|
||||
#ifdef FEATURE_MOSFETS
|
||||
BobbySchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms },
|
||||
#endif
|
||||
#ifdef FEATURE_NTP
|
||||
BobbySchedulerTask { "time", initTime, updateTime, 100ms },
|
||||
#endif
|
||||
BobbySchedulerTask { "potis", initPotis, readPotis, 20ms },
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
BobbySchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms },
|
||||
|
@@ -2,10 +2,8 @@
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
#ifdef FEATURE_NTP
|
||||
#include <lwip/apps/snmp.h>
|
||||
#include <esp_sntp.h>
|
||||
#endif
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <espstrutils.h>
|
||||
@@ -30,7 +28,6 @@ namespace {
|
||||
constexpr const char * const TAG = "BOBBYTIME";
|
||||
} // namespace
|
||||
|
||||
#ifdef FEATURE_NTP
|
||||
void time_sync_notification_cb(struct timeval *tv);
|
||||
|
||||
void initTime()
|
||||
@@ -54,6 +51,9 @@ void initTime()
|
||||
|
||||
void updateTime()
|
||||
{
|
||||
if (!configs.feature.ntp.value)
|
||||
return;
|
||||
|
||||
if (bool(sntp_enabled()) != configs.timeServerEnabled.value)
|
||||
{
|
||||
if (configs.timeServerEnabled.value)
|
||||
@@ -107,7 +107,6 @@ void time_sync_notification_cb(struct timeval *tv)
|
||||
else
|
||||
ESP_LOGI("BOBBY", "nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
void time_set_now(espchrono::utc_clock::time_point now)
|
||||
{
|
||||
|
@@ -7,9 +7,7 @@
|
||||
|
||||
espchrono::time_zone get_default_timezone() noexcept;
|
||||
|
||||
#ifdef FEATURE_NTP
|
||||
void initTime();
|
||||
void updateTime();
|
||||
#endif
|
||||
|
||||
void time_set_now(espchrono::utc_clock::time_point now);
|
||||
|
Reference in New Issue
Block a user