python3 make.py unix DISPLAY=sdl_display INDEV=sdl_pointer - how i use sdl ? #350
Replies: 2 comments 3 replies
-
This might be useful. |
Beta Was this translation helpful? Give feedback.
-
I only test the compiling and not the actual running of the binding. The problems that occur are almost always found during the compiling process. I am able to compile for different boards without having the actual hardware. When using the unix (posix) or macOS ports there is a different driver that is used to get the buffers to render to the screen. Most other things in the binding are going to function the same as if you were running on an MCU except for hardware related things that get omitted because of the hardware not being available. For the purposes of UI development the missing hardware drivers are able to be created by the user for purposes of testing if needed... Because the display drivers and the input drivers share a common API even in the unix and macos ports this allows code that is written by the user to also be used on a MCU without the need to make any changes. Here is a code example... import sys
import lcd_bus
try:
from micropython import const
except ImportError:
def const(x):
return x
_WIDTH = const(480)
_HEIGHT = const(320)
if sys.platform in ('linux', 'darwin'):
from sdl_display import SDLDisplay as display_driver
from sdl_pointer import SDLPointer as input_driver
_BL_PIN = None
_RST_PIN = None
display_bus = lcd_bus.SDLBus(flags=lcd_bus.SDLBus.WINDOW_BORDERLESS)
input_device = None
else:
from i2c import I2C
from st7796 import ST7796 as display_driver
import ft6x36
import machine
_SCL = const(8)
_SDA = const(9)
_DC = const(7)
_MOSI = const(12)
_MISO = const(13)
_SCK = const(14)
_FREQ = const(80000000)
_HOST = const(1)
_BL_PIN = const(6)
_RST_PIN = const(5)
input_driver = ft6x36.FT6x36
input_bus = I2C.Bus(host=1, sda=_SDA, scl=_SCL)
input_device = I2C.Device(bus=input_bus, dev_id=ft6x36.I2C_ADDR, reg_bits=ft6x36.BITS)
spi_bus = machine.SPI.Bus(host=_HOST, mosi=_MOSI, miso=_MISO, sck=_SCK)
display_bus = lcd_bus.SPIBus(spi_bus=spi_bus, cs=-1, freq=_FREQ, dc=_DC)
display = display_driver(display_bus, _WIDTH, _HEIGHT, backlight_pin=_BL_PIN, reset_pin=_RST_PIN)
display.init()
indev = input_driver(input_device)
import task_handler
import lvgl as lv
scrn = lv.screen_active()
slider = lv.slider(scrn)
slider.center()
display.set_backlight(100)
th = task_handler.TaskHandler() You would place that code into a file named |
Beta Was this translation helpful? Give feedback.
-
Hello,
i successful build the unix port micropython lvgl binding.
how i can connect now with an sdl display?
is there an visual simulation of the display, like this here:
https://github.com/Ryzee119/lvgl-sdl
//edit: i build the binary file with wsl (ubuntu subsystem in windows). So - is it possible, to run the micropython on the wsl ubuntu and the simulated display on windows? when yes, how i do it? when no, is it possible to build an docker container with everything?
@kdschlosser do you develope whole project in an virtual enviroment too? - because i not think, that you testing all microcontrollers with all displays ?
Beta Was this translation helpful? Give feedback.
All reactions