Skip to content

Commit cce8097

Browse files
committed
optimization button gpiomon code
Signed-off-by: Ruixi Zhou <zhouruixi@gmail.com>
1 parent 2f109ab commit cce8097

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

gs/button.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if [ ! -d /sys/class/net/wlan0 ]; then
1010
exit 0
1111
fi
1212
WIFI_mode_switch_PIN_info=$(gpiofind PIN_${WIFI_mode_switch_PIN})
13-
while [ "$(gpiomon -F %e -n 1 $WIFI_mode_switch_PIN_info)" == "1" ]; do
13+
while gpiomon -r -s -n 1 -B pull-down $WIFI_mode_switch_PIN_info; do
1414
wlan0_connected_connection=$(nmcli device status | grep '^wlan0.*connected' | tr -s ' ' | cut -d ' ' -f 4)
1515
case "$wlan0_connected_connection" in
1616
hotspot)
@@ -32,7 +32,7 @@ done
3232
otg_mode_switch_PIN_info=$(gpiofind PIN_${otg_mode_switch_PIN})
3333
otg_mode_file="/sys/kernel/debug/usb/fcc00000.dwc3/mode"
3434
otg_mode_LED_PIN_info=$(gpiofind PIN_${otg_mode_LED_PIN})
35-
while [ "$(gpiomon -F %e -n 1 $otg_mode_switch_PIN_info)" == "1" ]; do
35+
while gpiomon -r -s -n 1 -B pull-down $otg_mode_switch_PIN_info; do
3636
otg_mode=$(cat $otg_mode_file)
3737
if [ "$otg_mode" == "host" ]; then
3838
echo device > $otg_mode_file

gs/stream.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function gencmd(){
3434
gencmd norecord
3535
bash -c "$video_play_cmd" &
3636
pid_player=$!
37-
while [ "$(gpiomon -F %e -n 1 ${GPIO_REC})" == "1" ]; do
37+
while gpiomon -r -s -n 1 -B pull-down ${GPIO_REC}; do
3838
if [ "$video_record" == "0" ]; then
3939
if [ "$video_player" == "pixelpilot" ]; then
4040
kill -SIGUSR1 $pid_player
@@ -78,5 +78,5 @@ while [ "$(gpiomon -F %e -n 1 ${GPIO_REC})" == "1" ]; do
7878
fi
7979
video_record='0'
8080
fi
81-
sleep 1
81+
sleep 3
8282
done

0 commit comments

Comments
 (0)