42 lines
763 B
Rust
42 lines
763 B
Rust
use crate::hardware::mcp23017::Mcp23017;
|
|
use anyhow::Result;
|
|
|
|
pub trait Hardware {
|
|
|
|
fn get_mcp23017_a(&self) -> impl Mcp23017;
|
|
fn get_mcp23017_b(&self) -> impl Mcp23017;
|
|
|
|
fn get_battery_voltage(&self) -> Result<f64>;
|
|
}
|
|
|
|
// impl Hardware for () {
|
|
// fn get_i2c0_bus(&self) -> impl I2c {
|
|
// panic!()
|
|
// }
|
|
// }
|
|
|
|
#[cfg(feature = "raspi")]
|
|
mod raspi;
|
|
|
|
#[cfg(feature = "raspi")]
|
|
pub fn initialize() -> Result<impl Hardware> {
|
|
raspi::RaspiHardware::new()
|
|
}
|
|
|
|
#[cfg(not(feature = "raspi"))]
|
|
#[allow(unreachable_code)]
|
|
pub fn initialize() -> Result<impl Hardware> {
|
|
panic!("Can not Initialize");
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(not(feature = "raspi"))]
|
|
mod bno085;
|
|
#[cfg(not(feature = "raspi"))]
|
|
mod imu;
|
|
mod error;
|
|
|
|
pub mod mcp23017;
|
|
mod mcp3208;
|