I have a simple Bluetooth scanning function that works fine.
Importing the ili9341 driver causes the Bluetooth def bt_irq function to exit after a couple of cycles.
No REPL errors.
Microcontroller still responsive.
Where does one start to track down the conflict.
Using a Lion D32 Pro v2
Bluetooth conflict with LittlevGL ili9341 driver
Re: Bluetooth conflict with LittlevGL ili9341 driver
(Maybe a bit of a long shot) There is a known issue with ESP32 scan that could possibly be related? I just wrote some details about it on a different thread including some steps you can use to test out Espressif's possible fix. viewtopic.php?f=18&t=8058
Re: Bluetooth conflict with LittlevGL ili9341 driver
I saw that post and was very surprised about the scan dropping out after 7 hours.
Currently I have a program with a lot of moving parts....
ble, wifi, webserver w/websockets, email...
and I've been running the program weeks on end without a reboot (reboots are logged) .
Program loops every minute to scan for ble sensors
updates the website and saves data to sd and more (very common application right).
Now trying to add the LittlevGL gui and display.
Created this simple script to test LVGL & BLE and was surprised when there was a conflict.
BLE scan works fine if I don't load the display driver.
If I do load the ili9341 driver and execute ble('x')
I get maybe 1 or 2 "found a sensor" then kicked out to prompt before 10 sec time out.
No errors freezes or crash.
Your past help has been greatly appreciated!
Hopefully you see something suspicious in the code.
Stay safe from the virus.
Currently I have a program with a lot of moving parts....
ble, wifi, webserver w/websockets, email...
and I've been running the program weeks on end without a reboot (reboots are logged) .
Program loops every minute to scan for ble sensors
updates the website and saves data to sd and more (very common application right).
Now trying to add the LittlevGL gui and display.
Created this simple script to test LVGL & BLE and was surprised when there was a conflict.
BLE scan works fine if I don't load the display driver.
If I do load the ili9341 driver and execute ble('x')
I get maybe 1 or 2 "found a sensor" then kicked out to prompt before 10 sec time out.
No errors freezes or crash.
Your past help has been greatly appreciated!
Hopefully you see something suspicious in the code.
Stay safe from the virus.
Code: Select all
import utime, ubinascii, ubluetooth
import lvgl as lv
from micropython import const
from ili9341 import ili9341
# from xpt2046 import xpt2046
lv.init()
disp = ili9341(miso=19, mosi=23, clk=18, cs=14, dc=27, rst=33, backlight=32, backlight_on=2, rot=ili9341.LANDSCAPE, width=320, height=240)
_IRQ_SCAN_RESULT = const(1 << 4)
_IRQ_SCAN_COMPLETE = const(1 << 5)
bt=ubluetooth.BLE()
bt.active(True)
def ble(x):
start = utime.time()
x = (["0004", "0005"])
print(x)
def bt_irq(event, data):
if event == _IRQ_SCAN_RESULT and data[4][2:11] == b'BLEsensor' :
print("found a sensor")
mf = (ubinascii.hexlify(data[4]).decode("utf-8"))
sn = (ubinascii.hexlify(data[1]).decode("utf-8"))[-4:]
if sn in x:
x[x.index(sn)] = [data[3], int(mf[36:38], 16), (-(int(mf[38:44], 16) & 0x8000) | (int(mf[38:44], 16) & 0x7fff)) /10]
print('got sn:', sn)
elif event == _IRQ_SCAN_COMPLETE:
print("scan completed in",utime.time() - start,'sec')
print(x)
bt.gap_scan(10_000, 40_000, 40_000)
bt.irq(handler = bt_irq)
print("scan start @", utime.time() - start, 'sec')
scr = lv.obj()
l_p1 = lv.label(scr)
l_p1.set_text('Temp-1: ')
l_p1.align(scr, lv.ALIGN.CENTER, -50, -20)
l_p2 = lv.label(scr)
l_p2.set_text('Temp-2: ')
l_p2.align(scr, lv.ALIGN.CENTER, -50, 20)
lv.scr_load(scr)
ble('x')
Re: Bluetooth conflict with LittlevGL ili9341 driver
To date I have yet to find a solution for the Bluetooth scanning function becoming disabled due to its interaction with LVGL.
I have created this very short routine for anyone who might like to take a shot at it.
This routine works fine and has ran for over 17hr.
But if you uncomment the line "import lvesp32" then the ble becomes unresponsive and does not complete to "scan done".
This is the file when imported causes the issue... I hope someone could look at this file and see if there's anything that could be causing this problem. Also posted on LVGL... "https://forum.lvgl.io/t/ble-issue-with- ... ver/2604/8"
I have created this very short routine for anyone who might like to take a shot at it.
Code: Select all
import ubluetooth, utime
from machine import Timer
from micropython import const
import lvgl as lv
# import lvesp32
# from ili9341 import ili9341
# lv.init()
# disp = ili9341()
_IRQ_SCAN_RESULT = const(5)
_IRQ_SCAN_DONE = const(6)
bt=ubluetooth.BLE()
def bt_irq(event, data):
if event == _IRQ_SCAN_RESULT:
pass
elif event == _IRQ_SCAN_DONE:
print('scan done...')
def ble(tm):
print('\nruntime {:.2f}min' .format(utime.time()/60) )
start = utime.time()
bt.gap_scan(5000) # Scan for 5s
print('seconds to start: {}' .format(utime.time() - start))
bt.active(True)
bt.irq(handler = bt_irq)
tm = Timer(-1)
tm.init(period=15000, mode=Timer.PERIODIC, callback=ble) # trigger ble every 15 sec
This routine works fine and has ran for over 17hr.
But if you uncomment the line "import lvesp32" then the ble becomes unresponsive and does not complete to "scan done".
This is the file when imported causes the issue... I hope someone could look at this file and see if there's anything that could be causing this problem. Also posted on LVGL... "https://forum.lvgl.io/t/ble-issue-with- ... ver/2604/8"