Replies: 1 comment 2 replies
-
The problem is that you cannot have two encoders on the same pins. The solution is to create a single encoder object separately, and then share it between the different MIDI encoder objects: #include <Control_Surface.h> // https://github.com/tttapa/Control-Surface
#include <AH/Hardware/MultiPurposeButton.hpp>
// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;
AHEncoder enc{2, 3};
// Trim
BorrowedMIDIAbsoluteEncoder<ContinuousCCSender> cc_enc {
enc,
MCU::V_POT_7,
1, 4, {},
};
// Fader
BorrowedMIDIAbsoluteEncoder<PitchBendSender<10>> pb_enc {
enc,
Channel_7,
1, 4, {},
};
MultiPurposeButton btn{6};
enum class EncoderMode {
PitchBend, ControlChange
} mode = EncoderMode::PitchBend;
void setup() {
Serial.begin(115200);
btn.setLongPressDelay(1000);
btn.setMultiPressDelay(400);
btn.begin();
// Disable the second encoder before calling Control_Surface.begin(),
// so the encoder doesn't get initialized twice:
cc_enc.disable(); // Default state
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
switch (btn.update()) {
case btn.None: break;
case btn.LongPress:
if(mode == EncoderMode::PitchBend) {
Serial.println("cc");
pb_enc.disable();
cc_enc.resetPositionOffset();
cc_enc.enable();
mode = EncoderMode::ControlChange;
} else {
Serial.println("pb");
cc_enc.disable();
pb_enc.resetPositionOffset();
pb_enc.enable();
mode = EncoderMode::PitchBend;
}
break;
}
Control_Surface.loop(); // Update the Control Surface
} Also note the calls to |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am working on a Trim/Fader unit for channel 7 on my Sound Devices 833 unit.
The idea is that using 1 encoder can control both trim and fader by double pressing on the switch
The problem I'm having is that Trim uses CCRotaryEncoder and Fade uses PBAbsoluteEncoder and using MultiplePurpose button I can't get it to toggle between the two. resulting in no midi signal being sent at all.
Beta Was this translation helpful? Give feedback.
All reactions