Switch to fully composition based Transducers.

This commit is contained in:
Zachary Sunforge
2023-06-17 10:41:20 -07:00
parent ad66d8e030
commit 60e0edf7d2
6 changed files with 116 additions and 105 deletions

View File

@ -33,8 +33,8 @@ use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3};
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::pubsub::PubSubChannel;
use physical_ads1256::{standard_input, SingleEnded};
use physical_node::transducer::input::RawStatePubInput;
use physical_node::transducer::Publisher;
use physical_node::transducer::input::StatefulPublisher;
use physical_node::transducer::Publish;
const AUTOCAL_CONF: Config = Config {
status: Status::setting(Buffer::Enabled, AutoCal::Enabled, BitOrder::MostSigFirst),
@ -58,9 +58,9 @@ impl ads1256::BlockingDelay for Ads1256Delay {
}
struct Inputs {
ai1: RawStatePubInput<f32::ElectricPotential, NoopRawMutex, 10, 1>,
ai2: RawStatePubInput<f32::ElectricPotential, NoopRawMutex, 10, 1>,
ai3: RawStatePubInput<f32::ElectricPotential, NoopRawMutex, 10, 1>,
ai1: StatefulPublisher<f32::ElectricPotential, NoopRawMutex, 10, 1>,
ai2: StatefulPublisher<f32::ElectricPotential, NoopRawMutex, 10, 1>,
ai3: StatefulPublisher<f32::ElectricPotential, NoopRawMutex, 10, 1>,
}
// Inputs
@ -101,17 +101,17 @@ async fn main(spawner: Spawner) {
let ads_1256 = ADS_1256.init(Ads1256::new(Ads1256Delay, select_ads1256, ads1256_data_ready));
let inputs = &*ANALOG_INPUTS.init(Inputs {
ai1: RawStatePubInput::new(
Cell::new(f32::ElectricPotential::new::<volt>(-1000.0)),
PubSubChannel::new(),
ai1: StatefulPublisher::new(
Cell::new(f32::ElectricPotential::new::<volt>(-1000.0)).into(),
PubSubChannel::new().into(),
),
ai2: RawStatePubInput::new(
Cell::new(f32::ElectricPotential::new::<volt>(-1000.0)),
PubSubChannel::new(),
ai2: StatefulPublisher::new(
Cell::new(f32::ElectricPotential::new::<volt>(-1000.0)).into(),
PubSubChannel::new().into(),
),
ai3: RawStatePubInput::new(
Cell::new(f32::ElectricPotential::new::<volt>(-1000.0)),
PubSubChannel::new(),
ai3: StatefulPublisher::new(
Cell::new(f32::ElectricPotential::new::<volt>(-1000.0)).into(),
PubSubChannel::new().into(),
),
});