From b0e764ad4ee1b2d4bb217149d3b6472f0a773ec4 Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Thu, 2 Jul 2015 01:26:06 -0400 Subject: [PATCH] Low pass filter on RC RSSI --- src/ui/toolbar/MainToolBar.cc | 13 ++++++++++--- src/ui/toolbar/MainToolBar.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc index 390634fd5..73e7a48c1 100644 --- a/src/ui/toolbar/MainToolBar.cc +++ b/src/ui/toolbar/MainToolBar.cc @@ -52,6 +52,7 @@ MainToolBar::MainToolBar(QWidget* parent) , _showBattery(true) , _progressBarValue(0.0f) , _remoteRSSI(0) + , _remoteRSSIstore(100.0) , _telemetryRRSSI(0) , _telemetryLRSSI(0) , _rollDownMessages(0) @@ -328,10 +329,16 @@ void MainToolBar::_telemetryChanged(LinkInterface*, unsigned, unsigned, unsigned void MainToolBar::_remoteControlRSSIChanged(uint8_t rssi) { - // We only care if we haveone single connection + // We only care if we have one single connection if(_connectionCount == 1) { - if(_remoteRSSI != rssi) { - _remoteRSSI = rssi; + // Low pass to git rid of jitter + _remoteRSSIstore = (_remoteRSSIstore * 0.9f) + ((float)rssi * 0.1); + uint8_t filteredRSSI = (uint8_t)ceil(_remoteRSSIstore); + if(_remoteRSSIstore < 0.1) { + filteredRSSI = 0; + } + if(_remoteRSSI != filteredRSSI) { + _remoteRSSI = filteredRSSI; emit remoteRSSIChanged(_remoteRSSI); } } diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h index 58f0210a0..94bf57af4 100644 --- a/src/ui/toolbar/MainToolBar.h +++ b/src/ui/toolbar/MainToolBar.h @@ -134,6 +134,7 @@ private: bool _showBattery; float _progressBarValue; int _remoteRSSI; + double _remoteRSSIstore; int _telemetryRRSSI; int _telemetryLRSSI; -- 2.22.0