pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Dual Button

Example

Output button state

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

setScreenColor(0x222222)
dual_button_0 = unit.get(unit.DUAL_BUTTON, unit.PORTB)

while True:
  if dual_button_0.btnBlue.wasPressed():
    rgb.setColorAll(0x000099)
    print('Blue button pressed')
  elif dual_button_0.btnRed.wasPressed():
    rgb.setColorAll(0xcc0000)
    print('Red button pressed')
  wait_ms(2)

API

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