Ok try this code
[code]#!/usr/bin/env python
import cv2, sys, time, os
from pantilthat import *
servo_enable(1,1)
servo_enable(2,1)
pan(90)
tilt(90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(-90)
tilt(-90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(90)
tilt(90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(-90)
tilt(-90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(90)
tilt(90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(-90)
tilt(-90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(90)
tilt(90)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
time.sleep(5)
servo_enable(1,1)
servo_enable(2,1)
pan(-30)
tilt(0)
time.sleep(.7)
servo_enable(1,0)
servo_enable(2,0)
[/code]
I don’t really like the way its been implemented though as without the delay you will disable the servo before its finished the 1.6sec/60degree movement hence why I used .7.
It would be great if the pic had a register auto_shutoff_time where the pic would increment on each cycle and turn off the servo, also if zero then don’t turn off.
I have no idea how many registers that pic has or what can be done with it and how it could be flashed.
I found my problem about rotation but the whole pantilthad module is full of more arguments.
Easiest way is to sudo pcmanfm
Then navigate to /usr/local/lib/python2.7/dist-packages/pantilthat/pantilt.py and have look.
I sorted my rotation problem with
def __init__(self,
enable_servo1 = True,
enable_servo2 = True,
enable_lights = True,
light_mode = WS2812,
servo1_min = 575,
servo1_max = 2325,
servo2_min = 575,
servo2_max = 2325,
address = 0x15,
i2c_bus = None):
As you will see you are going from 800 to 2300 which aint 180 degrees servo’s have a little more than rated because they are analogue and you need to trim them.
The movement on the pan tilt is prob offset by 5 - 10 degrees physically and I have kept it as such so that its out of the dead zones as much as possible.
Its prob just a spline notch out of place or just sitting in a bad position and will have to trim back the rated minimium of 500 and knock the equivalent about off the top value.
doing the sudo pcmanfm will give you root access so you can edit the module but it will get overwritten on a lib upgrade from pimorini.
You can do the via python [code] def servo_pulse_min(self, index, value):
"""Set the minimum high pulse for a servo in microseconds.
:param value: Value in microseconds
"""
if index not in [1,2]:
raise ValueError("Servo index must be 1 or 2")
self._servo_min[index-1] = value
def servo_pulse_max(self, index, value):
"""Set the maximum high pulse for a servo in microseconds.
:param value: Value in microseconds
"""
if index not in [1,2]:
raise ValueError("Servo index must be 1 or 2")
self._servo_max[index-1] = value
[/code]
so
servo2 is servo_min(2…