From e69a5a6dd76bca1ee2b50124859fee4a841285c4 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Fri, 24 Apr 2020 09:32:35 +0200 Subject: Fix read function --- examples/typed.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples') 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, 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() { -- cgit v1.2.3-54-g00ecf