-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.py
More file actions
68 lines (52 loc) · 1.54 KB
/
camera.py
File metadata and controls
68 lines (52 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import time
import RPi.GPIO as GPIO
from ignore_motion import ignore_motion_for
# Toggle IR LED (ON or OFF)
# Setup GPIO mode
GPIO.setmode(GPIO.BCM)
# Set the GPIO pin that controls the IR LED
IR_LED_PIN = 17 # Change this pin number to match your setup
IR_FILTER_A_PIN = 20
IR_FILTER_B_PIN = 21
GPIO.setup(IR_LED_PIN, GPIO.OUT)
GPIO.setup(IR_FILTER_A_PIN, GPIO.OUT)
GPIO.setup(IR_FILTER_B_PIN, GPIO.OUT)
ignore_motion_for(10)
GPIO.output(IR_LED_PIN, GPIO.LOW)
GPIO.output(IR_FILTER_A_PIN, GPIO.LOW)
GPIO.output(IR_FILTER_B_PIN, GPIO.LOW)
ir_led_state = False
ir_filter_state = False
def turn_ir_on():
global ir_led_state
ir_led_state = True
GPIO.output(IR_LED_PIN, GPIO.HIGH)
def turn_ir_off():
ignore_motion_for(10)
global ir_led_state
ir_led_state = False
GPIO.output(IR_LED_PIN, GPIO.LOW)
def get_ir_led_state():
global ir_led_state
time.sleep(0.1)
return ir_led_state
def turn_ir_filter_on():
global ir_filter_state
ir_filter_state = True
GPIO.output(IR_FILTER_A_PIN, GPIO.HIGH)
GPIO.output(IR_FILTER_B_PIN, GPIO.LOW)
time.sleep(1.0)
GPIO.output(IR_FILTER_A_PIN, GPIO.LOW)
GPIO.output(IR_FILTER_B_PIN, GPIO.LOW)
def turn_ir_filter_off():
global ir_filter_state
ir_filter_state = False
GPIO.output(IR_FILTER_A_PIN, GPIO.LOW)
GPIO.output(IR_FILTER_B_PIN, GPIO.HIGH)
time.sleep(1.0)
GPIO.output(IR_FILTER_A_PIN, GPIO.LOW)
GPIO.output(IR_FILTER_B_PIN, GPIO.LOW)
def get_ir_filter_state():
global ir_filter_state
time.sleep(0.1)
return ir_filter_state