You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

628 lines
19 KiB

  1. #!/bin/bash
  2. # Instructions!
  3. # cd ~
  4. # wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/adafruit-pitft.sh
  5. # chmod +x adafruit-pitft.sh
  6. # sudo ./adafruit-pitft.sh
  7. if [ $(id -u) -ne 0 ]; then
  8. echo "Installer must be run as root."
  9. echo "Try 'sudo bash $0'"
  10. exit 1
  11. fi
  12. UPDATE_DB=false
  13. ############################ CALIBRATIONS ############################
  14. # For TSLib
  15. POINTERCAL_28r0="4232 11 -879396 1 5786 -752768 65536"
  16. POINTERCAL_28r90="33 -5782 21364572 4221 35 -1006432 65536"
  17. POINTERCAL_28r180="-4273 61 16441290 4 -5772 21627524 65536"
  18. POINTERCAL_28r270="-9 5786 -784608 -4302 19 16620508 65536"
  19. POINTERCAL_35r0="5724 -6 -1330074 26 8427 -1034528 65536"
  20. POINTERCAL_35r90="5 8425 -978304 -5747 61 22119468 65536"
  21. POINTERCAL_35r180="-5682 -1 22069150 13 -8452 32437698 65536"
  22. POINTERCAL_35r270="3 -8466 32440206 5703 -1 -1308696 65536"
  23. POINTERCAL_28c="320 65536 0 -65536 0 15728640 65536"
  24. # for PIXEL desktop
  25. TRANSFORM_28r0="0.988809 -0.023645 0.060523 -0.028817 1.003935 0.034176 0 0 1"
  26. TRANSFORM_28r90="0.014773 -1.132874 1.033662 1.118701 0.009656 -0.065273 0 0 1"
  27. TRANSFORM_28r180="-1.115235 -0.010589 1.057967 -0.005964 -1.107968 1.025780 0 0 1"
  28. TRANSFORM_28r270="-0.033192 1.126869 -0.014114 -1.115846 0.006580 1.050030 0 0 1"
  29. TRANSFORM_35r0="-1.098388 0.003455 1.052099 0.005512 -1.093095 1.026309 0 0 1"
  30. TRANSFORM_35r90="-0.000087 1.094214 -0.028826 -1.091711 -0.004364 1.057821 0 0 1"
  31. TRANSFORM_35r180="1.102807 0.000030 -0.066352 0.001374 1.085417 -0.027208 0 0 1"
  32. TRANSFORM_35r270="0.003893 -1.087542 1.025913 1.084281 0.008762 -0.060700 0 0 1"
  33. TRANSFORM_28c0="-1 0 1 0 -1 1 0 0 1"
  34. TRANSFORM_28c90="0 1 0 -1 0 1 0 0 1"
  35. TRANSFORM_28c180="1 0 0 0 1 0 0 0 1"
  36. TRANSFORM_28c270="0 -1 1 1 0 0 0 0 1"
  37. warning() {
  38. echo WARNING : $1
  39. }
  40. ############################ Script assisters ############################
  41. # Given a list of strings representing options, display each option
  42. # preceded by a number (1 to N), display a prompt, check input until
  43. # a valid number within the selection range is entered.
  44. selectN() {
  45. for ((i=1; i<=$#; i++)); do
  46. echo $i. ${!i}
  47. done
  48. echo
  49. REPLY=""
  50. while :
  51. do
  52. echo -n "SELECT 1-$#: "
  53. read
  54. if [[ $REPLY -ge 1 ]] && [[ $REPLY -le $# ]]; then
  55. return $REPLY
  56. fi
  57. done
  58. }
  59. function print_version() {
  60. echo "Adafruit PiTFT Helper v2.0.0"
  61. exit 1
  62. }
  63. function print_help() {
  64. echo "Usage: $0 "
  65. echo " -h Print this help"
  66. echo " -v Print version information"
  67. echo " -u [homedir] Specify path of primary user's home directory (defaults to /home/pi)"
  68. exit 1
  69. }
  70. group=ADAFRUIT
  71. function info() {
  72. system="$1"
  73. group="${system}"
  74. shift
  75. FG="1;32m"
  76. BG="40m"
  77. echo -e "[\033[${FG}\033[${BG}${system}\033[0m] $*"
  78. }
  79. function bail() {
  80. FG="1;31m"
  81. BG="40m"
  82. echo -en "[\033[${FG}\033[${BG}${group}\033[0m] "
  83. if [ -z "$1" ]; then
  84. echo "Exiting due to error"
  85. else
  86. echo "Exiting due to error: $*"
  87. fi
  88. exit 1
  89. }
  90. function ask() {
  91. # http://djm.me/ask
  92. while true; do
  93. if [ "${2:-}" = "Y" ]; then
  94. prompt="Y/n"
  95. default=Y
  96. elif [ "${2:-}" = "N" ]; then
  97. prompt="y/N"
  98. default=N
  99. else
  100. prompt="y/n"
  101. default=
  102. fi
  103. # Ask the question
  104. read -p "$1 [$prompt] " REPLY
  105. # Default?
  106. if [ -z "$REPLY" ]; then
  107. REPLY=$default
  108. fi
  109. # Check if the reply is valid
  110. case "$REPLY" in
  111. Y*|y*) return 0 ;;
  112. N*|n*) return 1 ;;
  113. esac
  114. done
  115. }
  116. function has_repo() {
  117. # Checks for the right raspbian repository
  118. # http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi firmware
  119. if [[ $(grep -h ^deb /etc/apt/sources.list /etc/apt/sources.list.d/* | grep "mirrordirector.raspbian.org") ]]; then
  120. return 0
  121. else
  122. return 1
  123. fi
  124. }
  125. progress() {
  126. count=0
  127. until [ $count -eq $1 ]; do
  128. echo -n "..." && sleep 1
  129. ((count++))
  130. done
  131. echo
  132. }
  133. sysupdate() {
  134. if ! $UPDATE_DB; then
  135. # echo "Checking for correct software repositories..."
  136. # has_repo || { warning "Missing Apt repo, please add deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi firmware to /etc/apt/sources.list.d/raspi.list" && exit 1; }
  137. echo "Updating apt indexes..." && progress 3 &
  138. sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; }
  139. echo "Reading package lists..."
  140. progress 3 && UPDATE_DB=true
  141. fi
  142. }
  143. # Given a filename, a regex pattern to match and a replacement string,
  144. # perform replacement if found, else append replacement to end of file.
  145. # (# $1 = filename, $2 = pattern to match, $3 = replacement)
  146. reconfig() {
  147. grep $2 $1 >/dev/null
  148. if [ $? -eq 0 ]; then
  149. # Pattern found; replace in file
  150. sed -i "s/$2/$3/g" $1 >/dev/null
  151. else
  152. # Not found; append (silently)
  153. echo $3 | sudo tee -a $1 >/dev/null
  154. fi
  155. }
  156. ############################ Sub-Scripts ############################
  157. function softwareinstall() {
  158. echo "Installing Pre-requisite Software...This may take a few minutes!"
  159. 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; }
  160. pip install evdev 1> /dev/null || { warning "Pip failed to install software!" && exit 1; }
  161. }
  162. # update /boot/config.txt with appropriate values
  163. function update_configtxt() {
  164. if grep -q "adafruit-pitft-helper" "/boot/config.txt"; then
  165. echo "Already have an adafruit-pitft-helper section in /boot/config.txt."
  166. echo "Removing old section..."
  167. cp /boot/config.txt /boot/configtxt.bak
  168. sed -i -e "/^# --- added by adafruit-pitft-helper/,/^# --- end adafruit-pitft-helper/d" /boot/config.txt
  169. fi
  170. if [ "${pitfttype}" == "22" ]; then
  171. overlay="dtoverlay=pitft22,rotate=${pitftrot},speed=64000000,fps=30"
  172. fi
  173. if [ "${pitfttype}" == "28r" ]; then
  174. overlay="dtoverlay=pitft28-resistive,rotate=${pitftrot},speed=64000000,fps=30"
  175. fi
  176. if [ "${pitfttype}" == "28c" ]; then
  177. overlay="dtoverlay=pitft28-capacitive,rotate=${pitftrot},speed=64000000,fps=30"
  178. fi
  179. if [ "${pitfttype}" == "35r" ]; then
  180. overlay="dtoverlay=pitft35-resistive,rotate=${pitftrot},speed=20000000,fps=20"
  181. fi
  182. date=`date`
  183. cat >> /boot/config.txt <<EOF
  184. # --- added by adafruit-pitft-helper $date ---
  185. dtparam=spi=on
  186. dtparam=i2c1=on
  187. dtparam=i2c_arm=on
  188. $overlay
  189. # --- end adafruit-pitft-helper $date ---
  190. EOF
  191. }
  192. function update_udev() {
  193. cat > /etc/udev/rules.d/95-touchmouse.rules <<EOF
  194. SUBSYSTEM=="input", ATTRS{name}=="touchmouse", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
  195. EOF
  196. cat > /etc/udev/rules.d/95-ftcaptouch.rules <<EOF
  197. SUBSYSTEM=="input", ATTRS{name}=="EP0110M09", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
  198. EOF
  199. cat > /etc/udev/rules.d/95-stmpe.rules <<EOF
  200. SUBSYSTEM=="input", ATTRS{name}=="*stmpe*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
  201. EOF
  202. }
  203. function update_pointercal() {
  204. if [ "${pitfttype}" == "28r" ] || [ "${pitfttype}" == "35r" ]; then
  205. echo $(eval echo "\$POINTERCAL_$pitfttype$pitftrot") > /etc/pointercal
  206. fi
  207. if [ "${pitfttype}" == "28c" ]; then
  208. echo $(eval echo "\$POINTERCAL_$pitfttype") > /etc/pointercal
  209. fi
  210. }
  211. function install_console() {
  212. echo "Set up main console turn on"
  213. if ! grep -q 'fbcon=map:10 fbcon=font:VGA8x8' /boot/cmdline.txt; then
  214. echo "Updating /boot/cmdline.txt"
  215. sed -i 's/rootwait/rootwait fbcon=map:10 fbcon=font:VGA8x8/g' "/boot/cmdline.txt"
  216. else
  217. echo "/boot/cmdline.txt already updated"
  218. fi
  219. echo "Turning off console blanking"
  220. # pre-stretch this is what you'd do:
  221. if [ -e /etc/kbd/config ]; then
  222. sed -i 's/BLANK_TIME=.*/BLANK_TIME=0/g' "/etc/kbd/config"
  223. fi
  224. # as of stretch....
  225. # removing any old version
  226. sed -i -e '/^# disable console blanking.*/d' /etc/rc.local
  227. sed -i -e '/^sudo sh -c "TERM=linux setterm -blank.*/d' /etc/rc.local
  228. sed -i -e "s|^exit 0|# disable console blanking on PiTFT\\nsudo sh -c \"TERM=linux setterm -blank 0 >/dev/tty0\"\\nexit 0|" /etc/rc.local
  229. reconfig /etc/default/console-setup "^.*FONTFACE.*$" "FONTFACE=\"Terminus\""
  230. reconfig /etc/default/console-setup "^.*FONTSIZE.*$" "FONTSIZE=\"6x12\""
  231. echo "Setting raspi-config to boot to console w/o login..."
  232. (cd "$target_homedir" && raspi-config nonint do_boot_behaviour B2)
  233. # remove fbcp
  234. sed -i -e "/^.*fbcp.*$/d" /etc/rc.local
  235. }
  236. function uninstall_console() {
  237. echo "Removing console fbcon map from /boot/cmdline.txt"
  238. sed -i 's/rootwait fbcon=map:10 fbcon=font:VGA8x8/rootwait/g' "/boot/cmdline.txt"
  239. echo "Screen blanking time reset to 10 minutes"
  240. if [ -e "/etc/kbd/config" ]; then
  241. sed -i 's/BLANK_TIME=0/BLANK_TIME=10/g' "/etc/kbd/config"
  242. fi
  243. sed -i -e '/^# disable console blanking.*/d' /etc/rc.local
  244. sed -i -e '/^sudo sh -c "TERM=linux.*/d' /etc/rc.local
  245. }
  246. function install_fbcp() {
  247. echo "Installing cmake..."
  248. apt-get --yes --force-yes install cmake 1> /dev/null || { warning "Apt failed to install software!" && exit 1; }
  249. echo "Downloading rpi-fbcp..."
  250. cd /tmp
  251. #curl -sLO https://github.com/tasanakorn/rpi-fbcp/archive/master.zip
  252. curl -sLO https://github.com/adafruit/rpi-fbcp/archive/master.zip
  253. echo "Uncompressing rpi-fbcp..."
  254. rm -rf /tmp/rpi-fbcp-master
  255. unzip master.zip 1> /dev/null || { warning "Failed to uncompress fbcp!" && exit 1; }
  256. cd rpi-fbcp-master
  257. mkdir build
  258. cd build
  259. echo "Building rpi-fbcp..."
  260. echo -e "\nset (CMAKE_C_FLAGS \"-std=gnu99 ${CMAKE_C_FLAGS}\")" >> ../CMakeLists.txt
  261. cmake .. 1> /dev/null || { warning "Failed to cmake fbcp!" && exit 1; }
  262. make 1> /dev/null || { warning "Failed to make fbcp!" && exit 1; }
  263. echo "Installing rpi-fbcp..."
  264. install fbcp /usr/local/bin/fbcp
  265. cd ~
  266. rm -rf /tmp/rpi-fbcp-master
  267. # Start fbcp in the appropriate place, depending on init system:
  268. if [ "$SYSTEMD" == "0" ]; then
  269. # Add fbcp to /etc/rc.local:
  270. echo "We have sysvinit, so add fbcp to /etc/rc.local..."
  271. grep fbcp /etc/rc.local >/dev/null
  272. if [ $? -eq 0 ]; then
  273. # fbcp already in rc.local, but make sure correct:
  274. sed -i "s|^.*fbcp.*$|/usr/local/bin/fbcp \&|g" /etc/rc.local >/dev/null
  275. else
  276. # Insert fbcp into rc.local before final 'exit 0':
  277. sed -i "s|^exit 0|/usr/local/bin/fbcp \&\\nexit 0|g" /etc/rc.local >/dev/null
  278. fi
  279. else
  280. # Install fbcp systemd unit, first making sure it's not in rc.local:
  281. uninstall_fbcp_rclocal
  282. echo "We have systemd, so install fbcp systemd unit..."
  283. install_fbcp_unit || bail "Unable to install fbcp unit file"
  284. sudo systemctl enable fbcp.service
  285. fi
  286. # if there's X11 installed...
  287. if [ -e /etc/lightdm ]; then
  288. echo "Setting raspi-config to boot to desktop w/o login..."
  289. raspi-config nonint do_boot_behaviour B4
  290. fi
  291. # Disable overscan compensation (use full screen):
  292. raspi-config nonint do_overscan 1
  293. # Set up HDMI parameters:
  294. echo "Configuring boot/config.txt for forced HDMI"
  295. reconfig /boot/config.txt "^.*hdmi_force_hotplug.*$" "hdmi_force_hotplug=1"
  296. reconfig /boot/config.txt "^.*hdmi_group.*$" "hdmi_group=2"
  297. reconfig /boot/config.txt "^.*hdmi_mode.*$" "hdmi_mode=87"
  298. # if there's X11 installed...
  299. if [ -e /etc/lightdm ]; then
  300. if [ "${pitfttype}" == "35r" ]; then
  301. echo "Using x1.5 resolution"
  302. SCALE=1.5
  303. else
  304. echo "Using x2 resolution"
  305. SCALE=2.0
  306. fi
  307. else
  308. echo "Using native resolution"
  309. SCALE=1
  310. fi
  311. WIDTH=`python -c "print(int(${WIDTH_VALUES[PITFT_SELECT-1]} * ${SCALE}))"`
  312. HEIGHT=`python -c "print(int(${HEIGHT_VALUES[PITFT_SELECT-1]} * ${SCALE}))"`
  313. reconfig /boot/config.txt "^.*hdmi_cvt.*$" "hdmi_cvt=${WIDTH} ${HEIGHT} 60 1 0 0 0"
  314. if [ "${pitftrot}" == "90" ] || [ "${pitftrot}" == "270" ]; then
  315. # dont rotate HDMI on 90 or 270
  316. reconfig /boot/config.txt "^.*display_hdmi_rotate.*$" ""
  317. fi
  318. if [ "${pitftrot}" == "0" ]; then
  319. reconfig /boot/config.txt "^.*display_hdmi_rotate.*$" "display_hdmi_rotate=1"
  320. # this is a hack but because we rotate HDMI we have to 'unrotate' the TFT!
  321. pitftrot=90
  322. update_configtxt || bail "Unable to update /boot/config.txt"
  323. pitftrot=0
  324. fi
  325. if [ "${pitftrot}" == "180" ]; then
  326. reconfig /boot/config.txt "^.*display_hdmi_rotate.*$" "display_hdmi_rotate=3"
  327. # this is a hack but because we rotate HDMI we have to 'unrotate' the TFT!
  328. pitftrot=90
  329. update_configtxt || bail "Unable to update /boot/config.txt"
  330. pitftrot=180
  331. fi
  332. }
  333. function install_fbcp_unit() {
  334. cat > /etc/systemd/system/fbcp.service <<EOF
  335. [Unit]
  336. Description=Framebuffer copy utility for PiTFT
  337. After=network.target
  338. [Service]
  339. Type=simple
  340. ExecStartPre=/bin/sleep 10
  341. ExecStart=/usr/local/bin/fbcp
  342. [Install]
  343. WantedBy=multi-user.target
  344. EOF
  345. }
  346. function uninstall_fbcp() {
  347. uninstall_fbcp_rclocal
  348. # Enable overscan compensation
  349. raspi-config nonint do_overscan 0
  350. # Set up HDMI parameters:
  351. echo "Configuring boot/config.txt for default HDMI"
  352. reconfig /boot/config.txt "^.*hdmi_force_hotplug.*$" "hdmi_force_hotplug=0"
  353. sed -i -e '/^hdmi_group=2.*$/d' /boot/config.txt
  354. sed -i -e '/^hdmi_mode=87.*$/d' /boot/config.txt
  355. sed -i -e '/^hdmi_cvt=.*$/d' /boot/config.txt
  356. }
  357. function uninstall_fbcp_rclocal() {
  358. # Remove fbcp from /etc/rc.local:
  359. echo "Remove fbcp from /etc/rc.local, if it's there..."
  360. sed -i -e '/^.*fbcp.*$/d' /etc/rc.local
  361. }
  362. function update_xorg() {
  363. if [ "${pitfttype}" == "28r" ] || [ "${pitfttype}" == "35r" ]; then
  364. matrix=$(eval echo "\$TRANSFORM_$pitfttype$pitftrot")
  365. transform="Option \"TransformationMatrix\" \"${matrix}\""
  366. cat > /usr/share/X11/xorg.conf.d/20-calibration.conf <<EOF
  367. Section "InputClass"
  368. Identifier "STMPE Touchscreen Calibration"
  369. MatchProduct "stmpe"
  370. MatchDevicePath "/dev/input/event*"
  371. Driver "libinput"
  372. ${transform}
  373. EndSection
  374. EOF
  375. fi
  376. if [ "${pitfttype}" == "28c" ]; then
  377. matrix=$(eval echo "\$TRANSFORM_$pitfttype$pitftrot")
  378. transform="Option \"TransformationMatrix\" \"${matrix}\""
  379. cat > /usr/share/X11/xorg.conf.d/20-calibration.conf <<EOF
  380. Section "InputClass"
  381. Identifier "FocalTech Touchscreen Calibration"
  382. MatchProduct "EP0110M09"
  383. MatchDevicePath "/dev/input/event*"
  384. Driver "libinput"
  385. ${transform}
  386. EndSection
  387. EOF
  388. fi
  389. }
  390. ####################################################### MAIN
  391. target_homedir="/home/pi"
  392. clear
  393. echo "This script downloads and installs"
  394. echo "PiTFT Support using userspace touch"
  395. echo "controls and a DTO for display drawing."
  396. echo "one of several configuration files."
  397. echo "Run time of up to 5 minutes. Reboot required!"
  398. echo
  399. echo "Select configuration:"
  400. selectN "PiTFT 2.4\", 2.8\" or 3.2\" resistive (240x320)" \
  401. "PiTFT 2.2\" no touch (240x320)" \
  402. "PiTFT 2.8\" capacitive touch (240x320)" \
  403. "PiTFT 3.5\" resistive touch (320x480)" \
  404. "Quit without installing"
  405. PITFT_SELECT=$?
  406. if [ $PITFT_SELECT -gt 4 ]; then
  407. exit 1
  408. fi
  409. echo "Select rotation:"
  410. selectN "90 degrees (landscape)" \
  411. "180 degrees (portait)" \
  412. "270 degrees (landscape)" \
  413. "0 degrees (portait)"
  414. PITFT_ROTATE=$?
  415. if [ $PITFT_ROTATE -gt 4 ]; then
  416. exit 1
  417. fi
  418. PITFT_ROTATIONS=("90" "180" "270" "0")
  419. PITFT_TYPES=("28r" "22" "28c" "35r")
  420. WIDTH_VALUES=(320 320 320 480)
  421. HEIGHT_VALUES=(240 240 240 320)
  422. HZ_VALUES=(64000000 64000000 64000000 32000000)
  423. args=$(getopt -uo 'hvri:o:b:u:' -- $*)
  424. [ $? != 0 ] && print_help
  425. set -- $args
  426. for i
  427. do
  428. case "$i"
  429. in
  430. -h)
  431. print_help
  432. ;;
  433. -v)
  434. print_version
  435. ;;
  436. -u)
  437. target_homedir="$2"
  438. echo "Homedir = ${2}"
  439. shift
  440. shift
  441. ;;
  442. esac
  443. done
  444. # check init system (technique borrowed from raspi-config):
  445. info PITFT 'Checking init system...'
  446. if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
  447. echo "Found systemd"
  448. SYSTEMD=1
  449. elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
  450. echo "Found sysvinit"
  451. SYSTEMD=0
  452. else
  453. bail "Unrecognised init system"
  454. fi
  455. if grep -q boot /proc/mounts; then
  456. echo "/boot is mounted"
  457. else
  458. echo "/boot must be mounted. if you think it's not, quit here and try: sudo mount /dev/mmcblk0p1 /boot"
  459. if ask "Continue?"; then
  460. echo "Proceeding."
  461. else
  462. bail "Aborting."
  463. fi
  464. fi
  465. if [[ ! -e "$target_homedir" || ! -d "$target_homedir" ]]; then
  466. bail "$target_homedir must be an existing directory (use -u /home/foo to specify)"
  467. fi
  468. pitfttype=${PITFT_TYPES[$PITFT_SELECT-1]}
  469. pitftrot=${PITFT_ROTATIONS[$PITFT_ROTATE-1]}
  470. if [ "${pitfttype}" != "28r" ] && [ "${pitfttype}" != "28c" ] && [ "${pitfttype}" != "35r" ] && [ "${pitfttype}" != "22" ]; then
  471. echo "Type must be one of:"
  472. echo " '28r' (2.8\" resistive, PID 1601)"
  473. echo " '28c' (2.8\" capacitive, PID 1983)"
  474. echo " '35r' (3.5\" Resistive)"
  475. echo " '22' (2.2\" no touch)"
  476. echo
  477. print_help
  478. fi
  479. info PITFT "System update"
  480. sysupdate || bail "Unable to apt-get update"
  481. info PITFT "Installing Python libraries & Software..."
  482. softwareinstall || bail "Unable to install software"
  483. info PITFT "Updating /boot/config.txt..."
  484. update_configtxt || bail "Unable to update /boot/config.txt"
  485. if [ "${pitfttype}" == "28r" ] || [ "${pitfttype}" == "35r" ] || [ "${pitfttype}" == "28c" ] ; then
  486. info PITFT "Updating SysFS rules for Touchscreen..."
  487. update_udev || bail "Unable to update /etc/udev/rules.d"
  488. info PITFT "Updating TSLib default calibration..."
  489. update_pointercal || bail "Unable to update /etc/pointercal"
  490. fi
  491. # ask for console access
  492. if ask "Would you like the console to appear on the PiTFT display?"; then
  493. info PITFT "Updating console to PiTFT..."
  494. uninstall_fbcp || bail "Unable to uninstall fbcp"
  495. install_console || bail "Unable to configure console"
  496. else
  497. info PITFT "Making sure console doesn't use PiTFT"
  498. uninstall_console || bail "Unable to configure console"
  499. if ask "Would you like the HDMI display to mirror to the PiTFT display?"; then
  500. info PITFT "Adding FBCP support..."
  501. install_fbcp || bail "Unable to configure fbcp"
  502. if [ -e /etc/lightdm ]; then
  503. info PITFT "Updating X11 default calibration..."
  504. update_xorg || bail "Unable to update calibration"
  505. fi
  506. fi
  507. fi
  508. #info PITFT "Updating X11 setup tweaks..."
  509. #update_x11profile || bail "Unable to update X11 setup"
  510. #if [ "${pitfttype}" != "35r" ]; then
  511. # # ask for 'on/off' button
  512. # if ask "Would you like GPIO #23 to act as a on/off button?"; then
  513. # info PITFT "Adding GPIO #23 on/off to PiTFT..."
  514. # install_onoffbutton || bail "Unable to add on/off button"
  515. # fi
  516. #fi
  517. # update_bootprefs || bail "Unable to set boot preferences"
  518. info PITFT "Success!"
  519. echo
  520. echo "Settings take effect on next boot."
  521. echo
  522. echo -n "REBOOT NOW? [y/N] "
  523. read
  524. if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
  525. echo "Exiting without reboot."
  526. exit 0
  527. fi
  528. echo "Reboot started..."
  529. reboot
  530. exit 0