Skip to content
Snippets Groups Projects
Commit d5b39b18 authored by rahix's avatar rahix
Browse files

feat(pmic): Add config option to disable low battery check

We have encountered a device where the connection from the PMIC's ADMUX
pin to the MCUs ADC is severed and thus the low battery check would
trigger immediately.

For making such devices still usable, add a config option to disable the
low battery check entirely.

Fixes: #227
parent dfcb2590
No related branches found
No related tags found
1 merge request!464Add config option to disable low battery check
Pipeline #5185 passed
......@@ -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.
================== ========== ===========
#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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment