Control Surface main
MIDI Control Surface library for Arduino
NoteCCKPLEDPWM.hpp
Go to the documentation of this file.
1#pragma once
2
6
8
9// -------------------------------------------------------------------------- //
10
20template <MIDIMessageType Type>
22 : public MatchingMIDIInputElement<Type, TwoByteMIDIMatcher> {
23 public:
26
32 : Parent(address), ledPin(ledPin) {}
33
34 private:
35 void handleUpdate(typename Matcher::Result match) override {
36 auto value = AH::increaseBitDepth<8, 7, uint8_t, uint8_t>(match.value);
38 }
39
40 public:
42 void begin() override {
45 }
46
48 void reset() override { AH::ExtIO::digitalWrite(ledPin, LOW); }
49
50 private:
52};
53
58
63
68
69// -------------------------------------------------------------------------- //
70
71namespace Bankable {
72
84template <MIDIMessageType Type, uint8_t BankSize>
85class NoteCCKPLEDPWM : public NoteCCKPValue<Type, BankSize> {
86 public:
88 using Matcher = typename Parent::Matcher;
89
99 MIDIAddress address)
100 : Parent(config, address), ledPin(ledPin) {}
101
102 protected:
103 void handleUpdate(typename Matcher::Result match) override {
104 bool newdirty = Parent::handleUpdateImpl(match);
105 if (newdirty)
106 display();
107 this->dirty |= newdirty;
108 }
109
110 void display() {
111 auto value = AH::increaseBitDepth<8, 7, uint8_t, uint8_t>(getValue());
113 }
114
115 public:
117 void begin() override {
120 }
121
123 void reset() override {
126 }
127
128 using Parent::getValue;
129
130 protected:
131 void onBankSettingChange() override {
133 display();
134 }
135
136 private:
138};
139
144template <uint8_t BankSize>
146
151template <uint8_t BankSize>
153
158template <uint8_t BankSize>
160
161} // namespace Bankable
162
constexpr PinStatus_t LOW
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...
NoteCCKPLEDPWM(BankConfig< BankSize > config, pin_t ledPin, MIDIAddress address)
Constructor.
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
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...
void begin() override
Set the pinmode of the LED to OUTPUT.
NoteCCKPLEDPWM(pin_t ledPin, MIDIAddress address)
void handleUpdate(typename Matcher::Result match) override
void reset() override
Turn off the LED.
void analogWrite(pin_t pin, analog_t val)
An ExtIO version of the Arduino function.
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 namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Matcher for MIDI messages with 2 data bytes, such as Note On/Off, Control Change, Key Pressure (but n...