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