TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TouchDriverBitBang Class Reference

Bit-banged 4-wire resistive touch panel driver. More...

#include <TouchDriverArduino.h>

Inheritance diagram for TouchDriverBitBang:
Inheritance graph
[legend]
Collaboration diagram for TouchDriverBitBang:
Collaboration graph
[legend]

Public Member Functions

 TouchDriverBitBang (int8_t xPlusPin, int8_t xMinusPin, int8_t yPlusPin, int8_t yMinusPin)
 
bool begin () override
 Initialize the controller.
 
bool isTouched () override
 Return whether the panel currently appears touched.
 
bool getPoint (Point &outPoint) override
 Read the current touch point.
 
- Public Member Functions inherited from TouchDriver
virtual ~TouchDriver ()=default
 
virtual bool begin ()=0
 Initialize the controller.
 
virtual bool isTouched ()=0
 Return whether the panel currently appears touched.
 
virtual bool getPoint (Point &outPoint)=0
 Read the current touch point.
 
virtual bool getSecondPoint (Point &outPoint)
 Read a second, simultaneous touch point, for multi-touch gestures (pinch/rotate).
 
void setRotation (Rotation rotation)
 
Rotation getRotation () const
 
bool setCalibration (const CalibrationData &cal)
 Set and validate calibration.
 
const CalibrationData & getCalibration () const
 
bool hasCalibration () const
 

Additional Inherited Members

- Protected Member Functions inherited from TouchDriver
Point mapCoordinates (int16_t rawX, int16_t rawY, uint16_t pressure=255) const
 Convert raw controller coordinates into logical display space.
 
- Static Protected Member Functions inherited from TouchDriver
static bool validateCalibration (const CalibrationData &cal)
 
static int32_t clamp32 (int32_t value, int32_t minimum, int32_t maximum)
 Clamp an integer to an inclusive range.
 
static int32_t mapRange (int32_t value, int32_t inMin, int32_t inMax, int32_t outMin, int32_t outMax)
 Map an integer from one range to another.
 
- Protected Attributes inherited from TouchDriver
Rotation rotation_ = Rotation::Deg0
 
CalibrationData calibration_
 
bool hasCalibration_ = false
 

Detailed Description

Bit-banged 4-wire resistive touch panel driver.

Drives the resistive layer's four pins (X-, Y-, X+, Y+) directly via GPIO - pinMode()/digitalWrite()/digitalRead()/analogRead() - rather than through a dedicated touch controller chip such as XPT2046. This matches small resistive touch panels that expose their four resistive-layer pins straight to microcontroller GPIOs instead of routing them through a controller IC.

Requires analogRead() to be available for all four pins, i.e. a real Arduino core (arduino-esp32, AVR, ...) - the ESP-IDF-native TinyGPU/Emulation fallback (see EmulationIDF.h) does not emulate analogRead()/ADC, so this driver will not compile against that fallback.

Position measurement, per axis:

Touch presence is a cheap digital check (Y+ as INPUT_PULLUP, X- driven LOW; a touch shorts the two layers together and pulls Y+ LOW) rather than a calibrated Z1/Z2 pressure measurement - this only needs to know whether the panel is touched at all. Pressure is therefore always reported as 255 while touched, like the capacitive controllers below.

Constructor & Destructor Documentation

◆ TouchDriverBitBang()

TouchDriverBitBang ( int8_t  xPlusPin,
int8_t  xMinusPin,
int8_t  yPlusPin,
int8_t  yMinusPin 
)
inline
Parameters
xPlusPinX+ resistive layer analog pin.
xMinusPinX- resistive layer digital pin.
yPlusPinY+ resistive layer analog pin.
yMinusPinY- resistive layer digital pin.

Member Function Documentation

◆ begin()

bool begin ( )
inlineoverridevirtual

Initialize the controller.

The driver does NOT initialize the SPI/I2C bus itself. The application is responsible for calling Wire.begin(), SPI.begin(), and configuring any board-specific bus pins.

Implements TouchDriver.

◆ getPoint()

bool getPoint ( Point &  outPoint)
inlineoverridevirtual

Read the current touch point.

Returns
true if a valid touch point was obtained.

Implements TouchDriver.

◆ isTouched()

bool isTouched ( )
inlineoverridevirtual

Return whether the panel currently appears touched.

For controllers without an IRQ pin this may perform a controller read.

Implements TouchDriver.


The documentation for this class was generated from the following file: