cancel
Showing results for 
Search instead for 
Did you mean: 

How to better show file structure with FatFS and TouchGFX?

EEuge
Senior

Hello!

I have code, working with FatFS in system area of my project.

main.c

res = f_opendir(&dir, "0:/");
while(1)
	{
           res = f_readdir(&dir, &fileInfo);
          if (res==FR_OK && fileInfo.fname[0])
          {
            fn = fileInfo.fname;
           // ... some code
	}
       else break;
     }
    f_closedir(&dir);

And I have scrollList widget, where I want to show filelist.

How can I send list of filenames to widget by Model->Presenter->View ?

  1. Create array filelist[65535][256] , and send it to view - is not good idea...
  2. Step by step sending command from View to System which everytime calls " res = f_readdir(&dir, &fileInfo); ", gets filename, and asks next filename again - is better, but still not good.
  3. Can I call res = f_opendir(&dir, "0:/"), and send variable "dir" to view?
  4. May be I can #include "fatfs.h" in STORAGE_SCREENView.cpp and work with FatFS from View?

What can you advise for me?

26 REPLIES 26

Im not try this , but maybe

Unicode::fromUTF8((const uint8_t*)FileList[data],textArea1Buffer, 20);
 textArea1.setWildcard(textArea1Buffer);
textArea1.invalidate();

Hello! All works very good.

But you forgot about one detail - after screen setup I need to close dir handle, and I need to open and close it every update of Item.

I added it, and all works very good.

Yes i write you need reset possition in dir, and you can try dir.index set before f_readdir, but other way is close and open dir =)

Thanks.

Next question.

I want work with scrolllist this way: touching and dragging -> scrolling the list of files, pressing (without drag) and releasing -> go to directory after releasing.

Question: how can i get Release event? Scrollist has onle 2 events - setItemSelectedCallback and setItemPressedCallback

Open new thread and mark here one reply as best

OK

Hello!

the scrollList1.itemChanged(itemIndex) function does not call scrollList1UpdateItem if the item with the itemIndex number is outside the scroll window. How to fix it?