---
title: "LVGL: Hello world"
canonical_url: https://developer.repebble.com/pebbleos/docs/samples/third_party/lvgl/hello_world/
last_updated: 2026-11-21
sdk_version: 4.44
---
# LVGL: Hello world

Source: https://developer.repebble.com/pebbleos/docs/samples/third_party/lvgl/hello_world/

This sample starts [LVGL](https://developer.repebble.com/pebbleos/docs/third_party/lvgl.md) on the display with `pbl_lvgl_init()`, puts a label and a spinner on the active screen and renders them for 5 seconds. Its loop is the whole of what LVGL needs to run: `lv_timer_handler()` renders what changed and returns how long it can wait until it is called again.

Watch the screen, on a watch or in the emulator’s window.

Run:

`pbl samples samples/third_party/lvgl/hello_world`

Boards:

every board

## Sources

src/main.c

```
#include \<stdio.h\>#include \<pbl/kernel/delay.h\>#include \<pbl/kernel/time.h\>#include \<pbl\_lvgl.h\>#define SHOW\_MS 5000int main(void) {lv\_obj\_t \*label;lv\_obj\_t \*spinner;uint64\_t end;int ret;ret = pbl\_lvgl\_init();if (ret != 0) {fprintf(stderr, "lvgl: init failed (%d)\n", ret);return ret;}label = lv\_label\_create(lv\_screen\_active());lv\_label\_set\_text(label, "Hello World!\n" CONFIG\_BOARD);lv\_obj\_set\_style\_text\_align(label, LV\_TEXT\_ALIGN\_CENTER, 0);lv\_obj\_align(label, LV\_ALIGN\_CENTER, 0, -40);/\* An animation, so that there is something to render on every pass. \*/spinner = lv\_spinner\_create(lv\_screen\_active());lv\_obj\_set\_size(spinner, 60, 60);lv\_obj\_align(spinner, LV\_ALIGN\_CENTER, 0, 30);printf("lvgl: %d.%d.%d, showing for %d s\n", lv\_version\_major(), lv\_version\_minor(),lv\_version\_patch(), SHOW\_MS / 1000);/\* LVGL does its work in lv\_timer\_handler(), which says when it is next due. \*/end = pbl\_uptime\_ms() + SHOW\_MS;while (pbl\_uptime\_ms() \< end) {pbl\_sleep\_ms(lv\_timer\_handler());}printf("Sample done\n");return 0;}
```

## Output

```
lvgl: \d+\.\d+\.\d+, showing for 5 s
Sample done
```

Generated from PebbleOS [4bbc630fa](https://github.com/coredevices/pebbleos/commit/4bbc630fa451369e352c06b8276c7fe37c67f4fd). This page is maintained in the pebbleos repository: [docs/samples/third\_party/lvgl/hello\_world.md](https://github.com/coredevices/pebbleos/blob/4bbc630fa451369e352c06b8276c7fe37c67f4fd/docs/samples/third_party/lvgl/hello_world.md).
