Last active
August 9, 2017 23:49
-
-
Save sethcohn/0d2493dc2b854bd5584fe09fc0cd8509 to your computer and use it in GitHub Desktop.
Why is this slow? It doesn't actually write the pixel...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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