Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
IncrementDecrementSelector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Selector.hpp"
5
7
8template <setting_t N, class Callback = EmptySelectorCallback>
11
12 public:
18
19 void begin() override {
21 buttons.begin();
22 }
23
24 void update() override {
26 using IncrDecrButtons = AH::IncrementDecrementButtons;
27 switch (buttons.update()) {
28 case IncrDecrButtons::Nothing: break;
29 case IncrDecrButtons::IncrementShort: // fallthrough
30 case IncrDecrButtons::IncrementLong: // fallthrough
31 case IncrDecrButtons::IncrementHold: this->increment(wrap); break;
32 case IncrDecrButtons::DecrementShort: // fallthrough
33 case IncrDecrButtons::DecrementLong: // fallthrough
34 case IncrDecrButtons::DecrementHold: this->decrement(wrap); break;
35 case IncrDecrButtons::Reset: this->reset(); break;
36 default: break;
37 }
38 }
39
41 void invert() { buttons.invert(); }
42
46
47 private:
50};
51
52// -------------------------------------------------------------------------- //
53
68template <setting_t N>
81
Wrap
An enumeration to set the behavior of selectors that are incremented (decremented) beyond their maxim...
Definition Selector.hpp:14
@ Wrap
When the maximum (minimum) setting is reached, wrap around to the minimum (maximum) setting.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class for buttons that increment and decrement some counter or setting.
State
An enumeration of the different actions to be performed by the counter.
State getState() const
Return the state of the increment/decrement button without updating it.
State update()
Update and return the state of the increment/decrement button.
AH::IncrementDecrementButtons::State getButtonsState() const
void update() override
Update this updatable.
void begin() override
Initialize this updatable.
GenericIncrementDecrementSelector(Selectable< N > &selectable, const Callback &callback, const AH::IncrementDecrementButtons &buttons, Wrap wrap=Wrap::Wrap)
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:109
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:128
Callback callback
Definition Selector.hpp:144
void update() override
Update this updatable.
Definition Selector.hpp:77
Selectable< N > & selectable
Definition Selector.hpp:141
void begin() override
Initialize this updatable.
Definition Selector.hpp:72
void reset()
Reset the selection to the initial selection.
Definition Selector.hpp:80
Selector with two buttons (one to increment, one to decrement).
IncrementDecrementSelector(Selectable< N > &selectable, const AH::IncrementDecrementButtons &buttons, Wrap wrap=Wrap::Wrap)