問題: タイム技術

Sunrise WakeUp Screen

0  

Simulate sunrise with computer screen.

YAML 発想

These days, computer screens are quite abundant, but few have "Wake Up Lights". So, we could use computer screen as a morning light simulator.

Here is a hint, if you're on Linux:

  1. Check available screens connected:

xrandr -q | grep " connected"

  1. Set screen brightness:

xrandr --output HDMI-1 --brightness 0.5

Ok, now, let's say you're interested in sleeping at 15:30 UTC, and waking at 0 UTC... You could simply do, something like this in Python:

import os
import time
device = 'HDMI-1'

# Let's say we sleep 1/3 of day, and sun
# starts setting 0.5 hr before sleep:
sun = {'rise': 1.0, 'set': 2/3 - 0.5/24}

fade = 0.025 # amount of day to use for fading
lbound = 0.05 # minimum amount of brightness
ubound = 1.0 # maximum amount of brightness
brange = abs(ubound-lbound)

while True:
    now = (time.time()/86400.) % 1

    # night
    if sun['set'] <= now <= sun['rise']:
        fadepart = lbound

        # sunset
        if sun['set'] <= now <= sun['set']+fade:
            fadepart = lbound + brange - (now - sun['set'])/fade * brange

    # day
    elif sun['rise'] <= now <= sun['set']:
        fadepart = ubound

        # sunrise
        if sun['rise'] <= now <= sun['rise']+fade:
            fadepart = lbound + (now - sun['rise'])/fade * brange


    print(fadepart)

    os.system(f'xrandr --output {device} --brightness {fadepart}')

    time.sleep(5) # check every 5 secs.

This might actually work...

Mindey,

(通知しない) (不必要) ログインしてください。