def main():
    mote.set_clear_on_exit(False)  # Very important
    for c in range(NUM_CHANNELS):
        mote.configure_channel(c + 1, NUM_PIXELS, True)

    current = start.copy()
    print(start)
    print(current)
    print(target)

    while current != target:
        mote.set_all(current[0], current[1], current[2])
        mote.show()

        diff = abs(current[0] - target[0])
        current[0] += (STEP if diff > STEP else
                       diff) * (-1 if current[0] > target[0] else 1)
        diff = abs(current[1] - target[1])
        current[1] += (STEP if diff > STEP else
                       diff) * (-1 if current[1] > target[1] else 1)
        diff = abs(current[2] - target[2])
        current[2] += (STEP if diff > STEP else
                       diff) * (-1 if current[2] > target[2] else 1)
        time.sleep(INTERVAL)
Beispiel #2
0
#!/usr/bin/env python

import time
from colorsys import hsv_to_rgb

import motephat as mote

print("""Rainbow

Press Ctrl+C to clear and exit.
""")

mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)

h = 1

try:
    while True:
        for channel in range(1, 5):
            pixel_count = mote.get_pixel_count(channel)
            for pixel in range(pixel_count):
                hue = (h + ((channel - 1) * pixel_count * 5) +
                       (pixel * 5)) % 360
                r, g, b = [
                    int(c * 255) for c in hsv_to_rgb(hue / 360.0, 1.0, 1.0)
                ]
                mote.set_pixel(channel, pixel, r, g, b)
        mote.show()
Beispiel #3
0
import motephat

print("""
Mote pHAT: Cheerlights

Display colours from the cheerlights API.

Press Ctrl+C to exit!

""")

motephat.set_brightness(1)

num_pixels = 16

motephat.configure_channel(1, num_pixels, False)
motephat.configure_channel(2, num_pixels, False)
motephat.configure_channel(3, num_pixels, False)
motephat.configure_channel(4, num_pixels, False)

try:
    while True:
        r = requests.get('http://api.thingspeak.com/channels/1417/feed.json')
        j = r.json()
        f = j['feeds'][-8:]

        f = [element for index, element in enumerate(f) if index % 2 == 0]

        print(f)

        channel = 1
def main():
  mote.set_clear_on_exit(False)  # Very important
  for c in range(NUM_CHANNELS):
    mote.configure_channel(c + 1, NUM_PIXELS, True)
  mote.set_all(r, g, b)
  mote.show()
Beispiel #5
0
#!/usr/bin/env python

import time
import os
import motephat

motephat.configure_channel(1, 16, False)
motephat.configure_channel(2, 16, False)

motephat.set_clear_on_exit(True)

facebookUrl = os.environ.get('facebook')
instagramUrl = os.environ.get('instagram')


def getFacebookLikes():
    likes = os.popen(
        "curl -s %s | grep -o 'total_likes\":[0-9|,]\{1,\}' | grep -o '[0-9|,]\+' | tr -d ','"
        % facebookUrl).read()

    return likes


def getInstagramFollowers():
    followers = os.popen(
        "curl -s %s | grep -o 'meta content=\"[0-9|,]\{1,\} Followers' | grep -o '[0-9|,]\+' | tr -d ','"
        % instagramUrl).read()

    return followers

import paho.mqtt.client as mqttClient
import time

import motephat as mote
from colorsys import hsv_to_rgb

mote.configure_channel(1, 16, False)

def hex_to_rgb(value):
    value = value.lstrip("#")
    length = len(value)
    return tuple(int(value[i:i + length // 3], 16) for i in range(0, length, length // 3))

def mote_on():
    for channel in range(4):
        for pixel in range(16):
            mote.set_pixel(channel + 1, pixel, 255,255,255, 0.7)
        time.sleep(0.01)

    mote.show()

def mote_change(c):
    r,g,b = hex_to_rgb(c)
    print(r,g,b)
    for channel in range(4):
        for pixel in range(16):
            mote.set_pixel(channel + 1, pixel, r,g,b, 0.5)
        time.sleep(0.01)

    mote.show()
def mote_init():
    mote.set_clear_on_exit(False)  # Very important
    for c in range(NUM_CHANNELS):
        mote.configure_channel(c + 1, NUM_PIXELS, True)
def main():
    mote.set_clear_on_exit(False)
    for c in range(NUM_CHANNELS):
        mote.configure_channel(c + 1, NUM_PIXELS, True)
    set_all()