From 98b8a61ca88abbc8bfb841e7e12dc8638d26174a Mon Sep 17 00:00:00 2001 From: night-ghost Date: Wed, 28 Feb 2018 17:22:16 +0500 Subject: [PATCH] Plane: allow AP_Stats to be optional --- ArduPlane/ArduPlane.cpp | 5 ++++- ArduPlane/Parameters.cpp | 3 ++- ArduPlane/Parameters.h | 2 ++ ArduPlane/config.h | 4 ++++ ArduPlane/is_flying.cpp | 2 ++ ArduPlane/system.cpp | 2 ++ 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ArduPlane/ArduPlane.cpp b/ArduPlane/ArduPlane.cpp index 5263e9e2f3..e5e3a8fd41 100644 --- a/ArduPlane/ArduPlane.cpp +++ b/ArduPlane/ArduPlane.cpp @@ -83,12 +83,15 @@ const AP_Scheduler::Task Plane::scheduler_tasks[] = { SCHED_TASK(ins_periodic, 50, 50), SCHED_TASK(avoidance_adsb_update, 10, 100), SCHED_TASK(button_update, 5, 100), +#if STATS_ENABLED == ENABLED SCHED_TASK(stats_update, 1, 100), +#endif #if GRIPPER_ENABLED == ENABLED SCHED_TASK_CLASS(AP_Gripper, &plane.g2.gripper, update, 10, 75), #endif }; +#if STATS_ENABLED == ENABLED /* update AP_Stats */ @@ -96,7 +99,7 @@ void Plane::stats_update(void) { g2.stats.update(); } - +#endif void Plane::setup() { diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index 216cc04459..8dff3ff811 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -1144,10 +1144,11 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @Values: 0:NotEnforced,1:Enforced // @User: Advanced AP_GROUPINFO("SYSID_ENFORCE", 4, ParametersG2, sysid_enforce, 0), - +#if STATS_ENABLED == ENABLED // @Group: STAT // @Path: ../libraries/AP_Stats/AP_Stats.cpp AP_SUBGROUPINFO(stats, "STAT", 5, ParametersG2, AP_Stats), +#endif // @Group: SERVO // @Path: ../libraries/SRV_Channel/SRV_Channels.cpp diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index 4b10c00370..031afc2f46 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -518,8 +518,10 @@ public: // button reporting library AP_Button button; +#if STATS_ENABLED == ENABLED // vehicle statistics AP_Stats stats; +#endif // internal combustion engine control AP_ICEngine ice_control; diff --git a/ArduPlane/config.h b/ArduPlane/config.h index 62930dafcc..ef858ca7c6 100644 --- a/ArduPlane/config.h +++ b/ArduPlane/config.h @@ -355,3 +355,7 @@ #else # define HAVE_PX4_MIXER 0 #endif + +#ifndef STATS_ENABLED + # define STATS_ENABLED ENABLED +#endif diff --git a/ArduPlane/is_flying.cpp b/ArduPlane/is_flying.cpp index dd99ff4d9c..5983704af3 100644 --- a/ArduPlane/is_flying.cpp +++ b/ArduPlane/is_flying.cpp @@ -150,7 +150,9 @@ void Plane::update_is_flying_5Hz(void) #if FRSKY_TELEM_ENABLED == ENABLED frsky_telemetry.set_is_flying(new_is_flying); #endif +#if STATS_ENABLED == ENABLED g2.stats.set_flying(new_is_flying); +#endif crash_detection_update(); diff --git a/ArduPlane/system.cpp b/ArduPlane/system.cpp index 532b21f60c..aa6e29be9f 100644 --- a/ArduPlane/system.cpp +++ b/ArduPlane/system.cpp @@ -33,8 +33,10 @@ void Plane::init_ardupilot() // load_parameters(); +#if STATS_ENABLED == ENABLED // initialise stats module g2.stats.init(); +#endif #if HIL_SUPPORT if (g.hil_mode == 1) {