2015-09-10 18:36:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-12-09 17:21:47 +00:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-09-10 18:36:39 +00: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.
|
|
|
|
*/
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
#include "ui_siggen.hpp"
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
#include "tonesets.hpp"
|
|
|
|
#include "portapack.hpp"
|
2017-04-18 11:55:49 +00:00
|
|
|
#include "baseband_api.hpp"
|
2015-09-10 18:36:39 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-04-18 11:55:49 +00:00
|
|
|
using namespace portapack;
|
2015-09-10 18:36:39 +00:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
void SigGenView::focus() {
|
|
|
|
options_shape.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
SigGenView::~SigGenView() {
|
|
|
|
transmitter_model.disable();
|
|
|
|
baseband::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SigGenView::start_tx() {
|
2017-04-18 11:55:49 +00:00
|
|
|
transmitter_model.set_sampling_rate(1536000);
|
|
|
|
transmitter_model.set_rf_amp(true);
|
|
|
|
transmitter_model.set_baseband_bandwidth(1750000);
|
|
|
|
transmitter_model.enable();
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
baseband::set_siggen_tone(symfield_tone.value_dec_u32());
|
2017-04-18 11:55:49 +00:00
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
auto duration = field_stop.value();
|
|
|
|
if (!checkbox_auto.value())
|
|
|
|
duration = 0;
|
2017-08-12 18:28:57 +00:00
|
|
|
baseband::set_siggen_config(transmitter_model.channel_bandwidth(), options_shape.selected_index_value(), duration);
|
2015-09-10 18:36:39 +00:00
|
|
|
}
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
void SigGenView::update_tone() {
|
|
|
|
baseband::set_siggen_tone(symfield_tone.value_dec_u32());
|
2015-09-10 18:36:39 +00:00
|
|
|
}
|
|
|
|
|
2017-09-24 19:05:42 +00:00
|
|
|
void SigGenView::on_tx_progress(const uint32_t progress, const bool done) {
|
|
|
|
(void) progress;
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
if (done)
|
|
|
|
tx_view.set_transmitting(false);
|
2017-04-18 11:55:49 +00:00
|
|
|
}
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
SigGenView::SigGenView(
|
2016-12-09 17:21:47 +00:00
|
|
|
NavigationView& nav
|
|
|
|
)
|
2015-09-10 18:36:39 +00:00
|
|
|
{
|
2017-07-18 18:31:05 +00:00
|
|
|
baseband::run_image(portapack::spi_flash::image_tag_siggen);
|
2017-04-18 11:55:49 +00:00
|
|
|
|
2017-01-16 03:45:44 +00:00
|
|
|
add_children({
|
2017-04-18 11:55:49 +00:00
|
|
|
&labels,
|
2017-07-18 18:31:05 +00:00
|
|
|
&options_shape,
|
|
|
|
&text_shape,
|
|
|
|
&symfield_tone,
|
|
|
|
&button_update,
|
|
|
|
&checkbox_auto,
|
2017-04-18 11:55:49 +00:00
|
|
|
&checkbox_stop,
|
|
|
|
&field_stop,
|
|
|
|
&tx_view
|
2017-01-16 03:45:44 +00:00
|
|
|
});
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
options_shape.on_change = [this](size_t, OptionsField::value_t v) {
|
|
|
|
text_shape.set(shape_strings[v]);
|
|
|
|
};
|
|
|
|
options_shape.set_selected_index(0);
|
|
|
|
text_shape.set(shape_strings[0]);
|
|
|
|
|
|
|
|
symfield_tone.set_sym(1, 1); // Default: 1000 Hz
|
|
|
|
symfield_tone.on_change = [this]() {
|
|
|
|
if (auto_update)
|
|
|
|
update_tone();
|
|
|
|
};
|
|
|
|
|
|
|
|
button_update.on_select = [this](Button&) {
|
|
|
|
update_tone();
|
|
|
|
};
|
|
|
|
|
|
|
|
checkbox_auto.on_select = [this](Checkbox&, bool v) {
|
|
|
|
auto_update = v;
|
|
|
|
};
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-04-18 11:55:49 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
};
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-04-18 11:55:49 +00:00
|
|
|
tx_view.on_start = [this]() {
|
2017-07-18 18:31:05 +00:00
|
|
|
start_tx();
|
|
|
|
tx_view.set_transmitting(true);
|
2017-04-18 11:55:49 +00:00
|
|
|
};
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-04-18 11:55:49 +00:00
|
|
|
tx_view.on_stop = [this]() {
|
2017-07-18 18:31:05 +00:00
|
|
|
transmitter_model.disable();
|
|
|
|
tx_view.set_transmitting(false);
|
2017-04-18 11:55:49 +00:00
|
|
|
};
|
2017-07-18 18:31:05 +00:00
|
|
|
|
2015-09-10 18:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|