pdf-icon

Unit LCD

SKU:U120

Description

Unit LCD is a 1.14-inch color LCD expansion screen unit. It uses the ST7789V2 driver with a resolution of 135 x 240 and supports RGB666 display (262,144 colors). It integrates an ESP32-PICO control core (with built-in firmware, making display development more convenient) and supports control and firmware upgrades via the I2C (addr: 0x3E) communication interface. The back of the screen features a magnetic design, allowing it to easily attach to metal surfaces for fixation. This LCD expansion is suitable for embedding into various instruments or control devices that require simple content display.

Features

  • 1.14-inch color LCD display panel
  • I2C communication interface
  • Viewing angle: Full viewing angle
  • Magnetic back design
  • Supports I2C firmware upgrade

Includes

  • 1 x Unit LCD
  • 1 x HY2.0-4P Grove cable (20cm)

Applications

  • Information display

Specifications

Specification Parameter
Screen Driver IC ST7789V2
Operating Current 45.7mA
Communication Interface I2C address: 0x3E
Display Size 1.14 inch
Pixel Pitch 0.1101 (H) x 0.1038 (V)mm
Resolution 135 x 240
Viewing Angle Full viewing angle
Operating Temperature 0 ~ 60°C
Net Weight 8.5g
Gross Weight 20g
Product Dimensions 48 x 24 x 8mm
Package Dimensions 67 x 52 x 12.5mm
Housing Material Plastic (PC)

Schematics

PinMap

Unit LCD

HY2.0-4P Black Red Yellow White
PORT.A GND 5V SDA SCL

Model Size

Datasheets

Softwares

Arduino

#include <M5UnitLCD.h>

M5UnitLCD display;

M5Canvas canvas(&display);

static constexpr char text[] = "Hello world ! こんにちは世界! this is long long string sample. 寿限無、寿限無、五劫の擦り切れ、海砂利水魚の、水行末・雲来末・風来末、喰う寝る処に住む処、藪ら柑子の藪柑子、パイポ・パイポ・パイポのシューリンガン、シューリンガンのグーリンダイ、グーリンダイのポンポコピーのポンポコナの、長久命の長助";
static constexpr size_t textlen = sizeof(text) / sizeof(text[0]);
int textpos = 0;
int scrollstep = 2;

void setup(void) 
{
  display.init();
  display.setRotation(2);
  canvas.setColorDepth(1); // mono color
  canvas.setFont(&fonts::lgfxJapanMinchoP_32);
  canvas.setTextWrap(false);
  canvas.setTextSize(2);
  canvas.createSprite(display.width() + 64, 72);
}

void loop(void)
{
  int32_t cursor_x = canvas.getCursorX()-scrollstep;
  if (cursor_x <= 0)
  {
    textpos = 0;
    cursor_x = display.width();
  }

  canvas.setCursor(cursor_x, 0);
  canvas.scroll(-scrollstep, 0);
  while (textpos < textlen && cursor_x <= display.width())
  {
    canvas.print(text[textpos++]);
    cursor_x = canvas.getCursorX();
  }
  display.waitDisplay();
  canvas.pushSprite(&display, 0, (display.height()-canvas.height()) >> 1);
}

Internal Firmware

Protocol

About Unit LCD

  • Unit LCD is an I2C unit with ESP32 and ST7789V2.
  • It has an IPS panel with a resolution of 135 x 240.
  • The number of displayable colors is 262,144 colors in RGB666, which is the specification of ST7789V2.
  • ESP32 is responsible for I2C communication and draws the frame buffer in memory based on the received content.
  • The content of the frame buffer in ESP32 memory is reflected in ST7789V2 through DMA transfer via SPI communication.
  • It is represented by 16,777,216 colors in RGB888 on the frame buffer.

About I2C Communication

  • You can use I2C communication to send commands and receive data to/from the Unit LCD.
  • The maximum communication speed for I2C communication is 400kHz.
  • The initial value of the 7-bit I2C address is 0x3E. It can be changed using the CHANGE_ADDR command.
  • The number of bytes required to send depends on the command. Some commands complete within 1 byte, while others require 7 bytes. There are also commands of indefinite length that do not end until communication stops.
  • If an I2C communication STOP or RESTART occurs during command transmission, the interrupted command will not be processed. It must be transmitted uninterrupted in a single transmission sequence until the end.
  • After sending a fixed-length command, you can send another command continuously.
  • After sending an indefinite-length command, you must stop I2C communication to indicate the end of the command.
  • If a NOP command or an undefined command is sent, the communication content will be ignored until I2C communication stops.
  • Since the I2C communication unit and the drawing processing unit operate in parallel, I2C communication can be performed even during drawing processing.
  • The I2C communication content is stored in the command buffer in ESP32 memory, and the drawing processing unit processes it sequentially.
  • You should use the READ_BUFCOUNT command to check the remaining amount of the buffer, as sending a large amount of heavy processing, such as extensive filling or range copying, may overflow the buffer.

About Drawing

  • You can draw a rectangle by using FILLRECT to fill any area with a single color.
  • If you want to draw only one pixel, you can use DRAWPIXEL instead of FILLRECT.
  • If you use a command that omits the foreground color, the last used color will be used.
  • You can specify the drawing range using CASET and RASET and send image data using the WRITE_RAW command.
  • You can use WRITE_RLE instead of WRITE_RAW to send run-length compressed image data.

Command List

※ Undefined commands are treated as no-operation instructions.

hex len command description send params
0x00 1-∞ NOP Do nothing until communication stops [0] 0x00
[1-∞] Ignored value
0x20 1 INVOFF Disable color inversion [0] 0x20
0x21 1 INVON Enable color inversion [0] 0x21
0x22 2 BRIGHTNESS Backlight brightness setting
0:Off-255:Full lights
[0] 0x22
[1] Brightness(0-255)
0x23 7 COPYRECT Rectangle range copy [0] 0x23
[1] Copy source X_Left
[2] Copy source Y_Top
[3] Copy source X_Right
[4] Copy source Y_Bottom
[5] Copy destination X_Left
[6] Copy destination Y_Top
0x2A 3 CASET X direction range selection [0] 0x2A
[1] X_Left
[2] X_Right
0x2B 3 RASET Y direction range selection [0] 0x2B
[1] Y_Top
[2] Y_Bottom
0x36 2 ROTATE Set drawing direction
0:Normal / 1:90° / 2:180° / 3:270°
4-7:flips 0-3 upside down
[0] 0x36
[1] Setting value (0-7)
0x38 2 SET_POWER Operating speed setting
(power consumption setting)
0:Low speed / 1:Normal / 2:High speed
[0] 0x38
[1] Setting value (0-2)
0x39 2 SET_SLEEP LCD panel sleep setting
0:wake up / 1:sleep
[0] 0x39
[1] Setting value (0-1)
0x41 2-∞ WRITE_RAW_8 Write image RGB332 [0] 0x41
[1] RGB332
until [1] communication STOP.
0x42 3-∞ WRITE_RAW_16 Write image RGB565 [0] 0x42
[1-2] RGB565
until [1-2] communication STOP.
0x43 4-∞ WRITE_RAW_24 Write image RGB888 [0] 0x43
[1-3] RGB888
until [1-3] communication STOP.
0x44 5-∞ WRITE_RAW_32 Write image ARGB8888 [0] 0x44
[1-4] ARGB8888
until [1-4] communication STOP.
0x45 2-∞ WRITE_RAW_A Write image A8
only alpha channel.
Use the last used drawing color.
[0] 0x45
[1] A8
until [1] communication STOP.
0x49 3-∞ WRITE_RLE_8 Write RLE image RGB332 [0] 0x49
[1-∞] RLE Data
0x4A 4-∞ WRITE_RLE_16 Write RLE image RGB565 [0] 0x4A
[1-∞] RLE Data
0x4B 5-∞ WRITE_RLE_24 Write RLE image RGB888 [0] 0x4B
[1-∞] RLE Data
0x4C 6-∞ WRITE_RLE_32 Write RLE image ARGB8888 [0] 0x4C
[1-∞] RLE Data
0x4D 3-∞ WRITE_RLE_A Draw RLE image A8
only alpha channel.
Use the last used drawing color.
[0] 0x4D
[1-∞] RLE Data
0x50 1 RAM_FILL Fill the selection with the last used drawing color [0] 0x50
0x51 2 SET_COLOR_8 Specify drawing color with RGB332 [0] 0x51
[1] RGB332
0x52 3 SET_COLOR_16 Specify drawing color with RGB565 [0] 0x52
[1-2] RGB565
0x53 4 SET_COLOR_24 Specify drawing color with RGB888 [0] 0x53
[1-3] RGB888
0x54 5 SET_COLOR_32 Specify drawing color with ARGB8888 [0] 0x54
[1-4] ARGB8888
0x60 3 DRAWPIXEL Draw a single point
Use the stored drawing color
[0] 0x60
[1] X
[2] Y
0x61 4 DRAWPIXEL_8 Draw a single point
RGB332 1Byte for drawing color specification
[0] 0x61
[1] X
[2] Y
[3] RGB332
0x62 5 DRAWPIXEL_16 Draw a single point
RGB565 2Byte for drawing color specification
[0] 0x62
[1] X
[2] Y
[3-4] RGB565
0x63 6 DRAWPIXEL_24 Draw a single point
RGB888 3Byte for drawing color specification
[0] 0x63
[1] X
[2] Y
[3-5] RGB888
0x64 7 DRAWPIXEL_32 Draw a single point
ARGB8888 4Byte for drawing color specification
Transparent composition with existing drawing content
[0] 0x64
[1] X
[2] Y
[3-6] ARGB8888
0x68 5 FILLRECT Fill rectangle
Use the stored drawing color
[0] 0x68
[1] X_Left
[2] Y_Top
[3] X_Right
[4] Y_Bottom
0x69 6 FILLRECT_8 Fill rectangle
RGB332 1Byte for drawing color specification
[0] 0x69
[1] X_Left
[2] Y_Top
[3] X_Right
[4] Y_Bottom
[5] RGB332
0x6A 7 FILLRECT_16 Fill rectangle
RGB565 2Byte for drawing color specification
[0] 0x6A
[1] X_Left
[2] Y_Top
[3] X_Right
[4] Y_Bottom
[5-6] RGB565
0x6B 8 FILLRECT_24 Fill rectangle
RGB888 3Byte for drawing color specification
[0] 0x6B
[1] X_Left
[2] Y_Top
[3] X_Right
[4] Y_Bottom
[5-7] RGB888
0x6C 9 FILLRECT_32 Fill rectangle
ARGB8888 4Byte for drawing color specification
Transparent composition with existing drawing content
[0] 0x6C
[1] X_Left
[2] Y_Top
[3] X_Right
[4] Y_Bottom
[5-8] ARGB8888
0xA0 4 CHANGE_ADDR I2C address change
Use [2] to specify the bit-inverted value of [1].
[0] 0xA0
[1] new I2C address.
[2] Bit[1] inverted
[3] 0xA0

Command list (readable commands)

hex len command description return values
0x04 1 READ_ID ID and firmware version.
4Byte received
[0] 0x77
[1] 0x89
[2] Major version
[3] Minor version
0x09 1 READ_BUFCOUNT Get remaining command buffer.
The higher the value, the more room there is.
Can be read out continuously.
[0] remaining command buffer (0~255)
Repeated reception is possible.
0x81 1 READ_RAW_8 Readout of RGB332 image [0] RGB332
Repeat [0] until communication STOP.
0x82 1 READ_RAW_16 Readout of RGB565 image [0-1] RGB565
Repeat [0-1] until communication STOP.
0x83 1 READ_RAW_24 Readout of RGB888 image [0-2] RGB888
Repeat [0-2] until communication STOP.

Communication example

Example: Use the Fill Rectangle command 0x6A to fill the rectangle range of X16-31 and Y32-47 with red.

index hex description
0 0x6A Fill rectangle RGB565
1 0x10 X Left
2 0x20 Y Top
3 0x1F X Right
4 0x2F Y Bottom
5 0xF8 Color data RRRRRGGG(red)
6 0x00 Color data GGGBBBBB(red)

The command 6Ah is a total of 7Byte command sequence.
If an I2C communication STOP or RESTART occurs during transmission, the command will not be processed. It is necessary to transmit without interruption until the end in a single transmission sequence.

Any of the rectangle fill commands 68h to 6Ch can be used for rectangle fill. Indexes 1 through 4 are the same, but indexes 5 and onward have different methods for specifying colors.

The "remembered color" of command 68h means that the last specified color will be reused. In other words, if you want to do several rectangular fills of the same color in succession, you can specify the color only for the first rectangular fill and then omit the color specification by using the 68h command.

Command 6Ch, ARGB8888, allows you to specify an alpha channel (transparency), which allows you to combine the already drawn content with the drawing color.


Example: Using the range specification command 0x2A/0x2B and the image transmission command, draw an image in the rectangular range of X 10 to 13 and Y 14 to 17.

index hex description
0 0x2A X-direction range selection
1 0x0A X Left(10)
2 0x0D X Right(13)
3 0x2B Y-direction range selection
4 0x0E Y Top(14)
5 0x11 Y Bottom(17)
6 0x43 Draw image RGB888
7-54 ?? Image data(RGB888 ×16)

Example: Sending an RLE (run length encoding) image using the WRITE_RLE command.

  • The RLE specification is based on the RLE for BMP files.
  • Unlike RLE for BMP files, it can be used for RGB565 and RGB888.
  • It first sends a consecutive number of pixels of the same color (0-255), followed by the color data.
  • If 0 is sent to a consecutive number, it will be in direct mode without using RLE.
  • In direct mode, the number of pixels (1-255) is sent first, followed by the color data for the number of pixels.
index hex description
0 0x4A Draw RLE image RGB565
1 0x07 Consecutive number (7pixel)
2-3 0xF800 Color data (red)
4 0x00 Consecutive number (0pixel)
switch to direct mode
5 0x03 Consecutive number of direct mode(3pixel)
6-7 0x07E0 Color data (green)
8-9 0x001F Color data (blue)
10-11 0xF800 Color data (red)
12 0x04 Consecutive number (4pixel)
13-14 0x001F Color data (blue)

The above example will be handled as follows.

  • index1-3 : Draw 7 pixels of red in RLE mode.
  • index4-5 : Switch to direct mode and instruct it to draw 3 pixels.
  • index6-11: Sends the color for 3 pixels in direct mode and draws green, blue, and red.
  • Since the direct mode for 3 pixels is completed by index11, we will return to the RLE mode from index12.
  • index12-14 : Draws 4 pixels of blue in RLE mode.

Firmware upgrade

Method 1. Use ESP32-Downloader to download firmware for update

Go to the resource page to download M5Burner , open the UNIT LCD case, and use the ESP32 DOWNLOADER update the program for it.

Method 2. Update via I2C communication

Compile the above Github source code or go to the resource page to download M5Burner , burn Record LCD_UNIT_FirmwareUpdater firmware to any master controller of M5Core1/Core2/M5StickC/CPlus/ATOM/Paper. Wiring the UNIT LCD to the I2C port will automatically start the update.

Model Size

UIFlow

How to use Unit lcd and related API instructions in the UIFlow1.0

Video

  • UIFlow2.0 LCD Unit