Last active
February 20, 2019 17:47
-
-
Save mashurex/2af24ab520193323fee85b08f6f2c36f to your computer and use it in GitHub Desktop.
GBZ Install and Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
disable_overscan=1 | |
dtparam=i2c_arm=on | |
dtparam=spi=on | |
dtparam=audio=on | |
gpu_mem_256=128 | |
gpu_mem_512=256 | |
gpu_mem_1024=256 | |
dtoverlay=pwm,pin=18,func=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Updating packages..." | |
sudo apt-get update | |
echo "Installing required packages..." | |
sudo apt-get -y install git build-essential python-dev cmake | |
if [ ! -f /usr/local/bin/retrogame ]; then | |
cd /home/pi | |
echo "Downloading and installing Adafruit-Retrogame binary..." | |
curl -f -s -o /tmp/retrogame https://raw.githubusercontent.com/adafruit/Adafruit-Retrogame/master/retrogame | |
sudo mv /tmp/retrogame /usr/local/bin | |
sudo chmod 755 /usr/local/bin/retrogame | |
sudo sed -i '/\"exit 0\"/!s/exit 0/\/usr\/local\/bin\/retrogame \&\nexit 0/g' /etc/rc.local | |
fi | |
if [ ! -f /boot/retrogame.cfg ]; then | |
cd /home/pi | |
echo "Installing retrogame.cfg..." | |
cat > retrogame.cfg <<EOF | |
UP 26 # 'UP' button | |
DOWN 13 # 'DOWN' button | |
LEFT 19 # 'LEFT' Button | |
RIGHT 6 # 'RIGHT' button | |
A 12 # 'A' Button | |
B 7 # 'B' button | |
X 22 # 'X' button | |
Y 23 # 'Y' button | |
ENTER 0 # 'ENTER' button | |
SPACE 5 # 'SELECT' button | |
L 21 # 'Left' Shoulder button | |
R 20 # 'Right' Shoulder button | |
EOF | |
sudo chown root:root retrogame.cfg | |
sudo chmod 555 retrogame.cfg | |
sudo cp retrogame.cfg /boot/retrogame.cfg | |
fi | |
if [ ! -f /etc/udev/rules.d/10-retrogame.rules ]; then | |
echo "Installing Retrogame SDL Config..." | |
sudo cat > /etc/udev/rules.d/10-retrogame.rules <<EOF | |
SUBSYSTEM=="input", ATTRS{name}=="retrogame", ENV{ID_INPUT_KEYBOARD}="1" | |
EOF | |
fi | |
if [ ! -f /home/pi/.emulationstation/es_temporaryinput.cfg ]; then | |
cat > /home/pi/.emulationstation/es_input.cfg <<EOF | |
<?xml version="1.0"?> | |
<inputList> | |
<inputAction type="onfinish"> | |
<command>/opt/retropie/supplementary/emulationstation/scripts/inputconfiguration.sh</command> | |
</inputAction> | |
<inputConfig type="keyboard" deviceName="Keyboard" deviceGUID="-1"> | |
<input name="pageup" type="key" id="108" value="1"/> | |
<input name="start" type="key" id="13" value="1"/> | |
<input name="down" type="key" id="1073741905" value="1"/> | |
<input name="pagedown" type="key" id="114" value="1"/> | |
<input name="right" type="key" id="1073741903" value="1"/> | |
<input name="select" type="key" id="32" value="1"/> | |
<input name="left" type="key" id="1073741904" value="1"/> | |
<input name="up" type="key" id="1073741906" value="1"/> | |
<input name="a" type="key" id="97" value="1"/> | |
<input name="b" type="key" id="98" value="1"/> | |
<input name="x" type="key" id="120" value="1"/> | |
<input name="y" type="key" id="121" value="1"/> | |
</inputConfig> | |
</inputList> | |
EOF | |
cat > /home/pi/.emulationstation/es_temporaryinput.cfg <<EOF | |
<?xml version="1.0"?> | |
<inputList> | |
<inputConfig type="keyboard" deviceName="Keyboard" deviceGUID="-1"> | |
<input name="a" type="key" id="97" value="1" /> | |
<input name="b" type="key" id="98" value="1" /> | |
<input name="down" type="key" id="1073741905" value="1" /> | |
<input name="hotkeyenable" type="key" id="32" value="1" /> | |
<input name="left" type="key" id="1073741904" value="1" /> | |
<input name="leftshoulder" type="key" id="108" value="1" /> | |
<input name="right" type="key" id="1073741903" value="1" /> | |
<input name="rightshoulder" type="key" id="114" value="1" /> | |
<input name="select" type="key" id="32" value="1" /> | |
<input name="start" type="key" id="13" value="1" /> | |
<input name="up" type="key" id="1073741906" value="1" /> | |
<input name="x" type="key" id="120" value="1" /> | |
<input name="y" type="key" id="121" value="1" /> | |
</inputConfig> | |
</inputList> | |
EOF | |
sudo chown pi:pi /home/pi/.emulationstation/es_*.cfg | |
sudo chmod 777 /home/pi/.emulationstation/es_*.cfg | |
fi | |
if [ ! -f /home/pi/.ads1x15 ]; then | |
cd /home/pi | |
if [ ! -d Adafruit_Python_ADS1x15 ]; then | |
echo "Cloning Adafruit ADS1x15 Python library..." | |
git clone https://github.com/adafruit/Adafruit_Python_ADS1x15.git | |
fi | |
cd Adafruit_Python_ADS1x15 | |
if [ ! -f setuptools-3.5.1.zip ]; then | |
if [ -f /boot/setuptools-3.5.1.zip ]; then | |
sudo cp /boot/setuptools-*.zip . | |
else | |
echo "Downloading setuptools-3.5.1.zip..." | |
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.5.1.zip | |
fi | |
fi | |
echo "Installing Adafruit ADS1x15 Python library..." | |
sudo python setup.py install | |
touch /home/pi/.ads1x15 | |
if [ -f /boot/setuptools-3.5.1.zip ]; then | |
echo "Removing setuptools from /boot..." | |
sudo rm -f /boot/setuptools-3.5.1.zip | |
fi | |
rm -rf Adafruit_Python_ADS1x15 | |
fi | |
if [ ! -f /home/pi/.minty ]; then | |
cd /home/pi | |
wget https://raw.githubusercontent.com/HoolyHoo/Mintybatterymonitor/master/MintyInstall.sh | |
chmod +x MintyInstall.sh | |
if [ ! -d Mintybatterymonitor ]; then | |
echo "Installing Minty Battery Monitor..." | |
git clone https://github.com/HoolyHoo/Mintybatterymonitor.git | |
echo "Reconfiguring MintStart.sh..." | |
cat > Mintybatterymonitor/MintyStart.sh <<EOF | |
#!/usr/bin/env bash | |
python /home/pi/Mintybatterymonitor/MintyBatteryMonitor.py & | |
EOF | |
fi | |
sudo ./MintyInstall.sh | |
touch /home/pi/.minty | |
rm -f MintyInstall.sh | |
fi | |
if [ ! -f /home/pi/.fbcp ]; then | |
echo "Installing RPi FBCP..." | |
cd /home/pi | |
if [ ! -d rpi-fbcp ]; then | |
git clone https://github.com/tasanakorn/rpi-fbcp.git | |
fi | |
cd rpi-fbcp | |
rm -rf build | |
mkdir build | |
cd build | |
cmake .. | |
make | |
sudo cp fbcp /usr/bin | |
sudo chmod 777 /usr/bin/fbcp | |
cd /home/pi | |
sudo sed -i '/\"exit 0\"/!s/exit 0/\/usr\/bin\/fbcp \&\nexit 0/g' /etc/rc.local | |
touch .fbcp | |
rm -rf rpi-fbcp | |
fi | |
if [ ! -f /home/pi/safe.py ]; then | |
cd /home/pi | |
echo "Installing safe shutdown script..." | |
cat > safe.py <<EOF | |
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import os, time | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Power switch | |
GPIO.setup(17, GPIO.OUT) #ON control | |
GPIO.output(17, GPIO.HIGH) | |
while True: | |
if (GPIO.input(27)): | |
time.sleep(1.00) | |
else: | |
print ("Shutting down...") | |
os.system("sudo shutdown -h now") | |
break | |
EOF | |
sudo chmod 777 /home/pi/safe.py | |
sudo sed -i '/\"exit 0\"/!s/exit 0/\/home\/pi\/safe.py \&\nexit 0/g' /etc/rc.local | |
fi | |
if [ ! -f /home/pi/.fbtft ]; then | |
sudo raspi-config nonint do_spi 0 | |
sudo raspi-config nonint do_overscan 1 | |
sudo cat > /etc/modprobe.d/fbtft.conf <<EOF | |
options fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24 speed=80000000 fps=60 bgr=1 rotate=90 custom=1 | |
EOF | |
sudo cat >> /etc/modules <<EOF | |
spi-bcm2835 | |
fbtft_device | |
EOF | |
touch /home/pi/.fbtft | |
sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24 speed=80000000 fps=60 bgr=1 rotate=90 | |
con2fbmap 1 1 | |
fi | |
sudo chown -R pi:pi /home/pi | |
echo "Done." | |
echo | |
echo "Rebooting..." | |
reboot | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment