Skip to content

Commit

Permalink
Merge branch 'arch/drivers'
Browse files Browse the repository at this point in the history
  • Loading branch information
amirgon committed Mar 10, 2023
2 parents f7dc04f + 23b04c3 commit cd1a217
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,34 +120,22 @@ import lvgl as lv
lv.init()
```

Then display driver and input driver needs to be registered.
Then event loop, display driver and input driver needs to be registered.
Refer to [Porting the library](https://docs.lvgl.io/8.0/porting/index.html) for more information.
Here is an example of registering SDL drivers on Micropython unix port:

```python
import SDL
SDL.init()

# Register SDL display driver.

draw_buf = lv.disp_draw_buf_t()
buf1_1 = bytearray(480*10)
draw_buf.init(buf1_1, None, len(buf1_1)//4)
disp_drv = lv.disp_drv_t()
disp_drv.init()
disp_drv.draw_buf = draw_buf
disp_drv.flush_cb = SDL.monitor_flush
disp_drv.hor_res = 480
disp_drv.ver_res = 320
disp_drv.register()

# Regsiter SDL mouse driver

indev_drv = lv.indev_drv_t()
indev_drv.init()
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = SDL.mouse_read
indev_drv.register()
# Create an event loop and Register SDL display/mouse/keyboard drivers.
from lv_utils import event_loop

WIDTH = 480
HEIGHT = 320

event_loop = event_loop()
disp_drv = lv.sdl_window_create(WIDTH, HEIGHT)
mouse = lv.sdl_mouse_create()
keyboard = lv.sdl_keyboard_create()
keyboard.set_group(self.group)
```

Here is an alternative example, for registering ILI9341 drivers on Micropython ESP32 port:
Expand Down
22 changes: 12 additions & 10 deletions ports/unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ else
# Use gcc syntax for map file
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
endif
LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) -lSDL2
LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)

# Flags to link with pthread library
LIBPTHREAD = -lpthread
Expand Down Expand Up @@ -219,6 +219,17 @@ endif

# Additional optional libraries

ifneq ($(UNAME_S),Darwin)
CFLAGS_MOD += -DMICROPY_FB=1
endif

SDL_CFLAGS_MOD := $(shell pkg-config --silence-errors --cflags sdl2)
SDL_LDFLAGS_MOD := $(shell pkg-config --silence-errors --libs sdl2)
ifneq ($(SDL_LDFLAGS_MOD),)
CFLAGS_MOD += $(SDL_CFLAGS_MOD) -DMICROPY_SDL=1
LDFLAGS_MOD += $(SDL_LDFLAGS_MOD)
endif

RLOTTIE_CFLAGS_MOD := $(shell pkg-config --silence-errors --cflags rlottie)
RLOTTIE_LDFLAGS_MOD := $(shell pkg-config --silence-errors --libs rlottie)
ifneq ($(RLOTTIE_LDFLAGS_MOD),)
Expand Down Expand Up @@ -262,9 +273,6 @@ SRC_C += \
$(wildcard $(VARIANT_DIR)/*.c)

LIB_SRC_C += $(addprefix lib/,\
lv_bindings/driver/SDL/sdl_common.c \
lv_bindings/driver/SDL/sdl.c \
lv_bindings/driver/SDL/modSDL.c \
$(LIB_SRC_C_EXTRA) \
)

Expand All @@ -274,12 +282,6 @@ SHARED_SRC_C += $(addprefix shared/,\
$(SHARED_SRC_C_EXTRA) \
)

ifneq ($(UNAME_S),Darwin)
LIB_SRC_C += $(addprefix lib/,\
lv_bindings/driver/linux/modfb.c \
)
endif

SRC_CXX += \
$(SRC_MOD_CXX)

Expand Down

0 comments on commit cd1a217

Please sign in to comment.