good afternoon, right now I am trying to understand how the Mems sensor work. I am trying to get this to work without using circleOS.
I have defined this on my main application:
typedef struct
{
s16 OutX ;
s16 OutX_F4 ;
s16 OutX_F16 ;
s32 OutX_F64 ;
s32 OutX_F256 ;
s16 OutY ;
s16 OutY_F4 ;
s16 OutY_F16 ;
s32 OutY_F64 ;
s32 OutY_F256 ;
s16 OutZ ;
s16 OutZ_F4 ;
s16 OutZ_F16 ;
s32 OutZ_F64 ;
s32 OutZ_F256 ;
s16 Shocked ;
s16 RELATIVE_X ;
s16 RELATIVE_Y ;
s16 DoubleClick ;
}tMEMS_Info;
taken from mems.c
The objective of the program is just to move a box according to the information read from the sensor.
right now it looks like this:
int main(void)
{
int x=0;
tMEMS_Info sensor;
s16 Current_MEMS_Y, Initial_MEMS_Y, delta;
LCD_Init();
MEMS_Init();
MEMS_GetInfo();
LCD_FillRect(0,0,132,132,0xffff);
LCD_FillRect(61,61,10,10,0x0000);
for( ; ; )
{
MEMS_GetInfo();
Current_MEMS_Y = sensor.OutY_F4;
delta = Current_MEMS_Y - Initial_MEMS_Y;
x = (delta + 3000) / 2000;
LCD_FillRect(0,0,132,132,0xffff);
LCD_FillRect(61,x,10,10,0x0000);
Initial_MEMS_Y = Current_MEMS_Y;
}
}
This code does nothing. It draws a box on the center and then it moves to the bottom of the screen and nothing else. No matter how i move the primer the box does not move.
I am doing something very wrong but cannot spot it.
I would be gratefull if anyone could help me. Thanks in advance