diff --git a/Documentation/card10-cfg.rst b/Documentation/card10-cfg.rst index 072911e1166ec57c81f8c5a966d16819c6b1cfa6..f77a345b594801c5caa117d3e9b4d04209e7c6a2 100644 --- a/Documentation/card10-cfg.rst +++ b/Documentation/card10-cfg.rst @@ -62,4 +62,6 @@ Option name Type Description ``bsec_debug`` Boolean Turn on debug output of the BSEC system. Prints each meaurement on the console. ------------------ ---------- ----------- ``bsec_offset`` Integer Temperature offset in .1 K. Example: Set to `-14` if temperature reads 1.4 "C" to high. Default: -2.2 K (appropriate for a card10 without a case, connected to USB and with BLE active in vertical orientation). +------------------ ---------- ----------- +``battery_check`` Boolean Whether the low battery check should be enabled (default ``true``). **Warning**: Do not use this unless you know what you're doing. This option is only meant to be used on devices with a broken PMIC ADMUX connection. ================== ========== =========== diff --git a/epicardium/modules/pmic.c b/epicardium/modules/pmic.c index 1c996b2313fd3c37e864b7eb896ebf4adb9c9b07..fba748f73ea9aa7d3dbc70e75152b4233e92f0d6 100644 --- a/epicardium/modules/pmic.c +++ b/epicardium/modules/pmic.c @@ -1,6 +1,7 @@ #include "epicardium.h" #include "modules/modules.h" #include "modules/log.h" +#include "modules/config.h" #include "card10.h" #include "pmic.h" @@ -173,6 +174,30 @@ static void pmic_check_battery() float u_batt; int res; + /** + * 0 = uncertain, ask config + * 1 = disabled + * 2 = enabled + */ + static int pmic_do_battery_check = 0; + + if (pmic_do_battery_check == 0) { + if (config_get_boolean_with_default("battery_check", true)) { + pmic_do_battery_check = 2; + } else { + pmic_do_battery_check = 1; + LOG_WARN( + "pmic", + "Battery check was disabled by config!" + ); + } + } + + if (pmic_do_battery_check == 1) { + /* Disabled, ignore */ + return; + } + res = pmic_read_amux(PMIC_AMUX_BATT_U, &u_batt); if (res < 0) { LOG_ERR("pmic",