1. After the LCD display is complete, you need to understand the touch screen related knowledge on this basis. Similarly, if you use the touch screen, you need to initialize it. As mentioned last time, you can see this in the chip manual.
The four pins are used to control the touch screen. Next, I will analyze a piece of code based on the script of:
The main function is quite simple:
LCD Initialization is clear, and the next step is to initialize the touch screen.
1. If the touch track screen experiences 30th interruptions of the External Interrupt VIC1, you must first set the interrupt.
2. After an interruption is received, the ad ing will be performed to convert our analog quantity to digital quantity. Here there is a delay. What is the Preset Delay Time? The following code provides the answer:
3. Some interrupt registers must be clear during initialization, including the touch screen ADC register and the touch screen wake-up interrupt register.
4. The following is the configuration of the ADC control register. For more information, see the code.
The initialization of the touch screen is complete.
Step 2
When an interrupt occurs, the VICxADDRESS In the interrupt control register will receive the information. Then, he can determine that there is an interruption in the VIC1 group and then enter the interrupt processing function to interrupt the processing function, in order to continue to judge whether the touch pen is interrupted by the press or when the touch pen is released
1. If the pen is interrupted by the press, first adjust the value of the Register ADCTSC.
Because we need to manually measure the coordinates of X and Y, we have the following code.
2. Through functions, we can obtain the corresponding x/y coordinate values.
The specific implementation method of GetCoordinate () can be expressed in the following code:
// Obtain the Coordinate Function
Void GetCoordinate (void)
{
Inttemp;
Temp = xValue;
// Boundary Determination
If (xValue <1, 185)
Temp = 185;
Else'if (xValue> 850)
Temp = 850;
XPos = (850-temp) * 479/(850-185 );
Temp = yValue;
If (yvalue <1, 300)
Temp = 300;
Elseif (yvalue> 700)
Temp = 700;
Ypos = (700-temp) * 271/(700-300 );
}
3. If the corresponding coordinates are obtained, it is easy to implement. As long as you simply use the functions of the preceding dashes, You can implement the touch screen function.
4. Don't forget. This is just an interruption. to wait for the next interruption, we also need to clear the interruption
5. The following code clears the interrupt to respond to the next code.
The touch screen just wants to talk about it here.