elpekenin/touch.h

Generic(ish) driver for touch screens.

Danger

Only XPT2046 has been implemented/tested.


struct touch_report_t
[source]

Current status of a screen.

uint16_t x
[source]

Horizontal coordinate of the touch point.

uint16_t y
[source]

Vertical coordinate of the touch point.

bool pressed
[source]

Whether it is presed.

struct spi_touch_comms_config_t
[source]

Configuration for SPI settings.

pin_t chip_select_pin
[source]

Its CS pin.

uint16_t divisor
[source]

Speed of the communications.

bool lsb_first
[source]

Byte order.

uint8_t mode
[source]

SPI mode.

pin_t irq_pin
[source]

Interrup pin: flags that device is pressed.

uint8_t x_cmd
[source]

Command issued to get the X coordinate.

uint8_t y_cmd
[source]

Command issued to get the Y coordinate.

struct touch_driver_t
[source]

Configuration for a touch device.

uint16_t width
[source]

Horizontal size.

uint16_t height
[source]

Vertical size.

float scale_x
[source]

Up-/down- scaling applied to raw X reading.

float scale_y
[source]

Up-/down- scaling applied to raw Y reading.

int16_t offset_x
[source]

Offset applied to X reading (after being scaled).

int16_t offset_y
[source]

Offset applied to Y reading (after being scaled).

touch_rotation_t rotation
[source]

Orientation of the device.

bool upside_down
[source]

Whether the device is flipped. Causes some maths changes.

spi_touch_comms_config_t spi_config
[source]

Communications configuration.

type touch_device_t
[source]

Handle to a device’s configuration.

bool touch_spi_init(touch_device_t device)
[source]

Initialize a device.

void report_from(int16_t x, int16_t y, touch_driver_t *driver, touch_report_t *report)
[source]

(WEAK) Low-level function that performs math.

Parameters:
  • x – Raw X reading from sensor.

  • y – Raw Y reading from sensor.

  • driver – Handle to the device, to fetch its configuration.

  • report – Output struct to be filled/updated.

touch_report_t get_spi_touch_report(touch_device_t device, bool check_irq)
[source]

Get the current state of a sensor.

Parameters:
  • device – Sensor’s configuration.

  • check_irq – Whether to check the IRQ’s pin state.