Skip to content

Commit 299afe7

Browse files
committed
Improve Clear()
1 parent 2936e8c commit 299afe7

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

include/ledmatrixgfx.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,20 @@ class LEDMatrixGFX : public GFXBase
151151
// before them on the next buffer swap. So we clear the backbuffer and then the leds, which point to
152152
// the current front buffer. TLDR: We clear both the front and back buffers to avoid flicker between effects.
153153

154-
memset((void *) backgroundLayer.backBuffer(), 0, sizeof(LEDMatrixGFX::SM_RGB) * _width * _height);
155154
if (color.g == color.r && color.r == color.b)
156-
memset((void *) leds, color.r, sizeof(CRGB) * _width * _height);
157-
else
158-
for (int i = 0; i < NUM_LEDS; ++i)
155+
{
156+
memset((void *) leds, color.r, sizeof(CRGB) * _ledcount);
157+
memset((void *) backgroundLayer.backBuffer(), color.r, sizeof(LEDMatrixGFX::SM_RGB) * _ledcount);
158+
}
159+
else
160+
{
161+
SM_RGB* buf = (SM_RGB*)backgroundLayer.backBuffer();
162+
for (int i = 0; i < _ledcount; ++i)
163+
{
164+
buf[i] = rgb24(color.r, color.g, color.b);
159165
leds[i] = color;
166+
}
167+
}
160168
}
161169

162170
const String & GetCaption()

include/soundanalyzer.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,17 @@ static constexpr AudioInputParams kParamsM5Plus2{
113113
// a consistent interface returning PeakData.
114114

115115
#ifndef MIN_VU
116-
#define MIN_VU 0.05f
116+
#define MIN_VU 0.05f
117117
#endif
118+
118119
#ifndef VUDAMPEN
119-
#define VUDAMPEN 0
120+
#define VUDAMPEN 0
120121
#endif
122+
121123
#define VUDAMPENMIN 1
122124
#define VUDAMPENMAX 1
123125

124-
//
126+
125127

126128
class PeakData
127129
{

0 commit comments

Comments
 (0)