2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file Flux_Power.h
|
|
|
|
|
|
* @brief 电源管理头文件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 用于声明电源IO,ADC采样,以及LED控制
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author wang xiang en
|
|
|
|
|
|
* @date 2025-04-18
|
|
|
|
|
|
* @version 版本号
|
|
|
|
|
|
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd)
|
|
|
|
|
|
*/
|
2025-03-14 18:59:49 +08:00
|
|
|
|
#ifndef _FLUX_POWER_H
|
|
|
|
|
|
#define _FLUX_POWER_H
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
#endif
|
2025-03-09 23:26:47 +08:00
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
|
|
#include "freertos/task.h"
|
|
|
|
|
|
#include "freertos/queue.h"
|
|
|
|
|
|
#include "driver/gpio.h"
|
2025-04-18 18:59:53 +08:00
|
|
|
|
|
2025-03-09 23:26:47 +08:00
|
|
|
|
#include "driver/ledc.h"
|
2025-04-18 18:59:53 +08:00
|
|
|
|
|
2025-03-09 23:26:47 +08:00
|
|
|
|
#include "soc/soc_caps.h"
|
|
|
|
|
|
#include "esp_log.h"
|
|
|
|
|
|
#include "esp_adc/adc_oneshot.h"
|
|
|
|
|
|
#include "esp_adc/adc_cali.h"
|
|
|
|
|
|
#include "esp_adc/adc_cali_scheme.h"
|
|
|
|
|
|
#include "ui.h"
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/* 定义背光相关参数 */
|
2025-03-14 18:59:49 +08:00
|
|
|
|
#define LEDC_TIMER LEDC_TIMER_0
|
|
|
|
|
|
#define LEDC_MODE LEDC_LOW_SPEED_MODE
|
2025-03-15 13:17:10 +08:00
|
|
|
|
#define LEDC_OUTPUT_IO GPIO_NUM_3 // Define the output GPIO
|
2025-03-14 18:59:49 +08:00
|
|
|
|
#define LEDC_CHANNEL LEDC_CHANNEL_0
|
|
|
|
|
|
#define LEDC_DUTY_RES LEDC_TIMER_13_BIT // Set duty resolution to 13 bits
|
|
|
|
|
|
#define LEDC_DUTY (4096) // Set duty to 50%. (2 ** 13) * 50% = 4096
|
|
|
|
|
|
#define LEDC_FREQUENCY (4000) // Frequency in Hertz. Set frequency at 4 kHz
|
2025-03-09 23:26:47 +08:00
|
|
|
|
|
2025-04-21 16:11:01 +08:00
|
|
|
|
#define DEFAULT_LIGHT (9000)
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/* 定义进行电池AD采样的通道 */
|
|
|
|
|
|
#define BATTERY_ADC_CHANNEL ADC_CHANNEL_8
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief LCD背光关闭宏函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* 用于快捷关闭LCD背光
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define LCD_BACKLIGHT_CLOSE ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 8192));\
|
|
|
|
|
|
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
|
2025-03-09 23:26:47 +08:00
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief LCD背光开启宏函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* 用于快捷开启LCD背光
|
|
|
|
|
|
*/
|
|
|
|
|
|
#define LCD_BACKLIGHT_OPEN ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 100));\
|
|
|
|
|
|
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
|
2025-03-15 13:17:10 +08:00
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 背光调节初始化函数
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2025-03-15 13:17:10 +08:00
|
|
|
|
void example_ledc_init(void);
|
2025-03-09 23:26:47 +08:00
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 锂电池电源管理任务
|
|
|
|
|
|
*
|
|
|
|
|
|
* 每隔5秒钟对锂电池电压进行检测
|
|
|
|
|
|
*/
|
|
|
|
|
|
void power_management_task(void* arg);
|
|
|
|
|
|
|
2025-03-14 18:59:49 +08:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
} /*extern "C"*/
|
|
|
|
|
|
#endif
|
2025-03-09 23:26:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-03-14 18:59:49 +08:00
|
|
|
|
#endif /*_FLUX_POWER_H*/
|