예제 #1
0
def run():
    sleep(float(_screen.update_buffer))

    if _screen.party_mode:
        update_bulb_party()
        sleep(float(_screen.update))
    else:
        results = img_proc.screen_avg(_screen)

        try:
            print '\n'
            if 'zones' in results:
                print 'Parse Method: zones | Color Mode: %s' % _screen.color_mode
                for zone in results['zones']:

                    for bulb in zone['bulbs']:
                        bulb_settings = _screen.bulb_settings[unicode(bulb)]
                        bulb_max_bri = bulb_settings['max_bri']
                        bulb_min_bri = bulb_settings['min_bri']
                        bri = utility.get_brightness(_screen, bulb_max_bri,
                                                     bulb_min_bri,
                                                     zone['dark_ratio'])
                        hue_interface.send_rgb_to_bulb(bulb, zone['rgb'], bri)
            else:
                print 'Parse Method: standard | Color Mode: %s' % _screen.color_mode
                rgb = results['rgb']
                dark_ratio = results['dark_ratio']
                update_bulbs(rgb, dark_ratio)
        except urllib2.URLError:
            print 'Connection timed out, continuing...'
            pass
예제 #2
0
def re_initialize():
    config = ConfigParser.RawConfigParser()
    config.read(utility.get_config_path())

    # Attributes
    at = initialize()

    global _screen
    _screen = Screen(*at)

    # Update bulbs with new settings
    results = img_proc.screen_avg(_screen)

    try:
        # Update Hue bulbs to avg color of screen
        if 'zones' in results:
            for zone in results['zones']:
                brightness = utility.get_brightness(_screen,
                                                    int(_screen.max_bri),
                                                    int(_screen.min_bri),
                                                    zone['dark_ratio'])

                for bulb in zone['bulbs']:
                    hue_interface.send_rgb_to_bulb(bulb, zone['rgb'],
                                                   brightness)
        else:
            update_bulbs(results['rgb'], results['dark_ratio'])
    except urllib2.URLError:
        print 'Connection timed out, continuing...'
        pass
예제 #3
0
def main():
    assert len(sys.argv) == 2
    light_ip = sys.argv[1]
    assert "." in light_ip

    assert shutil.which("brightness") is not None

    signal.signal(signal.SIGINT, kill)
    global quit_soon
    quit_soon = False

    light = LB130(light_ip)
    #print(light.light_details())
    time.sleep(1)

    while True:
        if quit_soon:
            break

# get output of screen brightness command
        output = subprocess.check_output(['brightness', '-l'])
        brightness = float(
            str(output).split('display 0: brightness ')[-1][:-3])

        # get avg RGB color of screen
        r, g, b = screen_avg()['rgb']  # 3-tuple
        hue, lightness, sat = colorsys.rgb_to_hls(r / 255, g / 255, b / 255)

        # set new hue & sat
        avg_brightness = min((brightness + lightness) / 2 * 1.15, 1)
        light.hsb = (int(hue * 360), int(sat * 100), int(avg_brightness * 100))

        break  # testing purposes
예제 #4
0
def run():
    screen = get_screen_object()
    sleep(float(screen.update_buffer))

    if screen.party_mode:
        update_bulb_party()
        sleep(float(screen.update))
    else:
        results = img_proc.screen_avg(screen)
        screenbloom_control_flow(results)
예제 #5
0
def run():
    screen = get_screen_object()
    sleep(float(screen.update_buffer))

    if screen.party_mode:
        update_bulb_party()
        sleep(float(screen.update))
    else:
        results = img_proc.screen_avg(screen)
        screenbloom_control_flow(results)
예제 #6
0
def run():
    screen = get_screen_object()
    sleep(float(screen.update_buffer))

    utility.main_loop_readout(screen)

    if screen.color_mode_enabled:
        if screen.party_mode:
            update_bulb_party()
            sleep(float(screen.update))
        else:
            results = img_proc.screen_avg(screen)
            color_mode_control_flow(results)