FluxDC/components/FluxPower/Flux_Power.h

82 lines
2.1 KiB
C
Raw Normal View History

/**
* @file Flux_Power.h
* @brief
*
* IOADC采样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
2025-03-15 13:17:10 +08:00
#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
2025-04-21 16:11:01 +08:00
#define DEFAULT_LIGHT (9000)
/* 定义进行电池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));
2025-03-15 13:17:10 +08:00
/**
* @brief
*
*/
2025-03-15 13:17:10 +08:00
void example_ledc_init(void);
/**
* @brief
*
* 5
*/
void power_management_task(void* arg);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_FLUX_POWER_H*/