SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
custom_callback_touch.ino File Reference

@license MIT License More...

#include <TouchDrv.hpp>
#include <IoExpanderDrv.hpp>
#include <SensorWireHelper.h>
Include dependency graph for custom_callback_touch.ino:

Go to the source code of this file.

Macros

#define TOUCH_SDA   8
 
#define TOUCH_SCL   48
 
#define TOUCH_IRQ   1
 
#define TOUCH_RST   1
 

Functions

bool i2c_wr_function (uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite)
 i2c_wr_function
 
uint32_t hal_callback (SensorCommCustomHal::Operation op, void *param1, void *param2)
 
void TouchDrvDigitalWrite (uint8_t gpio, uint8_t level)
 
uint8_t TouchDrvDigitalRead (uint8_t gpio)
 
void TouchDrvPinMode (uint8_t gpio, uint8_t mode)
 
bool setupTouchDrv ()
 
void setup ()
 
void loop ()
 

Variables

TouchDrvInterfacetouchDrv
 
IoExpanderXL9555 expander
 
int16_t x [5]
 
int16_t y [5]
 
uint8_t expander_io_tp_reset = 1
 

Detailed Description

@license MIT License

Copyright (c) 2025 lewis he

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.

Author
Lewis He (lewis.nosp@m.he@o.nosp@m.utloo.nosp@m.k.co.nosp@m.m)
Date
2025-01-21
Note
CustomCallbackTouchDrvInterface use LilyGo T-RGB,T-RGB has three types of screens, each of which uses different touch driver chips. The example demonstrates using the touch interface class and one sketch is suitable for three types of touch chips. The example demonstrates using custom callbacks to read touch or sensors. This method is also applicable to other platforms. The prerequisite compilation platform must support C++11.

Definition in file custom_callback_touch.ino.

Macro Definition Documentation

◆ TOUCH_IRQ

#define TOUCH_IRQ   1

Definition at line 46 of file custom_callback_touch.ino.

◆ TOUCH_RST

#define TOUCH_RST   1

Definition at line 50 of file custom_callback_touch.ino.

◆ TOUCH_SCL

#define TOUCH_SCL   48

Definition at line 42 of file custom_callback_touch.ino.

◆ TOUCH_SDA

#define TOUCH_SDA   8

Definition at line 38 of file custom_callback_touch.ino.

Function Documentation

◆ hal_callback()

◆ i2c_wr_function()

bool i2c_wr_function ( uint8_t  addr,
uint8_t  reg,
uint8_t *  buf,
size_t  len,
bool  writeReg,
bool  isWrite 
)

i2c_wr_function

Note
I2C communication using custom callbacks
Parameters
addr7-Bit Device Address
regRegister address, only needs to be written when writeReg is true
*bufWhen isWrite is true, it represents the written buf, otherwise it is the read data buffer
lenWhen isWrite is true, it indicates the length of data written , otherwise it is the data read length
writeRegwriteReg is the register address that needs to be written, otherwise the register address is not written
isWriteData write and read direction, true means write, false means read
Return values
Truemeans the device is executed successfully, false means it fails

Definition at line 74 of file custom_callback_touch.ino.

References buf, and i.

Referenced by setup(), and setupTouchDrv().

◆ loop()

◆ setup()

◆ setupTouchDrv()

◆ TouchDrvDigitalRead()

uint8_t TouchDrvDigitalRead ( uint8_t  gpio)

Definition at line 160 of file custom_callback_touch.ino.

References IoExpanderBase::digitalRead(), and expander.

Referenced by setupTouchDrv().

◆ TouchDrvDigitalWrite()

void TouchDrvDigitalWrite ( uint8_t  gpio,
uint8_t  level 
)

Definition at line 151 of file custom_callback_touch.ino.

References IoExpanderBase::digitalWrite(), expander, and level.

Referenced by setupTouchDrv().

◆ TouchDrvPinMode()

void TouchDrvPinMode ( uint8_t  gpio,
uint8_t  mode 
)

Definition at line 169 of file custom_callback_touch.ino.

References expander, and IoExpanderBase::pinMode().

Referenced by setupTouchDrv().

Variable Documentation

◆ expander

◆ expander_io_tp_reset

uint8_t expander_io_tp_reset = 1

Definition at line 61 of file custom_callback_touch.ino.

Referenced by setupTouchDrv().

◆ touchDrv

TouchDrvInterface* touchDrv

Definition at line 54 of file custom_callback_touch.ino.

Referenced by loop(), and setupTouchDrv().

◆ x

int16_t x[5]

Definition at line 58 of file custom_callback_touch.ino.

◆ y

int16_t y[5]

Definition at line 58 of file custom_callback_touch.ino.