Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ev3dev/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,21 @@ def wait(self, cond, timeout=None):
if cond(self.state):
return True

def wait_until_not_moving(self, timeout=None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a documentation comment here so that it shows up on the docs site.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used it when solving a 5x5x5 cube which was about 9 minutes of off/on movement of three large motors and a medium motor. If it had exited early it would have caused the cube to jam up but it was smooth sailing so I think it is good to go.

I'll add a docstring to it in the morning.

"""
Blocks until ``running`` is not in ``self.state`` or ``stalled`` is in
``self.state``. The condition is checked when there is an I/O event
related to the ``state`` attribute. Exits early when ``timeout``
(in milliseconds) is reached.

Returns ``True`` if the condition is met, and ``False`` if the timeout
is reached.

Example::

m.wait_until_not_moving()
"""
return self.wait(lambda state: self.STATE_RUNNING not in state or self.STATE_STALLED in state, timeout)

def wait_until(self, s, timeout=None):
"""
Expand Down