Control Surface  1.2.0
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:
23  const MIDIAddress &address,
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::Nothing: break;
39  case IncrDecrButtons::IncrementShort: // fallthrough
40  case IncrDecrButtons::IncrementLong: // fallthrough
41  case IncrDecrButtons::IncrementHold:
43  break;
44  case IncrDecrButtons::DecrementShort: // fallthrough
45  case IncrDecrButtons::DecrementLong: // fallthrough
46  case IncrDecrButtons::DecrementHold:
48  break;
49  case IncrDecrButtons::Reset: reset(); break;
50  default: break;
51  }
52  }
53 
54  void send(long delta, const MIDIAddress &address) {
55  relativeSender.send(delta, address);
56  }
57 
58  void reset() {
59  if (resetAddress) {
60  resetSender.sendOn(resetAddress);
61  resetSender.sendOff(resetAddress);
62  }
63  }
64 
65 #ifdef AH_INDIVIDUAL_BUTTON_INVERT
66  void invert() { buttons.invert(); }
67 #endif
68 
70  return buttons.getState();
71  }
72 
73  private:
76  const uint8_t multiplier;
78 
79  public:
80  RelativeSender relativeSender;
81  ResetSender resetSender;
82 };
83 
MIDIIncrementDecrementButtons::MIDIIncrementDecrementButtons
MIDIIncrementDecrementButtons(const AH::IncrementDecrementButtons &buttons, const MIDIAddress &address, uint8_t multiplier, const MIDIAddress &resetAddress, const RelativeSender &relativeSender, const ResetSender &resetSender)
Construct a new MIDIIncrementDecrementButtons.
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:22
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDIAddress.hpp:91
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:80
AH::Updatable<>
MIDIIncrementDecrementButtons::reset
void reset()
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:58
MIDIIncrementDecrementButtons::multiplier
const uint8_t multiplier
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:76
AH::IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition: IncrementDecrementButtons.hpp:74
AH::IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition: IncrementDecrementButtons.hpp:66
MIDIOutputElement.hpp
MIDIIncrementDecrementButtons::send
void send(long delta, const MIDIAddress &address)
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:54
Def.hpp
AH::IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition: IncrementDecrementButtons.hpp:25
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
MIDIIncrementDecrementButtons::address
const MIDIAddress address
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:75
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:81
AH::IncrementDecrementButtons::begin
void begin()
Definition: IncrementDecrementButtons.hpp:42
MIDIIncrementDecrementButtons::getButtonsState
AH::IncrementDecrementButtons::State getButtonsState() const
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:69
MIDIIncrementDecrementButtons::resetAddress
const MIDIAddress resetAddress
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:77
MIDIIncrementDecrementButtons::invert
void invert()
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:66
MIDIIncrementDecrementButtons::buttons
AH::IncrementDecrementButtons buttons
Definition: Abstract/MIDIIncrementDecrementButtons.hpp:74
AH::IncrementDecrementButtons::invert
void invert()
Definition: IncrementDecrementButtons.hpp:78
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