From c7bb5c238fc69b73de47d09f0df0ed94fef09c26 Mon Sep 17 00:00:00 2001 From: Christian Bergschneider Date: Thu, 11 Jan 2024 21:17:06 +0100 Subject: [PATCH] feat: allow input of color tuple for color --- swarm/swarm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swarm/swarm.py b/swarm/swarm.py index ac1115c..18be679 100644 --- a/swarm/swarm.py +++ b/swarm/swarm.py @@ -531,6 +531,9 @@ async def get_color(self) -> int: return self._color async def set_color(self, color) -> None: + # If color is a tuple, reformat it as hex + if isinstance(color, tuple) or isinstance(color, list): + color = (color[0] << 16) + (color[1] << 8) + color[2] self._color = color await self._swarm.send(self._port_name, "setColor", color)