Control Surface
main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
src
MIDI_Outputs
Bankable
Abstract
Bankable/Abstract/MIDIButton.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Hardware/Button.hpp
>
4
#include <
Banks/BankableAddresses.hpp
>
5
#include <
Def/Def.hpp
>
6
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
7
8
BEGIN_CS_NAMESPACE
9
10
namespace
Bankable
{
11
19
template
<
class
BankAddress,
class
Sender>
20
class
MIDIButton
:
public
MIDIOutputElement
{
21
public
:
33
MIDIButton
(BankAddress bankAddress, pin_t pin,
const
Sender &
sender
)
34
:
address
(bankAddress),
button
(pin),
sender
(
sender
) {}
35
36
void
begin
()
override
{
button
.
begin
(); }
37
void
update
()
override
{
38
AH::Button::State
state =
button
.
update
();
39
if
(state ==
AH::Button::Falling
) {
40
address
.lock();
41
sender
.sendOn(
address
.getActiveAddress());
42
}
else
if
(state ==
AH::Button::Rising
) {
43
sender
.sendOff(
address
.getActiveAddress());
44
address
.unlock();
45
}
46
}
47
49
void
invert
() {
button
.
invert
(); }
50
51
AH::Button::State
getButtonState
()
const
{
return
button
.
getState
(); }
52
53
protected
:
54
BankAddress
address
;
55
AH::Button
button
;
56
57
public
:
58
Sender
sender
;
59
};
60
61
}
// namespace Bankable
62
63
END_CS_NAMESPACE
BankableAddresses.hpp
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
Bankable::MIDIButton
An abstract class for momentary push buttons that send MIDI events.
Definition
Bankable/Abstract/MIDIButton.hpp:20
Bankable::MIDIButton::button
AH::Button button
Definition
Bankable/Abstract/MIDIButton.hpp:55
Bankable::MIDIButton::MIDIButton
MIDIButton(BankAddress bankAddress, pin_t pin, const Sender &sender)
Construct a new bankable MIDIButton.
Definition
Bankable/Abstract/MIDIButton.hpp:33
Bankable::MIDIButton::address
BankAddress address
Definition
Bankable/Abstract/MIDIButton.hpp:54
Bankable::MIDIButton::getButtonState
AH::Button::State getButtonState() const
Definition
Bankable/Abstract/MIDIButton.hpp:51
Bankable::MIDIButton::sender
Sender sender
Definition
Bankable/Abstract/MIDIButton.hpp:58
Bankable::MIDIButton::update
void update() override
Update this updatable.
Definition
Bankable/Abstract/MIDIButton.hpp:37
Bankable::MIDIButton::begin
void begin() override
Initialize this updatable.
Definition
Bankable/Abstract/MIDIButton.hpp:36
Bankable::MIDIButton::invert
void invert()
Definition
Bankable/Abstract/MIDIButton.hpp:49
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition
BankAddresses.hpp:7
Generated by
1.10.0