Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
NoteCCKPLED.hpp
Go to the documentation of this file.
1#pragma once
2
5
7
8// -------------------------------------------------------------------------- //
9
19template <MIDIMessageType Type>
20class NoteCCKPLED : public MatchingMIDIInputElement<Type, TwoByteMIDIMatcher> {
21 public:
24
30 : Parent(address), ledPin(ledPin) {}
31
32 private:
33 void handleUpdate(typename Matcher::Result match) override {
34 PinStatus_t state = match.value >= threshold ? HIGH : LOW;
36 }
37
38 public:
44
46 void reset() override { AH::ExtIO::digitalWrite(ledPin, LOW); }
47
49 uint8_t getThreshold() const { return threshold; }
51 void setThreshold(uint8_t threshold) { this->threshold = threshold; }
52
53 private:
55 uint8_t threshold = 0x01;
56};
57
62
67
72
73using NoteValueLED [[deprecated("Use NoteLED instead")]] = NoteLED;
74using CCValueLED [[deprecated("Use CCLED instead")]] = CCLED;
75
76// -------------------------------------------------------------------------- //
77
78namespace Bankable {
79
91template <MIDIMessageType Type, uint8_t BankSize>
92class NoteCCKPLED : public NoteCCKPValue<Type, BankSize> {
93 public:
95 using Matcher = typename Parent::Matcher;
96
104 : Parent(config, address), ledPin(ledPin) {}
105
106 protected:
107 void handleUpdate(typename Matcher::Result match) override {
108 bool newdirty = Parent::handleUpdateImpl(match);
109 if (newdirty)
110 display();
111 this->dirty |= newdirty;
112 }
113
114 void display() {
115 PinStatus_t state = getValue() >= threshold ? HIGH : LOW;
117 }
118
119 public:
125
127 void reset() override {
130 }
131
132 using Parent::getValue;
133
135 uint8_t getThreshold() const { return threshold; }
137 void setThreshold(uint8_t threshold) { this->threshold = threshold; }
138
139 protected:
140 void onBankSettingChange() override {
142 display();
143 }
144
145 private:
147 uint8_t threshold = 0x01;
148};
149
154template <uint8_t BankSize>
156
161template <uint8_t BankSize>
163
168template <uint8_t BankSize>
170
171template <uint8_t BankSize>
172using NoteValueLED [[deprecated("Use NoteLED instead")]] = NoteLED<BankSize>;
173template <uint8_t BankSize>
174using CCValueLED [[deprecated("Use CCLED instead")]] = CCLED<BankSize>;
175
176} // namespace Bankable
177
constexpr PinStatus_t LOW
AH::function_traits< decltype(::digitalWrite)>::argument_t< 1 > PinStatus_t
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Generic base class for classes that listen for MIDI Note, Control Change and Key Pressure events on a...
void setThreshold(uint8_t threshold)
Set the LED threshold. LED will be on if getValue() >= getThreshold().
void onBankSettingChange() override
A function to be executed each time the bank setting changes.
void begin() override
Set the pinmode of the LED to OUTPUT.
uint8_t getValue() const override
Get the most recent MIDI value that was received for the active bank.
void handleUpdate(typename Matcher::Result match) override
typename Parent::Matcher Matcher
NoteCCKPLED(BankConfig< BankSize > config, pin_t ledPin, MIDIAddress address)
uint8_t getThreshold() const
Get the LED threshold.
void reset() override
Reset all values to zero and turn off the LED.
Generic base class for classes that listen for MIDI Note, Control Change and Key Pressure events on a...
void onBankSettingChange() override
A function to be executed each time the bank setting changes.
bool handleUpdateImpl(typename Matcher::Result match)
BankableTwoByteMIDIMatcher< BankSize > Matcher
uint8_t getValue() const override
Get the most recent MIDI value that was received for the active bank.
void reset() override
Reset all values to zero.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
The MIDIInputElement base class is very general: you give it a MIDI message, and it calls the updateW...
Generic base class for classes that listen for MIDI Note, Control Change and Key Pressure events on a...
NoteCCKPLED(pin_t ledPin, MIDIAddress address)
void setThreshold(uint8_t threshold)
Set the LED threshold. LED will be on if getValue() >= getThreshold().
void begin() override
Set the pinmode of the LED to OUTPUT.
uint8_t threshold
void handleUpdate(typename Matcher::Result match) override
uint8_t getThreshold() const
Get the LED threshold.
void reset() override
Turn off the LED.
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.
NoteCCKPLED< MIDIMessageType::ControlChange > CCLED
Class that listens for MIDI Control Change events on a single address and turns on an LED when the va...
NoteCCKPLED< MIDIMessageType::NoteOn > NoteLED
Class that listens for MIDI Note events on a single address and turns on an LED when the value is hig...
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Type for storing pin numbers of Extended Input/Output elements.
Matcher for MIDI messages with 2 data bytes, such as Note On/Off, Control Change, Key Pressure (but n...