lv_circle_buf.h

Typedefs

typedef bool (*lv_circle_buf_fill_cb_t)(void *buf, uint32_t buff_len, int32_t index, void *user_data)

Functions

lv_circle_buf_t *lv_circle_buf_create(uint32_t capacity, uint32_t element_size)

Create a circle buffer

参数:
  • capacity -- the maximum number of elements in the buffer

  • element_size -- the size of an element in bytes

返回:

pointer to the created buffer

lv_circle_buf_t *lv_circle_buf_create_from_buf(void *buf, uint32_t capacity, uint32_t element_size)

Create a circle buffer from an existing buffer

参数:
  • buf -- pointer to a buffer

  • capacity -- the maximum number of elements in the buffer

  • element_size -- the size of an element in bytes

返回:

pointer to the created buffer

lv_circle_buf_t *lv_circle_buf_create_from_array(const lv_array_t *array)

Create a circle buffer from an existing array

参数:

array -- pointer to an array

返回:

pointer to the created buffer

lv_result_t lv_circle_buf_resize(lv_circle_buf_t *circle_buf, uint32_t capacity)

Resize the buffer

参数:
  • circle_buf -- pointer to a buffer

  • capacity -- the new capacity of the buffer

返回:

LV_RESULT_OK: the buffer is resized; LV_RESULT_INVALID: the buffer is not resized

void lv_circle_buf_destroy(lv_circle_buf_t *circle_buf)

Destroy a circle buffer

参数:

circle_buf -- pointer to buffer

uint32_t lv_circle_buf_size(const lv_circle_buf_t *circle_buf)

Get the size of the buffer

参数:

circle_buf -- pointer to buffer

返回:

the number of elements in the buffer

uint32_t lv_circle_buf_capacity(const lv_circle_buf_t *circle_buf)

Get the capacity of the buffer

参数:

circle_buf -- pointer to buffer

返回:

the maximum number of elements in the buffer

uint32_t lv_circle_buf_remain(const lv_circle_buf_t *circle_buf)

Get the remaining space in the buffer

参数:

circle_buf -- pointer to buffer

返回:

the number of elements that can be written to the buffer

bool lv_circle_buf_is_empty(const lv_circle_buf_t *circle_buf)

Check if the buffer is empty

参数:

circle_buf -- pointer to buffer

返回:

true: the buffer is empty; false: the buffer is not empty

bool lv_circle_buf_is_full(const lv_circle_buf_t *circle_buf)

Check if the buffer is full

参数:

circle_buf -- pointer to buffer

返回:

true: the buffer is full; false: the buffer is not full

void lv_circle_buf_reset(lv_circle_buf_t *circle_buf)

Reset the buffer

参数:

circle_buf -- pointer to buffer

返回:

LV_RESULT_OK: the buffer is reset; LV_RESULT_INVALID: the buffer is not reset

void *lv_circle_buf_head(const lv_circle_buf_t *circle_buf)

Get the head of the buffer

参数:

circle_buf -- pointer to buffer

返回:

pointer to the head of the buffer

void *lv_circle_buf_tail(const lv_circle_buf_t *circle_buf)

Get the tail of the buffer

参数:

circle_buf -- pointer to buffer

返回:

pointer to the tail of the buffer

lv_result_t lv_circle_buf_read(lv_circle_buf_t *circle_buf, void *data)

Read a value

参数:
  • circle_buf -- pointer to buffer

  • data -- pointer to a variable to store the read value

返回:

LV_RESULT_OK: the value is read; LV_RESULT_INVALID: the value is not read

lv_result_t lv_circle_buf_write(lv_circle_buf_t *circle_buf, const void *data)

Write a value

参数:
  • circle_buf -- pointer to buffer

  • data -- pointer to the value to write

返回:

LV_RESULT_OK: the value is written; LV_RESULT_INVALID: the value is not written

uint32_t lv_circle_buf_fill(lv_circle_buf_t *circle_buf, uint32_t count, lv_circle_buf_fill_cb_t fill_cb, void *user_data)

Fill the buffer with values

参数:
  • circle_buf -- pointer to buffer

  • count -- the number of values to fill

  • fill_cb -- the callback function to fill the buffer

  • user_data --

返回:

the number of values filled

lv_result_t lv_circle_buf_skip(lv_circle_buf_t *circle_buf)

Skip a value

参数:

circle_buf -- pointer to buffer

返回:

LV_RESULT_OK: the value is skipped; LV_RESULT_INVALID: the value is not skipped

lv_result_t lv_circle_buf_peek(const lv_circle_buf_t *circle_buf, void *data)

Peek a value

参数:
  • circle_buf -- pointer to buffer

  • data -- pointer to a variable to store the peeked value

返回:

LV_RESULT_OK: the value is peeked; LV_RESULT_INVALID: the value is not peeked

lv_result_t lv_circle_buf_peek_at(const lv_circle_buf_t *circle_buf, uint32_t index, void *data)

Peek a value at an index

参数:
  • circle_buf -- pointer to buffer

  • index -- the index of the value to peek, if the index is greater than the size of the buffer, it will return looply.

  • data -- pointer to a variable to store the peeked value

返回:

LV_RESULT_OK: the value is peeked; LV_RESULT_INVALID: the value is not peeked