Making a paginated menu with thumbnails

General discussion on mikroC PRO for FT90x.
Post Reply
Author
Message
hrfraz
Posts: 9
Joined: 04 Aug 2017 18:07

Making a paginated menu with thumbnails

#1 Post by hrfraz » 05 Sep 2017 17:15

Hi all,
So I've created a paginated menu with 8 pages each capable of showing six 265-color thumbnails and titles, all of which are stored in a struct. (This is for a food cooker of sorts.)

Code: Select all

struct MITEMS {
    unsigned long img[50];
    char name[50][18];
    unsigned long temp[50];
    int mins[50], secs[50];
} MenuItems; 
In order to scroll through, I set the img variable to the constant that is defined by VTFT for the location in the .RES file..

Code: Select all

const unsigned long CLEGCA_bmp = 0x0000016C;
const unsigned long CSTRIP_bmp = 0x000119AA;
const unsigned long UNDEF_bmp  = 0x000692E0;

Code: Select all

void populateFakeMenuItems(void) {
    int loops = 0;
    for (loops = 0; loops <= 50; loops++) {
        sprintf(MenuItems.name[loops], "[%d NOT SET]", loops + 1);
        MenuItems.img[loops] = UNDEF_bmp;
        MenuItems.temp[loops] = 335;
        MenuItems.mins[loops] = 2;
        MenuItems.secs[loops] = 0;
    }

    strcpy(MenuItems.name[0], "Chicken Legs");
    MenuItems.img[0] = CLEGCA_bmp;
    MenuItems.temp[0] = 335;
    MenuItems.mins[0] = 2;
    MenuItems.secs[0] = 0;

    strcpy(MenuItems.name[1], "Chicken Strips");
    MenuItems.img[1] = CSTRIP_bmp;
    MenuItems.temp[1] = 335;
    MenuItems.mins[1] = 2;
    MenuItems.secs[1] = 0;

... so on...
Based on an eveKey that is pressed, the code will set the image and text objects on the MenuScreen to the appropriate values contained in the struct.

Code: Select all

void loadMenuScreen(int pgNum) {

    imgMenuA.Picture_Name = MenuItems.img[pgNum * 6];
...
    imgMenuF.Picture_Name = MenuItems.img[pgNum * 6 + 5];

    DrawScreenO(&MenuScreen, VTFT_LOAD_RES_NONE); //Images are shewed. (LOAD_RES_ALL is called by function loading this screen initially.)
//DrawScreenO(&MenuScreen, VTFT_LOAD_RES_ALL); //Takes longer because of re-loading..

    return;
}
My questions are: How can I improve load times? Am I doing this correctly? It seems to work well if I re-load the resources every time but there is a ~1sec delay between page flips.

One other thing to note: I have been able to call DrawScreenO(&MenuScreen, VTFT_LOAD_RES_ALL); on initially loading the MenuScreen from, say, HomeScreen, and then for page number changes calling loadMenuScreen(x) with DrawScreenO(&MenuScreen, VTFT_LOAD_RES_NONE); The only issue is that upon a page change all the images load instantly, but are skewed to the right.. odd. (see attached)
IMG_4250.JPG.jpg
IMG_4250.JPG.jpg (43.29 KiB) Viewed 5205 times
IMG_4249.JPG.jpg
IMG_4249.JPG.jpg (43.23 KiB) Viewed 5205 times
Any suggestions?

Thank you!
Harrison

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Making a paginated menu with thumbnails

#2 Post by filip » 08 Sep 2017 15:20

Hi,

Please, can you record a video of this, so I could see this delay and understand the problem properly ?

Regards,
Filip.

hrfraz
Posts: 9
Joined: 04 Aug 2017 18:07

Re: Making a paginated menu with thumbnails

#3 Post by hrfraz » 15 Sep 2017 14:44

Sure, and thank you for your response!

https://youtu.be/FjF7g076Itw - Here is a video where DrawScreenO(...,LOAD_RES_ALL) is called when I press the MENU button and then after that when I press Next, Prev, or a page number, LOAD_RES_NONE is used.

https://youtu.be/7s7RyAv-X40 - In this video, DrawScreenO(...,LOAD_RES_ALL) is used each time a button is pressed. Everything looks great, but for the pages where different images are used (the first page) it takes more time to load. (See when I go back to page 1.

One additional thing- I set all images to visible=false, call DrawScreenO(...,VTFT_LOAD_RES_ALL) and then set visible=true for all images then call DrawScreenO(...,VTFT_LOAD_RES_NONE)

This seems to be the only way I can make it load without showing glitches... (Other glitches include the first image (drumstick chicken) being shown for all 6 images for a fraction of a second and then the rest will appear properly.)

Code: Select all

menuPicsVisible(false);
DrawScreenO(&MenuScreen, VTFT_LOAD_RES_ALL);
menuPicsVisible(true);
DrawScreenO(&MenuScreen, VTFT_LOAD_RES_NONE);
This is all this function does, to avoid displaying glitches...

Code: Select all

void menuPicsVisible(bool vis) {
    imgMenuA.Visible = vis;
    imgMenuB.Visible = vis;
    imgMenuC.Visible = vis;
    imgMenuD.Visible = vis;
    imgMenuE.Visible = vis;
    imgMenuF.Visible = vis;
    return;
}

Post Reply

Return to “mikroC PRO for FT90x General”