コード例 #1
0
ファイル: snake.py プロジェクト: thammi/ledwallfoo
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
ファイル: fade_text.py プロジェクト: thammi/ledwallfoo
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
ファイル: imageviewer.py プロジェクト: thammi/ledwallfoo
##  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)
コード例 #4
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)