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: 10
Joined: Sun Jan 01, 2017 3:07 pm

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

Postby Jason Kim » Sun Jan 01, 2017 3:12 pm

example)
I am Korean.
so i want write that "microbit.display.scroll("안녕하세요"); <- this is Korean.
Is it possible to make the output available in the desired language?

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

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

Postby deshipu » Sun Jan 01, 2017 11:41 pm

Micro:Bit has very limited memory, and the default font that it uses only covers the basic ASCII characters. Supporting the full Unicode range is pretty much out of question in this situation. You can, however, display and scroll those characters as images (as long as you manage to squeeze them into the 5x5 grid).

Jason Kim
Posts: 10
Joined: Sun Jan 01, 2017 3:07 pm

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

Postby Jason Kim » Mon Jan 02, 2017 1:39 am

@deshipu
thank you for reply.
Can you tell me which module I need to modifiy if i wnat to print the other language as images?
One more thing, What's the amount of memory that Micro:Bit has? So can not support all the Unicode?
Thank you very much.

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

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

Postby deshipu » Mon Jan 02, 2017 9:45 am

You can refer to the documentation about displaying and scrolling images:
http://microbit-micropython-pl.readthed ... image.html

You can read about the technical specs of the Micro:bit on the official page here: http://microbit.org/hardware/ and in the reference specification here: http://tech.microbit.org/hardware/#nrf5 ... -processor

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

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

Postby deshipu » Mon Jan 02, 2017 9:58 am

For example, I tried to make the "안녕하세요" text:

Code: Select all

from microbit import Image, Display
image = Image(
   "0900900900990090090009009090099900:"
   "9090990990990999090009009090900090:"
   "0900900999990090099090999090099900:"
   "0000000900090909090090909090090900:"
   "9999000999990090090090909090999990:")
   
def scroll(image):
    for x in range(image.width):
        yield image.crop(x, 0, 5, 5)
       
Display.show(scroll(image))


(I didn't test it, but it should give you an idea.)
Note how the characters are practically completely unreadable on the 5x5 display -- the Hangul glyphs are too complex to display properly at this resolution.

rcolistete
Posts: 85
Joined: Thu Dec 31, 2015 3:12 pm

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

Postby rcolistete » Mon Jan 02, 2017 10:55 am

I think that only the new 2017 Micro:bit version will support asian characters :
The Micro:bit Foundation wants to help 'tens of millions' of children to code
The Foundation has been created by the BBC, ARM, Microsoft, Nominet, Samsung and the Institution of Engineering and Technology, and wants to reach 100 million people
http://www.wired.co.uk/article/microbit-foundation-bbc-microsoft-samsung
...
But that isn't enough, Shelby says a new version of the micro:bit could come as soon as 2017. This would help it to keep up with technological developments and also make it compatible for use elsewhere in the world. Shelby says: "We have a lot more processor power coming".

"We're going to see more capabilities in regional support. We need bigger screens to be able to do Chinese and Japanese characters when we've been going out and using it in Asia," he explains.

Jason Kim
Posts: 10
Joined: Sun Jan 01, 2017 3:07 pm

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

Postby Jason Kim » Tue Jan 03, 2017 5:38 am

@deshipu Thank you for your response.
Thank you for the code you upload for me. and There are question about the code.
I changed the code slightly.
so i tried again.

Code: Select all

from microbit import *

image = Image(
    "090900:"
    "090909:"
    "090909:"
    "090909:"
    "090909:")
 
def my_scroll(image) :
      for x in range(image.width()) :
           yield image.crop(x, 0, 5, 5) <- understand!
display.show(my_scroll(image))

and then result is

Code: Select all

Allocation in interrupt handlerTraceback (most recent all last):
  File "<stdin>", line 15, in <module>
MemoryError


why is that happen to me.... :(

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

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

Postby deshipu » Tue Jan 03, 2017 11:52 am

I think I see the problem. Looks like the scroll iterator is getting executed inside an interrupt (makes sense, so that it it can scroll while other code is running), but inside an interrupt you are not allowed to allocate memory. However, the crop method creates an new image, allocating memory -- so it fails. I'm sorry, I didn't test this code before (there were a lot of spelling errors in it too), and I didn't think about this limitation.

The documentation actually warns about this: http://microbit-micropython.readthedocs ... #functions

Jason Kim
Posts: 10
Joined: Sun Jan 01, 2017 3:07 pm

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

Postby Jason Kim » Tue Jan 03, 2017 12:06 pm

@deshipu Thank you for reply.
I'm okay because I am learning a lot of thing about Micro:bit by you!
thank you a lot!

so, Is there any other way to solve this problem?
This is very basic and important to what I'm trying to do. If this problem is resolved, it will be modified to support all Unicode. I'd appreciate it if you could help me with this problem.

p.s I will upload again so that all people can see this problem. thank you so much deshipu

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

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

Postby deshipu » Tue Jan 03, 2017 12:14 pm

Here's a fixed program, that works around the memory allocation issue by manually copying the pixels from the original image into a new image. This time I tested it.

Code: Select all

from microbit import *

image = Image(
    "090900:"
    "090909:"
    "090909:"
    "090909:"
    "090909:")

window = Image(5, 5)
 
def my_scroll(image) :
    for position in range(-4, image.width() + 1):
        for y in range(5):
            for x in range(5):
                window.set_pixel(x, y, image.get_pixel(x + position, y) if 0 <= x + position < image.width() else 0)
        yield window

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


Return to “The micro:bit”

Who is online

Users browsing this forum: No registered users and 1 guest