-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotionDummy.py
More file actions
64 lines (45 loc) · 1.45 KB
/
motionDummy.py
File metadata and controls
64 lines (45 loc) · 1.45 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
#!/usr/bin/env python3
import random
import time
def destroy():
return
class PIR:
lastReading = False
motion = []
class Light:
colors = {'red' : 0xFF0000, 'green' : 0x00FF00, 'blue' : 0x0000FF}
def __init__(light, rPin = 13, gPin = 19, bPin = 26):
return
def red(light):
return
def green(light):
return
def blue(light):
return
def MAP(light, x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
# Define a function to set up colors
def setColor(light, color):
return
def __init__(self, pin = 27):
self.pirPin = pin
self.light = self.Light(rPin = 13, gPin = 19, bPin = 26)
def getMotion(self):
sample = 1000
switchTest = random.randint(0,sample)
if (switchTest>float(sample*.95) and self.lastReading == False) or self.lastReading==True:
self.lastReading = not self.lastReading
self.motion = [self.lastReading] + self.motion
self.motion.pop()
return self.lastReading
def getLastReading(self):
return self.lastReading
def getMotionList(self):
return self.motion
def getSensors(self,output = False):
data = {'motion': self.getMotion()}
if (output):
print(data)
return (data)
def cleanup(self):
destroy()