common/body_detection.c: Format with clang-format
BRANCH=none
TEST=none
@@ -31,8 +31,7 @@ static bool history_initialized;
static bool body_detect_enable;
STATIC_IF(CONFIG_ACCEL_SPOOF_MODE) bool spoof_enable;
-static struct body_detect_motion_data
-{
+static struct body_detect_motion_data {
int history[CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE]; /* acceleration */
int sum; /* sum(history) */
uint64_t n2_variance; /* n^2 * var(history) */
@@ -59,8 +58,8 @@ static void update_motion_data(struct body_detect_motion_data *x, int x_n)
const int sum_diff = x_n - x_0;
const int new_sum = x->sum + sum_diff;
- x->n2_variance += sum_diff *
- ((int64_t)n * (x_n + x_0) - new_sum - x->sum);
+ x->n2_variance +=
+ sum_diff * ((int64_t)n * (x_n + x_0) - new_sum - x->sum);
x->sum = new_sum;
x->history[history_idx] = x_n;
}
@@ -76,8 +75,8 @@ static void update_motion_variance(void)
/* return Var(X) + Var(Y) */
static uint64_t get_motion_variance(void)
{
- return (data[X].n2_variance + data[Y].n2_variance)
- / window_size / window_size;
+ return (data[X].n2_variance + data[Y].n2_variance) / window_size /
+ window_size;
}
static int calculate_motion_confidence(uint64_t var)
@@ -160,15 +159,15 @@ static void determine_threshold_scale(int range, int resolution, int rms_noise)
* CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR / 100.
*/
const int var_noise = POW2((uint64_t)rms_noise) *
- CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR * POW2(98)
- / 100 / POW2(10000);
+ CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR *
+ POW2(98) / 100 / POW2(10000);
- var_threshold_scaled = (uint64_t)
- (CONFIG_BODY_DETECTION_VAR_THRESHOLD + var_noise) *
- multiplier / divisor;
- confidence_delta_scaled = (uint64_t)
- CONFIG_BODY_DETECTION_CONFIDENCE_DELTA *
+ var_threshold_scaled =
+ (uint64_t)(CONFIG_BODY_DETECTION_VAR_THRESHOLD + var_noise) *
multiplier / divisor;
+ confidence_delta_scaled =
+ (uint64_t)CONFIG_BODY_DETECTION_CONFIDENCE_DELTA * multiplier /
+ divisor;
}
void body_detect_reset(void)
@@ -185,8 +184,8 @@ void body_detect_reset(void)
if (odr == 0)
return;
determine_window_size(odr);
- determine_threshold_scale(body_sensor->current_range,
- resolution, rms_noise);
+ determine_threshold_scale(body_sensor->current_range, resolution,
+ rms_noise);
/* initialize motion data and state */
memset(data, 0, sizeof(data));
history_idx = 0;
