增加低功耗睡眠唤醒功能

This commit is contained in:
YuXifeng 2025-04-08 13:52:30 +08:00
parent 9d37201166
commit 2cd91d966c
3 changed files with 11 additions and 1 deletions

View File

@ -68,6 +68,7 @@ void button_init_all()
.gpio_num = button_pins[i],
.active_level = BUTTON_ACTIVE_LEVEL,
.enable_power_save = true,
.disable_pull = false,
};
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);

View File

@ -2,6 +2,7 @@
#include "i2c_port.h"
#include "axp20x.hpp"
static const char *TAG = "AXP20x";
extern "C" QueueHandle_t gpio_evt_queue = NULL;
@ -30,7 +31,7 @@ extern "C" void axp_irq_init()
//change gpio intrrupt type for one pin
gpio_set_intr_type(AXP_ISR_GPIO, GPIO_INTR_NEGEDGE);
//install gpio isr service
gpio_install_isr_service(0);
// gpio_install_isr_service(0);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(AXP_ISR_GPIO, axp_isr_handler, (void *) AXP_ISR_GPIO);
//create a queue to handle gpio event from isr
@ -265,8 +266,14 @@ extern "C" void Axp202_task(void *pvParameter)
if (io_num == AXP_ISR_GPIO) {
axp.readIRQ();
if (axp.isPEKLongtPressIRQ()) {
ESP_LOGI("sleep","esp_light_sleep_start");
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_INPUT_MODE); // 屏幕供电
vTaskDelay(500/ portTICK_PERIOD_MS);
esp_light_sleep_start();
ESP_LOGI(TAG, "AXP202 PEK key Click:%.2f,%.2f,%.2f,%d",axp.getBattVoltage(),axp.getCoulombData(),axp.getBattDischargeCurrent(),axp.getBattPercentage());
// axp.shutdown();
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_LDO_MODE); // 屏幕供电
}
axp.clearIRQ();
}

View File

@ -32,6 +32,8 @@
#include "wifi_task.h"
#include "spiffs.h"
#include "esp_sleep.h"
#include "bsp_flash.h"
#include "esp_efuse.h"