pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Finger Unit

案例程序

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

setScreenColor(0x222222)
finger_0 = unit.get(unit.FINGER, unit.PORTE)

label1 = M5TextBox(23, 69, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
title0 = M5Title(title="FINGERPRINT", x=3, fgcolor=0xFFFFFF, bgcolor=0x0000FF)

def finger_0_cb(user_id, access):
  # global params
  if (access) == 1 and (user_id) == 1:
    rgb.setColorAll(0x33ff33)
    wait(1)
    rgb.setColorAll(0x000000)
  pass
finger_0.readFingerCb(callback=finger_0_cb)

def buttonA_wasPressed():
  # global params
  finger_0.removeAllUser()
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  finger_0.addUser(1, 1)
  pass
btnB.wasPressed(buttonB_wasPressed)

while True:
  label1.setText(str(finger_0.state))
  wait_ms(2)

功能说明

finger_0.uart_port_id(1)
  • 设置核心部件 ID
finger_0.addUser(1, 1)
  • 添加ID和访问权限
def finger_0_unknownCb():
  # global params
  pass
finger_0.getUnknownCb(finger_0_unknownCb)
  • 未知的id及权限执行以下操作(回调函数)
print(access)
  • 返回访问权限
print(user_id)
  • 返回ID
print(finger_0.state)
  • 读取传感器状态
def finger_0_cb(user_id, access):
  # global params
  pass
finger_0.readFingerCb(callback=finger_0_cb)
  • 添加ID和访问权限(回调函数)
finger_0.removeAllUser()
  • 移除所有指纹信息
移出指纹ID
  • 移出指纹ID
On This Page