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
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)
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 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
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()
#!/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
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:
# 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
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
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)
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
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 __init__(self, serial_object): self._logger = logging.getLogger(__name__) self.pixels = NeoPixel(crickit.seesaw, 20, 12)
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
# 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
# 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)