Showing
4 changed files
with
24 additions
and
11 deletions
| ... | @@ -48,7 +48,7 @@ def read_raw_data(addr): | ... | @@ -48,7 +48,7 @@ def read_raw_data(addr): |
| 48 | value = value - 65536 | 48 | value = value - 65536 |
| 49 | return value | 49 | return value |
| 50 | 50 | ||
| 51 | -def start_record(data): | 51 | +def start_record(data, timeData): |
| 52 | MPU_Init() | 52 | MPU_Init() |
| 53 | t = threading.currentThread() | 53 | t = threading.currentThread() |
| 54 | print (" Reading Data of Gyroscope and Accelerometer") | 54 | print (" Reading Data of Gyroscope and Accelerometer") |
| ... | @@ -63,6 +63,8 @@ def start_record(data): | ... | @@ -63,6 +63,8 @@ def start_record(data): |
| 63 | value=abs(acc_x+acc_y+acc_z)/10 | 63 | value=abs(acc_x+acc_y+acc_z)/10 |
| 64 | data.append(value) | 64 | data.append(value) |
| 65 | print(value) | 65 | print(value) |
| 66 | - | 66 | + if(time.time()>start_time+60): |
| 67 | - if(time.time()>start_time+10): | ||
| 68 | break | 67 | break |
| 68 | + | ||
| 69 | + end_time = time.time() | ||
| 70 | + timeData.append(round(end_time-start_time,2)) | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
| 28 | <h1>Haptic Data Recording</h1> | 28 | <h1>Haptic Data Recording</h1> |
| 29 | <p style="margin-top: 2%;">Subeen Kang & Jinhyeong Park</p> | 29 | <p style="margin-top: 2%;">Subeen Kang & Jinhyeong Park</p> |
| 30 | <form method ="post" action="/record"> | 30 | <form method ="post" action="/record"> |
| 31 | - <button style="margin-top: 10%;" type="button" id="start" > START </button> | 31 | + <button style="margin-top: 10%;" type="submit" id="start" > START </button> |
| 32 | </form> | 32 | </form> |
| 33 | </div> | 33 | </div> |
| 34 | <script type="module" src="{{url_for('static', filename = 'app.js')}}"></script> | 34 | <script type="module" src="{{url_for('static', filename = 'app.js')}}"></script> | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <title>Haptic Recording</title> | 7 | <title>Haptic Recording</title> |
| 8 | <link rel="stylesheet" href="{{url_for('static', filename = 'style.css')}}"> | 8 | <link rel="stylesheet" href="{{url_for('static', filename = 'style.css')}}"> |
| 9 | <style> | 9 | <style> |
| 10 | - #stop { | 10 | + #stop, #home { |
| 11 | width:100px; | 11 | width:100px; |
| 12 | background-color: #f8585b; | 12 | background-color: #f8585b; |
| 13 | border: none; | 13 | border: none; |
| ... | @@ -29,8 +29,11 @@ | ... | @@ -29,8 +29,11 @@ |
| 29 | <h1>Converting...</h1> | 29 | <h1>Converting...</h1> |
| 30 | <h1 style="margin-top: 2%; color:#f8585b;"id="clock">00:00</h1> | 30 | <h1 style="margin-top: 2%; color:#f8585b;"id="clock">00:00</h1> |
| 31 | <form method ="post" action="/stop"> | 31 | <form method ="post" action="/stop"> |
| 32 | - <button style="margin-top: 10%;" id="stop" type="button"> STOP </button> | 32 | + <button style="margin-top: 10%;" id="stop" type="submit"> STOP </button> |
| 33 | - </form> | 33 | + </form> |
| 34 | + | ||
| 35 | + <button style="margin-top: 10%; visibility: hidden;" id="home" type="button" onclick="location.href='/'"> HOME </button> | ||
| 36 | + | ||
| 34 | </div> | 37 | </div> |
| 35 | <script type="module" src="{{url_for('static', filename = 'app.js')}}"></script> | 38 | <script type="module" src="{{url_for('static', filename = 'app.js')}}"></script> |
| 36 | </body> | 39 | </body> |
| ... | @@ -57,6 +60,8 @@ | ... | @@ -57,6 +60,8 @@ |
| 57 | 60 | ||
| 58 | function stopit(){ | 61 | function stopit(){ |
| 59 | clearInterval(inter); | 62 | clearInterval(inter); |
| 63 | + document.getElementById("home").style.visibility="visible"; | ||
| 64 | + document.getElementById("stop").style.visibility="hidden"; | ||
| 60 | } | 65 | } |
| 61 | 66 | ||
| 62 | document.getElementById('stop').addEventListener('click', stopit); | 67 | document.getElementById('stop').addEventListener('click', stopit); | ... | ... |
| ... | @@ -11,24 +11,29 @@ import time | ... | @@ -11,24 +11,29 @@ import time |
| 11 | app = Flask(__name__) | 11 | app = Flask(__name__) |
| 12 | global data | 12 | global data |
| 13 | global th | 13 | global th |
| 14 | +global timeData | ||
| 15 | +timeData = [] | ||
| 14 | data=[] | 16 | data=[] |
| 15 | -th = threading.Thread(target=acc_test_2.start_record,args=(data,)) | 17 | +th = threading.Thread(target=acc_test_2.start_record,args=(data,timeData,)) |
| 16 | 18 | ||
| 17 | th.setDaemon(True) | 19 | th.setDaemon(True) |
| 18 | @app.route('/') | 20 | @app.route('/') |
| 19 | def upload_main(): | 21 | def upload_main(): |
| 22 | + print(timeData) | ||
| 20 | return render_template('index.html') | 23 | return render_template('index.html') |
| 21 | 24 | ||
| 22 | @app.route('/record', methods=['GET','POST']) | 25 | @app.route('/record', methods=['GET','POST']) |
| 23 | def submit(): | 26 | def submit(): |
| 24 | global th | 27 | global th |
| 25 | global data | 28 | global data |
| 29 | + global timeData | ||
| 26 | print(threading.enumerate()) | 30 | print(threading.enumerate()) |
| 27 | 31 | ||
| 28 | if not th.is_alive(): | 32 | if not th.is_alive(): |
| 29 | print('dead') | 33 | print('dead') |
| 30 | data=[] | 34 | data=[] |
| 31 | - th = threading.Thread(target=acc_test_2.start_record,args=(data,)) | 35 | + timeData=[] |
| 36 | + th = threading.Thread(target=acc_test_2.start_record,args=(data,timeData,)) | ||
| 32 | 37 | ||
| 33 | th.start() | 38 | th.start() |
| 34 | 39 | ||
| ... | @@ -39,13 +44,14 @@ def stop(): | ... | @@ -39,13 +44,14 @@ def stop(): |
| 39 | th.do_run = False | 44 | th.do_run = False |
| 40 | th.join() | 45 | th.join() |
| 41 | print("data length is " + str(len(data))) | 46 | print("data length is " + str(len(data))) |
| 47 | + print("timeData is " + str(timeData[0])) | ||
| 42 | r = upload(data) | 48 | r = upload(data) |
| 43 | return (r.content, r.status_code, r.headers.items()) | 49 | return (r.content, r.status_code, r.headers.items()) |
| 44 | 50 | ||
| 45 | 51 | ||
| 46 | def upload(datas): | 52 | def upload(datas): |
| 47 | - params={'datas':datas} | 53 | + params={'datas':datas, 'timeData':timeData[0]} |
| 48 | - url='http://192.168.0.25:80/upload' | 54 | + url='http://192.168.0.36:80/upload' |
| 49 | return requests.post(url,data =json.dumps(params)) | 55 | return requests.post(url,data =json.dumps(params)) |
| 50 | 56 | ||
| 51 | 57 | ... | ... |
-
Please register or login to post a comment