5 releases (breaking)

0.5.0 Jan 12, 2024
0.4.0 Jan 11, 2024
0.3.0 Jun 4, 2023
0.2.0 Aug 11, 2022
0.1.0 Aug 1, 2022

#399 in Embedded development

Download history 2/week @ 2024-09-23 3/week @ 2024-09-30 2/week @ 2024-10-07 55/week @ 2024-11-11 129/week @ 2024-11-18 145/week @ 2024-11-25 24/week @ 2024-12-02

353 downloads per month

MIT/Apache

37KB
777 lines

Rust SCL3300 Driver

Crates.io Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
scl3300 = "0.5"

lib.rs:

This is a driver for SCL3300 inclinometers, implemented using platform-agnostic embedded-hal traits.

Usage

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
use scl3300::{Scl3300, Acceleration, ComponentId, Inclination, MeasurementMode, Temperature};

let inclinometer = Scl3300::new(spi);

// Start the inclinometer and switch to inclination mode.
let mut inclinometer = inclinometer.start_up(MeasurementMode::Inclination)?;

// Read the component ID.
let id: ComponentId = inclinometer.read()?;
assert_eq!(id, ComponentId::WHOAMI);

// Read acceleration, inclination and temperature.
let (acc, inc, temp): (Acceleration, Inclination, Temperature) = inclinometer.read()?;

println!("Acceleration: {}g, {}g, {}g", acc.x_g(), acc.y_g(), acc.z_g());
#
println!("Inclination: {}°, {}°, {}°", inc.x_degrees(), inc.y_degrees(), inc.z_degrees());
#
println!("Temperature: {}°C", temp.degrees_celsius());

// Switch to power-down mode.
let inclinometer = inclinometer.power_down()?;

// Release the SPI peripheral again.
let spi = inclinometer.release();
drop(spi);

Dependencies

~550KB
~11K SLoC