summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2020-04-24 09:32:35 +0200
committerDiego Barrios Romero <eldruin@gmail.com>2020-04-24 09:32:35 +0200
commite69a5a6dd76bca1ee2b50124859fee4a841285c4 (patch)
tree8da3f1aba21180ac010fda3288ab0d1de662934f /examples
parent6311327dfef06b8f52e0a5baebb8228986e14ff6 (diff)
downloadads1x1x-async-e69a5a6dd76bca1ee2b50124859fee4a841285c4.tar.gz
ads1x1x-async-e69a5a6dd76bca1ee2b50124859fee4a841285c4.tar.xz
ads1x1x-async-e69a5a6dd76bca1ee2b50124859fee4a841285c4.zip
Fix read function
Diffstat (limited to 'examples')
-rw-r--r--examples/typed.rs7
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() {