Griffin powermate

@cmullen,

Could you provide some instructions to get this (grifcat) to work on Volumio 2?

Does it work for any source or is it tied to mpd playing from a filesystem?

I have an IQaudio HAT and would be interested in the commands needed for that board.

Thanks!!!

Has anyone had success setting up a Griffin Power Mate on a later version of Volumio? I am currently setting up a R-pi3 using a Schiit Audio Modi2 uber and would LOVE to have my Griffin Power mate as a volume/Skip/Pause controller :slight_smile:

Any help for a 100% Linux Noobie would be much appreciated.

Sorry for the late reply.

High level overview is:

  • download, compile and make the C coded application grifcat from GitHub for your rpi.
  • copy bash script to your /home/volumio directory.
  • setup script to run on boot.
  • script has been changed to use Volumio 2 command line interface so it is independent upon hardware DAC, etc.

What app does is increase volume on clockwise turn and decrease on counter clockwise rotation. Press the Powermate knob and the rpi shuts down and powers off. Powermate LED is dimmed for constant operation and flashes bright right before shutdown.

It might be easier to have grifcat and bash script included in a Volumio 2 release. Could be modified to work with any USB wheel mouse with plugin to define button commands, eg. mute volume, shutdown, next song, etc.

@cmullen,

Thanks for all this useful information. I’ve managed to get a Powermate working successfully in Raspbian with evrouter using your guidelines. I’ve also subsequently managed to get grifcat running successfully as well and seeing Powermate behaviour, but am stumped as to how to convert those grifcat responses in to a usable bash script. Do you have an example script you can share which could point me in the right direction?

Many thanks!

Sorry I took so long to respond. I put auto notification on reply.

Put bash script in /home/volumio/knobber.sh

Sorry for the condition of the script. Over the years I just commented out the code needed for Volumio 1 or changes I made to functionality. This script will change volume in linear scale (clockwise louder / counter clockwise quieter) push knob down gives power off.

[code]#!/bin/bash

sudo rmmod powermate

sleep .5
\

Flash the LEDs slowly for startup\

sudo /home/volumio/grifcat --led-pmode=2
\

Set brightness of LEDs. 0=LED off and 255=LED brightest.\

/home/volumio/grifcat --brightness=11

step=10
varitic=0


while true; do

sleep 10

echo “start Powermate script”
\

Must remove kernel driver powermate that conflists with\

grifcat/libusb USB interface conflict\


set +e
sudo rmmod powermate

stdbuf -oL /home/volumio/grifcat |
while IFS= read -r line
do\

echo “$line”\


#grifcat --led-on

\

Press Powermate knob down and shutdown rpi\

(or change code for volume muting)\


case “$line” in
own)

echo “SHUTDWN !!!”

killall grifcat
sudo /home/volumio/grifcat --led-pmode=2
volumio volume 44
sleep 4
shutdown -Fh now


STARTTIME=$(date +%s)

echo “STARTTIME”,$STARTTIME

\

Commented out mute volume code\

mpc volume 44\

amixer -c 1 sset “Digital” 44% -M\


;;

esac


#Turn Powermate clockwise and increase volume

case “$line” in
Cw)

#echo “UP Vol”


varitic=$(($varitic+1))

#echo “varitic=”, $varitic, “step=”,$step
#sleep 10


if [ “$varitic” -ge “$step” ]

then

#HiFiberry board command to increase volume\

mpc volume +1\


#IQAudio board command to increase volume\

amixer -c 1 sset “Digital” 1%+ -M\


#Volumio CLI increase volume by 1 (1-100)
volumio volume plus

#sleep 10
\

Variable step volume control. Step = f(vol)\

vol=$(mpc | grep -o -E ‘[0-9]+’ | head -1)\


##echo $vol,"<=Vol"
##sleep 10
\

if [ “$vol” -gt 60 ]; then step=5; else step=1; fi\

if [ “$vol” -gt 65 ]; then step=10; fi\

if [ “$vol” -gt 70 ]; then step=15; fi\

if [ “$vol” -gt 75 ]; then step=20; fi\




varitic=$((0))

#echo “got here”\

else\


#echo “up counter not vol yet”

fi

;;
esac


#Turn Powermate counter clockwise and decrease volume

case “$line” in
Ccw)
echo “DOWN Vol”

varitic=$(($varitic+3))

if [ “$varitic” -ge “$step” ]

then

#HiFiberry board command to decrease volume\

mpc volume -1\


#IQAudio board command to decrease volume\

amixer -c 1 sset “Digital” 1%- -M\


#Volumio CLI decrease volume by 1 (1-100)
volumio volume minus

varitic=$((0))

fi

;;
esac

\

Four quick tap shutdown code\

Currently not used\


case “$line” in
Nc)\

echo four press SHUTDOWN SYSTEM\


ENDTIME=$(date +%s)
DIFF=$((ENDTIME-STARTTIME))

#echo “STARTTIME”,$STARTTIME
#echo “ENDTIME”,$ENDTIME
#echo “DIFF”,$DIFF

if [ “$DIFF” -gt 3 ]; then
echo “shutdown”\

killall grifcat\

sudo grifcat --led-pmode=2\

sleep 4\

shutdown -Fh now\


fi

;;
esac

#grifcat --led-off

done


done

exit 0} [/code]

Edit /etc/rc.local file with nano editor.

[code]#!/bin/sh -e
#\

rc.local\

#\

This script is executed at the end of each multiuser runlevel.\

Make sure that the script will “exit 0” on success or any other\

value on error.\

#\

In order to enable or disable this script just change the execution\

bits.\

#\

By default this script does nothing.\


sudo /home/volumio/knobber.sh > /dev/null 2>&1 &


exit 0
} [/code]

Thank you so much for this, it definitely points me in the right direction.

Here’s how I am using USB PowerMate with Volumio 2.565 .

An USB DAC and an USB PowerMate are connected to My Raspberry pi 3B+.
Specification:

  • Rotate the knob to change the volume
  • Push the knob to switch between two internet radio channels;
    Venice classic radio and Capital UK.

Precedures:

  1. Download “input-event.js” from github.com/risacher/input-event
  2. Prepare following “pmate.js”


var inputevent = require('input-event.js');
var pm = new inputevent('event1');
// 'event1' is the file corresponding to my PowerMate in /dev/input/
// cat /proc/bus/input/devices 
var io=require('socket.io-client');
var socket= io.connect('http://localhost:3000');

// set initial volume value
var vol = 3 ;
socket.emit('volume', vol);

// Create play lists if empty
socket.emit('listPlaylist');
socket.on('pushListPlaylist', function(data) {
   if (data.length == 0) {

    socket.emit('createPlaylist',{"name":"Venice Classic Radio"});
    socket.emit('addToPlaylist',{
        "name":"Venice Classic Radio",
        "service":"webradio",
        "uri":"http://174.36.206.197:8000"
        });
    socket.emit('createPlaylist',{"name":"Capital FM"});
    socket.emit('addToPlaylist',{
        "name":"Capital FM",
        "service":"webradio",
        "uri":"http://media-ice.musicradio.com/CapitalMP3"
        });
    }
});

var playlist = 1 ;

pm.on('keypress', pm => {
    if (playlist == 1) {
        socket.emit('playPlaylist',{name:"Venice Classic Radio"});
        playlist = 2
        }
    else {
        socket.emit('playPlaylist',{name:"Capital FM"});
        playlist = 1
        }
    });


pm.on('rel', pm => {
  var direction = pm.value === 1 ? 1 : -1
// get current volume value
 socket.emit('getState', '');
 socket.on('pushState', function(data) {
   vol = data.volume ;  
 });
  vol = vol + direction ;
// volume limitter
  if (vol < 0) vol = 0 ;
  if (vol > 50) vol = 50 ;
  socket.emit('volume', vol);
});

Note:
“event1” in the second line may vary depending on your USB devices.
“event1” is the file corresponding to MY PowerMate in /dev/input/ .
Find YOUR eventX using cat /proc/bus/input/devices .

  1. Login to Volumio and install two node modules.
sudo su
npm install socket.io-client
npm install -g forever
  1. Copy above “input-event.js” file to
/home/volumio/node_modules

Note: If it is write-protected, change the propety by

chmod 777 /home/volumio/node_modules
  1. Copy above “pmate.js” to
 /home/volumio
  1. Run
node pmate.js &

If you turn the knob, the display of Volumio will be linked, and if you press the knob, the channel should be switched.

If it doesn’t work, make sure if the Volumio>Playback Options>Volume options>Mixer type is set to Hardware.
You may check if your powermate is assigned to “event1” using “cat /proc/bus/input/devices”.

  1. If it is OK, write a node command in /etc/rc.local to run “pmate.js” automatically at restart.
nano /etc/rc.local

Paste the following before “exit 0”.

node /home/volumio/node_modules/forever/bin/forever start /home/volumio/pmate.js

When you reboot, “pmate.js” should run.

Due to the recent update of socket.io-client, please specify the version when you install the module as follows:

sudo npm install socket.io-client@2.3.1