Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Selectable.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <AH/Error/Error.hpp>
4#include <AH/STL/type_traits>
5#include <Def/Def.hpp>
6#include <stdint.h>
7
9
10template <setting_t N> // TODO: check bounds here?
12 protected:
15
16 public:
17 virtual void select(setting_t setting) = 0;
18
20 static_assert(std::is_unsigned<setting_t>::value,
21 "Error: setting_t should be an unsigned integer type.");
22 if (setting >= N) {
23 ERROR(F("Error: Setting ")
24 << setting
25 << F(" is not less than the number of settings (") << N
26 << ')',
27 0xFFFE);
28 return N - 1;
29 }
30 return setting;
31 }
32
34
38
39 private:
41};
42
uint8_t setting_t
The type used for Selectors.
Definition Def.hpp:51
#define ERROR(msg, errc)
Definition Error.hpp:19
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
setting_t initialSelection
setting_t getInitialSelection() const
Selectable(setting_t initialSelection=0)
void setInitialSelection(setting_t initialSelection)
static setting_t validateSetting(setting_t setting)
virtual void select(setting_t setting)=0