Skip to main content

MicroPython Library

The InputronicGrid module talks to the ATtiny404 on the board over I2C. Import the InputronicGrid class, create one object, and read the pads and set the LEDs with its methods.

Not installed yet? Follow Quick Start before using the functionality pages.

Choosing the I2C bus​

InputronicGrid() with no arguments creates I2C(0, scl=Pin(22), sda=Pin(21)) itself on the ports the module recognises: ESP32, ESP8266 and one Soldered board. On a port it does not recognise it raises an exception with the message Board not recognized, pass an initialized I2C object. There, or with other pins, create the bus yourself and pass it in as InputronicGrid(i2c=i2c). The examples show how in two commented-out lines at the top; uncomment them, change the pin numbers to match your board and comment out the plain grid = InputronicGrid() line.

How pads and LEDs are numbered​

  • By row and column. readPad(row, col) and setLED(row, col, ...) take a row from 0 to 3 (top to bottom) and a column from 0 to 3 (left to right). Both point at the same pad.
  • By index. readButton(index) counts the buttons row by row: index = row * 4 + col. setLEDByIndex(index, ...) counts the LEDs in the order they sit on the data line, which runs left to right on even rows and right to left on odd rows, so on rows 1 and 3 the two index numbers point at different pads.
  • As a 16-bit mask. readAllPads() returns bit i for button i, counted row by row. setLEDMask(mask, r, g, b) lights LED i in data-line order for bit i, the same numbering as setLEDByIndex(), and turns every other LED off. On rows 1 and 3, a bit in the readAllPads() mask and the same bit in the setLEDMask() mask point at different pads.

readButton(), readAllPads(), setLEDByIndex() and setLEDMask() are in the module at this commit, but no example uses them yet.

Functionality​

Each page starts with one verified module example and explains every function the example uses to get that result.