1 unstable release
0.1.0 | Feb 25, 2025 |
---|
#295 in Embedded development
142 downloads per month
42KB
803 lines
HCMS-29xx Driver
A platform agnostic driver for HCMS-29XX and HCMS-39XX display ICs. Many thanks to @Andy4495's existing HCMS39xx Arduino/C++ library, which I used as a reference implementation as well as for the font data.
Features:
- Single dependency on embedded-hal v1.0
- Optional dependency on avr-progmem for AVR targets to store font data in PROGMEM (requires nightly toolchain)
- Examples for:
Install
To install this driver in your project, add the following line to your Cargo.toml
's dependencies
table:
hcms-29xx = "0.1.0"
For AVR targets:
hcms-29xx = { "0.1.0", features=["avr-progmem"] }
How to Use
The HCMS-29xx/HCMS-39xx displays require a minimum of four pins to control: Data (Din), Register Select (RS), Clock (CLK), and Chip Enable (CE). The other pins, Blank (BL), Oscillator Select (SEL), and Reset (RST), are optional. If not given, the optional pins' logic levels must be set appropriately, typically BL low, SEL high, and RST high.
Specifying only required pins:
const NUM_CHARS: usize = 8;
let mut display = hcms_29xx::Hcms29xx::<NUM_CHARS, _, _, _, _>::new(
HalOutputPin1, // Data pin
HalOutputPin2, // RS pin
HalOutputPin3, // Clock pin
HalOutputPin4, // CE pin
UnconfiguredPin, // Optional: Blank pin
UnconfiguredPin, // Optional: OscSel pin
UnconfiguredPin, // Optional: Reset pin
)
.unwrap();
display.begin().unwrap();
display.display_unblank().unwrap();
display
.set_peak_current(hcms_29xx::PeakCurrent::Max12_8Ma)
.unwrap();
display.set_brightness(15).unwrap();
display.print_ascii_bytes(b"hello!").unwrap();
Specifying all pins:
const NUM_CHARS: usize = 8;
let mut display = hcms_29xx::Hcms29xx::<NUM_CHARS, _, _, _, _, _, _, _>::new(
HalOutputPin1, // Data pin
HalOutputPin2, // RS pin
HalOutputPin3, // Clock pin
HalOutputPin4, // CE pin
HalOutputPin5, // Optional: Blank pin
HalOutputPin6, // Optional: OscSel pin
HalOutputPin7, // Optional: Reset pin
)
.unwrap();
display.begin().unwrap();
display.display_unblank().unwrap();
display.print_ascii_bytes(b"goodbye!").unwrap();
Examples
There are currently two included examples:
- Arduino Uno, based on avr-hal
- ESP32-S3, based on esp-hal.
Follow the appropriate documentation for each HAL for the prerequisite set up and then simply use cargo to build and/or run each.
TODO
- Improve generic type interface, e.g. UnconfiguredPin improvements, better constructor, etc.
- Improve function signatures, e.g. generic implementation for integer print functions
- Katakana font
Dependencies
~55–340KB