Open David-OConnor opened 4 years ago
Sorted out. This was partially due to an issue I can't identify, where I was using an older version of the package. I still think this would be useful. For stm32f3:
use hal::{
gpio::gpioc::PCx,
gpio::{OpenDrain, Output},
};
/// Read the temperature, from the appropriate source.
/// todo: Consider making fallible.
fn read_temp(
temp_sensor: &mut DS18B20,
one_w: &mut OneWire<PCx<Output<OpenDrain>>>,
delay: &mut Delay,
) -> f32 {
// request sensor to measure temperature
let resolution = s.measure_temperature(one_w, delay).unwrap();
delay.delay_ms(resolution.time_ms());
// read temperature
let temp = temp_sensor.read_temperature(one_w, delay).unwrap();
temp_from_ds(temp)
}
Eg:
This doesn't work due to needing the
Debug
trait onOneWire
: