
LCD Accelerometer with interrupt fault
calibrate.cpp
- Committer:
- Aubs
- Date:
- 2010-05-12
- Revision:
- 0:298e8a54dc2d
File content as of revision 0:298e8a54dc2d:
#include "header.h" extern float Xcal; extern float Ycal; extern float Zcal; extern int i; extern float per_old; extern float per_new; extern float sumx; extern float sumy; extern float sumz; extern float Xoff; extern float Yoff; extern float Zoff; void calibrate(void){ while (1){ lcd.locate(1,11); lcd.printf("Press Select to Confirm"); sumx=0; sumy=0; sumz=0; for(i=0; i<199; i++) { Xcal=((Xcal)*(per_old))+((acc.x())*(per_new)); Ycal=((Ycal)*(per_old))+((acc.y())*(per_new)); Zcal=((Zcal)*(per_old))+((acc.z())*(per_new)); lcd.locate(1,9); lcd.printf("Calibrate"); lcd.printf("%i",(200-i)); sumx += Xcal; sumy += Ycal; sumz += Zcal; } Xoff=0-(sumx/200); Yoff=0-(sumy/200); Zoff=1-(sumz/200); lcd.locate(1,1); lcd.printf("X="); lcd.printf("%0.5f",Xoff); lcd.locate(1,3); lcd.printf("Y="); lcd.printf("%0.5f",Yoff); lcd.locate(1,5); lcd.printf("Z="); lcd.printf("%0.5f",Zoff); but2.fall(&menuscreen); } }