解决低亮度闪烁的问题

This commit is contained in:
2025-08-03 22:46:05 +08:00
parent 8b3c805484
commit 745e6399ae
6 changed files with 16 additions and 19 deletions

View File

@@ -753,9 +753,9 @@ typedef struct __attribute__((packed, aligned(1))) {
#define BRIGHTNESS_MIN 0 // 最小亮度
#define BRIGHTNESS_MAX 100 // 最大亮度
#define BRIGHTNESS_LOCAL_MIN 0 // 最小亮度
#define BRIGHTNESS_LOCAL_MAX 1000 // 最大亮度
#define BRIGHTNESS_REMOTE2LOCAL(x) (x * 10) //变化范围0 -1000
#define BRIGHTNESS_LOCAL2REMOTE(x) (x / 10)
#define BRIGHTNESS_LOCAL_MAX 10000 // 最大亮度
#define BRIGHTNESS_REMOTE2LOCAL(x) (x * 100) //变化范围0 -10000
#define BRIGHTNESS_LOCAL2REMOTE(x) (x / 100)
#define BRIGHTNESS_LITME_RANGE(x) do { \
if (x > BRIGHTNESS_LOCAL_MAX) x = BRIGHTNESS_LOCAL_MAX; \
@@ -785,7 +785,7 @@ typedef struct __attribute__((packed, aligned(1))) {
#define FADE_INTERVAL_MIN (10*1000) //us
#define NORMAL_FADE_TIME 3 //s
#define PWM_DUTY_RATIO_MAX 1000
#define PWM_DUTY_RATIO_MAX 20000
//呼吸灯定义
#define BREARTH_PERIOD (3*1000*1000) //呼吸灯周期(Us)
@@ -892,12 +892,12 @@ void calculate_pwm_duty(device_control_t* pdevice_control)
pdevice_control->cct_local = SINGLE_COLOUR_CCT_LOCAL;
}
// 根据色温比例计算CW和WW的占空比
// 计算色温比例 (0-10000)
uint16_t cct_ratio = ((pdevice_control->cct_local - CCT_LOCAL_MIN) * 10000) / CCT_RANGE;
// 计算色温比例
float cct_ratio = ((pdevice_control->cct_local - CCT_LOCAL_MIN) * 1.0) / CCT_RANGE;
// 根据色温比例计算CW和WW的占空比
// 总亮度保持不变只调整CW和WW的比例
pdevice_control->duty_cw = (total_brightness_pwm * cct_ratio) / 10000;
pdevice_control->duty_cw = total_brightness_pwm * cct_ratio;
pdevice_control->duty_ww = total_brightness_pwm - pdevice_control->duty_cw;
}