FastLED 3.9.15
Loading...
Searching...
No Matches
HSVTest.h
Go to the documentation of this file.
1
10
11
12#include "FastLED.h"
13
14#define NUM_LEDS 5
15
16#ifndef PIN_DATA
17#define PIN_DATA 1 // Universally available pin
18#endif
19
20#ifndef PIN_CLOCK
21#define PIN_CLOCK 2 // Universally available pin
22#endif
23
25
26UISlider hueSlider("Hue", 128, 0, 255, 1);
27UISlider saturationSlider("Saturation", 255, 0, 255, 1);
28UISlider valueSlider("Value", 255, 0, 255, 1);
29UICheckbox autoHue("Auto Hue", true);
30
31// Group related HSV control UI elements using UIGroup template multi-argument constructor
33
34void setup() {
35 //FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
36 // fl::ScreenMap screenMap(NUM_LEDS);
37
39 .setCorrection(TypicalLEDStrip);
40}
41
42void loop() {
43
44 uint8_t hue = hueSlider.value();
45 uint8_t saturation = saturationSlider.value();
46 uint8_t value = valueSlider.value();
47
48 if (autoHue.value()) {
49 uint32_t now = millis();
50 uint32_t hue_offset = (now / 100) % 256;
51 hue = hue_offset;
52 hueSlider.setValue(hue);
53 }
54
55 CHSV hsv(hue, saturation, value);
56
57 leds[0] = hsv2rgb_spectrum(hsv);
58 leds[2] = hsv2rgb_rainbow(hsv);
59 leds[4] = hsv2rgb_fullspectrum(hsv);
60
61 FastLED.show();
62}
CRGB leds[NUM_LEDS]
#define NUM_LEDS
uint8_t hue
#define PIN_DATA
Definition simple.h:52
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:126
central include file for FastLED, defines the CFastLED class/object
UISlider saturationSlider("Saturation", 255, 0, 255, 1)
UISlider valueSlider("Value", 255, 0, 255, 1)
UIGroup hsvControls("HSV Controls", hueSlider, saturationSlider, valueSlider, autoHue)
void setup()
Definition HSVTest.h:34
UICheckbox autoHue("Auto Hue", true)
UISlider hueSlider("Hue", 128, 0, 255, 1)
void loop()
Definition HSVTest.h:42
#define PIN_CLOCK
Definition curr.h:52
@ BGR
Blue, Green, Red (0210)
Definition eorder.h:19
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
CRGB hsv2rgb_rainbow(const struct CHSV &hsv)
Definition hsv2rgb.cpp:261
CRGB hsv2rgb_spectrum(const struct CHSV &hsv)
Inline version of hsv2rgb_spectrum which returns a CRGB object.
Definition hsv2rgb.cpp:45
void hsv2rgb_fullspectrum(const struct CHSV &hsv, CRGB &rgb)
Definition hsv2rgb.cpp:494
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition hsv.h:15