diff --git a/mpf/platforms/fast/fast_led.py b/mpf/platforms/fast/fast_led.py index 9692982ef..b14503721 100644 --- a/mpf/platforms/fast/fast_led.py +++ b/mpf/platforms/fast/fast_led.py @@ -4,9 +4,8 @@ from typing import Optional from typing import List -from mpf.core.utility_functions import Util from mpf.platforms.interfaces.light_platform_interface import LightPlatformInterface -from mpf.platforms.fast.fast_defines import EXPANSION_BOARD_FEATURES + class FASTRGBLED: @@ -49,6 +48,7 @@ def current_color(self): return result + class FASTExpLED(FASTRGBLED): """FAST RGB LED on an expansion board.""" @@ -60,12 +60,13 @@ def __repr__(self): """Return representation of this LED.""" return f'' + # pylint: disable-msg=super-init-not-called def __init__(self, number: str, hardware_fade_ms: int, platform) -> None: """Initialize FAST LED.""" self.number = number # 5 char hex string, board address, breakout self.number_int = int(number, 16) self.platform = platform - self.address = f'{number[0:3]}' # '880' + self.address = f'{number[0:3]}' # '880' self.exp_board = platform.exp_boards_by_address[self.address[0:2]] self.breakout_board = platform.exp_breakout_boards[self.address] @@ -124,8 +125,12 @@ def get_fade_and_brightness(self, current_time): self._last_brightness = brightness done = True + # There is a bug that can sometimes cause the start_time to be ahead of the current_time, + # resulting in a negative brightness value. This may be a floating-point rounding error, + # or maybe something else. I can't figure it out, so just floor the value to be non-negative. if brightness < 0: - self.led.log.warning("Calculated a negative brightness (%s) for led %s channel %s. current_time: %s"+\ + brightness = 0 + self.led.log.warning("Calculated a negative brightness (%s) for led %s channel %s. current_time: %s " "start_brightness: %s, start_time: %s, target_brightness: %s, target_time: %s", brightness, self.led, self.channel, current_time, start_brightness, start_time, target_brightness, target_time)