Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dark-Mute
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jess Ward
Dark-Mute
Commits
4996af46
Commit
4996af46
authored
6 years ago
by
Jess Ward
Browse files
Options
Downloads
Patches
Plain Diff
added main darkmut function and minor tweaks
parent
178fadee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
darkmute.py
+20
-15
20 additions, 15 deletions
darkmute.py
with
20 additions
and
15 deletions
darkmute.py
+
20
−
15
View file @
4996af46
#!/usr/local/bin/python
import
RPi.GPIO
as
GPIO
import
RPi.GPIO
as
GPIO
import
time
import
time
import
snapcast.control
GPIO
.
setmode
(
GPIO
.
BOARD
)
SENSOR_PIN
=
7
pin_to_circuit
=
7
def
rc_time
(
pin_to_circuit
):
def
measure_brightness
(
pin_to_circuit
):
count
=
0
'''
Measure brightness using photoresistor-capacitor circuit.
'''
charge_time
=
0
GPIO
.
setup
(
pin_to_circuit
,
GPIO
.
OUT
)
GPIO
.
setup
(
pin_to_circuit
,
GPIO
.
OUT
)
GPIO
.
output
(
pin_to_circuit
,
GPIO
.
LOW
)
GPIO
.
output
(
pin_to_circuit
,
GPIO
.
LOW
)
...
@@ -17,15 +16,21 @@ def rc_time (pin_to_circuit):
...
@@ -17,15 +16,21 @@ def rc_time (pin_to_circuit):
GPIO
.
setup
(
pin_to_circuit
,
GPIO
.
IN
)
GPIO
.
setup
(
pin_to_circuit
,
GPIO
.
IN
)
while
(
GPIO
.
input
(
pin_to_circuit
)
==
GPIO
.
LOW
):
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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment