picofuse

Data Structures | Macros | Typedefs | Enumerations
FT6236

This module provides a device-level API for FT6236-compatible capacitive touch controllers over I2C. More...

Collaboration diagram for FT6236:

Data Structures

struct  dev_ft6236_config_t
 Optional FT6236 initialization options. More...
 
struct  dev_ft6236_touch_t
 A single touch contact. More...
 

Macros

#define DEV_FT6236_I2C_ADDR_DEFAULT   0x38u
 Fixed 7-bit I2C address - FT6236 has no address-select pin, so this is the only address it ever responds at. More...
 
#define DEV_FT6236_MAX_POINTS   2u
 Maximum number of simultaneous touch contacts reported by FT6236.
 

Typedefs

typedef struct dev_ft6236_t dev_ft6236_t
 Opaque FT6236 handle.
 

Enumerations

enum  dev_ft6236_touch_event_t { dev_ft6236_touch_up = 0, dev_ft6236_touch_down = 1, dev_ft6236_touch_move = 2 }
 Touch contact state reported by dev_ft6236_poll(). More...
 

Lifecycle

void dev_ft6236_default_config (dev_ft6236_config_t *config)
 Fill an FT6236 config struct with safe defaults. More...
 
dev_ft6236_tdev_ft6236_init (hw_deviceio_t *device, hw_gpio_t *int_pin, const dev_ft6236_config_t *config)
 Initialize an FT6236-compatible touch controller over I2C. More...
 
void dev_ft6236_deinit (dev_ft6236_t *ft6236)
 Deinitialize an FT6236 controller. More...
 

Properties

bool dev_ft6236_irq_active (const dev_ft6236_t *ft6236)
 Report whether the FT6236 interrupt line is currently asserted. More...
 

Methods

bool dev_ft6236_poll (dev_ft6236_t *ft6236, dev_ft6236_touch_t touches[DEV_FT6236_MAX_POINTS], uint8_t *out_touch_count)
 Poll the controller and parse the latest touch frame. More...
 

Detailed Description

This module provides a device-level API for FT6236-compatible capacitive touch controllers over I2C.

Macro Definition Documentation

◆ DEV_FT6236_I2C_ADDR_DEFAULT

#define DEV_FT6236_I2C_ADDR_DEFAULT   0x38u

Fixed 7-bit I2C address - FT6236 has no address-select pin, so this is the only address it ever responds at.

For use with hw_i2c_init() / hw_i2c_init_default() when constructing the device handle passed to dev_ft6236_init().

Definition at line 33 of file ft6236.h.

Enumeration Type Documentation

◆ dev_ft6236_touch_event_t

Touch contact state reported by dev_ft6236_poll().

Enumerator
dev_ft6236_touch_up 

Contact lifted - no longer touching.

dev_ft6236_touch_down 

A new contact.

dev_ft6236_touch_move 

An existing contact moved.

Definition at line 53 of file ft6236.h.

53  {
dev_ft6236_touch_event_t
Touch contact state reported by dev_ft6236_poll().
Definition: ft6236.h:53
Contact lifted - no longer touching.
Definition: ft6236.h:54
A new contact.
Definition: ft6236.h:55
An existing contact moved.
Definition: ft6236.h:56

Function Documentation

◆ dev_ft6236_default_config()

void dev_ft6236_default_config ( dev_ft6236_config_t config)

Fill an FT6236 config struct with safe defaults.

Parameters
configConfig structure to initialize.

◆ dev_ft6236_deinit()

void dev_ft6236_deinit ( dev_ft6236_t ft6236)

Deinitialize an FT6236 controller.

Parameters
ft6236FT6236 handle.

Passing NULL is safe and is a no-op.

◆ dev_ft6236_init()

dev_ft6236_t* dev_ft6236_init ( hw_deviceio_t device,
hw_gpio_t int_pin,
const dev_ft6236_config_t config 
)

Initialize an FT6236-compatible touch controller over I2C.

Parameters
deviceI2C device handle from hw_i2c_init() / hw_i2c_init_default() / hw_i2c_init_device(), already opened at the controller's address (see DEV_FT6236_I2C_ADDR_DEFAULT).
int_pinOptional interrupt GPIO handle. Pass NULL to always poll.
configOptional pointer to initialization options. Pass NULL to use default values.
Returns
FT6236 handle or NULL on failure.

◆ dev_ft6236_irq_active()

bool dev_ft6236_irq_active ( const dev_ft6236_t ft6236)

Report whether the FT6236 interrupt line is currently asserted.

Parameters
ft6236FT6236 handle.
Return values
trueThe controller is signalling a pending update.
falseNo pending update is signalled, or no interrupt pin exists.

◆ dev_ft6236_poll()

bool dev_ft6236_poll ( dev_ft6236_t ft6236,
dev_ft6236_touch_t  touches[DEV_FT6236_MAX_POINTS],
uint8_t *  out_touch_count 
)

Poll the controller and parse the latest touch frame.

Parameters
ft6236FT6236 handle.
touchesArray receiving parsed touch contacts, indexed by touch slot. Must have room for DEV_FT6236_MAX_POINTS entries.
out_touch_countOptional pointer receiving number of active touch points. Pass NULL to ignore.
Return values
trueRead succeeded.
falseRead failed.

When an interrupt pin is configured, this function skips the I2C transaction when no touch is pending and the previous frame was already idle.