Jump to content

Assign J5a/b core ports in .NGC


tago

Recommended Posts

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?

Link to comment
Share on other sites

Hello Tago

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.

Best

Zam

Link to comment
Share on other sites

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

Edited by tago
Link to comment
Share on other sites

You can mix IN/OUT at J10, but have to choose for a full row, a and b

So if you want to keep spare for future SCS (at J10a) it's not an option...

I'm sure someone can help you better than me for software side and J5 implementation

Best

Zam

 

 

Link to comment
Share on other sites

  • 4 months later...

Hi,

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?

 

Thank you very much!

 

Link to comment
Share on other sites

  • 2 weeks later...

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?

Any ideas?

Thank you very much!

 

Link to comment
Share on other sites

Hi Zam,

thanks for joining in.

This is from the .ngc manual, right? As far as i understood i have to do it in the ng app itself and can't simply use ngc/ngr.

Unfortunately i've no clue in which function i should put custom event handlers. Should i put it into APP_TICK (app.c) function?

But i'm not sure about it.

 

Link to comment
Share on other sites

I'd like to know the best place for the button handler and how to get/set kb_transpose values.

Here is some pseudo code.

void APP_Background(void)
{
	int old_transpose = kb_transpose;
	int new_transpose;
	
	// up btn pressed	
	if( MIOS32_BOARD_J5_PinGet(0) == 0) {
		new_transpose = old_transpose + 12;
	}

	// down btn pressed
	if( MIOS32_BOARD_J5_PinGet(1) == 0) {
		new_transpose = old_transpose - 12;
	}

	// transpose and handle LEDs
	if( old_transpose != new_transpose ) {

		kb_transpose = new_transpose;

		if( new_transpose > 0 ) {
			// enable up LED
			// disable down LED 
		} else if (new_transpose < 0 ) {
			// enable down LED
			// disable up LED 
		} else {
			// disable both LEDs
		}
	}
}

 

Link to comment
Share on other sites

There is this line in mbng_kb.c

s8 kb_transpose = (s8)item.custom_flags.KB.kb_transpose;

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.

Edited by tago
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...