msgs for button background leds
This commit is contained in:
@@ -15,13 +15,6 @@ class MessageFwToHost(Enum):
|
||||
TOUCH_BUTTON_RELEASE = 3
|
||||
|
||||
|
||||
class MessageHostToFw(Enum):
|
||||
LED_WHEEL_EFFECT_STATIC = 0
|
||||
LED_WHEEL_EFFECT_ALEXA_SWIPE = 1
|
||||
LED_WHEEL_EFFECT_CIRCULAR = 2
|
||||
LED_WHEEL_EFFECT_RANDOM_TWO_COLOR_INTERPOLATION = 3
|
||||
|
||||
|
||||
class TouchButton(Enum):
|
||||
LEFT_FOOT = 0
|
||||
RIGHT_FOOT = 1
|
||||
@@ -46,6 +39,9 @@ mouse_led_effect_to_message_id = {
|
||||
EffectReverseSwipe: 10,
|
||||
}
|
||||
|
||||
PREV_BUTTON_LED_MSG = 20
|
||||
NEXT_BUTTON_LED_MSG = 21
|
||||
|
||||
|
||||
class RfidTokenRead:
|
||||
def __init__(self, id: bytes):
|
||||
@@ -135,6 +131,16 @@ class MusicMouseProtocol(asyncio.Protocol):
|
||||
mouse_led_effect_to_message_id[type(effect_cfg)], len(msg_content))
|
||||
self.transport.write(header + msg_content)
|
||||
|
||||
def button_background_led_prev(self, val):
|
||||
msg_content = struct.pack("<f", val)
|
||||
header = struct.pack("<IBH", MAGIC_TOKEN_HOST_TO_FW, PREV_BUTTON_LED_MSG, len(msg_content))
|
||||
self.transport.write(header + msg_content)
|
||||
|
||||
def button_background_led_next(self, val):
|
||||
msg_content = struct.pack("<f", val)
|
||||
header = struct.pack("<IBH", MAGIC_TOKEN_HOST_TO_FW, NEXT_BUTTON_LED_MSG, len(msg_content))
|
||||
self.transport.write(header + msg_content)
|
||||
|
||||
def data_received(self, data):
|
||||
self.in_buff += data
|
||||
self._parse_message()
|
||||
|
||||
@@ -63,11 +63,18 @@ mouse_leds = {
|
||||
}
|
||||
|
||||
|
||||
def run_off_animation(protocol):
|
||||
ring_eff = EffectReverseSwipe()
|
||||
mouse_eff = EffectReverseSwipe()
|
||||
mouse_eff.startPosition = 6 / 45 * 360
|
||||
protocol.led_ring_effect(ring_eff)
|
||||
protocol.mouse_led_effect(mouse_eff)
|
||||
protocol.button_background_led_prev(0)
|
||||
protocol.button_background_led_next(0)
|
||||
|
||||
|
||||
def on_music_end_callback(protocol):
|
||||
eff = EffectAlexaSwipeConfig()
|
||||
eff.forward = False
|
||||
protocol.led_ring_effect(eff)
|
||||
protocol.mouse_led_effect(EffectStaticConfig(ColorRGBW(0, 0, 0, 0)))
|
||||
run_off_animation(protocol)
|
||||
|
||||
|
||||
def on_rfid(protocol, tagid):
|
||||
@@ -76,16 +83,11 @@ def on_rfid(protocol, tagid):
|
||||
if tagid == bytes.fromhex("0000000000"):
|
||||
# Off
|
||||
if audio_player.is_playing():
|
||||
ring_eff = EffectReverseSwipe()
|
||||
mouse_eff = EffectReverseSwipe()
|
||||
mouse_eff.startPosition = 6 / 45 * 360
|
||||
else:
|
||||
ring_eff = EffectStaticConfig(ColorRGBW(0, 0, 0, 0))
|
||||
mouse_eff = EffectStaticConfig(ColorRGBW(0, 0, 0, 0))
|
||||
protocol.led_ring_effect(ring_eff)
|
||||
protocol.mouse_led_effect(mouse_eff)
|
||||
audio_player.pause()
|
||||
|
||||
run_off_animation(protocol)
|
||||
audio_player.pause()
|
||||
#else:
|
||||
# protocol.led_ring_effect(EffectStaticConfig(ColorRGBW(0, 0, 0, 0)))
|
||||
# protocol.mouse_led_effect(EffectStaticConfig(ColorRGBW(0, 0, 0, 0)))
|
||||
last_figure = current_figure
|
||||
else:
|
||||
figure = rfid_token_map[tagid]
|
||||
@@ -101,8 +103,12 @@ def on_rfid(protocol, tagid):
|
||||
mouse_eff = EffectStaticConfig(ccfg.background)
|
||||
mouse_eff = deepcopy(ring_eff)
|
||||
mouse_eff.swipe.start_position = 6 / 45 * 360
|
||||
mouse_eff.swipe.bell_curve_width_in_leds = 16
|
||||
protocol.mouse_led_effect(mouse_eff)
|
||||
|
||||
protocol.button_background_led_prev(0.3)
|
||||
protocol.button_background_led_next(0.3)
|
||||
|
||||
if figure in playlists:
|
||||
audio_player.set_playlist(playlists[figure])
|
||||
if last_figure == current_figure:
|
||||
|
||||
Reference in New Issue
Block a user