Skip to content

Commit

Permalink
Made update_status_from_bulb more stable. ColorCycle takes brightne…
Browse files Browse the repository at this point in the history
…ss into account.
  • Loading branch information
samclane committed Dec 12, 2022
1 parent e47c7a1 commit 3579d7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lifx_control_panel/_constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "2.3.0"
BUILD_DATE = "2022-06-24T06:40:37.641096"
BUILD_DATE = "2022-12-12T06:22:59.747968"
AUTHOR = "Sawyer McLane"
DEBUGGING = False
12 changes: 10 additions & 2 deletions lifx_control_panel/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,11 @@ def update_status_from_bulb(self, run_once=False):
run_once - Don't call `after` statement at end. Keeps a million workers from being instanced.
"""
require_icon_update = False
if not self.master.bulb_interface.power_queue[self.label].empty():
power_queue = self.master.bulb_interface.power_queue
if (
self.label in power_queue
and not self.master.bulb_interface.power_queue[self.label].empty()
):
power = self.master.bulb_interface.power_queue[self.label].get()
require_icon_update = True
self.tk_power_var.set(power)
Expand All @@ -619,7 +623,11 @@ def update_status_from_bulb(self, run_once=False):
self.option_on.select()
self.option_off.selection_clear()

if not self.master.bulb_interface.color_queue[self.label].empty():
color_queue = self.master.bulb_interface.color_queue
if (
self.label in color_queue
and not self.master.bulb_interface.color_queue[self.label].empty()
):
hsbk = self.master.bulb_interface.color_queue[self.label].get()
require_icon_update = True
for key, _ in enumerate(self.hsbk):
Expand Down
4 changes: 2 additions & 2 deletions lifx_control_panel/utilities/color_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def __init__(self):
self.pos = 0
self.cycle_color = hsv_to_rgb(self.pos, 1, 1)

def get_color(self):
def get_color(self, *args, **kwargs):
if time.time() - self.last_change > 0.1:
self.pos = (self.pos + 1) % 360
self.cycle_color = hsv_to_rgb(self.pos, 1, 1)
self.cycle_color = hsv_to_rgb(self.pos, 1, self.initial_color[2] / 65535)
self.last_change = time.time()
return list(
utils.RGBtoHSBK(self.cycle_color, temperature=self.initial_color[3])
Expand Down

0 comments on commit 3579d7a

Please sign in to comment.