Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save samirsogay/4e05779aa0a95fa10c6ac22d097514f0 to your computer and use it in GitHub Desktop.
Save samirsogay/4e05779aa0a95fa10c6ac22d097514f0 to your computer and use it in GitHub Desktop.
Pan Tilt code for Motioneye
down_2
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/vert_pos_2', 'r') as f:
vert_pos_2 = int(f.readline())
print vert_pos_2
f.close()
vert_pos_2 += 15
if vert_pos_2>180:
vert_pos_2=180
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/tilt/' + str(vert_pos_2) + ' > /dev/null', shell=True)
with open('/etc/motioneye/vert_pos_2', 'w') as f:
f.write(str(vert_pos_2))
f.close()
raise SystemExit
down_3
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/vert_pos_3', 'r') as f:
vert_pos_3 = int(f.readline())
print vert_pos_3
f.close()
vert_pos_3 += 15
if vert_pos_3>180:
vert_pos_3=180
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/tilt/' + str(vert_pos_3) + ' > /dev/null', shell=True)
with open('/etc/motioneye/vert_pos_3', 'w') as f:
f.write(str(vert_pos_3))
f.close()
raise SystemExit
left_2
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/horz_pos_2', 'r') as f:
horz_pos_2 = int(f.readline())
print horz_pos_2
f.close()
horz_pos_2 -= 15
if horz_pos_2<0:
horz_pos_2=0
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/pan/' + str(horz_pos_2) + ' > /dev/null', shell=True)
with open('/etc/motioneye/horz_pos_2', 'w') as f:
f.write(str(horz_pos_2))
f.close()
raise SystemExit
left_3
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/horz_pos_3', 'r') as f:
horz_pos_3 = int(f.readline())
print horz_pos_3
f.close()
horz_pos_3 += 15
if horz_pos_3>180:
horz_pos_3=180
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/pan/' + str(horz_pos_3) + ' > /dev/null', shell=True)
with open('/etc/motioneye/horz_pos_3', 'w') as f:
f.write(str(horz_pos_3))
f.close()
raise SystemExit
preset1_2
#!/bin/bash
URL1="http://192.168.100.159/arduino/pan/90"
URL2="http://192.168.100.159/arduino/tilt/90"
METHOD="POST"
TIMEOUT="5"
curl -X $METHOD --connect-timeout $TIMEOUT "$URL1" > /dev/null
curl -X $METHOD --connect-timeout $TIMEOUT "$URL2" > /dev/null
preset1_3
#!/bin/bash
URL1="http://192.168.100.114:9595/api/pan/90"
URL2="http://192.168.100.114:9595/api/tilt/120"
METHOD="GET"
TIMEOUT="5"
curl -X $METHOD --connect-timeout $TIMEOUT "$URL1" > /dev/null
curl -X $METHOD --connect-timeout $TIMEOUT "$URL2" > /dev/null
right_2
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/horz_pos_2', 'r') as f:
horz_pos_2 = int(f.readline())
print horz_pos_2
f.close()
horz_pos_2 += 15
if horz_pos_2>180:
horz_pos_2=180
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/pan/' + str(horz_pos_2) + ' > /dev/null', shell=True)
with open('/etc/motioneye/horz_pos_2', 'w') as f:
f.write(str(horz_pos_2))
f.close()
raise SystemExit
right_3
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/horz_pos_3', 'r') as f:
horz_pos_3 = int(f.readline())
print horz_pos_3
f.close()
horz_pos_3 -= 15
if horz_pos_3<0:
horz_pos_3=0
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/pan/' + str(horz_pos_3) + ' > /dev/null', shell=True)
with open('/etc/motioneye/horz_pos_3', 'w') as f:
f.write(str(horz_pos_3))
f.close()
raise SystemExit
up_2
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/vert_pos_2', 'r') as f:
vert_pos_2 = int(f.readline())
print vert_pos_2
f.close()
vert_pos_2 -= 15
if vert_pos_2<0:
vert_pos_2=0
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/tilt/' + str(vert_pos_2) + ' > /dev/null', shell=True)
with open('/etc/motioneye/vert_pos_2', 'w') as f:
f.write(str(vert_pos_2))
f.close()
raise SystemExit
up_3
#!/usr/bin/env python
from __future__ import division
import time
import subprocess
with open('/etc/motioneye/vert_pos_3', 'r') as f:
vert_pos_3 = int(f.readline())
print vert_pos_3
f.close()
vert_pos_3 -= 15
if vert_pos_3<0:
vert_pos_3=0
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/tilt/' + str(vert_pos_3) + ' > /dev/null', shell=True)
with open('/etc/motioneye/vert_pos_3', 'w') as f:
f.write(str(vert_pos_3))
f.close()
raise SystemExit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment