FastLED 3.9.3
Loading...
Searching...
No Matches
five_bit_hd_gamma.h
1#pragma once
2
3#include <stdint.h>
4
5#include "namespace.h"
6#include "force_inline.h"
7#include "crgb.h"
8
9FASTLED_NAMESPACE_BEGIN
10
11enum FiveBitGammaCorrectionMode {
12 kFiveBitGammaCorrectionMode_Null = 0,
13 kFiveBitGammaCorrectionMode_BitShift = 1
14};
15
16// Applies gamma correction for the RGBV(8, 8, 8, 5) color space, where
17// the last byte is the brightness byte at 5 bits.
18// To override this five_bit_hd_gamma_bitshift you'll need to define
19// FASTLED_FIVE_BIT_HD_BITSHIFT_FUNCTION_OVERRIDE in your build settings
20// then define the function anywhere in your project.
21// Example:
22// FASTLED_NAMESPACE_BEGIN
23// void five_bit_hd_gamma_bitshift(
24// uint8_t r8, uint8_t g8, uint8_t b8,
25// uint8_t r8_scale, uint8_t g8_scale, uint8_t b8_scale,
26// uint8_t* out_r8,
27// uint8_t* out_g8,
28// uint8_t* out_b8,
29// uint8_t* out_power_5bit) {
30// cout << "hello world\n";
31// }
32// FASTLED_NAMESPACE_END
33
34void __builtin_five_bit_hd_gamma_bitshift(CRGB colors,
35 CRGB colors_scale,
36 uint8_t global_brightness,
37 CRGB* out_colors,
38 uint8_t *out_power_5bit);
39
40
41// Exposed for testing.
42uint8_t five_bit_bitshift(uint16_t r16, uint16_t g16, uint16_t b16, uint8_t brightness, CRGB* out, uint8_t* out_power_5bit);
43
44#ifdef FASTLED_FIVE_BIT_HD_BITSHIFT_FUNCTION_OVERRIDE
45// This function is located somewhere else in your project, so it's declared
46// extern here.
47extern void five_bit_hd_gamma_bitshift(CRGB colors,
48 CRGB colors_scale,
49 uint8_t global_brightness,
50 CRGB* out_colors,
51 uint8_t *out_power_5bit);
52#else
53FASTLED_FORCE_INLINE void
54five_bit_hd_gamma_bitshift(CRGB colors,
55 CRGB colors_scale,
56 uint8_t global_brightness,
57 CRGB* out_colors,
58 uint8_t *out_power_5bit) {
59 __builtin_five_bit_hd_gamma_bitshift(colors,
60 colors_scale,
61 global_brightness,
62 out_colors,
63 out_power_5bit);
64}
65#endif // FASTLED_FIVE_BIT_HD_BITSHIFT_FUNCTION_OVERRIDE
66
67// Simple gamma correction function that converts from
68// 8-bit color component and converts it to gamma corrected 16-bit
69// color component. Fast and no memory overhead!
70// To override this function you'll need to define
71// FASTLED_FIVE_BIT_HD_GAMMA_BITSHIFT_FUNCTION_OVERRIDE in your build settings
72// and then define your own version anywhere in your project. Example:
73// FASTLED_NAMESPACE_BEGIN
74// void five_bit_hd_gamma_function(
75// uint8_t r8, uint8_t g8, uint8_t b8,
76// uint16_t* r16, uint16_t* g16, uint16_t* b16) {
77// cout << "hello world\n";
78// }
79// FASTLED_NAMESPACE_END
80#ifdef FASTLED_FIVE_BIT_HD_GAMMA_FUNCTION_OVERRIDE
81// This function is located somewhere else in your project, so it's declared
82// extern here.
83extern void five_bit_hd_gamma_function(CRGB color,
84 uint16_t *r16, uint16_t *g16, uint16_t *b16);
85#else
86void five_bit_hd_gamma_function(CRGB color,
87 uint16_t *r16, uint16_t *g16, uint16_t *b16);
88#endif // FASTLED_FIVE_BIT_HD_GAMMA_FUNCTION_OVERRIDE
89
90FASTLED_NAMESPACE_END
91
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39