mirror of
https://github.com/m5stack/LLM_buildroot-external-m5stack.git
synced 2026-05-20 11:34:12 -07:00
[update] add bmi data and kit add USRBtn.sh
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Starts
|
||||
#
|
||||
ExecScript=/tmp/user_btn_start.sh
|
||||
|
||||
start() {
|
||||
printf "Starting $ExecScript"
|
||||
|
||||
|
||||
cat <<EOF > /tmp/user_btn_start.sh
|
||||
i2cset -y -f 1 0x43 0x0D 0x8
|
||||
enable_count=0
|
||||
last_led_state=0
|
||||
while true ; do
|
||||
if [[ \$(( \$(i2cget -y -f 1 0x43 0x0f) & 0x8 )) -ne 8 ]]; then
|
||||
enable_count=\$((enable_count+1))
|
||||
if [ \$enable_count -eq 12 ] ; then
|
||||
echo 255 > /sys/class/leds/sys_led/brightness ;
|
||||
find /mnt -name m5stack_user_start.sh -exec start-stop-daemon --start --quiet --background --make-pidfile --pidfile /tmp/.UsrBtnStart.pid --exec /bin/bash -- {} \; -quit
|
||||
else
|
||||
if [ \$enable_count -lt 12 ] ; then
|
||||
if [ \$last_led_state -eq 0 ] ; then
|
||||
last_led_state=1
|
||||
echo 0 > /sys/class/leds/sys_led/brightness ;
|
||||
else
|
||||
last_led_state=0
|
||||
echo 255 > /sys/class/leds/sys_led/brightness ;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ \$enable_count -gt 0 ] ; then
|
||||
echo 255 > /sys/class/leds/sys_led/brightness ;
|
||||
fi
|
||||
enable_count=0
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
EOF
|
||||
|
||||
start-stop-daemon --start --quiet --background --make-pidfile --pidfile /tmp/.user_btn_start.pid --exec /bin/bash -- /tmp/user_btn_start.sh
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
stop() {
|
||||
printf "Stopping $ExecScript"
|
||||
# /etc/rc.local stop
|
||||
start-stop-daemon --stop --pidfile /tmp/.user_btn_start.pid
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
Reference in New Issue
Block a user