pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Module DMX Base

案例程序

Master

from m5stack import *
from m5ui import *
from uiflow import *
import module

import time

setScreenColor(0x222222)
dmx = module.get(module.DMX512)

dmx.dmx_init(13, 35, 12, 1)
while True:
  dmx.write_dmx_data(1, 0)
  wait(1)
  dmx.write_dmx_data(2, 0)
  wait(1)
  dmx.write_dmx_data(3, 0)
  wait(1)
  dmx.write_dmx_data(1, 255)
  wait(1)
  dmx.write_dmx_data(2, 255)
  wait(1)
  dmx.write_dmx_data(3, 255)
  wait(1)
  wait_ms(2)

Slave

from m5stack import *
from m5ui import *
from uiflow import *
import module

setScreenColor(0x222222)

dmx = module.get(module.DMX512)

dmx.dmx_init(13, 35, 12, 2)
while True:
  print((str('ch1:') + str((dmx.read_dmx_data(1)))))
  print((str('ch2:') + str((dmx.read_dmx_data(2)))))
  print((str('ch3:') + str((dmx.read_dmx_data(3)))))
  dmx.clear_dmx_buffer()
  wait_ms(2)

功能说明

import module
dmx = module.get(module.DMX512)
dmx.dmx_init(tx, rx, en, mode)
  • 初始化DMX引脚配置,并指定工作模式(master/slave):
    • mode:
      • master:1
      • slave:2
dmx.read_dmx_data(ch)
  • slave模式下, 接收指定channel数据:
    • ch:1-512
dmx.write_dmx_data(ch, 100)
  • master模式下, 写入数据到指定channel:
    • ch:1-512
dmx.clear_dmx_buffer()
  • 清空DMX数据buffer
dmx.delete_port()
  • 逆初始化DMX,释放端口资源
On This Page