Skip to content

Commit acb61c5

Browse files
authored
Merge pull request #147 from Legion2/fix-scale
fixed scale function when scaling down
2 parents 03c0535 + 3d122e5 commit acb61c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/FastLEDControllerUtils.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,14 @@ void CLP::transformLLFanToStrip(FastLEDController* controller, uint8_t channelIn
3636
void CLP::scale(FastLEDController* controller, uint8_t channelIndex, int scaleToSize) {
3737
auto leds = controller->getLEDs(channelIndex);
3838
const float scaleFactor = (float)controller->getLEDCount(channelIndex) / scaleToSize;
39-
for (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {
40-
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
39+
if (scaleFactor < 1.0f) {
40+
for (int ledIndex = scaleToSize - 1; ledIndex >= 0; ledIndex--) {
41+
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
42+
}
43+
} else {
44+
for (int ledIndex = 0; ledIndex < scaleToSize; ledIndex++) {
45+
leds[ledIndex] = leds[lround(ledIndex * scaleFactor)];
46+
}
4147
}
4248
}
4349

0 commit comments

Comments
 (0)