pub struct InfraredSensor { /* private fields */ }Expand description
Stock EV3 Infrared Sensor
Note that this sensor does not support direct measurement of distance
and that the proximity() percentage does not scale linearly with distance.
If you want to get an accurate distance measurement, you should use anUltrasonicSensor.
Implementations§
Source§impl InfraredSensor
impl InfraredSensor
Sourcepub fn new(port: SensorPort) -> Ev3Result<Self>
pub fn new(port: SensorPort) -> Ev3Result<Self>
Find an InfraredSensor on the given port.
Will return SensorNotFound if no sensor is found
or IncorrectSensorType if the found sensor is not an InfraredSensor.
Sourcepub fn proximity(&self) -> Ev3Result<u8>
pub fn proximity(&self) -> Ev3Result<u8>
Get the proximity value of the sensor as a percentage (0 to 100).
100% is approximately 70cm/27in.
Note that this sensor does not support direct measurement of distance and that the percentage does not scale linearly with distance.
If you want to get an accurate distance measurement, you should use an UltrasonicSensor.
Get a HashSet of buttons currently pressed on the remote control channel 1.
Note that the set will be empty if three or more buttons are pressed.
Get a HashSet of buttons currently pressed on the remote control channel 2.
Note that the set will be empty if three or more buttons are pressed.
Get a HashSet of buttons currently pressed on the remote control channel 3.
Note that the set will be empty if three or more buttons are pressed.
Get a HashSet of buttons currently pressed on the remote control channel 4.
Note that the set will be empty if three or more buttons are pressed.
Sourcepub fn seek_channel_1(&self) -> Ev3Result<(i8, i8)>
pub fn seek_channel_1(&self) -> Ev3Result<(i8, i8)>
Seeks a remote control in beacon mode on channel 1.
The first value is heading (-25 to 25), and the second value is distance as a percentage (-128 and 0 to 100).
The distance is -128 when the remote is out of range.
§Examples
let (heading, distance) = infrared_sensor.seek_channel_1()?;Sourcepub fn seek_channel_2(&self) -> Ev3Result<(i8, i8)>
pub fn seek_channel_2(&self) -> Ev3Result<(i8, i8)>
Seeks a remote control in beacon mode on channel 2.
The first value is heading (-25 to 25), and the second value is distance as a percentage (-128 and 0 to 100).
The distance is -128 when the remote is out of range.
§Examples
let (heading, distance) = infrared_sensor.seek_channel_2()?;Sourcepub fn seek_channel_3(&self) -> Ev3Result<(i8, i8)>
pub fn seek_channel_3(&self) -> Ev3Result<(i8, i8)>
Seeks a remote control in beacon mode on channel 3.
The first value is heading (-25 to 25), and the second value is distance as a percentage (-128 and 0 to 100).
The distance is -128 when the remote is out of range.
§Examples
let (heading, distance) = infrared_sensor.seek_channel_3()?;Sourcepub fn seek_channel_4(&self) -> Ev3Result<(i8, i8)>
pub fn seek_channel_4(&self) -> Ev3Result<(i8, i8)>
Seeks a remote control in beacon mode on channel 4.
The first value is heading (-25 to 25), and the second value is distance as a percentage (-128 and 0 to 100).
The distance is -128 when the remote is out of range.
§Examples
let (heading, distance) = infrared_sensor.seek_channel_4()?;