Esempio n. 1
0
def cube_visuals():
    return generators.sequence([
        generators.sequence([
            scroll_past(Cube(SIZE, Colour.red()), Direction.UP),
            scroll_past(Cube(SIZE, Colour.green()), Direction.RIGHT),
            scroll_past(Cube(SIZE, Colour.blue()), Direction.FRONT),
        ]),
        generators.repeat(faces.faces(), 10),
        generators.repeat(edges.edges(), 10),
        text.text("BRIGHT",
                  [Colour.red(), Colour.green(),
                   Colour.blue()]),
        generators.fast(
            line_maps.line_to_cube(
                generators.sequence([
                    line.scroll_in(line.rainbow()),
                    line.scroll_out(line.rainbow()),
                ]))),
        text.text("subtle", [
            Colour((Colour.brightness // 8, 0, 0)),
            Colour((0, Colour.brightness // 8, 0)),
            Colour((0, 0, Colour.brightness // 8))
        ]),
        generators.repeat(corners.corners(), 10),
        generators.frame_limit(spiral.spiral(), 100),
        generators.repeat(extend.extend(), 3),
        generators.frame_limit(generators.slow(layers.layers(), frames=4),
                               100),
        generators.frame_limit(wave.wave(), 100),
        generators.frame_limit(snakes.snakes(), 300),
        generators.frame_limit(matrix.matrix(), 300),
    ])
Esempio n. 2
0
def rotate():
    cube = rainbow.make_colour_cube()
    return generators.sequence([
        generators.repeat(rotate_cube(cube, Direction.UP), 5),
        generators.repeat(rotate_cube(cube, Direction.LEFT), 5),
        generators.repeat(rotate_cube(cube, Direction.FRONT), 5),
    ])
Esempio n. 3
0
def text(text, colours):
    return generators.repeat(
        autoscroll(text_2d(text, colours), direction=Direction.FRONT),
        len(text))
Esempio n. 4
0
def scrolling_rainbow(num_leds = LEDS):
 return generators.sequence([
      scroll_in(rainbow(num_leds = num_leds)),
      generators.repeat(cycle(rainbow(num_leds = num_leds)), 2),
      scroll_out(rainbow(num_leds = num_leds)),
    ])
Esempio n. 5
0
def scroll_pixel(colour):
  cs = [colour] + [Colour.BLACK for i in range(LEDS - 1)]
  return generators.sequence([single_frame(cs), scroll_out(cs)])

if __name__ == "__main__":
  with Display() as d:
    # For testing the LEDs:
    #generators.generate(d, generators.sequence([
    #  scroll_pixel(Colour.red()),
    #  scroll_pixel(Colour.green()),
    #  scroll_pixel(Colour.blue()),
    #]))
    generators.generate(d, generators.shuffle([
      mirror(reverse(binary_count(LEDS // 2))),
      knight_rider(10),
      scroll_past([Colour.red() for i in range(LEDS)]),
      scroll_past([Colour.green() for i in range(LEDS)]),
      scroll_past([Colour.blue() for i in range(LEDS)]),
      scroll_past([Colour.cyan() for i in range(LEDS)], dir=-1),
      scroll_past([Colour.magenta() for i in range(LEDS)], dir=-1),
      scroll_past([Colour.yellow() for i in range(LEDS)], dir=-1),
      generators.sequence([
        scroll_in(rainbow()),
        generators.repeat(cycle(rainbow()), 5),
        generators.repeat(cycle(rainbow(), dir=-1), 5),
        scroll_out(rainbow(), dir=-1),
      ]),
    ]))

Esempio n. 6
0
    for slice_index in range(SIZE):
      pos = ([(low + i, low) for i in range(length)]
           + [(high, low + i) for i in range(length)]
           + [(high - i, high) for i in range(length)]
           + [(low, high - i) for i in range(length)])
      if length == 0:
        pos = [(low, low)]
      real_slice_index = slice_index if (layer % 2) == 0 else SIZE - 1 - slice_index
      for i in range(len(pos)):
        cube.set(convert_face_coordinates(Direction.FRONT, pos[i], real_slice_index), colours[i])
      colours = colours[len(pos):]
  return cube

def line_to_cube(line_generator, cube_transform = control_order):
  for val in line_generator:
    if type(val) is bool:
      yield val
    else:
      yield cube_transform(val)


if __name__ == "__main__":
  with Display() as d:
    generators.generate(d, generators.transform(line_to_cube(generators.sequence([
        line.scroll_in(line.rainbow()),
        generators.repeat(line.cycle(line.rainbow()), 2),
        line.scroll_out(line.rainbow()),
      ]), spiral), functools.partial(rotate.rotate, Direction.LEFT, 1)))