FastLED 3.9.15
Loading...
Searching...
No Matches
HD107.ino
Go to the documentation of this file.
1
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
18
19CRGB leds_hd[NUM_LEDS] = {0}; // HD mode implies gamma.
20CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
21
22// This is the regular gamma correction function that we used to have
23// to do. It's used here to showcase the difference between HD107HD
24// mode which does the gamma correction for you.
26 CRGB out;
27 // dim8_raw are the old gamma correction functions.
28 out.r = dim8_raw(in.r);
29 out.g = dim8_raw(in.g);
30 out.b = dim8_raw(in.b);
31 return out;
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.
39}
40
41uint8_t wrap_8bit(int i) {
42 // Module % operator here wraps a large "i" so that it is
43 // always in [0, 255] range when returned. For example, if
44 // "i" is 256, then this will return 0. If "i" is 257
45 // then this will return 1. No matter how big the "i" is, the
46 // output range will always be [0, 255]
47 return i % 256;
48}
49
50void loop() {
51 // Draw a a linear ramp of brightnesses to showcase the difference between
52 // the HD and non-HD mode.
53 for (int i = 0; i < NUM_LEDS; i++) {
54 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
55 CRGB c(brightness, brightness, brightness); // Just make a shade of white.
56 leds_hd[i] = c; // The HD107HD leds do their own gamma correction.
57 CRGB c_gamma_corrected = software_gamma(c);
58 leds[i] = c_gamma_corrected; // Set the software gamma corrected
59 // values to the other strip.
60 }
61 FastLED.show(); // All leds are now written out.
62 delay(8); // Wait 8 milliseconds until the next frame.
63}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
#define STRIP_0_DATA_PIN
Definition Apa102HD.ino:38
#define STRIP_1_CLOCK_PIN
Definition Apa102HD.ino:41
#define STRIP_0_CLOCK_PIN
Definition Apa102HD.ino:39
#define STRIP_1_DATA_PIN
Definition Apa102HD.ino:40
CRGB leds_hd[NUM_LEDS]
Definition Apa102HD.ino:44
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:58
@ HD107
Definition FastLED.h:107
@ HD107HD
Same as APA102, but in turbo 40-mhz mode.
Definition FastLED.h:108
central include file for FastLED, defines the CFastLED class/object
UISlider brightness("Brightness", 255, 0, 255, 1)
CRGB software_gamma(const CRGB &in)
Definition HD107.ino:25
void setup()
Definition HD107.ino:34
uint8_t wrap_8bit(int i)
Definition HD107.ino:41
void loop()
Definition HD107.ino:50
@ RGB
Red, Green, Blue (0012)
Definition eorder.h:15
LIB8STATIC uint8_t dim8_raw(uint8_t x)
Adjust a scaling value for dimming.
Definition scale8.h:703
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54