Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <Def/Def.hpp>
8
10
11namespace Bankable {
12
18template <class BankAddress, class RelativeSender, class ResetSender>
20 protected:
33
34 public:
35 void begin() override { buttons.begin(); }
36
37 void update() override {
38 using IncrDecrButtons = AH::IncrementDecrementButtons;
39 MIDIAddress address = addresses.getFirstActiveAddress();
40 switch (buttons.update()) {
41 case IncrDecrButtons::Nothing: break;
42 case IncrDecrButtons::IncrementShort: // fallthrough
43 case IncrDecrButtons::IncrementLong: // fallthrough
44 case IncrDecrButtons::IncrementHold:
45 send(multiplier, address);
46 break;
47 case IncrDecrButtons::DecrementShort: // fallthrough
48 case IncrDecrButtons::DecrementLong: // fallthrough
49 case IncrDecrButtons::DecrementHold:
50 send(-multiplier, address);
51 break;
52 case IncrDecrButtons::Reset: reset(); break;
53 default: break;
54 }
55 }
56
57 void send(long delta, MIDIAddress address) {
58 relativeSender.send(delta, address);
59 }
60
61 void reset() {
62 MIDIAddress address = addresses.getSecondActiveAddress();
63 if (address) {
64 resetSender.sendOn(address);
65 resetSender.sendOff(address);
66 }
67 }
68
70 void invert() { buttons.invert(); }
71
75
76 protected:
77 BankAddress addresses;
79 const uint8_t multiplier;
80
81 public:
82 RelativeSender relativeSender;
83 ResetSender resetSender;
84};
85
86} // namespace Bankable
87
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class for buttons that increment and decrement some counter or setting.
State
An enumeration of the different actions to be performed by the counter.
State getState() const
Return the state of the increment/decrement button without updating it.
State update()
Update and return the state of the increment/decrement button.
A super class for object that have to be updated regularly.
An abstract class for two buttons that send incremental MIDI events.
MIDIIncrementDecrementButtons(BankAddress addresses, const AH::IncrementDecrementButtons &buttons, uint8_t multiplier, const RelativeSender &relativeSender, const ResetSender &resetSender)
Construct a new MIDIIncrementDecrementButtons.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.