# lv_circle_buf.h (/api/misc/lv_circle_buf_h)



<ApiSummary functions="19" typedefs="1" />

Functions [#functions]

<ApiMember kind="function" name="lv_circle_buf_create" file="misc/lv_circle_buf.h" line="40" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L40">
  lv_circle_buf_create [#lv_circle_buf_create]

  Create a circle buffer

  ```c title=" " lineNumbers=1
  lv_circle_buf_t * lv_circle_buf_create(uint32_t capacity, uint32_t element_size)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name           | Type                        | Description                                  |
  | -------------- | --------------------------- | -------------------------------------------- |
  | `capacity`     | <ApiLink name="uint32_t" /> | the maximum number of elements in the buffer |
  | `element_size` | <ApiLink name="uint32_t" /> | the size of an element in bytes              |

  **Returns:** <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> — pointer to the created buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_create_from_buf" file="misc/lv_circle_buf.h" line="49" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L49">
  lv_circle_buf_create_from_buf [#lv_circle_buf_create_from_buf]

  Create a circle buffer from an existing buffer

  ```c title=" " lineNumbers=1
  lv_circle_buf_t * lv_circle_buf_create_from_buf(void *buf, uint32_t capacity, uint32_t element_size)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name           | Type                        | Description                                  |
  | -------------- | --------------------------- | -------------------------------------------- |
  | `buf`          | `void *`                    | pointer to a buffer                          |
  | `capacity`     | <ApiLink name="uint32_t" /> | the maximum number of elements in the buffer |
  | `element_size` | <ApiLink name="uint32_t" /> | the size of an element in bytes              |

  **Returns:** <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> — pointer to the created buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_create_from_array" file="misc/lv_circle_buf.h" line="56" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L56">
  lv_circle_buf_create_from_array [#lv_circle_buf_create_from_array]

  Create a circle buffer from an existing array

  ```c title=" " lineNumbers=1
  lv_circle_buf_t * lv_circle_buf_create_from_array(const lv_array_t *array)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name    | Type                                                       | Description         |
  | ------- | ---------------------------------------------------------- | ------------------- |
  | `array` | <ApiLink name="lv_array_t" display="const lv_array_t *" /> | pointer to an array |

  **Returns:** <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> — pointer to the created buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_resize" file="misc/lv_circle_buf.h" line="64" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L64">
  lv_circle_buf_resize [#lv_circle_buf_resize]

  Resize the buffer

  ```c title=" " lineNumbers=1
  lv_result_t lv_circle_buf_resize(lv_circle_buf_t *circle_buf, uint32_t capacity)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description                    |
  | ------------ | -------------------------------------------------------------- | ------------------------------ |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to a buffer            |
  | `capacity`   | <ApiLink name="uint32_t" />                                    | the new capacity of the buffer |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: the buffer is resized; LV\_RESULT\_INVALID: the buffer is not resized
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_destroy" file="misc/lv_circle_buf.h" line="70" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L70">
  lv_circle_buf_destroy [#lv_circle_buf_destroy]

  Destroy a circle buffer

  ```c title=" " lineNumbers=1
  void lv_circle_buf_destroy(lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description       |
  | ------------ | -------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to buffer |
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_size" file="misc/lv_circle_buf.h" line="77" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L77">
  lv_circle_buf_size [#lv_circle_buf_size]

  Get the size of the buffer

  ```c title=" " lineNumbers=1
  uint32_t lv_circle_buf_size(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** <ApiLink name="uint32_t" /> — the number of elements in the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_capacity" file="misc/lv_circle_buf.h" line="84" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L84">
  lv_circle_buf_capacity [#lv_circle_buf_capacity]

  Get the capacity of the buffer

  ```c title=" " lineNumbers=1
  uint32_t lv_circle_buf_capacity(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** <ApiLink name="uint32_t" /> — the maximum number of elements in the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_remain" file="misc/lv_circle_buf.h" line="91" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L91">
  lv_circle_buf_remain [#lv_circle_buf_remain]

  Get the remaining space in the buffer

  ```c title=" " lineNumbers=1
  uint32_t lv_circle_buf_remain(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** <ApiLink name="uint32_t" /> — the number of elements that can be written to the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_is_empty" file="misc/lv_circle_buf.h" line="98" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L98">
  lv_circle_buf_is_empty [#lv_circle_buf_is_empty]

  Check if the buffer is empty

  ```c title=" " lineNumbers=1
  bool lv_circle_buf_is_empty(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** <ApiLink name="bool" /> — true: the buffer is empty; false: the buffer is not empty
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_is_full" file="misc/lv_circle_buf.h" line="105" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L105">
  lv_circle_buf_is_full [#lv_circle_buf_is_full]

  Check if the buffer is full

  ```c title=" " lineNumbers=1
  bool lv_circle_buf_is_full(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** <ApiLink name="bool" /> — true: the buffer is full; false: the buffer is not full
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_reset" file="misc/lv_circle_buf.h" line="112" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L112">
  lv_circle_buf_reset [#lv_circle_buf_reset]

  Reset the buffer

  ```c title=" " lineNumbers=1
  void lv_circle_buf_reset(lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description       |
  | ------------ | -------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to buffer |
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_head" file="misc/lv_circle_buf.h" line="119" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L119">
  lv_circle_buf_head [#lv_circle_buf_head]

  Get the head of the buffer

  ```c title=" " lineNumbers=1
  void * lv_circle_buf_head(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** `void *` — pointer to the head of the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_tail" file="misc/lv_circle_buf.h" line="126" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L126">
  lv_circle_buf_tail [#lv_circle_buf_tail]

  Get the tail of the buffer

  ```c title=" " lineNumbers=1
  void * lv_circle_buf_tail(const lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description       |
  | ------------ | -------------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** `void *` — pointer to the tail of the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_read" file="misc/lv_circle_buf.h" line="134" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L134">
  lv_circle_buf_read [#lv_circle_buf_read]

  Read a value

  ```c title=" " lineNumbers=1
  lv_result_t lv_circle_buf_read(lv_circle_buf_t *circle_buf, void *data)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description                                   |
  | ------------ | -------------------------------------------------------------- | --------------------------------------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to buffer                             |
  | `data`       | `void *`                                                       | pointer to a variable to store the read value |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: the value is read; LV\_RESULT\_INVALID: the value is not read
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_write" file="misc/lv_circle_buf.h" line="142" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L142">
  lv_circle_buf_write [#lv_circle_buf_write]

  Write a value

  ```c title=" " lineNumbers=1
  lv_result_t lv_circle_buf_write(lv_circle_buf_t *circle_buf, const void *data)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description                   |
  | ------------ | -------------------------------------------------------------- | ----------------------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to buffer             |
  | `data`       | `const void *`                                                 | pointer to the value to write |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: the value is written; LV\_RESULT\_INVALID: the value is not written
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_fill" file="misc/lv_circle_buf.h" line="152" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L152">
  lv_circle_buf_fill [#lv_circle_buf_fill]

  Fill the buffer with values

  ```c title=" " lineNumbers=1
  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)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description                              |
  | ------------ | -------------------------------------------------------------- | ---------------------------------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to buffer                        |
  | `count`      | <ApiLink name="uint32_t" />                                    | the number of values to fill             |
  | `fill_cb`    | <ApiLink name="lv_circle_buf_fill_cb_t" />                     | the callback function to fill the buffer |
  | `user_data`  | `void *`                                                       |                                          |

  **Returns:** <ApiLink name="uint32_t" /> — the number of values filled
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_skip" file="misc/lv_circle_buf.h" line="160" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L160">
  lv_circle_buf_skip [#lv_circle_buf_skip]

  Skip a value

  ```c title=" " lineNumbers=1
  lv_result_t lv_circle_buf_skip(lv_circle_buf_t *circle_buf)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                           | Description       |
  | ------------ | -------------------------------------------------------------- | ----------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="lv_circle_buf_t *" /> | pointer to buffer |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: the value is skipped; LV\_RESULT\_INVALID: the value is not skipped
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_peek" file="misc/lv_circle_buf.h" line="168" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L168">
  lv_circle_buf_peek [#lv_circle_buf_peek]

  Peek a value

  ```c title=" " lineNumbers=1
  lv_result_t lv_circle_buf_peek(const lv_circle_buf_t *circle_buf, void *data)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description                                     |
  | ------------ | -------------------------------------------------------------------- | ----------------------------------------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer                               |
  | `data`       | `void *`                                                             | pointer to a variable to store the peeked value |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: the value is peeked; LV\_RESULT\_INVALID: the value is not peeked
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_peek_at" file="misc/lv_circle_buf.h" line="177" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L177">
  lv_circle_buf_peek_at [#lv_circle_buf_peek_at]

  Peek a value at an index

  ```c title=" " lineNumbers=1
  lv_result_t lv_circle_buf_peek_at(const lv_circle_buf_t *circle_buf, uint32_t index, void *data)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name         | Type                                                                 | Description                                                                                                 |
  | ------------ | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
  | `circle_buf` | <ApiLink name="lv_circle_buf_t" display="const lv_circle_buf_t *" /> | pointer to buffer                                                                                           |
  | `index`      | <ApiLink name="uint32_t" />                                          | the index of the value to peek, if the index is greater than the size of the buffer, it will return looply. |
  | `data`       | `void *`                                                             | pointer to a variable to store the peeked value                                                             |

  **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK: the value is peeked; LV\_RESULT\_INVALID: the value is not peeked
</ApiMember>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_circle_buf_fill_cb_t" file="misc/lv_circle_buf.h" line="28" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_circle_buf.h#L28">
  lv_circle_buf_fill_cb_t [#lv_circle_buf_fill_cb_t]

  ```c title=" " lineNumbers=1
  typedef bool(* lv_circle_buf_fill_cb_t) (void *buf, uint32_t buff_len, int32_t index, void *user_data)
  ```
</ApiMember>

<TypeUsedBy name="lv_circle_buf_fill_cb_t" count="1">
  * `lv_circle_buf_fill` — param `fill_cb`
</TypeUsedBy>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_types.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;]" />
