Install the Joy Bonnet

The Joy Bonnet is a terrific little board! Originally designed to play video games in emulation, it's actually incredibly useful for adding a small set of controls to embedded projects as well.

Let's install the Joy Bonnet software so that the system can use it. You should already have the Joy Bonnet attached to the Pi Zero -- if not, do so now.

Installation is as simple as entering two lines in the Terminal, but you can read more details here in the Joy Bonnet Learn Guide.

Type this in to your Terminal to load the install script on your system:

cd ~
sudo apt-get install python3-pip
sudo pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/joy-bonnet.py

Then, type this in your Terminal to run the install script:

sudo python3 joy-bonnet.py

then press return, then: 

  • enter Y to agree to install
  • enter again to disable overscan, and then enter:
  • enter N to not install the GPIO-halt utility
  • finally enter one last time to continue

Once installation is complete (it takes a few minutes), you'll be asked if you want to reboot. You can go ahead and type and press return. Or, you can reboot the system later by entering this in the Terminal:

sudo reboot 

Joy Bonnet Button Configuration

Now, we can set up the buttons on the Joy Bonnet to run particular commands for our slideshow by sending keystrokes to feh.

First, let's open the joy-bonnet.py script which contains the key bindings by typing:

sudo nano /boot/joy-bonnet.py

Scroll down to the section that starts with:

KEYES= { # EDIT KEYCODES IN THIS TABLE TO YOUR PREFERENCES:

Then change the key assignments to the following:

BUTTON_A: e.KEY_N,        # next image
BUTTON_B: e.KEY_P,        # previous image
BUTTON_X: e.KEY_Z,        # unassigned
BUTTON_Y: e.KEY_M,        # toggle menu
SELECT:   e.KEY_Q,        # quit feh
START:    e.KEY_H,        # pause/continue slideshow
PLAYER1:  e.KEY_ESC,      # escape key  to close menus       
PLAYER2:  e.KEY_ENTER,    # enter key for menus
1000:     e.KEY_UP,       # Analog up for menu nav
1001:     e.KEY_DOWN,     # Analog down for menu nav
1002:     e.KEY_LEFT,     # Analog left -- menu nav and next image
1003:     e.KEY_RIGHT,    # Analog right - menu nav and previous image
The rows in the first column correspond to the Joy Bonnet buttons and thumbstick (the four directions are the 1000-1003 entries), and the second column is the keystrokes that are sent

Once edited, save the file by pressing ctrl-x followed by and return.

You can choose other hotkeys, just look at the feh manual by typing 'man feh' in a Terminal to see what's available.

Reboot the Pi Zero so the changes take effect. Then, try out the Joy Bonnet buttons by opening a Terminal and pressing the buttons to "type" the assigned letters.

Now, let's use them as intended! Run the frame player script by typing this in your Terminal:

bash start-picture-frame.sh

Once the slideshow has begun, try pausing with the Joy Bonnet Start button, and then advancing or going back through the images with the and buttons.

Next, let's change the system to portrait orientation.

This guide was first published on Sep 15, 2017. It was last updated on Sep 15, 2017.

This page (Joy Bonnet Setup) was last updated on Sep 12, 2017.

Text editor powered by tinymce.