Adding Unix project

main
Drew Bednar
parent 3c199df906
commit c57e16dce7

@ -0,0 +1,2 @@
micropython
SDLPointer_2

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

@ -1,3 +1,39 @@
# Project 0
The is simply an example file used for testing the OS based lvgl micropython builds (unix, macOS). At present the MacOS build.
This folder is actually dedicated to LVGL running on Unix. Unfortunately, the matrix of hardware, lib versions etc is so great that you can't really make this binary portable across multiple linux versions. You have to build from source. I do have a copy of a unix LVGL Python stored in the `./builds` dir though build for Ubuntu LTS 24.04. You can always try your luck there, but I expect you will still need to build from source.By convention I include the a short sha of the commit from https://github.com/lvgl-micropython/lvgl_micropython that I built this off of.
The demos contained here are mostly just ports of the demos found in official LVGL docs
## Usage
If all is going to plan you should be able to
```
cd ./project0
cp ./builds/<unix upy binary> ./micropython
./micropython
```
Then in the REPL
```
import test_lv
```
Where you should see
![test_lv_screen1](./.img/screen_cap1.png)
Now, you can us lvgl functions to change objects within the display and screen.
```
import lvgl as lv
test_lv.scrn.set_style_bg_color(lv.color_hex(0x573a00), 0)
```
![test_lv_screen2](./.img/screen_cap2.png)
To exit
```
import sys;sys.exit()
```

@ -1,47 +0,0 @@
from micropython import const # NOQA
_WIDTH = const(480)
_HEIGHT = const(320)
_BUFFER_SIZE = _WIDTH * _HEIGHT * 3
import lcd_bus # NOQA
bus = lcd_bus.SDLBus(flags=0)
buf1 = bus.allocate_framebuffer(_BUFFER_SIZE, 0)
buf2 = bus.allocate_framebuffer(_BUFFER_SIZE, 0)
import lvgl as lv # NOQA
import sdl_display # NOQA
lv.init()
display = sdl_display.SDLDisplay(
data_bus=bus,
display_width=_WIDTH,
display_height=_HEIGHT,
frame_buffer1=buf1,
frame_buffer2=buf2,
color_space=lv.COLOR_FORMAT.RGB888,
)
display.init()
import sdl_pointer
mouse = sdl_pointer.SDLPointer()
scrn = lv.screen_active()
scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
slider = lv.slider(scrn)
slider.set_size(300, 25)
slider.center()
import task_handler
# the duration needs to be set to 5 to have a good response from the mouse.
# There is a thread that runs that facilitates double buffering.
th = task_handler.TaskHandler(duration=5)

@ -0,0 +1,72 @@
from micropython import const # NOQA
import display_driver_framework
_WIDTH = const(480)
_HEIGHT = const(320)
_BUFFER_SIZE = _WIDTH * _HEIGHT * 3
import lcd_bus # NOQA
print("Intializing LCD Bus")
bus = lcd_bus.SDLBus(flags=0)
print("Creating buffers")
buf1 = bus.allocate_framebuffer(_BUFFER_SIZE, 0)
buf2 = bus.allocate_framebuffer(_BUFFER_SIZE, 0)
import lvgl as lv # NOQA
import sdl_display # NOQA
print("Initializing LVGL")
lv.init()
print("Creating Display")
display = sdl_display.SDLDisplay(
data_bus=bus,
display_width=480,
display_height=320,
frame_buffer1=buf1,
frame_buffer2=buf2,
color_space=lv.COLOR_FORMAT.RGB888
)
print(display)
print("Initializing display")
display.init()
# print("Adding display to display driver")
# display_driver_framework.DisplayDriver._displays.append(display)
import sdl_pointer
print("Creating SDL pointer")
mouse = sdl_pointer.SDLPointer()
print(mouse)
print("Starting task handler")
import task_handler
th = task_handler.TaskHandler()
print("Activating screen")
scrn = lv.screen_active()
print("Setting screen style")
scrn.set_style_bg_color(lv.color_hex(0x000000), 0)
print("Creating Slider")
slider = lv.slider(scrn)
print("Setting slider size")
slider.set_size(400, 25)
print("Centering slider")
slider.center()
def on_value_changed(_):
print('VALUE_CHANGED:', slider.get_value())
print("Adding callback to slider")
slider.add_event_cb(on_value_changed, lv.EVENT.VALUE_CHANGED, None)
# import time
# while True:
# lv.tick_inc(5)
# lv.timer_handler()
# time.sleep_ms(5)
Loading…
Cancel
Save