Close

Using a Bluetooth joystick for slew control

A project log for Raspberry Pi Driven Telescope Mount

full telescope control over WiFi using INDI on a RPi Zero W

Dane GardnerDane Gardner 04/11/2017 at 02:110 Comments

I picked up a cheap Bluetooth SNES controller to allow me to slew my telescope without disturbing the setup with vibrations from a wired hand controller. This should allow things to settle more quickly after a manual change to the scope's position.

To configure the RPi for a Bluetooth joystick, I used `bluetoothctl` at the command line:

bluetoothctl
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# scan on
...
[bluetooth]# pair XX:XX:XX:XX:XX:XX
[bluetooth]# trust XX:XX:XX:XX:XX:XX
[bluetooth]# connect XX:XX:XX:XX:XX:XX
[bluetooth]# quit

Unfortunately, the joystick driver in libindi forgets any remapping you may perform in the UI, despite saving and reloading the configuration. To work around this, I changed the button mapping at the OS level to match what I wanted, and have it automatically reconfigure each time the RPi reboots.

apt-get install joystick
 
cat > /etc/joystick.cal < EOF
jscal -u 8,0,1,2,5,9,10,16,17,16,315,304,305,314,307,308,310,311,316,317,318,319,306,309,312,313 /dev/input/js0
jscal -s 8,1,0,127,127,-4194176,-4227201,1,0,127,127,4227201,4194176,1,0,127,127,2147483647,2147483647,1,0,127,127,2147483647,2147483647,1,0,0,0,2147483647,2147483647,1,0,0,0,2147483647,2147483647,1,0,0,0,2147483647,2147483647,1,0,0,0,2147483647,2147483647 /dev/input/js0
EOF
 
echo "source /etc/joystick.cal" >> /etc/rc.local

Be sure to add the 'Joystick' driver to the libindi server configuration in the web manager interface!

That's it. It works great for me now!

Discussions