diff --git a/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino b/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino index 04c24b2..303bdeb 100644 --- a/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino +++ b/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino @@ -139,7 +139,7 @@ void SetupAnimationSet() uint16_t time = random(100, 400); // each animation starts with the color that was present - RgbColor originalColor = strip.GetPixelColor(pixel); + RgbColor originalColor = strip.GetPixelColor(pixel); // and ends with a random color RgbColor targetColor = RgbColor(random(peak), random(peak), random(peak)); // with the random ease function diff --git a/examples/animations/NeoPixelCylon/NeoPixelCylon.ino b/examples/animations/NeoPixelCylon/NeoPixelCylon.ino index 15b36d0..6a1b899 100644 --- a/examples/animations/NeoPixelCylon/NeoPixelCylon.ino +++ b/examples/animations/NeoPixelCylon/NeoPixelCylon.ino @@ -40,7 +40,7 @@ void FadeAll(uint8_t darkenBy) RgbColor color; for (uint16_t indexPixel = 0; indexPixel < strip.PixelCount(); indexPixel++) { - color = strip.GetPixelColor(indexPixel); + color = strip.GetPixelColor(indexPixel); color.Darken(darkenBy); strip.SetPixelColor(indexPixel, color); } diff --git a/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino b/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino index ac18de5..280ef4b 100644 --- a/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino +++ b/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino @@ -82,7 +82,7 @@ void FadeInFadeOutRinseRepeat(float luminance) RgbColor target = HslColor(random(360) / 360.0f, 1.0f, luminance); uint16_t time = random(800, 2000); - animationState[0].StartingColor = strip.GetPixelColor(0); + animationState[0].StartingColor = strip.GetPixelColor(0); animationState[0].EndingColor = target; animations.StartAnimation(0, time, BlendAnimUpdate); @@ -92,7 +92,7 @@ void FadeInFadeOutRinseRepeat(float luminance) // fade to black uint16_t time = random(600, 700); - animationState[0].StartingColor = strip.GetPixelColor(0); + animationState[0].StartingColor = strip.GetPixelColor(0); animationState[0].EndingColor = RgbColor(0); animations.StartAnimation(0, time, BlendAnimUpdate); diff --git a/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino b/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino index 89e8347..dddeca3 100644 --- a/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino +++ b/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino @@ -76,7 +76,7 @@ void PickRandom(float luminance) // we use HslColor object as it allows us to easily pick a color // with the same saturation and luminance uint16_t time = random(100, 400); - animationState[pixel].StartingColor = strip.GetPixelColor(pixel); + animationState[pixel].StartingColor = strip.GetPixelColor(pixel); animationState[pixel].EndingColor = HslColor(random(360) / 360.0f, 1.0f, luminance); animations.StartAnimation(pixel, time, BlendAnimUpdate); diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index e7e92af..58d27b9 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -203,6 +203,11 @@ public: } }; + template T_COLOROBJECT GetPixelColor(uint16_t indexPixel) const + { + return T_COLOROBJECT(GetPixelColor(indexPixel)); + } + void ClearTo(typename T_COLOR_FEATURE::ColorObject color) { uint8_t temp[T_COLOR_FEATURE::PixelSize]; diff --git a/src/internal/colors/RgbColor.cpp b/src/internal/colors/RgbColor.cpp index 81d0ba5..6bc592c 100644 --- a/src/internal/colors/RgbColor.cpp +++ b/src/internal/colors/RgbColor.cpp @@ -35,6 +35,11 @@ License along with NeoPixel. If not, see #include "HtmlColor.h" #include "RgbwColor.h" +#include "RgbwwColor.h" +#include "RgbwwwColor.h" +#include "Rgb48Color.h" +#include "Rgbw64Color.h" +#include "Rgbww80Color.h" RgbColor::RgbColor(const RgbwColor& color) : R(color.R), @@ -43,6 +48,41 @@ RgbColor::RgbColor(const RgbwColor& color) : { }; +RgbColor::RgbColor(const RgbwwColor& color) : + R(color.R), + G(color.G), + B(color.B) +{ +}; + +RgbColor::RgbColor(const RgbwwwColor& color) : + R(color.R), + G(color.G), + B(color.B) +{ +}; + +RgbColor::RgbColor(const Rgb48Color& color) : + R(color.R >> 8), + G(color.G >> 8), + B(color.B >> 8) +{ +}; + +RgbColor::RgbColor(const Rgbw64Color& color) : + R(color.R >> 8), + G(color.G >> 8), + B(color.B >> 8) +{ +}; + +RgbColor::RgbColor(const Rgbww80Color& color) : + R(color.R >> 8), + G(color.G >> 8), + B(color.B >> 8) +{ +}; + RgbColor::RgbColor(const Rgb16Color& color) { R = color.getR(); diff --git a/src/internal/colors/RgbColor.h b/src/internal/colors/RgbColor.h index 2b34d80..c62df66 100644 --- a/src/internal/colors/RgbColor.h +++ b/src/internal/colors/RgbColor.h @@ -26,6 +26,11 @@ License along with NeoPixel. If not, see #pragma once struct RgbwColor; +struct RgbwwColor; +struct RgbwwwColor; +struct Rgb48Color; +struct Rgbw64Color; +struct Rgbww80Color; // ------------------------------------------------------------------------ // RgbColor represents a color object that is represented by Red, Green, Blue @@ -59,6 +64,31 @@ struct RgbColor : RgbColorBase // ------------------------------------------------------------------------ explicit RgbColor(const RgbwColor& color); + // ------------------------------------------------------------------------ + // explicitly Construct a RgbColor using RgbwwColor + // ------------------------------------------------------------------------ + explicit RgbColor(const RgbwwColor& color); + + // ------------------------------------------------------------------------ + // explicitly Construct a RgbColor using RgbwwwColor + // ------------------------------------------------------------------------ + explicit RgbColor(const RgbwwwColor& color); + + // ------------------------------------------------------------------------ + // explicitly Construct a RgbColor using Rgb48Color + // ------------------------------------------------------------------------ + explicit RgbColor(const Rgb48Color& color); + + // ------------------------------------------------------------------------ + // explicitly Construct a RgbColor using Rgbw64Color + // ------------------------------------------------------------------------ + explicit RgbColor(const Rgbw64Color& color); + + // ------------------------------------------------------------------------ + // explicitly Construct a RgbColor using Rgbww80Color + // ------------------------------------------------------------------------ + explicit RgbColor(const Rgbww80Color& color); + // ------------------------------------------------------------------------ // Construct a RgbColor using Rgb16Color // ------------------------------------------------------------------------