Page 2 of 2

Re: Is it possible for micro:bit to support multiple languages?

Posted: Tue Jan 03, 2017 4:05 pm
by Jason Kim
@deshipu Thank you for your response.
Thank you for the code you upload for me. This code will help me a lot.

I've just tried a test about your code.
led output is one by one and speed is slow but I will try to fix it! :)

Code: Select all

window = Image(5, 5)
The window is the first object I have ever seen. Even if i search, there is no information. Is it an object contained in the Micro:bit?

Anyway, your answer really helped me a lot.
Can I contact to you again if I doing study about Micro:bit?? :)

Re: Is it possible for micro:bit to support multiple languages?

Posted: Thu Jan 05, 2017 12:59 pm
by deshipu
The "window" is just a name I gave to the empty 5x5 image that I'm using here as a buffer. It's slow, because I'm copying into that buffer pixel-by-pixel in Python. I couldn't find a way to do it faster using built-in methods.

If you have any questions, just ask on this forum.

Re: Is it possible for micro:bit to support multiple languages?

Posted: Wed Jan 18, 2017 12:33 pm
by deshipu
There was a "blit" method added to the Image class just now, which, when released, will let you do the scrolling much faster: https://github.com/bbcmicrobit/micropython/pull/401

When the version containing this change is merged, the below code should work:

Code: Select all

from microbit import Image, Display
image = Image(
   "0900900900990090090009009090099900:"
   "9090990990990999090009009090900090:"
   "0900900999990090099090999090099900:"
   "0000000900090909090090909090090900:"
   "9999000999990090090090909090999990:")

def my_scroll(image) :
    window = Image(5, 5)
    for position in range(-4, image.width()):
        window.blit(image, position, 0, 5, 5)
        yield window

display.show(my_scroll(image), wait=False)