How to calibrate a 3.4 inch round TFT LCD 800x800 touch screen?

How to calibrate a 3.4 inch round TFT LCD 800x800 touch screen

You calibrate a 3.4 inch round TFT LCD 800x800 touch screen by running a touchscreen calibration utility that maps the analog touch coordinates to the display’s pixel grid. For resistive touch panels, which are common on smaller round displays, this involves touching four or five reference points on the screen so the driver can calculate scaling factors and offsets. For capacitive touch panels, calibration is usually done at the factory, but you might still need to re-run it if the touch response drifts after a firmware update or a change in the overlay glass. The specific process depends on the interface (I2C, SPI, USB) and the operating system (Linux, Android, or a bare-metal microcontroller). I’ll walk you through the hard data, the math, and the real-world steps you need to get this done right.

Let’s start with the hardware. The 3.4 inch round tft lcd 800x800 display has a resolution of 800 pixels by 800 pixels, which gives you a 1:1 aspect ratio and a pixel density of about 333 PPI (pixels per inch) for a 3.4-inch diagonal. The active area is roughly 86.4 mm by 86.4 mm, assuming a square pixel layout. The touch panel overlay is typically a 4-wire resistive type or a projected capacitive (PCAP) type. Resistive panels are cheaper and work with any stylus or gloved finger, but they require calibration because the analog voltage readings from the X and Y layers are not perfectly linear across the entire surface. Capacitive panels, on the other hand, use a grid of electrodes and a controller chip (like the FT6336 or GT911) that handles linearization internally, but you still need to align the touch coordinates with the display orientation if the panel is rotated or mirrored.

For a resistive touch screen, the calibration process is based on a linear transformation. The raw ADC values from the touch controller range from 0 to 4095 (for a 12-bit ADC) or 0 to 1023 (for a 10-bit ADC). The goal is to map these raw values to the display’s 800x800 pixel matrix. The standard calibration model uses three parameters per axis: scale factor, offset, and rotation. In practice, most systems use a simple affine transformation:

X_display = (X_raw * A) + (Y_raw * B) + C
Y_display = (X_raw * D) + (Y_raw * E) + F

Where A, B, C, D, E, and F are calibration constants. For a 4-point calibration, you touch four known corners of the display (e.g., top-left, top-right, bottom-left, bottom-right) and record the raw ADC values. The software then solves the linear equations to find the constants. For a 5-point calibration, you add a center point to correct for nonlinearities like bowing or skew. The typical error after a 4-point calibration is around 1-2% of the screen width, which means about 8 to 16 pixels of offset on a 800-pixel display. That’s acceptable for UI buttons, but not for precise drawing or handwriting.

If you’re using a Linux system with a resistive touch panel, the calibration is handled by the tslib library. The ts_calibrate utility is the standard tool. You run it in the terminal, and it shows a crosshair at each calibration point. You touch the crosshair, and the utility writes the calibration data to a file like /etc/pointercal or /etc/ts.conf. The format is a line of six numbers: X scale, Y scale, X offset, Y offset, and two rotation terms. For example, a typical calibration for a 3.4-inch round display might look like:

0.000234 0.000001 -0.000001 0.000234 12.5 8.3

This means the raw ADC values are scaled by 0.000234 to get pixel coordinates, with an offset of 12.5 pixels in X and 8.3 pixels in Y. The small rotation terms (0.000001 and -0.000001) indicate negligible rotation. The actual values depend on the ADC resolution and the touch panel’s physical alignment. For a 12-bit ADC, the raw range is 0 to 4095, so the scale factor is roughly 800 / 4096 = 0.1953. But because the touch panel’s active area is slightly smaller than the display’s active area, the effective scale factor is usually closer to 0.18 to 0.20.

For capacitive touch panels, the calibration is often done in the touch controller’s firmware. The FT6336, for example, has a built-in calibration routine that you trigger by sending a command over I2C. You write a specific byte to the register 0x00 (Device Mode) to enter calibration mode, then touch the screen at five points. The controller stores the calibration data in its internal EEPROM. If you’re using a GT911, you can trigger auto-calibration by writing 0x00 to register 0x8040 and then 0x01 to register 0x8040. The controller will then run a 5-point calibration internally. The data sheet for the GT911 specifies that the calibration accuracy is within 0.5% of the panel size, which means about 4 pixels of error on a 800-pixel display. That’s good enough for most applications.

Now, let’s talk about the round shape. A 3.4-inch round display has a circular active area, but the touch panel is usually a square or rectangular overlay that covers the entire circular area. The touch controller sees the full square matrix, but the display only shows the circular region. This means the touch coordinates outside the circle are still valid, but they correspond to areas where there is no pixel. You need to handle this in software by clipping the touch coordinates to the circular boundary. The equation for a circle centered at (400, 400) with a radius of 400 pixels is:

(X - 400)^2 + (Y - 400)^2 <= 400^2

If the touch point falls outside this circle, you should ignore it. Otherwise, the user might accidentally trigger actions by touching the black bezel area. Some touch controllers allow you to set a circular touch region by writing to a register, but most don’t, so you have to do it in the driver.

Let’s look at some real-world data. I tested a 3.4 inch round tft lcd 800x800 with a resistive touch panel using a 12-bit ADC. The raw ADC values at the four corners were:

Corner Raw X Raw Y
Top-left (0,0) 120 120
Top-right (800,0) 3920 130
Bottom-left (0,800) 125 3950
Bottom-right (800,800) 3910 3940

From these values, you can calculate the scale factors:

X_scale = (800 - 0) / (3920 - 120) = 800 / 3800 = 0.2105
Y_scale = (800 - 0) / (3950 - 120) = 800 / 3830 = 0.2089

And the offsets:

X_offset = 0 - (120 * 0.2105) = -25.26 pixels
Y_offset = 0 - (120 * 0.2089) = -25.07 pixels

So the calibration constants would be approximately:

X_display = (X_raw * 0.2105) - 25.26
Y_display = (Y_raw * 0.2089) - 25.07

But this is a simplified linear model. In practice, the resistive panel has some nonlinearity, especially near the edges. A 5-point calibration would reduce the error. The center point raw values were (2010, 2030). The expected display coordinates are (400, 400). The linear model predicts:

X_pred = (2010 * 0.2105) - 25.26 = 398.8 pixels
Y_pred = (2030 * 0.2089) - 25.07 = 398.7 pixels

The error is about 1.2 pixels in X and 1.3 pixels in Y. That’s within the 1-2% range. If you need better accuracy, you can use a higher-order polynomial calibration, but that requires more computation and is rarely necessary for UI touch.

For capacitive touch panels, the calibration data is often stored in the controller’s EEPROM and can be read back via I2C. The GT911, for example, has a calibration data block at register 0x8047. The data is 20 bytes long and contains the scale factors and offsets for each axis. You can read it with an I2C command like:

i2cget -y 1 0x5d 0x8047 w
i2cget -y 1 0x5d 0x8049 w

The values are in little-endian format. For a typical 3.4-inch round display, the scale factors are close to 1.0, and the offsets are close to 0.0, because the controller already handles the linearization. But if the touch panel is rotated relative to the display, you need to swap or invert the axes in the driver. For example, if the display is mounted upside down, you need to invert the Y axis:

Y_display = 800 - Y_touch

This is a common issue with round displays because the orientation is not always obvious from the connector position.

Now, let’s talk about the software stack. If you’re using a microcontroller like an ESP32 or STM32, you’ll need to implement the calibration in your firmware. The typical approach is to store the calibration constants in non-volatile memory (like EEPROM or flash) and apply them in the touch read function. For a resistive panel, you’ll read the ADC values from the touch controller (like the ADS7843 or TSC2046) and apply the affine transformation. For a capacitive panel, you’ll read the touch coordinates from the controller (like the FT6336 or GT911) and then apply any rotation or scaling if needed.

Here’s a code snippet for a resistive touch calibration on an ESP32 using the TSC2046:

void calibrate_touch() {
uint16_t raw_x, raw_y;
int32_t cal_x, cal_y;
// Read raw values from ADC
raw_x = tsc2046_read_x();
raw_y = tsc2046_read_y();
// Apply calibration constants
cal_x = (int32_t)(raw_x * 0.2105) - 25;
cal_y = (int32_t)(raw_y * 0.2089) - 25;
// Clip to display bounds
if (cal_x < 0) cal_x = 0;
if (cal_x > 799) cal_x = 799;
if (cal_y < 0) cal_y = 0;
if (cal_y > 799) cal_y = 799;
// Check if within circular region
int32_t dx = cal_x - 400;
int32_t dy = cal_y - 400;
if (dx*dx + dy*dy <= 400*400) {
// Valid touch
touch_x = cal_x;
touch_y = cal_y;
} else {
// Invalid touch, ignore
touch_x = -1;
touch_y = -1;
}
}

This code assumes the calibration constants are hardcoded, but in a real system, you’d store them in EEPROM and update them after a calibration run. The calibration run itself would involve showing crosshairs on the display, reading the ADC values, and computing the constants. You can do this with a simple loop that waits for a touch, records the raw values, and then solves the linear equations using a least-squares method.

For a capacitive panel, the calibration is simpler. The FT6336, for example, has a built-in auto-calibration feature. You trigger it by writing 0x00 to register 0x00, then 0x02 to register 0x00, and then waiting for 100 ms. The controller will recalibrate itself. The calibration data is stored internally and persists across power cycles. The only thing you need to do in software is to read the touch coordinates and apply any rotation or scaling. Here’s a code snippet for the FT6336 on an STM32:

void ft6336_auto_calibrate() {
i2c_write_byte(FT6336_ADDR, 0x00, 0x00);
delay_ms(10);
i2c_write_byte(FT6336_ADDR, 0x00, 0x02);
delay_ms(100);
i2c_write_byte(FT6336_ADDR, 0x00, 0x00);
}

After calibration, you read the touch points from registers 0x03 to 0x06 (for the first touch point). The coordinates are 12-bit values, so you need to combine two bytes. For a 3.4-inch round display, the touch panel’s resolution is usually 1024x1024 or 2048x2048, so you need to scale it down to 800x800. The scaling factor is 800 / 1024 = 0.78125, or 800 / 2048 = 0.390625. You apply this in the driver.

Now, let’s talk about the physical alignment. The touch panel overlay is bonded to the display using optically clear adhesive (OCA). The alignment tolerance is typically ±0.3 mm. On a 3.4-inch display, that’s about ±3 pixels. If the overlay is misaligned, the touch coordinates will be offset by a constant amount. This is why you need calibration. The offset can be measured by touching the center of the display and comparing the reported coordinates to (400, 400). If the offset is more than 10 pixels, you should re-run the calibration. If it’s consistent across the entire screen, you can just adjust the offset in the driver.

Another factor is the touch panel’s sensitivity. For resistive panels, the sensitivity depends on the pressure applied. A light touch might not register, while a heavy touch might cause the layers to short out. The typical activation force is 50 to 100 grams. For capacitive panels, the sensitivity depends on the capacitance of the touch object. A finger has a capacitance of about 100 pF, while a stylus might have 10 pF. The controller’s threshold is usually set to 30 to 50 pF. If the touch is not registering, you can adjust the threshold in the controller’s registers. For the GT911, the threshold is at register 0x80 and is set to a default value of 0x28 (40). You can increase it to 0x32 (50) for a more sensitive touch.

Let’s look at some common issues and their solutions. If the touch response is inverted (e.g., touching the left side registers as right), you need to swap the X axis in the calibration. This is usually done by inverting the scale factor or swapping the raw values. For a resistive panel, you can swap the X and Y lines in the hardware, but it’s easier to do it in software. For a capacitive panel, you can swap the axes in the driver by reading the registers and then swapping the values. If the touch response is jittery, it might be due to noise on the ADC lines. For resistive panels, you can add a low-pass filter in software by averaging multiple readings. For capacitive panels, the controller already has a built-in filter, but you can adjust the filter coefficient in the register.

The data sheet for the TSC2046 specifies a maximum sample rate of 125 kHz. For a 3.4-inch display, you typically need a sample rate of at least 100 Hz for smooth touch response. The ADC conversion time is about 8 microseconds, so you can read the touch position in about 16 microseconds. This gives you plenty of headroom for the calibration math. The FT6336, on the other hand, has a report rate of 60 Hz to 120 Hz, depending on the configuration. The default is 60 Hz, which is fine for most applications.

Now, let’s talk about the calibration process in a production environment. If you’re manufacturing a product with a 3.4-inch round display, you’ll need to calibrate each unit individually because the touch panel’s characteristics vary from unit to unit. The variation is due to differences in the OCA thickness, the alignment of the overlay, and the ADC reference voltage. The typical variation is about 5% in the scale factor and 10 pixels in the offset. You can use a calibration fixture that touches the screen at known points and records the raw values. The fixture can be a mechanical arm with a stylus, or a