Glass2 Unit

Glass2 Unit是一款1.51英寸透明OLED显示单元,采用SSD1309驱动方案。

支持以下产品:

Glass2Unit

UiFlow2 应用示例

绘制文本

在 UiFlow2 中打开 cores3_glass2_example.m5f2 项目。

此示例在屏幕上显示文本“GLASS2”。

UiFlow2 代码块:

example.png

示例输出:

None

MicroPython 应用示例

绘制文本

此示例在屏幕上显示文本“GLASS2”。

MicroPython 代码块:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import I2C
 9from hardware import Pin
10from unit import Glass2Unit
11
12
13label0 = None
14label1 = None
15i2c0 = None
16glass2_0 = None
17
18
19def setup():
20    global label0, label1, i2c0, glass2_0
21
22    M5.begin()
23    Widgets.fillScreen(0x222222)
24    label0 = Widgets.Label("CoreS3", 127, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
25
26    i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
27    glass2_0 = Glass2Unit(i2c0, 0x3C)
28    label1 = Widgets.Label(
29        "GLASS2", 26, 21, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18, glass2_0
30    )
31
32
33def loop():
34    global label0, label1, i2c0, glass2_0
35    M5.update()
36
37
38if __name__ == "__main__":
39    try:
40        setup()
41        while True:
42            loop()
43    except (Exception, KeyboardInterrupt) as e:
44        try:
45            from utility import print_error_msg
46
47            print_error_msg(e)
48        except ImportError:
49            print("please update to latest firmware")

示例输出:

None

API参考

class Glass2Unit

class unit.glass2.Glass2Unit(i2c, address=60)

基类:object

初始化 Glass2 Unit。

参数:
  • i2c (I2C | PAHUBUnit) – Glass2 Unit 所连接的 I2C 总线。

  • address (int) – Glass2 Unit 的 I2C 地址,默认为 0x3C。

UiFlow2 代码块:

init.png

MicroPython 代码块:

from unit import Glass2Unit
glass2_0 = Glass2Unit(i2c0, 0x3c)

Glass2Unit 类继承了 Display 类,有关更多详细信息,请参阅 hardware.Display