Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Bankable/Abstract/MIDIButtonLatching.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 protected:
33 MIDIButtonLatching(BankAddress bankAddress, pin_t pin, const Sender &sender)
34 : address(bankAddress), button(pin), sender(sender) {}
35
36 public:
37 void begin() override { button.begin(); }
38 void update() override {
40 if (state == AH::Button::Falling || state == AH::Button::Rising) {
41 MIDIAddress sendAddress = address.getActiveAddress();
42 sender.sendOn(sendAddress);
43 sender.sendOff(sendAddress);
44 }
45 }
46
48
49 protected:
50 BankAddress address;
52
53 public:
54 Sender sender;
55};
56
57} // namespace Bankable
58
#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:47
@ Rising
Input went from low to high (0,1)
Definition Button.hpp:51
@ Falling
Input went from high to low (1,0)
Definition Button.hpp:50
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.
A class for latching buttons and switches that send MIDI events.
MIDIButtonLatching(BankAddress bankAddress, pin_t pin, const Sender &sender)
Construct a new MIDIButtonLatching.
void update() override
Update this updatable.
void begin() override
Initialize this updatable.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
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.