Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stechuhr-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pandemic_Response
stechuhr-client
Commits
f2e656ba
Commit
f2e656ba
authored
Feb 2, 2021
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Seperate out buzzer thread
parent
dda0fd94
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
stechuhr_client/client.py
+14
-7
14 additions, 7 deletions
stechuhr_client/client.py
with
14 additions
and
7 deletions
stechuhr_client/client.py
+
14
−
7
View file @
f2e656ba
...
@@ -114,9 +114,6 @@ def dispatch_led(ledstate, config):
...
@@ -114,9 +114,6 @@ def dispatch_led(ledstate, config):
led_thread
=
threading
.
Thread
(
target
=
set_led
,
args
=
(
ledstate
,
config
,
))
led_thread
=
threading
.
Thread
(
target
=
set_led
,
args
=
(
ledstate
,
config
,
))
led_thread
.
start
()
led_thread
.
start
()
buzzer_thread
=
threading
.
Thread
(
target
=
set_buzzer
,
args
=
(
ledstate
,
config
,
))
buzzer_thread
.
start
()
def
set_led
(
ledstate
,
config
):
def
set_led
(
ledstate
,
config
):
"""
"""
Toggle between differen LED colors
Toggle between differen LED colors
...
@@ -148,8 +145,14 @@ def set_led(ledstate, config):
...
@@ -148,8 +145,14 @@ def set_led(ledstate, config):
# Return to default standby LED color in the end
# Return to default standby LED color in the end
LEDS
.
fill
(
config
[
"
led
"
][
"
standby_color
"
][
0
])
LEDS
.
fill
(
config
[
"
led
"
][
"
standby_color
"
][
0
])
def
dispatch_buzzer
(
state
,
config
):
"""
Dispatch a Buzzer thread with a given Buzzer state
"""
buzzer_thread
=
threading
.
Thread
(
target
=
set_buzzer
,
args
=
(
state
,
config
,
))
buzzer_thread
.
start
()
def
set_buzzer
(
led
state
,
config
):
def
set_buzzer
(
state
,
config
):
global
buzzer_pin
global
buzzer_pin
f
=
220
f
=
220
buzzer
=
GPIO
.
PWM
(
buzzer_pin
,
f
)
# Set frequency to 1 Khz
buzzer
=
GPIO
.
PWM
(
buzzer_pin
,
f
)
# Set frequency to 1 Khz
...
@@ -157,11 +160,12 @@ def set_buzzer(ledstate, config):
...
@@ -157,11 +160,12 @@ def set_buzzer(ledstate, config):
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
buzzer
.
stop
()
buzzer
.
stop
()
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
for
i
in
range
(
10
):
for
i
in
range
(
1
,
10
):
buzzer
.
ChangeFrequency
(
i
*
f
)
# Set frequency to 1 Khz
buzzer
.
ChangeFrequency
(
i
*
f
)
# Set frequency to 1 Khz
buzzer
.
ChangeDutyCycle
(
50
)
# Set dutycycle to 10
buzzer
.
start
(
50
)
# Set dutycycle to 10
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
buzzer
.
stop
()
buzzer
.
stop
()
time
.
sleep
(
0.5
)
def
process_request
(
output_queue
,
config
=
None
,
logger
=
None
):
def
process_request
(
output_queue
,
config
=
None
,
logger
=
None
):
...
@@ -352,6 +356,9 @@ def main():
...
@@ -352,6 +356,9 @@ def main():
outputThread
=
threading
.
Thread
(
target
=
process_request
,
args
=
(
output_queue
,
config
,
logger
),
daemon
=
True
)
outputThread
=
threading
.
Thread
(
target
=
process_request
,
args
=
(
output_queue
,
config
,
logger
),
daemon
=
True
)
outputThread
.
start
()
outputThread
.
start
()
dispatch_buzzer
(
"
startup
"
,
config
)
exit
()
# Set the LED to display readyness
# Set the LED to display readyness
dispatch_led
(
"
startup
"
,
config
)
dispatch_led
(
"
startup
"
,
config
)
...
...
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