pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Heart Rate

案例程序

获取心率和血氧的数值

from m5stack import *
from m5ui import *
from uiflow import *
import time
import hat

setScreenColor(0x111111)

hat_heartrate_0 = hat.get(hat.HEART_RATE)

hat_heartrate_0.setMode(0x03)
while True:
  print(hat_heartrate_0.getHeartRate())
  print(hat_heartrate_0.getSpO2())
  wait(0.4)
  wait_ms(2)

功能说明

hat_heartrate_0.getHeartRate()
  • 获取心率数据
hat_heartrate_0.getIr()
  • 获取红外原始ADC值
hat_heartrate_0.getRed()
  • 获取红光原始ADC值
hat_heartrate_0.getSpO2()
  • 获取血氧饱和度(SpO2)数据
hat_heartrate_0.setLedCurrent(0x00, 0x00)
  • 设置红光和红外LED的电流值
hat_heartrate_0.setMode(0x02)
  • 设置心率或其他模式
On This Page