This is an old version of the documentation. View the latest version here.
Control Surface  1.0.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,
15  const IncrementButton &button,
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 
32 #ifdef INDIVIDUAL_BUTTON_INVERT
33  void invert() { button.invert(); }
34 #endif
35 
36  private:
39 };
40 
41 // -------------------------------------------------------------------------- //
42 
55 template <setting_t N>
56 class IncrementSelector : virtual public GenericIncrementSelector<N> {
57  public:
61  selectable,
62  {},
63  button,
64  wrap,
65  } {}
66 
70  selectable,
71  {},
72  button,
73  wrap,
74  } {}
75 };
76 
GenericSelector::selectable
Selectable< N > & selectable
Definition: Selector.hpp:137
IncrementButton::getState
State getState() const
Return the state of the increment button without updating it.
Definition: IncrementButton.hpp:53
IncrementButton::update
State update()
Update and return the state of the increment button.
Definition: IncrementButton.hpp:46
IncrementSelector
Selector with one button that increments the selection.
Definition: IncrementSelector.hpp:56
GenericIncrementSelector::begin
void begin() override
Initialize this updatable.
Definition: IncrementSelector.hpp:20
Button
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:15
Selectable
Definition: Selectable.hpp:11
IncrementButton::Increment
The counter must be incremented.
Definition: IncrementButton.hpp:40
IncrementButton::begin
void begin()
Definition: IncrementButton.hpp:31
IncrementButton::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementButton.hpp:38
GenericIncrementSelector::wrap
Wrap wrap
Definition: IncrementSelector.hpp:38
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
IncrementButton
A class for buttons that increment some counter or setting.
Definition: IncrementButton.hpp:19
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const Button &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:67
GenericSelector::callback
Callback callback
Definition: Selector.hpp:140
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
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
GenericIncrementSelector::GenericIncrementSelector
GenericIncrementSelector(Selectable< N > &selectable, const Callback &callback, const IncrementButton &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:13
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const IncrementButton &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:58
GenericIncrementSelector::update
void update() override
Update this updatable.
Definition: IncrementSelector.hpp:25
GenericIncrementSelector::getButtonState
IncrementButton::State getButtonState() const
Definition: IncrementSelector.hpp:30
IncrementButton.hpp
Wrap::Wrap
When the maximum (minimum) setting is reached, wrap around to the minimum (maximum) setting.
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition: Selector.hpp:73
GenericIncrementSelector::button
IncrementButton button
Definition: IncrementSelector.hpp:37