refactor: simplify battery monitoring logic, remove unused fields, and replace BQ34Z100G1 integration with WCH I2C implementation
This commit is contained in:
@@ -2,6 +2,7 @@ use alloc::format;
|
||||
use alloc::string::{String, ToString};
|
||||
use core::convert::Infallible;
|
||||
use core::fmt;
|
||||
use core::fmt::Debug;
|
||||
use core::str::Utf8Error;
|
||||
use embassy_embedded_hal::shared_bus::I2cDeviceError;
|
||||
use embassy_executor::SpawnError;
|
||||
@@ -12,6 +13,7 @@ use esp_hal::pcnt::unit::{InvalidHighLimit, InvalidLowLimit};
|
||||
use esp_hal::twai::EspTwaiError;
|
||||
use esp_radio::wifi::WifiError;
|
||||
use ina219::errors::{BusVoltageReadError, ShuntVoltageReadError};
|
||||
use lib_bms_protocol::BmsProtocolError;
|
||||
use littlefs2_core::PathError;
|
||||
use onewire::Error;
|
||||
use pca9535::ExpanderError;
|
||||
@@ -19,6 +21,9 @@ use pca9535::ExpanderError;
|
||||
//All error superconstruct
|
||||
#[derive(Debug)]
|
||||
pub enum FatError {
|
||||
BMSError {
|
||||
error: String,
|
||||
},
|
||||
OneWireError {
|
||||
error: Error<Infallible>,
|
||||
},
|
||||
@@ -100,6 +105,7 @@ impl fmt::Display for FatError {
|
||||
write!(f, "CanBusError {error:?}")
|
||||
}
|
||||
FatError::SNTPError { error } => write!(f, "SNTPError {error:?}"),
|
||||
FatError::BMSError { error } => write!(f, "BMSError, {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,3 +322,14 @@ impl From<sntpc::Error> for FatError {
|
||||
FatError::SNTPError { error: value }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl From<BmsProtocolError> for FatError{
|
||||
fn from(value: BmsProtocolError) -> Self {
|
||||
match value {
|
||||
BmsProtocolError::I2cCommunicationError => {
|
||||
FatError::String{error: "I2C communication error".to_string()}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user