Create .env for config

This commit is contained in:
siinus
2021-05-02 01:37:38 +03:00
parent e6fb8ea528
commit 74b6cbe7e3
7 changed files with 85 additions and 27 deletions

View File

@@ -1,6 +1,4 @@
from rpi_ws281x import PixelStrip
# from lib.strip.WindowStrip import WindowStrip
# from lib.strip.TkinterStrip import TkinterStrip
from lib.Config import Config
from lib.LoopSwitch import LoopSwitch
from lib.Regions import Regions
from lib.Tempo import Tempo
@@ -8,11 +6,24 @@ from lib.Tempo import Tempo
class Litsimaja(object):
def __init__(self):
self._strip = PixelStrip(290, 18, 800000, 10, False, 255, 0, 4104)
self._config = Config()
if self.conf('USE_EMULATOR'):
module = __import__('lib.strip.TkinterStrip', None, None, ['TkinterStrip'])
class_name = 'TkinterStrip'
else:
module = __import__('rpi_ws281x', None, None, ['PixelStrip'])
class_name = 'PixelStrip'
loaded_class = getattr(module, class_name)
self._strip = loaded_class(
self.conf('STRIP_PIXELS'), self.conf('STRIP_GPIO_PIN'), self.conf('STRIP_HZ'), self.conf('STRIP_DMA'),
self.conf('STRIP_INVERT'), self.conf('STRIP_BRIGHTNESS'), self.conf('STRIP_CHANNEL'),
self.conf('STRIP_TYPE')
)
self._loops = []
self._strip.begin()
self._regions: Regions = Regions(self.count_pixels(), [46, 96, 191, 241])
self._tempo: Tempo = Tempo(60)
self._regions: Regions = Regions(self.count_pixels(), self.conf('REGIONS'))
self._tempo: Tempo = Tempo(self.conf('BPM_DEFAULT'))
self._selected_program = None
def count_pixels(self) -> int:
@@ -62,6 +73,9 @@ class Litsimaja(object):
def get_tempo(self):
return self._tempo
def set_selected_program(self, program_name: str):
self._selected_program = program_name
def conf(self, key: str):
return self._config.get(key)