TILE36 experiences

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
User avatar
marfis
Posts: 189
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

TILE36 experiences

Post by marfis » Fri Apr 12, 2019 7:42 pm

So I received my D series togehter with 2 Tiles36 modules (6x6 RGB matrixes) :)

The Tiles are really cool, but the documention is a bit short and doesn't provide code samples for displaying text etc.

So I digged around in the datasheet and was able to come up with a few code snippset that some of you might find useful. In the end I was able to display scrolling text across 2 tiles in rainbow color with the following code:

Code: Select all

from micropython import const
import time, machine

LED_ADDR = const(60)        # default LED36 address

i2c = machine.I2C(1)        # select I2C1

def set_text_color(r,g,b,rb,gb,bb,addr=60):
    ba = bytearray(b'\x02c      ')
    ba[-6] = b
    ba[-5] = g
    ba[-4] = r
    ba[-3] = bb
    ba[-2] = gb
    ba[-1] = rb    
    i2c.writeto(addr, ba)

def set_rot(angle, addr=60):
    ba = bytearray(b'\x02\x14 ')
    ba[-1] = angle
    i2c.writeto(addr, ba)

def text(data, addr=60, col_cycle=False):
    if col_cycle:
        ba = bytearray(b'\x02k ')
    else:
        ba = bytearray(b'\x02l ')
    ba[-1] = len(data) & 0xff
    i2c.writeto(addr, ba)
    for i in data:
       i2c.writeto(addr, i)

def show(delay=50):
    while True:
        i2c.writeto(1, b'\x01')
        time.sleep_ms(delay)

def brightness(b=100, addr=1):
    ba = bytearray(b'\x02\x16 ')
    ba[-1] = b & 0xff
    i2c.writeto(addr, ba)

set_rot(1,addr=1)
brightness(100)
text('Micropython is sooo cool..', addr=1, col_cycle=True)
show()
Some explanation to this:

1) First you'll need to setup your tiles with different I2C addresses. The default is 60, so set your second tile to 61 (and more if you have more tiles). The docs https://pybd.io/hw/tile_led36.html provide functions on how to do that (set_i2caddr and save_nvram).

2) I had to rotate the orientation to 1 so that is can scroll to the left.

3) text data is sent to all modules by writing to address 1. It is then sufficient to just write a `1`to address 1 to instruct the display to scroll to the left.

4) set_text_color is not used in this rainbow example, but if you don't want to cycle through the colors, this function can be used to define the foreground and background color of the text.

It's just a quick and dirty example but I guess it helps to get you started. It's really a cool little led display.

Surej
Posts: 3
Joined: Thu May 23, 2019 6:38 pm

Re: TILE36 experiences

Post by Surej » Thu May 23, 2019 8:31 pm

Hi,

Will this code work for single tile? I tried loading the code, still, LEDs are not turning ON..

Thanks

Surej

User avatar
jimmo
Posts: 309
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: TILE36 experiences

Post by jimmo » Fri May 24, 2019 6:25 am

marfis wrote:
Fri Apr 12, 2019 7:42 pm
So I digged around in the datasheet and was able to come up with a few code snippset that some of you might find useful. In the end I was able to display scrolling text across 2 tiles in rainbow color with the following code:
...
It's just a quick and dirty example but I guess it helps to get you started. It's really a cool little led display.
Mine just arrived today too! I agree, it's a really neat little tile. Thanks for this snippet above - works perfectly. :)
Surej wrote:
Thu May 23, 2019 8:31 pm
Will this code work for single tile? I tried loading the code, still, LEDs are not turning ON..
Surej - which WBUS adaptor are you using? If it's the little one (WBUS28), then you'll need to change the example code to machine.I2C(2) (it uses the Y positions instead, where as the WBUS68 uses the X positions). (You can also write machine.I2C('Y') to be clearer).

Surej
Posts: 3
Joined: Thu May 23, 2019 6:38 pm

Re: TILE36 experiences

Post by Surej » Fri May 24, 2019 9:48 am

Hi,

I am using the longer one with four tile connectors. I tried changing machine.I2C(1) and also to machine.I2C(2) with no luck. I have connected the tile to the fourth connector far from the pyboard, is it socket specific when using only one tile?

Thanks
Surej

User avatar
jimmo
Posts: 309
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: TILE36 experiences

Post by jimmo » Fri May 24, 2019 10:37 am

Surej wrote:
Fri May 24, 2019 9:48 am
I am using the longer one with four tile connectors. I tried changing machine.I2C(1) and also to machine.I2C(2) with no luck. I have connected the tile to the fourth connector far from the pyboard, is it socket specific when using only one tile?
That's the WBUS68. It uses the 'X' position (i.e. machine.I2C('X') or machine.I2C(1) ). It's the short one (WBUS28) that you would need to change it to 'Y' for.

It's working for me in the fourth connector on the WBUS68. Can you share the code you're using? Are you calling brightness(100) first?

I copied the code exactly from https://pybd.io/hw/tile_led36.html into a file named led36.py, then on the REPL:

Code: Select all

>>> import led36
>>> led36.brightness(100)
>>> led36.random_dots()

Surej
Posts: 3
Joined: Thu May 23, 2019 6:38 pm

Re: TILE36 experiences

Post by Surej » Fri May 24, 2019 10:53 am

Thanks that worked for me :) :D

User avatar
marfis
Posts: 189
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

Re: TILE36 experiences

Post by marfis » Fri May 24, 2019 7:59 pm

does that mean that the devices on the same bus are aware of eachother and can automatically sequentially-assign addresses? How does that interact with setting the i2c address manually?
My interpretation of it was that the i2c addresses can only be set manually via i2c. They cannot auto assign. It would have been neat if the breakout board had a HW ID per slot so that the tile knows in which slot it is attached. That would have solved the somewhat awkward user experience if you have orderes several tiles.

The FW of the tiles seems to contain logic that interprets the address as input what to display. Consider the way how text is displayed. text is broadcasted to all modules at once. Then each module interprets the following scroll commands differnetly, based on their address.

E.g. tile on address 60 displays the first letter, address 61 the second one etc. I also tested this by reassigning one tile to adress 62. And indeed the letter in between is then missing....

Post Reply