From be42e5330336884507bd8d037abd490965f2c741 Mon Sep 17 00:00:00 2001 From: Tom Pittenger Date: Tue, 6 Sep 2022 11:36:14 -0700 Subject: [PATCH] Sub: use new AP_TemperatureSensor library Co-authored-by: Joshua Henderson --- ArduSub/GCS_Mavlink.cpp | 7 +++++-- ArduSub/Sub.h | 3 --- ArduSub/system.cpp | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ArduSub/GCS_Mavlink.cpp b/ArduSub/GCS_Mavlink.cpp index 53a7f87a10..7468f73eae 100644 --- a/ArduSub/GCS_Mavlink.cpp +++ b/ArduSub/GCS_Mavlink.cpp @@ -96,7 +96,9 @@ int16_t GCS_MAVLINK_Sub::vfr_hud_throttle() const // Work around to get temperature sensor data out void GCS_MAVLINK_Sub::send_scaled_pressure3() { - if (!sub.celsius.healthy()) { +#if AP_TEMPERATURE_SENSOR_ENABLED + float temperature; + if (!sub.temperature_sensor.temperature(temperature)) { return; } mavlink_msg_scaled_pressure3_send( @@ -104,8 +106,9 @@ void GCS_MAVLINK_Sub::send_scaled_pressure3() AP_HAL::millis(), 0, 0, - sub.celsius.temperature() * 100, + temperature * 100, 0); // TODO: use differential pressure temperature +#endif } bool GCS_MAVLINK_Sub::send_info() diff --git a/ArduSub/Sub.h b/ArduSub/Sub.h index e2fed1afee..2f669b72e5 100644 --- a/ArduSub/Sub.h +++ b/ArduSub/Sub.h @@ -62,7 +62,6 @@ #include #include // Joystick/gamepad button function assignment #include // Leak detector -#include #include // Local modules @@ -138,8 +137,6 @@ private: AP_LeakDetector leak_detector; - TSYS01 celsius; - struct { bool enabled:1; bool alt_healthy:1; // true if we can trust the altitude from the rangefinder diff --git a/ArduSub/system.cpp b/ArduSub/system.cpp index 7743b1179a..f3639b96ca 100644 --- a/ArduSub/system.cpp +++ b/ArduSub/system.cpp @@ -48,7 +48,11 @@ void Sub::init_ardupilot() #elif CONFIG_HAL_BOARD != HAL_BOARD_LINUX AP_Param::set_default_by_name("BARO_EXT_BUS", 1); #endif - celsius.init(barometer.external_bus()); + +#if AP_TEMPERATURE_SENSOR_ENABLED + // In order to preserve Sub's previous AP_TemperatureSensor Behavior we set the Default I2C Bus Here + AP_Param::set_default_by_name("TEMP1_BUS", barometer.external_bus()); +#endif // setup telem slots with serial ports gcs().setup_uarts();