93 static inline bool rgb_is_neopixels (
rgb_ptr_t *device)
95 return device->
out != NULL && device->
cap.
R > 126 && device->
cap.
G > 126 && device->
cap.
B > 126;
98 static inline bool rgb_is_onoff (
rgb_ptr_t *device)
100 return device->
out != NULL && device->
cap.
R == 1 && device->
cap.
G == 1 && device->
cap.
B == 1;
107 color.
R = (uint8_t)(((color.
R + 1) * intensity) >> 8);
108 color.
G = (uint8_t)(((color.
G + 1) * intensity) >> 8);
109 color.
B = (uint8_t)(((color.
B + 1) * intensity) >> 8);
116 color.
R = (uint8_t)((color.
R << 8) / (intensity + 1));
117 color.
G = (uint8_t)((color.
G << 8) / (intensity + 1));
118 color.
B = (uint8_t)((color.
B << 8) / (intensity + 1));
127 uint32_t R = 0, G = 0, B = 0;
128 uint8_t bitmask = 0b10000000;
130 color = rgb_set_intensity(color, intensity);
134 R |= color.
R & bitmask ? 0b011 : 0b010;
136 G |= color.
G & bitmask ? 0b011 : 0b010;
138 B |= color.
B & bitmask ? 0b011 : 0b010;
139 }
while(bitmask >>= 1);
142 *led++ = (uint8_t)(G >> 16);
143 *led++ = (uint8_t)(G >> 8);
149 *led++ = (uint8_t)(R >> 16);
150 *led++ = (uint8_t)(R >> 8);
156 *led++ = (uint8_t)(B >> 16);
157 *led++ = (uint8_t)(B >> 8);
162 static inline rgb_color_t rgb_3bpp_unpack (uint8_t *led, uint8_t intensity)
168 uint32_t R = 0, G = 0, B = 0;
169 uint8_t bitmask = 0b00000001;
182 if((R & 0b011) == 0b011)
185 if((G & 0b011) == 0b011)
188 if((B & 0b011) == 0b011)
191 }
while(bitmask <<= 1);
193 color = rgb_reset_intensity(color, intensity);
219 color = rgb_set_intensity(color, intensity);
220 rgb_1bpp_assign(led, color, mask);
223 static inline rgb_color_t rgb_1bpp_unpack (uint8_t *led, uint8_t intensity)
233 color = rgb_reset_intensity(color, intensity);
uint8_t(* rgb_set_intensity_ptr)(uint8_t intensity)
Pointer to function for setting RGB (LED) intensity.
Definition: rgb.h:68
void(* rgb_write_ptr)(void)
Pointer to function for outputting RGB (LED) data to Neopixel strip.
Definition: rgb.h:72
void(* rgb_set_color_masked_ptr)(uint16_t device, rgb_color_t color, rgb_color_mask_t mask)
Pointer to function for setting RGB (LED) output, with mask for which LEDs to change.
Definition: rgb.h:62
void(* rgb_set_color_ptr)(uint16_t device, rgb_color_t color)
Pointer to function for setting RGB (LED) output.
Definition: rgb.h:56
uint8_t intensity
Definition: rgb.h:90
uint16_t num_bytes
Definition: rgb.h:88
uint8_t * leds
Definition: rgb.h:89
uint16_t num_leds
Definition: rgb.h:87
rgb_write_ptr write
Optional handler for outputting data to Neopixel strip.
Definition: rgb.h:77
rgb_set_intensity_ptr set_intensity
Optional handler for setting intensity, range 0 - 255.
Definition: rgb.h:78
rgb_set_color_ptr out
Optional handler for setting device (LED) color.
Definition: rgb.h:75
rgb_set_color_masked_ptr out_masked
Optional handler for setting device (LED) color, with mask for which LEDs to change.
Definition: rgb.h:76
rgb_properties_t flags
Driver property flags.
Definition: rgb.h:80
rgb_color_t cap
Driver capability, color value: 0 - not available, 1 - on off, > 1 - intensity range 0 - n.
Definition: rgb.h:79
uint16_t num_devices
Number of devices (LEDs) available.
Definition: rgb.h:81
uint8_t W
Definition: rgb.h:29
uint8_t value
Definition: rgb.h:23
uint8_t B
Definition: rgb.h:26
uint8_t mask
Definition: rgb.h:24
uint8_t G
Definition: rgb.h:27
uint8_t R
Definition: rgb.h:28
uint8_t unused
Definition: rgb.h:30
uint8_t W
White.
Definition: rgb.h:40
uint8_t B
Blue.
Definition: rgb.h:37
uint8_t G
Green.
Definition: rgb.h:38
uint8_t R
Red.
Definition: rgb.h:39
uint32_t value
Definition: rgb.h:35
uint8_t is_strip
Definition: rgb.h:48
uint8_t unassigned
Definition: rgb.h:49
uint8_t mask
Definition: rgb.h:45
uint8_t is_blocking
Definition: rgb.h:47