summaryrefslogtreecommitdiff
path: root/esp8266
diff options
context:
space:
mode:
authorjerryneedell <jerryneedell@gmail.com>2017-10-16 21:29:42 -0400
committerScott Shawcroft <scott@tannewt.org>2017-10-16 18:29:42 -0700
commitc6a15f76adfe0a3627fd42f6a4a5f2c45be51b35 (patch)
tree2e0cdc1d675470075b83bc573ea16b451ca459b6 /esp8266
parente2ce87e250b14f192955b1eb7968246734193237 (diff)
esp8266: add neopixel_write - remove neopixel.py (#339)
For ESP8266, remove frozen module neopixel.py and add neopixel_write to mpconfigport.h. Use [Adafruit_CircuitPython_Neopixel/neopixel.py](https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel) instead.
Diffstat (limited to 'esp8266')
-rw-r--r--esp8266/modules/neopixel.py32
-rw-r--r--esp8266/mpconfigport.h2
2 files changed, 2 insertions, 32 deletions
diff --git a/esp8266/modules/neopixel.py b/esp8266/modules/neopixel.py
deleted file mode 100644
index b13424d7d..000000000
--- a/esp8266/modules/neopixel.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# NeoPixel driver for MicroPython on ESP8266
-# MIT license; Copyright (c) 2016 Damien P. George
-
-from esp import neopixel_write
-
-
-class NeoPixel:
- ORDER = (1, 0, 2, 3)
-
- def __init__(self, pin, n, bpp=3):
- self.pin = pin
- self.n = n
- self.bpp = bpp
- self.buf = bytearray(n * bpp)
- self.pin.init(pin.OUT)
-
- def __setitem__(self, index, val):
- offset = index * self.bpp
- for i in range(self.bpp):
- self.buf[offset + self.ORDER[i]] = val[i]
-
- def __getitem__(self, index):
- offset = index * self.bpp
- return tuple(self.buf[offset + self.ORDER[i]]
- for i in range(self.bpp))
-
- def fill(self, color):
- for i in range(self.n):
- self[i] = color
-
- def write(self):
- neopixel_write(self.pin, self.buf, True)
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 19f80fbb6..5e9b1e0b6 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -171,6 +171,7 @@ extern const struct _mp_obj_module_t busio_module;
extern const struct _mp_obj_module_t bitbangio_module;
extern const struct _mp_obj_module_t time_module;
extern const struct _mp_obj_module_t multiterminal_module;
+extern const struct _mp_obj_module_t neopixel_write_module;
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
@@ -191,6 +192,7 @@ extern const struct _mp_obj_module_t multiterminal_module;
{ MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_multiterminal), (mp_obj_t)&multiterminal_module }, \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module }, \
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
{ MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, \