Moved settings.ledstrip

This commit is contained in:
CommanderRedYT
2022-01-02 22:43:33 +01:00
parent d276cadc33
commit 7f924d8cc2
7 changed files with 119 additions and 175 deletions

View File

@ -176,36 +176,36 @@ struct MotortestMaxPwmAccessor : public RefAccessorSaveSettings<uint16_t> { uint
// Ledstrip
#ifdef FEATURE_LEDSTRIP
struct EnableLedAnimationAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableLedAnimation; } };
struct EnableBrakeLightsAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBrakeLights; } };
struct LedsCountAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.ledsCount; } };
struct CenterOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.centerOffset; } };
struct SmallOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.smallOffset; } };
struct BigOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.bigOffset; } };
struct LedStripMaxMilliampsAccessor : public NewSettingsAccessor<uint32_t> { ConfigWrapper<uint32_t> &getConfig() const override { return configs.ledStripMaxMilliamps; } };
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 LedsCountAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.ledsCount; } };
struct CenterOffsetAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.centerOffset; } };
struct SmallOffsetAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.smallOffset; } };
struct BigOffsetAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.bigOffset; } };
struct LedStripMaxMilliampsAccessor : public NewSettingsAccessor<uint32_t> { ConfigWrapper<uint32_t> &getConfig() const override { return configs.ledstrip.maxMilliamps; } };
struct LedStripMaxAmpereAccessor : public virtual espgui::AccessorInterface<float>
{
float getValue() const override
{
return configs.ledStripMaxMilliamps.value / 1000.f;
return configs.ledstrip.maxMilliamps.value / 1000.f;
}
espgui::AccessorInterface<float>::setter_result_t setValue(float value) override
{
return configs.write_config(configs.ledStripMaxMilliamps, value * 1000);
return configs.write_config(configs.ledstrip.maxMilliamps, value * 1000);
}
};
struct EnableBeepWhenBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBeepWhenBlink; } };
struct EnableFullBlinkAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableFullBlink; } };
struct EnableLedstripStVOAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableStVO; } };
struct LedsStVOFrontOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.stvoFrontOffset; } };
struct LedsStVOFrontLengthAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.stvoFrontLength; } };
struct EnableLedstripStVOFrontlight : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.stvoFrontEnable; } };
struct AnimationMultiplierAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.animationMultiplier; } };
struct LedstripBrightnessAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.ledstrip.brightness; } };
struct LedstripEnableBlinkAnimationAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableAnimBlink; } };
struct EnableBeepWhenBlinkAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableBeepWhenBlink; } };
struct EnableFullBlinkAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableFullBlink; } };
struct EnableLedstripStVOAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableStVO; } };
struct LedsStVOFrontOffsetAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.stvoFrontOffset; } };
struct LedsStVOFrontLengthAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.stvoFrontLength; } };
struct EnableLedstripStVOFrontlight : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.stvoFrontEnable; } };
struct AnimationMultiplierAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.ledstrip.animationMultiplier; } };
struct LedstripBrightnessAccessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.ledstrip.brightness; } };
struct LedstripEnableBlinkAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableAnimBlink; } };
#ifdef FEATURE_OTA
struct LedstripOtaAnimationAccessor : public RefAccessorSaveSettings<OtaAnimationModes> { OtaAnimationModes &getRef() const override { return settings.ledstrip.otaMode; } };
struct LedstripOtaAnimationAccessor : public NewSettingsAccessor<OtaAnimationModes> { ConfigWrapper<OtaAnimationModes> &getConfig() const override { return configs.ledstrip.otaMode; } };
#endif
#endif

View File

@ -136,7 +136,7 @@ class LedStripMaxCurrentText : public virtual espgui::TextInterface
public:
std::string text() const override
{
return fmt::format("&sLedstrip max current: &f&2{:.02f}A", configs.ledStripMaxMilliamps.value / 1000.f);
return fmt::format("&sLedstrip max current: &f&2{:.02f}A", configs.ledstrip.maxMilliamps.value / 1000.f);
}
};
} // namespace

View File

@ -6,7 +6,7 @@
// local includes
#include "ledstrip.h"
#include "globals.h"
#include "newsettings.h"
#include "utils.h"
#include "ledstripmenu.h"
@ -24,8 +24,7 @@ class LedstripChangeOtaAnimModeAction : public virtual espgui::ActionInterface
public:
void triggered() override
{
settings.ledstrip.otaMode = mode;
saveSettings();
configs.write_config(configs.ledstrip.otaMode, mode);
}
};
} // namespace

View File

@ -23,8 +23,8 @@ LedstripAnimation animation_type = LedstripAnimation::DefaultRainbow;
void initLedStrip()
{
animation_type = LedstripAnimation(settings.ledstrip.animationType);
leds.resize(settings.ledstrip.ledsCount);
animation_type = LedstripAnimation(configs.ledstrip.animationType.value);
leds.resize(configs.ledstrip.ledsCount.value);
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size())
.setCorrection(TypicalSMD5050);
}
@ -33,15 +33,15 @@ void updateLedStrip()
{
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
static bool have_disabled_beeper = false;
const bool enAnim = settings.ledstrip.enableAnimBlink;
const bool enAnim = configs.ledstrip.enableAnimBlink.value;
if (cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH))
{
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
if (espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms || enAnim)
{
const auto anim_to_fill = time_to_percent(750ms, 500ms, 100ms, settings.ledstrip.enableFullBlink ? (leds.size() / 2) : settings.ledstrip.bigOffset - settings.ledstrip.smallOffset, settings.ledstrip.enableFullBlink);
if (settings.ledstrip.enableBeepWhenBlink)
const auto anim_to_fill = time_to_percent(750ms, 500ms, 100ms, configs.ledstrip.enableFullBlink.value ? (leds.size() / 2) : configs.ledstrip.bigOffset.value - configs.ledstrip.smallOffset.value, configs.ledstrip.enableFullBlink.value);
if (configs.ledstrip.enableBeepWhenBlink.value)
{
if (espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms)
for (Controller &controller : controllers)
@ -51,9 +51,9 @@ void updateLedStrip()
controller.command.buzzer.freq = 0;
}
auto color = CRGB{255, 200, 0};
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value);
if (settings.ledstrip.enableFullBlink)
if (configs.ledstrip.enableFullBlink.value)
{
// Full
if (BLINK_LEFT_EXPR)
@ -89,11 +89,11 @@ void updateLedStrip()
// Blink left
if (!enAnim)
{
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
std::fill(center - configs.ledstrip.bigOffset.value, center - configs.ledstrip.smallOffset.value, color);
}
else
{
std::fill(center - settings.ledstrip.smallOffset - anim_to_fill, center - settings.ledstrip.smallOffset, color);
std::fill(center - configs.ledstrip.smallOffset.value - anim_to_fill, center - configs.ledstrip.smallOffset.value, color);
}
}
if (BLINK_RIGHT_EXPR)
@ -101,35 +101,16 @@ void updateLedStrip()
// Blink right
if (!enAnim)
{
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
std::fill(center + configs.ledstrip.smallOffset.value, center + configs.ledstrip.bigOffset.value, color);
}
else
{
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.smallOffset + anim_to_fill, color);
std::fill(center + configs.ledstrip.smallOffset.value, center + configs.ledstrip.smallOffset.value + anim_to_fill, color);
}
}
}
// Old way to blink
// if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT && !settings.ledstrip.enableFullBlink)
// {
// std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
// }
// else if(blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT && settings.ledstrip.enableFullBlink)
// {
// std::fill(std::begin(leds), center, color);
// }
// if (blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT && !settings.ledstrip.enableFullBlink)
// {
// std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
// }
// else if(blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT && settings.ledstrip.enableFullBlink)
// {
// std::fill(center, std::end(leds), color);
// }
} else {
if (settings.ledstrip.enableBeepWhenBlink)
if (configs.ledstrip.enableBeepWhenBlink.value)
{
for (Controller &controller : controllers)
controller.command.buzzer.freq = 0;
@ -138,7 +119,7 @@ void updateLedStrip()
}
else
{
if (settings.ledstrip.enableBrakeLights)
if (configs.ledstrip.enableBrakeLights.value)
{
float avgPwm{};
for (const Controller &controller : controllers)
@ -153,17 +134,17 @@ void updateLedStrip()
{
auto color = avgSpeedKmh < -0.1f ? CRGB{255, 255, 255} : CRGB{255, 0, 0};
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value);
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
if (settings.ledstrip.enableFullBlink)
if (configs.ledstrip.enableFullBlink.value)
{
std::fill(std::begin(leds), std::end(leds), color);
}
else if(!settings.ledstrip.enableAnimBlink)
else if(!configs.ledstrip.enableAnimBlink.value)
{
std::fill(center - settings.ledstrip.bigOffset - 2, center - settings.ledstrip.smallOffset + 2, color);
std::fill(center + settings.ledstrip.smallOffset - 2, center + settings.ledstrip.bigOffset + 2, color);
std::fill(center - configs.ledstrip.bigOffset.value - 2, center - configs.ledstrip.smallOffset.value + 2, color);
std::fill(center + configs.ledstrip.smallOffset.value - 2, center + configs.ledstrip.bigOffset.value + 2, color);
}
}
else
@ -177,47 +158,47 @@ void updateLedStrip()
}
}
if (have_disabled_beeper == false && (!(cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) || !settings.ledstrip.enableBeepWhenBlink))
if (have_disabled_beeper == false && (!(cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) || !configs.ledstrip.enableBeepWhenBlink.value))
{
for (Controller &controller : controllers)
controller.command.buzzer.freq = 0;
have_disabled_beeper = true;
}
else if ((cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) && settings.ledstrip.enableBeepWhenBlink) have_disabled_beeper = false;
else if ((cpputils::is_in(blinkAnimation, LEDSTRIP_OVERWRITE_BLINKLEFT, LEDSTRIP_OVERWRITE_BLINKRIGHT, LEDSTRIP_OVERWRITE_BLINKBOTH)) && configs.ledstrip.enableBeepWhenBlink.value) have_disabled_beeper = false;
if (simplified || settings.ledstrip.enableStVO)
if (simplified || configs.ledstrip.enableStVO.value)
{
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value);
if (!(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT || blinkAnimation == LEDSTRIP_OVERWRITE_BLINKBOTH) || !(espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) || settings.ledstrip.enableFullBlink) // Condition for right
if (!(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKLEFT || blinkAnimation == LEDSTRIP_OVERWRITE_BLINKBOTH) || !(espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) || configs.ledstrip.enableFullBlink.value) // Condition for right
{
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, CRGB{0, 0, 0});
std::fill(center - settings.ledstrip.bigOffset - 1U, center - settings.ledstrip.smallOffset - 1U, CRGB{255, 0, 0}); // Right
std::fill(center - configs.ledstrip.bigOffset.value, center - configs.ledstrip.smallOffset.value, CRGB{0, 0, 0});
std::fill(center - configs.ledstrip.bigOffset.value - 1U, center - configs.ledstrip.smallOffset.value - 1U, CRGB{255, 0, 0}); // Right
}
if (!(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT || blinkAnimation == LEDSTRIP_OVERWRITE_BLINKBOTH) || !(espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) || settings.ledstrip.enableFullBlink) // Condition for left
if (!(blinkAnimation == LEDSTRIP_OVERWRITE_BLINKRIGHT || blinkAnimation == LEDSTRIP_OVERWRITE_BLINKBOTH) || !(espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) || configs.ledstrip.enableFullBlink.value) // Condition for left
{
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, CRGB{0, 0, 0});
std::fill(center + settings.ledstrip.smallOffset + 1U, center + settings.ledstrip.bigOffset + 1U, CRGB{255, 0, 0}); // Left
std::fill(center + configs.ledstrip.smallOffset.value, center + configs.ledstrip.bigOffset.value, CRGB{0, 0, 0});
std::fill(center + configs.ledstrip.smallOffset.value + 1U, center + configs.ledstrip.bigOffset.value + 1U, CRGB{255, 0, 0}); // Left
}
if (settings.ledstrip.stvoFrontEnable)
if (configs.ledstrip.stvoFrontEnable.value)
{
std::fill(std::begin(leds) + settings.ledstrip.stvoFrontOffset, std::begin(leds) + settings.ledstrip.stvoFrontOffset + settings.ledstrip.stvoFrontLength, CRGB{255, 255, 255});
std::fill(std::end(leds) - settings.ledstrip.stvoFrontOffset - settings.ledstrip.stvoFrontLength, std::end(leds) - settings.ledstrip.stvoFrontOffset, CRGB{255, 255, 255});
std::fill(std::begin(leds) + configs.ledstrip.stvoFrontOffset.value, std::begin(leds) + configs.ledstrip.stvoFrontOffset.value + configs.ledstrip.stvoFrontLength.value, CRGB{255, 255, 255});
std::fill(std::end(leds) - configs.ledstrip.stvoFrontOffset.value - configs.ledstrip.stvoFrontLength.value, std::end(leds) - configs.ledstrip.stvoFrontOffset.value, CRGB{255, 255, 255});
}
}
FastLED.setMaxPowerInVoltsAndMilliamps(5, configs.ledStripMaxMilliamps.value);
FastLED.setBrightness(settings.ledstrip.brightness);
FastLED.setMaxPowerInVoltsAndMilliamps(5, configs.ledstrip.maxMilliamps.value);
FastLED.setBrightness(configs.ledstrip.brightness.value);
FastLED.show();
}
void showAnimation()
{
if (settings.ledstrip.enableLedAnimation
if (configs.ledstrip.enableLedAnimation.value
&& !simplified
#ifdef FEATURE_OTA
&& !(asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None)
&& !(asyncOtaTaskStarted && configs.ledstrip.otaMode.value != OtaAnimationModes::None)
#endif
)
{
@ -228,7 +209,7 @@ void showAnimation()
else showDefaultLedstrip();
}
#ifdef FEATURE_OTA
else if (asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None)
else if (asyncOtaTaskStarted && configs.ledstrip.otaMode.value != OtaAnimationModes::None)
{
// show ota animation
showOtaAnimation();
@ -251,7 +232,7 @@ void showOtaAnimation()
if (const auto totalSize = asyncOta->totalSize(); totalSize && *totalSize > 0)
{
percentage = (float(progress) / *totalSize * 100);
if (settings.ledstrip.otaMode == OtaAnimationModes::GreenProgressBar)
if (configs.ledstrip.otaMode.value == OtaAnimationModes::GreenProgressBar)
{
int numLeds = (leds_count * percentage) / 100;
if (numLeds >= leds_count)
@ -260,7 +241,7 @@ void showOtaAnimation()
}
std::fill(std::begin(leds), std::begin(leds) + numLeds, CRGB{0,255,0});
}
else if (settings.ledstrip.otaMode == OtaAnimationModes::ColorChangeAll)
else if (configs.ledstrip.otaMode.value == OtaAnimationModes::ColorChangeAll)
{
const uint8_t redChannel = 255 - (2.55 * percentage);
const uint8_t greenChannel = 2.55 * percentage;
@ -309,7 +290,7 @@ void showSpeedSyncAnimation()
static float hue_result = 0;
const float hue_per_led = 1. / std::max(uint8_t(1), uint8_t(settings.ledstrip.animationMultiplier));
const float hue_per_led = 1. / std::max(uint8_t(1), uint8_t(configs.ledstrip.animationMultiplier.value));
const float meter_per_second = avgSpeedKmh / 3.6;
const float leds_per_second = meter_per_second * leds_per_meter;
const float hue_per_second = leds_per_second * hue_per_led;
@ -336,7 +317,7 @@ void showDefaultLedstrip()
void showCustomColor()
{
const auto eighth_length = leds.size() / 8;
const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value);
std::fill(std::begin(leds), std::end(leds), ledstrip_custom_colors[int(Bobbycar_Side::FRONT)]); // Front
std::fill(center - (eighth_length / 2), center + (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK)]); // Back

View File

@ -21,9 +21,15 @@
#include <makearray.h>
// local includes
#include "bluetoothmode.h"
#include "ledstrip.h"
#define REMOVE_TRAILING_COMMA_N(_1,_2,_3,_4,_5,_6,_7,_8,_9,N,...) \
REMOVE_TRAILING_COMMA_##N
#define REMOVE_TRAILING_COMMA(...) \
REMOVE_TRAILING_COMMA_N(__VA_ARGS__,9,8,7,6,5,4,3,2,1)(__VA_ARGS__)
using namespace espconfig;
#define __CONFIG__START nullptr
std::string defaultHostname();
@ -179,11 +185,6 @@ public:
ConfigWrapper<std::string> dns_announce_key {std::string{}, DoReset, {}, "dnsAnnounceKey" };
ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" };
// old settings
struct {
ConfigWrapper<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
} bleSettings;
struct {
ConfigWrapper<int16_t> wheelDiameter {DEFAULT_WHEELDIAMETER, DoReset, {}, "wheelDiameter" };
ConfigWrapper<int16_t> numMagnetPoles {15, DoReset, {}, "numMagnetPoles" };
@ -220,9 +221,32 @@ public:
ConfigWrapper<bool> enableCloudDebug {false, DoReset, {}, "debugCloud" };
ConfigWrapper<bool> udpUseStdString {false, DoReset, {}, "udpusestdstr" };
} udpCloudSettings;
struct {
ConfigWrapper<bool> enableLedAnimation {true, DoReset, {}, "enableLedAnimat" };
ConfigWrapper<bool> enableBrakeLights {true, DoReset, {}, "enableBrakeLigh" };
ConfigWrapper<int16_t> ledsCount {LEDSTRIP_LENGTH, DoReset, {}, "ledsCount" };
ConfigWrapper<int16_t> centerOffset {1, DoReset, {}, "centerOffset" };
ConfigWrapper<int16_t> smallOffset {4, DoReset, {}, "smallOffset" };
ConfigWrapper<int16_t> bigOffset {10, DoReset, {}, "bigOffset" };
ConfigWrapper<bool> enableBeepWhenBlink {true, DoReset, {}, "beepwhenblink" };
ConfigWrapper<int16_t> animationType {1, DoReset, {}, "animationType" };
ConfigWrapper<bool> enableFullBlink {true, DoReset, {}, "fullblink" };
ConfigWrapper<bool> enableStVO {true, DoReset, {}, "ledstvo" };
ConfigWrapper<int16_t> stvoFrontOffset {0, DoReset, {}, "ledstvofoff" };
ConfigWrapper<int16_t> stvoFrontLength {10, DoReset, {}, "ledstvoflen" };
ConfigWrapper<bool> stvoFrontEnable {false, DoReset, {}, "ledstvoen" };
ConfigWrapper<int16_t> animationMultiplier{10, DoReset, {}, "ledAnimMul" };
ConfigWrapper<uint8_t> brightness {255, DoReset, {}, "ledbrightness" };
ConfigWrapper<bool> enableAnimBlink {false, DoReset, {}, "enAnimBlink" };
ConfigWrapper<OtaAnimationModes> otaMode {OtaAnimationModes::GreenProgressBar, DoReset, {}, "ledOtaAnim" };
ConfigWrapper<uint32_t> maxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" };
} ledstrip;
// end old settings
ConfigWrapper<uint32_t> ledStripMaxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" };
struct {
ConfigWrapper<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
} bleSettings;
#define NEW_SETTINGS(x) \
x(baseMacAddressOverride) \
@ -411,8 +435,6 @@ public:
x(dns_announce_key) \
x(webserverPassword) \
\
x(bleSettings.bleEnabled) \
\
x(controllerHardware.wheelDiameter) \
x(controllerHardware.numMagnetPoles) \
x(controllerHardware.swapFrontBack) \
@ -441,7 +463,25 @@ public:
x(udpCloudSettings.enableCloudDebug) \
x(udpCloudSettings.udpUseStdString) \
\
//x(ledStripMaxMilliamps)
x(ledstrip.enableLedAnimation) \
x(ledstrip.enableBrakeLights) \
x(ledstrip.ledsCount) \
x(ledstrip.centerOffset) \
x(ledstrip.smallOffset) \
x(ledstrip.bigOffset) \
x(ledstrip.enableBeepWhenBlink) \
x(ledstrip.animationType) \
x(ledstrip.enableFullBlink) \
x(ledstrip.enableStVO) \
x(ledstrip.stvoFrontOffset) \
x(ledstrip.stvoFrontLength) \
x(ledstrip.stvoFrontEnable) \
x(ledstrip.animationMultiplier) \
x(ledstrip.brightness) \
x(ledstrip.enableAnimBlink) \
x(ledstrip.otaMode) \
x(ledstrip.maxMilliamps)
//x(bleSettings.bleEnabled)
template<typename T>
void callForEveryConfig(T &&callback)
@ -449,7 +489,6 @@ public:
#define HELPER(x) callback(x);
NEW_SETTINGS(HELPER)
#undef HELPER
callback(ledStripMaxMilliamps);
}
auto getAllConfigParams()
@ -458,7 +497,7 @@ public:
#define HELPER(x) std::ref<ConfigWrapperInterface>(x),
NEW_SETTINGS(HELPER)
#undef HELPER
std::ref<ConfigWrapperInterface>(ledStripMaxMilliamps)
std::ref<ConfigWrapperInterface>(bleSettings.bleEnabled)
);
}
};

View File

@ -130,34 +130,6 @@ constexpr Settings::Handbremse defaultHandbremse {
.visualize = true,
};
#ifdef FEATURE_LEDSTRIP
constexpr Settings::Ledstrip defaultLedstrip {
.enableLedAnimation = true,
.enableBrakeLights = true,
.ledsCount = LEDSTRIP_LENGTH,
.centerOffset = 1,
.smallOffset = 4,
.bigOffset = 10,
.enableBeepWhenBlink = false,
#ifdef LEDSTRIP_ANIMATION_DEFAULT
.animationType = LEDSTRIP_ANIMATION_DEFAULT,
#else
.animationType = LedstripAnimation::DefaultRainbow,
#endif
.enableFullBlink = false,
.enableStVO = false,
.stvoFrontOffset = 0,
.stvoFrontLength = 10,
.stvoFrontEnable = false,
.animationMultiplier = 10,
.brightness = 255,
.enableAnimBlink = false,
#ifdef FEATURE_OTA
.otaMode = OtaAnimationModes::GreenProgressBar
#endif
};
#endif
constexpr Settings::LockscreenSettings defaultLockscreen {
.allowPresetSwitch = true,
.keepLockedAfterReboot = false,
@ -208,9 +180,6 @@ constexpr Settings defaultSettings {
.tempomatMode = defaultTempomatMode,
.larsmMode = defaultLarsmMode,
.motortestMode = defaultMotortestMode,
#ifdef FEATURE_LEDSTRIP
.ledstrip = defaultLedstrip,
#endif
.battery = defaultBattery,
.hybrid = defaultHybrid,
.lockscreen = defaultLockscreen,

View File

@ -39,8 +39,8 @@ struct Settings
struct DefaultMode {
UnifiedModelMode modelMode; // profileSetting
bool squareGas;
bool squareBrems;
bool squareGas; // profileSetting
bool squareBrems; // profileSetting
bool enableSmoothingUp; // profileSetting
bool enableSmoothingDown; // profileSetting
bool enableFieldWeakSmoothingUp; // profileSetting
@ -67,34 +67,10 @@ struct Settings
} larsmMode;
struct MotortestMode {
uint8_t multiplikator;
uint16_t maxPwm;
uint8_t multiplikator; // profileSetting
uint16_t maxPwm; // profileSetting
} motortestMode;
#ifdef FEATURE_LEDSTRIP
struct Ledstrip {
bool enableLedAnimation;
bool enableBrakeLights;
int16_t ledsCount;
int16_t centerOffset;
int16_t smallOffset;
int16_t bigOffset;
bool enableBeepWhenBlink;
int16_t animationType;
bool enableFullBlink;
bool enableStVO;
int16_t stvoFrontOffset;
int16_t stvoFrontLength;
bool stvoFrontEnable;
int16_t animationMultiplier;
uint8_t brightness;
bool enableAnimBlink;
#ifdef FEATURE_OTA
OtaAnimationModes otaMode;
#endif
} ledstrip;
#endif
struct Battery {
uint8_t cellsSeries;
uint8_t cellsParallel;
@ -150,28 +126,6 @@ struct Settings
template<typename T>
void Settings::executeForEveryCommonSetting(T &&callable)
{
#ifdef FEATURE_LEDSTRIP
callable("enableLedAnimat", ledstrip.enableLedAnimation);
callable("enableBrakeLigh", ledstrip.enableBrakeLights);
callable("ledsCount", ledstrip.ledsCount);
callable("centerOffset", ledstrip.centerOffset);
callable("smallOffset", ledstrip.smallOffset);
callable("bigOffset", ledstrip.bigOffset);
callable("beeppwhenblink", ledstrip.enableBeepWhenBlink);
// callable("animationType", ledstrip.animationType);
callable("fullblink", ledstrip.enableFullBlink);
callable("ledstvo", ledstrip.enableStVO);
callable("ledstvofoff", ledstrip.stvoFrontOffset);
callable("ledstvoflen", ledstrip.stvoFrontLength);
callable("ledstvoen", ledstrip.stvoFrontEnable);
callable("ledAnimMul", ledstrip.animationMultiplier);
callable("ledbrightness", ledstrip.brightness);
callable("enAnimBlink", ledstrip.enableAnimBlink);
#ifdef FEATURE_OTA
callable("ledOtaAnim", ledstrip.otaMode);
#endif
#endif
callable("batteryCS", battery.cellsSeries);
callable("batteryCP", battery.cellsParallel);
callable("batteryType", battery.cellType);
@ -242,6 +196,8 @@ void Settings::executeForEveryProfileSetting(T &&callable)
callable("default.gas2_we", defaultMode.gas2_wert);
callable("default.brems1_", defaultMode.brems1_wert);
callable("default.brems2_", defaultMode.brems2_wert);
callable("default.squareG", defaultMode.squareGas);
callable("default.squareB", defaultMode.squareBrems);
callable("tempoma.modelMo", tempomatMode.modelMode);