SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
led_blinker.h
Go to the documentation of this file.
1#ifndef _led_blinker_H_
2#define _led_blinker_H_
3
4#include <ReactESP.h>
5
7#include "startable.h"
8
9namespace sensesp {
10
11#define PATTERN_END (-1)
12
16class BaseBlinker : public Startable {
17 public:
18 BaseBlinker(int pin);
19 void set_state(bool state);
20 void flip_state();
21 void blip(int duration = 20);
22 void set_enabled(bool state);
27 virtual void tick() = 0;
28 void start() override;
29
30 protected:
31 int pin_;
32 bool enabled_ = true;
33 bool state_ = false;
36};
37
42 public:
43 PeriodicBlinker(int pin, unsigned int period);
44 void set_period(unsigned int period) { this->period_ = period; }
45
46 protected:
47 unsigned int period_;
48};
49
55 public:
56 EvenBlinker(int pin, unsigned int period);
57 void tick() override final;
58};
59
65 public:
66 RatioBlinker(int pin, unsigned int period, float ratio = 0.);
67 void tick() override final;
68 void set_ratio(unsigned int ratio) { this->ratio_ = ratio; }
69
70 protected:
71 float ratio_;
72};
73
79 public:
80 PatternBlinker(int pin, int pattern[]);
81 void tick() override final;
82 void set_pattern(int pattern[]);
83 void restart();
84
85 protected:
87 unsigned int pattern_ptr_ = 0;
88};
89
90} // namespace sensesp
91
92#endif
A base class for LED blinker classes.
Definition led_blinker.h:16
void set_state(bool state)
void set_enabled(bool state)
void blip(int duration=20)
virtual void tick()=0
void start() override
An LED blinker class that blinks the LED 50% off, 50% on, at a given period.
Definition led_blinker.h:54
void tick() override final
Construct a new transform based on a single function.
A blinker that blinks the LED according to a defined repeating pattern.
Definition led_blinker.h:78
void set_pattern(int pattern[])
unsigned int pattern_ptr_
Definition led_blinker.h:87
void tick() override final
A base class for periodic blinkers.
Definition led_blinker.h:41
void set_period(unsigned int period)
Definition led_blinker.h:44
A periodic blinker that defines both the on-ratio and the period length.
Definition led_blinker.h:64
void set_ratio(unsigned int ratio)
Definition led_blinker.h:68
void tick() override final
Automatic calling of the start() method at startup.
Definition startable.h:20