OLED Unit

Unit OLED is a 1.3-inch OLED expansion screen unit. Driveing by SH1107, and the resolution is 128*64, monochrome display.

Support the following products:

OLEDUnit

Micropython Example:

 1import os, sys, io
 2import M5
 3from M5 import *
 4from hardware import I2C
 5from hardware import Pin
 6
 7
 8label0 = None
 9label1 = None
10i2c0 = None
11oled_0 = None
12
13
14def setup():
15    global label0, label1, i2c0, oled_0
16
17    M5.begin()
18    Widgets.fillScreen(0x222222)
19    label0 = Widgets.Label("CoreS3", 127, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
20
21    i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
22    oled_0 = M5.addDisplay(i2c0, 0x3C, {"unit_oled": True})
23    label1 = Widgets.Label("OLED", 5, 53, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18, oled_0)
24
25
26def loop():
27    global label0, label1, i2c0, oled_0
28    M5.update()
29
30
31if __name__ == "__main__":
32    try:
33        setup()
34        while True:
35            loop()
36    except (Exception, KeyboardInterrupt) as e:
37        try:
38            from utility import print_error_msg
39
40            print_error_msg(e)
41        except ImportError:
42            print("please update to latest firmware")

UIFLOW2 Example:

example.png

cores3_oled_example.m5f2

class OLEDUnit

Constructors

class OLEDUnit(i2c, address: int = 0x3c, freq: int = 400000)

Initialize the Unit OLED

参数:
  • i2c (I2C) – the I2C object.

  • address (int) – I2C address of the Unit OLED, default is 0x3c.

  • freq (int) – I2C frequency of the Unit OLED.

UIFLOW2:

init.png