4#include "force_inline.h"
6#if FASTLED_IS_USING_NAMESPACE
7#define FUNCTION_FILL_RAINBOW(a,b,c,d) FASTLED_NAMESPACE::fill_rainbow(a,b,c,d)
8#define FUNCTION_NAPPLY_GAMMA(a,b,c) FASTLED_NAMESPACE::napplyGamma_video(a,b,c)
9#define FUNCTION_NAPPLY_GAMMA_RGB(a,b,c,d,e) FASTLED_NAMESPACE::napplyGamma_video(a,b,c,d,e)
10#define FUNCTION_BLUR1D(a,b,c) FASTLED_NAMESPACE::blur1d(a,b,c)
11#define FUNCTION_FILL_GRADIENT(a,b,c,d,e) FASTLED_NAMESPACE::fill_gradient(a,b,c,d,e)
12#define FUNCTION_FILL_GRADIENT3(a,b,c,d,e,f) FASTLED_NAMESPACE::fill_gradient(a,b,c,d,e,f)
13#define FUNCTION_FILL_GRADIENT4(a,b,c,d,e,f,g) FASTLED_NAMESPACE::fill_gradient(a,b,c,d,e,f,g)
14#define FUNCTION_NBLEND(a,b,c) FASTLED_NAMESPACE::nblend(a,b,c)
15#define FUNCTION_FILL_GRADIENT_RGB(a,b,c,d) FASTLED_NAMESPACE::fill_gradient_RGB(a,b,c,d)
16#define FUNCTION_FILL_GRADIENT_RGB3(a,b,c,d,e) FASTLED_NAMESPACE::fill_gradient_RGB(a,b,c,d,e)
17#define FUNCTION_FILL_GRADIENT_RGB4(a,b,c,d,e,f) FASTLED_NAMESPACE::fill_gradient_RGB(a,b,c,d,e,f)
19#define FUNCTION_FILL_RAINBOW(a,b,c,d) ::fill_rainbow(a,b,c,d)
20#define FUNCTION_NAPPLY_GAMMA(a,b,c) ::napplyGamma_video(a,b,c)
21#define FUNCTION_NAPPLY_GAMMA_RGB(a,b,c,d,e) ::napplyGamma_video(a,b,c,d,e)
22#define FUNCTION_BLUR1D(a,b,c) ::blur1d(a,b,c)
23#define FUNCTION_FILL_GRADIENT(a,b,c,d,e) ::fill_gradient(a,b,c,d,e)
24#define FUNCTION_FILL_GRADIENT3(a,b,c,d,e,f) ::fill_gradient(a,b,c,d,e,f)
25#define FUNCTION_FILL_GRADIENT4(a,b,c,d,e,f,g) ::fill_gradient(a,b,c,d,e,f,g)
26#define FUNCTION_NBLEND(a,b,c) ::nblend(a,b,c)
27#define FUNCTION_FILL_GRADIENT_RGB(a,b,c,d) ::fill_gradient_RGB(a,b,c,d)
28#define FUNCTION_FILL_GRADIENT_RGB3(a,b,c,d,e) ::fill_gradient_RGB(a,b,c,d,e)
29#define FUNCTION_FILL_GRADIENT_RGB4(a,b,c,d,e,f) ::fill_gradient_RGB(a,b,c,d,e,f)
39FASTLED_NAMESPACE_BEGIN
41template<
class PIXEL_TYPE>
64template<
class PIXEL_TYPE>
88 inline CPixelView(PIXEL_TYPE *_leds,
int _start,
int _end) :
dir(((_end-_start)<0) ? -1 : 1),
len((_end - _start) +
dir),
leds(_leds + _start),
end_pos(_leds + _start +
len) {}
122 inline operator PIXEL_TYPE* ()
const {
return leds; }
127 for(
iterator pixel =
begin(), _end =
end(); pixel != _end; ++pixel) { (*pixel) = color; }
146 for(
iterator pixel =
begin(), rhspixel = rhs.
begin(), _end =
end(), rhs_end = rhs.
end(); (pixel != _end) && (rhspixel != rhs_end); ++pixel, ++rhspixel) {
147 (*pixel) = (*rhspixel);
225 inline operator bool() {
for(
iterator pixel =
begin(), _end =
end(); pixel != _end; ++pixel) {
if((*pixel))
return true; }
return false; }
243 FUNCTION_FILL_RAINBOW(
leds,
len,initialhue,deltahue);
245 FUNCTION_FILL_RAINBOW(
leds +
len + 1, -
len, initialhue - deltahue * (
len+1), -deltahue);
257 FUNCTION_FILL_GRADIENT(
leds,
len,startcolor, endcolor, directionCode);
259 FUNCTION_FILL_GRADIENT(
leds +
len + 1, (-
len), endcolor, startcolor, directionCode);
272 FUNCTION_FILL_GRADIENT3(
leds,
len, c1, c2, c3, directionCode);
274 FUNCTION_FILL_GRADIENT3(
leds +
len + 1, -
len, c3, c2, c1, directionCode);
288 FUNCTION_FILL_GRADIENT4(
leds,
len, c1, c2, c3, c4, directionCode);
290 FUNCTION_FILL_GRADIENT4(
leds +
len + 1, -
len, c4, c3, c2, c1, directionCode);
302 FUNCTION_FILL_GRADIENT_RGB(
leds,
len,startcolor, endcolor);
304 FUNCTION_FILL_GRADIENT_RGB(
leds +
len + 1, (-
len), endcolor, startcolor);
316 FUNCTION_FILL_GRADIENT_RGB3(
leds,
len, c1, c2, c3);
318 FUNCTION_FILL_GRADIENT_RGB3(
leds +
len + 1, -
len, c3, c2, c1);
331 FUNCTION_FILL_GRADIENT_RGB4(
leds,
len, c1, c2, c3, c4);
333 FUNCTION_FILL_GRADIENT_RGB4(
leds +
len + 1, -
len, c4, c3, c2, c1);
342 inline CPixelView &
nblend(
const PIXEL_TYPE & overlay,
fract8 amountOfOverlay) {
for(
iterator pixel =
begin(), _end =
end(); pixel != _end; ++pixel) { FUNCTION_NBLEND((*pixel), overlay, amountOfOverlay); }
return *
this; }
348 inline CPixelView &
nblend(
const CPixelView & rhs,
fract8 amountOfOverlay) {
for(
iterator pixel =
begin(), rhspixel = rhs.
begin(), _end =
end(), rhs_end = rhs.
end(); (pixel != _end) && (rhspixel != rhs_end); ++pixel, ++rhspixel) { FUNCTION_NBLEND((*pixel), (*rhspixel), amountOfOverlay); }
return *
this; }
356 FUNCTION_BLUR1D(
leds,
len, blur_amount);
358 FUNCTION_BLUR1D(
leds +
len + 1, -
len, blur_amount);
368 FUNCTION_NAPPLY_GAMMA(
leds,
len, gamma);
370 FUNCTION_NAPPLY_GAMMA(
leds +
len + 1, -
len, gamma);
382 FUNCTION_NAPPLY_GAMMA_RGB(
leds,
len, gammaR, gammaG, gammaB);
384 FUNCTION_NAPPLY_GAMMA_RGB(
leds +
len + 1, -
len, gammaR, gammaG, gammaB);
419 FASTLED_FORCE_INLINE PIXEL_TYPE&
operator*()
const {
return *leds; }
439 return (
CRGB*)pixels + offset;
451 using CPixelView::operator=;
458#undef FUNCTION_FILL_RAINBOW
459#undef FUNCTION_NAPPLY_GAMMA
460#undef FUNCTION_NAPPLY_GAMMA_RGB
461#undef FUNCTION_BLUR1D
462#undef FUNCTION_FILL_GRADIENT
463#undef FUNCTION_FILL_GRADIENT3
464#undef FUNCTION_FILL_GRADIENT4
465#undef FUNCTION_NBLEND
466#undef FUNCTION_FILL_GRADIENT_RGB
467#undef FUNCTION_FILL_GRADIENT_RGB3
468#undef FUNCTION_FILL_GRADIENT_RGB4
central include file for FastLED, defines the CFastLED class/object
Iterator helper class for CPixelView.
FASTLED_FORCE_INLINE bool operator==(pixelset_iterator_base &other) const
Check if iterator is at the same position.
FASTLED_FORCE_INLINE pixelset_iterator_base & operator++()
Increment LED pointer in data direction.
FASTLED_FORCE_INLINE pixelset_iterator_base operator++(int)
Increment LED pointer in data direction.
FASTLED_FORCE_INLINE pixelset_iterator_base(const pixelset_iterator_base &rhs)
Copy constructor.
FASTLED_FORCE_INLINE pixelset_iterator_base(T *_leds, const char _dir)
Base constructor.
FASTLED_FORCE_INLINE PIXEL_TYPE & operator*() const
Dereference operator, to get underlying pointer to the LEDs.
FASTLED_FORCE_INLINE bool operator!=(pixelset_iterator_base &other) const
Check if iterator is not at the same position.
Represents a set of LED objects.
CPixelView(PIXEL_TYPE *_leds, int _len)
PixelSet constructor for a pixel set starting at the given PIXEL_TYPE* and going for _len leds.
CPixelView & nscale8(PIXEL_TYPE &scaledown)
Scale every LED by the given scale.
CPixelView & operator&=(const CPixelView &rhs)
Apply the PIXEL_TYPE &= operator to every pixel in this set with every pixel in the passed in set.
CPixelView & fill_gradient(const CHSV &c1, const CHSV &c2, const CHSV &c3, TGradientDirectionCode directionCode=SHORTEST_HUES)
Fill all of the LEDs with a smooth HSV gradient between three HSV colors.
CPixelView & operator-=(CPixelView &rhs)
Subtract every pixel in the other set from this set.
CPixelView & fill_gradient_RGB(const PIXEL_TYPE &c1, const PIXEL_TYPE &c2, const PIXEL_TYPE &c3, const PIXEL_TYPE &c4)
Fill all of the LEDs with a smooth RGB gradient between four RGB colors.
CPixelView & fill_rainbow(uint8_t initialhue, uint8_t deltahue=5)
Fill all of the LEDs with a rainbow of colors.
CPixelView & addToRGB(uint8_t inc)
Add the passed in value to all channels for all of the pixels in this set.
PIXEL_TYPE *const leds
pointer to the LED data
CPixelView & nscale8_video(uint8_t scaledown)
Scale every LED by the given scale.
CPixelView & operator--()
Decrement every pixel value in this set.
const_iterator cbegin() const
Makes a const iterator instance for the start of the LED set, const qualified.
const_iterator cend() const
Makes a const iterator instance for the end of the LED set, const qualified.
CPixelView & operator*=(uint8_t d)
Multiply every LED in this set by the given value.
CPixelView & operator|=(const PIXEL_TYPE &rhs)
Apply the PIXEL_TYPE |= operator to every pixel in this set with the given PIXEL_TYPE value.
bool reversed()
Whether or not this set goes backwards.
CPixelView & operator--(int DUMMY_ARG)
Decrement every pixel value in this set.
CPixelView & fill_solid(const CHSV &color)
Fill all of the LEDs with a solid color.
CPixelView & operator=(const CPixelView &rhs)
Copy the contents of the passed-in set to our set.
CPixelView & operator++(int DUMMY_ARG)
Increment every pixel value in this set.
iterator end()
Makes an iterator instance for the end of the LED set.
CPixelView & operator+=(CPixelView &rhs)
Add every pixel in the other set to this set.
CPixelView & operator=(const PIXEL_TYPE &color)
Assign the passed in color to all elements in this set.
const int8_t dir
direction of the LED data, either 1 or -1. Determines how the pointer is incremented.
CPixelView & operator++()
Increment every pixel value in this set.
CPixelView & fill_gradient_RGB(const PIXEL_TYPE &c1, const PIXEL_TYPE &c2, const PIXEL_TYPE &c3)
Fill all of the LEDs with a smooth RGB gradient between three RGB colors.
void dump() const
Print debug data to serial, disabled for release.
CPixelView & blur1d(fract8 blur_amount)
One-dimensional blur filter.
CPixelView & nblend(const PIXEL_TYPE &overlay, fract8 amountOfOverlay)
Destructively modifies all LEDs, blending in a given fraction of an overlay color.
CPixelView & operator&=(const PIXEL_TYPE &rhs)
Apply the PIXEL_TYPE &= operator to every pixel in this set with the given PIXEL_TYPE value.
CPixelView & fill_gradient(const CHSV &startcolor, const CHSV &endcolor, TGradientDirectionCode directionCode=SHORTEST_HUES)
Fill all of the LEDs with a smooth HSV gradient between two HSV colors.
CPixelView & operator%=(uint8_t scaledown)
Scale down every LED by the given scale.
pixelset_iterator_base< PIXEL_TYPE > iterator
Iterator helper type for this class.
CPixelView & operator/=(uint8_t d)
Divide every LED by the given value.
CPixelView & nscale8(uint8_t scaledown)
Scale every LED by the given scale.
CPixelView & fill_gradient_RGB(const PIXEL_TYPE &startcolor, const PIXEL_TYPE &endcolor, TGradientDirectionCode directionCode=SHORTEST_HUES)
Fill all of the LEDs with a smooth RGB gradient between two RGB colors.
CPixelView & operator>>=(uint8_t d)
Shift every LED in this set right by the given number of bits.
CPixelView operator()(int start, int end)
Access an inclusive subset of the LEDs in this set.
bool operator==(const CPixelView &rhs) const
Do these sets point to the same thing? Note that this is different from the contents of the set being...
CPixelView & napplyGamma_video(float gamma)
Destructively applies a gamma adjustment to all LEDs.
CPixelView & fadeToBlackBy(uint8_t fade)
Fade every LED down by the given scale.
CPixelView & fill_gradient(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4, TGradientDirectionCode directionCode=SHORTEST_HUES)
Fill all of the LEDs with a smooth HSV gradient between four HSV colors.
CPixelView & operator|=(uint8_t d)
Apply the PIXEL_TYPE |= operator to every pixel in this set.
PIXEL_TYPE *const end_pos
pointer to the end position of the LED data
PIXEL_TYPE & operator[](int x) const
Access a single element in this set, just like an array operator.
CPixelView & subFromRGB(uint8_t inc)
Subtract the passed in value from all channels for all of the pixels in this set.
CPixelView & fadeLightBy(uint8_t fadefactor)
Fade every LED down by the given scale.
CPixelView & operator|=(const CPixelView &rhs)
Apply the PIXEL_TYPE |= operator to every pixel in this set with every pixel in the passed in set.
pixelset_iterator_base< const PIXEL_TYPE > const_iterator
Const iterator helper type for this class.
CPixelView & nscale8(CPixelView &rhs)
Scale every LED in this set by every led in the other set.
CPixelView operator-()
Return the reverse ordering of this set.
CPixelView & fill_solid(const PIXEL_TYPE &color)
Fill all of the LEDs with a solid color.
CPixelView(PIXEL_TYPE *_leds, int _start, int _end)
PixelSet constructor for the given set of LEDs, with start and end boundaries.
CPixelView & operator&=(uint8_t d)
Apply the PIXEL_TYPE &= operator to every pixel in this set with the passed in value.
bool operator!=(const CPixelView &rhs) const
Do these sets point to different things? Note that this is different from the contents of the set bei...
CPixelView & nblend(const CPixelView &rhs, fract8 amountOfOverlay)
Destructively blend another set of LEDs into this one.
iterator begin() const
Makes an iterator instance for the start of the LED set, const qualified.
iterator begin()
Makes an iterator instance for the start of the LED set.
iterator end() const
Makes an iterator instance for the end of the LED set, const qualified.
const int len
length of the LED data, in PIXEL_TYPE units.
CPixelView & napplyGamma_video(float gammaR, float gammaG, float gammaB)
Destructively applies a gamma adjustment to all LEDs.
CPixelView(const CPixelView &other)
PixelSet copy constructor.
int size()
Get the size of this set.
A version of CPixelView<CRGB> with an included array of CRGB LEDs.
TGradientDirectionCode
Hue direction for calculating fill gradients.
@ SHORTEST_HUES
Hue goes whichever way is shortest.
uint8_t fract8
ANSI: unsigned short _Fract.
FASTLED_FORCE_INLINE CRGB * operator+(const CRGBSet &pixels, int offset)
Retrieve a pointer to a CRGB array, using a CRGBSet and an LED offset.
CPixelView< CRGB > CRGBSet
CPixelView for CRGB arrays.
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Representation of an RGB pixel (Red, Green, Blue)