Merge pull request #270 from bobbycar-graz/better-flags-menu
This commit is contained in:
@ -104,7 +104,7 @@ void initBle()
|
||||
|
||||
void handleBle()
|
||||
{
|
||||
if (!configs.feature.ble.value)
|
||||
if (!configs.feature.ble.isEnabled.value)
|
||||
return;
|
||||
|
||||
if (configs.bleSettings.bleEnabled.value)
|
||||
@ -237,7 +237,7 @@ void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
|
||||
return;
|
||||
}
|
||||
|
||||
if (configs.feature.ledstrip.value)
|
||||
if (configs.feature.ledstrip.isEnabled.value)
|
||||
{
|
||||
const auto newBlinkAnimation = doc["anim"].as<int16_t>();
|
||||
if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation;
|
||||
|
@ -56,7 +56,7 @@ void handle_bobby_quickaction(espgui::Button button)
|
||||
|
||||
void open_garage()
|
||||
{
|
||||
if (!configs.feature.esp_now.value)
|
||||
if (!configs.feature.esp_now.isEnabled.value)
|
||||
return;
|
||||
|
||||
if (!espnow::espnow_init_allowed())
|
||||
@ -82,7 +82,7 @@ void action_wifi_scan()
|
||||
|
||||
void blink_left()
|
||||
{
|
||||
if (configs.feature.ledstrip.value)
|
||||
if (configs.feature.ledstrip.isEnabled.value)
|
||||
{
|
||||
if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to left
|
||||
{
|
||||
@ -101,7 +101,7 @@ void blink_left()
|
||||
|
||||
void blink_right()
|
||||
{
|
||||
if(configs.feature.ledstrip.value)
|
||||
if(configs.feature.ledstrip.isEnabled.value)
|
||||
{
|
||||
if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to right
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ void initCloud()
|
||||
|
||||
void updateCloud()
|
||||
{
|
||||
if (!configs.feature.cloud.value)
|
||||
if (!configs.feature.cloud.isEnabled.value)
|
||||
return;
|
||||
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
|
@ -68,7 +68,7 @@ DebugMenu::DebugMenu()
|
||||
#endif
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_QRCODE_DEBUG>, SwitchScreenAction<QrCodeDebugDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERYDEBUG>, SwitchScreenAction<BatteryDebugMenu>, StaticMenuItemIcon<&bobbyicons::battery>>>();
|
||||
if (configs.feature.udpcloud.value)
|
||||
if (configs.feature.udpcloud.isEnabled.value)
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TOGGLECLOUDDEBUG>, BobbyCheckbox, CloudDebugEnableAccessor>>();
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
#include "featureflagsmenu.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
#include <TFT_eSPI.h>
|
||||
#include <actions/switchscreenaction.h>
|
||||
#include <fmt/core.h>
|
||||
#include <icons/back.h>
|
||||
#include <strutils.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbycheckbox.h"
|
||||
#include "displays/bobbypopupdisplay.h"
|
||||
#include "displays/menus/settingsmenu.h"
|
||||
#include "bobbycheckbox.h"
|
||||
#include "newsettings.h"
|
||||
#include "taskmanager.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
@ -22,29 +24,49 @@ constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
class FeatureFlagMenuItem : public MenuItem, public virtual BobbyErrorHandler {
|
||||
public:
|
||||
explicit FeatureFlagMenuItem(ConfigWrapper<bool> &config) : m_config{config} {}
|
||||
explicit FeatureFlagMenuItem(ConfiguredFeatureFlag &flag, bool isInitialized) : m_flag{flag}, m_isInitialized{isInitialized} {}
|
||||
std::string text() const override
|
||||
{
|
||||
std::string_view name = m_config.nvsName();
|
||||
std::string_view name = m_flag.isEnabled.nvsName();
|
||||
constexpr const std::string_view prefix = "f_";
|
||||
if (cpputils::stringStartsWith(name, prefix)) {
|
||||
name.remove_prefix(prefix.size());
|
||||
}
|
||||
return std::string{name};
|
||||
std::string return_name = std::string{name};
|
||||
return_name += m_flag.isBeta() ? " (beta)" : "";
|
||||
return return_name;
|
||||
}
|
||||
|
||||
int color() const override
|
||||
{
|
||||
if (m_isInitialized)
|
||||
{
|
||||
return m_flag.isBeta() ? TFT_YELLOW : TFT_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_flag.isEnabled.value)
|
||||
{
|
||||
return TFT_RED;
|
||||
}
|
||||
else
|
||||
return m_flag.isBeta() ? TFT_ORANGE : TFT_GREY;
|
||||
}
|
||||
}
|
||||
|
||||
void triggered() override
|
||||
{
|
||||
if (auto result = m_config.write(configs.nvs_handle_user, !m_config.value); !result)
|
||||
if (auto result = m_flag.isEnabled.write(configs.nvs_handle_user, !m_flag.isEnabled.value); !result)
|
||||
errorOccured(std::move(result).error());
|
||||
}
|
||||
|
||||
const MenuItemIcon *icon() const override
|
||||
{
|
||||
return m_config.value ? &icons::checked : &icons::unchecked;
|
||||
return m_flag.isEnabled.value ? &icons::checked : &icons::unchecked;
|
||||
}
|
||||
private:
|
||||
ConfigWrapper<bool> &m_config;
|
||||
ConfiguredFeatureFlag &m_flag;
|
||||
const bool m_isInitialized;
|
||||
};
|
||||
|
||||
// TODO: Replace SwitchScreenAction / switchScreen with this action. Needs: BobbyPopupDisplayWithCustomExitAction => pass SwitchScreenAction<SettingsMenu> into it
|
||||
@ -62,8 +84,14 @@ public:
|
||||
|
||||
FeatureFlagsMenu::FeatureFlagsMenu()
|
||||
{
|
||||
configs.callForEveryFeature([&](ConfigWrapper<bool> &feature){
|
||||
constructMenuItem<FeatureFlagMenuItem>(feature);
|
||||
configs.callForEveryFeature([&](ConfiguredFeatureFlag &feature){
|
||||
const std::string name = feature.getTaskName();
|
||||
if (const auto err = checkInitializedByName(name); err)
|
||||
{
|
||||
constructMenuItem<FeatureFlagMenuItem>(feature, *err);
|
||||
}
|
||||
else
|
||||
constructMenuItem<FeatureFlagMenuItem>(feature, true);
|
||||
});
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>>>();
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ LedstripMenu::LedstripMenu()
|
||||
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTLENGTH, LedsStVOFrontLengthAccessor>, espgui::SwitchScreenAction<StVOLengthChangeScreen>>>(); }
|
||||
|
||||
constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_BLINKANIMATION>, espgui::SwitchScreenAction<LedstripSelectBlinkMenu>>>();
|
||||
if (configs.feature.ota.value)
|
||||
if (configs.feature.ota.isEnabled.value)
|
||||
if (!simplified) { constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_LEDSTRIP_CHANGE_OTA_ANIM>, espgui::SwitchScreenAction<LedstripOtaAnimationChangeMenu>>>(); }
|
||||
constructMenuItem<makeComponent<MenuItem, espgui::StaticText<TEXT_ANIMATION_MULTIPLIER>, espgui::SwitchScreenAction<AnimationMultiplierChangeScreen>>>();
|
||||
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, espgui::SwitchScreenAction<LedsCountChangeScreen>>>(); }
|
||||
|
@ -83,7 +83,7 @@ MainMenu::MainMenu()
|
||||
|
||||
// constructMenuItem<makeComponent<MenuItem, mainmenu::CurrentTimeText, DummyAction, StaticMenuItemIcon<&bobbyicons::time>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
if (configs.feature.ledstrip.value)
|
||||
if (configs.feature.ledstrip.isEnabled.value)
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&bobbyicons::neopixel>>>();
|
||||
}
|
||||
@ -94,11 +94,11 @@ MainMenu::MainMenu()
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&bobbyicons::settings>>>(); }
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GREENPASS>, SwitchScreenAction<GreenPassMenu>, StaticMenuItemIcon<&bobbyicons::greenpass>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&bobbyicons::lock>>>();
|
||||
if (configs.feature.garage.value && configs.feature.esp_now.value)
|
||||
if (configs.feature.garage.isEnabled.value && configs.feature.esp_now.isEnabled.value)
|
||||
{
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageMenu>>>(); }
|
||||
}
|
||||
if (configs.feature.ota.value)
|
||||
if (configs.feature.ota.isEnabled.value)
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATE>, SwitchScreenAction<OtaMenu>, StaticMenuItemIcon<&bobbyicons::update>>>(); }
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&bobbyicons::graph>>>(); }
|
||||
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
|
||||
|
@ -84,18 +84,18 @@ SettingsMenu::SettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LIMITSSETTINGS>, SwitchScreenAction<LimitsSettingsMenu>>>();
|
||||
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NETWORKSETTINGS>, SwitchScreenAction<NetworkSettingsMenu>, StaticMenuItemIcon<&bobbyicons::wifi>>>();
|
||||
if (configs.feature.esp_now.value)
|
||||
if (configs.feature.esp_now.isEnabled.value)
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ESPNOW>, SwitchScreenAction<EspNowMenu>, StaticMenuItemIcon<&bobbyicons::wifi>>>();
|
||||
#ifdef FEATURE_BLUETOOTH
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&bobbyicons::bluetooth>>>();
|
||||
#endif
|
||||
if (configs.feature.ble.value)
|
||||
if (configs.feature.ble.isEnabled.value)
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLESETTINGS>, SwitchScreenAction<BleSettingsMenu>, StaticMenuItemIcon<&bobbyicons::bluetooth>>>();
|
||||
if (configs.feature.cloud.value)
|
||||
if (configs.feature.cloud.isEnabled.value)
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSETTINGS>, SwitchScreenAction<CloudSettingsMenu>>>();
|
||||
if (configs.feature.udpcloud.value)
|
||||
if (configs.feature.udpcloud.isEnabled.value)
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UDPCLOUDSETTINGS>, SwitchScreenAction<UdpCloudSettingsMenu>>>();
|
||||
if (configs.feature.ota.value)
|
||||
if (configs.feature.ota.isEnabled.value)
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTBUILDSERVERMENU>, SwitchScreenAction<SelectBuildServerMenu>, StaticMenuItemIcon<&bobbyicons::update>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TIME>, SwitchScreenAction<TimeSettingsMenu>, StaticMenuItemIcon<&bobbyicons::time>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>>();
|
||||
|
@ -110,7 +110,7 @@ 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>>>();
|
||||
if (configs.feature.ntp.value)
|
||||
if (configs.feature.ntp.isEnabled.value)
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPENABLED>, BobbyCheckbox, TimeServerEnabledAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NTPSERVER>, SwitchScreenAction<TimeServerChangeDisplay>>>();
|
||||
|
@ -104,7 +104,7 @@ void StatusDisplay::redraw()
|
||||
}
|
||||
}
|
||||
|
||||
if(configs.feature.ledstrip.value)
|
||||
if(configs.feature.ledstrip.isEnabled.value)
|
||||
{
|
||||
static bool blink_fill_with_black;
|
||||
if (configs.ledstrip.enableVisualizeBlink.value && (espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) && (blinkAnimation > 0))
|
||||
@ -151,7 +151,7 @@ void StatusDisplay::redraw()
|
||||
|
||||
tft.setTextFont(2);
|
||||
|
||||
if (configs.feature.udpcloud.value)
|
||||
if (configs.feature.udpcloud.isEnabled.value)
|
||||
{
|
||||
if(configs.udpCloudSettings.udpCloudEnabled.value && configs.udpCloudSettings.enableCloudDebug.value)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ void init_dns_announce()
|
||||
|
||||
void handle_dns_announce()
|
||||
{
|
||||
if (!configs.feature.dnsannounce.value || !configs.dns_announce_enabled.value)
|
||||
if (!configs.feature.dnsannounce.isEnabled.value || !configs.dns_announce_enabled.value)
|
||||
return;
|
||||
|
||||
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
|
||||
|
@ -85,7 +85,7 @@ std::array<bool, 10> Helper<OUT, IN1, IN2, IN3, IN4, IN5>::read()
|
||||
result[7] = digitalRead(IN4);
|
||||
result[9] = digitalRead(IN5);
|
||||
|
||||
if (configs.feature.gschissene_diode.value && (result[8] && result[9]))
|
||||
if (configs.feature.gschissene_diode.isEnabled.value && (result[8] && result[9]))
|
||||
{
|
||||
result[9] = 0;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace {
|
||||
|
||||
void initLedStrip()
|
||||
{
|
||||
if (configs.feature.ledstrip.value)
|
||||
if (configs.feature.ledstrip.isEnabled.value)
|
||||
{
|
||||
leds.resize(configs.ledstrip.ledsCount.value);
|
||||
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size())
|
||||
@ -35,16 +35,16 @@ void initLedStrip()
|
||||
|
||||
void updateLedStrip()
|
||||
{
|
||||
if (configs.feature.ledstrip.value && !initialized)
|
||||
if (configs.feature.ledstrip.isEnabled.value && !initialized)
|
||||
initLedStrip();
|
||||
else if (!configs.feature.ledstrip.value && initialized)
|
||||
else if (!configs.feature.ledstrip.isEnabled.value && initialized)
|
||||
{
|
||||
std::fill(std::begin(leds), std::end(leds), CRGB::Black);
|
||||
FastLED.show();
|
||||
initialized = false;
|
||||
return;
|
||||
}
|
||||
else if (!configs.feature.ledstrip.value)
|
||||
else if (!configs.feature.ledstrip.isEnabled.value)
|
||||
return;
|
||||
|
||||
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
|
||||
|
@ -65,8 +65,11 @@ extern "C" void app_main()
|
||||
|
||||
for (const auto &task : schedulerTasks)
|
||||
{
|
||||
bootLabel.redraw(task.name());
|
||||
task.setup();
|
||||
if (checkEnabledByName(task.name()))
|
||||
{
|
||||
bootLabel.redraw(task.name());
|
||||
task.setup();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEATURE_JOYSTICK
|
||||
|
@ -3,30 +3,30 @@
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// system includes
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_sntp.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
#include <configmanager.h>
|
||||
#include <configconstraints_base.h>
|
||||
#include <configconstraints_espchrono.h>
|
||||
#include <configmanager.h>
|
||||
#include <configwrapper.h>
|
||||
#include <espwifiutils.h>
|
||||
#include <espchrono.h>
|
||||
#include <espwifiutils.h>
|
||||
#include <fmt/core.h>
|
||||
#include <makearray.h>
|
||||
|
||||
// local includes
|
||||
#include "battery.h"
|
||||
#include "ledstrip.h"
|
||||
#include "unifiedmodelmode.h"
|
||||
#include "bobbyquickactions.h"
|
||||
#include "displays/lockscreen.h"
|
||||
#include "handbremse.h"
|
||||
#include "bobbyquickactions.h"
|
||||
#include "ledstrip.h"
|
||||
#include "unifiedmodelmode.h"
|
||||
|
||||
using namespace espconfig;
|
||||
|
||||
@ -103,6 +103,23 @@ public:
|
||||
ConfigWrapper<std::string> url;
|
||||
};
|
||||
|
||||
class ConfiguredFeatureFlag
|
||||
{
|
||||
public:
|
||||
ConfiguredFeatureFlag(const char *enabledKey, const bool default_enabled = false, const bool default_is_beta = false, const char* taskName = "") :
|
||||
isEnabled{default_enabled, DoReset, {}, enabledKey },
|
||||
m_isBeta{default_is_beta},
|
||||
m_taskName{taskName}
|
||||
{}
|
||||
|
||||
ConfigWrapper<bool> isEnabled;
|
||||
bool isBeta() const { return m_isBeta; }
|
||||
std::string getTaskName() const { return m_taskName; }
|
||||
private:
|
||||
const bool m_isBeta;
|
||||
const std::string m_taskName;
|
||||
};
|
||||
|
||||
class ConfigContainer
|
||||
{
|
||||
using mac_t = wifi_stack::mac_t;
|
||||
@ -321,18 +338,18 @@ public:
|
||||
} espnow;
|
||||
|
||||
struct {
|
||||
ConfigWrapper<bool> ledstrip {false, DoReset, {}, "f_ledstrip" };
|
||||
ConfigWrapper<bool> webserver_disable_lock{false, DoReset, {}, "f_no_web_lock" };
|
||||
ConfigWrapper<bool> garage {false, DoReset, {}, "f_garage" };
|
||||
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> ble {false, DoReset, {}, "f_ble" };
|
||||
ConfigWrapper<bool> ota {false, DoReset, {}, "f_ota" };
|
||||
ConfigWrapper<bool> webserver {true, DoReset, {}, "featureWebserv" };
|
||||
ConfigWrapper<bool> gschissene_diode {false, DoReset, {}, "featurDiodeHin" };
|
||||
ConfigWrapper<bool> esp_now {false, DoReset, {}, "featureEspNow" };
|
||||
ConfiguredFeatureFlag ledstrip {"f_ledstrip", false, false, "ledstrip"};
|
||||
ConfiguredFeatureFlag webserver_disable_lock{"f_no_web_lock", false, true};
|
||||
ConfiguredFeatureFlag garage {"f_garage" };
|
||||
ConfiguredFeatureFlag cloud {"f_cloud", false, false, "cloud"};
|
||||
ConfiguredFeatureFlag udpcloud {"f_udpcloud", false, false, "udpcloud"};
|
||||
ConfiguredFeatureFlag dnsannounce {"f_dnsannounce"};
|
||||
ConfiguredFeatureFlag ntp {"f_ntp", false, false, "time"};
|
||||
ConfiguredFeatureFlag ble {"f_ble", false, false, "ble"};
|
||||
ConfiguredFeatureFlag ota {"f_ota", false, false, "ota"};
|
||||
ConfiguredFeatureFlag webserver {"featureWebserv", true};
|
||||
ConfiguredFeatureFlag gschissene_diode {"featurDiodeHin"};
|
||||
ConfiguredFeatureFlag esp_now {"featureEspNow", false, false, "espnow"};
|
||||
} feature;
|
||||
|
||||
struct {
|
||||
@ -624,33 +641,33 @@ public:
|
||||
x(espnow.syncTimeWithOthers) \
|
||||
x(espnow.syncBlink) \
|
||||
\
|
||||
x(feature.ledstrip) \
|
||||
x(feature.webserver_disable_lock) \
|
||||
x(feature.garage) \
|
||||
x(feature.udpcloud) \
|
||||
x(feature.cloud) \
|
||||
x(feature.dnsannounce) \
|
||||
x(feature.ntp) \
|
||||
x(feature.ble) \
|
||||
x(feature.ota) \
|
||||
x(feature.webserver) \
|
||||
x(feature.gschissene_diode) \
|
||||
x(feature.esp_now)
|
||||
x(feature.ble.isEnabled) \
|
||||
x(feature.cloud.isEnabled) \
|
||||
x(feature.dnsannounce.isEnabled)\
|
||||
x(feature.esp_now.isEnabled) \
|
||||
x(feature.garage.isEnabled) \
|
||||
x(feature.gschissene_diode.isEnabled) \
|
||||
x(feature.ledstrip.isEnabled) \
|
||||
x(feature.ntp.isEnabled) \
|
||||
x(feature.ota.isEnabled) \
|
||||
x(feature.udpcloud.isEnabled) \
|
||||
x(feature.webserver.isEnabled) \
|
||||
x(feature.webserver_disable_lock.isEnabled)
|
||||
//x(bleSettings.bleEnabled)
|
||||
|
||||
#define FEATURES(x) \
|
||||
x(feature.ledstrip) \
|
||||
x(feature.webserver_disable_lock) \
|
||||
x(feature.garage) \
|
||||
x(feature.udpcloud) \
|
||||
x(feature.cloud) \
|
||||
x(feature.dnsannounce) \
|
||||
x(feature.ntp) \
|
||||
x(feature.ble) \
|
||||
x(feature.ota) \
|
||||
x(feature.esp_now) \
|
||||
x(feature.webserver)
|
||||
//x(feature.gschisseneDiode)
|
||||
x(feature.cloud) \
|
||||
x(feature.dnsannounce)\
|
||||
x(feature.esp_now) \
|
||||
x(feature.garage) \
|
||||
x(feature.gschissene_diode) \
|
||||
x(feature.ledstrip) \
|
||||
x(feature.ntp) \
|
||||
x(feature.ota) \
|
||||
x(feature.udpcloud) \
|
||||
x(feature.webserver) \
|
||||
// x(feature.webserver_disable_lock)
|
||||
|
||||
template<typename T>
|
||||
void callForEveryConfig(T &&callback)
|
||||
@ -677,16 +694,16 @@ public:
|
||||
#define HELPER(x) callback(x);
|
||||
FEATURES(HELPER)
|
||||
#undef HELPER
|
||||
callback(feature.gschissene_diode);
|
||||
callback(feature.webserver_disable_lock);
|
||||
}
|
||||
|
||||
auto getAllFeatureParams()
|
||||
{
|
||||
return cpputils::make_array(
|
||||
#define HELPER(x) std::ref<ConfigWrapperInterface>(x),
|
||||
#define HELPER(x) std::ref<ConfiguredFeatureFlag>(x),
|
||||
FEATURES(HELPER)
|
||||
#undef HELPER
|
||||
std::ref<ConfigWrapperInterface>(feature.gschissene_diode)
|
||||
std::ref<ConfiguredFeatureFlag>(feature.webserver_disable_lock)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ void handleOta()
|
||||
|
||||
tl::expected<void, std::string> triggerOta(std::string_view url)
|
||||
{
|
||||
if (!configs.feature.ota.value)
|
||||
if (!configs.feature.ota.isEnabled.value)
|
||||
return tl::make_unexpected("OTA is not enabled!");
|
||||
|
||||
ESP_LOGI(TAG, "%.*s", url.size(), url.data());
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// system includes
|
||||
#include <iterator>
|
||||
#include <chrono>
|
||||
|
||||
// esp-idf includes
|
||||
@ -137,3 +136,24 @@ void sched_pushStats(bool printTasks)
|
||||
if (printTasks)
|
||||
ESP_LOGI(TAG, "end listing tasks");
|
||||
}
|
||||
|
||||
tl::expected<bool, std::string> checkInitializedByName(std::string name)
|
||||
{
|
||||
for (auto &schedulerTask : schedulerTasks)
|
||||
{
|
||||
// ESP_LOGE(TAG, "%s == %s", schedulerTask.name(), name.c_str());
|
||||
if (schedulerTask.name() == name)
|
||||
return schedulerTask.isInitialized();
|
||||
}
|
||||
return tl::make_unexpected("Task not found: " + std::string{name});
|
||||
}
|
||||
|
||||
bool checkEnabledByName(std::string name) {
|
||||
bool enabled = true;
|
||||
// iterate over all feature flags (runForEveryFeature())
|
||||
configs.callForEveryFeature([&](ConfiguredFeatureFlag &feature) {
|
||||
if (feature.getTaskName() == name)
|
||||
enabled = feature.isEnabled.value;
|
||||
});
|
||||
return enabled;
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// system includes
|
||||
#include <optional>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <arrayview.h>
|
||||
#include <tl/expected.hpp>
|
||||
|
||||
// local includes
|
||||
#include "bobbyschedulertask.h"
|
||||
@ -11,3 +15,7 @@ extern cpputils::ArrayView<BobbySchedulerTask> schedulerTasks;
|
||||
extern const BobbySchedulerTask &drivingModeTask;
|
||||
|
||||
void sched_pushStats(bool printTasks);
|
||||
|
||||
tl::expected<bool, std::string> checkInitializedByName(std::string name);
|
||||
|
||||
bool checkEnabledByName(std::string name);
|
||||
|
@ -51,7 +51,7 @@ void initTime()
|
||||
|
||||
void updateTime()
|
||||
{
|
||||
if (!configs.feature.ntp.value)
|
||||
if (!configs.feature.ntp.isEnabled.value)
|
||||
return;
|
||||
|
||||
if (bool(sntp_enabled()) != configs.timeServerEnabled.value)
|
||||
|
@ -39,7 +39,7 @@ void udpCloudInit()
|
||||
|
||||
void udpCloudUpdate()
|
||||
{
|
||||
if (!configs.feature.udpcloud.value)
|
||||
if (!configs.feature.udpcloud.isEnabled.value)
|
||||
return;
|
||||
|
||||
if (configs.udpCloudSettings.udpCloudEnabled.value && configs.udpCloudSettings.udpUid.touched())
|
||||
|
@ -44,7 +44,7 @@ esp_err_t webserver_status_handler(httpd_req_t *req);
|
||||
esp_err_t webserver_middleware_handler(httpd_req_t *req) {
|
||||
const auto handler = reinterpret_cast<esp_err_t(*)(httpd_req_t*)>(req->user_ctx);
|
||||
|
||||
if (configs.feature.webserver_disable_lock.value)
|
||||
if (configs.feature.webserver_disable_lock.isEnabled.value)
|
||||
{
|
||||
return handler(req);
|
||||
}
|
||||
@ -71,7 +71,7 @@ httpd_handle_t httpdHandle;
|
||||
|
||||
void initWebserver()
|
||||
{
|
||||
if(!configs.feature.webserver_disable_lock.value)
|
||||
if(!configs.feature.webserver_disable_lock.isEnabled.value)
|
||||
{
|
||||
webserver_lock.construct();
|
||||
webserver_lock->take(portMAX_DELAY);
|
||||
@ -117,7 +117,7 @@ void initWebserver()
|
||||
|
||||
void handleWebserver()
|
||||
{
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
if (!configs.feature.webserver_disable_lock.isEnabled.value)
|
||||
{
|
||||
webserver_lock->give();
|
||||
vTaskDelay(1);
|
||||
|
Reference in New Issue
Block a user