package lejos.hardware.sensor;
import lejos.hardware.port.UARTPort;
import lejos.robotics.RangeFinder;

/**
 * Basic sensor driver for the Lego EV3 Ultrasonic sensor.<br>
 * TODO: Need to implement other modes. Consider implementing other methods
 * to allow this device to be used in place of the NXT device (getDistance) etc.
 * @author andy
 *
 */
public class EV3UltrasonicSensor extends UARTSensor implements RangeFinder
{

    /**
     * Create the sensor class. The sensor will be set to return measurements in CM.
     * @param port
     */
    public EV3UltrasonicSensor(UARTPort port)
    {
        super(port);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public float getRange()
    {
        return (float)port.getShort()/10.0f;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public float[] getRanges()
    {
        // TODO Work out how to use other modes, maybe change this
        float [] result = new float[1];
        result[0] = getRange();
        return result;
    }

}

@@ -24,16 +24,49 @@
 sensor;%0A
+import lejos.hardware.port.Port;%0A
 import l
@@ -647,32 +647,234 @@
 r(port);%0A    %7D%0A%0A
+    /**%0A     * Create the sensor class. The sensor will be set to return measurements in CM.%0A     * @param port%0A     */%0A    public EV3UltrasonicSensor(Port port)%0A    %7B%0A        super(port);%0A    %7D%0A%0A    %0A%0A
     /**%0A     * %7B

Convert to use new port mechanism