IR Unit

支持以下产品:

IR

MicroPython 应用示例

 1import os, sys, io
 2import M5
 3from M5 import *
 4from unit import IRUnit
 5import time
 6
 7
 8ir_0 = None
 9
10
11def setup():
12    global ir_0
13
14    M5.begin()
15    Widgets.fillScreen(0x222222)
16
17    ir_0 = IRUnit((36, 26))
18
19
20def loop():
21    global ir_0
22    M5.update()
23    ir_0.tx(0, 0)
24    time.sleep(1)
25
26
27if __name__ == "__main__":
28    try:
29        setup()
30        while True:
31            loop()
32    except (Exception, KeyboardInterrupt) as e:
33        try:
34            from utility import print_error_msg
35
36            print_error_msg(e)
37        except ImportError:
38            print("please update to latest firmware")

UiFlow2 应用示例

example.png

ir_core_example.m5f2

class IRUnit

Constructors

class IRUnit(port)

创建一个 IRUnit 对象。

参数:

port (tuple) – IR 单元连接的端口。该元组是一对值,第一个值为接收引脚,第二个值为发射引脚。

UIFLOW2:

init.png

Methods

IRUnit.tx()

发送一个 IR 信号值到指定地址。

UIFLOW2:

tx.png

IRUnit.rx_event()

判断何时读取到红外信号,并开始执行一些处理流程。

UIFLOW2:

rx_event.png