From c2b8fa2e99db03835bb1c813beae55a1461e53ef Mon Sep 17 00:00:00 2001 From: metaMMA Date: Wed, 26 Feb 2020 02:59:19 -0600 Subject: [PATCH 1/4] Add ability to adjust screen timing. --- config.py.sample | 10 ++++++++++ weather.py | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/config.py.sample b/config.py.sample index a8630e4..dbfd667 100644 --- a/config.py.sample +++ b/config.py.sample @@ -32,3 +32,13 @@ FULLSCREEN = True # If the weather icons are overlapping the text try adjusting # this value. Negative values raise the icon. LARGE_ICON_OFFSET = -23.5 + +# Number of seconds to pause on the Daily and Hourly weather screens. +DH_PAUSE = 60 # 1 minute + +# Number of seconds to pause on the Info screen. +INFO_SCREEN_PAUSE = 300 # 5 minutes + +# Number of seconds between showing the info screen. +INFO_SCREEN_DELAY = 900 # 15 minutes + diff --git a/weather.py b/weather.py index 6faf1bf..c5649e4 100644 --- a/weather.py +++ b/weather.py @@ -868,21 +868,25 @@ def daylight(weather): if MODE not in ('d', 'h'): PERIODIC_INFO_ACTIVATION = 0 NON_WEATHER_TIMEOUT += 1 - # Five minute timeout at 100ms loop rate. - if NON_WEATHER_TIMEOUT > 3000: + # Default in config.py.sample: pause for 5 minutes on info screen + if NON_WEATHER_TIMEOUT > (config.INFO_SCREEN_PAUSE * 10): MODE = 'd' syslog.syslog("Switched to weather mode") else: NON_WEATHER_TIMEOUT = 0 PERIODIC_INFO_ACTIVATION += 1 - CURR_MIN_INT = int(datetime.datetime.now().strftime("%M")) - # 15 minute timeout at 100ms loop rate - if PERIODIC_INFO_ACTIVATION > 9000: + # Default in config.py.sample: flip between 2 weather screens + # for 15 minutes before showing info screen. + if PERIODIC_INFO_ACTIVATION > (config.INFO_SCREEN_DELAY * 10): MODE = 'i' syslog.syslog("Switched to info mode") - elif PERIODIC_INFO_ACTIVATION > 600 and CURR_MIN_INT % 2 == 0: + elif ( + PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and + MODE == 'd'): MODE = 'h' - elif PERIODIC_INFO_ACTIVATION > 600: + elif ( + PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and + MODE == 'h'): MODE = 'd' # Daily Weather Display Mode @@ -946,3 +950,4 @@ def daylight(weather): pygame.quit() + From b915103c6589d6e047caee1a3f0327ff89d7b3c5 Mon Sep 17 00:00:00 2001 From: metaMMA Date: Wed, 26 Feb 2020 03:05:02 -0600 Subject: [PATCH 2/4] Fix PEP8 formatting. --- weather.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/weather.py b/weather.py index c5649e4..f945586 100644 --- a/weather.py +++ b/weather.py @@ -880,12 +880,10 @@ def daylight(weather): if PERIODIC_INFO_ACTIVATION > (config.INFO_SCREEN_DELAY * 10): MODE = 'i' syslog.syslog("Switched to info mode") - elif ( - PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and + elif (PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and MODE == 'd'): MODE = 'h' - elif ( - PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and + elif (PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and MODE == 'h'): MODE = 'd' @@ -950,4 +948,3 @@ def daylight(weather): pygame.quit() - From be2175fb995d2d48b6a3b7493c2a6161ca75c457 Mon Sep 17 00:00:00 2001 From: metaMMA Date: Wed, 26 Feb 2020 16:01:15 -0600 Subject: [PATCH 3/4] Add abililty to adjust screen time for each screen. --- config.py.sample | 7 +++++-- weather.py | 32 +++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/config.py.sample b/config.py.sample index dbfd667..f075cd2 100644 --- a/config.py.sample +++ b/config.py.sample @@ -33,8 +33,11 @@ FULLSCREEN = True # this value. Negative values raise the icon. LARGE_ICON_OFFSET = -23.5 -# Number of seconds to pause on the Daily and Hourly weather screens. -DH_PAUSE = 60 # 1 minute +# Number of seconds to pause on the Daily weather screen. +DAILY_PAUSE = 60 # 1 minute + +# Number of seconds to pause on the Hourly weather screen. +HOURLY_PAUSE = 60 # 1 minute # Number of seconds to pause on the Info screen. INFO_SCREEN_PAUSE = 300 # 5 minutes diff --git a/weather.py b/weather.py index f945586..c5a4d43 100644 --- a/weather.py +++ b/weather.py @@ -54,10 +54,13 @@ import config # globals -MODE = 'd' # Default to weather mode. MOUSE_X, MOUSE_Y = 0, 0 UNICODE_DEGREE = u'\xb0' +MODE = 'd' # Default to weather mode. Showing daily weather first. +D_COUNT = 1 +H_COUNT = 0 + def exit_gracefully(signum, frame): sys.exit(0) @@ -141,7 +144,6 @@ def get_temperature_letter(unit=config.UNITS): return units_decoder(unit)['temperature'].split(' ')[-1][0].upper() - def icon_mapping(icon, size): """ https://darksky.net/dev/docs has this to say about icons: @@ -868,10 +870,13 @@ def daylight(weather): if MODE not in ('d', 'h'): PERIODIC_INFO_ACTIVATION = 0 NON_WEATHER_TIMEOUT += 1 - # Default in config.py.sample: pause for 5 minutes on info screen + D_COUNT = 0 + H_COUNT = 0 + # Default in config.py.sample: pause for 5 minutes on info screen. if NON_WEATHER_TIMEOUT > (config.INFO_SCREEN_PAUSE * 10): MODE = 'd' - syslog.syslog("Switched to weather mode") + D_COUNT = 1 + syslog.syslog("Switching to weather mode") else: NON_WEATHER_TIMEOUT = 0 PERIODIC_INFO_ACTIVATION += 1 @@ -879,13 +884,18 @@ def daylight(weather): # for 15 minutes before showing info screen. if PERIODIC_INFO_ACTIVATION > (config.INFO_SCREEN_DELAY * 10): MODE = 'i' - syslog.syslog("Switched to info mode") - elif (PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and - MODE == 'd'): - MODE = 'h' - elif (PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and - MODE == 'h'): - MODE = 'd' + syslog.syslog("Switching to info mode") + elif (PERIODIC_INFO_ACTIVATION % (((config.DAILY_PAUSE * D_COUNT) + + (config.HOURLY_PAUSE * H_COUNT)) * 10)) == 0: + syslog.syslog("Time: " + str(PERIODIC_INFO_ACTIVATION / 10)) + if MODE == 'd': + syslog.syslog("Switching to HOURLY") + MODE = 'h' + H_COUNT += 1 + else: + syslog.syslog("Switching to DAILY") + MODE = 'd' + D_COUNT += 1 # Daily Weather Display Mode if MODE == 'd': From a121bb17c553108005499124c7b9ad2a5e6a9769 Mon Sep 17 00:00:00 2001 From: metaMMA Date: Wed, 26 Feb 2020 16:06:43 -0600 Subject: [PATCH 4/4] Remove log output used for development. --- weather.py | 1 - 1 file changed, 1 deletion(-) diff --git a/weather.py b/weather.py index c5a4d43..796bfb7 100644 --- a/weather.py +++ b/weather.py @@ -887,7 +887,6 @@ def daylight(weather): syslog.syslog("Switching to info mode") elif (PERIODIC_INFO_ACTIVATION % (((config.DAILY_PAUSE * D_COUNT) + (config.HOURLY_PAUSE * H_COUNT)) * 10)) == 0: - syslog.syslog("Time: " + str(PERIODIC_INFO_ACTIVATION / 10)) if MODE == 'd': syslog.syslog("Switching to HOURLY") MODE = 'h'