Skip to content

Commit

Permalink
more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Apr 3, 2024
1 parent 3228ac0 commit c50a809
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 1 addition & 2 deletions sfy-buoy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sfy-buoy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ism330dhcx = { git = "https://github.com/gauteh/ism330dhcx", branch = "gyro-acce
cmsis_dsp = { git = "https://github.com/samcrow/cmsis_dsp.rs" }
embedded-sdmmc = { git = "https://github.com/rust-embedded-community/embedded-sdmmc-rs", rev="3b5c026d" }
one-wire-bus = { path = "../../../../dev/embedded/one-wire-bus" }
ds18b20 = { path = "../../../../dev/embedded/ds18b20" }
# embedded-sdmmc = { git = "https://github.com/gauteh/embedded-sdmmc-rs", branch = "sdmmc-spi-borrow" }
# embedded-sdmmc = { path = "../../../../dev/embedded/embedded-sdmmc-rs" }

Expand Down
16 changes: 10 additions & 6 deletions sfy-buoy/src/temp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use core::convert::Infallible;
use core::fmt::Debug;
use core::marker::PhantomData;
use embedded_hal::blocking::delay::{DelayMs, DelayUs};
use embedded_hal::digital::v2::{InputPin, OutputPin};

Expand All @@ -16,8 +18,10 @@ enum TempsState {
Failed(i64), // failure, with timestamp (millis) since failure
}

pub struct Temps<P: OutputPin<Error = E> + InputPin<Error = E>, E: Debug> {
wire: OneWire<P>,
type E = Infallible;

pub struct Temps {
wire: OneWire,
probes: Vec<Probe, MAX_PROBES>,
resolution: ds18b20::Resolution,
state: TempsState,
Expand All @@ -28,11 +32,11 @@ pub struct Probe {
pub sensor: ds18b20::Ds18b20,
}

impl<P: OutputPin<Error = E> + InputPin<Error = E>, E: Debug> Temps<P, E> {
impl Temps {
/// Scan for devices, init and set up logging.
///
/// Can be re-run to reset.
pub fn new(w: P, delay: &mut impl DelayUs<u16>) -> Result<Temps<P, E>, OneWireError<E>> {
pub fn new(w: one_wire_bus::TI, delay: &mut impl DelayUs<u16>) -> Result<Temps, OneWireError<E>> {
defmt::info!("setting up temperature sensors..");
let mut wire = OneWire::new(w)?;
let resolution = ds18b20::Resolution::Bits12;
Expand Down Expand Up @@ -151,9 +155,9 @@ impl<P: OutputPin<Error = E> + InputPin<Error = E>, E: Debug> Temps<P, E> {
}

impl Probe {
pub fn new<P: OutputPin<Error = E> + InputPin<Error = E>, E: Debug>(
pub fn new(
address: Address,
wire: &mut OneWire<P>,
wire: &mut OneWire,
resolution: ds18b20::Resolution,
delay: &mut impl DelayUs<u16>,
) -> Result<Probe, OneWireError<E>> {
Expand Down
6 changes: 3 additions & 3 deletions sfy-buoy/target-test/tests/temp_sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ mod tests {
let mut led = pins.d19.into_push_pull_output();

// pin D8 (on artemis nano)
// let mut tp = pins.d8.into_input_output();
let mut tp = pins.d10.into_input_output();
let mut tp = pins.d8.into_input();
// let mut tp = pins.d10.into_input_output();
// tp.internal_pull_up(true);
tp.open_drain();
// tp.open_drain();
// tp.set_high().ok();
// assert_eq!(tp.is_high().unwrap(), true);

Expand Down

0 comments on commit c50a809

Please sign in to comment.