Skip to content

Commit

Permalink
Add channel to SelectorPC
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Apr 25, 2018
1 parent 8959923 commit fadf0de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
7 changes: 4 additions & 3 deletions examples/Ex.16.SelectorPC/Ex.16.SelectorPC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

#include <Control_Surface.h> // 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

void loop() {
// Refresh the control surface, send a Program Change
// event when the patch number changes
Control_Surface.refresh();
}
}
5 changes: 3 additions & 2 deletions src/MIDI_Outputs/Analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

// =========================================================================================== //
Expand Down Expand Up @@ -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_
18 changes: 9 additions & 9 deletions src/Selectors/SelectorPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ class SelectorPC : public Selector
{
public:
template <class A, size_t N, class... Args>
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 <class A, class T, size_t N>
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 <class A, class T, class S, size_t N, size_t M>
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 <class A, class T, size_t N, size_t M>
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);
Expand All @@ -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

0 comments on commit fadf0de

Please sign in to comment.