Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Bankable/Abstract/MIDIButton.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <Def/Def.hpp>
7
9
10namespace Bankable {
11
19template <class BankAddress, class Sender>
21 public:
33 MIDIButton(BankAddress bankAddress, pin_t pin, const Sender &sender)
35
36 void begin() override { button.begin(); }
37 void update() override {
39 if (state == AH::Button::Falling) {
40 address.lock();
41 sender.sendOn(address.getActiveAddress());
42 } else if (state == AH::Button::Rising) {
43 sender.sendOff(address.getActiveAddress());
44 address.unlock();
45 }
46 }
47
49 void invert() { button.invert(); }
50
52
53 protected:
56
57 public:
58 Sender sender;
59};
60
61} // namespace Bankable
62
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class for reading and debouncing buttons and switches.
Definition Button.hpp:15
State update()
Read the button and return its new state.
Definition Button.cpp:11
State
An enumeration of the different states a button can be in.
Definition Button.hpp:45
@ Rising
Input went from low to high (0,1)
Definition Button.hpp:49
@ Falling
Input went from high to low (1,0)
Definition Button.hpp:48
void invert()
Invert the input state of this button (button pressed is HIGH instead of LOW).
Definition Button.cpp:9
State getState() const
Get the state of the button, without updating it.
Definition Button.cpp:32
void begin()
Initialize (enable the internal pull-up resistor).
Definition Button.cpp:7
A super class for object that have to be updated regularly.
An abstract class for momentary push buttons that send MIDI events.
MIDIButton(BankAddress bankAddress, pin_t pin, const Sender &sender)
Construct a new bankable MIDIButton.
AH::Button::State getButtonState() const
void update() override
Update this updatable.
void begin() override
Initialize this updatable.
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32