Skip to content

Commit 6e7732c

Browse files
committed
cleanup
1 parent ec2291f commit 6e7732c

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

src/components/pixels/controller.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,25 @@ bool PixelsController::Handle_Pixels_Add(pb_istream_t *stream) {
6060
msg_add->pixels_type, msg_add->pixels_ordering, msg_add->pixels_num,
6161
msg_add->pixels_brightness, msg_add->pixels_pin_data,
6262
msg_add->pixels_pin_dotstar_clock);
63-
if (!did_init)
63+
if (! did_init) {
6464
WS_DEBUG_PRINTLN("[pixels] Failed to create strand!");
65+
} else {
66+
_num_strands++;
67+
WS_DEBUG_PRINT("[pixels]: Added strand #");
68+
WS_DEBUG_PRINTLN(_num_strands);
69+
}
6570

6671
// Publish PixelsAdded message to the broker
67-
if (!_pixels_model->EncodePixelsAdded(msg_add->pixels_pin_data, did_init)) {
72+
if (! _pixels_model->EncodePixelsAdded(msg_add->pixels_pin_data, did_init)) {
6873
WS_DEBUG_PRINTLN("[pixels]: Failed to encode PixelsAdded message!");
6974
return false;
7075
}
71-
if (!WsV2.PublishSignal(wippersnapper_signal_DeviceToBroker_pixels_added_tag,
76+
if (! WsV2.PublishSignal(wippersnapper_signal_DeviceToBroker_pixels_added_tag,
7277
_pixels_model->GetPixelsAddedMsg())) {
7378
WS_DEBUG_PRINTLN("[pixels]: Unable to publish PixelsAdded message!");
7479
return false;
7580
}
7681

77-
// Increment the strand counter if initialization was successful
78-
if (did_init) {
79-
_num_strands++;
80-
WS_DEBUG_PRINT("[pixels]: Added strand #");
81-
WS_DEBUG_PRINTLN(_num_strands);
82-
}
83-
8482
return true;
8583
}
8684

@@ -102,7 +100,7 @@ bool PixelsController::Handle_Pixels_Write(pb_istream_t *stream) {
102100
_pixels_model->GetPixelsWriteMsg();
103101
uint16_t pin_data = atoi(msg_write->pixels_pin_data + 1);
104102
uint16_t idx = GetStrandIndex(pin_data);
105-
if (idx == 0xFF) {
103+
if (idx == STRAND_NOT_FOUND) {
106104
WS_DEBUG_PRINTLN("[pixels]: Failed to find strand index!");
107105
return false;
108106
}
@@ -132,7 +130,7 @@ bool PixelsController::Handle_Pixels_Remove(pb_istream_t *stream) {
132130

133131
uint16_t pin_data = atoi(msg_remove->pixels_pin_data + 1);
134132
uint16_t idx = GetStrandIndex(pin_data);
135-
if (idx == 0xFF) {
133+
if (idx == STRAND_NOT_FOUND) {
136134
WS_DEBUG_PRINTLN("[pixels]: Failed to find strand index!");
137135
return false;
138136
}
@@ -147,7 +145,7 @@ bool PixelsController::Handle_Pixels_Remove(pb_istream_t *stream) {
147145
@brief Gets the index of a strand by its data pin
148146
@param pin_data
149147
The desired data pin
150-
@returns Desired strand index, or 0xFF if not found.
148+
@returns Desired strand index, or STRAND_NOT_FOUND if not found.
151149
*/
152150
/**************************************************************************/
153151
uint16_t PixelsController::GetStrandIndex(uint16_t pin_data) {
@@ -156,7 +154,5 @@ uint16_t PixelsController::GetStrandIndex(uint16_t pin_data) {
156154
return i;
157155
}
158156
}
159-
WS_DEBUG_PRINT("[pixels]: No strand found on pin ");
160-
WS_DEBUG_PRINTLN(pin_data);
161-
return 0xFF; // Sentinel value indicating "not found"
157+
return STRAND_NOT_FOUND; // Sentinel value indicating "not found"
162158
}

src/components/pixels/hardware.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,7 @@ bool PixelsHardware::AddStrand(wippersnapper_pixels_PixelsType type,
165165
/**************************************************************************/
166166
void PixelsHardware::FillStrand(uint32_t color) {
167167
// Apply gamma correction to match IO Web
168-
WS_DEBUG_PRINT("[pixels] Filling strand with color: ");
169-
WS_DEBUG_PRINTLN(color);
170-
171-
WS_DEBUG_PRINTLN("Applying gamma correction..");
172168
uint32_t color_gamma = ApplyGammaCorrection(color);
173-
WS_DEBUG_PRINT("[pixels] Filling strand with color_gamma: ");
174-
WS_DEBUG_PRINT(color_gamma);
175169
if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_NEOPIXEL) {
176170
_neopixel->fill(color_gamma);
177171
_neopixel->show();
@@ -192,14 +186,7 @@ void PixelsHardware::FillStrand(uint32_t color) {
192186
*/
193187
/**************************************************************************/
194188
uint32_t PixelsHardware::ApplyGammaCorrection(uint32_t color) {
195-
WS_DEBUG_PRINT("Type: ");
196-
WS_DEBUG_PRINTLN(_type);
197189
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-
}
203190
return _neopixel->gamma32(color);
204191
} else if (_type == wippersnapper_pixels_PixelsType_PIXELS_TYPE_DOTSTAR) {
205192
return _dotstar->gamma32(color);

0 commit comments

Comments
 (0)