-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·142 lines (127 loc) · 5.22 KB
/
setup
File metadata and controls
executable file
·142 lines (127 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# adds display and backlight settings
# run manually initally, then called from reinstallMods
# to uninstall/deactivate, call this script with "uninstall" as first parameter
# Note, this script DOES require a system reboot.
overlayFile="/u-boot/overlays/gpio-led.dtbo"
configFile="/u-boot/config.txt"
headlessFlag=/etc/venus/headless
blankDeviceFile=/etc/venus/blank_display_device
#### following lines incorporate SetupHelper utilities into this script
# Refer to the SetupHelper ReadMe file for details.
source "/data/SetupHelper/HelperResources/IncludeHelpers"
#### end of lines to include SetupHelper
#### running manually and OK to proceed - prompt for input
if [ $scriptAction == 'NONE' ] ; then
# display innitial message
echo
echo "This package makes the following modifications:"
echo " - installs the overlay file for the GPIO LED (used for backlight)"
echo " - adds the display setup and backlight overlay to config.txt"
echo
yesNoPrompt "Do you want to continue (y/n)?: "
if $yesResponse ; then
scriptAction='INSTALL'
yesNoPrompt "Rotate the display 180 degrees (y/n)?: "
if $yesResponse ; then
touch "$setupOptionsDir/rotateDisplay"
else
rm -f "$setupOptionsDir/rotateDisplay"
fi
yesNoPrompt "Enter custom GPIO pin for backlight (default: 23) (y/n)?: "
if $yesResponse ; then
read -p "enter GPIO pin to use: " gpioPin
if [ "$gpioPin" != "" ]; then
echo $gpioPin > "$setupOptionsDir/backlight_gpio_pin"
else
rm -f "$setupOptionsDir/backlight_gpio_pin"
fi
else
rm -f "$setupOptionsDir/backlight_gpio_pin"
fi
fi
fi
#### installing
if [ $scriptAction == 'INSTALL' ] ; then
display_rotate=0
if [ -f $setupOptionsDir/rotateDisplay ]; then
display_rotate=2
fi
gpioPin=23
if [ -f $setupOptionsDir/backlight_gpio_pin ]; then
gpioPin=$(cat "$setupOptionsDir/backlight_gpio_pin")
fi
# install overlay only if it doesn't exist
[ -f "$overlayFile" ] || logMessage "installing Display Backlight overlay" && rebootNeeded=true && updateActiveFile "$overlayFile"
if [ $(grep -c "#### begin VeTouchDisplay" "$configFile") == 0 ]; then
logMessage "activating VeTouchDisplay settings in $configFile"
echo "#### begin VeTouchDisplay" >> "$configFile"
echo "# Elecrow RC050 5 inch HDMI 800 x 480 Capacitive Touch LCD Display for Raspberry Pi/ PC/ SONY PS4" >> "$configFile"
echo "# https://www.elecrow.com/wiki/index.php?title=RC050_5_inch_HDMI_800_x_480_Capacitive_Touch_LCD_Display_for_Raspberry_Pi/_PC/_SONY_PS4" >> "$configFile"
echo "hdmi_force_hotplug=1" >> "$configFile"
echo "max_usb_current=1" >> "$configFile"
echo "hdmi_drive=1" >> "$configFile"
echo "hdmi_group=2" >> "$configFile"
echo "hdmi_mode=1" >> "$configFile"
echo "hdmi_mode=87" >> "$configFile"
echo "hdmi_cvt=800 480 60 6 0 0 0" >> "$configFile"
echo "display_rotate=$display_rotate" >> "$configFile"
echo "framebuffer_width=800" >> "$configFile"
echo "framebuffer_height=480" >> "$configFile"
echo "# for backlight on / off" >> "$configFile"
echo "# gpio-led overlay allows to invert the backlight (echo 0 for on and 1 for off, like backlight blanking)" >> "$configFile"
echo "dtoverlay=gpio-led,gpio=$gpioPin,label=backlight,active_low=1" >> "$configFile"
# comment dtoverlay=vc4-kms-v3c for raspberrypi4 if active
if [ $machine == "raspberrypi4" ]; then
if [ $(grep -c "^\s*dtoverlay=vc4-kms-v3c" "$configFile") != 0 ]; then
logMessage "disabling dtoverlay=vc4-kms-v3c on Raspberry Pi 4"
sed -i 's/^\s*dtoverlay=vc4-kms-v3c/#dtoverlay=vc4-kms-v3c/g' "$configFile"
rebootNeeded=true
fi
fi
echo "#### end VeTouchDisplay" >> "$configFile"
echo "" >> "$configFile"
rebootNeeded=true
fi
# enable screen saver (blanking) from the Venus
if [ "$gpioPin" != "" ]; then
if [ ! -e "$blankDeviceFile" ] || [ $(grep -c "/sys/class/leds/backlight/brightness" "$blankDeviceFile") == 0 ]; then
logMessage "setting display blanking to GPIO pin $gpioPin"
echo "/sys/class/leds/backlight/brightness" > "$blankDeviceFile"
restartGui=true
fi
fi
if [ -e $headlessFlag ]; then
logMessage "activating local GUI"
rm -f $headlessFlag
rebootNeeded=true
fi
fi
# uninstalling - check scriptAction again
# if an install step failed package needs to be removed
if [ $scriptAction == 'UNINSTALL' ] ; then
logMessage "++ Uninstalling display setup"
if [ -e "$blankDeviceFile" ]; then
logMessage "disabling display blanking"
rm -f "$blankDeviceFile"
restartGui=true
fi
if [ ! -f "/etc/venus/headless" ]; then
echo
logMessage "DISABLING LOCAL GUI - reverts to console"
echo
touch "/etc/venus/headless"
rebootNeeded=true
fi
logMessage "restoring previous overlay file"
restoreActiveFile "$overlayFile"
# remove mods from configFile - do not use restore in case other mods were made manually
if [ -f "$configFile" ]; then
if [ $(grep -c "#### begin VeTouchDisplay" "$configFile") != 0 ]; then
sed -i -e '/#### begin VeTouchDisplay/,/#### end VeTouchDisplay/d' "$configFile"
rebootNeeded=true
fi
fi
fi
# thats all folks - SCRIPT EXITS INSIDE THE FUNCTION
endScript