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

lejos.robotics.RangeFinderAdapter 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 RangeFinderAdapter extends AbstractFilter implements RangeFinder{
	private final float[] buf;

	public RangeFinderAdapter(SampleProvider source) {
		super(source);
		buf=new float[sampleSize];
	}
	
	@Override
	public float getRange() {
		fetchSample(buf,0);
		return buf[0] * 100;
	}

	@Override
	public float[] getRanges() {
		float[] sample=new float[sampleSize];
		fetchSample(sample,0);
		return sample;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy