增加2KHz和50微秒混合脉宽测试
This commit is contained in:
@@ -11,21 +11,21 @@
|
|||||||
* C: GPIO_1 low, GPIO_2 high/PWM
|
* C: GPIO_1 low, GPIO_2 high/PWM
|
||||||
* OFF: both low
|
* OFF: both low
|
||||||
*
|
*
|
||||||
* Single-color output uses a fixed 1 kHz hardware PWM.
|
* Single-color output uses a fixed 2 kHz hardware PWM.
|
||||||
*
|
*
|
||||||
* Dual-color output uses one fixed 1 ms frame:
|
* Dual-color output uses one fixed 500 us frame:
|
||||||
* OFF -> W pulse -> OFF -> C pulse -> OFF to frame end.
|
* OFF -> W pulse -> OFF -> C pulse -> OFF to frame end.
|
||||||
* 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.
|
||||||
* Both non-zero colors therefore produce exactly one pulse per frame (1 kHz).
|
* Both non-zero colors therefore produce exactly one pulse per frame (2 kHz).
|
||||||
*/
|
*/
|
||||||
#define BRIDGE_PWM_SCALE 1000U
|
#define BRIDGE_PWM_SCALE 1000U
|
||||||
#define BRIDGE_PWM_PERIOD 7U
|
#define BRIDGE_PWM_PERIOD 6U
|
||||||
#define BRIDGE_MIX_SCALE 1000U
|
#define BRIDGE_MIX_SCALE 1000U
|
||||||
#define BRIDGE_FRAME_US 1000U
|
#define BRIDGE_FRAME_US 500U
|
||||||
#define BRIDGE_DEADTIME_US 25U
|
#define BRIDGE_DEADTIME_US 25U
|
||||||
#define BRIDGE_DUAL_ACTIVE_US 950U
|
#define BRIDGE_DUAL_ACTIVE_US 450U
|
||||||
#define BRIDGE_MIN_DUAL_PULSE_US 15U
|
#define BRIDGE_MIN_DUAL_PULSE_US 50U
|
||||||
#define BRIDGE_TIMER_TICKS_PER_US 16U
|
#define BRIDGE_TIMER_TICKS_PER_US 16U
|
||||||
|
|
||||||
#define BRIDGE_GPIO_PORT 0U
|
#define BRIDGE_GPIO_PORT 0U
|
||||||
@@ -294,7 +294,7 @@ __RAM_CODE void Bridge_Service_1ms(void)
|
|||||||
total = BRIDGE_MIX_SCALE;
|
total = BRIDGE_MIX_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep the verified fixed 1 kHz hardware PWM for a single color. */
|
/* Keep the verified fixed 2 kHz hardware PWM for a single color. */
|
||||||
if (w_mix == 0U || c_mix == 0U) {
|
if (w_mix == 0U || c_mix == 0U) {
|
||||||
single_state = (w_mix != 0U) ? BRIDGE_W : BRIDGE_C;
|
single_state = (w_mix != 0U) ? BRIDGE_W : BRIDGE_C;
|
||||||
pwm_duty = (uint16_t)((total * BRIDGE_PWM_SCALE +
|
pwm_duty = (uint16_t)((total * BRIDGE_PWM_SCALE +
|
||||||
@@ -323,15 +323,15 @@ __RAM_CODE void Bridge_Service_1ms(void)
|
|||||||
/*
|
/*
|
||||||
* Keep 50 us OFF at maximum dual-color brightness. The OFF time is
|
* Keep 50 us OFF at maximum dual-color brightness. The OFF time is
|
||||||
* split evenly between W->C and C->W, which both absorbs interrupt
|
* split evenly between W->C and C->W, which both absorbs interrupt
|
||||||
* latency and spreads the two optical pulses across the 1 ms frame.
|
* latency and spreads the two optical pulses across the 500 us frame.
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
/*
|
/*
|
||||||
* Timer/driver edge uncertainty becomes visible when a dual-color
|
* Timer/driver edge uncertainty becomes visible when a dual-color
|
||||||
* pulse is only a few microseconds wide. Keep both directions at
|
* pulse is only a few microseconds wide. Keep both directions at
|
||||||
* least 15 us. This gives dual color a stable floor of about 3%,
|
* least 50 us. Single-color hardware PWM keeps its independent
|
||||||
* while single-color hardware PWM can still reach 1%.
|
* 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;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ volatile uint8_t Light_Transition_FadeActive;
|
|||||||
#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_COMBINED_OUTPUT ((LIGHT_OUTPUT_SCALE * 15U) / 100U)
|
||||||
#define DUAL_MIN_STABLE_CHANNEL_OUTPUT 17U
|
#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
|
||||||
@@ -226,7 +226,7 @@ void Light_Transition_Task(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Mixed light starts from a 15% combined floor. If the weaker direction
|
* Mixed light starts from a 15% combined floor. If the weaker direction
|
||||||
* would be below 17/1000 (about 16 us of the 950 us active window), raise
|
* 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.
|
* the combined floor just enough to preserve the requested W:C ratio.
|
||||||
* Ratios that cannot satisfy this even at 100% are treated as single
|
* Ratios that cannot satisfy this even at 100% are treated as single
|
||||||
* color. Single-color output keeps the 1% Gamma minimum.
|
* color. Single-color output keeps the 1% Gamma minimum.
|
||||||
|
|||||||
Reference in New Issue
Block a user