GC9D01 Rust Driver
A no_std Rust driver for the GC9D01 LCD display controller with full embedded-graphics support. This driver provides both async and sync APIs, making it suitable for modern embedded frameworks like Embassy as well as traditional blocking applications.
✨ Features
- 🎯 Complete GC9D01 support - Full manufacturer initialization sequence from official documentation
- ⚡ Async/Sync APIs - Built for Embassy and other async frameworks, with sync fallback
- 🎨 embedded-graphics integration - Full DrawTarget implementation for rich graphics
- 🚀 High-performance rendering - Optimized batch SPI transfers and frame buffer architecture
- 🌈 RGB565 color format - 16-bit color depth with efficient memory usage
- 🔧 Hardware abstraction - Works with any embedded-hal SPI implementation
- 📐 Multiple orientations - Portrait, Landscape, and rotated variants with coordinate transformation
- 🎪 Display optimized - Designed for GC9D01-based LCD panels
- 📦 no_std compatible - Perfect for resource-constrained embedded systems
🚀 Quick Start
Add this to your Cargo.toml:
[]
= "0.1"
= "0.8"
# For async support
= { = "0.1", = ["async"] }
Basic Usage
use ;
use ;
// Create display configuration
let config = Config ;
// Initialize display (async example)
let mut display = GC9D01new;
display.init.await?;
// Draw with embedded-graphics
new
.into_styled
.draw?;
// Flush to screen
display.flush.await?;
📋 Examples
This repository includes comprehensive examples for different use cases:
🎮 STM32G4 Examples
Direct SPI Implementation
- Location:
examples/stm32g4-direct-spi-90-complex-patterns/ - Features: Raw SPI operations, complex pattern rendering, coordinate transformation
- Performance: Optimized for maximum speed with chunked rendering
embedded-graphics Integration
- Location:
examples/stm32g4-embedded-graphics/ - Features: Full embedded-graphics support, shapes, text, patterns
- Use case: Rich graphics applications with high-level drawing APIs
Basic Display Test
- Location:
examples/stm32g4/ - Features: Simple color cycling, basic functionality verification
- Use case: Hardware testing and driver validation
🔧 Hardware Configuration
All examples use this pin configuration:
| Function | Pin | Description |
|---|---|---|
| SCK | PB3 | SPI Clock |
| MOSI | PA7 | SPI Data |
| CS | PA4 | Chip Select (active low) |
| DC | PB0 | Data/Command select |
| RST | PC4 | Reset (active low) |
🏃♂️ Running Examples
# Basic functionality test
# embedded-graphics demo
# High-performance patterns
🎨 embedded-graphics Support
This driver provides full DrawTarget implementation, supporting:
- Primitives: Rectangles, circles, triangles, lines
- Text rendering: Multiple fonts and styles
- Images: Bitmap and raw image support
- Custom graphics: Any embedded-graphics compatible drawing
- Coordinate transformation: Automatic handling of display orientation
use ;
// Draw a rectangle
new
.into_styled
.draw?;
// Draw text
let text_style = new;
new
.draw?;
⚙️ Configuration
Display Orientations
The driver supports multiple orientations with automatic coordinate transformation:
use Orientation;
let config = Config ;
Performance Optimization
For maximum performance, use the frame buffer architecture:
// Allocate buffers
static DISPLAY_BUFFER: = ;
static FRAME_BUFFER: = ; // 160x40
// Create display with frame buffer
let mut display = GC9D01new;
🔧 Features
Cargo Features
async- Enable async/await support (requiresembedded-hal-async)defmt- Enable defmt logging support
[]
= { = "0.1", = ["async", "defmt"] }
📚 Documentation
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
📄 License
This project is dual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
🙏 Acknowledgments
- Based on the official GC9D01 initialization sequence
- Inspired by the embedded-hal ecosystem
- Built for the Embassy async framework