OK i installed:
sudo apt-get install python-pip python-dev
sudo pip install -U RPi.GPIO
Of course firstly I had to add for a moment few lines to /etc/apt/sources.list to standard rasbian repository.
When I had RPi.GPIO installed I used python script writen for BeagleBone Black (bbb):
github.com/francolargo/BBB-audi … er/leds.py
and adopted to my RPI.
I used GPIO17, 27,22 just like in the drawing from the article I mentioned in my first post:
If you use Ir control (Lirc) with standard gpio_in and out pins eg. GPIO 17, 18 you have to change GPIO17 assignment since there will be GPIO pins conflict. I changed IR pins to: ‘lirc_rpi gpio_in_pin=23 gpio_out_pin=4’
The running script drives shining of three LED’ RGB colors.
It is configured to display:
white color when no playback
green =44,1kHz
blue when =48 kHz
light blue=88/176;
yellow/orange=96/192
You can define your favorite colors.
The script:
[code]#!/usr/bin/env python
-- coding: utf-8 --
import RPi.GPIO as GPIO
import time
GPIO setup needed to address pins
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.output(11, GPIO.LOW)
GPIO.setup(13, GPIO.OUT)
GPIO.output(13, GPIO.LOW)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15, GPIO.LOW)
rate = 0
rawrate = 0
define a loop function to check hw_params every half second
def displayloop():
while True:
with open(’/proc/asound/card0/pcm0p/sub0/hw_params’) as f:
lines = f.readlines()
try:
rawrate = lines[4]
rate =(int(rawrate[6:12])/1000)
except IndexError:
rate = 0
display the sample rates being used - LED1=red, LED2=blue, LED3=green
white=no play; blue=44; green=48; light blue=88/1116; yellow(ish)=96/192
if rate == 0:
GPIO.output(11, GPIO.HIGH)
GPIO.output(13, GPIO.HIGH)
GPIO.output(15, GPIO.HIGH)
elif rate == 44:
GPIO.output(11, GPIO.LOW)
GPIO.output(13, GPIO.HIGH)
GPIO.output(15, GPIO.LOW)
elif rate == 48:
GPIO.output(11, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
GPIO.output(15, GPIO.HIGH)
elif rate == 88 or rate == 1116:
GPIO.output(11, GPIO.LOW)
GPIO.output(13, GPIO.HIGH)
GPIO.output(15, GPIO.HIGH)
elif rate == 96 or rate == 192:
GPIO.output(11, GPIO.HIGH)
GPIO.output(13, GPIO.LOW)
GPIO.output(15, GPIO.HIGH)
time.sleep (.5)
displayloop()[/code]
Of course you can run this script as a service and can run during RPI boot.
I’ve managed to put the RGB LED to the main on/off ring DAC button (my rpi board is inside aluminum DAC case). Works great. Running script consume about 0.5%CPU