pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Face Calculator

案例程序

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

setScreenColor(0x222222)
faces_calc = face.get(face.CALC)

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

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


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

功能说明

faces_calc.isNewKeyPress()
  • 检测是否有新的按键按下:
    • True:新的按键按下
    • False:无新的按键按下
faces_calc.readKey()
  • 读取输入按键key值
faces_calc.readStr()
  • 读取输入字符串。将会积累连续输入的内容。
faces_calc.deleteStrLast()
  • 删除输入的最后一个字符
faces_calc.clearStr()
  • 清空输入的字符
On This Page