svn commit: r237510 - user/adrian/ath_radar_stuff/src/qt-hpktlog
Adrian Chadd
adrian at FreeBSD.org
Sat Jun 23 21:03:51 UTC 2012
Author: adrian
Date: Sat Jun 23 21:03:50 2012
New Revision: 237510
URL: http://svn.freebsd.org/changeset/base/237510
Log:
Implement a very basic, hacky heat map.
It's totally inefficient - I'm still plotting all the points even if
all the samples are acutally at the same point. I'll fix this soon.
Modified:
user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp
user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h
Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp Sat Jun 23 20:44:45 2012 (r237509)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp Sat Jun 23 21:03:50 2012 (r237510)
@@ -14,6 +14,13 @@
MainApp::MainApp(QMainWindow *parent)
{
+ // Blank the heat map
+ for (int i = 0; i < MAX_RSSI; i++) {
+ for (int j = 0; j < MAX_PULSEDUR; j++) {
+ heat_map[i][j] = 0;
+ }
+ }
+
// How many entries to keep in the FIFO
num_entries = 128;
@@ -73,22 +80,33 @@ MainApp::getRadarEntry(struct radar_entr
q_dur.insert(q_dur.begin(), (float) re.re_dur);
q_rssi.insert(q_rssi.begin(), (float) re.re_rssi);
+
+ // Update the heat map for the current pixel, topping out at 65535
+ // entries (ie, don't overflow.)
+ if (heat_map[re.re_rssi % MAX_RSSI][re.re_dur % MAX_PULSEDUR] < MAX_HEATCNT)
+ heat_map[re.re_rssi % MAX_RSSI][re.re_dur % MAX_PULSEDUR]++;
+
q_points.insert(q_points.begin(),
QwtPoint3D(
(float) re.re_dur,
(float) re.re_rssi,
- (float) re.re_rssi * 25.0));
+ (float) heat_map[re.re_rssi % MAX_RSSI][re.re_dur % MAX_PULSEDUR] * 100.0));
// If we're too big, delete the first entry
if (q_points.size() > num_entries) {
+ // Decrement the heat map entry!
+ uint8_t rssi, dur;
+ rssi = q_rssi[q_rssi.size() - 1];
+ dur = q_dur[q_dur.size() - 1];
+ if (heat_map[rssi % MAX_RSSI][dur % MAX_PULSEDUR] > 0)
+ heat_map[rssi % MAX_RSSI][dur % MAX_PULSEDUR]--;
+
+ // Remove the tail entry
q_dur.pop_back();
q_rssi.pop_back();
q_points.pop_back();
}
- // Trim the head entries if the array is too big
- // (maybe we should use a queue, not a vector?)
-
// Replot!
RePlot();
}
Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h
==============================================================================
--- user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h Sat Jun 23 20:44:45 2012 (r237509)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h Sat Jun 23 21:03:50 2012 (r237510)
@@ -4,6 +4,7 @@
#include <vector>
#include <pcap.h>
+#include <sys/types.h>
#include <QtCore/QObject>
#include <QtGui/QMainWindow>
@@ -18,6 +19,10 @@
#include "libradarpkt/pkt.h"
+#define MAX_RSSI 256
+#define MAX_PULSEDUR 256
+#define MAX_HEATCNT 254
+
class MainApp : public QMainWindow
{
Q_OBJECT
@@ -32,11 +37,17 @@ class MainApp : public QMainWindow
// How many entries to keep in the histogram
size_t num_entries;
- // Our histogram data
+ // Our old-style histogram data
std::vector<double> q_dur;
std::vector<double> q_rssi;
+
+ // and the new-style histogram data
QVector<QwtPoint3D> q_points;
+ // Now, an array of items, for "heat" data
+ // XXX this really should be another class..
+ uint8_t heat_map[MAX_RSSI][MAX_PULSEDUR];
+
// TODO When rendering the screen, we only want to do it
// every say, 3ms.
More information about the svn-src-user
mailing list