forked from ArduCAM/RPI_Motorized_IRCut_Control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpi_zero_w_ircut_ctl.py
40 lines (32 loc) · 1.02 KB
/
pi_zero_w_ircut_ctl.py
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
#!/usr/bin/env python
import os, fcntl, struct
# RaspberryPi zero w camera LED controller by Arducam
class CameraLED():
def on(self):
cmd="echo 1 > /sys/class/gpio/gpio40/value"
os.system(cmd)
return "on" #self.__firmware_request__(self.SET_TAG, 1)
def off(self):
cmd="echo 0 > /sys/class/gpio/gpio40/value"
os.system(cmd)
return "off" #self.__firmware_request__(self.SET_TAG, 0)
# def state(self):
#return self.__firmware_request__(self.GET_TAG)
if __name__ == "__main__":
import sys
def usage():
print("Usage: " + sys.argv[0] + " (on|off)")
cmd="echo 40 > /sys/class/gpio/export"
os.system(cmd)
cmd="echo out > /sys/class/gpio/gpio40/direction"
os.system(cmd)
if len(sys.argv) == 2:
led = CameraLED()
if sys.argv[1] == "on":
print("State: " + str(led.on()))
elif sys.argv[1] == "off":
print("State: " + str(led.off()))
else:
usage()
else:
usage()