pub struct EcProbe { /* private fields */ }
Implementations
sourceimpl EcProbe
impl EcProbe
sourcepub fn new(
filename: &'static str,
address: u16
) -> Result<Self, Box<LinuxI2CError>>
pub fn new(
filename: &'static str,
address: u16
) -> Result<Self, Box<LinuxI2CError>>
Create a new EcProbe object
Pass the i2c port to use, it must be a software overlay device, and I2C address.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
sourcepub fn measure_temp(&mut self) -> Result<f32, Box<LinuxI2CError>>
pub fn measure_temp(&mut self) -> Result<f32, Box<LinuxI2CError>>
Start a temperature measurement
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.measure_temp();
sourcepub fn set_temp(&mut self, temp_c: f32) -> Result<(), Box<LinuxI2CError>>
pub fn set_temp(&mut self, temp_c: f32) -> Result<(), Box<LinuxI2CError>>
Sets the temperature used by the device.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.set_temp(20.2);
sourcepub fn calibrate_ec(
&mut self,
solution_ec: f32
) -> Result<(), Box<LinuxI2CError>>
pub fn calibrate_ec(
&mut self,
solution_ec: f32
) -> Result<(), Box<LinuxI2CError>>
Calibrates the EC range of measurement, in mS, and saves them in the devices’s EEPROM.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.calibrate_ec(2.0);
sourcepub fn calibrate_sw(
&mut self,
solution_sw: f32
) -> Result<(), Box<LinuxI2CError>>
pub fn calibrate_sw(
&mut self,
solution_sw: f32
) -> Result<(), Box<LinuxI2CError>>
Calibrates the SW range of measurements, in mS, and saves them in the devices’s EEPROM.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.calibrate_sw(53.0);
sourcepub fn measure_ec(&mut self, new_temp: bool) -> Result<f32, Box<LinuxI2CError>>
pub fn measure_ec(&mut self, new_temp: bool) -> Result<f32, Box<LinuxI2CError>>
Starts an EC measurement, taking a new temp measurement if true passed
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.measure_ec(true);
sourcepub fn measure_raw(&mut self) -> Result<f32, Box<LinuxI2CError>>
pub fn measure_raw(&mut self) -> Result<f32, Box<LinuxI2CError>>
Starts a raw measurement.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.measure_raw(true);
sourcepub fn measure_sw(&mut self) -> Result<f32, Box<LinuxI2CError>>
pub fn measure_sw(&mut self) -> Result<f32, Box<LinuxI2CError>>
Starts an SW measurement and returns the salinity in PSU.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.measure_salinity();
sourcepub fn set_temp_constant(
&mut self,
temp_constant: u8
) -> Result<(), Box<LinuxI2CError>>
pub fn set_temp_constant(
&mut self,
temp_constant: u8
) -> Result<(), Box<LinuxI2CError>>
Sets the temperature constant to use for compensation and saves it in the devices’s EEPROM.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.set_temp_constant(20);
sourcepub fn get_temp_constant(&mut self) -> Result<u8, Box<LinuxI2CError>>
pub fn get_temp_constant(&mut self) -> Result<u8, Box<LinuxI2CError>>
Returns the temperature constant from the device.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.get_temp_constant();
sourcepub fn get_calibration_ec(&mut self) -> Result<f32, Box<LinuxI2CError>>
pub fn get_calibration_ec(&mut self) -> Result<f32, Box<LinuxI2CError>>
Returns the dual-point calibration low reference value.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.set_dual_point_calibration(50.0, 0.0, 0.0, 0.0);
assert_eq!(50.0, ec.get_calibrate_low_reference().unwrap());
sourcepub fn get_calibration_sw(&mut self) -> Result<f32, Box<LinuxI2CError>>
pub fn get_calibration_sw(&mut self) -> Result<f32, Box<LinuxI2CError>>
Returns the dual-point calibration low reading value.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.set_dual_point_calibration(0.0, 0.0, 34.0, 0.0);
assert_eq!(34.0, ec.get_calibrate_low_reading().unwrap());
sourcepub fn read_eeprom(&mut self, address: f32) -> Result<f32, Box<LinuxI2CError>>
pub fn read_eeprom(&mut self, address: f32) -> Result<f32, Box<LinuxI2CError>>
Returns the dual-point calibration low reference value.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.set_dual_point_calibration(50.0, 0.0, 0.0, 0.0);
assert_eq!(50.0, ec.get_calibrate_low_reference().unwrap());
sourcepub fn write_eeprom(
&mut self,
address: f32,
value: f32
) -> Result<f32, Box<LinuxI2CError>>
pub fn write_eeprom(
&mut self,
address: f32,
value: f32
) -> Result<f32, Box<LinuxI2CError>>
Returns the dual-point calibration low reference value.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.set_dual_point_calibration(50.0, 0.0, 0.0, 0.0);
assert_eq!(50.0, ec.get_calibrate_low_reference().unwrap());
sourcepub fn use_temperature_compensation(
&mut self,
b: bool
) -> Result<(), Box<LinuxI2CError>>
pub fn use_temperature_compensation(
&mut self,
b: bool
) -> Result<(), Box<LinuxI2CError>>
Configures the device to use temperature compensation or not.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.use_temperature_compensation(true);
assert_eq!(1, ec.using_temperature_compensation().unwrap());
sourcepub fn get_version(&mut self) -> Result<u8, Box<LinuxI2CError>>
pub fn get_version(&mut self) -> Result<u8, Box<LinuxI2CError>>
Returns the firmware version of the device.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
assert_eq!(0x1c, ec.get_version().unwrap());
sourcepub fn get_firmware(&mut self) -> Result<u8, Box<LinuxI2CError>>
pub fn get_firmware(&mut self) -> Result<u8, Box<LinuxI2CError>>
Returns the firmware version of the device.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
assert_eq!(0x1c, ec.get_version().unwrap());
sourcepub fn reset(&mut self) -> Result<(), Box<LinuxI2CError>>
pub fn reset(&mut self) -> Result<(), Box<LinuxI2CError>>
Resets all the stored calibration information.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.reset();
assert_eq!(true, ec.get_calibrate_offset().unwrap().is_nan());
assert_eq!(true, ec.get_calibrate_low_reading().unwrap().is_nan());
assert_eq!(true, ec.get_calibrate_high_reading().unwrap().is_nan());
assert_eq!(true, ec.get_calibrate_low_reference().unwrap().is_nan());
assert_eq!(true, ec.get_calibrate_high_reference().unwrap().is_nan());
sourcepub fn using_temperature_compensation(
&mut self
) -> Result<u8, Box<LinuxI2CError>>
pub fn using_temperature_compensation(
&mut self
) -> Result<u8, Box<LinuxI2CError>>
Configures the device to use temperature compensation.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
ec.use_temperature_compensation(true);
assert_eq!(1, ec.using_temperature_compensation().unwrap());
sourcepub fn set_i2c_address(
&mut self,
i2c_address: u8
) -> Result<(), Box<LinuxI2CError>>
pub fn set_i2c_address(
&mut self,
i2c_address: u8
) -> Result<(), Box<LinuxI2CError>>
Sets the I2C address of the device.
Example
let mut ec = ufire_ec::EcProbe::new("/dev/i2c-3", 0x3c).unwrap();
// ec.set_i2c_address(0x4f);