Giter VIP home page Giter VIP logo

adxl345_driver's Introduction

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:

cargo add adxl345_driver

Which should add something like this in your Cargo.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. I would like to see the hardware drives extended beyond just the I²C interface but I currently don't have access to other hardware for development or testing using the SPI interface. 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.