Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
IncrementSelector.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>
9class GenericIncrementSelector : public GenericSelector<N, Callback> {
11
12 public:
17
18 void begin() override {
20 button.begin();
21 }
22
23 void update() override {
24 Parent::update();
25 switch (button.update()) {
27 case AH::IncrementButton::IncrementShort: // fallthrough
28 case AH::IncrementButton::IncrementLong: // fallthrough
30 this->increment(Wrap::Wrap);
31 break;
34 default: break;
35 }
36 }
37
41
43 void invert() { button.invert(); }
44
45 private:
47};
48
49// -------------------------------------------------------------------------- //
50
63template <setting_t N>
73
@ 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 reading and debouncing buttons and switches.
Definition Button.hpp:15
A class for buttons that increment some counter or setting.
State
An enumeration of the different actions to be performed by the counter.
@ Nothing
The counter must not be incremented.
@ IncrementShort
The counter must be incremented (after short press).
@ IncrementHold
The counter must be incremented (still pressed).
@ ReleasedLong
The button was released after a long press.
@ IncrementLong
The counter must be incremented (after long press).
@ ReleasedShort
The button was released after a short press.
State getState() const
Return the state of the increment button without updating it.
State update()
Update and return the state of the increment button.
AH::IncrementButton::State getButtonState() const
void update() override
Update this updatable.
void begin() override
Initialize this updatable.
GenericIncrementSelector(Selectable< N > &selectable, const Callback &callback, const AH::IncrementButton &button)
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
Callback callback
Definition Selector.hpp:144
Selectable< N > & selectable
Definition Selector.hpp:141
Selector with one button that increments the selection.
IncrementSelector(Selectable< N > &selectable, const AH::Button &button)
IncrementSelector(Selectable< N > &selectable, const AH::IncrementButton &button)
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32
T * begin()
Get a pointer to the first element.
Definition Array.hpp:74