A demonstration project for the ESP32-S3 microcontroller, showcasing a bouncing text animation on an ATK-MD0240 SPI LCD. This project is built with Rust using the esp-hal and features custom-written drivers for the display and an XL9555 I/O expander.
This project is a great starting point for anyone looking to drive an SPI display and use I2C peripherals with an ESP32-S3 in Rust.
- Bouncing "ESP32 <3 Rust" text animation using
embedded-graphics. - The background color cycles through a palette each time the text bounces off the side walls.
- Drives an ATK-MD0240 SPI LCD.
- Utilizes an XL9555 I2C I/O expander for display control signals (Reset and Power/Backlight).
- Built entirely in Rust on top of the
esp-rsecosystem (esp-hal,esp-backtrace, etc.). - Showcases custom,
no_stdcompatible drivers for both theatk_md0240display and thexl9555I/O expander.
- An ESP32-S3 development board.
- An ATK-MD0240 2.4" TFT LCD Module.
- An XL9555 I/O Expander.
The following table details the hardware connections used in this project.
| ESP32-S3 Pin | Connection | Notes |
|---|---|---|
| I2C (for XL9555) | ||
GPIO41 |
XL9555 SDA |
I2C Data |
GPIO42 |
XL9555 SCL |
I2C Clock |
| SPI (for LCD) | ||
GPIO11 |
LCD MOSI (or SDA) |
SPI Master Out, Slave In |
GPIO12 |
LCD SCLK (or SCL) |
SPI Clock |
GPIO13 |
LCD MISO (or SDO) |
SPI Master In, Slave Out (Optional) |
GPIO21 |
LCD CS |
SPI Chip Select |
| Direct LCD Control | ||
GPIO40 |
LCD WR/DC |
Data / Command Select |
| XL9555 Controlled | ||
XL9555 P12 |
LCD RST |
Reset Pin |
XL9555 P13 |
LCD PWR |
Backlight Power Control |
3V3 |
VCC | Power for all components |
GND |
GND | Common Ground |
This project is built using the Rust programming language and the esp-rs toolchain.
- Install the Rust
esptoolchain. Follow the instructions at https://esp-rs.github.io/book/installation/index.html. - Install
espflashfor easy flashing and monitoring:cargo install espflash
-
Clone this repository:
https://github.com/KaidRommel/esp-rust-spi-lcd-demo.git cd esp-rust-spi-lcd-demo -
Build and Run the project:
cargo run
You should see the bouncing text animation on your LCD screen!
A key part of this project is the use of two custom-written drivers, which are also available as standalone crates for your own projects:
atk_md0240-rs: Ano_stddriver for the ATK-MD0240 SPI LCD, providing a simple interface compatible withembedded-graphics.xl9555-rs: Ano_stddriver for the XL9555 I2C I/O expander, allowing easy control of its 16 I/O pins.
