From fd0f31dc4489e526a990a1954d87485803a6332f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Jul 2016 11:24:35 +1000 Subject: [PATCH] Rover: added AP_Button support --- APMrover2/APMrover2.cpp | 1 + APMrover2/Parameters.cpp | 4 ++++ APMrover2/Parameters.h | 1 + APMrover2/Rover.h | 3 +++ APMrover2/sensors.cpp | 8 ++++++++ 5 files changed, 17 insertions(+) diff --git a/APMrover2/APMrover2.cpp b/APMrover2/APMrover2.cpp index 5d12389850..1546e440fd 100644 --- a/APMrover2/APMrover2.cpp +++ b/APMrover2/APMrover2.cpp @@ -79,6 +79,7 @@ const AP_Scheduler::Task Rover::scheduler_tasks[] = { SCHED_TASK(frsky_telemetry_send, 5, 100), #endif SCHED_TASK(dataflash_periodic, 50, 300), + SCHED_TASK(button_update, 5, 100), }; /* diff --git a/APMrover2/Parameters.cpp b/APMrover2/Parameters.cpp index f659598e57..4bbcb3857a 100644 --- a/APMrover2/Parameters.cpp +++ b/APMrover2/Parameters.cpp @@ -552,6 +552,10 @@ const AP_Param::Info Rover::var_info[] = { // @Path: ../libraries/AP_Notify/AP_Notify.cpp GOBJECT(notify, "NTF_", AP_Notify), + // @Group: BTN_ + // @Path: ../libraries/AP_Button/AP_Button.cpp + GOBJECT(button, "BTN_", AP_Button), + AP_VAREND }; diff --git a/APMrover2/Parameters.h b/APMrover2/Parameters.h index 224592cd21..4c61d1080c 100644 --- a/APMrover2/Parameters.h +++ b/APMrover2/Parameters.h @@ -195,6 +195,7 @@ public: k_param_steerController, k_param_barometer, k_param_notify, + k_param_button, k_param_DataFlash = 253, // Logging Group diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index 6b10ce9ef2..80ea3d15d6 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -72,6 +72,7 @@ #include // Battery monitor library #include // Optical Flow library #include // RSSI Library +#include // Configuration #include "config.h" @@ -134,6 +135,7 @@ private: Compass compass; AP_InertialSensor ins; RangeFinder sonar { serial_manager }; + AP_Button button; // flight modes convenience array AP_Int8 *modes; @@ -454,6 +456,7 @@ private: void reset_control_switch(); void read_trim_switch(); void update_events(void); + void button_update(void); void navigate(); void set_control_channels(void); void init_rc_in(); diff --git a/APMrover2/sensors.cpp b/APMrover2/sensors.cpp index cb90bee5be..8110ab32b1 100644 --- a/APMrover2/sensors.cpp +++ b/APMrover2/sensors.cpp @@ -119,3 +119,11 @@ void Rover::read_sonars(void) obstacle.turn_angle = 0; } } + +/* + update AP_Button + */ +void Rover::button_update(void) +{ + button.update(); +}