Adafruit 8x8 LED matrix. More compact code?

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Adafruit 8x8 LED matrix. More compact code?

Post by deshipu » Thu Mar 02, 2017 11:32 am

Just swap x and y, I guess?

BruinBear
Posts: 27
Joined: Sat Jan 14, 2017 11:59 am

Re: Adafruit 8x8 LED matrix. More compact code?

Post by BruinBear » Thu Mar 02, 2017 12:49 pm

Yes, good suggestion. Instead of this:

Code: Select all

for y, line in enumerate(image):
    for x in range(8):
        if line & (1 << x):
            display.pixel(x, y, 1)
display.show()


I did this

Code: Select all

for y, line in enumerate(image):
    for x in range(8):
        if line & (1 << x):
            display.pixel(y, x, 1)
display.show()
and it is now the same orientation as the other device.

Thanks.

Post Reply