Control Surface
main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
src
MIDI_Outputs
Abstract
Abstract/MIDIButton.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Hardware/Button.hpp
>
4
#include <
Def/Def.hpp
>
5
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
6
7
BEGIN_CS_NAMESPACE
8
16
template
<
class
Sender>
17
class
MIDIButton
:
public
MIDIOutputElement
{
18
public
:
30
MIDIButton
(pin_t pin,
MIDIAddress
address
,
const
Sender &
sender
)
31
:
button
(pin),
address
(
address
),
sender
(
sender
) {}
32
33
void
begin
()
override
{
button
.
begin
(); }
34
void
update
()
override
{
35
AH::Button::State
state =
button
.
update
();
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
46
AH::Button::State
getButtonState
()
const
{
return
button
.
getState
(); }
47
49
MIDIAddress
getAddress
()
const
{
return
this->
address
; }
52
void
setAddressUnsafe
(
MIDIAddress
address
) { this->address =
address
; }
53
54
private
:
55
AH::Button
button
;
56
const
MIDIAddress
address
;
57
58
public
:
59
Sender
sender
;
60
};
61
62
END_CS_NAMESPACE
Button.hpp
Def.hpp
MIDIOutputElement.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
AH::Button
A class for reading and debouncing buttons and switches.
Definition
Button.hpp:15
AH::Button::update
State update()
Read the button and return its new state.
Definition
Button.cpp:11
AH::Button::State
State
An enumeration of the different states a button can be in.
Definition
Button.hpp:45
AH::Button::Rising
@ Rising
Input went from low to high (0,1)
Definition
Button.hpp:49
AH::Button::Falling
@ Falling
Input went from high to low (1,0)
Definition
Button.hpp:48
AH::Button::invert
void invert()
Invert the input state of this button (button pressed is HIGH instead of LOW).
Definition
Button.cpp:9
AH::Button::getState
State getState() const
Get the state of the button, without updating it.
Definition
Button.cpp:32
AH::Button::begin
void begin()
Initialize (enable the internal pull-up resistor).
Definition
Button.cpp:7
AH::Updatable
A super class for object that have to be updated regularly.
Definition
Updatable.hpp:169
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition
MIDIAddress.hpp:145
MIDIButton
An abstract class for momentary push buttons that send MIDI events.
Definition
Abstract/MIDIButton.hpp:17
MIDIButton::button
AH::Button button
Definition
Abstract/MIDIButton.hpp:55
MIDIButton::address
const MIDIAddress address
Definition
Abstract/MIDIButton.hpp:56
MIDIButton::setAddressUnsafe
void setAddressUnsafe(MIDIAddress address)
Set the MIDI address.
Definition
Abstract/MIDIButton.hpp:52
MIDIButton::getButtonState
AH::Button::State getButtonState() const
Definition
Abstract/MIDIButton.hpp:46
MIDIButton::MIDIButton
MIDIButton(pin_t pin, MIDIAddress address, const Sender &sender)
Construct a new MIDIButton.
Definition
Abstract/MIDIButton.hpp:30
MIDIButton::sender
Sender sender
Definition
Abstract/MIDIButton.hpp:59
MIDIButton::update
void update() override
Update this updatable.
Definition
Abstract/MIDIButton.hpp:34
MIDIButton::begin
void begin() override
Initialize this updatable.
Definition
Abstract/MIDIButton.hpp:33
MIDIButton::invert
void invert()
Definition
Abstract/MIDIButton.hpp:44
MIDIButton::getAddress
MIDIAddress getAddress() const
Get the MIDI address.
Definition
Abstract/MIDIButton.hpp:49
Generated by
1.10.0