Control Surface - Disable all CCRotaryEncoders

Hi all,

still working/learning on the mighty Control-Surface library.

I have a 3 buttons & 3 encoders circuit.
Would it be possible to disable all the CCRotaryEncoders whenever a Note button is pressed.

I tried flagging the encoders but it didn't work:

bool allencodersEnabled = true;                             // Flag to enable/disable all
OR
bool allCCEncodersEnabled = true;                             // Flag to enable/disable all

Any ideas? Thanks

CCRotaryEncoder encoders[] { ... };

void loop() {
  Control_Surface.loop();
  if (/* button pressed */) {
    for (auto &enc : encoders)
      enc.disable();
  } else if (/* button released */) {
    for (auto &enc : encoders)
      enc.enable();
  }
}
1 Like

Thanks @PieterP.

CCRotaryEncoder encoders[3] {
{21, 20},      //pins of encoder 1
{19, 18},      //pins of encoder 2
{15, 14}       //pins of encoder 3
};

But now can I create an array of encoders? Or more specifically, I can set the MIDI address to each encoder?
Thank you!

Use a pair of braces for each level of initialization: one for the array, one for each element of the array, one for each argument to the CCRotaryEncoder constructor (if it is initialized with more than one values).

For example:

CCRotaryEncoder encoders[] {
  {{21, 20}, {0x10, Channel_1}},
  {{19, 18}, {0x10, Channel_2}},
  {{15, 14}, {0x10, Channel_3}},
};
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.