From a496ef2b171716e51d114f1640dea0d03f3de773 Mon Sep 17 00:00:00 2001 From: jasonshort Date: Tue, 7 Sep 2010 05:43:08 +0000 Subject: [PATCH] don't fly git-svn-id: https://arducopter.googlecode.com/svn/trunk@427 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- .../RC/examples/AP_RC_test/AP_RC_test.pde | 2 +- libraries/Waypoints/Waypoints.cpp | 33 +++++++++++++++---- libraries/Waypoints/Waypoints.h | 17 ++++++---- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/libraries/RC/examples/AP_RC_test/AP_RC_test.pde b/libraries/RC/examples/AP_RC_test/AP_RC_test.pde index 1130908340..3b2b02c90c 100644 --- a/libraries/RC/examples/AP_RC_test/AP_RC_test.pde +++ b/libraries/RC/examples/AP_RC_test/AP_RC_test.pde @@ -6,7 +6,7 @@ (Works with last PPM_encoder firmware) */ -#include // ArduPilot Mega RC Library +#include // ArduPilot RC Library AP_RC rc; #define CH_ROLL 0 diff --git a/libraries/Waypoints/Waypoints.cpp b/libraries/Waypoints/Waypoints.cpp index c15055701c..edf64a6710 100644 --- a/libraries/Waypoints/Waypoints.cpp +++ b/libraries/Waypoints/Waypoints.cpp @@ -11,15 +11,12 @@ #include "Waypoints.h" -Waypoints::Waypoints(uint16_t start_byte, uint8_t wp_size, uint8_t total) +Waypoints::Waypoints() { - _start_byte = start_byte; - _wp_size = wp_size; - _total = total; } void -Waypoints::set_waypoint_with_index(Waypoints::WP wp, uint16_t i) +Waypoints::set_waypoint_with_index(Waypoints::WP wp, uint8_t i) { i = constrain(i, 0, _total); uint32_t mem = _start_byte + (i * _wp_size); @@ -45,7 +42,7 @@ Waypoints::set_waypoint_with_index(Waypoints::WP wp, uint16_t i) } Waypoints::WP -Waypoints::get_waypoint_with_index(uint16_t i) +Waypoints::get_waypoint_with_index(uint8_t i) { Waypoints::WP wp; @@ -79,6 +76,13 @@ Waypoints::get_next_waypoint(void) _index++; if (_index >= _total) _index == 0; + return get_waypoint_with_index(_index); +} + +Waypoints::WP +Waypoints::get_current_waypoint(void) +{ + return get_waypoint_with_index(_index); } uint8_t @@ -98,3 +102,20 @@ Waypoints::get_total(void) { return _total; } +void +Waypoints::set_total(uint8_t total) +{ + _total = total; +} + +void +Waypoints::set_start_byte(uint16_t start_byte) +{ + _start_byte = start_byte; +} + +void +Waypoints::set_wp_size(uint8_t wp_size) +{ + _wp_size = wp_size; +} diff --git a/libraries/Waypoints/Waypoints.h b/libraries/Waypoints/Waypoints.h index fb0ea5da3a..7fce5aec91 100644 --- a/libraries/Waypoints/Waypoints.h +++ b/libraries/Waypoints/Waypoints.h @@ -8,7 +8,7 @@ class Waypoints { public: - Waypoints(uint16_t start_byte, uint8_t wp_size, uint8_t total); + Waypoints(); struct WP { uint8_t id; // for commands @@ -17,16 +17,21 @@ class Waypoints int32_t lat; // Lattitude * 10**7 int32_t lng; // Longitude * 10**7 }; - - - Waypoints::WP get_waypoint_with_index(uint16_t i); - Waypoints::WP get_next_waypoint(void); - void set_waypoint_with_index(Waypoints::WP wp, uint16_t i); + WP get_waypoint_with_index(uint16_t i); + WP get_current_waypoint(void); + WP get_next_waypoint(void); + + void set_waypoint_with_index(Waypoints::WP wp, uint8_t i); + + void set_start_byte(uint16_t start_byte); + void set_wp_size(uint8_t wp_size); + uint8_t get_index(void); void set_index(uint8_t i); uint8_t get_total(void); + void set_total(uint8_t total);