From 14efc602a7724bd767c68e5edbce8eeb1b19c47b Mon Sep 17 00:00:00 2001 From: tstellanova Date: Mon, 22 Jul 2013 15:44:32 -0700 Subject: [PATCH] show full flight mode status --- src/uas/UAS.cc | 60 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 3076f3292..9b1556426 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -3325,45 +3325,55 @@ QString UAS::getAudioModeTextFor(int id) return mode; } +/** +* The mode returned can be auto, stabilized, test, manual, preflight or unknown. +* @return the short text of the mode for the id given. +*/ /** * The mode returned can be auto, stabilized, test, manual, preflight or unknown. * @return the short text of the mode for the id given. */ QString UAS::getShortModeTextFor(int id) { - QString mode; + QString mode = ""; uint8_t modeid = id; - qDebug() << "MODE:" << modeid; // BASE MODE DECODING - if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_AUTO) - { - mode += "|AUTO"; - } - else if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_GUIDED) - { - mode += "|VECTOR"; - } - if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_STABILIZE) - { - mode += "|STABILIZED"; - } - else if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_TEST) - { - mode += "|TEST"; - } - else if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_MANUAL) - { - mode += "|MANUAL"; - } - else if (modeid == 0) + + if (modeid == 0) { mode = "|PREFLIGHT"; } - else + else { + if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_AUTO){ + mode += "|AUTO"; + } + + if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_MANUAL){ + mode += "|MANUAL"; + } + + if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_GUIDED){ + mode += "|VECTOR"; + } + + if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_STABILIZE){ + mode += "|STABILIZED"; + } + + + if (modeid & (uint8_t)MAV_MODE_FLAG_DECODE_POSITION_TEST){ + mode += "|TEST"; + } + + + } + + if (mode.length() == 0) { mode = "|UNKNOWN"; + qDebug() << __FILE__ << __LINE__ << " Unknown modeid: " << modeid; } // ARMED STATE DECODING @@ -3382,6 +3392,8 @@ QString UAS::getShortModeTextFor(int id) mode.prepend("HIL:"); } + qDebug() << "MODE: " << modeid << " " << mode; + return mode; } -- 2.22.0