Beispiel #1
0
    def control(vDelta=0, hDelta=0):
        Servo.initialize()
        if vDelta != 0:
            duty_cycle = float(Database().get(Servo.V_DB_KEY))
            duty_cycle += vDelta
            duty_cycle = max(duty_cycle, 2.5)
            duty_cycle = min(duty_cycle, 12.5)
            print(duty_cycle)
            Database().set(Servo.V_DB_KEY, duty_cycle)
            Servo.vPin.ChangeDutyCycle(duty_cycle)
            time.sleep(0.02)
            Servo.vPin.ChangeDutyCycle(0)
            time.sleep(0.05)

        if hDelta != 0:
            duty_cycle = float(Database().get(Servo.H_DB_KEY))
            duty_cycle += hDelta
            duty_cycle = max(duty_cycle, 2.5)
            duty_cycle = min(duty_cycle, 12.5)
            print(duty_cycle)
            Database().set(Servo.H_DB_KEY, duty_cycle)
            Servo.hPin.ChangeDutyCycle(duty_cycle)
            time.sleep(0.02)
            Servo.hPin.ChangeDutyCycle(0)
            time.sleep(0.05)
Beispiel #2
0
    def initialize():
        if Servo.hPin is None and Servo.vPin is None:
            if Database().get(Servo.H_DB_KEY) is None:
                Database().set(Servo.H_DB_KEY, 7.5)
            if Database().get(Servo.V_DB_KEY) is None:
                Database().set(Servo.V_DB_KEY, 7.5)

            ## horizontal servo
            GPIO.setmode(GPIO.BCM)
            GPIO.setup(17, GPIO.OUT, initial=False)
            Servo.hPin = GPIO.PWM(17, 50)  # 50HZ
            Servo.hPin.start(0)

            ## vertical servo
            GPIO.setup(19, GPIO.OUT, initial=False)
            Servo.vPin = GPIO.PWM(19, 50)  # 50HZ
            Servo.vPin.start(0)
Beispiel #3
0
 def getBrightness():
     value = Database().get("brightness")
     if value is None:
         value = 60
         Database().set("brightness", value)
     return value
Beispiel #4
0
 def setBrightness(delta):
     value = int(Camera.getBrightness()) + int(delta)
     value = min(100, max(0, value))
     Database().set("brightness", value)
Beispiel #5
0
 def is_enable_face_detect():
     return Database().get("face_detect") == "1"
Beispiel #6
0
 def disable_face_detect():
     Database().set("face_detect", "0")
Beispiel #7
0
 def enable_face_detect():
     Database().set("face_detect", "1")