Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Abstract/MIDIButtonLatching.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <Def/Def.hpp>
6
8
16template <class Sender>
18 protected:
32
33 public:
34 void begin() override { button.begin(); }
35 void update() override {
36 AH::Button::State state = button.update();
37 if (state == AH::Button::Falling || state == AH::Button::Rising) {
38 sender.sendOn(address);
39 sender.sendOff(address);
40 }
41 }
42
43 AH::Button::State getButtonState() const { return button.getState(); }
44
46 MIDIAddress getAddress() const { return this->address; }
48 void setAddress(MIDIAddress address) { this->address = address; }
49
50 private:
53
54 public:
55 Sender sender;
56};
57
AH::Updatable<> MIDIOutputElement
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class for reading and debouncing buttons and switches.
Definition Button.hpp:15
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
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
void setAddress(MIDIAddress address)
Set the MIDI address.
MIDIButtonLatching(pin_t pin, MIDIAddress address, const Sender &sender)
Construct a new MIDIButtonLatching.
AH::Button::State getButtonState() const
void update() override
Update this updatable.
void begin() override
Initialize this updatable.
MIDIAddress getAddress() const
Get the MIDI address.
Type for storing pin numbers of Extended Input/Output elements.