IR
IR is used to control the infrared receiving/transmitting tube built into the host device.
The specific support of the host for IR is as follows:
Controller |
IR Transmitter |
IR Receiver |
|---|---|---|
Atom Lite |
✔ |
|
Atom Matrix |
✔ |
|
Atom U |
✔ |
|
AtomS3 Lite |
✔ |
|
AtomS3U |
✔ |
|
M5StickC |
✔ |
|
M5StickC PLUS |
✔ |
|
M5StickC PLUS2 |
✔ |
|
Cardputer |
✔ |
|
M5Capsule |
✔ |
Micropython Example:
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 * 9 10 11ir = None 12 13 14def setup(): 15 global ir 16 17 M5.begin() 18 ir = IR() 19 20 21def loop(): 22 global ir 23 M5.update() 24 ir.tx(0x01, 0) 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:
class IR
Constructors
- class IR
Initializes the IR unit with the appropriate pins based on the M5Stack board type.
UIFLOW2:

Methods
- IR.tx(cmd, data)
Transmits an IR signal with the specified command and data using the NEC protocol.
- 参数:
cmd – The command code to be transmitted.
data – The data associated with the command.
UIFLOW2:

