Extra switches now customizable from webconf

It seems good. If the switch works as CUIA, i don’t see any reason for not working as MIDI action. Look for the “MIDI SWITCHES SETUP…” in the UI log.

Regards,

Mar 13 22:45:36 zynthian startx[15321]: INFO:zynthian_gui: MIDI SWITCHES SETUP…
Mar 13 22:45:36 zynthian startx[15321]: INFO:zynthian_gui: MIDI ZYNSWITCH 7: 12 CH#15, 1

and when I press
Mar 13 22:47:29 zynthian startx[15321]: INFO:zynthian_gui: Short Switch 7

It looks fine! Try with a channel different from Master and disable the ZS3. You should see the MIDI event in the MIDI log …

Regards,

no midi messages (no blue m in ui neither)

And does it work with Note or CC messages?

no note either. I didn’t test CC

OK! I have it! MIDI send wasn’t implemented in the old zyncoder MCP23008 code (polling zynswitches).
I just created a branch in the zyncoder repository:

zynswitch_poll_midi

Please, test with this branch!

cd /zynthian/zyncoder
git fetch
git checkout zynswitch_poll_midi
git pull
./build.sh
systemctl restart zynthian

Regards,

Great…note works…testing pc now

1 Like

yes, pc as well. and 0 is the first one…like expected. although you could define 0 to load the default…

1 Like

It’s merged on master now :wink:

1 Like

Hi, I added an extra switch to the pin 16 (GPIO23/wPI4) of the RPi4 and I can detect it working from the commandline, but I cannot make zynthian detect it. I tried adding both 4 and 23 to the end of the list of switches in the webconf, but nothing works. Not a single message in the UI log either. Standard buttons on the MCP work well.

Am I missing something? I have to admit that I am not sure about the exact role of the “Wiring Layout” selector. So I have just selected the “Mcp23017 Zynscreen” option. Do I need to switch to another one?

1 Like

Sorry @wanthalf , the current zyncoder code has come limitations and doesn’t allow to mix switches on the RBPi GPIO and MCP2317.

Oh!.. Is it a temporary issue or all the guides about wiring buttons to the RPi just automatically expect that you do not use any MCP at all? Why is there talk about “extra” switches, then - “extra” to what?

Well, I have not studied the code, so I do not know whether you use some python library or just bash scripts, but that should not be a big problem, is it? When seeing the numbers above 100, I just expected a system similar to the IoAbstraction library for Arduinos - but OK, this is a completely different platform, so I should not be surprised and let me confuse by the similar system of PIN numbering.

I see now - the zyncoder module is written in C using the wiringPi library. I will try to have a look at the code, why is it a problem to deal with both an MCP and native GPIO at the same time… I already noticed that multiple MCPs are not supported either (yet?).

I just wanted to note a possible alternative to the port expander is the MPR121 I2C Capacitive touch 12 input chip, with some pins that can also be programmed as GPIO connections (with tricky looking code) , it could do the encoder interface as well as handling a row of panel buttons.
MPR121 Capacitive Touch and GPIO
1 board delivered for $2.33 (4 for $4.60)
These boards might be handy for a controller project, you can have 48 inputs using the 4 different I2C addresses available. Adafruit Writeup . . . Sparkfun

If it did prove reliable handling rotary encoders, you could have web interface selectable touch switch or digital input options on the remaining pins

It could be a good replacement on future hardware versions.

Thanks!

1 Like

It’s not a “real problem”. It could be done, but current code doesn’t allow it because until now nobody tried this combination. That’s all :wink:

Currently you can use these configurations:

  • 1 or 2 x MCP23017 (interrupts)
  • RBPi GPIO for switches & encoders (interrupts) + MCP23008 for switches (polling)

I must apologize because the zyncoder.c code is a mess. It was one of the first pieces of zynthian and it needs a deep refactorization, but as it works quite well and it’s highly critical, i’ve no incentive for prioritizing the task. Mr @riban is pushing to me for doing the task, so perhaps you could joint your forces and increase the pushing … or do the task!!! :rofl:

Regards,

2 Likes

@wyleu would like to add to the push…

2 Likes

@dhrupadiya backs up @riban and @wyleu.

Can’t help with the code itself (not qualified enough), sorry about that !

oh yes plaese, they are some free gpio’s who are waiting to be wired on custom switches :wink: