diff --git a/micropython/Config.py b/micropython/Config.py index 9b586f7..aa1c25a 100644 --- a/micropython/Config.py +++ b/micropython/Config.py @@ -2,6 +2,7 @@ from provider.ProviderClock import ProviderClock from provider.ProviderDadJoke import ProviderDadJoke from provider.ProviderMotion import ProviderMotion +from provider.ProviderNewYearCountdown import ProviderNewYearCountdown from provider.ProviderLetters import ProviderLetters # element order when displaying alphabet @@ -11,12 +12,13 @@ # flap offsets in display order for calibration display_offsets = [0, 0, -4, 0, 9, 22, 11, 0, 0, 0, - 2, 0, 0, -4, 32, 0, 0, 0, 0, 0] + 2, 0, 0, -16, 32, 0, 0, 0, 0, 0] providers = { "{CLOCK_STO}": ProviderClock("STO %H:%M%d.%m.%Y", "Europe/Stockholm"), "{CLOCK_ADL}": ProviderClock("ADL %H:%M%d.%m.%Y", "Australia/Adelaide"), "{CLOCK_NYC}": ProviderClock("NYC %H:%M%d.%m.%Y", "America/New_York"), + "{NEW_YEAR_STO}": ProviderNewYearCountdown("Europe/Stockholm"), "{ART}": ProviderArt(), "{MOTION}": ProviderMotion(), "{DAD_JOKE}": ProviderDadJoke(), diff --git a/micropython/provider/ProviderNewYearCountdown.py b/micropython/provider/ProviderNewYearCountdown.py new file mode 100644 index 0000000..652c4e7 --- /dev/null +++ b/micropython/provider/ProviderNewYearCountdown.py @@ -0,0 +1,25 @@ +from typing import Union, Tuple + +from provider.Clock import Clock +from provider.Provider import Provider + + +class ProviderNewYearCountdown(Provider): + def __init__(self, timezone: str): + self.timezone = timezone + + def get_word(self, word: str, display: Display) -> Tuple[str, Union[int, None]]: + now = Clock.now(self.timezone) + + if now.month == 1 and now.day == 1: # Jan 1st + return now.strftime("!HAPPY NEWYEAR %Y!"), None + + next_interval_ms = (60 - now.second) * 1000 + + delta_hours = 23 - now.hour + delta_minutes = 59 - now.minute + + if delta_minutes % 2 == 0: + return f"{now.year+1:04} IN {delta_hours:02}:{delta_minutes:02} ", next_interval_ms + else: + return f"COUNT DOWN {delta_hours:02}:{delta_minutes:02} ", next_interval_ms diff --git a/micropython/www/index.html b/micropython/www/index.html index b2915b4..bc0d9c5 100644 --- a/micropython/www/index.html +++ b/micropython/www/index.html @@ -143,6 +143,8 @@ ADL NYC
+ New Year Countdown +
Art
Motion