GithubHelp home page GithubHelp logo

lucazulian / gyuvl53l0x Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 3.0 65 KB

GYUVL53L0X - VL53L0X a Time-of-Flight I2C laser-ranging module

License: MIT License

Rust 100.00%
vl53l0x embedded-hal embedded nostd

gyuvl53l0x's Introduction

gyuvl53l0x

no_std driver for VL53L0X (Time-of-Flight I2C laser-ranging module)

Build Status crates.io Docs

Basic usage

Include this library as a dependency in your Cargo.toml:

[dependencies.gyuvl53l0x]
version = "<version>"

Use embedded-hal implementation to get I2C handle and then create vl53l0x handle.

Single read:

extern crate gyuvl53l0x;

match gyuvl53l0x::VL53L0X::default(i2c) {
    Ok(mut u) => {
        // set a new device address
        u.set_device_address(0x39).unwrap();
        // set the measurement timing budget in microseconds
        u.set_measurement_timing_budget(20_000).unwrap();
        loop {
            match u.read_range_single_millimeters_blocking() {
                Ok(val) => {
                    println!("{:#?}", val).unwrap();
                }
                _ => {
                    println!("Not ready").unwrap();
                }
            }
        }
    }
    Err(gyuvl53l0x::VL53L0X::Error::BusError(error)) => {
        println!("{:#?}", error).unwrap();
        panic!();
    }
    _ => {
        panic!();
    }
};

Continuos read:

extern crate gyuvl53l0x;

match gyuvl53l0x::VL53L0X::default(i2c) {
    Ok(mut u) => {
        u.start_continuous(20_000).unwrap();
        loop {
            match u.read_range_continuous_millimeters_blocking() {
                Ok(val) => {
                    println!("{:#?}", val).unwrap();
                }
                _ => {
                    println!("Not ready").unwrap();
                }
            }
        }
    }
    Err(gyuvl53l0x::VL53L0X::Error::BusError(error)) => {
        println!("{:#?}", error).unwrap();
        panic!();
    }
    _ => {
        panic!();
    }
};

License

MIT license

gyuvl53l0x's People

Contributors

dependabot[bot] avatar lucazulian avatar marius-meissner avatar massimiliano-mantione avatar

Stargazers

 avatar

Watchers

 avatar  avatar

gyuvl53l0x's Issues

Address shifting

First, thank you for this awesome crate, which usually works great!

I was only a bit surprised about the address shifting:

address: address << 1,

What is the reason for this?
In my case, this was not necessary. Due to the structure of the library, it is also not possible for a user to bypass this, or am I wrong?

If the assumption is true, what do you think about removing the shift and leaving it up to the caller to decide if this is necessary or not?

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.