forked from pvx/litsimaja
Compare commits
2 Commits
ba02a41c13
...
feature/vi
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c947e7ea7 | |||
|
|
29b4d65380 |
@@ -1,5 +1,7 @@
|
|||||||
from rpi_ws281x import PixelStrip
|
from rpi_ws281x import PixelStrip
|
||||||
import atexit
|
import atexit
|
||||||
|
from tkinter import Tk, Canvas
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
|
|
||||||
class _LedData(object):
|
class _LedData(object):
|
||||||
@@ -63,6 +65,15 @@ class FakeStrip(PixelStrip):
|
|||||||
# Substitute for __del__, traps an exit condition and cleans up properly
|
# Substitute for __del__, traps an exit condition and cleans up properly
|
||||||
atexit.register(self._cleanup)
|
atexit.register(self._cleanup)
|
||||||
|
|
||||||
|
self.viz = Tk()
|
||||||
|
self.x = 1000
|
||||||
|
self.y = 500
|
||||||
|
self.viz.geometry(f'{self.x}x{self.y}')
|
||||||
|
self.canv = Canvas(self.viz)
|
||||||
|
self.canv.pack(expand=1)
|
||||||
|
self.th.start()
|
||||||
|
self.th = Thread(target=self.viz.mainloop)
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
# Clean up memory used by the library when not needed anymore.
|
# Clean up memory used by the library when not needed anymore.
|
||||||
if self._channel is not None:
|
if self._channel is not None:
|
||||||
@@ -78,7 +89,43 @@ class FakeStrip(PixelStrip):
|
|||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""Update the display with the data from the LED buffer."""
|
"""Update the display with the data from the LED buffer."""
|
||||||
return # render
|
self.canv.delete("all")
|
||||||
|
size = 10.5
|
||||||
|
bp = [47, 97, 191, 242, 289]
|
||||||
|
for s in range(self.numPixels()):
|
||||||
|
x1 = 0
|
||||||
|
y1 = 0
|
||||||
|
x2 = 0
|
||||||
|
y2 = 0
|
||||||
|
|
||||||
|
if s < bp[0]:
|
||||||
|
x1 = (self.x / 2) + s * size
|
||||||
|
y1 = 0
|
||||||
|
x2 = x1 + size
|
||||||
|
y2 = size
|
||||||
|
elif s < bp[1]:
|
||||||
|
x1 = self.x - size
|
||||||
|
y1 = -(bp[0] - s) * size
|
||||||
|
x2 = x1 + size
|
||||||
|
y2 = y1 + size
|
||||||
|
elif s < bp[2]:
|
||||||
|
x1 = self.x + (bp[1] - s) * size
|
||||||
|
y1 = self.y
|
||||||
|
x2 = x1 - size
|
||||||
|
y2 = y1 - size
|
||||||
|
elif s < bp[3]:
|
||||||
|
x1 = 0
|
||||||
|
y1 = self.y + (bp[2] - s) * size
|
||||||
|
x2 = x1 + size
|
||||||
|
y2 = y1 - size
|
||||||
|
elif s < bp[4]:
|
||||||
|
x1 = size * - (bp[3] - s)
|
||||||
|
y1 = 0
|
||||||
|
x2 = x1 + size
|
||||||
|
y2 = y1 + size
|
||||||
|
|
||||||
|
rgb = self.getPixelColorRGB(s)
|
||||||
|
self.canv.create_rectangle(x1, y1, x2, y2, fill="#%02x%02x%02x" % (rgb.r, rgb.g, rgb.b))
|
||||||
|
|
||||||
def getBrightness(self) -> int:
|
def getBrightness(self) -> int:
|
||||||
return self._brightness
|
return self._brightness
|
||||||
|
|||||||
Reference in New Issue
Block a user