ag_lcd/lib.rs
1#![no_std]
2#![deny(unsafe_code)]
3#![deny(missing_docs)]
4#![deny(unused_variables)]
5#![deny(clippy::unwrap_used)]
6#![deny(clippy::expect_used)]
7#![allow(clippy::identity_op)]
8
9//! # AG-LCD
10//!
11//! This is a rust port of the [LiquidCrystal](https://github.com/arduino-libraries/LiquidCrystal) library. LiquidCrystal
12//! is a standard C++ library that allows developers to control a [HITACHI HD44780](https://pdf1.alldatasheet.com/datasheet-pdf/view/63673/HITACHI/HD44780/+435JWUEGSzDpKdlpzC.hv+/datasheet.pdf)
13//! LCD screen with one or two 16-character lines. Alternatives to this library (that I've investigated) are:
14//!
15//! * [lcd](https://crates.io/crates/lcd)
16//! * [lcd1602](https://crates.io/crates/lcd1602-rs)
17//!
18//! I decided to create a more comprehensive solution because existing libraries were either incomplete or somewhat
19//! complicated to use. This library uses traits from [embedded-hal](https://crates.io/crates/embedded-hal) and should work
20//! with any hardware abstraction layer that uses the same types. Currently this crate has only been tested with [avr-hal](https://github.com/Rahix/avr-hal)
21//! and all example code and comments assume you're using avr-hal as well.
22//!
23//! Most features (blink, cursor, text direction etc.) can be set either through a general `set_` function that accepts
24//! one or two arguments (like [set_blink][LcdDisplay::set_blink]), through specific conveniance functions ([blink_on][LcdDisplay::blink_on] rather
25//! than [set_blink][LcdDisplay::set_blink]) or with a builder function (like [with_blink][LcdDisplay::with_blink]).
26//!
27//! If some functions are missing for a settings, its either because it doesn't make sense for that particular setting, or
28//! because that feature can only be set *before* the [build][LcdDisplay::build] method is called (in which case only a `with_`
29//! function is provided).
30//!
31//! ## Usage
32//!
33//! ```
34//! use ag_lcd::{Display, Blink, Cursor, LcdDisplay};
35//!
36//! let peripherals = arduino_hal::Peripherals::take().unwrap();
37//! let pins = arduino_hal::pins!(peripherals);
38//! let delay = arduino_hal::Delay::new();
39//!
40//! let rs = pins.d12.into_output().downgrade();
41//! let rw = pins.d11.into_output().downgrade();
42//! let en = pins.d10.into_output().downgrade();
43//! // let d0 = pins.d9.into_output().downgrade();
44//! // let d1 = pins.d8.into_output().downgrade();
45//! // let d2 = pins.d7.into_output().downgrade();
46//! // let d3 = pins.d6.into_output().downgrade();
47//! let d4 = pins.d5.into_output().downgrade();
48//! let d5 = pins.d4.into_output().downgrade();
49//! let d6 = pins.d3.into_output().downgrade();
50//! let d7 = pins.d2.into_output().downgrade();
51//!
52//! let mut lcd: LcdDisplay<_,_> = LcdDisplay::new(rs, en, delay)
53//! // .with_full_bus(d0, d1, d2, d3, d4, d5, d6, d7)
54//! .with_half_bus(d4, d5, d6, d7)
55//! .with_display(Display::On)
56//! .with_blink(Blink::On)
57//! .with_cursor(Cursor::On)
58//! .with_rw(d10) // optional (set to GND if not provided)
59//! .build();
60//!
61//! lcd.set_cursor(Cursor::Off);
62//! lcd.set_blink(Blink::Off);
63//!
64//! lcd.print("Test message!");
65//! ```
66//!
67
68mod display;
69mod errors;
70#[cfg(feature = "i2c")]
71#[doc(hidden)]
72pub mod i2c;
73
74pub use display::*;
75pub use errors::Error;