Display & bus drivers

SSD1306 (OLED display)

SSD1306 OLED driver — thin wrapper around micropython-lib’s ssd1306.SSD1306_I2C.

The micropython-lib driver is already battle-tested and subclasses framebuf.FrameBuffer. We re-expose its core methods (text, pixel, fill, show) explicitly and delegate the rest (rect, line, hline, scroll, contrast, …) via __getattr__. An extra clear() convenience erases the buffer and pushes a blank frame.

The ssd1306 module is frozen into each board’s firmware image (see native/boards/*/manifest.py), so import works out of the box on flashed hardware.

A Display is an external I2C component, not part of the hub — instantiate one directly wherever you want to draw text / pixels.

class openbricks.drivers.ssd1306.SSD1306(i2c, addr=0x3C, width=128, height=64)[source]

Bases: object

128×64 (or 128×32) SSD1306 OLED on I2C.

text(s, x, y, c=1)[source]
pixel(x, y, c=None)[source]
fill(c)[source]
show()[source]
clear()[source]

TCA9548A (I2C multiplexer)

TI TCA9548A 8-channel I2C multiplexer / switch.

Some I2C sensors have a fixed address with no way to change it — the TCS34725 colour sensor is stuck at 0x29, for instance — so you cannot put two of them on one bus without an address collision. The TCA9548A sits between the host and the sensors and fans one bus out to eight electrically-isolated channels (SD0/SC0 .. SD7/SC7); each channel can host its own copy of the same-address device.

The mux itself answers at 0x70 by default (0x70..``0x77`` via the A0/A1/A2 address pins). Channel selection is a single-byte write to that address: bit N enables channel N. Multiple bits enable several channels at once; 0x00 disables all of them.

The drop-in path is mux[n]: it returns an object that quacks like a machine.I2C bus but transparently selects channel n before every operation, so existing drivers construct against it unchanged:

from machine import I2C, Pin
from openbricks.drivers.tca9548a import TCA9548A
from openbricks.drivers.tcs34725 import TCS34725

i2c = I2C(0, sda=Pin(21), scl=Pin(22), freq=400_000)
mux = TCA9548A(i2c)
left  = TCS34725(mux[0])   # 0x29 on channel 0
right = TCS34725(mux[1])   # 0x29 on channel 1

Reference: TCA9548A datasheet (Texas Instruments), section 8.3.

class openbricks.drivers.tca9548a.TCA9548A(i2c, address=_DEFAULT_ADDR)[source]

Bases: object

select(channel)[source]

Enable exactly channel (0..7), disabling the rest.

disable()[source]

Disable every channel (control byte 0x00).