Refactored Ledstrip (Fixed types and removed Macros)

This commit is contained in:
CommanderRedYT
2021-12-07 02:53:43 +01:00
parent c291752b46
commit ddf0d27137
5 changed files with 17 additions and 15 deletions

View File

@@ -10,7 +10,7 @@ using namespace espgui;
namespace { namespace {
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
template<int16_t type> template<uint16_t type>
class LedStripSetAnimationAction : public virtual ActionInterface class LedStripSetAnimationAction : public virtual ActionInterface
{ {
public: public:

View File

@@ -16,8 +16,8 @@ using namespace std::chrono_literals;
std::vector<CRGB> leds; std::vector<CRGB> leds;
uint8_t gHue = 0; uint8_t gHue = 0;
int16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE; uint16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE;
int16_t animation_type = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW; uint16_t animation_type = LedstripAnimation::DefaultRainbow;
void initLedStrip() void initLedStrip()
@@ -215,10 +215,10 @@ void showAnimation()
{ {
if (settings.ledstrip.enableLedAnimation && !simplified && !(asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None)) if (settings.ledstrip.enableLedAnimation && !simplified && !(asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None))
{ {
if (animation_type == LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW) showDefaultLedstrip(); if (animation_type == LedstripAnimation::DefaultRainbow) showDefaultLedstrip();
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW) showBetterRainbow(); else if (animation_type == LedstripAnimation::BetterRainbow) showBetterRainbow();
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION) showSpeedSyncAnimation(); else if (animation_type == LedstripAnimation::SpeedSync) showSpeedSyncAnimation();
else if (animation_type == LEDSTRIP_ANIMATION_TYPE_CUSTOMCOLOR) showCustomColor(); else if (animation_type == LedstripAnimation::CustomColor) showCustomColor();
else showDefaultLedstrip(); else showDefaultLedstrip();
} }
else if (asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None) else if (asyncOtaTaskStarted && settings.ledstrip.otaMode != OtaAnimationModes::None)

View File

@@ -29,8 +29,8 @@ enum OtaAnimationModes
extern std::vector<CRGB> leds; extern std::vector<CRGB> leds;
extern uint8_t gHue; extern uint8_t gHue;
extern int16_t blinkAnimation; extern uint16_t blinkAnimation;
extern int16_t animation_type; extern uint16_t animation_type;
void showDefaultLedstrip(); void showDefaultLedstrip();
void showAnimation(); void showAnimation();

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
#include <cstdint>
/* /*
* This file contains a few defines, so you don't have to remember which ledstrip animation is which number * This file contains a few defines, so you don't have to remember which ledstrip animation is which number
*/ */
@@ -13,11 +14,12 @@
#endif #endif
#define LEDSTRIP_OVERWRITE_BLINKBOTH 3 #define LEDSTRIP_OVERWRITE_BLINKBOTH 3
enum LedstripAnimation : uint16_t {
#define LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW 0 DefaultRainbow,
#define LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW 1 BetterRainbow,
#define LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION 2 SpeedSync,
#define LEDSTRIP_ANIMATION_TYPE_CUSTOMCOLOR 3 CustomColor
};
#define BLINK_LEFT_EXPR blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT #define BLINK_LEFT_EXPR blinkAnimation != LEDSTRIP_OVERWRITE_BLINKRIGHT
#define BLINK_RIGHT_EXPR blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT #define BLINK_RIGHT_EXPR blinkAnimation != LEDSTRIP_OVERWRITE_BLINKLEFT

View File

@@ -256,7 +256,7 @@ constexpr Settings::Ledstrip defaultLedstrip {
#ifdef LEDSTRIP_ANIMATION_DEFAULT #ifdef LEDSTRIP_ANIMATION_DEFAULT
.animationType = LEDSTRIP_ANIMATION_DEFAULT, .animationType = LEDSTRIP_ANIMATION_DEFAULT,
#else #else
.animationType = LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW, .animationType = LedstripAnimation::DefaultRainbow,
#endif #endif
.enableFullBlink = false, .enableFullBlink = false,
.enableStVO = false, .enableStVO = false,