From owner-svn-src-user@FreeBSD.ORG Sat Jun 23 21:03:51 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3F5DF106564A; Sat, 23 Jun 2012 21:03:51 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 29D348FC08; Sat, 23 Jun 2012 21:03:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5NL3p4T064621; Sat, 23 Jun 2012 21:03:51 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5NL3oXr064618; Sat, 23 Jun 2012 21:03:50 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206232103.q5NL3oXr064618@svn.freebsd.org> From: Adrian Chadd Date: Sat, 23 Jun 2012 21:03:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237510 - user/adrian/ath_radar_stuff/src/qt-hpktlog X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 21:03:51 -0000 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 #include +#include #include #include @@ -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 q_dur; std::vector q_rssi; + + // and the new-style histogram data QVector 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.