Example cleanup
This commit is contained in:
@ -3,20 +3,17 @@
|
||||
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
||||
|
||||
use core::cell::Cell;
|
||||
use cortex_m::prelude::{
|
||||
_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs,
|
||||
};
|
||||
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||
|
||||
use ads1256::standard::input::SingleEnded;
|
||||
use ads1256::{
|
||||
AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState,
|
||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer,
|
||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
||||
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DataRate, DigitalIo,
|
||||
DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status,
|
||||
};
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use embassy_time::Delay;
|
||||
use executor::Spawner;
|
||||
use stm32::dma::NoDma;
|
||||
use stm32::exti::ExtiInput;
|
||||
@ -30,7 +27,7 @@ use uom::si::f32;
|
||||
|
||||
use defmt::{debug, error, info, trace, unwrap};
|
||||
use embassy_executor::_export::StaticCell;
|
||||
use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3};
|
||||
use embassy_stm32::peripherals::{PF6, PF7, SPI3};
|
||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy_sync::pubsub::PubSubChannel;
|
||||
use physical_node::transducer::{Publish, StatefulPublisher};
|
||||
|
@ -3,19 +3,16 @@
|
||||
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
||||
|
||||
use core::cell::Cell;
|
||||
use core::ops::DerefMut;
|
||||
use cortex_m::prelude::{
|
||||
_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs,
|
||||
};
|
||||
|
||||
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||
|
||||
use ads1256::standard::input::SingleEnded;
|
||||
use ads1256::{
|
||||
AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState,
|
||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer,
|
||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
||||
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DState, DataRate, DigitalIo,
|
||||
DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status,
|
||||
};
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use executor::Spawner;
|
||||
@ -29,7 +26,7 @@ use stm32::{pac, spi};
|
||||
use uom::si::electric_potential::volt;
|
||||
use uom::si::f32;
|
||||
|
||||
use defmt::{debug, error, info, trace, unwrap};
|
||||
use defmt::info;
|
||||
use embassy_executor::_export::StaticCell;
|
||||
use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3};
|
||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||
|
@ -2,21 +2,18 @@
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
||||
|
||||
use core::cell::Cell;
|
||||
use cortex_m::prelude::{
|
||||
_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs,
|
||||
};
|
||||
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||
// Necessary unused import.
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||
|
||||
use ads1256::standard::input::{Differential, SingleEnded};
|
||||
use ads1256::{
|
||||
AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState,
|
||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer,
|
||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
||||
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DataRate, DigitalIo,
|
||||
DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status,
|
||||
};
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use embassy_time::Delay;
|
||||
use executor::Spawner;
|
||||
use stm32::dma::NoDma;
|
||||
use stm32::exti::ExtiInput;
|
||||
@ -26,9 +23,8 @@ use stm32::time::Hertz;
|
||||
use stm32::{pac, spi};
|
||||
|
||||
use uom::si::electric_potential::{millivolt, volt};
|
||||
use uom::si::f32;
|
||||
|
||||
use defmt::{debug, error, info, trace, unwrap};
|
||||
use defmt::info;
|
||||
use physical::transducer::{lm35, thermocouple_k};
|
||||
use uom::si::thermodynamic_temperature::degree_celsius;
|
||||
|
||||
@ -88,7 +84,7 @@ async fn main(spawner: Spawner) {
|
||||
ads_1256.self_calibrate(&mut spi).await.unwrap();
|
||||
|
||||
loop {
|
||||
let gain = Gain::X4;
|
||||
let gain = Gain::X2;
|
||||
let reference = ads_1256
|
||||
.autocal_convert(
|
||||
&mut spi,
|
||||
@ -101,9 +97,13 @@ async fn main(spawner: Spawner) {
|
||||
.await
|
||||
.unwrap()
|
||||
.to_voltage(gain);
|
||||
let reference_volts = reference.get::<volt>();
|
||||
let reference = lm35::convert(reference).unwrap();
|
||||
let reference_celsius = reference.get::<degree_celsius>();
|
||||
info!("Reference junction temperature: {}°C", reference_celsius);
|
||||
info!(
|
||||
"Reference junction temperature: {}°C, from voltage reading: {}V",
|
||||
reference_celsius, reference_volts
|
||||
);
|
||||
|
||||
let gain = Gain::X64;
|
||||
let voltage = ads_1256
|
||||
@ -121,6 +121,6 @@ async fn main(spawner: Spawner) {
|
||||
let mv = voltage.get::<millivolt>();
|
||||
let temperature = thermocouple_k::convert_direct(voltage, reference).unwrap();
|
||||
let celsius = temperature.get::<degree_celsius>();
|
||||
info!("Thermocouple temperature: {}°C, millivolts: {}", celsius, mv);
|
||||
info!("Thermocouple temperature: {}°C, from reading: {}mV", celsius, mv);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user