Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Madison <dmadison@users.noreply.github.com>2022-01-03 00:07:11 +0300
committerDavid Madison <dmadison@users.noreply.github.com>2022-01-03 00:07:11 +0300
commitf2da89411b1180398e204ca8c8522845706954f1 (patch)
tree7503b22e2b61758add0349f22dc36ab8ce0bc2da
parent3ebf7bf483c6066faec907855ab1f5882dc58d9a (diff)
Reduce circular precision constants by 1
256 * 256 - 1, to fit into a uint16_t (2^16)
-rw-r--r--src/colorutils.cpp4
-rw-r--r--src/colorutils.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/colorutils.cpp b/src/colorutils.cpp
index 18aa9ed8..16cf855d 100644
--- a/src/colorutils.cpp
+++ b/src/colorutils.cpp
@@ -71,7 +71,7 @@ void fill_rainbow_circular(struct CRGB* targetArray, int numToFill, uint8_t init
hsv.val = 255;
hsv.sat = 240;
- const uint16_t hueChange = 65536 / (uint16_t)numToFill; // hue change for each LED, * 256 for precision
+ const uint16_t hueChange = 65535 / (uint16_t)numToFill; // hue change for each LED, * 256 for precision (256 * 256 - 1)
uint16_t hueOffset = 0; // offset for hue value, with precision (*256)
for (int i = 0; i < numToFill; ++i) {
@@ -90,7 +90,7 @@ void fill_rainbow_circular(struct CHSV* targetArray, int numToFill, uint8_t init
hsv.val = 255;
hsv.sat = 240;
- const uint16_t hueChange = 65536 / (uint16_t)numToFill; // hue change for each LED, * 256 for precision
+ const uint16_t hueChange = 65535 / (uint16_t) numToFill; // hue change for each LED, * 256 for precision (256 * 256 - 1)
uint16_t hueOffset = 0; // offset for hue value, with precision (*256)
for (int i = 0; i < numToFill; ++i) {
diff --git a/src/colorutils.h b/src/colorutils.h
index 4ea7962d..8b9f98af 100644
--- a/src/colorutils.h
+++ b/src/colorutils.h
@@ -1586,7 +1586,7 @@ void fill_palette_circular(CRGB* L, uint16_t N, uint8_t startIndex,
{
if (N == 0) return; // avoiding div/0
- const uint16_t colorChange = 65536 / N; // color change for each LED, * 256 for precision
+ const uint16_t colorChange = 65535 / N; // color change for each LED, * 256 for precision
uint16_t colorIndex = ((uint16_t) startIndex) << 8; // offset for color index, with precision (*256)
for (uint16_t i = 0; i < N; ++i) {