Skip to content

Commit

Permalink
initial commit of python package. currently unit tests are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
monzelr committed Nov 23, 2021
1 parent 0b8431d commit f97fbf0
Show file tree
Hide file tree
Showing 19 changed files with 1,010 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so
*.c

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# IDE settings
.vscode/

# Pycharm
.idea
/python/ipt/ipt.c
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include dmx/__init__.py
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
USB-DMX512 Python Module
========================

This python module supports actual the following USB-DMX interfaces (FT232R chip based):
- EUROLITE USB-DMX512 PRO Cable Interface [(Link)](https://www.steinigke.de/en/mpn51860122-eurolite-usb-dmx512-pro-cable-interface.html)
- EUROLITE USB-DMX512 PRO Interface MK2 [(Link)](https://www.steinigke.de/en/mpn51860121-eurolite-usb-dmx512-pro-interface-mk2.html)


Requirements
------------
- Python ≥ 3.6
- numpy
- pyserial

Note: Tested on Windows 10, amd64, Python 3.8 \
Should also work on Linux, MacOS and on AARCH64 devices (ARM devices like Raspberry PI).


Installation
------------
Make sure to have git, python and pip in your environment path or activate your python environment before this code snippet:

git clone https://github.com/monzelr/dmx.git

cd dmx

pip install dmx

Example Code Snippets
---------------------
If you want to dim 4 channels up and down:

from dmx import DMX
import time

dmx = DMX(num_of_channels=4)
dmx.set_data(1, 0)
dmx.set_data(2, 0)
dmx.set_data(3, 0)
dmx.set_data(4, 0)

while True:
for i in range(0, 255, 5):
dmx.set_data(1, i, auto_send=False)
dmx.set_data(2, i, auto_send=False)
dmx.set_data(3, i, auto_send=False)
dmx.set_data(4, i)
time.sleep(0.01)

for i in range(255, 0, -5):
dmx.set_data(1, i, auto_send=False)
dmx.set_data(2, i, auto_send=False)
dmx.set_data(3, i, auto_send=False)
dmx.set_data(4, i)
time.sleep(0.01)

If you want to add your own adapter or multiple adapter by serial number:


from dmx import DMX

dmx = DMX()
my_device_serial_number = dmx.use_device.serial_number
del dmx

my_device_sn = dmx.use_device.serial_number
del dmx

dmx2 = DMX(serial_number=my_device_sn)
dmx2.set_data(1, 100)
dmx2.send()
time.sleep(1)
del dmx2

Technical notes
---------------
to EUROLITE USB-DMX512 PRO Cable Interface / EUROLITE USB-DMX512 PRO Interface MK2 :

- uses chip FTDI232R (like EUROLITE USB-DMX512 PRO Interface MK2)
- the FTDI FT232R updates the DMX automatically - you do no need to refresh the DMX universe by yourself
- if you only have 4 channels, set them at the DMX address start (1 to 4), thus sending updates to the FT232R chip is faster
- 250000 baudrate for the FT232R is a must
- needs 5 start bytes: [0x7E, 0x06, 0x01, 0x02, 0x00]

- byte 1: signal start byte 0x7E
- byte 2: TX DMX packet: 0x06
- byte 3 & 4: LSB of DMX length (in this case 513 -> do not forget address 0): 0x01 and 0x02
- byte 5: address 0 of DMX signal: 0x00
- supports only label 6: TX DMX Packet
- needs one end byte [0xE7]


Building the documentation
--------------------------
Go into the dmx root folder (where setup.py is) and type in the following command in the cmd/shell:

python setup.py build_sphinx

The documentation can than be found in dmx/build/sphinx/html.
16 changes: 16 additions & 0 deletions dmx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Top-level package"""

from dmx.dmx import DMX
from dmx.dmx import logger
from dmx.dmx import Device
from dmx.dmx import DEVICE_LIST
from dmx.dmx import sleep_us

__author__ = """Rune Monzel"""
__email__ = '[email protected]'
__version__ = '0.1.0'
__all__ = ['DMX',
'logger',
'Device',
'DEVICE_LIST',
'sleep_us',]
Loading

0 comments on commit f97fbf0

Please sign in to comment.