コード例 #1
0
def checkOnline():
    global online
    response = os.system("/bin/ping -c 1 192.168.178.1")
    if response != 0:
        print("Raspberry pi seems to be offline")
        online = False
        try:
            endpoint = Endpoint("192.168.178.48", "1234")
            setPixel(endpoint, Pixel(53, 2, "ffffff"))
            setPixel(endpoint, Pixel(54, 2, "ffffff"))
            setPixel(endpoint, Pixel(55, 2, "ffffff"))
            setPixel(endpoint, Pixel(56, 2, "ffffff"))
            setPixel(endpoint, Pixel(57, 2, "ff0000"))
            setPixel(endpoint, Pixel(55, 4, "ff0000"))
            setPixel(endpoint, Pixel(54, 4, "ffffff"))
            setPixel(endpoint, Pixel(56, 4, "ffffff"))
            setPixel(endpoint, Pixel(55, 6, "ffffff"))
            setPixel(endpoint, Pixel(58, 1, "ff0000"))
            setPixel(endpoint, Pixel(56, 3, "ff0000"))
            setPixel(endpoint, Pixel(54, 5, "ff0000"))
            setPixel(endpoint, Pixel(53, 6, "ff0000"))
            setPixel(endpoint, Pixel(52, 7, "ff0000"))
        except:
            print("Unexpected error: " + str(sys.exc_info()))
    else:
        # clear matrix once we're online again
        if online == False:
            try:
                endpoint = Endpoint("192.168.178.48", "1234")
                clearMatrix(endpoint, offset=Offset(52, 1), width=7, height=7)
                online = True
            except:
                print("Unexpected error: " + str(sys.exc_info()))
コード例 #2
0
ファイル: time.py プロジェクト: mythsunwind/matrixflut-client
 def __init__(self):
     self.formerdate = ''
     self.formertext = ''
     self.formerhour = -1
     self.blue = (0, 153, 255)
     self.color = (204, 0, 0)
     self.dyecolor = (255, 0, 0)
     self.endpoint = Endpoint("192.168.178.48", "1234")
コード例 #3
0
import sys

log = logging.getLogger('bitcoin')


def getValueFromApi():
    response = requests.get(
        'https://bitcoinapi.de/widget/current-btc-price/rate.json')
    json = response.json()
    return json['price_eur'].split(',')[0].encode('ascii', 'ignore')


if __name__ == '__main__':

    try:
        endpoint = Endpoint("192.168.178.48", "1234")

        while (True):
            try:
                rate = getValueFromApi()
                drawText(endpoint=endpoint,
                         text=rate,
                         color=(247, 147, 26),
                         offset=Offset(17, 19),
                         horizontalCentered=True,
                         fontfile="spleen-5x8.pil")
            except:
                log.error("Unexpected error on setting display: " +
                          str(sys.exc_info()))
            time.sleep(60 * 15)
コード例 #4
0
from matrixflut import Endpoint, Pixel, setPixel
import logging
import sys
import argparse
import urllib.request

log = logging.getLogger('sendImage')

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument("x", type=int, default=0)
    parser.add_argument("y", type=int, default=0)
    parser.add_argument("rgb")
    args = parser.parse_args()

    try:
        endpoint = Endpoint("192.168.178.48", 1234);
        pixel = Pixel(args.x, args.y, args.rgb)
        setPixel(endpoint, pixel)
    except KeyboardInterrupt:
        log.info("Stopping...")