HuiZhou GreenTouch Technology Co.,Ltd

HuiZhou GreenTouch Technology Co.,Ltd

English

WhatsApp:
+8613360075499

Select Language
English
Home> Industry Information> Touch screen driver analysis-touch screen expertise

Touch screen driver analysis-touch screen expertise

May 26, 2021

Embedded device touch screens can be divided into five categories according to their technical principles: vector pressure sensing, resistive, capacitive, infrared, and surface acoustic wave. Among them, Resistive Touch Screen are mostly used in embedded systems. Resistive touch panel can be divided into four lines, five lines, and seven lines. In general, the design and implementation of WinCE Touch Screen driver has the following steps:

(1) Configure and initialize the touch screen

The touch screen driver will call the TouchPanelEnable function during the initialization process. The DDSI functions called by this function are DdsiTouchPanelEnable and DdsiTouchPanelDisable. These two DDSI interface functions are the key to the realization of the driver, which are used to turn on and off the touch screen hardware. But in order to reduce power consumption, these two functions can actually not operate the hardware, but only implement software control. At the same time, these configurations and initializations need to be performed during initialization: one is to create events hTouchPanelEvent and hCalibrationSampleAvailable, the former is triggered when a touch pen is pressed or data needs to be collected regularly after being pressed under normal conditions; and the latter is In calibration state, it is triggered when there is calibration data input. The second is to check the interrupts gIntrTouch (touch screen interrupt) and gIntrTouchChanged (timer interrupt) required for initialization, and associate these two interrupts to the event hTouchPanelEvent. The third is to create an ISR thread TouchPanelpISR, used to wait for and handle touch screen events hTouchPanelEvent, it is also the only event source in the entire driver.

(2) Calibrate touch screen reference parameters

After completing the previous tedious work, the various functions of the driver are ready, and now you can actually operate the touch screen. But generally speaking, the resistive touch screen needs to be calibrated, which means that the MDD layer calls the corresponding DDSI function to read the correction data in the registry to correct the touch screen during the driver startup process. Ideally, the calibration procedure only needs to be run once during the initial power-on test of the embedded device, and the reference value will be stored in non-volatile memory to prevent users from recalibrating during the power-on start-up. However, a high-quality touch screen driver should provide users with a way to enter the calibration routine to recalibrate when the calibration is inaccurate due to temperature drift or other factors. Ideally, only two sets of raw data are needed to correct the touch screen reference, that is, the minimum and maximum values read diagonally across the screen. But in practical applications, because many resistive touch screens have obvious non-linearity, if only a simple insertion position value between the minimum and maximum values will cause the driver to be very inaccurate. Therefore, multiple calibration points need to be acquired in WinCE, and the number of commonly used calibration points is 5.

The method is: ① First, the driver sets the number of calibration points in the function DdsiTouchPanelGetDeviceCaps; ② is the system to obtain the screen coordinates of each calibration point in TouchDriverCalibrationPointGet; ③ is to display a position symbol at the calibration point coordinates of the screen interface, the user Press the touch screen precisely at the position symbol; ④ The driver reads the corresponding touch screen coordinate value through the TouchPanelReadCalibrationPoint function; ⑤ Then starts the next calibration point until the number of touch screen coordinates and the calibration point screen will be collected after the number of cycles set The coordinates are sent to the TouchPanelSetCalibration function for processing. This function will generate calibration reference parameters. After the calibration is completed, the touch screen can start normal operation.

(3) Determine whether the screen is touched

Once the touch screen hardware settings, initialization and reference parameter calibration are completed, a reliable method is needed to determine whether the screen has been touched.

WinCE provides a detection mechanism for whether the screen is touched, and can also choose whether to interrupt the main processor when a touch event occurs. The function name of the driver that determines whether the screen is touched is WaitForTouchState (). An interrupt that wakes up the host when the screen is first touched is called a PEN_DOWN interrupt. Doing so allows the driver to interrupt its execution when the screen is not touched, without consuming any CPU resources, and once the user touches the screen, the driver is woken up and enters the conversion mode.

After being awakened, there is a group of analog-to-digital data waiting for conversion and an interrupt signal is generated. Interrupts are an important method of dealing with hardware and software, so most drivers involve interrupt handling. As far as interrupt handling is concerned, WinCE uses a unique approach. It divides the interrupt processing into two steps: Interrupt Service Routine (ISR) and Interrupt Service Thread (IST). Specifically, the device interrupt request (IRQ) of each hardware is associated with an ISR. When an interrupt occurs and is not masked, the kernel calls the ISR registered by the interrupt. Because the ISR runs in kernel mode, it should be designed to be as short as possible. The basic responsibility of the ISR is to guide the kernel to schedule and start the appropriate IST. IST is written in the device driver software module, which acquires or sends data and control code from the hardware, and further handles device interrupts.

The WinCE touch screen driver uses an interrupt method to detect the pressed state of the touch pen. When an interrupt generated when the touch pen is pressed is detected, an event is triggered to notify a worker thread to start collecting data. At the same time, the driver will open a hardware timer, as long as it detects that the touch pen is still pressed, it will periodically trigger the same event to notify the worker thread to continue collecting data until the touch pen is lifted and then close the timer. Simply put, the driver will use the two interrupt sources of touch screen interrupt and timer interrupt at the same time. The purpose is not only to monitor the pressed and lifted state of the touch pen, but also to detect the drag trajectory when the touch pen is pressed. The two logical interrupts of the touch screen interrupt are: SYSINTR_TOUCH is used to generate a corresponding interrupt when the touch pen clicks on the touch screen; SYSINTR_TOUCH_CHANGE is used to generate a corresponding interrupt when the touch pen leaves.

Ideally, only two sets of raw data are needed to correct the touch screen reference, that is, the minimum and maximum values read diagonally across the screen. But in practical applications, because many resistive touch screens have obvious non-linearity, if only a simple insertion position value between the minimum and maximum values will cause the driver to be very inaccurate. Therefore, multiple calibration points need to be acquired in WinCE, and the number of commonly used calibration points is 5.

The method is: ① First, the driver sets the number of calibration points in the function DdsiTouchPanelGetDeviceCaps; ② is the system to obtain the screen coordinates of each calibration point in TouchDriverCalibrationPointGet; ③ is to display a position symbol at the calibration point coordinates of the screen interface, the user needs Press the touch screen precisely at the position symbol; ④ The driver reads the corresponding touch screen coordinate value through the TouchPanelReadCalibrationPoint function; ⑤ Then starts the next calibration point until the number of touch screen coordinates and the calibration point screen will be collected after the number of cycles set The coordinates are sent to the TouchPanelSetCalibration function for processing. This function will generate calibration reference parameters. After the calibration is completed, the touch screen can start normal operation.

The above is the Touch screen driver analysis-touch screen expertise we have listed for you. You can submit the following form to obtain more industry information we provide for you.

You can visit our website or contact us, and we will provide the latest consultation and solutions

Share to:

Send Inquiry

Home> Industry Information> Touch screen driver analysis-touch screen expertise
  • Send Inquiry

Copyright © 2024 HuiZhou GreenTouch Technology Co.,Ltd All rights reserved. Privacy Policy

We will contact you immediately

Fill in more information so that we can get in touch with you faster

Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.

Send