Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Abstract/MIDIButton.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <Def/Def.hpp>
6
8
16template <class Sender>
18 public:
32
33 void begin() override { button.begin(); }
34 void update() override {
36 if (state == AH::Button::Falling) {
37 sender.sendOn(address);
38 } else if (state == AH::Button::Rising) {
39 sender.sendOff(address);
40 }
41 }
42
44 void invert() { button.invert(); }
45
47
49 MIDIAddress getAddress() const { return this->address; }
52 void setAddressUnsafe(MIDIAddress address) { this->address = address; }
53
54 private:
57
58 public:
59 Sender sender;
60};
61
#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
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.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
An abstract class for momentary push buttons that send MIDI events.
MIDIAddress address
void setAddressUnsafe(MIDIAddress address)
Set the MIDI address.
AH::Button::State getButtonState() const
MIDIButton(pin_t pin, MIDIAddress address, const Sender &sender)
Construct a new MIDIButton.
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.