FluxDC/components/FluxPower/FluxPower.h

52 lines
1.7 KiB
C
Raw Normal View History

#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 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));
#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));
/* Define the channel used for ADC sampling */
#define EXAMPLE_ADC1_CHAN8 ADC_CHANNEL_8
#define EXAMPLE_POWER_IO (9)
/* Use PWM for backlight brightness adjustment */
#define LEDC_TIMER LEDC_TIMER_0
#define LEDC_MODE LEDC_LOW_SPEED_MODE
#define LEDC_OUTPUT_IO (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 the power management task, which performs a battery check every 5 seconds */
void powerTask(void);
void powerInit(void);
/*背光调节初始化*/
static void example_ledc_init(void);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_FLUX_POWER_H*/