From bec5fb568305bdd40e376282210599d2745e364a Mon Sep 17 00:00:00 2001 From: wanpiqiu123 <779893878@qq.com> Date: Mon, 22 Jul 2019 09:33:07 +0800 Subject: [PATCH] fps count --- .../src/armor_finder/send_target/send_target.cpp | 6 ++++-- energy/src/energy/send/send.cpp | 15 ++++++++++++++- others/include/config/setconfig.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/armor/src/armor_finder/send_target/send_target.cpp b/armor/src/armor_finder/send_target/send_target.cpp index b2a2fa8..d404e6b 100644 --- a/armor/src/armor_finder/send_target/send_target.cpp +++ b/armor/src/armor_finder/send_target/send_target.cpp @@ -7,10 +7,11 @@ static bool sendTarget(Serial &serial, double x, double y, double z, uint16_t shoot_delay) { static short x_tmp, y_tmp, z_tmp; - static time_t last_time = time(nullptr); - static int fps; uint8_t buff[10]; +#ifdef WITH_COUNT_FPS + static time_t last_time = time(nullptr); + static int fps; time_t t = time(nullptr); if (last_time != t) { last_time = t; @@ -18,6 +19,7 @@ static bool sendTarget(Serial &serial, double x, double y, double z, uint16_t sh fps = 0; } fps += 1; +#endif x_tmp = static_cast(x * (32768 - 1) / 100); y_tmp = static_cast(y * (32768 - 1) / 100); diff --git a/energy/src/energy/send/send.cpp b/energy/src/energy/send/send.cpp index 8ecb479..9e25a34 100644 --- a/energy/src/energy/send/send.cpp +++ b/energy/src/energy/send/send.cpp @@ -13,8 +13,21 @@ using namespace std; // 此函数用于发送数据给主控板 // --------------------------------------------------------------------------------------------------------------------- void Energy::sendTarget(Serial& serial, float x, float y, float z){ - static short x_tmp, y_tmp, z_tmp; + short x_tmp, y_tmp, z_tmp; uint8_t buff[10]; + +#ifdef WITH_COUNT_FPS + static auto last_time = time(nullptr); + static int fps = 0; + time_t t = time(nullptr); + if (last_time != t) { + last_time = t; + cout << "fps:" << fps << ", (" << x << "," << y << "," << z << ")" << endl; + fps = 0; + } + fps += 1; +#endif + x_tmp = static_cast(x * (32768 - 1) / 100); y_tmp = static_cast(y * (32768 - 1) / 100); z_tmp = static_cast(z * (32768 - 1) / 100); diff --git a/others/include/config/setconfig.h b/others/include/config/setconfig.h index 30826d0..1c5c61e 100644 --- a/others/include/config/setconfig.h +++ b/others/include/config/setconfig.h @@ -46,5 +46,6 @@ //#define GIMBAL_FLIP_MODE (-1) //#define CHASSIS_FLIP_MODE (-1) //#define WITH_TIME_BASED_CAMERA_GAIN +#define WITH_COUNT_FPS #endif /* SETCONFIG_H */