Commit a2606ecc authored by Nisarg Bhavsar's avatar Nisarg Bhavsar

Tap detection kinda

parent 24ba05a1
......@@ -215,7 +215,10 @@ int main(void)
long total_x_acc = 0, total_y_acc = 0, total_z_acc = 0;
while (1)
{
/* USER CODE END WHILE */
total_x_acc = 0;
total_y_acc = 0;
total_z_acc = 0;
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* Read device status register */
......@@ -244,22 +247,22 @@ int main(void)
gyro_y = acceleration_mg[1] - gyro_y_cal;
gyro_z = acceleration_mg[2] - gyro_z_cal;
acc_x = angular_rate_mdps[0];
acc_y = angular_rate_mdps[1];
acc_z = angular_rate_mdps[2];
acc_x_buffer[i] = acc_x;
acc_y_buffer[i] = acc_y;
acc_z_buffer[i] = acc_z;
acc_x_buffer[i] = angular_rate_mdps[0];
acc_y_buffer[i] = angular_rate_mdps[1];
acc_z_buffer[i] = angular_rate_mdps[2];
for(int avg_i=0; avg_i < 20; avg_i++){
/*for(int avg_i=0; avg_i < 20; avg_i++){
total_x_acc += acc_x_buffer[avg_i];
total_y_acc += acc_y_buffer[avg_i];
total_z_acc += acc_z_buffer[avg_i];
}
acc_x_output = total_x_acc / 20;
acc_y_output = total_y_acc / 20;
acc_z_output = total_z_acc / 20;
}*/
//acc_x_output = total_x_acc / 20;
//acc_y_output = total_y_acc / 20;
//acc_z_output = total_z_acc / 20;
acc_x_output = angular_rate_mdps[0];
acc_y_output = angular_rate_mdps[1];
acc_z_output = angular_rate_mdps[2];
gyro_x_output = gyro_x;
gyro_y_output = gyro_y;
......
......@@ -468,11 +468,11 @@ static void HIDSAPP_Tracking_UpdateChar(void)
}
if(zMotion > 125){
upTap = 5;
if(zMotion > 115 && upTap == 0){
upTap = 3;
}
if(zMotion < -50){
downTap = 5;
if(zMotion < -115 && downTap == 0){
downTap = 3;
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment