IR Unit

支持以下产品:

IR

Micropython Example:

 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:

example.png

ir_core_example.m5f2

class IRUnit

Constructors

class IRUnit(port)

Create an IRUnit object.

参数:

port (tuple) – The port to which the IR unit is connected. the tuple is a pair of values, the first value is the receive pin, and the second value is the transmit pin.

UIFLOW2:

init.png

Methods

IRUnit.tx()

向某个地址发送ir信号值。

UIFLOW2:

tx.png

IRUnit.rx_event()

判断读取到红外信号的时候,开始做某些处理程序。

UIFLOW2:

rx_event.png