Formatted code (#1007)

* Updated style

* Updated files

* fixed new line

* Updated spacing

* File fix WIP

* Updated to clang 13

* updated comment style

* Removed old comment code
This commit is contained in:
jLynx
2023-05-19 08:16:05 +12:00
committed by GitHub
parent 7aca7ce74d
commit 033c4e9a5b
599 changed files with 70746 additions and 66896 deletions

View File

@@ -33,43 +33,42 @@
#include <algorithm>
void TvCollector::on_message(const Message* const message) {
switch(message->id) {
case Message::ID::UpdateSpectrum:
update();
break;
switch (message->id) {
case Message::ID::UpdateSpectrum:
update();
break;
case Message::ID::SpectrumStreamingConfig:
set_state(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message));
break;
case Message::ID::SpectrumStreamingConfig:
set_state(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message));
break;
default:
break;
}
default:
break;
}
}
void TvCollector::set_state(const SpectrumStreamingConfigMessage& message) {
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
start();
} else {
stop();
}
if (message.mode == SpectrumStreamingConfigMessage::Mode::Running) {
start();
} else {
stop();
}
}
void TvCollector::start() {
streaming = true;
ChannelSpectrumConfigMessage message { &fifo };
shared_memory.application_queue.push(message);
streaming = true;
ChannelSpectrumConfigMessage message{&fifo};
shared_memory.application_queue.push(message);
}
void TvCollector::stop() {
streaming = false;
fifo.reset_in();
streaming = false;
fifo.reset_in();
}
void TvCollector::set_decimation_factor(
const size_t decimation_factor
) {
channel_spectrum_decimator.set_factor(decimation_factor);
const size_t decimation_factor) {
channel_spectrum_decimator.set_factor(decimation_factor);
}
/* TODO: Refactor to register task with idle thread?
@@ -78,43 +77,40 @@ void TvCollector::set_decimation_factor(
*/
void TvCollector::feed(
const buffer_c16_t& channel
) {
// Called from baseband processing thread.
channel_spectrum_decimator.feed(channel,[this](const buffer_c16_t& data) {this->post_message(data);});
const buffer_c16_t& channel) {
// Called from baseband processing thread.
channel_spectrum_decimator.feed(channel, [this](const buffer_c16_t& data) { this->post_message(data); });
}
void TvCollector::post_message(const buffer_c16_t& data) {
// Called from baseband processing thread.
float re, im;
float mag;
if( streaming && !channel_spectrum_request_update ) {
for(size_t i=0; i<256; i++)
{
re = (float)(data.p[i].real());
im = (float)(data.p[i].imag());
mag = __builtin_sqrtf((re * re) + (im * im)) ;
channel_spectrum[i] = {mag, mag};
}
channel_spectrum_sampling_rate = data.sampling_rate;
channel_spectrum_request_update = true;
EventDispatcher::events_flag(EVT_MASK_SPECTRUM);
}
// Called from baseband processing thread.
float re, im;
float mag;
if (streaming && !channel_spectrum_request_update) {
for (size_t i = 0; i < 256; i++) {
re = (float)(data.p[i].real());
im = (float)(data.p[i].imag());
mag = __builtin_sqrtf((re * re) + (im * im));
channel_spectrum[i] = {mag, mag};
}
channel_spectrum_sampling_rate = data.sampling_rate;
channel_spectrum_request_update = true;
EventDispatcher::events_flag(EVT_MASK_SPECTRUM);
}
}
void TvCollector::update() {
// Called from idle thread (after EVT_MASK_SPECTRUM is flagged)
if( streaming && channel_spectrum_request_update ) {
ChannelSpectrum spectrum;
spectrum.sampling_rate = channel_spectrum_sampling_rate;
for(size_t i=0; i<spectrum.db.size(); i++) {
const auto corrected_sample = channel_spectrum[i].real();
const unsigned int v = corrected_sample + 127.0f;
spectrum.db[i] = std::max(0U, std::min(255U, v));
}
fifo.in(spectrum);
}
// Called from idle thread (after EVT_MASK_SPECTRUM is flagged)
if (streaming && channel_spectrum_request_update) {
ChannelSpectrum spectrum;
spectrum.sampling_rate = channel_spectrum_sampling_rate;
for (size_t i = 0; i < spectrum.db.size(); i++) {
const auto corrected_sample = channel_spectrum[i].real();
const unsigned int v = corrected_sample + 127.0f;
spectrum.db[i] = std::max(0U, std::min(255U, v));
}
fifo.in(spectrum);
}
channel_spectrum_request_update = false;
channel_spectrum_request_update = false;
}