From cb5ca713a93e14ebc79bf29accdda48fb06d53b2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2016 11:24:13 +1000 Subject: [PATCH] Copter: added AP_Button support --- ArduCopter/ArduCopter.cpp | 1 + ArduCopter/Copter.h | 2 ++ ArduCopter/Parameters.cpp | 4 ++++ ArduCopter/Parameters.h | 3 +++ ArduCopter/sensors.cpp | 8 ++++++++ 5 files changed, 18 insertions(+) diff --git a/ArduCopter/ArduCopter.cpp b/ArduCopter/ArduCopter.cpp index 84fb2cad4c..9033bfb969 100644 --- a/ArduCopter/ArduCopter.cpp +++ b/ArduCopter/ArduCopter.cpp @@ -151,6 +151,7 @@ const AP_Scheduler::Task Copter::scheduler_tasks[] = { #ifdef USERHOOK_SUPERSLOWLOOP SCHED_TASK(userhook_SuperSlowLoop, 1, 75), #endif + SCHED_TASK(button_update, 5, 100), }; diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index ea7f52729b..8b44988952 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -88,6 +88,7 @@ #include #include // Pilot input handling library #include // Heli specific pilot input handling library +#include // Configuration #include "defines.h" @@ -660,6 +661,7 @@ private: void send_rangefinder(mavlink_channel_t chan); void send_rpm(mavlink_channel_t chan); void rpm_update(); + void button_update(); void send_pid_tuning(mavlink_channel_t chan); void gcs_send_message(enum ap_message id); void gcs_send_mission_item_reached_message(uint16_t mission_index); diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 180a02f856..6e284651b0 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -966,6 +966,10 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Standard AP_GROUPINFO("WP_TKOFF_NAV_ALT", 1, ParametersG2, takeoff_nav_alt, 0), + // @Group: BTN_ + // @Path: ../libraries/AP_Button/AP_Button.cpp + AP_SUBGROUPINFO(button, "BTN_", 2, ParametersG2, AP_Button), + AP_GROUPEND }; diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index ce7ce14392..4f95c6e034 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -543,6 +543,9 @@ public: // altitude at which nav control can start in takeoff AP_Float takeoff_nav_alt; + + // button checking + AP_Button button; }; extern const AP_Param::Info var_info[]; diff --git a/ArduCopter/sensors.cpp b/ArduCopter/sensors.cpp index 07dedfabac..c33939f580 100644 --- a/ArduCopter/sensors.cpp +++ b/ArduCopter/sensors.cpp @@ -226,3 +226,11 @@ void Copter::epm_update() epm.update(); } #endif + +/* + update AP_Button + */ +void Copter::button_update(void) +{ + g2.button.update(); +}