-
Notifications
You must be signed in to change notification settings - Fork 0
/
led.py
43 lines (38 loc) · 931 Bytes
/
led.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
40
41
42
43
import subprocess, settings, signal, sys
import RPi.GPIO as GPIO
from time import sleep
def set(r, g, b):
GPIO.output(settings.RED, r)
GPIO.output(settings.GREEN, g)
GPIO.output(settings.BLUE, b)
def lock():
flash = True
for i in range(0, settings.SPINTIME * settings.BLINKFRACTION):
if flash:
set(1, 1, 1)
else:
set(0, 1, 0)
flash = not flash
sleep(1.0 / settings.BLINKFRACTION)
set(0, 1, 0)
def unlock():
flash = True
for i in range(0, settings.SPINTIME * settings.BLINKFRACTION):
if flash:
set(1, 1, 0)
else:
set(0, 1, 0)
flash = not flash
sleep(1.0 / settings.BLINKFRACTION)
set(0, 1, 0)
def setup():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(settings.GREEN, GPIO.OUT)
GPIO.setup(settings.RED, GPIO.OUT)
GPIO.setup(settings.BLUE, GPIO.OUT)
GPIO.output(settings.GREEN, False)
GPIO.output(settings.RED, False)
GPIO.output(settings.BLUE, False)
def exit():
set(0, 0, 0)
GPIO.cleanup()