diff --git a/src/main/common/maths.h b/src/main/common/maths.h index 2cdae7ec1..1a506789b 100644 --- a/src/main/common/maths.h +++ b/src/main/common/maths.h @@ -57,6 +57,8 @@ #define Q12 (1 << 12) +#define HZ_TO_INTERVAL_US(x) (1000000 / (x)) + typedef int32_t fix12_t; typedef struct stdev_s diff --git a/src/main/sensors/current.c b/src/main/sensors/current.c index a2355f6f6..9261266cf 100644 --- a/src/main/sensors/current.c +++ b/src/main/sensors/current.c @@ -140,7 +140,7 @@ currentMeterADCState_t currentMeterADCState; void currentMeterADCInit(void) { memset(¤tMeterADCState, 0, sizeof(currentMeterADCState_t)); - biquadFilterInitLPF(&adciBatFilter, IBAT_LPF_FREQ, 20000); //50HZ Update + biquadFilterInitLPF(&adciBatFilter, IBAT_LPF_FREQ, HZ_TO_INTERVAL_US(50)); } void currentMeterADCRefresh(int32_t lastUpdateAt) diff --git a/src/main/sensors/voltage.c b/src/main/sensors/voltage.c index 58a9dfe3c..b12c2fb1d 100644 --- a/src/main/sensors/voltage.c +++ b/src/main/sensors/voltage.c @@ -191,7 +191,7 @@ void voltageMeterADCInit(void) voltageMeterADCState_t *state = &voltageMeterADCStates[i]; memset(state, 0, sizeof(voltageMeterADCState_t)); - biquadFilterInitLPF(&state->filter, VBAT_LPF_FREQ, 20000); //50HZ Update + biquadFilterInitLPF(&state->filter, VBAT_LPF_FREQ, HZ_TO_INTERVAL_US(50)); } } @@ -215,7 +215,7 @@ void voltageMeterESCInit(void) { #ifdef USE_ESC_SENSOR memset(&voltageMeterESCState, 0, sizeof(voltageMeterESCState_t)); - biquadFilterInitLPF(&voltageMeterESCState.filter, VBAT_LPF_FREQ, 20000); //50HZ Update + biquadFilterInitLPF(&voltageMeterESCState.filter, VBAT_LPF_FREQ, HZ_TO_INTERVAL_US(50)); #endif }