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