From b7c2b56a6657d6e36ac021c8bf12c7cb7478959e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sun, 20 Jun 2021 09:54:22 +1000 Subject: [PATCH] AP_Motors: tidy frame description strings Before: AP: Frame: TRI/ After: AP: Frame: TRI --- libraries/AP_Motors/AP_Motors_Class.cpp | 11 +++++++++++ libraries/AP_Motors/AP_Motors_Class.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/libraries/AP_Motors/AP_Motors_Class.cpp b/libraries/AP_Motors/AP_Motors_Class.cpp index 9a689a6e56..1c9662b865 100644 --- a/libraries/AP_Motors/AP_Motors_Class.cpp +++ b/libraries/AP_Motors/AP_Motors_Class.cpp @@ -48,6 +48,17 @@ AP_Motors::AP_Motors(uint16_t loop_rate, uint16_t speed_hz) : _thrust_balanced = true; }; +void AP_Motors::get_frame_and_type_string(char *buffer, uint8_t buflen) const +{ + const char *frame_str = get_frame_string(); + const char *type_str = get_type_string(); + if (type_str != nullptr && strlen(type_str)) { + hal.util->snprintf(buffer, buflen, "Frame: %s/%s", frame_str, type_str); + } else { + hal.util->snprintf(buffer, buflen, "Frame: %s", frame_str); + } +} + void AP_Motors::armed(bool arm) { if (_armed != arm) { diff --git a/libraries/AP_Motors/AP_Motors_Class.h b/libraries/AP_Motors/AP_Motors_Class.h index c6204563cc..81a77df2a5 100644 --- a/libraries/AP_Motors/AP_Motors_Class.h +++ b/libraries/AP_Motors/AP_Motors_Class.h @@ -74,6 +74,9 @@ public: // return string corresponding to frame_type virtual const char* get_type_string() const { return ""; } + // returns a formatted string into buffer, e.g. "QUAD/X" + void get_frame_and_type_string(char *buffer, uint8_t buflen) const; + // Constructor AP_Motors(uint16_t loop_rate, uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT);