Publié le : 25/04/2016 20:41:49
Catégories : Tutoriels
Rasberry Pi B+/2/3 GPIO NumbersLight up the pushbutton
Using our illuminated metal pushbutton, you will have to wire the + pin to a Raspberry GPIO (eg. GPIO 14 (pin 8)) and the - pin to a GND Raspberry pin. You need to configure the pin to be "up". We will provide script soon.
If using long pushbutton wire the NO and C pins. For our short pushbutton, wire the 2 other pins. Wire (NO) and (C) pins to a free GPIO and to a GND pin. We recommend GPIO3 if you are not using an i2c DAC.
Note from the Hifiberry team: HifiBerry boards use GPIO3 so "while it won’t harm the board, it might have an impact on the function of the board. I would strongly recommend to use another GPIO for this. Otherwise the HiFiBerry board might stop working."
You need to install Rpi.GPIO library first for this to work. See "HOW TO CONFIGURE OPENELEC by Arnaud P" to know how to proceed.
cd /storage/downloads
Download our script on Sourceforge :
wget https://sourceforge.net/projects/script-xbmc-nuxii-button/files/script.xbmc.nuxii.button.zip/download -O script.xbmc.nuxii.button.zip
From the Kodi Menu :
System > Settings > Add-ons > Install from zip file > Home folder > downloads > script.xbmc.nuxii.button.zip
You can configure the GPIO you use, the refresh rate and what happens when you push a button.
System > Settings > Add-ons > Services > NuXii Button Controller > Configure
Available actions:
Mute()
Reboot()
Shutdown()
ActivateScreensaver()
UpdateLibrary(video)
PlayerControl(Play)
RefreshRSS()
default: Shutdown()
Sources files are located at: /storage/.kodi/addons/script.xbmc.nuxii.button/
Warning: If you change a setting or if you need to modify the addon, you should reboot first and after you change
IRLED
mount -o remount,rw /flash
nano /flash/config.txt
Add the following to config.txt
dtoverlay=lirc-rpi,gpio_in_pin=17,gpio_out_pin=7
then ctrl+x to save.
mount -o remount,ro /flash
reboot
If you have a Nuxii Remote control:
nano /storage/.config/lircd.conf
copy this code
# Please make this file available to others
# by sending it to <lirc@bartelmus.de> #
# this config file was automatically generated
# using lirc-0.9.0(default) on Sun Nov 22 15:27:29 2015 #
# contributed by #
# brand: ./nuxii-remote-lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin
remote name ./nuxii-remote-lircd.conf
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 9029 4446
one 607 1630
zero 607 497
ptrail 607
repeat 9034 2182
pre_data_bits 16
pre_data 0xFF
gap 107947
toggle_bit_mask 0x0
begin codes
KEY_HOME 0x609F
KEY_BACK 0x18E7
KEY_UP 0x629D
KEY_DOWN 0x6897
KEY_LEFT 0xE21D
KEY_RIGHT 0xA857
KEY_OK 0xAA55
KEY_PLAY 0x02FD
KEY_STOP 0x20DF
KEY_FASTFORWARD 0x0AF5
KEY_REWIND 0x2AD5
KEY_VOLUMEUP 0x28D7
KEY_VOLUMEDOWN 0x08F7
end codes
end remote
then ctrl+x to save. Reboot and your remote control should work
You need to install Rpi.GPIO library for this to work. See "HOW TO CONFIGURE OPENELEC by Arnaud P" to know how to proceed.
cd /storage/downloads
Download our script on Sourceforge :
wget https://sourceforge.net/projects/script-xbmc-nuxii-led/files/script.xbmc.nuxii.led.zip/download -O script-xbmc-nuxii-led.zip
From the Kodi Menu :
System > Settings > Add-ons > Install from zip file > Home folder > downloads > script.xbmc.nuxii.led.zip
You can configure the GPIO you use and the condition where they light up.
System > Settings > Add-ons > Services > NuXii Components Controller > Configure
Source: http://wiki.openelec.tv
Raspberry Pi B+/2/3 GPIO Numbers
ARNAUD P.
README_Power_ON_OFF README_Lirc
From the Kodi Menu:
System > Settings > Add-ons > Install from Repo > OpenELEC Add-ons (Official) > Add on Repo > OpenELEC Add-ons (Unofficial)
Then go to:
OpenELEC Add-ons (Unofficial) > RPi.GPIO > Install
Reboot
Power button pinout : Pin5(GPIO3) & Pin6 (GND)
mkdir /storage/scripts
nano /storage/scripts/shutdown.py
Then add:
#!/usr/bin/python
import sys
sys.path.append('/storage/.kodi/addons/python.RPi.GPIO/lib')
import RPi.GPIO as GPIO
import time
import subprocess
time.sleep(15)
# we will use the pin numbering to match # the pins on the Pi, instead of the
# GPIO pin outs (makes it easier to keep track of things)
GPIO.setmode(GPIO.BOARD)
# use the same pin that is used for
# the reset button (one button to rule them all!)
GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)
oldButtonState1 = True
while True:
#grab the current button state
buttonState1 = GPIO.input(5)
# check to see if button has been pushed
if buttonState1 != oldButtonState1 and buttonState1 == False:
subprocess.call("shutdown -h now", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
oldButtonState1 = buttonState1
time.sleep(.5)
nano /storage/.config/autostart.sh
add:
python /storage/scripts/shutdown.py &
Reboot system then check if working
disable:
HDMI CEC => System => System => Input Devices => Peripherals (Unable HDMI CEC)
Reboot
nano /flash/config.txt
Add followings (Lirc Support):
dtoverlay=lirc-rpi,gpio_in_pin=17
reboot
dmesg | grep 'lirc'
[ 3.667447] lirc_dev: IR Remote Control driver registered, major 248 [ 3.681240] lirc_rpi: module is from the staging directory, the quality is unknown, you have been warned.
[ 4.528984] lirc_rpi: module is from the staging direcmount -o remount,rw /flashtory, the quality is unknown, you have been warned.
[ 4.575834] lirc_rpi: auto-detected active low receiver on GPIO pin 18
[ 4.576185] lirc_rpi lirc_rpi: lirc_dev: driver lirc_rpi registered at minor = 0
[ 4.576199] lirc_rpi: driver registered!
[ 5.448860] input: lircd as /devices/virtual/input/input0
mode2 -d /dev/lirc0
Then check answer by pushing button
echo "killall lircd; /usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --output=/var/run/lirc/lircd --pidfile=/var/run/lirc/lircd-lirc0.pid /storage/.config/lircd.conf" >> /storage/.config/autostart.sh
killall lircd irrecord -d /dev/lirc0 /storage/.config/lircd.conf
KEY_BACK
KEY_HOME
KEY_UP
KEY_DOWN
KEY_LEFT
KEY_RIGHT
KEY_SELECT
KEY_STOP
KEY_PLAY
KEY_REWIND
KEY_FORWARD
KEY_VOLUMEDOWN
KEY_VOLUMEUP
irw
Then check if working