Device driver interface for the Hynitron CST816S touch screen.
More...
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:
- 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.
- 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.
|
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...
|
|
|
const char * | cst816s_gesture_str [] |
| string versions of the cst816 gestures
|
|
◆ cst816s_irq_cb_t
typedef void(* cst816s_irq_cb_t) (void *arg) |
callback definition
Definition at line 60 of file cst816s.h.
◆ 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.
◆ cst816s_init()
Initialize the given cst816s device.
- Parameters
-
[out] | dev | device descriptor of the given cst816s device |
[in] | params | static configuration parameters |
[in] | cb | callback for the cst816s event interrupt, may be NULL |
[in] | arg | extra argument passed to the event interrupt. |
- Returns
- CST816S_OK on success
-
CST816S_ERR_IRQ on IRQ initialization error
◆ cst816s_read()
Read touch data from the cst816s device.
- Parameters
-
[in] | dev | device descriptor |
[out] | data | Touch data |
- Returns
- 0 on success
-
negative on I2C access error