rduino IDE下载:XPT2046_TouchScreen库。

#define TOUCH_CS_PIN 33

#define TOUCH_IRQ_PIN 34

触摸参数需要调校:
打开示例:GUIslice->arduino->diag_ard_touch_calib
运行后,点击屏幕四角的点,最后会出现参数

ADATOUCH_X_MIN
ADATOUCH_X_MAX
ADATOUCH_Y_MIN
ADATOUCH_Y_MAX
把这些数值修改到esp-tftespi-default-xpt2046.h中。

#ifndef _GUISLICE_CONFIG_ARD_H_
#define _GUISLICE_CONFIG_ARD_H_// =============================================================================
// GUIslice library (example user configuration) for:
//   - CPU:     ESP8266 / ESP32
//   - Display: TFT_eSPI (defined by TFT_eSPI config)
//   - Touch:   XPT2046 (Resistive)
//   - Wiring:  Custom breakout
//              - Pinout defined by TFT_eSPI's User_Setup.h
//
//   - Example display:
//     -
//
// TFT_eSPI Notes:
//   - When using the TFT_eSPI library, there are additional
//     library-specific configuration files that may need
//     customization (including pin configuration), such as
//     "User_Setup_Select.h" (typically located in the
//     Arduino /libraries/TFT_eSPI folder). Please refer to
//     Bodmer's TFT_eSPI library for more details:
//     https://github.com/Bodmer/TFT_eSPI
//
//   - To avoid potential SPI conflicts, it is recommended
//     that SUPPORT_TRANSACTIONS is defined in TFT_eSPI's "User Setup"
//
//   - For touch support by external drivers, the TFT_eSPI's integrated
//     XPT2046 touch driver should be disabled. This can be done by
//     ensuring that TFT_eSPI's User_Setup.h does not define TOUCH_CS
//     (ie. it should be commented out).
//
// DIRECTIONS:
// - To use this example configuration, include in "GUIslice_config.h"
//
// WIRING:
// - As this config file is designed for a breakout board, customization
//   of the Pinout in SECTION 2 will be required to match your display.
//
// =============================================================================
// - Calvin Hass
// - https://github.com/ImpulseAdventure/GUIslice
// =============================================================================
//
// The MIT License
//
// Copyright 2016-2020 Calvin Hass
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// =============================================================================
// \file GUIslice_config_ard.h// =============================================================================
// User Configuration
// - This file can be modified by the user to match the
//   intended target configuration
// =============================================================================#ifdef __cplusplus
extern "C" {
#endif // __cplusplus// =============================================================================// USER DEFINED CONFIGURATION// =============================================================================// -----------------------------------------------------------------------------// SECTION 1: Device Mode Selection// - The following defines the display and touch drivers//   and should not require modifications for this example config// -----------------------------------------------------------------------------#define DRV_DISP_TFT_ESPI         // bodmer/TFT_eSPI#define DRV_TOUCH_XPT2046_PS      // PaulStoffregen/XPT2046_Touchscreen// -----------------------------------------------------------------------------// SECTION 2: Pinout// -----------------------------------------------------------------------------// For TFT_eSPI, the display wiring is defined by TFT_eSPI's User_Setup.h// SD Card//#define ADAGFX_PIN_SDCS    2 // ESP8266 + Adafruit FeatherWing 2.4"#define ADAGFX_PIN_SDCS     14 // ESP32   + Adafruit FeatherWing 2.4"//#define ADAGFX_PIN_SDCS    5 // Others  + Adafruit FeatherWing 2.4"// -----------------------------------------------------------------------------// SECTION 3: Orientation// -----------------------------------------------------------------------------// Set Default rotation of the display// - Values 0,1,2,3. Rotation is clockwise#define GSLC_ROTATE     1// -----------------------------------------------------------------------------// SECTION 4: Touch Handling// - Documentation for configuring touch support can be found at://   https://github.com/ImpulseAdventure/GUIslice/wiki/Configure-Touch-Support// -----------------------------------------------------------------------------// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .// SECTION 4A: Update your pin connections here// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .// TFT_eSPI: Chip Select for Touch Device// - Since we are not using the TFT_eSPI's integrated XPT2046 touch driver,//   it is best to disable it. This can be done by ensuring that the TOUCH_CS line//   in TFT_eSPI's User_Setup.h is commented out.// Touch bus & pinout#define XPT2046_CS     33#define XPT2046_IRQ    255 // IRQ pin or 255 if no IRQ used// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .// SECTION 4B: Update your calibration settings here// - These values should come from the diag_ard_touch_calib sketch output// - Please update the values to the right of ADATOUCH_X/Y_MIN/MAX_* accordingly// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .// Calibration settings from diag_ard_touch_calib:// DRV_TOUCH_XPT2046:#define ADATOUCH_X_MIN    3951#define ADATOUCH_X_MAX    449#define ADATOUCH_Y_MIN    232#define ADATOUCH_Y_MAX    3716#define ADATOUCH_REMAP_YX 0    // Some touch controllers may swap X & Y coords// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .// SECTION 4D: Additional touch configuration// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .// Define pressure threshold for detecting a touch// - Specifying this range helps eliminate some erroneous touch events//   resulting from noise in the touch overlay detection// - For config details, please see://   https://github.com/ImpulseAdventure/GUIslice/wiki/Configuring-Touch-Pressure#define ADATOUCH_PRESS_MIN  200#define ADATOUCH_PRESS_MAX  4000// -----------------------------------------------------------------------------// SECTION 5: Diagnostics// -----------------------------------------------------------------------------// Error reporting// - Set DEBUG_ERR to >0 to enable error reporting via the Serial connection// - Enabling DEBUG_ERR increases FLASH memory consumption which may be//   limited on the baseline Arduino (ATmega328P) devices.//   - DEBUG_ERR 0 = Disable all error messaging//   - DEBUG_ERR 1 = Enable critical error messaging (eg. init)//   - DEBUG_ERR 2 = Enable verbose error messaging (eg. bad parameters, etc.)// - For baseline Arduino UNO, recommended to disable this after one has//   confirmed basic operation of the library is successful.#define DEBUG_ERR               1   // 1,2 to enable, 0 to disable// Debug initialization message// - By default, GUIslice outputs a message in DEBUG_ERR mode//   to indicate the initialization status, even during success.// - To disable the messages during successful initialization,//   uncomment the following line.//#define INIT_MSG_DISABLE// -----------------------------------------------------------------------------// SECTION 6: Optional Features// -----------------------------------------------------------------------------// Enable of optional features// - For memory constrained devices such as Arduino, it is best to//   set the following features to 0 (to disable) unless they are//   required.#define GSLC_FEATURE_COMPOUND       0   // Compound elements (eg. XSelNum)#define GSLC_FEATURE_XTEXTBOX_EMBED 0   // XTextbox control with embedded color#define GSLC_FEATURE_INPUT          0   // Keyboard / GPIO input control// Enable support for SD card// - Set to 1 to enable, 0 to disable// - Note that the inclusion of the SD library consumes considerable//   RAM and flash memory which could be problematic for Arduino models//   with limited resources.#define GSLC_SD_EN    0// Enable support for SPIFFS File System access// - Set to 1 to enable, 0 to disable// - Note that this requires the inclusion of TFT_eFEX library#define GSLC_SPIFFS_EN               0 // =============================================================================// SECTION 10: INTERNAL CONFIGURATION// - The following settings should not require modification by users// =============================================================================// -----------------------------------------------------------------------------// Touch Handling// -----------------------------------------------------------------------------// Define the maximum number of touch events that are handled// per gslc_Update() call. Normally this can be set to 1 but certain// displays may require a greater value (eg. 30) in order to increase// responsiveness of the touch functionality.#define GSLC_TOUCH_MAX_EVT    1// -----------------------------------------------------------------------------// Misc// -----------------------------------------------------------------------------// Define buffer size for loading images from SD// - A larger buffer will be faster but at the cost of RAM#define GSLC_SD_BUFFPIXEL   50// Enable support for graphics clipping (DrvSetClipRect)// - Note that this will impact performance of drawing graphics primitives#define GSLC_CLIP_EN 1// Enable for bitmap transparency and definition of color to use#define GSLC_BMP_TRANS_EN     1               // 1 = enabled, 0 = disabled#define GSLC_BMP_TRANS_RGB    0xFF,0x00,0xFF  // RGB color (default: MAGENTA)#define GSLC_USE_FLOAT        0   // 1=Use floating pt library, 0=Fixed-point lookup tables#define GSLC_DEV_TOUCH ""#define GSLC_USE_PROGMEM      0#define GSLC_LOCAL_STR        0   // 1=Use local strings (in element array), 0=External#define GSLC_LOCAL_STR_LEN    30  // Max string length of text elements// -----------------------------------------------------------------------------// Debug diagnostic modes// -----------------------------------------------------------------------------// - Uncomment any of the following to enable specific debug modes//#define DBG_LOG           // Enable debugging log output//#define DBG_TOUCH         // Enable debugging of touch-presses//#define DBG_FRAME_RATE    // Enable diagnostic frame rate reporting//#define DBG_DRAW_IMM      // Enable immediate rendering of drawing primitives//#define DBG_DRIVER        // Enable graphics driver debug reporting// =============================================================================#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _GUISLICE_CONFIG_ARD_H_

XPT2046 触摸校正相关推荐

  1. ESP32 开发笔记(三)源码示例 24_XPT2046_Touch_Test 电阻触摸XPT2046驱动测试触摸校正

    开发板购买链接 https://item.taobao.com/item.htm?spm=a2oq0.12575281.0.0.50111deb2Ij1As&ft=t&id=62636 ...

  2. 基于FPGA的XPT2046触摸控制器设计

    基于FPGA的XPT2046触摸控制器设计 小梅哥编写,未经许可,文章内容和所涉及代码不得用于其他商业销售的板卡 本实例所涉及代码均可通过向 xiaomeige_fpga@foxmail.com  发 ...

  3. ESP32驱动3.2寸ILI9341显示屏+XPT2046触摸,GUIslice用户图形库

    ESP32的主板ESPDUINO-32如下: 屏用如下的: 显示驱动用TFT_eSPI,这个显示的速度比adafruit ILI9341快10倍. 一.配置TFT_eSPI: arduino IDE ...

  4. 【工程源码】基于FPGA的XPT2046触摸控制器设计

    本文和设计代码由FPGA爱好者小梅哥编写,未经作者许可,本文仅允许网络论坛复制转载,且转载时请标明原作者. XPT2046是一款设计用于移动电话.个人数字助理.便携式一起.付款中断设备.触摸屏显示器等 ...

  5. ESP32 开发笔记(五)XPT2046 触摸

    ESP32 Touch TFT GitHub地址:工程源码 该工程时使用了 lcd.xpt2046.esp32 实现了触摸屏基础功能 编译.运行 请参考 esp-idf 的工程配置与运行

  6. ESP32 开发笔记(三)源码示例 6_TouchPad_Interrupt 电容触摸中断实现触摸按钮

    开发板购买链接 https://item.taobao.com/item.htm?spm=a2oq0.12575281.0.0.50111deb2Ij1As&ft=t&id=62636 ...

  7. 嵌入式驱动移植之触摸驱动初识

    开发环境 BootLoader:u-boot-1.1.6 kernel:linux-2.6.30.4 CPU:s3c2440 开发板:TQ2440 参考资料:<天嵌科技Linux移植手册> ...

  8. [GUI] ESP32(idf)触摸屏(XPT2046)驱动及驱动校准

    1. XPT2046简介 XPT2046是一款4线电阻式触摸屏控制器,包含12位125 kHz采样SAR型a /D转换器. XPT2046可以通过执行两个A/D转换来检测按下的屏幕位置. - 下面简单 ...

  9. 4-4.stm32之LCD XPT2046的使用

    xpt2046介绍 xpt2046触控显示模组包含xpt2046芯片触控芯片+ili9341lcd ic驱动芯片+串口转并口控制器芯片. xpt2046本来意思是一个带有ad驱动芯片,主要检测我们在触 ...

最新文章

  1. Linux下的Silverlight:Moonlight 1.0 Beta 1发布了
  2. java socket 全双工客户端_java socket实现全双工通信
  3. 获取请求url的查询字符串
  4. [Python web开发] Web框架开发基础 (一)
  5. 高仿带感魔性病毒源码+成品(最近很火的)
  6. java 注解 属性 类型_收藏!你一定要知道的Java8中的注解
  7. zjnu1730 PIRAMIDA(字符串,模拟)
  8. java start launcher_hmcl启动失败
  9. div+css 定位浅析
  10. c语言编码菱形用换行吗,使用c语言输出菱形
  11. 软件测试电商web项目如何描述,测试web项目实战
  12. Flink 滑动窗口优化
  13. android 跳转oppo应用中心_Android唤起应用商店并跳转到应用详情页
  14. C语言——三目运算符的进阶用法,比较三个或者四个数的大小
  15. python list diff_PythonList交集,并集,差集的应用
  16. MSDC 4.3 接口规范(20)
  17. UGUI实现Joystick
  18. singletask和onNewintent
  19. 使用pnpm+vue-cli,出现报错:Error: command failed: pnpm install --reporter silent --shamefully-hoist
  20. bulldog-1靶机 write up 源码 MD5解密得到密码到后台 命令执行绕过 反弹shell string分析文件得到密码提权

热门文章

  1. jmockit教程_Jmockit(一): 入门
  2. python爬取4399小游戏数据_4399小游戏童年的乐趣,python爬取4399全站小游戏
  3. 【Unity实战】制作类元气骑士、挺进地牢——俯视角射击游戏多种射击效果(二)(附源码)
  4. 电脑城装机系统SP3稳定版-080705
  5. 本地搭建gitlab服务器(Ubuntu)
  6. java写的学生信息查询系统_用JAVA写一个简易的学生信息管理系统
  7. 奈奎斯特采样定理(Nyquist)
  8. tina -飞机大战6.0
  9. 手机小游戏辅助程序的实现
  10. 迫于华为的强大技术领先优势,美国运营商终于还是低头交专利费