andyblarblar/ld06

This crate is a Rust driver for the tiny LD06 LiDAR sold under a few...

This crate is a Rust driver for the tiny LD06 LiDAR sold under a few brands, namely Innomaker

LD06

. The driver is cross-platform, but not designed for embedded use.

use std::thread::sleep;
use std::time::Duration;
use ld06::ld06_driver::LD06;

fn main() {
    println!("Connecting to a port automatically...");
    let mut ld = LD06::new_auto_port().unwrap();
    ld.listen(); //Port is released in Drop

    println!("Connected!");

    loop {
        if let Some(scan) = ld.next_scan() {
            println!("{:?}", scan);
        } else {
            sleep(Duration::from_millis(15)); //To avoid burning the CPU
        }
    }
}

Info

The driver spawns a background thread that it will listen to a LiDAR from. Once spawned, the thread will read data from the LiDAR into a buffer, which can be queried using the struct on the main thread. This buffer will not loop, so packets will be dropped if the buffer is full.

The driver aims to have a minimal memory footprint, and only contains dynamic allocation for the buffer the port reads into (and even then, this buffer should not grow under normal conditions).

If you wish to use an alternative source of LiDAR data, you can use LD06::from_reader() to provide your own source. The driver implementation makes no assumptions on the use of a serial port, however whatever reader is provided must maintain the same properties as RS232 (i.e. Little Endian). This is useful for testing from cated files.

Information - Updated Aug 02, 2022

Stars: 1
Forks: 0
Issues: 0

Repositories & Extras

ScyllaDB Rust Driver

This is a client-side driver for Tokio

ScyllaDB Rust Driver

Ws2812 driver for embedded-hal spi traits

For usage with the Hackaday | Cheating at 5V WS2812 Control to Use 3

Ws2812 driver for embedded-hal spi traits

A driver for Telaire T67XX CO2 sensor modules (tested on T6713)

This crate is licensed under either of

A driver for Telaire T67XX CO2 sensor modules (tested on T6713)

Rust driver for bq24196 battery controller

5-A Single Cell USB/Adapter Charger with Narrow VDC Power Path Management and USB OTG

Rust driver for bq24196 battery controller

Driver for Texas Instruments INA219 device

This device is a high-side

Driver for Texas Instruments INA219 device
Facebook Instagram Twitter GitHub Dribbble
Privacy