diff options
| -rw-r--r-- | console.py | 7 | ||||
| -rw-r--r-- | faders.py | 15 | ||||
| -rw-r--r-- | strips.py | 2 |
3 files changed, 9 insertions, 15 deletions
@@ -49,11 +49,11 @@ class ConsoleStatus(): # reverse the bit order before slicing so the index '0' is the LSB # and reverse back before converting to int - return int(bits32(bits)[::-1][first_bit:last_bit][::-1], 2) + return int(bits32(bits)[::-1][first_bit-1:last_bit][::-1], 2) class RunningStatusThread(): - def __init__(self, console, interval=1): + def __init__(self, console, interval=0.1): """ Constructor :type interval: int :param interval: Check interval, in seconds @@ -116,7 +116,8 @@ class Console(): changed = before ^ after - for bit in [i for i, b in enumerate(reversed(bits32(changed))) if int(b)]: + bits = reversed(bits32(changed)) + for bit in [i for i, b in enumerate(bits) if int(b)]: high = bool(after & (0b1 << bit)) button = self.buttons[index][int(bit)] if button is None: @@ -41,7 +41,6 @@ class Fader(Button): name = 'Strip {} Fader'. format(strip.num) super().__init__(console, name) self.strip = strip - self.pos = 0 self.addr = '/strip/fader' self.status_quadlet = status_quadlets[self.strip.num] self.status_bits = status_bits[self.strip.num] @@ -49,21 +48,15 @@ class Fader(Button): @property def position(self): - return self.pos + return self.console.status.field(self.status_quadlet, self.status_bits) @position.setter def position(self, pos): - self.pos = pos self.console.unit.strips[self.strip.num].set_position(pos) - def send_pos(self): - osc.client.sent_message(self.addr, (self.strip, self.pos/1023)) - - def handle_console_status(self, pos): - if pos != self.pos: - print('{}: {}'.format(self.name, pos)) - self.pos = pos - self.send_pos() + def send_pos(self, pos): + print('{}, ({}, {})'.format(self.addr, self.strip.num, pos/1023)) + osc.client.send_message(self.addr, (self.strip.num, pos/1023)) def press(self): self.console.status_thread.add_callback(self) @@ -28,7 +28,7 @@ class Strip(): def __init__(self, console, num): self.console = console - self.num = 0 + self.num = num self.mute_button = None self._mute = False self.solo_button = None |
