Moved FEATURE_LEDSTRIP into config-system

This commit is contained in:
CommanderRedYT
2022-01-17 13:02:57 +01:00
parent 0415d90d1b
commit 2117be359c
20 changed files with 31 additions and 62 deletions

View File

@ -171,7 +171,6 @@ struct MotortestModeMultiplikatorAccessor : public RefAccessorSaveSettings<uint8
struct MotortestMaxPwmAccessor : public RefAccessorSaveSettings<uint16_t> { uint16_t &getRef() const override { return profileSettings.motortestMode.maxPwm; } }; struct MotortestMaxPwmAccessor : public RefAccessorSaveSettings<uint16_t> { uint16_t &getRef() const override { return profileSettings.motortestMode.maxPwm; } };
// Ledstrip // Ledstrip
#ifdef FEATURE_LEDSTRIP
struct EnableLedAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableLedAnimation; } }; struct EnableLedAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableLedAnimation; } };
struct EnableBrakeLightsAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableBrakeLights; } }; struct EnableBrakeLightsAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableBrakeLights; } };
struct LedsCountAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.ledsCount; } }; struct LedsCountAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.ledsCount; } };
@ -204,7 +203,6 @@ struct LedstripEnableBlinkAnimationAccessor : public NewSettingsAccessor<bool> {
struct LedstripOtaAnimationAccessor : public NewSettingsAccessor<OtaAnimationModes> { ConfigWrapper<OtaAnimationModes> &getConfig() const override { return configs.ledstrip.otaMode; } }; struct LedstripOtaAnimationAccessor : public NewSettingsAccessor<OtaAnimationModes> { ConfigWrapper<OtaAnimationModes> &getConfig() const override { return configs.ledstrip.otaMode; } };
#endif #endif
struct LedstripEnableVisualizeBlinkAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableVisualizeBlink; } }; struct LedstripEnableVisualizeBlinkAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableVisualizeBlink; } };
#endif
// Battery // Battery
struct BatterySeriesCellsAccessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.battery.cellsSeries; } }; struct BatterySeriesCellsAccessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.battery.cellsSeries; } };

View File

@ -9,7 +9,6 @@
#include "newsettings.h" #include "newsettings.h"
#include "bobbyerrorhandler.h" #include "bobbyerrorhandler.h"
#ifdef FEATURE_LEDSTRIP
template<LedstripAnimation type> template<LedstripAnimation type>
class LedStripSetAnimationActionStatic : public virtual espgui::ActionInterface class LedStripSetAnimationActionStatic : public virtual espgui::ActionInterface
{ {
@ -29,5 +28,3 @@ public:
private: private:
const LedstripAnimation m_animation; const LedstripAnimation m_animation;
}; };
#endif

View File

@ -1,6 +1,5 @@
#include "ledstripblinkactions.h" #include "ledstripblinkactions.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h" #include "ledstrip.h"
#include "ledstripdefines.h" #include "ledstripdefines.h"
@ -39,4 +38,3 @@ void LedstripAnimationBlinkBothAction::triggered()
{ {
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH;
} }
#endif

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#ifdef FEATURE_LEDSTRIP
#include "actioninterface.h" #include "actioninterface.h"
class LedstripAnimationBlinkNoneAction : public virtual espgui::ActionInterface class LedstripAnimationBlinkNoneAction : public virtual espgui::ActionInterface
@ -34,4 +33,3 @@ class LedstripAnimationBlinkBothAction : public virtual espgui::ActionInterface
public: public:
void triggered() override; void triggered() override;
}; };
#endif

View File

@ -9,9 +9,7 @@
#include <futurecpp.h> #include <futurecpp.h>
// local includes // local includes
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h" #include "ledstrip.h"
#endif
#include "globals.h" #include "globals.h"
#include "modes/remotecontrolmode.h" #include "modes/remotecontrolmode.h"
#include "utils.h" #include "utils.h"
@ -246,10 +244,11 @@ void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
return; return;
} }
#ifdef FEATURE_LEDSTRIP if (configs.feature.ledstrip.value)
auto newBlinkAnimation = doc["anim"].as<int16_t>(); {
if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation; const auto newBlinkAnimation = doc["anim"].as<int16_t>();
#endif // FEATURE_LEDSTRIP if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation;
}
const bool isInverted = (profileSettings.controllerHardware.invertFrontLeft && !profileSettings.controllerHardware.invertFrontRight); const bool isInverted = (profileSettings.controllerHardware.invertFrontLeft && !profileSettings.controllerHardware.invertFrontRight);

View File

@ -6,10 +6,9 @@
// local includes // local includes
#include "newsettings.h" #include "newsettings.h"
#include "settingsutils.h" #include "settingsutils.h"
#ifdef FEATURE_LEDSTRIP #include "modes/defaultmode.h"
#include "ledstripdefines.h" #include "ledstripdefines.h"
#include "ledstrip.h" #include "ledstrip.h"
#endif
#include "bobbyquickactions.h" #include "bobbyquickactions.h"

View File

@ -82,7 +82,8 @@ void action_wifi_scan()
void blink_left() void blink_left()
{ {
#ifdef FEATURE_LEDSTRIP if (configs.feature.ledstrip.value)
{
if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to left if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to left
{ {
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT;
@ -95,12 +96,13 @@ void blink_left()
{ {
blinkAnimation = LEDSTRIP_OVERWRITE_NONE; blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
} }
#endif }
} }
void blink_right() void blink_right()
{ {
#ifdef FEATURE_LEDSTRIP if(configs.feature.ledstrip.value)
{
if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to right if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to right
{ {
blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT;
@ -113,7 +115,7 @@ void blink_right()
{ {
blinkAnimation = LEDSTRIP_OVERWRITE_NONE; blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
} }
#endif }
} }
void handle_handbremse() void handle_handbremse()

View File

@ -21,7 +21,6 @@
#include "globals.h" #include "globals.h"
#include "displays/menus/ledstripmenu.h" #include "displays/menus/ledstripmenu.h"
#ifdef FEATURE_LEDSTRIP
namespace { namespace {
constexpr char TEXT_LEDSTRIPCOLORMENU[] = "Customize Ledstrip"; constexpr char TEXT_LEDSTRIPCOLORMENU[] = "Customize Ledstrip";
@ -258,4 +257,3 @@ void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
} }
// espgui::tft.fillCircle(espgui::tft.width() / 2, 140, 100, TFT_BLACK); // espgui::tft.fillCircle(espgui::tft.width() / 2, 140, 100, TFT_BLACK);
} }
#endif

View File

@ -10,16 +10,6 @@
#include "bobbydisplaywithtitle.h" #include "bobbydisplaywithtitle.h"
#include "ledstrip.h" #include "ledstrip.h"
#ifdef FEATURE_LEDSTRIP
//extern int8_t selected_side;
//extern int8_t selected_color;
//extern bool state_select_color;
//extern bool last_state;
//extern const std::array<CRGB, 8> Colors;
//extern const std::array<uint16_t, 8> tft_colors;
class LedstripColorsDisplay : public BobbyDisplayWithTitle class LedstripColorsDisplay : public BobbyDisplayWithTitle
{ {
using Base = BobbyDisplayWithTitle; using Base = BobbyDisplayWithTitle;
@ -38,4 +28,3 @@ public:
private: private:
bool already_drew_circle{false}; bool already_drew_circle{false};
}; };
#endif

View File

@ -1,6 +1,5 @@
#include "ledstripmenu.h" #include "ledstripmenu.h"
#ifdef FEATURE_LEDSTRIP
// 3rdparty lib includes // 3rdparty lib includes
#include <FastLED.h> #include <FastLED.h>
#include <actioninterface.h> #include <actioninterface.h>
@ -185,4 +184,3 @@ void LedstripMenu::back()
{ {
espgui::switchScreen<MainMenu>(); espgui::switchScreen<MainMenu>();
} }
#endif

View File

@ -3,7 +3,6 @@
// local includes // local includes
#include "displays/menudisplaywithtime.h" #include "displays/menudisplaywithtime.h"
#ifdef FEATURE_LEDSTRIP
class LedstripMenu : public bobbygui::MenuDisplayWithTime class LedstripMenu : public bobbygui::MenuDisplayWithTime
{ {
public: public:
@ -13,4 +12,3 @@ public:
void back() override; void back() override;
}; };
#endif

View File

@ -1,7 +1,5 @@
#include "ledstripselectblinkmenu.h" #include "ledstripselectblinkmenu.h"
#ifdef FEATURE_LEDSTRIP
// 3rdparty lib includes // 3rdparty lib includes
#include "actions/dummyaction.h" #include "actions/dummyaction.h"
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
@ -83,4 +81,3 @@ std::string CurrentSelectedBlinkAnimationText::text() const
} }
} // namespace } // namespace
#endif

View File

@ -3,7 +3,6 @@
// Local includes // Local includes
#include "displays/bobbymenudisplay.h" #include "displays/bobbymenudisplay.h"
#ifdef FEATURE_LEDSTRIP
class LedstripSelectBlinkMenu : public BobbyMenuDisplay class LedstripSelectBlinkMenu : public BobbyMenuDisplay
{ {
public: public:
@ -12,4 +11,3 @@ public:
std::string text() const override; std::string text() const override;
void back() override; void back() override;
}; };
#endif

View File

@ -10,7 +10,7 @@
#include "utils.h" #include "utils.h"
#include "ledstripmenu.h" #include "ledstripmenu.h"
#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) #ifdef FEATURE_OTA
namespace { namespace {
constexpr char TEXT_BLINKANIMATION[] = "Blink animation"; constexpr char TEXT_BLINKANIMATION[] = "Blink animation";
constexpr char TEXT_OTAANIM_NONE[] = "None"; constexpr char TEXT_OTAANIM_NONE[] = "None";

View File

@ -3,7 +3,7 @@
// local includes // local includes
#include "displays/bobbymenudisplay.h" #include "displays/bobbymenudisplay.h"
#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) #ifdef FEATURE_OTA
class LedstripOtaAnimationChangeMenu : public BobbyMenuDisplay class LedstripOtaAnimationChangeMenu : public BobbyMenuDisplay
{ {
public: public:

View File

@ -42,9 +42,7 @@
#ifdef FEATURE_OTA #ifdef FEATURE_OTA
#include "icons/update.h" #include "icons/update.h"
#endif #endif
#ifdef FEATURE_LEDSTRIP
#include "icons/neopixel.h" #include "icons/neopixel.h"
#endif
#include "icons/poweroff.h" #include "icons/poweroff.h"
#include "icons/reboot.h" #include "icons/reboot.h"
#include "icons/statistics.h" #include "icons/statistics.h"
@ -89,9 +87,10 @@ MainMenu::MainMenu()
// constructMenuItem<makeComponent<MenuItem, mainmenu::CurrentTimeText, DummyAction, StaticMenuItemIcon<&bobbyicons::time>>>(); // constructMenuItem<makeComponent<MenuItem, mainmenu::CurrentTimeText, DummyAction, StaticMenuItemIcon<&bobbyicons::time>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>();
#ifdef FEATURE_LEDSTRIP if (configs.feature.ledstrip.value)
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&bobbyicons::neopixel>>>(); {
#endif constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&bobbyicons::neopixel>>>();
}
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATISTICSMENU>, SwitchScreenAction<StatisticsMenu>, StaticMenuItemIcon<&bobbyicons::statistics>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATISTICSMENU>, SwitchScreenAction<StatisticsMenu>, StaticMenuItemIcon<&bobbyicons::statistics>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&bobbyicons::modes>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&bobbyicons::modes>>>();
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); } if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); }

View File

@ -103,7 +103,8 @@ void StatusDisplay::redraw()
tft.fillRect(0, tft.height()-6, tft.width(), 6, TFT_BLACK); tft.fillRect(0, tft.height()-6, tft.width(), 6, TFT_BLACK);
} }
} }
#ifdef FEATURE_LEDSTRIP
if(configs.feature.ledstrip.value)
{ {
static bool blink_fill_with_black; static bool blink_fill_with_black;
if (configs.ledstrip.enableVisualizeBlink.value && (espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) && (blinkAnimation > 0)) if (configs.ledstrip.enableVisualizeBlink.value && (espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) && (blinkAnimation > 0))
@ -126,7 +127,6 @@ void StatusDisplay::redraw()
m_progressBarGas.start(); m_progressBarGas.start();
} }
} }
#endif
tft.setTextFont(2); tft.setTextFont(2);
m_labelRawGas.redraw(raw_gas ? std::to_string(*raw_gas) : "?"); m_labelRawGas.redraw(raw_gas ? std::to_string(*raw_gas) : "?");

View File

@ -13,7 +13,6 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
#ifdef FEATURE_LEDSTRIP
std::vector<CRGB> leds; std::vector<CRGB> leds;
uint8_t gHue = 0; uint8_t gHue = 0;
@ -22,13 +21,19 @@ uint16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
void initLedStrip() void initLedStrip()
{ {
leds.resize(configs.ledstrip.ledsCount.value); if (configs.feature.ledstrip.value)
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size()) {
.setCorrection(TypicalSMD5050); leds.resize(configs.ledstrip.ledsCount.value);
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size())
.setCorrection(TypicalSMD5050);
}
} }
void updateLedStrip() void updateLedStrip()
{ {
if(!configs.feature.ledstrip.value)
return;
EVERY_N_MILLISECONDS( 20 ) { gHue++; } EVERY_N_MILLISECONDS( 20 ) { gHue++; }
static bool have_disabled_beeper = false; static bool have_disabled_beeper = false;
const bool enAnim = configs.ledstrip.enableAnimBlink.value; const bool enAnim = configs.ledstrip.enableAnimBlink.value;
@ -347,5 +352,3 @@ void showCustomColor()
std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_LEFT)]); // Front Left std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_LEFT)]); // Front Left
#endif #endif
} }
#endif

View File

@ -23,7 +23,6 @@ DECLARE_BOBBYTYPESAFE_ENUM(OtaAnimationModes, : uint8_t, OtaAnimationModesValues
x(CustomColor) x(CustomColor)
DECLARE_BOBBYTYPESAFE_ENUM(LedstripAnimation, : uint8_t, LedstripAnimationValues) DECLARE_BOBBYTYPESAFE_ENUM(LedstripAnimation, : uint8_t, LedstripAnimationValues)
#ifdef FEATURE_LEDSTRIP
enum Bobbycar_Side enum Bobbycar_Side
{ {
FRONT_RIGHT, FRONT_RIGHT,
@ -52,4 +51,3 @@ void showOtaAnimation();
void initLedStrip(); void initLedStrip();
void updateLedStrip(); void updateLedStrip();
#endif

View File

@ -38,7 +38,7 @@ typename std::enable_if<
!std::is_same<T, espchrono::minutes32>::value && !std::is_same<T, espchrono::minutes32>::value &&
!std::is_same<T, espchrono::DayLightSavingMode>::value && !std::is_same<T, espchrono::DayLightSavingMode>::value &&
!std::is_same<T, UnifiedModelMode>::value !std::is_same<T, UnifiedModelMode>::value
#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) #ifdef FEATURE_OTA
&& !std::is_same<T, OtaAnimationModes>::value && !std::is_same<T, OtaAnimationModes>::value
#endif #endif
, bool>::type , bool>::type
@ -120,7 +120,7 @@ showInputForSetting(std::string_view key, T value, JsonObject &body)
return true; return true;
} }
#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) #ifdef FEATURE_OTA
template<typename T> template<typename T>
typename std::enable_if< typename std::enable_if<