Control Surface  1.1.1
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 AH_INDIVIDUAL_BUTTON_INVERT
35  void invert() { button.invert(); }
36 #endif
37 
38  private:
41 };
42 
43 // -------------------------------------------------------------------------- //
44 
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 
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition: Selector.hpp:73
GenericIncrementSelector::button
AH::IncrementButton button
Definition: IncrementSelector.hpp:39
GenericIncrementSelector::begin
void begin() override
Initialize this updatable.
Definition: IncrementSelector.hpp:20
IncrementSelector
Selector with one button that increments the selection.
Definition: IncrementSelector.hpp:58
AH::IncrementButton::begin
void begin()
Definition: IncrementButton.hpp:34
GenericIncrementSelector::invert
void invert()
Definition: IncrementSelector.hpp:35
AH::Button
A class for reading and debouncing buttons and switches.
Definition: Button.hpp:18
GenericIncrementSelector::GenericIncrementSelector
GenericIncrementSelector(Selectable< N > &selectable, const Callback &callback, const AH::IncrementButton &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:13
AH::IncrementButton::State
State
An enumeration of the different actions to be performed by the counter.
Definition: IncrementButton.hpp:41
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
Selectable
Definition: Selectable.hpp:11
IncrementSelector::IncrementSelector
IncrementSelector(Selectable< N > &selectable, const AH::IncrementButton &button, Wrap wrap=Wrap::Wrap)
Definition: IncrementSelector.hpp:60
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
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
AH::IncrementButton::Increment
The counter must be incremented.
Definition: IncrementButton.hpp:43
GenericIncrementSelector::update
void update() override
Update this updatable.
Definition: IncrementSelector.hpp:25
GenericIncrementSelector::getButtonState
AH::IncrementButton::State getButtonState() const
Definition: IncrementSelector.hpp:30
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
AH::IncrementButton::getState
State getState() const
Return the state of the increment button without updating it.
Definition: IncrementButton.hpp:56
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::wrap
Wrap wrap
Definition: IncrementSelector.hpp:40
AH::IncrementButton::invert
void invert()
Definition: IncrementButton.hpp:60
AH::IncrementButton::update
State update()
Update and return the state of the increment button.
Definition: IncrementButton.hpp:49
IncrementButton.hpp
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::selectable
Selectable< N > & selectable
Definition: Selector.hpp:137