From 053083f600581962d40912cf5c76a88cf6d8aaef Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 22 Aug 2022 17:06:28 +0200 Subject: [PATCH] Minor optimisation. --- wled00/FX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index a57aaafb8..2c01e1fef 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2826,7 +2826,7 @@ uint16_t mode_bouncing_balls(void) { // number of balls based on intensity setting to max of 7 (cycles colors) // non-chosen color is a random color - uint8_t numBalls = int(((SEGMENT.intensity * (maxNumBalls - 0.8f)) / 255) + 1); + uint16_t numBalls = int(((SEGMENT.intensity * (maxNumBalls - 0.8f)) / 255) + 1); float gravity = -9.81; // standard value of gravity float impactVelocityStart = sqrt( -2 * gravity); @@ -2848,7 +2848,7 @@ uint16_t mode_bouncing_balls(void) { if (balls[i].height < 0) { //start bounce balls[i].height = 0; //damping for better effect using multiple balls - float dampening = 0.90 - float(i)/(float(numBalls) * float(numBalls)); // avoid use pow(x, 2) - its extremely slow ! + float dampening = 0.90 - float(i)/float(numBalls * numBalls); // avoid use pow(x, 2) - its extremely slow ! balls[i].impactVelocity = dampening * balls[i].impactVelocity; balls[i].lastBounceTime = time;