DrawAxis.pde 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. void drawAxisX() {
  2. /* Draw gyro x-axis */
  3. noFill();
  4. stroke(255, 255, 0); // Yellow
  5. // Redraw everything
  6. beginShape();
  7. vertex(0, gyroX[0]);
  8. for (int i = 1; i < gyroX.length; i++) {
  9. if ((gyroX[i] < height/4 && gyroX[i - 1] > height/4*3) || (gyroX[i] > height/4*3 && gyroX[i - 1] < height/4)) {
  10. endShape();
  11. beginShape();
  12. }
  13. vertex(i, gyroX[i]);
  14. }
  15. endShape();
  16. // Put all data one array back
  17. for (int i = 1; i < gyroX.length;i++)
  18. gyroX[i-1] = gyroX[i];
  19. /* Draw acceleromter x-axis */
  20. noFill();
  21. stroke(0, 255, 0); // Green
  22. // Redraw everything
  23. beginShape();
  24. vertex(0, accX[0]);
  25. for (int i = 1; i < accX.length; i++) {
  26. if ((accX[i] < height/4 && accX[i - 1] > height/4*3) || (accX[i] > height/4*3 && accX[i - 1] < height/4)) {
  27. endShape();
  28. beginShape();
  29. }
  30. vertex(i, accX[i]);
  31. }
  32. endShape();
  33. // Put all data one array back
  34. for (int i = 1; i < accX.length;i++)
  35. accX[i-1] = accX[i];
  36. /* Draw complementary filter x-axis */
  37. noFill();
  38. stroke(0, 0, 255); // Blue
  39. // Redraw everything
  40. beginShape();
  41. vertex(0, compX[0]);
  42. for (int i = 1; i < compX.length; i++) {
  43. if ((compX[i] < height/4 && compX[i - 1] > height/4*3) || (compX[i] > height/4*3 && compX[i - 1] < height/4)) {
  44. endShape();
  45. beginShape();
  46. }
  47. vertex(i, compX[i]);
  48. }
  49. endShape();
  50. // Put all data one array back
  51. for (int i = 1; i < compX.length; i++)
  52. compX[i-1] = compX[i];
  53. /* Draw kalman filter x-axis */
  54. noFill();
  55. stroke(255, 0, 0);// Red
  56. // Redraw everything
  57. beginShape();
  58. vertex(0, kalmanX[0]);
  59. for (int i = 1; i < kalmanX.length; i++) {
  60. if ((kalmanX[i] < height/4 && kalmanX[i - 1] > height/4*3) || (kalmanX[i] > height/4*3 && kalmanX[i - 1] < height/4)) {
  61. endShape();
  62. beginShape();
  63. }
  64. vertex(i, kalmanX[i]);
  65. }
  66. endShape();
  67. // Put all data one array back
  68. for (int i = 1; i < kalmanX.length; i++)
  69. kalmanX[i-1] = kalmanX[i];
  70. }
  71. void drawAxisY() {
  72. /* Draw gyro y-axis */
  73. noFill();
  74. stroke(255, 0, 255); // Purble
  75. // Redraw everything
  76. beginShape();
  77. vertex(0, gyroY[0]);
  78. for (int i = 1; i < gyroY.length; i++) {
  79. if ((gyroY[i] < height/4 && gyroY[i - 1] > height/4*3) || (gyroY[i] > height/4*3 && gyroY[i - 1] < height/4)) {
  80. endShape();
  81. beginShape();
  82. }
  83. vertex(i, gyroY[i]);
  84. }
  85. endShape();
  86. // Put all data one array back
  87. for (int i = 1; i < gyroY.length;i++)
  88. gyroY[i-1] = gyroY[i];
  89. /* Draw acceleromter y-axis */
  90. noFill();
  91. stroke(0, 255, 255); // Light blue
  92. // Redraw everything
  93. beginShape();
  94. vertex(0, accY[0]);
  95. for (int i = 1; i < accY.length; i++) {
  96. if ((accY[i] < height/4 && accY[i - 1] > height/4*3) || (accY[i] > height/4*3 && accY[i - 1] < height/4)) {
  97. endShape();
  98. beginShape();
  99. }
  100. vertex(i, accY[i]);
  101. }
  102. endShape();
  103. // Put all data one array back
  104. for (int i = 1; i < accY.length;i++)
  105. accY[i-1] = accY[i];
  106. /* Draw complementary filter y-axis */
  107. noFill();
  108. stroke(124, 252, 0); // Lawn Green
  109. // Redraw everything
  110. beginShape();
  111. vertex(0, compY[0]);
  112. for (int i = 1; i < compY.length; i++) {
  113. if ((compY[i] < height/4 && compY[i - 1] > height/4*3) || (compY[i] > height/4*3 && compY[i - 1] < height/4)) {
  114. endShape();
  115. beginShape();
  116. }
  117. vertex(i, compY[i]);
  118. }
  119. endShape();
  120. // Put all data one array back
  121. for (int i = 1; i < compY.length;i++)
  122. compY[i-1] = compY[i];
  123. /* Draw kalman filter y-axis */
  124. noFill();
  125. stroke(0, 0, 0); // Black
  126. // Redraw everything
  127. beginShape();
  128. vertex(0, kalmanY[0]);
  129. for (int i = 1; i < kalmanY.length; i++) {
  130. if ((kalmanY[i] < height/4 && kalmanY[i - 1] > height/4*3) || (kalmanY[i] > height/4*3 && kalmanY[i - 1] < height/4)) {
  131. endShape();
  132. beginShape();
  133. }
  134. vertex(i, kalmanY[i]);
  135. }
  136. endShape();
  137. // Put all data one array back
  138. for (int i = 1; i<kalmanY.length;i++)
  139. kalmanY[i-1] = kalmanY[i];
  140. }