Commit e200d622 authored by Gus Grubba's avatar Gus Grubba

Properly handle (unavailable) RX RSSI

parent ef519e92
......@@ -130,7 +130,7 @@ Item {
property bool _hideEmergenyStop: !QGroundControl.corePlugin.options.guidedBarShowEmergencyStop
property bool _hideOrbit: !QGroundControl.corePlugin.options.guidedBarShowOrbit
property bool _vehicleWasFlying: false
property bool _rcRSSIAvailable: _activeVehicle ? _activeVehicle.rcRSSI > 0 && _activeVehicle.rcRSSI < 255 : false
property bool _rcRSSIAvailable: _activeVehicle ? _activeVehicle.rcRSSI > 0 && _activeVehicle.rcRSSI <= 100 : false
//Handy code for debugging state problems
property bool __debugGuidedStates: false
......
......@@ -110,7 +110,7 @@ Vehicle::Vehicle(LinkInterface* link,
, _currentMessageType(MessageNone)
, _updateCount(0)
, _rcRSSI(255)
, _rcRSSIstore(255)
, _rcRSSIstore(255.)
, _autoDisconnect(false)
, _flying(false)
, _landing(false)
......@@ -303,7 +303,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
, _currentMessageType(MessageNone)
, _updateCount(0)
, _rcRSSI(255)
, _rcRSSIstore(255)
, _rcRSSIstore(255.)
, _autoDisconnect(false)
, _flying(false)
, _landing(false)
......@@ -2447,10 +2447,18 @@ void Vehicle::_imageReady(UASInterface*)
void Vehicle::_remoteControlRSSIChanged(uint8_t rssi)
{
if (_rcRSSIstore < 0 || _rcRSSIstore > 100) {
_rcRSSIstore = rssi;
//-- 0 <= rssi <= 100 - 255 means "invalid/unknown"
if(rssi > 100) { // Anything over 100 doesn't make sense
if(_rcRSSI != 255) {
_rcRSSI = 255;
emit rcRSSIChanged(_rcRSSI);
}
return;
}
//-- Initialize it
if(_rcRSSIstore == 255.) {
_rcRSSIstore = (double)rssi;
}
// Low pass to git rid of jitter
_rcRSSIstore = (_rcRSSIstore * 0.9f) + ((float)rssi * 0.1);
uint8_t filteredRSSI = (uint8_t)ceil(_rcRSSIstore);
......
......@@ -26,7 +26,8 @@ Item {
anchors.bottom: parent.bottom
visible: _activeVehicle ? _activeVehicle.supportsRadio : true
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _rcRSSIAvailable: _activeVehicle ? _activeVehicle.rcRSSI > 0 && _activeVehicle.rcRSSI <= 100 : false
Component {
id: rcRSSIInfo
......@@ -54,7 +55,7 @@ Item {
GridLayout {
id: rcrssiGrid
visible: _activeVehicle && _activeVehicle.rcRSSI != 255
visible: _rcRSSIAvailable
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
columns: 2
......@@ -86,14 +87,14 @@ Item {
sourceSize.height: height
source: "/qmlimages/RC.svg"
fillMode: Image.PreserveAspectFit
opacity: _activeVehicle ? (((_activeVehicle.rcRSSI < 0) || (_activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5
opacity: _rcRSSIAvailable ? 1 : 0.5
color: qgcPal.buttonText
}
SignalStrength {
anchors.verticalCenter: parent.verticalCenter
size: parent.height * 0.5
percent: _activeVehicle ? ((_activeVehicle.rcRSSI > 100) ? 0 : _activeVehicle.rcRSSI) : 0
percent: _rcRSSIAvailable ? _activeVehicle.rcRSSI : 0
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment