Skip to main content
DVill
Associate II
August 17, 2025
Question

ScrollWheel used counter (slot machine style) problem on downcounting

  • August 17, 2025
  • 4 replies
  • 1067 views

Hi,

I'm using a ScrollWheel as counter for a slicer.

The scrollwheel has 5 item with 3 drawable in customcontainers with textarea.

It has 2 member values, the actual value and the set value. 

I overrided the UpdateItem callback to dinamically update the scrollwheel drawable for visualization as well as wheelAnimationEnd to update the current value during animation.

I have declared a function that set the new value to display in the counter and fires the animation to.

When called, it starts the animation transition rolling on all the number between the one it has at the beginning to the one used in the call.

The scroolwheel in always centered at position 2.

The code dinamically updates the wheel to have always the correct value displayed.

It works fine upcounting, not in downcounting.

When downcounting it stop always one before the desidered.

The internal value correctly reaches the set value in both directions but not the displayed when downcounting.

Something went wrong during the UpdateItem, only in downcounting and related to touchgfx management....

I attached the idleview files......

Have any idea about it?

It's a good solution or it works in upcounting 'cos I'm lucky?

Thank guys.

 

 

4 replies

ST Employee
August 18, 2025

Hello @DVill,

It's hard to understand what happens with only theses files, have you tried to debug and check if the invalidation is done correctly ?

BR,

DVill
DVillAuthor
Associate II
August 18, 2025

Hi,

thanks for your response first of all.

Yes, I debugged both on target (my board) as well as in simulator (via visual studio 2022) and what I saw is the following.

The strange behaviour is on rolling back to lower values starting from bigger value.

For example: you have displayed "10" and you set the value "0".

At the beginning you see a correct animation decreasing "10"->"9"->"8"...."1".

But on the last calling of onWheelAnimationEnded something strange happens:

"0" is initially showed, so it seems to be fine,

but on the last calling of  animateToItem(2, 0) which ends all the iteration, "1" is showed.

This last animateToItem(2, 0) (when _slicesDone is 0) in onWheelAnimationEnded, raises as designed the whSlicesUpdateItem call back, but the "item" passed has value "3", where I supposed it should be "2" ,so the "0" value is placed in the wrong place.

I checked manually rolling upwards  and I have another "1", and after "2","3","4".... so "0" updates in the wrong place.

What can I do to make it more clear?

Best regards and thank you.

ST Employee
August 19, 2025

So what you have is something like :

9 -> 8 -> 7 ... -> 1 -> 0 -> 1 ?

Have you tried to do a manual invalidation at the end ?

DVill
DVillAuthor
Associate II
August 25, 2025

Hi Louis,

I reproduced my problems in a simplier touchgfx app, reducing the whole size to the only simulator files.

All about my problems with scrollWheel are in this version as well. So you can debug it in Visual Studio via solution stored in .\simulator\msvs.

I think it's a good trade-off and I hope it is good for you, as well.

I'm using TouchGFX 4.23.2. and VS2022.

Thanks for your time.

Best regards.

 

ST Employee
August 26, 2025

Hello @DVill,

I took a look at your project and the function is not supposed to be use control the value of the items. It's just to pass the value to the item. 
A solution is to set number of items to "10 000" in designer and use the code below :

#include <gui/main_screen/MainView.hpp>
#include "BitmapDatabase.hpp"
#include "texts/TextKeysAndLanguages.hpp"

MainView::MainView() :
 scrollWheel1AnimationEndCallback(this, &MainView::scrollWheel1AnimationEndHandler)
{
 scrollWheel1.setAnimationEndedCallback(scrollWheel1AnimationEndCallback);
 _val = 0;
 _lock = false;
 
}

void MainView::setupScreen()
{
}

void MainView::scrollWheel1UpdateItem(textContainer& item, int16_t itemIndex)
{
 item.updateText(itemIndex);
}

void MainView::tearDownScreen()
{

}

void MainView::IncData()
{
 if (_lock == false)
 { 
 _lock = true;
 scrollWheel1.animateToItem((scrollWheel1.getSelectedItem())+1, 50);

 }
}

void MainView::DecData()
{

 if (_lock == false)
 { 
 _lock = true;
 scrollWheel1.animateToItem((scrollWheel1.getSelectedItem())-1, 50);
 }

}

void MainView::scrollWheel1AnimationEndHandler()
{
 _lock = false;
}


Not 10000 items will be create, its just for the list to know the indexes.
BR,

DVill
DVillAuthor
Associate II
August 26, 2025

Hi,

In other word my control usage was wrong, right? I've always got a bad feeling about that code....

What do you mean with:

" the function is not supposed to be use control the value of the items. It's just to pass the value to the item." 

Thanks very much for all.

Davide.

 

ST Employee
August 27, 2025

Hello @DVill,

The role of the function UpdateItem is to pass the data to the item at the index itemIndex, which is not supposed to be changed (it can be but the output can have unwanted behaviour). A typical usage is what you have in the scrollwheel/list example.

BR,