本文整理汇总了Python中timer.Timer.check_timer方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.check_timer方法的具体用法?Python Timer.check_timer怎么用?Python Timer.check_timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.check_timer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LeapListener
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import check_timer [as 别名]
#.........这里部分代码省略.........
self.prev_frames.pop(0)
self.prev_frames.append(self.frames[0])
self.frames.pop(0)
self.frames.append(controller.frame())
if not frame.hands.is_empty:
if len(frame.hands) == 2:
def task_switcher_callback(obj):
print "Activating task switcher"
obj.active_modes['task_switcher'] = True
obj.backend.start_task_switcher()
obj.lock_gestures()
if not self.active_modes['task_switcher']:
self.timer.factory('task_switcher', task_switcher_callback, self)
if self.check_gestures_timeout():
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_SWIPE:
swipe = Leap.SwipeGesture(gesture)
self.backend.switch_task(frame, swipe)
self.lock_gestures()
if len(frame.hands) <= 1 and self.active_modes['task_switcher']:
def deactivate_task_switcher_callback(obj):
print "Deactivating task switcher"
obj.active_modes['task_switcher'] = False
obj.backend.release_task_switcher()
obj.lock_gestures()
self.timer.factory('deactivate_task_switcher', deactivate_task_switcher_callback, self)
if len(frame.hands) == 1:
# Get the first hand
hand = frame.hands[0]
# Check if the hand has any fingers
fingers = hand.fingers
pitch = hand.direction.pitch * RAD_TO_DEG
if len(fingers) == 1:
pos = self.get_average_palm_position()
self.backend.process_pointer(pos)
if len(fingers) == 0 and (pitch > 45 or self.active_modes['scroll']):
# Checks for scroll timer
if 'scroll' not in self.timer.timers:
self.timer.start_timer('scroll')
elif self.timer.check_timer('scroll'):
del self.timer.timers['scroll']
# Toggles scroll mode
self.active_modes['scroll'] = not self.active_modes['scroll']
print "Toggle scroll mode to %s" % self.active_modes['scroll']
elif 'scroll' in self.timer.timers:
del self.timer.timers['scroll']
if self.active_modes['scroll'] and len(fingers) in (4, 5):
if self.timer.check_timer('scroll_sleep'):
self.backend.scroll(pitch)
del self.timer.timers['scroll_sleep']
if 'scroll_sleep' not in self.timer.timers:
self.timer.start_timer('scroll_sleep')
# Gestures
gesture_found = False
if self.check_gestures_timeout():
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_SWIPE and len(fingers) in (4, 5):
swipe = Leap.SwipeGesture(gesture)
workspaces = self.backend.generate_workspace_matrix(WORKSPACE_TOTAL, WORKSPACE_COLS)
current_position = self.backend.get_position(workspaces, self.backend.get_current_workspace())
new_position = self.backend.find_new_position(workspaces, current_position, swipe.direction)
new_workspace = self.backend.get_workspace_by_position(workspaces, new_position)
self.backend.move_to_workspace(new_workspace)
gesture_found = True
if gesture.type == Leap.Gesture.TYPE_CIRCLE and len(fingers) == 4:
self.backend.lock_screen()
gesture_found = True
if gesture.type == Leap.Gesture.TYPE_KEY_TAP and len(fingers) == 1:
self.backend.click()
self.flush_buffer()
if gesture_found:
self.lock_gestures()
if not (frame.hands.is_empty and frame.gestures().is_empty):
pass
def state_string(self, state):
if state == Leap.Gesture.STATE_START:
return "STATE_START"
if state == Leap.Gesture.STATE_UPDATE:
return "STATE_UPDATE"
if state == Leap.Gesture.STATE_STOP:
return "STATE_STOP"
if state == Leap.Gesture.STATE_INVALID:
return "STATE_INVALID"