FastLED 3.10.6
Loading...
Searching...
No Matches
analog.h
Go to the documentation of this file.
1#pragma once
2
5
7#include "fl/stl/noexcept.h"
8#include "fl/system/pin.h"
9
10namespace fl {
11
17template <u8 RED_PIN, u8 GREEN_PIN, u8 BLUE_PIN>
19 public:
20 static constexpr u32 PWM_FREQUENCY_HZ = 500;
21
22 void init() FL_NO_EXCEPT override {
24 fl::pinMode(GREEN_PIN, PinMode::Output);
29 writeRgb(0, 0, 0);
30 }
31
32 protected:
34 if (!pixels.has(1)) {
35 writeRgb(0, 0, 0);
36 return;
37 }
38
39 writeRgb(pixels.loadAndScale0(), pixels.loadAndScale1(),
40 pixels.loadAndScale2());
41 }
42
43 virtual void writeRgb(u8 red, u8 green, u8 blue) FL_NO_EXCEPT {
44 fl::analogWrite(RED_PIN, red);
45 fl::analogWrite(GREEN_PIN, green);
46 fl::analogWrite(BLUE_PIN, blue);
47 }
48};
49
50} // namespace fl
51
54template <fl::u8 RED_PIN, fl::u8 GREEN_PIN, fl::u8 BLUE_PIN>
56 : public fl::AnalogRGBController<RED_PIN, GREEN_PIN, BLUE_PIN> {};
FastLED chipset-style wrapper for three-pin PWM RGB output.
Definition analog.h:56
CPixelLEDController(RegistrationMode mode)
void init() FL_NO_EXCEPT override
Initialize the LED controller.
Definition analog.h:22
void showPixels(PixelController< RGB > &pixels) FL_NO_EXCEPT override
Definition analog.h:33
static constexpr u32 PWM_FREQUENCY_HZ
Definition analog.h:20
virtual void writeRgb(u8 red, u8 green, u8 blue) FL_NO_EXCEPT
Definition analog.h:43
Drives one non-addressable RGB LED or strip from three PWM pins.
Definition analog.h:18
defines the templated version of the CLEDController class
unsigned char u8
Definition stdint.h:131
int setPwmFrequency(int pin, u32 frequency_hz)
Set PWM frequency for a pin.
Definition pin.cpp.hpp:274
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
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
Base definition for an LED controller.
Definition crgb.hpp:179
Pixel controller class.