nxtlib/src/Sensors/UltrasonicSensor.cs
/// <summary>
/// <para>Polls the sensor, and fires the NXT-G like events if appropriate.</para>
/// </summary>
Polls the sensor, and fires the NXT-G like events if appropriate.
Polls the sensor and fires the NXT - G like events if appropriate .
public override void Poll()
        {
            if (brick.IsConnected)
            {
                byte? oldDistance, newDistance;
                lock (pollDataLock)
                {
                    oldDistance = DistanceCm;
                    pollData = ReadMeasurementByteX(0);
                    base.Poll();
                    newDistance = DistanceCm;
                }
                if (oldDistance.HasValue && newDistance.HasValue)
                {
                    if (oldDistance <= ThresholdDistanceCm && ThresholdDistanceCm < newDistance)
                    {
                        if (OnOutsideThresholdDistanceCm != null) OnOutsideThresholdDistanceCm(this);
                    }
                    if (newDistance < ThresholdDistanceCm && ThresholdDistanceCm <= oldDistance)
                    {
                        if (OnWithinThresholdDistanceCm != null) OnWithinThresholdDistanceCm(this);
                    }
                }
            }
        }
public override void Poll ( ) { if ( brick . IsConnected ) { byte ? oldDistance , newDistance ; lock ( pollDataLock ) { oldDistance = DistanceCm ; pollData = ReadMeasurementByteX ( 0 ) ; base . Poll ( ) ; newDistance = DistanceCm ; } if ( oldDistance . HasValue && newDistance . HasValue ) { if ( oldDistance <= ThresholdDistanceCm && ThresholdDistanceCm < newDistance ) { if ( OnOutsideThresholdDistanceCm != null ) OnOutsideThresholdDistanceCm ( this ) ; } if ( newDistance < ThresholdDistanceCm && ThresholdDistanceCm <= oldDistance ) { if ( OnWithinThresholdDistanceCm != null ) OnWithinThresholdDistanceCm ( this ) ; } } } }
Polls the sensor, and fires the NXT-G like events if appropriate.
Polls the sensor and fires the NXT - G like events if appropriate .
// Have the intensity passed over the threshold-distance? // Have the intensity passed below the threshold-distance?