ChannelSpectrumConfig message subsumes FIFONotify.

Separate channel spectrum config from spectrum data. This will permit sending config info only when necessary.
Use type information of ChannelSpectrum to statically define number of FFT bins elsewhere.
TODO: Posting configuration message way too often. Fixing that is the next step.
This commit is contained in:
Jared Boone 2016-01-06 12:10:30 -08:00
parent ba33cc737d
commit 7710b2d1fa
5 changed files with 49 additions and 42 deletions

View file

@ -48,6 +48,7 @@ void SpectrumCollector::feed(
// Called from baseband processing thread.
channel_filter_pass_frequency = filter_pass_frequency;
channel_filter_stop_frequency = filter_stop_frequency;
post_configuration_message();
channel_spectrum_decimator.feed(
channel,
[this](const buffer_c16_t& data) {
@ -66,6 +67,16 @@ void SpectrumCollector::post_message(const buffer_c16_t& data) {
}
}
void SpectrumCollector::post_configuration_message() {
ChannelSpectrumConfigMessage message {
channel_spectrum_sampling_rate,
channel_filter_pass_frequency,
channel_filter_stop_frequency,
&fifo
};
shared_memory.application_queue.push(message);
}
void SpectrumCollector::update() {
// Called from idle thread (after EVT_MASK_SPECTRUM is flagged)
if( channel_spectrum_request_update ) {
@ -85,13 +96,6 @@ void SpectrumCollector::update() {
spectrum.db[i] = std::max(0U, std::min(255U, v));
}
/* TODO: Rename .db -> .magnitude, or something more (less!) accurate. */
spectrum.db_count = spectrum.db.size();
spectrum.sampling_rate = channel_spectrum_sampling_rate;
spectrum.channel_filter_pass_frequency = channel_filter_pass_frequency;
spectrum.channel_filter_stop_frequency = channel_filter_stop_frequency;
fifo.in(spectrum);
FIFONotifyMessage message { &fifo };
shared_memory.application_queue.push(message);
}
}