/flystick

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

flystick

A python script for Raspberry Pi that reads a USB joystick (with pygame) and outputs a PPM signal to RC transmitter (with pigpio).

For the mandatory blinky-blinky, supports VERY FANCY (or so) visualizations for Scroll pHAT.

The input/output-mapping and visualization are highly configurable.

YouTube screenshot

Motivation

I wanted to try out how it's to fly FPV with a joystick. Project https://github.com/Iezious/rcjoy/wiki did seem very interesting, but I wasn't that thrilled about the low-level, hardware-specific approach; I wanted a simpler and more future-proof solution.

When the Raspberry Pi Zero came out, it seemed like a perfect hardware component for solving the problem. And then with the python libraries, the whole set came together very nicely — with very little code.

Setup (on Raspberry Pi)

Installation

  1. sudo apt-get install python-pygame git

  2. http://abyz.co.uk/rpi/pigpio/download.html

  3. Optional: from https://github.com/pimoroni/scroll-phat:

    curl -sS https://get.pimoroni.com/scrollphat | bash

  4. git clone https://github.com/jsa/flystick.git

Configuration

  1. Calibrate joystick, see jscal. Also the related jstest, jscal-store, and jscal-restore.

  2. Configure channel mapping.

  3. Configure Pi for safe unplugging.

  4. Insert to /etc/rc.local BEFORE THE LINE exit 0:

    pigpiod
    
    cd ~pi/flystick
    python flystick.py &
    cd -
    

Wiring

  1. 5V → Raspberry Pi

  2. Raspberry PPM output → transmitter trainer port

Thrustmaster Notes

jstest-gtk - joystick testing software sudo pigpiod - enable pigpio demon ./flystick.py - run the code ps aux | grep PROCESS_NAME - for getting process id kill -9 PROCESS_ID - for killing the demon or a process