예제 #1
0
def open_mote():
    m = Mote()

    for channel in range(1, 5):
        m.configure_channel(channel, 16, False)

    return m
예제 #2
0
def connectToMote(moteId="", led=(1, 0, 0, 0), changeOnly=False):
    """
    cache = MoteCache()
    cache.read()

    # print "GetMotes:", cache.getMotes()
    allDevs = detectAllPossible()

    selectedMoteId = None
    for d in allDevs:
        if d in cache.getMotes():
            selectedMoteId = d
            break

    if selectedMoteId == None:
        print "No motes found.  Device ids:", allDevs, "cacheMoteIds:", cache.getMotes().keys()
        sys.exit()

    # mote = cache.getMotes().values()[0]
    mote = cache.getMotes()[selectedMoteId]
    """

    #if moteId == "":
    #    moteId = "00:17:AB:32:BF:EF"
    #mote = Mote(id="00:19:1D:79:93:E0")
    #mote = Mote(id="00:17:AB:32:BF:EF")
    mote = Mote(id=moteId)
    mote.connect()

    #mote.setLeds(1,0,0,0)
    if mote.connected:
        mote.setLeds(led[0], led[1], led[2], led[3])
        mote.startReadThread()
        mote.irBasicModeOn(changeOnly=changeOnly)
    return mote
예제 #3
0
    def __init__(self):
        self.mote = Mote()

        gammaCorrection = False
        self.mote.configure_channel(1, 16, gammaCorrection)
        self.mote.configure_channel(2, 16, gammaCorrection)
        self.mote.configure_channel(3, 16, gammaCorrection)
        self.mote.configure_channel(4, 16, gammaCorrection)
예제 #4
0
def connectToMote(moteId="", led=(1,0,0,0) , changeOnly=False):
    """
    cache = MoteCache()
    cache.read()

    # print "GetMotes:", cache.getMotes()
    allDevs = detectAllPossible()

    selectedMoteId = None
    for d in allDevs:
        if d in cache.getMotes():
            selectedMoteId = d
            break

    if selectedMoteId == None:
        print "No motes found.  Device ids:", allDevs, "cacheMoteIds:", cache.getMotes().keys()
        sys.exit()

    # mote = cache.getMotes().values()[0]
    mote = cache.getMotes()[selectedMoteId]
    """

    #if moteId == "":
    #    moteId = "00:17:AB:32:BF:EF"
    #mote = Mote(id="00:19:1D:79:93:E0")
    #mote = Mote(id="00:17:AB:32:BF:EF")
    mote = Mote(id=moteId)
    mote.connect()

    #mote.setLeds(1,0,0,0)
    if mote.connected:
        mote.setLeds(led[0], led[1], led[2], led[3])
        mote.startReadThread()
        mote.irBasicModeOn(changeOnly=changeOnly)
    return mote
예제 #5
0
class MoteController:
    def __init__(self):
        self.mote = Mote()

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

    def run(self, programs):
        while True:
            for program in programs:
                program.run(self.mote)
예제 #6
0
def init_motes(colour, brightness):
    print("initialising Motes")
    #set
    mote = Mote()  # new instance of the Mote class, will do all the USB init
    for m in range(1, 4 + 1):
        mote.configure_channel(m, 16,
                               False)  # configure for use the Mote sticks
    #calculate colour for brightness
    # just first stick at the moment
    h, s, v = colorsys.rgb_to_hsv(colour[0][0], colour[0][1], colour[0][2])
    colour_new = [[0] * 3 for i in range(4)]
    colour_new[0][0], colour_new[0][1], colour_new[0][2] = rgb_to_decimal(
        colorsys.hsv_to_rgb(h, s, brightness))
    set_mote_sticks(mote, colour_new)
    return mote
예제 #7
0
    def __init__(self, channels=4, correction=[1., 1., 1.]):

        self.mote = Mote()

        for c in range(channels):
            self.mote.configure_channel(c + 1, 16, False)

        BaseLamp.__init__(self, correction=correction)

        self.channels = channels
        self.pixels = 16

        for channel in range(self.channels):
            self.mote.configure_channel(channel + 1, self.pixels, False)

        self.width = self.channels
        self.height = self.pixels
예제 #8
0
 def read(self, filename="mote.cache"):
     if os.path.exists("mote.cache"):
         cache = open("mote.cache", "r")
         cachedDevs = eval(cache.read())
         print "cachedDevs:", cachedDevs
         for device in cachedDevs:
             self.cachedDevs[device[0]] = Mote(device[0], device[1])
         cache.close()
    def connectToMote(self):
        self.showMessage("Connecting")
        try:
            from mote import Mote
            self.mote = Mote()
            self.simulate = False
            self.showMessage("Connected")
            if not self.simulate:
                self.mote.clear()
                self.mote.show()
        except IOError:
            self.simulate = True
            self.showMessage("Simulating")

        self.yToStick = []
        self.addStick(1)
        self.addStick(2)
        self.addStick(3)
        self.addStick(4)
예제 #10
0
    def addMotes(self, moteTupleList):
        if type(moteTupleList) == type(list()):
            for m in moteTupleList:
                self.cachedDevs[m[0]] = Mote(m[0], m[1])

            #if len(moteList) > 0:
            #    if type(moteList[0]) == type(mote.Mote())
            #        for m in moteList:
            #            self.cachedDevs[m.id] = m
        else:
            raise Exception("addMotes expected a list")
예제 #11
0
def connectmote():
    try:
        mote = Mote()
        retdata = {'MoteReply': {'status': '1'}}
    except IOError:
        mote = None
        retdata = {
            'MoteReply': {
                'status':
                '0',
                'error':
                'Mote device failed to connect. Check device is physically connected and try again.'
            }
        }
        return json.jsonify(retdata)
예제 #12
0
def setstick(s, r, g, b):
    mote = Mote()  # new instance of the Mote class, will do all the USB init
    state = getmotestate()
    for m in range(1, 4 + 1):
        mote.configure_channel(m, 16,
                               False)  # configure for use the Mote sticks
        setpixels(m, state[m - 1][0], state[m - 1][1], state[m - 1][2], mote)
    if s == 0:
        for st in range(1, 4 + 1):
            setpixels(st, r, g, b, mote)
            setmotestate(state, st, r, g, b)
    else:
        setpixels(s, r, g, b, mote)
        setmotestate(state, s, r, g, b)
    mote.show()
예제 #13
0
def setstick(s, b, i):
    mote = Mote()  # new instance of the Mote class, will do all the USB init
    state = getmotestate()
    if i != 0:
        b = getbrightness(state, s) + i
        if b < 0:
            b = 0
        elif b > 9:
            b = 9
    state = setbrightness(state, s, b, i)
    for m in range(1, 4 + 1):
        mote.configure_channel(m, 16,
                               False)  # configure for use the Mote sticks
        setpixels(m, state[m - 1][0], state[m - 1][1], state[m - 1][2], mote)
    mote.show()
    setmotestate(state, s, state[s - 1][0], state[s - 1][1], state[s - 1][2])
예제 #14
0
파일: mote-api.py 프로젝트: RogueM/mote
#!/usr/bin/env python

from colorsys import hsv_to_rgb, rgb_to_hsv
from sys import exit

try:
    from flask import Flask, jsonify, make_response
except ImportError:
    exit("This script requires the flask module\nInstall with: sudo pip install flask")

from mote import Mote


## Create app, Mote instance
app = Flask(__name__)
mote = Mote()

## Configure Mote channels for 4x 16 pixel strips
mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)

# Define baseurl and current API version
baseurl = "/mote/api/"
version = "v1.0"

## Default status to initialise with - all channels off, white, full brightness
status = {'state': {1: 0, 2: 0, 3: 0, 4: 0},
          'colour': {1: [255, 255, 255], 2: [255, 255, 255], 3: [255, 255, 255], 4: [255, 255, 255]},
          'brightness': {1: 255, 2: 255, 3: 255, 4: 255}
try:
    import requests
except ImportError:
    exit(
        "This script requires the requests module\nInstall with: sudo pip install requests"
    )

import serial.tools.list_ports
list = serial.tools.list_ports.comports()

#Find the MOTE Hubs!   This machine has 2 installed
var1 = 1
for element in list:
    if 'Mote' in element.description:
        if var1 == 1:
            mote1 = Mote(port_name=element.device)
            var1 = 2
        elif var1 == 2:
            mote2 = Mote(port_name=element.device)

#Configure the 16 LED's, clear channels on both hubs
mote1.configure_channel(1, 16, False)
mote1.configure_channel(2, 16, False)
mote1.configure_channel(3, 16, False)
mote1.configure_channel(4, 16, False)

mote2.configure_channel(1, 16, False)
mote2.configure_channel(2, 16, False)
mote2.configure_channel(3, 16, False)
mote2.configure_channel(4, 16, False)
예제 #16
0
파일: rgb.py 프로젝트: RogueM/mote
#!/usr/bin/env python

import sys
import time

from mote import Mote


mote = Mote()

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


def usage():
    print("Usage: {} <r> <g> <b>".format(sys.argv[0]))
    sys.exit(1)

if len(sys.argv) != 4:
    usage()

# Exit if non integer value. int() will raise a ValueError
try:
    r, g, b = [int(x) for x in sys.argv[1:]]
except ValueError:
    usage()

# Exit if any of r, g, b are greater than 255
if max(r,g,b) > 255:
예제 #17
0
import serial
# import struct
# import requests
# import traceback
import sys
import json

from mote import Mote

serial_connection = serial.Serial('/dev/ttyACM0', 115200, timeout=None)
mote = Mote(serial_connection)
i = 0
while True:
    data = mote.readline()
    print("Read from serial:", data)
    data = data + 1
    print("Enviando to serial:", data)
    mote.put(data)
    # make_request(data)
예제 #18
0
#!/usr/bin/env python

import time
from colorsys import hsv_to_rgb

from mote import Mote

print("""Rainbow

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

mote = Mote()

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)
                ]
예제 #19
0
#!/usr/bin/env python3
"""AmbiMote UDP Server."""
import argparse
import sys
import asyncio
import struct
from base64 import b16encode
from mote import Mote

mote = Mote()

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

try:
    import signal
except ImportError:
    signal = None


class UdpAmbiMoteProtocol:
    pix_no = 0

    def connection_made(self, transport):
        print('start', transport)
        self.transport = transport

    @staticmethod
    def parse_rgb(i):
예제 #20
0
}


def get_color():
    print('We have these colours available:')
    for key in COLORS.keys():
        print(key)
    ans = input('Which colour are you using today?' + ' ')
    if ans.lower() in COLORS.keys():
        return COLORS[ans.lower()]
    else:
        return COLORS[DEFAULT]


# configure mote
mote = Mote()

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

mote.clear()

# Set mode
colour = get_color()

# colours running
# Updated from: https://github.com/pimoroni/mote/blob/master/python/examples/rainbow.py
try:
    while True:
예제 #21
0
파일: set-all.py 프로젝트: pimoroni/mote
#!/usr/bin/env python

import time

from mote import Mote

rgb = (128, 0, 0)

mote = Mote()

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

while True:
    r, g, b = rgb
    mote.set_all(r, g, b)
    mote.show()
    time.sleep(1)
    rgb = (g, b, r)
예제 #22
0
from mote import Mote
import time

mote = Mote()
mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)
mote.clear()
mote.show()

# colours = ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
# iteration = 0
red = 255
green = 0
blue = 0

try:
    while True:
        if red > 0 and blue == 0:
            red -= 1
            green += 1
        if green > 0 and red == 0:
            green -= 1
            blue += 1
        if blue > 0 and green == 0:
            blue -= 1
            red += 1

        mote.set_all(red, green, blue, 0.5)
        mote.show()
예제 #23
0
#!/usr/bin/env python

import time
from colorsys import hsv_to_rgb

from mote import Mote


mote = Mote()

num_pixels = 16

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

colors = [
    (255,   0,   0),
    (0,   255,   0),
    (255,   0,   0),
    (0,   255,   0)
]    



def knightRider(lightdirection):
    timer = .001
    
    for pixel in range(15):
        for channel in range(4):
예제 #24
0
parser.add_argument('--loop',
                    help='Keep looping, while refreshing status-bar',
                    action='store_const',
                    const=1,
                    default=0)
args = parser.parse_args()  #'@/etc/heartbeat-display.conf')

print "============================="
print args

if args.output == mote_phat:
    import motephat
    mote = motephat
elif args.output == usb:
    from mote import Mote
    mote = Mote()
    mote.configure_channel(1, 16, False)
    mote.configure_channel(2, 16, False)
    mote.configure_channel(3, 16, False)
    mote.configure_channel(4, 16, False)
elif args.output == status_phat:
    print '--status_phat er ikke implementeret endnu'
    exit(1)
elif args.output == status_hat:
    print '--status_hat er ikke implementeret endnu'
    exit(1)

import json
import time
import requests
예제 #25
0
파일: pytix_mote.py 프로젝트: mdoege/PyTIX
	global disp,mote

	t = time.strftime(f, time.localtime())
	h1, h2, m1, m2 = [int(x) for x in t]
	disp = [[2, 1, 4, 4, 4, 1, 6, 6, 1, 8, 8, 8] for y in range(3)]
	tog( 0,  1, h1, 3)
	tog( 2,  5, h2, 5)
	tog( 6,  8, m1, 7)
	tog( 9, 12, m2, 9)
	for x in range(12):
		for y in range(3):
			r, g, b = colors[ disp[y][x] ]
			mote.set_pixel(y+1, x, r, g, b)
	mote.show()

mote = Mote()

num_pixels = 16

mote.configure_channel(1, num_pixels, False)
mote.configure_channel(2, num_pixels, False)
mote.configure_channel(3, num_pixels, False)
mote.clear()
mote.show()

try:
    while True:
        mainprog()
        time.sleep(inter)

except KeyboardInterrupt:
예제 #26
0
import time
from colorsys import hsv_to_rgb
from colorsys import rgb_to_hsv
from copy import copy
from sys import exit

try:
    import requests
except ImportError:
    exit("This script requires the requests module\nInstall with: sudo pip install requests")

from mote import Mote


mote = Mote()

num_pixels = 16

transition_time = 1 # seconds
transition_step = 100

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

try:
    channels_colour_rgb = [[0,0,0], [0,0,0], [0,0,0], [0,0,0]]
    channels_colour = [[0,0,0], [0,0,0], [0,0,0], [0,0,0]]
    channels_colour_delta = [[0,0,0], [0,0,0], [0,0,0], [0,0,0]]
from mote import Mote
import sys
motes = Mote()
motes.configure_channel(1, 16, False)

r = int(sys.argv[1])
g = int(sys.argv[2])
b = int(sys.argv[3])

motes.clear()
motes.set_pixel(1, 0, r, g, b)
motes.set_pixel(1, 1, r, g, b)
motes.set_pixel(1, 2, r, g, b)
motes.set_pixel(1, 3, r, g, b)
motes.set_pixel(1, 4, r, g, b)
motes.set_pixel(1, 5, r, g, b)
motes.set_pixel(1, 6, r, g, b)
motes.set_pixel(1, 7, r, g, b)
motes.set_pixel(1, 8, r, g, b)
motes.set_pixel(1, 9, r, g, b)
motes.set_pixel(1, 10, r, g, b)
motes.set_pixel(1, 11, r, g, b)
motes.set_pixel(1, 12, r, g, b)
motes.set_pixel(1, 13, r, g, b)
motes.set_pixel(1, 14, r, g, b)
motes.set_pixel(1, 15, r, g, b)
motes.show()
from time import sleep

from mote import Mote
from bluezero import constants
from bluezero import tools
from bluezero import adapter
from bluezero import device
from bluezero.GATT import Characteristic

display_on = False
lights = Mote()

mote_pixels = 16
lights.configure_channel(1, mote_pixels, False)


def on_accel_change(iface, changed_props, invalidated_props):
    print('Accel!')
    global display_on
    if iface != constants.GATT_CHRC_IFACE:
        return

    if not len(changed_props):
        return

    accel_val = changed_props.get('Value', None)
    if not accel_val:
        return

    # Read button value
    x = abs(int.from_bytes(accel_val[0:1], byteorder='little', signed=True))
예제 #29
0
#!/usr/bin/env python

import time
from colorsys import hsv_to_rgb

from mote import Mote


print("""Rainbow

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

mote = Mote()

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()
# Adapted from blinkt example
import random
import time
from mote import Mote

mote = Mote()

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

try:
    while True:
        for channel in range(4):
            for i in range(16):
                mote.set_pixel(channel+1,i, random.randint(0,255), random.randint(0,255), random.randint(0,255))
            time.sleep(0.01)
            mote.show()

except KeyboardInterrupt:
	mote.clear()
	mote.show()
	quit()

# see https://github.com/pimoroni/mote for installation instructions

import time

from mote import Mote

# On user input, this program mutates red, gree, and blue values in rgblist and sends them to the buffer (ie. outputs the light colours to the mote LED sticks). The light remains on until another selection is made of the program ends.

# Default RGB definitions (ie. off)
R = 0
G = 0
B = 0
rgblist = [R, G, B]

#mote definitions
mote = Mote()
mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)
mote.clear()

# Light mode name and RGB code for each (2000, 2700, 3000, 3700, 5000 Kelvin)
candle = [255, 138, 18]
fortyw = [255, 169, 87]
hundredw = [255, 180, 107]
halogen = [255, 201, 148]
carbon = [255, 228, 206]

# print options to select
print("""
예제 #32
0
print(r.status_code)
print(r.text)

url = '/datavenue/v1/datasources/' + DatasourceID + '/streams/' + StreamID + '/values'
endpoint = host + url

print('Get stream values:')
r = requests.get(endpoint, headers=headers)
print(r.status_code)
print(r.text)

parsed_json = json.loads(r.text)
num_frames = len(parsed_json)
print('got ' + str(num_frames) + ' frames')

mote = Mote()
mote.ActivateAbp(0x00CC01AF, "2B7E151628AED2A6ABF7158809CF4F3C",
                 "2B7E151628AED2A6ABF7158809CF4F3C")

for frame in parsed_json:
    time = frame['at']
    port = frame['metadata']['port']
    fcnt = frame['metadata']['fcnt']
    enc_payload = bytes.fromhex(frame['value'])
    payload = mote.EncryptPayload(port, enc_payload, 0x00CC01AF, 0, fcnt)
    payload_str = ''.join('{:02X}'.format(x) for x in payload)
    #print(frame)
    print(
        str(port) + '\t' + time + '\t' + str(frame['metadata']['fcnt']) +
        '\t' + frame['value'] + '\t' + payload_str)
예제 #33
0
#Adapted from Adafruit's dotstar python example (https://github.com/adafruit/Adafruit_DotStar_Pi)

from PIL import Image

numpixels = 16  # Number of LEDs in strip
filename = "hello.png"  # Image file to load

from mote import Mote
mote = Mote()
mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)

# Load image in RGB format and get dimensions:
print "Loading..."
img = Image.open(filename).convert("RGB")
pixels = img.load()
width = img.size[0]
height = img.size[1]
print "%dx%d pixels" % img.size

if (height > mote.get_pixel_count(1)): height = 15

# Calculate gamma correction table, makes mid-range colors look 'right':
gamma = bytearray(256)
for i in range(256):
    gamma[i] = int(pow(float(i) / 255.0, 2.7) * 255.0 + 0.5)

print "Displaying..."
예제 #34
0
        try:
            data = requests.get(
                'https://api.covid19api.com/country/ireland/status/confirmed/live'
            ).json()
            data_retrieved = True
        except:
            print('Error on request, sleeping for 30 seconds...')
            sleep(30)
    tot_cases_today = int(data[-1]['Cases'])
    tot_cases_yesterday = int(data[-2]['Cases'])
    new_cases_today = tot_cases_today - tot_cases_yesterday
    print('Updated new cases today:', new_cases_today)
    return str(bin(new_cases_today))[2:]


mote = Mote()

mote.configure_channel(1, 16, False)
last_case_str = None

mote.clear()

while True:
    cases_bin = new_cases_today_bin()

    if (not last_case_str) or cases_bin != last_case_str:
        print('Cases changed, updating display...')

        for i, v in enumerate(cases_bin):
            if v == '1':
                mote.set_pixel(1, i, 255, 255, 255, 0.02)
예제 #35
0
## Author: Daniel Pullan
## Github: GitHub.com/DanielPullan
## Website: DanielPullan.co.uk

from time import sleep
from mote import Mote


mail = int(feedparser.parse("https://" + email + ":" + password + "@mail.google.com/gmail/feed/atom/")["feed"] ["fullcount"])
mote = Mote()

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

# stripnumber, pixel number (0 is first), red, green, blue
# mote.set_pixel(1, 1, 255, 0 0) = on first strip, second pixel, red = 255, blue and green = 0

mote.clear()
for pixel in range(16):
    mote.set_pixel(1, pixel, 0,0,0)
    mote.show()

예제 #36
0
import time
from colorsys import hsv_to_rgb
from colorsys import rgb_to_hsv
from copy import copy
from sys import exit

try:
    import requests
except ImportError:
    exit(
        "This script requires the requests module\nInstall with: sudo pip install requests"
    )

from mote import Mote

mote = Mote()

num_pixels = 16

transition_time = 1  # seconds
transition_step = 100

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

try:
    channels_colour_rgb = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
    channels_colour = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
    channels_colour_delta = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
예제 #37
0
def run():
    """let's goooo"""
    mote = Mote()

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

    rand_cols = ColorRandom()

    patterns = [
        pattern_floodfill,
        pattern_scatter,
        pattern_race,
        pattern_horizflood,
        pattern_horizsnakeflood,
        pattern_snakeflood,
    ]
    black = lambda: ColorConstant([0, 0, 0])
    colors = [
        ColorRandom,
        lambda: ColorConstant(rand_cols.get(None)),
        lambda: ColorChannelConstant(rand_cols),
        lambda: ColorChannelFade(rand_cols.get(None), rand_cols.get(None)),
        lambda: ColorGlobalFade(rand_cols.get(None), rand_cols.get(None)),
        lambda: ColorPixelFade(rand_cols.get(None), rand_cols.get(None)),
        lambda: ColorHorizCenterFade(rand_cols.get(None), rand_cols.get(None)),
        lambda: ColorRadialFade(rand_cols.get(None), rand_cols.get(None)),
        lambda: ColorChequerboard(rand_cols),
    ]
    last_col_template = None
    last_pattern_template = None

    while True:
        pattern_template = choice(patterns)
        if pattern_template == last_pattern_template:
            continue
        pattern = pattern_template() if random() < 0.5 else pattern_reverse(
            pattern_template())

        color_template = black if (random() < 0.33 and last_col_template is not None) \
            else choice(colors)
        if color_template == last_col_template:
            continue
        color = color_template()

        for update in pattern:
            c = color.get(update)
            prev_c = mote.get_pixel(update[0], update[1])
            for step in range(8):
                step_c = lerp_cols(step / 7.0, prev_c, c)
                mote.set_pixel(update[0], update[1], step_c[0], step_c[1],
                               step_c[2])
                mote.show()
                time.sleep(0.03)

        last_col_template = color_template
        last_pattern_template = pattern_template
예제 #38
0
import time
from mote import Mote

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


def clamp16(n):
    return max(min(16, n), 0)


def moteset(n, r, g, b):
    # strip 1 (increasing pixels)
    r1 = clamp16(n)  # values between 1 and 16
    for pixel in range(r1):
        mote.set_pixel(1, pixel, r, g, b)
    # strip 2 (inc.)
    r2 = clamp16(n - 16)  # values between 17 and 32
    for pixel in range(r2):
        mote.set_pixel(2, pixel, r, g, b)
    # strip 3 (decreasing pixels)
    r3 = clamp16(n - 32)  # values between 33 and 48
    for pixel in range(15, 15 - r3, -1):
        mote.set_pixel(3, pixel, r, g, b)
    # strip 4 (dec.)
    r4 = clamp16(n - 48)  # values betwene 47 and 64
    for pixel in range(15, 15 - r4, -1):
예제 #39
0
파일: test.py 프로젝트: RogueM/mote
#!/usr/bin/env python

import time
from colorsys import hsv_to_rgb

from mote import Mote


mote = Mote()

num_pixels = 16

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

colors = [
    (255,   0,   0),
    (0,   255,   0),
    (0,     0, 255),
    (255, 255, 255)
]

try:
    # Display solid colour test
    for step in range(4):
        for channel in range(4):
            for pixel in range(mote.get_pixel_count(channel + 1)):
                r, g, b = colors[channel]
                mote.set_pixel(channel + 1, pixel, r, g, b)