Control Surface master
MIDI Control Surface library for Arduino
SelectorLEDs.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <Def/Def.hpp>
6
8
9template <setting_t N>
11 public:
13
15 void begin() {
16 for (pin_t pin : ledPins) {
19 }
20 }
21
23 void update() {}
24
26 void update(setting_t oldSetting, setting_t newSetting) {
29 }
30
31 private:
32 PinList<N> ledPins;
33};
34
36 public:
38
41
43 void update() {}
44
46 void update(setting_t oldSetting, setting_t newSetting) {
47 (void)oldSetting;
48 AH::ExtIO::digitalWrite(ledPin, newSetting == 0 ? LOW : HIGH);
49 }
50
51 private:
53};
54
56
57// -------------------------------------------------------------------------- //
58
60
62
69template <setting_t N>
71 : public GenericEncoderSelector<N, SelectorLEDsCallback<N>> {
72 public:
74 const EncoderSwitchPinList &pins,
75 const PinList<N> &ledPins, int8_t pulsesPerStep = 4,
78 selectable, {ledPins}, pins, pulsesPerStep, wrap,
79 } {}
80};
81
83
84// -------------------------------------------------------------------------- //
85
87
89
96template <setting_t N>
98 : public GenericIncrementDecrementSelector<N, SelectorLEDsCallback<N>> {
99 public:
102 const PinList<N> &ledPins,
106 {ledPins},
107 buttons,
108 wrap,
109 } {}
110};
111
113
114// -------------------------------------------------------------------------- //
115
117
119
126template <setting_t N>
128 : public GenericIncrementSelector<N, SelectorLEDsCallback<N>> {
129 public:
131 const PinList<N> &ledPins)
133 selectable, {ledPins}, button} {}
134};
135
137
138// -------------------------------------------------------------------------- //
139
141
143
150template <setting_t N>
152 : public GenericManyButtonsSelector<N, SelectorLEDsCallback<N>> {
153 public:
155 const PinList<N> &buttonPins,
156 const PinList<N> &ledPins)
159 {ledPins},
160 buttonPins,
161 } {}
162};
163
165
166// -------------------------------------------------------------------------- //
167
169
171
178template <setting_t N>
180 : public GenericProgramChangeSelector<N, SelectorLEDsCallback<N>> {
181 public:
183 MIDIChannelCable address,
184 const PinList<N> &ledPins)
187 {ledPins},
188 address,
189 } {}
190};
191
193
194// -------------------------------------------------------------------------- //
195
197
199
207 : public GenericSwitchSelector<SelectorSingleLEDCallback> {
208 public:
210 pin_t ledPin)
213 {ledPin},
214 button,
215 } {}
216};
217
constexpr PinStatus_t LOW
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
uint8_t setting_t
The type used for Selectors.
Definition: Def.hpp:51
Wrap
An enumeration to set the behavior of selectors that are incremented (decremented) beyond their maxim...
Definition: Selector.hpp:14
@ Wrap
When the maximum (minimum) setting is reached, wrap around to the minimum (maximum) setting.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:18
A class for buttons that increment and decrement some counter or setting.
Selector that reads from a rotary encoder. This version displays the setting using LEDs.
EncoderSelectorLEDs(Selectable< N > &selectable, const EncoderSwitchPinList &pins, const PinList< N > &ledPins, int8_t pulsesPerStep=4, Wrap wrap=Wrap::Wrap)
Selectable< N > & selectable
Definition: Selector.hpp:141
Selector with two buttons (one to increment, one to decrement). This version displays the setting usi...
IncrementDecrementSelectorLEDs(Selectable< N > &selectable, const AH::IncrementDecrementButtons &buttons, const PinList< N > &ledPins, Wrap wrap=Wrap::Wrap)
Selector with one button that increments the selection. This version displays the setting using LEDs.
IncrementSelectorLEDs(Selectable< N > &selectable, const AH::Button &button, const PinList< N > &ledPins)
A class for saving a MIDI channel and cable number.
Definition: MIDIAddress.hpp:24
Selector that reads from buttons. This version displays the setting using LEDs.
ManyButtonsSelectorLEDs(Selectable< N > &selectable, const PinList< N > &buttonPins, const PinList< N > &ledPins)
Selector that listens for MIDI Program Change events on a given MIDI Channel, and uses the program nu...
ProgramChangeSelectorLEDs(Selectable< N > &selectable, MIDIChannelCable address, const PinList< N > &ledPins)
PinList< N > ledPins
void update(setting_t oldSetting, setting_t newSetting)
Called when the setting changes.
void begin()
Initialize.
void update()
Refresh, called periodically.
SelectorLEDsCallback(const PinList< N > &ledPins)
SelectorSingleLEDCallback(pin_t ledPin)
void update(setting_t oldSetting, setting_t newSetting)
Called when the setting changes.
void begin()
Initialize.
void update()
Refresh, called periodically.
Selector that selects one of two settings, based on the state of a toggle or momentary switch....
SwitchSelectorLED(Selectable< 2 > &selectable, const AH::Button &button, pin_t ledPin)
void pinMode(pin_t pin, PinMode_t mode)
An ExtIO version of the Arduino function.
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
A struct for the pins of a rotary (quadrature) encoder with a switch.
Definition: Def.hpp:31