Control Surface
1.1.0
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
9
/**
10
* @brief A class for latching buttons and switches that send MIDI events.
11
*
12
* The button is debounced.
13
*
14
* @see Button
15
*/
16
template
<
class
Sender>
17
class
MIDIButtonLatching
:
public
MIDIOutputElement
{
18
protected
:
19
/**
20
* @brief Construct a new MIDIButtonLatching.
21
*
22
* @param pin
23
* The digital input pin with the button connected.
24
* The internal pull-up resistor will be enabled.
25
* @param address
26
* The MIDI address to send to.
27
* @param sender
28
* The MIDI sender to use.
29
*/
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::Button::Rising
< Input went from high to low (1,0)
Definition:
Button.hpp:57
AH::Updatable<>
Button.hpp
MIDIButtonLatching::update
void update() override
Update this updatable.
Definition:
Abstract/MIDIButtonLatching.hpp:36
AH::Button
A class for reading and debouncing buttons and switches.
Definition:
Button.hpp:18
MIDIOutputElement.hpp
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::getButtonState
AH::Button::State getButtonState() const
Definition:
Abstract/MIDIButtonLatching.hpp:44
MIDIButtonLatching::button
AH::Button button
Definition:
Abstract/MIDIButtonLatching.hpp:47
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition:
Settings/NamespaceSettings.hpp:10
AH::Button::getState
State getState() const
Get the state of the button, without updating it.
Definition:
Button.cpp:36
AH::Button::begin
void begin()
Initialize (enable the internal pull-up resistor).
Definition:
Button.cpp:11
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition:
MIDICNChannelAddress.hpp:82
AH::Button::update
State update()
Read the button and return its new state.
Definition:
Button.cpp:19
MIDIButtonLatching::sender
Sender sender
Definition:
Abstract/MIDIButtonLatching.hpp:51
MIDIButtonLatching::address
const MIDICNChannelAddress address
Definition:
Abstract/MIDIButtonLatching.hpp:48
AH::pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition:
Hardware-Types.hpp:17
MIDIButtonLatching::MIDIButtonLatching
MIDIButtonLatching(pin_t pin, const MIDICNChannelAddress &address, const Sender &sender)
Construct a new MIDIButtonLatching.
Definition:
Abstract/MIDIButtonLatching.hpp:30
AH::Button::State
State
An enumeration of the different states a button can be in.
Definition:
Button.hpp:53
MIDIButtonLatching::begin
void begin() override
Initialize this updatable.
Definition:
Abstract/MIDIButtonLatching.hpp:35
AH::Button::Falling
< Input went from high to high (1,1)
Definition:
Button.hpp:56
Generated by
1.8.16