Images
Applies to:
All variants
Introduction
Images on the VBOX are in the form of PNGs and need to be formatted further using software such as EVE Asset Builder because the microcontroller only accepts specific bitmap formats.
Installing and Formatting using Eve Asset Builder
Start by going to the following website: Toolchains - IC & Module and then click on the “Download the installation package from here” link of the EAB section
After doing so double-click the .exe file and install it to any folder, we tend to go with the one it suggests. Then open the EVE Asset Builder if it doesn’t automatically open. Your screen should look like this:
Along the top bar, you will see that there are many things that the Eve Asset Builder can do. We want to stick with the default one of “IMAGE UTILITIES”. Now click on the right-hand side where it says add and select the image you wish to convert (or drag and drop the image into the box). We will be using the following image for this example, feel free to download and use this image to follow along with this example.
After doing this you need to select the output folder that you wish for this file to go to and then select the EVE Chip which for all the VBOX Touch products is the FT81X. It should now look like this.
Now click CONVERT in the bottom right. This will create 4 files in the folder that you chose. That should look like this:
- You only need the .png file out of these. You probably want to rename it to something more relevant for example back to its original name so: “VBOX Motorsport.png”.
Now we recommend moving this into the folder that your workspace is going to be for this folder.
Creating an image on your VBOX Touch
There are many ways to create an image using VBOX Touch; in fact, you probably do it without knowing when you create a text widget.
Custom images, are harder to create than text as they aren’t built in like fonts/text. So to do this we recommend using our image.py framework which does the difficult bitmap conversion for you.
Warning:
There is only 1MB of space for loading in images and fonts. Because of this it is advised to compress your images wherever you can and try not to use anything with too high a resolution.
Remember that the VBOX Touch display is only 800 x 480 pixels so you will want to scale your image size to this, for example the icons we have on screen are usually about 50 x 50 pixels.
This framework is a new built-in library (as of 1.6) and hence can be used just by importing it:
import image
You will see that image has 2 classes Image and Image_Bank. You will only need an Image_Bank as this will create and manage the Image objects for you. So you can only import Image_Bank like this:
from image import Image_Bank
To load in an image and store it in the bank you need to provide it with its file path and file name. The easiest way to find the file path is by using the python os module:
import os
path = os.getcwd() + '/'
This will get the path of your current file (the main.py file). But as this is stored in the same place as your images (in Spifi) then there is no issue.
Then you need to instantiate the Image_Bank object. This should be treated as a Singleton.
When you instantiate you need to pass it a tuple of tuples. Each nested tuple contains the file path + name and then the name you wish to reference it by.
bank = Image_Bank((
(path + 'icon-VBOX-Motorsport.png', 'VBOX_Motorsport'),
(path + 'icon-moon.png', 'Moon'),
))
When you now wish to get an image you can use the name you assign along with the get function of Image_Bank.
bank.get('Moon')
This returns the object. With this object, you can use the various Image functions. To display the image using the Image functions you need to create a display list that you can put into gui.show()
generate_gui_l(self, tag=None, pos=None)
This will generate a display list command for the image. A full example of how you use this to display the image is below:
gui_l = [gui.DL_COLOR_RGB(255,255,255)]
gui_l.extend(bank.get('VBOX_Motorsport').generate_gui_l(255,(180,10)))
gui_l.extend(bank.get('Moon').generate_gui_l(255,(375,200)))
print(gui_l)
gui.show([
[gui.DL_BEGIN(gui.PRIM_BITMAPS)],
gui_l,
[gui.DL_END()],
])