ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
425 stars 144 forks source link

The 'IR-REM-A' mode of Infrared Sensor seems not work. #721

Open haiyongsong1921 opened 4 years ago

haiyongsong1921 commented 4 years ago

https://github.com/ev3dev/ev3dev-lang-python/blob/659f539c9c8e7d6668fe70960ffeb884c4d08cf7/ev3dev2/sensor/lego.py#L683

I cannot find the reference part of 'IR-REM-A' in the source code. I want to use the _BUTTON_VALUES dictionary for checking the multiple buttons pressed on Infrared beacon, like when press 'top_left' and 'top_right' at the same time, I can get 5 as a result from the public method, then I can implement my logic in that condition. But I do not see any method use the _BUTTON_VALUES dictionary, and return the key value of the pressed buttons. Do I misunderstand something? Is there anyone can help me to make it clear? Thanks a lot

WasabiFan commented 4 years ago

Hmmm... I wasn't aware of that mode. @dwalton76 @dlech Are you guys aware of a reason we would be using the existing IR-REMOTE mode rather than this one? Wouldn't this give a superset of the available info?

@haiyongsong1921 For your use case, I suggest you manually use the Sensor interfaces (https://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/sensors.html#base-sensor) to read the data; our IR sensor class doesn't seem to be equipped to handle it. You can set the mode then read the value 0 and do the conversion yourself -- it's unfortunate we don't propery support it but I think that's the best option.

haiyongsong1921 commented 4 years ago

@WasabiFan Thanks for your reply. Yes, actually I solved the issue by using the IR-REMOTE mode and do the conversion by myself. I post this question just because I saw the 'IR-REM-A' mode in the source code, and it seems like to provide this kind of API to do the conversion automatically. Anyway, really appreciate for your suggestion, and @dlech @dwalton76 any comments to my question are welcome. Thanks.

dwalton76 commented 4 years ago

@haiyongsong1921 try InfraredSensor.buttons_pressed() I think that is what you are looking for

dlech commented 4 years ago

IR-REMOTE can handle remotes on multiple IR channels at the same time. This is also the mode used in official LEGO software.

IR-REM-A only works with channel one and is not used in any official LEGO software.

haiyongsong1921 commented 4 years ago

@haiyongsong1921 try InfraredSensor.buttons_pressed() I think that is what you are looking for

@dwalton76 Thanks, I used this method to get the list of buttons pressed, and do the conversion by myself.

haiyongsong1921 commented 4 years ago

@dlech Thanks David, The IR-REMOTE works fine and can solve my problem. I have another question about how to be a contributor to this project. Is there any guide or requirements for this. I am an C++ developer with experience more than 10 years , I start to learn python from last year and I really love it. Currently I am programing on lego ev3 with python, and I found that this project is really awesome and helpful, so I want to be a contributor for this. Is there any suggestion from your side? Thx.

haiyongsong1921 commented 4 years ago

Hi @dlech , would you mind to share some information or requirements about how to be a contributor to this repo, I am really interested in being a contributor of this open source project. Thanks

dlech commented 4 years ago

Please see https://github.com/ev3dev/ev3dev-lang-python/blob/ev3dev-stretch/CONTRIBUTING.rst

WasabiFan commented 4 years ago

Yeah, @haiyongsong1921 you're totally welcome to contribute; the best way would be to go through open issues, pick one you think is interesting or achievable, and chat with us if you have any questions!

haiyongsong1921 commented 4 years ago

@dlech @WasabiFan, really thanks for your suggestions, I will follow the instruction and hope do some helpful for this fabulous project.