Skip to content

Latest commit

 

History

History
203 lines (130 loc) · 7.45 KB

hardware_installation_pitft.md

File metadata and controls

203 lines (130 loc) · 7.45 KB

Back to hardware_installation.md

Table of Contents

Hardware installation

Software installation

Hardware Assembly

Displays with headers (PiTFT or E-ink displays)

The PiTFT is easy to get and easy to run the pizero_bikecomputer program on X Window, so it's a good idea to start with this one.

  • top left: PiTFT 2.4
  • central left: Raspberry Pi Zero WH
  • central right: GPS module
  • bottom left: Enviro pHAT
  • bottom right: ANT+ USB dongle and micro USB OTG Adapter

First of all, connect the Enviro pHAT without the header(I2C SDA, I2C SCL, 3.3V and GND).

Next, connect the PiTFT.

Connect the GPS module in the same way as the Enviro pHAT.

Name Raspberry Pi GPS
UART TX IO8 RX
UART RX IO10 TX
GND IO6 GND
VCC 5V or 3.3V VIN(5V or 3.3V)

Finally, fix each parts with screws. To prevent from being disconnected by vibration, fix the USB power cable and ANT+ USB dongle to the PiTFT board with the tape.

It is more reliable to solder the PiTFT directly to the header of Raspberry Pi Zero.

Software Installation

Raspberry Pi OS

Display

PiTFT 2.4

Follow official setup guide of Adafruit, or my setup guide (Japanese).

If you run the program in a console, you need to build Qt5 and PyQt5 because the package python3-pyqt5 provided with Raspbian OS does not include a touchscreen library(tslib).

Note:

The touchscreen does not work properly in Raspbian OS(Buster) + Qt 5.14(or higher) + PyQt 5.14(or higher) from some issues. So, if you use PiTFT, I recomand to run on X Window at present. In Raspbian OS(Stretch) + Qt 5.12.3 + PyQt 5.12.3, the touchscreen works.

Build Qt

Follow "Building Qt 5.12 LTS for Raspberry Pi on Raspbian" with Raspberry Pi 4 4GB or 8GB. Use the compile option "-platform linux-rpi-g++" for Raspberry Pi 1 or zero, not use options for Raspberry Pi 4 and so on. Use the same SD card on Raspberry Pi 4.

You will need libts-dev package before configure of Qt. (from RaspberryPi2EGLFS)

sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
Build PyQt5

Follow PyQt Reference Guide. The source is available here

$ cd
$ mkdir work; cd work
$ wget NEWEST-PYQT5-PACKAGE-SOURCE-FILE
$ sudo pip3 install PyQt-builder
$ sip-build --no-make --qmake PATH-TO-YOUR-QMAKE
$ cd build
$ make -j4
$ sudo make install
$ sudo pip3 install PyQt5-sip

Quick Start

Run on X Window

PiTFT

If you run the program from the SSH login shell, add the following environment variable.

export DISPLAY=:0.0

Then, run the program.

$ python3 pizero_bikecomputer.py -f

Run from the lancher menu.

Making launcher menu or desktop icon may be useful.

lancher menu

Make "New Item" in Main Menu Editor, and set "/home/pi/pizero_bikecomputer/exec.sh" in "Command:" field.

short cut

Run with autostart

If you are using the autologin option, you can run the program automatically using the following procedure。

$ mkdir -p ~/.config/lxsession/LXDE-pi
$ cp /etc/xdg/lxsession/LXDE-pi/autostart ~/.config/lxsession/LXDE-pi/
$ echo "@/home/pi/pizero_bikecomputer/exec.sh" >> ~/.config/lxsession/LXDE-pi/autostart

Run on console

Manual execution

PiTFT

Before run the program, add the following environment variables.

$ export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb1
$ export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0:rotate=270
$ export QT_QPA_FB_TSLIB=1
$ export TSLIB_FBDEVICE=/dev/fb1
$ export TSLIB_TSDEVICE=/dev/input/event0
$ python3 pizero_bikecomputer.py

Note: Works with Raspbian Stretch. No further versions have been confirmed to work. It seems that the touch screen axis is not set.

Usage

Button

Hardware button

PiTFT 2.4

pitft_button

From left to right, the button assignments are as follows.

GPIO NUM Short press Long press
5 Left (<-) None
6 Lap Reset
12 Screen brightness On/Off None
13 Start/Stop None
16 Right (->) Menu

In the menu, the button has different assignments. From left to right, the button assignments are as follows.

GPIO NUM Short press Long press
5 Back None
6 None None
12 Enter None
13 Select items (Back) None
16 Select items (Forward) None

Both short press and long press can be changed. And only the GPIO number of PiTFT 2.4 is supported. For other models, you need to change it in modules/config.py.

Back to hardware_installation.md