forked from Makuna/NeoPixelBus
support for template GetPixelColor method (#774)
This commit is contained in:
@@ -139,7 +139,7 @@ void SetupAnimationSet()
|
|||||||
uint16_t time = random(100, 400);
|
uint16_t time = random(100, 400);
|
||||||
|
|
||||||
// each animation starts with the color that was present
|
// each animation starts with the color that was present
|
||||||
RgbColor originalColor = strip.GetPixelColor(pixel);
|
RgbColor originalColor = strip.GetPixelColor<RgbColor>(pixel);
|
||||||
// and ends with a random color
|
// and ends with a random color
|
||||||
RgbColor targetColor = RgbColor(random(peak), random(peak), random(peak));
|
RgbColor targetColor = RgbColor(random(peak), random(peak), random(peak));
|
||||||
// with the random ease function
|
// with the random ease function
|
||||||
|
@@ -40,7 +40,7 @@ void FadeAll(uint8_t darkenBy)
|
|||||||
RgbColor color;
|
RgbColor color;
|
||||||
for (uint16_t indexPixel = 0; indexPixel < strip.PixelCount(); indexPixel++)
|
for (uint16_t indexPixel = 0; indexPixel < strip.PixelCount(); indexPixel++)
|
||||||
{
|
{
|
||||||
color = strip.GetPixelColor(indexPixel);
|
color = strip.GetPixelColor<RgbColor>(indexPixel);
|
||||||
color.Darken(darkenBy);
|
color.Darken(darkenBy);
|
||||||
strip.SetPixelColor(indexPixel, color);
|
strip.SetPixelColor(indexPixel, color);
|
||||||
}
|
}
|
||||||
|
@@ -82,7 +82,7 @@ void FadeInFadeOutRinseRepeat(float luminance)
|
|||||||
RgbColor target = HslColor(random(360) / 360.0f, 1.0f, luminance);
|
RgbColor target = HslColor(random(360) / 360.0f, 1.0f, luminance);
|
||||||
uint16_t time = random(800, 2000);
|
uint16_t time = random(800, 2000);
|
||||||
|
|
||||||
animationState[0].StartingColor = strip.GetPixelColor(0);
|
animationState[0].StartingColor = strip.GetPixelColor<RgbColor>(0);
|
||||||
animationState[0].EndingColor = target;
|
animationState[0].EndingColor = target;
|
||||||
|
|
||||||
animations.StartAnimation(0, time, BlendAnimUpdate);
|
animations.StartAnimation(0, time, BlendAnimUpdate);
|
||||||
@@ -92,7 +92,7 @@ void FadeInFadeOutRinseRepeat(float luminance)
|
|||||||
// fade to black
|
// fade to black
|
||||||
uint16_t time = random(600, 700);
|
uint16_t time = random(600, 700);
|
||||||
|
|
||||||
animationState[0].StartingColor = strip.GetPixelColor(0);
|
animationState[0].StartingColor = strip.GetPixelColor<RgbColor>(0);
|
||||||
animationState[0].EndingColor = RgbColor(0);
|
animationState[0].EndingColor = RgbColor(0);
|
||||||
|
|
||||||
animations.StartAnimation(0, time, BlendAnimUpdate);
|
animations.StartAnimation(0, time, BlendAnimUpdate);
|
||||||
|
@@ -76,7 +76,7 @@ void PickRandom(float luminance)
|
|||||||
// we use HslColor object as it allows us to easily pick a color
|
// we use HslColor object as it allows us to easily pick a color
|
||||||
// with the same saturation and luminance
|
// with the same saturation and luminance
|
||||||
uint16_t time = random(100, 400);
|
uint16_t time = random(100, 400);
|
||||||
animationState[pixel].StartingColor = strip.GetPixelColor(pixel);
|
animationState[pixel].StartingColor = strip.GetPixelColor<RgbColor>(pixel);
|
||||||
animationState[pixel].EndingColor = HslColor(random(360) / 360.0f, 1.0f, luminance);
|
animationState[pixel].EndingColor = HslColor(random(360) / 360.0f, 1.0f, luminance);
|
||||||
|
|
||||||
animations.StartAnimation(pixel, time, BlendAnimUpdate);
|
animations.StartAnimation(pixel, time, BlendAnimUpdate);
|
||||||
|
@@ -203,6 +203,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T_COLOROBJECT> T_COLOROBJECT GetPixelColor(uint16_t indexPixel) const
|
||||||
|
{
|
||||||
|
return T_COLOROBJECT(GetPixelColor(indexPixel));
|
||||||
|
}
|
||||||
|
|
||||||
void ClearTo(typename T_COLOR_FEATURE::ColorObject color)
|
void ClearTo(typename T_COLOR_FEATURE::ColorObject color)
|
||||||
{
|
{
|
||||||
uint8_t temp[T_COLOR_FEATURE::PixelSize];
|
uint8_t temp[T_COLOR_FEATURE::PixelSize];
|
||||||
|
@@ -35,6 +35,11 @@ License along with NeoPixel. If not, see
|
|||||||
#include "HtmlColor.h"
|
#include "HtmlColor.h"
|
||||||
|
|
||||||
#include "RgbwColor.h"
|
#include "RgbwColor.h"
|
||||||
|
#include "RgbwwColor.h"
|
||||||
|
#include "RgbwwwColor.h"
|
||||||
|
#include "Rgb48Color.h"
|
||||||
|
#include "Rgbw64Color.h"
|
||||||
|
#include "Rgbww80Color.h"
|
||||||
|
|
||||||
RgbColor::RgbColor(const RgbwColor& color) :
|
RgbColor::RgbColor(const RgbwColor& color) :
|
||||||
R(color.R),
|
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)
|
RgbColor::RgbColor(const Rgb16Color& color)
|
||||||
{
|
{
|
||||||
R = color.getR();
|
R = color.getR();
|
||||||
|
@@ -26,6 +26,11 @@ License along with NeoPixel. If not, see
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct RgbwColor;
|
struct RgbwColor;
|
||||||
|
struct RgbwwColor;
|
||||||
|
struct RgbwwwColor;
|
||||||
|
struct Rgb48Color;
|
||||||
|
struct Rgbw64Color;
|
||||||
|
struct Rgbww80Color;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// RgbColor represents a color object that is represented by Red, Green, Blue
|
// RgbColor represents a color object that is represented by Red, Green, Blue
|
||||||
@@ -59,6 +64,31 @@ struct RgbColor : RgbColorBase
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
explicit RgbColor(const RgbwColor& color);
|
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
|
// Construct a RgbColor using Rgb16Color
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user