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"
|
|
|
|
|
|
|
|
#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() {
|
2017-01-15 22:45:44 -05:00
|
|
|
transmitter_model.set_sampling_rate(2280000U);
|
2016-12-05 06:56:41 -05:00
|
|
|
transmitter_model.set_rf_amp(true);
|
|
|
|
transmitter_model.set_baseband_bandwidth(1750000);
|
|
|
|
transmitter_model.enable();
|
|
|
|
|
|
|
|
baseband::set_rds_data(message_length);
|
2016-05-29 06:06:47 -04:00
|
|
|
}
|
|
|
|
|
2017-02-07 17:12:20 -05:00
|
|
|
void RDSView::paint(Painter&) {
|
2016-05-29 06:06:47 -04:00
|
|
|
text_psn.set(PSN);
|
2017-04-18 13:12:32 -04:00
|
|
|
text_radiotexta.set(RadioText.substr(0, 16));
|
|
|
|
text_radiotextb.set(RadioText.substr(16, 16));
|
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
|
|
|
|
2017-04-18 13:12:32 -04:00
|
|
|
PSN = "TEST1234";
|
|
|
|
RadioText = "Radiotext test ABCD1234";
|
2015-08-28 14:50:42 -04:00
|
|
|
|
2017-01-15 22:45:44 -05:00
|
|
|
add_children({
|
2017-02-13 00:35:13 -05:00
|
|
|
&labels,
|
2016-05-27 19:59:13 -04:00
|
|
|
&options_pty,
|
2016-05-29 06:06:47 -04:00
|
|
|
&options_countrycode,
|
|
|
|
&options_coverage,
|
2016-12-09 12:21:47 -05:00
|
|
|
&options_tx,
|
|
|
|
&check_mono_stereo,
|
|
|
|
&check_TA,
|
|
|
|
&check_TP,
|
|
|
|
&check_MS,
|
|
|
|
&sym_pi_code,
|
2016-05-29 06:06:47 -04:00
|
|
|
&button_editpsn,
|
|
|
|
&text_psn,
|
|
|
|
&button_editradiotext,
|
|
|
|
&text_radiotexta,
|
|
|
|
&text_radiotextb,
|
2017-02-07 17:12:20 -05:00
|
|
|
&tx_view,
|
2017-01-15 22:45:44 -05:00
|
|
|
});
|
2015-08-28 14:50:42 -04:00
|
|
|
|
2017-02-07 17:12:20 -05:00
|
|
|
tx_view.on_edit_frequency = [this, &nav]() {
|
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
2016-05-27 19:59:13 -04:00
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
2017-02-07 17:12:20 -05:00
|
|
|
receiver_model.set_tuning_frequency(f);
|
2016-12-05 06:56:41 -05:00
|
|
|
this->on_tuning_frequency_changed(f);
|
2016-05-27 19:59:13 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-02-07 17:12:20 -05:00
|
|
|
tx_view.on_start = [this]() {
|
|
|
|
tx_view.set_transmitting(true);
|
|
|
|
rds_flags.PI_code = sym_pi_code.value_hex_u64();
|
|
|
|
rds_flags.PTY = options_pty.selected_index_value();
|
|
|
|
rds_flags.DI = check_mono_stereo.value() ? 1 : 0;
|
|
|
|
rds_flags.TP = check_TP.value();
|
|
|
|
rds_flags.TA = check_TA.value();
|
|
|
|
rds_flags.MS = check_MS.value();
|
|
|
|
|
|
|
|
if (options_tx.selected_index() == 0)
|
|
|
|
message_length = gen_PSN(PSN, &rds_flags);
|
|
|
|
else if (options_tx.selected_index() == 1)
|
|
|
|
message_length = gen_RadioText(RadioText, 0, &rds_flags);
|
|
|
|
else
|
|
|
|
message_length = gen_ClockTime(&rds_flags, 2016, 12, 1, 9, 23, 2);
|
|
|
|
|
|
|
|
txing = true;
|
|
|
|
start_tx();
|
|
|
|
};
|
|
|
|
|
|
|
|
tx_view.on_stop = [this]() {
|
|
|
|
tx_view.set_transmitting(false);
|
|
|
|
transmitter_model.disable();
|
|
|
|
txing = false;
|
|
|
|
};
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
check_TA.set_value(true);
|
|
|
|
check_TP.set_value(true);
|
|
|
|
|
2017-03-13 00:09:21 -04:00
|
|
|
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);
|
2016-12-09 12:21:47 -05:00
|
|
|
sym_pi_code.on_change = [this]() {
|
|
|
|
rds_flags.PI_code = sym_pi_code.value_hex_u64();
|
|
|
|
};
|
2016-05-27 19:59:13 -04:00
|
|
|
|
2016-12-08 20:35:50 -05:00
|
|
|
options_pty.set_selected_index(0); // None
|
2016-12-09 12:21:47 -05:00
|
|
|
options_countrycode.set_selected_index(18); // Baguette du fromage
|
|
|
|
options_coverage.set_selected_index(0); // Local
|
|
|
|
|
|
|
|
button_editpsn.on_select = [this, &nav](Button&) {
|
2017-06-20 22:25:27 -04:00
|
|
|
text_prompt(nav, &PSN, 8);
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
2015-08-28 14:50:42 -04:00
|
|
|
|
2016-12-08 15:08:53 -05:00
|
|
|
button_editradiotext.on_select = [this, &nav](Button&){
|
2017-06-20 22:25:27 -04:00
|
|
|
text_prompt(nav, &RadioText, 24);
|
2016-05-29 06:06:47 -04:00
|
|
|
};
|
2015-08-28 14:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|