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
44 return buttons.getState();
45 }
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.
Definition Selector.hpp:17
#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.
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)
GenericSelector(Selectable< N > &selectable, const EmptySelectorCallback &callback)
Definition Selector.hpp:69
IncrementDecrementSelector(Selectable< N > &selectable, const AH::IncrementDecrementButtons &buttons, Wrap wrap=Wrap::Wrap)