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

Displaying Animation on the GT-SP by Switching Multiple Images

Displaying Animation on the GT-SP by Switching Multiple Images

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.

This time, we will register multiple images in GT Design Studio and display an animation on the GT-SP by switching the displayed images in sequence under host computer control.

For this example, we prepared 10 images showing slightly different states of a pump and display them sequentially at fixed intervals. By continuously switching between multiple still images, the pump appears to be moving on the GT-SP.

Preparing Images for Animation

First, prepare the images to be used for the animation.

In this example, we use 10 images, from pump_01.png to pump_10.png, each showing a slightly different state of the pump.

The images are displayed in order from the first to the tenth. After the last image is displayed, the sequence returns to the first image, creating a repeating animation.

Creating the Screen in GT Design Studio

Next, create the screen in GT Design Studio.

Register the 10 images used in this example to the project from “Image” at the top of the screen.

After registering the images, place an Image Object on the screen. Images can also be registered when creating an Image Object.

Instead of placing 10 separate Image Objects, we use one Image Object and switch the image displayed in that object from the Arduino.

After completing the screen and image settings, save the project and perform a Build.

Checking Image Addresses After Build

In this program, the image displayed in the Image Object is changed by specifying the address of an image registered in GT Design Studio from the Arduino.

The image addresses can be checked in a CSV file generated when the project is built in GT Design Studio.

When a project is saved in GT Design Studio, a folder with _prj_files appended to the project name is created in the project save location.

The project name used in this example is autopompanimation, so the following folder is created.

autopompanimation_prj_files

When the project is built, an output folder with _output appended to the project name is created inside this folder.

In this example, the folder structure is as follows.

autopompanimation_prj_files
└─ autopompanimation_output

The autopompanimation_output folder contains the files generated by the Build process.

The file used to check the image addresses in this example is:

autopompanimation_IMG.csv

The autopompanimation portion of the file name is the project name. If a different project name is used, check the _IMG.csv file with the corresponding project name.

Open autopompanimation_IMG.csv to view information about each registered image, including the image file name and image address.

The CSV file contains the following fields.

IMG_NAME,IMG_FILE,IMG_ADRS,IMG_LEN,NAME_ADRS

In this example, we use the values listed under IMG_ADRS.

For example, the address assigned to the first image, pump_01.png, is:

0x00040020

Different addresses are assigned to pump_02.png, pump_03.png, and the other registered images.

We will use the image addresses listed in this CSV file in the Arduino program.

Arduino Program

Now that the image addresses have been confirmed, create the program to be written to the Arduino.

In this program, the addresses of the 10 images obtained from autopompanimation_IMG.csv are set in the program and sent to the GT-SP in sequence.

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

 

Understanding the Program

First, let’s look at the section where the image addresses are set.

pump_img[0] = 0x00040020;
pump_img[1] = 0x0004ef70;
pump_img[2] = 0x0005dec0;
pump_img[3] = 0x0006ce10;
pump_img[4] = 0x0007bd60;
pump_img[5] = 0x0008acb0;
pump_img[6] = 0x00099c00;
pump_img[7] = 0x000a8b50;
pump_img[8] = 0x000b7aa0;
pump_img[9] = 0x000c69f0;

These values correspond to the IMG_ADRS values in autopompanimation_IMG.csv, arranged in order from pump_01.png to pump_10.png.

The image address stored in this array is sent to the GT-SP using the following line.

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

By changing the value of current_frame in sequence,

pump_img[0]
pump_img[1]
pump_img[2]

the registered image addresses are sent one by one in sequence.

After the tenth image is displayed, current_frame is reset to 0, and the sequence starts again from the first image.

Repeating this process continuously switches the 10 still images and displays them as an animation.

The image switching speed is set in the following line.

delay(100);

In this example, the image changes every 100 milliseconds.

A smaller value makes the animation faster, while a larger value makes it slower. Adjust this value according to the images used and the desired animation speed.

Summary

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

When a project is built in GT Design Studio, an _IMG.csv file is generated in the project output folder. The address assigned to each registered image can be checked in the IMG_ADRS field of this CSV file.

By setting these image addresses in the Arduino program and sending them to the GT-SP in sequence, multiple images can be displayed continuously using a single Image Object.

If images are added or their registration order is changed, the image addresses may change after the project is rebuilt. In that case, check the latest _IMG.csv file and update the addresses used in the program.

In this example, we specified the image addresses from the CSV file directly in the program.

When image addresses are specified directly, editing and rebuilding the project may change the addresses. Therefore, the _IMG.csv file must be checked and the values in the program updated each time the addresses change.

In the next article, we will use definition files to specify images by file name instead of directly specifying image addresses.

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

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