From abb91fc33a527f3929c1aac47278196bcc3e1e97 Mon Sep 17 00:00:00 2001 From: murata Date: Sun, 6 Oct 2019 22:59:15 +0900 Subject: [PATCH] Copter: Change external button specification to option Copter: Change the definition name from BUTTON to BUTTON_ENABLED. --- ArduCopter/APM_Config.h | 1 + ArduCopter/Copter.cpp | 2 ++ ArduCopter/Copter.h | 9 ++++++++- ArduCopter/Parameters.cpp | 2 ++ ArduCopter/Parameters.h | 2 ++ ArduCopter/config.h | 6 ++++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ArduCopter/APM_Config.h b/ArduCopter/APM_Config.h index a266a28625..90f6bbca19 100644 --- a/ArduCopter/APM_Config.h +++ b/ArduCopter/APM_Config.h @@ -46,6 +46,7 @@ //#define MODE_THROW_ENABLED DISABLED // disable throw mode support //#define MODE_ZIGZAG_ENABLED DISABLED // disable zigzag mode support //#define OSD_ENABLED DISABLED // disable on-screen-display support +//#define BUTTON_ENABLED DISABLED // disable button support // features below are disabled by default on all boards diff --git a/ArduCopter/Copter.cpp b/ArduCopter/Copter.cpp index a939d9f7ec..15f42efb58 100644 --- a/ArduCopter/Copter.cpp +++ b/ArduCopter/Copter.cpp @@ -196,7 +196,9 @@ const AP_Scheduler::Task Copter::scheduler_tasks[] = { #ifdef USERHOOK_SUPERSLOWLOOP SCHED_TASK(userhook_SuperSlowLoop, 1, 75), #endif +#if BUTTON_ENABLED == ENABLED SCHED_TASK_CLASS(AP_Button, &copter.g2.button, update, 5, 100), +#endif #if STATS_ENABLED == ENABLED SCHED_TASK_CLASS(AP_Stats, &copter.g2.stats, update, 1, 100), #endif diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index 6e3bd67c44..3212d6ce62 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -72,7 +72,6 @@ #include // Landing Gear library #include // Pilot input handling library #include // Heli specific pilot input handling library -#include #include #include #include @@ -156,6 +155,9 @@ #if CAMERA == ENABLED # include #endif +#if BUTTON_ENABLED == ENABLED + # include +#endif #if OSD_ENABLED == ENABLED #include @@ -553,6 +555,11 @@ private: AP_Parachute parachute{relay}; #endif + // Button +#if BUTTON_ENABLED == ENABLED + AP_Button button; +#endif + // Landing Gear Controller AP_LandingGear landinggear; diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index c1adfd022d..ceeec1c772 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -732,9 +732,11 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Standard AP_GROUPINFO("WP_NAVALT_MIN", 1, ParametersG2, wp_navalt_min, 0), +#if BUTTON_ENABLED == ENABLED // @Group: BTN_ // @Path: ../libraries/AP_Button/AP_Button.cpp AP_SUBGROUPINFO(button, "BTN_", 2, ParametersG2, AP_Button), +#endif #if MODE_THROW_ENABLED == ENABLED // @Param: THROW_NEXTMODE diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index 5164863e02..77aa9c46e9 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -485,8 +485,10 @@ public: // altitude at which nav control can start in takeoff AP_Float wp_navalt_min; +#if BUTTON_ENABLED == ENABLED // button checking AP_Button button; +#endif #if STATS_ENABLED == ENABLED // vehicle statistics diff --git a/ArduCopter/config.h b/ArduCopter/config.h index 84e4b70bb7..3daea4dc8b 100644 --- a/ArduCopter/config.h +++ b/ArduCopter/config.h @@ -371,6 +371,12 @@ # define BEACON_ENABLED !HAL_MINIMIZE_FEATURES #endif +////////////////////////////////////////////////////////////////////////////// +// Button - Enable the button connected to AUX1-6 +#ifndef BUTTON_ENABLED + # define BUTTON_ENABLED ENABLED +#endif + ////////////////////////////////////////////////////////////////////////////// // RADIO CONFIGURATION //////////////////////////////////////////////////////////////////////////////