diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2020-04-24 09:32:35 +0200 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2020-04-24 09:32:35 +0200 |
commit | e69a5a6dd76bca1ee2b50124859fee4a841285c4 (patch) | |
tree | 8da3f1aba21180ac010fda3288ab0d1de662934f | |
parent | 6311327dfef06b8f52e0a5baebb8228986e14ff6 (diff) | |
download | ads1x1x-async-e69a5a6dd76bca1ee2b50124859fee4a841285c4.tar.gz ads1x1x-async-e69a5a6dd76bca1ee2b50124859fee4a841285c4.tar.xz ads1x1x-async-e69a5a6dd76bca1ee2b50124859fee4a841285c4.zip |
Fix read function
-rw-r--r-- | examples/typed.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/typed.rs b/examples/typed.rs index a37a04f..1a2e1e7 100644 --- a/examples/typed.rs +++ b/examples/typed.rs @@ -19,9 +19,10 @@ use linux_embedded_hal::I2cdev; type Adc = Ads1x1x<I2cInterface<I2cdev>, Ads1115, Resolution16Bit, ads1x1x::mode::OneShot>; -/// Read a single value from channel A -pub fn read(adc: &mut Adc) -> f32 { - block!(adc.read(&mut SingleA0)); +/// Read a single value from channel A. +/// Returns 0 on Error. +pub fn read(adc: &mut Adc) -> i16 { + block!(adc.read(&mut SingleA0)).unwrap_or(0) } fn main() { |