Changes to Derive(PollVariants) to accept any path for the value type.

This commit is contained in:
Zachary Sunforge
2023-06-23 14:15:43 -07:00
parent 8f2d2b6679
commit 07cb49bee5
5 changed files with 63 additions and 30 deletions

View File

@ -8,7 +8,7 @@ readme.workspace = true
license.workspace = true
[features]
embassy-sync = ["dep:embassy-sync", "ads1256/embassy-sync"]
embassy-sync = ["dep:embassy-sync", "ads1256/embassy-sync", "physical-node/embassy-sync"]
poll = ["standard-multiplexer", "embassy-sync"]
config = ["physical-ads1256-types/config"]
standard-input = ["physical-ads1256-types/standard-input"]

View File

@ -1,11 +1,15 @@
use core::ops::DerefMut;
use ads1256::{
AdControl, Ads1256, BlockingDelay, DataRate, Multiplexer, OutputPin, SpiBus, Status, Wait,
};
use core::ops::DerefMut;
use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::mutex::Mutex;
use node_poll_variants::PollVariants;
use physical_node::transducer::input::Poll;
use uom::si::f32;
#[derive(PollVariants)]
#[value_type = "f32::ElectricPotential"]
pub struct AutocalPoll<'a, DeviceMutexT, ModInT, DelayerT, SST, DrdyT, SpiT>
where
DeviceMutexT: RawMutex,
@ -30,10 +34,22 @@ where
DrdyT: Wait,
SpiT: SpiBus,
{
type Value = ();
type Value = f32::ElectricPotential;
async fn poll(&self) -> Self::Value {
todo!()
self.ads1256
.lock()
.await
.deref_mut()
.autocal_convert_m(
self.spi,
self.input_mod.multiplexer(),
self.input_mod.status(),
self.input_mod.ad_control(),
self.input_mod.data_rate(),
true,
)
.await
}
}