Skip to content

nopnop2002/esp-idf-m5stickC-Plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-idf-m5stickC-Plus

Example code for driving M5StickC-Plus/Plus2 ST7789V2 display using ESP-IDF's SPI driver.
M5StickC-Plus/Plus2 has 135x240 ST7789V2 tft.

M5StickC-Plus2

Software requirements

esp-idf v4.4/v5.x.

Installation

git clone https://github.com/nopnop2002/esp-idf-m5stickC-Plus
cd esp-idf-m5stickC-Plus/screen
idf.py set-target esp32
idf.py menuconfig
idf.py flash -b 115200 monitor

You need to specify Baud rate for flashing.

Configuration

config-top config-app-1 config-app-2

Graphic support

M5StickC-Plus-2

M5StickC-Plus-3

M5StickC-Plus-4

Fonts support

It's possible to text rotation and invert.
M5StickC-Plus-5

M5StickC-Plus-6

M5StickC-Plus-7

It's possible to indicate more than one font at the same time.
M5StickC-Plus-11

Image support

BMP file
M5StickC-Plus-8 JPEG file
M5StickC-Plus-9 PNG file
M5StickC-Plus-10

Font File

This project uses the following as default fonts:

  • fonts/ILGH16XB.FNT // 8x16Dot Gothic
  • fonts/ILGH24XB.FNT // 12x24Dot Gothic
  • fonts/ILGH32XB.FNT // 16x32Dot Gothic
  • fonts/ILMH16XB.FNT // 8x16Dot Mincyo
  • fonts/ILMH24XB.FNT // 12x24Dot Mincyo
  • fonts/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.

You can add your original font file.
The format of the font file is the FONTX format.
Your font file is put in font directory.
When you build the firmware, the font files are uploaded to the SPIFFS partition.

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.

fontx-editor-1

Convert from BDF font to FONTX font

step1)
download Font File Editor(FONTX Editor) from here.

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

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

step4)
check font pattern.
emoticons21-1

step5)
adjust font size.
emoticons21-2

step6)
save as .fnt file from your fontedit.exe.
emoticons21-3

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

step8)
add font to use

FontxFile fx32E[2];
InitFontx(fx32E,"/fonts/emoticons21.fnt",""); // 24x24Dot Smile

FontxFile fx32S[2];
InitFontx(fx32S,"/fonts/Scroll-o-Sprites.fnt",""); // 16x16Dot Emoji

This is a 24x24 font converted from emoticons21.bdf from u8g2 library.
bdf-font-1

This is a 16x16 font converted from Scroll-o-Sprites.bdf from u8g2 library.
bdf-font-2

Convert from TTF font to FONTX font

step1)
Download WFONTX64.exe from here. Developer page is here.

step2)
Select ttf font.
Please note that if you select a proportional font, some fonts may not convert correctly.
If you select a proportional font, some fonts will need to be modified using fontxedit.exe.
Monospaced fonts can be converted correctly.
WFONTX64-1

step3)
Enter Height, Width, FontX2 name.
Specify half of Height for Width.
Specify your favorite font name in the FontX2 name field using up to 8 characters.
WFONTX64-2

step4)
Specify the file name to save.
WFONTX64-3

step5)
Specify the font style as required.
WFONTX64-4

step6)
Press the RUN button to convert TTF fonts to FONTX format.
WFONTX64-5

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

step8)
add font to use

    FontxFile fx16G[2];
    FontxFile fx24G[2];
    FontxFile fx32G[2];
    //InitFontx(fx16G,"/fonts/ILGH16XB.FNT",""); // 8x16Dot Gothic
    //InitFontx(fx24G,"/fonts/ILGH24XB.FNT",""); // 12x24Dot Gothic
    //InitFontx(fx32G,"/fonts/ILGH32XB.FNT",""); // 16x32Dot Gothic
    InitFontx(fx16G,"/fonts/Gigi16.FNT",""); // 8x16Dot Gigi
    InitFontx(fx24G,"/fonts/Gigi24.FNT",""); // 12x24Dot Gigi
    InitFontx(fx32G,"/fonts/Gigi32.FNT",""); // 16x32Dot Gigi

TTF_FONT

How to add your color

Change here.

#define RED    rgb565(255,   0,   0) // 0xf800
#define GREEN  rgb565(  0, 255,   0) // 0x07e0
#define BLUE   rgb565(  0,   0, 255) // 0x001f
#define BLACK  rgb565(  0,   0,   0) // 0x0000
#define WHITE  rgb565(255, 255, 255) // 0xffff
#define GRAY   rgb565(128, 128, 128) // 0x8410
#define YELLOW rgb565(255, 255,   0) // 0xFFE0
#define CYAN   rgb565(  0, 156, 209) // 0x04FA
#define PURPLE rgb565(128,   0, 128) // 0x8010

Reference

https://github.com/nopnop2002/esp-idf-m5stickC

Releases

No releases published

Packages

No packages published

Languages