A no_std driver for the ATK-MD0240 2.4-inch LCD module, which uses the ST7789V controller.
This crate is built upon the embedded-hal traits for hardware abstraction and uses embedded-graphics for all drawing operations.
The driver includes an internal framebuffer to allow for composing graphics before sending a complete frame to the display.
no_stdcompatible: Suitable for bare-metal and RTOS-based systems.- SPI interface for communication.
embedded-graphicsDrawTargetimplementation for easy drawing of shapes, text, and images.- Internal framebuffer (
Display2in14) for composing graphics before sending to the display. - Configurable framebuffer allocation via Cargo features:
stack_alloc(default): Allocates the framebuffer on the stack. Simple and no allocator needed.heap_alloc: Allocates the framebuffer on the heap. Requires a global allocator.
- Screen rotation support.
The driver requires an SPI interface and three GPIO pins for operation.
| LCD Pin | MCU Pin | Description in Code | Description |
|---|---|---|---|
| VCC | 3.3V / 5V | - | Power Supply |
| GND | GND | - | Ground |
| CS | SPI CS | - | Chip Select (often handled by SpiDevice) |
| SCLK | SPI SCLK | spi |
Serial Clock |
| SDA/SDI | SPI MOSI | spi |
Serial Data In (Master Out) |
| RESET | GPIO Output | rst |
Reset Pin (active low) |
| RS/DC | GPIO Output | wr |
Data/Command Select Pin |
| BL | GPIO Output | pwr |
Backlight Control Pin (active high) |
Add the following to your Cargo.toml file.
[dependencies]
atk_md0240 = { git = "https://github.com/KaidRommel/ATK-MD0240-rs.git" }If you need to use heap allocation for the framebuffer, enable the heap_alloc feature.
[dependencies]
atk_md0240 = { git = "https://github.com/KaidRommel/ATK-MD0240-rs.git", features = ["heap_alloc"] }Lcd: The main driver struct. It handles communication with the LCD.init(): Initializes the display controller.clear_frame(): Sends the entire content of aDisplay2in14buffer to the screen.set_pixel(): Sets a single pixel on the display (less efficient for multiple pixels).
Display2in14: An in-memory framebuffer that implementsembedded_graphics::DrawTarget.new(): Creates a new framebuffer, filling it with a specified color.clear_buffer(): Clears the buffer to a single color.- All
embedded-graphicsdrawing functions can be used on aDisplay2in14instance.