Beispiel #1
0
def main():
    lan = LifxLAN()

    tiles = ""
    if environ.get('MAC_ADDR') is None and environ.get('IP_ADDR') is None:
        lights = lan.get_tilechain_lights()
        if not lights:
          print("Lights not found.")
          raise("Lights not found.")

        print("Lights found:")
        for light in lights:
          print(light)

        tile_number = 0
        if environ.get('TILE_NUMBER') is not None:
          tile_number = os.environ['TILE_NUMBER']
        tiles = lights[tile_number]
    else:
        mac = environ.get('MAC_ADDR')
        ip = environ.get('IP_ADDR')
        tiles = TileChain(mac, ip)


    # milisecond delay in changing the color
    color_delay = 1000

    # Available colors
    a = (22573, 65535, 33183, 3500)
    b = (24029, 65535, 21626, 3500)
    c = (24426, 61139, 22213, 3500)
    d = (22068, 35606, 40227, 3500)
    none = (24426, 12584, 22213, 3500)

    for i in range(1, 6):

        if sys.argv[i] == "0":
            tiles.set_tile_colors(i - 1, [none] * 64, color_delay)

        elif sys.argv[i] == "1":
            tiles.set_tile_colors(i - 1, [d] * 64, color_delay)

        elif sys.argv[i] == "2":
            tiles.set_tile_colors(i - 1, [c] * 64, color_delay)

        elif sys.argv[i] == "3":
            tiles.set_tile_colors(i - 1, [b] * 64, color_delay)

        elif sys.argv[i] == "4":
            tiles.set_tile_colors(i - 1, [a] * 64, color_delay)
Beispiel #2
0
import attr
from lifxlan import LifxLAN
import numpy as np

from .base import BaseDevice
from .shared import Zone

num_expected_lights = 1
lifx = LifxLAN(num_expected_lights)

tile_chain = lifx.get_tilechain_lights()[0]
cols, rows = tile_chain.get_canvas_dimensions()


@attr.s(auto_attribs=True)
class LifxTile(BaseDevice):
    name: str = attr.ib(default="LIFX Tile")

    def set_all(self, color):
        print(color)

    def set_effect(self, effect):
        effect.on_tick()

        background_colors = []
        for row in range(rows):
            color_row = []
            for col in range(cols):
                center = np.array([row / rows, col / cols])
                zone = Zone((row, col), center)
                color = effect.calculate_zone_color(zone)