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.
This commit is contained in:
jerryneedell 2017-10-16 21:29:42 -04:00 committed by Scott Shawcroft
parent e2ce87e250
commit c6a15f76ad
2 changed files with 2 additions and 32 deletions

View File

@ -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)

View File

@ -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 bitbangio_module;
extern const struct _mp_obj_module_t time_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 multiterminal_module;
extern const struct _mp_obj_module_t neopixel_write_module;
#define MICROPY_PORT_BUILTIN_MODULES \ #define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \ { 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_random), (mp_obj_t)&random_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_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_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 \ #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
{ MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, \ { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, \