Loading...
Searching...
No Matches
Cst816S touch screen driver

Device driver interface for the Hynitron CST816S touch screen. More...

Detailed Description

Device driver interface for the Hynitron CST816S touch screen.

The CST816S is a touch sensor from Hynitron with integrated gesture detection. It is able to measure both the position of a single finger and a number of basic gestures. The PineTime board has one of these for the touch screen.

Documentation about the specifics is very limited and most of this driver is based on experimenting with the chip and from community effort on the PineTime.

Two things about the driver are noteworthy:

  1. It only responds to I2C commands after an event, such as a touch detection. Do not expect it to respond on init. Instead after a touch event, it will assert the IRQ and respond to I2C reads for a short time.
  2. While it should be able to detect multiple finger events, this version of the chip always returns only a single finger event and a gesture.

Reading the display data multiple times during a single event will return the last sampled finger position.

Files

file  cst816s_internal.h
 Internal constants for cst816s.
 
file  cst816s_params.h
 Default configuration for the CST816S touch screen driver.
 
file  cst816s_touch_dev.h
 Definition of the driver for the touch_dev generic interface.
 
file  cst816s.h
 Device driver interface for the CST816S touch screen.
 

Data Structures

struct  cst816s_touch_data_t
 cst816s touch event data More...
 
struct  cst816s_params_t
 cst816s driver struct More...
 
struct  cst816s_t
 cst816s device descriptor More...
 

Typedefs

typedef void(* cst816s_irq_cb_t) (void *arg)
 callback definition
 

Enumerations

enum  cst816s_touch_t { CST816S_TOUCH_DOWN = 0 , CST816S_TOUCH_UP = 1 , CST816S_TOUCH_CONTACT = 2 }
 cst816s touch event touch state More...
 
enum  cst816s_gesture_t {
  CST816S_GESTURE_NONE = 0x00 , CST816S_GESTURE_SLIDE_DOWN = 0x01 , CST816S_GESTURE_SLIDE_UP = 0x02 , CST816S_GESTURE_SLIDE_LEFT = 0x03 ,
  CST816S_GESTURE_SLIDE_RIGHT = 0x04 , CST816S_GESTURE_SINGLE_CLICK = 0x05 , CST816S_GESTURE_DOUBLE_CLICK = 0x0b , CST816S_GESTURE_LONG_PRESS = 0x0c
}
 CST816S Gesture types. More...
 
enum  { CST816S_OK = 0 , CST816S_ERR_IRQ = -1 }
 Status and error return codes. More...
 

Functions

int cst816s_init (cst816s_t *dev, const cst816s_params_t *params, cst816s_irq_cb_t cb, void *arg)
 Initialize the given cst816s device.
 
int cst816s_read (const cst816s_t *dev, cst816s_touch_data_t *data)
 Read touch data from the cst816s device.
 

Variables

const char * cst816s_gesture_str []
 string versions of the cst816 gestures
 

Typedef Documentation

◆ cst816s_irq_cb_t

typedef void(* cst816s_irq_cb_t) (void *arg)

callback definition

Definition at line 60 of file cst816s.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Status and error return codes.

Enumerator
CST816S_OK 

everything was fine

CST816S_ERR_IRQ 

IRQ initialization error.

Definition at line 126 of file cst816s.h.

◆ cst816s_gesture_t

CST816S Gesture types.

Enumerator
CST816S_GESTURE_NONE 

no gesture detected

CST816S_GESTURE_SLIDE_DOWN 

downward slide detected

CST816S_GESTURE_SLIDE_UP 

upward slide detected

CST816S_GESTURE_SLIDE_LEFT 

left slide detected

CST816S_GESTURE_SLIDE_RIGHT 

right slide detected

CST816S_GESTURE_SINGLE_CLICK 

single click detected

CST816S_GESTURE_DOUBLE_CLICK 

double click detected

CST816S_GESTURE_LONG_PRESS 

long press detected

Definition at line 74 of file cst816s.h.

◆ cst816s_touch_t

cst816s touch event touch state

Enumerator
CST816S_TOUCH_DOWN 

Touch press.

CST816S_TOUCH_UP 

Touch release.

CST816S_TOUCH_CONTACT 

Touch contact.

Definition at line 65 of file cst816s.h.

Function Documentation

◆ cst816s_init()

int cst816s_init ( cst816s_t dev,
const cst816s_params_t params,
cst816s_irq_cb_t  cb,
void *  arg 
)

Initialize the given cst816s device.

Parameters
[out]devdevice descriptor of the given cst816s device
[in]paramsstatic configuration parameters
[in]cbcallback for the cst816s event interrupt, may be NULL
[in]argextra argument passed to the event interrupt.
Returns
CST816S_OK on success
CST816S_ERR_IRQ on IRQ initialization error

◆ cst816s_read()

int cst816s_read ( const cst816s_t dev,
cst816s_touch_data_t data 
)

Read touch data from the cst816s device.

Parameters
[in]devdevice descriptor
[out]dataTouch data
Returns
0 on success
negative on I2C access error