这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

Touch Sensor API 参考

Touch Sensor

typedef void (*wm_drv_touch_sensor_callback_t)(wm_touch_sensor_num_t touch_num, void *priv)

Prototype touch sensor driver callback function.

int wm_drv_touch_sensor_register_callback(wm_device_t *dev, wm_touch_sensor_num_t touch_num, wm_drv_touch_sensor_callback_t callback, void *priv)

Registers a callback function for touch sensor.

参数:
  • dev[in] Pointer to the touch sensor device structure.

  • touch_num[in] Touch sensor number, range [0, WM_TOUCH_NUM_MAX].

  • callback[in] Pointer to the callback function .

  • priv[in] Pointer to user data to be passed to the callback function.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_touch_sensor_set_threshold(wm_device_t *dev, wm_touch_sensor_num_t touch_num, uint32_t threshold)

Sets the threshold value for touch sensing.

参数:
  • dev[in] Pointer to the touch sensor device.

  • touch_num[in] Touch sensor number, range [0, WM_TOUCH_NUM_MAX].

  • threshold[in] Threshold value to set, max value is WM_TOUCH_THRESHOLD_MAX.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_touch_sensor_get_threshold(wm_device_t *dev, wm_touch_sensor_num_t touch_num, uint32_t *threshold)

Gets the threshold value for touch sensing.

参数:
  • dev[in] Pointer to the touch sensor device.

  • touch_num[in] Touch sensor number, range [0, WM_TOUCH_NUM_MAX].

  • threshold[out] Threshold value to get.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_touch_sensor_read_countnum(wm_device_t *dev, wm_touch_sensor_num_t touch_num, uint32_t *countnum)

Reads the count number from the touch sensor.

参数:
  • dev[in] Pointer to the touch sensor device structure.

  • touch_num[in] Touch sensor number [0, WM_TOUCH_NUM_MAX].

  • countnum[out] Countnum value to get.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_touch_sensor_start(wm_device_t *dev, wm_touch_sensor_num_t touch_num)

start touch sensor driver

参数:
  • dev[in] Pointer to the touch sensor device structure.

  • touch_num[in] Touch sensor number [0, WM_TOUCH_NUM_MAX].

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_touch_sensor_stop(wm_device_t *dev, wm_touch_sensor_num_t touch_num)

stop touch sensor driver

参数:
  • dev[in] Pointer to the touch sensor device structure.

  • touch_num[in] Touch sensor number [0, WM_TOUCH_NUM_MAX].

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

wm_device_t *wm_drv_touch_sensor_init(const char *dev_name)

Initialize touch sensor driver.

参数:

dev_name[in] touch sensor device name

返回:

  • NULL: failed

  • others: succeed

int wm_drv_touch_sensor_deinit(wm_device_t *dev)

deinit touch sensor driver

参数:

dev[in] touch sensor driver device

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

Touch Button

enum wm_drv_touch_button_state_t

Values:

enumerator WM_DRV_TOUCH_BUTTON_PRESS

touch key press event

enumerator WM_DRV_TOUCH_BUTTON_RELEASE

touch key release event

enumerator WM_DRV_TOUCH_BUTTON_PRESSED

touch key short pressed event

enumerator WM_DRV_TOUCH_BUTTON_LONG_PRESSED

touch key long pressed event

typedef void (*wm_drv_touch_button_callback_t)(wm_touch_sensor_num_t touch_num, wm_drv_touch_button_state_t state, void *priv)

Prototype touch button callback function.

int wm_drv_touch_button_register_callback(wm_device_t *dev, wm_drv_touch_button_callback_t callback, void *priv)

Touch button register callback.

This function sets a callback routine into touch button, when the subscribed events occur, the callback routine will be called.

警告

Must be used before start api, since this event callback routine runs on driver core, it should not do something that attempts to Block, such as calling vTaskDelay().

参数:
  • dev[in] Touch button device

  • callback[in] Event callback

  • priv[in] User private pointer

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_touch_button_set_longpress(wm_device_t *dev, uint32_t threshold_time)

Touch button set long press trigger time.

This function sets the threshold time (ms) for a long press event. If a button is pressed and held for a period of time that exceeds the threshold time, a long press event is triggered. Default long press time 1000 ms.

参数:
  • dev[in] Touch button device

  • threshold_time[in] Threshold time (ms) of long press event occur, Min 1000.

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_touch_button_start(wm_device_t *dev)

start touch button

参数:

dev[in] Pointer to the touch button device structure.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_touch_button_stop(wm_device_t *dev)

stop touch button

参数:

dev[in] Pointer to the touch button device structure.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

wm_device_t *wm_drv_touch_button_init(const char *dev_name)

Initialize touch button.

参数:

dev_name[in] touch button device name

返回:

  • NULL: failed

  • others: succeed

int wm_drv_touch_button_deinit(wm_device_t *dev)

Deinitialize touch button.

参数:

dev[in] touch button device

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed