diff --git a/examples/Ex.16.SelectorPC/Ex.16.SelectorPC.ino b/examples/Ex.16.SelectorPC/Ex.16.SelectorPC.ino index 5344cdce6c..fca2a19b71 100644 --- a/examples/Ex.16.SelectorPC/Ex.16.SelectorPC.ino +++ b/examples/Ex.16.SelectorPC/Ex.16.SelectorPC.ino @@ -16,10 +16,11 @@ #include // Include the library -// Patch Selector selecting patches 1, 2, 3 or 4, +const uint8_t channel = 1; +// Patch Selector selecting patches 1, 2, 3 or 4 on MIDI channel 1, // increment patch number with button connected to pin 11, // decrement patch number with button connected to pin 12 -SelectorPC sel( { 1, 2, 3, 4 }, { 11, 12 } ); +SelectorPC sel( { 1, 2, 3, 4 }, channel, { 11, 12 } ); void setup() {} // Nothing to set up @@ -27,4 +28,4 @@ void loop() { // Refresh the control surface, send a Program Change // event when the patch number changes Control_Surface.refresh(); -} +} \ No newline at end of file diff --git a/src/MIDI_Outputs/Analog.h b/src/MIDI_Outputs/Analog.h index 8ffde9f046..bb4785d896 100755 --- a/src/MIDI_Outputs/Analog.h +++ b/src/MIDI_Outputs/Analog.h @@ -90,7 +90,8 @@ class AnalogCC : public AnalogBase virtual void send(unsigned int value); uint8_t oldVal = -1; - uint8_t controller, channel; + const uint8_t controller; + const uint8_t channel; }; // =========================================================================================== // @@ -126,7 +127,7 @@ class AnalogPB : public AnalogBase virtual void send(unsigned int value); uint16_t oldVal = -1; - uint8_t channel; + const uint8_t channel; }; #endif // ANALOG_h_ diff --git a/src/Selectors/SelectorPC.h b/src/Selectors/SelectorPC.h index 89939a0af2..9f3337700f 100644 --- a/src/Selectors/SelectorPC.h +++ b/src/Selectors/SelectorPC.h @@ -11,30 +11,30 @@ class SelectorPC : public Selector { public: template - SelectorPC(const A (&addresses)[N], Args... args) - : Selector(args...) + SelectorPC(const A (&addresses)[N], uint8_t channel, Args... args) + : Selector(args...), channel(channel) { this->addresses = new uint8_t[nb_settings]; copy(this->addresses, addresses); } // initializer_lists are not supported with variadic templates, so overload them manually template - SelectorPC(const A (&addresses)[N], const T (&switchPins)[N]) - : Selector((const pin_t (&)[N])switchPins) // Multiple buttons, no LEDs + SelectorPC(const A (&addresses)[N], uint8_t channel, const T (&switchPins)[N]) + : Selector((const pin_t (&)[N])switchPins), channel(channel) // Multiple buttons, no LEDs { this->addresses = new uint8_t[nb_settings]; copy(this->addresses, addresses); } template - SelectorPC(const A (&addresses)[M], const T (&switchPins)[N], const S (&ledPins)[M]) - : Selector((const pin_t (&)[N])switchPins, (const pin_t (&)[M])ledPins) // One (+1), two (+1, -1) or multiple buttons, multiple LEDs + SelectorPC(const A (&addresses)[M], uint8_t channel, const T (&switchPins)[N], const S (&ledPins)[M]) + : Selector((const pin_t (&)[N])switchPins, (const pin_t (&)[M])ledPins), channel(channel) // One (+1), two (+1, -1) or multiple buttons, multiple LEDs { this->addresses = new uint8_t[nb_settings]; copy(this->addresses, addresses); } template - SelectorPC(const A (&addresses)[M], const T (&switchPins)[N]) - : Selector((const pin_t (&)[N])switchPins, M) // One (+1) or two (+1, -1) buttons, no LEDs + SelectorPC(const A (&addresses)[M], uint8_t channel, const T (&switchPins)[N]) + : Selector((const pin_t (&)[N])switchPins, M), channel(channel) // One (+1) or two (+1, -1) buttons, no LEDs { this->addresses = new uint8_t[nb_settings]; copy(this->addresses, addresses); @@ -53,7 +53,7 @@ class SelectorPC : public Selector } uint8_t *addresses = nullptr; - const uint8_t channel = 0; + const uint8_t channel; }; #endif // SELECTOR_OUT_H