ld06_embed/lib.rs
1//!This crate is an embedded_hal peripheral driver for the LD06/LD09 drivers sold under various brands.
2//!
3//! ## Setup
4//! To use this crate, simply connect to the LD06 UART via an interface of your choice, then pass that interface to the
5//! LD06 struct found in this crate. Note that it seems the LiDAR needs a PWM signal for motor control as it has a PWM pin,
6//! but in my experience this has not been the case. Nonetheless, I have provided a wrapper struct that also provides PID
7//! control for this signal, should it be needed for your use case.
8//!
9//! ## Example
10//! (see [here](./examples/linux) for runnable example on linux)
11//!
12//!```rust
13//! # use nb::Error;
14//! # use ld06_embed::error::ParseError;
15//! # use ld06_embed::LD06;
16//! # use embedded_hal_mock::serial::{Mock, Transaction};
17//! # let serial = Mock::new(&[Transaction::read(0x54)]);
18//! let mut ld06 = LD06::new(serial);
19//!
20//! loop {
21//! match ld06.read_next_byte() {
22//! Ok(None) => {}
23//! Err(err) => match err {
24//! Error::Other(parse_err) => match parse_err {
25//! ParseError::SerialErr(_) => {
26//! println!("Serial issue")
27//! }
28//! ParseError::CrcFail => {
29//! println!("CRC failed")
30//! }
31//! },
32//! Error::WouldBlock => {
33//! println!("Would block")
34//! }
35//! },
36//! Ok(Some(scan)) => {
37//! println!("scan: {:?}", scan);
38//! }
39//! }
40//! # break;
41//! }
42//! ```
43
44#![no_std]
45
46mod crc;
47pub mod error;
48mod ld06_driver;
49mod scan_types;
50
51pub use ld06_driver::*;
52
53pub use nb;