Fix flux_led turn on when brightness is zero on newer devices (#64129)

This commit is contained in:
J. Nick Koston 2022-01-14 13:14:02 -10:00 committed by GitHub
parent 2d5fe93cb2
commit b273c37d2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 298 additions and 16 deletions

View file

@ -52,3 +52,26 @@ def _str_to_multi_color_effect(effect_str: str) -> MultiColorEffects:
return effect
# unreachable due to schema validation
assert False # pragma: no cover
def _min_rgb_brightness(rgb: tuple[int, int, int]) -> tuple[int, int, int]:
"""Ensure the RGB value will not turn off the device from a turn on command."""
if all(byte == 0 for byte in rgb):
return (1, 1, 1)
return rgb
def _min_rgbw_brightness(rgbw: tuple[int, int, int, int]) -> tuple[int, int, int, int]:
"""Ensure the RGBW value will not turn off the device from a turn on command."""
if all(byte == 0 for byte in rgbw):
return (1, 1, 1, 0)
return rgbw
def _min_rgbwc_brightness(
rgbwc: tuple[int, int, int, int, int]
) -> tuple[int, int, int, int, int]:
"""Ensure the RGBWC value will not turn off the device from a turn on command."""
if all(byte == 0 for byte in rgbwc):
return (1, 1, 1, 0, 0)
return rgbwc