Compare commits
3 Commits
55ab8bcccf
...
9c363e3760
| Author | SHA1 | Date | |
|---|---|---|---|
|
9c363e3760
|
|||
|
8be98b9447
|
|||
|
1d29f3ea5f
|
@@ -28,7 +28,7 @@ pub trait BatteryInteraction {
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct BatteryInfo {
|
||||
pub voltage_mv: Option<u16>,
|
||||
pub current_ma: Option<i16>,
|
||||
pub avg_current_ma: Option<i16>,
|
||||
pub soc_pct: Option<f32>,
|
||||
pub soh_pct: Option<u16>,
|
||||
pub temperature_c: Option<u16>,
|
||||
@@ -183,7 +183,7 @@ impl BatteryInteraction for BQ34Z100G1 {
|
||||
async fn get_battery_state(&mut self) -> FatResult<BatteryState> {
|
||||
Ok(BatteryState::Info(BatteryInfo {
|
||||
voltage_mv: Some(self.voltage_milli_volt().await?),
|
||||
current_ma: Some(self.average_current_milli_ampere().await?),
|
||||
avg_current_ma: Some(self.average_current_milli_ampere().await?),
|
||||
soc_pct: Some(self.state_charge_percent().await?),
|
||||
soh_pct: Some(self.state_health_percent().await?),
|
||||
temperature_c: Some(self.bat_temperature().await?),
|
||||
|
||||
@@ -866,7 +866,7 @@ async fn publish_battery_state(
|
||||
Ok(BatteryState::Info(info)) => info,
|
||||
Ok(BatteryState::Unknown) => BatteryInfo {
|
||||
voltage_mv: None,
|
||||
current_ma: None,
|
||||
avg_current_ma: None,
|
||||
soc_pct: None,
|
||||
soh_pct: None,
|
||||
temperature_c: None,
|
||||
@@ -877,7 +877,7 @@ async fn publish_battery_state(
|
||||
},
|
||||
Err(e) => BatteryInfo {
|
||||
voltage_mv: None,
|
||||
current_ma: None,
|
||||
avg_current_ma: None,
|
||||
soc_pct: None,
|
||||
soh_pct: None,
|
||||
temperature_c: None,
|
||||
|
||||
@@ -144,13 +144,13 @@ impl TankState {
|
||||
warn_level,
|
||||
volume_ml: left_ml,
|
||||
sensor_error: tank_err,
|
||||
raw,
|
||||
fill_raw_v: raw,
|
||||
water_frozen: water_temp
|
||||
.as_ref()
|
||||
.is_ok_and(|temp| *temp < WATER_FROZEN_THRESH),
|
||||
water_temp_c: water_temp.as_ref().copied().ok(),
|
||||
temp_sensor_error: water_temp.as_ref().err().map(|err| err.to_string()),
|
||||
pct: percent,
|
||||
fill_pct: percent,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,9 +184,9 @@ pub struct TankInfo {
|
||||
/// if there is an issue with the water level sensor
|
||||
pub(crate) sensor_error: Option<TankError>,
|
||||
/// raw water sensor value
|
||||
pub(crate) raw: Option<f32>,
|
||||
pub(crate) fill_raw_v: Option<f32>,
|
||||
/// percent value
|
||||
pub(crate) pct: Option<f32>,
|
||||
pub(crate) fill_pct: Option<f32>,
|
||||
/// water in the tank might be frozen
|
||||
pub(crate) water_frozen: bool,
|
||||
/// water temperature
|
||||
|
||||
Reference in New Issue
Block a user