Skip to content

Commit

Permalink
daemonize thread
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Dec 17, 2023
1 parent af00afa commit b5c11b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mycodo/functions/function_adafruit_neokey_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def listener(self):
while self.running:
# Check key press
for key in range(4):
if self.neokey[key] and not self.key_press_executing[key]:
if not self.key_press_executing[key] and self.neokey[key]:
self.key_press_executing[key] = True
self.logger.debug(f"Key {key + 1} Pressed")
self.set_color({"led_number": key, "led_color": self.options_channels['led_start'][key]})
Expand All @@ -359,6 +359,7 @@ def listener(self):
key_thread = threading.Thread(
target=self.run_key_actions,
args=(key,))
key_thread.daemon = True
key_thread.start()

# Check for flashing
Expand All @@ -374,7 +375,7 @@ def listener(self):
self.flashing[key]["on"] = True
self.set_color({"led_number": key, "led_color": self.flashing[key]["color"]})

time.sleep(0.05)
time.sleep(0.1)

def stop_function(self):
self.running = False
Expand Down Expand Up @@ -445,7 +446,6 @@ def set_color(self, dict_payload):
"Improper RGB color format. "
"Must be three values, separated by commas, between 0 and 255 each. For example: 10, 0, 255")


def flashing_on(self, dict_payload):
if "led_number" not in dict_payload:
self.logger.error("Missing key 'led_number'")
Expand Down

0 comments on commit b5c11b0

Please sign in to comment.