Adding a Display to BrickPi

Adding a Display to BrickPi

Since all of the other supported ev3dev devices have a screen, I’ve been thinking for a long time that it would be nice to have a screen on the BrickPi as well. So, I finally got around to getting one. Here’s how you can add one too.

I’ve written this a tutorial for ev3dev (of course) but it should work the same with official Raspbian or Dexter Industries Raspbian for Robots

Finding a Compatible Display

PiTFTFirst, you need a compatible display. I am using the Adafruit PiTFT 2.8″ resistive touchscreen (the capacitive version should work too). This display is designed for Raspberry Pi A/B, so it only has a 26-pin connector. This is essential since the BrickPi only has a 26-pin header. Also, the pins used on the display do not conflict with any of the pins used by the BrickPi. Don’t get one with a 40-pin header – it won’t fit!

26-pin header pin connections
Pin RPi BrickPi(+) PiTFT PiTFT BrickPi(+) RPi Pin
1 3.3V 3.3V N/C 5V 5V 5V 2
3 I2C SDA Sensor 5 (SDA) N/C 5V N/C 5V 4
5 I2C SCL Sensor 5 (SCL) N/C GND GND GND 6
7 GPIO 4 N/C N/C N/C RPI-TX UART TXD 8
9 GND N/C GND N/C RPI-FTDI-RX UART RXD 10
11 GPIO 17 N/C N/C SW4 LED2 GPIO 18 12
13 GPIO 27 LED1 SW3 GND N/C GND 14
15 GPIO 22 N/C SW2 SW1 N/C GPIO 23 16
17 3.3V N/C N/C RT_INT N/C GPIO 24 18
19 SPI MOSI N/C MOSI_3V GND N/C GND 20
21 SPI MISO N/C MISO TFT_DC_3V N/C GPIO 25 22
23 SPI SCLK N/C SCLK_3V FTF_CS_3V N/C (RESET) SPI CE0 24
25 GND N/C GND RT_CS_3V N/C SPI CE1 26

As you can see from the table above, SW3 and SW4 on the PiTFT conflict with the LEDs on the BrickPi. But these are not populated from the factory, so no problem. Also, the BrickPi+ uses pin 24 for reset on the microcontrollers. Fortunately, there is a jumper required for this pin to be electrically connected to anything, so it won’t cause a problem either.

Making It Fit

Adafruit used to sell this display with some assembly required, but now sells it fully assembled, which is unfortunate for us. The display has a connector for attaching a ribbon cable to connect additional IO. This will interfere with the capacitors on the BrickPi, so it has to go.

Removal1 Removal2

I did this by first adding some fresh solder to connections to make it easier to melt the existing solder. Then I grabbed the pins one at a time with a needle nose pliers and pulled gently while melting the solder. Be careful not to touch the screen with the soldering iron!

This is the only modification needed if you just want to stack this on top of the BrickPi with no case. However, if you have one of the six-sided cases, it won’t fit! One side of the circuit board sticks out too far and side “3” of the case won’t fit into place. But don’t worry, the offending part of the circuit board doesn’t have any circuits in it, it is just ground plane and screw holes, so we can remove it.

Score Break

I used a straightedge and a utility knife to score the circuit board. As you can see in the picture, you need to cut in a line along the bottom edge of the two corner screw holes. You also need to score the other side of the circuit board as well. Be careful not to knick the flex connectors on the display when scoring the other side. Once the scores are deep enough (about 1/4 of the way through on each side), use a tool to gently break it the rest of the way.

Now, you can assemble it all together. Tip: don’t push the 26-pin connectors all the way down, otherwise the circuit boards will be at an odd angle. And of course you have to leave off side “5” of the case, otherwise it would cover up the display.

Making It Work

The Adafruit Learn pages about installation are a bit out of date, so don’t bother with them unless you are still running wheezy. If you have a recent kernel, there is a device tree overlay for the PiTFT that needs to be enabled. In config.txt, add the following line:

dtoverlay=pitft28-resistive

You also need to edit cmdline.txt so that this display will be used for the console as well. Add the following to the end of the line:

fbcon=map:1 fbcon=font:VGA8x8

If you plan on using the HDMI as well, make fbcon=map:10 instead of just 1.

There are also a couple modules that don’t load automatically. Run the following command to create a udev rule that will take care of this automatically. (This rule will be included in the next ev3dev release, so you are reading this in the not-so-distant-future, you may not need to manually create this rule if you are using ev3dev.)

echo 'ENV{MODALIAS}=="spi:stmpe610", RUN{builtin}+="kmod load stmpe_ts gpio_backlight"' | sudo tee /etc/udev/rules.d/50-pitft.rules

Now, reboot your Pi. It should “just work™”. It booted into Brickman for me on the fist try because ev3dev is awesome!

It even shows the battery voltage if you have a BrickPi+ (and you enabled the appropriate line in config.txt). Brickman doesn’t actually have support for touchscreen yet, so I had to connect a keypad to navigate. However, you can confirm that touch is working using the evtest command line utility. You can also turn the backlight on and off using /sys/class/backlight/soc\:backlight/brightness.

Now, you can do cool stuff like run a desktop on the display, play videos, draw stuff, etc. Check out the Adafruit learn pages. Not all is applicable to ev3dev, but there is still lots of useful information there.