From d2a07802b4f6432fab9856e003b624380ea3e819 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sat, 29 Mar 2025 20:02:15 +0100 Subject: [PATCH] huh --- lib/bs412.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/bs412.c b/lib/bs412.c index ae2904b..e10ca81 100644 --- a/lib/bs412.c +++ b/lib/bs412.c @@ -8,12 +8,9 @@ void init_modulation_power_measure(MPXPowerMeasurement* mpx, int sample_rate) { float measure_mpx(MPXPowerMeasurement* mpx, int deviation) { mpx->sample += 10*log10f(deviation/19000.0f); - - float div = mpx->i; - if(div == 0) div = 1; - float modulation_power = mpx->sample/div; - mpx->i++; + float modulation_power = mpx->sample/(mpx->i++); + if (mpx->i >= mpx->sample_rate) { mpx->sample = modulation_power; mpx->i = 0;