Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
DotBarDisplayLEDs.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
6
8
12enum class DotBarMode : bool {
13 Bar = false,
14 Dot = true,
15};
16
25template <uint16_t N>
26class DotBarDisplayLEDs : public LEDs<N> {
27 public:
29 DotBarDisplayLEDs(const PinList<N> &ledPins) : LEDs<N>{ledPins} {}
30
37 void display(uint16_t value) const {
38 if (value == 0)
39 this->clear();
40 else if (mode == DotBarMode::Bar)
41 this->displayRange(0, value);
42 else
43 this->displayDot(value - 1);
44 }
45
52 void display(float value) const { display(uint16_t(value * (N + 1))); }
53
55 DotBarMode getMode() const { return mode; }
56
63 void setMode(DotBarMode mode) { this->mode = mode; }
64
66 void dotMode() { setMode(DotBarMode::Dot); }
67
69 void barMode() { setMode(DotBarMode::Bar); }
70
72 void toggleMode() { getMode() == DotBarMode::Bar ? dotMode() : barMode(); }
73
74 private:
75 DotBarMode mode = DotBarMode::Bar;
76};
77
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
A class for LED bars.
void display(float value) const
Display the given fraction of the LED bar.
void toggleMode()
Toggle the dot/bar mode.
void setMode(DotBarMode mode)
Set the mode to either dot or bar mode.
void display(uint16_t value) const
Display the given number of LEDs on the LED bar.
DotBarMode getMode() const
Get the dot/bar mode.
DotBarDisplayLEDs(const PinList< N > &ledPins)
Constructor from list of pins.
void dotMode()
Set the mode to dot mode.
void barMode()
Set the mode to bar mode.
A class for collections of LEDs that can display ranges.
Definition LEDs.hpp:18
DotBarMode
An enumeration type to set an LED display to either bar or dot mode.
@ Dot
Turn on only the active LED.
@ Bar
Turn on a range of LEDs up to the active LED.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32