diff --git a/uhr.py b/uhr.py index 9c072a4..7839784 100644 --- a/uhr.py +++ b/uhr.py @@ -40,7 +40,7 @@ class Uhr: self.pixels = pixels self.helligkeit_geaendert = None self.mode_geaendert = None - self.mode: str = mode + self.mode = mode self._rgb_leer = None self._rgb_sekunde = None self._rgb_minute = None @@ -51,7 +51,18 @@ class Uhr: def mode_wechseln(self): mode = int(self.mode) - self.mode = mode + mode_anzahl = len(CONFIG["mode"]) - 1 + if mode_anzahl < 0: + mode_anzahl = 0 + + mode += 1 + if mode > mode_anzahl: + mode = 0 + self.mode = str(mode) + now = datetime.datetime.now() + self.mode_geaendert = now + alle_led(0, 0, 0, self.pixels) + self.mode_control(now) def set_helligkeit(self, helligkeit): self.helligkeit = helligkeit @@ -94,8 +105,13 @@ class Uhr: 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.durchlauf_pause = datetime.timedelta(seconds=1) self.sleep_time = 0.5 + elif mode == 2: + stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, \ + rgbdict = uhr_aus_modus(rgbconf) + self.durchlauf_pause = datetime.timedelta(minutes=1) + self.sleep_time = 2 else: stunden_leds = [0] minuten_leds = [0] @@ -205,6 +221,16 @@ def stunde_minute_dauerhaft_modus(zeit, stdliste, rgbdict): return stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict +def uhr_aus_modus(rgbdict): + sekunden_leds = [] + minuten_leds = [] + stunden_leds = [] + sonstige_leds = [] + leer_leds = [led for led in range(0, 60)] + + return stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict + + def led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_leds, rgbdict, pixels): # Stunden setzen for stunde_led in stunden_leds: @@ -222,13 +248,10 @@ def led_setzen(stunden_leds, minuten_leds, sekunden_leds, leer_leds, sonstige_le 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() @@ -328,6 +351,7 @@ def main(): I_PLUS_TASTER.when_pressed = uhr.helligkeit_erhoehen I_MINUS_TASTER.when_pressed = uhr.helligkeit_verringern + I_MODE_TASTER.when_pressed = uhr.mode_wechseln try: while True: @@ -340,6 +364,11 @@ def main(): CONFIG["led_helligkeit"] = uhr.helligkeit config_schreiben() uhr.helligkeit_geaendert = None + if uhr.mode_geaendert is not None: + if (datetime.datetime.now() - uhr.mode_geaendert) > datetime.timedelta(seconds=30): + CONFIG["mode_nummer"] = uhr.mode + config_schreiben() + uhr.mode_geaendert = None time.sleep(uhr.sleep_time) finally: pixels.brightness = 0