Skip to content

NeoPixel neo_16x16 to neo_10x10 #16

Open
@DHavron

Description

@DHavron

Hi!

Using your neo_16x16 code to customize neo_10x10 :
test.py

from machine import Pin
import time

from neo10x10 import neo10x10

np = neo10x10(Pin(5))

npdat=[
0x00, 0x66, 0x66, 0xe0, 0xe0, 0xe0, 0xe0, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00
] 

n = 0
while 1:
    np.show(npdat, n)
    n = (n-10)%10
    time.sleep_ms(100)

neo10x10.py

from machine import Pin
import neopixel

class neo10x10:
    def __init__(self, pin):
        self.np = neopixel.NeoPixel(pin, 100)
        self.color = (0,0,8)
    
    def clear(self):
        self.np.fill((0,0,0))
        self.np.write()

    def set(self, n, color=''):
        if color!='':
            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))
        num = 0
        for x in range(10):
            for y in range(10):
                if (x+offset)>=len(dat):
                    self.np[x*10+y]=(0,0,0)
                else:
                    if (1<<y)&dat[x+offset]:
                        if offset%2==0:
                            self.np[x*10 + y] = self.color
                        else:
                            self.np[x*10 + 9 - y] = self.color

        self.np.write()

trying to display an image smile
I get this output
what could be the problem?
tell me in which editor to convert the image into an array of data?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions