FastLED 3.10.6
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[1]
#define NUM_LEDS
#define PIN_DATA
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
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
uint8_t hue
Definition advanced.h:94
#define PIN_CLOCK
Definition curr.h:51
constexpr EOrder BGR
Definition eorder.h:22
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
Definition FastLED.h:309
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
CRGB hsv2rgb_spectrum(const CHSV &hsv)
Inline version of hsv2rgb_spectrum which returns a CRGB object.
fl::hsv8 CHSV
Definition chsv.h:11
fl::CRGB CRGB
Definition crgb.h:25
CRGB hsv2rgb_rainbow(const CHSV &hsv)
void hsv2rgb_fullspectrum(const CHSV &hsv, CRGB &rgb)
Converts an HSV value to RGB using the algorithm from here: https://en.wikipedia.org/wiki/HSL_and_HSV...
unsigned char uint8_t
Definition stdint.h:208
fl::u32 uint32_t
Definition stdint.h:218