lejos.robotics.AccelerometerAdapter 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.robotics.filter.AbstractFilter;
public class AccelerometerAdapter extends AbstractFilter implements Accelerometer{
float[] sample;
public AccelerometerAdapter(SampleProvider source) {
super(source);
sample=new float[sampleSize];
}
protected int getElement(int index) {
fetchSample(sample,0);
return (int) sample[index];
}
@Override
public int getXAccel() {
return getElement(0);
}
@Override
public int getYAccel() {
return getElement(1);
}
@Override
public int getZAccel() {
return getElement(2);
}
}