-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy patharmbian-openvfd
More file actions
executable file
·200 lines (179 loc) · 6.61 KB
/
armbian-openvfd
File metadata and controls
executable file
·200 lines (179 loc) · 6.61 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
#==========================================================================
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#
# This file is a part of the Rebuild Armbian
# https://github.com/ophub/amlogic-s9xxx-armbian
#
# Description: LED Screen Display Control Tool
# Copyright (C) 2022- https://github.com/unifreq/openwrt_packit
# Copyright (C) 2022- https://github.com/ophub/amlogic-s9xxx-armbian
#
# Function : Command
# Default : armbian-openvfd
# One-key to open : armbian-openvfd <boxid>
# One-key to stop : armbian-openvfd 0
# Update config : armbian-openvfd -u
#
#============================= Functions list =============================
#
# do_start : Enable LED screen display
# do_stop : Disable LED screen display
# do_update_conf : Update OpenVFD configuration files
# do_select_box : Select and apply device configuration
#
#==========================================================================
#
# Openvfd files storage path
openvfd_path="/usr/share/openvfd"
openvfd_service="${openvfd_path}/vfdservice"
# The openvfd files download repository
openvfd_repo="https://github.com/ophub/amlogic-s9xxx-armbian.git"
openvfd_dir="build-armbian/armbian-files/platform-files/amlogic/rootfs/usr/share/openvfd"
#
# Set font color
STEPS="[\033[95m STEPS \033[0m]"
INFO="[\033[94m INFO \033[0m]"
SUCCESS="[\033[92m SUCCESS \033[0m]"
OPTIONS="[\033[93m OPTIONS \033[0m]"
ERROR="[\033[91m ERROR \033[0m]"
#
#==========================================================================
# Output error message and abort
error_msg() {
echo -e "${ERROR} ${1}"
exit 1
}
# Update OpenVFD configuration files
do_update_conf() {
echo -e "${STEPS} Updating OpenVFD configuration files..."
# Check dependencies
[[ -z "$(dpkg -l | awk '{print $2}' | grep -w "^git$")" ]] && sudo apt-get update && sudo apt-get install -y git
# Get the latest scripts
git_tmp_path="$(mktemp -d)"
cd ${git_tmp_path}
git init --quiet
git config core.sparseCheckout true
echo "${openvfd_dir}/*" >>.git/info/sparse-checkout
git remote add origin ${openvfd_repo}
git pull --quiet --depth=1 origin main
[[ "${?}" -ne "0" ]] && error_msg "Failed to download scripts from [ ${openvfd_repo} ]."
# Update related files
mkdir -p ${openvfd_path}
cp -af --no-preserve=ownership ${git_tmp_path}/${openvfd_dir}/* ${openvfd_path}
[[ "${?}" -ne "0" ]] && error_msg "Failed to sync scripts from [ ${openvfd_repo} ]."
chmod +x ${openvfd_path}/vfdservice
# Clean up temporary files
rm -rf ${git_tmp_path} 2>/dev/null
sync && sleep 3
echo -e "${SUCCESS} OpenVFD configuration files updated successfully."
exit 0
}
# Enable LED screen display
do_start() {
echo -e "${STEPS} Enabling LED screen display..."
# Check config files and services
conf_file="${openvfd_path}/conf/${1}"
if [[ -s "${conf_file}" && -x "${openvfd_service}" ]]; then
source "${conf_file}" 2>/dev/null
echo -e "${INFO} Using LED Profiles: ${conf_file}"
else
error_msg "The LED profile [ ${conf_file} ] does not exist!"
fi
modprobe openvfd vfd_gpio_clk=${vfd_gpio_clk} \
vfd_gpio_dat=${vfd_gpio_dat} \
vfd_gpio_stb=${vfd_gpio_stb:-0,0,0xFF} \
vfd_gpio0=${vfd_gpio0:-0,0,0xFF} \
vfd_gpio1=${vfd_gpio1:-0,0,0xFF} \
vfd_gpio2=${vfd_gpio2:-0,0,0xFF} \
vfd_gpio3=${vfd_gpio3:-0,0,0xFF} \
vfd_gpio_protocol=${vfd_gpio_protocol:-0,0} \
vfd_chars=${vfd_chars} vfd_dot_bits=${vfd_dot_bits} \
vfd_display_type=${vfd_display_type}
"${openvfd_service}" &
trap "killall ${openvfd_service}; rmmod openvfd; exit" 2 3 15
if [[ -n "${functions}" ]]; then
for func in ${functions}; do
echo -e "${INFO} turn led ${func} on ... "
echo "${func}" >/sys/class/leds/openvfd/led_on 2>/dev/null
done
fi
echo -e "${SUCCESS} LED display enabled!"
exit 0
}
# Disable LED screen display
do_stop() {
echo -e "${STEPS} Disabling LED screen display..."
killall -9 vfdservice 2>/dev/null
rmmod openvfd -f 2>/dev/null
echo -e "${SUCCESS} LED display disabled!"
exit 0
}
# Select and apply device configuration
do_select_box() {
case "${1}" in
11 | x96max) do_start x96max.conf ;;
12 | x96maxplus) do_start x96maxplus.conf ;;
13 | x96air) do_start x96air.conf ;;
14 | h96max-x3) do_start h96max-x3.conf ;;
15 | hk1-x3) do_start hk1-x3.conf ;;
16 | hk1box) do_start hk1box.conf ;;
17 | tx3) do_start tx3.conf ;;
18 | tx3-mini) do_start tx3-mini.conf ;;
19 | t95) do_start t95.conf ;;
20 | t95z-plus) do_start t95z-plus.conf ;;
21 | tx9-pro) do_start tx9-pro.conf ;;
22 | x92) do_start x92.conf ;;
23 | whale) do_start whale.conf ;;
24 | x88pro-x3) do_start x88pro-x3.conf ;;
99 | diy) do_start diy.conf ;;
0 | stop) do_stop ;;
1 | quit) echo "quit!" && exit 0 ;;
*) error_msg "Invalid input!" ;;
esac
}
# Execute according to the classification of input parameters
case "${1}" in
-u | u | -update | update)
do_update_conf
;;
[0-9]*)
do_select_box "${1}"
;;
*)
clear
cat <<EOF
┌────────[ Enable LED ]─────────┐
│ │
│ 11. x96max (s905x2) │
│ 12. x96maxplus (s905x3) │
│ 13. x96air (s905x3) │
│ 14. h96max-x3 (s905x3) │
│ 15. hk1-x3 (s905x3) │
│ 16. hk1box (s905x3) │
│ 17. tx3 (s905x3) │
│ 18. tx3-mini (s905w) │
│ 19. t95 (s905x) │
│ 20. t95z-plus (s912) │
│ 21. tx9-pro (s912) │
│ 22. x92 (s912) │
│ 23. whale (s905x3) │
| 24. x88pro-x3 (s905x3) |
│ 99. diy │
│ │
├──────[ Other Operations ]─────┤
│ │
│ -u. update │
│ 0. stop │
│ 1. quit │
│ │
└───────────────────────────────┘
EOF
echo -ne "${OPTIONS} Please Input ID: "
read boxid
do_select_box "${boxid}"
;;
esac