Switched to preferred calling syntax for UoM.

This commit is contained in:
Zachary Sunforge
2024-02-23 10:23:18 -08:00
parent 01280c79fe
commit 581be0f71d
2 changed files with 32 additions and 32 deletions

View File

@ -1,21 +1,21 @@
use crate::transducer::InvalidValue;
use uom::si::electric_potential::volt;
use uom::si::f32;
use uom::si::quantities::{ElectricPotential, ThermodynamicTemperature};
use uom::si::thermodynamic_temperature::degree_celsius;
const MIN_VOLTS: f32 = -0.55;
const MAX_VOLTS: f32 = 1.50;
const SCALE_FACTOR: f32 = 100.0;
#[inline]
pub fn convert(
voltage: f32::ElectricPotential,
) -> Result<f32::ThermodynamicTemperature, InvalidValue> {
voltage: ElectricPotential<f32>,
) -> Result<ThermodynamicTemperature<f32>, InvalidValue> {
const MIN_VOLTS: f32 = -0.55;
const MAX_VOLTS: f32 = 1.50;
const SCALE_FACTOR: f32 = 100.0;
let volts = voltage.get::<volt>();
if volts >= MIN_VOLTS && volts <= MAX_VOLTS {
let celsius = volts * SCALE_FACTOR;
Ok(f32::ThermodynamicTemperature::new::<degree_celsius>(celsius))
Ok(ThermodynamicTemperature::new::<degree_celsius>(celsius))
} else {
Err(InvalidValue)
}