diff options
author | Ben Connors <benconnors@outlook.com> | 2019-11-08 17:08:02 -0500 |
---|---|---|
committer | Ben Connors <benconnors@outlook.com> | 2019-11-08 17:08:02 -0500 |
commit | 1884a5197fbdf98bdaebafe2b25e3a7181967e30 (patch) | |
tree | f52cf449c61296970427570e2995a3dacdf5b3db | |
parent | 1f037f48e5badab2b758c4b9bd0541c5ccda7b3f (diff) |
Move to OLA rendering; bugfix
- Chaser.advance not using proper audio ID
- Add OLA renderer as main one
-rw-r--r-- | blc2/functions/chaser.py | 7 | ||||
-rw-r--r-- | interface/__main__.py | 4 | ||||
-rw-r--r-- | interface/ola.py | 22 |
3 files changed, 27 insertions, 6 deletions
diff --git a/blc2/functions/chaser.py b/blc2/functions/chaser.py index 5068fc2..0f7bb89 100644 --- a/blc2/functions/chaser.py +++ b/blc2/functions/chaser.py @@ -213,7 +213,7 @@ class Chaser(Function): raise ValueError("Chaser is finished") if data.steps: data.steps[-1].end_time = t - data.steps[-1].start_time - data.steps.append(self.steps[n]._get_data(t, n)) + data.steps.append(self.steps[n]._get_data(t, data.audio_id)) data.audio_id += 1 return data @@ -230,9 +230,8 @@ class Chaser(Function): if not self._steps: return (), (), data elif not data.steps: - ## Cross your fingers this is unnecessary... - # if data.audio_id != 0: - # raise ValueError("Audio ID must be zero") + if data.audio_id != 0: + raise ValueError("Audio ID must be zero") n = self.first_step sd = self.steps[n]._get_data(0, 0) #pylint: disable=protected-access data.audio_id += 1 diff --git a/interface/__main__.py b/interface/__main__.py index 64b47cd..712b746 100644 --- a/interface/__main__.py +++ b/interface/__main__.py @@ -3,9 +3,9 @@ import os import sys from .interface import Interface -from .dummy import DummyOutput +from .ola import OLAOutput if len(sys.argv) > 2: raise ValueError("Usage: %s [workspace file]" % sys.argv[0]) -Interface(sys.argv[1] if len(sys.argv) == 2 else None, DummyOutput()).main() +Interface(sys.argv[1] if len(sys.argv) == 2 else None, OLAOutput()).main() diff --git a/interface/ola.py b/interface/ola.py new file mode 100644 index 0000000..445b991 --- /dev/null +++ b/interface/ola.py @@ -0,0 +1,22 @@ +import array + +from ola.OlaClient import OlaClient + +class OLAOutput: + def set_values(self, values): + send = set() + for c, v in values.items(): + univ, addr = c.address + if univ not in self.universes: + self.universes[univ] = array.array('B', (0 for i in range(512))) + uni = self.universes[univ] + if uni[addr] != v: + uni[addr] = v + send.add(univ) + for univ in send: + self.client.SendDmx(univ, self.universes[univ]) + + def __init__(self): + self.client = OlaClient() + + self.universes = {1: array.array('B', (0 for i in range(512)))} |