ev3dev-lang-python icon indicating copy to clipboard operation
ev3dev-lang-python copied to clipboard

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

Open haiyongsong1921 opened this issue 5 years ago • 10 comments

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

haiyongsong1921 avatar Feb 05 '20 10:02 haiyongsong1921

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.

WasabiFan avatar Feb 09 '20 05:02 WasabiFan

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

haiyongsong1921 avatar Feb 09 '20 12:02 haiyongsong1921

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

dwalton76 avatar Feb 09 '20 14:02 dwalton76

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.

dlech avatar Feb 09 '20 19:02 dlech

@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 avatar Feb 10 '20 02:02 haiyongsong1921

@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 avatar Feb 10 '20 02:02 haiyongsong1921

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

haiyongsong1921 avatar Feb 13 '20 08:02 haiyongsong1921

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

dlech avatar Feb 13 '20 15:02 dlech

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!

WasabiFan avatar Feb 22 '20 06:02 WasabiFan

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

haiyongsong1921 avatar Feb 22 '20 09:02 haiyongsong1921