-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color Sensor's code not working #882
Comments
cc: @Ellerbach |
@ClementG-63, I'll try to see what's happening. As there are few different color sensors, may I ask you to send me a picture of your module? |
@ClementG-63 , so I tested the code with my own sensor and I get colors. With the next more, the "Blue" one (where light is actually not blue, still red): This is what I get when using the mode "Color" one (ambient one with the multi color light): And this is what I get when using the ambient and reflection modes (with the blue light): So there may be an issue with the 2 last modes. But that said comparing with the values from the EV3 brick itself (where only 3 modes are available), the relection mode should give something like 2 or 3. So I need to investigate. Also, seems that some modes may be mixed. So need to investigate as well reason why. In the mean time, can you confirm that you get the right EV3 sensor? |
Yes it's this one |
In the color mode, it's normal that you get the color. The number is the color number (not a percentage) you get from the Lego EV3 brick itself. If you go to the port and select the mode with color, you'll get this. |
I can’t get the color reflected percentage how you do it? |
It's by using the Reflection mode. But seems that there is an issue in the Read() function. I need to submit a fix. I don't have the sensor to test. But if you want to test, clone the project and change the Read function for the following: /// <summary>
/// Read the intensity of the reflected or ambient light in percent. In color mode the color index is returned
/// </summary>
public int Read()
{
int val = 0;
switch (_colorMode)
{
case ColorSensorMode.Color:
case ColorSensorMode.Ambient:
val = (int)ReadColor();
break;
case ColorSensorMode.Reflection:
default:
val = CalculateRawAverageAsPct();
break;
}
return val;
} If you don't want to clone the project and make any change, then you can still get the raw value thru the so something like this will give you the right value: var str = sensor.ReadTest();
var percentage = Convert.ToInt32(str.Split(" ")[3]); The variable Please let me know which way you'll go. You may want to check first what the |
[Triage] I need to check if this fix has been merged or not, if not, then do it at some point. |
@Ellerbach ping :-) |
Each mode of the ColorSensorMode is not working except the mode "Color".
RGB, Reflexion, Ambient are giving None and value equals 0.
Expected behavior
That's testing each mode, if 0 given : swap mode.
Result :
None
0%
Mode changedReflection
None
0%
Mode changedGreen
None
0%
Mode changedBlue
None
0%
Mode changedRed
None
0%
Mode changedColor
Brown
7% (not percentage)
Last Version Used
Add following information:
dotnet --info
:SDK .NET Core (reflétant tous les global.json) :
Version: 3.0.100
dotnet --info
on the machine where app is being run (not applicable for self-contained apps)System.Device.Gpio
package : Last VersionIot.Device.Bindings
package : Last VersionThe text was updated successfully, but these errors were encountered: