pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Face Keyboard

Example

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

setScreenColor(0x222222)

faces_keyboard = face.get(face.KEYBOARD)

def buttonA_wasPressed():
  # global params
  faces_keyboard.clearStr()
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  faces_keyboard.deleteStrLast()
  pass
btnB.wasPressed(buttonB_wasPressed)


while True:
  if faces_keyboard.isNewKeyPress():
    print((str('Button value:') + str((faces_keyboard.readKey()))))
    print((str('Input string:') + str((faces_keyboard.readStr()))))
  wait_ms(2)

API

faces_keyboard.isNewKeyPress()
  • Detects if a new key is pressed:
    • True:New button pressed
    • False:No new buttons pressed
faces_keyboard.readKey()
  • Read the input key value
faces_keyboard.readStr()
  • Reads the input string. Successive inputs will be accumulated.
faces_keyboard.deleteStrLast()
  • Delete the last character entered
faces_keyboard.clearStr()
  • Clear the entered string
On This Page