Skip to content
Snippets Groups Projects
Commit 4996af46 authored by Jess Ward's avatar Jess Ward
Browse files

added main darkmut function and minor tweaks

parent 178fadee
No related branches found
No related tags found
No related merge requests found
#!/usr/local/bin/python
import RPi.GPIO as GPIO
import time
import snapcast.control
GPIO.setmode(GPIO.BOARD)
SENSOR_PIN = 7
pin_to_circuit = 7
def rc_time (pin_to_circuit):
count = 0
def measure_brightness(pin_to_circuit):
'''Measure brightness using photoresistor-capacitor circuit.'''
charge_time = 0
GPIO.setup(pin_to_circuit, GPIO.OUT)
GPIO.output(pin_to_circuit, GPIO.LOW)
......@@ -17,15 +16,21 @@ def rc_time (pin_to_circuit):
GPIO.setup(pin_to_circuit, GPIO.IN)
while (GPIO.input(pin_to_circuit) == GPIO.LOW):
count += 1
charge_time += 1
return 1/charge_time
return count
def dark_mute():
GPIO.setmode(GPIO.BOARD)
try:
while True:
print(measure_brightness(SENSOR_PIN))
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
try:
while True:
print rc_time(pin_to_circuit)
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
if __name__ == '__main__':
dark_mute()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment