This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
IncrementDecrementSelector.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Selector.hpp"
5 
7 
8 template <setting_t N, class Callback = EmptySelectorCallback>
11 
12  public:
14  const Callback &callback,
18  wrap{wrap} {}
19 
20  void begin() override {
21  Parent::begin();
22  buttons.begin();
23  }
24 
25  void update() override {
27  using IncrDecrButtons = IncrementDecrementButtons;
28  switch (buttons.update()) {
29  case IncrDecrButtons::Increment: this->increment(wrap); break;
30  case IncrDecrButtons::Decrement: this->decrement(wrap); break;
31  case IncrDecrButtons::Reset: this->reset(); break;
32  case IncrDecrButtons::Nothing: break;
33  default: break;
34  }
35  }
36 
37 #ifdef INDIVIDUAL_BUTTON_INVERT
38  void invert() { buttons.invert(); }
39 #endif
40 
42  return buttons.getState();
43  }
44 
45  private:
48 };
49 
50 // -------------------------------------------------------------------------- //
51 
66 template <setting_t N>
68  public:
73  selectable,
74  {},
75  buttons,
76  wrap,
77  } {}
78 };
79 
GenericSelector::decrement
void decrement(Wrap wrap)
Subtract one from the setting, wrap around or clamp, depending on the parameter, if the new setting w...
Definition: Selector.hpp:124
GenericSelector::selectable
Selectable< N > & selectable
Definition: Selector.hpp:137
GenericIncrementDecrementSelector::buttons
IncrementDecrementButtons buttons
Definition: IncrementDecrementSelector.hpp:46
IncrementDecrementButtons::update
State update()
Update and return the state of the increment/decrement button.
Definition: IncrementDecrementButtons.hpp:59
Selectable
Definition: Selectable.hpp:11
IncrementDecrementButtons::getState
State getState() const
Return the state of the increment/decrement button without updating it.
Definition: IncrementDecrementButtons.hpp:67
IncrementDecrementSelector
Selector with two buttons (one to increment, one to decrement).
Definition: IncrementDecrementSelector.hpp:67
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
Wrap
Wrap
An enumeration to set the behavior of selectors that are incremented (decremented) beyond their maxim...
Definition: Selector.hpp:14
GenericSelector
Definition: Selector.hpp:57
GenericIncrementDecrementSelector::wrap
Wrap wrap
Definition: IncrementDecrementSelector.hpp:47
GenericSelector::update
void update() override
Update this updatable.
Definition: Selector.hpp:78
GenericSelector::callback
Callback callback
Definition: Selector.hpp:140
GenericIncrementDecrementSelector::update
void update() override
Update this updatable.
Definition: IncrementDecrementSelector.hpp:25
IncrementDecrementButtons::begin
void begin()
Definition: IncrementDecrementButtons.hpp:39
GenericSelector::increment
void increment(Wrap wrap)
Add one to the setting, wrap around or clamp, depending on the parameter, if the new setting would be...
Definition: Selector.hpp:105
Selector.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
Wrap::Wrap
When the maximum (minimum) setting is reached, wrap around to the minimum (maximum) setting.
IncrementDecrementButtons
A class for buttons that increment and decrement some counter or setting.
Definition: IncrementDecrementButtons.hpp:22
IncrementDecrementButtons::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementDecrementButtons.hpp:49
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition: Selector.hpp:73
GenericIncrementDecrementSelector::getButtonsState
IncrementDecrementButtons::State getButtonsState() const
Definition: IncrementDecrementSelector.hpp:41
IncrementDecrementSelector::IncrementDecrementSelector
IncrementDecrementSelector(Selectable< N > &selectable, const IncrementDecrementButtons &buttons, Wrap wrap=Wrap::Wrap)
Definition: IncrementDecrementSelector.hpp:69
GenericIncrementDecrementSelector::GenericIncrementDecrementSelector
GenericIncrementDecrementSelector(Selectable< N > &selectable, const Callback &callback, const IncrementDecrementButtons &buttons, Wrap wrap=Wrap::Wrap)
Definition: IncrementDecrementSelector.hpp:13
GenericIncrementDecrementSelector::begin
void begin() override
Initialize this updatable.
Definition: IncrementDecrementSelector.hpp:20
GenericIncrementDecrementSelector
Definition: IncrementDecrementSelector.hpp:9
GenericSelector::reset
void reset()
Reset the selection to the initial selection.
Definition: Selector.hpp:81
IncrementDecrementButtons.hpp