Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Outputs
Bankable
Abstract
Bankable/Abstract/MIDIButtonLatched.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Containers/BitArray.hpp
>
4
#include <
AH/Hardware/Button.hpp
>
5
#include <
Banks/BankableAddresses.hpp
>
6
#include <
Def/Def.hpp
>
7
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
8
9
BEGIN_CS_NAMESPACE
10
11
namespace
Bankable
{
12
21
template
<u
int
8_t NumBanks,
class
BankAddress,
class
Sender>
22
class
MIDIButtonLatched
:
public
MIDIOutputElement
{
23
protected
:
36
MIDIButtonLatched
(BankAddress bankAddress,
pin_t
pin,
const
Sender &
sender
)
37
:
address
(bankAddress),
button
(pin),
sender
(
sender
) {}
38
39
public
:
40
void
begin
()
override
{
button
.begin(); }
41
42
void
update
()
override
{
43
AH::Button::State
state =
button
.update();
44
if
(state ==
AH::Button::Falling
)
45
toggleState
();
46
}
47
48
bool
toggleState
() {
49
bool
newstate = !
getState
();
50
setState
(newstate);
51
return
newstate;
52
}
53
54
bool
getState
()
const
{
return
states
.get(
address
.getSelection()); }
55
56
void
setState
(
bool
state) {
57
states
.set(
address
.getSelection(), state);
58
if
(state) {
59
sender
.sendOn(
address
.getActiveAddress());
60
}
else
{
61
sender
.sendOff(
address
.getActiveAddress());
62
}
63
}
64
65
AH::Button::State
getButtonState
()
const
{
return
button
.getState(); }
66
67
protected
:
68
BankAddress
address
;
69
AH::Button
button
;
70
AH::BitArray<NumBanks>
states
;
71
72
public
:
73
Sender
sender
;
74
};
75
76
}
// namespace Bankable
77
78
END_CS_NAMESPACE
BankableAddresses.hpp
BitArray.hpp
Button.hpp
Def.hpp
MIDIOutputElement.hpp
MIDIOutputElement
AH::Updatable<> MIDIOutputElement
Definition
MIDIOutputElement.hpp:9
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::BitArray
A class for arrays of bits.
Definition
BitArray.hpp:21
AH::Button
A class for reading and debouncing buttons and switches.
Definition
Button.hpp:15
AH::Button::State
State
An enumeration of the different states a button can be in.
Definition
Button.hpp:47
AH::Button::Falling
@ Falling
Input went from high to low (1,0).
Definition
Button.hpp:50
Bankable::MIDIButtonLatched::getState
bool getState() const
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:54
Bankable::MIDIButtonLatched::button
AH::Button button
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:69
Bankable::MIDIButtonLatched::address
BankAddress address
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:68
Bankable::MIDIButtonLatched::getButtonState
AH::Button::State getButtonState() const
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:65
Bankable::MIDIButtonLatched::sender
Sender sender
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:73
Bankable::MIDIButtonLatched::update
void update() override
Update this updatable.
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:42
Bankable::MIDIButtonLatched::MIDIButtonLatched
MIDIButtonLatched(BankAddress bankAddress, pin_t pin, const Sender &sender)
Create a new bankable MIDIButtonLatched object on the given pin and address.
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:36
Bankable::MIDIButtonLatched::states
AH::BitArray< NumBanks > states
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:70
Bankable::MIDIButtonLatched::begin
void begin() override
Initialize this updatable.
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:40
Bankable::MIDIButtonLatched::toggleState
bool toggleState()
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:48
Bankable::MIDIButtonLatched::setState
void setState(bool state)
Definition
Bankable/Abstract/MIDIButtonLatched.hpp:56
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition
BankAddresses.hpp:7
AH::ExtIO::pin_t
Type for storing pin numbers of Extended Input/Output elements.
Definition
Hardware-Types.hpp:25
Generated by
1.17.0