Browse Source

adafruit-pitft: add python-dev to apt-get install list (needed for pip)

Phillip Burgess 1 year ago
parent
commit
be3e0fba5d
2 changed files with 221 additions and 1 deletions
  1. 1
    1
      adafruit-pitft.sh
  2. 220
    0
      rgb-matrix.sh.bak

+ 1
- 1
adafruit-pitft.sh View File

@@ -189,7 +189,7 @@ reconfig() {
189 189
 
190 190
 function softwareinstall() {
191 191
     echo "Installing Pre-requisite Software...This may take a few minutes!"
192
-    apt-get install -y bc fbi git python-pip python-smbus python-spidev evtest tslib libts-bin 1> /dev/null  || { warning "Apt failed to install software!" && exit 1; }
192
+    apt-get install -y bc fbi git python-dev python-pip python-smbus python-spidev evtest tslib libts-bin 1> /dev/null  || { warning "Apt failed to install software!" && exit 1; }
193 193
     pip install evdev 1> /dev/null  || { warning "Pip failed to install software!" && exit 1; }
194 194
 }
195 195
 

+ 220
- 0
rgb-matrix.sh.bak View File

@@ -0,0 +1,220 @@
1
+#!/bin/bash
2
+
3
+# INSTALLER SCRIPT FOR ADAFRUIT RGB MATRIX BONNET OR HAT
4
+
5
+# hzeller/rpi-rgb-led-matrix sees lots of active development!
6
+# That's cool and all, BUT, to avoid tutorial breakage,
7
+# we reference a specific commit (update this as needed):
8
+GITUSER=https://github.com/hzeller
9
+REPO=rpi-rgb-led-matrix
10
+COMMIT=58830f7bb5dfb47fc24f1fd26cd7c4e3a20f13f7
11
+
12
+if [ $(id -u) -ne 0 ]; then
13
+	echo "Installer must be run as root."
14
+	echo "Try 'sudo bash $0'"
15
+	exit 1
16
+fi
17
+
18
+clear
19
+
20
+echo "This script installs software for the Adafruit"
21
+echo "RGB Matrix Bonnet or HAT for Raspberry Pi."
22
+echo "Steps include:"
23
+echo "- Update package index files (apt-get update)"
24
+echo "- Install prerequisite software"
25
+echo "- Install RGB matrix driver software"
26
+echo "- Configure boot options"
27
+echo "Run time ~10 minutes. Some options require reboot."
28
+echo "EXISTING INSTALLATION, IF ANY, WILL BE OVERWRITTEN."
29
+echo
30
+echo -n "CONTINUE? [y/N] "
31
+read
32
+if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
33
+	echo "Canceled."
34
+	exit 0
35
+fi
36
+
37
+# FEATURE PROMPTS ----------------------------------------------------------
38
+# Installation doesn't begin until after all user input is taken.
39
+
40
+INTERFACE_TYPE=0
41
+INSTALL_RTC=0
42
+QUALITY_MOD=0
43
+
44
+# Given a list of strings representing options, display each option
45
+# preceded by a number (1 to N), display a prompt, check input until
46
+# a valid number within the selection range is entered.
47
+# Can we pass an array?
48
+selectN() {
49
+	args=("${@}")
50
+	for ((i=0; i<$#; i++)); do
51
+		echo $((i+1)). ${args[$i]}
52
+	done
53
+	echo
54
+	REPLY=""
55
+	while :
56
+	do
57
+		echo -n "SELECT 1-$#: "
58
+		read
59
+		if [[ $REPLY -ge 1 ]] && [[ $REPLY -le $# ]]; then
60
+			return $REPLY
61
+		fi
62
+	done
63
+}
64
+
65
+OPTION_NAMES=(NO YES)
66
+
67
+INTERFACES=( \
68
+  "Adafruit RGB Matrix Bonnet" \
69
+  "Adafruit RGB Matrix HAT + RTC" \
70
+)
71
+
72
+QUALITY_OPTS=( \
73
+  "Quality (disables sound, requires soldering)" \
74
+  "Convenience (sound on, no soldering)" \
75
+)
76
+
77
+echo
78
+echo "Select interface board type:"
79
+selectN "${INTERFACES[@]}"
80
+INTERFACE_TYPE=$?
81
+
82
+if [ $INTERFACE_TYPE -eq 2 ]; then
83
+	# For matrix HAT, ask about RTC install
84
+	echo
85
+	echo -n "Install realtime clock support? [y/N] "
86
+	read
87
+	if [[ "$REPLY" =~ (yes|y|Y)$ ]]; then
88
+		INSTALL_RTC=1
89
+	fi
90
+fi
91
+
92
+echo
93
+echo "Now you must choose between QUALITY and CONVENIENCE."
94
+echo
95
+echo "QUALITY: best output from the LED matrix requires"
96
+echo "commandeering hardware normally used for sound, plus"
97
+echo "some soldering.  If you choose this option, there will"
98
+echo "be NO sound from the audio jack or HDMI (USB audio"
99
+echo "adapters will work and sound best anyway), AND you"
100
+echo "must SOLDER a wire between GPIO4 and GPIO18 on the"
101
+echo "Bonnet or HAT board."
102
+echo
103
+echo "CONVENIENCE: sound works normally, no extra soldering."
104
+echo "Images on the LED matrix are not quite as steady, but"
105
+echo "maybe OK for most uses.  If eager to get started, use"
106
+echo "'CONVENIENCE' for now, you can make the change and"
107
+echo "reinstall using this script later!"
108
+echo
109
+echo "What is thy bidding?"
110
+selectN "${QUALITY_OPTS[@]}"
111
+QUALITY_MOD=$?
112
+
113
+# VERIFY SELECTIONS BEFORE CONTINUING --------------------------------------
114
+
115
+echo
116
+echo "Interface board type: ${INTERFACES[$INTERFACE_TYPE-1]}"
117
+if [ $INTERFACE_TYPE -eq 2 ]; then
118
+	echo "Install RTC support: ${OPTION_NAMES[$INSTALL_RTC]}"
119
+fi
120
+echo "Optimize: ${QUALITY_OPTS[$QUALITY_MOD-1]}"
121
+if [ $QUALITY_MOD -eq 1 ]; then
122
+	echo "Reminder: you must SOLDER a wire between GPIO4"
123
+	echo "and GPIO18, and internal sound is DISABLED!"
124
+fi
125
+echo
126
+echo -n "CONTINUE? [y/N] "
127
+read
128
+if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
129
+	echo "Canceled."
130
+	exit 0
131
+fi
132
+
133
+# START INSTALL ------------------------------------------------------------
134
+# All selections are validated at this point...
135
+
136
+# Given a filename, a regex pattern to match and a replacement string,
137
+# perform replacement if found, else append replacement to end of file.
138
+# (# $1 = filename, $2 = pattern to match, $3 = replacement)
139
+reconfig() {
140
+	grep $2 $1 >/dev/null
141
+	if [ $? -eq 0 ]; then
142
+		# Pattern found; replace in file
143
+		sed -i "s/$2/$3/g" $1 >/dev/null
144
+	else
145
+		# Not found; append (silently)
146
+		echo $3 | sudo tee -a $1 >/dev/null
147
+	fi
148
+}
149
+
150
+echo
151
+echo "Starting installation..."
152
+echo "Updating package index files..."
153
+apt-get update
154
+
155
+echo "Downloading prerequisites..."
156
+apt-get install -y --force-yes python-dev python-imaging
157
+
158
+echo "Downloading RGB matrix software..."
159
+curl -L $GITUSER/$REPO/archive/$COMMIT.zip -o $REPO-$COMMIT.zip
160
+unzip -q $REPO-$COMMIT.zip
161
+rm $REPO-$COMMIT.zip
162
+mv $REPO-$COMMIT rpi-rgb-led-matrix
163
+echo "Building RGB matrix software..."
164
+cd rpi-rgb-led-matrix
165
+if [ $QUALITY_MOD -eq 1 ]; then
166
+	HARDWARE_DESC=adafruit-hat-pwm make
167
+	cd bindings/python
168
+	python setup.py install
169
+else
170
+	HARDWARE_DESC=adafruit-hat make USER_DEFINES="-DDISABLE_HARDWARE_PULSES"
171
+	cd bindings/python
172
+	python setup.py install
173
+fi
174
+# Change ownership to user calling sudo
175
+cd ../../..
176
+chown -R $SUDO_USER:$(id -g $SUDO_USER) rpi-rgb-led-matrix
177
+
178
+
179
+# CONFIG -------------------------------------------------------------------
180
+
181
+echo "Configuring system..."
182
+
183
+if [ $INSTALL_RTC -ne 0 ]; then
184
+	# Enable I2C for RTC
185
+	raspi-config nonint do_i2c 0
186
+	# Do additional RTC setup for DS1307
187
+	reconfig /boot/config.txt "^.*dtoverlay=i2c-rtc.*$" "dtoverlay=i2c-rtc,ds1307"
188
+	apt-get -y remove fake-hwclock
189
+	update-rc.d -f fake-hwclock remove
190
+	sudo sed --in-place '/if \[ -e \/run\/systemd\/system \] ; then/,+2 s/^#*/#/' /lib/udev/hwclock-set
191
+
192
+fi
193
+
194
+if [ $QUALITY_MOD -eq 1 ]; then
195
+	# Disable sound ('easy way' -- kernel module not blacklisted)
196
+	reconfig /boot/config.txt "^.*dtparam=audio.*$" "dtparam=audio=off"
197
+else
198
+	# Enable sound (ditto)
199
+	reconfig /boot/config.txt "^.*dtparam=audio.*$" "dtparam=audio=on"
200
+fi
201
+
202
+# PROMPT FOR REBOOT --------------------------------------------------------
203
+
204
+echo "Done."
205
+echo
206
+echo "Settings take effect on next boot."
207
+if [ $INSTALL_RTC -ne 0 ]; then
208
+	echo "RTC will be enabled then but time must be set"
209
+	echo "up using the 'date' and 'hwclock' commands."
210
+fi
211
+echo
212
+echo -n "REBOOT NOW? [y/N] "
213
+read
214
+if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
215
+	echo "Exiting without reboot."
216
+	exit 0
217
+fi
218
+echo "Reboot started..."
219
+reboot
220
+exit 0

Loading…
Cancel
Save