Home

Awesome

ILI9342C Driver for MicroPython

Image

Video of Toaster bitmap demo

This is a work in progress

This driver is based on devbis' st7789_mpy driver. I modified the original driver for one of my projects to add:

Included are 12 bitmap fonts derived from classic pc text mode fonts, 26 Hershey vector fonts and several example programs that run on the M5Stack Core. This driver supports 320x240 displays.

Pre-compiled MicroPython firmware

The firmware directory contains MicroPython v1.16 firmware.bin files with the ILI9342C C driver and frozen python font files compiled with ESP-IDF 4.2 using the CMake build system.

Thanks go out to:

-- Russ

Overview

This is a driver for MicroPython to handle displays based on the ILI9342C chip.

Building instruction

Prepare build tools as described in the manual. You should follow the instruction for building MicroPython and ensure that you can build the firmware without this display module.

Clone this module alongside the MPY sources:

$ git clone https://github.com/russhughes/ili9342c_mpy.git

Go to MicroPython ports directory:

$ cd micropython/ports/esp32

And then compile the module setting USER_C_MODULES to the directory with the driver source code.

$ make USER_C_MODULES=../../../ili9342c_mpy/ all

Upload the resulting firmware to your device using the esptool.py program. (See MicroPython docs for more info)

CMake building instructions for MicroPython 1.14 and later

for ESP32:

$ cd micropython/ports/esp32

And then compile the module with specified USER_C_MODULES dir

$ make USER_C_MODULES=../../../../ili9342c_mpy/src/micropython.cmake all

Erase the target device if this is the first time uploading this firmware

$ make USER_C_MODULES=../../../../ili9342c_mpy/src/micropython.cmake erase

Upload the new firmware

$ make USER_C_MODULES=../../../../ili9342c_mpy/src/micropython.cmake deploy

Additional build parameters

Additional build parameters may be specified during the build, erase and upload operations by including them after the make command. For example you can specify the DEBUG flag, Upload BAUD rate, alternate partition.csv file for different flash sizes and the USB serial port.

  make -j 4 \
    DEBUG=1 \
    BOARD=M5CORE2 \
    BAUD=3000000 \
    PART_SRC=partitions-16MiB.csv \
    PORT=/dev/tty.SLAB_USBtoUART \
    USER_C_MODULES=../../../../ili9342c_mpy/src/micropython.cmake all

Examples

This module was tested on M5Stack Core and M5Stack Core 2 devices and should run on other ESP32 devices that are able run GENERIC MicroPython Firmware. See the examples folder for sample programs.

# ESP32

import machine
import ili9342c
spi = machine.SPI(2, baudrate=40000000, polarity=1, phase=1, sck=Pin(18), mosi=Pin(23)),
display = ili9342c.ILI9342C(
    spi,
    320,
    240,
    reset=Pin(33, Pin.OUT),
    cs=Pin(14, Pin.OUT),
    dc=Pin(27, Pin.OUT),
    backlight=Pin(32, Pin.OUT),
    rotation=0)

Methods

This driver supports only 16bit colors in RGB565 notation.

The module exposes predefined colors: BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, and WHITE

Helper functions