-
Notifications
You must be signed in to change notification settings - Fork 19
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
How turn on lights on ColorDistanceSensor ? #203
Comments
I do not have that device, was contributed by someone. The device code has a light mode field ... which is not accessible by a method. |
Try write a value 0-100 into the mode. Like that the technic sensor sector lights work. |
Thank you for your response. I've observed that the Technic Color Sensor #45605 features 3 white lights . |
Take this example and use the mode as the following. byte colorNr = PoweredUpColor.Red;
// mode is a capability offered by the device
var lightMode = colorDistSensor.SingleValueMode<sbyte, sbyte>(colorDistSensor.ModeIndexLight);
// the mode seems to receive a single byte with a color code number
await lightMode.WriteDirectModeDataAsync(new byte[] { colorNr }); Thanks to our friends on the node-poweredup community who have discovered the device more extensively. The mode is pretty-printed described by the protocol as the following
|
There is a lot more you can do with this little sensor ... see the node project ... if you are in the mood, create a Pull Request to add the color function as a method to our library |
Hi,
Thanks,
I tried the proposed code but can't get it to work. It does nothing.
Tried passing different colors but still nothing happens.
Il giorno mar 5 mar 2024 alle ore 20:57 T. Thiery ***@***.***>
ha scritto:
… There is a lot more you can do with this little sensor ... see the node
project ... if you are in the mood, create a Pull Request to add the color
function as a method to our library
—
Reply to this email directly, view it on GitHub
<#203 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKLR4I47QTUKLH2FRSRPRDYWYPRLAVCNFSM6AAAAABEE77XFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGUZDONRQGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Can you post the code? |
public class ExampleColorDistanceSensorLightColor : BaseExample
{
public override async Task ExecuteAsync()
{
using (var moveHub = Host.FindByType<MoveHub>())
{
var colorDistSensor =
moveHub.C.GetDevice<ColorDistanceSensor>();
byte colorNr = (byte)PoweredUpColor.Red;
// mode is a capability offered by the device
var lightMode = colorDistSensor.SingleValueMode<sbyte,
sbyte>(colorDistSensor.ModeIndexLight);
// the mode seems to receive a single byte with a color code
number
await lightMode.WriteDirectModeDataAsync(new byte[] { colorNr});
}
}
}
tried all the PoweredUpColor enum values.
Il giorno gio 7 mar 2024 alle ore 10:55 T. Thiery ***@***.***>
ha scritto:
… Can you post the code?
—
Reply to this email directly, view it on GitHub
<#203 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKLR4IXOJH6KTXLLASXFXTYXA2Q5AVCNFSM6AAAAABEE77XFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBTGE2DAMZUHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sounds about right. Pity that it does not work. There is one thing in the JS code ... the .subscribe(LED) above which is different. Try the following line before, adjusted to the right mode 5. |
Ok ,now works. I'm not able to create a pull request , here the edits . I added to ColorDistanceSensor class this method :
Added enum ColorDistanceLedColor .
Here the test class :
|
@tenacious I released the package in version 5.0.2 including your function. Feel free to test it. Curious: Why you are not able to do the Pull Request. I could have walked you through! |
Hi, you are very kind. I didn't want to run the risk of messing anything
up. For some lines of code I preferred to proceed like this.
Il giorno gio 21 mar 2024 alle ore 23:10 T. Thiery ***@***.***>
ha scritto:
… @tenacious <https://github.com/tenacious> I released the package in
version 5.0.2 including your function. Feel free to test it.
Curious: Why you are not able to do the Pull Request. I could have walked
you through!
—
Reply to this email directly, view it on GitHub
<#203 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKLR4J46VHAZZNBWEKORELYZNLGXAVCNFSM6AAAAABEE77XFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJTHEZTEOJTGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi,
How turn on lights on ColorDistanceSensor ?
I see is only possible get infos from ColorDistanceSensor .
From lego App is possible also turn on led lights on ColorDistanceSensor, is possible with Sharpbrick too ?
Thanks to everyone involved in this project !
The text was updated successfully, but these errors were encountered: