Exemple #1
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()
Exemple #2
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()
Exemple #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()
Exemple #4
0
                            intensity = math.sqrt((rad - dist) / rad) * 2 * max_intensity
                            intensity = min(intensity, max_intensity)

                            # not sending if pixel already at that state
                            if field[field_pos] != intensity:
                                # marking pixel as dirty
                                field[field_pos] = intensity

                                # finally painting
                                matrix.send_pixel((x,y), (intensity, intensity, 0x00))

                if not painted and field[field_pos]:
                    # clear formerly painted and no longer used pixels
                    field[field_pos] = False
                    matrix.send_pixel((x,y), (0x00, 0x00, 0x00))

        # move forward
        self.pos += 1

        # are we finished?
        return pos < width

matrix = LedMatrix()
pacman = Pacman(matrix)

try:
    const_loop(pacman.step, 0.2)
finally:
    matrix.close()

Exemple #5
0
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
###############################################################################

import sys
import Image, ImageDraw

from ledwall import LedMatrix

matrix = LedMatrix()

orig = Image.open(sys.argv[1])

target_res = matrix.size
scale = min(float(target) / old for old, target in zip(orig.size, target_res))
new_size = tuple(int(old * scale) for old in orig.size)

scaled = orig.resize(new_size, Image.ANTIALIAS)

top = tuple((target - new) / 2 for new, target in zip(new_size, target_res))

im = Image.new(mode="RGB", size=target_res)
im.paste(scaled, top)

matrix.send_image(im)
Exemple #6
0
      print "Error: %s" % err, debug

  def on_sync_message(self, bus, message):
    print (bus, message)
    if message.structure is None:
      return
    #message_name = message.structure.get_name()
    #if message_name == "prepare-xwindow-id":
    #  imagesink = message.src
    #  imagesink.set_property("force-aspect-ratio", True)
    #  imagesink.set_xwindow_id(self.movie_window.window.xid)

#
# Code to test the MySink class
#
matrix = LedMatrix(server=args.server)
#matrix = LedMatrix(server="127.0.0.1")

pipe = LedPipe(args.file[0], matrix, visualize=args.visualize)

import glib, sys, os, fcntl

def GetInHMS(seconds):
    hours = seconds / 3600
    seconds -= 3600*hours
    minutes = seconds / 60
    seconds -= 60*minutes
    if hours == 0:
        return "%02d:%02d" % (minutes, seconds)
    return "%02d:%02d:%02d" % (hours, minutes, seconds)
Exemple #7
0
                        if old_field[n % width][m % height]:
                            prox += 1

                if old_field[x][y]:
                    prox -= 1
                    if prox < 2:
                        print "lonely ", prox
                        self.die(x, y)
                    elif prox > 3:
                        print "crowded ", prox
                        self.die(x, y)
                    else:
                        self.survive(x, y)
                elif prox == 3:
                    self.create(x, y)

        return True


matrix = LedMatrix()

try:
    matrix.send_clear()

    game = GameOfLife(matrix)
    game.load(sys.argv[1])

    const_loop(game.step, 0.2)
finally:
    matrix.close()
Exemple #8
0
                            intensity = min(intensity, max_intensity)

                            # not sending if pixel already at that state
                            if field[field_pos] != intensity:
                                # marking pixel as dirty
                                field[field_pos] = intensity

                                # finally painting
                                matrix.send_pixel((x, y),
                                                  (intensity, intensity, 0x00))

                if not painted and field[field_pos]:
                    # clear formerly painted and no longer used pixels
                    field[field_pos] = False
                    matrix.send_pixel((x, y), (0x00, 0x00, 0x00))

        # move forward
        self.pos += 1

        # are we finished?
        return pos < width


matrix = LedMatrix()
pacman = Pacman(matrix)

try:
    const_loop(pacman.step, 0.2)
finally:
    matrix.close()
Exemple #9
0
#     taglist = msg.parse_tag()
#     print 'on_tag:'
#     for key in taglist.keys():
#       print '\t%s = %s' % (key, taglist[key])
#
#
#   def on_error(self, bus, msg):
#     error = msg.parse_error()
#     print 'on_error:', error[1]
#     self.mainloop.quit()
#

#
# Code to test the MySink class
#
matrix = LedMatrix()
LedPipe(sys.argv[1], matrix)
"""

src = gst.element_factory_make('filesrc')
src.set_property("location", "%s" %sys.argv[1])
gst.info('About to create LedSink')

#src = gst.element_factory_make('fakesrc')
sink = LedSink()
sink.set_property("name", "ledmatrix0")

#src = gst.element_factory_make('fakesrc')
converter = gst.element_factory_make('decodebin')
#aconverter = gst.element_factory_make('autoconvert')
Exemple #10
0
                        if old_field[n%width][m%height]:
                            prox += 1

                if old_field[x][y]:
                    prox -= 1
                    if prox < 2:
                        print "lonely ", prox
                        self.die(x, y)
                    elif prox > 3:
                        print "crowded ", prox
                        self.die(x, y)
                    else:
                        self.survive(x, y)
                elif prox == 3:
                    self.create(x, y)

        return True

matrix = LedMatrix()

try:
    matrix.send_clear()

    game = GameOfLife(matrix)
    game.load(sys.argv[1])

    const_loop(game.step, 0.2)
finally:
    matrix.close()

Exemple #11
0
    def on_sync_message(self, bus, message):
        print(bus, message)
        if message.structure is None:
            return
        #message_name = message.structure.get_name()
        #if message_name == "prepare-xwindow-id":
        #  imagesink = message.src
        #  imagesink.set_property("force-aspect-ratio", True)
        #  imagesink.set_xwindow_id(self.movie_window.window.xid)


#
# Code to test the MySink class
#
matrix = LedMatrix(server=args.server)
#matrix = LedMatrix(server="127.0.0.1")

pipe = LedPipe(args.file[0], matrix, visualize=args.visualize)

import glib, sys, os, fcntl


def GetInHMS(seconds):
    hours = seconds / 3600
    seconds -= 3600 * hours
    minutes = seconds / 60
    seconds -= 60 * minutes
    if hours == 0:
        return "%02d:%02d" % (minutes, seconds)
    return "%02d:%02d:%02d" % (hours, minutes, seconds)