sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
98 stars 19 forks source link

Color sensor 88007 is returning values > 255 in rgbMode #150

Open dkurok opened 3 years ago

dkurok commented 3 years ago

I've played arround with the ColorDistanceSensor-implementation from @highstreeto today. Using the ExampleColorDistanceSensor.cs and have it run a little bit longer in await TestMode(colorDistSensor, colorDistSensor.ModeIndexRgb) for better checking what it returns, I mentioned that it receives red, green and blue values GREATER than 255! (try over a clear white surface for getting fast to it). The "SharpBrick.PoweredUp.Cli.exe device list" gives this for the RGB-sensor Mode 6: Name: RGB I, Symbol: RAW, Capability: Input

tthiery commented 3 years ago

Yeah. Duplicate of #126

tthiery commented 3 years ago

Problem is: this scaling is integral part of the LWP. I did not realize at the beginning which led to the unfortunate decision to have input data type == output data type. We will fix this by making the output a double. Decimal might be another choice but has a price on memory.

tthiery commented 3 years ago

This is by the way the trigger for the v4 release in the first place.

tthiery commented 3 years ago

Wow. Sorry. Completely misread this thread. Good question. Well, same answer... We implement first of all LWP and powered up devices. They create a 1024 discrete color spectrum. Do I like it. Nope. Is a helper method maybe useful? Maybe. Will the endpoint use 1024 for the si endpoint? Yes

tthiery commented 3 years ago

Same story for other color sensors btw

highstreeto commented 3 years ago

Yeah, I noticed that behavior too.

I added that in my PR for the docs repo.

tthiery commented 6 months ago

Good First Issue:

Create an extension method which translates the 0-1000 value to a realistic RGB scale from 0-255.