The way i made the combinations possible was 'outside' of the Control Surface Library. The Multiplexer reading you are using are through the multiplexer are using the Control Surface library.
Button Combination presses are not supported within the library as far as i know, but maybe @PieterP can correct me.
What kind of multiplexer are you using ? and how do you have it connected ?
In other words, how can you read the state of the button that are connected to it, without the Control Surface library ? Show me a simple example and i can take it from there.
OK looking at your schematic and the info on the 74HC4051, you should at least add pullup resistors to the buttons.
Then you can make a MUXread() function that checks the buttons individually, i think i can manage from what i understand from this page by Nick Gammon.
And then it will pretty much work the same way as my sketch.
@PieterP I tried but no luck.
IDE quick suggestion says /* not deduced */
Hi all,
I've changed mux.digitalRead on the variable.
here's how the sketch looks like, it looks right but still doesn't work:
#include <Control_Surface.h>
USBMIDI_Interface midi;
using namespace MIDI_Notes;
CD74HC4051 mux{ 5, { 2, 3, 4 } };
const auto But1 = mux.pin(4);
const auto But2 = mux.pin(6);
const auto But3 = mux.pin(7);
byte butState;
//BUTTONS
NoteButton button1 = {
mux.pin(4),
{ note(Ab, -1), CHANNEL_1 }, // Note on MIDI channel
};
NoteButton button2 = {
mux.pin(6),
{ note(A, -1), CHANNEL_1 }, // Note on MIDI channel
};
NoteButton button3 = {
mux.pin(7),
{ note(Bb, -1), CHANNEL_1 }, // Note on MIDI channel
};
void setup() {
Serial.begin(115200);
Control_Surface.begin();
RelativeCCSender::setMode(relativeCCmode::MACKIE_CONTROL_RELATIVE);
pinMode(But1, INPUT_PULLUP);
pinMode(But2, INPUT_PULLUP);
pinMode(But3, INPUT_PULLUP);
byte but = mux.digitalRead(But1) | mux.digitalRead(But2) << 1 | mux.digitalRead(But3) << 2;
}
void loop() {
Control_Surface.loop();
const MIDIAddress note0 = MIDI_Notes::Eb[1];
const MIDIAddress note1 = MIDI_Notes::E[1];
const uint8_t velocityHIGH = 127;
const uint8_t velocityLOW = 0;
byte but = mux.digitalRead(But1) | mux.digitalRead(But2) << 1 | mux.digitalRead(But3) << 2;
if (butState != but) {
// COMBINATION 1+2
if (but == 0b100) { // pin 1 & 2 pressed
midi.sendNoteOn(note1, velocityHIGH);
} else if (butState == 0b100) { // were pressed, but aren't now
midi.sendNoteOn(note1, velocityLOW);
}
// COMBINATION 1+3
if (but == 0b010) { // pin 1 & 2 pressed
midi.sendNoteOn(note0, velocityHIGH);
} else if (butState == 0b010) {
midi.sendNoteOn(note0, velocityLOW);
}
butState = but;
}
}