All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lejos.robotics.AccelerometerAdapter Maven / Gradle / Ivy

Go to download

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);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy