|
|
|
@ -39,7 +39,8 @@ class Uhr:
|
|
|
|
|
self.helligkeit = pixels.brightness
|
|
|
|
|
self.pixels = pixels
|
|
|
|
|
self.helligkeit_geaendert = None
|
|
|
|
|
self.mode = mode
|
|
|
|
|
self.mode_geaendert = None
|
|
|
|
|
self.mode: str = mode
|
|
|
|
|
self._rgb_leer = None
|
|
|
|
|
self._rgb_sekunde = None
|
|
|
|
|
self._rgb_minute = None
|
|
|
|
@ -48,6 +49,10 @@ class Uhr:
|
|
|
|
|
self.durchlauf_pause = datetime.timedelta(seconds=0)
|
|
|
|
|
self.sleep_time = 0
|
|
|
|
|
|
|
|
|
|
def mode_wechseln(self):
|
|
|
|
|
mode = int(self.mode)
|
|
|
|
|
self.mode = mode
|
|
|
|
|
|
|
|
|
|
def set_helligkeit(self, helligkeit):
|
|
|
|
|
self.helligkeit = helligkeit
|
|
|
|
|
self.pixels.brightness = self.helligkeit
|
|
|
|
@ -78,20 +83,28 @@ class Uhr:
|
|
|
|
|
|
|
|
|
|
def mode_control(self, zeit):
|
|
|
|
|
rgbconf = self.rgb_farben_lesen()
|
|
|
|
|
if int(self.mode) == 0:
|
|
|
|
|
mode = int(self.mode)
|
|
|
|
|
if mode == 0:
|
|
|
|
|
stdliste = stunden_led_mapping_variante_0()
|
|
|
|
|
stunden_leds, minuten_leds, sekunden_leds, leer_leds, rgbdict, \
|
|
|
|
|
stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict, \
|
|
|
|
|
self.led_gesetzt = stunde_minute_sekunde_einfach_modus(zeit, stdliste, rgbconf, self.led_gesetzt)
|
|
|
|
|
self.durchlauf_pause = datetime.timedelta(seconds=1)
|
|
|
|
|
self.sleep_time = 0.2
|
|
|
|
|
elif mode == 1:
|
|
|
|
|
stdliste = stunden_led_mapping_variante_0()
|
|
|
|
|
stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, \
|
|
|
|
|
rgbdict = stunde_minute_dauerhaft_modus(zeit, stdliste, rgbconf)
|
|
|
|
|
self.durchlauf_pause = datetime.timedelta(minutes=1)
|
|
|
|
|
self.sleep_time = 0.5
|
|
|
|
|
else:
|
|
|
|
|
stunden_leds = [0]
|
|
|
|
|
minuten_leds = [0]
|
|
|
|
|
sekunden_leds = [0]
|
|
|
|
|
sonstige_leds = [0]
|
|
|
|
|
leer_leds = [0]
|
|
|
|
|
rgbdict = self.rgb_farben_lesen()
|
|
|
|
|
|
|
|
|
|
led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, rgbdict, self.pixels)
|
|
|
|
|
led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict, self.pixels)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# GPIO
|
|
|
|
@ -128,14 +141,20 @@ def stunden_led_mapping_variante_0():
|
|
|
|
|
return stdliste
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stunde_minute_sekunde_einfach_modus(zeit, stdliste, rgbdict, led_gesetzt):
|
|
|
|
|
def stunden_index_mapping_ermitteln(zeit):
|
|
|
|
|
if zeit.hour > 11:
|
|
|
|
|
index = zeit.hour - 12
|
|
|
|
|
else:
|
|
|
|
|
index = zeit.hour
|
|
|
|
|
return index
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stunde_minute_sekunde_einfach_modus(zeit, stdliste, rgbdict, led_gesetzt):
|
|
|
|
|
index = stunden_index_mapping_ermitteln(zeit)
|
|
|
|
|
stunden_leds = list(stdliste[index])
|
|
|
|
|
minuten_leds = [zeit.minute]
|
|
|
|
|
sekunden_leds = [zeit.second]
|
|
|
|
|
sonstige_leds = []
|
|
|
|
|
|
|
|
|
|
# Schnittfarben berechnen falls "Zeiger" übereinander liegen
|
|
|
|
|
# Stunde mit Minute vergleichen
|
|
|
|
@ -157,10 +176,36 @@ def stunde_minute_sekunde_einfach_modus(zeit, stdliste, rgbdict, led_gesetzt):
|
|
|
|
|
if isinstance(led_gesetzt, (int, float)):
|
|
|
|
|
led_gesetzt = [led_gesetzt]
|
|
|
|
|
leer_leds = set(led_gesetzt) - set(led_gesetzt_neu)
|
|
|
|
|
return stunden_leds, minuten_leds, sekunden_leds, leer_leds, rgbdict, led_gesetzt_neu
|
|
|
|
|
return stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict, led_gesetzt_neu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stunde_minute_dauerhaft_modus(zeit, stdliste, rgbdict):
|
|
|
|
|
sekunden_leds = []
|
|
|
|
|
|
|
|
|
|
index = stunden_index_mapping_ermitteln(zeit)
|
|
|
|
|
stunden_leds = list(stdliste[index])
|
|
|
|
|
|
|
|
|
|
minuten_leds = [minute for minute in range(0, zeit.minute + 1)]
|
|
|
|
|
|
|
|
|
|
if zeit.minute == 0:
|
|
|
|
|
leer_leds = list(set(range(0, 60)) - set(stunden_leds) - set(minuten_leds))
|
|
|
|
|
else:
|
|
|
|
|
leer_leds = []
|
|
|
|
|
|
|
|
|
|
if max(minuten_leds) < max(stunden_leds):
|
|
|
|
|
sonstige_leds = list(set(stunden_leds) & set(minuten_leds))
|
|
|
|
|
minuten_leds = list(set(minuten_leds) - set(sonstige_leds))
|
|
|
|
|
else:
|
|
|
|
|
sonstige_leds = []
|
|
|
|
|
|
|
|
|
|
minuten_leds = list(set(minuten_leds) - set(stunden_leds))
|
|
|
|
|
stunden_leds = list(set(stunden_leds) - set(sonstige_leds))
|
|
|
|
|
sonstige_leds = [(led, (0, 0, 255)) for led in sonstige_leds]
|
|
|
|
|
|
|
|
|
|
return stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict
|
|
|
|
|
|
|
|
|
|
def led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, rgbdict, pixels):
|
|
|
|
|
|
|
|
|
|
def led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict, pixels):
|
|
|
|
|
# Stunden setzen
|
|
|
|
|
for stunde_led in stunden_leds:
|
|
|
|
|
pixels[stunde_led] = rgbdict["rgb_std"][0], rgbdict["rgb_std"][1], rgbdict["rgb_std"][2]
|
|
|
|
@ -177,6 +222,13 @@ def led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, rgbdict, pi
|
|
|
|
|
for leer_led in leer_leds:
|
|
|
|
|
pixels[leer_led] = rgbdict["rgb_leer"][0], rgbdict["rgb_leer"][1], rgbdict["rgb_leer"][2]
|
|
|
|
|
|
|
|
|
|
print(sonstige_leds)
|
|
|
|
|
# Sonstige LEDs verarbeiten
|
|
|
|
|
# Aufbau -> [index_lednummer, (R, G, B)]
|
|
|
|
|
for led, rgb in sonstige_leds:
|
|
|
|
|
print(f"LED: {led} RGB: {rgb}")
|
|
|
|
|
pixels[led] = rgb[0], rgb[1], rgb[2]
|
|
|
|
|
|
|
|
|
|
pixels.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|