Control Surface main
MIDI Control Surface library for Arduino
No Matches
Go to the documentation of this file.
1/* ✔ */
3#pragma once
5#include <AH/Arduino-Wrapper.h> // Print
6#include <Settings/NamespaceSettings.hpp>
13class Channel {
14 public:
21 explicit constexpr Channel(uint8_t zeroBasedChannel)
29 constexpr uint8_t getRaw() const { return zeroBasedChannel; }
36 constexpr uint8_t getOneBased() const { return zeroBasedChannel + 1; }
44 static constexpr Channel createChannel(uint8_t oneBasedChannel) {
45 return Channel {uint8_t(oneBasedChannel - 1)};
46 }
54 constexpr bool operator==(const Channel &rhs) const {
55 return this->zeroBasedChannel == rhs.zeroBasedChannel;
56 }
64 constexpr bool operator!=(const Channel &rhs) const {
65 return this->zeroBasedChannel != rhs.zeroBasedChannel;
66 }
74 Channel &operator+=(uint8_t rhs) {
75 this->zeroBasedChannel += rhs;
76 return *this;
77 }
85 Channel operator+(uint8_t rhs) const {
86 Channel copy = *this;
87 copy += rhs;
88 return copy;
89 }
97 Channel &operator-=(uint8_t rhs) {
98 this->zeroBasedChannel -= rhs;
99 return *this;
100 }
108 Channel operator-(uint8_t rhs) const {
109 Channel copy = *this;
110 copy -= rhs;
111 return copy;
112 }
114 private:
115 uint8_t zeroBasedChannel : 4;
135#ifndef CHANNEL_1 // ArduinoCore-renesas defines this
136constexpr Channel CHANNEL_1 CS_DEPREC("Use Channel_1 instead") = Channel_1;
137constexpr Channel CHANNEL_2 CS_DEPREC("Use Channel_2 instead") = Channel_2;
138constexpr Channel CHANNEL_3 CS_DEPREC("Use Channel_3 instead") = Channel_3;
139constexpr Channel CHANNEL_4 CS_DEPREC("Use Channel_4 instead") = Channel_4;
140constexpr Channel CHANNEL_5 CS_DEPREC("Use Channel_5 instead") = Channel_5;
141constexpr Channel CHANNEL_6 CS_DEPREC("Use Channel_6 instead") = Channel_6;
142constexpr Channel CHANNEL_7 CS_DEPREC("Use Channel_7 instead") = Channel_7;
143constexpr Channel CHANNEL_8 CS_DEPREC("Use Channel_8 instead") = Channel_8;
144constexpr Channel CHANNEL_9 CS_DEPREC("Use Channel_9 instead") = Channel_9;
145constexpr Channel CHANNEL_10 CS_DEPREC("Use Channel_10 instead") = Channel_10;
146constexpr Channel CHANNEL_11 CS_DEPREC("Use Channel_11 instead") = Channel_11;
147constexpr Channel CHANNEL_12 CS_DEPREC("Use Channel_12 instead") = Channel_12;
148constexpr Channel CHANNEL_13 CS_DEPREC("Use Channel_13 instead") = Channel_13;
149constexpr Channel CHANNEL_14 CS_DEPREC("Use Channel_14 instead") = Channel_14;
150constexpr Channel CHANNEL_15 CS_DEPREC("Use Channel_15 instead") = Channel_15;
151constexpr Channel CHANNEL_16 CS_DEPREC("Use Channel_16 instead") = Channel_16;
154Print &operator<<(Print &, Channel);
constexpr Channel Channel_7
Definition Channel.hpp:124
constexpr Channel Channel_12
Definition Channel.hpp:129
constexpr Channel CHANNEL_2
Definition Channel.hpp:137
constexpr Channel Channel_6
Definition Channel.hpp:123
constexpr Channel CHANNEL_1
Definition Channel.hpp:136
constexpr Channel Channel_3
Definition Channel.hpp:120
constexpr Channel CHANNEL_11
Definition Channel.hpp:146
constexpr Channel CHANNEL_10
Definition Channel.hpp:145
constexpr Channel CHANNEL_12
Definition Channel.hpp:147
constexpr Channel Channel_1
Definition Channel.hpp:118
constexpr Channel CHANNEL_15
Definition Channel.hpp:150
constexpr Channel CHANNEL_6
Definition Channel.hpp:141
constexpr Channel Channel_2
Definition Channel.hpp:119
constexpr Channel Channel_14
Definition Channel.hpp:131
constexpr Channel CHANNEL_9
Definition Channel.hpp:144
constexpr Channel Channel_16
Definition Channel.hpp:133
constexpr Channel CHANNEL_13
Definition Channel.hpp:148
constexpr Channel CHANNEL_3
Definition Channel.hpp:138
constexpr Channel CHANNEL_4
Definition Channel.hpp:139
constexpr Channel CHANNEL_14
Definition Channel.hpp:149
constexpr Channel Channel_13
Definition Channel.hpp:130
constexpr Channel CHANNEL_5
Definition Channel.hpp:140
constexpr Channel Channel_9
Definition Channel.hpp:126
constexpr Channel Channel_4
Definition Channel.hpp:121
constexpr Channel CHANNEL_7
Definition Channel.hpp:142
constexpr Channel Channel_10
Definition Channel.hpp:127
constexpr Channel Channel_5
Definition Channel.hpp:122
constexpr Channel Channel_15
Definition Channel.hpp:132
constexpr Channel Channel_11
Definition Channel.hpp:128
constexpr Channel CHANNEL_16
Definition Channel.hpp:151
constexpr Channel CHANNEL_8
Definition Channel.hpp:143
constexpr Channel Channel_8
Definition Channel.hpp:125
Print & operator<<(Print &, Channel)
Definition Channel.cpp:6
#define CS_DEPREC(...)
A type-safe class for MIDI channels.
Definition Channel.hpp:13
uint8_t zeroBasedChannel
Definition Channel.hpp:115
Channel & operator+=(uint8_t rhs)
Add an offset.
Definition Channel.hpp:74
constexpr Channel(uint8_t zeroBasedChannel)
Create a MIDI Channel object.
Definition Channel.hpp:21
Channel operator+(uint8_t rhs) const
Add an offset to a channel.
Definition Channel.hpp:85
static constexpr Channel createChannel(uint8_t oneBasedChannel)
Create a channel.
Definition Channel.hpp:44
constexpr uint8_t getOneBased() const
Get the channel as an integer.
Definition Channel.hpp:36
constexpr bool operator!=(const Channel &rhs) const
Check if two channels are the different.
Definition Channel.hpp:64
constexpr uint8_t getRaw() const
Get the channel as an integer.
Definition Channel.hpp:29
Channel & operator-=(uint8_t rhs)
Subtract an offset.
Definition Channel.hpp:97
Channel operator-(uint8_t rhs) const
Subtract an offset from a channel.
Definition Channel.hpp:108
constexpr bool operator==(const Channel &rhs) const
Check if two channels are the same.
Definition Channel.hpp:54