增加模式切换柔和过渡

This commit is contained in:
2026-07-27 22:54:20 +08:00
parent 70979d3023
commit b85b15df17
3 changed files with 100 additions and 17 deletions
@@ -21,6 +21,7 @@ uint8_t direction = 1; //
uint8_t choose_mode_falsg=0; //模式值
uint8_t choose_mode_bh=0; //模式变化
static uint8_t mode_entry_initialized;
uint16_t Color_table_static[3][2]={
{100,0}, // warm light
@@ -113,31 +114,32 @@ void set_mode(){
break;
case 6:
//暖光跳变
W_PWM=Color_table[0][0];
C_PWM=Color_table[0][1];
W_PWM=0;
C_PWM=0;
driveMode=1;//切换为暖光的底层输出
direction=1;//呼吸方向恢复默认值
direction=0;//呼吸方向恢复默认值
Mode=mode2;
break;
case 7:
//中性光跳变
W_PWM=Color_table[1][0];
C_PWM=Color_table[1][1];
W_PWM=0;
C_PWM=0;
driveMode=0;//切换为中性光的底层输出
direction=0;
Mode=mode2;
break;
case 8:
//冷光跳变
W_PWM=Color_table[2][0];
C_PWM=Color_table[2][1];
W_PWM=0;
C_PWM=0;
driveMode=2;//切换为中性光的底层输出
direction=1;//呼吸方向恢复默认值
direction=0;//呼吸方向恢复默认值
Mode=mode2;
break;
case 9:
//暖光中性光冷交替跳变,先从暖光跳变
W_PWM=Color_table[0][0];
C_PWM=Color_table[0][1];
W_PWM=0;
C_PWM=0;
driveMode=1;//切换为暖光的底层输出
direction=1;//呼吸方向恢复默认值
Mode=mode2;
@@ -147,6 +149,15 @@ void set_mode(){
Mode=mode0;
break;
}
if(mode_entry_initialized)
{
Light_Transition_BeginModeChange();
startTimer(&timer1,1);
}
else
{
mode_entry_initialized=1;
}
}
}
void Mode0(){ //常量
@@ -353,6 +364,7 @@ pfunc modefunctin[] = { //ģʽ
Mode3,
};
void choice_mode(){
if(Light_Transition_ModeActive) return;
if (!timer1.active && timer1.count == 0){
if(Mode==mode0){
startTimer(&timer1,1);