Control Surface  1.1.0
MIDI Control Surface library for Arduino
IncrementSelector.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>
9 class GenericIncrementSelector : public GenericSelector<N, Callback> {
11 
12  public:
14  const Callback &callback,
17  : GenericSelector<N, Callback>{selectable, callback}, button{button},
18  wrap{wrap} {}
19 
20  void begin() override {
21  Parent::begin();
22  button.begin();
23  }
24 
25  void update() override {
27  this->increment(wrap);
28  }
29 
31  return button.getState();
32  }
33 
34 #ifdef INDIVIDUAL_BUTTON_INVERT
35  void invert() { button.invert(); }
36 #endif
37 
38  private:
41 };
42 
43 // -------------------------------------------------------------------------- //
44 
45 /**
46  * @brief Selector with one button that increments the selection.
47  *
48  * @htmlonly
49  * <object type="image/svg+xml" data="../../selector-increment-LED.svg"></object>
50  * @endhtmlonly
51  *
52  * @ingroup Selectors
53  *
54  * @tparam N
55  * The number of settings.
56  */
57 template <setting_t N>
58 class IncrementSelector : virtual public GenericIncrementSelector<N> {
59  public:
63  selectable,
64  {},
65  button,
66  wrap,
67  } {}
68 
72  selectable,
73  {},
74  button,
75  wrap,
76  } {}
77 };
78 
AH::IncrementButton::update
State update()
Update and return the state of the increment button.
Definition: IncrementButton.hpp:49
GenericSelector::selectable
Selectable< N > & selectable
Definition: Selector.hpp:137
IncrementSelector
Selector with one button that increments the selection.
Definition: IncrementSelector.hpp:58
GenericIncrementSelector::begin
void begin() override
Initialize this updatable.
Definition: IncrementSelector.hpp:20
AH::Button
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:18
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
Selectable
Definition: Selectable.hpp:11
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
GenericIncrementSelector::wrap
Wrap wrap
Definition: IncrementSelector.hpp:40
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
GenericIncrementSelector::button
AH::IncrementButton button
Definition: IncrementSelector.hpp:39
GenericSelector::callback
Callback callback
Definition: Selector.hpp:140
AH::IncrementButton::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementButton.hpp:41
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
GenericIncrementSelector
Definition: IncrementSelector.hpp:9
Selector.hpp
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const AH::Button &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:69
GenericIncrementSelector::update
void update() override
Update this updatable.
Definition: IncrementSelector.hpp:25
GenericIncrementSelector::getButtonState
AH::IncrementButton::State getButtonState() const
Definition: IncrementSelector.hpp:30
AH::IncrementButton::begin
void begin()
Definition: IncrementButton.hpp:34
IncrementButton.hpp
GenericIncrementSelector::GenericIncrementSelector
GenericIncrementSelector(Selectable< N > &selectable, const Callback &callback, const AH::IncrementButton &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:13
Wrap::Wrap
When the maximum (minimum) setting is reached, wrap around to the minimum (maximum) setting.
AH::IncrementButton
A class for buttons that increment some counter or setting.
Definition: IncrementButton.hpp:22
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition: Selector.hpp:73
AH::IncrementButton::getState
State getState() const
Return the state of the increment button without updating it.
Definition: IncrementButton.hpp:56
AH::IncrementButton::Increment
The counter must be incremented.
Definition: IncrementButton.hpp:43
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const AH::IncrementButton &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:60