cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX listLayout remove function doesn't work as it sposed to be.

q123w123e123qweqwe
Associate III

Hi,

I'm using list layout for my UI application. I'm holding some settings on the list and saving that data into flash. But when I erase an element(for example element 3 out of 6). element 3 erasing on the screen but not from the buffer. So when I write the data to flash I element 3 is still there but 6 is gone.

In here I don't have any elements and data on flash0693W000001skLgQAI.jpg0693W000001skLCQAY.jpg

Here I wrote data on flash

0693W000001skMyQAI.jpg0693W000001skMjQAI.jpg

And here I erased second element (name two) and it didn't erase but number four is gone.

0693W000001skM1QAI.jpg0693W000001skNrQAI.jpg

I'm using list example's code for erasing.

void listElement::deleteAction()
{
	if(viewCallback-> isValid())
	{
		viewCallback-> execute(*this);
	}
}
 
void settingsView::listElementClicked(listElement& element)
{
	list.remove(element);
	scrollCnt.invalidate();
}
 

8 REPLIES 8
Alexandre RENOUX
Principal

Hello,

Could you attach your UI project to this post ? This way it will be easier to find an issue if there is.

Also, you probably did, but maybe looking at the ListLayout Example available on TouchGFX Designer can help you.

/Alexandre

q123w123e123qweqwe
Associate III

Yes, I did look at the example and did it same but it works like that. Here is the link. I'm using listLayout on the settins_screen.

https://drive.google.com/file/d/1rZStIzJsNxjwUpRAGnX__e_1w_JoRUm8/view?usp=sharing

Alexandre RENOUX
Principal

Hello,

I downloaded your project.

But I still need some clarifications :

  • On your post you write "And here I erased second element (name two) and it didn't erase but number four is gone." but on the pictures you attached, it's number 2 that is removed from the GUI like it should. Number Four is still displayed on your picture.
  • You write "element 3 erasing on the screen but not from the buffer". What buffer? The keyboard buffer ?
  • Is the problem appearing as soon as you press the "Add" button or is the problem appearing when you enter the screen and void settingsView::refreshValues() is executed ?

/Alexandre

q123w123e123qweqwe
Associate III

Hi, sorry for unclear post.

Yes it did removed from the screen but it is still in the memory. After I erased listElements[1] (named two) and write the whole list to the flash, it appears I couldn't erase listElements[1] insted I erased listElements[3](named four).

By buffer I mean from the memory alocation for list elements.

And it appears when I write it to flash (When I executed void settingsView::saveButtonHandler()) and all this function does is reading list elements and write them to the flash.

Thanks.

I checked it again it seems number four doesn't erase too. I don't write it to the flash because I decrease the listIndex whenever I erase element so I exit from the loop before number four is written. So my new problem is when I erase element it isn't exactly erasing It just doesn't seem on the screen. Can I actually erase or destroy one of the list elements? Not just from the screen but from the RAM as well.

Hello,

I think I found why it does not work and it's a coding mistake.

Here you can see the two functions (the one that saves in the Flash and one that is supposed to delete the element):

void settingsView::saveButtonHandler()
 
{
	HAL_FLASH_Unlock();
	FLASH_Erase_Sector(FLASH_SECTOR_1, VOLTAGE_RANGE_3);
	HAL_FLASH_Lock();
 
	listIndexSaved = listIndex;
 
	int valf1, valf2, valf3;
	for(int i = 0; i < listIndex; ++i)
	{
		nameBufferptr = listElements[i].getBuffer();
		valf1 = listElements[i].getValueBuffer(1);
		valf2 = listElements[i].getValueBuffer(2);
		valf3 = listElements[i].getValueBuffer(3);
 
		Unicode::strncpy(nameBuffer, nameBufferptr, BUFFER_SIZE);
 
               // Some other code ....
          }
}
 
/*
 * removes element from the list
 * */
void settingsView::listElementClicked(listElement& element)
{
	list.remove(element);
	--listIndex;
	if(listIndex <= 0)
		listIndex = 0;
	scrollCnt.invalidate();
}

I you look closely, you remove item from list but you take the string from listElements. And from what I understood so far you don't delete the correspond element in listElements.

/Alexandre

Oh okay, I got it. But there is no function for deleting an element from listElements. So I have to do is shift other elements and overwrite to the element that I want to delete?

Hello,

This is your own list declaration, therefore it's normal that no function is available if you didn't implement any.

listElement listElements[numberOfListElements];

To remove an element, you have to delete the element like you would do in any project involving a list.

/Alexandre