GithubHelp home page GithubHelp logo

wen-templari / esp-idf-st7789 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nopnop2002/esp-idf-st7789

0.0 0.0 0.0 375 KB

ST7789 Driver for esp-idf

License: MIT License

C 99.35% Makefile 0.11% CMake 0.54%

esp-idf-st7789's Introduction

esp-idf-st7789

ST7789 Driver for esp-idf

The demo video by Dmitry Andreev.
https://www.youtube.com/watch?v=aOyaK0pUiPk&t

Software requirements

ESP-IDF V4.4/V5.0 or later.

Installation for ESP-IDF V4.4

git clone -b v4.4 https://github.com/nopnop2002/esp-idf-st7789
cd esp-idf-st7789/
idf.py set-target {esp32/esp32s2/esp32s3/esp32c3}
idf.py menuconfig
idf.py flash

Note for ESP32-S2
The tjpgd library is not included in the ESP32-S2 ROM because the ROM of the ESP32-S2 is small.
Therefore, JPEG files cannot be displayed.

Note for ESP32-C3
For some reason, there are development boards that cannot use GPIO06, GPIO08, GPIO09, GPIO19 for SPI clock pins.
According to the ESP32C3 specifications, these pins can also be used as SPI clocks.
I used a raw ESP-C3-13 to verify that these pins could be used as SPI clocks.

Installation for ESP-IDF V5.x

git clone https://github.com/nopnop2002/esp-idf-st7789
cd esp-idf-st7789/
idf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3}
idf.py menuconfig
idf.py flash

Note for ESP32-S2/ESP32-C2
The tjpgd library is not included in the ESP32-S2/ESP32-C2 ROM.
However, you can use this IDF component registry.
JPEG files can be displayed.

Configuration

config-top

Generic ST7789 1.3 Inch

There is 2 kinds of marking.
The pin marking is written as SCL/SDA, so it looks like i2c, but it is SPI.

st7789-back

config-240x240

MISO is not use.

st7789-1 st7789-2 st7789-3 st7789-4 st7789-5 st7789-6 st7789-7 st7789-8 st7789-9 st7789-10

BMP file
st7789-11

JPEG file(ESP32/ESP32S2/ESP32C3)
st7789-JPEG

PNG file
st7789-PNG

QR-CODE
st7789-QRCODE

Generic ST7789 2.0 Inch

st778-240x320-1 st778-240x320-2 st778-240x320-3 st778-240x320-5

Generic ST7789 1.14 Inch

st7789-135x240-2 st7789-135x240-1

SPI BUS selection

config-spi-bus

The ESP32 series has three SPI BUSs.
SPI1_HOST is used for communication with Flash memory.
You can use SPI2_HOST and SPI3_HOST freely.
When you use SDSPI(SD Card via SPI), SDSPI uses SPI2_HOST BUS.
When using this module at the same time as SDSPI or other SPI device using SPI2_HOST, it needs to be changed to SPI3_HOST.
When you don't use SDSPI, both SPI2_HOST and SPI3_HOST will work.
Previously it was called HSPI_HOST / VSPI_HOST, but now it is called SPI2_HOST / SPI3_HOST.

About Reset Circuit

TFT does not respond even after executing RESET several times.
I think there is an electrical problem around reset circuit.
I pulled up RESET by inserting a 100 ohm resistor between Vcc and RESET.
TroubleShooting st778-240x320-4

Perhaps the reset circuit requires a lot of current.
Ultimately I ended up using the following circuit.
And press the reset button several times.

ESP32 3V3  -------------------------------+
                                          |
                                          | Collector
                                         /
                                        /
ESP32 RES  ------------R(2.2K)---------|    SS8050
                                Base    \
                                         \
                                          | Emitter
                                          |
                                          +------------------------- ST77889 RST
                                          |
                                          |
ESP32 GND  ------------R(220)-------------+

If you know the cause, please let me know.

LILYGO TTGO 1.14 Inch ESP32

ttgo-1 ttgo-2

LILYGO TTGO T8 ESP32-S2

TTGO_T8_ESP32-S2-1 TTGO_T8_ESP32-S2-2

JPEG Decoder

The ESP-IDF component includes Tiny JPEG Decompressor.
The document of Tiny JPEG Decompressor is here.
This can reduce the image to 1/2 1/4 1/8.

PNG Decoder

The ESP-IDF component includes part of the miniz library, such as mz_crc32.
But it doesn't support all of the miniz.
The document of miniz library is here.

And I ported the pngle library from here.
This can reduce the image to any size.

Font File

You can add your original fonts.
The format of the font file is the FONTX format.
Your font file is put in font directory.
Your font file is uploaded to SPIFFS partition using meke flash.

Please refer this page about FONTX format.

Font File Editor(FONTX Editor)

There is a font file editor.
This can be done on Windows 10.
Developer page is here.

FontxEditor

This library uses the following as default fonts:

  • font/ILGH16XB.FNT // 8x16Dot Gothic
  • font/ILGH24XB.FNT // 12x24Dot Gothic
  • font/ILGH32XB.FNT // 16x32Dot Gothic
  • font/ILMH16XB.FNT // 8x16Dot Mincyo
  • font/ILMH24XB.FNT // 12x24Dot Mincyo
  • font/ILMH32XB.FNT // 16x32Dot Mincyo

From 0x00 to 0x7f, the characters image of Alphanumeric are stored.
From 0x80 to 0xff, the characters image of Japanese are stored.
Changing this file will change the font.

How to build your own font file

step1)
download fontxedit.exe.

step2)
download BDF font file from Internet.
I downloaded from here.
fontxedit.exe can ONLY import Monospaced bitmap fonts file.
Monospaced bitmap fonts can also be downloaded here.

step3)
import the BDF font file into your fontxedit.exe.
this tool can convert from BDF to FONTX.
FONTX-EDITTOR-1

step4)
adjust font size.
FONTX-EDITTOR-2

step5)
check font pattern.
FONTX-EDITTOR-13

step6)
save as .fnt file from your fontedit.exe.
FONTX-EDITTOR-14

step7)
upload your font file to $HOME/esp-idf-st7789/fonts directory.

step8)
add font to use

FontxFile fx32L[2];
InitFontx(fx32L,"/spiffs/LATIN32B.FNT",""); // 16x32Dot LATIN

Font file that From 0x80 to 0xff, the characters image of Japanese are stored.
st7789-KANA

Font file that From 0x80 to 0xff, the characters image of Latin are stored.
st7789-LATIN

External input module

You can use these if you need some input.

esp-idf-st7789's People

Contributors

beoran avatar nopnop2002 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.