pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Face Calculator

Example

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)

API

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