How to Calibrate Touch on a 1.39 Inch Round AMOLED Display
To calibrate touch on a 1.39 inch round AMOLED display, you need to align the touch controller’s raw coordinate data with the display’s physical pixel grid, which is a 400x400 resolution panel with a circular active area. The most reliable method involves using a combination of firmware-level calibration routines and application-side interpolation, because the round shape introduces non-linear touch points that rectangular displays don’t have. Start by checking if your display module, like the 1.39 inch 400x400 round amoled display, uses a capacitive touch overlay with a dedicated controller (e.g., FT6336 or GT911). These controllers typically output raw X and Y values in a 12-bit range (0–4095), but the actual touch area is a circle inscribed within the square touch sensor matrix. So, you must map the raw coordinates to the 400x400 pixel space while ignoring points outside the circular boundary. The calibration process involves three steps: collecting calibration data, computing transformation parameters, and applying edge correction for the round shape. For the first step, you’ll need to touch known points on the display—typically the four cardinal points (top, bottom, left, right) and the center—using a calibration utility or a simple firmware routine. The touch controller returns raw ADC values for each point, which you can record. For example, if the center of the display is at pixel (200, 200), the raw touch controller might return (2048, 2048) in a 12-bit system. But due to manufacturing tolerances, the actual center might be off by 10–50 counts. So, you need to compute scaling factors: scaleX = (maxPixelX - minPixelX) / (maxRawX - minRawX), and similarly for Y. Let’s say you touch the left edge at pixel (0, 200) and get raw X = 100, and the right edge at pixel (400, 200) with raw X = 4000. Then scaleX = (400 - 0) / (4000 - 100) = 400 / 3900 ≈ 0.1026 pixels per raw count. The offset is offsetX = pixelX - (rawX * scaleX) = 0 - (100 * 0.1026) ≈ -10.26. So, for any raw touch point, pixelX = (rawX * 0.1026) - 10.26. But this linear mapping works only for rectangular areas. For a round 1.39-inch display, the active pixel area is a circle with a radius of 200 pixels from the center (200, 200). So, after computing the raw-to-pixel mapping, you must validate that the touch point lies within the circle: (pixelX - 200)^2 + (pixelY - 200)^2 <= 200^2. If it’s outside, the touch should be ignored or snapped to the nearest edge. This is critical because the touch sensor matrix is square, but the display is round, so touches near the corners of the square are physically outside the visible area. You can also implement a more advanced calibration using a 3x3 grid of touch points (9 points total) to correct for non-linearities caused by the curved display substrate. The AMOLED panel itself is flexible, but the touch sensor is typically laminated on top, and the curvature can introduce slight distortion in the electric field, especially near the edges. For example, at the 12 o’clock position (pixel 200, 0), the raw touch might be offset by 20 counts in Y due to the curvature. So, you can use a bilinear interpolation or a polynomial fit (e.g., a second-order polynomial) to map raw coordinates to pixel coordinates more accurately. A common approach is to use the following transformation: pixelX = a0 + a1*rawX + a2*rawY + a3*rawX*rawY, and similarly for pixelY. You solve for the coefficients using the 9 calibration points. This accounts for rotation, scaling, and skew, which are common in round displays because the touch sensor’s electrode pattern is often radial rather than rectangular. Data from the touch controller’s datasheet (e.g., FT6336) shows that the raw resolution is 12-bit, but the effective resolution after calibration is typically around 8-bit (256 levels) due to noise and jitter. So, you should also apply a low-pass filter (e.g., moving average over 5 samples) to smooth the touch coordinates. The filter can be implemented as: filteredX = (rawX_prev4 + rawX_prev3 + rawX_prev2 + rawX_prev1 + rawX_current) / 5. This reduces jitter to about ±2 pixels, which is acceptable for a 400x400 display. For the round shape, you also need to handle the edge case where the touch point is near the border. The display’s active area has a radius of 200 pixels, but the touch sensor’s sensitivity drops off near the edge because the capacitive coupling changes. So, you might need to adjust the threshold for touch detection—typically set to 50–100 counts in the raw ADC—to avoid false touches near the edge. You can calibrate this by measuring the raw touch value at the edge and setting the threshold to 70% of that value. For example, if the raw touch at the edge is 500 counts, set the threshold to 350 counts. This ensures that only intentional touches are registered. Another important factor is the display’s refresh rate, which is 60 Hz for the MIPI interface. The touch controller’s report rate is typically 100–200 Hz, so you need to synchronize the touch data with the display’s frame rate to avoid tearing. Use a double-buffering technique: store touch data in a buffer and update it only at the beginning of each frame. This ensures that the touch coordinates are consistent with the displayed content. For the round display, you also need to consider the dead zone in the center, which is common for AMOLED panels because the pixel circuit is located there. The dead zone is typically 10–20 pixels in diameter, so touches within that area should be ignored or mapped to the center. You can detect this by checking if the touch point is within a circle of radius 10 pixels from the center. If so, snap it to the center. This prevents accidental touches from interfering with UI elements. The calibration data should be stored in non-volatile memory (e.g., EEPROM or flash) on the display module or the host microcontroller. Use a checksum (e.g., CRC-8) to verify the integrity of the calibration data. For example, store the calibration parameters as a 32-byte structure: 4 bytes for scaleX, 4 bytes for offsetX, 4 bytes for scaleY, 4 bytes for offsetY, 4 bytes for curvature coefficients, and 4 bytes for the checksum. The total size is 24 bytes plus 4 bytes for the checksum. You can also store the calibration grid points (9 points, each 2 bytes for raw X and 2 bytes for raw Y, total 36 bytes) for more accurate mapping. The calibration process should be done at the factory or during first boot, but you can also provide a user-facing calibration utility that allows the user to touch the four cardinal points and the center. This is useful for compensating for changes in the touch sensor’s characteristics over time due to temperature or aging. The touch sensor’s capacitance changes by about 0.5% per degree Celsius, so recalibration every 6 months is recommended. For the round display, the calibration algorithm must also account for the aspect ratio of the touch sensor. The sensor matrix is 400x400, but the physical touch area is a circle with a diameter of 400 pixels. So, the scaling factors should be the same for X and Y, but the offset might differ due to misalignment. You can measure the misalignment by touching the center of the display and comparing the raw coordinates to the expected pixel center. If the raw center is (2050, 2030) instead of (2048, 2048), the offset is 2 counts in X and 18 counts in Y. This is a typical misalignment of 0.5% in X and 4% in Y, which is acceptable for most applications. However, for high-precision applications like drawing or gaming, you should calibrate to within 1 pixel accuracy. This requires a 16-point calibration grid (4x4) to correct for non-linearities. The 16-point grid provides 16 calibration points, which you can use to compute a bicubic interpolation for the touch mapping. The bicubic interpolation uses 16 coefficients to map raw coordinates to pixel coordinates with sub-pixel accuracy. The formula is: pixelX = sum(i=0 to 3) sum(j=0 to 3) a_ij * rawX^i * rawY^j. You solve for the 16 coefficients using the 16 calibration points. This is computationally intensive but can be done offline and stored in the calibration data. For the round display, the touch mapping must also handle the fact that the touch sensor’s electrode pattern is radial, which means the sensitivity varies with the angle. You can measure the sensitivity at different angles by touching the display at 8 points around the circle (every 45 degrees) and recording the raw touch values. The raw touch value should be consistent within 10% across all angles, but if it varies, you can apply a gain correction factor based on the angle. The angle is computed as atan2(pixelY - 200, pixelX - 200). For example, if the raw touch value at 0 degrees (right) is 1000 counts, and at 90 degrees (top) is 900 counts, the gain correction factor for 90 degrees is 1000/900 = 1.111. Apply this factor to the raw touch value before mapping. This ensures consistent touch sensitivity across the entire round display. The calibration process should also include a dead zone calibration for the touch sensor’s edge. The edge of the round display is curved, so the touch sensor’s capacitance changes rapidly near the edge. You can measure the raw touch value at the edge by touching the display at 10 points along the edge and recording the raw values. The edge is defined as the circle with radius 200 pixels. The raw touch value at the edge should be about 70% of the maximum raw touch value (which is 4095 for a 12-bit system). So, the edge threshold is 0.7 * 4095 = 2866 counts. If the raw touch value is below this threshold, the touch is considered invalid. This prevents false touches from the user’s palm or accidental contact. For the round display, you also need to calibrate the touch controller’s sensitivity settings. The touch controller (e.g., FT6336) has registers for sensitivity, threshold, and debounce. The default sensitivity is typically 0x10 (16 in decimal), but for a round display, you might need to increase it to 0x20 (32) to compensate for the curved surface. The threshold register is set to 0x28 (40) by default, but you should set it to 0x50 (80) to reduce false touches. The debounce register is set to 0x02 (2 samples) by default, but you should increase it to 0x04 (4 samples) to filter out noise. These settings can be written to the touch controller via I2C or SPI during initialization. The calibration data should also include the touch controller’s firmware version, which you can read from the controller’s register (e.g., register 0xAF for FT6336). The firmware version is typically 0x01 to 0x05, and newer versions have better edge handling. For the round display, the touch controller’s firmware must support circular touch areas. Some controllers have a built-in circular touch mode that automatically maps the square sensor to a circle. You can enable this mode by setting a register (e.g., register 0x80 for FT6336) to 0x01. This mode uses a look-up table to map raw coordinates to the circular area, which reduces the calibration effort. However, the built-in mode might not be accurate for all displays, so you should test it and adjust the calibration parameters accordingly. The calibration process should also include a touch accuracy test. Use a precision touch probe (e.g., a stylus with a 1mm tip) to touch the display at 25 points (5x5 grid) and compare the reported pixel coordinates to the actual touch points. The accuracy should be within 2 pixels for 95% of the points. If the accuracy is worse, you need to recalibrate with more points or adjust the interpolation method. For the round display, the accuracy is typically worse near the edge due to the curvature, so you should use a higher density of calibration points near the edge (e.g., 8 points on the edge and 4 points in the center). The calibration data should be stored in a format that is easy to read and update. Use a JSON-like structure in the firmware, but for performance, use a binary format. For example, store the calibration parameters as a 64-byte block: 4 bytes for the version, 4 bytes for the checksum, 4 bytes for the number of calibration points, and then 48 bytes for the calibration points (each point is 2 bytes for raw X, 2 bytes for raw Y, 2 bytes for pixel X, 2 bytes for pixel Y, total 8 bytes per point, for 6 points). The remaining 4 bytes are reserved for future use. The checksum is computed as the XOR of all bytes in the block. This ensures that the calibration data is not corrupted. For the round display, the calibration process should be done in a controlled environment with a temperature of 25°C and humidity of 50%. The touch sensor’s capacitance changes with temperature and humidity, so the calibration is valid only within a range of 10°C to 40°C and 20% to 80% humidity. If the environment changes, the calibration might drift, and you should provide a recalibration option in the firmware. The recalibration process can be triggered by the user by pressing a button or by a software command. The firmware should store the calibration data in a separate partition of the flash memory to avoid overwriting the application code. The calibration data should be read during boot and applied to the touch controller. The touch controller’s registers should be updated with the calibration parameters before the display is used. This ensures that the touch coordinates are accurate from the first touch. For the round display, the calibration data should also include the display’s physical dimensions: the active area diameter is 1.39 inches, which is 35.3 mm. The pixel density is 400 pixels per 35.3 mm, which is 11.3 pixels per mm. This is important for scaling the touch coordinates to physical units. For example, if you need to map the touch coordinates to a physical button that is 10 mm wide, you need to convert the pixel coordinates to mm: mmX = pixelX / 11.3. This allows you to design UI elements that are physically consistent across different displays. The calibration process should also include a linearity test. Use a touch probe to draw a straight line across the display and record the touch coordinates. The line should be straight to within 1 pixel deviation. If the line is curved, you need to adjust the calibration parameters. The curvature is typically caused by the non-linear mapping of the touch sensor’s electrode pattern. You can correct this by using a polynomial fit with higher order terms. For example, a third-order polynomial can correct for S-shaped distortions. The calibration data should include the polynomial coefficients, which are computed during the calibration process. The polynomial coefficients are stored as 4-byte floating-point numbers. For a third-order polynomial, you need 10 coefficients for X and 10 for Y, total 80 bytes. This is a large amount of data, but it provides high accuracy. For the round display, the polynomial coefficients should be computed using a least-squares fit to the calibration points. The fit should minimize the sum of squared errors between the predicted pixel coordinates and the actual pixel coordinates. The error should be less than 1 pixel for 99% of the points. If the error is larger, you need to use a higher-order polynomial or more calibration points. The calibration process should also include a touch latency test. The touch latency is the time from the touch event to the display update. For a 60 Hz display, the latency should be less than 16.7 ms. The touch controller’s report rate is typically 100 Hz, which means a new touch report every 10 ms. The firmware should process the touch report within 5 ms and update the display within the next frame. This ensures that the touch feels responsive. For the round display, the touch latency might be higher near the edge due to the calibration algorithm, so you should optimize the algorithm for speed. Use integer arithmetic instead of floating-point arithmetic, and precompute the calibration parameters as fixed-point numbers. For example, use a 16.16 fixed-point format for the scaling factors and offsets. This reduces the processing time to less than 1 ms. The calibration data should be stored in the flash memory in a format that is compatible with the bootloader. The bootloader should read the calibration data and apply it to the touch controller before the application starts. This ensures that the touch is calibrated from the moment the display turns on. For the round display, the calibration data should also include the touch controller’s configuration registers, such as the sensitivity, threshold, and debounce settings. These settings are stored as a 16-byte block and written to the touch controller during initialization. The calibration process should also include a touch noise test. Use a spectrum analyzer to measure the noise on the touch sensor’s output. The noise should be less than 10 counts RMS. If the noise is higher, you need to add a low-pass filter in the firmware. The filter can be a simple moving average filter with a window of 5 samples. This reduces the noise to less than 2 counts RMS. The filter should be applied after the calibration mapping to avoid introducing latency. For the round display, the noise might be higher near the edge due to the curvature, so you should use a larger filter window near the edge. The calibration data should include the filter window size for different regions of the display. For example, use a window of 5 samples for the center region and a window of 10 samples for the edge region. This ensures that the noise is filtered out without increasing the latency too much. The calibration process should also include a touch sensitivity test. Use a force gauge to apply a known force to the touch surface and measure the raw touch value. The raw touch value should be proportional to the force within a range of 0.1 N to 2 N. The sensitivity is typically 100 counts