FastLED 3.9.15
Loading...
Searching...
No Matches
crgb16.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/int.h"
5#include "fl/stl/noexcept.h"
6
7namespace fl {
8
9struct CRGB16 {
10 typedef u8x8 fp;
11 u8x8 r, g, b;
12 CRGB16() FL_NOEXCEPT = default;
13 CRGB16(u8x8 rv, u8x8 gv, u8x8 bv) : r(rv), g(gv), b(bv) {}
15 r = u8x8::from_raw(static_cast<u16>((static_cast<u32>(r.raw()) * scale) >> 8));
16 g = u8x8::from_raw(static_cast<u16>((static_cast<u32>(g.raw()) * scale) >> 8));
17 b = u8x8::from_raw(static_cast<u16>((static_cast<u32>(b.raw()) * scale) >> 8));
18 return *this;
19 }
21 r = r * scale;
22 g = g * scale;
23 b = b * scale;
24 return *this;
25 }
26 CRGB16& operator+=(const CRGB16& rhs) {
27 u32 nr = static_cast<u32>(r.raw()) + rhs.r.raw();
28 u32 ng = static_cast<u32>(g.raw()) + rhs.g.raw();
29 u32 nb = static_cast<u32>(b.raw()) + rhs.b.raw();
30 r = u8x8::from_raw(nr > 0xFFFF ? u16(0xFFFF) : static_cast<u16>(nr));
31 g = u8x8::from_raw(ng > 0xFFFF ? u16(0xFFFF) : static_cast<u16>(ng));
32 b = u8x8::from_raw(nb > 0xFFFF ? u16(0xFFFF) : static_cast<u16>(nb));
33 return *this;
34 }
35};
36
37} // namespace fl
fl::UISlider scale("Scale", 4,.1, 4,.1)
constexpr u16 raw() const FL_NOEXCEPT
Definition u8x8.h:59
static constexpr FASTLED_FORCE_INLINE u8x8 from_raw(u16 raw) FL_NOEXCEPT
Definition u8x8.h:53
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
u8x8 b
Definition crgb16.h:11
u8x8 g
Definition crgb16.h:11
u8x8 fp
Definition crgb16.h:10
CRGB16 & nscale(u8x8 scale)
Definition crgb16.h:20
CRGB16 & nscale8(u8 scale)
Definition crgb16.h:14
CRGB16() FL_NOEXCEPT=default
CRGB16 & operator+=(const CRGB16 &rhs)
Definition crgb16.h:26
u8x8 r
Definition crgb16.h:11