Browse Source

Merge pull request #90 from makermelissa/master

Added uninstall option to PiTFT
Melissa LeBlanc-Williams 1 month ago
parent
commit
673a7cfd5a
No account linked to committer's email address
1 changed files with 81 additions and 56 deletions
  1. 81
    56
      adafruit-pitft.sh

+ 81
- 56
adafruit-pitft.sh View File

@@ -15,7 +15,7 @@ fi
15 15
 
16 16
 
17 17
 UPDATE_DB=false
18
-
18
+UNINSTALL=false
19 19
 
20 20
 ############################ CALIBRATIONS ############################
21 21
 # For TSLib
@@ -210,20 +210,28 @@ function softwareinstall() {
210 210
     pip install evdev 1> /dev/null  || { warning "Pip failed to install software!" && exit 1; }
211 211
 }
212 212
 
213
-# update /boot/config.txt with appropriate values
214
-function update_configtxt() {
213
+# Remove any old flexfb/fbtft stuff
214
+function uninstall_bootconfigtxt() {
215 215
     if grep -q "adafruit-pitft-helper" "/boot/config.txt"; then
216 216
         echo "Already have an adafruit-pitft-helper section in /boot/config.txt."
217 217
         echo "Removing old section..."
218 218
         cp /boot/config.txt /boot/configtxt.bak
219 219
         sed -i -e "/^# --- added by adafruit-pitft-helper/,/^# --- end adafruit-pitft-helper/d" /boot/config.txt
220 220
     fi
221
+}
221 222
 
222
-    # remove any old flexfb/fbtft stuff
223
+# Remove any old flexfb/fbtft stuff
224
+function uninstall_etc_modules() {
223 225
     rm -f /etc/modprobe.d/fbtft.conf
224 226
     sed -i 's/spi-bcm2835//g' "/etc/modules"
225 227
     sed -i 's/flexfb//g' "/etc/modules"
226 228
     sed -i 's/fbtft_device//g' "/etc/modules"
229
+}
230
+
231
+# update /boot/config.txt with appropriate values
232
+function update_configtxt() {
233
+    uninstall_bootconfigtxt
234
+    uninstall_etc_modules
227 235
 
228 236
     if [ "${pitfttype}" == "22" ]; then
229 237
         overlay="dtoverlay=pitft22,rotate=${pitftrot},speed=64000000,fps=30"
@@ -555,20 +563,28 @@ selectN "PiTFT 2.4\", 2.8\" or 3.2\" resistive (240x320)" \
555 563
         "PiTFT 3.5\" resistive touch (320x480)" \
556 564
         "PiTFT Mini 1.3\" or 1.54\" display (240x240)" \
557 565
         "MiniPiTFT 1.14\" display (240x135) - WARNING! CUTTING EDGE! WILL UPGRADE YOUR KERNEL TO LATEST" \
566
+        "Uninstall PiTFT" \
558 567
         "Quit without installing"
559 568
 PITFT_SELECT=$?
560
-if [ $PITFT_SELECT -gt 7 ]; then
569
+if [ $PITFT_SELECT -gt 8 ]; then
561 570
     exit 1
562 571
 fi
563 572
 
564
-echo "Select rotation:"
565
-selectN "90 degrees (landscape)" \
566
-        "180 degrees (portait)" \
567
-        "270 degrees (landscape)" \
568
-        "0 degrees (portait)"
569
-PITFT_ROTATE=$?
570
-if [ $PITFT_ROTATE -gt 4 ]; then
571
-    exit 1
573
+if [ $PITFT_SELECT -eq 8 ]; then
574
+    UNINSTALL=true
575
+fi
576
+
577
+
578
+if ! $UNINSTALL; then
579
+    echo "Select rotation:"
580
+    selectN "90 degrees (landscape)" \
581
+            "180 degrees (portait)" \
582
+            "270 degrees (landscape)" \
583
+            "0 degrees (portait)"
584
+    PITFT_ROTATE=$?
585
+    if [ $PITFT_ROTATE -gt 4 ]; then
586
+        exit 1
587
+    fi
572 588
 fi
573 589
 
574 590
 PITFT_ROTATIONS=("90" "180" "270" "0")
@@ -629,61 +645,70 @@ if [[ ! -e "$target_homedir" || ! -d "$target_homedir" ]]; then
629 645
     bail "$target_homedir must be an existing directory (use -u /home/foo to specify)"
630 646
 fi
631 647
 
632
-pitfttype=${PITFT_TYPES[$PITFT_SELECT-1]}
633
-pitftrot=${PITFT_ROTATIONS[$PITFT_ROTATE-1]}
634
-
635
-
636
-if [ "${pitfttype}" != "28r" ] && [ "${pitfttype}" != "28c" ] && [ "${pitfttype}" != "35r" ] && [ "${pitfttype}" != "22" ] && [ "${pitfttype}" != "st7789_240x240" ] && [ "${pitfttype}" != "st7789_240x320" ] && [ "${pitfttype}" != "st7789_240x135" ]; then
637
-    echo "Type must be one of:"
638
-    echo "  '28r' (2.8\" resistive, PID 1601)"
639
-    echo "  '28c' (2.8\" capacitive, PID 1983)"
640
-    echo "  '35r' (3.5\" Resistive)"
641
-    echo "  '22'  (2.2\" no touch)"
642
-    echo "  'st7789_240x240' (1.54\" or 1.3\" no touch)"
643
-    echo "  'st7789_320x240' (2.0\" no touch)"
644
-    echo "  'st7789_240x135' 1.14\" no touch)"
645
-    echo
646
-    print_help
647
-fi
648
+if ! $UNINSTALL;
649
+then
650
+    pitfttype=${PITFT_TYPES[$PITFT_SELECT-1]}
651
+    pitftrot=${PITFT_ROTATIONS[$PITFT_ROTATE-1]}
652
+
653
+
654
+    if [ "${pitfttype}" != "28r" ] && [ "${pitfttype}" != "28c" ] && [ "${pitfttype}" != "35r" ] && [ "${pitfttype}" != "22" ] && [ "${pitfttype}" != "st7789_240x240" ] && [ "${pitfttype}" != "st7789_240x320" ] && [ "${pitfttype}" != "st7789_240x135" ]; then
655
+        echo "Type must be one of:"
656
+        echo "  '28r' (2.8\" resistive, PID 1601)"
657
+        echo "  '28c' (2.8\" capacitive, PID 1983)"
658
+        echo "  '35r' (3.5\" Resistive)"
659
+        echo "  '22'  (2.2\" no touch)"
660
+        echo "  'st7789_240x240' (1.54\" or 1.3\" no touch)"
661
+        echo "  'st7789_320x240' (2.0\" no touch)"
662
+        echo "  'st7789_240x135' 1.14\" no touch)"
663
+        echo
664
+        print_help
665
+    fi
648 666
 
649
-info PITFT "System update"
650
-sysupdate || bail "Unable to apt-get update"
667
+    info PITFT "System update"
668
+    sysupdate || bail "Unable to apt-get update"
651 669
 
652
-info PITFT "Installing Python libraries & Software..."
653
-softwareinstall || bail "Unable to install software"
670
+    info PITFT "Installing Python libraries & Software..."
671
+    softwareinstall || bail "Unable to install software"
654 672
 
655
-info PITFT "Updating /boot/config.txt..."
656
-update_configtxt || bail "Unable to update /boot/config.txt"
673
+    info PITFT "Updating /boot/config.txt..."
674
+    update_configtxt || bail "Unable to update /boot/config.txt"
657 675
 
658
-if [ "${pitfttype}" == "28r" ] || [ "${pitfttype}" == "35r" ]  || [ "${pitfttype}" == "28c" ] ; then
659
-   info PITFT "Updating SysFS rules for Touchscreen..."
660
-   update_udev || bail "Unable to update /etc/udev/rules.d"
676
+    if [ "${pitfttype}" == "28r" ] || [ "${pitfttype}" == "35r" ]  || [ "${pitfttype}" == "28c" ] ; then
677
+       info PITFT "Updating SysFS rules for Touchscreen..."
678
+       update_udev || bail "Unable to update /etc/udev/rules.d"
661 679
 
662
-   info PITFT "Updating TSLib default calibration..."
663
-   update_pointercal || bail "Unable to update /etc/pointercal"
664
-fi
680
+       info PITFT "Updating TSLib default calibration..."
681
+       update_pointercal || bail "Unable to update /etc/pointercal"
682
+    fi
665 683
 
666
-# ask for console access
667
-if ask "Would you like the console to appear on the PiTFT display?"; then
668
-    info PITFT "Updating console to PiTFT..."
669
-    uninstall_fbcp  || bail "Unable to uninstall fbcp"
670
-    install_console || bail "Unable to configure console"
671
-else
672
-    info PITFT "Making sure console doesn't use PiTFT"
673
-    uninstall_console || bail "Unable to configure console"
684
+    # ask for console access
685
+    if ask "Would you like the console to appear on the PiTFT display?"; then
686
+        info PITFT "Updating console to PiTFT..."
687
+        uninstall_fbcp  || bail "Unable to uninstall fbcp"
688
+        install_console || bail "Unable to configure console"
689
+    else
690
+        info PITFT "Making sure console doesn't use PiTFT"
691
+        uninstall_console || bail "Unable to configure console"
674 692
 
675
-    if ask "Would you like the HDMI display to mirror to the PiTFT display?"; then
676
-        info PITFT "Adding FBCP support..."
677
-        install_fbcp || bail "Unable to configure fbcp"
693
+        if ask "Would you like the HDMI display to mirror to the PiTFT display?"; then
694
+            info PITFT "Adding FBCP support..."
695
+            install_fbcp || bail "Unable to configure fbcp"
678 696
 
679
-        if [ -e /etc/lightdm ]; then
680
-            info PITFT "Updating X11 default calibration..."
681
-            update_xorg || bail "Unable to update calibration"
697
+            if [ -e /etc/lightdm ]; then
698
+                info PITFT "Updating X11 default calibration..."
699
+                update_xorg || bail "Unable to update calibration"
700
+            fi
682 701
         fi
683 702
     fi
703
+else
704
+    info PITFT "Uninstalling PiTFT"
705
+    uninstall_bootconfigtxt
706
+    uninstall_console
707
+    uninstall_fbcp
708
+    uninstall_fbcp_rclocal
709
+    uninstall_etc_modules
684 710
 fi
685 711
 
686
-
687 712
 #info PITFT "Updating X11 setup tweaks..."
688 713
 #update_x11profile || bail "Unable to update X11 setup"
689 714
 

Loading…
Cancel
Save