From e9ecc11b00fac8d20b8c412a15a20b308162ff7d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 6 Mar 2018 07:36:45 +1100 Subject: [PATCH] GCS_MAVLink: use baro singleton --- libraries/GCS_MAVLink/GCS.h | 4 ++-- libraries/GCS_MAVLink/GCS_Common.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 836c1e25d4..1b2ddb6f1a 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -164,8 +164,8 @@ public: void send_system_time(); void send_radio_in(uint8_t receiver_rssi); void send_raw_imu(const AP_InertialSensor &ins, const Compass &compass); - void send_scaled_pressure(AP_Baro &barometer); - void send_sensor_offsets(const AP_InertialSensor &ins, const Compass &compass, AP_Baro &barometer); + void send_scaled_pressure(); + void send_sensor_offsets(const AP_InertialSensor &ins, const Compass &compass); void send_ahrs(); void send_battery2(const AP_BattMonitor &battery); #if AP_AHRS_NAVEKF_AVAILABLE diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 97a5edb13b..4a62a65d1f 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -1064,9 +1064,10 @@ void GCS_MAVLINK::send_raw_imu(const AP_InertialSensor &ins, const Compass &comp mag.z); } -void GCS_MAVLINK::send_scaled_pressure(AP_Baro &barometer) +void GCS_MAVLINK::send_scaled_pressure() { uint32_t now = AP_HAL::millis(); + const AP_Baro &barometer = AP::baro(); float pressure = barometer.get_pressure(0); mavlink_msg_scaled_pressure_send( chan, @@ -1098,7 +1099,7 @@ void GCS_MAVLINK::send_scaled_pressure(AP_Baro &barometer) } } -void GCS_MAVLINK::send_sensor_offsets(const AP_InertialSensor &ins, const Compass &compass, AP_Baro &barometer) +void GCS_MAVLINK::send_sensor_offsets(const AP_InertialSensor &ins, const Compass &compass) { // run this message at a much lower rate - otherwise it // pointlessly wastes quite a lot of bandwidth @@ -1112,6 +1113,8 @@ void GCS_MAVLINK::send_sensor_offsets(const AP_InertialSensor &ins, const Compas const Vector3f &accel_offsets = ins.get_accel_offsets(0); const Vector3f &gyro_offsets = ins.get_gyro_offsets(0); + const AP_Baro &barometer = AP::baro(); + mavlink_msg_sensor_offsets_send(chan, mag_offsets.x, mag_offsets.y,