Control Surface  1.1.1
MIDI Control Surface library for Arduino
Bankable/Abstract/MIDIButtonLatching.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <AH/Hardware/Button.hpp>
5 #include <Def/Def.hpp>
7 
9 
10 namespace Bankable {
11 
19 template <class BankAddress, class Sender>
21  protected:
33  MIDIButtonLatching(const BankAddress &bankAddress, pin_t pin,
34  const Sender &sender)
35  : address{bankAddress}, button{pin}, sender{sender} {}
36 
37  public:
38  void begin() override { button.begin(); }
39  void update() override {
41  if (state == AH::Button::Falling || state == AH::Button::Rising) {
42  MIDICNChannelAddress sendAddress = address.getActiveAddress();
43  sender.sendOn(sendAddress);
44  sender.sendOff(sendAddress);
45  }
46  }
47 
49 
50  private:
51  BankAddress address;
53 
54  public:
55  Sender sender;
56 };
57 
58 } // namespace Bankable
59 
AH::Updatable
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:25
BankableMIDIOutput.hpp
Bankable::MIDIButtonLatching::update
void update() override
Update this updatable.
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:39
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
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
Bankable::MIDIButtonLatching::getButtonState
AH::Button::State getButtonState() const
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:48
MIDIOutputElement.hpp
Def.hpp
Bankable::MIDIButtonLatching::MIDIButtonLatching
MIDIButtonLatching(const BankAddress &bankAddress, pin_t pin, const Sender &sender)
Construct a new MIDIButtonLatching.
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:33
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
Bankable::MIDIButtonLatching::button
AH::Button button
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:52
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
Bankable::MIDIButtonLatching::address
BankAddress address
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:51
Bankable::MIDIButtonLatching::begin
void begin() override
Initialize this updatable.
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:38
AH::Button::Rising
Input went from low to high (0,1)
Definition: Button.hpp:57
AH::Button::begin
void begin()
Initialize (enable the internal pull-up resistor).
Definition: Button.cpp:11
Bankable::MIDIButtonLatching::sender
Sender sender
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:55
AH::Button::update
State update()
Read the button and return its new state.
Definition: Button.cpp:19
Bankable::MIDIButtonLatching
A class for latching buttons and switches that send MIDI events.
Definition: Bankable/Abstract/MIDIButtonLatching.hpp:20