Skip to main content
MNils.2
Associate II
February 12, 2025
Question

Problem with scroll list on target

  • February 12, 2025
  • 7 replies
  • 1701 views

Hi,
I have a scroll list that works perfekt in the simulator, but when running it on target (STM32H735) I need to set a periodic update of scollList.invalidate(), to get it to work. The problem is that only the first and last element show as selected, when scrolled to, but the function on each element is OK, i.e to switch language.
What can be the cause of this? Here is the code:

#include <gui/installation_lang_screen/Installation_LANGView.hpp>
#include <images/BitmapDatabase.hpp>
#include <texts/TextKeysAndLanguages.hpp>

Installation_LANGView::Installation_LANGView()
 : currentIndex(0)
 , languages {{
 { BITMAP_UNITED_STATES_ID, T_TEXT_ENGLISHUS, std::nullopt, std::nullopt },
 { BITMAP_FRANCE_ID, T_TEXT_FRANCE, std::nullopt, std::nullopt },
 { BITMAP_GERMANY_ID, T_TEXT_DEUTSCHE, std::nullopt, std::nullopt },
 { BITMAP_HUNGARY_ID, T_TEXT_MAGYAR, std::nullopt, std::nullopt },
 { BITMAP_ITALY_ID, T_TEXT_ITALIANO, std::nullopt, std::nullopt },
 { BITMAP_NETHERLANDS_ID, T_TEXT_NEDERLANDS, std::nullopt, std::nullopt }
 }}
 {
 scrollList.setNumberOfItems(languages.size());
 for (int i = 0; i < scrollList.getNumberOfItems(); i++) {
 scrollListListItems[i].setup(languages[i]);
 scrollListListItems[i].setIndex(i);
 scrollListListItems[i].setUnselected();
 }
 scrollList.animateToItem(0);
 scrollListListItems[0].setSelected();
 scrollList.invalidate();
}

void Installation_LANGView::setupScreen()
{
 Installation_LANGViewBase::setupScreen();

 footer.showNavigationElement(POS_RIGHT, NAV_SET);
 footer.showNavigationElement(POS_CENTER, NAV_MOVE_UPDOWN);
 footer.showNavigationElement(POS_LEFT, NAV_BACK);
}

void Installation_LANGView::tearDownScreen()
{
 Installation_LANGViewBase::tearDownScreen();
}

void Installation_LANGView::scrollListUpdateItem(ListElement& item,
 int16_t itemIndex)
{
 if ((size_t)itemIndex < languages.size() && currentIndex < languages.size()) {
 if(item.getIndex() == currentIndex)
 {
 item.setSelected();
 } else {
 item.setUnselected();
 }
 }
 scrollList.invalidate();
}

void Installation_LANGView::scrollList_ItemSelectedHandler(int16_t itemSelected)
{
 scrollList.animateToItem(itemSelected);
 currentIndex = itemSelected;
 for (int i = 0; i < scrollList.getNumberOfItems(); i++) {
 scrollList.itemChanged(i);
 } 
}

void Installation_LANGView::goUp()
{
 if (currentIndex > 0) {
 scrollList_ItemSelectedHandler(currentIndex - 1);
 }
}

void Installation_LANGView::goDown()
{
 int16_t numItems = languages.size();
 if (currentIndex < numItems - 1) {
 scrollList_ItemSelectedHandler(currentIndex + 1);
 }
}

void Installation_LANGView::enter()
{
 if (scrollListListItems[0].isSelected()) {
 Texts::setLanguage(US);
 } else if (scrollListListItems[1].isSelected()) {
 Texts::setLanguage(FR);
 } else if (scrollListListItems[2].isSelected()) {
 Texts::setLanguage(DE);
 } else if (scrollListListItems[3].isSelected()) {
 Texts::setLanguage(HU);
 } else if (scrollListListItems[4].isSelected()) {
 Texts::setLanguage(IT);
 } else if (scrollListListItems[5].isSelected()) {
 Texts::setLanguage(NL);
 }

 application().gotoMain_MenuScreenNoTransition();
}

void Installation_LANGView::updateScrollList()
{
 // scrollList.invalidate();
}
 
 

 

7 replies

ST Employee
February 13, 2025

Hello @MNils.2,

Could you add screenshots of the issue with the 1st and last element ?

BR,

MNils.2
MNils.2Author
Associate II
February 13, 2025

The img_2238 shows the 1st element selected, if I click down button (using hw buttons) 5 times the last element is selected as in img_2239. I think this is because the last element is partly outside the view.
BR

ST Employee
February 13, 2025

And this only happens on the target but not the simulator right ?

MNils.2
MNils.2Author
Associate II
February 13, 2025

Yes, it works fine in simulator.

ST Employee
February 13, 2025

Something with the current index might cause issues, try to debug it on the board and follow the value of "currentIndex". You also said "I need to set a periodic update of scollList.invalidate()", what happens if you dont ?

MNils.2
MNils.2Author
Associate II
February 13, 2025
void Installation_LANGView::updateScrollList()
{
 // scrollList.invalidate();
}

If I uncomment the srcollList.invalidate() which is Triggered on every tick, it works fine on target as well.

If I don't do it I get the 1:st and last issue:
The thing is that the function on every item works , but it does not shown as selected. So if I go down 1 step and press enter we switch languages to French. But the field is not shown selected.
It is only if I click 5 times and come to Nederland that the field shows that it is selected.

ST Employee
February 13, 2025

Then maybe the invalidation causes problem, in scrollList_ItemSelectedHandler, try to put an invalidate at the begining and the end of this function.

MNils.2
MNils.2Author
Associate II
February 14, 2025

I tried that but unfortunately it behaves the same

MNils.2
MNils.2Author
Associate II
February 14, 2025

I inserted log print like this:

 

void Installation_LANGView::scrollListUpdateItem(ListElement& item,
 int16_t itemIndex)
{
 if(item.getIndex() == currentIndex)
 {
 item.setSelected();
#ifndef SIMULATOR
 LOG_INF("UpdateItem, itemIndex %d Selected", itemIndex);
#endif
 } else {
 item.setUnselected();
#ifndef SIMULATOR
 LOG_INF("UpdateItem, itemIndex %d Unselected", itemIndex);
#endif
 }
}

void Installation_LANGView::scrollList_ItemSelectedHandler(int16_t itemSelected)
{
#ifndef SIMULATOR
 LOG_INF("itemSelectedHandler, itemSelected %d", itemSelected);
#endif
 currentIndex = itemSelected;
 scrollList.animateToItem(itemSelected);
 for (int i = 0; i < scrollList.getNumberOfItems(); i++) {
 scrollList.itemChanged(i);
 }
 scrollList.invalidate();
}

 

And pressing down button 5 times gives the following log (but only item 0 and 5 shows selected),
it looks the same for every button press:

[00:00:12.552,000] <inf> lang_inst: UpdateItem, itemIndex 0 Selected
[00:00:12.552,000] <inf> lang_inst: UpdateItem, itemIndex 1 Unselected
[00:00:12.552,000] <inf> lang_inst: UpdateItem, itemIndex 2 Unselected
[00:00:12.552,000] <inf> lang_inst: UpdateItem, itemIndex 3 Unselected
[00:00:12.552,000] <inf> lang_inst: UpdateItem, itemIndex 4 Unselected
[00:00:12.552,000] <inf> lang_inst: UpdateItem, itemIndex 5 Unselected
[00:00:21.442,000] <inf> lang_inst: itemSelectedHandler, itemSelected 1
[00:00:21.442,000] <inf> lang_inst: UpdateItem, itemIndex 0 Unselected
[00:00:21.442,000] <inf> lang_inst: UpdateItem, itemIndex 1 Selected
[00:00:21.442,000] <inf> lang_inst: UpdateItem, itemIndex 2 Unselected
[00:00:21.442,000] <inf> lang_inst: UpdateItem, itemIndex 3 Unselected
[00:00:21.442,000] <inf> lang_inst: UpdateItem, itemIndex 4 Unselected
[00:00:21.442,000] <inf> lang_inst: UpdateItem, itemIndex 5 Unselected
[00:00:33.340,000] <inf> lang_inst: itemSelectedHandler, itemSelected 2
[00:00:33.340,000] <inf> lang_inst: UpdateItem, itemIndex 0 Unselected
[00:00:33.340,000] <inf> lang_inst: UpdateItem, itemIndex 1 Unselected
[00:00:33.340,000] <inf> lang_inst: UpdateItem, itemIndex 2 Selected
[00:00:33.340,000] <inf> lang_inst: UpdateItem, itemIndex 3 Unselected
[00:00:33.340,000] <inf> lang_inst: UpdateItem, itemIndex 4 Unselected
[00:00:33.340,000] <inf> lang_inst: UpdateItem, itemIndex 5 Unselected
[00:00:35.668,000] <inf> lang_inst: itemSelectedHandler, itemSelected 3
[00:00:35.668,000] <inf> lang_inst: UpdateItem, itemIndex 0 Unselected
[00:00:35.668,000] <inf> lang_inst: UpdateItem, itemIndex 1 Unselected
[00:00:35.668,000] <inf> lang_inst: UpdateItem, itemIndex 2 Unselected
[00:00:35.668,000] <inf> lang_inst: UpdateItem, itemIndex 3 Selected
[00:00:35.668,000] <inf> lang_inst: UpdateItem, itemIndex 4 Unselected
[00:00:35.668,000] <inf> lang_inst: UpdateItem, itemIndex 5 Unselected
[00:00:37.393,000] <inf> lang_inst: itemSelectedHandler, itemSelected 4
[00:00:37.393,000] <inf> lang_inst: UpdateItem, itemIndex 0 Unselected
[00:00:37.393,000] <inf> lang_inst: UpdateItem, itemIndex 1 Unselected
[00:00:37.393,000] <inf> lang_inst: UpdateItem, itemIndex 2 Unselected
[00:00:37.393,000] <inf> lang_inst: UpdateItem, itemIndex 3 Unselected
[00:00:37.393,000] <inf> lang_inst: UpdateItem, itemIndex 4 Selected
[00:00:37.393,000] <inf> lang_inst: UpdateItem, itemIndex 5 Unselected
[00:00:39.113,000] <inf> lang_inst: itemSelectedHandler, itemSelected 5
[00:00:39.113,000] <inf> lang_inst: UpdateItem, itemIndex 0 Unselected
[00:00:39.113,000] <inf> lang_inst: UpdateItem, itemIndex 1 Unselected
[00:00:39.113,000] <inf> lang_inst: UpdateItem, itemIndex 2 Unselected
[00:00:39.113,000] <inf> lang_inst: UpdateItem, itemIndex 3 Unselected
[00:00:39.113,000] <inf> lang_inst: UpdateItem, itemIndex 4 Unselected
[00:00:39.113,000] <inf> lang_inst: UpdateItem, itemIndex 5 Selected
ST Employee
February 14, 2025

Hello @MNils.2 ,

Could you send me your project, by private message ?

 

BR,