Using the Unit LCD ・ 使用 Unit LCD
M5StackのUnit LCDをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| M5Stack CoreS3 | Controller | grove_i2c, grove_analog, grove_uart, mbus, usb_c, sdcard | official page — $59.9 |
| Unit LCD | unit | grove_i2c | official page — $17.5 |
M5Stack CoreS3とUnit LCDをGrove I2Cケーブルで接続し、小さなカラー液晶画面を追加するシンプルな組み立てガイドです。Unit LCDは1.14インチ、135x240ピクセルのディスプレイで、CoreS3からI2C経由で制御します。
# M5Stack CoreS3 + Unit LCD (I2C)
# Wiring: Unit LCD -> CoreS3 Port.A (red Grove I2C port)
import machine
import time
from m5stack import lcd
# Unit LCD uses ST7789V2 driver via I2C (address 0x3C)
# We'll use a simple framebuffer approach
# For simplicity, we use the built-in lcd object for CoreS3's own screen
# and send data to Unit LCD via I2C
# I2C initialization on Port.A (pins: SDA=32, SCL=33 on CoreS3)
i2c = machine.I2C(0, sda=machine.Pin(32), scl=machine.Pin(33), freq=400000)
# Unit LCD I2C address (ST7789V2 typically 0x3C)
LCD_ADDR = 0x3C
# Simple function to send a command to the LCD
def lcd_cmd(cmd):
i2c.writeto(LCD_ADDR, bytes([0x00, cmd]))
# Simple function to send data to the LCD
def lcd_data(data):
i2c.writeto(LCD_ADDR, bytes([0x40]) + data)
# Initialize the LCD (basic init sequence for ST7789V2)
def lcd_init():
lcd_cmd(0x01) # Software reset
time.sleep_ms(150)
lcd_cmd(0x11) # Sleep out
time.sleep_ms(255)
lcd_cmd(0x3A) # Interface pixel format
lcd_data(b'\x05') # 16-bit color (RGB565)
lcd_cmd(0x36) # Memory data access control
lcd_data(b'\x00') # Normal orientation
lcd_cmd(0x21) # Display inversion on
lcd_cmd(0x13) # Normal display mode on
lcd_cmd(0x29) # Display on
time.sleep_ms(100)
# Fill screen with a color (RGB565)
def lcd_fill(color):
# Set address window to full screen (135x240)
lcd_cmd(0x2A) # Column address set
lcd_data(b'\x00\x00\x00\x87') # 0 to 135
lcd_cmd(0x2B) # Row address set
lcd_data(b'\x00\x00\x00\xEF') # 0 to 239
lcd_cmd(0x2C) # Memory write
# Send color for each pixel (135*240 = 32400 pixels, 2 bytes each)
data = color.to_bytes(2, 'big') * 32400
i2c.writeto(LCD_ADDR, bytes([0x40]) + data)
# Display text (simplified: just clear and show a message)
def lcd_show_text(text):
lcd_fill(0x0000) # Black background
# For simplicity, we just write raw bytes to display a fixed message
# In practice, you'd use a font library
# Here we just set a few pixels to show something
# Actually, let's use the CoreS3's own screen to show status
lcd.clear()
lcd.print('Unit LCD initialized', 10, 20)
lcd.print('Check Unit LCD', 10, 50)
# Main
lcd_init()
lcd_show_text('Hello from CoreS3!')
# Keep running
while True:
time.sleep(1)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。