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

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Jason Kim
Posts: 12
Joined: Sun Jan 01, 2017 3:07 pm

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

Post by Jason Kim » Tue Jan 03, 2017 4:05 pm

@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?? :)

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

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

Post by deshipu » Thu Jan 05, 2017 12:59 pm

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.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

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

Post by deshipu » Wed Jan 18, 2017 12:33 pm

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)

Post Reply