@@ -47,8 +47,10 @@ PixelsHardware::~PixelsHardware() {}
4747/* *************************************************************************/
4848bool PixelsHardware::AddNeoPixel (uint16_t num_pixels, uint16_t pin_data,
4949 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" );
5152 ReleaseStatusPixel (); // Release the status pixel for use
53+ }
5254
5355 _neopixel = new Adafruit_NeoPixel (num_pixels, pin_data, order);
5456 _neopixel->begin ();
@@ -131,6 +133,8 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
131133 _type = type;
132134 // Convert the pin string to an integer
133135 uint16_t p_data = atoi (pin_data + 1 );
136+ _pin_data = p_data; // Store the pin data for later reference
137+
134138 if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_NEOPIXEL) {
135139 if (!AddNeoPixel (num_pixels, p_data, GetStrandOrderNeoPixel (order),
136140 (uint8_t )brightness)) {
@@ -144,6 +148,7 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
144148 WS_DEBUG_PRINTLN (" [pixels] Failed to create DotStar strand!" );
145149 return false ;
146150 }
151+ return true ;
147152 } else {
148153 WS_DEBUG_PRINTLN (" [pixels] Unknown pixel type!" );
149154 return false ;
@@ -160,9 +165,13 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
160165/* *************************************************************************/
161166void PixelsHardware::FillStrand (uint32_t color) {
162167 // Apply gamma correction to match IO Web
163- uint32_t color_gamma = ApplyGammaCorrection (color);
164168 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);
166175 if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_NEOPIXEL) {
167176 _neopixel->fill (color_gamma);
168177 _neopixel->show ();
@@ -183,7 +192,14 @@ void PixelsHardware::FillStrand(uint32_t color) {
183192*/
184193/* *************************************************************************/
185194uint32_t PixelsHardware::ApplyGammaCorrection (uint32_t color) {
195+ WS_DEBUG_PRINT (" Type: " );
196+ WS_DEBUG_PRINTLN (_type);
186197 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+ }
187203 return _neopixel->gamma32 (color);
188204 } else if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_DOTSTAR) {
189205 return _dotstar->gamma32 (color);
@@ -235,7 +251,8 @@ uint16_t PixelsHardware::GetPinData() { return _pin_data; }
235251 @returns The color ordering for NeoPixel strands
236252*/
237253/* *************************************************************************/
238- neoPixelType PixelsHardware::GetStrandOrderNeoPixel (wippersnapper_pixels_PixelsOrder order) {
254+ neoPixelType
255+ PixelsHardware::GetStrandOrderNeoPixel (wippersnapper_pixels_PixelsOrder order) {
239256 switch (order) {
240257 case wippersnapper_pixels_PixelsOrder_PIXELS_ORDER_GRB:
241258 return NEO_GRB + NEO_KHZ800;
@@ -260,7 +277,8 @@ neoPixelType PixelsHardware::GetStrandOrderNeoPixel(wippersnapper_pixels_PixelsO
260277 @returns The color ordering for DotStar strands
261278*/
262279/* *************************************************************************/
263- uint8_t PixelsHardware::GetStrandOrderDotStar (wippersnapper_pixels_PixelsOrder order) {
280+ uint8_t
281+ PixelsHardware::GetStrandOrderDotStar (wippersnapper_pixels_PixelsOrder order) {
264282 switch (order) {
265283 case wippersnapper_pixels_PixelsOrder_PIXELS_ORDER_GRB:
266284 return DOTSTAR_GRB;
0 commit comments