From 829b179fb06ef17a2b007bf70426c733ae006b4b Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 17 Jun 2022 09:20:27 -0400 Subject: [PATCH 1/3] Add motion detect example --- examples/vc0706_snapshot_motiondetect.py | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/vc0706_snapshot_motiondetect.py diff --git a/examples/vc0706_snapshot_motiondetect.py b/examples/vc0706_snapshot_motiondetect.py new file mode 100644 index 0000000..2ff21ab --- /dev/null +++ b/examples/vc0706_snapshot_motiondetect.py @@ -0,0 +1,42 @@ +import board +import busio +import adafruit_vc0706 + +# Create a serial connection for the VC0706 connection, speed is auto-detected. +uart = busio.UART(board.TX, board.RX) +# Setup VC0706 camera +vc0706 = adafruit_vc0706.VC0706(uart) + +# Print the version string from the camera. +print("VC0706 version:") +print(vc0706.version) + +# Set the baud rate to 115200 for fastest transfer (its the max speed) +vc0706.baudrate = 115200 + +# Set the image size. +vc0706.image_size = adafruit_vc0706.IMAGE_SIZE_160x120 # Or set IMAGE_SIZE_320x240 or +# IMAGE_SIZE_160x120 +# Note you can also read the property and compare against those values to +# see the current size: +size = vc0706.image_size +if size == adafruit_vc0706.IMAGE_SIZE_640x480: + print("Using 640x480 size image.") +elif size == adafruit_vc0706.IMAGE_SIZE_320x240: + print("Using 320x240 size image.") +elif size == adafruit_vc0706.IMAGE_SIZE_160x120: + print("Using 160x120 size image.") + +vc0706.set_motion_detect(1) +print("detecting motion:") +print(vc0706.get_motion_detect()) + +while True: + if vc0706.motion_detected(): + print("Motion!") + print("disable motion detect") + vc0706.set_motion_detect(0) + print("enable motion detect") + vc0706.set_motion_detect(1) + else: + print("....") From 0ab78116647983cf432568204ba2a4498a64c9ac Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 17 Jun 2022 09:24:26 -0400 Subject: [PATCH 2/3] Add license to new example --- examples/vc0706_snapshot_motiondetect.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/vc0706_snapshot_motiondetect.py b/examples/vc0706_snapshot_motiondetect.py index 2ff21ab..b757597 100644 --- a/examples/vc0706_snapshot_motiondetect.py +++ b/examples/vc0706_snapshot_motiondetect.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2017 Tim Cocks for Adafruit Industries +# +# SPDX-License-Identifier: MIT + import board import busio import adafruit_vc0706 From e913c7cebf78df8b63022b1a296e9e11786ff2cc Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 17 Jun 2022 09:30:49 -0400 Subject: [PATCH 3/3] Update example with changes to library since used --- examples/vc0706_snapshot_motiondetect.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/vc0706_snapshot_motiondetect.py b/examples/vc0706_snapshot_motiondetect.py index b757597..aaea368 100644 --- a/examples/vc0706_snapshot_motiondetect.py +++ b/examples/vc0706_snapshot_motiondetect.py @@ -20,7 +20,7 @@ # Set the image size. vc0706.image_size = adafruit_vc0706.IMAGE_SIZE_160x120 # Or set IMAGE_SIZE_320x240 or -# IMAGE_SIZE_160x120 + # Note you can also read the property and compare against those values to # see the current size: size = vc0706.image_size @@ -31,16 +31,12 @@ elif size == adafruit_vc0706.IMAGE_SIZE_160x120: print("Using 160x120 size image.") -vc0706.set_motion_detect(1) -print("detecting motion:") -print(vc0706.get_motion_detect()) +# Turn on motion detection +vc0706.motion_detection = True +# Detect motion while True: - if vc0706.motion_detected(): - print("Motion!") - print("disable motion detect") - vc0706.set_motion_detect(0) - print("enable motion detect") - vc0706.set_motion_detect(1) + if vc0706.motion_detected: + print("Motion detected!") else: print("....")