DockerFluxDC/components/user_power_task/user_power_task.h

94 lines
2.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file FluxButton.h
* @brief 控制板按键头文件
*
* 用于声明按键IO编号按键回调函数等
*
* @author wang xiang en
* @date 2025-04-18
* @version 版本号
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd
*/
#ifndef _FLUX_BUTTON_H
#define _FLUX_BUTTON_H
#ifdef __cplusplus
extern "C" {
#endif
/* Include external button component header files */
#include "iot_button.h"
#include "esp_log.h"
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_mac.h"
#include "user_common.h"
#include "driver/ledc.h"
/* 定义电源输入IO编号 */
#define BUTTON_POWER_IN_IO_NUM GPIO_NUM_10
#define BUTTON_POWER_OUT_IO_NUM GPIO_NUM_11
/* 定义电源输出电平 */
#define POWER_OFF_OUT_LEVEL (0)
#define POWER_ON_OUT_LEVEL (1)
/* 定义按键电平 */
#define BUTTON_ACTIVE_LEVEL (0)
#define BUTTON_POWERIN_ACTIVE_LEVEL (1)
#define USE_LCD_BACKLIGHT_CLOSE (0)
/* 定义背光相关参数 */
#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
#define DEFAULT_LIGHT (4096)
/**
* @brief 按键命令枚举
*
* 定义按键按下事件的枚举值
*/
enum button_cmd_t
{
BUTTON_CMD_POWER_ON,
BUTTON_CMD_POWER_OFF,
};
/**
* @brief 关闭电源
*
* 用于快捷关闭电源关闭LDO芯片电源输出
*/
#define POWER_OFF gpio_set_level(BUTTON_POWER_OUT_IO_NUM, POWER_OFF_OUT_LEVEL);
/**
* @brief 开启电源
*
* 用于快捷开启电源使能LDO芯片电源输出
*/
#define POWER_ON gpio_set_level(BUTTON_POWER_OUT_IO_NUM, POWER_ON_OUT_LEVEL);
// 上电后初始化电源管理任务 包括电源使能及采样gpio 亮度调节等
void power_manager_task(void* arg);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*_FLUX_BUTTON_H*/