Control Surface
main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
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,
MIDIAddress
address
,
const
Sender &
sender
)
31
:
button
(pin),
address
(
address
),
sender
(
sender
) {}
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
:
51
AH::Button
button
;
52
const
MIDIAddress
address
;
53
54
public
:
55
Sender
sender
;
56
};
57
58
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::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
MIDIButtonLatching
A class for latching buttons and switches that send MIDI events.
Definition
Abstract/MIDIButtonLatching.hpp:17
MIDIButtonLatching::setAddress
void setAddress(MIDIAddress address)
Set the MIDI address.
Definition
Abstract/MIDIButtonLatching.hpp:48
MIDIButtonLatching::button
AH::Button button
Definition
Abstract/MIDIButtonLatching.hpp:51
MIDIButtonLatching::address
const MIDIAddress address
Definition
Abstract/MIDIButtonLatching.hpp:52
MIDIButtonLatching::MIDIButtonLatching
MIDIButtonLatching(pin_t pin, MIDIAddress address, const Sender &sender)
Construct a new MIDIButtonLatching.
Definition
Abstract/MIDIButtonLatching.hpp:30
MIDIButtonLatching::getButtonState
AH::Button::State getButtonState() const
Definition
Abstract/MIDIButtonLatching.hpp:43
MIDIButtonLatching::sender
Sender sender
Definition
Abstract/MIDIButtonLatching.hpp:55
MIDIButtonLatching::update
void update() override
Update this updatable.
Definition
Abstract/MIDIButtonLatching.hpp:35
MIDIButtonLatching::begin
void begin() override
Initialize this updatable.
Definition
Abstract/MIDIButtonLatching.hpp:34
MIDIButtonLatching::getAddress
MIDIAddress getAddress() const
Get the MIDI address.
Definition
Abstract/MIDIButtonLatching.hpp:46
Generated by
1.10.0