Added Touchpad example

This commit is contained in:
lewishe
2023-04-12 13:35:08 +08:00
parent 96a1a08faf
commit 0aec97510a
4 changed files with 124 additions and 5 deletions
+62
View File
@@ -0,0 +1,62 @@
/**
* @file Touchpad.ino
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2023 Shenzhen Xin Yuan Electronic Technology Co., Ltd
* @date 2023-04-12
*
*/
#include <Arduino.h>
#define TOUCH_MODULES_GT911
#include "TouchLib.h"
#include "utilities.h"
TouchLib touch(Wire, BOARD_I2C_SDA, BOARD_I2C_SCL, GT911_SLAVE_ADDRESS1);
void setup()
{
Serial.begin(115200);
pinMode(BOARD_TOUCH_INT, INPUT);
//! The board peripheral power control pin needs to be set to HIGH when using the peripheral
pinMode(BOARD_POWERON, OUTPUT);
digitalWrite(BOARD_POWERON, HIGH);
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
touch.init();
}
void loop()
{
// You can judge the level of the touch interrupt to get whether there is a touch
if (digitalRead(BOARD_TOUCH_INT)) {
bool res = touch.read();
if (res) {
TP_Point p = touch.getPoint(0);
Serial.printf("X:%d Y:%d\n", p.x, p.y);
}
}
delay(5);
}
+56
View File
@@ -0,0 +1,56 @@
/**
* @file utilities.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2023 Shenzhen Xin Yuan Electronic Technology Co., Ltd
* @date 2023-04-11
*
*/
#pragma once
//! The board peripheral power control pin needs to be set to HIGH when using the peripheral
#define BOARD_POWERON 10
#define BOARD_I2S_WS 5
#define BOARD_I2S_BCK 7
#define BOARD_I2S_DOUT 6
#define BOARD_I2C_SDA 18
#define BOARD_I2C_SCL 8
#define BOARD_BAT_ADC 4
#define BOARD_TOUCH_INT 16
#define BOARD_KEYBOARD_INT 46
#define BOARD_SDCARD_CS 39
#define BOARD_TFT_CS 12
#define RADIO_CS_PIN 9
#define BOARD_TFT_DC 11
#define BOARD_TFT_BACKLIGHT 42
#define BOARD_SPI_MOSI 41
#define BOARD_SPI_MISO 38
#define BOARD_SPI_SCK 40
#define BOARD_BOOT 0
#define BOARD_TBOX_UP 3
#define BOARD_TBOX_DOWN 2
#define BOARD_TBOX_LEFT 1
#define BOARD_TBOX_RIGHT 15
#define BOARD_ES7210_MCLK 48
#define BOARD_ES7210_LRCK 21
#define BOARD_ES7210_SCK 47
#define BOARD_ES7210_DIN 14
#define RADIO_BUSY_PIN 13
#define RADIO_RST_PIN 17
#define RADIO_DIO1_PIN 45
#define BOARD_BOOT_PIN 0
#define BOARD_BL_PIN 42
+5 -5
View File
@@ -74,11 +74,11 @@ public:
this->writeRegister(GT911_COMMAND, (uint8_t)0x02); // software reset
delay(200);
// int val = readRegister(GT911_MODULE_SWITCH_1);
// val &= 0XFC;
// val |= 0x03;
// this->writeRegister(GT911_MODULE_SWITCH_1, (uint8_t)val);
// delay(200);
int val = readRegister(GT911_MODULE_SWITCH_1);
val &= 0XFC;
val |= 0x03;
this->writeRegister(GT911_MODULE_SWITCH_1, (uint8_t)val);
delay(200);
return true;
}
+1
View File
@@ -17,6 +17,7 @@ default_envs = T-Deck
;; Examples only one is valid
src_dir = examples/UnitTest
; src_dir = examples/Microphone
; src_dir = examples/Touchpad