Skip to content

Commit 8dea122

Browse files
authored
Merge pull request #126 from PlummersSoftwareLLC/v2
V2 - Increase frametime accuracy
2 parents 77b2bf7 + 617d886 commit 8dea122

21 files changed

Lines changed: 1070 additions & 55 deletions

apihelpers.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "effects/paletteeffect.h"
77
#include "effects/colorwaveeffect.h"
88
#include "effects/starfield.h"
9+
#include "effects/stockbannereffect.h"
910
#include "effects/bouncingballeffect.h"
1011
#include "effects/fireworkseffect.h"
1112
#include "effects/videoeffect.h"
@@ -85,6 +86,25 @@ nlohmann::json CreateEffectCatalogJson()
8586
{{"path", "starCount"}, {"label", "Star Count"}, {"input", "number"}, {"step", 1}, {"min", 1}}
8687
})}
8788
},
89+
{
90+
{"type", typeid(StockBanner).name()},
91+
{"label", "Stock Banner"},
92+
{"defaults", json{
93+
{"stockServerHost", "localhost"},
94+
{"stockServerPort", 8888},
95+
{"minQuoteWidth", 64},
96+
{"compactQuoteWidth", 96},
97+
{"refreshSeconds", 60}
98+
}},
99+
{"fields", json::array({
100+
{{"path", "symbols"}, {"label", "Symbols"}, {"input", "json"}},
101+
{{"path", "stockServerHost"}, {"label", "Stock Server Host"}, {"input", "text"}},
102+
{{"path", "stockServerPort"}, {"label", "Stock Server Port"}, {"input", "number"}, {"step", 1}, {"min", 1}},
103+
{{"path", "minQuoteWidth"}, {"label", "Min Quote Width"}, {"input", "number"}, {"step", 1}, {"min", 32}},
104+
{{"path", "compactQuoteWidth"}, {"label", "Compact Width"}, {"input", "number"}, {"step", 1}, {"min", 64}},
105+
{{"path", "refreshSeconds"}, {"label", "Refresh Seconds"}, {"input", "number"}, {"step", 1}, {"min", 15}}
106+
})}
107+
},
88108
{
89109
{"type", typeid(BouncingBallEffect).name()},
90110
{"label", "Bouncing Balls"},

apihelpers.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ inline void StartCanvas(ApiRequestContext &context)
140140
{
141141
ApplyCanvasesRequest(context, [](shared_ptr<ICanvas> canvas)
142142
{
143+
for (auto &feature : canvas->Features())
144+
{
145+
feature->Socket()->Stop();
146+
feature->Socket()->Start();
147+
}
148+
143149
canvas->Effects().Start(*canvas);
144150
});
145151
}
@@ -149,6 +155,8 @@ inline void StopCanvas(ApiRequestContext &context)
149155
ApplyCanvasesRequest(context, [](shared_ptr<ICanvas> canvas)
150156
{
151157
canvas->Effects().Stop();
158+
for (auto &feature : canvas->Features())
159+
feature->Socket()->Stop();
152160
});
153161
}
154162

config.led.example

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{
99
"filePath": "./media/mp4/goldendollars.mp4",
1010
"name": "Money Video",
11-
"type": "17MP4PlaybackEffect"
11+
"type": "MP4PlaybackEffect"
1212
}
1313
],
1414
"fps": 24
@@ -42,7 +42,7 @@
4242
{
4343
"name": "Starfield",
4444
"starCount": 100,
45-
"type": "15StarfieldEffect"
45+
"type": "StarfieldEffect"
4646
}
4747
],
4848
"fps": 24
@@ -80,7 +80,7 @@
8080
"r": 255
8181
},
8282
"name": "Yellow Window",
83-
"type": "14SolidColorFill"
83+
"type": "SolidColorFill"
8484
}
8585
],
8686
"fps": 3
@@ -118,7 +118,7 @@
118118
"r": 0
119119
},
120120
"name": "Blue Window",
121-
"type": "14SolidColorFill"
121+
"type": "SolidColorFill"
122122
}
123123
],
124124
"fps": 3
@@ -156,7 +156,7 @@
156156
"r": 0
157157
},
158158
"name": "Green Window",
159-
"type": "14SolidColorFill"
159+
"type": "SolidColorFill"
160160
}
161161
],
162162
"fps": 3
@@ -242,7 +242,7 @@
242242
]
243243
},
244244
"rampedColor": false,
245-
"type": "13PaletteEffect"
245+
"type": "PaletteEffect"
246246
}
247247
],
248248
"fps": 20
@@ -350,7 +350,7 @@
350350
]
351351
},
352352
"rampedColor": false,
353-
"type": "13PaletteEffect"
353+
"type": "PaletteEffect"
354354
}
355355
],
356356
"fps": 24
@@ -429,7 +429,7 @@
429429
"erase": true,
430430
"mirrored": true,
431431
"name": "Bouncing Balls",
432-
"type": "18BouncingBallEffect"
432+
"type": "BouncingBallEffect"
433433
}
434434
],
435435
"fps": 30
@@ -515,7 +515,7 @@
515515
]
516516
},
517517
"rampedColor": false,
518-
"type": "13PaletteEffect"
518+
"type": "PaletteEffect"
519519
}
520520
],
521521
"fps": 30

effects/auroraeffect.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ using namespace std;
88

99
class AuroraEffect : public LEDEffectBase
1010
{
11+
public:
12+
static constexpr const char* TypeName = "AuroraEffect";
13+
1114
private:
1215
double _time;
1316
double _speed;
1417
double _brightness;
15-
18+
1619
public:
1720
AuroraEffect(const string& name, double speed = 0.2, double brightness = 1.0)
18-
: LEDEffectBase(name, "AuroraEffect"), _time(0.0), _speed(speed), _brightness(brightness)
21+
: LEDEffectBase(name, TypeName), _time(0.0), _speed(speed), _brightness(brightness)
1922
{
2023
}
2124

effects/bouncingballeffect.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ using namespace std::chrono;
1212

1313
class BouncingBallEffect : public LEDEffectBase
1414
{
15+
public:
16+
static constexpr const char* TypeName = "BouncingBallEffect";
17+
1518
private:
1619
size_t _ballCount;
1720
size_t _ballSize;
@@ -35,7 +38,7 @@ class BouncingBallEffect : public LEDEffectBase
3538

3639
public:
3740
BouncingBallEffect(const string& name, size_t ballCount = 5, size_t ballSize = 1, bool mirrored = true, bool erase = true)
38-
: LEDEffectBase(name), _ballCount(ballCount), _ballSize(ballSize), _mirrored(mirrored), _erase(erase)
41+
: LEDEffectBase(name, TypeName), _ballCount(ballCount), _ballSize(ballSize), _mirrored(mirrored), _erase(erase)
3942
{
4043
}
4144

effects/colorwaveeffect.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ using namespace std;
77

88
class ColorWaveEffect : public LEDEffectBase
99
{
10+
public:
11+
static constexpr const char* TypeName = "ColorWaveEffect";
12+
1013
private:
1114
double _hue; // Current hue for the wave
1215
double _speed; // Speed of hue change
1316
double _waveFrequency; // Frequency of the wave pattern
1417

1518
public:
1619
ColorWaveEffect(const string& name, double speed = 0.5, double waveFrequency = 10.0)
17-
: LEDEffectBase(name), _hue(0.0), _speed(speed), _waveFrequency(waveFrequency)
20+
: LEDEffectBase(name, TypeName), _hue(0.0), _speed(speed), _waveFrequency(waveFrequency)
1821
{
1922
}
2023

effects/fireworkseffect.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ using namespace std::chrono;
1414

1515
class FireworksEffect : public LEDEffectBase
1616
{
17+
public:
18+
static constexpr const char* TypeName = "FireworksEffect";
19+
1720
private:
1821
struct Particle
1922
{
@@ -68,7 +71,7 @@ class FireworksEffect : public LEDEffectBase
6871
double _particleSize = 1.0;
6972

7073
public:
71-
FireworksEffect(const string &name) : LEDEffectBase(name), _rng(random_device{}())
74+
FireworksEffect(const string &name) : LEDEffectBase(name, TypeName), _rng(random_device{}())
7275
{
7376
}
7477

@@ -80,8 +83,8 @@ class FireworksEffect : public LEDEffectBase
8083
double particleHoldTime,
8184
double particleFadeTime,
8285
double particleSize)
83-
: LEDEffectBase(name),
84-
_maxSpeed(maxSpeed),
86+
: LEDEffectBase(name, TypeName),
87+
_maxSpeed(maxSpeed),
8588
_newParticleProbability(newParticleProbability),
8689
_particlePreignitionTime(particlePreignitionTime),
8790
_particleIgnition(particleIgnition),

effects/misceffects.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ using namespace std::chrono;
1212

1313
class SolidColorFill : public LEDEffectBase
1414
{
15+
public:
16+
static constexpr const char* TypeName = "SolidColorFill";
17+
1518
private:
1619
CRGB _color;
1720

1821
public:
1922
SolidColorFill(const string& name, const CRGB& color)
20-
: LEDEffectBase(name), _color(color)
23+
: LEDEffectBase(name, TypeName), _color(color)
2124
{
2225
}
2326

@@ -53,8 +56,10 @@ inline void from_json(const nlohmann::json& j, shared_ptr<SolidColorFill>& effec
5356
class DaveDebugEffect : public LEDEffectBase
5457
{
5558
public:
59+
static constexpr const char* TypeName = "DaveDebugEffect";
60+
5661
DaveDebugEffect(const string& name)
57-
: LEDEffectBase(name)
62+
: LEDEffectBase(name, TypeName)
5863
{
5964
}
6065

effects/paletteeffect.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ using namespace std::chrono;
1616
#include "../pixeltypes.h"
1717
#include "../palette.h"
1818

19-
class PaletteEffect : public LEDEffectBase
19+
class PaletteEffect : public LEDEffectBase
2020
{
21+
public:
22+
static constexpr const char* TypeName = "PaletteEffect";
23+
2124
private:
2225
double _iPixel = 0;
2326
double _iColor;
@@ -45,8 +48,8 @@ class PaletteEffect : public LEDEffectBase
4548
double brightness = 1.0,
4649
bool mirrored = false,
4750
bool bBlend = true)
48-
: LEDEffectBase(name),
49-
_Palette(colors, bBlend),
51+
: LEDEffectBase(name, TypeName),
52+
_Palette(colors, bBlend),
5053
_iColor(0),
5154
_LEDColorPerSecond(ledColorPerSecond),
5255
_LEDScrollSpeed(ledScrollSpeed),

effects/starfield.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ using namespace std::chrono;
1212

1313
class StarfieldEffect : public LEDEffectBase
1414
{
15+
public:
16+
static constexpr const char* TypeName = "StarfieldEffect";
17+
1518
private:
1619
struct Star
1720
{
@@ -34,7 +37,7 @@ class StarfieldEffect : public LEDEffectBase
3437

3538
public:
3639
StarfieldEffect(const string& name, int starCount = 100)
37-
: LEDEffectBase(name), _starCount(starCount), _rng(random_device{}()),
40+
: LEDEffectBase(name, TypeName), _starCount(starCount), _rng(random_device{}()),
3841
_speedDist(5.0, 20.0), // Increased speed for hyperspace effect
3942
_directionDist(0, 2 * M_PI), // Full 360° angular range
4043
_brightnessDist(28, 255), _colorChanceDist(0, 1),

0 commit comments

Comments
 (0)