mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/touch_dev: extend API to set event callback function
This commit is contained in:
parent
84c83b8025
commit
528d884b5d
@ -41,6 +41,13 @@ typedef struct {
|
|||||||
uint16_t y; /**< Y coordinate */
|
uint16_t y; /**< Y coordinate */
|
||||||
} touch_t;
|
} touch_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Signature of touch event callback triggered from interrupt
|
||||||
|
*
|
||||||
|
* @param[in] arg optional context for the callback
|
||||||
|
*/
|
||||||
|
typedef void (*touch_event_cb_t)(void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic type for a touch driver
|
* @brief Generic type for a touch driver
|
||||||
*/
|
*/
|
||||||
@ -75,6 +82,15 @@ typedef struct {
|
|||||||
* @return number of touch positions, 0 means no touch
|
* @return number of touch positions, 0 means no touch
|
||||||
*/
|
*/
|
||||||
uint8_t (*touches)(const touch_dev_t *dev, touch_t *touches, size_t len);
|
uint8_t (*touches)(const touch_dev_t *dev, touch_t *touches, size_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set and configure the touch event callback
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the touch device
|
||||||
|
* @param[in] cb The callback function
|
||||||
|
* @param[in] arg Context argument
|
||||||
|
*/
|
||||||
|
void (*set_event_callback)(const touch_dev_t *dev, touch_event_cb_t cb, void *arg);
|
||||||
} touch_dev_driver_t;
|
} touch_dev_driver_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,6 +166,15 @@ uint16_t touch_dev_width(const touch_dev_t *dev);
|
|||||||
*/
|
*/
|
||||||
uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len);
|
uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set and configure the touch event callback
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the touch device
|
||||||
|
* @param[in] cb The callback function
|
||||||
|
* @param[in] arg Context argument
|
||||||
|
*/
|
||||||
|
void touch_dev_set_touch_event_callback(const touch_dev_t *dev, touch_event_cb_t cb, void *arg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,3 +82,9 @@ uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len)
|
|||||||
|
|
||||||
return dev->driver->touches(dev, touches, len);
|
return dev->driver->touches(dev, touches, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void touch_dev_set_touch_event_callback(const touch_dev_t *dev, touch_event_cb_t cb, void *arg)
|
||||||
|
{
|
||||||
|
assert(dev);
|
||||||
|
dev->driver->set_event_callback(dev, cb, arg);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user