Skip to content

Instantly share code, notes, and snippets.

@sethcohn
Last active August 9, 2017 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethcohn/0d2493dc2b854bd5584fe09fc0cd8509 to your computer and use it in GitHub Desktop.
Save sethcohn/0d2493dc2b854bd5584fe09fc0cd8509 to your computer and use it in GitHub Desktop.
Why is this slow? It doesn't actually write the pixel...
from board import *
import time
import neopixel
class PixelPaint:
def __init__(self, pixelobj):
self.pixelobj = pixelobj
self.n = len(self.pixelobj)
def update(self):
self.pixelobj.auto_write = False
red = (30,0,0)
starttime = time.monotonic()
for j in range(0, self.n):
pixelnumber = j
self.pixelobj[j] = red
stoptime = time.monotonic()
total = stoptime - starttime
print ("Timing total:", total)
#self.pixelobj.fill((0,0,0))
#self.pixelobj.show()
def run():
with neopixel.NeoPixel(A0, 100, 3, 1, False) as np: # change to match pin and pixel count
paint = PixelPaint(np)
for i in range(0,100):
paint.update()
#np.show()
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment