SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
touch/TouchDrvGT9895.hpp
Go to the documentation of this file.
1
30#pragma once
31
32#include "../SensorBuildOpt.h"
33#if !SENSORLIB_EXCLUDE_TOUCH_GT9895
34
35#include "TouchDrvInterface.hpp"
36
37static constexpr uint8_t GT9895_SLAVE_ADDRESS_H = (0x14);
38static constexpr uint8_t GT9895_SLAVE_ADDRESS_L = (0x5D);
39
41{
42public:
48 TouchDrvGT9895() = default;
49
54 ~TouchDrvGT9895() = default;
55
63 void sleep() override;
64
70 void wakeup() override;
71
80 const TouchPoints &getTouchPoints() override;
81
87 const char *getModelName() override;
88
89private:
90
91 enum CheckSumMode {
92 CHECKSUM_MODE_U8_LE,
93 CHECKSUM_MODE_U16_LE,
94 };
95
96 bool initImpl(uint8_t) override;
97
106 int calculateChecksum(const uint8_t *data, int size, CheckSumMode mode);
107
113 uint32_t getChipPID();
114
120 void clearStatus();
121
122protected:
123
124 static constexpr uint8_t MAX_FINGER_NUM = (10);
125 static constexpr uint8_t IRQ_EVENT_HEAD_LEN = (8);
126 static constexpr uint8_t BYTES_PER_POINT = (8);
127 static constexpr uint8_t COORDS_DATA_CHECKSUM_SIZE = (2);
128
129 static constexpr uint8_t POINT_TYPE_STYLUS_HOVER = (1);
130 static constexpr uint8_t POINT_TYPE_STYLUS = (3);
131
132 static constexpr uint32_t REG_FW_VERSION = (0x010014);
133 static constexpr uint32_t REG_INFO = (0x010070);
134 static constexpr uint32_t REG_CMD = (0x010174);
135 static constexpr uint32_t REG_POINT = (0x010308);
136 static constexpr uint32_t REG_NUM_POINT = (0x01030A);
137
138 static constexpr uint32_t CHIP_PID = (0x9895);
139};
140
141#endif
static constexpr uint8_t IRQ_EVENT_HEAD_LEN
const char * getModelName() override
Get the model name.
void wakeup() override
Wake up the touch driver.
static constexpr uint32_t REG_INFO
void sleep() override
Puts the touch driver to sleep.
static constexpr uint8_t MAX_FINGER_NUM
static constexpr uint32_t REG_CMD
static constexpr uint8_t BYTES_PER_POINT
const TouchPoints & getTouchPoints() override
Get the touch points.
static constexpr uint8_t POINT_TYPE_STYLUS
static constexpr uint32_t CHIP_PID
static constexpr uint32_t REG_FW_VERSION
static constexpr uint32_t REG_NUM_POINT
static constexpr uint8_t COORDS_DATA_CHECKSUM_SIZE
static constexpr uint32_t REG_POINT
TouchDrvGT9895()=default
Constructor for the touch driver.
~TouchDrvGT9895()=default
Destructor for the touch driver.
static constexpr uint8_t POINT_TYPE_STYLUS_HOVER
Abstract base class for touch screen drivers.
virtual uint8_t getPoint(int16_t *x_array, int16_t *y_array, uint8_t get_point=1) __attribute__((deprecated("use getTouchPoints instead of getPoint")))
Retrieve touch point coordinates (deprecated).
Container for touch point data and optional gesture information.