回滚:撤销‘优化开关与渐变的无缝衔接’修改
原因:该修改导致配网场景下的灯效渐变异常(持续闪烁)。 范围:还原 application/ws63/user_main/spotlight/spotlight_main.c 的相关改动;同时移除本次提交新增的 docs/ 与 logs/ 资源文件。 说明:仍保留上一笔‘修复灯光渐变与状态保持逻辑’提交,不影响‘未指定字段保持不变’与‘关灯态只更新目标不推进渐变’的修复。
This commit is contained in:
@@ -254,20 +254,14 @@ static void *fade_task(const char *arg)
|
||||
fade_ctx.fade_completed = false;
|
||||
|
||||
if (fade_ctx.is_closing_fade) {
|
||||
// 若在收尾时已被“开灯”抢占,则跳过关断动作,避免“先黑一下”的突变
|
||||
if (g_device_control.on) {
|
||||
e_printf("[fade_task] Close-fade preempted by OPEN, skip turning off\r\n");
|
||||
fade_ctx.is_closing_fade = false;
|
||||
// 保持当前PWM与占空,后续由OPEN流程接管渐变
|
||||
} else {
|
||||
// 关灯渐变完成:不更新g_device_control.brightness_local,保持原有目标亮度
|
||||
fade_ctx.is_closing_fade = false;
|
||||
update_pwm_output(false, 0, 0);
|
||||
g_device_control.duty_cw = 0;
|
||||
g_device_control.duty_ww = 0;
|
||||
e_printf("[fade_task] Close light fade completed, PWM turned off, brightness_local preserved: %d\r\n",
|
||||
g_device_control.brightness_local);
|
||||
}
|
||||
// 关灯渐变完成:不更新g_device_control.brightness_local,保持原有目标亮度
|
||||
fade_ctx.is_closing_fade = false;
|
||||
update_pwm_output(false, 0, 0);
|
||||
g_device_control.duty_cw = 0;
|
||||
g_device_control.duty_ww = 0;
|
||||
// 注意:这里不更新 g_device_control.brightness_local,保持之前的亮度值
|
||||
e_printf("[fade_task] Close light fade completed, PWM turned off, brightness_local preserved: %d\r\n",
|
||||
g_device_control.brightness_local);
|
||||
} else {
|
||||
// 正常渐变完成:正常更新所有值
|
||||
g_device_control.duty_ww = device_control.duty_ww;
|
||||
@@ -673,10 +667,10 @@ static void cancel_current_light_fade(void)
|
||||
// 竞态保护:先拉低标志再停计时器,避免回调自重启
|
||||
fade_ctx.timer_active = false;
|
||||
uapi_timer_stop(fade_ctx.timer_handle);
|
||||
// 标记为非渐变态,清除“关灯渐变”标记与完成态,避免旧渐变在回调里误触发收尾关断
|
||||
fade_ctx.is_fading = false;
|
||||
fade_ctx.is_closing_fade = false;
|
||||
fade_ctx.fade_completed = false;
|
||||
// 如果我打断了渐变,则将当前值更新到目标值不然下次计算会异常
|
||||
// g_device_control.cct_local = fade_ctx.current_cct;
|
||||
// g_device_control.brightness_local = fade_ctx.current_brightness;
|
||||
// memset(&fade_ctx, 0, FADE_CTRL_DATA_SIZE(fade_ctx));
|
||||
}
|
||||
|
||||
// 计算校验和
|
||||
@@ -945,16 +939,12 @@ int set_light(light_ctrl_source_e source,
|
||||
int32_t brightness_local_target, int32_t cct_local_target)
|
||||
{
|
||||
bool was_on = g_device_control.on;
|
||||
// 记录调用前是否处于“关灯渐变中”,用于开灯时做无缝反向
|
||||
bool was_closing_fade = (fade_ctx.is_fading && fade_ctx.is_closing_fade);
|
||||
int32_t curr_brightness_before_cancel = fade_ctx.current_brightness;
|
||||
int32_t curr_cct_before_cancel = fade_ctx.current_cct;
|
||||
|
||||
struct fade_ctx_t tmp_fade_ctx = {0};
|
||||
if (fade_ctx.is_fading) {
|
||||
bool closing_fade_active = fade_ctx.is_closing_fade;
|
||||
bool suppress_cancel = false;
|
||||
// 在关灯渐变过程中,属性/模式变更不应打断关灯过程
|
||||
if (fade_ctx.is_closing_fade) {
|
||||
if (closing_fade_active) {
|
||||
if (source == APP_CHANGE_LIGHT_BRIGHTNESS_CCT || source == APP_CHANGE_LIGHT_MODE || source == APP_CLOSE_LIGHT) {
|
||||
suppress_cancel = true; // 允许继续关灯渐变;再次关灯请求可复用或稍后重启
|
||||
}
|
||||
@@ -968,20 +958,11 @@ int set_light(light_ctrl_source_e source,
|
||||
g_device_control.on = true;
|
||||
|
||||
if (DEV_POWER_ON == source || (APP_OPEN_LIGHT == source && !was_on)) {
|
||||
// 若之前处于关灯渐变中,被“开灯”打断,则沿用渐变中的即时亮度作为起点,实现无缝反向
|
||||
if (was_closing_fade) {
|
||||
fade_ctx.current_brightness = curr_brightness_before_cancel;
|
||||
fade_ctx.current_cct = g_device_control.cct_local; // 使用当前目标色温
|
||||
fade_ctx.is_closing_fade = false;
|
||||
e_printf("[set_light] 开灯打断关灯渐变: brightness=%d->%d, cct=%d\n",
|
||||
fade_ctx.current_brightness, g_device_control.brightness_local, fade_ctx.current_cct);
|
||||
} else {
|
||||
// 真正的关→开或上电开灯:从0开始渐变
|
||||
fade_ctx.current_brightness = 0;
|
||||
fade_ctx.current_cct = g_device_control.cct_local; // 色温保持目标值
|
||||
e_printf("[set_light] 开灯渐变设置: brightness=0->%d, cct=%d\n",
|
||||
g_device_control.brightness_local, fade_ctx.current_cct);
|
||||
}
|
||||
// 开机或关灯→开灯:从0开始渐变
|
||||
fade_ctx.current_brightness = 0;
|
||||
fade_ctx.current_cct = g_device_control.cct_local; // 色温保持目标值
|
||||
e_printf("[set_light] 开灯渐变设置: brightness=0->%d, cct=%d\n",
|
||||
g_device_control.brightness_local, fade_ctx.current_cct);
|
||||
}
|
||||
|
||||
brightness_local_target = g_device_control.brightness_local;
|
||||
|
||||
Reference in New Issue
Block a user