Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
ManyButtonsSelector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Selector.hpp"
6#include <Def/Def.hpp>
7
9
10template <setting_t N, class Callback = EmptySelectorCallback>
11class GenericManyButtonsSelector : public GenericSelector<N, Callback> {
13
14 public:
20
21 void begin() override {
23 for (auto &btn : buttons)
24 btn.begin();
25 }
26
27 void update() override {
28 Parent::update();
29 for (setting_t i = 0; i < N; i++)
31 buttons[this->get()].getState() != AH::Button::Pressed)
32 this->set(i);
33 }
34
35 void invert() {
36 for (auto &btn : buttons)
37 btn.invert();
38 }
39
40 private:
42};
43
44// -------------------------------------------------------------------------- //
45
60template <setting_t N>
70
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
@ Pressed
Input went from low to low (0,0)
Definition Button.hpp:46
@ Falling
Input went from high to low (1,0)
Definition Button.hpp:48
void update() override
Update this updatable.
AH::Array< AH::Button, N > buttons
GenericManyButtonsSelector(Selectable< N > &selectable, const Callback &callback, const PinList< N > &buttonPins)
void begin() override
Initialize this updatable.
void set(setting_t newSetting)
Select the given selection.
Definition Selector.hpp:93
Callback callback
Definition Selector.hpp:144
Selectable< N > & selectable
Definition Selector.hpp:141
Selector that reads from buttons.
ManyButtonsSelector(Selectable< N > &selectable, const PinList< N > &buttonPins)
setting_t get() const
Get the current selection/setting.
Definition Selector.hpp:46
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