FastLED 3.10.10
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)
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// Both strips use the board's default clocked-chipset pin pairs
14// (platforms/default_pins.h). Literals are guesses about hardware this sketch
15// cannot see: the Adafruit Feather nRF52840 boards exclude D1 (UART RX), and
16// Feather M4 has no pins 2 or 3. A sketch or build flag defining these first
17// still wins.
18#ifndef STRIP_0_DATA_PIN
19#define STRIP_0_DATA_PIN FL_PIN_SPI_DATA_1
20#endif
21#ifndef STRIP_0_CLOCK_PIN
22#define STRIP_0_CLOCK_PIN FL_PIN_SPI_CLOCK_1
23#endif
24#ifndef STRIP_1_DATA_PIN
25#define STRIP_1_DATA_PIN FL_PIN_SPI_DATA_2
26#endif
27#ifndef STRIP_1_CLOCK_PIN
28#define STRIP_1_CLOCK_PIN FL_PIN_SPI_CLOCK_2
29#endif
30
31
32CRGB leds_hd[NUM_LEDS] = {0}; // HD mode implies gamma.
33CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
34
35// This is the regular gamma correction function that we used to have
36// to do. It's used here to showcase the difference between HD107HD
37// mode which does the gamma correction for you.
39 CRGB out;
40 // dim8_raw are the old gamma correction functions.
41 out.r = dim8_raw(in.r);
42 out.g = dim8_raw(in.g);
43 out.b = dim8_raw(in.b);
44 return out;
45}
46
47void setup() {
48 delay(500); // power-up safety delay
49 // Two strips of LEDs, one in HD mode, one in software gamma mode.
52}
53
54uint8_t wrap_8bit(int i) {
55 // Module % operator here wraps a large "i" so that it is
56 // always in [0, 255] range when returned. For example, if
57 // "i" is 256, then this will return 0. If "i" is 257
58 // then this will return 1. No matter how big the "i" is, the
59 // output range will always be [0, 255]
60 return i % 256;
61}
62
63void loop() {
64 // Draw a a linear ramp of brightnesses to showcase the difference between
65 // the HD and non-HD mode.
66 for (int i = 0; i < NUM_LEDS; i++) {
67 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
68 CRGB c(brightness, brightness, brightness); // Just make a shade of white.
69 leds_hd[i] = c; // The HD107HD leds do their own gamma correction.
70 CRGB c_gamma_corrected = software_gamma(c);
71 leds[i] = c_gamma_corrected; // Set the software gamma corrected
72 // values to the other strip.
73 }
74 FastLED.show(); // All leds are now written out.
75 delay(8); // Wait 8 milliseconds until the next frame.
76}
CRGB leds[1]
#define NUM_LEDS
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define STRIP_0_DATA_PIN
Definition Apa102HD.ino:46
#define STRIP_1_CLOCK_PIN
Definition Apa102HD.ino:55
#define STRIP_0_CLOCK_PIN
Definition Apa102HD.ino:49
#define STRIP_1_DATA_PIN
Definition Apa102HD.ino:52
CRGB leds_hd[NUM_LEDS]
Definition Apa102HD.ino:59
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ HD107S
Marketed HD107S part name; alias of HD107.
Definition FastLED.h:308
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
Definition FastLED.h:309
CRGB software_gamma(const CRGB &in)
Definition HD107.ino:38
void setup()
Definition HD107.ino:47
uint8_t wrap_8bit(int i)
Definition HD107.ino:54
void loop()
Definition HD107.ino:63
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.