Add better reaction to -q keyword

This commit is contained in:
2020-10-19 15:20:06 +03:00
parent fe0fe62cad
commit 6ef30d6d2a
10 changed files with 139 additions and 24 deletions

37
commandline/cfg/TurretMove Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
function move(){
./steppermove -I4 $*
}
if [ $# -ne 1 ]; then
echo "Usage: $0 Nposition (enumeration from 0)" >&2
exit 1
fi
if [ $1 -lt 0 -o $1 -gt 5 ]; then
echo "Turet position should be from 0 to 5" >&2
exit 2
fi
LAST=-1
[ -f lastpos ] && LAST=$(cat lastpos)
eval "$(move -s250 -m50)"
DIFF=$((CURENCODER - LAST))
ABS=${DIFF#-} # absoulte value
if [ $ABS -gt 3 ]; then # goto zero if last position differs more then for 3 from current
move -cE1 -r-1000
move -wcA
move -0
fi
move -Fa $((683*$1))
move -w
sleep 1 # wait for stopping
eval "$(move)"
echo $CURENCODER > lastpos
echo "Current encoder position: $CURENCODER"