Beispiel #1
0
    def __init__(self,
                 numPixel=None,
                 pixelOrder=None,
                 notifPixel=None,
                 flashPixelR=None,
                 flashPixelL=None):
        if numPixel == None:
            self.numPixel = 8
        else:
            self.numPixel = numPixel

        if (pixelOrder == 'GRB'):
            self.pixelOrder = neopixel.RGB
        else:
            self.pixelOrder = neopixel.GRB

        try:
            self.spi = board.SPI()  # SPI MOSI - PIN 19
        except Exception as e:
            print("Exception occured : ", e)

        self.notifPixel = notifPixel
        self.flashPixelR = flashPixelR
        self.flashPixelL = flashPixelL
        self.lenNotifPixel = len(range(numPixel)[self.notifPixel])
        self.lenFlashPixelR = len(range(numPixel)[self.flashPixelR])
        self.lenFlashPixelL = len(range(numPixel)[self.flashPixelL])

        try:
            self.pixels = neopixel.NeoPixel_SPI(self.spi,
                                                self.numPixel,
                                                pixel_order=self.pixelOrder,
                                                auto_write=False)
        except Exception as e:
            print("Exception occured : ", e)
Beispiel #2
0
    def __init__(self, num=1, order=neopixel.GRB, auto=False, bright=1.0):
        self.num_pixels = num
        self.pixel_order = order
        self.auto_write = auto
        self.brightness = bright
        self.spi = board.SPI()
        #while not self.spi.try_lock():
        #    pass
        #self.spi.configure(baudrate=3000000, phase=0, polarity=0)
        print(self.spi.frequency)
        self.enable = True

        self.pixels = neopixel.NeoPixel_SPI(self.spi,
                                            self.num_pixels,
                                            pixel_order=self.pixel_order,
                                            auto_write=self.auto_write,
                                            brightness=self.brightness)
        # manche LEDs starten leuchtend - alle ausschalten:
        self._set_all_pixel(0x00)
        self.set_brightness(self.brightness)
        self._show()
import time
import board
import neopixel_spi as neopixel

NUM_PIXELS = 12
PIXEL_ORDER = neopixel.GRB
COLORS = (0xFF0000, 0x00FF00, 0x0000FF)
DELAY = 0.1

spi = board.SPI()

pixels = neopixel.NeoPixel_SPI(spi,
                               NUM_PIXELS,
                               pixel_order=PIXEL_ORDER,
                               auto_write=False)

while True:
    for color in COLORS:
        for i in range(NUM_PIXELS):
            pixels[i] = color
            pixels.show()
            time.sleep(DELAY)
            pixels.fill(0)
Beispiel #4
0
activate_this = '/home/pi/piled/.venv/bin/activate_this.py'
exec(open(activate_this).read(), {'__file__': activate_this})

import adafruit_matrixkeypad
import board
from digitalio import DigitalInOut, Direction
from gpiozero import Button
import neopixel_spi
from pygame import mixer
import sys
import time

# NeoPixel Strip
NUM_PIXELS = 8
spi = board.SPI()
pixels = neopixel_spi.NeoPixel_SPI(spi, NUM_PIXELS, brightness=0.05)

# Big Red Button
button = Button(24)
button_light = DigitalInOut(board.D7)
button_light.direction = Direction.OUTPUT
button_light = False

# 3x4 matrix keypad
cols = [DigitalInOut(x) for x in (board.D4, board.D3, board.D2)]
rows = [DigitalInOut(x) for x in (board.D23, board.D22, board.D27, board.D17)]
keys = [(1, 2, 3), (4, 5, 6), (7, 8, 9), ('*', 0, '#')]
keypad = adafruit_matrixkeypad.Matrix_Keypad(rows, cols, keys)

sound_dir = "/home/pi/piled/sounds/"
selected_sound = 1
Beispiel #5
0
import sys

activate_this = '/home/pi/piled/.venv/bin/activate_this.py'
exec(open(activate_this).read(), {'__file__': activate_this})

import time
import board
import neopixel_spi

NUM_PIXELS = 8
spi = board.SPI()

pixels = neopixel_spi.NeoPixel_SPI(spi,
                                   NUM_PIXELS,
                                   brightness=0.2,
                                   auto_write=False)


def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        r = g = b = 0
    elif pos < 85:
        r = int(pos * 3)
        g = int(255 - pos * 3)
        b = 0
    elif pos < 170:
        pos -= 85
        r = int(255 - pos * 3)
        g = 0
Beispiel #6
0

def cycle(c):
    # Increment c and cycle to 0 if necessary
    c += 1
    if c >= MAX_COLOURS: c = 0
    return c


# START
if __name__ == '__main__':

    # Set up the NeoPixel array, as per the library and clear it
    # NOTE There's only one NeoPixel
    pixels = neopixel.NeoPixel_SPI(board.SPI(),
                                   1,
                                   pixel_order=neopixel.GRB,
                                   auto_write=False)
    clear(pixels)

    # Initialize key variables
    filename = os.path.expanduser("~") + '/.status'
    brightness = 30  # Brightness control as a percentage
    notification = [False, False, False]
    colour = [0, 0, 0]
    count = 0
    flashState = True

    # Run the loop
    while True:
        try:
            # Set the colours of each component in the NeoPixel
import time
import board
import neopixel_spi as neopixel

num_pixels = 30
PIXEL_ORDER = neopixel.GRB
spi = board.SPI()

pixels = neopixel.NeoPixel_SPI(spi,
                               num_pixels,
                               pixel_order=PIXEL_ORDER,
                               auto_write=False)

RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (255, 200, 0)
ORANGE = (255, 100, 0)

def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        return (0, 0, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85