From 1516b110293b3d886924bd87806dfe9766aef8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=90=AA?= Date: Tue, 28 Jul 2026 11:44:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E6=BB=91=E4=B8=89=E8=89=B2=E5=91=BC?= =?UTF-8?q?=E5=90=B8=E5=8D=95=E8=89=B2=E4=BD=8E=E4=BA=AE=E5=B0=BE=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ble/ble_peripheral/app/src/bridge_pwm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/project/example/ble/ble_peripheral/app/src/bridge_pwm.c b/project/example/ble/ble_peripheral/app/src/bridge_pwm.c index e69ec2a..37c6483 100644 --- a/project/example/ble/ble_peripheral/app/src/bridge_pwm.c +++ b/project/example/ble/ble_peripheral/app/src/bridge_pwm.c @@ -390,22 +390,23 @@ __RAM_CODE void Bridge_Service_1ms(void) /* * The low part of the three-color breathing effect cannot use short - * continuous W/C pulses reliably. Emit verified 50 us pulses and vary - * their density across the fixed 2 kHz frames instead. At the configured - * minimum output this gives about 450 emitted pulses per second. + * continuous pulses reliably. Emit verified 50 us pulses and vary their + * density across the fixed 2 kHz frames instead. Apply this to both the + * mixed section and each single-color tail, so no color disappears early + * when its hardware-PWM pulse becomes too narrow to light the LEDs. */ if (deviceStatus != POWEROFF && Mode == mode1 && choose_mode_falsg == 5U && - w_mix != 0U && c_mix != 0U) { + (w_mix != 0U || c_mix != 0U)) { /* * Follow the smoothed physical output rather than the next logical * target. This lets the old color reach zero before the wait state * starts the next color. */ - pdm_w_step = - BRIDGE_DUAL_ACTIVE_US * ((uint32_t)w_mix << 12); - pdm_c_step = - BRIDGE_DUAL_ACTIVE_US * ((uint32_t)c_mix << 12); + total_on_us = (w_mix != 0U && c_mix != 0U) + ? BRIDGE_DUAL_ACTIVE_US : BRIDGE_FRAME_US; + pdm_w_step = total_on_us * ((uint32_t)w_mix << 12); + pdm_c_step = total_on_us * ((uint32_t)c_mix << 12); if (pdm_w_step < BRIDGE_TRICOLOR_PDM_THRESHOLD && pdm_c_step < BRIDGE_TRICOLOR_PDM_THRESHOLD) {