修正渐变互补与闪烁切换
This commit is contained in:
@@ -62,7 +62,6 @@ void Stop_PWM(){
|
||||
|
||||
|
||||
void set_mode(){
|
||||
Light_Transition_Task();
|
||||
if(choose_mode_bh==0){
|
||||
choose_mode_bh=1;
|
||||
switch(choose_mode_falsg){
|
||||
@@ -122,6 +121,7 @@ void set_mode(){
|
||||
else
|
||||
{
|
||||
Light_Transition_ModeActive=0U;
|
||||
Light_Transition_SyncBrightness(Brightness);
|
||||
}
|
||||
startTimer(&timer1,1);
|
||||
}
|
||||
@@ -130,6 +130,7 @@ void set_mode(){
|
||||
mode_entry_initialized=1;
|
||||
}
|
||||
}
|
||||
Light_Transition_Task();
|
||||
}
|
||||
void Mode0(){ //常量
|
||||
(void)0;/* transition */
|
||||
|
||||
@@ -456,6 +456,16 @@ __RAM_CODE void Bridge_Service_1ms(void)
|
||||
single_state = (w_mix != 0U) ? BRIDGE_W : BRIDGE_C;
|
||||
pwm_duty = (uint16_t)((total * BRIDGE_PWM_SCALE +
|
||||
(BRIDGE_MIX_SCALE / 2U)) / BRIDGE_MIX_SCALE);
|
||||
/*
|
||||
* A mixed H-bridge frame has 450 us of active time after deadtime.
|
||||
* Use the same 450/500 energy at both single-color endpoints of the
|
||||
* continuous gradient so its total brightness does not jump there.
|
||||
*/
|
||||
if (Mode == mode3 && choose_mode_falsg == 7U) {
|
||||
pwm_duty = (uint16_t)(
|
||||
((uint32_t)pwm_duty * BRIDGE_DUAL_ACTIVE_US +
|
||||
(BRIDGE_FRAME_US / 2U)) / BRIDGE_FRAME_US);
|
||||
}
|
||||
|
||||
if (output_mode == BRIDGE_MODE_SINGLE &&
|
||||
active_state == single_state &&
|
||||
|
||||
@@ -293,6 +293,7 @@ void Light_Transition_Task(void)
|
||||
uint8_t powered_on = deviceStatus != POWEROFF;
|
||||
uint16_t target_w;
|
||||
uint16_t target_c;
|
||||
uint16_t target_total;
|
||||
uint16_t target_brightness_scale;
|
||||
uint16_t brightness_scale;
|
||||
uint16_t fade_scale;
|
||||
@@ -337,7 +338,22 @@ void Light_Transition_Task(void)
|
||||
powered_on ? (power_fade_progress_q12 < POWER_FADE_Q12_MAX)
|
||||
: (power_fade_progress_q12 != 0U);
|
||||
|
||||
if(Mode == mode1)
|
||||
if(Mode == mode3 && choose_mode_falsg == 7U)
|
||||
{
|
||||
/*
|
||||
* Continuous CCT uses one shared brightness envelope. Derive one
|
||||
* side from the other so every visible step is strictly complementary
|
||||
* and W + C remains constant throughout the sweep.
|
||||
*/
|
||||
target_total = (uint16_t)(
|
||||
((uint32_t)LIGHT_OUTPUT_SCALE * brightness_scale + 2048U) >> 12);
|
||||
target_w = (uint16_t)(
|
||||
((uint32_t)target_total * W_PWM + 50U) / 100U);
|
||||
if(target_w > target_total)
|
||||
target_w = target_total;
|
||||
target_c = target_total - target_w;
|
||||
}
|
||||
else if(Mode == mode1)
|
||||
{
|
||||
target_w = (uint16_t)(
|
||||
((uint32_t)effect_gamma_output(W_PWM) *
|
||||
@@ -364,7 +380,8 @@ void Light_Transition_Task(void)
|
||||
*/
|
||||
if(W_PWM != 0U && C_PWM != 0U &&
|
||||
!(Mode == mode1 &&
|
||||
(choose_mode_falsg == 5U || choose_mode_falsg == 6U)))
|
||||
(choose_mode_falsg == 5U || choose_mode_falsg == 6U)) &&
|
||||
!(Mode == mode3 && choose_mode_falsg == 7U))
|
||||
{
|
||||
mix_total = (uint16_t)(W_PWM + C_PWM);
|
||||
weak_mix = (W_PWM < C_PWM) ? W_PWM : C_PWM;
|
||||
@@ -419,7 +436,8 @@ void Light_Transition_Task(void)
|
||||
if(mode_transition_tick >= MODE_TRANSITION_TICKS)
|
||||
Light_Transition_ModeActive = 0U;
|
||||
}
|
||||
else if((Mode == mode2 && powered_on) || power_transitioning ||
|
||||
else if(((Mode == mode2 || Mode == mode3) && powered_on) ||
|
||||
power_transitioning ||
|
||||
transition_sync_pending)
|
||||
{
|
||||
W_PWM_duty = target_w;
|
||||
|
||||
Reference in New Issue
Block a user