Crates.io | fk-lis3dsh |
lib.rs | fk-lis3dsh |
version | 0.1.0 |
source | src |
created_at | 2020-10-19 17:10:41.874096 |
updated_at | 2020-10-19 17:10:41.874096 |
description | embedded-hal driver for LIS3D-SH Accelerometer |
homepage | |
repository | https://github.com/straend/fk-lis3dsh/ |
max_upload_size | |
id | 302982 |
size | 16,881 |
Include the library in Your Cargo.toml
[dependencies.fk-lis3dsh]
Use embedded-hal to create spi and cs and create accelerometer:
Create accelerometer with default configuration, only SPIBus implemented for now.
let mut acc =
LIS3DSH::new_with_interface(lis3dsh::commbus::SPIBus::new(spi, cs), &mut delay).unwrap();
Access accelerometer data
if acc.has_data().unwrap() {
let accel = acc.accel_raw().unwrap();
rprintln!("{}\t{}\t{}",
accel.x,
accel.y,
accel.z,
);
}