Initial commit

This commit is contained in:
2026-03-31 13:17:21 +02:00
commit 7eeecff042
6821 changed files with 3514215 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Micky
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.

View File

@@ -0,0 +1,2 @@
# TouchLib
In order to integrate the touch driver, let the touch interface be unified. (The following chips are currently supported. CST328, CST816, CST820, GT911)

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,92 @@
#define TOUCH_MODULES_GT911
//#define TOUCH_MODULES_CST_SELF
//#define TOUCH_MODULES_CST_MUTUAL
//#define TOUCH_MODULES_ZTW622
//#define TOUCH_MODULES_L58
#include "Arduino.h"
#include "TouchLib.h"
#include "Wire.h"
#define PIN_IIC_SCL 48
#define PIN_IIC_SDA 8
#define PIN_TOUCH_INT 1
#define PIN_TOUCH_RES 2
#define TOUCH_READ_FROM_INTERRNUPT 0
TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, GT911_SLAVE_ADDRESS2);
void scan_i2c_device(TwoWire &i2c)
{
Serial.println("Scanning for I2C devices ...");
Serial.print(" ");
for (int i = 0; i < 0x10; i++)
{
Serial.printf("0x%02X|", i);
}
uint8_t error;
for (int j = 0; j < 0x80; j += 0x10)
{
Serial.println();
Serial.printf("0x%02X |", j);
for (int i = 0; i < 0x10; i++)
{
Wire.beginTransmission(i | j);
error = Wire.endTransmission();
if (error == 0)
Serial.printf("0x%02X|", i | j);
else
Serial.print(" -- |");
}
}
Serial.println();
}
bool get_int = false;
void setup()
{
Serial.begin(115200);
Serial.println("Hello T-Display-S3");
pinMode(PIN_TOUCH_RES, OUTPUT);
digitalWrite(PIN_TOUCH_RES, 0);
delay(200);
digitalWrite(PIN_TOUCH_RES, 1);
delay(200);
Wire.begin(PIN_IIC_SDA, PIN_IIC_SCL);
scan_i2c_device(Wire);
touch.init();
#if (TOUCH_READ_FROM_INTERRNUPT)
attachInterrupt(
PIN_TOUCH_INT,
[]
{
get_int = 1;
Serial.println("get_int");
},
CHANGE);
#endif
}
void loop()
{
delay(5);
#if (TOUCH_READ_FROM_INTERRNUPT)
if (get_int)
{
get_int = 0;
touch.read();
#else
if (touch.read())
{
#endif
uint8_t n = touch.getPointNum();
Serial.printf("getPointNum: %d ", n);
for (uint8_t i = 0; i < n; i++)
{
TP_Point t = touch.getPoint(i);
Serial.printf("[%d] point x: %d point y: %d \r\n", i, t.x, t.y);
}
}
}

View File

@@ -0,0 +1,11 @@
name=TouchLib
version=0.0.1
author=Micky
maintainer=Micky
sentence=ESP32
paragraph=Supports TFT displays using drivers (ILI9341 etc) that operate with hardware SPI or 8 bit parallel.
category=Integrated touch driver (CST328, CST816, CST820, GT911)
url=
architectures=*
includes=TouchLib.h

View File

@@ -0,0 +1,148 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 micky
*
* 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 TouchLibCSTMutual.tpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#include "REG/CSTMutualConstants.h"
#include "TouchLibCommon.tpp"
#include "TouchLibInterface.hpp"
class TouchLibCSTMutual : public TouchLibCommon<TouchLibCSTMutual>, public TouchLibInterface
{
friend class TouchLibCommon<TouchLibCSTMutual>;
public:
#if defined(ARDUINO)
TouchLibCSTMutual(TwoWire &w, int sda = SDA, int scl = SCL, uint8_t addr = CTS328_SLAVE_ADDRESS, int rst = -1)
{
__wire = &w;
__sda = sda;
__scl = scl;
__addr = addr;
__rst = rst;
}
#endif
TouchLibCSTMutual()
{
#if defined(ARDUINO)
__wire = &Wire;
__sda = SDA;
__scl = SCL;
__rst = -1;
#endif
__addr = CTS328_SLAVE_ADDRESS;
}
~TouchLibCSTMutual()
{
log_i("~TouchLibCSTMutual");
deinit();
}
bool init() { return begin(); }
void deinit() { end(); }
bool enableSleep() { return this->writeRegister((uint8_t)(CHIP_DEEP_SLEEP_REG >> 8), (uint8_t)(CHIP_DEEP_SLEEP_REG & 0xFF)); }
bool read()
{
this->readRegister(MODE_NORMAL_0_REG, raw_data, sizeof(raw_data));
this->writeRegister(MODE_NORMAL_0_REG, (uint8_t)0xAB); // sync signal
// return raw_data[MODE_NORMAL_6_REG & 0xFF] == 0XAB ? 1 : 0;
return ((raw_data[MODE_NORMAL_5_REG & 0xff] & 0x0f) != 0 ? 1 : 0);
}
uint8_t getPointNum() { return raw_data[MODE_NORMAL_5_REG & 0xff] & 0x0f; }
TP_Point getPoint(uint8_t n)
{
TP_Point t;
switch (n)
{
case 0:
t.state = raw_data[MODE_NORMAL_0_REG & 0xFF] & 0xF;
t.x = COMBINE_H8L4_H(MODE_NORMAL_1_REG, MODE_NORMAL_3_REG);
t.y = COMBINE_H8L4_L(MODE_NORMAL_2_REG, MODE_NORMAL_3_REG);
t.pressure = raw_data[MODE_NORMAL_4_REG & 0xF];
break;
case 1:
t.state = raw_data[MODE_NORMAL_7_REG & 0xFF] & 0xF;
t.x = COMBINE_H8L4_H(MODE_NORMAL_8_REG, MODE_NORMAL_10_REG);
t.y = COMBINE_H8L4_L(MODE_NORMAL_9_REG, MODE_NORMAL_10_REG);
t.pressure = raw_data[MODE_NORMAL_11_REG & 0xF];
break;
case 2:
t.state = raw_data[MODE_NORMAL_12_REG & 0xFF] & 0xF;
t.x = COMBINE_H8L4_H(MODE_NORMAL_13_REG, MODE_NORMAL_15_REG);
t.y = COMBINE_H8L4_L(MODE_NORMAL_14_REG, MODE_NORMAL_15_REG);
t.pressure = raw_data[MODE_NORMAL_16_REG & 0xF];
break;
case 3:
t.state = raw_data[MODE_NORMAL_17_REG & 0xFF] & 0xF;
t.x = COMBINE_H8L4_H(MODE_NORMAL_18_REG, MODE_NORMAL_20_REG);
t.y = COMBINE_H8L4_L(MODE_NORMAL_19_REG, MODE_NORMAL_20_REG);
t.pressure = raw_data[MODE_NORMAL_21_REG & 0xF];
break;
case 4:
t.state = raw_data[MODE_NORMAL_22_REG & 0xFF] & 0xF;
t.x = COMBINE_H8L4_H(MODE_NORMAL_23_REG, MODE_NORMAL_25_REG);
t.y = COMBINE_H8L4_L(MODE_NORMAL_24_REG, MODE_NORMAL_25_REG);
t.pressure = raw_data[MODE_NORMAL_26_REG & 0xF];
break;
default:
log_i("The parameter range of getPoint is between 0 and 4.");
break;
}
t.id = n;
if (rotation == 0)
{
}
else if (rotation == 1)
{
uint16_t tmp = t.x;
t.x = t.y;
t.y = tmp;
}
return t;
}
void setRotation(uint8_t r) { rotation = r % 4; }
uint8_t getRotation() { return rotation; }
protected:
bool initImpl() { return true; }
uint8_t raw_data[27] = {0};
uint8_t rotation = 0;
};

View File

@@ -0,0 +1,130 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 micky
*
* 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 ModulesCSTSelf.tpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#include "REG/CSTSelfConstants.h"
#include "TouchLibCommon.tpp"
#include "TouchLibInterface.hpp"
class TouchLibCSTSelf : public TouchLibCommon<TouchLibCSTSelf>, public TouchLibInterface, public TouchLibGesture {
friend class TouchLibCommon<TouchLibCSTSelf>;
public:
#if defined(ARDUINO)
TouchLibCSTSelf(TwoWire &w, int sda = SDA, int scl = SCL, uint8_t addr = CTS826_SLAVE_ADDRESS, int rst = -1) {
__wire = &w;
__sda = sda;
__scl = scl;
__addr = addr;
__rst = rst;
}
#endif
TouchLibCSTSelf() {
#if defined(ARDUINO)
__wire = &Wire;
__sda = SDA;
__scl = SCL;
__rst = -1;
#endif
__addr = CTS826_SLAVE_ADDRESS;
}
~TouchLibCSTSelf() {
log_i("~TouchLibCSTSelf");
deinit();
}
bool init() { return begin(); }
void deinit() { end(); }
bool enableSleep() { return this->writeRegister(SLEEP_REG, (uint8_t)(0x03)); }
bool read() {
this->readRegister(WORK_MODE_REG, raw_data, sizeof(raw_data));
return raw_data[TOUCH_NUM_REG] > 0;
}
uint8_t getPointNum() { return raw_data[TOUCH_NUM_REG] & 0x0f; }
TP_Point getPoint(uint8_t n) {
TP_Point t;
switch (n) {
case 0:
t.state = raw_data[TOUCH1_XH_REG] >> 6;
t.x = COMBINE_H4L8(TOUCH1_XH_REG, TOUCH1_XL_REG);
t.y = COMBINE_H4L8(TOUCH1_YH_REG, TOUCH1_YL_REG);
break;
case 1:
t.state = raw_data[TOUCH2_XH_REG] >> 6;
t.x = COMBINE_H4L8(TOUCH2_XH_REG, TOUCH2_XL_REG);
t.y = COMBINE_H4L8(TOUCH2_YH_REG, TOUCH2_YL_REG);
break;
default:
log_i("The parameter range of getPoint is between 0 and 1.");
break;
}
t.id = n;
if (rotation == 0) {
} else if (rotation == 1) {
uint16_t tmp = t.x;
t.x = t.y;
t.y = tmp;
}
return t;
}
void setRotation(uint8_t r) { rotation = r % 4; }
uint8_t getRotation() { return rotation; }
bool isEnableGesture() { return this->readRegister(GES_STATE_REG); }
bool enableGesture() {
uint8_t t = 0x01;
return this->writeRegister(GES_STATE_REG, t);
}
bool disableGesture() {
uint8_t t = 0x00;
return this->writeRegister(GES_STATE_REG, t);
}
uint8_t getGesture(void) { return this->readRegister(GESTURE_ID_REG); }
protected:
bool initImpl() { return true; }
uint8_t raw_data[13] = {0};
uint8_t rotation = 0;
};

View File

@@ -0,0 +1,134 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 micky
*
* 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 ModulesGT911.tpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#include "REG/GT911Constants.h"
#include "TouchLibCommon.tpp"
#include "TouchLibInterface.hpp"
class TouchLibGT911 : public TouchLibCommon<TouchLibGT911>, public TouchLibInterface {
friend class TouchLibCommon<TouchLibGT911>;
public:
#if defined(ARDUINO)
TouchLibGT911(TwoWire &w, int sda = SDA, int scl = SCL, uint8_t addr = GT911_SLAVE_ADDRESS2, int rst = -1) {
__wire = &w;
__sda = sda;
__scl = scl;
__addr = addr;
__rst = rst;
}
#endif
TouchLibGT911() {
#if defined(ARDUINO)
__wire = &Wire;
__sda = SDA;
__scl = SCL;
__rst = -1;
#endif
__addr = GT911_SLAVE_ADDRESS2;
}
~TouchLibGT911() {
log_i("~TouchLibGT911");
deinit();
}
bool init() {
begin();
if (__rst == -1) {
// this->writeRegister(GT911_COMMAND, (uint8_t)0x05);
// delay(200);
this->writeRegister(GT911_COMMAND, (uint8_t)0x02); // software reset
delay(200);
// this->writeRegister(GT911_COMMAND, (uint8_t)0x00);
// uint8_t buf;
// buf = this->readRegister(GT911_MODULE_SWITCH_1);
// buf = buf & 0xfc;
// buf = buf | 0x01;
// this->writeRegister(GT911_MODULE_SWITCH_1, buf);
// buf = this->readRegister(GT911_MODULE_SWITCH_1);
// Serial.printf("2buf :0x%02X \r\n", buf);
return 0;
} else
return 1;
}
void deinit() { end(); }
bool enableSleep() { return 0; /* this->writeRegister(GT911_COMMAND, (uint8_t)0x05); */ }
bool read() {
this->readRegister(GT911_POINT_INFO, raw_data, sizeof(raw_data));
this->writeRegister(GT911_POINT_INFO, (uint8_t)0x00); // sync signal
return (raw_data[0] & 0xF) != 0 ? true : false;
}
uint8_t getPointNum() { return raw_data[0] & 0xF; }
TP_Point getPoint(uint8_t n) {
if (n > 4) {
log_i("The parameter range of getPoint is between 0 and 4.");
return TP_Point(0, 0, 0, 0, 0, 0);
}
TP_Point t;
uint16_t point_reg[5] = GT911_POINTS_REG;
uint16_t offset = point_reg[n] - GT911_POINT_INFO;
t.id = raw_data[offset];
t.x = raw_data[offset + 1] + (raw_data[offset + 2] << 8);
t.y = raw_data[offset + 3] + (raw_data[offset + 4] << 8);
t.size = raw_data[offset + 5] | (raw_data[offset + 6] << 8);
if (rotation == 0) {
} else if (rotation == 1) {
uint16_t tmp = t.x;
t.x = t.y;
t.y = tmp;
}
return t;
}
void setRotation(uint8_t r) { rotation = r % 4; }
uint8_t getRotation() { return rotation; }
protected:
bool initImpl() { return true; }
uint8_t raw_data[40] = {0};
uint8_t rotation = 0;
};

View File

@@ -0,0 +1,222 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 micky
*
* 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 TouchLibZTW622.tpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#include "REG/ZTW622Constants.h"
#include "TouchLibCommon.tpp"
#include "TouchLibInterface.hpp"
class TouchLibZTW622 : public TouchLibCommon<TouchLibZTW622>, public TouchLibInterface {
friend class TouchLibCommon<TouchLibZTW622>;
public:
#if defined(ARDUINO)
TouchLibZTW622(TwoWire &w, int sda = SDA, int scl = SCL, uint8_t addr = ZTW622_SLAVE_ADDRESS, int rst = -1) {
__wire = &w;
__sda = sda;
__scl = scl;
__addr = addr;
__rst = rst;
}
#endif
TouchLibZTW622() {
#if defined(ARDUINO)
__wire = &Wire;
__sda = SDA;
__scl = SCL;
__rst = -1;
#endif
__addr = ZTW622_SLAVE_ADDRESS;
}
~TouchLibZTW622() {
log_i("~TouchLibZTW622");
deinit();
}
bool init() {
int ret = 0;
begin();
ret = this->writeRegister((uint16_t)(0x000C), (uint16_t)(0x0001));
if (ret) {
log_i("power sequence error (vendor cmd enable)");
return false;
}
/* Read the value of the 0xCC00 address, the ID of the chip */
ret = this->readRegister((uint16_t)(0xCC00), (uint8_t *)&chip_code, 2);
if (ret) {
log_i("fail to read chip code");
return false;
}
log_i("chip code = 0x%x\n", chip_code);
ret = this->writeRegister((uint8_t)(0xC0), (uint8_t)(0x04));
if (ret) {
log_i("power sequence error (intn clear)");
return false;
}
ret = this->writeRegister((uint16_t)(0xC002), (uint16_t)(0x0001));
if (ret) {
log_i("power sequence error (nvm init)");
return false;
}
ret = this->writeRegister((uint16_t)(0xC001), (uint16_t)(0x0001));
if (ret) {
log_i("power sequence error (program start)");
return false;
}
delay(150);
ret = this->readRegister(ZINITIX_FIRMWARE_VERSION, (uint8_t *)&firmware_version, 2);
if (ret) {
log_i("fail to read FIRMWARE_VERSION");
return false;
}
/* 0x07 version cannot wake up from sleep */
if (firmware_version != 0x07)
ztw622_has_sleep_function = true;
log_i("touch FW version = %d\r\n", firmware_version);
ret = this->readRegister(ZINITIX_DATA_VERSION_REG, (uint8_t *)&reg_data_version, 2);
if (ret) {
log_i("fail to read reg version");
return false;
}
log_i("touch register version = %d\r\n", reg_data_version);
if (reg_data_version >= 3)
ztw622_has_palm_coverage_detection = true;
ret = this->writeRegister(ZINITIX_INITIAL_TOUCH_MODE, (uint16_t)(0x0001));
if (ret) {
log_i("fail to write inital touch mode");
return false;
}
ret = this->writeRegister(ZINITIX_TOUCH_MODE, (uint16_t)(0x0001));
if (ret) {
log_i("fail to write touh mode");
return false;
}
ret = this->writeRegister(ZINITIX_SUPPORTED_FINGER_NUM, (uint16_t)(0x0001));
if (ret) {
log_i("fail to write finger num");
return false;
}
ret = this->writeRegister(ZINITIX_X_RESOLUTION, (uint16_t)(0x0001));
if (ret) {
log_i("fail to write finger num");
return false;
}
ret = this->writeRegister(ZINITIX_Y_RESOLUTION, (uint16_t)(0x0001));
if (ret) {
log_i("fail to write finger num");
return false;
}
ret = this->writeRegister((uint8_t)(0x00), (uint8_t)(0x06));
if (ret) {
log_i("fail to write finger num");
return false;
}
for (int i = 0; i < 10; i++) {
this->writeRegister((uint8_t)(0x00), (uint8_t)(0x03));
delay(10);
}
return 1;
}
void deinit() { end(); }
bool enableSleep() { return 1; }
bool read() {
this->readRegister(ZINITIX_POINT_STATUS_REG, raw_data, sizeof(raw_data));
// for (int i = 0; i < 16; i++) {
// Serial.printf("[%d]0x%02X ", i, raw_data[i]);
// }
// Serial.println();
// this->readRegister(POINT_COUNT_TIMESTAMP_REG, &raw_data[2], 2);
// if ((raw_data[3] << 8 | raw_data[2]) != 0) {
// this->writeRegister((uint8_t)(ZINITIX_CLEAR_INT_CMD >> 8), (uint8_t)(ZINITIX_CLEAR_INT_CMD & 0xFF));
// return 1;
// }
// return 0;
return (raw_data[1] & BIT_POINT_DETECTED);
}
uint8_t getPointNum() { return (raw_data[3] << 8 | raw_data[2]); }
TP_Point getPoint(uint8_t n) {
if (n > 4) {
log_i("The parameter range of getPoint is between 0 and 4.");
return TP_Point(0, 0, 0, 0, 0, 0);
}
TP_Point t;
uint16_t point_reg[5] = ZINITIX_POINTS_REG;
uint16_t offset = point_reg[n] - ZINITIX_POINT_STATUS_REG;
t.id = n;
t.x = raw_data[offset] + (raw_data[offset + 1] << 8);
t.y = raw_data[offset + 2] + (raw_data[offset + 3] << 8);
t.pressure = raw_data[offset + 4];
t.state = raw_data[offset + 5];
if (rotation == 0) {
} else if (rotation == 1) {
uint16_t tmp = t.x;
t.x = t.y;
t.y = tmp;
}
return t;
}
void setRotation(uint8_t r) { rotation = r % 4; }
uint8_t getRotation() { return 1; }
protected:
bool initImpl() { return true; }
uint8_t raw_data[33] = {0};
uint8_t rotation = 0;
bool ztw622_has_sleep_function = false;
bool ztw622_has_palm_coverage_detection = false;
uint16_t chip_code = 0;
uint16_t firmware_version = 0;
uint16_t reg_data_version = 0;
};

View File

@@ -0,0 +1,593 @@
#pragma once
/* COMMAND LIST (READ BYTE:0)*/
// Software Reset
#define SOFT_RESET_CMD_REG ((uint16_t)0x0000)
// Wake Up
#define WAKE_UP_CMD_REG ((uint16_t)0x0001)
// Clearing the pended interrupt
#define CLEAR_INT_CMD_REG ((uint16_t)0x0003)
// Fall into the IDLE state : slow polling
#define GO_IDLE_CMD_REG ((uint16_t)0x0004)
// Fall into the SLEEP state : power saving
#define GO_SLEEP_CMD_REG ((uint16_t)0x0005)
#define CALIBRATE_CMD_REG ((uint16_t)0x0006)
// Save the current status to the flash
#define SAVE_STATUS_CMD_REG ((uint16_t)0x0007)
#define SAVE_CAL_DATA_CMD_REG ((uint16_t)0x0008)
// Recall factory default status from flash
#define FACTORY_DEFAULT_CMD_REG ((uint16_t)0x000F)
/* NORMAL CONFIGURE (READ BYTE:2)*/
// Set/Load the current touch mode
#define TOUCH_MODE_REG ((uint16_t)0x0010)
// Chip Revision
#define CHIP_REVISION_REG ((uint16_t)0x0011)
// Firmware Version
#define FIRMWARE_VERSION_REG ((uint16_t)0x0012)
// Register Data Version. (for driver)
#define REGISTER_DATA_VERSION_REG ((uint16_t)0x0013)
// HW ID
#define HW_ID_REG ((uint16_t)0x0014)
// Supported Max Finger Num is 10.
#define SUPPORTED_FINGER_NUM_REG ((uint16_t)0x0015)
// Max Y Line Number
#define MAX_Y_NUM_REG ((uint16_t)0x0016)
/*
Bit 0 : NOT USE 1ST BASELINE
Bit 1 : NOT USE 2ND BASELINE
Bit 2 : USE MINUS MAX FILTER
Bit 3 : USE ONLY SINGLE COORD
Bit 4 : USE SMALL PLAM CHECK
Bit 5 : USE LARGE PALM CHECK
Bit 6 : USE SINGLE COORD IN MULTI
Bit 7 : USE SMALL NOISE DENSITY CHECK
Bit 8 : USE BSR MP RATIO
Bit 9 : NOT USE MULTI AREA COORD
Bit 10 : USE MULTI AVERAGE COORD
Bit 11 : RESERVED
Bit 12 : USE ADPATIVE POINT FILTER
Bit 13 : USE LOW PALM CHECK
Bit 14 : NOT USE CUTOFF SENSITIVITY
Bit 15 : USE BSR REF BASELINE
*/
#define INTERNAL_FLAG_REG ((uint16_t)0x0017)
/*
EEPROM Info
Bit 0 : CALIBRATION BIT
Bit 1 : CONFIG INFO BIT (CHECK SUM)
Bit 2 : UPGRADE INFO BIT
*/
#define EEPROM_INFO_REG ((uint16_t)0x0018)
// Set/Load the inital touch mode
#define INITIAL_TOUCH_MODE_REG ((uint16_t)0x0019)
// Chip H/W Revision
#define CHIP_HW_REVISION_REG ((uint16_t)0x001A)
// Calibration N Data total number
#define CAL_N_DATA_TOTAL_NUM_REG ((uint16_t)0x001B)
// IC VENDOR ID : “ZI” (ASCII Code: 0x5A49)
#define IC_VENDOR_ID_REG ((uint16_t)0x001C)
// TSM Module ID
#define TSM_MODULE_ID_REG ((uint16_t)0x001E)
#define CURRENT_RAW_VARIATION_REG ((uint16_t)0x001F)
#define DELAY_FOR_HOST_REG ((uint16_t)0x007C)
#define SCAN_COUNT_FOR_HOST_REG ((uint16_t)0x007D)
#define DALAY_RAW_DATA_FOR_HOST_REG ((uint16_t)0x007F)
/*
Bit 0 : USE DELY FOR HOST
Bit 1 : USE AUTO DELAY FOR HOST
Bit 2 : NOT USE CUTOFF WIDTH
Bit 3 : RESERVED
Bit 4 : NOT USE EDGE SCALING
Bit 5 : USE AUTO DETECT NOISE
Bit 6 : REVERSE ANGLE DIRECTION
Bit 7 : USE EDGE ACTIVE UP
Bit 8 : USE INIT VARIATION CHECK
Bit 9 : USE REJECT SENSITIVITY
Bit 10 : USE SCAN NOISE DATA
Bit 11 : COMPENSATION SPREAD DATA
Bit 12 : USE BSR TSP FLATENESS CHECK
Bit 13 : USE ESD CHECK
Bit 14 : DEF AUTO CPU OSC(ZFT)
Bit 15 : FREE SPACE RECOVERY
*/
#define INTERNAL_FLAG_01_REG ((uint16_t)0x011D)
#define INTERNAL_FLAG_02_REG ((uint16_t)0x011E)
#define INTERNAL_FLAG_03_REG ((uint16_t)0x011F)
#define CHIP_CODE_REG ((uint16_t)0x0120)
// Minor firmware version
#define MINOR_FIRMWARE_VERSION_REG ((uint16_t)0x0121)
// 0x55AA
#define CHECKSUM_RESULT_REG ((uint16_t)0x012C)
// Check sum
#define SYSTEM_CHECKSUM_REG ((uint16_t)0x012E)
/* SENSITIVITY CONFIGURE (READ BYTE:2)*/
#define CURRENT_SENSITIVITY_TH_REG ((uint16_t)0x001D)
/*
Sensitivity Threshold : 0 ~ 65535
0 is least sensitive Threshold
65535 is most insensitive Threshold
*/
#define SENSITIVITY_TH_REG ((uint16_t)0x0020)
// Side (Left/Right/Top/Bottom) Sensitivity Th
#define FIRST_Y0_SENSITIVITY_TH_REG ((uint16_t)0x0021)
// Side (Left/Right/Top/Bottom) Sensitivity Th
#define LAST_Y_SENSITIVITY_TH_REG ((uint16_t)0x0022)
// Side (Left/Right/Top/Bottom) Sensitivity Th
#define FIRST_X0_SENSITIVITY_TH_REG ((uint16_t)0x0023)
// Side (Left/Right/Top/Bottom) Sensitivity Th
#define LAST_X_SENSITIVITY_TH_REG ((uint16_t)0x0024)
// Sensitivity Coef.
#define ACTIVE_UP_SENSITIVITY_RATIO_REG ((uint16_t)0x0025)
// Sensitivity Coef.
#define EDGE_ACTIVE_UP_ST_RATIO_REG ((uint16_t)0x0027)
// Sensitivity Coef.
#define HYSTERISYS_ST_RATIO_REG ((uint16_t)0x003D)
/* FILTER CONFIGURE (READ BYTE:2)*/
// Raw Data Filter Depth
#define FIR_COEFFICIENT_REG ((uint16_t)0x0030)
/*
Point Filter (Moving Average Filter) Depth
LSB : 1~32, MSB : 1~32
*/
#define POINT_FIR_COEFFICIENT_REG ((uint16_t)0x0033)
// Width Filter (Moving Filter) Depth : 1~16
#define POINT_WIDTH_FIR_REG ((uint16_t)0x0034)
// Width Coef.
#define WIDTH_AREA_COEF_REG ((uint16_t)0x0035).
// Point Filter Coef
#define POINT_FIR_DISTANCE_REG ((uint16_t)0x0037)
// Angle Filter Depth : 1~16
#define POINT_ANGLE_FIR_REG ((uint16_t)0x0038)
#define SW_ADAPTIVE_LIMIT_LENGTH_REG ((uint16_t)0x00CE)
#define SW_ADAPTIVE_TIMEOUT_REG ((uint16_t)0x00CF)
/* NORMAL NOISE (READ BYTE:2)*/
/*
Ignoring the initial point data : 1 ~ 16
1 : ignoring several initial point data
4 : ignoring many initial point data
*/
#define REACTION_COUNT_REG ((uint16_t)0x003B)
// Small finger reference value
#define SMALL_FINGER_REF_VAL_REG ((uint16_t)0x0042)
// Noise reject Coef
#define CUTOFF_NOISE_IDATA_RATIO_REG ((uint16_t)0x0043)
// Noise reject Coef
#define CUTOFF_NOISE_WIDTH_RATIO_REG ((uint16_t)0x0044)
#define MINUSF_M_COMPS_RATIO_REG ((uint16_t)0x0051)
// Max Node Length for Small Finger
#define SMALL_FINGER_MAX_NODE_LEN_REG ((uint16_t)0x005A)
// Min Node Length for Large Finger
#define LARGE_FINGER_MIN_NODE_LEN_REG ((uint16_t)0x005B)
// Max Node Length for Large Finger
#define LARGE_FINGER_MAX_NODE_LEN_REG ((uint16_t)0x0075)
#define SPREAD_COMP_RATIO_REG ((uint16_t)0x00F2)
/* BSR NOISE (READ BYTE:2)*/
// Duration for BSR Filter
#define BSR_DURATION_REG ((uint16_t)0x00D8)
// Variation Threshold for BSR Filter
#define BSR_VARIATION_TH_REG ((uint16_t)0x00D9)
// MP Reject Reference Value
#define MP_RATIO_REF_VAL_REG ((uint16_t)0x00E2)
// MP Reject Coef
#define MP_RATIO_SMALL_REG ((uint16_t)0x00E3)
// MP Reject Coef
#define MP_RATIO_LARGE_REG ((uint16_t)0x010A)
// Variation Threshold for Flatness
#define FLATNESS_VARIATION_TH_REG ((uint16_t)0x00DD)
#define FLATNESS_LIMIT_THRESHOLD_REG ((uint16_t)0x00DE)
// Reference Value for Flatness
#define FLATNESS_REF_VAL_REG ((uint16_t)0x00DF)
#define FLATNESS_CURRENT_VALUE_REG ((uint16_t)0x00E0)
// Reference value for baseline update
#define REF_BASELINE_LIMIT_TH_REG ((uint16_t)0x00E1)
/* SMALL NOISE (READ BYTE:2)*/
// Duration for Small Reject Baseline Update
#define SMALL_REJECT_BASELINE_PERIOD_REG ((uint16_t)0x0049)
// Small noise density Coef
#define NOISE_REJECT_DENSITY_RATIO_REG ((uint16_t)0x004A)
// Small noise Coef
#define NOISE_REJECT_SMALL_NOISE_REF_VAL_REG ((uint16_t)0x004B)
// Small noise density Coef
#define NOISE_REJECT_DENSITY_LIMIT_REG ((uint16_t)0x004C)
// Small noise density Coef
#define NOISE_REJECT_DENSITY_MIN_LEN_REG ((uint16_t)0x004D)
/* LOW PALM (READ BYTE:2)*/
// Low Palm sensitivity Th
#define LOW_PALM_SENSITIVITY_TH_REG ((uint16_t)0x0026)
// Max X Line for Low Palm
#define LOW_PALM_MAX_X_REG ((uint16_t)0x0031)
// Max Y Line for Low Palm
#define LOW_PALM_MAX_Y_REG ((uint16_t)0x0032)
// Max Area size for Low Palm
#define LOW_PALM_MAX_AREA_REG ((uint16_t)0x0036)
// Sensitivity Coef
#define LOW_PALM_ST_MAGNIFICATION_REG ((uint16_t)0x0047)
/* SMALL PALM (READ BYTE:2)*/
// Area size for Small Palm
#define SMALL_PALM_AREA_THRESHOLD_REG ((uint16_t)0x003C)
// Sensitivity Coef
#define SMALL_PALM_ST_MAGNIFICATION_REG ((uint16_t)0x0045)
// Duration for Small Palm Baseline Update
#define SMALL_PALM_BS_UPDATE_PERIOD_REG ((uint16_t)0x004F)
/* LARGE PALM (READ BYTE:2)*/
#define LARGE_PALM_REJECT_N_COUNT_REG ((uint16_t)0x003E)
#define LARGE_PALM_REJECT_AREA_TH_REG ((uint16_t)0x003F)
#define LARGE_PALM_REPORT_AREA_TH_REG ((uint16_t)0x0040)
#define LARGE_PALM_UP_SKIP_CNT_REG ((uint16_t)0x0041)
#define LARGE_PALM_ST_MAGNIFICATION_REG ((uint16_t)0x0046)
#define LARGE_PALM_TIME_REG ((uint16_t)0x0048)
#define LARGE_PALM_BS_UPDATE_PERIOD_REG ((uint16_t)0x004E)
/* AUTO NOISE LEVEL (READ BYTE:2)*/
// Raw Data variation
#define REAL_RAW_VARIATION_REG ((uint16_t)0x001F)
// Raw Data Max
#define REAL_RAW_MAX_REG ((uint16_t)0x0073)
// Raw Data Min
#define REAL_RAW_MIN_REG ((uint16_t)0x0074)
// Current Level Depth
#define CUR_LEVEL_DEPTH_REG ((uint16_t)0x0101)
// Current Level Down Count
#define CUR_LEVEL_DOWN_CNT_REG ((uint16_t)0x0102)
// Current ADC Variation
#define CUR_ADC_VARIATION_REG ((uint16_t)0x0103)
// Current PP Noise Variation
#define CUR_PP_NOISE_VARIATION_REG ((uint16_t)0x0104)
// Current PP Noise Max
#define CUR_PP_NOISE_MAX_REG ((uint16_t)0x0105)
// Current PP Noise Min
#define CUR_PP_NOISE_MIN_REG ((uint16_t)0x0106)
// Current Skip Step
#define CUR_SKIP_STEP_REG ((uint16_t)0x0107)
// Count for Level Down
#define DETECT_LEVEL_DOWN_CNT_REG ((uint16_t)0x0108)
#define ADC_VARIATION_TIMEOUT_REG ((uint16_t)0x0109)
// ADC variation threshold for LEVEL 0
#define LEVEL_0_ADC_VARIATION_TH_REG ((uint16_t)0x010A)
// PP variation threshold for LEVEL 1
#define LEVEL_1_PP_VARIATION_TH_REG ((uint16_t)0x010B)
// PP max threshold for LEVEL 1
#define LEVEL_1_PP_MAX_TH_REG ((uint16_t)0x010C)
// PP min threshold for LEVEL 1
#define LEVEL_1_PP_MIN_TH_REG ((uint16_t)0x010D)
// ADC variation threshold for LEVEL 1
#define LEVEL_1_ADC_VARIATION_TH_REG ((uint16_t)0x010E)
#define LEVEL_1_SENSITIVITY_INC_REG ((uint16_t)0x010F)
#define LEVEL_1_REACTION_CNT_INC_REG ((uint16_t)0x0110)
// Raw data filter for LEVEL 1
#define LEVEL_1_FIR_REG ((uint16_t)0x0111)
// Point Filter Coef for LEVEL 1
#define LEVEL_1_SW_FIR_REG ((uint16_t)0x0112)
// Point Filter Coef for LEVEL 1
#define LEVEL_1_SW_FIR_DIST_REG ((uint16_t)0x0113)
// Noise Reject Coef for LEVEL 1
#define LEVEL_1_CUTOFF_IDATA_REG ((uint16_t)0x0115)
/* ESD NOISE (READ BYTE:2)*/
// ESD Noise Variation Threshold
#define ESD_NOISE_VARIATION_TH_REG ((uint16_t)0x00E3)
// ESD Noise Count
#define ESD_NOISE_VARIATION_CNT_TH_REG ((uint16_t)0x00E4)
#define ESD_NOISE_MP_RATIO_REG ((uint16_t)0x00E5)
// ESD Noise Threshold
#define ESD_NOISE_THRESHOLD_REG ((uint16_t)0x00E6)
// ESD Noise Min
#define ESD_NOISE_MIN_CRT_REG ((uint16_t)0x00E7)
// ESD Noise Max
#define ESD_NOISE_MAX_CRT_REG ((uint16_t)0x00E8)
// ESD Noise Variation Count
#define ESD_NOISE_CUR_VARITON_CNT_REG ((uint16_t)0x00E9)
/* SCAN AREA CONFIGURE (READ BYTE:2)*/
#define CHECK_AREA_REF_VAL_RATIO_REG ((uint16_t)0x0050)
// X Size for Multi Check
#define SKIP_MULTI_CHK_MAX_X_REG ((uint16_t)0x0052)
// Y Size for Multi Check
#define SKIP_MULTI_CHK_MAX_Y_REG ((uint16_t)0x0053)
// Max Area Count for Multi check
#define SKIP_MULTI_CHK_MAX_AREA_REG ((uint16_t)0x0054)
// Min value for Multi Check
#define SKIP_MULTI_CHK_MIN_VAL_REG ((uint16_t)0x0055)
// Adhesion Coef
#define ADHESION_RATIO_REG ((uint16_t)0x0056)
// Min Area Count for Multi Check
#define SKIP_MULTI_CHK_MIN_AREA_REG ((uint16_t)0x0057)
// Noise reject Coef for Multi Check
#define MULTI_CUTOFF_RATIO_REG ((uint16_t)0x0058)
// Adhesion Reference value Coef for Multi Check
#define ADHESION_REF_VAL_RATIO_REG ((uint16_t)0x0059)
#define CAL_G_COORD_X_LEN_REG ((uint16_t)0x005C)
#define CAL_G_COORD_Y_LEN_REG ((uint16_t)0x005D)
#define ONE_RECT_COEF_REG ((uint16_t)0x005E)
// Area Count Reference Value Coef
#define AREA_COUNT_REF_VAL_RATIO_REG ((uint16_t)0x005F)
// Adhesion Coef for Multi Check
#define MULTI_ADHESION_RATIO_REG ((uint16_t)0x00C5)
// Free Space Coef for Multi Check
#define FREE_SPACE_RECOVERY_RATIO_REG ((uint16_t)0x00D2)
/* BASELINE CONFIGURE (READ BYTE:2)*/
// Variation for 1st Baseline Update
#define _1ST_BASELINE_VARIATION_REG ((uint16_t)0x0028)
// Variation for 2nd Baseline Update
#define _2ND_BASELINE_VARIATION_REG ((uint16_t)0x0029)
// Duration for 1st Baseline Update
#define _1ST_BASELINE_PERIOD_REG ((uint16_t)0x002A)
// Duration for 2nd Baseline Update
#define _2ND_BASELINE_PERIOD_REG ((uint16_t)0x002B)
// Duration for Baseline Update in detecting finger.
#define BASELINE_FORCE_PERIOD_REG ((uint16_t)0x002C)
// Step For 2nd Baseline Update
#define _2ND_BASELINE_STEP_REG ((uint16_t)0x002D)
// Initial Count for Soft calibration
#define SOFT_CALIBRATION_INIT_COUNT_REG ((uint16_t)0x0078)
/* CALIBRATION CONFIGURE (READ BYTE:2)*/
// Reference Value for H/W Calibration
#define CALIBRATION_REFERENCE_REG ((uint16_t)0x0076)
// Scan Count for H/W Calibration
#define CALIBRATION_SCAN_COUNT_REG ((uint16_t)0x0077)
// Afe N Count for H/W Calibration
#define CALIBRATION_DEFAULT_N_COUNT_REG ((uint16_t)0x0078)
// Default Cap Value for H/W Calibration
#define CALIBRATION_DEFAULT_C_REG ((uint16_t)0x0079)
// Calibration Mode
#define CALIBRATION_MODE_REG ((uint16_t)0x007A)
/* BUTTON CONFIGURE (READ BYTE:2)*/
// Supported Button Number
#define SUPPORTED_BUTTON_NUM_REG ((uint16_t)0x00B0)
// Ignoring the initial button data : 1 ~ 16
#define BUTTON_REACTION_CNT_REG ((uint16_t)0x00B1)
// Button Sensitivity Threshold
#define BUTTON_SENSITIVITY_TH_REG ((uint16_t)0x00B2)
// 0 = X LINE, 1 = Y LINE
#define BUTTON_LINE_TYPE_REG ((uint16_t)0x00B3)
// First or last X or Y Line Num (ex) 0 or 15
#define BUTTON_LINE_NUM_REG ((uint16_t)0x00B4)
/*
Button Node Count
ex) If BUTTON LINE TYPE = 0, BUTTON LINE NUM =
15, BUTTON_0 START NODE = 3 and this regs
value 3, BUTTON 0 AREA is X = 15, Y= 3~5.
*/
#define BUTTON_RANGE_REG ((uint16_t)0x00B5)
// BUTTON_0 Start Node Num
#define BUTTON_0_START_NODE_REG ((uint16_t)0x00B6)
#define BUTTON_1_START_NODE_REG ((uint16_t)0x00B7)
#define BUTTON_2_START_NODE_REG ((uint16_t)0x00B8)
#define BUTTON_3_START_NODE_REG ((uint16_t)0x00B9)
#define BUTTON_4_START_NODE_REG ((uint16_t)0x00BA)
#define BUTTON_5_START_NODE_REG ((uint16_t)0x00BB)
#define BUTTON_6_START_NODE_REG ((uint16_t)0x00BC)
#define BUTTON_7_START_NODE_REG ((uint16_t)0x00BD)
#define BUTTON_WIDTH_MUL_RATIO_REG ((uint16_t)0x00BE)
#define BUTTON_PRIORITY_RATIO_REG ((uint16_t)0x00BF)
/* X/Y CHANNEL CONFIGURE (READ BYTE:2)*/
// X Channel number
#define TOTAL_NUM_OF_X_REG ((uint16_t)0x0060)
// Y Channel number
#define TOTAL_NUM_OF_Y_REG ((uint16_t)0x0061)
// X Pin mapping num with ITO
#define X00_01_DRIVE_NUM_REG ((uint16_t)0x0062)
#define X02_03_DRIVE_NUM_REG ((uint16_t)0x0063)
#define X04_05_DRIVE_NUM_REG ((uint16_t)0x0064)
#define X06_07_DRIVE_NUM_REG ((uint16_t)0x0065)
#define X08_09_DRIVE_NUM_REG ((uint16_t)0x0066)
#define X10_11_DRIVE_NUM_REG ((uint16_t)0x0067)
#define X12_13_DRIVE_NUM_REG ((uint16_t)0x0068)
#define X14_15_DRIVE_NUM_REG ((uint16_t)0x0069)
#define X16_17_DRIVE_NUM_REG ((uint16_t)0x006A)
#define X18_19_DRIVE_NUM_REG ((uint16_t)0x006B)
#define X20_21_DRIVE_NUM_REG ((uint16_t)0x006C)
#define X22_23_DRIVE_NUM_REG ((uint16_t)0x006D)
#define X24_25_DRIVE_NUM_REG ((uint16_t)0x006E)
#define X26_27_DRIVE_NUM_REG ((uint16_t)0x006F)
#define X28_29_DRIVE_NUM_REG ((uint16_t)0x0070)
#define X30_31_DRIVE_NUM_REG ((uint16_t)0x0071)
#define Y00_01_INPUT_NUM_REG ((uint16_t)0x00F3)
#define Y02_03_INPUT_NUM_REG ((uint16_t)0x00F4)
#define Y04_05_INPUT_NUM_REG ((uint16_t)0x00F5)
#define Y06_07_INPUT_NUM_REG ((uint16_t)0x00F6)
#define Y08_09_INPUT_NUM_REG ((uint16_t)0x00F7)
#define Y10_11_INPUT_NUM_REG ((uint16_t)0x00F8)
#define Y12_13_INPUT_NUM_REG ((uint16_t)0x00F9)
#define Y14_15_INPUT_NUM_REG ((uint16_t)0x00FA)
#define Y16_17_INPUT_NUM_REG ((uint16_t)0x00FB)
/* AFE FREQ CONFIGURE (READ BYTE:2)*/
// AFE Frequency
#define AFE_FREQUENCY_REG ((uint16_t)0x0100)
/* AFE OPERATION COEF (READ BYTE:2)*/
// Default N Count
#define AFE_DEFAULT_N_COUNT_REG ((uint16_t)0x0122)
#define AFE_DEFAULT_C_REG ((uint16_t)0x0123)
/*
OSC Frequency
[ZMT200]
0(default) : 14MHz
1 : 18MHz
[ZFT400]
0(default) : 16.6MHz
21 : 33.3MHz
11 : 40MHz
*/
#define CPU_OSD_FREQUENCY_REG ((uint16_t)0x0125)
#define AFE_R_SHIFT_VALUE_REG ((uint16_t)0x012B)
/* COORD. CONFIGURE (READ BYTE:2)*/
// X Resolution
#define RESOLUTION_OF_X_REG ((uint16_t)0x00C0)
// Y Resolution
#define RESOLUTION_OF_Y_REG ((uint16_t)0x00C1)
/*
BIT 0 : X FLIP (1)
BIT 1 : Y FLIP (1)
BIT 2 : XY SWAP (1)
*/
#define COORD_ORIENTATION_REG ((uint16_t)0x00C2)
/*
Holding the point movement : 1 ~ 256
001 : point movement recognition is fast
128 : point movement recognition is slow
*/
#define HOLD_POINT_TRESHHOLD_REG ((uint16_t)0x00C3)
// Holding the width change : 1 ~ 256
#define HOLD_WIDTH_TRESHHOLD_REG ((uint16_t)0x00C4)
#define ASSUME_UP_THRESHHOLD_REG ((uint16_t)0x00C6)
#define ASSUME_UP_SKIP_THRESHHOLD_REG ((uint16_t)0x00C7)
// Shift X Coord for Accuracy Coef.
#define X_POINT_SHIFT_REG ((uint16_t)0x00C8)
// Shift Y Coord for Accuracy Coef.
#define Y_POINT_SHIFT_REG ((uint16_t)0x00C9)
// View Area First X Line Offset
#define VIEW_AREA_XF_OFFSET_REG ((uint16_t)0x00CA)
// View Area Last X Line Offset
#define VIEW_AREA_XL_OFFSET_REG ((uint16_t)0x00CB)
// View Area First Y Line Offset
#define VIEW_AREA_YF_OFFSET_REG ((uint16_t)0x00CC)
// View Area Last Y Line Offset
#define VIEW_AREA_YL_OFFSET_REG ((uint16_t)0x00CD)
// Coef. for calculation coord
#define COEF_X_GAIN_REG ((uint16_t)0x00D0)
// Coef. for calculation coord
#define COEF_Y_GAIN_REG ((uint16_t)0x00D1)
#define ACTIVE_UP_THRESHHOLD_REG ((uint16_t)0x00D3)
// Process Data Coef.
#define PDATA_COEF1_REG ((uint16_t)0x00D5)
// Process Data Coef.
#define PDATA_COEF2_REG ((uint16_t)0x00D6)
// Process Data Coef.
#define PDATA_COEF3_REG ((uint16_t)0x00D7)
// Edge Area Scale
#define VIEW_EDGE_SCALE_VAL_REG ((uint16_t)0x00EB)
// Edge Area First X Line Offset
#define VIEW_EDGE_XF_OFFSET_REG ((uint16_t)0x00EC)
// Edge Area Last X Line Offset
#define VIEW_EDGE_XL_OFFSET_REG ((uint16_t)0x00ED)
// Edge Area First Y Line Offset
#define VIEW_EDGE_YF_OFFSET_REG ((uint16_t)0x00EE)
// Edge Area Last Y Line Offset
#define VIEW_EDGE_YL_OFFSET_REG ((uint16_t)0x00EF)
/* INTERRUPT CONFIGURE (READ BYTE:2)*/
/*
BIT 00 : POINT COUNT CHANGE EVENT
BIT 01 : DOWN EVENT
BIT 02 : MOVE EVENT
BIT 03 : UP EVENT
BIT 04 : LARGE PALM REPORT
BIT 05 : LARGE PALM REJECT
BIT 06 : RESERVED
BIT 07 : RESERVED
BIT 08 : WIDTH CHANGED EVENT
BIT 09 : REJECT EVENT
BIT 10 : RESERVED
BIT 11 : POINT DETECTED EVENT
BIT 12 : RESERVED
BIT 13 : RESERVED
BIT 14 : DEBUG EVENT
BIT 15 : BUTTON EVENT
*/
#define INT_ENABLE_FLAG_REG ((uint16_t)0x00F0)
/*
0 : No Use
1~30000 : Occurred invalid Interrupt periodically
per setting Afe Cycle.
Invalid interrupt :
Status register = 0x00
Point Count = 100;
*/
#define ESD_INTERRUPT_INTERVAL_REG ((uint16_t)0x00F1)
/* POINT INFO (READ BYTE:2)*/
/*
BIT 00 : POINT COUNT CHANGE EVENT
BIT 01 : DOWN EVENT
BIT 02 : MOVE EVENT
BIT 03 : UP EVENT
BIT 04 : LARGE PALM REPORT
BIT 05 : LARGE PALM REJECT
BIT 06 : RESERVED
BIT 07 : RESERVED
BIT 08 : WIDTH CHANGED EVENT
BIT 09 : REJECT EVENT
BIT 10 : RESERVED
BIT 11 : POINT DETECTED EVENT
BIT 12 : RESERVED
BIT 13 : RESERVED
BIT 14 : DEBUG EVENT
BIT 15 : BUTTON EVENT
*/
#define STATUS_REGISTER_REG ((uint16_t)0x0080)
/*
LSB : Point Count, MSB : Time Stamp
if TOUCH MODE = 1, using event flag.
BIT 00 : Finger Idx00 Event
BIT 01 : Finger Idx01 Event
BIT 02 : Finger Idx01 Event
*/
#define POINT_COUNT_TIMESTAMP_REG ((uint16_t)0x0081)
/*
[TOUCH MODE 0] Report All Points Info.
1st Point X position(2BYTE) + 1st Point Y position(2BYTE) + 1st Major Width(1Byte) + 1st Sub Status(1Byte)
2nd Point X position(2BYTE) + 2nd Point Y position(2BYTE) + 2nd Major Width(1Byte) + 2nd Sub Status(1Bytes) ...
< SUB STATUS INFO>
BIT 00 : Point Exist (0 : no, 1 : yes)
BIT 01 : Down
BIT 02 : Move
BIT 03 : Up
BIT 04 : Update
BIT 05 : Wait
BIT 06 : Reaction CNT Full
BIT 07 : Width change
[TOUCH MODE 2] Report All Points Info.
1st Point X position(2BYTE) + 1st Point Y position(2BYTE) + 1st Major Width(1Byte) + 1st Sub Status(1Byte)
+ 1st Minor Width(1Byte) + 1st Angle(1Byte) + 2nd Point X position(2BYTE) + 2nd Point Y position(2BYTE)
+ 2nd Major Width(1Byte) + 2nd Sub Status(1Bytes) + 2nd Minor Width(1Byte) + 2nd Angle(1Byte)….
*/
#define REPORT_ALL_POINTS_INFO_REG ((uint16_t)0x0082)
/* BUTTON EVENT & OTHER EVENT INFO (READ BYTE:2)*/
/*
BIT 00 : BUTTON 0 DOWN
BIT 01 : BUTTON 1 DOWN
BIT 02 : BUTTON 2 DOWN
BIT 03 : BUTTON 3 DOWN
BIT 04 : BUTTON 4 DOWN
BIT 05 : BUTTON 5 DOWN
BIT 06 : BUTTON 6 DOWN
BIT 07 : BUTTON 7 DOWN
BIT 08 : BUTTON 0 UP
BIT 09 : BUTTON 1 UP
BIT 10 : BUTTON 2 UP
BIT 11 : BUTTON 3 UP
BIT 12 : BUTTON 4 UP
BIT 13 : BUTTON 5 UP
BIT 14 : BUTTON 6 UP
BIT 15 : BUTTON 7 UP
*/
#define BUTTON_EVENT_REG ((uint16_t)0x00AA)

View File

@@ -0,0 +1,209 @@
#pragma once
#define CTS328_SLAVE_ADDRESS (0x1A)
#define L58_SLAVE_ADDRESS (0X5A)
/* Version Information Register */
/* MODE_DEBUG_INFO */
/*
BYTE 3:KEY_NUM
BYTE 2:TP_NRX
BYTE 1:NC
BYTE 0:TP_NTX
*/
#define CST328_INFO_1_REG (uint16_t((0XD1F4))
/*
BYTE 3 ~ BYTE 2:TP_RESY
BYTE 1 ~ BYTE 0:TP_RESX
*/
#define CST328_INFO_2_REG (uint16_t((0XD1F8))
/*
BYTE 3 ~ BYTE 2:0XCACA
BYTE 1 ~ BYTE 0:BOOT_TIMER
*/
#define CST328_INFO_3_REG (uint16_t((0XD1FC))
/*
BYTE 3 ~ BYTE 2:IC_TYPE
BYTE 1 ~ BYTE 0:PROJECT_ID
*/
#define CST328_INFO_4_REG (uint16_t((0XD204))
/*
BYTE 3:FW_MAJOR
BYTE 2:FW_MINOR
BYTE 1 ~ BYTE 0:FW_BUILD
*/
#define CST328_INFO_5_REG (uint16_t((0XD208))
/*
BYTE 3:CHECKSNM_H
BYTE 2:CHECKSNM_H
BYTE 1:CHECKSNM_L
BYTE 0:CHECKSNM_L
*/
#define CST328_INFO_6_REG (uint16_t((0XD20C))
#define MODE_DEBUG_INFO_REG (uint16_t(0xD101))
#define CHIP_SYSTEM_RESET_REG (uint16_t(0xD102))
#define REDO_CALIBRATION_REG (uint16_t(0xD104))
#define CHIP_DEEP_SLEEP_REG (uint16_t(0xD105))
#define MODE_DEBUG_POINT_REG (uint16_t(0xD108))
#define MODE_NORMAL_REG (uint16_t(0xD109))
#define MODE_DEBUG_RAWDATA_REG (uint16_t(0xD10A))
#define MODE_DEBUG_WRITE_REG (uint16_t(0xD10B))
#define MODE_DEBUG_CALIBRATION_REG (uint16_t(0xD10C))
#define MODE_DEBUG_DIFF_REG (uint16_t(0xD10D))
#define MODE_FACTORY_REG (uint16_t(0xD119))
/* touch information register */
/* MODE_NORMAL */
/*
BIT 7 ~ BIT 4: 1st finger ID
BIT 3 ~ BIT 0: 1st finger state: pressed (0x06) or lifted
*/
#define MODE_NORMAL_0_REG (uint16_t(0xD000))
/*
BIT 7 ~ BIT 0: The X coordinate value of the 1st finger is eight high digits: X_Position>>4
*/
#define MODE_NORMAL_1_REG (uint16_t(0xD001))
/*
BIT 7 ~ BIT 0: The Y coordinate value of the 1st finger is eight high digits: Y_Position>>4
*/
#define MODE_NORMAL_2_REG (uint16_t(0xD002))
/*
BIT 7 ~ BIT 4: The X coordinate value of the 1st finger X_Position&0x0F
BIT 3 ~ BIT 0: The Y coordinate value of the 1st finger Y_Position&0x0F
*/
#define MODE_NORMAL_3_REG (uint16_t(0xD003))
/*
BIT 7 ~ BIT 0: 1st finger pressure value
*/
#define MODE_NORMAL_4_REG (uint16_t(0xD004))
/*
BIT 7 ~ BIT 4: Report button flag (0x80)
BIT 3 ~ BIT 0: Report the number of fingers
*/
#define MODE_NORMAL_5_REG (uint16_t(0xD005))
/*
BIT 7 ~ BIT 0: Fixed 0xAB
*/
#define MODE_NORMAL_6_REG (uint16_t(0xD006))
/*
BIT 7 ~ BIT 4: 2nd finger ID
BIT 3 ~ BIT 0: 2nd finger state: pressed (0x06) or lifted
*/
#define MODE_NORMAL_7_REG (uint16_t(0xD007))
/*
BIT 7 ~ BIT 0: The X coordinate value of the 2nd finger is eight high digits: X_Position>>4
*/
#define MODE_NORMAL_8_REG (uint16_t(0xD008))
/*
BIT 7 ~ BIT 0: The Y coordinate value of the 2nd finger is eight high digits: Y_Position>>4
*/
#define MODE_NORMAL_9_REG (uint16_t(0xD009))
/*
BIT 7 ~ BIT 4: The X coordinate value of the 2nd finger X_Position&0x0F
BIT 3 ~ BIT 0: The Y coordinate value of the 2nd finger Y_Position&0x0F
*/
#define MODE_NORMAL_10_REG (uint16_t(0xD00A))
/*
BIT 7 ~ BIT 0: 2nd finger pressure value
*/
#define MODE_NORMAL_11_REG (uint16_t(0xD00B))
/*
BIT 7 ~ BIT 4: 3rd finger ID
BIT 3 ~ BIT 0: 3rd finger state: pressed (0x06) or lifted
*/
#define MODE_NORMAL_12_REG (uint16_t(0xD00C))
/*
BIT 7 ~ BIT 0: The X coordinate value of the 3rd finger is eight high digits: X_Position>>4
*/
#define MODE_NORMAL_13_REG (uint16_t(0xD00D))
/*
BIT 7 ~ BIT 0: The Y coordinate value of the 3rd finger is eight high digits: Y_Position>>4
*/
#define MODE_NORMAL_14_REG (uint16_t(0xD00E))
/*
BIT 7 ~ BIT 4: The X coordinate value of the 3rd finger X_Position&0x0F
BIT 3 ~ BIT 0: The Y coordinate value of the 3rd finger Y_Position&0x0F
*/
#define MODE_NORMAL_15_REG (uint16_t(0xD00F))
/*
BIT 7 ~ BIT 0: 3rd finger pressure value
*/
#define MODE_NORMAL_16_REG (uint16_t(0xD010))
/*
BIT 7 ~ BIT 4: 4th finger ID
BIT 3 ~ BIT 0: 4th finger state: pressed (0x06) or lifted
*/
#define MODE_NORMAL_17_REG (uint16_t(0xD011))
/*
BIT 7 ~ BIT 0: The X coordinate value of the 4th finger is eight high digits: X_Position>>4
*/
#define MODE_NORMAL_18_REG (uint16_t(0xD012))
/*
BIT 7 ~ BIT 0: The Y coordinate value of the 4th finger is eight high digits: Y_Position>>4
*/
#define MODE_NORMAL_19_REG (uint16_t(0xD013))
/*
BIT 7 ~ BIT 4: The X coordinate value of the 4th finger X_Position&0x0F
BIT 3 ~ BIT 0: The Y coordinate value of the 4th finger Y_Position&0x0F
*/
#define MODE_NORMAL_20_REG (uint16_t(0xD014))
/*
BIT 7 ~ BIT 0: 4th finger pressure value
*/
#define MODE_NORMAL_21_REG (uint16_t(0xD015))
/*
BIT 7 ~ BIT 4: 5th finger ID
BIT 3 ~ BIT 0: 5th finger state: pressed (0x06) or lifted
*/
#define MODE_NORMAL_22_REG (uint16_t(0xD016))
/*
BIT 7 ~ BIT 0: The X coordinate value of the 5th finger is eight high digits: X_Position>>4
*/
#define MODE_NORMAL_23_REG (uint16_t(0xD017))
/*
BIT 7 ~ BIT 0: The Y coordinate value of the 5th finger is eight high digits: Y_Position>>4
*/
#define MODE_NORMAL_24_REG (uint16_t(0xD018))
/*
BIT 7 ~ BIT 4: The X coordinate value of the 5th finger X_Position&0x0F
BIT 3 ~ BIT 0: The Y coordinate value of the 5th finger Y_Position&0x0F
*/
#define MODE_NORMAL_25_REG (uint16_t(0xD019))
/*
BIT 7 ~ BIT 0: 5th finger pressure value
*/
#define MODE_NORMAL_26_REG (uint16_t(0xD01A))

View File

@@ -0,0 +1,123 @@
#pragma once
#define CTS826_SLAVE_ADDRESS (0X15)
#define CTS820_SLAVE_ADDRESS (0X15)
#define CTS816S_SLAVE_ADDRESS (0X15)
/* Working mode switching command */
// Normal reporting and gesture reporting
#define NOMAL_CMD_REG ((uint16_t)0x0000)
// Factory test data acquisition
#define DBG_IDAC_CMD_REG ((uint16_t)0x0004)
// Factory test button and coordinate acquisition
#define DBG_POS_CMD_REG ((uint16_t)0x00E0)
// Get the original value
#define DBG_RAW_CMD_REG ((uint16_t)0x0006)
// get the differ value
#define DBG_SIG_CMD_REG ((uint16_t)0x0007)
/* NOMAL register description */
/*
Write: 00: NOMAL
04: DBG_IDAC
E0: DBG_POS
06: DBG_RAW
07: DBG_SIG
*/
#define WORK_MODE_REG ((uint8_t)0x00)
/*
default00
far awayC0
nearE0
*/
#define PROXIMITY_ID_REG ((uint8_t)0x01)
/*
BIT 7 ~ BIT 4:
BIT 3 ~ BIT 0: touch points[3:0]
*/
#define TOUCH_NUM_REG ((uint8_t)0x02)
/*
BIT 7 ~ BIT 6: event_flg
BIT 5 ~ BIT 4:
BIT 3 ~ BIT 0: X_position[11:8]
*/
#define TOUCH1_XH_REG ((uint8_t)0x03)
/*
BIT 7 ~ BIT 0: X_position[7:0]
*/
#define TOUCH1_XL_REG ((uint8_t)0x04)
/*
BIT 7 ~ BIT 4: touch_ID[3:0]
BIT 3 ~ BIT 0: Y_position[11:8]
*/
#define TOUCH1_YH_REG ((uint8_t)0x05)
/*
BIT 7 ~ BIT 0: Y_position[7:0]
*/
#define TOUCH1_YL_REG ((uint8_t)0x06)
/*
BIT 7 ~ BIT 6: event_flg
BIT 5 ~ BIT 4:
BIT 3 ~ BIT 0: X_position[11:8]
*/
#define TOUCH2_XH_REG ((uint8_t)0x09)
/*
BIT 7 ~ BIT 0: X_position[7:0]
*/
#define TOUCH2_XL_REG ((uint8_t)0x10)
/*
BIT 7 ~ BIT 4: touch_ID[3:0]
BIT 3 ~ BIT 0: Y_position[11:8]
*/
#define TOUCH2_YH_REG ((uint8_t)0x11)
/*
BIT 7 ~ BIT 0: Y_position[7:0]
*/
#define TOUCH2_YL_REG ((uint8_t)0x12)
/*
BIT 7 ~ BIT 0: deepsleep[7:0] write 0X03 into deepsleep
*/
#define SLEEP_REG ((uint8_t)0xA5)
/*
Firmware version number
*/
#define FW_VERSION_0_7_REG ((uint8_t)0xA6)
#define FW_VERSION_8_15_REG ((uint8_t)0xA7)
#define MODULE_ID_REG ((uint8_t)0xA8)
#define PROJECT_NAME_REG ((uint8_t)0xA9)
#define CHIP_TYPE_0_7_REG ((uint8_t)0xAA)
#define CHIP_TYPE_8_15_REG ((uint8_t)0xAB)
#define CHECKSUM_0_7_REG ((uint8_t)0xAC)
#define CHECKSUM_8_15_REG ((uint8_t)0xAD)
/*
write
01H enter Proximity mode
00H exit Proximity mode
*/
#define PROX_STATE_REG ((uint8_t)0xB0)
/*
write
01H Enter gesture recognition mode
00H Exit gesture mode
*/
#define GES_STATE_REG ((uint8_t)0xD0)
/*
Gesture mode is enabled to be effective
double click: 0x24
up: 0x22
down: 0x23
left: 0x20
rignt: 0x21
C: 0x34
e:0x33
m:0x32
O: 0x30
S: 0x46
V: 0x54
W: 0x31
Z:0x65
*/
#define GESTURE_ID_REG ((uint8_t)0xD3)

View File

@@ -0,0 +1,124 @@
#pragma once
#define GT911_SLAVE_ADDRESS1 (0X5D)
#define GT911_SLAVE_ADDRESS2 (0X14)
// Real-time command (Write only)
#define GT911_COMMAND (uint16_t)0x8040
#define GT911_ESD_CHECK (uint16_t)0x8041
#define GT911_COMMAND_CHECK (uint16_t)0x8046
// Configuration information (R/W)
#define GT911_CONFIG_START (uint16_t)0x8047
#define GT911_CONFIG_VERSION (uint16_t)0x8047
#define GT911_X_OUTPUT_MAX_LOW (uint16_t)0x8048
#define GT911_X_OUTPUT_MAX_HIGH (uint16_t)0x8049
#define GT911_Y_OUTPUT_MAX_LOW (uint16_t)0x804A
#define GT911_Y_OUTPUT_MAX_HIGH (uint16_t)0x804B
#define GT911_TOUCH_NUMBER (uint16_t)0x804C
#define GT911_MODULE_SWITCH_1 (uint16_t)0x804D
#define GT911_MODULE_SWITCH_2 (uint16_t)0x804E
#define GT911_SHAKE_COUNT (uint16_t)0x804F
#define GT911_FILTER (uint16_t)0x8050
#define GT911_LARGE_TOUCH (uint16_t)0x8051
#define GT911_NOISE_REDUCTION (uint16_t)0x8052
#define GT911_SCREEN_TOUCH_LEVEL (uint16_t)0x8053
#define GT911_SCREEN_RELEASE_LEVEL (uint16_t)0x8054
#define GT911_LOW_POWER_CONTROL (uint16_t)0x8055
#define GT911_REFRESH_RATE (uint16_t)0x8056
#define GT911_X_THRESHOLD (uint16_t)0x8057
#define GT911_Y_THRESHOLD (uint16_t)0x8058
#define GT911_X_SPEED_LIMIT (uint16_t)0x8059 // Reserve
#define GT911_Y_SPEED_LIMIT (uint16_t)0x805A // Reserve
#define GT911_SPACE_TOP_BOTTOM (uint16_t)0x805B
#define GT911_SPACE_LEFT_RIGHT (uint16_t)0x805C
#define GT911_MINI_FILTER (uint16_t)0x805D
#define GT911_STRETCH_R0 (uint16_t)0x805E
#define GT911_STRETCH_R1 (uint16_t)0x805F
#define GT911_STRETCH_R2 (uint16_t)0x8060
#define GT911_STRETCH_RM (uint16_t)0x8061
#define GT911_DRV_GROUPA_NUM (uint16_t)0x8062
#define GT911_DRV_GROUPB_NUM (uint16_t)0x8063
#define GT911_SENSOR_NUM (uint16_t)0x8064
#define GT911_FREQ_A_FACTOR (uint16_t)0x8065
#define GT911_FREQ_B_FACTOR (uint16_t)0x8066
#define GT911_PANEL_BIT_FREQ_L (uint16_t)0x8067
#define GT911_PANEL_BIT_FREQ_H (uint16_t)0x8068
#define GT911_PANEL_SENSOR_TIME_L (uint16_t)0x8069 // Reserve
#define GT911_PANEL_SENSOR_TIME_H (uint16_t)0x806A
#define GT911_PANEL_TX_GAIN (uint16_t)0x806B
#define GT911_PANEL_RX_GAIN (uint16_t)0x806C
#define GT911_PANEL_DUMP_SHIFT (uint16_t)0x806D
#define GT911_DRV_FRAME_CONTROL (uint16_t)0x806E
#define GT911_CHARGING_LEVEL_UP (uint16_t)0x806F
#define GT911_MODULE_SWITCH3 (uint16_t)0x8070
#define GT911_GESTURE_DIS (uint16_t)0X8071
#define GT911_GESTURE_LONG_PRESS_TIME (uint16_t)0x8072
#define GT911_X_Y_SLOPE_ADJUST (uint16_t)0X8073
#define GT911_GESTURE_CONTROL (uint16_t)0X8074
#define GT911_GESTURE_SWITCH1 (uint16_t)0X8075
#define GT911_GESTURE_SWITCH2 (uint16_t)0X8076
#define GT911_GESTURE_REFRESH_RATE (uint16_t)0x8077
#define GT911_GESTURE_TOUCH_LEVEL (uint16_t)0x8078
#define GT911_NEWGREENWAKEUPLEVEL (uint16_t)0x8079
#define GT911_FREQ_HOPPING_START (uint16_t)0x807A
#define GT911_FREQ_HOPPING_END (uint16_t)0X807B
#define GT911_NOISE_DETECT_TIMES (uint16_t)0x807C
#define GT911_HOPPING_FLAG (uint16_t)0X807D
#define GT911_HOPPING_THRESHOLD (uint16_t)0X807E
#define GT911_NOISE_THRESHOLD (uint16_t)0X807F // Reserve
#define GT911_NOISE_MIN_THRESHOLD (uint16_t)0X8080
#define GT911_HOPPING_SENSOR_GROUP (uint16_t)0X8082
#define GT911_HOPPING_SEG1_NORMALIZE (uint16_t)0X8083
#define GT911_HOPPING_SEG1_FACTOR (uint16_t)0X8084
#define GT911_MAIN_CLOCK_AJDUST (uint16_t)0X8085
#define GT911_HOPPING_SEG2_NORMALIZE (uint16_t)0X8086
#define GT911_HOPPING_SEG2_FACTOR (uint16_t)0X8087
#define GT911_HOPPING_SEG3_NORMALIZE (uint16_t)0X8089
#define GT911_HOPPING_SEG3_FACTOR (uint16_t)0X808A
#define GT911_HOPPING_SEG4_NORMALIZE (uint16_t)0X808C
#define GT911_HOPPING_SEG4_FACTOR (uint16_t)0X808D
#define GT911_HOPPING_SEG5_NORMALIZE (uint16_t)0X808F
#define GT911_HOPPING_SEG5_FACTOR (uint16_t)0X8090
#define GT911_HOPPING_SEG6_NORMALIZE (uint16_t)0X8092
#define GT911_KEY_1 (uint16_t)0X8093
#define GT911_KEY_2 (uint16_t)0X8094
#define GT911_KEY_3 (uint16_t)0X8095
#define GT911_KEY_4 (uint16_t)0X8096
#define GT911_KEY_AREA (uint16_t)0X8097
#define GT911_KEY_TOUCH_LEVEL (uint16_t)0X8098
#define GT911_KEY_LEAVE_LEVEL (uint16_t)0X8099
#define GT911_KEY_SENS_1_2 (uint16_t)0X809A
#define GT911_KEY_SENS_3_4 (uint16_t)0X809B
#define GT911_KEY_RESTRAIN (uint16_t)0X809C
#define GT911_KEY_RESTRAIN_TIME (uint16_t)0X809D
#define GT911_GESTURE_LARGE_TOUCH (uint16_t)0X809E
#define GT911_HOTKNOT_NOISE_MAP (uint16_t)0X80A1
#define GT911_LINK_THRESHOLD (uint16_t)0X80A2
#define GT911_PXY_THRESHOLD (uint16_t)0X80A3
#define GT911_GHOT_DUMP_SHIFT (uint16_t)0X80A4
#define GT911_GHOT_RX_GAIN (uint16_t)0X80A5
#define GT911_FREQ_GAIN0 (uint16_t)0X80A6
#define GT911_FREQ_GAIN1 (uint16_t)0X80A7
#define GT911_FREQ_GAIN2 (uint16_t)0X80A8
#define GT911_FREQ_GAIN3 (uint16_t)0X80A9
#define GT911_COMBINE_DIS (uint16_t)0X80B3
#define GT911_SPLIT_SET (uint16_t)0X80B4
#define GT911_SENSOR_CH0 (uint16_t)0X80B7
#define GT911_DRIVER_CH0 (uint16_t)0X80D5
#define GT911_CONFIG_CHKSUM (uint16_t)0X80FF
#define GT911_CONFIG_FRESH (uint16_t)0X8100
#define GT911_CONFIG_SIZE (uint16_t)0xFF - 0x46
// Coordinate information
#define GT911_PRODUCT_ID (uint16_t)0X8140
#define GT911_FIRMWARE_VERSION (uint16_t)0X8140
#define GT911_RESOLUTION (uint16_t)0X8140
#define GT911_VENDOR_ID (uint16_t)0X8140
#define GT911_IMFORMATION (uint16_t)0X8140
#define GT911_POINT_INFO (uint16_t)0X814E
#define GT911_POINT_1 (uint16_t)0X814F
#define GT911_POINT_2 (uint16_t)0X8157
#define GT911_POINT_3 (uint16_t)0X815F
#define GT911_POINT_4 (uint16_t)0X8167
#define GT911_POINT_5 (uint16_t)0X816F
#define GT911_POINTS_REG {GT911_POINT_1, GT911_POINT_2, GT911_POINT_3, GT911_POINT_4, GT911_POINT_5}

View File

@@ -0,0 +1,92 @@
#pragma once
#define ZTW622_SLAVE_ADDRESS (0x20)
/*2. Register Map一些寄存器的定义用户不需修改直接使用就可以了*/
#define ZINITIX_SWRESET_CMD ((uint16_t)0x0000)
#define ZINITIX_WAKEUP_CMD ((uint16_t)0x0001)
#define ZINITIX_CLEAR_INT_CMD ((uint16_t)0x0003)
#define ZINITIX_IDLE_CMD ((uint16_t)0x0004)
#define ZINITIX_SLEEP_CMD ((uint16_t)0x0005)
#define ZINITIX_CLEAR_INT_STATUS_CMD ((uint16_t)0x0003)
#define ZINITIX_CALIBRATE_CMD ((uint16_t)0x0006)
#define ZINITIX_SAVE_STATUS_CMD ((uint16_t)0x0007)
#define ZINITIX_SAVE_CALIBRATION_CMD ((uint16_t)0x0008)
#define ZINITIX_RECALL_FACTORY_CMD ((uint16_t)0x000f)
#define ZINITIX_SENSITIVITY ((uint16_t)0x0020)
#define ZINITIX_I2C_CHECKSUM_WCNT ((uint16_t)0x016a)
#define ZINITIX_I2C_CHECKSUM_RESULT ((uint16_t)0x016c)
#define ZINITIX_DEBUG_REG ((uint16_t)0x0115) // 0~7
#define ZINITIX_TOUCH_MODE ((uint16_t)0x0010)
#define ZINITIX_CHIP_REVISION ((uint16_t)0x0011)
#define ZINITIX_FIRMWARE_VERSION ((uint16_t)0x0012)
#define ZINITIX_MINOR_FW_VERSION ((uint16_t)0x0121)
#define ZINITIX_DATA_VERSION_REG ((uint16_t)0x0013)
#define ZINITIX_HW_ID ((uint16_t)0x0014)
#define ZINITIX_SUPPORTED_FINGER_NUM ((uint16_t)0x0015)
#define ZINITIX_EEPROM_INFO ((uint16_t)0x0018)
#define ZINITIX_INITIAL_TOUCH_MODE ((uint16_t)0x0019)
#define ZINITIX_TOTAL_NUMBER_OF_X ((uint16_t)0x0060)
#define ZINITIX_TOTAL_NUMBER_OF_Y ((uint16_t)0x0061)
#define ZINITIX_DELAY_RAW_FOR_HOST ((uint16_t)0x007f)
#define ZINITIX_BUTTON_SUPPORTED_NUM ((uint16_t)0x00B0)
#define ZINITIX_BUTTON_SENSITIVITY ((uint16_t)0x00B2)
#define ZINITIX_X_RESOLUTION ((uint16_t)0x00C0)
#define ZINITIX_Y_RESOLUTION ((uint16_t)0x00C1)
#define ZINITIX_POINT_STATUS_REG ((uint16_t)0x0080)
#define ZINITIX_ICON_STATUS_REG ((uint16_t)0x00AA)
#define ZINITIX_AFE_FREQUENCY ((uint16_t)0x0100)
#define ZINITIX_DND_N_COUNT ((uint16_t)0x0122)
#define ZINITIX_RAWDATA_REG ((uint16_t)0x0200)
#define ZINITIX_EEPROM_INFO_REG ((uint16_t)0x0018)
#define ZINITIX_INT_ENABLE_FLAG ((uint16_t)0x00f0)
#define ZINITIX_PERIODICAL_INTERRUPT_INTERVAL ((uint16_t)0x00f1)
#define ZINITIX_CHECKSUM_RESULT ((uint16_t)0x012c)
#define ZINITIX_INIT_FLASH ((uint16_t)0x01d0)
#define ZINITIX_WRITE_FLASH ((uint16_t)0x01d1)
#define ZINITIX_READ_FLASH ((uint16_t)0x01d2)
#define ZINITIX_POINTS_REG \
{ 0x0084, 0x008a, 0x0090, 0x0096, 0x009c }
#define BIT_DOWN 1
#define BIT_MOVE 2
#define BIT_UP 3
#define BIT_PALM 4
#define BIT_PALM_REJECT 5
#define BIT_WAKEUP 6
#define RESERVED_1 7
#define BIT_WEIGHT_CHANGE 8
#define BIT_PT_NO_CHANGE 9
#define BIT_REJECT 10
#define BIT_PT_EXIST 11
#define RESERVED_2 12
#define BIT_MUST_ZERO 13
#define BIT_DEBUG 14
#define BIT_ICON_EVENT 15
/* Status Register LOW */
#define BIT_POINT_COUNT_CHANGE _BV(0)
#define BIT_POINT_DOWN _BV(1)
#define BIT_POINT_MOVE _BV(2)
#define BIT_POINT_UP _BV(3)
#define BIT_RESERVED04 _BV(4)
#define BIT_PALM_REPORT_GESTURE _BV(5)
#define BIT_WAKE_UP _BV(6)
#define BIT_RESERVED07 _BV(7)
/* Status Register HIGH */
#define BIT_RESERVED08 _BV(0)
#define BIT_RESERVED09 _BV(1)
#define BIT_RESERVED10 _BV(2)
#define BIT_POINT_DETECTED _BV(3)
#define BIT_RESERVED12 _BV(4)
#define BIT_MUST_ZERO _BV(5)
#define BIT_DEBUG _BV(6)
#define BIT_BUTTON_INFO _BV(7)
#define SUB_BIT_EXIST 0
#define SUB_BIT_DOWN 1
#define SUB_BIT_MOVE 2
#define SUB_BIT_UP 3
#define SUB_BIT_UPDATE 4
#define SUB_BIT_WAIT 5

View File

@@ -0,0 +1,34 @@
/**
* @file TouchLib.h
* @author Micky (513673326@qq.com)
* @brief
* @version 0.1
* @date 2022-10-24
*
* @copyright Copyright (c) 2022
*
*/
#ifndef __TOUCHLIB_H__
#define __TOUCHLIB_H__
#if defined(TOUCH_MODULES_CST_SELF)
#include "ModulesCSTSelf.tpp"
typedef TouchLibCSTSelf TouchLib;
#elif defined(TOUCH_MODULES_CST_MUTUAL)
#include "ModulesCSTMutual.tpp"
typedef TouchLibCSTMutual TouchLib;
#elif defined(TOUCH_MODULES_GT911)
#include "ModulesGT911.tpp"
typedef TouchLibGT911 TouchLib;
#elif defined(TOUCH_MODULES_ZTW622)
#include "ModulesZTW622.tpp"
typedef TouchLibZTW622 TouchLib;
#elif defined(TOUCH_MODULES_L58)
#else
#error "Please define a touch chip model."
#endif
#endif

View File

@@ -0,0 +1,404 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 Micky
*
* 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 TouchCommon.tpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#pragma once
#if defined(ARDUINO)
#include <Wire.h>
#endif
#ifdef _BV
#undef _BV
#endif
#define _BV(b) (1ULL << (uint64_t)(b))
#ifndef constrain
#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
#endif
#define COMBINE_H8L4_H(h, l) (raw_data[h & 0xFF] << 4 | raw_data[l & 0xFF] >> 4)
#define COMBINE_H8L4_L(h, l) (raw_data[h & 0xFF] << 4 | raw_data[l & 0xFF] & 0xF)
#define COMBINE_H4L8(h, l) ((raw_data[h] & 0x0F) << 8 | raw_data[l])
#define IS_BIT_SET(val, mask) (((val) & (mask)) == (mask))
#if !defined(ARDUINO)
#define log_e(...)
#define log_i(...)
#define log_d(...)
#define LOW 0x0
#define HIGH 0x1
// GPIO FUNCTIONS
#define INPUT 0x01
#define OUTPUT 0x03
#define PULLUP 0x04
#define INPUT_PULLUP 0x05
#define PULLDOWN 0x08
#define INPUT_PULLDOWN 0x09
#define RISING 0x01
#define FALLING 0x02
#endif
template <class chipType>
class TouchLibCommon
{
typedef int (*iic_fptr_t)(uint8_t devAddr, uint16_t regAddr, uint8_t *data, uint8_t len);
public:
#if defined(ARDUINO)
bool begin(TwoWire &w, int sda, int scl, uint8_t addr, int rst)
{
if (__has_init)
return thisChip().initImpl();
__has_init = true;
__wire = &w;
__wire->begin(sda, scl);
__addr = addr;
__rst = rst;
return thisChip().initImpl();
}
#endif
bool begin(uint8_t addr, int rst, iic_fptr_t readRegCallback, iic_fptr_t writeRegCallback)
{
if (__has_init)
return thisChip().initImpl();
__has_init = true;
thisReadRegCallback = readRegCallback;
thisWriteRegCallback = writeRegCallback;
__addr = addr;
__rst = rst;
return thisChip().initImpl();
}
// private:
protected:
int readRegister(uint8_t reg)
{
uint8_t val = 0;
if (thisReadRegCallback != nullptr)
{
if (thisReadRegCallback(__addr, reg, &val, 1) != 0)
{
return 0;
}
return val;
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg);
if (__wire->endTransmission() != 0)
{
return -1;
}
__wire->requestFrom(__addr, 1U);
return __wire->read();
}
#endif
return -1;
}
int readRegister(uint16_t reg)
{
uint8_t val = 0;
if (thisReadRegCallback != nullptr)
{
if (thisReadRegCallback(__addr, reg, &val, 1) != 0)
{
return 0;
}
return val;
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write((uint8_t)(reg >> 8));
__wire->write((uint8_t)(reg & 0xff));
if (__wire->endTransmission() != 0)
{
return -1;
}
__wire->requestFrom(__addr, 1U);
return __wire->read();
}
#endif
return -1;
}
int writeRegister(uint8_t reg, uint8_t val)
{
if (thisWriteRegCallback)
{
return thisWriteRegCallback(__addr, reg, &val, 1);
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg);
__wire->write(val);
return (__wire->endTransmission() == 0) ? 0 : -1;
}
#endif
return -1;
}
int writeRegister(uint16_t reg, uint8_t val)
{
if (thisWriteRegCallback)
{
return thisWriteRegCallback(__addr, reg, &val, 1);
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg >> 8);
__wire->write(reg & 0xff);
__wire->write(val);
return (__wire->endTransmission() == 0) ? 0 : -1;
}
#endif
return -1;
}
int writeRegister(uint16_t reg, uint16_t val)
{
if (thisWriteRegCallback)
{
return thisWriteRegCallback(__addr, reg, (uint8_t *)&val, 2);
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg >> 8);
__wire->write(reg & 0xff);
__wire->write(val >> 8);
__wire->write(val & 0xff);
return (__wire->endTransmission() == 0) ? 0 : -1;
}
#endif
return -1;
}
int readRegister(uint8_t reg, uint8_t *buf, uint8_t lenght)
{
if (thisReadRegCallback)
{
return thisReadRegCallback(__addr, reg, buf, lenght);
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg);
if (__wire->endTransmission() != 0)
{
return -1;
}
__wire->requestFrom(__addr, lenght);
return __wire->readBytes(buf, lenght) == lenght ? 0 : -1;
}
#endif
return -1;
}
int readRegister(uint16_t reg, uint8_t *buf, uint8_t lenght)
{
if (thisReadRegCallback)
{
return thisReadRegCallback(__addr, reg, buf, lenght);
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg >> 8);
__wire->write(reg & 0xff);
if (__wire->endTransmission() != 0)
{
return -1;
}
__wire->requestFrom(__addr, lenght);
return __wire->readBytes(buf, lenght) == lenght ? 0 : -1;
}
#endif
return -1;
}
int writeRegister(uint8_t reg, uint8_t *buf, uint8_t lenght)
{
if (thisWriteRegCallback)
{
return thisWriteRegCallback(__addr, reg, buf, lenght);
}
#if defined(ARDUINO)
if (__wire)
{
__wire->beginTransmission(__addr);
__wire->write(reg);
__wire->write(buf, lenght);
return (__wire->endTransmission() == 0) ? 0 : -1;
}
#endif
return -1;
}
bool inline clrRegisterBit(uint8_t registers, uint8_t bit)
{
int val = readRegister(registers);
if (val == -1)
{
return false;
}
return writeRegister(registers, (val & (~_BV(bit)))) == 0;
}
bool inline setRegisterBit(uint8_t registers, uint8_t bit)
{
int val = readRegister(registers);
if (val == -1)
{
return false;
}
return writeRegister(registers, (val | (_BV(bit)))) == 0;
}
bool inline getRegisterBit(uint8_t registers, uint8_t bit)
{
int val = readRegister(registers);
if (val == -1)
{
return false;
}
return val & _BV(bit);
}
uint16_t inline readRegisterH8L4(uint8_t highReg, uint8_t lowReg)
{
int h8 = readRegister(highReg);
int l4 = readRegister(lowReg);
if (h8 == -1 || l4 == -1)
return 0;
return (h8 << 4) | (l4 & 0x0F);
}
uint16_t inline readRegisterH8L5(uint8_t highReg, uint8_t lowReg)
{
int h8 = readRegister(highReg);
int l5 = readRegister(lowReg);
if (h8 == -1 || l5 == -1)
return 0;
return (h8 << 5) | (l5 & 0x1F);
}
uint16_t inline readRegisterH6L8(uint8_t highReg, uint8_t lowReg)
{
int h6 = readRegister(highReg);
int l8 = readRegister(lowReg);
if (h6 == -1 || l8 == -1)
return 0;
return ((h6 & 0x3F) << 8) | l8;
}
uint16_t inline readRegisterH5L8(uint8_t highReg, uint8_t lowReg)
{
int h5 = readRegister(highReg);
int l8 = readRegister(lowReg);
if (h5 == -1 || l8 == -1)
return 0;
return ((h5 & 0x1F) << 8) | l8;
}
/*
* CRTP Helper
*/
protected:
bool begin()
{
#if defined(ARDUINO)
if (__has_init)
return thisChip().initImpl();
__has_init = true;
log_i("SDA:%d SCL:%d RST:%d", __sda, __scl, __rst);
if (__rst != -1)
{
pinMode(__rst, OUTPUT);
digitalWrite(__rst, 0);
delay(200);
digitalWrite(__rst, 1);
delay(200);
}
__wire->begin(__sda, __scl);
__wire->beginTransmission(__addr);
uint8_t error = Wire.endTransmission();
if (error != 0)
return false;
#endif /*ARDUINO*/
return thisChip().initImpl();
}
void end()
{
#if defined(ARDUINO)
if (__wire)
{
#if defined(ESP_IDF_VERSION)
#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(4, 4, 0)
__wire->end();
#endif /*ESP_IDF_VERSION*/
#endif /*ESP_IDF_VERSION*/
}
#endif /*ARDUINO*/
}
inline const chipType &thisChip() const { return static_cast<const chipType &>(*this); }
inline chipType &thisChip() { return static_cast<chipType &>(*this); }
protected:
bool __has_init = false;
#if defined(ARDUINO)
TwoWire *__wire = NULL;
#endif
int __sda = -1;
int __scl = -1;
int __rst = -1;
uint8_t __addr = 0xFF;
iic_fptr_t thisReadRegCallback = NULL;
iic_fptr_t thisWriteRegCallback = NULL;
};

View File

@@ -0,0 +1,31 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 micky
*
* 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 TouchLibInterface.cpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#include "TouchLibInterface.hpp"

View File

@@ -0,0 +1,91 @@
/**
*
* @license MIT License
*
* Copyright (c) 2022 micky
*
* 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 TouchLibInterface.hpp
* @author Micky (513673326@qq.com)
* @date 2022-10-24
*
*/
#pragma once
#include "stdint.h"
class TP_Point {
public:
TP_Point(void){};
~TP_Point(){};
TP_Point(uint8_t id, uint16_t x, uint16_t y, uint16_t size, uint8_t pressure, uint8_t state)
: id(id), x(x), y(y), size(size), pressure(pressure), state(state) {}
bool operator==(TP_Point point) {
return ((point.x == x) && (point.y == y) && (point.size == size) && (point.pressure == pressure) && (point.state == state));
}
bool operator!=(TP_Point point) {
return ((point.x != x) || (point.y != y) || (point.size != size) || (point.pressure != pressure) || (point.state != state));
}
uint8_t id;
uint16_t x;
uint16_t y;
uint8_t size;
uint8_t pressure;
uint8_t state;
};
class TouchLibInterface {
public:
TouchLibInterface() {}
virtual ~TouchLibInterface() {}
virtual bool init() = 0;
virtual void deinit() = 0;
virtual bool enableSleep() = 0;
virtual bool read() = 0;
virtual uint8_t getPointNum() = 0;
virtual TP_Point getPoint(uint8_t n) = 0;
// virtual void setRotation(uint8_t r) = 0;
virtual uint8_t getRotation() = 0;
};
class TouchLibGesture {
public:
TouchLibGesture() {}
virtual ~TouchLibGesture() {}
virtual bool isEnableGesture() = 0;
virtual bool enableGesture() = 0;
virtual bool disableGesture() = 0;
virtual uint8_t getGesture(void) = 0;
};