FastLED 3.9.15
Loading...
Searching...
No Matches
HD107.ino
Go to the documentation of this file.
1// @filter: (board is not stm32f103cb) // Maple Mini lacks pins 1-4 (uses libmaple numbering)
6
7#include <Arduino.h>
8#include <FastLED.h>
9#include <lib8tion.h>
10
11#define NUM_LEDS 20
12// uint8_t DATA_PIN, uint8_t CLOCK_PIN,
13
14#define STRIP_0_DATA_PIN 1
15#define STRIP_0_CLOCK_PIN 2
16#define STRIP_1_DATA_PIN 3
17#define STRIP_1_CLOCK_PIN 4
18
19
20CRGB leds_hd[NUM_LEDS] = {0}; // HD mode implies gamma.
21CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
22
23// This is the regular gamma correction function that we used to have
24// to do. It's used here to showcase the difference between HD107HD
25// mode which does the gamma correction for you.
27 CRGB out;
28 // dim8_raw are the old gamma correction functions.
29 out.r = dim8_raw(in.r);
30 out.g = dim8_raw(in.g);
31 out.b = dim8_raw(in.b);
32 return out;
33}
34
35void setup() {
36 delay(500); // power-up safety delay
37 // Two strips of LEDs, one in HD mode, one in software gamma mode.
40}
41
42uint8_t wrap_8bit(int i) {
43 // Module % operator here wraps a large "i" so that it is
44 // always in [0, 255] range when returned. For example, if
45 // "i" is 256, then this will return 0. If "i" is 257
46 // then this will return 1. No matter how big the "i" is, the
47 // output range will always be [0, 255]
48 return i % 256;
49}
50
51void loop() {
52 // Draw a a linear ramp of brightnesses to showcase the difference between
53 // the HD and non-HD mode.
54 for (int i = 0; i < NUM_LEDS; i++) {
55 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
56 CRGB c(brightness, brightness, brightness); // Just make a shade of white.
57 leds_hd[i] = c; // The HD107HD leds do their own gamma correction.
58 CRGB c_gamma_corrected = software_gamma(c);
59 leds[i] = c_gamma_corrected; // Set the software gamma corrected
60 // values to the other strip.
61 }
62 FastLED.show(); // All leds are now written out.
63 delay(8); // Wait 8 milliseconds until the next frame.
64}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define STRIP_0_DATA_PIN
Definition Apa102HD.ino:40
#define STRIP_1_CLOCK_PIN
Definition Apa102HD.ino:43
#define STRIP_0_CLOCK_PIN
Definition Apa102HD.ino:41
#define STRIP_1_DATA_PIN
Definition Apa102HD.ino:42
CRGB leds_hd[NUM_LEDS]
Definition Apa102HD.ino:46
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ HD107
Same as APA102, but in turbo 40-mhz mode.
Definition FastLED.h:268
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
Definition FastLED.h:269
CRGB software_gamma(const CRGB &in)
Definition HD107.ino:26
void setup()
Definition HD107.ino:35
uint8_t wrap_8bit(int i)
Definition HD107.ino:42
void loop()
Definition HD107.ino:51
constexpr EOrder RGB
Definition eorder.h:17
fl::CRGB CRGB
Definition crgb.h:25
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.