guitarflake
New member
Hi Everyone,
I am working on a project that requires more than 8 encoders (and other peripherals on other Teensy pins). I'm using the EncoderTool library to multiplex 8 of them using a 74hc165 shift register as well as to read values from 2 other encoders (not connected to the shift register). I have set up everything according to the examples on the EncoderTool website, but for some reason the non-multiplexed Encoders are not working (it appears their valueChanged() is returning false even when I turn the knob().
I am using a Teensy 4.0 with the Arduino IDE.
The multiplexed encoders all work fine, but the enc_q encoder does not. I've tried this both using PolledEncoder and interrupt based Encoder class. Any ideas?
Thanks!
Lucas
I am working on a project that requires more than 8 encoders (and other peripherals on other Teensy pins). I'm using the EncoderTool library to multiplex 8 of them using a 74hc165 shift register as well as to read values from 2 other encoders (not connected to the shift register). I have set up everything according to the examples on the EncoderTool website, but for some reason the non-multiplexed Encoders are not working (it appears their valueChanged() is returning false even when I turn the knob().
I am using a Teensy 4.0 with the Arduino IDE.
Code:
//Multiplexed Encoder defs
constexpr int multiplexedEncoderCount = 8;
EncoderTool::EncPlex74165 encoders(multiplexedEncoderCount, shiftReg_LD, shiftReg_CLK, QH_A, QH_B); //move this to setup()?
//enum ENCPLEX_CONTROLS { OSC_VOL, GLIDE, VIBRATO, DECAY, SUSTAIN, RELEASE, FC_LOW, FC_HIGH};
enum ENCPLEX_CONTROLS {FC_HIGH, FC_LOW, RELEASE, SUSTAIN, DECAY, VIBRATO, GLIDE, OSC_VOL};
//Other Encoder defs
EncoderTool::Encoder enc_q;
//Button/LED Defs
Bounce2::Button envFilterBtn = Bounce2::Button();
Bounce2::Button envVolBtn = Bounce2::Button();
//Parameters
int glideTime = 50; //ms
bool gliding = false;
void setup() {
//... other button, SPI pin, and MIDI setup here ...
// Set up multiplexed encoders
encoders.begin(EncoderTool::CountMode::quarterInv);
for (int i = 0; i < multiplexedEncoderCount; i++)
encoders[i].setLimits(0, 127);
// Set up other encoders
enc_q.begin(Q_ENC_A, Q_ENC_B);
// Set up serial (for debugging)
Serial.begin(9600);
}
void loop() {
usbMIDI.read();
// ... Button update code here ...
encoders.tick();
for (int i = 0; i < multiplexedEncoderCount; i++) {
if (encoders[i].valueChanged()) {
Serial.print("\nencoder val changed: ");
Serial.print(i);
switch (i) {
case OSC_VOL:
usbMIDI.sendControlChange(OSCGAIN_CC, encoders[i].getValue(), channel);
break;
case GLIDE:
usbMIDI.sendControlChange(GLIDE_CC, encoders[i].getValue(), channel);
break;
case VIBRATO:
usbMIDI.sendControlChange(VIB_CC, encoders[i].getValue(), channel);
break;
case DECAY:
usbMIDI.sendControlChange(DECAY_CC, encoders[i].getValue(), channel);
break;
case SUSTAIN:
usbMIDI.sendControlChange(SUSTAIN_CC, encoders[i].getValue(), channel);
break;
case RELEASE:
usbMIDI.sendControlChange(RELEASE_CC, encoders[i].getValue(), channel);
break;
case FC_LOW:
usbMIDI.sendControlChange(FC_LOW_CC, encoders[i].getValue(), channel);
break;
case FC_HIGH:
usbMIDI.sendControlChange(FC_HI_CC, encoders[i].getValue(), channel);
break;
}
}
}
//enc_q.tick();
if (enc_q.valueChanged()) usbMIDI.sendControlChange(FILTER_Q_CC, enc_q.getValue(), channel);
}
The multiplexed encoders all work fine, but the enc_q encoder does not. I've tried this both using PolledEncoder and interrupt based Encoder class. Any ideas?
Thanks!
Lucas