Skip to content

Micropython support for ev3dev2 Button class #571

Closed

Description

@Dilbert76

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...

Activity

  1. added this to the v2.0-beta3 milestone on Dec 19, 2018
  2. WasabiFan commented on Dec 19, 2018

    @WasabiFan
    Member

    @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?

  3. dlech commented on Dec 21, 2018

    @dlech
    Member

    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.

    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.

  4. staadecker commented on May 10, 2019

    @staadecker

    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?

  5. dlech commented on May 10, 2019

    @dlech
    Member

    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.

  6. staadecker commented on May 11, 2019

    @staadecker

    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?

  7. JunOllyLi commented on May 12, 2019

    @JunOllyLi

    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.

  8. self-assigned this
    on May 13, 2019
  9. dwalton76 commented on Jun 8, 2019

    @dwalton76
    Collaborator

    @JunOllyLi had you worked on Display support in your project?

  10. JunOllyLi commented on Jun 9, 2019

    @JunOllyLi

    @dwalton76 No I have not got the chance to work on display yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions