pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

NCIR2 Unit

案例程序

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

setScreenColor(0x222222)
ncir2_0 = unit.get(unit.NCIR2, unit.PORTA)

ncir2_0.init_i2c_address(0x5A)
while True:
  print((str('temperature:') + str((ncir2_0.temperature_measure()))))
  print((str('emissivity:') + str((ncir2_0.emissivity_measure()))))
  print((str('threshold value:') + str((ncir2_0.temperature_threshold(0x20)))))
  print((str('buzzer frequency:') + str((ncir2_0.temp_buzzer_freq(0x40)))))
  wait(1)
  wait_ms(2)

功能说明

ncir2_0.init_i2c_address(0x5A)
  • 初始化I2C通讯地址
print(ncir2_0.button_status())
  • 获取按键状态(按下或者放开)
print(ncir2_0.buzzer_control())
  • 获取蜂鸣器使能状态(打开或者关闭)
print(ncir2_0.buzzer_duty())
  • 获取蜂鸣器占空比(占空比数值0-255,数值越大,响度越大)
print(ncir2_0.buzzer_freq())
  • 获取蜂鸣器频率值(默认4000)
print(ncir2_0.read_device_status(0xFE))
  • 获取设备固件版本或I2C地址(I2C默认地址为0x5A)
print(ncir2_0.chip_temperature_measure())
  • 获取设备温度值 ( ℃ )
print(ncir2_0.emissivity_measure())
  • 获取物体表面的反射率
print(ncir2_0.rgb_led())
  • 获取RGB LED颜色(RGB值为0-255)
print(ncir2_0.temperature_measure())
  • 获取温度值
print(ncir2_0.temp_buzzer_duty(0x44))
  • 设定最高最低温度下蜂鸣器的占空比(占空比数值为0-255,占空比越大响度越大)
print(ncir2_0.temp_buzzer_freq(0x40))
  • 获取最高或最低温度时蜂鸣器频率(默认为4000,数值越高响度越尖锐)
print(ncir2_0.temp_alarm_interval(0x42))
  • 获取最高或最低温度时蜂鸣器高低电平间隔(默认最低为100,最高为204)
print(ncir2_0.temp_alarm_led(0x30))
  • 获取最高或最低温度时LED的颜色(RGB值为0-255)
print(ncir2_0.temperature_threshold(0x20))
  • 获取最高或最低温度阈值(默认设置为最低10°C,最高37°C)
ncir2_0.save_config_setting()
  • 保存当前配置设定
ncir2_0.buzzer_duty(80)
  • 获取蜂鸣器占空比(占空比数值0-255,数值越大,响度越大)
ncir2_0.buzzer_freq(4000)
  • 设定蜂鸣器的频率(默认蜂鸣器频率为4000,数值越大响度越大)
ncir2_0.buzzer_control(0x01)
  • 设定蜂鸣器的使能状态(打开或者关闭)
ncir2_0.emissivity_measure(0.95)
  • 设定反射率(皮肤反射率为0.95)
ncir2_0.write_i2c_address(0x5A)
  • 设置设备的I2C地址(默认为0x5A)
ncir2_0.rgb_led(50, 50, 50)
  • 设定RGB LED的颜色值(RGB值范围0-255)
ncir2_0.temp_buzzer_duty(0x44, 80)
  • 设定最高最低温度下蜂鸣器的占空比(占空比数值为0-255,占空比越大响度越大)
ncir2_0.temp_buzzer_freq(0x40, 4000)
  • 设定最高或最低温度下蜂鸣器的间隔(数值设置越高响得越快)
ncir2_0.temp_alarm_interval(0x42, 100)
  • 设定最高或最低温度下蜂鸣器的间隔(数值设置越高响得越快)
ncir2_0.temp_alarm_led(0x30, 50, 50, 50)
  • 设定最高或最低温时蜂鸣器频率(这里默认设置为4000,频率越大,响声越尖锐)
ncir2_0.temperature_threshold(0x20, 25)
  • 设定最高或最低温时LED RGB颜色值(RGB值在0-255之间)
On This Page