解决低亮度闪烁的问题
This commit is contained in:
@@ -462,11 +462,11 @@ void calculate_pwm_duty(device_control_t* pdevice_control)
|
||||
{ // 如果开关关闭,则占空比为0
|
||||
uint32_t total_brightness_pwm = pdevice_control->brightness_local;
|
||||
// 计算色温比例 (0-10000)
|
||||
uint32_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;
|
||||
}
|
||||
|
||||
@@ -515,8 +515,8 @@ void update_pwm_output(bool on_state, uint16_t duty_cw_val, uint16_t duty_ww_val
|
||||
uapi_pwm_start_group(CONFIG_PWM_GROUP_ID);
|
||||
|
||||
if (should_print(&pwm_limiter)) {
|
||||
e_printf("on:%d, cw:high:%u, low:%u, duty:%u/1000, ww:high:%u, low:%u, duty:%u/1000, offset_time:%u\r\n",
|
||||
on_state, high_cnt_cw, low_cnt_cw, current_duty_cw, high_cnt_ww, low_cnt_ww, current_duty_ww, cfg_repeat.offset_time);
|
||||
e_printf("on:%d, cw:high:%u, low:%u, duty:%u/%u, ww:high:%u, low:%u, duty:%u/%u, offset_time:%u\r\n",
|
||||
on_state, high_cnt_cw, low_cnt_cw, current_duty_cw, PWM_DUTY_RATIO_MAX, high_cnt_ww, low_cnt_ww, current_duty_ww, PWM_DUTY_RATIO_MAX, cfg_repeat.offset_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user