pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Glass2

Example

draw the text

from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

glass2_0 = unit.get(unit.GLASS2_OLED, unit.PORTA)

font_size = None
from numbers import Number

font_size = 0
glass2_0.fill(0x000000)
for count in range(4):
  font_size = (font_size if isinstance(font_size, Number) else 0) + 1
  if font_size == 1:
    glass2_0.print('M5STACK', 0, 0, 1, 0xffffff)
  elif font_size == 2:
    glass2_0.print('M5STACK', 10, 0, 2, 0xffffff)
  elif font_size == 3:
    glass2_0.print('M5STACK', 25, 0, 3, 0xffffff)
  elif font_size == 4:
    glass2_0.print('M5STACK', 40, 0, 4, 0xffffff)
    font_size = 0
  glass2_0.show()
  wait_ms(500)
glass2_0.fill(0x000000)
glass2_0.show()

API

glass2_0.init_device_address(0x3C)
  • Set I2C address (0x3C~0x3D)
glass2_0.contrast(0)
  • Set screen brightness
glass2_0.invert(1)
  • Set screen color (normal display or inverted color)
    • 0: NORMAL
    • 1: REVERSE
glass2_0.power_ctrl(0x00)
  • Turn screen power on and off (ON/OFF)
glass2_0.scroll(0, 0)
  • Make a new copy of the contents of the more than one running code screen and define the initial location
glass2_0.show()
  • Turn on screen display
glass2_0.fill(0xffffff)
  • Set full-screen color
    • White: White
    • Black: Black
glass2_0.fill_rect(0, 0, 0, 0, 0xffffff)
  • Draw a square
glass2_0.hline(0, 0, 0, 0xffffff)

-- Draw a horizontal line

glass2_0.image(0, 0, "/flash/img/m5stack.pbm")
  • Fill external resource image
glass2_0.line(0, 0, 0, 0, 0xffffff)
  • Draw a line, input coordinates from point to point
glass2_0.pixel(0, 0, 0xffffff)
  • Input pixel for display
glass2_0.rect(0, 0, 0, 0, 0xffffff)
  • Draw a rectangle
glass2_0.print('M5Stack', 0, 0, 1, 0xffffff)
  • Draw text
glass2_0.vline(0, 0, 0, 0xffffff)
  • Draw a vertical line
On This Page