github:https://github.com/shaoziyang/mp ... /neopixel/neo_16x16
代码: 全选
"""
ESP8266/ESP32 neopixel 16x16 display drive
Author: shaoziyang
Date: 2018.2
http://www.micropython.org.cn
"""
from machine import Pin
import neopixel
class neo16x16:
def __init__(self, pin):
self.np = neopixel.NeoPixel(pin, 256)
self.color = (0,0,8)
def clear(self):
self.np.fill((0,0,0))
self.np.write()
def set(self, n, color=''):
if dat!='':
self.np[n] = color
else:
self.np[n] = self.color
self.np.write()
def setcolor(self, color):
self.color = color
def show(self, dat, offset=0, clear = True, color=''):
if color != '':
self.color = color
if clear:
self.np.fill((0,0,0))
for x in range(16):
for y in range(16):
if (x+offset)>=len(dat):
self.np[x*16+y]=(0,0,0)
else:
if (1<<y)&dat[x+offset]:
if offset%2==0:
self.np[x*16 + y] = self.color
else:
self.np[x*16 +15 - y] = self.color
self.np.write()
代码: 全选
'''
ESP8266/ESP32 neopixel 16x16 demo
Author: shaoziyang
Date: 2018.2
http://www.micropython.org.cn
'''
from machine import Pin
import time
from neo16x16 import neo16x16
np = neo16x16(Pin(2))
npdat=[
0x2008,0x1FFC,0x3FF8,0x1084,0x0100,0x1084,0x3FF8,0x1FFC,
0x2008,0x0000,0x1F00,0x01FC,0x2480,0x0124,0x2480,0x01EC,
0x1700,0x0000,0x0000,0x0804,0x2010,0x1FFC,0x3FF8,0x0004,
0x2000,0x0000,0x0000,0x0000,0x2010,0x0804,0x3FF8,0x1FFC,
0x2000,0x0004,0x0000,0x0000,0x0000,0x00F8,0x3F80,0x0104,
0x2080,0x0104,0x3F80,0x00F8,0x0000,0x0080,0x0180,0x0700,
0xFFF8,0xFFFF,0x1047,0x0638,0x0F38,0xF8C2,0xC00F,0x13FF,
0x7FC8,0x1080,0x0728,0x1C78,0x1818,0x0000,0x4010,0x0846,
0x37F0,0xFFB8,0x1E1F,0x0FEE,0x61F0,0x0100,0x4082,0x4103,
0xFFE2,0x4FFE,0x009A,0x7100,0x0086,0x0100,]
n = 0
while 1:
np.show(npdat, n)
n = (n + 1)%70
time.sleep_ms(200)