-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ESP32 to supported devices with basic type hints #114
base: master
Are you sure you want to change the base?
Conversation
For now the ESP32 type hints are just a copy of the ESP8266's.
override val usbIds: List<MicroPythonUsbId> | ||
get() = listOf(MicroPythonUsbId(0x1A86, 0x7523), | ||
MicroPythonUsbId(0x10C4, 0xEA60), | ||
MicroPythonUsbId(0x0403, 0x6001)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are copied from the ESP8266.
To find the values for an ESP32, I connected MCUs by USB and ran $ cat /sys/bus/usb-serial/devices/ttyUSB0/../uevent
. I tested with an ESP8266 and an ESP32 and both output PRODUCT=10c4/ea60/100
. I was a bit surprised - I expected them to be different.
PRODUCT=10c4/ea60/100
corresponds to the second element in this list. Auto-detect of my ESP32 subsequently worked. Shall we keep all the values copied from ESP8266 the same, then?
To expand on this, one example would be the This presents a problem: if we have a generic There's a similar issue in the I was thinking that board-specific type hint directories could maybe have an |
@Gor-Ren thank you for taking this on. I would like to test your added support for ESP32 but I am running into issue. |
@jsonpoindexter hrm, I can't seem to reproduce
maybe make sure you are running As a sanity check you could try loading the SNAPSHOT build into your IDE:
|
Question on this concerning the stub files. Why can't you change the library root to a directory specific to a type of board and that directory would contain the stub files needed? |
Many of the stubs describe common code to all boards. Therefore if possible it's desirable to consolidate it in one place, not to duplicate them across every board, which would be an onerous maintenance burden. Of course it starts to break down if the "common" code turns out to be a lot more custom for each board (which we are seeing with some methods in |
I can understand the duplicate code thing. I know it would not be ideal but it is a solution. T do not know how much manipulation is allowed to be done with PyCharm I am thinking that if you can make the directory for the micropython stubs as a sub directory of a boards stub files then you would be able to add the board stub file folder as the library root and your problem would be solved. The directory for the micropython stub files being a sub directory of the board would only exist in PyCharm and not on the filesystem. Tho you could use symbolic links to accomplish the same thing as well. I am going to run some tests to try and manipulate the library root. maybe it can be made to behave the way that is needed. |
Stub files are there only for the purposes of having an IDE work properly. I do not think they are there for any other purpose. I am the administrator of a project called EventGhost and this application is written mostly in Python. It is fairly large at around 200,000 lines of code. Some of the modules in it need to be loaded in a very specific order and we also wanted to keep memory management and the resources under control. We do this by only importing a modules when it is actually needed. This is done by wrapping a class around the main module and using __getattr__. The problem with this is an IDE is not able to offer code completion and type hints for those moduels because there is no hard coded import of the modules. This is what I did to make everything work correctly. import os
if 'THIS_CODE_NEVER_REALLY_RUNS' in os.environ:
from Classes import SomeModule as _SomeModule
SomeModule = _SomeModule Because PyCharm thinks that the code has a possibility of running it then scans the modules and allows all of the goodies in an IDE to work properly. This kind of manipulation can also be done as well in a pyi file. You would need to add in the imports of the board specific pyi files at the end the question now becomes how can this be done without the user being able to see the board specific files in the library root. |
Set the location that native code will be placed for execution after it is | ||
compiled. Native code is emitted when the ``@micropython.native``, ``@micropython.viper`` | ||
and ``@micropython.asm_xtensa`` decorators are applied to a function. The | ||
ESP8266 must execute code from either iRAM or the lower 1MByte of flash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a missed comment update. Still referring to ESP8266. Not ESP32.
Relates to #44
Changes
Made ESP32 a supported device, appearing as a device in the MicroPython settings list with auto-detect support.
Esp32DeviceProvider
class, largely a copy of theEsp8266
one./gradlew clean runIde
ESP32-WROOM-32
MCU/typehints/esp32/
dir, initially populated with the same files as ESP8266 - to be expanded in later PRsOut of Scope (but happy to discuss if you think it should be in this PR 😄)
CLA
I've signed it.