1#ifndef SENSESP_SYSTEM_LED_BLINKER_H_
2#define SENSESP_SYSTEM_LED_BLINKER_H_
12#define PATTERN_END (-1)
28 digitalWrite(
pin_, state);
40 void blip(
int duration = 20) {
47 bool const orig_state = this->
state_;
51 duration, [
this, duration, orig_state, current_counter]() {
56 event_loop()->onDelay(duration, [
this, orig_state, new_counter]() {
73 bool const was_enabled = this->
enabled_;
127 LEDPattern(
const std::initializer_list<LEDPatternFragment>& fragments)
143 unsigned long current_fragment_duration_ms =
154 current_fragment_duration_ms =
195 std::list<LEDPattern>::iterator it =
modifiers_.begin();
225 uint32_t fade_duration_ms,
226 const CRGB& target_color);
228 bool reverse =
false);
230 bool reverse =
false);
A base class for LED blinker classes.
void set_state(bool state)
void set_enabled(bool state)
void blip(int duration=20)
Blink the LED with a pattern specified by a vector of callback functions.
std::function< void()> show_func_
void add_modifier(const LEDPattern &modifier)
void set_pattern(const LEDPattern &pattern)
std::list< LEDPattern > modifiers_
LEDBlinker(CRGB &crgb, LEDPattern pattern, std::function< void()> show_func)
LEDPatternFragment(const LEDPatternFragment &other)
LEDPatternFragment & operator=(const LEDPatternFragment &other)
FragmentCallback callback_
LEDPatternFragment(uint32_t duration_ms, FragmentCallback callback)
LEDPattern(const std::vector< LEDPatternFragment > &fragments)
unsigned long fragment_begin_ms_
bool apply(CRGB &crgb, bool oneshot=false)
uint32_t current_fragment_idx_
std::vector< LEDPatternFragment > fragments_
LEDPattern(const std::initializer_list< LEDPatternFragment > &fragments)
LEDPattern & operator=(const LEDPattern &other)
std::shared_ptr< reactesp::EventLoop > event_loop()
std::function< void(uint32_t, CRGB &)> FragmentCallback
LEDPatternFragment frag_linear_fade(uint32_t duration_ms, uint32_t fade_duration_ms, const CRGB &target_color)
LEDPatternFragment frag_nop(uint32_t duration_ms)
LEDPatternFragment frag_blend(uint32_t duration_ms, const CRGB &target_color, bool reverse)
LEDPatternFragment frag_linear_invert(uint32_t duration_ms, bool reverse)
LEDPatternFragment frag_solid_color(uint32_t duration_ms, const CRGB &color)
Minimal RGB color struct.