This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
Def.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
5 #include "Channel.hpp"
6 #include "Frequency.hpp"
7 #include <Helpers/Array.hpp>
9 #include <stddef.h> // size_t
10 #include <stdint.h> // uint8_t
11 
13 
15 using analog_t = uint16_t;
17 using pin_t = uint16_t;
18 
19 #ifdef NO_PIN // Fix for FastLED: https://github.com/FastLED/FastLED/issues/893
20 #undef NO_PIN
21 #endif
22 
24 constexpr pin_t NO_PIN = 1 << (8 * sizeof(pin_t) - 1);
25 
29 
31 template <class T, size_t nb_rows, size_t nb_cols>
32 using Array2D = Array<Array<T, nb_cols>, nb_rows>;
33 
35 template <uint8_t nb_rows, uint8_t nb_cols>
37 
39 template <size_t N>
41 
44  // TODO: why do I need explicit constructors?
45  EncoderSwitchPinList(uint8_t A, uint8_t B, pin_t switchPin)
46  : A(A), B(B), switchPin(switchPin) {}
47  EncoderSwitchPinList(uint8_t A, uint8_t B)
48  : A(A), B(B), switchPin(NO_PIN) {}
49 
50  uint8_t A;
51  uint8_t B;
53 };
55 
58  uint8_t A;
59  uint8_t B;
60 };
61 
63 using setting_t = uint8_t;
65 constexpr setting_t NO_SETTING = 1 << (8 * sizeof(setting_t) - 1);
66 
67 // Updatable types:
68 struct NormalUpdatable {};
69 struct Potentiometer {};
70 struct MotorFader {};
71 struct Display {};
72 
74 struct PixelLocation {
75  int16_t x;
76  int16_t y;
77 };
78 
79 #define UNUSED_PARAM __attribute__((unused))
80 
NormalUpdatable
Definition: Def.hpp:68
pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Def.hpp:17
EncoderPinList::A
uint8_t A
The pin connected to the A pin of the encoder.
Definition: Def.hpp:58
MotorFader
Definition: Def.hpp:70
Array
An array wrapper for easy copying, comparing, and iterating.
Definition: Array.hpp:20
PixelLocation
A simple struct representing a pixel with integer coordinates.
Definition: Def.hpp:74
Array.hpp
EncoderSwitchPinList::EncoderSwitchPinList
EncoderSwitchPinList(uint8_t A, uint8_t B, pin_t switchPin)
Definition: Def.hpp:45
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
analog_t
uint16_t analog_t
The type returned from analogRead and similar functions.
Definition: Def.hpp:15
EncoderSwitchPinList::B
uint8_t B
The pin connected to the B pin of the encoder.
Definition: Def.hpp:51
Channel.hpp
NO_SETTING
constexpr setting_t NO_SETTING
A special setting that indicates an unused or invalid setting.
Definition: Def.hpp:65
Frequency.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
NamespaceSettings.hpp
Display
Definition: Def.hpp:71
Potentiometer
Definition: Def.hpp:69
EncoderSwitchPinList::EncoderSwitchPinList
EncoderSwitchPinList(uint8_t A, uint8_t B)
Definition: Def.hpp:47
setting_t
uint8_t setting_t
The type used for Selectors.
Definition: Def.hpp:63
EncoderPinList
A struct for the pins of a rotary (quadrature) encoder without a switch.
Definition: Def.hpp:57
EncoderSwitchPinList::switchPin
pin_t switchPin
The pin connected to the switch pin of the encoder.
Definition: Def.hpp:52
PixelLocation::x
int16_t x
Definition: Def.hpp:75
PixelLocation::y
int16_t y
Definition: Def.hpp:76
NO_PIN
constexpr pin_t NO_PIN
A special pin number that indicates an unused or invalid pin.
Definition: Def.hpp:24
MappingFunction
analog_t(*)(analog_t) MappingFunction
A function pointer to a mapping function to map analog values.
Definition: Def.hpp:28
EncoderPinList::B
uint8_t B
The pin connected to the B pin of the encoder.
Definition: Def.hpp:59
EncoderSwitchPinList::A
uint8_t A
The pin connected to the A pin of the encoder.
Definition: Def.hpp:50
EncoderSwitchPinList
A struct for the pins of a rotary (quadrature) encoder with a switch.
Definition: Def.hpp:43