Repository navigation
Conversation
2399852 to
1a4fd20
Compare
| def get_index(file): | ||
| match = Device._DEVICE_INDEX.match(file) | ||
| if match: | ||
| return int(match.group('idx')) |
There was a problem hiding this comment.
MicroPython's implementation of the re module is barebones and doesn't have support for named groups. I don't see any reason why we need to use a named group anyway.
|
Do you have timing tests from the actual EV3 for this? |
|
Here are some timing tests, although I'm moderately suspicious of them: |
|
Yes, I think python caches imports. Also, you are probably missing the time it takes to load the interpreter as well. May be something like would be more representative. Here hello.py could be import ev3dev.ev3 as ev3
m = ev3.Motor()
print(m.connected) |
| @@ -0,0 +1,692 @@ | |||
| """ | |||
There was a problem hiding this comment.
If we are moving them now and long term we want them to be in sound.py and screen.py files (I like that idea) why not go ahead and put them there now?
There was a problem hiding this comment.
To be honest, I put them in the same file because the existing framebuffer.py was annoying me 😆 Although, I am not entirely sure how I want to organize the platform check; I would prefer that the logic to compare implementation names is centralized in one location. Thoughts?
+1 |
|
Good procedure, @ddemidov! Mean 10.2 seconds for |
|
|
||
| import sys | ||
| optional_enabled = sys.implementation.name is not 'micropython' | ||
|
|
There was a problem hiding this comment.
what are the features needed here missing on micropython? Can those be added as a comment? I guess it is the subprocess module, but most of the sound stuff should work with os.system().
|
Some more details here: ev3dev/ev3dev#937 |
|
For subprocess looks like we can use os.pipe() as a work-around |
|
Part of the documented Sound interface is that users may call |
More importantly, PIL (pillow) will be missing for micro python. Maybe this will help? https://micropython.org/resources/docs/en/latest/wipy/library/framebuf.html |
|
Oh, and you can |
|
Not sure on a |
|
Well os.system() would be with an implicit .wait() otherwise we need to use a thread. |
|
Yes, the here are certainly ways to reimplement this functionality on micropython. I removed the impacted classes here so that we had a starting point to look into packaging and releasing it, and then we could modify these implementations as desired to use micropython's embedded interfaces or alternative APIs in the future. |
|
I'm going to close this and break out the only independent portion of these changes for a different PR. The PR in its current form is really just a partial split of some classes into their own modules, which is covered in full by #375; micropython support didn't require any other major changes. That will be all that's necessary to "support" micropython at a minimum, excluding packaging. |
This is my first crack at supporting micropython. Note that I haven't made any packaging changes, just rearranged things to make code run. I think it's a reasonable first step, but isn't useful yet without packaging.
The question is: do we want to do it this way? I chose to separate the two "optional" classes into their own file to give some separation, but that isn't necessary.
My eventual preference would be to split each module into its own separately-importable file: motors, sensors, LEDs, screen, sound, etc. That would both decrease load time (the interpreter doesn't need to parse a bunch of stuff that isn't used) and make it easier to navigate the file structure during development. However, I think these changes will be useful regardless of whether we decide to restructure or not.