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
pull/227/head
Silvano Seva 2024-01-09 18:54:41 +01:00
rodzic 4a45ce0c16
commit c4b7b7a337
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -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();