def masterThread(q):

		# Create NeoPixel object with appropriate configuration.
		strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
		# Intialize the library (must be called once before other functions).
		strip.begin()

		master = pxb.pixelMaster(strip, q)
		master.show()
		#pprint(master.layers)

		#pprint(master.ledsColorBuffer)

                startTime=time.time()
                iterTime=startTime
                count=1
                targetSleep=1/float(TARGET_FPS)
		print "target FPS: %s" % TARGET_FPS
		print "target runtime per frame: %s" % targetSleep
                updateFreq=TARGET_FPS*10 # every 10 seconds
                while master.die == False:
                        iterTime=time.time()
                        runTime=(time.time()-startTime)
                        master.show()
                        if count % updateFreq == 0:
                                print "Time: %2.3f FPS: %2.3f" % (runTime, count/runTime)
                                print master.layers
                		startTime=time.time()
				count = 1
			else:
                        	count += 1

                        sleepTime=targetSleep-(time.time()-iterTime)
                        if sleepTime > 0:
                                sleep(sleepTime)
	while True:
		pixels = layer[:]
		for x in range(layer.size+1):
			#print "random range of 1 to %s : %s\n" % (p1, random.randrange(1, p1+1))
			#print "x: %s\n" % pixels[x]
			if random.randrange(1, p1+1) == p1:
				layer.setPixelColor(x, twinklePxl(pixels[x], red, green, blue, twinkleSwing))
		layer.show()
		sleep(wait_ms/1000.0)

# Create NeoPixel object with appropriate configuration.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
# Intialize the library (must be called once before other functions).
strip.begin()

master = pxb.pixelMaster(strip)
master.show()
pprint(master.layers)

#layer1 = master.newLayer()
#layer1[10:20:2] = pxb.Color(255,0,0)
#layer1.show()
#layer2 = master.newLayer()
#layer2[9:21:2] = pxb.Color(0,255,0)
#layer2.show()
#master.show()

pprint(master.ledsColorBuffer)

#theaterChaseRainbow()