From c4b7b7a337b7ee3742b7cfec3b0862bdbd12658e Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Tue, 9 Jan 2024 18:54:41 +0100 Subject: [PATCH] Removed low-pass filtering of battery voltage in state update for GD77 and DM-1801 GD77 and DM-1801 already have an hardware low-pass filter on the battery measurement probe which causes the low battery protection to trigger at boot if the digital low pass filter is also used. Given that the hardware one is good enough for our purposes, the digital filter is now excluded. Provides a fix for #221 --- openrtx/src/core/state.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openrtx/src/core/state.c b/openrtx/src/core/state.c index 025cd921..a2229a28 100644 --- a/openrtx/src/core/state.c +++ b/openrtx/src/core/state.c @@ -111,10 +111,18 @@ void state_task() * Low-pass filtering with a time constant of 10s when updated at 1Hz * Original computation: state.v_bat = 0.02*vbat + 0.98*state.v_bat * Peak error is 18mV when input voltage is 49mV. + * + * NOTE: GD77 and DM-1801 already have an hardware low-pass filter on the + * vbat pin. Adding also the digital one seems to cause more troubles than + * benefits. */ uint16_t vbat = platform_getVbat(); + #if defined(PLATFORM_GD77) || defined(PLATFORM_DM1801) + state.v_bat = vbat; + #else state.v_bat -= (state.v_bat * 2) / 100; state.v_bat += (vbat * 2) / 100; + #endif state.charge = battery_getCharge(state.v_bat); state.rssi = rtx_getRssi();