forked from andreeuuetoa/litsimaja
Add zone switching (#5)
Pixel calculation error Add zone switching Co-authored-by: siinus <pearu@siinus.com> Reviewed-on: pvx/litsimaja#5
This commit is contained in:
@@ -2,15 +2,18 @@ from rpi_ws281x import PixelStrip
|
||||
# from lib.strip.WindowStrip import WindowStrip
|
||||
# from lib.strip.TkinterStrip import TkinterStrip
|
||||
from lib.LoopSwitch import LoopSwitch
|
||||
from lib.Regions import Regions
|
||||
|
||||
|
||||
class Litsimaja(object):
|
||||
_loops: []
|
||||
_regions: Regions
|
||||
|
||||
def __init__(self):
|
||||
self._strip = PixelStrip(290, 18, 800000, 10, False, 255, 0, 4104)
|
||||
self._loops = []
|
||||
self._strip.begin()
|
||||
self._regions: Regions = Regions(self.count_pixels(), [46, 96, 191, 241])
|
||||
|
||||
def count_pixels(self) -> int:
|
||||
return self._strip.numPixels()
|
||||
@@ -19,7 +22,10 @@ class Litsimaja(object):
|
||||
return self._strip
|
||||
|
||||
def set_pixel_color(self, n: int, color: int) -> None:
|
||||
self._strip.setPixelColor(n, color)
|
||||
if self._regions.is_pixel_enabled(n):
|
||||
self._strip.setPixelColor(n, color)
|
||||
else:
|
||||
self._strip.setPixelColor(n, 0)
|
||||
|
||||
def show(self) -> None:
|
||||
self._strip.show()
|
||||
@@ -32,3 +38,9 @@ class Litsimaja(object):
|
||||
for loop in self._loops:
|
||||
loop.stop()
|
||||
self._loops.clear()
|
||||
|
||||
def switch_region(self, region_id: int):
|
||||
self._regions.switch_region(region_id)
|
||||
|
||||
def get_region_ids(self):
|
||||
return self._regions.list_region_ids()
|
||||
|
||||
Reference in New Issue
Block a user