From 9023e6eb7d84cc6973967b13dcefcb1ca044d1b7 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 12 Feb 2019 18:39:45 +1100 Subject: [PATCH] AP_Frsky_Telem: use rangefinder singleton --- libraries/AP_Frsky_Telem/AP_Frsky_Telem.cpp | 9 +++------ libraries/AP_Frsky_Telem/AP_Frsky_Telem.h | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libraries/AP_Frsky_Telem/AP_Frsky_Telem.cpp b/libraries/AP_Frsky_Telem/AP_Frsky_Telem.cpp index 2504b0ad8e..bc0f9d3f82 100644 --- a/libraries/AP_Frsky_Telem/AP_Frsky_Telem.cpp +++ b/libraries/AP_Frsky_Telem/AP_Frsky_Telem.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -33,11 +34,6 @@ extern const AP_HAL::HAL& hal; ObjectArray AP_Frsky_Telem::_statustext_queue(FRSKY_TELEM_PAYLOAD_STATUS_CAPACITY); -//constructor -AP_Frsky_Telem::AP_Frsky_Telem(const RangeFinder &rng) : - _rng(rng) - {} - /* * init - perform required initialisation */ @@ -785,6 +781,7 @@ uint32_t AP_Frsky_Telem::calc_velandyaw(void) uint32_t AP_Frsky_Telem::calc_attiandrng(void) { const AP_AHRS &_ahrs = AP::ahrs(); + const RangeFinder *_rng = RangeFinder::get_singleton(); uint32_t attiandrng; @@ -793,7 +790,7 @@ uint32_t AP_Frsky_Telem::calc_attiandrng(void) // pitch from [-9000;9000] centidegrees to unsigned .2 degree increments [0;900] (just in case, limit to 1023 (0x3FF) since the value is stored on 10 bits) attiandrng |= ((uint16_t)roundf((_ahrs.pitch_sensor + 9000) * 0.05f) & ATTIANDRNG_PITCH_LIMIT)<distance_cm_orient(ROTATION_PITCH_270) : 0, 3, 1)< #include -#include #include #include @@ -114,7 +113,7 @@ for FrSky SPort Passthrough class AP_Frsky_Telem { public: - AP_Frsky_Telem(const RangeFinder &rng); + AP_Frsky_Telem() {} /* Do not allow copies */ AP_Frsky_Telem(const AP_Frsky_Telem &other) = delete; @@ -146,7 +145,6 @@ public: void set_frame_string(const char *string) { _frame_string = string; } private: - const RangeFinder &_rng; AP_HAL::UARTDriver *_port; // UART used to send data to FrSky receiver AP_SerialManager::SerialProtocol _protocol; // protocol used - detected using SerialManager's SERIAL#_PROTOCOL parameter bool _initialised_uart;