-
Notifications
You must be signed in to change notification settings - Fork 0
/
clap.py
39 lines (28 loc) · 992 Bytes
/
clap.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/python3
from piclap import *
import os
class Config(Settings):
'''Describes custom configurations and action methods to be executed based
on the number of claps detected.
'''
def __init__(self):
super().__init__()
self.chunk_size = 512 # Reduce as power of 2 if pyaudio overflow
self.interval = 0.5 # Adjust interval between claps
self.method.value = 9000 # Threshold value adjustment
def on1Claps(self):
os.system("open /Applications/Safari.app https://www.youtube.com/watch?v=HhoATZ1Imtw")
def on2Claps(self):
'''Custom action for 2 claps'''
print("You are clapping do something fun?")
def on3Claps(self):
'''Custom action for 3 claps'''
print("Light toggled on pin 6")
def on100Claps(self):
print("YOU'RE WEIRD!")
def main():
config = Config()
listener = Listener(config)
listener.start()
if __name__ == '__main__':
main()