Skip to content

Hello Word

Use the official LVGL library show Display characters on the screen.

import lvgl as lv

# App Name
NAME = "Hello World"

# LVGL widgets
scr = None

# LVGL widgets
label = None

counter = 0

async def on_running_foreground():
    # Once this App becomes ACTIVE, called by system approx. every 200ms
    global counter
    counter += 1
    label.set_text('Hello World ' + str(counter))


async def on_stop():
    # User triggered to leave this App. This App is no longer visible. all function should be deactivated
    # This App becomes STOPPED state
    global scr
    print('on stop')
    if scr:
        scr.clean()
        del scr
        scr = None


async def on_start():
    # User triggered to enter this App for the first time, or from STOPPED state, all function should be initialed
    # Then, this App becomes STARTED state
    global scr, label
    print('on start')
    # Create the LVGL widgets.
    scr = lv.obj()

    # Create the LVGL widgets.
    label = lv.label(scr)
    label.center()
    label.set_text('Hello World')

    # Load the LVGL widgets.
    lv.scr_load(scr)