Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design2
/
2016104096
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
subeen
2020-12-13 11:16:59 -1000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
93177da7a4ffdc5e8a28debd4c52b6aad7b64c20
93177da7
1 parent
c8dfc63a
hz계산 라즈베리파이 코드 수정
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
code/acc_test_2.py
code/templates/index.html
code/templates/record.html
code/webserver.py
code/acc_test_2.py
View file @
93177da
...
...
@@ -48,7 +48,7 @@ def read_raw_data(addr):
value
=
value
-
65536
return
value
def
start_record
(
data
):
def
start_record
(
data
,
timeData
):
MPU_Init
()
t
=
threading
.
currentThread
()
print
(
" Reading Data of Gyroscope and Accelerometer"
)
...
...
@@ -63,6 +63,8 @@ def start_record(data):
value
=
abs
(
acc_x
+
acc_y
+
acc_z
)
/
10
data
.
append
(
value
)
print
(
value
)
if
(
time
.
time
()
>
start_time
+
10
):
if
(
time
.
time
()
>
start_time
+
60
):
break
end_time
=
time
.
time
()
timeData
.
append
(
round
(
end_time
-
start_time
,
2
))
\ No newline at end of file
...
...
code/templates/index.html
View file @
93177da
...
...
@@ -28,7 +28,7 @@
<h1>
Haptic Data Recording
</h1>
<p
style=
"margin-top: 2%;"
>
Subeen Kang
&
Jinhyeong Park
</p>
<form
method =
"post"
action=
"/record"
>
<button
style=
"margin-top: 10%;"
type=
"
button
"
id=
"start"
>
START
</button>
<button
style=
"margin-top: 10%;"
type=
"
submit
"
id=
"start"
>
START
</button>
</form>
</div>
<script
type=
"module"
src=
"{{url_for('static', filename = 'app.js')}}"
></script>
...
...
code/templates/record.html
View file @
93177da
...
...
@@ -7,7 +7,7 @@
<title>
Haptic Recording
</title>
<link
rel=
"stylesheet"
href=
"{{url_for('static', filename = 'style.css')}}"
>
<style>
#stop
{
#stop
,
#home
{
width
:
100px
;
background-color
:
#f8585b
;
border
:
none
;
...
...
@@ -29,8 +29,11 @@
<h1>
Converting...
</h1>
<h1
style=
"margin-top: 2%; color:#f8585b;"
id=
"clock"
>
00:00
</h1>
<form
method =
"post"
action=
"/stop"
>
<button
style=
"margin-top: 10%;"
id=
"stop"
type=
"button"
>
STOP
</button>
</form>
<button
style=
"margin-top: 10%;"
id=
"stop"
type=
"submit"
>
STOP
</button>
</form>
<button
style=
"margin-top: 10%; visibility: hidden;"
id=
"home"
type=
"button"
onclick=
"location.href='/'"
>
HOME
</button>
</div>
<script
type=
"module"
src=
"{{url_for('static', filename = 'app.js')}}"
></script>
</body>
...
...
@@ -57,6 +60,8 @@
function
stopit
(){
clearInterval
(
inter
);
document
.
getElementById
(
"home"
).
style
.
visibility
=
"visible"
;
document
.
getElementById
(
"stop"
).
style
.
visibility
=
"hidden"
;
}
document
.
getElementById
(
'stop'
).
addEventListener
(
'click'
,
stopit
);
...
...
code/webserver.py
View file @
93177da
...
...
@@ -11,24 +11,29 @@ import time
app
=
Flask
(
__name__
)
global
data
global
th
global
timeData
timeData
=
[]
data
=
[]
th
=
threading
.
Thread
(
target
=
acc_test_2
.
start_record
,
args
=
(
data
,))
th
=
threading
.
Thread
(
target
=
acc_test_2
.
start_record
,
args
=
(
data
,
timeData
,
))
th
.
setDaemon
(
True
)
@app.route
(
'/'
)
def
upload_main
():
print
(
timeData
)
return
render_template
(
'index.html'
)
@app.route
(
'/record'
,
methods
=
[
'GET'
,
'POST'
])
def
submit
():
global
th
global
data
global
timeData
print
(
threading
.
enumerate
())
if
not
th
.
is_alive
():
print
(
'dead'
)
data
=
[]
th
=
threading
.
Thread
(
target
=
acc_test_2
.
start_record
,
args
=
(
data
,))
timeData
=
[]
th
=
threading
.
Thread
(
target
=
acc_test_2
.
start_record
,
args
=
(
data
,
timeData
,))
th
.
start
()
...
...
@@ -39,13 +44,14 @@ def stop():
th
.
do_run
=
False
th
.
join
()
print
(
"data length is "
+
str
(
len
(
data
)))
print
(
"timeData is "
+
str
(
timeData
[
0
]))
r
=
upload
(
data
)
return
(
r
.
content
,
r
.
status_code
,
r
.
headers
.
items
())
def
upload
(
datas
):
params
=
{
'datas'
:
datas
}
url
=
'http://192.168.0.
25
:80/upload'
params
=
{
'datas'
:
datas
,
'timeData'
:
timeData
[
0
]
}
url
=
'http://192.168.0.
36
:80/upload'
return
requests
.
post
(
url
,
data
=
json
.
dumps
(
params
))
...
...
Please
register
or
login
to post a comment