Control Surface pin-t-adl
MIDI Control Surface library for Arduino
Abstract/MIDIIncrementDecrementButtons.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <Def/Def.hpp>
6
8
10
14template <class RelativeSender, class ResetSender>
16 protected:
25 const RelativeSender &relativeSender,
26 const ResetSender &resetSender)
30
31 public:
32 void begin() override { buttons.begin(); }
33
34 void update() override {
35 using IncrDecrButtons = AH::IncrementDecrementButtons;
36 switch (buttons.update()) {
37 case IncrDecrButtons::Nothing: break;
38 case IncrDecrButtons::IncrementShort: // fallthrough
39 case IncrDecrButtons::IncrementLong: // fallthrough
40 case IncrDecrButtons::IncrementHold:
42 break;
43 case IncrDecrButtons::DecrementShort: // fallthrough
44 case IncrDecrButtons::DecrementLong: // fallthrough
45 case IncrDecrButtons::DecrementHold:
47 break;
48 case IncrDecrButtons::Reset: reset(); break;
49 default: break;
50 }
51 }
52
53 void send(long delta, MIDIAddress address) {
54 relativeSender.send(delta, address);
55 }
56
57 void reset() {
58 if (resetAddress) {
61 }
62 }
63
65 void invert() { buttons.invert(); }
66
68 return buttons.getState();
69 }
70
72 MIDIAddress getAddress() const { return this->address; }
74 void setAddress(MIDIAddress address) { this->address = address; }
75
77 MIDIAddress getResetAddress() const { return this->resetAddress; }
80
81 private:
84 uint8_t multiplier;
86
87 public:
88 RelativeSender relativeSender;
89 ResetSender resetSender;
90};
91
#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.
Definition: Updatable.hpp:173
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
An abstract class for two buttons that send incremental MIDI events.
void setAddress(MIDIAddress address)
Set the MIDI address.
AH::IncrementDecrementButtons::State getButtonsState() const
void update() override
Update this updatable.
MIDIIncrementDecrementButtons(const AH::IncrementDecrementButtons &buttons, MIDIAddress address, uint8_t multiplier, MIDIAddress resetAddress, const RelativeSender &relativeSender, const ResetSender &resetSender)
Construct a new MIDIIncrementDecrementButtons.
void begin() override
Initialize this updatable.
void setResetAddress(MIDIAddress address)
Set the MIDI address of the reset action.
MIDIAddress getAddress() const
Get the MIDI address.
MIDIAddress getResetAddress() const
Get the MIDI address of the reset action.
void send(long delta, MIDIAddress address)