工具/软件:
我将三个序列编程到存储器中。 我使用一个引擎来运行每个序列(不能同时运行)。
- 使用 D1、D2 和 D7 的脉动白色程序
- 稳定白色程序(再次,D1、D2 和 D7)
- 闪烁橙色程序(仅限 D2 和 D7)
序列独立工作(当所有输出都关闭时测试)、但当从脉动或实心序列切换到闪烁时、映射似乎受阻。
有时蓝色 LED (D1) 亮起、红色闪烁(使蓝色 — 品红色-蓝色 — 品红色...)、有时红色 (D2) 和绿色 (D7) 闪烁、蓝色熄灭(与预期一致!)。 这种行为对我来说很随意。
以下是我的代码:
uint8_t mapping_sequence[] = {
// Mapping describing which output channels to use (stored in page 0)
0x00, 0x43, // White (Red D2 + Blue D1 and Green D7)
0x00, 0x02, // Red D2 (used for orange)
0x00, 0x40, // Green D7 (used for orange)
};
uint8_t pulsating_white_sequence[] = {
// Pulsating white program (stored in page 1)
0x9F, 0x80, // Set mapping to instruction 0
0x40, 0x00, // PWM off (all LEDs)
0x40, PULSATING_PWM_HIGHEST, // PWM on
PULSATING_CYCLES_PER_STEP | 0x01, PULSATING_PWM_STEPS, // Ramp down
PULSATING_WAITING_CYCLES | 0x40, 0x00, // Wait
PULSATING_CYCLES_PER_STEP, PULSATING_PWM_STEPS, // Ramp up
0xA0, 0x03, // Jump to instruction 3
};
uint8_t solid_white_program[] = {
// Solid white program (stored in page 2)
0x9F, 0x80, // Set mapping to instruction 0
PULSATING_CYCLES_PER_STEP, PULSATING_PWM_STEPS, // Ramp up (smooth transition from pulsing)
};
uint8_t blinking_orange_sequence[] = {
// Blinking orange program (stored in page 3)
0x9F, 0x80, // Set mapping to instruction 0
0x40, 0x00, // PWM off (all LEDs)
0x9F, 0x81, // Set mapping to instruction 1
0x40, 0x00, // PWM off (Red)
0x9F, 0x82, // Set mapping to instruction 2
0x40, 0x00, // PWM off (Green)
BLINKING_WAITING_CYCLES | 0x40, 0x00, // Wait
0x9F, 0x81, // Set mapping to instruction 2
0x40, PWM_RED_ORANGE_BLINKING, // PWM on
0x9F, 0x82, // Set mapping to instruction 3
0x40, PWM_GREEN_ORANGE_BLINKING, // PWM on
BLINKING_WAITING_CYCLES | 0x40, 0x00, // Wait
0xA0, 0x02, // Jump to instruction 2
};
红色和绿色单独映射(变为橙色)的原因是、我希望两者的 PWM/亮度值可以单独管理、从而完全控制所看到的颜色。
我的代码有问题、我的代码是坏做法还是有问题?