FastLED 3.10.8
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#if FL_PLATFORM_HAS_TINY_MEMORY
8// Leave room for the controller and stack on parts with as little as 256 B SRAM.
9#define NUM_LEDS 8
10#else
11#define NUM_LEDS 20
12#endif
13
14// Defaults come from the board (platforms/default_pins.h) rather than a
15// literal, because a literal is a guess about hardware this sketch cannot
16// see -- Adafruit Feather M4 has no pin 2 at all. A sketch or build flag
17// defining these first still wins.
18#ifndef STRIP_DATA_PIN
19#define STRIP_DATA_PIN FL_PIN_SPI_DATA_1
20#endif
21
22#ifndef STRIP_CLOCK_PIN
23#define STRIP_CLOCK_PIN FL_PIN_SPI_CLOCK_1
24#endif
25
26CRGB leds[NUM_LEDS] = {0}; // Software gamma mode.
27
28void setup() {
29 delay(500); // power-up safety delay
30 // Two strips of LEDs, one in HD mode, one in software gamma mode.
32}
33
34uint8_t wrap_8bit(int i) {
35 // Modulo % operator here wraps a large "i" so that it is
36 // always in [0, 255] range when returned. For example, if
37 // "i" is 256, then this will return 0. If "i" is 257,
38 // then this will return 1. No matter how big the "i" is, the
39 // output range will always be [0, 255]
40 return i % 256;
41}
42
43void loop() {
44 // Draw a linear ramp of brightnesses to showcase the difference between
45 // the HD and non-HD mode.
46 for (int i = 0; i < NUM_LEDS; i++) {
47 uint8_t brightness = map(i, 0, NUM_LEDS - 1, 0, 255);
48 CRGB c(brightness, brightness, brightness); // Just make a shade of white.
49 leds[i] = c;
50 }
51 FastLED.show(); // All LEDs are now displayed.
52 delay(8); // Wait 8 milliseconds until the next frame.
53}
CRGB leds[1]
#define NUM_LEDS
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
void setup()
Definition Apa102.ino:28
#define STRIP_DATA_PIN
Definition Apa102.ino:19
#define STRIP_CLOCK_PIN
Definition Apa102.ino:23
uint8_t wrap_8bit(int i)
Definition Apa102.ino:34
void loop()
Definition Apa102.ino:43
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ APA102
APA102 LED chipset.
Definition FastLED.h:304
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.