FastLED 3.9.15
Loading...
Searching...
No Matches
Apa102.ino
Go to the documentation of this file.
1// @filter: (board is not stm32f103cb)
2
3#include <Arduino.h>
4#include <FastLED.h>
5#include <lib8tion.h>
6
7#define NUM_LEDS 20
8
9#define STRIP_DATA_PIN 1
10#define STRIP_CLOCK_PIN 2
11
12CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
13
14void setup() {
15 delay(500); // power-up safety delay
16 // Two strips of LEDs, one in HD mode, one in software gamma mode.
18}
19
20uint8_t wrap_8bit(int i) {
21 // Modulo % operator here wraps a large "i" so that it is
22 // always in [0, 255] range when returned. For example, if
23 // "i" is 256, then this will return 0. If "i" is 257,
24 // then this will return 1. No matter how big the "i" is, the
25 // output range will always be [0, 255]
26 return i % 256;
27}
28
29void loop() {
30 // Draw a linear ramp of brightnesses to showcase the difference between
31 // the HD and non-HD mode.
32 for (int i = 0; i < NUM_LEDS; i++) {
33 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
34 CRGB c(brightness, brightness, brightness); // Just make a shade of white.
35 leds[i] = c;
36 }
37 FastLED.show(); // All LEDs are now displayed.
38 delay(8); // Wait 8 milliseconds until the next frame.
39}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
void setup()
Definition Apa102.ino:14
#define STRIP_DATA_PIN
Definition Apa102.ino:9
#define STRIP_CLOCK_PIN
Definition Apa102.ino:10
uint8_t wrap_8bit(int i)
Definition Apa102.ino:20
void loop()
Definition Apa102.ino:29
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ APA102
APA102 LED chipset.
Definition FastLED.h:262
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.