Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to adjust screen timing #41

Merged
merged 4 commits into from
Feb 28, 2020
Merged

Conversation

metaMMA
Copy link
Contributor

@metaMMA metaMMA commented Feb 26, 2020

This pull request adds three variables to the config.py.sample, and amends weather.py to accept these variables. It was written to be backward compatible with what current users are accustomed to seeing.

config.py.sample additions:

# 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

weather.py amendments (line 867+):

    # Automatically switch back to weather display after a couple minutes.
    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
        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
        # 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 % (config.DH_PAUSE * 10)) == 0 and
              MODE == 'd'):
            MODE = 'h'
        elif (PERIODIC_INFO_ACTIVATION % (config.DH_PAUSE * 10)) == 0 and
              MODE == 'h'):
            MODE = 'd'

@metaMMA
Copy link
Contributor Author

metaMMA commented Feb 26, 2020

Relevant: #28

@genebean
Copy link
Owner

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.

@metaMMA
Copy link
Contributor Author

metaMMA commented Feb 26, 2020

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 #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.

@metaMMA
Copy link
Contributor Author

metaMMA commented Feb 26, 2020

update to config.py.sample additions:

# 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

update to weather.py (line 869+)

    # 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

additions to global variable ( lines 61-62)

D_COUNT = 1
H_COUNT = 0

@genebean
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants