Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Bankable/Abstract/MIDIButtonLatched.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <Def/Def.hpp>
8
10
11namespace Bankable {
12
21template <uint8_t NumBanks, class BankAddress, class Sender>
23 protected:
38
39 public:
40 void begin() override { button.begin(); }
41
42 void update() override {
44 if (state == AH::Button::Falling)
46 }
47
48 bool toggleState() {
49 bool newstate = !getState();
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
66
67 protected:
71
72 public:
73 Sender sender;
74};
75
76} // namespace Bankable
77
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
void set(uint16_t bitIndex)
Set the value of the given bit to 1.
Definition BitArray.hpp:39
bool get(uint16_t bitIndex) const
Get the value of the given bit.
Definition BitArray.hpp:29
A class for reading and debouncing buttons and switches.
Definition Button.hpp:15
State update()
Read the button and return its new state.
Definition Button.cpp:11
State
An enumeration of the different states a button can be in.
Definition Button.hpp:45
@ Falling
Input went from high to low (1,0)
Definition Button.hpp:48
State getState() const
Get the state of the button, without updating it.
Definition Button.cpp:32
void begin()
Initialize (enable the internal pull-up resistor).
Definition Button.cpp:7
A super class for object that have to be updated regularly.
A class for momentary buttons and switches that send MIDI events.
void update() override
Update this updatable.
MIDIButtonLatched(BankAddress bankAddress, pin_t pin, const Sender &sender)
Create a new bankable MIDIButtonLatched object on the given pin and address.
void begin() override
Initialize this updatable.
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32