Initial node implementation (#4)

Reviewed-on: #4
Co-authored-by: Zack <zack@bfpower.io>
Co-committed-by: Zack <zack@bfpower.io>
This commit is contained in:
2023-07-19 18:09:13 +00:00
committed by Zachary Sunforge
parent 886fbf0020
commit 6fc828e864
40 changed files with 2079 additions and 44 deletions

View File

@ -0,0 +1,22 @@
use crate::transducer::InvalidValue;
use uom::si::electric_potential::volt;
use uom::si::f32;
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> {
let volts = voltage.get::<volt>();
if volts >= MIN_VOLTS && volts <= MAX_VOLTS {
let celsius = volts * SCALE_FACTOR;
Ok(f32::ThermodynamicTemperature::new::<degree_celsius>(celsius))
} else {
Err(InvalidValue)
}
}