Skip to main content
KM L.1
Associate III
Oct 28, 2020 7:28 AM UTC
Solved

Scroll wheel using hardware buttons

Hi,

I'm working on stm32h7 controller and also designed GUI using scroll wheel and able to scroll using touch but i need to scroll the wheel up and down using two hardware buttons.

I also created the queue in model but how to scroll up and down.

Thank you

This topic has been closed for replies.
Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
Nov 2, 2020 8:32 AM UTC

ScrollWheelBase.hpp supports the following function:

void ScrollWheelBase::animateToPosition(int32_t position, int16_t steps)

/Martin

6 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
Nov 2, 2020 8:32 AM UTC

ScrollWheelBase.hpp supports the following function:

void ScrollWheelBase::animateToPosition(int32_t position, int16_t steps)

/Martin

Jun 8, 2024 11:42 AM UTC

Please guide me on this post.

Martin KJELDSEN
Principal III
Nov 2, 2020 1:25 PM UTC

​And you could play around with "steps" to make it go faster or slower depending on how manically you press some button :)

Jun 8, 2024 11:35 AM UTC

Greetings dear friends,

I'm also encountering this issue. I've created a scroll list with 10 items and I want to navigate between these items using a hardware button. Could you please guide me on which command I can use to achieve this? I would greatly appreciate your assistance.

ST Employee
Jun 11, 2024 12:37 PM UTC

Greetings my friend and welcome to the TouchGFX community!

 

Martin is long gone and wont answer you so let me do it for him.

 

There is 2 things you want to do here :
 - getting the button click event to TouchGFX
 - scrolling the scrollList with code

 

To understand how to get a hardware button click to the TouchGFX engine, please look at the 3 videos below:
 - ControllersTech : Send data to UI || Sampling from the GUI task 
 - ControllersTech : Send data to UI || Sampling from another task 
 - STM32 Graphics: Using “Hardware button is clicked” at Interactions 

 

Now, to scroll the list through code, you can look at the API documentation:  api/classes/classtouchgfx_1_1_scroll_list 

I think, the best method to use is "animateToItem".
It allows you to jump to an item, so when pressing your button, you will increment or decrement an index referring to the item number you want to focus on and the scrollList will smoothly scroll to the next (or previous) item.
This has the advantage of scrolling the perfect amount instead of setting manually a number of pixels to scroll.
To use it, you should keep a variable and check that it doesn't go below 0 nor does it go over getNumberOfItems().

 

I cannot provide you with an example because I don't know what hardware you use.
If you have related questions, feel free to ask!

 

This post is quite old, next time, you will have more luck by creating a new thread.

 

Regards,

Jun 15, 2024 9:10 AM UTC

thanks for your guide