FluxDC/components/FluxUI/ui_event_light.c
2025-04-28 17:49:47 +08:00

39 lines
896 B
C
Raw Permalink 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 ui_event_light.c
* @brief 此文件中专门实现亮度调节的事件处理
*
* 通过活动触摸屏来调节亮度
*
* @author wang xiang en
* @date 2025-04-19
* @version 版本号
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd
*/
#include "ui.h"
#include "driver/ledc.h"
#include "esp_err.h"
#include "esp_log.h"
/* 亮度最低值设定 */
#define LOWERST_LIGHT_LEVEL (7222)
/*亮度调节回调函数*/
void on_sliderLight_valueChanged(lv_event_t * e)
{
uint32_t value = 8192-lv_slider_get_value(e->target);
if (value>LOWERST_LIGHT_LEVEL)
{
value = LOWERST_LIGHT_LEVEL;
}
ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, value));
// Update duty to apply the new value
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
#if LOG_RECORD_ENABLE
WRITE_LOG_TO_SD("修改亮度");
#endif
}