Series: Using the GT-SP Touch Panel TFT Display with Arduino

Specifying Images on the GT-SP Using an Image Definition File

Specifying Images on the GT-SP Using an Image Definition File

DownloadDownload sample project & program (for GT Design Studio & Arduino)

Hello everyone, I’m @kissaten, a beginner in electronics. In this series, I’m explaining the process of connecting a 7-inch touch display (GT-SP series “GTWV070S3A00P”) to an Arduino and working on various projects.

In the previous article, we registered multiple images in GT Design Studio and displayed an animation on the GT-SP by specifying the image addresses sequentially from the Arduino.

This time, we will use the same animation and an image definition file generated by Build in GT Design Studio to specify the images to display using definitions corresponding to the image file names.

Using the Previous Project

This time, we will use the autopompanimation project created in the previous article as is.

The project contains 10 registered images, from pump_01.png to pump_10.png.

On the image registration screen in GT Design Studio, each image is assigned a number such as img_00000 or img_00001.

In this project, the images are registered as follows.

 

In the previous article, we opened the _IMG.csv file generated after Build, checked the address assigned to each image, and set those addresses in the Arduino program.

This time, we will use an image definition file generated by the same Build process.

Checking the Image Definition File Generated by Build

When the project is built in GT Design Studio, various definition files are generated in the project folder.

The image definition file used in this article is generated in the following folder.

 

When you open autopompanimation_IMG.h, you can check definitions such as the image number and image address for the images registered in GT Design Studio.

For example, the following definitions are generated for pump_01.png.

 

The image address used in this article is defined as follows.

GUI_DEF_IMG_pump_01_AD

We will use this definition in the Arduino program.

Similarly, definitions corresponding to each image file name are generated for pump_02.png through pump_10.png.

In autopompanimation_IMG.h, _AD definitions corresponding to the image names pump_01 through pump_10 are generated.

Using the Image Definition File in the Arduino Program

Next, configure the Arduino sketch so that autopompanimation_IMG.h can be used from the Arduino program.

In this example, place the Arduino sketch and autopompanimation_IMG.h in the same folder.

 

In the Arduino program, include the image definition file as follows.

#include "autopompanimation_IMG.h"

This allows the image addresses defined in autopompanimation_IMG.h to be used in the Arduino program.

Arduino Program

After placing the image definition file in the Arduino sketch folder, create the program to upload to the Arduino.

As in the previous article, this program displays an animation by switching through 10 images in sequence.

However, instead of writing the image addresses directly in the program, we will use the definitions corresponding to the image names generated in autopompanimation_IMG.h.

DownloadDownload sample project & program (for GT Design Studio & Arduino)

 

Understanding the Program

First, let’s look at the section that includes the image definition file.

#include "autopompanimation_IMG.h"

This allows the definitions in autopompanimation_IMG.h to be used in the program.

Next, let’s look at the section that sets the images used for the animation.

 

In the previous article, the image address was specified directly as follows.

pump_img[0] = 0x00040020;

This time, we use the definition generated for the image file name pump_01.png:

GUI_DEF_IMG_pump_01_AD

This definition is used instead of specifying the image address directly.

The .png extension is not included in the definition name, so pump_01.png is referenced as GUI_DEF_IMG_pump_01_AD.

The section that sends the image to the GT-SP is the same as in the previous article.

gtsp_ObjPrpSet_val(0, 0x48, 4, pump_img[current_frame]);

By changing the value of current_frame sequentially, the images from pump_01 through pump_10 are displayed in order.

After the 10th image is displayed, the sequence returns to the first image and the animation repeats.

Summary

This time, we used autopompanimation_IMG.h generated by Build in GT Design Studio and specified the images to display on the GT-SP using definitions corresponding to the image file names.

In the previous article, we checked the image addresses listed in _IMG.csv and set them directly in the Arduino program.

This time, we used definitions corresponding to the original image file names, such as

GUI_DEF_IMG_pump_01_AD

instead of specifying the image address directly.

By using the image definition file, the images can be specified in the program using clear names instead of the image address values themselves.

Series: Using the GT-SP Touch Panel TFT Display with Arduino

Series: Using the GT-SP Touch Panel TFT Display with Arduino