1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-08 23:20:48 +02:00

Allow example userscripts, with calibratePTZ example script. (#1371)

* PTZpresets.sh should not use inverted logic for motor control.

* Allow example userscripts, calibrate at boot example.

This commit changes run.sh to only execute files in /system/sdcard/config/userscripts/startup/
if they do not end with .dist. This allows example scripts to be included in the repository.

This commit also includes an example script calibratPTZ.sh.dist that will perform a PTZ calibration at boot
and if a /system/sdcard/config/cameraposition file exists it will also move the camera to the position it defines.

To enable the calibratePTZ.sh.dist demo, or any other script, copy or rename it to NOT end in .dist.
Example:
cp /system/sdcard/config/userscripts/startup/calibratePTZ.sh.dist /system/sdcard/config/userscripts/startup/calibratePTZ.sh
This commit is contained in:
Solomon S
2020-04-18 14:43:03 -04:00
committed by GitHub
parent 715f220f4a
commit 74247138e7
3 changed files with 32 additions and 2 deletions

5
.gitignore vendored
View File

@@ -57,5 +57,8 @@ firmware_mod/config/rtspserver.conf
firmware_mod/config/ntp_srv.conf
firmware_mod/config/lighttpd.user
firmware_mod/config/lighttpd.pem
firmware_mod/config/userscripts/*/*
firmware_mod/config/userscripts/motiondetection/*
!firmware_mod/config/userscripts/motiondetection/*.dist
firmware_mod/config/userscripts/startup/*
!firmware_mod/config/userscripts/startup/*.dist
firmware_mod/root/.ssh/*

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# Performs PTZ calibration at boot and if
# /system/sdcard/config/cameraposition exists
# will adjust camera to that position.
# Disabled by default as calibration can cause issues
# on cameras that do not have mechanical endstops.
# To enable:
# cp /system/sdcard/config/userscripts/startup/calibratePTZ.sh.dist /system/sdcard/config/userscripts/startup/calibratePTZ.sh
/system/sdcard/bin/motor -d v
FILECAMERAPOS=/system/sdcard/config/cameraposition
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
# go to home for both axis
/system/sdcard/scripts/PTZpresets.sh $origin_x_axis $origin_y_axis

View File

@@ -260,7 +260,9 @@ done
## Autostart startup userscripts
for i in /system/sdcard/config/userscripts/startup/*; do
$i &
if [ $i != *".dist" ]; then
$i &
fi
done
echo "Startup finished!" >> $LOGPATH