fastled 1.0.10__py2.py3-none-any.whl → 1.0.12__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fastled/keyboard.py ADDED
@@ -0,0 +1,89 @@
1
+ import os
2
+ import select
3
+ import sys
4
+ import time
5
+ from multiprocessing import Process, Queue
6
+ from queue import Empty
7
+
8
+
9
+ class SpaceBarWatcher:
10
+ def __init__(self) -> None:
11
+ self.queue: Queue = Queue()
12
+ self.queue_cancel: Queue = Queue()
13
+ self.process = Process(target=self._watch_for_space)
14
+ self.process.start()
15
+
16
+ def _watch_for_space(self) -> None:
17
+ # Set stdin to non-blocking mode
18
+ fd = sys.stdin.fileno()
19
+ if os.name != "nt": # Unix-like systems
20
+ import termios
21
+ import tty
22
+
23
+ old_settings = termios.tcgetattr(fd) # type: ignore
24
+ try:
25
+ tty.setraw(fd) # type: ignore
26
+ while True:
27
+ # Check for cancel signal
28
+ try:
29
+ self.queue_cancel.get(timeout=0.1)
30
+ break
31
+ except Empty:
32
+ pass
33
+
34
+ # Check if there's input ready
35
+ if select.select([sys.stdin], [], [], 0.1)[0]:
36
+ char = sys.stdin.read(1)
37
+ if char == " ":
38
+ self.queue.put(ord(" "))
39
+ finally:
40
+ termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) # type: ignore
41
+ else: # Windows
42
+ import msvcrt
43
+
44
+ while True:
45
+ # Check for cancel signal
46
+ try:
47
+ self.queue_cancel.get(timeout=0.1)
48
+ break
49
+ except Empty:
50
+ pass
51
+
52
+ # Check if there's input ready
53
+ if msvcrt.kbhit():
54
+ char = msvcrt.getch().decode()
55
+ if char == " ":
56
+ self.queue.put(ord(" "))
57
+
58
+ def space_bar_pressed(self) -> bool:
59
+ found = False
60
+ while not self.queue.empty():
61
+ key = self.queue.get()
62
+ if key == ord(" "):
63
+ found = True
64
+ return found
65
+
66
+ def stop(self) -> None:
67
+ self.queue_cancel.put(True)
68
+ self.process.terminate()
69
+ self.process.join()
70
+ self.queue.close()
71
+ self.queue.join_thread()
72
+
73
+
74
+ def main() -> None:
75
+ watcher = SpaceBarWatcher()
76
+ try:
77
+ while True:
78
+ if watcher.space_bar_pressed():
79
+ break
80
+ time.sleep(1)
81
+ finally:
82
+ watcher.stop()
83
+
84
+
85
+ if __name__ == "__main__":
86
+ try:
87
+ main()
88
+ except KeyboardInterrupt:
89
+ print("Keyboard interrupt detected.")
fastled/open_browser.py CHANGED
@@ -24,7 +24,11 @@ def _open_browser_python(fastled_js: Path, port: int) -> subprocess.Popen:
24
24
  ]
25
25
 
26
26
  # Start the process
27
- process = subprocess.Popen(cmd)
27
+ process = subprocess.Popen(
28
+ cmd,
29
+ # stdout=subprocess.DEVNULL,
30
+ stderr=subprocess.DEVNULL,
31
+ )
28
32
  return process
29
33
 
30
34