SensESP 3.0.0-beta.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
led_blinker.h
Go to the documentation of this file.
1#ifndef SENSESP_SRC_SENSESP_SYSTEM_LED_BLINKER_H_
2#define SENSESP_SRC_SENSESP_SYSTEM_LED_BLINKER_H_
3
4#include <ReactESP.h>
5
7
8namespace sensesp {
9
10#define PATTERN_END (-1)
11
16 public:
17 BaseBlinker(int pin);
18 void set_state(bool state);
19 void flip_state();
20 void blip(int duration = 20);
21 void set_enabled(bool state);
26 virtual void tick() = 0;
27
28 protected:
29 int pin_;
30 bool enabled_ = true;
31 bool state_ = false;
34};
35
40 public:
41 PeriodicBlinker(int pin, unsigned int period);
42 void set_period(unsigned int period) { this->period_ = period; }
43
44 protected:
45 unsigned int period_;
46};
47
53 public:
54 EvenBlinker(int pin, unsigned int period);
55 void tick() override final;
56};
57
63 public:
64 RatioBlinker(int pin, unsigned int period, float ratio = 0.);
65 void tick() override final;
66 void set_ratio(unsigned int ratio) { this->ratio_ = ratio; }
67
68 protected:
69 float ratio_;
70};
71
77 public:
78 PatternBlinker(int pin, int pattern[]);
79 void tick() override final;
80 void set_pattern(int pattern[]);
81 void restart();
82
83 protected:
85 unsigned int pattern_ptr_ = 0;
86};
87
88} // namespace sensesp
89
90#endif
A base class for LED blinker classes.
Definition led_blinker.h:15
void set_state(bool state)
void set_enabled(bool state)
void blip(int duration=20)
virtual void tick()=0
On/off switch for signals: input is emitted as-is if the enable flag is set in the web UI.
Definition enable.h:25
An LED blinker class that blinks the LED 50% off, 50% on, at a given period.
Definition led_blinker.h:52
EvenBlinker(int pin, unsigned int period)
void tick() override final
A blinker that blinks the LED according to a defined repeating pattern.
Definition led_blinker.h:76
PatternBlinker(int pin, int pattern[])
void set_pattern(int pattern[])
unsigned int pattern_ptr_
Definition led_blinker.h:85
void tick() override final
A base class for periodic blinkers.
Definition led_blinker.h:39
PeriodicBlinker(int pin, unsigned int period)
void set_period(unsigned int period)
Definition led_blinker.h:42
A periodic blinker that defines both the on-ratio and the period length.
Definition led_blinker.h:62
void set_ratio(unsigned int ratio)
Definition led_blinker.h:66
RatioBlinker(int pin, unsigned int period, float ratio=0.)
void tick() override final