Нема описа

Michael Cummings 6cc046b58a Prep for new tag. пре 2 година
examples 3e2a79d332 Merge some stashed changes from before PR merge пре 2 година
src 1f50ee1d09 Some changes from cargo fmt пре 2 година
.gitignore 3e2a79d332 Merge some stashed changes from before PR merge пре 2 година
CODE_OF_CONDUCT.md e6de5013ba Initial commit. пре 4 година
Cargo.toml 7b3ed1bd12 Prep for new tag. пре 2 година
LICENSE ca26ed1e56 Update to copyright in LICENSE file. пре 2 година
README.md 3e2a79d332 Merge some stashed changes from before PR merge пре 2 година

README.md

adxl345_driver

This is an implementation of a hardware driver for a ADXL345 type 3-Axis Digital Accelerometer write in Rust using the rppal library. It exposes a simple trait-based API for the command set which minimizes the coupling between the hardware driver (I²C, etc) and the code that passes commands and data to and from the accelerometer.

Through the name says ADXL345 the driver should also work with the ADXL346 device as well since the only difference between them is the physical packaging and not the internal workings.

Table Of Contents

Getting Started

You will need to have a recent version of Rust installed. Any version of Rust that supports version 0.11.3 or later of rppal should work but versions from 1.43 to 1.47 of Rust have been used during initial development on both the nightly and release channels. Earlier versions might work as well but have not been tested.

Development can be done on any OS that Rust supports but the only expected output target is a Raspberry Pi running a Linux OS. All initial development has been done with a combination of a laptop running Windows 10 and a 4GB Raspberry Pi 4 running the Raspberry Pi OS (Raspbian).

Using The Crate

To use the crate in your own project all you need to do is include it in [dependencies] of you project like you would any other crate. If you have cargo-edit install then on the command line you can use:

```shell script cargo add adxl345_driver


Which should add something like this in your [Cargo.toml]:

```toml
[dependencies]
adxl345_driver = "0.0.5"

Examples

You will find examples in the examples directory. The Raspberry Pi I²C example was used for testing during initial development on a RPi 4.

To build the I²C example start by clone this project somewhere on your Raspberry Pi:

git clone https://github.com/Dragonrun1/adxl345_driver

Next execute the follow to build the example:

cargo build --example i2c

And finally execute:

sudo ./target/debug/examples/i2c

You should see the series of x, y, z values displayed in the terminal if your device has been hooked up using the primary I²C that the example expects.

Output example:

axis: {'x': 1.6083, 'y': 0.0392, 'z': 8.7868} m/s²
axis: {'x': 1.6867, 'y': 0.1177, 'z': 8.7868} m/s²
axis: {'x': 1.6475, 'y': 0.1177, 'z': 8.8260} m/s²
...

You can find the latest version by go to adxl345_driver on the crates.io website.

Contributing

Contributors are welcome. Make sure you have read the Contributor Covenant Code of Conduct. All contributed code will be considered to also be contributed under a MIT license. Please include your information in a comment on all code files for the copyright etc.

All contributed documentation or non-code text like this README etc. will be consider to be under the same CC-BY-SA license.

Licenses

All code is available under the MIT license. You can find a copy of the license in the LICENSE file.

All documentation like this README is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (CC-BY-SA).


Creative Commons License