Fixed probleb with copy assignment of settings in LEDRunner and DisplayHelper classes. Cleaned code up a bit.

This commit is contained in:
Author glitchrain
2024-12-15 03:30:30 -08:00
committed by s.aydarov
parent 031a19b107
commit 11b4909f39
8 changed files with 246 additions and 294 deletions

View File

@@ -12,10 +12,24 @@ public:
int SwitchTime = 3000; //In milliseconds
float Brightness = MAX_BRIGHTNESS / 2;
Settings()
//=======================================
//Singleton. AVOID COPY ASSIGNMENTS
//=======================================
static Settings& getInstance()
{
static Settings instance; // Guaranteed to be destroyed. Instantiated on first use.
return instance;
}
Settings() {}
Settings(Settings const&) = delete;
void operator = (Settings const&) = delete;
//=======================================
//Singleton. AVOID COPY ASSIGNMENTS
//=======================================
void setSwitchTime(int _SwitchTime)
{
if(_SwitchTime > 15000)
@@ -67,6 +81,11 @@ public:
TimeModeState = static_cast<TimeMode>(wrapInt(static_cast<int>(TimeModeState) + _ModeIncrement, 3));
}
int getDisplaySwitchTime()
{
return SwitchTime / 10;
}
private:
int wrapInt(int _Num, int _Max)
{