三色呼吸恢复为纯PWM输出
This commit is contained in:
@@ -18,8 +18,6 @@
|
|||||||
* The available OFF time is distributed around both direction changes and
|
* The available OFF time is distributed around both direction changes and
|
||||||
* each W/C transition retains at least 25 us protection.
|
* each W/C transition retains at least 25 us protection.
|
||||||
* Normal dual-color output produces one pulse per color per frame (2 kHz).
|
* Normal dual-color output produces one pulse per color per frame (2 kHz).
|
||||||
* Low-level three-color breathing keeps 50 us pulses but density-modulates
|
|
||||||
* them across frames so the average output can fade below that pulse width.
|
|
||||||
*/
|
*/
|
||||||
#define BRIDGE_PWM_SCALE 1000U
|
#define BRIDGE_PWM_SCALE 1000U
|
||||||
#define BRIDGE_PWM_PERIOD 6U
|
#define BRIDGE_PWM_PERIOD 6U
|
||||||
@@ -28,11 +26,8 @@
|
|||||||
#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 1U
|
#define BRIDGE_MIN_DUAL_PULSE_US 1U
|
||||||
#define BRIDGE_TRICOLOR_PDM_PULSE_US 50U
|
|
||||||
#define BRIDGE_TIMER_TICKS_PER_US 16U
|
#define BRIDGE_TIMER_TICKS_PER_US 16U
|
||||||
#define BRIDGE_PDM_THRESHOLD (BRIDGE_MIX_SCALE * 4096UL)
|
#define BRIDGE_PDM_THRESHOLD (BRIDGE_MIX_SCALE * 4096UL)
|
||||||
#define BRIDGE_TRICOLOR_PDM_THRESHOLD \
|
|
||||||
(BRIDGE_TRICOLOR_PDM_PULSE_US * BRIDGE_PDM_THRESHOLD)
|
|
||||||
|
|
||||||
#define BRIDGE_GPIO_PORT 0U
|
#define BRIDGE_GPIO_PORT 0U
|
||||||
#define BRIDGE_GPIO_MASK ((1UL << IO_PWM_W) | (1UL << IO_PWM_C))
|
#define BRIDGE_GPIO_MASK ((1UL << IO_PWM_W) | (1UL << IO_PWM_C))
|
||||||
@@ -388,46 +383,6 @@ __RAM_CODE void Bridge_Service_1ms(void)
|
|||||||
goto dual_output_ready;
|
goto dual_output_ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* The low part of the three-color breathing effect cannot use short
|
|
||||||
* 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)) {
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
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) {
|
|
||||||
next_w_us = BRIDGE_TRICOLOR_PDM_PULSE_US;
|
|
||||||
next_c_us = BRIDGE_TRICOLOR_PDM_PULSE_US;
|
|
||||||
total_off_us =
|
|
||||||
BRIDGE_FRAME_US -
|
|
||||||
(2U * BRIDGE_TRICOLOR_PDM_PULSE_US);
|
|
||||||
next_wc_off_us = (uint16_t)(total_off_us / 2U);
|
|
||||||
next_cw_off_us =
|
|
||||||
(uint16_t)(total_off_us - next_wc_off_us);
|
|
||||||
next_pdm_w_step = pdm_w_step;
|
|
||||||
next_pdm_c_step = pdm_c_step;
|
|
||||||
next_pdm_threshold = BRIDGE_TRICOLOR_PDM_THRESHOLD;
|
|
||||||
next_pdm_enabled = 1U;
|
|
||||||
cached_w_mix = (uint16_t)w_mix;
|
|
||||||
cached_c_mix = (uint16_t)c_mix;
|
|
||||||
goto dual_output_ready;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next_pdm_enabled) {
|
if (next_pdm_enabled) {
|
||||||
cached_w_mix = 0xFFFFU;
|
cached_w_mix = 0xFFFFU;
|
||||||
cached_c_mix = 0xFFFFU;
|
cached_c_mix = 0xFFFFU;
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ volatile uint32_t Light_Transition_C_Output_Q12;
|
|||||||
#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_STABLE_CHANNEL_OUTPUT 102U
|
#define DUAL_MIN_STABLE_CHANNEL_OUTPUT 102U
|
||||||
#define THREE_COLOR_MIN_CHANNEL_OUTPUT 25U
|
|
||||||
#define THREE_COLOR_MIN_SINGLE_OUTPUT 45U
|
|
||||||
#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
|
||||||
@@ -355,29 +353,6 @@ void Light_Transition_Task(void)
|
|||||||
(LIGHT_OUTPUT_SCALE / 100U) + 2048U) >> 12);
|
(LIGHT_OUTPUT_SCALE / 100U) + 2048U) >> 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Three-color breathing uses 50 us pulse-density modulation below the
|
|
||||||
* normal dual-color pulse range. Keep both sides of each color join at
|
|
||||||
* the same low physical on-time: 45/1000 of a 500 us single-color frame,
|
|
||||||
* or 25 + 25 over the 450 us dual-color active interval.
|
|
||||||
*/
|
|
||||||
if(Mode == mode1 && choose_mode_falsg == 5U)
|
|
||||||
{
|
|
||||||
if(W_PWM != 0U && C_PWM == 0U &&
|
|
||||||
target_w < THREE_COLOR_MIN_SINGLE_OUTPUT)
|
|
||||||
target_w = THREE_COLOR_MIN_SINGLE_OUTPUT;
|
|
||||||
else if(C_PWM != 0U && W_PWM == 0U &&
|
|
||||||
target_c < THREE_COLOR_MIN_SINGLE_OUTPUT)
|
|
||||||
target_c = THREE_COLOR_MIN_SINGLE_OUTPUT;
|
|
||||||
else if(W_PWM != 0U && C_PWM != 0U)
|
|
||||||
{
|
|
||||||
if(target_w < THREE_COLOR_MIN_CHANNEL_OUTPUT)
|
|
||||||
target_w = THREE_COLOR_MIN_CHANNEL_OUTPUT;
|
|
||||||
if(target_c < THREE_COLOR_MIN_CHANNEL_OUTPUT)
|
|
||||||
target_c = THREE_COLOR_MIN_CHANNEL_OUTPUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keep the weaker mixed-light direction at the measured stable threshold.
|
* Keep the weaker mixed-light direction at the measured stable threshold.
|
||||||
* Raise the combined output only when the requested W:C ratio needs it.
|
* Raise the combined output only when the requested W:C ratio needs it.
|
||||||
|
|||||||
Reference in New Issue
Block a user