Exemplo n.º 1
0
class Led(object):
    def __init__(self, serial_object):
        self._logger = logging.getLogger(__name__)
        self.pixels = NeoPixel(crickit.seesaw, 20, 12)

    def on(self, red, green, blue):
        self._logger.debug("Setting LED to (%d, %d, %d)", red, green, blue)
        self.pixels.fill((red, green, blue))

    def off(self):
        self._logger.debug("Turning LED off")
        self.pixels.fill((0, 0, 0))
Exemplo n.º 2
0
 def __init__(self,
              n,
              seesaw=crickit.seesaw,
              pin=20,
              bpp=3,
              brightness=1.0,
              auto_write=True,
              pixel_order=None):
     self.numPixels = n
     self.pixels = NeoPixel(
         seesaw, pin, n,
         auto_write=False)  #, bpp, brightness, auto_write, pixel_order)
     self.pixels.brightness = 0.5
Exemplo n.º 3
0
 def onboard_pixel(self):
     """```adafruit_seesaw.neopixel`` object on the Seesaw on-board NeoPixel.
     Initialize on-board NeoPixel and clear upon first use.
     """
     if not self._onboard_pixel:
         from adafruit_seesaw.neopixel import NeoPixel
         self._onboard_pixel = NeoPixel(self._seesaw,
                                        _SS_PIXEL,
                                        1,
                                        bpp=3,
                                        brightness=1.0,
                                        auto_write=True,
                                        pixel_order=None)
         self._onboard_pixel.fill((0, 0, 0))
     return self._onboard_pixel
Exemplo n.º 4
0
    def init_neopixel(self,
                      n,
                      *,
                      bpp=3,
                      brightness=1.0,
                      auto_write=True,
                      pixel_order=None):
        """Set up a seesaw.NeoPixel object

        .. note:: On the CPX Crickit board, the NeoPixel terminal is by default
          controlled by CPX pin A1, and is not controlled by seesaw. So this object
          will not be usable. Instead, use the regular NeoPixel library
          and specify ``board.A1`` as the pin.

        You can change the jumper connection on the bottom of the CPX Crickit board
        to move control of the NeoPixel terminal to seesaw pin #20 (terminal.NEOPIXEL).
        In addition, the Crickit FeatherWing always uses seesaw pin #20.
        In either of those cases, this object will work.

        .. code-block:: python

          from adafruit_crickit.crickit import crickit

          crickit.init_neopixel(24)
          crickit.neopixel.fill((100, 0, 0))
        """
        from adafruit_seesaw.neopixel import NeoPixel
        self._neopixel = NeoPixel(self._seesaw,
                                  _NEOPIXEL,
                                  n,
                                  bpp=bpp,
                                  brightness=brightness,
                                  auto_write=auto_write,
                                  pixel_order=pixel_order)
def init():
    global capture_home_directory
    capture_home_directory = "teachable_machine/"
    #NeoPixel
    num_pixels = 16 # 16 for old robot - change for the number your NeoPixel ring has
    pixels = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.4, pixel_order=(1, 0, 2, 3), bpp=4)
    neo_black = (0,0,0,0) #rgbw
    blink_color = (256,256,256,256) #rgbw
Exemplo n.º 6
0
 def __init__(self,
              i2c_bus,
              interrupt=False,
              addr=_NEO_TRELLIS_ADDR,
              drdy=None):
     super().__init__(i2c_bus, addr, drdy)
     self.interrupt_enabled = interrupt
     self.callbacks = [None] * _NEO_TRELLIS_NUM_KEYS
     self.pixels = NeoPixel(self, _NEO_TRELLIS_NEOPIX_PIN,
                            _NEO_TRELLIS_NUM_KEYS)
Exemplo n.º 7
0
class Lights():
    def __init__(self, num_pixels):
        self.pixels = NeoPixel(crickit.seesaw, 20, num_pixels)
        self.pixels.fill((0, 0, 0))
        self.num_pixels = num_pixels
        self.pixels.fill((0, 0, 0))

    def updateLEDs(self, newColor, delay):
        r = 0
        g = 0
        b = 0
        while (r < newColor[0] or g < newColor[1] or b < newColor[2]):
            if (r < newColor[0]):
                r += 1
            if (g < newColor[1]):
                g += 1
            if (b < newColor[2]):
                b += 1
        self.pixels.fill((r, g, b))
        time.sleep(delay)

    def fillEach(self, color, delay):
        for x in range(self.num_pixels):
            self.pixels[x] = color
            time.sleep(delay)
def start_capture(category, interval, num_pics):
    camera = picamera.PiCamera()
    capture_home_directory = "teachable_machine/"
    #NeoPixel
    num_pixels = 16 # 16 for old robot - change for the number your NeoPixel ring has
    pixels = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.4, pixel_order=(1, 0, 2, 3), bpp=4)
    neo_black = (0,0,0,0) #rgbw
    blink_color = (256,256,256,256) #rgbw

    cap_directory = capture_home_directory + category
    CHECK_FOLDER = os.path.isdir(cap_directory)

    # If folder doesn't exist, then create it.
    if not CHECK_FOLDER:
        os.makedirs(cap_directory)
        print("created folder : ", cap_directory)

    else:
        print(cap_directory, "folder already exists.")

    intro = "about to start capturing " + str(num_pics) + " images for " + category
    print(intro)
    tts_pico.speak(intro, "GB")
    for i in range(1,num_pics + 1, 1):
        image_name = cap_directory + "/" + category + "-" + str(i).zfill(2) + ".jpg"
        time.sleep(interval)
        pixels.fill(blink_color)
        tts_pico.speak(category + ", " + str(i) + "of " + str(num_pics) + ", in 3, 2, 1", "GB")
        # pixels.fill(neo_black)
        # time.sleep(0.2)

        print("image name: ", image_name)
        camera.capture(image_name)
        time.sleep(0.5)
        pixels.fill(neo_black)
    time.sleep(1)
    tts_pico.speak("all finished with " + category, "GB")
    camera.close()
Exemplo n.º 9
0
 def __init__(self, num_pixels):
     self.pixels = NeoPixel(crickit.seesaw, 20, num_pixels)
     self.pixels.fill((0, 0, 0))
     self.num_pixels = num_pixels
     self.pixels.fill((0, 0, 0))
Exemplo n.º 10
0
# make sure to install the required libraries by opening your Pi terminal and typing:
# sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel

# from https://learn.adafruit.com/adafruit-crickit-hat-for-raspberry-pi-linux-computers
# accessed 02022021

# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

num_pixels = 30  # Number of pixels driven from Crickit NeoPixel terminal

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)


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)

Exemplo n.º 11
0
class Crickit:
    """Represents a Crickit board. Provides a number of devices available via properties, such as
    ``servo_1``. Devices are created on demand the first time they are referenced.

    It's fine to refer a device multiple times via its property, but it's faster and results
    in more compact code to assign a device to a variable.

    .. code-block:: python

      import time
      from adafruit_crickit import crickit

      # This is fine:
      crickit.servo_1.angle = 0
      time.sleep(1)
      crickit.servo_1.angle = 90
      time.sleep(1)

      # This is slightly faster and more compact:
      servo_1 = crickit.servo_1
      servo_1.angle = 0
      time.sleep(1)
      servo_1.angle = 90
      time.sleep(1)
    """

    SIGNAL1 = 2
    """Signal 1 terminal"""
    SIGNAL2 = 3
    """Signal 2 terminal"""
    SIGNAL3 = 40
    """Signal 3 terminal"""
    SIGNAL4 = 41
    """Signal 4 terminal"""
    SIGNAL5 = 11
    """Signal 5 terminal"""
    SIGNAL6 = 10
    """Signal 6 terminal"""
    SIGNAL7 = 9
    """Signal 7 terminal"""
    SIGNAL8 = 8
    """Signal 8 terminal"""

    def __init__(self, seesaw):
        self._seesaw = seesaw
        self._seesaw.pin_mapping = Crickit_Pinmap
        # Associate terminal(s) with certain devices.
        # Used to find existing devices.
        self._devices = dict()
        self._neopixel = None
        self._onboard_pixel = None

    @property
    def seesaw(self):
        """The Seesaw object that talks to the Crickit. Use this object to manipulate the
        signal pins that correspond to Crickit terminals.

        .. code-block:: python

          from adafruit_crickit import crickit

          ss = crickit.seesaw
          ss.pin_mode(crickit.SIGNAL4, ss.OUTPUT)
          ss.digital_write(crickit.SIGNAL4], True)
        """

        return self._seesaw

    @property
    def servo_1(self):
        """``adafruit_motor.servo.Servo`` object on Servo 1 terminal"""
        return self._servo(_SERVO1, Servo)

    @property
    def servo_2(self):
        """``adafruit_motor.servo.Servo`` object on Servo 2 terminal"""
        return self._servo(_SERVO2, Servo)

    @property
    def servo_3(self):
        """``adafruit_motor.servo.Servo`` object on Servo 3 terminal"""
        return self._servo(_SERVO3, Servo)

    @property
    def servo_4(self):
        """``adafruit_motor.servo.Servo`` object on Servo 4 terminal"""
        return self._servo(_SERVO4, Servo)

    @property
    def continuous_servo_1(self):
        """``adafruit_motor.servo.ContinuousServo`` object on Servo 1 terminal"""
        return self._servo(_SERVO1, ContinuousServo)

    @property
    def continuous_servo_2(self):
        """``adafruit_motor.servo.ContinuousServo`` object on Servo 2 terminal"""
        return self._servo(_SERVO2, ContinuousServo)

    @property
    def continuous_servo_3(self):
        """``adafruit_motor.servo.ContinuousServo`` object on Servo 3 terminal"""
        return self._servo(_SERVO3, ContinuousServo)

    @property
    def continuous_servo_4(self):
        """``adafruit_motor.servo.ContinuousServo`` object on Servo 4 terminal"""
        return self._servo(_SERVO4, ContinuousServo)

    def _servo(self, terminal, servo_class):
        device = self._devices.get(terminal, None)
        if not isinstance(device, servo_class):
            pwm = PWMOut(self._seesaw, terminal)
            pwm.frequency = 50
            device = servo_class(pwm)
            self._devices[terminal] = device
        return device

    @property
    def dc_motor_1(self):
        """``adafruit_motor.motor.DCMotor`` object on Motor 1 terminals"""
        return self._motor(_MOTOR1, DCMotor)

    @property
    def dc_motor_2(self):
        """``adafruit_motor.motor.DCMotor`` object on Motor 2 terminals"""
        return self._motor(_MOTOR2, DCMotor)

    @property
    def stepper_motor(self):
        """``adafruit_motor.motor.StepperMotor`` object on Motor 1 and Motor 2 terminals"""
        return self._motor(_MOTOR_STEPPER, StepperMotor)

    @property
    def drive_stepper_motor(self):
        """``adafruit_motor.motor.StepperMotor`` object on Drive terminals"""
        return self._motor(_DRIVE_STEPPER, StepperMotor)

    @property
    def feather_drive_stepper_motor(self):
        """``adafruit_motor.motor.StepperMotor`` object on Drive terminals on Crickit FeatherWing"""
        return self._motor(tuple(reversed(_DRIVE_STEPPER)), StepperMotor)

    def _motor(self, terminals, motor_class):
        device = self._devices.get(terminals, None)
        if not isinstance(device, motor_class):
            device = motor_class(
                *(PWMOut(self._seesaw, terminal) for terminal in terminals)
            )
            self._devices[terminals] = device
        return device

    @property
    def drive_1(self):
        """``adafruit_seesaw.pwmout.PWMOut`` object on Drive 1 terminal, with ``frequency=1000``"""
        return self._drive(_DRIVE1)

    @property
    def drive_2(self):
        """``adafruit_seesaw.pwmout.PWMOut`` object on Drive 2 terminal, with ``frequency=1000``"""
        return self._drive(_DRIVE2)

    @property
    def drive_3(self):
        """``adafruit_seesaw.pwmout.PWMOut`` object on Drive 3 terminal, with ``frequency=1000``"""
        return self._drive(_DRIVE3)

    @property
    def drive_4(self):
        """``adafruit_seesaw.pwmout.PWMOut`` object on Drive 4 terminal, with ``frequency=1000``"""
        return self._drive(_DRIVE4)

    feather_drive_1 = drive_4
    """``adafruit_seesaw.pwmout.PWMOut`` object on Crickit Featherwing Drive 1 terminal,
    with ``frequency=1000``
    """
    feather_drive_2 = drive_3
    """``adafruit_seesaw.pwmout.PWMOut`` object on Crickit Featherwing Drive 2 terminal,
    with ``frequency=1000``
    """
    feather_drive_3 = drive_2
    """``adafruit_seesaw.pwmout.PWMOut`` object on Crickit Featherwing Drive 3 terminal,
    with ``frequency=1000``
    """
    feather_drive_4 = drive_1
    """``adafruit_seesaw.pwmout.PWMOut`` object on Crickit Featherwing Drive 4 terminal,
    with ``frequency=1000``
    """

    def _drive(self, terminal):
        device = self._devices.get(terminal, None)
        if not isinstance(device, PWMOut):
            device = PWMOut(self._seesaw, terminal)
            device.frequency = 1000
            self._devices[terminal] = device
        return device

    @property
    def touch_1(self):
        """``adafruit_crickit.CrickitTouchIn`` object on Touch 1 terminal"""
        return self._touch(_TOUCH1)

    @property
    def touch_2(self):
        """``adafruit_crickit.CrickitTouchIn`` object on Touch 2 terminal"""
        return self._touch(_TOUCH2)

    @property
    def touch_3(self):
        """``adafruit_crickit.CrickitTouchIn`` object on Touch 3 terminal"""
        return self._touch(_TOUCH3)

    @property
    def touch_4(self):
        """``adafruit_crickit.CrickitTouchIn`` object on Touch 4 terminal"""
        return self._touch(_TOUCH4)

    def _touch(self, terminal):
        touch_in = self._devices.get(terminal, None)
        if not touch_in:
            touch_in = CrickitTouchIn(self._seesaw, terminal)
            self._devices[terminal] = touch_in
        return touch_in

    @property
    def neopixel(self):
        """```adafruit_seesaw.neopixel`` object on NeoPixel terminal.
        Raises ValueError if ``init_neopixel`` has not been called.
        """
        if not self._neopixel:
            raise ValueError("Call init_neopixel first")
        return self._neopixel

    def init_neopixel(
        self, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None
    ):
        """Set up a seesaw.NeoPixel object

        .. note:: On the CPX Crickit board, the NeoPixel terminal is by default
          controlled by CPX pin A1, and is not controlled by seesaw. So this object
          will not be usable. Instead, use the regular NeoPixel library
          and specify ``board.A1`` as the pin.

        You can change the jumper connection on the bottom of the CPX Crickit board
        to move control of the NeoPixel terminal to seesaw pin #20 (terminal.NEOPIXEL).
        In addition, the Crickit FeatherWing always uses seesaw pin #20.
        In either of those cases, this object will work.

        .. code-block:: python

          from adafruit_crickit.crickit import crickit

          crickit.init_neopixel(24)
          crickit.neopixel.fill((100, 0, 0))
        """
        from adafruit_seesaw.neopixel import (  # pylint: disable=import-outside-toplevel
            NeoPixel,
        )

        self._neopixel = NeoPixel(
            self._seesaw,
            _NEOPIXEL,
            n,
            bpp=bpp,
            brightness=brightness,
            auto_write=auto_write,
            pixel_order=pixel_order,
        )

    @property
    def onboard_pixel(self):
        """```adafruit_seesaw.neopixel`` object on the Seesaw on-board NeoPixel.
        Initialize on-board NeoPixel and clear upon first use.
        """
        if not self._onboard_pixel:
            from adafruit_seesaw.neopixel import (  # pylint: disable=import-outside-toplevel
                NeoPixel,
            )

            self._onboard_pixel = NeoPixel(
                self._seesaw,
                _SS_PIXEL,
                1,
                bpp=3,
                brightness=1.0,
                auto_write=True,
                pixel_order=None,
            )
            self._onboard_pixel.fill((0, 0, 0))
        return self._onboard_pixel

    def reset(self):
        """Reset the whole Crickit board."""
        self._seesaw.sw_reset()
Exemplo n.º 12
0
motor_2.throttle = 0.0

#NeoPixel
num_pixels = 16 # 16 for old robot - change for the number your NeoPixel ring has
# for blinking
blink = False
blink_state = False
# blink_color = (127,0,0) #rgb
blink_color = (127,0,0,0) #rgbw
# neo_black = (0,0,0) #rgb
neo_black = (0,0,0,0) #rgbw
blink_delay = 0.1
blink_times = 2
blink_next_time = time.time() + blink_delay
# bpp=4 is required for RGBW NeoPixels
pixels = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.02, pixel_order=(1, 0, 2, 3), bpp=4)
# bpp=3 is required for RGB NeoPixels
# pixels = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.04, pixel_order=neopixel.RGB, bpp=3)

# black out the LEDs on start
pixels.fill(neo_black)
# there was a bug in the neopixel lib that ignores zeros in rgbw
# https://github.com/adafruit/Adafruit_CircuitPython_seesaw/issues/32

# DEFINE sensors
# For signal control, we'll chat directly with seesaw, use 'ss' to shorted typing!
ss = crickit.seesaw

# analogin = False
analog_interval = .5
analog_next_time = time.time() + analog_interval
Exemplo n.º 13
0
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel
 
num_pixels = 8  #TODO changed based on our pixels 
 
# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels) #TODO check which pin 

ss = crickit.seesaw

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, 255, 255)
OFF = (0,0,0)

def Eve_waiting():
    pixels.fill(WHITE)
    
def Eve_recieved(): 
    pixels.fill(GREEN) #maybe some green some white
    
def Eve_guarding(): 
    pixels.fill(RED)
    
def Eve_planting():
    pixels.fill(BLUE)
Exemplo n.º 14
0
# Help from https://learn.adafruit.com/adafruit-crickit-hat-for-raspberry-pi-linux-computers

import time
from adafruit_crickit import crickit
#import neopixel
from adafruit_seesaw.neopixel import NeoPixel

num_pixels = 16  # Number of pixels driven from Crickit NeoPixel terminal
#ORDER = neopixel.GRBW

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw,
                  20,
                  num_pixels,
                  bpp=4,
                  pixel_order=(0, 1, 2, 3))


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, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3, 0)
    pos -= 170
    return (pos * 3, 0, 255 - pos * 3, 0)
Exemplo n.º 15
0
class MyNeoPixels:
    def __init__(self,
                 n,
                 seesaw=crickit.seesaw,
                 pin=20,
                 bpp=3,
                 brightness=1.0,
                 auto_write=True,
                 pixel_order=None):
        self.numPixels = n
        self.pixels = NeoPixel(
            seesaw, pin, n,
            auto_write=False)  #, bpp, brightness, auto_write, pixel_order)
        self.pixels.brightness = 0.5

    def setPixelColor(self, idx, color):
        self.pixels[idx] = color

    def show(self):
        self.pixels.show()
        return

    def fill(self, color):
        self.pixels.fill(color)

    # Define functions which animate LEDs in various ways.
    def colorWipe(self, color, wait_ms=50):
        """Wipe color across display a pixel at a time."""
        for i in range(self.numPixels):
            self.setPixelColor(i, color)
            self.show()
            time.sleep(wait_ms / 1000.0)

    def theaterChase(self, color, wait_ms=50, iterations=10):
        """Movie theater light style chaser animation."""
        for j in range(iterations):
            for q in range(3):
                for i in range(0, self.numPixels, 3):
                    self.setPixelColor(i + q, color)
                self.show()
                time.sleep(wait_ms / 1000.0)
                for i in range(0, self.numPixels, 3):
                    self.setPixelColor(i + q, 0)

    def rainbow(self, wait_ms=20, iterations=1):
        """Draw rainbow that fades across all pixels at once."""
        for j in range(256 * iterations):
            for i in range(self.numPixels):
                self.setPixelColor(i, wheel((i + j) & 255))
            self.show()
            time.sleep(wait_ms / 1000.0)

    def rainbowCycle(self, wait_ms=20, iterations=5):
        """Draw rainbow that uniformly distributes itself across all pixels."""
        for j in range(256 * iterations):
            for i in range(self.numPixels):
                self.setPixelColor(
                    i, wheel((int(i * 256 / self.numPixels) + j) & 255))
            self.show()
            time.sleep(wait_ms / 1000.0)

    def theaterChaseRainbow(self, wait_ms=50):
        """Rainbow movie theater light style chaser animation."""
        for j in range(256):
            for q in range(3):
                for i in range(0, self.numPixels, 3):
                    self.setPixelColor(i + q, wheel((i + j) % 255))
                self.show()
                time.sleep(wait_ms / 1000.0)
                for i in range(0, self.numPixels, 3):
                    self.setPixelColor(i + q, 0)

    def set_neopixels(self, color, count):
        if count > self.numPixels:
            count = self.numPixels
        logging.info("setting %d pixesl to %s" % (count, color))
        for i in range(0, self.numPixels):
            if i < count:
                self.setPixelColor(i, color)
            else:
                self.setPixelColor(i, colors['off'])
        self.show()

    # health will be a setting of 10 pixels, and the number will be out of 100
    def health(self, color, health, tip='off', wait_ms=50):
        self.set_neopixels(color, health)
        time.sleep(0.002)
        self.setPixelColor(self.numPixels - 1, colors[tip])
        self.show()

    ##############
    operations = {
        # custom = has A, B, C, D
        #'magic_item': magic_item,
        # needs colour and count
        'set': set_neopixels,
        'health': health,
        #needs colour
        'colourwipe': colorWipe,
        'theatrechase': theaterChase,
        #no colour option
        'rainbow': rainbow,
        'rainbow_cycle': rainbowCycle,
    }

    ###############
    def play(self, payload={}):
        operationname = get(payload, 'operation', 'colourwipe')
        operation = get(MyNeoPixels.operations, operationname,
                        MyNeoPixels.operations['colourwipe'])
        logging.info("playing %s" % operationname)

        if operationname == 'magic_item':
            operation(self, payload)
            return

        if operationname == 'rainbow' or operationname == 'rainbow_cycle':
            operation(self)
            return

        colourname = get(payload, 'colour', 'off')
        colour = get(colors, colourname, colors['off'])
        # TODO: maybe change to using HTML colors #000000 style?
        if operationname == 'colourwipe' or operationname == 'theatrechase':
            operation(self, colour)
            return

        count = get(payload, 'count', 10)
        operation(self, colour, count)
Exemplo n.º 16
0
motor_1.throttle = 0.0
motor_2.throttle = 0.0

#NeoPixel
num_pixels = 16
# for blinking
blink = False
blink_state = False
blink_color = (127, 0, 0, 0)
blink_delay = 0.1
blink_times = 2
blink_next_time = time.time() + blink_delay
# bpp=4 is required for RGBW
pixels = NeoPixel(crickit.seesaw,
                  20,
                  num_pixels,
                  brightness=0.02,
                  pixel_order=neopixel.RGBW,
                  bpp=4)
# black out the LEDs
pixels.fill(
    (1, 2, 3,
     0))  # there's a bug in the neopixel lib that ignores zeros in rgbw
# https://github.com/adafruit/Adafruit_CircuitPython_seesaw/issues/32
# DEFINE sensors
# For signal control, we'll chat directly with seesaw, use 'ss' to shorted typing!
ss = crickit.seesaw

# analogin = False
analog_interval = .5
analog_next_time = time.time() + analog_interval
# ports to be scanned each interval
Exemplo n.º 17
0
# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

pot = crickit.SIGNAL2
ss = crickit.seesaw

num_pixels = 24  # Number of pixels driven from Crickit NeoPixel terminal

ss.pin_mode(pot, ss.INPUT)

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)


def pot_color(wait):
    potValue = ss.analog_read(pot)
    potColorValue = round(translate(potValue, 0, 1023, 0, 255))
    print((potColorValue))
    pixels.fill((0, potColorValue, 0))
    #     pixels.fill((potColorValue, 155, abs(255-potColorValue)))
    pixels.show()
    time.sleep(wait)


# 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)
Exemplo n.º 18
0
# SPDX-FileCopyrightText: 2018 Anne Barela for Adafruit Industries
#
# SPDX-License-Identifier: MIT

# Using Crickit's onboard NeoPixel
# See http://www.color-hex.com/ for more colors and find your fav!
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

crickit_status_pixel = NeoPixel(crickit.seesaw, 27, 1)  # one NeoPixel pin 27

# Fill them with our favorite color "#0099FF light blue" -> 0x0099FF
crickit_status_pixel.fill(0x0099FF)

while True:
    pass
Exemplo n.º 19
0
 def __init__(self, serial_object):
     self._logger = logging.getLogger(__name__)
     self.pixels = NeoPixel(crickit.seesaw, 20, 12)
Exemplo n.º 20
0
# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

pot = crickit.SIGNAL2
ss = crickit.seesaw

num_pixels = 24  # Number of pixels driven from Crickit NeoPixel terminal

ss.pin_mode(pot, ss.INPUT)

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)


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 pot_chase(wait):
Exemplo n.º 21
0
from PIL import Image, ImageDraw, ImageOps, ImageEnhance
import numpy
from picamera import PiCamera
from time import sleep
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

num_pixels = 16

pixels = NeoPixel(crickit.seesaw,
                  20,
                  num_pixels,
                  bpp=4,
                  auto_write=True,
                  pixel_order=(0, 1, 2, 3))

polyfile = open("corner_coords.txt", "r")
polynumlist = polyfile.readlines()

polyNums = []
polyX = []
polyY = []

#polygon = ((0,0),(0,0),(0,0),(0,0),(0,0),(0,0))

for line in polynumlist:
    polyNums += line.strip().split(" ")  # get a list containing

for num in range(6 * 2):

    if (num % 2) == 0:
Exemplo n.º 22
0
from six.moves import queue

from gtts import gTTS
import os
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel
import datetime
r = 0
g = 0
b = 150
pulse_dir = 10
num_pixels = 74  # Number of pixels driven from Crickit NeoPixel terminal

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)
pixels.fill(0)
# Audio recording parameters, set for our USB mic.
RATE = 48000  #if you change mics - be sure to change this :)
CHUNK = int(RATE / 10)  # 100ms

credential_path = "/home/pi/DET-2019.json"  #replace with your file name!
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credential_path

client = speech.SpeechClient()

pygame.init()
pygame.mixer.init()

user_report = " "
#Some boolean values to control state
Exemplo n.º 23
0
#!/usr/bin/python3

# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
import logging
import time
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel

num_pixels = 64  # Number of pixels driven from Crickit NeoPixel terminal

#pixels = NeoPixel(crickit.seesaw, 20, 50)
#BLACK = (0, 0, 0)
#pixels.fill(BLACK)
# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixels = NeoPixel(crickit.seesaw, 20, num_pixels)
BLACK = (0, 0, 0)
pixels.fill(BLACK)
time.sleep(0.2)


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.º 24
0
from adafruit_seesaw.neopixel import NeoPixel

# setup pixel color order
if ring_colors == "GRB":
    ORDER = neopixel.GRB
elif ring_colors == "RGBW":
    ORDER = neopixel.RGBW
elif ring_colors == "GRBW":
    ORDER = neopixel.GRBW
else:
    ORDER = neopixel.RGB

# initialize the pixel ring
pixels = NeoPixel(crickit.seesaw,
                  20,
                  ring_pixels,
                  bpp=len(ring_colors),
                  brightness=pixel_brightness,
                  pixel_order=ORDER)

# bird functions
bird = crickit.dc_motor_1
beak = crickit.drive_1
beak.frequency = 1000


# push the bird out
def birdOut():
    bird.throttle = 1
    time.sleep(0.35)
    bird.throttle = 0
Exemplo n.º 25
0
# Drive NeoPixels on the NeoPixels Block on Crickit FeatherWing
import time
import busio
import board
from adafruit_crickit import crickit
from adafruit_seesaw.neopixel import NeoPixel
import adafruit_amg88xx

# Line necessary to not get the PA23 pin in use error
amg = adafruit_amg88xx.AMG88XX(crickit.seesaw.i2c_device.i2c)

num_pixels = 64  # Number of pixels driven from Crickit NeoPixel terminal

# The following line sets up a NeoPixel strip on Seesaw pin 20 for Feather
pixelss = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.05)

RED = (255, 0, 0)
YELLOW = (255, 255, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
ORANGE = (255, 125, 0)

#for i in range(1, 3):
pixelss.fill(PURPLE)
pixelss.show()
#print(i)
#time.sleep(1)

a = 0
Exemplo n.º 26
0
#NeoPixel
num_pixels = 16  # 16 for old robot - change for the number your NeoPixel ring has
# for blinking
blink = False
blink_state = False
# blink_color = (127,0,0) #rgb
blink_color = (127, 0, 0, 0)  #rgbw
# neo_black = (0,0,0) #rgb
neo_black = (0, 0, 0, 0)  #rgbw
blink_delay = 0.1
blink_times = 2
blink_next_time = time.time() + blink_delay
# bpp=4 is required for RGBW NeoPixels
pixels = NeoPixel(crickit.seesaw,
                  20,
                  num_pixels,
                  brightness=0.02,
                  pixel_order=neopixel.RGBW,
                  bpp=4)
# bpp=3 is required for RGB NeoPixels
# pixels = NeoPixel(crickit.seesaw, 20, num_pixels, brightness=0.04, pixel_order=neopixel.RGB, bpp=3)

# black out the LEDs on start
pixels.fill(neo_black)
# there was a bug in the neopixel lib that ignores zeros in rgbw
# https://github.com/adafruit/Adafruit_CircuitPython_seesaw/issues/32

# DEFINE sensors
# For signal control, we'll chat directly with seesaw, use 'ss' to shorted typing!
ss = crickit.seesaw

# analogin = False