Exemple #1
0
/**
 * Description: Writes dataLine to the buffer that is currently active.
 * Pre-Condition: DataBuffer's init() has been called, dataLine has been instantiated
 * Post-Condition: Adds the dataLine to the currentActive DataBuffer
 **/
void writeToBuffer(int cur_mode)
{
	if(me.currentWriteIndex == BUFFER_SIZE)
	{
		swap_Buffer();
	}
	me.dataBuffer[me.currentWriteBuffer][me.currentWriteIndex].x = (FX1_GetX() + X_OFFSET);
	me.dataBuffer[me.currentWriteBuffer][me.currentWriteIndex].y = (FX1_GetY() + Y_OFFSET);
	me.dataBuffer[me.currentWriteBuffer][me.currentWriteIndex].z = (FX1_GetZ() + Z_OFFSET);
	me.dataBuffer[me.currentWriteBuffer][me.currentWriteIndex].mode = cur_mode;
	me.dataBuffer[me.currentWriteBuffer][me.currentWriteIndex].time = currentTime;
	me.currentWriteIndex++;
}
Exemple #2
0
void APP_Run(void) {
  int16_t x,y,z;
  uint8_t res;
  #define ACCEL_VAL  2000

  res = FX1_Enable(); /* enable accelerometer (just in case) */
  if (res!=ERR_OK) {
    Err();
  }
  if (FAT1_Init()!=ERR_OK) {
    Err();
  }
  if (FAT1_mount(0, &fileSystemObject) != FR_OK) { /* mount file system */
    Err();
  }
  for(;;) {
    //LED1_Neg();
    x = FX1_GetX();
    y = FX1_GetY();
    z = FX1_GetZ();
    if (x>ACCEL_VAL || x<-ACCEL_VAL) {
      LED1_On();
      LED2_Off();
      LED3_Off();
    } else if (y>ACCEL_VAL || y<-ACCEL_VAL) {
      LED1_Off();
      LED2_On();
      LED3_Off();
    } else if (z>ACCEL_VAL || z<-ACCEL_VAL) {
      LED1_Off();
      LED2_Off();
      LED3_On();
    }
    LogToFile(x, y, z);
    WAIT1_Waitms(1000);
  }
}