JUCE on the Pi: using hardware encoder knobs and buttons

Hi there,

I’m an experienced C/C++ dev, and have some EE background, but I’m pretty new to JUCE.
Currently building a hardware sample player (based on a Pi3), and at the moment I’m trying to figure out what’s the best way to interface hardware, UI & DSP using JUCE as the main framework, without running into dead ends. Here’s the current state:

  • Pi3 running on Raspbian Jessie
  • AudioInjector Octo audio device (6 ins, 8 out) on top of the Pi, using ALSA
  • cheap Midi I/O USB device
  • 5" TFT (touch function not needed)
  • 1 encoder wheel (standard 3-pin grey code), plus 2 pins for push button
  • 4 push buttons for accessing dedicated sub views / pages
  • JUCE 4 using code::blocks IDE, gcc
  • basic JUCE-based standalone audio app up & running

The plan is to control the app entirely via the knob & buttons (the latter having easy access to dedicated pages). It should all work similar to a car stereo:

  • turn the encoder to dial in a control’s focus (thinking of drawing a ‘halo’ around the control)
  • press the encoder button. Halo blinks/changes colour. Now the selected control accepts value changes (inc/dec)
  • another button push leaves value change and reverts back to focus selection

Thinking of using the pigpio lib for ease-of-use, which uses callbacks.
Question is: where would you guys put a callback/notifier? Has anyone done something similar?
Should I derive from the Slider control and do stuff in the listener? Do I have to have to mess with the MessageManager in order to post my own messages to a control?

I’m totally open to any kind of suggestions :slight_smile:
Thanks,
Sascha

1 Like

Check out the AsyncUpdater class. You could write a class derived from that class, which handles the GPIO interrupts and posts them to the message thread.

One thing that would be cool is to have a class that handles the GPIO, but pass a lambda expression to the constructor to call setValue() on a slider instance in another class.

1 Like