Skip to content

Commit

Permalink
optimization button gpiomon code
Browse files Browse the repository at this point in the history
Signed-off-by: Ruixi Zhou <[email protected]>
  • Loading branch information
zhouruixi committed Oct 16, 2024
1 parent 2f109ab commit cce8097
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gs/button.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ ! -d /sys/class/net/wlan0 ]; then
exit 0
fi
WIFI_mode_switch_PIN_info=$(gpiofind PIN_${WIFI_mode_switch_PIN})
while [ "$(gpiomon -F %e -n 1 $WIFI_mode_switch_PIN_info)" == "1" ]; do
while gpiomon -r -s -n 1 -B pull-down $WIFI_mode_switch_PIN_info; do
wlan0_connected_connection=$(nmcli device status | grep '^wlan0.*connected' | tr -s ' ' | cut -d ' ' -f 4)
case "$wlan0_connected_connection" in
hotspot)
Expand All @@ -32,7 +32,7 @@ done
otg_mode_switch_PIN_info=$(gpiofind PIN_${otg_mode_switch_PIN})
otg_mode_file="/sys/kernel/debug/usb/fcc00000.dwc3/mode"
otg_mode_LED_PIN_info=$(gpiofind PIN_${otg_mode_LED_PIN})
while [ "$(gpiomon -F %e -n 1 $otg_mode_switch_PIN_info)" == "1" ]; do
while gpiomon -r -s -n 1 -B pull-down $otg_mode_switch_PIN_info; do
otg_mode=$(cat $otg_mode_file)
if [ "$otg_mode" == "host" ]; then
echo device > $otg_mode_file
Expand Down
4 changes: 2 additions & 2 deletions gs/stream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function gencmd(){
gencmd norecord
bash -c "$video_play_cmd" &
pid_player=$!
while [ "$(gpiomon -F %e -n 1 ${GPIO_REC})" == "1" ]; do
while gpiomon -r -s -n 1 -B pull-down ${GPIO_REC}; do
if [ "$video_record" == "0" ]; then
if [ "$video_player" == "pixelpilot" ]; then
kill -SIGUSR1 $pid_player
Expand Down Expand Up @@ -78,5 +78,5 @@ while [ "$(gpiomon -F %e -n 1 ${GPIO_REC})" == "1" ]; do
fi
video_record='0'
fi
sleep 1
sleep 3
done

0 comments on commit cce8097

Please sign in to comment.