How can i generate micropython stub for lvgl? I want autocomplete and documentation in vscode. What is the best way to achieve this?
I tried https://github.com/Josverl/micropython-stubber to generate the stubs from a microcontroller running lv_micropython. Everything else is generated, except lvgl.
Normal, on line 80 of createstubs.py it hardcodes the modules it will stub. It claims: āthere is no option to discover modules from upython, need to hardcodeā. Indeed help("modules")
prints the list of modules and returns None
ā¦
So one way to use this is to add `ālvglā to the list declared line 80ā¦
1 Like
One may even want to add as well espidf
, ili9341
and lvesp32
and a few of the new uasyncio
ones⦠Here is the complete printout I get from help("modules")
:
__main__ gc uasyncio/core uos
_boot ili9341 uasyncio/event upip
_onewire inisetup uasyncio/funcs upip_utarfile
_thread lodepng uasyncio/lock urandom
_uasyncio lvesp32 uasyncio/stream ure
_webrepl lvgl ubinascii uselect
apa106 machine ubluetooth usocket
btree math ucollections ussl
builtins micropython ucryptolib ustruct
cmath neopixel uctypes utime
dht network uerrno utimeq
ds18x20 ntptime uftpd uwebsocket
esp onewire uhashlib uzlib
esp32 rtch uhashlib webrepl
espidf sys uheapq webrepl_setup
flashbdev uarray uio websocket_helper
framebuf uasyncio/__init__ ujson xpt2046
Its quite long. One way to fabricate the list is to write the following script:
str = """BLAH"""
lst = str.split(" ")
print([k for k in lst if len(k)>0])
and save it. I name it blah.py
). Then:
- run
help("modules")
on your micropcontroller
- take the generated text and paste it replacing the word
BLAH
in the script blah.py
. Donāt touch the triple quotes.
- run the script and copy/paste the resulting list in order to replace the right hand side of the
=
sign in line 80 of createstubs.py. Iād personally duplicate line 80, comment out the first instance and modify the second, thus keeping a copy of the originalā¦
Have fun!