This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
Bankable/Abstract/MIDIIncrementDecrementButtons.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <Def/Def.hpp>
7 
9 
11 
12 namespace Bankable {
13 
19 template <class BankAddress, class RelativeSender, class ResetSender>
21  protected:
29  uint8_t multiplier,
30  const RelativeSender &relativeSender,
31  const ResetSender &resetSender)
34 
35  public:
36  void begin() override { buttons.begin(); }
37 
38  void update() override {
39  using IncrDecrButtons = IncrementDecrementButtons;
40  MIDICNChannelAddress address = addresses.getActiveAddress(0);
41  switch (buttons.update()) {
42  case IncrDecrButtons::Increment: send(multiplier, address); break;
43  case IncrDecrButtons::Decrement: send(-multiplier, address); break;
44  case IncrDecrButtons::Reset: reset(); break;
45  case IncrDecrButtons::Nothing: break;
46  default: break;
47  }
48  }
49 
50  void send(long delta, const MIDICNChannelAddress &address) {
51  relativeSender.send(delta, address);
52  }
53 
54  void reset() {
55  MIDICNChannelAddress address = addresses.getActiveAddress(1);
56  if (address) {
57  resetSender.sendOn(address);
58  resetSender.sendOff(address);
59  }
60  }
61 
62 #ifdef INDIVIDUAL_BUTTON_INVERT
63  void invert() { buttons.invert(); }
64 #endif
65 
67  return buttons.getState();
68  }
69 
70  private:
71  BankAddress addresses;
73  const uint8_t multiplier;
74 
75  public:
76  RelativeSender relativeSender;
77  ResetSender resetSender;
78 };
79 
80 } // namespace Bankable
81 
Updatable
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:20
Bankable::MIDIIncrementDecrementButtons::addresses
BankAddress addresses
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:71
BankableMIDIOutput.hpp
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
Bankable::MIDIIncrementDecrementButtons::getButtonsState
IncrementDecrementButtons::State getButtonsState() const
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:66
MIDIOutputElement.hpp
Def.hpp
Bankable::MIDIIncrementDecrementButtons::begin
void begin() override
Initialize this updatable.
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:36
IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition: IncrementDecrementButtons.hpp:59
IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition: IncrementDecrementButtons.hpp:67
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
Bankable::MIDIIncrementDecrementButtons::relativeSender
RelativeSender relativeSender
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:76
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
Bankable::MIDIIncrementDecrementButtons::MIDIIncrementDecrementButtons
MIDIIncrementDecrementButtons(const BankAddress &addresses, const IncrementDecrementButtons &buttons, uint8_t multiplier, const RelativeSender &relativeSender, const ResetSender &resetSender)
Construct a new MIDIIncrementDecrementButtons.
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:27
Bankable::MIDIIncrementDecrementButtons::update
void update() override
Update this updatable.
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:38
IncrementDecrementButtons::begin
void begin()
Definition: IncrementDecrementButtons.hpp:39
Bankable::MIDIIncrementDecrementButtons
An abstract class for two buttons that send incremental MIDI events.
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:20
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
Bankable::MIDIIncrementDecrementButtons::multiplier
const uint8_t multiplier
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:73
IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition: IncrementDecrementButtons.hpp:22
DigitalNoteSender.hpp
Bankable::MIDIIncrementDecrementButtons::reset
void reset()
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:54
IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementDecrementButtons.hpp:49
Bankable::MIDIIncrementDecrementButtons::buttons
IncrementDecrementButtons buttons
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:72
Bankable::MIDIIncrementDecrementButtons::send
void send(long delta, const MIDICNChannelAddress &address)
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:50
IncrementDecrementButtons.hpp
Bankable::MIDIIncrementDecrementButtons::resetSender
ResetSender resetSender
Definition: Bankable/Abstract/MIDIIncrementDecrementButtons.hpp:77