def cycle(): strips = [ Adafruit_DotStar(numpixels, datapin[0], clockpin[0]), Adafruit_DotStar(numpixels, datapin[1], clockpin[0]), Adafruit_DotStar(numpixels, datapin[2], clockpin[0]) ] for strip in strips: strip.begin() color = 0x00FF00 pos = (-1) * len(data[0]) while True: for i, strip in enumerate(strips): strip.clear() for pixel in range(0, numpixels): for j, pixel in enumerate(data[i]): if pixel == 1: strip.setPixelColor(pos + j, color) strip.show() pos = pos + 1 if pos == numpixels: pos = (-1) * len(data[0]) time.sleep(0.10)
def strand_test(): """ Basically the same as the Adafruit stand test """ test_strip = Adafruit_DotStar(ALL_LIGHTS, 12000000, order='bgr') test_strip.begin() test_strip.show() head = 0 # Index of first 'on' pixel tail = -10 # Index of last 'off' pixel color = 0xFF0000 # 'On' color (starts red) counter = ALL_LIGHTS * 3 + 10 while counter > 0: # Loop forever test_strip.setPixelColor(head, color) # Turn on 'head' pixel test_strip.setPixelColor(tail, 0) # Turn off 'tail' test_strip.show() # Refresh strip time.sleep(1.0 / 100) # Pause 20 milliseconds (~50 fps) head += 1 # Advance head position if head >= ALL_LIGHTS: # Off end of strip? head = 0 # Reset to start color >>= 8 # Red->green->blue->black if color == 0: color = 0xFF0000 # If black, reset to red tail += 1 # Advance tail position if tail >= ALL_LIGHTS: tail = 0 # Off end? Reset counter -= 1
def __init__(self): self.running = False # set the oled screen height self.screen_width = SCREEN_WIDTH self.screen_height = SCREEN_HEIGHT self.btn1Pin = LEFT_BTN_PIN self.btn2Pin = RIGHT_BTN_PIN # configure interrups for buttons GPIO.setup(self.btn1Pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(self.btn2Pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # configure screen spi_bus = 0 spi_device = 0 # Very important... This lets py-gaugette 'know' what pins to use in order to reset the display self.led = disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000)) # Change rows & cols values depending on your display dimensions. # Initialize library. self.led.begin() # Clear display. self.led.clear() self.led.display() # Create image buffer. # Make sure to create image with mode '1' for 1-bit color. self.image = Image.new('1', (self.screen_width, self.screen_height)) # Load default font. self.font = ImageFont.load_default() # Create drawing object. self.draw = ImageDraw.Draw(self.image) # load the pump configuration from file self.pump_configuration = Bartender.readPumpConfiguration() for pump in self.pump_configuration.keys(): GPIO.setup(self.pump_configuration[pump]["pin"], GPIO.OUT, initial=GPIO.HIGH) # setup pixels: self.numpixels = NUMBER_NEOPIXELS # Number of LEDs in strip # Here's how to control the strip from any two GPIO pins: datapin = NEOPIXEL_DATA_PIN clockpin = NEOPIXEL_CLOCK_PIN self.strip = Adafruit_DotStar(self.numpixels, datapin, clockpin) self.strip.begin() # Initialize pins for output self.strip.setBrightness(NEOPIXEL_BRIGHTNESS) # Limit brightness to ~1/4 duty cycle # turn everything off for i in range(0, self.numpixels): self.strip.setPixelColor(i, 0) self.strip.show() print "Done initializing"
def __init__(self): self.strip = Adafruit_DotStar(NUM_LEDS, 10, 11) self.strip.begin() self.stream = None self.time = 0
def main(render_sdl): if render_sdl: from sdl.driver import sdl_init from sdl.driver import sdl_draw window, renderer, pixels = sdl_init() else: from dotstar import Adafruit_DotStar strip = Adafruit_DotStar() strip.begin() t0 = time.time() i = 0 while True: t = time.time() - t0 i += 1 try: importlib.reload(face) f = face.Face() f.render(t=t, i=i) except (ModuleNotFoundError): continue if render_sdl: print('rendering sdl') sdl_draw(pixels, window, f.grid) else: arr = face.to_arr() render_dotstar(strip, arr)
def lightshow(): numpixels = 72 # Number of LEDs in strip # Here's how to control the strip from any two GPIO pins: datapin = 23 clockpin = 24 strip = Adafruit_DotStar(numpixels, datapin, clockpin) strip.begin() # Initialize pins for output strip.setBrightness(128) # Limit brightness to ~1/4 duty cycle #First, turn all black offspot = 1 offcolor = 0x000000 while offspot >= 1: strip.setPixelColor(offspot, offcolor) offspot += 1 if offspot == 72: break #set initial spots and colors of Jupiter and moons jupspot = 36 #jupiter position jupcolor = 0xFF8801 #jupiter color iospot = iopos #Io position iocolor = 0x9932cc #Io color eurspot = eurpos #Europa position eurcolor = 0x9932cc #Europa color ganspot = ganpos #Ganymede position gancolor = 0x9932cc #Ganymede color calspot = calpos #Calisto position calcolor = 0x9932cc #Calisto color lastcolor = 0x000000 lastiospot = (iospot - 1) gang = [iospot, eurspot, ganspot, calspot] #list of the four moon positions while True: # Loop forever strip.setBrightness(128) # Limit brightness strip.setPixelColor(jupspot, jupcolor) # Turn on jupiter to orange strip.setPixelColor(gang, 0) #Turn off last plots gang[:] = [x + 1 for x in a] # +=1 for each member of gang strip.setPixelColor(gang, iocolor) # Turn all moons to blue strip.show() # Refresh strip time.sleep(1.0 / 5) if t == now: strip.setBrightness(128) #max brightness time.sleep(3) if (iospot >= numpixels): iospot = 0 if (lastiospot >= numpixels): lastiospot = 0
def __init__(self): datapin = 10 clockpin = 11 if is_running_on_pi: self.strip = Adafruit_DotStar(0, datapin, clockpin, 18500000) else: self.strip = None
def __init__(self, host): self.host = host self.strip = Adafruit_DotStar(numpixels, datapin, clockpin) self.strip.begin() self.strip.setBrightness(32) green = self.to_rgb(0,255,0) self.show_all(green)
def strandtest(): #!/usr/bin/python # Simple strand test for Adafruit Dot Star RGB LED strip. # This is a basic diagnostic tool, NOT a graphics demo...helps confirm # correct wiring and tests each pixel's ability to display red, green # and blue and to forward data down the line. By limiting the number # and color of LEDs, it's reasonably safe to power a couple meters off # USB. DON'T try that with other code! import time from dotstar import Adafruit_DotStar numpixels = 72 # Number of LEDs in strip # Here's how to control the strip from any two GPIO pins: datapin = 23 clockpin = 24 strip = Adafruit_DotStar(numpixels, datapin, clockpin) # Alternate ways of declaring strip: # Adafruit_DotStar(npix, dat, clk, 1000000) # Bitbang @ ~1 MHz # Adafruit_DotStar(npix) # Use SPI (pins 10=MOSI, 11=SCLK) # Adafruit_DotStar(npix, 32000000) # SPI @ ~32 MHz # Adafruit_DotStar() # SPI, No pixel buffer # Adafruit_DotStar(32000000) # 32 MHz SPI, no pixel buf # See image-pov.py for explanation of no-pixel-buffer use. # Append "order='gbr'" to declaration for proper colors w/older DotStar strips) strip.begin() # Initialize pins for output strip.setBrightness(64) # Limit brightness to ~1/4 duty cycle # Runs 10 LEDs at a time along strip, cycling through red, green and blue. # This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel. head = 0 # Index of first 'on' pixel tail = -10 # Index of last 'off' pixel color = 0xFF0000 # 'On' color (starts red) stranditer = 4 strandnum = 0 while strandnum <= stranditer: # Loop forever strip.setPixelColor(head, color) # Turn on 'head' pixel strip.setPixelColor(tail, 0) # Turn off 'tail' strip.show() # Refresh strip time.sleep(1.0 / 50) # Pause 20 milliseconds (~50 fps) head += 1 # Advance head position if(head >= numpixels): # Off end of strip? head = 0 # Reset to start color >>= 8 # Red->green->blue->black if(color == 0): color = 0xFF0000 # If black, reset to red tail += 1 # Advance tail position if(tail >= numpixels): tail = 0 # Off end? Reset strandnum += 1
def init_arena(): "Create the strip and buffer objects" global strip, arena, changed_panels global spi_clock, height, pwidth, width, npanels strip = Adafruit_DotStar(height*pwidth, spi_clock) strip.begin() #TODO For maximum speed, use a byte array of RGB values instead # (see `image-pov.py` in the Adafruit library for example code) arena = ["black"] * height * width changed_panels = [False] * npanels
def __init__(self, datapin, clockpin, brightness): self.datapin = datapin self.clockpin = clockpin self.strip = Adafruit_DotStar(self.numpixels, self.datapin, self.clockpin, order='bgr') self.strip.begin() self.set_brightness(brightness) self.color = self.random_color()
def open(self, num_pixels, order='rgb'): """ Open the device :param num_pixels: Total number of pixels on the strip/string. :param order: The order of colors as expected by the strip/string. :return: """ self._strip = Adafruit_DotStar(num_pixels, order=order.encode('utf-8')) # print self._strip self._numpixels = num_pixels return self._begin()
def __init__(self): self.npixels = self.calc_npixels(self.sections_spec) self.strip = Adafruit_DotStar(self.npixels, self.datapin, self.clockpin) self.buffer = bytearray(self.npixels * 4) for i in range(0, self.npixels): self.buffer[i * 4] = 0xff self.sections = {} for spec in self.sections_spec: self.add_section(**spec) self.strip.begin()
def __init__(self): self.running = False # set the oled screen height self.screen_width = SCREEN_WIDTH self.screen_height = SCREEN_HEIGHT self.btn1Pin = LEFT_BTN_PIN self.btn2Pin = RIGHT_BTN_PIN # configure interrups for buttons GPIO.setup(self.btn1Pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(self.btn2Pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # configure screen spi_bus = 0 spi_device = 0 gpio = gaugette.gpio.GPIO() spi = gaugette.spi.SPI(spi_bus, spi_device) # Very important... This lets py-gaugette 'know' what pins to use in order to reset the display self.led = gaugette.ssd1306.SSD1306(gpio, spi, reset_pin=OLED_RESET_PIN, dc_pin=OLED_DC_PIN, rows=self.screen_height, cols=self.screen_width) # Change rows & cols values depending on your display dimensions. self.led.begin() self.led.clear_display() self.led.display() self.led.invert_display() time.sleep(0.5) self.led.normal_display() time.sleep(0.5) # load the pump configuration from file self.pump_configuration = Bartender.readPumpConfiguration() for pump in self.pump_configuration.keys(): GPIO.setup(self.pump_configuration[pump]["pin"], GPIO.OUT, initial=GPIO.HIGH) # setup pixels: self.numpixels = NUMBER_NEOPIXELS # Number of LEDs in strip # Here's how to control the strip from any two GPIO pins: datapin = NEOPIXEL_DATA_PIN clockpin = NEOPIXEL_CLOCK_PIN self.strip = Adafruit_DotStar(self.numpixels, datapin, clockpin) self.strip.begin() # Initialize pins for output self.strip.setBrightness(NEOPIXEL_BRIGHTNESS) # Limit brightness to ~1/4 duty cycle # turn everything off for i in range(0, self.numpixels): self.strip.setPixelColor(i, 0) self.strip.show() print "Done initializing"
def __init__(self): datapin = 10 clockpin = 11 self.column = None self.width = 0 self.sequence = [] self.cur_column = 0 self.images_folder = "" if is_running_on_pi: self.strip = Adafruit_DotStar(0, datapin, clockpin, 18500000) else: self.strip = None
def main(): # Alternate ways of declaring strip: # Only use hardware SPI # print "Data pin GPIO/BCM {0}".format(datapin) # print "Clock pin GPIO/BCM {0}".format(clockpin) print("Opening LED strip with {0} pixels".format(numpixels)) # NOTE: This is not the same as omitting data/clock pin args!!! # strip = Adafruit_DotStar(numpixels, datapin, clockpin, order='gbr') # Use SPI (pins 10=MOSI, 11=SCLK) # strip = Adafruit_DotStar(numpixels, datapin, clockpin, order='grb') # Use SPI (pins 10=MOSI, 11=SCLK) # strip = Adafruit_DotStar(numpixels) # Use SPI (pins 10=MOSI, 11=SCLK) # strip = Adafruit_DotStar(numpixels, order='gbr') # Use SPI (pins 10=MOSI, 11=SCLK) # NOTE: The default color order is BRG (not RGB) strip = Adafruit_DotStar( numpixels, order='rgb'.encode('utf-8')) # Use SPI (pins 10=MOSI, 11=SCLK) strip.begin() # Initialize pins for output strip.setBrightness(brightness) # Limit brightness #strip.setBrightness(127) # Unlimited brightness print("Hit Ctrl-C to end test") try: while True: # scroll_pixels(strip, Color(255, 83, 13), numpixels * 20) # This one pretty much produces the expected results (gamma applied) #scroll_pixels(strip, Color(255, 83, 13, gamma=True), numpixels * 20) #scroll_pixels(strip, rgb_color(255, 0, 0), numpixels * 20) #scroll_pixels(strip, rgb_color(0, 255, 0), numpixels * 20) #scroll_pixels(strip, rgb_color(0, 0, 255), numpixels * 20) #solid_fill(strip, Color(255, 0, 0, gamma=True), iterations=2) #solid_fill(strip, Color(0, 255, 0, gamma=True), iterations=2) #solid_fill(strip, Color(0, 0, 255, gamma=True), iterations=2) wheel_fill(strip, iterations=1) print("Pass complete") except (KeyboardInterrupt, Exception) as ex: print(ex) print("") print("Turning off all lights...") # Not well documented, but this is how you turn # off everything strip.clear() strip.show() strip.close() print("Strip closed")
def __init__(self): numpixels = 128 datapin = 10 clockpin = 11 self.strip = Adafruit_DotStar(numpixels, datapin, clockpin, 1000000) self.strip.begin() self.strip.setBrightness(64) SnipsMatrix.state_hotword = AnimationImage('hotword', self.strip) SnipsMatrix.state_time = AnimationTime(self.strip) SnipsMatrix.state_rotate = AnimationRotate(self.strip, 0) SnipsMatrix.state_weather = AnimationWeather(self.strip) SnipsMatrix.custom_anim = SnipsMatrix.load_custom_animation(self.strip) SnipsMatrix.queue.put(snipsMatrixAction.Hotword()) SnipsMatrix.queue.put(snipsMatrixAction.Clear( DisplayPriority.hardware)) t = threading.Thread(target=SnipsMatrix.worker, args=()) t.start()
def rgbStrip(R, G, B): numpixels = 30 # Number of LEDs in strip # strip = Adafruit_DotStar(numpixels, rgb_strip_datapin, rgb_strip_clockpin) strip = Adafruit_DotStar(numpixels) # SPI @ ~32 MHz strip.begin() # Initialize pins for output strip.setBrightness(64) # Limit brightness to ~1/4 duty cycle # Runs 10 LEDs at a time along strip, cycling through red, green and blue. # This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel. led = 0 # Index of first 'on' pixel while (led != 30): # Loop for each light strip.setPixelColor(led, R, G, B) # Set pin color strip.show() # Refresh strip led += 1 # Advance head position\
def __init__(self): datapin = 10 clockpin = 11 self.column = None self.width = 0 self.sequence = [] self.cur_column = 0 self.images_folder = "" self.next_buffer_index = 0 self.last_push = 0 self.image_start_time = 0 if is_running_on_pi: self.strip = Adafruit_DotStar(0, datapin, clockpin, 18500000) else: self.strip = None
def main(): # Alternate ways of declaring strip: print("Data pin GPIO/BCM {0}".format(datapin)) print("Clock pin GPIO/BCM {0}".format(clockpin)) print("Opening LED strip with {0} pixels".format(numpixels)) # The default here is SPI at 800 KHz # strip = Adafruit_DotStar(numpixels) # Use SPI (pins 10=MOSI, 11=SCLK by default) # This strip uses the specified pins at 800 KHz #strip = Adafruit_DotStar(numpixels, datapin, clockpin, order='gbr') # Use SPI (pins 10=MOSI, 11=SCLK) strip = Adafruit_DotStar( numpixels, order='gbr'.encode('utf-8')) # Use SPI (pins 10=MOSI, 11=SCLK) # strip = Adafruit_DotStar(numpixels, 32000000) # SPI @ ~32 MHz # strip = Adafruit_DotStar() # SPI, No pixel buffer # strip = Adafruit_DotStar(32000000) # 32 MHz SPI, no pixel buf # See image-pov.py for explanation of no-pixel-buffer use. # Append "order='gbr'" to declaration for proper colors w/older DotStar strips) strip.begin() # Initialize pins for output # strip.setBrightness(64) # Limit brightness to ~1/4 duty cycle strip.setBrightness(brightness) # Limit brightness # Runs 10 LEDs at a time along strip, cycling through red, green and blue. # This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel. print("Hit Ctrl-C to end test") try: while True: random_pixels(strip) run_all_effects(strip) scroll_pixels(strip, numpixels * 20) except (KeyboardInterrupt, Exception) as ex: print(ex) print("") print("Turning off all lights...") # Not well documented, but this is how you turn # off everything strip.clear() strip.show() strip.close() print("Strip closed")
def __init__(self): datapin = 10 clockpin = 11 self.buffer = bytearray(STRIP_LENGTH * 4) self.buffer_clear = bytearray(STRIP_LENGTH * 4) self.color_hsv = [0, 1, 0.7] self.start_time = time.time() self.cur_trail = 0 for i in range(0, len(self.buffer_clear), 4): self.buffer_clear[i] = 0xFF self.buffer_clear[i + rOffset] = 0 self.buffer_clear[i + gOffset] = 0 self.buffer_clear[i + bOffset] = 0 if is_running_on_pi: self.strip = Adafruit_DotStar(0, datapin, clockpin, 18500000) else: self.strip = None
def __init__(self, FreqAverage=5, Path="pov/", start=""): threading.Thread.__init__(self) self.datapin = 2 # GPIO-Numbering! self.clockpin = 3 # GPIO-Numbering! self.strip = Adafruit_DotStar(0, self.datapin, self.clockpin) # Notice the number of LEDs is set to 0. This is on purpose...we're asking # the DotStar module to NOT allocate any memory for this strip...we'll handle # our own allocation and conversion and will feed it 'raw' data. self.strip.begin() # Initialize pins for output self.empty_array = bytearray(60 * 4) # prepare empty-flash for x in range(60): self.empty_array[x * 4] = 0xFF self.empty_array[x * 4 + 1] = 0x00 self.empty_array[x * 4 + 2] = 0x00 self.empty_array[x * 4 + 3] = 0x00 self.povPath = Path self.povFile = start self.size = [0, 0] self.FAverage = FreqAverage self.actPeriod = 0 self.freq = get_freq.freqThread( NAverage=self.FAverage) # initialize frequency-thread self.running = False # is Thread displaying a pov-File? self.NEWrunning = False # want to stop and start new? self.active = True # is Thread active? (& playing OR waiting to play) -> only False if quitting main. self.pause = False self.pos = 0 self.loading = False # loading? --> main waits for finishing loading-process if start != "": self.running = True else: self.off() self.start()
def rgbStripTest(): numpixels = 30 # Number of LEDs in strip # strip = Adafruit_DotStar(numpixels, datapin, clockpin) strip = Adafruit_DotStar(numpixels, 12000000) # SPI @ ~32 MHz strip.begin() # Initialize pins for output strip.setBrightness(64) # Limit brightness to ~1/4 duty cycle # Runs 10 LEDs at a time along strip, cycling through red, green and blue. # This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel. head = 0 # Index of first 'on' pixel tail = -10 # Index of last 'off' pixel color = 0xFF0000 # 'On' color (starts red) repeat = 0 while True: # Loop forever strip.setPixelColor(head, color) # Turn on 'head' pixel strip.setPixelColor(tail, 0) # Turn off 'tail' strip.show() # Refresh strip time.sleep(1.0 / 50) # Pause 20 milliseconds (~50 fps) head += 1 # Advance head position if (head >= numpixels): # Off end of strip? head = 0 # Reset to start color >>= 8 # Red->green->blue->black if (color == 0): color = 0xFF0000 # If black, reset to red tail += 1 # Advance tail position if (tail >= numpixels): tail = 0 # Off end? Reset repeat += 1 if (repeat == 10): rgbStripOff(strip) break
#######Going for all 4 moons###### import ephem import time from dotstar import Adafruit_DotStar #INITIALIZE AND CLEAR DOTSTAR numpixels = 72 # Number of LEDs in strip # Here's how to control the strip from any two GPIO pins: datapin = 23 clockpin = 24 strip = Adafruit_DotStar(numpixels, datapin, clockpin) strip.begin() # Initialize pins for output strip.setBrightness(8) # Limit brightness to ~1/4 duty cycle #turn all leds to black (off) offspot = 1 offcolor = 0x000000 nump = 73 while offspot < nump: strip.setPixelColor(offspot, offcolor) offspot += 1 strip.show() #PYEPHEM PART--GET MOON SPOTS
nearest = add(nearest, start) # return (dist, nearest) return (dist) # ---------------------------------------------------------- numpixels = 3 * 300 + 255 + 256 # Number of LEDs in strip + disk + square #for i in range( numpixels ): # pixels.append( 0 ) maxLEDintensity = 64 mindist = 0.5 # Min distance for LED relative to line function that is ysed to set intensity 0.1 to 1 is reasonable if flagPi: strip = Adafruit_DotStar(numpixels, 4000000) # 4 MHz is more reliable strip.begin() # Initialize pins for output strip.setBrightness(maxLEDintensity) # Limit brightness to ~1/4 duty cycle # Set up xy positions of each point matrixLEDxy = [] matrixLEDintensity = [] matrixLEDcurrent = [] ll = [ -7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5 ] for i in range(16): for j in range(16): matrixLEDintensity.append(0)
# This is a basic diagnostic tool, NOT a graphics demo...helps confirm # correct wiring and tests each pixel's ability to display red, green # and blue and to forward data down the line. By limiting the number # and color of LEDs, it's reasonably safe to power a couple meters off # USB. DON'T try that with other code! import time from dotstar import Adafruit_DotStar numpixels = 30 # Number of LEDs in strip # Here's how to control the strip from any two GPIO pins: datapin = 23 clockpin = 24 #strip = Adafruit_DotStar(numpixels, datapin, clockpin) strip = Adafruit_DotStar(numpixels, datapin, clockpin, order='bgr') # Alternate ways of declaring strip: # strip = Adafruit_DotStar(numpixels) # Use SPI (pins 10=MOSI, 11=SCLK) # strip = Adafruit_DotStar(numpixels, 32000000) # SPI @ ~32 MHz # strip = Adafruit_DotStar() # SPI, No pixel buffer # strip = Adafruit_DotStar(32000000) # 32 MHz SPI, no pixel buf # See image-pov.py for explanation of no-pixel-buffer use. # Append "order='gbr'" to declaration for proper colors w/older DotStar strips) strip.begin() # Initialize pins for output strip.setBrightness(65) # Limit brightness to ~1/4 duty cycle # Runs 10 LEDs at a time along strip, cycling through red, green and blue. # This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel.
uniqueSound = pygame.mixer.Sound("testSound.wav") uniqueSound.set_volume(0) uniqueSound.play(-1) pygame.mixer.music.load("testSound.wav") pygame.mixer.music.set_volume(0) #pygame.mixer.music.play(-1) totalPixels = 150 # Number of LEDs in Locker pixel = 0 # Control Pins for the Raspberry Pi to the Dot Star strip datapin = 23 clockpin = 24 # strip = Adafruit_DotStar(totalPixels, datapin, clockpin) strip = Adafruit_DotStar(totalPixels, 100000) strip.begin() # Initialize pins for output strip.setBrightness(254) # Limit brightness to ~1/4 duty cycle color = 0 # Global Color Value prevColor = 0 class ColumnOSCThread(threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self):
batteryLevel = c_long(0) batteryLevelP = pointer(batteryLevel) maxBatteryLevel = c_int(0) maxBatteryLevelP = pointer(maxBatteryLevel) systemUpTime = c_float(0.0) wirelessStrength = c_int(0) # first resolve an ContactQuality stream on the lab network print("looking for a ContactQuality stream...") streams = resolve_stream('type', 'ContactQuality') # LED Strip Setup numpixels = 72 # Number of LEDs in strip strip = Adafruit_DotStar(numpixels, 125000, order='bgr') print 'strip object created' strip.begin() # Initialize pins for output strip.setBrightness(8) # Limit brightness to ~1/4 duty cycle # reset strip for ledi in range(0, numpixels): strip.setPixelColor(ledi, 0x00FF00) strip.show() strip.setPixelColor(ledi, 0) strip.show() # create a new inlet to read from the stream
# correct wiring and tests each pixel's ability to display red, green # and blue and to forward data down the line. By limiting the number # and color of LEDs, it's reasonably safe to power a couple meters off # USB. DON'T try that with other code! import time from dotstar import Adafruit_DotStar px = 305 numpixels = 305 # Number of LEDs in strip begin = 0 # Here's how to control the strip from any two GPIO pins: datapin = 23 clockpin = 24 strip = Adafruit_DotStar(numpixels, 12000000) # Alternate ways of declaring strip: # strip = Adafruit_DotStar(numpixels) # Use SPI (pins 10=MOSI, 11=SCLK) # strip = Adafruit_DotStar(numpixels, 32000000) # SPI @ ~32 MHz # strip = Adafruit_DotStar() # SPI, No pixel buffer # strip = Adafruit_DotStar(32000000) # 32 MHz SPI, no pixel buf # See image-pov.py for explanation of no-pixel-buffer use. # Append "order='gbr'" to declaration for proper colors w/older DotStar strips) strip.begin() # Initialize pins for output strip.setBrightness(255) # Limit brightness to ~1/4 duty cycle # Runs 10 LEDs at a time along strip, cycling through red, green and blue. # This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel.
#!/usr/bin/python import math import time from dotstar import Adafruit_DotStar num_pixels = 240 # Number of LEDs in strip. strip = Adafruit_DotStar(num_pixels) # Use SPI (pins 10=MOSI, 11=SCLK). strip.begin() # Initialize pins for output. strip.setBrightness(255) # Full brightness. def simple_chaser(strip, step, period=60): for pixel in range(strip.numPixels()): r = 1.0 + 0.5 * math.cos( (pixel - step) / float(period) * 2 * math.pi - 2 * math.pi / 3) g = 1.0 + 0.5 * math.cos( (pixel - step) / float(period) * 2 * math.pi + 2 * math.pi / 3) b = 1.0 + 0.5 * math.cos((pixel - step) / float(period) * 2 * math.pi) color = ((min(255, int(256 * max(r, 0))) << 16) + (min(255, int(256 * max(g, 0))) << 8) + (min(255, int(256 * max(b, 0))))) strip.setPixelColor(pixel, color) class TravelingWave(object): def __init__(self, wavenumber, omega, phi_0, gain, offset): self.wavenumber = wavenumber self.omega = omega