解决低亮度闪烁的问题

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

@@ -459,9 +459,6 @@ int fast_report(const char* svc_id)
// 云端模式使用HILINK_ReportCharState
err = HILINK_ReportCharState(svc_id, payload, len);
HILINK_Printf("CLOUD report %s result is %d, payload:%s \r\n", svc_id, err, payload);
if (payload != NULL) {
free(payload);
}
}
if (payload) {

View File

@@ -99,9 +99,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; \
@@ -131,7 +131,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)
@@ -140,7 +140,7 @@ typedef struct __attribute__((packed, aligned(1))) {
// PWM频率和周期定义
#define PWM_FREQUENCY 3000 // PWM频率 2KHz
#define PWM_FREQUENCY 3000 // PWM频率 3KHz
//渐变范围
#define SMOOTH_TIME_MAX 30

View File

@@ -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);
}
}