API Reference
The field-by-field reference for LVGL Safe v0.1.0 - the rules every widget follows, the defaults each one starts from, and the error codes every function returns.
The field-by-field reference for LVGL Safe v0.1.0. For the concepts behind it - the widget lifecycle, rendering, colors, input - start with How it works; to build and run an application, see Build and run.
Three rules hold for every widget in this reference:
ls_widget_common_tis always the first member, namedcommon.- You configure a widget by assigning its fields directly, after
ls_<widget>_create(). There are no setters or getters, andcreateoverwrites the struct, so it must come first. createleaves the widget in a visible state - opaque, with a placeholder color - so in practice you only have to set geometry and content. The two exceptions are listed under Defaults aftercreate.
Widgets
Core types
Rectangle
Label
Button
Image
Image button
Arc
Defaults after create
All sizes and positions start at 0, and focus_index at UINT32_MAX (never
focused). Beyond that:
| Widget | Defaults |
|---|---|
ls_rectangle_t | #cccccc fill, opaque; black border of width 0 (no border) |
ls_label_t | black text, opaque, left-aligned, letter_space 1, no font |
ls_button_t | #666666 and opaque in all five unchecked states; the five checked states are fully transparent |
ls_image_t | opaque, no rotation, black a8_color, src is NULL |
ls_image_button_t | all ten sources are NULL |
ls_arc_t | blue, opaque, center 30,30, radius 30, thickness 5, sweeping 30°→90° |
The NULL ones are not silent: a label without a font, an image without a src, or
an image button whose current state has no source makes ls_render() return
LS_ERROR_CODE_INVALID_CONFIGURATION for the whole frame. A widget that draws
nothing without an error is one that is hidden, still sized 0, or a
checked button state that was never given a color and opacity.
Error handling
Every public function returns an ls_error_code_t
(ls_error_codes.h) - check it at the call site:
| Code | Value | Meaning |
|---|---|---|
LS_ERROR_CODE_OK | 0 | Success |
LS_ERROR_CODE_INTERNAL_ERROR | 1 | Unexpected internal failure |
LS_ERROR_CODE_INVALID_ARGUMENT | 2 | NULL / out-of-range argument |
LS_ERROR_CODE_INVALID_CONFIGURATION | 3 | Inconsistent configuration |
LS_ERROR_CODE_MEMORY_CORRUPTION | 4 | Inconsistent internal data |
LS_ERROR_CODE_RENDER_FAILED | 5 | Rendering failed |
Not a widget, but part of the API
| Header | What it gives you |
|---|---|
| ls_color.h | ls_color_t, LS_COLOR_MAKE, LS_COLOR_HEX, ls_color_to_u16(), LS_BYTE_PER_PIXEL |
| ls_render.h | ls_render(), ls_render_clear_frame_buffer(), ls_render_goto_frame_buffer_px(), LS_OPA_COVER |
| ls_input.h | ls_indev_process(), input states, event types, callback typedefs |
| ls_font.h | ls_font_t - a generated glyph-bitmap font descriptor |
| ls_translation.h | ls_translation_init(), ls_translation_set_language(), ls_translation_get() |
| ls_math.h | ls_sin(), ls_cos() - integer trig, so no libm dependency |
| ls_conf.h | Compile-time feature switches. Do not edit in the preview - its values are already baked into the shipped library |
Last updated on
Assets
Fonts, images, and translations. Everything a widget draws is converted ahead of time and compiled in - nothing is loaded or decoded at runtime.
Core Types
The three types every LVGL Safe program uses - the widget header every widget embeds, the display that owns the framebuffer, and the screen that owns the widget list.