parser.add_argument( '--redraw', type=str2bool, nargs='?', default=True, help='Whether or not to redraw what is already being displayed on the LED matrix. Defaults to True' ) args = parser.parse_args() try: from sense_hat import SenseHat sense = SenseHat() result = sense.flip_v( args.redraw ) # A list containing 64 smaller lists of [R, G, B] pixels (red, green, blue) representing the flipped image. finish( { "result": result } ) except Exception, e: finish( e, 1 )
parser.add_argument( '--text_colour', type=to_int_list, nargs='?', default=[255, 255, 255], help= 'A list containing the R-G-B (red, green, blue) colour of the text. Each R-G-B element must be an integer between 0 and 255. Defaults to [255, 255, 255] white.' ) parser.add_argument( '--back_colour', type=to_int_list, nargs='?', default=[0, 0, 0], help= 'A list containing the R-G-B (red, green, blue) colour of the background. Each R-G-B element must be an integer between 0 and 255. Defaults to [0, 0, 0] black / off.' ) args = parser.parse_args() try: from sense_hat import SenseHat sense = SenseHat() sense.show_message(args.text_string, args.scroll_speed, args.text_colour, args.back_colour) finish({"result": True}) except Exception, e: finish(e, 1)
import argparse from _str2bool import str2bool from _return import finish parser = argparse.ArgumentParser(description='Get a single pixel') parser.add_argument('x', type=int, choices=xrange(0, 7), metavar='{ x: 0-7 }', help='0 is on the left, 7 on the right.') parser.add_argument('y', type=int, choices=xrange(0, 7), metavar='{ y: 0-7 }', help='0 is at the top, 7 at the bottom.') args = parser.parse_args() try: from sense_hat import SenseHat sense = SenseHat() result = sense.get_pixel(args.x, args.y) # Returns a list of [R, G, B] representing the colour of an individual LED matrix pixel at the specified X-Y coordinate. finish({"get_pixel": result}) except Exception, e: finish(e, 1)