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

Analog Meter Background Image Settings and Display Switching

Analog Meter Background Image Settings and Display Switching

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 this article, we will expand on the previous customization of the analog meter by implementing a system that changes the background image when the meter value reaches a specific range.

Analog Meter Configuration

In this implementation, we will use background images for the analog meter panel to create a more polished design. Additionally, we will introduce measures to ensure that circular meter images appear correctly on displays with non-square pixel aspect ratios. Below are the specific settings used.

Needle Configuration

  • Value Range: 0–160
  • Needle Properties:
    • Needle Type: Square<3>
    • Needle Length: 80
    • Needle Length2: -37
    • Needle Width: 2
    • Needle Center Size: 0
  • Needle Color:
    • Needle Color and Needle Center Color: White

Meter Panel Configuration

Two background images are registered in the Image Panel. These images are switched based on the Contents Selects (CNTS_SEL) property.

  • Image0: When Contents Selects (CNTS_SEL) = 0 (Normal State)
  • Image1: When Contents Selects (CNTS_SEL) = 1

In the program, the meter value is determined based on the potentiometer’s reading. If the value is 100 or below, Image0 (normal state) is displayed. If the value is 101 or above, Image1 (alert state) is displayed.

Aspect Ratio Adjustment for 7-Inch Displays

The GT-SP 7-inch TFT display does not have a square pixel aspect ratio. If a perfectly circular meter image is created on a PC and displayed on this screen, it will appear horizontally stretched. Follow these steps to adjust the aspect ratio for both the meter image and the needle.

You can determine if aspect ratio adjustment is required by checking the Pixel Pitch value in the display’s hardware specifications. If the Pixel Pitch ratio is 1:1, no adjustment is needed.

Adjusting the Meter Image Aspect Ratio

On the 7-inch display, the vertical-to-horizontal ratio is approximately 1:0.93 (precisely, 0.1926:0.1790). For example, if you create a 400 × 400 px circular meter image, follow these steps to adjust it:

  1. Open the image in an image editing tool.
  2. Resize the image to 400 px height × 371 px width.
  3. Save and register the adjusted image in GT Design Studio.

Before Adjustment (left) / After Adjustment (right)

Adjusting the Needle Aspect Ratio

The meter’s needle also requires aspect ratio correction. In GT Design Studio, adjust the following property:

  • Property Name: Aspect X/Y
  • Value: 93

Text Configuration

A text label is placed at the center of the analog meter.

 

Set Text0 Align X to “CENTER<1>” to align the text to the right.

Font: Use “Melete” as referenced in previous articles.

Set the font Properties to “Melete Medium”, Height to “28” and Size to “16”.

 

Overall Configuration

To match the meter design, we change the background color.

In the properties of PAGE_0, set Back Color to black (#000000).

Arduino Program

The following Arduino program controls the analog meter based on the potentiometer’s value. It changes the background image when the value reaches a specific threshold and displays the current value as text.

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

Understanding the Program

setMeterRange(0, 160)

This function defines the display range of the GT-SP analog meter. In this case, it is set from 0 to 160, ensuring the meter operates within this range in response to the potentiometer’s movement.

int meterValue = constrain(map(sensorValue, POT_MIN, POT_MAX, 160, 0), 0, 160)

This line maps the potentiometer’s analog reading (sensorValue) to the 0–160 range using the map() function. The direction of mapping is reversed to align the potentiometer’s rotation with the needle movement.

The constrain() function ensures that the value remains within the 0–160 range, preventing out-of-bounds display errors.

sendMeterValue(meterValue)

This function transmits the potentiometer’s value to the GT-SP analog meter. Internally, gtsp_ObjPrpSet_val() is used to send the value to property 0x10 of object No.0, enabling real-time meter updates.

updateMeterBackground(meterValue)

This function switches the background image based on the meter value.

  • meterValue <= 100: Background image Image0 (Blue)
  • meterValue > 100: Background image Image1 (Red)

It modifies GT-SP property CNTS_SEL (No. 0x14) to switch between the images.

gtsp_ObjPrpSet_string(2, 0x40, String(meterValue))

This function updates the GT-SP text object (No.2) with the current meter value as a string, providing a clear numerical display.

 

Conclusion

In this project, we learned how to use a potentiometer to control a GT-SP analog meter and dynamically switch its background image based on specific value thresholds. This approach enhances the meter’s visual clarity and usability.

In the next article, we will explore GT Design Studio’s graph tools for additional display enhancements.