Griffin powermate

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]