# lv_circle_buf_private.h (/api/private/misc/lv_circle_buf_private_h)



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

Functions [#functions]

<ApiMember kind="function" name="lv_circle_buf_create" file="private/misc/lv_circle_buf_private.h" line="42" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L42">
  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`     | `uint32_t` | the maximum number of elements in the buffer |
  | `element_size` | `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="private/misc/lv_circle_buf_private.h" line="51" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L51">
  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`     | `uint32_t` | the maximum number of elements in the buffer |
  | `element_size` | `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="private/misc/lv_circle_buf_private.h" line="58" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L58">
  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="private/misc/lv_circle_buf_private.h" line="66" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L66">
  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`   | `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="private/misc/lv_circle_buf_private.h" line="72" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L72">
  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="private/misc/lv_circle_buf_private.h" line="79" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L79">
  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:** `uint32_t` — the number of elements in the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_capacity" file="private/misc/lv_circle_buf_private.h" line="86" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L86">
  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:** `uint32_t` — the maximum number of elements in the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_remain" file="private/misc/lv_circle_buf_private.h" line="93" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L93">
  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:** `uint32_t` — the number of elements that can be written to the buffer
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_is_empty" file="private/misc/lv_circle_buf_private.h" line="100" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L100">
  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:** `bool` — true: the buffer is empty; false: the buffer is not empty
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_is_full" file="private/misc/lv_circle_buf_private.h" line="107" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L107">
  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:** `bool` — true: the buffer is full; false: the buffer is not full
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_reset" file="private/misc/lv_circle_buf_private.h" line="113" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L113">
  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="private/misc/lv_circle_buf_private.h" line="121" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L121">
  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

  <Callout type="info">
    The capacity of the buffer must be greater than 0.
  </Callout>
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_tail" file="private/misc/lv_circle_buf_private.h" line="129" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L129">
  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

  <Callout type="info">
    The capacity of the buffer must be greater than 0.
  </Callout>
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_read" file="private/misc/lv_circle_buf_private.h" line="137" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L137">
  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="private/misc/lv_circle_buf_private.h" line="145" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L145">
  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="private/misc/lv_circle_buf_private.h" line="155" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L155">
  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`      | `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:** `uint32_t` — the number of values filled
</ApiMember>

<ApiMember kind="function" name="lv_circle_buf_skip" file="private/misc/lv_circle_buf_private.h" line="163" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L163">
  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="private/misc/lv_circle_buf_private.h" line="171" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L171">
  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="private/misc/lv_circle_buf_private.h" line="181" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L181">
  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`      | `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

  <Callout type="info">
    The size of the buffer must be greater than 0.
  </Callout>
</ApiMember>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_circle_buf_t" file="private/misc/lv_circle_buf_private.h" line="29" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L29">
  lv_circle_buf_t [#lv_circle_buf_t]

  ```c title=" " lineNumbers=1
  typedef struct _lv_circle_buf_t lv_circle_buf_t
  ```
</ApiMember>

<TypeUsedBy name="lv_circle_buf_t" count="16">
  * `lv_circle_buf_resize` — param `circle_buf`
  * `lv_circle_buf_destroy` — param `circle_buf`
  * `lv_circle_buf_size` — param `circle_buf`
  * `lv_circle_buf_capacity` — param `circle_buf`
  * `lv_circle_buf_remain` — param `circle_buf`
  * `lv_circle_buf_is_empty` — param `circle_buf`
  * `lv_circle_buf_is_full` — param `circle_buf`
  * `lv_circle_buf_reset` — param `circle_buf`
  * `lv_circle_buf_head` — param `circle_buf`
  * `lv_circle_buf_tail` — param `circle_buf`
  * `lv_circle_buf_read` — param `circle_buf`
  * `lv_circle_buf_write` — param `circle_buf`
  * `lv_circle_buf_fill` — param `circle_buf`
  * `lv_circle_buf_skip` — param `circle_buf`
  * `lv_circle_buf_peek` — param `circle_buf`
  * `lv_circle_buf_peek_at` — param `circle_buf`
</TypeUsedBy>

<ApiMember kind="typedef" name="lv_circle_buf_fill_cb_t" file="private/misc/lv_circle_buf_private.h" line="30" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_circle_buf_private.h#L30">
  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;lvgl_public.h&#x22;, &#x22;lv_array.h&#x22;]" includedBy="[&#x22;lvgl_private.h&#x22;]" />
