pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Button

Example

Output button state

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

setScreenColor(0x222222)
button_0 = unit.get(unit.BUTTON, unit.PORTB)

while True:
  if button_0.wasPressed():
    print('Pressed')
  else:
    print('Released')
  wait_ms(2)

API

def button_0_wasPressed_cb():
  # global params
  pass
button_0.wasPressed(button_0_wasPressed_cb)
  • Callback function (trigger button)
print((str('status:') + str((button_0.wasPressed()))))
  • Gets the state after the button is triggered
On This Page