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: 931
Joined: Thu May 28, 2015 5:54 pm

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

Postby deshipu » Thu Mar 02, 2017 11:32 am

Just swap x and y, I guess?

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

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

Postby 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.


Return to “The micro:bit”

Who is online

Users browsing this forum: No registered users and 1 guest