Skip to content

Commit

Permalink
Removed exception checks from players, as they hid the real exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ZodiusInfuser committed Jul 30, 2024
1 parent 7a2280b commit 11c8718
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions picofx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,43 +214,34 @@ def __init__(self, mono_leds):
super().__init__(mono_leds)

def __show(self):
try:
for i in range(self.__num_leds):
if self.__effects[i] is not None:
self.__leds[i].brightness(self.__effects[i](*self.__data[i]))
except Exception:
raise TypeError("Incorrect effect setup for this MonoPlayer")
for i in range(self.__num_leds):
if self.__effects[i] is not None:
self.__leds[i].brightness(self.__effects[i](*self.__data[i]))


class ColourPlayer(EffectPlayer):
def __init__(self, rgb_leds):
super().__init__(rgb_leds)

def __show(self):
try:
for i in range(self.__num_leds):
if self.__effects[i] is not None:
colours = self.__effects[i](*self.__data[i])
if not isinstance(colours, tuple):
colours = [int(colours * 255)] * 3
for i in range(self.__num_leds):
if self.__effects[i] is not None:
colours = self.__effects[i](*self.__data[i])
if not isinstance(colours, tuple):
colours = [int(colours * 255)] * 3

self.__leds[i].set_rgb(*colours)
except Exception:
raise TypeError("Incorrect effect setup for this ColourPlayer")
self.__leds[i].set_rgb(*colours)


class StripPlayer(EffectPlayer):
def __init__(self, rgb_leds, num_leds=60):
super().__init__(rgb_leds, num_leds)

def __show(self):
try:
for i in range(self.__num_leds):
if self.__effects[i] is not None:
colours = self.__effects[i](*self.__data[i])
if not isinstance(colours, tuple):
colours = [int(colours * 255)] * 3

self.__leds.set_rgb(i, *colours)
except Exception:
raise TypeError("Incorrect effect setup for this StripPlayer")
for i in range(self.__num_leds):
if self.__effects[i] is not None:
colours = self.__effects[i](*self.__data[i])
if not isinstance(colours, tuple):
colours = [int(colours * 255)] * 3

self.__leds.set_rgb(i, *colours)

0 comments on commit 11c8718

Please sign in to comment.