From Dooba Wiki
Jump to navigation Jump to search
Inpad board


The Inpad is a user input module.

It features a 5-way switch (mini-joystick) as well as three tactile switches.

These inputs are connected to a mcp23008 I/O expander which communicates via I2C.


  • Power input: 3.3V
  • I2C address: 0x48
  • I/O expander: MCP23008


If you're using the Yolk UI framework, you don't need this - check out instructions on how to use with Yolk.

If you want to use the module directly, the mcp23008 library offers a simple interface to the Inpad.

The inputs are connected to ground, therefore internal pull-ups should be enabled on the mcp23008:

#include <util/delay.h>
#include <mcp23008/mcp23008.h>

#define INPAD    0x48

void init()
    // ...

    // Configure Inpad as inputs
    mcp23008_set_dir(INPAD, 0xff);

    // Enable internal pull-ups for inputs
    mcp23008_set_pullup(INPAD, 0xff);

    // ...

void loop()
    uint8_t input_state;

    // Read Input state
    input_state = mcp23008_get_gpio(INPAD);

    // Display input state
    scli_printf("Input: %h\n", input_state);

    // Delay

Input bits:

Input Mask Bit number
Up 0x04 2
Down 0x08 3
Left 0x10 4
Right 0x01 0
Center 0x02 1
Button 1 0x40 6
Button 2 0x80 7
Button 3 0x20 5


This device communicates via I2C. As always when dealing with the I2C bus, Don't forget to add pull-up resistors!

The wiring with an ioNode should look something like this:

Inpad wiring.png


The diagram below shows the pin assignments for the Inpad:


The four pins closer to the tactile switches are all connected to ground. They are provided for added mechanical stability.



Usage with Yolk

This device can be easily used as an input layer for Yolk.

To do that, define it as such in your substrate:

uses :yolk, name: 'ui0', dsp: 'dsp0', input:
    mask: 0xff,
    bit_nums: { up: 2, down: 3, left: 4, right: 0, center: 1 },
    driver: { type: :ioexp, addrs: [0x48] }

This only defines generic input bits for the 5-way switch (mini-joystick).

If desired, the tactile switches can be mapped to generic input bits in Yolk. Below is one such example:

uses :yolk, name: 'ui0', dsp: 'dsp0', input:
    mask: 0xff,
        up: 2, down: 3, left: 4, right: 0, center: 1,
        u1: 6, u2: 7
    driver: { type: :ioexp, addrs: [0x48] }