This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
NoteCCRangeLEDs.hpp
Go to the documentation of this file.
3 
5 
6 template <uint8_t NumLEDs>
8  public:
10 
11  void setThreshold(uint8_t threshold) { this->threshold = threshold; }
12  uint8_t getThreshold() const { return this->threshold; }
13 
14  void begin(const INoteCCValue &t) override {
15  for (pin_t pin : ledPins)
16  ExtIO::pinMode(pin, OUTPUT);
17  updateAll(t);
18  }
19 
20  void update(const INoteCCValue &t, uint8_t index) override {
21  uint8_t value = t.getValue(index);
22  bool state = value > threshold;
23  ExtIO::digitalWrite(ledPins[index], state);
24  }
25 
26  private:
28  uint8_t threshold = 0x3F;
29 };
30 
31 template <uint8_t RangeLen>
32 class NoteRangeLEDs : public GenericNoteCCRange<MIDIInputElementNote, RangeLen,
33  NoteCCLED<RangeLen>> {
34  public:
38  NoteCCLED<RangeLen>>{
39  address,
40  {ledPins},
41  } {}
42 };
43 
45  : public GenericNoteCCRange<MIDIInputElementNote, 1, NoteCCLED<1>> {
46  public:
49  address,
50  {{ledPin}},
51  } {}
52 };
53 
54 using MIDINoteLED[[deprecated("Use NoteValueLED instead")]] = NoteValueLED;
55 
56 template <uint8_t RangeLen>
57 class CCRangeLEDs : public GenericNoteCCRange<MIDIInputElementCC, RangeLen,
58  NoteCCLED<RangeLen>> {
59  public:
61  : GenericNoteCCRange<MIDIInputElementCC, RangeLen, NoteCCLED<RangeLen>>{
62  address,
63  {ledPins},
64  } {}
65 };
66 
68  : public GenericNoteCCRange<MIDIInputElementCC, 1, NoteCCLED<1>> {
69  public:
72  address,
73  {{ledPin}},
74  } {}
75 };
76 
77 namespace Bankable {
78 
79 template <uint8_t RangeLen, uint8_t BankSize>
80 class NoteRangeLEDs : public GenericNoteCCRange<MIDIInputElementNote, RangeLen,
81  BankSize, NoteCCLED<RangeLen>> {
82  public:
84  const PinList<RangeLen> &ledPins,
86  : GenericNoteCCRange<MIDIInputElementNote, RangeLen, BankSize,
87  NoteCCLED<RangeLen>>{
88  config,
89  address,
90  {ledPins},
91  } {}
92 };
93 
94 template <uint8_t BankSize>
95 class NoteValueLED : public GenericNoteCCRange<MIDIInputElementNote, 1,
96  BankSize, NoteCCLED<1>> {
97  public:
98  NoteValueLED(const BankConfig<BankSize> &config, pin_t ledPin,
101  config,
102  address,
103  {{ledPin}},
104  } {}
105 };
106 
107 template <uint8_t BankSize>
108 using MIDINoteLED[[deprecated("Use NoteValueLED instead")]] =
110 
111 template <uint8_t RangeLen, uint8_t BankSize>
112 class CCRangeLEDs : public GenericNoteCCRange<MIDIInputElementCC, RangeLen,
113  BankSize, NoteCCLED<RangeLen>> {
114  public:
116  const PinList<RangeLen> &ledPins,
118  : GenericNoteCCRange<MIDIInputElementCC, RangeLen, BankSize,
119  NoteCCLED<RangeLen>>{
120  config,
121  address,
122  {ledPins},
123  } {}
124 };
125 
126 template <uint8_t BankSize>
128  : public GenericNoteCCRange<MIDIInputElementCC, 1, BankSize, NoteCCLED<1>> {
129  public:
130  CCValueLED(const BankConfig<BankSize> &config, pin_t ledPin,
132  : GenericNoteCCRange<MIDIInputElementCC, 1, BankSize, NoteCCLED<1>>{
133  config,
134  address,
135  {{ledPin}},
136  } {}
137 };
138 
139 } // namespace Bankable
140 
CCRangeLEDs::CCRangeLEDs
CCRangeLEDs(const PinList< RangeLen > &ledPins, MIDICNChannelAddress address)
Definition: NoteCCRangeLEDs.hpp:60
Bankable::CCValueLED
Definition: NoteCCRangeLEDs.hpp:127
MIDIInputElementNote
Class for objects that listen for incoming MIDI Note events.
Definition: MIDIInputElementNote.hpp:20
Bankable::NoteValueLED
Definition: NoteCCRangeLEDs.hpp:95
Bankable::NoteValueLED::NoteValueLED
NoteValueLED(const BankConfig< BankSize > &config, pin_t ledPin, const MIDICNChannelAddress &address)
Definition: NoteCCRangeLEDs.hpp:98
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
GenericNoteCCRange
Definition: NoteCCRange.hpp:105
INoteCCValue
Definition: NoteCCRange.hpp:9
ExtIO::pinMode
void pinMode(pin_t pin, uint8_t mode)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:34
pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Def.hpp:17
Bankable::CCValueLED::CCValueLED
CCValueLED(const BankConfig< BankSize > &config, pin_t ledPin, const MIDICNChannelAddress &address)
Definition: NoteCCRangeLEDs.hpp:130
NoteValueLED::NoteValueLED
NoteValueLED(pin_t ledPin, MIDICNChannelAddress address)
Definition: NoteCCRangeLEDs.hpp:47
SimpleNoteCCValueCallback
Definition: NoteCCRange.hpp:29
Bankable::GenericNoteCCRange
Definition: NoteCCRange.hpp:164
NoteRangeLEDs::NoteRangeLEDs
NoteRangeLEDs(const PinList< RangeLen > &ledPins, MIDICNChannelAddress address)
Definition: NoteCCRangeLEDs.hpp:35
ExtendedInputOutput.hpp
MIDIInputElementCC
Class for objects that listen for incoming MIDI Controller Change events.
Definition: MIDIInputElementCC.hpp:23
Array< pin_t, N >
Bankable::CCRangeLEDs
Definition: NoteCCRangeLEDs.hpp:112
NoteCCLED::ledPins
PinList< NumLEDs > ledPins
Definition: NoteCCRangeLEDs.hpp:27
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
ExtIO::digitalWrite
void digitalWrite(pin_t pin, uint8_t val)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:45
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
NoteCCLED::NoteCCLED
NoteCCLED(const PinList< NumLEDs > &ledPins)
Definition: NoteCCRangeLEDs.hpp:9
NoteValueLED
Definition: NoteCCRangeLEDs.hpp:44
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
Bankable::CCRangeLEDs::CCRangeLEDs
CCRangeLEDs(const BankConfig< BankSize > &config, const PinList< RangeLen > &ledPins, const MIDICNChannelAddress &address)
Definition: NoteCCRangeLEDs.hpp:115
CCValueLED::CCValueLED
CCValueLED(pin_t ledPin, MIDICNChannelAddress address)
Definition: NoteCCRangeLEDs.hpp:70
NoteCCLED
Definition: NoteCCRangeLEDs.hpp:7
NoteCCLED::update
void update(const INoteCCValue &t, uint8_t index) override
Definition: NoteCCRangeLEDs.hpp:20
NoteCCLED::setThreshold
void setThreshold(uint8_t threshold)
Definition: NoteCCRangeLEDs.hpp:11
CCRangeLEDs
Definition: NoteCCRangeLEDs.hpp:57
NoteCCLED::threshold
uint8_t threshold
Definition: NoteCCRangeLEDs.hpp:28
CCValueLED
Definition: NoteCCRangeLEDs.hpp:67
BankConfig
A struct for selecting the bank of BankableMIDIInputs and the bank type.
Definition: BankConfig.hpp:39
OUTPUT
const uint8_t OUTPUT
Definition: ExtendedInputOutput.hpp:38
NoteCCLED::begin
void begin(const INoteCCValue &t) override
Definition: NoteCCRangeLEDs.hpp:14
MIDIInputElement::address
const MIDICNChannelAddress address
Definition: MIDIInputElement.hpp:80
INoteCCValue::getValue
virtual uint8_t getValue(uint8_t index) const =0
NoteCCLED::getThreshold
uint8_t getThreshold() const
Definition: NoteCCRangeLEDs.hpp:12
Bankable::NoteRangeLEDs
Definition: NoteCCRangeLEDs.hpp:80
NoteRangeLEDs
Definition: NoteCCRangeLEDs.hpp:32
Bankable::NoteRangeLEDs::NoteRangeLEDs
NoteRangeLEDs(const BankConfig< BankSize > &config, const PinList< RangeLen > &ledPins, const MIDICNChannelAddress &address)
Definition: NoteCCRangeLEDs.hpp:83
NoteCCRange.hpp
SimpleNoteCCValueCallback::updateAll
virtual void updateAll(const INoteCCValue &noteccval)
Definition: NoteCCRange.hpp:36