From 4ef3aa2f768a5f235f98993efb4ba5253b6b2ef1 Mon Sep 17 00:00:00 2001 From: NeoZng Date: Sun, 23 Apr 2023 14:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=81=A5=E6=8E=A7?= =?UTF-8?q?=E5=99=A8=E9=94=AE=E9=BC=A0=E6=8E=A5=E6=94=B6=E7=9A=84=E5=B9=B3?= =?UTF-8?q?=E6=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/remote/remote_control.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/remote/remote_control.c b/modules/remote/remote_control.c index 5d5fde7..497b7c8 100644 --- a/modules/remote/remote_control.c +++ b/modules/remote/remote_control.c @@ -5,6 +5,7 @@ #include "stdlib.h" #include "daemon.h" +#define RC_MOUSE_SMOOTH_COEF 0.9 // 鼠标平滑滤波器的阶数 #define REMOTE_CONTROL_FRAME_SIZE 18u // 遥控器接收的buffer大小 // 遥控器数据 static RC_ctrl_t rc_ctrl[2]; //[0]:当前数据TEMP,[1]:上一次的数据LAST.用于按键持续按下和切换的判断 @@ -48,9 +49,8 @@ static void sbus_to_rc(const uint8_t *sbus_buf) rc_ctrl[TEMP].rc.switch_left = ((sbus_buf[5] >> 4) & 0x000C) >> 2; //!< Switch left // 鼠标解析 - rc_ctrl[TEMP].mouse.x = sbus_buf[6] | (sbus_buf[7] << 8); //!< Mouse X axis - rc_ctrl[TEMP].mouse.y = sbus_buf[8] | (sbus_buf[9] << 8); //!< Mouse Y axis - rc_ctrl[TEMP].mouse.z = sbus_buf[10] | (sbus_buf[11] << 8); //!< Mouse Z axis + rc_ctrl[TEMP].mouse.x = (float)(sbus_buf[6] | (sbus_buf[7] << 8))*RC_MOUSE_SMOOTH_COEF + (1-RC_MOUSE_SMOOTH_COEF)*(float)(rc_ctrl[LAST].mouse.x); //!< Mouse X axis + rc_ctrl[TEMP].mouse.y = (float)(sbus_buf[8] | (sbus_buf[9] << 8))*RC_MOUSE_SMOOTH_COEF + (1-RC_MOUSE_SMOOTH_COEF)*(float)(rc_ctrl[TEMP].mouse.y); //!< Mouse Y axis rc_ctrl[TEMP].mouse.press_l = sbus_buf[12]; //!< Mouse Left Is Press ? rc_ctrl[TEMP].mouse.press_r = sbus_buf[13]; //!< Mouse Right Is Press ?