lejos.robotics.TouchAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lejos-ev3-api Show documentation
Show all versions of lejos-ev3-api Show documentation
leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.
The newest version!
package lejos.robotics;
import lejos.hardware.sensor.*;
public class TouchAdapter implements Touch{
private final float[] buf;
SensorMode source;
public TouchAdapter(BaseSensor touchSensor) {
this.source = touchSensor.getMode("Touch");
buf=new float[source.sampleSize()];
}
@Override
public boolean isPressed() {
source.fetchSample(buf,0);
return (buf[0] > 0);
}
}