pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit IR

Example

Receive IR data

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

setScreenColor(0x222222)
ir_0 = unit.get(unit.IR_NEC, unit.PORTB)

addr = None
data = None

def ir_nec_rx_cb(_data, _addr, _ctrl):
  global addr, data
  data = _data
  addr = _addr
  print((str('addr:') + str(addr)))
  print((str('data:') + str(data)))

ir_0.rx_cb(ir_nec_rx_cb)

ir_0.txOn()
addr = 0
addr = 27
while True:
  print((str('state:') + str((ir_0.rxStatus()))))
  wait_ms(2)

API

def ir_nec_rx_cb(_data, _addr, _ctrl):
  # global params
  data = _data
  addr = _addr

ir_0.rx_cb(ir_nec_rx_cb)
  • Receives IR data sent to the specified address and triggers the function
ir_0.tx(0, 0)
  • Send the IR signal value to the address
ir_0.txOff()
  • Enable data sending
ir_0.txOn()
  • Disable data sending
print((str('state:') + str((ir_0.rxStatus()))))
  • Obtain the current device status
On This Page