mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-13 08:55:39 -04:00
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:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -32,118 +32,116 @@ using namespace acars;
|
|||
#include "utility.hpp"
|
||||
|
||||
void ACARSLogger::log_raw_data(const acars::Packet& packet, const uint32_t frequency) {
|
||||
(void)frequency;
|
||||
std::string entry { }; //= "Raw: F:" + to_string_dec_uint(frequency) + "Hz ";
|
||||
entry.reserve(256);
|
||||
|
||||
// Raw hex dump of all the bytes
|
||||
//for (size_t c = 0; c < packet.length(); c += 32)
|
||||
// entry += to_string_hex(packet.read(c, 32), 8) + " ";
|
||||
|
||||
for (size_t c = 0; c < 256; c += 32)
|
||||
entry += to_string_bin(packet.read(c, 32), 32);
|
||||
|
||||
log_file.write_entry(packet.received_at(), entry);
|
||||
(void)frequency;
|
||||
std::string entry{}; //= "Raw: F:" + to_string_dec_uint(frequency) + "Hz ";
|
||||
entry.reserve(256);
|
||||
|
||||
// Raw hex dump of all the bytes
|
||||
// for (size_t c = 0; c < packet.length(); c += 32)
|
||||
// entry += to_string_hex(packet.read(c, 32), 8) + " ";
|
||||
|
||||
for (size_t c = 0; c < 256; c += 32)
|
||||
entry += to_string_bin(packet.read(c, 32), 32);
|
||||
|
||||
log_file.write_entry(packet.received_at(), entry);
|
||||
}
|
||||
|
||||
/*void ACARSLogger::log_decoded(
|
||||
const acars::Packet& packet,
|
||||
const std::string text) {
|
||||
|
||||
log_file.write_entry(packet.timestamp(), text);
|
||||
const acars::Packet& packet,
|
||||
const std::string text) {
|
||||
|
||||
log_file.write_entry(packet.timestamp(), text);
|
||||
}*/
|
||||
|
||||
namespace ui {
|
||||
|
||||
void ACARSAppView::update_freq(rf::Frequency f) {
|
||||
set_target_frequency(f);
|
||||
portapack::persistent_memory::set_tuned_frequency(f); // Maybe not ?
|
||||
set_target_frequency(f);
|
||||
portapack::persistent_memory::set_tuned_frequency(f); // Maybe not ?
|
||||
}
|
||||
|
||||
ACARSAppView::ACARSAppView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_acars);
|
||||
baseband::run_image(portapack::spi_flash::image_tag_acars);
|
||||
|
||||
add_children({
|
||||
&rssi,
|
||||
&channel,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&field_frequency,
|
||||
&check_log,
|
||||
&console
|
||||
});
|
||||
|
||||
receiver_model.set_sampling_rate(2457600);
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
receiver_model.enable();
|
||||
|
||||
field_frequency.set_value(receiver_model.tuning_frequency());
|
||||
update_freq(receiver_model.tuning_frequency());
|
||||
field_frequency.set_step(receiver_model.frequency_step());
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
update_freq(f);
|
||||
};
|
||||
field_frequency.on_edit = [this, &nav]() {
|
||||
// TODO: Provide separate modal method/scheme?
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
update_freq(f);
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
check_log.set_value(logging);
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
logger = std::make_unique<ACARSLogger>();
|
||||
if (logger)
|
||||
logger->append(LOG_ROOT_DIR "/ACARS.TXT");
|
||||
add_children({&rssi,
|
||||
&channel,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&field_frequency,
|
||||
&check_log,
|
||||
&console});
|
||||
|
||||
receiver_model.set_sampling_rate(2457600);
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
receiver_model.enable();
|
||||
|
||||
field_frequency.set_value(receiver_model.tuning_frequency());
|
||||
update_freq(receiver_model.tuning_frequency());
|
||||
field_frequency.set_step(receiver_model.frequency_step());
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
update_freq(f);
|
||||
};
|
||||
field_frequency.on_edit = [this, &nav]() {
|
||||
// TODO: Provide separate modal method/scheme?
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
update_freq(f);
|
||||
field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
check_log.set_value(logging);
|
||||
check_log.on_select = [this](Checkbox&, bool v) {
|
||||
logging = v;
|
||||
};
|
||||
|
||||
logger = std::make_unique<ACARSLogger>();
|
||||
if (logger)
|
||||
logger->append(LOG_ROOT_DIR "/ACARS.TXT");
|
||||
}
|
||||
|
||||
ACARSAppView::~ACARSAppView() {
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
void ACARSAppView::focus() {
|
||||
field_frequency.focus();
|
||||
field_frequency.focus();
|
||||
}
|
||||
|
||||
void ACARSAppView::on_packet(const acars::Packet& packet) {
|
||||
std::string console_info;
|
||||
|
||||
/*if (!packet.is_valid()) {
|
||||
console_info = to_string_datetime(packet.received_at(), HMS);
|
||||
console_info += " INVALID";
|
||||
|
||||
console.writeln(console_info);
|
||||
} else {
|
||||
console_info = to_string_datetime(packet.received_at(), HMS);
|
||||
console_info += ":" + to_string_bin(packet.read(0, 32), 32);
|
||||
//console_info += " REG:" + packet.registration_number();
|
||||
|
||||
console.writeln(console_info);
|
||||
}*/
|
||||
|
||||
packet_counter++;
|
||||
if (packet_counter % 10 == 0)
|
||||
console.writeln("Block #" + to_string_dec_uint(packet_counter));
|
||||
|
||||
// Log raw data whatever it contains
|
||||
if (logger && logging)
|
||||
logger->log_raw_data(packet, target_frequency());
|
||||
std::string console_info;
|
||||
|
||||
/*if (!packet.is_valid()) {
|
||||
console_info = to_string_datetime(packet.received_at(), HMS);
|
||||
console_info += " INVALID";
|
||||
|
||||
console.writeln(console_info);
|
||||
} else {
|
||||
console_info = to_string_datetime(packet.received_at(), HMS);
|
||||
console_info += ":" + to_string_bin(packet.read(0, 32), 32);
|
||||
//console_info += " REG:" + packet.registration_number();
|
||||
|
||||
console.writeln(console_info);
|
||||
}*/
|
||||
|
||||
packet_counter++;
|
||||
if (packet_counter % 10 == 0)
|
||||
console.writeln("Block #" + to_string_dec_uint(packet_counter));
|
||||
|
||||
// Log raw data whatever it contains
|
||||
if (logger && logging)
|
||||
logger->log_raw_data(packet, target_frequency());
|
||||
}
|
||||
|
||||
void ACARSAppView::set_target_frequency(const uint32_t new_value) {
|
||||
target_frequency_ = new_value;
|
||||
receiver_model.set_tuning_frequency(new_value);
|
||||
target_frequency_ = new_value;
|
||||
receiver_model.set_tuning_frequency(new_value);
|
||||
}
|
||||
|
||||
uint32_t ACARSAppView::target_frequency() const {
|
||||
return target_frequency_;
|
||||
return target_frequency_;
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue