roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
touch_gt911.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
roo_display/core/device.h
"
4
#include "
roo_display/driver/common/basic_touch.h
"
5
#include "
roo_display/driver/common/gpio_setter.h
"
6
#include "
roo_display/hal/i2c.h
"
7
#include "roo_threads.h"
8
#include "roo_threads/atomic.h"
9
#include "roo_threads/thread.h"
10
11
namespace
roo_display
{
12
13
// Note: this driver doesn't support interrupt-driven read explicitly. You can
14
// still use interrupts, if you want to, by registering an interrupt handler on
15
// the pinIntr pin externally, and then reacting to the interrupt signal by
16
// calling readTouch().
17
//
18
// Even if you're not using interrupts, you should still provide the pinIntr to
19
// the driver - or, alternatively, pull it low (e.g. tie it to GND). This is
20
// necessary because the GT911 uses the pin to select between two I2C addresses
21
// during initialization. This driver always uses the 0x5D address, which is
22
// selected by pulling the pin low during reset.
23
class
TouchGt911
:
public
BasicTouchDevice
<5> {
24
public
:
25
// Constructs the driver assuming the default I2C bus.
26
// For GpioSetter, you can pass pin numbers, or a custom implementation.
27
TouchGt911
(
GpioSetter
pinIntr
,
GpioSetter
pinRst
,
long
reset_low_hold_ms
= 1);
28
29
// Constructs the driver using the specified I2C bus (passed as the first
30
// argument).
31
// When using Arduino, you can pass a Wire& object reference.
32
// When using esp-idf, you can pass an i2c_port_num_t.
33
// For GpioSetter, you can pass pin numbers, or a custom implementation.
34
TouchGt911
(
I2cMasterBusHandle
i2c
,
GpioSetter
pinIntr
,
GpioSetter
pinRst
,
35
long
reset_low_hold_ms
= 1);
36
37
// Initializes the driver (performing GPIO setup and calling reset()).
38
// Must be called once.
39
void
initTouch
()
override
;
40
41
int
readTouch
(
TouchPoint
*
point
)
override
;
42
43
void
reset
();
44
45
private
:
46
bool
readByte(
uint16_t
reg
, roo::byte&
result
);
47
void
writeByte(
uint16_t
reg
, roo::byte val);
48
void
readBlock(roo::byte*
buf
,
uint16_t
reg
,
uint8_t
size);
49
50
int8_t
addr_;
51
GpioSetter
pinIntr_;
52
GpioSetter
pinRst_;
53
I2cSlaveDevice
i2c_slave_;
54
long
reset_low_hold_ms_;
55
56
roo::atomic<bool> ready_;
57
roo::thread reset_thread_;
58
};
59
60
}
// namespace roo_display
basic_touch.h
roo_display::BasicTouchDevice
Definition
basic_touch.h:14
roo_display::GpioSetter
Definition
gpio_setter.h:12
roo_display::TouchGt911
Definition
touch_gt911.h:23
roo_display::TouchGt911::reset
void reset()
Definition
touch_gt911.cpp:58
roo_display::TouchGt911::initTouch
void initTouch() override
Initialize the touch controller.
Definition
touch_gt911.cpp:47
roo_display::TouchGt911::readTouch
int readTouch(TouchPoint *point) override
Definition
touch_gt911.cpp:91
device.h
gpio_setter.h
i2c.h
roo_display
Defines 140 opaque HTML named colors.
Definition
roo_display.cpp:7
roo_display::BlendOp
Definition
blending.h:200
roo_display::TouchPoint
A single touch point returned by a touch controller.
Definition
device.h:390
temp_repos
roo_display
src
roo_display
driver
touch_gt911.h
Generated by
1.9.8