def __init__(self, outport: mido.ports.BaseOutput): self._timer = None self._layer_revert_interval = 0.0 self._outport = outport self._time_of_last_activity = time.time() ActiveLayer().subscribe_to_layer_change(self._on_layer_change) ActiveLayer().subscribe_to_activity(self._on_activity)
def set_active_layer(self, newlayer: ActiveLayerIdentifier): if newlayer == ActiveLayerIdentifier.A: msg = mido.Message('program_change', program=0) else: msg = mido.Message('program_change', program=1) self._outport.send(msg) ActiveLayer().active_layer = newlayer
def __init__(self, encoder_index, outport: mido.ports.BaseOutput): self._encoder_index = encoder_index self._receive_data_cc = self._encoder_index self._receive_data_note = self._encoder_index - 1 self._led_ring_value_cc = self._encoder_index + 8 self._on_layer = ActiveLayerIdentifier.A self._event_up = None self._event_down = None self._alternate_event_up = None self._alternate_event_down = None self._alternate_active = False self._event_press = None self._event_press_short = None self._event_press_long = None self._time_of_note_on = time.time() self._current_led_ring_value = 0 if self._encoder_index > 8: self._receive_data_cc += 2 self._receive_data_note += 16 self._led_ring_value_cc -= 8 self._on_layer = ActiveLayerIdentifier.B self._outport = outport ActiveLayer().subscribe_to_layer_change(self._on_layer_change)
def set_led_ring_value(self, value: int, blink=False): if blink: value += 13 self._current_led_ring_value = value if ActiveLayer().active_layer == self._on_layer: self._update_led_ring()
def set_led_ring_value(self, value: int, blink=False): if ActiveLayer().active_layer != self._on_layer: return if blink: value += 13 msg = mido.Message('control_change', control=self._led_ring_value_cc, value=value) self._outport.send(msg)
def set_led_on_off(self, on: bool, blink=False): value = 0 if on: value = 1 if blink: value = 2 self._current_led_value = value if ActiveLayer().active_layer == self._on_layer: self._update_led()
def set_led_ring_on_off(self, on: bool, blink=False): if ActiveLayer().active_layer != self._on_layer: return value = 0 if on: value = 27 if blink: value = 28 self._current_led_ring_value = value self._update_led_ring()
def set_led_ring_on_off(self, on: bool, blink=False): if ActiveLayer().active_layer != self._on_layer: return value = 0 if on: value = 27 if blink: value = 28 msg = mido.Message('control_change', control=self._led_ring_value_cc, value=value) self._outport.send(msg)
def set_led_on_off(self, on: bool, blink=False): if ActiveLayer().active_layer != self._on_layer: return value = 0 if on: value = 1 if blink: value = 2 msg = mido.Message('note_on', note=self._led_control_note, velocity=value) self._outport.send(msg)
def __init__(self, button_index, outport: mido.ports.BaseOutput): self._button_index = button_index self._receive_data_note = self._button_index + 7 self._led_control_note = self._button_index - 1 self._on_layer = ActiveLayerIdentifier.A self._simvar = None self._mobiflightsimvar = None self._event_press = None self._event_press_short = None self._event_press_long = None self._time_of_note_on = time.time() self._current_led_value = 0 if self._button_index > 16: self._receive_data_note += 8 self._led_control_note -= 16 self._on_layer = ActiveLayerIdentifier.B self._outport = outport ActiveLayer().subscribe_to_layer_change(self._on_layer_change)
def _update_active_layer(self): ActiveLayer().active_layer = self._on_layer