FastLED 3.7.8
Loading...
Searching...
No Matches
Apa102HDOverride.ino
1
3
4#define FASTLED_FIVE_BIT_HD_BITSHIFT_FUNCTION_OVERRIDE
5
6#include <Arduino.h>
7#include <FastLED.h>
8#include <lib8tion.h>
9
10#define NUM_LEDS 20
11// uint8_t DATA_PIN, uint8_t CLOCK_PIN,
12
13#define STRIP_0_DATA_PIN 1
14#define STRIP_0_CLOCK_PIN 2
15#define STRIP_1_DATA_PIN 3
16#define STRIP_1_CLOCK_PIN 4
17
18void five_bit_hd_gamma_bitshift(uint8_t r8, uint8_t g8, uint8_t b8,
19 uint8_t r8_scale, uint8_t g8_scale,
20 uint8_t b8_scale, uint8_t *out_r8,
21 uint8_t *out_g8, uint8_t *out_b8,
22 uint8_t *out_power_5bit) {
23 // all 0 values for output
24 *out_r8 = 0;
25 *out_g8 = 0;
26 *out_b8 = 0;
27 *out_power_5bit = 0;
28 Serial.println("Override function called");
29}
30
31CRGB leds_hd[NUM_LEDS] = {0}; // HD mode implies gamma.
32
33
34void setup() {
35 delay(500); // power-up safety delay
36 // Two strips of LEDs, one in HD mode, one in software gamma mode.
37 FastLED.addLeds<APA102HD, STRIP_0_DATA_PIN, STRIP_0_CLOCK_PIN, RGB>(
38 leds_hd, NUM_LEDS);
39}
40
41void loop() {
42 // Draw a a linear ramp of brightnesses to showcase the difference between
43 // the HD and non-HD mode.
44 for (int i = 0; i < NUM_LEDS; i++) {
45 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
46 CRGB c(brightness, brightness,
47 brightness); // Just make a shade of white.
48 leds_hd[i] = c; // The APA102HD leds do their own gamma correction.
49 }
50 FastLED.show(); // All leds are now written out.
51 delay(8); // Wait 8 milliseconds until the next frame.
52}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:21
central include file for FastLED, defines the CFastLED class/object
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:102
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:59
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:47
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:25