diff options
| -rw-r--r-- | tascam_fw_console/console.py | 24 | ||||
| -rw-r--r-- | tascam_fw_console/fader.py | 16 |
2 files changed, 20 insertions, 20 deletions
diff --git a/tascam_fw_console/console.py b/tascam_fw_console/console.py index 666bdf6..73e9b78 100644 --- a/tascam_fw_console/console.py +++ b/tascam_fw_console/console.py @@ -43,26 +43,26 @@ ENCODER_MODES = ['PAN', 'AUX1', 'AUX2', 'AUX3', 'AUX4', 'AUX5', 'AUX6', 'AUX7', 'AUX8'] -class ConsoleStatus(): +class ConsoleState(): def __init__(self, quadlets): self.quadlets = quadlets def field(self, index, first_bit=0, last_bit=32): bits = self.quadlets[index] - # reverse the bit order before slicing so the index '0' is the LSB + # reverse the bit order before slicing so that index '0' is the LSB # and reverse back before converting to int return int(bits32(bits)[::-1][first_bit-1:last_bit][::-1], 2) -class RunningStatusThread(): +class RunningStateThread(): def __init__(self, console, interval=0.1): - """ Background thread that will poll the console status data and + """ Background thread that will poll the console state data and pass it to all objects in the callbacks set. If the callback set is empty, polling doesn't happen. - Objects added to the callback set must have a status_callback() - method, a status_quadlet attribute containing the index of the - quadlet of interest, and a status_bits attribute containing a 2 member + Objects added to the callback set must have a state_callback() + method, a state_quadlet attribute containing the index of the + quadlet of interest, and a state_bits attribute containing a 2 member iterable with the start and end bits of the quadlet of interest. :param console: Console object @@ -87,10 +87,10 @@ class RunningStatusThread(): def run(self): while True: for obj in self.callbacks: - value = self.console.status.field(obj.status_quadlet, - *obj.status_bits, - ) - obj.status_callback(value) + value = self.console.state.field(obj.state_quadlet, + *obj.state_bits, + ) + obj.state_callback(value) time.sleep(self.interval) @@ -146,7 +146,7 @@ class Console(): self.unit.set_master_fader(False) self.unit.connect('control', self.handle_control) - self.status_thread = RunningStatusThread(self) # noqa F841 + self.state_thread = RunningStateThread(self) # noqa F841 def init_strips(self): self.strips = [] diff --git a/tascam_fw_console/fader.py b/tascam_fw_console/fader.py index fedfe39..7ed1932 100644 --- a/tascam_fw_console/fader.py +++ b/tascam_fw_console/fader.py @@ -22,8 +22,8 @@ from tascam_fw_console import osc -status_quadlets = (4, 0, 0, 1, 1, 2, 2, 3, 3) -status_bits = ((1, 16), +state_quadlets = (4, 0, 0, 1, 1, 2, 2, 3, 3) +state_bits = ((1, 16), (1, 16), (17, 32), (1, 16), @@ -48,13 +48,13 @@ class Fader(): self.addr = '/strip/fader' self.press_args = (1,) self.release_args = (0,) - self.status_quadlet = status_quadlets[self.strip.num] - self.status_bits = status_bits[self.strip.num] - self.status_callback = self.send_pos + self.state_quadlet = state_quadlets[self.strip.num] + self.state_bits = state_bits[self.strip.num] + self.state_callback = self.send_pos @property def position(self): - return self.console.status.field(self.status_quadlet, *self.status_bits) + return self.console.state.field(self.state_quadlet, *self.state_bits) @position.setter def position(self, pos): @@ -70,10 +70,10 @@ class Fader(): addr = '{}_touch'.format(self.addr) args = self.press_args + (1,) osc.client.send_message(addr, args) - self.console.status_thread.add_callback(self) + self.console.state_thread.add_callback(self) def release(self): addr = '{}_touch'.format(self.addr) args = self.press_args + (0,) osc.client.send_message(addr, args) - self.console.status_thread.remove_callback(self) + self.console.state_thread.remove_callback(self) |
