增加操控端遥控
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "app_rc.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/** 定时器 */
|
||||
static Timer rc_timer;
|
||||
@@ -163,11 +164,13 @@ void rcInputHandler(void *signal_id)
|
||||
// CRC校验通过,更新序列号和使能状态
|
||||
rc_app_state.rc_16ch_current_seq = remote_control_16ch_output.frame.SEQ;
|
||||
rc_app_state.rc_16ch_enable = 1;
|
||||
printf("RC: 16ch CRC OK, SEQ=%d, Enable=1\n", rc_app_state.rc_16ch_current_seq);
|
||||
}
|
||||
else
|
||||
{
|
||||
// CRC校验失败,不更新数据
|
||||
rc_app_state.rc_16ch_enable = 0;
|
||||
printf("RC: 16ch CRC FAILED, Enable=0\n");
|
||||
}
|
||||
}
|
||||
else if (signal_id == &un_remote_control_input_can)
|
||||
@@ -175,6 +178,9 @@ void rcInputHandler(void *signal_id)
|
||||
// 传统遥控器数据更新
|
||||
rc_app_state.rc_traditional_current_seq++;
|
||||
rc_app_state.rc_traditional_enable = un_remote_control_input_can.bit_data.enable;
|
||||
printf("RC: Traditional SEQ=%d, Enable=%d\n",
|
||||
rc_app_state.rc_traditional_current_seq,
|
||||
rc_app_state.rc_traditional_enable);
|
||||
}
|
||||
|
||||
// 节点在线判断和数据输出
|
||||
@@ -259,11 +265,19 @@ void rcInputHandler(void *signal_id)
|
||||
|
||||
un_remote_control_input.bit_data.switch_a = 0;
|
||||
un_remote_control_input.bit_data.enable = 1;
|
||||
|
||||
printf("RC: 16ch data processed - Speed=%d, Curvature=%d, Switch_D=%d, Switch_B=%d, Switch_C=%d\n",
|
||||
un_remote_control_input.bit_data.speed,
|
||||
un_remote_control_input.bit_data.curvature,
|
||||
un_remote_control_input.bit_data.switch_d,
|
||||
un_remote_control_input.bit_data.switch_b,
|
||||
un_remote_control_input.bit_data.switch_c);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 都离线,清空使能
|
||||
un_remote_control_input.bit_data.enable = 0;
|
||||
printf("RC: Both nodes offline, enable=0\n");
|
||||
}
|
||||
|
||||
publishMessage(&un_remote_control_input, 1); // 优先级为1,这里只传递数据指针
|
||||
@@ -292,4 +306,6 @@ void rcAppInit(void)
|
||||
|
||||
// 启动定时器,500ms周期
|
||||
timerStart(&rc_timer, 500, 1);
|
||||
|
||||
printf("RC: Application initialized successfully\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user