Hello!
In this example we are showcasing how to interface to the TFT Touch Shield v2.0 with the PSoC 4 Pioneer Kit. This example provides a simple user interface game to demonstrate a resistive touchscreen application with the PSoC 4. This example uses the dedicated Serial Communication Block (SPI) to communicate with the LCD controller. The project does not require any UDB resources, therefore it can be used with the PSoC 4 (42xx and 41xx families). In this example we will use the CY8CKit-042 Pioneer kit and the CY8C42xx family.
Forum Post Attachments:
At the bottom of this post we are including the following items:
- Example Project Zip File
- Zip File of Images
- Project Schematic
- Component Configurations
Components Used:
The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:
- SPI
- Mux
- ADC SAR Sequencer
- CyPins
Firmware Description:
The main.c firmware is included in the example project. Please review the commented sections for more details.
In yesterday’s example we introduced the users to the TFT Touchscreen shield. In that example we included .h and .c files to help the user draw shapes and sequences on the screen. In this example we will use those same files to draw the game elements on the screen.
The game screen is divided into nine boxes, BOX1, BOX2, BOX3, BOX4, BOX5, BOX6, BOX7, BOX8, BOX9. These boxes are used to divide the screen and display the X’s and O’s from the user touches. In the project, the analog pins XP, YP, XN, YN and the 12 bit SAR ADC are used to detect if a touch is detected within a box. Once a touch is detected the corresponding analog voltages are passed to ADC. Depending on the thresholds defined for each and every box the ADC outputs will indicate which box was pressed.
Included in yesterday’s were two header files that deliver API support for this TFT Touchscreen screen. The APIs are then called to plot an X or an O by sending instructions to the LCD controller through SPI.
Hardware Connections:
In this example the user needs to connect the TFT Touchscreen shield to the PSoC 4 Pioneer kit.
Test Your Project:
Program the Pioneer kit with the example project and connect the hardware. The user will be presented with squares to place an ‘X’ or a ‘O’. The user can touch the screen to indicate where to place the character. If you connect three characters in a row the game will let you know if you have won.
I hope this example can help you in your design.
Best,
Matt