Exemplo n.º 1
0
### 1m strip of 144 per m = 144
### 5m strip of  60 per m = 300
### 5m strip of  30 per m = 150
numpix = 144

### first arg - C or D?
### second arg - C or D?
### image shows output 2 to CI (2nd one down) and output 0 to DI (3rd one down)
### warning cable colours may be confusing on APA102 strips
### (D2,D0) according to online docs gives hardware SPI (i.e. efficient)
### https://circuitpython.readthedocs.io/projects/dotstar/en/latest/api.html
oclock=board.D2
odata=board.D0
##bright=0.2
bright=1.0
strip = adafruit_dotstar.DotStar(oclock, odata, numpix, bright, False)
##strip = adafruit_dotstar.DotStar(oclock, odata, numpix, bright)

boardled = digitalio.DigitalInOut(board.D13)
boardled.direction = digitalio.Direction.OUTPUT

black=(0,0,0)
red=(255,0,0)
green=(0,255,0)
blue=(0,0,255)
magenta=(255,0,255)
cyan=(0,255,255)
yellow=(255,255,0)

def wheel(pos):
    # Input a value 0 to 255 to get a color value.
Exemplo n.º 2
0
pulse = 0  # Current pulse choice.
RAMPTIME = 7.5  # Ramp up and down time, in seconds
STEP = 64  # Number of steps to ramp up/down
delay = 15

# Built-in dotStar
bright = 3

brightNess = {  # Brightness on LEDs isn't linear, nor is the human eye.
    0: 0.017,
    1: 0.078,
    2: 0.36,
    3: 1.00
}

dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=1)

# Built-in red LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# Capacitive touch
changePulse = TouchIn(board.A0)
changeBrightness = TouchIn(board.A2)


def updateDelay():
    # Get the chip temperature
    temp = microcontroller.cpu.temperature
    # Convert to F
    temp = temp * 9.0 / 5.0 + 32.0
Exemplo n.º 3
0
from adafruit_bus_device.i2c_device import I2CDevice
import adafruit_dotstar

from digitalio import DigitalInOut, Direction, Pull

# Pull CS pin low to enable level shifter
cs = DigitalInOut(board.GP17)
cs.direction = Direction.OUTPUT
cs.value = 0

# Set up APA102 pixels
num_pixels = 16
pixels = adafruit_dotstar.DotStar(board.GP18,
                                  board.GP19,
                                  num_pixels,
                                  brightness=0.2,
                                  auto_write=True)

# Set up I2C for IO expander (addr: 0x20)
i2c = busio.I2C(board.GP5, board.GP4)
device = I2CDevice(i2c, 0x20)


# Define two modes for the keyboard
class ButtonMode:
    CONFIGURATION_CHOSER = 0
    MACRO_CHOSER = 1


# Function to map 0-255 to position on colour wheel
Exemplo n.º 4
0
import time
import random
import board
import adafruit_dotstar as dotstar

# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
#dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
dots = dotstar.DotStar(board.SCK, board.MOSI, 96, brightness=1)

dots.fill(0xFF3E96)
dots.show()
Exemplo n.º 5
0
import time
import board
from PIL import Image
import adafruit_dotstar as dotstar

NUMPIXELS = 30  # Number of LEDs in strip
FILENAME = "hello.png"  # Image file to load

# First two arguments in strip declaration identify the clock and data pins
# (here we're using the hardware SPI pins). Last argument identifies the
# color order -- older DotStar strips use GBR instead of BRG.
DOTS = dotstar.DotStar(
    board.SCK,
    board.MOSI,
    NUMPIXELS,
    brightness=0.25,
    auto_write=False,
    pixel_order=dotstar.BGR,
)

# 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 > NUMPIXELS:
    HEIGHT = NUMPIXELS
Exemplo n.º 6
0
import time
import random

import numpy
import board
import adafruit_dotstar as dotstar

import config
import midi


dots = dotstar.DotStar(board.SCK, board.MOSI, 185, brightness=0.5, auto_write=False)


def led_init():
    n_dots = len(dots)
    for dot in range(n_dots):
        dots[dot] = (0, 0, 0)

    time.sleep(.25)
    print(dots)


def calc_color(starting_color, target_color, ratio):
    return numpy.int_(starting_color + ratio * numpy.subtract(target_color, starting_color))


def color_output(key, preset):
    if key.velocity > 0:
        return calc_color(preset['note_off'], preset['note_on'], key.ratio(preset['attack']))
    if key.velocity == 0:
Exemplo n.º 7
0
# button access
import busio
from adafruit_bus_device.i2c_device import I2CDevice

# midi comms
import usb_midi
import adafruit_midi
from adafruit_midi.note_on import NoteOn
from adafruit_midi.note_off import NoteOff


# led setup
cs = DigitalInOut(board.GP17)
cs.direction = Direction.OUTPUT
cs.value = 0
pixels = adafruit_dotstar.DotStar(board.GP18, board.GP19, 16,
                                  brightness=0.5, auto_write=True)

# button setup
i2c = busio.I2C(board.GP5, board.GP4)
device = I2CDevice(i2c, 0x20)

# midi setup
midi = [adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=ch) for ch in range(16)]


# enums
class ButtonState:
    PRESSED = 1
    LONGPRESSED = 2
    RELEASED = 3
# Cedar Grove StringCar M0 Express v06 initial test
import board
import time
import pulseio
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
import adafruit_dotstar as dotstar
from simpleio import map_range, tone

# Red Status LED
led = DigitalInOut(board.LED_STATUS)
led.direction = Direction.OUTPUT
led.value = False

# The RGB LED
dot = dotstar.DotStar(board.DOTSTAR_CI, board.DOTSTAR_DI, 1, brightness=0.1)
dot[0] = (128, 0, 128)  # yellow startup status

import busio

try:
    stemma = busio.I2C(board.SCL, board.SDA)
    stemma_connected = True
    print("STEMMA DEVICE CONNECTED")
except:
    stemma_connected = False
    print("Stemma device disconnected")
    time.sleep(3)

# Analog input on VOLTAGE_MONITOR
v_plus = AnalogIn(board.VOLTAGE_MONITOR)
Exemplo n.º 9
0

#----------------LEDS init---------------------
NOCOLOR = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

# Using a DotStar Digital LED Strip with 72 LEDs connected to hardware SPI
# 5V - Yellow wire to gpio11 and green wire to gpio10
#dots = dotstar.DotStar(board.SCK, board.MOSI, 72, brightness=0.1)

# Using a DotStar Digital LED Strip with 72 LEDs connected to digital pins
# 5V - Yellow wire to gpio6 and green wire to gpio5
dots = dotstar.DotStar(board.D6, board.D5, 72, brightness=0.1)

red = "red"
green = "green"
blue = "blue"
allColors = "all"

chosenColor = blue

dots.fill(NOCOLOR)

numberOfDots = len(dots)

#---------- sound decoding -----------------
sound = AS.from_mp3("sounds/Hej_sprit.mp3")
Exemplo n.º 10
0
import RPi.GPIO as GPIO
GPIO.setwarnings(False)  # Ignore warning for now
GPIO.setmode(GPIO.BOARD)  # Use physical pin numbering
GPIO.setup(
    8, GPIO.IN, pull_up_down=GPIO.PUD_DOWN
)  # Set pin 10 to be an input pin and set initial value to be pulled low (off)/
import time
import adafruit_dotstar as dotstar

# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
strip = dotstar.DotStar(23, 19, 60, brightness=0.9)

# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
# dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)

# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)
numpix = 60
pos = 29  # position
direction = 6  # direction of "eye"

while True:  # Run forever
    if GPIO.input(8) == GPIO.HIGH:
        strip[pos - 2] = ([128, 0, 0])  # Dark red
        strip[pos - 1] = ([255, 0, 0])  # Medium red
        strip[pos] = ([255, 48, 0])  # brightest
        strip[pos + 1] = ([128, 0, 0])  # Medium red

    if (pos + 2) < numpix:
        # Dark red, do not exceed number of pixels
        strip[pos + 2] = ([255, 0, 0])
Exemplo n.º 11
0
    selected_sequence = args.sequence

    # Set Brightness
    if args.brightness:
        if float(args.brightness) > 0.0 and float(args.brightness) <= 1.0:
            brightness = args.brightness

    # Set time delay between frames
    if args.delay:
        if float(args.delay) > 0.0 and float(args.delay) <= 1.0:
            frame_delay = args.delay

# Using a DotStar Digital LED Strip with LEDs connected to hardware SPI
dots = dotstar.DotStar(board.SCK,
                       board.MOSI,
                       NUMBER_OF_LEDS,
                       brightness=brightness,
                       auto_write=False)

# Initialize sequence
Sequence = None
if selected_sequence == "acceleration":
    Sequence = Acceleration(NUMBER_OF_LEDS)
    Sequence.setup(6)
elif selected_sequence == "breathe":
    frame_delay = 1 / 30
    Sequence = Breathe(NUMBER_OF_LEDS)
    Sequence.setup(0.1, 0.5)
elif selected_sequence == "clock":
    frame_delay = 1 / 10
    Sequence = Clock(NUMBER_OF_LEDS)
# CircuitPython demo - Dotstar

import time
from rainbowio import colorwheel
import adafruit_dotstar
import board

numpix = 64
strip = adafruit_dotstar.DotStar(board.D2, board.D0, numpix, brightness=0.2)


def rainbow_cycle(wait):
    for j in range(255):
        for i in range(len(strip)):
            idx = int((i * 256 / len(strip)) + j)
            strip[i] = colorwheel(idx & 255)
        strip.show()
        time.sleep(wait)


while True:
    strip.fill((255, 0, 0))
    strip.show()
    time.sleep(1)

    strip.fill((0, 255, 0))
    strip.show()
    time.sleep(1)

    strip.fill((0, 0, 255))
    strip.show()
Exemplo n.º 13
0
from secrets import secrets
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError

i2c = busio.I2C(board.SCL, board.SDA)
#sensor = adafruit_si7021.SI7021(i2c)
sensor = adafruit_tmp117.TMP117(i2c)
#sensor = adafruit_bme680.Adafruit_BME680_I2C(i2c)
#sensor.sea_level_pressure = 1013.25 # for Bme680
aio_username = secrets["aio_username"]
aio_key = secrets["aio_key"]
aio_feed_name = secrets["aio_feed_name"]
ssid = secrets["ssid"]
ssid_pass = secrets["password"]
dotstar = adafruit_dotstar.DotStar(board.APA102_SCK,
                                   board.APA102_MOSI,
                                   1,
                                   brightness=0.5,
                                   auto_write=True)
color_index = 0

dotstar[0] = (0, 0, 255, 0.5)
for network in wifi.radio.start_scanning_networks():
    print(network, network.ssid, network.rssi, network.channel)
wifi.radio.stop_scanning_networks()
dotstar[0] = (0, 0, 0, 0.5)

print("try first connect")
dotstar[0] = (0, 255, 0, 0.5)
print(wifi.radio.connect(ssid, ssid_pass))
dotstar[0] = (0, 0, 0, 0.5)
print("wifi connected")
Exemplo n.º 14
0
# CircuitPython demo - Dotstar

import time
import board
import adafruit_dotstar

num_pixels = 30
pixels = adafruit_dotstar.DotStar(board.A1,
                                  board.A2,
                                  num_pixels,
                                  brightness=0.1,
                                  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:
        return (0, 0, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3)
    pos -= 170
    return (pos * 3, 0, 255 - pos * 3)


def color_fill(color, wait):
    pixels.fill(color)
    pixels.show()
Exemplo n.º 15
0
# SPDX-FileCopyrightText: 2020 Noe Ruiz for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import board
import neopixel
import adafruit_dotstar

LED = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI,
                               1)  #Setup Internal Dotar
LED.brightness = 0.8  #DotStar brightness

NUMPIX = 7  # Number of NeoPixels
PIXPIN = board.D2  # Pin where NeoPixels are connected
PIXELS = neopixel.NeoPixel(PIXPIN, NUMPIX)  # NeoPixel object setup

RED = 7  #Number of pixels to be red
BLUE = 0  #First pixel

while True:  # Loop forever...
    #Make the internal dotstar light up.
    LED[0] = (100, 0, 255)

    #Select these pixels starting with the second pixel.
    for i in range(1, RED):
        # Make the pixels red
        PIXELS[i] = (100, 0, 0)

    #Make the first neopixel this color
    PIXELS[BLUE] = (0, 0, 100)
"""
CircuitPython DotStar red, green, blue, brightness control example - multiple DotStars.

This example is meant for boards that have multiple built-in DotStar LEDs.

Update NUMBER_OF_PIXELS to the match the number of built-in DotStars on the board.

DO NOT INCLUDE THE pylint: disable LINE IN THE GUIDE CODE. It is present only to deal with the
NUMBER_OF_PIXELS variable being undefined in this pseudo-code. As you will be updating the variable
in the guide, you will not need the pylint: disable.

For example:
If you are using a FunHouse, change NUMBER_OF_PIXELS to 5.
"""
# pylint: disable=undefined-variable

import time
import board
import adafruit_dotstar

dots = adafruit_dotstar.DotStar(board.DOTSTAR_CLOCK, board.DOTSTAR_DATA, NUMBER_OF_PIXELS)
dots.brightness = 0.3

while True:
    dots.fill((255, 0, 0))
    time.sleep(0.5)
    dots.fill((0, 255, 0))
    time.sleep(0.5)
    dots.fill((0, 0, 255))
    time.sleep(0.5)
Exemplo n.º 17
0
import busio
from adafruit_mcp230xx.mcp23017 import MCP23017
from digitalio import Direction

i2c = busio.I2C(board.SCL, board.SDA)

mcp = MCP23017(i2c)

#led_pin = mcp.get_pin(0)
#led_pin.direction = Direction.OUTPUT

num_pixels = 1
pixels = adafruit_dotstar.DotStar(mcp.get_pin(0),
                                  mcp.get_pin(1),
                                  num_pixels,
                                  brightness=0.1,
                                  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:
        return (0, 0, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3)
    pos -= 170
Exemplo n.º 18
0
fan = digitalio.DigitalInOut(board.GP6)
fan.direction = digitalio.Direction.OUTPUT

fan.value = True
time.sleep(3)
fan.value = False

# DotStar
"""
GPIO #5 (29) GP10 - DotStar LED data pin.
GPIO #6 (31) GP11 - Dotstar LED clock pin.
"""

print("DOTSTAR")

dots = dotstar.DotStar(board.GP11, board.GP10, 3, brightness=0.2)

time.sleep(1)
dots[0] = (255, 0, 0)
time.sleep(1)
dots[1] = (0, 255, 0)
time.sleep(1)
dots[2] = (0, 0, 255)
time.sleep(1)
dots.fill((0, 0, 0))

# Buttons
"""
GPIO #17 (11) GP7  - Button
GPIO #16 (36) GP17 - Joystick select
GPIO #22 (15) GP9  - Joystick left
Exemplo n.º 19
0
        dots[dot] = NOCOLOR
        time.sleep(0.015)

    dots.fill(NOCOLOR)


#----------------LEDS init---------------------
NOCOLOR = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

# Using a DotStar Digital LED Strip with 72 LEDs connected to hardware SPI
# 5V - Yellow wire to gpio11 and green wire to gpio10 - 27 first -
dots = dotstar.DotStar(board.SCK, board.MOSI, 28, brightness=0.3)

# Using a DotStar Digital LED Strip with 72 LEDs connected to digital pins
# 5V - Yellow wire to gpio6 and green wire to gpio5
#dots = dotstar.DotStar(board.D6, board.D5, 72, brightness=0.1)

red = "red"
green = "green"
blue = "blue"
allColors = "all"

chosenColor = blue

dots.fill(NOCOLOR)

numberOfDots = len(dots)
Exemplo n.º 20
0
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
import audioio
import touchio
import pulseio
import neopixel
import adafruit_dotstar
from adafruit_motor import servo

gc.collect()   # make some rooooom
# HID keyboard support
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

# One pixel connected internally!
dot = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.5)

# Built in red LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# Analog audio output on A0, using two audio files
audiofiles = ["rimshot.wav", "laugh.wav"]

# Analog input on A1
analog1in = AnalogIn(board.A1)

# Capacitive touch on A2
touch = touchio.TouchIn(board.A2)

# Digital input with pullup on D7, D9, and D10
Exemplo n.º 21
0
def set_all_pixels_white():
    pixels = adafruit_dotstar.DotStar(board.SCLK,
                                      board.MOSI,
                                      60,
                                      brightness=0.3)
    pixels.fill((255, 255, 255))
Exemplo n.º 22
0
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
#
"""CircuitPython DotStar rainbow example for FunHouse"""
import time
import board
import adafruit_dotstar
from rainbowio import colorwheel

dots = adafruit_dotstar.DotStar(board.DOTSTAR_CLOCK,
                                board.DOTSTAR_DATA,
                                5,
                                auto_write=False)
dots.brightness = 0.3


def rainbow(delay):
    for color_value in range(255):
        for led in range(5):
            pixel_index = (led * 256 // 5) + color_value
            dots[led] = colorwheel(pixel_index & 255)
        dots.show()
        time.sleep(delay)


while True:
    rainbow(0.01)
Exemplo n.º 23
0
RAINBOW_PERIOD_S = 18.0 # How many seconds it takes for the default rainbow
                        # cycle animation to perform a full cycle.  Increase
                        # this to slow down the animation or decrease to speed
                        # it up.

HEARTBEAT_BPM = 60.0    # Heartbeat animation beats per minute.  Increase to
                        # speed up the heartbeat, and decrease to slow down.

HEARTBEAT_HUE = 300.0   # The color hue to use when animating the heartbeat
                        # animation.  Pick a value in the range of 0 to 359
                        # degrees, see the hue spectrum here:
                        #   https://en.wikipedia.org/wiki/Hue
                        # A value of 300 is a nice pink color.

# First initialize the DotStar LED and turn it off.
dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
dotstar[0] = (0,0,0)

# Also make sure the on-board red LED is turned off.
red_led = digitalio.DigitalInOut(board.L)
red_led.switch_to_output(value=False)

# Wait the startup delay period while flashing the red LED.  This gives time
# to move your hand away from the flower/stem so the capacitive touch sensing
# is initialized and calibrated with a good non-touch starting state.
start = time.monotonic()
while time.monotonic() - start <= START_DELAY:
    # Blink the red LED on and off every half second.
    red_led.value = True
    time.sleep(0.5)
    red_led.value = False
Exemplo n.º 24
0
import time
import random
import board
import adafruit_dotstar as dotstar

# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
# dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)

# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
dots = dotstar.DotStar(board.SCK, board.MOSI, 64, brightness=0.1)

# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)


# HELPERS
# a random color 0 -> 192
def random_color():
    return random.randrange(0, 7) * 32


# MAIN LOOP
n_dots = len(dots)
print(n_dots)
c = (random_color(), random_color(), random_color())
print(c)
# for i in range(25):
#     # Fill each dot with a random color
#     for dot in range(n_dots):
#         dots[dot] = (random_color(), random_color(), random_color())
#     #dots.fill(c)
Exemplo n.º 25
0
# ADC

adc_running = False
adc_delay = 1.0
adc_mode = "raw"

# DAC

dac_running = False
dac_level = 30000
dac_pin.value = 0

# LED

pixels = adafruit_dotstar.DotStar(board.APA102_SCK,
                                  board.APA102_MOSI,
                                  1,
                                  brightness=.95)
black = (0, 0, 0)
curColor = black
targetColor = black
led_mode = "off"
pixels.fill(black)
pixels.show()

# Timer

lastime = thistime = time.monotonic()

# this function takes a standard "hex code" for a color and returns
# a tuple of (red, green, blue)
Exemplo n.º 26
0
# fmt: on


def isPi():
    return sys.platform == 'BROADCOM'


if isPi():
    _KEY_CFG = raspi_pins()
    _LED_PINS = (board.SCK, board.MOSI)
else:
    _KEY_CFG = itsybitsy_pins()
    _LED_PINS = (board.SCK, board.MOSI)

led_strip = adafruit_dotstar.DotStar(_LED_PINS[0], _LED_PINS[1], 12)
rgb_ext = RGB(
    pixel_pin=0,
    pixels=led_strip,
    num_pixels=12,
    animation_mode=AnimationModes.BREATHING_RAINBOW,
)


class Keybow(KMKKeyboard):
    '''
    Default keyboard config for the Keybow.
    '''

    extensions = [rgb_ext]
Exemplo n.º 27
0
# Send morse code over serial

from digitalio import DigitalInOut, Direction
from touchio import TouchIn
import adafruit_dotstar as dotstar
import board
import time

# One pixel connected internally!
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
dot.brightness = 0

# Built in red LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# Capacitive touch
touch0 = TouchIn(board.A0)
touch1 = TouchIn(board.A1)
touch2 = TouchIn(board.A2)

# based on experimentation. anything less than 500 loops is a 'dit', anything more is a 'dah'
dash_length = 500

morse_code_dict = {
    '.-': 'a',
    '-...': 'b',
    '-.-.': 'c',
    '-..': 'd',
    '.': 'e',
    '..-.': 'f',
Exemplo n.º 28
0
# Cut down into a simple library by Owain Kenway

# Let's go read a few libraries. Catacorns want knowledge!
import board
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogOut, AnalogIn
import touchio
import adafruit_dotstar as dotstar
import time
import random
import pulseio

# Setup everything we use :D
number_stars = 2
eyes = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, number_stars, brightness=0.15)
eye_corners = pulseio.PWMOut(board.EYE_CORNERS, frequency=2000, duty_cycle=0)
paws = pulseio.PWMOut(board.PAWS, frequency=2000, duty_cycle=0)
tail_inner = pulseio.PWMOut(board.TAIL1, frequency=2000, duty_cycle=0)
tail_outer = pulseio.PWMOut(board.TAIL2, frequency=2000, duty_cycle=0)
touch_right_ear = touchio.TouchIn(board.EAR_R)
touch_left_ear = touchio.TouchIn(board.EAR_L)

def left_eye(colour):
	eyes[1] = colour

def right_eye(colour):
	eyes[0] = colour

dark_red = (10,0,0)
red = (255,0,0)
Exemplo n.º 29
0
import time
import random
import board
import adafruit_dotstar as dotstar

# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
dots = dotstar.DotStar(board.SCK, board.MOSI, 11, brightness=0.2)


# HELPERS
# a random color 0 -> 192
def random_color():
    return random.randrange(0, 7) * 32


# MAIN LOOP
n_dots = len(dots)

# Fill each dot with a random color
for dot in range(n_dots):

    dots[dot] = (0, 0, 0)
Exemplo n.º 30
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import random
import time
import board
import adafruit_dotstar as dotstar

# Using a DotStar Digital LED Matrix with 64 LEDs connected to digital pins
dots = dotstar.DotStar(board.D13, board.D12, 64, brightness=0.1)
# Using a Respeaker 2-Mics Pi Hat with its 3 APA102 LEDs connected to hardware SPI
# chest = dotstar.DotStar(board.SCK, board.MOSI, 3, brightness=0.2)


class LEDs(object):
    """Class used to set up
       face LED-matrix animations
    """


"""
def initialize_pi_hat_leds():
    # a random bright 0 -> 224
    def random_bright():
        return random.randrange(0, 7) * 32

    # MAIN LOOP
    num = 1
    n_chest = len(chest)
    while num < 10:    # seqquence length
        # Fill each dot with a random bright