Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Cable.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
5#include <AH/Arduino-Wrapper.h> // Print
6#include <Settings/NamespaceSettings.hpp>
7
9
13class Cable {
14 public:
21 explicit constexpr Cable(uint8_t zeroBasedCable)
23
29 constexpr uint8_t getRaw() const { return zeroBasedCable; }
30
36 constexpr uint8_t getOneBased() const { return zeroBasedCable + 1; }
37
44 static constexpr Cable createCable(uint8_t oneBasedCable) {
45 return Cable {static_cast<uint8_t>(oneBasedCable - 1)};
46 }
47
54 constexpr bool operator==(const Cable &rhs) const {
55 return this->zeroBasedCable == rhs.zeroBasedCable;
56 }
57
64 constexpr bool operator!=(const Cable &rhs) const {
65 return this->zeroBasedCable != rhs.zeroBasedCable;
66 }
67
74 Cable &operator+=(uint8_t rhs) {
75 this->zeroBasedCable += rhs;
76 return *this;
77 }
78
85 Cable operator+(uint8_t rhs) const {
86 Cable copy = *this;
87 copy += rhs;
88 return copy;
89 }
90
97 Cable &operator-=(uint8_t rhs) {
98 this->zeroBasedCable -= rhs;
99 return *this;
100 }
101
108 Cable operator-(uint8_t rhs) const {
109 Cable copy = *this;
110 copy -= rhs;
111 return copy;
112 }
113
114 private:
115 uint8_t zeroBasedCable : 4;
116};
117
134
135constexpr Cable CABLE_1 CS_DEPREC("Use Cable_1 instead") = Cable_1;
136constexpr Cable CABLE_2 CS_DEPREC("Use Cable_2 instead") = Cable_2;
137constexpr Cable CABLE_3 CS_DEPREC("Use Cable_3 instead") = Cable_3;
138constexpr Cable CABLE_4 CS_DEPREC("Use Cable_4 instead") = Cable_4;
139constexpr Cable CABLE_5 CS_DEPREC("Use Cable_5 instead") = Cable_5;
140constexpr Cable CABLE_6 CS_DEPREC("Use Cable_6 instead") = Cable_6;
141constexpr Cable CABLE_7 CS_DEPREC("Use Cable_7 instead") = Cable_7;
142constexpr Cable CABLE_8 CS_DEPREC("Use Cable_8 instead") = Cable_8;
143constexpr Cable CABLE_9 CS_DEPREC("Use Cable_9 instead") = Cable_9;
144constexpr Cable CABLE_10 CS_DEPREC("Use Cable_10 instead") = Cable_10;
145constexpr Cable CABLE_11 CS_DEPREC("Use Cable_11 instead") = Cable_11;
146constexpr Cable CABLE_12 CS_DEPREC("Use Cable_12 instead") = Cable_12;
147constexpr Cable CABLE_13 CS_DEPREC("Use Cable_13 instead") = Cable_13;
148constexpr Cable CABLE_14 CS_DEPREC("Use Cable_14 instead") = Cable_14;
149constexpr Cable CABLE_15 CS_DEPREC("Use Cable_15 instead") = Cable_15;
150constexpr Cable CABLE_16 CS_DEPREC("Use Cable_16 instead") = Cable_16;
151
152Print &operator<<(Print &, Cable);
153
constexpr Cable Cable_3
Definition Cable.hpp:120
constexpr Cable CABLE_7
Definition Cable.hpp:141
constexpr Cable Cable_8
Definition Cable.hpp:125
constexpr Cable CABLE_13
Definition Cable.hpp:147
constexpr Cable CABLE_5
Definition Cable.hpp:139
constexpr Cable CABLE_12
Definition Cable.hpp:146
constexpr Cable Cable_14
Definition Cable.hpp:131
constexpr Cable CABLE_14
Definition Cable.hpp:148
constexpr Cable CABLE_10
Definition Cable.hpp:144
constexpr Cable CABLE_16
Definition Cable.hpp:150
constexpr Cable CABLE_9
Definition Cable.hpp:143
constexpr Cable CABLE_11
Definition Cable.hpp:145
constexpr Cable Cable_13
Definition Cable.hpp:130
constexpr Cable Cable_16
Definition Cable.hpp:133
constexpr Cable CABLE_3
Definition Cable.hpp:137
constexpr Cable Cable_7
Definition Cable.hpp:124
Print & operator<<(Print &, Cable)
Definition Cable.cpp:6
constexpr Cable CABLE_8
Definition Cable.hpp:142
constexpr Cable Cable_4
Definition Cable.hpp:121
constexpr Cable Cable_10
Definition Cable.hpp:127
constexpr Cable Cable_12
Definition Cable.hpp:129
constexpr Cable Cable_11
Definition Cable.hpp:128
constexpr Cable Cable_9
Definition Cable.hpp:126
constexpr Cable CABLE_1
Definition Cable.hpp:135
constexpr Cable Cable_2
Definition Cable.hpp:119
constexpr Cable CABLE_6
Definition Cable.hpp:140
constexpr Cable CABLE_2
Definition Cable.hpp:136
constexpr Cable CABLE_4
Definition Cable.hpp:138
constexpr Cable CABLE_15
Definition Cable.hpp:149
constexpr Cable Cable_5
Definition Cable.hpp:122
constexpr Cable Cable_6
Definition Cable.hpp:123
constexpr Cable Cable_15
Definition Cable.hpp:132
constexpr Cable Cable_1
Definition Cable.hpp:118
#define CS_DEPREC(...)
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A type-safe class for MIDI USB Cable numbers.
Definition Cable.hpp:13
Cable & operator+=(uint8_t rhs)
Add an offset.
Definition Cable.hpp:74
static constexpr Cable createCable(uint8_t oneBasedCable)
Create a cable.
Definition Cable.hpp:44
uint8_t zeroBasedCable
Definition Cable.hpp:115
constexpr bool operator==(const Cable &rhs) const
Check if two cables are the same.
Definition Cable.hpp:54
constexpr bool operator!=(const Cable &rhs) const
Check if two cables are the different.
Definition Cable.hpp:64
Cable operator-(uint8_t rhs) const
Subtract an offset from a cable.
Definition Cable.hpp:108
constexpr uint8_t getOneBased() const
Get the cable as an integer.
Definition Cable.hpp:36
constexpr Cable(uint8_t zeroBasedCable)
Create a MIDI Cable object.
Definition Cable.hpp:21
constexpr uint8_t getRaw() const
Get the cable as an integer.
Definition Cable.hpp:29
Cable & operator-=(uint8_t rhs)
Subtract an offset.
Definition Cable.hpp:97
Cable operator+(uint8_t rhs) const
Add an offset to a cable.
Definition Cable.hpp:85