예제 #1
0
def render_image(big_r, big_c, neo=None):
    """Display an image from `8x8_icons.png`."""
    r = FIRST_R + (SIZE + SKIP_R) * big_r
    c = FIRST_C + (SIZE + SKIP_C) * big_c

    sliced = image[r:r + SIZE, c:c + SIZE]

    if neo is None:
        neo = neopixel.Neopixel()
    downsampled = skimage.util.view_as_blocks(
        sliced, (4, 4, 3)).min(axis=-2).min(axis=-2).squeeze()
    neo.update(downsampled / 20)
예제 #2
0
# Quick neopixel test / sanity check for later
# Adapted from Adafruit's Raspberry Pi Neopixel Guide
# https://learn.adafruit.com/neopixels-on-raspberry-pi/python-usage


import time
import board
import neopixel

pixel_pin = board.D18

num_pixels = 3

ORDER = neopixel.RGB

pixels = neopixel.Neopixel(
    pixel_pin, num_pixels, brightness=0.2, auto_write=False,
    pixel_order=ORDER
    )
    
if __name__ == '__main__':
    pixels.fill ... tbd
예제 #3
0
        state = (state | on_pixels) & ~off_pixels
        neo[:] = colors * state
        return state

    prev_states = [0] * 4
    state = initialize()
    while True:
        prev_states.pop(0)
        prev_states.append(state.copy())
        state = update_state(state)
        time.sleep(0.02)

        for old_state in prev_states:
            if (state == old_state).all():
                for _ in xrange(50):
                    update_state(state)
                    time.sleep(0.02)
                state = initialize()


if __name__ == '__main__':
    filepath = os.path.join(PNGS_DIR, PNG_FILENAME)
    image = imageio.imread(filepath)

    neo = neopixel.Neopixel()

    # render_image(2, 0, neo)
    # cycle_images(neo)
    # cycle_letters(neo)
    render_message('WHY   AM   I   HERE   ')
예제 #4
0
import board
import time
import neopixel

pixels = neopixel.Neopixel(board.NEOPIXEL, 10, auto_write=False, brightness=0.05)

colors = [(0, 255, 0), (25, 255, 0),
        (50, 255, 0), (75, 255, 0),
        (100, 255, 0), (125, 255, 0),
        (150, 255, 0), (175, 255, 0),
        (200, 255, 0), (225, 255, 0)


while True:
    popColour = colors.pop(0)
    colors.append(popColour)

    for x xin range(len(pixels)):
        pixels[x] = colors[x]

    pixels.show()

    time.sleep(0.1)
예제 #5
0
import numpy as np 
from matplotlib import pyplot as plt 
import serial
import board
import neopixel
import sys

# data store
ec = email_content()
sys.stdout = open('/home/pi/data/experimentData.txt','a')
print('aa')

# neopixel setting
pixel_pin = board.D18
num_pixels = 8
pixels = neopixel.Neopixel(board.D18, num_pixels)
ORDER = neopixel.RGBW
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.2, auto_write=False, pixel_order=ORDER)
# pixels.fill((255, 0, 0, 0))
# pixels.show()

# camera setting
camera = PiCamera()
camera.resolution = (3280,2464)
camera.brightness = 52 # Bright Setting is can be changed.

# rgb extraction pixel range setting
seg_range = 30 # (ex. when seg_range=10 -> width=20 , height=20, with picked center point)
point1 = [459,1627]
point2 = [1818,2232]
point3 = [459,1627]
예제 #6
0
apikey = ""  # Key to access API link for data
# Location to check weather - currently Westminster
lati = "51.494720"
longi = "-0.135278"

# --- Parameters for Neopixels --- #

LED_BRIGHTNESS = 0.2  # 0 for darkest and 1 for brightest
pixel_pin = board.D18  # Pin that the lights are connected
num_pixels = 240  # Number of Pixels
ORDER = neopixel.GRB  # Define prder to be Green, Red, Blue

# Input parameters into the stairs variable
strip = neopixel.Neopixel(pixel_pin,
                          brightness=LED_BRIGHTNESS,
                          auto_write=False,
                          pixel_order=ORDER)
strip.fill((0, 0, 0))  # Make sure all off
strip.show(
)  # Auto Write is False so this line always needed when changing lights

# --- Parameters for PIR Sensor --- #

GPIO.setmode(GPIO.BCM)
PIR_PIN = 7
GPIO.setup(PIR_PIN, GPIO.IN)

#--------------------------------------------------
# Light Functions
#--------------------------------------------------
예제 #7
0
# LED Strip config
LED_COUNT = 12
LED_PIN = board.D7
LED_BRIGHTNESS = 0.75
LED_ORDER = neopixel.GRB

# COLORS
seafoam = (255, 0, 205)
skyblue = (198, 16, 249)
blue = (147, 15, 255)
bluenavy = (117, 2, 211)
bluepurple = (89, 64, 173)
COLORS = [blue, seafoam, skyblue, blue, bluenavy, bluepurple, blue]

strip = neopixel.Neopixel(LED_PIN, LED_COUNT, brightness = LED_BRIGHTNESS, pixel_order = LED_ORDER, auto_write = False)

def fade(color1, color2, percent):
    color1 = np.array(color1)
    color2 = np.array(color2)
    vector = color2-color1
    newcolor = (int((color1 + vector * percent)[0]), int((color1 + vector * percent)[1]), int((color1 + vector * percent)[2]))
    return newcolor

def cycle(wait):
  for c in range(len(COLORS)):
    for i in range(10):
      color1 = COLORS[c]
      if c == 5:
        color2 = blue
      else:
예제 #8
0
from microbit import *
import neopixel
import time

num_pixels = 24
pixels = neopixel.Neopixel(pin=0, num_pixels)


def update_leds(r, g, b):  # range 0-255
    global pixels
    for i in range(24):
        pixels[i] = (r, g, b)
        sleep(10)  #ms
        pixels.show()


while True:

    update_leds(255, 0, 0)
    time.sleep_ms(2000)

    update_leds(0, 255, 0)
    time.sleep_ms(2000)