def pose_handler(self, p): if p == Pose(0): pn = 0 elif p == Pose(1): pn = 1 elif p == Pose(2): pn = 2 elif p == Pose(3): pn = 3 elif p == Pose(4): pn = 4 elif p == Pose(5): pn = 5 else: pn = 6 if pn != self.last_pose: self.gest_history = str(self.gest_history[-100:]) + str( self.PoseToChar(pn)) self.act_history = str(self.act_history[-100:]) + str( self.PoseToChar(pn)) if self.locked == False: self.time_to_lock = self.lock_time if self.onPoseEdge != None: if self.last_pose > -1: self.onPoseEdge(self.PoseToStr(self.last_pose), 'off') self.onPoseEdge(self.PoseToStr(pn), 'on') self.last_pose = pn if pn == 5 and self.locked and self.use_lock: self.locked = False self.vibrate(1) print('unlock') if self.onUnlock != None: self.onUnlock()
def pose_handler(self, p): """Pose handler.""" if p == Pose(0): pn = 0 elif p == Pose(1): pn = 1 elif p == Pose(2): pn = 2 elif p == Pose(3): pn = 3 elif p == Pose(4): pn = 4 elif p == Pose(5): pn = 5 else: pn = 6 if pn != self.last_pose: self.gest_history = str(self.gest_history[-100:]) + str( self.PoseToChar(pn)) self.act_history = str(self.act_history[-100:]) + str( self.PoseToChar(pn)) if self.locked == False: self.time_to_lock = self.lock_time if self.last_pose > -1: if self.onPoseEdge is not None: self.onPoseEdge(self.PoseToStr(self.last_pose), 'off') for h in self.onPoseEdgeList: h(self.PoseToStr(pn), 'off') if self.onPoseEdge is not None: self.onPoseEdge(self.PoseToStr(pn), 'on') for h in self.onPoseEdgeList: h(self.PoseToStr(pn), 'on') self.last_pose = pn if pn == 5 and self.locked and self.use_lock: self.locked = False self.vibrate(1) if self.verbose: print('unlock') if self.onUnlock is not None: self.onUnlock() for h in self.onUnlockList: h() return