Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
AH
Hardware
LEDs
DotBarDisplayLEDs.hpp
Go to the documentation of this file.
1
/* ✔ */
2
3
#pragma once
4
5
#include <
AH/Hardware/LEDs/LEDs.hpp
>
6
7
BEGIN_AH_NAMESPACE
8
12
enum class
DotBarMode
:
bool
{
13
Bar
=
false
,
14
Dot
=
true
,
15
};
16
25
template
<u
int
16_t N>
26
class
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
78
END_AH_NAMESPACE
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:14
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:11
LEDs.hpp
::DotBarDisplayLEDs
A class for LED bars.
Definition
DotBarDisplayLEDs.hpp:26
AH::DotBarDisplayLEDs::display
void display(float value) const
Display the given fraction of the LED bar.
Definition
DotBarDisplayLEDs.hpp:52
AH::DotBarDisplayLEDs::toggleMode
void toggleMode()
Toggle the dot/bar mode.
Definition
DotBarDisplayLEDs.hpp:72
AH::DotBarDisplayLEDs::mode
DotBarMode mode
Definition
DotBarDisplayLEDs.hpp:75
AH::DotBarDisplayLEDs::setMode
void setMode(DotBarMode mode)
Set the mode to either dot or bar mode.
Definition
DotBarDisplayLEDs.hpp:63
AH::DotBarDisplayLEDs::display
void display(uint16_t value) const
Display the given number of LEDs on the LED bar.
Definition
DotBarDisplayLEDs.hpp:37
AH::DotBarDisplayLEDs::getMode
DotBarMode getMode() const
Get the dot/bar mode.
Definition
DotBarDisplayLEDs.hpp:55
AH::DotBarDisplayLEDs::DotBarDisplayLEDs
DotBarDisplayLEDs(const PinList< N > &ledPins)
Constructor from list of pins.
Definition
DotBarDisplayLEDs.hpp:29
AH::DotBarDisplayLEDs::dotMode
void dotMode()
Set the mode to dot mode.
Definition
DotBarDisplayLEDs.hpp:66
AH::DotBarDisplayLEDs::barMode
void barMode()
Set the mode to bar mode.
Definition
DotBarDisplayLEDs.hpp:69
AH::LEDs::ledPins
const PinList< N > ledPins
Definition
LEDs.hpp:83
AH::LEDs::LEDs
LEDs(const PinList< N > &ledPins)
Create a LEDs object.
Definition
LEDs.hpp:26
AH::LEDs::clear
void clear() const
Turn off all LEDs.
Definition
LEDs.hpp:77
AH::LEDs::displayDot
void displayDot(uint16_t led) const
Turn on a single LED, and turn off all others.
Definition
LEDs.hpp:72
AH::LEDs::displayRange
void displayRange(uint16_t startOn, uint16_t startOff) const
Turn on a range of the LEDs.
Definition
LEDs.hpp:45
AH::PinList
Array< pin_t, N > PinList
An easy alias for arrays of pins.
Definition
Hardware-Types.hpp:100
AH::DotBarMode
DotBarMode
An enumeration type to set an LED display to either bar or dot mode.
Definition
DotBarDisplayLEDs.hpp:12
AH::DotBarMode::Dot
@ Dot
Turn on only the active LED.
Definition
DotBarDisplayLEDs.hpp:14
AH::DotBarMode::Bar
@ Bar
Turn on a range of LEDs up to the active LED.
Definition
DotBarDisplayLEDs.hpp:13
Generated by
1.17.0