移除混合光最低亮度限制
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
#define BRIDGE_FRAME_US 500U
|
#define BRIDGE_FRAME_US 500U
|
||||||
#define BRIDGE_DEADTIME_US 25U
|
#define BRIDGE_DEADTIME_US 25U
|
||||||
#define BRIDGE_DUAL_ACTIVE_US 450U
|
#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_TIMER_TICKS_PER_US 16U
|
||||||
|
|
||||||
#define BRIDGE_GPIO_PORT 0U
|
#define BRIDGE_GPIO_PORT 0U
|
||||||
@@ -327,12 +327,7 @@ __RAM_CODE void Bridge_Service_1ms(void)
|
|||||||
*/
|
*/
|
||||||
total_on_us = (BRIDGE_DUAL_ACTIVE_US * total +
|
total_on_us = (BRIDGE_DUAL_ACTIVE_US * total +
|
||||||
(BRIDGE_MIX_SCALE / 2U)) / BRIDGE_MIX_SCALE;
|
(BRIDGE_MIX_SCALE / 2U)) / BRIDGE_MIX_SCALE;
|
||||||
/*
|
/* Keep a non-zero timer interval without imposing a brightness floor. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
if (total_on_us < (2U * BRIDGE_MIN_DUAL_PULSE_US)) {
|
if (total_on_us < (2U * BRIDGE_MIN_DUAL_PULSE_US)) {
|
||||||
total_on_us = 2U * BRIDGE_MIN_DUAL_PULSE_US;
|
total_on_us = 2U * BRIDGE_MIN_DUAL_PULSE_US;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ volatile uint8_t Light_Transition_FadeActive;
|
|||||||
#define OUTPUT_SMOOTH_SHIFT 4U
|
#define OUTPUT_SMOOTH_SHIFT 4U
|
||||||
#define LIGHT_OUTPUT_SCALE 1000U
|
#define LIGHT_OUTPUT_SCALE 1000U
|
||||||
#define BREATH_MIN_OUTPUT (LIGHT_OUTPUT_SCALE / 100U)
|
#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_Q12_MAX 4096U
|
||||||
#define POWER_FADE_ON_TICKS 140U
|
#define POWER_FADE_ON_TICKS 140U
|
||||||
#define POWER_FADE_OFF_TICKS 160U
|
#define POWER_FADE_OFF_TICKS 160U
|
||||||
@@ -196,10 +194,6 @@ void Light_Transition_Task(void)
|
|||||||
uint16_t target_brightness_scale;
|
uint16_t target_brightness_scale;
|
||||||
uint16_t brightness_scale;
|
uint16_t brightness_scale;
|
||||||
uint16_t fade_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;
|
uint8_t power_transitioning;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -224,47 +218,6 @@ void Light_Transition_Task(void)
|
|||||||
(uint16_t)(((uint32_t)C_PWM * brightness_scale *
|
(uint16_t)(((uint32_t)C_PWM * brightness_scale *
|
||||||
(LIGHT_OUTPUT_SCALE / 100U) + 2048U) >> 12);
|
(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_w = (uint16_t)(((uint32_t)target_w * fade_scale + 2048U) >> 12);
|
||||||
target_c = (uint16_t)(((uint32_t)target_c * fade_scale + 2048U) >> 12);
|
target_c = (uint16_t)(((uint32_t)target_c * fade_scale + 2048U) >> 12);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user