Advertisement
blackswords

IMU3000 main

May 28th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include "WProgram.h"
  2. #include <MyLib.h>
  3.  
  4. #include <stdio.h>
  5.  
  6. using namespace std;
  7.  
  8. HardwareTimer timer(1);
  9.  
  10. void setup() {
  11.  
  12.     LCD::LCD();
  13.     LCD::WriteText(10,10,"Initialization",Green,Black);
  14.  
  15.     IMU.Init(2, I2C_FAST_MODE);
  16.     IMU.SetLowPassFilter(F_5Hz);
  17.     IMU.Calibration();
  18.  
  19.     timer.setPrescaleFactor(1);
  20.     timer.setOverflow(0xFFFF);
  21.  
  22.  
  23. }
  24.  
  25. void loop() {
  26.  
  27.     char s[30];
  28.     int t;
  29.     timer.refresh();
  30.  
  31.     t = timer.getCount();
  32.     IMU.Update();
  33.     t = timer.getCount() - t;
  34.  
  35.     sprintf(s,"Gyro %5d %5d %5d",IMU.gyro.x,IMU.gyro.y,IMU.gyro.z);
  36.     LCD::WriteText(10,30,s,Green,Black);
  37.     sprintf(s,"Acc  %5d %5d %5d",IMU.acc.x,IMU.acc.y,IMU.acc.z);
  38.     LCD::WriteText(10,50,s,Green,Black);
  39.     sprintf(s,"Cal  %5d %5d %5d",IMU.calib.x,IMU.calib.y,IMU.calib.z);
  40.     LCD::WriteText(10,70,s,Green,Black);
  41.     sprintf(s,"Time = %3dus  ", t/72);
  42.     LCD::WriteText(10,90,s,Green,Black);
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement