Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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)
import lvgl as lv
import SDL
w = 800
h = 600
lv.init()
SDL.init(w=w,h=h)
@amirgon
amirgon / lv_sim_init.py
Created February 16, 2020 22:25
initialization script for micropython lvgl simulator. Loads display driver.
import imp, sys
sys.path.append('https://raw.githubusercontent.com/littlevgl/lv_binding_micropython/master/lib')
import display_driver
import lvgl as lv
@amirgon
amirgon / inspect.py
Created May 13, 2020 22:54
Micropython module inspection
from types import ModuleType
def inspect(t, name=None, nesting=0):
if not (name or hasattr(t, "__name__")): return
print("| "*nesting + (name if name else t.__name__))
if isinstance(t, int) or isinstance(t, str): return
if t is type or isinstance(lv, ModuleType):
for x in dir(t):
if not x.startswith("__"):
inspect(getattr(t,x), name=x, nesting = nesting + 1)
@amirgon
amirgon / lvgl7_micropython_api_tree.txt
Created May 13, 2020 22:56
lvgl dev-7 micropython API tree printed with inspect.py
lvgl
| list
| | remove
| | PART
| | | ALL
| | | MAIN
| | add_btn
| | add_protect
| | add_state
| | add_style