From 4fb607a826bd3702f0dbad317054638c8dc22904 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 22 Jan 2015 23:38:21 +0000 Subject: [PATCH] Noise floor measurement is too expensive to be worth it, disable it. --- demod_2400.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/demod_2400.c b/demod_2400.c index ab78c92..b25f32b 100644 --- a/demod_2400.c +++ b/demod_2400.c @@ -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 }