libfidl.py
def run(self):
        """
            Constantly checking wheather someone tries to leave the room, to unlock the door
        """
        try:
            self._init_GPIO()
            #move servo to resting postion
            self._set_servo_power(True)
            self._set_servo_angle(72)
            time.sleep(2)
            self._set_servo_power(False)

            #taking measueremnts and gethering approaching status
            while True:
                #unlocking is only relevant if the door is closed
                if self.is_door_closed():
                    for i in range(len(self.measurements)):
                        self.measurements[i] = (time.time(),self.get_distance())
                        time.sleep(0.1)
                        if not self.is_door_closed():
                            self._reset_measurements()
                            break
                        elif self.approach_detected() and self.unlocking == False: 
                            #unlocking the door
                            self.unlock()
                            self._reset_measurements()

        except KeyboardInterrupt:
            #move servo to resting postion
            self._set_servo_power(True)
            self._set_servo_angle(72)
            time.sleep(2)
            self.pulse.stop()
            self._set_servo_power(False)

            GPIO.cleanup()

            Constantly checking wheather someone tries to leave the room, to unlock the door
        
Constantly checking wheather someone tries to leave the room, to unlock the door
Constantly checking wheather someone tries to leave the room to unlock the door
def run(self):
        try:
            self._init_GPIO()
            self._set_servo_power(True)
            self._set_servo_angle(72)
            time.sleep(2)
            self._set_servo_power(False)
            while True:
                if self.is_door_closed():
                    for i in range(len(self.measurements)):
                        self.measurements[i] = (time.time(),self.get_distance())
                        time.sleep(0.1)
                        if not self.is_door_closed():
                            self._reset_measurements()
                            break
                        elif self.approach_detected() and self.unlocking == False: 
                            self.unlock()
                            self._reset_measurements()
        except KeyboardInterrupt:
            self._set_servo_power(True)
            self._set_servo_angle(72)
            time.sleep(2)
            self.pulse.stop()
            self._set_servo_power(False)
            GPIO.cleanup()
def run ( self ) : try : self . _init_GPIO ( ) self . _set_servo_power ( True ) self . _set_servo_angle ( 72 ) time . sleep ( 2 ) self . _set_servo_power ( False ) while True : if self . is_door_closed ( ) : for i in range ( len ( self . measurements ) ) : self . measurements [ i ] = ( time . time ( ) , self . get_distance ( ) ) time . sleep ( 0.1 ) if not self . is_door_closed ( ) : self . _reset_measurements ( ) break elif self . approach_detected ( ) and self . unlocking == False : self . unlock ( ) self . _reset_measurements ( ) except KeyboardInterrupt : self . _set_servo_power ( True ) self . _set_servo_angle ( 72 ) time . sleep ( 2 ) self . pulse . stop ( ) self . _set_servo_power ( False ) GPIO . cleanup ( )
Constantly checking wheather someone tries to leave the room, to unlock the door
Constantly checking wheather someone tries to leave the room to unlock the door
"""
            Constantly checking wheather someone tries to leave the room, to unlock the door
        """ #move servo to resting postion #taking measueremnts and gethering approaching status #unlocking is only relevant if the door is closed #unlocking the door #move servo to resting postion
self