1#ifndef SENSESP_SYSTEM_LED_BLINKER_H_
2#define SENSESP_SYSTEM_LED_BLINKER_H_
12#define max(a, b) ((a) > (b) ? (a) : (b))
13#define PATTERN_END (-1)
29 digitalWrite(
pin_, state);
41 void blip(
int duration = 20) {
43 static bool blipping =
false;
51 bool const orig_state = this->
state_;
55 duration, [
this, duration, orig_state, current_counter]() {
60 event_loop()->onDelay(duration, [
this, orig_state, new_counter]() {
77 bool const was_enabled = this->
enabled_;
130 LEDPattern(
const std::initializer_list<LEDPatternFragment>& fragments)
141 bool apply(CRGB& crgb,
bool oneshot =
false) {
146 unsigned long current_fragment_duration_ms =
157 current_fragment_duration_ms =
198 std::list<LEDPattern>::iterator it =
modifiers_.begin();
228 uint32_t fade_duration_ms,
229 const CRGB& target_color);
231 bool reverse =
false);
233 bool reverse =
false);
void set_state(bool state)
void set_enabled(bool state)
void blip(int duration=20)
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()
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)
std::function< void(uint32_t, CRGB &)> FragmentCallback
LEDPatternFragment frag_linear_invert(uint32_t duration_ms, bool reverse)
LEDPatternFragment frag_solid_color(uint32_t duration_ms, const CRGB &color)