# esp32p4-micropython-dfrobot-rpi-dsi-driver **Repository Path**: lyjunnan/esp32p4-micropython-dfrobot-rpi-dsi-driver ## Basic Information - **Project Name**: esp32p4-micropython-dfrobot-rpi-dsi-driver - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-28 - **Last Updated**: 2025-09-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ESP32-P4 MicroPython LCD Driver (5" 800×480 Raspberry-Pi DSI) A high-performance **native C** MicroPython module that drives the **5-inch, 800×480 IPS capacitive DSI LCD** designed for **Raspberry Pi**, but running on **Espressif ESP32-P4** with MicroPython. | | | | -------------- | ------------------------------------------------------- | | **Panel** | 5" IPS, 800 × 480, 5-point capacitive touch | | **Interface** | Raspberry-Pi DSI (adapted to ESP32-P4 MIPI-DSI) | | **Brightness** | 550 cd/m², full-laminated, anti-glare, anti-fingerprint | | **Colors** | 16-bit RGB (16.7 M) | | **Touch** | Capacitive, I²C 0x38 | --- ## Features - Pure **C** implementation for blazing speed and minimal RAM usage - **MicroPython bindings** – use the display exactly like any other Python object - Graphic primitives: point, line, rectangle, circle, filled shapes - Text rendering (bitmap fonts) with size & color control - Blit full-color images from `bytearray` / `memoryview` - Pre-defined color constants (`WHITE`, `BLACK`, `RED`, …) --- ## Quick Start Clone the repository inside the MicroPython `ports/esp32/modules/` directory: ```bash cd micropython/ports/esp32/modules git clone https://github.com/Vincent1-python/esp32p4-micropython-dfrobot-rpi-dsi-driver.git ``` Rebuild MicroPython: ```bash cd ../../ make USER_C_MODULES=modules/esp32p4-micropython-dfrobot-rpi-dsi-driver/src/micropython.cmake ``` Flash the resulting firmware to your ESP32-P4 board. ## Color Constants | Name | Hex Value | | :-------- | :-------- | | `WHITE` | 0xFFFF | | `BLACK` | 0x0000 | | `RED` | 0xF800 | | `GREEN` | 0x07E0 | | `BLUE` | 0x001F | | `YELLOW` | 0xFFE0 | | `CYAN` | 0x07FF | | `MAGENTA` | 0xF81F | | …and more | | ------ # MicroPython LCD Module – API Reference | Function | Signature | Description | | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | **init** | `lcd.init()` | Initialize the LCD controller (safe to call multiple times; initialization runs only once). | | **clear** | `lcd.clear(color: int)` | Fill the entire screen with the given 16-bit RGB565 color. | | **point** | `lcd.point(x: int, y: int, color: int)` | Draw a single pixel. | | **fill** | `lcd.fill(sx: int, sy: int, ex: int, ey: int, color: int)` | Draw a filled rectangle from `(sx,sy)` to `(ex,ey)` inclusive. | | **line** | `lcd.line(x1: int, y1: int, x2: int, y2: int, color: int)` | Draw a straight line between the two points. | | **hline** | `lcd.hline(x: int, y: int, len: int, color: int)` | Draw a horizontal line starting at `(x,y)` with length `len`. | | **rectangle** | `lcd.rectangle(x0: int, y0: int, x1: int, y1: int, color: int)` | Draw an **empty** rectangle outline. | | **circle** | `lcd.circle(x0: int, y0: int, r: int, color: int)` | Draw an **empty** circle centered at `(x0,y0)` with radius `r`. | | **fill_circle** | `lcd.fill_circle(x: int, y: int, r: int, color: int)` | Same as above, but filled. | | **char** | `lcd.char(x: int, y: int, ch: int, size: int, mode: int, color: int)` | Draw one ASCII character (`ch`) with the given font `size` and color. | | **num** | `lcd.num(x: int, y: int, n: int, length: int, size: int, color: int)` | Print the decimal integer `n`, padding to `length` digits. | | **xnum** | `lcd.xnum(x: int, y: int, n: int, length: int, size: int, mode: int, color: int)` | Print an integer in **hex** or **decimal** depending on `mode`. | | **string** | `lcd.string(x: int, y: int, w: int, h: int, size: int, text: str, color: int)` | Draw a complete string inside the clipping rectangle `(w,h)`. | | **image** | `lcd.image(x: int, y: int, w: int, h: int, buffer)` | Blit raw RGB565 pixel data (`bytes`, `bytearray`, or `memoryview`) to screen. | ### Quick Example ```python import lcd from machine import Pin from machine import I2C i2c = I2C(0,scl=Pin(8), sda=Pin(7)) i2c.writeto_mem(0x45, 0x86, b'\xff') # Initialize the display (only once) lcd.init() # Clear screen lcd.clear(lcd.WHITE) # Draw primitives lcd.line(0, 0, 100, 100, lcd.RED) lcd.circle(120, 120, 30, lcd.BLUE) lcd.fill_circle(200, 120, 20, lcd.GREEN) # Text lcd.string(10, 10, 200, 24, 24, "Hello ESP32-P4!", lcd.BLACK) # Blit raw RGB565 buffer import ustruct w, h = 100, 50 buf = bytearray(w * h * 2) for i in range(0, len(buf), 2): buf[i:i+2] = ustruct.pack("