Showing
1 changed file
with
12 additions
and
14 deletions
| ... | @@ -4,13 +4,9 @@ import math | ... | @@ -4,13 +4,9 @@ import math |
| 4 | ac_x = 0 | 4 | ac_x = 0 |
| 5 | ac_y = 0 | 5 | ac_y = 0 |
| 6 | ac_z = 0 | 6 | ac_z = 0 |
| 7 | -normal_x = 0 | ||
| 8 | -normal_y = 0 | ||
| 9 | -normal_z = 0 | ||
| 10 | deltha_x = [0,0,0] | 7 | deltha_x = [0,0,0] |
| 11 | deltha_y = [0,0,0] | 8 | deltha_y = [0,0,0] |
| 12 | deltha_z = [0,0,0] | 9 | deltha_z = [0,0,0] |
| 13 | -deltha = 0 | ||
| 14 | 10 | ||
| 15 | def map(x,input_min,input_max,output_min,output_max): | 11 | def map(x,input_min,input_max,output_min,output_max): |
| 16 | return (x-input_min)*(output_max-output_min)/(input_max-input_min)+output_min | 12 | return (x-input_min)*(output_max-output_min)/(input_max-input_min)+output_min |
| ... | @@ -31,8 +27,6 @@ def main(): | ... | @@ -31,8 +27,6 @@ def main(): |
| 31 | deltha_x[i] = 0 | 27 | deltha_x[i] = 0 |
| 32 | deltha_y[i] = 0 | 28 | deltha_y[i] = 0 |
| 33 | deltha_z[i] = 0 | 29 | deltha_z[i] = 0 |
| 34 | - angle = 0 | ||
| 35 | - angle_value = 0 | ||
| 36 | 30 | ||
| 37 | 31 | ||
| 38 | 32 | ||
| ... | @@ -45,16 +39,18 @@ def main(): | ... | @@ -45,16 +39,18 @@ def main(): |
| 45 | ac_y = acceleration.Y | 39 | ac_y = acceleration.Y |
| 46 | ac_z = acceleration.Z | 40 | ac_z = acceleration.Z |
| 47 | 41 | ||
| 48 | - normal_x = map(ac_x, -32768,32767,-5000,5000) | 42 | + normal_x = map(ac_x, -32768,32767,-10000,10000) |
| 49 | - normal_y = map(ac_y, -32768,32767,-5000,5000) | 43 | + normal_y = map(ac_y, -32768,32767,-10000,10000) |
| 50 | normal_z = map(ac_z, -32768,32767,-5000,5000) | 44 | normal_z = map(ac_z, -32768,32767,-5000,5000) |
| 45 | + | ||
| 46 | + | ||
| 51 | deltha_x[1] = deltha_x[1]+(normal_x) | 47 | deltha_x[1] = deltha_x[1]+(normal_x) |
| 52 | deltha_y[1] = deltha_y[1]+(normal_y) | 48 | deltha_y[1] = deltha_y[1]+(normal_y) |
| 53 | deltha_z[1] = deltha_z[1]+(normal_z) | 49 | deltha_z[1] = deltha_z[1]+(normal_z) |
| 54 | 50 | ||
| 55 | - deltha_x[1] = int(deltha_x[1]/4) | 51 | + deltha_x[1] = int(deltha_x[1]/4) |
| 56 | - deltha_y[1] = int(deltha_y[1]/4) | 52 | + deltha_y[1] = int(deltha_y[1]/4) |
| 57 | - deltha_z[1] = int(deltha_z[1]/4) | 53 | + deltha_z[1] = int(deltha_z[1]/4) |
| 58 | 54 | ||
| 59 | 55 | ||
| 60 | 56 | ||
| ... | @@ -67,9 +63,11 @@ def main(): | ... | @@ -67,9 +63,11 @@ def main(): |
| 67 | ac_y = acceleration.Y | 63 | ac_y = acceleration.Y |
| 68 | ac_z = acceleration.Z | 64 | ac_z = acceleration.Z |
| 69 | 65 | ||
| 70 | - normal_x = map(ac_x, -32768,32767,-5000,5000) | 66 | + normal_x = map(ac_x, -32768,32767,-10000,10000) |
| 71 | - normal_y = map(ac_y, -32768,32767,-5000,5000) | 67 | + normal_y = map(ac_y, -32768,32767,-10000,10000) |
| 72 | normal_z = map(ac_z, -32768,32767,-5000,5000) | 68 | normal_z = map(ac_z, -32768,32767,-5000,5000) |
| 69 | + | ||
| 70 | + | ||
| 73 | deltha_x[2] = deltha_x[2]+(normal_x) | 71 | deltha_x[2] = deltha_x[2]+(normal_x) |
| 74 | deltha_y[2] = deltha_y[2]+(normal_y) | 72 | deltha_y[2] = deltha_y[2]+(normal_y) |
| 75 | deltha_z[2] = deltha_z[2]+(normal_z) | 73 | deltha_z[2] = deltha_z[2]+(normal_z) |
| ... | @@ -82,7 +80,7 @@ def main(): | ... | @@ -82,7 +80,7 @@ def main(): |
| 82 | deltha_y[0] = abs(deltha_y[1]-deltha_y[2]) | 80 | deltha_y[0] = abs(deltha_y[1]-deltha_y[2]) |
| 83 | deltha_z[0] = abs(deltha_z[1]-deltha_z[2]) | 81 | deltha_z[0] = abs(deltha_z[1]-deltha_z[2]) |
| 84 | deltha = deltha_x[0] + deltha_y[0] + deltha_z[0] | 82 | deltha = deltha_x[0] + deltha_y[0] + deltha_z[0] |
| 85 | - print("AcX : ", deltha_x[0], "AcY : ", deltha_y[0], "AcZ : ", deltha_z[0] - 230, "Total : ", deltha) | 83 | + print("AcX : ", deltha_x[0], "AcY : ", deltha_y[0], "AcZ : ", deltha_z[0], "Total : ", deltha) |
| 86 | 84 | ||
| 87 | 85 | ||
| 88 | if __name__ == '__main__': | 86 | if __name__ == '__main__': | ... | ... |
-
Please register or login to post a comment