From 3f0a8d1761e5dc44d1a1ca4aad23de22ac57ee23 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2016 10:28:17 +1000 Subject: [PATCH] Plane: added AP_Button support for plane this also adds the g2 parameter table --- ArduPlane/ArduPlane.cpp | 1 + ArduPlane/Parameters.cpp | 16 ++++++++++++++++ ArduPlane/Parameters.h | 15 +++++++++++++++ ArduPlane/Plane.h | 6 ++++-- ArduPlane/sensors.cpp | 8 ++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ArduPlane/ArduPlane.cpp b/ArduPlane/ArduPlane.cpp index f536a59d68..19b1a69ed1 100644 --- a/ArduPlane/ArduPlane.cpp +++ b/ArduPlane/ArduPlane.cpp @@ -85,6 +85,7 @@ const AP_Scheduler::Task Plane::scheduler_tasks[] = { SCHED_TASK(update_is_flying_5Hz, 5, 100), SCHED_TASK(dataflash_periodic, 50, 400), SCHED_TASK(adsb_update, 10, 100), + SCHED_TASK(button_update, 5, 100), }; void Plane::setup() diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index 7860db467c..728561f6b2 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -1357,9 +1357,25 @@ const AP_Param::Info Plane::var_info[] = { // @Path: ../libraries/AP_Notify/AP_Notify.cpp GOBJECT(notify, "NTF_", AP_Notify), + // @Group: + // @Path: Parameters.cpp + GOBJECT(g2, "", ParametersG2), + AP_VAREND }; +/* + 2nd group of parameters + */ +const AP_Param::GroupInfo ParametersG2::var_info[] = { + + // @Group: BTN_ + // @Path: ../libraries/AP_Button/AP_Button.cpp + AP_SUBGROUPINFO(button, "BTN_", 1, ParametersG2, AP_Button), + + AP_GROUPEND +}; + /* This is a conversion table from old parameter values to new parameter names. The startup code looks for saved values of the old diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index cfedd2683b..f2050593a2 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -50,6 +50,7 @@ public: k_param_software_type, k_param_num_resets, k_param_NavEKF2, + k_param_g2, // Misc // @@ -568,4 +569,18 @@ public: {} }; +/* + 2nd block of parameters, to avoid going past 256 top level keys + */ +class ParametersG2 { +public: + ParametersG2(void) { AP_Param::setup_object_defaults(this, var_info); } + + // var_info for holding Parameter information + static const struct AP_Param::GroupInfo var_info[]; + + // button reporting library + AP_Button button; +}; + extern const AP_Param::Info var_info[]; diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 47237ec112..3e325e8a5d 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -88,6 +88,7 @@ #include // RSSI Library #include #include +#include #include "GCS_Mavlink.h" #include "quadplane.h" @@ -146,8 +147,9 @@ private: AP_Vehicle::FixedWing aparm; AP_HAL::BetterStream* cliSerial; - // Global parameters are all contained within the 'g' class. + // Global parameters are all contained within the 'g' and 'g2' classes. Parameters g; + ParametersG2 g2; // main loop scheduler AP_Scheduler scheduler; @@ -638,7 +640,6 @@ private: Location prev_wp; } adsb_state; - // Outback Challenge Failsafe Support #if OBC_FAILSAFE == ENABLED APM_OBC obc {mission, barometer, gps, rcmap}; @@ -955,6 +956,7 @@ private: void read_battery(void); void read_receiver_rssi(void); void rpm_update(void); + void button_update(void); void report_radio(); void report_ins(); void report_compass(); diff --git a/ArduPlane/sensors.cpp b/ArduPlane/sensors.cpp index 0c79ff77d3..ef445520f6 100644 --- a/ArduPlane/sensors.cpp +++ b/ArduPlane/sensors.cpp @@ -156,3 +156,11 @@ void Plane::rpm_update(void) } } } + +/* + update AP_Button + */ +void Plane::button_update(void) +{ + g2.button.update(); +}