Skip to content

Add motion detect feature #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 6, 2022
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
17 changes: 17 additions & 0 deletions adafruit_vc0706.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,23 @@ def read_picture_into(self, buf):
buf[i] = self._buffer[i]
return n

def motion_detected(self):
"""Read the gesture detection result"""
self._read_response(self._buffer, len(self._buffer))
if not self._verify_response(_COMM_MOTION_DETECTED):
return False
return True

def get_motion_detect(self):
"""Query the gesture detection status"""
return self._run_command(_COMM_MOTION_STATUS, bytes([0x00]), 6)

def set_motion_detect(self, args):
"""Set gesture detection status
args = 0 to unset, 1 to set
"""
return self._run_command(_COMM_MOTION_CTRL, bytes([0x01, args]), 5)

def _run_command(self, cmd, args, resplen, flush=True):
if flush:
self._read_response(self._buffer, len(self._buffer))
Expand Down