Skip to content

Commit

Permalink
finding the bad u8
Browse files Browse the repository at this point in the history
  • Loading branch information
Aux1r committed Nov 16, 2024
1 parent a27d3e7 commit db47381
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions lib/sensors/src/tof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ impl<'a, T: HypedI2c> TimeOfFlight<'a, T> {
pub fn new(i2c: &'a mut T, device_address: ToFAddresses) -> Result<Self, ToFError> {
// SR03 Settings as seen in Application Sheet
let device_address = device_address as u8;
for (reg, val) in PRIVATE_REGISTERS_u8 {
// writing to private registers
if let Err(e) = i2c.write_byte_to_register(
device_address,
reg,
val,
) {
panic!("Error writing private registers u8s");
}
}
for (reg,val) in PRIVATE_REGISTERS_u16 {
// writing to private registers u16
if let Err(e) = i2c.write_byte_to_register_16(
Expand Down Expand Up @@ -243,17 +233,10 @@ mod tests {
let i2c_values = FnvIndexMap::new();
let mut i2c = MockI2c::new(i2c_values);
let _ = TimeOfFlight::new(&mut i2c, ToFAddresses::Address29);
for (reg,val) in PRIVATE_REGISTERS_u8 {
assert_eq!(
i2c.get_writes()
.get(&(ToFAddresses::Address29 as u8, reg.into())),
Some(&Some(val))
)
}
for (reg,val) in PRIVATE_REGISTERS_u16 {
assert_eq!(
i2c.get_writes()
.get(&(ToFAddresses::Address29 as u8, reg.into())),
.get(&(ToFAddresses::Address29 as u8, reg)),
Some(&Some(val))
)
}
Expand Down

0 comments on commit db47381

Please sign in to comment.