Control Surface  1.1.1
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 
14 template <class RelativeSender, class ResetSender>
16  protected:
24  uint8_t multiplier,
26  const RelativeSender &relativeSender,
27  const ResetSender &resetSender)
31 
32  public:
33  void begin() override { buttons.begin(); }
34 
35  void update() override {
36  using IncrDecrButtons = AH::IncrementDecrementButtons;
37  switch (buttons.update()) {
38  case IncrDecrButtons::Increment: send(multiplier, address); break;
39  case IncrDecrButtons::Decrement: send(-multiplier, address); break;
40  case IncrDecrButtons::Reset: reset(); break;
41  case IncrDecrButtons::Nothing: break;
42  default: break;
43  }
44  }
45 
46  void send(long delta, const MIDICNChannelAddress &address) {
47  relativeSender.send(delta, address);
48  }
49 
50  void reset() {
51  if (resetAddress) {
52  resetSender.sendOn(resetAddress);
53  resetSender.sendOff(resetAddress);
54  }
55  }
56 
57 #ifdef AH_INDIVIDUAL_BUTTON_INVERT
58  void invert() { buttons.invert(); }
59 #endif
60 
62  return buttons.getState();
63  }
64 
65  private:
68  const uint8_t multiplier;
70 
71  public:
72  RelativeSender relativeSender;
73  ResetSender resetSender;
74 };
75 
AH::IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementDecrementButtons.hpp:52
MIDIIncrementDecrementButtons::relativeSender
RelativeSender relativeSender
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:72
AH::Updatable<>
MIDIIncrementDecrementButtons::MIDIIncrementDecrementButtons
MIDIIncrementDecrementButtons(const AH::IncrementDecrementButtons &buttons, const MIDICNChannelAddress &address, uint8_t multiplier, const MIDICNChannelAddress &resetAddress, const RelativeSender &relativeSender, const ResetSender &resetSender)
Construct a new MIDIIncrementDecrementButtons.
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:22
MIDIIncrementDecrementButtons::reset
void reset()
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:50
MIDIIncrementDecrementButtons::multiplier
const uint8_t multiplier
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:68
AH::IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition: IncrementDecrementButtons.hpp:70
AH::IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition: IncrementDecrementButtons.hpp:62
MIDIOutputElement.hpp
Def.hpp
AH::IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition: IncrementDecrementButtons.hpp:25
MIDIIncrementDecrementButtons::send
void send(long delta, const MIDICNChannelAddress &address)
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:46
MIDIIncrementDecrementButtons::resetAddress
const MIDICNChannelAddress resetAddress
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:69
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
MIDIIncrementDecrementButtons
An abstract class for two buttons that send incremental MIDI events.
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:15
MIDIIncrementDecrementButtons::resetSender
ResetSender resetSender
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:73
AH::IncrementDecrementButtons::begin
void begin()
Definition: IncrementDecrementButtons.hpp:42
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
MIDIIncrementDecrementButtons::getButtonsState
AH::IncrementDecrementButtons::State getButtonsState() const
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:61
MIDIIncrementDecrementButtons::invert
void invert()
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:58
MIDIIncrementDecrementButtons::buttons
AH::IncrementDecrementButtons buttons
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:66
AH::IncrementDecrementButtons::invert
void invert()
Definition: IncrementDecrementButtons.hpp:74
DigitalNoteSender.hpp
MIDIIncrementDecrementButtons::update
void update() override
Update this updatable.
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:35
MIDIIncrementDecrementButtons::begin
void begin() override
Initialize this updatable.
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:33
IncrementDecrementButtons.hpp
MIDIIncrementDecrementButtons::address
const MIDICNChannelAddress address
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:67