@@ -47,8 +47,10 @@ PixelsHardware::~PixelsHardware() {}
47
47
/* *************************************************************************/
48
48
bool PixelsHardware::AddNeoPixel (uint16_t num_pixels, uint16_t pin_data,
49
49
neoPixelType order, uint8_t brightness) {
50
- if (getStatusNeoPixelPin () == pin_data && WsV2.lockStatusNeoPixelV2 )
50
+ if (getStatusNeoPixelPin () == pin_data && WsV2.lockStatusNeoPixelV2 ) {
51
+ WS_DEBUG_PRINTLN (" [pixels] Releasing status pixel for use" );
51
52
ReleaseStatusPixel (); // Release the status pixel for use
53
+ }
52
54
53
55
_neopixel = new Adafruit_NeoPixel (num_pixels, pin_data, order);
54
56
_neopixel->begin ();
@@ -131,6 +133,8 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
131
133
_type = type;
132
134
// Convert the pin string to an integer
133
135
uint16_t p_data = atoi (pin_data + 1 );
136
+ _pin_data = p_data; // Store the pin data for later reference
137
+
134
138
if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_NEOPIXEL) {
135
139
if (!AddNeoPixel (num_pixels, p_data, GetStrandOrderNeoPixel (order),
136
140
(uint8_t )brightness)) {
@@ -144,6 +148,7 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
144
148
WS_DEBUG_PRINTLN (" [pixels] Failed to create DotStar strand!" );
145
149
return false ;
146
150
}
151
+ return true ;
147
152
} else {
148
153
WS_DEBUG_PRINTLN (" [pixels] Unknown pixel type!" );
149
154
return false ;
@@ -160,9 +165,13 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
160
165
/* *************************************************************************/
161
166
void PixelsHardware::FillStrand (uint32_t color) {
162
167
// Apply gamma correction to match IO Web
163
- uint32_t color_gamma = ApplyGammaCorrection (color);
164
168
WS_DEBUG_PRINT (" [pixels] Filling strand with color: " );
165
- WS_DEBUG_PRINT (color_gamma, HEX);
169
+ WS_DEBUG_PRINTLN (color);
170
+
171
+ WS_DEBUG_PRINTLN (" Applying gamma correction.." );
172
+ uint32_t color_gamma = ApplyGammaCorrection (color);
173
+ WS_DEBUG_PRINT (" [pixels] Filling strand with color_gamma: " );
174
+ WS_DEBUG_PRINT (color_gamma);
166
175
if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_NEOPIXEL) {
167
176
_neopixel->fill (color_gamma);
168
177
_neopixel->show ();
@@ -183,7 +192,14 @@ void PixelsHardware::FillStrand(uint32_t color) {
183
192
*/
184
193
/* *************************************************************************/
185
194
uint32_t PixelsHardware::ApplyGammaCorrection (uint32_t color) {
195
+ WS_DEBUG_PRINT (" Type: " );
196
+ WS_DEBUG_PRINTLN (_type);
186
197
if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_NEOPIXEL) {
198
+ WS_DEBUG_PRINTLN (" Applying gamma to neopixel..." );
199
+ if (_neopixel == nullptr ) {
200
+ WS_DEBUG_PRINTLN (" [pixels] No neopixel object found!" );
201
+ return color;
202
+ }
187
203
return _neopixel->gamma32 (color);
188
204
} else if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_DOTSTAR) {
189
205
return _dotstar->gamma32 (color);
@@ -235,7 +251,8 @@ uint16_t PixelsHardware::GetPinData() { return _pin_data; }
235
251
@returns The color ordering for NeoPixel strands
236
252
*/
237
253
/* *************************************************************************/
238
- neoPixelType PixelsHardware::GetStrandOrderNeoPixel (wippersnapper_pixels_PixelsOrder order) {
254
+ neoPixelType
255
+ PixelsHardware::GetStrandOrderNeoPixel (wippersnapper_pixels_PixelsOrder order) {
239
256
switch (order) {
240
257
case wippersnapper_pixels_PixelsOrder_PIXELS_ORDER_GRB:
241
258
return NEO_GRB + NEO_KHZ800;
@@ -260,7 +277,8 @@ neoPixelType PixelsHardware::GetStrandOrderNeoPixel(wippersnapper_pixels_PixelsO
260
277
@returns The color ordering for DotStar strands
261
278
*/
262
279
/* *************************************************************************/
263
- uint8_t PixelsHardware::GetStrandOrderDotStar (wippersnapper_pixels_PixelsOrder order) {
280
+ uint8_t
281
+ PixelsHardware::GetStrandOrderDotStar (wippersnapper_pixels_PixelsOrder order) {
264
282
switch (order) {
265
283
case wippersnapper_pixels_PixelsOrder_PIXELS_ORDER_GRB:
266
284
return DOTSTAR_GRB;
0 commit comments