I want to connect some switches and leds directly to the CORE_STM32F4 via J5a/b ports.
The NG manual shows an example using them as AINs, but not DIN/DOUT. Then i found the tutorial applications (eg polling_j5_pins) which show how to use them on app level.
What i dont get, is there a way to setup these ports and its indivdual pins directly in a .NGC file?
Yes J5 ports are available at .NGC, as analogue input, EVENT_AIN
with “ain_mode=switch” flag you can hook a button on it
You have to enable the input pins with:
Example: # AIN hardware AIN enable\_mask=110000 will enable the J5A.A0 and J5A.A1 inputs.
To connect LED I suppose you have to go deeper in mios32.
If you use toggle switch (and not tact switch) you can solve this with a dual pole version, one for the AIN and one for a LED directly powered by the switch.
Currently no J10 in use for now. I wanted to keep J10a clear if i later want to add an SCS. Therefor J10b would be available.
But the issue i found was, that you can’t have mixed DIN/DOUT on a J10 port. That lead me to the J5 ports. The wiring to core would be a mess for a little board with 2 switches and 2 LEDs.
ps. i want to setup two octave up/down buttons with indication LEDs
i’d like to continue working on my keyboard controller project.
Is there absolutely no way to set up the J5 ports as individual digital IO’s in ngc? I’d like to avoid a cumbersome solution modifing the source code. If there is no easy way, then so be it.
May i ask if it’s possible to simply do the following?
I want to setup J5a to have 2 digital ins and two digital outs.
// init pin 0 and 1 as digital ins (for tact switches) MIOS32\_BOARD\_J5\_PinInit(0, MIOS32\_BOARD\_PIN\_MODE\_INPUT\_PU); MIOS32\_BOARD\_J5\_PinInit(1, MIOS32\_BOARD\_PIN\_MODE\_INPUT\_PU); // init pin 2 and 3 as digital outs (for LEDs) MIOS32\_BOARD\_J5\_PinInit(2, MIOS32\_BOARD\_PIN\_MODE\_OUTPUT\_PP); MIOS32\_BOARD\_J5\_PinInit(3, MIOS32\_BOARD\_PIN\_MODE\_OUTPUT\_PP);
I assume i’d then have J5a:A0..A1 configured as INs and J5a:A2..A3 as OUTs, right?
I got the two LEDs working. I assume the switches will work too.
Now i need some help or hints on the implementation of kb_transpose on these elements. In the end i’d like to have octave up/down tact switches with respective indicator LEDs, as seen on many keyboard controllers.
It looks like i can’t do it via ngc scripts, because there is no event for J5 digital IOs. There is only EVENT_AIN when configured as analog inputs. Is this right?
But where should i put my custom button handler code in the NG app source? Do i need a new variable for the transpose state or is there already one?
What is item.custom_flags.KB.kb_transpose ? It looks like the place where the current transpose value is stored. But how can i modify this value myself?
Edit: Where is “item” coming from? I see it declared as “mbng_event_item_t” but not where it is referenced to any object.