BrickPi.Sensors.EV3IRSensor.ReadBeaconLocation C# (CSharp) Method

ReadBeaconLocation() public method

Gets the beacon location. This will change the mode to seek
public ReadBeaconLocation ( ) : int
return int
        public int ReadBeaconLocation()
        {
            if (Mode != IRMode.Seek)
            {
                Mode = IRMode.Seek;
            }
            //byte[] data = mUartSensor.ReadBytes(4 * 2);
            //return new BeaconLocation((sbyte)data[(int)Channel * 2], (sbyte)data[((int)Channel * 2) + 1]);
            return brick.BrickPi.Sensor[(int)Port].Value;
        }

Usage Example

Beispiel #1
0
        //EV3IRSensor
        private async Task TestIRSensor()
        {

            EV3IRSensor ultra = new EV3IRSensor(BrickPortSensor.PORT_S4, IRMode.Remote);
            for (int i = 0; i < ultra.NumberOfModes(); i++)
            {
                int count = 0;
                while (count < 100)
                {
                    Debug.WriteLine(string.Format("NXT ultra, Distance: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                        ultra.ReadBeaconLocation(), ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                    await Task.Delay(300);
                }
                ultra.SelectNextMode();
            }
        }