Skip to content

Unable to use block!(adc.read(...)) #34

@urc-ELIT

Description

@urc-ELIT

I have this code:

  pub fn try_new(i2c_name: &str, channel: Sender<SelectorsEvent>) -> Result<Self> {
      let i2c = I2cdev::new(i2c_name)?;
      let mut adc = Ads1x1x::new_ads1015(i2c, TargetAddr::default());

      let value = block!(adc.read(channel::DifferentialA0A1)).unwrap();

      //TODO: Setup the ADC configuration

      Ok(Self{adc, channel})
  }

but on the line block!(adc.read(channel::DifferentialA0A1)).unwrap() I get this error: expected a pattern, found a function call function calls are not allowed in patterns, why?

Toml:

[dependencies]
linux-embedded-hal = "0.4.0"
ads1x1x = "0.3.0"
nb = "1.1.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions