You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to propose to add ev3dev2.Button support for Micropython.
Buttons are often used by WRO or FLL teams to calibrate motors. Furthermore WRO Regular rules allow to start a program beforehand and start the actual run by pushing the center button on the EV3 brick. This trick would allow WRO teams to initialise/construct all motor and sensor objects (which still takes several seconds) before the actual run, so robot would move instantaneously as soon as center button is pressed without having to wait a couple of seconds before the robot actually starts doing something. Without Button support I'm afraid that it might be tough for WRO teams to use Python...
@dlech On the technical side, do you have any suggestions on the best way to do this? The button module uses fcntl which should be fairly easy to replace with the micropython equivalent, but I expect evdev (for device discovery and events) to be less doable. Is there a logical way that you see?
If micropython-lib has something compatible with the standard struct module, we could probably skip using the existing python evdev package and roll our own simplified version.
Any news on this? @dlech Is there any way for me to use the button class from the link since it works. What if I want my code to be compatible with both normal and micro. Should I have an if statement to differentiate between which modules to use?
IMHO, trying to make code that is compatible with both Python 3 and MicroPython is not worth the effort. They are different programming languages and there are too many gotchas to deal with because of all of the little differences.
Ok makes sense. Any plan to merge your code from micropython-ev3dev into the main repo and then people can import one library or the other depending on their needs? As of now, would the best be to clone the micropython repo onto the ev3 and add it to the path?
I had an experiment project, to improve ev3dev2 support in Micropython.
You guys can try it if you are interested. I am not familiar with the Debian Packaging stuff, so this would require some hands on compiling.
Activity
WasabiFan commentedon Dec 19, 2018
@dlech On the technical side, do you have any suggestions on the best way to do this? The button module uses
fcntlwhich should be fairly easy to replace with the micropython equivalent, but I expectevdev(for device discovery and events) to be less doable. Is there a logical way that you see?dlech commentedon Dec 21, 2018
If
micropython-libhas something compatible with the standardstructmodule, we could probably skip using the existing pythonevdevpackage and roll our own simplified version.See https://github.com/dlech/micropython-ev3dev/blob/ev3dev-stetch/src/uev3dev/button.py. This isn't compatible with standard python, but it could possibly be adapted.
staadecker commentedon May 10, 2019
Any news on this? @dlech Is there any way for me to use the button class from the link since it works. What if I want my code to be compatible with both normal and micro. Should I have an if statement to differentiate between which modules to use?
dlech commentedon May 10, 2019
IMHO, trying to make code that is compatible with both Python 3 and MicroPython is not worth the effort. They are different programming languages and there are too many gotchas to deal with because of all of the little differences.
staadecker commentedon May 11, 2019
Ok makes sense. Any plan to merge your code from micropython-ev3dev into the main repo and then people can import one library or the other depending on their needs? As of now, would the best be to clone the micropython repo onto the ev3 and add it to the path?
JunOllyLi commentedon May 12, 2019
I had an experiment project, to improve ev3dev2 support in Micropython.
You guys can try it if you are interested. I am not familiar with the Debian Packaging stuff, so this would require some hands on compiling.
https://github.com/robosaurus-ev3dev2-upy/upy-ev3dev2
So far I tested LEDs, sound, buttons and they work. And of course the motors and external sensors were already supported.
dwalton76 commentedon Jun 8, 2019
@JunOllyLi had you worked on Display support in your project?
JunOllyLi commentedon Jun 9, 2019
@dwalton76 No I have not got the chance to work on display yet.