Compare commits
2 Commits
103e04a1b4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 545ff966c8 | |||
|
|
33109455c9 |
@@ -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)
|
||||
|
||||
|
||||
38
pyleds/program/promise/ChristmasLights.py
Normal file
38
pyleds/program/promise/ChristmasLights.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from lib.Program import Program
|
||||
from rpi_ws281x import Color
|
||||
import time
|
||||
|
||||
def name():
|
||||
return 'Christmas Lights'
|
||||
|
||||
class ChristmasLights(Program):
|
||||
def run(self, args: [] = None):
|
||||
# Configuration
|
||||
wait_ms = 0 # Speed of the animation
|
||||
|
||||
# Define classic festive colors
|
||||
RED = Color(255, 0, 0)
|
||||
GREEN = Color(0, 255, 0)
|
||||
WARM_WHITE = Color(200, 180, 60) # A golden-ish warm white
|
||||
|
||||
colors = [RED, GREEN, WARM_WHITE]
|
||||
|
||||
# This determines how many pixels of the same color are next to each other
|
||||
group_size = 2
|
||||
|
||||
offset = 0
|
||||
while self.get_loop().status():
|
||||
num_pixels = self._lm.count_pixels()
|
||||
|
||||
for i in range(num_pixels):
|
||||
# Calculate which color index to use based on pixel position and current offset
|
||||
# This creates the "moving" effect
|
||||
color_index = ((i + offset) // group_size) % len(colors)
|
||||
self._lm.set_pixel_color(i, colors[color_index])
|
||||
|
||||
self._lm.show()
|
||||
|
||||
# Increment offset to move the lights
|
||||
offset = (offset + 1) % (len(colors) * group_size)
|
||||
self._lm.get_tempo().wait()
|
||||
time.sleep(wait_ms / 1000.0)
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user