Closed metaMMA closed 4 years ago
Thank you very much for this! The code looks good. I want to test it locally today but will merge it after that so long as it behaves as expected.
Thank you very much for this! The code looks good. I want to test it locally today but will merge it after that so long as it behaves as expected.
No problem. After reading Issue https://github.com/genebean/PiWeatherRock/issues/28 I think I'm going to amend this further, so that the end user can choose different screen times for daily and hourly, as well. I'll push the changes later today.
# 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
# Number of seconds between showing the info screen.
INFO_SCREEN_DELAY = 900 # 15 minutes
# Automatically switch back to weather display after a couple minutes.
if MODE not in ('d', 'h'):
PERIODIC_INFO_ACTIVATION = 0
NON_WEATHER_TIMEOUT += 1
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'
D_COUNT = 1
syslog.syslog("Switching to weather mode")
else:
NON_WEATHER_TIMEOUT = 0
PERIODIC_INFO_ACTIVATION += 1
# 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("Switching to info mode")
elif (PERIODIC_INFO_ACTIVATION % (((config.DAILY_PAUSE * D_COUNT) +
(config.HOURLY_PAUSE * H_COUNT)) * 10)) == 0:
if MODE == 'd':
syslog.syslog("Switching to HOURLY")
MODE = 'h'
H_COUNT += 1
else:
syslog.syslog("Switching to DAILY")
MODE = 'd'
D_COUNT += 1
D_COUNT = 1
H_COUNT = 0
This is working good for me, thanks!
Feb 27 20:55:43 tart python3[3863]: pygame 1.9.6
Feb 27 20:55:43 tart python3[3863]: Hello from the pygame community. https://www.pygame.org/contribute.html
Feb 27 20:55:43 tart python3[3863]: X Display = :0
Feb 27 20:55:43 tart python3[3863]: Framebuffer Size: 1824 x 984
Feb 27 20:55:44 tart systemd[1]: PiWeatherRock.service: Succeeded.
Feb 27 20:55:44 tart systemd[1]: Stopped PiWeatherRock Service.
Feb 27 20:55:44 tart systemd[1]: Started PiWeatherRock Service.
Feb 27 20:55:44 tart sudo[3894]: pam_unix(sudo:session): session closed for user root
Feb 27 20:55:48 tart /weather.py[3901]: X Display = :0
Feb 27 20:55:48 tart /weather.py[3901]: Framebuffer Size: 1824 x 984
Feb 27 20:57:27 tart /weather.py[3901]: Switching to HOURLY
Feb 27 20:59:00 tart /weather.py[3901]: Switching to DAILY
Feb 27 21:00:33 tart /weather.py[3901]: Switching to HOURLY
Feb 27 21:00:34 tart /weather.py[3901]: Switching to info mode
Feb 27 21:02:57 tart /weather.py[3901]: Switching to weather mode
This pull request adds three variables to the
config.py.sample
, and amendsweather.py
to accept these variables. It was written to be backward compatible with what current users are accustomed to seeing.config.py.sample additions:
weather.py amendments (line 867+):