From 5cb6bb828ee5614da9235cc855ecedaa41ecc6e1 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sat, 29 Mar 2025 22:28:29 +0100 Subject: [PATCH] update --- lib/bs412.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bs412.c b/lib/bs412.c index 5511ccd..b4d8fbf 100644 --- a/lib/bs412.c +++ b/lib/bs412.c @@ -17,9 +17,11 @@ void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) { float measure_mpx(MPXPowerMeasurement* mpx, int deviation) { mpx->sample += deviation; - float avg_deviation = mpx->sample/mpx->i; + float avg_deviation = (float)mpx->sample / mpx->i; float modulation_power = deviation_to_dbr(avg_deviation); + mpx->i++; + if (mpx->i >= mpx->sample_rate*60) { mpx->sample = 0; mpx->i = 1;