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

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

  • element_size -- the size of an element in bytes

Returns:

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

Parameters:
  • buf -- pointer to a buffer

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

  • element_size -- the size of an element in bytes

Returns:

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

Parameters:

array -- pointer to an array

Returns:

pointer to the created buffer

lv_result_t lv_circle_buf_resize(lv_circle_buf_t *circle_buf, uint32_t capacity)

Resize the buffer

Parameters:
  • circle_buf -- pointer to a buffer

  • capacity -- the new capacity of the buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

uint32_t lv_circle_buf_size(const lv_circle_buf_t *circle_buf)

Get the size of the buffer

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:
  • circle_buf -- pointer to buffer

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

Returns:

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

Parameters:
  • circle_buf -- pointer to buffer

  • data -- pointer to the value to write

Returns:

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

Parameters:
  • circle_buf -- pointer to buffer

  • count -- the number of values to fill

  • fill_cb -- the callback function to fill the buffer

  • user_data --

Returns:

the number of values filled

lv_result_t lv_circle_buf_skip(lv_circle_buf_t *circle_buf)

Skip a value

Parameters:

circle_buf -- pointer to buffer

Returns:

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

Parameters:
  • circle_buf -- pointer to buffer

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

Returns:

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

Parameters:
  • 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

Returns:

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