Change Button Image

GTT TFT Support

Moderator: Mods

Post Reply
Haz
LCD Geek
Posts: 28
Joined: Wed Jun 28, 2017 8:52 am

Change Button Image

Post by Haz » Tue Sep 11, 2018 7:31 am

What is the command i need to change the button image?

Can you tell me what to send to the screen? I have all the assets in the auto generated directory, so how do i point to one to load as the background?

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 176
Joined: Thu Sep 24, 2015 9:38 am

Re: Change Button Image

Post by Daniel Divino » Tue Sep 11, 2018 1:35 pm

Hi Haz,

Each button has at least 3 bitmaps assigned to it corresponding with the three available states: The Up Bitmap, Down Bitmap, and Disabled Bitmap. You can upload different images to the GTT's RAM, and actively change each of these bitmaps individually using their set_bitmap commands.

The Set_Bitmap command byte strings are as follows:

Set_Up_Bitmap: 254 250 1 6 0 <Object_ID> 21 9 0 <Bitmap_ID>
Set_Down_Bitmap: 254 250 1 6 0 <Object_ID> 21 10 0 <Bitmap_ID>
Set_Disabled_Bitmap: 254 250 1 <Object_ID> 0 4 21 14 0 <Bitmap_ID>

If you are using a custom image, you may have to load the image into the GTT's display ram first.You can do this using the Bitmap Load command:

Bitmap_Load: 254 250 13 0 0 <Bitmap_ID> 0 <etext_encoding> <String_Length> <String>
etext_encoding: Unicode = 0, ASCII = 1, UTF-8 = 2

As an example, if I had 3 images and that I wanted to use for the Up, Down, and Disabled bitmaps on a button (Object_ID 14), I would have to send the following:

Bitmap_Load(15, Unicode, 24, UpBitmap.bmp);
//data stream: 254 250 13 0 0 15 0 0 24 85 0 112 0 66 0 105 0 116 0 109 0 97 0 112 0 46 0 98 0 109 0 112 0

Bitmap_Load(16, Unicode, 28, DownBitmap.bmp);
//data stream: 254 250 13 0 0 16 0 0 28 68 0 111 0 119 0 110 0 66 0 105 0 116 0 109 0 97 0 112 0 46 0 98 0 109 0 112 0

Bitmap_Load(17, Unicode, 36, DisabledBitmap.bmp);
//data stream: 254 250 13 0 0 17 0 0 36 68 0 105 0 115 0 97 0 98 0 108 0 101 0 100 0 66 0 105 0 116 0 109 0 97 0 112 0 46 0 98 0 109 0 112 0

Set_Up_Bitmap(14, 15);
//data stream: 254 250 1 6 0 14 21 9 0 15

Set_Down_Bitmap(14, 16);
//data stream: 254 250 1 6 0 14 21 10 0 16

Set_Disabled_Bitmap(14, 17);
//data stream: 254 250 1 6 0 14 21 14 0 17

It is important to note that Object_ID values and Bitmap_ID values cannot be shared.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

Haz
LCD Geek
Posts: 28
Joined: Wed Jun 28, 2017 8:52 am

Re: Change Button Image

Post by Haz » Tue Sep 11, 2018 3:28 pm

Thank you Daniel,

For the bitmap ID, I have some bitmaps which are loaded as they are all part of objects already, so i am assuming they get loaded when the screen script runs.
How can i get the bitmap ID? I am able to get all the object IDs, so i know there is no overlap. Those are generated in the project .h file in the output directory.
But I see no reference to the bitmap IDs for images already loaded so i know what is loaded, and what i need to load and which ID is available for me to use with images i will load in my program vs. startup.

Thanks,
H-

Haz
LCD Geek
Posts: 28
Joined: Wed Jun 28, 2017 8:52 am

Re: Change Button Image

Post by Haz » Tue Sep 11, 2018 3:33 pm

Also, one more clarification. Do i only need the name of the bitmap? Or do i need a path?
If I need a path, what is it relative to?

Thank you,
H-

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 176
Joined: Thu Sep 24, 2015 9:38 am

Re: Change Button Image

Post by Daniel Divino » Tue Sep 11, 2018 4:35 pm

Hi Haz,

The best place to find your project Bitmap_IDs is the autoexec.txt file in your GTT project output folder. Near the top of the script, you will find a list of Bitmap_Load() commands, each specifying their own Bitmap_IDs. By referencing both the autoexec.txt file and the project.h file, you'll be able to determine what IDs are available.

You will need the path name, relative to the root of the SD card. In my previous example, the images would have been stored directly on the SD card, and not hidden in folders.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

Haz
LCD Geek
Posts: 28
Joined: Wed Jun 28, 2017 8:52 am

Re: Change Button Image

Post by Haz » Tue Sep 11, 2018 5:16 pm

Perfect. Found them. That's exactly what i was looking for.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests