#include <conio.h>
#include <stdio.h>
#include <i86.h>
#include "jr3.h"

#define esc 27


void handle_keys (char ch);
void main(void);

force_array received;
Force_sensor_data force_jr3;
char ch;
int jj;

void main(void)
{

	ch = ' ';
	force_jr3.init();
	force_jr3.zerooffs();
	force_jr3.get_full_scales();

	while (ch!=esc)
	{	
		//received = force_jr3.getDerivativeForces(0);
		received = force_jr3.getForces(3);
		for ( int i=0; i<6 ;i++)
		printf("%6.3f  ", received.axis[i]);

		printf("\n");
		for(int kk=0;kk<1000000;kk++) jj++;
	
		if (kbhit())
			handle_keys(ch=getch());
	}

	unsigned int a = force_jr3.getSaturationWarning();
	printf("\n %10d \n",a);
	a = force_jr3.getErrorCount();
	printf("\n %10d \n",a);

}

void handle_keys (char ch)
{
switch (ch)
 {
 case 'o' :
 case 'O' : force_jr3.zerooffs();      /*O (letter O) to zero readings*/
 } 
} 
