Mode Possibility

Status
Not open for further replies.

mtiger

Well-known member
Hi all,

I'm wondering if it is possible to achieve the following regarding button / mode states:

Mode Button = when selected, enters into a mode state from 0 to 1 (low to high)

8 select buttons = each button when selected, stores a set of 8 CC values then returns and exits back to Mode Button (State 0)

Then, when back in Mode state '0', each of the 8 values that were set to each button then send a single Midi CC message through the 8 buttons.

For example:
Mode Button = Toggled from LOW to HIGH = State 1
State 1 = 8 buttons (each holding 8 CC values).
User selects one of the buttons and State 1 is toggled back to '0'.

State 0 = Buttons 1 to 8, send different CC messages that were originally stored.


Its like a Bank selection. Toggling from State 0 to 1, opens up the bank selection option for the user to then chose a button (from 8) which then defines the output when State returns back to '0'.

Hope that makes sense.

I haven't come across this sort of logic so hoping someone could advise of the best possible logic to achieve this.
 
Is this a course related question?

Normal process would be a state machine, each press of the mode button increments the mode variable, wrapping if higher than 4.

If the state button is pressed you look up the current mode variable and decide what to do based on that. If you doing things like setting audio values you can keep what 1-8 of the 1-4 possible options in one array, and store the 4 final values in a different one, avoiding flocks of if statements.
 
This feature is often called 'bank' and using a two-dimensional array makes it a fairly simple addition once you have a basic version working using a stanard array to hold data values.

Here's a line of code from a note controller but it would be very similar with CC messages.

usbMIDI.sendNoteOn(note[bank], velocity, channel);

Where 'bank' is the mode variable set separately and 'i' is the index of the triggered switch.

This separates scanning event buttons and setting the mode/bank variable.

Are you familiar with arrays?

https://forum.pjrc.com/threads/43263-How-to-change-midi-notes-using-buttons-(usb-midi)
 
Last edited:
Appreciate your responses guys.
No, this is not a course related question. Deciding on the logic for a specific controller project.

In state '1', the 8 buttons are more of a 'select' button of predefined variables consisting of either 8 CC or midiNoteOn. Then once selected, state '1' returns to state '0', and the 8 buttons become individual buttons sending either CC or midiNoteOn.

Yes, i'm aware of arrays. However working with multiplexers (4067) specifically has made it more confusing. As not only is there the multi dimensional array table for the mux pins, but also the pre-defined bank CC or bank noteOn/off selection.
 
Last edited:
Ok so here is my logic of sorts

Button 1 = MODE Button (Two States (0 / 1)

//Button Stored Value Banks/Array
Button 2 = (0, 1, 2, 3, 4, 5, 6, 7)
Button 3 = (8, 9, 10, 11, 12, 13, 14, 15)
Button 4 = (16, 17, 18, 19, 20, 21, 22, 23)
Button 5 = (24, 25, 26, 27, 28, 29, 30, 31)
Button 6 = (32, 33, 34, 35, 36, 37, 37, 38)
Button 7 = (39, 40, 41, 42, 43, 44, 45, 46)
Button 8 = (47, 48, 49, 50, 51, 52, 53, 54)
Button 9 = (55, 56, 57, 58, 59, 60, 61, 62)

If Button 1 (Mode Button) = 0
Buttons 2 - 9 would have the value of Button 2 Array - By Default*

If Button 1 (Mode Button) = 1
User selects from Button 2 - 9 (choosing which values to distribute), and Mode Button returns back to 0.

Then if Button 1 (Mode Button) = 0
Buttons 2 - 9 would have the value of which ever 'bank of values' the user selected.

Any help on this would be marvellous as can't wrap my head around first, the arduino logic and secondly using a mux for it all.
 
There's no reason not to use three dimensions if that's what your code calls for.
You set you MUX outputs and digital read thru each pin and then send CC on fallingEdge()

usbMIDI.sendControlChange(control[pin][muxChnl][bank], 127, channel);

Or you could merge them together into a button variable by taking pin*8+muxChnl

usbMIDI.sendControlChange(control[pin*8+muxChnl][bank], 127, channel);

The hardest part is typing the string of characters in the setup that loads the array correctly.

The modal behaviour is simple. If the mode button is not one of the pins used with the mux I would keep it's logic separate.

You just need to toggle the global MODE variable whenever the pin is pulled low --i.e. fallingEdge().

If MODE is true then instead of sending the CC messages it sets the bank variable to the desired integer.
 
Status
Not open for further replies.
Back
Top