diff --git a/project/example/ble/ble_peripheral/app/src/Mode.c b/project/example/ble/ble_peripheral/app/src/Mode.c index dc3fc30..0c6c0a9 100644 --- a/project/example/ble/ble_peripheral/app/src/Mode.c +++ b/project/example/ble/ble_peripheral/app/src/Mode.c @@ -19,6 +19,8 @@ uint8_t Mode=mode0; //mode0 1 2 3 4 uint8_t Speed=5; //速度 uint8_t direction = 1; // 呼吸灯的亮度变化方向,1表示增加,0表示减小 +#define THREE_COLOR_SINGLE_JOIN_LEVEL 41U + uint8_t choose_mode_falsg=0; //模式值 uint8_t choose_mode_bh=0; //模式变化 static uint8_t mode_entry_initialized; @@ -230,11 +232,11 @@ void Mode1(){ // breathespeed_flag=0; W_PWM -= 1; C_PWM = 0; - if (W_PWM <= 1) { + if (W_PWM <= THREE_COLOR_SINGLE_JOIN_LEVEL) { direction = 2; driveMode=0; W_PWM = 1; - C_PWM = 0; + C_PWM = 1; } break; case 2: @@ -254,8 +256,8 @@ void Mode1(){ // if (W_PWM <=1) { driveMode=2; direction = 4; - W_PWM = 1; - C_PWM = 1; + W_PWM = 0; + C_PWM = THREE_COLOR_SINGLE_JOIN_LEVEL; } break; case 4: @@ -272,11 +274,11 @@ void Mode1(){ // breathespeed_flag=0; W_PWM = 0; C_PWM -= 1; - if (C_PWM <=1){ + if (C_PWM <= THREE_COLOR_SINGLE_JOIN_LEVEL){ direction = 0; driveMode=1; - W_PWM = 1; - C_PWM = 1; + W_PWM = THREE_COLOR_SINGLE_JOIN_LEVEL; + C_PWM = 0; } break; 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 0d263b5..a793aad 100644 --- a/project/example/ble/ble_peripheral/app/src/light_transition.c +++ b/project/example/ble/ble_peripheral/app/src/light_transition.c @@ -13,6 +13,7 @@ volatile uint32_t Light_Transition_C_Output_Q12; #define LIGHT_OUTPUT_SCALE 1000U #define BREATH_MIN_OUTPUT (LIGHT_OUTPUT_SCALE / 100U) #define DUAL_MIN_STABLE_CHANNEL_OUTPUT 102U +#define THREE_COLOR_JOIN_OUTPUT (2U * DUAL_MIN_STABLE_CHANNEL_OUTPUT) #define POWER_FADE_Q12_MAX 4096U #define POWER_FADE_ON_TICKS 140U #define POWER_FADE_OFF_TICKS 160U @@ -353,6 +354,22 @@ void Light_Transition_Task(void) (LIGHT_OUTPUT_SCALE / 100U) + 2048U) >> 12); } + /* + * The three-color breathing effect joins a single-color phase to a + * 50:50 phase. Keep the single-color side at the same physical minimum + * as the stable dual-color side, otherwise the first mixed step jumps + * from about 10/1000 to at least 204/1000. + */ + if(Mode == mode1 && choose_mode_falsg == 5U) + { + if(W_PWM != 0U && C_PWM == 0U && + target_w < THREE_COLOR_JOIN_OUTPUT) + target_w = THREE_COLOR_JOIN_OUTPUT; + else if(C_PWM != 0U && W_PWM == 0U && + target_c < THREE_COLOR_JOIN_OUTPUT) + target_c = THREE_COLOR_JOIN_OUTPUT; + } + /* * Keep the weaker mixed-light direction at the measured stable threshold. * Raise the combined output only when the requested W:C ratio needs it.