80 lines
2.1 KiB
C
80 lines
2.1 KiB
C
/**
|
||
* @file Flux_Power.h
|
||
* @brief 电源管理头文件
|
||
*
|
||
* 用于声明电源IO,ADC采样,以及LED控制
|
||
*
|
||
* @author wang xiang en
|
||
* @date 2025-04-18
|
||
* @version 版本号
|
||
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd)
|
||
*/
|
||
#ifndef _FLUX_POWER_H
|
||
#define _FLUX_POWER_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
#include <stdio.h>
|
||
#include "freertos/FreeRTOS.h"
|
||
#include "freertos/task.h"
|
||
#include "freertos/queue.h"
|
||
#include "driver/gpio.h"
|
||
|
||
#include "driver/ledc.h"
|
||
|
||
#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"
|
||
|
||
/* 定义背光相关参数 */
|
||
#define LEDC_TIMER LEDC_TIMER_0
|
||
#define LEDC_MODE LEDC_LOW_SPEED_MODE
|
||
#define LEDC_OUTPUT_IO GPIO_NUM_3 // Define the output GPIO
|
||
#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
|
||
|
||
/* 定义进行电池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));
|
||
|
||
/**
|
||
* @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));
|
||
|
||
/**
|
||
* @brief 背光调节初始化函数
|
||
*
|
||
*/
|
||
void example_ledc_init(void);
|
||
|
||
/**
|
||
* @brief 锂电池电源管理任务
|
||
*
|
||
* 每隔5秒钟对锂电池电压进行检测
|
||
*/
|
||
void power_management_task(void* arg);
|
||
|
||
#ifdef __cplusplus
|
||
} /*extern "C"*/
|
||
#endif
|
||
|
||
|
||
#endif /*_FLUX_POWER_H*/ |