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) {