Griffin powermate

Thanks for your detail reply.

I think I have the powermate udev rules all setup AOK. The evrouter program would not even run with it ready to read the powemate dev until this was done.

Also on the rpi B+ once you plug in the powermate and do a lsusb the device number never changes. I never even setup any udev rules for the powermate but it remained stable at the same number always on the rpi B+. However, on the rpi2, with the rules or without the rules for the powermate device the powermate device number keeps increasing. The powermate detaches and reattaches all the time. It starts out a low number less then 10 and by the next morning it is up to 120+.

Wonder were I can / should report the powermate driver error ?

Hold the horses. I think I have found a much easier approach then the evrouter or the gizmod (gizmo daemon) others have used to redirect the powermate to shell commands.

The evrouter and gizmod approaches require X to run. So why not use the xbindkeys tool that comes with X. You can use this tool to setup a action that’s associated with a button being pressed. This is done purely by entering the proper values in a config file. The link below shows how easy it is to setup a xbindkeys config file so a particular shell command (xterm in the example) is issued whenever a defined mouse button is pressed.

unix.stackexchange.com/questions … or-command
(check out the reference links on the bottom as they are great for udev knowledge)

Also with X it appears you will get Griffin Powermate device setup. I guess the Powermate is used allot on Linux boxes used as numerical controllers. See the support detail and what to look for on control output to X from a Powermate at the following link.

lists.x.org/archives/xorg/2009-April/045234.html
(you have to read up and down the thread to see all the info and the bug solution approach.)

The issue with the bad Powermate driver on the rpi2 remains. Any help on where that issue should be reported is most needed and appreciated.

The other problem also still remains, how do you install all of X on to Volumio 1.55 and not break it? We should make sure that all of X is included in Volumio 2 also.

The approach is great for ANY USB device that X knows about, and that list is huge. So just plug in an old USB mouse into your Volumio and run xev to see the X output protocol for each button or wheel turn of the device and then edit a config file and put in mpc and other shell commands using xbindkeys configuration method to control your Volumio node thru the USB mouse.

I can see folks taking apart a five button mouse with scroll wheels to get total control of their Volumio in the form factor they want and NO SOLDERING. Plus if you use an LED mouse the LED can be treated as a “the kernel is up and USB bus is a active” when the light is on and the hardware is shutdown when the mouse LED light is off.

Lets see, no soldering, complete volume and multiple button control, including a safe shutdown button, with an ON/OFF light for $20-30 by setting up a config file. Sounds good to me.

Why not include full X in Volumio 2 ?!?

No, because of the goal and design of volumio. It’s made for audio.

It should be installable though. A goal for volumio 2 is an apt repository this should make it harder to break.

Awesome. Thanks for the input.

So to test this xbindkeys approach to control a headless rpi with USB devices issuing shell commands I will work with standard Raspbian on a plain rpi2 with no DAC… I will then try and have shell commands issued from a Griffin Powermate, Apple mouse and Microsoft Intellimouse.

Already I had to install the following packages on top of the standard vanilla GUI boot image of Raspbian.

xinput
xbindkeys
xbindkeys-config

Yes the xbindkeys and xinput with shell script methods both work.

Did the test on Raspbian stock with boot to GUI.

Setup button 8 on Microsoft intelli-mouse to perform a reboot.

xinput command is very useful too. States device name and button state. Ran shell script that displays the button # and its state.

Not so lucky with the Griffin Powermate tho. Seems I can not get X to recognize the Powermate. Must make sure that all my udev permissions are done correctly. You see the Powermate with the lsusb command. In fact here is the verbose output of lsusb just for the Powermate:

Bus 001 Device 011: ID 077d:0410 Griffin Technology PowerMate Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x077d Griffin Technology idProduct 0x0410 PowerMate bcdDevice 4.00 iManufacturer 1 Griffin Technology, Inc. iProduct 2 Griffin PowerMate iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 41 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 4 Media Controller bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 0 No Subclass bInterfaceProtocol 0 None iInterface 5 Endpoint 1 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.00 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 74 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0006 1x 6 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0001 1x 1 bytes bInterval 10 Device Status: 0x0000 (Bus Powered)

This is output of xinput -list with the Powermate plugged into the rpi2.

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Macally iKeySlim Macally iKeySlim         id=7    [slave  pointer  (2)]
⎜   ↳ Mitsumi Electric Apple Optical USB Mouse  id=9    [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Macally iKeySlim Macally iKeySlim         id=6    [slave  keyboard (3)]

Don’t know why X does not see the Powermate. Not sure how to troubleshoot the udev permission either. Setup all the rules.d for the Powermate identical to the folks who get the Powermate to work using the evrouter program. Still X never see’s the Powermate.

Wonder why no one posted anywhere on the web getting the Powermate to work with the xbindkeys method. Seems all Linux users with the Powermate are using the evrouter or gizmod programs, and I do not know why?

BTW here is the output of the command:

egrep “” /proc/bus/input/devices

with just the Apple mouse, MacAlly keyboard and Powrmate plugged into the rpi2.

I: Bus=0003 Vendor=2222 Product=0013 Version=0110
N: Name="Macally iKeySlim Macally iKeySlim"
P: Phys=usb-3f980000.usb-1.3.1/input0
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/0003:2222:0013.0002/input/input0
U: Uniq=
H: Handlers=sysrq kbd event0
B: PROP=0
B: EV=120013
B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=7

I: Bus=0003 Vendor=2222 Product=0013 Version=0110
N: Name="Macally iKeySlim Macally iKeySlim"
P: Phys=usb-3f980000.usb-1.3.1/input1
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.1/0003:2222:0013.0003/input/input1
U: Uniq=
H: Handlers=kbd mouse0 event1
B: PROP=0
B: EV=17
B: KEY=10000000 0 0 70000 10000 10000 17a 0 e0000 0 0 0
B: REL=103
B: MSC=10

I: Bus=0003 Vendor=05ac Product=0304 Version=0110
N: Name="Mitsumi Electric Apple Optical USB Mouse"
P: Phys=usb-3f980000.usb-1.4/input0
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:05AC:0304.0001/input/input3
U: Uniq=
H: Handlers=mouse2 event3
B: PROP=0
B: EV=100017
B: KEY=f0000 0 0 0 0 0 0 0 0
B: REL=143
B: MSC=10

I: Bus=0003 Vendor=077d Product=0410 Version=0400
N: Name="Griffin PowerMate"
P: Phys=usb-3f980000.usb-1.3.2/input0
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.2/1-1.3.2:1.0/input/input6
U: Uniq=
H: Handlers=event2
B: PROP=0
B: EV=17
B: KEY=1 0 0 0 0 0 0 0 0
B: REL=80
B: MSC=2

The fact that the Powermate does not have a mouse handler may be the issue as to why X does not see it. Don’t know tho for sure.

OK success running the evrouter program with the Griffin Powermate on a rpi2 (no I2C DAC card) on a Raspbian GIU install.

Questions about the Powermate rpi2 driver and issues that X seemed not to recognize the Powermate as a HID were not answered. I thought possibly even IF I had the permissions all setup correctly for the Powermate, udev and X the Powermate may not be recognized by X as it may not be in its database of HID. Or said another way possibly X does not have the Powermate in its list of input devices it recognizes (if that is even an issue). Of course having the Powermate recognized by X is required for using either the xbindkeys or xinput --query-states script approaches.

Therefore I installed evrouter on a rpi2 with standard Raspbian that boots to GUI. Then I ran evrouter in debug mode to get output of Powermate control characters. Worked perfectly showing what control characters the Powermate outputs for each turn or knob press.

Then I created /etc/udev/rules.d/powermate.rules with the following content:

SUBSYSTEM=="input", ATTRS{idVendor}=="077d", ATTRS{idProduct}=="0410", SYMLINK+="powermate", MODE="660", GROUP="video"

Made sure user pi was a member of the video group. (The setup for udev rules will be made better later on, but this works.)

Then I created evrouterrc config file with shell commands linked to Powermate output. Powermate button push does “reboot”, turn knob right does “echo Volume UP” and turn volume left does “echo Volume DOWN”. Then I open terminal in GUI and run the following command:

 sudo evrouter -c /etc/evrouterrc /dev/input/event3

and the Powermate does what it is supposed to do. Push knowb down and rpi2 reboots. Turn knob and you see Volume UP and Volume DOWN repeated on the terminal window many times !

Don’t have evrouter running automatically on a boot yet and will setup /dev to a defined device powermate (so the command sudo evrouter -c /etc/evrouterrc /dev/powermate will work) so evrouter is not tied to a specific event# as it is now.

Now the question is can I install evrouter on Volumio 1.55 and get it to run without breaking Volumio 1.55?

This is how I got evrouter to install on vanilla Raspbian boot into GUI.

sudo apt-get install update
sudo apt-get install git-core
sudo apt-get install build-essential
sudo apt-get install libX11-dev
sudo apt-get install libXtst-dev
mkdir git
cd git
git clone git://github.com/larsmagne/evrouter.git
cd evrouter
./configure
sudo make check
sudo make install

Run this command to see if evrouter will run

evrouter --help

Also this was done on top of the current Raspbian GUI boot (2015-11-21-raspbian-jessie image) which has many more modules installed (X org eg.) then Volumio 1.55.

Now I need Volumio gurus to provide knowledge if I could ever get evrouter to run on Volumio 1.55 without breaking it and how to do that.

All input is welcome.
TIA.

SUCCESS !

Ok I have the Griffin Powermate control metal knob successfully attached to a rpi2 Volumio 1.55 node.

I used a C++ program called grifcat that only needed the libusb library. All other (much easier) solutions require X11 packages which when installed on Volumio in order to have an X server running cause Volumio to fail.

The Powermate works great with Volumio on a rpi2. Also running a HiFiberry Amp+ with it.

As the amp and speakers find their “sweet spot”, the the knob gets very sensitive. That is to say the approximate one degree turn of the knob still only allowed mdp to increase by delta 1% (mpc increase +1). However the increase in volume from 33% to 34% doesn’t sound that much louder. However the same 1 degree turn also takes mdp from 79% to 80% and that DOES seem much louder.

Sooooo, since we are a fly by wire control I wrote a stepped shell control script. As the volume increases you need more degrees of turning to add that delta 1% more in mpd volume. Works great and flattens out the control at the high end. Left volume down alone because when you want volume down speed is AOK. When you press the knob the mdp mutes

The sw installation works (thru setup, configurations and coding) on a headless boot and has total hotplug capabilities. Plug in the Powermate after boot, unplug and replug to different SB port it all doesn’t matter the Powermate just works.

The sound control is spontaneous. This does require CPU cycles that always seem <6% most of the time for grifcat and the shell script. If you spin the knob several times righ then left you can peak out around 20% for both tasks when running top.

Let me know if anyone wants source codes and installation instructions for this wired control device.

BTW found a fatal sw bug in Volumio 1.55, but as development has shifted to Volumio 2 it probably will not get solved. If you attach a 5 Ghz WiFi USB adapter and configure it in Volumio 1.55 browser interface all works fine. However when you reboot you loose ALL (wired and wifi) network connections and boot into single user mode. Very ugly, so don’t setup for 5GHz AP’s.

GREAT to see you have it working!
I believe congratulations are in order!

A C++ program that directly reads libusb works on a much lower level than when you tried it trough X11.
That is exactly the route I wanted to point you into. You say that the other solutions that require X11 are much easier, but in fact they turned out to be much harder to get working. :mrgreen:

I think, that if you would compare the cpu load this could even be lower load for the overall device than the x11 solutions. They need more processes thus more ram, more cpu cycles and more storage. Granted you wont notice the storage, but you kept it a truly headless system. :smiley:

Oh and that bug is worthy of a bug report :wink: makes it better to find for others.

@cmullen

nice work,
i would like to buy a griffin knob too but since it is expenxive, i would like to know if it would the whole thing still work with volumio 2.0??

thx in advance

@cmullen. have you had any luck with powermate on Volumio 2?

Yes have Griffin Powermate working with Volumio2. Was quite easy to do. Let me know if you want the details. Using the IQaudio Amp+. The command to incease / decrease volume is different for HiFiberry and IQaudio HAT boards.

You have to know the cli to change volume fir you amp board. It’s probably an mpc or amixer command. This is because you are controlling via fly by wire and sw.

@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