lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
250 stars 161 forks source link

LVGL and BLE on ESP32 #109

Closed lixas closed 3 years ago

lixas commented 3 years ago

Hello

I have an issue, that i can not use BLE in my LVGL micropython application. As and example i took advanced demo application as my starting point, for slightly modified ILI9341 and XPT2046. Built an UI that i like, and then i tried to implement BLE scanning functionality. And i failed at this point...

I was able to narrow down my issue to bare minimum:

import ubluetooth
import lvesp32          # <-- This breaks BLE scanner irq

def bt_irq(event, data):
    print(event, data)

ble = ubluetooth.BLE()
ble.active(True)
ble.irq(handler=bt_irq)
ble.gap_scan(0, 30000, 30000)

if lvesp32 is commented out- everything works as expected and i do see BLE advertisement packets. If i import lvesp32 later, when my BLE scanner is running- it stops like in second or so and no more data is shown. Importing lvesp32 is enough to kill/hang/stop BLE scanning process.

What I do need in my final application is read BLE advertisements packets, extract data and show in on LVGL interface on ILI9341 display.

I built firmware on my own computer for generic ESP32 (no external PSRAM) MicroPython v1.9.4-2805-g46e9073b2 on 2020-09-01; ESP32 module with ESP32

amirgon commented 3 years ago

Hi @lixas !

Please see related threads on forums:

The lvesp32 job is to call lv_tick_inc and lv_task_handler periodically, and it does it by creating a timer (xTimerCreate) and scheduling a task for Micropython. For some reason this approach does not work well with BLE, I'm not sure why.

Possible workarounds are:

lixas commented 3 years ago

Thanks you for suggestions I'll share outcome of my tests so far: Parameter =2 works for minimal scenario, bet did not really work for my app. I've finished with parameter =8. So far so good- everything works. But of course, I had to disable animations and transitions- it became choppy... Also, i understood how to use lv_tick_inc and lv_task_handler functions, so maybe some day later i'll make transition to get rid of lvesp32 and call those functions when needed. Thanks you once again for showing me right way

stale[bot] commented 3 years ago

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.