Skip to content

Instantly share code, notes, and snippets.

import lvgl as lv
import SDL
w = 800
h = 600
lv.init()
SDL.init(w=w,h=h)
@amirgon
amirgon / lvgl_heb_test1.py
Created December 17, 2019 22:37
LittlevGL test for Hebrew font and Bidi algorithm
# Helper function to set fonts
def set_font(obj, font = lv.font_heb_16):
if type(obj) == lv.style_t:
obj.text.font = font
else:
for style_type_str in dir(obj.STYLE):
if not style_type_str.startswith('_'):
style_type = getattr(obj.STYLE, style_type_str)
style = obj.get_style(style_type)
@amirgon
amirgon / lvgl_hello_world.py
Created December 17, 2019 19:52
Hello World LittlevGL (assumes drivers are loaded and lv.init() was called)
scr = lv.obj()
btn = lv.btn(scr)
btn.align(scr, lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text('Hello World!')
lv.scr_load(scr)
@amirgon
amirgon / init_lv_mp_js.py
Last active December 17, 2019 19:47
Initialization code for LittlevGL Micropython JavaScript simulator
import imp, sys
sys.path.append('https://raw.githubusercontent.com/littlevgl/lv_binding_micropython/master/lib')
import display_driver
import lvgl as lv
lv.init()
@amirgon
amirgon / loader_arc.py
Last active November 20, 2019 23:04
An example of loader arc, shows usage of tasks and OO
import display_driver
import lvgl as lv
# Create an arc which acts as a loader.
class loader_arc(lv.arc):
def __init__(self, parent, color = lv.color_hex(0x000080), width = 8, style = lv.style_plain, rate = 20):
super().__init__(parent)
@amirgon
amirgon / test_heb_font.py
Created November 12, 2019 07:06
Test script for Bidirectional support on lvgl
import lvgl as lv
lv.init()
import SDL
SDL.init()
# Register SDL display driver.
disp_buf1 = lv.disp_buf_t()
buf1_1 = bytearray(480*10)
@amirgon
amirgon / MPDBUS_README.md
Last active October 15, 2019 20:46
DBus Micropython Module

Example of converting dbus.h to Micropython module.

Command line:

python ~/esp/projects/lv_mpy/lib/lv_bindings/gen/gen_mpy.py -M dbus -MD dbusmod.json -I~/esp/projects/lv_mpy/lib/lv_bindings/pycparser/utils/fake_libc_include -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ dbus_pp.h > dbusmod.c
def init_drv():
import SDL
SDL.init()
# Register SDL display driver.
disp_buf1 = lv.disp_buf_t()
buf1_1 = bytes(480*10)
lv.disp_buf_init(disp_buf1,buf1_1, None, len(buf1_1)//4)
disp_drv = lv.disp_drv_t()

Parsing stack trace

xtensa-esp32-elf-addr2line -aipfC -e ports/esp32/build/application.elf <stack-trace (pairs of hex:hex)
# init
import lvgl as lv
lv.init()
import SDL
SDL.init()
# Register SDL display driver.