FastLED 3.9.15
Loading...
Searching...
No Matches
el_panel.cpp
Go to the documentation of this file.
1#include "el_panel.h"
2
3#ifdef __EMSCRIPTEN__
4
5static CRGB leds[NUM_EL_LEDS];
6static fl::ScreenMap screenMap(NUM_EL_LEDS, 0.5f, [](int index, fl::vec2f &pt) {
7 // Left group (high threshold): indices 0-3
8 // Right group (low threshold): indices 4-7
9 bool isRight = index >= LEDS_PER_PANEL;
10 int local = index % LEDS_PER_PANEL;
11 float groupX = isRight ? 65.0f : 25.0f;
12 // 2x2 grid within each group
13 pt.x = groupX + (local % 2) * 10.0f;
14 pt.y = 40.0f + (local / 2) * 10.0f;
15});
16
17void initPanels() {
18 FastLED.addLeds<WS2812, 3, GRB>(leds, NUM_EL_LEDS)
19 .setScreenMap(screenMap);
20}
21
22void setPanelHigh(float brightness) {
23 uint8_t v = uint8_t(brightness * 255);
25}
26
27void setPanelLow(float brightness) {
28 uint8_t v = uint8_t(brightness * 255);
30}
31
32void showPanels() {
33 FastLED.show();
34}
35
36#else // Real hardware
37
38#include "fl/system/pin.h"
39
40#define EL_PIN_HIGH 2 // D2 — high threshold panel
41#define EL_PIN_LOW 1 // D1 — low threshold panel
42#define PWM_FREQ_HZ 50
43
52
54 fl::analogWrite(EL_PIN_HIGH, uint8_t(brightness * 255));
55}
56
58 fl::analogWrite(EL_PIN_LOW, uint8_t(brightness * 255));
59}
60
61void showPanels() {
62 // No-op — PWM is always running
63}
64
65#endif // __EMSCRIPTEN__
fl::CRGB leds[NUM_LEDS]
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:9
#define EL_PIN_HIGH
Definition el_panel.cpp:40
void setPanelHigh(float brightness)
Definition el_panel.cpp:53
void initPanels()
Definition el_panel.cpp:44
#define EL_PIN_LOW
Definition el_panel.cpp:41
#define PWM_FREQ_HZ
Definition el_panel.cpp:42
void showPanels()
Definition el_panel.cpp:61
void setPanelLow(float brightness)
Definition el_panel.cpp:57
#define NUM_EL_LEDS
Definition el_panel.h:10
#define LEDS_PER_PANEL
EL panel hardware abstraction.
Definition el_panel.h:9
constexpr EOrder GRB
Definition eorder.h:19
fl::ScreenMap screenMap
Definition Corkscrew.h:101
fl::CRGB CRGB
Definition crgb.h:25
vec2< float > vec2f
Definition geometry.h:333
int setPwmFrequency(int pin, u32 frequency_hz)
Set PWM frequency for a pin.
Definition pin.cpp.hpp:274
void pinMode(int pin, PinMode mode)
Set pin mode (input, output, pull-up, pull-down)
Definition pin.cpp.hpp:378
void analogWrite(int pin, u16 val)
Write analog value to pin (PWM)
Definition pin.cpp.hpp:227
@ Output
Digital output (push-pull)
Definition pin.h:43
unsigned char uint8_t
Definition s16x16x4.h:209
value_type y
Definition geometry.h:191
value_type x
Definition geometry.h:190