Noise floor measurement is too expensive to be worth it, disable it.

This commit is contained in:
Oliver Jowett 2015-01-22 23:38:21 +00:00
parent dc8891e0ba
commit 4fb607a826

View file

@ -19,6 +19,12 @@
#include "dump1090.h"
//
// Measuring the noise power is actually surprisingly expensive on an ARM -
// it increases the CPU use of the demodulator by 1/3. So it's off by default.
// You can turn it back on here:
#undef MEASURE_NOISE
// 2.4MHz sampling rate version
//
// When sampling at 2.4MHz we have exactly 6 samples per 5 symbols.
@ -153,14 +159,18 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
struct modesMessage mm;
unsigned char msg1[MODES_LONG_MSG_BYTES], msg2[MODES_LONG_MSG_BYTES], *msg;
uint32_t j;
#ifdef MEASURE_NOISE
uint32_t last_message_end = 0;
#endif
unsigned char *bestmsg;
int bestscore, bestphase;
#ifdef MEASURE_NOISE
// noise floor:
uint32_t noise_power_count = 0;
uint64_t noise_power_sum = 0;
#endif
memset(&mm, 0, sizeof(mm));
msg = msg1;
@ -172,6 +182,7 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
int initial_phase, first_phase, last_phase, try_phase;
int msglen;
#ifdef MEASURE_NOISE
// update noise for all samples that aren't part of a message
// (we don't know if m[j] is or not, yet, so work one sample
// in arrears)
@ -182,6 +193,7 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
noise_power_sum += s * s;
noise_power_count++;
}
#endif
// Look for a message starting at around sample 0 with phase offset 3..7
@ -462,14 +474,18 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
// where the preamble of the second message clobbered the last
// few bits of the first message, but the message bits didn't
// overlap)
#ifdef MEASURE_NOISE
last_message_end = j + (8 + msglen)*12/5;
#endif
j += (8 + msglen - 8)*12/5 - 1;
// Pass data to the next layer
useModesMessage(&mm);
}
#ifdef MEASURE_NOISE
Modes.stats_current.noise_power_sum += (noise_power_sum / MAX_POWER / noise_power_count);
Modes.stats_current.noise_power_count ++;
#endif
}