Control Surface  1.1.0
MIDI Control Surface library for Arduino
NoteCCRangeLEDBar.hpp
Go to the documentation of this file.
4 
6 
7 /**
8  * @brief Callback class that drives a LED dot/bar display based on a note or
9  * control change value.
10  *
11  * @tparam NumLEDs
12  * The number of LEDs the display has.
13  */
14 template <uint8_t NumLEDs>
16  public:
18  : leds(leds) {}
19 
20  void begin(const INoteCCValue &t) override {
21  leds.begin();
22  updateAll(t);
23  }
24 
25  void update(const INoteCCValue &t, uint8_t) override {
26  uint8_t value = t.getValue();
27  leds.display(value / 127.0f);
28  }
29 
30  /// @copydoc AH::DotBarDisplayLEDs::dotMode
31  void dotMode() { leds.dotMode(); }
32  /// @copydoc AH::DotBarDisplayLEDs::barMode
33  void barMode() { leds.barMode(); }
34  /// @copydoc AH::DotBarDisplayLEDs::setMode
35  void setMode(AH::DotBarMode mode) { leds.setMode(mode); }
36 
37  private:
39 };
40 
41 // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
42 
43 /**
44  * @brief Class that listens for **Note** events and displays the velocity on
45  * an **LED Bar Graph**.
46  *
47  * @tparam NumLEDs
48  * The number of LEDs the display has.
49  * @ingroup midi-input-elements-leds
50  */
51 template <uint8_t NumLEDs>
52 class NoteLEDBar : public GenericNoteCCRange<MIDIInputElementNote, 1,
53  NoteCCLEDBarCallback<NumLEDs>> {
54  public:
58  NoteCCLEDBarCallback<NumLEDs>>{
59  address,
60  {leds},
61  } {}
62 
63  /// @copydoc AH::DotBarDisplayLEDs::dotMode
64  void dotMode() { this->callback.dotMode(); }
65  /// @copydoc AH::DotBarDisplayLEDs::barMode
66  void barMode() { this->callback.barMode(); }
67  /// @copydoc AH::DotBarDisplayLEDs::setMode
68  void setMode(AH::DotBarMode mode) { this->callback.setMode(mode); }
69 };
70 
71 // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
72 
73 /**
74  * @brief Class that listens for **Control Change** events and displays the
75  * velocity on an **LED Bar Graph**.
76  *
77  * @tparam NumLEDs
78  * The number of LEDs the display has.
79  * @ingroup midi-input-elements-leds
80  */
81 template <uint8_t NumLEDs>
82 class CCLEDBar : public GenericNoteCCRange<MIDIInputElementCC, 1,
83  NoteCCLEDBarCallback<NumLEDs>> {
84  public:
88  NoteCCLEDBarCallback<NumLEDs>>{
89  address,
90  {leds},
91  } {}
92 
93  /// @copydoc AH::DotBarDisplayLEDs::dotMode
94  void dotMode() { this->callback.dotMode(); }
95  /// @copydoc AH::DotBarDisplayLEDs::barMode
96  void barMode() { this->callback.barMode(); }
97  /// @copydoc AH::DotBarDisplayLEDs::setMode
98  void setMode(AH::DotBarMode mode) { this->callback.setMode(mode); }
99 };
100 
101 // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
102 
103 namespace Bankable {
104 
105 // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
106 
107 /**
108  * @brief Class that listens for **Note** events and displays the velocity on
109  * an **LED Bar Graph**.
110  *
111  * This version can be banked.
112  *
113  * @tparam NumLEDs
114  * The number of LEDs the display has.
115  * @ingroup midi-input-elements-leds
116  */
117 template <uint8_t BankSize, uint8_t NumLEDs>
118 class NoteLEDBar : public GenericNoteCCRange<MIDIInputElementNote, 1, BankSize,
119  NoteCCLEDBarCallback<NumLEDs>> {
120  public:
122  const AH::DotBarDisplayLEDs<NumLEDs> &leds,
125  NoteCCLEDBarCallback<NumLEDs>>{
126  config,
127  address,
128  {leds},
129  } {}
130 
131  /// @copydoc AH::DotBarDisplayLEDs::dotMode
132  void dotMode() { this->callback.dotMode(); }
133  /// @copydoc AH::DotBarDisplayLEDs::barMode
134  void barMode() { this->callback.barMode(); }
135  /// @copydoc AH::DotBarDisplayLEDs::setMode
136  void setMode(AH::DotBarMode mode) { this->callback.setMode(mode); }
137 };
138 
139 // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //
140 
141 /**
142  * @brief Class that listens for **Control Change** events and displays the
143  * velocity on an **LED Bar Graph**.
144  *
145  * This version can be banked.
146  *
147  * @tparam NumLEDs
148  * The number of LEDs the display has.
149  * @ingroup midi-input-elements-leds
150  */
151 template <uint8_t BankSize, uint8_t NumLEDs>
152 class CCLEDBar : public GenericNoteCCRange<MIDIInputElementCC, 1, BankSize,
153  NoteCCLEDBarCallback<NumLEDs>> {
154  public:
156  const AH::DotBarDisplayLEDs<NumLEDs> &leds,
158  : GenericNoteCCRange<MIDIInputElementCC, 1, BankSize,
159  NoteCCLEDBarCallback<NumLEDs>>{
160  config,
161  address,
162  {leds},
163  } {}
164 
165  /// @copydoc AH::DotBarDisplayLEDs::dotMode
166  void dotMode() { this->callback.dotMode(); }
167  /// @copydoc AH::DotBarDisplayLEDs::barMode
168  void barMode() { this->callback.barMode(); }
169  /// @copydoc AH::DotBarDisplayLEDs::setMode
170  void setMode(AH::DotBarMode mode) { this->callback.setMode(mode); }
171 };
172 
173 } // namespace Bankable
174 
NoteCCLEDBarCallback
Callback class that drives a LED dot/bar display based on a note or control change value.
Definition: NoteCCRangeLEDBar.hpp:15
NoteCCLEDBarCallback::leds
AH::DotBarDisplayLEDs< NumLEDs > leds
Definition: NoteCCRangeLEDBar.hpp:38
CCLEDBar
Class that listens for Control Change events and displays the velocity on an LED Bar Graph.
Definition: NoteCCRangeLEDBar.hpp:82
MIDIInputElementNote
Class for objects that listen for incoming MIDI Note events.
Definition: MIDIInputElementNote.hpp:20
Bankable::CCLEDBar::dotMode
void dotMode()
Set the mode to dot mode.
Definition: NoteCCRangeLEDBar.hpp:166
Bankable::CCLEDBar::barMode
void barMode()
Set the mode to bar mode.
Definition: NoteCCRangeLEDBar.hpp:168
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
AH::DotBarDisplayLEDs::setMode
void setMode(DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: DotBarDisplayLEDs.hpp:63
GenericNoteCCRange
Definition: NoteCCRange.hpp:105
INoteCCValue
Definition: NoteCCRange.hpp:9
Bankable::CCLEDBar::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: NoteCCRangeLEDBar.hpp:170
AH::DotBarDisplayLEDs::barMode
void barMode()
Set the mode to bar mode.
Definition: DotBarDisplayLEDs.hpp:69
NoteCCRange< MIDIInputElementNote, RangeLen, 1, NoteCCLEDBarCallback< NumLEDs > >::callback
NoteCCLEDBarCallback< NumLEDs > callback
Definition: NoteCCRange.hpp:97
SimpleNoteCCValueCallback
Definition: NoteCCRange.hpp:29
Bankable::GenericNoteCCRange
Definition: NoteCCRange.hpp:164
ExtendedInputOutput.hpp
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
MIDIInputElementCC
Class for objects that listen for incoming MIDI Controller Change events.
Definition: MIDIInputElementCC.hpp:23
CCLEDBar::dotMode
void dotMode()
Set the mode to dot mode.
Definition: NoteCCRangeLEDBar.hpp:94
AH::LEDs::begin
void begin() const
Initialize (set LED pins as outputs).
Definition: LEDs.hpp:34
NoteLEDBar::barMode
void barMode()
Set the mode to bar mode.
Definition: NoteCCRangeLEDBar.hpp:66
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
Bankable::NoteLEDBar
Class that listens for Note events and displays the velocity on an LED Bar Graph.
Definition: NoteCCRangeLEDBar.hpp:118
Bankable::NoteLEDBar::dotMode
void dotMode()
Set the mode to dot mode.
Definition: NoteCCRangeLEDBar.hpp:132
Bankable::NoteLEDBar::barMode
void barMode()
Set the mode to bar mode.
Definition: NoteCCRangeLEDBar.hpp:134
NoteLEDBar::NoteLEDBar
NoteLEDBar(const AH::DotBarDisplayLEDs< NumLEDs > &leds, MIDICNChannelAddress address)
Definition: NoteCCRangeLEDBar.hpp:55
CCLEDBar::CCLEDBar
CCLEDBar(const AH::DotBarDisplayLEDs< NumLEDs > &leds, MIDICNChannelAddress address)
Definition: NoteCCRangeLEDBar.hpp:85
NoteCCLEDBarCallback::update
void update(const INoteCCValue &t, uint8_t) override
Definition: NoteCCRangeLEDBar.hpp:25
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
Bankable::CCLEDBar
Class that listens for Control Change events and displays the velocity on an LED Bar Graph.
Definition: NoteCCRangeLEDBar.hpp:152
NoteLEDBar::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: NoteCCRangeLEDBar.hpp:68
AH::DotBarDisplayLEDs::dotMode
void dotMode()
Set the mode to dot mode.
Definition: DotBarDisplayLEDs.hpp:66
NoteCCLEDBarCallback::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: NoteCCRangeLEDBar.hpp:35
NoteCCLEDBarCallback::barMode
void barMode()
Set the mode to bar mode.
Definition: NoteCCRangeLEDBar.hpp:33
Bankable::NoteLEDBar::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: NoteCCRangeLEDBar.hpp:136
NoteCCLEDBarCallback::begin
void begin(const INoteCCValue &t) override
Definition: NoteCCRangeLEDBar.hpp:20
DotBarDisplayLEDs.hpp
NoteLEDBar
Class that listens for Note events and displays the velocity on an LED Bar Graph.
Definition: NoteCCRangeLEDBar.hpp:52
CCLEDBar::barMode
void barMode()
Set the mode to bar mode.
Definition: NoteCCRangeLEDBar.hpp:96
BankConfig
A struct for selecting the bank of BankableMIDIInputs and the bank type.
Definition: BankConfig.hpp:39
MIDIInputElement::address
const MIDICNChannelAddress address
Definition: MIDIInputElement.hpp:80
NoteLEDBar::dotMode
void dotMode()
Set the mode to dot mode.
Definition: NoteCCRangeLEDBar.hpp:64
NoteCCLEDBarCallback::dotMode
void dotMode()
Set the mode to dot mode.
Definition: NoteCCRangeLEDBar.hpp:31
AH::DotBarDisplayLEDs::display
void display(uint8_t value) const
Display the given number of LEDs on the LED bar.
Definition: DotBarDisplayLEDs.hpp:40
INoteCCValue::getValue
virtual uint8_t getValue(uint8_t index) const =0
NoteCCLEDBarCallback::NoteCCLEDBarCallback
NoteCCLEDBarCallback(const AH::DotBarDisplayLEDs< NumLEDs > &leds)
Definition: NoteCCRangeLEDBar.hpp:17
CCLEDBar::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: NoteCCRangeLEDBar.hpp:98
AH::DotBarMode
DotBarMode
An enumeration type to set an LED display to either bar or dot mode.
Definition: DotBarDisplayLEDs.hpp:15
Bankable::NoteLEDBar::NoteLEDBar
NoteLEDBar(const BankConfig< BankSize > &config, const AH::DotBarDisplayLEDs< NumLEDs > &leds, const MIDICNChannelAddress &address)
Definition: NoteCCRangeLEDBar.hpp:121
NoteCCRange.hpp
SimpleNoteCCValueCallback::updateAll
virtual void updateAll(const INoteCCValue &noteccval)
Definition: NoteCCRange.hpp:36
AH::DotBarDisplayLEDs< NumLEDs >
Bankable::CCLEDBar::CCLEDBar
CCLEDBar(const BankConfig< BankSize > &config, const AH::DotBarDisplayLEDs< NumLEDs > &leds, const MIDICNChannelAddress &address)
Definition: NoteCCRangeLEDBar.hpp:155