Skip to content

Commit

Permalink
Fix 0xA3 model brightness flip flop after change (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 27, 2021
1 parent bca6b52 commit ea8d5d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions flux_led/aiodevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ async def async_set_preset_pattern(
self, effect: int, speed: int, brightness: int = 100
) -> None:
"""Set a preset pattern on the device."""
self._set_transition_complete_time()
await self._async_send_msg(
self._generate_preset_pattern(effect, speed, brightness)
)
Expand Down
5 changes: 4 additions & 1 deletion flux_led/base_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ def brightness(self) -> int:
assert raw_state is not None

if self.dimmable_effects and self._mode == MODE_PRESET:
if self.protocol in NEW_EFFECTS_PROTOCOLS:
if (
self.protocol in NEW_EFFECTS_PROTOCOLS
and time.monotonic() > self._transition_complete_time
):
# the red byte holds the brightness during an effect
return min(255, round(raw_state.red * 255 / 100))
return round(self._last_effect_brightness * 255 / 100)
Expand Down
1 change: 1 addition & 0 deletions flux_led/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def _determine_protocol(self):
raise Exception("Cannot determine protocol")

def setPresetPattern(self, pattern, speed, brightness=100, retry=DEFAULT_RETRIES):
self._set_transition_complete_time()
self._send_with_retry(
self._generate_preset_pattern(pattern, speed, brightness), retry=retry
)
Expand Down

0 comments on commit ea8d5d8

Please sign in to comment.