Moved FEATURE_NTP into config-system

This commit is contained in:
CommanderRedYT
2022-01-18 10:08:20 +01:00
parent 18ba362d61
commit 4a47deccb8
15 changed files with 16 additions and 59 deletions

View File

@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
-DFEATURE_POWERSUPPLY -DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT -DFEATURE_LEDBACKLIGHT
-DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG -DFEATURE_WIRELESS_CONFIG
-DFEATURE_ESPNOW -DFEATURE_ESPNOW

View File

@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
# -DFEATURE_POWERSUPPLY # -DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT -DFEATURE_LEDBACKLIGHT
# -DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG -DFEATURE_WIRELESS_CONFIG
-DFEATURE_ESPNOW -DFEATURE_ESPNOW

View File

@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
-DFEATURE_POWERSUPPLY -DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT -DFEATURE_LEDBACKLIGHT
-DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG -DFEATURE_WIRELESS_CONFIG
# -DFEATURE_ESPNOW # -DFEATURE_ESPNOW

View File

@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
-DFEATURE_POWERSUPPLY -DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT -DFEATURE_LEDBACKLIGHT
# -DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG -DFEATURE_WIRELESS_CONFIG
-DFEATURE_ESPNOW -DFEATURE_ESPNOW

View File

@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
# -DFEATURE_POWERSUPPLY # -DFEATURE_POWERSUPPLY
# -DFEATURE_LEDBACKLIGHT # -DFEATURE_LEDBACKLIGHT
# -DFEATURE_NTP
# -DFEATURE_WIRELESS_CONFIG # -DFEATURE_WIRELESS_CONFIG
# -DFEATURE_ESPNOW # -DFEATURE_ESPNOW

View File

@@ -45,7 +45,6 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_GAMETRAK # -DFEATURE_GAMETRAK
-DFEATURE_POWERSUPPLY -DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT -DFEATURE_LEDBACKLIGHT
# -DFEATURE_NTP
-DFEATURE_WIRELESS_CONFIG -DFEATURE_WIRELESS_CONFIG
-DFEATURE_ESPNOW -DFEATURE_ESPNOW

View File

@@ -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 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 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; } }; 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 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 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 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 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; } }; struct TimeSyncIntervalAccessor : public NewSettingsChronoAdaptorAccessor<espchrono::milliseconds32> { ConfigWrapper<espchrono::milliseconds32> &getConfig() const override { return configs.timeSyncInterval; } };
#endif
// Controller Hardware // Controller Hardware
struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return profileSettings.controllerHardware.enableFrontLeft; } }; struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return profileSettings.controllerHardware.enableFrontLeft; } };

View File

@@ -69,7 +69,6 @@ using DaylightSavingModeChangeDisplay = espgui::makeComponent<
espgui::BackActionInterface<espgui::SwitchScreenAction<TimeSettingsMenu>> espgui::BackActionInterface<espgui::SwitchScreenAction<TimeSettingsMenu>>
>; >;
#ifdef FEATURE_NTP
using TimeServerChangeDisplay = espgui::makeComponent< using TimeServerChangeDisplay = espgui::makeComponent<
BobbyChangeValueDisplay<std::string>, BobbyChangeValueDisplay<std::string>,
espgui::StaticText<TEXT_NTPSERVER>, espgui::StaticText<TEXT_NTPSERVER>,
@@ -102,7 +101,6 @@ public:
return fmt::format("Status: {}", espcpputils::toString(sntp_get_sync_status())); return fmt::format("Status: {}", espcpputils::toString(sntp_get_sync_status()));
} }
}; };
#endif
} // namespace } // namespace
TimeSettingsMenu::TimeSettingsMenu() TimeSettingsMenu::TimeSettingsMenu()
@@ -112,13 +110,14 @@ TimeSettingsMenu::TimeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, CurrentLocalDateTimeText, StaticFont<2>, DummyAction>>(); constructMenuItem<makeComponent<MenuItem, CurrentLocalDateTimeText, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OFFSET>, SwitchScreenAction<TimezoneOffsetChangeDisplay>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_OFFSET>, SwitchScreenAction<TimezoneOffsetChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DAYLIGHTSAVINGMODE>, SwitchScreenAction<DaylightSavingModeChangeDisplay>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DAYLIGHTSAVINGMODE>, SwitchScreenAction<DaylightSavingModeChangeDisplay>>>();
#ifdef FEATURE_NTP 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_NTPENABLED>, BobbyCheckbox, TimeServerEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPMODE>, SwitchScreenAction<TimeSyncModeChangeDisplay>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPSERVER>, SwitchScreenAction<TimeServerChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPINTERVAL>, SwitchScreenAction<TimeSyncIntervalChangeDisplay>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPMODE>, SwitchScreenAction<TimeSyncModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, NtpSyncStatusText, DummyAction>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPINTERVAL>, SwitchScreenAction<TimeSyncIntervalChangeDisplay>>>();
#endif constructMenuItem<makeComponent<MenuItem, NtpSyncStatusText, DummyAction>>();
}
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
} }

View File

@@ -312,6 +312,7 @@ public:
ConfigWrapper<bool> cloud {false, DoReset, {}, "f_cloud" }; ConfigWrapper<bool> cloud {false, DoReset, {}, "f_cloud" };
ConfigWrapper<bool> udpcloud {false, DoReset, {}, "f_udpcloud" }; ConfigWrapper<bool> udpcloud {false, DoReset, {}, "f_udpcloud" };
ConfigWrapper<bool> dnsannounce {false, DoReset, {}, "f_dnsannounce" }; ConfigWrapper<bool> dnsannounce {false, DoReset, {}, "f_dnsannounce" };
ConfigWrapper<bool> ntp {false, DoReset, {}, "f_ntp" };
ConfigWrapper<bool> gschissene_diode {false, DoReset, {}, "f_gschissDiode" }; ConfigWrapper<bool> gschissene_diode {false, DoReset, {}, "f_gschissDiode" };
} feature; } feature;
@@ -610,7 +611,8 @@ public:
x(feature.garage) \ x(feature.garage) \
x(feature.udpcloud) \ x(feature.udpcloud) \
x(feature.cloud) \ x(feature.cloud) \
x(feature.dnsannounce) x(feature.dnsannounce) \
x(feature.ntp)
//x(bleSettings.bleEnabled) //x(bleSettings.bleEnabled)
#define FEATURES(x) \ #define FEATURES(x) \
@@ -619,7 +621,8 @@ public:
x(feature.garage) \ x(feature.garage) \
x(feature.udpcloud) \ x(feature.udpcloud) \
x(feature.cloud) \ x(feature.cloud) \
x(feature.dnsannounce) x(feature.dnsannounce) \
x(feature.ntp)
//x(feature.gschisseneDiode) //x(feature.gschisseneDiode)
template<typename T> template<typename T>

View File

@@ -1,18 +1,7 @@
#pragma once #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 // local includes
#include "profilesettings.h" #include "profilesettings.h"
#include "ledstripdefines.h"
#include "ledstrip.h"
using namespace std::chrono_literals; using namespace std::chrono_literals;

View File

@@ -2,21 +2,8 @@
// system includes // system includes
#include <cstdint> #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 // local includes
#include "bobbycar-common.h"
#include "unifiedmodelmode.h" #include "unifiedmodelmode.h"
#include "modes/larsmmode.h" #include "modes/larsmmode.h"

View File

@@ -6,10 +6,8 @@
// esp-idf includes // esp-idf includes
#include <esp_log.h> #include <esp_log.h>
#include <nvs_flash.h> #include <nvs_flash.h>
#ifdef FEATURE_NTP
#include <lwip/apps/snmp.h> #include <lwip/apps/snmp.h>
#include <esp_sntp.h> #include <esp_sntp.h>
#endif
// 3rdparty lib includes // 3rdparty lib includes
#include <fmt/core.h> #include <fmt/core.h>
@@ -209,7 +207,6 @@ template<> struct nvsGetterHelper<espchrono::hours32> { static esp_err_t nvs_get
*out_value = espchrono::hours32(tempValue); *out_value = espchrono::hours32(tempValue);
return err; 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) 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; 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); *out_value = sntp_sync_mode_t(tempValue);
return err; 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) 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; 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()); 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) 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)); 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) 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)); return nvs_set_u32(handle, key, std::bit_cast<uint32_t>(value));

View File

@@ -30,9 +30,7 @@
#ifdef FEATURE_MOSFETS #ifdef FEATURE_MOSFETS
#include "mosfets.h" #include "mosfets.h"
#endif #endif
#ifdef FEATURE_NTP
#include "time_bobbycar.h" #include "time_bobbycar.h"
#endif
#include "potis.h" #include "potis.h"
#ifdef FEATURE_BLUETOOTH #ifdef FEATURE_BLUETOOTH
#include "bluetooth_bobby.h" #include "bluetooth_bobby.h"
@@ -97,9 +95,7 @@ BobbySchedulerTask schedulerTasksArr[] {
#ifdef FEATURE_MOSFETS #ifdef FEATURE_MOSFETS
BobbySchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms }, BobbySchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms },
#endif #endif
#ifdef FEATURE_NTP
BobbySchedulerTask { "time", initTime, updateTime, 100ms }, BobbySchedulerTask { "time", initTime, updateTime, 100ms },
#endif
BobbySchedulerTask { "potis", initPotis, readPotis, 20ms }, BobbySchedulerTask { "potis", initPotis, readPotis, 20ms },
#ifdef FEATURE_BLUETOOTH #ifdef FEATURE_BLUETOOTH
BobbySchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms }, BobbySchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms },

View File

@@ -2,10 +2,8 @@
// esp-idf includes // esp-idf includes
#include <esp_log.h> #include <esp_log.h>
#ifdef FEATURE_NTP
#include <lwip/apps/snmp.h> #include <lwip/apps/snmp.h>
#include <esp_sntp.h> #include <esp_sntp.h>
#endif
// 3rdparty lib includes // 3rdparty lib includes
#include <espstrutils.h> #include <espstrutils.h>
@@ -30,7 +28,6 @@ namespace {
constexpr const char * const TAG = "BOBBYTIME"; constexpr const char * const TAG = "BOBBYTIME";
} // namespace } // namespace
#ifdef FEATURE_NTP
void time_sync_notification_cb(struct timeval *tv); void time_sync_notification_cb(struct timeval *tv);
void initTime() void initTime()
@@ -54,6 +51,9 @@ void initTime()
void updateTime() void updateTime()
{ {
if (!configs.feature.ntp.value)
return;
if (bool(sntp_enabled()) != configs.timeServerEnabled.value) if (bool(sntp_enabled()) != configs.timeServerEnabled.value)
{ {
if (configs.timeServerEnabled.value) if (configs.timeServerEnabled.value)
@@ -107,7 +107,6 @@ void time_sync_notification_cb(struct timeval *tv)
else else
ESP_LOGI("BOBBY", "nullptr"); ESP_LOGI("BOBBY", "nullptr");
} }
#endif
void time_set_now(espchrono::utc_clock::time_point now) void time_set_now(espchrono::utc_clock::time_point now)
{ {

View File

@@ -7,9 +7,7 @@
espchrono::time_zone get_default_timezone() noexcept; espchrono::time_zone get_default_timezone() noexcept;
#ifdef FEATURE_NTP
void initTime(); void initTime();
void updateTime(); void updateTime();
#endif
void time_set_now(espchrono::utc_clock::time_point now); void time_set_now(espchrono::utc_clock::time_point now);