MotionCal/imuread.c

43 lines
853 B
C
Raw Normal View History

2016-02-14 15:00:53 -08:00
#include "imuread.h"
2016-02-13 16:06:36 -08:00
2016-02-13 19:58:30 -08:00
void timer_callback(int val)
2016-02-13 16:06:36 -08:00
{
2016-02-13 19:58:30 -08:00
glutTimerFunc(TIMEOUT_MSEC, timer_callback, 0);
2016-02-14 15:00:53 -08:00
read_serial_data();
2016-02-14 15:18:56 -08:00
glutPostRedisplay(); // TODO: only redisplay if data changes
}
void resize_callback(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
2016-02-13 19:58:30 -08:00
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
2016-02-14 09:22:11 -08:00
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
2016-02-13 19:58:30 -08:00
glutInitWindowSize(600, 500);
glutCreateWindow("IMU Read");
2016-02-16 17:19:44 -08:00
visualize_init();
2016-02-14 09:22:11 -08:00
glutReshapeFunc(resize_callback);
2016-02-13 19:58:30 -08:00
glutDisplayFunc(display_callback);
glutTimerFunc(TIMEOUT_MSEC, timer_callback, 0);
2016-02-13 16:06:36 -08:00
2016-02-14 15:00:53 -08:00
open_port(PORT);
2016-02-13 19:58:30 -08:00
glutMainLoop();
2016-02-14 15:00:53 -08:00
close_port();
2016-02-13 16:06:36 -08:00
return 0;
}