From bf2b8e4796be84f9f2807cc46894944808c28462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=90=AA?= Date: Mon, 27 Jul 2026 18:31:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=B7=B7=E5=90=88=E5=85=89?= =?UTF-8?q?=E6=9C=80=E4=BD=8E=E4=BA=AE=E5=BA=A6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ble/ble_peripheral/app/src/bridge_pwm.c | 9 +--- .../ble_peripheral/app/src/light_transition.c | 47 ------------------- 2 files changed, 2 insertions(+), 54 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 8476ee3..53952ca 100644 --- a/project/example/ble/ble_peripheral/app/src/bridge_pwm.c +++ b/project/example/ble/ble_peripheral/app/src/bridge_pwm.c @@ -25,7 +25,7 @@ #define BRIDGE_FRAME_US 500U #define BRIDGE_DEADTIME_US 25U #define BRIDGE_DUAL_ACTIVE_US 450U -#define BRIDGE_MIN_DUAL_PULSE_US 50U +#define BRIDGE_MIN_DUAL_PULSE_US 1U #define BRIDGE_TIMER_TICKS_PER_US 16U #define BRIDGE_GPIO_PORT 0U @@ -327,12 +327,7 @@ __RAM_CODE void Bridge_Service_1ms(void) */ total_on_us = (BRIDGE_DUAL_ACTIVE_US * total + (BRIDGE_MIX_SCALE / 2U)) / BRIDGE_MIX_SCALE; - /* - * Timer/driver edge uncertainty becomes visible when a dual-color - * pulse is only a few microseconds wide. Keep both directions at - * least 50 us. Single-color hardware PWM keeps its independent - * high-resolution brightness range. - */ + /* Keep a non-zero timer interval without imposing a brightness floor. */ if (total_on_us < (2U * BRIDGE_MIN_DUAL_PULSE_US)) { total_on_us = 2U * BRIDGE_MIN_DUAL_PULSE_US; } diff --git a/project/example/ble/ble_peripheral/app/src/light_transition.c b/project/example/ble/ble_peripheral/app/src/light_transition.c index e36682a..3088be2 100644 --- a/project/example/ble/ble_peripheral/app/src/light_transition.c +++ b/project/example/ble/ble_peripheral/app/src/light_transition.c @@ -8,8 +8,6 @@ volatile uint8_t Light_Transition_FadeActive; #define OUTPUT_SMOOTH_SHIFT 4U #define LIGHT_OUTPUT_SCALE 1000U #define BREATH_MIN_OUTPUT (LIGHT_OUTPUT_SCALE / 100U) -#define DUAL_MIN_COMBINED_OUTPUT ((LIGHT_OUTPUT_SCALE * 15U) / 100U) -#define DUAL_MIN_STABLE_CHANNEL_OUTPUT 112U #define POWER_FADE_Q12_MAX 4096U #define POWER_FADE_ON_TICKS 140U #define POWER_FADE_OFF_TICKS 160U @@ -196,10 +194,6 @@ void Light_Transition_Task(void) uint16_t target_brightness_scale; uint16_t brightness_scale; uint16_t fade_scale; - uint16_t mix_total; - uint16_t weak_mix; - uint16_t required_total; - uint16_t floor_w; uint8_t power_transitioning; /* @@ -224,47 +218,6 @@ void Light_Transition_Task(void) (uint16_t)(((uint32_t)C_PWM * brightness_scale * (LIGHT_OUTPUT_SCALE / 100U) + 2048U) >> 12); - /* - * Mixed light starts from a 15% combined floor. If the weaker direction - * would be below 112/1000 (about 50 us of the 450 us active window), raise - * the combined floor just enough to preserve the requested W:C ratio. - * Ratios that cannot satisfy this even at 100% are treated as single - * color. Single-color output keeps the 1% Gamma minimum. - */ - if(W_PWM != 0U && C_PWM != 0U) - { - mix_total = (uint16_t)(W_PWM + C_PWM); - weak_mix = (W_PWM < C_PWM) ? W_PWM : C_PWM; - required_total = (uint16_t)( - ((uint32_t)DUAL_MIN_STABLE_CHANNEL_OUTPUT * mix_total + - weak_mix - 1U) / weak_mix); - - if(required_total > LIGHT_OUTPUT_SCALE) - { - if(W_PWM < C_PWM) - target_w = 0U; - else - target_c = 0U; - } - else - { - if(required_total < DUAL_MIN_COMBINED_OUTPUT) - required_total = DUAL_MIN_COMBINED_OUTPUT; - - if((uint16_t)(target_w + target_c) < required_total) - { - floor_w = (uint16_t)( - ((uint32_t)required_total * W_PWM + - (mix_total / 2U)) / mix_total); - if(floor_w == 0U) floor_w = 1U; - if(floor_w >= required_total) - floor_w = required_total - 1U; - target_w = floor_w; - target_c = required_total - floor_w; - } - } - } - target_w = (uint16_t)(((uint32_t)target_w * fade_scale + 2048U) >> 12); target_c = (uint16_t)(((uint32_t)target_c * fade_scale + 2048U) >> 12);