pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

DMX Base

Example

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)

API

import module
dmx = module.get(module.DMX512)
dmx.dmx_init(tx, rx, en, mode)
  • Initialize the DMX pin configuration and specify the operating mode (master/slave):
    • mode:
      • master:1
      • slave:2
dmx.read_dmx_data(ch)
  • In slave mode, receive data from the specified channel.
    • ch:1-512
dmx.write_dmx_data(ch, 100)
  • In master mode, write data to the specified channel.
    • ch:1-512
dmx.clear_dmx_buffer()
  • Empty the DMX data buffer
dmx.delete_port()
  • Inverse initialize DMX, release port resources
On This Page