Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom BlenderDMX namespace driver #89

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,14 @@ def onLoadFile(scene):
DMX_MVR_X_Protocol.disable()
DMX_Zeroconf.disable()

# register a "bdmxX" namespace to get current value of a DMX channel,
# the syntax is #bdmxX(universe, address), where X is c or f (coarse, fine)
# for example: #bdmxc(1,1)
data_get_coarse = DMX_Data.get_coarse
data_get_fine = DMX_Data.get_fine
bpy.app.driver_namespace['bdmxc'] = data_get_coarse
bpy.app.driver_namespace['bdmxf'] = data_get_fine

@bpy.app.handlers.persistent
def onUndo(scene):
if (not scene.dmx.collection and DMX.linkedToFile):
Expand Down
12 changes: 12 additions & 0 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ def setup(universes):
DMX_Data._universes.append(bytearray([0]*512))
print("DMX", "Universe Allocated: ", u)

@staticmethod
def get_coarse(universe, addr):
"""Used for the namespace bdmxc function
Returns single 8bit value """
return DMX_Data.get(universe, addr, 1)[0]

@staticmethod
def get_fine(universe, addr):
"""Used for the namespace bdmxf function
Returns single 16bit value"""
data = DMX_Data.get(universe, addr, 2)
return data[0]*256+data[1]

@staticmethod
def get(universe, addr, n):
Expand Down