Skip to content

Commit

Permalink
Merge pull request #648 from rbergen/fixincs
Browse files Browse the repository at this point in the history
Numerous minor changes for correctness.
  • Loading branch information
rbergen authored Nov 9, 2024
2 parents 352ac6b + 98c800b commit 15221f2
Show file tree
Hide file tree
Showing 42 changed files with 267 additions and 378 deletions.
3 changes: 1 addition & 2 deletions include/colordata.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//
// Description:
//
// Palettes and other color table defnitions. CPP daa in colordata.cpp
// Palettes and other color table definitions. CPP daa in colordata.cpp
//
// History: May-11-2021 Davepl Commented
//
Expand All @@ -34,7 +34,6 @@
extern const CRGBPalette16 vuPaletteGreen;
extern const CRGBPalette16 vuPaletteBlue;
extern const CRGBPalette16 spectrumBasicColors;
extern const CRGBPalette16 bluesky_pal;
extern const TProgmemRGBGradientPalette_byte vu_gpGreen[];
extern const TProgmemRGBPalette16 BlueHeatColors_p;
extern const TProgmemRGBPalette16 HeatColors2_p;
Expand Down
14 changes: 6 additions & 8 deletions include/deviceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@

#pragma once

#include <memory>
#include <vector>
#include <tuple>
#include <algorithm>
#include "jsonserializer.h"
#include "types.h"

Expand Down Expand Up @@ -146,7 +144,7 @@ class DeviceConfig : public IJSONSerializable

static constexpr int _jsonSize = 1024;

void SaveToJSON();
void SaveToJSON() const;

template <typename T>
void SetAndSave(T& target, const T& source)
Expand Down Expand Up @@ -274,14 +272,14 @@ class DeviceConfig : public IJSONSerializable
return true;
}

void RemovePersisted()
static void RemovePersisted()
{
RemoveJSONFile(DEVICE_CONFIG_FILE);
}

virtual const std::vector<std::reference_wrapper<SettingSpec>>& GetSettingSpecs()
{
if (settingSpecs.size() == 0)
if (settingSpecs.empty())
{
// Add SettingSpec for additional settings to this list
settingSpecs.emplace_back(
Expand Down Expand Up @@ -476,7 +474,7 @@ class DeviceConfig : public IJSONSerializable
return openWeatherApiKey;
}

ValidateResponse ValidateOpenWeatherAPIKey(const String &newOpenWeatherAPIKey);
static ValidateResponse ValidateOpenWeatherAPIKey(const String &newOpenWeatherAPIKey);

void SetOpenWeatherAPIKey(const String &newOpenWeatherAPIKey)
{
Expand Down Expand Up @@ -518,7 +516,7 @@ class DeviceConfig : public IJSONSerializable
return brightness;
}

ValidateResponse ValidateBrightness(const String& newBrightness)
static ValidateResponse ValidateBrightness(const String& newBrightness)
{
auto newNumericBrightness = newBrightness.toInt();

Expand Down Expand Up @@ -556,7 +554,7 @@ class DeviceConfig : public IJSONSerializable
return powerLimit;
}

ValidateResponse ValidatePowerLimit(const String& newPowerLimit)
static ValidateResponse ValidatePowerLimit(const String& newPowerLimit)
{
if (newPowerLimit.toInt() < POWER_LIMIT_MIN)
return { false, String("powerLimit is below minimum value of ") + POWER_LIMIT_MIN };
Expand Down
2 changes: 1 addition & 1 deletion include/effectfactories.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class EffectFactories

bool IsEmpty()
{
return defaultFactories.size() == 0 && jsonFactories.size() == 0;
return defaultFactories.empty() && jsonFactories.empty();
}

void ClearDefaultFactories()
Expand Down
32 changes: 13 additions & 19 deletions include/effectmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Description:
//
// Based on my original ESP32LEDStick project this is the class that keeps
// track of internal efects, which one is active, rotating among them,
// track of internal effects, which one is active, rotating among them,
// and fading between them.
//
//
Expand All @@ -35,12 +35,7 @@

#pragma once

#include <sys/types.h>
#include <errno.h>
#include <iostream>
#include <set>
#include <algorithm>
#include <math.h>

#include "effectfactories.h"

Expand All @@ -66,7 +61,6 @@ class EffectManager : public IJSONSerializable
uint _effectStartTime;
uint _effectInterval = 0;
bool _bPlayAll;
bool _bShowVU = true;
bool _clearTempEffectWhenExpired = false;
std::atomic_bool _newFrameAvailable = false;
int _effectSetVersion = 1;
Expand Down Expand Up @@ -108,8 +102,8 @@ class EffectManager : public IJSONSerializable
// Implementation is in effects.cpp
void LoadJSONAndMissingEffects(const JsonArrayConst& effectsArray);

void SaveCurrentEffectIndex();
bool ReadCurrentEffectIndex(size_t& index);
static void SaveCurrentEffectIndex();
static bool ReadCurrentEffectIndex(size_t& index);

void ClearEffects()
{
Expand All @@ -120,7 +114,7 @@ class EffectManager : public IJSONSerializable
static const uint csFadeButtonSpeed = 15 * 1000;
static const uint csSmoothButtonSpeed = 60 * 1000;

EffectManager(std::shared_ptr<LEDStripEffect> effect, std::vector<std::shared_ptr<GFXBase>>& gfx)
EffectManager(const std::shared_ptr<LEDStripEffect>& effect, std::vector<std::shared_ptr<GFXBase>>& gfx)
: _gfx(gfx)
{
debugV("EffectManager Splash Effect Constructor");
Expand Down Expand Up @@ -232,7 +226,7 @@ class EffectManager : public IJSONSerializable
{
// Try to load effect enabled state from JSON also, default to "enabled" otherwise
JsonArrayConst enabledArray = jsonObject["eef"].as<JsonArrayConst>();
int enabledSize = enabledArray.isNull() ? 0 : enabledArray.size();
size_t enabledSize = enabledArray.isNull() ? 0 : enabledArray.size();

for (int i = 0; i < _vEffects.size(); i++)
{
Expand Down Expand Up @@ -305,7 +299,7 @@ class EffectManager : public IJSONSerializable
return _gfx[iChannel];
}

// ShowVU - Control whether VU meter should be draw. Returns the previous state when set.
// ShowVU - Control whether VU meter should be drawn. Returns the previous state when set.
virtual bool ShowVU(bool bShow);
virtual bool IsVUVisible() const;

Expand All @@ -314,8 +308,8 @@ class EffectManager : public IJSONSerializable
// When a global color is set via the remote, we create a fill effect and assign it as the "remote effect"
// which takes drawing precedence

void ApplyGlobalColor(CRGB color);
void ApplyGlobalPaletteColors();
void ApplyGlobalColor(CRGB color) const;
void ApplyGlobalPaletteColors() const;

void ClearRemoteColor(bool retainRemoteEffect = false);

Expand Down Expand Up @@ -494,17 +488,17 @@ class EffectManager : public IJSONSerializable
return _vEffects;
}

const size_t EffectCount() const
size_t EffectCount() const
{
return _vEffects.size();
}

const bool AreEffectsEnabled() const
bool AreEffectsEnabled() const
{
return std::any_of(_vEffects.begin(), _vEffects.end(), [](const auto& pEffect){ return pEffect->IsEnabled(); } );
}

const size_t GetCurrentEffectIndex() const
size_t GetCurrentEffectIndex() const
{
return _iCurrentEffect;
}
Expand Down Expand Up @@ -572,7 +566,7 @@ class EffectManager : public IJSONSerializable

void CheckEffectTimerExpired()
{
// If interval is zero, the current effect never expires unless it thas a max effect time set
// If interval is zero, the current effect never expires unless it has a max effect time set

if (IsIntervalEternal() && !GetCurrentEffect().HasMaximumEffectTime())
return;
Expand All @@ -597,7 +591,7 @@ class EffectManager : public IJSONSerializable
g->CyclePalette(1);
}

void PreviousPalette()
void PreviousPalette() const
{
g()->CyclePalette(-1);
}
Expand Down
4 changes: 2 additions & 2 deletions include/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
#define EFFECT_MATRIX_CIRCUIT 103
#define EFFECT_MATRIX_CLOCK 104
#define EFFECT_MATRIX_CUBE 105
#define EFFECT_MATRIX_FLOW_FIELD 106
// Was #define EFFECT_MATRIX_FLOW_FIELD 106
#define EFFECT_MATRIX_LIFE 107
#define EFFECT_MATRIX_MANDALA 108
#define EFFECT_MATRIX_SUNBURST 109
Expand All @@ -109,7 +109,7 @@
#define EFFECT_MATRIX_QR 121
#define EFFECT_MATRIX_RADAR 122
#define EFFECT_MATRIX_SERENDIPITY 123
#define EFFECT_MATRIX_SPARK 124
// Was #define EFFECT_MATRIX_SPARK 124
#define EFFECT_MATRIX_SPIN 125
#define EFFECT_MATRIX_SPIRO 126
#define EFFECT_MATRIX_SUBSCRIBERS 127
Expand Down
2 changes: 2 additions & 0 deletions include/effects/strip/misceffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#pragma once

#include <deque>

#if USE_HUB75
#include "TJpg_Decoder.h"
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/effects/strip/musiceffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#pragma once

#include <deque>

#include "effects.h"
#include "faneffects.h"

Expand Down
2 changes: 2 additions & 0 deletions include/effects/strip/particles.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#pragma once

#include <deque>

#include "effects.h"

// Lifespan
Expand Down
2 changes: 2 additions & 0 deletions include/effects/strip/stareffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#pragma once

#include <deque>

#include "particles.h"

const int cMaxNewStarsPerFrame = 144;
Expand Down
2 changes: 2 additions & 0 deletions include/effects/strip/tempeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#if ENABLE_AUDIO

#include <deque>

class SimpleInsulatorBeatEffect : public LEDStripEffect, public BeatEffectBase
{
protected:
Expand Down
42 changes: 0 additions & 42 deletions include/effectsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,6 @@ const CRGBPalette16 GreenColors_p =
CRGB::LimeGreen
};

const CRGBPalette16 PurpleColors_p =
{
CRGB::Purple,
CRGB::Maroon,
CRGB::Violet,
CRGB::DarkViolet,

CRGB::Purple,
CRGB::Maroon,
CRGB::Violet,
CRGB::DarkViolet,

CRGB::Purple,
CRGB::Maroon,
CRGB::Violet,
CRGB::DarkViolet,

CRGB::Pink,
CRGB::Maroon,
CRGB::Violet,
CRGB::DarkViolet,
};

const CRGBPalette16 RGBColors_p =
{
CRGB::Red,
Expand All @@ -145,25 +122,6 @@ const CRGBPalette16 RGBColors_p =
CRGB::Blue
};

const CRGBPalette16 MagentaColors_p =
{
CRGB::Pink,
CRGB::DeepPink,
CRGB::HotPink,
CRGB::LightPink,
CRGB::LightCoral,
CRGB::Purple,
CRGB::MediumPurple,
CRGB::Magenta,
CRGB::DarkMagenta,
CRGB::DarkSalmon,
CRGB::MediumVioletRed,
CRGB::Pink,
CRGB::DeepPink,
CRGB::HotPink,
CRGB::LightPink,
CRGB::Magenta};

const CRGBPalette16 spectrumBasicColors =
{
CRGB(0xFD0E35), // Red
Expand Down
Loading

0 comments on commit 15221f2

Please sign in to comment.