Skip to content

Commit

Permalink
Merge pull request #41 from metaMMA/master
Browse files Browse the repository at this point in the history
Add ability to adjust screen timing
  • Loading branch information
genebean authored Feb 28, 2020
2 parents 67e4690 + a121bb1 commit dba8e80
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
13 changes: 13 additions & 0 deletions config.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ 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 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

37 changes: 24 additions & 13 deletions weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -868,22 +870,31 @@ 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:
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
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:
MODE = 'h'
elif PERIODIC_INFO_ACTIVATION > 600:
MODE = 'd'
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

# Daily Weather Display Mode
if MODE == 'd':
Expand Down

0 comments on commit dba8e80

Please sign in to comment.