if(count>0) { // Get the first inserted data point (in FIFO order) datapoint = sbuf_peek(); // Calculates the neutral peak by passing the data point to the Peak Filter neutral_datapoint = get_neutral_peaktopeak(datapoint); // Uses the neutral point to subtract from the current data point // Signal is rectified by taking absolute difference between the two points // Moving Average filter is applied to the obtained peak values result = get_moving_average(abs(datapoint - neutral_datapoint)); // For every true-positive flex, the pushup count is incremented // Cutoff eliminates false-positive peaks in the signal if(result>= 25 && flex_flag == 0) { flex_flag = 1; pushup_count += 1; sprintf(msg, "Just %d Push-ups? You can do better\r\n ", pushup_count); EXAMPLE_sendMessageOverBLE2(msg); } else if(result<25 && flex_flag == 1) { flex_flag = 0; } // Remove the first element (in FIFO order) since it has already been processed sbuf_remove(); time_elapsed += 5.0; }