cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with scroll list on target

MNils.2
Associate II

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();
}
 
 

 

0 REPLIES 0