This project is an extension of the CSharp project provided by Dester Industries on GitHub https://github.com/DexterInd/GoPiGo
There were a few gliches for my GoPiGo2 and some features that I wanted to have working.
I am working on adding a second part to stream the web camera image to the client. I am not looking for real-time stream it can have a delay but have yet to get it functioning. The UWP User application also works with Hololens as a UWP App and I will in the future add a project for a Unity user application.
In the Pin.cs file, I added Trigger = 15, and Echo = 16 to the enum.
In the Led.cs file I changed the internal to public.
And last the UltrasonicRangerSensor.cs I rewrote most of the function
public interface IUltrasonicRangerSensor
{
Task<int> MeasureInCentimeters();
}
internal class UltrasonicRangerSensor : IUltrasonicRangerSensor
{
private const byte CommandAddress = 117;
private readonly GoPiGo _device;
private readonly Pin _pin;
internal UltrasonicRangerSensor(GoPiGo device, Pin pin)
{
_device = device;
_pin = pin;
}
public async Task<int> MeasureInCentimeters()
{
var buffer = new[] { CommandAddress, (byte)_pin, Constants.Unused, Constants.Unused };
_device.DirectAccess.Write(buffer);
await Task.Delay(5);
_device.DirectAccess.Read(buffer);
return buffer[1] * 256 + buffer[2];
}
}
Comments