12extern SPI_HandleTypeDef hspi1;
21 tsc2046 =
new TSC2046(&hspi1, TSC2046_CS_GPIO_Port, TSC2046_CS_Pin);
STM32 HAL driver for a TI/Adafruit TSC2046 resistive touchscreen controller, reached over SPI via an ...
void setVRef(float vref)
Sets the voltage connected to the TSC2046's VRef pin, if any.
float readAuxiliaryVoltage()
float readBatteryVoltage()
void enableInterrupts(bool enable)
Enables or disables the TSC2046's own touch interrupt (IRQ pin pulled low on touch)....
TSC2046TouchPoint getPoint()
Reads the current touch position and pressure.
bool isTouched()
Determines if the touchscreen is currently being touched, based on the pressure value from getPoint()...
void setTouchedThreshold(float touchedThresholdOhms)
Sets the pressure threshold used by isTouched().
float readTemperatureC()
Reads the TSC2046's on-die temperature sensor, in degrees Celsius.
void begin(uint32_t xPlateResistance=400)
Initializes the driver. Call once before any other method.
void initTSC2046(void)
Constructs the TSC2046 driver. Must be called after MX_SPI1_Init() (and therefore after HAL_Init()/Sy...
bool tsc2046ReadBatteryVoltage(float *volts)
Reads the voltage on the VBAT pin.
void tsc2046SetVRef(float vref)
Sets the voltage connected to the TSC2046's VRef pin, if any.
bool tsc2046IsReady(void)
Reports whether initTSC2046() has run. Every other tsc2046* function below returns false without touc...
static bool tsc2046Ready
Set once initTSC2046() runs; guards every bridge function below against use-before-init.
void tsc2046SetTouchedThreshold(float touchedThresholdOhms)
Sets the pressure threshold used by tsc2046IsTouched().
bool tsc2046GetPoint(int16_t *x, int16_t *y, float *pressure)
Reads the current touch position and pressure.
bool tsc2046ReadAuxiliaryVoltage(float *volts)
Reads the voltage on the AUX pin.
bool tsc2046ReadTemperatureC(float *celsius)
Reads the current temperature.
bool tsc2046IsTouched(void)
Determines if the touchscreen is currently being touched.
static TSC2046 * tsc2046
The single TSC2046 driver instance, constructed in initTSC2046().
void tsc2046EnableInterrupts(bool enable)
Enables or disables the TSC2046's own touch interrupt (IRQ pin pulled low on touch)....
C-callable entry points bridging CubeMX-generated main.c into the C++ TSC2046 driver.
One touch reading: raw X/Y position and a pressure-proportional resistance value.
int16_t x
Raw 12-bit X coordinate (0-4095). Meaningless if not touched.
int16_t y
Raw 12-bit Y coordinate (0-4095). Meaningless if not touched.