aboutsummaryrefslogtreecommitdiff
path: root/NeoRuntime/Runtime
diff options
context:
space:
mode:
Diffstat (limited to 'NeoRuntime/Runtime')
-rw-r--r--NeoRuntime/Runtime/luxcena_neo/strip.py2
-rw-r--r--NeoRuntime/Runtime/neo_runtime.py21
2 files changed, 23 insertions, 0 deletions
diff --git a/NeoRuntime/Runtime/luxcena_neo/strip.py b/NeoRuntime/Runtime/luxcena_neo/strip.py
index bc2e2be..9a12969 100644
--- a/NeoRuntime/Runtime/luxcena_neo/strip.py
+++ b/NeoRuntime/Runtime/luxcena_neo/strip.py
@@ -119,6 +119,7 @@ class Strip:
def set_pixel_color(self, n, *color):
"""Set LED at position n to the provided 24-bit color value (in RGB order).
"""
+ if n >= self.LED_COUNT: return
c = detect_format_convert_color(*color)
self.TMPCOLORSTATE[n] = c
self.strip.setPixelColor(n, c)
@@ -132,6 +133,7 @@ class Strip:
"""Set a whole segment to the provided red, green and blue color.
Each color component should be a value from 0 to 255 (where 0 is the
lowest intensity and 255 is the highest intensity)."""
+ if segment >= len(self.SEGMENTS): return
for n in get_segment_range(self.SEGMENTS, segment):
self.set_pixel_color(n, *color)
diff --git a/NeoRuntime/Runtime/neo_runtime.py b/NeoRuntime/Runtime/neo_runtime.py
index b028530..3057f3c 100644
--- a/NeoRuntime/Runtime/neo_runtime.py
+++ b/NeoRuntime/Runtime/neo_runtime.py
@@ -116,11 +116,32 @@ class NeoRuntime:
ws.close()
last_send = time.perf_counter()
+
+ if self.__send_strip_buffer:
+ time.sleep(0.001)
+ buffer = [2]
+ for p in self.__strip.COLORSTATE:
+ buffer.append((p & 0x00FF0000) >> 16)
+ buffer.append((p & 0x0000FF00) >> 8)
+ buffer.append((p & 0x000000FF))
+ buffer = bytes(buffer)
+ for ws in w:
+ try:
+ ws.send(buffer)
+ except BrokenPipeError:
+ self.__s_clients.remove(ws)
+ ws.close()
+ time.sleep(0.001)
for rs in r:
if rs is self.__s:
c, a = self.__s.accept()
self.__s_clients.append(c)
+ try:
+ buf = bytes([3]) + bytes(json.dumps(self.__strip.pixelMatrix.matrix), "ascii")
+ c.send(buf)
+ except Exception as e:
+ print(e)
else:
data = rs.recv(128)
if not data: