aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/radioVector.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-10-17 21:23:34 -0400
committerThomas Tsou <tom@tsou.cc>2013-10-18 13:10:18 -0400
commitfa3a787ccbb250d929ebf78993047dd05e8765cb (patch)
tree4f14ca9fd9b87824ada664593cc24a70eadc1c54 /Transceiver52M/radioVector.cpp
parent010fff783bf658e79b0b32ad64a44af4e3f22b1e (diff)
Transceiver52M: Update noise measurement calculation
Previous removal of the energy detector requirement broke the noise level calculation loop. The previous adaptive approach was finicky - noticably at high gain levels. Since we no longer use the energy threshold for primary burst gating, we can return to a simpler world. In the new approach, we compute a running average of energy levels and track them with a noise vector. A timeslot that passes the correlator threshold is a valid burst. These are not used in the noise calculation. Everything else is considered noise and used to compute the noise level with respect to full scale input level, which for almost all supported devices is 2^15. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/radioVector.cpp')
-rw-r--r--Transceiver52M/radioVector.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/Transceiver52M/radioVector.cpp b/Transceiver52M/radioVector.cpp
index f20d97a..043effa 100644
--- a/Transceiver52M/radioVector.cpp
+++ b/Transceiver52M/radioVector.cpp
@@ -41,6 +41,35 @@ bool radioVector::operator>(const radioVector& other) const
return mTime > other.mTime;
}
+noiseVector::noiseVector(size_t n)
+{
+ this->resize(n);
+ it = this->begin();
+}
+
+float noiseVector::avg()
+{
+ float val = 0.0;
+
+ for (int i = 0; i < size(); i++)
+ val += (*this)[i];
+
+ return val / (float) size();
+}
+
+bool noiseVector::insert(float val)
+{
+ if (!size())
+ return false;
+
+ if (it == this->end())
+ it = this->begin();
+
+ *it++ = val;
+
+ return true;
+}
+
unsigned VectorFIFO::size()
{
return mQ.size();