From 19b8bc607cbd154567c016b775de0e594aa18a3e Mon Sep 17 00:00:00 2001 From: Zachary Sunforge Date: Tue, 13 Jun 2023 22:46:34 -0700 Subject: [PATCH] Core traits. --- node/Cargo.toml | 5 +++- node/src/transducer/mod.rs | 24 ++++++++++++++----- peripheral-components/ads1256/node/Cargo.toml | 5 +--- src/transducer/mod.rs | 2 +- src/transducer/output.rs | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/node/Cargo.toml b/node/Cargo.toml index 7eb900a..644cde8 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -16,4 +16,7 @@ workspace = true [dependencies.defmt] workspace = true [dependencies.uom] -workspace = true \ No newline at end of file +workspace = true +[dependencies.embassy-sync] +workspace = true +optional = true \ No newline at end of file diff --git a/node/src/transducer/mod.rs b/node/src/transducer/mod.rs index b0a4544..5a37c76 100644 --- a/node/src/transducer/mod.rs +++ b/node/src/transducer/mod.rs @@ -3,13 +3,25 @@ mod output; pub use physical::transducer::*; -// --------------------------------------------------------------------------------------------------------------------- -// ----- Publisher ------------------------ -// --------------------------------------------------------------------------------------------------------------------- +#[cfg(feature = "embassy-sync")] +use embassy_sync::blocking_mutex::raw::RawMutex; +#[cfg(feature = "embassy-sync")] +use embassy_sync::pubsub; +#[cfg(feature = "embassy-sync")] +use embassy_sync::pubsub::Subscriber; + #[cfg(feature = "embassy-sync")] pub trait Publisher { type Value: Copy; + type Mutex: RawMutex; + const CAPACITY: usize; + const NUM_SUBS: usize; + const NUM_PUBS: usize; - - fn subscribe() -> SubT; -} \ No newline at end of file + fn subscribe( + &self, + ) -> Result< + Subscriber, + pubsub::Error, + >; +} diff --git a/peripheral-components/ads1256/node/Cargo.toml b/peripheral-components/ads1256/node/Cargo.toml index 76d72d0..b4aa150 100644 --- a/peripheral-components/ads1256/node/Cargo.toml +++ b/peripheral-components/ads1256/node/Cargo.toml @@ -23,7 +23,4 @@ workspace = true [dependencies.defmt] workspace = true [dependencies.uom] -workspace = true -[dependencies.embassy-sync] -workspace = true -optional = true \ No newline at end of file +workspace = true \ No newline at end of file diff --git a/src/transducer/mod.rs b/src/transducer/mod.rs index ac4c6a2..d3986f6 100644 --- a/src/transducer/mod.rs +++ b/src/transducer/mod.rs @@ -6,5 +6,5 @@ pub mod output; pub trait Stateful { type Value: Copy; - fn state() -> Self::Value; + fn state(&self) -> Self::Value; } diff --git a/src/transducer/output.rs b/src/transducer/output.rs index 1c7180f..989830e 100644 --- a/src/transducer/output.rs +++ b/src/transducer/output.rs @@ -3,5 +3,5 @@ pub trait Output { //TODO: return result //TODO: Make maybe async - fn set(setting: Self::Value); + fn set(&mut self, setting: Self::Value); } \ No newline at end of file