feat(control_plane): reduce light standby runtime power
This commit is contained in:
@@ -28,11 +28,16 @@
|
||||
#define BATTERY_LOW_PROMPT_FILE "/littlefs/audio_prompts/battery_low_20.opus"
|
||||
#define BATTERY_FULL_PROMPT_FILE "/littlefs/audio_prompts/charge_complete.opus"
|
||||
|
||||
#ifndef CONFIG_TQ_LIGHT_STANDBY_BATTERY_INTERVAL_SEC
|
||||
#define CONFIG_TQ_LIGHT_STANDBY_BATTERY_INTERVAL_SEC 300
|
||||
#endif
|
||||
|
||||
static const char *TAG = "cp_battery";
|
||||
static TaskHandle_t s_battery_task;
|
||||
static bool s_stop_requested;
|
||||
static bool s_starting;
|
||||
static bool s_charge_gpio_isr_registered;
|
||||
static bool s_light_standby;
|
||||
static portMUX_TYPE s_battery_lock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
static void IRAM_ATTR battery_charge_gpio_isr(void *arg)
|
||||
@@ -122,6 +127,15 @@ static bool battery_stop_requested(void)
|
||||
return requested;
|
||||
}
|
||||
|
||||
static bool battery_light_standby(void)
|
||||
{
|
||||
bool standby;
|
||||
portENTER_CRITICAL(&s_battery_lock);
|
||||
standby = s_light_standby;
|
||||
portEXIT_CRITICAL(&s_battery_lock);
|
||||
return standby;
|
||||
}
|
||||
|
||||
static void battery_worker_finish(void)
|
||||
{
|
||||
portENTER_CRITICAL(&s_battery_lock);
|
||||
@@ -314,6 +328,8 @@ static void battery_worker(void *arg)
|
||||
delay_ms = BATTERY_SUPPRESSED_RETRY_MS;
|
||||
} else if (full_hint_candidate) {
|
||||
delay_ms = BATTERY_FULL_CONFIRM_RETRY_MS;
|
||||
} else if (battery_light_standby()) {
|
||||
delay_ms = (uint32_t)CONFIG_TQ_LIGHT_STANDBY_BATTERY_INTERVAL_SEC * 1000U;
|
||||
} else {
|
||||
delay_ms = (uint32_t)CONFIG_TQ_BATTERY_SAMPLE_INTERVAL_SEC * 1000U;
|
||||
}
|
||||
@@ -340,6 +356,7 @@ esp_err_t control_plane_battery_service_start(void)
|
||||
}
|
||||
s_stop_requested = false;
|
||||
s_starting = true;
|
||||
s_light_standby = false;
|
||||
portEXIT_CRITICAL(&s_battery_lock);
|
||||
|
||||
TaskHandle_t task = NULL;
|
||||
@@ -406,6 +423,18 @@ esp_err_t control_plane_battery_service_stop(int timeout_ms)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void control_plane_battery_service_set_light_standby(bool standby)
|
||||
{
|
||||
TaskHandle_t task;
|
||||
portENTER_CRITICAL(&s_battery_lock);
|
||||
s_light_standby = standby;
|
||||
task = s_battery_task;
|
||||
portEXIT_CRITICAL(&s_battery_lock);
|
||||
if (task != NULL) {
|
||||
xTaskNotifyGive(task);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
esp_err_t control_plane_battery_service_start(void)
|
||||
@@ -418,4 +447,9 @@ esp_err_t control_plane_battery_service_stop(int timeout_ms)
|
||||
return timeout_ms < 0 ? ESP_ERR_INVALID_ARG : ESP_OK;
|
||||
}
|
||||
|
||||
void control_plane_battery_service_set_light_standby(bool standby)
|
||||
{
|
||||
(void)standby;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user