Closed Tcm0 closed 4 years ago
Patches to add this functionality are welcome.
Why is your personal drive to add stuff to this library so low, just asking?
I don't have an EV3.
Hello. I would like to use C4EV3 with my students to program robots for Robocup Junior, and we need this sensor mode. Has it been added to the API? is there any reference to add it to the library? I tried to understand the ev3_sensor.c code but I miss some firmware background.
Thanks
Hello,
it hadn't been added, but I have taken a look at how ev3dev has done it and created the https://github.com/c4ev3/EV3-API/tree/wip-color-rgb-mode branch, which adds COL_COLOR_RGB
, which I think should do what you want (ReadSensor
should return a 32 bit integer with 0x00RRGGBB
, ReadSensorData
should return a pointer to a buffer with uint16_t rgb[3];
. As mentioned above, I don't have an EV3 to test (and the API wasn't written by me either), so please test and report back if it works!
Hi there, I tried out COL_COLOR_RGB
but it seems not to work. The returned R-value flips wildly between ~0 and ~200, while the G and B values are stuck at ~100-200. They seem to be unaffected by what the sensor is pointed at.
Not sure if this would be useful but I tried reading calling ReadSensorData
to get the raw values as data
and parsing it as 8 bytes instead. data[0]
now gives a value that seems to correlate with what the sensor is pointed at while other values are either stuck or flipping rapidly between a few values.
Did anyone have any luck getting this to work?
This is now fixed:
Is it already merged into the main branch?
Yup, the improvement has landed in the master branch (PR #48).
There is now also a more convenient API that can be used for the same purpose:
Nice. I'll close this then.
The 4th mode of the color sensor "RGB" is not supported. You can use it to read the actual R, G and B values and not only one out of 7 colors. It's also not officially supported by lego but there is a way to use it in the official software: http://mindcuber.com/mindcub3r/mindcub3r.html Monobrick supports it, too: https://github.com/Larsjep/monoev3/blob/release/MonoBrickFirmware/Sensors/EV3ColorSensor.cs