use serde::{Serialize, Deserialize};
pub mod cn7500;
pub mod str1;
pub mod waveshare;
pub mod wavesharev2;
pub use cn7500::CN7500;
pub use str1::STR1;
pub use waveshare::Waveshare;
pub use wavesharev2::WaveshareV2;
pub use crate::state::BinaryState;
pub use crate::drivers::InstrumentError;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum Controller {
STR1,
CN7500,
Waveshare,
WaveshareV2
}
impl std::fmt::Display for Controller {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::CN7500 => write!(f, "CN7500"),
Self::STR1 => write!(f, "STR1"),
Self::Waveshare => write!(f, "Waveshare"),
Self::WaveshareV2 => write!(f, "WaveshareV2")
}
}
}
impl<T: AsRef<str>> From<T> for Controller {
fn from(value: T) -> Self {
match value.as_ref() {
"STR1" => Self::STR1,
"CN7500" => Self::CN7500,
"Waveshare" => Self::Waveshare,
"WaveshareV2" => Self::WaveshareV2,
_ => panic!("`{}` is not a valid controller name", value.as_ref())
}
}
}