Remove TryFrom in order to build with stable
This commit is contained in:
parent
bccb2eac61
commit
287e673761
4 changed files with 1 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -44,7 +44,6 @@ name = "bme680-rs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"embedded-hal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"embedded-hal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"i2cdev 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"i2cdev 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"linux-embedded-hal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"linux-embedded-hal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -5,7 +5,6 @@ authors = ["marcelbuesing <buesing.marcel@googlemail.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
byteorder = "1.2"
|
|
||||||
embedded-hal = "0.2"
|
embedded-hal = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
//extern crate i2cdev;
|
|
||||||
extern crate embedded_hal;
|
extern crate embedded_hal;
|
||||||
extern crate linux_embedded_hal as hal;
|
extern crate linux_embedded_hal as hal;
|
||||||
extern crate bme680_rs;
|
extern crate bme680_rs;
|
||||||
|
|
||||||
//use i2cdev::linux::LinuxI2CDevice;
|
|
||||||
use bme680_rs::*;
|
use bme680_rs::*;
|
||||||
use std::io;
|
|
||||||
use hal::*;
|
use hal::*;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::result;
|
use std::result;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
#![feature(try_from)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
extern crate embedded_hal as hal;
|
extern crate embedded_hal as hal;
|
||||||
|
|
||||||
use hal::blocking::delay::DelayMs;
|
use hal::blocking::delay::DelayMs;
|
||||||
use hal::blocking::i2c::{Read, Write};
|
use hal::blocking::i2c::{Read, Write};
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use std::result;
|
use std::result;
|
||||||
|
|
||||||
|
@ -346,7 +343,7 @@ impl I2CUtil
|
||||||
where I2C: Read {
|
where I2C: Read {
|
||||||
let mut buf = [0; 1];
|
let mut buf = [0; 1];
|
||||||
match i2c.read(reg_addr, &mut buf) {
|
match i2c.read(reg_addr, &mut buf) {
|
||||||
Ok(()) => Ok(i8::try_from(buf[0]).expect("U8 overflow when reading register")),
|
Ok(()) => Ok(buf[0] as i8),
|
||||||
Err(_) => Err(Bme680Error::CommunicationFailure),
|
Err(_) => Err(Bme680Error::CommunicationFailure),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue