没有唤醒词的板子可以开启Auto Light Sleep,待机40~50mA

This commit is contained in:
Terrence
2025-03-04 06:27:11 +08:00
parent 5a71e1bdd6
commit 5997ff2ac4
9 changed files with 161 additions and 23 deletions

View File

@@ -45,6 +45,9 @@ Display::Display() {
};
ESP_ERROR_CHECK(esp_timer_create(&update_display_timer_args, &update_timer_));
ESP_ERROR_CHECK(esp_timer_start_periodic(update_timer_, 1000000));
// Create a power management lock
ESP_ERROR_CHECK(esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "ml307", &pm_lock_));
}
Display::~Display() {
@@ -65,6 +68,10 @@ Display::~Display() {
lv_obj_del(battery_label_);
lv_obj_del(emotion_label_);
}
if (pm_lock_ != nullptr) {
esp_pm_lock_delete(pm_lock_);
}
}
void Display::SetStatus(const char* status) {
@@ -114,6 +121,7 @@ void Display::Update() {
}
}
esp_pm_lock_acquire(pm_lock_);
// 更新电池图标
int battery_level;
bool charging;
@@ -149,12 +157,14 @@ void Display::Update() {
};
if (std::find(allowed_states.begin(), allowed_states.end(), device_state) != allowed_states.end()) {
icon = board.GetNetworkStateIcon();
if (network_label_ != nullptr && network_icon_ != icon) {
if (network_label_ != nullptr && icon != nullptr && network_icon_ != icon) {
DisplayLockGuard lock(this);
network_icon_ = icon;
lv_label_set_text(network_label_, network_icon_);
}
}
esp_pm_lock_release(pm_lock_);
}

View File

@@ -4,6 +4,7 @@
#include <lvgl.h>
#include <esp_timer.h>
#include <esp_log.h>
#include <esp_pm.h>
#include <string>
@@ -35,6 +36,8 @@ protected:
int height_ = 0;
uint8_t brightness_ = 0;
esp_pm_lock_handle_t pm_lock_ = nullptr;
lv_display_t *display_ = nullptr;
lv_obj_t *emotion_label_ = nullptr;