NCIR Hat
支持以下产品:
MicroPython 应用示例
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import * 9from hat import NCIRHat 10 11 12label0 = None 13i2c0 = None 14hat_ncir_0 = None 15 16 17def setup(): 18 global label0, i2c0, hat_ncir_0 19 20 M5.begin() 21 label0 = Widgets.Label("label0", 39, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 22 23 i2c0 = I2C(0, scl=Pin(26), sda=Pin(0), freq=100000) 24 hat_ncir_0 = NCIRHat(i2c0) 25 26 27def loop(): 28 global label0, i2c0, hat_ncir_0 29 M5.update() 30 label0.setText(str(hat_ncir_0.get_object_temperature())) 31 32 33if __name__ == "__main__": 34 try: 35 setup() 36 while True: 37 loop() 38 except (Exception, KeyboardInterrupt) as e: 39 try: 40 from utility import print_error_msg 41 42 print_error_msg(e) 43 except ImportError: 44 print("please update to latest firmware")
UiFlow2 应用示例
stickc_plus2_ncir_example.m5f2
class NCIRHat
Constructors
- class NCIRHat(i2c, address: int = 0x5A)
创建一个 NCIRHat 对象。
- 参数:
i2c – I2C 对象
address – 设备的 I2C 地址。默认值为 0x5A。
UIFLOW2:

NCIRHat 类继承自 NCIRUnit 类,更多详情请参阅 unit.NCIRUnit.Methods。

