This commit is contained in:
2025-06-18 09:21:10 +08:00
commit b2b79996d7
478 changed files with 82728 additions and 0 deletions

View File

@ -0,0 +1 @@
.vscode/*

View File

@ -0,0 +1 @@
{"type": "library", "name": "TAMC_GT911", "version": "1.0.2", "spec": {"owner": "tamctec", "id": 12932, "name": "TAMC_GT911", "requirements": null, "uri": null}}

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,4 @@
# GT911 Library
This is a library for the GT911 capacitive touch screen

View File

@ -0,0 +1,170 @@
#include "Arduino.h"
#include <TAMC_GT911.h>
#include <Wire.h>
TAMC_GT911::TAMC_GT911(uint8_t _sda, uint8_t _scl, uint8_t _int, uint8_t _rst, uint16_t _width, uint16_t _height) :
pinSda(_sda), pinScl(_scl), pinInt(_int), pinRst(_rst), width(_width), height(_height) {
}
void TAMC_GT911::begin(uint8_t _addr) {
addr = _addr;
Wire.begin(pinSda, pinScl);
reset();
}
void TAMC_GT911::reset() {
pinMode(pinInt, OUTPUT);
pinMode(pinRst, OUTPUT);
digitalWrite(pinInt, 0);
digitalWrite(pinRst, 0);
delay(10);
digitalWrite(pinInt, addr==GT911_ADDR2);
delay(1);
digitalWrite(pinRst, 1);
delay(5);
digitalWrite(pinInt, 0);
delay(50);
pinMode(pinInt, INPUT);
// attachInterrupt(pinInt, TAMC_GT911::onInterrupt, RISING);
delay(50);
readBlockData(configBuf, GT911_CONFIG_START, GT911_CONFIG_SIZE);
setResolution(width, height);
}
void TAMC_GT911::calculateChecksum() {
uint8_t checksum;
for (uint8_t i=0; i<GT911_CONFIG_SIZE; i++) {
checksum += configBuf[i];
}
checksum = (~checksum) + 1;
configBuf[GT911_CONFIG_CHKSUM - GT911_CONFIG_START] = checksum;
}
// void ARDUINO_ISR_ATTR TAMC_GT911::onInterrupt() {
// read();
// TAMC_GT911::onRead();
// }
void TAMC_GT911::reflashConfig() {
calculateChecksum();
writeByteData(GT911_CONFIG_CHKSUM, configBuf[GT911_CONFIG_CHKSUM-GT911_CONFIG_START]);
writeByteData(GT911_CONFIG_FRESH, 1);
}
void TAMC_GT911::setRotation(uint8_t rot) {
rotation = rot;
}
void TAMC_GT911::setResolution(uint16_t _width, uint16_t _height) {
configBuf[GT911_X_OUTPUT_MAX_LOW - GT911_CONFIG_START] = lowByte(_width);
configBuf[GT911_X_OUTPUT_MAX_HIGH - GT911_CONFIG_START] = highByte(_width);
configBuf[GT911_Y_OUTPUT_MAX_LOW - GT911_CONFIG_START] = lowByte(_height);
configBuf[GT911_Y_OUTPUT_MAX_HIGH - GT911_CONFIG_START] = highByte(_height);
reflashConfig();
}
// void TAMC_GT911::setOnRead(void (*isr)()) {
// onRead = isr;
// }
void TAMC_GT911::read(void) {
// Serial.println("TAMC_GT911::read");
uint8_t data[7];
uint8_t id;
uint16_t x, y, size;
uint8_t pointInfo = readByteData(GT911_POINT_INFO);
uint8_t bufferStatus = pointInfo >> 7 & 1;
uint8_t proximityValid = pointInfo >> 5 & 1;
uint8_t haveKey = pointInfo >> 4 & 1;
isLargeDetect = pointInfo >> 6 & 1;
touches = pointInfo & 0xF;
// Serial.print("bufferStatus: ");Serial.println(bufferStatus);
// Serial.print("largeDetect: ");Serial.println(isLargeDetect);
// Serial.print("proximityValid: ");Serial.println(proximityValid);
// Serial.print("haveKey: ");Serial.println(haveKey);
// Serial.print("touches: ");Serial.println(touches);
isTouched = touches > 0;
if (bufferStatus == 1 && isTouched) {
for (uint8_t i=0; i<touches; i++) {
readBlockData(data, GT911_POINT_1 + i * 8, 7);
points[i] = readPoint(data);
}
}
writeByteData(GT911_POINT_INFO, 0);
}
TP_Point TAMC_GT911::readPoint(uint8_t *data) {
uint16_t temp;
uint8_t id = data[0];
uint16_t x = data[1] + (data[2] << 8);
uint16_t y = data[3] + (data[4] << 8);
uint16_t size = data[5] + (data[6] << 8);
switch (rotation){
case ROTATION_NORMAL:
x = width - x;
y = height - y;
break;
case ROTATION_LEFT:
temp = x;
x = width - y;
y = temp;
break;
case ROTATION_INVERTED:
x = x;
y = y;
break;
case ROTATION_RIGHT:
temp = x;
x = y;
y = height - temp;
break;
default:
break;
}
return TP_Point(id, x, y, size);
}
void TAMC_GT911::writeByteData(uint16_t reg, uint8_t val) {
Wire.beginTransmission(addr);
Wire.write(highByte(reg));
Wire.write(lowByte(reg));
Wire.write(val);
Wire.endTransmission();
}
uint8_t TAMC_GT911::readByteData(uint16_t reg) {
uint8_t x;
Wire.beginTransmission(addr);
Wire.write(highByte(reg));
Wire.write(lowByte(reg));
Wire.endTransmission();
Wire.requestFrom(addr, (uint8_t)1);
x = Wire.read();
return x;
}
void TAMC_GT911::writeBlockData(uint16_t reg, uint8_t *val, uint8_t size) {
Wire.beginTransmission(addr);
Wire.write(highByte(reg));
Wire.write(lowByte(reg));
// Wire.write(val, size);
for (uint8_t i=0; i<size; i++) {
Wire.write(val[i]);
}
Wire.endTransmission();
}
void TAMC_GT911::readBlockData(uint8_t *buf, uint16_t reg, uint8_t size) {
Wire.beginTransmission(addr);
Wire.write(highByte(reg));
Wire.write(lowByte(reg));
Wire.endTransmission();
Wire.requestFrom(addr, size);
for (uint8_t i=0; i<size; i++) {
buf[i] = Wire.read();
}
}
TP_Point::TP_Point(void) {
id = x = y = size = 0;
}
TP_Point::TP_Point(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _size) {
id = _id;
x = _x;
y = _y;
size = _size;
}
bool TP_Point::operator==(TP_Point point) {
return ((point.x == x) && (point.y == y) && (point.size == size));
}
bool TP_Point::operator!=(TP_Point point) {
return ((point.x != x) || (point.y != y) || (point.size != size));
}

View File

@ -0,0 +1,189 @@
#ifndef TAMC_GT911_H
#define TAMC_GT911_H
#include "Arduino.h"
#include <Wire.h>
#define GT911_ADDR1 (uint8_t)0x5D
#define GT911_ADDR2 (uint8_t)0x14
#define ROTATION_LEFT (uint8_t)0
#define ROTATION_INVERTED (uint8_t)1
#define ROTATION_RIGHT (uint8_t)2
#define ROTATION_NORMAL (uint8_t)3
// 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}
class TP_Point {
public:
TP_Point(void);
TP_Point(uint8_t id, uint16_t x, uint16_t y, uint16_t size);
bool operator==(TP_Point);
bool operator!=(TP_Point);
uint8_t id;
uint16_t x;
uint16_t y;
uint8_t size;
};
class TAMC_GT911 {
public:
TAMC_GT911(uint8_t _sda, uint8_t _scl, uint8_t _int, uint8_t _rst, uint16_t _width, uint16_t _height);
void begin(uint8_t _addr=GT911_ADDR1);
void reset();
void setRotation(uint8_t rot);
void setResolution(uint16_t _width, uint16_t _height);
// void setOnRead(void (*isr)());
uint8_t getGesture(void);
void read(void);
uint8_t isLargeDetect;
uint8_t touches = 0;
bool isTouched = false;
// uint8_t gesture = NO_GESTURE;
TP_Point points[5];
private:
void calculateChecksum();
void reflashConfig();
// static void ARDUINO_ISR_ATTR onInterrupt();
TP_Point readPoint(uint8_t *data);
// void (*onRead)();
void writeByteData(uint16_t reg, uint8_t val);
uint8_t readByteData(uint16_t reg);
void writeBlockData(uint16_t reg, uint8_t *val, uint8_t size);
void readBlockData(uint8_t *buf, uint16_t reg, uint8_t size);
uint8_t rotation = ROTATION_NORMAL;
uint8_t addr;
uint8_t pinSda;
uint8_t pinScl;
uint8_t pinInt;
uint8_t pinRst;
uint16_t width;
uint16_t height;
uint8_t configBuf[GT911_CONFIG_SIZE];
// uint8_t *configBuf;
};
#endif // TAMC_GT911_H

View File

@ -0,0 +1,30 @@
#include "TAMC_GT911.h"
#define TOUCH_SDA 4
#define TOUCH_SCL 5
#define TOUCH_INT 25
#define TOUCH_RST 26
#define TOUCH_WIDTH 320
#define TOUCH_HEIGHT 240
TAMC_GT911 tp = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);
void setup() {
Serial.begin(115200);
Serial.println("TAMC_GT911 Example: Ready");
tp.begin();
tp.setRotation(ROTATION_NORMAL);
}
void loop() {
tp.read();
if (tp.isTouched){
for (int i=0; i<tp.touches; i++){
Serial.print("Touch ");Serial.print(i+1);Serial.print(": ");;
Serial.print(" x: ");Serial.print(tp.points[i].x);
Serial.print(" y: ");Serial.print(tp.points[i].y);
Serial.print(" size: ");Serial.println(tp.points[i].size);
Serial.println(' ');
}
}
}

View File

@ -0,0 +1,9 @@
name=TAMC_GT911
version=1.0.2
author=TAMC
maintainer=TAMC <tamctec@gmail.com>
sentence=Arduino library for GT911
paragraph=Arduino library for GT911 Touch Panel
category=Display
url=https://github.com/tamctec/gt911-arduino
architectures=esp32