pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Faces Gameboy

Example

Read and print the status of the direction keys and buttons of the GAMEBOY extension module

from m5stack import *
from m5ui import *
from uiflow import *
import face

setScreenColor(0x222222)

faces_boy = face.get(face.GAMEBOY)

while True:
  if faces_boy.getStatus(0):
    print('up')
  if faces_boy.getStatus(1):
    print('down')
  if faces_boy.getStatus(2):
    print('left')
  if faces_boy.getStatus(3):
    print('right')
  if faces_boy.getStatus(4):
    print('Button A')
  if faces_boy.getStatus(5):
    print('Button B')
  if faces_boy.getStatus(6):
    print('Button Select')
  if faces_boy.getStatus(7):
    print('Button Start')
  wait_ms(2)

API

faces_boy.getPressed(key)
  • Detecting gameboy key click, release events.
    • key:
      • 0:up
      • 1:down
      • 2:left
      • 3:right
      • 4:BtnA
      • 5:BtnB
      • 6:Btn Select
      • 7:Btn Start
faces_boy.getStatus(key)
  • Detecting gameboy keyboard key press status
    • key:
      • 0:up
      • 1:down
      • 2:left
      • 3:right
      • 4:BtnA
      • 5:BtnB
      • 6:Btn Select
      • 7:Btn Start
On This Page