修复椭圆遥控控制异常

This commit is contained in:
xushaoxiang
2026-07-21 16:31:07 +08:00
parent 908fe71b1b
commit 360697296c
151 changed files with 6899 additions and 6086 deletions
@@ -42,8 +42,8 @@ uint8_t adress_ch2_index = 0; // 通道2地址索引(0-4)
uint8_t match_ch = 0; // 匹配到的通道(1=GPIO52=GPIO2
#define MATCH_CH1 0 // HPW421 不使用通道1
#define MATCH_CH2 (1 << 1) // 通道2匹配标记
#define MATCH_CH1 (1 << 0) //GPIO5
#define MATCH_CH2 (1 << 1) // 通道2匹配标记
uint8_t flash_ch1_state=0;
@@ -92,8 +92,6 @@ void chx_gpio_init(void)
GPIO_InitCfg.FunSel = GPIO_Dx; // 选择GPIO功能(非特殊功能)
GPIO_InitCfg.Pull = GPIO_NOPULL; //下拉电阻使能
GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
GPIO_InitCfg.Dir = GPIO_DIR_OUTPUT; // 输出方向
GPIO_InitCfg.Int = NOT_INT; // 不使能中断
GPIO_InitCfg.Pin = RELAY_CH2_PIN; // 设置通道2引脚
@@ -143,17 +141,10 @@ void app_key_callback_handler(uint16_t key_value) //按键回调函数
case MODE_DOUBLE_CLICK: //双击
key_state=KEY_SHORT;
power=3;
power=4;
led_state=2;
break;
case MODE_QUAD_CLICK: //四击
key_state=KEY_SHORT;
power=3;
led_state=2;
break;
default:
break;
}
@@ -167,17 +158,11 @@ void ble_mode_scan(void)
{
switch(receive_mode)
{
case 1:
receive_mode=0;
key_state=KEY_SHORT;
power=3;
led_state=2;
break;
case 2:
receive_mode=0;
key_state=KEY_SHORT;
power=3;
power=4;
led_state=2;
break;
@@ -202,7 +187,7 @@ void _433_fun(void)
switch(res_data)
{
case 0x03: //如果是3键遥控或者是正方形白色遥控
if(match_ch & MATCH_CH2){
if(match_ch & MATCH_CH1){
xc_gpio_toggle_pin(RELAY_CH2_PIN);
flash_ch2_state=xc_gpio_read_pin(RELAY_CH2_PIN);
ble_state_mark_dirty(BLE_STATE_DIRTY_OUTPUT | BLE_STATE_DIRTY_RF433);
@@ -212,7 +197,7 @@ void _433_fun(void)
case 0x04: //如果是黑色长方形遥控或者椭圆遥控关闭按键
if(match_ch & MATCH_CH2)
if(match_ch & MATCH_CH1)
{
xc_gpio_write_pin(RELAY_CH2_PIN,GPIO_PIN_RESET);
flash_ch2_state=xc_gpio_read_pin(RELAY_CH2_PIN);
@@ -221,7 +206,7 @@ void _433_fun(void)
break;
case 0x02: //如果是黑色长方形遥控或者椭圆遥控打开按键
if(match_ch & MATCH_CH2)
if(match_ch & MATCH_CH1)
{
xc_gpio_write_pin(RELAY_CH2_PIN,GPIO_PIN_SET);
flash_ch2_state=xc_gpio_read_pin(RELAY_CH2_PIN);
@@ -256,7 +241,7 @@ void scan_433(void)
else if(rf433_sw_flag==2)
{
rf433_sw_flag=0;
power=3;
power=4;
key_state=KEY_SHORT;
led_state=2;
}
@@ -269,45 +254,45 @@ void scan_433(void)
}
if(power==3 && rf433_decoder_flag==true && key_state==KEY_SHORT ) //双击对码GPIO2
{
key_state=0;
power=2;
led_state=0;
if(adress_ch2_index>4)
{
adress_ch2_index=0;
}
adress_ture_flag=0;
for(i=0;i<5;i++)
{
if(adress_H_ch2[i]==adress_H && adress_L_ch2[i]==adress_L)
{
adress_ture_flag=1;
break;
}
}
if(adress_ture_flag==0)
{
adress_H_ch2[adress_ch2_index] = adress_H;
adress_L_ch2[adress_ch2_index] = adress_L;
adress_ch2_index++; // 索引自增
}
}
// if(power==3 && rf433_decoder_flag==true && key_state==KEY_SHORT ) //双击对码GPIO2
// {
//
//
// key_state=0;
// power=2;
// led_state=0;
//
//
//
// if(adress_ch2_index>4)
// {
// adress_ch2_index=0;
// }
//
// adress_ture_flag=0;
//
// for(i=0;i<5;i++)
// {
// if(adress_H_ch2[i]==adress_H && adress_L_ch2[i]==adress_L)
// {
// adress_ture_flag=1;
//
// break;
// }
// }
// if(adress_ture_flag==0)
// {
//
// adress_H_ch2[adress_ch2_index] = adress_H;
// adress_L_ch2[adress_ch2_index] = adress_L;
// adress_ch2_index++; // 索引自增
// }
//
//
// }
else if(power==4 && rf433_decoder_flag==true && key_state==KEY_SHORT ) //四击对码GPIO5
if(power==4 && rf433_decoder_flag==true && key_state==KEY_SHORT ) //四击对码GPIO5
{
@@ -366,14 +351,14 @@ void scan_433(void)
}
}
for(i=0; i<5; i++)
{
if(adress_H_ch2[i]==adress_H && adress_L_ch2[i]==adress_L)
{
match_ch|= MATCH_CH2; // 标记匹配到通道2
break;
}
}
// for(i=0; i<5; i++)
// {
// if(adress_H_ch2[i]==adress_H && adress_L_ch2[i]==adress_L)
// {
// match_ch|= MATCH_CH2; // 标记匹配到通道2
// break;
// }
// }
if(match_ch != 0)