From 8a23429e5f0bc76a3e3f6928a95dd7e75107d819 Mon Sep 17 00:00:00 2001 From: Zachary Sunforge Date: Tue, 9 Jul 2024 10:48:13 -0700 Subject: [PATCH] Added custom irradiance quantity --- src/circuit/mod.rs | 2 ++ src/{ => circuit}/resistive_divider.rs | 0 src/lib.rs | 4 ++-- src/uom.rs | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/circuit/mod.rs rename src/{ => circuit}/resistive_divider.rs (100%) create mode 100644 src/uom.rs diff --git a/src/circuit/mod.rs b/src/circuit/mod.rs new file mode 100644 index 0000000..aa258b0 --- /dev/null +++ b/src/circuit/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "resistive-divider")] +pub mod resistive_divider; \ No newline at end of file diff --git a/src/resistive_divider.rs b/src/circuit/resistive_divider.rs similarity index 100% rename from src/resistive_divider.rs rename to src/circuit/resistive_divider.rs diff --git a/src/lib.rs b/src/lib.rs index 94a73c5..dc334f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ pub mod control; pub mod error; pub mod adc; -#[cfg(feature = "resistive-divider")] -pub mod resistive_divider; +pub mod uom; +pub mod circuit; pub use error::CriticalError; diff --git a/src/uom.rs b/src/uom.rs new file mode 100644 index 0000000..955a205 --- /dev/null +++ b/src/uom.rs @@ -0,0 +1,16 @@ +//TODO: Everything in here is implemented standalone and not integrated with uom library because it is spawned from macro +// soup + has shit documentation and I cannot figure out how to add a custom unit to SI. This should be integrated with +// UoM + +#[derive(Copy, Clone, PartialEq, PartialOrd, Debug, Default)] +pub struct Irradiance(f32); + +pub fn watts_per_sq_meter(value: f32) -> Irradiance { + Irradiance(value) +} + +impl Irradiance { + fn to_watts_per_sq_meter(self) -> f32 { + self.0 + } +} \ No newline at end of file