mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-22 22:04:24 -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
|
@ -35,245 +35,228 @@ using namespace rds;
|
|||
namespace ui {
|
||||
|
||||
RDSPSNView::RDSPSNView(
|
||||
NavigationView& nav,
|
||||
Rect parent_rect
|
||||
) : OptionTabView(parent_rect)
|
||||
{
|
||||
set_type("PSN");
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&text_psn,
|
||||
&button_set,
|
||||
&check_mono_stereo,
|
||||
&check_TA,
|
||||
&check_MS
|
||||
});
|
||||
|
||||
set_enabled(true);
|
||||
|
||||
check_TA.set_value(true);
|
||||
|
||||
check_mono_stereo.on_select = [this](Checkbox&, bool value) {
|
||||
mono_stereo = value;
|
||||
};
|
||||
check_TA.on_select = [this](Checkbox&, bool value) {
|
||||
TA = value;
|
||||
};
|
||||
check_MS.on_select = [this](Checkbox&, bool value) {
|
||||
MS = value;
|
||||
};
|
||||
|
||||
button_set.on_select = [this, &nav](Button&) {
|
||||
text_prompt(
|
||||
nav,
|
||||
PSN,
|
||||
8,
|
||||
[this](std::string& s) {
|
||||
text_psn.set(s);
|
||||
}
|
||||
);
|
||||
};
|
||||
NavigationView& nav,
|
||||
Rect parent_rect)
|
||||
: OptionTabView(parent_rect) {
|
||||
set_type("PSN");
|
||||
|
||||
add_children({&labels,
|
||||
&text_psn,
|
||||
&button_set,
|
||||
&check_mono_stereo,
|
||||
&check_TA,
|
||||
&check_MS});
|
||||
|
||||
set_enabled(true);
|
||||
|
||||
check_TA.set_value(true);
|
||||
|
||||
check_mono_stereo.on_select = [this](Checkbox&, bool value) {
|
||||
mono_stereo = value;
|
||||
};
|
||||
check_TA.on_select = [this](Checkbox&, bool value) {
|
||||
TA = value;
|
||||
};
|
||||
check_MS.on_select = [this](Checkbox&, bool value) {
|
||||
MS = value;
|
||||
};
|
||||
|
||||
button_set.on_select = [this, &nav](Button&) {
|
||||
text_prompt(
|
||||
nav,
|
||||
PSN,
|
||||
8,
|
||||
[this](std::string& s) {
|
||||
text_psn.set(s);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
RDSRadioTextView::RDSRadioTextView(
|
||||
NavigationView& nav,
|
||||
Rect parent_rect
|
||||
) : OptionTabView(parent_rect)
|
||||
{
|
||||
set_type("Radiotext");
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&button_set,
|
||||
&text_radiotext
|
||||
});
|
||||
|
||||
button_set.on_select = [this, &nav](Button&){
|
||||
text_prompt(
|
||||
nav,
|
||||
radiotext,
|
||||
28,
|
||||
[this](std::string& s) {
|
||||
text_radiotext.set(s);
|
||||
}
|
||||
);
|
||||
};
|
||||
NavigationView& nav,
|
||||
Rect parent_rect)
|
||||
: OptionTabView(parent_rect) {
|
||||
set_type("Radiotext");
|
||||
|
||||
add_children({&labels,
|
||||
&button_set,
|
||||
&text_radiotext});
|
||||
|
||||
button_set.on_select = [this, &nav](Button&) {
|
||||
text_prompt(
|
||||
nav,
|
||||
radiotext,
|
||||
28,
|
||||
[this](std::string& s) {
|
||||
text_radiotext.set(s);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
RDSDateTimeView::RDSDateTimeView(
|
||||
Rect parent_rect
|
||||
) : OptionTabView(parent_rect)
|
||||
{
|
||||
set_type("date & time");
|
||||
|
||||
add_children({
|
||||
&labels
|
||||
});
|
||||
Rect parent_rect)
|
||||
: OptionTabView(parent_rect) {
|
||||
set_type("date & time");
|
||||
|
||||
add_children({&labels});
|
||||
}
|
||||
|
||||
RDSAudioView::RDSAudioView(
|
||||
Rect parent_rect
|
||||
) : OptionTabView(parent_rect)
|
||||
{
|
||||
set_type("audio");
|
||||
|
||||
add_children({
|
||||
&labels
|
||||
});
|
||||
Rect parent_rect)
|
||||
: OptionTabView(parent_rect) {
|
||||
set_type("audio");
|
||||
|
||||
add_children({&labels});
|
||||
}
|
||||
|
||||
RDSThread::RDSThread(
|
||||
std::vector<RDSGroup>** frames
|
||||
) : frames_ { std::move(frames) }
|
||||
{
|
||||
thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, RDSThread::static_fn, this);
|
||||
std::vector<RDSGroup>** frames)
|
||||
: frames_{std::move(frames)} {
|
||||
thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, RDSThread::static_fn, this);
|
||||
}
|
||||
|
||||
RDSThread::~RDSThread() {
|
||||
if( thread ) {
|
||||
chThdTerminate(thread);
|
||||
chThdWait(thread);
|
||||
thread = nullptr;
|
||||
}
|
||||
if (thread) {
|
||||
chThdTerminate(thread);
|
||||
chThdWait(thread);
|
||||
thread = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
msg_t RDSThread::static_fn(void* arg) {
|
||||
auto obj = static_cast<RDSThread*>(arg);
|
||||
obj->run();
|
||||
return 0;
|
||||
auto obj = static_cast<RDSThread*>(arg);
|
||||
obj->run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RDSThread::run() {
|
||||
std::vector<RDSGroup>* frame_ptr;
|
||||
size_t block_count, c;
|
||||
uint32_t * tx_data_u32 = (uint32_t*)shared_memory.bb_data.data;
|
||||
uint32_t frame_index = 0;
|
||||
|
||||
while( !chThdShouldTerminate() ) {
|
||||
std::vector<RDSGroup>* frame_ptr;
|
||||
size_t block_count, c;
|
||||
uint32_t* tx_data_u32 = (uint32_t*)shared_memory.bb_data.data;
|
||||
uint32_t frame_index = 0;
|
||||
|
||||
do {
|
||||
frame_ptr = frames_[frame_index];
|
||||
|
||||
if (frame_index == 2) {
|
||||
frame_index = 0;
|
||||
} else {
|
||||
frame_index++;
|
||||
}
|
||||
} while(!(block_count = frame_ptr->size() * 4));
|
||||
|
||||
for (c = 0; c < block_count; c++)
|
||||
tx_data_u32[c] = frame_ptr->at(c >> 2).block[c & 3];
|
||||
|
||||
baseband::set_rds_data(block_count * 26);
|
||||
|
||||
chThdSleepMilliseconds(1000);
|
||||
}
|
||||
while (!chThdShouldTerminate()) {
|
||||
do {
|
||||
frame_ptr = frames_[frame_index];
|
||||
|
||||
if (frame_index == 2) {
|
||||
frame_index = 0;
|
||||
} else {
|
||||
frame_index++;
|
||||
}
|
||||
} while (!(block_count = frame_ptr->size() * 4));
|
||||
|
||||
for (c = 0; c < block_count; c++)
|
||||
tx_data_u32[c] = frame_ptr->at(c >> 2).block[c & 3];
|
||||
|
||||
baseband::set_rds_data(block_count * 26);
|
||||
|
||||
chThdSleepMilliseconds(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void RDSView::focus() {
|
||||
tab_view.focus();
|
||||
tab_view.focus();
|
||||
}
|
||||
|
||||
RDSView::~RDSView() {
|
||||
// save app settings
|
||||
app_settings.tx_frequency = transmitter_model.tuning_frequency();
|
||||
settings.save("tx_rds", &app_settings);
|
||||
// save app settings
|
||||
app_settings.tx_frequency = transmitter_model.tuning_frequency();
|
||||
settings.save("tx_rds", &app_settings);
|
||||
|
||||
transmitter_model.disable();
|
||||
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit.
|
||||
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
|
||||
transmitter_model.disable();
|
||||
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit.
|
||||
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
|
||||
}
|
||||
|
||||
void RDSView::start_tx() {
|
||||
rds_flags.PI_code = sym_pi_code.value_hex_u64();
|
||||
rds_flags.PTY = options_pty.selected_index_value();
|
||||
rds_flags.DI = view_PSN.mono_stereo ? 1 : 0;
|
||||
rds_flags.TP = check_TP.value();
|
||||
rds_flags.TA = view_PSN.TA;
|
||||
rds_flags.MS = view_PSN.MS;
|
||||
|
||||
if (view_PSN.is_enabled())
|
||||
gen_PSN(frame_psn, view_PSN.PSN, &rds_flags);
|
||||
else
|
||||
frame_psn.clear();
|
||||
|
||||
if (view_radiotext.is_enabled())
|
||||
gen_RadioText(frame_radiotext, view_radiotext.radiotext, 0, &rds_flags);
|
||||
else
|
||||
frame_radiotext.clear();
|
||||
|
||||
// DEBUG
|
||||
if (view_datetime.is_enabled())
|
||||
gen_ClockTime(frame_datetime, &rds_flags, 2016, 12, 1, 9, 23, 2);
|
||||
else
|
||||
frame_datetime.clear();
|
||||
|
||||
transmitter_model.set_sampling_rate(2280000U);
|
||||
transmitter_model.set_baseband_bandwidth(1750000);
|
||||
transmitter_model.enable();
|
||||
|
||||
tx_thread = std::make_unique<RDSThread>(frames);
|
||||
rds_flags.PI_code = sym_pi_code.value_hex_u64();
|
||||
rds_flags.PTY = options_pty.selected_index_value();
|
||||
rds_flags.DI = view_PSN.mono_stereo ? 1 : 0;
|
||||
rds_flags.TP = check_TP.value();
|
||||
rds_flags.TA = view_PSN.TA;
|
||||
rds_flags.MS = view_PSN.MS;
|
||||
|
||||
if (view_PSN.is_enabled())
|
||||
gen_PSN(frame_psn, view_PSN.PSN, &rds_flags);
|
||||
else
|
||||
frame_psn.clear();
|
||||
|
||||
if (view_radiotext.is_enabled())
|
||||
gen_RadioText(frame_radiotext, view_radiotext.radiotext, 0, &rds_flags);
|
||||
else
|
||||
frame_radiotext.clear();
|
||||
|
||||
// DEBUG
|
||||
if (view_datetime.is_enabled())
|
||||
gen_ClockTime(frame_datetime, &rds_flags, 2016, 12, 1, 9, 23, 2);
|
||||
else
|
||||
frame_datetime.clear();
|
||||
|
||||
transmitter_model.set_sampling_rate(2280000U);
|
||||
transmitter_model.set_baseband_bandwidth(1750000);
|
||||
transmitter_model.enable();
|
||||
|
||||
tx_thread = std::make_unique<RDSThread>(frames);
|
||||
}
|
||||
|
||||
RDSView::RDSView(
|
||||
NavigationView& nav
|
||||
) : nav_ { nav }
|
||||
{
|
||||
baseband::run_image(portapack::spi_flash::image_tag_rds);
|
||||
|
||||
add_children({
|
||||
&tab_view,
|
||||
&labels,
|
||||
&sym_pi_code,
|
||||
&check_TP,
|
||||
&options_pty,
|
||||
&view_PSN,
|
||||
&view_radiotext,
|
||||
&view_datetime,
|
||||
&view_audio,
|
||||
&tx_view,
|
||||
});
|
||||
NavigationView& nav)
|
||||
: nav_{nav} {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_rds);
|
||||
|
||||
// load app settings
|
||||
auto rc = settings.load("tx_rds", &app_settings);
|
||||
if(rc == SETTINGS_OK) {
|
||||
transmitter_model.set_rf_amp(app_settings.tx_amp);
|
||||
transmitter_model.set_channel_bandwidth(app_settings.channel_bandwidth);
|
||||
transmitter_model.set_tuning_frequency(app_settings.tx_frequency);
|
||||
transmitter_model.set_tx_gain(app_settings.tx_gain);
|
||||
}
|
||||
check_TP.set_value(true);
|
||||
|
||||
sym_pi_code.set_sym(0, 0xF);
|
||||
sym_pi_code.set_sym(1, 0x3);
|
||||
sym_pi_code.set_sym(2, 0xE);
|
||||
sym_pi_code.set_sym(3, 0x0);
|
||||
sym_pi_code.on_change = [this]() {
|
||||
rds_flags.PI_code = sym_pi_code.value_hex_u64();
|
||||
};
|
||||
|
||||
options_pty.set_selected_index(0); // None
|
||||
|
||||
tx_view.on_edit_frequency = [this, &nav]() {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
};
|
||||
};
|
||||
|
||||
tx_view.on_start = [this]() {
|
||||
start_tx();
|
||||
tx_view.set_transmitting(true);
|
||||
txing = true;
|
||||
};
|
||||
|
||||
tx_view.on_stop = [this]() {
|
||||
// Kill tx_thread here ?
|
||||
tx_view.set_transmitting(false);
|
||||
transmitter_model.disable();
|
||||
txing = false;
|
||||
};
|
||||
add_children({
|
||||
&tab_view,
|
||||
&labels,
|
||||
&sym_pi_code,
|
||||
&check_TP,
|
||||
&options_pty,
|
||||
&view_PSN,
|
||||
&view_radiotext,
|
||||
&view_datetime,
|
||||
&view_audio,
|
||||
&tx_view,
|
||||
});
|
||||
|
||||
// load app settings
|
||||
auto rc = settings.load("tx_rds", &app_settings);
|
||||
if (rc == SETTINGS_OK) {
|
||||
transmitter_model.set_rf_amp(app_settings.tx_amp);
|
||||
transmitter_model.set_channel_bandwidth(app_settings.channel_bandwidth);
|
||||
transmitter_model.set_tuning_frequency(app_settings.tx_frequency);
|
||||
transmitter_model.set_tx_gain(app_settings.tx_gain);
|
||||
}
|
||||
check_TP.set_value(true);
|
||||
|
||||
sym_pi_code.set_sym(0, 0xF);
|
||||
sym_pi_code.set_sym(1, 0x3);
|
||||
sym_pi_code.set_sym(2, 0xE);
|
||||
sym_pi_code.set_sym(3, 0x0);
|
||||
sym_pi_code.on_change = [this]() {
|
||||
rds_flags.PI_code = sym_pi_code.value_hex_u64();
|
||||
};
|
||||
|
||||
options_pty.set_selected_index(0); // None
|
||||
|
||||
tx_view.on_edit_frequency = [this, &nav]() {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
};
|
||||
};
|
||||
|
||||
tx_view.on_start = [this]() {
|
||||
start_tx();
|
||||
tx_view.set_transmitting(true);
|
||||
txing = true;
|
||||
};
|
||||
|
||||
tx_view.on_stop = [this]() {
|
||||
// Kill tx_thread here ?
|
||||
tx_view.set_transmitting(false);
|
||||
transmitter_model.disable();
|
||||
txing = false;
|
||||
};
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue