FastLED 3.10.10
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// The board declares its default clocked-chipset pins; a literal 1/2 is not
17// routable everywhere (the Adafruit Feather nRF52840 Sense marks D1 invalid).
18#ifndef PIN_DATA
19#define PIN_DATA FL_PIN_SPI_DATA_1
20#endif
21
22#ifndef PIN_CLOCK
23#define PIN_CLOCK FL_PIN_SPI_CLOCK_1
24#endif
25
27
28UISlider hueSlider("Hue", 128, 0, 255, 1);
29UISlider saturationSlider("Saturation", 255, 0, 255, 1);
30UISlider valueSlider("Value", 255, 0, 255, 1);
31UICheckbox autoHue("Auto Hue", true);
32
33// Group related HSV control UI elements using UIGroup template multi-argument constructor
35
36void setup() {
37 //FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
38 // fl::ScreenMap screenMap(NUM_LEDS);
39
41 .setCorrection(TypicalLEDStrip);
42}
43
44void loop() {
45
46 uint8_t hue = hueSlider.value();
47 uint8_t saturation = saturationSlider.value();
48 uint8_t value = valueSlider.value();
49
50 if (autoHue.value()) {
51 uint32_t now = millis();
52 uint32_t hue_offset = (now / 100) % 256;
53 hue = hue_offset;
54 hueSlider.setValue(hue);
55 }
56
57 CHSV hsv(hue, saturation, value);
58
59 leds[0] = hsv2rgb_spectrum(hsv);
60 leds[2] = hsv2rgb_rainbow(hsv);
61 leds[4] = hsv2rgb_fullspectrum(hsv);
62
63 FastLED.show();
64}
CRGB leds[1]
#define NUM_LEDS
#define PIN_DATA
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:306
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:36
UICheckbox autoHue("Auto Hue", true)
UISlider hueSlider("Hue", 128, 0, 255, 1)
void loop()
Definition HSVTest.h:44
uint8_t hue
Definition advanced.h:94
#define PIN_CLOCK
Definition curr.h:51
constexpr EOrder BGR
Definition eorder.h:22
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
fl::hsv8 CHSV
Definition chsv.h:11
void hsv2rgb_fullspectrum(const CHSV &hsv, CRGB &rgb) FL_NO_EXCEPT
Converts an HSV value to RGB using the algorithm from here: https://en.wikipedia.org/wiki/HSL_and_HSV...
fl::CRGB CRGB
Definition crgb.h:25
CRGB hsv2rgb_rainbow(const CHSV &hsv) FL_NO_EXCEPT
CRGB hsv2rgb_spectrum(const CHSV &hsv) FL_NO_EXCEPT
Inline version of hsv2rgb_spectrum which returns a CRGB object.