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()
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.