增加低功耗睡眠唤醒功能
This commit is contained in:
parent
9d37201166
commit
2cd91d966c
@ -68,6 +68,7 @@ void button_init_all()
|
|||||||
.gpio_num = button_pins[i],
|
.gpio_num = button_pins[i],
|
||||||
.active_level = BUTTON_ACTIVE_LEVEL,
|
.active_level = BUTTON_ACTIVE_LEVEL,
|
||||||
.enable_power_save = true,
|
.enable_power_save = true,
|
||||||
|
.disable_pull = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);
|
esp_err_t ret = iot_button_new_gpio_device(&btn_cfg, &gpio_cfg, &buttons[i]);
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "i2c_port.h"
|
#include "i2c_port.h"
|
||||||
#include "axp20x.hpp"
|
#include "axp20x.hpp"
|
||||||
|
|
||||||
|
|
||||||
static const char *TAG = "AXP20x";
|
static const char *TAG = "AXP20x";
|
||||||
|
|
||||||
extern "C" QueueHandle_t gpio_evt_queue = NULL;
|
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
|
//change gpio intrrupt type for one pin
|
||||||
gpio_set_intr_type(AXP_ISR_GPIO, GPIO_INTR_NEGEDGE);
|
gpio_set_intr_type(AXP_ISR_GPIO, GPIO_INTR_NEGEDGE);
|
||||||
//install gpio isr service
|
//install gpio isr service
|
||||||
gpio_install_isr_service(0);
|
// gpio_install_isr_service(0);
|
||||||
//hook isr handler for specific gpio pin
|
//hook isr handler for specific gpio pin
|
||||||
gpio_isr_handler_add(AXP_ISR_GPIO, axp_isr_handler, (void *) AXP_ISR_GPIO);
|
gpio_isr_handler_add(AXP_ISR_GPIO, axp_isr_handler, (void *) AXP_ISR_GPIO);
|
||||||
//create a queue to handle gpio event from isr
|
//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) {
|
if (io_num == AXP_ISR_GPIO) {
|
||||||
axp.readIRQ();
|
axp.readIRQ();
|
||||||
if (axp.isPEKLongtPressIRQ()) {
|
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());
|
ESP_LOGI(TAG, "AXP202 PEK key Click:%.2f,%.2f,%.2f,%d",axp.getBattVoltage(),axp.getCoulombData(),axp.getBattDischargeCurrent(),axp.getBattPercentage());
|
||||||
// axp.shutdown();
|
// axp.shutdown();
|
||||||
|
axp.setGPIOMode(AXP_GPIO_0, AXP_IO_LDO_MODE); // 屏幕供电
|
||||||
|
|
||||||
}
|
}
|
||||||
axp.clearIRQ();
|
axp.clearIRQ();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
#include "wifi_task.h"
|
#include "wifi_task.h"
|
||||||
#include "spiffs.h"
|
#include "spiffs.h"
|
||||||
|
|
||||||
|
#include "esp_sleep.h"
|
||||||
|
|
||||||
#include "bsp_flash.h"
|
#include "bsp_flash.h"
|
||||||
|
|
||||||
#include "esp_efuse.h"
|
#include "esp_efuse.h"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user