2015-08-28 14:50:42 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-05-27 19:59:13 -04:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-08-28 14:50:42 -04:00
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui_rds.hpp"
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
#include "rds.hpp"
|
2015-08-28 14:50:42 -04:00
|
|
|
#include "portapack.hpp"
|
2016-07-26 21:03:40 -04:00
|
|
|
#include "baseband_api.hpp"
|
2015-08-28 14:50:42 -04:00
|
|
|
#include "portapack_shared_memory.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
2016-02-04 04:27:53 -05:00
|
|
|
using namespace portapack;
|
2016-12-05 06:56:41 -05:00
|
|
|
using namespace rds;
|
2015-08-28 14:50:42 -04:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
void RDSView::focus() {
|
2016-05-29 06:06:47 -04:00
|
|
|
button_editpsn.focus();
|
2015-08-28 14:50:42 -04:00
|
|
|
}
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
void RDSView::on_tuning_frequency_changed(rf::Frequency f) {
|
|
|
|
transmitter_model.set_tuning_frequency(f);
|
2016-05-27 19:59:13 -04:00
|
|
|
}
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
RDSView::~RDSView() {
|
|
|
|
transmitter_model.disable();
|
|
|
|
baseband::shutdown();
|
2016-05-29 06:06:47 -04:00
|
|
|
}
|
2015-08-28 14:50:42 -04:00
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
void RDSView::start_tx() {
|
|
|
|
transmitter_model.set_baseband_configuration({
|
|
|
|
.mode = 0,
|
|
|
|
.sampling_rate = 2280000,
|
|
|
|
.decimation_factor = 1,
|
|
|
|
});
|
|
|
|
transmitter_model.set_rf_amp(true);
|
|
|
|
transmitter_model.set_lna(40);
|
|
|
|
transmitter_model.set_vga(40);
|
|
|
|
transmitter_model.set_baseband_bandwidth(1750000);
|
|
|
|
transmitter_model.enable();
|
|
|
|
|
|
|
|
baseband::set_rds_data(message_length);
|
2016-05-29 06:06:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RDSView::paint(Painter& painter) {
|
|
|
|
char RadioTextA[17];
|
|
|
|
(void)painter;
|
|
|
|
|
|
|
|
text_psn.set(PSN);
|
2016-12-05 06:56:41 -05:00
|
|
|
|
2016-05-29 06:06:47 -04:00
|
|
|
memcpy(RadioTextA, RadioText, 16);
|
|
|
|
RadioTextA[16] = 0;
|
|
|
|
text_radiotexta.set(RadioTextA);
|
2016-12-05 06:56:41 -05:00
|
|
|
memcpy(RadioTextA, RadioText + 16, 8);
|
|
|
|
RadioTextA[8] = 0;
|
|
|
|
text_radiotextb.set(RadioTextA);
|
2015-08-28 14:50:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-26 21:03:40 -04:00
|
|
|
RDSView::RDSView(NavigationView& nav) {
|
|
|
|
baseband::run_image(portapack::spi_flash::image_tag_rds);
|
2016-05-29 06:06:47 -04:00
|
|
|
|
|
|
|
strcpy(PSN, "TEST1234");
|
2016-12-05 06:56:41 -05:00
|
|
|
strcpy(RadioText, "Radiotext test ABCD1234");
|
2015-08-28 14:50:42 -04:00
|
|
|
|
|
|
|
add_children({ {
|
2016-05-27 19:59:13 -04:00
|
|
|
&field_frequency,
|
|
|
|
&options_pty,
|
2016-05-29 06:06:47 -04:00
|
|
|
&options_countrycode,
|
|
|
|
&options_coverage,
|
|
|
|
&text_tx,
|
|
|
|
&button_editpsn,
|
|
|
|
&text_psn,
|
|
|
|
&button_txpsn,
|
|
|
|
&button_editradiotext,
|
|
|
|
&text_radiotexta,
|
|
|
|
&text_radiotextb,
|
|
|
|
&button_txradiotext,
|
2015-08-28 14:50:42 -04:00
|
|
|
&button_exit
|
|
|
|
} });
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
field_frequency.set_value(transmitter_model.tuning_frequency());
|
|
|
|
field_frequency.set_step(50000); // 50kHz steps
|
|
|
|
field_frequency.on_change = [this](rf::Frequency f) {
|
|
|
|
this->on_tuning_frequency_changed(f);
|
|
|
|
};
|
2016-05-27 19:59:13 -04:00
|
|
|
field_frequency.on_edit = [this, &nav]() {
|
2016-12-05 06:56:41 -05:00
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(field_frequency.value());
|
2016-05-27 19:59:13 -04:00
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
|
|
|
this->field_frequency.set_value(f);
|
2016-12-05 06:56:41 -05:00
|
|
|
this->on_tuning_frequency_changed(f);
|
2016-05-27 19:59:13 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-05-29 06:06:47 -04:00
|
|
|
options_pty.set_selected_index(0); // None
|
|
|
|
options_countrycode.set_selected_index(18); // France
|
|
|
|
options_coverage.set_selected_index(0); // Local
|
2016-05-27 19:59:13 -04:00
|
|
|
|
2016-05-29 06:06:47 -04:00
|
|
|
button_editpsn.on_select = [this,&nav](Button&){
|
|
|
|
textentry(nav, PSN, 8);
|
|
|
|
};
|
|
|
|
button_txpsn.on_select = [this](Button&){
|
|
|
|
if (txing) {
|
|
|
|
button_txpsn.set_text("PSN");
|
|
|
|
button_txradiotext.set_text("Radiotext");
|
2016-12-05 06:56:41 -05:00
|
|
|
transmitter_model.disable();
|
2016-05-29 06:06:47 -04:00
|
|
|
txing = false;
|
|
|
|
} else {
|
2016-12-05 06:56:41 -05:00
|
|
|
message_length = gen_PSN(PSN, options_pty.selected_index());
|
2016-05-29 06:06:47 -04:00
|
|
|
button_txpsn.set_text("STOP");
|
|
|
|
txing = true;
|
2016-12-05 06:56:41 -05:00
|
|
|
start_tx();
|
2016-05-29 06:06:47 -04:00
|
|
|
}
|
2015-08-28 14:50:42 -04:00
|
|
|
};
|
|
|
|
|
2016-05-29 06:06:47 -04:00
|
|
|
button_editradiotext.on_select = [this,&nav](Button&){
|
|
|
|
textentry(nav, RadioText, 24);
|
|
|
|
};
|
|
|
|
button_txradiotext.on_select = [this](Button&){
|
|
|
|
if (txing) {
|
|
|
|
button_txpsn.set_text("PSN");
|
|
|
|
button_txradiotext.set_text("Radiotext");
|
2016-12-05 06:56:41 -05:00
|
|
|
transmitter_model.disable();
|
2016-05-29 06:06:47 -04:00
|
|
|
txing = false;
|
|
|
|
} else {
|
2016-12-05 06:56:41 -05:00
|
|
|
message_length = gen_RadioText(RadioText, options_pty.selected_index());
|
2016-05-29 06:06:47 -04:00
|
|
|
button_txradiotext.set_text("STOP");
|
|
|
|
txing = true;
|
2016-12-05 06:56:41 -05:00
|
|
|
start_tx();
|
2016-05-29 06:06:47 -04:00
|
|
|
}
|
2015-08-28 14:50:42 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
button_exit.on_select = [&nav](Button&){
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|