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

lejos.hardware.sensor.HiTechnicIRSeeker 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.hardware.sensor;

import lejos.hardware.port.I2CPort;
import lejos.hardware.port.Port;

/**
 * HiTechnic NXT IRSeeker
* The NXT IRSeeker is a multi-element infrared detector that * detects infrared signals from sources such as the HiTechnic IRBall soccer * ball, infrared remote controls and sunlight. * *

* The code for this sensor has not been tested. Please report test results to * the leJOS forum. *

* *

*

* * * * * * * * * * * * * * * *
Supported modes
Mode nameDescriptionunit(s)Getter
UnmodulatedMeasures the angle to a source of unmodulated infrared lightDegrees {@link #getUnmodulatedMode() }
* * *

* * See * Sensor Product page * See The * leJOS sensor framework * See {@link lejos.robotics.SampleProvider leJOS conventions for * SampleProviders} * *

* * * @author ? * */ public class HiTechnicIRSeeker extends I2CSensor { byte[] buf = new byte[1]; public HiTechnicIRSeeker(I2CPort port) { super(port); init(); } public HiTechnicIRSeeker(Port port) { super(port); init(); } protected void init() { setModes(new SensorMode[] { new UnmodulatedMode() }); } /** * HiTechnic IR seeker, Unmodulated mode
* Measures the angle to a source of unmodulated infrared light * *

* Size and content of the sample
* The sample contains one element containing the angle to the infrared source. The angle is expressed in degrees following the right hand rule. */ public SensorMode getUnmodulatedMode() { return getMode(0); } /** * Measures angle with zero forward, anti-clockwise positive */ private class UnmodulatedMode implements SensorMode { @Override public int sampleSize() { return 1; } @Override public void fetchSample(float[] sample, int offset) { getData(0x42, buf, 1); float angle = Float.NaN; if (buf[0] > 0) { angle = -(buf[0] * 30 - 150); } sample[offset] = angle; } @Override public String getName() { return "Unmodulated"; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy