Jump to content

Toggle Driver: how test


quipu

Recommended Posts

I add for my STM32 board ginput toggle driver.

I created a new directory ugfx\drivers\ginput\toggle\STM32_HAL with:

  • ginput_lld_toggle_hal.c
  • ginput_lld_toggle_config.h

also, in inc directory I add:

  • ginput_lld_toggle_board.h

In gfxconf.h i enable:

  • GFX_USE_GINPUT
  • GINPUT_NEED_TOGGLE
  • GFX_USE_GEVENT
  • GFX_USE_GTIMER

How can i test the toggle driver?

 

ginput_lld_toggle_board.h

ginput_lld_toggle_hal.c

ginput_lld_toggle_config.h

Link to comment
Share on other sites

I haven't checked your board file but when it comes to testing you can either assign the toggle to a widget (eg. pushbutton widgets accept toggle roles) and see whether the button visibly changes state. Other than that you can just setup a listener for toggle events yourself and check whether you receive anything. Thinking of this... you can also just call ginputGetToggleStatus() in your application to poll the state :P 

Link to comment
Share on other sites

@Joel Bodenmann it seems to work :D

I tested it with the following code

GSourceHandle upHandle = ginputGetToggle(GINPUT_TOGGLE_ESC);
 
geventListenerInit(&pl);
geventAttachSource(&pl, upHandle, GLISTEN_TOGGLE_ON|GLISTEN_TOGGLE_OFF);

while (1)
{
	event = geventEventWait(&pl, 5000);
	if(event)
		printf("Pressed\n");
}

I have also added the following define in the file ginput_lld_toggle_board.h (attached) 

Now the big questions:

  • Q1: Can I create a list that I scroll with the UP and DOWN keys?
  • Q2: If yes, when I press the MODE key can I enter another list?
  • Q3: If yes, in the second list, I can go back to the previous one by pressing the ESC key etc. 

 

ginput_lld_toggle_board.h

Link to comment
Share on other sites

Glad to hear that you got it working!

  1. Yes, that's already implemented. Just assign the toggle(s) to the list widget
  2. Yes, selecting an item via a toggle is also already implemented. Of course, you'll have to do the "switching to another list" part yourself - just as you'd have to do with a touchscreen implementation.
  3. I don't think that the default list widget has a toggle input for that as it's not really the list's job. Instead, just assign a toggle to some other event (you can manually fire the event) to get a "BACK" event just as you're getting "UP", "DOWN" and "SELECT" events already from the list itself.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...