/********************************************************************* * @fn accelRead * * @brief Called by the application to read accelerometer data * and put data in accelerometer profile * * @param none * * @return none */ static void accelRead( void ) { static int8 x, y, z; int8 new_x, new_y, new_z; // Read data for each axis of the accelerometer accReadAcc(&new_x, &new_y, &new_z); // Check if x-axis value has changed by more than the threshold value and // set profile parameter if it has (this will send a notification if enabled) if( (x < (new_x-ACCEL_CHANGE_THRESHOLD)) || (x > (new_x+ACCEL_CHANGE_THRESHOLD)) ) { x = new_x; Accel_SetParameter(ACCEL_X_ATTR, sizeof ( int8 ), &x); } // Check if y-axis value has changed by more than the threshold value and // set profile parameter if it has (this will send a notification if enabled) if( (y < (new_y-ACCEL_CHANGE_THRESHOLD)) || (y > (new_y+ACCEL_CHANGE_THRESHOLD)) ) { y = new_y; Accel_SetParameter(ACCEL_Y_ATTR, sizeof ( int8 ), &y); } // Check if z-axis value has changed by more than the threshold value and // set profile parameter if it has (this will send a notification if enabled) if( (z < (new_z-ACCEL_CHANGE_THRESHOLD)) || (z > (new_z+ACCEL_CHANGE_THRESHOLD)) ) { z = new_z; Accel_SetParameter(ACCEL_Z_ATTR, sizeof ( int8 ), &z); } }
static void performPeriodicTask( void ){ int16 pXVal=0; int16 pYVal=0; int16 pZVal=0; accReadAcc( &pXVal, &pYVal, &pZVal); //uartWriteU16(0x2412); uartWriteString("X: "); uartWriteU16(pXVal); uartWriteString("\n\r"); uartWriteString("Y: "); uartWriteU16(pYVal); uartWriteString("\n\r"); uartWriteString("Z: "); uartWriteU16(pZVal); uartWriteString("\n\r"); uartWriteString("---------------\n\r"); }