示例#1
0
def main(args):
    from optparse import OptionParser

    optp = OptionParser(usage="%prog [options] [address]")

    optp.add_option("-p", "--player",
            help="Set preferred player (0-5)",
            metavar="PLAYER",
            type="int",
            default=None)

    optp.add_option("-d", "--direct-input",
            help="Get more direct input",
            action="store_false",
            default=True)

    optp.add_option("--priority",
            help="Change priority, default is 2",
            metavar="PRIORITY",
            type="int",
            default=2)

    (options, args) = optp.parse_args()

    matrix = LedMatrix(args[0] if args else None)

    try:
        matrix.change_priority(options.priority)

        game = SnakeGame(matrix, options.direct_input, options.player)
        game.run()
    finally:
        matrix.close()
示例#2
0
def main(args):
    from optparse import OptionParser

    optp = OptionParser()

    optp.add_option("-s",
                    "--fade_steps",
                    help="Set color fading speed in steps between colors",
                    metavar="FADE_STEPS",
                    type="int",
                    default=40)

    optp.add_option("--priority",
                    help="Apply the given priority to the connection",
                    metavar="PRIORITY",
                    type="int")

    optp.add_option(
        "-c",
        "--color",
        help="Add a color (in hex, e.g. ff0000) to the color fading",
        action="append",
        metavar="COLOR")

    optp.add_option("-b",
                    "--background",
                    help="Set background color",
                    metavar="COLOR")

    (options, args) = optp.parse_args()

    if options.color != None:
        colors = [parse_color(color_str) for color_str in options.color]
    else:
        colors = DEF_COLORS

    if options.background != None:
        background = parse_color(options.background)
    else:
        background = DEF_BACK

    matrix = LedMatrix()

    if options.priority != None:
        matrix.change_priority(options.priority)

    if len(args) < 1:
        text = "<<</>>"
    else:
        text = u' '.join(arg.decode("utf-8") for arg in args)

    try:
        FadingText(matrix,
                   text,
                   options.fade_steps,
                   colors,
                   background=background).endless()
    finally:
        matrix.close()
示例#3
0
def main(args):
    from optparse import OptionParser

    optp = OptionParser()

    optp.add_option("-s", "--fade_steps",
            help="Set color fading speed in steps between colors",
            metavar="FADE_STEPS",
            type="int",
            default=40)

    optp.add_option("--priority",
            help="Apply the given priority to the connection",
            metavar="PRIORITY",
            type="int")

    optp.add_option("-c", "--color",
            help="Add a color (in hex, e.g. ff0000) to the color fading",
            action="append",
            metavar="COLOR")

    optp.add_option("-b", "--background",
            help="Set background color",
            metavar="COLOR")

    (options, args) = optp.parse_args()

    if options.color != None:
         colors = [parse_color(color_str) for color_str in options.color]
    else:
         colors = DEF_COLORS

    if options.background != None:
        background = parse_color(options.background)
    else:
        background = DEF_BACK

    matrix = LedMatrix()

    if options.priority != None:
        matrix.change_priority(options.priority)

    if len(args) < 1:
        text = "<<</>>"
    else:
        text = u' '.join(arg.decode("utf-8") for arg in args)

    try:
        FadingText(matrix, text, options.fade_steps, colors, background=background).endless()
    finally:
        matrix.close()