2 Commits

Author SHA1 Message Date
364ea9971b Veits tihedam rgbt lihtsalt 2022-04-07 19:23:23 +03:00
siinus
33109455c9 Set paths absolute 2021-05-03 19:05:27 +03:00
3 changed files with 42 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
from dotenv import dotenv_values
import pathlib
def populate_values(load: {}):
@@ -26,9 +27,10 @@ class Config(object):
_config: {} = {}
def __init__(self):
rp = str(pathlib.Path(__file__).parent.parent.absolute())
load_conf = {
**dotenv_values(".env.defaults"),
**dotenv_values(".env"),
**dotenv_values(rp + "/.env.defaults"),
**dotenv_values(rp + "/.env"),
}
self._config = populate_values(load_conf)

View File

@@ -0,0 +1,35 @@
from lib.Program import Program
from rpi_ws281x import Color
import time
def name():
return 'Vikermasetsus'
def wheel(pos):
"""Generate rainbow colors across 0-255 positions."""
if pos < 85:
return Color(pos * 3, 255 - pos * 3, 0)
elif pos < 170:
pos -= 85
return Color(255 - pos * 3, 0, pos * 3)
else:
pos -= 170
return Color(0, pos * 3, 255 - pos * 3)
class Vikermasetsus(Program):
def run(self, args: [] = None):
wait_ms = 20
iterations = 5
while self.get_loop().status():
"""Draw rainbow that uniformly distributes itself across all pixels."""
for j in range(256 * iterations):
if not self.get_loop().status():
break
for i in range(self._lm.count_pixels()):
self._lm.set_pixel_color(i, wheel(
(int(i * 2560 / self._lm.count_pixels()) + j) & 255))
self._lm.show()
time.sleep(wait_ms / 1000.0)

View File

@@ -1,11 +1,12 @@
#!/usr/bin/env python3
import logging
import pathlib
import sys
import lib.ProgramLoading as Pl
from lib.Litsimaja import Litsimaja
from flask import Flask, request, Response, render_template, json
root_path = pathlib.Path(__file__).parent.absolute()
# start litsimaja
lm = Litsimaja()
@@ -13,7 +14,7 @@ lm = Litsimaja()
logger = logging.getLogger('litsimaja')
logger.setLevel(logging.DEBUG if lm.conf('IS_DEV') else logging.WARN)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler = logging.FileHandler('litsimaja.log')
file_handler = logging.FileHandler(str(root_path) + '/litsimaja.log')
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
stdout_handler = logging.StreamHandler(sys.stdout)