Control Surface
1.1.1
MIDI Control Surface library for Arduino
src
MIDI_Outputs
Abstract
Abstract/MIDIButtonLatching.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
MIDIButtonLatching
:
public
MIDIOutputElement
{
18
protected
:
30
MIDIButtonLatching
(
pin_t
pin,
const
MIDICNChannelAddress
&
address
,
31
const
Sender &
sender
)
32
:
button
{pin},
address
(
address
),
sender
{
sender
} {}
33
34
public
:
35
void
begin
()
override
{
button
.
begin
(); }
36
void
update
()
override
{
37
AH::Button::State
state =
button
.
update
();
38
if
(state ==
AH::Button::Falling
|| state ==
AH::Button::Rising
) {
39
sender
.sendOn(
address
);
40
sender
.sendOff(
address
);
41
}
42
}
43
44
AH::Button::State
getButtonState
()
const
{
return
button
.
getState
(); }
45
46
private
:
47
AH::Button
button
;
48
const
MIDICNChannelAddress
address
;
49
50
public
:
51
Sender
sender
;
52
};
53
54
END_CS_NAMESPACE
AH::Updatable<>
Button.hpp
AH::Button::Falling
Input went from high to low (1,0)
Definition:
Button.hpp:56
AH::Button::State
State
An enumeration of the different states a button can be in.
Definition:
Button.hpp:53
AH::Button::getState
State getState() const
Get the state of the button, without updating it.
Definition:
Button.cpp:36
AH::pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition:
Hardware-Types.hpp:17
AH::Button
A class for reading and debouncing buttons and switches.
Definition:
Button.hpp:18
MIDIOutputElement.hpp
MIDIButtonLatching::MIDIButtonLatching
MIDIButtonLatching(pin_t pin, const MIDICNChannelAddress &address, const Sender &sender)
Construct a new MIDIButtonLatching.
Definition:
Abstract/MIDIButtonLatching.hpp:30
Def.hpp
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition:
Settings/NamespaceSettings.hpp:9
MIDIButtonLatching
A class for latching buttons and switches that send MIDI events.
Definition:
Abstract/MIDIButtonLatching.hpp:17
MIDIButtonLatching::begin
void begin() override
Initialize this updatable.
Definition:
Abstract/MIDIButtonLatching.hpp:35
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition:
Settings/NamespaceSettings.hpp:10
MIDIButtonLatching::button
AH::Button button
Definition:
Abstract/MIDIButtonLatching.hpp:47
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition:
MIDICNChannelAddress.hpp:82
MIDIButtonLatching::sender
Sender sender
Definition:
Abstract/MIDIButtonLatching.hpp:51
AH::Button::Rising
Input went from low to high (0,1)
Definition:
Button.hpp:57
MIDIButtonLatching::address
const MIDICNChannelAddress address
Definition:
Abstract/MIDIButtonLatching.hpp:48
MIDIButtonLatching::getButtonState
AH::Button::State getButtonState() const
Definition:
Abstract/MIDIButtonLatching.hpp:44
AH::Button::begin
void begin()
Initialize (enable the internal pull-up resistor).
Definition:
Button.cpp:11
AH::Button::update
State update()
Read the button and return its new state.
Definition:
Button.cpp:19
MIDIButtonLatching::update
void update() override
Update this updatable.
Definition:
Abstract/MIDIButtonLatching.hpp:36
Generated by
1.8.16