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
7#include "roo_threads.h"
8#include "roo_threads/atomic.h"
9#include "roo_threads/thread.h"
10
11namespace 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.
23class 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.
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.
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
void initTouch() override
Initialize the touch controller.
int readTouch(TouchPoint *point) override
Defines 140 opaque HTML named colors.
A single touch point returned by a touch controller.
Definition device.h:390