-
hello there, thanks for this amazing library, I just have a question, is there any way to change the rotary encoder module from regular encoder to absolute and back using the switch on the encoder? thanks in advance |
Beta Was this translation helpful? Give feedback.
Answered by
tttapa
Oct 3, 2023
Replies: 1 comment
-
Yes, but you'll have to use the For example (untested): #include <Control_Surface.h>
BEGIN_CS_NAMESPACE
namespace Bankable {
template<uint8_t NumBanks>
struct BorrowedBankableCCAbsoluteEncoder : BorrowedMIDIAbsoluteEncoder<NumBanks, SingleAddress, ContinuousCCSender> {
BorrowedBankableCCAbsoluteEncoder(BankConfig<NumBanks> config, AHEncoder &encoder,
MIDIAddress address, int16_t speedMultiply = 1,
uint8_t pulsesPerStep = 4)
: BorrowedMIDIAbsoluteEncoder<NumBanks, SingleAddress, ContinuousCCSender>{ { config, address }, encoder, speedMultiply, pulsesPerStep, {} } {}
};
struct BorrowedBankableCCRelativeEncoder : BorrowedMIDIRotaryEncoder<SingleAddress, RelativeCCSender> {
BorrowedBankableCCRelativeEncoder(OutputBankConfig<> config, AHEncoder &encoder,
MIDIAddress address, int16_t speedMultiply = 1,
uint8_t pulsesPerStep = 4)
: BorrowedMIDIRotaryEncoder<SingleAddress, RelativeCCSender>{ { config, address }, encoder, speedMultiply, pulsesPerStep, {} } {}
};
} // namespace Bankable
END_CS_NAMESPACE
USBMIDI_Interface midi;
Bank<4> bank;
AHEncoder enc{2, 3};
Bankable::BorrowedBankableCCAbsoluteEncoder<4> abs_enc{bank, enc, MIDI_CC::General_Purpose_Controller_1};
Bankable::BorrowedBankableCCRelativeEncoder rel_enc{bank, enc, MIDI_CC::General_Purpose_Controller_2};
Button mode_switch{4};
void setup() {
mode_switch.begin();
abs_enc.disable();
Control_Surface.begin();
}
void loop() {
auto mode = mode_switch.update();
if (mode == Button::Falling) {
rel_enc.disable();
abs_enc.enable();
} else if (mode == Button::Rising) {
abs_enc.disable();
rel_enc.enable();
}
Control_Surface.loop();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MoSaye
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, but you'll have to use the
Borrowed...
variants, passing the encoder object by reference so it can be shared between the different MIDI elements.For example (untested):