tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.23k stars 139 forks source link

error: 'SelectorPC' does not name a type #980

Closed Wallirec closed 10 months ago

Wallirec commented 10 months ago

Hello! I wanted to upload your sketch, but it doesn’t compile, tell me what’s wrong.

#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(); 
}
}
tttapa commented 10 months ago

Where did you find this code? It looks like it was written for an old version of the library.

You could use something like this:

#include <Control_Surface.h>

// Sends Program Change messages for patches 1, 2, 3, 4,
// depending on the active selection.
ProgramChanger<4> pc{{1, 2, 3, 4}, Channel_1};
// Changes the selection of the program from `pc` based
// on the momentary push buttons on pins 11 and 12.
IncrementDecrementSelector<4> sel{pc, {11, 12}};

void setup() {
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}
Wallirec commented 10 months ago

Thank you