Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Binding the Resistive Touch Component with emWin - KBA230114

Binding the Resistive Touch Component with emWin - KBA230114

ChaitanyaV_61
Employee
Employee
50 questions asked 25 likes received 25 sign-ins

Author: DheerajK_81           Version: **

Translation - Japanese: 抵抗膜式タッチコンポーネントをemWinにバインドする-KBA230114 - Community Translated (JA)

The Resistive Touch Component for PSoC® 3/ PSoC 5LP devices is used to interface with a 4-wire resistive touch screen. This Component provides access to the touchscreen functionality of the SEGGER emWin graphics library to translate the resistance to screen coordinates. See the Component datasheet for more information on this.

This KBA assumes that you have the emWin graphics library set up in your project based on the display you are using. See the Segger emWin Graphics Library manual.

Do the following to allow touchscreen functionality when you set up the emWin graphics library:

1. Choose the correct library folder based on if you require RTOS support or not as shown in Figure 1. Note that both support touchscreen (ts), but one has RTOS support (os) while the other does not (nos).

Figure 1. EmWin Library

pastedImage_5.png

2. Include the header files (shown in Figure 2) from the nosts or osts folder in the path based on the library that you chose in Step 1.

  • For PSoC 5LP: \emWinGraphics_v5_46\Code\Include\PSoC4_5
  • For PSoC 3: \emWinGraphics_v5_46\Code\Include\PSoC3

Figure 2. Include Directory

   pastedImage_6.png

pastedImage_7.png

3. Enable support for touch in the GUIConf.h file. Set the macro GUI_SUPPORT_TOUCH to ‘1’ as shown below:

/*********************************************************************

*

*       Configuration of touch support

*/

#define GUI_SUPPORT_TOUCH         (1) // Support a touch screen (req. win-manager)

/*********************************************************************

Now that you have the emWin library configured to support touch, add the ResistiveTouch Component to your TopDesign schematic and build your application.

pastedImage_8.png

pastedImage_9.png

Note the.c/.h files being generated for the Component in the GeneratedSource directory.  The ResistiveTouch.h file contains emWin library-specific macros as shown in Figure 3.

Figure 3. Resistive Touch emWin Macros

  pastedImage_10.png

Do the following to bind the emWin library with the ResistiveTouch Component:

1. Copy the GUI_X_Touch.c file in emWinGraphics_v5_46\Code\Source\PSoC3\Graphics LCD Controller\ to your project .cydsn directory.  For example, if you named your PSoC Creator project “TouchScreen”, then the GUI_X_Touch.c file into the TouchScreen.cydsn directory as shown in Figure 4:

Figure 4. Project Directory

  pastedImage_11.png

2. In PSoC Creator, right-click Source Files and select Add > Existing Item as shown in Figure 5.

Figure 5. Adding the GUI_X_Touch.c File

  pastedImage_12.png

The GUI_X_Touch.c file provides the hardware routines to implement the resistive touch interface. If your project target is a PSoC 3 device, you don’t need to modify this file.

For PSoC 5LP devices, edit this file and change #include ”device.h” to #include “project.h”, and build your application.

You will notice that the touch routines in this file use the macros defined in ResistiveTouch.h as shown in Figure 6:

Figure 6. Touch Routines

pastedImage_13.png

This completes the setup of the emWin library to work with the ResistiveTouch Component.

To calibrate the touchscreen, follow the steps in Section 26.4 Touch screen driver in the EmWin User and Reference Guide in emWinGraphics_v5_46\Documentation\.

The PSoC3 and PSoC4_5 folders in the emWinGraphics_v5_46\Resources\Samples\ directory contain the files TOUCH_Sample.c and TOUCH_Calibrate.c that can be used as reference respectively for PSoC 3 and PSoC 5LP devices.

0 Likes
313 Views
Contributors