-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shared / borrowed encoder #887
Comments
This is the compilation error I get when trying to compile the example from the thread `/private/var/folders/mx/kjcsv4q907jblll2vbk5807w0000gn/T/.arduinoIDE-unsaved202318-2467-1jcxd3g.ygz3k/sketch_feb8a/sketch_feb8a.ino:16:1: error: could not convert '{enc, CS::MCU::V_POT_1, 1, 4, ()}' from '' to 'CS::BorrowedMIDIRotaryEncoderCS::ContinuousCCSender {aka CS::GenericMIDIRotaryEncoder<CS::AHEncoder&, CS::ContinuousCCSender>}' Compilation error: could not convert '{enc, CS::MCU::V_POT_1, 1, 4, ()}' from '' to 'CS::BorrowedMIDIRotaryEncoderCS::ContinuousCCSender {aka CS::GenericMIDIRotaryEncoder<CS::AHEncoder&, CS::ContinuousCCSender>}'` |
Untested, but this should compile using the latest version (02374bc): #include <Control_Surface.h>
USBDebugMIDI_Interface midi;
Button button {4};
AHEncoder enc {2, 3};
BorrowedMIDIRotaryEncoder<ContinuousCCSender> ccenc {
enc,
MCU::V_POT_1,
1, // multiplier
4, // pulses per step
{}, // MIDI sender
};
BorrowedMIDIAbsoluteEncoder<PitchBendSender<14>> pbenc {
enc,
CHANNEL_1,
127, // multiplier
4, // pulses per step
{}, // MIDI sender
};
void setup() {
button.begin();
Control_Surface.begin();
pbenc.disable();
}
void loop() {
Control_Surface.loop();
auto buttonState = button.update();
if (buttonState == Button::Falling) {
ccenc.disable();
pbenc.resetPositionOffset();
pbenc.enable();
} else if (buttonState == Button::Rising) {
pbenc.disable();
ccenc.resetPositionOffset();
ccenc.enable();
}
} |
Thank you Pieter for looking into this, it sure does compile, but nothing comes up in the serial monitor. I've double checked my wiring, and checked if the sketch works with each encoder object individually, and it does. However, when introducing both encoder objects at the same time while disabling one of them, nothing shows in serial monitor.
I am really at the boundaries of my knowledge here, so any help or pointers in the right direction is hugely appreciated :) |
I think the issue that the encoder is initialized twice, and the second time, it raises an error because the interrupts are already in use. You can try moving the Alternatively, you can try 39182bb, which should make initializing encoders multiple times no longer fail. |
Fantastic! |
In my project I am sharing a rotary encoder between an instance of PBAbsoluteEncoder and an instance of CCRotaryEncoder by physically switching pins with a switch. However I would like to make this more simple, perhaps with a small button switch or maybe one of the multipurposebutton commands, and wonder if it could be done with code. I've looked at this but it seems to be outdated. Any help is greatly appreciated
The text was updated successfully, but these errors were encountered: