cancel
Showing results for 
Search instead for 
Did you mean: 

Scrollable list with hardware buttons

sof.pag
Associate

Hi,

I'm trying to implement a scrollable list, but I would like to scroll the list by using hardware buttons. I have already generate the list and populated it properly.

What do I now need to do to get the list to scroll by pushing the hardware buttons instead of using the touchscreen?

Thank you very much in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @sof.pag​,

In this case, what you should do, is create a task (or poll from your Model::tick() method if you're just playing around) that can read the state of the buttons and communicate that to the GUI Task through an OS message queue. Take the element out of the queue from within Model::tick() and use your ModelListener interface to send the value to your active Presenter. The Presenter passes the value to the View which then passes the value to your Scrollable List to scroll either up or down depending on the button pressed.

That's the quick version. Let me know if that helps you - Otherwise we can get more specific.

You'll find that these examples (one polled-, one interrupt-based) will show you how to get data from UI to task and task to UI:

http://ftp.draupnergraphics.com/TouchGFX/knowledgebase/hw_integration_tasks_gpio.4.9.3.zip

http://ftp.draupnergraphics.com/TouchGFX/knowledgebase/hw_integration_tasks_exti.4.9.3.zip

Then all you need to do is have a handle in your Scrollable List that can scroll in both directions in the increments you decide on and that you can call when your presenter receives some signal, e.g. UserButtonPressed.

Best regards,

Martin

View solution in original post

2 REPLIES 2
Martin KJELDSEN
Chief III

Hi @sof.pag​,

In this case, what you should do, is create a task (or poll from your Model::tick() method if you're just playing around) that can read the state of the buttons and communicate that to the GUI Task through an OS message queue. Take the element out of the queue from within Model::tick() and use your ModelListener interface to send the value to your active Presenter. The Presenter passes the value to the View which then passes the value to your Scrollable List to scroll either up or down depending on the button pressed.

That's the quick version. Let me know if that helps you - Otherwise we can get more specific.

You'll find that these examples (one polled-, one interrupt-based) will show you how to get data from UI to task and task to UI:

http://ftp.draupnergraphics.com/TouchGFX/knowledgebase/hw_integration_tasks_gpio.4.9.3.zip

http://ftp.draupnergraphics.com/TouchGFX/knowledgebase/hw_integration_tasks_exti.4.9.3.zip

Then all you need to do is have a handle in your Scrollable List that can scroll in both directions in the increments you decide on and that you can call when your presenter receives some signal, e.g. UserButtonPressed.

Best regards,

Martin

Clark Sann
Senior

Hello @sof.pag​ 

I recently had a similar problem with my application. I pretty quickly was able to cause the GUI to make changes in my underlying hardware, but I had not yet allowed the hardware to make changes in my GUI. I got all that working in the last few days. Basically you just need to go backward through the MVC architecture.

I found some resources on the TouchGFX website that helped me.

https://touchgfx.zendesk.com/hc/en-us/articles/205717801-The-Screen-Concept-and-Model-View-Presenter

and

https://touchgfx.zendesk.com/hc/en-us/articles/205074561-Connecting-the-UI-to-your-system

and especially the examples linked from this page. I did not find the pseudo-code to be that helpful - it was too abstract for me, but the examples showed me the direction to follow.