Skip to content

Commit 67c953a

Browse files
committed
Updates for new driver API
1 parent fd21cf3 commit 67c953a

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

README.md

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,34 +120,22 @@ import lvgl as lv
120120
lv.init()
121121
```
122122

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

127127
```python
128-
import SDL
129-
SDL.init()
130-
131-
# Register SDL display driver.
132-
133-
draw_buf = lv.disp_draw_buf_t()
134-
buf1_1 = bytearray(480*10)
135-
draw_buf.init(buf1_1, None, len(buf1_1)//4)
136-
disp_drv = lv.disp_drv_t()
137-
disp_drv.init()
138-
disp_drv.draw_buf = draw_buf
139-
disp_drv.flush_cb = SDL.monitor_flush
140-
disp_drv.hor_res = 480
141-
disp_drv.ver_res = 320
142-
disp_drv.register()
143-
144-
# Regsiter SDL mouse driver
145-
146-
indev_drv = lv.indev_drv_t()
147-
indev_drv.init()
148-
indev_drv.type = lv.INDEV_TYPE.POINTER
149-
indev_drv.read_cb = SDL.mouse_read
150-
indev_drv.register()
128+
# Create an event loop and Register SDL display/mouse/keyboard drivers.
129+
from lv_utils import event_loop
130+
131+
WIDTH = 480
132+
HEIGHT = 320
133+
134+
event_loop = event_loop()
135+
disp_drv = lv.sdl_window_create(WIDTH, HEIGHT)
136+
mouse = lv.sdl_mouse_create()
137+
keyboard = lv.sdl_keyboard_create()
138+
keyboard.set_group(self.group)
151139
```
152140

153141
Here is an alternative example, for registering ILI9341 drivers on Micropython ESP32 port:

0 commit comments

Comments
 (0)