Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Chris
Pixelframe
Commits
c8832518
Commit
c8832518
authored
Dec 22, 2020
by
Christian Wander
Browse files
rename and reformat
parent
bbe276aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
pixelframe/controllers.py
View file @
c8832518
...
...
@@ -12,12 +12,12 @@ def main_page():
def
hello_method
():
return
render_template
(
'hello.html'
,
name
=
"foo"
)
@
app
.
route
(
'/
threadfun
'
)
@
app
.
route
(
'/
start
'
)
def
threadfun
():
t
.
doit
()
return
"Started work."
@
app
.
route
(
'/
thread
stop'
)
@
app
.
route
(
'/stop'
)
def
threadstop
():
t
.
stopit
()
return
"Stopped work"
\ No newline at end of file
pixelframe/threadfun.py
View file @
c8832518
import
threading
,
queue
import
threading
import
queue
import
time
import
pixelframe.blink
as
blink
...
...
@@ -6,17 +7,18 @@ import sacn
running
=
False
def
doit
():
global
running
if
running
is
True
:
print
(
">> DEBUG: already running."
)
return
return
print
(
f
'>> Starting a thread ...'
)
running
=
True
x
=
threading
.
Thread
(
target
=
threaded_function
,
daemon
=
True
)
x
=
threading
.
Thread
(
target
=
display_pixels
,
daemon
=
True
)
x
.
start
()
print
(
f
'>> Thread started.'
)
...
...
@@ -24,9 +26,9 @@ def doit():
def
stopit
():
global
running
running
=
False
def
threaded_function
():
def
display_pixels
():
universe
=
1
sender
=
sacn
.
sACNsender
()
...
...
@@ -39,7 +41,6 @@ def threaded_function():
pic
=
blink
.
Thing
(
file
=
"data/cyber-12x12.png"
)
sender
[
universe
].
dmx_data
=
pic
.
snake_tuple
()
time
.
sleep
(
2
)
sender
.
stop
()
print
(
f
'>> Finished work within thread!'
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment