Skip to main content
KM L.1
Associate III
October 28, 2020
Solved

Scroll wheel using hardware buttons

  • October 28, 2020
  • 3 replies
  • 2836 views

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

Best answer by Martin KJELDSEN

ScrollWheelBase.hpp supports the following function:

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

/Martin

3 replies

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
November 2, 2020

ScrollWheelBase.hpp supports the following function:

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

/Martin

June 8, 2024

Please guide me on this post.

Martin KJELDSEN
Principal III
November 2, 2020

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

June 8, 2024

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
June 11, 2024

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,

June 15, 2024

thanks for your guide