summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/scripts
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-04-28 13:37:17 +0100
committerDamien George <damien.p.george@gmail.com>2016-04-28 13:37:17 +0100
commit8c3b5526aee160f5dd7d836f4666a874e4c3212e (patch)
tree4a5448df554dd9d0653bc2ec2ff79319f5be0341 /esp8266/scripts
parent1f7cec944e9355860ebd264854015b2b9d561790 (diff)
downloadmicropython-8c3b5526aee160f5dd7d836f4666a874e4c3212e.tar.gz
micropython-8c3b5526aee160f5dd7d836f4666a874e4c3212e.zip
esp8266/scripts/neopixel.py: Remove test function from neopixel driver.
It takes up lots of room and isn't needed.
Diffstat (limited to 'esp8266/scripts')
-rw-r--r--esp8266/scripts/neopixel.py48
1 files changed, 4 insertions, 44 deletions
diff --git a/esp8266/scripts/neopixel.py b/esp8266/scripts/neopixel.py
index 7717bb496b..b0b9dc3813 100644
--- a/esp8266/scripts/neopixel.py
+++ b/esp8266/scripts/neopixel.py
@@ -1,5 +1,6 @@
-import time
-import machine
+# NeoPixel driver for MicroPython on ESP8266
+# MIT license; Copyright (c) 2016 Damien P. George
+
from esp import neopixel_write
class NeoPixel:
@@ -7,6 +8,7 @@ class NeoPixel:
self.pin = pin
self.n = n
self.buf = bytearray(n * 3)
+ self.pin.init(pin.OUT, pin.PULL_NONE)
def __setitem__(self, index, val):
r, g, b = val
@@ -20,45 +22,3 @@ class NeoPixel:
def write(self):
neopixel_write(self.pin, self.buf, True)
-
-def test():
- # put a neopixel strip on GPIO4
- p = machine.Pin(4, machine.Pin.OUT)
- np = NeoPixel(p, 8)
- n = np.n
-
- # cycle
- for i in range(4 * n):
- for j in range(n):
- np[j] = (0, 0, 0)
- np[i % n] = (255, 255, 255)
- np.write()
- time.sleep_ms(25)
-
- # bounce
- for i in range(4 * n):
- for j in range(n):
- np[j] = (0, 0, 128)
- if (i // n) % 2 == 0:
- np[i % n] = (0, 0, 0)
- else:
- np[n - 1 - (i % n)] = (0, 0, 0)
- np.write()
- time.sleep_ms(60)
-
- # fade in/out
- for i in range(0, 4 * 256, 8):
- for j in range(n):
- if (i // 256) % 2 == 0:
- val = i & 0xff
- else:
- val = 255 - (i & 0xff)
- np[j] = (val, 0, 0)
- np.write()
-
- # clear
- for i in range(n):
- np[i] = (0, 0, 0)
- np.write()
-
-test()